packaging: add AMB configuration that enables the plugin
[profile/ivi/ico-vic-amb-plugin.git] / tests / dbustest3.cc
1 #include <appcore-efl.h>
2 #include <Elementary.h>
3 #include <stdio.h>
4
5 #include <cassert>
6 #include <ico_dbus_amb_efl.h>
7
8 #include "ambconfig.h"
9 #include "logresult.h"
10
11 void getvalue(const char *objectname, const char *property, dbus_type type, union dbus_value_variant value, void *user_data) {
12     enum ClientType cltype = CLIENT_APP;
13     enum CommandType cotype = CMDTYPE_GET;
14     LogResult *logger = reinterpret_cast<LogResult*>(user_data);
15     switch (type) {
16     case DBUS_TYPE_BYTE :
17         logger->PutOut(cltype, cotype, std::string(property), value.yval);
18         break;
19     case DBUS_TYPE_BOOLEAN :
20         if (value.bval) {
21             logger->PutOut(cltype, cotype, std::string(property), true);
22         }
23         else {
24             logger->PutOut(cltype, cotype, std::string(property), false);
25         }
26         break;
27     case DBUS_TYPE_INT16 :
28         logger->PutOut(cltype, cotype, std::string(property), value.i16val);
29         break;
30     case DBUS_TYPE_UINT16 :
31         logger->PutOut(cltype, cotype, std::string(property), value.ui16val);
32         break;
33     case DBUS_TYPE_INT32 :
34         logger->PutOut(cltype, cotype, std::string(property), value.i32val);
35         break;
36     case DBUS_TYPE_UINT32 :
37         logger->PutOut(cltype, cotype, std::string(property), value.ui32val);
38         break;
39     case DBUS_TYPE_DOUBLE :
40         logger->PutOut(cltype, cotype, std::string(property), value.dval);
41         break;
42     case DBUS_TYPE_STRING :
43         logger->PutOut(cltype, cotype, std::string(property), value.sval);
44         break;
45     default :
46         break;
47     }
48     return;
49 }
50
51 EAPI int elm_main(int argc, char *argv[]) {
52     int ret;
53     std::string configpath = "/etc/ambd/AMBformat.conf";
54     while ((ret = getopt(argc, argv, "c:")) != -1) {
55         switch (ret) {
56         case 'c':
57             configpath = std::string(optarg);
58             break;
59         default :
60             break;
61         }
62     }
63
64     struct appcore_ops ops;
65     ops.create = NULL;
66     ops.resume = NULL;
67     ops.reset = NULL;
68     ops.pause = NULL;
69     ops.terminate = NULL;
70     ops.data = NULL;
71
72     assert(ico_dbus_amb_start() == 0);
73
74     AMBConfig config;
75     if (!config.readConfig(configpath)) {
76         std::cerr << "Can't read VIC-Plugin config file." << std::endl;
77         return -1;
78     }
79
80     std::vector<VehicleInfoDefine> vehicleinfolist =config.getVehicleInfoConfig();
81     LogResult logger;
82
83     auto itr_end = vehicleinfolist.end();
84     for (auto itr = vehicleinfolist.begin(); itr != itr_end; itr++) {
85         auto itr2_end = (*itr).status.end();
86         for (auto itr2 = (*itr).status.begin(); itr2 != itr2_end; itr2++) {
87             switch ((*itr2).type) {
88             case INT : {
89                 ico_dbus_amb_get((*itr2).dbusObjectName.c_str(), (*itr2).dbusPropertyName.c_str(), 0, DBUS_TYPE_INT32, getvalue, &logger);
90                 break;
91             }
92             case DOUBLE : {
93                 ico_dbus_amb_get((*itr2).dbusObjectName.c_str(), (*itr2).dbusPropertyName.c_str(), 0, DBUS_TYPE_DOUBLE, getvalue, &logger);
94                 break;
95             }
96             case CHAR : {
97                 ico_dbus_amb_get((*itr2).dbusObjectName.c_str(), (*itr2).dbusPropertyName.c_str(), 0, DBUS_TYPE_BYTE, getvalue, &logger);
98                 break;
99             }
100             case INT16 : {
101                 ico_dbus_amb_get((*itr2).dbusObjectName.c_str(), (*itr2).dbusPropertyName.c_str(), 0, DBUS_TYPE_INT16, getvalue, &logger);
102                 break;
103             }
104             case UINT16 : {
105                 ico_dbus_amb_get((*itr2).dbusObjectName.c_str(), (*itr2).dbusPropertyName.c_str(), 0, DBUS_TYPE_UINT16, getvalue, &logger);
106                 break;
107             }
108             case UINT32 : {
109                 ico_dbus_amb_get((*itr2).dbusObjectName.c_str(), (*itr2).dbusPropertyName.c_str(), 0, DBUS_TYPE_UINT32, getvalue, &logger);
110                 break;
111             }
112             case INT64 : {
113                 ico_dbus_amb_get((*itr2).dbusObjectName.c_str(), (*itr2).dbusPropertyName.c_str(), 0, DBUS_TYPE_INT64, getvalue, &logger);
114                 break;
115             }
116             case UINT64 : {
117                 ico_dbus_amb_get((*itr2).dbusObjectName.c_str(), (*itr2).dbusPropertyName.c_str(), 0, DBUS_TYPE_UINT64, getvalue, &logger);
118                 break;
119             }
120             case BOOL : {
121                 ico_dbus_amb_get((*itr2).dbusObjectName.c_str(), (*itr2).dbusPropertyName.c_str(), 0, DBUS_TYPE_BOOLEAN, getvalue, &logger);
122                 break;
123             }
124             default : {
125                 break;
126             }
127             }
128         }
129     }
130
131     appcore_efl_main("org.tizen.ico.testdbus", &argc, &argv, &ops);
132
133     assert(ico_dbus_amb_end() == 0);
134
135     elm_shutdown();
136
137     return 0;
138 }
139 ELM_MAIN()