summaryrefslogtreecommitdiff
path: root/core/applets/rotateapplet/rotate.cpp
Unidiff
Diffstat (limited to 'core/applets/rotateapplet/rotate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/rotateapplet/rotate.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp
index f621aa9..f23423d 100644
--- a/core/applets/rotateapplet/rotate.cpp
+++ b/core/applets/rotateapplet/rotate.cpp
@@ -22,24 +22,25 @@
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-= this library; see the file COPYING.LIB. 25    --        :-= this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include "rotate.h" 31#include "rotate.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odebug.h>
34#include <opie2/odevice.h> 35#include <opie2/odevice.h>
35#include <qpe/config.h> 36#include <qpe/config.h>
36#include <qpe/power.h> 37#include <qpe/power.h>
37#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
38#include <qpe/resource.h> 39#include <qpe/resource.h>
39using namespace Opie::Core; 40using namespace Opie::Core;
40 41
41/* QT */ 42/* QT */
42 43
43#include <time.h> 44#include <time.h>
44 45
45RotateApplet::RotateApplet() 46RotateApplet::RotateApplet()
@@ -53,59 +54,59 @@ RotateApplet::RotateApplet()
53#endif 54#endif
54 55
55} 56}
56 57
57RotateApplet::~RotateApplet ( ) 58RotateApplet::~RotateApplet ( )
58{} 59{}
59 60
60/** 61/**
61 * Qcop receive method. 62 * Qcop receive method.
62 */ 63 */
63void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) 64void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data )
64{ 65{
65 qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg ); 66 odebug << "RotateApplet::channelReceived( '" << msg << "' )" << oendl;
66 67
67 if ( ODevice::inst()->hasHingeSensor() ) 68 if ( ODevice::inst()->hasHingeSensor() )
68 { 69 {
69 struct timespec interval; 70 struct timespec interval;
70 struct timespec remain; 71 struct timespec remain;
71 interval.tv_sec = 0; 72 interval.tv_sec = 0;
72 interval.tv_nsec = 600000; 73 interval.tv_nsec = 600000;
73 ::nanosleep( &interval, &remain ); 74 ::nanosleep( &interval, &remain );
74 OHingeStatus status = ODevice::inst()->readHingeSensor(); 75 OHingeStatus status = ODevice::inst()->readHingeSensor();
75 qDebug( "RotateApplet::readHingeSensor = %d", (int) status ); 76 odebug << "RotateApplet::readHingeSensor = " << (int) status << "" << oendl;
76 77
77 Config cfg( "apm" ); 78 Config cfg( "apm" );
78 cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); 79 cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" );
79 int action = cfg.readNumEntry( "CloseHingeAction", 0 ); 80 int action = cfg.readNumEntry( "CloseHingeAction", 0 );
80 81
81 if ( status == CASE_CLOSED ) 82 if ( status == CASE_CLOSED )
82 { 83 {
83 switch ( action ) 84 switch ( action )
84 { 85 {
85 case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break; 86 case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break;
86 case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; 87 case 2: /* SUSPEND */ ODevice::inst()->suspend(); break;
87 default: /* IGNORE */ break; 88 default: /* IGNORE */ break;
88 } 89 }
89 } 90 }
90 else /* status != CASE_CLOSED */ 91 else /* status != CASE_CLOSED */
91 { 92 {
92 switch ( action ) 93 switch ( action )
93 { 94 {
94 case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break; 95 case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break;
95 case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break; 96 case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break;
96 default: /* IGNORE */ break; 97 default: /* IGNORE */ break;
97 } 98 }
98 } 99 }
99 qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) ); 100 odebug << "RotateApplet::switchAction " << cfg.readNumEntry( "CloseHingeAction" ) << " performed." << oendl;
100 } 101 }
101 102
102 QDataStream stream( data, IO_ReadOnly ); 103 QDataStream stream( data, IO_ReadOnly );
103 if ( msg == "flip()" ) 104 if ( msg == "flip()" )
104 { 105 {
105 activated ( ); 106 activated ( );
106 } 107 }
107 else if ( msg == "rotateDefault()") 108 else if ( msg == "rotateDefault()")
108 { 109 {
109 rotateDefault(); 110 rotateDefault();
110 } 111 }
111} 112}
@@ -230,23 +231,23 @@ void RotateApplet::activated()
230 m_flipped = !m_flipped; 231 m_flipped = !m_flipped;
231} 232}
232 233
233 234
234QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 235QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
235{ 236{
236 *iface = 0; 237 *iface = 0;
237 if ( uuid == IID_QUnknown ) 238 if ( uuid == IID_QUnknown )
238 *iface = this; 239 *iface = this;
239 else if ( uuid == IID_MenuApplet ) 240 else if ( uuid == IID_MenuApplet )
240 *iface = this; 241 *iface = this;
241 else 242 else
242 return QS_FALSE; 243 return QS_FALSE;
243 244
244 if ( *iface ) 245 if ( *iface )
245 (*iface)->addRef(); 246 (*iface)->addRef();
246 return QS_OK; 247 return QS_OK;
247} 248}
248 249
249Q_EXPORT_INTERFACE() 250Q_EXPORT_INTERFACE()
250{ 251{
251 Q_CREATE_INSTANCE( RotateApplet ) 252 Q_CREATE_INSTANCE( RotateApplet )
252} 253}