Merge lp:~dobey/ubuntuone-client/emblem-tweaking into lp:ubuntuone-client

Proposed by dobey
Status: Merged
Approved by: Elliot Murphy
Approved revision: 245
Merged at revision: not available
Proposed branch: lp:~dobey/ubuntuone-client/emblem-tweaking
Merge into: lp:ubuntuone-client
Diff against target: 159 lines
1 file modified
nautilus/ubuntuone-nautilus.c (+81/-3)
To merge this branch: bzr merge lp:~dobey/ubuntuone-client/emblem-tweaking
Reviewer Review Type Date Requested Status
Elliot Murphy (community) Approve
Review via email: mp+13145@code.launchpad.net

Commit message

Get the shares list when we load up the location bar
Get the metadata for files and add them to a list of updated/needs updating
Add emblems for updated and needs updating (default to updated)

To post a comment you must log in.
Revision history for this message
Elliot Murphy (statik) wrote :

looks good and builds fine.

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 2009-09-29 20:51:14 +0000
3+++ nautilus/ubuntuone-nautilus.c 2009-10-09 22:21:14 +0000
4@@ -73,6 +73,9 @@
5 GHashTable * uploads;
6 GHashTable * downloads;
7 GHashTable * shares;
8+ /* Lists of sync/unsync'd files */
9+ GHashTable * updated;
10+ GHashTable * needsupdating;
11
12 /* Extra data we need to free on finalization */
13 ShareCBData * share_cb_data;
14@@ -88,6 +91,9 @@
15 static void ubuntuone_nautilus_register_type (GTypeModule * module);
16
17 /* DBus signal and async method call handlers */
18+static void ubuntuone_nautilus_update_meta (DBusGProxy * proxy,
19+ DBusGProxyCall * call_id,
20+ gpointer user_data);
21 static void ubuntuone_nautilus_state_toggled (DBusGProxy * proxy,
22 DBusGProxyCall * call_id,
23 gpointer user_data);
24@@ -161,15 +167,28 @@
25 path = g_filename_from_uri (nautilus_file_info_get_uri (file), NULL, NULL);
26
27 if (path) {
28- if (g_hash_table_lookup (uon->uploads, path))
29- nautilus_file_info_add_emblem (file, "ubuntuone-updating");
30+ if (!g_hash_table_lookup (uon->updated, path) &&
31+ !g_hash_table_lookup (uon->needsupdating, path)) {
32+ /* Add the synchronized emblem anyway, and update later */
33+ nautilus_file_info_add_emblem (file, "ubuntuone-synchronized");
34+ dbus_g_proxy_begin_call (uon->u1_fs, "get_metadata",
35+ ubuntuone_nautilus_update_meta, uon,
36+ NULL, G_TYPE_STRING, path, G_TYPE_INVALID);
37+ goto updating_meta;
38+ }
39
40- if (g_hash_table_lookup (uon->downloads, path))
41+ if (g_hash_table_lookup (uon->uploads, path) ||
42+ g_hash_table_lookup (uon->downloads, path))
43 nautilus_file_info_add_emblem (file, "ubuntuone-updating");
44+ else if (g_hash_table_lookup (uon->updated, path))
45+ nautilus_file_info_add_emblem (file, "ubuntuone-synchronized");
46+ else if (g_hash_table_lookup (uon->needsupdating, path))
47+ nautilus_file_info_add_emblem (file, "ubuntuone-unsynchronized");
48
49 if (g_hash_table_lookup (uon->shares, path))
50 nautilus_file_info_add_emblem (file, "shared");
51
52+ updating_meta:
53 g_free (path);
54 }
55
56@@ -255,6 +274,11 @@
57 if (!path || !ubuntuone_is_storagefs (uon, path))
58 goto location_done;
59
60+ /* Update the list of shared folders - ok to call dbus now */
61+ dbus_g_proxy_begin_call (uon->u1_shares, "get_shared",
62+ ubuntuone_nautilus_got_shared, uon,
63+ NULL, G_TYPE_INVALID);
64+
65 hbox = gtk_hbox_new (FALSE, 6);
66 labeltext = g_strdup_printf ("<b>Ubuntu One</b> %s", _("File Sharing"));
67 label = gtk_label_new (labeltext);
68@@ -537,6 +561,8 @@
69 uon->uploads = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
70 uon->downloads = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
71 uon->shares = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
72+ uon->updated = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
73+ uon->needsupdating = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
74
75 /* Magic bag of holding +10:
76 * We store some button widgets in a hash table here, so that we can
77@@ -674,6 +700,12 @@
78 g_hash_table_destroy (uon->shares);
79 uon->shares = NULL;
80
81+ g_hash_table_destroy (uon->updated);
82+ uon->updated = NULL;
83+
84+ g_hash_table_destroy (uon->needsupdating);
85+ uon->needsupdating = NULL;
86+
87 g_hash_table_destroy (uon->buttons);
88 uon->buttons = NULL;
89 }
90@@ -737,6 +769,40 @@
91
92
93 /* DBus signal handlers and async method call handlers */
94+static void ubuntuone_nautilus_update_meta (DBusGProxy * proxy,
95+ DBusGProxyCall * call_id,
96+ gpointer user_data) {
97+ UbuntuOneNautilus * uon;
98+ GHashTable * metadata;
99+ GError * error = NULL;
100+ gchar * local, * server, * path, * new_path;
101+
102+ g_return_if_fail (proxy != NULL);
103+
104+ if (!dbus_g_proxy_end_call (proxy, call_id, &error,
105+ dbus_g_type_get_map ("GHashTable",
106+ G_TYPE_STRING,
107+ G_TYPE_STRING),
108+ &metadata,
109+ G_TYPE_INVALID)) {
110+ g_warning ("ERROR: %s", error->message);
111+ return;
112+ }
113+
114+ uon = UBUNTUONE_NAUTILUS (user_data);
115+
116+ path = g_hash_table_lookup (metadata, "path");
117+ local = g_hash_table_lookup (metadata, "local_hash");
118+ server = g_hash_table_lookup (metadata, "server_hash");
119+
120+ new_path = g_strdup (path);
121+ if (local && server && strcmp (local, server) == 0)
122+ g_hash_table_replace (uon->updated, new_path, new_path);
123+ else
124+ g_hash_table_replace (uon->needsupdating, new_path, new_path);
125+ utime (path, NULL);
126+}
127+
128 static void ubuntuone_nautilus_state_toggled (DBusGProxy * proxy,
129 DBusGProxyCall * call_id,
130 gpointer user_data) {
131@@ -848,8 +914,14 @@
132 gchar * path, GHashTable * info,
133 gpointer user_data) {
134 UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data);
135+ gchar * new_path;
136
137 g_hash_table_remove (uon->uploads, path);
138+ g_hash_table_remove (uon->needsupdating, path);
139+
140+ new_path = g_strdup (path);
141+ g_hash_table_replace (uon->updated, new_path, new_path);
142+
143 utime (path, NULL);
144 }
145
146@@ -870,8 +942,14 @@
147 GHashTable * info,
148 gpointer user_data) {
149 UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data);
150+ gchar * new_path;
151
152 g_hash_table_remove (uon->downloads, path);
153+ g_hash_table_remove (uon->needsupdating, path);
154+
155+ new_path = g_strdup (path);
156+ g_hash_table_replace (uon->updated, new_path, new_path);
157+
158 utime (path, NULL);
159 }
160

Subscribers

People subscribed via source and target branches