This email list is read-only. Emails sent to this list will be discarded
----------------------------------
ChangeLog | 7 +
client/main.c | 8 +-
client/session.c | 474 ++++++++++++++++++++++++++++++++++++++-------------
configure.ac | 2 +-
doc/client-api.txt | 7 +
src/bluetooth.c | 275 +++++++++---------------------
src/bluetooth.h | 2 +
src/dbus.h | 2 +-
src/main.c | 97 ++++-------
src/manager.c | 418 ++++++++++++++++++++++++++++++++++++----------
src/obex.c | 110 +++++++++----
src/obex.h | 21 ++-
test/send-files | 6 +
13 files changed, 924 insertions(+), 505 deletions(-)
New commits:
commit b39e5b3eecb0473a261bb1e95c954076ecec89f4
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Sun Nov 9 18:10:59 2008 +0100
Release 0.7
commit 37780892a0c8b8524263b43d78a1460c93889c65
Merge: 297c4f71b53e2d1589e0d8cbc50a748545f09d0b
415218be51bf7e1b27831d6598a3f7bb45b9c4e7
Author: Johan Hedberg <[EMAIL PROTECTED]>
Date: Thu Nov 6 23:33:14 2008 +0200
Merge branch 'devel' of git://git.infradead.org/users/vcgomes/obexd
commit 415218be51bf7e1b27831d6598a3f7bb45b9c4e7
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Thu Nov 6 18:15:11 2008 -0300
Check for allocation failure when sending messages to the agent
commit 13d215c711cc01c951a32a0fdde2e7840f5d15cd
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Thu Nov 6 15:31:23 2008 -0300
A little simplification
Moving transfer termination (closing and freeing it)
inside unregister_tranfer, to avoid repeated code.
commit 5612f8a03aeb1ded8e6c4a64e2a0866f68a03803
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Thu Nov 6 12:11:17 2008 -0300
Removes memory leaks when the transfer ends
commit 297c4f71b53e2d1589e0d8cbc50a748545f09d0b
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Thu Nov 6 18:15:11 2008 -0300
Check for allocation failure when sending messages to the agent
commit 389de8a5767df99d59e4478f66e709414edab08f
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Thu Nov 6 15:31:23 2008 -0300
A little simplification
Moving transfer termination (closing and freeing it)
inside unregister_tranfer, to avoid repeated code.
commit cff8b1d7497cac2873fd498161ea4c53391d6d8c
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Thu Nov 6 12:11:17 2008 -0300
Removes memory leaks when the transfer ends
commit f7cfc3424eb1a730fdb07a5dbf5cedc521d73027
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Wed Nov 5 17:51:27 2008 -0300
Implements CreateFolder
commit 82b593fac3c758792b5b228218c845c96a5ef3ad
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Wed Nov 5 16:57:13 2008 -0300
Adds Error to Agent methods
We needed a way to inform the agent that some error happened
during a transfer.
commit 93e13b8aa7a9479c1a69c94350f46235d346963d
Author: Johan Hedberg <[EMAIL PROTECTED]>
Date: Thu Nov 6 11:54:53 2008 +0200
Remove unecessary variable
commit 7bd5026d2610e38170974f5ea04f061e196f3fac
Author: Claudio Takahasi <[EMAIL PROTECTED]>
Date: Wed Nov 5 16:31:42 2008 -0300
Ignore NULL sent in x-obex/folder-listing replies
Some broken implementations send send NULL at the ending
of the listing.
commit f9d96d39c5074a21f9de12f0d7e5bcec87a76c68
Author: Claudio Takahasi <[EMAIL PROTECTED]>
Date: Wed Nov 5 13:47:08 2008 -0300
Fixed segmentation fault: ListFolder doesn't register transfer path
commit ee6aa40617138ebeec2278ab438c01e28b498664
Author: Claudio Takahasi <[EMAIL PROTECTED]>
Date: Wed Nov 5 09:32:56 2008 -0300
Added Delete method for Transfer interface
commit b363c3c41eca3f4f5a0d5f9b71d0a2c2c2abf002
Author: Johan Hedberg <[EMAIL PROTECTED]>
Date: Wed Nov 5 22:07:36 2008 +0200
Fix indentation
commit 4ce7a897e125613305a77191d3b0936bf93bab3e
Author: Luiz Augusto von Dentz <[EMAIL PROTECTED]>
Date: Wed Nov 5 16:47:46 2008 -0300
Close bluetooth socket when bluetoothd is not running.
obexd depend on bluetoothd for both link key and authorization, so it
make no sense to leave a socket listen since obexd will be unable to
accept any incoming connection.
commit 2039a0951a418b5f734600a4aed6fbfb038701da
Author: Johan Hedberg <[EMAIL PROTECTED]>
Date: Wed Nov 5 17:38:21 2008 +0200
Initialize services bit mask to 0
commit f9c392c96afcb7426a534447d5571b618f39b2b2
Author: Johan Hedberg <[EMAIL PROTECTED]>
Date: Wed Nov 5 17:19:37 2008 +0200
Try to reopen the tty once if the connection gets dropped
This ensures that we're back monitoring the tty in case the client sends
a OBEX Disconnect which in the current code always does a
OBEX_TransportDisconnect. This patch is also preparation for the next
step where we should be able to re-initialize the tty through some
external trigger (e.g. a SIGUSR1 signal).
commit a11c92d7da3a3b7890ad7aa75b69ed97ebac1b0c
Author: Johan Hedberg <[EMAIL PROTECTED]>
Date: Wed Nov 5 16:49:26 2008 +0200
Use the OBEX Connect command for server selection
Instead of pre-assigning a specific application profiles(OPP, FTP,
PBAP, etc) for each server, allow one server to have multiple
application profiles and select the one to use with the help of the
Connect commands target header.
commit 3285d80ac04a5b912ae13beaadfd1989e77beace
Author: Johan Hedberg <[EMAIL PROTECTED]>
Date: Wed Nov 5 13:19:53 2008 +0200
Plug memory leaks
commit eb2b875f3eeb90bcf56e17e7912267ccbd77d9fd
Author: Johan Hedberg <[EMAIL PROTECTED]>
Date: Wed Nov 5 13:09:32 2008 +0200
Use cfmakeraw() to setup the tty termios settings.
Without this patch the gadget serial drivers produce easily HUP's and
ERR's on the opened tty file descriptor.
commit 088a10434777d6f6eb87309cfac14d4ffca4b40e
Author: Claudio Takahasi <[EMAIL PROTECTED]>
Date: Tue Nov 4 14:53:41 2008 -0300
Avoid dupplicated records if FindRecords fails when bluetoothd starts after
obexd
commit 5d16a241b3b0c57c5cea55a2615ca6de6e22243b
Author: Claudio Takahasi <[EMAIL PROTECTED]>
Date: Tue Nov 4 14:32:30 2008 -0300
Use adapter ANY path to request authorization
commit aa570ad94a6fe74e57c92e1d3bb3a559b3545a8f
Author: Claudio Takahasi <[EMAIL PROTECTED]>
Date: Tue Nov 4 14:31:19 2008 -0300
Call AddRecord and FindAdapter asynchronously
commit 46dc529b0b95d49f9696a11a205fdc30f6419067
Author: Claudio Takahasi <[EMAIL PROTECTED]>
Date: Mon Nov 3 18:39:35 2008 -0300
Fixed memory leak when GET fails
commit f23f66b82561e92302d5e0eaaf5860ef3089ff09
Author: Claudio Takahasi <[EMAIL PROTECTED]>
Date: Mon Nov 3 18:09:04 2008 -0300
Use utility function to report transfer complete
commit fa7861e071b880cdc0f2adcb55cd40709b6f56ff
Author: Claudio Takahasi <[EMAIL PROTECTED]>
Date: Mon Nov 3 18:01:30 2008 -0300
Use utility function to report transfer progress
commit b7d6d3100e5de7a7da3a40ee13d210cc721aad9a
Author: Claudio Takahasi <[EMAIL PROTECTED]>
Date: Mon Nov 3 17:59:27 2008 -0300
Writing the received data into the file
commit 7911fa9f7b09b35a2c571292a5d712ee905cd0f6
Author: Claudio Takahasi <[EMAIL PROTECTED]>
Date: Mon Nov 3 17:24:10 2008 -0300
Added GetFile implementation
commit 15b288b0b10d7c359d0ddbf551ca51dd035c47ed
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Mon Nov 3 14:42:09 2008 -0300
Removing memory leaks when setting the target filename
commit 61f6598e98d26ce175b7b3376d4fbd9f480baa50
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Mon Nov 3 12:03:47 2008 -0300
Closes the transfer as the transfer finishes
Diff in this email is a maximum of 400 lines.
diff --git a/ChangeLog b/ChangeLog
index 4f2a5cb..24f255b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+ver 0.7:
+ Fix issue with transfers larger than session buffer size.
+ Fix various memory leaks within session handling.
+ Add support for OBEX client session interface.
+ Add support for File Transfer client interface.
+ Add support for using the any adapter object path.
+
ver 0.6:
Use BlueZ service for FTP authorization.
Use BlueZ service for service records.
diff --git a/client/main.c b/client/main.c
index e20eafc..259d4b0 100644
--- a/client/main.c
+++ b/client/main.c
@@ -74,10 +74,14 @@ static void create_callback(struct session_data *session,
void *user_data)
for (i = 0; i < data->files->len; i++) {
const gchar *filename = g_ptr_array_index(data->files, i);
+ gchar *basename = g_path_get_basename(filename);
- if (session_send(session, filename,
- g_path_get_basename(filename)) < 0)
+ if (session_send(session, filename, basename) < 0) {
+ g_free(basename);
break;
+ }
+
+ g_free(basename);
}
done:
diff --git a/client/session.c b/client/session.c
index b7a059d..90926ad 100644
--- a/client/session.c
+++ b/client/session.c
@@ -419,18 +419,103 @@ int session_create(const char *source,
return 0;
}
-static void abort_transfer(struct session_data *session)
+static void agent_request(DBusConnection *conn, const char *agent_name,
+ const char *agent_path, const char *transfer_path)
+{
+ DBusMessage *message;
+
+ if (agent_name == NULL || agent_path == NULL || transfer_path == NULL)
+ return;
+
+ message = dbus_message_new_method_call(agent_name,
+ agent_path, AGENT_INTERFACE, "Request");
+
+ dbus_message_append_args(message,
+ DBUS_TYPE_OBJECT_PATH, &transfer_path,
+ DBUS_TYPE_INVALID);
+
+ g_dbus_send_message(conn, message);
+
+ /* FIXME: Reply needs be handled */
+}
+
+static void agent_notify_progress(DBusConnection *conn, const char *agent_name,
+ const char *agent_path, const char *transfer_path,
+ uint64_t transferred)
+{
+ DBusMessage *message;
+
+ if (agent_name == NULL || agent_path == NULL || transfer_path == NULL)
+ return;
+
+ message = dbus_message_new_method_call(agent_name,
+ agent_path, AGENT_INTERFACE, "Progress");
+ if (message == NULL)
+ return;
+
+ dbus_message_set_no_reply(message, TRUE);
+
+ dbus_message_append_args(message,
+ DBUS_TYPE_OBJECT_PATH, &transfer_path,
+ DBUS_TYPE_UINT64, &transferred,
+ DBUS_TYPE_INVALID);
+
+ g_dbus_send_message(conn, message);
+}
+
+static void agent_notify_complete(DBusConnection *conn, const char *agent_name,
+ const char *agent_path, const char *transfer_path)
+{
+ DBusMessage *message;
+
+ if (agent_name == NULL || agent_path == NULL || transfer_path == NULL)
+ return;
+
+ message = dbus_message_new_method_call(agent_name,
+ agent_path, AGENT_INTERFACE, "Complete");
+ if (message == NULL)
+ return;
+
+ dbus_message_set_no_reply(message, TRUE);
+
+ dbus_message_append_args(message,
+ DBUS_TYPE_OBJECT_PATH, &transfer_path,
+ DBUS_TYPE_INVALID);
+
+ g_dbus_send_message(conn, message);
+
+}
+
+static void agent_notify_error(DBusConnection *conn, const char *agent_name,
+ const char *agent_path, const char *transfer_path,
+ const char *error_msg)
{
DBusMessage *message;
- message = dbus_message_new_method_call(session->agent_name,
- session->agent_path, AGENT_INTERFACE, "Complete");
+ if (agent_name == NULL || agent_path == NULL)
+ return;
+
+ message = dbus_message_new_method_call(agent_name,
+ agent_path, AGENT_INTERFACE, "Error");
+ if (message == NULL)
+ return;
+
+ dbus_message_set_no_reply(message, TRUE);
dbus_message_append_args(message,
- DBUS_TYPE_OBJECT_PATH, &session->transfer_path,
- DBUS_TYPE_INVALID);
+ DBUS_TYPE_OBJECT_PATH, &transfer_path,
+ DBUS_TYPE_STRING, &error_msg,
+ DBUS_TYPE_INVALID);
+
+ g_dbus_send_message(conn, message);
+}
- g_dbus_send_message(session->conn, message);
+static void abort_transfer(struct session_data *session)
+{
+
+ agent_notify_error(session->conn, session->agent_name,
+ session->agent_path, session->transfer_path,
+ "The transfer was cancelled");
gw_obex_xfer_abort(session->xfer, NULL);
@@ -733,18 +818,65 @@ static const GMarkupParser parser = {
NULL
};
+static char *register_transfer(DBusConnection *conn, void *user_data)
+{
+ char *path;
+
+ path = g_strdup_printf("%s/transfer%ju",
+ TRANSFER_BASEPATH, counter++);
+
+ if (g_dbus_register_interface(conn, path,
+ TRANSFER_INTERFACE,
+ transfer_methods, NULL, NULL,
+ user_data, NULL) == FALSE) {
+ g_free(path);
+ return NULL;
+ }
+
+ return path;
+}
+
+static void unregister_transfer(struct session_data *session)
+{
+ gw_obex_xfer_close(session->xfer, NULL);
+ gw_obex_xfer_free(session->xfer);
+ session->xfer = NULL;
+
+ g_free(session->filename);
+ session->filename = NULL;
+
+ g_free(session->name);
+ session->name = NULL;
+
+ if (session->transfer_path == NULL)
+ return;
+
+ g_dbus_unregister_interface(session->conn,
+ session->transfer_path, TRANSFER_INTERFACE);
+ g_free(session->transfer_path);
+ session->transfer_path = NULL;
+}
+
static void list_folder_callback(struct session_data *session,
void *user_data)
{
GMarkupParseContext *ctxt;
DBusMessage *reply;
DBusMessageIter iter;
+ int i;
reply = dbus_message_new_method_return(session->msg);
if (session->filled == 0)
goto done;
+ for (i = session->filled - 1; i > 0; i--) {
+ if (session->buffer[i] != '\0')
+ break;
+
+ session->filled--;
+ }
+
dbus_message_iter_init_append(reply, &iter);
ctxt = g_markup_parse_context_new(&parser, 0, &iter, NULL);
@@ -760,40 +892,159 @@ done:
session->msg = NULL;
}
+static void get_file_callback(struct session_data *session, void *user_data)
+{
+
+}
+
static void get_xfer_progress(GwObexXfer *xfer, gpointer user_data)
{
struct callback_data *callback = user_data;
struct session_data *session = callback->session;
- gint bsize, bread;
+ gint bsize, bread, err = 0;
gboolean ret;
- /* FIXME: Check buffer overflow */
bsize = sizeof(session->buffer) - session->filled;
ret = gw_obex_xfer_read(xfer, session->buffer + session->filled,
- bsize, &bread, NULL);
- session->filled += bread;
- if (ret == FALSE)
+ bsize, &bread, &err);
+
+ /* For GetFile reply on the first received stream */
+ if (session->fd > 0 && session->msg) {
+ DBusMessage *reply;
+
+ if (ret == FALSE)
+ reply = g_dbus_create_error(session->msg,
+ "org.openobex.Error.Failed",
+ OBEX_ResponseToString(err));
+ else
+ reply = dbus_message_new_method_return(session->msg);
+
+ g_dbus_send_message(session->conn, reply);
+
+ dbus_message_unref(session->msg);
+ session->msg = NULL;
+ }
+
+ if (ret == FALSE) {
+ fprintf(stderr, "gw_obex_xfer_read(): %s\n",
+ OBEX_ResponseToString(err));
goto complete;
+ }
+
+ session->filled += bread;
+ session->transferred += bread;
+ if (session->size == 0)
+ session->size = gw_obex_xfer_object_size(xfer);
- if (bread == gw_obex_xfer_object_size(xfer))
+ if (session->fd > 0) {
+ write(session->fd, session->buffer, bread);
+ session->filled = 0;
+ }
+
+ if (session->transferred == session->size)
goto complete;
gw_obex_xfer_flush(xfer, NULL);
+ agent_notify_progress(session->conn, session->agent_name,
+ session->agent_path, session->transfer_path,
+ session->transferred);
+
return;
complete:
- gw_obex_xfer_close(xfer, NULL);
- gw_obex_xfer_free(xfer);
- callback->session->xfer = NULL;
+
+ if (ret == TRUE)
+ agent_notify_complete(session->conn, session->agent_name,
+ session->agent_path, session->transfer_path);
+ else
+ agent_notify_error(session->conn, session->agent_name,
+ session->agent_path, session->transfer_path,
+ "Error getting object");
+
+ unregister_transfer(session);
callback->func(callback->session, callback->data);
+ if (session->fd > 0)
+ close(session->fd);
+
session_unref(callback->session);
g_free(callback);
}
+int session_get(struct session_data *session, const char *type,
+ const char *filename, const char *targetname,
+ session_callback_t func)
+{
+ struct callback_data *callback;
+ GwObexXfer *xfer;
+ int err, fd = 0;
+
+ if (session->obex == NULL)
+ return -ENOTCONN;
+
+ if (type == NULL) {
+ if (targetname == NULL)
+ targetname = filename;
+
+ fd = open(targetname, O_WRONLY | O_CREAT, 0600);
+ if (fd < 0) {
+ err = errno;
+ fprintf(stderr, "open(): %s(%d)\n", strerror(err), err);
+ return -err;
+ }
+
+ session->transfer_path = register_transfer(session->conn,
session);
+ if (session->transfer_path == NULL) {
+ if (fd)
+ close(fd);
+
+ return -EIO;
+ }
+ }
+
+ session->fd = fd;
+ session->transferred = 0;
+ session->size = 0;
+ session->filename = g_strdup(filename);
+ session->name = g_strdup(targetname);
+
+ session_ref(session);
+
+ xfer = gw_obex_get_async(session->obex,
+ filename, type, NULL);
+ if (xfer == NULL) {
+ close(session->fd);
+ session_unref(session);
+ return -EIO;
+ }
+
+ callback = g_try_malloc0(sizeof(*callback));
+ if (callback == NULL) {
+ close(session->fd);
+ session_unref(session);
+ gw_obex_xfer_free(xfer);
+ return -ENOMEM;
+ }
+
+ callback->session = session;
+ callback->func = func;
+
+ gw_obex_xfer_set_callback(xfer, get_xfer_progress, callback);
+
+ session->xfer = xfer;
+
+ agent_request(session->conn, session->agent_name,
+ session->agent_path, session->transfer_path);
+
+ agent_notify_progress(session->conn, session->agent_name,
+ session->agent_path, session->transfer_path, 0);
+
+ return 0;
+}
+
static DBusMessage *change_folder(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
@@ -819,6 +1070,21 @@ static DBusMessage *change_folder(DBusConnection
*connection,
static DBusMessage *create_folder(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
+ struct session_data *session = user_data;
+ const char *folder;
+ int err;
+
+ if (dbus_message_get_args(message, NULL,
+ DBUS_TYPE_STRING, &folder,
+ DBUS_TYPE_INVALID) == FALSE)
+ return g_dbus_create_error(message,
+ "org.openobex.Error.InvalidArguments", NULL);
+
+ if (gw_obex_mkdir(session->obex, folder, &err) == FALSE)
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits