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 <Eldbus.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 SUSPEND 0
23 #define HIBERNATE 1
24 #define SHUTDOWN 2
25 
26 #define POPUP_DEBOUNCE_CYCLES  2
27 
28 struct _Config
29 {
30    /* saved * loaded config values */
31    int              poll_interval;
32    int              alert;	/* Alert on minutes remaining */
33    int	            alert_p;    /* Alert on percentage remaining */
34    int              alert_timeout;  /* Popup dismissal timeout */
35    int              suspend_below;  /* Suspend if battery drops below this level */
36    int              suspend_method; /* Method used to suspend the machine */
37    int              force_mode; /* force use of batget or hal */
38    /* just config state */
39    E_Module        *module;
40    E_Config_Dialog *config_dialog;
41    Eina_List       *instances;
42    Ecore_Exe           *batget_exe;
43    Ecore_Event_Handler *batget_data_handler;
44    Ecore_Event_Handler *batget_del_handler;
45    Ecore_Timer         *alert_timer;
46    int                  full;
47    int                  time_left;
48    int                  time_full;
49    int                  have_battery;
50    int                  have_power;
51    int              desktop_notifications;
52 #ifdef HAVE_EEZE
53    Eeze_Udev_Watch     *acwatch;
54    Eeze_Udev_Watch     *batwatch;
55 #endif
56 #if defined HAVE_EEZE || defined __OpenBSD__ || defined __NetBSD__
57    Eina_Bool            fuzzy;
58    int                  fuzzcount;
59 #endif
60 };
61 
62 typedef struct _Battery Battery;
63 typedef struct _Ac_Adapter Ac_Adapter;
64 
65 struct _Battery
66 {
67    const char *udi;
68 #if defined HAVE_EEZE || defined __OpenBSD__ || defined __DragonFly__ || defined __FreeBSD__ || defined __NetBSD__
69    Ecore_Poller *poll;
70 #endif
71    Eina_Bool present E_BITFIELD;
72    Eina_Bool charging E_BITFIELD;
73 #if defined HAVE_EEZE || defined __OpenBSD__ || defined __DragonFly__ || defined __FreeBSD__ || defined __NetBSD__
74    double last_update;
75    double percent;
76    double current_charge;
77    double design_charge;
78    double last_full_charge;
79    double charge_rate;
80    double time_full;
81    double time_left;
82 #else
83    int percent;
84    int current_charge;
85    int design_charge;
86    int last_full_charge;
87    int charge_rate;
88    int time_full;
89    int time_left;
90    const char *type;
91    const char *charge_units;
92 #endif
93    const char *technology;
94    const char *model;
95    const char *vendor;
96    Eina_Bool got_prop E_BITFIELD;
97    Eldbus_Proxy *proxy;
98    int * mib;
99 #if defined(__FreeBSD__) || defined(__DragonFly__)
100    int * mib_state;
101    int * mib_units;
102    int * mib_time;
103    int batteries;
104    int time_min;
105 #endif
106 };
107 
108 struct _Ac_Adapter
109 {
110    const char *udi;
111    Eina_Bool present E_BITFIELD;
112    const char *product;
113    Eldbus_Proxy *proxy;
114    int * mib;
115 };
116 
117 Battery *_battery_battery_find(const char *udi);
118 Ac_Adapter *_battery_ac_adapter_find(const char *udi);
119 void _battery_device_update(void);
120 #ifdef HAVE_EEZE
121 /* in e_mod_udev.c */
122 int  _battery_udev_start(void);
123 void _battery_udev_stop(void);
124 /* end e_mod_udev.c */
125 #elif !defined __OpenBSD__ && !defined __DragonFly__ && !defined __FreeBSD__ && !defined __NetBSD__
126 /* in e_mod_dbus.c */
127 int _battery_upower_start(void);
128 void _battery_upower_stop(void);
129 /* end e_mod_dbus.c */
130 #else
131 /* in e_mod_sysctl.c */
132 int _battery_sysctl_start(void);
133 void _battery_sysctl_stop(void);
134 /* end e_mod_sysctl.c */
135 #endif
136 
137 E_API extern E_Module_Api e_modapi;
138 
139 E_API void *e_modapi_init     (E_Module *m);
140 E_API int   e_modapi_shutdown (E_Module *m);
141 E_API int   e_modapi_save     (E_Module *m);
142 
143 E_Config_Dialog *e_int_config_battery_module(Evas_Object *parent, const char *params EINA_UNUSED);
144 
145 void _battery_config_updated(void);
146 extern Config *battery_config;
147 
148 /**
149  * @addtogroup Optional_Gadgets
150  * @{
151  *
152  * @defgroup Module_Battery Battery
153  *
154  * Shows battery level and current status, may do actions given some
155  * thresholds.
156  *
157  * @}
158  */
159 
160 #endif
161