~codygarver/+junk/ind-sess

« back to all changes in this revision

Viewing changes to tests/backend-dbus/mock-session-manager.cc

  • Committer: Cody Garver
  • Date: 2014-04-03 17:08:08 UTC
  • Revision ID: cody@elementaryos.org-20140403170808-z56s93rorb1dzvmk
Initial import, version 12.10.5+14.04.20140324-0ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 Canonical Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *   Charles Kerr <charles.kerr@canonical.com>
 
6
 *
 
7
 * This program is free software: you can redistribute it and/or modify it
 
8
 * under the terms of the GNU General Public License version 3, as published
 
9
 * by the Free Software Foundation.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful, but
 
12
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
13
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
14
 * PURPOSE.  See the GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License along
 
17
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include "mock-session-manager.h"
 
21
 
 
22
gboolean
 
23
MockSessionManager :: handle_logout (GnomeSessionManager   * gsm,
 
24
                                     GDBusMethodInvocation * inv,
 
25
                                     guint                   arg,
 
26
                                     gpointer                gself)
 
27
{
 
28
  Action action;
 
29
  switch (arg) {
 
30
    case 0: action = LogoutNormal; break;
 
31
    case 1: action = LogoutQuiet; break;
 
32
    case 2: action = LogoutForce; break;
 
33
    default: action = None; break;
 
34
  }
 
35
  static_cast<MockSessionManager*>(gself)->my_last_action = action;
 
36
  gnome_session_manager_complete_logout (gsm, inv);
 
37
  return true;
 
38
}
 
39
 
 
40
 /***
 
41
****
 
42
***/
 
43
 
 
44
namespace
 
45
{
 
46
  const char * const SESSION_MANAGER_NAME = "org.gnome.SessionManager";
 
47
  const char * const SESSION_MANAGER_PATH = "/org/gnome/SessionManager";
 
48
 
 
49
}
 
50
 
 
51
MockSessionManager :: MockSessionManager (GMainLoop       * loop,
 
52
                                          GDBusConnection * bus_connection):
 
53
  MockObject (loop, bus_connection, SESSION_MANAGER_NAME, SESSION_MANAGER_PATH),
 
54
  my_skeleton (gnome_session_manager_skeleton_new ()),
 
55
  my_last_action (None)
 
56
{
 
57
  g_signal_connect (my_skeleton, "handle-logout",
 
58
                    G_CALLBACK(handle_logout), this);
 
59
 
 
60
  set_skeleton (G_DBUS_INTERFACE_SKELETON(my_skeleton));
 
61
}
 
62
 
 
63
MockSessionManager :: ~MockSessionManager ()
 
64
{
 
65
  g_clear_object (&my_skeleton);
 
66
}