pm_interface.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *                         Powersave Daemon                                *
00004  *                                                                         *
00005  *          Copyright (C) 2004,2005 SUSE Linux Products GmbH               *
00006  *                                                                         *
00007  *               Author(s): Holger Macht <hmacht@suse.de>                  *
00008  *                                                                         *
00009  * This program is free software; you can redistribute it and/or modify it *
00010  * under the terms of the GNU General Public License as published by the   *
00011  * Free Software Foundation; either version 2 of the License, or (at you   *
00012  * option) any later version.                                              *
00013  *                                                                         *
00014  * This program is distributed in the hope that it will be useful, but     *
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of              *
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
00017  * General Public License for more details.                                *
00018  *                                                                         *
00019  * You should have received a copy of the GNU General Public License along *
00020  * with this program; if not, write to the Free Software Foundation, Inc., *
00021  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA                  *
00022  *                                                                         *
00023  ***************************************************************************/
00024 
00025 #ifndef POWERSAVE_PM_INTERFACE_H
00026 #define POWERSAVE_PM_INTERFACE_H
00027 
00028 #ifdef CPUFREQ_MEASURE
00029 #define MEASURE_LOG_FILE "/tmp/cpufreq.log"
00030 #endif
00031 
00032 #define ACPI_SLEEP_SCRIPT "do_acpi_sleep"
00033 
00034 #include <errno.h>
00035 #include "throttle_interface.h"
00036 #include "config_pm.h"
00037 #include "powersave_dbus.h"
00038 #include "battery.h"
00039 #include "device_management.h"
00040 
00041 class MainLoop;
00042 class EventManagement;
00043 class Brightness;
00044 class ClientConnection;
00045 class CpufreqManagement;
00046 
00047 typedef struct PM_STATE {
00048         // THERM_MODE comes from library libpower.h
00049         THERM_MODE TEMP_STATE;
00050         AC_ADAPTER_STATE AC_STATE;
00051          PM_STATE() {
00052                 TEMP_STATE = OK;
00053                 AC_STATE = AC_UNKNOWN;
00054 }} PM_STATE;
00055 
00058 enum PSD_SLEEP_STATE_REQUESTS { PSD_NO_SLEEP_REQUEST = 0, PSD_SUSPEND2DISK, PSD_SUSPEND2RAM, PSD_STANDBY };
00059 
00065 class PM_Interface {
00066 public:
00068         PM_Interface();
00069         
00071         virtual ~ PM_Interface();
00072         
00077         BATTERY_STATES batteryState();
00078 
00082         void sleep_wrapper(const string &);
00083 
00085         int executeScript(const string &script, const string &param);
00086 
00093         int screenlock(const string &param);
00094 
00101         int x_notification(const string &param);
00102 
00104         void ignore_buttons(bool);
00105 
00111         virtual int start();
00112 
00115         virtual void checkTemperatureStateChanges();
00116 
00123         virtual void checkBatteryStateChanges();
00124 
00133         virtual int checkACStateChanges();
00134 
00143         virtual int updateTemperatureState();
00144 
00151         virtual int updateACState();
00152 
00154         virtual bool checkThrottling();
00155 
00163         void checkDevice(char *udi, bool added);
00164 
00173         virtual int activateScheme(const string &scheme_name);
00174 
00184         virtual int activateScheme(AC_ADAPTER_STATE ac_state);
00185 
00197         virtual void activateSettings();
00198 
00200         virtual int rereadConfig();
00201 
00207         virtual void throttle(int percent = -1);
00208 
00214         virtual void dethrottle();
00215 
00220         virtual void resume();
00221 
00231         DBUS_ERROR handleDBusRequest(DBusMessage *req, DBusMessage *reply,
00232                                      POWERSAVE_MESSAGE_TYPE type);
00233 
00238         virtual int suspend_to_ram() = 0;
00239 
00244         virtual int standby() = 0;
00245 
00250         virtual int openHWEventFD() = 0;
00251 
00256         virtual int openAcpidSocket() = 0;
00257 
00262         virtual int handleHWEventRequest(int fd = -1) = 0;
00263 
00268         void suspendNetworkManager();
00269 
00274         void resumeNetworkManager();
00275 
00280         bool haveSuspend2();
00281 
00283         ClientConnection *_cC;
00284 
00286         EventManagement *_eM;
00287 
00290         Brightness *_brightness;
00291 
00292 protected:
00294         bool _cooling_mode_supported;
00295 
00297         bool _thermal_trip_points_supported;
00298 
00301         PM_STATE _cur_state;
00302 
00304         int64_t _supported_sleeping_states;
00305 
00308         static PSD_SLEEP_STATE_REQUESTS _requested_sleep_state;
00309 
00311         static bool _sleep_triggered;
00312 
00314         ThrottleInterface _throttleInterface;
00315 
00317         Battery _battery;
00318 
00319 private:
00324         DBUS_ERROR handleManagerMessage(DBusMessage * msg);
00325  
00330         DBUS_ERROR handleScriptsMessage( DBusMessage *msg );
00331 
00337         DBUS_ERROR handleRequestMessage(DBusMessage * msg, DBusMessage * reply);
00338 
00343         DBUS_ERROR handleActionMessage(DBusMessage * msg);
00344 
00346         DeviceManagement _devices;
00347 };
00348 
00349 #endif // POWERSAVE_PM_INTERFACE_H

Generated on Mon Mar 27 09:27:19 2006 for Powersave Daemon by  doxygen 1.4.6