Merge lp:~alecu/ubuntuone-client/capt-nemos-share-hand into lp:ubuntuone-client

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 937
Merged at revision: 947
Proposed branch: lp:~alecu/ubuntuone-client/capt-nemos-share-hand
Merge into: lp:ubuntuone-client
Diff against target: 154 lines (+75/-4)
2 files modified
libsyncdaemon/syncdaemon-shares-interface.c (+40/-2)
nautilus/context-menu.c (+35/-2)
To merge this branch: bzr merge lp:~alecu/ubuntuone-client/capt-nemos-share-hand
Reviewer Review Type Date Requested Status
Chad Miller (community) Approve
dobey (community) Approve
Review via email: mp+56827@code.launchpad.net

Commit message

Add an emblem when offering a share and disable the context menu option to cancel it. (LP: #646059)

Description of the change

Add an emblem when offering a share and disable the context menu option to cancel it. (LP: #646059)

To post a comment you must log in.
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Alejandro J. Cura (alecu) wrote :

To test this:
 * compile and install the nautilus plugin in this branch, as per the instructions in: https://wiki.canonical.com/UbuntuOne/CodeReviewFaq#ubuntuone-client%20Nautilus%20Plugin
 * restart nautilus: killall nautilus
 * right click on a folder that has been uploaded to Ubuntu One, and select "Ubuntu One" -> "Share..."
 * select an email from the list or add a new email address and use it
 * immediately after you click on the "Share" button a share emblem should show up on the folder (it looks like an orange and a green arrow)
 * now try right clicking on that folder and going to the "Ubuntu One" menu. The "Stop Sharing" option should be grayed out, because there's no webservice call to cancel share offers, only accepted share offers (bug #752986).

Revision history for this message
Chad Miller (cmiller) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libsyncdaemon/syncdaemon-shares-interface.c'
--- libsyncdaemon/syncdaemon-shares-interface.c 2010-10-18 11:05:29 +0000
+++ libsyncdaemon/syncdaemon-shares-interface.c 2011-04-07 18:58:03 +0000
@@ -31,6 +31,11 @@
31 GHashTable *shares;31 GHashTable *shares;
32};32};
3333
34typedef struct _AddEmblemData {
35 SyncdaemonSharesInterface *interface;
36 gchar *path;
37} AddEmblemData;
38
34static void39static void
35syncdaemon_shares_interface_finalize (GObject *object)40syncdaemon_shares_interface_finalize (GObject *object)
36{41{
@@ -226,6 +231,34 @@
226 G_TYPE_INVALID);231 G_TYPE_INVALID);
227}232}
228233
234void
235add_emblem_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) {
236 SyncdaemonShareInfo *share_info;
237 SyncdaemonDaemon *daemon;
238 GHashTable *hash;
239 AddEmblemData *emblem_data = user_data;
240
241 hash = g_hash_table_new (g_str_hash, g_str_equal);
242 g_hash_table_insert (hash, "path", emblem_data->path);
243 share_info = syncdaemon_share_info_new_from_hash_table (hash);
244 g_hash_table_unref (hash);
245
246 g_hash_table_insert (emblem_data->interface->priv->shared,
247 g_strdup (syncdaemon_share_info_get_path (share_info)),
248 share_info);
249
250
251 g_object_get (G_OBJECT (emblem_data->interface), "daemon", &daemon, NULL);
252 if (daemon != NULL)
253 g_signal_emit_by_name (daemon, "share_created", TRUE, share_info);
254
255 no_output_dbus_call_ended_cb (proxy, call_id, user_data);
256
257 g_object_unref (emblem_data->interface);
258 g_free (emblem_data->path);
259 g_free (emblem_data);
260}
261
229/**262/**
230 * syncdaemon_shares_interface_create:263 * syncdaemon_shares_interface_create:
231 */264 */
@@ -236,14 +269,19 @@
236 const gchar *name,269 const gchar *name,
237 gboolean allow_modifications)270 gboolean allow_modifications)
238{271{
272 AddEmblemData *emblem_data;
239 g_return_if_fail (SYNCDAEMON_IS_SHARES_INTERFACE (interface));273 g_return_if_fail (SYNCDAEMON_IS_SHARES_INTERFACE (interface));
240 g_return_if_fail (path != NULL);274 g_return_if_fail (path != NULL);
241 g_return_if_fail (usernames != NULL);275 g_return_if_fail (usernames != NULL);
242 g_return_if_fail (name != NULL);276 g_return_if_fail (name != NULL);
243277
278 emblem_data = g_new0 (AddEmblemData, 1);
279 emblem_data->interface = g_object_ref (interface);
280 emblem_data->path = g_strdup (path);
281
244 if (g_slist_length (usernames) == 1) {282 if (g_slist_length (usernames) == 1) {
245 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "create_share",283 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "create_share",
246 no_output_dbus_call_ended_cb, interface, NULL,284 add_emblem_cb, emblem_data, NULL,
247 G_TYPE_STRING, path,285 G_TYPE_STRING, path,
248 G_TYPE_STRING, (const gchar *) usernames->data,286 G_TYPE_STRING, (const gchar *) usernames->data,
249 G_TYPE_STRING, name,287 G_TYPE_STRING, name,
@@ -258,7 +296,7 @@
258 users_array[i] = g_strdup (l->data);296 users_array[i] = g_strdup (l->data);
259297
260 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "create_shares",298 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "create_shares",
261 no_output_dbus_call_ended_cb, interface, NULL,299 add_emblem_cb, emblem_data, NULL,
262 G_TYPE_STRING, path,300 G_TYPE_STRING, path,
263 G_TYPE_STRV, users_array,301 G_TYPE_STRV, users_array,
264 G_TYPE_STRING, name,302 G_TYPE_STRING, name,
265303
=== modified file 'nautilus/context-menu.c'
--- nautilus/context-menu.c 2011-04-04 18:00:32 +0000
+++ nautilus/context-menu.c 2011-04-07 18:58:03 +0000
@@ -172,6 +172,34 @@
172 gconf_client_set_bool (conf_client, EXPANDER_SHOWN_KEY, !ubuntuone_is_location_bar_enabled (), NULL);172 gconf_client_set_bool (conf_client, EXPANDER_SHOWN_KEY, !ubuntuone_is_location_bar_enabled (), NULL);
173}173}
174174
175gboolean
176check_share_offer_pending (UbuntuOneNautilus *uon, const gchar *path)
177{
178 GSList *shares, *l;
179 SyncdaemonInterface *interface;
180 gboolean is_share_offer_pending = FALSE;
181 const gchar *node_id;
182
183 interface = syncdaemon_daemon_get_shares_interface (uon->syncdaemon);
184 if (SYNCDAEMON_IS_SHARES_INTERFACE (interface)) {
185 shares = syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface));
186 for (l = shares; l != NULL; l = l->next) {
187 SyncdaemonShareInfo *share_info = SYNCDAEMON_SHARE_INFO (l->data);
188
189 if (g_strcmp0 (syncdaemon_share_info_get_path (share_info), path) == 0) {
190 node_id = syncdaemon_share_info_get_node_id (share_info);
191 if (node_id == NULL)
192 is_share_offer_pending = TRUE;
193 break;
194 }
195 }
196
197 g_slist_free (shares);
198 }
199
200 return is_share_offer_pending;
201}
202
175NautilusMenuItem *203NautilusMenuItem *
176context_menu_new (UbuntuOneNautilus *uon,204context_menu_new (UbuntuOneNautilus *uon,
177 GtkWidget *window,205 GtkWidget *window,
@@ -183,10 +211,12 @@
183 gchar *path, *item, *homedir_path, *path_uri;211 gchar *path, *item, *homedir_path, *path_uri;
184 gboolean is_managed, is_root, is_udf, is_public, is_shared, is_pending;212 gboolean is_managed, is_root, is_udf, is_public, is_shared, is_pending;
185 gboolean is_shared_to_me, is_inhome, is_dir, is_regular, is_symlink;213 gboolean is_shared_to_me, is_inhome, is_dir, is_regular, is_symlink;
214 gboolean is_share_offer_pending;
186 MenuCallbackData *cb_data;215 MenuCallbackData *cb_data;
187216
188 is_managed = is_root = is_udf = is_public = is_shared = is_pending = FALSE;217 is_managed = is_root = is_udf = is_public = is_shared = is_pending = FALSE;
189 is_shared_to_me = is_inhome = is_dir = is_regular = is_symlink = FALSE;218 is_shared_to_me = is_inhome = is_dir = is_regular = is_symlink = FALSE;
219 is_share_offer_pending = FALSE;
190220
191 if (g_list_length (files) != 1)221 if (g_list_length (files) != 1)
192 return NULL;222 return NULL;
@@ -217,8 +247,11 @@
217 is_pending = TRUE;247 is_pending = TRUE;
218 }248 }
219249
220 if (ubuntuone_is_folder_shared (uon, path))250 if (ubuntuone_is_folder_shared (uon, path)) {
221 is_shared = TRUE;251 is_shared = TRUE;
252 if (check_share_offer_pending (uon, path))
253 is_share_offer_pending = TRUE;
254 }
222255
223 if (ubuntuone_is_inside_shares (uon, path))256 if (ubuntuone_is_inside_shares (uon, path))
224 is_shared_to_me = TRUE;257 is_shared_to_me = TRUE;
@@ -283,7 +316,7 @@
283 _("Stop _Sharing"),316 _("Stop _Sharing"),
284 _("Stop sharing this folder on Ubuntu One"),317 _("Stop sharing this folder on Ubuntu One"),
285 "ubuntuone");318 "ubuntuone");
286 if (is_pending)319 if (is_pending || is_share_offer_pending)
287 g_object_set (menu_item, "sensitive", FALSE, NULL);320 g_object_set (menu_item, "sensitive", FALSE, NULL);
288321
289 g_signal_connect (menu_item, "activate",322 g_signal_connect (menu_item, "activate",

Subscribers

People subscribed via source and target branches