8 _elements_print(E_Connman_Element **elements, unsigned 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 = %u\n", count);
21 _strings_print(const char **strings, unsigned int count)
24 for (i = 0; i < count; i++)
25 printf("--- strings %d: \"%s\"\n", i, strings[i]);
27 printf("END: all strings count = %u\n", count);
31 _on_element_add(void *data, int type, void *info)
33 E_Connman_Element *element = info;
34 printf(">>> %s\n", element->path);
39 _on_element_del(void *data, int type, void *info)
41 E_Connman_Element *element = info;
42 printf("<<< %s\n", element->path);
47 _on_element_updated(void *data, int type, void *info)
49 E_Connman_Element *element = info;
50 printf("!!! %s\n", element->path);
51 e_connman_element_print(stderr, element);
56 _on_cmd_quit(char *cmd, char *args)
58 fputs("Bye!\n", stderr);
59 ecore_main_loop_quit();
64 _on_cmd_sync(char *cmd, char *args)
66 e_connman_manager_sync_elements();
88 _on_cmd_get_all(char *cmd, char *args)
90 E_Connman_Element **elements;
101 ret = e_connman_elements_get_all_type(type, &count, &elements);
103 ret = e_connman_elements_get_all(&count, &elements);
106 fputs("ERROR: could not get elements\n", stderr);
109 printf("BEG: all elements type=%s count = %d\n", type, count);
110 _elements_print(elements, count);
116 static E_Connman_Element *
117 _element_from_args(char *args, char **next_args)
119 E_Connman_Element *element;
123 fputs("ERROR: missing element path\n", stderr);
128 *next_args = _tok(args);
129 element = e_connman_element_get(args);
131 fprintf(stderr, "ERROR: no element called \"%s\".\n", args);
137 _on_cmd_print(char *cmd, char *args)
140 E_Connman_Element *element = _element_from_args(args, &next_args);
142 e_connman_element_print(stdout, element);
147 _on_cmd_get_properties(char *cmd, char *args)
150 E_Connman_Element *element = _element_from_args(args, &next_args);
152 e_connman_element_properties_sync(element);
157 _on_cmd_property_set(char *cmd, char *args)
159 char *next_args, *name, *p;
160 E_Connman_Element *element = _element_from_args(args, &next_args);
172 fputs("ERROR: missing parameters name, type and value.\n", stderr);
180 fputs("ERROR: missing parameters type and value.\n", stderr);
187 fputs("ERROR: missing parameter value.\n", stderr);
194 case DBUS_TYPE_BOOLEAN:
195 vlong = !!atol(next_args);
196 value = (void *)vlong;
197 fprintf(stderr, "DBG: boolean is: %ld\n", vlong);
199 case DBUS_TYPE_UINT16:
200 vu16 = strtol(next_args, &p, 0);
203 fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
207 fprintf(stderr, "DBG: u16 is: %hu\n", vu16);
209 case DBUS_TYPE_UINT32:
210 vu32 = strtol(next_args, &p, 0);
213 fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
217 fprintf(stderr, "DBG: u16 is: %u\n", vu32);
219 case DBUS_TYPE_STRING:
220 case DBUS_TYPE_OBJECT_PATH:
221 p = next_args + strlen(next_args);
224 while (p > next_args && isspace(*p))
228 fprintf(stderr, "ERROR: invalid string \"%s\".\n", next_args);
232 fprintf(stderr, "DBG: string is: \"%s\"\n", next_args);
235 fprintf(stderr, "ERROR: don't know how to parse type '%c' (%d)\n",
240 fprintf(stderr, "set_property %s [%p] %s %c %p...\n",
241 args, element, name, type, value);
242 if (!e_connman_element_property_set(element, name, type, value))
244 fputs("ERROR: error setting property.\n", stderr);
251 /* Manager Commands */
254 _on_cmd_manager_get(char *cmd, char *args)
256 E_Connman_Element *element;
257 element = e_connman_manager_get();
258 e_connman_element_print(stderr, element);
263 _on_cmd_manager_get_profiles(char *cmd, char *args)
266 E_Connman_Element **profiles;
268 if (!e_connman_manager_profiles_get(&count, &profiles))
270 fputs("ERROR: can't get profiles\n", stderr);
273 printf("BEG: all manager profiles elements count = %d\n", count);
274 _elements_print(profiles, count);
279 _on_cmd_manager_get_devices(char *cmd, char *args)
282 E_Connman_Element **devices;
284 if (!e_connman_manager_devices_get(&count, &devices))
286 fputs("ERROR: can't get devices\n", stderr);
289 printf("BEG: all manager devices elements count = %d\n", count);
290 _elements_print(devices, count);
295 _on_cmd_manager_get_services(char *cmd, char *args)
298 E_Connman_Element **services;
300 if (!e_connman_manager_services_get(&count, &services))
302 fputs("ERROR: can't get services\n", stderr);
305 printf("BEG: all manager services elements count = %d\n", count);
306 _elements_print(services, count);
311 _on_cmd_manager_register_agent(char *cmd, char *args)
317 fputs("ERROR: missing the object path\n", stderr);
322 if (e_connman_manager_agent_register(path, NULL, NULL))
323 printf(":::Registering agent %s...\n", path);
325 fprintf(stderr, "ERROR: can't register agent %s\n", path);
331 _on_cmd_manager_unregister_agent(char *cmd, char *args)
337 fputs("ERROR: missing the object path\n", stderr);
342 if (e_connman_manager_agent_unregister(path, NULL, NULL))
343 printf(":::Unregistering agent %s...\n", path);
345 fprintf(stderr, "ERROR: can't unregister agent %s\n", path);
351 _on_cmd_manager_get_state(char *cmd, char *args)
354 if (e_connman_manager_state_get(&state))
355 printf(":::Manager state = \"%s\"\n", state);
357 fputs("ERROR: can't get manager state\n", stderr);
362 _on_cmd_manager_get_offline_mode(char *cmd, char *args)
365 if (e_connman_manager_offline_mode_get(&offline))
366 printf(":::Manager Offline Mode = %hhu\n", offline);
368 fputs("ERROR: can't get manager offline mode\n", stderr);
373 _on_cmd_manager_set_offline_mode(char *cmd, char *args)
378 fputs("ERROR: missing the offline mode value\n", stderr);
382 offline = !!atol(args);
383 if (e_connman_manager_offline_mode_set(offline, NULL, NULL))
384 printf(":::Manager Offline Mode set to %hhu\n", offline);
386 fputs("ERROR: can't set manager offline mode\n", stderr);
391 _on_cmd_manager_request_scan(char *cmd, char *args)
399 if (e_connman_manager_request_scan(args, NULL, NULL))
400 printf(":::Manager Request Scan for %s\n", args[0] ? args : "<all>");
402 fputs("ERROR: can't request scan on manager\n", stderr);
407 _on_cmd_manager_technology_enable(char *cmd, char *args)
411 fputs("ERROR: missing the technology type\n", stderr);
416 if (e_connman_manager_technology_enable(args, NULL, NULL))
417 printf(":::Manager Enable Technology %s\n", args);
419 fputs("ERROR: can't enable technology on manager\n", stderr);
424 _on_cmd_manager_technology_disable(char *cmd, char *args)
428 fputs("ERROR: missing the technology type\n", stderr);
433 if (e_connman_manager_technology_disable(args, NULL, NULL))
434 printf(":::Manager Disable Technology %s\n", args);
436 fputs("ERROR: can't disable technology on manager\n", stderr);
441 _on_cmd_manager_get_technologies_available(char *cmd, char *args)
443 const char **strings;
446 if (!e_connman_manager_technologies_available_get(&count, &strings))
447 fputs("ERROR: can't get available technologies\n", stderr);
450 printf("BEG: available technologies count = %u\n", count);
451 _strings_print(strings, count);
458 _on_cmd_manager_get_technologies_enabled(char *cmd, char *args)
460 const char **strings;
463 if (!e_connman_manager_technologies_enabled_get(&count, &strings))
464 fputs("ERROR: can't get enabled technologies\n", stderr);
467 printf("BEG: enabled technologies count = %u\n", count);
468 _strings_print(strings, count);
475 _on_cmd_manager_get_technologies_connected(char *cmd, char *args)
477 const char **strings;
480 if (!e_connman_manager_technologies_connected_get(&count, &strings))
481 fputs("ERROR: can't get connected technologies\n", stderr);
484 printf("BEG: connected technologies count = %u\n", count);
485 _strings_print(strings, count);
492 _on_cmd_manager_profile_remove(char *cmd, char *args)
494 E_Connman_Element *e;
498 fputs("ERROR: missing the profile path\n", stderr);
503 e = e_connman_profile_get(args);
504 if (e_connman_manager_profile_remove(e, NULL, NULL))
505 printf(":::Manager Remove Profile %s\n", args);
507 fputs("ERROR: can't remove profile from manager\n", stderr);
512 _on_cmd_manager_profile_get_active(char *cmd, char *args)
514 E_Connman_Element *e;
516 if (!e_connman_manager_profile_active_get(&e))
517 fputs("ERROR: can't active_get profile from manager\n", stderr);
519 e_connman_element_print(stderr, e);
524 _on_cmd_manager_profile_set_active(char *cmd, char *args)
526 E_Connman_Element *e;
530 fputs("ERROR: missing the profile path\n", stderr);
535 e = e_connman_profile_get(args);
536 if (e_connman_manager_profile_active_set(e, NULL, NULL))
537 printf(":::Manager Active Profile set to %s\n", args);
539 fputs("ERROR: can't set active profile\n", stderr);
543 /* Device Commands */
545 _on_cmd_device_propose_scan(char *cmd, char *args)
548 E_Connman_Element *e;
552 fputs("ERROR: missing the device path\n", stderr);
558 e = e_connman_device_get(path);
559 if (e_connman_device_propose_scan(e, NULL, NULL))
560 printf(":::Proposing scan %s...\n", path);
562 fputs("ERROR: can't propose scan\n", stderr);
567 _on_cmd_device_get_address(char *cmd, char *args)
569 const char *address, *path;
570 E_Connman_Element *e;
574 fputs("ERROR: missing the device path\n", stderr);
580 e = e_connman_device_get(path);
581 if (e_connman_device_address_get(e, &address))
582 printf(":::Device %s Address = \"%s\"\n", path, address);
584 fputs("ERROR: can't get device address\n", stderr);
589 _on_cmd_device_get_name(char *cmd, char *args)
591 const char *name, *path;
592 E_Connman_Element *e;
596 fputs("ERROR: missing the device path\n", stderr);
602 e = e_connman_device_get(path);
603 if (e_connman_device_name_get(e, &name))
604 printf(":::Device %s Name = \"%s\"\n", path, name);
606 fputs("ERROR: can't get device name\n", stderr);
611 _on_cmd_device_get_type(char *cmd, char *args)
613 const char *type, *path;
614 E_Connman_Element *e;
618 fputs("ERROR: missing the device path\n", stderr);
624 e = e_connman_device_get(path);
625 if (e_connman_device_type_get(e, &type))
626 printf(":::Device %s Type = \"%s\"\n", path, type);
628 fputs("ERROR: can't get device type\n", stderr);
633 _on_cmd_device_get_interface(char *cmd, char *args)
635 const char *interface, *path;
636 E_Connman_Element *e;
640 fputs("ERROR: missing the device path\n", stderr);
646 e = e_connman_device_get(path);
647 if (e_connman_device_interface_get(e, &interface))
648 printf(":::Device %s Interface = \"%s\"\n", path, interface);
650 fputs("ERROR: can't get device interface\n", stderr);
655 _on_cmd_device_get_powered(char *cmd, char *args)
659 E_Connman_Element *e;
663 fputs("ERROR: missing the device path\n", stderr);
669 e = e_connman_device_get(path);
670 if (e_connman_device_powered_get(e, &powered))
671 printf(":::Device %s Powered = %hhu\n", path, powered);
673 fputs("ERROR: can't get device powered\n", stderr);
678 _on_cmd_device_set_powered(char *cmd, char *args)
680 char *device_path, *next_args;
682 E_Connman_Element *e;
686 fputs("ERROR: missing the device path\n", stderr);
690 next_args = _tok(args);
693 fputs("ERROR: missing the powered value\n", stderr);
696 powered = !!atol(next_args);
698 e = e_connman_device_get(device_path);
699 if (e_connman_device_powered_set(e, powered, NULL, NULL))
700 printf(":::Device %s powered set to %hhu\n", device_path, powered);
702 fputs("ERROR: can't set device powered\n", stderr);
707 _on_cmd_device_get_scan_interval(char *cmd, char *args)
710 unsigned short scan_interval;
711 E_Connman_Element *e;
715 fputs("ERROR: missing the device path\n", stderr);
721 e = e_connman_device_get(path);
722 if (e_connman_device_scan_interval_get(e, &scan_interval))
723 printf(":::Device %s ScanInterval = %hu\n", path, scan_interval);
725 fputs("ERROR: can't get device scan interval\n", stderr);
730 _on_cmd_device_set_scan_interval(char *cmd, char *args)
732 char *device_path, *next_args, *p;
733 unsigned short scan_interval;
734 E_Connman_Element *e;
738 fputs("ERROR: missing the device path\n", stderr);
742 next_args = _tok(args);
745 fputs("ERROR: missing the scan interval value\n", stderr);
748 scan_interval = strtol(next_args, &p, 0);
751 fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
755 e = e_connman_device_get(device_path);
756 if (e_connman_device_scan_interval_set(e, scan_interval, NULL, NULL))
757 printf(":::Device %s scan interval set to %hu\n", device_path, scan_interval);
759 fputs("ERROR: can't set device scan interval\n", stderr);
764 _on_cmd_device_get_scanning(char *cmd, char *args)
768 E_Connman_Element *e;
772 fputs("ERROR: missing the device path\n", stderr);
778 e = e_connman_device_get(path);
779 if (e_connman_device_scanning_get(e, &scanning))
780 printf(":::Device %s Scanning = %hhu\n", path, scanning);
782 fputs("ERROR: can't get device scanning\n", stderr);
787 _on_cmd_device_get_networks(char *cmd, char *args)
789 E_Connman_Element **networks;
792 E_Connman_Element *e;
796 fputs("ERROR: missing the device path\n", stderr);
802 e = e_connman_device_get(path);
803 if (!e_connman_device_networks_get(e, &count, &networks))
805 fputs("ERROR: can't get networks\n", stderr);
809 printf("BEG: all device network elements count = %d\n", count);
810 _elements_print(networks, count);
814 /* Profile Commands */
817 _on_cmd_profile_get_name(char *cmd, char *args)
819 const char *name, *path;
820 E_Connman_Element *e;
824 fputs("ERROR: missing the profile path\n", stderr);
830 e = e_connman_profile_get(path);
831 if (e_connman_profile_name_get(e, &name))
832 printf(":::Profile %s Name = \"%s\"\n", path, name);
834 fputs("ERROR: can't get profile name\n", stderr);
839 _on_cmd_profile_set_name(char *cmd, char *args)
841 char *path, *next_args;
842 E_Connman_Element *e;
846 fputs("ERROR: missing the profile path\n", stderr);
850 next_args = _tok(args);
853 fputs("ERROR: missing the offline mode value\n", stderr);
858 e = e_connman_profile_get(path);
859 if (e_connman_profile_name_set(e, next_args, NULL, NULL))
860 printf(":::Profile %s Name set to %s\n", path, next_args);
862 fputs("ERROR: can't set profile name\n", stderr);
867 _on_cmd_profile_get_offline_mode(char *cmd, char *args)
871 E_Connman_Element *e;
875 fputs("ERROR: missing the profile path\n", stderr);
881 e = e_connman_profile_get(path);
882 if (e_connman_profile_offline_mode_get(e, &offline))
883 printf(":::Profile %s Offline Mode = %hhu\n", path, offline);
885 fputs("ERROR: can't get profile offline mode\n", stderr);
890 _on_cmd_profile_set_offline_mode(char *cmd, char *args)
892 char *path, *next_args;
894 E_Connman_Element *e;
898 fputs("ERROR: missing the profile path\n", stderr);
902 next_args = _tok(args);
905 fputs("ERROR: missing the offline mode value\n", stderr);
909 offline = !!atol(next_args);
911 e = e_connman_profile_get(path);
912 if (e_connman_profile_offline_mode_set(e, offline, NULL, NULL))
913 printf(":::Profile %s Offline Mode set to %hhu\n", path, offline);
915 fputs("ERROR: can't set profile offline mode\n", stderr);
920 _on_cmd_profile_get_services(char *cmd, char *args)
922 E_Connman_Element **services;
923 E_Connman_Element *e;
929 fputs("ERROR: missing the profile path\n", stderr);
935 e = e_connman_profile_get(path);
936 if (!e_connman_profile_services_get(e, &count, &services))
938 fputs("ERROR: can't get services\n", stderr);
941 printf("BEG: all profile services count = %d\n", count);
942 _elements_print(services, count);
947 /* Network Commands */
950 _on_cmd_network_get_address(char *cmd, char *args)
952 const char *address, *path;
953 E_Connman_Element *e;
957 fputs("ERROR: missing the network path\n", stderr);
963 e = e_connman_network_get(path);
964 if (e_connman_network_address_get(e, &address))
965 printf(":::Network %s Address = \"%s\"\n", path, address);
967 fputs("ERROR: can't get network address\n", stderr);
972 _on_cmd_network_get_name(char *cmd, char *args)
974 const char *name, *path;
975 E_Connman_Element *e;
979 fputs("ERROR: missing the network path\n", stderr);
985 e = e_connman_network_get(path);
986 if (e_connman_network_name_get(e, &name))
987 printf(":::Network %s Name = \"%s\"\n", path, name);
989 fputs("ERROR: can't get network name\n", stderr);
994 _on_cmd_network_get_connected(char *cmd, char *args)
998 E_Connman_Element *e;
1002 fputs("ERROR: missing the network path\n", stderr);
1008 e = e_connman_network_get(path);
1009 if (e_connman_network_connected_get(e, &connected))
1010 printf(":::Network %s Connected = %hhu\n", path, connected);
1012 fputs("ERROR: can't get network connected\n", stderr);
1017 _on_cmd_network_get_strength(char *cmd, char *args)
1020 unsigned char strength;
1021 E_Connman_Element *e;
1025 fputs("ERROR: missing the network path\n", stderr);
1031 e = e_connman_network_get(path);
1032 if (e_connman_network_strength_get(e, &strength))
1033 printf(":::Network %s Strength = %#02hhx (%d)\n", path, strength, strength);
1035 fputs("ERROR: can't get network strength\n", stderr);
1040 _on_cmd_network_get_frequency(char *cmd, char *args)
1043 unsigned short frequency;
1044 E_Connman_Element *e;
1048 fputs("ERROR: missing the network path\n", stderr);
1054 e = e_connman_network_get(path);
1055 if (e_connman_network_frequency_get(e, &frequency))
1056 printf(":::Network %s Frequency = %#04hx (%d)\n", path, frequency, frequency);
1058 fputs("ERROR: can't get network frequency\n", stderr);
1063 _on_cmd_network_get_device(char *cmd, char *args)
1065 E_Connman_Element *e, *device;
1070 fputs("ERROR: missing the network path\n", stderr);
1076 e = e_connman_network_get(path);
1077 if (!e_connman_network_device_get(e, &device))
1078 fputs("ERROR: can't get network device\n", stderr);
1080 e_connman_element_print(stderr, device);
1085 _on_cmd_network_get_wifi_ssid(char *cmd, char *args)
1087 unsigned char *bytes;
1089 unsigned int i, count;
1090 E_Connman_Element *e;
1094 fputs("ERROR: missing the network path\n", stderr);
1100 e = e_connman_network_get(path);
1101 if (e_connman_network_wifi_ssid_get(e, &count, &bytes))
1103 printf(":::Network %s Wifi SSID = ", path);
1104 for (i = 0; i < count; i++)
1105 printf("%#02hhx (\"%c\"), ", bytes[i], bytes[i]);
1109 fputs("ERROR: can't get network wifi ssid\n", stderr);
1114 _on_cmd_network_get_wifi_mode(char *cmd, char *args)
1116 const char *wifi_mode, *path;
1117 E_Connman_Element *e;
1121 fputs("ERROR: missing the network path\n", stderr);
1127 e = e_connman_network_get(path);
1128 if (e_connman_network_wifi_mode_get(e, &wifi_mode))
1129 printf(":::Network %s Wifi Mode = \"%s\"\n", path, wifi_mode);
1131 fputs("ERROR: can't get network wifi mode\n", stderr);
1136 _on_cmd_network_get_wifi_security(char *cmd, char *args)
1138 const char *wifi_security, *path;
1139 E_Connman_Element *e;
1143 fputs("ERROR: missing the network path\n", stderr);
1149 e = e_connman_network_get(path);
1150 if (e_connman_network_wifi_security_get(e, &wifi_security))
1151 printf(":::Network %s Wifi Security = \"%s\"\n", path, wifi_security);
1153 fputs("ERROR: can't get network wifi security\n", stderr);
1158 _on_cmd_network_get_wifi_passphrase(char *cmd, char *args)
1160 const char *wifi_passphrase, *path;
1161 E_Connman_Element *e;
1165 fputs("ERROR: missing the network path\n", stderr);
1171 e = e_connman_network_get(path);
1172 if (e_connman_network_wifi_passphrase_get(e, &wifi_passphrase))
1173 printf(":::Network %s Wifi Passphrase = \"%s\"\n", path, wifi_passphrase);
1175 fputs("ERROR: can't get network wifi passphrase\n", stderr);
1180 _on_cmd_network_get_wifi_channel(char *cmd, char *args)
1183 E_Connman_Element *e;
1184 unsigned short wifi_channel;
1188 fputs("ERROR: missing the network path\n", stderr);
1194 e = e_connman_network_get(path);
1195 if (e_connman_network_wifi_channel_get(e, &wifi_channel))
1196 printf(":::Network %s Wifi Channel = %#02hx (%d)\n", path, wifi_channel, wifi_channel);
1198 fputs("ERROR: can't get network wifi channel\n", stderr);
1203 _on_cmd_network_get_wifi_eap(char *cmd, char *args)
1205 const char *wifi_eap, *path;
1206 E_Connman_Element *e;
1210 fputs("ERROR: missing the network path\n", stderr);
1216 e = e_connman_network_get(path);
1217 if (e_connman_network_wifi_eap_get(e, &wifi_eap))
1218 printf(":::Network %s Wifi EAP = \"%s\"\n", path, wifi_eap);
1220 fputs("ERROR: can't get network wifi eap\n", stderr);
1224 /* Services Commands */
1226 _on_cmd_service_connect(char *cmd, char *args)
1229 E_Connman_Element *e;
1233 fputs("ERROR: missing the service path\n", stderr);
1239 e = e_connman_service_get(path);
1240 if (e_connman_service_connect(e, NULL, NULL))
1241 printf(":::Connecting to Service %s...\n", path);
1243 fputs("ERROR: can't connect to service\n", stderr);
1248 _on_cmd_service_disconnect(char *cmd, char *args)
1251 E_Connman_Element *e;
1255 fputs("ERROR: missing the service path\n", stderr);
1261 e = e_connman_service_get(path);
1262 if (e_connman_service_disconnect(e, NULL, NULL))
1263 printf(":::Disconnecting Service %s...\n", path);
1265 fputs("ERROR: can't disconnect service\n", stderr);
1270 _on_cmd_service_remove(char *cmd, char *args)
1273 E_Connman_Element *e;
1277 fputs("ERROR: missing the service path\n", stderr);
1283 e = e_connman_service_get(path);
1284 if (e_connman_service_remove(e, NULL, NULL))
1285 printf(":::Removing Service %s...\n", path);
1287 fputs("ERROR: can't remove service\n", stderr);
1292 _on_cmd_service_move_before(char *cmd, char *args)
1294 char *path, *service_path;
1295 E_Connman_Element *e;
1299 fputs("ERROR: missing the service path\n", stderr);
1302 service_path = args;
1307 fputs("ERROR: missing the object service\n", stderr);
1312 e = e_connman_service_get(service_path);
1313 if (e_connman_service_move_before(e, path, NULL, NULL))
1314 printf(":::Moving before %s...\n", path);
1316 fputs("ERROR: can't move before\n", stderr);
1321 _on_cmd_service_move_after(char *cmd, char *args)
1323 char *path, *service_path;
1324 E_Connman_Element *e;
1328 fputs("ERROR: missing the service path\n", stderr);
1331 service_path = args;
1336 fputs("ERROR: missing the object service\n", stderr);
1341 e = e_connman_service_get(service_path);
1342 if (e_connman_service_move_after(e, path, NULL, NULL))
1343 printf(":::Moving after %s...\n", path);
1345 fputs("ERROR: can't move after\n", stderr);
1350 _on_cmd_service_get_state(char *cmd, char *args)
1352 const char *state, *path;
1353 E_Connman_Element *e;
1357 fputs("ERROR: missing the service path\n", stderr);
1363 e = e_connman_service_get(path);
1364 if (e_connman_service_state_get(e, &state))
1365 printf(":::Service %s State = \"%s\"\n", path, state);
1367 fputs("ERROR: can't get service state\n", stderr);
1372 _on_cmd_service_get_error(char *cmd, char *args)
1374 const char *error, *path;
1375 E_Connman_Element *e;
1379 fputs("ERROR: missing the service path\n", stderr);
1385 e = e_connman_service_get(path);
1386 if (e_connman_service_error_get(e, &error))
1387 printf(":::Service %s Error = \"%s\"\n", path, error);
1389 fputs("ERROR: can't get service error\n", stderr);
1394 _on_cmd_service_get_name(char *cmd, char *args)
1396 const char *name, *path;
1397 E_Connman_Element *e;
1401 fputs("ERROR: missing the service path\n", stderr);
1407 e = e_connman_service_get(path);
1408 if (e_connman_service_name_get(e, &name))
1409 printf(":::Service %s Name = \"%s\"\n", path, name);
1411 fputs("ERROR: can't get service name\n", stderr);
1416 _on_cmd_service_get_type(char *cmd, char *args)
1418 const char *type, *path;
1419 E_Connman_Element *e;
1423 fputs("ERROR: missing the service path\n", stderr);
1429 e = e_connman_service_get(path);
1430 if (e_connman_service_type_get(e, &type))
1431 printf(":::Service %s Type = \"%s\"\n", path, type);
1433 fputs("ERROR: can't get service type\n", stderr);
1438 _on_cmd_service_get_mode(char *cmd, char *args)
1440 const char *mode, *path;
1441 E_Connman_Element *e;
1445 fputs("ERROR: missing the service path\n", stderr);
1451 e = e_connman_service_get(path);
1452 if (e_connman_service_mode_get(e, &mode))
1453 printf(":::Service %s Mode = \"%s\"\n", path, mode);
1455 fputs("ERROR: can't get service mode\n", stderr);
1460 _on_cmd_service_get_security(char *cmd, char *args)
1462 const char *security, *path;
1463 E_Connman_Element *e;
1467 fputs("ERROR: missing the service path\n", stderr);
1473 e = e_connman_service_get(path);
1474 if (e_connman_service_security_get(e, &security))
1475 printf(":::Service %s Security = \"%s\"\n", path, security);
1477 fputs("ERROR: can't get service security\n", stderr);
1482 _on_cmd_service_get_passphrase(char *cmd, char *args)
1484 const char *passphrase, *path;
1485 E_Connman_Element *e;
1489 fputs("ERROR: missing the service path\n", stderr);
1495 e = e_connman_service_get(path);
1496 if (e_connman_service_passphrase_get(e, &passphrase))
1497 printf(":::Service %s Passphrase = \"%s\"\n", path, passphrase);
1499 fputs("ERROR: can't get service passphrase\n", stderr);
1504 _on_cmd_service_set_passphrase(char *cmd, char *args)
1506 char *passphrase, *path;
1507 E_Connman_Element *e;
1511 fputs("ERROR: missing the service path\n", stderr);
1515 passphrase = _tok(args);
1519 fputs("ERROR: missing the passphrase value\n", stderr);
1524 e = e_connman_service_get(path);
1525 if (e_connman_service_passphrase_set(e, passphrase, NULL, NULL))
1526 printf(":::Service %s passphrase set to \"%s\"\n", path, passphrase);
1528 fputs("ERROR: can't set service passphrase\n", stderr);
1533 _on_cmd_service_get_passphrase_required(char *cmd, char *args)
1537 E_Connman_Element *e;
1541 fputs("ERROR: missing the service path\n", stderr);
1547 e = e_connman_service_get(path);
1548 if (e_connman_service_passphrase_required_get(e, &passphrase))
1549 printf(":::Service %s Passphrase Required = %hhu\n", path, passphrase);
1551 fputs("ERROR: can't get service passphrase required\n", stderr);
1556 _on_cmd_service_get_strength(char *cmd, char *args)
1559 unsigned char strength;
1560 E_Connman_Element *e;
1564 fputs("ERROR: missing the service path\n", stderr);
1570 e = e_connman_service_get(path);
1571 if (e_connman_service_strength_get(e, &strength))
1572 printf(":::Service %s Strength = %#02hhx (%d)\n", path, strength, strength);
1574 fputs("ERROR: can't get service strength\n", stderr);
1579 _on_cmd_service_get_favorite(char *cmd, char *args)
1583 E_Connman_Element *e;
1587 fputs("ERROR: missing the service path\n", stderr);
1593 e = e_connman_service_get(path);
1594 if (e_connman_service_favorite_get(e, &favorite))
1595 printf(":::Service %s Favorite = %hhu\n", path, favorite);
1597 fputs("ERROR: can't get service favorite\n", stderr);
1602 _on_cmd_service_get_immutable(char *cmd, char *args)
1606 E_Connman_Element *e;
1610 fputs("ERROR: missing the service path\n", stderr);
1616 e = e_connman_service_get(path);
1617 if (e_connman_service_immutable_get(e, &immutable))
1618 printf(":::Service %s Immutable = %hhu\n", path, immutable);
1620 fputs("ERROR: can't get service immutable\n", stderr);
1625 _on_cmd_service_get_auto_connect(char *cmd, char *args)
1629 E_Connman_Element *e;
1633 fputs("ERROR: missing the service path\n", stderr);
1639 e = e_connman_service_get(path);
1640 if (e_connman_service_auto_connect_get(e, &auto_connect))
1641 printf(":::Service %s Auto Connect = %hhu\n", path, auto_connect);
1643 fputs("ERROR: can't get service auto connect\n", stderr);
1648 _on_cmd_service_set_auto_connect(char *cmd, char *args)
1650 char *path, *next_args;
1652 E_Connman_Element *e;
1656 fputs("ERROR: missing the service path\n", stderr);
1660 next_args = _tok(args);
1664 fputs("ERROR: missing the auto connect value\n", stderr);
1668 auto_connect = !!atol(next_args);
1670 e = e_connman_service_get(path);
1671 if (e_connman_service_auto_connect_set(e, auto_connect, NULL, NULL))
1672 printf(":::Service %s auto connect set to %d\n", path, auto_connect);
1674 fputs("ERROR: can't set service auto connect\n", stderr);
1679 _on_cmd_service_get_setup_required(char *cmd, char *args)
1682 bool setup_required;
1683 E_Connman_Element *e;
1687 fputs("ERROR: missing the service path\n", stderr);
1693 e = e_connman_service_get(path);
1694 if (e_connman_service_setup_required_get(e, &setup_required))
1695 printf(":::Service %s Setup Required = %hhu\n", path, setup_required);
1697 fputs("ERROR: can't get service setup required\n", stderr);
1702 _on_cmd_service_get_apn(char *cmd, char *args)
1704 const char *apn, *path;
1705 E_Connman_Element *e;
1709 fputs("ERROR: missing the service path\n", stderr);
1715 e = e_connman_service_get(path);
1716 if (e_connman_service_apn_get(e, &apn))
1717 printf(":::Service %s APN = \"%s\"\n", path, apn);
1719 fputs("ERROR: can't get service APN\n", stderr);
1724 _on_cmd_service_set_apn(char *cmd, char *args)
1727 E_Connman_Element *e;
1731 fputs("ERROR: missing the service path\n", stderr);
1739 fputs("ERROR: missing the apn value\n", stderr);
1744 e = e_connman_service_get(path);
1745 if (e_connman_service_apn_set(e, apn, NULL, NULL))
1746 printf(":::Service %s APN set to \"%s\"\n", path, apn);
1748 fputs("ERROR: can't set service APN\n", stderr);
1753 _on_cmd_service_get_mcc(char *cmd, char *args)
1755 const char *mcc, *path;
1756 E_Connman_Element *e;
1760 fputs("ERROR: missing the service path\n", stderr);
1766 e = e_connman_service_get(path);
1767 if (e_connman_service_mcc_get(e, &mcc))
1768 printf(":::Service %s MCC = \"%s\"\n", path, mcc);
1770 fputs("ERROR: can't get service MCC\n", stderr);
1775 _on_cmd_service_get_mnc(char *cmd, char *args)
1777 const char *mnc, *path;
1778 E_Connman_Element *e;
1782 fputs("ERROR: missing the service path\n", stderr);
1788 e = e_connman_service_get(path);
1789 if (e_connman_service_mnc_get(e, &mnc))
1790 printf(":::Service %s MNC = \"%s\"\n", path, mnc);
1792 fputs("ERROR: can't get service MNC\n", stderr);
1797 _on_cmd_service_get_roaming(char *cmd, char *args)
1801 E_Connman_Element *e;
1805 fputs("ERROR: missing the service path\n", stderr);
1811 e = e_connman_service_get(path);
1812 if (e_connman_service_roaming_get(e, &roaming))
1813 printf(":::Service %s Roaming = %hhu\n", path, roaming);
1815 fputs("ERROR: can't get service roaming\n", stderr);
1820 _on_cmd_service_get_ipv4_method(char *cmd, char *args)
1822 const char *ipv4_method, *path;
1823 E_Connman_Element *e;
1827 fputs("ERROR: missing the service path\n", stderr);
1833 e = e_connman_service_get(path);
1834 if (e_connman_service_ipv4_method_get(e, &ipv4_method))
1835 printf(":::Service %s IPv4 Method = \"%s\"\n", path, ipv4_method);
1837 fputs("ERROR: can't get service ipv4 method\n", stderr);
1842 _on_cmd_service_get_ipv4_address(char *cmd, char *args)
1844 const char *ipv4_address, *path;
1845 E_Connman_Element *e;
1849 fputs("ERROR: missing the service path\n", stderr);
1855 e = e_connman_service_get(path);
1856 if (e_connman_service_ipv4_address_get(e, &ipv4_address))
1857 printf(":::Service %s IPv4 Address = \"%s\"\n", path, ipv4_address);
1859 fputs("ERROR: can't get service ipv4 address\n", stderr);
1864 _on_cmd_service_get_ipv4_gateway(char *cmd, char *args)
1866 const char *ipv4_gateway, *path;
1867 E_Connman_Element *e;
1871 fputs("ERROR: missing the service path\n", stderr);
1877 e = e_connman_service_get(path);
1878 if (e_connman_service_ipv4_gateway_get(e, &ipv4_gateway))
1879 printf(":::Service %s IPv4 Gateway = \"%s\"\n", path, ipv4_gateway);
1881 fputs("ERROR: can't get service ipv4 gateway\n", stderr);
1886 _on_cmd_service_get_ipv4_netmask(char *cmd, char *args)
1888 const char *ipv4_netmask, *path;
1889 E_Connman_Element *e;
1893 fputs("ERROR: missing the service path\n", stderr);
1899 e = e_connman_service_get(path);
1900 if (e_connman_service_ipv4_netmask_get(e, &ipv4_netmask))
1901 printf(":::Service %s IPv4 Netmask = \"%s\"\n", path, ipv4_netmask);
1903 fputs("ERROR: can't get service ipv4 netmask\n", stderr);
1908 _on_cmd_service_get_ipv4_configuration_method(char *cmd, char *args)
1910 const char *ipv4_method, *path;
1911 E_Connman_Element *e;
1915 fputs("ERROR: missing the service path\n", stderr);
1921 e = e_connman_service_get(path);
1922 if (e_connman_service_ipv4_configuration_method_get(e, &ipv4_method))
1923 printf(":::Service %s IPv4 Configuration Method = \"%s\"\n",
1926 fputs("ERROR: can't get service ipv4_configuration method\n", stderr);
1931 _on_cmd_service_get_ipv4_configuration_address(char *cmd, char *args)
1933 const char *ipv4_address, *path;
1934 E_Connman_Element *e;
1938 fputs("ERROR: missing the service path\n", stderr);
1944 e = e_connman_service_get(path);
1945 if (e_connman_service_ipv4_configuration_address_get(e, &ipv4_address))
1946 printf(":::Service %s IPv4 Configuration Address = \"%s\"\n",
1947 path, ipv4_address);
1949 fputs("ERROR: can't get service ipv4_configuration address\n", stderr);
1954 _on_cmd_service_get_ipv4_configuration_gateway(char *cmd, char *args)
1956 const char *ipv4_gateway, *path;
1957 E_Connman_Element *e;
1961 fputs("ERROR: missing the service path\n", stderr);
1967 e = e_connman_service_get(path);
1968 if (e_connman_service_ipv4_configuration_gateway_get(e, &ipv4_gateway))
1969 printf(":::Service %s IPv4 Configuration Gateway = \"%s\"\n",
1970 path, ipv4_gateway);
1972 fputs("ERROR: can't get service ipv4_configuration gateway\n", stderr);
1977 _on_cmd_service_get_ipv4_configuration_netmask(char *cmd, char *args)
1979 const char *ipv4_netmask, *path;
1980 E_Connman_Element *e;
1984 fputs("ERROR: missing the service path\n", stderr);
1990 e = e_connman_service_get(path);
1991 if (e_connman_service_ipv4_configuration_netmask_get(e, &ipv4_netmask))
1992 printf(":::Service %s IPv4 Configuration Netmask = \"%s\"\n",
1993 path, ipv4_netmask);
1995 fputs("ERROR: can't get service ipv4 configuration netmask\n", stderr);
2000 _on_cmd_service_get_ethernet_method(char *cmd, char *args)
2002 const char *ethernet_method, *path;
2003 E_Connman_Element *e;
2007 fputs("ERROR: missing the service path\n", stderr);
2013 e = e_connman_service_get(path);
2014 if (e_connman_service_ethernet_method_get(e, ðernet_method))
2015 printf(":::Service %s Ethernet Method = \"%s\"\n", path, ethernet_method);
2017 fputs("ERROR: can't get service ethernet method\n", stderr);
2022 _on_cmd_service_get_ethernet_address(char *cmd, char *args)
2024 const char *ethernet_address, *path;
2025 E_Connman_Element *e;
2029 fputs("ERROR: missing the service path\n", stderr);
2035 e = e_connman_service_get(path);
2036 if (e_connman_service_ethernet_address_get(e, ðernet_address))
2037 printf(":::Service %s Ethernet Address = \"%s\"\n",
2038 path, ethernet_address);
2040 fputs("ERROR: can't get service ethernet address\n", stderr);
2045 _on_cmd_service_get_ethernet_mtu(char *cmd, char *args)
2048 E_Connman_Element *e;
2049 unsigned short ethernet_mtu;
2053 fputs("ERROR: missing the service path\n", stderr);
2059 e = e_connman_service_get(path);
2060 if (e_connman_service_ethernet_mtu_get(e, ðernet_mtu))
2061 printf(":::Service %s Ethernet MTU = %hu\n", path, ethernet_mtu);
2063 fputs("ERROR: can't get service ethernet mtu\n", stderr);
2068 _on_cmd_service_get_ethernet_netmask(char *cmd, char *args)
2070 const char *ethernet_netmask, *path;
2071 E_Connman_Element *e;
2075 fputs("ERROR: missing the service path\n", stderr);
2081 e = e_connman_service_get(path);
2082 if (e_connman_service_ethernet_netmask_get(e, ðernet_netmask))
2083 printf(":::Service %s Ethernet Netmask = \"%s\"\n",
2084 path, ethernet_netmask);
2086 fputs("ERROR: can't get service ethernet netmask\n", stderr);
2092 _on_input(void *data, Ecore_Fd_Handler *fd_handler)
2098 int (*cb)(char *cmd, char *args);
2100 {"quit", _on_cmd_quit},
2101 {"sync", _on_cmd_sync},
2102 {"get_all", _on_cmd_get_all},
2103 {"print", _on_cmd_print},
2104 {"get_properties", _on_cmd_get_properties},
2105 {"set_property", _on_cmd_property_set},
2106 {"manager_get", _on_cmd_manager_get},
2107 {"manager_get_profiles", _on_cmd_manager_get_profiles},
2108 {"manager_get_devices", _on_cmd_manager_get_devices},
2109 {"manager_get_services", _on_cmd_manager_get_services},
2110 {"manager_register_agent", _on_cmd_manager_register_agent},
2111 {"manager_unregister_agent", _on_cmd_manager_unregister_agent},
2112 {"manager_get_state", _on_cmd_manager_get_state},
2113 {"manager_get_offline_mode", _on_cmd_manager_get_offline_mode},
2114 {"manager_set_offline_mode", _on_cmd_manager_set_offline_mode},
2115 {"manager_request_scan", _on_cmd_manager_request_scan},
2116 {"manager_technology_enable", _on_cmd_manager_technology_enable},
2117 {"manager_technology_disable", _on_cmd_manager_technology_disable},
2118 {"manager_get_technologies_available", _on_cmd_manager_get_technologies_available},
2119 {"manager_get_technologies_enabled", _on_cmd_manager_get_technologies_enabled},
2120 {"manager_get_technologies_connected", _on_cmd_manager_get_technologies_connected},
2121 {"manager_profile_remove", _on_cmd_manager_profile_remove},
2122 {"manager_profile_get_active", _on_cmd_manager_profile_get_active},
2123 {"manager_profile_set_active", _on_cmd_manager_profile_set_active},
2124 {"device_propose_scan", _on_cmd_device_propose_scan},
2125 {"device_get_address", _on_cmd_device_get_address},
2126 {"device_get_name", _on_cmd_device_get_name},
2127 {"device_get_type", _on_cmd_device_get_type},
2128 {"device_get_interface", _on_cmd_device_get_interface},
2129 {"device_get_powered", _on_cmd_device_get_powered},
2130 {"device_set_powered", _on_cmd_device_set_powered},
2131 {"device_get_scan_interval", _on_cmd_device_get_scan_interval},
2132 {"device_set_scan_interval", _on_cmd_device_set_scan_interval},
2133 {"device_get_scanning", _on_cmd_device_get_scanning},
2134 {"device_get_networks", _on_cmd_device_get_networks},
2135 {"profile_get_name", _on_cmd_profile_get_name},
2136 {"profile_set_name", _on_cmd_profile_set_name},
2137 {"profile_get_offline_mode", _on_cmd_profile_get_offline_mode},
2138 {"profile_set_offline_mode", _on_cmd_profile_set_offline_mode},
2139 {"profile_get_services", _on_cmd_profile_get_services},
2140 {"network_get_address", _on_cmd_network_get_address},
2141 {"network_get_name", _on_cmd_network_get_name},
2142 {"network_get_connected", _on_cmd_network_get_connected},
2143 {"network_get_strength", _on_cmd_network_get_strength},
2144 {"network_get_frequency", _on_cmd_network_get_frequency},
2145 {"network_get_device", _on_cmd_network_get_device},
2146 {"network_get_wifi_ssid", _on_cmd_network_get_wifi_ssid},
2147 {"network_get_wifi_mode", _on_cmd_network_get_wifi_mode},
2148 {"network_get_wifi_security", _on_cmd_network_get_wifi_security},
2149 {"network_get_wifi_passphrase", _on_cmd_network_get_wifi_passphrase},
2150 {"network_get_wifi_channel", _on_cmd_network_get_wifi_channel},
2151 {"network_get_wifi_eap", _on_cmd_network_get_wifi_eap},
2152 {"service_connect", _on_cmd_service_connect},
2153 {"service_disconnect", _on_cmd_service_disconnect},
2154 {"service_remove", _on_cmd_service_remove},
2155 {"service_move_before", _on_cmd_service_move_before},
2156 {"service_move_after", _on_cmd_service_move_after},
2157 {"service_get_state", _on_cmd_service_get_state},
2158 {"service_get_error", _on_cmd_service_get_error},
2159 {"service_get_name", _on_cmd_service_get_name},
2160 {"service_get_type", _on_cmd_service_get_type},
2161 {"service_get_mode", _on_cmd_service_get_mode},
2162 {"service_get_security", _on_cmd_service_get_security},
2163 {"service_get_passphrase", _on_cmd_service_get_passphrase},
2164 {"service_set_passphrase", _on_cmd_service_set_passphrase},
2165 {"service_get_passphrase_required", _on_cmd_service_get_passphrase_required},
2166 {"service_get_strength", _on_cmd_service_get_strength},
2167 {"service_get_favorite", _on_cmd_service_get_favorite},
2168 {"service_get_immutable", _on_cmd_service_get_immutable},
2169 {"service_get_auto_connect", _on_cmd_service_get_auto_connect},
2170 {"service_set_auto_connect", _on_cmd_service_set_auto_connect},
2171 {"service_get_setup_required", _on_cmd_service_get_setup_required},
2172 {"service_get_apn", _on_cmd_service_get_apn},
2173 {"service_set_apn", _on_cmd_service_set_apn},
2174 {"service_get_mcc", _on_cmd_service_get_mcc},
2175 {"service_get_mnc", _on_cmd_service_get_mnc},
2176 {"service_get_roaming", _on_cmd_service_get_roaming},
2177 {"service_get_ipv4_method", _on_cmd_service_get_ipv4_method},
2178 {"service_get_ipv4_address", _on_cmd_service_get_ipv4_address},
2179 {"service_get_ipv4_gateway", _on_cmd_service_get_ipv4_gateway},
2180 {"service_get_ipv4_netmask", _on_cmd_service_get_ipv4_netmask},
2181 {"service_get_ipv4_configuration_method", _on_cmd_service_get_ipv4_configuration_method},
2182 {"service_get_ipv4_configuration_address", _on_cmd_service_get_ipv4_configuration_address},
2183 {"service_get_ipv4_configuration_gateway", _on_cmd_service_get_ipv4_configuration_gateway},
2184 {"service_get_ipv4_configuration_netmask", _on_cmd_service_get_ipv4_configuration_netmask},
2185 {"service_get_ethernet_method", _on_cmd_service_get_ethernet_method},
2186 {"service_get_ethernet_address", _on_cmd_service_get_ethernet_address},
2187 {"service_get_ethernet_mtu", _on_cmd_service_get_ethernet_mtu},
2188 {"service_get_ethernet_netmask", _on_cmd_service_get_ethernet_netmask},
2193 if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR))
2195 fputs("ERROR: reading from stdin, exit\n", stderr);
2199 if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
2201 fputs("ERROR: nothing to read?\n", stderr);
2205 if (!fgets(buf, sizeof(buf), stdin))
2207 fprintf(stderr, "ERROR: could not read command: %s\n", strerror(errno));
2208 ecore_main_loop_quit();
2213 while (isspace(*cmd))
2216 args = strchr(cmd, ' ');
2224 while (isspace(*args))
2227 p = args + strlen(args) - 1;
2235 p = cmd + strlen(cmd) - 1;
2240 if (strcmp(cmd, "help") == 0)
2244 printf("Commands with '%s' in the name:\n", args);
2245 for (itr = maps; itr->cmd != NULL; itr++)
2246 if (strstr(itr->cmd, args))
2247 printf("\t%s\n", itr->cmd);
2251 fputs("Commands:\n", stdout);
2252 for (itr = maps; itr->cmd != NULL; itr++)
2253 printf("\t%s\n", itr->cmd);
2255 fputc('\n', stdout);
2259 for (itr = maps; itr->cmd != NULL; itr++)
2260 if (strcmp(itr->cmd, cmd) == 0)
2261 return itr->cb(cmd, args);
2263 printf("unknown command \"%s\", args=%s\n", cmd, args);
2268 main(int argc, char *argv[])
2270 E_DBus_Connection *c;
2276 c = e_dbus_bus_get(DBUS_BUS_SYSTEM);
2278 printf("ERROR: can't connect to system session\n");
2282 e_connman_system_init(c);
2283 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_ADD, _on_element_add, NULL);
2284 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_DEL, _on_element_del, NULL);
2285 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_UPDATED,
2286 _on_element_updated, NULL);
2288 ecore_main_fd_handler_add
2289 (0, ECORE_FD_READ | ECORE_FD_ERROR, _on_input, NULL, NULL, NULL);
2291 ecore_main_loop_begin();
2293 e_connman_system_shutdown();
2295 e_dbus_connection_close(c);
2300 fputs("DBG: clean exit.\n", stderr);