Merge lp:~rodrigo-moya/ubuntuone-client/check-published-files into lp:ubuntuone-client
- check-published-files
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Rodrigo Moya |
Approved revision: | 658 |
Merged at revision: | 654 |
Proposed branch: | lp:~rodrigo-moya/ubuntuone-client/check-published-files |
Merge into: | lp:ubuntuone-client |
Diff against target: |
949 lines (+584/-133) 14 files modified
libsyncdaemon/Makefile.am (+2/-0) libsyncdaemon/libsyncdaemon.h (+1/-0) libsyncdaemon/syncdaemon-daemon.c (+7/-5) libsyncdaemon/syncdaemon-daemon.h (+3/-2) libsyncdaemon/syncdaemon-file-info.c (+223/-0) libsyncdaemon/syncdaemon-file-info.h (+65/-0) libsyncdaemon/syncdaemon-publicfiles-interface.c (+34/-9) libsyncdaemon/test-libsyncdaemon.c (+43/-0) nautilus/Makefile.am (+2/-1) nautilus/location-widget.c (+1/-101) nautilus/ubuntuone-nautilus.c (+28/-15) nautilus/ubuntuone-nautilus.h (+4/-0) nautilus/utils.c (+170/-0) po/POTFILES.in (+1/-0) |
To merge this branch: | bzr merge lp:~rodrigo-moya/ubuntuone-client/check-published-files |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alejandro J. Cura (community) | Approve | ||
John Lenton (community) | Approve | ||
Review via email: mp+33660@code.launchpad.net |
Commit message
Check that the user has no published files before disabling a UDF (LP: #603576)
Description of the change
Check that the user has no published files before disabling a UDF
John Lenton (chipaca) : | # |
dobey (dobey) wrote : | # |
The attempt to merge lp:~rodrigo-moya/ubuntuone-client/check-published-files into lp:ubuntuone-client failed.Below is the output from the failed tests.
/usr/bin/
checking for autoconf >= 2.53...
testing autoconf2.50... not found.
testing autoconf... found 2.67
checking for automake >= 1.10...
testing automake-1.11... found 1.11.1
checking for libtool >= 1.5...
testing libtoolize... found 2.2.6b
checking for intltool >= 0.30...
testing intltoolize... found 0.41.1
checking for pkg-config >= 0.14.0...
testing pkg-config... found 0.25
Checking for required M4 macros...
Checking for forbidden M4 macros...
Processing ./configure.ac
Running libtoolize...
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
Running intltoolize...
Running aclocal-1.11...
Running autoconf...
Running autoheader...
Running automake-1.11...
Running ./configure --with-
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for library containing strerror... none required
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
c...
dobey (dobey) wrote : | # |
The attempt to merge lp:~rodrigo-moya/ubuntuone-client/check-published-files into lp:ubuntuone-client failed.Below is the output from the failed tests.
/usr/bin/
checking for autoconf >= 2.53...
testing autoconf2.50... not found.
testing autoconf... found 2.67
checking for automake >= 1.10...
testing automake-1.11... found 1.11.1
checking for libtool >= 1.5...
testing libtoolize... found 2.2.6b
checking for intltool >= 0.30...
testing intltoolize... found 0.41.1
checking for pkg-config >= 0.14.0...
testing pkg-config... found 0.25
Checking for required M4 macros...
Checking for forbidden M4 macros...
Processing ./configure.ac
Running libtoolize...
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
Running intltoolize...
Running aclocal-1.11...
Running autoconf...
Running autoheader...
Running automake-1.11...
Running ./configure --with-
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for library containing strerror... none required
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
c...
Preview Diff
1 | === modified file 'libsyncdaemon/Makefile.am' |
2 | --- libsyncdaemon/Makefile.am 2010-08-13 19:25:17 +0000 |
3 | +++ libsyncdaemon/Makefile.am 2010-08-25 20:03:47 +0000 |
4 | @@ -26,6 +26,7 @@ |
5 | syncdaemon-config-interface.h \ |
6 | syncdaemon-credentials.h \ |
7 | syncdaemon-events-interface.h \ |
8 | + syncdaemon-file-info.h \ |
9 | syncdaemon-filesystem-interface.h \ |
10 | syncdaemon-folder-info.h \ |
11 | syncdaemon-folders-interface.h \ |
12 | @@ -46,6 +47,7 @@ |
13 | syncdaemon-config-interface.c \ |
14 | syncdaemon-credentials.c \ |
15 | syncdaemon-events-interface.c \ |
16 | + syncdaemon-file-info.c \ |
17 | syncdaemon-filesystem-interface.c \ |
18 | syncdaemon-folder-info.c \ |
19 | syncdaemon-folders-interface.c \ |
20 | |
21 | === modified file 'libsyncdaemon/libsyncdaemon.h' |
22 | --- libsyncdaemon/libsyncdaemon.h 2010-08-09 15:56:51 +0000 |
23 | +++ libsyncdaemon/libsyncdaemon.h 2010-08-25 20:03:47 +0000 |
24 | @@ -24,6 +24,7 @@ |
25 | #include <libsyncdaemon/syncdaemon-credentials.h> |
26 | #include <libsyncdaemon/syncdaemon-daemon.h> |
27 | #include <libsyncdaemon/syncdaemon-events-interface.h> |
28 | +#include <libsyncdaemon/syncdaemon-file-info.h> |
29 | #include <libsyncdaemon/syncdaemon-filesystem-interface.h> |
30 | #include <libsyncdaemon/syncdaemon-folder-info.h> |
31 | #include <libsyncdaemon/syncdaemon-folders-interface.h> |
32 | |
33 | === modified file 'libsyncdaemon/syncdaemon-daemon.c' |
34 | --- libsyncdaemon/syncdaemon-daemon.c 2010-08-05 09:16:55 +0000 |
35 | +++ libsyncdaemon/syncdaemon-daemon.c 2010-08-25 20:03:47 +0000 |
36 | @@ -210,16 +210,18 @@ |
37 | (GSignalFlags) G_SIGNAL_RUN_LAST, |
38 | G_STRUCT_OFFSET (SyncdaemonDaemonClass, file_published), |
39 | NULL, NULL, |
40 | - g_cclosure_marshal_VOID__POINTER, |
41 | - G_TYPE_NONE, 1, |
42 | - G_TYPE_POINTER); |
43 | + _syncdaemon_marshal_VOID__BOOLEAN_OBJECT, |
44 | + G_TYPE_NONE, 2, |
45 | + G_TYPE_BOOLEAN, |
46 | + G_TYPE_OBJECT); |
47 | daemon_signals[GOT_PUBLISHED_FILES_SIGNAL] = g_signal_new ("got_published_files", |
48 | G_TYPE_FROM_CLASS (klass), |
49 | (GSignalFlags) G_SIGNAL_RUN_LAST, |
50 | G_STRUCT_OFFSET (SyncdaemonDaemonClass, got_published_files), |
51 | NULL, NULL, |
52 | - g_cclosure_marshal_VOID__POINTER, |
53 | - G_TYPE_NONE, 1, |
54 | + _syncdaemon_marshal_VOID__BOOLEAN_POINTER, |
55 | + G_TYPE_NONE, 2, |
56 | + G_TYPE_BOOLEAN, |
57 | G_TYPE_POINTER); |
58 | daemon_signals[SHARE_CREATED_SIGNAL] = g_signal_new ("share_created", |
59 | G_TYPE_FROM_CLASS (klass), |
60 | |
61 | === modified file 'libsyncdaemon/syncdaemon-daemon.h' |
62 | --- libsyncdaemon/syncdaemon-daemon.h 2010-08-05 09:16:55 +0000 |
63 | +++ libsyncdaemon/syncdaemon-daemon.h 2010-08-25 20:03:47 +0000 |
64 | @@ -24,6 +24,7 @@ |
65 | |
66 | #include <glib-object.h> |
67 | #include "syncdaemon-authentication.h" |
68 | +#include "syncdaemon-file-info.h" |
69 | #include "syncdaemon-folder-info.h" |
70 | #include "syncdaemon-interface.h" |
71 | #include "syncdaemon-share-info.h" |
72 | @@ -64,8 +65,8 @@ |
73 | void (* folder_subscribed) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info); |
74 | void (* folder_unsubscribed) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info); |
75 | |
76 | - void (* file_published) (SyncdaemonDaemon *daemon, GHashTable *file_info); |
77 | - void (* got_published_files) (SyncdaemonDaemon *daemon, GPtrArray *files); |
78 | + void (* file_published) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFileInfo *file_info); |
79 | + void (* got_published_files) (SyncdaemonDaemon *daemon, gboolean success, GSList *files); |
80 | |
81 | void (* share_created) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info); |
82 | void (* share_deleted) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info); |
83 | |
84 | === added file 'libsyncdaemon/syncdaemon-file-info.c' |
85 | --- libsyncdaemon/syncdaemon-file-info.c 1970-01-01 00:00:00 +0000 |
86 | +++ libsyncdaemon/syncdaemon-file-info.c 2010-08-25 20:03:47 +0000 |
87 | @@ -0,0 +1,223 @@ |
88 | +/* |
89 | + * Syncdaemon API |
90 | + * |
91 | + * Authors: Rodrigo Moya <rodrigo.moya@canonical.com> |
92 | + * |
93 | + * Copyright 2010 Canonical Ltd. |
94 | + * |
95 | + * This program is free software: you can redistribute it and/or modify it |
96 | + * under the terms of the GNU General Public License version 3, as published |
97 | + * by the Free Software Foundation. |
98 | + * |
99 | + * This program is distributed in the hope that it will be useful, but |
100 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
101 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
102 | + * PURPOSE. See the GNU General Public License for more details. |
103 | + * |
104 | + * You should have received a copy of the GNU General Public License along |
105 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
106 | + * |
107 | + */ |
108 | + |
109 | +#include "syncdaemon-file-info.h" |
110 | + |
111 | +G_DEFINE_TYPE(SyncdaemonFileInfo, syncdaemon_file_info, G_TYPE_OBJECT) |
112 | + |
113 | +struct _SyncdaemonFileInfoPrivate { |
114 | + gchar *volume_id; |
115 | + gchar *node_id; |
116 | + gchar *public_url; |
117 | + gchar *path; |
118 | + gboolean is_public; |
119 | +}; |
120 | + |
121 | +static void |
122 | +syncdaemon_file_info_finalize (GObject *object) |
123 | +{ |
124 | + SyncdaemonFileInfo *finfo = SYNCDAEMON_FILE_INFO (object); |
125 | + |
126 | + if (finfo->priv != NULL) { |
127 | + if (finfo->priv->volume_id != NULL) |
128 | + g_free (finfo->priv->volume_id); |
129 | + |
130 | + if (finfo->priv->node_id != NULL) |
131 | + g_free (finfo->priv->node_id); |
132 | + |
133 | + if (finfo->priv->public_url != NULL) |
134 | + g_free (finfo->priv->public_url); |
135 | + |
136 | + if (finfo->priv->path != NULL) |
137 | + g_free (finfo->priv->path); |
138 | + |
139 | + g_free (finfo->priv); |
140 | + } |
141 | + |
142 | + G_OBJECT_CLASS (syncdaemon_file_info_parent_class)->finalize (object); |
143 | +} |
144 | + |
145 | +static void |
146 | +syncdaemon_file_info_class_init (SyncdaemonFileInfoClass *klass) |
147 | +{ |
148 | + GObjectClass *object_class = G_OBJECT_CLASS (klass); |
149 | + |
150 | + object_class->finalize = syncdaemon_file_info_finalize; |
151 | +} |
152 | + |
153 | +static void |
154 | +syncdaemon_file_info_init (SyncdaemonFileInfo *finfo) |
155 | +{ |
156 | + finfo->priv = g_new0 (SyncdaemonFileInfoPrivate, 1); |
157 | +} |
158 | + |
159 | +/** |
160 | + * syncdaemon_file_info_new: |
161 | + */ |
162 | +SyncdaemonFileInfo * |
163 | +syncdaemon_file_info_new (void) |
164 | +{ |
165 | + return g_object_new (SYNCDAEMON_TYPE_FILE_INFO, NULL); |
166 | +} |
167 | + |
168 | +/** |
169 | + * syncdaemon_file_info_new_from_hash_table: |
170 | + */ |
171 | +SyncdaemonFileInfo * |
172 | +syncdaemon_file_info_new_from_hash_table (GHashTable *hash) |
173 | +{ |
174 | + SyncdaemonFileInfo *finfo; |
175 | + |
176 | + finfo = g_object_new (SYNCDAEMON_TYPE_FILE_INFO, NULL); |
177 | + if (hash != NULL) { |
178 | + syncdaemon_file_info_set_volume_id (finfo, g_hash_table_lookup (hash, "volume_id")); |
179 | + syncdaemon_file_info_set_node_id (finfo, g_hash_table_lookup (hash, "node_id")); |
180 | + syncdaemon_file_info_set_public_url (finfo, g_hash_table_lookup (hash, "public_url")); |
181 | + syncdaemon_file_info_set_path (finfo, g_hash_table_lookup (hash, "path")); |
182 | + syncdaemon_file_info_set_is_public ( |
183 | + finfo, |
184 | + g_strcmp0 (g_hash_table_lookup (hash, "is_public"), "True") == 0); |
185 | + } |
186 | + |
187 | + return finfo; |
188 | +} |
189 | + |
190 | +/** |
191 | + * syncdaemon_file_info_get_volume_id: |
192 | + */ |
193 | +const gchar * |
194 | +syncdaemon_file_info_get_volume_id (SyncdaemonFileInfo *finfo) |
195 | +{ |
196 | + g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), NULL); |
197 | + |
198 | + return (const gchar *) finfo->priv->volume_id; |
199 | +} |
200 | + |
201 | +/** |
202 | + * syncdaemon_file_info_set_volume_id: |
203 | + */ |
204 | +void |
205 | +syncdaemon_file_info_set_volume_id (SyncdaemonFileInfo *finfo, const gchar *volume_id) |
206 | +{ |
207 | + g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo)); |
208 | + |
209 | + if (finfo->priv->volume_id != NULL) |
210 | + g_free (finfo->priv->volume_id); |
211 | + |
212 | + finfo->priv->volume_id = g_strdup (volume_id); |
213 | +} |
214 | + |
215 | +/** |
216 | + * syncdaemon_file_info_get_node_id: |
217 | + */ |
218 | +const gchar * |
219 | +syncdaemon_file_info_get_node_id (SyncdaemonFileInfo *finfo) |
220 | +{ |
221 | + g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), NULL); |
222 | + |
223 | + return (const gchar *) finfo->priv->node_id; |
224 | +} |
225 | + |
226 | +/** |
227 | + * syncdaemon_file_info_set_node_id: |
228 | + */ |
229 | +void |
230 | +syncdaemon_file_info_set_node_id (SyncdaemonFileInfo *finfo, const gchar *node_id) |
231 | +{ |
232 | + g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo)); |
233 | + |
234 | + if (finfo->priv->node_id != NULL) |
235 | + g_free (finfo->priv->node_id); |
236 | + |
237 | + finfo->priv->node_id = g_strdup (node_id); |
238 | +} |
239 | + |
240 | +/** |
241 | + * syncdaemon_file_info_get_public_url: |
242 | + */ |
243 | +const gchar * |
244 | +syncdaemon_file_info_get_public_url (SyncdaemonFileInfo *finfo) |
245 | +{ |
246 | + g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), NULL); |
247 | + |
248 | + return (const gchar *) finfo->priv->public_url; |
249 | +} |
250 | + |
251 | +/** |
252 | + * syncdaemon_file_info_set_public_url: |
253 | + */ |
254 | +void |
255 | +syncdaemon_file_info_set_public_url (SyncdaemonFileInfo *finfo, const gchar *public_url) |
256 | +{ |
257 | + g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo)); |
258 | + |
259 | + if (finfo->priv->public_url != NULL) |
260 | + g_free (finfo->priv->public_url); |
261 | + |
262 | + finfo->priv->public_url = g_strdup (public_url); |
263 | +} |
264 | + |
265 | +/** |
266 | + * syncdaemon_file_info_get_path: |
267 | + */ |
268 | +const gchar * |
269 | +syncdaemon_file_info_get_path (SyncdaemonFileInfo *finfo) |
270 | +{ |
271 | + g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), NULL); |
272 | + |
273 | + return (const gchar *) finfo->priv->path; |
274 | +} |
275 | + |
276 | +/** |
277 | + * syncdaemon_file_info_set_path: |
278 | + */ |
279 | +void |
280 | +syncdaemon_file_info_set_path (SyncdaemonFileInfo *finfo, const gchar *path) |
281 | +{ |
282 | + g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo)); |
283 | + |
284 | + if (finfo->priv->path != NULL) |
285 | + g_free (finfo->priv->path); |
286 | + |
287 | + finfo->priv->path = g_strdup (path); |
288 | +} |
289 | + |
290 | +/** |
291 | + * syncdaemon_file_info_get_is_public: |
292 | + */ |
293 | +gboolean |
294 | +syncdaemon_file_info_get_is_public (SyncdaemonFileInfo *finfo) |
295 | +{ |
296 | + g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), FALSE); |
297 | + |
298 | + return finfo->priv->is_public; |
299 | +} |
300 | + |
301 | +/** |
302 | + * syncdaemon_file_info_set_is_public: |
303 | + */ |
304 | +void |
305 | +syncdaemon_file_info_set_is_public (SyncdaemonFileInfo *finfo, gboolean is_public) |
306 | +{ |
307 | + g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo)); |
308 | + |
309 | + finfo->priv->is_public = is_public; |
310 | +} |
311 | |
312 | === added file 'libsyncdaemon/syncdaemon-file-info.h' |
313 | --- libsyncdaemon/syncdaemon-file-info.h 1970-01-01 00:00:00 +0000 |
314 | +++ libsyncdaemon/syncdaemon-file-info.h 2010-08-25 20:03:47 +0000 |
315 | @@ -0,0 +1,65 @@ |
316 | +/* |
317 | + * Syncdaemon API |
318 | + * |
319 | + * Authors: Rodrigo Moya <rodrigo.moya@canonical.com> |
320 | + * |
321 | + * Copyright 2010 Canonical Ltd. |
322 | + * |
323 | + * This program is free software: you can redistribute it and/or modify it |
324 | + * under the terms of the GNU General Public License version 3, as published |
325 | + * by the Free Software Foundation. |
326 | + * |
327 | + * This program is distributed in the hope that it will be useful, but |
328 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
329 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
330 | + * PURPOSE. See the GNU General Public License for more details. |
331 | + * |
332 | + * You should have received a copy of the GNU General Public License along |
333 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
334 | + * |
335 | + */ |
336 | + |
337 | +#ifndef __SYNCDAEMON_FILE_INFO_H__ |
338 | +#define __SYNCDAEMON_FILE_INFO_H__ |
339 | + |
340 | +#include <glib-object.h> |
341 | + |
342 | +G_BEGIN_DECLS |
343 | + |
344 | +#define SYNCDAEMON_TYPE_FILE_INFO (syncdaemon_file_info_get_type ()) |
345 | +#define SYNCDAEMON_FILE_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNCDAEMON_TYPE_FILE_INFO, SyncdaemonFileInfo)) |
346 | +#define SYNCDAEMON_IS_FILE_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNCDAEMON_TYPE_FILE_INFO)) |
347 | +#define SYNCDAEMON_FILE_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNCDAEMON_TYPE_FILE_INFO, SyncdaemonFileInfoClass)) |
348 | +#define SYNCDAEMON_IS_FILE_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNCDAEMON_TYPE_FILE_INFO)) |
349 | +#define SYNCDAEMON_FILE_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNCDAEMON_TYPE_FILE_INFO, SyncdaemonFileInfoClass)) |
350 | + |
351 | +typedef struct _SyncdaemonFileInfoPrivate SyncdaemonFileInfoPrivate; |
352 | + |
353 | +typedef struct { |
354 | + GObject parent; |
355 | + SyncdaemonFileInfoPrivate *priv; |
356 | +} SyncdaemonFileInfo; |
357 | + |
358 | +typedef struct { |
359 | + GObjectClass parent_class; |
360 | +} SyncdaemonFileInfoClass; |
361 | + |
362 | +GType syncdaemon_file_info_get_type (void); |
363 | +SyncdaemonFileInfo *syncdaemon_file_info_new (void); |
364 | +SyncdaemonFileInfo *syncdaemon_file_info_new_from_hash_table (GHashTable *hash); |
365 | + |
366 | +const gchar *syncdaemon_file_info_get_volume_id (SyncdaemonFileInfo *finfo); |
367 | +void syncdaemon_file_info_set_volume_id (SyncdaemonFileInfo *finfo, const gchar *volume_id); |
368 | +const gchar *syncdaemon_file_info_get_node_id (SyncdaemonFileInfo *finfo); |
369 | +void syncdaemon_file_info_set_node_id (SyncdaemonFileInfo *finfo, const gchar *node_id); |
370 | +const gchar *syncdaemon_file_info_get_path (SyncdaemonFileInfo *finfo); |
371 | +void syncdaemon_file_info_set_path (SyncdaemonFileInfo *finfo, const gchar *path); |
372 | + |
373 | +gboolean syncdaemon_file_info_get_is_public (SyncdaemonFileInfo *finfo); |
374 | +void syncdaemon_file_info_set_is_public (SyncdaemonFileInfo *finfo, gboolean is_public); |
375 | +const gchar *syncdaemon_file_info_get_public_url (SyncdaemonFileInfo *finfo); |
376 | +void syncdaemon_file_info_set_public_url (SyncdaemonFileInfo *finfo, const gchar *public_url); |
377 | + |
378 | +G_END_DECLS |
379 | + |
380 | +#endif |
381 | |
382 | === modified file 'libsyncdaemon/syncdaemon-publicfiles-interface.c' |
383 | --- libsyncdaemon/syncdaemon-publicfiles-interface.c 2010-06-09 22:46:42 +0000 |
384 | +++ libsyncdaemon/syncdaemon-publicfiles-interface.c 2010-08-25 20:03:47 +0000 |
385 | @@ -50,14 +50,20 @@ |
386 | } |
387 | |
388 | static void |
389 | -file_published_cb (DBusGProxy *proxy, GHashTable *file_info, gpointer user_data) |
390 | +file_published_cb (DBusGProxy *proxy, GHashTable *hash, gpointer user_data) |
391 | { |
392 | SyncdaemonDaemon *daemon = NULL; |
393 | SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (user_data); |
394 | |
395 | g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL); |
396 | - if (daemon != NULL) |
397 | - g_signal_emit_by_name (daemon, "file_published", file_info); |
398 | + if (daemon != NULL) { |
399 | + SyncdaemonFileInfo *finfo; |
400 | + |
401 | + finfo = syncdaemon_file_info_new_from_hash_table (hash); |
402 | + g_signal_emit_by_name (daemon, "file_published", TRUE, finfo); |
403 | + |
404 | + g_object_unref (G_OBJECT (finfo)); |
405 | + } |
406 | } |
407 | |
408 | static void |
409 | @@ -67,19 +73,38 @@ |
410 | SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (user_data); |
411 | |
412 | g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL); |
413 | - if (daemon != NULL) |
414 | - g_signal_emit_by_name (daemon, "got_published_files", files); |
415 | + if (daemon != NULL) { |
416 | + GSList *finfo_list = NULL; |
417 | + guint i; |
418 | + |
419 | + for (i = 0; i < files->len; i++) { |
420 | + SyncdaemonFileInfo *finfo = syncdaemon_file_info_new_from_hash_table (g_ptr_array_index (files, i)); |
421 | + |
422 | + finfo_list = g_slist_append (finfo_list, finfo); |
423 | + } |
424 | + |
425 | + g_signal_emit_by_name (daemon, "got_published_files", TRUE, finfo_list); |
426 | + |
427 | + g_slist_foreach (finfo_list, (GFunc) g_object_unref, NULL); |
428 | + g_slist_free (finfo_list); |
429 | + } |
430 | } |
431 | |
432 | static void |
433 | -public_access_change_error_cb (DBusGProxy *proxy, GHashTable *file_info, gchar *error, gpointer user_data) |
434 | +public_access_change_error_cb (DBusGProxy *proxy, GHashTable *hash, gchar *error, gpointer user_data) |
435 | { |
436 | SyncdaemonDaemon *daemon = NULL; |
437 | SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (user_data); |
438 | |
439 | g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL); |
440 | - if (daemon != NULL) |
441 | - g_signal_emit_by_name (daemon, "error", error, file_info); |
442 | + if (daemon != NULL) { |
443 | + SyncdaemonFileInfo *finfo; |
444 | + |
445 | + finfo = syncdaemon_file_info_new_from_hash_table (hash); |
446 | + g_signal_emit_by_name (daemon, "file_published", FALSE, finfo); |
447 | + |
448 | + g_object_unref (G_OBJECT (finfo)); |
449 | + } |
450 | } |
451 | |
452 | static void |
453 | @@ -90,7 +115,7 @@ |
454 | |
455 | g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL); |
456 | if (daemon != NULL) |
457 | - g_signal_emit_by_name (daemon, "error", error, NULL); |
458 | + g_signal_emit_by_name (daemon, "got_published_files", FALSE, NULL); |
459 | } |
460 | |
461 | static void |
462 | |
463 | === modified file 'libsyncdaemon/test-libsyncdaemon.c' |
464 | --- libsyncdaemon/test-libsyncdaemon.c 2010-08-09 15:56:51 +0000 |
465 | +++ libsyncdaemon/test-libsyncdaemon.c 2010-08-25 20:03:47 +0000 |
466 | @@ -114,6 +114,48 @@ |
467 | } |
468 | |
469 | static void |
470 | +test_file_info (void) |
471 | +{ |
472 | + GHashTable *hash; |
473 | + SyncdaemonFileInfo *finfo; |
474 | + |
475 | + /* Test creating an empty SyncdaemonFileInfo */ |
476 | + finfo = syncdaemon_file_info_new (); |
477 | + g_assert (SYNCDAEMON_IS_FILE_INFO (finfo)); |
478 | + |
479 | + syncdaemon_file_info_set_path (finfo, TEST_PATH); |
480 | + g_assert (g_strcmp0 (syncdaemon_file_info_get_path (finfo), TEST_PATH) == 0); |
481 | + syncdaemon_file_info_set_volume_id (finfo, TEST_ID); |
482 | + g_assert (g_strcmp0 (syncdaemon_file_info_get_volume_id (finfo), TEST_ID) == 0); |
483 | + syncdaemon_file_info_set_node_id (finfo, TEST_ID); |
484 | + g_assert (g_strcmp0 (syncdaemon_file_info_get_node_id (finfo), TEST_ID) == 0); |
485 | + syncdaemon_file_info_set_public_url (finfo, TEST_PATH); |
486 | + g_assert (g_strcmp0 (syncdaemon_file_info_get_public_url (finfo), TEST_PATH) == 0); |
487 | + syncdaemon_file_info_set_is_public (finfo, TRUE); |
488 | + g_assert (syncdaemon_file_info_get_is_public (finfo)); |
489 | + |
490 | + g_object_unref (G_OBJECT (finfo)); |
491 | + |
492 | + /* Test creating a SyncdaemonFileInfo from a hash table */ |
493 | + hash = g_hash_table_new (g_str_hash, g_str_equal); |
494 | + g_hash_table_insert (hash, "volume_id", TEST_ID); |
495 | + g_hash_table_insert (hash, "node_id", TEST_ID); |
496 | + g_hash_table_insert (hash, "public_url", TEST_PATH); |
497 | + g_hash_table_insert (hash, "path", TEST_PATH); |
498 | + g_hash_table_insert (hash, "is_public", "True"); |
499 | + |
500 | + finfo = syncdaemon_file_info_new_from_hash_table (hash); |
501 | + g_assert (g_strcmp0 (syncdaemon_file_info_get_path (finfo), TEST_PATH) == 0); |
502 | + g_assert (g_strcmp0 (syncdaemon_file_info_get_volume_id (finfo), TEST_ID) == 0); |
503 | + g_assert (g_strcmp0 (syncdaemon_file_info_get_node_id (finfo), TEST_ID) == 0); |
504 | + g_assert (g_strcmp0 (syncdaemon_file_info_get_public_url (finfo), TEST_PATH) == 0); |
505 | + g_assert (syncdaemon_file_info_get_is_public (finfo)); |
506 | + |
507 | + g_object_unref (G_OBJECT (finfo)); |
508 | + g_hash_table_destroy (hash); |
509 | +} |
510 | + |
511 | +static void |
512 | test_folder_info (void) |
513 | { |
514 | GHashTable *hash; |
515 | @@ -477,6 +519,7 @@ |
516 | g_test_add_func ("/testlibsyncdaemon/TestDaemon", test_daemon); |
517 | g_test_add_func ("/testlibsyncdaemon/TestConfig", test_config); |
518 | g_test_add_func ("/testlibsyncdaemon/TestCredentials", test_credentials); |
519 | + g_test_add_func ("/testlibsyncdaemon/TestFileInfo", test_file_info); |
520 | g_test_add_func ("/testlibsyncdaemon/TestFolderInfo", test_folder_info); |
521 | g_test_add_func ("/testlibsyncdaemon/TestFolders", test_folders); |
522 | g_test_add_func ("/testlibsyncdaemon/TestMetadata", test_metadata); |
523 | |
524 | === modified file 'nautilus/Makefile.am' |
525 | --- nautilus/Makefile.am 2010-08-02 10:40:26 +0000 |
526 | +++ nautilus/Makefile.am 2010-08-25 20:03:47 +0000 |
527 | @@ -36,7 +36,8 @@ |
528 | ubuntuone-marshallers.c \ |
529 | ubuntuone-marshallers.h \ |
530 | ubuntuone-nautilus.c \ |
531 | - ubuntuone-nautilus.h |
532 | + ubuntuone-nautilus.h \ |
533 | + utils.c |
534 | |
535 | libnautilus_ubuntuone_la_LDFLAGS = -no-undefined -avoid-version |
536 | libnautilus_ubuntuone_la_LIBADD = \ |
537 | |
538 | === modified file 'nautilus/location-widget.c' |
539 | --- nautilus/location-widget.c 2010-08-25 14:37:39 +0000 |
540 | +++ nautilus/location-widget.c 2010-08-25 20:03:47 +0000 |
541 | @@ -110,106 +110,6 @@ |
542 | object_class->finalize = location_widget_finalize; |
543 | } |
544 | |
545 | -/* this is the wrong place for this, but it'll have to do for now */ |
546 | -gboolean |
547 | -location_widget_check_shared_for_folder (SyncdaemonDaemon *daemon, SyncdaemonFolderInfo *folder_info, GtkWidget *widget) |
548 | -{ |
549 | - SyncdaemonInterface *interface; |
550 | - GHashTable *shares = NULL; |
551 | - gboolean result = TRUE; |
552 | - |
553 | - interface = syncdaemon_daemon_get_shares_interface (daemon); |
554 | - if (SYNCDAEMON_IS_SHARES_INTERFACE (interface)) { |
555 | - GSList *shared_list, *l; |
556 | - |
557 | - shared_list = syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface)); |
558 | - for (l = shared_list; l != NULL; l = l->next) { |
559 | - SyncdaemonShareInfo *share_info = SYNCDAEMON_SHARE_INFO (shared_list->data); |
560 | - |
561 | - if (g_str_has_prefix (syncdaemon_share_info_get_path (share_info), |
562 | - syncdaemon_folder_info_get_path (folder_info)) |
563 | - && syncdaemon_share_info_get_accepted (share_info)) { |
564 | - gchar *path; |
565 | - const gchar *username; |
566 | - GSList *users = NULL; |
567 | - |
568 | - if (shares == NULL) |
569 | - shares = g_hash_table_new (g_str_hash, g_str_equal); |
570 | - |
571 | - g_hash_table_lookup_extended (shares, |
572 | - syncdaemon_share_info_get_path (share_info), |
573 | - (gpointer *) &path, |
574 | - (gpointer *) &users); |
575 | - |
576 | - /* Add the share and the user it's shared with to the hash table */ |
577 | - if (syncdaemon_share_info_get_user_visible_name (share_info) != NULL) |
578 | - username = syncdaemon_share_info_get_user_visible_name (share_info); |
579 | - else |
580 | - username = syncdaemon_share_info_get_username (share_info); |
581 | - |
582 | - users = g_slist_append (users, (gpointer) username); |
583 | - g_hash_table_insert (shares, |
584 | - (gpointer) syncdaemon_share_info_get_path (share_info), |
585 | - (gpointer) users); |
586 | - } |
587 | - } |
588 | - |
589 | - g_slist_free (shared_list); |
590 | - |
591 | - /* If there are shares, ask the user what to do */ |
592 | - if (shares != NULL) { |
593 | - GtkWidget *dialog; |
594 | - GHashTableIter iter; |
595 | - GString *question; |
596 | - gchar *path; |
597 | - GSList *users; |
598 | - |
599 | - question = g_string_new (_("This folder contains folders that have been shared:\n")); |
600 | - |
601 | - g_hash_table_iter_init (&iter, shares); |
602 | - while (g_hash_table_iter_next (&iter, (gpointer) &path, (gpointer) &users)) { |
603 | - gint count = 0; |
604 | - |
605 | - question = g_string_append (question, "\t- "); |
606 | - question = g_string_append (question, path); |
607 | - question = g_string_append (question, " ("); |
608 | - |
609 | - while (users != NULL) { |
610 | - gchar *username = (gchar *) users->data; |
611 | - |
612 | - if (count > 0) |
613 | - question = g_string_append (question, ", "); |
614 | - question = g_string_append (question, username); |
615 | - |
616 | - users = g_slist_remove (users, username); |
617 | - count += 1; |
618 | - } |
619 | - |
620 | - question = g_string_append (question, ")\n"); |
621 | - } |
622 | - |
623 | - question = g_string_append (question, _("This action will un-share these items. Other users" |
624 | - " will no longer be able to access these files." |
625 | - " Would you like to proceed?")); |
626 | - |
627 | - dialog = gtk_message_dialog_new ( |
628 | - GTK_WINDOW (gtk_widget_get_toplevel (widget)), |
629 | - 0, GTK_MESSAGE_QUESTION, |
630 | - GTK_BUTTONS_YES_NO, |
631 | - "%s", question->str); |
632 | - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) |
633 | - result = FALSE; |
634 | - |
635 | - gtk_widget_destroy (dialog); |
636 | - g_string_free (question, TRUE); |
637 | - g_hash_table_destroy (shares); |
638 | - } |
639 | - |
640 | - } |
641 | - |
642 | - return result; |
643 | -} |
644 | - |
645 | static void |
646 | disable_u1 (LocationWidget *location) |
647 | { |
648 | @@ -224,7 +124,7 @@ |
649 | SYNCDAEMON_FOLDERS_INTERFACE (interface), |
650 | location->path); |
651 | if (folder_info != NULL) { |
652 | - if (location_widget_check_shared_for_folder (location->uon->syncdaemon, folder_info, GTK_WIDGET (location))) { |
653 | + if (ubuntuone_nautilus_check_shares_and_public_files (location->uon, folder_info, GTK_WIDGET (location))) { |
654 | gtk_widget_set_sensitive (location->toggle_button, FALSE); |
655 | |
656 | syncdaemon_folders_interface_delete ( |
657 | |
658 | === modified file 'nautilus/ubuntuone-nautilus.c' |
659 | --- nautilus/ubuntuone-nautilus.c 2010-08-17 15:55:01 +0000 |
660 | +++ nautilus/ubuntuone-nautilus.c 2010-08-25 20:03:47 +0000 |
661 | @@ -98,10 +98,12 @@ |
662 | SyncdaemonFolderInfo *folder_info, |
663 | gpointer user_data); |
664 | static void ubuntuone_nautilus_file_published (SyncdaemonDaemon *daemon, |
665 | - GHashTable * hash, |
666 | + gboolean success, |
667 | + SyncdaemonFileInfo *finfo, |
668 | gpointer user_data); |
669 | static void ubuntuone_nautilus_got_public_files (SyncdaemonDaemon *daemon, |
670 | - GPtrArray * files, |
671 | + gboolean success, |
672 | + GSList *files, |
673 | gpointer user_data); |
674 | static void ubuntuone_nautilus_share_created (SyncdaemonDaemon *daemon, |
675 | gboolean success, |
676 | @@ -423,7 +425,7 @@ |
677 | folder_info = syncdaemon_folders_interface_get_info (SYNCDAEMON_FOLDERS_INTERFACE (interface), |
678 | data->path); |
679 | if (folder_info != NULL) { |
680 | - if (location_widget_check_shared_for_folder (data->uon->syncdaemon, folder_info, data->parent)) { |
681 | + if (ubuntuone_nautilus_check_shares_and_public_files (data->uon, folder_info, data->parent)) { |
682 | syncdaemon_folders_interface_delete (SYNCDAEMON_FOLDERS_INTERFACE (interface), |
683 | syncdaemon_folder_info_get_volume_id (folder_info)); |
684 | } |
685 | @@ -1122,16 +1124,19 @@ |
686 | } |
687 | |
688 | static void ubuntuone_nautilus_file_published (SyncdaemonDaemon *daemon, |
689 | - GHashTable *file_info, |
690 | + gboolean success, |
691 | + SyncdaemonFileInfo *finfo, |
692 | gpointer user_data) { |
693 | UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data); |
694 | - gchar * path, * url, * public; |
695 | + const gchar * path, * url; |
696 | gboolean is_public; |
697 | |
698 | - path = g_hash_table_lookup (file_info, "path"); |
699 | - url = g_hash_table_lookup (file_info, "public_url"); |
700 | - public = g_hash_table_lookup (file_info, "is_public"); |
701 | - is_public = (public != NULL && strlen (public) != 0); |
702 | + if (!success) |
703 | + return; |
704 | + |
705 | + path = syncdaemon_file_info_get_path (finfo); |
706 | + url = syncdaemon_file_info_get_public_url (finfo); |
707 | + is_public = syncdaemon_file_info_get_is_public (finfo); |
708 | |
709 | if (!is_public && g_hash_table_lookup (uon->public, path)) |
710 | g_hash_table_remove (uon->public, path); |
711 | @@ -1144,16 +1149,24 @@ |
712 | } |
713 | |
714 | static void ubuntuone_nautilus_got_public_files (SyncdaemonDaemon *daemon, |
715 | - GPtrArray *files, |
716 | + gboolean success, |
717 | + GSList *files, |
718 | gpointer user_data) { |
719 | UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data); |
720 | int i; |
721 | |
722 | - g_hash_table_remove_all (uon->public); |
723 | - for (i = 0; i < files->len; i++) |
724 | - g_hash_table_insert (uon->public, |
725 | - g_strdup (g_hash_table_lookup (files->pdata[i], "path")), |
726 | - g_strdup (g_hash_table_lookup (files->pdata[i], "public_url"))); |
727 | + if (success) { |
728 | + GSList *l; |
729 | + |
730 | + g_hash_table_remove_all (uon->public); |
731 | + for (l = files; l != NULL; l = l->next) { |
732 | + SyncdaemonFileInfo *finfo; |
733 | + |
734 | + g_hash_table_insert (uon->public, |
735 | + g_strdup (syncdaemon_file_info_get_path (finfo)), |
736 | + g_strdup (syncdaemon_file_info_get_public_url (finfo))); |
737 | + } |
738 | + } |
739 | } |
740 | |
741 | static void ubuntuone_nautilus_share_created (SyncdaemonDaemon *daemon, |
742 | |
743 | === modified file 'nautilus/ubuntuone-nautilus.h' |
744 | --- nautilus/ubuntuone-nautilus.h 2010-08-02 10:40:26 +0000 |
745 | +++ nautilus/ubuntuone-nautilus.h 2010-08-25 20:03:47 +0000 |
746 | @@ -26,6 +26,7 @@ |
747 | |
748 | #include <dbus/dbus-glib.h> |
749 | #include <libsyncdaemon/syncdaemon-daemon.h> |
750 | +#include <gtk/gtk.h> |
751 | |
752 | #define UBUNTUONE_TYPE_NAUTILUS (ubuntuone_nautilus_get_type ()) |
753 | #define UBUNTUONE_NAUTILUS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UBUNTUONE_TYPE_NAUTILUS, UbuntuOneNautilus)) |
754 | @@ -88,6 +89,9 @@ |
755 | gboolean ubuntuone_is_storagefs (UbuntuOneNautilus * uon, |
756 | const char * path, |
757 | gboolean * is_root); |
758 | +gboolean ubuntuone_nautilus_check_shares_and_public_files (UbuntuOneNautilus *uon, |
759 | + SyncdaemonFolderInfo *folder_info, |
760 | + GtkWidget *widget); |
761 | |
762 | void ubuntuone_show_error_dialog (UbuntuOneNautilus *uon, const gchar *title, const gchar *error_message, ...); |
763 | |
764 | |
765 | === added file 'nautilus/utils.c' |
766 | --- nautilus/utils.c 1970-01-01 00:00:00 +0000 |
767 | +++ nautilus/utils.c 2010-08-25 20:03:47 +0000 |
768 | @@ -0,0 +1,170 @@ |
769 | +/* |
770 | + * UbuntuOne Nautilus plugin |
771 | + * |
772 | + * Authors: Rodrigo Moya <rodrigo.moya@canonical.com> |
773 | + * |
774 | + * Copyright 2009-2010 Canonical Ltd. |
775 | + * |
776 | + * This program is free software: you can redistribute it and/or modify it |
777 | + * under the terms of the GNU General Public License version 3, as published |
778 | + * by the Free Software Foundation. |
779 | + * |
780 | + * This program is distributed in the hope that it will be useful, but |
781 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
782 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
783 | + * PURPOSE. See the GNU General Public License for more details. |
784 | + * |
785 | + * You should have received a copy of the GNU General Public License along |
786 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
787 | + * |
788 | + */ |
789 | + |
790 | +#include <glib/gi18n.h> |
791 | +#include <libsyncdaemon/syncdaemon-shares-interface.h> |
792 | +#include "ubuntuone-nautilus.h" |
793 | + |
794 | +/* this is the wrong place for this, but it'll have to do for now */ |
795 | +gboolean |
796 | +ubuntuone_nautilus_check_shares_and_public_files (UbuntuOneNautilus *uon, SyncdaemonFolderInfo *folder_info, GtkWidget *widget) |
797 | +{ |
798 | + SyncdaemonInterface *interface; |
799 | + GHashTable *shares = NULL; |
800 | + gboolean result = TRUE; |
801 | + |
802 | + interface = syncdaemon_daemon_get_shares_interface (uon->syncdaemon); |
803 | + if (SYNCDAEMON_IS_SHARES_INTERFACE (interface)) { |
804 | + GSList *shared_list, *l; |
805 | + |
806 | + shared_list = syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface)); |
807 | + for (l = shared_list; l != NULL; l = l->next) { |
808 | + SyncdaemonShareInfo *share_info = SYNCDAEMON_SHARE_INFO (shared_list->data); |
809 | + |
810 | + if (g_str_has_prefix (syncdaemon_share_info_get_path (share_info), |
811 | + syncdaemon_folder_info_get_path (folder_info)) |
812 | + && syncdaemon_share_info_get_accepted (share_info)) { |
813 | + gchar *path; |
814 | + const gchar *username; |
815 | + GSList *users = NULL; |
816 | + |
817 | + if (shares == NULL) |
818 | + shares = g_hash_table_new (g_str_hash, g_str_equal); |
819 | + |
820 | + g_hash_table_lookup_extended (shares, |
821 | + syncdaemon_share_info_get_path (share_info), |
822 | + (gpointer *) &path, |
823 | + (gpointer *) &users); |
824 | + |
825 | + /* Add the share and the user it's shared with to the hash table */ |
826 | + if (syncdaemon_share_info_get_user_visible_name (share_info) != NULL) |
827 | + username = syncdaemon_share_info_get_user_visible_name (share_info); |
828 | + else |
829 | + username = syncdaemon_share_info_get_username (share_info); |
830 | + |
831 | + users = g_slist_append (users, (gpointer) username); |
832 | + g_hash_table_insert (shares, |
833 | + (gpointer) syncdaemon_share_info_get_path (share_info), |
834 | + (gpointer) users); |
835 | + } |
836 | + } |
837 | + |
838 | + g_slist_free (shared_list); |
839 | + |
840 | + /* If there are shares, ask the user what to do */ |
841 | + if (shares != NULL) { |
842 | + GtkWidget *dialog; |
843 | + GHashTableIter iter; |
844 | + GString *question; |
845 | + gchar *path; |
846 | + GSList *users; |
847 | + |
848 | + question = g_string_new (_("This folder contains folders that have been shared:\n\n")); |
849 | + |
850 | + g_hash_table_iter_init (&iter, shares); |
851 | + while (g_hash_table_iter_next (&iter, (gpointer) &path, (gpointer) &users)) { |
852 | + gint count = 0; |
853 | + |
854 | + question = g_string_append (question, "\t- "); |
855 | + question = g_string_append (question, path); |
856 | + question = g_string_append (question, " ("); |
857 | + |
858 | + while (users != NULL) { |
859 | + gchar *username = (gchar *) users->data; |
860 | + |
861 | + if (count > 0) |
862 | + question = g_string_append (question, ", "); |
863 | + question = g_string_append (question, username); |
864 | + |
865 | + users = g_slist_remove (users, username); |
866 | + count += 1; |
867 | + } |
868 | + |
869 | + question = g_string_append (question, ")\n"); |
870 | + } |
871 | + |
872 | + question = g_string_append (question, _("\nThis action will un-share these items. Other users" |
873 | + " will no longer be able to access these files." |
874 | + " Would you like to proceed?")); |
875 | + |
876 | + dialog = gtk_message_dialog_new ( |
877 | + GTK_WINDOW (gtk_widget_get_toplevel (widget)), |
878 | + 0, GTK_MESSAGE_QUESTION, |
879 | + GTK_BUTTONS_YES_NO, |
880 | + "%s", question->str); |
881 | + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) |
882 | + result = FALSE; |
883 | + |
884 | + gtk_widget_destroy (dialog); |
885 | + g_string_free (question, TRUE); |
886 | + g_hash_table_destroy (shares); |
887 | + |
888 | + if (!result) |
889 | + return FALSE; |
890 | + } |
891 | + |
892 | + } |
893 | + |
894 | + /* Now check for published files */ |
895 | + if (uon->gotpubs) { |
896 | + GHashTableIter iter; |
897 | + gchar *key, *value; |
898 | + GString *question; |
899 | + gboolean has_published = FALSE; |
900 | + |
901 | + question = g_string_new (_("This folder contains files that have been published:\n\n")); |
902 | + |
903 | + g_hash_table_iter_init (&iter, uon->public); |
904 | + while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) { |
905 | + if (g_str_has_prefix (key, syncdaemon_folder_info_get_path (folder_info))) { |
906 | + has_published = TRUE; |
907 | + |
908 | + question = g_string_append (question, "\t- "); |
909 | + question = g_string_append (question, key); |
910 | + question = g_string_append (question, " ("); |
911 | + question = g_string_append (question, value); |
912 | + question = g_string_append (question, ")\n"); |
913 | + } |
914 | + } |
915 | + |
916 | + question = g_string_append (question, _("\nThis action will un-publish these items. Other users" |
917 | + " will no longer be able to access these files." |
918 | + " Would you like to proceeed?")); |
919 | + |
920 | + if (has_published) { |
921 | + GtkWidget *dialog; |
922 | + |
923 | + dialog = gtk_message_dialog_new ( |
924 | + GTK_WINDOW (gtk_widget_get_toplevel (widget)), |
925 | + 0, GTK_MESSAGE_QUESTION, |
926 | + GTK_BUTTONS_YES_NO, |
927 | + "%s", question->str); |
928 | + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) |
929 | + result = FALSE; |
930 | + |
931 | + gtk_widget_destroy (dialog); |
932 | + } |
933 | + |
934 | + g_string_free (question, TRUE); |
935 | + } |
936 | + |
937 | + return result; |
938 | +} |
939 | |
940 | === modified file 'po/POTFILES.in' |
941 | --- po/POTFILES.in 2010-08-20 21:09:00 +0000 |
942 | +++ po/POTFILES.in 2010-08-25 20:03:47 +0000 |
943 | @@ -10,5 +10,6 @@ |
944 | nautilus/u1-contacts-picker.c |
945 | nautilus/location-widget.c |
946 | nautilus/share-dialog.c |
947 | +nautilus/utils.c |
948 | gsd-plugin/gsd-ubuntuone.c |
949 | [type: gettext/ini]gsd-plugin/ubuntuone.gnome-settings-plugin.in |
Looks fine. I've added LP: #624212 to cover the case of two confirmation dialogs being shown in a row.