1 /* 2 * proxy.h - Base class for Telepathy client proxies 3 * 4 * Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/> 5 * Copyright (C) 2007 Nokia Corporation 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library 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 GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #if defined (TP_DISABLE_SINGLE_INCLUDE) && !defined (_TP_IN_META_HEADER) && !defined (_TP_COMPILATION) 23 #error "Only <telepathy-glib/telepathy-glib.h> and <telepathy-glib/telepathy-glib-dbus.h> can be included directly." 24 #endif 25 26 #ifndef __TP_PROXY_H__ 27 #define __TP_PROXY_H__ 28 29 #include <dbus/dbus-glib.h> 30 #include <gio/gio.h> 31 32 #include <telepathy-glib/defs.h> 33 #include <telepathy-glib/_gen/genums.h> 34 35 G_BEGIN_DECLS 36 37 /* Forward declaration of a subclass - from dbus.h */ 38 typedef struct _TpDBusDaemon TpDBusDaemon; 39 /* Forward declaration - from simple-client-factory.h */ 40 typedef struct _TpSimpleClientFactory TpSimpleClientFactory; 41 42 typedef struct _TpProxyPrivate TpProxyPrivate; 43 44 typedef struct _TpProxy TpProxy; 45 46 #define TP_DBUS_ERRORS (tp_dbus_errors_quark ()) 47 GQuark tp_dbus_errors_quark (void); 48 49 typedef enum { 50 TP_DBUS_ERROR_UNKNOWN_REMOTE_ERROR = 0, 51 TP_DBUS_ERROR_PROXY_UNREFERENCED = 1, 52 TP_DBUS_ERROR_NO_INTERFACE = 2, 53 TP_DBUS_ERROR_NAME_OWNER_LOST = 3, 54 TP_DBUS_ERROR_INVALID_BUS_NAME = 4, 55 TP_DBUS_ERROR_INVALID_INTERFACE_NAME = 5, 56 TP_DBUS_ERROR_INVALID_OBJECT_PATH = 6, 57 TP_DBUS_ERROR_INVALID_MEMBER_NAME = 7, 58 TP_DBUS_ERROR_OBJECT_REMOVED = 8, 59 TP_DBUS_ERROR_CANCELLED = 9, 60 TP_DBUS_ERROR_INCONSISTENT = 10, 61 } TpDBusError; 62 #define TP_NUM_DBUS_ERRORS (TP_DBUS_ERROR_INCONSISTENT + 1) 63 #define NUM_TP_DBUS_ERRORS TP_NUM_DBUS_ERRORS 64 65 struct _TpProxy { 66 /*<private>*/ 67 GObject parent; 68 69 TpDBusDaemon *_TP_SEAL (dbus_daemon); 70 DBusGConnection *_TP_SEAL (dbus_connection); 71 gchar *_TP_SEAL (bus_name); 72 gchar *_TP_SEAL (object_path); 73 74 GError *_TP_SEAL (invalidated); 75 76 TpProxyPrivate *priv; 77 }; 78 79 typedef struct _TpProxyClass TpProxyClass; 80 81 typedef struct _TpProxyFeature TpProxyFeature; 82 typedef struct _TpProxyFeaturePrivate TpProxyFeaturePrivate; 83 84 typedef void (* TpProxyPrepareAsync) (TpProxy *proxy, 85 const TpProxyFeature *feature, 86 GAsyncReadyCallback callback, 87 gpointer user_data); 88 89 struct _TpProxyFeature { 90 /*<public>*/ 91 GQuark name; 92 gboolean core; 93 94 TpProxyPrepareAsync prepare_async; 95 TpProxyPrepareAsync prepare_before_signalling_connected_async; 96 97 const GQuark *interfaces_needed; 98 /* Features we depend on */ 99 const GQuark *depends_on; 100 101 gboolean can_retry; 102 103 /*<private>*/ 104 GCallback _reserved[4]; 105 TpProxyFeaturePrivate *priv; 106 }; 107 108 /* XXX: hide this from the g-i scanner, since vapigen can't cope */ 109 #ifndef __GI_SCANNER__ 110 typedef const TpProxyFeature *(*TpProxyClassFeatureListFunc) ( 111 TpProxyClass *cls); 112 #endif /* __GI_SCANNER__ */ 113 114 struct _TpProxyClass { 115 /*<public>*/ 116 GObjectClass parent_class; 117 118 GQuark interface; 119 120 unsigned int must_have_unique_name:1; 121 /*<private>*/ 122 guint _reserved_flags:31; 123 124 /* XXX: hide this from the g-i scanner, since vapigen can't cope */ 125 #ifdef __GI_SCANNER__ 126 GCallback _internal_list_features; 127 #else 128 TpProxyClassFeatureListFunc list_features; 129 #endif /* __GI_SCANNER__ */ 130 GCallback _reserved[3]; 131 gpointer priv; 132 }; 133 134 typedef struct _TpProxyPendingCall TpProxyPendingCall; 135 136 void tp_proxy_pending_call_cancel (TpProxyPendingCall *pc); 137 138 typedef struct _TpProxySignalConnection TpProxySignalConnection; 139 140 void tp_proxy_signal_connection_disconnect (TpProxySignalConnection *sc); 141 142 GType tp_proxy_get_type (void); 143 144 /* TYPE MACROS */ 145 #define TP_TYPE_PROXY \ 146 (tp_proxy_get_type ()) 147 #define TP_PROXY(obj) \ 148 (G_TYPE_CHECK_INSTANCE_CAST((obj), TP_TYPE_PROXY, \ 149 TpProxy)) 150 #define TP_PROXY_CLASS(klass) \ 151 (G_TYPE_CHECK_CLASS_CAST((klass), TP_TYPE_PROXY, \ 152 TpProxyClass)) 153 #define TP_IS_PROXY(obj) \ 154 (G_TYPE_CHECK_INSTANCE_TYPE((obj), TP_TYPE_PROXY)) 155 #define TP_IS_PROXY_CLASS(klass) \ 156 (G_TYPE_CHECK_CLASS_TYPE((klass), TP_TYPE_PROXY)) 157 #define TP_PROXY_GET_CLASS(obj) \ 158 (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_PROXY, \ 159 TpProxyClass)) 160 161 gboolean tp_proxy_has_interface_by_id (gpointer self, GQuark iface); 162 gboolean tp_proxy_has_interface (gpointer self, const gchar *iface); 163 164 _TP_AVAILABLE_IN_0_16 165 TpSimpleClientFactory *tp_proxy_get_factory (gpointer self); 166 167 TpDBusDaemon *tp_proxy_get_dbus_daemon (gpointer self); 168 169 DBusGConnection *tp_proxy_get_dbus_connection (gpointer self); 170 171 const gchar *tp_proxy_get_bus_name (gpointer self); 172 173 const gchar *tp_proxy_get_object_path (gpointer self); 174 175 const GError *tp_proxy_get_invalidated (gpointer self); 176 177 void tp_proxy_dbus_error_to_gerror (gpointer self, 178 const char *dbus_error, const char *debug_message, GError **error); 179 180 gboolean tp_proxy_is_prepared (gpointer self, GQuark feature); 181 void tp_proxy_prepare_async (gpointer self, 182 const GQuark *features, 183 GAsyncReadyCallback callback, 184 gpointer user_data); 185 gboolean tp_proxy_prepare_finish (gpointer self, 186 GAsyncResult *result, 187 GError **error); 188 189 G_END_DECLS 190 191 #include <telepathy-glib/_gen/tp-cli-generic.h> 192 193 #endif /* #ifndef __TP_PROXY_H__*/ 194