author | ulf69 <ulf69> | 2004-08-10 16:10:42 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-10 16:10:42 (UTC) |
commit | c56c4729e32a9c8ba8709493b3ea11cf7cf229d3 (patch) (unidiff) | |
tree | 10072e3a37eb3dca26482e67c08229bd2a1cbba6 /libkdepim | |
parent | c9d570427f3d5bead7bee1301514a2d4b82836ea (diff) | |
download | kdepimpi-c56c4729e32a9c8ba8709493b3ea11cf7cf229d3.zip kdepimpi-c56c4729e32a9c8ba8709493b3ea11cf7cf229d3.tar.gz kdepimpi-c56c4729e32a9c8ba8709493b3ea11cf7cf229d3.tar.bz2 |
additional files for external application configuration
-rw-r--r-- | libkdepim/externalapphandler.cpp | 526 | ||||
-rw-r--r-- | libkdepim/externalapphandler.h | 120 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.cpp | 89 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.h | 112 |
4 files changed, 847 insertions, 0 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp new file mode 100644 index 0000000..6f812d0 --- a/dev/null +++ b/libkdepim/externalapphandler.cpp | |||
@@ -0,0 +1,526 @@ | |||
1 | /* | ||
2 | This file is part of libkdepim. | ||
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | Enhanced Version of the file for platform independent KDE tools. | ||
26 | Copyright (c) 2004 Ulf Schenk | ||
27 | |||
28 | $Id$ | ||
29 | */ | ||
30 | #include <stdlib.h> | ||
31 | |||
32 | #include <qfile.h> | ||
33 | #include <qmap.h> | ||
34 | |||
35 | |||
36 | #include <qtopia/qcopenvelope_qws.h> | ||
37 | |||
38 | |||
39 | #include <kstaticdeleter.h> | ||
40 | |||
41 | |||
42 | #include "externalapphandler.h" | ||
43 | |||
44 | #include "kpimglobalprefs.h" | ||
45 | |||
46 | |||
47 | |||
48 | |||
49 | |||
50 | |||
51 | |||
52 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; | ||
53 | static KStaticDeleter<ExternalAppHandler> staticDeleter; | ||
54 | |||
55 | |||
56 | ExternalAppHandler::ExternalAppHandler() | ||
57 | { | ||
58 | mDefaultItems.setAutoDelete(true); | ||
59 | } | ||
60 | |||
61 | ExternalAppHandler::~ExternalAppHandler() | ||
62 | { | ||
63 | } | ||
64 | |||
65 | void ExternalAppHandler::loadConfig() | ||
66 | { | ||
67 | mDefaultItems.clear(); | ||
68 | |||
69 | |||
70 | |||
71 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); | ||
72 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); | ||
73 | |||
74 | if (opiepath.isEmpty()) | ||
75 | opiepath = qtopiapath; | ||
76 | |||
77 | //mailclients | ||
78 | QString mailmsg1 = "writeMail(QString,QString)"; | ||
79 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; | ||
80 | |||
81 | QString undefined = "undefined"; | ||
82 | |||
83 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); | ||
84 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); | ||
85 | |||
86 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | ||
87 | ( QFile::exists( opiepath + "/bin/ompi" ))) | ||
88 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", "newMail(QString)", "%1", mailmsg2, "ATTACHMENT=%1"); | ||
89 | |||
90 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) | ||
91 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, ";%1", mailmsg2, "ATTACHMENT=%1"); | ||
92 | |||
93 | if ( QFile::exists( opiepath + "/bin/opiemail" )) | ||
94 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, ";%1", mailmsg2, "ATTACHMENT=%1"); | ||
95 | |||
96 | |||
97 | |||
98 | //phoneclients | ||
99 | |||
100 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); | ||
101 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); | ||
102 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | ||
103 | ( QFile::exists( opiepath + "/bin/kppi" ))) | ||
104 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | ||
105 | |||
106 | //faxclients | ||
107 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); | ||
108 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); | ||
109 | |||
110 | //smsclients | ||
111 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); | ||
112 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); | ||
113 | |||
114 | //pagerclients | ||
115 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); | ||
116 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); | ||
117 | |||
118 | } | ||
119 | |||
120 | ExternalAppHandler *ExternalAppHandler::instance() | ||
121 | { | ||
122 | if ( !sInstance ) { | ||
123 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | ||
124 | sInstance->loadConfig(); | ||
125 | } | ||
126 | |||
127 | return sInstance; | ||
128 | } | ||
129 | |||
130 | void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) | ||
131 | { | ||
132 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | ||
133 | |||
134 | mDefaultItems.append(dai); | ||
135 | } | ||
136 | |||
137 | |||
138 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | ||
139 | { | ||
140 | QList<DefaultAppItem> list; | ||
141 | |||
142 | DefaultAppItem* dai; | ||
143 | |||
144 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | ||
145 | { | ||
146 | if (dai->_type == type) | ||
147 | list.append(dai); | ||
148 | } | ||
149 | |||
150 | return list; | ||
151 | } | ||
152 | |||
153 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | ||
154 | { | ||
155 | DefaultAppItem* dai; | ||
156 | |||
157 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | ||
158 | { | ||
159 | if (dai->_type == type && dai->_id == clientid) | ||
160 | return dai; | ||
161 | } | ||
162 | |||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | |||
167 | |||
168 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) | ||
169 | bool ExternalAppHandler::mailAttachments( const QString& urls ) | ||
170 | { | ||
171 | #ifndef QT_NO_COP | ||
172 | QString channel; | ||
173 | QString message2; | ||
174 | QString parameters2; | ||
175 | |||
176 | |||
177 | int client = KPimGlobalPrefs::instance()->mEmailClient; | ||
178 | if (client == KPimGlobalPrefs::OTHER_EMC) | ||
179 | { | ||
180 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | ||
181 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | ||
182 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | ||
183 | } | ||
184 | else | ||
185 | { | ||
186 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | ||
187 | if (!dai) | ||
188 | { | ||
189 | qDebug("could not find configured email application."); | ||
190 | return false; | ||
191 | } | ||
192 | channel = dai->_channel; | ||
193 | message2 = dai->_message2; | ||
194 | parameters2 = dai->_parameters2; | ||
195 | } | ||
196 | |||
197 | |||
198 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | ||
199 | qDebug("passing attachmenturls:(%s) as parameter in the form %s to QCopEnvelope", urls.latin1(), parameters2.latin1()); | ||
200 | |||
201 | QCopEnvelope e(channel.latin1(), message2.latin1()); | ||
202 | //US we need no names in the To field. The emailadresses are enough | ||
203 | |||
204 | passParameter(&e, parameters2, urls); | ||
205 | |||
206 | |||
207 | #else | ||
208 | KMessageBox::sorry( this, i18n( "This version does not support the sending of emails." ) ); | ||
209 | #endif | ||
210 | |||
211 | return true; | ||
212 | } | ||
213 | |||
214 | |||
215 | |||
216 | //calls the emailapplication and creates a mail with parameter emails as recipients | ||
217 | bool ExternalAppHandler::mailToContacts( const QString& emails ) | ||
218 | { | ||
219 | #ifndef QT_NO_COP | ||
220 | QString channel; | ||
221 | QString message; | ||
222 | QString parameters; | ||
223 | |||
224 | |||
225 | int client = KPimGlobalPrefs::instance()->mEmailClient; | ||
226 | if (client == KPimGlobalPrefs::OTHER_EMC) | ||
227 | { | ||
228 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | ||
229 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | ||
230 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | ||
231 | } | ||
232 | else | ||
233 | { | ||
234 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | ||
235 | if (!dai) | ||
236 | { | ||
237 | qDebug("could not find configured email application."); | ||
238 | return false; | ||
239 | } | ||
240 | channel = dai->_channel; | ||
241 | message = dai->_message; | ||
242 | parameters = dai->_parameters; | ||
243 | } | ||
244 | |||
245 | |||
246 | //first check if one of the mailers need the emails right in the message. | ||
247 | message = translateMessage(message, emails); | ||
248 | |||
249 | |||
250 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | ||
251 | qDebug("passing emailadresses:(%s) as parameter in the form %s to QCopEnvelope", emails.latin1(), parameters.latin1()); | ||
252 | |||
253 | QCopEnvelope e(channel.latin1(), message.latin1()); | ||
254 | //US we need no names in the To field. The emailadresses are enough | ||
255 | |||
256 | passParameter(&e, parameters, emails); | ||
257 | |||
258 | |||
259 | #else | ||
260 | KMessageBox::sorry( this, i18n( "This version does not support the sending of emails." ) ); | ||
261 | #endif | ||
262 | |||
263 | |||
264 | return true; | ||
265 | } | ||
266 | |||
267 | |||
268 | //calls the phoneapplication with the number | ||
269 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | ||
270 | { | ||
271 | #ifndef QT_NO_COP | ||
272 | QString channel; | ||
273 | QString message; | ||
274 | QString parameters; | ||
275 | |||
276 | |||
277 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | ||
278 | if (client == KPimGlobalPrefs::OTHER_PHC) | ||
279 | { | ||
280 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | ||
281 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | ||
282 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | ||
283 | } | ||
284 | else | ||
285 | { | ||
286 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | ||
287 | if (!dai) | ||
288 | { | ||
289 | qDebug("could not find configured phone application."); | ||
290 | return false; | ||
291 | } | ||
292 | channel = dai->_channel; | ||
293 | message = dai->_message; | ||
294 | parameters = dai->_parameters; | ||
295 | } | ||
296 | |||
297 | |||
298 | //first check if one of the mailers need the emails right in the message. | ||
299 | message = translateMessage(message, phonenumber); | ||
300 | |||
301 | |||
302 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | ||
303 | qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | ||
304 | |||
305 | QCopEnvelope e(channel.latin1(), message.latin1()); | ||
306 | //US we need no names in the To field. The emailadresses are enough | ||
307 | |||
308 | passParameter(&e, parameters, phonenumber); | ||
309 | |||
310 | |||
311 | #else | ||
312 | KMessageBox::sorry( this, i18n( "This version does not support phonecalls." ) ); | ||
313 | #endif | ||
314 | |||
315 | |||
316 | return true; | ||
317 | } | ||
318 | |||
319 | //calls the smsapplication with the number | ||
320 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | ||
321 | { | ||
322 | #ifndef QT_NO_COP | ||
323 | QString channel; | ||
324 | QString message; | ||
325 | QString parameters; | ||
326 | |||
327 | |||
328 | int client = KPimGlobalPrefs::instance()->mSMSClient; | ||
329 | if (client == KPimGlobalPrefs::OTHER_SMC) | ||
330 | { | ||
331 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; | ||
332 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; | ||
333 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; | ||
334 | } | ||
335 | else | ||
336 | { | ||
337 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); | ||
338 | if (!dai) | ||
339 | { | ||
340 | qDebug("could not find configured sms application."); | ||
341 | return false; | ||
342 | } | ||
343 | channel = dai->_channel; | ||
344 | message = dai->_message; | ||
345 | parameters = dai->_parameters; | ||
346 | } | ||
347 | |||
348 | |||
349 | //first check if one of the mailers need the emails right in the message. | ||
350 | message = translateMessage(message, phonenumber); | ||
351 | |||
352 | |||
353 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | ||
354 | qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | ||
355 | |||
356 | QCopEnvelope e(channel.latin1(), message.latin1()); | ||
357 | //US we need no names in the To field. The emailadresses are enough | ||
358 | |||
359 | passParameter(&e, parameters, phonenumber); | ||
360 | |||
361 | |||
362 | #else | ||
363 | KMessageBox::sorry( this, i18n( "This version does not support the sending of sms." ) ); | ||
364 | #endif | ||
365 | |||
366 | |||
367 | return true; | ||
368 | } | ||
369 | |||
370 | //calls the pagerapplication with the number | ||
371 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) | ||
372 | { | ||
373 | #ifndef QT_NO_COP | ||
374 | QString channel; | ||
375 | QString message; | ||
376 | QString parameters; | ||
377 | |||
378 | |||
379 | int client = KPimGlobalPrefs::instance()->mPagerClient; | ||
380 | if (client == KPimGlobalPrefs::OTHER_PAC) | ||
381 | { | ||
382 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; | ||
383 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; | ||
384 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; | ||
385 | } | ||
386 | else | ||
387 | { | ||
388 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); | ||
389 | if (!dai) | ||
390 | { | ||
391 | qDebug("could not find configured pager application."); | ||
392 | return false; | ||
393 | } | ||
394 | channel = dai->_channel; | ||
395 | message = dai->_message; | ||
396 | parameters = dai->_parameters; | ||
397 | } | ||
398 | |||
399 | |||
400 | //first check if one of the mailers need the emails right in the message. | ||
401 | message = translateMessage(message, pagernumber); | ||
402 | |||
403 | |||
404 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | ||
405 | qDebug("passing pagernumber:(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); | ||
406 | |||
407 | QCopEnvelope e(channel.latin1(), message.latin1()); | ||
408 | //US we need no names in the To field. The emailadresses are enough | ||
409 | |||
410 | passParameter(&e, parameters, pagernumber); | ||
411 | |||
412 | |||
413 | #else | ||
414 | KMessageBox::sorry( this, i18n( "This version does not support paging." ) ); | ||
415 | #endif | ||
416 | |||
417 | |||
418 | return true; | ||
419 | } | ||
420 | |||
421 | //calls the faxapplication with the number | ||
422 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) | ||
423 | { | ||
424 | #ifndef QT_NO_COP | ||
425 | QString channel; | ||
426 | QString message; | ||
427 | QString parameters; | ||
428 | |||
429 | |||
430 | int client = KPimGlobalPrefs::instance()->mFaxClient; | ||
431 | if (client == KPimGlobalPrefs::OTHER_FAC) | ||
432 | { | ||
433 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; | ||
434 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; | ||
435 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; | ||
436 | } | ||
437 | else | ||
438 | { | ||
439 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); | ||
440 | if (!dai) | ||
441 | { | ||
442 | qDebug("could not find configured fax application."); | ||
443 | return false; | ||
444 | } | ||
445 | channel = dai->_channel; | ||
446 | message = dai->_message; | ||
447 | parameters = dai->_parameters; | ||
448 | } | ||
449 | |||
450 | |||
451 | //first check if one of the mailers need the emails right in the message. | ||
452 | message = translateMessage(message, faxnumber); | ||
453 | |||
454 | |||
455 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | ||
456 | qDebug("passing faxnumber:(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); | ||
457 | |||
458 | QCopEnvelope e(channel.latin1(), message.latin1()); | ||
459 | //US we need no names in the To field. The emailadresses are enough | ||
460 | |||
461 | passParameter(&e, parameters, faxnumber); | ||
462 | |||
463 | |||
464 | #else | ||
465 | KMessageBox::sorry( this, i18n( "This version does not support the sending of faxes." ) ); | ||
466 | #endif | ||
467 | |||
468 | |||
469 | return true; | ||
470 | } | ||
471 | |||
472 | |||
473 | |||
474 | |||
475 | |||
476 | |||
477 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1) const | ||
478 | { | ||
479 | return message.replace( QRegExp("%1"), param1 ); | ||
480 | } | ||
481 | |||
482 | void ExternalAppHandler::passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const | ||
483 | { | ||
484 | QMap<QString, QString> valmap; | ||
485 | bool useValMap = false; | ||
486 | |||
487 | // first extract all parts of the parameters. | ||
488 | QStringList paramlist = QStringList::split(";", parameters); | ||
489 | |||
490 | //Now check how many parts we have. | ||
491 | //=0 :no params to pass | ||
492 | //>0 :parameters to pass | ||
493 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) | ||
494 | { | ||
495 | QString param = (*it); | ||
496 | QStringList keyvallist = QStringList::split("=", param); | ||
497 | |||
498 | //if we have keyvalue pairs, we assume that we pass a map to the envelope | ||
499 | QStringList::Iterator it2 = keyvallist.begin(); | ||
500 | QString key = (*it2); | ||
501 | key = key.replace( QRegExp("%1"), param1 ); | ||
502 | ++it2; | ||
503 | |||
504 | if(it2 != keyvallist.end()) | ||
505 | { | ||
506 | QString value = (*it2); | ||
507 | value = value.replace( QRegExp("%1"), param1 ); | ||
508 | |||
509 | valmap.insert(key, value); | ||
510 | useValMap = true; | ||
511 | } | ||
512 | else | ||
513 | { | ||
514 | (*e) << key.latin1(); | ||
515 | } | ||
516 | } | ||
517 | |||
518 | if (useValMap == true) | ||
519 | (*e) << valmap; | ||
520 | |||
521 | |||
522 | |||
523 | } | ||
524 | |||
525 | |||
526 | |||
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h new file mode 100644 index 0000000..3ecf1b1 --- a/dev/null +++ b/libkdepim/externalapphandler.h | |||
@@ -0,0 +1,120 @@ | |||
1 | /* | ||
2 | This file is part of libkdepim. | ||
3 | Copyright (c) 2004 Ulf Schenk | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | Enhanced Version of the file for platform independent KDE tools. | ||
26 | Copyright (c) 2004 Ulf Schenk | ||
27 | |||
28 | $Id$ | ||
29 | */ | ||
30 | |||
31 | #ifndef EXTERNALAPPHANDLER_H | ||
32 | #define EXTERNALAPPHANDLER_H | ||
33 | |||
34 | #include <qlist.h> | ||
35 | |||
36 | class QCopEnvelope; | ||
37 | |||
38 | |||
39 | class ExternalAppHandler; | ||
40 | |||
41 | class DefaultAppItem | ||
42 | { | ||
43 | public: | ||
44 | DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) | ||
45 | : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) | ||
46 | {} | ||
47 | |||
48 | DefaultAppItem() | ||
49 | { } | ||
50 | |||
51 | public: | ||
52 | int _type; | ||
53 | int _id; | ||
54 | QString _label; | ||
55 | QString _channel; | ||
56 | QString _message; | ||
57 | QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; | ||
58 | QString _message2; | ||
59 | QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; | ||
60 | |||
61 | }; | ||
62 | |||
63 | class ExternalAppHandler | ||
64 | { | ||
65 | public: | ||
66 | virtual ~ExternalAppHandler(); | ||
67 | |||
68 | static ExternalAppHandler *instance(); | ||
69 | |||
70 | enum Types { | ||
71 | EMAIL = 0, | ||
72 | PHONE = 1, | ||
73 | SMS = 2, | ||
74 | FAX = 3, | ||
75 | PAGER = 4 | ||
76 | }; | ||
77 | |||
78 | //calls the emailapplication with a number of attachments that need to be send | ||
79 | bool mailAttachments( const QString& urls ); | ||
80 | |||
81 | //calls the emailapplication and creates a mail with parameter emails as recipients | ||
82 | bool mailToContacts( const QString& emails ); | ||
83 | |||
84 | //calls the phoneapplication with the number | ||
85 | bool callByPhone( const QString& phonenumber ); | ||
86 | |||
87 | //calls the smsapplication with the number | ||
88 | bool callBySMS( const QString& phonenumber ); | ||
89 | |||
90 | //calls the pagerapplication with the number | ||
91 | bool callByPager( const QString& pagernumber ); | ||
92 | |||
93 | //calls the faxapplication with the number | ||
94 | bool callByFax( const QString& faxnumber ); | ||
95 | |||
96 | |||
97 | //loadConfig clears the cache and checks again if the applications are available or not | ||
98 | void loadConfig(); | ||
99 | |||
100 | QList<DefaultAppItem> getAvailableDefaultItems(Types); | ||
101 | DefaultAppItem* getDefaultItem(Types, int); | ||
102 | |||
103 | |||
104 | private: | ||
105 | ExternalAppHandler(); | ||
106 | QList<DefaultAppItem> mDefaultItems; | ||
107 | |||
108 | |||
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); | ||
110 | |||
111 | QString& translateMessage(QString& message, const QString& emails) const; | ||
112 | void passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const; | ||
113 | |||
114 | |||
115 | static ExternalAppHandler *sInstance; | ||
116 | |||
117 | |||
118 | }; | ||
119 | |||
120 | #endif | ||
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp new file mode 100644 index 0000000..4790980 --- a/dev/null +++ b/libkdepim/kpimglobalprefs.cpp | |||
@@ -0,0 +1,89 @@ | |||
1 | /* | ||
2 | This file is part of libkdepim. | ||
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | Enhanced Version of the file for platform independent KDE tools. | ||
26 | Copyright (c) 2004 Ulf Schenk | ||
27 | |||
28 | $Id$ | ||
29 | */ | ||
30 | |||
31 | #include <kglobal.h> | ||
32 | #include <kconfig.h> | ||
33 | #include <klocale.h> | ||
34 | #include <kdebug.h> | ||
35 | #include <kstaticdeleter.h> | ||
36 | |||
37 | #include "kpimglobalprefs.h" | ||
38 | |||
39 | KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; | ||
40 | static KStaticDeleter<KPimGlobalPrefs> staticDeleter; | ||
41 | |||
42 | |||
43 | KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) | ||
44 | : KPrefs("kkdepimrc") | ||
45 | { | ||
46 | KPrefs::setCurrentGroup( "ExternalApplications" ); | ||
47 | |||
48 | addItemInt( "EmailChannelType", &mEmailClient, NONE_EMC ); | ||
49 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); | ||
50 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); | ||
51 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); | ||
52 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); | ||
53 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); | ||
54 | |||
55 | addItemInt( "PhoneChannelType", &mPhoneClient, NONE_PHC ); | ||
56 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); | ||
57 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); | ||
58 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); | ||
59 | |||
60 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); | ||
61 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); | ||
62 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); | ||
63 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); | ||
64 | |||
65 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); | ||
66 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); | ||
67 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); | ||
68 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); | ||
69 | |||
70 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); | ||
71 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); | ||
72 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); | ||
73 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); | ||
74 | |||
75 | } | ||
76 | |||
77 | KPimGlobalPrefs::~KPimGlobalPrefs() | ||
78 | { | ||
79 | } | ||
80 | |||
81 | KPimGlobalPrefs *KPimGlobalPrefs::instance() | ||
82 | { | ||
83 | if ( !sInstance ) { | ||
84 | sInstance = staticDeleter.setObject( new KPimGlobalPrefs() ); | ||
85 | sInstance->readConfig(); | ||
86 | } | ||
87 | |||
88 | return sInstance; | ||
89 | } | ||
diff --git a/libkdepim/kpimglobalprefs.h b/libkdepim/kpimglobalprefs.h new file mode 100644 index 0000000..80b2c4f --- a/dev/null +++ b/libkdepim/kpimglobalprefs.h | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | This file is part of libkdepim. | ||
3 | Copyright (c) 2004 Ulf Schenk | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | Enhanced Version of the file for platform independent KDE tools. | ||
26 | Copyright (c) 2004 Ulf Schenk | ||
27 | |||
28 | $Id$ | ||
29 | */ | ||
30 | |||
31 | #ifndef KPIMGLOBALPREFS_H | ||
32 | #define KPIMGLOBALPREFS_H | ||
33 | |||
34 | #include "kprefs.h" | ||
35 | |||
36 | class KPimGlobalPrefs : public KPrefs | ||
37 | { | ||
38 | public: | ||
39 | |||
40 | static KPimGlobalPrefs *instance(); | ||
41 | |||
42 | |||
43 | virtual ~KPimGlobalPrefs(); | ||
44 | |||
45 | |||
46 | enum EMailClients { | ||
47 | NONE_EMC = 0, | ||
48 | OTHER_EMC = 1, | ||
49 | OMPI_EMC = 2, | ||
50 | QTOPIA_EMC = 3, | ||
51 | OPIE_EMC = 4 | ||
52 | }; | ||
53 | |||
54 | enum PhoneClients { | ||
55 | NONE_PHC = 0, | ||
56 | OTHER_PHC = 1, | ||
57 | KPPI_PHC = 2 | ||
58 | }; | ||
59 | |||
60 | enum FaxClients { | ||
61 | NONE_FAC = 0, | ||
62 | OTHER_FAC = 1 | ||
63 | }; | ||
64 | |||
65 | enum SMSClients { | ||
66 | NONE_SMC = 0, | ||
67 | OTHER_SMC = 1 | ||
68 | }; | ||
69 | |||
70 | enum PagerClients { | ||
71 | NONE_PAC = 0, | ||
72 | OTHER_PAC = 1 | ||
73 | }; | ||
74 | |||
75 | private: | ||
76 | KPimGlobalPrefs( const QString &name = QString::null ); | ||
77 | |||
78 | static KPimGlobalPrefs *sInstance; | ||
79 | |||
80 | |||
81 | public: | ||
82 | int mEmailClient; | ||
83 | QString mEmailOtherChannel; | ||
84 | QString mEmailOtherMessage; | ||
85 | QString mEmailOtherMessageParameters; | ||
86 | QString mEmailOtherMessage2; | ||
87 | QString mEmailOtherMessageParameters2; | ||
88 | |||
89 | int mPhoneClient; | ||
90 | QString mPhoneOtherChannel; | ||
91 | QString mPhoneOtherMessage; | ||
92 | QString mPhoneOtherMessageParameters; | ||
93 | |||
94 | int mFaxClient; | ||
95 | QString mFaxOtherChannel; | ||
96 | QString mFaxOtherMessage; | ||
97 | QString mFaxOtherMessageParameters; | ||
98 | |||
99 | int mSMSClient; | ||
100 | QString mSMSOtherChannel; | ||
101 | QString mSMSOtherMessage; | ||
102 | QString mSMSOtherMessageParameters; | ||
103 | |||
104 | int mPagerClient; | ||
105 | QString mPagerOtherChannel; | ||
106 | QString mPagerOtherMessage; | ||
107 | QString mPagerOtherMessageParameters; | ||
108 | |||
109 | |||
110 | }; | ||
111 | |||
112 | #endif | ||