Add basic hookup of passphrase agent callback
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 30 Aug 2009 06:28:32 +0000 (23:28 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 30 Aug 2009 06:28:32 +0000 (23:28 -0700)
src/agent.c
src/connman.h
src/service.c

index 82f6146..5b2b77c 100644 (file)
@@ -85,6 +85,34 @@ int __connman_agent_unregister(const char *sender, const char *path)
        return 0;
 }
 
+int __connman_agent_request_passphrase(struct connman_service *service,
+                               passphrase_cb_t callback, void *user_data)
+{
+       DBusMessage *message;
+       const char *path;
+
+       DBG("service %p", service);
+
+       if (agent_path == NULL)
+               return -ESRCH;
+
+       message = dbus_message_new_method_call(agent_sender, agent_path,
+                               CONNMAN_AGENT_INTERFACE, "RequestPassphrase");
+       if (message == NULL)
+               return -ENOMEM;
+
+       dbus_message_set_no_reply(message, TRUE);
+
+       path = __connman_service_get_path(service);
+
+       dbus_message_append_args(message, DBUS_TYPE_OBJECT_PATH, &path,
+                                                       DBUS_TYPE_INVALID);
+
+       g_dbus_send_message(connection, message);
+
+       return -EIO;
+}
+
 int __connman_agent_init(void)
 {
        DBG("");
@@ -98,7 +126,7 @@ int __connman_agent_init(void)
 
 void __connman_agent_cleanup(void)
 {
-       DBusMessage *msg;
+       DBusMessage *message;
 
        DBG("");
 
@@ -111,16 +139,14 @@ void __connman_agent_cleanup(void)
        if (agent_path == NULL)
                return;
 
-       msg = dbus_message_new_method_call(agent_sender, agent_path,
+       message = dbus_message_new_method_call(agent_sender, agent_path,
                                        CONNMAN_AGENT_INTERFACE, "Release");
-       if (msg == NULL)
+       if (message == NULL)
                return;
 
-       dbus_message_set_no_reply(msg, TRUE);
-
-       dbus_connection_send(connection, msg, NULL);
+       dbus_message_set_no_reply(message, TRUE);
 
-       dbus_message_unref(msg);
+       g_dbus_send_message(connection, message);
 
        agent_free();
 
index 81343dd..ff4e286 100644 (file)
@@ -65,6 +65,14 @@ void __connman_agent_cleanup(void);
 int __connman_agent_register(const char *sender, const char *path);
 int __connman_agent_unregister(const char *sender, const char *path);
 
+struct connman_service;
+
+typedef void (* passphrase_cb_t) (struct connman_service *service,
+                               const char *passphrase, void *user_data);
+
+int __connman_agent_request_passphrase(struct connman_service *service,
+                               passphrase_cb_t callback, void *user_data);
+
 #include <connman/log.h>
 
 int __connman_log_init(gboolean detach, gboolean debug);
@@ -328,6 +336,7 @@ struct connman_service *__connman_service_create_from_network(struct connman_net
 void __connman_service_update_from_network(struct connman_network *network);
 void __connman_service_remove_from_network(struct connman_network *network);
 
+const char *__connman_service_get_path(struct connman_service *service);
 unsigned int __connman_service_get_order(struct connman_service *service);
 
 int __connman_service_set_carrier(struct connman_service *service,
index 5c58d51..cce1bfc 100644 (file)
@@ -756,6 +756,12 @@ static DBusMessage *connect_service(DBusConnection *conn,
 
        err = __connman_service_connect(service);
        if (err < 0) {
+               if (err == -ENOKEY) {
+                       if (__connman_agent_request_passphrase(service,
+                                                       NULL, NULL) == 0)
+                               return NULL;
+               }
+
                if (err != -EINPROGRESS) {
                        dbus_message_unref(service->pending);
                        service->pending = NULL;
@@ -1796,6 +1802,11 @@ struct connman_service *__connman_service_lookup_from_network(struct connman_net
        return service;
 }
 
+const char *__connman_service_get_path(struct connman_service *service)
+{
+       return service->path;
+}
+
 unsigned int __connman_service_get_order(struct connman_service *service)
 {
        GSequenceIter *iter;