Merge lp:~bluetooth/ubuntu/lucid/obexd/main into lp:ubuntu/lucid/obexd
- Lucid (10.04)
- main
- Merge into lucid
Proposed by
Baptiste Mille-Mathias
Status: | Merged |
---|---|
Merge reported by: | James Westby |
Merged at revision: | not available |
Proposed branch: | lp:~bluetooth/ubuntu/lucid/obexd/main |
Merge into: | lp:ubuntu/lucid/obexd |
Diff against target: |
4906 lines (+1768/-999) 57 files modified
ChangeLog (+12/-0) Makefile.am (+1/-0) Makefile.in (+21/-18) README (+1/-1) aclocal.m4 (+8/-8) client/main.c (+50/-13) client/pbap.c (+8/-7) client/pbap.h (+2/-2) client/session.c (+314/-173) client/session.h (+1/-1) client/sync.c (+2/-2) client/sync.h (+2/-2) config.guess (+79/-139) config.h.in (+3/-0) config.sub (+31/-12) configure (+97/-15) configure.ac (+14/-4) debian/changelog (+25/-1) debian/patches/0001-Revert-Fix-the-session-is-shutdown-when-the-agent-ex.patch (+50/-0) doc/agent-api.txt (+2/-3) doc/client-api.txt (+1/-1) doc/obexd-api.txt (+2/-3) gdbus/gdbus.h (+11/-6) gdbus/mainloop.c (+166/-107) gdbus/object.c (+14/-14) gdbus/watch.c (+368/-245) ltmain.sh (+4/-4) plugins/filesystem.c (+167/-48) plugins/ftp.c (+8/-9) plugins/opp.c (+7/-5) plugins/pbap.c (+10/-3) plugins/phonebook-dummy.c (+2/-2) plugins/phonebook-ebook.c (+11/-13) plugins/phonebook.h (+1/-1) plugins/syncevolution.c (+29/-70) plugins/telephony-dummy.c (+2/-2) plugins/telephony.h (+1/-1) src/bluetooth.c (+2/-3) src/bluetooth.h (+2/-3) src/btio.c (+2/-2) src/btio.h (+2/-2) src/dbus.h (+1/-1) src/logging.c (+1/-1) src/logging.h (+1/-1) src/main.c (+1/-1) src/manager.c (+13/-3) src/mimetype.c (+83/-1) src/mimetype.h (+10/-2) src/obex.c (+86/-24) src/obex.h (+3/-3) src/obexd.h (+5/-1) src/plugin.c (+1/-1) src/plugin.h (+1/-1) src/service.c (+8/-4) src/service.h (+1/-1) test/ftp-client (+17/-8) test/main.c (+1/-1) |
To merge this branch: | bzr merge lp:~bluetooth/ubuntu/lucid/obexd/main |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu branches | Pending | ||
Review via email: mp+24151@code.launchpad.net |
Commit message
Description of the change
Revision of the 0.22-0ubuntu1, (did again, I used import-dsc this time, really better :)
To post a comment you must log in.
- 5. By Baptiste Mille-Mathias
-
Revert change in release 0.22 to fix bluetooth-sendto dialog not being
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2010-01-10 10:46:58 +0000 |
3 | +++ ChangeLog 2010-04-28 20:38:30 +0000 |
4 | @@ -1,3 +1,15 @@ |
5 | +ver 0.22: |
6 | + Fix file corruption during PUT operation. |
7 | + Fix the response of PUT requests for PBAP. |
8 | + Fix blocking while waiting capability script to exit. |
9 | + Fix compilation issues with driver and plugin options. |
10 | + Fix service driver selection when WHO header is informed. |
11 | + Fix issue with PC-Suite WHO header. |
12 | + Fix issue when mime type exists but is unknown. |
13 | + Fix issue when opening file fails during SendFiles. |
14 | + Fix error code response when there is no default vCard. |
15 | + Fix a memory leak when opening a folder for listing. |
16 | + |
17 | ver 0.21: |
18 | Fix crash caused by D-Bus timeout handling. |
19 | Fix issue when the object size is unknown. |
20 | |
21 | === modified file 'Makefile.am' |
22 | --- Makefile.am 2010-01-10 10:46:58 +0000 |
23 | +++ Makefile.am 2010-04-28 20:38:30 +0000 |
24 | @@ -90,6 +90,7 @@ |
25 | |
26 | client_obex_client_SOURCES = $(gdbus_sources) $(gwobex_sources) client/main.c \ |
27 | client/session.h client/session.c \ |
28 | + src/logging.h src/logging.c \ |
29 | client/pbap.h client/pbap.c \ |
30 | client/sync.h client/sync.c |
31 | |
32 | |
33 | === modified file 'Makefile.in' |
34 | --- Makefile.in 2010-01-10 10:46:58 +0000 |
35 | +++ Makefile.in 2010-04-28 20:38:30 +0000 |
36 | @@ -1,4 +1,4 @@ |
37 | -# Makefile.in generated by automake 1.11 from Makefile.am. |
38 | +# Makefile.in generated by automake 1.11.1 from Makefile.am. |
39 | # @configure_input@ |
40 | |
41 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
42 | @@ -89,8 +89,9 @@ |
43 | gdbus/object.c gdbus/watch.c gwobex/gw-obex.h gwobex/gw-obex.c \ |
44 | gwobex/obex-priv.h gwobex/obex-priv.c gwobex/obex-xfer.h \ |
45 | gwobex/obex-xfer.c gwobex/utils.h gwobex/utils.c gwobex/log.h \ |
46 | - client/main.c client/session.h client/session.c client/pbap.h \ |
47 | - client/pbap.c client/sync.h client/sync.c |
48 | + client/main.c client/session.h client/session.c src/logging.h \ |
49 | + src/logging.c client/pbap.h client/pbap.c client/sync.h \ |
50 | + client/sync.c |
51 | am__dirstamp = $(am__leading_dot)dirstamp |
52 | am__objects_1 = gdbus/mainloop.$(OBJEXT) gdbus/object.$(OBJEXT) \ |
53 | gdbus/watch.$(OBJEXT) |
54 | @@ -98,8 +99,8 @@ |
55 | gwobex/obex-xfer.$(OBJEXT) gwobex/utils.$(OBJEXT) |
56 | @CLIENT_TRUE@am_client_obex_client_OBJECTS = $(am__objects_1) \ |
57 | @CLIENT_TRUE@ $(am__objects_2) client/main.$(OBJEXT) \ |
58 | -@CLIENT_TRUE@ client/session.$(OBJEXT) client/pbap.$(OBJEXT) \ |
59 | -@CLIENT_TRUE@ client/sync.$(OBJEXT) |
60 | +@CLIENT_TRUE@ client/session.$(OBJEXT) src/logging.$(OBJEXT) \ |
61 | +@CLIENT_TRUE@ client/pbap.$(OBJEXT) client/sync.$(OBJEXT) |
62 | client_obex_client_OBJECTS = $(am_client_obex_client_OBJECTS) |
63 | client_obex_client_DEPENDENCIES = |
64 | AM_V_lt = $(am__v_lt_$(V)) |
65 | @@ -354,6 +355,7 @@ |
66 | @SERVER_TRUE@test_obex_test_LDADD = @OPENOBEX_LIBS@ @BLUEZ_LIBS@ @GLIB_LIBS@ |
67 | @CLIENT_TRUE@client_obex_client_SOURCES = $(gdbus_sources) $(gwobex_sources) client/main.c \ |
68 | @CLIENT_TRUE@ client/session.h client/session.c \ |
69 | +@CLIENT_TRUE@ src/logging.h src/logging.c \ |
70 | @CLIENT_TRUE@ client/pbap.h client/pbap.c \ |
71 | @CLIENT_TRUE@ client/sync.h client/sync.c |
72 | |
73 | @@ -552,6 +554,14 @@ |
74 | client/$(DEPDIR)/$(am__dirstamp) |
75 | client/session.$(OBJEXT): client/$(am__dirstamp) \ |
76 | client/$(DEPDIR)/$(am__dirstamp) |
77 | +src/$(am__dirstamp): |
78 | + @$(MKDIR_P) src |
79 | + @: > src/$(am__dirstamp) |
80 | +src/$(DEPDIR)/$(am__dirstamp): |
81 | + @$(MKDIR_P) src/$(DEPDIR) |
82 | + @: > src/$(DEPDIR)/$(am__dirstamp) |
83 | +src/logging.$(OBJEXT): src/$(am__dirstamp) \ |
84 | + src/$(DEPDIR)/$(am__dirstamp) |
85 | client/pbap.$(OBJEXT): client/$(am__dirstamp) \ |
86 | client/$(DEPDIR)/$(am__dirstamp) |
87 | client/sync.$(OBJEXT): client/$(am__dirstamp) \ |
88 | @@ -575,17 +585,9 @@ |
89 | plugins/$(DEPDIR)/$(am__dirstamp) |
90 | plugins/syncevolution.$(OBJEXT): plugins/$(am__dirstamp) \ |
91 | plugins/$(DEPDIR)/$(am__dirstamp) |
92 | -src/$(am__dirstamp): |
93 | - @$(MKDIR_P) src |
94 | - @: > src/$(am__dirstamp) |
95 | -src/$(DEPDIR)/$(am__dirstamp): |
96 | - @$(MKDIR_P) src/$(DEPDIR) |
97 | - @: > src/$(DEPDIR)/$(am__dirstamp) |
98 | src/main.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) |
99 | src/plugin.$(OBJEXT): src/$(am__dirstamp) \ |
100 | src/$(DEPDIR)/$(am__dirstamp) |
101 | -src/logging.$(OBJEXT): src/$(am__dirstamp) \ |
102 | - src/$(DEPDIR)/$(am__dirstamp) |
103 | src/btio.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) |
104 | src/manager.$(OBJEXT): src/$(am__dirstamp) \ |
105 | src/$(DEPDIR)/$(am__dirstamp) |
106 | @@ -822,7 +824,8 @@ |
107 | fi; \ |
108 | done |
109 | -test -n "$(am__skip_mode_fix)" \ |
110 | - || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ |
111 | + || find "$(distdir)" -type d ! -perm -755 \ |
112 | + -exec chmod u+rwx,go+rx {} \; -o \ |
113 | ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ |
114 | ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ |
115 | ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ |
116 | @@ -866,17 +869,17 @@ |
117 | distcheck: dist |
118 | case '$(DIST_ARCHIVES)' in \ |
119 | *.tar.gz*) \ |
120 | - GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ |
121 | + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ |
122 | *.tar.bz2*) \ |
123 | - bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ |
124 | + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ |
125 | *.tar.lzma*) \ |
126 | - unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ |
127 | + lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ |
128 | *.tar.xz*) \ |
129 | xz -dc $(distdir).tar.xz | $(am__untar) ;;\ |
130 | *.tar.Z*) \ |
131 | uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ |
132 | *.shar.gz*) \ |
133 | - GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ |
134 | + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ |
135 | *.zip*) \ |
136 | unzip $(distdir).zip ;;\ |
137 | esac |
138 | |
139 | === modified file 'README' |
140 | --- README 2009-07-27 19:02:30 +0000 |
141 | +++ README 2010-04-28 20:38:30 +0000 |
142 | @@ -1,7 +1,7 @@ |
143 | OBEX Server and Client |
144 | ********************** |
145 | |
146 | -Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
147 | +Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
148 | |
149 | |
150 | Compilation and installation |
151 | |
152 | === modified file 'aclocal.m4' |
153 | --- aclocal.m4 2009-07-27 19:02:30 +0000 |
154 | +++ aclocal.m4 2010-04-28 20:38:30 +0000 |
155 | @@ -1,4 +1,4 @@ |
156 | -# generated automatically by aclocal 1.11 -*- Autoconf -*- |
157 | +# generated automatically by aclocal 1.11.1 -*- Autoconf -*- |
158 | |
159 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
160 | # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
161 | @@ -7862,15 +7862,15 @@ |
162 | |
163 | # Generated from ltversion.in. |
164 | |
165 | -# serial 3012 ltversion.m4 |
166 | +# serial 3017 ltversion.m4 |
167 | # This file is part of GNU Libtool |
168 | |
169 | -m4_define([LT_PACKAGE_VERSION], [2.2.6]) |
170 | -m4_define([LT_PACKAGE_REVISION], [1.3012]) |
171 | +m4_define([LT_PACKAGE_VERSION], [2.2.6b]) |
172 | +m4_define([LT_PACKAGE_REVISION], [1.3017]) |
173 | |
174 | AC_DEFUN([LTVERSION_VERSION], |
175 | -[macro_version='2.2.6' |
176 | -macro_revision='1.3012' |
177 | +[macro_version='2.2.6b' |
178 | +macro_revision='1.3017' |
179 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) |
180 | _LT_DECL(, macro_revision, 0) |
181 | ]) |
182 | @@ -8139,7 +8139,7 @@ |
183 | [am__api_version='1.11' |
184 | dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to |
185 | dnl require some minimum version. Point them to the right macro. |
186 | -m4_if([$1], [1.11], [], |
187 | +m4_if([$1], [1.11.1], [], |
188 | [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl |
189 | ]) |
190 | |
191 | @@ -8155,7 +8155,7 @@ |
192 | # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. |
193 | # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. |
194 | AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], |
195 | -[AM_AUTOMAKE_VERSION([1.11])dnl |
196 | +[AM_AUTOMAKE_VERSION([1.11.1])dnl |
197 | m4_ifndef([AC_AUTOCONF_VERSION], |
198 | [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl |
199 | _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) |
200 | |
201 | === modified file 'client/main.c' |
202 | --- client/main.c 2010-01-10 10:46:58 +0000 |
203 | +++ client/main.c 2010-04-28 20:38:30 +0000 |
204 | @@ -2,7 +2,7 @@ |
205 | * |
206 | * OBEX Client |
207 | * |
208 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
209 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
210 | * |
211 | * |
212 | * This program is free software; you can redistribute it and/or modify |
213 | @@ -29,10 +29,12 @@ |
214 | #include <stdlib.h> |
215 | #include <string.h> |
216 | #include <signal.h> |
217 | +#include <syslog.h> |
218 | |
219 | #include <glib.h> |
220 | #include <gdbus.h> |
221 | |
222 | +#include "logging.h" |
223 | #include "session.h" |
224 | |
225 | #define CLIENT_SERVICE "org.openobex.client" |
226 | @@ -429,6 +431,17 @@ |
227 | |
228 | static GMainLoop *event_loop = NULL; |
229 | |
230 | +static gboolean option_debug = FALSE; |
231 | +static gboolean option_stderr = FALSE; |
232 | + |
233 | +static GOptionEntry options[] = { |
234 | + { "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug, |
235 | + "Enable debug information output" }, |
236 | + { "stderr", 's', 0, G_OPTION_ARG_NONE, &option_stderr, |
237 | + "Write log information to stderr" }, |
238 | + { NULL }, |
239 | +}; |
240 | + |
241 | static void sig_term(int sig) |
242 | { |
243 | g_main_loop_quit(event_loop); |
244 | @@ -436,32 +449,56 @@ |
245 | |
246 | int main(int argc, char *argv[]) |
247 | { |
248 | + GOptionContext *context; |
249 | struct sigaction sa; |
250 | DBusConnection *conn; |
251 | - DBusError err; |
252 | - |
253 | - dbus_error_init(&err); |
254 | - |
255 | - conn = g_dbus_setup_bus(DBUS_BUS_SESSION, CLIENT_SERVICE, &err); |
256 | - if (conn == NULL) { |
257 | - if (dbus_error_is_set(&err) == TRUE) { |
258 | - fprintf(stderr, "%s\n", err.message); |
259 | - dbus_error_free(&err); |
260 | - } else |
261 | - fprintf(stderr, "Can't register with session bus\n"); |
262 | + DBusError derr; |
263 | + GError *gerr = NULL; |
264 | + int log_option; |
265 | + |
266 | + context = g_option_context_new(NULL); |
267 | + g_option_context_add_main_entries(context, options, NULL); |
268 | + |
269 | + g_option_context_parse(context, &argc, &argv, &gerr); |
270 | + if (gerr != NULL) { |
271 | + g_printerr("%s\n", gerr->message); |
272 | + g_error_free(gerr); |
273 | + exit(EXIT_FAILURE); |
274 | + } |
275 | + |
276 | + g_option_context_free(context); |
277 | + |
278 | + dbus_error_init(&derr); |
279 | + |
280 | + conn = g_dbus_setup_bus(DBUS_BUS_SESSION, CLIENT_SERVICE, &derr); |
281 | + if (dbus_error_is_set(&derr) == TRUE) { |
282 | + g_printerr("%s: %s\n", derr.name, derr.message); |
283 | + dbus_error_free(&derr); |
284 | exit(EXIT_FAILURE); |
285 | } |
286 | |
287 | if (g_dbus_register_interface(conn, CLIENT_PATH, CLIENT_INTERFACE, |
288 | client_methods, NULL, NULL, |
289 | NULL, NULL) == FALSE) { |
290 | - fprintf(stderr, "Can't register client interface\n"); |
291 | + g_printerr("Can't register client interface\n"); |
292 | dbus_connection_unref(conn); |
293 | exit(EXIT_FAILURE); |
294 | } |
295 | |
296 | event_loop = g_main_loop_new(NULL, FALSE); |
297 | |
298 | + log_option = LOG_NDELAY | LOG_PID; |
299 | + |
300 | + if (option_stderr == TRUE) |
301 | + log_option |= LOG_PERROR; |
302 | + |
303 | + openlog("obex-client", log_option, LOG_DAEMON); |
304 | + |
305 | + if (option_debug == TRUE) { |
306 | + info("Enabling debug information"); |
307 | + enable_debug(); |
308 | + } |
309 | + |
310 | memset(&sa, 0, sizeof(sa)); |
311 | sa.sa_handler = sig_term; |
312 | sigaction(SIGINT, &sa, NULL); |
313 | |
314 | === modified file 'client/pbap.c' |
315 | --- client/pbap.c 2010-01-10 10:46:58 +0000 |
316 | +++ client/pbap.c 2010-04-28 20:38:30 +0000 |
317 | @@ -2,8 +2,8 @@ |
318 | * |
319 | * OBEX Client |
320 | * |
321 | - * Copyright (C) 2007-2008 Intel Corporation |
322 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
323 | + * Copyright (C) 2007-2010 Intel Corporation |
324 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
325 | * |
326 | * |
327 | * This program is free software; you can redistribute it and/or modify |
328 | @@ -30,6 +30,7 @@ |
329 | #include <glib.h> |
330 | #include <gdbus.h> |
331 | |
332 | +#include "logging.h" |
333 | #include "session.h" |
334 | #include "pbap.h" |
335 | |
336 | @@ -298,8 +299,8 @@ |
337 | struct apparam_hdr *hdr = (struct apparam_hdr *) buf; |
338 | |
339 | if (hdr->len > size - APPARAM_HDR_SIZE) { |
340 | - fprintf(stderr, "Unexpected PBAP pullphonebook app" |
341 | - " length, tag %d, len %d\n", |
342 | + error("Unexpected PBAP pullphonebook app" |
343 | + " length, tag %d, len %d", |
344 | hdr->tag, hdr->len); |
345 | return; |
346 | } |
347 | @@ -317,8 +318,8 @@ |
348 | *new_missed_calls = hdr->val[0]; |
349 | break; |
350 | default: |
351 | - fprintf(stderr, "Unexpected PBAP pullphonebook app" |
352 | - " parameter, tag %d, len %d\n", |
353 | + error("Unexpected PBAP pullphonebook app" |
354 | + " parameter, tag %d, len %d", |
355 | hdr->tag, hdr->len); |
356 | } |
357 | |
358 | @@ -443,7 +444,7 @@ |
359 | func = phonebook_size_callback; |
360 | break; |
361 | default: |
362 | - fprintf(stderr, "Unexpected type : 0x%2x\n", type); |
363 | + error("Unexpected type : 0x%2x", type); |
364 | return NULL; |
365 | } |
366 | |
367 | |
368 | === modified file 'client/pbap.h' |
369 | --- client/pbap.h 2009-07-27 19:02:30 +0000 |
370 | +++ client/pbap.h 2010-04-28 20:38:30 +0000 |
371 | @@ -2,8 +2,8 @@ |
372 | * |
373 | * OBEX Client |
374 | * |
375 | - * Copyright (C) 2007-2008 Intel Corporation |
376 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
377 | + * Copyright (C) 2007-2010 Intel Corporation |
378 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
379 | * |
380 | * |
381 | * This program is free software; you can redistribute it and/or modify |
382 | |
383 | === modified file 'client/session.c' |
384 | --- client/session.c 2009-07-27 19:02:30 +0000 |
385 | +++ client/session.c 2010-04-28 20:38:30 +0000 |
386 | @@ -2,7 +2,7 @@ |
387 | * |
388 | * OBEX Client |
389 | * |
390 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
391 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
392 | * |
393 | * |
394 | * This program is free software; you can redistribute it and/or modify |
395 | @@ -39,6 +39,7 @@ |
396 | #include <bluetooth/sdp.h> |
397 | #include <bluetooth/sdp_lib.h> |
398 | |
399 | +#include "logging.h" |
400 | #include "pbap.h" |
401 | #include "sync.h" |
402 | #include "session.h" |
403 | @@ -55,6 +56,8 @@ |
404 | |
405 | #define DEFAULT_BUFFER_SIZE 4096 |
406 | |
407 | +typedef int (*reply_callback_t) (struct session_data *session, void *data); |
408 | + |
409 | static guint64 counter = 0; |
410 | |
411 | static unsigned char pcsuite_uuid[] = { 0x00, 0x00, 0x50, 0x05, 0x00, 0x00, |
412 | @@ -68,6 +71,19 @@ |
413 | void *data; |
414 | }; |
415 | |
416 | +struct pending_request { |
417 | + struct session_data *session; |
418 | + reply_callback_t callback; |
419 | + void *data; |
420 | +}; |
421 | + |
422 | +struct get_params { |
423 | + const char *type; |
424 | + const guint8 *apparam; |
425 | + gint apparam_size; |
426 | + session_callback_t func; |
427 | +}; |
428 | + |
429 | static struct session_data *session_ref(struct session_data *session) |
430 | { |
431 | g_atomic_int_inc(&session->refcount); |
432 | @@ -461,26 +477,6 @@ |
433 | return 0; |
434 | } |
435 | |
436 | -static void agent_request(DBusConnection *conn, const char *agent_name, |
437 | - const char *agent_path, const char *transfer_path) |
438 | -{ |
439 | - DBusMessage *message; |
440 | - |
441 | - if (agent_name == NULL || agent_path == NULL || transfer_path == NULL) |
442 | - return; |
443 | - |
444 | - message = dbus_message_new_method_call(agent_name, |
445 | - agent_path, AGENT_INTERFACE, "Request"); |
446 | - |
447 | - dbus_message_append_args(message, |
448 | - DBUS_TYPE_OBJECT_PATH, &transfer_path, |
449 | - DBUS_TYPE_INVALID); |
450 | - |
451 | - g_dbus_send_message(conn, message); |
452 | - |
453 | - /* FIXME: Reply needs be handled */ |
454 | -} |
455 | - |
456 | static void agent_notify_progress(DBusConnection *conn, const char *agent_name, |
457 | const char *agent_path, const char *transfer_path, |
458 | uint64_t transferred) |
459 | @@ -592,21 +588,6 @@ |
460 | session_unref(session); |
461 | } |
462 | |
463 | -int session_set_agent(struct session_data *session, const char *name, |
464 | - const char *path) |
465 | -{ |
466 | - if (session == NULL) |
467 | - return -EINVAL; |
468 | - |
469 | - if (session->agent_name != NULL || session->agent_path != NULL) |
470 | - return -EALREADY; |
471 | - |
472 | - session->agent_name = g_strdup(name); |
473 | - session->agent_path = g_strdup(path); |
474 | - |
475 | - return 0; |
476 | -} |
477 | - |
478 | static void append_entry(DBusMessageIter *dict, |
479 | const char *key, int type, void *val) |
480 | { |
481 | @@ -978,9 +959,11 @@ |
482 | |
483 | static void unregister_transfer(struct session_data *session) |
484 | { |
485 | - gw_obex_xfer_close(session->xfer, NULL); |
486 | - gw_obex_xfer_free(session->xfer); |
487 | - session->xfer = NULL; |
488 | + if (session->xfer) { |
489 | + gw_obex_xfer_close(session->xfer, NULL); |
490 | + gw_obex_xfer_free(session->xfer); |
491 | + session->xfer = NULL; |
492 | + } |
493 | |
494 | g_free(session->filename); |
495 | session->filename = NULL; |
496 | @@ -1081,7 +1064,7 @@ |
497 | } |
498 | |
499 | if (err) { |
500 | - fprintf(stderr, "gw_obex_xfer_read(): %s\n", |
501 | + error("gw_obex_xfer_read(): %s", |
502 | OBEX_ResponseToString(err)); |
503 | goto complete; |
504 | } |
505 | @@ -1157,7 +1140,7 @@ |
506 | } |
507 | |
508 | if (ret == FALSE) { |
509 | - fprintf(stderr, "gw_obex_xfer_read(): %s\n", |
510 | + error("gw_obex_xfer_read(): %s", |
511 | OBEX_ResponseToString(err)); |
512 | goto complete; |
513 | } |
514 | @@ -1215,13 +1198,212 @@ |
515 | g_free(callback); |
516 | } |
517 | |
518 | +static void put_xfer_progress(GwObexXfer *xfer, gpointer user_data) |
519 | +{ |
520 | + struct session_data *session = user_data; |
521 | + ssize_t len; |
522 | + gint written; |
523 | + |
524 | + if (session->buffer_len == 0) { |
525 | + session->buffer_len = DEFAULT_BUFFER_SIZE; |
526 | + session->buffer = g_new0(char, DEFAULT_BUFFER_SIZE); |
527 | + } |
528 | + |
529 | + len = read(session->fd, session->buffer + session->filled, |
530 | + session->buffer_len - session->filled); |
531 | + if (len <= 0) |
532 | + goto complete; |
533 | + |
534 | + if (gw_obex_xfer_write(xfer, session->buffer, session->filled + len, |
535 | + &written, NULL) == FALSE) |
536 | + goto complete; |
537 | + |
538 | + if (gw_obex_xfer_flush(xfer, NULL) == FALSE) |
539 | + goto complete; |
540 | + |
541 | + session->filled = (session->filled + len) - written; |
542 | + |
543 | + memmove(session->buffer, session->buffer + written, session->filled); |
544 | + |
545 | + session->transferred += written; |
546 | + |
547 | + agent_notify_progress(session->conn, session->agent_name, |
548 | + session->agent_path, session->transfer_path, |
549 | + session->transferred); |
550 | + return; |
551 | + |
552 | +complete: |
553 | + if (len == 0) |
554 | + agent_notify_complete(session->conn, session->agent_name, |
555 | + session->agent_path, session->transfer_path); |
556 | + else |
557 | + agent_notify_error(session->conn, session->agent_name, |
558 | + session->agent_path, session->transfer_path, |
559 | + "Error sending object"); |
560 | + |
561 | + unregister_transfer(session); |
562 | + |
563 | + if (session->pending->len > 0) { |
564 | + gchar *filename = g_ptr_array_index(session->pending, 0); |
565 | + gchar *basename = g_path_get_basename(filename); |
566 | + |
567 | + g_ptr_array_remove(session->pending, filename); |
568 | + |
569 | + session_send(session, filename, basename); |
570 | + g_free(filename); |
571 | + g_free(basename); |
572 | + } |
573 | + |
574 | + session_unref(session); |
575 | +} |
576 | + |
577 | +static void agent_request_reply(DBusPendingCall *call, gpointer user_data) |
578 | +{ |
579 | + struct pending_request *pending = user_data; |
580 | + struct session_data *session = pending->session; |
581 | + DBusMessage *reply = dbus_pending_call_steal_reply(call); |
582 | + const char *name; |
583 | + DBusError derr; |
584 | + |
585 | + dbus_error_init(&derr); |
586 | + if (dbus_set_error_from_message(&derr, reply)) { |
587 | + error("Replied with an error: %s, %s", |
588 | + derr.name, derr.message); |
589 | + dbus_error_free(&derr); |
590 | + goto fail; |
591 | + } |
592 | + |
593 | + dbus_message_get_args(reply, NULL, |
594 | + DBUS_TYPE_STRING, &name, |
595 | + DBUS_TYPE_INVALID); |
596 | + |
597 | + if (strlen(name)) { |
598 | + g_free(session->name); |
599 | + session->name = g_strdup(name); |
600 | + } |
601 | + |
602 | + if (pending->callback(session, pending->data)) |
603 | + goto fail; |
604 | + |
605 | + g_free(pending); |
606 | + |
607 | + return; |
608 | + |
609 | +fail: |
610 | + unregister_transfer(session); |
611 | + |
612 | + session_unref(session); |
613 | + |
614 | + if (session->pending->len > 0) { |
615 | + gchar *filename = g_ptr_array_index(session->pending, 0); |
616 | + gchar *basename = g_path_get_basename(filename); |
617 | + |
618 | + g_ptr_array_remove(session->pending, filename); |
619 | + |
620 | + session_send(session, filename, basename); |
621 | + g_free(filename); |
622 | + g_free(basename); |
623 | + } |
624 | + |
625 | + g_free(pending); |
626 | +} |
627 | + |
628 | +static void agent_request(DBusConnection *conn, struct session_data *session, |
629 | + reply_callback_t cb, void *user_data) |
630 | +{ |
631 | + DBusMessage *message; |
632 | + DBusPendingCall *call; |
633 | + struct pending_request *pending; |
634 | + |
635 | + if (session->agent_name == NULL || session->agent_path == NULL || |
636 | + session->transfer_path == NULL) { |
637 | + if (cb(session, user_data)) |
638 | + goto fail; |
639 | + |
640 | + return; |
641 | + } |
642 | + |
643 | + message = dbus_message_new_method_call(session->agent_name, |
644 | + session->agent_path, AGENT_INTERFACE, "Request"); |
645 | + |
646 | + dbus_message_append_args(message, |
647 | + DBUS_TYPE_OBJECT_PATH, &session->transfer_path, |
648 | + DBUS_TYPE_INVALID); |
649 | + |
650 | + if (!dbus_connection_send_with_reply(conn, message, &call, -1)) { |
651 | + dbus_message_unref(message); |
652 | + return; |
653 | + } |
654 | + |
655 | + dbus_message_unref(message); |
656 | + |
657 | + pending = g_new0(struct pending_request, 1); |
658 | + pending->session = session; |
659 | + pending->callback = cb; |
660 | + pending->data = user_data; |
661 | + |
662 | + dbus_pending_call_set_notify(call, agent_request_reply, pending, NULL); |
663 | + dbus_pending_call_unref(call); |
664 | + |
665 | + return; |
666 | + |
667 | +fail: |
668 | + unregister_transfer(session); |
669 | + |
670 | + session_unref(session); |
671 | +} |
672 | + |
673 | +static int session_get_reply(struct session_data *session, void *data) |
674 | +{ |
675 | + struct get_params *params = data; |
676 | + struct callback_data *callback; |
677 | + GwObexXfer *xfer; |
678 | + |
679 | + xfer = gw_obex_get_async_with_apparam(session->obex, session->filename, |
680 | + params->type, params->apparam, params->apparam_size, |
681 | + NULL); |
682 | + |
683 | + if (xfer == NULL) { |
684 | + close(session->fd); |
685 | + session_unref(session); |
686 | + g_free(params); |
687 | + return -EIO; |
688 | + } |
689 | + |
690 | + callback = g_try_malloc0(sizeof(*callback)); |
691 | + if (callback == NULL) { |
692 | + close(session->fd); |
693 | + session_unref(session); |
694 | + gw_obex_xfer_free(xfer); |
695 | + g_free(params); |
696 | + return -ENOMEM; |
697 | + } |
698 | + |
699 | + callback->session = session; |
700 | + callback->func = params->func; |
701 | + |
702 | + if (params->type == NULL) |
703 | + gw_obex_xfer_set_callback(xfer, get_xfer_progress, callback); |
704 | + else |
705 | + gw_obex_xfer_set_callback(xfer, get_xfer_listing_progress, |
706 | + callback); |
707 | + |
708 | + session->xfer = xfer; |
709 | + |
710 | + agent_notify_progress(session->conn, session->agent_name, |
711 | + session->agent_path, session->transfer_path, 0); |
712 | + |
713 | + g_free(params); |
714 | + |
715 | + return 0; |
716 | +} |
717 | + |
718 | int session_get(struct session_data *session, const char *type, |
719 | const char *filename, const char *targetname, |
720 | const guint8 *apparam, gint apparam_size, |
721 | session_callback_t func) |
722 | { |
723 | - struct callback_data *callback; |
724 | - GwObexXfer *xfer; |
725 | + struct get_params *params; |
726 | int err, fd = 0; |
727 | |
728 | if (session->obex == NULL) |
729 | @@ -1234,12 +1416,13 @@ |
730 | fd = open(targetname, O_WRONLY | O_CREAT, 0600); |
731 | if (fd < 0) { |
732 | err = errno; |
733 | - fprintf(stderr, "open(): %s(%d)\n", strerror(err), err); |
734 | + error("open(): %s(%d)", strerror(err), err); |
735 | return -err; |
736 | } |
737 | } |
738 | |
739 | - if (type == NULL || !g_str_equal(type, "x-obex/folder-listing")) { |
740 | + /* for OBEX specific mime types we don't need to register a transfer */ |
741 | + if (type == NULL || (strncmp(type, "x-obex/", 7) && strncmp(type, "x-bt/", 5))) { |
742 | session->transfer_path = register_transfer(session->conn, session); |
743 | if (session->transfer_path == NULL) { |
744 | if (fd) |
745 | @@ -1257,38 +1440,13 @@ |
746 | |
747 | session_ref(session); |
748 | |
749 | - xfer = gw_obex_get_async_with_apparam(session->obex, |
750 | - filename, type, apparam, apparam_size, NULL); |
751 | - if (xfer == NULL) { |
752 | - close(session->fd); |
753 | - session_unref(session); |
754 | - return -EIO; |
755 | - } |
756 | - |
757 | - callback = g_try_malloc0(sizeof(*callback)); |
758 | - if (callback == NULL) { |
759 | - close(session->fd); |
760 | - session_unref(session); |
761 | - gw_obex_xfer_free(xfer); |
762 | - return -ENOMEM; |
763 | - } |
764 | - |
765 | - callback->session = session; |
766 | - callback->func = func; |
767 | - |
768 | - if (type == NULL) |
769 | - gw_obex_xfer_set_callback(xfer, get_xfer_progress, callback); |
770 | - else |
771 | - gw_obex_xfer_set_callback(xfer, get_xfer_listing_progress, |
772 | - callback); |
773 | - |
774 | - session->xfer = xfer; |
775 | - |
776 | - agent_request(session->conn, session->agent_name, |
777 | - session->agent_path, session->transfer_path); |
778 | - |
779 | - agent_notify_progress(session->conn, session->agent_name, |
780 | - session->agent_path, session->transfer_path, 0); |
781 | + params = g_new0(struct get_params, 1); |
782 | + params->type = type; |
783 | + params->apparam = apparam; |
784 | + params->apparam_size = apparam_size; |
785 | + params->func = func; |
786 | + |
787 | + agent_request(session->conn, session, session_get_reply, params); |
788 | |
789 | return 0; |
790 | } |
791 | @@ -1458,93 +1616,56 @@ |
792 | { } |
793 | }; |
794 | |
795 | -static void put_xfer_progress(GwObexXfer *xfer, gpointer user_data) |
796 | + |
797 | +static int session_send_reply(struct session_data *session, void *data) |
798 | { |
799 | - struct session_data *session = user_data; |
800 | - ssize_t len; |
801 | - gint written; |
802 | - |
803 | - if (session->buffer_len == 0) { |
804 | - session->buffer_len = DEFAULT_BUFFER_SIZE; |
805 | - session->buffer = g_new0(char, DEFAULT_BUFFER_SIZE); |
806 | - } |
807 | - |
808 | - len = read(session->fd, session->buffer + session->filled, |
809 | - session->buffer_len - session->filled); |
810 | - if (len <= 0) |
811 | - goto complete; |
812 | - |
813 | - if (gw_obex_xfer_write(xfer, session->buffer, session->filled + len, |
814 | - &written, NULL) == FALSE) |
815 | - goto complete; |
816 | - |
817 | - if (gw_obex_xfer_flush(xfer, NULL) == FALSE) |
818 | - goto complete; |
819 | - |
820 | - session->filled = (session->filled + len) - written; |
821 | - |
822 | - memmove(session->buffer + written, session->buffer, session->filled); |
823 | - |
824 | - session->transferred += written; |
825 | + GwObexXfer *xfer; |
826 | + |
827 | + xfer = gw_obex_put_async(session->obex, session->name, NULL, |
828 | + session->size, -1, NULL); |
829 | + if (xfer == NULL) |
830 | + return -ENOTCONN; |
831 | + |
832 | + gw_obex_xfer_set_callback(xfer, put_xfer_progress, session); |
833 | + |
834 | + session->xfer = xfer; |
835 | |
836 | agent_notify_progress(session->conn, session->agent_name, |
837 | - session->agent_path, session->transfer_path, |
838 | - session->transferred); |
839 | - return; |
840 | - |
841 | -complete: |
842 | - if (len == 0) |
843 | - agent_notify_complete(session->conn, session->agent_name, |
844 | - session->agent_path, session->transfer_path); |
845 | - else |
846 | - agent_notify_error(session->conn, session->agent_name, |
847 | - session->agent_path, session->transfer_path, |
848 | - "Error sending object"); |
849 | - |
850 | - unregister_transfer(session); |
851 | - |
852 | - if (session->pending->len > 0) { |
853 | - gchar *filename = g_ptr_array_index(session->pending, 0); |
854 | - gchar *basename = g_path_get_basename(filename); |
855 | - |
856 | - g_ptr_array_remove(session->pending, filename); |
857 | - |
858 | - session_send(session, filename, basename); |
859 | - g_free(filename); |
860 | - g_free(basename); |
861 | - } |
862 | - |
863 | - session_unref(session); |
864 | + session->agent_path, session->transfer_path, 0); |
865 | + |
866 | + return 0; |
867 | } |
868 | |
869 | int session_send(struct session_data *session, const char *filename, |
870 | const char *targetname) |
871 | { |
872 | - GwObexXfer *xfer; |
873 | struct stat st; |
874 | - int fd; |
875 | + int fd, err; |
876 | |
877 | if (session->obex == NULL) |
878 | return -ENOTCONN; |
879 | |
880 | - if (session->xfer != NULL) { |
881 | + if (session->transfer_path != NULL) { |
882 | g_ptr_array_add(session->pending, g_strdup(filename)); |
883 | return 0; |
884 | } |
885 | |
886 | + session->transfer_path = register_transfer(session->conn, session); |
887 | + if (session->transfer_path == NULL) { |
888 | + err = -EINVAL; |
889 | + goto fail; |
890 | + } |
891 | + |
892 | fd = open(filename, O_RDONLY); |
893 | - if (fd < 0) |
894 | - return -EIO; |
895 | + if (fd < 0) { |
896 | + err = -EIO; |
897 | + goto fail; |
898 | + } |
899 | |
900 | if (fstat(fd, &st) < 0) { |
901 | close(fd); |
902 | - return -EIO; |
903 | - } |
904 | - |
905 | - session->transfer_path = register_transfer(session->conn, session); |
906 | - if (session->transfer_path == NULL) { |
907 | - close(fd); |
908 | - return -EIO; |
909 | + err = -EIO; |
910 | + goto fail; |
911 | } |
912 | |
913 | session->fd = fd; |
914 | @@ -1555,22 +1676,16 @@ |
915 | |
916 | session_ref(session); |
917 | |
918 | - xfer = gw_obex_put_async(session->obex, session->name, NULL, |
919 | - session->size, -1, NULL); |
920 | - if (xfer == NULL) |
921 | - return -ENOTCONN; |
922 | - |
923 | - gw_obex_xfer_set_callback(xfer, put_xfer_progress, session); |
924 | - |
925 | - session->xfer = xfer; |
926 | - |
927 | - agent_request(session->conn, session->agent_name, |
928 | - session->agent_path, session->transfer_path); |
929 | - |
930 | - agent_notify_progress(session->conn, session->agent_name, |
931 | - session->agent_path, session->transfer_path, 0); |
932 | + agent_request(session->conn, session, session_send_reply, NULL); |
933 | |
934 | return 0; |
935 | + |
936 | +fail: |
937 | + agent_notify_error(session->conn, session->agent_name, |
938 | + session->agent_path, session->transfer_path, |
939 | + "Could not open file for sending"); |
940 | + |
941 | + return err; |
942 | } |
943 | |
944 | int session_pull(struct session_data *session, |
945 | @@ -1695,10 +1810,30 @@ |
946 | session_unref(session); |
947 | } |
948 | |
949 | + |
950 | +static int session_put_reply(struct session_data *session, void *data) |
951 | +{ |
952 | + GwObexXfer *xfer; |
953 | + |
954 | + xfer = gw_obex_put_async(session->obex, session->name, NULL, |
955 | + session->size, -1, NULL); |
956 | + if (xfer == NULL) |
957 | + return -ENOTCONN; |
958 | + |
959 | + session_ref(session); |
960 | + |
961 | + gw_obex_xfer_set_callback(xfer, put_buf_xfer_progress, session); |
962 | + |
963 | + session->xfer = xfer; |
964 | + |
965 | + agent_notify_progress(session->conn, session->agent_name, |
966 | + session->agent_path, session->transfer_path, 0); |
967 | + |
968 | + return 0; |
969 | +} |
970 | + |
971 | int session_put(struct session_data *session, char *buf, const char *targetname) |
972 | { |
973 | - GwObexXfer *xfer; |
974 | - |
975 | if (session->obex == NULL) |
976 | return -ENOTCONN; |
977 | |
978 | @@ -1711,22 +1846,28 @@ |
979 | session->name = g_strdup(targetname); |
980 | session->buffer = buf; |
981 | |
982 | - xfer = gw_obex_put_async(session->obex, session->name, NULL, |
983 | - session->size, -1, NULL); |
984 | - if (xfer == NULL) |
985 | - return -ENOTCONN; |
986 | + agent_request(session->conn, session, session_put_reply, NULL); |
987 | + |
988 | + return 0; |
989 | +} |
990 | + |
991 | +int session_set_agent(struct session_data *session, const char *name, |
992 | + const char *path) |
993 | +{ |
994 | + if (session == NULL) |
995 | + return -EINVAL; |
996 | + |
997 | + if (session->agent_name != NULL || session->agent_path != NULL) |
998 | + return -EALREADY; |
999 | + |
1000 | + session->agent_name = g_strdup(name); |
1001 | + session->agent_path = g_strdup(path); |
1002 | + |
1003 | + session->owner_watch = g_dbus_add_disconnect_watch(session->conn, |
1004 | + session->owner, owner_disconnected, |
1005 | + session, NULL); |
1006 | |
1007 | session_ref(session); |
1008 | |
1009 | - gw_obex_xfer_set_callback(xfer, put_buf_xfer_progress, session); |
1010 | - |
1011 | - session->xfer = xfer; |
1012 | - |
1013 | - agent_request(session->conn, session->agent_name, |
1014 | - session->agent_path, session->transfer_path); |
1015 | - |
1016 | - agent_notify_progress(session->conn, session->agent_name, |
1017 | - session->agent_path, session->transfer_path, 0); |
1018 | - |
1019 | return 0; |
1020 | } |
1021 | |
1022 | === modified file 'client/session.h' |
1023 | --- client/session.h 2010-01-10 10:46:58 +0000 |
1024 | +++ client/session.h 2010-04-28 20:38:30 +0000 |
1025 | @@ -2,7 +2,7 @@ |
1026 | * |
1027 | * OBEX Client |
1028 | * |
1029 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
1030 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
1031 | * |
1032 | * |
1033 | * This program is free software; you can redistribute it and/or modify |
1034 | |
1035 | === modified file 'client/sync.c' |
1036 | --- client/sync.c 2009-07-27 19:02:30 +0000 |
1037 | +++ client/sync.c 2010-04-28 20:38:30 +0000 |
1038 | @@ -2,8 +2,8 @@ |
1039 | * |
1040 | * OBEX Client |
1041 | * |
1042 | - * Copyright (C) 2007-2009 Intel Corporation |
1043 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
1044 | + * Copyright (C) 2007-2010 Intel Corporation |
1045 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
1046 | * |
1047 | * |
1048 | * This program is free software; you can redistribute it and/or modify |
1049 | |
1050 | === modified file 'client/sync.h' |
1051 | --- client/sync.h 2009-07-27 19:02:30 +0000 |
1052 | +++ client/sync.h 2010-04-28 20:38:30 +0000 |
1053 | @@ -2,8 +2,8 @@ |
1054 | * |
1055 | * OBEX Client |
1056 | * |
1057 | - * Copyright (C) 2007-2008 Intel Corporation |
1058 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
1059 | + * Copyright (C) 2007-2010 Intel Corporation |
1060 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
1061 | * |
1062 | * |
1063 | * This program is free software; you can redistribute it and/or modify |
1064 | |
1065 | === modified file 'config.guess' |
1066 | --- config.guess 2009-07-27 19:02:30 +0000 |
1067 | +++ config.guess 2010-04-28 20:38:30 +0000 |
1068 | @@ -1,10 +1,10 @@ |
1069 | #! /bin/sh |
1070 | # Attempt to guess a canonical system name. |
1071 | # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
1072 | -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
1073 | +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
1074 | # Free Software Foundation, Inc. |
1075 | |
1076 | -timestamp='2009-04-27' |
1077 | +timestamp='2009-11-20' |
1078 | |
1079 | # This file is free software; you can redistribute it and/or modify it |
1080 | # under the terms of the GNU General Public License as published by |
1081 | @@ -27,16 +27,16 @@ |
1082 | # the same distribution terms that you use for the rest of that program. |
1083 | |
1084 | |
1085 | -# Originally written by Per Bothner <per@bothner.com>. |
1086 | -# Please send patches to <config-patches@gnu.org>. Submit a context |
1087 | -# diff and a properly formatted ChangeLog entry. |
1088 | +# Originally written by Per Bothner. Please send patches (context |
1089 | +# diff format) to <config-patches@gnu.org> and include a ChangeLog |
1090 | +# entry. |
1091 | # |
1092 | # This script attempts to guess a canonical system name similar to |
1093 | # config.sub. If it succeeds, it prints the system name on stdout, and |
1094 | # exits with 0. Otherwise, it exits with 1. |
1095 | # |
1096 | -# The plan is that this can be called by configure scripts if you |
1097 | -# don't specify an explicit build system type. |
1098 | +# You can get the latest version of this script from: |
1099 | +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD |
1100 | |
1101 | me=`echo "$0" | sed -e 's,.*/,,'` |
1102 | |
1103 | @@ -170,7 +170,7 @@ |
1104 | arm*|i386|m68k|ns32k|sh3*|sparc|vax) |
1105 | eval $set_cc_for_build |
1106 | if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ |
1107 | - | grep __ELF__ >/dev/null |
1108 | + | grep -q __ELF__ |
1109 | then |
1110 | # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). |
1111 | # Return netbsd for either. FIX? |
1112 | @@ -333,6 +333,9 @@ |
1113 | sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) |
1114 | echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` |
1115 | exit ;; |
1116 | + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) |
1117 | + echo i386-pc-auroraux${UNAME_RELEASE} |
1118 | + exit ;; |
1119 | i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) |
1120 | eval $set_cc_for_build |
1121 | SUN_ARCH="i386" |
1122 | @@ -656,7 +659,7 @@ |
1123 | # => hppa64-hp-hpux11.23 |
1124 | |
1125 | if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | |
1126 | - grep __LP64__ >/dev/null |
1127 | + grep -q __LP64__ |
1128 | then |
1129 | HP_ARCH="hppa2.0w" |
1130 | else |
1131 | @@ -807,12 +810,12 @@ |
1132 | i*:PW*:*) |
1133 | echo ${UNAME_MACHINE}-pc-pw32 |
1134 | exit ;; |
1135 | - *:Interix*:[3456]*) |
1136 | + *:Interix*:*) |
1137 | case ${UNAME_MACHINE} in |
1138 | x86) |
1139 | echo i586-pc-interix${UNAME_RELEASE} |
1140 | exit ;; |
1141 | - EM64T | authenticamd | genuineintel) |
1142 | + authenticamd | genuineintel | EM64T) |
1143 | echo x86_64-unknown-interix${UNAME_RELEASE} |
1144 | exit ;; |
1145 | IA64) |
1146 | @@ -822,6 +825,9 @@ |
1147 | [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) |
1148 | echo i${UNAME_MACHINE}-pc-mks |
1149 | exit ;; |
1150 | + 8664:Windows_NT:*) |
1151 | + echo x86_64-pc-mks |
1152 | + exit ;; |
1153 | i*:Windows_NT*:* | Pentium*:Windows_NT*:*) |
1154 | # How do we know it's Interix rather than the generic POSIX subsystem? |
1155 | # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we |
1156 | @@ -851,6 +857,20 @@ |
1157 | i*86:Minix:*:*) |
1158 | echo ${UNAME_MACHINE}-pc-minix |
1159 | exit ;; |
1160 | + alpha:Linux:*:*) |
1161 | + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in |
1162 | + EV5) UNAME_MACHINE=alphaev5 ;; |
1163 | + EV56) UNAME_MACHINE=alphaev56 ;; |
1164 | + PCA56) UNAME_MACHINE=alphapca56 ;; |
1165 | + PCA57) UNAME_MACHINE=alphapca56 ;; |
1166 | + EV6) UNAME_MACHINE=alphaev6 ;; |
1167 | + EV67) UNAME_MACHINE=alphaev67 ;; |
1168 | + EV68*) UNAME_MACHINE=alphaev68 ;; |
1169 | + esac |
1170 | + objdump --private-headers /bin/sh | grep -q ld.so.1 |
1171 | + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi |
1172 | + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} |
1173 | + exit ;; |
1174 | arm*:Linux:*:*) |
1175 | eval $set_cc_for_build |
1176 | if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ |
1177 | @@ -873,6 +893,17 @@ |
1178 | frv:Linux:*:*) |
1179 | echo frv-unknown-linux-gnu |
1180 | exit ;; |
1181 | + i*86:Linux:*:*) |
1182 | + LIBC=gnu |
1183 | + eval $set_cc_for_build |
1184 | + sed 's/^ //' << EOF >$dummy.c |
1185 | + #ifdef __dietlibc__ |
1186 | + LIBC=dietlibc |
1187 | + #endif |
1188 | +EOF |
1189 | + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` |
1190 | + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" |
1191 | + exit ;; |
1192 | ia64:Linux:*:*) |
1193 | echo ${UNAME_MACHINE}-unknown-linux-gnu |
1194 | exit ;; |
1195 | @@ -882,78 +913,34 @@ |
1196 | m68*:Linux:*:*) |
1197 | echo ${UNAME_MACHINE}-unknown-linux-gnu |
1198 | exit ;; |
1199 | - mips:Linux:*:*) |
1200 | - eval $set_cc_for_build |
1201 | - sed 's/^ //' << EOF >$dummy.c |
1202 | - #undef CPU |
1203 | - #undef mips |
1204 | - #undef mipsel |
1205 | - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) |
1206 | - CPU=mipsel |
1207 | - #else |
1208 | - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) |
1209 | - CPU=mips |
1210 | - #else |
1211 | - CPU= |
1212 | - #endif |
1213 | - #endif |
1214 | -EOF |
1215 | - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' |
1216 | - /^CPU/{ |
1217 | - s: ::g |
1218 | - p |
1219 | - }'`" |
1220 | - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } |
1221 | - ;; |
1222 | - mips64:Linux:*:*) |
1223 | - eval $set_cc_for_build |
1224 | - sed 's/^ //' << EOF >$dummy.c |
1225 | - #undef CPU |
1226 | - #undef mips64 |
1227 | - #undef mips64el |
1228 | - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) |
1229 | - CPU=mips64el |
1230 | - #else |
1231 | - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) |
1232 | - CPU=mips64 |
1233 | - #else |
1234 | - CPU= |
1235 | - #endif |
1236 | - #endif |
1237 | -EOF |
1238 | - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' |
1239 | - /^CPU/{ |
1240 | - s: ::g |
1241 | - p |
1242 | - }'`" |
1243 | + mips:Linux:*:* | mips64:Linux:*:*) |
1244 | + eval $set_cc_for_build |
1245 | + sed 's/^ //' << EOF >$dummy.c |
1246 | + #undef CPU |
1247 | + #undef ${UNAME_MACHINE} |
1248 | + #undef ${UNAME_MACHINE}el |
1249 | + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) |
1250 | + CPU=${UNAME_MACHINE}el |
1251 | + #else |
1252 | + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) |
1253 | + CPU=${UNAME_MACHINE} |
1254 | + #else |
1255 | + CPU= |
1256 | + #endif |
1257 | + #endif |
1258 | +EOF |
1259 | + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` |
1260 | test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } |
1261 | ;; |
1262 | or32:Linux:*:*) |
1263 | echo or32-unknown-linux-gnu |
1264 | exit ;; |
1265 | - ppc:Linux:*:*) |
1266 | - echo powerpc-unknown-linux-gnu |
1267 | - exit ;; |
1268 | - ppc64:Linux:*:*) |
1269 | - echo powerpc64-unknown-linux-gnu |
1270 | - exit ;; |
1271 | - alpha:Linux:*:*) |
1272 | - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in |
1273 | - EV5) UNAME_MACHINE=alphaev5 ;; |
1274 | - EV56) UNAME_MACHINE=alphaev56 ;; |
1275 | - PCA56) UNAME_MACHINE=alphapca56 ;; |
1276 | - PCA57) UNAME_MACHINE=alphapca56 ;; |
1277 | - EV6) UNAME_MACHINE=alphaev6 ;; |
1278 | - EV67) UNAME_MACHINE=alphaev67 ;; |
1279 | - EV68*) UNAME_MACHINE=alphaev68 ;; |
1280 | - esac |
1281 | - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null |
1282 | - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi |
1283 | - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} |
1284 | - exit ;; |
1285 | padre:Linux:*:*) |
1286 | echo sparc-unknown-linux-gnu |
1287 | exit ;; |
1288 | + parisc64:Linux:*:* | hppa64:Linux:*:*) |
1289 | + echo hppa64-unknown-linux-gnu |
1290 | + exit ;; |
1291 | parisc:Linux:*:* | hppa:Linux:*:*) |
1292 | # Look for CPU level |
1293 | case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in |
1294 | @@ -962,8 +949,11 @@ |
1295 | *) echo hppa-unknown-linux-gnu ;; |
1296 | esac |
1297 | exit ;; |
1298 | - parisc64:Linux:*:* | hppa64:Linux:*:*) |
1299 | - echo hppa64-unknown-linux-gnu |
1300 | + ppc64:Linux:*:*) |
1301 | + echo powerpc64-unknown-linux-gnu |
1302 | + exit ;; |
1303 | + ppc:Linux:*:*) |
1304 | + echo powerpc-unknown-linux-gnu |
1305 | exit ;; |
1306 | s390:Linux:*:* | s390x:Linux:*:*) |
1307 | echo ${UNAME_MACHINE}-ibm-linux |
1308 | @@ -986,66 +976,6 @@ |
1309 | xtensa*:Linux:*:*) |
1310 | echo ${UNAME_MACHINE}-unknown-linux-gnu |
1311 | exit ;; |
1312 | - i*86:Linux:*:*) |
1313 | - # The BFD linker knows what the default object file format is, so |
1314 | - # first see if it will tell us. cd to the root directory to prevent |
1315 | - # problems with other programs or directories called `ld' in the path. |
1316 | - # Set LC_ALL=C to ensure ld outputs messages in English. |
1317 | - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ |
1318 | - | sed -ne '/supported targets:/!d |
1319 | - s/[ ][ ]*/ /g |
1320 | - s/.*supported targets: *// |
1321 | - s/ .*// |
1322 | - p'` |
1323 | - case "$ld_supported_targets" in |
1324 | - elf32-i386) |
1325 | - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" |
1326 | - ;; |
1327 | - a.out-i386-linux) |
1328 | - echo "${UNAME_MACHINE}-pc-linux-gnuaout" |
1329 | - exit ;; |
1330 | - "") |
1331 | - # Either a pre-BFD a.out linker (linux-gnuoldld) or |
1332 | - # one that does not give us useful --help. |
1333 | - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" |
1334 | - exit ;; |
1335 | - esac |
1336 | - # Determine whether the default compiler is a.out or elf |
1337 | - eval $set_cc_for_build |
1338 | - sed 's/^ //' << EOF >$dummy.c |
1339 | - #include <features.h> |
1340 | - #ifdef __ELF__ |
1341 | - # ifdef __GLIBC__ |
1342 | - # if __GLIBC__ >= 2 |
1343 | - LIBC=gnu |
1344 | - # else |
1345 | - LIBC=gnulibc1 |
1346 | - # endif |
1347 | - # else |
1348 | - LIBC=gnulibc1 |
1349 | - # endif |
1350 | - #else |
1351 | - #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) |
1352 | - LIBC=gnu |
1353 | - #else |
1354 | - LIBC=gnuaout |
1355 | - #endif |
1356 | - #endif |
1357 | - #ifdef __dietlibc__ |
1358 | - LIBC=dietlibc |
1359 | - #endif |
1360 | -EOF |
1361 | - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' |
1362 | - /^LIBC/{ |
1363 | - s: ::g |
1364 | - p |
1365 | - }'`" |
1366 | - test x"${LIBC}" != x && { |
1367 | - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" |
1368 | - exit |
1369 | - } |
1370 | - test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } |
1371 | - ;; |
1372 | i*86:DYNIX/ptx:4*:*) |
1373 | # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. |
1374 | # earlier versions are messed up and put the nodename in both |
1375 | @@ -1074,7 +1004,7 @@ |
1376 | i*86:syllable:*:*) |
1377 | echo ${UNAME_MACHINE}-pc-syllable |
1378 | exit ;; |
1379 | - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) |
1380 | + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) |
1381 | echo i386-unknown-lynxos${UNAME_RELEASE} |
1382 | exit ;; |
1383 | i*86:*DOS:*:*) |
1384 | @@ -1182,7 +1112,7 @@ |
1385 | rs6000:LynxOS:2.*:*) |
1386 | echo rs6000-unknown-lynxos${UNAME_RELEASE} |
1387 | exit ;; |
1388 | - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) |
1389 | + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) |
1390 | echo powerpc-unknown-lynxos${UNAME_RELEASE} |
1391 | exit ;; |
1392 | SM[BE]S:UNIX_SV:*:*) |
1393 | @@ -1275,6 +1205,16 @@ |
1394 | *:Darwin:*:*) |
1395 | UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown |
1396 | case $UNAME_PROCESSOR in |
1397 | + i386) |
1398 | + eval $set_cc_for_build |
1399 | + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then |
1400 | + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ |
1401 | + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ |
1402 | + grep IS_64BIT_ARCH >/dev/null |
1403 | + then |
1404 | + UNAME_PROCESSOR="x86_64" |
1405 | + fi |
1406 | + fi ;; |
1407 | unknown) UNAME_PROCESSOR=powerpc ;; |
1408 | esac |
1409 | echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} |
1410 | |
1411 | === modified file 'config.h.in' |
1412 | --- config.h.in 2009-07-27 19:02:30 +0000 |
1413 | +++ config.h.in 2010-04-28 20:38:30 +0000 |
1414 | @@ -43,6 +43,9 @@ |
1415 | */ |
1416 | #undef LT_OBJDIR |
1417 | |
1418 | +/* Define to 1 if you need the dbus_connection_can_send_type() funnction. */ |
1419 | +#undef NEED_DBUS_CONNECTION_CAN_SEND_TYPE |
1420 | + |
1421 | /* Define to 1 if you need the dbus_watch_get_unix_fd() function. */ |
1422 | #undef NEED_DBUS_WATCH_GET_UNIX_FD |
1423 | |
1424 | |
1425 | === modified file 'config.sub' |
1426 | --- config.sub 2009-07-27 19:02:30 +0000 |
1427 | +++ config.sub 2010-04-28 20:38:30 +0000 |
1428 | @@ -1,10 +1,10 @@ |
1429 | #! /bin/sh |
1430 | # Configuration validation subroutine script. |
1431 | # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
1432 | -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
1433 | +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
1434 | # Free Software Foundation, Inc. |
1435 | |
1436 | -timestamp='2009-04-17' |
1437 | +timestamp='2009-11-20' |
1438 | |
1439 | # This file is (in principle) common to ALL GNU software. |
1440 | # The presence of a machine in this file suggests that SOME GNU software |
1441 | @@ -32,13 +32,16 @@ |
1442 | |
1443 | |
1444 | # Please send patches to <config-patches@gnu.org>. Submit a context |
1445 | -# diff and a properly formatted ChangeLog entry. |
1446 | +# diff and a properly formatted GNU ChangeLog entry. |
1447 | # |
1448 | # Configuration subroutine to validate and canonicalize a configuration type. |
1449 | # Supply the specified configuration type as an argument. |
1450 | # If it is invalid, we print an error message on stderr and exit with code 1. |
1451 | # Otherwise, we print the canonical config type on stdout and succeed. |
1452 | |
1453 | +# You can get the latest version of this script from: |
1454 | +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD |
1455 | + |
1456 | # This file is supposed to be the same for all GNU packages |
1457 | # and recognize all the CPU types, system types and aliases |
1458 | # that are meaningful with *any* GNU software. |
1459 | @@ -149,10 +152,13 @@ |
1460 | -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ |
1461 | -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ |
1462 | -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ |
1463 | - -apple | -axis | -knuth | -cray) |
1464 | + -apple | -axis | -knuth | -cray | -microblaze) |
1465 | os= |
1466 | basic_machine=$1 |
1467 | ;; |
1468 | + -bluegene*) |
1469 | + os=-cnk |
1470 | + ;; |
1471 | -sim | -cisco | -oki | -wec | -winbond) |
1472 | os= |
1473 | basic_machine=$1 |
1474 | @@ -281,6 +287,7 @@ |
1475 | | pdp10 | pdp11 | pj | pjl \ |
1476 | | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ |
1477 | | pyramid \ |
1478 | + | rx \ |
1479 | | score \ |
1480 | | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ |
1481 | | sh64 | sh64le \ |
1482 | @@ -288,13 +295,14 @@ |
1483 | | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ |
1484 | | spu | strongarm \ |
1485 | | tahoe | thumb | tic4x | tic80 | tron \ |
1486 | + | ubicom32 \ |
1487 | | v850 | v850e \ |
1488 | | we32k \ |
1489 | | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ |
1490 | | z8k | z80) |
1491 | basic_machine=$basic_machine-unknown |
1492 | ;; |
1493 | - m6811 | m68hc11 | m6812 | m68hc12) |
1494 | + m6811 | m68hc11 | m6812 | m68hc12 | picochip) |
1495 | # Motorola 68HC11/12. |
1496 | basic_machine=$basic_machine-unknown |
1497 | os=-none |
1498 | @@ -337,7 +345,7 @@ |
1499 | | lm32-* \ |
1500 | | m32c-* | m32r-* | m32rle-* \ |
1501 | | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ |
1502 | - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ |
1503 | + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ |
1504 | | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ |
1505 | | mips16-* \ |
1506 | | mips64-* | mips64el-* \ |
1507 | @@ -365,7 +373,7 @@ |
1508 | | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ |
1509 | | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ |
1510 | | pyramid-* \ |
1511 | - | romp-* | rs6000-* \ |
1512 | + | romp-* | rs6000-* | rx-* \ |
1513 | | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ |
1514 | | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ |
1515 | | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ |
1516 | @@ -374,6 +382,7 @@ |
1517 | | tahoe-* | thumb-* \ |
1518 | | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ |
1519 | | tron-* \ |
1520 | + | ubicom32-* \ |
1521 | | v850-* | v850e-* | vax-* \ |
1522 | | we32k-* \ |
1523 | | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ |
1524 | @@ -467,6 +476,10 @@ |
1525 | basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` |
1526 | os=-linux |
1527 | ;; |
1528 | + bluegene*) |
1529 | + basic_machine=powerpc-ibm |
1530 | + os=-cnk |
1531 | + ;; |
1532 | c90) |
1533 | basic_machine=c90-cray |
1534 | os=-unicos |
1535 | @@ -719,6 +732,9 @@ |
1536 | basic_machine=ns32k-utek |
1537 | os=-sysv |
1538 | ;; |
1539 | + microblaze) |
1540 | + basic_machine=microblaze-xilinx |
1541 | + ;; |
1542 | mingw32) |
1543 | basic_machine=i386-pc |
1544 | os=-mingw32 |
1545 | @@ -1240,6 +1256,9 @@ |
1546 | # First match some system type aliases |
1547 | # that might get confused with valid system types. |
1548 | # -solaris* is a basic system type, with this one exception. |
1549 | + -auroraux) |
1550 | + os=-auroraux |
1551 | + ;; |
1552 | -solaris1 | -solaris1.*) |
1553 | os=`echo $os | sed -e 's|solaris1|sunos4|'` |
1554 | ;; |
1555 | @@ -1260,9 +1279,9 @@ |
1556 | # Each alternative MUST END IN A *, to match a version number. |
1557 | # -sysv* is not here because it comes later, after sysvr4. |
1558 | -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ |
1559 | - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ |
1560 | - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ |
1561 | - | -kopensolaris* \ |
1562 | + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ |
1563 | + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ |
1564 | + | -sym* | -kopensolaris* \ |
1565 | | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ |
1566 | | -aos* | -aros* \ |
1567 | | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ |
1568 | @@ -1283,7 +1302,7 @@ |
1569 | | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ |
1570 | | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ |
1571 | | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ |
1572 | - | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) |
1573 | + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) |
1574 | # Remember, each alternative MUST END IN *, to match a version number. |
1575 | ;; |
1576 | -qnx*) |
1577 | @@ -1613,7 +1632,7 @@ |
1578 | -sunos*) |
1579 | vendor=sun |
1580 | ;; |
1581 | - -aix*) |
1582 | + -cnk*|-aix*) |
1583 | vendor=ibm |
1584 | ;; |
1585 | -beos*) |
1586 | |
1587 | === modified file 'configure' |
1588 | --- configure 2010-01-10 10:46:58 +0000 |
1589 | +++ configure 2010-04-28 20:38:30 +0000 |
1590 | @@ -1,6 +1,6 @@ |
1591 | #! /bin/sh |
1592 | # Guess values for system-dependent variables and create Makefiles. |
1593 | -# Generated by GNU Autoconf 2.63 for obexd 0.21. |
1594 | +# Generated by GNU Autoconf 2.63 for obexd 0.22. |
1595 | # |
1596 | # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, |
1597 | # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
1598 | @@ -743,8 +743,8 @@ |
1599 | # Identity of this package. |
1600 | PACKAGE_NAME='obexd' |
1601 | PACKAGE_TARNAME='obexd' |
1602 | -PACKAGE_VERSION='0.21' |
1603 | -PACKAGE_STRING='obexd 0.21' |
1604 | +PACKAGE_VERSION='0.22' |
1605 | +PACKAGE_STRING='obexd 0.22' |
1606 | PACKAGE_BUGREPORT='' |
1607 | |
1608 | ac_default_prefix=/usr/local |
1609 | @@ -1509,7 +1509,7 @@ |
1610 | # Omit some internal or obsolete options to make the list less imposing. |
1611 | # This message is too long to be a string in the A/UX 3.1 sh. |
1612 | cat <<_ACEOF |
1613 | -\`configure' configures obexd 0.21 to adapt to many kinds of systems. |
1614 | +\`configure' configures obexd 0.22 to adapt to many kinds of systems. |
1615 | |
1616 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1617 | |
1618 | @@ -1579,7 +1579,7 @@ |
1619 | |
1620 | if test -n "$ac_init_help"; then |
1621 | case $ac_init_help in |
1622 | - short | recursive ) echo "Configuration of obexd 0.21:";; |
1623 | + short | recursive ) echo "Configuration of obexd 0.22:";; |
1624 | esac |
1625 | cat <<\_ACEOF |
1626 | |
1627 | @@ -1706,7 +1706,7 @@ |
1628 | test -n "$ac_init_help" && exit $ac_status |
1629 | if $ac_init_version; then |
1630 | cat <<\_ACEOF |
1631 | -obexd configure 0.21 |
1632 | +obexd configure 0.22 |
1633 | generated by GNU Autoconf 2.63 |
1634 | |
1635 | Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, |
1636 | @@ -1720,7 +1720,7 @@ |
1637 | This file contains any messages produced by compilers while |
1638 | running configure, to aid debugging if configure makes a mistake. |
1639 | |
1640 | -It was created by obexd $as_me 0.21, which was |
1641 | +It was created by obexd $as_me 0.22, which was |
1642 | generated by GNU Autoconf 2.63. Invocation command line was |
1643 | |
1644 | $ $0 $@ |
1645 | @@ -2570,7 +2570,7 @@ |
1646 | |
1647 | # Define the identity of the package. |
1648 | PACKAGE='obexd' |
1649 | - VERSION='0.21' |
1650 | + VERSION='0.22' |
1651 | |
1652 | |
1653 | cat >>confdefs.h <<_ACEOF |
1654 | @@ -4040,8 +4040,8 @@ |
1655 | |
1656 | |
1657 | |
1658 | -macro_version='2.2.6' |
1659 | -macro_revision='1.3012' |
1660 | +macro_version='2.2.6b' |
1661 | +macro_revision='1.3017' |
1662 | |
1663 | |
1664 | |
1665 | @@ -11932,6 +11932,81 @@ |
1666 | |
1667 | fi |
1668 | |
1669 | +{ $as_echo "$as_me:$LINENO: checking for dbus_connection_can_send_type in -ldbus-1" >&5 |
1670 | +$as_echo_n "checking for dbus_connection_can_send_type in -ldbus-1... " >&6; } |
1671 | +if test "${ac_cv_lib_dbus_1_dbus_connection_can_send_type+set}" = set; then |
1672 | + $as_echo_n "(cached) " >&6 |
1673 | +else |
1674 | + ac_check_lib_save_LIBS=$LIBS |
1675 | +LIBS="-ldbus-1 $LIBS" |
1676 | +cat >conftest.$ac_ext <<_ACEOF |
1677 | +/* confdefs.h. */ |
1678 | +_ACEOF |
1679 | +cat confdefs.h >>conftest.$ac_ext |
1680 | +cat >>conftest.$ac_ext <<_ACEOF |
1681 | +/* end confdefs.h. */ |
1682 | + |
1683 | +/* Override any GCC internal prototype to avoid an error. |
1684 | + Use char because int might match the return type of a GCC |
1685 | + builtin and then its argument prototype would still apply. */ |
1686 | +#ifdef __cplusplus |
1687 | +extern "C" |
1688 | +#endif |
1689 | +char dbus_connection_can_send_type (); |
1690 | +int |
1691 | +main () |
1692 | +{ |
1693 | +return dbus_connection_can_send_type (); |
1694 | + ; |
1695 | + return 0; |
1696 | +} |
1697 | +_ACEOF |
1698 | +rm -f conftest.$ac_objext conftest$ac_exeext |
1699 | +if { (ac_try="$ac_link" |
1700 | +case "(($ac_try" in |
1701 | + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; |
1702 | + *) ac_try_echo=$ac_try;; |
1703 | +esac |
1704 | +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" |
1705 | +$as_echo "$ac_try_echo") >&5 |
1706 | + (eval "$ac_link") 2>conftest.er1 |
1707 | + ac_status=$? |
1708 | + grep -v '^ *+' conftest.er1 >conftest.err |
1709 | + rm -f conftest.er1 |
1710 | + cat conftest.err >&5 |
1711 | + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 |
1712 | + (exit $ac_status); } && { |
1713 | + test -z "$ac_c_werror_flag" || |
1714 | + test ! -s conftest.err |
1715 | + } && test -s conftest$ac_exeext && { |
1716 | + test "$cross_compiling" = yes || |
1717 | + $as_test_x conftest$ac_exeext |
1718 | + }; then |
1719 | + ac_cv_lib_dbus_1_dbus_connection_can_send_type=yes |
1720 | +else |
1721 | + $as_echo "$as_me: failed program was:" >&5 |
1722 | +sed 's/^/| /' conftest.$ac_ext >&5 |
1723 | + |
1724 | + ac_cv_lib_dbus_1_dbus_connection_can_send_type=no |
1725 | +fi |
1726 | + |
1727 | +rm -rf conftest.dSYM |
1728 | +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ |
1729 | + conftest$ac_exeext conftest.$ac_ext |
1730 | +LIBS=$ac_check_lib_save_LIBS |
1731 | +fi |
1732 | +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dbus_1_dbus_connection_can_send_type" >&5 |
1733 | +$as_echo "$ac_cv_lib_dbus_1_dbus_connection_can_send_type" >&6; } |
1734 | +if test "x$ac_cv_lib_dbus_1_dbus_connection_can_send_type" = x""yes; then |
1735 | + dummy=yes |
1736 | +else |
1737 | + |
1738 | +cat >>confdefs.h <<\_ACEOF |
1739 | +#define NEED_DBUS_CONNECTION_CAN_SEND_TYPE 1 |
1740 | +_ACEOF |
1741 | + |
1742 | +fi |
1743 | + |
1744 | |
1745 | |
1746 | |
1747 | @@ -12102,13 +12177,16 @@ |
1748 | |
1749 | fi |
1750 | |
1751 | - |
1752 | phonebook_driver=dummy |
1753 | |
1754 | # Check whether --with-phonebook was given. |
1755 | if test "${with_phonebook+set}" = set; then |
1756 | withval=$with_phonebook; |
1757 | - phonebook_driver=${withval} |
1758 | + if (test "${withval}" = "no"); then |
1759 | + phonebook_driver=dummy; |
1760 | + else |
1761 | + phonebook_driver=${withval}; |
1762 | + fi |
1763 | |
1764 | fi |
1765 | |
1766 | @@ -12277,7 +12355,11 @@ |
1767 | # Check whether --with-telephony was given. |
1768 | if test "${with_telephony+set}" = set; then |
1769 | withval=$with_telephony; |
1770 | - telephony_driver=${withval} |
1771 | + if (test "${withval}" = "no"); then |
1772 | + telephony_driver=dummy; |
1773 | + else |
1774 | + telephony_driver=${withval}; |
1775 | + fi |
1776 | |
1777 | fi |
1778 | |
1779 | @@ -12781,7 +12863,7 @@ |
1780 | # report actual input values of CONFIG_FILES etc. instead of their |
1781 | # values after options handling. |
1782 | ac_log=" |
1783 | -This file was extended by obexd $as_me 0.21, which was |
1784 | +This file was extended by obexd $as_me 0.22, which was |
1785 | generated by GNU Autoconf 2.63. Invocation command line was |
1786 | |
1787 | CONFIG_FILES = $CONFIG_FILES |
1788 | @@ -12844,7 +12926,7 @@ |
1789 | _ACEOF |
1790 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
1791 | ac_cs_version="\\ |
1792 | -obexd config.status 0.21 |
1793 | +obexd config.status 0.22 |
1794 | configured by $0, generated by GNU Autoconf 2.63, |
1795 | with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" |
1796 | |
1797 | |
1798 | === modified file 'configure.ac' |
1799 | --- configure.ac 2010-01-10 10:46:58 +0000 |
1800 | +++ configure.ac 2010-04-28 20:38:30 +0000 |
1801 | @@ -1,5 +1,5 @@ |
1802 | AC_PREREQ(2.60) |
1803 | -AC_INIT(obexd, 0.21) |
1804 | +AC_INIT(obexd, 0.22) |
1805 | |
1806 | AM_INIT_AUTOMAKE([foreign subdir-objects]) |
1807 | AM_CONFIG_HEADER(config.h) |
1808 | @@ -76,6 +76,9 @@ |
1809 | AC_CHECK_LIB(dbus-1, dbus_watch_get_unix_fd, dummy=yes, |
1810 | AC_DEFINE(NEED_DBUS_WATCH_GET_UNIX_FD, 1, |
1811 | [Define to 1 if you need the dbus_watch_get_unix_fd() function.])) |
1812 | +AC_CHECK_LIB(dbus-1, dbus_connection_can_send_type, dummy=yes, |
1813 | + AC_DEFINE(NEED_DBUS_CONNECTION_CAN_SEND_TYPE, 1, |
1814 | + [Define to 1 if you need the dbus_connection_can_send_type() funnction.])) |
1815 | AC_SUBST(DBUS_CFLAGS) |
1816 | AC_SUBST(DBUS_LIBS) |
1817 | |
1818 | @@ -102,10 +105,13 @@ |
1819 | CFLAGS="$CFLAGS -g" |
1820 | fi |
1821 | ]) |
1822 | - |
1823 | phonebook_driver=dummy |
1824 | AC_ARG_WITH(phonebook, AC_HELP_STRING([--with-phonebook=DRIVER], [select phonebook driver]), [ |
1825 | - phonebook_driver=${withval} |
1826 | + if (test "${withval}" = "no"); then |
1827 | + phonebook_driver=dummy; |
1828 | + else |
1829 | + phonebook_driver=${withval}; |
1830 | + fi |
1831 | ]) |
1832 | |
1833 | if (test "${phonebook_driver}" = "ebook"); then |
1834 | @@ -126,7 +132,11 @@ |
1835 | |
1836 | telephony_driver=dummy |
1837 | AC_ARG_WITH(telephony, AC_HELP_STRING([--with-telephony=DRIVER], [select telephony driver]), [ |
1838 | - telephony_driver=${withval} |
1839 | + if (test "${withval}" = "no"); then |
1840 | + telephony_driver=dummy; |
1841 | + else |
1842 | + telephony_driver=${withval}; |
1843 | + fi |
1844 | ]) |
1845 | |
1846 | AC_SUBST([TELEPHONY_DRIVER], [telephony-${telephony_driver}.c]) |
1847 | |
1848 | === modified file 'debian/changelog' |
1849 | --- debian/changelog 2010-01-10 10:46:58 +0000 |
1850 | +++ debian/changelog 2010-04-28 20:38:30 +0000 |
1851 | @@ -1,4 +1,28 @@ |
1852 | -obexd (0.21-0ubuntu1) lucid; urgency=low |
1853 | +obexd (0.22-0ubuntu2) lucid-proposed; urgency=low |
1854 | + |
1855 | + * debian/patches/0001-Revert-Fix-the-session-is-shutdown-when-the-agent-ex.patch |
1856 | + - Revert change in release 0.22 to fix bluetooth-sendto dialog not being |
1857 | + closed after transfer (LP: #559412) |
1858 | + |
1859 | + -- Baptiste Mille-Mathias <baptiste.millemathias@gmail.com> Wed, 28 Apr 2010 21:20:16 +0200 |
1860 | + |
1861 | +obexd (0.22-0ubuntu1) lucid; urgency=low |
1862 | + |
1863 | + * New upstream release (LP: #539914): |
1864 | + - Fix file corruption during PUT operation. (LP: #421684] |
1865 | + - Fix the response of PUT requests for PBAP. |
1866 | + - Fix blocking while waiting capability script to exit. |
1867 | + - Fix compilation issues with driver and plugin options. |
1868 | + - Fix service driver selection when WHO header is informed. |
1869 | + - Fix issue with PC-Suite WHO header. |
1870 | + - Fix issue when mime type exists but is unknown. |
1871 | + - Fix issue when opening file fails during SendFiles. |
1872 | + - Fix error code response when there is no default vCard. |
1873 | + - Fix a memory leak when opening a folder for listing. |
1874 | + |
1875 | + -- Baptiste Mille-Mathias <baptiste.millemathias@gmail.com> Mon, 15 Mar 2010 20:43:06 +0100 |
1876 | + |
1877 | +obexd (0.21-0ubuntu1) karmic; urgency=low |
1878 | |
1879 | * New upstream release: (LP: #505432) |
1880 | - Fix crash caused by D-Bus timeout handling. |
1881 | |
1882 | === added directory 'debian/patches' |
1883 | === added file 'debian/patches/0001-Revert-Fix-the-session-is-shutdown-when-the-agent-ex.patch' |
1884 | --- debian/patches/0001-Revert-Fix-the-session-is-shutdown-when-the-agent-ex.patch 1970-01-01 00:00:00 +0000 |
1885 | +++ debian/patches/0001-Revert-Fix-the-session-is-shutdown-when-the-agent-ex.patch 2010-04-28 20:38:30 +0000 |
1886 | @@ -0,0 +1,50 @@ |
1887 | +diff -Nur -x '*.orig' -x '*~' obexd/client/session.c obexd.new/client/session.c |
1888 | +--- obexd/client/session.c 2010-04-26 21:41:26.362047000 +0200 |
1889 | ++++ obexd.new/client/session.c 2010-04-28 22:32:26.726018633 +0200 |
1890 | +@@ -588,6 +588,21 @@ |
1891 | + session_unref(session); |
1892 | + } |
1893 | + |
1894 | ++int session_set_agent(struct session_data *session, const char *name, |
1895 | ++ const char *path) |
1896 | ++{ |
1897 | ++ if (session == NULL) |
1898 | ++ return -EINVAL; |
1899 | ++ |
1900 | ++ if (session->agent_name != NULL || session->agent_path != NULL) |
1901 | ++ return -EALREADY; |
1902 | ++ |
1903 | ++ session->agent_name = g_strdup(name); |
1904 | ++ session->agent_path = g_strdup(path); |
1905 | ++ |
1906 | ++ return 0; |
1907 | ++} |
1908 | ++ |
1909 | + static void append_entry(DBusMessageIter *dict, |
1910 | + const char *key, int type, void *val) |
1911 | + { |
1912 | +@@ -1850,24 +1865,3 @@ |
1913 | + |
1914 | + return 0; |
1915 | + } |
1916 | +- |
1917 | +-int session_set_agent(struct session_data *session, const char *name, |
1918 | +- const char *path) |
1919 | +-{ |
1920 | +- if (session == NULL) |
1921 | +- return -EINVAL; |
1922 | +- |
1923 | +- if (session->agent_name != NULL || session->agent_path != NULL) |
1924 | +- return -EALREADY; |
1925 | +- |
1926 | +- session->agent_name = g_strdup(name); |
1927 | +- session->agent_path = g_strdup(path); |
1928 | +- |
1929 | +- session->owner_watch = g_dbus_add_disconnect_watch(session->conn, |
1930 | +- session->owner, owner_disconnected, |
1931 | +- session, NULL); |
1932 | +- |
1933 | +- session_ref(session); |
1934 | +- |
1935 | +- return 0; |
1936 | +-} |
1937 | |
1938 | === modified file 'doc/agent-api.txt' |
1939 | --- doc/agent-api.txt 2009-07-27 19:02:30 +0000 |
1940 | +++ doc/agent-api.txt 2010-04-28 20:38:30 +0000 |
1941 | @@ -1,9 +1,8 @@ |
1942 | obexd Agent API description |
1943 | ********************************** |
1944 | |
1945 | -Copyright (C) 2007-2008 Nokia Corporation |
1946 | -Copyright (C) 2007-2008 Instituto Nokia de Tecnologia (INdT) |
1947 | -Copyright (C) 2007-2008 Marcel Holtmann <marcel@holtmann.org> |
1948 | +Copyright (C) 2007-2010 Nokia Corporation |
1949 | +Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
1950 | |
1951 | |
1952 | Agent hierarchy |
1953 | |
1954 | === modified file 'doc/client-api.txt' |
1955 | --- doc/client-api.txt 2010-01-10 10:46:58 +0000 |
1956 | +++ doc/client-api.txt 2010-04-28 20:38:30 +0000 |
1957 | @@ -1,7 +1,7 @@ |
1958 | OBEX client API description |
1959 | *************************** |
1960 | |
1961 | -Copyright (C) 2007-2008 Marcel Holtmann <marcel@holtmann.org> |
1962 | +Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
1963 | |
1964 | |
1965 | Client hierarchy |
1966 | |
1967 | === modified file 'doc/obexd-api.txt' |
1968 | --- doc/obexd-api.txt 2009-07-27 19:02:30 +0000 |
1969 | +++ doc/obexd-api.txt 2010-04-28 20:38:30 +0000 |
1970 | @@ -1,9 +1,8 @@ |
1971 | obexd API description |
1972 | ********************************** |
1973 | |
1974 | -Copyright (C) 2007-2008 Nokia Corporation |
1975 | -Copyright (C) 2007-2008 Instituto Nokia de Tecnologia (INdT) |
1976 | -Copyright (C) 2007-2008 Marcel Holtmann <marcel@holtmann.org> |
1977 | +Copyright (C) 2007-2010 Nokia Corporation |
1978 | +Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
1979 | |
1980 | |
1981 | Manager hierarchy |
1982 | |
1983 | === modified file 'gdbus/gdbus.h' |
1984 | --- gdbus/gdbus.h 2010-01-10 10:46:58 +0000 |
1985 | +++ gdbus/gdbus.h 2010-04-28 20:38:30 +0000 |
1986 | @@ -2,7 +2,7 @@ |
1987 | * |
1988 | * D-Bus helper library |
1989 | * |
1990 | - * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> |
1991 | + * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> |
1992 | * |
1993 | * |
1994 | * This program is free software; you can redistribute it and/or modify |
1995 | @@ -40,6 +40,9 @@ |
1996 | DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name, |
1997 | DBusError *error); |
1998 | |
1999 | +DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name, |
2000 | + DBusError *error); |
2001 | + |
2002 | gboolean g_dbus_request_name(DBusConnection *connection, const char *name, |
2003 | DBusError *error); |
2004 | |
2005 | @@ -88,9 +91,9 @@ |
2006 | |
2007 | gboolean g_dbus_register_interface(DBusConnection *connection, |
2008 | const char *path, const char *name, |
2009 | - GDBusMethodTable *methods, |
2010 | - GDBusSignalTable *signals, |
2011 | - GDBusPropertyTable *properties, |
2012 | + const GDBusMethodTable *methods, |
2013 | + const GDBusSignalTable *signals, |
2014 | + const GDBusPropertyTable *properties, |
2015 | void *user_data, |
2016 | GDBusDestroyFunction destroy); |
2017 | gboolean g_dbus_unregister_interface(DBusConnection *connection, |
2018 | @@ -125,8 +128,10 @@ |
2019 | GDBusWatchFunction function, |
2020 | void *user_data, GDBusDestroyFunction destroy); |
2021 | guint g_dbus_add_signal_watch(DBusConnection *connection, |
2022 | - const char *rule, GDBusSignalFunction function, |
2023 | - void *user_data, GDBusDestroyFunction destroy); |
2024 | + const char *sender, const char *path, |
2025 | + const char *interface, const char *member, |
2026 | + GDBusSignalFunction function, void *user_data, |
2027 | + GDBusDestroyFunction destroy); |
2028 | gboolean g_dbus_remove_watch(DBusConnection *connection, guint tag); |
2029 | void g_dbus_remove_all_watches(DBusConnection *connection); |
2030 | |
2031 | |
2032 | === modified file 'gdbus/mainloop.c' |
2033 | --- gdbus/mainloop.c 2010-01-10 10:46:58 +0000 |
2034 | +++ gdbus/mainloop.c 2010-04-28 20:38:30 +0000 |
2035 | @@ -2,7 +2,7 @@ |
2036 | * |
2037 | * D-Bus helper library |
2038 | * |
2039 | - * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> |
2040 | + * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> |
2041 | * |
2042 | * |
2043 | * This program is free software; you can redistribute it and/or modify |
2044 | @@ -25,8 +25,6 @@ |
2045 | #include <config.h> |
2046 | #endif |
2047 | |
2048 | -#include <stdint.h> |
2049 | - |
2050 | #include <glib.h> |
2051 | #include <dbus/dbus.h> |
2052 | |
2053 | @@ -42,116 +40,131 @@ |
2054 | #define error(fmt...) |
2055 | #define debug(fmt...) |
2056 | |
2057 | -typedef struct { |
2058 | - uint32_t id; |
2059 | +struct timeout_handler { |
2060 | + guint id; |
2061 | DBusTimeout *timeout; |
2062 | -} timeout_handler_t; |
2063 | +}; |
2064 | |
2065 | struct watch_info { |
2066 | - guint watch_id; |
2067 | - GIOChannel *io; |
2068 | + guint id; |
2069 | + DBusWatch *watch; |
2070 | DBusConnection *conn; |
2071 | }; |
2072 | |
2073 | -struct server_info { |
2074 | - guint watch_id; |
2075 | - GIOChannel *io; |
2076 | - DBusServer *server; |
2077 | -}; |
2078 | - |
2079 | struct disconnect_data { |
2080 | - GDBusWatchFunction disconnect_cb; |
2081 | + GDBusWatchFunction function; |
2082 | void *user_data; |
2083 | }; |
2084 | |
2085 | -static DBusHandlerResult disconnect_filter(DBusConnection *conn, |
2086 | +static gboolean disconnected_signal(DBusConnection *conn, |
2087 | DBusMessage *msg, void *data) |
2088 | { |
2089 | struct disconnect_data *dc_data = data; |
2090 | |
2091 | - if (dbus_message_is_signal(msg, |
2092 | - DBUS_INTERFACE_LOCAL, "Disconnected") == TRUE) { |
2093 | - error("Got disconnected from the system message bus"); |
2094 | - dc_data->disconnect_cb(conn, dc_data->user_data); |
2095 | - dbus_connection_unref(conn); |
2096 | - } |
2097 | - |
2098 | - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
2099 | + error("Got disconnected from the system message bus"); |
2100 | + |
2101 | + dc_data->function(conn, dc_data->user_data); |
2102 | + |
2103 | + dbus_connection_unref(conn); |
2104 | + |
2105 | + return TRUE; |
2106 | } |
2107 | |
2108 | -static gboolean message_dispatch_cb(void *data) |
2109 | +static gboolean message_dispatch(void *data) |
2110 | { |
2111 | - DBusConnection *connection = data; |
2112 | + DBusConnection *conn = data; |
2113 | |
2114 | - dbus_connection_ref(connection); |
2115 | + dbus_connection_ref(conn); |
2116 | |
2117 | /* Dispatch messages */ |
2118 | - while (dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS); |
2119 | + while (dbus_connection_dispatch(conn) == DBUS_DISPATCH_DATA_REMAINS); |
2120 | |
2121 | - dbus_connection_unref(connection); |
2122 | + dbus_connection_unref(conn); |
2123 | |
2124 | return FALSE; |
2125 | } |
2126 | |
2127 | +static inline void queue_dispatch(DBusConnection *conn, |
2128 | + DBusDispatchStatus status) |
2129 | +{ |
2130 | + if (status == DBUS_DISPATCH_DATA_REMAINS) |
2131 | + g_timeout_add(DISPATCH_TIMEOUT, message_dispatch, conn); |
2132 | +} |
2133 | + |
2134 | static gboolean watch_func(GIOChannel *chan, GIOCondition cond, gpointer data) |
2135 | { |
2136 | - DBusWatch *watch = data; |
2137 | - struct watch_info *info = dbus_watch_get_data(watch); |
2138 | - int flags = 0; |
2139 | + struct watch_info *info = data; |
2140 | + unsigned int flags = 0; |
2141 | + |
2142 | + dbus_connection_ref(info->conn); |
2143 | |
2144 | if (cond & G_IO_IN) flags |= DBUS_WATCH_READABLE; |
2145 | if (cond & G_IO_OUT) flags |= DBUS_WATCH_WRITABLE; |
2146 | if (cond & G_IO_HUP) flags |= DBUS_WATCH_HANGUP; |
2147 | if (cond & G_IO_ERR) flags |= DBUS_WATCH_ERROR; |
2148 | |
2149 | - dbus_watch_handle(watch, flags); |
2150 | + dbus_watch_handle(info->watch, flags); |
2151 | |
2152 | - if (dbus_connection_get_dispatch_status(info->conn) == DBUS_DISPATCH_DATA_REMAINS) |
2153 | - g_timeout_add(DISPATCH_TIMEOUT, message_dispatch_cb, info->conn); |
2154 | + dbus_connection_unref(info->conn); |
2155 | |
2156 | return TRUE; |
2157 | } |
2158 | |
2159 | +static void watch_info_free(void *data) |
2160 | +{ |
2161 | + struct watch_info *info = data; |
2162 | + |
2163 | + if (info->id > 0) { |
2164 | + g_source_remove(info->id); |
2165 | + info->id = 0; |
2166 | + } |
2167 | + |
2168 | + dbus_connection_unref(info->conn); |
2169 | + |
2170 | + g_free(info); |
2171 | +} |
2172 | + |
2173 | static dbus_bool_t add_watch(DBusWatch *watch, void *data) |
2174 | { |
2175 | + DBusConnection *conn = data; |
2176 | GIOCondition cond = G_IO_HUP | G_IO_ERR; |
2177 | - DBusConnection *conn = data; |
2178 | + GIOChannel *chan; |
2179 | struct watch_info *info; |
2180 | - int fd, flags; |
2181 | + unsigned int flags; |
2182 | + int fd; |
2183 | |
2184 | if (!dbus_watch_get_enabled(watch)) |
2185 | return TRUE; |
2186 | |
2187 | - info = g_new(struct watch_info, 1); |
2188 | + info = g_new0(struct watch_info, 1); |
2189 | |
2190 | fd = dbus_watch_get_unix_fd(watch); |
2191 | - info->io = g_io_channel_unix_new(fd); |
2192 | + chan = g_io_channel_unix_new(fd); |
2193 | + |
2194 | + info->watch = watch; |
2195 | info->conn = dbus_connection_ref(conn); |
2196 | |
2197 | - dbus_watch_set_data(watch, info, NULL); |
2198 | + dbus_watch_set_data(watch, info, watch_info_free); |
2199 | |
2200 | flags = dbus_watch_get_flags(watch); |
2201 | |
2202 | if (flags & DBUS_WATCH_READABLE) cond |= G_IO_IN; |
2203 | if (flags & DBUS_WATCH_WRITABLE) cond |= G_IO_OUT; |
2204 | |
2205 | - info->watch_id = g_io_add_watch(info->io, cond, watch_func, watch); |
2206 | + info->id = g_io_add_watch(chan, cond, watch_func, info); |
2207 | + |
2208 | + g_io_channel_unref(chan); |
2209 | |
2210 | return TRUE; |
2211 | } |
2212 | |
2213 | static void remove_watch(DBusWatch *watch, void *data) |
2214 | { |
2215 | - struct watch_info *info = dbus_watch_get_data(watch); |
2216 | + if (dbus_watch_get_enabled(watch)) |
2217 | + return; |
2218 | |
2219 | + /* will trigger watch_info_free() */ |
2220 | dbus_watch_set_data(watch, NULL, NULL); |
2221 | - |
2222 | - if (info) { |
2223 | - g_source_remove(info->watch_id); |
2224 | - g_io_channel_unref(info->io); |
2225 | - dbus_connection_unref(info->conn); |
2226 | - g_free(info); |
2227 | - } |
2228 | } |
2229 | |
2230 | static void watch_toggled(DBusWatch *watch, void *data) |
2231 | @@ -166,10 +179,12 @@ |
2232 | |
2233 | static gboolean timeout_handler_dispatch(gpointer data) |
2234 | { |
2235 | - timeout_handler_t *handler = data; |
2236 | + struct timeout_handler *handler = data; |
2237 | + |
2238 | + handler->id = 0; |
2239 | |
2240 | /* if not enabled should not be polled by the main loop */ |
2241 | - if (dbus_timeout_get_enabled(handler->timeout) != TRUE) |
2242 | + if (!dbus_timeout_get_enabled(handler->timeout)) |
2243 | return FALSE; |
2244 | |
2245 | dbus_timeout_handle(handler->timeout); |
2246 | @@ -179,9 +194,7 @@ |
2247 | |
2248 | static void timeout_handler_free(void *data) |
2249 | { |
2250 | - timeout_handler_t *handler = data; |
2251 | - if (!handler) |
2252 | - return; |
2253 | + struct timeout_handler *handler = data; |
2254 | |
2255 | if (handler->id > 0) { |
2256 | g_source_remove(handler->id); |
2257 | @@ -193,35 +206,31 @@ |
2258 | |
2259 | static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data) |
2260 | { |
2261 | - timeout_handler_t *handler; |
2262 | + int interval = dbus_timeout_get_interval(timeout); |
2263 | + struct timeout_handler *handler; |
2264 | |
2265 | if (!dbus_timeout_get_enabled(timeout)) |
2266 | return TRUE; |
2267 | |
2268 | - handler = g_new0(timeout_handler_t, 1); |
2269 | + handler = g_new0(struct timeout_handler, 1); |
2270 | |
2271 | handler->timeout = timeout; |
2272 | - handler->id = g_timeout_add(dbus_timeout_get_interval(timeout), |
2273 | - timeout_handler_dispatch, handler); |
2274 | |
2275 | dbus_timeout_set_data(timeout, handler, timeout_handler_free); |
2276 | |
2277 | + handler->id = g_timeout_add(interval, timeout_handler_dispatch, |
2278 | + handler); |
2279 | + |
2280 | return TRUE; |
2281 | } |
2282 | |
2283 | static void remove_timeout(DBusTimeout *timeout, void *data) |
2284 | { |
2285 | - timeout_handler_t *handler; |
2286 | - |
2287 | - handler = dbus_timeout_get_data(timeout); |
2288 | - |
2289 | - if (!handler) |
2290 | - return; |
2291 | - |
2292 | - if (handler->id > 0) { |
2293 | - g_source_remove(handler->id); |
2294 | - handler->id = 0; |
2295 | - } |
2296 | + if (dbus_timeout_get_enabled(timeout)) |
2297 | + return; |
2298 | + |
2299 | + /* will trigger timeout_handler_free() */ |
2300 | + dbus_timeout_set_data(timeout, NULL, NULL); |
2301 | } |
2302 | |
2303 | static void timeout_toggled(DBusTimeout *timeout, void *data) |
2304 | @@ -232,63 +241,95 @@ |
2305 | remove_timeout(timeout, data); |
2306 | } |
2307 | |
2308 | -static void dispatch_status_cb(DBusConnection *conn, |
2309 | - DBusDispatchStatus new_status, void *data) |
2310 | +static void dispatch_status(DBusConnection *conn, |
2311 | + DBusDispatchStatus status, void *data) |
2312 | { |
2313 | if (!dbus_connection_get_is_connected(conn)) |
2314 | return; |
2315 | |
2316 | - if (new_status == DBUS_DISPATCH_DATA_REMAINS) |
2317 | - g_timeout_add(DISPATCH_TIMEOUT, message_dispatch_cb, data); |
2318 | + queue_dispatch(conn, status); |
2319 | } |
2320 | |
2321 | -static void setup_dbus_with_main_loop(DBusConnection *conn) |
2322 | +static inline void setup_dbus_with_main_loop(DBusConnection *conn) |
2323 | { |
2324 | dbus_connection_set_watch_functions(conn, add_watch, remove_watch, |
2325 | watch_toggled, conn, NULL); |
2326 | |
2327 | dbus_connection_set_timeout_functions(conn, add_timeout, remove_timeout, |
2328 | - timeout_toggled, conn, NULL); |
2329 | + timeout_toggled, NULL, NULL); |
2330 | |
2331 | - dbus_connection_set_dispatch_status_function(conn, dispatch_status_cb, |
2332 | - conn, NULL); |
2333 | + dbus_connection_set_dispatch_status_function(conn, dispatch_status, |
2334 | + NULL, NULL); |
2335 | } |
2336 | |
2337 | -DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name, |
2338 | - DBusError *error) |
2339 | +static gboolean setup_bus(DBusConnection *conn, const char *name, |
2340 | + DBusError *error) |
2341 | { |
2342 | - DBusConnection *conn; |
2343 | - |
2344 | - conn = dbus_bus_get(type, error); |
2345 | - |
2346 | - if (error != NULL) { |
2347 | - if (dbus_error_is_set(error) == TRUE) |
2348 | - return NULL; |
2349 | - } |
2350 | - |
2351 | - if (conn == NULL) |
2352 | - return NULL; |
2353 | + gboolean result; |
2354 | + DBusDispatchStatus status; |
2355 | |
2356 | if (name != NULL) { |
2357 | - if (dbus_bus_request_name(conn, name, |
2358 | - DBUS_NAME_FLAG_DO_NOT_QUEUE, error) != |
2359 | - DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER ) { |
2360 | - dbus_connection_unref(conn); |
2361 | - return NULL; |
2362 | - } |
2363 | + result = g_dbus_request_name(conn, name, error); |
2364 | |
2365 | if (error != NULL) { |
2366 | - if (dbus_error_is_set(error) == TRUE) { |
2367 | - dbus_connection_unref(conn); |
2368 | - return NULL; |
2369 | - } |
2370 | + if (dbus_error_is_set(error) == TRUE) |
2371 | + return FALSE; |
2372 | } |
2373 | + |
2374 | + if (result == FALSE) |
2375 | + return FALSE; |
2376 | } |
2377 | |
2378 | setup_dbus_with_main_loop(conn); |
2379 | |
2380 | - if (dbus_connection_get_dispatch_status(conn) == DBUS_DISPATCH_DATA_REMAINS) |
2381 | - g_timeout_add(DISPATCH_TIMEOUT, message_dispatch_cb, conn); |
2382 | + status = dbus_connection_get_dispatch_status(conn); |
2383 | + queue_dispatch(conn, status); |
2384 | + |
2385 | + return TRUE; |
2386 | +} |
2387 | + |
2388 | +DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name, |
2389 | + DBusError *error) |
2390 | +{ |
2391 | + DBusConnection *conn; |
2392 | + |
2393 | + conn = dbus_bus_get(type, error); |
2394 | + |
2395 | + if (error != NULL) { |
2396 | + if (dbus_error_is_set(error) == TRUE) |
2397 | + return NULL; |
2398 | + } |
2399 | + |
2400 | + if (conn == NULL) |
2401 | + return NULL; |
2402 | + |
2403 | + if (setup_bus(conn, name, error) == FALSE) { |
2404 | + dbus_connection_unref(conn); |
2405 | + return NULL; |
2406 | + } |
2407 | + |
2408 | + return conn; |
2409 | +} |
2410 | + |
2411 | +DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name, |
2412 | + DBusError *error) |
2413 | +{ |
2414 | + DBusConnection *conn; |
2415 | + |
2416 | + conn = dbus_bus_get_private(type, error); |
2417 | + |
2418 | + if (error != NULL) { |
2419 | + if (dbus_error_is_set(error) == TRUE) |
2420 | + return NULL; |
2421 | + } |
2422 | + |
2423 | + if (conn == NULL) |
2424 | + return NULL; |
2425 | + |
2426 | + if (setup_bus(conn, name, error) == FALSE) { |
2427 | + dbus_connection_unref(conn); |
2428 | + return NULL; |
2429 | + } |
2430 | |
2431 | return conn; |
2432 | } |
2433 | @@ -296,6 +337,23 @@ |
2434 | gboolean g_dbus_request_name(DBusConnection *connection, const char *name, |
2435 | DBusError *error) |
2436 | { |
2437 | + int result; |
2438 | + |
2439 | + result = dbus_bus_request_name(connection, name, |
2440 | + DBUS_NAME_FLAG_DO_NOT_QUEUE, error); |
2441 | + |
2442 | + if (error != NULL) { |
2443 | + if (dbus_error_is_set(error) == TRUE) |
2444 | + return FALSE; |
2445 | + } |
2446 | + |
2447 | + if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { |
2448 | + if (error != NULL) |
2449 | + dbus_set_error(error, name, "Name already in use"); |
2450 | + |
2451 | + return FALSE; |
2452 | + } |
2453 | + |
2454 | return TRUE; |
2455 | } |
2456 | |
2457 | @@ -305,16 +363,17 @@ |
2458 | { |
2459 | struct disconnect_data *dc_data; |
2460 | |
2461 | - dc_data = g_new(struct disconnect_data, 1); |
2462 | + dc_data = g_new0(struct disconnect_data, 1); |
2463 | |
2464 | - dc_data->disconnect_cb = function; |
2465 | + dc_data->function = function; |
2466 | dc_data->user_data = user_data; |
2467 | |
2468 | dbus_connection_set_exit_on_disconnect(connection, FALSE); |
2469 | |
2470 | - if (dbus_connection_add_filter(connection, disconnect_filter, |
2471 | - dc_data, g_free) == FALSE) { |
2472 | - error("Can't add D-Bus disconnect filter"); |
2473 | + if (g_dbus_add_signal_watch(connection, NULL, NULL, |
2474 | + DBUS_INTERFACE_LOCAL, "Disconnected", |
2475 | + disconnected_signal, dc_data, g_free) == 0) { |
2476 | + error("Failed to add watch for D-Bus Disconnected signal"); |
2477 | g_free(dc_data); |
2478 | return FALSE; |
2479 | } |
2480 | |
2481 | === modified file 'gdbus/object.c' |
2482 | --- gdbus/object.c 2010-01-10 10:46:58 +0000 |
2483 | +++ gdbus/object.c 2010-04-28 20:38:30 +0000 |
2484 | @@ -2,7 +2,7 @@ |
2485 | * |
2486 | * D-Bus helper library |
2487 | * |
2488 | - * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> |
2489 | + * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> |
2490 | * |
2491 | * |
2492 | * This program is free software; you can redistribute it and/or modify |
2493 | @@ -45,9 +45,9 @@ |
2494 | |
2495 | struct interface_data { |
2496 | char *name; |
2497 | - GDBusMethodTable *methods; |
2498 | - GDBusSignalTable *signals; |
2499 | - GDBusPropertyTable *properties; |
2500 | + const GDBusMethodTable *methods; |
2501 | + const GDBusSignalTable *signals; |
2502 | + const GDBusPropertyTable *properties; |
2503 | void *user_data; |
2504 | GDBusDestroyFunction destroy; |
2505 | }; |
2506 | @@ -114,8 +114,8 @@ |
2507 | |
2508 | static void generate_interface_xml(GString *gstr, struct interface_data *iface) |
2509 | { |
2510 | - GDBusMethodTable *method; |
2511 | - GDBusSignalTable *signal; |
2512 | + const GDBusMethodTable *method; |
2513 | + const GDBusSignalTable *signal; |
2514 | |
2515 | for (method = iface->methods; method && method->name; method++) { |
2516 | if (!strlen(method->signature) && !strlen(method->reply)) |
2517 | @@ -238,7 +238,7 @@ |
2518 | { |
2519 | struct generic_data *data = user_data; |
2520 | struct interface_data *iface; |
2521 | - GDBusMethodTable *method; |
2522 | + const GDBusMethodTable *method; |
2523 | const char *interface; |
2524 | |
2525 | interface = dbus_message_get_interface(message); |
2526 | @@ -327,9 +327,9 @@ |
2527 | }; |
2528 | |
2529 | static void add_interface(struct generic_data *data, const char *name, |
2530 | - GDBusMethodTable *methods, |
2531 | - GDBusSignalTable *signals, |
2532 | - GDBusPropertyTable *properties, |
2533 | + const GDBusMethodTable *methods, |
2534 | + const GDBusSignalTable *signals, |
2535 | + const GDBusPropertyTable *properties, |
2536 | void *user_data, |
2537 | GDBusDestroyFunction destroy) |
2538 | { |
2539 | @@ -428,7 +428,7 @@ |
2540 | { |
2541 | struct generic_data *data = NULL; |
2542 | struct interface_data *iface; |
2543 | - GDBusSignalTable *signal; |
2544 | + const GDBusSignalTable *signal; |
2545 | |
2546 | *args = NULL; |
2547 | if (!dbus_connection_get_object_path_data(conn, path, |
2548 | @@ -502,9 +502,9 @@ |
2549 | |
2550 | gboolean g_dbus_register_interface(DBusConnection *connection, |
2551 | const char *path, const char *name, |
2552 | - GDBusMethodTable *methods, |
2553 | - GDBusSignalTable *signals, |
2554 | - GDBusPropertyTable *properties, |
2555 | + const GDBusMethodTable *methods, |
2556 | + const GDBusSignalTable *signals, |
2557 | + const GDBusPropertyTable *properties, |
2558 | void *user_data, |
2559 | GDBusDestroyFunction destroy) |
2560 | { |
2561 | |
2562 | === modified file 'gdbus/watch.c' |
2563 | --- gdbus/watch.c 2010-01-10 10:46:58 +0000 |
2564 | +++ gdbus/watch.c 2010-04-28 20:38:30 +0000 |
2565 | @@ -2,7 +2,7 @@ |
2566 | * |
2567 | * D-Bus helper library |
2568 | * |
2569 | - * Copyright (C) 2004-2009 Marcel Holtmann <marcel@holtmann.org> |
2570 | + * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> |
2571 | * |
2572 | * |
2573 | * This program is free software; you can redistribute it and/or modify |
2574 | @@ -37,212 +37,335 @@ |
2575 | #define error(fmt...) |
2576 | #define debug(fmt...) |
2577 | |
2578 | -static DBusHandlerResult name_exit_filter(DBusConnection *connection, |
2579 | +static DBusHandlerResult message_filter(DBusConnection *connection, |
2580 | DBusMessage *message, void *user_data); |
2581 | |
2582 | static guint listener_id = 0; |
2583 | -static GSList *name_listeners = NULL; |
2584 | +static GSList *listeners = NULL; |
2585 | |
2586 | -struct name_callback { |
2587 | +struct filter_callback { |
2588 | GDBusWatchFunction conn_func; |
2589 | GDBusWatchFunction disc_func; |
2590 | + GDBusSignalFunction signal_func; |
2591 | + GDBusDestroyFunction destroy_func; |
2592 | void *user_data; |
2593 | guint id; |
2594 | }; |
2595 | |
2596 | -struct name_data { |
2597 | +struct filter_data { |
2598 | DBusConnection *connection; |
2599 | - char *name; |
2600 | + DBusHandleMessageFunction handle_func; |
2601 | + char *sender; |
2602 | + char *path; |
2603 | + char *interface; |
2604 | + char *member; |
2605 | + char *argument; |
2606 | GSList *callbacks; |
2607 | GSList *processed; |
2608 | gboolean lock; |
2609 | + gboolean registered; |
2610 | }; |
2611 | |
2612 | -static struct name_data *name_data_find(DBusConnection *connection, |
2613 | - const char *name) |
2614 | +static struct filter_data *filter_data_find(DBusConnection *connection, |
2615 | + const char *sender, |
2616 | + const char *path, |
2617 | + const char *interface, |
2618 | + const char *member, |
2619 | + const char *argument) |
2620 | { |
2621 | GSList *current; |
2622 | |
2623 | - for (current = name_listeners; |
2624 | + for (current = listeners; |
2625 | current != NULL; current = current->next) { |
2626 | - struct name_data *data = current->data; |
2627 | + struct filter_data *data = current->data; |
2628 | |
2629 | if (connection != data->connection) |
2630 | continue; |
2631 | |
2632 | - if (name == NULL || g_str_equal(name, data->name)) |
2633 | - return data; |
2634 | - } |
2635 | - |
2636 | - return NULL; |
2637 | -} |
2638 | - |
2639 | -static struct name_callback *name_callback_find(GSList *callbacks, guint id) |
2640 | -{ |
2641 | - GSList *current; |
2642 | - |
2643 | - for (current = callbacks; current != NULL; current = current->next) { |
2644 | - struct name_callback *cb = current->data; |
2645 | - if (cb->id == id) |
2646 | - return cb; |
2647 | - } |
2648 | - |
2649 | - return NULL; |
2650 | -} |
2651 | - |
2652 | -static void name_data_call_and_free(struct name_data *data) |
2653 | + if (sender && data->sender && |
2654 | + g_str_equal(sender, data->sender) == FALSE) |
2655 | + continue; |
2656 | + |
2657 | + if (path && data->path && |
2658 | + g_str_equal(path, data->path) == FALSE) |
2659 | + continue; |
2660 | + |
2661 | + if (interface && data->interface && |
2662 | + g_str_equal(interface, data->interface) == FALSE) |
2663 | + continue; |
2664 | + |
2665 | + if (member && data->member && |
2666 | + g_str_equal(member, data->member) == FALSE) |
2667 | + continue; |
2668 | + |
2669 | + if (argument && data->argument && |
2670 | + g_str_equal(argument, data->argument) == FALSE) |
2671 | + continue; |
2672 | + |
2673 | + return data; |
2674 | + } |
2675 | + |
2676 | + return NULL; |
2677 | +} |
2678 | + |
2679 | +static void format_rule(struct filter_data *data, char *rule, size_t size) |
2680 | +{ |
2681 | + int offset; |
2682 | + |
2683 | + offset = snprintf(rule, size, "type='signal'"); |
2684 | + |
2685 | + if (data->sender) |
2686 | + offset += snprintf(rule + offset, size - offset, |
2687 | + ",sender='%s'", data->sender); |
2688 | + if (data->path) |
2689 | + offset += snprintf(rule + offset, size - offset, |
2690 | + ",path='%s'", data->path); |
2691 | + if (data->interface) |
2692 | + offset += snprintf(rule + offset, size - offset, |
2693 | + ",interface='%s'", data->interface); |
2694 | + if (data->member) |
2695 | + offset += snprintf(rule + offset, size - offset, |
2696 | + ",member='%s'", data->member); |
2697 | + if (data->argument) |
2698 | + snprintf(rule + offset, size - offset, |
2699 | + ",arg0='%s'", data->argument); |
2700 | +} |
2701 | + |
2702 | +static gboolean add_match(struct filter_data *data, |
2703 | + DBusHandleMessageFunction filter) |
2704 | +{ |
2705 | + DBusError err; |
2706 | + char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; |
2707 | + |
2708 | + format_rule(data, rule, sizeof(rule)); |
2709 | + dbus_error_init(&err); |
2710 | + |
2711 | + dbus_bus_add_match(data->connection, rule, &err); |
2712 | + if (dbus_error_is_set(&err)) { |
2713 | + error("Adding match rule \"%s\" failed: %s", rule, |
2714 | + err.message); |
2715 | + dbus_error_free(&err); |
2716 | + return FALSE; |
2717 | + } |
2718 | + |
2719 | + data->handle_func = filter; |
2720 | + data->registered = TRUE; |
2721 | + |
2722 | + return TRUE; |
2723 | +} |
2724 | + |
2725 | +static gboolean remove_match(struct filter_data *data) |
2726 | +{ |
2727 | + DBusError err; |
2728 | + char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; |
2729 | + |
2730 | + format_rule(data, rule, sizeof(rule)); |
2731 | + |
2732 | + dbus_error_init(&err); |
2733 | + |
2734 | + dbus_bus_remove_match(data->connection, rule, &err); |
2735 | + if (dbus_error_is_set(&err)) { |
2736 | + error("Removing owner match rule for %s failed: %s", |
2737 | + rule, err.message); |
2738 | + dbus_error_free(&err); |
2739 | + return FALSE; |
2740 | + } |
2741 | + |
2742 | + return TRUE; |
2743 | +} |
2744 | + |
2745 | +static struct filter_data *filter_data_get(DBusConnection *connection, |
2746 | + DBusHandleMessageFunction filter, |
2747 | + const char *sender, |
2748 | + const char *path, |
2749 | + const char *interface, |
2750 | + const char *member, |
2751 | + const char *argument) |
2752 | +{ |
2753 | + struct filter_data *data; |
2754 | + |
2755 | + if (!filter_data_find(connection, NULL, NULL, NULL, NULL, NULL)) { |
2756 | + if (!dbus_connection_add_filter(connection, |
2757 | + message_filter, NULL, NULL)) { |
2758 | + error("dbus_connection_add_filter() failed"); |
2759 | + return NULL; |
2760 | + } |
2761 | + } |
2762 | + |
2763 | + data = filter_data_find(connection, sender, path, interface, member, |
2764 | + argument); |
2765 | + if (data) |
2766 | + return data; |
2767 | + |
2768 | + data = g_new0(struct filter_data, 1); |
2769 | + |
2770 | + data->connection = dbus_connection_ref(connection); |
2771 | + data->sender = g_strdup(sender); |
2772 | + data->path = g_strdup(path); |
2773 | + data->interface = g_strdup(interface); |
2774 | + data->member = g_strdup(member); |
2775 | + data->argument = g_strdup(argument); |
2776 | + |
2777 | + if (!add_match(data, filter)) { |
2778 | + g_free(data); |
2779 | + return NULL; |
2780 | + } |
2781 | + |
2782 | + listeners = g_slist_append(listeners, data); |
2783 | + |
2784 | + return data; |
2785 | +} |
2786 | + |
2787 | +static struct filter_callback *filter_data_find_callback( |
2788 | + struct filter_data *data, |
2789 | + guint id) |
2790 | +{ |
2791 | + GSList *l; |
2792 | + |
2793 | + for (l = data->callbacks; l; l = l->next) { |
2794 | + struct filter_callback *cb = l->data; |
2795 | + if (cb->id == id) |
2796 | + return cb; |
2797 | + } |
2798 | + for (l = data->processed; l; l = l->next) { |
2799 | + struct filter_callback *cb = l->data; |
2800 | + if (cb->id == id) |
2801 | + return cb; |
2802 | + } |
2803 | + |
2804 | + return NULL; |
2805 | +} |
2806 | + |
2807 | +static void filter_data_free(struct filter_data *data) |
2808 | +{ |
2809 | + GSList *l; |
2810 | + |
2811 | + for (l = data->callbacks; l != NULL; l = l->next) |
2812 | + g_free(l->data); |
2813 | + |
2814 | + g_slist_free(data->callbacks); |
2815 | + g_free(data->sender); |
2816 | + g_free(data->path); |
2817 | + g_free(data->interface); |
2818 | + g_free(data->member); |
2819 | + g_free(data->argument); |
2820 | + dbus_connection_unref(data->connection); |
2821 | + g_free(data); |
2822 | +} |
2823 | + |
2824 | +static void filter_data_call_and_free(struct filter_data *data) |
2825 | { |
2826 | GSList *l; |
2827 | |
2828 | for (l = data->callbacks; l != NULL; l = l->next) { |
2829 | - struct name_callback *cb = l->data; |
2830 | + struct filter_callback *cb = l->data; |
2831 | if (cb->disc_func) |
2832 | cb->disc_func(data->connection, cb->user_data); |
2833 | + if (cb->destroy_func) |
2834 | + cb->destroy_func(cb->user_data); |
2835 | g_free(cb); |
2836 | } |
2837 | |
2838 | - g_slist_free(data->callbacks); |
2839 | - g_free(data->name); |
2840 | - g_free(data); |
2841 | -} |
2842 | - |
2843 | -static void name_data_free(struct name_data *data) |
2844 | -{ |
2845 | - GSList *l; |
2846 | - |
2847 | - for (l = data->callbacks; l != NULL; l = l->next) |
2848 | - g_free(l->data); |
2849 | - |
2850 | - g_slist_free(data->callbacks); |
2851 | - g_free(data->name); |
2852 | - g_free(data); |
2853 | -} |
2854 | - |
2855 | -static int name_data_add(DBusConnection *connection, const char *name, |
2856 | + filter_data_free(data); |
2857 | +} |
2858 | + |
2859 | +static struct filter_callback *filter_data_add_callback( |
2860 | + struct filter_data *data, |
2861 | GDBusWatchFunction connect, |
2862 | GDBusWatchFunction disconnect, |
2863 | - void *user_data, guint id) |
2864 | + GDBusSignalFunction signal, |
2865 | + GDBusDestroyFunction destroy, |
2866 | + void *user_data) |
2867 | { |
2868 | - int first = 1; |
2869 | - struct name_data *data = NULL; |
2870 | - struct name_callback *cb = NULL; |
2871 | + struct filter_callback *cb = NULL; |
2872 | |
2873 | - cb = g_new(struct name_callback, 1); |
2874 | + cb = g_new(struct filter_callback, 1); |
2875 | |
2876 | cb->conn_func = connect; |
2877 | cb->disc_func = disconnect; |
2878 | + cb->signal_func = signal; |
2879 | + cb->destroy_func = destroy; |
2880 | cb->user_data = user_data; |
2881 | - cb->id = id; |
2882 | - |
2883 | - data = name_data_find(connection, name); |
2884 | - if (data) { |
2885 | - first = 0; |
2886 | - goto done; |
2887 | - } |
2888 | - |
2889 | - data = g_new0(struct name_data, 1); |
2890 | - |
2891 | - data->connection = connection; |
2892 | - data->name = g_strdup(name); |
2893 | - |
2894 | - name_listeners = g_slist_append(name_listeners, data); |
2895 | - |
2896 | -done: |
2897 | + cb->id = ++listener_id; |
2898 | + |
2899 | if (data->lock) |
2900 | data->processed = g_slist_append(data->processed, cb); |
2901 | else |
2902 | data->callbacks = g_slist_append(data->callbacks, cb); |
2903 | |
2904 | - return first; |
2905 | + return cb; |
2906 | } |
2907 | |
2908 | -static void name_data_remove(DBusConnection *connection, |
2909 | - const char *name, guint id) |
2910 | +static gboolean filter_data_remove_callback(struct filter_data *data, |
2911 | + struct filter_callback *cb) |
2912 | { |
2913 | - struct name_data *data; |
2914 | - struct name_callback *cb = NULL; |
2915 | - |
2916 | - data = name_data_find(connection, name); |
2917 | - if (!data) |
2918 | - return; |
2919 | - |
2920 | - cb = name_callback_find(data->callbacks, id); |
2921 | - if (cb) { |
2922 | - data->callbacks = g_slist_remove(data->callbacks, cb); |
2923 | - g_free(cb); |
2924 | - } |
2925 | - |
2926 | - if (data->callbacks) |
2927 | - return; |
2928 | - |
2929 | - name_listeners = g_slist_remove(name_listeners, data); |
2930 | - name_data_free(data); |
2931 | + DBusConnection *connection; |
2932 | + |
2933 | + data->callbacks = g_slist_remove(data->callbacks, cb); |
2934 | + data->processed = g_slist_remove(data->processed, cb); |
2935 | + |
2936 | + if (cb->destroy_func) |
2937 | + cb->destroy_func(cb->user_data); |
2938 | + |
2939 | + g_free(cb); |
2940 | + |
2941 | + /* Don't remove the filter if other callbacks exist or data is lock |
2942 | + * processing callbacks */ |
2943 | + if (data->callbacks || data->lock) |
2944 | + return TRUE; |
2945 | + |
2946 | + if (data->registered && !remove_match(data)) |
2947 | + return FALSE; |
2948 | + |
2949 | + connection = dbus_connection_ref(data->connection); |
2950 | + listeners = g_slist_remove(listeners, data); |
2951 | + filter_data_free(data); |
2952 | |
2953 | /* Remove filter if there are no listeners left for the connection */ |
2954 | - data = name_data_find(connection, NULL); |
2955 | + data = filter_data_find(connection, NULL, NULL, NULL, NULL, NULL); |
2956 | if (!data) |
2957 | - dbus_connection_remove_filter(connection, |
2958 | - name_exit_filter, |
2959 | + dbus_connection_remove_filter(connection, message_filter, |
2960 | NULL); |
2961 | -} |
2962 | - |
2963 | -static gboolean add_match(DBusConnection *connection, const char *name) |
2964 | -{ |
2965 | - DBusError err; |
2966 | - char match_string[128]; |
2967 | - |
2968 | - snprintf(match_string, sizeof(match_string), |
2969 | - "interface=%s,member=NameOwnerChanged,arg0=%s", |
2970 | - DBUS_INTERFACE_DBUS, name); |
2971 | - |
2972 | - dbus_error_init(&err); |
2973 | - |
2974 | - dbus_bus_add_match(connection, match_string, &err); |
2975 | - |
2976 | - if (dbus_error_is_set(&err)) { |
2977 | - error("Adding match rule \"%s\" failed: %s", match_string, |
2978 | - err.message); |
2979 | - dbus_error_free(&err); |
2980 | - return FALSE; |
2981 | - } |
2982 | - |
2983 | - return TRUE; |
2984 | -} |
2985 | - |
2986 | -static gboolean remove_match(DBusConnection *connection, const char *name) |
2987 | -{ |
2988 | - DBusError err; |
2989 | - char match_string[128]; |
2990 | - |
2991 | - snprintf(match_string, sizeof(match_string), |
2992 | - "interface=%s,member=NameOwnerChanged,arg0=%s", |
2993 | - DBUS_INTERFACE_DBUS, name); |
2994 | - |
2995 | - dbus_error_init(&err); |
2996 | - |
2997 | - dbus_bus_remove_match(connection, match_string, &err); |
2998 | - |
2999 | - if (dbus_error_is_set(&err)) { |
3000 | - error("Removing owner match rule for %s failed: %s", |
3001 | - name, err.message); |
3002 | - dbus_error_free(&err); |
3003 | - return FALSE; |
3004 | - } |
3005 | - |
3006 | - return TRUE; |
3007 | -} |
3008 | - |
3009 | -static DBusHandlerResult name_exit_filter(DBusConnection *connection, |
3010 | - DBusMessage *message, void *user_data) |
3011 | -{ |
3012 | - struct name_data *data; |
3013 | - struct name_callback *cb; |
3014 | + |
3015 | + dbus_connection_unref(connection); |
3016 | + |
3017 | + return TRUE; |
3018 | +} |
3019 | + |
3020 | +static DBusHandlerResult signal_filter(DBusConnection *connection, |
3021 | + DBusMessage *message, void *user_data) |
3022 | +{ |
3023 | + struct filter_data *data = user_data; |
3024 | + struct filter_callback *cb; |
3025 | + |
3026 | + while (data->callbacks) { |
3027 | + cb = data->callbacks->data; |
3028 | + |
3029 | + if (cb->signal_func && !cb->signal_func(connection, message, |
3030 | + cb->user_data)) { |
3031 | + filter_data_remove_callback(data, cb); |
3032 | + continue; |
3033 | + } |
3034 | + |
3035 | + /* Check if the watch was removed/freed by the callback |
3036 | + * function */ |
3037 | + if (!g_slist_find(data->callbacks, cb)) |
3038 | + continue; |
3039 | + |
3040 | + data->callbacks = g_slist_remove(data->callbacks, cb); |
3041 | + data->processed = g_slist_append(data->processed, cb); |
3042 | + } |
3043 | + |
3044 | + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
3045 | +} |
3046 | + |
3047 | +static DBusHandlerResult service_filter(DBusConnection *connection, |
3048 | + DBusMessage *message, void *user_data) |
3049 | +{ |
3050 | + struct filter_data *data = user_data; |
3051 | + struct filter_callback *cb; |
3052 | char *name, *old, *new; |
3053 | |
3054 | - if (!dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, |
3055 | - "NameOwnerChanged")) |
3056 | - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
3057 | - |
3058 | if (!dbus_message_get_args(message, NULL, |
3059 | DBUS_TYPE_STRING, &name, |
3060 | DBUS_TYPE_STRING, &old, |
3061 | @@ -252,14 +375,6 @@ |
3062 | return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
3063 | } |
3064 | |
3065 | - data = name_data_find(connection, name); |
3066 | - if (!data) { |
3067 | - error("Got NameOwnerChanged signal for %s which has no listeners", name); |
3068 | - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
3069 | - } |
3070 | - |
3071 | - data->lock = TRUE; |
3072 | - |
3073 | while (data->callbacks) { |
3074 | cb = data->callbacks->data; |
3075 | |
3076 | @@ -286,24 +401,56 @@ |
3077 | data->processed = g_slist_append(data->processed, cb); |
3078 | } |
3079 | |
3080 | - data->callbacks = data->processed; |
3081 | - data->processed = NULL; |
3082 | - data->lock = FALSE; |
3083 | + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
3084 | +} |
3085 | + |
3086 | + |
3087 | +static DBusHandlerResult message_filter(DBusConnection *connection, |
3088 | + DBusMessage *message, void *user_data) |
3089 | +{ |
3090 | + struct filter_data *data; |
3091 | + const char *sender, *path, *iface, *member, *arg = NULL; |
3092 | + |
3093 | + /* Only filter signals */ |
3094 | + if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL) |
3095 | + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
3096 | + |
3097 | + sender = dbus_message_get_sender(message); |
3098 | + path = dbus_message_get_path(message); |
3099 | + iface = dbus_message_get_interface(message); |
3100 | + member = dbus_message_get_member(message); |
3101 | + dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg, DBUS_TYPE_INVALID); |
3102 | + |
3103 | + data = filter_data_find(connection, sender, path, iface, member, arg); |
3104 | + if (!data) { |
3105 | + error("Got %s.%s signal which has no listeners", iface, member); |
3106 | + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
3107 | + } |
3108 | + |
3109 | + if (data->handle_func) { |
3110 | + data->lock = TRUE; |
3111 | + |
3112 | + data->handle_func(connection, message, data); |
3113 | + |
3114 | + data->callbacks = data->processed; |
3115 | + data->processed = NULL; |
3116 | + data->lock = FALSE; |
3117 | + } |
3118 | |
3119 | if (data->callbacks) |
3120 | return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
3121 | |
3122 | - name_listeners = g_slist_remove(name_listeners, data); |
3123 | - name_data_free(data); |
3124 | + remove_match(data); |
3125 | + |
3126 | + listeners = g_slist_remove(listeners, data); |
3127 | + filter_data_free(data); |
3128 | |
3129 | /* Remove filter if there no listener left for the connection */ |
3130 | - data = name_data_find(connection, NULL); |
3131 | + data = filter_data_find(connection, NULL, NULL, NULL, NULL, NULL); |
3132 | if (!data) |
3133 | - dbus_connection_remove_filter(connection, name_exit_filter, |
3134 | + dbus_connection_remove_filter(connection, message_filter, |
3135 | NULL); |
3136 | |
3137 | - remove_match(connection, name); |
3138 | - |
3139 | return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
3140 | } |
3141 | |
3142 | @@ -388,6 +535,8 @@ |
3143 | |
3144 | dbus_pending_call_set_notify(call, service_reply, data, NULL); |
3145 | |
3146 | + dbus_pending_call_unref(call); |
3147 | + |
3148 | done: |
3149 | dbus_message_unref(message); |
3150 | } |
3151 | @@ -397,38 +546,27 @@ |
3152 | GDBusWatchFunction disconnect, |
3153 | void *user_data, GDBusDestroyFunction destroy) |
3154 | { |
3155 | - int first; |
3156 | - |
3157 | - if (!name_data_find(connection, NULL)) { |
3158 | - if (!dbus_connection_add_filter(connection, |
3159 | - name_exit_filter, NULL, NULL)) { |
3160 | - error("dbus_connection_add_filter() failed"); |
3161 | - return 0; |
3162 | - } |
3163 | - } |
3164 | - |
3165 | - listener_id++; |
3166 | - first = name_data_add(connection, name, connect, disconnect, |
3167 | - user_data, listener_id); |
3168 | - /* The filter is already added if this is not the first callback |
3169 | - * registration for the name */ |
3170 | - if (!first) |
3171 | - goto done; |
3172 | - |
3173 | - if (name) { |
3174 | - debug("name_listener_add(%s)", name); |
3175 | - |
3176 | - if (!add_match(connection, name)) { |
3177 | - name_data_remove(connection, name, listener_id); |
3178 | - return 0; |
3179 | - } |
3180 | - } |
3181 | - |
3182 | -done: |
3183 | + struct filter_data *data; |
3184 | + struct filter_callback *cb; |
3185 | + |
3186 | + if (!name) |
3187 | + return 0; |
3188 | + |
3189 | + data = filter_data_get(connection, service_filter, NULL, NULL, |
3190 | + DBUS_INTERFACE_DBUS, "NameOwnerChanged", |
3191 | + name); |
3192 | + if (!data) |
3193 | + return 0; |
3194 | + |
3195 | + cb = filter_data_add_callback(data, connect, disconnect, NULL, NULL, |
3196 | + user_data); |
3197 | + if (!cb) |
3198 | + return 0; |
3199 | + |
3200 | if (connect) |
3201 | check_service(connection, name, connect, user_data); |
3202 | |
3203 | - return listener_id; |
3204 | + return cb->id; |
3205 | } |
3206 | |
3207 | guint g_dbus_add_disconnect_watch(DBusConnection *connection, const char *name, |
3208 | @@ -440,72 +578,57 @@ |
3209 | } |
3210 | |
3211 | guint g_dbus_add_signal_watch(DBusConnection *connection, |
3212 | - const char *rule, GDBusSignalFunction function, |
3213 | - void *user_data, GDBusDestroyFunction destroy) |
3214 | + const char *sender, const char *path, |
3215 | + const char *interface, const char *member, |
3216 | + GDBusSignalFunction function, void *user_data, |
3217 | + GDBusDestroyFunction destroy) |
3218 | { |
3219 | - return 0; |
3220 | + struct filter_data *data; |
3221 | + struct filter_callback *cb; |
3222 | + |
3223 | + data = filter_data_get(connection, signal_filter, sender, path, |
3224 | + interface, member, NULL); |
3225 | + if (!data) |
3226 | + return 0; |
3227 | + |
3228 | + cb = filter_data_add_callback(data, NULL, NULL, function, destroy, |
3229 | + user_data); |
3230 | + if (!cb) |
3231 | + return 0; |
3232 | + |
3233 | + return cb->id; |
3234 | } |
3235 | |
3236 | gboolean g_dbus_remove_watch(DBusConnection *connection, guint id) |
3237 | { |
3238 | - struct name_data *data; |
3239 | - struct name_callback *cb; |
3240 | - GSList *ldata, *lcb; |
3241 | + struct filter_data *data; |
3242 | + struct filter_callback *cb; |
3243 | + GSList *ldata; |
3244 | |
3245 | if (id == 0) |
3246 | return FALSE; |
3247 | |
3248 | - for (ldata = name_listeners; ldata; ldata = ldata->next) { |
3249 | + for (ldata = listeners; ldata; ldata = ldata->next) { |
3250 | data = ldata->data; |
3251 | - for (lcb = data->callbacks; lcb; lcb = lcb->next) { |
3252 | - cb = lcb->data; |
3253 | - if (cb->id == id) |
3254 | - goto remove; |
3255 | - } |
3256 | - for (lcb = data->processed; lcb; lcb = lcb->next) { |
3257 | - cb = lcb->data; |
3258 | - if (cb->id == id) |
3259 | - goto remove; |
3260 | + |
3261 | + cb = filter_data_find_callback(data, id); |
3262 | + if (cb) { |
3263 | + filter_data_remove_callback(data, cb); |
3264 | + return TRUE; |
3265 | } |
3266 | } |
3267 | |
3268 | return FALSE; |
3269 | - |
3270 | -remove: |
3271 | - data->callbacks = g_slist_remove(data->callbacks, cb); |
3272 | - data->processed = g_slist_remove(data->processed, cb); |
3273 | - g_free(cb); |
3274 | - |
3275 | - /* Don't remove the filter if other callbacks exist or data is lock |
3276 | - * processing callbacks */ |
3277 | - if (data->callbacks || data->lock) |
3278 | - return TRUE; |
3279 | - |
3280 | - if (data->name) { |
3281 | - if (!remove_match(data->connection, data->name)) |
3282 | - return FALSE; |
3283 | - } |
3284 | - |
3285 | - name_listeners = g_slist_remove(name_listeners, data); |
3286 | - name_data_free(data); |
3287 | - |
3288 | - /* Remove filter if there are no listeners left for the connection */ |
3289 | - data = name_data_find(connection, NULL); |
3290 | - if (!data) |
3291 | - dbus_connection_remove_filter(connection, name_exit_filter, |
3292 | - NULL); |
3293 | - |
3294 | - return TRUE; |
3295 | } |
3296 | |
3297 | void g_dbus_remove_all_watches(DBusConnection *connection) |
3298 | { |
3299 | - struct name_data *data; |
3300 | + struct filter_data *data; |
3301 | |
3302 | - while ((data = name_data_find(connection, NULL))) { |
3303 | - name_listeners = g_slist_remove(name_listeners, data); |
3304 | - name_data_call_and_free(data); |
3305 | + while ((data = filter_data_find(connection, NULL, NULL, NULL, NULL, NULL))) { |
3306 | + listeners = g_slist_remove(listeners, data); |
3307 | + filter_data_call_and_free(data); |
3308 | } |
3309 | |
3310 | - dbus_connection_remove_filter(connection, name_exit_filter, NULL); |
3311 | + dbus_connection_remove_filter(connection, message_filter, NULL); |
3312 | } |
3313 | |
3314 | === modified file 'ltmain.sh' |
3315 | --- ltmain.sh 2009-07-27 19:02:30 +0000 |
3316 | +++ ltmain.sh 2010-04-28 20:38:30 +0000 |
3317 | @@ -1,6 +1,6 @@ |
3318 | # Generated from ltmain.m4sh. |
3319 | |
3320 | -# ltmain.sh (GNU libtool) 2.2.6 |
3321 | +# ltmain.sh (GNU libtool) 2.2.6b |
3322 | # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 |
3323 | |
3324 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc. |
3325 | @@ -65,7 +65,7 @@ |
3326 | # compiler: $LTCC |
3327 | # compiler flags: $LTCFLAGS |
3328 | # linker: $LD (gnu? $with_gnu_ld) |
3329 | -# $progname: (GNU libtool) 2.2.6 |
3330 | +# $progname: (GNU libtool) 2.2.6b |
3331 | # automake: $automake_version |
3332 | # autoconf: $autoconf_version |
3333 | # |
3334 | @@ -73,9 +73,9 @@ |
3335 | |
3336 | PROGRAM=ltmain.sh |
3337 | PACKAGE=libtool |
3338 | -VERSION=2.2.6 |
3339 | +VERSION=2.2.6b |
3340 | TIMESTAMP="" |
3341 | -package_revision=1.3012 |
3342 | +package_revision=1.3017 |
3343 | |
3344 | # Be Bourne compatible |
3345 | if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then |
3346 | |
3347 | === modified file 'plugins/filesystem.c' |
3348 | --- plugins/filesystem.c 2010-01-10 10:46:58 +0000 |
3349 | +++ plugins/filesystem.c 2010-04-28 20:38:30 +0000 |
3350 | @@ -2,8 +2,8 @@ |
3351 | * |
3352 | * OBEX Server |
3353 | * |
3354 | - * Copyright (C) 2009 Intel Corporation |
3355 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
3356 | + * Copyright (C) 2009-2010 Intel Corporation |
3357 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
3358 | * |
3359 | * |
3360 | * This program is free software; you can redistribute it and/or modify |
3361 | @@ -123,37 +123,49 @@ |
3362 | } |
3363 | |
3364 | static gpointer filesystem_open(const char *name, int oflag, mode_t mode, |
3365 | - size_t *size) |
3366 | + size_t *size, int *err) |
3367 | { |
3368 | struct stat stats; |
3369 | struct statvfs buf; |
3370 | int fd = open(name, oflag, mode); |
3371 | |
3372 | - if (fd < 0) |
3373 | + if (fd < 0) { |
3374 | + if (err) |
3375 | + *err = -errno; |
3376 | return NULL; |
3377 | + } |
3378 | |
3379 | if (fstat(fd, &stats) < 0) { |
3380 | - error("fstat(fd=%d): %s (%d)", fd, strerror(errno), errno); |
3381 | + if (err) |
3382 | + *err = -errno; |
3383 | goto failed; |
3384 | } |
3385 | |
3386 | if (oflag == O_RDONLY) { |
3387 | if (size) |
3388 | *size = stats.st_size; |
3389 | - return GINT_TO_POINTER(fd); |
3390 | + goto done; |
3391 | } |
3392 | |
3393 | - if (fstatvfs(fd, &buf) < 0) |
3394 | + if (fstatvfs(fd, &buf) < 0) { |
3395 | + if (err) |
3396 | + *err = -errno; |
3397 | goto failed; |
3398 | + } |
3399 | |
3400 | if (size == NULL) |
3401 | - return GINT_TO_POINTER(fd); |
3402 | + goto done; |
3403 | |
3404 | if (buf.f_bsize * buf.f_bavail < *size) { |
3405 | - errno = ENOSPC; |
3406 | + if (err) |
3407 | + *err = -ENOSPC; |
3408 | goto failed; |
3409 | } |
3410 | |
3411 | +done: |
3412 | + if (err) |
3413 | + *err = 0; |
3414 | + |
3415 | return GINT_TO_POINTER(fd); |
3416 | |
3417 | failed: |
3418 | @@ -163,71 +175,138 @@ |
3419 | |
3420 | static int filesystem_close(gpointer object) |
3421 | { |
3422 | - return close(GPOINTER_TO_INT(object)); |
3423 | + if (close(GPOINTER_TO_INT(object)) < 0) |
3424 | + return -errno; |
3425 | + |
3426 | + return 0; |
3427 | } |
3428 | |
3429 | static ssize_t filesystem_read(gpointer object, void *buf, size_t count) |
3430 | { |
3431 | - return read(GPOINTER_TO_INT(object), buf, count); |
3432 | + ssize_t ret; |
3433 | + |
3434 | + ret = read(GPOINTER_TO_INT(object), buf, count); |
3435 | + if (ret < 0) |
3436 | + return -errno; |
3437 | + |
3438 | + return ret; |
3439 | } |
3440 | |
3441 | static ssize_t filesystem_write(gpointer object, const void *buf, size_t count) |
3442 | { |
3443 | - return write(GPOINTER_TO_INT(object), buf, count); |
3444 | + ssize_t ret; |
3445 | + |
3446 | + ret = write(GPOINTER_TO_INT(object), buf, count); |
3447 | + if (ret < 0) |
3448 | + return -errno; |
3449 | + |
3450 | + return ret; |
3451 | +} |
3452 | + |
3453 | +struct capability_object { |
3454 | + int pid; |
3455 | + int output; |
3456 | + int err; |
3457 | + guint watch; |
3458 | + GString *buffer; |
3459 | +}; |
3460 | + |
3461 | +static void script_exited(GPid pid, gint status, gpointer data) |
3462 | +{ |
3463 | + struct capability_object *object = data; |
3464 | + char buf[128]; |
3465 | + |
3466 | + object->pid = -1; |
3467 | + |
3468 | + if (WEXITSTATUS(status) != EXIT_SUCCESS) { |
3469 | + memset(buf, 0, sizeof(buf)); |
3470 | + if (read(object->err, buf, sizeof(buf)) > 0) |
3471 | + error("%s", buf); |
3472 | + obex_object_set_io_flags(data, G_IO_ERR, -EPERM); |
3473 | + } else |
3474 | + obex_object_set_io_flags(data, G_IO_IN, 0); |
3475 | + |
3476 | + g_spawn_close_pid(pid); |
3477 | +} |
3478 | + |
3479 | +static int capability_exec(const char **argv, int *output, int *err) |
3480 | +{ |
3481 | + GError *gerr = NULL; |
3482 | + int pid; |
3483 | + GSpawnFlags flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH; |
3484 | + |
3485 | + if (!g_spawn_async_with_pipes(NULL, (char **) argv, NULL, flags, NULL, |
3486 | + NULL, &pid, NULL, output, err, &gerr)) { |
3487 | + error("%s", gerr->message); |
3488 | + g_error_free(gerr); |
3489 | + return -EPERM; |
3490 | + } |
3491 | + |
3492 | + return pid; |
3493 | } |
3494 | |
3495 | static gpointer capability_open(const char *name, int oflag, mode_t mode, |
3496 | - size_t *size) |
3497 | + size_t *size, int *err) |
3498 | { |
3499 | - GError *gerr = NULL; |
3500 | + struct capability_object *object = NULL; |
3501 | gchar *buf; |
3502 | - gint exit; |
3503 | - gboolean ret; |
3504 | - GString *object; |
3505 | + const char *argv[2]; |
3506 | |
3507 | if (oflag != O_RDONLY) |
3508 | goto fail; |
3509 | |
3510 | + object = g_new0(struct capability_object, 1); |
3511 | + object->pid = -1; |
3512 | + object->output = -1; |
3513 | + object->err = -1; |
3514 | + |
3515 | if (name[0] != '!') { |
3516 | + GError *gerr = NULL; |
3517 | + gboolean ret; |
3518 | + |
3519 | ret = g_file_get_contents(name, &buf, NULL, &gerr); |
3520 | if (ret == FALSE) { |
3521 | error("%s", gerr->message); |
3522 | + g_error_free(gerr); |
3523 | goto fail; |
3524 | } |
3525 | |
3526 | + object->buffer = g_string_new(buf); |
3527 | + |
3528 | + if (size) |
3529 | + *size = object->buffer->len; |
3530 | + |
3531 | goto done; |
3532 | } |
3533 | |
3534 | - ret = g_spawn_command_line_sync(name + 1, &buf, NULL, &exit, &gerr); |
3535 | - if (ret == FALSE) { |
3536 | - error("%s", gerr->message); |
3537 | - goto fail; |
3538 | - } |
3539 | - |
3540 | - if (WEXITSTATUS(exit) != EXIT_SUCCESS) { |
3541 | - error("%s failed", name + 1); |
3542 | - g_free(buf); |
3543 | - goto fail; |
3544 | - } |
3545 | + argv[0] = &name[1]; |
3546 | + argv[1] = NULL; |
3547 | + |
3548 | + object->pid = capability_exec(argv, &object->output, &object->err); |
3549 | + if (object->pid < 0) |
3550 | + goto fail; |
3551 | + |
3552 | + object->watch = g_child_watch_add(object->pid, script_exited, object); |
3553 | + |
3554 | + if (size) |
3555 | + *size = 1; |
3556 | |
3557 | done: |
3558 | - object = g_string_new(buf); |
3559 | - |
3560 | - if (size) |
3561 | - *size = object->len; |
3562 | + if (err) |
3563 | + *err = 0; |
3564 | |
3565 | return object; |
3566 | |
3567 | fail: |
3568 | - if (gerr) |
3569 | - g_error_free(gerr); |
3570 | + if (err) |
3571 | + *err = -EPERM; |
3572 | |
3573 | - errno = EPERM; |
3574 | + g_free(object); |
3575 | return NULL; |
3576 | } |
3577 | |
3578 | static gpointer folder_open(const char *name, int oflag, mode_t mode, |
3579 | - size_t *size) |
3580 | + size_t *size, int *err) |
3581 | { |
3582 | struct obex_session *os; |
3583 | struct stat fstat, dstat; |
3584 | @@ -235,7 +314,7 @@ |
3585 | DIR *dp; |
3586 | GString *object; |
3587 | gboolean root, pcsuite; |
3588 | - gint err; |
3589 | + int ret; |
3590 | |
3591 | os = obex_get_session(NULL); |
3592 | |
3593 | @@ -250,20 +329,21 @@ |
3594 | |
3595 | dp = opendir(name); |
3596 | if (dp == NULL) { |
3597 | - errno = ENOENT; |
3598 | + if (err) |
3599 | + *err = -ENOENT; |
3600 | goto failed; |
3601 | } |
3602 | |
3603 | if (root && os->server->symlinks) |
3604 | - err = stat(name, &dstat); |
3605 | + ret = stat(name, &dstat); |
3606 | else { |
3607 | object = g_string_append(object, FL_PARENT_FOLDER_ELEMENT); |
3608 | - err = lstat(name, &dstat); |
3609 | + ret = lstat(name, &dstat); |
3610 | } |
3611 | |
3612 | - if (err < 0) { |
3613 | - error("%s: %s(%d)", root ? "stat" : "lstat", |
3614 | - strerror(errno), errno); |
3615 | + if (ret < 0) { |
3616 | + if (err) |
3617 | + *err = -errno; |
3618 | goto failed; |
3619 | } |
3620 | |
3621 | @@ -284,11 +364,11 @@ |
3622 | fullname = g_build_filename(os->current_folder, ep->d_name, NULL); |
3623 | |
3624 | if (root && os->server->symlinks) |
3625 | - err = stat(fullname, &fstat); |
3626 | + ret = stat(fullname, &fstat); |
3627 | else |
3628 | - err = lstat(fullname, &fstat); |
3629 | + ret = lstat(fullname, &fstat); |
3630 | |
3631 | - if (err < 0) { |
3632 | + if (ret < 0) { |
3633 | debug("%s: %s(%d)", root ? "stat" : "lstat", |
3634 | strerror(errno), errno); |
3635 | g_free(name); |
3636 | @@ -310,13 +390,21 @@ |
3637 | g_free(line); |
3638 | } |
3639 | |
3640 | + closedir(dp); |
3641 | + |
3642 | object = g_string_append(object, FL_BODY_END); |
3643 | if (size) |
3644 | *size = object->len; |
3645 | |
3646 | + if (err) |
3647 | + *err = 0; |
3648 | + |
3649 | return object; |
3650 | |
3651 | failed: |
3652 | + if (dp) |
3653 | + closedir(dp); |
3654 | + |
3655 | g_string_free(object, TRUE); |
3656 | return NULL; |
3657 | } |
3658 | @@ -345,6 +433,37 @@ |
3659 | return len; |
3660 | } |
3661 | |
3662 | +static ssize_t capability_read(gpointer object, void *buf, size_t count) |
3663 | +{ |
3664 | + struct capability_object *obj = object; |
3665 | + |
3666 | + if (obj->buffer) |
3667 | + return string_read(obj->buffer, buf, count); |
3668 | + |
3669 | + if (obj->pid >= 0) |
3670 | + return -EAGAIN; |
3671 | + |
3672 | + return read(obj->output, buf, count); |
3673 | +} |
3674 | + |
3675 | +static int capability_close(gpointer object) |
3676 | +{ |
3677 | + struct capability_object *obj = object; |
3678 | + |
3679 | + if (obj->pid >= 0) { |
3680 | + g_source_remove(obj->watch); |
3681 | + kill(obj->pid, SIGTERM); |
3682 | + g_spawn_close_pid(obj->pid); |
3683 | + } |
3684 | + |
3685 | + if (obj->buffer != NULL) |
3686 | + g_string_free(obj->buffer, TRUE); |
3687 | + |
3688 | + g_free(obj); |
3689 | + |
3690 | + return 0; |
3691 | +} |
3692 | + |
3693 | struct obex_mime_type_driver file = { |
3694 | .open = filesystem_open, |
3695 | .close = filesystem_close, |
3696 | @@ -357,8 +476,8 @@ |
3697 | .target = FTP_TARGET, |
3698 | .mimetype = "x-obex/capability", |
3699 | .open = capability_open, |
3700 | - .close = string_free, |
3701 | - .read = string_read, |
3702 | + .close = capability_close, |
3703 | + .read = capability_read, |
3704 | }; |
3705 | |
3706 | struct obex_mime_type_driver folder = { |
3707 | |
3708 | === modified file 'plugins/ftp.c' |
3709 | --- plugins/ftp.c 2010-01-10 10:46:58 +0000 |
3710 | +++ plugins/ftp.c 2010-04-28 20:38:30 +0000 |
3711 | @@ -2,9 +2,8 @@ |
3712 | * |
3713 | * OBEX Server |
3714 | * |
3715 | - * Copyright (C) 2007-2008 Nokia Corporation |
3716 | - * Copyright (C) 2007-2008 Instituto Nokia de Tecnologia (INdT) |
3717 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
3718 | + * Copyright (C) 2007-2010 Nokia Corporation |
3719 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
3720 | * |
3721 | * |
3722 | * This program is free software; you can redistribute it and/or modify |
3723 | @@ -94,6 +93,7 @@ |
3724 | </record>" |
3725 | |
3726 | #define PCSUITE_CHANNEL 24 |
3727 | +#define PCSUITE_WHO_SIZE 8 |
3728 | #define PCSUITE_RECORD "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> \ |
3729 | <record> \ |
3730 | <attribute id=\"0x0001\"> \ |
3731 | @@ -141,9 +141,8 @@ |
3732 | 0xF9, 0xEC, 0x7B, 0xC4, 0x95, 0x3C, 0x11, 0xD2, |
3733 | 0x98, 0x4E, 0x52, 0x54, 0x00, 0xDC, 0x9E, 0x09 }; |
3734 | |
3735 | -static const guint8 PCSUITE_TARGET[TARGET_SIZE] = { |
3736 | - 0x00, 0x00, 0x50, 0x05, 0x00, 0x00, 0x10, 0x00, |
3737 | - 0x80, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x01 }; |
3738 | +static const guint8 PCSUITE_WHO[PCSUITE_WHO_SIZE] = { |
3739 | + 'P','C',' ','S','u','i','t','e' }; |
3740 | |
3741 | static gint get_by_type(struct obex_session *os, gchar *type, size_t *size) |
3742 | { |
3743 | @@ -156,7 +155,7 @@ |
3744 | if (g_str_equal(type, LST_TYPE)) |
3745 | return os_prepare_get(os, os->current_folder, size); |
3746 | |
3747 | - return FALSE; |
3748 | + return -ENOENT; |
3749 | } |
3750 | |
3751 | static gint ftp_prepare_get(struct obex_session *os, gchar *file, |
3752 | @@ -465,8 +464,8 @@ |
3753 | .record = PCSUITE_RECORD, |
3754 | .target = FTP_TARGET, |
3755 | .target_size = TARGET_SIZE, |
3756 | - .who = PCSUITE_TARGET, |
3757 | - .who_size = TARGET_SIZE, |
3758 | + .who = PCSUITE_WHO, |
3759 | + .who_size = PCSUITE_WHO_SIZE, |
3760 | .connect = ftp_connect, |
3761 | .get = ftp_get, |
3762 | .put = ftp_put, |
3763 | |
3764 | === modified file 'plugins/opp.c' |
3765 | --- plugins/opp.c 2010-01-10 10:46:58 +0000 |
3766 | +++ plugins/opp.c 2010-04-28 20:38:30 +0000 |
3767 | @@ -2,9 +2,8 @@ |
3768 | * |
3769 | * OBEX Server |
3770 | * |
3771 | - * Copyright (C) 2007-2008 Nokia Corporation |
3772 | - * Copyright (C) 2007-2008 Instituto Nokia de Tecnologia (INdT) |
3773 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
3774 | + * Copyright (C) 2007-2010 Nokia Corporation |
3775 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
3776 | * |
3777 | * |
3778 | * This program is free software; you can redistribute it and/or modify |
3779 | @@ -193,8 +192,11 @@ |
3780 | goto fail; |
3781 | |
3782 | if (g_str_equal(os->type, VCARD_TYPE)) { |
3783 | - if (os_prepare_get(os, VCARD_FILE, &size) < 0) |
3784 | - goto fail; |
3785 | + if (os_prepare_get(os, VCARD_FILE, &size) < 0) { |
3786 | + OBEX_ObjectSetRsp(obj, OBEX_RSP_NOT_FOUND, |
3787 | + OBEX_RSP_NOT_FOUND); |
3788 | + return; |
3789 | + } |
3790 | } else |
3791 | goto fail; |
3792 | |
3793 | |
3794 | === modified file 'plugins/pbap.c' |
3795 | --- plugins/pbap.c 2010-01-10 10:46:58 +0000 |
3796 | +++ plugins/pbap.c 2010-04-28 20:38:30 +0000 |
3797 | @@ -2,8 +2,8 @@ |
3798 | * |
3799 | * OBEX Server |
3800 | * |
3801 | - * Copyright (C) 2009 Intel Corporation |
3802 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
3803 | + * Copyright (C) 2009-2010 Intel Corporation |
3804 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
3805 | * |
3806 | * |
3807 | * This program is free software; you can redistribute it and/or modify |
3808 | @@ -558,6 +558,12 @@ |
3809 | unregister_session(os->cid); |
3810 | } |
3811 | |
3812 | +static gint pbap_chkput(obex_t *obex, obex_object_t *obj) |
3813 | +{ |
3814 | + /* Rejects all PUTs */ |
3815 | + return -EINVAL; |
3816 | +} |
3817 | + |
3818 | struct obex_service_driver pbap = { |
3819 | .name = "Phonebook Access server", |
3820 | .service = OBEX_PBAP, |
3821 | @@ -568,7 +574,8 @@ |
3822 | .connect = pbap_connect, |
3823 | .get = pbap_get, |
3824 | .setpath = pbap_setpath, |
3825 | - .disconnect = pbap_disconnect |
3826 | + .disconnect = pbap_disconnect, |
3827 | + .chkput = pbap_chkput |
3828 | }; |
3829 | |
3830 | static int pbap_init(void) |
3831 | |
3832 | === modified file 'plugins/phonebook-dummy.c' |
3833 | --- plugins/phonebook-dummy.c 2010-01-10 10:46:58 +0000 |
3834 | +++ plugins/phonebook-dummy.c 2010-04-28 20:38:30 +0000 |
3835 | @@ -2,8 +2,8 @@ |
3836 | * |
3837 | * OBEX Server |
3838 | * |
3839 | - * Copyright (C) 2009 Intel Corporation |
3840 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
3841 | + * Copyright (C) 2009-2010 Intel Corporation |
3842 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
3843 | * |
3844 | * |
3845 | * This program is free software; you can redistribute it and/or modify |
3846 | |
3847 | === modified file 'plugins/phonebook-ebook.c' |
3848 | --- plugins/phonebook-ebook.c 2010-01-10 10:46:58 +0000 |
3849 | +++ plugins/phonebook-ebook.c 2010-04-28 20:38:30 +0000 |
3850 | @@ -2,8 +2,8 @@ |
3851 | * |
3852 | * OBEX Server |
3853 | * |
3854 | - * Copyright (C) 2009 Intel Corporation |
3855 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
3856 | + * Copyright (C) 2009-2010 Intel Corporation |
3857 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
3858 | * |
3859 | * |
3860 | * This program is free software; you can redistribute it and/or modify |
3861 | @@ -113,7 +113,7 @@ |
3862 | for (l = attrib_list; l; l = l->next) { |
3863 | int i; |
3864 | const char *attrib_name = e_vcard_attribute_get_name( |
3865 | - (EVCardAttribute *)l->data); |
3866 | + (EVCardAttribute *) l->data); |
3867 | |
3868 | for (i = 0; i <= 28; i++) { |
3869 | int mask; |
3870 | @@ -123,10 +123,9 @@ |
3871 | continue; |
3872 | if (g_strcmp0(vcard_attribs[i], attrib_name)) |
3873 | continue; |
3874 | - e_vcard_add_attribute( |
3875 | - evcard_filtered, |
3876 | - e_vcard_attribute_copy( |
3877 | - (EVCardAttribute *)l->data)); |
3878 | + e_vcard_add_attribute(evcard_filtered, |
3879 | + e_vcard_attribute_copy( |
3880 | + (EVCardAttribute *) l->data)); |
3881 | break; |
3882 | } |
3883 | } |
3884 | @@ -365,7 +364,7 @@ |
3885 | for (l = attrib_list; l; l = l->next) { |
3886 | int i; |
3887 | const char *attrib_name = e_vcard_attribute_get_name( |
3888 | - (EVCardAttribute *)l->data); |
3889 | + (EVCardAttribute *) l->data); |
3890 | for (i = 0; i <= 28; i++) { |
3891 | int mask; |
3892 | |
3893 | @@ -375,11 +374,10 @@ |
3894 | if (g_strcmp0(vcard_attribs[i], attrib_name)) |
3895 | continue; |
3896 | |
3897 | - e_vcard_add_attribute( |
3898 | - evcard_filtered, |
3899 | - e_vcard_attribute_copy( |
3900 | - (EVCardAttribute *)l->data)); |
3901 | - break; |
3902 | + e_vcard_add_attribute(evcard_filtered, |
3903 | + e_vcard_attribute_copy( |
3904 | + (EVCardAttribute *) l->data)); |
3905 | + break; |
3906 | } |
3907 | } |
3908 | vcard = e_vcard_to_string(evcard_filtered, params->format); |
3909 | |
3910 | === modified file 'plugins/phonebook.h' |
3911 | --- plugins/phonebook.h 2010-01-10 10:46:58 +0000 |
3912 | +++ plugins/phonebook.h 2010-04-28 20:38:30 +0000 |
3913 | @@ -2,7 +2,7 @@ |
3914 | * |
3915 | * OBEX Server |
3916 | * |
3917 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
3918 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
3919 | * |
3920 | * |
3921 | * This program is free software; you can redistribute it and/or modify |
3922 | |
3923 | === modified file 'plugins/syncevolution.c' |
3924 | --- plugins/syncevolution.c 2010-01-10 10:46:58 +0000 |
3925 | +++ plugins/syncevolution.c 2010-04-28 20:38:30 +0000 |
3926 | @@ -2,8 +2,8 @@ |
3927 | * |
3928 | * OBEX Server |
3929 | * |
3930 | - * Copyright (C) 2007-2008 Intel Corporation |
3931 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
3932 | + * Copyright (C) 2007-2010 Intel Corporation |
3933 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
3934 | * |
3935 | * |
3936 | * This program is free software; you can redistribute it and/or modify |
3937 | @@ -43,6 +43,7 @@ |
3938 | #include "dbus.h" |
3939 | #include "btio.h" |
3940 | #include "obexd.h" |
3941 | +#include "gdbus.h" |
3942 | |
3943 | #define SYNCML_TARGET_SIZE 11 |
3944 | |
3945 | @@ -85,13 +86,13 @@ |
3946 | #define SYNCE_SERVER_INTERFACE "org.syncevolution.Server" |
3947 | #define SYNCE_CONN_INTERFACE "org.syncevolution.Connection" |
3948 | |
3949 | -static char match_string[256]; |
3950 | - |
3951 | struct synce_context { |
3952 | struct obex_session *os; |
3953 | DBusConnection *dbus_conn; |
3954 | gchar *conn_obj; |
3955 | gboolean reply_received; |
3956 | + guint reply_watch; |
3957 | + guint abort_watch; |
3958 | }; |
3959 | |
3960 | struct callback_data { |
3961 | @@ -115,20 +116,6 @@ |
3962 | return NULL; |
3963 | } |
3964 | |
3965 | -static struct synce_context *find_context_by_conn_obj(const char *path) |
3966 | -{ |
3967 | - GSList *l; |
3968 | - |
3969 | - for (l = context_list; l != NULL; l = l->next) { |
3970 | - struct synce_context *context = l->data; |
3971 | - |
3972 | - if (strcmp(context->conn_obj, path) == 0) |
3973 | - return context; |
3974 | - } |
3975 | - |
3976 | - return NULL; |
3977 | -} |
3978 | - |
3979 | static void append_dict_entry(DBusMessageIter *dict, const char *key, |
3980 | int type, void *val) |
3981 | { |
3982 | @@ -141,17 +128,18 @@ |
3983 | dbus_message_iter_close_container(dict, &entry); |
3984 | } |
3985 | |
3986 | -static void handle_connection_reply_signal(DBusMessage *msg, |
3987 | - const char *obj_path, void *data) |
3988 | +static gboolean reply_signal(DBusConnection *conn, DBusMessage *msg, |
3989 | + void *data) |
3990 | { |
3991 | struct synce_context *context = data; |
3992 | struct obex_session *os = context->os; |
3993 | + const char *path = dbus_message_get_path(msg); |
3994 | DBusMessageIter iter, array_iter; |
3995 | gchar *value; |
3996 | gint length; |
3997 | |
3998 | - if (strcmp(context->conn_obj, obj_path) != 0) |
3999 | - return; |
4000 | + if (strcmp(context->conn_obj, path) != 0) |
4001 | + return FALSE; |
4002 | |
4003 | dbus_message_iter_init(msg, &iter); |
4004 | |
4005 | @@ -159,7 +147,7 @@ |
4006 | dbus_message_iter_get_fixed_array(&array_iter, &value, &length); |
4007 | |
4008 | if (length == 0) |
4009 | - return; |
4010 | + return TRUE; |
4011 | |
4012 | os->buf = g_malloc(length); |
4013 | memcpy(os->buf, value, length); |
4014 | @@ -167,10 +155,12 @@ |
4015 | os->finished = TRUE; |
4016 | context->reply_received = TRUE; |
4017 | OBEX_ResumeRequest(os->obex); |
4018 | + |
4019 | + return TRUE; |
4020 | } |
4021 | |
4022 | -static void handle_connection_abort_signal(DBusMessage *msg, |
4023 | - const char *obj_path, void *data) |
4024 | +static gboolean abort_signal(DBusConnection *conn, DBusMessage *msg, |
4025 | + void *data) |
4026 | { |
4027 | struct synce_context *context = data; |
4028 | struct obex_session *os = context->os; |
4029 | @@ -179,35 +169,12 @@ |
4030 | os->finished = TRUE; |
4031 | OBEX_ResumeRequest(os->obex); |
4032 | OBEX_TransportDisconnect(os->obex); |
4033 | -} |
4034 | - |
4035 | -static DBusHandlerResult signal_filter(DBusConnection *conn, |
4036 | - DBusMessage *msg, void *data) |
4037 | -{ |
4038 | - const char *path = dbus_message_get_path(msg); |
4039 | - struct synce_context *context; |
4040 | - |
4041 | - if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL) |
4042 | - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
4043 | - |
4044 | - context = find_context_by_conn_obj(path); |
4045 | - if (!context) |
4046 | - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
4047 | - |
4048 | - if (dbus_message_is_signal(msg, SYNCE_CONN_INTERFACE, "Reply")) { |
4049 | - debug("Reply signal is received."); |
4050 | - handle_connection_reply_signal(msg, path, context); |
4051 | - } else if (dbus_message_is_signal(msg, SYNCE_CONN_INTERFACE, "Abort")) { |
4052 | - debug("Abort signal is received."); |
4053 | - handle_connection_abort_signal(msg, path, context); |
4054 | - } |
4055 | - |
4056 | - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; |
4057 | + |
4058 | + return TRUE; |
4059 | } |
4060 | |
4061 | static void connect_cb(DBusPendingCall *call, void *user_data) |
4062 | { |
4063 | - static gboolean signal_filter_added = FALSE; |
4064 | struct callback_data *cb_data = user_data; |
4065 | obex_t *obex = cb_data->obex; |
4066 | obex_object_t *obj = cb_data->obj; |
4067 | @@ -240,22 +207,13 @@ |
4068 | debug("Got conn object %s from syncevolution", path); |
4069 | context->conn_obj = g_strdup(path); |
4070 | |
4071 | - /* add signal filter */ |
4072 | - if (!signal_filter_added) { |
4073 | - if (!dbus_connection_add_filter(conn, signal_filter, |
4074 | - os, NULL)) { |
4075 | - error("Can't add signal filter"); |
4076 | - dbus_message_unref(reply); |
4077 | - g_free(cb_data); |
4078 | - goto failed; |
4079 | - } |
4080 | - signal_filter_added = TRUE; |
4081 | - } |
4082 | + context->reply_watch = g_dbus_add_signal_watch(conn, NULL, path, |
4083 | + SYNCE_CONN_INTERFACE, "Reply", |
4084 | + reply_signal, context, NULL); |
4085 | |
4086 | - snprintf(match_string, sizeof(match_string), "type=signal,interface=%s," |
4087 | - "path=%s", SYNCE_CONN_INTERFACE, context->conn_obj); |
4088 | - dbus_bus_add_match(conn, match_string, NULL); |
4089 | - dbus_connection_flush(conn); |
4090 | + context->abort_watch = g_dbus_add_signal_watch(conn, NULL, path, |
4091 | + SYNCE_CONN_INTERFACE, "Abort", |
4092 | + abort_signal, context, NULL); |
4093 | |
4094 | dbus_message_unref(reply); |
4095 | g_free(cb_data); |
4096 | @@ -311,7 +269,7 @@ |
4097 | struct callback_data *cb_data; |
4098 | struct synce_context *context; |
4099 | |
4100 | - conn = dbus_bus_get(DBUS_BUS_SESSION, NULL); |
4101 | + conn = obex_dbus_get_connection(); |
4102 | if (!conn) |
4103 | goto failed; |
4104 | |
4105 | @@ -507,10 +465,11 @@ |
4106 | dbus_pending_call_unref(call); |
4107 | |
4108 | failed: |
4109 | - snprintf(match_string, sizeof(match_string), |
4110 | - "type=signal,interface=%s,path=%s", |
4111 | - SYNCE_CONN_INTERFACE, context->conn_obj); |
4112 | - dbus_bus_remove_match(context->dbus_conn, match_string, NULL); |
4113 | + g_dbus_remove_watch(context->dbus_conn, context->reply_watch); |
4114 | + context->reply_watch = 0; |
4115 | + g_dbus_remove_watch(context->dbus_conn, context->abort_watch); |
4116 | + context->abort_watch = 0; |
4117 | + |
4118 | g_free(context->conn_obj); |
4119 | context->conn_obj = NULL; |
4120 | |
4121 | |
4122 | === modified file 'plugins/telephony-dummy.c' |
4123 | --- plugins/telephony-dummy.c 2010-01-10 10:46:58 +0000 |
4124 | +++ plugins/telephony-dummy.c 2010-04-28 20:38:30 +0000 |
4125 | @@ -2,8 +2,8 @@ |
4126 | * |
4127 | * OBEX Server |
4128 | * |
4129 | - * Copyright (C) 2009 Intel Corporation |
4130 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4131 | + * Copyright (C) 2009-2010 Intel Corporation |
4132 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4133 | * |
4134 | * |
4135 | * This program is free software; you can redistribute it and/or modify |
4136 | |
4137 | === modified file 'plugins/telephony.h' |
4138 | --- plugins/telephony.h 2010-01-10 10:46:58 +0000 |
4139 | +++ plugins/telephony.h 2010-04-28 20:38:30 +0000 |
4140 | @@ -2,7 +2,7 @@ |
4141 | * |
4142 | * OBEX Server |
4143 | * |
4144 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4145 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4146 | * |
4147 | * |
4148 | * This program is free software; you can redistribute it and/or modify |
4149 | |
4150 | === modified file 'src/bluetooth.c' |
4151 | --- src/bluetooth.c 2010-01-10 10:46:58 +0000 |
4152 | +++ src/bluetooth.c 2010-04-28 20:38:30 +0000 |
4153 | @@ -2,9 +2,8 @@ |
4154 | * |
4155 | * OBEX Server |
4156 | * |
4157 | - * Copyright (C) 2007-2008 Nokia Corporation |
4158 | - * Copyright (C) 2007-2008 Instituto Nokia de Tecnologia (INdT) |
4159 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4160 | + * Copyright (C) 2007-2010 Nokia Corporation |
4161 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4162 | * |
4163 | * |
4164 | * This program is free software; you can redistribute it and/or modify |
4165 | |
4166 | === modified file 'src/bluetooth.h' |
4167 | --- src/bluetooth.h 2010-01-10 10:46:58 +0000 |
4168 | +++ src/bluetooth.h 2010-04-28 20:38:30 +0000 |
4169 | @@ -2,9 +2,8 @@ |
4170 | * |
4171 | * OBEX Server |
4172 | * |
4173 | - * Copyright (C) 2007-2008 Nokia Corporation |
4174 | - * Copyright (C) 2007-2008 Instituto Nokia de Tecnologia (INdT) |
4175 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4176 | + * Copyright (C) 2007-2010 Nokia Corporation |
4177 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4178 | * |
4179 | * |
4180 | * This program is free software; you can redistribute it and/or modify |
4181 | |
4182 | === modified file 'src/btio.c' |
4183 | --- src/btio.c 2010-01-10 10:46:58 +0000 |
4184 | +++ src/btio.c 2010-04-28 20:38:30 +0000 |
4185 | @@ -2,8 +2,8 @@ |
4186 | * |
4187 | * BlueZ - Bluetooth protocol stack for Linux |
4188 | * |
4189 | - * Copyright (C) 2009 Marcel Holtmann <marcel@holtmann.org> |
4190 | - * Copyright (C) 2009 Nokia Corporation |
4191 | + * Copyright (C) 2009-2010 Marcel Holtmann <marcel@holtmann.org> |
4192 | + * Copyright (C) 2009-2010 Nokia Corporation |
4193 | * |
4194 | * |
4195 | * This program is free software; you can redistribute it and/or modify |
4196 | |
4197 | === modified file 'src/btio.h' |
4198 | --- src/btio.h 2010-01-10 10:46:58 +0000 |
4199 | +++ src/btio.h 2010-04-28 20:38:30 +0000 |
4200 | @@ -2,8 +2,8 @@ |
4201 | * |
4202 | * BlueZ - Bluetooth protocol stack for Linux |
4203 | * |
4204 | - * Copyright (C) 2009 Marcel Holtmann <marcel@holtmann.org> |
4205 | - * Copyright (C) 2009 Nokia Corporation |
4206 | + * Copyright (C) 2009-2010 Marcel Holtmann <marcel@holtmann.org> |
4207 | + * Copyright (C) 2009-2010 Nokia Corporation |
4208 | * |
4209 | * |
4210 | * This program is free software; you can redistribute it and/or modify |
4211 | |
4212 | === modified file 'src/dbus.h' |
4213 | --- src/dbus.h 2009-07-27 19:02:30 +0000 |
4214 | +++ src/dbus.h 2010-04-28 20:38:30 +0000 |
4215 | @@ -2,7 +2,7 @@ |
4216 | * |
4217 | * OBEX Server |
4218 | * |
4219 | - * Copyright (C) 2007-2008 Instituto Nokia de Tecnologia (INdT) |
4220 | + * Copyright (C) 2007-2010 Nokia Corporation |
4221 | * |
4222 | * |
4223 | * This program is free software; you can redistribute it and/or modify |
4224 | |
4225 | === modified file 'src/logging.c' |
4226 | --- src/logging.c 2009-07-27 19:02:30 +0000 |
4227 | +++ src/logging.c 2010-04-28 20:38:30 +0000 |
4228 | @@ -2,7 +2,7 @@ |
4229 | * |
4230 | * OBEX Server |
4231 | * |
4232 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4233 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4234 | * |
4235 | * |
4236 | * This program is free software; you can redistribute it and/or modify |
4237 | |
4238 | === modified file 'src/logging.h' |
4239 | --- src/logging.h 2009-07-27 19:02:30 +0000 |
4240 | +++ src/logging.h 2010-04-28 20:38:30 +0000 |
4241 | @@ -2,7 +2,7 @@ |
4242 | * |
4243 | * OBEX Server |
4244 | * |
4245 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4246 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4247 | * |
4248 | * |
4249 | * This program is free software; you can redistribute it and/or modify |
4250 | |
4251 | === modified file 'src/main.c' |
4252 | --- src/main.c 2010-01-10 10:46:58 +0000 |
4253 | +++ src/main.c 2010-04-28 20:38:30 +0000 |
4254 | @@ -2,7 +2,7 @@ |
4255 | * |
4256 | * OBEX Server |
4257 | * |
4258 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4259 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4260 | * |
4261 | * |
4262 | * This program is free software; you can redistribute it and/or modify |
4263 | |
4264 | === modified file 'src/manager.c' |
4265 | --- src/manager.c 2010-01-10 10:46:58 +0000 |
4266 | +++ src/manager.c 2010-04-28 20:38:30 +0000 |
4267 | @@ -2,7 +2,7 @@ |
4268 | * |
4269 | * OBEX Server |
4270 | * |
4271 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4272 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4273 | * |
4274 | * |
4275 | * This program is free software; you can redistribute it and/or modify |
4276 | @@ -528,7 +528,8 @@ |
4277 | |
4278 | dbus_error_init(&err); |
4279 | |
4280 | - connection = g_dbus_setup_bus(DBUS_BUS_SESSION, OPENOBEX_SERVICE, &err); |
4281 | + connection = g_dbus_setup_private(DBUS_BUS_SESSION, OPENOBEX_SERVICE, |
4282 | + &err); |
4283 | if (connection == NULL) { |
4284 | if (dbus_error_is_set(&err) == TRUE) { |
4285 | fprintf(stderr, "%s\n", err.message); |
4286 | @@ -539,8 +540,11 @@ |
4287 | } |
4288 | |
4289 | system_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL); |
4290 | - if (system_conn == NULL) |
4291 | + if (system_conn == NULL) { |
4292 | + dbus_connection_unref(connection); |
4293 | + connection = NULL; |
4294 | return FALSE; |
4295 | + } |
4296 | |
4297 | listener_id = g_dbus_add_service_watch(system_conn, "org.bluez", |
4298 | name_acquired, name_released, NULL, NULL); |
4299 | @@ -1028,4 +1032,10 @@ |
4300 | g_free(path); |
4301 | } |
4302 | |
4303 | +DBusConnection *obex_dbus_get_connection(void) |
4304 | +{ |
4305 | + if (connection == NULL) |
4306 | + return NULL; |
4307 | |
4308 | + return dbus_connection_ref(connection); |
4309 | +} |
4310 | |
4311 | === modified file 'src/mimetype.c' |
4312 | --- src/mimetype.c 2010-01-10 10:46:58 +0000 |
4313 | +++ src/mimetype.c 2010-04-28 20:38:30 +0000 |
4314 | @@ -2,7 +2,7 @@ |
4315 | * |
4316 | * OBEX Server |
4317 | * |
4318 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4319 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4320 | * |
4321 | * |
4322 | * This program is free software; you can redistribute it and/or modify |
4323 | @@ -38,6 +38,85 @@ |
4324 | |
4325 | static GSList *drivers = NULL; |
4326 | |
4327 | +static GSList *watches = NULL; |
4328 | + |
4329 | +struct io_watch { |
4330 | + gpointer object; |
4331 | + obex_object_io_func func; |
4332 | + gpointer user_data; |
4333 | +}; |
4334 | + |
4335 | +void obex_object_set_io_flags(gpointer object, int flags, int err) |
4336 | +{ |
4337 | + GSList *l; |
4338 | + |
4339 | + for (l = watches; l; l = l->next) { |
4340 | + struct io_watch *watch = l->data; |
4341 | + |
4342 | + if (watch->object != object) |
4343 | + continue; |
4344 | + |
4345 | + if (watch->func(object, flags, err, watch->user_data) == TRUE) |
4346 | + continue; |
4347 | + |
4348 | + if (g_slist_find(watches, watch) == NULL) |
4349 | + continue; |
4350 | + |
4351 | + watches = g_slist_remove(watches, watch); |
4352 | + g_free(watch); |
4353 | + } |
4354 | +} |
4355 | + |
4356 | +static struct io_watch *find_io_watch(gpointer object) |
4357 | +{ |
4358 | + GSList *l; |
4359 | + |
4360 | + for (l = watches; l; l = l->next) { |
4361 | + struct io_watch *watch = l->data; |
4362 | + |
4363 | + if (watch->object == object) |
4364 | + return watch; |
4365 | + } |
4366 | + |
4367 | + return NULL; |
4368 | +} |
4369 | + |
4370 | +static void reset_io_watch(gpointer object) |
4371 | +{ |
4372 | + struct io_watch *watch; |
4373 | + |
4374 | + watch = find_io_watch(object); |
4375 | + if (watch == NULL) |
4376 | + return; |
4377 | + |
4378 | + watches = g_slist_remove(watches, watch); |
4379 | + g_free(watch); |
4380 | +} |
4381 | + |
4382 | +static int set_io_watch(gpointer object, obex_object_io_func func, |
4383 | + gpointer user_data) |
4384 | +{ |
4385 | + struct io_watch *watch; |
4386 | + |
4387 | + if (func == NULL) { |
4388 | + reset_io_watch(object); |
4389 | + return 0; |
4390 | + } |
4391 | + |
4392 | + watch = find_io_watch(object); |
4393 | + if (watch) |
4394 | + return -EPERM; |
4395 | + |
4396 | + watch = g_new0(struct io_watch, 1); |
4397 | + watch->object = object; |
4398 | + watch->func = func; |
4399 | + watch->user_data = user_data; |
4400 | + |
4401 | + watches = g_slist_append(watches, watch); |
4402 | + |
4403 | + return 0; |
4404 | +} |
4405 | + |
4406 | struct obex_mime_type_driver *obex_mime_type_driver_find(const guint8 *target, const char *mimetype) |
4407 | { |
4408 | GSList *l; |
4409 | @@ -68,6 +147,9 @@ |
4410 | return -EPERM; |
4411 | } |
4412 | |
4413 | + if (driver->set_io_watch == NULL) |
4414 | + driver->set_io_watch = set_io_watch; |
4415 | + |
4416 | debug("driver %p mimetype %s registered", driver, driver->mimetype); |
4417 | |
4418 | drivers = g_slist_append(drivers, driver); |
4419 | |
4420 | === modified file 'src/mimetype.h' |
4421 | --- src/mimetype.h 2010-01-10 10:46:58 +0000 |
4422 | +++ src/mimetype.h 2010-04-28 20:38:30 +0000 |
4423 | @@ -2,7 +2,7 @@ |
4424 | * |
4425 | * OBEX Server |
4426 | * |
4427 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4428 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4429 | * |
4430 | * |
4431 | * This program is free software; you can redistribute it and/or modify |
4432 | @@ -23,17 +23,25 @@ |
4433 | |
4434 | #define TARGET_SIZE 16 |
4435 | |
4436 | +typedef gboolean (*obex_object_io_func) (gpointer object, int flags, int err, |
4437 | + gpointer user_data); |
4438 | + |
4439 | struct obex_mime_type_driver { |
4440 | const guint8 *target; |
4441 | const char *mimetype; |
4442 | - gpointer (*open) (const char *name, int oflag, mode_t mode, size_t *size); |
4443 | + gpointer (*open) (const char *name, int oflag, mode_t mode, |
4444 | + size_t *size, int *err); |
4445 | int (*close) (gpointer object); |
4446 | ssize_t (*read) (gpointer object, void *buf, size_t count); |
4447 | ssize_t (*write) (gpointer object, const void *buf, size_t count); |
4448 | int (*remove) (const char *name); |
4449 | + int (*set_io_watch) (gpointer object, obex_object_io_func func, |
4450 | + gpointer user_data); |
4451 | }; |
4452 | |
4453 | int obex_mime_type_driver_register(struct obex_mime_type_driver *driver); |
4454 | void obex_mime_type_driver_unregister(struct obex_mime_type_driver *driver); |
4455 | struct obex_mime_type_driver *obex_mime_type_driver_find(const guint8 *target, |
4456 | const char *mimetype); |
4457 | + |
4458 | +void obex_object_set_io_flags(gpointer object, int flags, int err); |
4459 | |
4460 | === modified file 'src/obex.c' |
4461 | --- src/obex.c 2010-01-10 10:46:58 +0000 |
4462 | +++ src/obex.c 2010-04-28 20:38:30 +0000 |
4463 | @@ -2,9 +2,8 @@ |
4464 | * |
4465 | * OBEX Server |
4466 | * |
4467 | - * Copyright (C) 2007-2008 Nokia Corporation |
4468 | - * Copyright (C) 2007-2008 Instituto Nokia de Tecnologia (INdT) |
4469 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4470 | + * Copyright (C) 2007-2010 Nokia Corporation |
4471 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4472 | * |
4473 | * |
4474 | * This program is free software; you can redistribute it and/or modify |
4475 | @@ -68,8 +67,10 @@ |
4476 | static void os_reset_session(struct obex_session *os) |
4477 | { |
4478 | if (os->object) { |
4479 | + os->driver->set_io_watch(os->object, NULL, NULL); |
4480 | os->driver->close(os->object); |
4481 | os->object = NULL; |
4482 | + os->obj = NULL; |
4483 | if (os->aborted && os->cmd == OBEX_CMD_PUT && os->current_folder) { |
4484 | gchar *path; |
4485 | path = g_build_filename(os->current_folder, os->name, NULL); |
4486 | @@ -90,6 +91,7 @@ |
4487 | g_free(os->buf); |
4488 | os->buf = NULL; |
4489 | } |
4490 | + |
4491 | os->driver = NULL; |
4492 | os->aborted = FALSE; |
4493 | os->offset = 0; |
4494 | @@ -386,10 +388,9 @@ |
4495 | gint err; |
4496 | gpointer object; |
4497 | |
4498 | - object = os->driver->open(filename, O_RDONLY, 0, size); |
4499 | + object = os->driver->open(filename, O_RDONLY, 0, size, &err); |
4500 | if (object == NULL) { |
4501 | - err = -errno; |
4502 | - error("open(%s): %s (%d)", filename, strerror(errno), errno); |
4503 | + error("open(%s): %s (%d)", filename, strerror(-err), -err); |
4504 | goto fail; |
4505 | } |
4506 | |
4507 | @@ -432,11 +433,13 @@ |
4508 | |
4509 | len = os->driver->read(os->object, os->buf, os->tx_mtu); |
4510 | if (len < 0) { |
4511 | - gint err = errno; |
4512 | - error("read(): %s (%d)", strerror(err), err); |
4513 | + error("read(): %s (%d)", strerror(-len), -len); |
4514 | + if (len == -EAGAIN) |
4515 | + return len; |
4516 | + |
4517 | g_free(os->buf); |
4518 | os->buf = NULL; |
4519 | - return -err; |
4520 | + return len; |
4521 | } |
4522 | |
4523 | ptr = os->buf; |
4524 | @@ -465,13 +468,14 @@ |
4525 | { |
4526 | gchar *path; |
4527 | gint len; |
4528 | + int err; |
4529 | |
4530 | path = g_build_filename(os->current_folder, os->name, NULL); |
4531 | os->object = os->driver->open(path, O_WRONLY | O_CREAT | O_TRUNC, 0600, |
4532 | os->size != OBJECT_SIZE_UNKNOWN ? |
4533 | - (size_t *) &os->size : NULL); |
4534 | + (size_t *) &os->size : NULL, &err); |
4535 | if (os->object == NULL) { |
4536 | - error("open(%s): %s (%d)", path, strerror(errno), errno); |
4537 | + error("open(%s): %s (%d)", path, strerror(-err), -err); |
4538 | g_free(path); |
4539 | return -EPERM; |
4540 | } |
4541 | @@ -489,13 +493,11 @@ |
4542 | |
4543 | w = os->driver->write(os->object, os->buf + len, os->offset - len); |
4544 | if (w < 0) { |
4545 | - gint err = errno; |
4546 | - error("write(%s): %s (%d)", path, strerror(errno), |
4547 | - errno); |
4548 | - if (err == EINTR) |
4549 | + error("write(%s): %s (%d)", path, strerror(-w), -w); |
4550 | + if (w == -EINTR) |
4551 | continue; |
4552 | else |
4553 | - return -err; |
4554 | + return w; |
4555 | } |
4556 | |
4557 | len += w; |
4558 | @@ -544,11 +546,10 @@ |
4559 | |
4560 | w = os->driver->write(os->object, buffer + len, size - len); |
4561 | if (w < 0) { |
4562 | - gint err = errno; |
4563 | - if (err == EINTR) |
4564 | + if (w == -EINTR) |
4565 | continue; |
4566 | else |
4567 | - return -err; |
4568 | + return w; |
4569 | } |
4570 | |
4571 | len += w; |
4572 | @@ -559,6 +560,44 @@ |
4573 | return 0; |
4574 | } |
4575 | |
4576 | +static gboolean handle_async_io(gpointer object, int flags, int err, |
4577 | + gpointer user_data) |
4578 | +{ |
4579 | + struct obex_session *os = user_data; |
4580 | + int ret = 0; |
4581 | + |
4582 | + if (err < 0) { |
4583 | + ret = err; |
4584 | + goto proceed; |
4585 | + } |
4586 | + |
4587 | + if (flags & (G_IO_IN | G_IO_PRI)) |
4588 | + ret = obex_write_stream(os, os->obex, os->obj); |
4589 | + else if (flags & G_IO_OUT) |
4590 | + ret = obex_read_stream(os, os->obex, os->obj); |
4591 | + |
4592 | +proceed: |
4593 | + switch (ret) { |
4594 | + case -EINVAL: |
4595 | + OBEX_ObjectSetRsp(os->obj, OBEX_RSP_BAD_REQUEST, |
4596 | + OBEX_RSP_BAD_REQUEST); |
4597 | + case -EPERM: |
4598 | + OBEX_ObjectSetRsp(os->obj, OBEX_RSP_FORBIDDEN, |
4599 | + OBEX_RSP_FORBIDDEN); |
4600 | + break; |
4601 | + default: |
4602 | + if (ret < 0) |
4603 | + OBEX_ObjectSetRsp(os->obj, |
4604 | + OBEX_RSP_INTERNAL_SERVER_ERROR, |
4605 | + OBEX_RSP_INTERNAL_SERVER_ERROR); |
4606 | + break; |
4607 | + } |
4608 | + |
4609 | + OBEX_ResumeRequest(os->obex); |
4610 | + |
4611 | + return FALSE; |
4612 | +} |
4613 | + |
4614 | static gboolean check_put(obex_t *obex, obex_object_t *obj) |
4615 | { |
4616 | struct obex_session *os; |
4617 | @@ -645,7 +684,7 @@ |
4618 | } |
4619 | } |
4620 | |
4621 | - if (!os->service || !os->service->chkput) |
4622 | + if (!os->service->chkput) |
4623 | goto done; |
4624 | |
4625 | ret = os->service->chkput(obex, obj); |
4626 | @@ -659,6 +698,11 @@ |
4627 | case -EPERM: |
4628 | OBEX_ObjectSetRsp(obj, OBEX_RSP_FORBIDDEN, OBEX_RSP_FORBIDDEN); |
4629 | return FALSE; |
4630 | + case -EAGAIN: |
4631 | + OBEX_SuspendRequest(obex, obj); |
4632 | + os->obj = obj; |
4633 | + os->driver->set_io_watch(os->object, handle_async_io, os); |
4634 | + return TRUE; |
4635 | default: |
4636 | debug("Unhandled chkput error: %d", ret); |
4637 | OBEX_ObjectSetRsp(obj, OBEX_RSP_INTERNAL_SERVER_ERROR, |
4638 | @@ -727,13 +771,12 @@ |
4639 | case OBEX_CMD_PUT: |
4640 | case OBEX_CMD_GET: |
4641 | case OBEX_CMD_SETPATH: |
4642 | + default: |
4643 | os_session_mark_aborted(os); |
4644 | if (os->service->reset) |
4645 | os->service->reset(obex); |
4646 | os_reset_session(os); |
4647 | break; |
4648 | - default: |
4649 | - break; |
4650 | } |
4651 | break; |
4652 | case OBEX_EV_REQHINT: |
4653 | @@ -758,7 +801,7 @@ |
4654 | case OBEX_EV_REQCHECK: |
4655 | switch (cmd) { |
4656 | case OBEX_CMD_PUT: |
4657 | - if (os->service && os->service->put) |
4658 | + if (os->service) |
4659 | check_put(obex, obj); |
4660 | break; |
4661 | default: |
4662 | @@ -796,6 +839,11 @@ |
4663 | OBEX_ObjectSetRsp(obj, |
4664 | OBEX_RSP_FORBIDDEN, OBEX_RSP_FORBIDDEN); |
4665 | break; |
4666 | + case -EAGAIN: |
4667 | + OBEX_SuspendRequest(obex, obj); |
4668 | + os->obj = obj; |
4669 | + os->driver->set_io_watch(os->object, handle_async_io, os); |
4670 | + break; |
4671 | default: |
4672 | OBEX_ObjectSetRsp(obj, |
4673 | OBEX_RSP_INTERNAL_SERVER_ERROR, |
4674 | @@ -805,7 +853,21 @@ |
4675 | |
4676 | break; |
4677 | case OBEX_EV_STREAMEMPTY: |
4678 | - obex_write_stream(os, obex, obj); |
4679 | + switch (obex_write_stream(os, obex, obj)) { |
4680 | + case -EPERM: |
4681 | + OBEX_ObjectSetRsp(obj, |
4682 | + OBEX_RSP_FORBIDDEN, OBEX_RSP_FORBIDDEN); |
4683 | + break; |
4684 | + case -EAGAIN: |
4685 | + OBEX_SuspendRequest(obex, obj); |
4686 | + os->obj = obj; |
4687 | + os->driver->set_io_watch(os->object, handle_async_io, |
4688 | + os); |
4689 | + break; |
4690 | + default: |
4691 | + break; |
4692 | + } |
4693 | + |
4694 | break; |
4695 | case OBEX_EV_LINKERR: |
4696 | break; |
4697 | |
4698 | === modified file 'src/obex.h' |
4699 | --- src/obex.h 2010-01-10 10:46:58 +0000 |
4700 | +++ src/obex.h 2010-04-28 20:38:30 +0000 |
4701 | @@ -2,9 +2,8 @@ |
4702 | * |
4703 | * OBEX Server |
4704 | * |
4705 | - * Copyright (C) 2007-2008 Nokia Corporation |
4706 | - * Copyright (C) 2007-2008 Instituto Nokia de Tecnologia (INdT) |
4707 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4708 | + * Copyright (C) 2007-2010 Nokia Corporation |
4709 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4710 | * |
4711 | * |
4712 | * This program is free software; you can redistribute it and/or modify |
4713 | @@ -78,6 +77,7 @@ |
4714 | struct server *server; |
4715 | gboolean checked; |
4716 | obex_t *obex; |
4717 | + obex_object_t *obj; |
4718 | struct obex_mime_type_driver *driver; |
4719 | gboolean finished; |
4720 | }; |
4721 | |
4722 | === modified file 'src/obexd.h' |
4723 | --- src/obexd.h 2009-07-27 19:02:30 +0000 |
4724 | +++ src/obexd.h 2010-04-28 20:38:30 +0000 |
4725 | @@ -2,7 +2,7 @@ |
4726 | * |
4727 | * OBEX Server |
4728 | * |
4729 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4730 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4731 | * |
4732 | * |
4733 | * This program is free software; you can redistribute it and/or modify |
4734 | @@ -21,6 +21,8 @@ |
4735 | * |
4736 | */ |
4737 | |
4738 | +#include <dbus/dbus.h> |
4739 | + |
4740 | #define OPENOBEX_SERVICE "org.openobex" |
4741 | |
4742 | #define OPENOBEX_MANAGER_PATH "/" |
4743 | @@ -34,3 +36,5 @@ |
4744 | |
4745 | gboolean plugin_init(void); |
4746 | void plugin_cleanup(void); |
4747 | + |
4748 | +DBusConnection *obex_dbus_get_connection(void); |
4749 | |
4750 | === modified file 'src/plugin.c' |
4751 | --- src/plugin.c 2010-01-10 10:46:58 +0000 |
4752 | +++ src/plugin.c 2010-04-28 20:38:30 +0000 |
4753 | @@ -2,7 +2,7 @@ |
4754 | * |
4755 | * OBEX Server |
4756 | * |
4757 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4758 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4759 | * |
4760 | * |
4761 | * This program is free software; you can redistribute it and/or modify |
4762 | |
4763 | === modified file 'src/plugin.h' |
4764 | --- src/plugin.h 2010-01-10 10:46:58 +0000 |
4765 | +++ src/plugin.h 2010-04-28 20:38:30 +0000 |
4766 | @@ -2,7 +2,7 @@ |
4767 | * |
4768 | * OBEX Server |
4769 | * |
4770 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4771 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4772 | * |
4773 | * |
4774 | * This program is free software; you can redistribute it and/or modify |
4775 | |
4776 | === modified file 'src/service.c' |
4777 | --- src/service.c 2010-01-10 10:46:58 +0000 |
4778 | +++ src/service.c 2010-04-28 20:38:30 +0000 |
4779 | @@ -2,7 +2,7 @@ |
4780 | * |
4781 | * OBEX Server |
4782 | * |
4783 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4784 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4785 | * |
4786 | * |
4787 | * This program is free software; you can redistribute it and/or modify |
4788 | @@ -49,8 +49,8 @@ |
4789 | struct obex_service_driver *driver = l->data; |
4790 | |
4791 | if (driver->who && who && |
4792 | - driver->who_size == who_size && |
4793 | - memcmp(driver->who, who, who_size) != 0) |
4794 | + (driver->who_size != who_size || |
4795 | + memcmp(driver->who, who, who_size) != 0)) |
4796 | continue; |
4797 | |
4798 | if (driver->target == NULL && target == NULL) |
4799 | @@ -97,7 +97,11 @@ |
4800 | |
4801 | debug("driver %p service %s registered", driver, driver->name); |
4802 | |
4803 | - drivers = g_slist_append(drivers, driver); |
4804 | + /* Drivers that support who has priority */ |
4805 | + if (driver->who) |
4806 | + drivers = g_slist_prepend(drivers, driver); |
4807 | + else |
4808 | + drivers = g_slist_append(drivers, driver); |
4809 | |
4810 | return 0; |
4811 | } |
4812 | |
4813 | === modified file 'src/service.h' |
4814 | --- src/service.h 2010-01-10 10:46:58 +0000 |
4815 | +++ src/service.h 2010-04-28 20:38:30 +0000 |
4816 | @@ -2,7 +2,7 @@ |
4817 | * |
4818 | * OBEX Server |
4819 | * |
4820 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4821 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4822 | * |
4823 | * |
4824 | * This program is free software; you can redistribute it and/or modify |
4825 | |
4826 | === modified file 'test/ftp-client' |
4827 | --- test/ftp-client 2009-07-27 19:02:30 +0000 |
4828 | +++ test/ftp-client 2010-04-28 20:38:30 +0000 |
4829 | @@ -15,6 +15,11 @@ |
4830 | self.verbose = verbose |
4831 | |
4832 | @dbus.service.method("org.openobex.Agent", |
4833 | + in_signature="o", out_signature="s") |
4834 | + def Request(self, path): |
4835 | + return "" |
4836 | + |
4837 | + @dbus.service.method("org.openobex.Agent", |
4838 | in_signature="ot", out_signature="") |
4839 | def Progress(self, path, transferred): |
4840 | if self.verbose: |
4841 | @@ -55,6 +60,11 @@ |
4842 | |
4843 | return parser.parse_args() |
4844 | |
4845 | +def error(err): |
4846 | + print err |
4847 | + |
4848 | +def void_reply(): |
4849 | + pass |
4850 | |
4851 | def change_folder(session, new_dir): |
4852 | for node in new_dir.split("/"): |
4853 | @@ -69,11 +79,15 @@ |
4854 | |
4855 | def put_file(session, filename): |
4856 | session.PutFile(os.path.abspath(filename), |
4857 | - os.path.basename(filename)) |
4858 | + os.path.basename(filename), |
4859 | + reply_handler=void_reply, |
4860 | + error_handler=error) |
4861 | |
4862 | def get_file(session, filename): |
4863 | session.GetFile(os.path.abspath(filename), |
4864 | - os.path.basename(filename)) |
4865 | + os.path.basename(filename), |
4866 | + reply_handler=void_reply, |
4867 | + error_handler=error) |
4868 | |
4869 | |
4870 | if __name__ == '__main__': |
4871 | @@ -91,8 +105,6 @@ |
4872 | bus = dbus.SessionBus() |
4873 | mainloop = gobject.MainLoop() |
4874 | |
4875 | - need_mainloop = False |
4876 | - |
4877 | path = "/test/agent" |
4878 | agent = Agent(bus, path, options.verbose) |
4879 | |
4880 | @@ -117,12 +129,9 @@ |
4881 | list_folder(ftp) |
4882 | |
4883 | if options.get_file: |
4884 | - need_mainloop = True |
4885 | get_file(ftp, options.get_file) |
4886 | |
4887 | if options.put_file: |
4888 | - need_mainloop = True |
4889 | put_file(ftp, options.put_file) |
4890 | |
4891 | - if need_mainloop: |
4892 | - mainloop.run() |
4893 | + mainloop.run() |
4894 | |
4895 | === modified file 'test/main.c' |
4896 | --- test/main.c 2009-07-27 19:02:30 +0000 |
4897 | +++ test/main.c 2010-04-28 20:38:30 +0000 |
4898 | @@ -2,7 +2,7 @@ |
4899 | * |
4900 | * OBEX Test |
4901 | * |
4902 | - * Copyright (C) 2007-2009 Marcel Holtmann <marcel@holtmann.org> |
4903 | + * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org> |
4904 | * |
4905 | * |
4906 | * This program is free software; you can redistribute it and/or modify |