[evolution] Use SoupURI instead of EUri.



commit 67b64140d5f429cc9bb4e8645ce9e6f9f2553162
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Jun 18 22:04:43 2012 -0400

    Use SoupURI instead of EUri.
    
    EUri is now deprecated.

 modules/addressbook/e-book-shell-backend.c   |   14 ++++--
 modules/calendar/e-cal-shell-backend.c       |   12 ++++--
 modules/calendar/e-memo-shell-backend.c      |   12 ++++--
 modules/calendar/e-task-shell-backend.c      |   12 ++++--
 plugins/publish-calendar/publish-calendar.c  |   15 ++++---
 plugins/publish-calendar/publish-location.c  |   16 +++----
 plugins/publish-calendar/url-editor-dialog.c |   57 ++++++++++++++++----------
 7 files changed, 84 insertions(+), 54 deletions(-)
---
diff --git a/modules/addressbook/e-book-shell-backend.c b/modules/addressbook/e-book-shell-backend.c
index b2da5b9..2475312 100644
--- a/modules/addressbook/e-book-shell-backend.c
+++ b/modules/addressbook/e-book-shell-backend.c
@@ -321,7 +321,7 @@ static gboolean
 book_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
                                   const gchar *uri)
 {
-	EUri *euri;
+	SoupURI *soup_uri;
 	const gchar *cp;
 	gchar *source_uid = NULL;
 	gchar *contact_uid = NULL;
@@ -329,11 +329,15 @@ book_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
 	if (!g_str_has_prefix (uri, "contacts:"))
 		return FALSE;
 
-	euri = e_uri_new (uri);
-	cp = euri->query;
+	soup_uri = soup_uri_new (uri);
+
+	if (soup_uri == NULL)
+		return FALSE;
+
+	cp = soup_uri_get_query (soup_uri);
 
 	if (cp == NULL) {
-		e_uri_free (euri);
+		soup_uri_free (soup_uri);
 		return FALSE;
 	}
 
@@ -378,7 +382,7 @@ book_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
 	g_free (source_uid);
 	g_free (contact_uid);
 
-	e_uri_free (euri);
+	soup_uri_free (soup_uri);
 
 	return TRUE;
 }
diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c
index 0cfe9b8..44179dc 100644
--- a/modules/calendar/e-cal-shell-backend.c
+++ b/modules/calendar/e-cal-shell-backend.c
@@ -356,7 +356,7 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
 	ESource *source;
 	ESourceRegistry *registry;
 	ECalClientSourceType source_type;
-	EUri *euri;
+	SoupURI *soup_uri;
 	icalcomponent *icalcomp;
 	icalproperty *icalprop;
 	const gchar *cp;
@@ -378,8 +378,12 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
 	if (strncmp (uri, "calendar:", 9) != 0)
 		return FALSE;
 
-	euri = e_uri_new (uri);
-	cp = euri->query;
+	soup_uri = soup_uri_new (uri);
+
+	if (soup_uri == NULL)
+		return FALSE;
+
+	cp = soup_uri_get_query (soup_uri);
 	if (cp == NULL)
 		goto exit;
 
@@ -534,7 +538,7 @@ exit:
 	g_free (comp_uid);
 	g_free (comp_rid);
 
-	e_uri_free (euri);
+	soup_uri_free (soup_uri);
 
 	return handled;
 }
diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c
index db042cb..fa4884b 100644
--- a/modules/calendar/e-memo-shell-backend.c
+++ b/modules/calendar/e-memo-shell-backend.c
@@ -234,7 +234,7 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
 	ESource *source;
 	ESourceRegistry *registry;
 	ECalClientSourceType source_type;
-	EUri *euri;
+	SoupURI *soup_uri;
 	icalcomponent *icalcomp;
 	const gchar *cp;
 	gchar *source_uid = NULL;
@@ -249,8 +249,12 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
 	if (strncmp (uri, "memo:", 5) != 0)
 		return FALSE;
 
-	euri = e_uri_new (uri);
-	cp = euri->query;
+	soup_uri = soup_uri_new (uri);
+
+	if (soup_uri == NULL)
+		return FALSE;
+
+	cp = soup_uri_get_query (soup_uri);
 	if (cp == NULL)
 		goto exit;
 
@@ -370,7 +374,7 @@ exit:
 	g_free (comp_uid);
 	g_free (comp_rid);
 
-	e_uri_free (euri);
+	soup_uri_free (soup_uri);
 
 	return handled;
 }
diff --git a/modules/calendar/e-task-shell-backend.c b/modules/calendar/e-task-shell-backend.c
index dd6acb0..4d76e50 100644
--- a/modules/calendar/e-task-shell-backend.c
+++ b/modules/calendar/e-task-shell-backend.c
@@ -231,7 +231,7 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
 	ESource *source;
 	ESourceRegistry *registry;
 	ECalClientSourceType source_type;
-	EUri *euri;
+	SoupURI *soup_uri;
 	icalcomponent *icalcomp;
 	icalproperty *icalprop;
 	const gchar *cp;
@@ -247,8 +247,12 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
 	if (strncmp (uri, "task:", 5) != 0)
 		return FALSE;
 
-	euri = e_uri_new (uri);
-	cp = euri->query;
+	soup_uri = soup_uri_new (uri);
+
+	if (soup_uri == NULL)
+		return FALSE;
+
+	cp = soup_uri_get_query (soup_uri);
 	if (cp == NULL)
 		goto exit;
 
@@ -373,7 +377,7 @@ exit:
 	g_free (comp_uid);
 	g_free (comp_rid);
 
-	e_uri_free (euri);
+	soup_uri_free (soup_uri);
 
 	return handled;
 }
diff --git a/plugins/publish-calendar/publish-calendar.c b/plugins/publish-calendar/publish-calendar.c
index ff9814f..681b1fb 100644
--- a/plugins/publish-calendar/publish-calendar.c
+++ b/plugins/publish-calendar/publish-calendar.c
@@ -310,9 +310,10 @@ ask_password (GMountOperation *op,
               gpointer user_data)
 {
 	struct mnt_struct *ms = (struct mnt_struct *) user_data;
-	gchar *username, *password;
+	const gchar *username;
+	gchar *password;
 	gboolean req_pass = FALSE;
-	EUri *euri;
+	SoupURI *soup_uri;
 
 	g_return_if_fail (ms != NULL);
 
@@ -320,8 +321,10 @@ ask_password (GMountOperation *op,
 	if ((flags & G_ASK_PASSWORD_NEED_PASSWORD) == 0)
 		return;
 
-	euri = e_uri_new (ms->uri->location);
-	username = euri->user;
+	soup_uri = soup_uri_new (ms->uri->location);
+	g_return_if_fail (soup_uri != NULL);
+
+	username = soup_uri_get_user (soup_uri);
 	password = e_passwords_get_password (NULL, ms->uri->location);
 	req_pass = ((username && *username) && !(ms->uri->service_type == TYPE_ANON_FTP &&
 			!strcmp (username, "anonymous"))) ? TRUE:FALSE;
@@ -337,7 +340,7 @@ ask_password (GMountOperation *op,
 		if (!password) {
 			/* user canceled password dialog */
 			g_mount_operation_reply (op, G_MOUNT_OPERATION_ABORTED);
-			e_uri_free (euri);
+			soup_uri_free (soup_uri);
 
 			return;
 		}
@@ -353,7 +356,7 @@ ask_password (GMountOperation *op,
 
 	g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED);
 
-	e_uri_free (euri);
+	soup_uri_free (soup_uri);
 }
 
 static void
diff --git a/plugins/publish-calendar/publish-location.c b/plugins/publish-calendar/publish-location.c
index c0d46c1..44217c0 100644
--- a/plugins/publish-calendar/publish-location.c
+++ b/plugins/publish-calendar/publish-location.c
@@ -43,7 +43,7 @@ migrateURI (const gchar *xml,
 	xmlNodePtr root, p;
 	EPublishUri *uri;
 	gchar *password, *temp;
-	EUri *euri;
+	SoupURI *soup_uri;
 	gint ii;
 	gboolean found = FALSE;
 
@@ -55,22 +55,20 @@ migrateURI (const gchar *xml,
 	frequency = xmlGetProp (root, (const guchar *)"frequency");
 	username = xmlGetProp (root, (const guchar *)"username");
 
-	euri = e_uri_new ((const gchar *) location);
+	soup_uri = soup_uri_new ((gchar *) location);
 
-	if (!euri) {
+	if (soup_uri == NULL) {
 		g_warning ("Could not form the uri for %s \n", location);
 		goto cleanup;
 	}
 
-	if (euri->user)
-		g_free (euri->user);
+	soup_uri_set_user (soup_uri, (gchar *) username);
 
-	euri->user = g_strdup ((const gchar *) username);
-
-	temp = e_uri_to_string (euri, FALSE);
+	temp = soup_uri_to_string (soup_uri, FALSE);
 	uri->location = g_strdup_printf ("dav://%s", strstr (temp, "//") + 2);
 	g_free (temp);
-	e_uri_free (euri);
+
+	soup_uri_free (soup_uri);
 
 	if (enabled != NULL)
 		uri->enabled = atoi ((gchar *) enabled);
diff --git a/plugins/publish-calendar/url-editor-dialog.c b/plugins/publish-calendar/url-editor-dialog.c
index c5483d5..3e97756 100644
--- a/plugins/publish-calendar/url-editor-dialog.c
+++ b/plugins/publish-calendar/url-editor-dialog.c
@@ -299,51 +299,64 @@ static void
 set_from_uri (UrlEditorDialog *dialog)
 {
 	EPublishUri *uri;
-	gchar *method;
-	EUri *euri = NULL;
+	SoupURI *soup_uri;
+	const gchar *scheme;
+	const gchar *user;
+	const gchar *host;
+	const gchar *path;
+	guint port;
 
 	uri = dialog->uri;
 
-	euri = e_uri_new (uri->location);
-	/* determine our method */
-	method = euri->protocol;
-	if (strcmp ((const gchar *)method, "smb") == 0)
+	soup_uri = soup_uri_new (uri->location);
+	g_return_if_fail (soup_uri != NULL);
+
+	/* determine our service type */
+	scheme = soup_uri_get_scheme (soup_uri);
+	g_return_if_fail (scheme != NULL);
+
+	if (strcmp (scheme, "smb") == 0)
 		uri->service_type = TYPE_SMB;
-	else if (strcmp ((const gchar *)method, "sftp") == 0)
+	else if (strcmp (scheme, "sftp") == 0)
 		uri->service_type = TYPE_SFTP;
-	else if (strcmp ((const gchar *)method, "ftp") == 0)
+	else if (strcmp (scheme, "ftp") == 0)
 		/* we set TYPE_FTP here for now. if we don't find a
 		 * username later, we'll change it to TYPE_ANON_FTP */
 		uri->service_type = TYPE_FTP;
-	else if (strcmp ((const gchar *)method, "dav") == 0)
+	else if (strcmp (scheme, "dav") == 0)
 		uri->service_type = TYPE_DAV;
-	else if (strcmp ((const gchar *)method, "davs") == 0)
+	else if (strcmp (scheme, "davs") == 0)
 		uri->service_type = TYPE_DAVS;
 	else
 		uri->service_type = TYPE_URI;
 
-	if (euri->user)
-		gtk_entry_set_text (GTK_ENTRY (dialog->username_entry), euri->user);
+	user = soup_uri_get_user (soup_uri);
+	host = soup_uri_get_host (soup_uri);
+	port = soup_uri_get_port (soup_uri);
+	path = soup_uri_get_path (soup_uri);
 
-	if (euri->host)
-		gtk_entry_set_text (GTK_ENTRY (dialog->server_entry), euri->host);
+	if (user != NULL)
+		gtk_entry_set_text (GTK_ENTRY (dialog->username_entry), user);
 
-	if (euri->port) {
-		gchar *port;
-		port = g_strdup_printf ("%d", euri->port);
-		gtk_entry_set_text (GTK_ENTRY (dialog->port_entry), port);
-		g_free (port);
+	if (host != NULL)
+		gtk_entry_set_text (GTK_ENTRY (dialog->server_entry), host);
+
+	if (port > 0) {
+		gchar *port_str;
+		port_str = g_strdup_printf ("%d", port);
+		gtk_entry_set_text (GTK_ENTRY (dialog->port_entry), port_str);
+		g_free (port_str);
 	}
 
-	if (euri->path)
-		gtk_entry_set_text (GTK_ENTRY (dialog->file_entry), euri->path);
+	if (path != NULL)
+		gtk_entry_set_text (GTK_ENTRY (dialog->file_entry), path);
 
 	if (uri->service_type == TYPE_URI)
 		gtk_entry_set_text (GTK_ENTRY (dialog->server_entry), uri->location);
 
 	gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->publish_service), uri->service_type);
 
-	e_uri_free (euri);
+	soup_uri_free (soup_uri);
 }
 
 static gboolean



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]