17d83df1f274afc9fd75598a3fce7e27072fc9ab
[platform/core/connectivity/zigbee-manager.git] / zigbee-daemon / zigbee-interface / src / zigbee_service_interface_common.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Contact: Suresh Kumar N (suresh.n@samsung.com)
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef __ZIGBEE_SERVICE_INTERFACE_COMMON_H__
20 #define __ZIGBEE_SERVICE_INTERFACE_COMMON_H__
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25
26 #include <glib.h>
27 #include <gio/gio.h>
28
29 #include <zblib.h>
30 #include <zblib_service_interface.h>
31
32 #include "zigbee_generated_code.h"
33
34 #include "zigbee_service_dbus_interface_service.h"
35 #include "zigbee_service_dbus_interface_on_off.h"
36 #include "zigbee_service_dbus_interface_door_lock.h"
37 #include "zigbee_service_dbus_interface_level_control.h"
38 #include "zigbee_service_dbus_interface_thermostat.h"
39 #include "zigbee_service_dbus_interface_fan_control.h"
40 #include "zigbee_service_dbus_interface_alarm.h"
41 #include "zigbee_service_dbus_interface_mfglib_control.h"
42 #include "zigbee_service_dbus_interface_zclglobal_control.h"
43 #include "zigbee_service_dbus_interface_zdodev_control.h"
44 #include "zigbee_service_dbus_interface_zclbasic_control.h"
45 #include "zigbee_service_dbus_interface_zclidentify_control.h"
46 #include "zigbee_service_dbus_interface_zclias_control.h"
47 #include "zigbee_service_dbus_interface_zcl_poll_control.h"
48 #include "zigbee_service_dbus_interface_zcl_group.h"
49 #include "zigbee_service_dbus_interface_zcl_scene.h"
50 #include "zigbee_service_dbus_interface_zdo_bind.h"
51 #include "zigbee_service_dbus_interface_zcl_color.h"
52 #include "zigbee_service_dbus_interface_custom.h"
53
54 /**< ZigBee D-BUS service*/
55 #define ZIGBEE_DBUS_SERVICE             "org.tizen.zigbee"
56
57 /**< ZigBee D-BUS service path */
58 #define ZIGBEE_DBUS_PATH                "/org/tizen/zigbee"
59
60 /**< ZigBee D-BUS generic fail response macro */
61 #define ZIGBEE_DBUS_FAIL_RESPONSE(invocation, msg) do { \
62         g_dbus_method_invocation_return_error(invocation, \
63                 G_DBUS_ERROR, G_DBUS_ERROR_FAILED, msg); \
64 } while (0)
65
66 /**< ZigBee D-BUS default fail message */
67 #define ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG "Request failed"
68
69 /**< ZigBee D-BUS interface custom data */
70 typedef struct {
71         GDBusObjectManagerServer *manager; /**< ZigBee object */
72         ZigbeeManager *zigbee_mgr;
73         GHashTable *objects; /**< ZigBee D-BUS object(s) */
74
75         gint bus_id; /**< ZigBee D-BUS ID */
76
77         gboolean name_acquired; /**< ZigBee D-BUS name acquired */
78         gboolean sevice_interface_init_complete; /**< ZigBee D-BUS service init completed */
79
80         gboolean zigbee_state; /**< ZigBee service state */
81 } ZigbeeCustomData_t;
82
83 /**< ZigBee D-BUS response callback data */
84 typedef struct zigbee_service_interface_resp_cb_type ZigbeeServiceInterfaceRespCbData_t;
85
86 /**< Common APIs */
87 ZigbeeServiceInterfaceRespCbData_t *
88 zigbee_service_dbus_interface_create_resp_cb_data(void *interface_object,
89         GDBusMethodInvocation *invocation,
90         void *user_data, unsigned int user_data_len);
91
92 void zigbee_service_dbus_interface_destroy_resp_cb_data(ZigbeeServiceInterfaceRespCbData_t *resp_cb_data);
93
94 gboolean zigbee_service_dbus_interface_dispatch_request(ZigBeeServiceInterface *service_interface,
95         ZblibDriverType_e driver_type, guint ops_id,
96         gpointer request_data, guint request_data_len,
97         ZblibServiceInterfaceResponseCb_t resp_cb, gpointer resp_cb_data);
98
99 #endif /* __ZIGBEE_SERVICE_INTERFACE_COMMON_H__ */