summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-08-10 22:40:58 (UTC)
committer ulf69 <ulf69>2004-08-10 22:40:58 (UTC)
commitc1ef5e08dbc5d0b891de75ef8e90e73cc4f3d26f (patch) (unidiff)
treed225831e4aa2af66480dbb7df3a9e56590c8ddbb
parent29abd716e5187a4717a5459b9c25c6c299df8d56 (diff)
downloadkdepimpi-c1ef5e08dbc5d0b891de75ef8e90e73cc4f3d26f.zip
kdepimpi-c1ef5e08dbc5d0b891de75ef8e90e73cc4f3d26f.tar.gz
kdepimpi-c1ef5e08dbc5d0b891de75ef8e90e73cc4f3d26f.tar.bz2
changes on how we call external email application
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp84
1 files changed, 55 insertions, 29 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 5a56d68..1093abf 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -64,71 +64,71 @@ ExternalAppHandler::~ExternalAppHandler()
64{ 64{
65} 65}
66 66
67void ExternalAppHandler::loadConfig() 67void ExternalAppHandler::loadConfig()
68{ 68{
69 69
70 mDefaultItems.clear(); 70 mDefaultItems.clear();
71 71
72 mEmailAppAvailable = UNDEFINED; 72 mEmailAppAvailable = UNDEFINED;
73 mPhoneAppAvailable = UNDEFINED; 73 mPhoneAppAvailable = UNDEFINED;
74 mFaxAppAvailable = UNDEFINED; 74 mFaxAppAvailable = UNDEFINED;
75 mSMSAppAvailable = UNDEFINED; 75 mSMSAppAvailable = UNDEFINED;
76 mPagerAppAvailable = UNDEFINED; 76 mPagerAppAvailable = UNDEFINED;
77 77
78 78
79 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 79 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
80 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 80 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
81 81
82 if (opiepath.isEmpty()) 82 if (opiepath.isEmpty())
83 opiepath = qtopiapath; 83 opiepath = qtopiapath;
84 84
85 //mailclients 85 //mailclients
86 QString mailmsg1 = "writeMail(QString,QString)"; 86 QString mailmsg1 = "writeMail(QString,QString)";
87 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 87 QString mailmsg2 = "writeMail(QMap(QString,QString))";
88 88
89 QString undefined = ""; 89 QString undefined = "";
90 90
91 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 91 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
92 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 92 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
93 93
94 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 94 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
95 ( QFile::exists( opiepath + "/bin/ompi" ))) 95 ( QFile::exists( opiepath + "/bin/ompi" )))
96 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", "newMail(QString)", "%1", mailmsg2, "ATTACHMENT=%1"); 96 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
97 97
98 if ( QFile::exists( qtopiapath + "/bin/qtmail" )) 98 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
99 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, ";%1", mailmsg2, "ATTACHMENT=%1"); 99 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
100 100
101 if ( QFile::exists( opiepath + "/bin/opiemail" )) 101 if ( QFile::exists( opiepath + "/bin/opiemail" ))
102 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, ";%1", mailmsg2, "ATTACHMENT=%1"); 102 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
103 103
104 104
105 105
106 //phoneclients 106 //phoneclients
107 107
108 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 108 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
109 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 109 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
110 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 110 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
111 ( QFile::exists( opiepath + "/bin/kppi" ))) 111 ( QFile::exists( opiepath + "/bin/kppi" )))
112 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 112 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
113 113
114 //faxclients 114 //faxclients
115 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 115 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
116 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 116 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
117 117
118 //smsclients 118 //smsclients
119 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 119 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
120 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 120 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
121 121
122 //pagerclients 122 //pagerclients
123 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 123 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
124 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 124 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
125 125
126} 126}
127 127
128ExternalAppHandler *ExternalAppHandler::instance() 128ExternalAppHandler *ExternalAppHandler::instance()
129{ 129{
130 if ( !sInstance ) { 130 if ( !sInstance ) {
131 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 131 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
132 sInstance->loadConfig(); 132 sInstance->loadConfig();
133 } 133 }
134 134
@@ -238,417 +238,443 @@ bool ExternalAppHandler::isFaxAppAvailable()
238 } 238 }
239 239
240 return (mFaxAppAvailable == AVAILABLE); 240 return (mFaxAppAvailable == AVAILABLE);
241#else //DESKTOP_VERSION 241#else //DESKTOP_VERSION
242 return false; 242 return false;
243#endif //DESKTOP_VERSION 243#endif //DESKTOP_VERSION
244} 244}
245 245
246bool ExternalAppHandler::isPagerAppAvailable() 246bool ExternalAppHandler::isPagerAppAvailable()
247{ 247{
248#ifndef DESKTOP_VERSION 248#ifndef DESKTOP_VERSION
249 if (mPagerAppAvailable == UNDEFINED) 249 if (mPagerAppAvailable == UNDEFINED)
250 { 250 {
251 int client = KPimGlobalPrefs::instance()->mPagerClient; 251 int client = KPimGlobalPrefs::instance()->mPagerClient;
252 if (client == KPimGlobalPrefs::NONE_PAC) 252 if (client == KPimGlobalPrefs::NONE_PAC)
253 mPagerAppAvailable = UNAVAILABLE; 253 mPagerAppAvailable = UNAVAILABLE;
254 else 254 else
255 mPagerAppAvailable = AVAILABLE; 255 mPagerAppAvailable = AVAILABLE;
256 } 256 }
257 257
258 return (mPagerAppAvailable == AVAILABLE); 258 return (mPagerAppAvailable == AVAILABLE);
259#else //DESKTOP_VERSION 259#else //DESKTOP_VERSION
260 return false; 260 return false;
261#endif //DESKTOP_VERSION 261#endif //DESKTOP_VERSION
262} 262}
263 263
264/************************************************************************** 264/**************************************************************************
265 * 265 *
266 **************************************************************************/ 266 **************************************************************************/
267 267
268 268
269//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 269//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
270bool ExternalAppHandler::mailAttachments( const QString& urls ) 270bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
271{ 271{
272 272
273#ifndef DESKTOP_VERSION 273#ifndef DESKTOP_VERSION
274 QString channel; 274 QString channel;
275 QString message2; 275 QString message2;
276 QString parameters2; 276 QString parameters2;
277 277
278 278
279 int client = KPimGlobalPrefs::instance()->mEmailClient; 279 int client = KPimGlobalPrefs::instance()->mEmailClient;
280 if (client == KPimGlobalPrefs::OTHER_EMC) 280 if (client == KPimGlobalPrefs::OTHER_EMC)
281 { 281 {
282 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 282 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
283 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 283 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
284 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 284 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
285 } 285 }
286 else 286 else
287 { 287 {
288 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 288 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
289 if (!dai) 289 if (!dai)
290 { 290 {
291 qDebug("could not find configured email application."); 291 qDebug("could not find configured email application.");
292 return false; 292 return false;
293 } 293 }
294 channel = dai->_channel; 294 channel = dai->_channel;
295 message2 = dai->_message2; 295 message2 = dai->_message2;
296 parameters2 = dai->_parameters2; 296 parameters2 = dai->_parameters2;
297 } 297 }
298 298
299 //first check if one of the mailers need the emails right in the message.
300 message2 = translateMessage(message2, emails, urls);
301
299 302
300 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 303 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
301 qDebug("passing attachmenturls:(%s) as parameter in the form %s to QCopEnvelope", urls.latin1(), parameters2.latin1()); 304 qDebug("passing emailadresses:(%s), attachmenturls:(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
302 305
303 306
304 QCopEnvelope e(channel.latin1(), message2.latin1()); 307 QCopEnvelope e(channel.latin1(), message2.latin1());
305 //US we need no names in the To field. The emailadresses are enough 308 //US we need no names in the To field. The emailadresses are enough
306 309
307 passParameter(&e, parameters2, urls); 310 passParameters(&e, parameters2, emails, urls);
308 311
309 312
310 313
311#else 314#else
312 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 315 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
313#endif 316#endif
314 317
315 return true; 318 return true;
316} 319}
317 320
318/************************************************************************** 321/**************************************************************************
319 * 322 *
320 **************************************************************************/ 323 **************************************************************************/
321 324
322 325
323//calls the emailapplication and creates a mail with parameter emails as recipients 326//calls the emailapplication and creates a mail with parameter emails as recipients
324bool ExternalAppHandler::mailToContacts( const QString& emails ) 327bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
325{ 328{
326#ifndef DESKTOP_VERSION 329#ifndef DESKTOP_VERSION
327 QString channel; 330 QString channel;
328 QString message; 331 QString message;
329 QString parameters; 332 QString parameters;
330 333
331 334
332 int client = KPimGlobalPrefs::instance()->mEmailClient; 335 int client = KPimGlobalPrefs::instance()->mEmailClient;
333 if (client == KPimGlobalPrefs::OTHER_EMC) 336 if (client == KPimGlobalPrefs::OTHER_EMC)
334 { 337 {
335 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 338 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
336 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 339 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
337 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 340 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
338 } 341 }
339 else 342 else
340 { 343 {
341 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 344 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
342 if (!dai) 345 if (!dai)
343 { 346 {
344 qDebug("could not find configured email application."); 347 qDebug("could not find configured email application.");
345 return false; 348 return false;
346 } 349 }
347 channel = dai->_channel; 350 channel = dai->_channel;
348 message = dai->_message; 351 message = dai->_message;
349 parameters = dai->_parameters; 352 parameters = dai->_parameters;
350 } 353 }
351 354
352 355
353 //first check if one of the mailers need the emails right in the message. 356 //first check if one of the mailers need the emails right in the message.
354 message = translateMessage(message, emails); 357 message = translateMessage(message, name, emailadress);
355 358
356 359
357 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 360 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
358 qDebug("passing emailadresses:(%s) as parameter in the form %s to QCopEnvelope", emails.latin1(), parameters.latin1()); 361 qDebug("passing name:(%s), emailadresses:(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
359 362
360 QCopEnvelope e(channel.latin1(), message.latin1()); 363 QCopEnvelope e(channel.latin1(), message.latin1());
361 //US we need no names in the To field. The emailadresses are enough 364 //US we need no names in the To field. The emailadresses are enough
362 365
363 passParameter(&e, parameters, emails); 366 passParameters(&e, parameters, name, emailadress);
364 367
365 368
366#else 369#else
367 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 370 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
368#endif 371#endif
369 372
370 373
371 return true; 374 return true;
372} 375}
373 376
374/************************************************************************** 377/**************************************************************************
375 * 378 *
376 **************************************************************************/ 379 **************************************************************************/
377 380
381//calls the emailapplication and creates a mail with parameter as recipients
382// parameters format is
383// NAME <EMAIL>:SUBJECT
384bool ExternalAppHandler::mailToOneContact( const QString& adressline )
385{
386 QString line = adressline;
387
388 int first = line.find( "<");
389 int last = line.find( ">");
390 QString name = line.left(first);
391 QString emailadress = line.mid(first+1, last-first-1);
392
393 //Subject can not be handled right now.
394 mailToOneContact( name, emailadress );
395}
396
397
398/**************************************************************************
399 *
400 **************************************************************************/
401
378//calls the phoneapplication with the number 402//calls the phoneapplication with the number
379bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 403bool ExternalAppHandler::callByPhone( const QString& phonenumber )
380{ 404{
381#ifndef DESKTOP_VERSION 405#ifndef DESKTOP_VERSION
382 QString channel; 406 QString channel;
383 QString message; 407 QString message;
384 QString parameters; 408 QString parameters;
385 409
386 410
387 int client = KPimGlobalPrefs::instance()->mPhoneClient; 411 int client = KPimGlobalPrefs::instance()->mPhoneClient;
388 if (client == KPimGlobalPrefs::OTHER_PHC) 412 if (client == KPimGlobalPrefs::OTHER_PHC)
389 { 413 {
390 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 414 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
391 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 415 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
392 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 416 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
393 } 417 }
394 else 418 else
395 { 419 {
396 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 420 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
397 if (!dai) 421 if (!dai)
398 { 422 {
399 qDebug("could not find configured phone application."); 423 qDebug("could not find configured phone application.");
400 return false; 424 return false;
401 } 425 }
402 channel = dai->_channel; 426 channel = dai->_channel;
403 message = dai->_message; 427 message = dai->_message;
404 parameters = dai->_parameters; 428 parameters = dai->_parameters;
405 } 429 }
406 430
407 431
408 //first check if one of the mailers need the emails right in the message. 432 //first check if one of the mailers need the emails right in the message.
409 message = translateMessage(message, phonenumber); 433 message = translateMessage(message, phonenumber, "");
410 434
411 435
412 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 436 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
413 qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 437 qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
414 438
415 QCopEnvelope e(channel.latin1(), message.latin1()); 439 QCopEnvelope e(channel.latin1(), message.latin1());
416 //US we need no names in the To field. The emailadresses are enough 440 //US we need no names in the To field. The emailadresses are enough
417 441
418 passParameter(&e, parameters, phonenumber); 442 passParameters(&e, parameters, phonenumber, "");
419 443
420 444
421#else 445#else
422 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 446 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
423#endif 447#endif
424 448
425 449
426 return true; 450 return true;
427} 451}
428 452
429/************************************************************************** 453/**************************************************************************
430 * 454 *
431 **************************************************************************/ 455 **************************************************************************/
432 456
433//calls the smsapplication with the number 457//calls the smsapplication with the number
434bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 458bool ExternalAppHandler::callBySMS( const QString& phonenumber )
435{ 459{
436#ifndef DESKTOP_VERSION 460#ifndef DESKTOP_VERSION
437 QString channel; 461 QString channel;
438 QString message; 462 QString message;
439 QString parameters; 463 QString parameters;
440 464
441 465
442 int client = KPimGlobalPrefs::instance()->mSMSClient; 466 int client = KPimGlobalPrefs::instance()->mSMSClient;
443 if (client == KPimGlobalPrefs::OTHER_SMC) 467 if (client == KPimGlobalPrefs::OTHER_SMC)
444 { 468 {
445 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 469 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
446 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 470 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
447 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 471 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
448 } 472 }
449 else 473 else
450 { 474 {
451 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 475 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
452 if (!dai) 476 if (!dai)
453 { 477 {
454 qDebug("could not find configured sms application."); 478 qDebug("could not find configured sms application.");
455 return false; 479 return false;
456 } 480 }
457 channel = dai->_channel; 481 channel = dai->_channel;
458 message = dai->_message; 482 message = dai->_message;
459 parameters = dai->_parameters; 483 parameters = dai->_parameters;
460 } 484 }
461 485
462 486
463 //first check if one of the mailers need the emails right in the message. 487 //first check if one of the mailers need the emails right in the message.
464 message = translateMessage(message, phonenumber); 488 message = translateMessage(message, phonenumber, "");
465 489
466 490
467 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 491 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
468 qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 492 qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
469 493
470 QCopEnvelope e(channel.latin1(), message.latin1()); 494 QCopEnvelope e(channel.latin1(), message.latin1());
471 //US we need no names in the To field. The emailadresses are enough 495 //US we need no names in the To field. The emailadresses are enough
472 496
473 passParameter(&e, parameters, phonenumber); 497 passParameters(&e, parameters, phonenumber, "");
474 498
475 499
476#else 500#else
477 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); 501 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) );
478#endif 502#endif
479 503
480 504
481 return true; 505 return true;
482} 506}
483 507
484/************************************************************************** 508/**************************************************************************
485 * 509 *
486 **************************************************************************/ 510 **************************************************************************/
487 511
488//calls the pagerapplication with the number 512//calls the pagerapplication with the number
489bool ExternalAppHandler::callByPager( const QString& pagernumber ) 513bool ExternalAppHandler::callByPager( const QString& pagernumber )
490{ 514{
491#ifndef DESKTOP_VERSION 515#ifndef DESKTOP_VERSION
492 QString channel; 516 QString channel;
493 QString message; 517 QString message;
494 QString parameters; 518 QString parameters;
495 519
496 520
497 int client = KPimGlobalPrefs::instance()->mPagerClient; 521 int client = KPimGlobalPrefs::instance()->mPagerClient;
498 if (client == KPimGlobalPrefs::OTHER_PAC) 522 if (client == KPimGlobalPrefs::OTHER_PAC)
499 { 523 {
500 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 524 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
501 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 525 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
502 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 526 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
503 } 527 }
504 else 528 else
505 { 529 {
506 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 530 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
507 if (!dai) 531 if (!dai)
508 { 532 {
509 qDebug("could not find configured pager application."); 533 qDebug("could not find configured pager application.");
510 return false; 534 return false;
511 } 535 }
512 channel = dai->_channel; 536 channel = dai->_channel;
513 message = dai->_message; 537 message = dai->_message;
514 parameters = dai->_parameters; 538 parameters = dai->_parameters;
515 } 539 }
516 540
517 541
518 //first check if one of the mailers need the emails right in the message. 542 //first check if one of the mailers need the emails right in the message.
519 message = translateMessage(message, pagernumber); 543 message = translateMessage(message, pagernumber, "");
520 544
521 545
522 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 546 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
523 qDebug("passing pagernumber:(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 547 qDebug("passing pagernumber:(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
524 548
525 QCopEnvelope e(channel.latin1(), message.latin1()); 549 QCopEnvelope e(channel.latin1(), message.latin1());
526 //US we need no names in the To field. The emailadresses are enough 550 //US we need no names in the To field. The emailadresses are enough
527 551
528 passParameter(&e, parameters, pagernumber); 552 passParameters(&e, parameters, pagernumber, "");
529 553
530 554
531#else 555#else
532 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 556 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
533#endif 557#endif
534 558
535 559
536 return true; 560 return true;
537} 561}
538 562
539/************************************************************************** 563/**************************************************************************
540 * 564 *
541 **************************************************************************/ 565 **************************************************************************/
542 566
543//calls the faxapplication with the number 567//calls the faxapplication with the number
544bool ExternalAppHandler::callByFax( const QString& faxnumber ) 568bool ExternalAppHandler::callByFax( const QString& faxnumber )
545{ 569{
546#ifndef DESKTOP_VERSION 570#ifndef DESKTOP_VERSION
547 QString channel; 571 QString channel;
548 QString message; 572 QString message;
549 QString parameters; 573 QString parameters;
550 574
551 575
552 int client = KPimGlobalPrefs::instance()->mFaxClient; 576 int client = KPimGlobalPrefs::instance()->mFaxClient;
553 if (client == KPimGlobalPrefs::OTHER_FAC) 577 if (client == KPimGlobalPrefs::OTHER_FAC)
554 { 578 {
555 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 579 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
556 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 580 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
557 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 581 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
558 } 582 }
559 else 583 else
560 { 584 {
561 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 585 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
562 if (!dai) 586 if (!dai)
563 { 587 {
564 qDebug("could not find configured fax application."); 588 qDebug("could not find configured fax application.");
565 return false; 589 return false;
566 } 590 }
567 channel = dai->_channel; 591 channel = dai->_channel;
568 message = dai->_message; 592 message = dai->_message;
569 parameters = dai->_parameters; 593 parameters = dai->_parameters;
570 } 594 }
571 595
572 596
573 //first check if one of the mailers need the emails right in the message. 597 //first check if one of the mailers need the emails right in the message.
574 message = translateMessage(message, faxnumber); 598 message = translateMessage(message, faxnumber, "");
575 599
576 600
577 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 601 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
578 qDebug("passing faxnumber:(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 602 qDebug("passing faxnumber:(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
579 603
580 QCopEnvelope e(channel.latin1(), message.latin1()); 604 QCopEnvelope e(channel.latin1(), message.latin1());
581 //US we need no names in the To field. The emailadresses are enough 605 //US we need no names in the To field. The emailadresses are enough
582 606
583 passParameter(&e, parameters, faxnumber); 607 passParameters(&e, parameters, faxnumber, "");
584 608
585 609
586#else 610#else
587 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 611 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
588#endif 612#endif
589 613
590 614
591 return true; 615 return true;
592} 616}
593 617
594/************************************************************************** 618/**************************************************************************
595 * 619 *
596 **************************************************************************/ 620 **************************************************************************/
597 621
598 622
599 623QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
600QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1) const
601{ 624{
602 return message.replace( QRegExp("%1"), param1 ); 625 message = message.replace( QRegExp("%1"), param1 );
626 return message.replace( QRegExp("%2"), param2 );
603} 627}
604 628
605/************************************************************************** 629/**************************************************************************
606 * 630 *
607 **************************************************************************/ 631 **************************************************************************/
608 632
609void ExternalAppHandler::passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const 633void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
610{ 634{
611#ifndef DESKTOP_VERSION 635#ifndef DESKTOP_VERSION
612 QMap<QString, QString> valmap; 636 QMap<QString, QString> valmap;
613 bool useValMap = false; 637 bool useValMap = false;
614 638
615 // first extract all parts of the parameters. 639 // first extract all parts of the parameters.
616 QStringList paramlist = QStringList::split(";", parameters); 640 QStringList paramlist = QStringList::split(";", parameters);
617 641
618 //Now check how many parts we have. 642 //Now check how many parts we have.
619 //=0 :no params to pass 643 //=0 :no params to pass
620 //>0 :parameters to pass 644 //>0 :parameters to pass
621 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 645 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
622 { 646 {
623 QString param = (*it); 647 QString param = (*it);
624 QStringList keyvallist = QStringList::split("=", param); 648 QStringList keyvallist = QStringList::split("=", param);
625 649
626 //if we have keyvalue pairs, we assume that we pass a map to the envelope 650 //if we have keyvalue pairs, we assume that we pass a map to the envelope
627 QStringList::Iterator it2 = keyvallist.begin(); 651 QStringList::Iterator it2 = keyvallist.begin();
628 QString key = (*it2); 652 QString key = (*it2);
629 key = key.replace( QRegExp("%1"), param1 ); 653 key = key.replace( QRegExp("%1"), param1 );
654 key = key.replace( QRegExp("%2"), param2 );
630 ++it2; 655 ++it2;
631 656
632 if(it2 != keyvallist.end()) 657 if(it2 != keyvallist.end())
633 { 658 {
634 QString value = (*it2); 659 QString value = (*it2);
635 value = value.replace( QRegExp("%1"), param1 ); 660 value = value.replace( QRegExp("%1"), param1 );
661 value = value.replace( QRegExp("%2"), param2 );
636 662
637 valmap.insert(key, value); 663 valmap.insert(key, value);
638 useValMap = true; 664 useValMap = true;
639 } 665 }
640 else 666 else
641 { 667 {
642 (*e) << key.latin1(); 668 (*e) << key.latin1();
643 } 669 }
644 } 670 }
645 671
646 if (useValMap == true) 672 if (useValMap == true)
647 (*e) << valmap; 673 (*e) << valmap;
648 674
649#endif 675#endif
650 676
651} 677}
652 678
653 679
654 680