11 #define E_CONNMAN_I_KNOW_THIS_API_IS_SUBJECT_TO_CHANGE 1
12 #include "connman0_7x/E_Connman.h"
15 _method_success_check(void *data, __UNUSED__ DBusMessage *msg, DBusError *error)
17 const char *name = data;
19 if ((!error) || (!dbus_error_is_set(error)))
21 printf("SUCCESS: method %s() finished successfully.\n", name);
25 printf("FAILURE: method %s() finished with error: %s %s\n",
26 name, error->name, error->message);
27 dbus_error_free(error);
31 _elements_print(E_Connman_Element **elements, unsigned int count)
34 for (i = 0; i < count; i++)
36 printf("--- element %d:\n", i);
37 e_connman_element_print(stdout, elements[i]);
40 printf("END: all elements count = %u\n", count);
44 _strings_print(const char **strings, unsigned int count)
47 for (i = 0; i < count; i++)
48 printf("--- strings %d: \"%s\"\n", i, strings[i]);
50 printf("END: all strings count = %u\n", count);
54 _on_element_add(__UNUSED__ void *data, __UNUSED__ int type, void *info)
56 E_Connman_Element *element = info;
57 printf(">>> %s\n", element->path);
58 return ECORE_CALLBACK_PASS_ON;
62 _on_element_del(__UNUSED__ void *data, __UNUSED__ int type, void *info)
64 E_Connman_Element *element = info;
65 printf("<<< %s\n", element->path);
66 return ECORE_CALLBACK_PASS_ON;
70 _on_element_updated(__UNUSED__ void *data, __UNUSED__ int type, void *info)
72 E_Connman_Element *element = info;
73 printf("!!! %s\n", element->path);
74 e_connman_element_print(stderr, element);
75 return ECORE_CALLBACK_PASS_ON;
79 _on_cmd_quit(__UNUSED__ char *cmd, __UNUSED__ char *args)
81 fputs("Bye!\n", stderr);
82 ecore_main_loop_quit();
83 return ECORE_CALLBACK_CANCEL;
87 _on_cmd_sync(__UNUSED__ char *cmd, __UNUSED__ char *args)
89 e_connman_manager_sync_elements();
90 return ECORE_CALLBACK_RENEW;
111 _on_cmd_get_all(__UNUSED__ char *cmd, char *args)
113 E_Connman_Element **elements;
124 ret = e_connman_elements_get_all_type(type, &count, &elements);
126 ret = e_connman_elements_get_all(&count, &elements);
129 fputs("ERROR: could not get elements\n", stderr);
132 printf("BEG: all elements type=%s count = %d\n", type, count);
133 _elements_print(elements, count);
136 return ECORE_CALLBACK_RENEW;
139 static E_Connman_Element *
140 _element_from_args(char *args, char **next_args)
142 E_Connman_Element *element;
146 fputs("ERROR: missing element path\n", stderr);
151 *next_args = _tok(args);
152 element = e_connman_element_get(args);
154 fprintf(stderr, "ERROR: no element called \"%s\".\n", args);
160 _on_cmd_print(__UNUSED__ char *cmd, char *args)
163 E_Connman_Element *element = _element_from_args(args, &next_args);
165 e_connman_element_print(stdout, element);
166 return ECORE_CALLBACK_RENEW;
170 _on_cmd_get_properties(__UNUSED__ char *cmd, char *args)
173 E_Connman_Element *element = _element_from_args(args, &next_args);
175 e_connman_element_properties_sync(element);
176 return ECORE_CALLBACK_RENEW;
180 _on_cmd_property_set(__UNUSED__ char *cmd, char *args)
182 char *next_args, *name, *p;
183 E_Connman_Element *element = _element_from_args(args, &next_args);
191 return ECORE_CALLBACK_RENEW;
195 fputs("ERROR: missing parameters name, type and value.\n", stderr);
196 return ECORE_CALLBACK_RENEW;
203 fputs("ERROR: missing parameters type and value.\n", stderr);
204 return ECORE_CALLBACK_RENEW;
210 fputs("ERROR: missing parameter value.\n", stderr);
211 return ECORE_CALLBACK_RENEW;
217 case DBUS_TYPE_BOOLEAN:
218 vlong = !!atol(next_args);
220 fprintf(stderr, "DBG: boolean is: %ld\n", vlong);
222 case DBUS_TYPE_UINT16:
223 vu16 = strtol(next_args, &p, 0);
226 fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
227 return ECORE_CALLBACK_RENEW;
230 fprintf(stderr, "DBG: u16 is: %hu\n", vu16);
232 case DBUS_TYPE_UINT32:
233 vu32 = strtol(next_args, &p, 0);
236 fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
237 return ECORE_CALLBACK_RENEW;
240 fprintf(stderr, "DBG: u16 is: %u\n", vu32);
242 case DBUS_TYPE_STRING:
243 case DBUS_TYPE_OBJECT_PATH:
244 p = next_args + strlen(next_args);
247 while (p > next_args && isspace(*p))
251 fprintf(stderr, "ERROR: invalid string \"%s\".\n", next_args);
255 fprintf(stderr, "DBG: string is: \"%s\"\n", next_args);
258 fprintf(stderr, "ERROR: don't know how to parse type '%c' (%d)\n",
260 return ECORE_CALLBACK_RENEW;
263 fprintf(stderr, "set_property %s [%p] %s %c %p...\n",
264 args, element, name, type, value);
265 if (!e_connman_element_property_set(element, name, type, value))
266 fputs("ERROR: error setting property.\n", stderr);
268 return ECORE_CALLBACK_RENEW;
272 /* Manager Commands */
275 _on_cmd_manager_get(__UNUSED__ char *cmd, __UNUSED__ char *args)
277 E_Connman_Element *element;
278 element = e_connman_manager_get();
279 e_connman_element_print(stderr, element);
280 return ECORE_CALLBACK_RENEW;
284 _on_cmd_manager_get_profiles(__UNUSED__ char *cmd, __UNUSED__ char *args)
287 E_Connman_Element **profiles;
289 if (!e_connman_manager_profiles_get(&count, &profiles))
291 fputs("ERROR: can't get profiles\n", stderr);
292 return ECORE_CALLBACK_RENEW;
294 printf("BEG: all manager profiles elements count = %d\n", count);
295 _elements_print(profiles, count);
296 return ECORE_CALLBACK_RENEW;
300 _on_cmd_manager_get_services(__UNUSED__ char *cmd, __UNUSED__ char *args)
303 E_Connman_Element **services;
305 if (!e_connman_manager_services_get(&count, &services))
307 fputs("ERROR: can't get services\n", stderr);
308 return ECORE_CALLBACK_RENEW;
310 printf("BEG: all manager services elements count = %d\n", count);
311 _elements_print(services, count);
312 return ECORE_CALLBACK_RENEW;
316 _on_cmd_manager_register_agent(__UNUSED__ char *cmd, char *args)
322 fputs("ERROR: missing the object path\n", stderr);
323 return ECORE_CALLBACK_RENEW;
327 if (e_connman_manager_agent_register
328 (path, _method_success_check, "manager_register_agent"))
329 printf(":::Registering agent %s...\n", path);
331 fprintf(stderr, "ERROR: can't register agent %s\n", path);
333 return ECORE_CALLBACK_RENEW;
337 _on_cmd_manager_unregister_agent(__UNUSED__ char *cmd, char *args)
343 fputs("ERROR: missing the object path\n", stderr);
344 return ECORE_CALLBACK_RENEW;
348 if (e_connman_manager_agent_unregister
349 (path, _method_success_check, "manager_unregister_agent"))
350 printf(":::Unregistering agent %s...\n", path);
352 fprintf(stderr, "ERROR: can't unregister agent %s\n", path);
354 return ECORE_CALLBACK_RENEW;
358 _on_cmd_manager_get_state(__UNUSED__ char *cmd, __UNUSED__ char *args)
361 if (e_connman_manager_state_get(&state))
362 printf(":::Manager state = \"%s\"\n", state);
364 fputs("ERROR: can't get manager state\n", stderr);
365 return ECORE_CALLBACK_RENEW;
369 _on_cmd_manager_get_offline_mode(__UNUSED__ char *cmd, __UNUSED__ char *args)
372 if (e_connman_manager_offline_mode_get(&offline))
373 printf(":::Manager Offline Mode = %hhu\n", offline);
375 fputs("ERROR: can't get manager offline mode\n", stderr);
376 return ECORE_CALLBACK_RENEW;
380 _on_cmd_manager_set_offline_mode(__UNUSED__ char *cmd, char *args)
385 fputs("ERROR: missing the offline mode value\n", stderr);
386 return ECORE_CALLBACK_RENEW;
389 offline = !!atol(args);
390 if (e_connman_manager_offline_mode_set
391 (offline, _method_success_check, "manager_set_offline_mode"))
393 printf(":::Manager Offline Mode set to %hhu\n", offline);
395 fputs("ERROR: can't set manager offline mode\n", stderr);
396 return ECORE_CALLBACK_RENEW;
400 _on_cmd_manager_request_scan(__UNUSED__ char *cmd, char *args)
408 if (e_connman_manager_request_scan
409 (args, _method_success_check, "manager_request_scan"))
410 printf(":::Manager Request Scan for %s\n", args[0] ? args : "<all>");
412 fputs("ERROR: can't request scan on manager\n", stderr);
413 return ECORE_CALLBACK_RENEW;
417 _on_cmd_manager_technology_enable(__UNUSED__ char *cmd, char *args)
421 fputs("ERROR: missing the technology type\n", stderr);
422 return ECORE_CALLBACK_RENEW;
426 if (e_connman_manager_technology_enable
427 (args, _method_success_check, "manager_technology_enable"))
428 printf(":::Manager Enable Technology %s\n", args);
430 fputs("ERROR: can't enable technology on manager\n", stderr);
431 return ECORE_CALLBACK_RENEW;
435 _on_cmd_manager_technology_disable(__UNUSED__ char *cmd, char *args)
439 fputs("ERROR: missing the technology type\n", stderr);
440 return ECORE_CALLBACK_RENEW;
444 if (e_connman_manager_technology_disable
445 (args, _method_success_check, "manager_technology_disable"))
446 printf(":::Manager Disable Technology %s\n", args);
448 fputs("ERROR: can't disable technology on manager\n", stderr);
449 return ECORE_CALLBACK_RENEW;
453 _on_cmd_manager_get_technologies_available(__UNUSED__ char *cmd, __UNUSED__ char *args)
455 const char **strings;
458 if (!e_connman_manager_technologies_available_get(&count, &strings))
459 fputs("ERROR: can't get available technologies\n", stderr);
462 printf("BEG: available technologies count = %u\n", count);
463 _strings_print(strings, count);
466 return ECORE_CALLBACK_RENEW;
470 _on_cmd_manager_get_technologies_enabled(__UNUSED__ char *cmd, __UNUSED__ char *args)
472 const char **strings;
475 if (!e_connman_manager_technologies_enabled_get(&count, &strings))
476 fputs("ERROR: can't get enabled technologies\n", stderr);
479 printf("BEG: enabled technologies count = %u\n", count);
480 _strings_print(strings, count);
483 return ECORE_CALLBACK_RENEW;
487 _on_cmd_manager_get_technologies_connected(__UNUSED__ char *cmd, __UNUSED__ char *args)
489 const char **strings;
492 if (!e_connman_manager_technologies_connected_get(&count, &strings))
493 fputs("ERROR: can't get connected technologies\n", stderr);
496 printf("BEG: connected technologies count = %u\n", count);
497 _strings_print(strings, count);
500 return ECORE_CALLBACK_RENEW;
504 _on_cmd_manager_profile_remove(__UNUSED__ char *cmd, char *args)
506 E_Connman_Element *e;
510 fputs("ERROR: missing the profile path\n", stderr);
511 return ECORE_CALLBACK_RENEW;
515 e = e_connman_profile_get(args);
516 if (e_connman_manager_profile_remove
517 (e, _method_success_check, "manager_profile_remove"))
518 printf(":::Manager Remove Profile %s\n", args);
520 fputs("ERROR: can't remove profile from manager\n", stderr);
521 return ECORE_CALLBACK_RENEW;
525 _on_cmd_manager_profile_get_active(__UNUSED__ char *cmd, __UNUSED__ char *args)
527 E_Connman_Element *e;
529 if (!e_connman_manager_profile_active_get(&e))
530 fputs("ERROR: can't active_get profile from manager\n", stderr);
532 e_connman_element_print(stderr, e);
533 return ECORE_CALLBACK_RENEW;
537 _on_cmd_manager_profile_set_active(__UNUSED__ char *cmd, char *args)
539 E_Connman_Element *e;
543 fputs("ERROR: missing the profile path\n", stderr);
544 return ECORE_CALLBACK_RENEW;
548 e = e_connman_profile_get(args);
549 if (e_connman_manager_profile_active_set
550 (e, _method_success_check, "manager_profile_set_active"))
551 printf(":::Manager Active Profile set to %s\n", args);
553 fputs("ERROR: can't set active profile\n", stderr);
554 return ECORE_CALLBACK_RENEW;
557 /* Profile Commands */
560 _on_cmd_profile_get_name(__UNUSED__ char *cmd, char *args)
562 const char *name, *path;
563 E_Connman_Element *e;
567 fputs("ERROR: missing the profile path\n", stderr);
568 return ECORE_CALLBACK_RENEW;
573 e = e_connman_profile_get(path);
574 if (e_connman_profile_name_get(e, &name))
575 printf(":::Profile %s Name = \"%s\"\n", path, name);
577 fputs("ERROR: can't get profile name\n", stderr);
578 return ECORE_CALLBACK_RENEW;
582 _on_cmd_profile_set_name(__UNUSED__ char *cmd, char *args)
584 char *path, *next_args;
585 E_Connman_Element *e;
589 fputs("ERROR: missing the profile path\n", stderr);
590 return ECORE_CALLBACK_RENEW;
593 next_args = _tok(args);
596 fputs("ERROR: missing the offline mode value\n", stderr);
597 return ECORE_CALLBACK_RENEW;
601 e = e_connman_profile_get(path);
602 if (e_connman_profile_name_set
603 (e, next_args, _method_success_check, "profile_set_name"))
604 printf(":::Profile %s Name set to %s\n", path, next_args);
606 fputs("ERROR: can't set profile name\n", stderr);
607 return ECORE_CALLBACK_RENEW;
611 _on_cmd_profile_get_offline_mode(__UNUSED__ char *cmd, char *args)
615 E_Connman_Element *e;
619 fputs("ERROR: missing the profile path\n", stderr);
620 return ECORE_CALLBACK_RENEW;
625 e = e_connman_profile_get(path);
626 if (e_connman_profile_offline_mode_get(e, &offline))
627 printf(":::Profile %s Offline Mode = %hhu\n", path, offline);
629 fputs("ERROR: can't get profile offline mode\n", stderr);
630 return ECORE_CALLBACK_RENEW;
634 _on_cmd_profile_set_offline_mode(__UNUSED__ char *cmd, char *args)
636 char *path, *next_args;
638 E_Connman_Element *e;
642 fputs("ERROR: missing the profile path\n", stderr);
643 return ECORE_CALLBACK_RENEW;
646 next_args = _tok(args);
649 fputs("ERROR: missing the offline mode value\n", stderr);
650 return ECORE_CALLBACK_RENEW;
653 offline = !!atol(next_args);
655 e = e_connman_profile_get(path);
656 if (e_connman_profile_offline_mode_set
657 (e, offline, _method_success_check, "profile_set_offline_mode"))
658 printf(":::Profile %s Offline Mode set to %hhu\n", path, offline);
660 fputs("ERROR: can't set profile offline mode\n", stderr);
661 return ECORE_CALLBACK_RENEW;
665 _on_cmd_profile_get_services(__UNUSED__ char *cmd, char *args)
667 E_Connman_Element **services;
668 E_Connman_Element *e;
674 fputs("ERROR: missing the profile path\n", stderr);
675 return ECORE_CALLBACK_RENEW;
680 e = e_connman_profile_get(path);
681 if (!e_connman_profile_services_get(e, &count, &services))
683 fputs("ERROR: can't get services\n", stderr);
684 return ECORE_CALLBACK_RENEW;
686 printf("BEG: all profile services count = %d\n", count);
687 _elements_print(services, count);
688 return ECORE_CALLBACK_RENEW;
692 /* Services Commands */
694 _on_cmd_service_connect(__UNUSED__ char *cmd, char *args)
697 E_Connman_Element *e;
701 fputs("ERROR: missing the service path\n", stderr);
702 return ECORE_CALLBACK_RENEW;
707 e = e_connman_service_get(path);
708 if (e_connman_service_connect
709 (e, _method_success_check, "service_connect"))
710 printf(":::Connecting to Service %s...\n", path);
712 fputs("ERROR: can't connect to service\n", stderr);
713 return ECORE_CALLBACK_RENEW;
717 _on_cmd_service_disconnect(__UNUSED__ char *cmd, char *args)
720 E_Connman_Element *e;
724 fputs("ERROR: missing the service path\n", stderr);
725 return ECORE_CALLBACK_RENEW;
730 e = e_connman_service_get(path);
731 if (e_connman_service_disconnect
732 (e, _method_success_check, "service_disconnect"))
733 printf(":::Disconnecting Service %s...\n", path);
735 fputs("ERROR: can't disconnect service\n", stderr);
736 return ECORE_CALLBACK_RENEW;
740 _on_cmd_service_remove(__UNUSED__ char *cmd, char *args)
743 E_Connman_Element *e;
747 fputs("ERROR: missing the service path\n", stderr);
748 return ECORE_CALLBACK_RENEW;
753 e = e_connman_service_get(path);
754 if (e_connman_service_remove
755 (e, _method_success_check, "service_remove"))
756 printf(":::Removing Service %s...\n", path);
758 fputs("ERROR: can't remove service\n", stderr);
759 return ECORE_CALLBACK_RENEW;
763 _on_cmd_service_move_before(__UNUSED__ char *cmd, char *args)
765 char *path, *service_path;
766 E_Connman_Element *e;
770 fputs("ERROR: missing the service path\n", stderr);
771 return ECORE_CALLBACK_RENEW;
778 fputs("ERROR: missing the object service\n", stderr);
779 return ECORE_CALLBACK_RENEW;
783 e = e_connman_service_get(service_path);
784 if (e_connman_service_move_before
785 (e, path, _method_success_check, "service_move_before"))
786 printf(":::Moving before %s...\n", path);
788 fputs("ERROR: can't move before\n", stderr);
789 return ECORE_CALLBACK_RENEW;
793 _on_cmd_service_move_after(__UNUSED__ char *cmd, char *args)
795 char *path, *service_path;
796 E_Connman_Element *e;
800 fputs("ERROR: missing the service path\n", stderr);
801 return ECORE_CALLBACK_RENEW;
808 fputs("ERROR: missing the object service\n", stderr);
809 return ECORE_CALLBACK_RENEW;
813 e = e_connman_service_get(service_path);
814 if (e_connman_service_move_after
815 (e, path, _method_success_check, "service_move_after"))
816 printf(":::Moving after %s...\n", path);
818 fputs("ERROR: can't move after\n", stderr);
819 return ECORE_CALLBACK_RENEW;
823 _on_cmd_service_get_state(__UNUSED__ char *cmd, char *args)
825 const char *state, *path;
826 E_Connman_Element *e;
830 fputs("ERROR: missing the service path\n", stderr);
831 return ECORE_CALLBACK_RENEW;
836 e = e_connman_service_get(path);
837 if (e_connman_service_state_get(e, &state))
838 printf(":::Service %s State = \"%s\"\n", path, state);
840 fputs("ERROR: can't get service state\n", stderr);
841 return ECORE_CALLBACK_RENEW;
845 _on_cmd_service_get_error(__UNUSED__ char *cmd, char *args)
847 const char *error, *path;
848 E_Connman_Element *e;
852 fputs("ERROR: missing the service path\n", stderr);
853 return ECORE_CALLBACK_RENEW;
858 e = e_connman_service_get(path);
859 if (e_connman_service_error_get(e, &error))
860 printf(":::Service %s Error = \"%s\"\n", path, error);
862 fputs("ERROR: can't get service error\n", stderr);
863 return ECORE_CALLBACK_RENEW;
867 _on_cmd_service_get_name(__UNUSED__ char *cmd, char *args)
869 const char *name, *path;
870 E_Connman_Element *e;
874 fputs("ERROR: missing the service path\n", stderr);
875 return ECORE_CALLBACK_RENEW;
880 e = e_connman_service_get(path);
881 if (e_connman_service_name_get(e, &name))
882 printf(":::Service %s Name = \"%s\"\n", path, name);
884 fputs("ERROR: can't get service name\n", stderr);
885 return ECORE_CALLBACK_RENEW;
889 _on_cmd_service_get_type(__UNUSED__ char *cmd, char *args)
891 const char *type, *path;
892 E_Connman_Element *e;
896 fputs("ERROR: missing the service path\n", stderr);
897 return ECORE_CALLBACK_RENEW;
902 e = e_connman_service_get(path);
903 if (e_connman_service_type_get(e, &type))
904 printf(":::Service %s Type = \"%s\"\n", path, type);
906 fputs("ERROR: can't get service type\n", stderr);
907 return ECORE_CALLBACK_RENEW;
911 _on_cmd_service_get_security(__UNUSED__ char *cmd, char *args)
914 const char **security;
916 E_Connman_Element *e;
920 fputs("ERROR: missing the service path\n", stderr);
921 return ECORE_CALLBACK_RENEW;
926 e = e_connman_service_get(path);
927 if (e_connman_service_security_get(e, &count, &security))
930 for (i = 0; i < count; i++)
931 printf("\"%s\", ", security[i]);
935 fputs("ERROR: can't get service security\n", stderr);
936 return ECORE_CALLBACK_RENEW;
940 _on_cmd_service_get_passphrase(__UNUSED__ char *cmd, char *args)
942 const char *passphrase, *path;
943 E_Connman_Element *e;
947 fputs("ERROR: missing the service path\n", stderr);
948 return ECORE_CALLBACK_RENEW;
953 e = e_connman_service_get(path);
954 if (e_connman_service_passphrase_get(e, &passphrase))
955 printf(":::Service %s Passphrase = \"%s\"\n", path, passphrase);
957 fputs("ERROR: can't get service passphrase\n", stderr);
958 return ECORE_CALLBACK_RENEW;
962 _on_cmd_service_set_passphrase(__UNUSED__ char *cmd, char *args)
964 char *passphrase, *path;
965 E_Connman_Element *e;
969 fputs("ERROR: missing the service path\n", stderr);
970 return ECORE_CALLBACK_RENEW;
973 passphrase = _tok(args);
977 fputs("ERROR: missing the passphrase value\n", stderr);
978 return ECORE_CALLBACK_RENEW;
982 e = e_connman_service_get(path);
983 if (e_connman_service_passphrase_set
984 (e, passphrase, _method_success_check, "service_set_passphrase"))
985 printf(":::Service %s passphrase set to \"%s\"\n", path, passphrase);
987 fputs("ERROR: can't set service passphrase\n", stderr);
988 return ECORE_CALLBACK_RENEW;
992 _on_cmd_service_get_passphrase_required(__UNUSED__ char *cmd, char *args)
995 Eina_Bool passphrase;
996 E_Connman_Element *e;
1000 fputs("ERROR: missing the service path\n", stderr);
1001 return ECORE_CALLBACK_RENEW;
1006 e = e_connman_service_get(path);
1007 if (e_connman_service_passphrase_required_get(e, &passphrase))
1008 printf(":::Service %s Passphrase Required = %hhu\n", path, passphrase);
1010 fputs("ERROR: can't get service passphrase required\n", stderr);
1011 return ECORE_CALLBACK_RENEW;
1015 _on_cmd_service_get_strength(__UNUSED__ char *cmd, char *args)
1018 unsigned char strength;
1019 E_Connman_Element *e;
1023 fputs("ERROR: missing the service path\n", stderr);
1024 return ECORE_CALLBACK_RENEW;
1029 e = e_connman_service_get(path);
1030 if (e_connman_service_strength_get(e, &strength))
1031 printf(":::Service %s Strength = %#02hhx (%d)\n", path, strength, strength);
1033 fputs("ERROR: can't get service strength\n", stderr);
1034 return ECORE_CALLBACK_RENEW;
1038 _on_cmd_service_get_favorite(__UNUSED__ char *cmd, char *args)
1042 E_Connman_Element *e;
1046 fputs("ERROR: missing the service path\n", stderr);
1047 return ECORE_CALLBACK_RENEW;
1052 e = e_connman_service_get(path);
1053 if (e_connman_service_favorite_get(e, &favorite))
1054 printf(":::Service %s Favorite = %hhu\n", path, favorite);
1056 fputs("ERROR: can't get service favorite\n", stderr);
1057 return ECORE_CALLBACK_RENEW;
1061 _on_cmd_service_get_immutable(__UNUSED__ char *cmd, char *args)
1064 Eina_Bool immutable;
1065 E_Connman_Element *e;
1069 fputs("ERROR: missing the service path\n", stderr);
1070 return ECORE_CALLBACK_RENEW;
1075 e = e_connman_service_get(path);
1076 if (e_connman_service_immutable_get(e, &immutable))
1077 printf(":::Service %s Immutable = %hhu\n", path, immutable);
1079 fputs("ERROR: can't get service immutable\n", stderr);
1080 return ECORE_CALLBACK_RENEW;
1084 _on_cmd_service_get_auto_connect(__UNUSED__ char *cmd, char *args)
1087 Eina_Bool auto_connect;
1088 E_Connman_Element *e;
1092 fputs("ERROR: missing the service path\n", stderr);
1093 return ECORE_CALLBACK_RENEW;
1098 e = e_connman_service_get(path);
1099 if (e_connman_service_auto_connect_get(e, &auto_connect))
1100 printf(":::Service %s Auto Connect = %hhu\n", path, auto_connect);
1102 fputs("ERROR: can't get service auto connect\n", stderr);
1103 return ECORE_CALLBACK_RENEW;
1107 _on_cmd_service_set_auto_connect(__UNUSED__ char *cmd, char *args)
1109 char *path, *next_args;
1110 Eina_Bool auto_connect;
1111 E_Connman_Element *e;
1115 fputs("ERROR: missing the service path\n", stderr);
1116 return ECORE_CALLBACK_RENEW;
1119 next_args = _tok(args);
1123 fputs("ERROR: missing the auto connect value\n", stderr);
1124 return ECORE_CALLBACK_RENEW;
1127 auto_connect = !!atol(next_args);
1129 e = e_connman_service_get(path);
1130 if (e_connman_service_auto_connect_set
1131 (e, auto_connect, _method_success_check, "service_set_auto_connect"))
1132 printf(":::Service %s auto connect set to %d\n", path, auto_connect);
1134 fputs("ERROR: can't set service auto connect\n", stderr);
1135 return ECORE_CALLBACK_RENEW;
1139 _on_cmd_service_get_roaming(__UNUSED__ char *cmd, char *args)
1143 E_Connman_Element *e;
1147 fputs("ERROR: missing the service path\n", stderr);
1148 return ECORE_CALLBACK_RENEW;
1153 e = e_connman_service_get(path);
1154 if (e_connman_service_roaming_get(e, &roaming))
1155 printf(":::Service %s Roaming = %hhu\n", path, roaming);
1157 fputs("ERROR: can't get service roaming\n", stderr);
1158 return ECORE_CALLBACK_RENEW;
1162 _on_cmd_service_get_ipv4_method(__UNUSED__ char *cmd, char *args)
1164 const char *ipv4_method, *path;
1165 E_Connman_Element *e;
1169 fputs("ERROR: missing the service path\n", stderr);
1170 return ECORE_CALLBACK_RENEW;
1175 e = e_connman_service_get(path);
1176 if (e_connman_service_ipv4_method_get(e, &ipv4_method))
1177 printf(":::Service %s IPv4 Method = \"%s\"\n", path, ipv4_method);
1179 fputs("ERROR: can't get service ipv4 method\n", stderr);
1180 return ECORE_CALLBACK_RENEW;
1184 _on_cmd_service_get_ipv4_address(__UNUSED__ char *cmd, char *args)
1186 const char *ipv4_address, *path;
1187 E_Connman_Element *e;
1191 fputs("ERROR: missing the service path\n", stderr);
1192 return ECORE_CALLBACK_RENEW;
1197 e = e_connman_service_get(path);
1198 if (e_connman_service_ipv4_address_get(e, &ipv4_address))
1199 printf(":::Service %s IPv4 Address = \"%s\"\n", path, ipv4_address);
1201 fputs("ERROR: can't get service ipv4 address\n", stderr);
1202 return ECORE_CALLBACK_RENEW;
1206 _on_cmd_service_get_ipv4_gateway(__UNUSED__ char *cmd, char *args)
1208 const char *ipv4_gateway, *path;
1209 E_Connman_Element *e;
1213 fputs("ERROR: missing the service path\n", stderr);
1214 return ECORE_CALLBACK_RENEW;
1219 e = e_connman_service_get(path);
1220 if (e_connman_service_ipv4_gateway_get(e, &ipv4_gateway))
1221 printf(":::Service %s IPv4 Gateway = \"%s\"\n", path, ipv4_gateway);
1223 fputs("ERROR: can't get service ipv4 gateway\n", stderr);
1224 return ECORE_CALLBACK_RENEW;
1228 _on_cmd_service_get_ipv4_netmask(__UNUSED__ char *cmd, char *args)
1230 const char *ipv4_netmask, *path;
1231 E_Connman_Element *e;
1235 fputs("ERROR: missing the service path\n", stderr);
1236 return ECORE_CALLBACK_RENEW;
1241 e = e_connman_service_get(path);
1242 if (e_connman_service_ipv4_netmask_get(e, &ipv4_netmask))
1243 printf(":::Service %s IPv4 Netmask = \"%s\"\n", path, ipv4_netmask);
1245 fputs("ERROR: can't get service ipv4 netmask\n", stderr);
1246 return ECORE_CALLBACK_RENEW;
1250 _on_cmd_service_get_ipv4_configuration_method(__UNUSED__ char *cmd, char *args)
1252 const char *ipv4_method, *path;
1253 E_Connman_Element *e;
1257 fputs("ERROR: missing the service path\n", stderr);
1258 return ECORE_CALLBACK_RENEW;
1263 e = e_connman_service_get(path);
1264 if (e_connman_service_ipv4_configuration_method_get(e, &ipv4_method))
1265 printf(":::Service %s IPv4 Configuration Method = \"%s\"\n",
1268 fputs("ERROR: can't get service ipv4_configuration method\n", stderr);
1269 return ECORE_CALLBACK_RENEW;
1273 _on_cmd_service_get_ipv4_configuration_address(__UNUSED__ char *cmd, char *args)
1275 const char *ipv4_address, *path;
1276 E_Connman_Element *e;
1280 fputs("ERROR: missing the service path\n", stderr);
1281 return ECORE_CALLBACK_RENEW;
1286 e = e_connman_service_get(path);
1287 if (e_connman_service_ipv4_configuration_address_get(e, &ipv4_address))
1288 printf(":::Service %s IPv4 Configuration Address = \"%s\"\n",
1289 path, ipv4_address);
1291 fputs("ERROR: can't get service ipv4_configuration address\n", stderr);
1292 return ECORE_CALLBACK_RENEW;
1296 _on_cmd_service_get_ipv4_configuration_gateway(__UNUSED__ char *cmd, char *args)
1298 const char *ipv4_gateway, *path;
1299 E_Connman_Element *e;
1303 fputs("ERROR: missing the service path\n", stderr);
1304 return ECORE_CALLBACK_RENEW;
1309 e = e_connman_service_get(path);
1310 if (e_connman_service_ipv4_configuration_gateway_get(e, &ipv4_gateway))
1311 printf(":::Service %s IPv4 Configuration Gateway = \"%s\"\n",
1312 path, ipv4_gateway);
1314 fputs("ERROR: can't get service ipv4_configuration gateway\n", stderr);
1315 return ECORE_CALLBACK_RENEW;
1319 _on_cmd_service_get_ipv4_configuration_netmask(__UNUSED__ char *cmd, char *args)
1321 const char *ipv4_netmask, *path;
1322 E_Connman_Element *e;
1326 fputs("ERROR: missing the service path\n", stderr);
1327 return ECORE_CALLBACK_RENEW;
1332 e = e_connman_service_get(path);
1333 if (e_connman_service_ipv4_configuration_netmask_get(e, &ipv4_netmask))
1334 printf(":::Service %s IPv4 Configuration Netmask = \"%s\"\n",
1335 path, ipv4_netmask);
1337 fputs("ERROR: can't get service ipv4 configuration netmask\n", stderr);
1338 return ECORE_CALLBACK_RENEW;
1342 _on_cmd_service_ipv4_configure_dhcp(__UNUSED__ char *cmd, char *args)
1345 E_Connman_Element *e;
1349 fputs("ERROR: missing the service path\n", stderr);
1350 return ECORE_CALLBACK_RENEW;
1355 e = e_connman_service_get(path);
1356 if (e_connman_service_ipv4_configure_dhcp
1357 (e, _method_success_check, "service_ipv4_configure_dhcp"))
1358 printf(":::Service %s IPv4 Configuration set to DHCP\n", path);
1360 fputs("ERROR: can't set service ipv4_configuration dhcp\n", stderr);
1361 return ECORE_CALLBACK_RENEW;
1365 _on_cmd_service_ipv4_configure_manual(__UNUSED__ char *cmd, char *args)
1367 char *path, *next_args, *address, *netmask = NULL, *gateway = NULL;
1368 E_Connman_Element *e;
1372 fputs("ERROR: missing the service path\n", stderr);
1373 return ECORE_CALLBACK_RENEW;
1376 next_args = _tok(args);
1379 fputs("ERROR: missing the service address\n", stderr);
1380 return ECORE_CALLBACK_RENEW;
1383 address = next_args;
1384 next_args = _tok(next_args);
1386 netmask = next_args;
1388 next_args = _tok(next_args);
1391 gateway = next_args;
1395 e = e_connman_service_get(path);
1396 if (e_connman_service_ipv4_configure_manual
1397 (e, address, netmask, gateway,
1398 _method_success_check, "service_ipv4_configure_manual"))
1399 printf(":::Service %s IPv4 Configuration set to Manual (%s/%s) gw %s\n",
1400 path, address, netmask, gateway);
1402 fputs("ERROR: can't set service ipv4_configuration manual\n", stderr);
1403 return ECORE_CALLBACK_RENEW;
1407 _on_cmd_service_get_ethernet_method(__UNUSED__ char *cmd, char *args)
1409 const char *ethernet_method, *path;
1410 E_Connman_Element *e;
1414 fputs("ERROR: missing the service path\n", stderr);
1415 return ECORE_CALLBACK_RENEW;
1420 e = e_connman_service_get(path);
1421 if (e_connman_service_ethernet_method_get(e, ðernet_method))
1422 printf(":::Service %s Ethernet Method = \"%s\"\n", path, ethernet_method);
1424 fputs("ERROR: can't get service ethernet method\n", stderr);
1425 return ECORE_CALLBACK_RENEW;
1429 _on_cmd_service_get_ethernet_address(__UNUSED__ char *cmd, char *args)
1431 const char *ethernet_address, *path;
1432 E_Connman_Element *e;
1436 fputs("ERROR: missing the service path\n", stderr);
1437 return ECORE_CALLBACK_RENEW;
1442 e = e_connman_service_get(path);
1443 if (e_connman_service_ethernet_address_get(e, ðernet_address))
1444 printf(":::Service %s Ethernet Address = \"%s\"\n",
1445 path, ethernet_address);
1447 fputs("ERROR: can't get service ethernet address\n", stderr);
1448 return ECORE_CALLBACK_RENEW;
1452 _on_cmd_service_get_ethernet_mtu(__UNUSED__ char *cmd, char *args)
1455 E_Connman_Element *e;
1456 unsigned short ethernet_mtu;
1460 fputs("ERROR: missing the service path\n", stderr);
1461 return ECORE_CALLBACK_RENEW;
1466 e = e_connman_service_get(path);
1467 if (e_connman_service_ethernet_mtu_get(e, ðernet_mtu))
1468 printf(":::Service %s Ethernet MTU = %hu\n", path, ethernet_mtu);
1470 fputs("ERROR: can't get service ethernet mtu\n", stderr);
1471 return ECORE_CALLBACK_RENEW;
1475 _on_cmd_technology_get_state(__UNUSED__ char *cmd, char *args)
1477 const char *state, *path;
1478 E_Connman_Element *e;
1482 fputs("ERROR: missing the technology path\n", stderr);
1483 return ECORE_CALLBACK_RENEW;
1488 e = e_connman_technology_get(path);
1489 if (e_connman_technology_state_get(e, &state))
1490 printf(":::Technology %s State = \"%s\"\n", path, state);
1492 fputs("ERROR: can't get technology state\n", stderr);
1493 return ECORE_CALLBACK_RENEW;
1497 _on_cmd_technology_get_type(__UNUSED__ char *cmd, char *args)
1499 const char *type, *path;
1500 E_Connman_Element *e;
1504 fputs("ERROR: missing the technology path\n", stderr);
1505 return ECORE_CALLBACK_RENEW;
1510 e = e_connman_technology_get(path);
1511 if (e_connman_technology_type_get(e, &type))
1512 printf(":::Technology %s Type = \"%s\"\n", path, type);
1514 fputs("ERROR: can't get technology type\n", stderr);
1515 return ECORE_CALLBACK_RENEW;
1519 _on_cmd_technology_get_name(__UNUSED__ char *cmd, char *args)
1521 const char *name, *path;
1522 E_Connman_Element *e;
1526 fputs("ERROR: missing the technology path\n", stderr);
1527 return ECORE_CALLBACK_RENEW;
1532 e = e_connman_technology_get(path);
1533 if (e_connman_technology_name_get(e, &name))
1534 printf(":::Technology %s Name = \"%s\"\n", path, name);
1536 fputs("ERROR: can't get technology name\n", stderr);
1537 return ECORE_CALLBACK_RENEW;
1541 _on_input(__UNUSED__ void *data, Ecore_Fd_Handler *fd_handler)
1547 Eina_Bool (*cb)(char *cmd, char *args);
1549 {"quit", _on_cmd_quit},
1550 {"sync", _on_cmd_sync},
1551 {"get_all", _on_cmd_get_all},
1552 {"print", _on_cmd_print},
1553 {"get_properties", _on_cmd_get_properties},
1554 {"set_property", _on_cmd_property_set},
1555 {"manager_get", _on_cmd_manager_get},
1556 {"manager_get_profiles", _on_cmd_manager_get_profiles},
1557 {"manager_get_services", _on_cmd_manager_get_services},
1558 {"manager_register_agent", _on_cmd_manager_register_agent},
1559 {"manager_unregister_agent", _on_cmd_manager_unregister_agent},
1560 {"manager_get_state", _on_cmd_manager_get_state},
1561 {"manager_get_offline_mode", _on_cmd_manager_get_offline_mode},
1562 {"manager_set_offline_mode", _on_cmd_manager_set_offline_mode},
1563 {"manager_request_scan", _on_cmd_manager_request_scan},
1564 {"manager_technology_enable", _on_cmd_manager_technology_enable},
1565 {"manager_technology_disable", _on_cmd_manager_technology_disable},
1566 {"manager_get_technologies_available", _on_cmd_manager_get_technologies_available},
1567 {"manager_get_technologies_enabled", _on_cmd_manager_get_technologies_enabled},
1568 {"manager_get_technologies_connected", _on_cmd_manager_get_technologies_connected},
1569 {"manager_profile_remove", _on_cmd_manager_profile_remove},
1570 {"manager_profile_get_active", _on_cmd_manager_profile_get_active},
1571 {"manager_profile_set_active", _on_cmd_manager_profile_set_active},
1572 {"profile_get_name", _on_cmd_profile_get_name},
1573 {"profile_set_name", _on_cmd_profile_set_name},
1574 {"profile_get_offline_mode", _on_cmd_profile_get_offline_mode},
1575 {"profile_set_offline_mode", _on_cmd_profile_set_offline_mode},
1576 {"profile_get_services", _on_cmd_profile_get_services},
1577 {"service_connect", _on_cmd_service_connect},
1578 {"service_disconnect", _on_cmd_service_disconnect},
1579 {"service_remove", _on_cmd_service_remove},
1580 {"service_move_before", _on_cmd_service_move_before},
1581 {"service_move_after", _on_cmd_service_move_after},
1582 {"service_get_state", _on_cmd_service_get_state},
1583 {"service_get_error", _on_cmd_service_get_error},
1584 {"service_get_name", _on_cmd_service_get_name},
1585 {"service_get_type", _on_cmd_service_get_type},
1586 {"service_get_security", _on_cmd_service_get_security},
1587 {"service_get_passphrase", _on_cmd_service_get_passphrase},
1588 {"service_set_passphrase", _on_cmd_service_set_passphrase},
1589 {"service_get_passphrase_required", _on_cmd_service_get_passphrase_required},
1590 {"service_get_strength", _on_cmd_service_get_strength},
1591 {"service_get_favorite", _on_cmd_service_get_favorite},
1592 {"service_get_immutable", _on_cmd_service_get_immutable},
1593 {"service_get_auto_connect", _on_cmd_service_get_auto_connect},
1594 {"service_set_auto_connect", _on_cmd_service_set_auto_connect},
1595 {"service_get_roaming", _on_cmd_service_get_roaming},
1596 {"service_get_ipv4_method", _on_cmd_service_get_ipv4_method},
1597 {"service_get_ipv4_address", _on_cmd_service_get_ipv4_address},
1598 {"service_get_ipv4_gateway", _on_cmd_service_get_ipv4_gateway},
1599 {"service_get_ipv4_netmask", _on_cmd_service_get_ipv4_netmask},
1600 {"service_get_ipv4_configuration_method", _on_cmd_service_get_ipv4_configuration_method},
1601 {"service_get_ipv4_configuration_address", _on_cmd_service_get_ipv4_configuration_address},
1602 {"service_get_ipv4_configuration_gateway", _on_cmd_service_get_ipv4_configuration_gateway},
1603 {"service_get_ipv4_configuration_netmask", _on_cmd_service_get_ipv4_configuration_netmask},
1604 {"service_ipv4_configure_dhcp", _on_cmd_service_ipv4_configure_dhcp},
1605 {"service_ipv4_configure_manual", _on_cmd_service_ipv4_configure_manual},
1606 {"service_get_ethernet_method", _on_cmd_service_get_ethernet_method},
1607 {"service_get_ethernet_address", _on_cmd_service_get_ethernet_address},
1608 {"service_get_ethernet_mtu", _on_cmd_service_get_ethernet_mtu},
1609 {"technology_get_state", _on_cmd_technology_get_state},
1610 {"technology_get_type", _on_cmd_technology_get_type},
1611 {"technology_get_name", _on_cmd_technology_get_name},
1616 if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR))
1618 fputs("ERROR: reading from stdin, exit\n", stderr);
1619 return ECORE_CALLBACK_CANCEL;
1622 if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
1624 fputs("ERROR: nothing to read?\n", stderr);
1625 return ECORE_CALLBACK_CANCEL;
1628 if (!fgets(buf, sizeof(buf), stdin))
1630 fprintf(stderr, "ERROR: could not read command: %s\n", strerror(errno));
1631 ecore_main_loop_quit();
1632 return ECORE_CALLBACK_CANCEL;
1636 while (isspace(*cmd))
1639 args = strchr(cmd, ' ');
1647 while (isspace(*args))
1650 p = args + strlen(args) - 1;
1658 p = cmd + strlen(cmd) - 1;
1663 if (strcmp(cmd, "help") == 0)
1667 printf("Commands with '%s' in the name:\n", args);
1668 for (itr = maps; itr->cmd; itr++)
1669 if (strstr(itr->cmd, args))
1670 printf("\t%s\n", itr->cmd);
1674 fputs("Commands:\n", stdout);
1675 for (itr = maps; itr->cmd; itr++)
1676 printf("\t%s\n", itr->cmd);
1678 fputc('\n', stdout);
1679 return ECORE_CALLBACK_RENEW;
1682 for (itr = maps; itr->cmd; itr++)
1683 if (strcmp(itr->cmd, cmd) == 0)
1684 return itr->cb(cmd, args);
1686 printf("unknown command \"%s\", args=%s\n", cmd, args);
1687 return ECORE_CALLBACK_RENEW;
1691 main(__UNUSED__ int argc, __UNUSED__ char *argv[])
1693 E_DBus_Connection *c;
1699 c = e_dbus_bus_get(DBUS_BUS_SYSTEM);
1701 printf("ERROR: can't connect to system session\n");
1705 e_connman_system_init(c);
1706 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_ADD, _on_element_add, NULL);
1707 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_DEL, _on_element_del, NULL);
1708 ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_UPDATED,
1709 _on_element_updated, NULL);
1711 ecore_main_fd_handler_add
1712 (0, ECORE_FD_READ | ECORE_FD_ERROR, _on_input, NULL, NULL, NULL);
1714 ecore_main_loop_begin();
1716 e_connman_system_shutdown();
1718 e_dbus_connection_close(c);
1723 fputs("DBG: clean exit.\n", stderr);