~ubuntu-branches/ubuntu/quantal/gnome-panel/quantal

« back to all changes in this revision

Viewing changes to applets/clock/set-timezone.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-02-08 00:17:11 UTC
  • mfrom: (1.13.15)
  • Revision ID: package-import@ubuntu.com-20120208001711-npwmthl0c6iy3s9a
Tags: 1:3.3.5-0ubuntu1
* New upstream release.
* debian/control.in:
  - Bump minimum glib to 2.31.14
* debian/patches/13_disable_missing_help.patch:
  Updated patch from bugzilla
* debian/patches/14_revert-timedate-change.patch:
  - Revert switch to systemd timedate protocol until ubuntu-system-
    services supports it

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
#include "set-timezone.h"
34
34
 
35
 
#define CACHE_VALIDITY_SEC 2
 
35
#define CACHE_VALIDITY_SEC 20
36
36
 
37
 
#define MECHANISM_BUS_NAME    "org.gnome.SettingsDaemon.DateTimeMechanism"
 
37
#define MECHANISM_BUS_NAME "org.gnome.SettingsDaemon.DateTimeMechanism"
38
38
#define MECHANISM_OBJECT_PATH "/"
39
 
#define MECHANISM_INTERFACE   "org.gnome.SettingsDaemon.DateTimeMechanism"
 
39
#define MECHANISM_INTERFACE "org.gnome.SettingsDaemon.DateTimeMechanism"
40
40
 
41
41
typedef struct {
42
42
  gboolean in_progress;
44
44
  guint64  stamp;
45
45
} Cache;
46
46
 
47
 
static Cache can_set_time_cache;
48
47
static Cache can_set_timezone_cache;
49
48
 
50
49
static GDBusConnection *
67
66
}
68
67
 
69
68
static void
70
 
can_set_call_finished (GObject      *source,
71
 
                       GAsyncResult *result,
72
 
                       gpointer      user_data)
 
69
can_set_call_finished (GObject *source,
 
70
 GAsyncResult *result,
 
71
 gpointer user_data)
73
72
{
74
 
  Cache *cache = user_data;
75
 
  GVariant *reply;
76
 
 
77
 
  reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source),
78
 
                                         result, NULL);
79
 
 
80
 
  if (reply != NULL)
81
 
    {
82
 
      g_variant_get (reply, "(i)", &cache->value);
83
 
      g_variant_unref (reply);
84
 
    }
85
 
 
86
 
  cache->stamp = g_get_monotonic_time ();
87
 
  cache->in_progress = FALSE;
 
73
 Cache *cache = user_data;
 
74
 GVariant *reply;
 
75
 
 
76
 reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source),
 
77
 result, NULL);
 
78
 
 
79
 if (reply != NULL)
 
80
 {
 
81
 g_variant_get (reply, "(i)", &cache->value);
 
82
 g_variant_unref (reply);
 
83
 }
 
84
 
 
85
 cache->stamp = g_get_monotonic_time ();
 
86
 cache->in_progress = FALSE;
88
87
}
89
88
 
90
89
static int
100
99
 
101
100
          if (system_bus != NULL)
102
101
            g_dbus_connection_call (system_bus, MECHANISM_BUS_NAME,
103
 
                                    MECHANISM_OBJECT_PATH, MECHANISM_INTERFACE,
104
 
                                    method_name, NULL, G_VARIANT_TYPE ("(i)"),
105
 
                                    G_DBUS_CALL_FLAGS_NONE, -1, NULL,
106
 
                                    can_set_call_finished, cache);
 
102
                                   MECHANISM_OBJECT_PATH, MECHANISM_INTERFACE,
 
103
                                   method_name, NULL, G_VARIANT_TYPE ("(i)"),
 
104
                                   G_DBUS_CALL_FLAGS_NONE, -1, NULL,
 
105
                                   can_set_call_finished, cache);
107
106
 
108
107
          /* Even if the system bus was NULL, we want to set this in
109
108
           * order to effectively wedge ourselves from ever trying
122
121
  return can_set (&can_set_timezone_cache, "CanSetTimezone");
123
122
}
124
123
 
125
 
gint
126
 
can_set_system_time (void)
127
 
{
128
 
  return can_set (&can_set_time_cache, "CanSetTime");
129
 
}
130
 
 
131
124
gboolean
132
125
set_system_timezone_finish (GAsyncResult  *result,
133
126
                            GError       **error)
177
170
 
178
171
  g_dbus_connection_call (system_bus, MECHANISM_BUS_NAME,
179
172
                          MECHANISM_OBJECT_PATH, MECHANISM_INTERFACE,
180
 
                          "SetTimezone", g_variant_new ("(s)", tz),
 
173
                          "SetTimezone", g_variant_new ("(s)", tz, TRUE),
181
174
                          NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL,
182
175
                          callback, user_data);
183
176
}