bool -> Eina_Bool
[framework/uifw/edbus.git] / src / bin / e_dbus_connman_test.c
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #include "E_Connman.h"
6 #include <stdio.h>
7 #include <string.h>
8 #include <ctype.h>
9 #include <errno.h>
10
11 static void
12 _method_success_check(void *data, __UNUSED__ DBusMessage *msg, DBusError *error)
13 {
14    const char *name = data;
15
16    if ((!error) || (!dbus_error_is_set(error)))
17      {
18         printf("SUCCESS: method %s() finished successfully.\n", name);
19         return;
20      }
21
22    printf("FAILURE: method %s() finished with error: %s %s\n",
23           name, error->name, error->message);
24    dbus_error_free(error);
25 }
26
27 static void
28 _elements_print(E_Connman_Element **elements, unsigned int count)
29 {
30    unsigned int i;
31    for (i = 0; i < count; i++)
32      {
33         printf("--- element %d:\n", i);
34         e_connman_element_print(stdout, elements[i]);
35      }
36    free(elements);
37    printf("END: all elements count = %u\n", count);
38 }
39
40 static void
41 _strings_print(const char **strings, unsigned int count)
42 {
43    unsigned int i;
44    for (i = 0; i < count; i++)
45      printf("--- strings %d: \"%s\"\n", i, strings[i]);
46    free(strings);
47    printf("END: all strings count = %u\n", count);
48 }
49
50 static Eina_Bool
51 _on_element_add(__UNUSED__ void *data, __UNUSED__ int type, void *info)
52 {
53    E_Connman_Element *element = info;
54    printf(">>> %s\n", element->path);
55    return ECORE_CALLBACK_PASS_ON;
56 }
57
58 static Eina_Bool
59 _on_element_del(__UNUSED__ void *data, __UNUSED__ int type, void *info)
60 {
61    E_Connman_Element *element = info;
62    printf("<<< %s\n", element->path);
63    return ECORE_CALLBACK_PASS_ON;
64 }
65
66 static Eina_Bool
67 _on_element_updated(__UNUSED__ void *data, __UNUSED__ int type, void *info)
68 {
69    E_Connman_Element *element = info;
70    printf("!!! %s\n", element->path);
71    e_connman_element_print(stderr, element);
72    return ECORE_CALLBACK_PASS_ON;
73 }
74
75 static Eina_Bool
76 _on_cmd_quit(__UNUSED__ char *cmd, __UNUSED__ char *args)
77 {
78    fputs("Bye!\n", stderr);
79    ecore_main_loop_quit();
80    return ECORE_CALLBACK_CANCEL;
81 }
82
83 static Eina_Bool
84 _on_cmd_sync(__UNUSED__ char *cmd, __UNUSED__ char *args)
85 {
86    e_connman_manager_sync_elements();
87    return ECORE_CALLBACK_RENEW;
88 }
89
90 static char *
91 _tok(char *p)
92 {
93    p = strchr(p, ' ');
94    if (!p)
95      return NULL;
96
97    *p = '\0';
98    p++;
99    while (isspace(*p))
100      p++;
101    if (*p == '\0')
102      return NULL;
103
104    return p;
105 }
106
107 static Eina_Bool
108 _on_cmd_get_all(__UNUSED__ char *cmd, char *args)
109 {
110    E_Connman_Element **elements;
111    char *type;
112    unsigned int count;
113    Eina_Bool ret;
114
115    if (!args)
116      type = NULL;
117    else
118      type = args;
119
120    if (type)
121      ret = e_connman_elements_get_all_type(type, &count, &elements);
122    else
123      ret = e_connman_elements_get_all(&count, &elements);
124
125    if (!ret)
126      fputs("ERROR: could not get elements\n", stderr);
127    else
128      {
129         printf("BEG: all elements type=%s count = %d\n", type, count);
130         _elements_print(elements, count);
131      }
132
133    return ECORE_CALLBACK_RENEW;
134 }
135
136 static E_Connman_Element *
137 _element_from_args(char *args, char **next_args)
138 {
139    E_Connman_Element *element;
140
141    if (!args)
142      {
143         fputs("ERROR: missing element path\n", stderr);
144         *next_args = NULL;
145         return NULL;
146      }
147
148    *next_args = _tok(args);
149    element = e_connman_element_get(args);
150    if (!element)
151      fprintf(stderr, "ERROR: no element called \"%s\".\n", args);
152
153    return element;
154 }
155
156 static Eina_Bool
157 _on_cmd_print(__UNUSED__ char *cmd, char *args)
158 {
159    char *next_args;
160    E_Connman_Element *element = _element_from_args(args, &next_args);
161    if (element)
162      e_connman_element_print(stdout, element);
163    return ECORE_CALLBACK_RENEW;
164 }
165
166 static Eina_Bool
167 _on_cmd_get_properties(__UNUSED__ char *cmd, char *args)
168 {
169    char *next_args;
170    E_Connman_Element *element = _element_from_args(args, &next_args);
171    if (element)
172      e_connman_element_properties_sync(element);
173    return ECORE_CALLBACK_RENEW;
174 }
175
176 static Eina_Bool
177 _on_cmd_property_set(__UNUSED__ char *cmd, char *args)
178 {
179    char *next_args, *name, *p;
180    E_Connman_Element *element = _element_from_args(args, &next_args);
181    void *value;
182    long vlong;
183    unsigned short vu16;
184    unsigned int vu32;
185    int type;
186
187    if (!element)
188      return ECORE_CALLBACK_RENEW;
189
190    if (!next_args)
191      {
192         fputs("ERROR: missing parameters name, type and value.\n", stderr);
193         return ECORE_CALLBACK_RENEW;
194      }
195
196    name = next_args;
197    p = _tok(name);
198    if (!p)
199      {
200         fputs("ERROR: missing parameters type and value.\n", stderr);
201         return ECORE_CALLBACK_RENEW;
202      }
203
204    next_args = _tok(p);
205    if (!next_args)
206      {
207         fputs("ERROR: missing parameter value.\n", stderr);
208         return ECORE_CALLBACK_RENEW;
209      }
210
211    type = p[0];
212    switch (type)
213      {
214       case DBUS_TYPE_BOOLEAN:
215          vlong = !!atol(next_args);
216          value = &vlong;
217          fprintf(stderr, "DBG: boolean is: %ld\n", vlong);
218          break;
219       case DBUS_TYPE_UINT16:
220          vu16 = strtol(next_args, &p, 0);
221          if (p == next_args)
222            {
223               fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
224               return ECORE_CALLBACK_RENEW;
225            }
226          value = &vu16;
227          fprintf(stderr, "DBG: u16 is: %hu\n", vu16);
228          break;
229       case DBUS_TYPE_UINT32:
230          vu32 = strtol(next_args, &p, 0);
231          if (p == next_args)
232            {
233               fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
234               return ECORE_CALLBACK_RENEW;
235            }
236          value = &vu32;
237          fprintf(stderr, "DBG: u16 is: %u\n", vu32);
238          break;
239       case DBUS_TYPE_STRING:
240       case DBUS_TYPE_OBJECT_PATH:
241          p = next_args + strlen(next_args);
242          if (p > next_args)
243            p--;
244          while (p > next_args && isspace(*p))
245            p--;
246          if (p <= next_args)
247            {
248               fprintf(stderr, "ERROR: invalid string \"%s\".\n", next_args);
249            }
250          p[1] = '\0';
251          value = next_args;
252          fprintf(stderr, "DBG: string is: \"%s\"\n", next_args);
253          break;
254       default:
255          fprintf(stderr, "ERROR: don't know how to parse type '%c' (%d)\n",
256                  type, type);
257          return ECORE_CALLBACK_RENEW;
258      }
259
260    fprintf(stderr, "set_property %s [%p] %s %c %p...\n",
261            args, element, name, type, value);
262    if (!e_connman_element_property_set(element, name, type, value))
263         fputs("ERROR: error setting property.\n", stderr);
264
265    return ECORE_CALLBACK_RENEW;
266 }
267
268
269 /* Manager Commands */
270
271 static Eina_Bool
272 _on_cmd_manager_get(__UNUSED__ char *cmd, __UNUSED__ char *args)
273 {
274    E_Connman_Element *element;
275    element = e_connman_manager_get();
276    e_connman_element_print(stderr, element);
277    return ECORE_CALLBACK_RENEW;
278 }
279
280 static Eina_Bool
281 _on_cmd_manager_get_profiles(__UNUSED__ char *cmd, __UNUSED__ char *args)
282 {
283    unsigned int count;
284    E_Connman_Element **profiles;
285
286    if (!e_connman_manager_profiles_get(&count, &profiles))
287      {
288         fputs("ERROR: can't get profiles\n", stderr);
289         return ECORE_CALLBACK_RENEW;
290      }
291    printf("BEG: all manager profiles elements count = %d\n", count);
292    _elements_print(profiles, count);
293    return ECORE_CALLBACK_RENEW;
294 }
295
296 static Eina_Bool
297 _on_cmd_manager_get_services(__UNUSED__ char *cmd, __UNUSED__ char *args)
298 {
299    unsigned int count;
300    E_Connman_Element **services;
301
302    if (!e_connman_manager_services_get(&count, &services))
303      {
304         fputs("ERROR: can't get services\n", stderr);
305         return ECORE_CALLBACK_RENEW;
306      }
307    printf("BEG: all manager services elements count = %d\n", count);
308    _elements_print(services, count);
309    return ECORE_CALLBACK_RENEW;
310 }
311
312 static Eina_Bool
313 _on_cmd_manager_register_agent(__UNUSED__ char *cmd, char *args)
314 {
315    char *path;
316
317    if (!args)
318      {
319         fputs("ERROR: missing the object path\n", stderr);
320         return ECORE_CALLBACK_RENEW;
321      }
322
323    path = args;
324    if (e_connman_manager_agent_register
325        (path, _method_success_check, "manager_register_agent"))
326      printf(":::Registering agent %s...\n", path);
327    else
328      fprintf(stderr, "ERROR: can't register agent %s\n", path);
329
330    return ECORE_CALLBACK_RENEW;
331 }
332
333 static Eina_Bool
334 _on_cmd_manager_unregister_agent(__UNUSED__ char *cmd, char *args)
335 {
336    char *path;
337
338    if (!args)
339      {
340         fputs("ERROR: missing the object path\n", stderr);
341         return ECORE_CALLBACK_RENEW;
342      }
343
344    path = args;
345    if (e_connman_manager_agent_unregister
346        (path, _method_success_check, "manager_unregister_agent"))
347      printf(":::Unregistering agent %s...\n", path);
348    else
349      fprintf(stderr, "ERROR: can't unregister agent %s\n", path);
350
351    return ECORE_CALLBACK_RENEW;
352 }
353
354 static Eina_Bool
355 _on_cmd_manager_get_state(__UNUSED__ char *cmd, __UNUSED__ char *args)
356 {
357    const char *state;
358    if (e_connman_manager_state_get(&state))
359      printf(":::Manager state = \"%s\"\n", state);
360    else
361      fputs("ERROR: can't get manager state\n", stderr);
362    return ECORE_CALLBACK_RENEW;
363 }
364
365 static Eina_Bool
366 _on_cmd_manager_get_offline_mode(__UNUSED__ char *cmd, __UNUSED__ char *args)
367 {
368    Eina_Bool offline;
369    if (e_connman_manager_offline_mode_get(&offline))
370      printf(":::Manager Offline Mode = %hhu\n", offline);
371    else
372      fputs("ERROR: can't get manager offline mode\n", stderr);
373    return ECORE_CALLBACK_RENEW;
374 }
375
376 static Eina_Bool
377 _on_cmd_manager_set_offline_mode(__UNUSED__ char *cmd, char *args)
378 {
379    Eina_Bool offline;
380    if (!args)
381      {
382         fputs("ERROR: missing the offline mode value\n", stderr);
383         return ECORE_CALLBACK_RENEW;
384      }
385    _tok(args);
386    offline = !!atol(args);
387    if (e_connman_manager_offline_mode_set
388        (offline, _method_success_check, "manager_set_offline_mode"))
389
390      printf(":::Manager Offline Mode set to %hhu\n", offline);
391    else
392      fputs("ERROR: can't set manager offline mode\n", stderr);
393    return ECORE_CALLBACK_RENEW;
394 }
395
396 static Eina_Bool
397 _on_cmd_manager_request_scan(__UNUSED__ char *cmd, char *args)
398 {
399    if (args)
400      _tok(args);
401
402    if (!args)
403      args = "";
404
405    if (e_connman_manager_request_scan
406        (args, _method_success_check, "manager_request_scan"))
407      printf(":::Manager Request Scan for %s\n", args[0] ? args : "<all>");
408    else
409      fputs("ERROR: can't request scan on manager\n", stderr);
410    return ECORE_CALLBACK_RENEW;
411 }
412
413 static Eina_Bool
414 _on_cmd_manager_technology_enable(__UNUSED__ char *cmd, char *args)
415 {
416    if (!args)
417      {
418         fputs("ERROR: missing the technology type\n", stderr);
419         return ECORE_CALLBACK_RENEW;
420      }
421    _tok(args);
422
423    if (e_connman_manager_technology_enable
424        (args, _method_success_check, "manager_technology_enable"))
425      printf(":::Manager Enable Technology %s\n", args);
426    else
427      fputs("ERROR: can't enable technology on manager\n", stderr);
428    return ECORE_CALLBACK_RENEW;
429 }
430
431 static Eina_Bool
432 _on_cmd_manager_technology_disable(__UNUSED__ char *cmd, char *args)
433 {
434    if (!args)
435      {
436         fputs("ERROR: missing the technology type\n", stderr);
437         return ECORE_CALLBACK_RENEW;
438      }
439    _tok(args);
440
441    if (e_connman_manager_technology_disable
442        (args, _method_success_check, "manager_technology_disable"))
443      printf(":::Manager Disable Technology %s\n", args);
444    else
445      fputs("ERROR: can't disable technology on manager\n", stderr);
446    return ECORE_CALLBACK_RENEW;
447 }
448
449 static Eina_Bool
450 _on_cmd_manager_get_technologies_available(__UNUSED__ char *cmd, __UNUSED__ char *args)
451 {
452    const char **strings;
453    unsigned int count;
454
455    if (!e_connman_manager_technologies_available_get(&count, &strings))
456      fputs("ERROR: can't get available technologies\n", stderr);
457    else
458      {
459         printf("BEG: available technologies count = %u\n", count);
460         _strings_print(strings, count);
461      }
462
463    return ECORE_CALLBACK_RENEW;
464 }
465
466 static Eina_Bool
467 _on_cmd_manager_get_technologies_enabled(__UNUSED__ char *cmd, __UNUSED__ char *args)
468 {
469    const char **strings;
470    unsigned int count;
471
472    if (!e_connman_manager_technologies_enabled_get(&count, &strings))
473      fputs("ERROR: can't get enabled technologies\n", stderr);
474    else
475      {
476         printf("BEG: enabled technologies count = %u\n", count);
477         _strings_print(strings, count);
478      }
479
480    return ECORE_CALLBACK_RENEW;
481 }
482
483 static Eina_Bool
484 _on_cmd_manager_get_technologies_connected(__UNUSED__ char *cmd, __UNUSED__ char *args)
485 {
486    const char **strings;
487    unsigned int count;
488
489    if (!e_connman_manager_technologies_connected_get(&count, &strings))
490      fputs("ERROR: can't get connected technologies\n", stderr);
491    else
492      {
493         printf("BEG: connected technologies count = %u\n", count);
494         _strings_print(strings, count);
495      }
496
497    return ECORE_CALLBACK_RENEW;
498 }
499
500 static Eina_Bool
501 _on_cmd_manager_profile_remove(__UNUSED__ char *cmd, char *args)
502 {
503    E_Connman_Element *e;
504
505    if (!args)
506      {
507         fputs("ERROR: missing the profile path\n", stderr);
508         return ECORE_CALLBACK_RENEW;
509      }
510    _tok(args);
511
512    e = e_connman_profile_get(args);
513    if (e_connman_manager_profile_remove
514        (e, _method_success_check, "manager_profile_remove"))
515      printf(":::Manager Remove Profile %s\n", args);
516    else
517      fputs("ERROR: can't remove profile from manager\n", stderr);
518    return ECORE_CALLBACK_RENEW;
519 }
520
521 static Eina_Bool
522 _on_cmd_manager_profile_get_active(__UNUSED__ char *cmd, __UNUSED__ char *args)
523 {
524    E_Connman_Element *e;
525
526    if (!e_connman_manager_profile_active_get(&e))
527      fputs("ERROR: can't active_get profile from manager\n", stderr);
528    else
529      e_connman_element_print(stderr, e);
530    return ECORE_CALLBACK_RENEW;
531 }
532
533 static Eina_Bool
534 _on_cmd_manager_profile_set_active(__UNUSED__ char *cmd, char *args)
535 {
536    E_Connman_Element *e;
537
538    if (!args)
539      {
540         fputs("ERROR: missing the profile path\n", stderr);
541         return ECORE_CALLBACK_RENEW;
542      }
543    _tok(args);
544
545    e = e_connman_profile_get(args);
546    if (e_connman_manager_profile_active_set
547        (e, _method_success_check, "manager_profile_set_active"))
548      printf(":::Manager Active Profile set to %s\n", args);
549    else
550      fputs("ERROR: can't set active profile\n", stderr);
551    return ECORE_CALLBACK_RENEW;
552 }
553
554 /* Device Commands */
555 static Eina_Bool
556 _on_cmd_device_propose_scan(__UNUSED__ char *cmd, char *args)
557 {
558    char *path;
559    E_Connman_Element *e;
560
561    if (!args)
562      {
563         fputs("ERROR: missing the device path\n", stderr);
564         return ECORE_CALLBACK_RENEW;
565      }
566    _tok(args);
567    path = args;
568
569    e = e_connman_device_get(path);
570    if (e_connman_device_propose_scan
571        (e, _method_success_check, "device_propose_scan"))
572      printf(":::Proposing scan %s...\n", path);
573    else
574      fputs("ERROR: can't propose scan\n", stderr);
575    return ECORE_CALLBACK_RENEW;
576 }
577
578 static Eina_Bool
579 _on_cmd_device_get_address(__UNUSED__ char *cmd, char *args)
580 {
581    const char *address, *path;
582    E_Connman_Element *e;
583
584    if (!args)
585      {
586         fputs("ERROR: missing the device path\n", stderr);
587         return ECORE_CALLBACK_RENEW;
588      }
589    _tok(args);
590    path = args;
591
592    e = e_connman_device_get(path);
593    if (e_connman_device_address_get(e, &address))
594      printf(":::Device %s Address = \"%s\"\n", path, address);
595    else
596      fputs("ERROR: can't get device address\n", stderr);
597    return ECORE_CALLBACK_RENEW;
598 }
599
600 static Eina_Bool
601 _on_cmd_device_get_name(__UNUSED__ char *cmd, char *args)
602 {
603    const char *name, *path;
604    E_Connman_Element *e;
605
606    if (!args)
607      {
608         fputs("ERROR: missing the device path\n", stderr);
609         return ECORE_CALLBACK_RENEW;
610      }
611    _tok(args);
612    path = args;
613
614    e = e_connman_device_get(path);
615    if (e_connman_device_name_get(e, &name))
616      printf(":::Device %s Name = \"%s\"\n", path, name);
617    else
618      fputs("ERROR: can't get device name\n", stderr);
619    return ECORE_CALLBACK_RENEW;
620 }
621
622 static Eina_Bool
623 _on_cmd_device_get_type(__UNUSED__ char *cmd, char *args)
624 {
625    const char *type, *path;
626    E_Connman_Element *e;
627
628    if (!args)
629      {
630         fputs("ERROR: missing the device path\n", stderr);
631         return ECORE_CALLBACK_RENEW;
632      }
633    _tok(args);
634    path = args;
635
636    e = e_connman_device_get(path);
637    if (e_connman_device_type_get(e, &type))
638      printf(":::Device %s Type = \"%s\"\n", path, type);
639    else
640      fputs("ERROR: can't get device type\n", stderr);
641    return ECORE_CALLBACK_RENEW;
642 }
643
644 static Eina_Bool
645 _on_cmd_device_get_interface(__UNUSED__ char *cmd, char *args)
646 {
647    const char *interface, *path;
648    E_Connman_Element *e;
649
650    if (!args)
651      {
652         fputs("ERROR: missing the device path\n", stderr);
653         return ECORE_CALLBACK_RENEW;
654      }
655    _tok(args);
656    path = args;
657
658    e = e_connman_device_get(path);
659    if (e_connman_device_interface_get(e, &interface))
660      printf(":::Device %s Interface = \"%s\"\n", path, interface);
661    else
662      fputs("ERROR: can't get device interface\n", stderr);
663    return ECORE_CALLBACK_RENEW;
664 }
665
666 static Eina_Bool
667 _on_cmd_device_get_powered(__UNUSED__ char *cmd, char *args)
668 {
669    char *path;
670    Eina_Bool powered;
671    E_Connman_Element *e;
672
673    if (!args)
674      {
675         fputs("ERROR: missing the device path\n", stderr);
676         return ECORE_CALLBACK_RENEW;
677      }
678    _tok(args);
679    path = args;
680
681    e = e_connman_device_get(path);
682    if (e_connman_device_powered_get(e, &powered))
683      printf(":::Device %s Powered = %hhu\n", path, powered);
684    else
685      fputs("ERROR: can't get device powered\n", stderr);
686    return ECORE_CALLBACK_RENEW;
687 }
688
689 static Eina_Bool
690 _on_cmd_device_set_powered(__UNUSED__ char *cmd, char *args)
691 {
692    char *device_path, *next_args;
693    Eina_Bool powered;
694    E_Connman_Element *e;
695
696    if (!args)
697      {
698         fputs("ERROR: missing the device path\n", stderr);
699         return ECORE_CALLBACK_RENEW;
700      }
701    device_path = args;
702    next_args = _tok(args);
703    if (!next_args)
704      {
705         fputs("ERROR: missing the powered value\n", stderr);
706         return ECORE_CALLBACK_RENEW;
707      }
708    powered = !!atol(next_args);
709
710    e = e_connman_device_get(device_path);
711    if (e_connman_device_powered_set
712        (e, powered, _method_success_check, "device_set_powered"))
713      printf(":::Device %s powered set to %hhu\n", device_path, powered);
714    else
715      fputs("ERROR: can't set device powered\n", stderr);
716    return ECORE_CALLBACK_RENEW;
717 }
718
719 static Eina_Bool
720 _on_cmd_device_get_scan_interval(__UNUSED__ char *cmd, char *args)
721 {
722    char *path;
723    unsigned short scan_interval;
724    E_Connman_Element *e;
725
726    if (!args)
727      {
728         fputs("ERROR: missing the device path\n", stderr);
729         return ECORE_CALLBACK_RENEW;
730      }
731    _tok(args);
732    path = args;
733
734    e = e_connman_device_get(path);
735    if (e_connman_device_scan_interval_get(e, &scan_interval))
736      printf(":::Device %s ScanInterval = %hu\n", path, scan_interval);
737    else
738      fputs("ERROR: can't get device scan interval\n", stderr);
739    return ECORE_CALLBACK_RENEW;
740 }
741
742 static Eina_Bool
743 _on_cmd_device_set_scan_interval(__UNUSED__ char *cmd, char *args)
744 {
745    char *device_path, *next_args, *p;
746    unsigned short scan_interval;
747    E_Connman_Element *e;
748
749    if (!args)
750      {
751         fputs("ERROR: missing the device path\n", stderr);
752         return ECORE_CALLBACK_RENEW;
753      }
754    device_path = args;
755    next_args = _tok(args);
756    if (!next_args)
757      {
758         fputs("ERROR: missing the scan interval value\n", stderr);
759         return ECORE_CALLBACK_RENEW;
760      }
761    scan_interval = strtol(next_args, &p, 0);
762    if (p == next_args)
763      {
764         fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
765         return ECORE_CALLBACK_RENEW;
766      }
767
768    e = e_connman_device_get(device_path);
769    if (e_connman_device_scan_interval_set
770        (e, scan_interval, _method_success_check, "device_set_scan_interval"))
771      printf(":::Device %s scan interval set to %hu\n", device_path, scan_interval);
772    else
773      fputs("ERROR: can't set device scan interval\n", stderr);
774    return ECORE_CALLBACK_RENEW;
775 }
776
777 static Eina_Bool
778 _on_cmd_device_get_scanning(__UNUSED__ char *cmd, char *args)
779 {
780    char *path;
781    Eina_Bool scanning;
782    E_Connman_Element *e;
783
784    if (!args)
785      {
786         fputs("ERROR: missing the device path\n", stderr);
787         return ECORE_CALLBACK_RENEW;
788      }
789    _tok(args);
790    path = args;
791
792    e = e_connman_device_get(path);
793    if (e_connman_device_scanning_get(e, &scanning))
794      printf(":::Device %s Scanning = %hhu\n", path, scanning);
795    else
796      fputs("ERROR: can't get device scanning\n", stderr);
797    return ECORE_CALLBACK_RENEW;
798 }
799
800 static Eina_Bool
801 _on_cmd_device_get_networks(__UNUSED__ char *cmd, char *args)
802 {
803    E_Connman_Element **networks;
804    unsigned int count;
805    char *path;
806    E_Connman_Element *e;
807
808    if (!args)
809      {
810         fputs("ERROR: missing the device path\n", stderr);
811         return ECORE_CALLBACK_RENEW;
812      }
813    _tok(args);
814    path = args;
815
816    e = e_connman_device_get(path);
817    if (!e_connman_device_networks_get(e, &count, &networks))
818      {
819         fputs("ERROR: can't get networks\n", stderr);
820         return ECORE_CALLBACK_RENEW;
821      }
822
823    printf("BEG: all device network elements count = %d\n", count);
824    _elements_print(networks, count);
825    return ECORE_CALLBACK_RENEW;
826 }
827
828 /* Profile Commands */
829
830 static Eina_Bool
831 _on_cmd_profile_get_name(__UNUSED__ char *cmd, char *args)
832 {
833    const char *name, *path;
834    E_Connman_Element *e;
835
836    if (!args)
837      {
838         fputs("ERROR: missing the profile path\n", stderr);
839         return ECORE_CALLBACK_RENEW;
840      }
841    _tok(args);
842    path = args;
843
844    e = e_connman_profile_get(path);
845    if (e_connman_profile_name_get(e, &name))
846      printf(":::Profile %s Name = \"%s\"\n", path, name);
847    else
848      fputs("ERROR: can't get profile name\n", stderr);
849    return ECORE_CALLBACK_RENEW;
850 }
851
852 static Eina_Bool
853 _on_cmd_profile_set_name(__UNUSED__ char *cmd, char *args)
854 {
855    char *path, *next_args;
856    E_Connman_Element *e;
857
858    if (!args)
859      {
860         fputs("ERROR: missing the profile path\n", stderr);
861         return ECORE_CALLBACK_RENEW;
862      }
863    path = args;
864    next_args = _tok(args);
865    if (!next_args)
866      {
867         fputs("ERROR: missing the offline mode value\n", stderr);
868         return ECORE_CALLBACK_RENEW;
869      }
870    _tok(next_args);
871
872    e = e_connman_profile_get(path);
873    if (e_connman_profile_name_set
874        (e, next_args, _method_success_check, "profile_set_name"))
875      printf(":::Profile %s Name set to %s\n", path, next_args);
876    else
877      fputs("ERROR: can't set profile name\n", stderr);
878    return ECORE_CALLBACK_RENEW;
879 }
880
881 static Eina_Bool
882 _on_cmd_profile_get_offline_mode(__UNUSED__ char *cmd, char *args)
883 {
884    char *path;
885    Eina_Bool offline;
886    E_Connman_Element *e;
887
888    if (!args)
889      {
890         fputs("ERROR: missing the profile path\n", stderr);
891         return ECORE_CALLBACK_RENEW;
892      }
893    _tok(args);
894    path = args;
895
896    e = e_connman_profile_get(path);
897    if (e_connman_profile_offline_mode_get(e, &offline))
898      printf(":::Profile  %s Offline Mode = %hhu\n", path, offline);
899    else
900      fputs("ERROR: can't get profile offline mode\n", stderr);
901    return ECORE_CALLBACK_RENEW;
902 }
903
904 static Eina_Bool
905 _on_cmd_profile_set_offline_mode(__UNUSED__ char *cmd, char *args)
906 {
907    char *path, *next_args;
908    Eina_Bool offline;
909    E_Connman_Element *e;
910
911    if (!args)
912      {
913         fputs("ERROR: missing the profile path\n", stderr);
914         return ECORE_CALLBACK_RENEW;
915      }
916    path = args;
917    next_args = _tok(args);
918    if (!next_args)
919      {
920         fputs("ERROR: missing the offline mode value\n", stderr);
921         return ECORE_CALLBACK_RENEW;
922      }
923    _tok(next_args);
924    offline = !!atol(next_args);
925
926    e = e_connman_profile_get(path);
927    if (e_connman_profile_offline_mode_set
928        (e, offline, _method_success_check, "profile_set_offline_mode"))
929      printf(":::Profile %s Offline Mode set to %hhu\n", path, offline);
930    else
931      fputs("ERROR: can't set profile offline mode\n", stderr);
932    return ECORE_CALLBACK_RENEW;
933 }
934
935 static Eina_Bool
936 _on_cmd_profile_get_services(__UNUSED__ char *cmd, char *args)
937 {
938    E_Connman_Element **services;
939    E_Connman_Element *e;
940    unsigned int count;
941    char *path;
942
943    if (!args)
944      {
945         fputs("ERROR: missing the profile path\n", stderr);
946         return ECORE_CALLBACK_RENEW;
947      }
948    _tok(args);
949    path = args;
950
951    e = e_connman_profile_get(path);
952    if (!e_connman_profile_services_get(e, &count, &services))
953      {
954         fputs("ERROR: can't get services\n", stderr);
955         return ECORE_CALLBACK_RENEW;
956      }
957    printf("BEG: all profile services count = %d\n", count);
958    _elements_print(services, count);
959    return ECORE_CALLBACK_RENEW;
960 }
961
962
963 /* Network Commands */
964
965 static Eina_Bool
966 _on_cmd_network_get_address(__UNUSED__ char *cmd, char *args)
967 {
968    const char *address, *path;
969    E_Connman_Element *e;
970
971    if (!args)
972      {
973         fputs("ERROR: missing the network path\n", stderr);
974         return ECORE_CALLBACK_RENEW;
975      }
976    _tok(args);
977    path = args;
978
979    e = e_connman_network_get(path);
980    if (e_connman_network_address_get(e, &address))
981      printf(":::Network %s Address = \"%s\"\n", path, address);
982    else
983      fputs("ERROR: can't get network address\n", stderr);
984    return ECORE_CALLBACK_RENEW;
985 }
986
987 static Eina_Bool
988 _on_cmd_network_get_name(__UNUSED__ char *cmd, char *args)
989 {
990    const char *name, *path;
991    E_Connman_Element *e;
992
993    if (!args)
994      {
995         fputs("ERROR: missing the network path\n", stderr);
996         return ECORE_CALLBACK_RENEW;
997      }
998    _tok(args);
999    path = args;
1000
1001    e = e_connman_network_get(path);
1002    if (e_connman_network_name_get(e, &name))
1003      printf(":::Network %s Name = \"%s\"\n", path, name);
1004    else
1005      fputs("ERROR: can't get network name\n", stderr);
1006    return ECORE_CALLBACK_RENEW;
1007 }
1008
1009 static Eina_Bool
1010 _on_cmd_network_get_connected(__UNUSED__ char *cmd, char *args)
1011 {
1012    char *path;
1013    Eina_Bool connected;
1014    E_Connman_Element *e;
1015
1016    if (!args)
1017      {
1018         fputs("ERROR: missing the network path\n", stderr);
1019         return ECORE_CALLBACK_RENEW;
1020      }
1021    _tok(args);
1022    path = args;
1023
1024    e = e_connman_network_get(path);
1025    if (e_connman_network_connected_get(e, &connected))
1026      printf(":::Network %s Connected = %hhu\n", path, connected);
1027    else
1028      fputs("ERROR: can't get network connected\n", stderr);
1029    return ECORE_CALLBACK_RENEW;
1030 }
1031
1032 static Eina_Bool
1033 _on_cmd_network_get_strength(__UNUSED__ char *cmd, char *args)
1034 {
1035    char *path;
1036    unsigned char strength;
1037    E_Connman_Element *e;
1038
1039    if (!args)
1040      {
1041         fputs("ERROR: missing the network path\n", stderr);
1042         return ECORE_CALLBACK_RENEW;
1043      }
1044    _tok(args);
1045    path = args;
1046
1047    e = e_connman_network_get(path);
1048    if (e_connman_network_strength_get(e, &strength))
1049      printf(":::Network %s Strength = %#02hhx (%d)\n", path, strength, strength);
1050    else
1051      fputs("ERROR: can't get network strength\n", stderr);
1052    return ECORE_CALLBACK_RENEW;
1053 }
1054
1055 static Eina_Bool
1056 _on_cmd_network_get_frequency(__UNUSED__ char *cmd, char *args)
1057 {
1058    char *path;
1059    unsigned short frequency;
1060    E_Connman_Element *e;
1061
1062    if (!args)
1063      {
1064         fputs("ERROR: missing the network path\n", stderr);
1065         return ECORE_CALLBACK_RENEW;
1066      }
1067    _tok(args);
1068    path = args;
1069
1070    e = e_connman_network_get(path);
1071    if (e_connman_network_frequency_get(e, &frequency))
1072      printf(":::Network %s Frequency = %#04hx (%d)\n", path, frequency, frequency);
1073    else
1074      fputs("ERROR: can't get network frequency\n", stderr);
1075    return ECORE_CALLBACK_RENEW;
1076 }
1077
1078 static Eina_Bool
1079 _on_cmd_network_get_device(__UNUSED__ char *cmd, char *args)
1080 {
1081    E_Connman_Element *e, *device;
1082    char *path;
1083
1084    if (!args)
1085      {
1086         fputs("ERROR: missing the network path\n", stderr);
1087         return ECORE_CALLBACK_RENEW;
1088      }
1089    _tok(args);
1090    path = args;
1091
1092    e = e_connman_network_get(path);
1093    if (!e_connman_network_device_get(e, &device))
1094      fputs("ERROR: can't get network device\n", stderr);
1095    else
1096      e_connman_element_print(stderr, device);
1097    return ECORE_CALLBACK_RENEW;
1098 }
1099
1100 static Eina_Bool
1101 _on_cmd_network_get_wifi_ssid(__UNUSED__ char *cmd, char *args)
1102 {
1103    unsigned char *bytes;
1104    char *path;
1105    unsigned int i, count;
1106    E_Connman_Element *e;
1107
1108    if (!args)
1109      {
1110         fputs("ERROR: missing the network path\n", stderr);
1111         return ECORE_CALLBACK_RENEW;
1112      }
1113    _tok(args);
1114    path = args;
1115
1116    e = e_connman_network_get(path);
1117    if (e_connman_network_wifi_ssid_get(e, &count, &bytes))
1118      {
1119         printf(":::Network %s Wifi SSID = ", path);
1120         for (i = 0; i < count; i++)
1121           printf("%#02hhx (\"%c\"), ", bytes[i], bytes[i]);
1122         printf("\n");
1123      }
1124    else
1125      fputs("ERROR: can't get network wifi ssid\n", stderr);
1126    return ECORE_CALLBACK_RENEW;
1127 }
1128
1129 static Eina_Bool
1130 _on_cmd_network_get_wifi_mode(__UNUSED__ char *cmd, char *args)
1131 {
1132    const char *wifi_mode, *path;
1133    E_Connman_Element *e;
1134
1135    if (!args)
1136      {
1137         fputs("ERROR: missing the network path\n", stderr);
1138         return ECORE_CALLBACK_RENEW;
1139      }
1140    _tok(args);
1141    path = args;
1142
1143    e = e_connman_network_get(path);
1144    if (e_connman_network_wifi_mode_get(e, &wifi_mode))
1145      printf(":::Network %s Wifi Mode = \"%s\"\n", path, wifi_mode);
1146    else
1147      fputs("ERROR: can't get network wifi mode\n", stderr);
1148    return ECORE_CALLBACK_RENEW;
1149 }
1150
1151 static Eina_Bool
1152 _on_cmd_network_get_wifi_security(__UNUSED__ char *cmd, char *args)
1153 {
1154    const char *wifi_security, *path;
1155    E_Connman_Element *e;
1156
1157    if (!args)
1158      {
1159         fputs("ERROR: missing the network path\n", stderr);
1160         return ECORE_CALLBACK_RENEW;
1161      }
1162    _tok(args);
1163    path = args;
1164
1165    e = e_connman_network_get(path);
1166    if (e_connman_network_wifi_security_get(e, &wifi_security))
1167      printf(":::Network %s Wifi Security = \"%s\"\n", path, wifi_security);
1168    else
1169      fputs("ERROR: can't get network wifi security\n", stderr);
1170    return ECORE_CALLBACK_RENEW;
1171 }
1172
1173 static Eina_Bool
1174 _on_cmd_network_get_wifi_passphrase(__UNUSED__ char *cmd, char *args)
1175 {
1176    const char *wifi_passphrase, *path;
1177    E_Connman_Element *e;
1178
1179    if (!args)
1180      {
1181         fputs("ERROR: missing the network path\n", stderr);
1182         return ECORE_CALLBACK_RENEW;
1183      }
1184    _tok(args);
1185    path = args;
1186
1187    e = e_connman_network_get(path);
1188    if (e_connman_network_wifi_passphrase_get(e, &wifi_passphrase))
1189      printf(":::Network %s Wifi Passphrase = \"%s\"\n", path, wifi_passphrase);
1190    else
1191      fputs("ERROR: can't get network wifi passphrase\n", stderr);
1192    return ECORE_CALLBACK_RENEW;
1193 }
1194
1195 static Eina_Bool
1196 _on_cmd_network_get_wifi_channel(__UNUSED__ char *cmd, char *args)
1197 {
1198    char *path;
1199    E_Connman_Element *e;
1200    unsigned short wifi_channel;
1201
1202    if (!args)
1203      {
1204         fputs("ERROR: missing the network path\n", stderr);
1205         return ECORE_CALLBACK_RENEW;
1206      }
1207    _tok(args);
1208    path = args;
1209
1210    e = e_connman_network_get(path);
1211    if (e_connman_network_wifi_channel_get(e, &wifi_channel))
1212      printf(":::Network %s Wifi Channel = %#02hx (%d)\n", path, wifi_channel, wifi_channel);
1213    else
1214      fputs("ERROR: can't get network wifi channel\n", stderr);
1215    return ECORE_CALLBACK_RENEW;
1216 }
1217
1218 static Eina_Bool
1219 _on_cmd_network_get_wifi_eap(__UNUSED__ char *cmd, char *args)
1220 {
1221    const char *wifi_eap, *path;
1222    E_Connman_Element *e;
1223
1224    if (!args)
1225      {
1226         fputs("ERROR: missing the network path\n", stderr);
1227         return ECORE_CALLBACK_RENEW;
1228      }
1229    _tok(args);
1230    path = args;
1231
1232    e = e_connman_network_get(path);
1233    if (e_connman_network_wifi_eap_get(e, &wifi_eap))
1234      printf(":::Network %s Wifi EAP = \"%s\"\n", path, wifi_eap);
1235    else
1236      fputs("ERROR: can't get network wifi eap\n", stderr);
1237    return ECORE_CALLBACK_RENEW;
1238 }
1239
1240 /* Services Commands */
1241 static Eina_Bool
1242 _on_cmd_service_connect(__UNUSED__ char *cmd, char *args)
1243 {
1244    char *path;
1245    E_Connman_Element *e;
1246
1247    if (!args)
1248      {
1249         fputs("ERROR: missing the service path\n", stderr);
1250         return ECORE_CALLBACK_RENEW;
1251      }
1252    _tok(args);
1253    path = args;
1254
1255    e = e_connman_service_get(path);
1256    if (e_connman_service_connect
1257        (e, _method_success_check, "service_connect"))
1258      printf(":::Connecting to Service %s...\n", path);
1259    else
1260      fputs("ERROR: can't connect to service\n", stderr);
1261    return ECORE_CALLBACK_RENEW;
1262 }
1263
1264 static Eina_Bool
1265 _on_cmd_service_disconnect(__UNUSED__ char *cmd, char *args)
1266 {
1267    char *path;
1268    E_Connman_Element *e;
1269
1270    if (!args)
1271      {
1272         fputs("ERROR: missing the service path\n", stderr);
1273         return ECORE_CALLBACK_RENEW;
1274      }
1275    _tok(args);
1276    path = args;
1277
1278    e = e_connman_service_get(path);
1279    if (e_connman_service_disconnect
1280        (e, _method_success_check, "service_disconnect"))
1281      printf(":::Disconnecting Service %s...\n", path);
1282    else
1283      fputs("ERROR: can't disconnect service\n", stderr);
1284    return ECORE_CALLBACK_RENEW;
1285 }
1286
1287 static Eina_Bool
1288 _on_cmd_service_remove(__UNUSED__ char *cmd, char *args)
1289 {
1290    char *path;
1291    E_Connman_Element *e;
1292
1293    if (!args)
1294      {
1295         fputs("ERROR: missing the service path\n", stderr);
1296         return ECORE_CALLBACK_RENEW;
1297      }
1298    _tok(args);
1299    path = args;
1300
1301    e = e_connman_service_get(path);
1302    if (e_connman_service_remove
1303        (e, _method_success_check, "service_remove"))
1304      printf(":::Removing Service %s...\n", path);
1305    else
1306      fputs("ERROR: can't remove service\n", stderr);
1307    return ECORE_CALLBACK_RENEW;
1308 }
1309
1310 static Eina_Bool
1311 _on_cmd_service_move_before(__UNUSED__ char *cmd, char *args)
1312 {
1313    char *path, *service_path;
1314    E_Connman_Element *e;
1315
1316    if (!args)
1317      {
1318         fputs("ERROR: missing the service path\n", stderr);
1319         return ECORE_CALLBACK_RENEW;
1320      }
1321    service_path = args;
1322    path = _tok(args);
1323
1324    if (!path)
1325      {
1326         fputs("ERROR: missing the object service\n", stderr);
1327         return ECORE_CALLBACK_RENEW;
1328      }
1329    _tok(path);
1330
1331    e = e_connman_service_get(service_path);
1332    if (e_connman_service_move_before
1333        (e, path, _method_success_check, "service_move_before"))
1334      printf(":::Moving before %s...\n", path);
1335    else
1336      fputs("ERROR: can't move before\n", stderr);
1337    return ECORE_CALLBACK_RENEW;
1338 }
1339
1340 static Eina_Bool
1341 _on_cmd_service_move_after(__UNUSED__ char *cmd, char *args)
1342 {
1343    char *path, *service_path;
1344    E_Connman_Element *e;
1345
1346    if (!args)
1347      {
1348         fputs("ERROR: missing the service path\n", stderr);
1349         return ECORE_CALLBACK_RENEW;
1350      }
1351    service_path = args;
1352    path = _tok(args);
1353
1354    if (!path)
1355      {
1356         fputs("ERROR: missing the object service\n", stderr);
1357         return ECORE_CALLBACK_RENEW;
1358      }
1359    _tok(path);
1360
1361    e = e_connman_service_get(service_path);
1362    if (e_connman_service_move_after
1363        (e, path, _method_success_check, "service_move_after"))
1364      printf(":::Moving after %s...\n", path);
1365    else
1366      fputs("ERROR: can't move after\n", stderr);
1367    return ECORE_CALLBACK_RENEW;
1368 }
1369
1370 static Eina_Bool
1371 _on_cmd_service_get_state(__UNUSED__ char *cmd, char *args)
1372 {
1373    const char *state, *path;
1374    E_Connman_Element *e;
1375
1376    if (!args)
1377      {
1378         fputs("ERROR: missing the service path\n", stderr);
1379         return ECORE_CALLBACK_RENEW;
1380      }
1381    _tok(args);
1382    path = args;
1383
1384    e = e_connman_service_get(path);
1385    if (e_connman_service_state_get(e, &state))
1386      printf(":::Service %s State = \"%s\"\n", path, state);
1387    else
1388      fputs("ERROR: can't get service state\n", stderr);
1389    return ECORE_CALLBACK_RENEW;
1390 }
1391
1392 static Eina_Bool
1393 _on_cmd_service_get_error(__UNUSED__ char *cmd, char *args)
1394 {
1395    const char *error, *path;
1396    E_Connman_Element *e;
1397
1398    if (!args)
1399      {
1400         fputs("ERROR: missing the service path\n", stderr);
1401         return ECORE_CALLBACK_RENEW;
1402      }
1403    _tok(args);
1404    path = args;
1405
1406    e = e_connman_service_get(path);
1407    if (e_connman_service_error_get(e, &error))
1408      printf(":::Service %s Error = \"%s\"\n", path, error);
1409    else
1410      fputs("ERROR: can't get service error\n", stderr);
1411    return ECORE_CALLBACK_RENEW;
1412 }
1413
1414 static Eina_Bool
1415 _on_cmd_service_get_name(__UNUSED__ char *cmd, char *args)
1416 {
1417    const char *name, *path;
1418    E_Connman_Element *e;
1419
1420    if (!args)
1421      {
1422         fputs("ERROR: missing the service path\n", stderr);
1423         return ECORE_CALLBACK_RENEW;
1424      }
1425    _tok(args);
1426    path = args;
1427
1428    e = e_connman_service_get(path);
1429    if (e_connman_service_name_get(e, &name))
1430      printf(":::Service %s Name = \"%s\"\n", path, name);
1431    else
1432      fputs("ERROR: can't get service name\n", stderr);
1433    return ECORE_CALLBACK_RENEW;
1434 }
1435
1436 static Eina_Bool
1437 _on_cmd_service_get_type(__UNUSED__ char *cmd, char *args)
1438 {
1439    const char *type, *path;
1440    E_Connman_Element *e;
1441
1442    if (!args)
1443      {
1444         fputs("ERROR: missing the service path\n", stderr);
1445         return ECORE_CALLBACK_RENEW;
1446      }
1447    _tok(args);
1448    path = args;
1449
1450    e = e_connman_service_get(path);
1451    if (e_connman_service_type_get(e, &type))
1452      printf(":::Service %s Type = \"%s\"\n", path, type);
1453    else
1454      fputs("ERROR: can't get service type\n", stderr);
1455    return ECORE_CALLBACK_RENEW;
1456 }
1457
1458 static Eina_Bool
1459 _on_cmd_service_get_mode(__UNUSED__ char *cmd, char *args)
1460 {
1461    const char *mode, *path;
1462    E_Connman_Element *e;
1463
1464    if (!args)
1465      {
1466         fputs("ERROR: missing the service path\n", stderr);
1467         return ECORE_CALLBACK_RENEW;
1468      }
1469    _tok(args);
1470    path = args;
1471
1472    e = e_connman_service_get(path);
1473    if (e_connman_service_mode_get(e, &mode))
1474      printf(":::Service %s Mode = \"%s\"\n", path, mode);
1475    else
1476      fputs("ERROR: can't get service mode\n", stderr);
1477    return ECORE_CALLBACK_RENEW;
1478 }
1479
1480 static Eina_Bool
1481 _on_cmd_service_get_security(__UNUSED__ char *cmd, char *args)
1482 {
1483    const char *security, *path;
1484    E_Connman_Element *e;
1485
1486    if (!args)
1487      {
1488         fputs("ERROR: missing the service path\n", stderr);
1489         return ECORE_CALLBACK_RENEW;
1490      }
1491    _tok(args);
1492    path = args;
1493
1494    e = e_connman_service_get(path);
1495    if (e_connman_service_security_get(e, &security))
1496      printf(":::Service %s Security = \"%s\"\n", path, security);
1497    else
1498      fputs("ERROR: can't get service security\n", stderr);
1499    return ECORE_CALLBACK_RENEW;
1500 }
1501
1502 static Eina_Bool
1503 _on_cmd_service_get_passphrase(__UNUSED__ char *cmd, char *args)
1504 {
1505    const char *passphrase, *path;
1506    E_Connman_Element *e;
1507
1508    if (!args)
1509      {
1510         fputs("ERROR: missing the service path\n", stderr);
1511         return ECORE_CALLBACK_RENEW;
1512      }
1513    _tok(args);
1514    path = args;
1515
1516    e = e_connman_service_get(path);
1517    if (e_connman_service_passphrase_get(e, &passphrase))
1518      printf(":::Service %s Passphrase = \"%s\"\n", path, passphrase);
1519    else
1520      fputs("ERROR: can't get service passphrase\n", stderr);
1521    return ECORE_CALLBACK_RENEW;
1522 }
1523
1524 static Eina_Bool
1525 _on_cmd_service_set_passphrase(__UNUSED__ char *cmd, char *args)
1526 {
1527    char *passphrase, *path;
1528    E_Connman_Element *e;
1529
1530    if (!args)
1531      {
1532         fputs("ERROR: missing the service path\n", stderr);
1533         return ECORE_CALLBACK_RENEW;
1534      }
1535    path = args;
1536    passphrase = _tok(args);
1537
1538    if (!passphrase)
1539      {
1540         fputs("ERROR: missing the passphrase value\n", stderr);
1541         return ECORE_CALLBACK_RENEW;
1542      }
1543    _tok(passphrase);
1544
1545    e = e_connman_service_get(path);
1546    if (e_connman_service_passphrase_set
1547        (e, passphrase, _method_success_check, "service_set_passphrase"))
1548      printf(":::Service %s passphrase set to \"%s\"\n", path, passphrase);
1549    else
1550      fputs("ERROR: can't set service passphrase\n", stderr);
1551    return ECORE_CALLBACK_RENEW;
1552 }
1553
1554 static Eina_Bool
1555 _on_cmd_service_get_passphrase_required(__UNUSED__ char *cmd, char *args)
1556 {
1557    const char *path;
1558    Eina_Bool passphrase;
1559    E_Connman_Element *e;
1560
1561    if (!args)
1562      {
1563         fputs("ERROR: missing the service path\n", stderr);
1564         return ECORE_CALLBACK_RENEW;
1565      }
1566    _tok(args);
1567    path = args;
1568
1569    e = e_connman_service_get(path);
1570    if (e_connman_service_passphrase_required_get(e, &passphrase))
1571      printf(":::Service %s Passphrase Required = %hhu\n", path, passphrase);
1572    else
1573      fputs("ERROR: can't get service passphrase required\n", stderr);
1574    return ECORE_CALLBACK_RENEW;
1575 }
1576
1577 static Eina_Bool
1578 _on_cmd_service_get_strength(__UNUSED__ char *cmd, char *args)
1579 {
1580    const char *path;
1581    unsigned char strength;
1582    E_Connman_Element *e;
1583
1584    if (!args)
1585      {
1586         fputs("ERROR: missing the service path\n", stderr);
1587         return ECORE_CALLBACK_RENEW;
1588      }
1589    _tok(args);
1590    path = args;
1591
1592    e = e_connman_service_get(path);
1593    if (e_connman_service_strength_get(e, &strength))
1594      printf(":::Service %s Strength = %#02hhx (%d)\n", path, strength, strength);
1595    else
1596      fputs("ERROR: can't get service strength\n", stderr);
1597    return ECORE_CALLBACK_RENEW;
1598 }
1599
1600 static Eina_Bool
1601 _on_cmd_service_get_favorite(__UNUSED__ char *cmd, char *args)
1602 {
1603    const char *path;
1604    Eina_Bool favorite;
1605    E_Connman_Element *e;
1606
1607    if (!args)
1608      {
1609         fputs("ERROR: missing the service path\n", stderr);
1610         return ECORE_CALLBACK_RENEW;
1611      }
1612    _tok(args);
1613    path = args;
1614
1615    e = e_connman_service_get(path);
1616    if (e_connman_service_favorite_get(e, &favorite))
1617      printf(":::Service %s Favorite = %hhu\n", path, favorite);
1618    else
1619      fputs("ERROR: can't get service favorite\n", stderr);
1620    return ECORE_CALLBACK_RENEW;
1621 }
1622
1623 static Eina_Bool
1624 _on_cmd_service_get_immutable(__UNUSED__ char *cmd, char *args)
1625 {
1626    const char *path;
1627    Eina_Bool immutable;
1628    E_Connman_Element *e;
1629
1630    if (!args)
1631      {
1632         fputs("ERROR: missing the service path\n", stderr);
1633         return ECORE_CALLBACK_RENEW;
1634      }
1635    _tok(args);
1636    path = args;
1637
1638    e = e_connman_service_get(path);
1639    if (e_connman_service_immutable_get(e, &immutable))
1640      printf(":::Service %s Immutable = %hhu\n", path, immutable);
1641    else
1642      fputs("ERROR: can't get service immutable\n", stderr);
1643    return ECORE_CALLBACK_RENEW;
1644 }
1645
1646 static Eina_Bool
1647 _on_cmd_service_get_auto_connect(__UNUSED__ char *cmd, char *args)
1648 {
1649    const char *path;
1650    Eina_Bool auto_connect;
1651    E_Connman_Element *e;
1652
1653    if (!args)
1654      {
1655         fputs("ERROR: missing the service path\n", stderr);
1656         return ECORE_CALLBACK_RENEW;
1657      }
1658    _tok(args);
1659    path = args;
1660
1661    e = e_connman_service_get(path);
1662    if (e_connman_service_auto_connect_get(e, &auto_connect))
1663      printf(":::Service %s Auto Connect = %hhu\n", path, auto_connect);
1664    else
1665      fputs("ERROR: can't get service auto connect\n", stderr);
1666    return ECORE_CALLBACK_RENEW;
1667 }
1668
1669 static Eina_Bool
1670 _on_cmd_service_set_auto_connect(__UNUSED__ char *cmd, char *args)
1671 {
1672    char *path, *next_args;
1673    Eina_Bool auto_connect;
1674    E_Connman_Element *e;
1675
1676    if (!args)
1677      {
1678         fputs("ERROR: missing the service path\n", stderr);
1679         return ECORE_CALLBACK_RENEW;
1680      }
1681    path = args;
1682    next_args = _tok(args);
1683
1684    if (!next_args)
1685      {
1686         fputs("ERROR: missing the auto connect value\n", stderr);
1687         return ECORE_CALLBACK_RENEW;
1688      }
1689    _tok(next_args);
1690    auto_connect = !!atol(next_args);
1691
1692    e = e_connman_service_get(path);
1693    if (e_connman_service_auto_connect_set
1694        (e, auto_connect, _method_success_check, "service_set_auto_connect"))
1695      printf(":::Service %s auto connect set to %d\n", path, auto_connect);
1696    else
1697      fputs("ERROR: can't set service auto connect\n", stderr);
1698    return ECORE_CALLBACK_RENEW;
1699 }
1700
1701 static Eina_Bool
1702 _on_cmd_service_get_setup_required(__UNUSED__ char *cmd, char *args)
1703 {
1704    const char *path;
1705    Eina_Bool setup_required;
1706    E_Connman_Element *e;
1707
1708    if (!args)
1709      {
1710         fputs("ERROR: missing the service path\n", stderr);
1711         return ECORE_CALLBACK_RENEW;
1712      }
1713    _tok(args);
1714    path = args;
1715
1716    e = e_connman_service_get(path);
1717    if (e_connman_service_setup_required_get(e, &setup_required))
1718      printf(":::Service %s Setup Required = %hhu\n", path, setup_required);
1719    else
1720      fputs("ERROR: can't get service setup required\n", stderr);
1721    return ECORE_CALLBACK_RENEW;
1722 }
1723
1724 static Eina_Bool
1725 _on_cmd_service_get_apn(__UNUSED__ char *cmd, char *args)
1726 {
1727    const char *apn, *path;
1728    E_Connman_Element *e;
1729
1730    if (!args)
1731      {
1732         fputs("ERROR: missing the service path\n", stderr);
1733         return ECORE_CALLBACK_RENEW;
1734      }
1735    _tok(args);
1736    path = args;
1737
1738    e = e_connman_service_get(path);
1739    if (e_connman_service_apn_get(e, &apn))
1740      printf(":::Service %s APN = \"%s\"\n", path, apn);
1741    else
1742      fputs("ERROR: can't get service APN\n", stderr);
1743    return ECORE_CALLBACK_RENEW;
1744 }
1745
1746 static Eina_Bool
1747 _on_cmd_service_set_apn(__UNUSED__ char *cmd, char *args)
1748 {
1749    char *apn, *path;
1750    E_Connman_Element *e;
1751
1752    if (!args)
1753      {
1754         fputs("ERROR: missing the service path\n", stderr);
1755         return ECORE_CALLBACK_RENEW;
1756      }
1757    path = args;
1758    apn = _tok(args);
1759
1760    if (!apn)
1761      {
1762         fputs("ERROR: missing the apn value\n", stderr);
1763         return ECORE_CALLBACK_RENEW;
1764      }
1765    _tok(apn);
1766
1767    e = e_connman_service_get(path);
1768    if (e_connman_service_apn_set
1769        (e, apn, _method_success_check, "service_set_apn"))
1770      printf(":::Service %s APN set to \"%s\"\n", path, apn);
1771    else
1772      fputs("ERROR: can't set service APN\n", stderr);
1773    return ECORE_CALLBACK_RENEW;
1774 }
1775
1776 static Eina_Bool
1777 _on_cmd_service_get_mcc(__UNUSED__ char *cmd, char *args)
1778 {
1779    const char *mcc, *path;
1780    E_Connman_Element *e;
1781
1782    if (!args)
1783      {
1784         fputs("ERROR: missing the service path\n", stderr);
1785         return ECORE_CALLBACK_RENEW;
1786      }
1787    _tok(args);
1788    path = args;
1789
1790    e = e_connman_service_get(path);
1791    if (e_connman_service_mcc_get(e, &mcc))
1792      printf(":::Service %s MCC = \"%s\"\n", path, mcc);
1793    else
1794      fputs("ERROR: can't get service MCC\n", stderr);
1795    return ECORE_CALLBACK_RENEW;
1796 }
1797
1798 static Eina_Bool
1799 _on_cmd_service_get_mnc(__UNUSED__ char *cmd, char *args)
1800 {
1801    const char *mnc, *path;
1802    E_Connman_Element *e;
1803
1804    if (!args)
1805      {
1806         fputs("ERROR: missing the service path\n", stderr);
1807         return ECORE_CALLBACK_RENEW;
1808      }
1809    _tok(args);
1810    path = args;
1811
1812    e = e_connman_service_get(path);
1813    if (e_connman_service_mnc_get(e, &mnc))
1814      printf(":::Service %s MNC = \"%s\"\n", path, mnc);
1815    else
1816      fputs("ERROR: can't get service MNC\n", stderr);
1817    return ECORE_CALLBACK_RENEW;
1818 }
1819
1820 static Eina_Bool
1821 _on_cmd_service_get_roaming(__UNUSED__ char *cmd, char *args)
1822 {
1823    const char *path;
1824    Eina_Bool roaming;
1825    E_Connman_Element *e;
1826
1827    if (!args)
1828      {
1829         fputs("ERROR: missing the service path\n", stderr);
1830         return ECORE_CALLBACK_RENEW;
1831      }
1832    _tok(args);
1833    path = args;
1834
1835    e = e_connman_service_get(path);
1836    if (e_connman_service_roaming_get(e, &roaming))
1837      printf(":::Service %s Roaming = %hhu\n", path, roaming);
1838    else
1839      fputs("ERROR: can't get service roaming\n", stderr);
1840    return ECORE_CALLBACK_RENEW;
1841 }
1842
1843 static Eina_Bool
1844 _on_cmd_service_get_ipv4_method(__UNUSED__ char *cmd, char *args)
1845 {
1846    const char *ipv4_method, *path;
1847    E_Connman_Element *e;
1848
1849    if (!args)
1850      {
1851         fputs("ERROR: missing the service path\n", stderr);
1852         return ECORE_CALLBACK_RENEW;
1853      }
1854    _tok(args);
1855    path = args;
1856
1857    e = e_connman_service_get(path);
1858    if (e_connman_service_ipv4_method_get(e, &ipv4_method))
1859      printf(":::Service %s IPv4 Method = \"%s\"\n", path, ipv4_method);
1860    else
1861      fputs("ERROR: can't get service ipv4 method\n", stderr);
1862    return ECORE_CALLBACK_RENEW;
1863 }
1864
1865 static Eina_Bool
1866 _on_cmd_service_get_ipv4_address(__UNUSED__ char *cmd, char *args)
1867 {
1868    const char *ipv4_address, *path;
1869    E_Connman_Element *e;
1870
1871    if (!args)
1872      {
1873         fputs("ERROR: missing the service path\n", stderr);
1874         return ECORE_CALLBACK_RENEW;
1875      }
1876    _tok(args);
1877    path = args;
1878
1879    e = e_connman_service_get(path);
1880    if (e_connman_service_ipv4_address_get(e, &ipv4_address))
1881      printf(":::Service %s IPv4 Address = \"%s\"\n", path, ipv4_address);
1882    else
1883      fputs("ERROR: can't get service ipv4 address\n", stderr);
1884    return ECORE_CALLBACK_RENEW;
1885 }
1886
1887 static Eina_Bool
1888 _on_cmd_service_get_ipv4_gateway(__UNUSED__ char *cmd, char *args)
1889 {
1890    const char *ipv4_gateway, *path;
1891    E_Connman_Element *e;
1892
1893    if (!args)
1894      {
1895         fputs("ERROR: missing the service path\n", stderr);
1896         return ECORE_CALLBACK_RENEW;
1897      }
1898    _tok(args);
1899    path = args;
1900
1901    e = e_connman_service_get(path);
1902    if (e_connman_service_ipv4_gateway_get(e, &ipv4_gateway))
1903      printf(":::Service %s IPv4 Gateway = \"%s\"\n", path, ipv4_gateway);
1904    else
1905      fputs("ERROR: can't get service ipv4 gateway\n", stderr);
1906    return ECORE_CALLBACK_RENEW;
1907 }
1908
1909 static Eina_Bool
1910 _on_cmd_service_get_ipv4_netmask(__UNUSED__ char *cmd, char *args)
1911 {
1912    const char *ipv4_netmask, *path;
1913    E_Connman_Element *e;
1914
1915    if (!args)
1916      {
1917         fputs("ERROR: missing the service path\n", stderr);
1918         return ECORE_CALLBACK_RENEW;
1919      }
1920    _tok(args);
1921    path = args;
1922
1923    e = e_connman_service_get(path);
1924    if (e_connman_service_ipv4_netmask_get(e, &ipv4_netmask))
1925      printf(":::Service %s IPv4 Netmask = \"%s\"\n", path, ipv4_netmask);
1926    else
1927      fputs("ERROR: can't get service ipv4 netmask\n", stderr);
1928    return ECORE_CALLBACK_RENEW;
1929 }
1930
1931 static Eina_Bool
1932 _on_cmd_service_get_ipv4_configuration_method(__UNUSED__ char *cmd, char *args)
1933 {
1934    const char *ipv4_method, *path;
1935    E_Connman_Element *e;
1936
1937    if (!args)
1938      {
1939         fputs("ERROR: missing the service path\n", stderr);
1940         return ECORE_CALLBACK_RENEW;
1941      }
1942    _tok(args);
1943    path = args;
1944
1945    e = e_connman_service_get(path);
1946    if (e_connman_service_ipv4_configuration_method_get(e, &ipv4_method))
1947      printf(":::Service %s IPv4 Configuration Method = \"%s\"\n",
1948             path, ipv4_method);
1949    else
1950      fputs("ERROR: can't get service ipv4_configuration method\n", stderr);
1951    return ECORE_CALLBACK_RENEW;
1952 }
1953
1954 static Eina_Bool
1955 _on_cmd_service_get_ipv4_configuration_address(__UNUSED__ char *cmd, char *args)
1956 {
1957    const char *ipv4_address, *path;
1958    E_Connman_Element *e;
1959
1960    if (!args)
1961      {
1962         fputs("ERROR: missing the service path\n", stderr);
1963         return ECORE_CALLBACK_RENEW;
1964      }
1965    _tok(args);
1966    path = args;
1967
1968    e = e_connman_service_get(path);
1969    if (e_connman_service_ipv4_configuration_address_get(e, &ipv4_address))
1970      printf(":::Service %s IPv4 Configuration Address = \"%s\"\n",
1971             path, ipv4_address);
1972    else
1973      fputs("ERROR: can't get service ipv4_configuration address\n", stderr);
1974    return ECORE_CALLBACK_RENEW;
1975 }
1976
1977 static Eina_Bool
1978 _on_cmd_service_get_ipv4_configuration_gateway(__UNUSED__ char *cmd, char *args)
1979 {
1980    const char *ipv4_gateway, *path;
1981    E_Connman_Element *e;
1982
1983    if (!args)
1984      {
1985         fputs("ERROR: missing the service path\n", stderr);
1986         return ECORE_CALLBACK_RENEW;
1987      }
1988    _tok(args);
1989    path = args;
1990
1991    e = e_connman_service_get(path);
1992    if (e_connman_service_ipv4_configuration_gateway_get(e, &ipv4_gateway))
1993      printf(":::Service %s IPv4 Configuration Gateway = \"%s\"\n",
1994             path, ipv4_gateway);
1995    else
1996      fputs("ERROR: can't get service ipv4_configuration gateway\n", stderr);
1997    return ECORE_CALLBACK_RENEW;
1998 }
1999
2000 static Eina_Bool
2001 _on_cmd_service_get_ipv4_configuration_netmask(__UNUSED__ char *cmd, char *args)
2002 {
2003    const char *ipv4_netmask, *path;
2004    E_Connman_Element *e;
2005
2006    if (!args)
2007      {
2008         fputs("ERROR: missing the service path\n", stderr);
2009         return ECORE_CALLBACK_RENEW;
2010      }
2011    _tok(args);
2012    path = args;
2013
2014    e = e_connman_service_get(path);
2015    if (e_connman_service_ipv4_configuration_netmask_get(e, &ipv4_netmask))
2016      printf(":::Service %s IPv4 Configuration Netmask = \"%s\"\n",
2017             path, ipv4_netmask);
2018    else
2019      fputs("ERROR: can't get service ipv4 configuration netmask\n", stderr);
2020    return ECORE_CALLBACK_RENEW;
2021 }
2022
2023 static Eina_Bool
2024 _on_cmd_service_ipv4_configure_dhcp(__UNUSED__ char *cmd, char *args)
2025 {
2026    char *path;
2027    E_Connman_Element *e;
2028
2029    if (!args)
2030      {
2031         fputs("ERROR: missing the service path\n", stderr);
2032         return ECORE_CALLBACK_RENEW;
2033      }
2034    path = args;
2035    _tok(args);
2036
2037    e = e_connman_service_get(path);
2038    if (e_connman_service_ipv4_configure_dhcp
2039        (e, _method_success_check, "service_ipv4_configure_dhcp"))
2040      printf(":::Service %s IPv4 Configuration set to DHCP\n", path);
2041    else
2042      fputs("ERROR: can't set service ipv4_configuration dhcp\n", stderr);
2043    return ECORE_CALLBACK_RENEW;
2044 }
2045
2046 static Eina_Bool
2047 _on_cmd_service_ipv4_configure_manual(__UNUSED__ char *cmd, char *args)
2048 {
2049    char *path, *next_args, *address, *netmask = NULL, *gateway = NULL;
2050    E_Connman_Element *e;
2051
2052    if (!args)
2053      {
2054         fputs("ERROR: missing the service path\n", stderr);
2055         return ECORE_CALLBACK_RENEW;
2056      }
2057    path = args;
2058    next_args = _tok(args);
2059    if (!next_args)
2060      {
2061         fputs("ERROR: missing the service address\n", stderr);
2062         return ECORE_CALLBACK_RENEW;
2063      }
2064
2065    address = next_args;
2066    next_args = _tok(next_args);
2067    if (next_args)
2068       netmask = next_args;
2069
2070    next_args = _tok(next_args);
2071    if (next_args)
2072      {
2073         gateway = next_args;
2074         _tok(next_args);
2075      }
2076
2077    e = e_connman_service_get(path);
2078    if (e_connman_service_ipv4_configure_manual
2079        (e, address, netmask, gateway,
2080         _method_success_check, "service_ipv4_configure_manual"))
2081      printf(":::Service %s IPv4 Configuration set to Manual (%s/%s) gw %s\n",
2082             path, address, netmask, gateway);
2083    else
2084      fputs("ERROR: can't set service ipv4_configuration manual\n", stderr);
2085    return ECORE_CALLBACK_RENEW;
2086 }
2087
2088 static Eina_Bool
2089 _on_cmd_service_get_ethernet_method(__UNUSED__ char *cmd, char *args)
2090 {
2091    const char *ethernet_method, *path;
2092    E_Connman_Element *e;
2093
2094    if (!args)
2095      {
2096         fputs("ERROR: missing the service path\n", stderr);
2097         return ECORE_CALLBACK_RENEW;
2098      }
2099    _tok(args);
2100    path = args;
2101
2102    e = e_connman_service_get(path);
2103    if (e_connman_service_ethernet_method_get(e, &ethernet_method))
2104      printf(":::Service %s Ethernet Method = \"%s\"\n", path, ethernet_method);
2105    else
2106      fputs("ERROR: can't get service ethernet method\n", stderr);
2107    return ECORE_CALLBACK_RENEW;
2108 }
2109
2110 static Eina_Bool
2111 _on_cmd_service_get_ethernet_address(__UNUSED__ char *cmd, char *args)
2112 {
2113    const char *ethernet_address, *path;
2114    E_Connman_Element *e;
2115
2116    if (!args)
2117      {
2118         fputs("ERROR: missing the service path\n", stderr);
2119         return ECORE_CALLBACK_RENEW;
2120      }
2121    _tok(args);
2122    path = args;
2123
2124    e = e_connman_service_get(path);
2125    if (e_connman_service_ethernet_address_get(e, &ethernet_address))
2126      printf(":::Service %s Ethernet Address = \"%s\"\n",
2127             path, ethernet_address);
2128    else
2129      fputs("ERROR: can't get service ethernet address\n", stderr);
2130    return ECORE_CALLBACK_RENEW;
2131 }
2132
2133 static Eina_Bool
2134 _on_cmd_service_get_ethernet_mtu(__UNUSED__ char *cmd, char *args)
2135 {
2136    const char *path;
2137    E_Connman_Element *e;
2138    unsigned short ethernet_mtu;
2139
2140    if (!args)
2141      {
2142         fputs("ERROR: missing the service path\n", stderr);
2143         return ECORE_CALLBACK_RENEW;
2144      }
2145    _tok(args);
2146    path = args;
2147
2148    e = e_connman_service_get(path);
2149    if (e_connman_service_ethernet_mtu_get(e, &ethernet_mtu))
2150      printf(":::Service %s Ethernet MTU = %hu\n", path, ethernet_mtu);
2151    else
2152      fputs("ERROR: can't get service ethernet mtu\n", stderr);
2153    return ECORE_CALLBACK_RENEW;
2154 }
2155
2156 static Eina_Bool
2157 _on_cmd_service_get_ethernet_netmask(__UNUSED__ char *cmd, char *args)
2158 {
2159    const char *ethernet_netmask, *path;
2160    E_Connman_Element *e;
2161
2162    if (!args)
2163      {
2164         fputs("ERROR: missing the service path\n", stderr);
2165         return ECORE_CALLBACK_RENEW;
2166      }
2167    _tok(args);
2168    path = args;
2169
2170    e = e_connman_service_get(path);
2171    if (e_connman_service_ethernet_netmask_get(e, &ethernet_netmask))
2172      printf(":::Service %s Ethernet Netmask = \"%s\"\n",
2173             path, ethernet_netmask);
2174    else
2175      fputs("ERROR: can't get service ethernet netmask\n", stderr);
2176    return ECORE_CALLBACK_RENEW;
2177 }
2178
2179 static Eina_Bool
2180 _on_cmd_technology_get_devices(__UNUSED__ char *cmd, char *args)
2181 {
2182    E_Connman_Element **devices;
2183    E_Connman_Element *e;
2184    unsigned int count;
2185    char *path;
2186
2187    if (!args)
2188      {
2189         fputs("ERROR: missing the technology path\n", stderr);
2190         return ECORE_CALLBACK_RENEW;
2191      }
2192    _tok(args);
2193    path = args;
2194
2195    e = e_connman_technology_get(path);
2196    if (!e_connman_technology_devices_get(e, &count, &devices))
2197      {
2198         fputs("ERROR: can't get devices\n", stderr);
2199         return ECORE_CALLBACK_RENEW;
2200      }
2201    printf("BEG: all technology devices count = %d\n", count);
2202    _elements_print(devices, count);
2203    return ECORE_CALLBACK_RENEW;
2204 }
2205
2206 static Eina_Bool
2207 _on_cmd_technology_get_state(__UNUSED__ char *cmd, char *args)
2208 {
2209    const char *state, *path;
2210    E_Connman_Element *e;
2211
2212    if (!args)
2213      {
2214         fputs("ERROR: missing the technology path\n", stderr);
2215         return ECORE_CALLBACK_RENEW;
2216      }
2217    _tok(args);
2218    path = args;
2219
2220    e = e_connman_technology_get(path);
2221    if (e_connman_technology_state_get(e, &state))
2222      printf(":::Technology %s State = \"%s\"\n", path, state);
2223    else
2224      fputs("ERROR: can't get technology state\n", stderr);
2225    return ECORE_CALLBACK_RENEW;
2226 }
2227
2228 static Eina_Bool
2229 _on_cmd_technology_get_type(__UNUSED__ char *cmd, char *args)
2230 {
2231    const char *type, *path;
2232    E_Connman_Element *e;
2233
2234    if (!args)
2235      {
2236         fputs("ERROR: missing the technology path\n", stderr);
2237         return ECORE_CALLBACK_RENEW;
2238      }
2239    _tok(args);
2240    path = args;
2241
2242    e = e_connman_technology_get(path);
2243    if (e_connman_technology_type_get(e, &type))
2244      printf(":::Technology %s Type = \"%s\"\n", path, type);
2245    else
2246      fputs("ERROR: can't get technology type\n", stderr);
2247    return ECORE_CALLBACK_RENEW;
2248 }
2249
2250 static Eina_Bool
2251 _on_cmd_technology_get_name(__UNUSED__ char *cmd, char *args)
2252 {
2253    const char *name, *path;
2254    E_Connman_Element *e;
2255
2256    if (!args)
2257      {
2258         fputs("ERROR: missing the technology path\n", stderr);
2259         return ECORE_CALLBACK_RENEW;
2260      }
2261    _tok(args);
2262    path = args;
2263
2264    e = e_connman_technology_get(path);
2265    if (e_connman_technology_name_get(e, &name))
2266      printf(":::Technology %s Name = \"%s\"\n", path, name);
2267    else
2268      fputs("ERROR: can't get technology name\n", stderr);
2269    return ECORE_CALLBACK_RENEW;
2270 }
2271
2272 static Eina_Bool
2273 _on_input(__UNUSED__ void *data, Ecore_Fd_Handler *fd_handler)
2274 {
2275    char buf[256];
2276    char *cmd, *args;
2277    const struct {
2278       const char *cmd;
2279       Eina_Bool (*cb)(char *cmd, char *args);
2280    } *itr, maps[] = {
2281      {"quit", _on_cmd_quit},
2282      {"sync", _on_cmd_sync},
2283      {"get_all", _on_cmd_get_all},
2284      {"print", _on_cmd_print},
2285      {"get_properties", _on_cmd_get_properties},
2286      {"set_property", _on_cmd_property_set},
2287      {"manager_get", _on_cmd_manager_get},
2288      {"manager_get_profiles", _on_cmd_manager_get_profiles},
2289      {"manager_get_services", _on_cmd_manager_get_services},
2290      {"manager_register_agent", _on_cmd_manager_register_agent},
2291      {"manager_unregister_agent", _on_cmd_manager_unregister_agent},
2292      {"manager_get_state", _on_cmd_manager_get_state},
2293      {"manager_get_offline_mode", _on_cmd_manager_get_offline_mode},
2294      {"manager_set_offline_mode", _on_cmd_manager_set_offline_mode},
2295      {"manager_request_scan", _on_cmd_manager_request_scan},
2296      {"manager_technology_enable", _on_cmd_manager_technology_enable},
2297      {"manager_technology_disable", _on_cmd_manager_technology_disable},
2298      {"manager_get_technologies_available", _on_cmd_manager_get_technologies_available},
2299      {"manager_get_technologies_enabled", _on_cmd_manager_get_technologies_enabled},
2300      {"manager_get_technologies_connected", _on_cmd_manager_get_technologies_connected},
2301      {"manager_profile_remove", _on_cmd_manager_profile_remove},
2302      {"manager_profile_get_active", _on_cmd_manager_profile_get_active},
2303      {"manager_profile_set_active", _on_cmd_manager_profile_set_active},
2304      {"device_propose_scan", _on_cmd_device_propose_scan},
2305      {"device_get_address", _on_cmd_device_get_address},
2306      {"device_get_name", _on_cmd_device_get_name},
2307      {"device_get_type", _on_cmd_device_get_type},
2308      {"device_get_interface", _on_cmd_device_get_interface},
2309      {"device_get_powered", _on_cmd_device_get_powered},
2310      {"device_set_powered", _on_cmd_device_set_powered},
2311      {"device_get_scan_interval", _on_cmd_device_get_scan_interval},
2312      {"device_set_scan_interval", _on_cmd_device_set_scan_interval},
2313      {"device_get_scanning", _on_cmd_device_get_scanning},
2314      {"device_get_networks", _on_cmd_device_get_networks},
2315      {"profile_get_name", _on_cmd_profile_get_name},
2316      {"profile_set_name", _on_cmd_profile_set_name},
2317      {"profile_get_offline_mode", _on_cmd_profile_get_offline_mode},
2318      {"profile_set_offline_mode", _on_cmd_profile_set_offline_mode},
2319      {"profile_get_services", _on_cmd_profile_get_services},
2320      {"network_get_address", _on_cmd_network_get_address},
2321      {"network_get_name", _on_cmd_network_get_name},
2322      {"network_get_connected", _on_cmd_network_get_connected},
2323      {"network_get_strength", _on_cmd_network_get_strength},
2324      {"network_get_frequency", _on_cmd_network_get_frequency},
2325      {"network_get_device", _on_cmd_network_get_device},
2326      {"network_get_wifi_ssid", _on_cmd_network_get_wifi_ssid},
2327      {"network_get_wifi_mode", _on_cmd_network_get_wifi_mode},
2328      {"network_get_wifi_security", _on_cmd_network_get_wifi_security},
2329      {"network_get_wifi_passphrase", _on_cmd_network_get_wifi_passphrase},
2330      {"network_get_wifi_channel", _on_cmd_network_get_wifi_channel},
2331      {"network_get_wifi_eap", _on_cmd_network_get_wifi_eap},
2332      {"service_connect", _on_cmd_service_connect},
2333      {"service_disconnect", _on_cmd_service_disconnect},
2334      {"service_remove", _on_cmd_service_remove},
2335      {"service_move_before", _on_cmd_service_move_before},
2336      {"service_move_after", _on_cmd_service_move_after},
2337      {"service_get_state", _on_cmd_service_get_state},
2338      {"service_get_error", _on_cmd_service_get_error},
2339      {"service_get_name", _on_cmd_service_get_name},
2340      {"service_get_type", _on_cmd_service_get_type},
2341      {"service_get_mode", _on_cmd_service_get_mode},
2342      {"service_get_security", _on_cmd_service_get_security},
2343      {"service_get_passphrase", _on_cmd_service_get_passphrase},
2344      {"service_set_passphrase", _on_cmd_service_set_passphrase},
2345      {"service_get_passphrase_required", _on_cmd_service_get_passphrase_required},
2346      {"service_get_strength", _on_cmd_service_get_strength},
2347      {"service_get_favorite", _on_cmd_service_get_favorite},
2348      {"service_get_immutable", _on_cmd_service_get_immutable},
2349      {"service_get_auto_connect", _on_cmd_service_get_auto_connect},
2350      {"service_set_auto_connect", _on_cmd_service_set_auto_connect},
2351      {"service_get_setup_required", _on_cmd_service_get_setup_required},
2352      {"service_get_apn", _on_cmd_service_get_apn},
2353      {"service_set_apn", _on_cmd_service_set_apn},
2354      {"service_get_mcc", _on_cmd_service_get_mcc},
2355      {"service_get_mnc", _on_cmd_service_get_mnc},
2356      {"service_get_roaming", _on_cmd_service_get_roaming},
2357      {"service_get_ipv4_method", _on_cmd_service_get_ipv4_method},
2358      {"service_get_ipv4_address", _on_cmd_service_get_ipv4_address},
2359      {"service_get_ipv4_gateway", _on_cmd_service_get_ipv4_gateway},
2360      {"service_get_ipv4_netmask", _on_cmd_service_get_ipv4_netmask},
2361      {"service_get_ipv4_configuration_method", _on_cmd_service_get_ipv4_configuration_method},
2362      {"service_get_ipv4_configuration_address", _on_cmd_service_get_ipv4_configuration_address},
2363      {"service_get_ipv4_configuration_gateway", _on_cmd_service_get_ipv4_configuration_gateway},
2364      {"service_get_ipv4_configuration_netmask", _on_cmd_service_get_ipv4_configuration_netmask},
2365      {"service_ipv4_configure_dhcp", _on_cmd_service_ipv4_configure_dhcp},
2366      {"service_ipv4_configure_manual", _on_cmd_service_ipv4_configure_manual},
2367      {"service_get_ethernet_method", _on_cmd_service_get_ethernet_method},
2368      {"service_get_ethernet_address", _on_cmd_service_get_ethernet_address},
2369      {"service_get_ethernet_mtu", _on_cmd_service_get_ethernet_mtu},
2370      {"service_get_ethernet_netmask", _on_cmd_service_get_ethernet_netmask},
2371      {"technology_get_devices", _on_cmd_technology_get_devices},
2372      {"technology_get_state", _on_cmd_technology_get_state},
2373      {"technology_get_type", _on_cmd_technology_get_type},
2374      {"technology_get_name", _on_cmd_technology_get_name},
2375      {NULL, NULL}
2376    };
2377
2378
2379    if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR))
2380      {
2381         fputs("ERROR: reading from stdin, exit\n", stderr);
2382         return ECORE_CALLBACK_CANCEL;
2383      }
2384
2385    if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
2386      {
2387         fputs("ERROR: nothing to read?\n", stderr);
2388         return ECORE_CALLBACK_CANCEL;
2389      }
2390
2391    if (!fgets(buf, sizeof(buf), stdin))
2392      {
2393         fprintf(stderr, "ERROR: could not read command: %s\n", strerror(errno));
2394         ecore_main_loop_quit();
2395         return ECORE_CALLBACK_CANCEL;
2396      }
2397
2398    cmd = buf;
2399    while (isspace(*cmd))
2400      cmd++;
2401
2402    args = strchr(cmd, ' ');
2403    if (args)
2404      {
2405         char *p;
2406
2407         *args = '\0';
2408         args++;
2409
2410         while (isspace(*args))
2411           args++;
2412
2413         p = args + strlen(args) - 1;
2414         if (*p == '\n')
2415           *p = '\0';
2416      }
2417    else
2418      {
2419         char *p;
2420
2421         p = cmd + strlen(cmd) - 1;
2422         if (*p == '\n')
2423           *p = '\0';
2424      }
2425
2426    if (strcmp(cmd, "help") == 0)
2427      {
2428         if (args)
2429           {
2430              printf("Commands with '%s' in the name:\n", args);
2431              for (itr = maps; itr->cmd; itr++)
2432                if (strstr(itr->cmd, args))
2433                  printf("\t%s\n", itr->cmd);
2434           }
2435         else
2436           {
2437              fputs("Commands:\n", stdout);
2438              for (itr = maps; itr->cmd; itr++)
2439                printf("\t%s\n", itr->cmd);
2440           }
2441         fputc('\n', stdout);
2442         return ECORE_CALLBACK_RENEW;
2443      }
2444
2445    for (itr = maps; itr->cmd; itr++)
2446      if (strcmp(itr->cmd, cmd) == 0)
2447        return itr->cb(cmd, args);
2448
2449    printf("unknown command \"%s\", args=%s\n", cmd, args);
2450    return ECORE_CALLBACK_RENEW;
2451 }
2452
2453 int
2454 main(__UNUSED__ int argc, __UNUSED__ char *argv[])
2455 {
2456    E_DBus_Connection *c;
2457
2458    ecore_init();
2459    e_dbus_init();
2460    eina_init();
2461
2462    c = e_dbus_bus_get(DBUS_BUS_SYSTEM);
2463    if (!c) {
2464       printf("ERROR: can't connect to system session\n");
2465       return -1;
2466    }
2467
2468    e_connman_system_init(c);
2469    ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_ADD, _on_element_add, NULL);
2470    ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_DEL, _on_element_del, NULL);
2471    ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_UPDATED,
2472                            _on_element_updated, NULL);
2473
2474    ecore_main_fd_handler_add
2475      (0, ECORE_FD_READ | ECORE_FD_ERROR, _on_input, NULL, NULL, NULL);
2476
2477    ecore_main_loop_begin();
2478
2479    e_connman_system_shutdown();
2480
2481    e_dbus_connection_close(c);
2482    eina_shutdown();
2483    e_dbus_shutdown();
2484    ecore_shutdown();
2485
2486    fputs("DBG: clean exit.\n", stderr);
2487
2488    return 0;
2489 }