Merge lp:~rodrigo-moya/libubuntuone/use-libsyncdaemon into lp:libubuntuone
- use-libsyncdaemon
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | dobey |
Approved revision: | 96 |
Merged at revision: | 93 |
Proposed branch: | lp:~rodrigo-moya/libubuntuone/use-libsyncdaemon |
Merge into: | lp:libubuntuone |
Diff against target: |
550 lines (+57/-326) 8 files modified
configure.ac (+1/-1) libubuntuone/Makefile.am (+1/-3) libubuntuone/authentication.c (+2/-2) libubuntuone/syncdaemon.c (+0/-182) libubuntuone/syncdaemon.h (+0/-41) libubuntuone/u1-music-store.c (+52/-25) tests/Makefile.am (+1/-7) tests/test-syncdaemon.c (+0/-65) |
To merge this branch: | bzr merge lp:~rodrigo-moya/libubuntuone/use-libsyncdaemon |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chad Miller (community) | Approve | ||
Stuart Langridge (community) | Approve | ||
Alejandro J. Cura (community) | Approve | ||
John Lenton (community) | Approve | ||
Review via email: mp+29316@code.launchpad.net |
Commit message
Use libsyncdaemon to talk to syncdaemon
Description of the change
Use libsyncdaemon to talk to syncdaemon
Rodrigo Moya (rodrigo-moya) wrote : | # |
John Lenton (chipaca) wrote : | # |
No more polling can only be good. Right? Even more so when the patch to do it is mostly red :) Good work!
Chad Miller (cmiller) wrote : | # |
Are we sure the url doesn't contain metacharacters?
command_line = g_strdup_printf ("totem %s", url);
g_spawn_async with two parameters at argv, "totem", and url, would fix the shell problem.
Do we care? If not, then mine is "Approve".
Rodrigo Moya (rodrigo-moya) wrote : | # |
> Are we sure the url doesn't contain metacharacters?
>
> command_line = g_strdup_printf ("totem %s", url);
>
> g_spawn_async with two parameters at argv, "totem", and url, would fix the
> shell problem.
>
> Do we care? If not, then mine is "Approve".
I just added that code for some temporary testing, so just removed it now
Alejandro J. Cura (alecu) wrote : | # |
The code looks fine, and it works as advertised.
dobey (dobey) wrote : | # |
The attempt to merge lp:~rodrigo-moya/libubuntuone/use-libsyncdaemon into lp:libubuntuone 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.65
checking for automake >= 1.6...
testing automake-1.11... found 1.11.1
checking for libtool >= 1.5...
testing libtoolize... found 2.2.6b
checking for glib-gettext >= 2.2.0...
testing glib-gettextize... found 2.25.11
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 gtk-doc >= 1.0...
testing gtkdocize... found 1.15
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: You should add the contents of the following files to `aclocal.m4':
libtoolize: `/usr/share/
libtoolize: `/usr/share/
libtoolize: `/usr/share/
libtoolize: `/usr/share/
libtoolize: `/usr/share/
libtoolize: Consider adding `AC_CONFIG_
libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
Running glib-gettextize... Ignore non-fatal messages.
Copying file mkinstalldirs
Copying file po/Makefile.in.in
Please add the files
codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 lcmessage.m4
progtest.m4
from the /aclocal directory to your autoconf macro directory
or directly to your aclocal.m4 file.
You will also need config.guess and config.sub, which you can get from
ftp://ftp.
Running intltoolize...
Running gtkdocize...
Running aclocal-1.11...
Running autoconf...
Running autoheader...
Running automake-1.11...
Running ./configure ...
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 how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd....
Stuart Langridge (sil) wrote : | # |
Seems good to me!
dobey (dobey) wrote : | # |
The attempt to merge lp:~rodrigo-moya/libubuntuone/use-libsyncdaemon into lp:libubuntuone 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.65
checking for automake >= 1.6...
testing automake-1.11... found 1.11.1
checking for libtool >= 1.5...
testing libtoolize... found 2.2.6b
checking for glib-gettext >= 2.2.0...
testing glib-gettextize... found 2.25.11
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 gtk-doc >= 1.0...
testing gtkdocize... found 1.15
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: Consider adding `AC_CONFIG_
libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
Running glib-gettextize... Ignore non-fatal messages.
Copying file mkinstalldirs
Copying file po/Makefile.in.in
Please add the files
codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 lcmessage.m4
progtest.m4
from the /aclocal directory to your autoconf macro directory
or directly to your aclocal.m4 file.
You will also need config.guess and config.sub, which you can get from
ftp://ftp.
Running intltoolize...
Running gtkdocize...
Running aclocal-1.11...
Running autoconf...
Running autoheader...
Running automake-1.11...
Running ./configure ...
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 how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (ca...
dobey (dobey) wrote : | # |
The attempt to merge lp:~rodrigo-moya/libubuntuone/use-libsyncdaemon into lp:libubuntuone 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.65
checking for automake >= 1.6...
testing automake-1.11... found 1.11.1
checking for libtool >= 1.5...
testing libtoolize... found 2.2.6b
checking for glib-gettext >= 2.2.0...
testing glib-gettextize... found 2.25.11
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 gtk-doc >= 1.0...
testing gtkdocize... found 1.15
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: Consider adding `AC_CONFIG_
libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
Running glib-gettextize... Ignore non-fatal messages.
Copying file mkinstalldirs
Copying file po/Makefile.in.in
Please add the files
codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 lcmessage.m4
progtest.m4
from the /aclocal directory to your autoconf macro directory
or directly to your aclocal.m4 file.
You will also need config.guess and config.sub, which you can get from
ftp://ftp.
Running intltoolize...
Running gtkdocize...
Running aclocal-1.11...
Running autoconf...
Running autoheader...
Running automake-1.11...
Running ./configure ...
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 how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (ca...
Chad Miller (cmiller) : | # |
Preview Diff
1 | === modified file 'configure.ac' |
2 | --- configure.ac 2010-07-21 13:31:04 +0000 |
3 | +++ configure.ac 2010-08-04 15:01:42 +0000 |
4 | @@ -30,7 +30,7 @@ |
5 | AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal) |
6 | |
7 | dnl Look for needed modules |
8 | -PKG_CHECK_MODULES(LIBUBUNTUONE, webkit-1.0 >= 1.1.15 gnome-keyring-1 dbus-glib-1 gconf-2.0 libxml-2.0 libsoup-gnome-2.4) |
9 | +PKG_CHECK_MODULES(LIBUBUNTUONE, gdk-pixbuf-2.0 webkit-1.0 >= 1.1.15 gnome-keyring-1 dbus-glib-1 gconf-2.0 libxml-2.0 libsoup-gnome-2.4 libsyncdaemon-1.0 >= 1.3.2) |
10 | AC_SUBST(LIBUBUNTUONE_CFLAGS) |
11 | AC_SUBST(LIBUBUNTUONE_LIBS) |
12 | |
13 | |
14 | === modified file 'libubuntuone/Makefile.am' |
15 | --- libubuntuone/Makefile.am 2010-05-27 22:18:59 +0000 |
16 | +++ libubuntuone/Makefile.am 2010-08-04 15:01:42 +0000 |
17 | @@ -21,8 +21,6 @@ |
18 | authentication.h \ |
19 | oauth.c \ |
20 | oauth.h \ |
21 | - syncdaemon.c \ |
22 | - syncdaemon.h \ |
23 | u1-music-store.c \ |
24 | xmalloc.c \ |
25 | xmalloc.h |
26 | @@ -60,4 +58,4 @@ |
27 | typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) |
28 | |
29 | CLEANFILES += $(gir_DATA) $(typelibs_DATA) |
30 | -endif |
31 | \ No newline at end of file |
32 | +endif |
33 | |
34 | === modified file 'libubuntuone/authentication.c' |
35 | --- libubuntuone/authentication.c 2010-04-15 11:12:21 +0000 |
36 | +++ libubuntuone/authentication.c 2010-08-04 15:01:42 +0000 |
37 | @@ -43,8 +43,8 @@ |
38 | |
39 | /* Initialize connection to authentication service */ |
40 | if (auth_proxy == NULL) { |
41 | - auth_proxy = dbus_g_proxy_new_for_name (bus, "com.ubuntuone.Authentication", |
42 | - "/", "com.ubuntuone.Authentication"); |
43 | + auth_proxy = dbus_g_proxy_new_for_name (bus, "com.ubuntu.sso", |
44 | + "/", "com.ubuntu.sso"); |
45 | } |
46 | } |
47 | |
48 | |
49 | === removed file 'libubuntuone/syncdaemon.c' |
50 | --- libubuntuone/syncdaemon.c 2010-04-08 12:12:12 +0000 |
51 | +++ libubuntuone/syncdaemon.c 1970-01-01 00:00:00 +0000 |
52 | @@ -1,182 +0,0 @@ |
53 | -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
54 | -/* |
55 | - * Copyright (C) 2009 Canonical Services Ltd (www.canonical.com) |
56 | - * |
57 | - * Authors: Rodrigo Moya <rodrigo.moya@canonical.com> |
58 | - * |
59 | - * This library is free software; you can redistribute it and/or |
60 | - * modify it under the terms of version 2 of the GNU Lesser General Public |
61 | - * License as published by the Free Software Foundation. |
62 | - * |
63 | - * This program is distributed in the hope that it will be useful, |
64 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
65 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
66 | - * General Public License for more details. |
67 | - * |
68 | - * You should have received a copy of the GNU Lesser General Public |
69 | - * License along with this library; if not, write to the |
70 | - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
71 | - * Boston, MA 02110-1301, USA. |
72 | - */ |
73 | - |
74 | -#include <stdlib.h> |
75 | -#include <dbus/dbus-glib.h> |
76 | -#include "syncdaemon.h" |
77 | - |
78 | -static DBusGConnection *bus = NULL; |
79 | -static DBusGProxy *daemon_proxy = NULL; |
80 | -static DBusGProxy *status_proxy = NULL; |
81 | - |
82 | -void |
83 | -syncdaemon_init (void) |
84 | -{ |
85 | - GError *error; |
86 | - |
87 | - /* Initialize connection to DBus if not done already */ |
88 | - if (bus == NULL) { |
89 | - error = NULL; |
90 | - bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); |
91 | - if (error) { |
92 | - g_warning ("Couldn't get session bus: %s", error->message); |
93 | - g_error_free (error); |
94 | - return; |
95 | - } |
96 | - } |
97 | - |
98 | - /* Initialize connection to syncdaemon */ |
99 | - if (daemon_proxy == NULL) { |
100 | - daemon_proxy = dbus_g_proxy_new_for_name (bus, "com.ubuntuone.SyncDaemon", |
101 | - "/", "com.ubuntuone.SyncDaemon.SyncDaemon"); |
102 | - if (daemon_proxy == NULL) |
103 | - g_warning ("Could not get proxy for com.ubuntuone.SyncDaemon.SyncDaemon"); |
104 | - } |
105 | - |
106 | - /* Initialize com.ubuntuone.SyncDaemon.Status proxy */ |
107 | - if (status_proxy == NULL) { |
108 | - status_proxy = dbus_g_proxy_new_for_name (bus, "com.ubuntuone.SyncDaemon", |
109 | - "/status", "com.ubuntuone.SyncDaemon.Status"); |
110 | - if (status_proxy == NULL) |
111 | - g_warning ("Could not get proxy for com.ubuntuone.SyncDaemon.Status"); |
112 | - } |
113 | -} |
114 | - |
115 | -gboolean |
116 | -syncdaemon_is_connected (void) |
117 | -{ |
118 | - GHashTable *return_value; |
119 | - gboolean is_connected = FALSE; |
120 | - GError *error = NULL; |
121 | - |
122 | - syncdaemon_init (); |
123 | - |
124 | - if (dbus_g_proxy_call (status_proxy, "current_status", &error, |
125 | - G_TYPE_INVALID, |
126 | - dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING), &return_value, |
127 | - G_TYPE_INVALID)) { |
128 | - is_connected = g_strcmp0 (g_hash_table_lookup (return_value, "is_connected"), "True") == 0; |
129 | - |
130 | - g_hash_table_destroy (return_value); |
131 | - } else { |
132 | - g_warning ("Error calling current_status: %s", error->message); |
133 | - g_error_free (error); |
134 | - } |
135 | - |
136 | - return is_connected; |
137 | -} |
138 | - |
139 | -void |
140 | -syncdaemon_connect (void) |
141 | -{ |
142 | - GError *error; |
143 | - |
144 | - syncdaemon_init (); |
145 | - |
146 | - if (syncdaemon_is_connected ()) { |
147 | - g_warning ("Syncdaemon already connected, not connecting again"); |
148 | - return; |
149 | - } |
150 | - |
151 | - /* Make the syncdaemon connect if it's not connected */ |
152 | - error = NULL; |
153 | - |
154 | - if (!dbus_g_proxy_call (daemon_proxy, "connect", &error, |
155 | - G_TYPE_INVALID, |
156 | - G_TYPE_INVALID)) { |
157 | - g_warning ("Could not connect to Ubuntu One: %s", error->message); |
158 | - g_error_free (error); |
159 | - } |
160 | -} |
161 | - |
162 | -void |
163 | -syncdaemon_finalize (void) |
164 | -{ |
165 | - g_object_unref (G_OBJECT (daemon_proxy)); |
166 | - g_object_unref (G_OBJECT (status_proxy)); |
167 | - dbus_g_connection_unref (bus); |
168 | -} |
169 | - |
170 | -static void |
171 | -free_syncdaemon_download (SyncdaemonDownload *item_data) |
172 | -{ |
173 | - g_free (item_data->path); |
174 | - g_free (item_data->share_id); |
175 | - g_free (item_data->node_id); |
176 | - |
177 | - g_free (item_data); |
178 | -} |
179 | - |
180 | -GHashTable * |
181 | -syncdaemon_get_current_downloads (void) |
182 | -{ |
183 | - GError *error; |
184 | - GPtrArray *return_value; |
185 | - GHashTable *downloads = NULL; |
186 | - |
187 | - /* Make sure we are connected when we get here */ |
188 | - syncdaemon_connect (); |
189 | - |
190 | - /* Ask the syncdaemon about current downloads */ |
191 | - error = NULL; |
192 | - if (dbus_g_proxy_call (status_proxy, "current_downloads", &error, |
193 | - G_TYPE_INVALID, |
194 | - dbus_g_type_get_collection ( |
195 | - "GPtrArray", |
196 | - dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING)), &return_value, |
197 | - G_TYPE_INVALID)) { |
198 | - gint i; |
199 | - |
200 | - downloads = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) free_syncdaemon_download); |
201 | - for (i = 0; i < return_value->len; i++) { |
202 | - SyncdaemonDownload *item_data; |
203 | - gchar *str; |
204 | - GHashTable *values = (GHashTable *) g_ptr_array_index (return_value, i); |
205 | - |
206 | - item_data = g_new0 (SyncdaemonDownload, 1); |
207 | - item_data->path = g_strdup (g_hash_table_lookup (values, "path")); |
208 | - item_data->share_id = g_strdup (g_hash_table_lookup (values, "share_id")); |
209 | - item_data->node_id = g_strdup (g_hash_table_lookup (values, "node_id")); |
210 | - |
211 | - str = g_hash_table_lookup (values, "n_bytes_read"); |
212 | - if (str != NULL) |
213 | - item_data->n_bytes_read = atol (str); |
214 | - else |
215 | - item_data->n_bytes_read = 0; |
216 | - |
217 | - str = g_hash_table_lookup (values, "deflated_size"); |
218 | - if (str != NULL) |
219 | - item_data->deflated_size = atol (str); |
220 | - else |
221 | - item_data->deflated_size = 0; |
222 | - |
223 | - g_hash_table_insert (downloads, g_strdup (item_data->path), item_data); |
224 | - } |
225 | - |
226 | - g_ptr_array_free (return_value, TRUE); |
227 | - } else { |
228 | - g_warning ("Error calling current_downloads: %s", error->message); |
229 | - g_error_free (error); |
230 | - } |
231 | - |
232 | - return downloads; |
233 | -} |
234 | - |
235 | |
236 | === removed file 'libubuntuone/syncdaemon.h' |
237 | --- libubuntuone/syncdaemon.h 2010-03-25 09:29:01 +0000 |
238 | +++ libubuntuone/syncdaemon.h 1970-01-01 00:00:00 +0000 |
239 | @@ -1,41 +0,0 @@ |
240 | -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
241 | -/* |
242 | - * Copyright (C) 2009 Canonical Services Ltd (www.canonical.com) |
243 | - * |
244 | - * Authors: Rodrigo Moya <rodrigo.moya@canonical.com> |
245 | - * |
246 | - * This library is free software; you can redistribute it and/or |
247 | - * modify it under the terms of version 2 of the GNU Lesser General Public |
248 | - * License as published by the Free Software Foundation. |
249 | - * |
250 | - * This program is distributed in the hope that it will be useful, |
251 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
252 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
253 | - * General Public License for more details. |
254 | - * |
255 | - * You should have received a copy of the GNU Lesser General Public |
256 | - * License along with this library; if not, write to the |
257 | - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
258 | - * Boston, MA 02110-1301, USA. |
259 | - */ |
260 | - |
261 | -#ifndef __SYNCDAEMON_H__ |
262 | -#define __SYNCDAEMON_H__ |
263 | - |
264 | -#include <glib.h> |
265 | - |
266 | -typedef struct { |
267 | - gchar *path; |
268 | - gchar *share_id; |
269 | - gchar *node_id; |
270 | - glong n_bytes_read; |
271 | - glong deflated_size; |
272 | -} SyncdaemonDownload; |
273 | - |
274 | -void syncdaemon_init (void); |
275 | -gboolean syncdaemon_is_connected (void); |
276 | -void syncdaemon_connect (void); |
277 | -void syncdaemon_finalize (void); |
278 | -GHashTable *syncdaemon_get_current_downloads (void); |
279 | - |
280 | -#endif |
281 | |
282 | === modified file 'libubuntuone/u1-music-store.c' |
283 | --- libubuntuone/u1-music-store.c 2010-05-27 21:45:32 +0000 |
284 | +++ libubuntuone/u1-music-store.c 2010-08-04 15:01:42 +0000 |
285 | @@ -27,10 +27,10 @@ |
286 | #include <libsoup/soup-gnome-features.h> |
287 | #include <libsoup/soup-uri.h> |
288 | #include <gnome-keyring.h> |
289 | +#include <libsyncdaemon/libsyncdaemon.h> |
290 | #include "oauth.h" |
291 | #include "u1-music-store.h" |
292 | #include "authentication.h" |
293 | -#include "syncdaemon.h" |
294 | #include "u1-marshal.h" |
295 | |
296 | #define U1_MUSIC_LIBRARY_LOCATION ".ubuntuone/Purchased from Ubuntu One" |
297 | @@ -50,6 +50,7 @@ |
298 | |
299 | struct _U1MusicStorePrivate { |
300 | DBusGConnection *bus; |
301 | + SyncdaemonDaemon *syncdaemon; |
302 | gchar *base_url; |
303 | |
304 | GtkWidget *scroll; |
305 | @@ -80,8 +81,6 @@ |
306 | { |
307 | U1MusicStore *music_store = U1_MUSIC_STORE (object); |
308 | |
309 | - syncdaemon_finalize (); |
310 | - |
311 | if (music_store->priv != NULL) { |
312 | if (music_store->priv->idle_cb != 0) { |
313 | g_source_remove (music_store->priv->idle_cb); |
314 | @@ -108,6 +107,11 @@ |
315 | music_store->priv->bus = NULL; |
316 | } |
317 | |
318 | + if (music_store->priv->syncdaemon != NULL) { |
319 | + g_object_unref (G_OBJECT (music_store->priv->syncdaemon)); |
320 | + music_store->priv->syncdaemon = NULL; |
321 | + } |
322 | + |
323 | g_free (music_store->priv); |
324 | music_store->priv = NULL; |
325 | } |
326 | @@ -243,9 +247,6 @@ |
327 | |
328 | parse_oauth_string (first_item->secret, oauth_token, oauth_token_secret); |
329 | gnome_keyring_found_list_free (items_found); |
330 | - |
331 | - /* Connect to syncdaemon now that we have tokens */ |
332 | - syncdaemon_connect (); |
333 | } |
334 | } |
335 | |
336 | @@ -301,6 +302,9 @@ |
337 | "ubuntuone", "hammertime", |
338 | oauth_token, oauth_token_secret); |
339 | g_free (s); |
340 | + |
341 | + /* Connect to syncdaemon now that we have tokens */ |
342 | + syncdaemon_daemon_connect (music_store->priv->syncdaemon); |
343 | } |
344 | |
345 | g_free (oauth_token); |
346 | @@ -637,7 +641,7 @@ |
347 | gchar *script = NULL, *full_path; |
348 | GString *escaped_prop; |
349 | gint i; |
350 | - SyncdaemonDownload *download; |
351 | + SyncdaemonTransferInfo *download; |
352 | |
353 | prop = xmlGetProp (subnode, "data-path"); |
354 | if (prop == NULL) |
355 | @@ -659,15 +663,19 @@ |
356 | download = g_hash_table_lookup (current_downloads, full_path); |
357 | if (download != NULL) { |
358 | gdouble percent; |
359 | - |
360 | - if (download->deflated_size != 0) |
361 | - percent = (gdouble) download->n_bytes_read / (gdouble) download->deflated_size; |
362 | + glong total_size, bytes_read; |
363 | + |
364 | + total_size = syncdaemon_transfer_info_get_total_size (download); |
365 | + bytes_read = syncdaemon_transfer_info_get_bytes_transferred (download); |
366 | + |
367 | + if (total_size != 0) |
368 | + percent = (gdouble) bytes_read / (gdouble) total_size; |
369 | else |
370 | percent = 0.0; |
371 | script = g_strdup_printf ("setProgressBar('%s', %.2f, '%.1fMB of %.1fMB downloaded');", |
372 | escaped_prop->str, percent, |
373 | - (gdouble) download->n_bytes_read / (gdouble) 1024 / (gdouble) 1024, |
374 | - (gdouble) download->deflated_size / (gdouble) 1024 / (gdouble) 1024); |
375 | + (gdouble) bytes_read / (gdouble) 1024 / (gdouble) 1024, |
376 | + (gdouble) total_size / (gdouble) 1024 / (gdouble) 1024); |
377 | } else { |
378 | /* If the file exists, the download is done */ |
379 | if (g_file_test (full_path, G_FILE_TEST_EXISTS)) { |
380 | @@ -713,6 +721,8 @@ |
381 | WebKitWebDataSource *data_source; |
382 | htmlDocPtr html_doc; |
383 | htmlNodePtr root_node; |
384 | + GSList *list; |
385 | + SyncdaemonInterface *interface; |
386 | GHashTable *current_downloads; |
387 | |
388 | /* Retrieve contents of the page */ |
389 | @@ -720,17 +730,34 @@ |
390 | html = webkit_web_data_source_get_data (data_source); |
391 | |
392 | /* Get list of current downloads */ |
393 | - current_downloads = syncdaemon_get_current_downloads (); |
394 | - if (current_downloads != NULL) { |
395 | - /* Parse HTML */ |
396 | - html_doc = htmlParseDoc (html->str, NULL); |
397 | - root_node = xmlDocGetRootElement (html_doc); |
398 | - parse_html_node (music_store, web_view, root_node, current_downloads); |
399 | - |
400 | - /* Free memory */ |
401 | - xmlFreeDoc (html_doc); |
402 | - g_hash_table_destroy (current_downloads); |
403 | - } |
404 | + interface = syncdaemon_daemon_get_status_interface (music_store->priv->syncdaemon); |
405 | + if (interface == NULL) { |
406 | + g_warning ("Could not get /status interface for SyncDaemon"); |
407 | + return; |
408 | + } |
409 | + |
410 | + list = syncdaemon_status_interface_get_current_downloads (SYNCDAEMON_STATUS_INTERFACE (interface)); |
411 | + |
412 | + current_downloads = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_object_unref); |
413 | + |
414 | + while (list != NULL) { |
415 | + SyncdaemonTransferInfo *transfer_info = (SyncdaemonTransferInfo *) list->data; |
416 | + |
417 | + g_hash_table_insert (current_downloads, |
418 | + g_strdup (syncdaemon_transfer_info_get_path (transfer_info)), |
419 | + g_object_ref (G_OBJECT (transfer_info))); |
420 | + |
421 | + list = g_slist_remove (list, transfer_info); |
422 | + } |
423 | + |
424 | + /* Parse HTML */ |
425 | + html_doc = htmlParseDoc (html->str, NULL); |
426 | + root_node = xmlDocGetRootElement (html_doc); |
427 | + parse_html_node (music_store, web_view, root_node, current_downloads); |
428 | + |
429 | + /* Free memory */ |
430 | + xmlFreeDoc (html_doc); |
431 | + g_hash_table_destroy (current_downloads); |
432 | } |
433 | |
434 | static gboolean |
435 | @@ -781,7 +808,7 @@ |
436 | update_status_in_library_page (music_store, web_view, frame); |
437 | |
438 | /* Poll syncdaemon for downloads while the page is loaded */ |
439 | - music_store->priv->watch_id = g_timeout_add (5000, (GSourceFunc) poll_downloads_cb, music_store); |
440 | + music_store->priv->watch_id = g_timeout_add (1000, (GSourceFunc) poll_downloads_cb, music_store); |
441 | } |
442 | |
443 | g_free (tmp_url); |
444 | @@ -880,6 +907,7 @@ |
445 | |
446 | music_store->priv = g_new0 (U1MusicStorePrivate, 1); |
447 | music_store->priv->watched_downloads = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); |
448 | + music_store->priv->syncdaemon = syncdaemon_daemon_new (); |
449 | |
450 | /* Initialize DBus */ |
451 | music_store->priv->bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); |
452 | @@ -902,7 +930,6 @@ |
453 | G_TYPE_INVALID); |
454 | |
455 | /* Initialize services */ |
456 | - syncdaemon_init (); |
457 | authentication_init (); |
458 | |
459 | /* Create web viewer object */ |
460 | |
461 | === modified file 'tests/Makefile.am' |
462 | --- tests/Makefile.am 2010-02-12 15:48:04 +0000 |
463 | +++ tests/Makefile.am 2010-08-04 15:01:42 +0000 |
464 | @@ -3,15 +3,9 @@ |
465 | -I$(top_srcdir) |
466 | |
467 | noinst_PROGRAMS = \ |
468 | - test-music-store \ |
469 | - test-syncdaemon |
470 | + test-music-store |
471 | |
472 | test_music_store_SOURCES = test-music-store.c |
473 | test_music_store_LDADD = \ |
474 | $(LIBUBUNTUONE_LIBS) \ |
475 | $(top_builddir)/libubuntuone/libubuntuone-1.0.la |
476 | - |
477 | -test_syncdaemon_SOURCES = test-syncdaemon.c |
478 | -test_syncdaemon_LDADD = \ |
479 | - $(LIBUBUNTUONE_LIBS) \ |
480 | - $(top_builddir)/libubuntuone/libubuntuone-1.0.la |
481 | |
482 | === removed file 'tests/test-syncdaemon.c' |
483 | --- tests/test-syncdaemon.c 2010-02-12 15:48:04 +0000 |
484 | +++ tests/test-syncdaemon.c 1970-01-01 00:00:00 +0000 |
485 | @@ -1,65 +0,0 @@ |
486 | -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
487 | -/* |
488 | - * Copyright (C) 2010 Canonical Services Ltd (www.canonical.com) |
489 | - * |
490 | - * Authors: Rodrigo Moya <rodrigo.moya@canonical.com> |
491 | - * |
492 | - * This library is free software; you can redistribute it and/or |
493 | - * modify it under the terms of version 2 of the GNU Lesser General Public |
494 | - * License as published by the Free Software Foundation. |
495 | - * |
496 | - * This program is distributed in the hope that it will be useful, |
497 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
498 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
499 | - * General Public License for more details. |
500 | - * |
501 | - * You should have received a copy of the GNU Lesser General Public |
502 | - * License along with this library; if not, write to the |
503 | - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
504 | - * Boston, MA 02110-1301, USA. |
505 | - */ |
506 | - |
507 | -#include <libubuntuone/syncdaemon.h> |
508 | - |
509 | -static void |
510 | -display_download_cb (gpointer key, gpointer value, gpointer user_data) |
511 | -{ |
512 | - SyncdaemonDownload *item_data = (SyncdaemonDownload *) value; |
513 | - gint *count = (gint *) user_data; |
514 | - |
515 | - *count = *count + 1; |
516 | - g_print ("Download #%d:\n", *count); |
517 | - g_print ("\tPath:\t%s\n", item_data->path); |
518 | - g_print ("\tShare ID\t:%s\n", item_data->share_id); |
519 | - g_print ("\tNode ID:\t%s\n", item_data->node_id); |
520 | - g_print ("\tStatus:\t%d of %d bytes downloaded\n", item_data->n_bytes_read, item_data->deflated_size); |
521 | -} |
522 | - |
523 | -static gboolean |
524 | -timeout_cb (gpointer user_data) |
525 | -{ |
526 | - GHashTable *downloads; |
527 | - gint count = 0; |
528 | - |
529 | - g_print ("\n*** GETTING DOWNLOADS ***\n"); |
530 | - downloads = syncdaemon_get_current_downloads (); |
531 | - g_hash_table_foreach (downloads, (GHFunc) display_download_cb, &count); |
532 | - g_hash_table_destroy (downloads); |
533 | - |
534 | - return TRUE; |
535 | -} |
536 | - |
537 | -int |
538 | -main (int argc, char *argv[]) |
539 | -{ |
540 | - GMainLoop *main_loop; |
541 | - g_type_init (); |
542 | - |
543 | - g_timeout_add (3000, (GSourceFunc) timeout_cb, NULL); |
544 | - |
545 | - /* Run the main loop */ |
546 | - main_loop = g_main_loop_new (NULL, FALSE); |
547 | - g_main_loop_run (main_loop); |
548 | - |
549 | - return 0; |
550 | -} |
This avoids the constant polling of syncdaemon we were doing, since libsyncdaemon keeps track of downloads/uploads by listening to signals from Syncdaemon