Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(806)

Side by Side Diff: src/manager.c

Issue 6659006: flimflam: add support for multiple profiles (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/flimflam.git@master
Patch Set: rebase Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * 2 *
3 * Connection Manager 3 * Connection Manager
4 * 4 *
5 * Copyright (C) 2007-2009 Intel Corporation. All rights reserved. 5 * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 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 8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 * 10 *
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 connman_bool_t offlinemode; 166 connman_bool_t offlinemode;
167 167
168 if (type != DBUS_TYPE_BOOLEAN) 168 if (type != DBUS_TYPE_BOOLEAN)
169 return __connman_error_invalid_arguments(msg); 169 return __connman_error_invalid_arguments(msg);
170 170
171 dbus_message_iter_get_basic(&value, &offlinemode); 171 dbus_message_iter_get_basic(&value, &offlinemode);
172 172
173 __connman_profile_set_offlinemode(offlinemode); 173 __connman_profile_set_offlinemode(offlinemode);
174 174
175 __connman_profile_save_default(); 175 __connman_profile_save_default();
176 } else if (g_str_equal(name, "ActiveProfile") == TRUE) {
177 const char *str;
178
179 dbus_message_iter_get_basic(&value, &str);
180
181 return __connman_error_not_supported(msg);
182 } else 176 } else
183 return __connman_error_invalid_property(msg); 177 return __connman_error_invalid_property(msg);
184 178
185 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); 179 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
186 } 180 }
187 181
188 static DBusMessage *get_state(DBusConnection *conn, 182 static DBusMessage *get_state(DBusConnection *conn,
189 DBusMessage *msg, void *data) 183 DBusMessage *msg, void *data)
190 { 184 {
191 const char *str; 185 const char *str;
(...skipping 28 matching lines...) Expand all
220 if (err < 0) 214 if (err < 0)
221 return __connman_error_failed(msg, -err); 215 return __connman_error_failed(msg, -err);
222 216
223 return g_dbus_create_reply(msg, DBUS_TYPE_OBJECT_PATH, &path, 217 return g_dbus_create_reply(msg, DBUS_TYPE_OBJECT_PATH, &path,
224 DBUS_TYPE_INVALID); 218 DBUS_TYPE_INVALID);
225 } 219 }
226 220
227 static DBusMessage *remove_profile(DBusConnection *conn, 221 static DBusMessage *remove_profile(DBusConnection *conn,
228 DBusMessage *msg, void *data) 222 DBusMessage *msg, void *data)
229 { 223 {
230 » const char *path; 224 » const char *ident;
231 int err; 225 int err;
232 226
233 _DBG_MANAGER("conn %p", conn); 227 _DBG_MANAGER("conn %p", conn);
234 228
235 » dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, 229 » dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &ident,
236 DBUS_TYPE_INVALID); 230 DBUS_TYPE_INVALID);
237 231
238 if (__connman_security_check_privilege(msg, 232 if (__connman_security_check_privilege(msg,
239 CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0) 233 CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
240 return __connman_error_permission_denied(msg); 234 return __connman_error_permission_denied(msg);
241 235
242 » err = __connman_profile_remove(path); 236 » err = __connman_profile_remove(ident);
243 if (err < 0) 237 if (err < 0)
244 return __connman_error_failed(msg, -err); 238 return __connman_error_failed(msg, -err);
245 239
246 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); 240 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
247 } 241 }
248 242
243 static DBusMessage *push_profile(DBusConnection *conn,
244 DBusMessage *msg, void *data)
245 {
246 const char *ident, *path;
247 int err;
248
249 _DBG_MANAGER("conn %p", conn);
250
251 dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &ident,
252 DBUS_TYPE_INVALID);
253
254 if (__connman_security_check_privilege(msg,
255 CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
256 return __connman_error_permission_denied(msg);
257
258 err = __connman_profile_push(ident, NULL, &path);
259 if (err < 0)
260 return __connman_error_failed(msg, -err);
261
262 return g_dbus_create_reply(msg, DBUS_TYPE_OBJECT_PATH, &path,
263 DBUS_TYPE_INVALID);
264 }
265
266 static DBusMessage *__pop_profile(DBusMessage *msg, const char *ident)
267 {
268 int err;
269
270 if (__connman_security_check_privilege(msg,
271 CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
272 return __connman_error_permission_denied(msg);
273
274 err = __connman_profile_pop(ident);
275 if (err < 0)
276 return __connman_error_failed(msg, -err);
277
278 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
279 }
280
281 static DBusMessage *pop_profile(DBusConnection *conn,
282 DBusMessage *msg, void *data)
283 {
284 const char *ident;
285
286 dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &ident,
287 DBUS_TYPE_INVALID);
288
289 _DBG_MANAGER("ident %s", ident);
290
291 return __pop_profile(msg, ident);
292 }
293
294 static DBusMessage *pop_any_profile(DBusConnection *conn,
295 DBusMessage *msg, void *data)
296 {
297 _DBG_MANAGER("");
298
299 return __pop_profile(msg, NULL);
300 }
301
249 static DBusMessage *request_scan(DBusConnection *conn, 302 static DBusMessage *request_scan(DBusConnection *conn,
250 DBusMessage *msg, void *data) 303 DBusMessage *msg, void *data)
251 { 304 {
252 enum connman_service_type type; 305 enum connman_service_type type;
253 const char *str; 306 const char *str;
254 int err; 307 int err;
255 308
256 _DBG_MANAGER("conn %p", conn); 309 _DBG_MANAGER("conn %p", conn);
257 310
258 dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &str, 311 dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &str,
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 /* TODO(sleffler) update state (e.g. routing) */ 704 /* TODO(sleffler) update state (e.g. routing) */
652 705
653 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); 706 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
654 } 707 }
655 708
656 static GDBusMethodTable manager_methods[] = { 709 static GDBusMethodTable manager_methods[] = {
657 { "GetProperties", "", "a{sv}", get_properties }, 710 { "GetProperties", "", "a{sv}", get_properties },
658 { "SetProperty", "sv", "", set_property }, 711 { "SetProperty", "sv", "", set_property },
659 { "GetState", "", "s", get_state }, 712 { "GetState", "", "s", get_state },
660 { "CreateProfile", "s", "o", create_profile }, 713 { "CreateProfile", "s", "o", create_profile },
661 » { "RemoveProfile", "o", "", remove_profile }, 714 » { "RemoveProfile", "s", "", remove_profile },
715 » { "PushProfile", "s", "o", push_profile },
716 » { "PopProfile", "s", "", pop_profile },
717 » { "PopAnyProfile", "", "", pop_any_profile },
662 { "RequestScan", "s", "", request_scan }, 718 { "RequestScan", "s", "", request_scan },
663 { "EnableTechnology", "s", "", enable_technology, 719 { "EnableTechnology", "s", "", enable_technology,
664 G_DBUS_METHOD_FLAG_ASYNC }, 720 G_DBUS_METHOD_FLAG_ASYNC },
665 { "DisableTechnology", "s", "", disable_technology, 721 { "DisableTechnology", "s", "", disable_technology,
666 G_DBUS_METHOD_FLAG_ASYNC }, 722 G_DBUS_METHOD_FLAG_ASYNC },
667 { "GetService", "a{sv}", "o", get_wifi_service }, 723 { "GetService", "a{sv}", "o", get_wifi_service },
668 { "GetWifiService", "a{sv}", "o", get_wifi_service }, 724 { "GetWifiService", "a{sv}", "o", get_wifi_service },
669 { "ConfigureWifiService","a{sv}","", configure_wifi_service }, 725 { "ConfigureWifiService","a{sv}","", configure_wifi_service },
670 { "GetVPNService", "a{sv}","o", get_vpn_service }, 726 { "GetVPNService", "a{sv}","o", get_vpn_service },
671 { "RegisterAgent", "o", "", register_agent }, 727 { "RegisterAgent", "o", "", register_agent },
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 906
851 g_dbus_unregister_interface(connection, CONNMAN_MANAGER_PATH, 907 g_dbus_unregister_interface(connection, CONNMAN_MANAGER_PATH,
852 CONNMAN_MANAGER_INTERFACE); 908 CONNMAN_MANAGER_INTERFACE);
853 909
854 dbus_bus_remove_match(connection, powerman_rule, NULL); 910 dbus_bus_remove_match(connection, powerman_rule, NULL);
855 dbus_connection_flush(connection); 911 dbus_connection_flush(connection);
856 dbus_connection_remove_filter(connection, powerman_filter, NULL); 912 dbus_connection_remove_filter(connection, powerman_filter, NULL);
857 913
858 dbus_connection_unref(connection); 914 dbus_connection_unref(connection);
859 } 915 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698