5 * Copyright (C) 2011 BWM CarIT GmbH. 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
28 #include "test-connman.h"
30 static DBusMessage *set_property(DBusConnection *connection,
31 const char *property, int type, void *value)
33 DBusMessage *message, *reply;
37 message = dbus_message_new_method_call(CONNMAN_SERVICE,
39 CONNMAN_MANAGER_INTERFACE,
44 dbus_message_iter_init_append(message, &iter);
45 connman_dbus_property_append_basic(&iter, property, type, value);
47 dbus_error_init(&error);
49 reply = dbus_connection_send_with_reply_and_block(connection,
52 if (dbus_error_is_set(&error) == TRUE) {
53 LOG("%s", error.message);
54 dbus_error_free(&error);
56 LOG("Failed to get properties");
58 dbus_message_unref(message);
62 dbus_message_unref(message);
67 DBusMessage *manager_get_services(DBusConnection *connection)
69 DBusMessage *message, *reply;
72 message = dbus_message_new_method_call(CONNMAN_SERVICE,
74 CONNMAN_MANAGER_INTERFACE,
79 dbus_error_init(&error);
81 reply = dbus_connection_send_with_reply_and_block(connection,
84 if (dbus_error_is_set(&error) == TRUE) {
85 LOG("%s", error.message);
86 dbus_error_free(&error);
88 LOG("Failed to get properties");
90 dbus_message_unref(message);
94 dbus_message_unref(message);
99 DBusMessage *manager_create_session(DBusConnection *connection,
100 struct test_session_info *info,
101 const char *notifier_path)
103 DBusMessage *message, *reply;
105 DBusMessageIter array, dict;
107 message = dbus_message_new_method_call(CONNMAN_SERVICE,
108 CONNMAN_MANAGER_PATH,
109 CONNMAN_MANAGER_INTERFACE,
114 dbus_error_init(&error);
116 dbus_message_iter_init_append(message, &array);
118 connman_dbus_dict_open(&array, &dict);
120 session_append_settings(&dict, info);
122 connman_dbus_dict_close(&array, &dict);
124 dbus_message_iter_append_basic(&array, DBUS_TYPE_OBJECT_PATH,
127 reply = dbus_connection_send_with_reply_and_block(connection,
128 message, -1, &error);
130 if (dbus_error_is_set(&error) == TRUE) {
131 LOG("%s", error.message);
132 dbus_error_free(&error);
134 LOG("Failed to get properties");
136 dbus_message_unref(message);
140 dbus_message_unref(message);
145 DBusMessage *manager_destroy_session(DBusConnection *connection,
146 const char *notifier_path)
148 DBusMessage *message, *reply;
150 DBusMessageIter array;
152 message = dbus_message_new_method_call(CONNMAN_SERVICE,
153 CONNMAN_MANAGER_PATH,
154 CONNMAN_MANAGER_INTERFACE,
159 dbus_error_init(&error);
161 dbus_message_iter_init_append(message, &array);
163 dbus_message_iter_append_basic(&array, DBUS_TYPE_OBJECT_PATH,
166 reply = dbus_connection_send_with_reply_and_block(connection,
167 message, -1, &error);
169 if (dbus_error_is_set(&error) == TRUE) {
170 LOG("%s", error.message);
171 dbus_error_free(&error);
173 LOG("%s", error.message);
175 dbus_message_unref(message);
179 dbus_message_unref(message);
184 DBusMessage *manager_set_session_mode(DBusConnection *connection,
185 connman_bool_t enable)
187 return set_property(connection, "SessionMode",
188 DBUS_TYPE_BOOLEAN, &enable);