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 DEVICE_H 00026 #define DEVICE_H 00027 00028 #include <list> 00029 #include <string> 00030 00033 enum DPM_POWER_STATE { DPM_STATE_UNKNOWN = -1, DPM_STATE_D0, DPM_STATE_D1, 00034 DPM_STATE_D2, DPM_STATE_D3 }; 00035 00037 enum DPM_DEVICE_CLASS { DPM_CLASS_USB, DPM_CLASS_LAN, DPM_CLASS_WLAN, 00038 DPM_CLASS_SOUND, DPM_CLASS_MAX }; 00039 00041 extern char *DPM_CLASS_NAMES[DPM_CLASS_MAX]; 00042 00044 class Device { 00045 public: 00050 Device(const std::string &udi); 00051 00053 virtual ~Device(); 00054 00062 virtual bool suspend(DPM_POWER_STATE state = DPM_STATE_D3, bool force = false); 00063 00068 virtual bool resume(); 00069 00076 virtual bool isActive() = 0; 00077 00082 virtual DPM_DEVICE_CLASS deviceClass(); 00083 00088 virtual std::string udi(); 00089 00097 virtual DPM_POWER_STATE updateState(); 00098 00105 DPM_POWER_STATE readState(const std::string &state_file); 00106 00107 protected: 00109 std::string _udi; 00110 00112 DPM_DEVICE_CLASS _device_class; 00113 00118 std::string _device_path; 00119 00124 std::string _state_file; 00125 00126 private: 00128 DPM_POWER_STATE _current_state; 00129 }; 00130 00131 00133 class UsbDevice : public Device { 00134 public: 00139 UsbDevice(const std::string &udi); 00140 00142 ~UsbDevice(); 00143 00148 virtual bool isActive(); 00149 00154 static void getDevices(std::list<std::string> &device_udis); 00155 00162 static bool isDevice(const char *udi); 00163 }; 00164 00165 00167 class WlanDevice : public Device { 00168 public: 00173 WlanDevice(const std::string &udi); 00174 00176 ~WlanDevice(); 00177 00182 virtual bool isActive(); 00183 00188 static void getDevices(std::list<std::string> &device_udis); 00189 00196 static bool isDevice(char *udi); 00197 }; 00198 00199 00201 class SoundDevice : public Device { 00202 public: 00207 SoundDevice(const std::string &udi); 00208 00210 ~SoundDevice(); 00211 00216 virtual bool isActive(); 00217 00222 static void getDevices(std::list<std::string> &device_udis); 00223 00230 static bool isDevice(const char *udi); 00231 }; 00232 00233 00235 class LanDevice : public Device { 00236 public: 00241 LanDevice(const std::string &udi); 00242 00244 ~LanDevice(); 00245 00250 virtual bool isActive(); 00251 00256 static void getDevices(std::list<std::string> &device_udis); 00257 00264 static bool isDevice(char *udi); 00265 }; 00266 00267 #endif // DEVICE_H