gdm r5967 - in trunk: . common daemon gui/simple-greeter



Author: halfline
Date: Sun Mar  9 21:22:50 2008
New Revision: 5967
URL: http://svn.gnome.org/viewvc/gdm?rev=5967&view=rev

Log:
2008-03-09  Ray Strode  <rstrode redhat com>

	* common/gdm-marshal.list (VOID:STRING,INT):
	* daemon/gdm-greeter-server.c:
	(send_dbus_string_and_int_signal):
	* gui/simple-greeter/gdm-greeter-client.c
	(emit_string_and_int_signal_for_message),
	(send_dbus_bool_method),
	(send_dbus_bool_method):
	Add some helper functions that will be useful later


Modified:
   trunk/ChangeLog
   trunk/common/gdm-marshal.list
   trunk/daemon/gdm-greeter-server.c
   trunk/gui/simple-greeter/gdm-greeter-client.c

Modified: trunk/common/gdm-marshal.list
==============================================================================
--- trunk/common/gdm-marshal.list	(original)
+++ trunk/common/gdm-marshal.list	Sun Mar  9 21:22:50 2008
@@ -3,3 +3,4 @@
 VOID:STRING,STRING,STRING
 VOID:STRING,STRING
 VOID:UINT,UINT
+VOID:STRING,INT

Modified: trunk/daemon/gdm-greeter-server.c
==============================================================================
--- trunk/daemon/gdm-greeter-server.c	(original)
+++ trunk/daemon/gdm-greeter-server.c	Sun Mar  9 21:22:50 2008
@@ -118,6 +118,40 @@
 }
 
 static void
+send_dbus_string_and_int_signal (GdmGreeterServer *greeter_server,
+                                 const char       *name,
+                                 const char       *text,
+                                 int               number)
+{
+        DBusMessage    *message;
+        DBusMessageIter iter;
+        const char     *str;
+
+        if (text != NULL) {
+                str = text;
+        } else {
+                str = "";
+        }
+
+        g_return_if_fail (greeter_server != NULL);
+
+        message = dbus_message_new_signal (GDM_GREETER_SERVER_DBUS_PATH,
+                                           GDM_GREETER_SERVER_DBUS_INTERFACE,
+                                           name);
+
+        dbus_message_iter_init_append (message, &iter);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &str);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &number);
+
+        g_debug ("GreeterServer: Sending %s (%s %d)", name, str, number);
+        if (! send_dbus_message (greeter_server->priv->greeter_connection, message)) {
+                g_debug ("GreeterServer: Could not send %s signal", name);
+        }
+
+        dbus_message_unref (message);
+}
+
+static void
 send_dbus_string_signal (GdmGreeterServer *greeter_server,
                          const char       *name,
                          const char       *text)

Modified: trunk/gui/simple-greeter/gdm-greeter-client.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-greeter-client.c	(original)
+++ trunk/gui/simple-greeter/gdm-greeter-client.c	Sun Mar  9 21:22:50 2008
@@ -99,6 +99,36 @@
 }
 
 static void
+emit_string_and_int_signal_for_message (GdmGreeterClient *client,
+                                        const char       *name,
+                                        DBusMessage      *message,
+                                        int               signal)
+{
+        DBusError   error;
+        const char *text;
+        int         number;
+        dbus_bool_t res;
+
+        dbus_error_init (&error);
+        res = dbus_message_get_args (message,
+                                     &error,
+                                     DBUS_TYPE_STRING, &text,
+                                     DBUS_TYPE_INT32, &number,
+                                     DBUS_TYPE_INVALID);
+        if (res) {
+
+                g_debug ("GdmGreeterClient: Received %s (%s %d)", name, text, number);
+
+                g_signal_emit (client,
+                               gdm_greeter_client_signals[signal],
+                               0, text, number);
+        } else {
+                g_warning ("Unable to get arguments: %s", error.message);
+                dbus_error_free (&error);
+        }
+}
+
+static void
 emit_string_signal_for_message (GdmGreeterClient *client,
                                 const char       *name,
                                 DBusMessage      *message,
@@ -250,6 +280,51 @@
         return TRUE;
 }
 
+static gboolean
+send_dbus_bool_method (DBusConnection *connection,
+                       const char     *method,
+                       gboolean        payload)
+{
+        DBusError       error;
+        DBusMessage    *message;
+        DBusMessage    *reply;
+        DBusMessageIter iter;
+
+        g_debug ("GdmGreeterClient: Calling %s", method);
+        message = dbus_message_new_method_call (NULL,
+                                                GREETER_SERVER_DBUS_PATH,
+                                                GREETER_SERVER_DBUS_INTERFACE,
+                                                method);
+        if (message == NULL) {
+                g_warning ("Couldn't allocate the D-Bus message");
+                return FALSE;
+        }
+
+        dbus_message_iter_init_append (message, &iter);
+        dbus_message_iter_append_basic (&iter,
+                                        DBUS_TYPE_BOOLEAN,
+                                        &payload);
+
+        dbus_error_init (&error);
+        reply = dbus_connection_send_with_reply_and_block (connection,
+                                                           message,
+                                                           -1,
+                                                           &error);
+
+        dbus_message_unref (message);
+
+        if (dbus_error_is_set (&error)) {
+                g_warning ("%s %s raised: %s\n",
+                           method,
+                           error.name,
+                           error.message);
+                return FALSE;
+        }
+        dbus_message_unref (reply);
+        dbus_connection_flush (connection);
+
+        return TRUE;
+}
 
 static gboolean
 send_dbus_void_method (DBusConnection *connection,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]