Tcl DBus Interface

Check-in [8d96b7b74f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:- Add some clarifications to the man page. - Correctly clean up old information when a signal is defined. - Reverse part of overenthusiastic code clean up.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:8d96b7b74f13143b9e4dc8e244796c24f7a2a7e478b29f13e55b80799d965e62
User & Date: schelte 2015-06-18 08:05:13
Context
2015-06-18
08:53
- Summarize the changes since version 1.1 Leaf check-in: 11109db44f user: schelte tags: trunk, release-1-2
08:05
- Add some clarifications to the man page. - Correctly clean up old information when a signal is defined. - Reverse part of overenthusiastic code clean up. check-in: 8d96b7b74f user: schelte tags: trunk
2015-04-27
19:47
- Allow the application to trigger a PropertiesChanged signal instead of delaying it until the application is idle. - Provide a method to completely disable the PropertiesChanged feature. - Provide a way to add/replace methods and signals for standard interfaces. - Completely clean up the old signal when reusing a signal ID. check-in: 598aca4a28 user: schelte tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to dbif.tcl.

252
253
254
255
256
257
258















259
260
261
262
263
264
265
...
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
    } else {
	# If the command is in another interpreter, we probably arived here
	# through an interp alias. In that case the calling context of that
	# interp is accessible via interp eval
	return [interp eval $interp [list namespace current]]
    }
}
















proc dbus::dbif::namecheck {name {thing Name}} {
    if {[string is wordchar -strict $name]} {return name}
    error "$thing contains invalid characters: \"$name\""
}

proc dbus::dbif::buscheck {name} {
................................................................................
	    }
	    set old [array names dbif *,$opath,$ointf]
	} else {
	    set old [list $obus,$opath,$ointf]
	}
	foreach o $old {
	    set sigs [dict get $dbif($o) signals]
    	    dict set $dbif($o) signals \
	      [lsearch -all -inline -exact -not $sigs $id]
	}
    }
    set signal($id) [dict merge $dict [args $in] [dict create meta $meta]]
    dict lappend dbif($bus,$path,$intf) signals $id
    return $id
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
...
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
    } else {
	# If the command is in another interpreter, we probably arived here
	# through an interp alias. In that case the calling context of that
	# interp is accessible via interp eval
	return [interp eval $interp [list namespace current]]
    }
}

# Access the miscellaneous information of a message
#
proc dbus::dbif::get {id name} {
    variable info
    if {![info exists info($id)]} {
	error "MessageID does not exist: \"$id\""
    }
    if {![dict exists $info($id) $name]} {
	set list [lsort [dict keys $info($id)]]
	lset list end "or [lindex $list end]"
	error "Unknown property: \"$name\". Must be [join $list ", "]"
    }
    return [dict get $info($id) $name]
}

proc dbus::dbif::namecheck {name {thing Name}} {
    if {[string is wordchar -strict $name]} {return name}
    error "$thing contains invalid characters: \"$name\""
}

proc dbus::dbif::buscheck {name} {
................................................................................
	    }
	    set old [array names dbif *,$opath,$ointf]
	} else {
	    set old [list $obus,$opath,$ointf]
	}
	foreach o $old {
	    set sigs [dict get $dbif($o) signals]
    	    dict set dbif($o) signals \
	      [lsearch -all -inline -exact -not $sigs $id]
	}
    }
    set signal($id) [dict merge $dict [args $in] [dict create meta $meta]]
    dict lappend dbif($bus,$path,$intf) signals $id
    return $id
}

Changes to doc/dbif.man.

31
32
33
34
35
36
37
38

39
40
41
42
43
44
45
..
56
57
58
59
60
61
62










63
64
65
66
67
68
69
one or more names to the current application.

[para]

The [option -yield] option specifies that the application will release the
requested name when some other application requests the same name and has
indicated that it wants to take over ownership of the name. The application
will be informed by a signal when it loses ownership of the name.


[para]

The [option -replace] option indicates that the application wants to take
over the ownership of the name from the application that is currently the
primary owner, if any. This request will only be honoured if the current
owner has indicated that it will release the name on request. See also the
................................................................................
[option -noqueue] option may be specified to indicate that the name request
should not be queued.

[para]

The command returns a list of names that have successfully been acquired.











[call [cmd [vset cmdname]] [method default] \
  [opt "[option -bus] [arg bustype]"] \
  [opt "[option -interface] [arg interface]"]]

Generally an application will perform several [cmd [vset cmdname]] commands
related to the same message bus and interface. To avoid having to pass the
same values for the [option -bus] and [option -interface] options with all







|
>







 







>
>
>
>
>
>
>
>
>
>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
one or more names to the current application.

[para]

The [option -yield] option specifies that the application will release the
requested name when some other application requests the same name and has
indicated that it wants to take over ownership of the name. The application
will be informed by a [emph NameLost] signal when it loses ownership of the
name.

[para]

The [option -replace] option indicates that the application wants to take
over the ownership of the name from the application that is currently the
primary owner, if any. This request will only be honoured if the current
owner has indicated that it will release the name on request. See also the
................................................................................
[option -noqueue] option may be specified to indicate that the name request
should not be queued.

[para]

The command returns a list of names that have successfully been acquired.

[para]

The following code can be used to allow a new instance of a program to 
replace the current one. This can be useful during program development:
[example_begin]
dbif connect -yield -replace $dbusname
dbif listen -interface [lb]dbus info service[rb] \
  [lb]dbus info path[rb] NameLost name {if {$name eq $::dbusname} exit}
[example_end]

[call [cmd [vset cmdname]] [method default] \
  [opt "[option -bus] [arg bustype]"] \
  [opt "[option -interface] [arg interface]"]]

Generally an application will perform several [cmd [vset cmdname]] commands
related to the same message bus and interface. To avoid having to pass the
same values for the [option -bus] and [option -interface] options with all