~codygarver/+junk/ind-sess

« back to all changes in this revision

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

  • 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 "actions.h"
 
21
#include "backend-dbus.h"
 
22
#include "guest.h"
 
23
#include "users.h"
 
24
#include "utils.h"
 
25
 
 
26
struct dbus_world_data
 
27
{
 
28
  GCancellable                * cancellable;
 
29
  IndicatorSessionActionsDbus * actions;
 
30
  IndicatorSessionUsersDbus   * users;
 
31
  IndicatorSessionGuestDbus   * guest;
 
32
};
 
33
 
 
34
static void 
 
35
on_proxies_ready (Login1Manager      * login1_manager,
 
36
                  Login1Seat         * login1_seat,
 
37
                  DisplayManagerSeat * display_manager_seat, 
 
38
                  Accounts           * account_manager,
 
39
                  GCancellable       * cancellable,
 
40
                  gpointer             gdata)
 
41
{
 
42
  struct dbus_world_data * data = gdata;
 
43
 
 
44
  if (!g_cancellable_is_cancelled (cancellable))
 
45
    {
 
46
      if (data->actions != NULL)
 
47
        indicator_session_actions_dbus_set_proxies (data->actions,
 
48
                                                    login1_manager,
 
49
                                                    login1_seat,
 
50
                                                    display_manager_seat);
 
51
 
 
52
      if (data->users != NULL)
 
53
        indicator_session_users_dbus_set_proxies (data->users,
 
54
                                                  login1_manager,
 
55
                                                  login1_seat,
 
56
                                                  display_manager_seat,
 
57
                                                  account_manager);
 
58
 
 
59
      if (data->guest != NULL)
 
60
        indicator_session_guest_dbus_set_proxies (data->guest,
 
61
                                                  login1_manager,
 
62
                                                  login1_seat,
 
63
                                                  display_manager_seat);
 
64
    }
 
65
 
 
66
  g_free (data);
 
67
}
 
68
 
 
69
/***
 
70
****
 
71
***/
 
72
 
 
73
void
 
74
backend_get (GCancellable             * cancellable,
 
75
             IndicatorSessionActions ** setme_actions,
 
76
             IndicatorSessionUsers   ** setme_users,
 
77
             IndicatorSessionGuest   ** setme_guest)
 
78
{
 
79
  struct dbus_world_data * data;
 
80
 
 
81
  data = g_new0 (struct dbus_world_data, 1);
 
82
 
 
83
  if (setme_actions != NULL)
 
84
    {
 
85
      IndicatorSessionActions * actions;
 
86
      actions = indicator_session_actions_dbus_new ();
 
87
      data->actions = INDICATOR_SESSION_ACTIONS_DBUS (actions);
 
88
 
 
89
      *setme_actions = actions;
 
90
    }
 
91
 
 
92
  if (setme_users != NULL)
 
93
    {
 
94
      IndicatorSessionUsers * users;
 
95
      users = indicator_session_users_dbus_new ();
 
96
      data->users = INDICATOR_SESSION_USERS_DBUS (users);
 
97
 
 
98
      *setme_users = users;
 
99
    }
 
100
 
 
101
  if (setme_guest != NULL)
 
102
    {
 
103
      IndicatorSessionGuest * guest;
 
104
      guest = indicator_session_guest_dbus_new ();
 
105
      data->guest = INDICATOR_SESSION_GUEST_DBUS (guest);
 
106
 
 
107
      *setme_guest = guest;
 
108
    }
 
109
 
 
110
  data->cancellable = g_object_ref (cancellable);
 
111
 
 
112
  indicator_session_util_get_session_proxies (on_proxies_ready,
 
113
                                              data->cancellable,
 
114
                                              data);
 
115
}