Commit Graph

171 Commits

Author SHA1 Message Date
Luiz Augusto von Dentz
6b7b19c972 obexd: add FileTransfer.CopyFile implementation 2012-12-04 22:48:43 +01:00
Luiz Augusto von Dentz
501fa35265 obexd: add FileTransfer.MoveFile implementation 2012-12-04 22:48:43 +01:00
Luiz Augusto von Dentz
3fbffebe57 obexd: add sync target
sync target implements sync driver
2012-12-04 22:48:42 +01:00
Luiz Augusto von Dentz
e976fc0a57 obexd: add pbap target
pbap target implements phonebook access driver
2012-12-04 22:48:42 +01:00
Luiz Augusto von Dentz
044d002f1f obexd: add ftp target
ftp target implements file transfer and Nokia Pc Suite drivers.
2012-12-04 22:48:42 +01:00
Luiz Augusto von Dentz
9e64065e4f obexd: add opp target
opp target implements object push driver
2012-12-04 22:48:42 +01:00
Luiz Augusto von Dentz
29eb13b108 obexd: make use of obc_ prefix for public functions
This should indicate more clearer which function are public to the
drivers.
2012-12-04 22:48:42 +01:00
Luiz Augusto von Dentz
590fd450bb obexd: add target driver support
This simplify target matching to a single place making it easier to add
new targets/profiles.

Matching is done by either friendly name e.g. opp, ftp... or Bluetooth
UUID.

Drivers are probed when a session is established and removed when the
session is destroyed.
2012-12-04 22:48:42 +01:00
Luiz Augusto von Dentz
ec0e7836cf obexd: move __obex_log_init before manager_init
This enables us to log target during initialization
2012-12-04 22:48:42 +01:00
Luiz Augusto von Dentz
7605e6c809 obexd: add target module vtable
New targets/profiles can be introduced by just adding an entry to the
table and register their drivers similarly to a plugin.
2012-12-04 22:48:42 +01:00
Luiz Augusto von Dentz
c3dee209a0 obexd: separate manager interface code from main
Move manager interface code to it own file.
2012-12-04 22:48:41 +01:00
Luiz Augusto von Dentz
22c7e9f390 obexd: separate agent code from session
This should improve modularization of code
2012-12-04 22:48:41 +01:00
Luiz Augusto von Dentz
fd15f3a28a obexd: separate ftp code from session
This should improve modularization of code
2012-12-04 22:48:41 +01:00
Luiz Augusto von Dentz
b5c28914a1 obexd: make transfer structure private
This make it easier to modularize obex-client
2012-12-04 22:48:41 +01:00
Luiz Augusto von Dentz
d06d20882a obexd: make session structure private
Session data should not be acessible directly otherwise it cause too
much dependency by profile specific code which is quite inefficient in
the long term.
2012-12-04 22:48:41 +01:00
Dmitriy Paliy
b17209a9b4 obexd: Add adapter ReleaseSession to obex-client
Release of adapter session is added to obex-client when closing OBEX
transfer.
2012-12-04 22:48:39 +01:00
Dmitriy Paliy
821da85bb6 obexd: Add handling of system D-Bus method calls
Sending system D-Bus method calls (DefaultAdapter, FindAdapter
and RequestSession) and handling of pending D-Bus calls is added
to obex-client.
2012-12-04 22:48:39 +01:00
Dmitriy Paliy
d89ad62c05 obexd: Split up session_create in separate functions
Connection of RFCOMM and SDP are extracted from session_create function
into session_connect. Such allows making asynchronous calls before
creating connections.
2012-12-04 22:48:39 +01:00
Dmitriy Paliy
bbcc0f34da obexd: Add system bus connection in obex-client
Connection to system bus is added in obex-client. Purpose is to carry
out OBEX transfers within a single adapter's session.
2012-12-04 22:48:39 +01:00
Dmitriy Paliy
d8d19199e8 obexd: remove unnecessary brackets 2012-12-04 22:48:38 +01:00
Bartosz Szatkowski
bca372b405 obexd: Fix endian conversion for appparams in pbap client 2012-12-04 22:48:36 +01:00
Luiz Augusto von Dentz
50071dde9c obexd: add support for reusing session for the same client
If the a client owning a session attempt to send a new file just reuse
the same session instead of trying to connect again.
2012-12-04 22:48:36 +01:00
Luiz Augusto von Dentz
4780531beb obexd: fix not canceling connection request if client exit bus
There is no point on proceeding with sdp/rfcomm connections if client
exit the bus.
2012-12-04 22:48:36 +01:00
Luiz Augusto von Dentz
553f3949b5 obexd: remove unused variable 2012-12-04 22:48:35 +01:00
Luiz Augusto von Dentz
932949fe49 obexd: Add support for stat files bigger than 2GB on 32-bit systems
From stat documentation:

"(stat())  path  refers to a file whose size cannot be represented in the
type off_t.  This can occur when an application compiled on a 32-bit
platform without -D_FILE_OFFSET_BITS=64 calls stat() on a file whose size
exceeds (2<<31)-1 bits."

To fix this now size header is omitted when the file is over 32-bit, but
it is able to transfer it by using 64-bit variables. In addition to that
folder-listing now should report such big sizes properly.
2012-12-04 22:48:32 +01:00
Luiz Augusto von Dentz
127fe7b3cf obexd: Fix logging for obex-client
Since obex-client and obexd share the same log code they both were using
obexd for openlog which makes it very confusing when reading the logs.

To fix this now __obex_log_init takes the binary name so that each daemon
can be properly labeled.
2012-12-04 22:48:31 +01:00
Luiz Augusto von Dentz
22d757b954 obexd: Fix possible crash when processing session callback
If the callback removes the pending data it cause this:

==20639== Invalid read of size 4
==20639==    at 0x80553E9: free_pending (session.c:112)
==20639==    by 0x8056C83: session_request_reply (session.c:837)
==20639==    by 0x412F7E0: ??? (in /lib/libdbus-1.so.3.5.2)
==20639==    by 0x411D975: ??? (in /lib/libdbus-1.so.3.5.2)
==20639==    by 0x4120B81: dbus_connection_dispatch (in /lib/libdbus-1.so.3.5.2)
==20639==    by 0x804C27F: message_dispatch (mainloop.c:80)
==20639==    by 0x407EFCB: ??? (in /lib/libglib-2.0.so.0.2600.1)
==20639==    by 0x407E854: g_main_context_dispatch (in /lib/libglib-2.0.so.0.2600.1)
==20639==    by 0x4082667: ??? (in /lib/libglib-2.0.so.0.2600.1)
==20639==    by 0x4082BA6: g_main_loop_run (in /lib/libglib-2.0.so.0.2600.1)
==20639==    by 0x8055171: main (main.c:625)
==20639==  Address 0x4363c88 is 0 bytes inside a block of size 12 free'd
==20639==    at 0x40257ED: free (vg_replace_malloc.c:366)
==20639==    by 0x4087485: g_free (in /lib/libglib-2.0.so.0.2600.1)
==20639==    by 0x80553FE: free_pending (session.c:115)
==20639==    by 0x805543C: agent_free (session.c:127)
==20639==    by 0x80566A6: session_free (session.c:149)
==20639==    by 0x8056BCA: session_terminate_transfer (session.c:914)
==20639==    by 0x8056F61: session_prepare_put (session.c:1397)
==20639==    by 0x8056C74: session_request_reply (session.c:835)
==20639==    by 0x412F7E0: ??? (in /lib/libdbus-1.so.3.5.2)
==20639==    by 0x411D975: ??? (in /lib/libdbus-1.so.3.5.2)
==20639==    by 0x4120B81: dbus_connection_dispatch (in /lib/libdbus-1.so.3.5.2)
==20639==    by 0x804C27F: message_dispatch (mainloop.c:80)

To fix this agent->pending is now reset to NULL before calling the
callback, so even if the session is terminated it won't cause a free to
pending data, which is fine since it is latter freed on callback return.
2012-12-04 22:48:31 +01:00
Luiz Augusto von Dentz
972f88aa1c obexd: Make use of transfer->err to store transfer errors 2012-12-04 22:48:28 +01:00
Daniel Orstadius
fc5c121427 obexd: Fix process pending request if transfer canceled
If the call to the Request method of the obex client agent returns
with an error (for example if the transfer is rejected), call
function session_terminate_transfer instead of unregister_transfer
to both unregister the transfer and handle the pending request.
2012-12-04 22:48:28 +01:00
Luiz Augusto von Dentz
4a54d91c7d obexd: Fix possible NULL pointer deference
Variable "transfer" tracked as NULL was passed to function
"transfer_unregister" that dereferences it.
2012-12-04 22:48:27 +01:00
Luiz Augusto von Dentz
9fcc33bfb8 obexd: Fix not detecting errors on small files
Make use of gw_obex_xfer_close instead of gw_obex_xfer_flush since the
former not only flushes the remaining data but also wait for the response
catching errors that gw_obex_xfer_flush doesn't.
2012-12-04 22:48:27 +01:00
Luiz Augusto von Dentz
8702ac21b9 obexd: Fix not detecting errors when transferring the last part of the buffer
The last part has to be flushed in order to sent the remaining buffer as
a obex packet and detect possible errors.
2012-12-04 22:48:27 +01:00
Johan Hedberg
ca5d2090f6 obexd: Fix format string warnings for g_dbus_create_error
This patch fixes gcc warnings for "format not a string literal and no
format arguments".
2012-12-04 22:48:25 +01:00
Luiz Augusto von Dentz
1759d7153c obexd: Make sure errors are reported properly to applications
Error message were most of the time empty.

Thanks for Vitja Makarov <vitja.makarov@gmail.com> for reporting this.
2012-12-04 22:48:24 +01:00
Luiz Augusto von Dentz
27906878d9 obexd: Fix not closing socket when connection attempt fails
When connection attempt fails the socket were left opened as it is not
assigned to the session, also when the connection does succeed the socket
is closed twice when the session is removed.

To fix those issues session now holds a reference to the GIOChannel
returned bt bt_io_connect so that the connection can properly close when
releasing, in addiction to that it also is marked to not close the socket
when the connection succeeds so that when removing the session it doesn't
close the socket twice.

Thanks for Vitja Makarov <vitja.makarov@gmail.com> for reporting this.
2012-12-04 22:48:23 +01:00
Luiz Augusto von Dentz
bb30d00920 obexd: reuse code when reading buffered data
This should also improve speed since now file transfer also tries to read
all buffered data before continue, so each progress will probably be
around the MTU size rather than buffer size.
2012-12-04 22:48:23 +01:00
Luiz Augusto von Dentz
15130f0c06 obexd: fix not reading all buffered data 2012-12-04 22:48:23 +01:00
Luiz Augusto von Dentz
8a504f047d obexd: fix strerr option 2012-12-04 22:48:22 +01:00
Marcel Holtmann
cf7c506246 obexd: More cleanup for the logging code 2012-12-04 22:48:22 +01:00
Luiz Augusto von Dentz
dea41fe55c obexd: Fix security requirements for legacy devices (< 2.1)
Make use of security low so that services like opp do not request bonding
when connecting to legacy devices.
2012-12-04 22:48:22 +01:00
Luiz Augusto von Dentz
11c141b636 obexd: Make use of BtIO on obex-client 2012-12-04 22:48:21 +01:00
Luiz Augusto Von Dentz
537072e41d obexd: Fix transfer for empty name/mimetype specific 2012-12-04 22:48:21 +01:00
Luiz Augusto Von Dentz
0493343137 obexd: Fix not unregistering transfer when completed 2012-12-04 22:48:21 +01:00
Luiz Augusto Von Dentz
0dff3b37be obexd: Fix memory leak when freeing transfer parameters 2012-12-04 22:48:21 +01:00
Luiz Augusto Von Dentz
4e5782eb00 obexd: Fix crash on pbap client when message was already replied/freed 2012-12-04 22:48:21 +01:00
Luiz Augusto Von Dentz
757db74df7 obexd: Fix not replying error when transfer could not be started 2012-12-04 22:48:21 +01:00
Luiz Augusto Von Dentz
fc180e2f74 obexd: Replace uses of debug with DBG 2012-12-04 22:48:21 +01:00
Luiz Augusto von Dentz
97c6683e95 obexd: Add dynamic debug feature 2012-12-04 22:48:21 +01:00
Luiz Augusto von Dentz
6ba70b4e55 obexd: Fix possible memory leak 2012-12-04 22:48:21 +01:00
Vinicius Costa Gomes
e85450cc32 obexd: Fix PullBusinessCard ignoring the file argument
These five commits should solve the issue reported by Daniel Abraham
on the mailing list.
2012-12-04 22:48:16 +01:00