summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Houston <stephen@localhost.localdomain>2017-11-27 13:44:56 -0600
committerStephen Houston <stephen@localhost.localdomain>2017-11-27 13:44:56 -0600
commite7a9fa1a0fb66481795ab735910a90908f4e65e3 (patch)
treeb8d0b88f559353274c8ce011e9147525bfd1dd0a
parent96d040dbe6b41dd4db46a8dfb84d3849936e625e (diff)
Add beginnings of an agent manager
-rw-r--r--TODO3
-rw-r--r--src/networkmanager.c97
2 files changed, 94 insertions, 6 deletions
diff --git a/TODO b/TODO
index 406565f..d4a4f78 100644
--- a/TODO
+++ b/TODO
@@ -5,4 +5,5 @@ Proxy config editing
5--Issues-- 5--Issues--
6Doesn't update the icon correctly when activing connections on separate devices 6Doesn't update the icon correctly when activing connections on separate devices
7Random crashes 7Random crashes
8 8--Needed--
9Update when connections and access points are added/removed
diff --git a/src/networkmanager.c b/src/networkmanager.c
index dc8bcf9..f40e624 100644
--- a/src/networkmanager.c
+++ b/src/networkmanager.c
@@ -144,8 +144,10 @@ static Eldbus_Pending *pending_getproperties_manager;
144static Eldbus_Pending *pending_getdevices; 144static Eldbus_Pending *pending_getdevices;
145static Eldbus_Pending *pending_getactive; 145static Eldbus_Pending *pending_getactive;
146static Eldbus_Proxy *proxy_manager; 146static Eldbus_Proxy *proxy_manager;
147static Eldbus_Proxy *agent_proxy_manager;
147static Eina_List *pending_technologies; 148static Eina_List *pending_technologies;
148static Eina_List *sig_handlers; 149static Eina_List *sig_handlers;
150static Eldbus_Service_Interface *agent_iface;
149static const char *active_connection; 151static const char *active_connection;
150Eldbus_Connection *dbus_conn; 152Eldbus_Connection *dbus_conn;
151 153
@@ -864,7 +866,7 @@ networkmanager_service_edit(const char *path, Wireless_Connection *wc)
864} 866}
865 867
866void 868void
867networkmanager_service_edit_proxy(const char *path EINA_UNUSED, Wireless_Connection *wc EINA_UNUSED) 869networkmanager_service_edit_proxy(const char *path, Wireless_Connection *wc)
868{ 870{
869 NetworkManager_Service *ns; 871 NetworkManager_Service *ns;
870 Eldbus_Object *obj; 872 Eldbus_Object *obj;
@@ -885,15 +887,47 @@ networkmanager_service_edit_proxy(const char *path EINA_UNUSED, Wireless_Connect
885} 887}
886 888
887void 889void
888networkmanager_service_edit_domains(const char *path EINA_UNUSED, Wireless_Connection *wc EINA_UNUSED) 890networkmanager_service_edit_domains(const char *path, Wireless_Connection *wc)
889{ 891{
892 NetworkManager_Service *ns;
893 Eldbus_Object *obj;
894 Eldbus_Proxy *proxy;
895 Eldbus_Pending *pend;
896
897 ns = _networkmanager_service_find_path(path);
898 EINA_SAFETY_ON_NULL_RETURN(ns);
890 899
900 if (ns->domain_servers)
901 array_clear(ns->domain_servers);
902 ns->name_servers = wc->domain_servers;
903
904 obj = eldbus_object_get(dbus_conn, NETWORKMANAGER_BUS_NAME, ns->path);
905 proxy = eldbus_proxy_get(obj, NETWORKMANAGER_BUS_INTERFACE ".Settings.Connection");
906 pend = eldbus_proxy_call(proxy, "GetSettings",
907 _networkmanager_edit_getsettings, ns, -1, "");
908 pending_technologies = eina_list_append(pending_technologies, pend);
891} 909}
892 910
893void 911void
894networkmanager_service_edit_nameservers(const char *path EINA_UNUSED, Wireless_Connection *wc EINA_UNUSED) 912networkmanager_service_edit_nameservers(const char *path, Wireless_Connection *wc)
895{ 913{
914 NetworkManager_Service *ns;
915 Eldbus_Object *obj;
916 Eldbus_Proxy *proxy;
917 Eldbus_Pending *pend;
896 918
919 ns = _networkmanager_service_find_path(path);
920 EINA_SAFETY_ON_NULL_RETURN(ns);
921
922 if (ns->name_servers)
923 array_clear(ns->name_servers);
924 ns->name_servers = wc->name_servers;
925
926 obj = eldbus_object_get(dbus_conn, NETWORKMANAGER_BUS_NAME, ns->path);
927 proxy = eldbus_proxy_get(obj, NETWORKMANAGER_BUS_INTERFACE ".Settings.Connection");
928 pend = eldbus_proxy_call(proxy, "GetSettings",
929 _networkmanager_edit_getsettings, ns, -1, "");
930 pending_technologies = eina_list_append(pending_technologies, pend);
897} 931}
898 932
899void 933void
@@ -2359,10 +2393,53 @@ _networkmanager_services_free(void)
2359 } 2393 }
2360} 2394}
2361 2395
2396static Eldbus_Message *
2397_networkmanager_agent_request_input(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg EINA_UNUSED)
2398{
2399 printf("Hi\n");
2400 return NULL;
2401}
2402
2403static const Eldbus_Method methods[] = {
2404 {
2405 "GetSecrets", ELDBUS_ARGS({"a{sa{sv}}", "connection"}, {"o", "connection_path"},
2406 {"s", "setting_name"}, {"as", "hints"}, {"u", "flags"}),
2407 ELDBUS_ARGS({"a{sa{sv}}", "secrets"}), _networkmanager_agent_request_input, 0
2408 },
2409 {
2410 "CancelGetSecrets", ELDBUS_ARGS({"o", "connection_path"}, {"s", "setting_name"}), NULL,
2411 _networkmanager_agent_request_input, 0
2412 },
2413 {
2414 "SaveSecrets", ELDBUS_ARGS({"a{sa{sv}}", "connection"}, {"o", "connection_path"}),
2415 NULL, _networkmanager_agent_request_input, 0
2416 },
2417 {
2418 "DeleteSecrets", ELDBUS_ARGS({"a{sa{sv}}", "connection"}, {"o", "connection_path"}),
2419 NULL, _networkmanager_agent_request_input, 0
2420 },
2421 { NULL, NULL, NULL, NULL, 0 }
2422};
2423
2424static const Eldbus_Service_Interface_Desc desc = {
2425 NETWORKMANAGER_AGENT_NAME, methods, NULL, NULL, NULL, NULL
2426};
2427
2428static void
2429_networkmanager_manager_agent_register(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
2430{
2431 const char *name, *text;
2432
2433 if (eldbus_message_error_get(msg, &name, &text))
2434 {
2435 ERR("Could not register agent. %s: %s", name, text);
2436 }
2437}
2438
2362static void 2439static void
2363_networkmanager_start(void) 2440_networkmanager_start(void)
2364{ 2441{
2365 Eldbus_Object *obj; 2442 Eldbus_Object *obj, *agent_obj;
2366 int i; 2443 int i;
2367 2444
2368 NETWORKMANAGER_SERVICE_TYPE_ITER(i) 2445 NETWORKMANAGER_SERVICE_TYPE_ITER(i)
@@ -2374,6 +2451,8 @@ _networkmanager_start(void)
2374 2451
2375 obj = eldbus_object_get(dbus_conn, NETWORKMANAGER_BUS_NAME, NETWORKMANAGER_BUS_PATH); 2452 obj = eldbus_object_get(dbus_conn, NETWORKMANAGER_BUS_NAME, NETWORKMANAGER_BUS_PATH);
2376 proxy_manager = eldbus_proxy_get(obj, NETWORKMANAGER_BUS_INTERFACE); 2453 proxy_manager = eldbus_proxy_get(obj, NETWORKMANAGER_BUS_INTERFACE);
2454 agent_obj = eldbus_object_get(dbus_conn, NETWORKMANAGER_BUS_NAME, NETWORKMANAGER_AGENT_MANAGER_PATH);
2455 agent_proxy_manager = eldbus_proxy_get(agent_obj, NETWORKMANAGER_AGENT_MANAGER);
2377 2456
2378 pending_getproperties_manager = 2457 pending_getproperties_manager =
2379 eldbus_proxy_call(proxy_manager, "state", _networkmanager_manager_getstate, 2458 eldbus_proxy_call(proxy_manager, "state", _networkmanager_manager_getstate,
@@ -2385,6 +2464,11 @@ _networkmanager_start(void)
2385 eldbus_proxy_property_get(proxy_manager, "PrimaryConnection", 2464 eldbus_proxy_property_get(proxy_manager, "PrimaryConnection",
2386 _networkmanager_manager_getactive, NULL); 2465 _networkmanager_manager_getactive, NULL);
2387 2466
2467 agent_iface = eldbus_service_interface_register(dbus_conn, NETWORKMANAGER_AGENT_PATH, &desc);
2468
2469 eldbus_proxy_call(agent_proxy_manager, "Register", _networkmanager_manager_agent_register,
2470 NULL, -1, "s", NETWORKMANAGER_AGENT_NAME);
2471
2388 sig_handlers = eina_list_append(sig_handlers, 2472 sig_handlers = eina_list_append(sig_handlers,
2389 eldbus_proxy_signal_handler_add(proxy_manager, "PropertiesChanged", 2473 eldbus_proxy_signal_handler_add(proxy_manager, "PropertiesChanged",
2390 _networkmanager_manager_event_property, NULL)); 2474 _networkmanager_manager_event_property, NULL));
@@ -2424,9 +2508,12 @@ _networkmanager_end(void)
2424 if (pending_getproperties_manager) 2508 if (pending_getproperties_manager)
2425 eldbus_pending_cancel(pending_getproperties_manager); 2509 eldbus_pending_cancel(pending_getproperties_manager);
2426 pending_getproperties_manager = NULL; 2510 pending_getproperties_manager = NULL;
2427 2511 _eldbus_proxy_del(agent_proxy_manager);
2512 agent_proxy_manager = NULL;
2428 _eldbus_proxy_del(proxy_manager); 2513 _eldbus_proxy_del(proxy_manager);
2429 proxy_manager = NULL; 2514 proxy_manager = NULL;
2515 eldbus_service_object_unregister(agent_iface);
2516 agent_iface = NULL;
2430} 2517}
2431 2518
2432static void 2519static void