summaryrefslogtreecommitdiffabout
path: root/libkdepim/externalapphandler.cpp
Unidiff
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index f376e6c..3fc548a 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -1,365 +1,367 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30#include <stdlib.h> 30#include <stdlib.h>
31 31
32#include <qfile.h> 32#include <qfile.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qregexp.h> 35#include <qregexp.h>
36 36
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include <qtopia/qcopenvelope_qws.h> 39#include <qtopia/qcopenvelope_qws.h>
40#else 40#else
41#include <qapplication.h> 41#include <qapplication.h>
42#include <qprocess.h> 42#include <q3process.h>
43//Added by qt3to4:
44#include <Q3CString>
43#endif 45#endif
44 46
45#include <kstaticdeleter.h> 47#include <kstaticdeleter.h>
46#include <kmessagebox.h> 48#include <kmessagebox.h>
47 49
48 50
49#include "externalapphandler.h" 51#include "externalapphandler.h"
50 52
51#include "kpimglobalprefs.h" 53#include "kpimglobalprefs.h"
52 54
53//uncomment line to get debug output 55//uncomment line to get debug output
54//#define DEBUG_EXT_APP_HANDLER 56//#define DEBUG_EXT_APP_HANDLER
55 57
56/********************************************************************************* 58/*********************************************************************************
57 * 59 *
58 ********************************************************************************/ 60 ********************************************************************************/
59 61
60 62
61QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 63QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
62 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) 64 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
63{ 65{
64 //sourceMessage passes later three parameters: sourceChannel, uid, param1 66 //sourceMessage passes later three parameters: sourceChannel, uid, param1
65 if (_usedSourceParameters == 0) 67 if (_usedSourceParameters == 0)
66 _sourceMessageParameters = "QString,QString)"; 68 _sourceMessageParameters = "QString,QString)";
67 else if (_usedSourceParameters == 1) 69 else if (_usedSourceParameters == 1)
68 _sourceMessageParameters = "(QString,QString,QString)"; 70 _sourceMessageParameters = "(QString,QString,QString)";
69 else if (_usedSourceParameters == 2) 71 else if (_usedSourceParameters == 2)
70 _sourceMessageParameters = "(QString,QString,QString,QString)"; 72 _sourceMessageParameters = "(QString,QString,QString,QString)";
71 else if (_usedSourceParameters == 3) 73 else if (_usedSourceParameters == 3)
72 _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; 74 _sourceMessageParameters = "(QString,QString,QString,QString,QString)";
73} 75}
74 76
75/*********************************************************************************/ 77/*********************************************************************************/
76 78
77QCopTransferItem::QCopTransferItem() 79QCopTransferItem::QCopTransferItem()
78{ 80{
79} 81}
80 82
81/*********************************************************************************/ 83/*********************************************************************************/
82bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) 84bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3)
83{ 85{
84 86
85#ifndef DESKTOP_VERSION 87#ifndef DESKTOP_VERSION
86 //sourceMessage passes two parameters: sourceChannel, uid 88 //sourceMessage passes two parameters: sourceChannel, uid
87 QString sourceMessage = _sourceMessage + _sourceMessageParameters; 89 QString sourceMessage = _sourceMessage + _sourceMessageParameters;
88#ifdef DEBUG_EXT_APP_HANDLER 90#ifdef DEBUG_EXT_APP_HANDLER
89 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); 91 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1());
90 qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); 92 qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1());
91#endif 93#endif
92 94
93 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); 95 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
94 96
95 e << _sourceChannel << uid; 97 e << _sourceChannel << uid;
96 98
97 if (_usedSourceParameters == 1) 99 if (_usedSourceParameters == 1)
98 e << param1; 100 e << param1;
99 else if (_usedSourceParameters == 2) 101 else if (_usedSourceParameters == 2)
100 e << param1 << param2; 102 e << param1 << param2;
101 else if (_usedSourceParameters == 3) 103 else if (_usedSourceParameters == 3)
102 e << param1 << param2 << param3; 104 e << param1 << param2 << param3;
103 105
104 qApp->processEvents(); 106 qApp->processEvents();
105 107
106 return true; 108 return true;
107 109
108#else 110#else
109 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 111 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
110 return false; 112 return false;
111#endif 113#endif
112 114
113} 115}
114 116
115 117
116/*********************************************************************************/ 118/*********************************************************************************/
117void QCopTransferItem::setSourceChannel(const QString& sourceChannel) 119void QCopTransferItem::setSourceChannel(const QString& sourceChannel)
118{ 120{
119 121
120 if ( !sourceChannel.isEmpty()) 122 if ( !sourceChannel.isEmpty())
121 _sourceChannel = sourceChannel; 123 _sourceChannel = sourceChannel;
122} 124}
123 125
124 126
125/*********************************************************************************/ 127/*********************************************************************************/
126bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 128bool QCopTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data )
127{ 129{
128 130
129 // copied from old mail2 131 // copied from old mail2
130/* 132/*
131 static int ii = 0; 133 static int ii = 0;
132 134
133 // block second call 135 // block second call
134 if ( ii < 2 ) { 136 if ( ii < 2 ) {
135 ++ii; 137 ++ii;
136 if ( ii > 1 ) { 138 if ( ii > 1 ) {
137 qDebug("qcop call blocked "); 139 qDebug("qcop call blocked ");
138 return true; 140 return true;
139 } 141 }
140 } 142 }
141*/ 143*/
142 144
143// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); 145// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
144 146
145 //we are in the target and get a request from the source 147 //we are in the target and get a request from the source
146 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) 148 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
147 { 149 {
148 150
149 QDataStream stream( data, IO_ReadOnly ); 151 QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly );
150 152
151 153
152 QString sourceChannel; 154 QString sourceChannel;
153 QString uid; 155 QString uid;
154 QString param1; 156 QString param1;
155 QString param2; 157 QString param2;
156 QString param3; 158 QString param3;
157 159
158 stream >> sourceChannel >> uid; 160 stream >> sourceChannel >> uid;
159 161
160 if (_usedSourceParameters == 0) 162 if (_usedSourceParameters == 0)
161 { 163 {
162 emit receivedMessageFromSource(sourceChannel, uid); 164 emit receivedMessageFromSource(sourceChannel, uid);
163 } 165 }
164 else if (_usedSourceParameters == 1) 166 else if (_usedSourceParameters == 1)
165 { 167 {
166 stream >> param1; 168 stream >> param1;
167 emit receivedMessageFromSource(sourceChannel, uid, param1); 169 emit receivedMessageFromSource(sourceChannel, uid, param1);
168 } 170 }
169 else if (_usedSourceParameters == 2) 171 else if (_usedSourceParameters == 2)
170 { 172 {
171 stream >> param1 >> param2; 173 stream >> param1 >> param2;
172 emit receivedMessageFromSource(sourceChannel, uid, param1, param2); 174 emit receivedMessageFromSource(sourceChannel, uid, param1, param2);
173 } 175 }
174 else if (_usedSourceParameters == 3) 176 else if (_usedSourceParameters == 3)
175 { 177 {
176 stream >> param1 >> param2 >> param3; 178 stream >> param1 >> param2 >> param3;
177 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); 179 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3);
178 } 180 }
179 181
180 return true; 182 return true;
181 } 183 }
182 184
183 return false; 185 return false;
184} 186}
185 187
186 188
187/********************************************************************************* 189/*********************************************************************************
188 * 190 *
189 ********************************************************************************/ 191 ********************************************************************************/
190 192
191 193
192QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 194QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
193 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 195 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
194{ 196{
195 //targetMessage returns later two parameters: uid, and map<qstring,qstring> 197 //targetMessage returns later two parameters: uid, and map<qstring,qstring>
196 _targetMessageParameters = "(QString,QMAP<QString,QString>)"; 198 _targetMessageParameters = "(QString,QMAP<QString,QString>)";
197} 199}
198 200
199/*********************************************************************************/ 201/*********************************************************************************/
200bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) 202bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap)
201{ 203{
202#ifndef DESKTOP_VERSION 204#ifndef DESKTOP_VERSION
203 //targetMessage passes two parameters: uid, map 205 //targetMessage passes two parameters: uid, map
204 QString targetMessage = _targetMessage + _targetMessageParameters; 206 QString targetMessage = _targetMessage + _targetMessageParameters;
205 207
206#ifdef DEBUG_EXT_APP_HANDLER 208#ifdef DEBUG_EXT_APP_HANDLER
207 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 209 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
208 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); 210 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
209#endif 211#endif
210 212
211 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 213 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
212 //US we need no names in the To field. The emailadresses are enough 214 //US we need no names in the To field. The emailadresses are enough
213 215
214 e << uid << nameEmailMap; 216 e << uid << nameEmailMap;
215 217
216 qApp->processEvents(); 218 qApp->processEvents();
217 219
218 return true; 220 return true;
219 221
220#else 222#else
221 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 223 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
222 return false; 224 return false;
223#endif 225#endif
224 226
225} 227}
226 228
227 229
228/*********************************************************************************/ 230/*********************************************************************************/
229bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 231bool QCopMapTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data )
230{ 232{
231 bool res = QCopTransferItem::appMessage( cmsg, data ); 233 bool res = QCopTransferItem::appMessage( cmsg, data );
232 234
233 if (res == false) 235 if (res == false)
234 { 236 {
235 QDataStream stream( data, IO_ReadOnly ); 237 QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly );
236 238
237// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); 239// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() );
238 240
239 //we are in the source and get an answer from the target 241 //we are in the source and get an answer from the target
240 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 242 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
241 { 243 {
242 QMap<QString,QString> adrMap; 244 QMap<QString,QString> adrMap;
243 QString uid; 245 QString uid;
244 246
245 stream >> uid >> adrMap; 247 stream >> uid >> adrMap;
246 248
247 emit receivedMessageFromTarget(uid, adrMap); 249 emit receivedMessageFromTarget(uid, adrMap);
248 250
249 251
250 return true; 252 return true;
251 } 253 }
252 } 254 }
253 255
254 return false; 256 return false;
255} 257}
256 258
257 259
258/********************************************************************************* 260/*********************************************************************************
259 * 261 *
260 ********************************************************************************/ 262 ********************************************************************************/
261 263
262QCopListTransferItem::~QCopListTransferItem() 264QCopListTransferItem::~QCopListTransferItem()
263{ 265{
264 266
265} 267}
266 268
267QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 269QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
268 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 270 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
269{ 271{
270 //targetMessage returns later two parameters: uid, and three lists 272 //targetMessage returns later two parameters: uid, and three lists
271 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; 273 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)";
272} 274}
273 275
274/*********************************************************************************/ 276/*********************************************************************************/
275bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) 277bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6)
276{ 278{
277#ifndef DESKTOP_VERSION 279#ifndef DESKTOP_VERSION
278 //targetMessage passes two parameters: uid, map 280 //targetMessage passes two parameters: uid, map
279 QString targetMessage = _targetMessage + _targetMessageParameters; 281 QString targetMessage = _targetMessage + _targetMessageParameters;
280 282
281#ifdef DEBUG_EXT_APP_HANDLER 283#ifdef DEBUG_EXT_APP_HANDLER
282 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 284 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
283 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); 285 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1());
284 286
285 287
286 for ( int i = 0; i < list3.count(); i++) 288 for ( int i = 0; i < list3.count(); i++)
287 qDebug("listentry list3: %s",list3[i].latin1()); 289 qDebug("listentry list3: %s",list3[i].latin1());
288#endif 290#endif
289 291
290 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 292 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
291 //US we need no names in the To field. The emailadresses are enough 293 //US we need no names in the To field. The emailadresses are enough
292 294
293 e << uid << list1 << list2 << list3 << list4 << list5 << list6; 295 e << uid << list1 << list2 << list3 << list4 << list5 << list6;
294 296
295 qApp->processEvents(); 297 qApp->processEvents();
296 298
297 return true; 299 return true;
298 300
299#else 301#else
300 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 302 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
301 return false; 303 return false;
302#endif 304#endif
303 305
304} 306}
305 307
306 308
307/*********************************************************************************/ 309/*********************************************************************************/
308bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 310bool QCopListTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data )
309{ 311{
310 bool res = QCopTransferItem::appMessage( cmsg, data ); 312 bool res = QCopTransferItem::appMessage( cmsg, data );
311#ifdef DEBUG_EXT_APP_HANDLER 313#ifdef DEBUG_EXT_APP_HANDLER
312 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 314 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
313#endif 315#endif
314 316
315 if (res == false) 317 if (res == false)
316 { 318 {
317 QDataStream stream( data, IO_ReadOnly ); 319 QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly );
318 320
319#ifdef DEBUG_EXT_APP_HANDLER 321#ifdef DEBUG_EXT_APP_HANDLER
320 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 322 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
321#endif 323#endif
322 324
323 //we are in the source and get an answer from the target 325 //we are in the source and get an answer from the target
324 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 326 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
325 { 327 {
326 QStringList list1; 328 QStringList list1;
327 QStringList list2; 329 QStringList list2;
328 QStringList list3; 330 QStringList list3;
329 QStringList list4; 331 QStringList list4;
330 QStringList list5; 332 QStringList list5;
331 QStringList list6; 333 QStringList list6;
332 QString uid; 334 QString uid;
333 335
334#ifdef DEBUG_EXT_APP_HANDLER 336#ifdef DEBUG_EXT_APP_HANDLER
335 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 337 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
336#endif 338#endif
337 339
338 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; 340 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6;
339 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); 341 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6);
340 342
341 343
342 return true; 344 return true;
343 } 345 }
344 } 346 }
345 347
346 return false; 348 return false;
347} 349}
348 350
349 351
350 352
351/********************************************************************************* 353/*********************************************************************************
352 * 354 *
353 ********************************************************************************/ 355 ********************************************************************************/
354 356
355 357
356ExternalAppHandler *ExternalAppHandler::sInstance = 0; 358ExternalAppHandler *ExternalAppHandler::sInstance = 0;
357static KStaticDeleter<ExternalAppHandler> staticDeleter; 359static KStaticDeleter<ExternalAppHandler> staticDeleter;
358 360
359ExternalAppHandler::ExternalAppHandler() 361ExternalAppHandler::ExternalAppHandler()
360{ 362{
361 mDefaultItems.setAutoDelete(true); 363 mDefaultItems.setAutoDelete(true);
362 364
363 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); 365 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
364 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); 366 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&)));
365 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 367 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
@@ -473,99 +475,99 @@ void ExternalAppHandler::loadConfig()
473 475
474 //phoneclients 476 //phoneclients
475 477
476 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 478 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
477 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 479 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
478 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 480 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
479 ( QFile::exists( opiepath + "/bin/kppi" ))) 481 ( QFile::exists( opiepath + "/bin/kppi" )))
480 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 482 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
481 483
482 //faxclients 484 //faxclients
483 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 485 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
484 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 486 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
485 487
486 //smsclients 488 //smsclients
487 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 489 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
488 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 490 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
489 491
490 //pagerclients 492 //pagerclients
491 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 493 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
492 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 494 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
493 495
494 //sipclients 496 //sipclients
495 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); 497 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined);
496 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); 498 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined);
497 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 499 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
498 ( QFile::exists( opiepath + "/bin/kppi" ))) 500 ( QFile::exists( opiepath + "/bin/kppi" )))
499 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 501 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
500 502
501} 503}
502 504
503ExternalAppHandler *ExternalAppHandler::instance() 505ExternalAppHandler *ExternalAppHandler::instance()
504{ 506{
505 if ( !sInstance ) { 507 if ( !sInstance ) {
506 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 508 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
507 sInstance->loadConfig(); 509 sInstance->loadConfig();
508 } 510 }
509 511
510 return sInstance; 512 return sInstance;
511} 513}
512 514
513void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 515void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
514{ 516{
515 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 517 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
516 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); 518 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
517 mDefaultItems.append(dai); 519 mDefaultItems.append(dai);
518} 520}
519 521
520 522
521QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 523Q3PtrList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
522{ 524{
523 QList<DefaultAppItem> list; 525 Q3PtrList<DefaultAppItem> list;
524 526
525 DefaultAppItem* dai; 527 DefaultAppItem* dai;
526 528
527 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 529 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
528 { 530 {
529 if (dai->_type == type) 531 if (dai->_type == type)
530 list.append(dai); 532 list.append(dai);
531 } 533 }
532 534
533 return list; 535 return list;
534} 536}
535 537
536DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 538DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
537{ 539{
538 DefaultAppItem* dai; 540 DefaultAppItem* dai;
539 541
540 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 542 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
541 { 543 {
542 if (dai->_type == type && dai->_id == clientid) 544 if (dai->_type == type && dai->_id == clientid)
543 return dai; 545 return dai;
544 } 546 }
545 547
546 return 0; 548 return 0;
547} 549}
548 550
549bool ExternalAppHandler::isEmailAppAvailable() 551bool ExternalAppHandler::isEmailAppAvailable()
550{ 552{
551 553
552 if (mEmailAppAvailable == UNDEFINED) 554 if (mEmailAppAvailable == UNDEFINED)
553 { 555 {
554 int client = KPimGlobalPrefs::instance()->mEmailClient; 556 int client = KPimGlobalPrefs::instance()->mEmailClient;
555 if (client == KPimGlobalPrefs::NONE_EMC) 557 if (client == KPimGlobalPrefs::NONE_EMC)
556 mEmailAppAvailable = UNAVAILABLE; 558 mEmailAppAvailable = UNAVAILABLE;
557 else 559 else
558 mEmailAppAvailable = AVAILABLE; 560 mEmailAppAvailable = AVAILABLE;
559 } 561 }
560 return (mEmailAppAvailable == AVAILABLE); 562 return (mEmailAppAvailable == AVAILABLE);
561 563
562} 564}
563 565
564bool ExternalAppHandler::isSMSAppAvailable() 566bool ExternalAppHandler::isSMSAppAvailable()
565{ 567{
566#ifndef DESKTOP_VERSION 568#ifndef DESKTOP_VERSION
567 if (mSMSAppAvailable == UNDEFINED) 569 if (mSMSAppAvailable == UNDEFINED)
568 { 570 {
569 int client = KPimGlobalPrefs::instance()->mSMSClient; 571 int client = KPimGlobalPrefs::instance()->mSMSClient;
570 if (client == KPimGlobalPrefs::NONE_SMC) 572 if (client == KPimGlobalPrefs::NONE_SMC)
571 mSMSAppAvailable = UNAVAILABLE; 573 mSMSAppAvailable = UNAVAILABLE;
@@ -701,201 +703,201 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS
701 //US we need no names in the To field. The emailadresses are enough 703 //US we need no names in the To field. The emailadresses are enough
702 704
703 passParameters(&e, parameters2, emails, urls); 705 passParameters(&e, parameters2, emails, urls);
704 706
705 707
706 708
707#else 709#else
708 //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1()); 710 //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1());
709 711
710 QString channel; 712 QString channel;
711 QString message2; 713 QString message2;
712 QString parameters2; 714 QString parameters2;
713 QString message; 715 QString message;
714 QString parameters; 716 QString parameters;
715 717
716 718
717 int client = KPimGlobalPrefs::instance()->mEmailClient; 719 int client = KPimGlobalPrefs::instance()->mEmailClient;
718 if (client == KPimGlobalPrefs::OTHER_EMC) 720 if (client == KPimGlobalPrefs::OTHER_EMC)
719 { 721 {
720 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 722 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
721 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 723 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
722 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2; 724 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2;
723 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 725 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
724 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2; 726 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2;
725 } 727 }
726 else 728 else
727 { 729 {
728 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 730 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
729 if (!dai) 731 if (!dai)
730 { 732 {
731 qDebug("could not find configured email application."); 733 qDebug("could not find configured email application.");
732 return false; 734 return false;
733 } 735 }
734 channel = dai->_channel; 736 channel = dai->_channel;
735 message2 = dai->_message2; 737 message2 = dai->_message2;
736 parameters2 = dai->_parameters2; 738 parameters2 = dai->_parameters2;
737 message = dai->_message; 739 message = dai->_message;
738 parameters = dai->_parameters; 740 parameters = dai->_parameters;
739 } 741 }
740 742
741 //first check if one of the mailers need the emails right in the message. 743 //first check if one of the mailers need the emails right in the message.
742 message2 = translateMessage(message2, emails, urls); 744 message2 = translateMessage(message2, emails, urls);
743#ifdef DEBUG_EXT_APP_HANDLER 745#ifdef DEBUG_EXT_APP_HANDLER
744 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 746 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
745 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 747 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
746#endif 748#endif
747 qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); 749 qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() );
748 //KMessageBox::sorry( 0, message2 ); 750 //KMessageBox::sorry( 0, message2 );
749 QProcess * proc = new QProcess( this ); 751 Q3Process * proc = new Q3Process( this );
750 int i = 0; 752 int i = 0;
751 proc->addArgument( channel ); 753 proc->addArgument( channel );
752 754
753 if ( message.find (" " ) > 0 ) { 755 if ( message.find (" " ) > 0 ) {
754 QStringList list = QStringList::split( " ", message ); 756 QStringList list = QStringList::split( " ", message );
755 int i = 0; 757 int i = 0;
756 while ( i < list.count ( ) ) { 758 while ( i < list.count ( ) ) {
757 //qDebug("add%sdd ",list[i].latin1() ); 759 //qDebug("add%sdd ",list[i].latin1() );
758 proc->addArgument( list[i] ); 760 proc->addArgument( list[i] );
759 //KMessageBox::sorry( 0,list[i]); 761 //KMessageBox::sorry( 0,list[i]);
760 ++i; 762 ++i;
761 } 763 }
762 } else { 764 } else {
763 proc->addArgument(message ); 765 proc->addArgument(message );
764 //KMessageBox::sorry( 0, message ); 766 //KMessageBox::sorry( 0, message );
765 767
766 } 768 }
767 769
768 parameters2 = translateMessage(parameters2, urls, "" ); 770 parameters2 = translateMessage(parameters2, urls, "" );
769 QString arg = "to='%1'"; 771 QString arg = "to='%1'";
770 arg = arg.arg( emails ) + ","+parameters2;; 772 arg = arg.arg( emails ) + ","+parameters2;;
771 773
772 //KMessageBox::sorry( 0,arg ); 774 //KMessageBox::sorry( 0,arg );
773 //qDebug("2add%sdd ",arg.latin1() ); 775 //qDebug("2add%sdd ",arg.latin1() );
774 proc->addArgument( arg); 776 proc->addArgument( arg);
775 proc->launch(""); 777 proc->launch(QString());
776#endif 778#endif
777 779
778 return true; 780 return true;
779} 781}
780 782
781/************************************************************************** 783/**************************************************************************
782 * 784 *
783 **************************************************************************/ 785 **************************************************************************/
784 786
785 787
786//calls the emailapplication and creates a mail with parameter emails as recipients 788//calls the emailapplication and creates a mail with parameter emails as recipients
787bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 789bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
788{ 790{
789 791
790 QString channel; 792 QString channel;
791 QString message; 793 QString message;
792 QString parameters; 794 QString parameters;
793 795
794 796
795 int client = KPimGlobalPrefs::instance()->mEmailClient; 797 int client = KPimGlobalPrefs::instance()->mEmailClient;
796 if (client == KPimGlobalPrefs::OTHER_EMC) 798 if (client == KPimGlobalPrefs::OTHER_EMC)
797 { 799 {
798 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 800 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
799 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 801 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
800 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 802 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
801 } 803 }
802 else 804 else
803 { 805 {
804 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 806 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
805 if (!dai) 807 if (!dai)
806 { 808 {
807 qDebug("could not find configured email application."); 809 qDebug("could not find configured email application.");
808 return false; 810 return false;
809 } 811 }
810 channel = dai->_channel; 812 channel = dai->_channel;
811 message = dai->_message; 813 message = dai->_message;
812 parameters = dai->_parameters; 814 parameters = dai->_parameters;
813 } 815 }
814 816
815#ifdef DESKTOP_VERSION 817#ifdef DESKTOP_VERSION
816 //message = channel + " " +message + " \""+ parameters + "\""; 818 //message = channel + " " +message + " \""+ parameters + "\"";
817#endif 819#endif
818 //first check if one of the mailers need the emails right in the message. 820 //first check if one of the mailers need the emails right in the message.
819 message = translateMessage(message, name, emailadress); 821 message = translateMessage(message, name, emailadress);
820 822
821#ifdef DEBUG_EXT_APP_HANDLER 823#ifdef DEBUG_EXT_APP_HANDLER
822 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 824 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
823 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); 825 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
824#endif 826#endif
825 827
826#ifndef DESKTOP_VERSION 828#ifndef DESKTOP_VERSION
827 QCopEnvelope e(channel.latin1(), message.latin1()); 829 QCopEnvelope e(channel.latin1(), message.latin1());
828 //US we need no names in the To field. The emailadresses are enough 830 //US we need no names in the To field. The emailadresses are enough
829 831
830 passParameters(&e, parameters, name, emailadress); 832 passParameters(&e, parameters, name, emailadress);
831#else // DESKTOP_VERSION 833#else // DESKTOP_VERSION
832 834
833 //KMessageBox::sorry( 0,channel ); 835 //KMessageBox::sorry( 0,channel );
834 QProcess * proc = new QProcess( this ); 836 Q3Process * proc = new Q3Process( this );
835 proc->addArgument( channel ); 837 proc->addArgument( channel );
836 if ( message.find (" " ) > 0 ) { 838 if ( message.find (" " ) > 0 ) {
837 QStringList list = QStringList::split( " ", message ); 839 QStringList list = QStringList::split( " ", message );
838 int i = 0; 840 int i = 0;
839 while ( i < list.count ( ) ) { 841 while ( i < list.count ( ) ) {
840 //qDebug("add%sdd ",list[i].latin1() ); 842 //qDebug("add%sdd ",list[i].latin1() );
841 proc->addArgument( list[i] ); 843 proc->addArgument( list[i] );
842 //KMessageBox::sorry( 0,list[i]); 844 //KMessageBox::sorry( 0,list[i]);
843 ++i; 845 ++i;
844 } 846 }
845 } else { 847 } else {
846 proc->addArgument(message ); 848 proc->addArgument(message );
847 849
848 } 850 }
849 parameters = translateMessage(parameters, name, emailadress); 851 parameters = translateMessage(parameters, name, emailadress);
850 852
851 //KMessageBox::information(0,parameters); 853 //KMessageBox::information(0,parameters);
852 proc->addArgument( parameters ); 854 proc->addArgument( parameters );
853 proc->launch(""); 855 proc->launch(QString());
854#endif 856#endif
855 857
856 return true; 858 return true;
857} 859}
858 860
859/************************************************************************** 861/**************************************************************************
860 * 862 *
861 **************************************************************************/ 863 **************************************************************************/
862 864
863//calls the emailapplication and creates a mail with parameter as recipients 865//calls the emailapplication and creates a mail with parameter as recipients
864// parameters format is 866// parameters format is
865// NAME <EMAIL>:SUBJECT 867// NAME <EMAIL>:SUBJECT
866bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 868bool ExternalAppHandler::mailToOneContact( const QString& adressline )
867{ 869{
868 QString line = adressline; 870 QString line = adressline;
869 871
870 int first = line.find( "<"); 872 int first = line.find( "<");
871 int last = line.find( ">"); 873 int last = line.find( ">");
872 QString name = line.left(first); 874 QString name = line.left(first);
873 QString emailadress = line.mid(first+1, last-first-1); 875 QString emailadress = line.mid(first+1, last-first-1);
874 876
875 //Subject can not be handled right now. 877 //Subject can not be handled right now.
876 return mailToOneContact( name, emailadress ); 878 return mailToOneContact( name, emailadress );
877 879
878} 880}
879 881
880 882
881/************************************************************************** 883/**************************************************************************
882 * 884 *
883 **************************************************************************/ 885 **************************************************************************/
884 886
885//calls the phoneapplication with the number 887//calls the phoneapplication with the number
886bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 888bool ExternalAppHandler::callByPhone( const QString& phonenumber )
887{ 889{
888#ifndef DESKTOP_VERSION 890#ifndef DESKTOP_VERSION
889 QString channel; 891 QString channel;
890 QString message; 892 QString message;
891 QString parameters; 893 QString parameters;
892 894
893 895
894 int client = KPimGlobalPrefs::instance()->mPhoneClient; 896 int client = KPimGlobalPrefs::instance()->mPhoneClient;
895 if (client == KPimGlobalPrefs::OTHER_PHC) 897 if (client == KPimGlobalPrefs::OTHER_PHC)
896 { 898 {
897 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 899 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
898 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 900 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
899 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 901 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
900 } 902 }
901 else 903 else
@@ -1187,97 +1189,97 @@ void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& paramete
1187 1189
1188 // first extract all parts of the parameters. 1190 // first extract all parts of the parameters.
1189 QStringList paramlist = QStringList::split(";", parameters); 1191 QStringList paramlist = QStringList::split(";", parameters);
1190 1192
1191 //Now check how many parts we have. 1193 //Now check how many parts we have.
1192 //=0 :no params to pass 1194 //=0 :no params to pass
1193 //>0 :parameters to pass 1195 //>0 :parameters to pass
1194 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 1196 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
1195 { 1197 {
1196 QString param = (*it); 1198 QString param = (*it);
1197 QStringList keyvallist = QStringList::split("=", param); 1199 QStringList keyvallist = QStringList::split("=", param);
1198 1200
1199 //if we have keyvalue pairs, we assume that we pass a map to the envelope 1201 //if we have keyvalue pairs, we assume that we pass a map to the envelope
1200 QStringList::Iterator it2 = keyvallist.begin(); 1202 QStringList::Iterator it2 = keyvallist.begin();
1201 QString key = (*it2); 1203 QString key = (*it2);
1202 key = key.replace( QRegExp("%1"), param1 ); 1204 key = key.replace( QRegExp("%1"), param1 );
1203 key = key.replace( QRegExp("%2"), param2 ); 1205 key = key.replace( QRegExp("%2"), param2 );
1204 ++it2; 1206 ++it2;
1205 1207
1206 if(it2 != keyvallist.end()) 1208 if(it2 != keyvallist.end())
1207 { 1209 {
1208 QString value = (*it2); 1210 QString value = (*it2);
1209 value = value.replace( QRegExp("%1"), param1 ); 1211 value = value.replace( QRegExp("%1"), param1 );
1210 value = value.replace( QRegExp("%2"), param2 ); 1212 value = value.replace( QRegExp("%2"), param2 );
1211 1213
1212 valmap.insert(key, value); 1214 valmap.insert(key, value);
1213 useValMap = true; 1215 useValMap = true;
1214 } 1216 }
1215 else 1217 else
1216 { 1218 {
1217 // qDebug("pass parameter << %s", key.latin1()); 1219 // qDebug("pass parameter << %s", key.latin1());
1218 (*e) << key; 1220 (*e) << key;
1219 } 1221 }
1220 } 1222 }
1221 1223
1222 if (useValMap == true) 1224 if (useValMap == true)
1223 (*e) << valmap; 1225 (*e) << valmap;
1224 1226
1225#endif 1227#endif
1226 1228
1227} 1229}
1228 1230
1229 1231
1230 1232
1231/************************************************************************** 1233/**************************************************************************
1232 * 1234 *
1233 **************************************************************************/ 1235 **************************************************************************/
1234 1236
1235void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) 1237void ExternalAppHandler::appMessage( const Q3CString& cmsg, const QByteArray& data )
1236{ 1238{
1237 qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this); 1239 qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this);
1238 if ( cmsg == "nextView()" ) { 1240 if ( cmsg == "nextView()" ) {
1239 qDebug("nextView()"); 1241 qDebug("nextView()");
1240 QTimer::singleShot( 0, this, SIGNAL ( nextView() )); 1242 QTimer::singleShot( 0, this, SIGNAL ( nextView() ));
1241 return; 1243 return;
1242 } 1244 }
1243 if ( cmsg == "callContactdialog()" ) { 1245 if ( cmsg == "callContactdialog()" ) {
1244 qDebug("callContactdialog()"); 1246 qDebug("callContactdialog()");
1245 QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() )); 1247 QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() ));
1246 return; 1248 return;
1247 } 1249 }
1248 if ( cmsg == "doRingSync" ) { 1250 if ( cmsg == "doRingSync" ) {
1249 qDebug("doRingSync"); 1251 qDebug("doRingSync");
1250 QTimer::singleShot( 0, this, SIGNAL ( doRingSync() )); 1252 QTimer::singleShot( 0, this, SIGNAL ( doRingSync() ));
1251 return; 1253 return;
1252 } 1254 }
1253 1255
1254 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1256 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1255 if (!res) 1257 if (!res)
1256 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); 1258 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data );
1257 1259
1258 if (!res) 1260 if (!res)
1259 res = mDisplayDetails->appMessage( cmsg, data ); 1261 res = mDisplayDetails->appMessage( cmsg, data );
1260 1262
1261// if (!res) 1263// if (!res)
1262// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1264// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1263} 1265}
1264 1266
1265 1267
1266 1268
1267bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1269bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1268{ 1270{
1269 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1271 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1270 // maybe we are sending to KA/Pi fom a different worldd... 1272 // maybe we are sending to KA/Pi fom a different worldd...
1271 // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application 1273 // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application
1272 // for that reason we send the current QApplication::desktop()->width() to KA/Pi 1274 // for that reason we send the current QApplication::desktop()->width() to KA/Pi
1273 //qDebug("UID %s ", sessionuid.latin1()); 1275 //qDebug("UID %s ", sessionuid.latin1());
1274 //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() )); 1276 //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() ));
1275 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); 1277 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid);
1276} 1278}
1277 1279
1278bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1280bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1279{ 1281{
1280 QStringList list4, list5, list6; 1282 QStringList list4, list5, list6;
1281 1283
1282 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1284 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1283 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1285 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);