summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Houston <stephen@localhost.localdomain>2017-11-27 16:07:17 -0600
committerStephen Houston <stephen@localhost.localdomain>2017-11-27 16:07:17 -0600
commit5a9a4c6a473dee2e7f35fa8377f289be285962fe (patch)
tree79a31be7dde28abc384a4eed33e5276f66d17a70
parentfdc9905ee2e26745dcf48f0bf548475f98c09fda (diff)
Secret Agent Manager now works to set a passphrase.
-rw-r--r--src/networkmanager.c69
-rw-r--r--src/wireless.c4
2 files changed, 55 insertions, 18 deletions
diff --git a/src/networkmanager.c b/src/networkmanager.c
index 0ea2f23..8606e46 100644
--- a/src/networkmanager.c
+++ b/src/networkmanager.c
@@ -6,8 +6,8 @@
6#define NETWORKMANAGER_AGENT_MANAGER NETWORKMANAGER_BUS_NAME ".AgentManager" 6#define NETWORKMANAGER_AGENT_MANAGER NETWORKMANAGER_BUS_NAME ".AgentManager"
7#define NETWORKMANAGER_AGENT_MANAGER_PATH NETWORKMANAGER_BUS_PATH "/AgentManager" 7#define NETWORKMANAGER_AGENT_MANAGER_PATH NETWORKMANAGER_BUS_PATH "/AgentManager"
8#define NETWORKMANAGER_SECRET_AGENT "org.freedesktop.NetworkManager.SecretAgent" 8#define NETWORKMANAGER_SECRET_AGENT "org.freedesktop.NetworkManager.SecretAgent"
9#define NETWORKMANAGER_SECRET_AGENT_PATH "/org/freedesktop/NetworkManager/SecretAgent"
9#define NETWORKMANAGER_AGENT_NAME "org.wireless.networkmanager.agent" 10#define NETWORKMANAGER_AGENT_NAME "org.wireless.networkmanager.agent"
10#define NETWORKMANAGER_AGENT_PATH "/org/wireless/networkmanager/agent"
11 11
12#define NETWORKMANAGER_SERVICE_TYPE_ITER(i) \ 12#define NETWORKMANAGER_SERVICE_TYPE_ITER(i) \
13 for ((i) = 0; (i) < NETWORKMANAGER_SERVICE_TYPE_LAST; (i)++) 13 for ((i) = 0; (i) < NETWORKMANAGER_SERVICE_TYPE_LAST; (i)++)
@@ -2394,10 +2394,59 @@ _networkmanager_services_free(void)
2394 } 2394 }
2395} 2395}
2396 2396
2397static void
2398_networkmanager_agent_auth_send(void *data, const Eina_Array *fields)
2399{
2400 Eldbus_Message *reply;
2401 Eldbus_Message_Iter *oiter, *moarray, *moarray2, *moarray3, *entry;
2402 const char *password, *f;
2403 unsigned int i;
2404 Eina_Array_Iterator it;
2405
2406 if (!fields)
2407 {
2408 reply = eldbus_message_error_new(data,
2409 "org.freedesktop.NetworkManager.SecretAgent.Error>Canceled",
2410 "User canceled dialog");
2411 eldbus_connection_send(dbus_conn, reply, NULL, NULL, -1);
2412 return;
2413 }
2414 reply = eldbus_message_method_return_new(data);
2415 oiter = eldbus_message_iter_get(reply);
2416 moarray = eldbus_message_iter_container_new(oiter, 'a', "{sa{sv}}");
2417 moarray2 = eldbus_message_iter_container_new(moarray, 'e', NULL);
2418 eldbus_message_iter_arguments_append(moarray2, "s", "802-11-wireless-security");
2419 moarray3 = eldbus_message_iter_container_new(moarray2, 'a', "{sv}");
2420 entry = eldbus_message_iter_container_new(moarray3, 'e', NULL);
2421 EINA_ARRAY_ITER_NEXT(fields, i, f, it)
2422 {
2423 eina_stringshare_replace(&password, f);
2424 }
2425 _networkmanager_edit_getsettings_append_string(entry, "psk", password);
2426 eldbus_message_iter_container_close(moarray3, entry);
2427 eldbus_message_iter_container_close(moarray2, moarray3);
2428 eldbus_message_iter_container_close(moarray, moarray2);
2429 eldbus_message_iter_container_close(oiter, moarray);
2430 eldbus_connection_send(dbus_conn, reply, NULL, NULL, -1);
2431}
2432
2397static Eldbus_Message * 2433static Eldbus_Message *
2398_networkmanager_agent_request_input(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg EINA_UNUSED) 2434_networkmanager_agent_request_input(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
2399{ 2435{
2400 printf("Hi\n"); 2436 Eldbus_Message_Iter *array, *array2;
2437 const char *path, *setting_name;
2438 unsigned int num;
2439 Eina_Array *arr = NULL;
2440
2441 if (!eldbus_message_arguments_get(msg, "a{sa{sv}}osasu", &array, &path, &setting_name, &array2, &num))
2442 return NULL;
2443 if ((num & (1 << 0x2)) != 0)
2444 {
2445 arr = eina_array_new(1);
2446 eina_array_push(arr, eina_stringshare_add(setting_name));
2447 wireless_authenticate(arr, _networkmanager_agent_auth_send, eldbus_message_ref((Eldbus_Message *)msg));
2448 array_clear(arr);
2449 }
2401 return NULL; 2450 return NULL;
2402} 2451}
2403 2452
@@ -2407,18 +2456,6 @@ static const Eldbus_Method methods[] = {
2407 {"s", "setting_name"}, {"as", "hints"}, {"u", "flags"}), 2456 {"s", "setting_name"}, {"as", "hints"}, {"u", "flags"}),
2408 ELDBUS_ARGS({"a{sa{sv}}", "secrets"}), _networkmanager_agent_request_input, 0 2457 ELDBUS_ARGS({"a{sa{sv}}", "secrets"}), _networkmanager_agent_request_input, 0
2409 }, 2458 },
2410 {
2411 "CancelGetSecrets", ELDBUS_ARGS({"o", "connection_path"}, {"s", "setting_name"}), NULL,
2412 _networkmanager_agent_request_input, 0
2413 },
2414 {
2415 "SaveSecrets", ELDBUS_ARGS({"a{sa{sv}}", "connection"}, {"o", "connection_path"}),
2416 NULL, _networkmanager_agent_request_input, 0
2417 },
2418 {
2419 "DeleteSecrets", ELDBUS_ARGS({"a{sa{sv}}", "connection"}, {"o", "connection_path"}),
2420 NULL, _networkmanager_agent_request_input, 0
2421 },
2422 { NULL, NULL, NULL, NULL, 0 } 2459 { NULL, NULL, NULL, NULL, 0 }
2423}; 2460};
2424 2461
@@ -2465,7 +2502,7 @@ _networkmanager_start(void)
2465 eldbus_proxy_property_get(proxy_manager, "PrimaryConnection", 2502 eldbus_proxy_property_get(proxy_manager, "PrimaryConnection",
2466 _networkmanager_manager_getactive, NULL); 2503 _networkmanager_manager_getactive, NULL);
2467 2504
2468 agent_iface = eldbus_service_interface_register(dbus_conn, NETWORKMANAGER_AGENT_PATH, &desc); 2505 agent_iface = eldbus_service_interface_register(dbus_conn, NETWORKMANAGER_SECRET_AGENT_PATH, &desc);
2469 2506
2470 eldbus_proxy_call(agent_proxy_manager, "Register", _networkmanager_manager_agent_register, 2507 eldbus_proxy_call(agent_proxy_manager, "Register", _networkmanager_manager_agent_register,
2471 NULL, -1, "s", NETWORKMANAGER_AGENT_NAME); 2508 NULL, -1, "s", NETWORKMANAGER_AGENT_NAME);
diff --git a/src/wireless.c b/src/wireless.c
index 78a8adb..bf324ba 100644
--- a/src/wireless.c
+++ b/src/wireless.c
@@ -1721,8 +1721,8 @@ wireless_authenticate(const Eina_Array *fields, Wireless_Auth_Cb cb, void *data)
1721 1721
1722 popup = elm_win_add(inst->win, "win", ELM_WIN_BASIC); 1722 popup = elm_win_add(inst->win, "win", ELM_WIN_BASIC);
1723 elm_win_alpha_set(popup, 1); 1723 elm_win_alpha_set(popup, 1);
1724 evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _wireless_auth_key, NULL); 1724 evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, _wireless_auth_key, p);
1725 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _wireless_auth_del, NULL); 1725 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _wireless_auth_del, p);
1726 p->popup = popup; 1726 p->popup = popup;
1727 1727
1728 tb = elm_table_add(popup); 1728 tb = elm_table_add(popup);