summaryrefslogtreecommitdiff
path: root/core/qws/oqwsserver.cpp
Unidiff
Diffstat (limited to 'core/qws/oqwsserver.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/qws/oqwsserver.cpp196
1 files changed, 196 insertions, 0 deletions
diff --git a/core/qws/oqwsserver.cpp b/core/qws/oqwsserver.cpp
new file mode 100644
index 0000000..1c61d19
--- a/dev/null
+++ b/core/qws/oqwsserver.cpp
@@ -0,0 +1,196 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <syslog.h>
22
23#include "oqwsserver.h"
24#include "qcopbridge.h"
25#include "transferserver.h"
26
27#include <qpe/applnk.h>
28#include <qpe/mimetype.h>
29#include <qpe/password.h>
30#include <qpe/config.h>
31#include <qpe/power.h>
32#include <qpe/timeconversion.h>
33#include <qpe/qcopenvelope_qws.h>
34#include <qpe/network.h>
35#include <qpe/global.h>
36
37#if defined( QT_QWS_SL5XXX ) || defined( QT_QWS_IPAQ )
38#include <qpe/custom.h>
39#endif
40
41#include <opie/odevice.h>
42
43#include <qgfx_qws.h>
44#include <qmainwindow.h>
45#include <qmessagebox.h>
46#include <qtimer.h>
47#include <qwindowsystem_qws.h>
48
49#include <qvaluelist.h>
50
51#include <stdlib.h>
52#include <unistd.h>
53#include <fcntl.h>
54
55using namespace Opie;
56
57OQWSServer::OQWSServer( int& argc, char **argv, Type appType )
58 : QPEApplication( argc, argv, appType )
59{
60 startServers();
61}
62
63OQWSServer::~OQWSServer()
64{
65 terminateServers();
66}
67
68bool OQWSServer::eventFilter ( QObject *o, QEvent *e )
69{
70#if 0
71 if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) {
72 QKeyEvent *ke = (QKeyEvent *) e;
73
74 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( ));
75
76 if ( db ) {
77 if (checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )))
78 return true; //checkButtonAction retrune false if events should be routed through
79 }
80 }
81#endif
82 return QPEApplication::eventFilter ( o, e );
83}
84
85#ifdef Q_WS_QWS
86
87bool OQWSServer::qwsEventFilter( QWSEvent *e )
88{
89#if 0
90 qpedesktop->checkMemory();
91
92 if ( e->type == QWSEvent::Key ) {
93 QWSKeyEvent * ke = (QWSKeyEvent *) e;
94 ushort keycode = ke-> simpleData. keycode;
95
96 if ( !loggedin && keycode != Key_F34 )
97 return true;
98
99 bool press = ke-> simpleData. is_press;
100 bool autoRepeat = ke-> simpleData. is_auto_repeat;
101
102 if ( !keyboardGrabbed ( )) {
103 // app that registers key/message to be sent back to the app, when it doesn't have focus,
104 // when user presses key, unless keyboard has been requested from app.
105 // will not send multiple repeats if user holds key
106 // i.e. one shot
107
108 if ( keycode != 0 && press && !autoRepeat ) {
109 for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
110 if (( *it ). getKeyCode ( ) == keycode ) {
111 QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( ));
112 return true;
113 }
114 }
115 }
116 }
117
118 if ( keycode == HardKey_Suspend ) {
119 if ( press )
120 emit power ( );
121 return true;
122 }
123 else if ( keycode == HardKey_Backlight ) {
124 if ( press )
125 emit backlight ( );
126 return true;
127 }
128 else if ( keycode == Key_F32 ) {
129 if ( press )
130 QCopEnvelope e( "QPE/Desktop", "startSync()" );
131 return true;
132 }
133 else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM
134 if ( press )
135 emit symbol ( );
136 return true;
137 }
138 else if ( keycode == Key_NumLock ) {
139 if ( press )
140 emit numLockStateToggle ( );
141 }
142 else if ( keycode == Key_CapsLock ) {
143 if ( press )
144 emit capsLockStateToggle();
145 }
146 if (( press && !autoRepeat ) || ( !press && autoRepeat )) {
147 if ( m_keyclick_sound )
148 ODevice::inst ( )-> keySound ( );
149 }
150 }
151 else if ( e-> type == QWSEvent::Mouse ) {
152 QWSMouseEvent * me = ( QWSMouseEvent * ) e;
153 static bool up = true;
154
155 if ( me-> simpleData. state & LeftButton ) {
156 if ( up ) {
157 up = false;
158 if ( m_screentap_sound )
159 ODevice::inst ( ) -> touchSound ( );
160 }
161 }
162 else {
163 up = true;
164 }
165 }
166#endif
167 return QPEApplication::qwsEventFilter ( e );
168}
169
170#endif
171
172void OQWSServer::startServers()
173{
174 // start qcop bridge server
175 m_qcopBridge = new QCopBridge( 4243 );
176 if ( !m_qcopBridge->ok() ) {
177 delete m_qcopBridge;
178 m_qcopBridge = 0;
179 }
180 // start transfer server
181 m_transferServer = new TransferServer( 4242 );
182 if ( !m_transferServer->ok() ) {
183 delete m_transferServer;
184 m_transferServer = 0;
185 }
186 //if ( !transferServer || !qcopBridge )
187 // startTimer( 2000 );
188}
189
190void OQWSServer::terminateServers()
191{
192 delete m_transferServer;
193 delete m_qcopBridge;
194 m_transferServer = 0;
195 m_qcopBridge = 0;
196}