summaryrefslogtreecommitdiff
path: root/core
Unidiff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/qcopbridge.cpp322
1 files changed, 161 insertions, 161 deletions
diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp
index c78e827..c8af919 100644
--- a/core/launcher/qcopbridge.cpp
+++ b/core/launcher/qcopbridge.cpp
@@ -55,10 +55,10 @@ QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent = 0,
55 if ( !ok() ) 55 if ( !ok() )
56 qWarning( "Failed to bind to port %d", port ); 56 qWarning( "Failed to bind to port %d", port );
57 else { 57 else {
58 desktopChannel = new QCopChannel( "QPE/Desktop", this ); 58 desktopChannel = new QCopChannel( "QPE/Desktop", this );
59 connect( desktopChannel, SIGNAL(received(const QCString &, const QByteArray &)), 59 connect( desktopChannel, SIGNAL(received(const QCString &, const QByteArray &)),
60 this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); 60 this, SLOT(desktopMessage( const QCString &, const QByteArray &)) );
61 cardChannel = new QCopChannel( "QPE/Card", this ); 61 cardChannel = new QCopChannel( "QPE/Card", this );
62 connect( cardChannel, SIGNAL(received(const QCString &, const QByteArray &)), 62 connect( cardChannel, SIGNAL(received(const QCString &, const QByteArray &)),
63 this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); 63 this, SLOT(desktopMessage( const QCString &, const QByteArray &)) );
64 } 64 }
@@ -80,4 +80,4 @@ void QCopBridge::newConnection( int socket )
80 if ( sendSync ) { 80 if ( sendSync ) {
81 pi ->startSync(); 81 pi ->startSync();
82 sendSync = FALSE; 82 sendSync = FALSE;
83 } 83 }
@@ -89,3 +89,3 @@ void QCopBridge::connectionClosed( QCopBridgePI *pi )
89 if ( openConnections.count() == 0 ) { 89 if ( openConnections.count() == 0 ) {
90 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 90 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
91 } 91 }
@@ -97,3 +97,3 @@ void QCopBridge::closeOpenConnections()
97 for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) 97 for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() )
98 pi->close(); 98 pi->close();
99} 99}
@@ -107,4 +107,4 @@ void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args
107 if ( paren <= 0 ) { 107 if ( paren <= 0 ) {
108 qDebug("DesktopMessage: bad qcop syntax"); 108 qDebug("DesktopMessage: bad qcop syntax");
109 return; 109 return;
110 } 110 }
@@ -113,4 +113,4 @@ void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args
113 if ( params[params.length()-1] != ')' ) { 113 if ( params[params.length()-1] != ')' ) {
114 qDebug("DesktopMessage: bad qcop syntax"); 114 qDebug("DesktopMessage: bad qcop syntax");
115 return; 115 return;
116 } 116 }
@@ -122,29 +122,29 @@ void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args
122 if ( paramList.count() ) { 122 if ( paramList.count() ) {
123 QDataStream stream( args, IO_ReadOnly ); 123 QDataStream stream( args, IO_ReadOnly );
124 for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { 124 for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) {
125 QString str; 125 QString str;
126 if ( *it == "QString" ) { 126 if ( *it == "QString" ) {
127 stream >> str; 127 stream >> str;
128 } else if ( *it == "QCString" ) { 128 } else if ( *it == "QCString" ) {
129 QCString cstr; 129 QCString cstr;
130 stream >> cstr; 130 stream >> cstr;
131 str = QString::fromLocal8Bit( cstr ); 131 str = QString::fromLocal8Bit( cstr );
132 } else if ( *it == "int" ) { 132 } else if ( *it == "int" ) {
133 int i; 133 int i;
134 stream >> i; 134 stream >> i;
135 str = QString::number( i ); 135 str = QString::number( i );
136 } else if ( *it == "bool" ) { 136 } else if ( *it == "bool" ) {
137 int i; 137 int i;
138 stream >> i; 138 stream >> i;
139 str = QString::number( i ); 139 str = QString::number( i );
140 } else { 140 } else {
141 qDebug(" cannot route the argument type %s throught the qcop bridge", (*it).latin1() ); 141 qDebug(" cannot route the argument type %s through the qcop bridge", (*it).latin1() );
142 return; 142 return;
143 } 143 }
144 str.replace( QRegExp("&"), "&amp;" ); 144 str.replace( QRegExp("&"), "&amp;" );
145 str.replace( QRegExp(" "), "&0x20;" ); 145 str.replace( QRegExp(" "), "&0x20;" );
146 str.replace( QRegExp("\n"), "&0x0d;" ); 146 str.replace( QRegExp("\n"), "&0x0d;" );
147 str.replace( QRegExp("\r"), "&0x0a;" ); 147 str.replace( QRegExp("\r"), "&0x0a;" );
148 data += " " + str; 148 data += " " + str;
149 } 149 }
150 } 150 }
@@ -153,5 +153,5 @@ void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args
153 if ( command == "startSync()" ) { 153 if ( command == "startSync()" ) {
154 // we need to buffer it a bit 154 // we need to buffer it a bit
155 sendSync = TRUE; 155 sendSync = TRUE;
156 startTimer( 20000 ); 156 startTimer( 20000 );
157 } 157 }
@@ -160,3 +160,3 @@ void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args
160 for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { 160 for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) {
161 pi->sendDesktopMessage( sendCommand ); 161 pi->sendDesktopMessage( sendCommand );
162 } 162 }
@@ -181,18 +181,18 @@ QCopBridgePI::QCopBridgePI( int socket, QObject *parent = 0, const char* name =
181 if ( !accessAuthorized(peeraddress) ) { 181 if ( !accessAuthorized(peeraddress) ) {
182 state = Forbidden; 182 state = Forbidden;
183 startTimer( 0 ); 183 startTimer( 0 );
184 } else 184 } else
185 #endif 185#endif
186 { 186 {
187 state = Connected; 187 state = Connected;
188 sendSync = FALSE; 188 sendSync = FALSE;
189 connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); 189 connect( this, SIGNAL( readyRead() ), SLOT( read() ) );
190 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); 190 connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) );
191 191
192 send( "220 Qtopia QCop bridge ready!" ); 192 send( "220 Qtopia QCop bridge ready!" );
193 state = Wait_USER; 193 state = Wait_USER;
194 194
195 // idle timer to close connections when not used anymore 195 // idle timer to close connections when not used anymore
196 startTimer( 60000 ); 196 startTimer( 60000 );
197 connected = TRUE; 197 connected = TRUE;
198 } 198 }
@@ -230,3 +230,3 @@ void QCopBridgePI::read()
230 while ( canReadLine() ) 230 while ( canReadLine() )
231 process( readLine().stripWhiteSpace() ); 231 process( readLine().stripWhiteSpace() );
232} 232}
@@ -257,3 +257,3 @@ bool QCopBridgePI::checkPassword( const QString& password )
257 if ( cpwd == "x" && spw ) 257 if ( cpwd == "x" && spw )
258 cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); 258 cpwd = QString::fromLocal8Bit( spw->sp_pwdp );
259 259
@@ -278,3 +278,3 @@ void QCopBridgePI::process( const QString& message )
278 if ( msg.count() >= 2 ) 278 if ( msg.count() >= 2 )
279 arg = msg[1]; 279 arg = msg[1];
280 280
@@ -282,5 +282,5 @@ void QCopBridgePI::process( const QString& message )
282 if ( cmd == "QUIT" ) { 282 if ( cmd == "QUIT" ) {
283 send( "211 Have a nice day!" ); 283 send( "211 Have a nice day!" );
284 delete this; 284 delete this;
285 return; 285 return;
286 } 286 }
@@ -289,3 +289,3 @@ void QCopBridgePI::process( const QString& message )
289 if ( Connected == state ) 289 if ( Connected == state )
290 return; 290 return;
291 291
@@ -294,9 +294,9 @@ void QCopBridgePI::process( const QString& message )
294 294
295 if ( cmd != "USER" || msg.count() < 2 || !checkUser( arg ) ) { 295 if ( cmd != "USER" || msg.count() < 2 || !checkUser( arg ) ) {
296 send( "530 Please login with USER and PASS" ); 296 send( "530 Please login with USER and PASS" );
297 return; 297 return;
298 } 298 }
299 send( "331 User name ok, need password" ); 299 send( "331 User name ok, need password" );
300 state = Wait_PASS; 300 state = Wait_PASS;
301 return; 301 return;
302 } 302 }
@@ -306,14 +306,14 @@ void QCopBridgePI::process( const QString& message )
306 306
307 if ( cmd != "PASS" || !checkPassword( arg ) ) { 307 if ( cmd != "PASS" || !checkPassword( arg ) ) {
308 //if ( cmd != "PASS" || msg.count() < 2 || !checkPassword( arg ) ) { 308 //if ( cmd != "PASS" || msg.count() < 2 || !checkPassword( arg ) ) {
309 send( "530 Please login with USER and PASS" ); 309 send( "530 Please login with USER and PASS" );
310 return; 310 return;
311 } 311 }
312 send( "230 User logged in, proceed" ); 312 send( "230 User logged in, proceed" );
313 state = Ready; 313 state = Ready;
314 if ( sendSync ) { 314 if ( sendSync ) {
315 sendDesktopMessage( "startSync()" ); 315 sendDesktopMessage( "startSync()" );
316 sendSync = FALSE; 316 sendSync = FALSE;
317 } 317 }
318 return; 318 return;
319 } 319 }
@@ -322,4 +322,4 @@ void QCopBridgePI::process( const QString& message )
322 else if ( cmd == "NOOP" ) { 322 else if ( cmd == "NOOP" ) {
323 connected = TRUE; 323 connected = TRUE;
324 send( "200 Command okay" ); 324 send( "200 Command okay" );
325 } 325 }
@@ -329,74 +329,74 @@ void QCopBridgePI::process( const QString& message )
329 329
330 // example: call QPE/System execute(QString) addressbook 330 // example: call QPE/System execute(QString) addressbook
331 331
332 if ( msg.count() < 3 ) { 332 if ( msg.count() < 3 ) {
333 send( "500 Syntax error, command unrecognized" ); 333 send( "500 Syntax error, command unrecognized" );
334 } 334 }
335 else { 335 else {
336 336
337 QString channel = msg[1]; 337 QString channel = msg[1];
338 QString command = msg[2]; 338 QString command = msg[2];
339 339
340 command.stripWhiteSpace(); 340 command.stripWhiteSpace();
341 341
342 int paren = command.find( "(" ); 342 int paren = command.find( "(" );
343 if ( paren <= 0 ) { 343 if ( paren <= 0 ) {
344 send( "500 Syntax error, command unrecognized" ); 344 send( "500 Syntax error, command unrecognized" );
345 return; 345 return;
346 } 346 }
347 347
348 QString params = command.mid( paren + 1 ); 348 QString params = command.mid( paren + 1 );
349 if ( params[params.length()-1] != ')' ) { 349 if ( params[params.length()-1] != ')' ) {
350 send( "500 Syntax error, command unrecognized" ); 350 send( "500 Syntax error, command unrecognized" );
351 return; 351 return;
352 } 352 }
353 353
354 params.truncate( params.length()-1 ); 354 params.truncate( params.length()-1 );
355 QByteArray buffer; 355 QByteArray buffer;
356 QDataStream ds( buffer, IO_WriteOnly ); 356 QDataStream ds( buffer, IO_WriteOnly );
357 357
358 int msgId = 3; 358 int msgId = 3;
359 359
360 QStringList paramList = QStringList::split( ",", params ); 360 QStringList paramList = QStringList::split( ",", params );
361 if ( paramList.count() > msg.count() - 3 ) { 361 if ( paramList.count() > msg.count() - 3 ) {
362 send( "500 Syntax error, command unrecognized" ); 362 send( "500 Syntax error, command unrecognized" );
363 return; 363 return;
364 } 364 }
365 365
366 for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { 366 for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) {
367 367
368 QString arg = msg[msgId]; 368 QString arg = msg[msgId];
369 arg.replace( QRegExp("&0x20;"), " " ); 369 arg.replace( QRegExp("&0x20;"), " " );
370 arg.replace( QRegExp("&amp;"), "&" ); 370 arg.replace( QRegExp("&amp;"), "&" );
371 arg.replace( QRegExp("&0x0d;"), "\n" ); 371 arg.replace( QRegExp("&0x0d;"), "\n" );
372 arg.replace( QRegExp("&0x0a;"), "\r" ); 372 arg.replace( QRegExp("&0x0a;"), "\r" );
373 if ( *it == "QString" ) 373 if ( *it == "QString" )
374 ds << arg; 374 ds << arg;
375 else if ( *it == "QCString" ) 375 else if ( *it == "QCString" )
376 ds << arg.local8Bit(); 376 ds << arg.local8Bit();
377 else if ( *it == "int" ) 377 else if ( *it == "int" )
378 ds << arg.toInt(); 378 ds << arg.toInt();
379 else if ( *it == "bool" ) 379 else if ( *it == "bool" )
380 ds << arg.toInt(); 380 ds << arg.toInt();
381 else { 381 else {
382 send( "500 Syntax error, command unrecognized" ); 382 send( "500 Syntax error, command unrecognized" );
383 return; 383 return;
384 } 384 }
385 msgId++; 385 msgId++;
386 } 386 }
387 387
388 if ( !QCopChannel::isRegistered( channel.latin1() ) ) { 388 if ( !QCopChannel::isRegistered( channel.latin1() ) ) {
389 // send message back about it 389 // send message back about it
390 QString answer = "599 ChannelNotRegistered " + channel; 390 QString answer = "599 ChannelNotRegistered " + channel;
391 send( answer ); 391 send( answer );
392 return; 392 return;
393 } 393 }
394 394
395 if ( paramList.count() ) 395 if ( paramList.count() )
396 QCopChannel::send( channel.latin1(), command.latin1(), buffer ); 396 QCopChannel::send( channel.latin1(), command.latin1(), buffer );
397 else 397 else
398 QCopChannel::send( channel.latin1(), command.latin1() ); 398 QCopChannel::send( channel.latin1(), command.latin1() );
399 399
400 send( "200 Command okay" ); 400 send( "200 Command okay" );
401 } 401 }
402 } 402 }
@@ -404,3 +404,3 @@ void QCopBridgePI::process( const QString& message )
404 else 404 else
405 send( "502 Command not implemented" ); 405 send( "502 Command not implemented" );
406} 406}
@@ -412,5 +412,5 @@ void QCopBridgePI::timerEvent( QTimerEvent * )
412 if ( connected ) 412 if ( connected )
413 connected = FALSE; 413 connected = FALSE;
414 else 414 else
415 connectionClosed(); 415 connectionClosed();
416} 416}