diff options
| author | Michael Albinus | 2008-07-13 15:07:10 +0000 |
|---|---|---|
| committer | Michael Albinus | 2008-07-13 15:07:10 +0000 |
| commit | 944cc4a8833392d5e689f8187d3432b7a772dd70 (patch) | |
| tree | 82cd45c20fbeef78a290baad4a66515c7312b0fc /src | |
| parent | bdee2ef3fab9b8a434d41c1f95c3f98aa342008b (diff) | |
| download | emacs-944cc4a8833392d5e689f8187d3432b7a772dd70.tar.gz emacs-944cc4a8833392d5e689f8187d3432b7a772dd70.zip | |
* dbusbind.c (Fdbus_register_signal): Allow also signal arguments
for filtering.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/dbusbind.c | 47 |
2 files changed, 47 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 3cd3caf8f1e..c28d2fdcb7c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2008-07-13 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * dbusbind.c (Fdbus_register_signal): Allow also signal arguments | ||
| 4 | for filtering. | ||
| 5 | |||
| 1 | 2008-07-13 Dan Nicolaescu <dann@ics.uci.edu> | 6 | 2008-07-13 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 7 | ||
| 3 | * s/vms.h: Use __GNUC__ instead of _GNUC_. | 8 | * s/vms.h: Use __GNUC__ instead of _GNUC_. |
| @@ -6,8 +11,8 @@ | |||
| 6 | * m/alpha.h: Use GNU_LINUX instead of LINUX. Reorganize conditionals. | 11 | * m/alpha.h: Use GNU_LINUX instead of LINUX. Reorganize conditionals. |
| 7 | 12 | ||
| 8 | * m/ibms390x.h (XINT, XUINT): Don't define, same as the default | 13 | * m/ibms390x.h (XINT, XUINT): Don't define, same as the default |
| 9 | (SPECIAL_EMACS_INT): | 14 | (SPECIAL_EMACS_INT): |
| 10 | * m/ia64.h (SPECIAL_EMACS_INT): | 15 | * m/ia64.h (SPECIAL_EMACS_INT): |
| 11 | * m/amdx86-64.h (SPECIAL_EMACS_INT): | 16 | * m/amdx86-64.h (SPECIAL_EMACS_INT): |
| 12 | * s/gnu.h (NLIST_STRUCT): | 17 | * s/gnu.h (NLIST_STRUCT): |
| 13 | * aix4-2.h (X11R5_INHIBIT_I18N): | 18 | * aix4-2.h (X11R5_INHIBIT_I18N): |
| @@ -15,7 +20,7 @@ | |||
| 15 | * s/msdos.h (HAVE_FACES): | 20 | * s/msdos.h (HAVE_FACES): |
| 16 | * s/ms-w32.h (HAVE_FACES): Don't define, unused. | 21 | * s/ms-w32.h (HAVE_FACES): Don't define, unused. |
| 17 | 22 | ||
| 18 | * systty.h: | 23 | * systty.h: |
| 19 | * sysdep.c (setup_pty): Don't depend on SYSV_PTYS, it is not used | 24 | * sysdep.c (setup_pty): Don't depend on SYSV_PTYS, it is not used |
| 20 | anymore. | 25 | anymore. |
| 21 | 26 | ||
diff --git a/src/dbusbind.c b/src/dbusbind.c index 122d39158ba..c59f2f5cfea 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -1266,7 +1266,7 @@ xd_read_queued_messages () | |||
| 1266 | } | 1266 | } |
| 1267 | 1267 | ||
| 1268 | DEFUN ("dbus-register-signal", Fdbus_register_signal, Sdbus_register_signal, | 1268 | DEFUN ("dbus-register-signal", Fdbus_register_signal, Sdbus_register_signal, |
| 1269 | 6, 6, 0, | 1269 | 6, MANY, 0, |
| 1270 | doc: /* Register for signal SIGNAL on the D-Bus BUS. | 1270 | doc: /* Register for signal SIGNAL on the D-Bus BUS. |
| 1271 | 1271 | ||
| 1272 | BUS is either the symbol `:system' or the symbol `:session'. | 1272 | BUS is either the symbol `:system' or the symbol `:session'. |
| @@ -1281,8 +1281,14 @@ nil if the path name of incoming signals shall not be checked. | |||
| 1281 | 1281 | ||
| 1282 | INTERFACE is an interface offered by SERVICE. It must provide SIGNAL. | 1282 | INTERFACE is an interface offered by SERVICE. It must provide SIGNAL. |
| 1283 | HANDLER is a Lisp function to be called when the signal is received. | 1283 | HANDLER is a Lisp function to be called when the signal is received. |
| 1284 | It must accept as arguments the values SIGNAL is sending. INTERFACE, | 1284 | It must accept as arguments the values SIGNAL is sending. |
| 1285 | SIGNAL and HANDLER must not be nil. Example: | 1285 | |
| 1286 | All other arguments ARGS, if specified, must be strings. They stand | ||
| 1287 | for the respective arguments of the signal in their order, and are | ||
| 1288 | used for filtering as well. A nil argument might be used to preserve | ||
| 1289 | the order. | ||
| 1290 | |||
| 1291 | INTERFACE, SIGNAL and HANDLER must not be nil. Example: | ||
| 1286 | 1292 | ||
| 1287 | \(defun my-signal-handler (device) | 1293 | \(defun my-signal-handler (device) |
| 1288 | (message "Device %s added" device)) | 1294 | (message "Device %s added" device)) |
| @@ -1295,16 +1301,29 @@ SIGNAL and HANDLER must not be nil. Example: | |||
| 1295 | ("org.freedesktop.Hal" "/org/freedesktop/Hal/Manager" my-signal-handler)) | 1301 | ("org.freedesktop.Hal" "/org/freedesktop/Hal/Manager" my-signal-handler)) |
| 1296 | 1302 | ||
| 1297 | `dbus-register-signal' returns an object, which can be used in | 1303 | `dbus-register-signal' returns an object, which can be used in |
| 1298 | `dbus-unregister-object' for removing the registration. */) | 1304 | `dbus-unregister-object' for removing the registration. |
| 1299 | (bus, service, path, interface, signal, handler) | 1305 | |
| 1300 | Lisp_Object bus, service, path, interface, signal, handler; | 1306 | usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARGS) */) |
| 1307 | (nargs, args) | ||
| 1308 | int nargs; | ||
| 1309 | register Lisp_Object *args; | ||
| 1301 | { | 1310 | { |
| 1311 | Lisp_Object bus, service, path, interface, signal, handler; | ||
| 1312 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; | ||
| 1302 | Lisp_Object uname, key, key1, value; | 1313 | Lisp_Object uname, key, key1, value; |
| 1303 | DBusConnection *connection; | 1314 | DBusConnection *connection; |
| 1315 | int i; | ||
| 1304 | char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; | 1316 | char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; |
| 1305 | DBusError derror; | 1317 | DBusError derror; |
| 1306 | 1318 | ||
| 1307 | /* Check parameters. */ | 1319 | /* Check parameters. */ |
| 1320 | bus = args[0]; | ||
| 1321 | service = args[1]; | ||
| 1322 | path = args[2]; | ||
| 1323 | interface = args[3]; | ||
| 1324 | signal = args[4]; | ||
| 1325 | handler = args[5]; | ||
| 1326 | |||
| 1308 | CHECK_SYMBOL (bus); | 1327 | CHECK_SYMBOL (bus); |
| 1309 | if (!NILP (service)) CHECK_STRING (service); | 1328 | if (!NILP (service)) CHECK_STRING (service); |
| 1310 | if (!NILP (path)) CHECK_STRING (path); | 1329 | if (!NILP (path)) CHECK_STRING (path); |
| @@ -1312,6 +1331,7 @@ SIGNAL and HANDLER must not be nil. Example: | |||
| 1312 | CHECK_STRING (signal); | 1331 | CHECK_STRING (signal); |
| 1313 | if (!FUNCTIONP (handler)) | 1332 | if (!FUNCTIONP (handler)) |
| 1314 | wrong_type_argument (intern ("functionp"), handler); | 1333 | wrong_type_argument (intern ("functionp"), handler); |
| 1334 | GCPRO6 (bus, service, path, interface, signal, handler); | ||
| 1315 | 1335 | ||
| 1316 | /* Retrieve unique name of service. If service is a known name, we | 1336 | /* Retrieve unique name of service. If service is a known name, we |
| 1317 | will register for the corresponding unique name, if any. Signals | 1337 | will register for the corresponding unique name, if any. Signals |
| @@ -1351,11 +1371,22 @@ SIGNAL and HANDLER must not be nil. Example: | |||
| 1351 | if (!NILP (path)) | 1371 | if (!NILP (path)) |
| 1352 | sprintf (rule, "%s,path='%s'", rule, SDATA (path)); | 1372 | sprintf (rule, "%s,path='%s'", rule, SDATA (path)); |
| 1353 | 1373 | ||
| 1374 | /* Add arguments to the rule if they are non-nil. */ | ||
| 1375 | for (i = 6; i < nargs; ++i) | ||
| 1376 | if (!NILP (args[i])) | ||
| 1377 | { | ||
| 1378 | CHECK_STRING (args[i]); | ||
| 1379 | sprintf (rule, "%s,arg%d='%s'", rule, i-6, SDATA (args[i])); | ||
| 1380 | } | ||
| 1381 | |||
| 1354 | /* Add the rule to the bus. */ | 1382 | /* Add the rule to the bus. */ |
| 1355 | dbus_error_init (&derror); | 1383 | dbus_error_init (&derror); |
| 1356 | dbus_bus_add_match (connection, rule, &derror); | 1384 | dbus_bus_add_match (connection, rule, &derror); |
| 1357 | if (dbus_error_is_set (&derror)) | 1385 | if (dbus_error_is_set (&derror)) |
| 1358 | XD_ERROR (derror); | 1386 | { |
| 1387 | UNGCPRO; | ||
| 1388 | XD_ERROR (derror); | ||
| 1389 | } | ||
| 1359 | 1390 | ||
| 1360 | XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule); | 1391 | XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule); |
| 1361 | } | 1392 | } |
| @@ -1369,7 +1400,7 @@ SIGNAL and HANDLER must not be nil. Example: | |||
| 1369 | Fputhash (key, Fcons (key1, value), Vdbus_registered_functions_table); | 1400 | Fputhash (key, Fcons (key1, value), Vdbus_registered_functions_table); |
| 1370 | 1401 | ||
| 1371 | /* Return object. */ | 1402 | /* Return object. */ |
| 1372 | return list2 (key, list3 (service, path, handler)); | 1403 | RETURN_UNGCPRO (list2 (key, list3 (service, path, handler))); |
| 1373 | } | 1404 | } |
| 1374 | 1405 | ||
| 1375 | DEFUN ("dbus-register-method", Fdbus_register_method, Sdbus_register_method, | 1406 | DEFUN ("dbus-register-method", Fdbus_register_method, Sdbus_register_method, |