1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2  *
3  * Copyright (C) 2009-2010 Red Hat, Inc.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  *
19  * Written by: Matthias Clasen <mclasen@redhat.com>
20  */
21 
22 #ifndef __DAEMON_H__
23 #define __DAEMON_H__
24 
25 #include <sys/types.h>
26 #include <glib.h>
27 #include <glib-object.h>
28 
29 #include "types.h"
30 #include "user.h"
31 #include "accounts-generated.h"
32 
33 G_BEGIN_DECLS
34 
35 #define TYPE_DAEMON         (daemon_get_type ())
36 #define DAEMON(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_DAEMON, Daemon))
37 #define DAEMON_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), TYPE_DAEMON, DaemonClass))
38 #define IS_DAEMON(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_DAEMON))
39 #define IS_DAEMON_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_DAEMON))
40 #define DAEMON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_DAEMON, DaemonClass))
41 
42 typedef struct DaemonClass DaemonClass;
43 
44 struct Daemon {
45         AccountsAccountsSkeleton parent;
46 };
47 
48 struct DaemonClass {
49         AccountsAccountsSkeletonClass parent_class;
50 };
51 
52 typedef enum {
53         ERROR_FAILED,
54         ERROR_USER_EXISTS,
55         ERROR_USER_DOES_NOT_EXIST,
56         ERROR_PERMISSION_DENIED,
57         ERROR_NOT_SUPPORTED,
58         NUM_ERRORS
59 } Error;
60 
61 #define ERROR error_quark ()
62 
63 GType error_get_type (void);
64 #define TYPE_ERROR (error_get_type ())
65 GQuark error_quark (void);
66 
67 GType   daemon_get_type              (void) G_GNUC_CONST;
68 Daemon *daemon_new                   (void);
69 
70 /* local methods */
71 
72 User *daemon_local_find_user_by_id   (Daemon                *daemon,
73                                       uid_t                  uid);
74 User *daemon_local_find_user_by_name (Daemon                *daemon,
75                                       const gchar           *name);
76 User *daemon_local_get_automatic_login_user (Daemon         *daemon);
77 
78 typedef void (*AuthorizedCallback)   (Daemon                *daemon,
79                                       User                  *user,
80                                       GDBusMethodInvocation *context,
81                                       gpointer               data);
82 
83 void         daemon_local_check_auth (Daemon                *daemon,
84                                       User                  *user,
85                                       const gchar           *action_id,
86                                       gboolean               allow_interaction,
87                                       AuthorizedCallback     auth_cb,
88                                       GDBusMethodInvocation *context,
89                                       gpointer               data,
90                                       GDestroyNotify         destroy_notify);
91 
92 gboolean   daemon_local_set_automatic_login (Daemon         *daemon,
93                                              User           *user,
94                                              gboolean        enabled,
95                                              GError        **error);
96 
97 GHashTable * daemon_read_extension_ifaces (void);
98 GHashTable * daemon_get_extension_ifaces (Daemon *daemon);
99 
100 G_END_DECLS
101 
102 #endif /* __DAEMON_H__ */
103