aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/sysinfo/sysinfo.h
blob: ed641f774fd5374b638eb22d5313c92c63aa123f (plain) (blame)
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#ifndef SYSINFO_H
#define SYSINFO_H

#include "e.h"
#if defined(HAVE_EEZE)
# include <Eeze.h>
#else
# include <Eldbus.h>
#endif

E_API extern E_Module_Api e_modapi;

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

typedef enum _E_Sysinfo_Module E_Sysinfo_Module;
enum _E_Sysinfo_Module
{
   E_SYSINFO_MODULE_NONE = 0,
   E_SYSINFO_MODULE_BATMAN ,
   E_SYSINFO_MODULE_THERMAL,
   E_SYSINFO_MODULE_CPUCLOCK,
   E_SYSINFO_MODULE_CPUMONITOR,
   E_SYSINFO_MODULE_MEMUSAGE,
   E_SYSINFO_MODULE_NETSTATUS,
   E_SYSINFO_MODULE_SYSINFO
};

typedef enum _Netstatus_Unit Netstatus_Unit;
enum _Netstatus_Unit
{
   NETSTATUS_UNIT_BYTES = 0,
   NETSTATUS_UNIT_KB,
   NETSTATUS_UNIT_MB,
   NETSTATUS_UNIT_GB
};

typedef enum _Sensor_Type
{
   SENSOR_TYPE_NONE,
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
   SENSOR_TYPE_FREEBSD,
   SENSOR_TYPE_OPENBSD,
#else
   SENSOR_TYPE_OMNIBOOK,
   SENSOR_TYPE_LINUX_MACMINI,
   SENSOR_TYPE_LINUX_I2C,
   SENSOR_TYPE_LINUX_ACPI,
   SENSOR_TYPE_LINUX_PCI,
   SENSOR_TYPE_LINUX_PBOOK,
   SENSOR_TYPE_LINUX_INTELCORETEMP,
   SENSOR_TYPE_LINUX_THINKPAD,
   SENSOR_TYPE_LINUX_SYS
#endif
} Sensor_Type;

typedef enum _Unit
{
   CELSIUS,
   FAHRENHEIT
} Unit;

typedef struct _Tempthread Tempthread;
typedef struct _Cpu_Status       Cpu_Status;
typedef struct _CPU_Core         CPU_Core;
typedef struct _Config Config;
typedef struct _Config_Item Config_Item;
typedef struct _Instance Instance;

struct _Tempthread
{
   Instance *inst;
   int poll_interval;
   Sensor_Type sensor_type;
   const char *sensor_name;
   const char *sensor_path;
   void *extn;
   E_Powersave_Sleeper *sleeper;
#if defined(HAVE_EEZE)
   Eina_List *tempdevs;
#endif
   Eina_Bool initted E_BITFIELD;
};

struct _Cpu_Status
{
   Eina_List     *frequencies;
   Eina_List     *governors;
   int            cur_frequency;
#if defined(__OpenBSD__)
   int            cur_percent;
#endif
   int            cur_min_frequency;
   int            cur_max_frequency;
   int            can_set_frequency;
   int            pstate_min;
   int            pstate_max;
   char          *cur_governor;
   const char    *orig_governor;
   unsigned char  active;
   unsigned char  pstate;
   unsigned char  pstate_turbo;
};

struct _CPU_Core
{
   int percent;
   long total;
   long idle;
   Evas_Object *layout;
};

struct _Config
{
   Eina_List *items;

   E_Module    *module;
   Evas_Object *config_dialog;
};

struct _Config_Item
{
   int                     id;
   int                     version;
   E_Sysinfo_Module        esm;
   struct
   {
      Evas_Object         *o_gadget;
      Evas_Object         *popup;
      Evas_Object         *configure;
      /* 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                  suspend_below;  /* Suspend if battery drops below this level */
      int                  suspend_method; /* Method used to suspend the machine */
      int                  force_mode; /* force use of batget or hal */
      /* just config state */
      Ecore_Timer         *alert_timer;
      int                  full;
      int                  time_left;
      int                  have_battery;
      int                  have_power;
      int                  desktop_notifications;
      Eina_List           *handlers;
      Eina_Bool            done;
#if defined(HAVE_EEZE)
      Eeze_Udev_Watch     *acwatch;
      Eeze_Udev_Watch     *batwatch;
#endif
#if defined(HAVE_EEZE) || defined(__OpenBSD__) || defined(__NetBSD__)
      Eina_Bool            fuzzy;
      int                  fuzzcount;
#endif
   } batman;
   struct
   {
      Evas_Object         *o_gadget;
      Evas_Object         *configure;
      Evas_Object         *popup;
      Evas_Object         *popup_pbar;
      int                  poll_interval;
      int                  low, high;
      int                  sensor_type;
      int                  temp;
      int                  percent;
      const char          *sensor_name;
      Unit                 units;
#if defined(HAVE_EEZE)
      Ecore_Poller        *poller;
      Tempthread          *tth;
#endif
      Ecore_Thread        *th;

      Eina_Bool            have_temp E_BITFIELD;
      Eina_List           *handlers;
      Eina_Bool            defer;
      Eina_Bool            done;
   } thermal;
   struct
   {
      Evas_Object         *o_gadget;
      Evas_Object         *popup;
      Evas_Object         *popup_pbar;
      Evas_Object         *configure;
      int                  poll_interval;
      int                  restore_governor;
      int                  auto_powersave;
      int                  percent;
      int                  tot_min_frequency;
      int                  tot_max_frequency;
      const char          *powersave_governor;
      const char          *governor;
      int                  pstate_min;
      int                  pstate_max;
      Cpu_Status          *status;
      Ecore_Thread        *frequency_check_thread;
      Eina_List           *handlers;
   } cpuclock;
   struct
   {
      Evas_Object         *o_gadget;
      Evas_Object         *o_gadget_box;
      Evas_Object         *event;
      Evas_Object         *popup;
      Evas_Object         *popup_pbar;
      Evas_Object         *configure;
      int                  poll_interval;
      int                  percent;
      int                  cores;

      Ecore_Thread        *usage_check_thread;
      Eina_List           *handlers;
   } cpumonitor;
   struct
   {
      Evas_Object         *o_gadget;
      Evas_Object         *popup;
      Evas_Object         *configure;
      int                  poll_interval;
      int                  mem_percent;
      int                  swp_percent;
      unsigned long        mem_total;
      unsigned long        mem_used;
      unsigned long        mem_cached;
      unsigned long        mem_buffers;
      unsigned long        mem_shared;
      unsigned long        swp_total;
      unsigned long        swp_used;
      Ecore_Thread        *usage_check_thread;
      Eina_List           *handlers;
   } memusage;
   struct
   {
      Evas_Object         *o_gadget;
      Evas_Object         *popup;
      Evas_Object         *popup_inpbar;
      Evas_Object         *popup_outpbar;
      Evas_Object         *configure;
      Eina_Bool            automax;
      Netstatus_Unit       receive_units;
      Netstatus_Unit       send_units;
      int                  poll_interval;
      int                  inpercent;
      int                  outpercent;
      unsigned long        inmax;
      unsigned long        outmax;
      Ecore_Thread        *usage_check_thread;
      Eina_List           *handlers;
      Eina_Stringshare    *instring;
      Eina_Stringshare    *outstring;
   } netstatus;
   struct   {
      Evas_Object *o_batman;
      Evas_Object *o_thermal;
      Evas_Object *o_cpuclock;
      Evas_Object *o_cpumonitor;
      Evas_Object *o_memusage;
      Evas_Object *o_netstatus;
   } sysinfo;
};

struct _Instance
{
   Evas_Object         *o_main;
   Evas_Object         *o_table;
   Evas_Object         *popup_battery;
   Evas_Object         *warning;
   Config_Item         *cfg;
   unsigned int         notification_id;
};

EINTERN Evas_Object *config_sysinfo(E_Zone *zone, Instance *inst, E_Sysinfo_Module esm);
EINTERN Evas_Object *batman_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient);
EINTERN Evas_Object *thermal_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient);
EINTERN Evas_Object *cpuclock_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient);
EINTERN Evas_Object *cpumonitor_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient);
EINTERN Evas_Object *memusage_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient);
EINTERN Evas_Object *netstatus_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient);
EINTERN Evas_Object *sysinfo_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient);

EINTERN Evas_Object *config_sysinfo(E_Zone *zone, Instance *inst, E_Sysinfo_Module esm);
EINTERN Evas_Object *sysinfo_batman_create(Evas_Object *parent, Instance *inst);
EINTERN Evas_Object *sysinfo_thermal_create(Evas_Object *parent, Instance *inst);
EINTERN Evas_Object *sysinfo_cpuclock_create(Evas_Object *parent, Instance *inst);
EINTERN Evas_Object *sysinfo_cpumonitor_create(Evas_Object *parent, Instance *inst);
EINTERN Evas_Object *sysinfo_memusage_create(Evas_Object *parent, Instance *inst);
EINTERN Evas_Object *sysinfo_netstatus_create(Evas_Object *parent, Instance *inst);

EINTERN void sysinfo_batman_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED);
EINTERN void sysinfo_thermal_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED);
EINTERN void sysinfo_cpuclock_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED);
EINTERN void sysinfo_cpumonitor_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED);
EINTERN void sysinfo_memusage_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED);
EINTERN void sysinfo_netstatus_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED);

EINTERN extern Config *sysinfo_config;
EINTERN extern Eina_List *sysinfo_instances;

#endif