aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/battery/e_mod_main.h
blob: 58d53db38c6efa2c5f10d331b6b910d2d5827738 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H

typedef struct _Config       Config;

#define CHECK_NONE      0
#define CHECK_ACPI      1
#define CHECK_APM       2
#define CHECK_PMU       3
#define CHECK_SYS_ACPI  4

#define UNKNOWN 0
#define NOSUBSYSTEM 1
#define SUBSYSTEM 2

#define POPUP_DEBOUNCE_CYCLES  2

struct _Config
{
   /* saved * loaded config values */
   int              poll_interval;
   int              alert;	/* Alert on minutes remaining */
   int	            alert_p;    /* Alert on percentage remaining */
   int              alert_timeout;  /* Popup dismissal timeout */
   int              force_mode; /* force use of batget or hal */
   /* just config state */
   E_Module        *module;
   E_Config_Dialog *config_dialog;
   Eina_List       *instances;
   E_Menu          *menu;
   Ecore_Exe           *batget_exe;
   Ecore_Event_Handler *batget_data_handler;
   Ecore_Event_Handler *batget_del_handler;
   Ecore_Timer         *alert_timer;
   int                  full;
   int                  time_left;
   int                  time_full;
   int                  have_battery;
   int                  have_power;
   int                  have_subsystem;
#ifdef HAVE_EUDEV
   Eeze_Udev_Watch     *acwatch;
   Eeze_Udev_Watch     *batwatch;
#else
   struct {
      // FIXME: on bat_conf del dbus_pending_call_cancel(dbus.have);
      //        then set dbus.have to NULL
      DBusPendingCall       *have;
      // FIXME: on bat_conf del e_dbus_signal_handler_del() these
      E_DBus_Signal_Handler *dev_add;
      E_DBus_Signal_Handler *dev_del;
   } dbus;
#endif
};

typedef struct _Battery Battery;
typedef struct _Ac_Adapter Ac_Adapter;

struct _Battery
{
   const char *udi;
#ifdef HAVE_EUDEV
   Eeze_Udev_Watch *watch;
#else
   E_DBus_Signal_Handler *prop_change;
#endif
   Eina_Bool present:1;
   Eina_Bool can_charge:1;
   int state;
   int percent;
   int current_charge;
   int design_charge;
   int last_full_charge;
   int charge_rate;
   int time_full;
   int time_left;
   const char *technology;
   const char *type;
   const char *charge_units;
   const char *model;
   const char *vendor;
   Eina_Bool got_prop:1;
};

struct _Ac_Adapter
{
   const char *udi;
#ifdef HAVE_EUDEV
   Eeze_Udev_Watch *watch;
#else
   E_DBus_Signal_Handler *prop_change;
#endif
   Eina_Bool present:1;
   const char *product;
};

Battery *_battery_battery_find(const char *udi);
Ac_Adapter *_battery_ac_adapter_find(const char *udi);
/* in e_mod_dbus.c */
void _battery_dbus_battery_props(void *data, void *reply_data, DBusError *error);
void _battery_dbus_ac_adapter_props(void *data, void *reply_data, DBusError *error);
void _battery_dbus_battery_property_changed(void *data, DBusMessage *msg);
void _battery_dbus_battery_add(const char *udi);
void _battery_dbus_battery_del(const char *udi);
void _battery_dbus_ac_adapter_add(const char *udi);
void _battery_dbus_ac_adapter_del(const char *udi);
void _battery_dbus_find_battery(void *user_data, void *reply_data, DBusError *err);
void _battery_dbus_find_ac(void *user_data, void *reply_data, DBusError *err);
void _battery_dbus_is_battery(void *user_data, void *reply_data, DBusError *err);
void _battery_dbus_is_ac_adapter(void *user_data, void *reply_data, DBusError *err);
void _battery_dbus_dev_add(void *data, DBusMessage *msg);
void _battery_dbus_dev_del(void *data, DBusMessage *msg);
void _battery_dbus_have_dbus(void);
void _battery_dbus_shutdown(void);
void _battery_device_update(void);
/* end e_mod_dbus.c */
/* in e_mod_udev.c */
void _battery_udev_start(void);
/* end e_mod_udev.c */
Eina_List *device_batteries;
Eina_List *device_ac_adapters;
double init_time;

EAPI extern E_Module_Api e_modapi;

EAPI void *e_modapi_init     (E_Module *m);
EAPI int   e_modapi_shutdown (E_Module *m);
EAPI int   e_modapi_save     (E_Module *m);

E_Config_Dialog *e_int_config_battery_module(E_Container *con, const char *params __UNUSED__);
    
void _battery_config_updated(void);
extern Config *battery_config;

#endif