Commit Graph

1215 Commits

Author SHA1 Message Date
Christian Fetzer
5316ed07d5 obexd: Fix SetPath response
This fixes the issue, that failed attempts to the OBEX SetPath command
are not propagated through the D-Bus API.

Trace:

  method call sender=:1.942 -> dest=:1.934 serial=8
  path=/org/bluez/obex/client/session3;
  interface=org.bluez.obex.MessageAccess1; member=SetFolder
     string "test"
  method return sender=:1.934 -> dest=:1.942 reply_serial=8

  method call sender=:1.946 -> dest=:1.945 serial=8
  path=/org/bluez/obex/client/session0;
  interface=org.bluez.obex.MessageAccess1; member=SetFolder
     string "test"
  error sender=:1.945 -> dest=:1.946
  error_name=org.bluez.obex.Error.Failed reply_serial=8
     string "Not Found"
2013-05-23 14:34:31 -07:00
Luiz Augusto von Dentz
b5afba2181 obexd: Fix using the same prefix for client and server sessions
This avoids using the same path for different sessions which fail since
it cannot register a second time causing an unexpected error.
2013-05-10 14:56:25 +03:00
Lucas De Marchi
94862127b4 obexd: Get rid of gchar
Use plain char instead of gchar.
2013-05-02 09:03:48 +03:00
Lucas De Marchi
65878a7806 obexd: Get rid of gint
Use plain int instead of gint. In glib gint is always a typedef to int,
so it's safe to use it even for callbacks with glib.
2013-05-01 09:08:53 +03:00
Luiz Augusto von Dentz
8140306965 obexd: Fix make distcheck
../obexd/client/map.c:43:17: fatal error: sdp.h: No such file or directory
2013-04-17 17:46:55 +03:00
Christian Fetzer
4ee201a588 obexd: Read service attributes when instantiating MAP session
Parse the service attributes mas_instance_id and supported_message_types
from the transport's service attributes as soon as a connection is
established.
2013-04-17 13:43:45 +03:00
Christian Fetzer
f4bf087572 obexd: Add obc_session_get_attribute to session
This adds a obc_session_get_attribute function to the client session.
The function allows querying the session specific service attributes.
2013-04-17 13:43:45 +03:00
Christian Fetzer
cb59ec7853 obexd: Add bluetooth_getattribute to Bluetooth transport
This function makes the cached SDP attributes available for the profile
implementations.
2013-04-17 13:43:38 +03:00
Christian Fetzer
e0c744c9a8 obexd: Add getattribute to obc_transport
This adds a getattribute function pointer to obc_transport, which allows
transports to provide the session specific service attributes.
2013-04-17 13:31:05 +03:00
Christian Fetzer
e163a91514 obexd: Cache SDP record in bluetooth transport
This caches the SDP record of the active session in the Bluetooth
transport.
2013-04-17 13:31:05 +03:00
Christian Fetzer
518a51ad1d obexd: Automatically setup notification connection for MAP client
This automatically establishes the MNS connection when the MAS client
session is started and terminates the MNS connection when the MAS client
session is closed.

The MAP client controls the notification channel using the
SetNotificationRegistration function. The MSE will connect/disconnect
the MNS connection accordingly.
2013-04-10 14:56:46 +03:00
Christian Fetzer
eecf2d8c21 obexd: Enable MNS server 2013-04-10 14:51:09 +03:00
Christian Fetzer
ef4b34eb5e obexd: Add Message Notification Service (MNS) server
This implements the server role of the MAP Message Notification Service
(MNS) which is part of the MAP Client Equipment (MCE) device.

After successful registration, the MNS will receive event reports,
notifying about state changes on the server side.

Possible events are: NewMessages, DeliverySuccess, SendingSuccess,
DeliveryFailure, SendingFailure, MemoryFull, MemoryAvailable,
MessageDeleted, MessageShift
2013-04-10 14:51:09 +03:00
Lucas De Marchi
ee27640ef6 obexd: Use gcc builtin instead of g_atomic
g_atomic_* end up using G_STATIC_ASSERT, causing gcc 4.8 to yell due to
-Wunused-local-typedefs.

/usr/include/glib-2.0/glib/gmacros.h:162:53: error: typedef ‘_GStaticAssertCompileTimeAssertion_2’ locally defined but not used [-Werror=unused-local-typedefs]
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]

Most of the uses of atomic operations were wrong. They were fixed as
well. If we are using atomic operations, reading the variable again
later for logging is not an option, we should use the return of the
atomic function used to fetch the variable.
2013-04-09 07:02:19 +09:00
Christian Fetzer
ed3b98a683 obexd: Handle absolute paths in obc_session_setpath
For absolute paths (that begin with '/'), obc_session_setpath gets called
twice to reset to the root folder.
This is caused by an empty first element in the folder list created by g_strsplit.

This solution sets the index to the folder array correctly and ignores
empty folder names. This fixes as well paths with double slashes.

Trace for 'SetFolder /telecom':

< ACL data: handle 21 flags 0x00 dlen 21
    L2CAP(d): cid 0x0040 len 17 [psm 3]
      RFCOMM(d): UIH: cr 1 dlci 32 pf 0 ilen 13 fcs 0xd8
        OBEX: SetPath cmd(f): len 13 flags 2 constants 0
        Connection ID (0xcb) = 17
        Name (0x01) = Unicode length 0
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 21 packets 1
> ACL data: handle 21 flags 0x02 dlen 11
    L2CAP(d): cid 0x0041 len 7 [psm 3]
      RFCOMM(d): UIH: cr 0 dlci 32 pf 0 ilen 3 fcs 0x2
        OBEX: SetPath rsp(f): status 200 len 3
< ACL data: handle 21 flags 0x00 dlen 21
    L2CAP(d): cid 0x0040 len 17 [psm 3]
      RFCOMM(d): UIH: cr 1 dlci 32 pf 0 ilen 13 fcs 0xd8
        OBEX: SetPath cmd(f): len 13 flags 2 constants 0
        Connection ID (0xcb) = 17
        Name (0x01) = Unicode length 0
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 21 packets 1
> ACL data: handle 21 flags 0x02 dlen 11
    L2CAP(d): cid 0x0041 len 7 [psm 3]
      RFCOMM(d): UIH: cr 0 dlci 32 pf 0 ilen 3 fcs 0x2
        OBEX: SetPath rsp(f): status 200 len 3
< ACL data: handle 21 flags 0x00 dlen 37
    L2CAP(d): cid 0x0040 len 33 [psm 3]
      RFCOMM(d): UIH: cr 1 dlci 32 pf 0 ilen 29 fcs 0xd8
        OBEX: SetPath cmd(f): len 29 flags 2 constants 0
        Connection ID (0xcb) = 17
        Name (0x01) = Unicode length 16
        0000: 00 74 00 65 00 6c 00 65  00 63 00 6f 00 6d 00 00  .t.e.l.e.c.o.m..
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 21 packets 1
> ACL data: handle 21 flags 0x02 dlen 11
    L2CAP(d): cid 0x0041 len 7 [psm 3]
      RFCOMM(d): UIH: cr 0 dlci 32 pf 0 ilen 3 fcs 0x2
        OBEX: SetPath rsp(f): status 200 len 3
2013-02-22 10:41:52 +02:00
Christian Fetzer
7f80320654 obexd: Remove obc_session_setpath limit
obc_session_setpath is able to handle multiple folder changes at once.
This removes the limit, that was introduced because of PBAP's limitation
to 3 levels (75d32c6b3a).

Other profiles like MAP might have deeper folder hierarchies.
2013-02-22 10:41:52 +02:00
Christian Fetzer
e859c03231 obexd: Add PushMessage
Push message has been implemented similar to send file (OPP),
the message to send (in bMessage format) is read from a file.
2013-02-07 13:49:00 +02:00
Christian Fetzer
970333272c obexd: Add parameter Status to GetMessageListing response
The parameter Status indicates the status of reception of the message.
It can be used to differentiate between messages with a reception status
of "completed", "fractioned" and "notification".

This parameter got lost when obexd was refactored to use of D-Bus properties.
The documentation and the parsing code for it was still there.
2013-01-18 13:58:50 +02:00
Christian Fetzer
41d1d89cf5 obexd: Add parameter AttachmentSize to GetMessageListing response
The parameter AttachmentSize indicates if the message contains
any attachment and their overall size (in bytes).
2013-01-18 13:58:50 +02:00
Christian Fetzer
ff52e50288 obexd: Add parameter Text to GetMessageListing response
The Text flag indicates if the message contains any textual content
or has binary content only.
2013-01-18 13:58:49 +02:00
Christian Fetzer
cb4a4de99c obexd: Move parse_size function in map.c
This reorders msg_parsers and moves the function parse_size
to match the order in the MAP specification.
2013-01-18 13:58:49 +02:00
Christian Fetzer
f9998e750f obexd: Add parameter SubjectLength to map_list_messages
This parameter allows the client to request a maximum length of the
parameter "subject" in the messages listing.
2013-01-18 13:58:42 +02:00
Christian Fetzer
363e55779d obexd: Remove transferred file only if the GET operation failed
Since 9606375649 xfer_complete() sets the
transfer status rather than the size. Adapt obc_transfer_free to check
for the completed status to avoid deletion of completed transfers.
2013-01-14 17:42:06 +02:00
Christian Fetzer
86de586204 obexd: Change behavior of parse_filter_read
Calls to ListMessages with filter 'Read' set to true should
request the MSE to send read messages only.

The old code requests the MSE to send unread messages only.
This behavior is not matching the other filters.
2013-01-14 17:42:05 +02:00
Christian Fetzer
d0b4698c8f obexd: Use defines for values in parse_filter_read parse_filter_priority 2013-01-14 17:42:05 +02:00
Christian Fetzer
499d0a4eaf obexd: Fix segfault in parse_filter_read and parse_filter_priority
Calls to ListMessages with filter 'Read' or 'Priority' caused a segfault
in parse_filter_read / parse_filter_priority. The functions read
D-Bus boolean values (uint32) into uint8.

0  0x00007ffff730332d in ?? () from /usr/lib/libdbus-1.so.3
1  0x00007ffff7304219 in dbus_message_iter_next () from /usr/lib/libdbus-1.so.3
2  0x000000000043ef0f in parse_message_filters (
    apparam=<error reading variable: Cannot access memory at address 0x7ffffeffff08>,
    iter=<error reading variable: Cannot access memory at address 0x7ffffeffff00>)
    at obexd/client/map.c:1246
2013-01-14 17:42:05 +02:00
Christian Fetzer
90322684e0 obexd: Fix FILTER_ALL in MAP client to set 16 bit
The MAP specification defines ParameterMask as a bitmask of 32 bit / 4 bytes.
For the lower 16 bit the specification defines parameters, the higher 16 bit
remain reserved for future use. Therefore FILTER_ALL is set to 0x0000FFFF.
(Reserved bits have to be set to 0)

In addition this fixes the issue that ListFilterFields didn't show all fields.
2013-01-14 17:42:04 +02:00
Christian Fetzer
a1d1ea32df obexd: Fix infinite loop in ListMessages with filter "Types"
Calls to ListMessages with filter 'Types' make obexd hang in an infinite loop.
This is caused by a missing dbus_message_iter_next in parse_filter_type.

0  0x00007ffff7304ca7 in dbus_message_iter_get_basic ()
   from /usr/lib/libdbus-1.so.3
1  0x0000000000434fba in parse_filter_type (iter=0x7fffffffd7d0, apparam=
    0x6987f0) at obexd/client/map.c:1086
2  parse_message_filters (iter=0x7fffffffd730, apparam=0x6987f0)
    at obexd/client/map.c:1222
3  map_list_messages (connection=<optimized out>, message=0x669ae0, user_data=
    0x698a60) at obexd/client/map.c:1273
4  0x00000000004109a1 in process_message (connection=0x662b20,
    message=<optimized out>, iface_user_data=<optimized out>,
    method=<optimized out>, method=<optimized out>) at gdbus/object.c:285
5  0x00007ffff7308e15 in ?? () from /usr/lib/libdbus-1.so.3
6  0x00007ffff72fb070 in dbus_connection_dispatch ()
   from /usr/lib/libdbus-1.so.3
7  0x000000000040e3d8 in message_dispatch (data=0x662b20)
    at gdbus/mainloop.c:76
8  0x00007ffff703d3cb in ?? () from /usr/lib/libglib-2.0.so.0
9  0x00007ffff703c845 in g_main_context_dispatch ()
   from /usr/lib/libglib-2.0.so.0
10 0x00007ffff703cb78 in ?? () from /usr/lib/libglib-2.0.so.0
11 0x00007ffff703cf72 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
12 0x000000000040df82 in main (argc=1, argv=0x7fffffffdd88)
    at obexd/src/main.c:323
2013-01-14 17:42:04 +02:00
Christian Fetzer
0b6a5b5068 obexd: Add property exist functions to map client
This fixes crashes in MAP client when the server does not send optional properties.

0  0x00007ffff6a792c5 in raise () from /usr/lib/libc.so.6
1  0x00007ffff6a7a748 in abort () from /usr/lib/libc.so.6
2  0x00007ffff731c145 in ?? () from /usr/lib/libdbus-1.so.3
3  0x00007ffff7312a25 in ?? () from /usr/lib/libdbus-1.so.3
4  0x00007ffff73050d6 in dbus_message_iter_append_basic () from /usr/lib/libdbus-1.so.3
5  0x0000000000433cc5 in get_replyto (property=<optimized out>, iter=<optimized out>,
    data=<optimized out>) at obexd/client/map.c:484
6  0x00000000004103b6 in append_property (p=p@entry=0x6594c0 <map_msg_properties+192>,
    dict=dict@entry=0x7fffffffd8e0, iface=0x6a3720) at gdbus/object.c:547
7  0x0000000000410472 in append_properties (data=data@entry=0x6a3720, iter=iter@entry=
    0x7fffffffd960) at gdbus/object.c:576
8  0x00000000004104d1 in append_interface (data=0x6a3720, user_data=0x7fffffffda40)
    at gdbus/object.c:591
9  0x00007ffff7058a4d in g_slist_foreach () from /usr/lib/libglib-2.0.so.0
10 0x0000000000411d05 in emit_interfaces_added (data=0x6a2ff0) at gdbus/object.c:623
11 process_changes (user_data=0x6a2ff0) at gdbus/object.c:1006
12 0x00007ffff703c845 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
13 0x00007ffff703cb78 in ?? () from /usr/lib/libglib-2.0.so.0
14 0x00007ffff703cf72 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
15 0x000000000040df82 in main (argc=1, argv=0x7fffffffdd88) at obexd/src/main.c:323
2013-01-14 17:42:04 +02:00
Christian Fetzer
5e358f18b1 obexd: Handle empty path name in SetPath
If the empty path is given, an empty name should be sent via OBEX.
Currently the name field is not set at all and later checks which
depend on data->index will access invalid memory regions as g_strsplit
returns NULL when an empty string is given.

0  0x000000000041a181 in g_obex_setpath (obex=obex@entry=0x662eb0, path=
    0x20 <Address 0x20 out of bounds>, func=func@entry=0x42d300 <setpath_cb>,
    user_data=user_data@entry=0x668f10, err=err@entry=0x7fffffffda08)
    at gobex/gobex.c:1397
1  0x000000000042d395 in setpath_cb (obex=0x662eb0, err=0x0, rsp=<optimized out>,
    user_data=0x668f10) at obexd/client/session.c:902
2  0x0000000000418e54 in handle_response (obex=obex@entry=0x662eb0, err=err@entry=0x0,
    rsp=rsp@entry=0x668f40) at gobex/gobex.c:948
3  0x0000000000419d7a in incoming_data (io=<optimized out>, cond=<optimized out>,
    user_data=0x662eb0) at gobex/gobex.c:1191
4  0x00007ffff703c845 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
5  0x00007ffff703cb78 in ?? () from /usr/lib/libglib-2.0.so.0
6  0x00007ffff703cf72 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
7  0x000000000040def2 in main (argc=1, argv=0x7fffffffdd88) at obexd/src/main.c:323
2013-01-14 17:42:03 +02:00
Marcel Holtmann
9472de3087 obexd: Don't bother with trying to handle SIGPIPE 2013-01-11 09:45:40 -08:00
Marcel Holtmann
86cd7d0886 obexd: Fix includes for uuid.h 2013-01-09 20:30:43 -08:00
Marcel Holtmann
c59ae99e67 obexd: Remove the total silly usage of gchar and replace it with char 2013-01-04 12:27:55 -08:00
Marcin Zawiejski
6a8cb20ef5 obexd: Fix crash while removing session
Crash occurs when removing a session with RemoveSession while another
session has been created but not yet registered.

Backtrace:
0  __strcmp_ssse3 () at ../sysdeps/i386/i686/multiarch/strcmp-ssse3.S:233
1  0xb758e7c3 in g_str_equal () from /lib/i386-linux-gnu/libglib-2.0.so.0
2  0x08073e56 in find_session (path=0x85c8504 "/org/bluez/obex/session0") at obexd/client/manager.c:146
3  remove_session (connection=0x85bc5e0, message=0x85bca98, user_data=0x0) at obexd/client/manager.c:216
4  0x08055f6f in process_message (connection=0x85bc5e0, message=<optimized out>, iface_user_data=0x0,
    method=<optimized out>, method=<optimized out>) at gdbus/object.c:285
5  0xb7672666 in ?? () from /lib/i386-linux-gnu/libdbus-1.so.3
6  0xb76624d7 in dbus_connection_dispatch () from /lib/i386-linux-gnu/libdbus-1.so.3
7  0x080532f8 in message_dispatch (data=0x85bc5e0) at gdbus/mainloop.c:76
8  0xb759f6bf in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
9  0xb759e9e3 in g_main_context_dispatch () from /lib/i386-linux-gnu/libglib-2.0.so.0
10 0xb759ed80 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
11 0xb759f1db in g_main_loop_run () from /lib/i386-linux-gnu/libglib-2.0.so.0
12 0x08052d74 in main (argc=1, argv=0xbfb344e4) at obexd/src/main.c:323
2013-01-02 16:13:13 +02:00
Marcel Holtmann
651090b3e5 obexd: The function g_dbus_pending_property_error has no return value 2012-12-29 21:24:26 -08:00
Cristian Rodríguez
2e772c22ef obexd: Fix missing config.h includes 2012-12-23 18:59:25 -08:00
Marcel Holtmann
9ba1d688bf obexd: Move __terminated into signal handler 2012-12-23 10:16:53 -08:00
Johan Hedberg
4794363f19 obexd: Update string enumeration values to lower case 2012-12-22 18:30:05 +02:00
Anderson Lizardo
ec25822178 obexd: Simplify org.bluez.Error.InvalidArguments handling
Use a helper function to void code duplication.
2012-12-22 00:15:45 +02:00
Luiz Augusto von Dentz
fdb28673f4 obexd: Fix crash while attempting to authorize transfer
Transfer need to be registered before it is authorized because
AuthorizePush takes the transfer path and the agent may try to access
the transfer properties to figure out its details.
2012-12-21 23:26:13 +02:00
Johan Hedberg
c3f7df1042 obexd: Update Authorize call to AuthorizePush API 2012-12-21 22:20:10 +02:00
Johan Hedberg
cbf8891907 obexd: Implement Session transfer property 2012-12-21 22:03:45 +02:00
Johan Hedberg
59efeba8cb obexd: Fix session path generation in manager_unregister_session 2012-12-21 22:00:01 +02:00
Johan Hedberg
ee699dbc6a obexd: Implement Time transfer property 2012-12-21 21:53:14 +02:00
Johan Hedberg
2837514fc7 obexd: Implement Type transfer property 2012-12-21 21:42:41 +02:00
Marcel Holtmann
c72af721b9 obexd: Add a few more debug statements 2012-12-21 18:56:50 +01:00
Marcel Holtmann
0c388f5a77 obexd: There is only one daemon 2012-12-21 17:55:39 +01:00
Luiz Augusto von Dentz
405afea4a5 obexd: Add Session property to Transfer interface
This property indicates the session object path.
2012-12-21 17:06:10 +02:00
Luiz Augusto von Dentz
432dffc3d2 obexd: Remove unused code
obc_transfer_append_dbus_properties as the code now uses
g_dbus_get_properties to append transfer properties.
2012-12-21 17:06:10 +02:00
Luiz Augusto von Dentz
da068075ce obexd: Rename Progress property to Transferred 2012-12-21 14:53:42 +02:00