diff options
Diffstat (limited to 'plugins/smartcard')
-rw-r--r-- | plugins/smartcard/msd-smartcard-manager.c | 6 | ||||
-rw-r--r-- | plugins/smartcard/msd-smartcard-manager.h | 1 | ||||
-rw-r--r-- | plugins/smartcard/msd-smartcard-plugin.c | 116 | ||||
-rw-r--r-- | plugins/smartcard/msd-smartcard-plugin.h | 1 | ||||
-rw-r--r-- | plugins/smartcard/msd-smartcard.c | 1 | ||||
-rw-r--r-- | plugins/smartcard/msd-smartcard.h | 1 |
6 files changed, 78 insertions, 48 deletions
diff --git a/plugins/smartcard/msd-smartcard-manager.c b/plugins/smartcard/msd-smartcard-manager.c index 43d6644..6d1ec4a 100644 --- a/plugins/smartcard/msd-smartcard-manager.c +++ b/plugins/smartcard/msd-smartcard-manager.c @@ -2,6 +2,7 @@ * removal events * * Copyright (C) 2006, 2009 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -290,8 +291,8 @@ msd_smartcard_manager_class_install_signals (MsdSmartcardManagerClass *manager_c } static gboolean -slot_id_equal (CK_SLOT_ID *slot_id_1, - CK_SLOT_ID *slot_id_2) +slot_id_equal (const CK_SLOT_ID *slot_id_1, + const CK_SLOT_ID *slot_id_2) { g_assert (slot_id_1 != NULL); g_assert (slot_id_2 != NULL); @@ -1207,7 +1208,6 @@ msd_smartcard_manager_worker_run (MsdSmartcardManagerWorker *worker) { GError *error; - error = NULL; while (msd_smartcard_manager_worker_watch_for_and_process_event (worker, &error)); diff --git a/plugins/smartcard/msd-smartcard-manager.h b/plugins/smartcard/msd-smartcard-manager.h index c5c9d55..b8b0e7c 100644 --- a/plugins/smartcard/msd-smartcard-manager.h +++ b/plugins/smartcard/msd-smartcard-manager.h @@ -2,6 +2,7 @@ * removal events * * Copyright (C) 2006, 2009 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/plugins/smartcard/msd-smartcard-plugin.c b/plugins/smartcard/msd-smartcard-plugin.c index b11deda..3792cb5 100644 --- a/plugins/smartcard/msd-smartcard-plugin.c +++ b/plugins/smartcard/msd-smartcard-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,9 +26,6 @@ #include <glib.h> #include <glib-object.h> - -#include <dbus/dbus-glib.h> - #include <gio/gio.h> #include "mate-settings-plugin.h" @@ -36,8 +34,7 @@ struct MsdSmartcardPluginPrivate { MsdSmartcardManager *manager; - DBusGConnection *bus_connection; - + GDBusProxy *screensaver_proxy; guint32 is_active : 1; }; @@ -65,62 +62,82 @@ MATE_SETTINGS_PLUGIN_REGISTER_WITH_PRIVATE (MsdSmartcardPlugin, msd_smartcard_pl static void simulate_user_activity (MsdSmartcardPlugin *plugin) { - DBusGProxy *screensaver_proxy; + GError *error = NULL; + GVariant *ret; g_debug ("MsdSmartcardPlugin telling screensaver about smart card insertion"); - screensaver_proxy = dbus_g_proxy_new_for_name (plugin->priv->bus_connection, - SCREENSAVER_DBUS_NAME, - SCREENSAVER_DBUS_PATH, - SCREENSAVER_DBUS_INTERFACE); - - dbus_g_proxy_call_no_reply (screensaver_proxy, - "SimulateUserActivity", - G_TYPE_INVALID, G_TYPE_INVALID); - - g_object_unref (screensaver_proxy); + ret = g_dbus_proxy_call_sync (plugin->priv->screensaver_proxy, + "SimulateUserActivity", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (ret == NULL) { + g_warning ("MsdSmartcardPlugin Unable to force logout: %s", error->message); + g_error_free (error); + } else { + g_variant_unref (ret); + } } static void lock_screen (MsdSmartcardPlugin *plugin) { - DBusGProxy *screensaver_proxy; + GError *error = NULL; + GVariant *ret; g_debug ("MsdSmartcardPlugin telling screensaver to lock screen"); - screensaver_proxy = dbus_g_proxy_new_for_name (plugin->priv->bus_connection, - SCREENSAVER_DBUS_NAME, - SCREENSAVER_DBUS_PATH, - SCREENSAVER_DBUS_INTERFACE); - dbus_g_proxy_call_no_reply (screensaver_proxy, - "Lock", - G_TYPE_INVALID, G_TYPE_INVALID); - - g_object_unref (screensaver_proxy); + ret = g_dbus_proxy_call_sync (plugin->priv->screensaver_proxy, + "Lock", + g_variant_new ("()"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (ret == NULL) { + g_warning ("MsdSmartcardPlugin Unable to force logout: %s", error->message); + g_error_free (error); + } else { + g_variant_unref (ret); + } } static void force_logout (MsdSmartcardPlugin *plugin) { - DBusGProxy *sm_proxy; - GError *error; - gboolean res; + GDBusProxy *sm_proxy; + GError *error = NULL; + GVariant *ret; g_debug ("MsdSmartcardPlugin telling session manager to force logout"); - sm_proxy = dbus_g_proxy_new_for_name (plugin->priv->bus_connection, - SM_DBUS_NAME, - SM_DBUS_PATH, - SM_DBUS_INTERFACE); - - error = NULL; - res = dbus_g_proxy_call (sm_proxy, - "Logout", - &error, - G_TYPE_UINT, SM_LOGOUT_MODE_FORCE, - G_TYPE_INVALID, G_TYPE_INVALID); + sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + SM_DBUS_NAME, + SM_DBUS_PATH, + SM_DBUS_INTERFACE, + NULL, + &error); + if (sm_proxy == NULL) { + g_warning ("Unable to contact session manager daemon: %s\n", error->message); + g_error_free (error); + return; + } - if (! res) { + ret = g_dbus_proxy_call_sync (sm_proxy, + "Logout", + g_variant_new ("(u", SM_LOGOUT_MODE_FORCE), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (ret == NULL) { g_warning ("MsdSmartcardPlugin Unable to force logout: %s", error->message); g_error_free (error); + } else { + g_variant_unref (ret); } g_object_unref (sm_proxy); @@ -270,10 +287,18 @@ impl_activate (MateSettingsPlugin *plugin) g_debug ("MsdSmartcardPlugin Activating smartcard plugin"); error = NULL; - smartcard_plugin->priv->bus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - - if (smartcard_plugin->priv->bus_connection == NULL) { + smartcard_plugin->priv->screensaver_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + SCREENSAVER_DBUS_NAME, + SCREENSAVER_DBUS_PATH, + SCREENSAVER_DBUS_INTERFACE, + NULL, + &error); + + if (smartcard_plugin->priv->screensaver_proxy == NULL) { g_warning ("MsdSmartcardPlugin Unable to connect to session bus: %s", error->message); + g_error_free (error); return; } @@ -319,7 +344,8 @@ impl_deactivate (MateSettingsPlugin *plugin) g_signal_handlers_disconnect_by_func (smartcard_plugin->priv->manager, smartcard_inserted_cb, smartcard_plugin); - smartcard_plugin->priv->bus_connection = NULL; + if (smartcard_plugin->priv->screensaver_proxy != NULL) + g_object_unref (smartcard_plugin->priv->screensaver_proxy); smartcard_plugin->priv->is_active = FALSE; } diff --git a/plugins/smartcard/msd-smartcard-plugin.h b/plugins/smartcard/msd-smartcard-plugin.h index 64663d3..f16665b 100644 --- a/plugins/smartcard/msd-smartcard-plugin.h +++ b/plugins/smartcard/msd-smartcard-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/plugins/smartcard/msd-smartcard.c b/plugins/smartcard/msd-smartcard.c index ab46ca6..b5df5ce 100644 --- a/plugins/smartcard/msd-smartcard.c +++ b/plugins/smartcard/msd-smartcard.c @@ -1,6 +1,7 @@ /* msd-smartcard.c - smartcard object * * Copyright (C) 2006 Ray Strode <[email protected]> + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/plugins/smartcard/msd-smartcard.h b/plugins/smartcard/msd-smartcard.h index da50b62..2633e31 100644 --- a/plugins/smartcard/msd-smartcard.h +++ b/plugins/smartcard/msd-smartcard.h @@ -1,6 +1,7 @@ /* securitycard.h - api for reading and writing data to a security card * * Copyright (C) 2006 Ray Strode + * Copyright (C) 2012-2021 MATE Developers * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by |