[gnome-online-accounts/gnome-3-16] owncloud: Add uri_to_string_with_path() helper
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/gnome-3-16] owncloud: Add uri_to_string_with_path() helper
- Date: Thu, 1 Oct 2015 17:02:29 +0000 (UTC)
commit 3118776bdd83f558751ec6452a88dd2fdd44ffcd
Author: Christophe Fergeau <cfergeau redhat com>
Date: Sun May 3 11:04:29 2015 +0200
owncloud: Add uri_to_string_with_path() helper
This extracts a bit of repeated code out of
GoaOwncloudProvider::build_object() and makes the high level code flow
somewhat easier to follow.
https://bugzilla.gnome.org/show_bug.cgi?id=752941
src/goabackend/goaowncloudprovider.c | 46 ++++++++++++++--------------------
1 files changed, 19 insertions(+), 27 deletions(-)
---
diff --git a/src/goabackend/goaowncloudprovider.c b/src/goabackend/goaowncloudprovider.c
index 86d8234..82c9039 100644
--- a/src/goabackend/goaowncloudprovider.c
+++ b/src/goabackend/goaowncloudprovider.c
@@ -85,6 +85,22 @@ get_provider_features (GoaProvider *provider)
/* ---------------------------------------------------------------------------------------------------- */
+static char *
+uri_to_string_with_path (SoupURI *soup_uri, const gchar *path)
+{
+ gchar *uri_string;
+ gchar *uri_tmp;
+
+ if (soup_uri == NULL)
+ return NULL;
+
+ uri_tmp = soup_uri_to_string (soup_uri, FALSE);
+ uri_string = g_strconcat (uri_tmp, path, NULL);
+ g_free (uri_tmp);
+
+ return uri_string;
+}
+
static gboolean on_handle_get_password (GoaPasswordBased *interface,
GDBusMethodInvocation *invocation,
const gchar *id,
@@ -168,17 +184,7 @@ build_object (GoaProvider *provider,
{
gchar *uri_caldav;
- uri_caldav = NULL;
-
- if (uri != NULL)
- {
- gchar *uri_tmp;
-
- uri_tmp = soup_uri_to_string (uri, FALSE);
- uri_caldav = g_strconcat (uri_tmp, CALDAV_ENDPOINT, NULL);
- g_free (uri_tmp);
- }
-
+ uri_caldav = uri_to_string_with_path (uri, CALDAV_ENDPOINT);
calendar = goa_calendar_skeleton_new ();
g_object_set (G_OBJECT (calendar),
"accept-ssl-errors", accept_ssl_errors,
@@ -203,17 +209,7 @@ build_object (GoaProvider *provider,
{
gchar *uri_carddav;
- uri_carddav = NULL;
-
- if (uri != NULL)
- {
- gchar *uri_tmp;
-
- uri_tmp = soup_uri_to_string (uri, FALSE);
- uri_carddav = g_strconcat (uri_tmp, CARDDAV_ENDPOINT, NULL);
- g_free (uri_tmp);
- }
-
+ uri_carddav = uri_to_string_with_path (uri, CARDDAV_ENDPOINT);
contacts = goa_contacts_skeleton_new ();
g_object_set (G_OBJECT (contacts),
"accept-ssl-errors", accept_ssl_errors,
@@ -261,17 +257,13 @@ build_object (GoaProvider *provider,
if (uri != NULL)
{
const gchar *scheme;
- gchar *uri_tmp;
scheme = soup_uri_get_scheme (uri);
if (g_strcmp0 (scheme, SOUP_URI_SCHEME_HTTPS) == 0)
soup_uri_set_scheme (uri, "davs");
else
soup_uri_set_scheme (uri, "dav");
-
- uri_tmp = soup_uri_to_string (uri, FALSE);
- uri_webdav = g_strconcat (uri_tmp, WEBDAV_ENDPOINT, NULL);
- g_free (uri_tmp);
+ uri_webdav = uri_to_string_with_path (uri, WEBDAV_ENDPOINT);
}
files = goa_files_skeleton_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]