5 #define E_CONNMAN_I_KNOW_THIS_API_IS_SUBJECT_TO_CHANGE 1
13 _method_success_check(void *data, __UNUSED__ DBusMessage *msg, DBusError *error)
15 const char *name = data;
17 if ((!error) || (!dbus_error_is_set(error)))
19 printf("SUCCESS: method %s() finished successfully.\n", name);
23 printf("FAILURE: method %s() finished with error: %s %s\n",
24 name, error->name, error->message);
25 dbus_error_free(error);
29 _elements_print(E_Connman_Element **elements, unsigned int count)
32 for (i = 0; i < count; i++)
34 printf("--- element %d:\n", i);
35 e_connman_element_print(stdout, elements[i]);
38 printf("END: all elements count = %u\n", count);
42 _strings_print(const char **strings, unsigned int count)
45 for (i = 0; i < count; i++)
46 printf("--- strings %d: \"%s\"\n", i, strings[i]);
48 printf("END: all strings count = %u\n", count);
52 _on_element_add(__UNUSED__ void *data, __UNUSED__ int type, void *info)
54 E_Connman_Element *element = info;
55 printf(">>> %s\n", element->path);
56 return ECORE_CALLBACK_PASS_ON;
60 _on_element_del(__UNUSED__ void *data, __UNUSED__ int type, void *info)
62 E_Connman_Element *element = info;
63 printf("<<< %s\n", element->path);
64 return ECORE_CALLBACK_PASS_ON;
68 _on_element_updated(__UNUSED__ void *data, __UNUSED__ int type, void *info)
70 E_Connman_Element *element = info;
71 printf("!!! %s\n", element->path);
72 e_connman_element_print(stderr, element);
73 return ECORE_CALLBACK_PASS_ON;
77 _on_cmd_quit(__UNUSED__ char *cmd, __UNUSED__ char *args)
79 fputs("Bye!\n", stderr);
80 ecore_main_loop_quit();
81 return ECORE_CALLBACK_CANCEL;
85 _on_cmd_sync(__UNUSED__ char *cmd, __UNUSED__ char *args)
87 e_connman_manager_sync_elements();
88 return ECORE_CALLBACK_RENEW;
109 _on_cmd_get_all(__UNUSED__ char *cmd, char *args)
111 E_Connman_Element **elements;
122 ret = e_connman_elements_get_all_type(type, &count, &elements);
124 ret = e_connman_elements_get_all(&count, &elements);
127 fputs("ERROR: could not get elements\n", stderr);
130 printf("BEG: all elements type=%s count = %d\n", type, count);
131 _elements_print(elements, count);
134 return ECORE_CALLBACK_RENEW;
137 static E_Connman_Element *
138 _element_from_args(char *args, char **next_args)
140 E_Connman_Element *element;
144 fputs("ERROR: missing element path\n", stderr);
149 *next_args = _tok(args);
150 element = e_connman_element_get(args);
152 fprintf(stderr, "ERROR: no element called \"%s\".\n", args);
158 _on_cmd_print(__UNUSED__ char *cmd, char *args)
161 E_Connman_Element *element = _element_from_args(args, &next_args);
163 e_connman_element_print(stdout, element);
164 return ECORE_CALLBACK_RENEW;
168 _on_cmd_get_properties(__UNUSED__ char *cmd, char *args)
171 E_Connman_Element *element = _element_from_args(args, &next_args);
173 e_connman_element_properties_sync(element);
174 return ECORE_CALLBACK_RENEW;
178 _on_cmd_property_set(__UNUSED__ char *cmd, char *args)
180 char *next_args, *name, *p;
181 E_Connman_Element *element = _element_from_args(args, &next_args);
189 return ECORE_CALLBACK_RENEW;
193 fputs("ERROR: missing parameters name, type and value.\n", stderr);
194 return ECORE_CALLBACK_RENEW;
201 fputs("ERROR: missing parameters type and value.\n", stderr);
202 return ECORE_CALLBACK_RENEW;
208 fputs("ERROR: missing parameter value.\n", stderr);
209 return ECORE_CALLBACK_RENEW;
215 case DBUS_TYPE_BOOLEAN:
216 vlong = !!atol(next_args);
218 fprintf(stderr, "DBG: boolean is: %ld\n", vlong);
220 case DBUS_TYPE_UINT16:
221 vu16 = strtol(next_args, &p, 0);
224 fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
225 return ECORE_CALLBACK_RENEW;
228 fprintf(stderr, "DBG: u16 is: %hu\n", vu16);
230 case DBUS_TYPE_UINT32:
231 vu32 = strtol(next_args, &p, 0);
234 fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
235 return ECORE_CALLBACK_RENEW;
238 fprintf(stderr, "DBG: u16 is: %u\n", vu32);
240 case DBUS_TYPE_STRING:
241 case DBUS_TYPE_OBJECT_PATH:
242 p = next_args + strlen(next_args);
245 while (p > next_args && isspace(*p))
249 fprintf(stderr, "ERROR: invalid string \"%s\".\n", next_args);
253 fprintf(stderr, "DBG: string is: \"%s\"\n", next_args);
256 fprintf(stderr, "ERROR: don't know how to parse type '%c' (%d)\n",
258 return ECORE_CALLBACK_RENEW;
261 fprintf(stderr, "set_property %s [%p] %s %c %p...\n",
262 args, element, name, type, value);
263 if (!e_connman_element_property_set(element, name, type, value))
264 fputs("ERROR: error setting property.\n", stderr);
266 return ECORE_CALLBACK_RENEW;
270 /* Manager Commands */
273 _on_cmd_manager_get(__UNUSED__ char *cmd, __UNUSED__ char *args)
275 E_Connman_Element *element;
276 element = e_connman_manager_get();
277 e_connman_element_print(stderr, element);
278 return ECORE_CALLBACK_RENEW;
282 _on_cmd_manager_get_profiles(__UNUSED__ char *cmd, __UNUSED__ char *args)
285 E_Connman_Element **profiles;
287 if (!e_connman_manager_profiles_get(&count, &profiles))
289 fputs("ERROR: can't get profiles\n", stderr);
290 return ECORE_CALLBACK_RENEW;
292 printf("BEG: all manager profiles elements count = %d\n", count);
293 _elements_print(profiles, count);
294 return ECORE_CALLBACK_RENEW;
298 _on_cmd_manager_get_services(__UNUSED__ char *cmd, __UNUSED__ char *args)
301 E_Connman_Element **services;
303 if (!e_connman_manager_services_get(&count, &services))
305 fputs("ERROR: can't get services\n", stderr);
306 return ECORE_CALLBACK_RENEW;
308 printf("BEG: all manager services elements count = %d\n", count);
309 _elements_print(services, count);
310 return ECORE_CALLBACK_RENEW;
314 _on_cmd_manager_register_agent(__UNUSED__ char *cmd, char *args)
320 fputs("ERROR: missing the object path\n", stderr);
321 return ECORE_CALLBACK_RENEW;
325 if (e_connman_manager_agent_register
326 (path, _method_success_check, "manager_register_agent"))
327 printf(":::Registering agent %s...\n", path);
329 fprintf(stderr, "ERROR: can't register agent %s\n", path);
331 return ECORE_CALLBACK_RENEW;
335 _on_cmd_manager_unregister_agent(__UNUSED__ char *cmd, char *args)
341 fputs("ERROR: missing the object path\n", stderr);
342 return ECORE_CALLBACK_RENEW;
346 if (e_connman_manager_agent_unregister
347 (path, _method_success_check, "manager_unregister_agent"))
348 printf(":::Unregistering agent %s...\n", path);
350 fprintf(stderr, "ERROR: can't unregister agent %s\n", path);
352 return ECORE_CALLBACK_RENEW;
356 _on_cmd_manager_get_state(__UNUSED__ char *cmd, __UNUSED__ char *args)
359 if (e_connman_manager_state_get(&state))
360 printf(":::Manager state = \"%s\"\n", state);
362 fputs("ERROR: can't get manager state\n", stderr);
363 return ECORE_CALLBACK_RENEW;
367 _on_cmd_manager_get_offline_mode(__UNUSED__ char *cmd, __UNUSED__ char *args)
370 if (e_connman_manager_offline_mode_get(&offline))
371 printf(":::Manager Offline Mode = %hhu\n", offline);
373 fputs("ERROR: can't get manager offline mode\n", stderr);
374 return ECORE_CALLBACK_RENEW;
378 _on_cmd_manager_set_offline_mode(__UNUSED__ char *cmd, char *args)
383 fputs("ERROR: missing the offline mode value\n", stderr);
384 return ECORE_CALLBACK_RENEW;
387 offline = !!atol(args);
388 if (e_connman_manager_offline_mode_set
389 (offline, _method_success_check, "manager_set_offline_mode"))
391 printf(":::Manager Offline Mode set to %hhu\n", offline);
393 fputs("ERROR: can't set manager offline mode\n", stderr);
394 return ECORE_CALLBACK_RENEW;
398 _on_cmd_manager_request_scan(__UNUSED__ char *cmd, char *args)
406 if (e_connman_manager_request_scan
407 (args, _method_success_check, "manager_request_scan"))
408 printf(":::Manager Request Scan for %s\n", args[0] ? args : "<all>");
410 fputs("ERROR: can't request scan on manager\n", stderr);
411 return ECORE_CALLBACK_RENEW;
415 _on_cmd_manager_technology_enable(__UNUSED__ char *cmd, char *args)
419 fputs("ERROR: missing the technology type\n", stderr);
420 return ECORE_CALLBACK_RENEW;
424 if (e_connman_manager_technology_enable
425 (args, _method_success_check, "manager_technology_enable"))
426 printf(":::Manager Enable Technology %s\n", args);
428 fputs("ERROR: can't enable technology on manager\n", stderr);
429 return ECORE_CALLBACK_RENEW;
433 _on_cmd_manager_technology_disable(__UNUSED__ char *cmd, char *args)
437 fputs("ERROR: missing the technology type\n", stderr);
438 return ECORE_CALLBACK_RENEW;
442 if (e_connman_manager_technology_disable
443 (args, _method_success_check, "manager_technology_disable"))
444 printf(":::Manager Disable Technology %s\n", args);
446 fputs("ERROR: can't disable technology on manager\n", stderr);
447 return ECORE_CALLBACK_RENEW;
451 _on_cmd_manager_get_technologies_available(__UNUSED__ char *cmd, __UNUSED__ char *args)
453 const char **strings;
456 if (!e_connman_manager_technologies_available_get(&count, &strings))
457 fputs("ERROR: can't get available technologies\n", stderr);
460 printf("BEG: available technologies count = %u\n", count);
461 _strings_print(strings, count);
464 return ECORE_CALLBACK_RENEW;
468 _on_cmd_manager_get_technologies_enabled(__UNUSED__ char *cmd, __UNUSED__ char *args)
470 const char **strings;
473 if (!e_connman_manager_technologies_enabled_get(&count, &strings))
474 fputs("ERROR: can't get enabled technologies\n", stderr);
477 printf("BEG: enabled technologies count = %u\n", count);
478 _strings_print(strings, count);
481 return ECORE_CALLBACK_RENEW;
485 _on_cmd_manager_get_technologies_connected(__UNUSED__ char *cmd, __UNUSED__ char *args)
487 const char **strings;
490 if (!e_connman_manager_technologies_connected_get(&count, &strings))
491 fputs("ERROR: can't get connected technologies\n", stderr);
494 printf("BEG: connected technologies count = %u\n", count);
495 _strings_print(strings, count);
498 return ECORE_CALLBACK_RENEW;
502 _on_cmd_manager_profile_remove(__UNUSED__ char *cmd, char *args)
504 E_Connman_Element *e;
508 fputs("ERROR: missing the profile path\n", stderr);
509 return ECORE_CALLBACK_RENEW;
513 e = e_connman_profile_get(args);
514 if (e_connman_manager_profile_remove
515 (e, _method_success_check, "manager_profile_remove"))
516 printf(":::Manager Remove Profile %s\n", args);
518 fputs("ERROR: can't remove profile from manager\n", stderr);
519 return ECORE_CALLBACK_RENEW;
523 _on_cmd_manager_profile_get_active(__UNUSED__ char *cmd, __UNUSED__ char *args)
525 E_Connman_Element *e;
527 if (!e_connman_manager_profile_active_get(&e))
528 fputs("ERROR: can't active_get profile from manager\n", stderr);
530 e_connman_element_print(stderr, e);
531 return ECORE_CALLBACK_RENEW;
535 _on_cmd_manager_profile_set_active(__UNUSED__ char *cmd, char *args)
537 E_Connman_Element *e;
541 fputs("ERROR: missing the profile path\n", stderr);
542 return ECORE_CALLBACK_RENEW;
546 e = e_connman_profile_get(args);
547 if (e_connman_manager_profile_active_set
548 (e, _method_success_check, "manager_profile_set_active"))
549 printf(":::Manager Active Profile set to %s\n", args);
551 fputs("ERROR: can't set active profile\n", stderr);
552 return ECORE_CALLBACK_RENEW;
555 /* Profile Commands */
558 _on_cmd_profile_get_name(__UNUSED__ char *cmd, char *args)
560 const char *name, *path;
561 E_Connman_Element *e;
565 fputs("ERROR: missing the profile path\n", stderr);
566 return ECORE_CALLBACK_RENEW;
571 e = e_connman_profile_get(path);
572 if (e_connman_profile_name_get(e, &name))
573 printf(":::Profile %s Name = \"%s\"\n", path, name);
575 fputs("ERROR: can't get profile name\n", stderr);
576 return ECORE_CALLBACK_RENEW;
580 _on_cmd_profile_set_name(__UNUSED__ char *cmd, char *args)
582 char *path, *next_args;
583 E_Connman_Element *e;
587 fputs("ERROR: missing the profile path\n", stderr);
588 return ECORE_CALLBACK_RENEW;
591 next_args = _tok(args);
594 fputs("ERROR: missing the offline mode value\n", stderr);
595 return ECORE_CALLBACK_RENEW;
599 e = e_connman_profile_get(path);
600 if (e_connman_profile_name_set
601 (e, next_args, _method_success_check, "profile_set_name"))
602 printf(":::Profile %s Name set to %s\n", path, next_args);
604 fputs("ERROR: can't set profile name\n", stderr);
605 return ECORE_CALLBACK_RENEW;
609 _on_cmd_profile_get_offline_mode(__UNUSED__ char *cmd, char *args)
613 E_Connman_Element *e;
617 fputs("ERROR: missing the profile path\n", stderr);
618 return ECORE_CALLBACK_RENEW;
623 e = e_connman_profile_get(path);
624 if (e_connman_profile_offline_mode_get(e, &offline))
625 printf(":::Profile %s Offline Mode = %hhu\n", path, offline);
627 fputs("ERROR: can't get profile offline mode\n", stderr);
628 return ECORE_CALLBACK_RENEW;
632 _on_cmd_profile_set_offline_mode(__UNUSED__ char *cmd, char *args)
634 char *path, *next_args;
636 E_Connman_Element *e;
640 fputs("ERROR: missing the profile path\n", stderr);
641 return ECORE_CALLBACK_RENEW;
644 next_args = _tok(args);
647 fputs("ERROR: missing the offline mode value\n", stderr);
648 return ECORE_CALLBACK_RENEW;
651 offline = !!atol(next_args);
653 e = e_connman_profile_get(path);
654 if (e_connman_profile_offline_mode_set
655 (e, offline, _method_success_check, "profile_set_offline_mode"))
656 printf(":::Profile %s Offline Mode set to %hhu\n", path, offline);
658 fputs("ERROR: can't set profile offline mode\n", stderr);
659 return ECORE_CALLBACK_RENEW;
663 _on_cmd_profile_get_services(__UNUSED__ char *cmd, char *args)
665 E_Connman_Element **services;
666 E_Connman_Element *e;
672 fputs("ERROR: missing the profile path\n", stderr);
673 return ECORE_CALLBACK_RENEW;
678 e = e_connman_profile_get(path);
679 if (!e_connman_profile_services_get(e, &count, &services))
681 fputs("ERROR: can't get services\n", stderr);
682 return ECORE_CALLBACK_RENEW;
684 printf("BEG: all profile services count = %d\n", count);
685 _elements_print(services, count);
686 return ECORE_CALLBACK_RENEW;
690 /* Services Commands */
692 _on_cmd_service_connect(__UNUSED__ char *cmd, char *args)
695 E_Connman_Element *e;
699 fputs("ERROR: missing the service path\n", stderr);
700 return ECORE_CALLBACK_RENEW;
705 e = e_connman_service_get(path);
706 if (e_connman_service_connect
707 (e, _method_success_check, "service_connect"))
708 printf(":::Connecting to Service %s...\n", path);
710 fputs("ERROR: can't connect to service\n", stderr);
711 return ECORE_CALLBACK_RENEW;
715 _on_cmd_service_disconnect(__UNUSED__ char *cmd, char *args)
718 E_Connman_Element *e;
722 fputs("ERROR: missing the service path\n", stderr);
723 return ECORE_CALLBACK_RENEW;
728 e = e_connman_service_get(path);
729 if (e_connman_service_disconnect
730 (e, _method_success_check, "service_disconnect"))
731 printf(":::Disconnecting Service %s...\n", path);
733 fputs("ERROR: can't disconnect service\n", stderr);
734 return ECORE_CALLBACK_RENEW;
738 _on_cmd_service_remove(__UNUSED__ char *cmd, char *args)
741 E_Connman_Element *e;
745 fputs("ERROR: missing the service path\n", stderr);
746 return ECORE_CALLBACK_RENEW;
751 e = e_connman_service_get(path);
752 if (e_connman_service_remove
753 (e, _method_success_check, "service_remove"))
754 printf(":::Removing Service %s...\n", path);
756 fputs("ERROR: can't remove service\n", stderr);
757 return ECORE_CALLBACK_RENEW;
761 _on_cmd_service_move_before(__UNUSED__ char *cmd, char *args)
763 char *path, *service_path;
764 E_Connman_Element *e;
768 fputs("ERROR: missing the service path\n", stderr);
769 return ECORE_CALLBACK_RENEW;
776 fputs("ERROR: missing the object service\n", stderr);
777 return ECORE_CALLBACK_RENEW;
781 e = e_connman_service_get(service_path);
782 if (e_connman_service_move_before
783 (e, path, _method_success_check, "service_move_before"))
784 printf(":::Moving before %s...\n", path);
786 fputs("ERROR: can't move before\n", stderr);
787 return ECORE_CALLBACK_RENEW;
791 _on_cmd_service_move_after(__UNUSED__ char *cmd, char *args)
793 char *path, *service_path;
794 E_Connman_Element *e;
798 fputs("ERROR: missing the service path\n", stderr);
799 return ECORE_CALLBACK_RENEW;
806 fputs("ERROR: missing the object service\n", stderr);
807 return ECORE_CALLBACK_RENEW;
811 e = e_connman_service_get(service_path);
812 if (e_connman_service_move_after
813 (e, path, _method_success_check, "service_move_after"))
814 printf(":::Moving after %s...\n", path);
816 fputs("ERROR: can't move after\n", stderr);
817 return ECORE_CALLBACK_RENEW;
821 _on_cmd_service_get_state(__UNUSED__ char *cmd, char *args)
823 const char *state, *path;
824 E_Connman_Element *e;
828 fputs("ERROR: missing the service path\n", stderr);
829 return ECORE_CALLBACK_RENEW;
834 e = e_connman_service_get(path);
835 if (e_connman_service_state_get(e, &state))
836 printf(":::Service %s State = \"%s\"\n", path, state);
838 fputs("ERROR: can't get service state\n", stderr);
839 return ECORE_CALLBACK_RENEW;
843 _on_cmd_service_get_error(__UNUSED__ char *cmd, char *args)
845 const char *error, *path;
846 E_Connman_Element *e;
850 fputs("ERROR: missing the service path\n", stderr);
851 return ECORE_CALLBACK_RENEW;
856 e = e_connman_service_get(path);
857 if (e_connman_service_error_get(e, &error))
858 printf(":::Service %s Error = \"%s\"\n", path, error);
860 fputs("ERROR: can't get service error\n", stderr);
861 return ECORE_CALLBACK_RENEW;
865 _on_cmd_service_get_name(__UNUSED__ char *cmd, char *args)
867 const char *name, *path;
868 E_Connman_Element *e;
872 fputs("ERROR: missing the service path\n", stderr);
873 return ECORE_CALLBACK_RENEW;
878 e = e_connman_service_get(path);
879 if (e_connman_service_name_get(e, &name))
880 printf(":::Service %s Name = \"%s\"\n", path, name);
882 fputs("ERROR: can't get service name\n", stderr);
883 return ECORE_CALLBACK_RENEW;
887 _on_cmd_service_get_type(__UNUSED__ char *cmd, char *args)
889 const char *type, *path;
890 E_Connman_Element *e;
894 fputs("ERROR: missing the service path\n", stderr);
895 return ECORE_CALLBACK_RENEW;
900 e = e_connman_service_get(path);
901 if (e_connman_service_type_get(e, &type))
902 printf(":::Service %s Type = \"%s\"\n", path, type);
904 fputs("ERROR: can't get service type\n", stderr);
905 return ECORE_CALLBACK_RENEW;
909 _on_cmd_service_get_security(__UNUSED__ char *cmd, char *args)
912 const char **security;
914 E_Connman_Element *e;
918 fputs("ERROR: missing the service path\n", stderr);
919 return ECORE_CALLBACK_RENEW;
924 e = e_connman_service_get(path);
925 if (e_connman_service_security2_get(e, &count, &security))
928 for (i = 0; i < count; i++)
929 printf("\"%s\", ", security[i]);
933 fputs("ERROR: can't get service security\n", stderr);
934 return ECORE_CALLBACK_RENEW;
938 _on_cmd_service_get_passphrase(__UNUSED__ char *cmd, char *args)
940 const char *passphrase, *path;
941 E_Connman_Element *e;
945 fputs("ERROR: missing the service path\n", stderr);
946 return ECORE_CALLBACK_RENEW;
951 e = e_connman_service_get(path);
952 if (e_connman_service_passphrase_get(e, &passphrase))
953 printf(":::Service %s Passphrase = \"%s\"\n", path, passphrase);
955 fputs("ERROR: can't get service passphrase\n", stderr);
956 return ECORE_CALLBACK_RENEW;
960 _on_cmd_service_set_passphrase(__UNUSED__ char *cmd, char *args)
962 char *passphrase, *path;
963 E_Connman_Element *e;
967 fputs("ERROR: missing the service path\n", stderr);
968 return ECORE_CALLBACK_RENEW;
971 passphrase = _tok(args);
975 fputs("ERROR: missing the passphrase value\n", stderr);
976 return ECORE_CALLBACK_RENEW;
980 e = e_connman_service_get(path);
981 if (e_connman_service_passphrase_set
982 (e, passphrase, _method_success_check, "service_set_passphrase"))
983 printf(":::Service %s passphrase set to \"%s\"\n", path, passphrase);
985 fputs("ERROR: can't set service passphrase\n", stderr);
986 return ECORE_CALLBACK_RENEW;
990 _on_cmd_service_get_passphrase_required(__UNUSED__ char *cmd, char *args)
993 Eina_Bool passphrase;
994 E_Connman_Element *e;
998 fputs("ERROR: missing the service path\n", stderr);
999 return ECORE_CALLBACK_RENEW;
1004 e = e_connman_service_get(path);
1005 if (e_connman_service_passphrase_required_get(e, &passphrase))
1006 printf(":::Service %s Passphrase Required = %hhu\n", path, passphrase);
1008 fputs("ERROR: can't get service passphrase required\n", stderr);
1009 return ECORE_CALLBACK_RENEW;
1013 _on_cmd_service_get_strength(__UNUSED__ char *cmd, char *args)
1016 unsigned char strength;
1017 E_Connman_Element *e;
1021 fputs("ERROR: missing the service path\n", stderr);
1022 return ECORE_CALLBACK_RENEW;
1027 e = e_connman_service_get(path);
1028 if (e_connman_service_strength_get(e, &strength))
1029 printf(":::Service %s Strength = %#02hhx (%d)\n", path, strength, strength);
1031 fputs("ERROR: can't get service strength\n", stderr);
1032 return ECORE_CALLBACK_RENEW;
1036 _on_cmd_service_get_favorite(__UNUSED__ char *cmd, char *args)
1040 E_Connman_Element *e;
1044 fputs("ERROR: missing the service path\n", stderr);
1045 return ECORE_CALLBACK_RENEW;
1050 e = e_connman_service_get(path);
1051 if (e_connman_service_favorite_get(e, &favorite))
1052 printf(":::Service %s Favorite = %hhu\n", path, favorite);
1054 fputs("ERROR: can't get service favorite\n", stderr);
1055 return ECORE_CALLBACK_RENEW;
1059 _on_cmd_service_get_immutable(__UNUSED__ char *cmd, char *args)
1062 Eina_Bool immutable;
1063 E_Connman_Element *e;
1067 fputs("ERROR: missing the service path\n", stderr);
1068 return ECORE_CALLBACK_RENEW;
1073 e = e_connman_service_get(path);
1074 if (e_connman_service_immutable_get(e, &immutable))
1075 printf(":::Service %s Immutable = %hhu\n", path, immutable);
1077 fputs("ERROR: can't get service immutable\n", stderr);
1078 return ECORE_CALLBACK_RENEW;
1082 _on_cmd_service_get_auto_connect(__UNUSED__ char *cmd, char *args)
1085 Eina_Bool auto_connect;
1086 E_Connman_Element *e;
1090 fputs("ERROR: missing the service path\n", stderr);
1091 return ECORE_CALLBACK_RENEW;
1096 e = e_connman_service_get(path);
1097 if (e_connman_service_auto_connect_get(e, &auto_connect))
1098 printf(":::Service %s Auto Connect = %hhu\n", path, auto_connect);
1100 fputs("ERROR: can't get service auto connect\n", stderr);
1101 return ECORE_CALLBACK_RENEW;
1105 _on_cmd_service_set_auto_connect(__UNUSED__ char *cmd, char *args)
1107 char *path, *next_args;
1108 Eina_Bool auto_connect;
1109 E_Connman_Element *e;
1113 fputs("ERROR: missing the service path\n", stderr);
1114 return ECORE_CALLBACK_RENEW;
1117 next_args = _tok(args);
1121 fputs("ERROR: missing the auto connect value\n", stderr);
1122 return ECORE_CALLBACK_RENEW;
1125 auto_connect = !!atol(next_args);
1127 e = e_connman_service_get(path);
1128 if (e_connman_service_auto_connect_set
1129 (e, auto_connect, _method_success_check, "service_set_auto_connect"))
1130 printf(":::Service %s auto connect set to %d\n", path, auto_connect);
1132 fputs("ERROR: can't set service auto connect\n", stderr);
1133 return ECORE_CALLBACK_RENEW;
1137 _on_cmd_service_get_roaming(__UNUSED__ char *cmd, char *args)
1141 E_Connman_Element *e;
1145 fputs("ERROR: missing the service path\n", stderr);
1146 return ECORE_CALLBACK_RENEW;
1151 e = e_connman_service_get(path);
1152 if (e_connman_service_roaming_get(e, &roaming))
1153 printf(":::Service %s Roaming = %hhu\n", path, roaming);
1155 fputs("ERROR: can't get service roaming\n", stderr);
1156 return ECORE_CALLBACK_RENEW;
1160 _on_cmd_service_get_ipv4_method(__UNUSED__ char *cmd, char *args)
1162 const char *ipv4_method, *path;
1163 E_Connman_Element *e;
1167 fputs("ERROR: missing the service path\n", stderr);
1168 return ECORE_CALLBACK_RENEW;
1173 e = e_connman_service_get(path);
1174 if (e_connman_service_ipv4_method_get(e, &ipv4_method))
1175 printf(":::Service %s IPv4 Method = \"%s\"\n", path, ipv4_method);
1177 fputs("ERROR: can't get service ipv4 method\n", stderr);
1178 return ECORE_CALLBACK_RENEW;
1182 _on_cmd_service_get_ipv4_address(__UNUSED__ char *cmd, char *args)
1184 const char *ipv4_address, *path;
1185 E_Connman_Element *e;
1189 fputs("ERROR: missing the service path\n", stderr);
1190 return ECORE_CALLBACK_RENEW;
1195 e = e_connman_service_get(path);
1196 if (e_connman_service_ipv4_address_get(e, &ipv4_address))
1197 printf(":::Service %s IPv4 Address = \"%s\"\n", path, ipv4_address);
1199 fputs("ERROR: can't get service ipv4 address\n", stderr);
1200 return ECORE_CALLBACK_RENEW;
1204 _on_cmd_service_get_ipv4_gateway(__UNUSED__ char *cmd, char *args)
1206 const char *ipv4_gateway, *path;
1207 E_Connman_Element *e;
1211 fputs("ERROR: missing the service path\n", stderr);
1212 return ECORE_CALLBACK_RENEW;
1217 e = e_connman_service_get(path);
1218 if (e_connman_service_ipv4_gateway_get(e, &ipv4_gateway))
1219 printf(":::Service %s IPv4 Gateway = \"%s\"\n", path, ipv4_gateway);
1221 fputs("ERROR: can't get service ipv4 gateway\n", stderr);
1222 return ECORE_CALLBACK_RENEW;
1226 _on_cmd_service_get_ipv4_netmask(__UNUSED__ char *cmd, char *args)
1228 const char *ipv4_netmask, *path;
1229 E_Connman_Element *e;
1233 fputs("ERROR: missing the service path\n", stderr);
1234 return ECORE_CALLBACK_RENEW;
1239 e = e_connman_service_get(path);
1240 if (e_connman_service_ipv4_netmask_get(e, &ipv4_netmask))
1241 printf(":::Service %s IPv4 Netmask = \"%s\"\n", path, ipv4_netmask);
1243 fputs("ERROR: can't get service ipv4 netmask\n", stderr);
1244 return ECORE_CALLBACK_RENEW;
1248 _on_cmd_service_get_ipv4_configuration_method(__UNUSED__ char *cmd, char *args)
1250 const char *ipv4_method, *path;
1251 E_Connman_Element *e;
1255 fputs("ERROR: missing the service path\n", stderr);
1256 return ECORE_CALLBACK_RENEW;
1261 e = e_connman_service_get(path);
1262 if (e_connman_service_ipv4_configuration_method_get(e, &ipv4_method))
1263 printf(":::Service %s IPv4 Configuration Method = \"%s\"\n",
1266 fputs("ERROR: can't get service ipv4_configuration method\n", stderr);
1267 return ECORE_CALLBACK_RENEW;
1271 _on_cmd_service_get_ipv4_configuration_address(__UNUSED__ char *cmd, char *args)
1273 const char *ipv4_address, *path;
1274 E_Connman_Element *e;
1278 fputs("ERROR: missing the service path\n", stderr);
1279 return ECORE_CALLBACK_RENEW;
1284 e = e_connman_service_get(path);
1285 if (e_connman_service_ipv4_configuration_address_get(e, &ipv4_address))
1286 printf(":::Service %s IPv4 Configuration Address = \"%s\"\n",
1287 path, ipv4_address);
1289 fputs("ERROR: can't get service ipv4_configuration address\n", stderr);
1290 return ECORE_CALLBACK_RENEW;
1294 _on_cmd_service_get_ipv4_configuration_gateway(__UNUSED__ char *cmd, char *args)
1296 const char *ipv4_gateway, *path;
1297 E_Connman_Element *e;
1301 fputs("ERROR: missing the service path\n", stderr);
1302 return ECORE_CALLBACK_RENEW;
1307 e = e_connman_service_get(path);
1308 if (e_connman_service_ipv4_configuration_gateway_get(e, &ipv4_gateway))
1309 printf(":::Service %s IPv4 Configuration Gateway = \"%s\"\n",
1310 path, ipv4_gateway);
1312 fputs("ERROR: can't get service ipv4_configuration gateway\n", stderr);
1313 return ECORE_CALLBACK_RENEW;
1317 _on_cmd_service_get_ipv4_configuration_netmask(__UNUSED__ char *cmd, char *args)
1319 const char *ipv4_netmask, *path;
1320 E_Connman_Element *e;
1324 fputs("ERROR: missing the service path\n", stderr);
1325 return ECORE_CALLBACK_RENEW;
1330 e = e_connman_service_get(path);
1331 if (e_connman_service_ipv4_configuration_netmask_get(e, &ipv4_netmask))
1332 printf(":::Service %s IPv4 Configuration Netmask = \"%s\"\n",
1333 path, ipv4_netmask);
1335 fputs("ERROR: can't get service ipv4 configuration netmask\n", stderr);
1336 return ECORE_CALLBACK_RENEW;
1340 _on_cmd_service_ipv4_configure_dhcp(__UNUSED__ char *cmd, char *args)
1343 E_Connman_Element *e;
1347 fputs("ERROR: missing the service path\n", stderr);
1348 return ECORE_CALLBACK_RENEW;
1353 e = e_connman_service_get(path);
1354 if (e_connman_service_ipv4_configure_dhcp
1355 (e, _method_success_check, "service_ipv4_configure_dhcp"))
1356 printf(":::Service %s IPv4 Configuration set to DHCP\n", path);
1358 fputs("ERROR: can't set service ipv4_configuration dhcp\n", stderr);
1359 return ECORE_CALLBACK_RENEW;
1363 _on_cmd_service_ipv4_configure_manual(__UNUSED__ char *cmd, char *args)
1365 char *path, *next_args, *address, *netmask = NULL, *gateway = NULL;
1366 E_Connman_Element *e;
1370 fputs("ERROR: missing the service path\n", stderr);
1371 return ECORE_CALLBACK_RENEW;
1374 next_args = _tok(args);
1377 fputs("ERROR: missing the service address\n", stderr);
1378 return ECORE_CALLBACK_RENEW;
1381 address = next_args;
1382 next_args = _tok(next_args);
1384 netmask = next_args;
1386 next_args = _tok(next_args);
1389 gateway = next_args;
1393 e = e_connman_service_get(path);
1394 if (e_connman_service_ipv4_configure_manual
1395 (e, address, netmask, gateway,
1396 _method_success_check, "service_ipv4_configure_manual"))
1397 printf(":::Service %s IPv4 Configuration set to Manual (%s/%s) gw %s\n",
1398 path, address, netmask, gateway);
1400 fputs("ERROR: can't set service ipv4_configuration manual\n", stderr);
1401 return ECORE_CALLBACK_RENEW;
1405 _on_cmd_service_get_ethernet_method(__UNUSED__ char *cmd, char *args)
1407 const char *ethernet_method, *path;
1408 E_Connman_Element *e;
1412 fputs("ERROR: missing the service path\n", stderr);
1413 return ECORE_CALLBACK_RENEW;
1418 e = e_connman_service_get(path);
1419 if (e_connman_service_ethernet_method_get(e, ðernet_method))
1420 printf(":::Service %s Ethernet Method = \"%s\"\n", path, ethernet_method);
1422 fputs("ERROR: can't get service ethernet method\n", stderr);
1423 return ECORE_CALLBACK_RENEW;
1427 _on_cmd_service_get_ethernet_address(__UNUSED__ char *cmd, char *args)
1429 const char *ethernet_address, *path;
1430 E_Connman_Element *e;
1434 fputs("ERROR: missing the service path\n", stderr);
1435 return ECORE_CALLBACK_RENEW;
1440 e = e_connman_service_get(path);
1441 if (e_connman_service_ethernet_address_get(e, ðernet_address))
1442 printf(":::Service %s Ethernet Address = \"%s\"\n",
1443 path, ethernet_address);
1445 fputs("ERROR: can't get service ethernet address\n", stderr);
1446 return ECORE_CALLBACK_RENEW;
1450 _on_cmd_service_get_ethernet_mtu(__UNUSED__ char *cmd, char *args)
1453 E_Connman_Element *e;
1454 unsigned short ethernet_mtu;
1458 fputs("ERROR: missing the service path\n", stderr);
1459 return ECORE_CALLBACK_RENEW;
1464 e = e_connman_service_get(path);
1465 if (e_connman_service_ethernet_mtu_get(e, ðernet_mtu))
1466 printf(":::Service %s Ethernet MTU = %hu\n", path, ethernet_mtu);
1468 fputs("ERROR: can't get service ethernet mtu\n", stderr);
1469 return ECORE_CALLBACK_RENEW;
1473 _on_cmd_technology_get_state(__UNUSED__ char *cmd, char *args)
1475 const char *state, *path;
1476 E_Connman_Element *e;
1480 fputs("ERROR: missing the technology path\n", stderr);
1481 return ECORE_CALLBACK_RENEW;
1486 e = e_connman_technology_get(path);
1487 if (e_connman_technology_state_get(e, &state))
1488 printf(":::Technology %s State = \"%s\"\n", path, state);
1490 fputs("ERROR: can't get technology state\n", stderr);
1491 return ECORE_CALLBACK_RENEW;
1495 _on_cmd_technology_get_type(__UNUSED__ char *cmd, char *args)
1497 const char *type, *path;
1498 E_Connman_Element *e;
1502 fputs("ERROR: missing the technology path\n", stderr);
1503 return ECORE_CALLBACK_RENEW;
1508 e = e_connman_technology_get(path);
1509 if (e_connman_technology_type_get(e, &type))
1510 printf(":::Technology %s Type = \"%s\"\n", path, type);
1512 fputs("ERROR: can't get technology type\n", stderr);
1513 return ECORE_CALLBACK_RENEW;
1517 _on_cmd_technology_get_name(__UNUSED__ char *cmd, char *args)
1519 const char *name, *path;
1520 E_Connman_Element *e;
1524 fputs("ERROR: missing the technology path\n", stderr);
1525 return ECORE_CALLBACK_RENEW;
1530 e = e_connman_technology_get(path);
1531 if (e_connman_technology_name_get(e, &name))
1532 printf(":::Technology %s Name = \"%s\"\n", path, name);
1534 fputs("ERROR: can't get technology name\n", stderr);
1535 return ECORE_CALLBACK_RENEW;
1539 _on_input(__UNUSED__ void *data, Ecore_Fd_Handler *fd_handler)
1545 Eina_Bool (*cb)(char *cmd, char *args);
1547 {"quit", _on_cmd_quit},
1548 {"sync", _on_cmd_sync},
1549 {"get_all", _on_cmd_get_all},
1550 {"print", _on_cmd_print},
1551 {"get_properties", _on_cmd_get_properties},
1552 {"set_property", _on_cmd_property_set},
1553 {"manager_get", _on_cmd_manager_get},
1554 {"manager_get_profiles", _on_cmd_manager_get_profiles},
1555 {"manager_get_services", _on_cmd_manager_get_services},
1556 {"manager_register_agent", _on_cmd_manager_register_agent},
1557 {"manager_unregister_agent", _on_cmd_manager_unregister_agent},
1558 {"manager_get_state", _on_cmd_manager_get_state},
1559 {"manager_get_offline_mode", _on_cmd_manager_get_offline_mode},
1560 {"manager_set_offline_mode", _on_cmd_manager_set_offline_mode},
1561 {"manager_request_scan", _on_cmd_manager_request_scan},
1562 {"manager_technology_enable", _on_cmd_manager_technology_enable},
1563 {"manager_technology_disable", _on_cmd_manager_technology_disable},
1564 {"manager_get_technologies_available", _on_cmd_manager_get_technologies_available},
1565 {"manager_get_technologies_enabled", _on_cmd_manager_get_technologies_enabled},
1566 {"manager_get_technologies_connected", _on_cmd_manager_get_technologies_connected},
1567 {"manager_profile_remove", _on_cmd_manager_profile_remove},
1568 {"manager_profile_get_active", _on_cmd_manager_profile_get_active},
1569 {"manager_profile_set_active", _on_cmd_manager_profile_set_active},
1570 {"profile_get_name", _on_cmd_profile_get_name},
1571 {"profile_set_name", _on_cmd_profile_set_name},
1572 {"profile_get_offline_mode", _on_cmd_profile_get_offline_mode},
1573 {"profile_set_offline_mode", _on_cmd_profile_set_offline_mode},
1574 {"profile_get_services", _on_cmd_profile_get_services},
1575 {"service_connect", _on_cmd_service_connect},
1576 {"service_disconnect", _on_cmd_service_disconnect},
1577 {"service_remove", _on_cmd_service_remove},
1578 {"service_move_before", _on_cmd_service_move_before},
1579 {"service_move_after", _on_cmd_service_move_after},
1580 {"service_get_state", _on_cmd_service_get_state},
1581 {"service_get_error", _on_cmd_service_get_error},
1582 {"service_get_name", _on_cmd_service_get_name},
1583 {"service_get_type", _on_cmd_service_get_type},
1584 {"service_get_security", _on_cmd_service_get_security},
1585 {"service_get_passphrase", _on_cmd_service_get_passphrase},
1586 {"service_set_passphrase", _on_cmd_service_set_passphrase},
1587 {"service_get_passphrase_required", _on_cmd_service_get_passphrase_required},
1588 {"service_get_strength", _on_cmd_service_get_strength},
1589 {"service_get_favorite", _on_cmd_service_get_favorite},
1590 {"service_get_immutable", _on_cmd_service_get_immutable},
1591 {"service_get_auto_connect", _on_cmd_service_get_auto_connect},
1592 {"service_set_auto_connect", _on_cmd_service_set_auto_connect},
1593 {"service_get_roaming", _on_cmd_service_get_roaming},
1594 {"service_get_ipv4_method", _on_cmd_service_get_ipv4_method},
1595 {"service_get_ipv4_address", _on_cmd_service_get_ipv4_address},
1596 {"service_get_ipv4_gateway", _on_cmd_service_get_ipv4_gateway},
1597 {"service_get_ipv4_netmask", _on_cmd_service_get_ipv4_netmask},
1598 {"service_get_ipv4_configuration_method", _on_cmd_service_get_ipv4_configuration_method},
1599 {"service_get_ipv4_configuration_address", _on_cmd_service_get_ipv4_configuration_address},
1600 {"service_get_ipv4_configuration_gateway", _on_cmd_service_get_ipv4_configuration_gateway},
1601 {"service_get_ipv4_configuration_netmask", _on_cmd_service_get_ipv4_configuration_netmask},
1602 {"service_ipv4_configure_dhcp", _on_cmd_service_ipv4_configure_dhcp},
1603 {"service_ipv4_configure_manual", _on_cmd_service_ipv4_configure_manual},
1604 {"service_get_ethernet_method", _on_cmd_service_get_ethernet_method},
1605 {"service_get_ethernet_address", _on_cmd_service_get_ethernet_address},
1606 {"service_get_ethernet_mtu", _on_cmd_service_get_ethernet_mtu},
1607 {"technology_get_state", _on_cmd_technology_get_state},
1608 {"technology_get_type", _on_cmd_technology_get_type},
1609 {"technology_get_name", _on_cmd_technology_get_name},
1614 if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR))
1616 fputs("ERROR: reading from stdin, exit\n", stderr);
1617 return ECORE_CALLBACK_CANCEL;
1620 if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
1622 fputs("ERROR: nothing to read?\n", stderr);
1623 return ECORE_CALLBACK_CANCEL;
1626 if (!fgets(buf, sizeof(buf), stdin))
1628 fprintf(stderr, "ERROR: could not read command: %s\n", strerror(errno));
1629 ecore_main_loop_quit();
1630 return ECORE_CALLBACK_CANCEL;
1634 while (isspace(*cmd))
1637 args = strchr(cmd, ' ');
1645 while (isspace(*args))
1648 p = args + strlen(args) - 1;
1656 p = cmd + strlen(cmd) - 1;
1661 if (strcmp(cmd, "help") == 0)
1665 printf("Commands with '%s' in the name:\n", args);
1666 for (itr = maps; itr->cmd; itr++)
1667 if (strstr(itr->cmd, args))
1668 printf("\t%s\n", itr->cmd);
1672 fputs("Commands:\n", stdout);
1673 for (itr = maps; itr->cmd; itr++)
1674 printf("\t%s\n", itr->cmd);
1676 fputc('\n', stdout);
1677 return ECORE_CALLBACK_RENEW;
1680 for (itr = maps; itr->cmd; itr++)
1681 if (strcmp(itr->cmd, cmd) == 0)
1682 return itr->cb(cmd, args);
1684 printf("unknown command \"%s\", args=%s\n", cmd, args);
1685 return ECORE_CALLBACK_RENEW;
1689 main(__UNUSED__ int argc, __UNUSED__ char *argv[])
1691 E_DBus_Connection *c;
1697 c = e_dbus_bus_get(DBUS_BUS_SYSTEM);
1699 printf("ERROR: can't connect to system session\n");
1703 e_connman_system_init(c);
1704 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_ADD, _on_element_add, NULL);
1705 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_DEL, _on_element_del, NULL);
1706 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_UPDATED,
1707 _on_element_updated, NULL);
1709 ecore_main_fd_handler_add
1710 (0, ECORE_FD_READ | ECORE_FD_ERROR, _on_input, NULL, NULL, NULL);
1712 ecore_main_loop_begin();
1714 e_connman_system_shutdown();
1716 e_dbus_connection_close(c);
1721 fputs("DBG: clean exit.\n", stderr);