summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp128
-rw-r--r--libkdepim/externalapphandler.h19
2 files changed, 144 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
@@ -57,39 +57,45 @@ static KStaticDeleter<ExternalAppHandler> staticDeleter;
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" ))
@@ -156,24 +162,117 @@ DefaultAppItem* 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
@@ -207,24 +306,27 @@ bool ExternalAppHandler::mailAttachments( const QString& urls )
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;
@@ -260,24 +362,27 @@ bool ExternalAppHandler::mailToContacts( const QString& emails )
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)
@@ -312,24 +417,28 @@ bool ExternalAppHandler::callByPhone( const QString& phonenumber )
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 {
@@ -363,24 +472,28 @@ bool ExternalAppHandler::callBySMS( const QString& phonenumber )
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 {
@@ -414,24 +527,28 @@ bool ExternalAppHandler::callByPager( const QString& pagernumber )
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 {
@@ -465,34 +582,39 @@ bool ExternalAppHandler::callByFax( const QString& faxnumber )
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
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h
index 3ecf1b1..efcdd89 100644
--- a/libkdepim/externalapphandler.h
+++ b/libkdepim/externalapphandler.h
@@ -66,54 +66,73 @@ class ExternalAppHandler
66 virtual ~ExternalAppHandler(); 66 virtual ~ExternalAppHandler();
67 67
68 static ExternalAppHandler *instance(); 68 static ExternalAppHandler *instance();
69 69
70 enum Types { 70 enum Types {
71 EMAIL = 0, 71 EMAIL = 0,
72 PHONE = 1, 72 PHONE = 1,
73 SMS = 2, 73 SMS = 2,
74 FAX = 3, 74 FAX = 3,
75 PAGER = 4 75 PAGER = 4
76 }; 76 };
77 77
78 enum Availability {
79 UNDEFINED = -1,
80 UNAVAILABLE = 0,
81 AVAILABLE = 1
82 };
83
78 //calls the emailapplication with a number of attachments that need to be send 84 //calls the emailapplication with a number of attachments that need to be send
79 bool mailAttachments( const QString& urls ); 85 bool mailAttachments( const QString& urls );
80 86
81 //calls the emailapplication and creates a mail with parameter emails as recipients 87 //calls the emailapplication and creates a mail with parameter emails as recipients
82 bool mailToContacts( const QString& emails ); 88 bool mailToContacts( const QString& emails );
83 89
84 //calls the phoneapplication with the number 90 //calls the phoneapplication with the number
85 bool callByPhone( const QString& phonenumber ); 91 bool callByPhone( const QString& phonenumber );
86 92
87 //calls the smsapplication with the number 93 //calls the smsapplication with the number
88 bool callBySMS( const QString& phonenumber ); 94 bool callBySMS( const QString& phonenumber );
89 95
90 //calls the pagerapplication with the number 96 //calls the pagerapplication with the number
91 bool callByPager( const QString& pagernumber ); 97 bool callByPager( const QString& pagernumber );
92 98
93 //calls the faxapplication with the number 99 //calls the faxapplication with the number
94 bool callByFax( const QString& faxnumber ); 100 bool callByFax( const QString& faxnumber );
95 101
102 bool isEmailAppAvailable();
103 bool isSMSAppAvailable();
104 bool isPhoneAppAvailable();
105 bool isFaxAppAvailable();
106 bool isPagerAppAvailable();
107
108
96 109
97 //loadConfig clears the cache and checks again if the applications are available or not 110 //loadConfig clears the cache and checks again if the applications are available or not
98 void loadConfig(); 111 void loadConfig();
99 112
100 QList<DefaultAppItem> getAvailableDefaultItems(Types); 113 QList<DefaultAppItem> getAvailableDefaultItems(Types);
101 DefaultAppItem* getDefaultItem(Types, int); 114 DefaultAppItem* getDefaultItem(Types, int);
102 115
103 116
104 private: 117 private:
105 ExternalAppHandler(); 118 ExternalAppHandler();
106 QList<DefaultAppItem> mDefaultItems; 119 QList<DefaultAppItem> mDefaultItems;
107 120
121 Availability mEmailAppAvailable;
122 Availability mPhoneAppAvailable;
123 Availability mFaxAppAvailable;
124 Availability mSMSAppAvailable;
125 Availability mPagerAppAvailable;
126
108 127
109 void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); 128 void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2);
110 129
111 QString& translateMessage(QString& message, const QString& emails) const; 130 QString& translateMessage(QString& message, const QString& emails) const;
112 void passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const; 131 void passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const;
113 132
114 133
115 static ExternalAppHandler *sInstance; 134 static ExternalAppHandler *sInstance;
116 135
117 136
118}; 137};
119 138