From 6d444beb4392c2116533749fa869b6a1c4c6454a Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 28 Aug 2013 12:37:47 -0400 Subject: Flesh out service to actually do what it says on the tin --- CMakeLists.txt | 7 +++ data/CMakeLists.txt | 10 ++++ data/com.canonical.Unity.Greeter.Broadcast.conf | 21 ++++++++ debian/unity-greeter-session-broadcast.install | 1 + service/CMakeLists.txt | 10 +++- service/service.c | 70 ++++++++++++++++++++++++- 6 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 data/com.canonical.Unity.Greeter.Broadcast.conf diff --git a/CMakeLists.txt b/CMakeLists.txt index 86192f6..97d6cad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,13 @@ else() endif() message("Installing DBus services to ${DBUSSERVICEDIR}") +if(${LOCAL_INSTALL}) + set(DBUSSYSCONFDIR "${CMAKE_INSTALL_SYSCONFDIR}") +else() + EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS dbus-1 --variable sysconfdir OUTPUT_VARIABLE DBUSSYSCONFDIR) +endif() +message("Installing DBus policy files to ${DBUSSYSCONFDIR}") + if(${LOCAL_INSTALL}) set(DBUSIFACEDIR "${CMAKE_INSTALL_DATADIR}/dbus-1/interfaces/") else() diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index b784adb..d00c9ef 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -9,6 +9,16 @@ com.canonical.Unity.Greeter.Broadcast.xml DESTINATION ${DBUSIFACEDIR} ) +########################### +# DBus Policy Files +########################### + +install( +FILES +com.canonical.Unity.Greeter.Broadcast.conf +DESTINATION ${DBUSSYSCONFDIR}/dbus-1/system.d +) + ########################### # Dbus Services ########################### diff --git a/data/com.canonical.Unity.Greeter.Broadcast.conf b/data/com.canonical.Unity.Greeter.Broadcast.conf new file mode 100644 index 0000000..8a8cfe6 --- /dev/null +++ b/data/com.canonical.Unity.Greeter.Broadcast.conf @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + diff --git a/debian/unity-greeter-session-broadcast.install b/debian/unity-greeter-session-broadcast.install index 46805f9..4a7f626 100644 --- a/debian/unity-greeter-session-broadcast.install +++ b/debian/unity-greeter-session-broadcast.install @@ -1,3 +1,4 @@ +etc/dbus-1 usr/lib/*/unity-greeter-session-broadcast usr/share/dbus-1 usr/share/glib-2.0 diff --git a/service/CMakeLists.txt b/service/CMakeLists.txt index ac70f23..7e336d5 100644 --- a/service/CMakeLists.txt +++ b/service/CMakeLists.txt @@ -30,11 +30,19 @@ ${GOBJECT2_LIBRARIES} # Service Executable ########################### +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} +) + add_executable(service-exec service.c) set_target_properties(service-exec PROPERTIES OUTPUT_NAME "unity-greeter-session-broadcast-service") -target_link_libraries(service-exec service-generated) +target_link_libraries(service-exec +service-generated +${GIO2_LIBRARIES} +) ########################### # Installation diff --git a/service/service.c b/service/service.c index 3c2f9e2..adf45b3 100644 --- a/service/service.c +++ b/service/service.c @@ -15,15 +15,81 @@ * */ +#include +#include +#include "service-iface.h" + +static gboolean +on_handle_request_application_start (ServiceIfaceComCanonicalUnityGreeterBroadcast *object, + GDBusMethodInvocation *invocation, + const gchar *arg_username, + const gchar *arg_appId) +{ + /* Simply pass the request on */ + service_iface_com_canonical_unity_greeter_broadcast_emit_start_application (object, + arg_username, + arg_appId); + service_iface_com_canonical_unity_greeter_broadcast_complete_request_application_start (object, + invocation); + return TRUE; +} + +static void +on_bus_acquired (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + GError *error = NULL; + ServiceIfaceComCanonicalUnityGreeterBroadcast *interface; + + interface = (ServiceIfaceComCanonicalUnityGreeterBroadcast *)user_data; + + if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (interface), + connection, + "/com/canonical/Unity/Greeter/Broadcast", + &error)) + { + g_error ("Unable to export interface: %s, exiting", error->message); + } +} + +static void +on_name_lost (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + g_error ("Lost bus name, exiting"); +} + int main (int argc, char * argv[]) { + guint owner_id; + GMainLoop *loop; + ServiceIfaceComCanonicalUnityGreeterBroadcast *interface; + interface = service_iface_com_canonical_unity_greeter_broadcast_skeleton_new (); + g_signal_connect (interface, + "handle-request-application-start", + G_CALLBACK (on_handle_request_application_start), + NULL); + owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM, + "com.canonical.Unity.Greeter.Broadcast", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus_acquired, + NULL, + on_name_lost, + g_object_ref (interface), + g_object_unref); + loop = g_main_loop_new (NULL, FALSE); + g_main_loop_run (loop); + g_bus_unown_name (owner_id); + g_object_unref (interface); + g_object_unref (loop); - - return 0; + return 0; } -- cgit v1.2.3