connman: update to latest server API.
[framework/uifw/edbus.git] / src / bin / e_dbus_connman_test.c
1 #include "E_Connman.h"
2 #include <stdio.h>
3 #include <string.h>
4 #include <ctype.h>
5 #include <errno.h>
6
7 static void
8 _elements_print(E_Connman_Element **elements, int count)
9 {
10    int i;
11    for (i = 0; i < count; i++)
12      {
13         printf("--- element %d:\n", i);
14         e_connman_element_print(stdout, elements[i]);
15      }
16    free(elements);
17    printf("END: all elements count = %d\n", count);
18 }
19
20 static int
21 _on_element_add(void *data, int type, void *info)
22 {
23    E_Connman_Element *element = info;
24    printf(">>> %s\n", element->path);
25    return 1;
26 }
27
28 static int
29 _on_element_del(void *data, int type, void *info)
30 {
31    E_Connman_Element *element = info;
32    printf("<<< %s\n", element->path);
33    return 1;
34 }
35
36 static int
37 _on_element_updated(void *data, int type, void *info)
38 {
39    E_Connman_Element *element = info;
40    printf("!!! %s\n", element->path);
41    e_connman_element_print(stderr, element);
42    return 1;
43 }
44
45 static int
46 _on_cmd_quit(char *cmd, char *args)
47 {
48    fputs("Bye!\n", stderr);
49    ecore_main_loop_quit();
50    return 0;
51 }
52
53 static int
54 _on_cmd_sync(char *cmd, char *args)
55 {
56    e_connman_manager_sync_elements();
57    return 1;
58 }
59
60 static char *
61 _tok(char *p)
62 {
63    p = strchr(p, ' ');
64    if (!p)
65      return NULL;
66
67    *p = '\0';
68    p++;
69    while (isspace(*p))
70      p++;
71    if (*p == '\0')
72      return NULL;
73
74    return p;
75 }
76
77 static int
78 _on_cmd_get_all(char *cmd, char *args)
79 {
80    E_Connman_Element **elements;
81    char *type;
82    unsigned int count;
83    bool ret;
84
85    if (!args)
86      type = NULL;
87    else
88      type = args;
89
90    if (type)
91      ret = e_connman_elements_get_all_type(type, &count, &elements);
92    else
93      ret = e_connman_elements_get_all(&count, &elements);
94
95    if (!ret)
96      fputs("ERROR: could not get elements\n", stderr);
97    else
98      {
99         printf("BEG: all elements type=%s count = %d\n", type, count);
100         _elements_print(elements, count);
101      }
102
103    return 1;
104 }
105
106 static E_Connman_Element *
107 _element_from_args(char *args, char **next_args)
108 {
109    E_Connman_Element *element;
110
111    if (!args)
112      {
113         fputs("ERROR: missing element path\n", stderr);
114         *next_args = NULL;
115         return NULL;
116      }
117
118    *next_args = _tok(args);
119    element = e_connman_element_get(args);
120    if (!element)
121      fprintf(stderr, "ERROR: no element called \"%s\".\n", args);
122
123    return element;
124 }
125
126 static int
127 _on_cmd_print(char *cmd, char *args)
128 {
129    char *next_args;
130    E_Connman_Element *element = _element_from_args(args, &next_args);
131    if (element)
132      e_connman_element_print(stdout, element);
133    return 1;
134 }
135
136 static int
137 _on_cmd_get_properties(char *cmd, char *args)
138 {
139    char *next_args;
140    E_Connman_Element *element = _element_from_args(args, &next_args);
141    if (element)
142      e_connman_element_properties_sync(element);
143    return 1;
144 }
145
146 static int
147 _on_cmd_property_set(char *cmd, char *args)
148 {
149    char *next_args, *name, *p;
150    E_Connman_Element *element = _element_from_args(args, &next_args);
151    void *value;
152    long vlong;
153    unsigned short vu16;
154    unsigned int vu32;
155    int type;
156
157    if (!element)
158      return 1;
159
160    if (!next_args)
161      {
162         fputs("ERROR: missing parameters name, type and value.\n", stderr);
163         return 1;
164      }
165
166    name = next_args;
167    p = _tok(name);
168    if (!p)
169      {
170         fputs("ERROR: missing parameters type and value.\n", stderr);
171         return 1;
172      }
173
174    next_args = _tok(p);
175    if (!next_args)
176      {
177         fputs("ERROR: missing parameter value.\n", stderr);
178         return 1;
179      }
180
181    type = p[0];
182    switch (type)
183      {
184       case DBUS_TYPE_BOOLEAN:
185          vlong = !!atol(next_args);
186          value = (void *)vlong;
187          fprintf(stderr, "DBG: boolean is: %ld\n", vlong);
188          break;
189       case DBUS_TYPE_UINT16:
190          vu16 = strtol(next_args, &p, 0);
191          if (p == next_args)
192            {
193               fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
194               return 1;
195            }
196          value = &vu16;
197          fprintf(stderr, "DBG: u16 is: %hu\n", vu16);
198          break;
199       case DBUS_TYPE_UINT32:
200          vu32 = strtol(next_args, &p, 0);
201          if (p == next_args)
202            {
203               fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
204               return 1;
205            }
206          value = &vu32;
207          fprintf(stderr, "DBG: u16 is: %u\n", vu32);
208          break;
209       case DBUS_TYPE_STRING:
210       case DBUS_TYPE_OBJECT_PATH:
211          p = next_args + strlen(next_args);
212          if (p > next_args)
213            p--;
214          while (p > next_args && isspace(*p))
215            p--;
216          if (p <= next_args)
217            {
218               fprintf(stderr, "ERROR: invalid string \"%s\".\n", next_args);
219            }
220          p[1] = '\0';
221          value = next_args;
222          fprintf(stderr, "DBG: string is: \"%s\"\n", next_args);
223          break;
224       default:
225          fprintf(stderr, "ERROR: don't know how to parse type '%c' (%d)\n",
226                  type, type);
227          return 1;
228      }
229
230    fprintf(stderr, "set_property %s [%p] %s %c %p...\n",
231            args, element, name, type, value);
232    if (!e_connman_element_property_set(element, name, type, value))
233      {
234         fputs("ERROR: error setting property.\n", stderr);
235         return 1;
236      }
237    return 1;
238 }
239
240
241 /* Manager Commands */
242
243 static int
244 _on_cmd_manager_get(char *cmd, char *args)
245 {
246    E_Connman_Element *element;
247    element = e_connman_manager_get();
248    e_connman_element_print(stderr, element);
249    return 1;
250 }
251
252 static int
253 _on_cmd_manager_get_profiles(char *cmd, char *args)
254 {
255    unsigned int count;
256    E_Connman_Element **profiles;
257
258    if (!e_connman_manager_profiles_get(&count, &profiles))
259      {
260         fputs("ERROR: can't get profiles\n", stderr);
261         return 1;
262      }
263    printf("BEG: all manager profiles elements count = %d\n", count);
264    _elements_print(profiles, count);
265    return 1;
266 }
267
268 static int
269 _on_cmd_manager_get_devices(char *cmd, char *args)
270 {
271    unsigned int count;
272    E_Connman_Element **devices;
273
274    if (!e_connman_manager_devices_get(&count, &devices))
275      {
276         fputs("ERROR: can't get devices\n", stderr);
277         return 1;
278      }
279    printf("BEG: all manager devices elements count = %d\n", count);
280    _elements_print(devices, count);
281    return 1;
282 }
283
284 static int
285 _on_cmd_manager_get_services(char *cmd, char *args)
286 {
287    unsigned int count;
288    E_Connman_Element **services;
289
290    if (!e_connman_manager_services_get(&count, &services))
291      {
292         fputs("ERROR: can't get services\n", stderr);
293         return 1;
294      }
295    printf("BEG: all manager services elements count = %d\n", count);
296    _elements_print(services, count);
297    return 1;
298 }
299
300 static int
301 _on_cmd_manager_register_agent(char *cmd, char *args)
302 {
303    char *path;
304
305    if (!args)
306      {
307         fputs("ERROR: missing the object path\n", stderr);
308         return 1;
309      }
310
311    path = args;
312    if (e_connman_manager_agent_register(path, NULL, NULL))
313      printf(":::Registering agent %s...\n", path);
314    else
315      fprintf(stderr, "ERROR: can't register agent %s\n", path);
316
317    return 1;
318 }
319
320 static int
321 _on_cmd_manager_unregister_agent(char *cmd, char *args)
322 {
323    char *path;
324
325    if (!args)
326      {
327         fputs("ERROR: missing the object path\n", stderr);
328         return 1;
329      }
330
331    path = args;
332    if (e_connman_manager_agent_unregister(path, NULL, NULL))
333      printf(":::Unregistering agent %s...\n", path);
334    else
335      fprintf(stderr, "ERROR: can't unregister agent %s\n", path);
336
337    return 1;
338 }
339
340 static int
341 _on_cmd_manager_get_state(char *cmd, char *args)
342 {
343    const char *state;
344    if (e_connman_manager_state_get(&state))
345      printf(":::Manager state = \"%s\"\n", state);
346    else
347      fputs("ERROR: can't get manager state\n", stderr);
348    return 1;
349 }
350
351 static int
352 _on_cmd_manager_get_offline_mode(char *cmd, char *args)
353 {
354    bool offline;
355    if (e_connman_manager_offline_mode_get(&offline))
356      printf(":::Manager Offline Mode = %hhu\n", offline);
357    else
358      fputs("ERROR: can't get manager offline mode\n", stderr);
359    return 1;
360 }
361
362 static int
363 _on_cmd_manager_set_offline_mode(char *cmd, char *args)
364 {
365    bool offline;
366    if (!args)
367      {
368         fputs("ERROR: missing the offline mode value\n", stderr);
369         return 1;
370      }
371    _tok(args);
372    offline = !!atol(args);
373    if (e_connman_manager_offline_mode_set(offline, NULL, NULL))
374      printf(":::Manager Offline Mode set to %hhu\n", offline);
375    else
376      fputs("ERROR: can't set manager offline mode\n", stderr);
377    return 1;
378 }
379
380 /* Device Commands */
381 static int
382 _on_cmd_device_propose_scan(char *cmd, char *args)
383 {
384    char *path;
385    E_Connman_Element *e;
386
387    if (!args)
388      {
389         fputs("ERROR: missing the device path\n", stderr);
390         return 1;
391      }
392    _tok(args);
393    path = args;
394
395    e = e_connman_device_get(path);
396    if (e_connman_device_propose_scan(e, NULL, NULL))
397      printf(":::Proposing scan %s...\n", path);
398    else
399      fputs("ERROR: can't propose scan\n", stderr);
400    return 1;
401 }
402
403 static int
404 _on_cmd_device_get_name(char *cmd, char *args)
405 {
406    const char *name, *path;
407    E_Connman_Element *e;
408
409    if (!args)
410      {
411         fputs("ERROR: missing the device path\n", stderr);
412         return 1;
413      }
414    _tok(args);
415    path = args;
416
417    e = e_connman_device_get(path);
418    if (e_connman_device_name_get(e, &name))
419      printf(":::Device %s Name = \"%s\"\n", path, name);
420    else
421      fputs("ERROR: can't get device name\n", stderr);
422    return 1;
423 }
424
425 static int
426 _on_cmd_device_get_type(char *cmd, char *args)
427 {
428    const char *type, *path;
429    E_Connman_Element *e;
430
431    if (!args)
432      {
433         fputs("ERROR: missing the device path\n", stderr);
434         return 1;
435      }
436    _tok(args);
437    path = args;
438
439    e = e_connman_device_get(path);
440    if (e_connman_device_type_get(e, &type))
441      printf(":::Device %s Type = \"%s\"\n", path, type);
442    else
443      fputs("ERROR: can't get device type\n", stderr);
444    return 1;
445 }
446
447 static int
448 _on_cmd_device_get_interface(char *cmd, char *args)
449 {
450    const char *interface, *path;
451    E_Connman_Element *e;
452
453    if (!args)
454      {
455         fputs("ERROR: missing the device path\n", stderr);
456         return 1;
457      }
458    _tok(args);
459    path = args;
460
461    e = e_connman_device_get(path);
462    if (e_connman_device_interface_get(e, &interface))
463      printf(":::Device %s Interface = \"%s\"\n", path, interface);
464    else
465      fputs("ERROR: can't get device interface\n", stderr);
466    return 1;
467 }
468
469 static int
470 _on_cmd_device_get_powered(char *cmd, char *args)
471 {
472    char *path;
473    bool powered;
474    E_Connman_Element *e;
475
476    if (!args)
477      {
478         fputs("ERROR: missing the device path\n", stderr);
479         return 1;
480      }
481    _tok(args);
482    path = args;
483
484    e = e_connman_device_get(path);
485    if (e_connman_device_powered_get(e, &powered))
486      printf(":::Device %s Powered = %hhu\n", path, powered);
487    else
488      fputs("ERROR: can't get device powered\n", stderr);
489    return 1;
490 }
491
492 static int
493 _on_cmd_device_set_powered(char *cmd, char *args)
494 {
495    char *device_path, *next_args;
496    bool powered;
497    E_Connman_Element *e;
498
499    if (!args)
500      {
501         fputs("ERROR: missing the device path\n", stderr);
502         return 1;
503      }
504    device_path = args;
505    next_args = _tok(args);
506    if (!next_args)
507      {
508         fputs("ERROR: missing the powered value\n", stderr);
509         return 1;
510      }
511    powered = !!atol(next_args);
512
513    e = e_connman_device_get(device_path);
514    if (e_connman_device_powered_set(e, powered, NULL, NULL))
515      printf(":::Device %s powered set to %hhu\n", device_path, powered);
516    else
517      fputs("ERROR: can't set device powered\n", stderr);
518    return 1;
519 }
520
521 static int
522 _on_cmd_device_get_scan_interval(char *cmd, char *args)
523 {
524    char *path;
525    unsigned short scan_interval;
526    E_Connman_Element *e;
527
528    if (!args)
529      {
530         fputs("ERROR: missing the device path\n", stderr);
531         return 1;
532      }
533    _tok(args);
534    path = args;
535
536    e = e_connman_device_get(path);
537    if (e_connman_device_scan_interval_get(e, &scan_interval))
538      printf(":::Device %s ScanInterval = %hu\n", path, scan_interval);
539    else
540      fputs("ERROR: can't get device scan interval\n", stderr);
541    return 1;
542 }
543
544 static int
545 _on_cmd_device_set_scan_interval(char *cmd, char *args)
546 {
547    char *device_path, *next_args, *p;
548    unsigned short scan_interval;
549    E_Connman_Element *e;
550
551    if (!args)
552      {
553         fputs("ERROR: missing the device path\n", stderr);
554         return 1;
555      }
556    device_path = args;
557    next_args = _tok(args);
558    if (!next_args)
559      {
560         fputs("ERROR: missing the scan interval value\n", stderr);
561         return 1;
562      }
563    scan_interval = strtol(next_args, &p, 0);
564    if (p == next_args)
565      {
566         fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args);
567         return 1;
568      }
569
570    e = e_connman_device_get(device_path);
571    if (e_connman_device_scan_interval_set(e, scan_interval, NULL, NULL))
572      printf(":::Device %s scan interval set to %hu\n", device_path, scan_interval);
573    else
574      fputs("ERROR: can't set device scan interval\n", stderr);
575    return 1;
576 }
577
578 static int
579 _on_cmd_device_get_scanning(char *cmd, char *args)
580 {
581    char *path;
582    bool scanning;
583    E_Connman_Element *e;
584
585    if (!args)
586      {
587         fputs("ERROR: missing the device path\n", stderr);
588         return 1;
589      }
590    _tok(args);
591    path = args;
592
593    e = e_connman_device_get(path);
594    if (e_connman_device_scanning_get(e, &scanning))
595      printf(":::Device %s Scanning = %hhu\n", path, scanning);
596    else
597      fputs("ERROR: can't get device scanning\n", stderr);
598    return 1;
599 }
600
601 static int
602 _on_cmd_device_get_networks(char *cmd, char *args)
603 {
604    E_Connman_Element **networks;
605    unsigned int count;
606    char *path;
607    E_Connman_Element *e;
608
609    if (!args)
610      {
611         fputs("ERROR: missing the device path\n", stderr);
612         return 1;
613      }
614    _tok(args);
615    path = args;
616
617    e = e_connman_device_get(path);
618    if (!e_connman_device_networks_get(e, &count, &networks))
619      {
620         fputs("ERROR: can't get networks\n", stderr);
621         return 1;
622      }
623
624    printf("BEG: all device network elements count = %d\n", count);
625    _elements_print(networks, count);
626    return 1;
627 }
628
629 /* Profile Commands */
630
631 static int
632 _on_cmd_profile_get_name(char *cmd, char *args)
633 {
634    const char *name, *path;
635    E_Connman_Element *e;
636
637    if (!args)
638      {
639         fputs("ERROR: missing the profile path\n", stderr);
640         return 1;
641      }
642    _tok(args);
643    path = args;
644
645    e = e_connman_profile_get(path);
646    if (e_connman_profile_name_get(e, &name))
647      printf(":::Profile %s Name = \"%s\"\n", path, name);
648    else
649      fputs("ERROR: can't get profile name\n", stderr);
650    return 1;
651 }
652
653 static int
654 _on_cmd_profile_get_offline_mode(char *cmd, char *args)
655 {
656    char *path;
657    bool offline;
658    E_Connman_Element *e;
659
660    if (!args)
661      {
662         fputs("ERROR: missing the profile path\n", stderr);
663         return 1;
664      }
665    _tok(args);
666    path = args;
667
668    e = e_connman_profile_get(path);
669    if (e_connman_profile_offline_mode_get(e, &offline))
670      printf(":::Profile  %s Offline Mode = %hhu\n", path, offline);
671    else
672      fputs("ERROR: can't get profile offline mode\n", stderr);
673    return 1;
674 }
675
676 static int
677 _on_cmd_profile_set_offline_mode(char *cmd, char *args)
678 {
679    char *path, *next_args;
680    bool offline;
681    E_Connman_Element *e;
682
683    if (!args)
684      {
685         fputs("ERROR: missing the profile path\n", stderr);
686         return 1;
687      }
688    path = args;
689    next_args = _tok(args);
690    if (!next_args)
691      {
692         fputs("ERROR: missing the offline mode value\n", stderr);
693         return 1;
694      }
695    _tok(next_args);
696    offline = !!atol(next_args);
697
698    e = e_connman_profile_get(path);
699    if (e_connman_profile_offline_mode_set(e, offline, NULL, NULL))
700      printf(":::Profile %s Offline Mode set to %hhu\n", path, offline);
701    else
702      fputs("ERROR: can't set profile offline mode\n", stderr);
703    return 1;
704 }
705
706 static int
707 _on_cmd_profile_get_services(char *cmd, char *args)
708 {
709    E_Connman_Element **services;
710    E_Connman_Element *e;
711    unsigned int count;
712    char *path;
713
714    if (!args)
715      {
716         fputs("ERROR: missing the profile path\n", stderr);
717         return 1;
718      }
719    _tok(args);
720    path = args;
721
722    e = e_connman_profile_get(path);
723    if (!e_connman_profile_services_get(e, &count, &services))
724      {
725         fputs("ERROR: can't get services\n", stderr);
726         return 1;
727      }
728    printf("BEG: all profile services count = %d\n", count);
729    _elements_print(services, count);
730    return 1;
731 }
732
733
734 /* Network Commands */
735
736 static int
737 _on_cmd_network_get_name(char *cmd, char *args)
738 {
739    const char *name, *path;
740    E_Connman_Element *e;
741
742    if (!args)
743      {
744         fputs("ERROR: missing the network path\n", stderr);
745         return 1;
746      }
747    _tok(args);
748    path = args;
749
750    e = e_connman_network_get(path);
751    if (e_connman_network_name_get(e, &name))
752      printf(":::Network %s Name = \"%s\"\n", path, name);
753    else
754      fputs("ERROR: can't get network name\n", stderr);
755    return 1;
756 }
757
758 static int
759 _on_cmd_network_get_connected(char *cmd, char *args)
760 {
761    char *path;
762    bool connected;
763    E_Connman_Element *e;
764
765    if (!args)
766      {
767         fputs("ERROR: missing the network path\n", stderr);
768         return 1;
769      }
770    _tok(args);
771    path = args;
772
773    e = e_connman_network_get(path);
774    if (e_connman_network_connected_get(e, &connected))
775      printf(":::Network %s Connected = %hhu\n", path, connected);
776    else
777      fputs("ERROR: can't get network connected\n", stderr);
778    return 1;
779 }
780
781 static int
782 _on_cmd_network_get_strength(char *cmd, char *args)
783 {
784    char *path;
785    unsigned char strength;
786    E_Connman_Element *e;
787
788    if (!args)
789      {
790         fputs("ERROR: missing the network path\n", stderr);
791         return 1;
792      }
793    _tok(args);
794    path = args;
795
796    e = e_connman_network_get(path);
797    if (e_connman_network_strength_get(e, &strength))
798      printf(":::Network %s Strength = %#02hhx (%d)\n", path, strength, strength);
799    else
800      fputs("ERROR: can't get network strength\n", stderr);
801    return 1;
802 }
803
804 static int
805 _on_cmd_network_get_device(char *cmd, char *args)
806 {
807    E_Connman_Element *e, *device;
808    char *path;
809
810    if (!args)
811      {
812         fputs("ERROR: missing the network path\n", stderr);
813         return 1;
814      }
815    _tok(args);
816    path = args;
817
818    e = e_connman_network_get(path);
819    if (!e_connman_network_device_get(e, &device))
820      fputs("ERROR: can't get network device\n", stderr);
821    else
822      e_connman_element_print(stderr, device);
823    return 1;
824 }
825
826 static int
827 _on_cmd_network_get_wifi_ssid(char *cmd, char *args)
828 {
829    unsigned char *bytes;
830    char *path;
831    unsigned int i, count;
832    E_Connman_Element *e;
833
834    if (!args)
835      {
836         fputs("ERROR: missing the network path\n", stderr);
837         return 1;
838      }
839    _tok(args);
840    path = args;
841
842    e = e_connman_network_get(path);
843    if (e_connman_network_wifi_ssid_get(e, &count, &bytes))
844      {
845         printf(":::Network %s Wifi SSID = ", path);
846         for (i = 0; i < count; i++)
847           printf("%#02hhx (\"%c\"), ", bytes[i], bytes[i]);
848         printf("\n");
849      }
850    else
851      fputs("ERROR: can't get network wifi ssid\n", stderr);
852    return 1;
853 }
854
855 static int
856 _on_cmd_network_get_wifi_mode(char *cmd, char *args)
857 {
858    const char *wifi_mode, *path;
859    E_Connman_Element *e;
860
861    if (!args)
862      {
863         fputs("ERROR: missing the network path\n", stderr);
864         return 1;
865      }
866    _tok(args);
867    path = args;
868
869    e = e_connman_network_get(path);
870    if (e_connman_network_wifi_mode_get(e, &wifi_mode))
871      printf(":::Network %s Wifi Mode = \"%s\"\n", path, wifi_mode);
872    else
873      fputs("ERROR: can't get network wifi mode\n", stderr);
874    return 1;
875 }
876
877 static int
878 _on_cmd_network_get_wifi_security(char *cmd, char *args)
879 {
880    const char *wifi_security, *path;
881    E_Connman_Element *e;
882
883    if (!args)
884      {
885         fputs("ERROR: missing the network path\n", stderr);
886         return 1;
887      }
888    _tok(args);
889    path = args;
890
891    e = e_connman_network_get(path);
892    if (e_connman_network_wifi_security_get(e, &wifi_security))
893      printf(":::Network %s Wifi Security = \"%s\"\n", path, wifi_security);
894    else
895      fputs("ERROR: can't get network wifi security\n", stderr);
896    return 1;
897 }
898
899 static int
900 _on_cmd_network_get_wifi_passphrase(char *cmd, char *args)
901 {
902    const char *wifi_passphrase, *path;
903    E_Connman_Element *e;
904
905    if (!args)
906      {
907         fputs("ERROR: missing the network path\n", stderr);
908         return 1;
909      }
910    _tok(args);
911    path = args;
912
913    e = e_connman_network_get(path);
914    if (e_connman_network_wifi_passphrase_get(e, &wifi_passphrase))
915      printf(":::Network %s Wifi Passphrase = \"%s\"\n", path, wifi_passphrase);
916    else
917      fputs("ERROR: can't get network wifi passphrase\n", stderr);
918    return 1;
919 }
920
921 /* Services Commands */
922 static int
923 _on_cmd_service_connect(char *cmd, char *args)
924 {
925    char *path;
926    E_Connman_Element *e;
927
928    if (!args)
929      {
930         fputs("ERROR: missing the service path\n", stderr);
931         return 1;
932      }
933    _tok(args);
934    path = args;
935
936    e = e_connman_service_get(path);
937    if (e_connman_service_connect(e, NULL, NULL))
938      printf(":::Connecting to Service %s...\n", path);
939    else
940      fputs("ERROR: can't connect to service\n", stderr);
941    return 1;
942 }
943
944 static int
945 _on_cmd_service_disconnect(char *cmd, char *args)
946 {
947    char *path;
948    E_Connman_Element *e;
949
950    if (!args)
951      {
952         fputs("ERROR: missing the service path\n", stderr);
953         return 1;
954      }
955    _tok(args);
956    path = args;
957
958    e = e_connman_service_get(path);
959    if (e_connman_service_disconnect(e, NULL, NULL))
960      printf(":::Disconnecting Service %s...\n", path);
961    else
962      fputs("ERROR: can't disconnect service\n", stderr);
963    return 1;
964 }
965
966 static int
967 _on_cmd_service_remove(char *cmd, char *args)
968 {
969    char *path;
970    E_Connman_Element *e;
971
972    if (!args)
973      {
974         fputs("ERROR: missing the service path\n", stderr);
975         return 1;
976      }
977    _tok(args);
978    path = args;
979
980    e = e_connman_service_get(path);
981    if (e_connman_service_remove(e, NULL, NULL))
982      printf(":::Removing Service %s...\n", path);
983    else
984      fputs("ERROR: can't remove service\n", stderr);
985    return 1;
986 }
987
988 static int
989 _on_cmd_service_move_before(char *cmd, char *args)
990 {
991    char *path, *service_path;
992    E_Connman_Element *e;
993
994    if (!args)
995      {
996         fputs("ERROR: missing the service path\n", stderr);
997         return 1;
998      }
999    service_path = args;
1000    path = _tok(args);
1001
1002    if (!path)
1003      {
1004         fputs("ERROR: missing the object service\n", stderr);
1005         return 1;
1006      }
1007    _tok(path);
1008
1009    e = e_connman_service_get(service_path);
1010    if (e_connman_service_move_before(e, path, NULL, NULL))
1011      printf(":::Moving before %s...\n", path);
1012    else
1013      fputs("ERROR: can't move before\n", stderr);
1014    return 1;
1015 }
1016
1017 static int
1018 _on_cmd_service_move_after(char *cmd, char *args)
1019 {
1020    char *path, *service_path;
1021    E_Connman_Element *e;
1022
1023    if (!args)
1024      {
1025         fputs("ERROR: missing the service path\n", stderr);
1026         return 1;
1027      }
1028    service_path = args;
1029    path = _tok(args);
1030
1031    if (!path)
1032      {
1033         fputs("ERROR: missing the object service\n", stderr);
1034         return 1;
1035      }
1036    _tok(path);
1037
1038    e = e_connman_service_get(service_path);
1039    if (e_connman_service_move_after(e, path, NULL, NULL))
1040      printf(":::Moving after %s...\n", path);
1041    else
1042      fputs("ERROR: can't move after\n", stderr);
1043    return 1;
1044 }
1045
1046 static int
1047 _on_cmd_service_get_state(char *cmd, char *args)
1048 {
1049    const char *state, *path;
1050    E_Connman_Element *e;
1051
1052    if (!args)
1053      {
1054         fputs("ERROR: missing the service path\n", stderr);
1055         return 1;
1056      }
1057    _tok(args);
1058    path = args;
1059
1060    e = e_connman_service_get(path);
1061    if (e_connman_service_state_get(e, &state))
1062      printf(":::Service %s State = \"%s\"\n", path, state);
1063    else
1064      fputs("ERROR: can't get service state\n", stderr);
1065    return 1;
1066 }
1067
1068 static int
1069 _on_cmd_service_get_error(char *cmd, char *args)
1070 {
1071    const char *error, *path;
1072    E_Connman_Element *e;
1073
1074    if (!args)
1075      {
1076         fputs("ERROR: missing the service path\n", stderr);
1077         return 1;
1078      }
1079    _tok(args);
1080    path = args;
1081
1082    e = e_connman_service_get(path);
1083    if (e_connman_service_error_get(e, &error))
1084      printf(":::Service %s Error = \"%s\"\n", path, error);
1085    else
1086      fputs("ERROR: can't get service error\n", stderr);
1087    return 1;
1088 }
1089
1090 static int
1091 _on_cmd_service_get_name(char *cmd, char *args)
1092 {
1093    const char *name, *path;
1094    E_Connman_Element *e;
1095
1096    if (!args)
1097      {
1098         fputs("ERROR: missing the service path\n", stderr);
1099         return 1;
1100      }
1101    _tok(args);
1102    path = args;
1103
1104    e = e_connman_service_get(path);
1105    if (e_connman_service_name_get(e, &name))
1106      printf(":::Service %s Name = \"%s\"\n", path, name);
1107    else
1108      fputs("ERROR: can't get service name\n", stderr);
1109    return 1;
1110 }
1111
1112 static int
1113 _on_cmd_service_get_type(char *cmd, char *args)
1114 {
1115    const char *type, *path;
1116    E_Connman_Element *e;
1117
1118    if (!args)
1119      {
1120         fputs("ERROR: missing the service path\n", stderr);
1121         return 1;
1122      }
1123    _tok(args);
1124    path = args;
1125
1126    e = e_connman_service_get(path);
1127    if (e_connman_service_type_get(e, &type))
1128      printf(":::Service %s Type = \"%s\"\n", path, type);
1129    else
1130      fputs("ERROR: can't get service type\n", stderr);
1131    return 1;
1132 }
1133
1134 static int
1135 _on_cmd_service_get_mode(char *cmd, char *args)
1136 {
1137    const char *mode, *path;
1138    E_Connman_Element *e;
1139
1140    if (!args)
1141      {
1142         fputs("ERROR: missing the service path\n", stderr);
1143         return 1;
1144      }
1145    _tok(args);
1146    path = args;
1147
1148    e = e_connman_service_get(path);
1149    if (e_connman_service_mode_get(e, &mode))
1150      printf(":::Service %s Mode = \"%s\"\n", path, mode);
1151    else
1152      fputs("ERROR: can't get service mode\n", stderr);
1153    return 1;
1154 }
1155
1156 static int
1157 _on_cmd_service_get_security(char *cmd, char *args)
1158 {
1159    const char *security, *path;
1160    E_Connman_Element *e;
1161
1162    if (!args)
1163      {
1164         fputs("ERROR: missing the service path\n", stderr);
1165         return 1;
1166      }
1167    _tok(args);
1168    path = args;
1169
1170    e = e_connman_service_get(path);
1171    if (e_connman_service_security_get(e, &security))
1172      printf(":::Service %s Security = \"%s\"\n", path, security);
1173    else
1174      fputs("ERROR: can't get service security\n", stderr);
1175    return 1;
1176 }
1177
1178 static int
1179 _on_cmd_service_get_passphrase(char *cmd, char *args)
1180 {
1181    const char *passphrase, *path;
1182    E_Connman_Element *e;
1183
1184    if (!args)
1185      {
1186         fputs("ERROR: missing the service path\n", stderr);
1187         return 1;
1188      }
1189    _tok(args);
1190    path = args;
1191
1192    e = e_connman_service_get(path);
1193    if (e_connman_service_passphrase_get(e, &passphrase))
1194      printf(":::Service %s Passphrase = \"%s\"\n", path, passphrase);
1195    else
1196      fputs("ERROR: can't get service passphrase\n", stderr);
1197    return 1;
1198 }
1199
1200 static int
1201 _on_cmd_service_set_passphrase(char *cmd, char *args)
1202 {
1203    char *passphrase, *path;
1204    E_Connman_Element *e;
1205
1206    if (!args)
1207      {
1208         fputs("ERROR: missing the service path\n", stderr);
1209         return 1;
1210      }
1211    path = args;
1212    passphrase = _tok(args);
1213
1214    if (!passphrase)
1215      {
1216         fputs("ERROR: missing the passphrase value\n", stderr);
1217         return 1;
1218      }
1219    _tok(passphrase);
1220
1221    e = e_connman_service_get(path);
1222    if (e_connman_service_passphrase_set(e, passphrase, NULL, NULL))
1223      printf(":::Service %s passphrase set to \"%s\"\n", path, passphrase);
1224    else
1225      fputs("ERROR: can't set service passphrase\n", stderr);
1226    return 1;
1227 }
1228
1229 static int
1230 _on_cmd_service_get_passphrase_required(char *cmd, char *args)
1231 {
1232    const char *path;
1233    bool passphrase;
1234    E_Connman_Element *e;
1235
1236    if (!args)
1237      {
1238         fputs("ERROR: missing the service path\n", stderr);
1239         return 1;
1240      }
1241    _tok(args);
1242    path = args;
1243
1244    e = e_connman_service_get(path);
1245    if (e_connman_service_passphrase_required_get(e, &passphrase))
1246      printf(":::Service %s Passphrase Required = %hhu\n", path, passphrase);
1247    else
1248      fputs("ERROR: can't get service passphrase required\n", stderr);
1249    return 1;
1250 }
1251
1252 static int
1253 _on_cmd_service_get_strength(char *cmd, char *args)
1254 {
1255    const char *path;
1256    unsigned char strength;
1257    E_Connman_Element *e;
1258
1259    if (!args)
1260      {
1261         fputs("ERROR: missing the service path\n", stderr);
1262         return 1;
1263      }
1264    _tok(args);
1265    path = args;
1266
1267    e = e_connman_service_get(path);
1268    if (e_connman_service_strength_get(e, &strength))
1269      printf(":::Service %s Strength = %#02hhx (%d)\n", path, strength, strength);
1270    else
1271      fputs("ERROR: can't get service strength\n", stderr);
1272    return 1;
1273 }
1274
1275 static int
1276 _on_cmd_service_get_favorite(char *cmd, char *args)
1277 {
1278    const char *path;
1279    bool favorite;
1280    E_Connman_Element *e;
1281
1282    if (!args)
1283      {
1284         fputs("ERROR: missing the service path\n", stderr);
1285         return 1;
1286      }
1287    _tok(args);
1288    path = args;
1289
1290    e = e_connman_service_get(path);
1291    if (e_connman_service_favorite_get(e, &favorite))
1292      printf(":::Service %s Favorite = %hhu\n", path, favorite);
1293    else
1294      fputs("ERROR: can't get service favorite\n", stderr);
1295    return 1;
1296 }
1297
1298 static int
1299 _on_cmd_service_get_auto_connect(char *cmd, char *args)
1300 {
1301    const char *path;
1302    bool auto_connect;
1303    E_Connman_Element *e;
1304
1305    if (!args)
1306      {
1307         fputs("ERROR: missing the service path\n", stderr);
1308         return 1;
1309      }
1310    _tok(args);
1311    path = args;
1312
1313    e = e_connman_service_get(path);
1314    if (e_connman_service_auto_connect_get(e, &auto_connect))
1315      printf(":::Service %s Auto Connect = %hhu\n", path, auto_connect);
1316    else
1317      fputs("ERROR: can't get service auto connect\n", stderr);
1318    return 1;
1319 }
1320
1321 static int
1322 _on_cmd_service_set_auto_connect(char *cmd, char *args)
1323 {
1324    char *path, *next_args;
1325    bool auto_connect;
1326    E_Connman_Element *e;
1327
1328    if (!args)
1329      {
1330         fputs("ERROR: missing the service path\n", stderr);
1331         return 1;
1332      }
1333    path = args;
1334    next_args = _tok(args);
1335
1336    if (!next_args)
1337      {
1338         fputs("ERROR: missing the auto connect value\n", stderr);
1339         return 1;
1340      }
1341    _tok(next_args);
1342    auto_connect = !!atol(next_args);
1343
1344    e = e_connman_service_get(path);
1345    if (e_connman_service_auto_connect_set(e, auto_connect, NULL, NULL))
1346      printf(":::Service %s auto connect set to %d\n", path, auto_connect);
1347    else
1348      fputs("ERROR: can't set service auto connect\n", stderr);
1349    return 1;
1350 }
1351
1352 static int
1353 _on_cmd_service_get_setup_required(char *cmd, char *args)
1354 {
1355    const char *path;
1356    bool setup_required;
1357    E_Connman_Element *e;
1358
1359    if (!args)
1360      {
1361         fputs("ERROR: missing the service path\n", stderr);
1362         return 1;
1363      }
1364    _tok(args);
1365    path = args;
1366
1367    e = e_connman_service_get(path);
1368    if (e_connman_service_setup_required_get(e, &setup_required))
1369      printf(":::Service %s Setup Required = %hhu\n", path, setup_required);
1370    else
1371      fputs("ERROR: can't get service setup required\n", stderr);
1372    return 1;
1373 }
1374
1375 static int
1376 _on_cmd_service_get_apn(char *cmd, char *args)
1377 {
1378    const char *apn, *path;
1379    E_Connman_Element *e;
1380
1381    if (!args)
1382      {
1383         fputs("ERROR: missing the service path\n", stderr);
1384         return 1;
1385      }
1386    _tok(args);
1387    path = args;
1388
1389    e = e_connman_service_get(path);
1390    if (e_connman_service_apn_get(e, &apn))
1391      printf(":::Service %s APN = \"%s\"\n", path, apn);
1392    else
1393      fputs("ERROR: can't get service APN\n", stderr);
1394    return 1;
1395 }
1396
1397 static int
1398 _on_cmd_service_set_apn(char *cmd, char *args)
1399 {
1400    char *apn, *path;
1401    E_Connman_Element *e;
1402
1403    if (!args)
1404      {
1405         fputs("ERROR: missing the service path\n", stderr);
1406         return 1;
1407      }
1408    path = args;
1409    apn = _tok(args);
1410
1411    if (!apn)
1412      {
1413         fputs("ERROR: missing the apn value\n", stderr);
1414         return 1;
1415      }
1416    _tok(apn);
1417
1418    e = e_connman_service_get(path);
1419    if (e_connman_service_apn_set(e, apn, NULL, NULL))
1420      printf(":::Service %s APN set to \"%s\"\n", path, apn);
1421    else
1422      fputs("ERROR: can't set service APN\n", stderr);
1423    return 1;
1424 }
1425
1426 static int
1427 _on_cmd_service_get_mcc(char *cmd, char *args)
1428 {
1429    const char *mcc, *path;
1430    E_Connman_Element *e;
1431
1432    if (!args)
1433      {
1434         fputs("ERROR: missing the service path\n", stderr);
1435         return 1;
1436      }
1437    _tok(args);
1438    path = args;
1439
1440    e = e_connman_service_get(path);
1441    if (e_connman_service_mcc_get(e, &mcc))
1442      printf(":::Service %s MCC = \"%s\"\n", path, mcc);
1443    else
1444      fputs("ERROR: can't get service MCC\n", stderr);
1445    return 1;
1446 }
1447
1448 static int
1449 _on_cmd_service_get_mnc(char *cmd, char *args)
1450 {
1451    const char *mnc, *path;
1452    E_Connman_Element *e;
1453
1454    if (!args)
1455      {
1456         fputs("ERROR: missing the service path\n", stderr);
1457         return 1;
1458      }
1459    _tok(args);
1460    path = args;
1461
1462    e = e_connman_service_get(path);
1463    if (e_connman_service_mnc_get(e, &mnc))
1464      printf(":::Service %s MNC = \"%s\"\n", path, mnc);
1465    else
1466      fputs("ERROR: can't get service MNC\n", stderr);
1467    return 1;
1468 }
1469
1470 static int
1471 _on_cmd_service_get_roaming(char *cmd, char *args)
1472 {
1473    const char *path;
1474    bool roaming;
1475    E_Connman_Element *e;
1476
1477    if (!args)
1478      {
1479         fputs("ERROR: missing the service path\n", stderr);
1480         return 1;
1481      }
1482    _tok(args);
1483    path = args;
1484
1485    e = e_connman_service_get(path);
1486    if (e_connman_service_roaming_get(e, &roaming))
1487      printf(":::Service %s Roaming = %hhu\n", path, roaming);
1488    else
1489      fputs("ERROR: can't get service roaming\n", stderr);
1490    return 1;
1491 }
1492
1493 static int
1494 _on_cmd_service_get_ipv4_method(char *cmd, char *args)
1495 {
1496    const char *ipv4_method, *path;
1497    E_Connman_Element *e;
1498
1499    if (!args)
1500      {
1501         fputs("ERROR: missing the service path\n", stderr);
1502         return 1;
1503      }
1504    _tok(args);
1505    path = args;
1506
1507    e = e_connman_service_get(path);
1508    if (e_connman_service_ipv4_method_get(e, &ipv4_method))
1509      printf(":::Service %s ipv4 method = \"%s\"\n", path, ipv4_method);
1510    else
1511      fputs("ERROR: can't get service ipv4 method\n", stderr);
1512    return 1;
1513 }
1514
1515 static int
1516 _on_cmd_service_get_ipv4_address(char *cmd, char *args)
1517 {
1518    const char *ipv4_address, *path;
1519    E_Connman_Element *e;
1520
1521    if (!args)
1522      {
1523         fputs("ERROR: missing the service path\n", stderr);
1524         return 1;
1525      }
1526    _tok(args);
1527    path = args;
1528
1529    e = e_connman_service_get(path);
1530    if (e_connman_service_ipv4_address_get(e, &ipv4_address))
1531      printf(":::Service %s ipv4 address = \"%s\"\n", path, ipv4_address);
1532    else
1533      fputs("ERROR: can't get service ipv4 address\n", stderr);
1534    return 1;
1535 }
1536
1537
1538 static int
1539 _on_input(void *data, Ecore_Fd_Handler *fd_handler)
1540 {
1541    char buf[256];
1542    char *cmd, *args;
1543    const struct {
1544       const char *cmd;
1545       int (*cb)(char *cmd, char *args);
1546    } *itr, maps[] = {
1547      {"quit", _on_cmd_quit},
1548      {"sync", _on_cmd_sync},
1549      {"get_all", _on_cmd_get_all},
1550      {"print", _on_cmd_print},
1551      {"get_properties", _on_cmd_get_properties},
1552      {"set_property", _on_cmd_property_set},
1553      {"manager_get", _on_cmd_manager_get},
1554      {"manager_get_profiles", _on_cmd_manager_get_profiles},
1555      {"manager_get_devices", _on_cmd_manager_get_devices},
1556      {"manager_get_services", _on_cmd_manager_get_services},
1557      {"manager_register_agent", _on_cmd_manager_register_agent},
1558      {"manager_unregister_agent", _on_cmd_manager_unregister_agent},
1559      {"manager_get_state", _on_cmd_manager_get_state},
1560      {"manager_get_offline_mode", _on_cmd_manager_get_offline_mode},
1561      {"manager_set_offline_mode", _on_cmd_manager_set_offline_mode},
1562      {"device_propose_scan", _on_cmd_device_propose_scan},
1563      {"device_get_name", _on_cmd_device_get_name},
1564      {"device_get_type", _on_cmd_device_get_type},
1565      {"device_get_interface", _on_cmd_device_get_interface},
1566      {"device_get_powered", _on_cmd_device_get_powered},
1567      {"device_set_powered", _on_cmd_device_set_powered},
1568      {"device_get_scan_interval", _on_cmd_device_get_scan_interval},
1569      {"device_set_scan_interval", _on_cmd_device_set_scan_interval},
1570      {"device_get_scanning", _on_cmd_device_get_scanning},
1571      {"device_get_networks", _on_cmd_device_get_networks},
1572      {"profile_get_name", _on_cmd_profile_get_name},
1573      {"profile_get_offline_mode", _on_cmd_profile_get_offline_mode},
1574      {"profile_set_offline_mode", _on_cmd_profile_set_offline_mode},
1575      {"profile_get_services", _on_cmd_profile_get_services},
1576      {"network_get_name", _on_cmd_network_get_name},
1577      {"network_get_connected", _on_cmd_network_get_connected},
1578      {"network_get_strength", _on_cmd_network_get_strength},
1579      {"network_get_device", _on_cmd_network_get_device},
1580      {"network_get_wifi_ssid", _on_cmd_network_get_wifi_ssid},
1581      {"network_get_wifi_mode", _on_cmd_network_get_wifi_mode},
1582      {"network_get_wifi_security", _on_cmd_network_get_wifi_security},
1583      {"network_get_wifi_passphrase", _on_cmd_network_get_wifi_passphrase},
1584      {"service_connect", _on_cmd_service_connect},
1585      {"service_disconnect", _on_cmd_service_disconnect},
1586      {"service_remove", _on_cmd_service_remove},
1587      {"service_move_before", _on_cmd_service_move_before},
1588      {"service_move_after", _on_cmd_service_move_after},
1589      {"service_get_state", _on_cmd_service_get_state},
1590      {"service_get_error", _on_cmd_service_get_error},
1591      {"service_get_name", _on_cmd_service_get_name},
1592      {"service_get_type", _on_cmd_service_get_type},
1593      {"service_get_mode", _on_cmd_service_get_mode},
1594      {"service_get_security", _on_cmd_service_get_security},
1595      {"service_get_passphrase", _on_cmd_service_get_passphrase},
1596      {"service_set_passphrase", _on_cmd_service_set_passphrase},
1597      {"service_get_passphrase_required", _on_cmd_service_get_passphrase_required},
1598      {"service_get_strength", _on_cmd_service_get_strength},
1599      {"service_get_favorite", _on_cmd_service_get_favorite},
1600      {"service_get_auto_connect", _on_cmd_service_get_auto_connect},
1601      {"service_set_auto_connect", _on_cmd_service_set_auto_connect},
1602      {"service_get_setup_required", _on_cmd_service_get_setup_required},
1603      {"service_get_apn", _on_cmd_service_get_apn},
1604      {"service_set_apn", _on_cmd_service_set_apn},
1605      {"service_get_mcc", _on_cmd_service_get_mcc},
1606      {"service_get_mnc", _on_cmd_service_get_mnc},
1607      {"service_get_roaming", _on_cmd_service_get_roaming},
1608      {"service_get_ipv4_method", _on_cmd_service_get_ipv4_method},
1609      {"service_get_ipv4_address", _on_cmd_service_get_ipv4_address},
1610      {NULL, NULL}
1611    };
1612
1613
1614    if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR))
1615      {
1616         fputs("ERROR: reading from stdin, exit\n", stderr);
1617         return 0;
1618      }
1619
1620    if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
1621      {
1622         fputs("ERROR: nothing to read?\n", stderr);
1623         return 0;
1624      }
1625
1626    if (!fgets(buf, sizeof(buf), stdin))
1627      {
1628         fprintf(stderr, "ERROR: could not read command: %s\n", strerror(errno));
1629         ecore_main_loop_quit();
1630         return 0;
1631      }
1632
1633    cmd = buf;
1634    while (isspace(*cmd))
1635      cmd++;
1636
1637    args = strchr(cmd, ' ');
1638    if (args)
1639      {
1640         char *p;
1641
1642         *args = '\0';
1643         args++;
1644
1645         while (isspace(*args))
1646           args++;
1647
1648         p = args + strlen(args) - 1;
1649         if (*p == '\n')
1650           *p = '\0';
1651      }
1652    else
1653      {
1654         char *p;
1655
1656         p = cmd + strlen(cmd) - 1;
1657         if (*p == '\n')
1658           *p = '\0';
1659      }
1660
1661    if (strcmp(cmd, "help") == 0)
1662      {
1663         if (args)
1664           {
1665              printf("Commands with '%s' in the name:\n", args);
1666              for (itr = maps; itr->cmd != NULL; itr++)
1667                if (strstr(itr->cmd, args))
1668                  printf("\t%s\n", itr->cmd);
1669           }
1670         else
1671           {
1672              fputs("Commands:\n", stdout);
1673              for (itr = maps; itr->cmd != NULL; itr++)
1674                printf("\t%s\n", itr->cmd);
1675           }
1676         fputc('\n', stdout);
1677         return 1;
1678      }
1679
1680    for (itr = maps; itr->cmd != NULL; itr++)
1681      if (strcmp(itr->cmd, cmd) == 0)
1682        return itr->cb(cmd, args);
1683
1684    printf("unknown command \"%s\", args=%s\n", cmd, args);
1685    return 1;
1686 }
1687
1688 int
1689 main(int argc, char *argv[])
1690 {
1691    E_DBus_Connection *c;
1692
1693    ecore_init();
1694    e_dbus_init();
1695    eina_init();
1696
1697    c = e_dbus_bus_get(DBUS_BUS_SYSTEM);
1698    if (!c) {
1699       printf("ERROR: can't connect to system session\n");
1700       return -1;
1701    }
1702
1703    e_connman_system_init(c);
1704    ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_ADD, _on_element_add, NULL);
1705    ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_DEL, _on_element_del, NULL);
1706    ecore_event_handler_add(E_CONNMAN_EVENT_ELEMENT_UPDATED,
1707                            _on_element_updated, NULL);
1708
1709    ecore_main_fd_handler_add
1710      (0, ECORE_FD_READ | ECORE_FD_ERROR, _on_input, NULL, NULL, NULL);
1711
1712    ecore_main_loop_begin();
1713
1714    e_connman_system_shutdown();
1715
1716    e_dbus_connection_close(c);
1717    eina_shutdown();
1718    e_dbus_shutdown();
1719    ecore_shutdown();
1720
1721    fputs("DBG: clean exit.\n", stderr);
1722
1723    return 0;
1724 }