Imported Upstream version 1.7.1
[platform/upstream/edbus.git] / src / lib / hal / e_hal_main.c
1 #include <E_Hal.h>
2 #include "e_hal_private.h"
3
4 int _e_dbus_hal_log_dom = -1;
5 int _e_dbus_hal_init_count = 0;
6
7 EAPI int
8 e_hal_init(void)
9 {
10    if (++_e_dbus_hal_init_count != 1)
11      return _e_dbus_hal_init_count;
12
13    if (!eina_init())
14      return --_e_dbus_hal_init_count;
15
16    _e_dbus_hal_log_dom = eina_log_domain_register
17      ("e_hal", E_DBUS_COLOR_DEFAULT);
18    if (_e_dbus_hal_log_dom < 0)
19      {
20         EINA_LOG_ERR("Could not register 'e_hal' log domain.");
21         goto shutdown_eina;
22      }
23
24    if (!e_dbus_init()) {
25       ERR("Could not initialize E_DBus.");
26       goto unregister_log_domain;
27    }
28
29    return _e_dbus_hal_init_count;
30
31  unregister_log_domain:
32    eina_log_domain_unregister(_e_dbus_hal_log_dom);
33    _e_dbus_hal_log_dom = -1;
34  shutdown_eina:
35    eina_shutdown();
36
37    return _e_dbus_hal_init_count;
38 }
39
40 EAPI int
41 e_hal_shutdown(void)
42 {
43    if (--_e_dbus_hal_init_count != 0)
44      return _e_dbus_hal_init_count;
45
46    e_dbus_shutdown();
47
48    eina_log_domain_unregister(_e_dbus_hal_log_dom);
49    _e_dbus_hal_log_dom = -1;
50    eina_shutdown();
51
52    return _e_dbus_hal_init_count;
53 }