~ubuntu-branches/ubuntu/karmic/powersave/karmic

« back to all changes in this revision

Viewing changes to daemon/acpi.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2006-01-13 21:38:52 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060113213852-lqnirx6tfj6q76jv
Tags: 0.11.2-1
* New upstream release.
* Removed patches shebang_fix.diff, awk_path_fix.diff and
  wttyhx_fixes.diff, all merged upstream.
* hal and dbus are now mandatory. Added the corresponding dependencies to
  debian/control.
* Added powersaved.postinst, dbus needs to be reloaded after powersaved has
  been installed. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *                                                                         *
 
3
 *                         Powersave Daemon                                *
 
4
 *                                                                         *
 
5
 *          Copyright (C) 2004,2005 SUSE Linux Products GmbH               *
 
6
 *                                                                         *
 
7
 * This program is free software; you can redistribute it and/or modify it *
 
8
 * under the terms of the GNU General Public License as published by the   *
 
9
 * Free Software Foundation; either version 2 of the License, or (at you   *
 
10
 * option) any later version.                                              *
 
11
 *                                                                         *
 
12
 * This program is distributed in the hope that it will be useful, but     *
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of              *
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
 
15
 * General Public License for more details.                                *
 
16
 *                                                                         *
 
17
 * You should have received a copy of the GNU General Public License along *
 
18
 * with this program; if not, write to the Free Software Foundation, Inc., *
 
19
 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA                  *
 
20
 *                                                                         *
 
21
 ***************************************************************************/
 
22
 
1
23
#ifndef POWERSAVE_ACPI_H
2
24
#define POWERSAVE_ACPI_H
3
25
 
4
 
#define ACPI_EVENTFILE "/proc/acpi/event"
5
26
#define ACPI_SLEEPFILE "/proc/acpi/sleep"
6
27
 
7
 
 
8
 
class ACPI_Interface : public PM_Interface
9
 
{
10
 
 private:
11
 
        
12
 
        // workaround for buggy double button events
13
 
        // only allow one button event(sleep/power)
14
 
        // inside the time window below (in millisecs)
15
 
        unsigned long last_button_occurence;
16
 
        const static unsigned int button_time_window = 1000;
17
 
 
18
 
        int setBatteryAlarm_();
19
 
 
20
 
        static string acpidSocketFile;
21
 
 public:
22
 
        // default initialisation
23
 
        ACPI_Interface(GeneralConfig *config_obj);
24
 
        virtual ~ACPI_Interface();
 
28
#include "pm_interface.h"
 
29
 
 
30
class ACPI_Interface : public PM_Interface {
 
31
public:
 
32
        /** @brief default initialisation */
 
33
         ACPI_Interface();
 
34
 
 
35
        /** @brief destructor */
 
36
         virtual ~ ACPI_Interface();
 
37
 
 
38
        /** @brief opens the acpi event file
 
39
         *
 
40
         * @return the filedescriptor or -1 on error
 
41
         * @retval < 0 on error
 
42
         * @retval the filedesctiptor on success
 
43
         */
25
44
        virtual int openHWEventFD();
26
 
        virtual int handleHWEventRequest();
 
45
 
 
46
        /** @brief Handles an event on the socket
 
47
         *
 
48
         * @return integer value with result if handle event
 
49
         * @retval 1 if an event has been generated
 
50
         * @retval 0 if no event has been generated
 
51
         * @retval -1 on fatal errors
 
52
         * @retval -2 if acpid shuts down/ socket is missing
 
53
         */
 
54
        virtual int handleHWEventRequest(int fd = -1);
 
55
 
 
56
        /** @brief triggers execution of suspend_to_ram script
 
57
         *
 
58
         * @return true on success, false if not supported
 
59
         */
27
60
        virtual int suspend_to_ram();
 
61
 
 
62
        /** @brief triggers execution of standby script
 
63
         *
 
64
         * @return true on success, false if not supported
 
65
         */
28
66
        virtual int standby();
 
67
 
 
68
        /** @brief get time in millisecs since 1970
 
69
         *
 
70
         * @return time in milliseconds since 1970
 
71
         */
29
72
        unsigned long getTimestamp();
 
73
 
 
74
        /** @brief opens the socket provided by acpid 
 
75
         *
 
76
         * @return the filedescriptor or < 0 on error
 
77
         */
30
78
        virtual int openAcpidSocket();
 
79
 
 
80
        /** @brief activates settings for specific scheme 
 
81
         *
 
82
         * throttling and thermal control only in ACPI
 
83
         */
31
84
        virtual void activateSettings();
 
85
 
 
86
        /** @brief event file for acpi events
 
87
         *
 
88
         * this is now configurable via -f parameter it could be either
 
89
         * the acpid socket or the kernel acpi event file
 
90
         */
 
91
        static string ACPI_EVENTFILE;
 
92
 
 
93
private:
 
94
        /** @brief sets the battery alarm of the current scheme
 
95
         *
 
96
         * @return integer value with the result of set batteryalarm
 
97
         * @retval - 1 on success
 
98
         * @retval -1 if alarm could not be set or is not supported
 
99
         */
 
100
        int setBatteryAlarm_();
 
101
 
 
102
        /** @brief workaround for buggy double button events
 
103
         *
 
104
         * only allow one button event(sleep/power)
 
105
         * inside the time window below (in millisecs)
 
106
         */
 
107
        unsigned long _last_button_occurence;
 
108
 
 
109
        /** @brief time window for ignoring double button events */
 
110
        const static unsigned int _button_time_window = 1000;
32
111
};
33
112
 
34
 
#endif
 
113
#endif // POWERSAVE_ACPI_H