Qtopia library API Documentation

power.h

00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 #ifndef POWER_H
00022 #define POWER_H
00023 
00024 #include <qobject.h>
00025 
00026 class PowerStatus
00027 {
00028 public:
00029     PowerStatus() {
00030     ac = Offline;
00031     bs = NotPresent;
00032     bbs = NotPresent;
00033     percentRemain = -1;
00034     secsRemain = -1;
00035     }
00036 
00037     enum ACStatus { Offline, Online, Backup };
00038     ACStatus acStatus() const { return ac; }
00039 
00040     enum BatteryStatus { High=0x01, Low=0x02, VeryLow=0x04, Critical=0x08,
00041              Charging=0x10, NotPresent=0x20 };
00042     BatteryStatus batteryStatus() const { return bs; }
00043     BatteryStatus backupBatteryStatus() const { return bbs; }
00044 
00045     bool batteryPercentAccurate() const { return percentAccurate; }
00046     int batteryPercentRemaining() const { return percentRemain; }
00047     int batteryTimeRemaining() const { return secsRemain; }
00048 
00049     bool operator!=( const PowerStatus &ps ) {
00050     return  (ps.ac != ac) || (ps.bs != bs) || (ps.bbs != bbs) ||
00051         (ps.percentRemain != percentRemain) ||
00052         (ps.secsRemain != secsRemain );
00053     }
00054 
00055 private:
00056     ACStatus ac;
00057     BatteryStatus bs;
00058     BatteryStatus bbs;
00059     int percentRemain;
00060     int secsRemain;
00061     bool percentAccurate;
00062 
00063     friend class PowerStatusManager;
00064 };
00065 
00066 
00067 class PowerStatusManager
00068 {
00069 public:
00070     PowerStatusManager();
00071 
00072     static const PowerStatus &readStatus();
00073 
00074 protected:
00075     bool getProcApmStatus( int &ac, int &bs, int &bf, int &pc, int &sec );
00076     void getStatus();
00077 
00078 private:
00079     static PowerStatus *ps;
00080     static PowerStatusManager *powerManager;
00081 };
00082 
00083 
00084 #endif
00085 
KDE Logo
This file is part of the documentation for OPIE Version 1.5.5.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:06 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001