1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- |
---|
2 | * |
---|
3 | * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com> |
---|
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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
18 | * |
---|
19 | */ |
---|
20 | |
---|
21 | #include "config.h" |
---|
22 | |
---|
23 | #include <stdlib.h> |
---|
24 | #include <stdio.h> |
---|
25 | #include <fcntl.h> |
---|
26 | #include <unistd.h> |
---|
27 | #include <string.h> |
---|
28 | #include <sys/types.h> |
---|
29 | #include <sys/wait.h> |
---|
30 | #include <errno.h> |
---|
31 | #include <ctype.h> |
---|
32 | #include <pwd.h> |
---|
33 | #include <grp.h> |
---|
34 | #include <signal.h> |
---|
35 | |
---|
36 | #include <glib.h> |
---|
37 | #include <glib/gi18n.h> |
---|
38 | #include <glib-object.h> |
---|
39 | |
---|
40 | #include "gdm-common.h" |
---|
41 | |
---|
42 | #include "gdm-welcome-session.h" |
---|
43 | #include "gdm-chooser-session.h" |
---|
44 | |
---|
45 | #define GDM_CHOOSER_SERVER_DBUS_PATH "/org/gnome/DisplayManager/ChooserServer" |
---|
46 | #define GDM_CHOOSER_SERVER_DBUS_INTERFACE "org.gnome.DisplayManager.ChooserServer" |
---|
47 | |
---|
48 | #define GDM_CHOOSER_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_CHOOSER_SESSION, GdmChooserSessionPrivate)) |
---|
49 | |
---|
50 | struct GdmChooserSessionPrivate |
---|
51 | { |
---|
52 | gpointer dummy; |
---|
53 | }; |
---|
54 | |
---|
55 | enum { |
---|
56 | PROP_0, |
---|
57 | }; |
---|
58 | |
---|
59 | static void gdm_chooser_session_class_init (GdmChooserSessionClass *klass); |
---|
60 | static void gdm_chooser_session_init (GdmChooserSession *chooser_session); |
---|
61 | static void gdm_chooser_session_finalize (GObject *object); |
---|
62 | |
---|
63 | G_DEFINE_TYPE (GdmChooserSession, gdm_chooser_session, GDM_TYPE_WELCOME_SESSION) |
---|
64 | |
---|
65 | static void |
---|
66 | gdm_chooser_session_set_property (GObject *object, |
---|
67 | guint prop_id, |
---|
68 | const GValue *value, |
---|
69 | GParamSpec *pspec) |
---|
70 | { |
---|
71 | switch (prop_id) { |
---|
72 | default: |
---|
73 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
---|
74 | break; |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | static void |
---|
79 | gdm_chooser_session_get_property (GObject *object, |
---|
80 | guint prop_id, |
---|
81 | GValue *value, |
---|
82 | GParamSpec *pspec) |
---|
83 | { |
---|
84 | switch (prop_id) { |
---|
85 | default: |
---|
86 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
---|
87 | break; |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | static GObject * |
---|
92 | gdm_chooser_session_constructor (GType type, |
---|
93 | guint n_construct_properties, |
---|
94 | GObjectConstructParam *construct_properties) |
---|
95 | { |
---|
96 | GdmChooserSession *chooser_session; |
---|
97 | |
---|
98 | chooser_session = GDM_CHOOSER_SESSION (G_OBJECT_CLASS (gdm_chooser_session_parent_class)->constructor (type, |
---|
99 | n_construct_properties, |
---|
100 | construct_properties)); |
---|
101 | |
---|
102 | return G_OBJECT (chooser_session); |
---|
103 | } |
---|
104 | |
---|
105 | static void |
---|
106 | gdm_chooser_session_class_init (GdmChooserSessionClass *klass) |
---|
107 | { |
---|
108 | GObjectClass *object_class = G_OBJECT_CLASS (klass); |
---|
109 | |
---|
110 | object_class->get_property = gdm_chooser_session_get_property; |
---|
111 | object_class->set_property = gdm_chooser_session_set_property; |
---|
112 | object_class->constructor = gdm_chooser_session_constructor; |
---|
113 | object_class->finalize = gdm_chooser_session_finalize; |
---|
114 | |
---|
115 | g_type_class_add_private (klass, sizeof (GdmChooserSessionPrivate)); |
---|
116 | } |
---|
117 | |
---|
118 | static void |
---|
119 | gdm_chooser_session_init (GdmChooserSession *chooser_session) |
---|
120 | { |
---|
121 | |
---|
122 | chooser_session->priv = GDM_CHOOSER_SESSION_GET_PRIVATE (chooser_session); |
---|
123 | } |
---|
124 | |
---|
125 | static void |
---|
126 | gdm_chooser_session_finalize (GObject *object) |
---|
127 | { |
---|
128 | GdmChooserSession *chooser_session; |
---|
129 | |
---|
130 | g_return_if_fail (object != NULL); |
---|
131 | g_return_if_fail (GDM_IS_CHOOSER_SESSION (object)); |
---|
132 | |
---|
133 | chooser_session = GDM_CHOOSER_SESSION (object); |
---|
134 | |
---|
135 | g_return_if_fail (chooser_session->priv != NULL); |
---|
136 | |
---|
137 | G_OBJECT_CLASS (gdm_chooser_session_parent_class)->finalize (object); |
---|
138 | } |
---|
139 | |
---|
140 | GdmChooserSession * |
---|
141 | gdm_chooser_session_new (const char *display_name, |
---|
142 | const char *display_device, |
---|
143 | const char *display_hostname) |
---|
144 | { |
---|
145 | GObject *object; |
---|
146 | |
---|
147 | object = g_object_new (GDM_TYPE_CHOOSER_SESSION, |
---|
148 | "command", LIBEXECDIR "/gdm-simple-chooser", |
---|
149 | "server-dbus-path", GDM_CHOOSER_SERVER_DBUS_PATH, |
---|
150 | "server-dbus-interface", GDM_CHOOSER_SERVER_DBUS_INTERFACE, |
---|
151 | "server-env-var-name", "GDM_CHOOSER_DBUS_ADDRESS", |
---|
152 | "register-ck-session", FALSE, |
---|
153 | "x11-display-name", display_name, |
---|
154 | "x11-display-device", display_device, |
---|
155 | "x11-display-hostname", display_hostname, |
---|
156 | NULL); |
---|
157 | |
---|
158 | return GDM_CHOOSER_SESSION (object); |
---|
159 | } |
---|