Merge lp:~rodrigo-moya/ubuntuone-client/final-nautilus-refactor into lp:ubuntuone-client

Proposed by Rodrigo Moya
Status: Merged
Approved by: dobey
Approved revision: 744
Merged at revision: 742
Proposed branch: lp:~rodrigo-moya/ubuntuone-client/final-nautilus-refactor
Merge into: lp:ubuntuone-client
Diff against target: 668 lines (+209/-149)
11 files modified
libsyncdaemon/syncdaemon-daemon.c (+10/-10)
libsyncdaemon/syncdaemon-daemon.h (+1/-1)
libsyncdaemon/syncdaemon-publicfiles-interface.c (+44/-14)
libsyncdaemon/syncdaemon-publicfiles-interface.h (+1/-1)
libsyncdaemon/syncdaemon-shares-interface.c (+22/-7)
libsyncdaemon/syncdaemon-shares-interface.h (+1/-1)
nautilus/context-menu.c (+5/-7)
nautilus/file-watcher.c (+77/-64)
nautilus/ubuntuone-nautilus.c (+8/-31)
nautilus/ubuntuone-nautilus.h (+1/-4)
nautilus/utils.c (+39/-9)
To merge this branch: bzr merge lp:~rodrigo-moya/ubuntuone-client/final-nautilus-refactor
Reviewer Review Type Date Requested Status
dobey (community) Approve
John Lenton (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+38728@code.launchpad.net

Commit message

- Cache public files in libsyncdaemon
- Fix issue with emblems disappearing

Description of the change

- Cache public files in libsyncdaemon
- Fix issue with emblems disappearing

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

I'm getting the following, but rodrigo says he will fix this on another branch:

** (nautilus:9918): WARNING **: Failed calling get_metadata_and_quick_tree_synced: Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/dbus/service.py", line 702, in _message_cb
    retval = candidate_method(self, *args, **keywords)
  File "/usr/lib/pymodules/python2.6/ubuntuone/syncdaemon/dbus_interface.py", line 1027, in get_metadata_and_quick_tree_synced
    mdobj = self.fs_manager.get_by_path(real_path)
  File "/usr/lib/pymodules/python2.6/ubuntuone/syncdaemon/filesystem_manager.py", line 607, in get_by_path
    mdid = self._idx_path[path]
KeyError: '/home/nessita/.local/share/ubuntuone/shares'

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Also reported bug #663333.

Other than that, emblems does show up for themes ubuntu-* and humanity-* (other themes doesn't show the synchronized emblem).

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Both issues (KeyError and missing emblems) are reported on bug #442504 and bug #645299.

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

syncdaemon-publicfiles-interface.c: In function ‘syncdaemon_publicfiles_interface_get_public_files’:
syncdaemon-publicfiles-interface.c:236: error: ‘finfo’ may be used uninitialized in this function
syncdaemon-publicfiles-interface.c:235: error: ‘path’ may be used uninitialized in this function
make: *** [syncdaemon-publicfiles-interface.lo] Error 1

review: Needs Fixing
744. By Rodrigo Moya

Fix building with --enable-debug

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 'libsyncdaemon/syncdaemon-daemon.c'
2--- libsyncdaemon/syncdaemon-daemon.c 2010-10-21 11:41:33 +0000
3+++ libsyncdaemon/syncdaemon-daemon.c 2010-11-03 15:01:52 +0000
4@@ -74,7 +74,7 @@
5 FOLDER_SUBSCRIBED_SIGNAL,
6 FOLDER_UNSUBSCRIBED_SIGNAL,
7 FILE_PUBLISHED_SIGNAL,
8- GOT_PUBLISHED_FILES_SIGNAL,
9+ FILE_UNPUBLISHED_SIGNAL,
10 SHARE_CREATED_SIGNAL,
11 SHARE_DELETED_SIGNAL,
12 DOWNLOAD_STARTED_SIGNAL,
13@@ -218,15 +218,15 @@
14 G_TYPE_NONE, 2,
15 G_TYPE_BOOLEAN,
16 G_TYPE_OBJECT);
17- daemon_signals[GOT_PUBLISHED_FILES_SIGNAL] = g_signal_new ("got_published_files",
18- G_TYPE_FROM_CLASS (klass),
19- (GSignalFlags) G_SIGNAL_RUN_LAST,
20- G_STRUCT_OFFSET (SyncdaemonDaemonClass, got_published_files),
21- NULL, NULL,
22- _syncdaemon_marshal_VOID__BOOLEAN_POINTER,
23- G_TYPE_NONE, 2,
24- G_TYPE_BOOLEAN,
25- G_TYPE_POINTER);
26+ daemon_signals[FILE_UNPUBLISHED_SIGNAL] = g_signal_new ("file_unpublished",
27+ G_TYPE_FROM_CLASS (klass),
28+ (GSignalFlags) G_SIGNAL_RUN_LAST,
29+ G_STRUCT_OFFSET (SyncdaemonDaemonClass, file_unpublished),
30+ NULL, NULL,
31+ _syncdaemon_marshal_VOID__BOOLEAN_OBJECT,
32+ G_TYPE_NONE, 2,
33+ G_TYPE_BOOLEAN,
34+ G_TYPE_OBJECT);
35 daemon_signals[SHARE_CREATED_SIGNAL] = g_signal_new ("share_created",
36 G_TYPE_FROM_CLASS (klass),
37 (GSignalFlags) G_SIGNAL_RUN_LAST,
38
39=== modified file 'libsyncdaemon/syncdaemon-daemon.h'
40--- libsyncdaemon/syncdaemon-daemon.h 2010-10-21 11:41:33 +0000
41+++ libsyncdaemon/syncdaemon-daemon.h 2010-11-03 15:01:52 +0000
42@@ -67,7 +67,7 @@
43 void (* folder_unsubscribed) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info);
44
45 void (* file_published) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFileInfo *file_info);
46- void (* got_published_files) (SyncdaemonDaemon *daemon, gboolean success, GSList *files);
47+ void (* file_unpublished) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFileInfo *file_info);
48
49 void (* share_created) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info);
50 void (* share_deleted) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info);
51
52=== modified file 'libsyncdaemon/syncdaemon-publicfiles-interface.c'
53--- libsyncdaemon/syncdaemon-publicfiles-interface.c 2010-08-25 18:18:56 +0000
54+++ libsyncdaemon/syncdaemon-publicfiles-interface.c 2010-11-03 15:01:52 +0000
55@@ -27,6 +27,7 @@
56
57 struct _SyncdaemonPublicfilesInterfacePrivate {
58 GObject *proxy;
59+ GHashTable *public_files;
60 };
61
62 static void
63@@ -35,6 +36,9 @@
64 SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (object);
65
66 if (interface->priv != NULL) {
67+ if (interface->priv->public_files != NULL)
68+ g_hash_table_destroy (interface->priv->public_files);
69+
70 g_free (interface->priv);
71 }
72
73@@ -60,7 +64,10 @@
74 SyncdaemonFileInfo *finfo;
75
76 finfo = syncdaemon_file_info_new_from_hash_table (hash);
77- g_signal_emit_by_name (daemon, "file_published", TRUE, finfo);
78+ if (syncdaemon_file_info_get_is_public (finfo))
79+ g_signal_emit_by_name (daemon, "file_published", TRUE, finfo);
80+ else
81+ g_signal_emit_by_name (daemon, "file_unpublished", TRUE, finfo);
82
83 g_object_unref (G_OBJECT (finfo));
84 }
85@@ -72,21 +79,24 @@
86 SyncdaemonDaemon *daemon = NULL;
87 SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (user_data);
88
89+ if (interface->priv->public_files == NULL) {
90+ interface->priv->public_files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
91+ }
92+
93 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
94 if (daemon != NULL) {
95- GSList *finfo_list = NULL;
96 guint i;
97
98 for (i = 0; i < files->len; i++) {
99 SyncdaemonFileInfo *finfo = syncdaemon_file_info_new_from_hash_table (g_ptr_array_index (files, i));
100
101- finfo_list = g_slist_append (finfo_list, finfo);
102+ if (SYNCDAEMON_IS_FILE_INFO (finfo)) {
103+ g_hash_table_insert (interface->priv->public_files,
104+ g_strdup (syncdaemon_file_info_get_path (finfo)),
105+ finfo);
106+ g_signal_emit_by_name (daemon, "file_published", TRUE, finfo);
107+ }
108 }
109-
110- g_signal_emit_by_name (daemon, "got_published_files", TRUE, finfo_list);
111-
112- g_slist_foreach (finfo_list, (GFunc) g_object_unref, NULL);
113- g_slist_free (finfo_list);
114 }
115 }
116
117@@ -198,13 +208,33 @@
118
119 /**
120 * syncdaemon_publicfiles_interface_get_public_files:
121+ *
122+ * Return value: A #GSList of #SyncdaemonFileInfo objects, each of which describes
123+ * a published file for the user. When no longer needed, this list should be
124+ * freed by calling g_slist_free, but the data within the list should never
125+ * be freed, as it belongs to the library.
126 */
127-void
128+GSList *
129 syncdaemon_publicfiles_interface_get_public_files (SyncdaemonPublicfilesInterface *interface)
130 {
131- g_return_if_fail (SYNCDAEMON_IS_PUBLICFILES_INTERFACE (interface));
132-
133- dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "get_public_files",
134- no_output_dbus_call_ended_cb, interface, NULL,
135- G_TYPE_INVALID);
136+ GSList *files_list = NULL;
137+
138+ g_return_val_if_fail (SYNCDAEMON_IS_PUBLICFILES_INTERFACE (interface), NULL);
139+
140+ if (interface->priv->public_files == NULL) {
141+ /* Only retrieve list if we haven't yet */
142+ dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "get_public_files",
143+ no_output_dbus_call_ended_cb, interface, NULL,
144+ G_TYPE_INVALID);
145+ } else {
146+ GHashTableIter iter;
147+ gchar *path;
148+ SyncdaemonFileInfo *finfo;
149+
150+ g_hash_table_iter_init (&iter, interface->priv->public_files);
151+ while (g_hash_table_iter_next (&iter, (gpointer *) &path, (gpointer *) &finfo))
152+ files_list = g_slist_append (files_list, finfo);
153+ }
154+
155+ return files_list;
156 }
157
158=== modified file 'libsyncdaemon/syncdaemon-publicfiles-interface.h'
159--- libsyncdaemon/syncdaemon-publicfiles-interface.h 2010-06-04 15:36:24 +0000
160+++ libsyncdaemon/syncdaemon-publicfiles-interface.h 2010-11-03 15:01:52 +0000
161@@ -53,7 +53,7 @@
162 const gchar *share_id,
163 const gchar *node_id,
164 gboolean is_public);
165-void syncdaemon_publicfiles_interface_get_public_files (SyncdaemonPublicfilesInterface *interface);
166+GSList *syncdaemon_publicfiles_interface_get_public_files (SyncdaemonPublicfilesInterface *interface);
167
168 G_END_DECLS
169
170
171=== modified file 'libsyncdaemon/syncdaemon-shares-interface.c'
172--- libsyncdaemon/syncdaemon-shares-interface.c 2010-07-21 11:40:57 +0000
173+++ libsyncdaemon/syncdaemon-shares-interface.c 2010-11-03 15:01:52 +0000
174@@ -273,15 +273,30 @@
175 * syncdaemon_shares_interface_delete:
176 */
177 void
178-syncdaemon_shares_interface_delete (SyncdaemonSharesInterface *interface, const gchar *share_id)
179+syncdaemon_shares_interface_delete (SyncdaemonSharesInterface *interface, const gchar *path)
180 {
181+ GSList *shares, *l;
182+ const gchar *share_id = NULL;
183+
184 g_return_if_fail (SYNCDAEMON_IS_SHARES_INTERFACE (interface));
185- g_return_if_fail (share_id != NULL);
186-
187- dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "delete_share",
188- no_output_dbus_call_ended_cb, interface, NULL,
189- G_TYPE_STRING, share_id,
190- G_TYPE_INVALID);
191+ g_return_if_fail (path != NULL);
192+
193+ shares = syncdaemon_shares_interface_get_shared (interface);
194+ for (l = shares; l != NULL; l = l->next) {
195+ SyncdaemonShareInfo *sinfo = SYNCDAEMON_SHARE_INFO (l->data);
196+
197+ if (g_str_equal (path, syncdaemon_share_info_get_path (sinfo)))
198+ share_id = syncdaemon_share_info_get_node_id (sinfo);
199+ }
200+
201+ if (share_id != NULL) {
202+ dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "delete_share",
203+ no_output_dbus_call_ended_cb, interface, NULL,
204+ G_TYPE_STRING, share_id,
205+ G_TYPE_INVALID);
206+ }
207+
208+ g_slist_free (shares);
209 }
210
211 /**
212
213=== modified file 'libsyncdaemon/syncdaemon-shares-interface.h'
214--- libsyncdaemon/syncdaemon-shares-interface.h 2010-07-20 14:10:43 +0000
215+++ libsyncdaemon/syncdaemon-shares-interface.h 2010-11-03 15:01:52 +0000
216@@ -55,7 +55,7 @@
217 GSList *usernames,
218 const gchar *name,
219 gboolean allow_modifications);
220-void syncdaemon_shares_interface_delete (SyncdaemonSharesInterface *interface, const gchar *share_id);
221+void syncdaemon_shares_interface_delete (SyncdaemonSharesInterface *interface, const gchar *path);
222 GSList *syncdaemon_shares_interface_get_shared (SyncdaemonSharesInterface *interface);
223 GSList *syncdaemon_shares_interface_get_shares (SyncdaemonSharesInterface *interface);
224 void syncdaemon_shares_interface_refresh (SyncdaemonSharesInterface *interface);
225
226=== modified file 'nautilus/context-menu.c'
227--- nautilus/context-menu.c 2010-10-05 12:47:32 +0000
228+++ nautilus/context-menu.c 2010-11-03 15:01:52 +0000
229@@ -138,7 +138,7 @@
230 (SyncdaemonGotMetadataFunc) got_public_meta, data);
231 }
232
233- g_hash_table_replace (data->uon->public, g_strdup (data->path), UPDATE_PENDING);
234+ g_hash_table_replace (data->uon->public, g_strdup (data->path), g_strdup (UPDATE_PENDING));
235 file_watcher_update_path (data->uon->file_watcher, data->path);
236 }
237
238@@ -156,14 +156,11 @@
239 unshare_folder_cb (NautilusMenuItem *item, gpointer user_data)
240 {
241 MenuCallbackData * data = (MenuCallbackData *) user_data;
242- gchar * share_id;
243 SyncdaemonSharesInterface *interface;
244
245 interface = (SyncdaemonSharesInterface *) syncdaemon_daemon_get_shares_interface (data->uon->syncdaemon);
246- if (interface != NULL) {
247- share_id = g_hash_table_lookup (data->uon->shares, data->path);
248- syncdaemon_shares_interface_delete (interface, share_id);
249- }
250+ if (interface != NULL)
251+ syncdaemon_shares_interface_delete (interface, data->path);
252 }
253
254 static void
255@@ -217,7 +214,8 @@
256 if (strcmp (item, UPDATE_PENDING) == 0)
257 is_pending = TRUE;
258 }
259- if (g_hash_table_lookup (uon->shares, path) != NULL)
260+
261+ if (ubuntuone_is_folder_shared (uon, path))
262 is_shared = TRUE;
263
264 is_dir = nautilus_file_info_is_directory (file);
265
266=== modified file 'nautilus/file-watcher.c'
267--- nautilus/file-watcher.c 2010-10-08 07:46:41 +0000
268+++ nautilus/file-watcher.c 2010-11-03 15:01:52 +0000
269@@ -29,13 +29,25 @@
270
271 G_DEFINE_TYPE(FileWatcher, file_watcher, G_TYPE_OBJECT)
272
273+static void observed_file_unrefed (gpointer user_data, GObject *where_the_object_was);
274+
275+static void
276+foreach_weak_unref (gpointer key, gpointer value, gpointer user_data)
277+{
278+ g_object_weak_unref (G_OBJECT (value),
279+ (GWeakNotify) observed_file_unrefed,
280+ user_data);
281+}
282+
283 static void
284 file_watcher_finalize (GObject *object)
285 {
286 FileWatcher *watcher = FILE_WATCHER (object);
287
288- if (watcher->files != NULL)
289+ if (watcher->files != NULL) {
290+ g_hash_table_foreach (watcher->files, (GHFunc) foreach_weak_unref, watcher);
291 g_hash_table_destroy (watcher->files);
292+ }
293
294 G_OBJECT_CLASS (file_watcher_parent_class)->finalize (object);
295 }
296@@ -52,7 +64,7 @@
297 file_watcher_init (FileWatcher *watcher)
298 {
299 watcher->uon = NULL;
300- watcher->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
301+ watcher->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
302 }
303
304 static void
305@@ -87,13 +99,7 @@
306
307 path = syncdaemon_share_info_get_path (share_info);
308 if (success) {
309- const gchar * id;
310-
311- id = syncdaemon_share_info_get_volume_id (share_info);
312- if (!g_hash_table_lookup (watcher->uon->shares, path)) {
313- g_hash_table_insert (watcher->uon->shares, g_strdup (path), g_strdup (id));
314- file_watcher_update_path (watcher, path);
315- }
316+ file_watcher_update_path (watcher, path);
317 } else {
318 ubuntuone_show_error_dialog (watcher->uon, _("Error creating share."),
319 _("There was an error sharing the folder '%s'"),
320@@ -112,7 +118,6 @@
321
322 path = syncdaemon_share_info_get_path (share_info);
323 if (success) {
324- g_hash_table_remove (watcher->uon->shares, path);
325 file_watcher_update_path (watcher, path);
326 } else {
327 ubuntuone_show_error_dialog (watcher->uon, _("Error deleting share."),
328@@ -186,7 +191,6 @@
329 g_hash_table_replace (watcher->uon->public, g_strdup (path), g_strdup (url));
330
331 file_watcher_update_path (watcher, path);
332- watcher->uon->gotpubs = TRUE;
333 } else {
334 ubuntuone_show_error_dialog (watcher->uon, _("Error publishing file."),
335 _("There was an error publishing file '%s'"),
336@@ -194,35 +198,6 @@
337 }
338 }
339
340-static void
341-got_public_files_cb (SyncdaemonDaemon *daemon,
342- gboolean success,
343- GSList *files,
344- gpointer user_data)
345-{
346- FileWatcher *watcher = FILE_WATCHER (user_data);
347-
348- if (success) {
349- GSList *l;
350-
351- g_hash_table_remove_all (watcher->uon->public);
352- for (l = files; l != NULL; l = l->next) {
353- const gchar *path;
354- SyncdaemonFileInfo *finfo = SYNCDAEMON_FILE_INFO (l->data);
355-
356- path = syncdaemon_file_info_get_path (finfo);
357- g_hash_table_insert (watcher->uon->public,
358- g_strdup (path),
359- g_strdup (syncdaemon_file_info_get_public_url (finfo)));
360-
361- file_watcher_update_path (watcher, path);
362- }
363- } else {
364- ubuntuone_show_error_dialog (watcher->uon, _("Error getting public files"),
365- _("There was an error getting the list of public files"));
366- }
367-}
368-
369 FileWatcher *
370 file_watcher_new (UbuntuOneNautilus *uon)
371 {
372@@ -260,8 +235,8 @@
373 /* Connect to public files-related signals */
374 g_signal_connect (G_OBJECT (uon->syncdaemon), "file_published",
375 G_CALLBACK (file_published_cb), watcher);
376- g_signal_connect (G_OBJECT (uon->syncdaemon), "got_published_files",
377- G_CALLBACK (got_public_files_cb), watcher);
378+ g_signal_connect (G_OBJECT (uon->syncdaemon), "file_unpublished",
379+ G_CALLBACK (file_published_cb), watcher);
380
381 return watcher;
382 }
383@@ -286,11 +261,25 @@
384 return is_shared;
385 }
386
387+static void
388+observed_file_unrefed (gpointer user_data, GObject *where_the_object_was)
389+{
390+ gchar *path;
391+ FileWatcher *watcher = FILE_WATCHER (user_data);
392+
393+ path = g_filename_from_uri (nautilus_file_info_get_uri (NAUTILUS_FILE_INFO (where_the_object_was)), NULL, NULL);
394+ if (g_hash_table_lookup (watcher->files, path))
395+ g_hash_table_remove (watcher->files, path);
396+
397+ g_free (path);
398+}
399+
400 void
401 file_watcher_add_file (FileWatcher *watcher, NautilusFileInfo *file)
402 {
403 gboolean is_root;
404 gchar *path = NULL;
405+ NautilusFileInfo *old_file;
406
407 g_return_if_fail (IS_FILE_WATCHER (watcher));
408
409@@ -299,7 +288,14 @@
410 return;
411
412 /* Always add it to the observed hash table, so that we can update emblems */
413- g_hash_table_insert (watcher->files, path, g_object_ref (file));
414+ if ((old_file = g_hash_table_lookup (watcher->files, path))) {
415+ g_object_weak_unref (G_OBJECT (old_file),
416+ (GWeakNotify) observed_file_unrefed, watcher);
417+ }
418+
419+ g_object_weak_ref (G_OBJECT (file),
420+ (GWeakNotify) observed_file_unrefed, watcher);
421+ g_hash_table_insert (watcher->files, g_strdup (path), file);
422
423 /* Retrieve metadata */
424 if (syncdaemon_daemon_is_folder_enabled (watcher->uon->syncdaemon, path, &is_root)) {
425@@ -312,32 +308,49 @@
426
427 metadata = syncdaemon_filesystem_interface_get_metadata (
428 SYNCDAEMON_FILESYSTEM_INTERFACE (interface), path, is_dir);
429-
430- if (syncdaemon_metadata_get_is_synced (metadata))
431- nautilus_file_info_add_emblem (file, "ubuntuone-synchronized");
432- else
433- nautilus_file_info_add_emblem (file, "ubuntuone-updating");
434-
435- if (is_dir) {
436- /* If it's a directory, check shares */
437- interface = syncdaemon_daemon_get_shares_interface (watcher->uon->syncdaemon);
438- if (check_for_shared_folder ((const gchar *) path,
439- syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface))) ||
440- check_for_shared_folder ((const gchar *) path,
441- syncdaemon_shares_interface_get_shares (SYNCDAEMON_SHARES_INTERFACE (interface)))) {
442- nautilus_file_info_add_emblem (file, "shared");
443+ if (SYNCDAEMON_IS_METADATA (metadata)) {
444+ if (syncdaemon_metadata_get_is_synced (metadata))
445+ nautilus_file_info_add_emblem (file, "ubuntuone-synchronized");
446+ else
447+ nautilus_file_info_add_emblem (file, "ubuntuone-updating");
448+
449+ if (is_dir) {
450+ /* If it's a directory, check shares */
451+ interface = syncdaemon_daemon_get_shares_interface (watcher->uon->syncdaemon);
452+ if (check_for_shared_folder ((const gchar *) path,
453+ syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface))) ||
454+ check_for_shared_folder ((const gchar *) path,
455+ syncdaemon_shares_interface_get_shares (SYNCDAEMON_SHARES_INTERFACE (interface)))) {
456+ nautilus_file_info_add_emblem (file, "shared");
457+ }
458+ } else {
459+ GSList *public_files, *l;
460+
461+ /* If it's a file, check for public files */
462+ interface = syncdaemon_daemon_get_publicfiles_interface (watcher->uon->syncdaemon);
463+ public_files = syncdaemon_publicfiles_interface_get_public_files (SYNCDAEMON_PUBLICFILES_INTERFACE (interface));
464+ for (l = public_files; l != NULL; l = l->next) {
465+ SyncdaemonFileInfo *file_info = SYNCDAEMON_FILE_INFO (l->data);
466+
467+ if (!SYNCDAEMON_IS_FILE_INFO (file_info))
468+ continue;
469+
470+ if (g_strcmp0 (path, syncdaemon_file_info_get_path (file_info)) == 0) {
471+ nautilus_file_info_add_emblem (file, "ubuntuone-public");
472+ break;
473+ }
474+ }
475+
476+ g_slist_free (public_files);
477 }
478- } else {
479- /* If it's a file, check for public files */
480+
481+ /* Free memory */
482+ g_object_unref (G_OBJECT (metadata));
483 }
484-
485- /* Free memory */
486- g_object_unref (G_OBJECT (metadata));
487 }
488 }
489
490- /* if (g_hash_table_lookup (watcher->uon->public, path)) */
491- /* nautilus_file_info_add_emblem (file, "ubuntuone-public"); */
492+ g_free (path);
493 }
494
495 void
496
497=== modified file 'nautilus/ubuntuone-nautilus.c'
498--- nautilus/ubuntuone-nautilus.c 2010-10-08 07:46:41 +0000
499+++ nautilus/ubuntuone-nautilus.c 2010-11-03 15:01:52 +0000
500@@ -172,9 +172,8 @@
501 ubuntuone_nautilus_instance_init (UbuntuOneNautilus * uon)
502 {
503 uon->connected = FALSE;
504- uon->shares = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
505 uon->udfs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
506- uon->public = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
507+ uon->public = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
508
509 uon->syncdaemon = syncdaemon_daemon_new ();
510 g_signal_connect (G_OBJECT (uon->syncdaemon), "ready",
511@@ -187,7 +186,6 @@
512 uon->managed = g_build_filename (g_get_home_dir (), "Ubuntu One", NULL);
513 uon->gotroot = FALSE;
514 uon->gotudfs = FALSE;
515- uon->gotpubs = FALSE;
516 }
517
518 static void
519@@ -209,9 +207,6 @@
520 if (uon->syncdaemon)
521 g_object_unref (uon->syncdaemon);
522
523- g_hash_table_destroy (uon->shares);
524- uon->shares = NULL;
525-
526 g_hash_table_destroy (uon->udfs);
527 uon->udfs = NULL;
528
529@@ -333,36 +328,18 @@
530 }
531 }
532
533- /* Get the list of shared folders */
534- interface = syncdaemon_daemon_get_shares_interface (uon->syncdaemon);
535- if (SYNCDAEMON_IS_SHARES_INTERFACE (interface)) {
536- GSList *shares;
537-
538- shares = syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface));
539- while (shares != NULL) {
540- const gchar *id, *path;
541- SyncdaemonShareInfo *share_info = SYNCDAEMON_SHARE_INFO (shares->data);
542-
543- /* This code is duplicated in file-watcher.c */
544- path = syncdaemon_share_info_get_path (share_info);
545- id = syncdaemon_share_info_get_volume_id (share_info);
546- if (!g_hash_table_lookup (uon->shares, path)) {
547- g_hash_table_insert (uon->shares, g_strdup (path), g_strdup (id));
548- file_watcher_update_path (uon->file_watcher, path);
549- }
550-
551- shares = g_slist_remove (shares, shares->data);
552- }
553- }
554-
555 /* Get the list of public files if we haven't already */
556- if (is_online && !uon->gotpubs) {
557+ if (is_online) {
558 SyncdaemonInterface *public;
559
560 public = syncdaemon_daemon_get_publicfiles_interface (uon->syncdaemon);
561 if (public != NULL) {
562- syncdaemon_publicfiles_interface_get_public_files (SYNCDAEMON_PUBLICFILES_INTERFACE (public));
563- uon->gotpubs = TRUE;
564+ GSList *files_list;
565+
566+ /* We just call it here so that libsyncdaemon caches it, but we discard
567+ the list, as we don't need it yet */
568+ files_list = syncdaemon_publicfiles_interface_get_public_files (SYNCDAEMON_PUBLICFILES_INTERFACE (public));
569+ g_slist_free (files_list);
570 }
571 }
572 }
573
574=== modified file 'nautilus/ubuntuone-nautilus.h'
575--- nautilus/ubuntuone-nautilus.h 2010-09-30 13:04:47 +0000
576+++ nautilus/ubuntuone-nautilus.h 2010-11-03 15:01:52 +0000
577@@ -50,10 +50,6 @@
578 /* Avoid calling get_rootdir and get_folders lots of times */
579 gboolean gotroot;
580 gboolean gotudfs;
581- gboolean gotpubs;
582-
583- /* Lists of ul/dl/shares for setting emblems */
584- GHashTable * shares;
585
586 /* Lists of public files and user defined folders */
587 GHashTable * public;
588@@ -67,6 +63,7 @@
589 GType ubuntuone_nautilus_get_type (void);
590
591 /* Utility functions */
592+gboolean ubuntuone_is_folder_shared (UbuntuOneNautilus *uon, const gchar *path);
593 gboolean ubuntuone_is_location_bar_enabled (void);
594
595 gboolean ubuntuone_check_shares_and_public_files (UbuntuOneNautilus *uon,
596
597=== modified file 'nautilus/utils.c'
598--- nautilus/utils.c 2010-09-29 11:12:35 +0000
599+++ nautilus/utils.c 2010-11-03 15:01:52 +0000
600@@ -59,22 +59,27 @@
601 }
602
603 /* Now check for published files */
604- if (uon->gotpubs) {
605- GHashTableIter iter;
606- gchar *key, *value;
607-
608- g_hash_table_iter_init (&iter, uon->public);
609- while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) {
610- if (g_str_has_prefix (key, syncdaemon_folder_info_get_path (folder_info))) {
611+ interface = syncdaemon_daemon_get_publicfiles_interface (uon->syncdaemon);
612+ if (SYNCDAEMON_IS_PUBLICFILES_INTERFACE (interface)) {
613+ GSList *public_files, *l;
614+ public_files = syncdaemon_publicfiles_interface_get_public_files (SYNCDAEMON_PUBLICFILES_INTERFACE (interface));
615+
616+ for (l = public_files; l != NULL; l = l->next) {
617+ const gchar *path;
618+
619+ path = syncdaemon_file_info_get_path (SYNCDAEMON_FILE_INFO (l->data));
620+ if (g_str_has_prefix (path, syncdaemon_folder_info_get_path (folder_info))) {
621 has_published = TRUE;
622
623 question = g_string_append (question, "\t- ");
624- question = g_string_append (question, key);
625+ question = g_string_append (question, path);
626 question = g_string_append (question, _(" (Published at "));
627- question = g_string_append (question, value);
628+ question = g_string_append (question, syncdaemon_file_info_get_public_url (SYNCDAEMON_FILE_INFO (l->data)));
629 question = g_string_append (question, ")\n");
630 }
631 }
632+
633+ g_slist_free (public_files);
634 }
635
636 if (has_shares || has_published) {
637@@ -101,6 +106,31 @@
638 }
639
640 gboolean
641+ubuntuone_is_folder_shared (UbuntuOneNautilus *uon, const gchar *path)
642+{
643+ GSList *shares, *l;
644+ SyncdaemonInterface *interface;
645+ gboolean is_shared = FALSE;
646+
647+ interface = syncdaemon_daemon_get_shares_interface (uon->syncdaemon);
648+ if (SYNCDAEMON_IS_SHARES_INTERFACE (interface)) {
649+ shares = syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface));
650+ for (l = shares; l != NULL; l = l->next) {
651+ SyncdaemonShareInfo *share_info = SYNCDAEMON_SHARE_INFO (l->data);
652+
653+ if (g_strcmp0 (syncdaemon_share_info_get_path (share_info), path) == 0) {
654+ is_shared = TRUE;
655+ break;
656+ }
657+ }
658+
659+ g_slist_free (shares);
660+ }
661+
662+ return is_shared;
663+}
664+
665+gboolean
666 ubuntuone_is_location_bar_enabled (void)
667 {
668 GConfClient *conf_client;

Subscribers

People subscribed via source and target branches