summaryrefslogtreecommitdiffabout
path: root/libkdepim/externalapphandler.cpp
Unidiff
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 9085673..9f12152 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -1,1181 +1,1187 @@
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() 260QCopListTransferItem::~QCopListTransferItem()
261{ 261{
262 262
263} 263}
264 264
265QCopListTransferItem::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)
266 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 266 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
267{ 267{
268 //targetMessage returns later two parameters: uid, and three lists 268 //targetMessage returns later two parameters: uid, and three lists
269 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; 269 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)";
270} 270}
271 271
272/*********************************************************************************/ 272/*********************************************************************************/
273bool 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)
274{ 274{
275#ifndef DESKTOP_VERSION 275#ifndef DESKTOP_VERSION
276 //targetMessage passes two parameters: uid, map 276 //targetMessage passes two parameters: uid, map
277 QString targetMessage = _targetMessage + _targetMessageParameters; 277 QString targetMessage = _targetMessage + _targetMessageParameters;
278 278
279#ifdef DEBUG_EXT_APP_HANDLER 279#ifdef DEBUG_EXT_APP_HANDLER
280 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 280 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
281 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());
282 282
283 283
284 for ( int i = 0; i < list3.count(); i++) 284 for ( int i = 0; i < list3.count(); i++)
285 qDebug("listentry list3: %s",list3[i].latin1()); 285 qDebug("listentry list3: %s",list3[i].latin1());
286#endif 286#endif
287 287
288 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 288 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
289 //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
290 290
291 e << uid << list1 << list2 << list3 << list4 << list5 << list6; 291 e << uid << list1 << list2 << list3 << list4 << list5 << list6;
292 292
293 qApp->processEvents(); 293 qApp->processEvents();
294 294
295 return true; 295 return true;
296 296
297#else 297#else
298 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 298 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
299 return false; 299 return false;
300#endif 300#endif
301 301
302} 302}
303 303
304 304
305/*********************************************************************************/ 305/*********************************************************************************/
306bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 306bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
307{ 307{
308 bool res = QCopTransferItem::appMessage( cmsg, data ); 308 bool res = QCopTransferItem::appMessage( cmsg, data );
309#ifdef DEBUG_EXT_APP_HANDLER 309#ifdef DEBUG_EXT_APP_HANDLER
310 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 310 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
311#endif 311#endif
312 312
313 if (res == false) 313 if (res == false)
314 { 314 {
315 QDataStream stream( data, IO_ReadOnly ); 315 QDataStream stream( data, IO_ReadOnly );
316 316
317#ifdef DEBUG_EXT_APP_HANDLER 317#ifdef DEBUG_EXT_APP_HANDLER
318 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 318 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
319#endif 319#endif
320 320
321 //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
322 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 322 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
323 { 323 {
324 QStringList list1; 324 QStringList list1;
325 QStringList list2; 325 QStringList list2;
326 QStringList list3; 326 QStringList list3;
327 QStringList list4; 327 QStringList list4;
328 QStringList list5; 328 QStringList list5;
329 QStringList list6; 329 QStringList list6;
330 QString uid; 330 QString uid;
331 331
332#ifdef DEBUG_EXT_APP_HANDLER 332#ifdef DEBUG_EXT_APP_HANDLER
333 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 333 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
334#endif 334#endif
335 335
336 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; 336 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6;
337 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); 337 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6);
338 338
339 339
340 return true; 340 return true;
341 } 341 }
342 } 342 }
343 343
344 return false; 344 return false;
345} 345}
346 346
347 347
348 348
349/********************************************************************************* 349/*********************************************************************************
350 * 350 *
351 ********************************************************************************/ 351 ********************************************************************************/
352 352
353 353
354ExternalAppHandler *ExternalAppHandler::sInstance = 0; 354ExternalAppHandler *ExternalAppHandler::sInstance = 0;
355static KStaticDeleter<ExternalAppHandler> staticDeleter; 355static KStaticDeleter<ExternalAppHandler> staticDeleter;
356 356
357ExternalAppHandler::ExternalAppHandler() 357ExternalAppHandler::ExternalAppHandler()
358{ 358{
359 mDefaultItems.setAutoDelete(true); 359 mDefaultItems.setAutoDelete(true);
360 360
361 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); 361 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
362 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&)));
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&))); 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&)));
364 364
365//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); 365//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
366//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&)));
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&))); 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&)));
368 368
369 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); 369 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
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&))); 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&)));
371 371
372 372
373 373
374 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); 374 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList");
375 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&)));
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&))); 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&)));
377 377
378 378
379} 379}
380 380
381ExternalAppHandler::~ExternalAppHandler() 381ExternalAppHandler::~ExternalAppHandler()
382{ 382{
383 delete mNameEmailUidListFromKAPITransfer; 383 delete mNameEmailUidListFromKAPITransfer;
384 //delete mFindByEmailFromKAPITransfer; 384 //delete mFindByEmailFromKAPITransfer;
385 delete mDisplayDetails; 385 delete mDisplayDetails;
386 delete mBirthdayListFromKAPITransfer; 386 delete mBirthdayListFromKAPITransfer;
387} 387}
388 388
389void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, 389void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid,
390 const QStringList& nameList, 390 const QStringList& nameList,
391 const QStringList& emailList, 391 const QStringList& emailList,
392 const QStringList& uidList, 392 const QStringList& uidList,
393 const QStringList&, 393 const QStringList&,
394 const QStringList&, 394 const QStringList&,
395 const QStringList& ) 395 const QStringList& )
396{ 396{
397 // 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
398 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); 398 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList);
399} 399}
400 400
401 401
402void ExternalAppHandler::loadConfig() 402void ExternalAppHandler::loadConfig()
403{ 403{
404 404
405 mDefaultItems.clear(); 405 mDefaultItems.clear();
406 mEmailAppAvailable = UNDEFINED; 406 mEmailAppAvailable = UNDEFINED;
407 mPhoneAppAvailable = UNDEFINED; 407 mPhoneAppAvailable = UNDEFINED;
408 mFaxAppAvailable = UNDEFINED; 408 mFaxAppAvailable = UNDEFINED;
409 mSMSAppAvailable = UNDEFINED; 409 mSMSAppAvailable = UNDEFINED;
410 mPagerAppAvailable = UNDEFINED; 410 mPagerAppAvailable = UNDEFINED;
411 mSIPAppAvailable = UNDEFINED; 411 mSIPAppAvailable = UNDEFINED;
412 412
413 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 413 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
414 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 414 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
415 415
416 if (opiepath.isEmpty()) 416 if (opiepath.isEmpty())
417 opiepath = qtopiapath; 417 opiepath = qtopiapath;
418 418
419 //mailclients 419 //mailclients
420 QString mailmsg1 = "writeMail(QString,QString)"; 420 QString mailmsg1 = "writeMail(QString,QString)";
421 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 421 QString mailmsg2 = "writeMail(QMap(QString,QString))";
422 422
423 QString undefined = ""; 423 QString undefined = "";
424 424
425 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);
426 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);
427 427
428 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 428 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
429 ( QFile::exists( opiepath + "/bin/ompi" ))) 429 ( QFile::exists( opiepath + "/bin/ompi" )))
430 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");
431 431
432 if ( QFile::exists( qtopiapath + "/bin/qtmail" )) 432 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
433 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");
434 434
435 if ( QFile::exists( opiepath + "/bin/opiemail" )) 435 if ( QFile::exists( opiepath + "/bin/opiemail" ))
436 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");
437 437
438 438
439 439
440 //phoneclients 440 //phoneclients
441 441
442 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);
443 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);
444 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 444 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
445 ( QFile::exists( opiepath + "/bin/kppi" ))) 445 ( QFile::exists( opiepath + "/bin/kppi" )))
446 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);
447 447
448 //faxclients 448 //faxclients
449 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);
450 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);
451 451
452 //smsclients 452 //smsclients
453 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);
454 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);
455 455
456 //pagerclients 456 //pagerclients
457 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);
458 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);
459 459
460 //sipclients 460 //sipclients
461 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);
462 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);
463 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 463 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
464 ( QFile::exists( opiepath + "/bin/kppi" ))) 464 ( QFile::exists( opiepath + "/bin/kppi" )))
465 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);
466 466
467} 467}
468 468
469ExternalAppHandler *ExternalAppHandler::instance() 469ExternalAppHandler *ExternalAppHandler::instance()
470{ 470{
471 if ( !sInstance ) { 471 if ( !sInstance ) {
472 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 472 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
473 sInstance->loadConfig(); 473 sInstance->loadConfig();
474 } 474 }
475 475
476 return sInstance; 476 return sInstance;
477} 477}
478 478
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) 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)
480{ 480{
481 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);
482 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); 482 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
483 mDefaultItems.append(dai); 483 mDefaultItems.append(dai);
484} 484}
485 485
486 486
487QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 487QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
488{ 488{
489 QList<DefaultAppItem> list; 489 QList<DefaultAppItem> list;
490 490
491 DefaultAppItem* dai; 491 DefaultAppItem* dai;
492 492
493 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 493 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
494 { 494 {
495 if (dai->_type == type) 495 if (dai->_type == type)
496 list.append(dai); 496 list.append(dai);
497 } 497 }
498 498
499 return list; 499 return list;
500} 500}
501 501
502DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 502DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
503{ 503{
504 DefaultAppItem* dai; 504 DefaultAppItem* dai;
505 505
506 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 506 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
507 { 507 {
508 if (dai->_type == type && dai->_id == clientid) 508 if (dai->_type == type && dai->_id == clientid)
509 return dai; 509 return dai;
510 } 510 }
511 511
512 return 0; 512 return 0;
513} 513}
514 514
515bool ExternalAppHandler::isEmailAppAvailable() 515bool ExternalAppHandler::isEmailAppAvailable()
516{ 516{
517#ifndef DESKTOP_VERSION 517#ifndef DESKTOP_VERSION
518 if (mEmailAppAvailable == UNDEFINED) 518 if (mEmailAppAvailable == UNDEFINED)
519 { 519 {
520 int client = KPimGlobalPrefs::instance()->mEmailClient; 520 int client = KPimGlobalPrefs::instance()->mEmailClient;
521 if (client == KPimGlobalPrefs::NONE_EMC) 521 if (client == KPimGlobalPrefs::NONE_EMC)
522 mEmailAppAvailable = UNAVAILABLE; 522 mEmailAppAvailable = UNAVAILABLE;
523 else 523 else
524 mEmailAppAvailable = AVAILABLE; 524 mEmailAppAvailable = AVAILABLE;
525 } 525 }
526 return (mEmailAppAvailable == AVAILABLE); 526 return (mEmailAppAvailable == AVAILABLE);
527 527
528#else //DESKTOP_VERSION 528#else //DESKTOP_VERSION
529 return false; 529 return false;
530#endif //DESKTOP_VERSION 530#endif //DESKTOP_VERSION
531} 531}
532 532
533bool ExternalAppHandler::isSMSAppAvailable() 533bool ExternalAppHandler::isSMSAppAvailable()
534{ 534{
535#ifndef DESKTOP_VERSION 535#ifndef DESKTOP_VERSION
536 if (mSMSAppAvailable == UNDEFINED) 536 if (mSMSAppAvailable == UNDEFINED)
537 { 537 {
538 int client = KPimGlobalPrefs::instance()->mSMSClient; 538 int client = KPimGlobalPrefs::instance()->mSMSClient;
539 if (client == KPimGlobalPrefs::NONE_SMC) 539 if (client == KPimGlobalPrefs::NONE_SMC)
540 mSMSAppAvailable = UNAVAILABLE; 540 mSMSAppAvailable = UNAVAILABLE;
541 else 541 else
542 mSMSAppAvailable = AVAILABLE; 542 mSMSAppAvailable = AVAILABLE;
543 } 543 }
544 544
545 return (mSMSAppAvailable == AVAILABLE); 545 return (mSMSAppAvailable == AVAILABLE);
546#else //DESKTOP_VERSION 546#else //DESKTOP_VERSION
547 return false; 547 return false;
548#endif //DESKTOP_VERSION 548#endif //DESKTOP_VERSION
549} 549}
550 550
551bool ExternalAppHandler::isPhoneAppAvailable() 551bool ExternalAppHandler::isPhoneAppAvailable()
552{ 552{
553#ifndef DESKTOP_VERSION 553#ifndef DESKTOP_VERSION
554 if (mPhoneAppAvailable == UNDEFINED) 554 if (mPhoneAppAvailable == UNDEFINED)
555 { 555 {
556 int client = KPimGlobalPrefs::instance()->mPhoneClient; 556 int client = KPimGlobalPrefs::instance()->mPhoneClient;
557 if (client == KPimGlobalPrefs::NONE_PHC) 557 if (client == KPimGlobalPrefs::NONE_PHC)
558 mPhoneAppAvailable = UNAVAILABLE; 558 mPhoneAppAvailable = UNAVAILABLE;
559 else 559 else
560 mPhoneAppAvailable = AVAILABLE; 560 mPhoneAppAvailable = AVAILABLE;
561 } 561 }
562 562
563 return (mPhoneAppAvailable == AVAILABLE); 563 return (mPhoneAppAvailable == AVAILABLE);
564#else //DESKTOP_VERSION 564#else //DESKTOP_VERSION
565 return false; 565 return false;
566#endif //DESKTOP_VERSION 566#endif //DESKTOP_VERSION
567} 567}
568 568
569bool ExternalAppHandler::isFaxAppAvailable() 569bool ExternalAppHandler::isFaxAppAvailable()
570{ 570{
571#ifndef DESKTOP_VERSION 571#ifndef DESKTOP_VERSION
572 if (mFaxAppAvailable == UNDEFINED) 572 if (mFaxAppAvailable == UNDEFINED)
573 { 573 {
574 int client = KPimGlobalPrefs::instance()->mFaxClient; 574 int client = KPimGlobalPrefs::instance()->mFaxClient;
575 if (client == KPimGlobalPrefs::NONE_FAC) 575 if (client == KPimGlobalPrefs::NONE_FAC)
576 mFaxAppAvailable = UNAVAILABLE; 576 mFaxAppAvailable = UNAVAILABLE;
577 else 577 else
578 mFaxAppAvailable = AVAILABLE; 578 mFaxAppAvailable = AVAILABLE;
579 } 579 }
580 580
581 return (mFaxAppAvailable == AVAILABLE); 581 return (mFaxAppAvailable == AVAILABLE);
582#else //DESKTOP_VERSION 582#else //DESKTOP_VERSION
583 return false; 583 return false;
584#endif //DESKTOP_VERSION 584#endif //DESKTOP_VERSION
585} 585}
586 586
587bool ExternalAppHandler::isPagerAppAvailable() 587bool ExternalAppHandler::isPagerAppAvailable()
588{ 588{
589#ifndef DESKTOP_VERSION 589#ifndef DESKTOP_VERSION
590 if (mPagerAppAvailable == UNDEFINED) 590 if (mPagerAppAvailable == UNDEFINED)
591 { 591 {
592 int client = KPimGlobalPrefs::instance()->mPagerClient; 592 int client = KPimGlobalPrefs::instance()->mPagerClient;
593 if (client == KPimGlobalPrefs::NONE_PAC) 593 if (client == KPimGlobalPrefs::NONE_PAC)
594 mPagerAppAvailable = UNAVAILABLE; 594 mPagerAppAvailable = UNAVAILABLE;
595 else 595 else
596 mPagerAppAvailable = AVAILABLE; 596 mPagerAppAvailable = AVAILABLE;
597 } 597 }
598 598
599 return (mPagerAppAvailable == AVAILABLE); 599 return (mPagerAppAvailable == AVAILABLE);
600#else //DESKTOP_VERSION 600#else //DESKTOP_VERSION
601 return false; 601 return false;
602#endif //DESKTOP_VERSION 602#endif //DESKTOP_VERSION
603} 603}
604 604
605 605
606bool ExternalAppHandler::isSIPAppAvailable() 606bool ExternalAppHandler::isSIPAppAvailable()
607{ 607{
608#ifndef DESKTOP_VERSION 608#ifndef DESKTOP_VERSION
609 if (mSIPAppAvailable == UNDEFINED) 609 if (mSIPAppAvailable == UNDEFINED)
610 { 610 {
611 int client = KPimGlobalPrefs::instance()->mSipClient; 611 int client = KPimGlobalPrefs::instance()->mSipClient;
612 if (client == KPimGlobalPrefs::NONE_SIC) 612 if (client == KPimGlobalPrefs::NONE_SIC)
613 mSIPAppAvailable = UNAVAILABLE; 613 mSIPAppAvailable = UNAVAILABLE;
614 else 614 else
615 mSIPAppAvailable = AVAILABLE; 615 mSIPAppAvailable = AVAILABLE;
616 } 616 }
617 617
618 return (mSIPAppAvailable == AVAILABLE); 618 return (mSIPAppAvailable == AVAILABLE);
619#else //DESKTOP_VERSION 619#else //DESKTOP_VERSION
620 return false; 620 return false;
621#endif //DESKTOP_VERSION 621#endif //DESKTOP_VERSION
622} 622}
623 623
624/************************************************************************** 624/**************************************************************************
625 * 625 *
626 **************************************************************************/ 626 **************************************************************************/
627 627
628 628
629//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)
630bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 630bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
631{ 631{
632 632
633#ifndef DESKTOP_VERSION 633#ifndef DESKTOP_VERSION
634 QString channel; 634 QString channel;
635 QString message2; 635 QString message2;
636 QString parameters2; 636 QString parameters2;
637 637
638 638
639 int client = KPimGlobalPrefs::instance()->mEmailClient; 639 int client = KPimGlobalPrefs::instance()->mEmailClient;
640 if (client == KPimGlobalPrefs::OTHER_EMC) 640 if (client == KPimGlobalPrefs::OTHER_EMC)
641 { 641 {
642 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 642 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
643 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 643 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
644 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 644 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
645 } 645 }
646 else 646 else
647 { 647 {
648 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 648 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
649 if (!dai) 649 if (!dai)
650 { 650 {
651 qDebug("could not find configured email application."); 651 qDebug("could not find configured email application.");
652 return false; 652 return false;
653 } 653 }
654 channel = dai->_channel; 654 channel = dai->_channel;
655 message2 = dai->_message2; 655 message2 = dai->_message2;
656 parameters2 = dai->_parameters2; 656 parameters2 = dai->_parameters2;
657 } 657 }
658 658
659 //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.
660 message2 = translateMessage(message2, emails, urls); 660 message2 = translateMessage(message2, emails, urls);
661 661
662 662
663#ifdef DEBUG_EXT_APP_HANDLER 663#ifdef DEBUG_EXT_APP_HANDLER
664 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 664 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
665 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());
666#endif 666#endif
667 667
668 668
669 QCopEnvelope e(channel.latin1(), message2.latin1()); 669 QCopEnvelope e(channel.latin1(), message2.latin1());
670 //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
671 671
672 passParameters(&e, parameters2, emails, urls); 672 passParameters(&e, parameters2, emails, urls);
673 673
674 674
675 675
676#else 676#else
677 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." ) );
678#endif 678#endif
679 679
680 return true; 680 return true;
681} 681}
682 682
683/************************************************************************** 683/**************************************************************************
684 * 684 *
685 **************************************************************************/ 685 **************************************************************************/
686 686
687 687
688//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
689bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 689bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
690{ 690{
691#ifndef DESKTOP_VERSION 691#ifndef DESKTOP_VERSION
692 QString channel; 692 QString channel;
693 QString message; 693 QString message;
694 QString parameters; 694 QString parameters;
695 695
696 696
697 int client = KPimGlobalPrefs::instance()->mEmailClient; 697 int client = KPimGlobalPrefs::instance()->mEmailClient;
698 if (client == KPimGlobalPrefs::OTHER_EMC) 698 if (client == KPimGlobalPrefs::OTHER_EMC)
699 { 699 {
700 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 700 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
701 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 701 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
702 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 702 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
703 } 703 }
704 else 704 else
705 { 705 {
706 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 706 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
707 if (!dai) 707 if (!dai)
708 { 708 {
709 qDebug("could not find configured email application."); 709 qDebug("could not find configured email application.");
710 return false; 710 return false;
711 } 711 }
712 channel = dai->_channel; 712 channel = dai->_channel;
713 message = dai->_message; 713 message = dai->_message;
714 parameters = dai->_parameters; 714 parameters = dai->_parameters;
715 } 715 }
716 716
717 717
718 //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.
719 message = translateMessage(message, name, emailadress); 719 message = translateMessage(message, name, emailadress);
720 720
721 721
722#ifdef DEBUG_EXT_APP_HANDLER 722#ifdef DEBUG_EXT_APP_HANDLER
723 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 723 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
724 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());
725#endif 725#endif
726 726
727 QCopEnvelope e(channel.latin1(), message.latin1()); 727 QCopEnvelope e(channel.latin1(), message.latin1());
728 //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
729 729
730 passParameters(&e, parameters, name, emailadress); 730 passParameters(&e, parameters, name, emailadress);
731 731
732 732
733#else 733#else
734 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." ) );
735#endif 735#endif
736 736
737 737
738 return true; 738 return true;
739} 739}
740 740
741/************************************************************************** 741/**************************************************************************
742 * 742 *
743 **************************************************************************/ 743 **************************************************************************/
744 744
745//calls the emailapplication and creates a mail with parameter as recipients 745//calls the emailapplication and creates a mail with parameter as recipients
746// parameters format is 746// parameters format is
747// NAME <EMAIL>:SUBJECT 747// NAME <EMAIL>:SUBJECT
748bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 748bool ExternalAppHandler::mailToOneContact( const QString& adressline )
749{ 749{
750 QString line = adressline; 750 QString line = adressline;
751 751
752 int first = line.find( "<"); 752 int first = line.find( "<");
753 int last = line.find( ">"); 753 int last = line.find( ">");
754 QString name = line.left(first); 754 QString name = line.left(first);
755 QString emailadress = line.mid(first+1, last-first-1); 755 QString emailadress = line.mid(first+1, last-first-1);
756 756
757 //Subject can not be handled right now. 757 //Subject can not be handled right now.
758 return mailToOneContact( name, emailadress ); 758 return mailToOneContact( name, emailadress );
759 759
760} 760}
761 761
762 762
763/************************************************************************** 763/**************************************************************************
764 * 764 *
765 **************************************************************************/ 765 **************************************************************************/
766 766
767//calls the phoneapplication with the number 767//calls the phoneapplication with the number
768bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 768bool ExternalAppHandler::callByPhone( const QString& phonenumber )
769{ 769{
770#ifndef DESKTOP_VERSION 770#ifndef DESKTOP_VERSION
771 QString channel; 771 QString channel;
772 QString message; 772 QString message;
773 QString parameters; 773 QString parameters;
774 774
775 775
776 int client = KPimGlobalPrefs::instance()->mPhoneClient; 776 int client = KPimGlobalPrefs::instance()->mPhoneClient;
777 if (client == KPimGlobalPrefs::OTHER_PHC) 777 if (client == KPimGlobalPrefs::OTHER_PHC)
778 { 778 {
779 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 779 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
780 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 780 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
781 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 781 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
782 } 782 }
783 else 783 else
784 { 784 {
785 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 785 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
786 if (!dai) 786 if (!dai)
787 { 787 {
788 qDebug("could not find configured phone application."); 788 qDebug("could not find configured phone application.");
789 return false; 789 return false;
790 } 790 }
791 channel = dai->_channel; 791 channel = dai->_channel;
792 message = dai->_message; 792 message = dai->_message;
793 parameters = dai->_parameters; 793 parameters = dai->_parameters;
794 } 794 }
795 795
796 796
797 //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.
798 message = translateMessage(message, phonenumber, ""); 798 message = translateMessage(message, phonenumber, "");
799 799
800 800
801#ifdef DEBUG_EXT_APP_HANDLER 801#ifdef DEBUG_EXT_APP_HANDLER
802 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 802 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
803 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());
804#endif 804#endif
805 805
806 QCopEnvelope e(channel.latin1(), message.latin1()); 806 QCopEnvelope e(channel.latin1(), message.latin1());
807 //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
808 808
809 passParameters(&e, parameters, phonenumber, ""); 809 passParameters(&e, parameters, phonenumber, "");
810 810
811 811
812#else 812#else
813 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 813 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
814#endif 814#endif
815 815
816 816
817 return true; 817 return true;
818} 818}
819 819
820/************************************************************************** 820/**************************************************************************
821 * 821 *
822 **************************************************************************/ 822 **************************************************************************/
823 823
824//calls the smsapplication with the number 824//calls the smsapplication with the number
825bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 825bool ExternalAppHandler::callBySMS( const QString& phonenumber )
826{ 826{
827#ifndef DESKTOP_VERSION 827#ifndef DESKTOP_VERSION
828 QString channel; 828 QString channel;
829 QString message; 829 QString message;
830 QString parameters; 830 QString parameters;
831 831
832 832
833 int client = KPimGlobalPrefs::instance()->mSMSClient; 833 int client = KPimGlobalPrefs::instance()->mSMSClient;
834 if (client == KPimGlobalPrefs::OTHER_SMC) 834 if (client == KPimGlobalPrefs::OTHER_SMC)
835 { 835 {
836 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 836 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
837 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 837 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
838 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 838 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
839 } 839 }
840 else 840 else
841 { 841 {
842 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 842 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
843 if (!dai) 843 if (!dai)
844 { 844 {
845 qDebug("could not find configured sms application."); 845 qDebug("could not find configured sms application.");
846 return false; 846 return false;
847 } 847 }
848 channel = dai->_channel; 848 channel = dai->_channel;
849 message = dai->_message; 849 message = dai->_message;
850 parameters = dai->_parameters; 850 parameters = dai->_parameters;
851 } 851 }
852 852
853 853
854 //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.
855 message = translateMessage(message, phonenumber, ""); 855 message = translateMessage(message, phonenumber, "");
856 856
857 857
858#ifdef DEBUG_EXT_APP_HANDLER 858#ifdef DEBUG_EXT_APP_HANDLER
859 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 859 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
860 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());
861#endif 861#endif
862 862
863 QCopEnvelope e(channel.latin1(), message.latin1()); 863 QCopEnvelope e(channel.latin1(), message.latin1());
864 //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
865 865
866 passParameters(&e, parameters, phonenumber, ""); 866 passParameters(&e, parameters, phonenumber, "");
867 867
868 868
869#else 869#else
870 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." ) );
871#endif 871#endif
872 872
873 873
874 return true; 874 return true;
875} 875}
876 876
877/************************************************************************** 877/**************************************************************************
878 * 878 *
879 **************************************************************************/ 879 **************************************************************************/
880 880
881//calls the pagerapplication with the number 881//calls the pagerapplication with the number
882bool ExternalAppHandler::callByPager( const QString& pagernumber ) 882bool ExternalAppHandler::callByPager( const QString& pagernumber )
883{ 883{
884#ifndef DESKTOP_VERSION 884#ifndef DESKTOP_VERSION
885 QString channel; 885 QString channel;
886 QString message; 886 QString message;
887 QString parameters; 887 QString parameters;
888 888
889 889
890 int client = KPimGlobalPrefs::instance()->mPagerClient; 890 int client = KPimGlobalPrefs::instance()->mPagerClient;
891 if (client == KPimGlobalPrefs::OTHER_PAC) 891 if (client == KPimGlobalPrefs::OTHER_PAC)
892 { 892 {
893 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 893 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
894 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 894 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
895 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 895 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
896 } 896 }
897 else 897 else
898 { 898 {
899 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 899 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
900 if (!dai) 900 if (!dai)
901 { 901 {
902 qDebug("could not find configured pager application."); 902 qDebug("could not find configured pager application.");
903 return false; 903 return false;
904 } 904 }
905 channel = dai->_channel; 905 channel = dai->_channel;
906 message = dai->_message; 906 message = dai->_message;
907 parameters = dai->_parameters; 907 parameters = dai->_parameters;
908 } 908 }
909 909
910 910
911 //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.
912 message = translateMessage(message, pagernumber, ""); 912 message = translateMessage(message, pagernumber, "");
913 913
914 914
915#ifdef DEBUG_EXT_APP_HANDLER 915#ifdef DEBUG_EXT_APP_HANDLER
916 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 916 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
917 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());
918#endif 918#endif
919 919
920 QCopEnvelope e(channel.latin1(), message.latin1()); 920 QCopEnvelope e(channel.latin1(), message.latin1());
921 //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
922 922
923 passParameters(&e, parameters, pagernumber, ""); 923 passParameters(&e, parameters, pagernumber, "");
924 924
925 925
926#else 926#else
927 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 927 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
928#endif 928#endif
929 929
930 930
931 return true; 931 return true;
932} 932}
933 933
934/************************************************************************** 934/**************************************************************************
935 * 935 *
936 **************************************************************************/ 936 **************************************************************************/
937 937
938//calls the faxapplication with the number 938//calls the faxapplication with the number
939bool ExternalAppHandler::callByFax( const QString& faxnumber ) 939bool ExternalAppHandler::callByFax( const QString& faxnumber )
940{ 940{
941#ifndef DESKTOP_VERSION 941#ifndef DESKTOP_VERSION
942 QString channel; 942 QString channel;
943 QString message; 943 QString message;
944 QString parameters; 944 QString parameters;
945 945
946 946
947 int client = KPimGlobalPrefs::instance()->mFaxClient; 947 int client = KPimGlobalPrefs::instance()->mFaxClient;
948 if (client == KPimGlobalPrefs::OTHER_FAC) 948 if (client == KPimGlobalPrefs::OTHER_FAC)
949 { 949 {
950 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 950 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
951 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 951 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
952 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 952 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
953 } 953 }
954 else 954 else
955 { 955 {
956 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 956 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
957 if (!dai) 957 if (!dai)
958 { 958 {
959 qDebug("could not find configured fax application."); 959 qDebug("could not find configured fax application.");
960 return false; 960 return false;
961 } 961 }
962 channel = dai->_channel; 962 channel = dai->_channel;
963 message = dai->_message; 963 message = dai->_message;
964 parameters = dai->_parameters; 964 parameters = dai->_parameters;
965 } 965 }
966 966
967 967
968 //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.
969 message = translateMessage(message, faxnumber, ""); 969 message = translateMessage(message, faxnumber, "");
970 970
971 971
972#ifdef DEBUG_EXT_APP_HANDLER 972#ifdef DEBUG_EXT_APP_HANDLER
973 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 973 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
974 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());
975#endif 975#endif
976 976
977 QCopEnvelope e(channel.latin1(), message.latin1()); 977 QCopEnvelope e(channel.latin1(), message.latin1());
978 //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
979 979
980 passParameters(&e, parameters, faxnumber, ""); 980 passParameters(&e, parameters, faxnumber, "");
981 981
982 982
983#else 983#else
984 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." ) );
985#endif 985#endif
986 986
987 987
988 return true; 988 return true;
989} 989}
990 990
991/************************************************************************** 991/**************************************************************************
992 * 992 *
993 **************************************************************************/ 993 **************************************************************************/
994 994
995//calls the sipapplication with the number 995//calls the sipapplication with the number
996bool ExternalAppHandler::callBySIP( const QString& sipnumber ) 996bool ExternalAppHandler::callBySIP( const QString& sipnumber )
997{ 997{
998#ifndef DESKTOP_VERSION 998#ifndef DESKTOP_VERSION
999 QString channel; 999 QString channel;
1000 QString message; 1000 QString message;
1001 QString parameters; 1001 QString parameters;
1002 1002
1003 1003
1004 int client = KPimGlobalPrefs::instance()->mSipClient; 1004 int client = KPimGlobalPrefs::instance()->mSipClient;
1005 if (client == KPimGlobalPrefs::OTHER_SIC) 1005 if (client == KPimGlobalPrefs::OTHER_SIC)
1006 { 1006 {
1007 channel = KPimGlobalPrefs::instance()->mSipOtherChannel; 1007 channel = KPimGlobalPrefs::instance()->mSipOtherChannel;
1008 message = KPimGlobalPrefs::instance()->mSipOtherMessage; 1008 message = KPimGlobalPrefs::instance()->mSipOtherMessage;
1009 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; 1009 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters;
1010 } 1010 }
1011 else 1011 else
1012 { 1012 {
1013 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); 1013 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client);
1014 if (!dai) 1014 if (!dai)
1015 { 1015 {
1016 qDebug("could not find configured sip application."); 1016 qDebug("could not find configured sip application.");
1017 return false; 1017 return false;
1018 } 1018 }
1019 channel = dai->_channel; 1019 channel = dai->_channel;
1020 message = dai->_message; 1020 message = dai->_message;
1021 parameters = dai->_parameters; 1021 parameters = dai->_parameters;
1022 } 1022 }
1023 1023
1024 1024
1025 //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.
1026 message = translateMessage(message, sipnumber, ""); 1026 message = translateMessage(message, sipnumber, "");
1027 1027
1028 1028
1029#ifdef DEBUG_EXT_APP_HANDLER 1029#ifdef DEBUG_EXT_APP_HANDLER
1030 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1030 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1031 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());
1032#endif 1032#endif
1033 1033
1034 QCopEnvelope e(channel.latin1(), message.latin1()); 1034 QCopEnvelope e(channel.latin1(), message.latin1());
1035 //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
1036 1036
1037 passParameters(&e, parameters, sipnumber, ""); 1037 passParameters(&e, parameters, sipnumber, "");
1038 1038
1039 1039
1040#else 1040#else
1041 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); 1041 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) );
1042#endif 1042#endif
1043 1043
1044 1044
1045 return true; 1045 return true;
1046} 1046}
1047 1047
1048 1048
1049/************************************************************************** 1049/**************************************************************************
1050 * 1050 *
1051 **************************************************************************/ 1051 **************************************************************************/
1052 1052
1053 1053
1054QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 1054QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
1055{ 1055{
1056 message = message.replace( QRegExp("%1"), param1 ); 1056 message = message.replace( QRegExp("%1"), param1 );
1057 return message.replace( QRegExp("%2"), param2 ); 1057 return message.replace( QRegExp("%2"), param2 );
1058} 1058}
1059 1059
1060/************************************************************************** 1060/**************************************************************************
1061 * 1061 *
1062 **************************************************************************/ 1062 **************************************************************************/
1063 1063
1064void 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
1065{ 1065{
1066#ifndef DESKTOP_VERSION 1066#ifndef DESKTOP_VERSION
1067 QMap<QString, QString> valmap; 1067 QMap<QString, QString> valmap;
1068 bool useValMap = false; 1068 bool useValMap = false;
1069 1069
1070 // first extract all parts of the parameters. 1070 // first extract all parts of the parameters.
1071 QStringList paramlist = QStringList::split(";", parameters); 1071 QStringList paramlist = QStringList::split(";", parameters);
1072 1072
1073 //Now check how many parts we have. 1073 //Now check how many parts we have.
1074 //=0 :no params to pass 1074 //=0 :no params to pass
1075 //>0 :parameters to pass 1075 //>0 :parameters to pass
1076 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 1076 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
1077 { 1077 {
1078 QString param = (*it); 1078 QString param = (*it);
1079 QStringList keyvallist = QStringList::split("=", param); 1079 QStringList keyvallist = QStringList::split("=", param);
1080 1080
1081 //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
1082 QStringList::Iterator it2 = keyvallist.begin(); 1082 QStringList::Iterator it2 = keyvallist.begin();
1083 QString key = (*it2); 1083 QString key = (*it2);
1084 key = key.replace( QRegExp("%1"), param1 ); 1084 key = key.replace( QRegExp("%1"), param1 );
1085 key = key.replace( QRegExp("%2"), param2 ); 1085 key = key.replace( QRegExp("%2"), param2 );
1086 ++it2; 1086 ++it2;
1087 1087
1088 if(it2 != keyvallist.end()) 1088 if(it2 != keyvallist.end())
1089 { 1089 {
1090 QString value = (*it2); 1090 QString value = (*it2);
1091 value = value.replace( QRegExp("%1"), param1 ); 1091 value = value.replace( QRegExp("%1"), param1 );
1092 value = value.replace( QRegExp("%2"), param2 ); 1092 value = value.replace( QRegExp("%2"), param2 );
1093 1093
1094 valmap.insert(key, value); 1094 valmap.insert(key, value);
1095 useValMap = true; 1095 useValMap = true;
1096 } 1096 }
1097 else 1097 else
1098 { 1098 {
1099 // qDebug("pass parameter << %s", key.latin1()); 1099 // qDebug("pass parameter << %s", key.latin1());
1100 (*e) << key; 1100 (*e) << key;
1101 } 1101 }
1102 } 1102 }
1103 1103
1104 if (useValMap == true) 1104 if (useValMap == true)
1105 (*e) << valmap; 1105 (*e) << valmap;
1106 1106
1107#endif 1107#endif
1108 1108
1109} 1109}
1110 1110
1111 1111
1112 1112
1113/************************************************************************** 1113/**************************************************************************
1114 * 1114 *
1115 **************************************************************************/ 1115 **************************************************************************/
1116 1116
1117void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) 1117void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data )
1118{ 1118{
1119
1120 if ( cmsg == "nextView()" ) {
1121 emit nextView();
1122 return;
1123 }
1124
1119 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1125 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1120 if (!res) 1126 if (!res)
1121 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); 1127 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data );
1122 1128
1123 if (!res) 1129 if (!res)
1124 res = mDisplayDetails->appMessage( cmsg, data ); 1130 res = mDisplayDetails->appMessage( cmsg, data );
1125 1131
1126// if (!res) 1132// if (!res)
1127// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1133// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1128} 1134}
1129 1135
1130 1136
1131 1137
1132bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1138bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1133{ 1139{
1134 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1140 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1135 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); 1141 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid);
1136} 1142}
1137 1143
1138bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1144bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1139{ 1145{
1140 QStringList list4, list5, list6; 1146 QStringList list4, list5, list6;
1141 1147
1142 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1148 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1143 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1149 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1144} 1150}
1145 1151
1146bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) 1152bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email)
1147{ 1153{
1148 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1154 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1149 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); 1155 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email);
1150} 1156}
1151 1157
1152bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1158bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1153{ 1159{
1154 QStringList list4, list5, list6; 1160 QStringList list4, list5, list6;
1155 1161
1156 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1162 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1157 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1163 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1158} 1164}
1159 1165
1160bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) 1166bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid)
1161{ 1167{
1162 mDisplayDetails->setSourceChannel(""); 1168 mDisplayDetails->setSourceChannel("");
1163 return mDisplayDetails->sendMessageToTarget("", name, email, uid); 1169 return mDisplayDetails->sendMessageToTarget("", name, email, uid);
1164} 1170}
1165 1171
1166bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1172bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1167{ 1173{
1168 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1174 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1169 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); 1175 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid);
1170} 1176}
1171 1177
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) 1178bool 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)
1173{ 1179{
1174 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1180 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1175 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1181 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1176} 1182}
1177 1183
1178 1184
1179 1185
1180 1186
1181 1187