summaryrefslogtreecommitdiffabout
path: root/libkdepim/externalapphandler.cpp
Unidiff
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 779b20e..9085673 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -1,1173 +1,1181 @@
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 <qmap.h> 33#include <qmap.h>
34#include <qregexp.h> 34#include <qregexp.h>
35 35
36#ifndef DESKTOP_VERSION 36#ifndef DESKTOP_VERSION
37#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
38#include <qtopia/qcopenvelope_qws.h> 38#include <qtopia/qcopenvelope_qws.h>
39#else 39#else
40#include <qapplication.h> 40#include <qapplication.h>
41#endif 41#endif
42 42
43#include <kstaticdeleter.h> 43#include <kstaticdeleter.h>
44#include <kmessagebox.h> 44#include <kmessagebox.h>
45 45
46 46
47#include "externalapphandler.h" 47#include "externalapphandler.h"
48 48
49#include "kpimglobalprefs.h" 49#include "kpimglobalprefs.h"
50 50
51//uncomment line to get debug output 51//uncomment line to get debug output
52//#define DEBUG_EXT_APP_HANDLER 52//#define DEBUG_EXT_APP_HANDLER
53 53
54/********************************************************************************* 54/*********************************************************************************
55 * 55 *
56 ********************************************************************************/ 56 ********************************************************************************/
57 57
58 58
59QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 59QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
60 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) 60 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
61{ 61{
62 //sourceMessage passes later three parameters: sourceChannel, uid, param1 62 //sourceMessage passes later three parameters: sourceChannel, uid, param1
63 if (_usedSourceParameters == 0) 63 if (_usedSourceParameters == 0)
64 _sourceMessageParameters = "(QString,QString)"; 64 _sourceMessageParameters = "QString,QString)";
65 else if (_usedSourceParameters == 1) 65 else if (_usedSourceParameters == 1)
66 _sourceMessageParameters = "(QString,QString,QString)"; 66 _sourceMessageParameters = "(QString,QString,QString)";
67 else if (_usedSourceParameters == 2) 67 else if (_usedSourceParameters == 2)
68 _sourceMessageParameters = "(QString,QString,QString,QString)"; 68 _sourceMessageParameters = "(QString,QString,QString,QString)";
69 else if (_usedSourceParameters == 3) 69 else if (_usedSourceParameters == 3)
70 _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; 70 _sourceMessageParameters = "(QString,QString,QString,QString,QString)";
71} 71}
72 72
73/*********************************************************************************/ 73/*********************************************************************************/
74 74
75QCopTransferItem::QCopTransferItem() 75QCopTransferItem::QCopTransferItem()
76{ 76{
77} 77}
78 78
79/*********************************************************************************/ 79/*********************************************************************************/
80bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) 80bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3)
81{ 81{
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84 //sourceMessage passes two parameters: sourceChannel, uid 84 //sourceMessage passes two parameters: sourceChannel, uid
85 QString sourceMessage = _sourceMessage + _sourceMessageParameters; 85 QString sourceMessage = _sourceMessage + _sourceMessageParameters;
86#ifdef DEBUG_EXT_APP_HANDLER 86#ifdef DEBUG_EXT_APP_HANDLER
87 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); 87 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1());
88 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()); 88 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());
89#endif 89#endif
90 90
91 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); 91 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
92 92
93 e << _sourceChannel << uid; 93 e << _sourceChannel << uid;
94 94
95 if (_usedSourceParameters == 1) 95 if (_usedSourceParameters == 1)
96 e << param1; 96 e << param1;
97 else if (_usedSourceParameters == 2) 97 else if (_usedSourceParameters == 2)
98 e << param1 << param2; 98 e << param1 << param2;
99 else if (_usedSourceParameters == 3) 99 else if (_usedSourceParameters == 3)
100 e << param1 << param2 << param3; 100 e << param1 << param2 << param3;
101 101
102 qApp->processEvents(); 102 qApp->processEvents();
103 103
104 return true; 104 return true;
105 105
106#else 106#else
107 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 107 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
108 return false; 108 return false;
109#endif 109#endif
110 110
111} 111}
112 112
113 113
114/*********************************************************************************/ 114/*********************************************************************************/
115void QCopTransferItem::setSourceChannel(const QString& sourceChannel) 115void QCopTransferItem::setSourceChannel(const QString& sourceChannel)
116{ 116{
117 117
118 if ( !sourceChannel.isEmpty()) 118 if ( !sourceChannel.isEmpty())
119 _sourceChannel = sourceChannel; 119 _sourceChannel = sourceChannel;
120} 120}
121 121
122 122
123/*********************************************************************************/ 123/*********************************************************************************/
124bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 124bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
125{ 125{
126 126
127 // copied from old mail2 127 // copied from old mail2
128/* 128/*
129 static int ii = 0; 129 static int ii = 0;
130 130
131 // block second call 131 // block second call
132 if ( ii < 2 ) { 132 if ( ii < 2 ) {
133 ++ii; 133 ++ii;
134 if ( ii > 1 ) { 134 if ( ii > 1 ) {
135 qDebug("qcop call blocked "); 135 qDebug("qcop call blocked ");
136 return true; 136 return true;
137 } 137 }
138 } 138 }
139*/ 139*/
140 140
141// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); 141// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
142 142
143 //we are in the target and get a request from the source 143 //we are in the target and get a request from the source
144 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) 144 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
145 { 145 {
146 146
147 QDataStream stream( data, IO_ReadOnly ); 147 QDataStream stream( data, IO_ReadOnly );
148 148
149 149
150 QString sourceChannel; 150 QString sourceChannel;
151 QString uid; 151 QString uid;
152 QString param1; 152 QString param1;
153 QString param2; 153 QString param2;
154 QString param3; 154 QString param3;
155 155
156 stream >> sourceChannel >> uid; 156 stream >> sourceChannel >> uid;
157 157
158 if (_usedSourceParameters == 0) 158 if (_usedSourceParameters == 0)
159 { 159 {
160 emit receivedMessageFromSource(sourceChannel, uid); 160 emit receivedMessageFromSource(sourceChannel, uid);
161 } 161 }
162 else if (_usedSourceParameters == 1) 162 else if (_usedSourceParameters == 1)
163 { 163 {
164 stream >> param1; 164 stream >> param1;
165 emit receivedMessageFromSource(sourceChannel, uid, param1); 165 emit receivedMessageFromSource(sourceChannel, uid, param1);
166 } 166 }
167 else if (_usedSourceParameters == 2) 167 else if (_usedSourceParameters == 2)
168 { 168 {
169 stream >> param1 >> param2; 169 stream >> param1 >> param2;
170 emit receivedMessageFromSource(sourceChannel, uid, param1, param2); 170 emit receivedMessageFromSource(sourceChannel, uid, param1, param2);
171 } 171 }
172 else if (_usedSourceParameters == 3) 172 else if (_usedSourceParameters == 3)
173 { 173 {
174 stream >> param1 >> param2 >> param3; 174 stream >> param1 >> param2 >> param3;
175 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); 175 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3);
176 } 176 }
177 177
178 return true; 178 return true;
179 } 179 }
180 180
181 return false; 181 return false;
182} 182}
183 183
184 184
185/********************************************************************************* 185/*********************************************************************************
186 * 186 *
187 ********************************************************************************/ 187 ********************************************************************************/
188 188
189 189
190QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 190QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
191 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 191 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
192{ 192{
193 //targetMessage returns later two parameters: uid, and map<qstring,qstring> 193 //targetMessage returns later two parameters: uid, and map<qstring,qstring>
194 _targetMessageParameters = "(QString,QMAP<QString,QString>)"; 194 _targetMessageParameters = "(QString,QMAP<QString,QString>)";
195} 195}
196 196
197/*********************************************************************************/ 197/*********************************************************************************/
198bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) 198bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap)
199{ 199{
200#ifndef DESKTOP_VERSION 200#ifndef DESKTOP_VERSION
201 //targetMessage passes two parameters: uid, map 201 //targetMessage passes two parameters: uid, map
202 QString targetMessage = _targetMessage + _targetMessageParameters; 202 QString targetMessage = _targetMessage + _targetMessageParameters;
203 203
204#ifdef DEBUG_EXT_APP_HANDLER 204#ifdef DEBUG_EXT_APP_HANDLER
205 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 205 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
206 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); 206 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
207#endif 207#endif
208 208
209 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 209 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
210 //US we need no names in the To field. The emailadresses are enough 210 //US we need no names in the To field. The emailadresses are enough
211 211
212 e << uid << nameEmailMap; 212 e << uid << nameEmailMap;
213 213
214 qApp->processEvents(); 214 qApp->processEvents();
215 215
216 return true; 216 return true;
217 217
218#else 218#else
219 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 219 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
220 return false; 220 return false;
221#endif 221#endif
222 222
223} 223}
224 224
225 225
226/*********************************************************************************/ 226/*********************************************************************************/
227bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 227bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
228{ 228{
229 bool res = QCopTransferItem::appMessage( cmsg, data ); 229 bool res = QCopTransferItem::appMessage( cmsg, data );
230 230
231 if (res == false) 231 if (res == false)
232 { 232 {
233 QDataStream stream( data, IO_ReadOnly ); 233 QDataStream stream( data, IO_ReadOnly );
234 234
235// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); 235// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() );
236 236
237 //we are in the source and get an answer from the target 237 //we are in the source and get an answer from the target
238 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 238 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
239 { 239 {
240 QMap<QString,QString> adrMap; 240 QMap<QString,QString> adrMap;
241 QString uid; 241 QString uid;
242 242
243 stream >> uid >> adrMap; 243 stream >> uid >> adrMap;
244 244
245 emit receivedMessageFromTarget(uid, adrMap); 245 emit receivedMessageFromTarget(uid, adrMap);
246 246
247 247
248 return true; 248 return true;
249 } 249 }
250 } 250 }
251 251
252 return false; 252 return false;
253} 253}
254 254
255 255
256/********************************************************************************* 256/*********************************************************************************
257 * 257 *
258 ********************************************************************************/ 258 ********************************************************************************/
259 259
260QCopListTransferItem::~QCopListTransferItem()
261{
262
263}
260 264
261QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 265QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
262 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 266 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
263{ 267{
264 //targetMessage returns later two parameters: uid, and three lists 268 //targetMessage returns later two parameters: uid, and three lists
265 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; 269 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)";
266} 270}
267 271
268/*********************************************************************************/ 272/*********************************************************************************/
269bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) 273bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6)
270{ 274{
271#ifndef DESKTOP_VERSION 275#ifndef DESKTOP_VERSION
272 //targetMessage passes two parameters: uid, map 276 //targetMessage passes two parameters: uid, map
273 QString targetMessage = _targetMessage + _targetMessageParameters; 277 QString targetMessage = _targetMessage + _targetMessageParameters;
274 278
275#ifdef DEBUG_EXT_APP_HANDLER 279#ifdef DEBUG_EXT_APP_HANDLER
276 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 280 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
277 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); 281 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1());
278 282
279 283
280 for ( int i = 0; i < list3.count(); i++) 284 for ( int i = 0; i < list3.count(); i++)
281 qDebug("listentry list3: %s",list3[i].latin1()); 285 qDebug("listentry list3: %s",list3[i].latin1());
282#endif 286#endif
283 287
284 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 288 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
285 //US we need no names in the To field. The emailadresses are enough 289 //US we need no names in the To field. The emailadresses are enough
286 290
287 e << uid << list1 << list2 << list3 << list4 << list5 << list6; 291 e << uid << list1 << list2 << list3 << list4 << list5 << list6;
288 292
289 qApp->processEvents(); 293 qApp->processEvents();
290 294
291 return true; 295 return true;
292 296
293#else 297#else
294 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 298 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
295 return false; 299 return false;
296#endif 300#endif
297 301
298} 302}
299 303
300 304
301/*********************************************************************************/ 305/*********************************************************************************/
302bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 306bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
303{ 307{
304 bool res = QCopTransferItem::appMessage( cmsg, data ); 308 bool res = QCopTransferItem::appMessage( cmsg, data );
305#ifdef DEBUG_EXT_APP_HANDLER 309#ifdef DEBUG_EXT_APP_HANDLER
306 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 310 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
307#endif 311#endif
308 312
309 if (res == false) 313 if (res == false)
310 { 314 {
311 QDataStream stream( data, IO_ReadOnly ); 315 QDataStream stream( data, IO_ReadOnly );
312 316
313#ifdef DEBUG_EXT_APP_HANDLER 317#ifdef DEBUG_EXT_APP_HANDLER
314 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 318 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
315#endif 319#endif
316 320
317 //we are in the source and get an answer from the target 321 //we are in the source and get an answer from the target
318 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 322 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
319 { 323 {
320 QStringList list1; 324 QStringList list1;
321 QStringList list2; 325 QStringList list2;
322 QStringList list3; 326 QStringList list3;
323 QStringList list4; 327 QStringList list4;
324 QStringList list5; 328 QStringList list5;
325 QStringList list6; 329 QStringList list6;
326 QString uid; 330 QString uid;
327 331
328#ifdef DEBUG_EXT_APP_HANDLER 332#ifdef DEBUG_EXT_APP_HANDLER
329 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 333 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
330#endif 334#endif
331 335
332 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; 336 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6;
333 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); 337 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6);
334 338
335 339
336 return true; 340 return true;
337 } 341 }
338 } 342 }
339 343
340 return false; 344 return false;
341} 345}
342 346
343 347
344 348
345/********************************************************************************* 349/*********************************************************************************
346 * 350 *
347 ********************************************************************************/ 351 ********************************************************************************/
348 352
349 353
350ExternalAppHandler *ExternalAppHandler::sInstance = 0; 354ExternalAppHandler *ExternalAppHandler::sInstance = 0;
351static KStaticDeleter<ExternalAppHandler> staticDeleter; 355static KStaticDeleter<ExternalAppHandler> staticDeleter;
352 356
353ExternalAppHandler::ExternalAppHandler() 357ExternalAppHandler::ExternalAppHandler()
354{ 358{
355 mDefaultItems.setAutoDelete(true); 359 mDefaultItems.setAutoDelete(true);
356 360
357 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); 361 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
358 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); 362 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&)));
359 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&))); 363 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&)));
360 364
361//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); 365//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
362//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); 366//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
363//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 367//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
364 368
365 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); 369 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
366 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&))); 370 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&)));
367 371
368 372
369 373
370 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); 374 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList");
371 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); 375 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&)));
372 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&))); 376 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&)));
373 377
374 378
375} 379}
376 380
377ExternalAppHandler::~ExternalAppHandler() 381ExternalAppHandler::~ExternalAppHandler()
378{ 382{
383 delete mNameEmailUidListFromKAPITransfer;
384 //delete mFindByEmailFromKAPITransfer;
385 delete mDisplayDetails;
386 delete mBirthdayListFromKAPITransfer;
379} 387}
380 388
381void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, 389void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid,
382 const QStringList& nameList, 390 const QStringList& nameList,
383 const QStringList& emailList, 391 const QStringList& emailList,
384 const QStringList& uidList, 392 const QStringList& uidList,
385 const QStringList&, 393 const QStringList&,
386 const QStringList&, 394 const QStringList&,
387 const QStringList& ) 395 const QStringList& )
388{ 396{
389 // this method is a conevnient way to reduce the number of parameters I have to pass 397 // this method is a conevnient way to reduce the number of parameters I have to pass
390 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); 398 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList);
391} 399}
392 400
393 401
394void ExternalAppHandler::loadConfig() 402void ExternalAppHandler::loadConfig()
395{ 403{
396 404
397 mDefaultItems.clear(); 405 mDefaultItems.clear();
398 mEmailAppAvailable = UNDEFINED; 406 mEmailAppAvailable = UNDEFINED;
399 mPhoneAppAvailable = UNDEFINED; 407 mPhoneAppAvailable = UNDEFINED;
400 mFaxAppAvailable = UNDEFINED; 408 mFaxAppAvailable = UNDEFINED;
401 mSMSAppAvailable = UNDEFINED; 409 mSMSAppAvailable = UNDEFINED;
402 mPagerAppAvailable = UNDEFINED; 410 mPagerAppAvailable = UNDEFINED;
403 mSIPAppAvailable = UNDEFINED; 411 mSIPAppAvailable = UNDEFINED;
404 412
405 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 413 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
406 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 414 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
407 415
408 if (opiepath.isEmpty()) 416 if (opiepath.isEmpty())
409 opiepath = qtopiapath; 417 opiepath = qtopiapath;
410 418
411 //mailclients 419 //mailclients
412 QString mailmsg1 = "writeMail(QString,QString)"; 420 QString mailmsg1 = "writeMail(QString,QString)";
413 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 421 QString mailmsg2 = "writeMail(QMap(QString,QString))";
414 422
415 QString undefined = ""; 423 QString undefined = "";
416 424
417 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 425 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
418 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 426 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
419 427
420 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 428 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
421 ( QFile::exists( opiepath + "/bin/ompi" ))) 429 ( QFile::exists( opiepath + "/bin/ompi" )))
422 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 430 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
423 431
424 if ( QFile::exists( qtopiapath + "/bin/qtmail" )) 432 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
425 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 433 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
426 434
427 if ( QFile::exists( opiepath + "/bin/opiemail" )) 435 if ( QFile::exists( opiepath + "/bin/opiemail" ))
428 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 436 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
429 437
430 438
431 439
432 //phoneclients 440 //phoneclients
433 441
434 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 442 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
435 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 443 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
436 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 444 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
437 ( QFile::exists( opiepath + "/bin/kppi" ))) 445 ( QFile::exists( opiepath + "/bin/kppi" )))
438 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 446 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
439 447
440 //faxclients 448 //faxclients
441 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 449 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
442 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 450 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
443 451
444 //smsclients 452 //smsclients
445 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 453 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
446 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 454 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
447 455
448 //pagerclients 456 //pagerclients
449 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 457 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
450 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 458 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
451 459
452 //sipclients 460 //sipclients
453 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); 461 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined);
454 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); 462 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined);
455 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 463 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
456 ( QFile::exists( opiepath + "/bin/kppi" ))) 464 ( QFile::exists( opiepath + "/bin/kppi" )))
457 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 465 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
458 466
459} 467}
460 468
461ExternalAppHandler *ExternalAppHandler::instance() 469ExternalAppHandler *ExternalAppHandler::instance()
462{ 470{
463 if ( !sInstance ) { 471 if ( !sInstance ) {
464 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 472 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
465 sInstance->loadConfig(); 473 sInstance->loadConfig();
466 } 474 }
467 475
468 return sInstance; 476 return sInstance;
469} 477}
470 478
471void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 479void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
472{ 480{
473 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 481 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
474 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); 482 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
475 mDefaultItems.append(dai); 483 mDefaultItems.append(dai);
476} 484}
477 485
478 486
479QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 487QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
480{ 488{
481 QList<DefaultAppItem> list; 489 QList<DefaultAppItem> list;
482 490
483 DefaultAppItem* dai; 491 DefaultAppItem* dai;
484 492
485 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 493 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
486 { 494 {
487 if (dai->_type == type) 495 if (dai->_type == type)
488 list.append(dai); 496 list.append(dai);
489 } 497 }
490 498
491 return list; 499 return list;
492} 500}
493 501
494DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 502DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
495{ 503{
496 DefaultAppItem* dai; 504 DefaultAppItem* dai;
497 505
498 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 506 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
499 { 507 {
500 if (dai->_type == type && dai->_id == clientid) 508 if (dai->_type == type && dai->_id == clientid)
501 return dai; 509 return dai;
502 } 510 }
503 511
504 return 0; 512 return 0;
505} 513}
506 514
507bool ExternalAppHandler::isEmailAppAvailable() 515bool ExternalAppHandler::isEmailAppAvailable()
508{ 516{
509#ifndef DESKTOP_VERSION 517#ifndef DESKTOP_VERSION
510 if (mEmailAppAvailable == UNDEFINED) 518 if (mEmailAppAvailable == UNDEFINED)
511 { 519 {
512 int client = KPimGlobalPrefs::instance()->mEmailClient; 520 int client = KPimGlobalPrefs::instance()->mEmailClient;
513 if (client == KPimGlobalPrefs::NONE_EMC) 521 if (client == KPimGlobalPrefs::NONE_EMC)
514 mEmailAppAvailable = UNAVAILABLE; 522 mEmailAppAvailable = UNAVAILABLE;
515 else 523 else
516 mEmailAppAvailable = AVAILABLE; 524 mEmailAppAvailable = AVAILABLE;
517 } 525 }
518 return (mEmailAppAvailable == AVAILABLE); 526 return (mEmailAppAvailable == AVAILABLE);
519 527
520#else //DESKTOP_VERSION 528#else //DESKTOP_VERSION
521 return false; 529 return false;
522#endif //DESKTOP_VERSION 530#endif //DESKTOP_VERSION
523} 531}
524 532
525bool ExternalAppHandler::isSMSAppAvailable() 533bool ExternalAppHandler::isSMSAppAvailable()
526{ 534{
527#ifndef DESKTOP_VERSION 535#ifndef DESKTOP_VERSION
528 if (mSMSAppAvailable == UNDEFINED) 536 if (mSMSAppAvailable == UNDEFINED)
529 { 537 {
530 int client = KPimGlobalPrefs::instance()->mSMSClient; 538 int client = KPimGlobalPrefs::instance()->mSMSClient;
531 if (client == KPimGlobalPrefs::NONE_SMC) 539 if (client == KPimGlobalPrefs::NONE_SMC)
532 mSMSAppAvailable = UNAVAILABLE; 540 mSMSAppAvailable = UNAVAILABLE;
533 else 541 else
534 mSMSAppAvailable = AVAILABLE; 542 mSMSAppAvailable = AVAILABLE;
535 } 543 }
536 544
537 return (mSMSAppAvailable == AVAILABLE); 545 return (mSMSAppAvailable == AVAILABLE);
538#else //DESKTOP_VERSION 546#else //DESKTOP_VERSION
539 return false; 547 return false;
540#endif //DESKTOP_VERSION 548#endif //DESKTOP_VERSION
541} 549}
542 550
543bool ExternalAppHandler::isPhoneAppAvailable() 551bool ExternalAppHandler::isPhoneAppAvailable()
544{ 552{
545#ifndef DESKTOP_VERSION 553#ifndef DESKTOP_VERSION
546 if (mPhoneAppAvailable == UNDEFINED) 554 if (mPhoneAppAvailable == UNDEFINED)
547 { 555 {
548 int client = KPimGlobalPrefs::instance()->mPhoneClient; 556 int client = KPimGlobalPrefs::instance()->mPhoneClient;
549 if (client == KPimGlobalPrefs::NONE_PHC) 557 if (client == KPimGlobalPrefs::NONE_PHC)
550 mPhoneAppAvailable = UNAVAILABLE; 558 mPhoneAppAvailable = UNAVAILABLE;
551 else 559 else
552 mPhoneAppAvailable = AVAILABLE; 560 mPhoneAppAvailable = AVAILABLE;
553 } 561 }
554 562
555 return (mPhoneAppAvailable == AVAILABLE); 563 return (mPhoneAppAvailable == AVAILABLE);
556#else //DESKTOP_VERSION 564#else //DESKTOP_VERSION
557 return false; 565 return false;
558#endif //DESKTOP_VERSION 566#endif //DESKTOP_VERSION
559} 567}
560 568
561bool ExternalAppHandler::isFaxAppAvailable() 569bool ExternalAppHandler::isFaxAppAvailable()
562{ 570{
563#ifndef DESKTOP_VERSION 571#ifndef DESKTOP_VERSION
564 if (mFaxAppAvailable == UNDEFINED) 572 if (mFaxAppAvailable == UNDEFINED)
565 { 573 {
566 int client = KPimGlobalPrefs::instance()->mFaxClient; 574 int client = KPimGlobalPrefs::instance()->mFaxClient;
567 if (client == KPimGlobalPrefs::NONE_FAC) 575 if (client == KPimGlobalPrefs::NONE_FAC)
568 mFaxAppAvailable = UNAVAILABLE; 576 mFaxAppAvailable = UNAVAILABLE;
569 else 577 else
570 mFaxAppAvailable = AVAILABLE; 578 mFaxAppAvailable = AVAILABLE;
571 } 579 }
572 580
573 return (mFaxAppAvailable == AVAILABLE); 581 return (mFaxAppAvailable == AVAILABLE);
574#else //DESKTOP_VERSION 582#else //DESKTOP_VERSION
575 return false; 583 return false;
576#endif //DESKTOP_VERSION 584#endif //DESKTOP_VERSION
577} 585}
578 586
579bool ExternalAppHandler::isPagerAppAvailable() 587bool ExternalAppHandler::isPagerAppAvailable()
580{ 588{
581#ifndef DESKTOP_VERSION 589#ifndef DESKTOP_VERSION
582 if (mPagerAppAvailable == UNDEFINED) 590 if (mPagerAppAvailable == UNDEFINED)
583 { 591 {
584 int client = KPimGlobalPrefs::instance()->mPagerClient; 592 int client = KPimGlobalPrefs::instance()->mPagerClient;
585 if (client == KPimGlobalPrefs::NONE_PAC) 593 if (client == KPimGlobalPrefs::NONE_PAC)
586 mPagerAppAvailable = UNAVAILABLE; 594 mPagerAppAvailable = UNAVAILABLE;
587 else 595 else
588 mPagerAppAvailable = AVAILABLE; 596 mPagerAppAvailable = AVAILABLE;
589 } 597 }
590 598
591 return (mPagerAppAvailable == AVAILABLE); 599 return (mPagerAppAvailable == AVAILABLE);
592#else //DESKTOP_VERSION 600#else //DESKTOP_VERSION
593 return false; 601 return false;
594#endif //DESKTOP_VERSION 602#endif //DESKTOP_VERSION
595} 603}
596 604
597 605
598bool ExternalAppHandler::isSIPAppAvailable() 606bool ExternalAppHandler::isSIPAppAvailable()
599{ 607{
600#ifndef DESKTOP_VERSION 608#ifndef DESKTOP_VERSION
601 if (mSIPAppAvailable == UNDEFINED) 609 if (mSIPAppAvailable == UNDEFINED)
602 { 610 {
603 int client = KPimGlobalPrefs::instance()->mSipClient; 611 int client = KPimGlobalPrefs::instance()->mSipClient;
604 if (client == KPimGlobalPrefs::NONE_SIC) 612 if (client == KPimGlobalPrefs::NONE_SIC)
605 mSIPAppAvailable = UNAVAILABLE; 613 mSIPAppAvailable = UNAVAILABLE;
606 else 614 else
607 mSIPAppAvailable = AVAILABLE; 615 mSIPAppAvailable = AVAILABLE;
608 } 616 }
609 617
610 return (mSIPAppAvailable == AVAILABLE); 618 return (mSIPAppAvailable == AVAILABLE);
611#else //DESKTOP_VERSION 619#else //DESKTOP_VERSION
612 return false; 620 return false;
613#endif //DESKTOP_VERSION 621#endif //DESKTOP_VERSION
614} 622}
615 623
616/************************************************************************** 624/**************************************************************************
617 * 625 *
618 **************************************************************************/ 626 **************************************************************************/
619 627
620 628
621//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 629//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
622bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 630bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
623{ 631{
624 632
625#ifndef DESKTOP_VERSION 633#ifndef DESKTOP_VERSION
626 QString channel; 634 QString channel;
627 QString message2; 635 QString message2;
628 QString parameters2; 636 QString parameters2;
629 637
630 638
631 int client = KPimGlobalPrefs::instance()->mEmailClient; 639 int client = KPimGlobalPrefs::instance()->mEmailClient;
632 if (client == KPimGlobalPrefs::OTHER_EMC) 640 if (client == KPimGlobalPrefs::OTHER_EMC)
633 { 641 {
634 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 642 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
635 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 643 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
636 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 644 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
637 } 645 }
638 else 646 else
639 { 647 {
640 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 648 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
641 if (!dai) 649 if (!dai)
642 { 650 {
643 qDebug("could not find configured email application."); 651 qDebug("could not find configured email application.");
644 return false; 652 return false;
645 } 653 }
646 channel = dai->_channel; 654 channel = dai->_channel;
647 message2 = dai->_message2; 655 message2 = dai->_message2;
648 parameters2 = dai->_parameters2; 656 parameters2 = dai->_parameters2;
649 } 657 }
650 658
651 //first check if one of the mailers need the emails right in the message. 659 //first check if one of the mailers need the emails right in the message.
652 message2 = translateMessage(message2, emails, urls); 660 message2 = translateMessage(message2, emails, urls);
653 661
654 662
655#ifdef DEBUG_EXT_APP_HANDLER 663#ifdef DEBUG_EXT_APP_HANDLER
656 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 664 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
657 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 665 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
658#endif 666#endif
659 667
660 668
661 QCopEnvelope e(channel.latin1(), message2.latin1()); 669 QCopEnvelope e(channel.latin1(), message2.latin1());
662 //US we need no names in the To field. The emailadresses are enough 670 //US we need no names in the To field. The emailadresses are enough
663 671
664 passParameters(&e, parameters2, emails, urls); 672 passParameters(&e, parameters2, emails, urls);
665 673
666 674
667 675
668#else 676#else
669 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 677 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
670#endif 678#endif
671 679
672 return true; 680 return true;
673} 681}
674 682
675/************************************************************************** 683/**************************************************************************
676 * 684 *
677 **************************************************************************/ 685 **************************************************************************/
678 686
679 687
680//calls the emailapplication and creates a mail with parameter emails as recipients 688//calls the emailapplication and creates a mail with parameter emails as recipients
681bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 689bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
682{ 690{
683#ifndef DESKTOP_VERSION 691#ifndef DESKTOP_VERSION
684 QString channel; 692 QString channel;
685 QString message; 693 QString message;
686 QString parameters; 694 QString parameters;
687 695
688 696
689 int client = KPimGlobalPrefs::instance()->mEmailClient; 697 int client = KPimGlobalPrefs::instance()->mEmailClient;
690 if (client == KPimGlobalPrefs::OTHER_EMC) 698 if (client == KPimGlobalPrefs::OTHER_EMC)
691 { 699 {
692 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 700 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
693 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 701 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
694 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 702 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
695 } 703 }
696 else 704 else
697 { 705 {
698 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 706 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
699 if (!dai) 707 if (!dai)
700 { 708 {
701 qDebug("could not find configured email application."); 709 qDebug("could not find configured email application.");
702 return false; 710 return false;
703 } 711 }
704 channel = dai->_channel; 712 channel = dai->_channel;
705 message = dai->_message; 713 message = dai->_message;
706 parameters = dai->_parameters; 714 parameters = dai->_parameters;
707 } 715 }
708 716
709 717
710 //first check if one of the mailers need the emails right in the message. 718 //first check if one of the mailers need the emails right in the message.
711 message = translateMessage(message, name, emailadress); 719 message = translateMessage(message, name, emailadress);
712 720
713 721
714#ifdef DEBUG_EXT_APP_HANDLER 722#ifdef DEBUG_EXT_APP_HANDLER
715 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 723 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
716 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); 724 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
717#endif 725#endif
718 726
719 QCopEnvelope e(channel.latin1(), message.latin1()); 727 QCopEnvelope e(channel.latin1(), message.latin1());
720 //US we need no names in the To field. The emailadresses are enough 728 //US we need no names in the To field. The emailadresses are enough
721 729
722 passParameters(&e, parameters, name, emailadress); 730 passParameters(&e, parameters, name, emailadress);
723 731
724 732
725#else 733#else
726 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 734 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
727#endif 735#endif
728 736
729 737
730 return true; 738 return true;
731} 739}
732 740
733/************************************************************************** 741/**************************************************************************
734 * 742 *
735 **************************************************************************/ 743 **************************************************************************/
736 744
737//calls the emailapplication and creates a mail with parameter as recipients 745//calls the emailapplication and creates a mail with parameter as recipients
738// parameters format is 746// parameters format is
739// NAME <EMAIL>:SUBJECT 747// NAME <EMAIL>:SUBJECT
740bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 748bool ExternalAppHandler::mailToOneContact( const QString& adressline )
741{ 749{
742 QString line = adressline; 750 QString line = adressline;
743 751
744 int first = line.find( "<"); 752 int first = line.find( "<");
745 int last = line.find( ">"); 753 int last = line.find( ">");
746 QString name = line.left(first); 754 QString name = line.left(first);
747 QString emailadress = line.mid(first+1, last-first-1); 755 QString emailadress = line.mid(first+1, last-first-1);
748 756
749 //Subject can not be handled right now. 757 //Subject can not be handled right now.
750 return mailToOneContact( name, emailadress ); 758 return mailToOneContact( name, emailadress );
751 759
752} 760}
753 761
754 762
755/************************************************************************** 763/**************************************************************************
756 * 764 *
757 **************************************************************************/ 765 **************************************************************************/
758 766
759//calls the phoneapplication with the number 767//calls the phoneapplication with the number
760bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 768bool ExternalAppHandler::callByPhone( const QString& phonenumber )
761{ 769{
762#ifndef DESKTOP_VERSION 770#ifndef DESKTOP_VERSION
763 QString channel; 771 QString channel;
764 QString message; 772 QString message;
765 QString parameters; 773 QString parameters;
766 774
767 775
768 int client = KPimGlobalPrefs::instance()->mPhoneClient; 776 int client = KPimGlobalPrefs::instance()->mPhoneClient;
769 if (client == KPimGlobalPrefs::OTHER_PHC) 777 if (client == KPimGlobalPrefs::OTHER_PHC)
770 { 778 {
771 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 779 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
772 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 780 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
773 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 781 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
774 } 782 }
775 else 783 else
776 { 784 {
777 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 785 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
778 if (!dai) 786 if (!dai)
779 { 787 {
780 qDebug("could not find configured phone application."); 788 qDebug("could not find configured phone application.");
781 return false; 789 return false;
782 } 790 }
783 channel = dai->_channel; 791 channel = dai->_channel;
784 message = dai->_message; 792 message = dai->_message;
785 parameters = dai->_parameters; 793 parameters = dai->_parameters;
786 } 794 }
787 795
788 796
789 //first check if one of the mailers need the emails right in the message. 797 //first check if one of the mailers need the emails right in the message.
790 message = translateMessage(message, phonenumber, ""); 798 message = translateMessage(message, phonenumber, "");
791 799
792 800
793#ifdef DEBUG_EXT_APP_HANDLER 801#ifdef DEBUG_EXT_APP_HANDLER
794 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 802 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
795 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 803 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
796#endif 804#endif
797 805
798 QCopEnvelope e(channel.latin1(), message.latin1()); 806 QCopEnvelope e(channel.latin1(), message.latin1());
799 //US we need no names in the To field. The emailadresses are enough 807 //US we need no names in the To field. The emailadresses are enough
800 808
801 passParameters(&e, parameters, phonenumber, ""); 809 passParameters(&e, parameters, phonenumber, "");
802 810
803 811
804#else 812#else
805 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 813 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
806#endif 814#endif
807 815
808 816
809 return true; 817 return true;
810} 818}
811 819
812/************************************************************************** 820/**************************************************************************
813 * 821 *
814 **************************************************************************/ 822 **************************************************************************/
815 823
816//calls the smsapplication with the number 824//calls the smsapplication with the number
817bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 825bool ExternalAppHandler::callBySMS( const QString& phonenumber )
818{ 826{
819#ifndef DESKTOP_VERSION 827#ifndef DESKTOP_VERSION
820 QString channel; 828 QString channel;
821 QString message; 829 QString message;
822 QString parameters; 830 QString parameters;
823 831
824 832
825 int client = KPimGlobalPrefs::instance()->mSMSClient; 833 int client = KPimGlobalPrefs::instance()->mSMSClient;
826 if (client == KPimGlobalPrefs::OTHER_SMC) 834 if (client == KPimGlobalPrefs::OTHER_SMC)
827 { 835 {
828 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 836 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
829 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 837 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
830 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 838 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
831 } 839 }
832 else 840 else
833 { 841 {
834 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 842 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
835 if (!dai) 843 if (!dai)
836 { 844 {
837 qDebug("could not find configured sms application."); 845 qDebug("could not find configured sms application.");
838 return false; 846 return false;
839 } 847 }
840 channel = dai->_channel; 848 channel = dai->_channel;
841 message = dai->_message; 849 message = dai->_message;
842 parameters = dai->_parameters; 850 parameters = dai->_parameters;
843 } 851 }
844 852
845 853
846 //first check if one of the mailers need the emails right in the message. 854 //first check if one of the mailers need the emails right in the message.
847 message = translateMessage(message, phonenumber, ""); 855 message = translateMessage(message, phonenumber, "");
848 856
849 857
850#ifdef DEBUG_EXT_APP_HANDLER 858#ifdef DEBUG_EXT_APP_HANDLER
851 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 859 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
852 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 860 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
853#endif 861#endif
854 862
855 QCopEnvelope e(channel.latin1(), message.latin1()); 863 QCopEnvelope e(channel.latin1(), message.latin1());
856 //US we need no names in the To field. The emailadresses are enough 864 //US we need no names in the To field. The emailadresses are enough
857 865
858 passParameters(&e, parameters, phonenumber, ""); 866 passParameters(&e, parameters, phonenumber, "");
859 867
860 868
861#else 869#else
862 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); 870 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) );
863#endif 871#endif
864 872
865 873
866 return true; 874 return true;
867} 875}
868 876
869/************************************************************************** 877/**************************************************************************
870 * 878 *
871 **************************************************************************/ 879 **************************************************************************/
872 880
873//calls the pagerapplication with the number 881//calls the pagerapplication with the number
874bool ExternalAppHandler::callByPager( const QString& pagernumber ) 882bool ExternalAppHandler::callByPager( const QString& pagernumber )
875{ 883{
876#ifndef DESKTOP_VERSION 884#ifndef DESKTOP_VERSION
877 QString channel; 885 QString channel;
878 QString message; 886 QString message;
879 QString parameters; 887 QString parameters;
880 888
881 889
882 int client = KPimGlobalPrefs::instance()->mPagerClient; 890 int client = KPimGlobalPrefs::instance()->mPagerClient;
883 if (client == KPimGlobalPrefs::OTHER_PAC) 891 if (client == KPimGlobalPrefs::OTHER_PAC)
884 { 892 {
885 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 893 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
886 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 894 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
887 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 895 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
888 } 896 }
889 else 897 else
890 { 898 {
891 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 899 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
892 if (!dai) 900 if (!dai)
893 { 901 {
894 qDebug("could not find configured pager application."); 902 qDebug("could not find configured pager application.");
895 return false; 903 return false;
896 } 904 }
897 channel = dai->_channel; 905 channel = dai->_channel;
898 message = dai->_message; 906 message = dai->_message;
899 parameters = dai->_parameters; 907 parameters = dai->_parameters;
900 } 908 }
901 909
902 910
903 //first check if one of the mailers need the emails right in the message. 911 //first check if one of the mailers need the emails right in the message.
904 message = translateMessage(message, pagernumber, ""); 912 message = translateMessage(message, pagernumber, "");
905 913
906 914
907#ifdef DEBUG_EXT_APP_HANDLER 915#ifdef DEBUG_EXT_APP_HANDLER
908 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 916 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
909 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 917 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
910#endif 918#endif
911 919
912 QCopEnvelope e(channel.latin1(), message.latin1()); 920 QCopEnvelope e(channel.latin1(), message.latin1());
913 //US we need no names in the To field. The emailadresses are enough 921 //US we need no names in the To field. The emailadresses are enough
914 922
915 passParameters(&e, parameters, pagernumber, ""); 923 passParameters(&e, parameters, pagernumber, "");
916 924
917 925
918#else 926#else
919 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 927 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
920#endif 928#endif
921 929
922 930
923 return true; 931 return true;
924} 932}
925 933
926/************************************************************************** 934/**************************************************************************
927 * 935 *
928 **************************************************************************/ 936 **************************************************************************/
929 937
930//calls the faxapplication with the number 938//calls the faxapplication with the number
931bool ExternalAppHandler::callByFax( const QString& faxnumber ) 939bool ExternalAppHandler::callByFax( const QString& faxnumber )
932{ 940{
933#ifndef DESKTOP_VERSION 941#ifndef DESKTOP_VERSION
934 QString channel; 942 QString channel;
935 QString message; 943 QString message;
936 QString parameters; 944 QString parameters;
937 945
938 946
939 int client = KPimGlobalPrefs::instance()->mFaxClient; 947 int client = KPimGlobalPrefs::instance()->mFaxClient;
940 if (client == KPimGlobalPrefs::OTHER_FAC) 948 if (client == KPimGlobalPrefs::OTHER_FAC)
941 { 949 {
942 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 950 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
943 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 951 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
944 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 952 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
945 } 953 }
946 else 954 else
947 { 955 {
948 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 956 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
949 if (!dai) 957 if (!dai)
950 { 958 {
951 qDebug("could not find configured fax application."); 959 qDebug("could not find configured fax application.");
952 return false; 960 return false;
953 } 961 }
954 channel = dai->_channel; 962 channel = dai->_channel;
955 message = dai->_message; 963 message = dai->_message;
956 parameters = dai->_parameters; 964 parameters = dai->_parameters;
957 } 965 }
958 966
959 967
960 //first check if one of the mailers need the emails right in the message. 968 //first check if one of the mailers need the emails right in the message.
961 message = translateMessage(message, faxnumber, ""); 969 message = translateMessage(message, faxnumber, "");
962 970
963 971
964#ifdef DEBUG_EXT_APP_HANDLER 972#ifdef DEBUG_EXT_APP_HANDLER
965 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 973 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
966 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 974 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
967#endif 975#endif
968 976
969 QCopEnvelope e(channel.latin1(), message.latin1()); 977 QCopEnvelope e(channel.latin1(), message.latin1());
970 //US we need no names in the To field. The emailadresses are enough 978 //US we need no names in the To field. The emailadresses are enough
971 979
972 passParameters(&e, parameters, faxnumber, ""); 980 passParameters(&e, parameters, faxnumber, "");
973 981
974 982
975#else 983#else
976 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 984 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
977#endif 985#endif
978 986
979 987
980 return true; 988 return true;
981} 989}
982 990
983/************************************************************************** 991/**************************************************************************
984 * 992 *
985 **************************************************************************/ 993 **************************************************************************/
986 994
987//calls the sipapplication with the number 995//calls the sipapplication with the number
988bool ExternalAppHandler::callBySIP( const QString& sipnumber ) 996bool ExternalAppHandler::callBySIP( const QString& sipnumber )
989{ 997{
990#ifndef DESKTOP_VERSION 998#ifndef DESKTOP_VERSION
991 QString channel; 999 QString channel;
992 QString message; 1000 QString message;
993 QString parameters; 1001 QString parameters;
994 1002
995 1003
996 int client = KPimGlobalPrefs::instance()->mSipClient; 1004 int client = KPimGlobalPrefs::instance()->mSipClient;
997 if (client == KPimGlobalPrefs::OTHER_SIC) 1005 if (client == KPimGlobalPrefs::OTHER_SIC)
998 { 1006 {
999 channel = KPimGlobalPrefs::instance()->mSipOtherChannel; 1007 channel = KPimGlobalPrefs::instance()->mSipOtherChannel;
1000 message = KPimGlobalPrefs::instance()->mSipOtherMessage; 1008 message = KPimGlobalPrefs::instance()->mSipOtherMessage;
1001 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; 1009 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters;
1002 } 1010 }
1003 else 1011 else
1004 { 1012 {
1005 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); 1013 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client);
1006 if (!dai) 1014 if (!dai)
1007 { 1015 {
1008 qDebug("could not find configured sip application."); 1016 qDebug("could not find configured sip application.");
1009 return false; 1017 return false;
1010 } 1018 }
1011 channel = dai->_channel; 1019 channel = dai->_channel;
1012 message = dai->_message; 1020 message = dai->_message;
1013 parameters = dai->_parameters; 1021 parameters = dai->_parameters;
1014 } 1022 }
1015 1023
1016 1024
1017 //first check if one of the sip apps need the emails right in the message. 1025 //first check if one of the sip apps need the emails right in the message.
1018 message = translateMessage(message, sipnumber, ""); 1026 message = translateMessage(message, sipnumber, "");
1019 1027
1020 1028
1021#ifdef DEBUG_EXT_APP_HANDLER 1029#ifdef DEBUG_EXT_APP_HANDLER
1022 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1030 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1023 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); 1031 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1());
1024#endif 1032#endif
1025 1033
1026 QCopEnvelope e(channel.latin1(), message.latin1()); 1034 QCopEnvelope e(channel.latin1(), message.latin1());
1027 //US we need no names in the To field. The emailadresses are enough 1035 //US we need no names in the To field. The emailadresses are enough
1028 1036
1029 passParameters(&e, parameters, sipnumber, ""); 1037 passParameters(&e, parameters, sipnumber, "");
1030 1038
1031 1039
1032#else 1040#else
1033 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); 1041 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) );
1034#endif 1042#endif
1035 1043
1036 1044
1037 return true; 1045 return true;
1038} 1046}
1039 1047
1040 1048
1041/************************************************************************** 1049/**************************************************************************
1042 * 1050 *
1043 **************************************************************************/ 1051 **************************************************************************/
1044 1052
1045 1053
1046QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 1054QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
1047{ 1055{
1048 message = message.replace( QRegExp("%1"), param1 ); 1056 message = message.replace( QRegExp("%1"), param1 );
1049 return message.replace( QRegExp("%2"), param2 ); 1057 return message.replace( QRegExp("%2"), param2 );
1050} 1058}
1051 1059
1052/************************************************************************** 1060/**************************************************************************
1053 * 1061 *
1054 **************************************************************************/ 1062 **************************************************************************/
1055 1063
1056void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const 1064void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
1057{ 1065{
1058#ifndef DESKTOP_VERSION 1066#ifndef DESKTOP_VERSION
1059 QMap<QString, QString> valmap; 1067 QMap<QString, QString> valmap;
1060 bool useValMap = false; 1068 bool useValMap = false;
1061 1069
1062 // first extract all parts of the parameters. 1070 // first extract all parts of the parameters.
1063 QStringList paramlist = QStringList::split(";", parameters); 1071 QStringList paramlist = QStringList::split(";", parameters);
1064 1072
1065 //Now check how many parts we have. 1073 //Now check how many parts we have.
1066 //=0 :no params to pass 1074 //=0 :no params to pass
1067 //>0 :parameters to pass 1075 //>0 :parameters to pass
1068 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 1076 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
1069 { 1077 {
1070 QString param = (*it); 1078 QString param = (*it);
1071 QStringList keyvallist = QStringList::split("=", param); 1079 QStringList keyvallist = QStringList::split("=", param);
1072 1080
1073 //if we have keyvalue pairs, we assume that we pass a map to the envelope 1081 //if we have keyvalue pairs, we assume that we pass a map to the envelope
1074 QStringList::Iterator it2 = keyvallist.begin(); 1082 QStringList::Iterator it2 = keyvallist.begin();
1075 QString key = (*it2); 1083 QString key = (*it2);
1076 key = key.replace( QRegExp("%1"), param1 ); 1084 key = key.replace( QRegExp("%1"), param1 );
1077 key = key.replace( QRegExp("%2"), param2 ); 1085 key = key.replace( QRegExp("%2"), param2 );
1078 ++it2; 1086 ++it2;
1079 1087
1080 if(it2 != keyvallist.end()) 1088 if(it2 != keyvallist.end())
1081 { 1089 {
1082 QString value = (*it2); 1090 QString value = (*it2);
1083 value = value.replace( QRegExp("%1"), param1 ); 1091 value = value.replace( QRegExp("%1"), param1 );
1084 value = value.replace( QRegExp("%2"), param2 ); 1092 value = value.replace( QRegExp("%2"), param2 );
1085 1093
1086 valmap.insert(key, value); 1094 valmap.insert(key, value);
1087 useValMap = true; 1095 useValMap = true;
1088 } 1096 }
1089 else 1097 else
1090 { 1098 {
1091 // qDebug("pass parameter << %s", key.latin1()); 1099 // qDebug("pass parameter << %s", key.latin1());
1092 (*e) << key; 1100 (*e) << key;
1093 } 1101 }
1094 } 1102 }
1095 1103
1096 if (useValMap == true) 1104 if (useValMap == true)
1097 (*e) << valmap; 1105 (*e) << valmap;
1098 1106
1099#endif 1107#endif
1100 1108
1101} 1109}
1102 1110
1103 1111
1104 1112
1105/************************************************************************** 1113/**************************************************************************
1106 * 1114 *
1107 **************************************************************************/ 1115 **************************************************************************/
1108 1116
1109void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) 1117void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data )
1110{ 1118{
1111 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1119 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1112 if (!res) 1120 if (!res)
1113 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); 1121 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data );
1114 1122
1115 if (!res) 1123 if (!res)
1116 res = mDisplayDetails->appMessage( cmsg, data ); 1124 res = mDisplayDetails->appMessage( cmsg, data );
1117 1125
1118// if (!res) 1126// if (!res)
1119// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1127// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1120} 1128}
1121 1129
1122 1130
1123 1131
1124bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1132bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1125{ 1133{
1126 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1134 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1127 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); 1135 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid);
1128} 1136}
1129 1137
1130bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1138bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1131{ 1139{
1132 QStringList list4, list5, list6; 1140 QStringList list4, list5, list6;
1133 1141
1134 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1142 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1135 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1143 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1136} 1144}
1137 1145
1138bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) 1146bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email)
1139{ 1147{
1140 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1148 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1141 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); 1149 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email);
1142} 1150}
1143 1151
1144bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1152bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1145{ 1153{
1146 QStringList list4, list5, list6; 1154 QStringList list4, list5, list6;
1147 1155
1148 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1156 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1149 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1157 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1150} 1158}
1151 1159
1152bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) 1160bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid)
1153{ 1161{
1154 mDisplayDetails->setSourceChannel(""); 1162 mDisplayDetails->setSourceChannel("");
1155 return mDisplayDetails->sendMessageToTarget("", name, email, uid); 1163 return mDisplayDetails->sendMessageToTarget("", name, email, uid);
1156} 1164}
1157 1165
1158bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1166bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1159{ 1167{
1160 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1168 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1161 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); 1169 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid);
1162} 1170}
1163 1171
1164bool 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) 1172bool 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)
1165{ 1173{
1166 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1174 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1167 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1175 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1168} 1176}
1169 1177
1170 1178
1171 1179
1172 1180
1173 1181