~ubuntu-branches/ubuntu/oneiric/indicator-session/oneiric-proposed

« back to all changes in this revision

Viewing changes to src/users-service-dbus.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2011-09-09 11:18:26 UTC
  • mfrom: (1.1.40 upstream)
  • Revision ID: package-import@ubuntu.com-20110909111826-5cu458yxgnu4k3nu
Tags: 0.3.5.0-0ubuntu1
* New upstream release:
  - fix the updates menu items randomly working (lp: #842946)
  - "Guest Session should not show if guest session was disabled in 
     the display manager" (lp: #835084)
  - segfault fix (lp: #840660)
  - don't display temporary guest user generated username (lp: #844272)
  - respect "show-real-name-on-panel" to hide the username (lp: #812728)

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
 
87
87
  DBusGProxy *accounts_service_proxy;
88
88
  DBusGProxy *display_manager_proxy;
 
89
  DBusGProxy *display_manager_props_proxy;
89
90
  DBusGProxy *ck_proxy;
90
91
  DBusGProxy *seat_proxy;
91
92
  DBusGProxy *session_proxy;
95
96
 
96
97
  DbusmenuMenuitem * guest_item;
97
98
  gchar * guest_session_id;
 
99
  gboolean guest_session_enabled;
98
100
};
99
101
 
100
102
#define USERS_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), USERS_SERVICE_DBUS_TYPE, UsersServiceDbusPrivate))
148
150
  priv->count = 0;
149
151
  priv->guest_item = NULL;
150
152
  priv->guest_session_id = NULL;
 
153
  
 
154
  priv->guest_session_enabled = FALSE;
151
155
 
152
156
  /* Get the system bus */
153
157
  priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
194
198
  G_OBJECT_CLASS (users_service_dbus_parent_class)->finalize (object);
195
199
}
196
200
 
 
201
 
197
202
static void
198
203
create_display_manager_proxy (UsersServiceDbus *self)
199
204
{
202
207
  GError *error = NULL;
203
208
  const gchar *cookie = NULL;
204
209
  gchar *seat = NULL;
205
 
 
 
210
  
206
211
  cookie = g_getenv ("XDG_SESSION_COOKIE");
207
212
  if (cookie == NULL || cookie[0] == 0)
208
213
    {
232
237
      return;
233
238
    }
234
239
  g_object_unref (dm_proxy);
235
 
 
 
240
  g_debug ("CREATING DM PROXIES WITH %s", seat);
236
241
  priv->display_manager_proxy = dbus_g_proxy_new_for_name (priv->system_bus,
237
242
                                                           "org.freedesktop.DisplayManager",
238
243
                                                           seat,
239
244
                                                           "org.freedesktop.DisplayManager.Seat");
 
245
 
 
246
  priv->display_manager_props_proxy = dbus_g_proxy_new_for_name (priv->system_bus,
 
247
                                                                 "org.freedesktop.DisplayManager",
 
248
                                                                 seat,
 
249
                                                                 "org.freedesktop.DBus.Properties");
 
250
 
 
251
 
240
252
  g_free (seat);
241
253
 
242
254
  if (!priv->display_manager_proxy)
244
256
      g_warning ("Failed to get DisplayManager seat proxy.");
245
257
      return;
246
258
    }
 
259
  if (!priv->display_manager_props_proxy)
 
260
    {
 
261
      g_warning ("Failed to get DisplayManager Properties seat proxy.");
 
262
      return;
 
263
    }
 
264
  
 
265
  GValue has_guest_session = {0};
 
266
  g_value_init (&has_guest_session, G_TYPE_BOOLEAN);
 
267
  if (!dbus_g_proxy_call (priv->display_manager_props_proxy,
 
268
                          "Get",
 
269
                          &error,
 
270
                          G_TYPE_STRING,
 
271
                          "org.freedesktop.DisplayManager.Seat",
 
272
                          G_TYPE_STRING,
 
273
                          "HasGuestAccount",
 
274
                          G_TYPE_INVALID,
 
275
                          G_TYPE_VALUE,
 
276
                          &has_guest_session,
 
277
                          G_TYPE_INVALID))
 
278
    {
 
279
      g_warning ("Failed to get the HasGuestSession property from the DisplayManager Properties seat proxy. error: %s", error->message);
 
280
      g_error_free (error);      
 
281
      return;      
 
282
    }
 
283
    g_debug ("Does seat have a guest account = %i", g_value_get_boolean (&has_guest_session));
 
284
    priv->guest_session_enabled = g_value_get_boolean (&has_guest_session);                                                        
247
285
}
248
286
 
249
287
static void
931
969
                          G_TYPE_BOOLEAN, &can_activate,
932
970
                          G_TYPE_INVALID))
933
971
    {
934
 
      g_warning ("Failed to determine if seat can activate sessions: %s", error->message);
935
 
      g_error_free (error);
936
 
 
 
972
      if (error != NULL){
 
973
        g_warning ("Failed to determine if seat can activate sessions: %s",
 
974
                    error->message);
 
975
        g_error_free (error);
 
976
      }
937
977
      return FALSE;
938
978
    }
939
979
 
954
994
 
955
995
        return;
956
996
}
 
997
 
 
998
gboolean users_service_dbus_guest_session_enabled (UsersServiceDbus * self)
 
999
{
 
1000
        g_return_val_if_fail(IS_USERS_SERVICE_DBUS(self), FALSE);
 
1001
        UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self);
 
1002
 
 
1003
  return priv->guest_session_enabled;
 
1004
}                                                    
 
1005