[gnome-software/wip/rancell/permissions: 2/2] Drop G-S knowledge of permission types
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/rancell/permissions: 2/2] Drop G-S knowledge of permission types
- Date: Thu, 10 Aug 2017 08:54:39 +0000 (UTC)
commit b515647cbaf447b7a111f64b50a111206ba3de1c
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Aug 10 20:54:15 2017 +1200
Drop G-S knowledge of permission types
lib/gs-permission.c | 100 +----------------------------------------
lib/gs-permission.h | 9 +---
plugins/snap/gs-plugin-snap.c | 29 +-----------
3 files changed, 5 insertions(+), 133 deletions(-)
---
diff --git a/lib/gs-permission.c b/lib/gs-permission.c
index 397d783..0ec7820 100644
--- a/lib/gs-permission.c
+++ b/lib/gs-permission.c
@@ -141,7 +141,7 @@ gs_permission_init (GsPermission *permission)
g_free, g_free);
}
-static GsPermission *
+GsPermission *
gs_permission_new (const gchar *label, gboolean enabled)
{
GsPermission *permission;
@@ -151,102 +151,4 @@ gs_permission_new (const gchar *label, gboolean enabled)
return GS_PERMISSION (permission);
}
-/**
- * gs_permission_new_camera:
- * @enabled: %TRUE if camera access is enabled.
- *
- * Creates a new permission object for camera access.
- *
- * Return value: a new #GsPermission object.
- **/
-GsPermission *
-gs_permission_new_camera (gboolean enabled)
-{
- return gs_permission_new (_("Can acquire photos / video from cameras"), enabled);
-}
-
-/**
- * gs_permission_new_bluetooth:
- * @enabled: %TRUE if Bluetooth access is enabled.
- *
- * Creates a new permission object for Bluetooth access.
- *
- * Return value: a new #GsPermission object.
- **/
-GsPermission *
-gs_permission_new_bluetooth (gboolean enabled)
-{
- return gs_permission_new (_("Can access Bluetooth devices"), enabled);
-}
-
-/**
- * gs_permission_new_network:
- * @enabled: %TRUE if network access is enabled.
- *
- * Creates a new permission object for network access.
- *
- * Return value: a new #GsPermission object.
- **/
-GsPermission *
-gs_permission_new_network (gboolean enabled)
-{
- return gs_permission_new (_("Can access the network"), enabled);
-}
-
-/**
- * gs_permission_new_media:
- * @enabled: %TRUE if removable media is enabled.
- *
- * Creates a new permission object for removable media.
- *
- * Return value: a new #GsPermission object.
- **/
-GsPermission *
-gs_permission_new_media (gboolean enabled)
-{
- return gs_permission_new (_("Can access removable media (USB drives etc)"), enabled);
-}
-
-/**
- * gs_permission_new_optical_drive:
- * @enabled: %TRUE if optical drive access is enabled.
- *
- * Creates a new permission object for optical drive access.
- *
- * Return value: a new #GsPermission object.
- **/
-GsPermission *
-gs_permission_new_optical_drive (gboolean enabled)
-{
- return gs_permission_new (_("Can access optical drives (CD, DVD etc)"), enabled);
-}
-
-/**
- * gs_permission_new_printing:
- * @enabled: %TRUE if printing access is enabled.
- *
- * Creates a new permission object for printing access.
- *
- * Return value: a new #GsPermission object.
- **/
-GsPermission *
-gs_permission_new_printing (gboolean enabled)
-{
- return gs_permission_new (_("Can print documents"), enabled);
-}
-
-/**
- * gs_permission_new_shutdown:
- * @enabled: %TRUE if shutdown / restart is allowed.
- *
- * Creates a new permission object for shutdown / restart of this machine.
- *
- * Return value: a new #GsPermission object.
- **/
-GsPermission *
-gs_permission_new_shutdown (gboolean enabled)
-{
- return gs_permission_new (_("Can shutdown / restart this computer"), enabled);
-}
-
/* vim: set noexpandtab: */
diff --git a/lib/gs-permission.h b/lib/gs-permission.h
index c952ac3..925e1be 100644
--- a/lib/gs-permission.h
+++ b/lib/gs-permission.h
@@ -31,13 +31,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GsPermission, gs_permission, GS, PERMISSION, GObject)
-GsPermission *gs_permission_new_bluetooth (gboolean enabled);
-GsPermission *gs_permission_new_camera (gboolean enabled);
-GsPermission *gs_permission_new_network (gboolean enabled);
-GsPermission *gs_permission_new_media (gboolean enabled);
-GsPermission *gs_permission_new_optical_drive (gboolean enabled);
-GsPermission *gs_permission_new_printing (gboolean enabled);
-GsPermission *gs_permission_new_shutdown (gboolean enabled);
+GsPermission *gs_permission_new (const gchar *label,
+ gboolean enabled);
const gchar *gs_permission_get_metadata_item (GsPermission *permission,
const gchar *key);
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index c0998a9..32e7f28 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -596,7 +596,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
g_autoptr(GPtrArray) slots = NULL;
guint i;
- if (!snapd_client_get_interfaces_sync (client, &plugs, &slots, cancellable, error))
+ if (!snapd_client_get_interfaces_sync (priv->client, &plugs, &slots, cancellable, error))
return FALSE;
for (i = 0; i < plugs->len; i++) {
SnapdPlug *plug = plugs->pdata[i];
@@ -611,32 +611,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
/* map interfaces to known permissions */
name = snapd_plug_get_name (plug);
is_connected = snapd_plug_get_connections (plug)->len > 0;
- if (g_strcmp0 (name, "camera") == 0)
- permission = gs_permission_new_camera (is_connected);
- else if (g_strcmp0 (name, "removable-media") == 0)
- permission = gs_permission_new_media (is_connected);
- else if (g_strcmp0 (name, "optical-drive") == 0)
- permission = gs_permission_new_optical_drive (is_connected);
- else if (g_strcmp0 (name, "network") == 0)
- permission = gs_permission_new_network (is_connected);
- else if (g_strcmp0 (name, "cups-control") == 0)
- permission = gs_permission_new_printing (is_connected);
- else if (g_strcmp0 (name, "bluetooth-control") == 0)
- permission = gs_permission_new_bluetooth (is_connected);
- else if (g_strcmp0 (name, "shutdown") == 0)
- permission = gs_permission_new_shutdown (is_connected);
- else if (g_strcmp0 (name, "home") == 0 ||
- g_strcmp0 (name, "opengl") == 0 ||
- g_strcmp0 (name, "pulseaudio") == 0 ||
- g_strcmp0 (name, "unity7") == 0 ||
- g_strcmp0 (name, "x11") == 0) {
- g_debug ("Ignoring common plug %s:%s", snapd_plug_get_snap (plug), name);
- continue;
- } else {
- g_warning ("Ignoring unknown plug %s:%s", snapd_plug_get_snap (plug), name);
- continue;
- }
-
+ permission = gs_permission_new (name, is_connected);
gs_app_add_permission (app, permission);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]