summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2003-08-25 16:41:34 (UTC)
committer zecke <zecke>2003-08-25 16:41:34 (UTC)
commit93572d0abaae444a56051d21a6fdbb76d56726e3 (patch) (side-by-side diff)
tree859d9d17e45d3acf2ecb9b4157ac96daba714ad6 /libopie
parent44b9e62c1e5071fc6e5f8e80204b9974dbc704b6 (diff)
downloadopie-93572d0abaae444a56051d21a6fdbb76d56726e3.zip
opie-93572d0abaae444a56051d21a6fdbb76d56726e3.tar.gz
opie-93572d0abaae444a56051d21a6fdbb76d56726e3.tar.bz2
add is null
and comment about constness
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.h3
-rw-r--r--libopie/odevicebutton.cpp4
-rw-r--r--libopie/odevicebutton.h2
3 files changed, 8 insertions, 1 deletions
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 650a2da..d8ad135 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -1,50 +1,51 @@
/* This file is part of the OPIE libraries
Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
+ Copyright (C) 2003 Holger 'zecke' Freyther (zecke@handhelds.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef _LIBOPIE_ODEVICE_H_
#define _LIBOPIE_ODEVICE_H_
#include <qobject.h>
#include <qstring.h>
#include <qnamespace.h>
#include <qstrlist.h>
#include <opie/odevicebutton.h>
#include <qpe/qpeapplication.h> /* for Transformation enum.. */
class ODeviceData;
namespace Opie {
/**
* The available devices
*/
enum OModel {
Model_Unknown, // = 0
Model_Series_Mask = 0xff000000,
Model_iPAQ = ( 1 << 24 ),
Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
@@ -168,89 +169,89 @@ public:
OSystem system ( ) const;
QString systemVersionString ( ) const;
Transformation rotation ( ) const;
ODirection direction ( ) const;
// system
virtual bool setSoftSuspend ( bool on );
virtual bool suspend ( );
virtual bool setDisplayStatus ( bool on );
virtual bool setDisplayBrightness ( int brightness );
virtual int displayBrightnessResolution ( ) const;
virtual bool setDisplayContrast ( int contrast );
virtual int displayContrastResolution ( ) const;
// don't add new virtual methods, use this:
// /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
// and in your subclass do do overwrite
// protected virtual int virtual_hook(int, void *)
// which is defined below
// input / output
//FIXME playAlarmSound and al might be better -zecke
virtual void alarmSound ( );
virtual void keySound ( );
virtual void touchSound ( );
virtual QValueList <OLed> ledList ( ) const;
virtual QValueList <OLedState> ledStateList ( OLed led ) const;
virtual OLedState ledState ( OLed led ) const;
virtual bool setLedState ( OLed led, OLedState st );
virtual bool hasLightSensor ( ) const;
virtual int readLightSensor ( );
virtual int lightSensorResolution ( ) const;
const QStrList &allowedCpuFrequencies() const;
bool setCurrentCpuFrequency(uint index);
/**
* Returns the available buttons on this device. The number and location
* of buttons will vary depending on the device. Button numbers will be assigned
* by the device manufacturer and will be from most preferred button to least preffered
* button. Note that this list only contains "user mappable" buttons.
*/
- const QValueList<ODeviceButton> &buttons ( );
+ const QValueList<ODeviceButton> &buttons ( ) /* ### make const */;
/**
* Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
* returns 0L
*/
const ODeviceButton *buttonForKeycode ( ushort keyCode );
/**
* Reassigns the pressed action for \a button. To return to the factory
* default pass an empty string as \a qcopMessage.
*/
void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
/**
* Reassigns the held action for \a button. To return to the factory
* default pass an empty string as \a qcopMessage.
*/
void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
/**
* How long (in ms) you have to press a button for a "hold" action
*/
uint buttonHoldTime ( ) const;
signals:
void buttonMappingChanged ( );
private slots:
void systemMessage ( const QCString &, const QByteArray & );
protected:
void reloadButtonMapping ( );
/* ugly virtual hook */
virtual void virtual_hook( int id, void* data );
};
}
#endif
diff --git a/libopie/odevicebutton.cpp b/libopie/odevicebutton.cpp
index eccb57c..314eb51 100644
--- a/libopie/odevicebutton.cpp
+++ b/libopie/odevicebutton.cpp
@@ -51,96 +51,100 @@ OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
{
init ( assign. channel ( ), assign. message ( ), assign. data ( ));
return *this;
}
OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
: d ( 0 )
{
init ( ch, m, arg );
}
void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
{
if ( !d )
d = new OQCopMessageData ( );
d-> m_channel = ch;
d-> m_message = m;
d-> m_data = arg;
}
bool OQCopMessage::send ( )
{
if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ) )
return false;
QCopEnvelope e ( d-> m_channel, d-> m_message );
if ( d-> m_data. size ( ))
e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( ));
return true;
}
QCString OQCopMessage::channel ( ) const
{
return d-> m_channel;
}
QCString OQCopMessage::message ( ) const
{
return d-> m_message;
}
QByteArray OQCopMessage::data ( ) const
{
return d-> m_data;
}
+bool OQCopMessage::isNull() const
+{
+ return d-> m_message.isNull() || d-> m_channel.isNull();
+}
void OQCopMessage::setChannel ( const QCString &ch )
{
d-> m_channel = ch;
}
void OQCopMessage::setMessage ( const QCString &m )
{
d-> m_message = m;
}
void OQCopMessage::setData ( const QByteArray &data )
{
d-> m_data = data;
}
/*! \class Opie::ODeviceButton
\brief The Opie::ODeviceButton class represents a physical user mappable button on a Qtopia device.
This class represents a physical button on a Qtopia device. A
device may have "user programmable" buttons.
The location and number of buttons will vary from device to
device. userText() and pixmap() may be used to describe this button
to the user in help documentation.
\ingroup qtopiaemb
\internal
*/
ODeviceButton::ODeviceButton()
{
}
ODeviceButton::~ODeviceButton()
{
}
/*!
Returns the button's keycode.
*/
ushort ODeviceButton::keycode() const
{
return m_Keycode;
}
/*!
This function returns a human readable, translated description of the button.
*/
diff --git a/libopie/odevicebutton.h b/libopie/odevicebutton.h
index fcc2af1..1621526 100644
--- a/libopie/odevicebutton.h
+++ b/libopie/odevicebutton.h
@@ -1,94 +1,96 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DEVICE_BUTTON_H
#define DEVICE_BUTTON_H
#include <qpixmap.h>
#include <qstring.h>
class OQCopMessageData;
namespace Opie
{
class OQCopMessage {
public:
OQCopMessage ( );
OQCopMessage ( const OQCopMessage &copy );
OQCopMessage ( const QCString &m_channel, const QCString &message, const QByteArray &args = QByteArray ( ));
OQCopMessage &operator = ( const OQCopMessage &assign );
void setChannel ( const QCString &channel );
void setMessage ( const QCString &message );
void setData ( const QByteArray &ba );
QCString channel ( ) const;
QCString message ( ) const;
QByteArray data ( ) const;
+ bool isNull()const;
+
bool send ( );
private:
void init ( const QCString &m_channel, const QCString &message, const QByteArray &args );
OQCopMessageData *d;
class Private;
Private* m_data;
};
/**
* This class represents a physical button on a Qtopia device. A device may
* have n "user programmable" buttons, which are number 1..n. The location
* and number of buttons will vary from device to device. userText() and pixmap()
* may be used to describe this button to the user in help documentation.
*
* @version 1.0
* @author Trolltech
* @short A representation of buttons
*/
class ODeviceButton
{
public:
ODeviceButton();
virtual ~ODeviceButton();
ushort keycode ( ) const;
QString userText ( ) const;
QPixmap pixmap ( ) const;
OQCopMessage factoryPresetPressedAction ( ) const;
OQCopMessage pressedAction ( ) const;
OQCopMessage factoryPresetHeldAction ( ) const;
OQCopMessage heldAction ( ) const;
void setKeycode ( ushort keycode );
void setUserText ( const QString& text );
void setPixmap ( const QPixmap& picture );
void setFactoryPresetPressedAction ( const OQCopMessage& qcopMessage );
void setPressedAction ( const OQCopMessage& qcopMessage );
void setFactoryPresetHeldAction ( const OQCopMessage& qcopMessage );
void setHeldAction ( const OQCopMessage& qcopMessage );
private:
ushort m_Keycode;
QString m_UserText;
QPixmap m_Pixmap;