summaryrefslogtreecommitdiff
path: root/src/task.c
diff options
context:
space:
mode:
authorMohamed Abbas <mabbas@linux.intel.com>2011-11-15 13:06:15 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2011-11-15 13:41:44 +0100
commit36f57036dcf4faf2327709be40aef2e9fa0209d5 (patch)
treece235455eb13076d713d7f4b97cabaadde67381b /src/task.c
parentc75a3bd3b009b8894fa14d130709642d1bc0c8c6 (diff)
downloadconnman-36f57036dcf4faf2327709be40aef2e9fa0209d5.tar.gz
connman-36f57036dcf4faf2327709be40aef2e9fa0209d5.tar.bz2
connman-36f57036dcf4faf2327709be40aef2e9fa0209d5.zip
task: Allow vpn plugins to send reply
Change task notify to allow client to send dbus reply. This will allow vpn plugin to send requested user/password info.
Diffstat (limited to 'src/task.c')
-rw-r--r--src/task.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/task.c b/src/task.c
index 41710cdc..d26d6170 100644
--- a/src/task.c
+++ b/src/task.c
@@ -372,6 +372,7 @@ static DBusHandlerResult task_filter(DBusConnection *connection,
struct connman_task *task;
struct notify_data *notify;
const char *path, *member;
+ DBusMessage *reply = NULL;
if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_METHOD_CALL)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -388,29 +389,32 @@ static DBusHandlerResult task_filter(DBusConnection *connection,
if (task == NULL)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- if (dbus_message_get_no_reply(message) == FALSE) {
- DBusMessage *reply;
+ member = dbus_message_get_member(message);
+ if (member == NULL)
+ goto send_reply;
+
+ notify = g_hash_table_lookup(task->notify, member);
+ if (notify == NULL)
+ goto send_reply;
+
+ if (notify->func)
+ reply = notify->func(task, message, notify->data);
+
+send_reply:
+ if (dbus_message_get_no_reply(message) == FALSE &&
+ reply == NULL) {
reply = dbus_message_new_method_return(message);
if (reply == NULL)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
+ }
+ if (reply != NULL) {
dbus_connection_send(connection, reply, NULL);
dbus_message_unref(reply);
}
- member = dbus_message_get_member(message);
- if (member == NULL)
- return DBUS_HANDLER_RESULT_HANDLED;
-
- notify = g_hash_table_lookup(task->notify, member);
- if (notify == NULL)
- return DBUS_HANDLER_RESULT_HANDLED;
-
- if (notify->func)
- notify->func(task, message, notify->data);
-
return DBUS_HANDLER_RESULT_HANDLED;
}