1 From c742b40860851f1659e801d0a652f854f6783bd1 Mon Sep 17 00:00:00 2001
2 Message-Id: <c742b40860851f1659e801d0a652f854f6783bd1.1334369310.git.paul.eggleton@linux.intel.com>
3 In-Reply-To: <cover.1334369310.git.paul.eggleton@linux.intel.com>
4 References: <cover.1334369310.git.paul.eggleton@linux.intel.com>
5 From: Paul Eggleton <paul.eggleton@linux.intel.com>
6 Date: Sat, 14 Apr 2012 02:32:43 +0100
7 Subject: [PATCH 4/6] Handle WiFi authentication using an agent
9 Register an agent within the applet which shows an appropriate dialog
10 when credentials are requested upon connecting to a secured wireless
13 Thanks to Julien Massot for providing the underlying agent library code.
15 Upstream-Status: Submitted
17 Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
19 applet/Makefile.am | 3 +-
20 applet/agent.c | 209 +++++++++++++++++++++++
21 applet/agent.h | 29 +++
23 common/Makefile.am | 13 +-
24 common/connman-agent.c | 426 ++++++++++++++++++++++++++++++++++++++++++++++
25 common/connman-agent.h | 77 +++++++++
26 common/connman-agent.xml | 26 +++
27 common/marshal.list | 2 +
28 9 files changed, 783 insertions(+), 5 deletions(-)
29 create mode 100644 applet/agent.c
30 create mode 100644 applet/agent.h
31 create mode 100644 common/connman-agent.c
32 create mode 100644 common/connman-agent.h
33 create mode 100644 common/connman-agent.xml
35 diff --git a/applet/Makefile.am b/applet/Makefile.am
36 index fe582ef..2e7c157 100644
37 --- a/applet/Makefile.am
38 +++ b/applet/Makefile.am
40 bin_PROGRAMS = connman-applet
42 connman_applet_SOURCES = main.c \
43 - properties.h properties.c status.h status.c
44 + properties.h properties.c status.h \
45 + status.c agent.h agent.c
47 connman_applet_LDADD = $(top_builddir)/common/libcommon.a \
48 @GTK_LIBS@ @DBUS_LIBS@
49 diff --git a/applet/agent.c b/applet/agent.c
51 index 0000000..b12d337
57 + * Connection Manager
59 + * Agent implementation based on code from bluez-gnome
61 + * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org>
62 + * Copyright (C) 2006-2007 Bastien Nocera <hadess@hadess.net>
63 + * Copyright (C) 2012 Intel Corporation
66 + * This program is free software; you can redistribute it and/or modify
67 + * it under the terms of the GNU General Public License as published by
68 + * the Free Software Foundation; either version 2 of the License, or
69 + * (at your option) any later version.
71 + * This program is distributed in the hope that it will be useful,
72 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
73 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74 + * GNU General Public License for more details.
76 + * You should have received a copy of the GNU General Public License
77 + * along with this program; if not, write to the Free Software
78 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
88 +#include <glib/gi18n.h>
91 +#include <dbus/dbus-glib.h>
93 +#include <connman-agent.h>
99 + gpointer request_data;
101 + GHashTable *entries;
104 +static struct input_data *input_data_inst = NULL;
106 +static void input_free(struct input_data *input)
108 + gtk_widget_destroy(input->dialog);
110 + g_hash_table_destroy(input->entries);
112 + if( input_data_inst == input )
113 + input_data_inst = NULL;
118 +static void request_input_callback(GtkWidget *dialog,
119 + gint response, gpointer user_data)
121 + GHashTableIter iter;
122 + gpointer key, value;
123 + GValue *retvalue = NULL;
125 + struct input_data *input = user_data;
127 + if (response == GTK_RESPONSE_OK) {
128 + GHashTable *reply = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
129 + g_hash_table_iter_init (&iter, input->entries);
130 + while (g_hash_table_iter_next (&iter, &key, &value)) {
131 + text = gtk_entry_get_text((GtkEntry *)value);
133 + retvalue = g_slice_new0(GValue);
134 + g_value_init(retvalue, G_TYPE_STRING);
135 + g_value_set_string(retvalue, text);
136 + g_hash_table_insert(reply, g_strdup(key), retvalue);
140 + connman_agent_request_input_set_reply(input->request_data, reply);
142 + connman_agent_request_input_abort(input->request_data);
148 +static void show_dialog(gpointer data, gpointer user_data)
150 + struct input_data *input = data;
152 + gtk_widget_show_all(input->dialog);
154 + gtk_window_present(GTK_WINDOW(input->dialog));
157 +static void request_input_dialog(GHashTable *request,
158 + gpointer request_data)
164 + struct input_data *input;
165 + GHashTableIter iter;
166 + gpointer key, value;
169 + input = g_try_malloc0(sizeof(*input));
173 + input->request_data = request_data;
175 + input->entries = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
177 + dialog = gtk_dialog_new();
178 + gtk_window_set_title(GTK_WINDOW(dialog), _("Connection Manager"));
179 + gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
180 + gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
181 + gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
182 + gtk_window_set_urgency_hint(GTK_WINDOW(dialog), TRUE);
183 + gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
184 + input->dialog = dialog;
186 + gtk_dialog_add_button(GTK_DIALOG(dialog),
187 + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
188 + gtk_dialog_add_button(GTK_DIALOG(dialog),
189 + GTK_STOCK_OK, GTK_RESPONSE_OK);
191 + elems = g_hash_table_size(request);
192 + table = gtk_table_new(elems+1, 2, FALSE);
193 + gtk_table_set_row_spacings(GTK_TABLE(table), 4);
194 + gtk_table_set_col_spacings(GTK_TABLE(table), 20);
195 + gtk_container_set_border_width(GTK_CONTAINER(table), 12);
196 + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
198 + label = gtk_label_new(_("Please provide some network information:"));
199 + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
200 + gtk_table_attach(GTK_TABLE(table), label, 0, 2, 0, 1,
201 + GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
203 + g_hash_table_iter_init (&iter, request);
205 + while (g_hash_table_iter_next (&iter, &key, &value)) {
206 + label = gtk_label_new((const char *)key);
207 + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
208 + gtk_table_attach(GTK_TABLE(table), label, 0, 1, i, i+1,
209 + GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
211 + entry = gtk_entry_new();
212 + gtk_entry_set_max_length(GTK_ENTRY(entry), 64);
213 + gtk_entry_set_width_chars(GTK_ENTRY(entry), 16);
214 + gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
215 + gtk_table_attach(GTK_TABLE(table), entry, 1, 2, i, i+1,
216 + GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
217 + g_hash_table_insert(input->entries, g_strdup(key), entry);
222 + input_data_inst = input;
224 + g_signal_connect(G_OBJECT(dialog), "response",
225 + G_CALLBACK(request_input_callback), input);
227 + show_dialog(input, NULL);
230 +static void request_input(const char *service_id,
231 + GHashTable *request, gpointer request_data, gpointer user_data)
233 + request_input_dialog(request, request_data);
236 +static gboolean cancel_request(DBusGMethodInvocation *context,
237 + gpointer user_data)
239 + if( input_data_inst ) {
240 + connman_agent_request_input_abort(input_data_inst->request_data);
242 + input_free(input_data_inst);
248 +int setup_agents(void)
250 + ConnmanAgent *agent = connman_agent_new();
251 + connman_agent_setup(agent, "/org/gnome/connman/applet");
253 + connman_agent_set_request_input_func(agent, request_input, agent);
254 + connman_agent_set_cancel_func(agent, cancel_request, agent);
256 + connman_agent_register(agent);
261 +void cleanup_agents(void)
264 diff --git a/applet/agent.h b/applet/agent.h
266 index 0000000..d85676b
272 + * Connection Manager
274 + * Agent implementation based on code from bluez-gnome
276 + * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org>
277 + * Copyright (C) 2006-2007 Bastien Nocera <hadess@hadess.net>
278 + * Copyright (C) 2012 Intel Corporation
281 + * This program is free software; you can redistribute it and/or modify
282 + * it under the terms of the GNU General Public License as published by
283 + * the Free Software Foundation; either version 2 of the License, or
284 + * (at your option) any later version.
286 + * This program is distributed in the hope that it will be useful,
287 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
288 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
289 + * GNU General Public License for more details.
291 + * You should have received a copy of the GNU General Public License
292 + * along with this program; if not, write to the Free Software
293 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
297 +int setup_agents(void);
298 +void cleanup_agents(void);
299 diff --git a/applet/main.c b/applet/main.c
300 index 68a77b1..d06ce60 100644
305 #include "properties.h"
309 static gboolean global_ready = FALSE;
310 static gint global_strength = -1;
311 @@ -132,6 +133,7 @@ static void manager_init(DBusGConnection *connection)
312 "/", "net.connman.Manager");
314 properties_create(manager, manager_property_changed, NULL);
318 static void manager_cleanup(void)
319 @@ -148,6 +150,7 @@ static void name_owner_changed(DBusGProxy *proxy, const char *name,
322 properties_enable(manager);
325 properties_disable(manager);
326 status_unavailable();
327 diff --git a/common/Makefile.am b/common/Makefile.am
328 index ef1267a..5bfff19 100644
329 --- a/common/Makefile.am
330 +++ b/common/Makefile.am
331 @@ -3,19 +3,21 @@ noinst_LIBRARIES = libcommon.a
333 libcommon_a_SOURCES = connman-dbus.c connman-dbus.h connman-dbus-glue.h \
334 connman-client.h connman-client.c \
335 - instance.h instance.c
336 + instance.h instance.c \
337 + connman-agent.h connman-agent.c
339 BUILT_SOURCES = marshal.h marshal.c \
340 connman-dbus-glue.h \
343 + connman-agent-glue.h
345 -nodist_libcommon_a_SOURCES = connman-dbus-glue.h instance-glue.h
346 +nodist_libcommon_a_SOURCES = connman-dbus-glue.h instance-glue.h connman-agent-glue.h
348 CLEANFILES = $(BUILT_SOURCES)
350 AM_CFLAGS = @DBUS_CFLAGS@ @GTK_CFLAGS@
352 -EXTRA_DIST = marshal.list instance.xml connman-dbus.xml
353 +EXTRA_DIST = marshal.list instance.xml connman-dbus.xml connman-agent.xml
355 MAINTAINERCLEANFILES = Makefile.in
357 @@ -30,3 +32,6 @@ instance-glue.h: instance.xml
359 connman-dbus-glue.h: connman-dbus.xml
360 $(DBUS_BINDING_TOOL) --prefix=connman --mode=glib-client --output=$@ $<
362 +connman-agent-glue.h: connman-agent.xml
363 + $(DBUS_BINDING_TOOL) --prefix=connman_agent --mode=glib-server --output=$@ $<
364 diff --git a/common/connman-agent.c b/common/connman-agent.c
366 index 0000000..769bf27
368 +++ b/common/connman-agent.c
371 + * Connection Manager Agent implementation
374 + * - Julien MASSOT <jmassot@aldebaran-robotics.com>
375 + * - Paul Eggleton <paul.eggleton@linux.intel.com>
377 + * Copyright (C) 2012 Aldebaran Robotics
378 + * Copyright (C) 2012 Intel Corporation
380 + * This library is free software; you can redistribute it and/or
381 + * modify it under the terms of the GNU Lesser General Public
382 + * License version 2.1 as published by the Free Software Foundation.
384 + * This library is distributed in the hope that it will be useful,
385 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
386 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
387 + * Lesser General Public License for more details.
389 + * You should have received a copy of the GNU Lesser General Public
390 + * License along with this library; if not, write to the Free Software
391 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
394 +#include <dbus/dbus-glib.h>
395 +#include <dbus/dbus-glib-lowlevel.h>
398 +#include "connman-agent.h"
399 +#include "connman-dbus.h"
401 +#define CONNMAN_AGENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
402 + CONNMAN_TYPE_AGENT, ConnmanAgentPrivate))
405 + AGENT_ERROR_REJECT,
409 +#define AGENT_ERROR (agent_error_quark())
411 +#define AGENT_ERROR_TYPE (agent_error_get_type())
413 +static GQuark agent_error_quark(void)
415 + static GQuark quark = 0;
417 + quark = g_quark_from_static_string("Agent");
422 +#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
424 +static GType agent_error_get_type(void)
426 + static GType etype = 0;
428 + static const GEnumValue values[] = {
429 + ENUM_ENTRY(AGENT_ERROR_REJECT, "Rejected"),
430 + ENUM_ENTRY(AGENT_ERROR_RETRY, "Retry"),
434 + etype = g_enum_register_static("Agent", values);
440 +typedef struct _ConnmanAgentPrivate ConnmanAgentPrivate;
442 +typedef struct _PendingRequest PendingRequest;
444 +struct _PendingRequest {
445 + DBusGMethodInvocation *context;
446 + ConnmanAgent *agent;
449 +struct _ConnmanAgentPrivate {
452 + DBusGConnection *connection;
453 + DBusGProxy *connman_proxy;
455 + ConnmanAgentRequestInputFunc input_func;
456 + gpointer input_data;
458 + ConnmanAgentCancelFunc cancel_func;
459 + gpointer cancel_data;
461 + ConnmanAgentReleaseFunc release_func;
462 + gpointer release_data;
464 + ConnmanAgentDebugFunc debug_func;
465 + gpointer debug_data;
469 +G_DEFINE_TYPE(ConnmanAgent, connman_agent, G_TYPE_OBJECT)
471 +static inline void debug(ConnmanAgent *agent, const char *format, ...)
475 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
477 + if (priv->debug_func == NULL)
480 + va_start(ap, format);
482 + if (vsnprintf(str, sizeof(str), format, ap) > 0)
483 + priv->debug_func(str, priv->debug_data);
488 +gboolean connman_agent_request_input_set_reply(gpointer request_data, GHashTable *reply)
490 + PendingRequest *pendingrequest = request_data;
492 + if (request_data == NULL)
495 + dbus_g_method_return(pendingrequest->context, reply);
497 + g_free(pendingrequest);
502 +gboolean connman_agent_request_input_abort(gpointer request_data)
504 + PendingRequest *pendingrequest = request_data;
506 + if (request_data == NULL)
509 + result = g_error_new(AGENT_ERROR, AGENT_ERROR_REJECT,
510 + "Input request rejected");
511 + dbus_g_method_return_error(pendingrequest->context, result);
512 + g_clear_error(&result);
513 + g_free(pendingrequest);
518 +static gboolean connman_agent_request_input_cb(const GHashTable *reply, gpointer user_data)
521 + PendingRequest *pendingrequest = user_data;
523 + dbus_g_method_return(pendingrequest->context, reply);
525 + g_free(pendingrequest);
529 +gboolean connman_agent_report_error(ConnmanAgent *agent,
530 + const char *path, const char *error,
531 + DBusGMethodInvocation *context)
534 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
536 + debug(agent, "connection %s, reports an error: %s", path, error);
537 + result = g_error_new(AGENT_ERROR, AGENT_ERROR_RETRY,
539 + dbus_g_method_return_error(context, result);
540 + g_clear_error(&result);
545 +gboolean connman_agent_request_input(ConnmanAgent *agent,
546 + const char *path, GHashTable *fields,
547 + DBusGMethodInvocation *context)
549 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
550 + const char *sender = dbus_g_method_get_sender(context);
551 + char *name = NULL, *type = NULL;
553 + PendingRequest *pendingrequest = NULL;
555 + debug(agent, "request %s, sender %s", path, sender);
557 + if (fields == NULL)
560 + if (priv->input_func != NULL) {
561 + id = g_strsplit(path, "/net/connman/service/", 2);
562 + if (g_strv_length(id) == 2) {
563 + pendingrequest = g_try_new0(PendingRequest, 1);
564 + pendingrequest->context = context;
565 + pendingrequest->agent = agent;
566 + priv->input_func(id[1], fields, pendingrequest, priv->input_data);
574 +gboolean connman_agent_cancel(ConnmanAgent *agent,
575 + DBusGMethodInvocation *context)
577 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
578 + const char *sender = dbus_g_method_get_sender(context);
579 + gboolean result = FALSE;
581 + debug(agent, "Request Canceled %s", sender);
583 + if (g_str_equal(sender, priv->busname) == FALSE)
586 + if (priv->cancel_func)
587 + result = priv->cancel_func(context, priv->cancel_data);
592 +gboolean connman_agent_release(ConnmanAgent *agent,
593 + DBusGMethodInvocation *context)
595 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
596 + const char *sender = dbus_g_method_get_sender(context);
598 + debug(agent, "agent %p sender %s", agent, sender);
600 + if (g_str_equal(sender, priv->busname) == FALSE)
603 + dbus_g_method_return(context);
608 +#include "connman-agent-glue.h"
610 +static void connman_agent_init(ConnmanAgent *agent)
612 + debug(agent, "agent %p", agent);
615 +static void connman_agent_finalize(GObject *agent)
617 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
619 + if (priv->connman_proxy != NULL) {
620 + g_object_unref(priv->connman_proxy);
623 + g_free(priv->path);
624 + g_free(priv->busname);
625 + dbus_g_connection_unref(priv->connection);
627 + G_OBJECT_CLASS(connman_agent_parent_class)->finalize(agent);
630 +static void connman_agent_class_init(ConnmanAgentClass *klass)
632 + GObjectClass *object_class = (GObjectClass *) klass;
634 + g_type_class_add_private(klass, sizeof(ConnmanAgentPrivate));
636 + object_class->finalize = connman_agent_finalize;
638 + dbus_g_object_type_install_info(CONNMAN_TYPE_AGENT,
639 + &dbus_glib_connman_agent_object_info);
642 +ConnmanAgent *connman_agent_new(void)
644 + ConnmanAgent *agent;
647 + agent = CONNMAN_AGENT(g_object_new(CONNMAN_TYPE_AGENT, NULL));
652 +gboolean connman_agent_setup(ConnmanAgent *agent, const char *path)
654 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
657 + GError *error = NULL;
659 + debug(agent, "agent_setup %p", agent);
661 + if (priv->path != NULL)
664 + priv->path = g_strdup(path);
665 + priv->connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
666 + if (error != NULL) {
667 + g_printerr("Connecting to system bus failed: %s\n",
669 + g_error_free(error);
673 + proxy = dbus_g_proxy_new_for_name_owner(priv->connection, CONNMAN_SERVICE,
674 + CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, NULL);
676 + g_free(priv->busname);
678 + if (proxy != NULL) {
679 + priv->busname = g_strdup(dbus_g_proxy_get_bus_name(proxy));
680 + g_object_unref(proxy);
682 + priv->busname = NULL;
684 + object = dbus_g_connection_lookup_g_object(priv->connection, priv->path);
685 + if (object != NULL)
686 + g_object_unref(object);
692 +gboolean connman_agent_register(ConnmanAgent *agent)
694 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
697 + GError *error = NULL;
700 + debug(agent, "register agent %p", agent);
702 + if (priv->connman_proxy != NULL)
705 + priv->connman_proxy = dbus_g_proxy_new_for_name_owner(priv->connection, CONNMAN_SERVICE,
706 + CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, NULL);
708 + g_free(priv->busname);
710 + priv->busname = g_strdup(dbus_g_proxy_get_bus_name(priv->connman_proxy));
712 + object = dbus_g_connection_lookup_g_object(priv->connection, priv->path);
713 + if (object != NULL)
714 + g_object_unref(object);
716 + dbus_g_connection_register_g_object(priv->connection,
717 + priv->path, G_OBJECT(agent));
719 + dbus_g_proxy_call(priv->connman_proxy, "RegisterAgent", &error,
720 + DBUS_TYPE_G_OBJECT_PATH, priv->path,
721 + G_TYPE_INVALID, G_TYPE_INVALID);
723 + if (error != NULL) {
724 + g_printerr("Agent registration failed: %s\n",
726 + g_error_free(error);
733 +gboolean connman_agent_unregister(ConnmanAgent *agent)
735 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
736 + GError *error = NULL;
738 + debug(agent, "unregister agent %p", agent);
740 + if (priv->connman_proxy == NULL)
743 + dbus_g_proxy_call(priv->connman_proxy, "UnregisterAgent", &error,
744 + DBUS_TYPE_G_OBJECT_PATH, priv->path,
745 + G_TYPE_INVALID, G_TYPE_INVALID);
747 + if (error != NULL) {
748 + g_printerr("Agent unregistration failed: %s\n",
750 + g_error_free(error);
753 + g_object_unref(priv->connman_proxy);
754 + priv->connman_proxy = NULL;
756 + g_free(priv->path);
762 +void connman_agent_set_request_input_func(ConnmanAgent *agent,
763 + ConnmanAgentRequestInputFunc func, gpointer data)
765 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
767 + priv->input_func = func;
768 + priv->input_data = data;
771 +void connman_agent_set_cancel_func(ConnmanAgent *agent,
772 + ConnmanAgentCancelFunc func, gpointer data)
774 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
776 + priv->cancel_func = func;
777 + priv->cancel_data = data;
780 +void connman_agent_set_release_func(ConnmanAgent *agent,
781 + ConnmanAgentReleaseFunc func, gpointer data)
783 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
785 + priv->release_func = func;
786 + priv->release_data = data;
789 +void connman_agent_set_debug_func(ConnmanAgent *agent, ConnmanAgentDebugFunc func, gpointer data)
791 + ConnmanAgentPrivate *priv = CONNMAN_AGENT_GET_PRIVATE(agent);
793 + priv->debug_func = func;
794 + priv->debug_data = data;
796 diff --git a/common/connman-agent.h b/common/connman-agent.h
798 index 0000000..0a1aa92
800 +++ b/common/connman-agent.h
803 + * Connection Manager Agent implementation
806 + * - Julien MASSOT <jmassot@aldebaran-robotics.com>
807 + * - Paul Eggleton <paul.eggleton@linux.intel.com>
809 + * Copyright (C) 2012 Aldebaran Robotics
810 + * Copyright (C) 2012 Intel Corporation
812 + * This library is free software; you can redistribute it and/or
813 + * modify it under the terms of the GNU Lesser General Public
814 + * License version 2.1 as published by the Free Software Foundation.
816 + * This library is distributed in the hope that it will be useful,
817 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
818 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
819 + * Lesser General Public License for more details.
821 + * You should have received a copy of the GNU Lesser General Public
822 + * License along with this library; if not, write to the Free Software
823 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
826 +#ifndef CONNMAN_AGENT_H_
827 +# define CONNMAN_AGENT_H_
829 +#include <glib-object.h>
830 +#include <dbus/dbus-glib.h>
834 +#define CONNMAN_TYPE_AGENT (connman_agent_get_type())
835 +#define CONNMAN_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
836 + CONNMAN_TYPE_AGENT, ConnmanAgent))
837 +#define CONNMAN_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \
838 + CONNMAN_TYPE_AGENT, ConnmanAgentClass))
839 +#define CONNMAN_IS_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
840 + CONNMAN_TYPE_AGENT))
841 +#define CONNMAN_IS_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), \
842 + CONNMAN_TYPE_AGENT))
843 +#define CONNMAN_GET_AGENT_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), \
844 + CONNMAN_TYPE_AGENT, ConnmanAgentClass))
846 +typedef struct _ConnmanAgent ConnmanAgent;
847 +typedef struct _ConnmanAgentClass ConnmanAgentClass;
849 +struct _ConnmanAgent {
853 +struct _ConnmanAgentClass {
854 + GObjectClass parent_class;
857 +GType connman_agent_get_type(void);
859 +ConnmanAgent *connman_agent_new(void);
861 +gboolean connman_agent_setup(ConnmanAgent *agent, const char *path);
863 +gboolean connman_agent_register(ConnmanAgent *agent);
864 +gboolean connman_agent_unregister(ConnmanAgent *agent);
865 +gboolean connman_agent_request_input_set_reply(gpointer request_data, GHashTable *reply);
866 +gboolean connman_agent_request_input_abort(gpointer request_data);
868 +typedef void (*ConnmanAgentRequestInputFunc) (const char *service_id, GHashTable *request, gpointer request_data, gpointer user_data);
869 +typedef gboolean (*ConnmanAgentCancelFunc) (DBusGMethodInvocation *context, gpointer data);
870 +typedef gboolean (*ConnmanAgentReleaseFunc) (DBusGMethodInvocation *context, gpointer data);
871 +typedef void (*ConnmanAgentDebugFunc) (const char *str, gpointer user_data);
873 +void connman_agent_set_request_input_func(ConnmanAgent *agent, ConnmanAgentRequestInputFunc func, gpointer data);
874 +void connman_agent_set_cancel_func(ConnmanAgent *agent, ConnmanAgentCancelFunc func, gpointer data);
875 +void connman_agent_set_debug_func(ConnmanAgent *agent, ConnmanAgentDebugFunc func, gpointer data);
878 +#endif /* !CONNMAN_AGENT_H_ */
879 diff --git a/common/connman-agent.xml b/common/connman-agent.xml
881 index 0000000..ed9ee8b
883 +++ b/common/connman-agent.xml
885 +<?xml version="1.0" encoding="UTF-8" ?>
887 +<node name="/net/connman/Agent">
888 + <interface name="net.connman.Agent">
889 + <method name="ReportError">
890 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
891 + <arg type="o" direction="in"/>
892 + <arg type="s" direction="in"/>
895 + <method name="RequestInput">
896 + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
897 + <arg type="o" direction="in"/>
898 + <arg type="a{sv}" direction="in"/>
899 + <arg type="a{sv}" direction="out"/>
902 + <method name="Cancel">
903 + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
906 + <method name="Release">
907 + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
911 diff --git a/common/marshal.list b/common/marshal.list
912 index 8b174d0..3c6317b 100644
913 --- a/common/marshal.list
914 +++ b/common/marshal.list