summaryrefslogtreecommitdiffabout
path: root/libkdepim/externalapphandler.cpp
Unidiff
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp128
1 files changed, 125 insertions, 3 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 0128cf7..5a56d68 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -45,63 +45,69 @@ $Id$
45 45
46#include "kpimglobalprefs.h" 46#include "kpimglobalprefs.h"
47 47
48 48
49 49
50 50
51 51
52 52
53 53
54ExternalAppHandler *ExternalAppHandler::sInstance = 0; 54ExternalAppHandler *ExternalAppHandler::sInstance = 0;
55static KStaticDeleter<ExternalAppHandler> staticDeleter; 55static KStaticDeleter<ExternalAppHandler> staticDeleter;
56 56
57 57
58ExternalAppHandler::ExternalAppHandler() 58ExternalAppHandler::ExternalAppHandler()
59{ 59{
60 mDefaultItems.setAutoDelete(true); 60 mDefaultItems.setAutoDelete(true);
61} 61}
62 62
63ExternalAppHandler::~ExternalAppHandler() 63ExternalAppHandler::~ExternalAppHandler()
64{ 64{
65} 65}
66 66
67void ExternalAppHandler::loadConfig() 67void ExternalAppHandler::loadConfig()
68{ 68{
69
69 mDefaultItems.clear(); 70 mDefaultItems.clear();
70 71
72 mEmailAppAvailable = UNDEFINED;
73 mPhoneAppAvailable = UNDEFINED;
74 mFaxAppAvailable = UNDEFINED;
75 mSMSAppAvailable = UNDEFINED;
76 mPagerAppAvailable = UNDEFINED;
71 77
72 78
73 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 79 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
74 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 80 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
75 81
76 if (opiepath.isEmpty()) 82 if (opiepath.isEmpty())
77 opiepath = qtopiapath; 83 opiepath = qtopiapath;
78 84
79 //mailclients 85 //mailclients
80 QString mailmsg1 = "writeMail(QString,QString)"; 86 QString mailmsg1 = "writeMail(QString,QString)";
81 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 87 QString mailmsg2 = "writeMail(QMap(QString,QString))";
82 88
83 QString undefined = "undefined"; 89 QString undefined = "";
84 90
85 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);
86 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);
87 93
88 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 94 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
89 ( QFile::exists( opiepath + "/bin/ompi" ))) 95 ( QFile::exists( opiepath + "/bin/ompi" )))
90 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", "newMail(QString)", "%1", mailmsg2, "ATTACHMENT=%1");
91 97
92 if ( QFile::exists( qtopiapath + "/bin/qtmail" )) 98 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
93 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", mailmsg2, "ATTACHMENT=%1");
94 100
95 if ( QFile::exists( opiepath + "/bin/opiemail" )) 101 if ( QFile::exists( opiepath + "/bin/opiemail" ))
96 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", mailmsg2, "ATTACHMENT=%1");
97 103
98 104
99 105
100 //phoneclients 106 //phoneclients
101 107
102 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);
103 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);
104 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 110 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
105 ( QFile::exists( opiepath + "/bin/kppi" ))) 111 ( QFile::exists( opiepath + "/bin/kppi" )))
106 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);
107 113
@@ -144,48 +150,141 @@ QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
144 DefaultAppItem* dai; 150 DefaultAppItem* dai;
145 151
146 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 152 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
147 { 153 {
148 if (dai->_type == type) 154 if (dai->_type == type)
149 list.append(dai); 155 list.append(dai);
150 } 156 }
151 157
152 return list; 158 return list;
153} 159}
154 160
155DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 161DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
156{ 162{
157 DefaultAppItem* dai; 163 DefaultAppItem* dai;
158 164
159 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 165 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
160 { 166 {
161 if (dai->_type == type && dai->_id == clientid) 167 if (dai->_type == type && dai->_id == clientid)
162 return dai; 168 return dai;
163 } 169 }
164 170
165 return 0; 171 return 0;
166} 172}
167 173
174bool ExternalAppHandler::isEmailAppAvailable()
175{
176#ifndef DESKTOP_VERSION
177 if (mEmailAppAvailable == UNDEFINED)
178 {
179 int client = KPimGlobalPrefs::instance()->mEmailClient;
180 if (client == KPimGlobalPrefs::NONE_EMC)
181 mEmailAppAvailable = UNAVAILABLE;
182 else
183 mEmailAppAvailable = AVAILABLE;
184 }
185 return (mEmailAppAvailable == AVAILABLE);
186
187#else //DESKTOP_VERSION
188 return false;
189#endif //DESKTOP_VERSION
190}
191
192bool ExternalAppHandler::isSMSAppAvailable()
193{
194#ifndef DESKTOP_VERSION
195 if (mSMSAppAvailable == UNDEFINED)
196 {
197 int client = KPimGlobalPrefs::instance()->mSMSClient;
198 if (client == KPimGlobalPrefs::NONE_SMC)
199 mSMSAppAvailable = UNAVAILABLE;
200 else
201 mSMSAppAvailable = AVAILABLE;
202 }
203
204 return (mSMSAppAvailable == AVAILABLE);
205#else //DESKTOP_VERSION
206 return false;
207#endif //DESKTOP_VERSION
208}
209
210bool ExternalAppHandler::isPhoneAppAvailable()
211{
212#ifndef DESKTOP_VERSION
213 if (mPhoneAppAvailable == UNDEFINED)
214 {
215 int client = KPimGlobalPrefs::instance()->mPhoneClient;
216 if (client == KPimGlobalPrefs::NONE_PHC)
217 mPhoneAppAvailable = UNAVAILABLE;
218 else
219 mPhoneAppAvailable = AVAILABLE;
220 }
221
222 return (mPhoneAppAvailable == AVAILABLE);
223#else //DESKTOP_VERSION
224 return false;
225#endif //DESKTOP_VERSION
226}
227
228bool ExternalAppHandler::isFaxAppAvailable()
229{
230#ifndef DESKTOP_VERSION
231 if (mFaxAppAvailable == UNDEFINED)
232 {
233 int client = KPimGlobalPrefs::instance()->mFaxClient;
234 if (client == KPimGlobalPrefs::NONE_FAC)
235 mFaxAppAvailable = UNAVAILABLE;
236 else
237 mFaxAppAvailable = AVAILABLE;
238 }
239
240 return (mFaxAppAvailable == AVAILABLE);
241#else //DESKTOP_VERSION
242 return false;
243#endif //DESKTOP_VERSION
244}
245
246bool ExternalAppHandler::isPagerAppAvailable()
247{
248#ifndef DESKTOP_VERSION
249 if (mPagerAppAvailable == UNDEFINED)
250 {
251 int client = KPimGlobalPrefs::instance()->mPagerClient;
252 if (client == KPimGlobalPrefs::NONE_PAC)
253 mPagerAppAvailable = UNAVAILABLE;
254 else
255 mPagerAppAvailable = AVAILABLE;
256 }
257
258 return (mPagerAppAvailable == AVAILABLE);
259#else //DESKTOP_VERSION
260 return false;
261#endif //DESKTOP_VERSION
262}
263
264/**************************************************************************
265 *
266 **************************************************************************/
168 267
169 268
170//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)
171bool ExternalAppHandler::mailAttachments( const QString& urls ) 270bool ExternalAppHandler::mailAttachments( const QString& urls )
172{ 271{
173 272
174#ifndef DESKTOP_VERSION 273#ifndef DESKTOP_VERSION
175 QString channel; 274 QString channel;
176 QString message2; 275 QString message2;
177 QString parameters2; 276 QString parameters2;
178 277
179 278
180 int client = KPimGlobalPrefs::instance()->mEmailClient; 279 int client = KPimGlobalPrefs::instance()->mEmailClient;
181 if (client == KPimGlobalPrefs::OTHER_EMC) 280 if (client == KPimGlobalPrefs::OTHER_EMC)
182 { 281 {
183 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 282 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
184 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 283 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
185 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 284 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
186 } 285 }
187 else 286 else
188 { 287 {
189 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 288 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
190 if (!dai) 289 if (!dai)
191 { 290 {
@@ -195,48 +294,51 @@ bool ExternalAppHandler::mailAttachments( const QString& urls )
195 channel = dai->_channel; 294 channel = dai->_channel;
196 message2 = dai->_message2; 295 message2 = dai->_message2;
197 parameters2 = dai->_parameters2; 296 parameters2 = dai->_parameters2;
198 } 297 }
199 298
200 299
201 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 300 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
202 qDebug("passing attachmenturls:(%s) as parameter in the form %s to QCopEnvelope", urls.latin1(), parameters2.latin1()); 301 qDebug("passing attachmenturls:(%s) as parameter in the form %s to QCopEnvelope", urls.latin1(), parameters2.latin1());
203 302
204 303
205 QCopEnvelope e(channel.latin1(), message2.latin1()); 304 QCopEnvelope e(channel.latin1(), message2.latin1());
206 //US we need no names in the To field. The emailadresses are enough 305 //US we need no names in the To field. The emailadresses are enough
207 306
208 passParameter(&e, parameters2, urls); 307 passParameter(&e, parameters2, urls);
209 308
210 309
211 310
212#else 311#else
213 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 312 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
214#endif 313#endif
215 314
216 return true; 315 return true;
217} 316}
218 317
318/**************************************************************************
319 *
320 **************************************************************************/
219 321
220 322
221//calls the emailapplication and creates a mail with parameter emails as recipients 323//calls the emailapplication and creates a mail with parameter emails as recipients
222bool ExternalAppHandler::mailToContacts( const QString& emails ) 324bool ExternalAppHandler::mailToContacts( const QString& emails )
223{ 325{
224#ifndef DESKTOP_VERSION 326#ifndef DESKTOP_VERSION
225 QString channel; 327 QString channel;
226 QString message; 328 QString message;
227 QString parameters; 329 QString parameters;
228 330
229 331
230 int client = KPimGlobalPrefs::instance()->mEmailClient; 332 int client = KPimGlobalPrefs::instance()->mEmailClient;
231 if (client == KPimGlobalPrefs::OTHER_EMC) 333 if (client == KPimGlobalPrefs::OTHER_EMC)
232 { 334 {
233 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 335 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
234 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 336 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
235 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 337 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
236 } 338 }
237 else 339 else
238 { 340 {
239 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 341 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
240 if (!dai) 342 if (!dai)
241 { 343 {
242 qDebug("could not find configured email application."); 344 qDebug("could not find configured email application.");
@@ -248,48 +350,51 @@ bool ExternalAppHandler::mailToContacts( const QString& emails )
248 } 350 }
249 351
250 352
251 //first check if one of the mailers need the emails right in the message. 353 //first check if one of the mailers need the emails right in the message.
252 message = translateMessage(message, emails); 354 message = translateMessage(message, emails);
253 355
254 356
255 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 357 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
256 qDebug("passing emailadresses:(%s) as parameter in the form %s to QCopEnvelope", emails.latin1(), parameters.latin1()); 358 qDebug("passing emailadresses:(%s) as parameter in the form %s to QCopEnvelope", emails.latin1(), parameters.latin1());
257 359
258 QCopEnvelope e(channel.latin1(), message.latin1()); 360 QCopEnvelope e(channel.latin1(), message.latin1());
259 //US we need no names in the To field. The emailadresses are enough 361 //US we need no names in the To field. The emailadresses are enough
260 362
261 passParameter(&e, parameters, emails); 363 passParameter(&e, parameters, emails);
262 364
263 365
264#else 366#else
265 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 367 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
266#endif 368#endif
267 369
268 370
269 return true; 371 return true;
270} 372}
271 373
374/**************************************************************************
375 *
376 **************************************************************************/
272 377
273//calls the phoneapplication with the number 378//calls the phoneapplication with the number
274bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 379bool ExternalAppHandler::callByPhone( const QString& phonenumber )
275{ 380{
276#ifndef DESKTOP_VERSION 381#ifndef DESKTOP_VERSION
277 QString channel; 382 QString channel;
278 QString message; 383 QString message;
279 QString parameters; 384 QString parameters;
280 385
281 386
282 int client = KPimGlobalPrefs::instance()->mPhoneClient; 387 int client = KPimGlobalPrefs::instance()->mPhoneClient;
283 if (client == KPimGlobalPrefs::OTHER_PHC) 388 if (client == KPimGlobalPrefs::OTHER_PHC)
284 { 389 {
285 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 390 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
286 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 391 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
287 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 392 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
288 } 393 }
289 else 394 else
290 { 395 {
291 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 396 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
292 if (!dai) 397 if (!dai)
293 { 398 {
294 qDebug("could not find configured phone application."); 399 qDebug("could not find configured phone application.");
295 return false; 400 return false;
@@ -300,48 +405,52 @@ bool ExternalAppHandler::callByPhone( const QString& phonenumber )
300 } 405 }
301 406
302 407
303 //first check if one of the mailers need the emails right in the message. 408 //first check if one of the mailers need the emails right in the message.
304 message = translateMessage(message, phonenumber); 409 message = translateMessage(message, phonenumber);
305 410
306 411
307 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 412 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
308 qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 413 qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
309 414
310 QCopEnvelope e(channel.latin1(), message.latin1()); 415 QCopEnvelope e(channel.latin1(), message.latin1());
311 //US we need no names in the To field. The emailadresses are enough 416 //US we need no names in the To field. The emailadresses are enough
312 417
313 passParameter(&e, parameters, phonenumber); 418 passParameter(&e, parameters, phonenumber);
314 419
315 420
316#else 421#else
317 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 422 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
318#endif 423#endif
319 424
320 425
321 return true; 426 return true;
322} 427}
323 428
429/**************************************************************************
430 *
431 **************************************************************************/
432
324//calls the smsapplication with the number 433//calls the smsapplication with the number
325bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 434bool ExternalAppHandler::callBySMS( const QString& phonenumber )
326{ 435{
327#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
328 QString channel; 437 QString channel;
329 QString message; 438 QString message;
330 QString parameters; 439 QString parameters;
331 440
332 441
333 int client = KPimGlobalPrefs::instance()->mSMSClient; 442 int client = KPimGlobalPrefs::instance()->mSMSClient;
334 if (client == KPimGlobalPrefs::OTHER_SMC) 443 if (client == KPimGlobalPrefs::OTHER_SMC)
335 { 444 {
336 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 445 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
337 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 446 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
338 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 447 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
339 } 448 }
340 else 449 else
341 { 450 {
342 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 451 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
343 if (!dai) 452 if (!dai)
344 { 453 {
345 qDebug("could not find configured sms application."); 454 qDebug("could not find configured sms application.");
346 return false; 455 return false;
347 } 456 }
@@ -351,48 +460,52 @@ bool ExternalAppHandler::callBySMS( const QString& phonenumber )
351 } 460 }
352 461
353 462
354 //first check if one of the mailers need the emails right in the message. 463 //first check if one of the mailers need the emails right in the message.
355 message = translateMessage(message, phonenumber); 464 message = translateMessage(message, phonenumber);
356 465
357 466
358 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 467 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
359 qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 468 qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
360 469
361 QCopEnvelope e(channel.latin1(), message.latin1()); 470 QCopEnvelope e(channel.latin1(), message.latin1());
362 //US we need no names in the To field. The emailadresses are enough 471 //US we need no names in the To field. The emailadresses are enough
363 472
364 passParameter(&e, parameters, phonenumber); 473 passParameter(&e, parameters, phonenumber);
365 474
366 475
367#else 476#else
368 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); 477 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) );
369#endif 478#endif
370 479
371 480
372 return true; 481 return true;
373} 482}
374 483
484/**************************************************************************
485 *
486 **************************************************************************/
487
375//calls the pagerapplication with the number 488//calls the pagerapplication with the number
376bool ExternalAppHandler::callByPager( const QString& pagernumber ) 489bool ExternalAppHandler::callByPager( const QString& pagernumber )
377{ 490{
378#ifndef DESKTOP_VERSION 491#ifndef DESKTOP_VERSION
379 QString channel; 492 QString channel;
380 QString message; 493 QString message;
381 QString parameters; 494 QString parameters;
382 495
383 496
384 int client = KPimGlobalPrefs::instance()->mPagerClient; 497 int client = KPimGlobalPrefs::instance()->mPagerClient;
385 if (client == KPimGlobalPrefs::OTHER_PAC) 498 if (client == KPimGlobalPrefs::OTHER_PAC)
386 { 499 {
387 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 500 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
388 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 501 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
389 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 502 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
390 } 503 }
391 else 504 else
392 { 505 {
393 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 506 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
394 if (!dai) 507 if (!dai)
395 { 508 {
396 qDebug("could not find configured pager application."); 509 qDebug("could not find configured pager application.");
397 return false; 510 return false;
398 } 511 }
@@ -402,48 +515,52 @@ bool ExternalAppHandler::callByPager( const QString& pagernumber )
402 } 515 }
403 516
404 517
405 //first check if one of the mailers need the emails right in the message. 518 //first check if one of the mailers need the emails right in the message.
406 message = translateMessage(message, pagernumber); 519 message = translateMessage(message, pagernumber);
407 520
408 521
409 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 522 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
410 qDebug("passing pagernumber:(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 523 qDebug("passing pagernumber:(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
411 524
412 QCopEnvelope e(channel.latin1(), message.latin1()); 525 QCopEnvelope e(channel.latin1(), message.latin1());
413 //US we need no names in the To field. The emailadresses are enough 526 //US we need no names in the To field. The emailadresses are enough
414 527
415 passParameter(&e, parameters, pagernumber); 528 passParameter(&e, parameters, pagernumber);
416 529
417 530
418#else 531#else
419 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 532 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
420#endif 533#endif
421 534
422 535
423 return true; 536 return true;
424} 537}
425 538
539/**************************************************************************
540 *
541 **************************************************************************/
542
426//calls the faxapplication with the number 543//calls the faxapplication with the number
427bool ExternalAppHandler::callByFax( const QString& faxnumber ) 544bool ExternalAppHandler::callByFax( const QString& faxnumber )
428{ 545{
429#ifndef DESKTOP_VERSION 546#ifndef DESKTOP_VERSION
430 QString channel; 547 QString channel;
431 QString message; 548 QString message;
432 QString parameters; 549 QString parameters;
433 550
434 551
435 int client = KPimGlobalPrefs::instance()->mFaxClient; 552 int client = KPimGlobalPrefs::instance()->mFaxClient;
436 if (client == KPimGlobalPrefs::OTHER_FAC) 553 if (client == KPimGlobalPrefs::OTHER_FAC)
437 { 554 {
438 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 555 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
439 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 556 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
440 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 557 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
441 } 558 }
442 else 559 else
443 { 560 {
444 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 561 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
445 if (!dai) 562 if (!dai)
446 { 563 {
447 qDebug("could not find configured fax application."); 564 qDebug("could not find configured fax application.");
448 return false; 565 return false;
449 } 566 }
@@ -453,58 +570,63 @@ bool ExternalAppHandler::callByFax( const QString& faxnumber )
453 } 570 }
454 571
455 572
456 //first check if one of the mailers need the emails right in the message. 573 //first check if one of the mailers need the emails right in the message.
457 message = translateMessage(message, faxnumber); 574 message = translateMessage(message, faxnumber);
458 575
459 576
460 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 577 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
461 qDebug("passing faxnumber:(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 578 qDebug("passing faxnumber:(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
462 579
463 QCopEnvelope e(channel.latin1(), message.latin1()); 580 QCopEnvelope e(channel.latin1(), message.latin1());
464 //US we need no names in the To field. The emailadresses are enough 581 //US we need no names in the To field. The emailadresses are enough
465 582
466 passParameter(&e, parameters, faxnumber); 583 passParameter(&e, parameters, faxnumber);
467 584
468 585
469#else 586#else
470 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 587 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
471#endif 588#endif
472 589
473 590
474 return true; 591 return true;
475} 592}
476 593
477 594/**************************************************************************
478 595 *
596 **************************************************************************/
479 597
480 598
481 599
482QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1) const 600QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1) const
483{ 601{
484 return message.replace( QRegExp("%1"), param1 ); 602 return message.replace( QRegExp("%1"), param1 );
485} 603}
486 604
605/**************************************************************************
606 *
607 **************************************************************************/
608
487void ExternalAppHandler::passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const 609void ExternalAppHandler::passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const
488{ 610{
489#ifndef DESKTOP_VERSION 611#ifndef DESKTOP_VERSION
490 QMap<QString, QString> valmap; 612 QMap<QString, QString> valmap;
491 bool useValMap = false; 613 bool useValMap = false;
492 614
493 // first extract all parts of the parameters. 615 // first extract all parts of the parameters.
494 QStringList paramlist = QStringList::split(";", parameters); 616 QStringList paramlist = QStringList::split(";", parameters);
495 617
496 //Now check how many parts we have. 618 //Now check how many parts we have.
497 //=0 :no params to pass 619 //=0 :no params to pass
498 //>0 :parameters to pass 620 //>0 :parameters to pass
499 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 621 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
500 { 622 {
501 QString param = (*it); 623 QString param = (*it);
502 QStringList keyvallist = QStringList::split("=", param); 624 QStringList keyvallist = QStringList::split("=", param);
503 625
504 //if we have keyvalue pairs, we assume that we pass a map to the envelope 626 //if we have keyvalue pairs, we assume that we pass a map to the envelope
505 QStringList::Iterator it2 = keyvallist.begin(); 627 QStringList::Iterator it2 = keyvallist.begin();
506 QString key = (*it2); 628 QString key = (*it2);
507 key = key.replace( QRegExp("%1"), param1 ); 629 key = key.replace( QRegExp("%1"), param1 );
508 ++it2; 630 ++it2;
509 631
510 if(it2 != keyvallist.end()) 632 if(it2 != keyvallist.end())