summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2013-04-25 16:15:45 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-05-03 17:10:20 +0300
commitaff1619ca4bdab4d5a64847866b73854afff7757 (patch)
tree441cb06a11494b6f1557b483ece23529232be533 /client
parent26497cb23cf58a115ced964419b2d770411117d4 (diff)
downloadconnman-aff1619ca4bdab4d5a64847866b73854afff7757.tar.gz
connman-aff1619ca4bdab4d5a64847866b73854afff7757.tar.bz2
connman-aff1619ca4bdab4d5a64847866b73854afff7757.zip
client: Implement Agent Release and Cancel method calls
Unref the saved Agent D-Bus message on Release and Cancel. In response to the Release method call unnregister Agent interface and quit if in non-interactive mode.
Diffstat (limited to 'client')
-rw-r--r--client/agent.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/client/agent.c b/client/agent.c
index 239c1028..b12cdcaa 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -32,10 +32,12 @@
#include <gdbus.h>
+#include "input.h"
#include "dbus_helpers.h"
#include "agent.h"
static bool agent_registered = false;
+static DBusMessage *agent_message = NULL;
#define AGENT_INTERFACE "net.connman.Agent"
@@ -49,7 +51,55 @@ static char *agent_path(void)
return path;
}
+static void pending_message_remove()
+{
+ if (agent_message != NULL) {
+ dbus_message_unref(agent_message);
+ agent_message = NULL;
+ }
+}
+
+static void pending_command_complete(char *message)
+{
+ __connmanctl_save_rl();
+
+ fprintf(stdout, message);
+
+ __connmanctl_redraw_rl();
+
+ if (__connmanctl_is_interactive() == true)
+ __connmanctl_command_mode();
+ else
+ __connmanctl_agent_mode("", NULL);
+}
+
+static DBusMessage *agent_release(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ g_dbus_unregister_interface(connection, agent_path(), AGENT_INTERFACE);
+ agent_registered = false;
+
+ pending_message_remove();
+ pending_command_complete("Agent unregistered by ConnMan\n");
+
+ if (__connmanctl_is_interactive() == false)
+ __connmanctl_quit();
+
+ return dbus_message_new_method_return(message);
+}
+
+static DBusMessage *agent_cancel(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ pending_message_remove();
+ pending_command_complete("Agent request cancelled by ConnMan\n");
+
+ return dbus_message_new_method_return(message);
+}
+
static const GDBusMethodTable agent_methods[] = {
+ { GDBUS_METHOD("Release", NULL, NULL, agent_release) },
+ { GDBUS_METHOD("Cancel", NULL, NULL, agent_cancel) },
{ },
};