aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2008-08-03 17:14:34 +0000
committerMichael Albinus2008-08-03 17:14:34 +0000
commiteb932e8a59875d4499def7f94568f56526a461ef (patch)
treee1975c6a88001b3fb635507c1ee8d1dbe2aeae89
parent517571872e4d1b48c16c357a82458910b4d538c7 (diff)
downloademacs-eb932e8a59875d4499def7f94568f56526a461ef.tar.gz
emacs-eb932e8a59875d4499def7f94568f56526a461ef.zip
* dbus.texi (Receiving Method Calls): Document error handling of own
D-Bus methods.
-rw-r--r--doc/misc/ChangeLog5
-rw-r--r--doc/misc/dbus.texi34
2 files changed, 36 insertions, 3 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 1ce8133fd22..b80aeb1abd0 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,8 @@
12008-08-03 Michael Albinus <michael.albinus@gmx.de>
2
3 * dbus.texi (Receiving Method Calls): Document error handling of own
4 D-Bus methods.
5
12008-08-01 Bill Wohler <wohler@newt.com> 62008-08-01 Bill Wohler <wohler@newt.com>
2 7
3 * mh-e.texi (Reading Mail) 8 * mh-e.texi (Reading Mail)
diff --git a/doc/misc/dbus.texi b/doc/misc/dbus.texi
index 0b761cef6da..c7692e44bbe 100644
--- a/doc/misc/dbus.texi
+++ b/doc/misc/dbus.texi
@@ -1219,9 +1219,9 @@ registration for @var{method}. Example:
1219 "org.freedesktop.TextEditor" "OpenFile" 1219 "org.freedesktop.TextEditor" "OpenFile"
1220 'my-dbus-method-handler) 1220 'my-dbus-method-handler)
1221 1221
1222@result{} ((:system "org.freedesktop.TextEditor" "OpenFile") 1222@result{} ((:session "org.freedesktop.TextEditor" "OpenFile")
1223 ("org.freedesktop.TextEditor" "/org/freedesktop/TextEditor" 1223 ("org.freedesktop.TextEditor" "/org/freedesktop/TextEditor"
1224 my-method-handler)) 1224 my-dbus-method-handler))
1225@end lisp 1225@end lisp
1226 1226
1227If you invoke the method @samp{org.freedesktop.TextEditor.OpenFile} 1227If you invoke the method @samp{org.freedesktop.TextEditor.OpenFile}
@@ -1237,7 +1237,35 @@ could use the command line tool @code{dbus-send} in a shell:
1237 "org.freedesktop.TextEditor.OpenFile" string:"/etc/hosts" 1237 "org.freedesktop.TextEditor.OpenFile" string:"/etc/hosts"
1238 1238
1239@print{} method return sender=:1.22 -> dest=:1.23 reply_serial=2 1239@print{} method return sender=:1.22 -> dest=:1.23 reply_serial=2
1240 boolean true 1240 boolean true
1241@end example
1242
1243You can indicate an error by raising the Emacs signal
1244@code{dbus-error}. The handler above could be changed like this:
1245
1246@lisp
1247(defun my-dbus-method-handler (&rest args)
1248 (unless (and (= (length args) 1) (stringp (car args)))
1249 (signal 'dbus-error (list (format "Wrong argument list: %S" args))))
1250 (condition-case err
1251 (find-file (car args))
1252 (error (signal 'dbus-error (cdr err))))
1253 t)
1254
1255@result{} my-dbus-method-handler
1256@end lisp
1257
1258The test runs then
1259
1260@example
1261# dbus-send --session --print-reply \
1262 --dest="org.freedesktop.TextEditor" \
1263 "/org/freedesktop/TextEditor" \
1264 "org.freedesktop.TextEditor.OpenFile" \
1265 string:"/etc/hosts" string:"/etc/passwd"
1266
1267@print{} Error org.freedesktop.DBus.Error.Failed:
1268 Wrong argument list: ("/etc/hosts" "/etc/passwd")
1241@end example 1269@end example
1242@end defun 1270@end defun
1243 1271