Mercurial > pidgin
comparison 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 |
comparison
equal
deleted
inserted
replaced
11170:0e9e2b923d09 | 11171:ebb02ea3c789 |
---|---|
25 */ | 25 */ |
26 | 26 |
27 #ifndef _GAIM_DBUS_SERVER_H_ | 27 #ifndef _GAIM_DBUS_SERVER_H_ |
28 #define _GAIM_DBUS_SERVER_H_ | 28 #define _GAIM_DBUS_SERVER_H_ |
29 | 29 |
30 #include <glib-object.h> | |
31 #include "value.h" | 30 #include "value.h" |
31 | |
32 | 32 |
33 G_BEGIN_DECLS | 33 G_BEGIN_DECLS |
34 | 34 |
35 /* These are the categories of codes used by gaim dbus implementation | 35 /** |
36 for remote calls. In practice, they don't matter | 36 Types of pointers are identified by the ADDRESS of a GaimDbusType |
37 */ | 37 object. This way, plugins can easily access types defined in gaim |
38 typedef enum { | 38 proper as well as introduce their own types that will not conflict |
39 DBUS_ERROR_NONE = 0, | 39 with those introduced by other plugins. |
40 DBUS_ERROR_NOT_FOUND = 1 | |
41 } DbusErrorCodes; | |
42 | 40 |
43 /* Types of pointers that can be registered with the gaim dbus pointer | 41 The structure GaimDbusType has only one element #parent, which |
44 registration engine. See below */ | 42 contains a pointer to the parent type, or #NULL if the type has no |
45 typedef enum { | 43 parent. Parent means the same as the base class is object oriented |
46 DBUS_POINTER_NONE = 0, | 44 programming. |
47 #include "dbus-auto-enum-types.h" | 45 */ |
48 DBUS_POINTER_LASTTYPE | |
49 } GaimDBusPointerType; | |
50 | 46 |
51 typedef struct _GaimObject GaimObject; | 47 typedef struct _GaimDBusType GaimDBusType; |
52 | 48 |
53 /** The main GaimObject */ | 49 struct _GaimDBusType { |
54 GaimObject * gaim_dbus_object; | 50 GaimDBusType *parent; |
51 }; | |
55 | 52 |
56 /** | 53 /* By convesion, the GaimDBusType variable representing each structure |
57 * Starts the gaim DBUS server. It is responsible for handling DBUS | 54 GaimSomeStructure has the name GAIM_DBUS_TYPE_GaimSomeStructure. |
58 * requests from other applications. | 55 The following macros facilitate defining such variables |
59 * | |
60 * @return TRUE if successful, FALSE otherwise. | |
61 */ | |
62 gboolean gaim_dbus_init(void); | |
63 | 56 |
64 gboolean gaim_dbus_connect(GaimObject *object); | 57 #GAIM_DBUS_DECLARE_TYPE declares an extern variable representing a |
58 given type, for use in header files. | |
59 | |
60 #GAIM_DBUS_DEFINE_TYPE defines a variable representing a given | |
61 type, use in .c files. It defines a new type without a parent; for | |
62 types with a parent use #GAIM_DBUS_DEFINE_INHERITING_TYPE. | |
63 */ | |
64 | |
65 #define GAIM_DBUS_TYPE(type) (&GAIM_DBUS_TYPE_##type) | |
66 | |
67 | |
68 #define GAIM_DBUS_DECLARE_TYPE(type) \ | |
69 extern GaimDBusType GAIM_DBUS_TYPE_##type; | |
70 | |
71 #define GAIM_DBUS_DEFINE_TYPE(type) \ | |
72 GaimDBusType GAIM_DBUS_TYPE_##type = { NULL }; | |
73 | |
74 #define GAIM_DBUS_DEFINE_INHERITING_TYPE(type, parent) \ | |
75 GaimDBusType GAIM_DBUS_TYPE_##type = { GAIM_DBUS_TYPE(parent) }; | |
76 | |
65 | 77 |
66 /** | 78 /** |
67 Initializes gaim dbus pointer registration engine. | 79 Initializes gaim dbus pointer registration engine. |
68 | 80 |
69 Remote dbus applications need a way of addressing objects exposed | 81 Remote dbus applications need a way of addressing objects exposed |
96 Registers a typed pointer. | 108 Registers a typed pointer. |
97 | 109 |
98 @param node The pointer to register. | 110 @param node The pointer to register. |
99 @param type Type of that pointer. | 111 @param type Type of that pointer. |
100 */ | 112 */ |
101 void gaim_dbus_register_pointer(gpointer node, GaimDBusPointerType type); | 113 void gaim_dbus_register_pointer(gpointer node, GaimDBusType *type); |
102 | 114 |
103 /** | 115 /** |
104 Unregisters a pointer previously registered with | 116 Unregisters a pointer previously registered with |
105 gaim_dbus_register_pointer. | 117 gaim_dbus_register_pointer. |
106 | 118 |
111 | 123 |
112 | 124 |
113 /** | 125 /** |
114 Emits a dbus signal. | 126 Emits a dbus signal. |
115 | 127 |
116 @param object The #GaimObject (usually #gaim_dbus_object) | 128 @param name The name of the signal ("bla-bla-blaa") |
117 @param dbus_id Id of the signal. | |
118 @param num_values The number of parameters. | 129 @param num_values The number of parameters. |
119 @param values Array of pointers to #GaimValue objects representing | 130 @param values Array of pointers to #GaimValue objects representing |
120 the types of the parameters. | 131 the types of the parameters. |
121 @param vargs A va_list containing the actual parameters. | 132 @param vargs A va_list containing the actual parameters. |
133 */ | |
134 void gaim_dbus_signal_emit_gaim(char *name, int num_values, | |
135 GaimValue **values, va_list vargs); | |
122 | 136 |
123 This function is intended to be used in signal.h, where it | 137 /** |
124 automatically emits all gaim signals to dbus. For your own dbus | 138 * Starts the gaim DBUS server. It is responsible for handling DBUS |
125 signals, use #gaim_dbus_emit. | 139 * requests from other applications. |
126 */ | 140 * |
127 void gaim_dbus_signal_emit_gaim(GaimObject *object, char *name, | 141 * @return TRUE if successful, FALSE otherwise. |
128 int num_values, GaimValue **values, | 142 */ |
129 va_list vargs); | 143 gboolean gaim_dbus_init(void); |
130 | 144 |
131 | 145 |
146 | |
147 /** | |
148 | |
149 Macro #DBUS_EXPORT expands to nothing. It is used to indicate to the | |
150 #dbus-analize-functions.py script that the given function should be | |
151 available to other applications through DBUS. If | |
152 #dbus-analize-functions.py is run without the "--export-only" option, | |
153 this prefix is ignored. | |
154 | |
155 */ | |
156 | |
157 #define DBUS_EXPORT | |
158 | |
159 /* | |
160 Here we include the list of #GAIM_DBUS_DECLARE_TYPE statements for | |
161 all structs defined in gaim. This file has been generated by the | |
162 #dbus-analize-types.py script. | |
163 */ | |
164 | |
165 #include "dbus-types.h" | |
132 | 166 |
133 G_END_DECLS | 167 G_END_DECLS |
134 | 168 |
135 #endif /* _GAIM_DBUS_SERVER_H_ */ | 169 #endif /* _GAIM_DBUS_SERVER_H_ */ |