diff src/dbus-server.h @ 11171:ebb02ea3c789

[gaim-migrate @ 13272] Moved DBUS init call from gtkmain.c to core.c Reimplemented DBUS bindings mechamism to use low-level GLib bindings as described in my last blog entry. This way plugins can add new DBUS methods on the fly. Also wrote an example plugin that demonstrate how to do it. committer: Tailor Script <tailor@pidgin.im>
author Piotr Zielinski <zielaj>
date Sat, 30 Jul 2005 00:23:21 +0000
parents 1c5398ccbeb0
children 9563b768e8e2
line wrap: on
line diff
--- a/src/dbus-server.h	Fri Jul 29 13:38:00 2005 +0000
+++ b/src/dbus-server.h	Sat Jul 30 00:23:21 2005 +0000
@@ -27,41 +27,53 @@
 #ifndef _GAIM_DBUS_SERVER_H_
 #define _GAIM_DBUS_SERVER_H_
 
-#include <glib-object.h>
 #include "value.h"
 
+
 G_BEGIN_DECLS
 
-/* These are the categories of codes used by gaim dbus implementation
-   for remote calls.  In practice, they don't matter
- */
-typedef enum {
-  DBUS_ERROR_NONE = 0,
-  DBUS_ERROR_NOT_FOUND = 1
-} DbusErrorCodes;
+/** 
+   Types of pointers are identified by the ADDRESS of a GaimDbusType
+   object.  This way, plugins can easily access types defined in gaim
+   proper as well as introduce their own types that will not conflict
+   with those introduced by other plugins.
+
+   The structure GaimDbusType has only one element #parent, which
+   contains a pointer to the parent type, or #NULL if the type has no
+   parent.  Parent means the same as the base class is object oriented
+   programming.  
+   */
+
+typedef struct _GaimDBusType GaimDBusType;
+
+struct _GaimDBusType {
+    GaimDBusType *parent;
+};
 
-/* Types of pointers that can be registered with the gaim dbus pointer
-   registration engine.  See below */
-typedef enum {
-  DBUS_POINTER_NONE = 0,
-#include "dbus-auto-enum-types.h"
-  DBUS_POINTER_LASTTYPE
-} GaimDBusPointerType;
+/* By convesion, the GaimDBusType variable representing each structure
+   GaimSomeStructure has the name GAIM_DBUS_TYPE_GaimSomeStructure.
+   The following macros facilitate defining such variables
 
-typedef struct _GaimObject GaimObject;
+   #GAIM_DBUS_DECLARE_TYPE declares an extern variable representing a
+   given type, for use in header files.
+
+   #GAIM_DBUS_DEFINE_TYPE defines a variable representing a given
+   type, use in .c files.  It defines a new type without a parent; for
+   types with a parent use #GAIM_DBUS_DEFINE_INHERITING_TYPE.
+  */
 
-/** The main GaimObject  */
-GaimObject * gaim_dbus_object;
+#define GAIM_DBUS_TYPE(type) (&GAIM_DBUS_TYPE_##type)
+
+
+#define GAIM_DBUS_DECLARE_TYPE(type) \
+    extern GaimDBusType GAIM_DBUS_TYPE_##type;
 
-/**
- * Starts the gaim DBUS server.  It is responsible for handling DBUS
- * requests from other applications.
- *
- * @return TRUE if successful, FALSE otherwise.
- */
-gboolean gaim_dbus_init(void);
+#define GAIM_DBUS_DEFINE_TYPE(type) \
+    GaimDBusType GAIM_DBUS_TYPE_##type = { NULL };
 
-gboolean gaim_dbus_connect(GaimObject *object);
+#define GAIM_DBUS_DEFINE_INHERITING_TYPE(type, parent) \
+    GaimDBusType GAIM_DBUS_TYPE_##type = { GAIM_DBUS_TYPE(parent) };
+
 
 /**
    Initializes gaim dbus pointer registration engine.
@@ -98,7 +110,7 @@
     @param node   The pointer to register.
     @param type   Type of that pointer.
  */
-void gaim_dbus_register_pointer(gpointer node, GaimDBusPointerType type);
+void gaim_dbus_register_pointer(gpointer node, GaimDBusType *type);
 
 /** 
     Unregisters a pointer previously registered with
@@ -113,22 +125,44 @@
 /**
     Emits a dbus signal.
 
-    @param object      The #GaimObject (usually #gaim_dbus_object)
-    @param dbus_id     Id of the signal.
+    @param name        The name of the signal ("bla-bla-blaa")
     @param num_values  The number of parameters.
     @param values      Array of pointers to #GaimValue objects representing
                        the types of the parameters.
     @param vargs       A va_list containing the actual parameters.
+  */
+void gaim_dbus_signal_emit_gaim(char *name, int num_values, 
+				GaimValue **values, va_list vargs);
 
-    This function is intended to be used in signal.h, where it
-    automatically emits all gaim signals to dbus.  For your own dbus
-    signals, use #gaim_dbus_emit.
-  */
-void gaim_dbus_signal_emit_gaim(GaimObject *object, char *name,
-				int num_values, GaimValue **values, 
-				va_list vargs);
+/**
+ * Starts the gaim DBUS server.  It is responsible for handling DBUS
+ * requests from other applications.
+ *
+ * @return TRUE if successful, FALSE otherwise.
+ */
+gboolean gaim_dbus_init(void);
+
 
 
+/**
+
+ Macro #DBUS_EXPORT expands to nothing.  It is used to indicate to the
+ #dbus-analize-functions.py script that the given function should be
+ available to other applications through DBUS.  If
+ #dbus-analize-functions.py is run without the "--export-only" option,
+ this prefix is ignored.
+
+ */
+
+#define DBUS_EXPORT
+
+/* 
+   Here we include the list of #GAIM_DBUS_DECLARE_TYPE statements for
+   all structs defined in gaim.  This file has been generated by the
+   #dbus-analize-types.py script.
+*/
+
+#include "dbus-types.h"
 
 G_END_DECLS