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
=== modified file 'libsyncdaemon/syncdaemon-daemon.c'
--- libsyncdaemon/syncdaemon-daemon.c 2010-10-21 11:41:33 +0000
+++ libsyncdaemon/syncdaemon-daemon.c 2010-11-03 15:01:52 +0000
@@ -74,7 +74,7 @@
74 FOLDER_SUBSCRIBED_SIGNAL,74 FOLDER_SUBSCRIBED_SIGNAL,
75 FOLDER_UNSUBSCRIBED_SIGNAL,75 FOLDER_UNSUBSCRIBED_SIGNAL,
76 FILE_PUBLISHED_SIGNAL,76 FILE_PUBLISHED_SIGNAL,
77 GOT_PUBLISHED_FILES_SIGNAL,77 FILE_UNPUBLISHED_SIGNAL,
78 SHARE_CREATED_SIGNAL,78 SHARE_CREATED_SIGNAL,
79 SHARE_DELETED_SIGNAL,79 SHARE_DELETED_SIGNAL,
80 DOWNLOAD_STARTED_SIGNAL,80 DOWNLOAD_STARTED_SIGNAL,
@@ -218,15 +218,15 @@
218 G_TYPE_NONE, 2,218 G_TYPE_NONE, 2,
219 G_TYPE_BOOLEAN,219 G_TYPE_BOOLEAN,
220 G_TYPE_OBJECT);220 G_TYPE_OBJECT);
221 daemon_signals[GOT_PUBLISHED_FILES_SIGNAL] = g_signal_new ("got_published_files",221 daemon_signals[FILE_UNPUBLISHED_SIGNAL] = g_signal_new ("file_unpublished",
222 G_TYPE_FROM_CLASS (klass),222 G_TYPE_FROM_CLASS (klass),
223 (GSignalFlags) G_SIGNAL_RUN_LAST,223 (GSignalFlags) G_SIGNAL_RUN_LAST,
224 G_STRUCT_OFFSET (SyncdaemonDaemonClass, got_published_files),224 G_STRUCT_OFFSET (SyncdaemonDaemonClass, file_unpublished),
225 NULL, NULL,225 NULL, NULL,
226 _syncdaemon_marshal_VOID__BOOLEAN_POINTER,226 _syncdaemon_marshal_VOID__BOOLEAN_OBJECT,
227 G_TYPE_NONE, 2,227 G_TYPE_NONE, 2,
228 G_TYPE_BOOLEAN,228 G_TYPE_BOOLEAN,
229 G_TYPE_POINTER);229 G_TYPE_OBJECT);
230 daemon_signals[SHARE_CREATED_SIGNAL] = g_signal_new ("share_created",230 daemon_signals[SHARE_CREATED_SIGNAL] = g_signal_new ("share_created",
231 G_TYPE_FROM_CLASS (klass),231 G_TYPE_FROM_CLASS (klass),
232 (GSignalFlags) G_SIGNAL_RUN_LAST,232 (GSignalFlags) G_SIGNAL_RUN_LAST,
233233
=== modified file 'libsyncdaemon/syncdaemon-daemon.h'
--- libsyncdaemon/syncdaemon-daemon.h 2010-10-21 11:41:33 +0000
+++ libsyncdaemon/syncdaemon-daemon.h 2010-11-03 15:01:52 +0000
@@ -67,7 +67,7 @@
67 void (* folder_unsubscribed) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info);67 void (* folder_unsubscribed) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info);
6868
69 void (* file_published) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFileInfo *file_info);69 void (* file_published) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFileInfo *file_info);
70 void (* got_published_files) (SyncdaemonDaemon *daemon, gboolean success, GSList *files);70 void (* file_unpublished) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFileInfo *file_info);
7171
72 void (* share_created) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info);72 void (* share_created) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info);
73 void (* share_deleted) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info);73 void (* share_deleted) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info);
7474
=== modified file 'libsyncdaemon/syncdaemon-publicfiles-interface.c'
--- libsyncdaemon/syncdaemon-publicfiles-interface.c 2010-08-25 18:18:56 +0000
+++ libsyncdaemon/syncdaemon-publicfiles-interface.c 2010-11-03 15:01:52 +0000
@@ -27,6 +27,7 @@
2727
28struct _SyncdaemonPublicfilesInterfacePrivate {28struct _SyncdaemonPublicfilesInterfacePrivate {
29 GObject *proxy;29 GObject *proxy;
30 GHashTable *public_files;
30};31};
3132
32static void33static void
@@ -35,6 +36,9 @@
35 SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (object);36 SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (object);
3637
37 if (interface->priv != NULL) {38 if (interface->priv != NULL) {
39 if (interface->priv->public_files != NULL)
40 g_hash_table_destroy (interface->priv->public_files);
41
38 g_free (interface->priv);42 g_free (interface->priv);
39 }43 }
4044
@@ -60,7 +64,10 @@
60 SyncdaemonFileInfo *finfo;64 SyncdaemonFileInfo *finfo;
6165
62 finfo = syncdaemon_file_info_new_from_hash_table (hash);66 finfo = syncdaemon_file_info_new_from_hash_table (hash);
63 g_signal_emit_by_name (daemon, "file_published", TRUE, finfo);67 if (syncdaemon_file_info_get_is_public (finfo))
68 g_signal_emit_by_name (daemon, "file_published", TRUE, finfo);
69 else
70 g_signal_emit_by_name (daemon, "file_unpublished", TRUE, finfo);
6471
65 g_object_unref (G_OBJECT (finfo));72 g_object_unref (G_OBJECT (finfo));
66 }73 }
@@ -72,21 +79,24 @@
72 SyncdaemonDaemon *daemon = NULL;79 SyncdaemonDaemon *daemon = NULL;
73 SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (user_data);80 SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (user_data);
7481
82 if (interface->priv->public_files == NULL) {
83 interface->priv->public_files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
84 }
85
75 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);86 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
76 if (daemon != NULL) {87 if (daemon != NULL) {
77 GSList *finfo_list = NULL;
78 guint i;88 guint i;
7989
80 for (i = 0; i < files->len; i++) {90 for (i = 0; i < files->len; i++) {
81 SyncdaemonFileInfo *finfo = syncdaemon_file_info_new_from_hash_table (g_ptr_array_index (files, i));91 SyncdaemonFileInfo *finfo = syncdaemon_file_info_new_from_hash_table (g_ptr_array_index (files, i));
8292
83 finfo_list = g_slist_append (finfo_list, finfo);93 if (SYNCDAEMON_IS_FILE_INFO (finfo)) {
94 g_hash_table_insert (interface->priv->public_files,
95 g_strdup (syncdaemon_file_info_get_path (finfo)),
96 finfo);
97 g_signal_emit_by_name (daemon, "file_published", TRUE, finfo);
98 }
84 }99 }
85
86 g_signal_emit_by_name (daemon, "got_published_files", TRUE, finfo_list);
87
88 g_slist_foreach (finfo_list, (GFunc) g_object_unref, NULL);
89 g_slist_free (finfo_list);
90 }100 }
91}101}
92102
@@ -198,13 +208,33 @@
198208
199/**209/**
200 * syncdaemon_publicfiles_interface_get_public_files:210 * syncdaemon_publicfiles_interface_get_public_files:
211 *
212 * Return value: A #GSList of #SyncdaemonFileInfo objects, each of which describes
213 * a published file for the user. When no longer needed, this list should be
214 * freed by calling g_slist_free, but the data within the list should never
215 * be freed, as it belongs to the library.
201 */216 */
202void217GSList *
203syncdaemon_publicfiles_interface_get_public_files (SyncdaemonPublicfilesInterface *interface)218syncdaemon_publicfiles_interface_get_public_files (SyncdaemonPublicfilesInterface *interface)
204{219{
205 g_return_if_fail (SYNCDAEMON_IS_PUBLICFILES_INTERFACE (interface));220 GSList *files_list = NULL;
206221
207 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "get_public_files",222 g_return_val_if_fail (SYNCDAEMON_IS_PUBLICFILES_INTERFACE (interface), NULL);
208 no_output_dbus_call_ended_cb, interface, NULL,223
209 G_TYPE_INVALID);224 if (interface->priv->public_files == NULL) {
225 /* Only retrieve list if we haven't yet */
226 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "get_public_files",
227 no_output_dbus_call_ended_cb, interface, NULL,
228 G_TYPE_INVALID);
229 } else {
230 GHashTableIter iter;
231 gchar *path;
232 SyncdaemonFileInfo *finfo;
233
234 g_hash_table_iter_init (&iter, interface->priv->public_files);
235 while (g_hash_table_iter_next (&iter, (gpointer *) &path, (gpointer *) &finfo))
236 files_list = g_slist_append (files_list, finfo);
237 }
238
239 return files_list;
210}240}
211241
=== modified file 'libsyncdaemon/syncdaemon-publicfiles-interface.h'
--- libsyncdaemon/syncdaemon-publicfiles-interface.h 2010-06-04 15:36:24 +0000
+++ libsyncdaemon/syncdaemon-publicfiles-interface.h 2010-11-03 15:01:52 +0000
@@ -53,7 +53,7 @@
53 const gchar *share_id,53 const gchar *share_id,
54 const gchar *node_id,54 const gchar *node_id,
55 gboolean is_public);55 gboolean is_public);
56void syncdaemon_publicfiles_interface_get_public_files (SyncdaemonPublicfilesInterface *interface);56GSList *syncdaemon_publicfiles_interface_get_public_files (SyncdaemonPublicfilesInterface *interface);
5757
58G_END_DECLS58G_END_DECLS
5959
6060
=== modified file 'libsyncdaemon/syncdaemon-shares-interface.c'
--- libsyncdaemon/syncdaemon-shares-interface.c 2010-07-21 11:40:57 +0000
+++ libsyncdaemon/syncdaemon-shares-interface.c 2010-11-03 15:01:52 +0000
@@ -273,15 +273,30 @@
273 * syncdaemon_shares_interface_delete:273 * syncdaemon_shares_interface_delete:
274 */274 */
275void275void
276syncdaemon_shares_interface_delete (SyncdaemonSharesInterface *interface, const gchar *share_id)276syncdaemon_shares_interface_delete (SyncdaemonSharesInterface *interface, const gchar *path)
277{277{
278 GSList *shares, *l;
279 const gchar *share_id = NULL;
280
278 g_return_if_fail (SYNCDAEMON_IS_SHARES_INTERFACE (interface));281 g_return_if_fail (SYNCDAEMON_IS_SHARES_INTERFACE (interface));
279 g_return_if_fail (share_id != NULL);282 g_return_if_fail (path != NULL);
280283
281 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "delete_share",284 shares = syncdaemon_shares_interface_get_shared (interface);
282 no_output_dbus_call_ended_cb, interface, NULL,285 for (l = shares; l != NULL; l = l->next) {
283 G_TYPE_STRING, share_id,286 SyncdaemonShareInfo *sinfo = SYNCDAEMON_SHARE_INFO (l->data);
284 G_TYPE_INVALID);287
288 if (g_str_equal (path, syncdaemon_share_info_get_path (sinfo)))
289 share_id = syncdaemon_share_info_get_node_id (sinfo);
290 }
291
292 if (share_id != NULL) {
293 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "delete_share",
294 no_output_dbus_call_ended_cb, interface, NULL,
295 G_TYPE_STRING, share_id,
296 G_TYPE_INVALID);
297 }
298
299 g_slist_free (shares);
285}300}
286301
287/**302/**
288303
=== modified file 'libsyncdaemon/syncdaemon-shares-interface.h'
--- libsyncdaemon/syncdaemon-shares-interface.h 2010-07-20 14:10:43 +0000
+++ libsyncdaemon/syncdaemon-shares-interface.h 2010-11-03 15:01:52 +0000
@@ -55,7 +55,7 @@
55 GSList *usernames,55 GSList *usernames,
56 const gchar *name,56 const gchar *name,
57 gboolean allow_modifications);57 gboolean allow_modifications);
58void syncdaemon_shares_interface_delete (SyncdaemonSharesInterface *interface, const gchar *share_id);58void syncdaemon_shares_interface_delete (SyncdaemonSharesInterface *interface, const gchar *path);
59GSList *syncdaemon_shares_interface_get_shared (SyncdaemonSharesInterface *interface);59GSList *syncdaemon_shares_interface_get_shared (SyncdaemonSharesInterface *interface);
60GSList *syncdaemon_shares_interface_get_shares (SyncdaemonSharesInterface *interface);60GSList *syncdaemon_shares_interface_get_shares (SyncdaemonSharesInterface *interface);
61void syncdaemon_shares_interface_refresh (SyncdaemonSharesInterface *interface);61void syncdaemon_shares_interface_refresh (SyncdaemonSharesInterface *interface);
6262
=== modified file 'nautilus/context-menu.c'
--- nautilus/context-menu.c 2010-10-05 12:47:32 +0000
+++ nautilus/context-menu.c 2010-11-03 15:01:52 +0000
@@ -138,7 +138,7 @@
138 (SyncdaemonGotMetadataFunc) got_public_meta, data);138 (SyncdaemonGotMetadataFunc) got_public_meta, data);
139 }139 }
140140
141 g_hash_table_replace (data->uon->public, g_strdup (data->path), UPDATE_PENDING);141 g_hash_table_replace (data->uon->public, g_strdup (data->path), g_strdup (UPDATE_PENDING));
142 file_watcher_update_path (data->uon->file_watcher, data->path);142 file_watcher_update_path (data->uon->file_watcher, data->path);
143}143}
144144
@@ -156,14 +156,11 @@
156unshare_folder_cb (NautilusMenuItem *item, gpointer user_data)156unshare_folder_cb (NautilusMenuItem *item, gpointer user_data)
157{157{
158 MenuCallbackData * data = (MenuCallbackData *) user_data;158 MenuCallbackData * data = (MenuCallbackData *) user_data;
159 gchar * share_id;
160 SyncdaemonSharesInterface *interface;159 SyncdaemonSharesInterface *interface;
161160
162 interface = (SyncdaemonSharesInterface *) syncdaemon_daemon_get_shares_interface (data->uon->syncdaemon);161 interface = (SyncdaemonSharesInterface *) syncdaemon_daemon_get_shares_interface (data->uon->syncdaemon);
163 if (interface != NULL) {162 if (interface != NULL)
164 share_id = g_hash_table_lookup (data->uon->shares, data->path);163 syncdaemon_shares_interface_delete (interface, data->path);
165 syncdaemon_shares_interface_delete (interface, share_id);
166 }
167}164}
168165
169static void166static void
@@ -217,7 +214,8 @@
217 if (strcmp (item, UPDATE_PENDING) == 0)214 if (strcmp (item, UPDATE_PENDING) == 0)
218 is_pending = TRUE;215 is_pending = TRUE;
219 }216 }
220 if (g_hash_table_lookup (uon->shares, path) != NULL)217
218 if (ubuntuone_is_folder_shared (uon, path))
221 is_shared = TRUE;219 is_shared = TRUE;
222220
223 is_dir = nautilus_file_info_is_directory (file);221 is_dir = nautilus_file_info_is_directory (file);
224222
=== modified file 'nautilus/file-watcher.c'
--- nautilus/file-watcher.c 2010-10-08 07:46:41 +0000
+++ nautilus/file-watcher.c 2010-11-03 15:01:52 +0000
@@ -29,13 +29,25 @@
2929
30G_DEFINE_TYPE(FileWatcher, file_watcher, G_TYPE_OBJECT)30G_DEFINE_TYPE(FileWatcher, file_watcher, G_TYPE_OBJECT)
3131
32static void observed_file_unrefed (gpointer user_data, GObject *where_the_object_was);
33
34static void
35foreach_weak_unref (gpointer key, gpointer value, gpointer user_data)
36{
37 g_object_weak_unref (G_OBJECT (value),
38 (GWeakNotify) observed_file_unrefed,
39 user_data);
40}
41
32static void42static void
33file_watcher_finalize (GObject *object)43file_watcher_finalize (GObject *object)
34{44{
35 FileWatcher *watcher = FILE_WATCHER (object);45 FileWatcher *watcher = FILE_WATCHER (object);
3646
37 if (watcher->files != NULL)47 if (watcher->files != NULL) {
48 g_hash_table_foreach (watcher->files, (GHFunc) foreach_weak_unref, watcher);
38 g_hash_table_destroy (watcher->files);49 g_hash_table_destroy (watcher->files);
50 }
3951
40 G_OBJECT_CLASS (file_watcher_parent_class)->finalize (object);52 G_OBJECT_CLASS (file_watcher_parent_class)->finalize (object);
41}53}
@@ -52,7 +64,7 @@
52file_watcher_init (FileWatcher *watcher)64file_watcher_init (FileWatcher *watcher)
53{65{
54 watcher->uon = NULL;66 watcher->uon = NULL;
55 watcher->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);67 watcher->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
56}68}
5769
58static void70static void
@@ -87,13 +99,7 @@
8799
88 path = syncdaemon_share_info_get_path (share_info);100 path = syncdaemon_share_info_get_path (share_info);
89 if (success) {101 if (success) {
90 const gchar * id;102 file_watcher_update_path (watcher, path);
91
92 id = syncdaemon_share_info_get_volume_id (share_info);
93 if (!g_hash_table_lookup (watcher->uon->shares, path)) {
94 g_hash_table_insert (watcher->uon->shares, g_strdup (path), g_strdup (id));
95 file_watcher_update_path (watcher, path);
96 }
97 } else {103 } else {
98 ubuntuone_show_error_dialog (watcher->uon, _("Error creating share."),104 ubuntuone_show_error_dialog (watcher->uon, _("Error creating share."),
99 _("There was an error sharing the folder '%s'"),105 _("There was an error sharing the folder '%s'"),
@@ -112,7 +118,6 @@
112118
113 path = syncdaemon_share_info_get_path (share_info);119 path = syncdaemon_share_info_get_path (share_info);
114 if (success) {120 if (success) {
115 g_hash_table_remove (watcher->uon->shares, path);
116 file_watcher_update_path (watcher, path);121 file_watcher_update_path (watcher, path);
117 } else {122 } else {
118 ubuntuone_show_error_dialog (watcher->uon, _("Error deleting share."),123 ubuntuone_show_error_dialog (watcher->uon, _("Error deleting share."),
@@ -186,7 +191,6 @@
186 g_hash_table_replace (watcher->uon->public, g_strdup (path), g_strdup (url));191 g_hash_table_replace (watcher->uon->public, g_strdup (path), g_strdup (url));
187192
188 file_watcher_update_path (watcher, path);193 file_watcher_update_path (watcher, path);
189 watcher->uon->gotpubs = TRUE;
190 } else {194 } else {
191 ubuntuone_show_error_dialog (watcher->uon, _("Error publishing file."),195 ubuntuone_show_error_dialog (watcher->uon, _("Error publishing file."),
192 _("There was an error publishing file '%s'"),196 _("There was an error publishing file '%s'"),
@@ -194,35 +198,6 @@
194 }198 }
195}199}
196200
197static void
198got_public_files_cb (SyncdaemonDaemon *daemon,
199 gboolean success,
200 GSList *files,
201 gpointer user_data)
202{
203 FileWatcher *watcher = FILE_WATCHER (user_data);
204
205 if (success) {
206 GSList *l;
207
208 g_hash_table_remove_all (watcher->uon->public);
209 for (l = files; l != NULL; l = l->next) {
210 const gchar *path;
211 SyncdaemonFileInfo *finfo = SYNCDAEMON_FILE_INFO (l->data);
212
213 path = syncdaemon_file_info_get_path (finfo);
214 g_hash_table_insert (watcher->uon->public,
215 g_strdup (path),
216 g_strdup (syncdaemon_file_info_get_public_url (finfo)));
217
218 file_watcher_update_path (watcher, path);
219 }
220 } else {
221 ubuntuone_show_error_dialog (watcher->uon, _("Error getting public files"),
222 _("There was an error getting the list of public files"));
223 }
224}
225
226FileWatcher *201FileWatcher *
227file_watcher_new (UbuntuOneNautilus *uon)202file_watcher_new (UbuntuOneNautilus *uon)
228{203{
@@ -260,8 +235,8 @@
260 /* Connect to public files-related signals */235 /* Connect to public files-related signals */
261 g_signal_connect (G_OBJECT (uon->syncdaemon), "file_published",236 g_signal_connect (G_OBJECT (uon->syncdaemon), "file_published",
262 G_CALLBACK (file_published_cb), watcher);237 G_CALLBACK (file_published_cb), watcher);
263 g_signal_connect (G_OBJECT (uon->syncdaemon), "got_published_files",238 g_signal_connect (G_OBJECT (uon->syncdaemon), "file_unpublished",
264 G_CALLBACK (got_public_files_cb), watcher);239 G_CALLBACK (file_published_cb), watcher);
265240
266 return watcher;241 return watcher;
267}242}
@@ -286,11 +261,25 @@
286 return is_shared;261 return is_shared;
287}262}
288263
264static void
265observed_file_unrefed (gpointer user_data, GObject *where_the_object_was)
266{
267 gchar *path;
268 FileWatcher *watcher = FILE_WATCHER (user_data);
269
270 path = g_filename_from_uri (nautilus_file_info_get_uri (NAUTILUS_FILE_INFO (where_the_object_was)), NULL, NULL);
271 if (g_hash_table_lookup (watcher->files, path))
272 g_hash_table_remove (watcher->files, path);
273
274 g_free (path);
275}
276
289void277void
290file_watcher_add_file (FileWatcher *watcher, NautilusFileInfo *file)278file_watcher_add_file (FileWatcher *watcher, NautilusFileInfo *file)
291{279{
292 gboolean is_root;280 gboolean is_root;
293 gchar *path = NULL;281 gchar *path = NULL;
282 NautilusFileInfo *old_file;
294283
295 g_return_if_fail (IS_FILE_WATCHER (watcher));284 g_return_if_fail (IS_FILE_WATCHER (watcher));
296285
@@ -299,7 +288,14 @@
299 return;288 return;
300289
301 /* Always add it to the observed hash table, so that we can update emblems */290 /* Always add it to the observed hash table, so that we can update emblems */
302 g_hash_table_insert (watcher->files, path, g_object_ref (file));291 if ((old_file = g_hash_table_lookup (watcher->files, path))) {
292 g_object_weak_unref (G_OBJECT (old_file),
293 (GWeakNotify) observed_file_unrefed, watcher);
294 }
295
296 g_object_weak_ref (G_OBJECT (file),
297 (GWeakNotify) observed_file_unrefed, watcher);
298 g_hash_table_insert (watcher->files, g_strdup (path), file);
303299
304 /* Retrieve metadata */300 /* Retrieve metadata */
305 if (syncdaemon_daemon_is_folder_enabled (watcher->uon->syncdaemon, path, &is_root)) {301 if (syncdaemon_daemon_is_folder_enabled (watcher->uon->syncdaemon, path, &is_root)) {
@@ -312,32 +308,49 @@
312308
313 metadata = syncdaemon_filesystem_interface_get_metadata (309 metadata = syncdaemon_filesystem_interface_get_metadata (
314 SYNCDAEMON_FILESYSTEM_INTERFACE (interface), path, is_dir);310 SYNCDAEMON_FILESYSTEM_INTERFACE (interface), path, is_dir);
315311 if (SYNCDAEMON_IS_METADATA (metadata)) {
316 if (syncdaemon_metadata_get_is_synced (metadata))312 if (syncdaemon_metadata_get_is_synced (metadata))
317 nautilus_file_info_add_emblem (file, "ubuntuone-synchronized");313 nautilus_file_info_add_emblem (file, "ubuntuone-synchronized");
318 else314 else
319 nautilus_file_info_add_emblem (file, "ubuntuone-updating");315 nautilus_file_info_add_emblem (file, "ubuntuone-updating");
320316
321 if (is_dir) {317 if (is_dir) {
322 /* If it's a directory, check shares */318 /* If it's a directory, check shares */
323 interface = syncdaemon_daemon_get_shares_interface (watcher->uon->syncdaemon);319 interface = syncdaemon_daemon_get_shares_interface (watcher->uon->syncdaemon);
324 if (check_for_shared_folder ((const gchar *) path,320 if (check_for_shared_folder ((const gchar *) path,
325 syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface))) ||321 syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface))) ||
326 check_for_shared_folder ((const gchar *) path,322 check_for_shared_folder ((const gchar *) path,
327 syncdaemon_shares_interface_get_shares (SYNCDAEMON_SHARES_INTERFACE (interface)))) {323 syncdaemon_shares_interface_get_shares (SYNCDAEMON_SHARES_INTERFACE (interface)))) {
328 nautilus_file_info_add_emblem (file, "shared");324 nautilus_file_info_add_emblem (file, "shared");
325 }
326 } else {
327 GSList *public_files, *l;
328
329 /* If it's a file, check for public files */
330 interface = syncdaemon_daemon_get_publicfiles_interface (watcher->uon->syncdaemon);
331 public_files = syncdaemon_publicfiles_interface_get_public_files (SYNCDAEMON_PUBLICFILES_INTERFACE (interface));
332 for (l = public_files; l != NULL; l = l->next) {
333 SyncdaemonFileInfo *file_info = SYNCDAEMON_FILE_INFO (l->data);
334
335 if (!SYNCDAEMON_IS_FILE_INFO (file_info))
336 continue;
337
338 if (g_strcmp0 (path, syncdaemon_file_info_get_path (file_info)) == 0) {
339 nautilus_file_info_add_emblem (file, "ubuntuone-public");
340 break;
341 }
342 }
343
344 g_slist_free (public_files);
329 }345 }
330 } else {346
331 /* If it's a file, check for public files */347 /* Free memory */
348 g_object_unref (G_OBJECT (metadata));
332 }349 }
333
334 /* Free memory */
335 g_object_unref (G_OBJECT (metadata));
336 }350 }
337 }351 }
338352
339 /* if (g_hash_table_lookup (watcher->uon->public, path)) */353 g_free (path);
340 /* nautilus_file_info_add_emblem (file, "ubuntuone-public"); */
341}354}
342355
343void356void
344357
=== modified file 'nautilus/ubuntuone-nautilus.c'
--- nautilus/ubuntuone-nautilus.c 2010-10-08 07:46:41 +0000
+++ nautilus/ubuntuone-nautilus.c 2010-11-03 15:01:52 +0000
@@ -172,9 +172,8 @@
172ubuntuone_nautilus_instance_init (UbuntuOneNautilus * uon)172ubuntuone_nautilus_instance_init (UbuntuOneNautilus * uon)
173{173{
174 uon->connected = FALSE;174 uon->connected = FALSE;
175 uon->shares = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
176 uon->udfs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);175 uon->udfs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
177 uon->public = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);176 uon->public = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
178177
179 uon->syncdaemon = syncdaemon_daemon_new ();178 uon->syncdaemon = syncdaemon_daemon_new ();
180 g_signal_connect (G_OBJECT (uon->syncdaemon), "ready",179 g_signal_connect (G_OBJECT (uon->syncdaemon), "ready",
@@ -187,7 +186,6 @@
187 uon->managed = g_build_filename (g_get_home_dir (), "Ubuntu One", NULL);186 uon->managed = g_build_filename (g_get_home_dir (), "Ubuntu One", NULL);
188 uon->gotroot = FALSE;187 uon->gotroot = FALSE;
189 uon->gotudfs = FALSE;188 uon->gotudfs = FALSE;
190 uon->gotpubs = FALSE;
191}189}
192190
193static void191static void
@@ -209,9 +207,6 @@
209 if (uon->syncdaemon)207 if (uon->syncdaemon)
210 g_object_unref (uon->syncdaemon);208 g_object_unref (uon->syncdaemon);
211209
212 g_hash_table_destroy (uon->shares);
213 uon->shares = NULL;
214
215 g_hash_table_destroy (uon->udfs);210 g_hash_table_destroy (uon->udfs);
216 uon->udfs = NULL;211 uon->udfs = NULL;
217212
@@ -333,36 +328,18 @@
333 }328 }
334 }329 }
335330
336 /* Get the list of shared folders */
337 interface = syncdaemon_daemon_get_shares_interface (uon->syncdaemon);
338 if (SYNCDAEMON_IS_SHARES_INTERFACE (interface)) {
339 GSList *shares;
340
341 shares = syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface));
342 while (shares != NULL) {
343 const gchar *id, *path;
344 SyncdaemonShareInfo *share_info = SYNCDAEMON_SHARE_INFO (shares->data);
345
346 /* This code is duplicated in file-watcher.c */
347 path = syncdaemon_share_info_get_path (share_info);
348 id = syncdaemon_share_info_get_volume_id (share_info);
349 if (!g_hash_table_lookup (uon->shares, path)) {
350 g_hash_table_insert (uon->shares, g_strdup (path), g_strdup (id));
351 file_watcher_update_path (uon->file_watcher, path);
352 }
353
354 shares = g_slist_remove (shares, shares->data);
355 }
356 }
357
358 /* Get the list of public files if we haven't already */331 /* Get the list of public files if we haven't already */
359 if (is_online && !uon->gotpubs) {332 if (is_online) {
360 SyncdaemonInterface *public;333 SyncdaemonInterface *public;
361334
362 public = syncdaemon_daemon_get_publicfiles_interface (uon->syncdaemon);335 public = syncdaemon_daemon_get_publicfiles_interface (uon->syncdaemon);
363 if (public != NULL) {336 if (public != NULL) {
364 syncdaemon_publicfiles_interface_get_public_files (SYNCDAEMON_PUBLICFILES_INTERFACE (public));337 GSList *files_list;
365 uon->gotpubs = TRUE;338
339 /* We just call it here so that libsyncdaemon caches it, but we discard
340 the list, as we don't need it yet */
341 files_list = syncdaemon_publicfiles_interface_get_public_files (SYNCDAEMON_PUBLICFILES_INTERFACE (public));
342 g_slist_free (files_list);
366 }343 }
367 }344 }
368}345}
369346
=== modified file 'nautilus/ubuntuone-nautilus.h'
--- nautilus/ubuntuone-nautilus.h 2010-09-30 13:04:47 +0000
+++ nautilus/ubuntuone-nautilus.h 2010-11-03 15:01:52 +0000
@@ -50,10 +50,6 @@
50 /* Avoid calling get_rootdir and get_folders lots of times */50 /* Avoid calling get_rootdir and get_folders lots of times */
51 gboolean gotroot;51 gboolean gotroot;
52 gboolean gotudfs;52 gboolean gotudfs;
53 gboolean gotpubs;
54
55 /* Lists of ul/dl/shares for setting emblems */
56 GHashTable * shares;
5753
58 /* Lists of public files and user defined folders */54 /* Lists of public files and user defined folders */
59 GHashTable * public;55 GHashTable * public;
@@ -67,6 +63,7 @@
67GType ubuntuone_nautilus_get_type (void);63GType ubuntuone_nautilus_get_type (void);
6864
69/* Utility functions */65/* Utility functions */
66gboolean ubuntuone_is_folder_shared (UbuntuOneNautilus *uon, const gchar *path);
70gboolean ubuntuone_is_location_bar_enabled (void);67gboolean ubuntuone_is_location_bar_enabled (void);
7168
72gboolean ubuntuone_check_shares_and_public_files (UbuntuOneNautilus *uon,69gboolean ubuntuone_check_shares_and_public_files (UbuntuOneNautilus *uon,
7370
=== modified file 'nautilus/utils.c'
--- nautilus/utils.c 2010-09-29 11:12:35 +0000
+++ nautilus/utils.c 2010-11-03 15:01:52 +0000
@@ -59,22 +59,27 @@
59 }59 }
6060
61 /* Now check for published files */61 /* Now check for published files */
62 if (uon->gotpubs) {62 interface = syncdaemon_daemon_get_publicfiles_interface (uon->syncdaemon);
63 GHashTableIter iter;63 if (SYNCDAEMON_IS_PUBLICFILES_INTERFACE (interface)) {
64 gchar *key, *value;64 GSList *public_files, *l;
6565 public_files = syncdaemon_publicfiles_interface_get_public_files (SYNCDAEMON_PUBLICFILES_INTERFACE (interface));
66 g_hash_table_iter_init (&iter, uon->public);66
67 while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) {67 for (l = public_files; l != NULL; l = l->next) {
68 if (g_str_has_prefix (key, syncdaemon_folder_info_get_path (folder_info))) {68 const gchar *path;
69
70 path = syncdaemon_file_info_get_path (SYNCDAEMON_FILE_INFO (l->data));
71 if (g_str_has_prefix (path, syncdaemon_folder_info_get_path (folder_info))) {
69 has_published = TRUE;72 has_published = TRUE;
7073
71 question = g_string_append (question, "\t- ");74 question = g_string_append (question, "\t- ");
72 question = g_string_append (question, key);75 question = g_string_append (question, path);
73 question = g_string_append (question, _(" (Published at "));76 question = g_string_append (question, _(" (Published at "));
74 question = g_string_append (question, value);77 question = g_string_append (question, syncdaemon_file_info_get_public_url (SYNCDAEMON_FILE_INFO (l->data)));
75 question = g_string_append (question, ")\n");78 question = g_string_append (question, ")\n");
76 }79 }
77 }80 }
81
82 g_slist_free (public_files);
78 }83 }
7984
80 if (has_shares || has_published) {85 if (has_shares || has_published) {
@@ -101,6 +106,31 @@
101}106}
102107
103gboolean108gboolean
109ubuntuone_is_folder_shared (UbuntuOneNautilus *uon, const gchar *path)
110{
111 GSList *shares, *l;
112 SyncdaemonInterface *interface;
113 gboolean is_shared = FALSE;
114
115 interface = syncdaemon_daemon_get_shares_interface (uon->syncdaemon);
116 if (SYNCDAEMON_IS_SHARES_INTERFACE (interface)) {
117 shares = syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface));
118 for (l = shares; l != NULL; l = l->next) {
119 SyncdaemonShareInfo *share_info = SYNCDAEMON_SHARE_INFO (l->data);
120
121 if (g_strcmp0 (syncdaemon_share_info_get_path (share_info), path) == 0) {
122 is_shared = TRUE;
123 break;
124 }
125 }
126
127 g_slist_free (shares);
128 }
129
130 return is_shared;
131}
132
133gboolean
104ubuntuone_is_location_bar_enabled (void)134ubuntuone_is_location_bar_enabled (void)
105{135{
106 GConfClient *conf_client;136 GConfClient *conf_client;

Subscribers

People subscribed via source and target branches