[Non-ACR] refactoring - dbus init/deinit in listeners
[platform/core/system/batterymonitor.git] / include / bm_util.h
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License")
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #ifndef __BM_UTIL_H__
19 #define __BM_UTIL_H__
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <signal.h>
24 #include <glib.h>
25
26 #if !GLIB_CHECK_VERSION(2, 31, 0)
27 #include <glib/gmacros.h>
28 #endif
29
30 #include "../battery_monitor_stub.h"
31 #include "bm_power_engine.h"
32 #include "bm_private.h"
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 GQuark bm_error_quark(void);
39
40 int bm_check_privilege_battery(GDBusMethodInvocation *invocation);
41
42 int initialize_cynara(void);
43
44 void deinitialize_cynara(void);
45
46 int bm_calc_individual_consumption(int resource_val, int total_consumption);
47
48 double bm_calc_individual_mah_consumption(int resource_val, double mah_c);
49
50 GVariant* bm_marshal_serialized_data(const bm_total_consumption_h data);
51
52 const char *bm_get_resource_id_string(gint resource_id);
53
54 int bm_set_dbus_connection_obj(GDBusConnection* conn);
55
56 GDBusConnection* bm_get_dbus_connection_obj(void);
57
58 void bm_data_free(gpointer data);
59
60 void bm_atm_free(gpointer data);
61
62 void bm_appid_usage_free(appid_usage_s *data);
63
64 void bm_resourceid_usage_free(resourceid_usage_s *data);
65
66 long int bm_get_log_time(int bias);
67
68 void bm_set_free_atm_st2_list(GSList *atm_list);
69
70 void bm_set_free_atm_st1_list(GSList *atm_list);
71
72 void bm_set_free_ble_data_handle(bm_bluetooth_st **bt_handle);
73
74 void bm_set_free_wifi_data_handle(bm_wifi_st **wifi_handle);
75
76 void bm_set_free_cpu_data_handle(bm_cpu_st **cpu_handle);
77
78 void bm_set_free_display_data_handle(bm_display_st **display_handle);
79
80 void bm_set_free_device_network_data_handle(bm_device_network_st **dn_handle);
81
82 #ifdef DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN
83 void bm_set_free_gps_sensor_data_handle(bm_gps_st **gps_handle);
84 #endif /* DISABLE_FEATURE_DATA_FROM_GPS_PLUGIN */
85
86 void bm_set_free_data_handles(bm_feature_data_h* data_h);
87
88 void bm_set_free_gslist_appid_map(GSList *list);
89 #ifdef __cplusplus
90 }
91 #endif
92
93 #endif /* __BM_UTIL_H__ */
94