From 1324c3108ff3982bd1010bb3a4d3439b611dd975 Mon Sep 17 00:00:00 2001 From: Wu zheng Date: Wed, 23 Oct 2013 11:12:04 +0800 Subject: [PATCH] Add set root folder function Change-Id: Ib3e179d7b8a7b602ea9560e036c77495da9e9d34 --- obexd/src/main.c | 8 ++++++++ obexd/src/manager.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ obexd/src/obexd.h | 3 +++ 3 files changed, 61 insertions(+) diff --git a/obexd/src/main.c b/obexd/src/main.c index 80645f8..29e832a 100644 --- a/obexd/src/main.c +++ b/obexd/src/main.c @@ -179,6 +179,14 @@ static GOptionEntry options[] = { { NULL }, }; +#ifdef __TIZEN_PATCH__ +void obex_option_set_root_folder(const char *root) +{ + g_free(option_root); + option_root = g_strdup(root); +} +#endif + gboolean obex_option_auto_accept(void) { return option_autoaccept; diff --git a/obexd/src/manager.c b/obexd/src/manager.c index 326e56f..f431f86 100644 --- a/obexd/src/manager.c +++ b/obexd/src/manager.c @@ -222,6 +222,52 @@ static gboolean session_target_exists(const GDBusPropertyTable *property, return os->service->target ? TRUE : FALSE; } +#ifdef __TIZEN_PATCH__ +static DBusMessage *set_root(DBusConnection *conn, DBusMessage *msg, + const char *root, void *data) +{ + DBG("new_root: %s", root); + + /* Change the option root path (using in filesystem) */ + obex_option_set_root_folder(root); + + return dbus_message_new_method_return(msg); +} + +static DBusMessage *set_property(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessageIter iter; + DBusMessageIter sub; + const char *property; + + if (!dbus_message_iter_init(msg, &iter)) + return invalid_args(msg); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) + return invalid_args(msg); + + dbus_message_iter_get_basic(&iter, &property); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) + return invalid_args(msg); + dbus_message_iter_recurse(&iter, &sub); + + if (g_str_equal("Root", property)) { + const char *root; + + if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) + return invalid_args(msg); + dbus_message_iter_get_basic(&sub, &root); + + return set_root(conn, msg, root, data); + } + + return invalid_args(msg); +} +#endif + static char *target2str(const uint8_t *t) { if (!t) @@ -457,6 +503,10 @@ static const GDBusMethodTable manager_methods[] = { GDBUS_ARGS({ "agent", "o" }), NULL, register_agent) }, { GDBUS_METHOD("UnregisterAgent", GDBUS_ARGS({ "agent", "o" }), NULL, unregister_agent) }, +#ifdef __TIZEN_PATCH__ + { GDBUS_METHOD("SetProperty", + GDBUS_ARGS({ "property", "sv" }), NULL, set_property) }, +#endif { } }; diff --git a/obexd/src/obexd.h b/obexd/src/obexd.h index 42c3c4d..41f28d6 100644 --- a/obexd/src/obexd.h +++ b/obexd/src/obexd.h @@ -41,3 +41,6 @@ gboolean obex_option_auto_accept(void); const char *obex_option_root_folder(void); gboolean obex_option_symlinks(void); const char *obex_option_capability(void); +#ifdef __TIZEN_PATCH__ +void obex_option_set_root_folder(const char *root); +#endif -- 2.7.4