[gnome-software/wip/ubuntu-xenial] Update snap plugin to match master
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/ubuntu-xenial] Update snap plugin to match master
- Date: Fri, 1 Jul 2016 04:16:12 +0000 (UTC)
commit e0f55cfb04c3f169b3a0ba4980e8883f8c6064cf
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Jul 1 15:57:29 2016 +1200
Update snap plugin to match master
src/plugins/gs-plugin-snap.c | 144 ++++++++++++++++++++++++-------------
src/plugins/gs-snapd.c | 145 +++++++++++++++++++++++--------------
src/plugins/gs-snapd.h | 28 ++++----
src/plugins/gs-ubuntuone-dialog.c | 26 ++++----
4 files changed, 212 insertions(+), 131 deletions(-)
---
diff --git a/src/plugins/gs-plugin-snap.c b/src/plugins/gs-plugin-snap.c
index 91ed2a4..61758ba 100644
--- a/src/plugins/gs-plugin-snap.c
+++ b/src/plugins/gs-plugin-snap.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2015 Canonical Ltd
+ * Copyright (C) 2015-2016 Canonical Ltd
*
* Licensed under the GNU General Public License Version 2
*
@@ -25,10 +25,6 @@
#include "gs-snapd.h"
#include "gs-ubuntuone.h"
-// snapd API documentation is at https://github.com/snapcore/snapd/blob/master/docs/rest.md
-
-#define SNAPD_SOCKET "/run/snapd.socket"
-
struct GsPluginPrivate {
};
@@ -46,9 +42,9 @@ gs_plugin_initialize (GsPlugin *plugin)
/* create private area */
plugin->priv = GS_PLUGIN_GET_PRIVATE (GsPluginPrivate);
- if (!g_file_test (SNAPD_SOCKET, G_FILE_TEST_EXISTS)) {
- g_debug ("disabling '%s' as no %s available",
- plugin->name, SNAPD_SOCKET);
+ if (!gs_snapd_exists ()) {
+ g_debug ("disabling '%s' as snapd not running",
+ gs_plugin_get_name ());
gs_plugin_set_enabled (plugin, FALSE);
}
}
@@ -57,7 +53,7 @@ static JsonParser *
parse_result (const gchar *response, const gchar *response_type, GError **error)
{
g_autoptr(JsonParser) parser = NULL;
- g_autoptr(GError) sub_error = NULL;
+ g_autoptr(GError) error_local = NULL;
if (response_type == NULL) {
g_set_error_literal (error,
@@ -75,11 +71,12 @@ parse_result (const gchar *response, const gchar *response_type, GError **error)
}
parser = json_parser_new ();
- if (!json_parser_load_from_data (parser, response, -1, &sub_error)) {
+ if (!json_parser_load_from_data (parser, response, -1, &error_local)) {
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
- "Unable to parse snapd response: %s", sub_error->message);
+ "Unable to parse snapd response: %s",
+ error_local->message);
return NULL;
}
if (!JSON_NODE_HOLDS_OBJECT (json_parser_get_root (parser))) {
@@ -104,24 +101,28 @@ refine_app (GsPlugin *plugin, GsApp *app, JsonObject *package, gboolean from_sea
if (g_strcmp0 (status, "installed") == 0 || g_strcmp0 (status, "active") == 0) {
const gchar *update_available;
- update_available = json_object_has_member (package, "update_available") ?
json_object_get_string_member (package, "update_available") : NULL;
+ update_available = json_object_has_member (package, "update_available") ?
+ json_object_get_string_member (package, "update_available") : NULL;
if (update_available)
gs_app_set_state (app, AS_APP_STATE_UPDATABLE);
else
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
size = json_object_get_int_member (package, "installed-size");
+ } else if (g_strcmp0 (status, "not installed") == 0 || g_strcmp0 (status, "available") == 0) {
+ gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
+ size = json_object_get_int_member (package, "download-size");
}
else if (g_strcmp0 (status, "removed") == 0) {
// A removed app is only available if it can be downloaded (it might have been sideloaded)
size = json_object_get_int_member (package, "download-size");
if (size > 0)
gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
- } else if (g_strcmp0 (status, "not installed") == 0 || g_strcmp0 (status, "available") == 0) {
- gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
- size = json_object_get_int_member (package, "download-size");
}
- gs_app_set_name (app, GS_APP_QUALITY_HIGHEST, json_object_get_string_member (package, "name"));
- gs_app_set_summary (app, GS_APP_QUALITY_HIGHEST, json_object_get_string_member (package,
"description"));
+
+ gs_app_set_name (app, GS_APP_QUALITY_HIGHEST,
+ json_object_get_string_member (package, "name"));
+ gs_app_set_summary (app, GS_APP_QUALITY_HIGHEST,
+ json_object_get_string_member (package, "description"));
gs_app_set_version (app, json_object_get_string_member (package, "version"));
if (size > 0)
gs_app_set_size (app, size);
@@ -131,11 +132,17 @@ refine_app (GsPlugin *plugin, GsApp *app, JsonObject *package, gboolean from_sea
g_autofree gchar *icon_response = NULL;
gsize icon_response_length;
- if (send_snapd_request ("GET", icon_url, NULL, TRUE, NULL, TRUE, NULL, NULL, NULL, NULL,
&icon_response, &icon_response_length, NULL)) {
+ if (gs_snapd_request ("GET", icon_url, NULL, TRUE, NULL, TRUE, NULL,
+ NULL, NULL, NULL,
+ &icon_response, &icon_response_length,
+ NULL)) {
g_autoptr(GdkPixbufLoader) loader = NULL;
loader = gdk_pixbuf_loader_new ();
- gdk_pixbuf_loader_write (loader, (guchar *) icon_response, icon_response_length,
NULL);
+ gdk_pixbuf_loader_write (loader,
+ (guchar *) icon_response,
+ icon_response_length,
+ NULL);
gdk_pixbuf_loader_close (loader, NULL);
icon_pixbuf = g_object_ref (gdk_pixbuf_loader_get_pixbuf (loader));
}
@@ -150,15 +157,18 @@ refine_app (GsPlugin *plugin, GsApp *app, JsonObject *package, gboolean from_sea
if (message != NULL) {
soup_session_send_message (plugin->soup_session, message);
loader = gdk_pixbuf_loader_new ();
- gdk_pixbuf_loader_write (loader, (guint8 *) message->response_body->data,
message->response_body->length, NULL);
+ gdk_pixbuf_loader_write (loader,
+ (guint8 *) message->response_body->data,
+ message->response_body->length,
+ NULL);
gdk_pixbuf_loader_close (loader, NULL);
icon_pixbuf = g_object_ref (gdk_pixbuf_loader_get_pixbuf (loader));
}
}
- if (icon_pixbuf)
+ if (icon_pixbuf) {
gs_app_set_pixbuf (app, icon_pixbuf);
- else {
+ } else {
g_autoptr(AsIcon) icon = NULL;
icon = as_icon_new ();
@@ -182,7 +192,13 @@ refine_app (GsPlugin *plugin, GsApp *app, JsonObject *package, gboolean from_sea
}
static gboolean
-get_apps (GsPlugin *plugin, const gchar *sources, gchar **search_terms, GList **list, AppFilterFunc
filter_func, gpointer user_data, GError **error)
+get_apps (GsPlugin *plugin,
+ const gchar *sources,
+ gchar **search_terms,
+ GList **list,
+ AppFilterFunc filter_func,
+ gpointer user_data,
+ GError **error)
{
guint status_code;
GPtrArray *query_fields;
@@ -214,14 +230,18 @@ get_apps (GsPlugin *plugin, const gchar *sources, gchar **search_terms, GList **
g_string_append (path, fields);
}
g_ptr_array_free (query_fields, TRUE);
- if (!send_snapd_request ("GET", path->str, NULL, TRUE, NULL, TRUE, NULL, &status_code,
&reason_phrase, &response_type, &response, NULL, error))
+ if (!gs_snapd_request ("GET", path->str, NULL, TRUE, NULL, TRUE, NULL,
+ &status_code, &reason_phrase,
+ &response_type, &response,
+ NULL, error))
return FALSE;
if (status_code != SOUP_STATUS_OK) {
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
- "snapd returned status code %d: %s", status_code, reason_phrase);
+ "snapd returned status code %d: %s",
+ status_code, reason_phrase);
return FALSE;
}
@@ -261,19 +281,26 @@ static gboolean
get_app (GsPlugin *plugin, GsApp *app, GError **error)
{
guint status_code;
- g_autofree gchar *path = NULL, *reason_phrase = NULL, *response_type = NULL, *response = NULL;
+ g_autofree gchar *path = NULL;
+ g_autofree gchar *reason_phrase = NULL;
+ g_autofree gchar *response = NULL;
+ g_autofree gchar *response_type = NULL;
g_autoptr(JsonParser) parser = NULL;
JsonObject *root, *result;
path = g_strdup_printf ("/v2/snaps/%s", gs_app_get_id (app));
- if (!send_snapd_request ("GET", path, NULL, TRUE, NULL, TRUE, NULL, &status_code, &reason_phrase,
&response_type, &response, NULL, error))
+ if (!gs_snapd_request ("GET", path, NULL, TRUE, NULL, TRUE, NULL,
+ &status_code, &reason_phrase,
+ &response_type, &response,
+ NULL, error))
return FALSE;
if (status_code != SOUP_STATUS_OK) {
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
- "snapd returned status code %d: %s", status_code, reason_phrase);
+ "snapd returned status code %d: %s",
+ status_code, reason_phrase);
return FALSE;
}
@@ -350,11 +377,18 @@ gs_plugin_refine (GsPlugin *plugin,
}
static gboolean
-send_package_action (GsPlugin *plugin, GsApp *app, const char *id, const gchar *action, GError **error)
+send_package_action (GsPlugin *plugin,
+ GsApp *app,
+ const gchar *id,
+ const gchar *action,
+ GError **error)
{
g_autofree gchar *content = NULL, *path = NULL;
guint status_code;
- g_autofree gchar *reason_phrase = NULL, *response_type = NULL, *response = NULL, *status = NULL;
+ g_autofree gchar *reason_phrase = NULL;
+ g_autofree gchar *response_type = NULL;
+ g_autofree gchar *response = NULL;
+ g_autofree gchar *status = NULL;
g_autoptr(JsonParser) parser = NULL;
JsonObject *root, *result, *task, *progress;
JsonArray *tasks;
@@ -367,14 +401,18 @@ send_package_action (GsPlugin *plugin, GsApp *app, const char *id, const gchar *
content = g_strdup_printf ("{\"action\": \"%s\"}", action);
path = g_strdup_printf ("/v2/snaps/%s", id);
- if (!send_snapd_request ("POST", path, content, TRUE, NULL, TRUE, &macaroon, &status_code,
&reason_phrase, &response_type, &response, NULL, error))
+ if (!gs_snapd_request ("POST", path, content, TRUE, NULL, TRUE,
+ &macaroon, &status_code,
+ &reason_phrase, &response_type,
+ &response, NULL, error))
return FALSE;
if (status_code != SOUP_STATUS_ACCEPTED) {
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
- "snapd returned status code %d: %s", status_code, reason_phrase);
+ "snapd returned status code %d: %s",
+ status_code, reason_phrase);
return FALSE;
}
@@ -390,15 +428,18 @@ send_package_action (GsPlugin *plugin, GsApp *app, const char *id, const gchar *
resource_path = g_strdup_printf ("/v2/changes/%s", change_id);
while (TRUE) {
- g_autofree gchar *status_reason_phrase = NULL, *status_response_type = NULL,
*status_response = NULL;
+ g_autofree gchar *status_reason_phrase = NULL;
+ g_autofree gchar *status_response_type = NULL;
+ g_autofree gchar *status_response = NULL;
g_autoptr(JsonParser) status_parser = NULL;
/* Wait for a little bit before polling */
g_usleep (100 * 1000);
- if (!send_snapd_request ("GET", resource_path, NULL, TRUE, macaroon, TRUE, NULL,
- &status_code, &status_reason_phrase, &status_response_type,
- &status_response, NULL, error)) {
+ if (!gs_snapd_request ("GET", resource_path, NULL, TRUE, macaroon, TRUE, NULL,
+ &status_code, &status_reason_phrase,
+ &status_response_type, &status_response,
+ NULL, error)) {
return FALSE;
}
@@ -406,7 +447,8 @@ send_package_action (GsPlugin *plugin, GsApp *app, const char *id, const gchar *
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
- "snapd returned status code %d: %s", status_code,
status_reason_phrase);
+ "snapd returned status code %d: %s",
+ status_code, status_reason_phrase);
return FALSE;
}
@@ -462,20 +504,20 @@ gs_plugin_app_install (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
- gboolean result;
+ gboolean ret;
/* We can only install apps we know of */
if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0)
return TRUE;
gs_app_set_state (app, AS_APP_STATE_INSTALLING);
- result = send_package_action (plugin, app, gs_app_get_id (app), "install", error);
- if (result)
- gs_app_set_state (app, AS_APP_STATE_INSTALLED);
- else
+ ret = send_package_action (plugin, app, gs_app_get_id (app), "install", error);
+ if (!ret) {
gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
-
- return result;
+ return FALSE;
+ }
+ gs_app_set_state (app, AS_APP_STATE_INSTALLED);
+ return TRUE;
}
gboolean
@@ -517,18 +559,18 @@ gs_plugin_app_remove (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
- gboolean result;
+ gboolean ret;
/* We can only remove apps we know of */
if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0)
return TRUE;
gs_app_set_state (app, AS_APP_STATE_REMOVING);
- result = send_package_action (plugin, app, gs_app_get_id (app), "remove", error);
- if (result)
- gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
- else
+ ret = send_package_action (plugin, app, gs_app_get_id (app), "remove", error);
+ if (!ret) {
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
-
- return result;
+ return FALSE;
+ }
+ gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
+ return TRUE;
}
diff --git a/src/plugins/gs-snapd.c b/src/plugins/gs-snapd.c
index 5770778..9f91fa9 100644
--- a/src/plugins/gs-snapd.c
+++ b/src/plugins/gs-snapd.c
@@ -24,34 +24,46 @@
#include <gs-plugin.h>
#include <libsoup/soup.h>
#include <gio/gunixsocketaddress.h>
+
#include "gs-snapd.h"
#include "gs-ubuntuone.h"
-#define SNAPD_SOCKET_PATH "/run/snapd.socket"
-
// snapd API documentation is at https://github.com/snapcore/snapd/blob/master/docs/rest.md
+#define SNAPD_SOCKET "/run/snapd.socket"
+
+gboolean
+gs_snapd_exists (void)
+{
+ return g_file_test (SNAPD_SOCKET, G_FILE_TEST_EXISTS);
+}
+
static GSocket *
open_snapd_socket (GError **error)
{
GSocket *socket;
g_autoptr(GSocketAddress) address = NULL;
- g_autoptr(GError) sub_error = NULL;
+ g_autoptr(GError) error_local = NULL;
- socket = g_socket_new (G_SOCKET_FAMILY_UNIX, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_DEFAULT,
&sub_error);
+ socket = g_socket_new (G_SOCKET_FAMILY_UNIX,
+ G_SOCKET_TYPE_STREAM,
+ G_SOCKET_PROTOCOL_DEFAULT,
+ &error_local);
if (!socket) {
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
- "Unable to open snapd socket: %s", sub_error->message);
+ "Unable to open snapd socket: %s",
+ error_local->message);
return NULL;
}
- address = g_unix_socket_address_new (SNAPD_SOCKET_PATH);
- if (!g_socket_connect (socket, address, NULL, &sub_error)) {
+ address = g_unix_socket_address_new (SNAPD_SOCKET);
+ if (!g_socket_connect (socket, address, NULL, &error_local)) {
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
- "Unable to connect snapd socket: %s", sub_error->message);
+ "Unable to connect snapd socket: %s",
+ error_local->message);
g_object_unref (socket);
return NULL;
}
@@ -60,10 +72,17 @@ open_snapd_socket (GError **error)
}
static gboolean
-read_from_snapd (GSocket *socket, gchar *buffer, gsize buffer_length, gsize *read_offset, GError **error)
+read_from_snapd (GSocket *socket,
+ gchar *buffer, gsize buffer_length,
+ gsize *read_offset,
+ GError **error)
{
gssize n_read;
- n_read = g_socket_receive (socket, buffer + *read_offset, buffer_length - *read_offset, NULL, error);
+ n_read = g_socket_receive (socket,
+ buffer + *read_offset,
+ buffer_length - *read_offset,
+ NULL,
+ error);
if (n_read < 0)
return FALSE;
*read_offset += n_read;
@@ -73,19 +92,19 @@ read_from_snapd (GSocket *socket, gchar *buffer, gsize buffer_length, gsize *rea
}
gboolean
-send_snapd_request (const gchar *method,
- const gchar *path,
- const gchar *content,
- gboolean authenticate,
- GVariant *macaroon,
- gboolean retry_after_login,
- GVariant **out_macaroon,
- guint *status_code,
- gchar **reason_phrase,
- gchar **response_type,
- gchar **response,
- gsize *response_length,
- GError **error)
+gs_snapd_request (const gchar *method,
+ const gchar *path,
+ const gchar *content,
+ gboolean authenticate,
+ GVariant *macaroon,
+ gboolean retry_after_login,
+ GVariant **out_macaroon,
+ guint *status_code,
+ gchar **reason_phrase,
+ gchar **response_type,
+ gchar **response,
+ gsize *response_length,
+ GError **error)
{
g_autoptr (GSocket) socket = NULL;
g_autoptr (GString) request = NULL;
@@ -111,7 +130,6 @@ send_snapd_request (const gchar *method,
// https://bugzilla.gnome.org/show_bug.cgi?id=727563
socket = open_snapd_socket (error);
-
if (socket == NULL)
return FALSE;
@@ -137,14 +155,18 @@ send_snapd_request (const gchar *method,
if (g_strcmp0 (g_getenv ("GNOME_SOFTWARE_SNAPPY"), "debug") == 0)
g_print ("===== begin snapd request =====\n%s\n===== end snapd request =====\n",
request->str);
- /* Send HTTP request */
+ /* send HTTP request */
n_written = g_socket_send (socket, request->str, request->len, NULL, error);
if (n_written < 0)
return FALSE;
- /* Read HTTP headers */
+ /* read HTTP headers */
while (data_length < max_data_length && !body) {
- if (!read_from_snapd (socket, data, max_data_length, &data_length, error))
+ if (!read_from_snapd (socket,
+ data,
+ max_data_length,
+ &data_length,
+ error))
return FALSE;
body = strstr (data, "\r\n\r\n");
}
@@ -156,13 +178,14 @@ send_snapd_request (const gchar *method,
return FALSE;
}
- /* Body starts after header divider */
+ /* body starts after header divider */
body += 4;
header_length = body - data;
- /* Parse headers */
+ /* parse headers */
headers = soup_message_headers_new (SOUP_MESSAGE_HEADERS_RESPONSE);
- if (!soup_headers_parse_response (data, header_length, headers, NULL, &code, reason_phrase)) {
+ if (!soup_headers_parse_response (data, header_length, headers,
+ NULL, &code, reason_phrase)) {
g_set_error_literal (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
@@ -181,24 +204,26 @@ send_snapd_request (const gchar *method,
macaroon = gs_ubuntuone_get_macaroon (FALSE, TRUE, NULL);
if (macaroon == NULL) {
- g_set_error_literal (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED,
+ g_set_error_literal (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED,
"failed to authenticate");
return FALSE;
}
- ret = send_snapd_request (method,
- path,
- content,
- TRUE,
- macaroon,
- FALSE,
- NULL,
- status_code,
- reason_phrase,
- response_type,
- response,
- response_length,
- error);
+ ret = gs_snapd_request (method,
+ path,
+ content,
+ TRUE,
+ macaroon,
+ FALSE,
+ NULL,
+ status_code,
+ reason_phrase,
+ response_type,
+ response,
+ response_length,
+ error);
if (ret && out_macaroon != NULL) {
*out_macaroon = macaroon;
@@ -209,25 +234,31 @@ send_snapd_request (const gchar *method,
return ret;
}
- /* Work out how much data to follow */
- if (g_strcmp0 (soup_message_headers_get_one (headers, "Transfer-Encoding"), "chunked") == 0) {
+ /* work out how much data to follow */
+ if (g_strcmp0 (soup_message_headers_get_one (headers, "Transfer-Encoding"),
+ "chunked") == 0) {
while (data_length < max_data_length) {
chunk_start = strstr (body, "\r\n");
if (chunk_start)
break;
- if (!read_from_snapd (socket, data, max_data_length, &data_length, error))
+ if (!read_from_snapd (socket,
+ data,
+ max_data_length,
+ &data_length,
+ error))
return FALSE;
}
if (!chunk_start) {
g_set_error_literal (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
- "Unable to find chunk header in snapd response");
+ "Unable to find chunk header in "
+ "snapd response");
return FALSE;
}
chunk_length = strtoul (body, NULL, 16);
chunk_start += 2;
- // FIXME: Support multiple chunks
+ // FIXME: support multiple chunks
}
else {
const gchar *value;
@@ -236,26 +267,32 @@ send_snapd_request (const gchar *method,
g_set_error_literal (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
- "Unable to determine content length of snapd response");
+ "Unable to determine content "
+ "length of snapd response");
return FALSE;
}
chunk_length = strtoul (value, NULL, 10);
chunk_start = body;
}
- /* Check if enough space to read chunk */
+ /* check if enough space to read chunk */
n_required = (chunk_start - data) + chunk_length;
if (n_required > max_data_length) {
g_set_error (error,
GS_PLUGIN_ERROR,
GS_PLUGIN_ERROR_FAILED,
- "Not enough space for snapd response, require %zi octets, have %zi", n_required,
max_data_length);
+ "Not enough space for snapd response, "
+ "require %zi octets, have %zi",
+ n_required, max_data_length);
return FALSE;
}
- /* Read chunk content */
+ /* read chunk content */
while (data_length < n_required)
- if (!read_from_snapd (socket, data, n_required - data_length, &data_length, error))
+ if (!read_from_snapd (socket, data,
+ n_required - data_length,
+ &data_length,
+ error))
return FALSE;
if (out_macaroon != NULL)
diff --git a/src/plugins/gs-snapd.h b/src/plugins/gs-snapd.h
index d44d834..b6de429 100644
--- a/src/plugins/gs-snapd.h
+++ b/src/plugins/gs-snapd.h
@@ -24,18 +24,20 @@
#include <gio/gio.h>
-gboolean send_snapd_request (const gchar *method,
- const gchar *path,
- const gchar *content,
- gboolean authenticate,
- GVariant *macaroon,
- gboolean retry_after_login,
- GVariant **out_macaroon,
- guint *status_code,
- gchar **reason_phrase,
- gchar **response_type,
- gchar **response,
- gsize *response_length,
- GError **error);
+gboolean gs_snapd_exists (void);
+
+gboolean gs_snapd_request (const gchar *method,
+ const gchar *path,
+ const gchar *content,
+ gboolean authenticate,
+ GVariant *macaroon,
+ gboolean retry_after_login,
+ GVariant **out_macaroon,
+ guint *status_code,
+ gchar **reason_phrase,
+ gchar **response_type,
+ gchar **response,
+ gsize *response_length,
+ GError **error);
#endif /* __GS_SNAPD_H__ */
diff --git a/src/plugins/gs-ubuntuone-dialog.c b/src/plugins/gs-ubuntuone-dialog.c
index 6fc2a34..aca0925 100644
--- a/src/plugins/gs-ubuntuone-dialog.c
+++ b/src/plugins/gs-ubuntuone-dialog.c
@@ -428,19 +428,19 @@ send_login_request (GsUbuntuoneDialog *self)
password);
}
- if (send_snapd_request (SOUP_METHOD_POST,
- "/v2/login",
- content,
- FALSE,
- NULL,
- FALSE,
- NULL,
- &status_code,
- &reason_phrase,
- &response_type,
- &response,
- &response_length,
- &error)) {
+ if (gs_snapd_request (SOUP_METHOD_POST,
+ "/v2/login",
+ content,
+ FALSE,
+ NULL,
+ FALSE,
+ NULL,
+ &status_code,
+ &reason_phrase,
+ &response_type,
+ &response,
+ &response_length,
+ &error)) {
reenable_widgets (self);
check_snapd_response (self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]