Migrate certificates, icons, logs to XDG dirs
[pidgin-git.git] / libpurple / dbus-server.h
blob513e690e43ee589c9082a6fb4cb41ee0cfe01b6d
1 /* purple
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef _PURPLE_DBUS_SERVER_H_
23 #define _PURPLE_DBUS_SERVER_H_
24 /**
25 * SECTION:dbus-server
26 * @section_id: libpurple-dbus-server
27 * @short_description: <filename>dbus-server.h</filename>
28 * @title: DBUS Server
29 * @see_also: <link linkend="chapter-signals-dbus-server">D-Bus Server signals</link>
32 #include "dbus-purple.h"
34 G_BEGIN_DECLS
36 typedef struct _PurpleDBusType PurpleDBusType;
38 /**
39 * PurpleDBusType:
41 * Types of pointers are identified by the ADDRESS of a PurpleDbusType
42 * object. This way, plugins can easily access types defined in purple
43 * proper as well as introduce their own types that will not conflict
44 * with those introduced by other plugins.
46 * The structure PurpleDbusType has only one element (PurpleDBusType::parent), a
47 * contains a pointer to the parent type, or %NULL if the type has no
48 * parent. Parent means the same as the base class in object oriented
49 * programming.
51 struct _PurpleDBusType {
52 PurpleDBusType *parent;
55 #include "dbus-bindings.h"
57 /* By convention, the PurpleDBusType variable representing each structure
58 PurpleSomeStructure has the name PURPLE_DBUS_TYPE_PurpleSomeStructure.
59 The following macros facilitate defining such variables
61 #PURPLE_DBUS_DECLARE_TYPE declares an extern variable representing a
62 given type, for use in header files.
64 #PURPLE_DBUS_DEFINE_TYPE defines a variable representing a given
65 type, use in .c files. It defines a new type without a parent; for
66 types with a parent use #PURPLE_DBUS_DEFINE_INHERITING_TYPE.
69 #define PURPLE_DBUS_TYPE(type) (&PURPLE_DBUS_TYPE_##type)
72 #define PURPLE_DBUS_DECLARE_TYPE(type) \
73 extern PurpleDBusType PURPLE_DBUS_TYPE_##type;
75 #define PURPLE_DBUS_DEFINE_TYPE(type) \
76 PurpleDBusType PURPLE_DBUS_TYPE_##type = { NULL };
78 #define PURPLE_DBUS_DEFINE_INHERITING_TYPE(type, parent) \
79 PurpleDBusType PURPLE_DBUS_TYPE_##type = { PURPLE_DBUS_TYPE(parent) };
81 #define PURPLE_DBUS_RETURN_FALSE_IF_DISABLED(plugin) \
82 if (purple_dbus_get_init_error() != NULL) \
83 { \
84 gchar *title; \
85 title = g_strdup_printf("Unable to Load %s Plugin", \
86 purple_plugin_info_get_name(purple_plugin_get_info(plugin))); \
87 purple_notify_error(NULL, title, \
88 _("Purple's D-BUS server is not running for the reason listed below"), \
89 _(purple_dbus_get_init_error()), NULL); \
90 g_free(title); \
91 return FALSE; \
94 /**
95 * purple_dbus_init_ids:
97 * Initializes purple dbus pointer registration engine.
99 * Remote dbus applications need a way of addressing objects exposed
100 * by purple to the outside world. In purple itself, these objects (such
101 * as PurpleBuddy and company) are identified by pointers. The purple
102 * dbus pointer registration engine converts pointers to handles and
103 * back.
105 * In order for an object to participate in the scheme, it must
106 * register itself and its type with the engine. This registration
107 * allocates an integer id which can be resolved to the pointer and
108 * back.
110 * Handles are not persistent. They are reissued every time purple is
111 * started. This is not good; external applications that use purple
112 * should work even whether purple was restarted in the middle of the
113 * interaction.
115 * Pointer registration is only a temporary solution. When PurpleBuddy
116 * and similar structures have been converted into gobjects, this
117 * registration will be done automatically by objects themselves.
119 * By the way, this kind of object-handle translation should be so
120 * common that there must be a library (maybe even glib) that
121 * implements it. I feel a bit like reinventing the wheel here.
123 void purple_dbus_init_ids(void);
126 * purple_dbus_register_pointer:
127 * @node: The pointer to register.
128 * @type: Type of that pointer.
130 * Registers a typed pointer.
132 void purple_dbus_register_pointer(gpointer node, PurpleDBusType *type);
135 * purple_dbus_unregister_pointer:
136 * @node: The pointer to register.
138 * Unregisters a pointer previously registered with
139 * purple_dbus_register_pointer.
141 void purple_dbus_unregister_pointer(gpointer node);
144 * purple_dbus_signal_emit_purple:
145 * @name: The name of the signal ("bla-bla-blaa")
146 * @num_values: The number of parameters.
147 * @types: Array of GTypes representing the types of the parameters.
148 * @vargs: A va_list containing the actual parameters.
150 * Emits a dbus signal.
152 void purple_dbus_signal_emit_purple(const char *name, int num_values,
153 GType *types, va_list vargs);
156 * purple_dbus_get_init_error:
158 * Returns whether Purple's D-BUS subsystem is up and running. If it's
159 * NOT running then #purple_dbus_dispatch_init failed for some reason,
160 * and a message should have been purple_debug_error()'ed.
162 * Purple plugins that use D-BUS should use the
163 * PURPLE_DBUS_RETURN_FALSE_IF_DISABLED macro to short-circuit
164 * initialization if Purple's D-BUS subsystem is not running.
166 * Returns: If the D-BUS subsystem started with no problems then this
167 * will return NULL and everything will be hunky dory. If
168 * there was an error initializing the D-BUS subsystem then
169 * this will return an error message explaining why.
171 const char *purple_dbus_get_init_error(void);
174 * purple_dbus_get_handle:
176 * Returns the dbus subsystem handle.
178 * Returns: The dbus subsystem handle.
180 void *purple_dbus_get_handle(void);
183 * purple_dbus_is_owner:
185 * Determines whether this instance owns the DBus service name
187 gboolean purple_dbus_is_owner(void);
190 * purple_dbus_init:
192 * Starts Purple's D-BUS server. It is responsible for handling DBUS
193 * requests from other applications.
195 void purple_dbus_init(void);
198 * purple_dbus_uninit:
200 * Uninitializes Purple's D-BUS server.
202 void purple_dbus_uninit(void);
205 * DBUS_EXPORT:
207 * Macro #DBUS_EXPORT expands to nothing. It is used to indicate to the
208 * dbus-analyze-functions.py script that the given function should be
209 * available to other applications through DBUS. If
210 * dbus-analyze-functions.py is run without the "--export-only" option,
211 * this prefix is ignored.
213 #ifndef DBUS_EXPORT
214 #define DBUS_EXPORT
215 #endif
218 Here we include the list of #PURPLE_DBUS_DECLARE_TYPE statements for
219 all structs defined in purple. This file has been generated by the
220 #dbus-analyze-types.py script.
223 #include "dbus-types.h"
225 G_END_DECLS
227 #endif /* _PURPLE_DBUS_SERVER_H_ */