5 * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 static DBusConnection *connection = NULL;
35 static guint agent_watch = 0;
36 static gchar *agent_path = NULL;
37 static gchar *agent_sender = NULL;
39 static void agent_free(void)
50 static void agent_disconnect(DBusConnection *connection, void *data)
57 int __connman_agent_register(const char *sender, const char *path)
59 DBG("sender %s path %s", sender, path);
61 if (agent_path != NULL)
64 agent_sender = g_strdup(sender);
65 agent_path = g_strdup(path);
67 agent_watch = g_dbus_add_disconnect_watch(connection, sender,
68 agent_disconnect, NULL, NULL);
73 int __connman_agent_unregister(const char *sender, const char *path)
75 DBG("sender %s path %s", sender, path);
77 if (agent_path == NULL)
81 g_dbus_remove_watch(connection, agent_watch);
88 int __connman_agent_request_passphrase(struct connman_service *service,
89 passphrase_cb_t callback, void *user_data)
94 DBG("service %p", service);
96 if (agent_path == NULL)
99 message = dbus_message_new_method_call(agent_sender, agent_path,
100 CONNMAN_AGENT_INTERFACE, "RequestPassphrase");
104 dbus_message_set_no_reply(message, TRUE);
106 path = __connman_service_get_path(service);
108 dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &path,
111 g_dbus_send_message(connection, message);
116 int __connman_agent_init(void)
120 connection = connman_dbus_get_connection();
121 if (connection == NULL)
127 void __connman_agent_cleanup(void)
129 DBusMessage *message;
133 if (connection == NULL)
137 g_dbus_remove_watch(connection, agent_watch);
139 if (agent_path == NULL)
142 message = dbus_message_new_method_call(agent_sender, agent_path,
143 CONNMAN_AGENT_INTERFACE, "Release");
147 dbus_message_set_no_reply(message, TRUE);
149 g_dbus_send_message(connection, message);
153 dbus_connection_unref(connection);