diff options
author | Eric Koegel <eric.koegel@gmail.com> | 2015-03-30 09:51:29 +0300 |
---|---|---|
committer | Eric Koegel <eric.koegel@gmail.com> | 2015-04-13 11:41:19 +0300 |
commit | 2fde17d8a3f06717b47ccb392d1d1c3b5c8eaa72 (patch) | |
tree | 6e8b3f5b4a657adb68e06d89a36b37a62631c9e9 | |
parent | 8f4fe327e3e657a4b745e242615ba1d281cdd4d0 (diff) | |
download | ConsoleKit2-2fde17d8a3f06717b47ccb392d1d1c3b5c8eaa72.tar.gz |
Minor fixes
We can't pass around the GVariantBuilder and parse it at the same
time so we'll need to fix the is-local in another way.
Fix the signal emission on the manager.
We may need to use a GDBusObjectManager to get the signals for
interface-added/interface-removed on our Sessions (and eventually
Seats?)
-rw-r--r-- | src/ck-manager.c | 34 | ||||
-rw-r--r-- | src/ck-session-leader.c | 16 | ||||
-rw-r--r-- | src/ck-session-leader.h | 2 | ||||
-rw-r--r-- | src/test-session-leader.c | 5 |
4 files changed, 30 insertions, 27 deletions
diff --git a/src/ck-manager.c b/src/ck-manager.c index 67e4211..1d8606d 100644 --- a/src/ck-manager.c +++ b/src/ck-manager.c @@ -980,6 +980,12 @@ get_caller_info (CkManager *manager, GError *error = NULL; if (sender == NULL) { + g_debug ("sender == NULL"); + goto out; + } + + if (manager->priv->bus_proxy == NULL) { + g_debug ("manager->priv->bus_proxy == NULL"); goto out; } @@ -995,7 +1001,7 @@ get_caller_info (CkManager *manager, g_error_free (error); goto out; } - g_variant_get (value, "(u)", &calling_uid); + g_variant_get (value, "(u)", calling_uid); value = g_dbus_proxy_call_sync (manager->priv->bus_proxy, "GetConnectionUnixProcessID", g_variant_new ("(s)", sender), @@ -1009,7 +1015,7 @@ get_caller_info (CkManager *manager, g_error_free (error); goto out; } - g_variant_get (value, "(u)", &calling_pid); + g_variant_get (value, "(u)", calling_pid); res = TRUE; @@ -2106,7 +2112,7 @@ add_new_seat (CkManager *manager, ck_seat_run_programs (seat, NULL, NULL, "seat_added"); g_debug ("Emitting seat-added: %s", sid); - g_signal_emit (manager, signals [SEAT_ADDED], 0, sid); + console_kit_manager_emit_seat_added (CONSOLE_KIT_MANAGER (manager), sid); log_seat_added_event (manager, seat); @@ -2149,7 +2155,7 @@ remove_seat (CkManager *manager, ck_seat_run_programs (seat, NULL, NULL, "seat_removed"); g_debug ("Emitting seat-removed: %s", sid); - g_signal_emit (manager, signals [SEAT_REMOVED], 0, sid); + console_kit_manager_emit_seat_removed (CONSOLE_KIT_MANAGER (manager), sid); log_seat_removed_event (manager, orig_seat); @@ -2239,7 +2245,7 @@ manager_set_system_idle_hint (CkManager *manager, g_get_current_time (&manager->priv->system_idle_since_hint); g_debug ("Emitting system-idle-hint-changed: %d", idle_hint); - g_signal_emit (manager, signals [SYSTEM_IDLE_HINT_CHANGED], 0, idle_hint); + console_kit_manager_emit_system_idle_hint_changed (CONSOLE_KIT_MANAGER (manager), idle_hint); } return TRUE; @@ -2338,6 +2344,8 @@ open_session_for_leader (CkManager *manager, return; } +/* FIXME: probably need to use a GDbusObjectManager and monitor + * interface-added/interface-removed signals g_bus_watch_name_on_connection (manager->priv->connection, ssid, G_BUS_NAME_WATCHER_FLAGS_NONE, @@ -2345,7 +2353,7 @@ open_session_for_leader (CkManager *manager, remove_sessions_for_connection, manager, NULL); - +*/ g_hash_table_insert (manager->priv->sessions, g_strdup (ssid), g_object_ref (session)); @@ -2424,7 +2432,7 @@ _verify_login_session_id_is_local (CkManager *manager, static void verify_and_open_session_for_leader (CkManager *manager, CkSessionLeader *leader, - GVariantBuilder *parameters, + GVariant *parameters, GDBusMethodInvocation *context) { gboolean is_local = FALSE; @@ -2451,20 +2459,17 @@ verify_and_open_session_for_leader (CkManager *manager, } g_debug ("CkManager: found is-local=%s", is_local ? "true" : "false"); - g_variant_builder_add (parameters, "{sv}", "is-local", is_local); + /* FIXME: we need to rework the setting of is-local */ open_session_for_leader (manager, leader, - g_variant_builder_end (parameters), + parameters, context); - - /* Done with the builder, release the memory */ - g_variant_builder_unref (parameters); } static void collect_parameters_cb (CkSessionLeader *leader, - GVariantBuilder *parameters, + GVariant *parameters, GDBusMethodInvocation *context, CkManager *manager) { @@ -2515,6 +2520,7 @@ create_session_for_sender (CkManager *manager, &uid, &pid); if (! res) { + g_debug ("Unable to get information about the calling process"); throw_error (context, CK_MANAGER_ERROR_GENERAL, "Unable to get information about the calling process"); return FALSE; } @@ -3003,8 +3009,6 @@ register_manager (CkManager *manager, GDBusConnection *connection) polkit_authority_get_async (NULL, polkit_authority_get_cb, manager); #endif - g_debug ("exporting path %s", CK_MANAGER_DBUS_PATH); - if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (CONSOLE_KIT_MANAGER (manager)), manager->priv->connection, CK_MANAGER_DBUS_PATH, diff --git a/src/ck-session-leader.c b/src/ck-session-leader.c index 5de1be2..4f9df57 100644 --- a/src/ck-session-leader.c +++ b/src/ck-session-leader.c @@ -166,11 +166,11 @@ add_to_parameters (gpointer key, /* Allocates and returns a GVariantBuilder holding all the parameters, * free with g_variant_builder_unref when done using it */ -static GVariantBuilder * +static GVariant * parse_output (CkSessionLeader *leader, const char *output) { - GVariantBuilder *ck_parameters; + GVariantBuilder ck_parameters; char **lines; int i; @@ -179,7 +179,7 @@ parse_output (CkSessionLeader *leader, return NULL; } - ck_parameters = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}")); + g_variant_builder_init (&ck_parameters, G_VARIANT_TYPE ("a{sv}")); /* first add generated params */ for (i = 0; lines[i] != NULL; i++) { @@ -208,7 +208,7 @@ parse_output (CkSessionLeader *leader, element = g_variant_new (variant_type, vals[1]); - g_variant_builder_add (ck_parameters, "{sv}", vals[0], element); + g_variant_builder_add (&ck_parameters, "{sv}", vals[0], element); g_strfreev (vals); } @@ -217,9 +217,9 @@ parse_output (CkSessionLeader *leader, /* now overlay the overrides */ g_hash_table_foreach (leader->priv->override_parameters, (GHFunc)add_to_parameters, - ck_parameters); + &ck_parameters); - return ck_parameters; + return g_variant_builder_end (&ck_parameters); } static void @@ -286,8 +286,8 @@ job_completed (CkJob *job, { g_debug ("Job status: %d", status); if (status == 0) { - char *output; - GVariantBuilder *parameters; + char *output; + GVariant *parameters; output = NULL; ck_job_get_stdout (job, &output); diff --git a/src/ck-session-leader.h b/src/ck-session-leader.h index 0fe9ba2..80b312b 100644 --- a/src/ck-session-leader.h +++ b/src/ck-session-leader.h @@ -56,7 +56,7 @@ typedef enum #define CK_SESSION_LEADER_ERROR ck_session_leader_error_quark () typedef void (* CkSessionLeaderDoneFunc) (CkSessionLeader *session_leader, - GVariantBuilder *parameters, + GVariant *parameters, GDBusMethodInvocation *context, gpointer data); diff --git a/src/test-session-leader.c b/src/test-session-leader.c index 57f55f1..c467157 100644 --- a/src/test-session-leader.c +++ b/src/test-session-leader.c @@ -42,13 +42,12 @@ CkSessionLeader *leader = NULL; static void collect_parameters_cb (CkSessionLeader *leader, - GVariantBuilder *parameters, + GVariant *parameters, GDBusMethodInvocation *context, GMainLoop *loop) { - g_debug ("[collect_parameters_cb] Parameters: %s", g_variant_print (g_variant_builder_end (parameters), TRUE)); + g_debug ("[collect_parameters_cb] Parameters: %s", g_variant_print (parameters, TRUE)); g_main_loop_quit (loop); - g_variant_builder_unref (parameters); } static void |