Merge lp:~chipaca/ubuntuone-client/public_files_list_v2 into lp:ubuntuone-client

Proposed by John Lenton
Status: Merged
Approved by: dobey
Approved revision: 504
Merged at revision: not available
Proposed branch: lp:~chipaca/ubuntuone-client/public_files_list_v2
Merge into: lp:ubuntuone-client
Diff against target: 103 lines (+52/-8)
1 file modified
nautilus/ubuntuone-nautilus.c (+52/-8)
To merge this branch: bzr merge lp:~chipaca/ubuntuone-client/public_files_list_v2
Reviewer Review Type Date Requested Status
dobey (community) Approve
Vincenzo Di Somma (community) Approve
Rodrigo Moya (community) Approve
Review via email: mp+23507@code.launchpad.net

Commit message

Plug nautilus into syncdaemon's get_public_files. Without this patch, nautilus has no information as to what files the user has previously published.

Description of the change

This makes the public files notification work! yay

To post a comment you must log in.
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

Looks ok to me

review: Approve
Revision history for this message
Vincenzo Di Somma (vds) :
review: Approve
503. By John Lenton

this is a fix for 562443

Revision history for this message
dobey (dobey) wrote :

I'd prefer to not have the additional got_one_public file function here, and just use a for loop instead. Is there any particular reason not to do so?

I'd also really like to know why exactly GSList wouldn't work for the signal here. We're using a GSList of GHashTables elsewhere for "aa{ss}" signatures from DBus, just fine. So, I'd like to understand why exactly it's failing here, but not elsewhere, and why a GPtrArray would work instead. It makes no sense to me at all.

Revision history for this message
John Lenton (chipaca) wrote :

I agree about avoiding got_one. Will change it to just a plain for, if that works.
And I agree it makes no sense. Yet it works. I'm not about to go spelunking into dbus_glib :)

504. By John Lenton

remove _got_one_ call

Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nautilus/ubuntuone-nautilus.c'
2--- nautilus/ubuntuone-nautilus.c 2010-04-14 23:52:06 +0000
3+++ nautilus/ubuntuone-nautilus.c 2010-04-16 16:25:49 +0000
4@@ -164,6 +164,12 @@
5 GHashTable * hash,
6 gchar * error,
7 gpointer user_data);
8+static void ubuntuone_nautilus_got_public_files (DBusGProxy * proxy,
9+ GPtrArray * files,
10+ gpointer user_data);
11+static void ubuntuone_nautilus_public_files_list_error (DBusGProxy * proxy,
12+ gchar * error,
13+ gpointer user_data);
14 static void ubuntuone_nautilus_share_created (DBusGProxy * proxy,
15 GHashTable * hash,
16 gpointer user_data);
17@@ -1083,6 +1089,25 @@
18 dbus_g_proxy_connect_signal (uon->u1_public, "PublicAccessChangeError",
19 G_CALLBACK (ubuntuone_nautilus_publish_error),
20 uon, NULL);
21+
22+ dbus_g_proxy_add_signal (uon->u1_public, "PublicFilesList",
23+ dbus_g_type_get_collection ("GPtrArray",
24+ dbus_g_type_get_map
25+ ("GHashTable",
26+ G_TYPE_STRING,
27+ G_TYPE_STRING)),
28+ G_TYPE_INVALID);
29+ dbus_g_proxy_connect_signal (uon->u1_public, "PublicFilesList",
30+ G_CALLBACK (ubuntuone_nautilus_got_public_files),
31+ uon, NULL);
32+
33+ dbus_g_proxy_add_signal (uon->u1_public, "PublicFilesListError",
34+ G_TYPE_STRING,
35+ G_TYPE_INVALID);
36+ dbus_g_proxy_connect_signal (uon->u1_public, "PublicFilesListError",
37+ G_CALLBACK (ubuntuone_nautilus_public_files_list_error),
38+ uon, NULL);
39+
40 }
41
42 static void ubuntuone_nautilus_class_init (UbuntuOneNautilusClass * klass) {
43@@ -1343,11 +1368,9 @@
44 gpointer user_data) {
45 UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data);
46 gchar * status;
47- gchar * is_online;
48- gchar * is_connected;
49+ gboolean is_online;
50
51- is_online = g_hash_table_lookup (hash, "is_online");
52- is_connected = g_hash_table_lookup (hash, "is_connected");
53+ is_online = g_strcmp0(g_hash_table_lookup (hash, "is_online"), "True") == 0;
54 status = g_hash_table_lookup (hash, "name");
55
56 /* Get the root when we get a status change signal, if we haven't yet */
57@@ -1362,14 +1385,13 @@
58 ubuntuone_nautilus_got_udfs, uon,
59 NULL, G_TYPE_INVALID);
60
61-#if 0
62- /* The following code is disabled, for the time being. lp:562443 */
63 /* Get the list of public files if we haven't already */
64- if (!uon->gotpubs)
65+ if (is_online && !uon->gotpubs) {
66 dbus_g_proxy_begin_call (uon->u1_public, "get_public_files",
67 ubuntuone_nautilus_end_dbus_call, uon,
68 NULL, G_TYPE_INVALID);
69-#endif
70+ uon->gotpubs = TRUE;
71+ }
72 }
73
74 static void ubuntuone_nautilus_upload_started (DBusGProxy * proxy,
75@@ -1505,6 +1527,28 @@
76 ubuntuone_nautilus_file_published (proxy, hash, user_data);
77 }
78
79+static void ubuntuone_nautilus_got_public_files (DBusGProxy * proxy,
80+ GPtrArray * files,
81+ gpointer user_data) {
82+ UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data);
83+ int i;
84+
85+ g_hash_table_remove_all (uon->public);
86+ for (i = 0; i < files->len; i++)
87+ g_hash_table_insert (uon->public,
88+ g_strdup (g_hash_table_lookup (files->pdata[i], "path")),
89+ g_strdup (g_hash_table_lookup (files->pdata[i], "public_url")));
90+}
91+
92+static void ubuntuone_nautilus_public_files_list_error (DBusGProxy * proxy,
93+ gchar * error,
94+ gpointer user_data) {
95+ UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data);
96+ /* the get_public_files call failed. We unset gotpubs, so the call
97+ is retried when the syncdaemon next tells us it's online */
98+ uon->gotpubs = FALSE;
99+}
100+
101 static void ubuntuone_nautilus_share_created (DBusGProxy * proxy,
102 GHashTable * hash,
103 gpointer user_data) {

Subscribers

People subscribed via source and target branches