2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * LoginHelper interface
6 * Copyright 2004 Sun Microsystems Inc.,
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 /* login-helper.c: minimal implementation of Accessibility_LoginHelper.idl */
26 #include "login-helper.h"
27 #include "spi-common/spi-dbus.h"
28 #include "droute/droute.h"
30 /* Our parent Gtk object type */
31 #define PARENT_TYPE G_TYPE_OBJECT
33 /* A pointer to our parent object class */
34 static GObjectClass *g_object_parent_class;
37 login_helper_finalize (GObject *object)
39 (G_OBJECT_CLASS (g_object_parent_class))->finalize (object);
43 login_helper_set_safe (LoginHelper *helper, gboolean safe)
45 LoginHelperClass *klass = LOGIN_HELPER_GET_CLASS (helper);
48 return (* klass->set_safe)(helper, safe);
54 impl_set_safe (DBusConnection *bus, DBusMessage *message, void *user_data)
56 LoginHelper *helper = user_data;
63 dbus_error_init (&error);
64 if (!dbus_message_get_args
65 (message, &error, DBUS_TYPE_BOOLEAN, &safe, DBUS_TYPE_INVALID))
67 return SPI_DBUS_RETURN_ERROR (message, &error);
69 rv = login_helper_set_safe (helper, safe);
70 reply = dbus_message_new_method_return (message);
73 dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv, DBUS_TYPE_INVALID);
78 static LoginHelperDeviceReqFlags
79 login_helper_get_device_reqs (LoginHelper *helper)
81 LoginHelperClass *klass = LOGIN_HELPER_GET_CLASS (helper);
83 if (klass->get_device_reqs)
84 return (* klass->get_device_reqs)(helper);
90 impl_get_device_reqs (DBusConnection *bus, DBusMessage *message, void *user_data)
92 LoginHelper *helper = user_data;
93 dbus_uint32_t flags = 0;
96 flags = login_helper_get_device_reqs (helper);
98 reply = dbus_message_new_method_return (message);
101 dbus_message_append_args (reply, DBUS_TYPE_UINT32, &flags, DBUS_TYPE_INVALID);
107 login_helper_get_raise_windows (LoginHelper *helper)
109 LoginHelperClass *klass = LOGIN_HELPER_GET_CLASS (helper);
111 if (klass->get_raise_windows)
112 return (* klass->get_raise_windows)(helper);
118 impl_get_raise_windows (DBusConnection *bus, DBusMessage *message, void *user_data)
120 LoginHelper *helper = user_data;
124 DBusMessageIter iter, iter_array;
126 wids = login_helper_get_raise_windows (helper);
127 reply = dbus_message_new_method_return (message);
128 if (!reply) return NULL;
129 dbus_message_iter_init_append (message, &iter);
130 if (dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "i", &iter_array) && wids)
134 // TODO: figure out if this will break on 64-bit systems
135 dbus_int32_t id = *wids++;
136 dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_INT32, &id);
138 dbus_message_iter_close_container (&iter, &iter_array);
140 if (wids) g_free (wids);
145 login_helper_class_init (LoginHelperClass *klass)
147 GObjectClass * object_class = (GObjectClass *) klass;
149 g_object_parent_class = g_type_class_peek_parent (klass);
151 object_class->finalize = login_helper_finalize;
156 login_helper_init (LoginHelper *object)
160 G_DEFINE_TYPE (LoginHelper,