Fix build error on plugin build
[platform/core/connectivity/zigbee-manager.git] / zigbee-daemon / zigbee-interface / src / zigbee_service_dbus_interface_zcl_ias_zone.c
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 #include "zigbee_service_interface_common.h"
20
21 #include <zblib_driver_zcl_ias_zone.h>
22
23 static void on_zclias_control_enroll_response_resp(ZigBeeServiceInterface *service_interface,
24         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
25 {
26         ZigbeeServiceInterfaceRespCbData_t *cb_data =
27                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
28
29         NOT_USED(cb_data);
30         NOT_USED(service_interface);
31         NOT_USED(request_id);
32         NOT_USED(resp_data);
33         NOT_USED(resp_data_len);
34 }
35
36 static gboolean on_zclias_control_enroll_response(ZigbeeZcl_ias_zone *zclias_control_object,
37         GDBusMethodInvocation *invocation,
38         gshort node_id,
39         gchar dest_ep,
40         gchar enroll_code,
41         gchar zone_id,
42         gpointer user_data)
43 {
44         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
45         ZigbeeZcliasControlEnrolResponse_t req;
46         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
47
48         gboolean ret;
49
50         memset(&req, 0x0, sizeof(ZigbeeZcliasControlEnrolResponse_t));
51
52         /* Update request structure */
53         req.node_id = node_id;
54         req.dest_ep = dest_ep;
55         req.enroll_code = enroll_code;
56         req.zone_id = zone_id;
57
58         /* Allocate response callback data */
59         resp_cb_data =
60                 zigbee_service_dbus_interface_create_resp_cb_data(zclias_control_object,
61                         invocation, NULL, 0);
62         if (NULL == resp_cb_data) {
63                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
64
65                 /* Send failure response */
66                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
67
68                 return TRUE;
69         }
70
71         /* Dispatch request */
72         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
73                 ZBLIB_DRIVER_TYPE_ZCLIAS_CONTROL,
74                 ZBLIB_ZCLIAS_CONTROL_OPS_ENROLL_RESPONSE,
75                 &req, sizeof(req),
76                 on_zclias_control_enroll_response_resp, resp_cb_data);
77         if (FALSE == ret) {
78                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
79
80                 /* Free response callback data */
81                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
82
83                 /* Send failure response */
84                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
85
86                 return TRUE;
87         }
88
89         return TRUE;
90 }
91
92 gboolean zigbee_service_dbus_interface_zcl_ias_zone_init(ZigBeeServiceInterface *service_interface,
93         ZigbeeObjectSkeleton *zigbee_object)
94 {
95         ZigbeeZcl_ias_zone *zclias_control_object;
96
97         if (NULL == service_interface) {
98                 Z_LOGE("service_interface is NULL");
99                 return FALSE;
100         }
101
102         zclias_control_object = zigbee_zcl_ias_zone_skeleton_new();
103         zigbee_object_skeleton_set_zcl_ias_zone(zigbee_object, zclias_control_object);
104         g_object_unref(zclias_control_object);
105
106         Z_LOGI("zclias_control_object: [%p]", zclias_control_object);
107
108         /*
109          * Register signal handlers for 'zclias_control' interface
110          */
111         g_signal_connect(zclias_control_object,
112                 "handle-enroll-response",
113                 G_CALLBACK(on_zclias_control_enroll_response), service_interface);
114
115         return TRUE;
116 }