battery: Move changed_battery_cf() from plugin to core
[platform/core/system/deviced.git] / src / battery / battery-ops.h
1 /*
2  * deviced
3  *
4  * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
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
20 #ifndef __BATTERY_OPS_H__
21 #define __BATTERY_OPS_H__
22
23 #include <errno.h>
24 #include "shared/common.h"
25 #include "power-supply.h"
26 #include <libsyscommon/libgdbus.h>
27
28 struct battery_ops {
29         char *name;
30         void (*init) (void *data);
31         void (*exit) (void *data);
32         int (*func) (unsigned int cmd, void *arg);
33 };
34
35 struct battery_plugin {
36         void *handle;
37         /* low battery notification */
38         int (*lowbat_noti_launch) (int capacity, int option);
39         void (*lowbat_noti_clean) (const char *prev, const char *str);
40
41         void (*remove_health_popup) (void);
42
43         void (*launch_health_popup_by_display_state) (int display_state);
44         int (*check_power_supply_noti) (void);
45         void (*update_ovp) (enum battery_noti_status status);
46         /* Add plugins here */
47 };
48
49 void add_battery(const struct battery_ops *batt);
50 void remove_battery(const struct battery_ops *batt);
51 const struct battery_ops *find_battery_feature(const char *name);
52
53 void battery_ops_init(void *data);
54 void battery_ops_exit(void *data);
55
56 #define BATTERY_OPS_REGISTER(batt)      \
57 static void __CONSTRUCTOR__ module_init(void)   \
58 {       \
59         add_battery(batt);      \
60 }       \
61 static void __DESTRUCTOR__ module_exit(void)    \
62 {       \
63         remove_battery(batt);   \
64 }
65
66 #define FIND_BATTERY(dev, name) do { \
67         if (!dev) dev = find_battery_feature(name); \
68 } while (0)
69
70
71 #endif