Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

odevice.h

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003                              Copyright (C) The Opie Team <opie-devel@handhelds.org>
00004               =.
00005             .=l.
00006            .>+-=
00007  _;:,     .>    :=|.         This program is free software; you can
00008 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00009 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00010 .="- .-=="i,     .._         License as published by the Free Software
00011  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00012      ._= =}       :          or (at your option) any later version.
00013     .%`+i>       _;_.
00014     .i_,=:_.      -<s.       This program is distributed in the hope that
00015      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00016     : ..    .:,     . . .    without even the implied warranty of
00017     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00018   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00019 ..}^=.=       =       ;      Library General Public License for more
00020 ++=   -.     .`     .:       details.
00021  :     =  ...= . :.=-
00022  -.   .:....=;==+<;          You should have received a copy of the GNU
00023   -_. . .   )=.  =           Library General Public License along with
00024     --        :-=`           this library; see the file COPYING.LIB.
00025                              If not, write to the Free Software Foundation,
00026                              Inc., 59 Temple Place - Suite 330,
00027                              Boston, MA 02111-1307, USA.
00028 */
00029 
00030 #ifndef ODEVICE_H_
00031 #define ODEVICE_H_
00032 
00033 /* OPIE */
00034 #include <opie2/odevicebutton.h>
00035 #include <qpe/qpeapplication.h> /* for Transformation enum.. */
00036 
00037 /* QT */
00038 #include <qnamespace.h>
00039 #include <qobject.h>
00040 #include <qstring.h>
00041 
00042 
00043 #include <qstrlist.h>
00044 #include <qwindowsystem_qws.h>
00045 
00046 
00047 class Sound;
00048 
00049 namespace Opie{
00050 namespace Core{
00051 
00052 class ODeviceData;
00056 enum OModel {
00057     Model_Unknown, // = 0
00058 
00059     Model_Series_Mask   = 0xffff0000,
00060 
00061     Model_iPAQ          = ( 1 << 16 ),
00062 
00063     Model_iPAQ_All      = ( Model_iPAQ | 0xffff ),
00064     Model_iPAQ_H31xx    = ( Model_iPAQ | 0x0001 ),
00065     Model_iPAQ_H36xx    = ( Model_iPAQ | 0x0002 ),
00066     Model_iPAQ_H37xx    = ( Model_iPAQ | 0x0003 ),
00067     Model_iPAQ_H38xx    = ( Model_iPAQ | 0x0004 ),
00068     Model_iPAQ_H39xx    = ( Model_iPAQ | 0x0005 ),
00069     Model_iPAQ_H5xxx    = ( Model_iPAQ | 0x0006 ),
00070     Model_iPAQ_H22xx    = ( Model_iPAQ | 0x0007 ),
00071     Model_iPAQ_H191x    = ( Model_iPAQ | 0x0008 ),
00072     Model_iPAQ_H1940    = ( Model_iPAQ | 0x0009 ),
00073 
00074     Model_Jornada       = ( 6 << 16 ),
00075     Model_Jornada_56x   = ( Model_Jornada | 0x0001 ),
00076     Model_Jornada_720   = ( Model_Jornada | 0x0002 ),
00077 
00078     Model_Zaurus        = ( 2 << 16 ),
00079 
00080     Model_Zaurus_SL5000 = ( Model_Zaurus | 0x0001 ),
00081     Model_Zaurus_SL5500 = ( Model_Zaurus | 0x0002 ),
00082     Model_Zaurus_SLA300 = ( Model_Zaurus | 0x0003 ),
00083     Model_Zaurus_SLB600 = ( Model_Zaurus | 0x0004 ),
00084     Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x0005 ),
00085     Model_Zaurus_SL6000 = ( Model_Zaurus | 0x0006 ),
00086     Model_Zaurus_SLC3000 = ( Model_Zaurus | 0x0007 ),
00087     Model_Zaurus_SLC1000 = ( Model_Zaurus | 0x0008 ),
00088     Model_Zaurus_SLC3100 = ( Model_Zaurus | 0x0009 ),
00089 
00090     Model_SIMpad        = ( 3 << 16 ),
00091 
00092     Model_SIMpad_All    = ( Model_SIMpad | 0xffff ),
00093     Model_SIMpad_CL4    = ( Model_SIMpad | 0x0001 ),
00094     Model_SIMpad_SL4    = ( Model_SIMpad | 0x0002 ),
00095     Model_SIMpad_SLC    = ( Model_SIMpad | 0x0003 ),
00096     Model_SIMpad_TSinus = ( Model_SIMpad | 0x0004 ),
00097 
00098     Model_Ramses        = ( 4 << 16 ),
00099 
00100     Model_Ramses_All    = ( Model_Ramses | 0xffff ),
00101     Model_Ramses_MNCI   = ( Model_Ramses | 0x0001 ),
00102     Model_Ramses_MNCIRX = ( Model_Ramses | 0x0002 ),
00103 
00104     Model_Yopy          = ( 5 << 16 ),
00105 
00106     Model_Yopy_All      = ( Model_Yopy | 0xffff ),
00107     Model_Yopy_3000     = ( Model_Yopy | 0x0001 ),
00108     Model_Yopy_3500     = ( Model_Yopy | 0x0002 ),
00109     Model_Yopy_3700     = ( Model_Yopy | 0x0003 ),
00110 
00111     Model_Beagle        = ( 6 << 16 ),
00112 
00113     Model_Beagle_All    = ( Model_Beagle | 0xffff ),
00114     Model_Beagle_PA100  = ( Model_Beagle | 0x0001 ),
00115 
00116     Model_GenuineIntel  = ( 7 << 16 ),
00117 
00118     Model_MyPal         = ( 8 << 16 ),
00119 
00120     Model_MyPal_All     = ( Model_MyPal | 0xffff ),
00121     Model_MyPal_620     = ( Model_MyPal | 0x0001 ),
00122     Model_MyPal_716     = ( Model_MyPal | 0x0002 ),
00123     Model_MyPal_730     = ( Model_MyPal | 0x0003 )
00124 };
00125 
00129 enum OVendor {
00130     Vendor_Unknown,
00131 
00132     Vendor_HP,
00133     Vendor_Sharp,
00134     Vendor_SIEMENS,
00135     Vendor_MundN,
00136     Vendor_GMate,
00137     Vendor_MasterIA,
00138     Vendor_GenuineIntel,
00139     Vendor_Asus
00140 };
00141 
00145 enum OSystem {
00146     System_Unknown,
00147 
00148     System_Familiar,
00149     System_Zaurus,
00150     System_OpenZaurus,
00151     System_Linupy,
00152     System_OpenEmbedded,
00153     System_PC
00154 };
00155 
00156 typedef struct {
00157     OSystem system;
00158     char* sysstr;
00159     char* sysvfile;
00160 } ODistribution;
00161 
00162 extern ODistribution distributions[];
00163 
00164 
00165 enum OLedState {
00166     Led_Off,
00167     Led_On,
00168     Led_BlinkSlow,
00169     Led_BlinkFast
00170 };
00171 
00172 enum OLed {
00173     Led_Mail,
00174     Led_Power,
00175     Led_BlueTooth
00176 };
00177 
00178 enum OHardKey {
00179     HardKey_Datebook  = Qt::Key_F9,
00180     HardKey_Contacts  = Qt::Key_F10,
00181     HardKey_Menu      = Qt::Key_F11,
00182     HardKey_Home      = Qt::Key_F12,
00183     HardKey_Mail      = Qt::Key_F13,
00184     HardKey_Record    = Qt::Key_F24,
00185     HardKey_Suspend   = Qt::Key_F34,
00186     HardKey_Backlight = Qt::Key_F35,
00187     HardKey_Action    = Qt::Key_F10,
00188     HardKey_OK        = Qt::Key_F11,
00189     HardKey_End       = Qt::Key_F12,
00190 };
00191 
00192 enum ODirection {
00193     CW   = 0,
00194     CCW  = 1,
00195     Flip = 2,
00196 };
00197 
00198 enum OHingeStatus {
00199     CASE_CLOSED = 3,
00200     CASE_PORTRAIT = 2,
00201     CASE_LANDSCAPE = 0,
00202     CASE_UNKNOWN = 1,
00203 };
00204 
00205 /* default button for qvfb or such
00206  * see odevice.cpp for details.
00207  * hint: manage a user defined button for qvfb?
00208  * alwin
00209  */
00210 struct default_button {
00211     Qt::Key code;
00212     char *utext;
00213     char *pix;
00214     char *fpressedservice;
00215     char *fpressedaction;
00216     char *fheldservice;
00217     char *fheldaction;
00218 };
00219 
00230 class ODevice : public QObject
00231 {
00232     Q_OBJECT
00233 
00234 private:
00235     /* disable copy */
00236     ODevice ( const ODevice & );
00237 
00238 protected:
00239     ODevice();
00240     virtual void init(const QString&);
00241     virtual void initButtons();
00242     static void sendSuspendmsg();
00243 
00244     ODeviceData *d;
00245 
00246 public:
00247     // sandman do we want to allow destructions? -zecke?
00248     virtual ~ODevice();
00249     static ODevice *inst();
00250 
00251     // information
00252     QString modelString() const;
00253     OModel model() const;
00254     inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
00255 
00256     QString vendorString() const;
00257     OVendor vendor() const;
00258 
00259     QString systemString() const;
00260     OSystem system() const;
00261 
00262     QString systemVersionString() const;
00263 
00264     virtual Transformation rotation() const;
00265     virtual ODirection direction() const;
00266 
00267     QString qteDriver() const;
00268 
00269     // system
00270     virtual bool suspend();
00271 
00272     virtual bool setDisplayStatus ( bool on );
00273     virtual bool setDisplayBrightness ( int brightness );
00274     virtual int displayBrightnessResolution() const;
00275     virtual bool setDisplayContrast ( int contrast );
00276     virtual int displayContrastResolution() const;
00277 
00278     // don't add new virtual methods, use this:
00279     //  /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
00280     // and in your subclass do overwrite
00281     //  protected virtual int virtual_hook(int, void *)
00282     // which is defined below
00283 
00284     // input / output
00285     virtual void playAlarmSound();
00286     virtual void playKeySound();
00287     virtual void playTouchSound();
00288 
00289     virtual QValueList <OLed> ledList() const;
00290     virtual QValueList <OLedState> ledStateList ( OLed led ) const;
00291     virtual OLedState ledState ( OLed led ) const;
00292     virtual bool setLedState ( OLed led, OLedState st );
00293 
00294     virtual bool hasLightSensor() const;
00295     virtual int readLightSensor();
00296     virtual int lightSensorResolution() const;
00297 
00298     virtual bool hasHingeSensor() const;
00299     virtual OHingeStatus readHingeSensor()const;
00300 
00301     const QStrList &allowedCpuFrequencies() const;
00302     bool setCurrentCpuFrequency(uint index);
00303 
00313     const QValueList<ODeviceButton> &buttons();
00314 
00319     const ODeviceButton *buttonForKeycode ( ushort keyCode );
00320 
00325     void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
00326 
00331     void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
00332 
00336     uint buttonHoldTime() const;
00337 
00338 signals:
00339     void buttonMappingChanged();
00340 
00341 private slots:
00342     void systemMessage ( const QCString &, const QByteArray & );
00343     void playingStopped();
00344 
00345 protected:
00346     void addPreHandler(QWSServer::KeyboardFilter*aFilter);
00347     void remPreHandler(QWSServer::KeyboardFilter*aFilter);
00348     void reloadButtonMapping();
00349     void changeMixerForAlarm( int mixer, const char* file, Sound *snd);
00350 
00351     /*  ugly virtual hook */
00352     virtual void virtual_hook( int id, void* data );
00353 };
00354 
00355 class ODeviceData {
00356 
00357   public:
00358     QString m_vendorstr;
00359     OVendor m_vendor;
00360 
00361     QString m_modelstr;
00362     OModel m_model;
00363 
00364     QString m_systemstr;
00365     OSystem m_system;
00366 
00367     QString m_sysverstr;
00368 
00369     Transformation m_rotation;
00370     ODirection m_direction;
00371 
00372     QString m_qteDriver;
00373 
00374     QValueList <ODeviceButton> *m_buttons;
00375     uint                        m_holdtime;
00376     QStrList                   *m_cpu_frequencies;
00377     bool    m_initializedButtonQcop : 1;
00378 
00379     /* values for changeMixerForAlarm */
00380     int m_sound, m_vol, m_mixer;
00381 };
00382 
00383 extern bool isQWS();
00384 extern QCString makeChannel ( const char *str );
00385 }
00386 }
00387 
00388 
00389 
00390 
00391 #endif
00392 

Generated on Sat Nov 5 16:16:05 2005 for OPIE by  doxygen 1.4.2