summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2012-09-03 14:17:13 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-09-04 12:08:53 +0300
commita79d3c464d7eec5ae071f1b94faadbc3733fe1e4 (patch)
treeff3926ca6db55a37489ab4b29b34988dc672b160
parente67e0c606669bdf092672b87d51002b8d9c17d0a (diff)
downloadconnman-a79d3c464d7eec5ae071f1b94faadbc3733fe1e4.tar.gz
connman-a79d3c464d7eec5ae071f1b94faadbc3733fe1e4.tar.bz2
connman-a79d3c464d7eec5ae071f1b94faadbc3733fe1e4.zip
agent: Implement Agent API Cancel() method call
Clean up the queue and cancel the current message at the agent, if any. Split out the actual cancel message sending as it will be used separately from the rest of the code.
-rw-r--r--src/agent.c54
-rw-r--r--src/connman.h2
2 files changed, 56 insertions, 0 deletions
diff --git a/src/agent.c b/src/agent.c
index 92cea77a..132aa858 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -150,6 +150,25 @@ fail:
return -ESRCH;
}
+static int agent_send_cancel(void)
+{
+ DBusMessage *message;
+
+ if (agent_sender == NULL)
+ return 0;
+
+ message = dbus_message_new_method_call(agent_sender, agent_path,
+ CONNMAN_AGENT_INTERFACE, "Cancel");
+ if (message != NULL) {
+ dbus_message_set_no_reply(message, TRUE);
+ g_dbus_send_message(connection, message);
+ return 0;
+ }
+
+ connman_warn("Failed to send Cancel message to agent");
+ return -ESRCH;
+}
+
static void agent_receive_message(DBusPendingCall *call, void *user_data)
{
struct agent_data *queue_data = user_data;
@@ -199,6 +218,41 @@ static int agent_queue_message(struct connman_service *service,
return agent_send_next_request();
}
+void __connman_agent_cancel(struct connman_service *service)
+{
+ GList *item, *next;
+ struct agent_data *queued_req;
+
+ DBG("service %p", service);
+
+ item = agent_queue;
+
+ while (item != NULL) {
+ next = g_list_next(item);
+ queued_req = item->data;
+
+ if (queued_req->service == service || service == NULL) {
+ agent_data_free(queued_req);
+ agent_queue = g_list_delete_link(agent_queue, item);
+ }
+
+ item = next;
+ }
+
+ if (agent_request == NULL)
+ return;
+
+ if (agent_request->service != service && service != NULL)
+ return;
+
+ agent_data_free(agent_request);
+ agent_request = NULL;
+
+ agent_send_cancel();
+
+ agent_send_next_request();
+}
+
static connman_bool_t check_reply_has_dict(DBusMessage *reply)
{
const char *signature = DBUS_TYPE_ARRAY_AS_STRING
diff --git a/src/connman.h b/src/connman.h
index 305f09f9..120de302 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -84,6 +84,8 @@ void __connman_counter_cleanup(void);
struct connman_service;
+void __connman_agent_cancel(struct connman_service *service);
+
int __connman_service_add_passphrase(struct connman_service *service,
const gchar *passphrase);
typedef void (* authentication_cb_t) (struct connman_service *service,