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