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

oqwsserver.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of 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 #include <syslog.h>
00022 
00023 #include "oqwsserver.h"
00024 #include "qcopbridge.h"
00025 #include "transferserver.h"
00026 
00027 
00028 #if defined( QT_QWS_SL5XXX ) || defined( QT_QWS_IPAQ )
00029 #include <qpe/custom.h>
00030 #endif
00031 
00032 #include <opie2/odevice.h>
00033 
00034 
00035 
00036 #include <stdlib.h>
00037 #include <unistd.h>
00038 #include <fcntl.h>
00039 
00040 using namespace Opie;
00041 
00042 OQWSServer::OQWSServer( int& argc, char **argv, Type appType )
00043         : QPEApplication( argc, argv, appType )
00044 {
00045         startServers();
00046 }
00047 
00048 OQWSServer::~OQWSServer()
00049 {
00050         terminateServers();
00051 }
00052 
00053 bool OQWSServer::eventFilter ( QObject *o, QEvent *e )
00054 {
00055 #if 0
00056         if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) {
00057                 QKeyEvent *ke = (QKeyEvent *) e;
00058         
00059                 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( ));
00060         
00061                 if ( db ) {
00062                         if (checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )))
00063                                 return true;            //checkButtonAction retrune false if events should be routed through
00064                 }
00065         }
00066 #endif
00067         return QPEApplication::eventFilter ( o, e );
00068 }
00069 
00070 #ifdef Q_WS_QWS
00071 
00072 bool OQWSServer::qwsEventFilter( QWSEvent *e )
00073 {
00074 #if 0
00075         qpedesktop->checkMemory();
00076 
00077         if ( e->type == QWSEvent::Key ) {
00078                 QWSKeyEvent * ke = (QWSKeyEvent *) e;
00079                 ushort keycode = ke-> simpleData. keycode;
00080 
00081                 if ( !loggedin && keycode != Key_F34 )
00082                         return true;
00083                         
00084                 bool press = ke-> simpleData. is_press;
00085                 bool autoRepeat = ke-> simpleData. is_auto_repeat;
00086 
00087                 if ( !keyboardGrabbed ( )) {
00088                         // app that registers key/message to be sent back to the app, when it doesn't have focus,
00089                         // when user presses key, unless keyboard has been requested from app.
00090                         // will not send multiple repeats if user holds key
00091                         // i.e. one shot
00092                  
00093                         if ( keycode != 0 && press && !autoRepeat ) {
00094                                 for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
00095                                         if (( *it ). getKeyCode ( ) == keycode ) {
00096                                                 QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( ));
00097                                                 return true;
00098                                         }
00099                                 }
00100                         }
00101                 }
00102 
00103                 if ( keycode == HardKey_Suspend ) {
00104                         if ( press )
00105                                 emit power ( );
00106                         return true;
00107                 }
00108                 else if ( keycode == HardKey_Backlight ) {
00109                         if ( press )
00110                                 emit backlight ( );
00111                         return true;
00112                 }
00113                 else if ( keycode == Key_F32 ) {
00114                         if ( press )
00115                                 QCopEnvelope e( "QPE/Desktop", "startSync()" );
00116                         return true;
00117                 }
00118                 else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM
00119                         if ( press )
00120                                 emit symbol ( );
00121                         return true;
00122                 }
00123                 else if ( keycode == Key_NumLock ) {
00124                         if ( press )
00125                                 emit numLockStateToggle ( );
00126                 }
00127                 else if ( keycode == Key_CapsLock ) {
00128                         if ( press )
00129                                 emit capsLockStateToggle();
00130                 }
00131                 if (( press && !autoRepeat ) || ( !press && autoRepeat )) {
00132                         if ( m_keyclick_sound )
00133                                 ODevice::inst ( )-> keySound ( );
00134                 }
00135         }
00136         else if ( e-> type == QWSEvent::Mouse ) {
00137                 QWSMouseEvent * me = ( QWSMouseEvent * ) e;
00138                 static bool up = true;
00139 
00140                 if ( me-> simpleData. state & LeftButton ) {
00141                         if ( up ) {
00142                                 up = false;
00143                                 if ( m_screentap_sound )
00144                                         ODevice::inst ( ) -> touchSound ( );
00145                         }
00146                 }
00147                 else {
00148                         up = true;
00149                 }
00150         }
00151 #endif
00152         return QPEApplication::qwsEventFilter ( e );
00153 }
00154 
00155 #endif
00156 
00157 void OQWSServer::startServers()
00158 {
00159         // start qcop bridge server
00160         m_qcopBridge = new QCopBridge( 4243 );
00161         if ( !m_qcopBridge->ok() ) {
00162                 delete m_qcopBridge;
00163                 m_qcopBridge = 0;
00164         }
00165         // start transfer server
00166         m_transferServer = new TransferServer( 4242 );
00167         if ( !m_transferServer->ok() ) {
00168                 delete m_transferServer;
00169                 m_transferServer = 0;
00170         }
00171 //      if ( !transferServer || !qcopBridge )
00172 //              startTimer( 2000 );
00173 }
00174 
00175 void OQWSServer::terminateServers()
00176 {
00177         delete m_transferServer;
00178         delete m_qcopBridge;
00179         m_transferServer = 0;
00180         m_qcopBridge = 0;
00181 }

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