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 if (!e_connman_element_property_set(element, name, type, value))
234 fputs("ERROR: error setting property.\n", stderr);
241 /* Manager Commands */
244 _on_cmd_manager_get(char *cmd, char *args)
246 E_Connman_Element *element;
247 element = e_connman_manager_get();
248 e_connman_element_print(stderr, element);
253 _on_cmd_manager_get_profiles(char *cmd, char *args)
256 E_Connman_Element **profiles;
258 if (!e_connman_manager_profiles_get(&count, &profiles))
260 fputs("ERROR: can't get profiles\n", stderr);
263 printf("BEG: all manager profiles elements count = %d\n", count);
264 _elements_print(profiles, count);
269 _on_cmd_manager_get_devices(char *cmd, char *args)
272 E_Connman_Element **devices;
274 if (!e_connman_manager_devices_get(&count, &devices))
276 fputs("ERROR: can't get devices\n", stderr);
279 printf("BEG: all manager devices elements count = %d\n", count);
280 _elements_print(devices, count);
285 _on_cmd_manager_get_services(char *cmd, char *args)
288 E_Connman_Element **services;
290 if (!e_connman_manager_services_get(&count, &services))
292 fputs("ERROR: can't get services\n", stderr);
295 printf("BEG: all manager services elements count = %d\n", count);
296 _elements_print(services, count);
301 _on_cmd_manager_register_agent(char *cmd, char *args)
307 fputs("ERROR: missing the object path\n", stderr);
312 if (e_connman_manager_agent_register(path, NULL, NULL))
313 printf(":::Registering agent %s...\n", path);
315 fprintf(stderr, "ERROR: can't register agent %s\n", path);
321 _on_cmd_manager_unregister_agent(char *cmd, char *args)
327 fputs("ERROR: missing the object path\n", stderr);
332 if (e_connman_manager_agent_unregister(path, NULL, NULL))
333 printf(":::Unregistering agent %s...\n", path);
335 fprintf(stderr, "ERROR: can't unregister agent %s\n", path);
341 _on_cmd_manager_get_state(char *cmd, char *args)
344 if (e_connman_manager_state_get(&state))
345 printf(":::Manager state = \"%s\"\n", state);
347 fputs("ERROR: can't get manager state\n", stderr);
352 _on_cmd_manager_get_offline_mode(char *cmd, char *args)
355 if (e_connman_manager_offline_mode_get(&offline))
356 printf(":::Manager Offline Mode = %hhu\n", offline);
358 fputs("ERROR: can't get manager offline mode\n", stderr);
363 _on_cmd_manager_set_offline_mode(char *cmd, char *args)
368 fputs("ERROR: missing the offline mode value\n", stderr);
372 offline = !!atol(args);
373 if (e_connman_manager_offline_mode_set(offline, NULL, NULL))
374 printf(":::Manager Offline Mode set to %hhu\n", offline);
376 fputs("ERROR: can't set manager offline mode\n", stderr);
380 /* Device Commands */
382 _on_cmd_device_propose_scan(char *cmd, char *args)
385 E_Connman_Element *e;
389 fputs("ERROR: missing the device path\n", stderr);
395 e = e_connman_device_get(path);
396 if (e_connman_device_propose_scan(e, NULL, NULL))
397 printf(":::Proposing scan %s...\n", path);
399 fputs("ERROR: can't propose scan\n", stderr);
404 _on_cmd_device_get_address(char *cmd, char *args)
406 const char *address, *path;
407 E_Connman_Element *e;
411 fputs("ERROR: missing the device path\n", stderr);
417 e = e_connman_device_get(path);
418 if (e_connman_device_address_get(e, &address))
419 printf(":::Device %s Address = \"%s\"\n", path, address);
421 fputs("ERROR: can't get device address\n", stderr);
426 _on_cmd_device_get_name(char *cmd, char *args)
428 const char *name, *path;
429 E_Connman_Element *e;
433 fputs("ERROR: missing the device path\n", stderr);
439 e = e_connman_device_get(path);
440 if (e_connman_device_name_get(e, &name))
441 printf(":::Device %s Name = \"%s\"\n", path, name);
443 fputs("ERROR: can't get device name\n", stderr);
448 _on_cmd_device_get_type(char *cmd, char *args)
450 const char *type, *path;
451 E_Connman_Element *e;
455 fputs("ERROR: missing the device path\n", stderr);
461 e = e_connman_device_get(path);
462 if (e_connman_device_type_get(e, &type))
463 printf(":::Device %s Type = \"%s\"\n", path, type);
465 fputs("ERROR: can't get device type\n", stderr);
470 _on_cmd_device_get_interface(char *cmd, char *args)
472 const char *interface, *path;
473 E_Connman_Element *e;
477 fputs("ERROR: missing the device path\n", stderr);
483 e = e_connman_device_get(path);
484 if (e_connman_device_interface_get(e, &interface))
485 printf(":::Device %s Interface = \"%s\"\n", path, interface);
487 fputs("ERROR: can't get device interface\n", stderr);
492 _on_cmd_device_get_powered(char *cmd, char *args)
496 E_Connman_Element *e;
500 fputs("ERROR: missing the device path\n", stderr);
506 e = e_connman_device_get(path);
507 if (e_connman_device_powered_get(e, &powered))
508 printf(":::Device %s Powered = %hhu\n", path, powered);
510 fputs("ERROR: can't get device powered\n", stderr);
515 _on_cmd_device_set_powered(char *cmd, char *args)
517 char *device_path, *next_args;
519 E_Connman_Element *e;
523 fputs("ERROR: missing the device path\n", stderr);
527 next_args = _tok(args);
530 fputs("ERROR: missing the powered value\n", stderr);
533 powered = !!atol(next_args);
535 e = e_connman_device_get(device_path);
536 if (e_connman_device_powered_set(e, powered, NULL, NULL))
537 printf(":::Device %s powered set to %hhu\n", device_path, powered);
539 fputs("ERROR: can't set device powered\n", stderr);
544 _on_cmd_device_get_scan_interval(char *cmd, char *args)
547 unsigned short scan_interval;
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_scan_interval_get(e, &scan_interval))
560 printf(":::Device %s ScanInterval = %hu\n", path, scan_interval);
562 fputs("ERROR: can't get device scan interval\n", stderr);
567 _on_cmd_device_set_scan_interval(char *cmd, char *args)
569 char *device_path, *next_args, *p;
570 unsigned short scan_interval;
571 E_Connman_Element *e;
575 fputs("ERROR: missing the device path\n", stderr);
579 next_args = _tok(args);
582 fputs("ERROR: missing the scan interval value\n", stderr);
585 scan_interval = strtol(next_args, &p, 0);
588 fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
592 e = e_connman_device_get(device_path);
593 if (e_connman_device_scan_interval_set(e, scan_interval, NULL, NULL))
594 printf(":::Device %s scan interval set to %hu\n", device_path, scan_interval);
596 fputs("ERROR: can't set device scan interval\n", stderr);
601 _on_cmd_device_get_scanning(char *cmd, char *args)
605 E_Connman_Element *e;
609 fputs("ERROR: missing the device path\n", stderr);
615 e = e_connman_device_get(path);
616 if (e_connman_device_scanning_get(e, &scanning))
617 printf(":::Device %s Scanning = %hhu\n", path, scanning);
619 fputs("ERROR: can't get device scanning\n", stderr);
624 _on_cmd_device_get_networks(char *cmd, char *args)
626 E_Connman_Element **networks;
629 E_Connman_Element *e;
633 fputs("ERROR: missing the device path\n", stderr);
639 e = e_connman_device_get(path);
640 if (!e_connman_device_networks_get(e, &count, &networks))
642 fputs("ERROR: can't get networks\n", stderr);
646 printf("BEG: all device network elements count = %d\n", count);
647 _elements_print(networks, count);
651 /* Profile Commands */
654 _on_cmd_profile_get_name(char *cmd, char *args)
656 const char *name, *path;
657 E_Connman_Element *e;
661 fputs("ERROR: missing the profile path\n", stderr);
667 e = e_connman_profile_get(path);
668 if (e_connman_profile_name_get(e, &name))
669 printf(":::Profile %s Name = \"%s\"\n", path, name);
671 fputs("ERROR: can't get profile name\n", stderr);
676 _on_cmd_profile_set_name(char *cmd, char *args)
678 char *path, *next_args;
679 E_Connman_Element *e;
683 fputs("ERROR: missing the profile path\n", stderr);
687 next_args = _tok(args);
690 fputs("ERROR: missing the offline mode value\n", stderr);
695 e = e_connman_profile_get(path);
696 if (e_connman_profile_name_set(e, next_args, NULL, NULL))
697 printf(":::Profile %s Name set to %hhu\n", path, next_args);
699 fputs("ERROR: can't set profile name\n", stderr);
704 _on_cmd_profile_get_offline_mode(char *cmd, char *args)
708 E_Connman_Element *e;
712 fputs("ERROR: missing the profile path\n", stderr);
718 e = e_connman_profile_get(path);
719 if (e_connman_profile_offline_mode_get(e, &offline))
720 printf(":::Profile %s Offline Mode = %hhu\n", path, offline);
722 fputs("ERROR: can't get profile offline mode\n", stderr);
727 _on_cmd_profile_set_offline_mode(char *cmd, char *args)
729 char *path, *next_args;
731 E_Connman_Element *e;
735 fputs("ERROR: missing the profile path\n", stderr);
739 next_args = _tok(args);
742 fputs("ERROR: missing the offline mode value\n", stderr);
746 offline = !!atol(next_args);
748 e = e_connman_profile_get(path);
749 if (e_connman_profile_offline_mode_set(e, offline, NULL, NULL))
750 printf(":::Profile %s Offline Mode set to %hhu\n", path, offline);
752 fputs("ERROR: can't set profile offline mode\n", stderr);
757 _on_cmd_profile_get_services(char *cmd, char *args)
759 E_Connman_Element **services;
760 E_Connman_Element *e;
766 fputs("ERROR: missing the profile path\n", stderr);
772 e = e_connman_profile_get(path);
773 if (!e_connman_profile_services_get(e, &count, &services))
775 fputs("ERROR: can't get services\n", stderr);
778 printf("BEG: all profile services count = %d\n", count);
779 _elements_print(services, count);
784 /* Network Commands */
787 _on_cmd_network_get_address(char *cmd, char *args)
789 const char *address, *path;
790 E_Connman_Element *e;
794 fputs("ERROR: missing the network path\n", stderr);
800 e = e_connman_network_get(path);
801 if (e_connman_network_address_get(e, &address))
802 printf(":::Network %s Address = \"%s\"\n", path, address);
804 fputs("ERROR: can't get network address\n", stderr);
809 _on_cmd_network_get_name(char *cmd, char *args)
811 const char *name, *path;
812 E_Connman_Element *e;
816 fputs("ERROR: missing the network path\n", stderr);
822 e = e_connman_network_get(path);
823 if (e_connman_network_name_get(e, &name))
824 printf(":::Network %s Name = \"%s\"\n", path, name);
826 fputs("ERROR: can't get network name\n", stderr);
831 _on_cmd_network_get_connected(char *cmd, char *args)
835 E_Connman_Element *e;
839 fputs("ERROR: missing the network path\n", stderr);
845 e = e_connman_network_get(path);
846 if (e_connman_network_connected_get(e, &connected))
847 printf(":::Network %s Connected = %hhu\n", path, connected);
849 fputs("ERROR: can't get network connected\n", stderr);
854 _on_cmd_network_get_strength(char *cmd, char *args)
857 unsigned char strength;
858 E_Connman_Element *e;
862 fputs("ERROR: missing the network path\n", stderr);
868 e = e_connman_network_get(path);
869 if (e_connman_network_strength_get(e, &strength))
870 printf(":::Network %s Strength = %#02hhx (%d)\n", path, strength, strength);
872 fputs("ERROR: can't get network strength\n", stderr);
877 _on_cmd_network_get_frequency(char *cmd, char *args)
880 unsigned short frequency;
881 E_Connman_Element *e;
885 fputs("ERROR: missing the network path\n", stderr);
891 e = e_connman_network_get(path);
892 if (e_connman_network_frequency_get(e, &frequency))
893 printf(":::Network %s Frequency = %#04hx (%d)\n", path, frequency, frequency);
895 fputs("ERROR: can't get network frequency\n", stderr);
900 _on_cmd_network_get_device(char *cmd, char *args)
902 E_Connman_Element *e, *device;
907 fputs("ERROR: missing the network path\n", stderr);
913 e = e_connman_network_get(path);
914 if (!e_connman_network_device_get(e, &device))
915 fputs("ERROR: can't get network device\n", stderr);
917 e_connman_element_print(stderr, device);
922 _on_cmd_network_get_wifi_ssid(char *cmd, char *args)
924 unsigned char *bytes;
926 unsigned int i, count;
927 E_Connman_Element *e;
931 fputs("ERROR: missing the network path\n", stderr);
937 e = e_connman_network_get(path);
938 if (e_connman_network_wifi_ssid_get(e, &count, &bytes))
940 printf(":::Network %s Wifi SSID = ", path);
941 for (i = 0; i < count; i++)
942 printf("%#02hhx (\"%c\"), ", bytes[i], bytes[i]);
946 fputs("ERROR: can't get network wifi ssid\n", stderr);
951 _on_cmd_network_get_wifi_mode(char *cmd, char *args)
953 const char *wifi_mode, *path;
954 E_Connman_Element *e;
958 fputs("ERROR: missing the network path\n", stderr);
964 e = e_connman_network_get(path);
965 if (e_connman_network_wifi_mode_get(e, &wifi_mode))
966 printf(":::Network %s Wifi Mode = \"%s\"\n", path, wifi_mode);
968 fputs("ERROR: can't get network wifi mode\n", stderr);
973 _on_cmd_network_get_wifi_security(char *cmd, char *args)
975 const char *wifi_security, *path;
976 E_Connman_Element *e;
980 fputs("ERROR: missing the network path\n", stderr);
986 e = e_connman_network_get(path);
987 if (e_connman_network_wifi_security_get(e, &wifi_security))
988 printf(":::Network %s Wifi Security = \"%s\"\n", path, wifi_security);
990 fputs("ERROR: can't get network wifi security\n", stderr);
995 _on_cmd_network_get_wifi_passphrase(char *cmd, char *args)
997 const char *wifi_passphrase, *path;
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_wifi_passphrase_get(e, &wifi_passphrase))
1010 printf(":::Network %s Wifi Passphrase = \"%s\"\n", path, wifi_passphrase);
1012 fputs("ERROR: can't get network wifi passphrase\n", stderr);
1017 _on_cmd_network_get_wifi_channel(char *cmd, char *args)
1020 E_Connman_Element *e;
1021 unsigned short wifi_channel;
1025 fputs("ERROR: missing the network path\n", stderr);
1031 e = e_connman_network_get(path);
1032 if (e_connman_network_wifi_channel_get(e, &wifi_channel))
1033 printf(":::Network %s Wifi Channel = %#02hx (%d)\n", path, wifi_channel, wifi_channel);
1035 fputs("ERROR: can't get network wifi channel\n", stderr);
1040 _on_cmd_network_get_wifi_eap(char *cmd, char *args)
1042 const char *wifi_eap, *path;
1043 E_Connman_Element *e;
1047 fputs("ERROR: missing the network path\n", stderr);
1053 e = e_connman_network_get(path);
1054 if (e_connman_network_wifi_eap_get(e, &wifi_eap))
1055 printf(":::Network %s Wifi EAP = \"%s\"\n", path, wifi_eap);
1057 fputs("ERROR: can't get network wifi eap\n", stderr);
1061 /* Services Commands */
1063 _on_cmd_service_connect(char *cmd, char *args)
1066 E_Connman_Element *e;
1070 fputs("ERROR: missing the service path\n", stderr);
1076 e = e_connman_service_get(path);
1077 if (e_connman_service_connect(e, NULL, NULL))
1078 printf(":::Connecting to Service %s...\n", path);
1080 fputs("ERROR: can't connect to service\n", stderr);
1085 _on_cmd_service_disconnect(char *cmd, char *args)
1088 E_Connman_Element *e;
1092 fputs("ERROR: missing the service path\n", stderr);
1098 e = e_connman_service_get(path);
1099 if (e_connman_service_disconnect(e, NULL, NULL))
1100 printf(":::Disconnecting Service %s...\n", path);
1102 fputs("ERROR: can't disconnect service\n", stderr);
1107 _on_cmd_service_remove(char *cmd, char *args)
1110 E_Connman_Element *e;
1114 fputs("ERROR: missing the service path\n", stderr);
1120 e = e_connman_service_get(path);
1121 if (e_connman_service_remove(e, NULL, NULL))
1122 printf(":::Removing Service %s...\n", path);
1124 fputs("ERROR: can't remove service\n", stderr);
1129 _on_cmd_service_move_before(char *cmd, char *args)
1131 char *path, *service_path;
1132 E_Connman_Element *e;
1136 fputs("ERROR: missing the service path\n", stderr);
1139 service_path = args;
1144 fputs("ERROR: missing the object service\n", stderr);
1149 e = e_connman_service_get(service_path);
1150 if (e_connman_service_move_before(e, path, NULL, NULL))
1151 printf(":::Moving before %s...\n", path);
1153 fputs("ERROR: can't move before\n", stderr);
1158 _on_cmd_service_move_after(char *cmd, char *args)
1160 char *path, *service_path;
1161 E_Connman_Element *e;
1165 fputs("ERROR: missing the service path\n", stderr);
1168 service_path = args;
1173 fputs("ERROR: missing the object service\n", stderr);
1178 e = e_connman_service_get(service_path);
1179 if (e_connman_service_move_after(e, path, NULL, NULL))
1180 printf(":::Moving after %s...\n", path);
1182 fputs("ERROR: can't move after\n", stderr);
1187 _on_cmd_service_get_state(char *cmd, char *args)
1189 const char *state, *path;
1190 E_Connman_Element *e;
1194 fputs("ERROR: missing the service path\n", stderr);
1200 e = e_connman_service_get(path);
1201 if (e_connman_service_state_get(e, &state))
1202 printf(":::Service %s State = \"%s\"\n", path, state);
1204 fputs("ERROR: can't get service state\n", stderr);
1209 _on_cmd_service_get_error(char *cmd, char *args)
1211 const char *error, *path;
1212 E_Connman_Element *e;
1216 fputs("ERROR: missing the service path\n", stderr);
1222 e = e_connman_service_get(path);
1223 if (e_connman_service_error_get(e, &error))
1224 printf(":::Service %s Error = \"%s\"\n", path, error);
1226 fputs("ERROR: can't get service error\n", stderr);
1231 _on_cmd_service_get_name(char *cmd, char *args)
1233 const char *name, *path;
1234 E_Connman_Element *e;
1238 fputs("ERROR: missing the service path\n", stderr);
1244 e = e_connman_service_get(path);
1245 if (e_connman_service_name_get(e, &name))
1246 printf(":::Service %s Name = \"%s\"\n", path, name);
1248 fputs("ERROR: can't get service name\n", stderr);
1253 _on_cmd_service_get_type(char *cmd, char *args)
1255 const char *type, *path;
1256 E_Connman_Element *e;
1260 fputs("ERROR: missing the service path\n", stderr);
1266 e = e_connman_service_get(path);
1267 if (e_connman_service_type_get(e, &type))
1268 printf(":::Service %s Type = \"%s\"\n", path, type);
1270 fputs("ERROR: can't get service type\n", stderr);
1275 _on_cmd_service_get_mode(char *cmd, char *args)
1277 const char *mode, *path;
1278 E_Connman_Element *e;
1282 fputs("ERROR: missing the service path\n", stderr);
1288 e = e_connman_service_get(path);
1289 if (e_connman_service_mode_get(e, &mode))
1290 printf(":::Service %s Mode = \"%s\"\n", path, mode);
1292 fputs("ERROR: can't get service mode\n", stderr);
1297 _on_cmd_service_get_security(char *cmd, char *args)
1299 const char *security, *path;
1300 E_Connman_Element *e;
1304 fputs("ERROR: missing the service path\n", stderr);
1310 e = e_connman_service_get(path);
1311 if (e_connman_service_security_get(e, &security))
1312 printf(":::Service %s Security = \"%s\"\n", path, security);
1314 fputs("ERROR: can't get service security\n", stderr);
1319 _on_cmd_service_get_passphrase(char *cmd, char *args)
1321 const char *passphrase, *path;
1322 E_Connman_Element *e;
1326 fputs("ERROR: missing the service path\n", stderr);
1332 e = e_connman_service_get(path);
1333 if (e_connman_service_passphrase_get(e, &passphrase))
1334 printf(":::Service %s Passphrase = \"%s\"\n", path, passphrase);
1336 fputs("ERROR: can't get service passphrase\n", stderr);
1341 _on_cmd_service_set_passphrase(char *cmd, char *args)
1343 char *passphrase, *path;
1344 E_Connman_Element *e;
1348 fputs("ERROR: missing the service path\n", stderr);
1352 passphrase = _tok(args);
1356 fputs("ERROR: missing the passphrase value\n", stderr);
1361 e = e_connman_service_get(path);
1362 if (e_connman_service_passphrase_set(e, passphrase, NULL, NULL))
1363 printf(":::Service %s passphrase set to \"%s\"\n", path, passphrase);
1365 fputs("ERROR: can't set service passphrase\n", stderr);
1370 _on_cmd_service_get_passphrase_required(char *cmd, char *args)
1374 E_Connman_Element *e;
1378 fputs("ERROR: missing the service path\n", stderr);
1384 e = e_connman_service_get(path);
1385 if (e_connman_service_passphrase_required_get(e, &passphrase))
1386 printf(":::Service %s Passphrase Required = %hhu\n", path, passphrase);
1388 fputs("ERROR: can't get service passphrase required\n", stderr);
1393 _on_cmd_service_get_strength(char *cmd, char *args)
1396 unsigned char strength;
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_strength_get(e, &strength))
1409 printf(":::Service %s Strength = %#02hhx (%d)\n", path, strength, strength);
1411 fputs("ERROR: can't get service strength\n", stderr);
1416 _on_cmd_service_get_favorite(char *cmd, char *args)
1420 E_Connman_Element *e;
1424 fputs("ERROR: missing the service path\n", stderr);
1430 e = e_connman_service_get(path);
1431 if (e_connman_service_favorite_get(e, &favorite))
1432 printf(":::Service %s Favorite = %hhu\n", path, favorite);
1434 fputs("ERROR: can't get service favorite\n", stderr);
1439 _on_cmd_service_get_immutable(char *cmd, char *args)
1443 E_Connman_Element *e;
1447 fputs("ERROR: missing the service path\n", stderr);
1453 e = e_connman_service_get(path);
1454 if (e_connman_service_immutable_get(e, &immutable))
1455 printf(":::Service %s Immutable = %hhu\n", path, immutable);
1457 fputs("ERROR: can't get service immutable\n", stderr);
1462 _on_cmd_service_get_auto_connect(char *cmd, char *args)
1466 E_Connman_Element *e;
1470 fputs("ERROR: missing the service path\n", stderr);
1476 e = e_connman_service_get(path);
1477 if (e_connman_service_auto_connect_get(e, &auto_connect))
1478 printf(":::Service %s Auto Connect = %hhu\n", path, auto_connect);
1480 fputs("ERROR: can't get service auto connect\n", stderr);
1485 _on_cmd_service_set_auto_connect(char *cmd, char *args)
1487 char *path, *next_args;
1489 E_Connman_Element *e;
1493 fputs("ERROR: missing the service path\n", stderr);
1497 next_args = _tok(args);
1501 fputs("ERROR: missing the auto connect value\n", stderr);
1505 auto_connect = !!atol(next_args);
1507 e = e_connman_service_get(path);
1508 if (e_connman_service_auto_connect_set(e, auto_connect, NULL, NULL))
1509 printf(":::Service %s auto connect set to %d\n", path, auto_connect);
1511 fputs("ERROR: can't set service auto connect\n", stderr);
1516 _on_cmd_service_get_setup_required(char *cmd, char *args)
1519 bool setup_required;
1520 E_Connman_Element *e;
1524 fputs("ERROR: missing the service path\n", stderr);
1530 e = e_connman_service_get(path);
1531 if (e_connman_service_setup_required_get(e, &setup_required))
1532 printf(":::Service %s Setup Required = %hhu\n", path, setup_required);
1534 fputs("ERROR: can't get service setup required\n", stderr);
1539 _on_cmd_service_get_apn(char *cmd, char *args)
1541 const char *apn, *path;
1542 E_Connman_Element *e;
1546 fputs("ERROR: missing the service path\n", stderr);
1552 e = e_connman_service_get(path);
1553 if (e_connman_service_apn_get(e, &apn))
1554 printf(":::Service %s APN = \"%s\"\n", path, apn);
1556 fputs("ERROR: can't get service APN\n", stderr);
1561 _on_cmd_service_set_apn(char *cmd, char *args)
1564 E_Connman_Element *e;
1568 fputs("ERROR: missing the service path\n", stderr);
1576 fputs("ERROR: missing the apn value\n", stderr);
1581 e = e_connman_service_get(path);
1582 if (e_connman_service_apn_set(e, apn, NULL, NULL))
1583 printf(":::Service %s APN set to \"%s\"\n", path, apn);
1585 fputs("ERROR: can't set service APN\n", stderr);
1590 _on_cmd_service_get_mcc(char *cmd, char *args)
1592 const char *mcc, *path;
1593 E_Connman_Element *e;
1597 fputs("ERROR: missing the service path\n", stderr);
1603 e = e_connman_service_get(path);
1604 if (e_connman_service_mcc_get(e, &mcc))
1605 printf(":::Service %s MCC = \"%s\"\n", path, mcc);
1607 fputs("ERROR: can't get service MCC\n", stderr);
1612 _on_cmd_service_get_mnc(char *cmd, char *args)
1614 const char *mnc, *path;
1615 E_Connman_Element *e;
1619 fputs("ERROR: missing the service path\n", stderr);
1625 e = e_connman_service_get(path);
1626 if (e_connman_service_mnc_get(e, &mnc))
1627 printf(":::Service %s MNC = \"%s\"\n", path, mnc);
1629 fputs("ERROR: can't get service MNC\n", stderr);
1634 _on_cmd_service_get_roaming(char *cmd, char *args)
1638 E_Connman_Element *e;
1642 fputs("ERROR: missing the service path\n", stderr);
1648 e = e_connman_service_get(path);
1649 if (e_connman_service_roaming_get(e, &roaming))
1650 printf(":::Service %s Roaming = %hhu\n", path, roaming);
1652 fputs("ERROR: can't get service roaming\n", stderr);
1657 _on_cmd_service_get_ipv4_method(char *cmd, char *args)
1659 const char *ipv4_method, *path;
1660 E_Connman_Element *e;
1664 fputs("ERROR: missing the service path\n", stderr);
1670 e = e_connman_service_get(path);
1671 if (e_connman_service_ipv4_method_get(e, &ipv4_method))
1672 printf(":::Service %s ipv4 method = \"%s\"\n", path, ipv4_method);
1674 fputs("ERROR: can't get service ipv4 method\n", stderr);
1679 _on_cmd_service_get_ipv4_address(char *cmd, char *args)
1681 const char *ipv4_address, *path;
1682 E_Connman_Element *e;
1686 fputs("ERROR: missing the service path\n", stderr);
1692 e = e_connman_service_get(path);
1693 if (e_connman_service_ipv4_address_get(e, &ipv4_address))
1694 printf(":::Service %s ipv4 address = \"%s\"\n", path, ipv4_address);
1696 fputs("ERROR: can't get service ipv4 address\n", stderr);
1702 _on_input(void *data, Ecore_Fd_Handler *fd_handler)
1708 int (*cb)(char *cmd, char *args);
1710 {"quit", _on_cmd_quit},
1711 {"sync", _on_cmd_sync},
1712 {"get_all", _on_cmd_get_all},
1713 {"print", _on_cmd_print},
1714 {"get_properties", _on_cmd_get_properties},
1715 {"set_property", _on_cmd_property_set},
1716 {"manager_get", _on_cmd_manager_get},
1717 {"manager_get_profiles", _on_cmd_manager_get_profiles},
1718 {"manager_get_devices", _on_cmd_manager_get_devices},
1719 {"manager_get_services", _on_cmd_manager_get_services},
1720 {"manager_register_agent", _on_cmd_manager_register_agent},
1721 {"manager_unregister_agent", _on_cmd_manager_unregister_agent},
1722 {"manager_get_state", _on_cmd_manager_get_state},
1723 {"manager_get_offline_mode", _on_cmd_manager_get_offline_mode},
1724 {"manager_set_offline_mode", _on_cmd_manager_set_offline_mode},
1725 {"device_propose_scan", _on_cmd_device_propose_scan},
1726 {"device_get_address", _on_cmd_device_get_address},
1727 {"device_get_name", _on_cmd_device_get_name},
1728 {"device_get_type", _on_cmd_device_get_type},
1729 {"device_get_interface", _on_cmd_device_get_interface},
1730 {"device_get_powered", _on_cmd_device_get_powered},
1731 {"device_set_powered", _on_cmd_device_set_powered},
1732 {"device_get_scan_interval", _on_cmd_device_get_scan_interval},
1733 {"device_set_scan_interval", _on_cmd_device_set_scan_interval},
1734 {"device_get_scanning", _on_cmd_device_get_scanning},
1735 {"device_get_networks", _on_cmd_device_get_networks},
1736 {"profile_get_name", _on_cmd_profile_get_name},
1737 {"profile_set_name", _on_cmd_profile_set_name},
1738 {"profile_get_offline_mode", _on_cmd_profile_get_offline_mode},
1739 {"profile_set_offline_mode", _on_cmd_profile_set_offline_mode},
1740 {"profile_get_services", _on_cmd_profile_get_services},
1741 {"network_get_address", _on_cmd_network_get_address},
1742 {"network_get_name", _on_cmd_network_get_name},
1743 {"network_get_connected", _on_cmd_network_get_connected},
1744 {"network_get_strength", _on_cmd_network_get_strength},
1745 {"network_get_frequency", _on_cmd_network_get_frequency},
1746 {"network_get_device", _on_cmd_network_get_device},
1747 {"network_get_wifi_ssid", _on_cmd_network_get_wifi_ssid},
1748 {"network_get_wifi_mode", _on_cmd_network_get_wifi_mode},
1749 {"network_get_wifi_security", _on_cmd_network_get_wifi_security},
1750 {"network_get_wifi_passphrase", _on_cmd_network_get_wifi_passphrase},
1751 {"network_get_wifi_channel", _on_cmd_network_get_wifi_channel},
1752 {"network_get_wifi_eap", _on_cmd_network_get_wifi_eap},
1753 {"service_connect", _on_cmd_service_connect},
1754 {"service_disconnect", _on_cmd_service_disconnect},
1755 {"service_remove", _on_cmd_service_remove},
1756 {"service_move_before", _on_cmd_service_move_before},
1757 {"service_move_after", _on_cmd_service_move_after},
1758 {"service_get_state", _on_cmd_service_get_state},
1759 {"service_get_error", _on_cmd_service_get_error},
1760 {"service_get_name", _on_cmd_service_get_name},
1761 {"service_get_type", _on_cmd_service_get_type},
1762 {"service_get_mode", _on_cmd_service_get_mode},
1763 {"service_get_security", _on_cmd_service_get_security},
1764 {"service_get_passphrase", _on_cmd_service_get_passphrase},
1765 {"service_set_passphrase", _on_cmd_service_set_passphrase},
1766 {"service_get_passphrase_required", _on_cmd_service_get_passphrase_required},
1767 {"service_get_strength", _on_cmd_service_get_strength},
1768 {"service_get_favorite", _on_cmd_service_get_favorite},
1769 {"service_get_immutable", _on_cmd_service_get_immutable},
1770 {"service_get_auto_connect", _on_cmd_service_get_auto_connect},
1771 {"service_set_auto_connect", _on_cmd_service_set_auto_connect},
1772 {"service_get_setup_required", _on_cmd_service_get_setup_required},
1773 {"service_get_apn", _on_cmd_service_get_apn},
1774 {"service_set_apn", _on_cmd_service_set_apn},
1775 {"service_get_mcc", _on_cmd_service_get_mcc},
1776 {"service_get_mnc", _on_cmd_service_get_mnc},
1777 {"service_get_roaming", _on_cmd_service_get_roaming},
1778 {"service_get_ipv4_method", _on_cmd_service_get_ipv4_method},
1779 {"service_get_ipv4_address", _on_cmd_service_get_ipv4_address},
1784 if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR))
1786 fputs("ERROR: reading from stdin, exit\n", stderr);
1790 if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
1792 fputs("ERROR: nothing to read?\n", stderr);
1796 if (!fgets(buf, sizeof(buf), stdin))
1798 fprintf(stderr, "ERROR: could not read command: %s\n", strerror(errno));
1799 ecore_main_loop_quit();
1804 while (isspace(*cmd))
1807 args = strchr(cmd, ' ');
1815 while (isspace(*args))
1818 p = args + strlen(args) - 1;
1826 p = cmd + strlen(cmd) - 1;
1831 if (strcmp(cmd, "help") == 0)
1835 printf("Commands with '%s' in the name:\n", args);
1836 for (itr = maps; itr->cmd != NULL; itr++)
1837 if (strstr(itr->cmd, args))
1838 printf("\t%s\n", itr->cmd);
1842 fputs("Commands:\n", stdout);
1843 for (itr = maps; itr->cmd != NULL; itr++)
1844 printf("\t%s\n", itr->cmd);
1846 fputc('\n', stdout);
1850 for (itr = maps; itr->cmd != NULL; itr++)
1851 if (strcmp(itr->cmd, cmd) == 0)
1852 return itr->cb(cmd, args);
1854 printf("unknown command \"%s\", args=%s\n", cmd, args);
1859 main(int argc, char *argv[])
1861 E_DBus_Connection *c;
1867 c = e_dbus_bus_get(DBUS_BUS_SYSTEM);
1869 printf("ERROR: can't connect to system session\n");
1873 e_connman_system_init(c);
1874 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_ADD, _on_element_add, NULL);
1875 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_DEL, _on_element_del, NULL);
1876 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_UPDATED,
1877 _on_element_updated, NULL);
1879 ecore_main_fd_handler_add
1880 (0, ECORE_FD_READ | ECORE_FD_ERROR, _on_input, NULL, NULL, NULL);
1882 ecore_main_loop_begin();
1884 e_connman_system_shutdown();
1886 e_dbus_connection_close(c);
1891 fputs("DBG: clean exit.\n", stderr);