Add initial code for GTest
[platform/core/connectivity/zigbee-manager.git] / unittest / gdbus.h
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef __ZIGBEE_GDBUS_H__
17 #define __ZIGBEE_GDBUS_H__
18
19 #include <glib.h>
20 #include "common.h"
21
22 #define GMAINTIMEOUT 10000
23 #define ZIGBEE_BROADCAST_TIMEOUT (9.5 + 2) * 1000 /**< default timeout for gdbus */
24
25
26 #ifndef ZIGBEE_DBUS_INTERFACE
27 #define ZIGBEE_DBUS_INTERFACE "org.tizen.zigbee"
28 #endif
29
30 #ifndef ZIGBEE_DBUS_OBJPATH
31 #define ZIGBEE_DBUS_OBJPATH "/org/tizen/zigbee"
32 #endif
33
34 #define ZIGBEE_SERVER_NAME "org.tizen.zigbee"
35 #define ZIGBEE_CONTROL_OBJECT_PATH "/org/tizen/zigbee/control"
36
37 #define ZIGBEE_MANAGER_INTERFACE "org.tizen.zigbee.manager"
38 #define ZIGBEE_SERVICE_INTERFACE "org.tizen.zigbee.service"
39 #define ZIGBEE_SERVICE_OBJECT_PATH "/org/tizen/zigbee/service"
40
41 #define ZIGBEE_ZDO_DEV_CONTROL_INTERFACE "org.tizen.zigbee.zdo_dev_control"
42 #define ZIGBEE_ZDO_BIND_INTERFACE "org.tizen.zigbee.zdo_bind"
43 #define ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE "org.tizen.zigbee.zcl_global_control"
44 #define ZIGBEE_ZCL_ALARM_INTERFACE "org.tizen.zigbee.zcl_alarm"
45 #define ZIGBEE_ZCL_BASIC_INTERFACE "org.tizen.zigbee.zcl_basic"
46 #define ZIGBEE_ZCL_COLOR_CONTROL_INTERFACE "org.tizen.zigbee.zcl_color_control"
47 #define ZIGBEE_ZCL_ON_OFF_INTERFACE "org.tizen.zigbee.zcl_on_off"
48 #define ZIGBEE_ZCL_DOOR_LOCK_INTERFACE "org.tizen.zigbee.zcl_door_lock"
49 #define ZIGBEE_ZCL_GROUP_INTERFACE "org.tizen.zigbee.zcl_group"
50 #define ZIGBEE_ZCL_FAN_CONTROL_INTERFACE "org.tizen.zigbee.zcl_fan_control"
51 #define ZIGBEE_ZCL_IAS_ZONE_INTERFACE "org.tizen.zigbee.zcl_ias_zone"
52 #define ZIGBEE_ZCL_IDENTIFY_INTERFACE "org.tizen.zigbee.zcl_identify"
53 #define ZIGBEE_ZCL_LEVEL_CONTROL_INTERFACE "org.tizen.zigbee.zcl_level_control"
54 #define ZIGBEE_ZCL_POLL_CONTROL_INTERFACE "org.tizen.zigbee.zcl_poll_control"
55 #define ZIGBEE_ZCL_SCENE_INTERFACE "org.tizen.zigbee.zcl_scene"
56 #define ZIGBEE_ZCL_THERMOSTAT_INTERFACE "org.tizen.zigbee.zcl_thermostat"
57 #define ZIGBEE_CUSTOM_INTERFACE "org.tizen.zigbee.custom"
58 #define ZIGBEE_MFGLIB_CONTROL_INTERFACE "org.tizen.zigbee.mfglib_control"
59
60 typedef enum {
61         SERVICE_GPROXY,
62         ON_OFF_GPROXY,
63         DOOR_LOCK_GPROXY,
64         LEVEL_CONTROL_GPROXY,
65         THERMOSTAT_GPROXY,
66         ALARM_GPROXY,
67         FAN_CONTROL_GPROXY,
68         MFGLIB_GPROXY,
69         ZCL_GLOBAL_PROXY,
70         ZDO_DEV_PROXY,
71         ZCL_BASIC_PROXY,
72         ZCL_IDENTIFY_PROXY,
73         ZCL_IAS_ZONE_PROXY,
74         ZCL_POLL_CONTROL_PROXY,
75         ZCL_GROUP_PROXY,
76         ZCL_SCENE_PROXY,
77         ZDO_BIND_PROXY,
78         ZCL_COLOR_CONTROL_PROXY,
79         CUSTOM_GPROXY,
80 } gproxy_type_e;
81
82 class GDbus {
83         private:
84                 GDBusConnection *m_pConnection;
85                 GDBusProxy *service_gproxy;
86                 GDBusProxy *on_off_gproxy;
87                 GDBusProxy *door_lock_gproxy;
88                 GDBusProxy *level_control_gproxy;
89                 GDBusProxy *thermostat_gproxy;
90                 GDBusProxy *alarm_gproxy;
91                 GDBusProxy *fan_control_gproxy;
92                 GDBusProxy *mfglib_gproxy;
93                 GDBusProxy *zcl_global_proxy;
94                 GDBusProxy *zdo_dev_proxy;
95                 GDBusProxy *zcl_basic_proxy;
96                 GDBusProxy *zcl_identify_proxy;
97                 GDBusProxy *zcl_ias_zone_proxy;
98                 GDBusProxy *zcl_poll_control_proxy;
99                 GDBusProxy *zcl_group_proxy;
100                 GDBusProxy *zcl_scene_proxy;
101                 GDBusProxy *zdo_bind_proxy;
102                 GDBusProxy *zcl_color_control_proxy;
103                 GDBusProxy *custom_gproxy;
104                 GCancellable *m_pCancellable;
105                 GDBusProxy *get_proxy_type(gproxy_type_e type);
106
107         public:
108                 GDbus();
109                 ~GDbus();
110                 zb_error_e Create(void);
111                 zb_error_e Destroy(void);
112                 GDBusConnection *GetConnection(void);
113                 GCancellable *GetCancellable(void);
114
115                 GVariant *invoke_proxy_method(gproxy_type_e type, const char *method, GVariant *params, int *error);
116                 GVariant *InvokeMethod(const char *dest, const char *path,
117                                 const char *iface_name, const char *method, GVariant *params, int *error);
118                 zb_error_e InvokeMethodNonblock(const char *dest, const char *path,
119                                 const char *iface_name, const char *method, GVariant *params, int timeout,
120                                 GAsyncReadyCallback notify_func, void *user_data);
121 };
122 #endif /* __ZIGBEE_GDBUS_H__ */