fis svace issue
[platform/core/connectivity/zigbee-manager.git] / zigbee-daemon / zigbee-interface / src / zigbee_service_dbus_interface.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 <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22
23 #include <glib.h>
24 #include <dlog.h>
25
26 #include <zblib.h>
27 #include <zblib_service.h>
28 #include <zblib_service_interface.h>
29 #include <zblib_driver_manager.h>
30
31 #include "zigbee_service_interface.h"
32 #include "zigbee_service_interface_common.h"
33 #include "zigbee_service_dbus_interface.h"
34
35 /**< ZigBee D-BUS service interface name */
36 #define ZIGBEE_DBUS_SERVICE_INTERFACE_NAME "zigbee-dbus"
37
38 static void _notify_zigbee_state(ZigBeeServiceInterface *service_interface,
39                 gboolean result)
40 {
41         ZigbeeCustomData_t *custom_data = zblib_service_interface_ref_user_data(service_interface);
42         ZigBeeService *service = zblib_service_interface_ref_service(service_interface);
43
44         if (NULL == custom_data) {
45                 Z_LOGE("Unexpected invalid parameter !");
46                 return;
47         }
48
49         if (result) {
50                 /* Notify zigbee service manually here (Enabled) */
51                 zigbee_manager_emit_zigbee_state(custom_data->zigbee_mgr, result);
52         } else {
53                 /* ZigBee state will be emitted on bus termination */
54                 zblib_service_exit(service);
55         }
56 }
57
58 static gboolean on_manager_enable(ZigbeeManager *zigbee_mgr,
59         GDBusMethodInvocation *invocation,
60         gpointer user_data)
61 {
62         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
63         ZigbeeCustomData_t *custom_data = zblib_service_interface_ref_user_data(service_interface);
64
65         if (NULL == custom_data) {
66                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
67
68                 return TRUE;
69         }
70
71         zigbee_manager_complete_enable(zigbee_mgr, invocation);
72
73         return TRUE;
74 }
75
76 static gboolean on_manager_disable(ZigbeeManager *zigbee_mgr,
77         GDBusMethodInvocation *invocation,
78         gpointer user_data)
79 {
80         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
81         ZigBeeService *service = zblib_service_interface_ref_service(service_interface);
82
83         NOT_USED(user_data);
84
85         zigbee_manager_complete_disable(zigbee_mgr, invocation, 0);
86
87         if (service)
88                 zblib_service_exit(service);
89
90         return TRUE;
91 }
92
93 static gboolean on_manager_get_zigbee_state(ZigbeeManager *zigbee_mgr,
94         GDBusMethodInvocation *invocation, gpointer user_data)
95 {
96         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
97         ZigbeeCustomData_t *custom_data = zblib_service_interface_ref_user_data(service_interface);
98
99         Z_LOGI("Entered");
100
101         if (NULL == custom_data) {
102                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
103
104                 return TRUE;
105         }
106
107         zigbee_manager_complete_get_zigbee_state(zigbee_mgr, invocation,
108                         0, custom_data->sevice_interface_init_complete);
109
110         return TRUE;
111 }
112
113 static void zigbee_service_dbus_interface_initialize_interfaces(ZigBeeServiceInterface *service_interface,
114         ZigbeeObjectSkeleton *zigbee_object)
115 {
116         gboolean ret;
117
118         ret = zigbee_service_dbus_interface_zcl_alarm_init(service_interface, zigbee_object);
119         Z_LOGD("ret: %d", ret);
120
121         ret = zigbee_service_dbus_interface_custom_init(service_interface, zigbee_object);
122         Z_LOGD("ret: %d", ret);
123
124         ret = zigbee_service_dbus_interface_zcl_door_lock_init(service_interface, zigbee_object);
125         Z_LOGD("ret: %d", ret);
126
127         ret = zigbee_service_dbus_interface_zcl_fan_control_init(service_interface, zigbee_object);
128         Z_LOGD("ret: %d", ret);
129
130         ret = zigbee_service_dbus_interface_zcl_level_control_init(service_interface, zigbee_object);
131         Z_LOGD("ret: %d", ret);
132
133         ret = zigbee_service_dbus_interface_mfglib_control_init(service_interface, zigbee_object);
134         Z_LOGD("ret: %d", ret);
135
136         ret = zigbee_service_dbus_interface_zcl_on_off_init(service_interface, zigbee_object);
137         Z_LOGD("ret: %d", ret);
138
139         ret = zigbee_service_dbus_interface_service_init(service_interface, zigbee_object);
140         Z_LOGD("ret: %d", ret);
141
142         ret = zigbee_service_dbus_interface_zcl_thermostat_init(service_interface, zigbee_object);
143         Z_LOGD("ret: %d", ret);
144
145         ret = zigbee_service_dbus_interface_zcl_basic_init(service_interface, zigbee_object);
146         Z_LOGD("ret: %d", ret);
147
148         ret = zigbee_service_dbus_interface_zcl_color_control_init(service_interface, zigbee_object);
149         Z_LOGD("ret: %d", ret);
150
151         ret = zigbee_service_dbus_interface_zcl_global_control_init(service_interface, zigbee_object);
152         Z_LOGD("ret: %d", ret);
153
154         ret = zigbee_service_dbus_interface_zcl_group_init(service_interface, zigbee_object);
155         Z_LOGD("ret: %d", ret);
156
157         ret = zigbee_service_dbus_interface_zcl_ias_zone_init(service_interface, zigbee_object);
158         Z_LOGD("ret: %d", ret);
159
160         ret = zigbee_service_dbus_interface_zcl_identify_init(service_interface, zigbee_object);
161         Z_LOGD("ret: %d", ret);
162
163         ret = zigbee_service_dbus_interface_zcl_poll_control_init(service_interface, zigbee_object);
164         Z_LOGD("ret: %d", ret);
165
166         ret = zigbee_service_dbus_interface_zcl_scene_init(service_interface, zigbee_object);
167         Z_LOGD("ret: %d", ret);
168
169         ret = zigbee_service_dbus_interface_zdo_bind_init(service_interface, zigbee_object);
170         Z_LOGD("ret: %d", ret);
171
172         ret = zigbee_service_dbus_interface_zdo_dev_control_init(service_interface, zigbee_object);
173         Z_LOGD("ret: %d", ret);
174 }
175
176 static void zigbee_service_dbus_interface_noti_cb(ZigBeeServiceInterface *service_interface,
177         guint noti_id, gpointer noti_data, guint noti_data_len, gpointer noti_cb_data)
178 {
179         ZblibDriverType_e driver_type;
180         guint notification_id;
181
182         if (NULL == service_interface) {
183                 Z_LOGE("service_interface is NULL");
184                 return;
185         }
186
187         /* Extract driver_type */
188         driver_type = ((noti_id & 0xFF000000) >> 24);
189
190         /* Extract notification_id */
191         notification_id = (noti_id & 0x000000FF);
192
193         Z_LOGI("Driver type: [%d] Notification ID: [%d]", driver_type, notification_id);
194
195         switch (driver_type) {
196         case ZBLIB_DRIVER_TYPE_ZCL_ALARM: {
197                 zigbee_service_dbus_interface_zcl_alarm_notification(service_interface,
198                         notification_id, noti_data, noti_data_len, noti_cb_data);
199         }
200         break;
201
202         case ZBLIB_DRIVER_TYPE_CUSTOM: {
203                 zigbee_service_dbus_interface_custom_notification(service_interface,
204                         notification_id, noti_data, noti_data_len, noti_cb_data);
205         }
206         break;
207
208         case ZBLIB_DRIVER_TYPE_ZCL_DOOR_LOCK: {
209                 zigbee_service_dbus_interface_zcl_door_lock_notification(service_interface,
210                         notification_id, noti_data, noti_data_len, noti_cb_data);
211         }
212         break;
213
214         case ZBLIB_DRIVER_TYPE_ZCL_FAN_CONTROL: {
215                 zigbee_service_dbus_interface_zcl_fan_control_notification(service_interface,
216                         notification_id, noti_data, noti_data_len, noti_cb_data);
217         }
218         break;
219
220         case ZBLIB_DRIVER_TYPE_ZCL_LEVEL_CONTROL: {
221                 zigbee_service_dbus_interface_zcl_level_control_notification(service_interface,
222                         notification_id, noti_data, noti_data_len, noti_cb_data);
223         }
224         break;
225
226         case ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL: {
227                 zigbee_service_dbus_interface_mfglib_control_notification(service_interface,
228                         notification_id, noti_data, noti_data_len, noti_cb_data);
229         }
230         break;
231
232         case ZBLIB_DRIVER_TYPE_ZCL_ON_OFF: {
233                 zigbee_service_dbus_interface_zcl_on_off_notification(service_interface,
234                         notification_id, noti_data, noti_data_len, noti_cb_data);
235         }
236         break;
237
238         case ZBLIB_DRIVER_TYPE_SERVICE: {
239                 zigbee_service_dbus_interface_service_notification(service_interface,
240                         notification_id, noti_data, noti_data_len, noti_cb_data);
241         }
242         break;
243
244         case ZBLIB_DRIVER_TYPE_ZCL_THERMOSTAT: {
245                 zigbee_service_dbus_interface_zcl_thermostat_notification(service_interface,
246                         notification_id, noti_data, noti_data_len, noti_cb_data);
247         }
248         break;
249
250         case ZBLIB_DRIVER_TYPE_ZCL_BASIC: {
251                 zigbee_service_dbus_interface_zcl_basic_notification(service_interface,
252                         notification_id, noti_data, noti_data_len, noti_cb_data);
253         }
254         break;
255
256         case ZBLIB_DRIVER_TYPE_ZCL_GLOBAL_CONTROL: {
257                 zigbee_service_dbus_interface_zcl_global_control_notification(service_interface,
258                         notification_id, noti_data, noti_data_len, noti_cb_data);
259         }
260         break;
261
262         case ZBLIB_DRIVER_TYPE_ZCL_IAS_ZONE: {
263                 zigbee_service_dbus_interface_zcl_ias_zone_notification(service_interface,
264                         notification_id, noti_data, noti_data_len, noti_cb_data);
265         }
266         break;
267
268         case ZBLIB_DRIVER_TYPE_ZCL_IDENTIFY: {
269                 zigbee_service_dbus_interface_zcl_identify_notification(service_interface,
270                         notification_id, noti_data, noti_data_len, noti_cb_data);
271         }
272         break;
273
274         case ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL: {
275                 zigbee_service_dbus_interface_zcl_color_control_notification(service_interface,
276                         notification_id, noti_data, noti_data_len, noti_cb_data);
277         }
278         break;
279
280         case ZBLIB_DRIVER_TYPE_ZCL_GROUP: {
281                 zigbee_service_dbus_interface_zcl_group_notification(service_interface,
282                         notification_id, noti_data, noti_data_len, noti_cb_data);
283         }
284         break;
285
286         case ZBLIB_DRIVER_TYPE_ZCL_POLL_CONTROL: {
287                 zigbee_service_dbus_interface_zcl_poll_control_notification(service_interface,
288                         notification_id, noti_data, noti_data_len, noti_cb_data);
289         }
290         break;
291
292         case ZBLIB_DRIVER_TYPE_ZCL_SCENE: {
293                 zigbee_service_dbus_interface_zcl_scene_notification(service_interface,
294                         notification_id, noti_data, noti_data_len, noti_cb_data);
295         }
296         break;
297
298         case ZBLIB_DRIVER_TYPE_ZDO_DEV_CONTROL: {
299                 zigbee_service_dbus_interface_zdo_dev_control_notification(service_interface,
300                         notification_id, noti_data, noti_data_len, noti_cb_data);
301         }
302         break;
303
304         case ZBLIB_DRIVER_TYPE_ZDO_BIND: {
305                 zigbee_service_dbus_interface_zdo_bind_notification(service_interface,
306                         notification_id, noti_data, noti_data_len, noti_cb_data);
307         }
308         break;
309
310         case ZBLIB_DRIVER_TYPE_MANAGER: {
311                 /* Handle 'enabled' notification here */
312                 if (notification_id == ZBLIB_MANAGER_NOTI_ZIGBEE_ENABLED) {
313                         gboolean *rsp = (gboolean*)noti_data;
314
315                         Z_LOGD("Firmware update result : [%s]", ((*rsp) ? "Succeed" : "Failed"));
316                         _notify_zigbee_state(service_interface, *rsp);
317                 } else
318                         Z_LOGE("Unhandled notification id: [%d]", notification_id);
319         }
320         break;
321
322         case ZBLIB_DRIVER_TYPE_NONE: /* Fall through */
323         default: {
324                 Z_LOGE("Unhandled driver type: [%d]", driver_type);
325         }
326         break;
327         }
328 }
329
330 static void zigbee_on_name_lost(GDBusConnection *connection,
331         const gchar *name, gpointer user_data)
332 {
333         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
334         ZigbeeCustomData_t *custom_data = zblib_service_interface_ref_user_data(service_interface);
335
336         Z_LOGW("'%s' - [Name Lost]", name);
337
338         zblib_check_null_ret("custom_data", custom_data);
339
340         NOT_USED(connection);
341
342         /* Bus name is 'lost' */
343         custom_data->name_acquired = FALSE;
344 }
345
346 static void zigbee_on_name_acquired(GDBusConnection *connection,
347         const gchar *name, gpointer user_data)
348 {
349         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
350         ZigbeeCustomData_t *custom_data = zblib_service_interface_ref_user_data(service_interface);
351
352         Z_LOGI("'%s' - [Name Acquired]", name);
353
354         NOT_USED(connection);
355
356         zblib_check_null_ret("custom_data", custom_data);
357
358         /* Bus name is 'acquired' */
359         custom_data->name_acquired = TRUE;
360 }
361
362 static void zigbee_on_bus_acquired(GDBusConnection *connection,
363         const gchar *name, gpointer user_data)
364 {
365         gboolean ret;
366         GError *error = NULL;
367         ZigbeeObjectSkeleton *zigbee_object;
368         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
369         ZigBeeService *service = NULL;
370         ZigbeeCustomData_t *custom_data = NULL;
371         char *path = NULL;
372
373         Z_LOGI("'%s' - [BUS Acquired]", name);
374
375         if (NULL == service_interface) {
376                 Z_LOGE("service_interface is NULL!");
377                 return;
378         }
379
380         service = zblib_service_interface_ref_service(service_interface);
381         if (NULL == service) {
382                 Z_LOGE("service is NULL!");
383                 return;
384         }
385
386         custom_data = (ZigbeeCustomData_t *)zblib_service_interface_ref_user_data(service_interface);
387         if (NULL == custom_data) {
388                 Z_LOGE("D-BUS service interface custom_data is NULL!");
389                 return;
390         }
391
392         /*
393          * Create ZigBee 'manager' D-BUS object
394          */
395         custom_data->zigbee_mgr = zigbee_manager_skeleton_new();
396
397         /*
398          * Set ZigBee 'manager' D-BUS object method(s)
399          */
400         g_signal_connect(custom_data->zigbee_mgr,
401                         "handle-get-zigbee-state",
402                         G_CALLBACK(on_manager_get_zigbee_state),
403                         service_interface);
404
405         g_signal_connect(custom_data->zigbee_mgr,
406                         "handle-enable",
407                         G_CALLBACK(on_manager_enable),
408                         service_interface);
409
410         g_signal_connect(custom_data->zigbee_mgr,
411                         "handle-disable",
412                         G_CALLBACK(on_manager_disable),
413                         service_interface);
414
415         /*
416          * Export 'manager' interface on ZigBee D-BUS
417          */
418         ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(custom_data->zigbee_mgr),
419                 connection, ZIGBEE_DBUS_PATH, &error);
420         if (FALSE == ret) {
421                 /* LCOV_EXCL_START */
422                 Z_LOGW("g_dbus_interface_skeleton_export() Fail(%s)", error->message);
423                 g_error_free(error);
424                 /* LCOV_EXCL_STOP */
425         }
426         /*
427          * Exports all objects managed by 'manager' on Connection (connection)
428          */
429         g_dbus_object_manager_server_set_connection(custom_data->manager, connection);
430
431         path = g_strdup_printf("%s", ZIGBEE_SERVICE_PATH);
432         Z_LOGI("dbus object path: [%s]", path);
433
434         /*
435          * Create 'object' for specific path only once.
436          */
437         zigbee_object = g_hash_table_lookup(custom_data->objects, path);
438         if (zigbee_object) {
439                 Z_LOGW("ZigBee D-BUS interface object already created (object: %p)", zigbee_object);
440                 goto OUT;
441         }
442
443         /*
444          * Create ZigBee D-BUS object
445          */
446         zigbee_object = zigbee_object_skeleton_new(path);
447         Z_LOGI("ZigBee D-BUS object created (zigbee_object: [%p])", zigbee_object);
448
449         /*
450          * Insert ZigBee object to HASH table
451          */
452         g_hash_table_insert(custom_data->objects, g_strdup(path), zigbee_object);
453
454         /*
455          * Initialize interfaces
456          */
457         zigbee_service_dbus_interface_initialize_interfaces(service_interface, zigbee_object);
458         Z_LOGI("ZigBee service interfaces initialized!!!");
459
460         /* Export the Object to Manager */
461         g_dbus_object_manager_server_export(custom_data->manager,
462                 G_DBUS_OBJECT_SKELETON(zigbee_object));
463
464         /* Service interface initialization completed */
465         custom_data->sevice_interface_init_complete = TRUE;
466
467 OUT:
468         g_free(path);
469 }
470
471 static void zigbee_get_activation_sbus(ZigbeeCustomData_t *interface_data)
472 {
473         /* Get D-Bus owner to activate zigbee-daemon */
474         interface_data->activation_dbus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
475                         ZIGBEE_DBUS_SERVICE".manager",
476                         G_BUS_NAME_OWNER_FLAGS_REPLACE,
477                         NULL,
478                         NULL,
479                         NULL,
480                         NULL,
481                         NULL);
482         Z_LOGI("ZigBee D-BUS activation ID: [%d]", interface_data->activation_dbus_id);
483 }
484
485 /**< Zigbee service dbus interface initialization */
486 gboolean zigbee_service_dbus_interface_init(ZigBeeService *service)
487 {
488         ZigBeeServiceInterface *service_interface = NULL;
489         ZigbeeCustomData_t *interface_data = NULL;
490         gboolean ret;
491
492         if (NULL == service) {
493                 Z_LOGE("service is NULL");
494                 return FALSE;
495         }
496
497         /*
498          * Create ZigBee service interface object
499          */
500         service_interface = zblib_service_interface_new(service,
501                 ZIGBEE_DBUS_SERVICE_INTERFACE_NAME);
502         if (NULL == service_interface) {
503                 Z_LOGE("Create D-BUS service interface failed!");
504
505                 return FALSE;
506         }
507
508         /*
509          * Set Service interface notification callback
510          */
511         ret = zblib_service_interface_set_noti_cb(service_interface,
512                 zigbee_service_dbus_interface_noti_cb, NULL);
513         if (FALSE == ret) {
514                 Z_LOGE("Set service interface notification callback failed!");
515
516                 goto EXIT;
517         }
518
519         /*
520          * Add Service interface object to 'service'
521          */
522         ret = zblib_service_add_service_interface(service,
523                         service_interface);
524         if (FALSE == ret) {
525                 Z_LOGE("Add D-BUS service interface failed!");
526
527                 goto EXIT;
528         }
529
530         /*
531          * ZigBee D-BUS interface custom data
532          */
533         interface_data = g_malloc0(sizeof(ZigbeeCustomData_t));
534
535         /*
536          * Link interface data to service
537          */
538         ret = zblib_service_interface_link_user_data(service_interface,
539                         interface_data);
540         if (FALSE == ret) {
541                 Z_LOGE("Link D-BUS service interface data failed!");
542
543                 goto EXIT;
544         }
545
546         /* HASH table for maintaining 'objects' list */
547         interface_data->objects = g_hash_table_new_full(g_str_hash, g_str_equal,
548                         g_free, NULL);
549
550         /*
551          * Acquire "org.tizen.zigbee.manager" named bus on D-BUS SYSTEM bus.
552          */
553         zigbee_get_activation_sbus(interface_data);
554
555         /*
556          * Acquire "org.tizen.zigbee" named bus on D-BUS SYSTEM bus.
557          */
558         interface_data->bus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
559                         ZIGBEE_DBUS_SERVICE,
560                         G_BUS_NAME_OWNER_FLAGS_REPLACE,
561                         zigbee_on_bus_acquired,
562                         zigbee_on_name_acquired,
563                         zigbee_on_name_lost,
564                         service_interface,
565                         NULL);
566         Z_LOGI("ZigBee D-BUS ID: [%d]", interface_data->bus_id);
567
568         interface_data->manager = g_dbus_object_manager_server_new(ZIGBEE_DBUS_PATH);
569
570         return TRUE;
571
572 EXIT:
573         g_free(interface_data);
574
575         /*
576          * Remove Service interface object from 'service'
577          */
578         ret = zblib_service_remove_service_interface(service,
579                         service_interface);
580         if (FALSE == ret)
581                 Z_LOGE("Remove service interface failed!");
582
583         /*
584          * Free Service interface object
585          */
586         zblib_service_interface_free(service,
587                         service_interface);
588
589         return FALSE;
590 }
591
592 /**< Zigbee service dbus interface de-initialization */
593 void zigbee_service_dbus_interface_deinit(ZigBeeService *service)
594 {
595         ZigBeeServiceInterface *service_interface = NULL;
596         ZigbeeCustomData_t *interface_data = NULL;
597         gboolean ret;
598
599         if (NULL == service) {
600                 Z_LOGE("service is NULL");
601                 return;
602         }
603
604         service_interface = zblib_service_ref_service_interface(service,
605                 ZIGBEE_DBUS_SERVICE_INTERFACE_NAME);
606         if (NULL == service_interface) {
607                 Z_LOGE("D-BUS service interface not found!");
608
609                 return;
610         }
611
612         interface_data = (ZigbeeCustomData_t *)zblib_service_interface_ref_user_data(service_interface);
613         if (NULL == interface_data) {
614                 Z_LOGE("D-BUS interface data not found!");
615
616                 goto EXIT;
617         }
618
619         /* Emit zigbee_state - disabled */
620         Z_LOGD("Update zigbee_state ----");
621         zigbee_manager_emit_zigbee_state(interface_data->zigbee_mgr, FALSE);
622
623         /*
624          * Unown "org.tizen.zigbee.manager" named bus on D-BUS SYSTEM bus
625          */
626         if (interface_data->activation_dbus_id > 0) {
627                 Z_LOGI("Unowning ZigBee Service interface activation D-BUS ID: [%d]",
628                         interface_data->activation_dbus_id);
629                 g_bus_unown_name(interface_data->activation_dbus_id);
630         }
631
632         /*
633          * Unown "org.tizen.zigbee" named bus on D-BUS SYSTEM bus
634          */
635         if (interface_data->bus_id > 0) {
636                 Z_LOGI("Unowning ZigBee Service interface D-BUS ID: [%d]", interface_data->bus_id);
637                 g_bus_unown_name(interface_data->bus_id);
638         }
639
640         /* Free resources */
641         g_hash_table_destroy(interface_data->objects);
642         g_free(interface_data);
643
644 EXIT:
645         /*
646          * Remove Service interface object from 'service'
647          */
648         ret = zblib_service_remove_service_interface(service,
649                         service_interface);
650         if (FALSE == ret)
651                 Z_LOGE("Remove service interface failed!");
652
653         /*
654          * Free Service interface object
655          */
656         zblib_service_interface_free(service,
657                         service_interface);
658 }