~indicator-applet-developers/indicator-session/trunk.0.1

« back to all changes in this revision

Viewing changes to src/status-provider-mc5.c

  • Committer: Ted Gould
  • Date: 2009-12-08 17:22:35 UTC
  • mfrom: (56.2.3 indicator-session)
  • Revision ID: ted@gould.cx-20091208172235-aaz0vmwk9wlsh3n3
Update to use libtelepathy instead of libempathy

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "config.h"
25
25
#endif
26
26
 
27
 
#include "libempathy/empathy-account-manager.h"
 
27
#include <telepathy-glib/account-manager.h>
28
28
 
29
29
#include "status-provider.h"
30
30
#include "status-provider-mc5.h"
65
65
 
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;
71
71
};
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);
89
89
 
109
109
        return;
110
110
}
111
111
 
112
 
/* Build our empathy account manager instance if we don't
 
112
/* Build our telepathy account manager instance if we don't
113
113
   have one. */
114
114
static void
115
115
build_eam (StatusProviderMC5 * self)
116
116
{
117
117
        StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(self);
 
118
        static TpDBusDaemon *daemon = NULL;
 
119
        GError *error = NULL;
118
120
 
119
121
        if (priv->manager != NULL) {
120
122
                return;
121
123
        }
122
 
 
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);
 
126
 
 
127
        if (daemon == NULL)
 
128
        {
 
129
                g_debug("Cannot create DBus daemon: %s\n", error->message);
 
130
                g_error_free(error);
 
131
                return;
 
132
        }
 
133
 
 
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",
 
139
                NULL));
 
140
        g_signal_connect(G_OBJECT(priv->manager), "most-available-presence-changed", G_CALLBACK(presence_changed), self);
125
141
 
126
142
        return;
127
143
}
128
144
 
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. */
133
149
static void
266
282
        StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(sp);
267
283
 
268
284
        build_eam(STATUS_PROVIDER_MC5(sp));
269
 
 
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], "");
271
286
 
272
287
        return;
273
288
}
287
302
        return priv->status;
288
303
}
289
304
 
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. */
293
308
static void
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)
295
310
{
296
311
        StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(sp);
297
312