1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
12
* You should have received a copy of the GNU General Public License along
13
* with this program; if not, write to the Free Software Foundation, Inc.,
14
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
* (C) Copyright 2008 - 2010 Red Hat, Inc.
17
* Author: David Zeuthen <davidz@redhat.com>
18
* Author: Dan Williams <dcbw@redhat.com>
23
#include "nm-logging.h"
25
#include "nm-session-utils.h"
26
#include "nm-session-monitor.h"
29
* SECTION:nm-session-monitor
30
* @title: NMSessionMonitor
31
* @short_description: Monitor sessions
33
* The #NMSessionMonitor class is a utility class to track and monitor sessions.
36
struct _NMSessionMonitor {
37
GObject parent_instance;
40
struct _NMSessionMonitorClass {
41
GObjectClass parent_class;
43
void (*changed) (NMSessionMonitor *monitor);
51
static guint signals[LAST_SIGNAL] = {0};
53
G_DEFINE_TYPE (NMSessionMonitor, nm_session_monitor, G_TYPE_OBJECT);
55
/********************************************************************/
58
nm_session_monitor_init (NMSessionMonitor *self)
63
nm_session_monitor_class_init (NMSessionMonitorClass *klass)
66
* NMSessionMonitor::changed:
67
* @monitor: A #NMSessionMonitor
69
* Emitted when something changes.
71
signals[CHANGED] = g_signal_new (NM_SESSION_MONITOR_CHANGED,
72
NM_TYPE_SESSION_MONITOR,
75
g_cclosure_marshal_VOID__VOID,
80
nm_session_monitor_get (void)
82
static NMSessionMonitor *singleton = NULL;
85
return g_object_ref (singleton);
87
singleton = NM_SESSION_MONITOR (g_object_new (NM_TYPE_SESSION_MONITOR, NULL));
92
/* ---------------------------------------------------------------------------------------------------- */
95
* nm_session_monitor_user_has_session:
96
* @monitor: A #NMSessionMonitor.
97
* @username: A username.
98
* @error: Return location for error.
100
* Checks whether the given @username is logged into a session or not.
102
* Returns: %FALSE if @error is set otherwise %TRUE if the given @username is
103
* currently logged into a session.
106
nm_session_monitor_user_has_session (NMSessionMonitor *monitor,
107
const char *username,
111
return nm_session_user_to_uid (username, out_uid, error);
115
* nm_session_monitor_uid_has_session:
116
* @monitor: A #NMSessionMonitor.
118
* @error: Return location for error.
120
* Checks whether the given @uid is logged into a session or not.
122
* Returns: %FALSE if @error is set otherwise %TRUE if the given @uid is
123
* currently logged into a session.
126
nm_session_monitor_uid_has_session (NMSessionMonitor *monitor,
128
const char **out_user,
131
return nm_session_uid_to_user (uid, out_user, error);
135
* nm_session_monitor_user_active:
136
* @monitor: A #NMSessionMonitor.
137
* @username: A username.
138
* @error: Return location for error.
140
* Checks whether the given @username is logged into a active session or not.
142
* Returns: %FALSE if @error is set otherwise %TRUE if the given @username is
143
* logged into an active session.
146
nm_session_monitor_user_active (NMSessionMonitor *monitor,
147
const char *username,
154
* nm_session_monitor_uid_active:
155
* @monitor: A #NMSessionMonitor.
157
* @error: Return location for error.
159
* Checks whether the given @uid is logged into a active session or not.
161
* Returns: %FALSE if @error is set otherwise %TRUE if the given @uid is
162
* logged into an active session.
165
nm_session_monitor_uid_active (NMSessionMonitor *monitor,