66
66
typedef struct _StatusProviderMC5Private StatusProviderMC5Private;
67
67
struct _StatusProviderMC5Private {
68
EmpathyAccountManager * manager;
68
TpAccountManager * manager;
69
69
StatusProviderStatus status;
70
70
DBusGProxy * dbus_proxy;
83
83
/* Internal Funcs */
84
84
static void set_status (StatusProvider * sp, StatusProviderStatus status);
85
85
static StatusProviderStatus get_status (StatusProvider * sp);
86
static void presence_changed (EmpathyAccountManager * eam, guint type, const gchar * type_str, const gchar * message, StatusProviderMC5 * sp);
86
static void presence_changed (TpAccountManager * eam, guint type, const gchar * type_str, const gchar * message, StatusProviderMC5 * sp);
87
87
static void dbus_namechange (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, StatusProviderMC5 * self);
88
88
static void mc5_exists_cb (DBusGProxy * proxy, gboolean exists, GError * error, gpointer userdata);
112
/* Build our empathy account manager instance if we don't
112
/* Build our telepathy account manager instance if we don't
115
115
build_eam (StatusProviderMC5 * self)
117
117
StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(self);
118
static TpDBusDaemon *daemon = NULL;
119
GError *error = NULL;
119
121
if (priv->manager != NULL) {
123
priv->manager = EMPATHY_ACCOUNT_MANAGER(g_object_new(EMPATHY_TYPE_ACCOUNT_MANAGER, NULL));
124
g_signal_connect(G_OBJECT(priv->manager), "global-presence-changed", G_CALLBACK(presence_changed), self);
124
/* the daemon is used to communicate via DBus */
125
daemon = tp_dbus_daemon_dup(&error);
129
g_debug("Cannot create DBus daemon: %s\n", error->message);
134
priv->manager = TP_ACCOUNT_MANAGER (g_object_new (TP_TYPE_ACCOUNT_MANAGER,
135
"dbus-daemon", daemon,
136
"dbus-connection", ((TpProxy *) daemon)->dbus_connection,
137
"bus-name", "org.freedesktop.Telepathy.MissionControl5",
138
"object-path", "/org/freedesktop/Telepathy/AccountManager",
140
g_signal_connect(G_OBJECT(priv->manager), "most-available-presence-changed", G_CALLBACK(presence_changed), self);
129
145
/* Creating an instance of the status provider. We set the variables
130
and create an EmpathyAccountManager object. It does all the hard
146
and create an TpAccountManager object. It does all the hard
131
147
work in this module of tracking MissionControl and enumerating the
132
148
accounts and all that jazz. */
266
282
StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(sp);
268
284
build_eam(STATUS_PROVIDER_MC5(sp));
270
empathy_account_manager_request_global_presence(priv->manager, sp_to_tp_map[status], sp_to_mc_map[status], "");
285
tp_account_manager_set_all_requested_presences(priv->manager, sp_to_tp_map[status], sp_to_mc_map[status], "");
287
302
return priv->status;
290
/* A signal handler for when the EmpatyAccountManager believes
305
/* A signal handler for when the TpAccountManager believes
291
306
that the global status has changed. It roughly calculates this
292
307
by finding the most available of all accounts that are active. */
294
presence_changed (EmpathyAccountManager * eam, guint type, const gchar * type_str, const gchar * message, StatusProviderMC5 * sp)
309
presence_changed (TpAccountManager * eam, guint type, const gchar * type_str, const gchar * message, StatusProviderMC5 * sp)
296
311
StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(sp);