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
1=== modified file 'libubuntuone/syncdaemon.c'
2--- libubuntuone/syncdaemon.c 2010-03-05 17:15:53 +0000
3+++ libubuntuone/syncdaemon.c 2010-03-25 09:39:17 +0000
4@@ -60,6 +60,30 @@
5 }
6 }
7
8+gboolean
9+syncdaemon_is_connected (void)
10+{
11+ GHashTable *return_value;
12+ gboolean is_connected = FALSE;
13+ GError *error = NULL;
14+
15+ syncdaemon_init ();
16+
17+ if (dbus_g_proxy_call (status_proxy, "current_status", &error,
18+ G_TYPE_INVALID,
19+ dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING), &return_value,
20+ G_TYPE_INVALID)) {
21+ is_connected = g_strcmp0 (g_hash_table_lookup (return_value, "is_connected"), "True") == 0;
22+
23+ g_hash_table_destroy (return_value);
24+ } else {
25+ g_warning ("Error calling current_status: %s", error->message);
26+ g_error_free (error);
27+ }
28+
29+ return is_connected;
30+}
31+
32 void
33 syncdaemon_connect (void)
34 {
35@@ -67,6 +91,11 @@
36
37 syncdaemon_init ();
38
39+ if (syncdaemon_is_connected ()) {
40+ g_warning ("Syncdaemon already connected, not connecting again");
41+ return;
42+ }
43+
44 /* Make the syncdaemon connect if it's not connected */
45 error = NULL;
46
47@@ -103,7 +132,8 @@
48 GPtrArray *return_value;
49 GHashTable *downloads = NULL;
50
51- syncdaemon_init ();
52+ /* Make sure we are connected when we get here */
53+ syncdaemon_connect ();
54
55 /* Ask the syncdaemon about current downloads */
56 error = NULL;
57
58=== modified file 'libubuntuone/syncdaemon.h'
59--- libubuntuone/syncdaemon.h 2010-03-05 17:15:53 +0000
60+++ libubuntuone/syncdaemon.h 2010-03-25 09:39:17 +0000
61@@ -33,6 +33,7 @@
62 } SyncdaemonDownload;
63
64 void syncdaemon_init (void);
65+gboolean syncdaemon_is_connected (void);
66 void syncdaemon_connect (void);
67 void syncdaemon_finalize (void);
68 GHashTable *syncdaemon_get_current_downloads (void);
69
70=== modified file 'libubuntuone/u1-music-store.c'
71--- libubuntuone/u1-music-store.c 2010-03-24 20:45:23 +0000
72+++ libubuntuone/u1-music-store.c 2010-03-25 09:39:17 +0000
73@@ -405,8 +405,7 @@
74 load_internal_html_page (web_view, U1_OUTSIDE_DOMAIN_ERROR_PAGE, to_and_from_error_uris);
75 g_free (to_and_from_error_uris);
76 }
77- }
78- if (!g_strcmp0 ((const gchar *) parsed_uri->host, "one.ubuntu.com")) {
79+ } else if (!g_strcmp0 ((const gchar *) parsed_uri->host, "one.ubuntu.com")) {
80 /* host is one.ubuntu.com. It must not be the login page */
81 if (g_str_has_prefix (parsed_uri->path, "/auth/")) {
82 /* trying to log the user into o.u.c inside the webview. Die. */
83@@ -426,8 +425,7 @@
84 }
85 g_free (to_and_from_error_uris);
86 }
87- }
88- if (!g_strcmp0 ((const gchar *) parsed_uri->host, "login.ubuntu.com")) {
89+ } else if (!g_strcmp0 ((const gchar *) parsed_uri->host, "login.ubuntu.com")) {
90 /* host is SSO. Die. */
91 gchar *real_url;
92 gchar *to_and_from_error_uris;

Subscribers

People subscribed via source and target branches