summaryrefslogtreecommitdiff
authorzecke <zecke>2003-09-19 16:45:45 (UTC)
committer zecke <zecke>2003-09-19 16:45:45 (UTC)
commit0468cfef459d613ae0a32a3fa03e67726d19f6e9 (patch) (side-by-side diff)
treea9c3a751f206b97e8eee6046057eba8d92a22d1d
parent42a5104340694255dc514514e7621ac2cee026fe (diff)
downloadopie-0468cfef459d613ae0a32a3fa03e67726d19f6e9.zip
opie-0468cfef459d613ae0a32a3fa03e67726d19f6e9.tar.gz
opie-0468cfef459d613ae0a32a3fa03e67726d19f6e9.tar.bz2
Either be compatible with Sharp( IntelliSync, KitchenSync, QtopiaDesktop)
or with the newer QtopiaDesktop or with both
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/qcopbridge.cpp99
-rw-r--r--core/launcher/qcopbridge.h3
2 files changed, 99 insertions, 3 deletions
diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp
index f780235..9cb56ce 100644
--- a/core/launcher/qcopbridge.cpp
+++ b/core/launcher/qcopbridge.cpp
@@ -29,2 +29,3 @@
#include <qtopia/version.h>
+#include <qtopia/config.h>
@@ -82,2 +83,3 @@ QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent,
openConnections.setAutoDelete( TRUE );
+ authorizeConnections();
}
@@ -93,2 +95,5 @@ void QCopBridge::authorizeConnections()
{
+ Config cfg("Security");
+ cfg.setGroup("SyncMode");
+ m_mode = Mode(cfg.readNumEntry("Mode", Sharp ));
QListIterator<QCopBridgePI> it(openConnections);
@@ -154,8 +159,94 @@ void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data
+ if ( m_mode & Qtopia1_7 ) {
+ // send the command to all open connections
+ QCopBridgePI *pi;
+ for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) {
+ pi->sendDesktopMessage( command, data );
+ }
+ }
+ if ( m_mode & Sharp )
+ sendDesktopMessageOld( command, data );
+}
+
+#ifndef OPIE_NO_OLD_SYNC_CODE
+/*
+ * Old compat mode
+ */
+void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArray& args) {
+ command.stripWhiteSpace();
+
+ int paren = command.find( "(" );
+ if ( paren <= 0 ) {
+ qDebug("DesktopMessage: bad qcop syntax");
+ return;
+ }
+
+ QString params = command.mid( paren + 1 );
+ if ( params[params.length()-1] != ')' ) {
+ qDebug("DesktopMessage: bad qcop syntax");
+ return;
+ }
+
+ params.truncate( params.length()-1 );
+
+ QStringList paramList = QStringList::split( ",", params );
+ QString data;
+ if ( paramList.count() ) {
+ QDataStream stream( args, IO_ReadOnly );
+ for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) {
+ QString str;
+ if ( *it == "QString" ) {
+ stream >> str;
+ } else if ( *it == "QCString" ) {
+ QCString cstr;
+ stream >> cstr;
+ str = QString::fromLocal8Bit( cstr );
+ } else if ( *it == "int" ) {
+ int i;
+ stream >> i;
+ str = QString::number( i );
+ } else if ( *it == "bool" ) {
+ int i;
+ stream >> i;
+ str = QString::number( i );
+ } else {
+ qDebug(" cannot route the argument type %s throught the qcop bridge", (*it).latin1() );
+ return;
+ }
+ QString estr;
+ for (int i=0; i<(int)str.length(); i++) {
+ QChar ch = str[i];
+ if ( ch.row() )
+ goto quick;
+ switch (ch.cell()) {
+ case '&':
+ estr.append( "&amp;" );
+ break;
+ case ' ':
+ estr.append( "&0x20;" );
+ break;
+ case '\n':
+ estr.append( "&0x0d;" );
+ break;
+ case '\r':
+ estr.append( "&0x0a;" );
+ break;
+ default: quick:
+ estr.append(ch);
+ }
+ }
+ data += " " + estr;
+ }
+ }
+ QString sendCommand = QString(command.data()) + data;
+
+
// send the command to all open connections
QCopBridgePI *pi;
- for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) {
- pi->sendDesktopMessage( command, data );
- }
+ for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() )
+ pi->sendDesktopMessage( sendCommand );
+
}
+#endif
+
@@ -231,2 +322,3 @@ void QCopBridgePI::sendDesktopMessage( const QCString &msg, const QByteArray& da
return;
+
const char hdr[]="CALLB QPE/Desktop ";
@@ -238,2 +330,3 @@ void QCopBridgePI::sendDesktopMessage( const QCString &msg, const QByteArray& da
writeBlock("\r\n",2);
+
}
diff --git a/core/launcher/qcopbridge.h b/core/launcher/qcopbridge.h
index bae3f88..9483d9d 100644
--- a/core/launcher/qcopbridge.h
+++ b/core/launcher/qcopbridge.h
@@ -39,2 +39,3 @@ class QCopBridge : public QServerSocket
public:
+ enum Mode { Qtopia1_7= 0x01, Sharp = 0x02, Both = Qtopia1_7 | Sharp };
QCopBridge( Q_UINT16 port, QObject *parent = 0, const char* name = 0 );
@@ -55,2 +56,3 @@ protected:
void timerEvent( QTimerEvent * );
+ void sendDesktopMessageOld( const QCString&, const QByteArray& );
@@ -61,2 +63,3 @@ private:
bool sendSync;
+ Mode m_mode;
};