summaryrefslogtreecommitdiffabout
path: root/libkdepim/externalapphandler.cpp
Unidiff
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 6100097..5ba32b6 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -1,935 +1,934 @@
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/********************************************************************************* 51/*********************************************************************************
52 * 52 *
53 ********************************************************************************/ 53 ********************************************************************************/
54 54
55 55
56QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 56QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
57 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) 57 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
58{ 58{
59 //sourceMessage passes later three parameters: sourceChannel, uid, param1 59 //sourceMessage passes later three parameters: sourceChannel, uid, param1
60 if (_usedSourceParameters == 0) 60 if (_usedSourceParameters == 0)
61 _sourceMessageParameters = "(QString,QString)"; 61 _sourceMessageParameters = "(QString,QString)";
62 else if (_usedSourceParameters == 1) 62 else if (_usedSourceParameters == 1)
63 _sourceMessageParameters = "(QString,QString,QString)"; 63 _sourceMessageParameters = "(QString,QString,QString)";
64 else if (_usedSourceParameters == 2) 64 else if (_usedSourceParameters == 2)
65 _sourceMessageParameters = "(QString,QString,QString,QString)"; 65 _sourceMessageParameters = "(QString,QString,QString,QString)";
66 else if (_usedSourceParameters == 3) 66 else if (_usedSourceParameters == 3)
67 _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; 67 _sourceMessageParameters = "(QString,QString,QString,QString,QString)";
68} 68}
69 69
70/*********************************************************************************/ 70/*********************************************************************************/
71 71
72QCopTransferItem::QCopTransferItem() 72QCopTransferItem::QCopTransferItem()
73{ 73{
74} 74}
75 75
76/*********************************************************************************/ 76/*********************************************************************************/
77bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) 77bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3)
78{ 78{
79 79
80#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
81 //sourceMessage passes two parameters: sourceChannel, uid 81 //sourceMessage passes two parameters: sourceChannel, uid
82 QString sourceMessage = _sourceMessage + _sourceMessageParameters; 82 QString sourceMessage = _sourceMessage + _sourceMessageParameters;
83 83
84 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); 84 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1());
85 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()); 85 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());
86 86
87 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); 87 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
88 88
89 e << _sourceChannel << uid; 89 e << _sourceChannel << uid;
90 90
91 if (_usedSourceParameters == 1) 91 if (_usedSourceParameters == 1)
92 e << param1; 92 e << param1;
93 else if (_usedSourceParameters == 2) 93 else if (_usedSourceParameters == 2)
94 e << param1 << param2; 94 e << param1 << param2;
95 else if (_usedSourceParameters == 3) 95 else if (_usedSourceParameters == 3)
96 e << param1 << param2 << param3; 96 e << param1 << param2 << param3;
97 97
98 qApp->processEvents(); 98 qApp->processEvents();
99 99
100 return true; 100 return true;
101 101
102#else 102#else
103 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 103 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
104 return false; 104 return false;
105#endif 105#endif
106 106
107} 107}
108 108
109 109
110/*********************************************************************************/ 110/*********************************************************************************/
111void QCopTransferItem::setSourceChannel(const QString& sourceChannel) 111void QCopTransferItem::setSourceChannel(const QString& sourceChannel)
112{ 112{
113 113
114 if (_sourceChannel.isEmpty()) 114 if (_sourceChannel.isEmpty())
115 _sourceChannel = sourceChannel; 115 _sourceChannel = sourceChannel;
116} 116}
117 117
118 118
119/*********************************************************************************/ 119/*********************************************************************************/
120bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 120bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
121{ 121{
122 122
123 // copied from old mail2 123 // copied from old mail2
124/* 124/*
125 static int ii = 0; 125 static int ii = 0;
126 126
127 // block second call 127 // block second call
128 if ( ii < 2 ) { 128 if ( ii < 2 ) {
129 ++ii; 129 ++ii;
130 if ( ii > 1 ) { 130 if ( ii > 1 ) {
131 qDebug("qcop call blocked "); 131 qDebug("qcop call blocked ");
132 return true; 132 return true;
133 } 133 }
134 } 134 }
135*/ 135*/
136 136
137// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); 137// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
138 138
139 //we are in the target and get a request from the source 139 //we are in the target and get a request from the source
140 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) 140 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
141 { 141 {
142 142
143 QDataStream stream( data, IO_ReadOnly ); 143 QDataStream stream( data, IO_ReadOnly );
144 144
145 145
146 QString sourceChannel; 146 QString sourceChannel;
147 QString uid; 147 QString uid;
148 QString param1; 148 QString param1;
149 QString param2; 149 QString param2;
150 QString param3; 150 QString param3;
151 151
152 stream >> sourceChannel >> uid; 152 stream >> sourceChannel >> uid;
153 153
154 if (_usedSourceParameters == 0) 154 if (_usedSourceParameters == 0)
155 { 155 {
156 emit receivedMessageFromSource(sourceChannel, uid); 156 emit receivedMessageFromSource(sourceChannel, uid);
157 } 157 }
158 else if (_usedSourceParameters == 1) 158 else if (_usedSourceParameters == 1)
159 { 159 {
160 stream >> param1; 160 stream >> param1;
161 emit receivedMessageFromSource(sourceChannel, uid, param1); 161 emit receivedMessageFromSource(sourceChannel, uid, param1);
162 } 162 }
163 else if (_usedSourceParameters == 2) 163 else if (_usedSourceParameters == 2)
164 { 164 {
165 stream >> param1 >> param2; 165 stream >> param1 >> param2;
166 emit receivedMessageFromSource(sourceChannel, uid, param1, param2); 166 emit receivedMessageFromSource(sourceChannel, uid, param1, param2);
167 } 167 }
168 else if (_usedSourceParameters == 3) 168 else if (_usedSourceParameters == 3)
169 { 169 {
170 stream >> param1 >> param2 >> param3; 170 stream >> param1 >> param2 >> param3;
171 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); 171 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3);
172 } 172 }
173 173
174 return true; 174 return true;
175 } 175 }
176 176
177 return false; 177 return false;
178} 178}
179 179
180 180
181/********************************************************************************* 181/*********************************************************************************
182 * 182 *
183 ********************************************************************************/ 183 ********************************************************************************/
184 184
185 185
186QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 186QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
187 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 187 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
188{ 188{
189 //targetMessage returns later two parameters: uid, and map<qstring,qstring> 189 //targetMessage returns later two parameters: uid, and map<qstring,qstring>
190 _targetMessageParameters = "(QString,QMAP<QString,QString>)"; 190 _targetMessageParameters = "(QString,QMAP<QString,QString>)";
191} 191}
192 192
193/*********************************************************************************/ 193/*********************************************************************************/
194bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) 194bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap)
195{ 195{
196#ifndef DESKTOP_VERSION 196#ifndef DESKTOP_VERSION
197 //targetMessage passes two parameters: uid, map 197 //targetMessage passes two parameters: uid, map
198 QString targetMessage = _targetMessage + _targetMessageParameters; 198 QString targetMessage = _targetMessage + _targetMessageParameters;
199 199
200 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 200 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
201 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); 201 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
202 202
203 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 203 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
204 //US we need no names in the To field. The emailadresses are enough 204 //US we need no names in the To field. The emailadresses are enough
205 205
206 e << uid << nameEmailMap; 206 e << uid << nameEmailMap;
207 207
208 qApp->processEvents(); 208 qApp->processEvents();
209 209
210 return true; 210 return true;
211 211
212#else 212#else
213 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 213 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
214 return false; 214 return false;
215#endif 215#endif
216 216
217} 217}
218 218
219 219
220/*********************************************************************************/ 220/*********************************************************************************/
221bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 221bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
222{ 222{
223 bool res = QCopTransferItem::appMessage( cmsg, data ); 223 bool res = QCopTransferItem::appMessage( cmsg, data );
224 224
225 if (res == false) 225 if (res == false)
226 { 226 {
227 QDataStream stream( data, IO_ReadOnly ); 227 QDataStream stream( data, IO_ReadOnly );
228 228
229// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); 229// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() );
230 230
231 //we are in the source and get an answer from the target 231 //we are in the source and get an answer from the target
232 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 232 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
233 { 233 {
234 QMap<QString,QString> adrMap; 234 QMap<QString,QString> adrMap;
235 QString uid; 235 QString uid;
236 236
237 stream >> uid >> adrMap; 237 stream >> uid >> adrMap;
238 238
239 emit receivedMessageFromTarget(uid, adrMap); 239 emit receivedMessageFromTarget(uid, adrMap);
240 240
241 241
242 return true; 242 return true;
243 } 243 }
244 } 244 }
245 245
246 return false; 246 return false;
247} 247}
248 248
249 249
250/********************************************************************************* 250/*********************************************************************************
251 * 251 *
252 ********************************************************************************/ 252 ********************************************************************************/
253 253
254 254
255QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 255QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
256 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 256 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
257{ 257{
258 //targetMessage returns later two parameters: uid, and three lists 258 //targetMessage returns later two parameters: uid, and three lists
259 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList)"; 259 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList)";
260} 260}
261 261
262/*********************************************************************************/ 262/*********************************************************************************/
263bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 263bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
264{ 264{
265#ifndef DESKTOP_VERSION 265#ifndef DESKTOP_VERSION
266 //targetMessage passes two parameters: uid, map 266 //targetMessage passes two parameters: uid, map
267 QString targetMessage = _targetMessage + _targetMessageParameters; 267 QString targetMessage = _targetMessage + _targetMessageParameters;
268 268
269 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 269 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
270 qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1()); 270 qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1());
271 271
272 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 272 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
273 //US we need no names in the To field. The emailadresses are enough 273 //US we need no names in the To field. The emailadresses are enough
274 274
275 e << uid << list1 << list2 << list3; 275 e << uid << list1 << list2 << list3;
276 276
277 qApp->processEvents(); 277 qApp->processEvents();
278 278
279 return true; 279 return true;
280 280
281#else 281#else
282 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 282 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
283 return false; 283 return false;
284#endif 284#endif
285 285
286} 286}
287 287
288 288
289/*********************************************************************************/ 289/*********************************************************************************/
290bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 290bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
291{ 291{
292 bool res = QCopTransferItem::appMessage( cmsg, data ); 292 bool res = QCopTransferItem::appMessage( cmsg, data );
293 293
294 if (res == false) 294 if (res == false)
295 { 295 {
296 QDataStream stream( data, IO_ReadOnly ); 296 QDataStream stream( data, IO_ReadOnly );
297 297
298// qDebug("QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 298// qDebug("QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
299 299
300 //we are in the source and get an answer from the target 300 //we are in the source and get an answer from the target
301 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 301 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
302 { 302 {
303 QStringList list1; 303 QStringList list1;
304 QStringList list2; 304 QStringList list2;
305 QStringList list3; 305 QStringList list3;
306 QString uid; 306 QString uid;
307 307
308 stream >> uid >> list1 >> list2 >> list3; 308 stream >> uid >> list1 >> list2 >> list3;
309 emit receivedMessageFromTarget(uid, list1, list2, list3); 309 emit receivedMessageFromTarget(uid, list1, list2, list3);
310 310
311 311
312 return true; 312 return true;
313 } 313 }
314 } 314 }
315 315
316 return false; 316 return false;
317} 317}
318 318
319 319
320 320
321/********************************************************************************* 321/*********************************************************************************
322 * 322 *
323 ********************************************************************************/ 323 ********************************************************************************/
324 324
325 325
326ExternalAppHandler *ExternalAppHandler::sInstance = 0; 326ExternalAppHandler *ExternalAppHandler::sInstance = 0;
327static KStaticDeleter<ExternalAppHandler> staticDeleter; 327static KStaticDeleter<ExternalAppHandler> staticDeleter;
328 328
329ExternalAppHandler::ExternalAppHandler() 329ExternalAppHandler::ExternalAppHandler()
330{ 330{
331 mDefaultItems.setAutoDelete(true); 331 mDefaultItems.setAutoDelete(true);
332 332
333 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); 333 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
334 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); 334 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&)));
335 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 335 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
336 336
337//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); 337//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
338//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); 338//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
339//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 339//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
340 340
341 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); 341 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
342 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&))); 342 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&)));
343} 343}
344 344
345ExternalAppHandler::~ExternalAppHandler() 345ExternalAppHandler::~ExternalAppHandler()
346{ 346{
347} 347}
348 348
349void ExternalAppHandler::loadConfig() 349void ExternalAppHandler::loadConfig()
350{ 350{
351 351
352 mDefaultItems.clear(); 352 mDefaultItems.clear();
353
354 mEmailAppAvailable = UNDEFINED; 353 mEmailAppAvailable = UNDEFINED;
355 mPhoneAppAvailable = UNDEFINED; 354 mPhoneAppAvailable = UNDEFINED;
356 mFaxAppAvailable = UNDEFINED; 355 mFaxAppAvailable = UNDEFINED;
357 mSMSAppAvailable = UNDEFINED; 356 mSMSAppAvailable = UNDEFINED;
358 mPagerAppAvailable = UNDEFINED; 357 mPagerAppAvailable = UNDEFINED;
359 358
360 359
361 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 360 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
362 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 361 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
363 362
364 if (opiepath.isEmpty()) 363 if (opiepath.isEmpty())
365 opiepath = qtopiapath; 364 opiepath = qtopiapath;
366 365
367 //mailclients 366 //mailclients
368 QString mailmsg1 = "writeMail(QString,QString)"; 367 QString mailmsg1 = "writeMail(QString,QString)";
369 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 368 QString mailmsg2 = "writeMail(QMap(QString,QString))";
370 369
371 QString undefined = ""; 370 QString undefined = "";
372 371
373 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 372 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
374 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 373 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
375 374
376 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 375 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
377 ( QFile::exists( opiepath + "/bin/ompi" ))) 376 ( QFile::exists( opiepath + "/bin/ompi" )))
378 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 377 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
379 378
380 if ( QFile::exists( qtopiapath + "/bin/qtmail" )) 379 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
381 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 380 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
382 381
383 if ( QFile::exists( opiepath + "/bin/opiemail" )) 382 if ( QFile::exists( opiepath + "/bin/opiemail" ))
384 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 383 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
385 384
386 385
387 386
388 //phoneclients 387 //phoneclients
389 388
390 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 389 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
391 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 390 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
392 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 391 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
393 ( QFile::exists( opiepath + "/bin/kppi" ))) 392 ( QFile::exists( opiepath + "/bin/kppi" )))
394 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 393 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
395 394
396 //faxclients 395 //faxclients
397 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 396 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
398 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 397 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
399 398
400 //smsclients 399 //smsclients
401 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 400 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
402 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 401 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
403 402
404 //pagerclients 403 //pagerclients
405 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 404 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
406 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 405 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
407 406
408} 407}
409 408
410ExternalAppHandler *ExternalAppHandler::instance() 409ExternalAppHandler *ExternalAppHandler::instance()
411{ 410{
412 if ( !sInstance ) { 411 if ( !sInstance ) {
413 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 412 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
414 sInstance->loadConfig(); 413 sInstance->loadConfig();
415 } 414 }
416 415
417 return sInstance; 416 return sInstance;
418} 417}
419 418
420void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 419void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
421{ 420{
422 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 421 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
423 422 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
424 mDefaultItems.append(dai); 423 mDefaultItems.append(dai);
425} 424}
426 425
427 426
428QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 427QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
429{ 428{
430 QList<DefaultAppItem> list; 429 QList<DefaultAppItem> list;
431 430
432 DefaultAppItem* dai; 431 DefaultAppItem* dai;
433 432
434 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 433 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
435 { 434 {
436 if (dai->_type == type) 435 if (dai->_type == type)
437 list.append(dai); 436 list.append(dai);
438 } 437 }
439 438
440 return list; 439 return list;
441} 440}
442 441
443DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 442DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
444{ 443{
445 DefaultAppItem* dai; 444 DefaultAppItem* dai;
446 445
447 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 446 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
448 { 447 {
449 if (dai->_type == type && dai->_id == clientid) 448 if (dai->_type == type && dai->_id == clientid)
450 return dai; 449 return dai;
451 } 450 }
452 451
453 return 0; 452 return 0;
454} 453}
455 454
456bool ExternalAppHandler::isEmailAppAvailable() 455bool ExternalAppHandler::isEmailAppAvailable()
457{ 456{
458#ifndef DESKTOP_VERSION 457#ifndef DESKTOP_VERSION
459 if (mEmailAppAvailable == UNDEFINED) 458 if (mEmailAppAvailable == UNDEFINED)
460 { 459 {
461 int client = KPimGlobalPrefs::instance()->mEmailClient; 460 int client = KPimGlobalPrefs::instance()->mEmailClient;
462 if (client == KPimGlobalPrefs::NONE_EMC) 461 if (client == KPimGlobalPrefs::NONE_EMC)
463 mEmailAppAvailable = UNAVAILABLE; 462 mEmailAppAvailable = UNAVAILABLE;
464 else 463 else
465 mEmailAppAvailable = AVAILABLE; 464 mEmailAppAvailable = AVAILABLE;
466 } 465 }
467 return (mEmailAppAvailable == AVAILABLE); 466 return (mEmailAppAvailable == AVAILABLE);
468 467
469#else //DESKTOP_VERSION 468#else //DESKTOP_VERSION
470 return false; 469 return false;
471#endif //DESKTOP_VERSION 470#endif //DESKTOP_VERSION
472} 471}
473 472
474bool ExternalAppHandler::isSMSAppAvailable() 473bool ExternalAppHandler::isSMSAppAvailable()
475{ 474{
476#ifndef DESKTOP_VERSION 475#ifndef DESKTOP_VERSION
477 if (mSMSAppAvailable == UNDEFINED) 476 if (mSMSAppAvailable == UNDEFINED)
478 { 477 {
479 int client = KPimGlobalPrefs::instance()->mSMSClient; 478 int client = KPimGlobalPrefs::instance()->mSMSClient;
480 if (client == KPimGlobalPrefs::NONE_SMC) 479 if (client == KPimGlobalPrefs::NONE_SMC)
481 mSMSAppAvailable = UNAVAILABLE; 480 mSMSAppAvailable = UNAVAILABLE;
482 else 481 else
483 mSMSAppAvailable = AVAILABLE; 482 mSMSAppAvailable = AVAILABLE;
484 } 483 }
485 484
486 return (mSMSAppAvailable == AVAILABLE); 485 return (mSMSAppAvailable == AVAILABLE);
487#else //DESKTOP_VERSION 486#else //DESKTOP_VERSION
488 return false; 487 return false;
489#endif //DESKTOP_VERSION 488#endif //DESKTOP_VERSION
490} 489}
491 490
492bool ExternalAppHandler::isPhoneAppAvailable() 491bool ExternalAppHandler::isPhoneAppAvailable()
493{ 492{
494#ifndef DESKTOP_VERSION 493#ifndef DESKTOP_VERSION
495 if (mPhoneAppAvailable == UNDEFINED) 494 if (mPhoneAppAvailable == UNDEFINED)
496 { 495 {
497 int client = KPimGlobalPrefs::instance()->mPhoneClient; 496 int client = KPimGlobalPrefs::instance()->mPhoneClient;
498 if (client == KPimGlobalPrefs::NONE_PHC) 497 if (client == KPimGlobalPrefs::NONE_PHC)
499 mPhoneAppAvailable = UNAVAILABLE; 498 mPhoneAppAvailable = UNAVAILABLE;
500 else 499 else
501 mPhoneAppAvailable = AVAILABLE; 500 mPhoneAppAvailable = AVAILABLE;
502 } 501 }
503 502
504 return (mPhoneAppAvailable == AVAILABLE); 503 return (mPhoneAppAvailable == AVAILABLE);
505#else //DESKTOP_VERSION 504#else //DESKTOP_VERSION
506 return false; 505 return false;
507#endif //DESKTOP_VERSION 506#endif //DESKTOP_VERSION
508} 507}
509 508
510bool ExternalAppHandler::isFaxAppAvailable() 509bool ExternalAppHandler::isFaxAppAvailable()
511{ 510{
512#ifndef DESKTOP_VERSION 511#ifndef DESKTOP_VERSION
513 if (mFaxAppAvailable == UNDEFINED) 512 if (mFaxAppAvailable == UNDEFINED)
514 { 513 {
515 int client = KPimGlobalPrefs::instance()->mFaxClient; 514 int client = KPimGlobalPrefs::instance()->mFaxClient;
516 if (client == KPimGlobalPrefs::NONE_FAC) 515 if (client == KPimGlobalPrefs::NONE_FAC)
517 mFaxAppAvailable = UNAVAILABLE; 516 mFaxAppAvailable = UNAVAILABLE;
518 else 517 else
519 mFaxAppAvailable = AVAILABLE; 518 mFaxAppAvailable = AVAILABLE;
520 } 519 }
521 520
522 return (mFaxAppAvailable == AVAILABLE); 521 return (mFaxAppAvailable == AVAILABLE);
523#else //DESKTOP_VERSION 522#else //DESKTOP_VERSION
524 return false; 523 return false;
525#endif //DESKTOP_VERSION 524#endif //DESKTOP_VERSION
526} 525}
527 526
528bool ExternalAppHandler::isPagerAppAvailable() 527bool ExternalAppHandler::isPagerAppAvailable()
529{ 528{
530#ifndef DESKTOP_VERSION 529#ifndef DESKTOP_VERSION
531 if (mPagerAppAvailable == UNDEFINED) 530 if (mPagerAppAvailable == UNDEFINED)
532 { 531 {
533 int client = KPimGlobalPrefs::instance()->mPagerClient; 532 int client = KPimGlobalPrefs::instance()->mPagerClient;
534 if (client == KPimGlobalPrefs::NONE_PAC) 533 if (client == KPimGlobalPrefs::NONE_PAC)
535 mPagerAppAvailable = UNAVAILABLE; 534 mPagerAppAvailable = UNAVAILABLE;
536 else 535 else
537 mPagerAppAvailable = AVAILABLE; 536 mPagerAppAvailable = AVAILABLE;
538 } 537 }
539 538
540 return (mPagerAppAvailable == AVAILABLE); 539 return (mPagerAppAvailable == AVAILABLE);
541#else //DESKTOP_VERSION 540#else //DESKTOP_VERSION
542 return false; 541 return false;
543#endif //DESKTOP_VERSION 542#endif //DESKTOP_VERSION
544} 543}
545 544
546/************************************************************************** 545/**************************************************************************
547 * 546 *
548 **************************************************************************/ 547 **************************************************************************/
549 548
550 549
551//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 550//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
552bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 551bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
553{ 552{
554 553
555#ifndef DESKTOP_VERSION 554#ifndef DESKTOP_VERSION
556 QString channel; 555 QString channel;
557 QString message2; 556 QString message2;
558 QString parameters2; 557 QString parameters2;
559 558
560 559
561 int client = KPimGlobalPrefs::instance()->mEmailClient; 560 int client = KPimGlobalPrefs::instance()->mEmailClient;
562 if (client == KPimGlobalPrefs::OTHER_EMC) 561 if (client == KPimGlobalPrefs::OTHER_EMC)
563 { 562 {
564 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 563 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
565 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 564 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
566 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 565 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
567 } 566 }
568 else 567 else
569 { 568 {
570 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 569 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
571 if (!dai) 570 if (!dai)
572 { 571 {
573 qDebug("could not find configured email application."); 572 qDebug("could not find configured email application.");
574 return false; 573 return false;
575 } 574 }
576 channel = dai->_channel; 575 channel = dai->_channel;
577 message2 = dai->_message2; 576 message2 = dai->_message2;
578 parameters2 = dai->_parameters2; 577 parameters2 = dai->_parameters2;
579 } 578 }
580 579
581 //first check if one of the mailers need the emails right in the message. 580 //first check if one of the mailers need the emails right in the message.
582 message2 = translateMessage(message2, emails, urls); 581 message2 = translateMessage(message2, emails, urls);
583 582
584 583
585 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 584 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
586 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 585 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
587 586
588 587
589 QCopEnvelope e(channel.latin1(), message2.latin1()); 588 QCopEnvelope e(channel.latin1(), message2.latin1());
590 //US we need no names in the To field. The emailadresses are enough 589 //US we need no names in the To field. The emailadresses are enough
591 590
592 passParameters(&e, parameters2, emails, urls); 591 passParameters(&e, parameters2, emails, urls);
593 592
594 593
595 594
596#else 595#else
597 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 596 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
598#endif 597#endif
599 598
600 return true; 599 return true;
601} 600}
602 601
603/************************************************************************** 602/**************************************************************************
604 * 603 *
605 **************************************************************************/ 604 **************************************************************************/
606 605
607 606
608//calls the emailapplication and creates a mail with parameter emails as recipients 607//calls the emailapplication and creates a mail with parameter emails as recipients
609bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 608bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
610{ 609{
611#ifndef DESKTOP_VERSION 610#ifndef DESKTOP_VERSION
612 QString channel; 611 QString channel;
613 QString message; 612 QString message;
614 QString parameters; 613 QString parameters;
615 614
616 615
617 int client = KPimGlobalPrefs::instance()->mEmailClient; 616 int client = KPimGlobalPrefs::instance()->mEmailClient;
618 if (client == KPimGlobalPrefs::OTHER_EMC) 617 if (client == KPimGlobalPrefs::OTHER_EMC)
619 { 618 {
620 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 619 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
621 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 620 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
622 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 621 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
623 } 622 }
624 else 623 else
625 { 624 {
626 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 625 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
627 if (!dai) 626 if (!dai)
628 { 627 {
629 qDebug("could not find configured email application."); 628 qDebug("could not find configured email application.");
630 return false; 629 return false;
631 } 630 }
632 channel = dai->_channel; 631 channel = dai->_channel;
633 message = dai->_message; 632 message = dai->_message;
634 parameters = dai->_parameters; 633 parameters = dai->_parameters;
635 } 634 }
636 635
637 636
638 //first check if one of the mailers need the emails right in the message. 637 //first check if one of the mailers need the emails right in the message.
639 message = translateMessage(message, name, emailadress); 638 message = translateMessage(message, name, emailadress);
640 639
641 640
642 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 641 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
643 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); 642 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
644 643
645 QCopEnvelope e(channel.latin1(), message.latin1()); 644 QCopEnvelope e(channel.latin1(), message.latin1());
646 //US we need no names in the To field. The emailadresses are enough 645 //US we need no names in the To field. The emailadresses are enough
647 646
648 passParameters(&e, parameters, name, emailadress); 647 passParameters(&e, parameters, name, emailadress);
649 648
650 649
651#else 650#else
652 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 651 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
653#endif 652#endif
654 653
655 654
656 return true; 655 return true;
657} 656}
658 657
659/************************************************************************** 658/**************************************************************************
660 * 659 *
661 **************************************************************************/ 660 **************************************************************************/
662 661
663//calls the emailapplication and creates a mail with parameter as recipients 662//calls the emailapplication and creates a mail with parameter as recipients
664// parameters format is 663// parameters format is
665// NAME <EMAIL>:SUBJECT 664// NAME <EMAIL>:SUBJECT
666bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 665bool ExternalAppHandler::mailToOneContact( const QString& adressline )
667{ 666{
668 QString line = adressline; 667 QString line = adressline;
669 668
670 int first = line.find( "<"); 669 int first = line.find( "<");
671 int last = line.find( ">"); 670 int last = line.find( ">");
672 QString name = line.left(first); 671 QString name = line.left(first);
673 QString emailadress = line.mid(first+1, last-first-1); 672 QString emailadress = line.mid(first+1, last-first-1);
674 673
675 //Subject can not be handled right now. 674 //Subject can not be handled right now.
676 return mailToOneContact( name, emailadress ); 675 return mailToOneContact( name, emailadress );
677 676
678} 677}
679 678
680 679
681/************************************************************************** 680/**************************************************************************
682 * 681 *
683 **************************************************************************/ 682 **************************************************************************/
684 683
685//calls the phoneapplication with the number 684//calls the phoneapplication with the number
686bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 685bool ExternalAppHandler::callByPhone( const QString& phonenumber )
687{ 686{
688#ifndef DESKTOP_VERSION 687#ifndef DESKTOP_VERSION
689 QString channel; 688 QString channel;
690 QString message; 689 QString message;
691 QString parameters; 690 QString parameters;
692 691
693 692
694 int client = KPimGlobalPrefs::instance()->mPhoneClient; 693 int client = KPimGlobalPrefs::instance()->mPhoneClient;
695 if (client == KPimGlobalPrefs::OTHER_PHC) 694 if (client == KPimGlobalPrefs::OTHER_PHC)
696 { 695 {
697 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 696 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
698 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 697 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
699 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 698 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
700 } 699 }
701 else 700 else
702 { 701 {
703 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 702 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
704 if (!dai) 703 if (!dai)
705 { 704 {
706 qDebug("could not find configured phone application."); 705 qDebug("could not find configured phone application.");
707 return false; 706 return false;
708 } 707 }
709 channel = dai->_channel; 708 channel = dai->_channel;
710 message = dai->_message; 709 message = dai->_message;
711 parameters = dai->_parameters; 710 parameters = dai->_parameters;
712 } 711 }
713 712
714 713
715 //first check if one of the mailers need the emails right in the message. 714 //first check if one of the mailers need the emails right in the message.
716 message = translateMessage(message, phonenumber, ""); 715 message = translateMessage(message, phonenumber, "");
717 716
718 717
719 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 718 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
720 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 719 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
721 720
722 QCopEnvelope e(channel.latin1(), message.latin1()); 721 QCopEnvelope e(channel.latin1(), message.latin1());
723 //US we need no names in the To field. The emailadresses are enough 722 //US we need no names in the To field. The emailadresses are enough
724 723
725 passParameters(&e, parameters, phonenumber, ""); 724 passParameters(&e, parameters, phonenumber, "");
726 725
727 726
728#else 727#else
729 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 728 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
730#endif 729#endif
731 730
732 731
733 return true; 732 return true;
734} 733}
735 734
736/************************************************************************** 735/**************************************************************************
737 * 736 *
738 **************************************************************************/ 737 **************************************************************************/
739 738
740//calls the smsapplication with the number 739//calls the smsapplication with the number
741bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 740bool ExternalAppHandler::callBySMS( const QString& phonenumber )
742{ 741{
743#ifndef DESKTOP_VERSION 742#ifndef DESKTOP_VERSION
744 QString channel; 743 QString channel;
745 QString message; 744 QString message;
746 QString parameters; 745 QString parameters;
747 746
748 747
749 int client = KPimGlobalPrefs::instance()->mSMSClient; 748 int client = KPimGlobalPrefs::instance()->mSMSClient;
750 if (client == KPimGlobalPrefs::OTHER_SMC) 749 if (client == KPimGlobalPrefs::OTHER_SMC)
751 { 750 {
752 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 751 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
753 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 752 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
754 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 753 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
755 } 754 }
756 else 755 else
757 { 756 {
758 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 757 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
759 if (!dai) 758 if (!dai)
760 { 759 {
761 qDebug("could not find configured sms application."); 760 qDebug("could not find configured sms application.");
762 return false; 761 return false;
763 } 762 }
764 channel = dai->_channel; 763 channel = dai->_channel;
765 message = dai->_message; 764 message = dai->_message;
766 parameters = dai->_parameters; 765 parameters = dai->_parameters;
767 } 766 }
768 767
769 768
770 //first check if one of the mailers need the emails right in the message. 769 //first check if one of the mailers need the emails right in the message.
771 message = translateMessage(message, phonenumber, ""); 770 message = translateMessage(message, phonenumber, "");
772 771
773 772
774 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 773 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
775 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 774 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
776 775
777 QCopEnvelope e(channel.latin1(), message.latin1()); 776 QCopEnvelope e(channel.latin1(), message.latin1());
778 //US we need no names in the To field. The emailadresses are enough 777 //US we need no names in the To field. The emailadresses are enough
779 778
780 passParameters(&e, parameters, phonenumber, ""); 779 passParameters(&e, parameters, phonenumber, "");
781 780
782 781
783#else 782#else
784 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); 783 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) );
785#endif 784#endif
786 785
787 786
788 return true; 787 return true;
789} 788}
790 789
791/************************************************************************** 790/**************************************************************************
792 * 791 *
793 **************************************************************************/ 792 **************************************************************************/
794 793
795//calls the pagerapplication with the number 794//calls the pagerapplication with the number
796bool ExternalAppHandler::callByPager( const QString& pagernumber ) 795bool ExternalAppHandler::callByPager( const QString& pagernumber )
797{ 796{
798#ifndef DESKTOP_VERSION 797#ifndef DESKTOP_VERSION
799 QString channel; 798 QString channel;
800 QString message; 799 QString message;
801 QString parameters; 800 QString parameters;
802 801
803 802
804 int client = KPimGlobalPrefs::instance()->mPagerClient; 803 int client = KPimGlobalPrefs::instance()->mPagerClient;
805 if (client == KPimGlobalPrefs::OTHER_PAC) 804 if (client == KPimGlobalPrefs::OTHER_PAC)
806 { 805 {
807 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 806 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
808 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 807 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
809 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 808 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
810 } 809 }
811 else 810 else
812 { 811 {
813 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 812 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
814 if (!dai) 813 if (!dai)
815 { 814 {
816 qDebug("could not find configured pager application."); 815 qDebug("could not find configured pager application.");
817 return false; 816 return false;
818 } 817 }
819 channel = dai->_channel; 818 channel = dai->_channel;
820 message = dai->_message; 819 message = dai->_message;
821 parameters = dai->_parameters; 820 parameters = dai->_parameters;
822 } 821 }
823 822
824 823
825 //first check if one of the mailers need the emails right in the message. 824 //first check if one of the mailers need the emails right in the message.
826 message = translateMessage(message, pagernumber, ""); 825 message = translateMessage(message, pagernumber, "");
827 826
828 827
829 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 828 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
830 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 829 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
831 830
832 QCopEnvelope e(channel.latin1(), message.latin1()); 831 QCopEnvelope e(channel.latin1(), message.latin1());
833 //US we need no names in the To field. The emailadresses are enough 832 //US we need no names in the To field. The emailadresses are enough
834 833
835 passParameters(&e, parameters, pagernumber, ""); 834 passParameters(&e, parameters, pagernumber, "");
836 835
837 836
838#else 837#else
839 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 838 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
840#endif 839#endif
841 840
842 841
843 return true; 842 return true;
844} 843}
845 844
846/************************************************************************** 845/**************************************************************************
847 * 846 *
848 **************************************************************************/ 847 **************************************************************************/
849 848
850//calls the faxapplication with the number 849//calls the faxapplication with the number
851bool ExternalAppHandler::callByFax( const QString& faxnumber ) 850bool ExternalAppHandler::callByFax( const QString& faxnumber )
852{ 851{
853#ifndef DESKTOP_VERSION 852#ifndef DESKTOP_VERSION
854 QString channel; 853 QString channel;
855 QString message; 854 QString message;
856 QString parameters; 855 QString parameters;
857 856
858 857
859 int client = KPimGlobalPrefs::instance()->mFaxClient; 858 int client = KPimGlobalPrefs::instance()->mFaxClient;
860 if (client == KPimGlobalPrefs::OTHER_FAC) 859 if (client == KPimGlobalPrefs::OTHER_FAC)
861 { 860 {
862 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 861 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
863 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 862 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
864 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 863 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
865 } 864 }
866 else 865 else
867 { 866 {
868 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 867 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
869 if (!dai) 868 if (!dai)
870 { 869 {
871 qDebug("could not find configured fax application."); 870 qDebug("could not find configured fax application.");
872 return false; 871 return false;
873 } 872 }
874 channel = dai->_channel; 873 channel = dai->_channel;
875 message = dai->_message; 874 message = dai->_message;
876 parameters = dai->_parameters; 875 parameters = dai->_parameters;
877 } 876 }
878 877
879 878
880 //first check if one of the mailers need the emails right in the message. 879 //first check if one of the mailers need the emails right in the message.
881 message = translateMessage(message, faxnumber, ""); 880 message = translateMessage(message, faxnumber, "");
882 881
883 882
884 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 883 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
885 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 884 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
886 885
887 QCopEnvelope e(channel.latin1(), message.latin1()); 886 QCopEnvelope e(channel.latin1(), message.latin1());
888 //US we need no names in the To field. The emailadresses are enough 887 //US we need no names in the To field. The emailadresses are enough
889 888
890 passParameters(&e, parameters, faxnumber, ""); 889 passParameters(&e, parameters, faxnumber, "");
891 890
892 891
893#else 892#else
894 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 893 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
895#endif 894#endif
896 895
897 896
898 return true; 897 return true;
899} 898}
900 899
901/************************************************************************** 900/**************************************************************************
902 * 901 *
903 **************************************************************************/ 902 **************************************************************************/
904 903
905 904
906QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 905QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
907{ 906{
908 message = message.replace( QRegExp("%1"), param1 ); 907 message = message.replace( QRegExp("%1"), param1 );
909 return message.replace( QRegExp("%2"), param2 ); 908 return message.replace( QRegExp("%2"), param2 );
910} 909}
911 910
912/************************************************************************** 911/**************************************************************************
913 * 912 *
914 **************************************************************************/ 913 **************************************************************************/
915 914
916void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const 915void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
917{ 916{
918#ifndef DESKTOP_VERSION 917#ifndef DESKTOP_VERSION
919 QMap<QString, QString> valmap; 918 QMap<QString, QString> valmap;
920 bool useValMap = false; 919 bool useValMap = false;
921 920
922 // first extract all parts of the parameters. 921 // first extract all parts of the parameters.
923 QStringList paramlist = QStringList::split(";", parameters); 922 QStringList paramlist = QStringList::split(";", parameters);
924 923
925 //Now check how many parts we have. 924 //Now check how many parts we have.
926 //=0 :no params to pass 925 //=0 :no params to pass
927 //>0 :parameters to pass 926 //>0 :parameters to pass
928 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 927 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
929 { 928 {
930 QString param = (*it); 929 QString param = (*it);
931 QStringList keyvallist = QStringList::split("=", param); 930 QStringList keyvallist = QStringList::split("=", param);
932 931
933 //if we have keyvalue pairs, we assume that we pass a map to the envelope 932 //if we have keyvalue pairs, we assume that we pass a map to the envelope
934 QStringList::Iterator it2 = keyvallist.begin(); 933 QStringList::Iterator it2 = keyvallist.begin();
935 QString key = (*it2); 934 QString key = (*it2);