summaryrefslogtreecommitdiff
path: root/core/launcher/qcopbridge.cpp
Unidiff
Diffstat (limited to 'core/launcher/qcopbridge.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/qcopbridge.cpp23
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
@@ -18,27 +18,30 @@
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>
32using 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>
@@ -46,26 +49,22 @@
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
55const int block_size = 51200; 55const int block_size = 51200;
56 56
57using namespace Opie::Core;
58QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, 57QCopBridge::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 );
@@ -168,19 +167,19 @@ void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data
168 */ 167 */
169void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArray& args) { 168void 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 );
@@ -201,13 +200,13 @@ void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArra
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() )
@@ -329,26 +328,26 @@ void QCopBridgePI::sendDesktopMessage( const QCString &msg, const QByteArray& da
329void QCopBridgePI::send( const QString& msg ) 328void 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
338void QCopBridgePI::read() 337void 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
346void QCopBridgePI::process( const QString& message ) 345void 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