summaryrefslogtreecommitdiff
path: root/src/ck-session.h
blob: 8c5c00ec12179d0fb2032388530f612e7757d0db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 *
 * Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 */


#ifndef __CK_SESSION_H
#define __CK_SESSION_H

#include <glib-object.h>
#include <dbus/dbus-glib.h>

G_BEGIN_DECLS

#define CK_TYPE_SESSION         (ck_session_get_type ())
#define CK_SESSION(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), CK_TYPE_SESSION, CkSession))
#define CK_SESSION_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), CK_TYPE_SESSION, CkSessionClass))
#define CK_IS_SESSION(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), CK_TYPE_SESSION))
#define CK_IS_SESSION_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), CK_TYPE_SESSION))
#define CK_SESSION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CK_TYPE_SESSION, CkSessionClass))

typedef struct CkSessionPrivate CkSessionPrivate;

typedef struct
{
        GObject           parent;
        CkSessionPrivate *priv;
} CkSession;

typedef struct
{
        GObjectClass   parent_class;

        /* internal signals */
        void          (* activate)          (CkSession             *session,
                                             DBusGMethodInvocation *context);

        /* exported signals */
        void          (* lock)              (CkSession *session);
        void          (* unlock)            (CkSession *session);
        void          (* active_changed)    (CkSession *session,
                                             gboolean   active);
        void          (* idle_hint_changed) (CkSession *session,
                                             gboolean   idle_hint);
} CkSessionClass;

typedef enum
{
         CK_SESSION_ERROR_GENERAL
} CkSessionError;

#define CK_SESSION_ERROR ck_session_error_quark ()

GQuark              ck_session_error_quark            (void);
GType               ck_session_get_type               (void);
CkSession         * ck_session_new                    (const char            *ssid,
                                                       const char            *cookie);
CkSession         * ck_session_new_with_parameters    (const char            *ssid,
                                                       const char            *cookie,
                                                       const GPtrArray       *parameters);

void                ck_session_dump                   (CkSession             *session,
                                                       GKeyFile              *key_file);

gboolean            ck_session_set_active             (CkSession             *session,
                                                       gboolean               active,
                                                       GError               **error);
gboolean            ck_session_set_is_local           (CkSession             *session,
                                                       gboolean               is_local,
                                                       GError               **error);
gboolean            ck_session_set_id                 (CkSession             *session,
                                                       const char            *ssid,
                                                       GError               **error);
gboolean            ck_session_set_cookie             (CkSession             *session,
                                                       const char            *cookie,
                                                       GError               **error);
gboolean            ck_session_set_seat_id            (CkSession             *session,
                                                       const char            *sid,
                                                       GError               **error);
gboolean            ck_session_set_unix_user          (CkSession             *session,
                                                       guint                  uid,
                                                       GError               **error);
gboolean            ck_session_set_x11_display        (CkSession             *session,
                                                       const char            *xdisplay,
                                                       GError               **error);
gboolean            ck_session_set_x11_display_device (CkSession             *session,
                                                       const char            *xdisplay,
                                                       GError               **error);
gboolean            ck_session_set_display_device     (CkSession             *session,
                                                       const char            *device,
                                                       GError               **error);
gboolean            ck_session_set_remote_host_name   (CkSession             *session,
                                                       const char            *remote_host_name,
                                                       GError               **error);
gboolean            ck_session_set_session_type       (CkSession             *session,
                                                       const char            *type,
                                                       GError               **error);

/* Exported methods */

/* Authoritative properties */
gboolean            ck_session_get_id                 (CkSession             *session,
                                                       char                 **ssid,
                                                       GError               **error);
gboolean            ck_session_get_seat_id            (CkSession             *session,
                                                       char                 **sid,
                                                       GError               **error);
gboolean            ck_session_is_active              (CkSession             *session,
                                                       gboolean              *active,
                                                       GError               **error);
gboolean            ck_session_is_local               (CkSession             *session,
                                                       gboolean              *local,
                                                       GError               **error);
gboolean            ck_session_get_unix_user          (CkSession             *session,
                                                       guint                 *uid,
                                                       GError               **error);
gboolean            ck_session_get_x11_display        (CkSession             *session,
                                                       char                 **display,
                                                       GError               **error);
gboolean            ck_session_get_x11_display_device (CkSession             *session,
                                                       char                 **display,
                                                       GError               **error);
gboolean            ck_session_get_display_device     (CkSession             *session,
                                                       char                 **display,
                                                       GError               **error);
gboolean            ck_session_get_session_type       (CkSession             *session,
                                                       char                 **type,
                                                       GError               **error);
gboolean            ck_session_get_remote_host_name   (CkSession             *session,
                                                       char                 **host_name,
                                                       GError               **error);
gboolean            ck_session_get_creation_time      (CkSession             *session,
                                                       char                 **iso8601_datetime,
                                                       GError               **error);
/*deprecated*/
gboolean            ck_session_get_user               (CkSession             *session,
                                                       guint                 *uid,
                                                       GError               **error);

/* Non-authoritative properties */
gboolean            ck_session_get_idle_hint          (CkSession             *session,
                                                       gboolean              *idle_hint,
                                                       GError               **error);
gboolean            ck_session_get_idle_since_hint    (CkSession             *session,
                                                       char                 **iso8601_datetime,
                                                       GError               **error);
gboolean            ck_session_set_idle_hint          (CkSession             *session,
                                                       gboolean               idle_hint,
                                                       DBusGMethodInvocation *context);

/* Privileged actions */
gboolean            ck_session_activate               (CkSession             *session,
                                                       DBusGMethodInvocation *context);
gboolean            ck_session_lock                   (CkSession             *session,
                                                       DBusGMethodInvocation *context);
gboolean            ck_session_unlock                 (CkSession             *session,
                                                       DBusGMethodInvocation *context);


G_END_DECLS

#endif /* __CK_SESSION_H */