This email list is read-only. Emails sent to this list will be discarded
----------------------------------
client/main.c | 2 +
client/session.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++++---
client/session.h | 6 ++-
doc/client-api.txt | 12 +++++
4 files changed, 132 insertions(+), 9 deletions(-)
New commits:
commit 1249dfe12027fe7c1e6662458101d6e9c4180a4d
Merge: f1b50bd5d6e8809cf41f14afc5e5db133edf8eb7
0910ed5b86426289d7e091abcc3b5658c6e7b11f
Author: Johan Hedberg <[EMAIL PROTECTED]>
Date: Wed Nov 12 19:30:27 2008 +0200
Merge branch 'devel' of git://git.infradead.org/users/vcgomes/obexd into
vcgomes
commit 0910ed5b86426289d7e091abcc3b5658c6e7b11f
Author: Claudio Takahasi <[EMAIL PROTECTED]>
Date: Wed Nov 12 14:11:49 2008 -0300
Fixes the dbus signature of the folder listing method
commit f1b50bd5d6e8809cf41f14afc5e5db133edf8eb7
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Tue Nov 11 19:26:14 2008 -0300
Fixes the dbus signature of the folder listing method
commit c8aea830f609e1540690667a1310183f9bad61d0
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Tue Nov 11 18:50:08 2008 -0300
Do not remove owner watch in the disconnect remove watch callback
commit ff7a6e06d2e6ab9c0cb274ac7e89b4ef5eb75acd
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Tue Nov 11 18:42:54 2008 -0300
Separate Session and Transfer properties
commit e6706f176a973c47e8e1339ce2c3fb706a7010ba
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Tue Nov 11 10:31:00 2008 -0300
Removes the owner disconnect watch when removing closing the session
commit c079afae0aaef1526cc5f867417a087e76db2692
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Mon Nov 10 15:30:27 2008 -0300
Dealing with folder listings
When the object size is unknown ends the transfer as soon as the first
packet arrives.
commit a88ac8b19a9cc8c56679cfc73dd2ebf4b124043e
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Mon Nov 10 14:57:46 2008 -0300
Do not try to send a error notification if the path is invalid
commit a5c33c4b1eba9f7248c6a465ba77a4983c50f62e
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Mon Nov 10 10:48:43 2008 -0300
Closes the session when the client leaves the bus
commit a2aaa3c0b87e7721c0e32a33ff741512e289fdef
Author: Vinicius Costa Gomes <[EMAIL PROTECTED]>
Date: Mon Nov 10 10:37:14 2008 -0300
Adds Session Close method
Diff in this email is a maximum of 400 lines.
diff --git a/client/main.c b/client/main.c
index 259d4b0..9595af9 100644
--- a/client/main.c
+++ b/client/main.c
@@ -60,6 +60,8 @@ static void create_callback(struct session_data *session,
void *user_data)
goto done;
}
+ session->owner = g_strdup(data->sender);
+
if (session->target != NULL) {
session_register(session);
g_dbus_send_reply(data->connection, data->message,
diff --git a/client/session.c b/client/session.c
index 90926ad..4bbb0bb 100644
--- a/client/session.c
+++ b/client/session.c
@@ -115,6 +115,7 @@ static void session_unref(struct session_data *session)
g_free(session->filename);
g_free(session->agent_name);
g_free(session->agent_path);
+ g_free(session->owner);
g_free(session);
}
@@ -492,7 +493,7 @@ static void agent_notify_error(DBusConnection *conn, const
char *agent_name,
{
DBusMessage *message;
- if (agent_name == NULL || agent_path == NULL)
+ if (agent_name == NULL || agent_path == NULL || transfer_path == NULL)
return;
message = dbus_message_new_method_call(agent_name,
@@ -596,7 +597,7 @@ static void append_entry(DBusMessageIter *dict,
dbus_message_iter_close_container(dict, &entry);
}
-static DBusMessage *get_properties(DBusConnection *connection,
+static DBusMessage *transfer_get_properties(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
struct session_data *session = user_data;
@@ -646,7 +647,7 @@ static DBusMessage *transfer_cancel(DBusConnection
*connection,
}
static GDBusMethodTable transfer_methods[] = {
- { "GetProperties", "", "a{sv}", get_properties },
+ { "GetProperties", "", "a{sv}", transfer_get_properties },
{ "Cancel", "", "", transfer_cancel },
{ }
};
@@ -732,10 +733,104 @@ static DBusMessage *release_agent(DBusConnection
*connection,
return dbus_message_new_method_return(message);
}
+static void session_shutdown(struct session_data *session)
+{
+ if (session->transfer_path) {
+ agent_notify_error(session->conn, session->agent_name,
+ session->agent_path, session->transfer_path,
+ "The transfer was cancelled");
+
+ g_dbus_unregister_interface(session->conn,
+ session->transfer_path, TRANSFER_INTERFACE);
+ g_free(session->transfer_path);
+
+ session->transfer_path = NULL;
+ }
+
+ if (session->xfer) {
+ gw_obex_xfer_abort(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;
+
+ /* the transfer was holding a session ref */
+ session_unref(session);
+ }
+
+ session_unref(session);
+}
+
+static DBusMessage *close_session(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ struct session_data *session = user_data;
+ const gchar *sender;
+
+ sender = dbus_message_get_sender(message);
+ if (g_str_equal(sender, session->owner) == FALSE)
+ return g_dbus_create_error(message,
+ "org.openobex.Error.NotAuthorized",
+ "Not Authorized");
+
+ g_dbus_remove_watch(session->conn, session->owner_watch);
+
+ session_shutdown(session);
+
+ return dbus_message_new_method_return(message);
+}
+
+static void owner_disconnected(DBusConnection *connection, void *user_data)
+{
+ struct session_data *session = user_data;
+
+ session_shutdown(session);
+}
+
+static DBusMessage *session_get_properties(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ struct session_data *session = user_data;
+ DBusMessage *reply;
+ DBusMessageIter iter, dict;
+ char addr[18];
+ char *paddr = addr;
+
+ reply = dbus_message_new_method_return(message);
+ if (!reply)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &iter);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+
+ ba2str(&session->src, addr);
+ append_entry(&dict, "Source", DBUS_TYPE_STRING, &paddr);
+
+ ba2str(&session->dst, addr);
+ append_entry(&dict, "Destination", DBUS_TYPE_STRING, &paddr);
+
+ if (session->agent_path)
+ append_entry(&dict, "AgentPath", DBUS_TYPE_STRING,
&session->agent_path);
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
static GDBusMethodTable session_methods[] = {
- { "GetProperties", "", "a{sv}", get_properties },
+ { "GetProperties", "", "a{sv}", session_get_properties },
{ "AssignAgent", "o", "", assign_agent },
{ "ReleaseAgent", "o", "", release_agent },
+ { "Close", "", "", close_session },
{ }
};
@@ -862,7 +957,7 @@ static void list_folder_callback(struct session_data
*session,
{
GMarkupParseContext *ctxt;
DBusMessage *reply;
- DBusMessageIter iter;
+ DBusMessageIter iter, array;
int i;
reply = dbus_message_new_method_return(session->msg);
@@ -878,11 +973,16 @@ static void list_folder_callback(struct session_data
*session,
}
dbus_message_iter_init_append(reply, &iter);
-
- ctxt = g_markup_parse_context_new(&parser, 0, &iter, NULL);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &array);
+ ctxt = g_markup_parse_context_new(&parser, 0, &array, NULL);
g_markup_parse_context_parse(ctxt, session->buffer,
session->filled, NULL);
g_markup_parse_context_free(ctxt);
+ dbus_message_iter_close_container(&iter, &array);
session->filled = 0;
@@ -941,6 +1041,9 @@ static void get_xfer_progress(GwObexXfer *xfer, gpointer
user_data)
session->filled = 0;
}
+ if (session->size == -1)
+ goto complete;
+
if (session->transferred == session->size)
goto complete;
@@ -1386,6 +1489,10 @@ int session_register(struct session_data *session)
return -EIO;
}
+ session->owner_watch = g_dbus_add_disconnect_watch(session->conn,
+ session->owner, owner_disconnected, session,
+ NULL);
+
session_ref(session);
return 0;
diff --git a/client/session.h b/client/session.h
index 6e400ae..16c3392 100644
--- a/client/session.h
+++ b/client/session.h
@@ -46,12 +46,14 @@ struct session_data {
GwObexXfer *xfer;
char buffer[4096];
int filled;
- uint64_t size;
- uint64_t transferred;
+ ssize_t size;
+ size_t transferred;
gchar *filename;
gchar *agent_name;
gchar *agent_path;
guint agent_watch;
+ gchar *owner; /* Session owner */
+ guint owner_watch;
GPtrArray *pending;
};
diff --git a/doc/client-api.txt b/doc/client-api.txt
index 102cb2c..9f2c461 100644
--- a/doc/client-api.txt
+++ b/doc/client-api.txt
@@ -60,6 +60,14 @@ Methods dict GetProperties()
Release a previously assigned OBEX agent.
+Properties string Source [read-only]
+
+ string Destination [read-only]
+
+ string AgentPath [read-only]
+
+ Object Path of the assigned agent. This property will
+ not be present if there is no assigned agent.
File Transfer hierarchy
=======================
@@ -147,6 +155,10 @@ Properties string Name [read-only]
Size of the transferred object. If the size is
unknown, then this property will not be present.
+ string Filename [read-only]
+
+ Complete name of the file being received or sent.
+
Agent hierarchy
===============
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits