'From etoys3.0 of 7 March 2008 [latest update: #1939] on 28 March 2008 at 4:44:24 pm'! "Change Set: DBus-Core-bf-38 Date: 27 March 2008 Author: Bert Freudenberg Name: DBus-Core-bf.38 Author: bf Time: 27 March 2008, 4:45:37 pm UUID: cc92dc8e-0804-45e4-bd6b-9ca0670f1928 Ancestors: DBus-Core-bf.37 - rename bool to boolean - nicer signature names"! !DBusConnection commentStamp: '' prior: 0! I represent a connection to the DBus (see http://dbus.freedesktop.org/). connectionIndex: 0 for session bus, 1 for system bus semaIndex: index of the read semaphore in the externalObjects array This class is known to the DBus plugin. The connectionIndex and semaIndex must be the first instance variables in the class. The plugin automatically connects to the DBus when a primitive of me is called.! !Boolean methodsFor: '*DBus-Core' stamp: 'bf 3/27/2008 14:35'! dbusType ^ DBusArgument boolean! ! !DBusArgument class methodsFor: 'types' stamp: 'bf 3/27/2008 14:36'! boolean ^ $b! ! !DBusArgument class methodsFor: 'instance creation' stamp: 'bf 3/27/2008 14:36'! boolean: arg ^ self value: arg type: self boolean ! ! !DBusArgument class methodsFor: 'utilities' stamp: 'bf 3/27/2008 16:16'! nameOfSignature: aSignature "Answer a capitalized readable name for this signature, including one level of contained types" | entry | ^String streamContents: [:stream | self signaturesIn: aSignature do: [:sig | stream nextPutAll: (sig first caseOf: { [$a] -> [ sig second caseOf: { [${] -> ['Dictionary']. [$a] -> [sig third = ${ ifTrue: ['ArrayOfDictionaries'] ifFalse: ['ArrayOfArrays']] } otherwise: ['ArrayOf', (self nameOfType: sig second) capitalized, 's']]. [${] -> [entry := self splitSignature: sig allButFirst allButLast. 'DictEntryMapping', (self nameOfType: entry first first) capitalized, 'To', (self nameOfType: entry second first) capitalized]. [$(] -> [String streamContents: [:s | s nextPutAll: 'StructWith'. (self splitSignature: sig allButFirst allButLast) do: [:each | s nextPutAll: (self nameOfType: each) capitalized] separatedBy: [s nextPutAll: 'And']]] } otherwise: [(self nameOfType: sig first) capitalized])]] "self nameOfSignature: 'a{s(six)}'"! ! !DBusArgument class methodsFor: 'utilities' stamp: 'bf 3/27/2008 14:35'! typesAndNames ^#( $a array $b boolean $y byte $e dictEntry ${ dictEntry $d double $n int16 $i int32 $x int64 $o objectPath $g signature $s string $r struct $( struct $q uint16 $u uint32 $t uint64 $v variant)! ! !DBusConnection methodsFor: 'arguments-read' stamp: 'bf 3/27/2008 14:37'! argumentReadBoolean ^ DBusArgument boolean: self primArgumentGetBool! ! !DBusConnection class methodsFor: 'class initialization' stamp: 'bf 3/27/2008 14:37'! initialize "self initialize" "start up before AutoStart". Smalltalk addToStartUpList: self after: FileDirectory. Readers := { $b->#argumentReadBoolean. $d->#argumentReadDouble. $s->#argumentReadString. $a->#argumentReadArray. $e->#argumentReadDictEntry. $r->#argumentReadStruct. $o->#argumentReadObjectPath. $v->#argumentReadVariant. $y->#argumentReadByte. $n->#argumentReadInt16. $q->#argumentReadUInt16. $i->#argumentReadInt32. $u->#argumentReadUInt32. $x->#argumentReadInt64. $t->#argumentReadUInt64. $g->#argumentReadSignature. } as: Dictionary. Writers := { $b->#argumentWriteBasicArgument:. $i->#argumentWriteBasicArgument:. $d->#argumentWriteBasicArgument:. $s->#argumentWriteBasicArgument:. $y->#argumentWriteBasicArgument:. $n->#argumentWriteBasicArgument:. $q->#argumentWriteBasicArgument:. $u->#argumentWriteBasicArgument:. $x->#argumentWriteBasicArgument:. $t->#argumentWriteBasicArgument:. $o->#argumentWriteBasicArgument:. $g->#argumentWriteBasicArgument:. $a->#argumentWriteArray:. $e->#argumentWriteDictEntry:. $r->#argumentWriteStruct:. $v->#argumentWriteVariant:. } as: Dictionary. ! ! !DBusMessage class methodsFor: 'examples' stamp: 'bf 3/27/2008 14:37'! testMethodCall "create a new method call" | msg | msg := DBusMessageMethodCall destination: 'org.squeak.dbus.example' path: '/org/squeak/dbus/example' interface: 'org.squeak.dbus.testinterface' selector: 'testselector'. "add some arguments" msg addArgument: (DBusArgument boolean: false). "boolean" msg addArgument: (DBusArgument int32: 125487). "integer 32" msg addArgument: (DBusArgument array: {'element 0'. 'element 1'. 'element 2'} signature: 'as'). "3 element array of strings" msg addArgument: (DBusArgument variant: (DBusArgument uint64: 45879245651)). "variant with an unsigned integer 64" ^msg ! ! DBusConnection initialize! DBusConnection removeSelector: #argumentReadBool! DBusArgument class removeSelector: #bool! DBusArgument class removeSelector: #bool:!