-I$(top_srcdir)/liblightdm-gobject \
$(WARN_CFLAGS) \
$(GLIB_CFLAGS) \
- $(GOBJECT_CFLAGS) \
+ $(GIO_UNIX_CFLAGS) \
$(XCB_CFLAGS)
test_gobject_greeter_LDADD = \
-L$(top_builddir)/liblightdm-gobject \
-llightdm-gobject-1 \
$(GLIB_LIBS) \
- $(GOBJECT_LIBS) \
+ $(GIO_UNIX_LIBS) \
$(XCB_LIBS)
guest_account_SOURCES = guest-account.c status.c status.h
guest_account_CFLAGS = \
$(WARN_CFLAGS) \
- $(GLIB_CFLAGS)
+ $(GLIB_CFLAGS) \
+ $(GIO_UNIX_CFLAGS)
guest_account_LDADD = \
- $(GLIB_LIBS)
+ $(GLIB_LIBS) \
+ $(GIO_UNIX_LIBS)
test_script_hook_SOURCES = test-script-hook.c status.c status.h
test_script_hook_CFLAGS = \
$(WARN_CFLAGS) \
- $(GLIB_CFLAGS)
+ $(GLIB_CFLAGS) \
+ $(GIO_UNIX_CFLAGS)
test_script_hook_LDADD = \
- $(GLIB_LIBS)
+ $(GLIB_LIBS) \
+ $(GIO_UNIX_LIBS)
test-qt-greeter_moc.cpp: test-qt-greeter.h
$(MOC) $< -o $@
test_qt_greeter_SOURCES = test-qt-greeter.cpp test-qt-greeter.h status.c status.h
nodist_test_qt_greeter_SOURCES = test-qt-greeter_moc.cpp
+test_qt_greeter_CFLAGS = \
+ $(GLIB_CFLAGS) \
+ $(GIO_UNIX_CFLAGS) \
+ $(XCB_CFLAGS)
test_qt_greeter_CXXFLAGS = \
-I$(top_srcdir)/liblightdm-qt \
$(LIBLIGHTDM_QT_CFLAGS) \
- $(XCB_CFLAGS)
+ $(GLIB_CFLAGS)
test_qt_greeter_LDADD = \
-L$(top_builddir)/liblightdm-qt \
-llightdm-qt-2 \
$(LIBLIGHTDM_QT_LIBS) \
+ $(GLIB_LIBS) \
+ $(GIO_UNIX_LIBS) \
$(XCB_LIBS)
test_session_SOURCES = test-session.c status.c status.h
test_session_CFLAGS = \
$(WARN_CFLAGS) \
$(GLIB_CFLAGS) \
+ $(GIO_UNIX_CFLAGS) \
$(XCB_CFLAGS)
test_session_LDADD = \
$(GLIB_LIBS) \
+ $(GIO_UNIX_LIBS) \
$(XCB_LIBS)
initctl_SOURCES = initctl.c status.c status.h
initctl_CFLAGS = \
$(WARN_CFLAGS) \
- $(GLIB_CFLAGS)
+ $(GLIB_CFLAGS) \
+ $(GIO_UNIX_CFLAGS)
initctl_LDADD = \
- $(GLIB_LIBS)
+ $(GLIB_LIBS) \
+ $(GIO_UNIX_LIBS)
plymouth_SOURCES = plymouth.c status.c status.h
plymouth_CFLAGS = \
$(WARN_CFLAGS) \
- $(GLIB_CFLAGS)
+ $(GLIB_CFLAGS) \
+ $(GIO_UNIX_CFLAGS)
plymouth_LDADD = \
- $(GLIB_LIBS)
+ $(GLIB_LIBS) \
+ $(GIO_UNIX_LIBS)
vnc_client_SOURCES = vnc-client.c status.c status.h
vnc_client_CFLAGS = \
$(WARN_CFLAGS) \
$(GLIB_CFLAGS) \
- $(GIO_CFLAGS)
+ $(GIO_CFLAGS) \
+ $(GIO_UNIX_CFLAGS)
vnc_client_LDADD = \
$(GLIB_LIBS) \
- $(GIO_LIBS)
+ $(GIO_LIBS) \
+ $(GIO_UNIX_LIBS)
CLEANFILES = \
test-qt-greeter_moc.cpp
#include <errno.h>
#include <string.h>
#include <glib.h>
+#include <glib-object.h>
#include "status.h"
int
main (int argc, char **argv)
{
+ g_type_init ();
+
config = g_key_file_new ();
if (g_getenv ("LIGHTDM_TEST_CONFIG"))
g_key_file_load_from_file (config, g_getenv ("LIGHTDM_TEST_CONFIG"), G_KEY_FILE_NONE, NULL);
#include <stdlib.h>
#include <string.h>
#include <glib.h>
+#include <glib-object.h>
#include "status.h"
int
main (int argc, char **argv)
{
+ g_type_init ();
+
config = g_key_file_new ();
if (g_getenv ("LIGHTDM_TEST_CONFIG"))
g_key_file_load_from_file (config, g_getenv ("LIGHTDM_TEST_CONFIG"), G_KEY_FILE_NONE, NULL);
-#include <stdlib.h>
#include <stdio.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
+#include <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <gio/gunixsocketaddress.h>
#include "status.h"
-/* For some reason sys/un.h doesn't define this */
-#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX 108
-#endif
-
void
-notify_status (const char *format, ...)
+notify_status (const gchar *format, ...)
{
- int s;
- struct sockaddr_un address;
- char *socket_name, status[1024];
+ GSocket *s;
+ GSocketAddress *address;
+ const gchar *path;
+ gchar status[1024];
va_list ap;
+ GError *error = NULL;
va_start (ap, format);
vsnprintf (status, 1024, format, ap);
va_end (ap);
- s = socket (AF_UNIX, SOCK_DGRAM, 0);
- if (s < 0)
+ path = g_getenv ("LIGHTDM_TEST_STATUS_SOCKET");
+ if (!path)
{
- fprintf (stderr, "Unable to open socket for status: %s\n", strerror (errno));
- return;
- }
-
- socket_name = getenv ("LIGHTDM_TEST_STATUS_SOCKET");
- if (!socket_name)
- {
- static int warned = 0;
+ static gboolean warned = FALSE;
if (!warned)
{
- fprintf (stderr, "LIGHTDM_TEST_STATUS_SOCKET not defined\n");
- warned = 1;
+ g_printerr ("LIGHTDM_TEST_STATUS_SOCKET not defined\n");
+ warned = TRUE;
}
- fprintf (stderr, "%s", status);
- fprintf (stderr, "\n");
+ g_printerr ("%s\n", status);
return;
}
- address.sun_family = AF_UNIX;
- strncpy (address.sun_path, socket_name, UNIX_PATH_MAX);
- if (sendto (s, status, strlen (status), 0, (struct sockaddr *) &address, sizeof (address)) < 0)
- {
- fprintf (stderr, "Error writing status: %s\n", strerror (errno));
+ s = g_socket_new (G_SOCKET_FAMILY_UNIX, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_DEFAULT, &error);
+ if (error)
+ g_printerr ("Unable to open socket for status: %s\n", error->message);
+ g_clear_error (&error);
+ if (!s)
return;
- }
- close (s);
+ address = g_unix_socket_address_new (path);
+ g_socket_connect (s, address, NULL, &error);
+ g_object_unref (address);
+ if (error)
+ g_printerr ("Failed to connect to status socket %s: %s\n", path, error->message);
+ g_clear_error (&error);
+
+ g_socket_send (s, status, strlen (status), NULL, &error);
+ if (error)
+ g_printerr ("Failed to write to status socket: %s\n", error->message);
+ g_clear_error (&error);
+ g_object_unref (s);
}
signal (SIGINT, signal_cb);
signal (SIGTERM, signal_cb);
+ g_type_init ();
+
notify_status ("GREETER %s START", getenv ("DISPLAY"));
config = g_key_file_new ();
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
+#include <glib-object.h>
#include <xcb/xcb.h>
#include <QLightDM/Greeter>
#include <QtCore/QSettings>
int main(int argc, char *argv[])
{
+ g_type_init ();
+
QCoreApplication app(argc, argv);
signal (SIGINT, signal_cb);
return script_iter->data;
}
-static GSocket *
-open_unix_socket (const gchar *path, GError **error)
-{
- GSocket *s;
- GSocketAddress *address;
- gboolean result;
-
- s = g_socket_new (G_SOCKET_FAMILY_UNIX, G_SOCKET_TYPE_DATAGRAM, G_SOCKET_PROTOCOL_DEFAULT, error);
- if (!s)
- return NULL;
- address = g_unix_socket_address_new (path);
- result = g_socket_bind (s, address, FALSE, error);
- g_object_unref (address);
- if (!result)
- {
- g_object_unref (s);
- return NULL;
- }
- return s;
-}
-
static void
run_commands ()
{
static gboolean
status_message_cb (gpointer data)
{
+ GSocket *socket = data;
gchar buffer[1024];
ssize_t n_read;
GError *error = NULL;
+ GSocketAddress *address = NULL;
- n_read = g_socket_receive (status_socket, buffer, 1023, NULL, &error);
+ n_read = g_socket_receive_from (socket, &address, buffer, 1023, NULL, &error);
if (error)
g_warning ("Error reading from socket: %s", error->message);
g_clear_error (&error);
return TRUE;
}
+static gboolean
+status_connect_cb (gpointer data)
+{
+ GSocket *socket;
+ GError *error = NULL;
+
+ socket = g_socket_accept (status_socket, NULL, &error);
+ if (error)
+ g_warning ("Failed to accept status connection: %s", error->message);
+ g_clear_error (&error);
+ if (socket)
+ {
+ GSource *source;
+
+ source = g_socket_create_source (socket, G_IO_IN, NULL);
+ g_source_set_callback (source, status_message_cb, socket, NULL);
+ g_source_attach (source, NULL);
+ }
+
+ return TRUE;
+}
+
static void
load_script (const gchar *filename)
{
/* Open socket for status */
status_socket_name = g_build_filename (cwd, ".status-socket", NULL);
g_setenv ("LIGHTDM_TEST_STATUS_SOCKET", status_socket_name, TRUE);
- unlink (status_socket_name);
- status_socket = open_unix_socket (status_socket_name, &error);
+ unlink (status_socket_name);
+ status_socket = g_socket_new (G_SOCKET_FAMILY_UNIX, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_DEFAULT, &error);
if (error)
- g_warning ("Error opening status socket: %s", error->message);
+ g_warning ("Error creating status socket: %s", error->message);
g_clear_error (&error);
+ if (status_socket)
+ {
+ GSocketAddress *address;
+ gboolean result;
+
+ address = g_unix_socket_address_new (status_socket_name);
+ result = g_socket_bind (status_socket, address, FALSE, &error);
+ g_object_unref (address);
+ if (error)
+ g_warning ("Error binding status socket: %s", error->message);
+ g_clear_error (&error);
+ if (result)
+ {
+ result = g_socket_listen (status_socket, &error);
+ if (error)
+ g_warning ("Error listening on status socket: %s", error->message);
+ g_clear_error (&error);
+ }
+ if (!result)
+ {
+ g_object_unref (status_socket);
+ status_socket = NULL;
+ }
+ }
if (!status_socket)
quit (EXIT_FAILURE);
status_source = g_socket_create_source (status_socket, G_IO_IN, NULL);
- g_source_set_callback (status_source, status_message_cb, NULL, NULL);
+ g_source_set_callback (status_source, status_connect_cb, NULL, NULL);
g_source_attach (status_source, NULL);
/* Run from a temporary directory */
#include <stdlib.h>
#include <glib.h>
+#include <glib-object.h>
#include "status.h"
int
main (int argc, char **argv)
{
+ g_type_init ();
+
config = g_key_file_new ();
if (g_getenv ("LIGHTDM_TEST_CONFIG"))
g_key_file_load_from_file (config, g_getenv ("LIGHTDM_TEST_CONFIG"), G_KEY_FILE_NONE, NULL);
#include <unistd.h>
#include <xcb/xcb.h>
#include <glib.h>
+#include <glib-object.h>
#include "status.h"
signal (SIGINT, quit_cb);
signal (SIGTERM, quit_cb);
+ g_type_init ();
+
if (argc > 1)
notify_status ("SESSION %s START NAME=%s USER=%s", getenv ("DISPLAY"), argv[1], getenv ("USER"));
else