6f347c8207666bef650f752a2ec35b3d9b68083e
[framework/uifw/e17.git] / src / modules / battery / e_mod_main.h
1 #ifndef E_MOD_MAIN_H
2 #define E_MOD_MAIN_H
3
4 #ifdef HAVE_EEZE
5 # include <Eeze.h>
6 #else
7 # include <E_Hal.h>
8 #endif
9
10 typedef struct _Config       Config;
11
12 #define CHECK_NONE      0
13 #define CHECK_ACPI      1
14 #define CHECK_APM       2
15 #define CHECK_PMU       3
16 #define CHECK_SYS_ACPI  4
17
18 #define UNKNOWN 0
19 #define NOSUBSYSTEM 1
20 #define SUBSYSTEM 2
21
22 #define POPUP_DEBOUNCE_CYCLES  2
23
24 struct _Config
25 {
26    /* saved * loaded config values */
27    int              poll_interval;
28    int              alert;      /* Alert on minutes remaining */
29    int              alert_p;    /* Alert on percentage remaining */
30    int              alert_timeout;  /* Popup dismissal timeout */
31    int              suspend_below;  /* Suspend if batter drops below this level */
32    int              force_mode; /* force use of batget or hal */
33    /* just config state */
34    E_Module        *module;
35    E_Config_Dialog *config_dialog;
36    Eina_List       *instances;
37    E_Menu          *menu;
38    Ecore_Exe           *batget_exe;
39    Ecore_Event_Handler *batget_data_handler;
40    Ecore_Event_Handler *batget_del_handler;
41    Ecore_Timer         *alert_timer;
42    int                  full;
43    int                  time_left;
44    int                  time_full;
45    int                  have_battery;
46    int                  have_power;
47 #ifdef HAVE_ENOTIFY
48    int              desktop_notifications;
49 #endif
50 #ifdef HAVE_EEZE
51    Eeze_Udev_Watch     *acwatch;
52    Eeze_Udev_Watch     *batwatch;
53 #endif
54 #if defined HAVE_EEZE || defined __OpenBSD__
55    Eina_Bool            fuzzy;
56    int                  fuzzcount;
57 #else
58    struct {
59       // FIXME: on bat_conf del dbus_pending_call_cancel(dbus.have);
60       //        then set dbus.have to NULL
61       DBusPendingCall       *have;
62       // FIXME: on bat_conf del e_dbus_signal_handler_del() these
63       E_DBus_Signal_Handler *dev_add;
64       E_DBus_Signal_Handler *dev_del;
65    } dbus;
66 #endif
67 };
68
69 typedef struct _Battery Battery;
70 typedef struct _Ac_Adapter Ac_Adapter;
71
72 struct _Battery
73 {
74    const char *udi;
75 #if defined HAVE_EEZE || defined __OpenBSD__
76    Ecore_Poller *poll;
77 #else
78    E_DBus_Signal_Handler *prop_change;
79    Eina_Bool can_charge:1;
80 #endif
81    Eina_Bool present:1;
82    Eina_Bool charging:1;
83 #if defined HAVE_EEZE || defined __OpenBSD__
84    double last_update;
85    double percent;
86    double current_charge;
87    double design_charge;
88    double last_full_charge;
89    double charge_rate;
90    double time_full;
91    double time_left;
92 #else
93    int percent;
94    int current_charge;
95    int design_charge;
96    int last_full_charge;
97    int charge_rate;
98    int time_full;
99    int time_left;
100    const char *type;
101    const char *charge_units;
102 #endif
103    const char *technology;
104    const char *model;
105    const char *vendor;
106    Eina_Bool got_prop:1;
107 #ifdef __OpenBSD__
108    int * mib;
109 #endif
110 };
111
112 struct _Ac_Adapter
113 {
114    const char *udi;
115 #ifndef HAVE_EEZE
116    E_DBus_Signal_Handler *prop_change;
117 #endif
118    Eina_Bool present:1;
119    const char *product;
120 #ifdef __OpenBSD__
121    int * mib;
122 #endif
123 };
124
125 Battery *_battery_battery_find(const char *udi);
126 Ac_Adapter *_battery_ac_adapter_find(const char *udi);
127 void _battery_device_update(void);
128 #ifdef HAVE_EEZE
129 /* in e_mod_udev.c */
130 int  _battery_udev_start(void);
131 void _battery_udev_stop(void);
132 /* end e_mod_udev.c */
133 #elif !defined __OpenBSD__
134 /* in e_mod_dbus.c */
135 int  _battery_dbus_start(void);
136 void _battery_dbus_stop(void);
137 /* end e_mod_dbus.c */
138 #else
139 /* in e_mod_openbsd.c */
140 int _battery_openbsd_start(void);
141 void _battery_openbsd_stop(void);
142 /* end e_mod_openbsd.c */
143 #endif
144
145 EAPI extern E_Module_Api e_modapi;
146
147 EAPI void *e_modapi_init     (E_Module *m);
148 EAPI int   e_modapi_shutdown (E_Module *m);
149 EAPI int   e_modapi_save     (E_Module *m);
150
151 E_Config_Dialog *e_int_config_battery_module(E_Container *con, const char *params __UNUSED__);
152     
153 void _battery_config_updated(void);
154 extern Config *battery_config;
155
156 /**
157  * @addtogroup Optional_Gadgets
158  * @{
159  *
160  * @defgroup Module_Battery Battery
161  *
162  * Shows battery level and current status, may do actions given some
163  * thresholds.
164  *
165  * @}
166  */
167
168 #endif