[134] | 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 <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-transient-display.h" |
---|
| 42 | #include "gdm-transient-display-glue.h" |
---|
| 43 | |
---|
| 44 | #define GDM_TRANSIENT_DISPLAY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_TRANSIENT_DISPLAY, GdmTransientDisplayPrivate)) |
---|
| 45 | |
---|
| 46 | struct GdmTransientDisplayPrivate |
---|
| 47 | { |
---|
| 48 | gpointer dummy; |
---|
| 49 | }; |
---|
| 50 | |
---|
| 51 | enum { |
---|
| 52 | PROP_0, |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | static void gdm_transient_display_class_init (GdmTransientDisplayClass *klass); |
---|
| 56 | static void gdm_transient_display_init (GdmTransientDisplay *display); |
---|
| 57 | static void gdm_transient_display_finalize (GObject *object); |
---|
| 58 | |
---|
| 59 | G_DEFINE_TYPE (GdmTransientDisplay, gdm_transient_display, GDM_TYPE_DISPLAY) |
---|
| 60 | |
---|
| 61 | static gboolean |
---|
| 62 | gdm_transient_display_create_authority (GdmDisplay *display) |
---|
| 63 | { |
---|
| 64 | g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE); |
---|
| 65 | |
---|
| 66 | GDM_DISPLAY_CLASS (gdm_transient_display_parent_class)->create_authority (display); |
---|
| 67 | |
---|
| 68 | return TRUE; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | static gboolean |
---|
| 72 | gdm_transient_display_add_user_authorization (GdmDisplay *display, |
---|
| 73 | const char *username, |
---|
| 74 | char **filename, |
---|
| 75 | GError **error) |
---|
| 76 | { |
---|
| 77 | return GDM_DISPLAY_CLASS (gdm_transient_display_parent_class)->add_user_authorization (display, username, filename, error); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | static gboolean |
---|
| 81 | gdm_transient_display_remove_user_authorization (GdmDisplay *display, |
---|
| 82 | const char *username, |
---|
| 83 | GError **error) |
---|
| 84 | { |
---|
| 85 | return GDM_DISPLAY_CLASS (gdm_transient_display_parent_class)->remove_user_authorization (display, username, error); |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | static gboolean |
---|
| 89 | gdm_transient_display_manage (GdmDisplay *display) |
---|
| 90 | { |
---|
| 91 | g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE); |
---|
| 92 | |
---|
| 93 | GDM_DISPLAY_CLASS (gdm_transient_display_parent_class)->manage (display); |
---|
| 94 | |
---|
| 95 | return TRUE; |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | static gboolean |
---|
| 99 | gdm_transient_display_finish (GdmDisplay *display) |
---|
| 100 | { |
---|
| 101 | g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE); |
---|
| 102 | |
---|
| 103 | GDM_DISPLAY_CLASS (gdm_transient_display_parent_class)->finish (display); |
---|
| 104 | |
---|
| 105 | /* we don't restart/remanage transient displays */ |
---|
| 106 | gdm_display_unmanage (display); |
---|
| 107 | |
---|
| 108 | return TRUE; |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | static gboolean |
---|
| 112 | gdm_transient_display_unmanage (GdmDisplay *display) |
---|
| 113 | { |
---|
| 114 | g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE); |
---|
| 115 | |
---|
| 116 | GDM_DISPLAY_CLASS (gdm_transient_display_parent_class)->unmanage (display); |
---|
| 117 | |
---|
| 118 | return TRUE; |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | static void |
---|
| 122 | gdm_transient_display_set_property (GObject *object, |
---|
| 123 | guint prop_id, |
---|
| 124 | const GValue *value, |
---|
| 125 | GParamSpec *pspec) |
---|
| 126 | { |
---|
| 127 | switch (prop_id) { |
---|
| 128 | default: |
---|
| 129 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
---|
| 130 | break; |
---|
| 131 | } |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | static void |
---|
| 135 | gdm_transient_display_get_property (GObject *object, |
---|
| 136 | guint prop_id, |
---|
| 137 | GValue *value, |
---|
| 138 | GParamSpec *pspec) |
---|
| 139 | { |
---|
| 140 | switch (prop_id) { |
---|
| 141 | default: |
---|
| 142 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
---|
| 143 | break; |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | static void |
---|
| 148 | gdm_transient_display_get_timed_login_details (GdmDisplay *display, |
---|
| 149 | gboolean *enabledp, |
---|
| 150 | char **usernamep, |
---|
| 151 | int *delayp) |
---|
| 152 | { |
---|
| 153 | *enabledp = FALSE; |
---|
| 154 | *usernamep = g_strdup (""); |
---|
| 155 | *delayp = 0; |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | static void |
---|
| 159 | gdm_transient_display_class_init (GdmTransientDisplayClass *klass) |
---|
| 160 | { |
---|
| 161 | GObjectClass *object_class = G_OBJECT_CLASS (klass); |
---|
| 162 | GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass); |
---|
| 163 | |
---|
| 164 | object_class->get_property = gdm_transient_display_get_property; |
---|
| 165 | object_class->set_property = gdm_transient_display_set_property; |
---|
| 166 | object_class->finalize = gdm_transient_display_finalize; |
---|
| 167 | |
---|
| 168 | display_class->create_authority = gdm_transient_display_create_authority; |
---|
| 169 | display_class->add_user_authorization = gdm_transient_display_add_user_authorization; |
---|
| 170 | display_class->remove_user_authorization = gdm_transient_display_remove_user_authorization; |
---|
| 171 | display_class->manage = gdm_transient_display_manage; |
---|
| 172 | display_class->finish = gdm_transient_display_finish; |
---|
| 173 | display_class->unmanage = gdm_transient_display_unmanage; |
---|
| 174 | display_class->get_timed_login_details = gdm_transient_display_get_timed_login_details; |
---|
| 175 | |
---|
| 176 | g_type_class_add_private (klass, sizeof (GdmTransientDisplayPrivate)); |
---|
| 177 | |
---|
| 178 | dbus_g_object_type_install_info (GDM_TYPE_TRANSIENT_DISPLAY, &dbus_glib_gdm_transient_display_object_info); |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | static void |
---|
| 182 | gdm_transient_display_init (GdmTransientDisplay *display) |
---|
| 183 | { |
---|
| 184 | |
---|
| 185 | display->priv = GDM_TRANSIENT_DISPLAY_GET_PRIVATE (display); |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | static void |
---|
| 189 | gdm_transient_display_finalize (GObject *object) |
---|
| 190 | { |
---|
| 191 | GdmTransientDisplay *display; |
---|
| 192 | |
---|
| 193 | g_return_if_fail (object != NULL); |
---|
| 194 | g_return_if_fail (GDM_IS_TRANSIENT_DISPLAY (object)); |
---|
| 195 | |
---|
| 196 | display = GDM_TRANSIENT_DISPLAY (object); |
---|
| 197 | |
---|
| 198 | g_return_if_fail (display->priv != NULL); |
---|
| 199 | |
---|
| 200 | G_OBJECT_CLASS (gdm_transient_display_parent_class)->finalize (object); |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | GdmDisplay * |
---|
| 204 | gdm_transient_display_new (int display_number) |
---|
| 205 | { |
---|
| 206 | GObject *object; |
---|
| 207 | char *x11_display; |
---|
| 208 | |
---|
| 209 | x11_display = g_strdup_printf (":%d", display_number); |
---|
| 210 | object = g_object_new (GDM_TYPE_TRANSIENT_DISPLAY, |
---|
| 211 | "x11-display-number", display_number, |
---|
| 212 | "x11-display-name", x11_display, |
---|
| 213 | NULL); |
---|
| 214 | g_free (x11_display); |
---|
| 215 | |
---|
| 216 | return GDM_DISPLAY (object); |
---|
| 217 | } |
---|