From 3871079dc42a75b1253d1c5e4ee9dccd4f6d715f Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Fri, 24 Oct 2008 14:13:41 -0300 Subject: [PATCH] obexd: Added session methods skeleton --- obexd/client/main.c | 4 +++- obexd/client/session.c | 42 +++++++++++++++++++++++++++++++++++++++--- obexd/client/session.h | 1 + 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/obexd/client/main.c b/obexd/client/main.c index 8a8cfb21d..7338e4e9e 100644 --- a/obexd/client/main.c +++ b/obexd/client/main.c @@ -62,8 +62,10 @@ static void create_callback(struct session_data *session, void *user_data) g_dbus_send_reply(data->connection, data->message, DBUS_TYPE_INVALID); - if (session->target != NULL) + if (session->target != NULL) { + session_register(session); goto done; + } session_set_agent(session, data->sender, data->agent); diff --git a/obexd/client/session.c b/obexd/client/session.c index a4af3710a..367a17b12 100644 --- a/obexd/client/session.c +++ b/obexd/client/session.c @@ -44,7 +44,8 @@ #define AGENT_INTERFACE "org.openobex.Agent" #define TRANSFER_INTERFACE "org.openobex.Transfer" -#define TRANSFER_BASEPATH "/org/openobex" +#define SESSION_INTERFACE "org.openobex.Session" +#define BASEPATH "/org/openobex" #define FOLDER_BROWSING_UUID "\xF9\xEC\x7B\xC4\x95\x3C\x11\xD2\x98\x4E\x52\x54\x00\xDC\x9E\x09" @@ -504,6 +505,25 @@ static GDBusMethodTable transfer_methods[] = { { } }; +static DBusMessage *assign_agent(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + return dbus_message_new_method_return(message); +} + +static DBusMessage *release_agent(DBusConnection *connection, + DBusMessage *message, void *user_data) +{ + return dbus_message_new_method_return(message); +} + +static GDBusMethodTable session_methods[] = { + { "GetProperties", "", "a{sv}", get_properties }, + { "AssignAgent", "o", "", assign_agent }, + { "ReleaseAgent", "o", "", release_agent }, + { } +}; + static void xfer_progress(GwObexXfer *xfer, gpointer user_data) { struct session_data *session = user_data; @@ -611,8 +631,8 @@ int session_send(struct session_data *session, const char *filename) session->filename = g_strdup(filename); session->name = g_path_get_basename(filename); - session->path = g_strdup_printf("%s/transfer%ld", - TRANSFER_BASEPATH, counter++); + session->path = g_strdup_printf("%s/transfer%llu", + BASEPATH, counter++); if (g_dbus_register_interface(session->conn, session->path, TRANSFER_INTERFACE, @@ -652,3 +672,19 @@ int session_send(struct session_data *session, const char *filename) return 0; } + +int session_register(struct session_data *session) +{ + session->path = g_strdup_printf("%s/session%llu", + BASEPATH, counter++); + + if (g_dbus_register_interface(session->conn, session->path, + SESSION_INTERFACE, + session_methods, NULL, NULL, + session, NULL) == FALSE) + return -EIO; + + session_ref(session); + + return 0; +} diff --git a/obexd/client/session.h b/obexd/client/session.h index d74706b6a..39f74b820 100644 --- a/obexd/client/session.h +++ b/obexd/client/session.h @@ -59,3 +59,4 @@ int session_create(const char *source, int session_set_agent(struct session_data *session, const char *name, const char *path); int session_send(struct session_data *session, const char *filename); +int session_register(struct session_data *session); -- 2.47.3