aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2008-01-04 21:44:23 +0000
committerMichael Albinus2008-01-04 21:44:23 +0000
commitaddb7f2e1e67ab6ac5b84ebafaff1fb24853eef8 (patch)
treee276fbae32d69a1197285a445a9e89a641c1e80f
parentabe136eecdfa666e748e1d668066a4f9d1529af8 (diff)
downloademacs-addb7f2e1e67ab6ac5b84ebafaff1fb24853eef8.tar.gz
emacs-addb7f2e1e67ab6ac5b84ebafaff1fb24853eef8.zip
* dbus.texi (Receiving Method Calls): New chapter.
(Errors and Events): Add serial number to events. Replace "signal" by "message". Introduce dbus-event-serial-number.
-rw-r--r--doc/misc/ChangeLog6
-rw-r--r--doc/misc/dbus.texi98
2 files changed, 100 insertions, 4 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index b8e7a342644..802dc0bfb0b 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,9 @@
12008-01-04 Michael Albinus <michael.albinus@gmx.de>
2
3 * dbus.texi (Receiving Method Calls): New chapter.
4 (Errors and Events): Add serial number to events. Replace "signal" by
5 "message". Introduce dbus-event-serial-number.
6
12008-01-03 Michael Albinus <michael.albinus@gmx.de> 72008-01-03 Michael Albinus <michael.albinus@gmx.de>
2 8
3 * dbus.texi (Type Conversion): Explain the type specification for empty 9 * dbus.texi (Type Conversion): Explain the type specification for empty
diff --git a/doc/misc/dbus.texi b/doc/misc/dbus.texi
index c3fc8c2d766..506716e8d92 100644
--- a/doc/misc/dbus.texi
+++ b/doc/misc/dbus.texi
@@ -50,6 +50,7 @@ be found at @uref{http://dbus.freedesktop.org/}.
50* Inspection:: Inspection of the bus names. 50* Inspection:: Inspection of the bus names.
51* Type Conversion:: Mapping Lisp types and D-Bus types. 51* Type Conversion:: Mapping Lisp types and D-Bus types.
52* Synchronous Methods:: Calling methods in a blocking way. 52* Synchronous Methods:: Calling methods in a blocking way.
53* Receiving Method Calls:: Offering own methods.
53* Signals:: Sending and receiving signals. 54* Signals:: Sending and receiving signals.
54* Errors and Events:: Errors and events. 55* Errors and Events:: Errors and events.
55* GNU Free Documentation License:: The license for this documentation. 56* GNU Free Documentation License:: The license for this documentation.
@@ -487,6 +488,86 @@ emulate the @code{lshal} command on GNU/Linux systems:
487@end defun 488@end defun
488 489
489 490
491@node Receiving Method Calls
492@chapter Offering own methods.
493@cindex method calls, returning
494@cindex returning method calls
495
496Emacs can also offer own methods, which can be called by other
497applications. These methods could be an implementation of an
498interface of a well known service, like @code{org.freedesktop.TextEditor}.
499
500It could be also an implementation of an own interface. In this case,
501the service name must be @code{org.gnu.Emacs}. The object path shall
502begin with @code{/org/gnu/Emacs/@strong{Application}/}, and the
503interface name shall be @code{org.gnu.Emacs.@strong{Application}}.
504@code{@strong{Application}} is the name of the application which
505provides the interface.
506
507@defun dbus-register-method bus service path interface method handler
508With this function, an application registers @var{method} on the D-Bus
509@var{bus}.
510
511@var{bus} is either the symbol @code{:system} or the symbol
512@code{:session}.
513
514@var{service} is the D-Bus service name of the D-Bus object
515@var{method} is registered for. It must be a known name.
516
517@var{path} is the D-Bus object path @var{service} is
518registered.
519
520@var{interface} is the interface offered by @var{service}. It must
521provide @var{method}.
522
523@var{handler} is a Lisp function to be called when when a @var{method}
524call is is received. It must accept as arguments the input arguments
525of @var{method}. @var{handler} must return a list, which elements are
526used as arguments for the reply message of @var{method}. This list
527can be composed like the input parameters in @ref{Type Conversion}.
528
529@code{dbus-register-method} returns a Lisp symbol, which can be used
530as argument in @code{dbus-unregister-object} for removing the
531registration for @var{method}. Example:
532
533@example
534(defun my-dbus-method-handler (filename)
535 (let (result)
536 (if (find-file filename)
537 (setq result '(:boolean t))
538 (setq result '(:boolean nil)))
539 result))
540
541@result{} my-dbus-method-handler
542
543(dbus-register-method
544 :session "org.freedesktop.TextEditor" "/org/freedesktop/TextEditor"
545 "org.freedesktop.TextEditor" "OpenFile"
546 'my-dbus-method-handler)
547
548@result{} ((:system "org.freedesktop.TextEditor" "OpenFile")
549 ("org.freedesktop.TextEditor" "/org/freedesktop/TextEditor"
550 my-method-handler))
551@end example
552
553If you invoke the method @code{org.freedesktop.TextEditor.OpenFile}
554from another D-Bus application with a filename as parameter, the file
555is opened in Emacs, and the method returns either @var{true} or
556@var{false}, indicating the success if the method. As test tool one
557could use the command line tool @code{dbus-send} in a shell:
558
559@example
560# dbus-send --session --print-reply \
561 --dest="org.freedesktop.TextEditor" \
562 "/org/freedesktop/TextEditor" \
563 "org.freedesktop.TextEditor.OpenFile" string:"/etc/hosts"
564
565@print{} method return sender=:1.22 -> dest=:1.23 reply_serial=2
566 boolean true
567@end example
568@end defun
569
570
490@node Signals 571@node Signals
491@chapter Sending and receiving signals. 572@chapter Sending and receiving signals.
492@cindex signals 573@cindex signals
@@ -601,18 +682,21 @@ Incoming D-Bus messages are handled as Emacs events (see @pxref{Misc
601Events, , , elisp}). The generated event has this form: 682Events, , , elisp}). The generated event has this form:
602 683
603@example 684@example
604(dbus-event @var{bus} @var{service} @var{path} @var{interface} @var{member} @var{handler} &rest @var{args}) 685(dbus-event @var{bus} @var{serial} @var{service} @var{path} @var{interface} @var{member} @var{handler} &rest @var{args})
605@end example 686@end example
606 687
607@var{bus} identifies the D-Bus the signal is coming from. It is 688@var{bus} identifies the D-Bus the signal is coming from. It is
608either the symbol @code{:system} or the symbol @code{:session}. 689either the symbol @code{:system} or the symbol @code{:session}.
609 690
691@var{serial} is the serial number of the received D-Bus message if it
692is a method call, or @code{nil}.
693
610@var{service} and @var{path} are the unique name and the object path 694@var{service} and @var{path} are the unique name and the object path
611of the D-Bus object emitting the signal. @var{interface} and 695of the D-Bus object emitting the message. @var{interface} and
612@var{member} denote the signal which has been sent. 696@var{member} denote the message which has been sent.
613 697
614@var{handler} is the callback function which has been registered for 698@var{handler} is the callback function which has been registered for
615this signal (see @pxref{Signals}). When a @code{dbus-event} event 699this message (see @pxref{Signals}). When a @code{dbus-event} event
616arrives, @var{handler} is called with @var{args} as arguments. 700arrives, @var{handler} is called with @var{args} as arguments.
617 701
618In order to inspect the @code{dbus-event} data, you could extend the 702In order to inspect the @code{dbus-event} data, you could extend the
@@ -631,6 +715,12 @@ Returns the bus name @var{event} is coming from.
631The result is either the symbol @code{:system} or the symbol @code{:session}. 715The result is either the symbol @code{:system} or the symbol @code{:session}.
632@end defun 716@end defun
633 717
718@defun dbus-event-serial-number event
719Returns the serial number of the corresponding D-Bus message.
720The result is a number in case the D-Bus message is a method
721call, or @code{nil} for all other mesage types.
722@end defun
723
634@defun dbus-event-service-name event 724@defun dbus-event-service-name event
635Returns the unique name of the D-Bus object @var{event} is coming from. 725Returns the unique name of the D-Bus object @var{event} is coming from.
636@end defun 726@end defun