author | zecke <zecke> | 2003-09-19 16:45:45 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-09-19 16:45:45 (UTC) |
commit | 0468cfef459d613ae0a32a3fa03e67726d19f6e9 (patch) (unidiff) | |
tree | a9c3a751f206b97e8eee6046057eba8d92a22d1d | |
parent | 42a5104340694255dc514514e7621ac2cee026fe (diff) | |
download | opie-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
-rw-r--r-- | core/launcher/qcopbridge.cpp | 99 | ||||
-rw-r--r-- | core/launcher/qcopbridge.h | 3 |
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 @@ | |||
29 | #include <qtopia/version.h> | 29 | #include <qtopia/version.h> |
30 | #include <qtopia/config.h> | ||
30 | 31 | ||
@@ -82,2 +83,3 @@ QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, | |||
82 | openConnections.setAutoDelete( TRUE ); | 83 | openConnections.setAutoDelete( TRUE ); |
84 | authorizeConnections(); | ||
83 | } | 85 | } |
@@ -93,2 +95,5 @@ void QCopBridge::authorizeConnections() | |||
93 | { | 95 | { |
96 | Config cfg("Security"); | ||
97 | cfg.setGroup("SyncMode"); | ||
98 | m_mode = Mode(cfg.readNumEntry("Mode", Sharp )); | ||
94 | QListIterator<QCopBridgePI> it(openConnections); | 99 | QListIterator<QCopBridgePI> it(openConnections); |
@@ -154,8 +159,94 @@ void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data | |||
154 | 159 | ||
160 | if ( m_mode & Qtopia1_7 ) { | ||
161 | // send the command to all open connections | ||
162 | QCopBridgePI *pi; | ||
163 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { | ||
164 | pi->sendDesktopMessage( command, data ); | ||
165 | } | ||
166 | } | ||
167 | if ( m_mode & Sharp ) | ||
168 | sendDesktopMessageOld( command, data ); | ||
169 | } | ||
170 | |||
171 | #ifndef OPIE_NO_OLD_SYNC_CODE | ||
172 | /* | ||
173 | * Old compat mode | ||
174 | */ | ||
175 | void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArray& args) { | ||
176 | command.stripWhiteSpace(); | ||
177 | |||
178 | int paren = command.find( "(" ); | ||
179 | if ( paren <= 0 ) { | ||
180 | qDebug("DesktopMessage: bad qcop syntax"); | ||
181 | return; | ||
182 | } | ||
183 | |||
184 | QString params = command.mid( paren + 1 ); | ||
185 | if ( params[params.length()-1] != ')' ) { | ||
186 | qDebug("DesktopMessage: bad qcop syntax"); | ||
187 | return; | ||
188 | } | ||
189 | |||
190 | params.truncate( params.length()-1 ); | ||
191 | |||
192 | QStringList paramList = QStringList::split( ",", params ); | ||
193 | QString data; | ||
194 | if ( paramList.count() ) { | ||
195 | QDataStream stream( args, IO_ReadOnly ); | ||
196 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { | ||
197 | QString str; | ||
198 | if ( *it == "QString" ) { | ||
199 | stream >> str; | ||
200 | } else if ( *it == "QCString" ) { | ||
201 | QCString cstr; | ||
202 | stream >> cstr; | ||
203 | str = QString::fromLocal8Bit( cstr ); | ||
204 | } else if ( *it == "int" ) { | ||
205 | int i; | ||
206 | stream >> i; | ||
207 | str = QString::number( i ); | ||
208 | } else if ( *it == "bool" ) { | ||
209 | int i; | ||
210 | stream >> i; | ||
211 | str = QString::number( i ); | ||
212 | } else { | ||
213 | qDebug(" cannot route the argument type %s throught the qcop bridge", (*it).latin1() ); | ||
214 | return; | ||
215 | } | ||
216 | QString estr; | ||
217 | for (int i=0; i<(int)str.length(); i++) { | ||
218 | QChar ch = str[i]; | ||
219 | if ( ch.row() ) | ||
220 | goto quick; | ||
221 | switch (ch.cell()) { | ||
222 | case '&': | ||
223 | estr.append( "&" ); | ||
224 | break; | ||
225 | case ' ': | ||
226 | estr.append( "&0x20;" ); | ||
227 | break; | ||
228 | case '\n': | ||
229 | estr.append( "&0x0d;" ); | ||
230 | break; | ||
231 | case '\r': | ||
232 | estr.append( "&0x0a;" ); | ||
233 | break; | ||
234 | default: quick: | ||
235 | estr.append(ch); | ||
236 | } | ||
237 | } | ||
238 | data += " " + estr; | ||
239 | } | ||
240 | } | ||
241 | QString sendCommand = QString(command.data()) + data; | ||
242 | |||
243 | |||
155 | // send the command to all open connections | 244 | // send the command to all open connections |
156 | QCopBridgePI *pi; | 245 | QCopBridgePI *pi; |
157 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { | 246 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) |
158 | pi->sendDesktopMessage( command, data ); | 247 | pi->sendDesktopMessage( sendCommand ); |
159 | } | 248 | |
160 | } | 249 | } |
250 | #endif | ||
251 | |||
161 | 252 | ||
@@ -231,2 +322,3 @@ void QCopBridgePI::sendDesktopMessage( const QCString &msg, const QByteArray& da | |||
231 | return; | 322 | return; |
323 | |||
232 | const char hdr[]="CALLB QPE/Desktop "; | 324 | const char hdr[]="CALLB QPE/Desktop "; |
@@ -238,2 +330,3 @@ void QCopBridgePI::sendDesktopMessage( const QCString &msg, const QByteArray& da | |||
238 | writeBlock("\r\n",2); | 330 | writeBlock("\r\n",2); |
331 | |||
239 | } | 332 | } |
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 | |||
39 | public: | 39 | public: |
40 | enum Mode { Qtopia1_7= 0x01, Sharp = 0x02, Both = Qtopia1_7 | Sharp }; | ||
40 | QCopBridge( Q_UINT16 port, QObject *parent = 0, const char* name = 0 ); | 41 | QCopBridge( Q_UINT16 port, QObject *parent = 0, const char* name = 0 ); |
@@ -55,2 +56,3 @@ protected: | |||
55 | void timerEvent( QTimerEvent * ); | 56 | void timerEvent( QTimerEvent * ); |
57 | void sendDesktopMessageOld( const QCString&, const QByteArray& ); | ||
56 | 58 | ||
@@ -61,2 +63,3 @@ private: | |||
61 | bool sendSync; | 63 | bool sendSync; |
64 | Mode m_mode; | ||
62 | }; | 65 | }; |