a269b0f90390db8b89e12b719981ec087d3bb998
[platform/core/connectivity/zigbee-manager.git] / zigbee-daemon / zigbee-interface / src / zigbee_service_dbus_interface_on_off.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 static gboolean on_on_off_set_on_off(ZigbeeOn_off *on_off_object,
22         GDBusMethodInvocation *invocation,
23         gshort node_id,
24         gchar endpoint,
25         gchar on_off_type,
26         gpointer user_data)
27 {
28         ZigBeeService *service = (ZigBeeService *)user_data;
29
30         NOT_USED(on_off_object);
31         NOT_USED(invocation);
32         NOT_USED(service);
33         NOT_USED(node_id);
34         NOT_USED(endpoint);
35         NOT_USED(on_off_type);
36
37         /*
38          * TODO -
39          * Create and send request for processing
40          */
41
42         return TRUE;
43 }
44
45 static gboolean on_on_off_get_on_off_state(ZigbeeOn_off *on_off_object,
46         GDBusMethodInvocation *invocation,
47         gshort node_id,
48         gchar endpoint,
49         gpointer user_data)
50 {
51         ZigBeeService *service = (ZigBeeService *)user_data;
52
53         NOT_USED(on_off_object);
54         NOT_USED(invocation);
55         NOT_USED(service);
56         NOT_USED(node_id);
57         NOT_USED(endpoint);
58
59         /*
60          * TODO -
61          * Create and send request for processing
62          */
63
64         return TRUE;
65 }
66
67 gboolean zigbee_service_dbus_interface_on_off_init(ZigBeeService *service,
68         ZigbeeObjectSkeleton *zigbee_object)
69 {
70         ZigbeeOn_off *on_off_object;
71
72         if (NULL == service) {
73                 Z_LOGE("service is NULL");
74                 return FALSE;
75         }
76
77         on_off_object = zigbee_on_off_skeleton_new();
78         zigbee_object_skeleton_set_on_off(zigbee_object, on_off_object);
79         g_object_unref(on_off_object);
80
81         Z_LOGI("on_off_object: [%p]", on_off_object);
82
83         /*
84          * Register signal handlers for 'on_off' interface
85          */
86         g_signal_connect(on_off_object,
87                 "handle-set-on-off",
88                 G_CALLBACK(on_on_off_set_on_off), service);
89
90         g_signal_connect(on_off_object,
91                 "handle-get-on-off-state",
92                 G_CALLBACK(on_on_off_get_on_off_state), service);
93
94         return TRUE;
95 }