8 _elements_print(E_Connman_Element **elements, int count)
11 for (i = 0; i < count; i++)
13 printf("--- element %d:\n", i);
14 e_connman_element_print(stdout, elements[i]);
17 printf("END: all elements count = %d\n", count);
21 _on_element_add(void *data, int type, void *info)
23 E_Connman_Element *element = info;
24 printf(">>> %s\n", element->path);
29 _on_element_del(void *data, int type, void *info)
31 E_Connman_Element *element = info;
32 printf("<<< %s\n", element->path);
37 _on_element_updated(void *data, int type, void *info)
39 E_Connman_Element *element = info;
40 printf("!!! %s\n", element->path);
41 e_connman_element_print(stderr, element);
46 _on_cmd_quit(char *cmd, char *args)
48 fputs("Bye!\n", stderr);
49 ecore_main_loop_quit();
54 _on_cmd_sync(char *cmd, char *args)
56 e_connman_manager_sync_elements();
78 _on_cmd_get_all(char *cmd, char *args)
80 E_Connman_Element **elements;
91 ret = e_connman_elements_get_all_type(type, &count, &elements);
93 ret = e_connman_elements_get_all(&count, &elements);
96 fputs("ERROR: could not get elements\n", stderr);
99 printf("BEG: all elements type=%s count = %d\n", type, count);
100 _elements_print(elements, count);
106 static E_Connman_Element *
107 _element_from_args(char *args, char **next_args)
109 E_Connman_Element *element;
113 fputs("ERROR: missing element path\n", stderr);
118 *next_args = _tok(args);
119 element = e_connman_element_get(args);
121 fprintf(stderr, "ERROR: no element called \"%s\".\n", args);
127 _on_cmd_print(char *cmd, char *args)
130 E_Connman_Element *element = _element_from_args(args, &next_args);
132 e_connman_element_print(stdout, element);
137 _on_cmd_get_properties(char *cmd, char *args)
140 E_Connman_Element *element = _element_from_args(args, &next_args);
142 e_connman_element_properties_sync(element);
147 _on_cmd_property_set(char *cmd, char *args)
149 char *next_args, *name, *p;
150 E_Connman_Element *element = _element_from_args(args, &next_args);
162 fputs("ERROR: missing parameters name, type and value.\n", stderr);
170 fputs("ERROR: missing parameters type and value.\n", stderr);
177 fputs("ERROR: missing parameter value.\n", stderr);
184 case DBUS_TYPE_BOOLEAN:
185 vlong = !!atol(next_args);
186 value = (void *)vlong;
187 fprintf(stderr, "DBG: boolean is: %ld\n", vlong);
189 case DBUS_TYPE_UINT16:
190 vu16 = strtol(next_args, &p, 0);
193 fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
197 fprintf(stderr, "DBG: u16 is: %hu\n", vu16);
199 case DBUS_TYPE_UINT32:
200 vu32 = strtol(next_args, &p, 0);
203 fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
207 fprintf(stderr, "DBG: u16 is: %u\n", vu32);
209 case DBUS_TYPE_STRING:
210 case DBUS_TYPE_OBJECT_PATH:
211 p = next_args + strlen(next_args);
214 while (p > next_args && isspace(*p))
218 fprintf(stderr, "ERROR: invalid string \"%s\".\n", next_args);
222 fprintf(stderr, "DBG: string is: \"%s\"\n", next_args);
225 fprintf(stderr, "ERROR: don't know how to parse type '%c' (%d)\n",
230 fprintf(stderr, "set_property %s [%p] %s %c %p...\n",
231 args, element, name, type, value);
232 e_connman_element_property_set(element, name, type, value);
237 /* Manager Commands */
240 _on_cmd_manager_get(char *cmd, char *args)
242 E_Connman_Element *element;
243 element = e_connman_manager_get();
244 e_connman_element_print(stderr, element);
249 _on_cmd_manager_get_profiles(char *cmd, char *args)
252 E_Connman_Element **profiles;
254 if (!e_connman_manager_profiles_get(&count, &profiles))
256 fputs("ERROR: can't get profiles\n", stderr);
259 printf("BEG: all manager profiles elements count = %d\n", count);
260 _elements_print(profiles, count);
265 _on_cmd_manager_get_devices(char *cmd, char *args)
268 E_Connman_Element **devices;
270 if (!e_connman_manager_devices_get(&count, &devices))
272 fputs("ERROR: can't get devices\n", stderr);
275 printf("BEG: all manager devices elements count = %d\n", count);
276 _elements_print(devices, count);
281 _on_cmd_manager_get_connections(char *cmd, char *args)
284 E_Connman_Element **connections;
286 if (!e_connman_manager_connections_get(&count, &connections))
288 fputs("ERROR: can't get connections\n", stderr);
291 printf("BEG: all manager connections elements count = %d\n", count);
292 _elements_print(connections, count);
297 _on_cmd_manager_register_agent(char *cmd, char *args)
303 fputs("ERROR: missing the object path\n", stderr);
308 if (e_connman_manager_register_agent(path, NULL, NULL))
309 printf(":::Registering agent %s...\n", path);
311 fprintf(stderr, "ERROR: can't register agent %s\n", path);
317 _on_cmd_manager_unregister_agent(char *cmd, char *args)
323 fputs("ERROR: missing the object path\n", stderr);
328 if (e_connman_manager_unregister_agent(path, NULL, NULL))
329 printf(":::Unregistering agent %s...\n", path);
331 fprintf(stderr, "ERROR: can't unregister agent %s\n", path);
337 _on_cmd_manager_get_state(char *cmd, char *args)
340 if (e_connman_manager_state_get(&state))
341 printf(":::Manager state = \"%s\"\n", state);
343 fputs("ERROR: can't get manager state\n", stderr);
348 _on_cmd_manager_get_policy(char *cmd, char *args)
351 if (e_connman_manager_policy_get(&policy))
352 printf(":::Manager policy = \"%s\"\n", policy);
354 fputs("ERROR: can't get manager policy\n", stderr);
359 _on_cmd_manager_set_policy(char *cmd, char *args)
364 fputs("ERROR: missing the policy value\n", stderr);
369 if (e_connman_manager_policy_set(policy, NULL, NULL))
370 printf(":::Manager policy set to \"%s\"\n", policy);
372 fputs("ERROR: can't set manager policy\n", stderr);
377 _on_cmd_manager_get_offline_mode(char *cmd, char *args)
380 if (e_connman_manager_offline_mode_get(&offline))
381 printf(":::Manager Offline Mode = %hhu\n", offline);
383 fputs("ERROR: can't get manager offline mode\n", stderr);
388 _on_cmd_manager_set_offline_mode(char *cmd, char *args)
393 fputs("ERROR: missing the offline mode value\n", stderr);
397 offline = !!atol(args);
398 if (e_connman_manager_offline_mode_set(offline, NULL, NULL))
399 printf(":::Manager Offline Mode set to %hhu\n", offline);
401 fputs("ERROR: can't set manager offline mode\n", stderr);
405 /* Device Commands */
408 _on_cmd_device_create_network(char *cmd, char *args)
411 E_Connman_Element *e;
415 fputs("ERROR: missing the device path\n", stderr);
420 e = e_connman_device_get(path);
421 if (e_connman_device_network_create(e, NULL, NULL))
422 printf(":::Creating Network %s...\n", path);
424 fputs("ERROR: can't create network\n", stderr);
429 _on_cmd_device_remove_network(char *cmd, char *args)
431 char *path, *device_path;
432 E_Connman_Element *e;
436 fputs("ERROR: missing the device path\n", stderr);
444 fputs("ERROR: missing the object network\n", stderr);
449 e = e_connman_device_get(device_path);
450 if (e_connman_device_network_remove(e, path, NULL, NULL))
451 printf(":::Removing Network %s...\n", path);
453 fputs("ERROR: can't remove network\n", stderr);
458 _on_cmd_device_propose_scan(char *cmd, char *args)
461 E_Connman_Element *e;
465 fputs("ERROR: missing the device path\n", stderr);
471 e = e_connman_device_get(path);
472 if (e_connman_device_propose_scan(e, NULL, NULL))
473 printf(":::Proposing scan %s...\n", path);
475 fputs("ERROR: can't propose scan\n", stderr);
480 _on_cmd_device_get_name(char *cmd, char *args)
482 const char *name, *path;
483 E_Connman_Element *e;
487 fputs("ERROR: missing the device path\n", stderr);
493 e = e_connman_device_get(path);
494 if (e_connman_device_name_get(e, &name))
495 printf(":::Device %s Name = \"%s\"\n", path, name);
497 fputs("ERROR: can't get device name\n", stderr);
502 _on_cmd_device_get_type(char *cmd, char *args)
504 const char *type, *path;
505 E_Connman_Element *e;
509 fputs("ERROR: missing the device path\n", stderr);
515 e = e_connman_device_get(path);
516 if (e_connman_device_type_get(e, &type))
517 printf(":::Device %s Type = \"%s\"\n", path, type);
519 fputs("ERROR: can't get device type\n", stderr);
524 _on_cmd_device_get_interface(char *cmd, char *args)
526 const char *interface, *path;
527 E_Connman_Element *e;
531 fputs("ERROR: missing the device path\n", stderr);
537 e = e_connman_device_get(path);
538 if (e_connman_device_interface_get(e, &interface))
539 printf(":::Device %s Interface = \"%s\"\n", path, interface);
541 fputs("ERROR: can't get device interface\n", stderr);
546 _on_cmd_device_get_policy(char *cmd, char *args)
548 const char *policy, *path;
549 E_Connman_Element *e;
553 fputs("ERROR: missing the device path\n", stderr);
559 e = e_connman_device_get(path);
560 if (e_connman_device_policy_get(e, &policy))
561 printf(":::Device %s Policy = \"%s\"\n", path, policy);
563 fputs("ERROR: can't get device policy\n", stderr);
568 _on_cmd_device_set_policy(char *cmd, char *args)
571 const char *device_path;
572 E_Connman_Element *e;
576 fputs("ERROR: missing the device path\n", stderr);
584 fputs("ERROR: missing the policy value\n", stderr);
589 e = e_connman_device_get(device_path);
590 if (e_connman_device_policy_set(e, policy, NULL, NULL))
591 printf(":::Device %s policy set to \"%s\"\n", device_path, policy);
593 fputs("ERROR: can't set device policy\n", stderr);
598 _on_cmd_device_get_priority(char *cmd, char *args)
601 unsigned char priority;
602 E_Connman_Element *e;
606 fputs("ERROR: missing the device path\n", stderr);
612 e = e_connman_device_get(path);
613 if (e_connman_device_priority_get(e, &priority))
614 printf(":::Device %s Priority = %#02hhx (%d)\n", path, priority, priority);
616 fputs("ERROR: can't get device priority\n", stderr);
621 _on_cmd_device_set_priority(char *cmd, char *args)
623 char *next_args, *device_path, *p;
624 unsigned char priority;
625 E_Connman_Element *e;
629 fputs("ERROR: missing the device path\n", stderr);
633 next_args = _tok(args);
636 fputs("ERROR: missing the priority value\n", stderr);
640 priority = strtol(next_args, &p, 0);
643 fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
647 e = e_connman_device_get(device_path);
648 if (e_connman_device_priority_set(e, priority, NULL, NULL))
649 printf(":::Device %s priority set to %d\n", device_path, priority);
651 fputs("ERROR: can't set device priority\n", stderr);
656 _on_cmd_device_get_powered(char *cmd, char *args)
660 E_Connman_Element *e;
664 fputs("ERROR: missing the device path\n", stderr);
670 e = e_connman_device_get(path);
671 if (e_connman_device_powered_get(e, &powered))
672 printf(":::Device %s Powered = %hhu\n", path, powered);
674 fputs("ERROR: can't get device powered\n", stderr);
679 _on_cmd_device_set_powered(char *cmd, char *args)
681 char *device_path, *next_args;
683 E_Connman_Element *e;
687 fputs("ERROR: missing the device path\n", stderr);
691 next_args = _tok(args);
694 fputs("ERROR: missing the powered value\n", stderr);
697 powered = !!atol(next_args);
699 e = e_connman_device_get(device_path);
700 if (e_connman_device_powered_set(e, powered, NULL, NULL))
701 printf(":::Device %s powered set to %hhu\n", device_path, powered);
703 fputs("ERROR: can't set device powered\n", stderr);
708 _on_cmd_device_get_scan_interval(char *cmd, char *args)
711 unsigned short scan_interval;
712 E_Connman_Element *e;
716 fputs("ERROR: missing the device path\n", stderr);
722 e = e_connman_device_get(path);
723 if (e_connman_device_scan_interval_get(e, &scan_interval))
724 printf(":::Device %s ScanInterval = %hu\n", path, scan_interval);
726 fputs("ERROR: can't get device scan interval\n", stderr);
731 _on_cmd_device_set_scan_interval(char *cmd, char *args)
733 char *device_path, *next_args, *p;
734 unsigned short scan_interval;
735 E_Connman_Element *e;
739 fputs("ERROR: missing the device path\n", stderr);
743 next_args = _tok(args);
746 fputs("ERROR: missing the scan interval value\n", stderr);
749 scan_interval = strtol(next_args, &p, 0);
752 fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
756 e = e_connman_device_get(device_path);
757 if (e_connman_device_scan_interval_set(e, scan_interval, NULL, NULL))
758 printf(":::Device %s scan interval set to %hu\n", device_path, scan_interval);
760 fputs("ERROR: can't set device scan interval\n", stderr);
765 _on_cmd_device_get_scanning(char *cmd, char *args)
769 E_Connman_Element *e;
773 fputs("ERROR: missing the device path\n", stderr);
779 e = e_connman_device_get(path);
780 if (e_connman_device_scanning_get(e, &scanning))
781 printf(":::Device %s Scanning = %hhu\n", path, scanning);
783 fputs("ERROR: can't get device scanning\n", stderr);
788 _on_cmd_device_get_networks(char *cmd, char *args)
790 E_Connman_Element **networks;
793 E_Connman_Element *e;
797 fputs("ERROR: missing the device path\n", stderr);
803 e = e_connman_device_get(path);
804 if (!e_connman_device_networks_get(e, &count, &networks))
806 fputs("ERROR: can't get networks\n", stderr);
810 printf("BEG: all device network elements count = %d\n", count);
811 _elements_print(networks, count);
815 /* Profile Commands */
818 _on_cmd_profile_get_name(char *cmd, char *args)
820 const char *name, *path;
821 E_Connman_Element *e;
825 fputs("ERROR: missing the profile path\n", stderr);
831 e = e_connman_profile_get(path);
832 if (e_connman_profile_name_get(e, &name))
833 printf(":::Profile %s Name = \"%s\"\n", path, name);
835 fputs("ERROR: can't get profile name\n", stderr);
839 /* Connection Commands */
842 _on_cmd_connection_get_type(char *cmd, char *args)
844 const char *type, *path;
845 E_Connman_Element *e;
849 fputs("ERROR: missing the connection path\n", stderr);
855 e = e_connman_connection_get(path);
856 if (e_connman_connection_type_get(e, &type))
857 printf(":::Connection %s Type = \"%s\"\n", path, type);
859 fputs("ERROR: can't get connection type\n", stderr);
864 _on_cmd_connection_get_interface(char *cmd, char *args)
866 const char *interface, *path;
867 E_Connman_Element *e;
871 fputs("ERROR: missing the connection path\n", stderr);
877 e = e_connman_connection_get(path);
878 if (e_connman_connection_interface_get(e, &interface))
879 printf(":::Connection %s Interface = \"%s\"\n", path, interface);
881 fputs("ERROR: can't get connection type\n", stderr);
886 _on_cmd_connection_get_device(char *cmd, char *args)
888 E_Connman_Element *e, *device;
893 fputs("ERROR: missing the connection path\n", stderr);
899 e = e_connman_connection_get(path);
900 if (!e_connman_connection_device_get(e, &device))
901 fputs("ERROR: can't get connection device\n", stderr);
903 e_connman_element_print(stderr, device);
908 _on_cmd_connection_get_network(char *cmd, char *args)
910 E_Connman_Element *e, *network;
915 fputs("ERROR: missing the connection path\n", stderr);
921 e = e_connman_connection_get(path);
922 if (!e_connman_connection_network_get(e, &network))
923 fputs("ERROR: can't get connection network\n", stderr);
925 e_connman_element_print(stderr, network);
930 _on_cmd_connection_get_strength(char *cmd, char *args)
933 unsigned char strength;
934 E_Connman_Element *e;
938 fputs("ERROR: missing the connection path\n", stderr);
944 e = e_connman_connection_get(path);
945 if (e_connman_connection_strength_get(e, &strength))
946 printf(":::Connection %s Strength = %#02hhx (%d)\n", path, strength, strength);
948 fputs("ERROR: can't get connection strength\n", stderr);
953 _on_cmd_connection_get_default(char *cmd, char *args)
956 bool connection_default;
957 E_Connman_Element *e;
961 fputs("ERROR: missing the connection path\n", stderr);
967 e = e_connman_connection_get(path);
968 if (e_connman_connection_default_get(e, &connection_default))
969 printf(":::Connection %s Default = %hhu\n", path, connection_default);
971 fputs("ERROR: can't get connection default\n", stderr);
976 _on_cmd_connection_get_ipv4_method(char *cmd, char *args)
978 const char *method, *path;
979 E_Connman_Element *e;
983 fputs("ERROR: missing the connection path\n", stderr);
989 e = e_connman_connection_get(path);
990 if (e_connman_connection_ipv4_method_get(e, &method))
991 printf(":::Connection %s IPv4 Method = \"%s\"\n", path, method);
993 fputs("ERROR: can't get connection ipv4 method\n", stderr);
998 _on_cmd_connection_get_ipv4_address(char *cmd, char *args)
1000 const char *address, *path;
1001 E_Connman_Element *e;
1005 fputs("ERROR: missing the connection path\n", stderr);
1011 e = e_connman_connection_get(path);
1012 if (e_connman_connection_ipv4_address_get(e, &address))
1013 printf(":::Connection %s IPv4 Address = \"%s\"\n", path, address);
1015 fputs("ERROR: can't get connection ipv4 address\n", stderr);
1019 /* Network Commands */
1022 _on_cmd_network_connect(char *cmd, char *args)
1025 E_Connman_Element *e;
1029 fputs("ERROR: missing the network path\n", stderr);
1035 e = e_connman_network_get(path);
1036 if (e_connman_network_connect(e, NULL, NULL))
1037 printf(":::Connecting to Network %s...\n", path);
1039 fputs("ERROR: can't connect to network\n", stderr);
1044 _on_cmd_network_disconnect(char *cmd, char *args)
1047 E_Connman_Element *e;
1051 fputs("ERROR: missing the network path\n", stderr);
1057 e = e_connman_network_get(path);
1058 if (e_connman_network_disconnect(e, NULL, NULL))
1059 printf(":::Disconnecting Network %s...\n", path);
1061 fputs("ERROR: can't disconnect network\n", stderr);
1066 _on_cmd_network_get_name(char *cmd, char *args)
1068 const char *name, *path;
1069 E_Connman_Element *e;
1073 fputs("ERROR: missing the network path\n", stderr);
1079 e = e_connman_network_get(path);
1080 if (e_connman_network_name_get(e, &name))
1081 printf(":::Network %s Name = \"%s\"\n", path, name);
1083 fputs("ERROR: can't get network name\n", stderr);
1088 _on_cmd_network_get_available(char *cmd, char *args)
1092 E_Connman_Element *e;
1096 fputs("ERROR: missing the network path\n", stderr);
1102 e = e_connman_network_get(path);
1103 if (e_connman_network_available_get(e, &available))
1104 printf(":::Network %s Available = %hhu\n", path, available);
1106 fputs("ERROR: can't get network available\n", stderr);
1111 _on_cmd_network_get_connected(char *cmd, char *args)
1115 E_Connman_Element *e;
1119 fputs("ERROR: missing the network path\n", stderr);
1125 e = e_connman_network_get(path);
1126 if (e_connman_network_connected_get(e, &connected))
1127 printf(":::Network %s Connected = %hhu\n", path, connected);
1129 fputs("ERROR: can't get network connected\n", stderr);
1134 _on_cmd_network_get_remember(char *cmd, char *args)
1138 E_Connman_Element *e;
1142 fputs("ERROR: missing the network path\n", stderr);
1148 e = e_connman_network_get(path);
1149 if (e_connman_network_remember_get(e, &remember))
1150 printf(":::Network %s Remember = %hhu\n", path, remember);
1152 fputs("ERROR: can't get network remember\n", stderr);
1157 _on_cmd_network_set_remember(char *cmd, char *args)
1159 char *network_path, *next_args;
1161 E_Connman_Element *e;
1165 fputs("ERROR: missing the network path\n", stderr);
1168 network_path = args;
1169 next_args = _tok(args);
1172 fputs("ERROR: missing the remember value\n", stderr);
1176 remember = !!atol(next_args);
1178 e = e_connman_network_get(network_path);
1179 if (e_connman_network_remember_set(e, remember, NULL, NULL))
1180 printf(":::Network %s remember set to %d\n", network_path, remember);
1182 fputs("ERROR: can't set network remember\n", stderr);
1187 _on_cmd_network_get_strength(char *cmd, char *args)
1190 unsigned char strength;
1191 E_Connman_Element *e;
1195 fputs("ERROR: missing the network path\n", stderr);
1201 e = e_connman_network_get(path);
1202 if (e_connman_network_strength_get(e, &strength))
1203 printf(":::Network %s Strength = %#02hhx (%d)\n", path, strength, strength);
1205 fputs("ERROR: can't get network strength\n", stderr);
1210 _on_cmd_network_get_device(char *cmd, char *args)
1212 E_Connman_Element *e, *device;
1217 fputs("ERROR: missing the network path\n", stderr);
1223 e = e_connman_network_get(path);
1224 if (!e_connman_network_device_get(e, &device))
1225 fputs("ERROR: can't get network device\n", stderr);
1227 e_connman_element_print(stderr, device);
1232 _on_cmd_network_get_wifi_ssid(char *cmd, char *args)
1234 unsigned char *bytes;
1236 unsigned int i, count;
1237 E_Connman_Element *e;
1241 fputs("ERROR: missing the network path\n", stderr);
1247 e = e_connman_network_get(path);
1248 if (e_connman_network_wifi_ssid_get(e, &count, &bytes))
1250 printf(":::Network %s Wifi SSID = ", path);
1251 for (i = 0; i < count; i++)
1252 printf("%#02hhx (\"%c\"), ", bytes[i], bytes[i]);
1256 fputs("ERROR: can't get network wifi ssid\n", stderr);
1261 _on_cmd_network_get_wifi_mode(char *cmd, char *args)
1263 const char *wifi_mode, *path;
1264 E_Connman_Element *e;
1268 fputs("ERROR: missing the network path\n", stderr);
1274 e = e_connman_network_get(path);
1275 if (e_connman_network_wifi_mode_get(e, &wifi_mode))
1276 printf(":::Network %s Wifi Mode = \"%s\"\n", path, wifi_mode);
1278 fputs("ERROR: can't get network wifi mode\n", stderr);
1283 _on_cmd_network_set_wifi_mode(char *cmd, char *args)
1286 const char *network_path;
1287 E_Connman_Element *e;
1291 fputs("ERROR: missing the network path\n", stderr);
1294 network_path = args;
1295 wifi_mode = _tok(args);
1299 fputs("ERROR: missing the wifi mode value\n", stderr);
1304 e = e_connman_network_get(network_path);
1305 if (e_connman_network_wifi_mode_set(e, wifi_mode, NULL, NULL))
1306 printf(":::Network %s wifi mode set to \"%s\"\n", network_path, wifi_mode);
1308 fputs("ERROR: can't set network wifi mode\n", stderr);
1313 _on_cmd_network_get_wifi_security(char *cmd, char *args)
1315 const char *wifi_security, *path;
1316 E_Connman_Element *e;
1320 fputs("ERROR: missing the network path\n", stderr);
1326 e = e_connman_network_get(path);
1327 if (e_connman_network_wifi_security_get(e, &wifi_security))
1328 printf(":::Network %s Wifi Security = \"%s\"\n", path, wifi_security);
1330 fputs("ERROR: can't get network wifi security\n", stderr);
1335 _on_cmd_network_set_wifi_security(char *cmd, char *args)
1337 char *wifi_security, *network_path;
1338 E_Connman_Element *e;
1342 fputs("ERROR: missing the network path\n", stderr);
1345 network_path = args;
1346 wifi_security = _tok(args);
1350 fputs("ERROR: missing the wifi security value\n", stderr);
1353 _tok(wifi_security);
1355 e = e_connman_network_get(network_path);
1356 if (e_connman_network_wifi_security_set(e, wifi_security, NULL, NULL))
1357 printf(":::Network %s wifi security set to \"%s\"\n", network_path, wifi_security);
1359 fputs("ERROR: can't set network wifi security\n", stderr);
1364 _on_cmd_network_get_wifi_passphrase(char *cmd, char *args)
1366 const char *wifi_passphrase, *path;
1367 E_Connman_Element *e;
1371 fputs("ERROR: missing the network path\n", stderr);
1377 e = e_connman_network_get(path);
1378 if (e_connman_network_wifi_passphrase_get(e, &wifi_passphrase))
1379 printf(":::Network %s Wifi Passphrase = \"%s\"\n", path, wifi_passphrase);
1381 fputs("ERROR: can't get network wifi passphrase\n", stderr);
1386 _on_cmd_network_set_wifi_passphrase(char *cmd, char *args)
1388 char *wifi_passphrase, *network_path;
1389 E_Connman_Element *e;
1393 fputs("ERROR: missing the network path\n", stderr);
1396 network_path = args;
1397 wifi_passphrase = _tok(args);
1399 if (!wifi_passphrase)
1401 fputs("ERROR: missing the wifi passphrase value\n", stderr);
1404 _tok(wifi_passphrase);
1406 e = e_connman_network_get(network_path);
1407 if (e_connman_network_wifi_passphrase_set(e, wifi_passphrase, NULL, NULL))
1408 printf(":::Network %s wifi passphrase set to \"%s\"\n", network_path, wifi_passphrase);
1410 fputs("ERROR: can't set network wifi passphrase\n", stderr);
1416 _on_input(void *data, Ecore_Fd_Handler *fd_handler)
1422 int (*cb)(char *cmd, char *args);
1424 {"quit", _on_cmd_quit},
1425 {"sync", _on_cmd_sync},
1426 {"get_all", _on_cmd_get_all},
1427 {"print", _on_cmd_print},
1428 {"get_properties", _on_cmd_get_properties},
1429 {"set_property", _on_cmd_property_set},
1430 {"manager_get", _on_cmd_manager_get},
1431 {"manager_get_profiles", _on_cmd_manager_get_profiles},
1432 {"manager_get_devices", _on_cmd_manager_get_devices},
1433 {"manager_get_connections", _on_cmd_manager_get_connections},
1434 {"manager_register_agent", _on_cmd_manager_register_agent},
1435 {"manager_unregister_agent", _on_cmd_manager_unregister_agent},
1436 {"manager_get_state", _on_cmd_manager_get_state},
1437 {"manager_get_policy", _on_cmd_manager_get_policy},
1438 {"manager_set_policy", _on_cmd_manager_set_policy},
1439 {"manager_get_offline_mode", _on_cmd_manager_get_offline_mode},
1440 {"manager_set_offline_mode", _on_cmd_manager_set_offline_mode},
1441 {"device_create_network", _on_cmd_device_create_network},
1442 {"device_remove_network", _on_cmd_device_remove_network},
1443 {"device_propose_scan", _on_cmd_device_propose_scan},
1444 {"device_get_name", _on_cmd_device_get_name},
1445 {"device_get_type", _on_cmd_device_get_type},
1446 {"device_get_interface", _on_cmd_device_get_interface},
1447 {"device_get_policy", _on_cmd_device_get_policy},
1448 {"device_set_policy", _on_cmd_device_set_policy},
1449 {"device_get_priority", _on_cmd_device_get_priority},
1450 {"device_set_priority", _on_cmd_device_set_priority},
1451 {"device_get_powered", _on_cmd_device_get_powered},
1452 {"device_set_powered", _on_cmd_device_set_powered},
1453 {"device_get_scan_interval", _on_cmd_device_get_scan_interval},
1454 {"device_set_scan_interval", _on_cmd_device_set_scan_interval},
1455 {"device_get_scanning", _on_cmd_device_get_scanning},
1456 {"device_get_networks", _on_cmd_device_get_networks},
1457 {"profile_get_name", _on_cmd_profile_get_name},
1458 {"connection_get_type", _on_cmd_connection_get_type},
1459 {"connection_get_interface", _on_cmd_connection_get_interface},
1460 {"connection_get_strength", _on_cmd_connection_get_strength},
1461 {"connection_get_default", _on_cmd_connection_get_default},
1462 {"connection_get_device", _on_cmd_connection_get_device},
1463 {"connection_get_network", _on_cmd_connection_get_network},
1464 {"connection_get_ipv4_method", _on_cmd_connection_get_ipv4_method},
1465 {"connection_get_ipv4_address", _on_cmd_connection_get_ipv4_address},
1466 {"network_connect", _on_cmd_network_connect},
1467 {"network_disconnect", _on_cmd_network_disconnect},
1468 {"network_get_name", _on_cmd_network_get_name},
1469 {"network_get_available", _on_cmd_network_get_available},
1470 {"network_get_connected", _on_cmd_network_get_connected},
1471 {"network_get_remember", _on_cmd_network_get_remember},
1472 {"network_set_remember", _on_cmd_network_set_remember},
1473 {"network_get_strength", _on_cmd_network_get_strength},
1474 {"network_get_device", _on_cmd_network_get_device},
1475 {"network_get_wifi_ssid", _on_cmd_network_get_wifi_ssid},
1476 {"network_get_wifi_mode", _on_cmd_network_get_wifi_mode},
1477 {"network_set_wifi_mode", _on_cmd_network_set_wifi_mode},
1478 {"network_get_wifi_security", _on_cmd_network_get_wifi_security},
1479 {"network_set_wifi_security", _on_cmd_network_set_wifi_security},
1480 {"network_get_wifi_passphrase", _on_cmd_network_get_wifi_passphrase},
1481 {"network_set_wifi_passphrase", _on_cmd_network_set_wifi_passphrase},
1485 if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR))
1487 fputs("ERROR: reading from stdin, exit\n", stderr);
1491 if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
1493 fputs("ERROR: nothing to read?\n", stderr);
1497 if (!fgets(buf, sizeof(buf), stdin))
1499 fprintf(stderr, "ERROR: could not read command: %s\n", strerror(errno));
1500 ecore_main_loop_quit();
1505 while (isspace(*cmd))
1508 args = strchr(cmd, ' ');
1516 while (isspace(*args))
1519 p = args + strlen(args) - 1;
1527 p = cmd + strlen(cmd) - 1;
1532 if (strcmp(cmd, "help") == 0)
1536 printf("Commands with '%s' in the name:\n", args);
1537 for (itr = maps; itr->cmd != NULL; itr++)
1538 if (strstr(itr->cmd, args))
1539 printf("\t%s\n", itr->cmd);
1543 fputs("Commands:\n", stdout);
1544 for (itr = maps; itr->cmd != NULL; itr++)
1545 printf("\t%s\n", itr->cmd);
1547 fputc('\n', stdout);
1551 for (itr = maps; itr->cmd != NULL; itr++)
1552 if (strcmp(itr->cmd, cmd) == 0)
1553 return itr->cb(cmd, args);
1555 printf("unknown command \"%s\", args=%s\n", cmd, args);
1560 main(int argc, char *argv[])
1562 E_DBus_Connection *c;
1568 c = e_dbus_bus_get(DBUS_BUS_SYSTEM);
1570 printf("ERROR: can't connect to system session\n");
1574 e_connman_system_init(c);
1575 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_ADD, _on_element_add, NULL);
1576 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_DEL, _on_element_del, NULL);
1577 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_UPDATED,
1578 _on_element_updated, NULL);
1580 ecore_main_fd_handler_add
1581 (0, ECORE_FD_READ | ECORE_FD_ERROR, _on_input, NULL, NULL, NULL);
1583 ecore_main_loop_begin();
1585 e_connman_system_shutdown();
1587 e_dbus_connection_close(c);
1592 fputs("DBG: clean exit.\n", stderr);