summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2004-02-19 20:29:53 (UTC)
committer zecke <zecke>2004-02-19 20:29:53 (UTC)
commitf6f89c9fad356f91f1ad63402757335f7fb4fed2 (patch) (side-by-side diff)
tree9646358fb1b6bdec12fa29971936cbe63ad8f06b /libopie
parentc2eb77f6b8933b02bd8bd59ec7325da0bfc956cb (diff)
downloadopie-f6f89c9fad356f91f1ad63402757335f7fb4fed2.zip
opie-f6f89c9fad356f91f1ad63402757335f7fb4fed2.tar.gz
opie-f6f89c9fad356f91f1ad63402757335f7fb4fed2.tar.bz2
Restore binary compatibility and make use of the virtual_hook
Yeah it is ugly... but will work for libopie... Now onto libopie2! development
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp112
-rw-r--r--libopie/odevice.h24
2 files changed, 107 insertions, 29 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index c5a916b..c5342e1 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -77,2 +77,3 @@ public:
QStrList *m_cpu_frequencies;
+
};
@@ -142,4 +143,4 @@ public:
- virtual bool hasHingeSensor() const;
- virtual OHingeStatus readHingeSensor();
+ bool hasHingeSensor() const;
+ OHingeStatus readHingeSensor();
@@ -149,4 +150,4 @@ public:
virtual bool suspend ( );
- virtual Transformation rotation ( ) const;
- virtual ODirection direction ( ) const;
+ Transformation rotation ( ) const;
+ ODirection direction ( ) const;
@@ -157,2 +158,3 @@ protected:
bool m_embedix;
+ void virtual_hook( int id, void *data );
};
@@ -446,3 +448,3 @@ ODevice *ODevice::inst ( )
- if ( !dev ) {
+ if ( !dev ) {
if ( QFile::exists ( "/proc/hal/model" ))
@@ -730,3 +732,6 @@ Transformation ODevice::rotation ( ) const
{
- return d-> m_rotation;
+ VirtRotation rot;
+ ODevice* that =(ODevice* )this;
+ that->virtual_hook( VIRTUAL_ROTATION, &rot );
+ return rot.trans;
}
@@ -738,3 +743,6 @@ ODirection ODevice::direction ( ) const
{
- return d-> m_direction;
+ VirtDirection dir;
+ ODevice* that =(ODevice* )this;
+ that->virtual_hook( VIRTUAL_DIRECTION, &dir );
+ return dir.direct;
}
@@ -848,3 +856,6 @@ bool ODevice::hasHingeSensor ( ) const
{
- return false;
+ VirtHasHinge hing;
+ ODevice* that =(ODevice* )this;
+ that->virtual_hook( VIRTUAL_HAS_HINGE, &hing );
+ return hing.hasHinge;
}
@@ -856,3 +867,5 @@ OHingeStatus ODevice::readHingeSensor ( )
{
- return CASE_UNKNOWN;
+ VirtHingeStatus hing;
+ virtual_hook( VIRTUAL_HINGE, &hing );
+ return hing.hingeStat;
}
@@ -1005,4 +1018,25 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
}
-void ODevice::virtual_hook(int, void* ){
-
+void ODevice::virtual_hook(int id, void* data){
+ switch( id ) {
+ case VIRTUAL_ROTATION:{
+ VirtRotation* rot = reinterpret_cast<VirtRotation*>( data );
+ rot->trans = d->m_rotation;
+ break;
+ }
+ case VIRTUAL_DIRECTION:{
+ VirtDirection *dir = reinterpret_cast<VirtDirection*>( data );
+ dir->direct = d->m_direction;
+ break;
+ }
+ case VIRTUAL_HAS_HINGE:{
+ VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data );
+ hin->hasHinge = false;
+ break;
+ }
+ case VIRTUAL_HINGE:{
+ VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data );
+ hin->hingeStat = CASE_UNKNOWN;
+ break;
+ }
+ }
}
@@ -1042,6 +1076,6 @@ void Yopy::init ( )
d-> m_rotation = Rot0;
-
+
d-> m_systemstr = "Linupy";
d-> m_system = System_Linupy;
-
+
QFile f ( "/etc/issue" );
@@ -1065,3 +1099,3 @@ void Yopy::initButtons ( )
yopy_button *ib = yopy_buttons + i;
-
+
ODeviceButton b;
@@ -1079,5 +1113,5 @@ void Yopy::initButtons ( )
reloadButtonMapping ( );
-
+
QCopChannel *sysch = new QCopChannel("QPE/System", this);
- connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
+ connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
this, SLOT(systemMessage(const QCString &, const QByteArray & )));
@@ -1087,4 +1121,4 @@ bool Yopy::suspend()
{
- /* Opie for Yopy does not implement its own power management at the
- moment. The public version runs parallel to X, and relies on the
+ /* Opie for Yopy does not implement its own power management at the
+ moment. The public version runs parallel to X, and relies on the
existing power management features. */
@@ -1545,3 +1579,3 @@ bool Zaurus::isZaurus()
return true;
- }
+ }
@@ -1823,3 +1857,3 @@ void Zaurus::buzzer ( int sound )
Sound snd ( soundname );
-
+
if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
@@ -1850,5 +1884,5 @@ void Zaurus::buzzer ( int sound )
}
- } else {
+ } else {
int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
-
+
if ( fd >= 0 ) {
@@ -1858,3 +1892,3 @@ void Zaurus::buzzer ( int sound )
- }
+ }
#endif
@@ -2068,5 +2102,5 @@ Transformation Zaurus::rotation ( ) const
- if (retval == 2 )
+ if (retval == 2 )
rot = Rot0;
- else
+ else
rot = Rot270;
@@ -2155,2 +2189,30 @@ OHingeStatus Zaurus::readHingeSensor()
+void Zaurus::virtual_hook( int id, void *data ) {
+ switch( id ) {
+ case VIRTUAL_ROTATION:{
+ VirtRotation* rot = reinterpret_cast<VirtRotation*>( data );
+ rot->trans = rotation();
+ break;
+ }
+ case VIRTUAL_DIRECTION:{
+ VirtDirection *dir = reinterpret_cast<VirtDirection*>( data );
+ dir->direct = direction();
+ break;
+ }
+ case VIRTUAL_HAS_HINGE:{
+ VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data );
+ hin->hasHinge = hasHingeSensor();
+ break;
+ }
+ case VIRTUAL_HINGE:{
+ VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data );
+ hin->hingeStat = readHingeSensor();
+ break;
+ }
+ default:
+ ODevice::virtual_hook( id, data );
+ break;
+ }
+}
+
/**************************************************
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 791d358..fc41079 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -196,4 +196,4 @@ public:
- virtual Transformation rotation ( ) const;
- virtual ODirection direction ( ) const;
+ /*virtual*/ Transformation rotation ( ) const;
+ /*virtual*/ ODirection direction ( ) const;
@@ -231,4 +231,4 @@ public:
- virtual bool hasHingeSensor ( ) const;
- virtual OHingeStatus readHingeSensor ( );
+ /*virtual*/ bool hasHingeSensor ( ) const;
+ /*virtual*/ OHingeStatus readHingeSensor ( );
@@ -280,2 +280,18 @@ protected:
virtual void virtual_hook( int id, void* data );
+
+protected:
+ enum { VIRTUAL_ROTATION = 0x200, VIRTUAL_DIRECTION,
+ VIRTUAL_HAS_HINGE, VIRTUAL_HINGE };
+ struct VirtRotation {
+ Transformation trans;
+ };
+ struct VirtDirection {
+ ODirection direct;
+ };
+ struct VirtHasHinge {
+ bool hasHinge;
+ };
+ struct VirtHingeStatus {
+ OHingeStatus hingeStat;
+ };
};