Merge lp:~rodrigo-moya/libubuntuone/catch-syncdaemon-errors into lp:libubuntuone

Proposed by Rodrigo Moya
Status: Merged
Approved by: Facundo Batista
Approved revision: 74
Merged at revision: not available
Proposed branch: lp:~rodrigo-moya/libubuntuone/catch-syncdaemon-errors
Merge into: lp:libubuntuone
Diff against target: 92 lines (+34/-5)
3 files modified
libubuntuone/syncdaemon.c (+31/-1)
libubuntuone/syncdaemon.h (+1/-0)
libubuntuone/u1-music-store.c (+2/-4)
To merge this branch: bzr merge lp:~rodrigo-moya/libubuntuone/catch-syncdaemon-errors
Reviewer Review Type Date Requested Status
Facundo Batista (community) Approve
Tim Cole (community) Approve
Review via email: mp+22109@code.launchpad.net

Commit message

Make sure we are connected to the syncdaemon every time we need it

Description of the change

Make sure we are connected to the syncdaemon every time we need it

To post a comment you must log in.
Revision history for this message
Tim Cole (tcole) :
review: Approve
Revision history for this message
Facundo Batista (facundo) wrote :

Looks ok!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libubuntuone/syncdaemon.c'
--- libubuntuone/syncdaemon.c 2010-03-05 17:15:53 +0000
+++ libubuntuone/syncdaemon.c 2010-03-25 09:39:17 +0000
@@ -60,6 +60,30 @@
60 }60 }
61}61}
6262
63gboolean
64syncdaemon_is_connected (void)
65{
66 GHashTable *return_value;
67 gboolean is_connected = FALSE;
68 GError *error = NULL;
69
70 syncdaemon_init ();
71
72 if (dbus_g_proxy_call (status_proxy, "current_status", &error,
73 G_TYPE_INVALID,
74 dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING), &return_value,
75 G_TYPE_INVALID)) {
76 is_connected = g_strcmp0 (g_hash_table_lookup (return_value, "is_connected"), "True") == 0;
77
78 g_hash_table_destroy (return_value);
79 } else {
80 g_warning ("Error calling current_status: %s", error->message);
81 g_error_free (error);
82 }
83
84 return is_connected;
85}
86
63void87void
64syncdaemon_connect (void)88syncdaemon_connect (void)
65{89{
@@ -67,6 +91,11 @@
6791
68 syncdaemon_init ();92 syncdaemon_init ();
6993
94 if (syncdaemon_is_connected ()) {
95 g_warning ("Syncdaemon already connected, not connecting again");
96 return;
97 }
98
70 /* Make the syncdaemon connect if it's not connected */99 /* Make the syncdaemon connect if it's not connected */
71 error = NULL;100 error = NULL;
72101
@@ -103,7 +132,8 @@
103 GPtrArray *return_value;132 GPtrArray *return_value;
104 GHashTable *downloads = NULL;133 GHashTable *downloads = NULL;
105134
106 syncdaemon_init ();135 /* Make sure we are connected when we get here */
136 syncdaemon_connect ();
107137
108 /* Ask the syncdaemon about current downloads */138 /* Ask the syncdaemon about current downloads */
109 error = NULL;139 error = NULL;
110140
=== modified file 'libubuntuone/syncdaemon.h'
--- libubuntuone/syncdaemon.h 2010-03-05 17:15:53 +0000
+++ libubuntuone/syncdaemon.h 2010-03-25 09:39:17 +0000
@@ -33,6 +33,7 @@
33} SyncdaemonDownload;33} SyncdaemonDownload;
3434
35void syncdaemon_init (void);35void syncdaemon_init (void);
36gboolean syncdaemon_is_connected (void);
36void syncdaemon_connect (void);37void syncdaemon_connect (void);
37void syncdaemon_finalize (void);38void syncdaemon_finalize (void);
38GHashTable *syncdaemon_get_current_downloads (void);39GHashTable *syncdaemon_get_current_downloads (void);
3940
=== modified file 'libubuntuone/u1-music-store.c'
--- libubuntuone/u1-music-store.c 2010-03-24 20:45:23 +0000
+++ libubuntuone/u1-music-store.c 2010-03-25 09:39:17 +0000
@@ -405,8 +405,7 @@
405 load_internal_html_page (web_view, U1_OUTSIDE_DOMAIN_ERROR_PAGE, to_and_from_error_uris);405 load_internal_html_page (web_view, U1_OUTSIDE_DOMAIN_ERROR_PAGE, to_and_from_error_uris);
406 g_free (to_and_from_error_uris);406 g_free (to_and_from_error_uris);
407 }407 }
408 }408 } else if (!g_strcmp0 ((const gchar *) parsed_uri->host, "one.ubuntu.com")) {
409 if (!g_strcmp0 ((const gchar *) parsed_uri->host, "one.ubuntu.com")) {
410 /* host is one.ubuntu.com. It must not be the login page */409 /* host is one.ubuntu.com. It must not be the login page */
411 if (g_str_has_prefix (parsed_uri->path, "/auth/")) {410 if (g_str_has_prefix (parsed_uri->path, "/auth/")) {
412 /* trying to log the user into o.u.c inside the webview. Die. */411 /* trying to log the user into o.u.c inside the webview. Die. */
@@ -426,8 +425,7 @@
426 }425 }
427 g_free (to_and_from_error_uris);426 g_free (to_and_from_error_uris);
428 }427 }
429 }428 } else if (!g_strcmp0 ((const gchar *) parsed_uri->host, "login.ubuntu.com")) {
430 if (!g_strcmp0 ((const gchar *) parsed_uri->host, "login.ubuntu.com")) {
431 /* host is SSO. Die. */429 /* host is SSO. Die. */
432 gchar *real_url;430 gchar *real_url;
433 gchar *to_and_from_error_uris;431 gchar *to_and_from_error_uris;

Subscribers

People subscribed via source and target branches