dbus-bindings.h

Go to the documentation of this file.
00001 
00006 /* purple
00007  *
00008  * Purple is the legal property of its developers, whose names are too numerous
00009  * to list here.  Please refer to the COPYRIGHT file distributed with this
00010  * source distribution.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00025  *
00026  */
00027 
00028 #ifndef _PURPLE_DBUS_BINDINGS_H_
00029 #define _PURPLE_DBUS_BINDINGS_H_
00030 
00031 #include <dbus/dbus.h>
00032 #include <dbus/dbus-glib-lowlevel.h>
00033 #include <glib.h>
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 gint purple_dbus_pointer_to_id(gconstpointer node);
00040 gpointer purple_dbus_id_to_pointer(gint id, PurpleDBusType *type);
00041 gint  purple_dbus_pointer_to_id_error(gconstpointer ptr, DBusError *error);
00042 gpointer purple_dbus_id_to_pointer_error(gint id, PurpleDBusType *type,
00043                        const char *typename, DBusError *error);
00044 
00045 #define NULLIFY(id) id = empty_to_null(id)
00046 
00047 #define CHECK_ERROR(error) if (dbus_error_is_set(error)) return NULL;
00048 
00049 #define PURPLE_DBUS_ID_TO_POINTER(ptr, id, type, error)         \
00050     G_STMT_START {                          \
00051     ptr = (type*) purple_dbus_id_to_pointer_error           \
00052         (id, PURPLE_DBUS_TYPE(type), #type, error);         \
00053     CHECK_ERROR(error);                     \
00054     } G_STMT_END
00055 
00056 
00057 #define PURPLE_DBUS_POINTER_TO_ID(id, ptr, error)               \
00058     G_STMT_START {                          \
00059     id = purple_dbus_pointer_to_id_error(ptr,error);            \
00060     CHECK_ERROR(error);                     \
00061     } G_STMT_END
00062 
00063 
00064 dbus_bool_t
00065 purple_dbus_message_get_args (DBusMessage     *message,
00066                 DBusError       *error,
00067                 int              first_arg_type,
00068                 ...);
00069 dbus_bool_t
00070 purple_dbus_message_get_args_valist (DBusMessage     *message,
00071                    DBusError       *error,
00072                    int              first_arg_type,
00073                    va_list          var_args);
00074 
00075 dbus_bool_t
00076 purple_dbus_message_iter_get_args (DBusMessageIter *iter,
00077                  DBusError       *error,
00078                  int              first_arg_type,
00079                  ...);
00080 
00081 dbus_bool_t
00082 purple_dbus_message_iter_get_args_valist (DBusMessageIter *iter,
00083                     DBusError       *error,
00084                     int              first_arg_type,
00085                     va_list          var_args);
00086 
00087 dbus_int32_t* purple_dbusify_GList(GList *list, gboolean free_memory, 
00088                  dbus_int32_t *len);
00089 dbus_int32_t* purple_dbusify_GSList(GSList *list, gboolean free_memory,
00090                   dbus_int32_t *len);
00091 gpointer* purple_GList_to_array(GList *list, gboolean free_memory,
00092                   dbus_int32_t *len);
00093 gpointer* purple_GSList_to_array(GSList *list, gboolean free_memory,
00094                   dbus_int32_t *len);
00095 GHashTable *purple_dbus_iter_hash_table(DBusMessageIter *iter, DBusError *error);
00096 
00097 const char* empty_to_null(const char *str);
00098 const char* null_to_empty(const char *s);
00099 
00100 typedef struct {
00101     const char *name;
00102     const char *parameters;
00103     DBusMessage* (*handler)(DBusMessage *request, DBusError *error);
00104 } PurpleDBusBinding;
00105 
00106 void purple_dbus_register_bindings(void *handle, PurpleDBusBinding *bindings);
00107 
00108 DBusConnection *purple_dbus_get_connection(void);
00109 
00110 #ifdef __cplusplus
00111 }
00112 #endif
00113 
00114 #endif