-rw-r--r-- | core/launcher/qcopbridge.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp index 33df6c4..e339dc7 100644 --- a/core/launcher/qcopbridge.cpp +++ b/core/launcher/qcopbridge.cpp | |||
@@ -12,66 +12,65 @@ | |||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "qcopbridge.h" | 21 | #include "qcopbridge.h" |
22 | #include "transferserver.h" | 22 | #include "transferserver.h" |
23 | 23 | ||
24 | /* OPIE */ | ||
25 | #include <opie2/odebug.h> | ||
24 | #include <opie2/oglobal.h> | 26 | #include <opie2/oglobal.h> |
25 | |||
26 | #ifdef Q_WS_QWS | 27 | #ifdef Q_WS_QWS |
27 | #include <qtopia/qcopenvelope_qws.h> | 28 | #include <qtopia/qcopenvelope_qws.h> |
28 | #endif | 29 | #endif |
29 | #include <qtopia/qpeapplication.h> | 30 | #include <qtopia/qpeapplication.h> |
30 | |||
31 | #include <qtopia/version.h> | 31 | #include <qtopia/version.h> |
32 | using namespace Opie::Core; | ||
32 | 33 | ||
34 | /* QT */ | ||
33 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
34 | #include <qtimer.h> | 36 | #include <qtimer.h> |
35 | #ifdef Q_WS_QWS | 37 | #ifdef Q_WS_QWS |
36 | #include <qcopchannel_qws.h> | 38 | #include <qcopchannel_qws.h> |
37 | #endif | 39 | #endif |
38 | 40 | ||
41 | /* STD */ | ||
39 | #ifndef _XOPEN_SOURCE | 42 | #ifndef _XOPEN_SOURCE |
40 | #define _XOPEN_SOURCE | 43 | #define _XOPEN_SOURCE |
41 | #endif | 44 | #endif |
42 | #ifndef Q_OS_WIN32 | 45 | #ifndef Q_OS_WIN32 |
43 | #include <pwd.h> | 46 | #include <pwd.h> |
44 | #include <unistd.h> | 47 | #include <unistd.h> |
45 | #include <sys/types.h> | 48 | #include <sys/types.h> |
46 | #endif | 49 | #endif |
47 | 50 | ||
48 | #if defined(_OS_LINUX_) | 51 | #if defined(_OS_LINUX_) |
49 | #include <shadow.h> | 52 | #include <shadow.h> |
50 | #endif | 53 | #endif |
51 | 54 | ||
52 | |||
53 | //#define INSECURE | ||
54 | |||
55 | const int block_size = 51200; | 55 | const int block_size = 51200; |
56 | 56 | ||
57 | using namespace Opie::Core; | ||
58 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, | 57 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, |
59 | const char* name ) | 58 | const char* name ) |
60 | : QServerSocket( port, 1, parent, name ), | 59 | : QServerSocket( port, 1, parent, name ), |
61 | desktopChannel( 0 ), | 60 | desktopChannel( 0 ), |
62 | cardChannel( 0 ) | 61 | cardChannel( 0 ) |
63 | { | 62 | { |
64 | if ( !ok() ) | 63 | if ( !ok() ) |
65 | qWarning( "Failed to bind to port %d", port ); | 64 | owarn << "Failed to bind to port " << port << "" << oendl; |
66 | else { | 65 | else { |
67 | #ifndef QT_NO_COP | 66 | #ifndef QT_NO_COP |
68 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); | 67 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); |
69 | connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 68 | connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
70 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); | 69 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
71 | cardChannel = new QCopChannel( "QPE/Card", this ); | 70 | cardChannel = new QCopChannel( "QPE/Card", this ); |
72 | connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 71 | connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
73 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); | 72 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
74 | #endif | 73 | #endif |
75 | } | 74 | } |
76 | sendSync = FALSE; | 75 | sendSync = FALSE; |
77 | openConnections.setAutoDelete( TRUE ); | 76 | openConnections.setAutoDelete( TRUE ); |
@@ -162,31 +161,31 @@ void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data | |||
162 | sendDesktopMessageOld( command, data ); | 161 | sendDesktopMessageOld( command, data ); |
163 | } | 162 | } |
164 | 163 | ||
165 | #ifndef OPIE_NO_OLD_SYNC_CODE | 164 | #ifndef OPIE_NO_OLD_SYNC_CODE |
166 | /* | 165 | /* |
167 | * Old compat mode | 166 | * Old compat mode |
168 | */ | 167 | */ |
169 | void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArray& args) { | 168 | void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArray& args) { |
170 | command.stripWhiteSpace(); | 169 | command.stripWhiteSpace(); |
171 | 170 | ||
172 | int paren = command.find( "(" ); | 171 | int paren = command.find( "(" ); |
173 | if ( paren <= 0 ) { | 172 | if ( paren <= 0 ) { |
174 | qDebug("DesktopMessage: bad qcop syntax"); | 173 | odebug << "DesktopMessage: bad qcop syntax" << oendl; |
175 | return; | 174 | return; |
176 | } | 175 | } |
177 | 176 | ||
178 | QString params = command.mid( paren + 1 ); | 177 | QString params = command.mid( paren + 1 ); |
179 | if ( params[params.length()-1] != ')' ) { | 178 | if ( params[params.length()-1] != ')' ) { |
180 | qDebug("DesktopMessage: bad qcop syntax"); | 179 | odebug << "DesktopMessage: bad qcop syntax" << oendl; |
181 | return; | 180 | return; |
182 | } | 181 | } |
183 | 182 | ||
184 | params.truncate( params.length()-1 ); | 183 | params.truncate( params.length()-1 ); |
185 | 184 | ||
186 | QStringList paramList = QStringList::split( ",", params ); | 185 | QStringList paramList = QStringList::split( ",", params ); |
187 | QString data; | 186 | QString data; |
188 | if ( paramList.count() ) { | 187 | if ( paramList.count() ) { |
189 | QDataStream stream( args, IO_ReadOnly ); | 188 | QDataStream stream( args, IO_ReadOnly ); |
190 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { | 189 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { |
191 | QString str; | 190 | QString str; |
192 | if ( *it == "QString" ) { | 191 | if ( *it == "QString" ) { |
@@ -195,25 +194,25 @@ void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArra | |||
195 | QCString cstr; | 194 | QCString cstr; |
196 | stream >> cstr; | 195 | stream >> cstr; |
197 | str = QString::fromLocal8Bit( cstr ); | 196 | str = QString::fromLocal8Bit( cstr ); |
198 | } else if ( *it == "int" ) { | 197 | } else if ( *it == "int" ) { |
199 | int i; | 198 | int i; |
200 | stream >> i; | 199 | stream >> i; |
201 | str = QString::number( i ); | 200 | str = QString::number( i ); |
202 | } else if ( *it == "bool" ) { | 201 | } else if ( *it == "bool" ) { |
203 | int i; | 202 | int i; |
204 | stream >> i; | 203 | stream >> i; |
205 | str = QString::number( i ); | 204 | str = QString::number( i ); |
206 | } else { | 205 | } else { |
207 | qDebug(" cannot route the argument type %s throught the qcop bridge", (*it).latin1() ); | 206 | odebug << " cannot route the argument type " << (*it) << " throught the qcop bridge" << oendl; |
208 | return; | 207 | return; |
209 | } | 208 | } |
210 | QString estr; | 209 | QString estr; |
211 | for (int i=0; i<(int)str.length(); i++) { | 210 | for (int i=0; i<(int)str.length(); i++) { |
212 | QChar ch = str[i]; | 211 | QChar ch = str[i]; |
213 | if ( ch.row() ) | 212 | if ( ch.row() ) |
214 | goto quick; | 213 | goto quick; |
215 | switch (ch.cell()) { | 214 | switch (ch.cell()) { |
216 | case '&': | 215 | case '&': |
217 | estr.append( "&" ); | 216 | estr.append( "&" ); |
218 | break; | 217 | break; |
219 | case ' ': | 218 | case ' ': |
@@ -323,38 +322,38 @@ void QCopBridgePI::sendDesktopMessage( const QCString &msg, const QByteArray& da | |||
323 | writeBlock(b64.data(),b64.size()); | 322 | writeBlock(b64.data(),b64.size()); |
324 | writeBlock("\r\n",2); | 323 | writeBlock("\r\n",2); |
325 | 324 | ||
326 | } | 325 | } |
327 | 326 | ||
328 | 327 | ||
329 | void QCopBridgePI::send( const QString& msg ) | 328 | void QCopBridgePI::send( const QString& msg ) |
330 | { | 329 | { |
331 | if ( !isOpen() ) // eg. Forbidden | 330 | if ( !isOpen() ) // eg. Forbidden |
332 | return; | 331 | return; |
333 | QTextStream os( this ); | 332 | QTextStream os( this ); |
334 | os << msg << endl; | 333 | os << msg << endl; |
335 | //qDebug( "sending qcop message: %s", msg.latin1() ); | 334 | //odebug << "sending qcop message: " << msg << "" << oendl; |
336 | } | 335 | } |
337 | 336 | ||
338 | void QCopBridgePI::read() | 337 | void QCopBridgePI::read() |
339 | { | 338 | { |
340 | while ( canReadLine() ) { | 339 | while ( canReadLine() ) { |
341 | timer->start( 300000, TRUE ); | 340 | timer->start( 300000, TRUE ); |
342 | process( readLine().stripWhiteSpace() ); | 341 | process( readLine().stripWhiteSpace() ); |
343 | } | 342 | } |
344 | } | 343 | } |
345 | 344 | ||
346 | void QCopBridgePI::process( const QString& message ) | 345 | void QCopBridgePI::process( const QString& message ) |
347 | { | 346 | { |
348 | //qDebug( "Command: %s", message.latin1() ); | 347 | //odebug << "Command: " << message << "" << oendl; |
349 | 348 | ||
350 | // split message using "," as separator | 349 | // split message using "," as separator |
351 | QStringList msg = QStringList::split( " ", message ); | 350 | QStringList msg = QStringList::split( " ", message ); |
352 | if ( msg.isEmpty() ) return; | 351 | if ( msg.isEmpty() ) return; |
353 | 352 | ||
354 | // command token | 353 | // command token |
355 | QString cmd = msg[0].upper(); | 354 | QString cmd = msg[0].upper(); |
356 | 355 | ||
357 | // argument token | 356 | // argument token |
358 | QString arg; | 357 | QString arg; |
359 | if ( msg.count() >= 2 ) | 358 | if ( msg.count() >= 2 ) |
360 | arg = msg[1]; | 359 | arg = msg[1]; |