diff --git a/README.md b/README.md index c40a273cc1cfce9cf1e60fcb786619611101cc3a..1e63c7f90ef5a3219d4253c82615a44e95146f28 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A plugin system is used to access software from different sources. Plugins are provided for: - Traditional package installation via PackageKit (e.g. Debian package, RPM). - - Next generation packages: [Flatpak](https://flatpak.org/) and [Snap](https://snapcraft.io/). + - Next generation packages: [Flatpak](https://flatpak.org/). - Firmware updates. - Ratings and reviews using [ODRS](https://odrs.gnome.org/). diff --git a/contrib/gnome-software.spec.in b/contrib/gnome-software.spec.in index aeb9b5529affe8cbbb714302e1106242ae3c4a12..3641916ba667273717d050e3ceb1fe2ea96158ae 100644 --- a/contrib/gnome-software.spec.in +++ b/contrib/gnome-software.spec.in @@ -45,10 +45,6 @@ BuildRequires: rpm-devel BuildRequires: rpm-ostree-devel BuildRequires: libgudev1-devel BuildRequires: valgrind-devel -BuildRequires: liboauth-devel -%if 0%{?fedora} -BuildRequires: snapd-glib-devel >= 1.42 -%endif Requires: appstream-data %if 0%{?fedora} @@ -93,27 +89,11 @@ Requires: %{name}%{?_isa} = %{version}-%{release} %description editor Editor for designing banners for GNOME Software. -%if 0%{?fedora} -%package snap -Summary: Support for Ubuntu Snap packages -Requires: %{name}%{?_isa} = %{version}-%{release} -Requires: snapd-login-service -Supplements: (gnome-software%{?_isa} and snapd%{?_isa}) - -%description snap -Adds support for Snap packages from the Snap store. -%endif - %prep %autosetup -p1 %build %meson \ -%if 0%{?fedora} - -Dsnap=true \ -%else - -Dsnap=false \ -%endif -Dgudev=true \ -Dpackagekit=true \ -Dexternal_appstream=false \ @@ -205,12 +185,6 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop %{_libexecdir}/gnome-software-cmd %{_libexecdir}/gnome-software-restarter -%if 0%{?fedora} -%files snap -%{_libdir}/gs-plugins-%{gs_plugin_version}/libgs_plugin_snap.so -%{_datadir}/metainfo/org.gnome.Software.Plugin.Snap.metainfo.xml -%endif - %files devel %{_libdir}/pkgconfig/gnome-software.pc %dir %{_includedir}/gnome-software diff --git a/data/org.gnome.software.gschema.xml b/data/org.gnome.software.gschema.xml index 97780e0d381aa13488f94229b8124af206ca8fdd..fab37c9e3c9d9b5b60f82755e1a6f42194496ef4 100644 --- a/data/org.gnome.software.gschema.xml +++ b/data/org.gnome.software.gschema.xml @@ -139,12 +139,5 @@ true Enable GNOME Shell extensions repository - - - - - '' - A string storing the gnome-online-account id used to login - diff --git a/doc/api/gnome-software-docs.xml b/doc/api/gnome-software-docs.xml index cce7512a2faf8ff0e8d58399efe1a777507b762f..385ea5cd18833ce9de9f2950545434e4eb600698 100644 --- a/doc/api/gnome-software-docs.xml +++ b/doc/api/gnome-software-docs.xml @@ -603,7 +603,6 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app) - diff --git a/lib/gnome-software.h b/lib/gnome-software.h index f90b17f528ddfc4dfe3d21a42dd43b6f6af33a97..2833d0ffa0d2f94385480237f60fdca2dfe931f1 100644 --- a/lib/gnome-software.h +++ b/lib/gnome-software.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/gs-app-list.c b/lib/gs-app-list.c index 00574e753ea23a301dbfb063dc1ff48c2ff1616a..0acf7fe53380e1578736710e02c8c69b58eba41d 100644 --- a/lib/gs-app-list.c +++ b/lib/gs-app-list.c @@ -157,8 +157,7 @@ gs_app_list_invalidate_state (GsAppList *self) GsApp *app_tmp = g_ptr_array_index (apps, i); AsAppState state_tmp = gs_app_get_state (app_tmp); if (state_tmp == AS_APP_STATE_INSTALLING || - state_tmp == AS_APP_STATE_REMOVING || - state_tmp == AS_APP_STATE_PURCHASING) { + state_tmp == AS_APP_STATE_REMOVING) { state = state_tmp; break; } diff --git a/lib/gs-app.c b/lib/gs-app.c index 2bc32011ba8a1de7567efa34d97ccee34202485c..476ec62e6f8d3e475f3b2e3436e56e9cddb3910e 100644 --- a/lib/gs-app.c +++ b/lib/gs-app.c @@ -112,7 +112,6 @@ typedef struct GFile *local_file; AsContentRating *content_rating; GdkPixbuf *pixbuf; - GsPrice *price; GCancellable *cancellable; GsPluginAction pending_action; GsAppPermissions permissions; @@ -587,10 +586,6 @@ gs_app_to_string_append (GsApp *app, GString *str) gs_app_kv_size (str, "size-installed", priv->size_installed); if (priv->size_download != 0) gs_app_kv_size (str, "size-download", gs_app_get_size_download (app)); - if (priv->price != NULL) - gs_app_kv_printf (str, "price", "%s %.2f", - gs_price_get_currency (priv->price), - gs_price_get_amount (priv->price)); for (i = 0; i < gs_app_list_length (priv->related); i++) { GsApp *app_tmp = gs_app_list_index (priv->related, i); const gchar *id = gs_app_get_unique_id (app_tmp); @@ -914,8 +909,7 @@ gs_app_set_state_internal (GsApp *app, AsAppState state) state == AS_APP_STATE_AVAILABLE_LOCAL || state == AS_APP_STATE_UPDATABLE || state == AS_APP_STATE_UPDATABLE_LIVE || - state == AS_APP_STATE_UNAVAILABLE || - state == AS_APP_STATE_PURCHASABLE) + state == AS_APP_STATE_UNAVAILABLE) state_change_ok = TRUE; break; case AS_APP_STATE_INSTALLED: @@ -953,7 +947,6 @@ gs_app_set_state_internal (GsApp *app, AsAppState state) /* removing has to go into an stable state */ if (state == AS_APP_STATE_UNKNOWN || state == AS_APP_STATE_AVAILABLE || - state == AS_APP_STATE_PURCHASABLE || state == AS_APP_STATE_INSTALLED) state_change_ok = TRUE; break; @@ -983,19 +976,6 @@ gs_app_set_state_internal (GsApp *app, AsAppState state) state == AS_APP_STATE_INSTALLING) state_change_ok = TRUE; break; - case AS_APP_STATE_PURCHASABLE: - /* local has to go into an action state */ - if (state == AS_APP_STATE_UNKNOWN || - state == AS_APP_STATE_PURCHASING) - state_change_ok = TRUE; - break; - case AS_APP_STATE_PURCHASING: - /* purchasing has to go into an stable state */ - if (state == AS_APP_STATE_UNKNOWN || - state == AS_APP_STATE_AVAILABLE || - state == AS_APP_STATE_PURCHASABLE) - state_change_ok = TRUE; - break; default: g_warning ("state %s unhandled", as_app_state_to_string (priv->state)); @@ -1022,7 +1002,6 @@ gs_app_set_state_internal (GsApp *app, AsAppState state) case AS_APP_STATE_INSTALLING: case AS_APP_STATE_REMOVING: case AS_APP_STATE_QUEUED_FOR_INSTALL: - case AS_APP_STATE_PURCHASING: /* transient, so ignore */ break; default: @@ -1871,46 +1850,6 @@ gs_app_set_pixbuf (GsApp *app, GdkPixbuf *pixbuf) g_set_object (&priv->pixbuf, pixbuf); } -/** - * gs_app_get_price: - * @app: a #GsApp - * - * Gets the price required to purchase the application. - * - * Returns: (transfer none): a #GsPrice, or %NULL - * - * Since: 3.26 - **/ -GsPrice * -gs_app_get_price (GsApp *app) -{ - GsAppPrivate *priv = gs_app_get_instance_private (app); - g_return_val_if_fail (GS_IS_APP (app), NULL); - return priv->price; -} - -/** - * gs_app_set_price: - * @app: a #GsApp - * @amount: the amount of this price, e.g. 0.99 - * @currency: an ISO 4217 currency code, e.g. "USD" - * - * Sets a price required to purchase the application. - * - * Since: 3.26 - **/ -void -gs_app_set_price (GsApp *app, gdouble amount, const gchar *currency) -{ - GsAppPrivate *priv = gs_app_get_instance_private (app); - g_autoptr(GMutexLocker) locker = NULL; - g_return_if_fail (GS_IS_APP (app)); - locker = g_mutex_locker_new (&priv->mutex); - if (priv->price != NULL) - g_object_unref (priv->price); - priv->price = gs_price_new (amount, currency); -} - typedef enum { GS_APP_VERSION_FIXUP_RELEASE = 1, GS_APP_VERSION_FIXUP_DISTRO_SUFFIX = 2, @@ -4204,8 +4143,6 @@ gs_app_finalize (GObject *object) g_object_unref (priv->content_rating); if (priv->pixbuf != NULL) g_object_unref (priv->pixbuf); - if (priv->price != NULL) - g_object_unref (priv->price); G_OBJECT_CLASS (gs_app_parent_class)->finalize (object); } diff --git a/lib/gs-app.h b/lib/gs-app.h index cd185154e453b0af63eb5b97ed236be361e164ba..cc3aa9cc8e4de43d88e5cdc52f73fdf43119adfb 100644 --- a/lib/gs-app.h +++ b/lib/gs-app.h @@ -13,8 +13,6 @@ #include #include -#include "gs-price.h" - G_BEGIN_DECLS #define GS_TYPE_APP (gs_app_get_type ()) @@ -281,10 +279,6 @@ void gs_app_set_management_plugin (GsApp *app, GdkPixbuf *gs_app_get_pixbuf (GsApp *app); void gs_app_set_pixbuf (GsApp *app, GdkPixbuf *pixbuf); -GsPrice *gs_app_get_price (GsApp *app); -void gs_app_set_price (GsApp *app, - gdouble amount, - const gchar *currency); GPtrArray *gs_app_get_icons (GsApp *app); void gs_app_add_icon (GsApp *app, AsIcon *icon); diff --git a/lib/gs-auth.c b/lib/gs-auth.c deleted file mode 100644 index 7f604691e59fe1927005c929f0159ab5f265892a..0000000000000000000000000000000000000000 --- a/lib/gs-auth.c +++ /dev/null @@ -1,470 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2016 Richard Hughes - * Copyright (C) 2018 Canonical Ltd - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -/** - * SECTION:gs-auth - * @title: GsAuth - * @include: gnome-software.h - * @stability: Unstable - * @short_description: User data used for authentication - * - * This object represents user data used for authentication. - * This data is shared between all plugins. - */ - -#include "config.h" - -#include "gs-auth.h" -#include "gs-plugin.h" - -struct _GsAuth -{ - GObject parent_instance; - - gchar *header_none; - gchar *header_single; - gchar *header_multiple; - - gchar *auth_id; - gchar *provider_name; - gchar *provider_type; - - GoaClient *goa_client; - GoaObject *goa_object; - - GSettings *settings; -}; - -static void gs_auth_initable_iface_init (GInitableIface *iface); - -G_DEFINE_TYPE_WITH_CODE (GsAuth, gs_auth, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE, gs_auth_initable_iface_init)) - -enum { - SIGNAL_CHANGED, - SIGNAL_LAST -}; - -enum { - PROP_0, - PROP_AUTH_ID, - PROP_PROVIDER_TYPE, - PROP_GOA_OBJECT, - PROP_LAST -}; - -static guint signals [SIGNAL_LAST] = { 0 }; - - -/** - * gs_auth_get_header: - * @auth: a #GsAuth - * @n: the number of accounts - * - * Gets the header to be used in the authentication dialog in case there are @n - * available accounts. - * - * Returns: (transfer none) : a string - */ -const gchar * -gs_auth_get_header (GsAuth *auth, guint n) -{ - g_return_val_if_fail (GS_IS_AUTH (auth), NULL); - - if (n == 0) - return auth->header_none; - else if (n == 1) - return auth->header_single; - else - return auth->header_multiple; -} - -/** - * gs_auth_set_header: - * @auth: a #GsAuth - * @header_none: the header to be used if no account is present - * @header_single: the header to be used if one account is present - * @header_multiple: the header to be used if two or more accounts are present - * - * Sets the headers to be used for the authentication dialog. - */ -void -gs_auth_set_header (GsAuth *auth, - const gchar *header_none, - const gchar *header_single, - const gchar *header_multiple) -{ - g_return_if_fail (GS_IS_AUTH (auth)); - g_return_if_fail (header_none != NULL); - g_return_if_fail (header_single != NULL); - g_return_if_fail (header_multiple != NULL); - - g_free (auth->header_none); - auth->header_none = g_strdup (header_none); - - g_free (auth->header_single); - auth->header_single = g_strdup (header_single); - - g_free (auth->header_multiple); - auth->header_multiple = g_strdup (header_multiple); -} - -/** - * gs_auth_get_auth_id: - * @auth: a #GsAuth - * - * Gets the authentication service ID. - * - * Returns: (transfer none): a string - */ -const gchar * -gs_auth_get_auth_id (GsAuth *auth) -{ - g_return_val_if_fail (GS_IS_AUTH (auth), NULL); - return auth->auth_id; -} - -/** - * gs_auth_get_provider_name: - * @auth: a #GsAuth - * - * Gets the authentication service name. - * - * Returns: (transfer none): a string - */ -const gchar * -gs_auth_get_provider_name (GsAuth *auth) -{ - g_return_val_if_fail (GS_IS_AUTH (auth), NULL); - return auth->provider_name; -} - -/** - * gs_auth_set_provider_name: - * @auth: a #GsAuth - * @provider_name: a service name, e.g. "Snap Store" - * - * Sets the name to be used for the authentication dialog. - */ -void -gs_auth_set_provider_name (GsAuth *auth, const gchar *provider_name) -{ - g_return_if_fail (GS_IS_AUTH (auth)); - g_return_if_fail (provider_name != NULL); - - g_free (auth->provider_name); - auth->provider_name = g_strdup (provider_name); -} - -/** - * gs_auth_get_provider_type: - * @auth: a #GsAuth - * - * Gets the GoaProvider type to be used for the authentication dialog. - * - * Returns: (transfer none): a string - */ -const gchar * -gs_auth_get_provider_type (GsAuth *auth) -{ - g_return_val_if_fail (GS_IS_AUTH (auth), NULL); - return auth->provider_type; -} - -/** - * gs_auth_peek_goa_object: - * @auth: a #GsAuth - * - * Gets the logged #GoaObject if any. - * - * Returns: (transfer none) (nullable): a #GoaObject, or %NULL - */ -GoaObject * -gs_auth_peek_goa_object (GsAuth *auth) -{ - g_return_val_if_fail (GS_IS_AUTH (auth), NULL); - return auth->goa_object; -} - -static gboolean -gs_auth_goa_account_equal (GoaAccount *acc1, GoaAccount *acc2) -{ - if (acc1 == acc2) - return TRUE; - - if (acc1 == NULL || acc2 == NULL) - return FALSE; - - return !g_strcmp0 (goa_account_get_id (acc1), - goa_account_get_id (acc2)); -} - -static gboolean -gs_auth_goa_object_equal (GoaObject *obj1, GoaObject *obj2) -{ - if (obj1 == obj2) - return TRUE; - - if (obj1 == NULL || obj2 == NULL) - return FALSE; - - return gs_auth_goa_account_equal(goa_object_peek_account (obj1), - goa_object_peek_account (obj2)); -} - -static void -gs_auth_account_changed_cb (GoaClient *client, - GoaObject *goa_object, - GsAuth *auth) -{ - if (!gs_auth_goa_object_equal (auth->goa_object, goa_object)) - return; - - g_signal_emit (auth, signals[SIGNAL_CHANGED], 0); -} - -static void -gs_auth_account_removed_cb (GoaClient *client, - GoaObject *goa_object, - GsAuth *auth) -{ - if (!gs_auth_goa_object_equal (auth->goa_object, goa_object)) - return; - - gs_auth_set_goa_object (auth, NULL); -} - -/** - * gs_auth_set_goa_object: - * @auth: a #GsAuth - * @goa_object: (nullable) a #GoaObject - * - * Set the #GoaObject used to login in. - */ -void -gs_auth_set_goa_object (GsAuth *auth, - GoaObject *goa_object) -{ - g_return_if_fail (GS_IS_AUTH (auth)); - - if (gs_auth_goa_object_equal (auth->goa_object, goa_object)) - return; - - g_clear_object (&auth->goa_object); - if (goa_object) - auth->goa_object = g_object_ref (goa_object); - - g_object_notify (G_OBJECT (auth), "goa-object"); - g_signal_emit (auth, signals[SIGNAL_CHANGED], 0); -} - -static gboolean -string_to_goa_object (GValue *value, - GVariant *variant, - gpointer user_data) -{ - GsAuth *auth = GS_AUTH (user_data); - GoaObject *goa_object; - const gchar *account_id; - - account_id = g_variant_get_string (variant, NULL); - - goa_object = goa_client_lookup_by_id (auth->goa_client, account_id); - if (!goa_object) - return TRUE; - - g_value_take_object (value, goa_object); - return TRUE; -} - -static GVariant * -goa_object_to_string (const GValue *value, - const GVariantType *expected_type, - gpointer user_data) -{ - GObject *object = g_value_get_object (value); - - GoaObject *goa_object = object != NULL ? GOA_OBJECT (object) : NULL; - GoaAccount *goa_account = goa_object != NULL ? goa_object_peek_account (goa_object) : NULL; - - if (goa_account != NULL) - return g_variant_new_string (goa_account_get_id (goa_account)); - else - return g_variant_new_string (""); -} - -/* GObject */ - -static void -gs_auth_init (GsAuth *auth) -{ -} - -static void -gs_auth_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - GsAuth *auth = GS_AUTH (object); - - switch (prop_id) { - case PROP_AUTH_ID: - g_value_set_string (value, auth->auth_id); - break; - case PROP_PROVIDER_TYPE: - g_value_set_string (value, auth->provider_type); - break; - case PROP_GOA_OBJECT: - g_value_set_object (value, auth->goa_object); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gs_auth_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - GsAuth *auth = GS_AUTH (object); - - switch (prop_id) { - case PROP_AUTH_ID: - auth->auth_id = g_value_dup_string (value); - break; - case PROP_PROVIDER_TYPE: - auth->provider_type = g_value_dup_string (value); - break; - case PROP_GOA_OBJECT: - gs_auth_set_goa_object (auth, g_value_get_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gs_auth_finalize (GObject *object) -{ - GsAuth *auth = GS_AUTH (object); - - g_free (auth->header_none); - g_free (auth->header_single); - g_free (auth->header_multiple); - g_free (auth->auth_id); - g_free (auth->provider_name); - - g_clear_object (&auth->goa_client); - g_clear_object (&auth->goa_object); - - g_clear_object (&auth->settings); - - G_OBJECT_CLASS (gs_auth_parent_class)->finalize (object); -} - -static void -gs_auth_class_init (GsAuthClass *klass) -{ - GParamSpec *pspec; - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = gs_auth_finalize; - object_class->get_property = gs_auth_get_property; - object_class->set_property = gs_auth_set_property; - - pspec = g_param_spec_string ("auth-id", NULL, NULL, NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_AUTH_ID, pspec); - - pspec = g_param_spec_string ("provider-type", NULL, NULL, NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_PROVIDER_TYPE, pspec); - - pspec = g_param_spec_object ("goa-object", NULL, NULL, - GOA_TYPE_OBJECT, - G_PARAM_READWRITE | - G_PARAM_EXPLICIT_NOTIFY); - g_object_class_install_property (object_class, PROP_GOA_OBJECT, pspec); - - signals [SIGNAL_CHANGED] = - g_signal_new ("changed", - G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - 0, NULL, NULL, g_cclosure_marshal_generic, - G_TYPE_NONE, 0); -} - -/* GInitable */ - -static gboolean -gs_auth_initable_init (GInitable *initable, - GCancellable *cancellable, - GError **error) -{ - GsAuth *self; - g_autofree gchar *path = NULL; - - g_return_val_if_fail (GS_IS_AUTH (initable), FALSE); - - self = GS_AUTH (initable); - - self->goa_client = goa_client_new_sync (NULL, error); - if (self->goa_client == NULL) - return FALSE; - - g_signal_connect (self->goa_client, "account-changed", - G_CALLBACK (gs_auth_account_changed_cb), self); - g_signal_connect (self->goa_client, "account-removed", - G_CALLBACK (gs_auth_account_removed_cb), self); - - path = g_strdup_printf ("/org/gnome/software/auth/%s/", self->auth_id); - self->settings = g_settings_new_with_path ("org.gnome.software.auth", path); - - g_settings_bind_with_mapping (self->settings, "account-id", - self, "goa-object", - G_SETTINGS_BIND_DEFAULT, - string_to_goa_object, - goa_object_to_string, - self, NULL); - - return TRUE; -} - -static void -gs_auth_initable_iface_init (GInitableIface *iface) -{ - iface->init = gs_auth_initable_init; -} - -/** - * gs_auth_new: - * @auth_id: an identifier used for mapping, e.g. "snapd" - * @provider_type: the name of the GoaProvider466 to be used, e.g. "ubuntusso" - * @error: A #GError - * - * Return value: (transfer full) (nullable): a new #GsAuth object. - **/ -GsAuth * -gs_auth_new (const gchar *auth_id, - const gchar *provider_type, - GError **error) -{ - GsAuth *auth; - - g_return_val_if_fail (auth_id != NULL, NULL); - g_return_val_if_fail (provider_type != NULL, NULL); - - auth = g_initable_new (GS_TYPE_AUTH, NULL, error, - "auth-id", auth_id, - "provider-type", provider_type, - NULL); - - return GS_AUTH (auth); -} diff --git a/lib/gs-auth.h b/lib/gs-auth.h deleted file mode 100644 index 40a593f00c1ca4fa952424646b0c71b2d9267462..0000000000000000000000000000000000000000 --- a/lib/gs-auth.h +++ /dev/null @@ -1,39 +0,0 @@ - /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2016 Richard Hughes - * Copyright (C) 2018 Canonical Ltd - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#pragma once - -#include -#include -#define GOA_API_IS_SUBJECT_TO_CHANGE -#include - -G_BEGIN_DECLS - -#define GS_TYPE_AUTH (gs_auth_get_type ()) - -G_DECLARE_FINAL_TYPE (GsAuth, gs_auth, GS, AUTH, GObject) - -GsAuth *gs_auth_new (const gchar *auth_id, - const gchar *provider_type, - GError **error); -const gchar *gs_auth_get_header (GsAuth *auth, - guint n); -void gs_auth_set_header (GsAuth *auth, - const gchar *header_none, - const gchar *header_single, - const gchar *header_multiple); -const gchar *gs_auth_get_auth_id (GsAuth *auth); -const gchar *gs_auth_get_provider_name (GsAuth *auth); -void gs_auth_set_provider_name (GsAuth *auth, - const gchar *provider_name); -const gchar *gs_auth_get_provider_type (GsAuth *auth); -GoaObject *gs_auth_peek_goa_object (GsAuth *auth); -void gs_auth_set_goa_object (GsAuth *auth, - GoaObject *goa_object); -G_END_DECLS diff --git a/lib/gs-plugin-job-private.h b/lib/gs-plugin-job-private.h index 64ee39b79e7d535b99c198df01eed1761e273d58..0fa0d2d04973451ec422dde4825f99af453f634a 100644 --- a/lib/gs-plugin-job-private.h +++ b/lib/gs-plugin-job-private.h @@ -30,14 +30,12 @@ guint64 gs_plugin_job_get_age (GsPluginJob *self); GsAppListSortFunc gs_plugin_job_get_sort_func (GsPluginJob *self); gpointer gs_plugin_job_get_sort_func_data (GsPluginJob *self); const gchar *gs_plugin_job_get_search (GsPluginJob *self); -GsAuth *gs_plugin_job_get_auth (GsPluginJob *self); GsApp *gs_plugin_job_get_app (GsPluginJob *self); GsAppList *gs_plugin_job_get_list (GsPluginJob *self); GFile *gs_plugin_job_get_file (GsPluginJob *self); GsPlugin *gs_plugin_job_get_plugin (GsPluginJob *self); GsCategory *gs_plugin_job_get_category (GsPluginJob *self); AsReview *gs_plugin_job_get_review (GsPluginJob *self); -GsPrice *gs_plugin_job_get_price (GsPluginJob *self); gchar *gs_plugin_job_to_string (GsPluginJob *self); void gs_plugin_job_set_action (GsPluginJob *self, GsPluginAction action); diff --git a/lib/gs-plugin-job.c b/lib/gs-plugin-job.c index bc001011d69e3c05108ba5aa3993e8e2de2a8b92..24830a9be25950ea5e54a9d8284f4679077343ae 100644 --- a/lib/gs-plugin-job.c +++ b/lib/gs-plugin-job.c @@ -28,13 +28,11 @@ struct _GsPluginJob GsAppListSortFunc sort_func; gpointer sort_func_data; gchar *search; - GsAuth *auth; GsApp *app; GsAppList *list; GFile *file; GsCategory *category; AsReview *review; - GsPrice *price; gint64 time_created; }; @@ -47,14 +45,12 @@ enum { PROP_FILTER_FLAGS, PROP_DEDUPE_FLAGS, PROP_INTERACTIVE, - PROP_AUTH, PROP_APP, PROP_LIST, PROP_FILE, PROP_CATEGORY, PROP_REVIEW, PROP_MAX_RESULTS, - PROP_PRICE, PROP_TIMEOUT, PROP_LAST }; @@ -111,14 +107,6 @@ gs_plugin_job_to_string (GsPluginJob *self) g_string_append_printf (str, " with review=%s", as_review_get_id (self->review)); } - if (self->price != NULL) { - g_autofree gchar *price_string = gs_price_to_string (self->price); - g_string_append_printf (str, " with price=%s", price_string); - } - if (self->auth != NULL) { - g_string_append_printf (str, " with auth=%s", - gs_auth_get_auth_id (self->auth)); - } if (self->file != NULL) { g_autofree gchar *path = g_file_get_path (self->file); g_string_append_printf (str, " with file=%s", path); @@ -321,20 +309,6 @@ gs_plugin_job_get_search (GsPluginJob *self) return self->search; } -void -gs_plugin_job_set_auth (GsPluginJob *self, GsAuth *auth) -{ - g_return_if_fail (GS_IS_PLUGIN_JOB (self)); - g_set_object (&self->auth, auth); -} - -GsAuth * -gs_plugin_job_get_auth (GsPluginJob *self) -{ - g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), NULL); - return self->auth; -} - void gs_plugin_job_set_app (GsPluginJob *self, GsApp *app) { @@ -425,20 +399,6 @@ gs_plugin_job_get_review (GsPluginJob *self) return self->review; } -void -gs_plugin_job_set_price (GsPluginJob *self, GsPrice *price) -{ - g_return_if_fail (GS_IS_PLUGIN_JOB (self)); - g_set_object (&self->price, price); -} - -GsPrice * -gs_plugin_job_get_price (GsPluginJob *self) -{ - g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), NULL); - return self->price; -} - static void gs_plugin_job_get_property (GObject *obj, guint prop_id, GValue *value, GParamSpec *pspec) { @@ -466,9 +426,6 @@ gs_plugin_job_get_property (GObject *obj, guint prop_id, GValue *value, GParamSp case PROP_SEARCH: g_value_set_string (value, self->search); break; - case PROP_AUTH: - g_value_set_object (value, self->auth); - break; case PROP_APP: g_value_set_object (value, self->app); break; @@ -484,9 +441,6 @@ gs_plugin_job_get_property (GObject *obj, guint prop_id, GValue *value, GParamSp case PROP_REVIEW: g_value_set_object (value, self->review); break; - case PROP_PRICE: - g_value_set_object (value, self->price); - break; case PROP_MAX_RESULTS: g_value_set_uint (value, self->max_results); break; @@ -526,9 +480,6 @@ gs_plugin_job_set_property (GObject *obj, guint prop_id, const GValue *value, GP case PROP_SEARCH: gs_plugin_job_set_search (self, g_value_get_string (value)); break; - case PROP_AUTH: - gs_plugin_job_set_auth (self, g_value_get_object (value)); - break; case PROP_APP: gs_plugin_job_set_app (self, g_value_get_object (value)); break; @@ -550,9 +501,6 @@ gs_plugin_job_set_property (GObject *obj, guint prop_id, const GValue *value, GP case PROP_TIMEOUT: gs_plugin_job_set_timeout (self, g_value_get_uint (value)); break; - case PROP_PRICE: - gs_plugin_job_set_price (self, g_value_get_object (value)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); break; @@ -564,14 +512,12 @@ gs_plugin_job_finalize (GObject *obj) { GsPluginJob *self = GS_PLUGIN_JOB (obj); g_free (self->search); - g_clear_object (&self->auth); g_clear_object (&self->app); g_clear_object (&self->list); g_clear_object (&self->file); g_clear_object (&self->plugin); g_clear_object (&self->category); g_clear_object (&self->review); - g_clear_object (&self->price); G_OBJECT_CLASS (gs_plugin_job_parent_class)->finalize (obj); } @@ -622,11 +568,6 @@ gs_plugin_job_class_init (GsPluginJobClass *klass) G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_SEARCH, pspec); - pspec = g_param_spec_object ("auth", NULL, NULL, - GS_TYPE_AUTH, - G_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_AUTH, pspec); - pspec = g_param_spec_object ("app", NULL, NULL, GS_TYPE_APP, G_PARAM_READWRITE); @@ -661,11 +602,6 @@ gs_plugin_job_class_init (GsPluginJobClass *klass) 0, G_MAXUINT, 60, G_PARAM_READWRITE | G_PARAM_CONSTRUCT); g_object_class_install_property (object_class, PROP_TIMEOUT, pspec); - - pspec = g_param_spec_object ("price", NULL, NULL, - GS_TYPE_PRICE, - G_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_PRICE, pspec); } static void diff --git a/lib/gs-plugin-job.h b/lib/gs-plugin-job.h index a986334308db58a301cfd33114d82b6de6587a9a..5100fdf0ddb2adfc0485c20274080562551d6aba 100644 --- a/lib/gs-plugin-job.h +++ b/lib/gs-plugin-job.h @@ -10,10 +10,8 @@ #include #include "gs-app-list-private.h" -#include "gs-auth.h" #include "gs-category.h" #include "gs-plugin-types.h" -#include "gs-price.h" G_BEGIN_DECLS @@ -41,8 +39,6 @@ void gs_plugin_job_set_sort_func_data (GsPluginJob *self, gpointer sort_func_data); void gs_plugin_job_set_search (GsPluginJob *self, const gchar *search); -void gs_plugin_job_set_auth (GsPluginJob *self, - GsAuth *auth); void gs_plugin_job_set_app (GsPluginJob *self, GsApp *app); void gs_plugin_job_set_list (GsPluginJob *self, @@ -55,8 +51,6 @@ void gs_plugin_job_set_category (GsPluginJob *self, GsCategory *category); void gs_plugin_job_set_review (GsPluginJob *self, AsReview *review); -void gs_plugin_job_set_price (GsPluginJob *self, - GsPrice *price); #define gs_plugin_job_newv(a,...) GS_PLUGIN_JOB(g_object_new(GS_TYPE_PLUGIN_JOB, "action", a, __VA_ARGS__)) diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c index 17b010e95b6381fec97fa22c30a47da14fc9b7d7..cf73406179b5010bd9c75a27588c5175480c20a5 100644 --- a/lib/gs-plugin-loader.c +++ b/lib/gs-plugin-loader.c @@ -36,7 +36,6 @@ typedef struct gchar *language; gboolean plugin_dir_dirty; SoupSession *soup_session; - GPtrArray *auth_array; GPtrArray *file_monitors; GsPluginStatus global_status_last; @@ -122,20 +121,11 @@ typedef gboolean (*GsPluginActionFunc) (GsPlugin *plugin, GsApp *app, GCancellable *cancellable, GError **error); -typedef gboolean (*GsPluginPurchaseFunc) (GsPlugin *plugin, - GsApp *app, - GsPrice *price, - GCancellable *cancellable, - GError **error); typedef gboolean (*GsPluginReviewFunc) (GsPlugin *plugin, GsApp *app, AsReview *review, GCancellable *cancellable, GError **error); -typedef gboolean (*GsPluginAuthFunc) (GsPlugin *plugin, - GsAuth *auth, - GCancellable *cancellable, - GError **error); typedef gboolean (*GsPluginRefineFunc) (GsPlugin *plugin, GsAppList *list, GsPluginRefineFlags refine_flags, @@ -369,14 +359,6 @@ gs_plugin_loader_is_error_fatal (const GError *err) { if (g_error_matches (err, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_TIMED_OUT)) return TRUE; - if (g_error_matches (err, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_AUTH_REQUIRED)) - return TRUE; - if (g_error_matches (err, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_AUTH_INVALID)) - return TRUE; - if (g_error_matches (err, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_PURCHASE_NOT_SETUP)) - return TRUE; - if (g_error_matches (err, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_PURCHASE_DECLINED)) - return TRUE; return FALSE; } @@ -603,14 +585,6 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper, ret = plugin_func (plugin, app, cancellable, &error_local); } break; - case GS_PLUGIN_ACTION_PURCHASE: - { - GsPluginPurchaseFunc plugin_func = func; - ret = plugin_func (plugin, app, - gs_plugin_job_get_price (helper->plugin_job), - cancellable, &error_local); - } - break; case GS_PLUGIN_ACTION_REVIEW_SUBMIT: case GS_PLUGIN_ACTION_REVIEW_UPVOTE: case GS_PLUGIN_ACTION_REVIEW_DOWNVOTE: @@ -1147,7 +1121,6 @@ gs_plugin_loader_app_is_valid_installed (GsApp *app, gpointer user_data) switch (gs_app_get_state (app)) { case AS_APP_STATE_INSTALLING: case AS_APP_STATE_REMOVING: - case AS_APP_STATE_PURCHASING: return TRUE; break; default: @@ -2092,7 +2065,6 @@ gs_plugin_loader_open_plugin (GsPluginLoader *plugin_loader, G_CALLBACK (gs_plugin_loader_allow_updates_cb), plugin_loader); gs_plugin_set_soup_session (plugin, priv->soup_session); - gs_plugin_set_auth_array (plugin, priv->auth_array); gs_plugin_set_locale (plugin, priv->locale); gs_plugin_set_language (plugin, priv->language); gs_plugin_set_scale (plugin, gs_plugin_loader_get_scale (plugin_loader)); @@ -2123,29 +2095,6 @@ gs_plugin_loader_get_scale (GsPluginLoader *plugin_loader) return priv->scale; } -GsAuth * -gs_plugin_loader_get_auth_by_id (GsPluginLoader *plugin_loader, - const gchar *auth_id) -{ - GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader); - guint i; - - /* match on ID */ - for (i = 0; i < priv->auth_array->len; i++) { - GsAuth *auth = g_ptr_array_index (priv->auth_array, i); - if (g_strcmp0 (gs_auth_get_auth_id (auth), auth_id) == 0) - return auth; - } - return NULL; -} - -GPtrArray * -gs_plugin_loader_get_auths (GsPluginLoader *plugin_loader) -{ - GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader); - return priv->auth_array; -} - void gs_plugin_loader_add_location (GsPluginLoader *plugin_loader, const gchar *location) { @@ -2626,7 +2575,6 @@ gs_plugin_loader_dispose (GObject *object) g_clear_object (&priv->network_monitor); g_clear_object (&priv->soup_session); g_clear_object (&priv->settings); - g_clear_pointer (&priv->auth_array, g_ptr_array_unref); g_clear_pointer (&priv->pending_apps, g_ptr_array_unref); G_OBJECT_CLASS (gs_plugin_loader_parent_class)->dispose (object); @@ -2750,7 +2698,6 @@ gs_plugin_loader_init (GsPluginLoader *plugin_loader) get_max_parallel_ops (), FALSE, NULL); - priv->auth_array = g_ptr_array_new_with_free_func ((GFreeFunc) g_object_unref); priv->file_monitors = g_ptr_array_new_with_free_func ((GFreeFunc) g_object_unref); priv->locations = g_ptr_array_new_with_free_func (g_free); priv->settings = g_settings_new ("org.gnome.software"); diff --git a/lib/gs-plugin-loader.h b/lib/gs-plugin-loader.h index 1d0c10f7d8b5f4d19295aa6124f64dcc7744d28a..e5083d9ece3ef0faad045067253e91cc8db282b9 100644 --- a/lib/gs-plugin-loader.h +++ b/lib/gs-plugin-loader.h @@ -11,7 +11,6 @@ #include #include "gs-app.h" -#include "gs-auth.h" #include "gs-category.h" #include "gs-plugin-event.h" #include "gs-plugin-private.h" @@ -64,9 +63,6 @@ gboolean gs_plugin_loader_get_enabled (GsPluginLoader *plugin_loader, const gchar *plugin_name); void gs_plugin_loader_add_location (GsPluginLoader *plugin_loader, const gchar *location); -GsAuth *gs_plugin_loader_get_auth_by_id (GsPluginLoader *plugin_loader, - const gchar *auth_id); -GPtrArray *gs_plugin_loader_get_auths (GsPluginLoader *plugin_loader); guint gs_plugin_loader_get_scale (GsPluginLoader *plugin_loader); void gs_plugin_loader_set_scale (GsPluginLoader *plugin_loader, guint scale); diff --git a/lib/gs-plugin-private.h b/lib/gs-plugin-private.h index d6a6dfbd541063814e42f96f32902c7e29b26254..42ad22f9aa5b5e7721414006d374e2fecdc9a13e 100644 --- a/lib/gs-plugin-private.h +++ b/lib/gs-plugin-private.h @@ -39,8 +39,6 @@ void gs_plugin_set_locale (GsPlugin *plugin, const gchar *locale); void gs_plugin_set_language (GsPlugin *plugin, const gchar *language); -void gs_plugin_set_auth_array (GsPlugin *plugin, - GPtrArray *auth_array); GPtrArray *gs_plugin_get_rules (GsPlugin *plugin, GsPluginRule rule); gpointer gs_plugin_get_symbol (GsPlugin *plugin, diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h index a455abff4d23a8fbf253618906a42ebf5f107bcd..aa5d1fd696ea32c95d9efd26c47e8ca33243ef51 100644 --- a/lib/gs-plugin-types.h +++ b/lib/gs-plugin-types.h @@ -56,8 +56,6 @@ typedef guint64 GsPluginFlags; * @GS_PLUGIN_ERROR_NO_NETWORK: No network connection available * @GS_PLUGIN_ERROR_NO_SECURITY: Security policy forbid action * @GS_PLUGIN_ERROR_NO_SPACE: No disk space to allow action - * @GS_PLUGIN_ERROR_AUTH_REQUIRED: Authentication was required - * @GS_PLUGIN_ERROR_AUTH_INVALID: Provided authentication was invalid * @GS_PLUGIN_ERROR_PLUGIN_DEPSOLVE_FAILED: The plugins installed are incompatible * @GS_PLUGIN_ERROR_DOWNLOAD_FAILED: The download action failed * @GS_PLUGIN_ERROR_WRITE_FAILED: The save-to-disk failed @@ -66,8 +64,6 @@ typedef guint64 GsPluginFlags; * @GS_PLUGIN_ERROR_RESTART_REQUIRED: A restart is required * @GS_PLUGIN_ERROR_AC_POWER_REQUIRED: AC power is required * @GS_PLUGIN_ERROR_TIMED_OUT: The job timed out - * @GS_PLUGIN_ERROR_PURCHASE_NOT_SETUP: Purchase support not setup - * @GS_PLUGIN_ERROR_PURCHASE_DECLINED: Purchase was declined * * The failure error types. **/ @@ -78,8 +74,6 @@ typedef enum { GS_PLUGIN_ERROR_NO_NETWORK, GS_PLUGIN_ERROR_NO_SECURITY, GS_PLUGIN_ERROR_NO_SPACE, - GS_PLUGIN_ERROR_AUTH_REQUIRED, - GS_PLUGIN_ERROR_AUTH_INVALID, GS_PLUGIN_ERROR_PLUGIN_DEPSOLVE_FAILED, GS_PLUGIN_ERROR_DOWNLOAD_FAILED, GS_PLUGIN_ERROR_WRITE_FAILED, @@ -88,8 +82,6 @@ typedef enum { GS_PLUGIN_ERROR_RESTART_REQUIRED, GS_PLUGIN_ERROR_AC_POWER_REQUIRED, GS_PLUGIN_ERROR_TIMED_OUT, - GS_PLUGIN_ERROR_PURCHASE_NOT_SETUP, - GS_PLUGIN_ERROR_PURCHASE_DECLINED, /*< private >*/ GS_PLUGIN_ERROR_LAST } GsPluginError; @@ -226,7 +218,6 @@ typedef enum { * @GS_PLUGIN_ACTION_GET_UPDATES_HISTORICAL: Get the list of historical updates * @GS_PLUGIN_ACTION_INITIALIZE: Initialize the plugin * @GS_PLUGIN_ACTION_DESTROY: Destroy the plugin - * @GS_PLUGIN_ACTION_PURCHASE: Purchase an app * @GS_PLUGIN_ACTION_DOWNLOAD: Download an application * @GS_PLUGIN_ACTION_GET_ALTERNATES: Get the alternates for a specific application * @@ -271,7 +262,6 @@ typedef enum { GS_PLUGIN_ACTION_GET_UPDATES_HISTORICAL, GS_PLUGIN_ACTION_INITIALIZE, GS_PLUGIN_ACTION_DESTROY, - GS_PLUGIN_ACTION_PURCHASE, GS_PLUGIN_ACTION_DOWNLOAD, GS_PLUGIN_ACTION_GET_ALTERNATES, /*< private >*/ diff --git a/lib/gs-plugin-vfuncs.h b/lib/gs-plugin-vfuncs.h index d9527bfaff2e18bca6190929c03f8e5b3b5d1bd5..94f63bdbf36d18922b80cde15a2b9e3f7e260869 100644 --- a/lib/gs-plugin-vfuncs.h +++ b/lib/gs-plugin-vfuncs.h @@ -24,7 +24,6 @@ #include "gs-app.h" #include "gs-app-list.h" #include "gs-category.h" -#include "gs-price.h" G_BEGIN_DECLS @@ -546,27 +545,6 @@ gboolean gs_plugin_update_cancel (GsPlugin *plugin, GCancellable *cancellable, GError **error); -/** - * gs_plugin_app_purchase: - * @plugin: a #GsPlugin - * @app: a #GsApp - * @price: a #GsPrice - * @cancellable: a #GCancellable, or %NULL - * @error: a #GError, or %NULL - * - * Purchase the application. - * - * NOTE: Once the action is complete, the plugin must set the new state of @app - * to %AS_APP_STATE_AVAILABLE. - * - * Returns: %TRUE for success or if not relevant - **/ -gboolean gs_plugin_app_purchase (GsPlugin *plugin, - GsApp *app, - GsPrice *price, - GCancellable *cancellable, - GError **error); - /** * gs_plugin_app_install: * @plugin: a #GsPlugin diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c index eab2287a416eaa49a0b9659d5678e283b5446f58..ab8c104a1892aa47bab9f27c0d803310bffb0232 100644 --- a/lib/gs-plugin.c +++ b/lib/gs-plugin.c @@ -47,7 +47,6 @@ typedef struct { - GPtrArray *auth_array; GHashTable *cache; GMutex cache_mutex; GModule *module; @@ -209,8 +208,6 @@ gs_plugin_finalize (GObject *object) g_free (priv->data); g_free (priv->locale); g_free (priv->language); - if (priv->auth_array != NULL) - g_ptr_array_unref (priv->auth_array); if (priv->soup_session != NULL) g_object_unref (priv->soup_session); if (priv->network_monitor != NULL) @@ -598,64 +595,6 @@ gs_plugin_set_language (GsPlugin *plugin, const gchar *language) priv->language = g_strdup (language); } -/** - * gs_plugin_set_auth_array: - * @plugin: a #GsPlugin - * @auth_array: (element-type GsAuth): an array - * - * Sets the authentication objects that can be added by the plugin. - * - * Since: 3.22 - **/ -void -gs_plugin_set_auth_array (GsPlugin *plugin, GPtrArray *auth_array) -{ - GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin); - priv->auth_array = g_ptr_array_ref (auth_array); -} - -/** - * gs_plugin_add_auth: - * @plugin: a #GsPlugin - * @auth: a #GsAuth - * - * Adds an authentication object that can be used for all the plugins. - * - * Since: 3.22 - **/ -void -gs_plugin_add_auth (GsPlugin *plugin, GsAuth *auth) -{ - GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin); - g_ptr_array_add (priv->auth_array, g_object_ref (auth)); -} - -/** - * gs_plugin_get_auth_by_id: - * @plugin: a #GsPlugin - * @auth_id: an ID, e.g. "dummy-sso" - * - * Gets a specific authentication object. - * - * Returns: the #GsAuth, or %NULL if not found - * - * Since: 3.22 - **/ -GsAuth * -gs_plugin_get_auth_by_id (GsPlugin *plugin, const gchar *auth_id) -{ - GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin); - guint i; - - /* match on ID */ - for (i = 0; i < priv->auth_array->len; i++) { - GsAuth *auth = g_ptr_array_index (priv->auth_array, i); - if (g_strcmp0 (gs_auth_get_auth_id (auth), auth_id) == 0) - return auth; - } - return NULL; -} - /** * gs_plugin_get_soup_session: * @plugin: a #GsPlugin @@ -1530,10 +1469,6 @@ gs_plugin_error_to_string (GsPluginError error) return "no-security"; if (error == GS_PLUGIN_ERROR_NO_SPACE) return "no-space"; - if (error == GS_PLUGIN_ERROR_AUTH_REQUIRED) - return "auth-required"; - if (error == GS_PLUGIN_ERROR_AUTH_INVALID) - return "auth-invalid"; if (error == GS_PLUGIN_ERROR_PLUGIN_DEPSOLVE_FAILED) return "plugin-depsolve-failed"; if (error == GS_PLUGIN_ERROR_DOWNLOAD_FAILED) @@ -1550,10 +1485,6 @@ gs_plugin_error_to_string (GsPluginError error) return "ac-power-required"; if (error == GS_PLUGIN_ERROR_TIMED_OUT) return "timed-out"; - if (error == GS_PLUGIN_ERROR_PURCHASE_NOT_SETUP) - return "purchase-not-setup"; - if (error == GS_PLUGIN_ERROR_PURCHASE_DECLINED) - return "purchase-declined"; return NULL; } @@ -1644,8 +1575,6 @@ gs_plugin_action_to_function_name (GsPluginAction action) return "gs_plugin_initialize"; if (action == GS_PLUGIN_ACTION_DESTROY) return "gs_plugin_destroy"; - if (action == GS_PLUGIN_ACTION_PURCHASE) - return "gs_plugin_app_purchase"; if (action == GS_PLUGIN_ACTION_GET_ALTERNATES) return "gs_plugin_add_alternates"; return NULL; @@ -1740,8 +1669,6 @@ gs_plugin_action_to_string (GsPluginAction action) return "initialize"; if (action == GS_PLUGIN_ACTION_DESTROY) return "destroy"; - if (action == GS_PLUGIN_ACTION_PURCHASE) - return "purchase"; if (action == GS_PLUGIN_ACTION_GET_ALTERNATES) return "get-alternates"; return NULL; @@ -1836,8 +1763,6 @@ gs_plugin_action_from_string (const gchar *action) return GS_PLUGIN_ACTION_INITIALIZE; if (g_strcmp0 (action, "destroy") == 0) return GS_PLUGIN_ACTION_DESTROY; - if (g_strcmp0 (action, "purchase") == 0) - return GS_PLUGIN_ACTION_PURCHASE; if (g_strcmp0 (action, "get-alternates") == 0) return GS_PLUGIN_ACTION_GET_ALTERNATES; return GS_PLUGIN_ACTION_UNKNOWN; diff --git a/lib/gs-plugin.h b/lib/gs-plugin.h index d4595186f6492b400327b1b6b607fb78f709d0bb..7dd2d864021cb4015b31f7f0cab5c8f69a12dfcd 100644 --- a/lib/gs-plugin.h +++ b/lib/gs-plugin.h @@ -15,7 +15,6 @@ #include "gs-app.h" #include "gs-app-list.h" -#include "gs-auth.h" #include "gs-category.h" #include "gs-plugin-event.h" #include "gs-plugin-types.h" @@ -71,10 +70,6 @@ const gchar *gs_plugin_get_language (GsPlugin *plugin); SoupSession *gs_plugin_get_soup_session (GsPlugin *plugin); void gs_plugin_set_soup_session (GsPlugin *plugin, SoupSession *soup_session); -void gs_plugin_add_auth (GsPlugin *plugin, - GsAuth *auth); -GsAuth *gs_plugin_get_auth_by_id (GsPlugin *plugin, - const gchar *auth_id); void gs_plugin_add_rule (GsPlugin *plugin, GsPluginRule rule, const gchar *name); diff --git a/lib/gs-price.c b/lib/gs-price.c deleted file mode 100644 index 4dc1a73c41ad0f3e35835d41b53bc2e73daa1601..0000000000000000000000000000000000000000 --- a/lib/gs-price.c +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2016 Canonical Ltd. - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include "config.h" - -#include - -#include "gs-price.h" - -struct _GsPrice -{ - GObject parent_instance; - - gdouble amount; - gchar *currency; -}; - -G_DEFINE_TYPE (GsPrice, gs_price, G_TYPE_OBJECT) - -/** - * gs_price_get_amount: - * @price: a #GsPrice - * - * Get the amount of money in this price. - * - * Returns: The amount of money in this price, e.g. 0.99 - */ -gdouble -gs_price_get_amount (GsPrice *price) -{ - g_return_val_if_fail (GS_IS_PRICE (price), 0); - return price->amount; -} - -/** - * gs_price_set_amount: - * @price: a #GsPrice - * @amount: The amount of this price, e.g. 0.99 - * - * Set the amount of money in this price. - */ -void -gs_price_set_amount (GsPrice *price, gdouble amount) -{ - g_return_if_fail (GS_IS_PRICE (price)); - price->amount = amount; -} - -/** - * gs_price_get_currency: - * @price: a #GsPrice - * - * Get the currency a price is using. - * - * Returns: an ISO 4217 currency code for this price, e.g. "USD" - */ -const gchar * -gs_price_get_currency (GsPrice *price) -{ - g_return_val_if_fail (GS_IS_PRICE (price), NULL); - return price->currency; -} - -/** - * gs_price_set_currency: - * @price: a #GsPrice - * @currency: An ISO 4217 currency code, e.g. "USD" - * - * Set the currency this price is using. - */ -void -gs_price_set_currency (GsPrice *price, const gchar *currency) -{ - g_return_if_fail (GS_IS_PRICE (price)); - g_free (price->currency); - price->currency = g_strdup (currency); -} - -/** - * gs_price_to_string: - * @price: a #GsPrice - * - * Convert a price object to a human readable string. - * - * Returns: A human readable string for this price, e.g. "US$0.99" - */ -gchar * -gs_price_to_string (GsPrice *price) -{ - g_return_val_if_fail (GS_IS_PRICE (price), NULL); - - if (g_strcmp0 (price->currency, "AUD") == 0) { - return g_strdup_printf (_("A$%.2f"), price->amount); - } else if (g_strcmp0 (price->currency, "CAD") == 0) { - return g_strdup_printf (_("C$%.2f"), price->amount); - } else if (g_strcmp0 (price->currency, "CNY") == 0) { - return g_strdup_printf (_("CN¥%.2f"), price->amount); - } else if (g_strcmp0 (price->currency, "EUR") == 0) { - return g_strdup_printf (_("€%.2f"), price->amount); - } else if (g_strcmp0 (price->currency, "GBP") == 0) { - return g_strdup_printf (_("£%.2f"), price->amount); - } else if (g_strcmp0 (price->currency, "JPY") == 0) { - return g_strdup_printf (_("¥%.2f"), price->amount); - } else if (g_strcmp0 (price->currency, "NZD") == 0) { - return g_strdup_printf (_("NZ$%.2f"), price->amount); - } else if (g_strcmp0 (price->currency, "RUB") == 0) { - return g_strdup_printf (_("₽%.2f"), price->amount); - } else if (g_strcmp0 (price->currency, "USD") == 0) { - return g_strdup_printf (_("US$%.2f"), price->amount); - } else { - /* Translators: %s is the currency, and %f is the amount. - * You can switch the order by using “%2$f %1$s” instead. */ - return g_strdup_printf (_("%s %f"), price->currency, price->amount); - } -} - -static void -gs_price_finalize (GObject *object) -{ - GsPrice *price = GS_PRICE (object); - - g_free (price->currency); - - G_OBJECT_CLASS (gs_price_parent_class)->finalize (object); -} - -static void -gs_price_class_init (GsPriceClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->finalize = gs_price_finalize; -} - -static void -gs_price_init (GsPrice *price) -{ -} - -/** - * gs_price_new: - * @amount: The amount of this price, e.g. 0.99 - * @currency: An ISO 4217 currency code, e.g. "USD" - * - * Creates a new price object. - * - * Return value: a new #GsPrice object. - **/ -GsPrice * -gs_price_new (gdouble amount, const gchar *currency) -{ - GsPrice *price; - price = g_object_new (GS_TYPE_PRICE, NULL); - price->amount = amount; - price->currency = g_strdup (currency); - return GS_PRICE (price); -} diff --git a/lib/gs-price.h b/lib/gs-price.h deleted file mode 100644 index fd5d0336d7a6256fd6758307d3c8cb50cd5029b1..0000000000000000000000000000000000000000 --- a/lib/gs-price.h +++ /dev/null @@ -1,31 +0,0 @@ - /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2016 Canonical Ltd. - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#pragma once - -#include - -G_BEGIN_DECLS - -#define GS_TYPE_PRICE (gs_price_get_type ()) - -G_DECLARE_FINAL_TYPE (GsPrice, gs_price, GS, PRICE, GObject) - -GsPrice *gs_price_new (gdouble amount, - const gchar *currency); - -gdouble gs_price_get_amount (GsPrice *price); -void gs_price_set_amount (GsPrice *price, - gdouble amount); - -const gchar *gs_price_get_currency (GsPrice *price); -void gs_price_set_currency (GsPrice *price, - const gchar *currency); - -gchar *gs_price_to_string (GsPrice *price); - -G_END_DECLS diff --git a/lib/meson.build b/lib/meson.build index b74248a5f438aa8ee05deeeadc0d6d0283027715..86c7d378de56111a3c63db438f5c9933c2c80128 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -39,14 +39,12 @@ install_headers([ 'gnome-software.h', 'gs-app.h', 'gs-app-list.h', - 'gs-auth.h', 'gs-category.h', 'gs-os-release.h', 'gs-plugin.h', 'gs-plugin-event.h', 'gs-plugin-types.h', 'gs-plugin-vfuncs.h', - 'gs-price.h', 'gs-utils.h' ], subdir : 'gnome-software' @@ -73,7 +71,6 @@ libgnomesoftware = static_library( sources : [ 'gs-app.c', 'gs-app-list.c', - 'gs-auth.c', 'gs-category.c', 'gs-debug.c', 'gs-ioprio.c', @@ -84,7 +81,6 @@ libgnomesoftware = static_library( 'gs-plugin-job.c', 'gs-plugin-loader.c', 'gs-plugin-loader-sync.c', - 'gs-price.c', 'gs-test.c', 'gs-utils.c', ], diff --git a/meson.build b/meson.build index 51c5648ad992eed60b1f40c46859e305934cc0a1..db2bcd034e7f346d58a6486379b6db9472120393 100644 --- a/meson.build +++ b/meson.build @@ -172,10 +172,6 @@ if get_option('gudev') gudev = dependency('gudev-1.0') endif -if get_option('snap') - snap = dependency('snapd-glib', version : '>= 1.48') -endif - gnome = import('gnome') i18n = import('i18n') diff --git a/meson_options.txt b/meson_options.txt index 0f961d9aca72801e7a18dcfcfb103185e9ded1ec..1154923119b31555d58b3a2fb24782fd265b3d1c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -13,7 +13,6 @@ option('shell_extensions', type : 'boolean', value : true, description : 'enable option('odrs', type : 'boolean', value : true, description : 'enable ODRS support') option('webapps', type : 'boolean', value : true, description : 'enable webapps support') option('gudev', type : 'boolean', value : true, description : 'enable GUdev support') -option('snap', type : 'boolean', value : false, description : 'enable Snap support') option('external_appstream', type : 'boolean', value : false, description : 'enable external AppStream support') option('valgrind', type : 'boolean', value : true, description : 'enable Valgrind debugging integration') option('gtk_doc', type : 'boolean', value : true, description : 'enable API reference') diff --git a/plugins/dummy/gs-plugin-dummy.c b/plugins/dummy/gs-plugin-dummy.c index bb3b1b12cb0cc27c62ed7c391a3b4ef8a72147c4..d426428f35c2cccd9ffa985e1c9d1b9d833d16a3 100644 --- a/plugins/dummy/gs-plugin-dummy.c +++ b/plugins/dummy/gs-plugin-dummy.c @@ -19,8 +19,6 @@ struct GsPluginData { guint quirk_id; guint allow_updates_id; gboolean allow_updates_inhibit; - guint has_auth; - GsAuth *auth; GsApp *cached_origin; GHashTable *installed_apps; /* id:1 */ GHashTable *available_apps; /* id:1 */ @@ -54,13 +52,6 @@ gs_plugin_initialize (GsPlugin *plugin) gs_plugin_dummy_allow_updates_cb, plugin); } - /* set up a dummy authentication provider */ - priv->auth = gs_auth_new (gs_plugin_get_name (plugin), "google", NULL); - if (priv->auth != NULL) { - gs_auth_set_provider_name (priv->auth, "GNOME SSO"); - gs_plugin_add_auth (plugin, priv->auth); - } - /* add source */ priv->cached_origin = gs_app_new (gs_plugin_get_name (plugin)); gs_app_set_kind (priv->cached_origin, AS_APP_KIND_SOURCE); @@ -102,8 +93,6 @@ gs_plugin_destroy (GsPlugin *plugin) g_hash_table_unref (priv->available_apps); if (priv->quirk_id > 0) g_source_remove (priv->quirk_id); - if (priv->auth != NULL) - g_object_unref (priv->auth); if (priv->cached_origin != NULL) g_object_unref (priv->cached_origin); } @@ -495,7 +484,7 @@ gs_plugin_add_popular (GsPlugin *plugin, /* add again, this time with a prefix so it gets deduplicated */ app2 = gs_app_new ("zeus.desktop"); gs_app_set_scope (app2, AS_APP_SCOPE_USER); - gs_app_set_bundle_kind (app2, AS_BUNDLE_KIND_SNAP); + gs_app_set_bundle_kind (app2, AS_BUNDLE_KIND_FLATPAK); gs_app_set_metadata (app2, "GnomeSoftware::Creator", gs_plugin_get_name (plugin)); gs_app_list_add (list, app2); @@ -871,28 +860,6 @@ gs_plugin_update_cancel (GsPlugin *plugin, GsApp *app, return TRUE; } -gboolean -gs_plugin_app_purchase (GsPlugin *plugin, - GsApp *app, - GsPrice *price, - GCancellable *cancellable, - GError **error) -{ - g_debug ("Purchasing app"); - - /* purchase app */ - if (g_strcmp0 (gs_app_get_id (app), "chiron-paid.desktop") == 0) { - gs_app_set_state (app, AS_APP_STATE_PURCHASING); - if (!gs_plugin_dummy_delay (plugin, app, 500, cancellable, error)) { - gs_app_set_state_recover (app); - return FALSE; - } - gs_app_set_state (app, AS_APP_STATE_AVAILABLE); - } - - return TRUE; -} - gboolean gs_plugin_review_submit (GsPlugin *plugin, GsApp *app, @@ -947,18 +914,6 @@ gs_plugin_review_remove (GsPlugin *plugin, GCancellable *cancellable, GError **error) { - GsPluginData *priv = gs_plugin_get_data (plugin); - - /* simulate an auth check */ - if (!priv->has_auth) { - g_set_error (error, - GS_PLUGIN_ERROR, - GS_PLUGIN_ERROR_AUTH_REQUIRED, - "authentication is required using @%s", - gs_plugin_get_name (plugin)); - return FALSE; - } - /* all okay */ g_debug ("Removing dummy self-review"); return TRUE; diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c index 3f6b9c8e569af95b45851e89ad390f7f70845c17..8ca5f8ca51765b4b9b65ee3dc199f34eb333c8cf 100644 --- a/plugins/dummy/gs-self-test.c +++ b/plugins/dummy/gs-self-test.c @@ -591,30 +591,6 @@ gs_plugins_dummy_wildcard_func (GsPluginLoader *plugin_loader) } } -static void -gs_plugins_dummy_purchase_func (GsPluginLoader *plugin_loader) -{ - gboolean ret; - g_autoptr(GsApp) app = NULL; - g_autoptr(GError) error = NULL; - g_autoptr(GsPluginJob) plugin_job = NULL; - - /* get the updates list */ - app = gs_app_new ("chiron-paid.desktop"); - gs_app_set_management_plugin (app, "dummy"); - gs_app_set_state (app, AS_APP_STATE_PURCHASABLE); - gs_app_set_price (app, 100, "USD"); - plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_PURCHASE, - "app", app, - "price", gs_app_get_price (app), - NULL); - ret = gs_plugin_loader_job_action (plugin_loader, plugin_job, NULL, &error); - gs_test_flush_main_context (); - g_assert_no_error (error); - g_assert (ret); - g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE); -} - static void plugin_job_action_cb (GObject *source, GAsyncResult *res, @@ -880,9 +856,6 @@ main (int argc, char **argv) g_test_add_data_func ("/gnome-software/plugins/dummy/distro-upgrades", plugin_loader, (GTestDataFunc) gs_plugins_dummy_distro_upgrades_func); - g_test_add_data_func ("/gnome-software/plugins/dummy/purchase", - plugin_loader, - (GTestDataFunc) gs_plugins_dummy_purchase_func); g_test_add_data_func ("/gnome-software/plugins/dummy/metadata-quirks", plugin_loader, (GTestDataFunc) gs_plugins_dummy_metadata_quirks); diff --git a/plugins/eos-updater/gs-plugin-eos-updater.c b/plugins/eos-updater/gs-plugin-eos-updater.c index 55e5d2b63bb9b3101fe19baf4180fa6b26440b4d..f38eee507b1aa47234f75fd3fd458010993baa71 100644 --- a/plugins/eos-updater/gs-plugin-eos-updater.c +++ b/plugins/eos-updater/gs-plugin-eos-updater.c @@ -229,8 +229,6 @@ should_add_os_upgrade (AsAppState state) case AS_APP_STATE_QUEUED_FOR_INSTALL: case AS_APP_STATE_INSTALLING: case AS_APP_STATE_UPDATABLE_LIVE: - case AS_APP_STATE_PURCHASABLE: - case AS_APP_STATE_PURCHASING: return TRUE; case AS_APP_STATE_UNKNOWN: case AS_APP_STATE_INSTALLED: diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c index f1355e5dd9e091d8928d3d6377a562e53a4541ac..164969550c9f28f7d33958f41e55a320d2823ad9 100644 --- a/plugins/flatpak/gs-flatpak.c +++ b/plugins/flatpak/gs-flatpak.c @@ -793,7 +793,6 @@ gs_flatpak_progress_cb (const gchar *status, switch (gs_app_get_state (phelper->app)) { case AS_APP_STATE_INSTALLING: - case AS_APP_STATE_PURCHASING: plugin_status = GS_PLUGIN_STATUS_INSTALLING; break; case AS_APP_STATE_REMOVING: diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c index 071471b27d6c7deeff1ffd0805c6c9421b156a32..e353405acc182c9ebe8b97f96b27e59786a3f50f 100644 --- a/plugins/fwupd/gs-plugin-fwupd.c +++ b/plugins/fwupd/gs-plugin-fwupd.c @@ -63,8 +63,6 @@ gs_plugin_fwupd_error_convert (GError **perror) error->code = GS_PLUGIN_ERROR_NOT_SUPPORTED; break; case FWUPD_ERROR_AUTH_FAILED: - error->code = GS_PLUGIN_ERROR_AUTH_INVALID; - break; case FWUPD_ERROR_SIGNATURE_INVALID: error->code = GS_PLUGIN_ERROR_NO_SECURITY; break; diff --git a/plugins/meson.build b/plugins/meson.build index c941fef156efa65fa350caa82c52130d29adac18..d37dd7025cc39467fc9f9a07573e20bfab2a2cff 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -39,9 +39,6 @@ endif if get_option('shell_extensions') subdir('shell-extensions') endif -if get_option('snap') - subdir('snap') -endif if get_option('external_appstream') subdir('external-appstream') endif diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c deleted file mode 100644 index 18146f605bba01d77cd4ea2259c7502efe9eb3cc..0000000000000000000000000000000000000000 --- a/plugins/snap/gs-plugin-snap.c +++ /dev/null @@ -1,1151 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2015-2018 Canonical Ltd - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include - -#include -#include -#include -#include - -struct GsPluginData { - SnapdAuthData *auth_data; - gchar *store_name; - SnapdSystemConfinement system_confinement; - GsAuth *auth; - - GMutex store_snaps_lock; - GHashTable *store_snaps; -}; - -static SnapdClient * -get_client (GsPlugin *plugin, GError **error) -{ - GsPluginData *priv = gs_plugin_get_data (plugin); - g_autoptr(SnapdClient) client = NULL; - const gchar *old_user_agent; - g_autofree gchar *user_agent = NULL; - - client = snapd_client_new (); - snapd_client_set_allow_interaction (client, TRUE); - old_user_agent = snapd_client_get_user_agent (client); - user_agent = g_strdup_printf ("%s %s", gs_user_agent (), old_user_agent); - snapd_client_set_user_agent (client, user_agent); - snapd_client_set_auth_data (client, priv->auth_data); - - return g_steal_pointer (&client); -} - -static void -load_auth (GsPlugin *plugin); - -void -gs_plugin_initialize (GsPlugin *plugin) -{ - GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData)); - g_autoptr(SnapdClient) client = NULL; - g_autoptr (GError) error = NULL; - - g_mutex_init (&priv->store_snaps_lock); - - client = get_client (plugin, &error); - if (client == NULL) { - gs_plugin_set_enabled (plugin, FALSE); - return; - } - - priv->store_snaps = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, (GDestroyNotify) g_object_unref); - - priv->auth = gs_auth_new ("snapd", "ubuntusso", &error); - if (priv->auth) { - gs_auth_set_provider_name (priv->auth, "Snap Store"); - gs_auth_set_header (priv->auth, _("To continue, you need to use an Ubuntu One account."), - _("To continue, you need to use your Ubuntu One account."), - _("To continue, you need to use an Ubuntu One account.")); - gs_plugin_add_auth (plugin, priv->auth); - g_signal_connect_object (priv->auth, "changed", - G_CALLBACK (load_auth), - plugin, G_CONNECT_SWAPPED); - } else { - g_warning ("Failed to instantiate the snapd authentication object: %s", error->message); - } - - gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "desktop-categories"); - gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_BETTER_THAN, "packagekit"); - gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_BEFORE, "icons"); - - /* Override hardcoded popular apps */ - gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_BEFORE, "hardcoded-popular"); - - /* set name of MetaInfo file */ - gs_plugin_set_appstream_id (plugin, "org.gnome.Software.Plugin.Snap"); -} - -void -gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app) -{ - if (gs_app_get_bundle_kind (app) == AS_BUNDLE_KIND_SNAP) - gs_app_set_management_plugin (app, "snap"); - - if (g_str_has_prefix (gs_app_get_id (app), "io.snapcraft.")) { - g_autofree gchar *name_and_id = NULL; - gchar *divider, *snap_name;/*, *id;*/ - - name_and_id = g_strdup (gs_app_get_id (app) + strlen ("io.snapcraft.")); - divider = strrchr (name_and_id, '-'); - if (divider != NULL) { - *divider = '\0'; - snap_name = name_and_id; - /*id = divider + 1;*/ /* NOTE: Should probably validate ID */ - - gs_app_set_management_plugin (app, "snap"); - gs_app_set_metadata (app, "snap::name", snap_name); - gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_SNAP); - } - } -} - -static void -snapd_error_convert (GError **perror) -{ - GError *error = perror != NULL ? *perror : NULL; - - /* not set */ - if (error == NULL) - return; - - /* this are allowed for low-level errors */ - if (gs_utils_error_convert_gio (perror)) - return; - - /* custom to this plugin */ - if (error->domain == SNAPD_ERROR) { - switch (error->code) { - case SNAPD_ERROR_AUTH_DATA_REQUIRED: - error->code = GS_PLUGIN_ERROR_AUTH_REQUIRED; - g_free (error->message); - error->message = g_strdup ("Requires authentication with @snapd"); - break; - case SNAPD_ERROR_AUTH_DATA_INVALID: - case SNAPD_ERROR_TWO_FACTOR_INVALID: - error->code = GS_PLUGIN_ERROR_AUTH_INVALID; - break; - case SNAPD_ERROR_AUTH_CANCELLED: - error->code = GS_PLUGIN_ERROR_CANCELLED; - break; - case SNAPD_ERROR_CONNECTION_FAILED: - case SNAPD_ERROR_WRITE_FAILED: - case SNAPD_ERROR_READ_FAILED: - case SNAPD_ERROR_BAD_REQUEST: - case SNAPD_ERROR_BAD_RESPONSE: - case SNAPD_ERROR_PERMISSION_DENIED: - case SNAPD_ERROR_FAILED: - case SNAPD_ERROR_TERMS_NOT_ACCEPTED: - case SNAPD_ERROR_PAYMENT_NOT_SETUP: - case SNAPD_ERROR_PAYMENT_DECLINED: - case SNAPD_ERROR_ALREADY_INSTALLED: - case SNAPD_ERROR_NOT_INSTALLED: - case SNAPD_ERROR_NO_UPDATE_AVAILABLE: - case SNAPD_ERROR_PASSWORD_POLICY_ERROR: - case SNAPD_ERROR_NEEDS_DEVMODE: - case SNAPD_ERROR_NEEDS_CLASSIC: - case SNAPD_ERROR_NEEDS_CLASSIC_SYSTEM: - default: - error->code = GS_PLUGIN_ERROR_FAILED; - break; - } - } else { - g_warning ("can't reliably fixup error from domain %s", - g_quark_to_string (error->domain)); - error->code = GS_PLUGIN_ERROR_FAILED; - } - error->domain = GS_PLUGIN_ERROR; -} - -static void -load_auth (GsPlugin *plugin) -{ - GsPluginData *priv = gs_plugin_get_data (plugin); - GsAuth *auth; - GoaObject *goa_object; - GoaPasswordBased *password_based; - g_autofree gchar *macaroon = NULL; - g_autofree gchar *discharges_str = NULL; - g_autoptr(GVariant) discharges_var = NULL; - g_auto(GStrv) discharges = NULL; - g_autoptr(SnapdAuthData) auth_data = NULL; - g_autoptr(GError) error = NULL; - - auth = gs_plugin_get_auth_by_id (plugin, "snapd"); - if (auth == NULL) - return; - - g_clear_object (&priv->auth_data); - goa_object = gs_auth_peek_goa_object (auth); - if (goa_object == NULL) - return; - - password_based = goa_object_peek_password_based (goa_object); - g_return_if_fail (password_based != NULL); - - goa_password_based_call_get_password_sync (password_based, - "macaroon", - &macaroon, - NULL, &error); - if (error != NULL) { - g_warning ("Failed to get macaroon: %s", error->message); - return; - } - - goa_password_based_call_get_password_sync (password_based, - "discharges", - &discharges_str, - NULL, &error); - if (error != NULL) { - g_warning ("Failed to get discharges %s", error->message); - return; - } - - if (discharges_str) - discharges_var = g_variant_parse (G_VARIANT_TYPE ("as"), - discharges_str, - NULL, NULL, NULL); - if (discharges_var) - discharges = g_variant_dup_strv (discharges_var, NULL); - - priv->auth_data = snapd_auth_data_new (macaroon, discharges); -} - -gboolean -gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error) -{ - GsPluginData *priv = gs_plugin_get_data (plugin); - g_autoptr(SnapdClient) client = NULL; - g_autoptr(SnapdSystemInformation) system_information = NULL; - - client = get_client (plugin, error); - if (client == NULL) - return FALSE; - - system_information = snapd_client_get_system_information_sync (client, cancellable, error); - if (system_information == NULL) - return FALSE; - priv->store_name = g_strdup (snapd_system_information_get_store (system_information)); - if (priv->store_name == NULL) - priv->store_name = g_strdup (/* TRANSLATORS: default snap store name */ - _("Snap Store")); - priv->system_confinement = snapd_system_information_get_confinement (system_information); - - /* success */ - return TRUE; -} - -static SnapdSnap * -store_snap_cache_lookup (GsPlugin *plugin, const gchar *name) -{ - GsPluginData *priv = gs_plugin_get_data (plugin); - g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&priv->store_snaps_lock); - SnapdSnap *snap; - - snap = g_hash_table_lookup (priv->store_snaps, name); - if (snap == NULL) - return NULL; - - return g_object_ref (snap); -} - -static void -store_snap_cache_update (GsPlugin *plugin, GPtrArray *snaps) -{ - GsPluginData *priv = gs_plugin_get_data (plugin); - g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&priv->store_snaps_lock); - guint i; - - for (i = 0; i < snaps->len; i++) { - SnapdSnap *snap = snaps->pdata[i]; - g_hash_table_insert (priv->store_snaps, g_strdup (snapd_snap_get_name (snap)), g_object_ref (snap)); - } -} - -static GPtrArray * -find_snaps (GsPlugin *plugin, SnapdFindFlags flags, const gchar *section, const gchar *query, GCancellable *cancellable, GError **error) -{ - g_autoptr(SnapdClient) client = NULL; - g_autoptr(GPtrArray) snaps = NULL; - - client = get_client (plugin, error); - if (client == NULL) - return NULL; - - snaps = snapd_client_find_section_sync (client, flags, section, query, NULL, cancellable, error); - if (snaps == NULL) { - snapd_error_convert (error); - return NULL; - } - - store_snap_cache_update (plugin, snaps); - - return g_steal_pointer (&snaps); -} - -static GsApp * -snap_to_app (GsPlugin *plugin, SnapdSnap *snap) -{ - GsPluginData *priv = gs_plugin_get_data (plugin); - GStrv common_ids; - g_autofree gchar *appstream_id = NULL; - g_autofree gchar *unique_id = NULL; - g_autoptr(GsApp) app = NULL; - SnapdConfinement confinement; - - /* Get the AppStream ID from the snap, or generate a fallback one */ - common_ids = snapd_snap_get_common_ids (snap); - if (g_strv_length (common_ids) == 1) - appstream_id = g_strdup (common_ids[0]); - else - appstream_id = g_strdup_printf ("io.snapcraft.%s-%s", snapd_snap_get_name (snap), snapd_snap_get_id (snap)); - - switch (snapd_snap_get_snap_type (snap)) { - case SNAPD_SNAP_TYPE_APP: - unique_id = g_strdup_printf ("system/snap/*/desktop/%s/*", appstream_id); - break; - case SNAPD_SNAP_TYPE_KERNEL: - case SNAPD_SNAP_TYPE_GADGET: - case SNAPD_SNAP_TYPE_OS: - unique_id = g_strdup_printf ("system/snap/*/runtime/%s/*", appstream_id); - break; - default: - case SNAPD_SNAP_TYPE_UNKNOWN: - unique_id = g_strdup_printf ("system/snap/*/*/%s/*", appstream_id); - break; - } - - app = gs_plugin_cache_lookup (plugin, unique_id); - if (app == NULL) { - app = gs_app_new (NULL); - gs_app_set_from_unique_id (app, unique_id); - gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_SNAP); - gs_app_set_metadata (app, "snap::name", snapd_snap_get_name (snap)); - gs_plugin_cache_add (plugin, unique_id, app); - } - - gs_app_set_management_plugin (app, "snap"); - if (gs_app_get_kind (app) != AS_APP_KIND_DESKTOP) - gs_app_add_quirk (app, GS_APP_QUIRK_NOT_LAUNCHABLE); - if (gs_plugin_check_distro_id (plugin, "ubuntu")) - gs_app_add_quirk (app, GS_APP_QUIRK_PROVENANCE); - - confinement = snapd_snap_get_confinement (snap); - if (confinement != SNAPD_CONFINEMENT_UNKNOWN) { - GEnumClass *enum_class = g_type_class_ref (SNAPD_TYPE_CONFINEMENT); - gs_app_set_metadata (app, "snap::confinement", g_enum_get_value (enum_class, confinement)->value_nick); - g_type_class_unref (enum_class); - } - - if (priv->system_confinement == SNAPD_SYSTEM_CONFINEMENT_STRICT && confinement == SNAPD_CONFINEMENT_STRICT) - gs_app_add_kudo (app, GS_APP_KUDO_SANDBOXED); - - return g_steal_pointer (&app); -} - -gboolean -gs_plugin_url_to_app (GsPlugin *plugin, - GsAppList *list, - const gchar *url, - GCancellable *cancellable, - GError **error) -{ - g_autofree gchar *scheme = NULL; - g_autofree gchar *path = NULL; - g_autoptr(GPtrArray) snaps = NULL; - g_autoptr(GsApp) app = NULL; - - /* not us */ - scheme = gs_utils_get_url_scheme (url); - if (g_strcmp0 (scheme, "snap") != 0) - return TRUE; - - /* create app */ - path = gs_utils_get_url_path (url); - snaps = find_snaps (plugin, SNAPD_FIND_FLAGS_SCOPE_WIDE | SNAPD_FIND_FLAGS_MATCH_NAME, NULL, path, cancellable, NULL); - if (snaps == NULL || snaps->len < 1) - return TRUE; - - app = snap_to_app (plugin, g_ptr_array_index (snaps, 0)); - gs_app_list_add (list, app); - - return TRUE; -} - -void -gs_plugin_destroy (GsPlugin *plugin) -{ - GsPluginData *priv = gs_plugin_get_data (plugin); - g_free (priv->store_name); - g_clear_object (&priv->auth); - g_clear_pointer (&priv->store_snaps, g_hash_table_unref); - g_mutex_clear (&priv->store_snaps_lock); -} - -static gboolean -is_banner_image (const gchar *filename) -{ - /* Check if this screenshot was uploaded as "banner.png" or "banner.jpg". - * The server optionally adds a 7 character suffix onto it if it would collide with - * an existing name, e.g. "banner_MgEy4MI.png" - * See https://forum.snapcraft.io/t/improve-method-for-setting-featured-snap-banner-image-in-store/ - */ - return g_regex_match_simple ("^banner(?:_[a-zA-Z0-9]{7})?\\.(?:png|jpg)$", filename, 0, 0); -} - -static gboolean -is_banner_icon_image (const gchar *filename) -{ - /* Check if this screenshot was uploaded as "banner-icon.png" or "banner-icon.jpg". - * The server optionally adds a 7 character suffix onto it if it would collide with - * an existing name, e.g. "banner-icon_Ugn6pmj.png" - * See https://forum.snapcraft.io/t/improve-method-for-setting-featured-snap-banner-image-in-store/ - */ - return g_regex_match_simple ("^banner-icon(?:_[a-zA-Z0-9]{7})?\\.(?:png|jpg)$", filename, 0, 0); -} - -static const gchar * -get_media_url (SnapdSnap *snap, gboolean (*match_func)(const gchar *filename)) -{ - GPtrArray *media, *screenshots; - guint i; - - media = snapd_snap_get_media (snap); - for (i = 0; i < media->len; i++) { - SnapdMedia *m = media->pdata[i]; - - /* FIXME: In the future there will be a media type for these */ - - /* Fall back to old specially named screenshots */ - if (g_strcmp0 (snapd_media_get_media_type (m), "screenshot") == 0) { - const gchar *url; - g_autofree gchar *filename = NULL; - - url = snapd_media_get_url (m); - filename = g_path_get_basename (url); - if (match_func (filename)) - return url; - } - } - - /* Fall back to old screenshots */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - screenshots = snapd_snap_get_screenshots (snap); -G_GNUC_END_IGNORE_DEPRECATIONS - for (i = 0; i < screenshots->len; i++) { - SnapdScreenshot *screenshot = screenshots->pdata[i]; - const gchar *url; - g_autofree gchar *filename = NULL; - - url = snapd_screenshot_get_url (screenshot); - filename = g_path_get_basename (url); - if (match_func (filename)) - return url; - } - - return NULL; -} - -gboolean -gs_plugin_add_featured (GsPlugin *plugin, - GsAppList *list, - GCancellable *cancellable, - GError **error) -{ - g_autoptr(GPtrArray) snaps = NULL; - SnapdSnap *snap; - g_autoptr(GsApp) app = NULL; - const gchar *banner_url = NULL, *icon_url = NULL; - g_autoptr(GString) background_css = NULL; - g_autofree gchar *css = NULL; - - snaps = find_snaps (plugin, SNAPD_FIND_FLAGS_SCOPE_WIDE, "featured", NULL, cancellable, error); - - if (snaps == NULL) - return FALSE; - - if (snaps->len == 0) - return TRUE; - - /* use first snap as the featured app */ - snap = snaps->pdata[0]; - app = snap_to_app (plugin, snap); - - /* if has a screenshot called 'banner.png' or 'banner-icon.png' then use them for the banner */ - banner_url = get_media_url (snap, is_banner_image); - icon_url = get_media_url (snap, is_banner_icon_image); - - background_css = g_string_new (""); - if (icon_url != NULL) - g_string_append_printf (background_css, - "url('%s') left center / auto 100%% no-repeat, ", - icon_url); - else - g_string_append_printf (background_css, - "url('%s') left center / auto 100%% no-repeat, ", - snapd_snap_get_icon (snap)); - if (banner_url != NULL) - g_string_append_printf (background_css, - "url('%s') center / cover no-repeat;", - banner_url); - else - g_string_append_printf (background_css, "#FFFFFF;"); - css = g_strdup_printf ("border-color: #000000;\n" - "text-shadow: 0 1px 1px rgba(255,255,255,0.5);\n" - "color: #000000;\n" - "outline-offset: 0;\n" - "outline-color: alpha(#ffffff, 0.75);\n" - "outline-style: dashed;\n" - "outline-offset: 2px;\n" - "background: %s;", - background_css->str); - gs_app_set_metadata (app, "GnomeSoftware::FeatureTile-css", css); - - gs_app_list_add (list, app); - - return TRUE; -} - -gboolean -gs_plugin_add_popular (GsPlugin *plugin, - GsAppList *list, - GCancellable *cancellable, - GError **error) -{ - g_autoptr(GPtrArray) snaps = NULL; - guint i; - - snaps = find_snaps (plugin, SNAPD_FIND_FLAGS_SCOPE_WIDE, "featured", NULL, cancellable, error); - if (snaps == NULL) - return FALSE; - - /* skip first snap - it is used as the featured app */ - for (i = 1; i < snaps->len; i++) { - g_autoptr(GsApp) app = snap_to_app (plugin, g_ptr_array_index (snaps, i)); - gs_app_list_add (list, app); - } - - return TRUE; -} - -gboolean -gs_plugin_add_category_apps (GsPlugin *plugin, - GsCategory *category, - GsAppList *list, - GCancellable *cancellable, - GError **error) -{ - GsCategory *c; - g_autoptr(GString) id = NULL; - const gchar *sections = NULL; - - id = g_string_new (""); - for (c = category; c != NULL; c = gs_category_get_parent (c)) { - if (c != category) - g_string_prepend (id, "/"); - g_string_prepend (id, gs_category_get_id (c)); - } - - if (strcmp (id->str, "games/featured") == 0) - sections = "games"; - else if (strcmp (id->str, "audio-video/featured") == 0) - sections = "music;video"; - else if (strcmp (id->str, "graphics/featured") == 0) - sections = "graphics"; - else if (strcmp (id->str, "communication/featured") == 0) - sections = "social-networking"; - else if (strcmp (id->str, "productivity/featured") == 0) - sections = "productivity;finance"; - else if (strcmp (id->str, "developer-tools/featured") == 0) - sections = "developers"; - else if (strcmp (id->str, "utilities/featured") == 0) - sections = "utilities"; - - if (sections != NULL) { - g_auto(GStrv) tokens = NULL; - int i; - - tokens = g_strsplit (sections, ";", -1); - for (i = 0; tokens[i] != NULL; i++) { - g_autoptr(GPtrArray) snaps = NULL; - guint j; - - snaps = find_snaps (plugin, SNAPD_FIND_FLAGS_SCOPE_WIDE, tokens[i], NULL, cancellable, error); - if (snaps == NULL) - return FALSE; - for (j = 0; j < snaps->len; j++) { - g_autoptr(GsApp) app = snap_to_app (plugin, g_ptr_array_index (snaps, j)); - gs_app_list_add (list, app); - } - } - } - return TRUE; -} - -gboolean -gs_plugin_add_installed (GsPlugin *plugin, - GsAppList *list, - GCancellable *cancellable, - GError **error) -{ - g_autoptr(SnapdClient) client = NULL; - g_autoptr(GPtrArray) snaps = NULL; - guint i; - - client = get_client (plugin, error); - if (client == NULL) - return FALSE; - - snaps = snapd_client_get_snaps_sync (client, SNAPD_GET_SNAPS_FLAGS_NONE, NULL, cancellable, error); - if (snaps == NULL) { - snapd_error_convert (error); - return FALSE; - } - - for (i = 0; i < snaps->len; i++) { - SnapdSnap *snap = g_ptr_array_index (snaps, i); - g_autoptr(GsApp) app = NULL; - - app = snap_to_app (plugin, snap); - gs_app_list_add (list, app); - } - - return TRUE; -} - -gboolean -gs_plugin_add_search (GsPlugin *plugin, - gchar **values, - GsAppList *list, - GCancellable *cancellable, - GError **error) -{ - g_autofree gchar *query = NULL; - g_autoptr(GPtrArray) snaps = NULL; - guint i; - - query = g_strjoinv (" ", values); - snaps = find_snaps (plugin, SNAPD_FIND_FLAGS_SCOPE_WIDE, NULL, query, cancellable, error); - if (snaps == NULL) - return FALSE; - - for (i = 0; i < snaps->len; i++) { - g_autoptr(GsApp) app = snap_to_app (plugin, g_ptr_array_index (snaps, i)); - gs_app_list_add (list, app); - } - - return TRUE; -} - -static SnapdSnap * -get_store_snap (GsPlugin *plugin, const gchar *name, GCancellable *cancellable, GError **error) -{ - SnapdSnap *snap = NULL; - g_autoptr(GPtrArray) snaps = NULL; - - /* use cached version if available */ - snap = store_snap_cache_lookup (plugin, name); - if (snap != NULL) - return g_object_ref (snap); - - snaps = find_snaps (plugin, SNAPD_FIND_FLAGS_SCOPE_WIDE | SNAPD_FIND_FLAGS_MATCH_NAME, NULL, name, cancellable, error); - if (snaps == NULL || snaps->len < 1) - return NULL; - - return g_object_ref (g_ptr_array_index (snaps, 0)); -} - -static gboolean -load_snap_icon (GsApp *app, SnapdClient *client, SnapdSnap *snap, GCancellable *cancellable) -{ - const gchar *icon_url; - g_autoptr(SnapdIcon) icon = NULL; - g_autoptr(GInputStream) input_stream = NULL; - g_autoptr(GdkPixbuf) pixbuf = NULL; - g_autoptr(GError) error = NULL; - - icon_url = snapd_snap_get_icon (snap); - if (icon_url == NULL || strcmp (icon_url, "") == 0) - return FALSE; - - icon = snapd_client_get_icon_sync (client, gs_app_get_metadata_item (app, "snap::name"), cancellable, &error); - if (icon == NULL) { - g_warning ("Failed to load snap icon: %s", error->message); - return FALSE; - } - - input_stream = g_memory_input_stream_new_from_bytes (snapd_icon_get_data (icon)); - pixbuf = gdk_pixbuf_new_from_stream_at_scale (input_stream, 64, 64, TRUE, cancellable, &error); - if (pixbuf == NULL) { - g_warning ("Failed to decode snap icon %s: %s", icon_url, error->message); - return FALSE; - } - gs_app_set_pixbuf (app, pixbuf); - - return TRUE; -} - -static gboolean -app_name_matches_snap_name (SnapdSnap *snap, SnapdApp *app) -{ - return g_strcmp0 (snapd_snap_get_name (snap), snapd_app_get_name (app)) == 0; -} - -static SnapdApp * -get_primary_app (SnapdSnap *snap) -{ - GPtrArray *apps; - guint i; - SnapdApp *primary_app = NULL; - - /* Pick the "main" app from the snap. In order of - * preference, we want to pick: - * - * 1. the main app, provided it has a desktop file - * 2. the first app with a desktop file - * 3. the main app - * 4. the first app - * - * The "main app" is one whose name matches the snap name. - */ - apps = snapd_snap_get_apps (snap); - for (i = 0; i < apps->len; i++) { - SnapdApp *app = apps->pdata[i]; - - if (primary_app == NULL || - (snapd_app_get_desktop_file (primary_app) == NULL && snapd_app_get_desktop_file (app) != NULL) || - (!app_name_matches_snap_name (snap, primary_app) && app_name_matches_snap_name (snap, app))) - primary_app = app; - } - - return primary_app; -} - -static gboolean -load_desktop_icon (GsApp *app, SnapdSnap *snap) -{ - GPtrArray *apps; - guint i; - - apps = snapd_snap_get_apps (snap); - for (i = 0; i < apps->len; i++) { - SnapdApp *snap_app = apps->pdata[i]; - const gchar *desktop_file_path; - g_autoptr(GKeyFile) desktop_file = NULL; - g_autoptr(GError) error = NULL; - g_autofree gchar *icon_value = NULL; - g_autoptr(AsIcon) icon = NULL; - - desktop_file_path = snapd_app_get_desktop_file (snap_app); - if (desktop_file_path == NULL) - continue; - - desktop_file = g_key_file_new (); - if (!g_key_file_load_from_file (desktop_file, desktop_file_path, G_KEY_FILE_NONE, &error)) { - g_warning ("Failed to load desktop file %s: %s", desktop_file_path, error->message); - continue; - } - - icon_value = g_key_file_get_string (desktop_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, &error); - if (icon_value == NULL) { - g_warning ("Failed to get desktop file icon %s: %s", desktop_file_path, error->message); - continue; - } - - icon = as_icon_new (); - if (g_str_has_prefix (icon_value, "/")) { - as_icon_set_kind (icon, AS_ICON_KIND_LOCAL); - as_icon_set_filename (icon, icon_value); - } else { - as_icon_set_kind (icon, AS_ICON_KIND_STOCK); - as_icon_set_name (icon, icon_value); - } - gs_app_add_icon (app, icon); - - return TRUE; - } - - return FALSE; -} - -static gboolean -load_store_icon (GsApp *app, SnapdSnap *snap) -{ - const gchar *icon_url; - - icon_url = snapd_snap_get_icon (snap); - if (icon_url == NULL) - return FALSE; - - if (g_str_has_prefix (icon_url, "http://") || g_str_has_prefix (icon_url, "https://")) { - g_autoptr(AsIcon) icon = as_icon_new (); - as_icon_set_kind (icon, AS_ICON_KIND_REMOTE); - as_icon_set_url (icon, icon_url); - gs_app_add_icon (app, icon); - return TRUE; - } - - return FALSE; -} - -static gboolean -load_icon (GsPlugin *plugin, SnapdClient *client, GsApp *app, const gchar *id, SnapdSnap *local_snap, SnapdSnap *store_snap, GCancellable *cancellable) -{ - if (local_snap != NULL) { - if (load_snap_icon (app, client, local_snap, cancellable)) - return TRUE; - if (load_desktop_icon (app, local_snap)) - return TRUE; - } - - if (store_snap == NULL) - store_snap = get_store_snap (plugin, gs_app_get_metadata_item (app, "snap::name"), cancellable, NULL); - if (store_snap != NULL) - return load_store_icon (app, store_snap); - - return FALSE; -} - -static gchar * -gs_plugin_snap_get_description_safe (SnapdSnap *snap) -{ - GString *str = g_string_new (snapd_snap_get_description (snap)); - as_utils_string_replace (str, "\r", ""); - as_utils_string_replace (str, " ", " "); - return g_string_free (str, FALSE); -} - -static void -refine_screenshots (GsApp *app, SnapdSnap *snap) -{ - GPtrArray *media, *screenshots; - guint i; - - media = snapd_snap_get_media (snap); - for (i = 0; i < media->len; i++) { - SnapdMedia *m = media->pdata[i]; - const gchar *url; - g_autofree gchar *filename = NULL; - g_autoptr(AsScreenshot) ss = NULL; - g_autoptr(AsImage) image = NULL; - - if (g_strcmp0 (snapd_media_get_media_type (m), "screenshot") != 0) - continue; - - /* skip screenshots used for banner when app is featured */ - url = snapd_media_get_url (m); - filename = g_path_get_basename (url); - if (is_banner_image (filename) || is_banner_icon_image (filename)) - continue; - - ss = as_screenshot_new (); - as_screenshot_set_kind (ss, AS_SCREENSHOT_KIND_NORMAL); - image = as_image_new (); - as_image_set_url (image, snapd_media_get_url (m)); - as_image_set_kind (image, AS_IMAGE_KIND_SOURCE); - as_image_set_width (image, snapd_media_get_width (m)); - as_image_set_height (image, snapd_media_get_height (m)); - as_screenshot_add_image (ss, image); - gs_app_add_screenshot (app, ss); - } - - if (gs_app_get_screenshots (app)->len > 0) - return; - - /* fallback to old screenshots data */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - screenshots = snapd_snap_get_screenshots (snap); -G_GNUC_END_IGNORE_DEPRECATIONS - for (i = 0; i < screenshots->len; i++) { - SnapdScreenshot *screenshot = screenshots->pdata[i]; - const gchar *url; - g_autofree gchar *filename = NULL; - g_autoptr(AsScreenshot) ss = NULL; - g_autoptr(AsImage) image = NULL; - - /* skip screenshots used for banner when app is featured */ - url = snapd_screenshot_get_url (screenshot); - filename = g_path_get_basename (url); - if (is_banner_image (filename) || is_banner_icon_image (filename)) - continue; - - ss = as_screenshot_new (); - as_screenshot_set_kind (ss, AS_SCREENSHOT_KIND_NORMAL); - image = as_image_new (); - as_image_set_url (image, snapd_screenshot_get_url (screenshot)); - as_image_set_kind (image, AS_IMAGE_KIND_SOURCE); - as_image_set_width (image, snapd_screenshot_get_width (screenshot)); - as_image_set_height (image, snapd_screenshot_get_height (screenshot)); - as_screenshot_add_image (ss, image); - gs_app_add_screenshot (app, ss); - } -} - -gboolean -gs_plugin_refine_app (GsPlugin *plugin, - GsApp *app, - GsPluginRefineFlags flags, - GCancellable *cancellable, - GError **error) -{ - GsPluginData *priv = gs_plugin_get_data (plugin); - g_autoptr(SnapdClient) client = NULL; - const gchar *name; - g_autoptr(SnapdSnap) local_snap = NULL; - g_autoptr(SnapdSnap) store_snap = NULL; - SnapdSnap *snap; - const gchar *developer_name; - g_autofree gchar *description = NULL; - - /* not us */ - if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0) - return TRUE; - - client = get_client (plugin, error); - if (client == NULL) - return FALSE; - - /* get information from local snaps and store */ - local_snap = snapd_client_get_snap_sync (client, gs_app_get_metadata_item (app, "snap::name"), cancellable, NULL); - if (local_snap == NULL || (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS) != 0) - store_snap = get_store_snap (plugin, gs_app_get_metadata_item (app, "snap::name"), cancellable, NULL); - if (local_snap == NULL && store_snap == NULL) - return TRUE; - - if (local_snap != NULL) - gs_app_set_state (app, AS_APP_STATE_INSTALLED); - else - gs_app_set_state (app, AS_APP_STATE_AVAILABLE); - - /* use store information for basic metadata over local information */ - snap = store_snap != NULL ? store_snap : local_snap; - name = snapd_snap_get_title (snap); - if (name == NULL || g_strcmp0 (name, "") == 0) - name = snapd_snap_get_name (snap); - gs_app_set_name (app, GS_APP_QUALITY_NORMAL, name); - gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, snapd_snap_get_summary (snap)); - description = gs_plugin_snap_get_description_safe (snap); - if (description != NULL) - gs_app_set_description (app, GS_APP_QUALITY_NORMAL, description); - gs_app_set_license (app, GS_APP_QUALITY_NORMAL, snapd_snap_get_license (snap)); - developer_name = snapd_snap_get_publisher_display_name (snap); - if (developer_name == NULL) - developer_name = snapd_snap_get_publisher_username (snap); - gs_app_set_developer_name (app, developer_name); - if (snapd_snap_get_publisher_validation (snap) == SNAPD_PUBLISHER_VALIDATION_VERIFIED) - gs_app_add_quirk (app, GS_APP_QUIRK_DEVELOPER_VERIFIED); - - snap = local_snap != NULL ? local_snap : store_snap; - gs_app_set_version (app, snapd_snap_get_version (snap)); - - switch (snapd_snap_get_snap_type (snap)) { - case SNAPD_SNAP_TYPE_APP: - gs_app_set_kind (app, AS_APP_KIND_DESKTOP); - break; - case SNAPD_SNAP_TYPE_KERNEL: - case SNAPD_SNAP_TYPE_GADGET: - case SNAPD_SNAP_TYPE_OS: - gs_app_set_kind (app, AS_APP_KIND_RUNTIME); - break; - default: - case SNAPD_SNAP_TYPE_UNKNOWN: - gs_app_set_kind (app, AS_APP_KIND_UNKNOWN); - break; - } - - /* add information specific to installed snaps */ - if (local_snap != NULL) { - SnapdApp *snap_app; - GDateTime *install_date; - - install_date = snapd_snap_get_install_date (local_snap); - gs_app_set_size_installed (app, snapd_snap_get_installed_size (local_snap)); - gs_app_set_install_date (app, install_date != NULL ? g_date_time_to_unix (install_date) : GS_APP_INSTALL_DATE_UNKNOWN); - - snap_app = get_primary_app (local_snap); - if (snap_app != NULL) { - gs_app_set_metadata (app, "snap::launch-name", snapd_app_get_name (snap_app)); - gs_app_set_metadata (app, "snap::launch-desktop", snapd_app_get_desktop_file (snap_app)); - } else { - gs_app_add_quirk (app, GS_APP_QUIRK_NOT_LAUNCHABLE); - } - } - - /* add information specific to store snaps */ - if (store_snap != NULL) { - gs_app_set_origin (app, priv->store_name); - gs_app_set_size_download (app, snapd_snap_get_download_size (store_snap)); - - if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS && gs_app_get_screenshots (app)->len == 0) - refine_screenshots (app, store_snap); - } - - /* load icon if requested */ - if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON && gs_app_get_pixbuf (app) == NULL) - load_icon (plugin, client, app, gs_app_get_metadata_item (app, "snap::name"), local_snap, store_snap, cancellable); - - return TRUE; -} - -static void -progress_cb (SnapdClient *client, SnapdChange *change, gpointer deprecated, gpointer user_data) -{ - GsApp *app = user_data; - GPtrArray *tasks; - guint i; - gint64 done = 0, total = 0; - - tasks = snapd_change_get_tasks (change); - for (i = 0; i < tasks->len; i++) { - SnapdTask *task = tasks->pdata[i]; - done += snapd_task_get_progress_done (task); - total += snapd_task_get_progress_total (task); - } - - gs_app_set_progress (app, (guint) (100 * done / total)); -} - -gboolean -gs_plugin_app_install (GsPlugin *plugin, - GsApp *app, - GCancellable *cancellable, - GError **error) -{ - g_autoptr(SnapdClient) client = NULL; - SnapdInstallFlags flags = SNAPD_INSTALL_FLAGS_NONE; - - /* We can only install apps we know of */ - if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0) - return TRUE; - - client = get_client (plugin, error); - if (client == NULL) - return FALSE; - - gs_app_set_state (app, AS_APP_STATE_INSTALLING); - if (g_strcmp0 (gs_app_get_metadata_item (app, "snap::confinement"), "classic") == 0) - flags |= SNAPD_INSTALL_FLAGS_CLASSIC; - if (!snapd_client_install2_sync (client, flags, gs_app_get_metadata_item (app, "snap::name"), NULL, NULL, progress_cb, app, cancellable, error)) { - gs_app_set_state_recover (app); - snapd_error_convert (error); - return FALSE; - } - gs_app_set_state (app, AS_APP_STATE_INSTALLED); - return TRUE; -} - -// Check if an app is graphical by checking if it uses a known GUI interface. -// This doesn't necessarily mean that every binary uses this interfaces, but is probably true. -// https://bugs.launchpad.net/bugs/1595023 -static gboolean -is_graphical (GsPlugin *plugin, GsApp *app, GCancellable *cancellable) -{ - g_autoptr(SnapdClient) client = NULL; - g_autoptr(GPtrArray) plugs = NULL; - guint i; - g_autoptr(GError) error = NULL; - - client = get_client (plugin, &error); - if (client == NULL) - return FALSE; - - if (!snapd_client_get_connections_sync (client, NULL, NULL, &plugs, NULL, cancellable, &error)) { - g_warning ("Failed to get connections: %s", error->message); - return FALSE; - } - - for (i = 0; i < plugs->len; i++) { - SnapdPlug *plug = plugs->pdata[i]; - const gchar *interface; - - // Only looks at the plugs for this snap - if (g_strcmp0 (snapd_plug_get_snap (plug), gs_app_get_metadata_item (app, "snap::name")) != 0) - continue; - - interface = snapd_plug_get_interface (plug); - if (interface == NULL) - continue; - - if (g_strcmp0 (interface, "unity7") == 0 || g_strcmp0 (interface, "x11") == 0 || g_strcmp0 (interface, "mir") == 0) - return TRUE; - } - - return FALSE; -} - -gboolean -gs_plugin_launch (GsPlugin *plugin, - GsApp *app, - GCancellable *cancellable, - GError **error) -{ - const gchar *launch_name; - const gchar *launch_desktop; - g_autoptr(GAppInfo) info = NULL; - - /* We can only launch apps we know of */ - if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0) - return TRUE; - - launch_name = gs_app_get_metadata_item (app, "snap::launch-name"); - launch_desktop = gs_app_get_metadata_item (app, "snap::launch-desktop"); - if (!launch_name) - return TRUE; - - if (launch_desktop) { - info = (GAppInfo *)g_desktop_app_info_new_from_filename (launch_desktop); - } else { - g_autofree gchar *commandline = NULL; - GAppInfoCreateFlags flags = G_APP_INFO_CREATE_NONE; - - if (g_strcmp0 (launch_name, gs_app_get_metadata_item (app, "snap::name")) == 0) - commandline = g_strdup_printf ("snap run %s", launch_name); - else - commandline = g_strdup_printf ("snap run %s.%s", gs_app_get_metadata_item (app, "snap::name"), launch_name); - - if (!is_graphical (plugin, app, cancellable)) - flags |= G_APP_INFO_CREATE_NEEDS_TERMINAL; - info = g_app_info_create_from_commandline (commandline, NULL, flags, error); - } - - if (info == NULL) - return FALSE; - - return g_app_info_launch (info, NULL, NULL, error); -} - -gboolean -gs_plugin_app_remove (GsPlugin *plugin, - GsApp *app, - GCancellable *cancellable, - GError **error) -{ - g_autoptr(SnapdClient) client = NULL; - - /* We can only remove apps we know of */ - if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0) - return TRUE; - - client = get_client (plugin, error); - if (client == NULL) - return FALSE; - - gs_app_set_state (app, AS_APP_STATE_REMOVING); - if (!snapd_client_remove_sync (client, gs_app_get_metadata_item (app, "snap::name"), progress_cb, app, cancellable, error)) { - gs_app_set_state_recover (app); - snapd_error_convert (error); - return FALSE; - } - gs_app_set_state (app, AS_APP_STATE_AVAILABLE); - return TRUE; -} diff --git a/plugins/snap/gs-self-test.c b/plugins/snap/gs-self-test.c deleted file mode 100644 index 75277ad7aa2d069ae6a9d9c4b6a8a91b4822923a..0000000000000000000000000000000000000000 --- a/plugins/snap/gs-self-test.c +++ /dev/null @@ -1,329 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2017 Canonical Ltd - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include - -#include "config.h" - -#include "gnome-software-private.h" - -#include "gs-test.h" - -static gboolean snap_installed = FALSE; - -SnapdAuthData * -snapd_login_sync (const gchar *username, const gchar *password, const gchar *otp, - GCancellable *cancellable, GError **error) -{ - return snapd_auth_data_new ("macaroon", NULL); -} - -SnapdClient * -snapd_client_new (void) -{ - /* use a dummy object - we intercept all snapd-glib calls */ - return g_object_new (G_TYPE_OBJECT, NULL); -} - -void -snapd_client_set_allow_interaction (SnapdClient *client, gboolean allow_interaction) -{ -} - -void -snapd_client_set_auth_data (SnapdClient *client, SnapdAuthData *auth_data) -{ -} - -gboolean -snapd_client_connect_sync (SnapdClient *client, GCancellable *cancellable, GError **error) -{ - /* skip connection */ - return TRUE; -} - -const gchar * -snapd_client_get_user_agent (SnapdClient *client) -{ - return "snapd-glib/0.0.1"; -} - -void -snapd_client_set_user_agent (SnapdClient *client, const gchar *user_agent) -{ -} - -SnapdSystemInformation * -snapd_client_get_system_information_sync (SnapdClient *client, GCancellable *cancellable, GError **error) -{ - g_autoptr(GHashTable) sandbox_features = g_hash_table_new (g_str_hash, g_str_equal); - return g_object_new (SNAPD_TYPE_SYSTEM_INFORMATION, - "version", "2.31", - "confinement", SNAPD_SYSTEM_CONFINEMENT_STRICT, - "sandbox-features", sandbox_features, - NULL); -} - -static SnapdSnap * -make_snap (const gchar *name, SnapdSnapStatus status) -{ - gchar *common_ids[] = { NULL }; - g_autoptr(GDateTime) install_date = NULL; - g_autoptr(GPtrArray) apps = NULL; - g_autoptr(GPtrArray) screenshots = NULL; - SnapdScreenshot *screenshot; - - install_date = g_date_time_new_utc (2017, 1, 2, 11, 23, 58); - - apps = g_ptr_array_new_with_free_func (g_object_unref); - - screenshots = g_ptr_array_new_with_free_func (g_object_unref); - screenshot = g_object_new (SNAPD_TYPE_SCREENSHOT, - "url", "http://example.com/screenshot1.jpg", - "width", 640, - "height", 480, - NULL); - g_ptr_array_add (screenshots, screenshot); - screenshot = g_object_new (SNAPD_TYPE_SCREENSHOT, - "url", "http://example.com/screenshot2.jpg", - "width", 1024, - "height", 768, - NULL); - g_ptr_array_add (screenshots, screenshot); - - return g_object_new (SNAPD_TYPE_SNAP, - "apps", status == SNAPD_SNAP_STATUS_INSTALLED ? apps : NULL, - "common-ids", common_ids, - "description", "DESCRIPTION", - "download-size", status == SNAPD_SNAP_STATUS_AVAILABLE ? 500 : 0, - "icon", "/icon", - "id", name, - "install-date", status == SNAPD_SNAP_STATUS_INSTALLED ? install_date : NULL, - "installed-size", status == SNAPD_SNAP_STATUS_INSTALLED ? 1000 : 0, - "name", name, - "screenshots", status == SNAPD_SNAP_STATUS_AVAILABLE ? screenshots : NULL, - "status", status, - "snap-type", SNAPD_SNAP_TYPE_APP, - "summary", "SUMMARY", - "version", "VERSION", - NULL); -} - -GPtrArray * -snapd_client_get_snaps_sync (SnapdClient *client, - SnapdGetSnapsFlags flags, gchar **names, - GCancellable *cancellable, GError **error) -{ - GPtrArray *snaps; - - snaps = g_ptr_array_new_with_free_func (g_object_unref); - if (snap_installed) - g_ptr_array_add (snaps, make_snap ("snap", SNAPD_SNAP_STATUS_INSTALLED)); - - return snaps; -} - -SnapdSnap * -snapd_client_get_snap_sync (SnapdClient *client, - const gchar *name, - GCancellable *cancellable, GError **error) -{ - if (snap_installed) { - return make_snap ("snap", SNAPD_SNAP_STATUS_INSTALLED); - } else { - g_set_error_literal (error, SNAPD_ERROR, SNAPD_ERROR_NOT_INSTALLED, "not installed"); - return NULL; - } -} - -SnapdIcon * -snapd_client_get_icon_sync (SnapdClient *client, - const gchar *name, - GCancellable *cancellable, GError **error) -{ - g_autoptr(GBytes) data = NULL; - /* apparently this is the smallest valid PNG file (1x1) */ - const gchar png_data[67] = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, - 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, 0xC4, - 0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44, 0x41, - 0x54, 0x78, 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00, - 0x05, 0x00, 0x01, 0x0D, 0x0A, 0x2D, 0xB4, 0x00, - 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, - 0x42, 0x60, 0x82 }; - - data = g_bytes_new (png_data, 67); - return g_object_new (SNAPD_TYPE_ICON, - "mime-type", "image/png", - "data", data, - NULL); -} - -gboolean -snapd_client_get_interfaces_sync (SnapdClient *client, - GPtrArray **plugs, GPtrArray **slots, - GCancellable *cancellable, GError **error) -{ - if (plugs) - *plugs = g_ptr_array_new_with_free_func (g_object_unref); - if (slots) - *slots = g_ptr_array_new_with_free_func (g_object_unref); - return TRUE; -} - -GPtrArray * -snapd_client_find_section_sync (SnapdClient *client, - SnapdFindFlags flags, - const gchar *section, const gchar *query, - gchar **suggested_currency, - GCancellable *cancellable, GError **error) -{ - GPtrArray *snaps; - - snaps = g_ptr_array_new_with_free_func (g_object_unref); - g_ptr_array_add (snaps, make_snap ("snap", SNAPD_SNAP_STATUS_AVAILABLE)); - - return snaps; -} - -gboolean -snapd_client_install2_sync (SnapdClient *client, - SnapdInstallFlags flags, - const gchar *name, const gchar *channel, const gchar *revision, - SnapdProgressCallback progress_callback, gpointer progress_callback_data, - GCancellable *cancellable, GError **error) -{ - g_assert_cmpstr (name, ==, "snap"); - g_assert (channel == NULL); - snap_installed = TRUE; - return TRUE; -} - -gboolean -snapd_client_remove_sync (SnapdClient *client, - const gchar *name, - SnapdProgressCallback progress_callback, gpointer progress_callback_data, - GCancellable *cancellable, GError **error) -{ - g_assert_cmpstr (name, ==, "snap"); - return TRUE; -} - -static void -gs_plugins_snap_test_func (GsPluginLoader *plugin_loader) -{ - g_autoptr(GsPluginJob) plugin_job = NULL; - g_autoptr(GsAppList) apps = NULL; - gboolean ret; - GsApp *app; - GPtrArray *screenshots, *images; - AsScreenshot *screenshot; - AsImage *image; - GdkPixbuf *pixbuf; - g_autoptr(GError) error = NULL; - - /* no snap, abort */ - if (!gs_plugin_loader_get_enabled (plugin_loader, "snap")) { - g_test_skip ("not enabled"); - return; - } - - plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_SEARCH, - "search", "snap", - "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON, - NULL); - apps = gs_plugin_loader_job_process (plugin_loader, plugin_job, NULL, &error); - g_assert_no_error (error); - g_assert (apps != NULL); - g_assert_cmpint (gs_app_list_length (apps), ==, 1); - app = gs_app_list_index (apps, 0); - g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_AVAILABLE); - g_assert_cmpstr (gs_app_get_name (app), ==, "snap"); - g_assert_cmpstr (gs_app_get_version (app), ==, "VERSION"); - g_assert_cmpstr (gs_app_get_summary (app), ==, "SUMMARY"); - g_assert_cmpstr (gs_app_get_description (app), ==, "DESCRIPTION"); - screenshots = gs_app_get_screenshots (app); - g_assert_cmpint (screenshots->len, ==, 2); - screenshot = g_ptr_array_index (screenshots, 0); - images = as_screenshot_get_images (screenshot); - g_assert_cmpint (images->len, ==, 1); - image = g_ptr_array_index (images, 0); - g_assert_cmpstr (as_image_get_url (image), ==, "http://example.com/screenshot1.jpg"); - g_assert_cmpint (as_image_get_width (image), ==, 640); - g_assert_cmpint (as_image_get_height (image), ==, 480); - screenshot = g_ptr_array_index (screenshots, 1); - images = as_screenshot_get_images (screenshot); - g_assert_cmpint (images->len, ==, 1); - image = g_ptr_array_index (images, 0); - g_assert_cmpstr (as_image_get_url (image), ==, "http://example.com/screenshot2.jpg"); - g_assert_cmpint (as_image_get_width (image), ==, 1024); - g_assert_cmpint (as_image_get_height (image), ==, 768); - pixbuf = gs_app_get_pixbuf (app); - g_assert_cmpint (gdk_pixbuf_get_width (pixbuf), ==, 1); - g_assert_cmpint (gdk_pixbuf_get_height (pixbuf), ==, 1); - g_assert_cmpint (gs_app_get_size_installed (app), ==, 0); - g_assert_cmpint (gs_app_get_size_download (app), ==, 500); - g_assert_cmpint (gs_app_get_install_date (app), ==, 0); - - g_object_unref (plugin_job); - plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_INSTALL, - "app", app, - NULL); - ret = gs_plugin_loader_job_action (plugin_loader, plugin_job, NULL, &error); - gs_test_flush_main_context (); - g_assert_no_error (error); - g_assert (ret); - g_assert_cmpint (gs_app_get_state (app), ==, AS_APP_STATE_INSTALLED); - g_assert_cmpint (gs_app_get_size_installed (app), ==, 1000); - g_assert_cmpint (gs_app_get_install_date (app), ==, g_date_time_to_unix (g_date_time_new_utc (2017, 1, 2, 11, 23, 58))); - - g_object_unref (plugin_job); - plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REMOVE, - "app", app, - NULL); - gs_test_flush_main_context (); - ret = gs_plugin_loader_job_action (plugin_loader, plugin_job, NULL, &error); - g_assert_no_error (error); - g_assert (ret); -} - -int -main (int argc, char **argv) -{ - gboolean ret; - g_autoptr(GError) error = NULL; - g_autoptr(GsPluginLoader) plugin_loader = NULL; - const gchar *whitelist[] = { - "snap", - NULL - }; - - g_test_init (&argc, &argv, NULL); - g_setenv ("G_MESSAGES_DEBUG", "all", TRUE); - - /* only critical and error are fatal */ - g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL); - - /* we can only load this once per process */ - plugin_loader = gs_plugin_loader_new (); - gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR); - gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR_CORE); - ret = gs_plugin_loader_setup (plugin_loader, - (gchar**) whitelist, - NULL, - NULL, - &error); - g_assert_no_error (error); - g_assert (ret); - - /* plugin tests go here */ - g_test_add_data_func ("/gnome-software/plugins/snap/test", - plugin_loader, - (GTestDataFunc) gs_plugins_snap_test_func); - return g_test_run (); -} diff --git a/plugins/snap/meson.build b/plugins/snap/meson.build deleted file mode 100644 index ccaff96c11bcb76815098d5a513390ee4c2ae5db..0000000000000000000000000000000000000000 --- a/plugins/snap/meson.build +++ /dev/null @@ -1,54 +0,0 @@ -cargs = ['-DG_LOG_DOMAIN="GsPluginSnap"'] - -shared_module( - 'gs_plugin_snap', - sources : [ - 'gs-plugin-snap.c' - ], - include_directories : [ - include_directories('../..'), - include_directories('../../lib'), - ], - install : true, - install_dir: plugin_dir, - c_args : cargs, - dependencies : [ plugin_libs, snap ], - link_with : [ - libgnomesoftware - ] -) -metainfo = 'org.gnome.Software.Plugin.Snap.metainfo.xml' - -i18n.merge_file( - input: metainfo + '.in', - output: metainfo, - type: 'xml', - po_dir: join_paths(meson.source_root(), 'po'), - install: true, - install_dir: join_paths(get_option('datadir'), 'metainfo') -) - -if get_option('tests') - cargs += ['-DLOCALPLUGINDIR="' + meson.current_build_dir() + '"'] - cargs += ['-DLOCALPLUGINDIR_CORE="' + meson.current_build_dir() + '/../core"'] - e = executable( - 'gs-self-test-snap', - compiled_schemas, - sources : [ - 'gs-self-test.c' - ], - include_directories : [ - include_directories('../..'), - include_directories('../../lib'), - ], - dependencies : [ - plugin_libs, - snap - ], - link_with : [ - libgnomesoftware - ], - c_args : cargs, - ) - test('gs-self-test-snap', e, env: test_env) -endif diff --git a/plugins/snap/org.gnome.Software.Plugin.Snap.metainfo.xml.in b/plugins/snap/org.gnome.Software.Plugin.Snap.metainfo.xml.in deleted file mode 100644 index 24787788ea78c528f3c69be52909f2c314639f03..0000000000000000000000000000000000000000 --- a/plugins/snap/org.gnome.Software.Plugin.Snap.metainfo.xml.in +++ /dev/null @@ -1,12 +0,0 @@ - - - - org.gnome.Software.Plugin.Snap - org.gnome.Software.desktop - Snap Support - A snap is a universal Linux package - https://snapcraft.io/ - CC0-1.0 - GPL-2.0+ - richard_at_hughsie.com - diff --git a/po/POTFILES.in b/po/POTFILES.in index cf7dafed0eba88a024941e92a85d55f98f655521..bebf68fe5928a41b4a16e48bb779948ae639d364 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -12,8 +12,6 @@ src/gs-app-row.c src/gs-app-row.ui src/gs-app-tile.c src/gs-app-tile.ui -src/gs-auth-dialog.c -src/gs-auth-dialog.ui lib/gs-category.c src/gs-category-page.c src/gs-category-page.ui @@ -47,7 +45,6 @@ lib/gs-plugin-loader.c src/gs-popular-tile.c src/gs-popular-tile.ui src/gs-prefs-dialog.ui -lib/gs-price.c src/gs-removal-dialog.c src/gs-removal-dialog.ui src/gs-repos-dialog.c @@ -94,5 +91,3 @@ plugins/fwupd/org.gnome.Software.Plugin.Fwupd.metainfo.xml.in plugins/odrs/gs-plugin-odrs.c plugins/odrs/org.gnome.Software.Plugin.Odrs.metainfo.xml.in plugins/shell-extensions/gs-plugin-shell-extensions.c -plugins/snap/gs-plugin-snap.c -plugins/snap/org.gnome.Software.Plugin.Snap.metainfo.xml.in diff --git a/src/gnome-software-local-file.desktop.in b/src/gnome-software-local-file.desktop.in index 1126b7b709a44270c6205be9b1c28c7672f2b9fc..7179aeec964305c800d9cfb1868873cb94e8bb23 100644 --- a/src/gnome-software-local-file.desktop.in +++ b/src/gnome-software-local-file.desktop.in @@ -9,4 +9,4 @@ Type=Application Icon=system-software-install StartupNotify=true NoDisplay=true -MimeType=application/x-rpm;application/x-redhat-package-manager;application/x-deb;application/x-app-package;application/vnd.ms-cab-compressed;application/vnd.flatpak;application/vnd.flatpak.repo;application/vnd.flatpak.ref;application/vnd.snap; +MimeType=application/x-rpm;application/x-redhat-package-manager;application/x-deb;application/x-app-package;application/vnd.ms-cab-compressed;application/vnd.flatpak;application/vnd.flatpak.repo;application/vnd.flatpak.ref; diff --git a/src/gnome-software.gresource.xml b/src/gnome-software.gresource.xml index a8efa6a99a468304faea58ac8e27594becb9d430..2a523021b757f9041e8cb42b237e571a114d639d 100644 --- a/src/gnome-software.gresource.xml +++ b/src/gnome-software.gresource.xml @@ -5,7 +5,6 @@ gs-app-addon-row.ui gs-app-folder-dialog.ui gs-app-row.ui - gs-auth-dialog.ui gs-category-page.ui gs-category-tile.ui gs-details-page.ui diff --git a/src/gs-auth-dialog.c b/src/gs-auth-dialog.c deleted file mode 100644 index d1a8a08d99019e563688a86948ce8c2da4e4ed21..0000000000000000000000000000000000000000 --- a/src/gs-auth-dialog.c +++ /dev/null @@ -1,475 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2016 Richard Hughes - * Copyright (C) 2017 Kalev Lember - * Copyright (C) 2018 Canonical Ltd - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#include "config.h" - -#include -#define GOA_API_IS_SUBJECT_TO_CHANGE -#include - -#include "gs-auth-dialog.h" -#include "gs-common.h" - -struct _GsAuthDialog -{ - GtkDialog parent_instance; - - GoaClient *goa_client; - GtkListStore *liststore_account; - - GtkWidget *label_header; - GtkWidget *combobox_account; - GtkWidget *label_account; - GtkWidget *button_add_another; - GtkWidget *button_cancel; - GtkWidget *button_continue; - - gboolean dispose_on_new_account; - - GCancellable *cancellable; - GsPluginLoader *plugin_loader; - GsApp *app; - GsAuth *auth; -}; - -static void gs_auth_dialog_initable_iface_init (GInitableIface *iface); - -G_DEFINE_TYPE_WITH_CODE (GsAuthDialog, gs_auth_dialog, GTK_TYPE_DIALOG, - G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, gs_auth_dialog_initable_iface_init)) - -enum { - COLUMN_ID, - COLUMN_EMAIL, - COLUMN_ACCOUNT, - N_COLUMNS -}; - -static gboolean -gs_auth_dialog_ignore_account (GsAuthDialog *self, GoaAccount *account) -{ - return g_strcmp0 (goa_account_get_provider_type (account), - gs_auth_get_provider_type (self->auth)) != 0; -} - -static void -gs_auth_dialog_set_header (GsAuthDialog *self, - const gchar *text) -{ - g_autofree gchar *markup = NULL; - markup = g_strdup_printf ("%s", text); - gtk_label_set_markup (GTK_LABEL (self->label_header), markup); -} - -static gint -gs_auth_dialog_get_naccounts (GsAuthDialog *self) -{ - return gtk_tree_model_iter_n_children (GTK_TREE_MODEL (self->liststore_account), NULL); -} - -static gboolean -gs_auth_dialog_get_nth_account_data (GsAuthDialog *self, - gint n, - ...) -{ - GtkTreeIter iter; - va_list var_args; - - if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (self->liststore_account), &iter, NULL, n)) - return FALSE; - - va_start (var_args, n); - gtk_tree_model_get_valist (GTK_TREE_MODEL (self->liststore_account), &iter, var_args); - va_end (var_args); - - return TRUE; -} - -static gboolean -gs_auth_dialog_get_account_iter (GsAuthDialog *self, - GoaAccount *account, - GtkTreeIter *iter) -{ - gboolean valid; - - valid = gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (self->liststore_account), iter, NULL, 0); - - while (valid) { - g_autofree gchar *id; - gtk_tree_model_get (GTK_TREE_MODEL (self->liststore_account), iter, COLUMN_ID, &id, -1); - if (g_strcmp0 (id, goa_account_get_id (account)) == 0) - return TRUE; - else - valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (self->liststore_account), iter); - } - - return FALSE; -} - - -static void -gs_auth_dialog_check_ui (GsAuthDialog *self, - gboolean select) -{ - gint naccounts = gs_auth_dialog_get_naccounts (self); - - gs_auth_dialog_set_header (self, gs_auth_get_header (self->auth, naccounts)); - - if (naccounts == 0) { - gtk_widget_set_visible (self->combobox_account, FALSE); - gtk_widget_set_visible (self->label_account, FALSE); - gtk_widget_set_visible (self->button_add_another, FALSE); - gtk_button_set_label (GTK_BUTTON (self->button_continue), _("Sign In / Register…")); - } else if (naccounts == 1) { - g_autofree gchar *email = NULL; - - gtk_widget_set_visible (self->combobox_account, FALSE); - gtk_widget_set_visible (self->label_account, TRUE); - gtk_widget_set_visible (self->button_add_another, TRUE); - gtk_button_set_label (GTK_BUTTON (self->button_continue), _("Continue")); - gs_auth_dialog_get_nth_account_data (self, 0, COLUMN_EMAIL, &email, -1); - gtk_label_set_text (GTK_LABEL (self->label_account), email); - } else { - gtk_widget_set_visible (self->combobox_account, TRUE); - gtk_widget_set_visible (self->label_account, FALSE); - gtk_widget_set_visible (self->button_add_another, TRUE); - gtk_button_set_label (GTK_BUTTON (self->button_continue), _("Use")); - - if (select) - gtk_combo_box_set_active (GTK_COMBO_BOX (self->combobox_account), naccounts - 1); - else if (gtk_combo_box_get_active (GTK_COMBO_BOX (self->combobox_account)) == -1) - gtk_combo_box_set_active (GTK_COMBO_BOX (self->combobox_account), 0); - } -} - -static void -gs_auth_dialog_add_account (GsAuthDialog *self, - GoaAccount *account, - gboolean select) -{ - GtkTreeIter iter; - - if (gs_auth_dialog_ignore_account (self, account) || - gs_auth_dialog_get_account_iter (self, account, &iter)) - return; - - gtk_list_store_append (self->liststore_account, &iter); - gtk_list_store_set (self->liststore_account, &iter, - COLUMN_ID, goa_account_get_id (account), - COLUMN_EMAIL, goa_account_get_presentation_identity (account), - COLUMN_ACCOUNT, account, - -1); - - gs_auth_dialog_check_ui (self, select); -} - -static void -gs_auth_dialog_remove_account (GsAuthDialog *self, - GoaAccount *account) -{ - GtkTreeIter iter; - - if (gs_auth_dialog_ignore_account (self, account) || - !gs_auth_dialog_get_account_iter (self, account, &iter)) - return; - - - gtk_list_store_remove (self->liststore_account, &iter); - gs_auth_dialog_check_ui (self, FALSE); -} - -static void -gs_auth_dialog_setup_model (GsAuthDialog *self) -{ - g_autoptr(GList) accounts = goa_client_get_accounts (self->goa_client); - - for (GList *l = accounts; l != NULL; l = l->next) { - gs_auth_dialog_add_account (self, goa_object_peek_account (l->data), FALSE); - g_object_unref (l->data); - } -} - -static GVariant* -gs_auth_dialog_build_dbus_parameters (const gchar *action, - const gchar *arg) -{ - GVariantBuilder builder; - GVariant *array[1], *params2[3]; - - g_variant_builder_init (&builder, G_VARIANT_TYPE ("av")); - - if (!action && !arg) { - g_variant_builder_add (&builder, "v", g_variant_new_string ("")); - } else { - if (action) - g_variant_builder_add (&builder, "v", g_variant_new_string (action)); - - if (arg) - g_variant_builder_add (&builder, "v", g_variant_new_string (arg)); - } - - array[0] = g_variant_new ("v", g_variant_new ("(sav)", "online-accounts", &builder)); - - params2[0] = g_variant_new_string ("launch-panel"); - params2[1] = g_variant_new_array (G_VARIANT_TYPE ("v"), array, 1); - params2[2] = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0); - - return g_variant_new_tuple (params2, 3); -} - -static void -gs_auth_dialog_spawn_goa_with_args (const gchar *action, - const gchar *arg) -{ - g_autoptr(GDBusProxy) proxy = NULL; - - proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - "org.gnome.ControlCenter", - "/org/gnome/ControlCenter", - "org.gtk.Actions", - NULL, - NULL); - - if (!proxy) - { - g_warning ("Couldn't open Online Accounts panel"); - return; - } - - g_dbus_proxy_call_sync (proxy, - "Activate", - gs_auth_dialog_build_dbus_parameters (action, arg), - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - NULL); -} - -static void -gs_auth_dialog_ensure_crendentials_cb (GObject *source_object, - GAsyncResult *res, - gpointer user_data) -{ - GsAuthDialog *self = (GsAuthDialog*) user_data; - GoaAccount *account = GOA_ACCOUNT (source_object); - g_autoptr(GError) error = NULL; - - if (!goa_account_call_ensure_credentials_finish (account, NULL, res, &error)) { - gs_auth_dialog_spawn_goa_with_args (goa_account_get_id (account), NULL); - } else { - GoaObject *goa_object; - - goa_object = goa_client_lookup_by_id (self->goa_client, - goa_account_get_id (account)); - - gs_auth_set_goa_object (self->auth, goa_object); - gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_OK); - } -} - -static void -gs_auth_dialog_response_if_valid (GsAuthDialog *self, - GoaAccount *account) -{ - goa_account_call_ensure_credentials (account, - self->cancellable, - gs_auth_dialog_ensure_crendentials_cb, - self); -} - -static void -gs_auth_dialog_account_added_cb (GoaClient *client, - GoaObject *object, - GsAuthDialog *self) -{ - GoaAccount *account = goa_object_peek_account (object); - - if (gs_auth_dialog_ignore_account (self, account)) - return; - - if (!self->dispose_on_new_account) - gs_auth_dialog_add_account (self, account, FALSE); - else - gs_auth_dialog_response_if_valid (self, account); -} - -static void -gs_auth_dialog_account_removed_cb (GoaClient *client, - GoaObject *object, - GsAuthDialog *self) -{ - GoaAccount *account = goa_object_peek_account (object); - gs_auth_dialog_remove_account (self, account); -} - -static void -gs_auth_dialog_button_add_another_cb (GtkButton *button, - GsAuthDialog *self) -{ - gs_auth_dialog_spawn_goa_with_args ("add", gs_auth_get_provider_type (self->auth)); - self->dispose_on_new_account = TRUE; -} - -static void -gs_auth_dialog_button_cancel_cb (GtkButton *button, - GsAuthDialog *self) -{ - gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_CANCEL); -} - -static void -gs_auth_dialog_button_continue_cb (GtkButton *button, - GsAuthDialog *self) -{ - GoaAccount *account = NULL; - gint naccounts = gs_auth_dialog_get_naccounts (self); - - if (naccounts == 1) { - gs_auth_dialog_get_nth_account_data (self, 0, COLUMN_ACCOUNT, &account, -1); - } else { - gint active = gtk_combo_box_get_active (GTK_COMBO_BOX (self->combobox_account)); - gs_auth_dialog_get_nth_account_data (self, active, COLUMN_ACCOUNT, &account, -1); - } - - if (account == NULL) - gs_auth_dialog_button_add_another_cb (GTK_BUTTON (self->button_add_another), self); - else - gs_auth_dialog_response_if_valid (self, account); - - g_clear_object (&account); -} - -/* GObject */ - -static void -gs_auth_dialog_dispose (GObject *object) -{ - GsAuthDialog *self = GS_AUTH_DIALOG (object); - - g_clear_object (&self->goa_client); - - g_cancellable_cancel (self->cancellable); - g_clear_object (&self->cancellable); - - G_OBJECT_CLASS (gs_auth_dialog_parent_class)->dispose (object); -} - -static void -gs_auth_dialog_class_init (GsAuthDialogClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->dispose = gs_auth_dialog_dispose; - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-auth-dialog.ui"); - - gtk_widget_class_bind_template_child (widget_class, GsAuthDialog, label_header); - gtk_widget_class_bind_template_child (widget_class, GsAuthDialog, combobox_account); - gtk_widget_class_bind_template_child (widget_class, GsAuthDialog, label_account); - gtk_widget_class_bind_template_child (widget_class, GsAuthDialog, button_add_another); - gtk_widget_class_bind_template_child (widget_class, GsAuthDialog, button_cancel); - gtk_widget_class_bind_template_child (widget_class, GsAuthDialog, button_continue); - gtk_widget_class_bind_template_child (widget_class, GsAuthDialog, liststore_account); - - - gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), gs_auth_dialog_button_add_another_cb); - gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), gs_auth_dialog_button_cancel_cb); - gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), gs_auth_dialog_button_continue_cb); -} - -static void -gs_auth_dialog_init (GsAuthDialog *self) -{ - self->cancellable = g_cancellable_new (); - - gtk_widget_init_template (GTK_WIDGET (self)); - gtk_widget_grab_focus (self->button_continue); -} - -/* GInitable */ - -static gboolean -gs_auth_dialog_initable_init (GInitable *initable, - GCancellable *cancellable, - GError **error) -{ - GsAuthDialog *self; - - g_return_val_if_fail (GS_IS_AUTH_DIALOG (initable), FALSE); - - self = GS_AUTH_DIALOG (initable); - - self->goa_client = goa_client_new_sync (NULL, error); - if (!self->goa_client) - return FALSE; - - /* Be ready to other accounts */ - g_signal_connect (self->goa_client, "account-added", G_CALLBACK (gs_auth_dialog_account_added_cb), self); - g_signal_connect (self->goa_client, "account-removed", G_CALLBACK (gs_auth_dialog_account_removed_cb), self); - - return TRUE; -} - -static void -gs_auth_dialog_initable_iface_init (GInitableIface *iface) -{ - iface->init = gs_auth_dialog_initable_init; -} - -/* Public API */ - -GtkWidget * -gs_auth_dialog_new (GsPluginLoader *plugin_loader, - GsApp *app, - const gchar *auth_id, - GError **error) -{ - GsAuthDialog *dialog; - GsAuth *auth; - - /* get the authentication provider */ - if (auth_id == NULL) { - g_set_error (error, - GS_PLUGIN_ERROR, - GS_PLUGIN_ERROR_FAILED, - "no auth-provider given for %s", - app != NULL ? gs_app_get_id (app) : NULL); - return NULL; - } - auth = gs_plugin_loader_get_auth_by_id (plugin_loader, auth_id); - if (auth == NULL) { - g_set_error (error, - GS_PLUGIN_ERROR, - GS_PLUGIN_ERROR_NOT_SUPPORTED, - "no auth-provider %s for %s", - auth_id, - app != NULL ? gs_app_get_id (app) : NULL); - return NULL; - } - - /* create dialog */ - dialog = g_initable_new (GS_TYPE_AUTH_DIALOG, - NULL, error, - "use-header-bar", FALSE, - NULL); - - if (dialog == NULL) - return NULL; - - dialog->plugin_loader = g_object_ref (plugin_loader); - dialog->app = app != NULL ? g_object_ref (app) : NULL; - dialog->auth = g_object_ref (auth); - - gs_auth_dialog_setup_model (dialog); - gs_auth_dialog_check_ui (dialog, FALSE); - - return GTK_WIDGET (dialog); -} diff --git a/src/gs-auth-dialog.h b/src/gs-auth-dialog.h deleted file mode 100644 index a8ed4ff769d1473909c076ea9326579f5a63b13b..0000000000000000000000000000000000000000 --- a/src/gs-auth-dialog.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2016 Richard Hughes - * - * SPDX-License-Identifier: GPL-2.0+ - */ - -#pragma once - -#include - -#include "gnome-software-private.h" - -G_BEGIN_DECLS - -#define GS_TYPE_AUTH_DIALOG (gs_auth_dialog_get_type ()) - -G_DECLARE_FINAL_TYPE (GsAuthDialog, gs_auth_dialog, GS, AUTH_DIALOG, GtkDialog) - -GtkWidget *gs_auth_dialog_new (GsPluginLoader *plugin_loader, - GsApp *app, - const gchar *auth_id, - GError **error); - -G_END_DECLS diff --git a/src/gs-auth-dialog.ui b/src/gs-auth-dialog.ui deleted file mode 100644 index 77c49492e8b3b02540dbcfd8154a520410e02932..0000000000000000000000000000000000000000 --- a/src/gs-auth-dialog.ui +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/src/gs-common.c b/src/gs-common.c index 703e813682ab22f3c555b2fc460804303075cb92..6561c7cfff2ebbdf4bfc3a96aeb32d57aad9877a 100644 --- a/src/gs-common.c +++ b/src/gs-common.c @@ -515,28 +515,6 @@ gs_utils_show_error_dialog (GtkWindow *parent, gtk_widget_show (dialog); } -/** - * gs_utils_get_error_value: - * @error: A GError - * - * Gets the machine-readable value stored in the error message. - * The machine readable string is after the first "@", e.g. - * message = "Requires authentication with @aaa" - * - * Returns: a string, or %NULL - */ -const gchar * -gs_utils_get_error_value (const GError *error) -{ - gchar *str; - if (error == NULL) - return NULL; - str = g_strstr_len (error->message, -1, "@"); - if (str == NULL) - return NULL; - return (const gchar *) str + 1; -} - /** * gs_utils_build_unique_id_kind: * @kind: A #AsAppKind diff --git a/src/gs-common.h b/src/gs-common.h index 89e6db598cc4d122cf2cdaacf0cd0183e2f09581..6f4ed6dc404ced2a65c7cb133b54d1b89bb652fc 100644 --- a/src/gs-common.h +++ b/src/gs-common.h @@ -34,7 +34,6 @@ void gs_image_set_from_pixbuf (GtkImage *image, gboolean gs_utils_is_current_desktop (const gchar *name); void gs_utils_widget_set_css (GtkWidget *widget, const gchar *css); -const gchar *gs_utils_get_error_value (const GError *error); void gs_utils_show_error_dialog (GtkWindow *parent, const gchar *title, const gchar *msg, diff --git a/src/gs-details-page.c b/src/gs-details-page.c index 87f00f12a147c2fd07d0d89f18ea3560f42391f9..2a59f8f08983b0967a7d031c0d8bb624a78faaac 100644 --- a/src/gs-details-page.c +++ b/src/gs-details-page.c @@ -18,7 +18,6 @@ #include "gs-details-page.h" #include "gs-app-addon-row.h" -#include "gs-auth-dialog.h" #include "gs-history-dialog.h" #include "gs-origin-popover-row.h" #include "gs-screenshot-image.h" @@ -797,7 +796,6 @@ static void gs_details_page_refresh_buttons (GsDetailsPage *self) { AsAppState state; - GsPrice *price; g_autofree gchar *text = NULL; state = gs_app_get_state (self->app); @@ -814,15 +812,6 @@ gs_details_page_refresh_buttons (GsDetailsPage *self) case AS_APP_STATE_INSTALLING: gtk_widget_set_visible (self->button_install, FALSE); break; - case AS_APP_STATE_PURCHASABLE: - gtk_widget_set_visible (self->button_install, TRUE); - price = gs_app_get_price (self->app); - text = gs_price_to_string (price); - gtk_button_set_label (GTK_BUTTON (self->button_install), text); - break; - case AS_APP_STATE_PURCHASING: - gtk_widget_set_visible (self->button_install, FALSE); - break; case AS_APP_STATE_UNKNOWN: case AS_APP_STATE_INSTALLED: case AS_APP_STATE_REMOVING: @@ -931,8 +920,6 @@ gs_details_page_refresh_buttons (GsDetailsPage *self) case AS_APP_STATE_REMOVING: case AS_APP_STATE_UNAVAILABLE: case AS_APP_STATE_UNKNOWN: - case AS_APP_STATE_PURCHASABLE: - case AS_APP_STATE_PURCHASING: case AS_APP_STATE_QUEUED_FOR_INSTALL: gtk_widget_set_visible (self->button_remove, FALSE); break; @@ -1430,33 +1417,6 @@ gs_details_page_review_helper_free (GsDetailsPageReviewHelper *helper) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GsDetailsPageReviewHelper, gs_details_page_review_helper_free); -static void -gs_details_page_app_set_review_cb (GObject *source, - GAsyncResult *res, - gpointer user_data); - -static void -gs_details_page_authenticate_cb (GsPage *page, - gboolean authenticated, - gpointer user_data) -{ - g_autoptr(GsDetailsPageReviewHelper) helper = (GsDetailsPageReviewHelper *) user_data; - g_autoptr(GsPluginJob) plugin_job = NULL; - - if (!authenticated) - return; - - plugin_job = gs_plugin_job_newv (helper->action, - "app", helper->app, - "review", helper->review, - NULL); - gs_plugin_loader_job_process_async (helper->self->plugin_loader, plugin_job, - helper->self->cancellable, - gs_details_page_app_set_review_cb, - helper); - g_steal_pointer (&helper); -} - static void gs_details_page_app_set_review_cb (GObject *source, GAsyncResult *res, @@ -1467,19 +1427,6 @@ gs_details_page_app_set_review_cb (GObject *source, g_autoptr(GError) error = NULL; if (!gs_plugin_loader_job_action_finish (plugin_loader, res, &error)) { - /* try to authenticate then retry */ - if (g_error_matches (error, - GS_PLUGIN_ERROR, - GS_PLUGIN_ERROR_AUTH_REQUIRED)) { - gs_page_authenticate (GS_PAGE (helper->self), - helper->app, - gs_utils_get_error_value (error), - helper->self->cancellable, - gs_details_page_authenticate_cb, - helper); - g_steal_pointer (&helper); - return; - } g_warning ("failed to set review on %s: %s", gs_app_get_id (helper->app), error->message); return; diff --git a/src/gs-page.c b/src/gs-page.c index 4b8ae790ad73c5035127dbb1586e798a35a4519b..692737fdbac0bfdde1de0d14e07ca307e51001b6 100644 --- a/src/gs-page.c +++ b/src/gs-page.c @@ -13,7 +13,6 @@ #include "gs-page.h" #include "gs-common.h" -#include "gs-auth-dialog.h" #include "gs-screenshot-image.h" typedef struct @@ -42,7 +41,6 @@ typedef struct { GtkWidget *button_install; GsPluginAction action; GsShellInteraction interaction; - GsPageAuthCallback callback; gpointer callback_data; } GsPageHelper; @@ -62,110 +60,6 @@ gs_page_helper_free (GsPageHelper *helper) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GsPageHelper, gs_page_helper_free); -static void -gs_page_authenticate_cb (GtkDialog *dialog, - GtkResponseType response_type, - gpointer user_data) -{ - g_autoptr(GsPageHelper) helper = user_data; - - /* unmap the dialog */ - gtk_widget_destroy (GTK_WIDGET (dialog)); - - if (helper->callback != NULL) - helper->callback (helper->page, response_type == GTK_RESPONSE_OK, helper->callback_data); -} - -void -gs_page_authenticate (GsPage *page, - GsApp *app, - const gchar *auth_id, - GCancellable *cancellable, - GsPageAuthCallback callback, - gpointer user_data) -{ - GsPagePrivate *priv = gs_page_get_instance_private (page); - g_autoptr(GsPageHelper) helper = NULL; - GtkWidget *dialog; - g_autoptr(GError) error = NULL; - - helper = g_slice_new0 (GsPageHelper); - helper->app = app != NULL ? g_object_ref (app) : NULL; - helper->page = g_object_ref (page); - helper->callback = callback; - helper->callback_data = user_data; - - dialog = gs_auth_dialog_new (priv->plugin_loader, - app, - auth_id, - &error); - if (dialog == NULL) { - g_warning ("%s", error->message); - return; - } - gs_shell_modal_dialog_present (priv->shell, GTK_DIALOG (dialog)); - g_signal_connect (dialog, "response", - G_CALLBACK (gs_page_authenticate_cb), - helper); - g_steal_pointer (&helper); -} - -static void -gs_page_app_installed_cb (GObject *source, - GAsyncResult *res, - gpointer user_data); - -static void -gs_page_install_authenticate_cb (GsPage *page, - gboolean authenticated, - gpointer user_data) -{ - g_autoptr(GsPageHelper) helper = (GsPageHelper *) user_data; - GsPagePrivate *priv = gs_page_get_instance_private (page); - g_autoptr(GsPluginJob) plugin_job = NULL; - - if (!authenticated) - return; - - plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_INSTALL, - "interactive", TRUE, - "app", helper->app, - NULL); - gs_plugin_loader_job_process_async (priv->plugin_loader, plugin_job, - helper->cancellable, - gs_page_app_installed_cb, - helper); - g_steal_pointer (&helper); -} - -static void -gs_page_app_removed_cb (GObject *source, - GAsyncResult *res, - gpointer user_data); - -static void -gs_page_remove_authenticate_cb (GsPage *page, - gboolean authenticated, - gpointer user_data) -{ - g_autoptr(GsPageHelper) helper = (GsPageHelper *) user_data; - GsPagePrivate *priv = gs_page_get_instance_private (page); - g_autoptr(GsPluginJob) plugin_job = NULL; - - if (!authenticated) - return; - - plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REMOVE, - "interactive", TRUE, - "app", helper->app, - NULL); - gs_plugin_loader_job_process_async (priv->plugin_loader, plugin_job, - helper->cancellable, - gs_page_app_removed_cb, - helper); - g_steal_pointer (&helper); -} - static void gs_page_app_installed_cb (GObject *source, GAsyncResult *res, @@ -188,20 +82,6 @@ gs_page_app_installed_cb (GObject *source, return; } if (!ret) { - /* try to authenticate then retry */ - if (g_error_matches (error, - GS_PLUGIN_ERROR, - GS_PLUGIN_ERROR_AUTH_REQUIRED)) { - gs_page_authenticate (page, - helper->app, - gs_utils_get_error_value (error), - helper->cancellable, - gs_page_install_authenticate_cb, - helper); - g_steal_pointer (&helper); - return; - } - g_warning ("failed to install %s: %s", gs_app_get_id (helper->app), error->message); @@ -249,20 +129,6 @@ gs_page_app_removed_cb (GObject *source, return; } if (!ret) { - /* try to authenticate then retry */ - if (g_error_matches (error, - GS_PLUGIN_ERROR, - GS_PLUGIN_ERROR_AUTH_REQUIRED)) { - gs_page_authenticate (page, - helper->app, - gs_utils_get_error_value (error), - helper->cancellable, - gs_page_remove_authenticate_cb, - helper); - g_steal_pointer (&helper); - return; - } - g_warning ("failed to remove: %s", error->message); return; } @@ -305,147 +171,6 @@ gs_page_set_header_end_widget (GsPage *page, GtkWidget *widget) g_set_object (&priv->header_end_widget, widget); } -static void -gs_page_app_purchased_cb (GObject *source, - GAsyncResult *res, - gpointer user_data); - -static void -gs_page_purchase_authenticate_cb (GsPage *page, - gboolean authenticated, - gpointer user_data) -{ - g_autoptr(GsPageHelper) helper = (GsPageHelper *) user_data; - GsPagePrivate *priv = gs_page_get_instance_private (page); - g_autoptr(GsPluginJob) plugin_job = NULL; - - if (!authenticated) - return; - - plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_PURCHASE, - "interactive", TRUE, - "app", helper->app, - "price", gs_app_get_price (helper->app), - NULL); - gs_plugin_loader_job_process_async (priv->plugin_loader, plugin_job, - helper->cancellable, - gs_page_app_purchased_cb, - helper); - g_steal_pointer (&helper); -} - -static void -gs_page_app_purchased_cb (GObject *source, - GAsyncResult *res, - gpointer user_data) -{ - g_autoptr(GsPageHelper) helper = (GsPageHelper *) user_data; - GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source); - GsPage *page = helper->page; - GsPagePrivate *priv = gs_page_get_instance_private (page); - gboolean ret; - g_autoptr(GsPluginJob) plugin_job = NULL; - g_autoptr(GError) error = NULL; - - ret = gs_plugin_loader_job_action_finish (plugin_loader, - res, - &error); - if (g_error_matches (error, - GS_PLUGIN_ERROR, - GS_PLUGIN_ERROR_CANCELLED)) { - g_debug ("%s", error->message); - return; - } - if (!ret) { - /* try to authenticate then retry */ - if (g_error_matches (error, - GS_PLUGIN_ERROR, - GS_PLUGIN_ERROR_AUTH_REQUIRED)) { - gs_page_authenticate (page, - helper->app, - gs_utils_get_error_value (error), - helper->cancellable, - gs_page_purchase_authenticate_cb, - helper); - g_steal_pointer (&helper); - return; - } else if (g_error_matches (error, - GS_PLUGIN_ERROR, - GS_PLUGIN_ERROR_PURCHASE_NOT_SETUP)) { - const gchar *url; - - /* have we been given a link */ - url = gs_utils_get_error_value (error); - if (url != NULL) { - g_autoptr(GError) error_local = NULL; - g_debug ("showing link in: %s", error->message); - if (!gtk_show_uri_on_window (GTK_WINDOW (gs_shell_get_window (priv->shell)), - url, - GDK_CURRENT_TIME, - &error_local)) { - g_warning ("failed to show URI %s: %s", - url, error_local->message); - } - return; - } - } - - g_warning ("failed to purchase %s: %s", - gs_app_get_id (helper->app), - error->message); - return; - } - - if (gs_app_get_state (helper->app) != AS_APP_STATE_AVAILABLE) { - g_warning ("no plugin purchased %s", - gs_app_get_id (helper->app)); - return; - } - - /* now install */ - plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_INSTALL, - "interactive", TRUE, - "app", helper->app, - NULL); - gs_plugin_loader_job_process_async (priv->plugin_loader, - plugin_job, - helper->cancellable, - gs_page_app_installed_cb, - helper); - g_steal_pointer (&helper); -} - -static void -gs_page_install_purchase_response_cb (GtkDialog *dialog, - gint response, - gpointer user_data) -{ - g_autoptr(GsPageHelper) helper = (GsPageHelper *) user_data; - GsPagePrivate *priv = gs_page_get_instance_private (helper->page); - g_autoptr(GsPluginJob) plugin_job = NULL; - - /* unmap the dialog */ - gtk_widget_destroy (GTK_WIDGET (dialog)); - - /* not agreed */ - if (response != GTK_RESPONSE_OK) - return; - - g_debug ("purchase %s", gs_app_get_id (helper->app)); - - plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_PURCHASE, - "interactive", TRUE, - "app", helper->app, - "price", gs_app_get_price (helper->app), - NULL); - gs_plugin_loader_job_process_async (priv->plugin_loader, - plugin_job, - helper->cancellable, - gs_page_app_purchased_cb, - helper); - g_steal_pointer (&helper); -} - void gs_page_install_app (GsPage *page, GsApp *app, @@ -454,6 +179,7 @@ gs_page_install_app (GsPage *page, { GsPagePrivate *priv = gs_page_get_instance_private (page); GsPageHelper *helper; + g_autoptr(GsPluginJob) plugin_job = NULL; /* probably non-free */ if (gs_app_get_state (app) == AS_APP_STATE_UNAVAILABLE) { @@ -471,51 +197,15 @@ gs_page_install_app (GsPage *page, helper->cancellable = g_object_ref (cancellable); helper->interaction = interaction; - /* need to purchase first */ - if (gs_app_get_state (app) == AS_APP_STATE_PURCHASABLE) { - GtkWidget *dialog; - g_autofree gchar *title = NULL; - g_autofree gchar *message = NULL; - g_autofree gchar *price_text = NULL; - - /* TRANSLATORS: this is a prompt message, and '%s' is an - * application summary, e.g. 'GNOME Clocks' */ - title = g_strdup_printf (_("Are you sure you want to purchase %s?"), - gs_app_get_name (app)); - price_text = gs_price_to_string (gs_app_get_price (app)); - /* TRANSLATORS: longer dialog text */ - message = g_strdup_printf (_("%s will be installed, and you will " - "be charged %s."), - gs_app_get_name (app), price_text); - - dialog = gtk_message_dialog_new (gs_shell_get_window (priv->shell), - GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_CANCEL, - "%s", title); - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - "%s", message); - - /* TRANSLATORS: this is button text to purchase the application */ - gtk_dialog_add_button (GTK_DIALOG (dialog), _("Purchase"), GTK_RESPONSE_OK); - - /* handle this async */ - g_signal_connect (dialog, "response", - G_CALLBACK (gs_page_install_purchase_response_cb), helper); - gs_shell_modal_dialog_present (priv->shell, GTK_DIALOG (dialog)); - } else { - g_autoptr(GsPluginJob) plugin_job = NULL; - - plugin_job = gs_plugin_job_newv (helper->action, - "interactive", TRUE, - "app", helper->app, - NULL); - gs_plugin_loader_job_process_async (priv->plugin_loader, - plugin_job, - helper->cancellable, - gs_page_app_installed_cb, - helper); - } + plugin_job = gs_plugin_job_newv (helper->action, + "interactive", TRUE, + "app", helper->app, + NULL); + gs_plugin_loader_job_process_async (priv->plugin_loader, + plugin_job, + helper->cancellable, + gs_page_app_installed_cb, + helper); } static void diff --git a/src/gs-page.h b/src/gs-page.h index ccea9b7bfbb7bf6c6f5e6ed7ea2ba5f6b23893ff..16527448983f123d1287a72846322a8cd1521525 100644 --- a/src/gs-page.h +++ b/src/gs-page.h @@ -36,8 +36,6 @@ struct _GsPageClass GError **error); }; -typedef void (*GsPageAuthCallback) (GsPage *page, gboolean authorized, gpointer user_data); - GsPage *gs_page_new (void); GsShell *gs_page_get_shell (GsPage *page); GtkWidget *gs_page_get_header_start_widget (GsPage *page); @@ -46,12 +44,6 @@ void gs_page_set_header_start_widget (GsPage *page, GtkWidget *gs_page_get_header_end_widget (GsPage *page); void gs_page_set_header_end_widget (GsPage *page, GtkWidget *widget); -void gs_page_authenticate (GsPage *page, - GsApp *app, - const gchar *auth_id, - GCancellable *cancellable, - GsPageAuthCallback callback, - gpointer user_data); void gs_page_install_app (GsPage *page, GsApp *app, GsShellInteraction interaction, diff --git a/src/gs-search-page.c b/src/gs-search-page.c index 189bd43c1ab3b5d675198446fe38c5c97e79ac8e..1eb04021793957c0794916ec310c907a95cb99d7 100644 --- a/src/gs-search-page.c +++ b/src/gs-search-page.c @@ -50,7 +50,7 @@ gs_search_page_app_row_clicked_cb (GsAppRow *app_row, { GsApp *app; app = gs_app_row_get_app (app_row); - if (gs_app_get_state (app) == AS_APP_STATE_AVAILABLE || gs_app_get_state (app) == AS_APP_STATE_PURCHASABLE) + if (gs_app_get_state (app) == AS_APP_STATE_AVAILABLE) gs_page_install_app (GS_PAGE (self), app, GS_SHELL_INTERACTION_FULL, self->cancellable); else if (gs_app_get_state (app) == AS_APP_STATE_INSTALLED) diff --git a/src/gs-shell.c b/src/gs-shell.c index 029aa49c4c334286f96f6402f9bd855c1560cc7b..0097c88240ea907a9facdc43b1da7174df597e2e 100644 --- a/src/gs-shell.c +++ b/src/gs-shell.c @@ -66,7 +66,6 @@ typedef struct gchar *events_info_uri; gboolean in_mode_change; GsPage *page; - GSimpleActionGroup *auth_actions; } GsShellPrivate; G_DEFINE_TYPE_WITH_PRIVATE (GsShell, gs_shell, G_TYPE_OBJECT) @@ -648,110 +647,6 @@ search_mode_enabled_cb (GtkSearchBar *search_bar, GParamSpec *pspec, GsShell *sh gtk_search_bar_get_search_mode (search_bar)); } -static void -signin_activated_cb (GSimpleAction *action, GVariant *parameter, GsShell *shell) -{ - GsShellPrivate *priv = gs_shell_get_instance_private (shell); - const gchar *action_name, *auth_id; - GsAuth *auth; - - action_name = g_action_get_name (G_ACTION (action)); - g_return_if_fail (g_str_has_prefix (action_name, "signin-")); - auth_id = action_name + strlen ("signin-"); - - auth = gs_plugin_loader_get_auth_by_id (priv->plugin_loader, auth_id); - g_return_if_fail (auth != NULL); - - gs_page_authenticate (priv->page, NULL, - gs_auth_get_auth_id (auth), - priv->cancellable, - NULL, NULL); -} - -static void -signout_activated_cb (GSimpleAction *action, GVariant *parameter, GsShell *shell) -{ - GsShellPrivate *priv = gs_shell_get_instance_private (shell); - const gchar *action_name, *auth_id; - GsAuth *auth; - - action_name = g_action_get_name (G_ACTION (action)); - g_return_if_fail (g_str_has_prefix (action_name, "signout-")); - auth_id = action_name + strlen ("signout-"); - - auth = gs_plugin_loader_get_auth_by_id (priv->plugin_loader, auth_id); - g_return_if_fail (auth != NULL); - - gs_auth_set_goa_object (auth, NULL); -} - -static void -gs_shell_reload_auth_menus (GsShell *shell) -{ - GsShellPrivate *priv = gs_shell_get_instance_private (shell); - GMenu *accounts_menu; - GPtrArray *auth_array; - - accounts_menu = G_MENU (gtk_builder_get_object (priv->builder, "accounts_menu")); - g_menu_remove_all (accounts_menu); - - auth_array = gs_plugin_loader_get_auths (priv->plugin_loader); - for (guint i = 0; i < auth_array->len; i++) { - GsAuth *auth = g_ptr_array_index (auth_array, i); - gboolean logged_in; - g_autofree gchar *signin_action_name = NULL; - GSimpleAction *signin_action; - g_autofree gchar *signin_target = NULL; - g_autofree gchar *signout_action_name = NULL; - GSimpleAction *signout_action; - g_autofree gchar *signout_target = NULL; - GoaObject *goa_object; - g_autofree gchar *signin_label = NULL; - g_autofree gchar *signout_label = NULL; - g_autoptr(GMenu) auth_menu = NULL; - g_autoptr(GMenuItem) signin_item = NULL; - g_autoptr(GMenuItem) signout_item = NULL; - - - goa_object = gs_auth_peek_goa_object (auth); - logged_in = goa_object != NULL; - - auth_menu = g_menu_new (); - accounts_menu = G_MENU (gtk_builder_get_object (priv->builder, "accounts_menu")); - g_menu_append_section (accounts_menu, gs_auth_get_provider_name (auth), G_MENU_MODEL (auth_menu)); - - signin_action_name = g_strdup_printf ("signin-%s", gs_auth_get_auth_id (auth)); - signin_action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (priv->auth_actions), signin_action_name)); - g_simple_action_set_enabled (signin_action, !logged_in); - - signout_action_name = g_strdup_printf ("signout-%s", gs_auth_get_auth_id (auth)); - signout_action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (priv->auth_actions), signout_action_name)); - g_simple_action_set_enabled (signout_action, logged_in); - - - if (logged_in) { - GoaAccount *goa_account = goa_object_peek_account (goa_object); - - /* TRANSLATORS: menu item that signs into the named account with a particular username */ - signin_label = g_strdup_printf (_("Signed in as %s"), - goa_account_get_presentation_identity (goa_account)); - } else { - /* TRANSLATORS: menu item that signs into the named account */ - signin_label = g_strdup_printf (_("Sign in…")); - } - - signin_target = g_strdup_printf ("auth.%s", signin_action_name); - signin_item = g_menu_item_new (signin_label, signin_target); - g_menu_append_item (auth_menu, signin_item); - - /* TRANSLATORS: menu item for signing out from the named account */ - signout_label = g_strdup_printf (_("Sign out")); - signout_target = g_strdup_printf ("auth.%s", signout_action_name); - signout_item = g_menu_item_new (signout_label, signout_target); - g_menu_append_item (auth_menu, signout_item); - } -} - static gboolean window_key_press_event (GtkWidget *win, GdkEventKey *event, GsShell *shell) { @@ -1037,16 +932,6 @@ gs_shell_show_event_refresh (GsShell *shell, GsPluginEvent *event) } buttons |= GS_SHELL_EVENT_BUTTON_NO_SPACE; break; - case GS_PLUGIN_ERROR_AUTH_REQUIRED: - /* TRANSLATORS: failure text for the in-app notification */ - g_string_append (str, _("Unable to download updates: " - "authentication was required")); - break; - case GS_PLUGIN_ERROR_AUTH_INVALID: - /* TRANSLATORS: failure text for the in-app notification */ - g_string_append (str, _("Unable to download updates: " - "authentication was invalid")); - break; case GS_PLUGIN_ERROR_NO_SECURITY: /* TRANSLATORS: failure text for the in-app notification */ g_string_append (str, _("Unable to download updates: you do not have" @@ -1083,59 +968,6 @@ gs_shell_show_event_refresh (GsShell *shell, GsPluginEvent *event) return TRUE; } -static gboolean -gs_shell_show_event_purchase (GsShell *shell, GsPluginEvent *event) -{ - GsApp *app = gs_plugin_event_get_app (event); - const GError *error = gs_plugin_event_get_error (event); - g_autofree gchar *str_app = NULL; - g_autoptr(GString) str = g_string_new (NULL); - - str_app = gs_shell_get_title_from_app (app); - switch (error->code) { - case GS_PLUGIN_ERROR_AUTH_REQUIRED: - /* TRANSLATORS: failure text for the in-app notification, - * where the %s is the application name (e.g. "GIMP") */ - g_string_append_printf (str, _("Unable to purchase %s: " - "authentication was required"), - str_app); - break; - case GS_PLUGIN_ERROR_AUTH_INVALID: - /* TRANSLATORS: failure text for the in-app notification, - * where the %s is the application name (e.g. "GIMP") */ - g_string_append_printf (str, _("Unable to purchase %s: " - "authentication was invalid"), - str_app); - break; - case GS_PLUGIN_ERROR_PURCHASE_NOT_SETUP: - /* TRANSLATORS: failure text for the in-app notification, - * where the %s is the application name (e.g. "GIMP") */ - g_string_append_printf (str, _("Unable to purchase %s: " - "no payment method setup"), - str_app); - break; - case GS_PLUGIN_ERROR_PURCHASE_DECLINED: - /* TRANSLATORS: failure text for the in-app notification, - * where the %s is the application name (e.g. "GIMP") */ - g_string_append_printf (str, _("Unable to purchase %s: " - "payment was declined"), - str_app); - break; - default: - /* TRANSLATORS: failure text for the in-app notification, - * where the %s is the application name (e.g. "GIMP") */ - g_string_append_printf (str, _("Unable to purchase %s"), str_app); - gs_shell_append_detailed_error (shell, str, error); - break; - } - if (str->len == 0) - return FALSE; - - /* show in-app notification */ - gs_shell_show_event_app_notify (shell, str->str, GS_SHELL_EVENT_BUTTON_NONE); - return TRUE; -} - static gboolean gs_shell_show_event_install (GsShell *shell, GsPluginEvent *event) { @@ -1204,19 +1036,6 @@ gs_shell_show_event_install (GsShell *shell, GsPluginEvent *event) str_app); buttons |= GS_SHELL_EVENT_BUTTON_NO_SPACE; break; - case GS_PLUGIN_ERROR_AUTH_REQUIRED: - /* TRANSLATORS: failure text for the in-app notification */ - g_string_append_printf (str, _("Unable to install %s: " - "authentication was required"), - str_app); - break; - case GS_PLUGIN_ERROR_AUTH_INVALID: - /* TRANSLATORS: failure text for the in-app notification, - * where the %s is the application name (e.g. "GIMP") */ - g_string_append_printf (str, _("Unable to install %s: " - "authentication was invalid"), - str_app); - break; case GS_PLUGIN_ERROR_NO_SECURITY: /* TRANSLATORS: failure text for the in-app notification, * where the %s is the application name (e.g. "GIMP") */ @@ -1328,34 +1147,6 @@ gs_shell_show_event_update (GsShell *shell, GsPluginEvent *event) } buttons |= GS_SHELL_EVENT_BUTTON_NO_SPACE; break; - case GS_PLUGIN_ERROR_AUTH_REQUIRED: - if (app != NULL) { - str_app = gs_shell_get_title_from_app (app); - /* TRANSLATORS: failure text for the in-app notification, - * where the %s is the application name (e.g. "GIMP") */ - g_string_append_printf (str, _("Unable to update %s: " - "authentication was required"), - str_app); - } else { - /* TRANSLATORS: failure text for the in-app notification */ - g_string_append_printf (str, _("Unable to install updates: " - "authentication was required")); - } - break; - case GS_PLUGIN_ERROR_AUTH_INVALID: - if (app != NULL) { - str_app = gs_shell_get_title_from_app (app); - /* TRANSLATORS: failure text for the in-app notification, - * where the %s is the application name (e.g. "GIMP") */ - g_string_append_printf (str, _("Unable to update %s: " - "authentication was invalid"), - str_app); - } else { - /* TRANSLATORS: failure text for the in-app notification */ - g_string_append_printf (str, _("Unable to install updates: " - "authentication was invalid")); - } - break; case GS_PLUGIN_ERROR_NO_SECURITY: if (app != NULL) { str_app = gs_shell_get_title_from_app (app); @@ -1468,20 +1259,6 @@ gs_shell_show_event_upgrade (GsShell *shell, GsPluginEvent *event) str_app); buttons |= GS_SHELL_EVENT_BUTTON_NO_SPACE; break; - case GS_PLUGIN_ERROR_AUTH_REQUIRED: - /* TRANSLATORS: failure text for the in-app notification, - * where the %s is the distro name (e.g. "Fedora 25") */ - g_string_append_printf (str, _("Unable to upgrade to %s: " - "authentication was required"), - str_app); - break; - case GS_PLUGIN_ERROR_AUTH_INVALID: - /* TRANSLATORS: failure text for the in-app notification, - * where the %s is the distro name (e.g. "Fedora 25") */ - g_string_append_printf (str, _("Unable to upgrade to %s: " - "authentication was invalid"), - str_app); - break; case GS_PLUGIN_ERROR_NO_SECURITY: /* TRANSLATORS: failure text for the in-app notification, * where the %s is the distro name (e.g. "Fedora 25") */ @@ -1536,18 +1313,6 @@ gs_shell_show_event_remove (GsShell *shell, GsPluginEvent *event) str_app = gs_shell_get_title_from_app (app); switch (error->code) { - case GS_PLUGIN_ERROR_AUTH_REQUIRED: - /* TRANSLATORS: failure text for the in-app notification, - * where the %s is the application name (e.g. "GIMP") */ - g_string_append_printf (str, _("Unable to remove %s: authentication was required"), - str_app); - break; - case GS_PLUGIN_ERROR_AUTH_INVALID: - /* TRANSLATORS: failure text for the in-app notification, - * where the %s is the application name (e.g. "GIMP") */ - g_string_append_printf (str, _("Unable to remove %s: authentication was invalid"), - str_app); - break; case GS_PLUGIN_ERROR_NO_SECURITY: /* TRANSLATORS: failure text for the in-app notification, * where the %s is the application name (e.g. "GIMP") */ @@ -1661,14 +1426,6 @@ gs_shell_show_event_file_to_app (GsShell *shell, GsPluginEvent *event) g_autoptr(GString) str = g_string_new (NULL); switch (error->code) { - case GS_PLUGIN_ERROR_NOT_SUPPORTED: - /* TRANSLATORS: failure text for the in-app notification */ - g_string_append (str, _("Failed to install file: not supported")); - break; - case GS_PLUGIN_ERROR_NO_SECURITY: - /* TRANSLATORS: failure text for the in-app notification */ - g_string_append (str, _("Failed to install file: authentication failed")); - break; case GS_PLUGIN_ERROR_NO_SPACE: /* TRANSLATORS: failure text for the in-app notification */ g_string_append (str, _("Not enough disk space — free up some space " @@ -1836,8 +1593,6 @@ gs_shell_show_event (GsShell *shell, GsPluginEvent *event) case GS_PLUGIN_ACTION_REFRESH: case GS_PLUGIN_ACTION_DOWNLOAD: return gs_shell_show_event_refresh (shell, event); - case GS_PLUGIN_ACTION_PURCHASE: - return gs_shell_show_event_purchase (shell, event); case GS_PLUGIN_ACTION_INSTALL: return gs_shell_show_event_install (shell, event); case GS_PLUGIN_ACTION_UPDATE: @@ -1966,7 +1721,6 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can GtkWidget *widget; GtkStyleContext *style_context; GsPage *page; - GPtrArray *auth_array; g_return_if_fail (GS_IS_SHELL (shell)); @@ -2111,33 +1865,6 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can /* primary menu */ gs_shell_add_about_menu_item (shell); - /* auth menu */ - priv->auth_actions = g_simple_action_group_new (); - gtk_widget_insert_action_group (GTK_WIDGET (priv->main_window), "auth", G_ACTION_GROUP (priv->auth_actions)); - auth_array = gs_plugin_loader_get_auths (priv->plugin_loader); - for (guint i = 0; i < auth_array->len; i++) { - GsAuth *auth = g_ptr_array_index (auth_array, i); - g_autoptr(GSimpleAction) signin_action = NULL; - g_autofree gchar *signin_action_name = NULL; - g_autoptr(GSimpleAction) signout_action = NULL; - g_autofree gchar *signout_action_name = NULL; - - signin_action_name = g_strdup_printf ("signin-%s", gs_auth_get_auth_id (auth)); - signin_action = g_simple_action_new (signin_action_name, NULL); - g_signal_connect (signin_action, "activate", G_CALLBACK (signin_activated_cb), shell); - g_action_map_add_action (G_ACTION_MAP (priv->auth_actions), G_ACTION (signin_action)); - - signout_action_name = g_strdup_printf ("signout-%s", gs_auth_get_auth_id (auth)); - signout_action = g_simple_action_new (signout_action_name, NULL); - g_signal_connect (signout_action, "activate", G_CALLBACK (signout_activated_cb), shell); - g_action_map_add_action (G_ACTION_MAP (priv->auth_actions), G_ACTION (signout_action)); - - g_signal_connect_object (auth, "changed", - G_CALLBACK (gs_shell_reload_auth_menus), - shell, G_CONNECT_SWAPPED); - gs_shell_reload_auth_menus (shell); - } - /* show loading page, which triggers the initial refresh */ gs_shell_change_mode (shell, GS_SHELL_MODE_LOADING, NULL, TRUE); } @@ -2327,7 +2054,6 @@ gs_shell_dispose (GObject *object) g_clear_pointer (&priv->pages, g_hash_table_unref); g_clear_pointer (&priv->events_info_uri, g_free); g_clear_pointer (&priv->modal_dialogs, g_ptr_array_unref); - g_clear_object (&priv->auth_actions); G_OBJECT_CLASS (gs_shell_parent_class)->dispose (object); } diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c index 429bf27b07d17d9f72576546f1fc9f4d87202aee..117e7bcde44ca5e729697964bbb35ba2d6ede165 100644 --- a/src/gs-updates-page.c +++ b/src/gs-updates-page.c @@ -1200,7 +1200,6 @@ gs_shell_update_are_updates_in_progress (GsUpdatesPage *self) switch (gs_app_get_state (app)) { case AS_APP_STATE_INSTALLING: case AS_APP_STATE_REMOVING: - case AS_APP_STATE_PURCHASING: return TRUE; break; default: diff --git a/src/gs-updates-section.c b/src/gs-updates-section.c index 5806371a075aa25417dee7eb2c7319667bb13c56..60289913e5955860ae5b58c37794e673ecb95f04 100644 --- a/src/gs-updates-section.c +++ b/src/gs-updates-section.c @@ -415,7 +415,7 @@ _build_section_header (GsUpdatesSection *self) label = gtk_label_new (_("Requires Restart")); } else if (self->kind == GS_UPDATES_SECTION_KIND_ONLINE) { /* TRANSLATORS: This is the header for online runtime and - * app updates, typically flatpaks or snaps */ + * app updates, typically flatpaks */ label = gtk_label_new (_("Application Updates")); } else if (self->kind == GS_UPDATES_SECTION_KIND_ONLINE_FIRMWARE) { /* TRANSLATORS: This is the header for device firmware that can diff --git a/src/meson.build b/src/meson.build index 9c118ecc35bc627b657928d52a70e974d50990dc..fde9ebd662ac809334456ab6ba57b93e7d79fcf7 100644 --- a/src/meson.build +++ b/src/meson.build @@ -21,7 +21,6 @@ gnome_software_sources = [ 'gs-application.c', 'gs-app-row.c', 'gs-app-tile.c', - 'gs-auth-dialog.c', 'gs-category-page.c', 'gs-category-tile.c', 'gs-common.c', diff --git a/src/org.gnome.Software.desktop.in b/src/org.gnome.Software.desktop.in index dde6bad1cb573596770cdab4972bd4c9e5a044b0..b50a1b190a75d9d9b63557493e2d76f1c61a9037 100644 --- a/src/org.gnome.Software.desktop.in +++ b/src/org.gnome.Software.desktop.in @@ -10,7 +10,7 @@ Categories=GNOME;GTK;System;PackageManager; # Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon! Keywords=Updates;Upgrade;Sources;Repositories;Preferences;Install;Uninstall;Program;Software;App;Store; StartupNotify=true -MimeType=x-scheme-handler/appstream;x-scheme-handler/apt;x-scheme-handler/snap; +MimeType=x-scheme-handler/appstream;x-scheme-handler/apt; X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Product=gnome-software X-GNOME-Bugzilla-Component=gnome-software