5 * Copyright (C) 2012 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
31 #include <connman/log.h>
32 #include <connman/agent.h>
33 #include <vpn/vpn-provider.h>
35 #include "vpn-agent.h"
38 bool vpn_agent_check_reply_has_dict(DBusMessage *reply)
40 const char *signature = DBUS_TYPE_ARRAY_AS_STRING
41 DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
42 DBUS_TYPE_STRING_AS_STRING
43 DBUS_TYPE_VARIANT_AS_STRING
44 DBUS_DICT_ENTRY_END_CHAR_AS_STRING;
46 if (dbus_message_has_signature(reply, signature))
49 connman_warn("Reply %s to %s from %s has wrong signature %s",
51 dbus_message_get_interface(reply),
52 dbus_message_get_sender(reply),
53 dbus_message_get_signature(reply));
58 static void request_input_append_name(DBusMessageIter *iter, void *user_data)
60 struct vpn_provider *provider = user_data;
61 const char *str = "string";
63 connman_dbus_dict_append_basic(iter, "Type",
64 DBUS_TYPE_STRING, &str);
65 str = "informational";
66 connman_dbus_dict_append_basic(iter, "Requirement",
67 DBUS_TYPE_STRING, &str);
69 str = vpn_provider_get_name(provider);
70 connman_dbus_dict_append_basic(iter, "Value",
71 DBUS_TYPE_STRING, &str);
74 static void request_input_append_host(DBusMessageIter *iter, void *user_data)
76 struct vpn_provider *provider = user_data;
77 const char *str = "string";
79 connman_dbus_dict_append_basic(iter, "Type",
80 DBUS_TYPE_STRING, &str);
81 str = "informational";
82 connman_dbus_dict_append_basic(iter, "Requirement",
83 DBUS_TYPE_STRING, &str);
85 str = vpn_provider_get_host(provider);
86 connman_dbus_dict_append_basic(iter, "Value",
87 DBUS_TYPE_STRING, &str);
90 void vpn_agent_append_host_and_name(DBusMessageIter *iter,
91 struct vpn_provider *provider)
93 connman_dbus_dict_append_dict(iter, "Host",
94 request_input_append_host,
97 connman_dbus_dict_append_dict(iter, "Name",
98 request_input_append_name,
102 struct user_info_data {
103 struct vpn_provider *provider;
104 const char *username_str;
107 static void request_input_append_user_info(DBusMessageIter *iter,
110 struct user_info_data *data = user_data;
111 struct vpn_provider *provider = data->provider;
112 const char *str = "string";
114 connman_dbus_dict_append_basic(iter, "Type",
115 DBUS_TYPE_STRING, &str);
117 connman_dbus_dict_append_basic(iter, "Requirement",
118 DBUS_TYPE_STRING, &str);
120 if (data->username_str) {
121 str = vpn_provider_get_string(provider, data->username_str);
123 connman_dbus_dict_append_basic(iter, "Value",
124 DBUS_TYPE_STRING, &str);
128 void vpn_agent_append_user_info(DBusMessageIter *iter,
129 struct vpn_provider *provider,
130 const char *username_str)
132 struct user_info_data data = {
133 .provider = provider,
134 .username_str = username_str
137 connman_dbus_dict_append_dict(iter, "Username",
138 request_input_append_user_info,
141 data.username_str = NULL;
142 connman_dbus_dict_append_dict(iter, "Password",
143 request_input_append_user_info,