summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2014-02-26 05:06:33 +0000
committerTarmac <>2014-02-26 05:06:33 +0000
commitd19c134dd264bd6a482abb4213a2116a23bd2158 (patch)
tree1f3b60dea4da6d8852101dcef6608d9bc31699b1 /tests
parent72a4b3131cca26be210e4ef101bd1f3a852e8487 (diff)
parent4e31d8a34377ff3668900764c51cb35c7a7ccb43 (diff)
downloadlightdm-d19c134dd264bd6a482abb4213a2116a23bd2158.tar.gz
Convert all test programs to use key value pairs for requests.
Approved by PS Jenkins bot, Robert Ancell.
Diffstat (limited to 'tests')
-rw-r--r--tests/src/X.c57
-rw-r--r--tests/src/Xvnc.c40
-rw-r--r--tests/src/guest-account.c2
-rw-r--r--tests/src/initctl.c2
-rw-r--r--tests/src/libsystem.c2
-rw-r--r--tests/src/plymouth.c2
-rw-r--r--tests/src/status.c111
-rw-r--r--tests/src/status.h4
-rw-r--r--tests/src/test-gobject-greeter.c151
-rw-r--r--tests/src/test-greeter-wrapper.c7
-rw-r--r--tests/src/test-guest-wrapper.c7
-rw-r--r--tests/src/test-mir-greeter.c45
-rw-r--r--tests/src/test-qt-greeter.cpp125
-rw-r--r--tests/src/test-script-hook.c2
-rw-r--r--tests/src/test-session.c71
-rw-r--r--tests/src/unity-system-compositor.c17
-rw-r--r--tests/src/vnc-client.c2
17 files changed, 276 insertions, 371 deletions
diff --git a/tests/src/X.c b/tests/src/X.c
index aae852a7..5aaf0b9c 100644
--- a/tests/src/X.c
+++ b/tests/src/X.c
@@ -24,6 +24,9 @@ static gchar *lock_path = NULL;
/* Path to authority database to use */
static gchar *auth_path = NULL;
+/* ID to use for test reporting */
+static gchar *id;
+
/* Display number being served */
static int display_number = 0;
@@ -61,14 +64,14 @@ quit (int status)
static gboolean
sighup_cb (gpointer user_data)
{
- status_notify ("XSERVER-%d DISCONNECT-CLIENTS", display_number);
+ status_notify ("%s DISCONNECT-CLIENTS", id);
return TRUE;
}
static gboolean
sigint_cb (gpointer user_data)
{
- status_notify ("XSERVER-%d TERMINATE SIGNAL=%d", display_number, SIGINT);
+ status_notify ("%s TERMINATE SIGNAL=%d", id, SIGINT);
quit (EXIT_SUCCESS);
return TRUE;
}
@@ -76,7 +79,7 @@ sigint_cb (gpointer user_data)
static gboolean
sigterm_cb (gpointer user_data)
{
- status_notify ("XSERVER-%d TERMINATE SIGNAL=%d", display_number, SIGTERM);
+ status_notify ("%s TERMINATE SIGNAL=%d", id, SIGTERM);
quit (EXIT_SUCCESS);
return TRUE;
}
@@ -88,7 +91,7 @@ xdmcp_query_cb (XDMCPClient *client)
if (!notified_query)
{
- status_notify ("XSERVER-%d SEND-QUERY", display_number);
+ status_notify ("%s SEND-QUERY", id);
notified_query = TRUE;
}
}
@@ -99,9 +102,9 @@ xdmcp_willing_cb (XDMCPClient *client, XDMCPWilling *message)
gchar **authorization_names;
GInetAddress *addresses[2];
- status_notify ("XSERVER-%d GOT-WILLING AUTHENTICATION-NAME=\"%s\" HOSTNAME=\"%s\" STATUS=\"%s\"", display_number, message->authentication_name, message->hostname, message->status);
+ status_notify ("%s GOT-WILLING AUTHENTICATION-NAME=\"%s\" HOSTNAME=\"%s\" STATUS=\"%s\"", id, message->authentication_name, message->hostname, message->status);
- status_notify ("XSERVER-%d SEND-REQUEST DISPLAY-NUMBER=%d AUTHORIZATION-NAME=\"%s\" MFID=\"%s\"", display_number, display_number, "MIT-MAGIC-COOKIE-1", "TEST XSERVER");
+ status_notify ("%s SEND-REQUEST DISPLAY-NUMBER=%d AUTHORIZATION-NAME=\"%s\" MFID=\"%s\"", id, display_number, "MIT-MAGIC-COOKIE-1", "TEST XSERVER");
authorization_names = g_strsplit ("MIT-MAGIC-COOKIE-1", " ", -1);
addresses[0] = xdmcp_client_get_local_address (client);
@@ -116,7 +119,7 @@ xdmcp_willing_cb (XDMCPClient *client, XDMCPWilling *message)
static void
xdmcp_accept_cb (XDMCPClient *client, XDMCPAccept *message)
{
- status_notify ("XSERVER-%d GOT-ACCEPT SESSION-ID=%d AUTHENTICATION-NAME=\"%s\" AUTHORIZATION-NAME=\"%s\"", display_number, message->session_id, message->authentication_name, message->authorization_name);
+ status_notify ("%s GOT-ACCEPT SESSION-ID=%d AUTHENTICATION-NAME=\"%s\" AUTHORIZATION-NAME=\"%s\"", id, message->session_id, message->authentication_name, message->authorization_name);
/* Ignore if haven't picked a valid authorization */
if (strcmp (message->authorization_name, "MIT-MAGIC-COOKIE-1") != 0)
@@ -127,26 +130,26 @@ xdmcp_accept_cb (XDMCPClient *client, XDMCPAccept *message)
xdmcp_cookie = g_malloc (message->authorization_data_length);
memcpy (xdmcp_cookie, message->authorization_data, message->authorization_data_length);
- status_notify ("XSERVER-%d SEND-MANAGE SESSION-ID=%d DISPLAY-NUMBER=%d DISPLAY-CLASS=\"%s\"", display_number, message->session_id, display_number, "DISPLAY CLASS");
+ status_notify ("%s SEND-MANAGE SESSION-ID=%d DISPLAY-NUMBER=%d DISPLAY-CLASS=\"%s\"", id, message->session_id, display_number, "DISPLAY CLASS");
xdmcp_client_send_manage (client, message->session_id, display_number, "DISPLAY CLASS");
}
static void
xdmcp_decline_cb (XDMCPClient *client, XDMCPDecline *message)
{
- status_notify ("XSERVER-%d GOT-DECLINE STATUS=\"%s\" AUTHENTICATION-NAME=\"%s\"", display_number, message->status, message->authentication_name);
+ status_notify ("%s GOT-DECLINE STATUS=\"%s\" AUTHENTICATION-NAME=\"%s\"", id, message->status, message->authentication_name);
}
static void
xdmcp_failed_cb (XDMCPClient *client, XDMCPFailed *message)
{
- status_notify ("XSERVER-%d GOT-FAILED SESSION-ID=%d STATUS=\"%s\"", display_number, message->session_id, message->status);
+ status_notify ("%s GOT-FAILED SESSION-ID=%d STATUS=\"%s\"", id, message->session_id, message->status);
}
static void
client_connected_cb (XServer *server, XClient *client)
{
- status_notify ("XSERVER-%d ACCEPT-CONNECT", display_number);
+ status_notify ("%s ACCEPT-CONNECT", id);
x_client_send_success (client);
}
@@ -157,44 +160,38 @@ client_disconnected_cb (XServer *server, XClient *client)
}
static void
-request_cb (const gchar *request)
+request_cb (const gchar *name, GHashTable *params)
{
- gchar *r;
-
- if (!request)
+ if (!name)
{
g_main_loop_quit (loop);
return;
}
- r = g_strdup_printf ("XSERVER-%d CRASH", display_number);
- if (strcmp (request, r) == 0)
+ if (strcmp (name, "CRASH") == 0)
{
cleanup ();
kill (getpid (), SIGSEGV);
}
- g_free (r);
- r = g_strdup_printf ("XSERVER-%d INDICATE-READY", display_number);
- if (strcmp (request, r) == 0)
+
+ else if (strcmp (name, "INDICATE-READY") == 0)
{
void *handler;
handler = signal (SIGUSR1, SIG_IGN);
if (handler == SIG_IGN)
{
- status_notify ("XSERVER-%d INDICATE-READY", display_number);
+ status_notify ("%s INDICATE-READY", id);
kill (getppid (), SIGUSR1);
}
signal (SIGUSR1, handler);
}
- g_free (r);
- r = g_strdup_printf ("XSERVER-%d START-XDMCP", display_number);
- if (strcmp (request, r) == 0)
+
+ else if (strcmp (name, "START-XDMCP") == 0)
{
if (!xdmcp_client_start (xdmcp_client))
quit (EXIT_FAILURE);
}
- g_free (r);
}
int
@@ -221,8 +218,6 @@ main (int argc, char **argv)
g_unix_signal_add (SIGTERM, sigterm_cb, NULL);
g_unix_signal_add (SIGHUP, sighup_cb, NULL);
- status_connect (request_cb);
-
for (i = 1; i < argc; i++)
{
char *arg = argv[i];
@@ -311,12 +306,16 @@ main (int argc, char **argv)
}
}
+ id = g_strdup_printf ("XSERVER-%d", display_number);
+
+ status_connect (request_cb, id);
+
xserver = x_server_new (display_number);
g_signal_connect (xserver, "client-connected", G_CALLBACK (client_connected_cb), NULL);
g_signal_connect (xserver, "client-disconnected", G_CALLBACK (client_disconnected_cb), NULL);
status_text = g_string_new ("");
- g_string_printf (status_text, "XSERVER-%d START", display_number);
+ g_string_printf (status_text, "%s START", id);
if (vt_number >= 0)
g_string_append_printf (status_text, " VT=%d", vt_number);
if (seat != NULL)
@@ -332,7 +331,7 @@ main (int argc, char **argv)
if (g_key_file_has_key (config, "test-xserver-config", "return-value", NULL))
{
int return_value = g_key_file_get_integer (config, "test-xserver-config", "return-value", NULL);
- status_notify ("XSERVER-%d EXIT CODE=%d", display_number, return_value);
+ status_notify ("%s EXIT CODE=%d", id, return_value);
return return_value;
}
diff --git a/tests/src/Xvnc.c b/tests/src/Xvnc.c
index 473fe97a..b7e3498e 100644
--- a/tests/src/Xvnc.c
+++ b/tests/src/Xvnc.c
@@ -22,6 +22,9 @@ static gchar *lock_path = NULL;
/* Path to authority database to use */
static gchar *auth_path = NULL;
+/* ID to use for test reporting */
+static gchar *id;
+
/* Display number being served */
static int display_number = 0;
@@ -47,14 +50,14 @@ quit (int status)
static gboolean
sighup_cb (gpointer user_data)
{
- status_notify ("XSERVER-%d DISCONNECT-CLIENTS", display_number);
+ status_notify ("%s DISCONNECT-CLIENTS", id);
return TRUE;
}
static gboolean
sigint_cb (gpointer user_data)
{
- status_notify ("XSERVER-%d TERMINATE SIGNAL=%d", display_number, SIGINT);
+ status_notify ("%s TERMINATE SIGNAL=%d", id, SIGINT);
quit (EXIT_SUCCESS);
return TRUE;
}
@@ -62,7 +65,7 @@ sigint_cb (gpointer user_data)
static gboolean
sigterm_cb (gpointer user_data)
{
- status_notify ("XSERVER-%d TERMINATE SIGNAL=%d", display_number, SIGTERM);
+ status_notify ("%s TERMINATE SIGNAL=%d", id, SIGTERM);
quit (EXIT_SUCCESS);
return TRUE;
}
@@ -72,7 +75,7 @@ client_connected_cb (XServer *server, XClient *client)
{
gchar *auth_error = NULL;
- status_notify ("XSERVER-%d ACCEPT-CONNECT", display_number);
+ status_notify ("%s ACCEPT-CONNECT", id);
if (auth_error)
x_client_send_failed (client, auth_error);
@@ -105,44 +108,39 @@ vnc_data_cb (GIOChannel *channel, GIOCondition condition, gpointer data)
buffer[n_read] = '\0';
if (g_str_has_suffix (buffer, "\n"))
buffer[n_read-1] = '\0';
- status_notify ("XSERVER-%d VNC-CLIENT-CONNECT VERSION=\"%s\"", display_number, buffer);
+ status_notify ("%s VNC-CLIENT-CONNECT VERSION=\"%s\"", id, buffer);
}
return TRUE;
}
static void
-request_cb (const gchar *request)
+request_cb (const gchar *name, GHashTable *params)
{
- gchar *r;
-
- if (!request)
+ if (!name)
{
g_main_loop_quit (loop);
return;
}
- r = g_strdup_printf ("XSERVER-%d INDICATE-READY", display_number);
- if (strcmp (request, r) == 0)
+ if (strcmp (name, "INDICATE-READY") == 0)
{
void *handler;
handler = signal (SIGUSR1, SIG_IGN);
if (handler == SIG_IGN)
{
- status_notify ("XSERVER-%d INDICATE-READY", display_number);
+ status_notify ("%s INDICATE-READY", id);
kill (getppid (), SIGUSR1);
}
signal (SIGUSR1, handler);
}
- g_free (r);
- r = g_strdup_printf ("XSERVER-%d START-VNC", display_number);
- if (strcmp (request, r) == 0)
+
+ else if (strcmp (name, "START-VNC") == 0)
{
/* Send server protocol version to client */
g_print ("RFB 003.007\n");
}
- g_free (r);
}
int
@@ -167,8 +165,6 @@ main (int argc, char **argv)
g_unix_signal_add (SIGTERM, sigterm_cb, NULL);
g_unix_signal_add (SIGHUP, sighup_cb, NULL);
- status_connect (request_cb);
-
for (i = 1; i < argc; i++)
{
char *arg = argv[i];
@@ -223,12 +219,16 @@ main (int argc, char **argv)
return EXIT_FAILURE;
}
}
-
+
+ id = g_strdup_printf ("XSERVER-%d", display_number);
+
+ status_connect (request_cb, id);
+
xserver = x_server_new (display_number);
g_signal_connect (xserver, "client-connected", G_CALLBACK (client_connected_cb), NULL);
g_signal_connect (xserver, "client-disconnected", G_CALLBACK (client_disconnected_cb), NULL);
- status_notify ("XSERVER-%d START GEOMETRY=%s DEPTH=%d OPTION=%s", display_number, geometry, depth, has_option ? "TRUE" : "FALSE");
+ status_notify ("%s START GEOMETRY=%s DEPTH=%d OPTION=%s", id, geometry, depth, has_option ? "TRUE" : "FALSE");
config = g_key_file_new ();
g_key_file_load_from_file (config, g_build_filename (g_getenv ("LIGHTDM_TEST_ROOT"), "script", NULL), G_KEY_FILE_NONE, NULL);
diff --git a/tests/src/guest-account.c b/tests/src/guest-account.c
index 55cec6df..655f34b9 100644
--- a/tests/src/guest-account.c
+++ b/tests/src/guest-account.c
@@ -18,7 +18,7 @@ main (int argc, char **argv)
g_type_init ();
#endif
- status_connect (NULL);
+ status_connect (NULL, NULL);
config = g_key_file_new ();
g_key_file_load_from_file (config, g_build_filename (g_getenv ("LIGHTDM_TEST_ROOT"), "script", NULL), G_KEY_FILE_NONE, NULL);
diff --git a/tests/src/initctl.c b/tests/src/initctl.c
index 5d97b81f..092e8b90 100644
--- a/tests/src/initctl.c
+++ b/tests/src/initctl.c
@@ -9,7 +9,7 @@ static GKeyFile *config;
int
main (int argc, char **argv)
{
- status_connect (NULL);
+ status_connect (NULL, NULL);
config = g_key_file_new ();
g_key_file_load_from_file (config, g_build_filename (g_getenv ("LIGHTDM_TEST_ROOT"), "script", NULL), G_KEY_FILE_NONE, NULL);
diff --git a/tests/src/libsystem.c b/tests/src/libsystem.c
index 2fdd19c1..fb1307e4 100644
--- a/tests/src/libsystem.c
+++ b/tests/src/libsystem.c
@@ -502,7 +502,7 @@ ioctl (int d, unsigned long request, ...)
{
active_vt = vt;
if (!status_connected)
- status_connected = status_connect (NULL);
+ status_connected = status_connect (NULL, NULL);
status_notify ("VT ACTIVATE VT=%d", active_vt);
}
break;
diff --git a/tests/src/plymouth.c b/tests/src/plymouth.c
index 9fada6d4..1b70f304 100644
--- a/tests/src/plymouth.c
+++ b/tests/src/plymouth.c
@@ -14,7 +14,7 @@ main (int argc, char **argv)
g_type_init ();
#endif
- status_connect (NULL);
+ status_connect (NULL, NULL);
config = g_key_file_new ();
g_key_file_load_from_file (config, g_build_filename (g_getenv ("LIGHTDM_TEST_ROOT"), "script", NULL), G_KEY_FILE_NONE, NULL);
diff --git a/tests/src/status.c b/tests/src/status.c
index 96bb8744..34062da4 100644
--- a/tests/src/status.c
+++ b/tests/src/status.c
@@ -5,11 +5,13 @@
#include <gio/gio.h>
#include <gio/gunixsocketaddress.h>
#include <unistd.h>
+#include <ctype.h>
#include "status.h"
static GSocket *status_socket = NULL;
static StatusRequestFunc request_func = NULL;
+static gchar *filter_id = NULL;
static gboolean
status_request_cb (GSocket *socket, GIOCondition condition, gpointer data)
@@ -17,6 +19,11 @@ status_request_cb (GSocket *socket, GIOCondition condition, gpointer data)
int length;
gchar buffer[1024];
ssize_t n_read;
+ const gchar *c, *start;
+ int l;
+ gchar *id, *name = NULL;
+ gboolean id_matches;
+ GHashTable *params;
GError *error = NULL;
n_read = g_socket_receive (socket, (gchar *)&length, sizeof (length), NULL, &error);
@@ -25,24 +32,117 @@ status_request_cb (GSocket *socket, GIOCondition condition, gpointer data)
if (n_read == 0)
{
if (request_func)
- request_func (NULL);
+ request_func (NULL, NULL);
return FALSE;
}
if (error)
g_warning ("Error reading from socket: %s", error->message);
g_clear_error (&error);
- if (n_read > 0 && request_func)
+ if (n_read <= 0 || !request_func)
+ return TRUE;
+
+ buffer[n_read] = '\0';
+ c = buffer;
+ start = c;
+ l = 0;
+ while (*c && !isspace (*c))
+ {
+ c++;
+ l++;
+ }
+ id = g_strdup_printf ("%.*s", l, start);
+ id_matches = g_strcmp0 (id, filter_id) == 0;
+ g_free (id);
+ if (!id_matches)
+ return TRUE;
+
+ while (isspace (*c))
+ c++;
+ start = c;
+ l = 0;
+ while (*c && !isspace (*c))
+ {
+ c++;
+ l++;
+ }
+ name = g_strdup_printf ("%.*s", l, start);
+
+ params = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ while (TRUE)
{
- buffer[n_read] = '\0';
- request_func (buffer);
+ const gchar *start;
+ gchar *param_name, *param_value;
+
+ while (isspace (*c))
+ c++;
+ start = c;
+ while (*c && !isspace (*c) && *c != '=')
+ c++;
+ if (*c == '\0')
+ break;
+
+ param_name = g_strdup_printf ("%.*s", (int) (c - start), start);
+
+ if (*c == '=')
+ {
+ c++;
+ while (isspace (*c))
+ c++;
+ if (*c == '\"')
+ {
+ gboolean escaped = FALSE;
+ GString *value;
+
+ c++;
+ value = g_string_new ("");
+ while (*c)
+ {
+ if (*c == '\\')
+ {
+ if (escaped)
+ {
+ g_string_append_c (value, '\\');
+ escaped = FALSE;
+ }
+ else
+ escaped = TRUE;
+ }
+ else if (!escaped && *c == '\"')
+ break;
+ if (!escaped)
+ g_string_append_c (value, *c);
+ c++;
+ }
+ param_value = value->str;
+ g_string_free (value, FALSE);
+ if (*c == '\"')
+ c++;
+ }
+ else
+ {
+ start = c;
+ while (*c && !isspace (*c))
+ c++;
+ param_value = g_strdup_printf ("%.*s", (int) (c - start), start);
+ }
+ }
+ else
+ param_value = g_strdup ("");
+
+ g_hash_table_insert (params, param_name, param_value);
}
+ request_func (name, params);
+
+ g_free (name);
+ g_hash_table_unref (params);
+
return TRUE;
}
gboolean
-status_connect (StatusRequestFunc request_cb)
+status_connect (StatusRequestFunc request_cb, const gchar *id)
{
gchar *path;
GSocketAddress *address;
@@ -51,6 +151,7 @@ status_connect (StatusRequestFunc request_cb)
GError *error = NULL;
request_func = request_cb;
+ filter_id = g_strdup (id);
status_socket = g_socket_new (G_SOCKET_FAMILY_UNIX, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_DEFAULT, &error);
if (error)
diff --git a/tests/src/status.h b/tests/src/status.h
index c9abe43b..c88822f2 100644
--- a/tests/src/status.h
+++ b/tests/src/status.h
@@ -7,9 +7,9 @@ extern "C" {
#include <glib-object.h>
-typedef void (*StatusRequestFunc)(const gchar *message);
+typedef void (*StatusRequestFunc)(const gchar *name, GHashTable *params);
-gboolean status_connect (StatusRequestFunc message_cb);
+gboolean status_connect (StatusRequestFunc message_cb, const gchar *id);
void status_notify (const gchar *format, ...);
diff --git a/tests/src/test-gobject-greeter.c b/tests/src/test-gobject-greeter.c
index 7918f490..8982d00b 100644
--- a/tests/src/test-gobject-greeter.c
+++ b/tests/src/test-gobject-greeter.c
@@ -71,139 +71,45 @@ user_changed_cb (LightDMUser *user)
}
static void
-request_cb (const gchar *request)
+request_cb (const gchar *name, GHashTable *params)
{
- const gchar *c, *start;
- int l;
- gchar *id, *name = NULL;
- gboolean id_matches;
- GHashTable *params;
-
- if (!request)
+ if (!name)
{
g_main_loop_quit (loop);
return;
}
- c = request;
- start = c;
- l = 0;
- while (*c && !isspace (*c))
- {
- c++;
- l++;
- }
- id = g_strdup_printf ("%.*s", l, start);
- id_matches = strcmp (id, greeter_id) == 0;
- g_free (id);
- if (!id_matches)
- return;
-
- while (isspace (*c))
- c++;
- start = c;
- l = 0;
- while (*c && !isspace (*c))
- {
- c++;
- l++;
- }
- name = g_strdup_printf ("%.*s", l, start);
-
- params = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- while (TRUE)
- {
- const gchar *start;
- gchar *param_name, *param_value;
-
- while (isspace (*c))
- c++;
- start = c;
- while (*c && !isspace (*c) && *c != '=')
- c++;
- if (*c == '\0')
- break;
-
- param_name = g_strdup_printf ("%.*s", (int) (c - start), start);
-
- if (*c == '=')
- {
- c++;
- while (isspace (*c))
- c++;
- if (*c == '\"')
- {
- gboolean escaped = FALSE;
- GString *value;
-
- c++;
- value = g_string_new ("");
- while (*c)
- {
- if (*c == '\\')
- {
- if (escaped)
- {
- g_string_append_c (value, '\\');
- escaped = FALSE;
- }
- else
- escaped = TRUE;
- }
- else if (!escaped && *c == '\"')
- break;
- if (!escaped)
- g_string_append_c (value, *c);
- c++;
- }
- param_value = value->str;
- g_string_free (value, FALSE);
- if (*c == '\"')
- c++;
- }
- else
- {
- start = c;
- while (*c && !isspace (*c))
- c++;
- param_value = g_strdup_printf ("%.*s", (int) (c - start), start);
- }
- }
- else
- param_value = g_strdup ("");
-
- g_hash_table_insert (params, param_name, param_value);
- }
-
if (strcmp (name, "AUTHENTICATE") == 0)
lightdm_greeter_authenticate (greeter, g_hash_table_lookup (params, "USERNAME"));
- if (strcmp (name, "AUTHENTICATE-GUEST") == 0)
+ else if (strcmp (name, "AUTHENTICATE-GUEST") == 0)
lightdm_greeter_authenticate_as_guest (greeter);
- if (strcmp (name, "AUTHENTICATE-AUTOLOGIN") == 0)
+ else if (strcmp (name, "AUTHENTICATE-AUTOLOGIN") == 0)
lightdm_greeter_authenticate_autologin (greeter);
- if (strcmp (name, "AUTHENTICATE-REMOTE") == 0)
+ else if (strcmp (name, "AUTHENTICATE-REMOTE") == 0)
lightdm_greeter_authenticate_remote (greeter, g_hash_table_lookup (params, "SESSION"), NULL);
- if (strcmp (name, "RESPOND") == 0)
+ else if (strcmp (name, "RESPOND") == 0)
lightdm_greeter_respond (greeter, g_hash_table_lookup (params, "TEXT"));
- if (strcmp (name, "CANCEL-AUTHENTICATION") == 0)
+ else if (strcmp (name, "CANCEL-AUTHENTICATION") == 0)
lightdm_greeter_cancel_authentication (greeter);
- if (strcmp (name, "START-SESSION") == 0)
+ else if (strcmp (name, "START-SESSION") == 0)
+ {
if (!lightdm_greeter_start_session_sync (greeter, g_hash_table_lookup (params, "SESSION"), NULL))
- status_notify ("%s SESSION-FAILED", greeter_id);
+ status_notify ("%s SESSION-FAILED", greeter_id);
+ }
- if (strcmp (name, "LOG-DEFAULT-SESSION") == 0)
+ else if (strcmp (name, "LOG-DEFAULT-SESSION") == 0)
status_notify ("%s LOG-DEFAULT-SESSION SESSION=%s", greeter_id, lightdm_greeter_get_default_session_hint (greeter));
- if (strcmp (name, "LOG-USER-LIST-LENGTH") == 0)
+ else if (strcmp (name, "LOG-USER-LIST-LENGTH") == 0)
status_notify ("%s LOG-USER-LIST-LENGTH N=%d", greeter_id, lightdm_user_list_get_length (lightdm_user_list_get_instance ()));
- if (strcmp (name, "WRITE-SHARED-DATA") == 0)
+ else if (strcmp (name, "WRITE-SHARED-DATA") == 0)
{
gchar *dir;
@@ -230,7 +136,7 @@ request_cb (const gchar *request)
status_notify ("%s WRITE-SHARED-DATA ERROR=NO_SHARED_DIR", greeter_id);
}
- if (strcmp (name, "READ-SHARED-DATA") == 0)
+ else if (strcmp (name, "READ-SHARED-DATA") == 0)
{
gchar *dir;
@@ -256,7 +162,7 @@ request_cb (const gchar *request)
status_notify ("%s READ-SHARED-DATA ERROR=NO_SHARED_DIR", greeter_id);
}
- if (strcmp (name, "WATCH-USER") == 0)
+ else if (strcmp (name, "WATCH-USER") == 0)
{
LightDMUser *user;
const gchar *username;
@@ -268,7 +174,7 @@ request_cb (const gchar *request)
status_notify ("%s WATCH-USER USERNAME=%s", greeter_id, username);
}
- if (strcmp (name, "LOG-USER") == 0)
+ else if (strcmp (name, "LOG-USER") == 0)
{
LightDMUser *user;
const gchar *username, *image, *background, *language, *layout, *session;
@@ -328,7 +234,7 @@ request_cb (const gchar *request)
g_string_free (status_text, TRUE);
}
- if (strcmp (name, "LOG-USER-LIST") == 0)
+ else if (strcmp (name, "LOG-USER-LIST") == 0)
{
GList *users, *link;
@@ -340,13 +246,13 @@ request_cb (const gchar *request)
}
}
- if (strcmp (name, "GET-CAN-SUSPEND") == 0)
+ else if (strcmp (name, "GET-CAN-SUSPEND") == 0)
{
gboolean can_suspend = lightdm_get_can_suspend ();
status_notify ("%s CAN-SUSPEND ALLOWED=%s", greeter_id, can_suspend ? "TRUE" : "FALSE");
}
- if (strcmp (name, "SUSPEND") == 0)
+ else if (strcmp (name, "SUSPEND") == 0)
{
GError *error = NULL;
if (!lightdm_suspend (&error))
@@ -354,13 +260,13 @@ request_cb (const gchar *request)
g_clear_error (&error);
}
- if (strcmp (name, "GET-CAN-HIBERNATE") == 0)
+ else if (strcmp (name, "GET-CAN-HIBERNATE") == 0)
{
gboolean can_hibernate = lightdm_get_can_hibernate ();
status_notify ("%s CAN-HIBERNATE ALLOWED=%s", greeter_id, can_hibernate ? "TRUE" : "FALSE");
}
- if (strcmp (name, "HIBERNATE") == 0)
+ else if (strcmp (name, "HIBERNATE") == 0)
{
GError *error = NULL;
if (!lightdm_hibernate (&error))
@@ -368,13 +274,13 @@ request_cb (const gchar *request)
g_clear_error (&error);
}
- if (strcmp (name, "GET-CAN-RESTART") == 0)
+ else if (strcmp (name, "GET-CAN-RESTART") == 0)
{
gboolean can_restart = lightdm_get_can_restart ();
status_notify ("%s CAN-RESTART ALLOWED=%s", greeter_id, can_restart ? "TRUE" : "FALSE");
}
- if (strcmp (name, "RESTART") == 0)
+ else if (strcmp (name, "RESTART") == 0)
{
GError *error = NULL;
if (!lightdm_restart (&error))
@@ -382,22 +288,19 @@ request_cb (const gchar *request)
g_clear_error (&error);
}
- if (strcmp (name, "GET-CAN-SHUTDOWN") == 0)
+ else if (strcmp (name, "GET-CAN-SHUTDOWN") == 0)
{
gboolean can_shutdown = lightdm_get_can_shutdown ();
status_notify ("%s CAN-SHUTDOWN ALLOWED=%s", greeter_id, can_shutdown ? "TRUE" : "FALSE");
}
- if (strcmp (name, "SHUTDOWN") == 0)
+ else if (strcmp (name, "SHUTDOWN") == 0)
{
GError *error = NULL;
if (!lightdm_shutdown (&error))
status_notify ("%s FAIL-SHUTDOWN", greeter_id);
g_clear_error (&error);
}
-
- g_free (name);
- g_hash_table_unref (params);
}
static void
@@ -449,7 +352,7 @@ main (int argc, char **argv)
g_unix_signal_add (SIGINT, sigint_cb, NULL);
g_unix_signal_add (SIGTERM, sigterm_cb, NULL);
- status_connect (request_cb);
+ status_connect (request_cb, greeter_id);
status_text = g_string_new ("");
g_string_printf (status_text, "%s START", greeter_id);
diff --git a/tests/src/test-greeter-wrapper.c b/tests/src/test-greeter-wrapper.c
index aa723538..dae274fa 100644
--- a/tests/src/test-greeter-wrapper.c
+++ b/tests/src/test-greeter-wrapper.c
@@ -3,17 +3,12 @@
#include "status.h"
-static void
-request_cb (const gchar *request)
-{
-}
-
int
main (int argc, char **argv)
{
gchar *display;
- status_connect (request_cb);
+ status_connect (NULL, NULL);
display = getenv ("DISPLAY");
if (display == NULL)
diff --git a/tests/src/test-guest-wrapper.c b/tests/src/test-guest-wrapper.c
index 0c883cf9..614acd6e 100644
--- a/tests/src/test-guest-wrapper.c
+++ b/tests/src/test-guest-wrapper.c
@@ -3,17 +3,12 @@
#include "status.h"
-static void
-request_cb (const gchar *request)
-{
-}
-
int
main (int argc, char **argv)
{
gchar *display;
- status_connect (request_cb);
+ status_connect (NULL, NULL);
display = getenv ("DISPLAY");
if (display == NULL)
diff --git a/tests/src/test-mir-greeter.c b/tests/src/test-mir-greeter.c
index 83935fce..d32028e2 100644
--- a/tests/src/test-mir-greeter.c
+++ b/tests/src/test-mir-greeter.c
@@ -46,56 +46,33 @@ signal_cb (int signum)
}
static void
-request_cb (const gchar *request)
+request_cb (const gchar *name, GHashTable *params)
{
- gchar *r;
-
- if (!request)
+ if (!name)
{
g_main_loop_quit (loop);
return;
}
- r = g_strdup_printf ("%s AUTHENTICATE", greeter_id);
- if (strcmp (request, r) == 0)
- lightdm_greeter_authenticate (greeter, NULL);
- g_free (r);
-
- r = g_strdup_printf ("%s AUTHENTICATE USERNAME=", greeter_id);
- if (g_str_has_prefix (request, r))
- lightdm_greeter_authenticate (greeter, request + strlen (r));
- g_free (r);
-
- r = g_strdup_printf ("%s RESPOND TEXT=\"", greeter_id);
- if (g_str_has_prefix (request, r))
+ if (strcmp (name, "AUTHENTICATE") == 0)
+ lightdm_greeter_authenticate (greeter, g_hash_table_lookup (params, "USERNAME"));
+
+ if (strcmp (name, "RESPOND") == 0)
{
- gchar *text = g_strdup (request + strlen (r));
+ gchar *text = g_strdup (g_hash_table_lookup (params, "TEXT"));
text[strlen (text) - 1] = '\0';
lightdm_greeter_respond (greeter, text);
g_free (text);
}
- g_free (r);
- r = g_strdup_printf ("%s CANCEL-AUTHENTICATION", greeter_id);
- if (strcmp (request, r) == 0)
+ if (strcmp (name, "CANCEL-AUTHENTICATION") == 0)
lightdm_greeter_cancel_authentication (greeter);
- g_free (r);
-
- r = g_strdup_printf ("%s START-SESSION", greeter_id);
- if (strcmp (request, r) == 0)
- {
- if (!lightdm_greeter_start_session_sync (greeter, NULL, NULL))
- status_notify ("%s SESSION-FAILED", greeter_id);
- }
- g_free (r);
- r = g_strdup_printf ("%s START-SESSION SESSION=", greeter_id);
- if (g_str_has_prefix (request, r))
+ if (strcmp (name, "START-SESSION") == 0)
{
- if (!lightdm_greeter_start_session_sync (greeter, request + strlen (r), NULL))
+ if (!lightdm_greeter_start_session_sync (greeter, g_hash_table_lookup (params, "SESSION"), NULL))
status_notify ("%s SESSION-FAILED", greeter_id);
}
- g_free (r);
}
int
@@ -112,7 +89,7 @@ main (int argc, char **argv)
loop = g_main_loop_new (NULL, FALSE);
- status_connect (request_cb);
+ status_connect (request_cb, greeter_id);
status_notify ("%s START", greeter_id);
diff --git a/tests/src/test-qt-greeter.cpp b/tests/src/test-qt-greeter.cpp
index 3d24e13f..29434c7b 100644
--- a/tests/src/test-qt-greeter.cpp
+++ b/tests/src/test-qt-greeter.cpp
@@ -80,81 +80,59 @@ signal_cb (int signum)
}
static void
-request_cb (const gchar *request)
+request_cb (const gchar *name, GHashTable *params)
{
gchar *r;
- if (!request)
+ if (!name)
{
app->quit ();
return;
}
- r = g_strdup_printf ("%s AUTHENTICATE", greeter_id);
- if (strcmp (request, r) == 0)
- greeter->authenticate ();
- g_free (r);
-
- r = g_strdup_printf ("%s AUTHENTICATE USERNAME=", greeter_id);
- if (g_str_has_prefix (request, r))
- greeter->authenticate (request + strlen (r));
- g_free (r);
-
- r = g_strdup_printf ("%s AUTHENTICATE-GUEST", greeter_id);
- if (strcmp (request, r) == 0)
- greeter->authenticateAsGuest ();
- g_free (r);
+ if (strcmp (name, "AUTHENTICATE") == 0)
+ {
+ if (g_hash_table_lookup (params, "USERNAME"))
+ greeter->authenticate ((const gchar *) g_hash_table_lookup (params, "USERNAME"));
+ else
+ greeter->authenticate ();
+ }
- r = g_strdup_printf ("%s AUTHENTICATE-AUTOLOGIN", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "AUTHENTICATE-GUEST") == 0)
+ greeter->authenticateAsGuest ();
+
+ else if (strcmp (name, "AUTHENTICATE-AUTOLOGIN") == 0)
greeter->authenticateAutologin ();
- g_free (r);
- r = g_strdup_printf ("%s AUTHENTICATE-REMOTE SESSION=", greeter_id);
- if (g_str_has_prefix (request, r))
- greeter->authenticateRemote (request + strlen (r), NULL);
- g_free (r);
+ else if (strcmp (name, "AUTHENTICATE-REMOTE") == 0)
+ greeter->authenticateRemote ((const gchar *) g_hash_table_lookup (params, "SESSION"), NULL);
- r = g_strdup_printf ("%s RESPOND TEXT=\"", greeter_id);
- if (g_str_has_prefix (request, r))
- {
- gchar *text = g_strdup (request + strlen (r));
- text[strlen (text) - 1] = '\0';
- greeter->respond (text);
- g_free (text);
- }
- g_free (r);
+ else if (strcmp (name, "RESPOND") == 0)
+ greeter->respond ((const gchar *) g_hash_table_lookup (params, "TEXT"));
- r = g_strdup_printf ("%s CANCEL-AUTHENTICATION", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "CANCEL-AUTHENTICATION") == 0)
greeter->cancelAuthentication ();
- g_free (r);
- r = g_strdup_printf ("%s START-SESSION", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "START-SESSION") == 0)
{
- if (!greeter->startSessionSync ())
- status_notify ("%s SESSION-FAILED", greeter_id);
- }
- g_free (r);
-
- r = g_strdup_printf ("%s START-SESSION SESSION=", greeter_id);
- if (g_str_has_prefix (request, r))
- {
- if (!greeter->startSessionSync (request + strlen (r)))
- status_notify ("%s SESSION-FAILED", greeter_id);
+ if (g_hash_table_lookup (params, "SESSION"))
+ {
+ if (!greeter->startSessionSync ((const gchar *) g_hash_table_lookup (params, "SESSION")))
+ status_notify ("%s SESSION-FAILED", greeter_id);
+ }
+ else
+ {
+ if (!greeter->startSessionSync ())
+ status_notify ("%s SESSION-FAILED", greeter_id);
+ }
}
- g_free (r);
- r = g_strdup_printf ("%s LOG-USER-LIST-LENGTH", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "LOG-USER-LIST-LENGTH") == 0)
status_notify ("%s LOG-USER-LIST-LENGTH N=%d", greeter_id, users_model->rowCount (QModelIndex ()));
- g_free (r);
- r = g_strdup_printf ("%s LOG-USER USERNAME=", greeter_id);
- if (g_str_has_prefix (request, r))
+ else if (strcmp (name, "LOG-USER") == 0)
{
- const gchar *username = request + strlen (r);
+ const gchar *username = (const gchar *) g_hash_table_lookup (params, "USERNAME");
for (int i = 0; i < users_model->rowCount (QModelIndex ()); i++)
{
QString name = users_model->data (users_model->index (i, 0), QLightDM::UsersModel::NameRole).toString ();
@@ -162,10 +140,8 @@ request_cb (const gchar *request)
status_notify ("%s LOG-USER USERNAME=%s", greeter_id, qPrintable (name));
}
}
- g_free (r);
- r = g_strdup_printf ("%s LOG-USER-LIST", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "LOG-USER-LIST") == 0)
{
for (int i = 0; i < users_model->rowCount (QModelIndex ()); i++)
{
@@ -173,71 +149,54 @@ request_cb (const gchar *request)
status_notify ("%s LOG-USER USERNAME=%s", greeter_id, qPrintable (name));
}
}
- g_free (r);
- r = g_strdup_printf ("%s GET-CAN-SUSPEND", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "GET-CAN-SUSPEND") == 0)
{
gboolean can_suspend = power->canSuspend ();
status_notify ("%s CAN-SUSPEND ALLOWED=%s", greeter_id, can_suspend ? "TRUE" : "FALSE");
}
- g_free (r);
- r = g_strdup_printf ("%s SUSPEND", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "SUSPEND") == 0)
{
if (!power->suspend ())
status_notify ("%s FAIL-SUSPEND", greeter_id);
}
- g_free (r);
- r = g_strdup_printf ("%s GET-CAN-HIBERNATE", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "GET-CAN-HIBERNATE") == 0)
{
gboolean can_hibernate = power->canHibernate ();
status_notify ("%s CAN-HIBERNATE ALLOWED=%s", greeter_id, can_hibernate ? "TRUE" : "FALSE");
}
- g_free (r);
- r = g_strdup_printf ("%s HIBERNATE", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "HIBERNATE") == 0)
{
if (!power->hibernate ())
status_notify ("%s FAIL-HIBERNATE", greeter_id);
}
- g_free (r);
- r = g_strdup_printf ("%s GET-CAN-RESTART", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "GET-CAN-RESTART") == 0)
{
gboolean can_restart = power->canRestart ();
status_notify ("%s CAN-RESTART ALLOWED=%s", greeter_id, can_restart ? "TRUE" : "FALSE");
}
- g_free (r);
- r = g_strdup_printf ("%s RESTART", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "RESTART") == 0)
{
if (!power->restart ())
status_notify ("%s FAIL-RESTART", greeter_id);
}
- g_free (r);
- r = g_strdup_printf ("%s GET-CAN-SHUTDOWN", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "GET-CAN-SHUTDOWN") == 0)
{
gboolean can_shutdown = power->canShutdown ();
status_notify ("%s CAN-SHUTDOWN ALLOWED=%s", greeter_id, can_shutdown ? "TRUE" : "FALSE");
}
- g_free (r);
- r = g_strdup_printf ("%s SHUTDOWN", greeter_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "SHUTDOWN") == 0)
{
if (!power->shutdown ())
status_notify ("%s FAIL-SHUTDOWN", greeter_id);
}
- g_free (r);
}
int
@@ -265,7 +224,7 @@ main(int argc, char *argv[])
else
greeter_id = g_strdup ("GREETER-?");
- status_connect (request_cb);
+ status_connect (request_cb, greeter_id);
app = new QCoreApplication (argc, argv);
diff --git a/tests/src/test-script-hook.c b/tests/src/test-script-hook.c
index 67ddffdc..7ce8a0cd 100644
--- a/tests/src/test-script-hook.c
+++ b/tests/src/test-script-hook.c
@@ -15,7 +15,7 @@ main (int argc, char **argv)
g_type_init ();
#endif
- status_connect (NULL);
+ status_connect (NULL, NULL);
config = g_key_file_new ();
g_key_file_load_from_file (config, g_build_filename (g_getenv ("LIGHTDM_TEST_ROOT"), "script", NULL), G_KEY_FILE_NONE, NULL);
diff --git a/tests/src/test-session.c b/tests/src/test-session.c
index d7f23a91..1e39a724 100644
--- a/tests/src/test-session.c
+++ b/tests/src/test-session.c
@@ -41,28 +41,21 @@ sigterm_cb (gpointer user_data)
}
static void
-request_cb (const gchar *request)
+request_cb (const gchar *name, GHashTable *params)
{
- gchar *r;
-
- if (!request)
+ if (!name)
{
g_main_loop_quit (loop);
return;
}
- r = g_strdup_printf ("%s LOGOUT", session_id);
- if (strcmp (request, r) == 0)
+ if (strcmp (name, "LOGOUT") == 0)
exit (EXIT_SUCCESS);
- g_free (r);
-
- r = g_strdup_printf ("%s CRASH", session_id);
- if (strcmp (request, r) == 0)
+
+ else if (strcmp (name, "CRASH") == 0)
kill (getpid (), SIGSEGV);
- g_free (r);
- r = g_strdup_printf ("%s LOCK-SEAT", session_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "LOCK-SEAT") == 0)
{
status_notify ("%s LOCK-SEAT", session_id);
g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
@@ -77,10 +70,8 @@ request_cb (const gchar *request)
NULL,
NULL);
}
- g_free (r);
- r = g_strdup_printf ("%s LOCK-SESSION", session_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "LOCK-SESSION") == 0)
{
status_notify ("%s LOCK-SESSION", session_id);
g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
@@ -95,10 +86,8 @@ request_cb (const gchar *request)
NULL,
NULL);
}
- g_free (r);
- r = g_strdup_printf ("%s LIST-GROUPS", session_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "LIST-GROUPS") == 0)
{
int n_groups, i;
gid_t *groups;
@@ -130,29 +119,22 @@ request_cb (const gchar *request)
free (groups);
}
- r = g_strdup_printf ("%s READ-ENV NAME=", session_id);
- if (g_str_has_prefix (request, r))
+ else if (strcmp (name, "READ-ENV") == 0)
{
- const gchar *name = request + strlen (r);
+ const gchar *name = g_hash_table_lookup (params, "NAME");
const gchar *value = g_getenv (name);
status_notify ("%s READ-ENV NAME=%s VALUE=%s", session_id, name, value ? value : "");
}
- g_free (r);
- r = g_strdup_printf ("%s WRITE-STDOUT TEXT=", session_id);
- if (g_str_has_prefix (request, r))
- g_print ("%s", request + strlen (r));
- g_free (r);
+ else if (strcmp (name, "WRITE-STDOUT") == 0)
+ g_print ("%s", (const gchar *) g_hash_table_lookup (params, "TEXT"));
- r = g_strdup_printf ("%s WRITE-STDERR TEXT=", session_id);
- if (g_str_has_prefix (request, r))
- g_printerr ("%s", request + strlen (r));
- g_free (r);
+ else if (strcmp (name, "WRITE-STDERR") == 0)
+ g_printerr ("%s", (const gchar *) g_hash_table_lookup (params, "TEXT"));
- r = g_strdup_printf ("%s READ FILE=", session_id);
- if (g_str_has_prefix (request, r))
+ else if (strcmp (name, "READ") == 0)
{
- const gchar *name = request + strlen (r);
+ const gchar *name = g_hash_table_lookup (params, "FILE");
gchar *contents = NULL;
GError *error = NULL;
@@ -163,15 +145,11 @@ request_cb (const gchar *request)
g_free (contents);
g_clear_error (&error);
}
- g_free (r);
- r = g_strdup_printf ("%s LIST-UNKNOWN-FILE-DESCRIPTORS", session_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "LIST-UNKNOWN-FILE-DESCRIPTORS") == 0)
status_notify ("%s LIST-UNKNOWN-FILE-DESCRIPTORS FDS=%s", session_id, open_fds->str);
- g_free (r);
- r = g_strdup_printf ("%s CHECK-X-AUTHORITY", session_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "CHECK-X-AUTHORITY") == 0)
{
gchar *xauthority;
GStatBuf file_info;
@@ -197,12 +175,10 @@ request_cb (const gchar *request)
status_notify ("%s CHECK-X-AUTHORITY MODE=%s", session_id, mode_string->str);
g_string_free (mode_string, TRUE);
}
- g_free (r);
- r = g_strdup_printf ("%s WRITE-SHARED-DATA DATA=", session_id);
- if (g_str_has_prefix (request, r))
+ else if (strcmp (name, "WRITE-SHARED-DATA") == 0)
{
- const gchar *data = request + strlen (r);
+ const gchar *data = g_hash_table_lookup (params, "DATA");
gchar *dir;
dir = getenv ("XDG_GREETER_DATA_DIR");
@@ -224,10 +200,8 @@ request_cb (const gchar *request)
else
status_notify ("%s WRITE-SHARED-DATA ERROR=NO_XDG_GREETER_DATA_DIR", session_id);
}
- g_free (r);
- r = g_strdup_printf ("%s READ-SHARED-DATA", session_id);
- if (strcmp (request, r) == 0)
+ else if (strcmp (name, "READ-SHARED-DATA") == 0)
{
gchar *dir;
@@ -250,7 +224,6 @@ request_cb (const gchar *request)
else
status_notify ("%s WRITE-SHARED-DATA ERROR=NO_XDG_GREETER_DATA_DIR", session_id);
}
- g_free (r);
}
int
@@ -304,7 +277,7 @@ main (int argc, char **argv)
g_unix_signal_add (SIGINT, sigint_cb, NULL);
g_unix_signal_add (SIGTERM, sigterm_cb, NULL);
- status_connect (request_cb);
+ status_connect (request_cb, session_id);
status_text = g_string_new ("");
g_string_printf (status_text, "%s START", session_id);
diff --git a/tests/src/unity-system-compositor.c b/tests/src/unity-system-compositor.c
index e10041fe..eae07317 100644
--- a/tests/src/unity-system-compositor.c
+++ b/tests/src/unity-system-compositor.c
@@ -118,21 +118,24 @@ read_message_cb (GIOChannel *channel, GIOCondition condition, gpointer data)
}
static void
-request_cb (const gchar *request)
+request_cb (const gchar *name, GHashTable *params)
{
- if (!request)
+ if (!name)
{
g_main_loop_quit (loop);
return;
}
- if (strcmp (request, "UNITY-SYSTEM-COMPOSITOR PING") == 0)
+ if (strcmp (name, "PING") == 0)
write_message (USC_MESSAGE_PING, NULL, 0);
- else if (strcmp (request, "UNITY-SYSTEM-COMPOSITOR PONG") == 0)
+
+ else if (strcmp (name, "PONG") == 0)
write_message (USC_MESSAGE_PONG, NULL, 0);
- else if (strcmp (request, "UNITY-SYSTEM-COMPOSITOR READY") == 0)
+
+ else if (strcmp (name, "READY") == 0)
write_message (USC_MESSAGE_READY, NULL, 0);
- else if (strcmp (request, "UNITY-SYSTEM-COMPOSITOR CRASH") == 0)
+
+ else if (strcmp (name, "CRASH") == 0)
kill (getpid (), SIGSEGV);
}
@@ -154,7 +157,7 @@ main (int argc, char **argv)
g_unix_signal_add (SIGINT, sigint_cb, NULL);
g_unix_signal_add (SIGTERM, sigterm_cb, NULL);
- status_connect (request_cb);
+ status_connect (request_cb, "UNITY-SYSTEM-COMPOSITOR");
for (i = 1; i < argc; i++)
{
diff --git a/tests/src/vnc-client.c b/tests/src/vnc-client.c
index 01419a32..a8a4b591 100644
--- a/tests/src/vnc-client.c
+++ b/tests/src/vnc-client.c
@@ -27,7 +27,7 @@ main (int argc, char **argv)
g_type_init ();
#endif
- status_connect (NULL);
+ status_connect (NULL, NULL);
status_notify ("VNC-CLIENT START");