1 /* 2 * base-connection.h - Header for TpBaseConnection 3 * 4 * Copyright (C) 2007-2008 Collabora Ltd. 5 * Copyright (C) 2007-2008 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_BASE_CONNECTION_H__ 27 #define __TP_BASE_CONNECTION_H__ 28 29 #include <dbus/dbus-glib.h> 30 #include <glib-object.h> 31 32 #include <telepathy-glib/channel-manager.h> 33 #include <telepathy-glib/defs.h> 34 #include <telepathy-glib/enums.h> 35 #include <telepathy-glib/handle-repo.h> 36 #include <telepathy-glib/proxy.h> 37 #include <telepathy-glib/svc-connection.h> 38 39 G_BEGIN_DECLS 40 41 /* The TpBaseConnection typedef is forward-declared in handle-repo.h */ 42 typedef struct _TpBaseConnectionClass TpBaseConnectionClass; 43 typedef struct _TpBaseConnectionPrivate TpBaseConnectionPrivate; 44 45 typedef void (*TpBaseConnectionProc) (TpBaseConnection *self); 46 47 typedef gboolean (*TpBaseConnectionStartConnectingImpl) ( 48 TpBaseConnection *self, GError **error); 49 50 typedef void (*TpBaseConnectionCreateHandleReposImpl) (TpBaseConnection *self, 51 TpHandleRepoIface *repos[TP_NUM_HANDLE_TYPES]); 52 53 54 typedef GPtrArray *(*TpBaseConnectionCreateChannelFactoriesImpl) ( 55 TpBaseConnection *self); 56 57 typedef GPtrArray *(*TpBaseConnectionCreateChannelManagersImpl) ( 58 TpBaseConnection *self); 59 60 typedef gchar *(*TpBaseConnectionGetUniqueConnectionNameImpl) ( 61 TpBaseConnection *self); 62 63 typedef GPtrArray *(*TpBaseConnectionGetInterfacesImpl) ( 64 TpBaseConnection *self); 65 66 struct _TpBaseConnection { 67 /*<private>*/ 68 GObject parent; 69 70 gchar *_TP_SEAL (bus_name); 71 gchar *_TP_SEAL (object_path); 72 73 TpConnectionStatus _TP_SEAL (status); 74 75 TpHandle _TP_SEAL (self_handle); 76 77 /*<private>*/ 78 gpointer _future1; 79 gpointer _future2; 80 gpointer _future3; 81 gpointer _future4; 82 83 TpBaseConnectionPrivate *priv; 84 }; 85 86 struct _TpBaseConnectionClass { 87 GObjectClass parent_class; 88 89 #ifdef __GI_SCANNER__ 90 /*<private>*/ 91 GCallback _internal_create_handle_repos; 92 /*<public>*/ 93 #else 94 TpBaseConnectionCreateHandleReposImpl create_handle_repos; 95 #endif 96 97 TpBaseConnectionCreateChannelFactoriesImpl create_channel_factories; 98 99 TpBaseConnectionGetUniqueConnectionNameImpl get_unique_connection_name; 100 101 TpBaseConnectionProc connecting; 102 TpBaseConnectionProc connected; 103 TpBaseConnectionProc disconnected; 104 105 TpBaseConnectionProc shut_down; 106 107 TpBaseConnectionStartConnectingImpl start_connecting; 108 109 /*<private>*/ 110 const gchar **_TP_SEAL (interfaces_always_present); 111 /*<public>*/ 112 TpBaseConnectionCreateChannelManagersImpl create_channel_managers; 113 114 TpBaseConnectionGetInterfacesImpl get_interfaces_always_present; 115 116 /*<private>*/ 117 gpointer _future3; 118 gpointer _future4; 119 120 gpointer priv; 121 }; 122 123 # define TP_INTERNAL_CONNECTION_STATUS_NEW ((TpConnectionStatus)(-1)) 124 125 GType tp_base_connection_get_type (void); 126 127 _TP_AVAILABLE_IN_0_20 128 const gchar *tp_base_connection_get_bus_name (TpBaseConnection *self); 129 130 _TP_AVAILABLE_IN_0_20 131 const gchar *tp_base_connection_get_object_path (TpBaseConnection *self); 132 133 _TP_AVAILABLE_IN_0_20 134 TpConnectionStatus tp_base_connection_get_status (TpBaseConnection *self); 135 136 _TP_AVAILABLE_IN_0_20 137 gboolean tp_base_connection_is_destroyed (TpBaseConnection *self); 138 139 _TP_AVAILABLE_IN_0_20 140 gboolean tp_base_connection_check_connected (TpBaseConnection *self, 141 GError **error); 142 143 TpHandleRepoIface *tp_base_connection_get_handles (TpBaseConnection *self, 144 TpHandleType handle_type); 145 146 gboolean tp_base_connection_register (TpBaseConnection *self, 147 const gchar *cm_name, gchar **bus_name, gchar **object_path, 148 GError **error); 149 150 /* FIXME: when dbus-glib exposes its GError -> D-Bus error name mapping, 151 we could also add: 152 void tp_base_connection_disconnect_with_error (TpBaseConnection *self, 153 const GError *error, GHashTable *details, TpConnectionStatusReason reason); 154 */ 155 156 void tp_base_connection_disconnect_with_dbus_error (TpBaseConnection *self, 157 const gchar *error_name, GHashTable *details, 158 TpConnectionStatusReason reason); 159 void tp_base_connection_disconnect_with_dbus_error_vardict ( 160 TpBaseConnection *self, 161 const gchar *error_name, 162 GVariant *details, 163 TpConnectionStatusReason reason); 164 165 void tp_base_connection_change_status (TpBaseConnection *self, 166 TpConnectionStatus status, TpConnectionStatusReason reason); 167 168 TpHandle tp_base_connection_get_self_handle (TpBaseConnection *self); 169 170 void tp_base_connection_set_self_handle (TpBaseConnection *self, 171 TpHandle self_handle); 172 173 void tp_base_connection_finish_shutdown (TpBaseConnection *self); 174 175 void tp_base_connection_add_interfaces (TpBaseConnection *self, 176 const gchar **interfaces); 177 178 #ifndef TP_DISABLE_DEPRECATED 179 _TP_DEPRECATED_IN_0_20 180 void tp_base_connection_dbus_request_handles (TpSvcConnection *iface, 181 guint handle_type, const gchar **names, DBusGMethodInvocation *context); 182 #endif 183 184 void tp_base_connection_register_with_contacts_mixin (TpBaseConnection *self); 185 186 187 typedef struct _TpChannelManagerIter TpChannelManagerIter; 188 189 struct _TpChannelManagerIter { 190 /*<private>*/ 191 TpBaseConnection *self; 192 guint index; 193 gpointer _future[2]; 194 }; 195 196 void tp_base_connection_channel_manager_iter_init (TpChannelManagerIter *iter, 197 TpBaseConnection *self); 198 199 gboolean tp_base_connection_channel_manager_iter_next ( 200 TpChannelManagerIter *iter, TpChannelManager **manager_out); 201 202 203 /* TYPE MACROS */ 204 #define TP_TYPE_BASE_CONNECTION \ 205 (tp_base_connection_get_type ()) 206 #define TP_BASE_CONNECTION(obj) \ 207 (G_TYPE_CHECK_INSTANCE_CAST((obj), TP_TYPE_BASE_CONNECTION, \ 208 TpBaseConnection)) 209 #define TP_BASE_CONNECTION_CLASS(klass) \ 210 (G_TYPE_CHECK_CLASS_CAST((klass), TP_TYPE_BASE_CONNECTION, \ 211 TpBaseConnectionClass)) 212 #define TP_IS_BASE_CONNECTION(obj) \ 213 (G_TYPE_CHECK_INSTANCE_TYPE((obj), TP_TYPE_BASE_CONNECTION)) 214 #define TP_IS_BASE_CONNECTION_CLASS(klass) \ 215 (G_TYPE_CHECK_CLASS_TYPE((klass), TP_TYPE_BASE_CONNECTION)) 216 #define TP_BASE_CONNECTION_GET_CLASS(obj) \ 217 (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_BASE_CONNECTION, \ 218 TpBaseConnectionClass)) 219 220 #define TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED(conn, context) \ 221 G_STMT_START { \ 222 TpBaseConnection *c_ = (conn); \ 223 GError *e_ = NULL; \ 224 \ 225 G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ 226 if (!tp_base_connection_check_connected (c_, &e_)) \ 227 { \ 228 dbus_g_method_return_error ((context), e_); \ 229 g_error_free (e_); \ 230 return; \ 231 } \ 232 G_GNUC_END_IGNORE_DEPRECATIONS \ 233 } G_STMT_END 234 235 TpDBusDaemon *tp_base_connection_get_dbus_daemon (TpBaseConnection *self); 236 237 void tp_base_connection_add_client_interest (TpBaseConnection *self, 238 const gchar *unique_name, const gchar *token, 239 gboolean only_if_uninterested); 240 241 void tp_base_connection_add_possible_client_interest (TpBaseConnection *self, 242 GQuark token); 243 244 _TP_AVAILABLE_IN_0_24 245 const gchar *tp_base_connection_get_account_path_suffix ( 246 TpBaseConnection *self); 247 248 G_END_DECLS 249 250 #endif /* #ifndef __TP_BASE_CONNECTION_H__*/ 251