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
1=== modified file 'libsyncdaemon/syncdaemon-shares-interface.c'
2--- libsyncdaemon/syncdaemon-shares-interface.c 2010-10-18 11:05:29 +0000
3+++ libsyncdaemon/syncdaemon-shares-interface.c 2011-04-07 18:58:03 +0000
4@@ -31,6 +31,11 @@
5 GHashTable *shares;
6 };
7
8+typedef struct _AddEmblemData {
9+ SyncdaemonSharesInterface *interface;
10+ gchar *path;
11+} AddEmblemData;
12+
13 static void
14 syncdaemon_shares_interface_finalize (GObject *object)
15 {
16@@ -226,6 +231,34 @@
17 G_TYPE_INVALID);
18 }
19
20+void
21+add_emblem_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data) {
22+ SyncdaemonShareInfo *share_info;
23+ SyncdaemonDaemon *daemon;
24+ GHashTable *hash;
25+ AddEmblemData *emblem_data = user_data;
26+
27+ hash = g_hash_table_new (g_str_hash, g_str_equal);
28+ g_hash_table_insert (hash, "path", emblem_data->path);
29+ share_info = syncdaemon_share_info_new_from_hash_table (hash);
30+ g_hash_table_unref (hash);
31+
32+ g_hash_table_insert (emblem_data->interface->priv->shared,
33+ g_strdup (syncdaemon_share_info_get_path (share_info)),
34+ share_info);
35+
36+
37+ g_object_get (G_OBJECT (emblem_data->interface), "daemon", &daemon, NULL);
38+ if (daemon != NULL)
39+ g_signal_emit_by_name (daemon, "share_created", TRUE, share_info);
40+
41+ no_output_dbus_call_ended_cb (proxy, call_id, user_data);
42+
43+ g_object_unref (emblem_data->interface);
44+ g_free (emblem_data->path);
45+ g_free (emblem_data);
46+}
47+
48 /**
49 * syncdaemon_shares_interface_create:
50 */
51@@ -236,14 +269,19 @@
52 const gchar *name,
53 gboolean allow_modifications)
54 {
55+ AddEmblemData *emblem_data;
56 g_return_if_fail (SYNCDAEMON_IS_SHARES_INTERFACE (interface));
57 g_return_if_fail (path != NULL);
58 g_return_if_fail (usernames != NULL);
59 g_return_if_fail (name != NULL);
60
61+ emblem_data = g_new0 (AddEmblemData, 1);
62+ emblem_data->interface = g_object_ref (interface);
63+ emblem_data->path = g_strdup (path);
64+
65 if (g_slist_length (usernames) == 1) {
66 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "create_share",
67- no_output_dbus_call_ended_cb, interface, NULL,
68+ add_emblem_cb, emblem_data, NULL,
69 G_TYPE_STRING, path,
70 G_TYPE_STRING, (const gchar *) usernames->data,
71 G_TYPE_STRING, name,
72@@ -258,7 +296,7 @@
73 users_array[i] = g_strdup (l->data);
74
75 dbus_g_proxy_begin_call (DBUS_G_PROXY (interface->priv->proxy), "create_shares",
76- no_output_dbus_call_ended_cb, interface, NULL,
77+ add_emblem_cb, emblem_data, NULL,
78 G_TYPE_STRING, path,
79 G_TYPE_STRV, users_array,
80 G_TYPE_STRING, name,
81
82=== modified file 'nautilus/context-menu.c'
83--- nautilus/context-menu.c 2011-04-04 18:00:32 +0000
84+++ nautilus/context-menu.c 2011-04-07 18:58:03 +0000
85@@ -172,6 +172,34 @@
86 gconf_client_set_bool (conf_client, EXPANDER_SHOWN_KEY, !ubuntuone_is_location_bar_enabled (), NULL);
87 }
88
89+gboolean
90+check_share_offer_pending (UbuntuOneNautilus *uon, const gchar *path)
91+{
92+ GSList *shares, *l;
93+ SyncdaemonInterface *interface;
94+ gboolean is_share_offer_pending = FALSE;
95+ const gchar *node_id;
96+
97+ interface = syncdaemon_daemon_get_shares_interface (uon->syncdaemon);
98+ if (SYNCDAEMON_IS_SHARES_INTERFACE (interface)) {
99+ shares = syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface));
100+ for (l = shares; l != NULL; l = l->next) {
101+ SyncdaemonShareInfo *share_info = SYNCDAEMON_SHARE_INFO (l->data);
102+
103+ if (g_strcmp0 (syncdaemon_share_info_get_path (share_info), path) == 0) {
104+ node_id = syncdaemon_share_info_get_node_id (share_info);
105+ if (node_id == NULL)
106+ is_share_offer_pending = TRUE;
107+ break;
108+ }
109+ }
110+
111+ g_slist_free (shares);
112+ }
113+
114+ return is_share_offer_pending;
115+}
116+
117 NautilusMenuItem *
118 context_menu_new (UbuntuOneNautilus *uon,
119 GtkWidget *window,
120@@ -183,10 +211,12 @@
121 gchar *path, *item, *homedir_path, *path_uri;
122 gboolean is_managed, is_root, is_udf, is_public, is_shared, is_pending;
123 gboolean is_shared_to_me, is_inhome, is_dir, is_regular, is_symlink;
124+ gboolean is_share_offer_pending;
125 MenuCallbackData *cb_data;
126
127 is_managed = is_root = is_udf = is_public = is_shared = is_pending = FALSE;
128 is_shared_to_me = is_inhome = is_dir = is_regular = is_symlink = FALSE;
129+ is_share_offer_pending = FALSE;
130
131 if (g_list_length (files) != 1)
132 return NULL;
133@@ -217,8 +247,11 @@
134 is_pending = TRUE;
135 }
136
137- if (ubuntuone_is_folder_shared (uon, path))
138+ if (ubuntuone_is_folder_shared (uon, path)) {
139 is_shared = TRUE;
140+ if (check_share_offer_pending (uon, path))
141+ is_share_offer_pending = TRUE;
142+ }
143
144 if (ubuntuone_is_inside_shares (uon, path))
145 is_shared_to_me = TRUE;
146@@ -283,7 +316,7 @@
147 _("Stop _Sharing"),
148 _("Stop sharing this folder on Ubuntu One"),
149 "ubuntuone");
150- if (is_pending)
151+ if (is_pending || is_share_offer_pending)
152 g_object_set (menu_item, "sensitive", FALSE, NULL);
153
154 g_signal_connect (menu_item, "activate",

Subscribers

People subscribed via source and target branches