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,413 +1,415 @@
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&)));
366 368
367//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); 369//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
368//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); 370//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
369//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 371//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
370 372
371 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); 373 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
372 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 374 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
373 375
374 376
375 377
376 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); 378 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList");
377 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); 379 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&)));
378 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 380 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
379 381
380 382
381} 383}
382 384
383ExternalAppHandler::~ExternalAppHandler() 385ExternalAppHandler::~ExternalAppHandler()
384{ 386{
385 delete mNameEmailUidListFromKAPITransfer; 387 delete mNameEmailUidListFromKAPITransfer;
386 //delete mFindByEmailFromKAPITransfer; 388 //delete mFindByEmailFromKAPITransfer;
387 delete mDisplayDetails; 389 delete mDisplayDetails;
388 delete mBirthdayListFromKAPITransfer; 390 delete mBirthdayListFromKAPITransfer;
389} 391}
390 392
391void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, 393void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid,
392 const QStringList& nameList, 394 const QStringList& nameList,
393 const QStringList& emailList, 395 const QStringList& emailList,
394 const QStringList& uidList, 396 const QStringList& uidList,
395 const QStringList&, 397 const QStringList&,
396 const QStringList&, 398 const QStringList&,
397 const QStringList& ) 399 const QStringList& )
398{ 400{
399 // this method is a conevnient way to reduce the number of parameters I have to pass 401 // this method is a conevnient way to reduce the number of parameters I have to pass
400 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); 402 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList);
401} 403}
402 404
403 405
404void ExternalAppHandler::loadConfig() 406void ExternalAppHandler::loadConfig()
405{ 407{
406 408
407 mDefaultItems.clear(); 409 mDefaultItems.clear();
408 mEmailAppAvailable = UNDEFINED; 410 mEmailAppAvailable = UNDEFINED;
409 mPhoneAppAvailable = UNDEFINED; 411 mPhoneAppAvailable = UNDEFINED;
410 mFaxAppAvailable = UNDEFINED; 412 mFaxAppAvailable = UNDEFINED;
411 mSMSAppAvailable = UNDEFINED; 413 mSMSAppAvailable = UNDEFINED;
412 mPagerAppAvailable = UNDEFINED; 414 mPagerAppAvailable = UNDEFINED;
413 mSIPAppAvailable = UNDEFINED; 415 mSIPAppAvailable = UNDEFINED;
@@ -425,195 +427,195 @@ void ExternalAppHandler::loadConfig()
425 opiepath = qtopiapath; 427 opiepath = qtopiapath;
426 428
427 429
428 430
429 //mailclients 431 //mailclients
430 QString mailmsg1 = "writeMail(QString,QString)"; 432 QString mailmsg1 = "writeMail(QString,QString)";
431 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 433 QString mailmsg2 = "writeMail(QMap(QString,QString))";
432 434
433 QString undefined = ""; 435 QString undefined = "";
434 436
435 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 437 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
436 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 438 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
437 439
438#ifdef DESKTOP_VERSION 440#ifdef DESKTOP_VERSION
439 QString appPath; 441 QString appPath;
440#ifdef _WIN32_ 442#ifdef _WIN32_
441 appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe"; 443 appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe";
442#else 444#else
443 appPath = "/usr/bin/thunderbird"; 445 appPath = "/usr/bin/thunderbird";
444#endif 446#endif
445 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1"); 447 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1");
446 448
447#ifdef _WIN32_ 449#ifdef _WIN32_
448 appPath = "C:\\Programme\\Mozilla\\mozilla.exe"; 450 appPath = "C:\\Programme\\Mozilla\\mozilla.exe";
449#else 451#else
450 appPath = "/usr/bin/mozilla"; 452 appPath = "/usr/bin/mozilla";
451#endif 453#endif
452 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1"); 454 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1");
453 455
454 456
455 457
456#else 458#else
457 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 459 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
458 ( QFile::exists( opiepath + "/bin/ompi" )) || 460 ( QFile::exists( opiepath + "/bin/ompi" )) ||
459 ( QFile::exists( qtpath + "/bin/ompi" ))) 461 ( QFile::exists( qtpath + "/bin/ompi" )))
460 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 462 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
461 463
462 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || 464 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) ||
463 ( QFile::exists( qtpath + "/bin/qtmail" ))) 465 ( QFile::exists( qtpath + "/bin/qtmail" )))
464 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 466 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
465 467
466 if ( QFile::exists( opiepath + "/bin/opiemail" )) 468 if ( QFile::exists( opiepath + "/bin/opiemail" ))
467 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 469 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
468 470
469 if ( QFile::exists( opiepath + "/bin/mailit" )) 471 if ( QFile::exists( opiepath + "/bin/mailit" ))
470 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 472 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
471#endif 473#endif
472 474
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;
572 else 574 else
573 mSMSAppAvailable = AVAILABLE; 575 mSMSAppAvailable = AVAILABLE;
574 } 576 }
575 577
576 return (mSMSAppAvailable == AVAILABLE); 578 return (mSMSAppAvailable == AVAILABLE);
577#else //DESKTOP_VERSION 579#else //DESKTOP_VERSION
578 return false; 580 return false;
579#endif //DESKTOP_VERSION 581#endif //DESKTOP_VERSION
580} 582}
581 583
582bool ExternalAppHandler::isPhoneAppAvailable() 584bool ExternalAppHandler::isPhoneAppAvailable()
583{ 585{
584#ifndef DESKTOP_VERSION 586#ifndef DESKTOP_VERSION
585 if (mPhoneAppAvailable == UNDEFINED) 587 if (mPhoneAppAvailable == UNDEFINED)
586 { 588 {
587 int client = KPimGlobalPrefs::instance()->mPhoneClient; 589 int client = KPimGlobalPrefs::instance()->mPhoneClient;
588 if (client == KPimGlobalPrefs::NONE_PHC) 590 if (client == KPimGlobalPrefs::NONE_PHC)
589 mPhoneAppAvailable = UNAVAILABLE; 591 mPhoneAppAvailable = UNAVAILABLE;
590 else 592 else
591 mPhoneAppAvailable = AVAILABLE; 593 mPhoneAppAvailable = AVAILABLE;
592 } 594 }
593 595
594 return (mPhoneAppAvailable == AVAILABLE); 596 return (mPhoneAppAvailable == AVAILABLE);
595#else //DESKTOP_VERSION 597#else //DESKTOP_VERSION
596 return false; 598 return false;
597#endif //DESKTOP_VERSION 599#endif //DESKTOP_VERSION
598} 600}
599 601
600bool ExternalAppHandler::isFaxAppAvailable() 602bool ExternalAppHandler::isFaxAppAvailable()
601{ 603{
602#ifndef DESKTOP_VERSION 604#ifndef DESKTOP_VERSION
603 if (mFaxAppAvailable == UNDEFINED) 605 if (mFaxAppAvailable == UNDEFINED)
604 { 606 {
605 int client = KPimGlobalPrefs::instance()->mFaxClient; 607 int client = KPimGlobalPrefs::instance()->mFaxClient;
606 if (client == KPimGlobalPrefs::NONE_FAC) 608 if (client == KPimGlobalPrefs::NONE_FAC)
607 mFaxAppAvailable = UNAVAILABLE; 609 mFaxAppAvailable = UNAVAILABLE;
608 else 610 else
609 mFaxAppAvailable = AVAILABLE; 611 mFaxAppAvailable = AVAILABLE;
610 } 612 }
611 613
612 return (mFaxAppAvailable == AVAILABLE); 614 return (mFaxAppAvailable == AVAILABLE);
613#else //DESKTOP_VERSION 615#else //DESKTOP_VERSION
614 return false; 616 return false;
615#endif //DESKTOP_VERSION 617#endif //DESKTOP_VERSION
616} 618}
617 619
618bool ExternalAppHandler::isPagerAppAvailable() 620bool ExternalAppHandler::isPagerAppAvailable()
619{ 621{
@@ -653,297 +655,297 @@ bool ExternalAppHandler::isSIPAppAvailable()
653} 655}
654 656
655/************************************************************************** 657/**************************************************************************
656 * 658 *
657 **************************************************************************/ 659 **************************************************************************/
658 660
659 661
660//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 662//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
661bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 663bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
662{ 664{
663 665
664#ifndef DESKTOP_VERSION 666#ifndef DESKTOP_VERSION
665 QString channel; 667 QString channel;
666 QString message2; 668 QString message2;
667 QString parameters2; 669 QString parameters2;
668 670
669 671
670 int client = KPimGlobalPrefs::instance()->mEmailClient; 672 int client = KPimGlobalPrefs::instance()->mEmailClient;
671 if (client == KPimGlobalPrefs::OTHER_EMC) 673 if (client == KPimGlobalPrefs::OTHER_EMC)
672 { 674 {
673 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 675 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
674 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 676 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
675 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 677 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
676 } 678 }
677 else 679 else
678 { 680 {
679 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 681 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
680 if (!dai) 682 if (!dai)
681 { 683 {
682 qDebug("could not find configured email application."); 684 qDebug("could not find configured email application.");
683 return false; 685 return false;
684 } 686 }
685 channel = dai->_channel; 687 channel = dai->_channel;
686 message2 = dai->_message2; 688 message2 = dai->_message2;
687 parameters2 = dai->_parameters2; 689 parameters2 = dai->_parameters2;
688 } 690 }
689 691
690 //first check if one of the mailers need the emails right in the message. 692 //first check if one of the mailers need the emails right in the message.
691 message2 = translateMessage(message2, emails, urls); 693 message2 = translateMessage(message2, emails, urls);
692 694
693 695
694#ifdef DEBUG_EXT_APP_HANDLER 696#ifdef DEBUG_EXT_APP_HANDLER
695 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 697 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
696 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 698 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
697#endif 699#endif
698 700
699 701
700 QCopEnvelope e(channel.latin1(), message2.latin1()); 702 QCopEnvelope e(channel.latin1(), message2.latin1());
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
902 { 904 {
903 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 905 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
904 if (!dai) 906 if (!dai)
905 { 907 {
906 qDebug("could not find configured phone application."); 908 qDebug("could not find configured phone application.");
907 return false; 909 return false;
908 } 910 }
909 channel = dai->_channel; 911 channel = dai->_channel;
910 message = dai->_message; 912 message = dai->_message;
911 parameters = dai->_parameters; 913 parameters = dai->_parameters;
912 } 914 }
913 915
914 916
915 //first check if one of the mailers need the emails right in the message. 917 //first check if one of the mailers need the emails right in the message.
916 message = translateMessage(message, phonenumber, ""); 918 message = translateMessage(message, phonenumber, "");
917 919
918 920
919#ifdef DEBUG_EXT_APP_HANDLER 921#ifdef DEBUG_EXT_APP_HANDLER
920 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 922 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
921 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 923 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
922#endif 924#endif
923 925
924 QCopEnvelope e(channel.latin1(), message.latin1()); 926 QCopEnvelope e(channel.latin1(), message.latin1());
925 //US we need no names in the To field. The emailadresses are enough 927 //US we need no names in the To field. The emailadresses are enough
926 928
927 passParameters(&e, parameters, phonenumber, ""); 929 passParameters(&e, parameters, phonenumber, "");
928 930
929 931
930#else 932#else
931 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 933 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
932#endif 934#endif
933 935
934 936
935 return true; 937 return true;
936} 938}
937 939
938/************************************************************************** 940/**************************************************************************
939 * 941 *
940 **************************************************************************/ 942 **************************************************************************/
941 943
942//calls the smsapplication with the number 944//calls the smsapplication with the number
943bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 945bool ExternalAppHandler::callBySMS( const QString& phonenumber )
944{ 946{
945#ifndef DESKTOP_VERSION 947#ifndef DESKTOP_VERSION
946 QString channel; 948 QString channel;
947 QString message; 949 QString message;
948 QString parameters; 950 QString parameters;
949 951
@@ -1139,183 +1141,183 @@ bool ExternalAppHandler::callBySIP( const QString& sipnumber )
1139 parameters = dai->_parameters; 1141 parameters = dai->_parameters;
1140 } 1142 }
1141 1143
1142 1144
1143 //first check if one of the sip apps need the emails right in the message. 1145 //first check if one of the sip apps need the emails right in the message.
1144 message = translateMessage(message, sipnumber, ""); 1146 message = translateMessage(message, sipnumber, "");
1145 1147
1146 1148
1147#ifdef DEBUG_EXT_APP_HANDLER 1149#ifdef DEBUG_EXT_APP_HANDLER
1148 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1150 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1149 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); 1151 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1());
1150#endif 1152#endif
1151 1153
1152 QCopEnvelope e(channel.latin1(), message.latin1()); 1154 QCopEnvelope e(channel.latin1(), message.latin1());
1153 //US we need no names in the To field. The emailadresses are enough 1155 //US we need no names in the To field. The emailadresses are enough
1154 1156
1155 passParameters(&e, parameters, sipnumber, ""); 1157 passParameters(&e, parameters, sipnumber, "");
1156 1158
1157 1159
1158#else 1160#else
1159 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); 1161 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) );
1160#endif 1162#endif
1161 1163
1162 1164
1163 return true; 1165 return true;
1164} 1166}
1165 1167
1166 1168
1167/************************************************************************** 1169/**************************************************************************
1168 * 1170 *
1169 **************************************************************************/ 1171 **************************************************************************/
1170 1172
1171 1173
1172QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 1174QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
1173{ 1175{
1174 message = message.replace( QRegExp("%1"), param1 ); 1176 message = message.replace( QRegExp("%1"), param1 );
1175 return message.replace( QRegExp("%2"), param2 ); 1177 return message.replace( QRegExp("%2"), param2 );
1176} 1178}
1177 1179
1178/************************************************************************** 1180/**************************************************************************
1179 * 1181 *
1180 **************************************************************************/ 1182 **************************************************************************/
1181 1183
1182void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const 1184void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
1183{ 1185{
1184#ifndef DESKTOP_VERSION 1186#ifndef DESKTOP_VERSION
1185 QMap<QString, QString> valmap; 1187 QMap<QString, QString> valmap;
1186 bool useValMap = false; 1188 bool useValMap = false;
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);
1284} 1286}
1285 1287
1286bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) 1288bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email)
1287{ 1289{
1288 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1290 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1289 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); 1291 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email);
1290} 1292}
1291 1293
1292bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1294bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1293{ 1295{
1294 QStringList list4, list5, list6; 1296 QStringList list4, list5, list6;
1295 1297
1296 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1298 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1297 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1299 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1298} 1300}
1299 1301
1300bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) 1302bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid)
1301{ 1303{
1302 mDisplayDetails->setSourceChannel(""); 1304 mDisplayDetails->setSourceChannel("");
1303 return mDisplayDetails->sendMessageToTarget("", name, email, uid); 1305 return mDisplayDetails->sendMessageToTarget("", name, email, uid);
1304} 1306}
1305 1307
1306bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1308bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1307{ 1309{
1308 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1310 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1309 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); 1311 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid);
1310} 1312}
1311 1313
1312bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) 1314bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6)
1313{ 1315{
1314 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1316 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1315 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1317 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1316} 1318}
1317 1319
1318 1320
1319 1321
1320 1322
1321 1323