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_get_offline_mode(char *cmd, char *args)
680 E_Connman_Element *e;
684 fputs("ERROR: missing the profile path\n", stderr);
690 e = e_connman_profile_get(path);
691 if (e_connman_profile_offline_mode_get(e, &offline))
692 printf(":::Profile %s Offline Mode = %hhu\n", path, offline);
694 fputs("ERROR: can't get profile offline mode\n", stderr);
699 _on_cmd_profile_set_offline_mode(char *cmd, char *args)
701 char *path, *next_args;
703 E_Connman_Element *e;
707 fputs("ERROR: missing the profile path\n", stderr);
711 next_args = _tok(args);
714 fputs("ERROR: missing the offline mode value\n", stderr);
718 offline = !!atol(next_args);
720 e = e_connman_profile_get(path);
721 if (e_connman_profile_offline_mode_set(e, offline, NULL, NULL))
722 printf(":::Profile %s Offline Mode set to %hhu\n", path, offline);
724 fputs("ERROR: can't set profile offline mode\n", stderr);
729 _on_cmd_profile_get_services(char *cmd, char *args)
731 E_Connman_Element **services;
732 E_Connman_Element *e;
738 fputs("ERROR: missing the profile path\n", stderr);
744 e = e_connman_profile_get(path);
745 if (!e_connman_profile_services_get(e, &count, &services))
747 fputs("ERROR: can't get services\n", stderr);
750 printf("BEG: all profile services count = %d\n", count);
751 _elements_print(services, count);
756 /* Network Commands */
759 _on_cmd_network_get_address(char *cmd, char *args)
761 const char *address, *path;
762 E_Connman_Element *e;
766 fputs("ERROR: missing the network path\n", stderr);
772 e = e_connman_network_get(path);
773 if (e_connman_network_address_get(e, &address))
774 printf(":::Network %s Address = \"%s\"\n", path, address);
776 fputs("ERROR: can't get network address\n", stderr);
781 _on_cmd_network_get_name(char *cmd, char *args)
783 const char *name, *path;
784 E_Connman_Element *e;
788 fputs("ERROR: missing the network path\n", stderr);
794 e = e_connman_network_get(path);
795 if (e_connman_network_name_get(e, &name))
796 printf(":::Network %s Name = \"%s\"\n", path, name);
798 fputs("ERROR: can't get network name\n", stderr);
803 _on_cmd_network_get_connected(char *cmd, char *args)
807 E_Connman_Element *e;
811 fputs("ERROR: missing the network path\n", stderr);
817 e = e_connman_network_get(path);
818 if (e_connman_network_connected_get(e, &connected))
819 printf(":::Network %s Connected = %hhu\n", path, connected);
821 fputs("ERROR: can't get network connected\n", stderr);
826 _on_cmd_network_get_strength(char *cmd, char *args)
829 unsigned char strength;
830 E_Connman_Element *e;
834 fputs("ERROR: missing the network path\n", stderr);
840 e = e_connman_network_get(path);
841 if (e_connman_network_strength_get(e, &strength))
842 printf(":::Network %s Strength = %#02hhx (%d)\n", path, strength, strength);
844 fputs("ERROR: can't get network strength\n", stderr);
849 _on_cmd_network_get_device(char *cmd, char *args)
851 E_Connman_Element *e, *device;
856 fputs("ERROR: missing the network path\n", stderr);
862 e = e_connman_network_get(path);
863 if (!e_connman_network_device_get(e, &device))
864 fputs("ERROR: can't get network device\n", stderr);
866 e_connman_element_print(stderr, device);
871 _on_cmd_network_get_wifi_ssid(char *cmd, char *args)
873 unsigned char *bytes;
875 unsigned int i, count;
876 E_Connman_Element *e;
880 fputs("ERROR: missing the network path\n", stderr);
886 e = e_connman_network_get(path);
887 if (e_connman_network_wifi_ssid_get(e, &count, &bytes))
889 printf(":::Network %s Wifi SSID = ", path);
890 for (i = 0; i < count; i++)
891 printf("%#02hhx (\"%c\"), ", bytes[i], bytes[i]);
895 fputs("ERROR: can't get network wifi ssid\n", stderr);
900 _on_cmd_network_get_wifi_mode(char *cmd, char *args)
902 const char *wifi_mode, *path;
903 E_Connman_Element *e;
907 fputs("ERROR: missing the network path\n", stderr);
913 e = e_connman_network_get(path);
914 if (e_connman_network_wifi_mode_get(e, &wifi_mode))
915 printf(":::Network %s Wifi Mode = \"%s\"\n", path, wifi_mode);
917 fputs("ERROR: can't get network wifi mode\n", stderr);
922 _on_cmd_network_get_wifi_security(char *cmd, char *args)
924 const char *wifi_security, *path;
925 E_Connman_Element *e;
929 fputs("ERROR: missing the network path\n", stderr);
935 e = e_connman_network_get(path);
936 if (e_connman_network_wifi_security_get(e, &wifi_security))
937 printf(":::Network %s Wifi Security = \"%s\"\n", path, wifi_security);
939 fputs("ERROR: can't get network wifi security\n", stderr);
944 _on_cmd_network_get_wifi_passphrase(char *cmd, char *args)
946 const char *wifi_passphrase, *path;
947 E_Connman_Element *e;
951 fputs("ERROR: missing the network path\n", stderr);
957 e = e_connman_network_get(path);
958 if (e_connman_network_wifi_passphrase_get(e, &wifi_passphrase))
959 printf(":::Network %s Wifi Passphrase = \"%s\"\n", path, wifi_passphrase);
961 fputs("ERROR: can't get network wifi passphrase\n", stderr);
965 /* Services Commands */
967 _on_cmd_service_connect(char *cmd, char *args)
970 E_Connman_Element *e;
974 fputs("ERROR: missing the service path\n", stderr);
980 e = e_connman_service_get(path);
981 if (e_connman_service_connect(e, NULL, NULL))
982 printf(":::Connecting to Service %s...\n", path);
984 fputs("ERROR: can't connect to service\n", stderr);
989 _on_cmd_service_disconnect(char *cmd, char *args)
992 E_Connman_Element *e;
996 fputs("ERROR: missing the service path\n", stderr);
1002 e = e_connman_service_get(path);
1003 if (e_connman_service_disconnect(e, NULL, NULL))
1004 printf(":::Disconnecting Service %s...\n", path);
1006 fputs("ERROR: can't disconnect service\n", stderr);
1011 _on_cmd_service_remove(char *cmd, char *args)
1014 E_Connman_Element *e;
1018 fputs("ERROR: missing the service path\n", stderr);
1024 e = e_connman_service_get(path);
1025 if (e_connman_service_remove(e, NULL, NULL))
1026 printf(":::Removing Service %s...\n", path);
1028 fputs("ERROR: can't remove service\n", stderr);
1033 _on_cmd_service_move_before(char *cmd, char *args)
1035 char *path, *service_path;
1036 E_Connman_Element *e;
1040 fputs("ERROR: missing the service path\n", stderr);
1043 service_path = args;
1048 fputs("ERROR: missing the object service\n", stderr);
1053 e = e_connman_service_get(service_path);
1054 if (e_connman_service_move_before(e, path, NULL, NULL))
1055 printf(":::Moving before %s...\n", path);
1057 fputs("ERROR: can't move before\n", stderr);
1062 _on_cmd_service_move_after(char *cmd, char *args)
1064 char *path, *service_path;
1065 E_Connman_Element *e;
1069 fputs("ERROR: missing the service path\n", stderr);
1072 service_path = args;
1077 fputs("ERROR: missing the object service\n", stderr);
1082 e = e_connman_service_get(service_path);
1083 if (e_connman_service_move_after(e, path, NULL, NULL))
1084 printf(":::Moving after %s...\n", path);
1086 fputs("ERROR: can't move after\n", stderr);
1091 _on_cmd_service_get_state(char *cmd, char *args)
1093 const char *state, *path;
1094 E_Connman_Element *e;
1098 fputs("ERROR: missing the service path\n", stderr);
1104 e = e_connman_service_get(path);
1105 if (e_connman_service_state_get(e, &state))
1106 printf(":::Service %s State = \"%s\"\n", path, state);
1108 fputs("ERROR: can't get service state\n", stderr);
1113 _on_cmd_service_get_error(char *cmd, char *args)
1115 const char *error, *path;
1116 E_Connman_Element *e;
1120 fputs("ERROR: missing the service path\n", stderr);
1126 e = e_connman_service_get(path);
1127 if (e_connman_service_error_get(e, &error))
1128 printf(":::Service %s Error = \"%s\"\n", path, error);
1130 fputs("ERROR: can't get service error\n", stderr);
1135 _on_cmd_service_get_name(char *cmd, char *args)
1137 const char *name, *path;
1138 E_Connman_Element *e;
1142 fputs("ERROR: missing the service path\n", stderr);
1148 e = e_connman_service_get(path);
1149 if (e_connman_service_name_get(e, &name))
1150 printf(":::Service %s Name = \"%s\"\n", path, name);
1152 fputs("ERROR: can't get service name\n", stderr);
1157 _on_cmd_service_get_type(char *cmd, char *args)
1159 const char *type, *path;
1160 E_Connman_Element *e;
1164 fputs("ERROR: missing the service path\n", stderr);
1170 e = e_connman_service_get(path);
1171 if (e_connman_service_type_get(e, &type))
1172 printf(":::Service %s Type = \"%s\"\n", path, type);
1174 fputs("ERROR: can't get service type\n", stderr);
1179 _on_cmd_service_get_mode(char *cmd, char *args)
1181 const char *mode, *path;
1182 E_Connman_Element *e;
1186 fputs("ERROR: missing the service path\n", stderr);
1192 e = e_connman_service_get(path);
1193 if (e_connman_service_mode_get(e, &mode))
1194 printf(":::Service %s Mode = \"%s\"\n", path, mode);
1196 fputs("ERROR: can't get service mode\n", stderr);
1201 _on_cmd_service_get_security(char *cmd, char *args)
1203 const char *security, *path;
1204 E_Connman_Element *e;
1208 fputs("ERROR: missing the service path\n", stderr);
1214 e = e_connman_service_get(path);
1215 if (e_connman_service_security_get(e, &security))
1216 printf(":::Service %s Security = \"%s\"\n", path, security);
1218 fputs("ERROR: can't get service security\n", stderr);
1223 _on_cmd_service_get_passphrase(char *cmd, char *args)
1225 const char *passphrase, *path;
1226 E_Connman_Element *e;
1230 fputs("ERROR: missing the service path\n", stderr);
1236 e = e_connman_service_get(path);
1237 if (e_connman_service_passphrase_get(e, &passphrase))
1238 printf(":::Service %s Passphrase = \"%s\"\n", path, passphrase);
1240 fputs("ERROR: can't get service passphrase\n", stderr);
1245 _on_cmd_service_set_passphrase(char *cmd, char *args)
1247 char *passphrase, *path;
1248 E_Connman_Element *e;
1252 fputs("ERROR: missing the service path\n", stderr);
1256 passphrase = _tok(args);
1260 fputs("ERROR: missing the passphrase value\n", stderr);
1265 e = e_connman_service_get(path);
1266 if (e_connman_service_passphrase_set(e, passphrase, NULL, NULL))
1267 printf(":::Service %s passphrase set to \"%s\"\n", path, passphrase);
1269 fputs("ERROR: can't set service passphrase\n", stderr);
1274 _on_cmd_service_get_passphrase_required(char *cmd, char *args)
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_passphrase_required_get(e, &passphrase))
1290 printf(":::Service %s Passphrase Required = %hhu\n", path, passphrase);
1292 fputs("ERROR: can't get service passphrase required\n", stderr);
1297 _on_cmd_service_get_strength(char *cmd, char *args)
1300 unsigned char strength;
1301 E_Connman_Element *e;
1305 fputs("ERROR: missing the service path\n", stderr);
1311 e = e_connman_service_get(path);
1312 if (e_connman_service_strength_get(e, &strength))
1313 printf(":::Service %s Strength = %#02hhx (%d)\n", path, strength, strength);
1315 fputs("ERROR: can't get service strength\n", stderr);
1320 _on_cmd_service_get_favorite(char *cmd, char *args)
1324 E_Connman_Element *e;
1328 fputs("ERROR: missing the service path\n", stderr);
1334 e = e_connman_service_get(path);
1335 if (e_connman_service_favorite_get(e, &favorite))
1336 printf(":::Service %s Favorite = %hhu\n", path, favorite);
1338 fputs("ERROR: can't get service favorite\n", stderr);
1343 _on_cmd_service_get_immutable(char *cmd, char *args)
1347 E_Connman_Element *e;
1351 fputs("ERROR: missing the service path\n", stderr);
1357 e = e_connman_service_get(path);
1358 if (e_connman_service_immutable_get(e, &immutable))
1359 printf(":::Service %s Immutable = %hhu\n", path, immutable);
1361 fputs("ERROR: can't get service immutable\n", stderr);
1366 _on_cmd_service_get_auto_connect(char *cmd, char *args)
1370 E_Connman_Element *e;
1374 fputs("ERROR: missing the service path\n", stderr);
1380 e = e_connman_service_get(path);
1381 if (e_connman_service_auto_connect_get(e, &auto_connect))
1382 printf(":::Service %s Auto Connect = %hhu\n", path, auto_connect);
1384 fputs("ERROR: can't get service auto connect\n", stderr);
1389 _on_cmd_service_set_auto_connect(char *cmd, char *args)
1391 char *path, *next_args;
1393 E_Connman_Element *e;
1397 fputs("ERROR: missing the service path\n", stderr);
1401 next_args = _tok(args);
1405 fputs("ERROR: missing the auto connect value\n", stderr);
1409 auto_connect = !!atol(next_args);
1411 e = e_connman_service_get(path);
1412 if (e_connman_service_auto_connect_set(e, auto_connect, NULL, NULL))
1413 printf(":::Service %s auto connect set to %d\n", path, auto_connect);
1415 fputs("ERROR: can't set service auto connect\n", stderr);
1420 _on_cmd_service_get_setup_required(char *cmd, char *args)
1423 bool setup_required;
1424 E_Connman_Element *e;
1428 fputs("ERROR: missing the service path\n", stderr);
1434 e = e_connman_service_get(path);
1435 if (e_connman_service_setup_required_get(e, &setup_required))
1436 printf(":::Service %s Setup Required = %hhu\n", path, setup_required);
1438 fputs("ERROR: can't get service setup required\n", stderr);
1443 _on_cmd_service_get_apn(char *cmd, char *args)
1445 const char *apn, *path;
1446 E_Connman_Element *e;
1450 fputs("ERROR: missing the service path\n", stderr);
1456 e = e_connman_service_get(path);
1457 if (e_connman_service_apn_get(e, &apn))
1458 printf(":::Service %s APN = \"%s\"\n", path, apn);
1460 fputs("ERROR: can't get service APN\n", stderr);
1465 _on_cmd_service_set_apn(char *cmd, char *args)
1468 E_Connman_Element *e;
1472 fputs("ERROR: missing the service path\n", stderr);
1480 fputs("ERROR: missing the apn value\n", stderr);
1485 e = e_connman_service_get(path);
1486 if (e_connman_service_apn_set(e, apn, NULL, NULL))
1487 printf(":::Service %s APN set to \"%s\"\n", path, apn);
1489 fputs("ERROR: can't set service APN\n", stderr);
1494 _on_cmd_service_get_mcc(char *cmd, char *args)
1496 const char *mcc, *path;
1497 E_Connman_Element *e;
1501 fputs("ERROR: missing the service path\n", stderr);
1507 e = e_connman_service_get(path);
1508 if (e_connman_service_mcc_get(e, &mcc))
1509 printf(":::Service %s MCC = \"%s\"\n", path, mcc);
1511 fputs("ERROR: can't get service MCC\n", stderr);
1516 _on_cmd_service_get_mnc(char *cmd, char *args)
1518 const char *mnc, *path;
1519 E_Connman_Element *e;
1523 fputs("ERROR: missing the service path\n", stderr);
1529 e = e_connman_service_get(path);
1530 if (e_connman_service_mnc_get(e, &mnc))
1531 printf(":::Service %s MNC = \"%s\"\n", path, mnc);
1533 fputs("ERROR: can't get service MNC\n", stderr);
1538 _on_cmd_service_get_roaming(char *cmd, char *args)
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_roaming_get(e, &roaming))
1554 printf(":::Service %s Roaming = %hhu\n", path, roaming);
1556 fputs("ERROR: can't get service roaming\n", stderr);
1561 _on_cmd_service_get_ipv4_method(char *cmd, char *args)
1563 const char *ipv4_method, *path;
1564 E_Connman_Element *e;
1568 fputs("ERROR: missing the service path\n", stderr);
1574 e = e_connman_service_get(path);
1575 if (e_connman_service_ipv4_method_get(e, &ipv4_method))
1576 printf(":::Service %s ipv4 method = \"%s\"\n", path, ipv4_method);
1578 fputs("ERROR: can't get service ipv4 method\n", stderr);
1583 _on_cmd_service_get_ipv4_address(char *cmd, char *args)
1585 const char *ipv4_address, *path;
1586 E_Connman_Element *e;
1590 fputs("ERROR: missing the service path\n", stderr);
1596 e = e_connman_service_get(path);
1597 if (e_connman_service_ipv4_address_get(e, &ipv4_address))
1598 printf(":::Service %s ipv4 address = \"%s\"\n", path, ipv4_address);
1600 fputs("ERROR: can't get service ipv4 address\n", stderr);
1606 _on_input(void *data, Ecore_Fd_Handler *fd_handler)
1612 int (*cb)(char *cmd, char *args);
1614 {"quit", _on_cmd_quit},
1615 {"sync", _on_cmd_sync},
1616 {"get_all", _on_cmd_get_all},
1617 {"print", _on_cmd_print},
1618 {"get_properties", _on_cmd_get_properties},
1619 {"set_property", _on_cmd_property_set},
1620 {"manager_get", _on_cmd_manager_get},
1621 {"manager_get_profiles", _on_cmd_manager_get_profiles},
1622 {"manager_get_devices", _on_cmd_manager_get_devices},
1623 {"manager_get_services", _on_cmd_manager_get_services},
1624 {"manager_register_agent", _on_cmd_manager_register_agent},
1625 {"manager_unregister_agent", _on_cmd_manager_unregister_agent},
1626 {"manager_get_state", _on_cmd_manager_get_state},
1627 {"manager_get_offline_mode", _on_cmd_manager_get_offline_mode},
1628 {"manager_set_offline_mode", _on_cmd_manager_set_offline_mode},
1629 {"device_propose_scan", _on_cmd_device_propose_scan},
1630 {"device_get_address", _on_cmd_device_get_address},
1631 {"device_get_name", _on_cmd_device_get_name},
1632 {"device_get_type", _on_cmd_device_get_type},
1633 {"device_get_interface", _on_cmd_device_get_interface},
1634 {"device_get_powered", _on_cmd_device_get_powered},
1635 {"device_set_powered", _on_cmd_device_set_powered},
1636 {"device_get_scan_interval", _on_cmd_device_get_scan_interval},
1637 {"device_set_scan_interval", _on_cmd_device_set_scan_interval},
1638 {"device_get_scanning", _on_cmd_device_get_scanning},
1639 {"device_get_networks", _on_cmd_device_get_networks},
1640 {"profile_get_name", _on_cmd_profile_get_name},
1641 {"profile_get_offline_mode", _on_cmd_profile_get_offline_mode},
1642 {"profile_set_offline_mode", _on_cmd_profile_set_offline_mode},
1643 {"profile_get_services", _on_cmd_profile_get_services},
1644 {"network_get_address", _on_cmd_network_get_address},
1645 {"network_get_name", _on_cmd_network_get_name},
1646 {"network_get_connected", _on_cmd_network_get_connected},
1647 {"network_get_strength", _on_cmd_network_get_strength},
1648 {"network_get_device", _on_cmd_network_get_device},
1649 {"network_get_wifi_ssid", _on_cmd_network_get_wifi_ssid},
1650 {"network_get_wifi_mode", _on_cmd_network_get_wifi_mode},
1651 {"network_get_wifi_security", _on_cmd_network_get_wifi_security},
1652 {"network_get_wifi_passphrase", _on_cmd_network_get_wifi_passphrase},
1653 {"service_connect", _on_cmd_service_connect},
1654 {"service_disconnect", _on_cmd_service_disconnect},
1655 {"service_remove", _on_cmd_service_remove},
1656 {"service_move_before", _on_cmd_service_move_before},
1657 {"service_move_after", _on_cmd_service_move_after},
1658 {"service_get_state", _on_cmd_service_get_state},
1659 {"service_get_error", _on_cmd_service_get_error},
1660 {"service_get_name", _on_cmd_service_get_name},
1661 {"service_get_type", _on_cmd_service_get_type},
1662 {"service_get_mode", _on_cmd_service_get_mode},
1663 {"service_get_security", _on_cmd_service_get_security},
1664 {"service_get_passphrase", _on_cmd_service_get_passphrase},
1665 {"service_set_passphrase", _on_cmd_service_set_passphrase},
1666 {"service_get_passphrase_required", _on_cmd_service_get_passphrase_required},
1667 {"service_get_strength", _on_cmd_service_get_strength},
1668 {"service_get_favorite", _on_cmd_service_get_favorite},
1669 {"service_get_immutable", _on_cmd_service_get_immutable},
1670 {"service_get_auto_connect", _on_cmd_service_get_auto_connect},
1671 {"service_set_auto_connect", _on_cmd_service_set_auto_connect},
1672 {"service_get_setup_required", _on_cmd_service_get_setup_required},
1673 {"service_get_apn", _on_cmd_service_get_apn},
1674 {"service_set_apn", _on_cmd_service_set_apn},
1675 {"service_get_mcc", _on_cmd_service_get_mcc},
1676 {"service_get_mnc", _on_cmd_service_get_mnc},
1677 {"service_get_roaming", _on_cmd_service_get_roaming},
1678 {"service_get_ipv4_method", _on_cmd_service_get_ipv4_method},
1679 {"service_get_ipv4_address", _on_cmd_service_get_ipv4_address},
1684 if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR))
1686 fputs("ERROR: reading from stdin, exit\n", stderr);
1690 if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
1692 fputs("ERROR: nothing to read?\n", stderr);
1696 if (!fgets(buf, sizeof(buf), stdin))
1698 fprintf(stderr, "ERROR: could not read command: %s\n", strerror(errno));
1699 ecore_main_loop_quit();
1704 while (isspace(*cmd))
1707 args = strchr(cmd, ' ');
1715 while (isspace(*args))
1718 p = args + strlen(args) - 1;
1726 p = cmd + strlen(cmd) - 1;
1731 if (strcmp(cmd, "help") == 0)
1735 printf("Commands with '%s' in the name:\n", args);
1736 for (itr = maps; itr->cmd != NULL; itr++)
1737 if (strstr(itr->cmd, args))
1738 printf("\t%s\n", itr->cmd);
1742 fputs("Commands:\n", stdout);
1743 for (itr = maps; itr->cmd != NULL; itr++)
1744 printf("\t%s\n", itr->cmd);
1746 fputc('\n', stdout);
1750 for (itr = maps; itr->cmd != NULL; itr++)
1751 if (strcmp(itr->cmd, cmd) == 0)
1752 return itr->cb(cmd, args);
1754 printf("unknown command \"%s\", args=%s\n", cmd, args);
1759 main(int argc, char *argv[])
1761 E_DBus_Connection *c;
1767 c = e_dbus_bus_get(DBUS_BUS_SYSTEM);
1769 printf("ERROR: can't connect to system session\n");
1773 e_connman_system_init(c);
1774 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_ADD, _on_element_add, NULL);
1775 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_DEL, _on_element_del, NULL);
1776 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_UPDATED,
1777 _on_element_updated, NULL);
1779 ecore_main_fd_handler_add
1780 (0, ECORE_FD_READ | ECORE_FD_ERROR, _on_input, NULL, NULL, NULL);
1782 ecore_main_loop_begin();
1784 e_connman_system_shutdown();
1786 e_dbus_connection_close(c);
1791 fputs("DBG: clean exit.\n", stderr);