~unity8-desktop-session-team/indicator-session/indicator-session-using-upstart

« back to all changes in this revision

Viewing changes to src/backend-dbus/actions.c

  • Committer: Stephen M. Webb
  • Date: 2014-03-23 21:32:27 UTC
  • Revision ID: stephen.webb@canonical.com-20140323213227-l4ibsge0sd7xfhav
removed tests that assume gnome-session

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
1
2
/*
2
3
 * Copyright 2013 Canonical Ltd.
3
4
 *
22
23
 
23
24
#include "dbus-end-session-dialog.h"
24
25
#include "dbus-login1-manager.h"
 
26
#include "dbus-upstart.h"
25
27
#include "dbus-webcredentials.h"
26
28
#include "gnome-screen-saver.h"
27
29
#include "gnome-session-manager.h"
48
50
  Login1Seat * login1_seat;
49
51
  DisplayManagerSeat * dm_seat;
50
52
  GCancellable * dm_seat_cancellable;
 
53
  Upstart0_6 * upstart;
 
54
  GCancellable * upstart_cancellable;
51
55
  Webcredentials * webcredentials;
52
56
  EndSessionDialog * end_session_dialog;
53
57
  char * zenity;
96
100
{
97
101
  prompt_status_t prompt = PROMPT_NONE;
98
102
  const priv_t * p = self->priv;
 
103
  char const* mir_socket;
99
104
 
100
105
  if (!g_settings_get_boolean (p->indicator_settings, "suppress-logout-restart-shutdown"))
101
106
    {
109
114
          g_free (name);
110
115
        }
111
116
 
 
117
      /* gonna assume if MIR_SOCKET is set, prompting via X11 is gonna grief */
 
118
      mir_socket = g_getenv("MIR_SOCKET");
 
119
      if ((prompt == PROMPT_NONE) && mir_socket)
 
120
          return prompt;
 
121
 
112
122
      /* can we use zenity? */
113
123
      if ((prompt == PROMPT_NONE) && p && p->zenity)
114
124
        prompt = PROMPT_WITH_ZENITY;
282
292
}
283
293
 
284
294
static void
 
295
set_upstart (IndicatorSessionActionsDbus * self,
 
296
             Upstart0_6                  * upstart)
 
297
{
 
298
  priv_t * p = self->priv;
 
299
 
 
300
  if (p->upstart != NULL)
 
301
    {
 
302
      g_cancellable_cancel (p->upstart_cancellable);
 
303
      g_clear_object (&p->upstart_cancellable);
 
304
      g_clear_object (&p->upstart);
 
305
    }
 
306
 
 
307
  if (upstart != NULL)
 
308
    {
 
309
      p->upstart_cancellable = g_cancellable_new ();
 
310
      p->upstart = g_object_ref (upstart);
 
311
    }
 
312
}
 
313
 
 
314
static void
285
315
on_session_manager_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer gself)
286
316
{
287
317
  GError * err;
457
487
logout_now (IndicatorSessionActionsDbus * self)
458
488
{
459
489
  priv_t * p = self->priv;
460
 
 
461
 
  g_return_if_fail (p->session_manager != NULL);
462
 
 
463
 
  gnome_session_manager_call_logout (p->session_manager,
464
 
                                     1, /* don't prompt */
465
 
                                     p->cancellable,
466
 
                                     NULL,
467
 
                                     NULL);
 
490
  GError * err;
 
491
 
 
492
  upstart0_6_call_end_session_sync (p->upstart,
 
493
                                    p->upstart_cancellable,
 
494
                                    &err);
 
495
  log_and_clear_error (&err, G_STRLOC, G_STRFUNC);
468
496
}
469
497
 
470
498
static void
853
881
  set_dm_seat (self, NULL);
854
882
  set_login1_manager (self, NULL);
855
883
  set_login1_seat (self, NULL);
 
884
  set_upstart (self, NULL);
856
885
 
857
886
  G_OBJECT_CLASS (indicator_session_actions_dbus_parent_class)->dispose (o);
858
887
}
993
1022
indicator_session_actions_dbus_set_proxies (IndicatorSessionActionsDbus * self,
994
1023
                                            Login1Manager               * login1_manager,
995
1024
                                            Login1Seat                  * login1_seat,
996
 
                                            DisplayManagerSeat          * dm_seat)
 
1025
                                            DisplayManagerSeat          * dm_seat,
 
1026
                                            Upstart0_6                  * upstart)
997
1027
{
998
1028
  g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS_DBUS(self));
999
1029
 
1000
1030
  set_login1_manager (self, login1_manager);
1001
1031
  set_login1_seat (self, login1_seat);
1002
1032
  set_dm_seat (self, dm_seat);
 
1033
  set_upstart (self, upstart);
1003
1034
}