Merge lp:~rodrigo-moya/ubuntuone-client/check-published-files into lp:ubuntuone-client

Proposed by Rodrigo Moya
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
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

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

Looks fine. I've added LP: #624212 to cover the case of two confirmation dialogs being shown in a row.

review: Approve
Revision history for this message
dobey (dobey) wrote :
Download full text (52.6 KiB)

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/gnome-autogen.sh
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_MACRO_DIR, `m4'.
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-protocol=/var/cache/tarmac/ubuntuone-storage-protocol/trunk ...
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...

Revision history for this message
dobey (dobey) wrote :
Download full text (52.6 KiB)

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/gnome-autogen.sh
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_MACRO_DIR, `m4'.
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-protocol=/var/cache/tarmac/ubuntuone-storage-protocol/trunk ...
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libsyncdaemon/Makefile.am'
--- libsyncdaemon/Makefile.am 2010-08-13 19:25:17 +0000
+++ libsyncdaemon/Makefile.am 2010-08-25 20:03:47 +0000
@@ -26,6 +26,7 @@
26 syncdaemon-config-interface.h \26 syncdaemon-config-interface.h \
27 syncdaemon-credentials.h \27 syncdaemon-credentials.h \
28 syncdaemon-events-interface.h \28 syncdaemon-events-interface.h \
29 syncdaemon-file-info.h \
29 syncdaemon-filesystem-interface.h \30 syncdaemon-filesystem-interface.h \
30 syncdaemon-folder-info.h \31 syncdaemon-folder-info.h \
31 syncdaemon-folders-interface.h \32 syncdaemon-folders-interface.h \
@@ -46,6 +47,7 @@
46 syncdaemon-config-interface.c \47 syncdaemon-config-interface.c \
47 syncdaemon-credentials.c \48 syncdaemon-credentials.c \
48 syncdaemon-events-interface.c \49 syncdaemon-events-interface.c \
50 syncdaemon-file-info.c \
49 syncdaemon-filesystem-interface.c \51 syncdaemon-filesystem-interface.c \
50 syncdaemon-folder-info.c \52 syncdaemon-folder-info.c \
51 syncdaemon-folders-interface.c \53 syncdaemon-folders-interface.c \
5254
=== modified file 'libsyncdaemon/libsyncdaemon.h'
--- libsyncdaemon/libsyncdaemon.h 2010-08-09 15:56:51 +0000
+++ libsyncdaemon/libsyncdaemon.h 2010-08-25 20:03:47 +0000
@@ -24,6 +24,7 @@
24#include <libsyncdaemon/syncdaemon-credentials.h>24#include <libsyncdaemon/syncdaemon-credentials.h>
25#include <libsyncdaemon/syncdaemon-daemon.h>25#include <libsyncdaemon/syncdaemon-daemon.h>
26#include <libsyncdaemon/syncdaemon-events-interface.h>26#include <libsyncdaemon/syncdaemon-events-interface.h>
27#include <libsyncdaemon/syncdaemon-file-info.h>
27#include <libsyncdaemon/syncdaemon-filesystem-interface.h>28#include <libsyncdaemon/syncdaemon-filesystem-interface.h>
28#include <libsyncdaemon/syncdaemon-folder-info.h>29#include <libsyncdaemon/syncdaemon-folder-info.h>
29#include <libsyncdaemon/syncdaemon-folders-interface.h>30#include <libsyncdaemon/syncdaemon-folders-interface.h>
3031
=== modified file 'libsyncdaemon/syncdaemon-daemon.c'
--- libsyncdaemon/syncdaemon-daemon.c 2010-08-05 09:16:55 +0000
+++ libsyncdaemon/syncdaemon-daemon.c 2010-08-25 20:03:47 +0000
@@ -210,16 +210,18 @@
210 (GSignalFlags) G_SIGNAL_RUN_LAST,210 (GSignalFlags) G_SIGNAL_RUN_LAST,
211 G_STRUCT_OFFSET (SyncdaemonDaemonClass, file_published),211 G_STRUCT_OFFSET (SyncdaemonDaemonClass, file_published),
212 NULL, NULL,212 NULL, NULL,
213 g_cclosure_marshal_VOID__POINTER,213 _syncdaemon_marshal_VOID__BOOLEAN_OBJECT,
214 G_TYPE_NONE, 1,214 G_TYPE_NONE, 2,
215 G_TYPE_POINTER);215 G_TYPE_BOOLEAN,
216 G_TYPE_OBJECT);
216 daemon_signals[GOT_PUBLISHED_FILES_SIGNAL] = g_signal_new ("got_published_files",217 daemon_signals[GOT_PUBLISHED_FILES_SIGNAL] = g_signal_new ("got_published_files",
217 G_TYPE_FROM_CLASS (klass),218 G_TYPE_FROM_CLASS (klass),
218 (GSignalFlags) G_SIGNAL_RUN_LAST,219 (GSignalFlags) G_SIGNAL_RUN_LAST,
219 G_STRUCT_OFFSET (SyncdaemonDaemonClass, got_published_files),220 G_STRUCT_OFFSET (SyncdaemonDaemonClass, got_published_files),
220 NULL, NULL,221 NULL, NULL,
221 g_cclosure_marshal_VOID__POINTER,222 _syncdaemon_marshal_VOID__BOOLEAN_POINTER,
222 G_TYPE_NONE, 1,223 G_TYPE_NONE, 2,
224 G_TYPE_BOOLEAN,
223 G_TYPE_POINTER);225 G_TYPE_POINTER);
224 daemon_signals[SHARE_CREATED_SIGNAL] = g_signal_new ("share_created",226 daemon_signals[SHARE_CREATED_SIGNAL] = g_signal_new ("share_created",
225 G_TYPE_FROM_CLASS (klass),227 G_TYPE_FROM_CLASS (klass),
226228
=== modified file 'libsyncdaemon/syncdaemon-daemon.h'
--- libsyncdaemon/syncdaemon-daemon.h 2010-08-05 09:16:55 +0000
+++ libsyncdaemon/syncdaemon-daemon.h 2010-08-25 20:03:47 +0000
@@ -24,6 +24,7 @@
2424
25#include <glib-object.h>25#include <glib-object.h>
26#include "syncdaemon-authentication.h"26#include "syncdaemon-authentication.h"
27#include "syncdaemon-file-info.h"
27#include "syncdaemon-folder-info.h"28#include "syncdaemon-folder-info.h"
28#include "syncdaemon-interface.h"29#include "syncdaemon-interface.h"
29#include "syncdaemon-share-info.h"30#include "syncdaemon-share-info.h"
@@ -64,8 +65,8 @@
64 void (* folder_subscribed) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info);65 void (* folder_subscribed) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info);
65 void (* folder_unsubscribed) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info);66 void (* folder_unsubscribed) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFolderInfo *folder_info);
6667
67 void (* file_published) (SyncdaemonDaemon *daemon, GHashTable *file_info);68 void (* file_published) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonFileInfo *file_info);
68 void (* got_published_files) (SyncdaemonDaemon *daemon, GPtrArray *files);69 void (* got_published_files) (SyncdaemonDaemon *daemon, gboolean success, GSList *files);
6970
70 void (* share_created) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info);71 void (* share_created) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info);
71 void (* share_deleted) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info);72 void (* share_deleted) (SyncdaemonDaemon *daemon, gboolean success, SyncdaemonShareInfo *share_info);
7273
=== added file 'libsyncdaemon/syncdaemon-file-info.c'
--- libsyncdaemon/syncdaemon-file-info.c 1970-01-01 00:00:00 +0000
+++ libsyncdaemon/syncdaemon-file-info.c 2010-08-25 20:03:47 +0000
@@ -0,0 +1,223 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "syncdaemon-file-info.h"
23
24G_DEFINE_TYPE(SyncdaemonFileInfo, syncdaemon_file_info, G_TYPE_OBJECT)
25
26struct _SyncdaemonFileInfoPrivate {
27 gchar *volume_id;
28 gchar *node_id;
29 gchar *public_url;
30 gchar *path;
31 gboolean is_public;
32};
33
34static void
35syncdaemon_file_info_finalize (GObject *object)
36{
37 SyncdaemonFileInfo *finfo = SYNCDAEMON_FILE_INFO (object);
38
39 if (finfo->priv != NULL) {
40 if (finfo->priv->volume_id != NULL)
41 g_free (finfo->priv->volume_id);
42
43 if (finfo->priv->node_id != NULL)
44 g_free (finfo->priv->node_id);
45
46 if (finfo->priv->public_url != NULL)
47 g_free (finfo->priv->public_url);
48
49 if (finfo->priv->path != NULL)
50 g_free (finfo->priv->path);
51
52 g_free (finfo->priv);
53 }
54
55 G_OBJECT_CLASS (syncdaemon_file_info_parent_class)->finalize (object);
56}
57
58static void
59syncdaemon_file_info_class_init (SyncdaemonFileInfoClass *klass)
60{
61 GObjectClass *object_class = G_OBJECT_CLASS (klass);
62
63 object_class->finalize = syncdaemon_file_info_finalize;
64}
65
66static void
67syncdaemon_file_info_init (SyncdaemonFileInfo *finfo)
68{
69 finfo->priv = g_new0 (SyncdaemonFileInfoPrivate, 1);
70}
71
72/**
73 * syncdaemon_file_info_new:
74 */
75SyncdaemonFileInfo *
76syncdaemon_file_info_new (void)
77{
78 return g_object_new (SYNCDAEMON_TYPE_FILE_INFO, NULL);
79}
80
81/**
82 * syncdaemon_file_info_new_from_hash_table:
83 */
84SyncdaemonFileInfo *
85syncdaemon_file_info_new_from_hash_table (GHashTable *hash)
86{
87 SyncdaemonFileInfo *finfo;
88
89 finfo = g_object_new (SYNCDAEMON_TYPE_FILE_INFO, NULL);
90 if (hash != NULL) {
91 syncdaemon_file_info_set_volume_id (finfo, g_hash_table_lookup (hash, "volume_id"));
92 syncdaemon_file_info_set_node_id (finfo, g_hash_table_lookup (hash, "node_id"));
93 syncdaemon_file_info_set_public_url (finfo, g_hash_table_lookup (hash, "public_url"));
94 syncdaemon_file_info_set_path (finfo, g_hash_table_lookup (hash, "path"));
95 syncdaemon_file_info_set_is_public (
96 finfo,
97 g_strcmp0 (g_hash_table_lookup (hash, "is_public"), "True") == 0);
98 }
99
100 return finfo;
101}
102
103/**
104 * syncdaemon_file_info_get_volume_id:
105 */
106const gchar *
107syncdaemon_file_info_get_volume_id (SyncdaemonFileInfo *finfo)
108{
109 g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), NULL);
110
111 return (const gchar *) finfo->priv->volume_id;
112}
113
114/**
115 * syncdaemon_file_info_set_volume_id:
116 */
117void
118syncdaemon_file_info_set_volume_id (SyncdaemonFileInfo *finfo, const gchar *volume_id)
119{
120 g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo));
121
122 if (finfo->priv->volume_id != NULL)
123 g_free (finfo->priv->volume_id);
124
125 finfo->priv->volume_id = g_strdup (volume_id);
126}
127
128/**
129 * syncdaemon_file_info_get_node_id:
130 */
131const gchar *
132syncdaemon_file_info_get_node_id (SyncdaemonFileInfo *finfo)
133{
134 g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), NULL);
135
136 return (const gchar *) finfo->priv->node_id;
137}
138
139/**
140 * syncdaemon_file_info_set_node_id:
141 */
142void
143syncdaemon_file_info_set_node_id (SyncdaemonFileInfo *finfo, const gchar *node_id)
144{
145 g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo));
146
147 if (finfo->priv->node_id != NULL)
148 g_free (finfo->priv->node_id);
149
150 finfo->priv->node_id = g_strdup (node_id);
151}
152
153/**
154 * syncdaemon_file_info_get_public_url:
155 */
156const gchar *
157syncdaemon_file_info_get_public_url (SyncdaemonFileInfo *finfo)
158{
159 g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), NULL);
160
161 return (const gchar *) finfo->priv->public_url;
162}
163
164/**
165 * syncdaemon_file_info_set_public_url:
166 */
167void
168syncdaemon_file_info_set_public_url (SyncdaemonFileInfo *finfo, const gchar *public_url)
169{
170 g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo));
171
172 if (finfo->priv->public_url != NULL)
173 g_free (finfo->priv->public_url);
174
175 finfo->priv->public_url = g_strdup (public_url);
176}
177
178/**
179 * syncdaemon_file_info_get_path:
180 */
181const gchar *
182syncdaemon_file_info_get_path (SyncdaemonFileInfo *finfo)
183{
184 g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), NULL);
185
186 return (const gchar *) finfo->priv->path;
187}
188
189/**
190 * syncdaemon_file_info_set_path:
191 */
192void
193syncdaemon_file_info_set_path (SyncdaemonFileInfo *finfo, const gchar *path)
194{
195 g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo));
196
197 if (finfo->priv->path != NULL)
198 g_free (finfo->priv->path);
199
200 finfo->priv->path = g_strdup (path);
201}
202
203/**
204 * syncdaemon_file_info_get_is_public:
205 */
206gboolean
207syncdaemon_file_info_get_is_public (SyncdaemonFileInfo *finfo)
208{
209 g_return_val_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo), FALSE);
210
211 return finfo->priv->is_public;
212}
213
214/**
215 * syncdaemon_file_info_set_is_public:
216 */
217void
218syncdaemon_file_info_set_is_public (SyncdaemonFileInfo *finfo, gboolean is_public)
219{
220 g_return_if_fail (SYNCDAEMON_IS_FILE_INFO (finfo));
221
222 finfo->priv->is_public = is_public;
223}
0224
=== added file 'libsyncdaemon/syncdaemon-file-info.h'
--- libsyncdaemon/syncdaemon-file-info.h 1970-01-01 00:00:00 +0000
+++ libsyncdaemon/syncdaemon-file-info.h 2010-08-25 20:03:47 +0000
@@ -0,0 +1,65 @@
1/*
2 * Syncdaemon API
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2010 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef __SYNCDAEMON_FILE_INFO_H__
23#define __SYNCDAEMON_FILE_INFO_H__
24
25#include <glib-object.h>
26
27G_BEGIN_DECLS
28
29#define SYNCDAEMON_TYPE_FILE_INFO (syncdaemon_file_info_get_type ())
30#define SYNCDAEMON_FILE_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SYNCDAEMON_TYPE_FILE_INFO, SyncdaemonFileInfo))
31#define SYNCDAEMON_IS_FILE_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SYNCDAEMON_TYPE_FILE_INFO))
32#define SYNCDAEMON_FILE_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SYNCDAEMON_TYPE_FILE_INFO, SyncdaemonFileInfoClass))
33#define SYNCDAEMON_IS_FILE_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SYNCDAEMON_TYPE_FILE_INFO))
34#define SYNCDAEMON_FILE_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SYNCDAEMON_TYPE_FILE_INFO, SyncdaemonFileInfoClass))
35
36typedef struct _SyncdaemonFileInfoPrivate SyncdaemonFileInfoPrivate;
37
38typedef struct {
39 GObject parent;
40 SyncdaemonFileInfoPrivate *priv;
41} SyncdaemonFileInfo;
42
43typedef struct {
44 GObjectClass parent_class;
45} SyncdaemonFileInfoClass;
46
47GType syncdaemon_file_info_get_type (void);
48SyncdaemonFileInfo *syncdaemon_file_info_new (void);
49SyncdaemonFileInfo *syncdaemon_file_info_new_from_hash_table (GHashTable *hash);
50
51const gchar *syncdaemon_file_info_get_volume_id (SyncdaemonFileInfo *finfo);
52void syncdaemon_file_info_set_volume_id (SyncdaemonFileInfo *finfo, const gchar *volume_id);
53const gchar *syncdaemon_file_info_get_node_id (SyncdaemonFileInfo *finfo);
54void syncdaemon_file_info_set_node_id (SyncdaemonFileInfo *finfo, const gchar *node_id);
55const gchar *syncdaemon_file_info_get_path (SyncdaemonFileInfo *finfo);
56void syncdaemon_file_info_set_path (SyncdaemonFileInfo *finfo, const gchar *path);
57
58gboolean syncdaemon_file_info_get_is_public (SyncdaemonFileInfo *finfo);
59void syncdaemon_file_info_set_is_public (SyncdaemonFileInfo *finfo, gboolean is_public);
60const gchar *syncdaemon_file_info_get_public_url (SyncdaemonFileInfo *finfo);
61void syncdaemon_file_info_set_public_url (SyncdaemonFileInfo *finfo, const gchar *public_url);
62
63G_END_DECLS
64
65#endif
066
=== modified file 'libsyncdaemon/syncdaemon-publicfiles-interface.c'
--- libsyncdaemon/syncdaemon-publicfiles-interface.c 2010-06-09 22:46:42 +0000
+++ libsyncdaemon/syncdaemon-publicfiles-interface.c 2010-08-25 20:03:47 +0000
@@ -50,14 +50,20 @@
50}50}
5151
52static void52static void
53file_published_cb (DBusGProxy *proxy, GHashTable *file_info, gpointer user_data)53file_published_cb (DBusGProxy *proxy, GHashTable *hash, gpointer user_data)
54{54{
55 SyncdaemonDaemon *daemon = NULL;55 SyncdaemonDaemon *daemon = NULL;
56 SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (user_data);56 SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (user_data);
5757
58 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);58 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
59 if (daemon != NULL)59 if (daemon != NULL) {
60 g_signal_emit_by_name (daemon, "file_published", file_info);60 SyncdaemonFileInfo *finfo;
61
62 finfo = syncdaemon_file_info_new_from_hash_table (hash);
63 g_signal_emit_by_name (daemon, "file_published", TRUE, finfo);
64
65 g_object_unref (G_OBJECT (finfo));
66 }
61}67}
6268
63static void69static void
@@ -67,19 +73,38 @@
67 SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (user_data);73 SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (user_data);
6874
69 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);75 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
70 if (daemon != NULL)76 if (daemon != NULL) {
71 g_signal_emit_by_name (daemon, "got_published_files", files);77 GSList *finfo_list = NULL;
78 guint i;
79
80 for (i = 0; i < files->len; i++) {
81 SyncdaemonFileInfo *finfo = syncdaemon_file_info_new_from_hash_table (g_ptr_array_index (files, i));
82
83 finfo_list = g_slist_append (finfo_list, finfo);
84 }
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 }
72}91}
7392
74static void93static void
75public_access_change_error_cb (DBusGProxy *proxy, GHashTable *file_info, gchar *error, gpointer user_data)94public_access_change_error_cb (DBusGProxy *proxy, GHashTable *hash, gchar *error, gpointer user_data)
76{95{
77 SyncdaemonDaemon *daemon = NULL;96 SyncdaemonDaemon *daemon = NULL;
78 SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (user_data);97 SyncdaemonPublicfilesInterface *interface = SYNCDAEMON_PUBLICFILES_INTERFACE (user_data);
7998
80 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);99 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
81 if (daemon != NULL)100 if (daemon != NULL) {
82 g_signal_emit_by_name (daemon, "error", error, file_info);101 SyncdaemonFileInfo *finfo;
102
103 finfo = syncdaemon_file_info_new_from_hash_table (hash);
104 g_signal_emit_by_name (daemon, "file_published", FALSE, finfo);
105
106 g_object_unref (G_OBJECT (finfo));
107 }
83}108}
84109
85static void110static void
@@ -90,7 +115,7 @@
90115
91 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);116 g_object_get (G_OBJECT (interface), "daemon", &daemon, NULL);
92 if (daemon != NULL)117 if (daemon != NULL)
93 g_signal_emit_by_name (daemon, "error", error, NULL);118 g_signal_emit_by_name (daemon, "got_published_files", FALSE, NULL);
94}119}
95120
96static void121static void
97122
=== modified file 'libsyncdaemon/test-libsyncdaemon.c'
--- libsyncdaemon/test-libsyncdaemon.c 2010-08-09 15:56:51 +0000
+++ libsyncdaemon/test-libsyncdaemon.c 2010-08-25 20:03:47 +0000
@@ -114,6 +114,48 @@
114}114}
115115
116static void116static void
117test_file_info (void)
118{
119 GHashTable *hash;
120 SyncdaemonFileInfo *finfo;
121
122 /* Test creating an empty SyncdaemonFileInfo */
123 finfo = syncdaemon_file_info_new ();
124 g_assert (SYNCDAEMON_IS_FILE_INFO (finfo));
125
126 syncdaemon_file_info_set_path (finfo, TEST_PATH);
127 g_assert (g_strcmp0 (syncdaemon_file_info_get_path (finfo), TEST_PATH) == 0);
128 syncdaemon_file_info_set_volume_id (finfo, TEST_ID);
129 g_assert (g_strcmp0 (syncdaemon_file_info_get_volume_id (finfo), TEST_ID) == 0);
130 syncdaemon_file_info_set_node_id (finfo, TEST_ID);
131 g_assert (g_strcmp0 (syncdaemon_file_info_get_node_id (finfo), TEST_ID) == 0);
132 syncdaemon_file_info_set_public_url (finfo, TEST_PATH);
133 g_assert (g_strcmp0 (syncdaemon_file_info_get_public_url (finfo), TEST_PATH) == 0);
134 syncdaemon_file_info_set_is_public (finfo, TRUE);
135 g_assert (syncdaemon_file_info_get_is_public (finfo));
136
137 g_object_unref (G_OBJECT (finfo));
138
139 /* Test creating a SyncdaemonFileInfo from a hash table */
140 hash = g_hash_table_new (g_str_hash, g_str_equal);
141 g_hash_table_insert (hash, "volume_id", TEST_ID);
142 g_hash_table_insert (hash, "node_id", TEST_ID);
143 g_hash_table_insert (hash, "public_url", TEST_PATH);
144 g_hash_table_insert (hash, "path", TEST_PATH);
145 g_hash_table_insert (hash, "is_public", "True");
146
147 finfo = syncdaemon_file_info_new_from_hash_table (hash);
148 g_assert (g_strcmp0 (syncdaemon_file_info_get_path (finfo), TEST_PATH) == 0);
149 g_assert (g_strcmp0 (syncdaemon_file_info_get_volume_id (finfo), TEST_ID) == 0);
150 g_assert (g_strcmp0 (syncdaemon_file_info_get_node_id (finfo), TEST_ID) == 0);
151 g_assert (g_strcmp0 (syncdaemon_file_info_get_public_url (finfo), TEST_PATH) == 0);
152 g_assert (syncdaemon_file_info_get_is_public (finfo));
153
154 g_object_unref (G_OBJECT (finfo));
155 g_hash_table_destroy (hash);
156}
157
158static void
117test_folder_info (void)159test_folder_info (void)
118{160{
119 GHashTable *hash;161 GHashTable *hash;
@@ -477,6 +519,7 @@
477 g_test_add_func ("/testlibsyncdaemon/TestDaemon", test_daemon);519 g_test_add_func ("/testlibsyncdaemon/TestDaemon", test_daemon);
478 g_test_add_func ("/testlibsyncdaemon/TestConfig", test_config);520 g_test_add_func ("/testlibsyncdaemon/TestConfig", test_config);
479 g_test_add_func ("/testlibsyncdaemon/TestCredentials", test_credentials);521 g_test_add_func ("/testlibsyncdaemon/TestCredentials", test_credentials);
522 g_test_add_func ("/testlibsyncdaemon/TestFileInfo", test_file_info);
480 g_test_add_func ("/testlibsyncdaemon/TestFolderInfo", test_folder_info);523 g_test_add_func ("/testlibsyncdaemon/TestFolderInfo", test_folder_info);
481 g_test_add_func ("/testlibsyncdaemon/TestFolders", test_folders);524 g_test_add_func ("/testlibsyncdaemon/TestFolders", test_folders);
482 g_test_add_func ("/testlibsyncdaemon/TestMetadata", test_metadata);525 g_test_add_func ("/testlibsyncdaemon/TestMetadata", test_metadata);
483526
=== modified file 'nautilus/Makefile.am'
--- nautilus/Makefile.am 2010-08-02 10:40:26 +0000
+++ nautilus/Makefile.am 2010-08-25 20:03:47 +0000
@@ -36,7 +36,8 @@
36 ubuntuone-marshallers.c \36 ubuntuone-marshallers.c \
37 ubuntuone-marshallers.h \37 ubuntuone-marshallers.h \
38 ubuntuone-nautilus.c \38 ubuntuone-nautilus.c \
39 ubuntuone-nautilus.h39 ubuntuone-nautilus.h \
40 utils.c
4041
41libnautilus_ubuntuone_la_LDFLAGS = -no-undefined -avoid-version42libnautilus_ubuntuone_la_LDFLAGS = -no-undefined -avoid-version
42libnautilus_ubuntuone_la_LIBADD = \43libnautilus_ubuntuone_la_LIBADD = \
4344
=== modified file 'nautilus/location-widget.c'
--- nautilus/location-widget.c 2010-08-25 14:37:39 +0000
+++ nautilus/location-widget.c 2010-08-25 20:03:47 +0000
@@ -110,106 +110,6 @@
110 object_class->finalize = location_widget_finalize;110 object_class->finalize = location_widget_finalize;
111}111}
112112
113/* this is the wrong place for this, but it'll have to do for now */
114gboolean
115location_widget_check_shared_for_folder (SyncdaemonDaemon *daemon, SyncdaemonFolderInfo *folder_info, GtkWidget *widget)
116{
117 SyncdaemonInterface *interface;
118 GHashTable *shares = NULL;
119 gboolean result = TRUE;
120
121 interface = syncdaemon_daemon_get_shares_interface (daemon);
122 if (SYNCDAEMON_IS_SHARES_INTERFACE (interface)) {
123 GSList *shared_list, *l;
124
125 shared_list = syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface));
126 for (l = shared_list; l != NULL; l = l->next) {
127 SyncdaemonShareInfo *share_info = SYNCDAEMON_SHARE_INFO (shared_list->data);
128
129 if (g_str_has_prefix (syncdaemon_share_info_get_path (share_info),
130 syncdaemon_folder_info_get_path (folder_info))
131 && syncdaemon_share_info_get_accepted (share_info)) {
132 gchar *path;
133 const gchar *username;
134 GSList *users = NULL;
135
136 if (shares == NULL)
137 shares = g_hash_table_new (g_str_hash, g_str_equal);
138
139 g_hash_table_lookup_extended (shares,
140 syncdaemon_share_info_get_path (share_info),
141 (gpointer *) &path,
142 (gpointer *) &users);
143
144 /* Add the share and the user it's shared with to the hash table */
145 if (syncdaemon_share_info_get_user_visible_name (share_info) != NULL)
146 username = syncdaemon_share_info_get_user_visible_name (share_info);
147 else
148 username = syncdaemon_share_info_get_username (share_info);
149
150 users = g_slist_append (users, (gpointer) username);
151 g_hash_table_insert (shares,
152 (gpointer) syncdaemon_share_info_get_path (share_info),
153 (gpointer) users);
154 }
155 }
156
157 g_slist_free (shared_list);
158
159 /* If there are shares, ask the user what to do */
160 if (shares != NULL) {
161 GtkWidget *dialog;
162 GHashTableIter iter;
163 GString *question;
164 gchar *path;
165 GSList *users;
166
167 question = g_string_new (_("This folder contains folders that have been shared:\n"));
168
169 g_hash_table_iter_init (&iter, shares);
170 while (g_hash_table_iter_next (&iter, (gpointer) &path, (gpointer) &users)) {
171 gint count = 0;
172
173 question = g_string_append (question, "\t- ");
174 question = g_string_append (question, path);
175 question = g_string_append (question, " (");
176
177 while (users != NULL) {
178 gchar *username = (gchar *) users->data;
179
180 if (count > 0)
181 question = g_string_append (question, ", ");
182 question = g_string_append (question, username);
183
184 users = g_slist_remove (users, username);
185 count += 1;
186 }
187
188 question = g_string_append (question, ")\n");
189 }
190
191 question = g_string_append (question, _("This action will un-share these items. Other users"
192 " will no longer be able to access these files."
193 " Would you like to proceed?"));
194
195 dialog = gtk_message_dialog_new (
196 GTK_WINDOW (gtk_widget_get_toplevel (widget)),
197 0, GTK_MESSAGE_QUESTION,
198 GTK_BUTTONS_YES_NO,
199 "%s", question->str);
200 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
201 result = FALSE;
202
203 gtk_widget_destroy (dialog);
204 g_string_free (question, TRUE);
205 g_hash_table_destroy (shares);
206 }
207
208 }
209
210 return result;
211}
212
213static void113static void
214disable_u1 (LocationWidget *location)114disable_u1 (LocationWidget *location)
215{115{
@@ -224,7 +124,7 @@
224 SYNCDAEMON_FOLDERS_INTERFACE (interface),124 SYNCDAEMON_FOLDERS_INTERFACE (interface),
225 location->path);125 location->path);
226 if (folder_info != NULL) {126 if (folder_info != NULL) {
227 if (location_widget_check_shared_for_folder (location->uon->syncdaemon, folder_info, GTK_WIDGET (location))) {127 if (ubuntuone_nautilus_check_shares_and_public_files (location->uon, folder_info, GTK_WIDGET (location))) {
228 gtk_widget_set_sensitive (location->toggle_button, FALSE);128 gtk_widget_set_sensitive (location->toggle_button, FALSE);
229129
230 syncdaemon_folders_interface_delete (130 syncdaemon_folders_interface_delete (
231131
=== modified file 'nautilus/ubuntuone-nautilus.c'
--- nautilus/ubuntuone-nautilus.c 2010-08-17 15:55:01 +0000
+++ nautilus/ubuntuone-nautilus.c 2010-08-25 20:03:47 +0000
@@ -98,10 +98,12 @@
98 SyncdaemonFolderInfo *folder_info,98 SyncdaemonFolderInfo *folder_info,
99 gpointer user_data);99 gpointer user_data);
100static void ubuntuone_nautilus_file_published (SyncdaemonDaemon *daemon,100static void ubuntuone_nautilus_file_published (SyncdaemonDaemon *daemon,
101 GHashTable * hash,101 gboolean success,
102 SyncdaemonFileInfo *finfo,
102 gpointer user_data);103 gpointer user_data);
103static void ubuntuone_nautilus_got_public_files (SyncdaemonDaemon *daemon,104static void ubuntuone_nautilus_got_public_files (SyncdaemonDaemon *daemon,
104 GPtrArray * files,105 gboolean success,
106 GSList *files,
105 gpointer user_data);107 gpointer user_data);
106static void ubuntuone_nautilus_share_created (SyncdaemonDaemon *daemon,108static void ubuntuone_nautilus_share_created (SyncdaemonDaemon *daemon,
107 gboolean success,109 gboolean success,
@@ -423,7 +425,7 @@
423 folder_info = syncdaemon_folders_interface_get_info (SYNCDAEMON_FOLDERS_INTERFACE (interface),425 folder_info = syncdaemon_folders_interface_get_info (SYNCDAEMON_FOLDERS_INTERFACE (interface),
424 data->path);426 data->path);
425 if (folder_info != NULL) {427 if (folder_info != NULL) {
426 if (location_widget_check_shared_for_folder (data->uon->syncdaemon, folder_info, data->parent)) {428 if (ubuntuone_nautilus_check_shares_and_public_files (data->uon, folder_info, data->parent)) {
427 syncdaemon_folders_interface_delete (SYNCDAEMON_FOLDERS_INTERFACE (interface),429 syncdaemon_folders_interface_delete (SYNCDAEMON_FOLDERS_INTERFACE (interface),
428 syncdaemon_folder_info_get_volume_id (folder_info));430 syncdaemon_folder_info_get_volume_id (folder_info));
429 }431 }
@@ -1122,16 +1124,19 @@
1122}1124}
11231125
1124static void ubuntuone_nautilus_file_published (SyncdaemonDaemon *daemon,1126static void ubuntuone_nautilus_file_published (SyncdaemonDaemon *daemon,
1125 GHashTable *file_info,1127 gboolean success,
1128 SyncdaemonFileInfo *finfo,
1126 gpointer user_data) {1129 gpointer user_data) {
1127 UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data);1130 UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data);
1128 gchar * path, * url, * public;1131 const gchar * path, * url;
1129 gboolean is_public;1132 gboolean is_public;
11301133
1131 path = g_hash_table_lookup (file_info, "path");1134 if (!success)
1132 url = g_hash_table_lookup (file_info, "public_url");1135 return;
1133 public = g_hash_table_lookup (file_info, "is_public");1136
1134 is_public = (public != NULL && strlen (public) != 0);1137 path = syncdaemon_file_info_get_path (finfo);
1138 url = syncdaemon_file_info_get_public_url (finfo);
1139 is_public = syncdaemon_file_info_get_is_public (finfo);
11351140
1136 if (!is_public && g_hash_table_lookup (uon->public, path))1141 if (!is_public && g_hash_table_lookup (uon->public, path))
1137 g_hash_table_remove (uon->public, path);1142 g_hash_table_remove (uon->public, path);
@@ -1144,16 +1149,24 @@
1144}1149}
11451150
1146static void ubuntuone_nautilus_got_public_files (SyncdaemonDaemon *daemon,1151static void ubuntuone_nautilus_got_public_files (SyncdaemonDaemon *daemon,
1147 GPtrArray *files,1152 gboolean success,
1153 GSList *files,
1148 gpointer user_data) {1154 gpointer user_data) {
1149 UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data);1155 UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS (user_data);
1150 int i;1156 int i;
11511157
1152 g_hash_table_remove_all (uon->public);1158 if (success) {
1153 for (i = 0; i < files->len; i++)1159 GSList *l;
1154 g_hash_table_insert (uon->public,1160
1155 g_strdup (g_hash_table_lookup (files->pdata[i], "path")),1161 g_hash_table_remove_all (uon->public);
1156 g_strdup (g_hash_table_lookup (files->pdata[i], "public_url")));1162 for (l = files; l != NULL; l = l->next) {
1163 SyncdaemonFileInfo *finfo;
1164
1165 g_hash_table_insert (uon->public,
1166 g_strdup (syncdaemon_file_info_get_path (finfo)),
1167 g_strdup (syncdaemon_file_info_get_public_url (finfo)));
1168 }
1169 }
1157}1170}
11581171
1159static void ubuntuone_nautilus_share_created (SyncdaemonDaemon *daemon,1172static void ubuntuone_nautilus_share_created (SyncdaemonDaemon *daemon,
11601173
=== modified file 'nautilus/ubuntuone-nautilus.h'
--- nautilus/ubuntuone-nautilus.h 2010-08-02 10:40:26 +0000
+++ nautilus/ubuntuone-nautilus.h 2010-08-25 20:03:47 +0000
@@ -26,6 +26,7 @@
2626
27#include <dbus/dbus-glib.h>27#include <dbus/dbus-glib.h>
28#include <libsyncdaemon/syncdaemon-daemon.h>28#include <libsyncdaemon/syncdaemon-daemon.h>
29#include <gtk/gtk.h>
2930
30#define UBUNTUONE_TYPE_NAUTILUS (ubuntuone_nautilus_get_type ())31#define UBUNTUONE_TYPE_NAUTILUS (ubuntuone_nautilus_get_type ())
31#define UBUNTUONE_NAUTILUS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UBUNTUONE_TYPE_NAUTILUS, UbuntuOneNautilus))32#define UBUNTUONE_NAUTILUS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UBUNTUONE_TYPE_NAUTILUS, UbuntuOneNautilus))
@@ -88,6 +89,9 @@
88gboolean ubuntuone_is_storagefs (UbuntuOneNautilus * uon,89gboolean ubuntuone_is_storagefs (UbuntuOneNautilus * uon,
89 const char * path,90 const char * path,
90 gboolean * is_root);91 gboolean * is_root);
92gboolean ubuntuone_nautilus_check_shares_and_public_files (UbuntuOneNautilus *uon,
93 SyncdaemonFolderInfo *folder_info,
94 GtkWidget *widget);
9195
92void ubuntuone_show_error_dialog (UbuntuOneNautilus *uon, const gchar *title, const gchar *error_message, ...);96void ubuntuone_show_error_dialog (UbuntuOneNautilus *uon, const gchar *title, const gchar *error_message, ...);
9397
9498
=== added file 'nautilus/utils.c'
--- nautilus/utils.c 1970-01-01 00:00:00 +0000
+++ nautilus/utils.c 2010-08-25 20:03:47 +0000
@@ -0,0 +1,170 @@
1/*
2 * UbuntuOne Nautilus plugin
3 *
4 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
5 *
6 * Copyright 2009-2010 Canonical Ltd.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include <glib/gi18n.h>
23#include <libsyncdaemon/syncdaemon-shares-interface.h>
24#include "ubuntuone-nautilus.h"
25
26/* this is the wrong place for this, but it'll have to do for now */
27gboolean
28ubuntuone_nautilus_check_shares_and_public_files (UbuntuOneNautilus *uon, SyncdaemonFolderInfo *folder_info, GtkWidget *widget)
29{
30 SyncdaemonInterface *interface;
31 GHashTable *shares = NULL;
32 gboolean result = TRUE;
33
34 interface = syncdaemon_daemon_get_shares_interface (uon->syncdaemon);
35 if (SYNCDAEMON_IS_SHARES_INTERFACE (interface)) {
36 GSList *shared_list, *l;
37
38 shared_list = syncdaemon_shares_interface_get_shared (SYNCDAEMON_SHARES_INTERFACE (interface));
39 for (l = shared_list; l != NULL; l = l->next) {
40 SyncdaemonShareInfo *share_info = SYNCDAEMON_SHARE_INFO (shared_list->data);
41
42 if (g_str_has_prefix (syncdaemon_share_info_get_path (share_info),
43 syncdaemon_folder_info_get_path (folder_info))
44 && syncdaemon_share_info_get_accepted (share_info)) {
45 gchar *path;
46 const gchar *username;
47 GSList *users = NULL;
48
49 if (shares == NULL)
50 shares = g_hash_table_new (g_str_hash, g_str_equal);
51
52 g_hash_table_lookup_extended (shares,
53 syncdaemon_share_info_get_path (share_info),
54 (gpointer *) &path,
55 (gpointer *) &users);
56
57 /* Add the share and the user it's shared with to the hash table */
58 if (syncdaemon_share_info_get_user_visible_name (share_info) != NULL)
59 username = syncdaemon_share_info_get_user_visible_name (share_info);
60 else
61 username = syncdaemon_share_info_get_username (share_info);
62
63 users = g_slist_append (users, (gpointer) username);
64 g_hash_table_insert (shares,
65 (gpointer) syncdaemon_share_info_get_path (share_info),
66 (gpointer) users);
67 }
68 }
69
70 g_slist_free (shared_list);
71
72 /* If there are shares, ask the user what to do */
73 if (shares != NULL) {
74 GtkWidget *dialog;
75 GHashTableIter iter;
76 GString *question;
77 gchar *path;
78 GSList *users;
79
80 question = g_string_new (_("This folder contains folders that have been shared:\n\n"));
81
82 g_hash_table_iter_init (&iter, shares);
83 while (g_hash_table_iter_next (&iter, (gpointer) &path, (gpointer) &users)) {
84 gint count = 0;
85
86 question = g_string_append (question, "\t- ");
87 question = g_string_append (question, path);
88 question = g_string_append (question, " (");
89
90 while (users != NULL) {
91 gchar *username = (gchar *) users->data;
92
93 if (count > 0)
94 question = g_string_append (question, ", ");
95 question = g_string_append (question, username);
96
97 users = g_slist_remove (users, username);
98 count += 1;
99 }
100
101 question = g_string_append (question, ")\n");
102 }
103
104 question = g_string_append (question, _("\nThis action will un-share these items. Other users"
105 " will no longer be able to access these files."
106 " Would you like to proceed?"));
107
108 dialog = gtk_message_dialog_new (
109 GTK_WINDOW (gtk_widget_get_toplevel (widget)),
110 0, GTK_MESSAGE_QUESTION,
111 GTK_BUTTONS_YES_NO,
112 "%s", question->str);
113 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
114 result = FALSE;
115
116 gtk_widget_destroy (dialog);
117 g_string_free (question, TRUE);
118 g_hash_table_destroy (shares);
119
120 if (!result)
121 return FALSE;
122 }
123
124 }
125
126 /* Now check for published files */
127 if (uon->gotpubs) {
128 GHashTableIter iter;
129 gchar *key, *value;
130 GString *question;
131 gboolean has_published = FALSE;
132
133 question = g_string_new (_("This folder contains files that have been published:\n\n"));
134
135 g_hash_table_iter_init (&iter, uon->public);
136 while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) {
137 if (g_str_has_prefix (key, syncdaemon_folder_info_get_path (folder_info))) {
138 has_published = TRUE;
139
140 question = g_string_append (question, "\t- ");
141 question = g_string_append (question, key);
142 question = g_string_append (question, " (");
143 question = g_string_append (question, value);
144 question = g_string_append (question, ")\n");
145 }
146 }
147
148 question = g_string_append (question, _("\nThis action will un-publish these items. Other users"
149 " will no longer be able to access these files."
150 " Would you like to proceeed?"));
151
152 if (has_published) {
153 GtkWidget *dialog;
154
155 dialog = gtk_message_dialog_new (
156 GTK_WINDOW (gtk_widget_get_toplevel (widget)),
157 0, GTK_MESSAGE_QUESTION,
158 GTK_BUTTONS_YES_NO,
159 "%s", question->str);
160 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
161 result = FALSE;
162
163 gtk_widget_destroy (dialog);
164 }
165
166 g_string_free (question, TRUE);
167 }
168
169 return result;
170}
0171
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2010-08-20 21:09:00 +0000
+++ po/POTFILES.in 2010-08-25 20:03:47 +0000
@@ -10,5 +10,6 @@
10nautilus/u1-contacts-picker.c10nautilus/u1-contacts-picker.c
11nautilus/location-widget.c11nautilus/location-widget.c
12nautilus/share-dialog.c12nautilus/share-dialog.c
13nautilus/utils.c
13gsd-plugin/gsd-ubuntuone.c14gsd-plugin/gsd-ubuntuone.c
14[type: gettext/ini]gsd-plugin/ubuntuone.gnome-settings-plugin.in15[type: gettext/ini]gsd-plugin/ubuntuone.gnome-settings-plugin.in

Subscribers

People subscribed via source and target branches