~ubuntu-branches/ubuntu/oneiric/libindicator/oneiric

« back to all changes in this revision

Viewing changes to libindicator/indicator-service-manager.c

  • Committer: Bazaar Package Importer
  • Author(s): Ted Gould
  • Date: 2011-01-27 15:31:04 UTC
  • mfrom: (1.1.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20110127153104-pq0apjb7lvrs878b
Tags: 0.3.18-0ubuntu1
* New upstream release.
  * Adding a signal for scrolling that includes the entry
* debian/rules: Updating shlibs 

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        gchar * name;
47
47
        GDBusProxy * service_proxy;
48
48
        GCancellable * service_proxy_cancel;
 
49
        guint name_watcher;
49
50
        gboolean connected;
50
51
        guint this_service_version;
51
52
        guint restart_count;
102
103
static void start_service_again (IndicatorServiceManager * manager);
103
104
static void unwatch (GDBusProxy * proxy);
104
105
static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);
105
 
static void service_proxy_name_change (GObject * object, GParamSpec * pspec, gpointer user_data);
 
106
static void service_proxy_name_changed (GDBusConnection * connection, const gchar * sender_name, const gchar * object_path, const gchar * interface_name, const gchar * signal_name, GVariant * parameters, gpointer user_data);
106
107
 
107
108
G_DEFINE_TYPE (IndicatorServiceManager, indicator_service_manager, G_TYPE_OBJECT);
108
109
 
186
187
        priv->name = NULL;
187
188
        priv->service_proxy = NULL;
188
189
        priv->service_proxy_cancel = NULL;
 
190
        priv->name_watcher = 0;
189
191
        priv->connected = FALSE;
190
192
        priv->this_service_version = 0;
191
193
        priv->restart_count = 0;
218
220
                g_signal_emit(object, signals[CONNECTION_CHANGE], 0, FALSE, TRUE);
219
221
        }
220
222
 
 
223
        if (priv->name_watcher != 0) {
 
224
                g_dbus_connection_signal_unsubscribe(g_dbus_proxy_get_connection(priv->service_proxy),
 
225
                                                     priv->name_watcher);
 
226
                priv->name_watcher = 0;
 
227
        }
 
228
 
221
229
        /* If we're still getting the proxy, stop looking so we
222
230
           can then clean up some more. */
223
231
        if (priv->service_proxy_cancel != NULL) {
442
450
        return;
443
451
}
444
452
 
445
 
/* Callback from trying to create the proxy for the serivce, this
 
453
/* Callback from trying to create the proxy for the service, this
446
454
   could include starting the service.  Sometime it'll fail and
447
455
   we'll try to start that dang service again! */
448
456
static void
486
494
        priv->service_proxy = proxy;
487
495
 
488
496
        /* Signal for drop */
489
 
        g_signal_connect(G_OBJECT(priv->service_proxy), "notify::g-name-owner", G_CALLBACK(service_proxy_name_change), user_data);
 
497
        priv->name_watcher = g_dbus_connection_signal_subscribe(
 
498
                                           g_dbus_proxy_get_connection(proxy),
 
499
                                           "org.freedesktop.DBus",
 
500
                                           "org.freedesktop.DBus",
 
501
                                           "NameOwnerChanged",
 
502
                                           "/org/freedesktop/DBus",
 
503
                                           g_dbus_proxy_get_name(proxy),
 
504
                                           G_DBUS_SIGNAL_FLAGS_NONE,
 
505
                                           service_proxy_name_changed,
 
506
                                           user_data,
 
507
                                           NULL);
490
508
 
491
509
        /* Build cancelable if we need it */
492
510
        if (priv->watch_cancel == NULL) {
510
528
   usually means the service died.  We're dropping the proxy
511
529
   and recreating it so that it'll restart the service. */
512
530
static void
513
 
service_proxy_name_change (GObject * object, GParamSpec * pspec, gpointer user_data)
 
531
service_proxy_name_changed (GDBusConnection * connection, const gchar * sender_name,
 
532
                            const gchar * object_path, const gchar * interface_name,
 
533
                            const gchar * signal_name, GVariant * parameters,
 
534
                            gpointer user_data)
 
535
 
514
536
{
515
537
        IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(user_data);
516
 
        gchar * name = g_dbus_proxy_get_name_owner(priv->service_proxy);
517
 
 
518
 
        if (name == NULL) {
 
538
 
 
539
        const gchar * new_name;
 
540
        g_variant_get(parameters, "(&s&s&s)", NULL, NULL, &new_name);
 
541
 
 
542
        if (new_name == NULL || new_name[0] == 0) {
519
543
                if (priv->connected) {
520
544
                        priv->connected = FALSE;
521
545
                        g_signal_emit(G_OBJECT(user_data), signals[CONNECTION_CHANGE], 0, FALSE, TRUE);
523
547
 
524
548
                start_service_again(INDICATOR_SERVICE_MANAGER(user_data));
525
549
        } else {
526
 
                /* This case is an oddity, and really can only be a weird race
527
 
                   condition.  So we're going to ignore it for now. */
528
 
                g_free(name);
 
550
                if (!priv->connected) {
 
551
                        priv->connected = TRUE;
 
552
                        g_signal_emit(G_OBJECT(user_data), signals[CONNECTION_CHANGE], 0, TRUE, TRUE);
 
553
                }
529
554
        }
530
555
 
531
556
        return;