source: proiecte/PPPP/gdm/daemon/gdm-static-display.c @ 134

Last change on this file since 134 was 134, checked in by (none), 14 years ago

gdm sources with the modifications for webcam

File size: 7.3 KB
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
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 <errno.h>
24#include <stdlib.h>
25#include <stdio.h>
26#include <fcntl.h>
27#include <pwd.h>
28#include <unistd.h>
29#include <string.h>
30#include <signal.h>
31#include <sys/stat.h>
32#include <sys/types.h>
33#include <sys/socket.h>
34
35#include <glib.h>
36#include <glib/gi18n.h>
37#include <glib-object.h>
38
39#include "gdm-common.h"
40#include "gdm-display.h"
41#include "gdm-static-display.h"
42#include "gdm-static-display-glue.h"
43
44#define GDM_STATIC_DISPLAY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_STATIC_DISPLAY, GdmStaticDisplayPrivate))
45
46struct GdmStaticDisplayPrivate
47{
48        gboolean enable_timed_login;
49};
50
51enum {
52        PROP_0,
53};
54
55static void     gdm_static_display_class_init   (GdmStaticDisplayClass *klass);
56static void     gdm_static_display_init         (GdmStaticDisplay      *static_display);
57static void     gdm_static_display_finalize     (GObject              *object);
58
59G_DEFINE_TYPE (GdmStaticDisplay, gdm_static_display, GDM_TYPE_DISPLAY)
60
61static gboolean
62gdm_static_display_create_authority (GdmDisplay *display)
63{
64        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
65
66        GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->create_authority (display);
67
68        return TRUE;
69}
70
71static gboolean
72gdm_static_display_add_user_authorization (GdmDisplay *display,
73                                           const char *username,
74                                           char      **filename,
75                                           GError    **error)
76{
77        return GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->add_user_authorization (display, username, filename, error);
78}
79
80static gboolean
81gdm_static_display_remove_user_authorization (GdmDisplay *display,
82                                              const char *username,
83                                              GError    **error)
84{
85        return GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->remove_user_authorization (display, username, error);
86}
87
88static gboolean
89gdm_static_display_manage (GdmDisplay *display)
90{
91        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
92
93        GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->manage (display);
94
95        return TRUE;
96}
97
98static gboolean
99gdm_static_display_finish (GdmDisplay *display)
100{
101        int status;
102
103        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
104
105        /* Don't call parent's finish since we don't ever
106           want to be put in the FINISHED state */
107
108        /* restart static displays */
109        gdm_display_unmanage (display);
110
111        status = gdm_display_get_status (display);
112        if (status != GDM_DISPLAY_FAILED) {
113                gdm_display_manage (display);
114        }
115
116        return TRUE;
117}
118
119static gboolean
120gdm_static_display_unmanage (GdmDisplay *display)
121{
122        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
123
124        GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->unmanage (display);
125
126        return TRUE;
127}
128
129static void
130gdm_static_display_set_property (GObject      *object,
131                                 guint         prop_id,
132                                 const GValue *value,
133                                 GParamSpec   *pspec)
134{
135        switch (prop_id) {
136        default:
137                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
138                break;
139        }
140}
141
142static void
143gdm_static_display_get_property (GObject    *object,
144                                 guint       prop_id,
145                                 GValue     *value,
146                                 GParamSpec *pspec)
147{
148        switch (prop_id) {
149        default:
150                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
151                break;
152        }
153}
154
155static void
156gdm_static_display_get_timed_login_details (GdmDisplay *display,
157                                            gboolean   *enabledp,
158                                            char      **usernamep,
159                                            int        *delayp)
160{
161        if (GDM_STATIC_DISPLAY (display)->priv->enable_timed_login) {
162                GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->get_timed_login_details (display, enabledp, usernamep, delayp);
163        } else {
164                *enabledp = FALSE;
165                *usernamep = g_strdup ("");
166                *delayp = 0;
167        }
168}
169
170static void
171gdm_static_display_class_init (GdmStaticDisplayClass *klass)
172{
173        GObjectClass    *object_class = G_OBJECT_CLASS (klass);
174        GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
175
176        object_class->get_property = gdm_static_display_get_property;
177        object_class->set_property = gdm_static_display_set_property;
178        object_class->finalize = gdm_static_display_finalize;
179
180        display_class->create_authority = gdm_static_display_create_authority;
181        display_class->add_user_authorization = gdm_static_display_add_user_authorization;
182        display_class->remove_user_authorization = gdm_static_display_remove_user_authorization;
183        display_class->manage = gdm_static_display_manage;
184        display_class->finish = gdm_static_display_finish;
185        display_class->unmanage = gdm_static_display_unmanage;
186        display_class->get_timed_login_details = gdm_static_display_get_timed_login_details;
187
188        g_type_class_add_private (klass, sizeof (GdmStaticDisplayPrivate));
189
190        dbus_g_object_type_install_info (GDM_TYPE_STATIC_DISPLAY, &dbus_glib_gdm_static_display_object_info);
191}
192
193static void
194gdm_static_display_init (GdmStaticDisplay *static_display)
195{
196
197        static_display->priv = GDM_STATIC_DISPLAY_GET_PRIVATE (static_display);
198
199        static_display->priv->enable_timed_login = TRUE;
200}
201
202static void
203gdm_static_display_finalize (GObject *object)
204{
205        GdmStaticDisplay *static_display;
206
207        g_return_if_fail (object != NULL);
208        g_return_if_fail (GDM_IS_STATIC_DISPLAY (object));
209
210        static_display = GDM_STATIC_DISPLAY (object);
211
212        g_return_if_fail (static_display->priv != NULL);
213
214        G_OBJECT_CLASS (gdm_static_display_parent_class)->finalize (object);
215}
216
217GdmDisplay *
218gdm_static_display_new (int display_number)
219{
220        GObject *object;
221        char    *x11_display;
222
223        x11_display = g_strdup_printf (":%d", display_number);
224        object = g_object_new (GDM_TYPE_STATIC_DISPLAY,
225                               "x11-display-number", display_number,
226                               "x11-display-name", x11_display,
227                               NULL);
228        g_free (x11_display);
229
230        return GDM_DISPLAY (object);
231}
Note: See TracBrowser for help on using the repository browser.