Commit graph

8 commits

Author SHA1 Message Date
Patrick Ohly 40f84d7fc1 TransportAgent: simplified timeout API
Instead of allowing users of the API to register a callback
which can choose between aborting and time out, only accept
the timeout duration and always treat that as a timeout.

The advanced functionality wasn't used and the simplification
makes implementing the API easier.
2011-02-09 15:02:13 +01:00
Chen Congwu 4704efac52 ObexTransportAgent: Fix valgrind warnings (MB#10091)
Patrick found some valgrind warnings and put a prelimilary version
of part of the fix. Finished the work in this patch.

Added a libical timezone supression rule, with an additonal patch
in libsynthesis and the updated supression rules, valgrind is happy.
2010-03-12 06:33:13 -08:00
Patrick Ohly 73b088914c syncevo-dbus-server + OBEX: transport was not enabled (MB #9436)
The syncevo-dbus-server never instantiated an ObexTransportAgent
in its own createTransportAgent() implementation because that code
hadn't been updated.

Instead of duplicating the code for instantiating the various agents,
now DBusSync::createTransportAgent() calls the underlying
SyncContext::createTransportAgent(). It passes its glib main loop
pointer and expects to get an agent which uses that.

It is a bit inconsistent that we have to pass a GMainLoop pointer
through an interface that is supposed to be independent of glib.
Therefore it is declared as "void *". When adding other main loop
integrations, we can either add more parameters or reinterpret the
content of that pointer.

This patch also cleans up the reference counting of the GMainLoop.
Now the reference is no longer handed over to the agent. That solution
was not entirely exception-safe. Instead the constructed agent has to
increase the reference count itself, or do whatever is necessary
instead to keep using the loop. In the ObexTransportAgent, a reference
to the right GMainContext is kept.
2010-02-10 10:01:17 +01:00
Chen Congwu 25a525adb1 ObexTransportAgent: fix typos 2009-12-24 12:10:22 +08:00
Chen Congwu 802c21f2e7 Revert "ObexTransportAgent: fixing an obex event leak for SyncML server case"
This reverts commit fe124636b3.
Fix the problem in the SmartPtr.
2009-12-03 17:25:16 +08:00
Chen Congwu fe124636b3 ObexTransportAgent: fixing an obex event leak for SyncML server case
ObexEvent which wraps an underlying OBEX event source is expected to
be released during ObexTransportAgent class destructing or during
wait() where we copied it to the local stack.

The assumption was: wait() is called after each send(). This is not
correct for SyncML server case. Therefore later shutdown() sets up a
new ObexEvent and overwrites the old one without releasing the resource.
This may also occurs if user calls send(), send() without calling wait()
in between (Rarely, though).

The solution is to check explictly whether m_obexEvent already wraps a resource
before assigning a new value to it.
2009-11-30 11:44:38 +01:00
Chen Congwu b3a88ef0d6 ObexTransportAgent: compiling fixes MB#5188
Add ENABLE_OBEX wrapper with the two files, so that it will include nothing if
no libopenobex is installed.
Include OBEX header after Bluetooth header to avoid a redefinition error.
2009-11-17 17:04:37 +08:00
Chen Congwu 3f04de4833 OBEX Client Transport: in-process OBEX client (binding over Bluetooth, #5188)
Outgoing OBEX connection implementation, only binds over Bluetooth now.

Integrates with gmainloop so that the opertaions in the transport will not
block the whole application.

It uses Bluetooth sdp to automatically discovery the corresponding service
channel providing SyncML service; the process is asynchronous. Callback
sdp_source_cb and sdp_callback are used for this purpose. sdp_source_cb is a
GIOChannel watch event callback which poll the underlying sdp socket, the
sdp_callback is invoked by Bluez during processing sdp packets.

Callback obex_fd_source and obex_callback are related to the OBEX processing
(Connect, Put, Get, Disconnect). obex_fd_source is a GIOChannel event source
callback which poll the underlying OBEX interface, the obex_callback is
invoked by libopenobex when it needs to delivering events to the application.

Connect is splited by several steps, see CONNECT_STATUS for more detail.
Disconnect will be invoked when shutDown is called or processing in
obex_fd_source_cb is failed, timeout occurs or user suspention. It will first
try to send a "Disconnect" command to server and waiting for response. If
such opertaion is failed it will disconnect anyway. It is important to call
wait after shutdown to ensure the transport is properly cleaned up.

Each callback function is protected by a "Try-catch" block to ensure no
exception is thrown in the C stack. This is important otherwise the application
will abort if an exception is really thrown.

Using several smart pointers to avoid potential resource leak. After initialized
the resource is held by ObexTransportAgent. Copy the smart pointer to the local
stack entering a function and return to ObexTransportAgent if the whole
process is correct and we want to continue. First, it ensures the resource is
released at least during ObexTransportAgent destructing; Second, it can also
try to release the resource as early as possible. For example cxxptr<ObexEvent>
will release the resource during each wait() so that the underlying poll will
not be processed if no transport activity is expected by the application.

"SyncURL" is used consistently for the address of the remote peer to
contact with.
2009-11-17 13:15:54 +08:00