2004-12-27 00:33:52 -08:00
|
|
|
#ifndef E_MOD_MAIN_H
|
|
|
|
#define E_MOD_MAIN_H
|
|
|
|
|
2011-01-06 10:41:58 -08:00
|
|
|
#ifdef HAVE_EEZE
|
|
|
|
# include <Eeze.h>
|
|
|
|
#else
|
|
|
|
# include <E_Hal.h>
|
|
|
|
#endif
|
|
|
|
|
2004-12-27 00:33:52 -08:00
|
|
|
typedef struct _Config Config;
|
2005-02-09 04:14:08 -08:00
|
|
|
|
2008-01-28 12:37:00 -08:00
|
|
|
#define CHECK_NONE 0
|
|
|
|
#define CHECK_ACPI 1
|
|
|
|
#define CHECK_APM 2
|
|
|
|
#define CHECK_PMU 3
|
|
|
|
#define CHECK_SYS_ACPI 4
|
2004-12-27 02:49:46 -08:00
|
|
|
|
2010-05-17 00:17:59 -07:00
|
|
|
#define UNKNOWN 0
|
|
|
|
#define NOSUBSYSTEM 1
|
|
|
|
#define SUBSYSTEM 2
|
|
|
|
|
2012-03-25 21:00:53 -07:00
|
|
|
#define SUSPEND 0
|
|
|
|
#define HIBERNATE 1
|
|
|
|
#define SHUTDOWN 2
|
|
|
|
|
2010-05-17 00:17:59 -07:00
|
|
|
#define POPUP_DEBOUNCE_CYCLES 2
|
|
|
|
|
2004-12-27 00:33:52 -08:00
|
|
|
struct _Config
|
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
/* saved * loaded config values */
|
2008-01-10 23:33:57 -08:00
|
|
|
int poll_interval;
|
2008-05-03 12:51:49 -07:00
|
|
|
int alert; /* Alert on minutes remaining */
|
|
|
|
int alert_p; /* Alert on percentage remaining */
|
|
|
|
int alert_timeout; /* Popup dismissal timeout */
|
2012-03-25 21:00:53 -07:00
|
|
|
int suspend_below; /* Suspend if battery drops below this level */
|
|
|
|
int suspend_method; /* Method used to suspend the machine */
|
2009-01-31 19:26:46 -08:00
|
|
|
int force_mode; /* force use of batget or hal */
|
2006-04-20 04:30:25 -07:00
|
|
|
/* just config state */
|
2006-05-09 06:02:48 -07:00
|
|
|
E_Module *module;
|
2006-01-06 13:30:53 -08:00
|
|
|
E_Config_Dialog *config_dialog;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *instances;
|
2008-03-03 01:48:37 -08:00
|
|
|
Ecore_Exe *batget_exe;
|
|
|
|
Ecore_Event_Handler *batget_data_handler;
|
|
|
|
Ecore_Event_Handler *batget_del_handler;
|
2009-01-31 19:26:46 -08:00
|
|
|
Ecore_Timer *alert_timer;
|
2008-03-03 01:48:37 -08:00
|
|
|
int full;
|
|
|
|
int time_left;
|
2010-04-30 18:13:38 -07:00
|
|
|
int time_full;
|
2008-03-03 01:48:37 -08:00
|
|
|
int have_battery;
|
|
|
|
int have_power;
|
2012-01-10 16:29:42 -08:00
|
|
|
#ifdef HAVE_ENOTIFY
|
|
|
|
int desktop_notifications;
|
|
|
|
#endif
|
2010-05-22 00:04:26 -07:00
|
|
|
#ifdef HAVE_EEZE
|
2010-05-17 01:57:47 -07:00
|
|
|
Eeze_Udev_Watch *acwatch;
|
|
|
|
Eeze_Udev_Watch *batwatch;
|
2011-10-30 09:47:50 -07:00
|
|
|
#endif
|
|
|
|
#if defined HAVE_EEZE || defined __OpenBSD__
|
2010-05-18 03:39:30 -07:00
|
|
|
Eina_Bool fuzzy;
|
|
|
|
int fuzzcount;
|
2010-05-16 22:14:50 -07:00
|
|
|
#else
|
2008-11-14 19:42:19 -08:00
|
|
|
struct {
|
2010-04-30 18:13:38 -07:00
|
|
|
// FIXME: on bat_conf del dbus_pending_call_cancel(dbus.have);
|
|
|
|
// then set dbus.have to NULL
|
2008-11-14 19:42:19 -08:00
|
|
|
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;
|
2010-04-30 18:13:38 -07:00
|
|
|
} dbus;
|
2010-05-16 22:14:50 -07:00
|
|
|
#endif
|
2005-02-09 04:14:08 -08:00
|
|
|
};
|
|
|
|
|
2010-05-17 00:17:59 -07:00
|
|
|
typedef struct _Battery Battery;
|
|
|
|
typedef struct _Ac_Adapter Ac_Adapter;
|
|
|
|
|
|
|
|
struct _Battery
|
|
|
|
{
|
|
|
|
const char *udi;
|
2011-10-30 09:47:50 -07:00
|
|
|
#if defined HAVE_EEZE || defined __OpenBSD__
|
2010-05-18 03:39:30 -07:00
|
|
|
Ecore_Poller *poll;
|
2010-05-17 00:17:59 -07:00
|
|
|
#else
|
|
|
|
E_DBus_Signal_Handler *prop_change;
|
2010-05-18 03:39:30 -07:00
|
|
|
Eina_Bool can_charge:1;
|
2010-05-17 00:17:59 -07:00
|
|
|
#endif
|
|
|
|
Eina_Bool present:1;
|
2010-05-18 03:39:30 -07:00
|
|
|
Eina_Bool charging:1;
|
2011-10-30 09:47:50 -07:00
|
|
|
#if defined HAVE_EEZE || defined __OpenBSD__
|
2010-05-18 03:39:30 -07:00
|
|
|
double last_update;
|
|
|
|
double percent;
|
|
|
|
double current_charge;
|
|
|
|
double design_charge;
|
|
|
|
double last_full_charge;
|
|
|
|
double charge_rate;
|
|
|
|
double time_full;
|
|
|
|
double time_left;
|
|
|
|
#else
|
2010-05-17 00:17:59 -07:00
|
|
|
int percent;
|
|
|
|
int current_charge;
|
|
|
|
int design_charge;
|
|
|
|
int last_full_charge;
|
|
|
|
int charge_rate;
|
|
|
|
int time_full;
|
|
|
|
int time_left;
|
|
|
|
const char *type;
|
|
|
|
const char *charge_units;
|
2010-05-18 03:39:30 -07:00
|
|
|
#endif
|
|
|
|
const char *technology;
|
2010-05-17 00:17:59 -07:00
|
|
|
const char *model;
|
|
|
|
const char *vendor;
|
|
|
|
Eina_Bool got_prop:1;
|
2011-10-30 09:47:50 -07:00
|
|
|
#ifdef __OpenBSD__
|
|
|
|
int * mib;
|
|
|
|
#endif
|
2010-05-17 00:17:59 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Ac_Adapter
|
|
|
|
{
|
|
|
|
const char *udi;
|
2010-05-22 00:04:26 -07:00
|
|
|
#ifndef HAVE_EEZE
|
2010-05-17 00:17:59 -07:00
|
|
|
E_DBus_Signal_Handler *prop_change;
|
|
|
|
#endif
|
|
|
|
Eina_Bool present:1;
|
|
|
|
const char *product;
|
2011-10-30 09:47:50 -07:00
|
|
|
#ifdef __OpenBSD__
|
|
|
|
int * mib;
|
|
|
|
#endif
|
2010-05-17 00:17:59 -07:00
|
|
|
};
|
|
|
|
|
2010-05-17 01:57:47 -07:00
|
|
|
Battery *_battery_battery_find(const char *udi);
|
|
|
|
Ac_Adapter *_battery_ac_adapter_find(const char *udi);
|
2010-05-17 00:17:59 -07:00
|
|
|
void _battery_device_update(void);
|
2010-06-19 10:53:49 -07:00
|
|
|
#ifdef HAVE_EEZE
|
2010-05-17 01:57:47 -07:00
|
|
|
/* in e_mod_udev.c */
|
2010-08-30 12:57:36 -07:00
|
|
|
int _battery_udev_start(void);
|
2010-05-18 03:39:30 -07:00
|
|
|
void _battery_udev_stop(void);
|
2010-05-17 01:57:47 -07:00
|
|
|
/* end e_mod_udev.c */
|
2011-10-30 09:47:50 -07:00
|
|
|
#elif !defined __OpenBSD__
|
2010-06-19 10:53:49 -07:00
|
|
|
/* in e_mod_dbus.c */
|
2010-08-30 12:57:36 -07:00
|
|
|
int _battery_dbus_start(void);
|
2010-06-19 10:53:49 -07:00
|
|
|
void _battery_dbus_stop(void);
|
|
|
|
/* end e_mod_dbus.c */
|
2011-10-30 09:47:50 -07:00
|
|
|
#else
|
|
|
|
/* in e_mod_openbsd.c */
|
|
|
|
int _battery_openbsd_start(void);
|
|
|
|
void _battery_openbsd_stop(void);
|
|
|
|
/* end e_mod_openbsd.c */
|
2010-06-19 10:53:49 -07:00
|
|
|
#endif
|
2010-05-17 00:17:59 -07:00
|
|
|
|
2005-12-27 09:16:58 -08:00
|
|
|
EAPI extern E_Module_Api e_modapi;
|
2005-09-23 10:13:47 -07:00
|
|
|
|
2006-06-06 08:19:36 -07:00
|
|
|
EAPI void *e_modapi_init (E_Module *m);
|
2005-04-11 20:34:31 -07:00
|
|
|
EAPI int e_modapi_shutdown (E_Module *m);
|
|
|
|
EAPI int e_modapi_save (E_Module *m);
|
2004-12-27 00:33:52 -08:00
|
|
|
|
2010-01-22 12:28:39 -08:00
|
|
|
E_Config_Dialog *e_int_config_battery_module(E_Container *con, const char *params __UNUSED__);
|
2007-10-31 05:21:02 -07:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
void _battery_config_updated(void);
|
|
|
|
extern Config *battery_config;
|
2005-12-14 14:46:51 -08:00
|
|
|
|
2012-01-19 15:25:32 -08:00
|
|
|
/**
|
|
|
|
* @addtogroup Optional_Gadgets
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @defgroup Module_Battery Battery
|
|
|
|
*
|
|
|
|
* Shows battery level and current status, may do actions given some
|
|
|
|
* thresholds.
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2004-12-27 00:33:52 -08:00
|
|
|
#endif
|