Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libkdepim/externalapphandler.cpp | 282 |
1 files changed, 280 insertions, 2 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 35638b1..64caa7d 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -1,188 +1,424 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 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. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | 31 | ||
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qmap.h> | 33 | #include <qmap.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | 35 | ||
36 | #ifndef DESKTOP_VERSION | 36 | #ifndef DESKTOP_VERSION |
37 | #include <qtopia/qcopenvelope_qws.h> | 37 | #include <qtopia/qcopenvelope_qws.h> |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #include <kstaticdeleter.h> | 40 | #include <kstaticdeleter.h> |
41 | #include <kmessagebox.h> | 41 | #include <kmessagebox.h> |
42 | 42 | ||
43 | 43 | ||
44 | #include "externalapphandler.h" | 44 | #include "externalapphandler.h" |
45 | 45 | ||
46 | #include "kpimglobalprefs.h" | 46 | #include "kpimglobalprefs.h" |
47 | 47 | ||
48 | /********************************************************************************* | ||
49 | * | ||
50 | ********************************************************************************/ | ||
51 | |||
52 | |||
53 | QCopTransferItem::QCopTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | ||
54 | : _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) | ||
55 | { | ||
56 | //sourceMessage passes later three parameters: sourceChannel, uid, param1 | ||
57 | _sourceMessageParameters = "(QString,QString,QString)"; | ||
58 | } | ||
59 | |||
60 | /*********************************************************************************/ | ||
61 | |||
62 | QCopTransferItem::QCopTransferItem() | ||
63 | { | ||
64 | } | ||
65 | |||
66 | /*********************************************************************************/ | ||
67 | bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1) | ||
68 | { | ||
69 | |||
70 | #ifndef DESKTOP_VERSION | ||
71 | //sourceMessage passes two parameters: sourceChannel, uid | ||
72 | QString sourceMessage = _sourceMessage + _sourceMessageParameters; | ||
73 | |||
74 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); | ||
75 | qDebug("passing sourcechannel(%s), uid(%s), param1(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1()); | ||
76 | |||
77 | QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); | ||
78 | |||
79 | e << _sourceChannel << uid << param1; | ||
80 | |||
81 | return true; | ||
82 | |||
83 | #else | ||
84 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | ||
85 | return false; | ||
86 | #endif | ||
87 | |||
88 | } | ||
89 | |||
90 | |||
91 | /*********************************************************************************/ | ||
92 | void QCopTransferItem::setSourceChannel(const QString& sourceChannel) | ||
93 | { | ||
94 | |||
95 | if (_sourceChannel.isEmpty()) | ||
96 | _sourceChannel = sourceChannel; | ||
97 | } | ||
98 | |||
99 | |||
100 | /*********************************************************************************/ | ||
101 | bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | ||
102 | { | ||
103 | /*US | ||
104 | // copied from old mail2 | ||
105 | static int ii = 0; | ||
106 | |||
107 | // block second call | ||
108 | if ( ii < 2 ) { | ||
109 | ++ii; | ||
110 | if ( ii > 1 ) { | ||
111 | qDebug("qcop call blocked "); | ||
112 | return true; | ||
113 | } | ||
114 | } | ||
115 | */ | ||
116 | qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); | ||
117 | |||
118 | //we are in the target and get a request from the source | ||
119 | if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) | ||
120 | { | ||
121 | QDataStream stream( data, IO_ReadOnly ); | ||
122 | |||
123 | |||
124 | QString sourceChannel; | ||
125 | QString uid; | ||
126 | QString param1; | ||
48 | 127 | ||
128 | stream >> sourceChannel >> uid >> param1; | ||
49 | 129 | ||
130 | emit receivedMessageFromSource(sourceChannel, uid, param1); | ||
50 | 131 | ||
132 | return true; | ||
133 | } | ||
134 | |||
135 | return false; | ||
136 | } | ||
137 | |||
138 | |||
139 | /********************************************************************************* | ||
140 | * | ||
141 | ********************************************************************************/ | ||
142 | |||
143 | |||
144 | QCopMapTransferItem::QCopMapTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | ||
145 | : QCopTransferItem(sourceMessage, targetChannel,targetMessage) | ||
146 | { | ||
147 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> | ||
148 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; | ||
149 | } | ||
150 | |||
151 | /*********************************************************************************/ | ||
152 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) | ||
153 | { | ||
154 | #ifndef DESKTOP_VERSION | ||
155 | //targetMessage passes two parameters: uid, map | ||
156 | QString targetMessage = _targetMessage + _targetMessageParameters; | ||
157 | |||
158 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | ||
159 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); | ||
51 | 160 | ||
161 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | ||
162 | //US we need no names in the To field. The emailadresses are enough | ||
163 | |||
164 | e << uid << nameEmailMap; | ||
165 | |||
166 | return true; | ||
167 | |||
168 | #else | ||
169 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | ||
170 | return false; | ||
171 | #endif | ||
172 | |||
173 | } | ||
174 | |||
175 | |||
176 | /*********************************************************************************/ | ||
177 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | ||
178 | { | ||
179 | bool res = QCopTransferItem::appMessage( cmsg, data ); | ||
180 | |||
181 | if (res == false) | ||
182 | { | ||
183 | QDataStream stream( data, IO_ReadOnly ); | ||
184 | |||
185 | qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); | ||
186 | |||
187 | //we are in the source and get an answer from the target | ||
188 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | ||
189 | { | ||
190 | QMap<QString,QString> adrMap; | ||
191 | QString uid; | ||
192 | |||
193 | stream >> uid >> adrMap; | ||
194 | |||
195 | emit receivedMessageFromTarget(uid, adrMap); | ||
196 | |||
197 | |||
198 | return true; | ||
199 | } | ||
200 | } | ||
201 | |||
202 | return false; | ||
203 | } | ||
204 | |||
205 | |||
206 | /********************************************************************************* | ||
207 | * | ||
208 | ********************************************************************************/ | ||
209 | |||
210 | |||
211 | QCopListTransferItem::QCopListTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | ||
212 | : QCopTransferItem(sourceMessage, targetChannel,targetMessage) | ||
213 | { | ||
214 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> | ||
215 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList)"; | ||
216 | } | ||
217 | |||
218 | /*********************************************************************************/ | ||
219 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | ||
220 | { | ||
221 | #ifndef DESKTOP_VERSION | ||
222 | //targetMessage passes two parameters: uid, map | ||
223 | QString targetMessage = _targetMessage + _targetMessageParameters; | ||
224 | |||
225 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | ||
226 | qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1()); | ||
227 | |||
228 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | ||
229 | //US we need no names in the To field. The emailadresses are enough | ||
230 | |||
231 | e << uid << list1 << list2 << list3; | ||
232 | |||
233 | return true; | ||
234 | |||
235 | #else | ||
236 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | ||
237 | return false; | ||
238 | #endif | ||
239 | |||
240 | } | ||
241 | |||
242 | |||
243 | /*********************************************************************************/ | ||
244 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | ||
245 | { | ||
246 | bool res = QCopTransferItem::appMessage( cmsg, data ); | ||
247 | |||
248 | if (res == false) | ||
249 | { | ||
250 | QDataStream stream( data, IO_ReadOnly ); | ||
251 | |||
252 | qDebug("QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | ||
253 | |||
254 | //we are in the source and get an answer from the target | ||
255 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | ||
256 | { | ||
257 | QStringList list1; | ||
258 | QStringList list2; | ||
259 | QStringList list3; | ||
260 | QString uid; | ||
261 | |||
262 | stream >> uid >> list1 >> list2 >> list3; | ||
263 | |||
264 | emit receivedMessageFromTarget(uid, list1, list2, list3); | ||
265 | |||
266 | |||
267 | return true; | ||
268 | } | ||
269 | } | ||
270 | |||
271 | return false; | ||
272 | } | ||
273 | |||
274 | |||
275 | |||
276 | /********************************************************************************* | ||
277 | * | ||
278 | ********************************************************************************/ | ||
52 | 279 | ||
53 | 280 | ||
54 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; | 281 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; |
55 | static KStaticDeleter<ExternalAppHandler> staticDeleter; | 282 | static KStaticDeleter<ExternalAppHandler> staticDeleter; |
56 | 283 | ||
57 | |||
58 | ExternalAppHandler::ExternalAppHandler() | 284 | ExternalAppHandler::ExternalAppHandler() |
59 | { | 285 | { |
60 | mDefaultItems.setAutoDelete(true); | 286 | mDefaultItems.setAutoDelete(true); |
287 | |||
288 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem("requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); | ||
289 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&, const QString&))); | ||
290 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); | ||
291 | |||
292 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem("requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); | ||
293 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); | ||
294 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); | ||
295 | |||
296 | |||
61 | } | 297 | } |
62 | 298 | ||
63 | ExternalAppHandler::~ExternalAppHandler() | 299 | ExternalAppHandler::~ExternalAppHandler() |
64 | { | 300 | { |
65 | } | 301 | } |
66 | 302 | ||
67 | void ExternalAppHandler::loadConfig() | 303 | void ExternalAppHandler::loadConfig() |
68 | { | 304 | { |
69 | 305 | ||
70 | mDefaultItems.clear(); | 306 | mDefaultItems.clear(); |
71 | 307 | ||
72 | mEmailAppAvailable = UNDEFINED; | 308 | mEmailAppAvailable = UNDEFINED; |
73 | mPhoneAppAvailable = UNDEFINED; | 309 | mPhoneAppAvailable = UNDEFINED; |
74 | mFaxAppAvailable = UNDEFINED; | 310 | mFaxAppAvailable = UNDEFINED; |
75 | mSMSAppAvailable = UNDEFINED; | 311 | mSMSAppAvailable = UNDEFINED; |
76 | mPagerAppAvailable = UNDEFINED; | 312 | mPagerAppAvailable = UNDEFINED; |
77 | 313 | ||
78 | 314 | ||
79 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); | 315 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); |
80 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); | 316 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); |
81 | 317 | ||
82 | if (opiepath.isEmpty()) | 318 | if (opiepath.isEmpty()) |
83 | opiepath = qtopiapath; | 319 | opiepath = qtopiapath; |
84 | 320 | ||
85 | //mailclients | 321 | //mailclients |
86 | QString mailmsg1 = "writeMail(QString,QString)"; | 322 | QString mailmsg1 = "writeMail(QString,QString)"; |
87 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; | 323 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; |
88 | 324 | ||
89 | QString undefined = ""; | 325 | QString undefined = ""; |
90 | 326 | ||
91 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); | 327 | 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); | 328 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); |
93 | 329 | ||
94 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | 330 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || |
95 | ( QFile::exists( opiepath + "/bin/ompi" ))) | 331 | ( QFile::exists( opiepath + "/bin/ompi" ))) |
96 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 332 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
97 | 333 | ||
98 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) | 334 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) |
99 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 335 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
100 | 336 | ||
101 | if ( QFile::exists( opiepath + "/bin/opiemail" )) | 337 | if ( QFile::exists( opiepath + "/bin/opiemail" )) |
102 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 338 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
103 | 339 | ||
104 | 340 | ||
105 | 341 | ||
106 | //phoneclients | 342 | //phoneclients |
107 | 343 | ||
108 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); | 344 | 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); | 345 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); |
110 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 346 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
111 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 347 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
112 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 348 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
113 | 349 | ||
114 | //faxclients | 350 | //faxclients |
115 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); | 351 | 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); | 352 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); |
117 | 353 | ||
118 | //smsclients | 354 | //smsclients |
119 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); | 355 | 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); | 356 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); |
121 | 357 | ||
122 | //pagerclients | 358 | //pagerclients |
123 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); | 359 | 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); | 360 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); |
125 | 361 | ||
126 | } | 362 | } |
127 | 363 | ||
128 | ExternalAppHandler *ExternalAppHandler::instance() | 364 | ExternalAppHandler *ExternalAppHandler::instance() |
129 | { | 365 | { |
130 | if ( !sInstance ) { | 366 | if ( !sInstance ) { |
131 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | 367 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); |
132 | sInstance->loadConfig(); | 368 | sInstance->loadConfig(); |
133 | } | 369 | } |
134 | 370 | ||
135 | return sInstance; | 371 | return sInstance; |
136 | } | 372 | } |
137 | 373 | ||
138 | 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) | 374 | 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) |
139 | { | 375 | { |
140 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | 376 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); |
141 | 377 | ||
142 | mDefaultItems.append(dai); | 378 | mDefaultItems.append(dai); |
143 | } | 379 | } |
144 | 380 | ||
145 | 381 | ||
146 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | 382 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) |
147 | { | 383 | { |
148 | QList<DefaultAppItem> list; | 384 | QList<DefaultAppItem> list; |
149 | 385 | ||
150 | DefaultAppItem* dai; | 386 | DefaultAppItem* dai; |
151 | 387 | ||
152 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 388 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
153 | { | 389 | { |
154 | if (dai->_type == type) | 390 | if (dai->_type == type) |
155 | list.append(dai); | 391 | list.append(dai); |
156 | } | 392 | } |
157 | 393 | ||
158 | return list; | 394 | return list; |
159 | } | 395 | } |
160 | 396 | ||
161 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | 397 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) |
162 | { | 398 | { |
163 | DefaultAppItem* dai; | 399 | DefaultAppItem* dai; |
164 | 400 | ||
165 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 401 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
166 | { | 402 | { |
167 | if (dai->_type == type && dai->_id == clientid) | 403 | if (dai->_type == type && dai->_id == clientid) |
168 | return dai; | 404 | return dai; |
169 | } | 405 | } |
170 | 406 | ||
171 | return 0; | 407 | return 0; |
172 | } | 408 | } |
173 | 409 | ||
174 | bool ExternalAppHandler::isEmailAppAvailable() | 410 | bool ExternalAppHandler::isEmailAppAvailable() |
175 | { | 411 | { |
176 | #ifndef DESKTOP_VERSION | 412 | #ifndef DESKTOP_VERSION |
177 | if (mEmailAppAvailable == UNDEFINED) | 413 | if (mEmailAppAvailable == UNDEFINED) |
178 | { | 414 | { |
179 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 415 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
180 | if (client == KPimGlobalPrefs::NONE_EMC) | 416 | if (client == KPimGlobalPrefs::NONE_EMC) |
181 | mEmailAppAvailable = UNAVAILABLE; | 417 | mEmailAppAvailable = UNAVAILABLE; |
182 | else | 418 | else |
183 | mEmailAppAvailable = AVAILABLE; | 419 | mEmailAppAvailable = AVAILABLE; |
184 | } | 420 | } |
185 | return (mEmailAppAvailable == AVAILABLE); | 421 | return (mEmailAppAvailable == AVAILABLE); |
186 | 422 | ||
187 | #else //DESKTOP_VERSION | 423 | #else //DESKTOP_VERSION |
188 | return false; | 424 | return false; |
@@ -266,257 +502,258 @@ bool ExternalAppHandler::isPagerAppAvailable() | |||
266 | **************************************************************************/ | 502 | **************************************************************************/ |
267 | 503 | ||
268 | 504 | ||
269 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) | 505 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) |
270 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) | 506 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) |
271 | { | 507 | { |
272 | 508 | ||
273 | #ifndef DESKTOP_VERSION | 509 | #ifndef DESKTOP_VERSION |
274 | QString channel; | 510 | QString channel; |
275 | QString message2; | 511 | QString message2; |
276 | QString parameters2; | 512 | QString parameters2; |
277 | 513 | ||
278 | 514 | ||
279 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 515 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
280 | if (client == KPimGlobalPrefs::OTHER_EMC) | 516 | if (client == KPimGlobalPrefs::OTHER_EMC) |
281 | { | 517 | { |
282 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 518 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
283 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 519 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
284 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 520 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
285 | } | 521 | } |
286 | else | 522 | else |
287 | { | 523 | { |
288 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 524 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
289 | if (!dai) | 525 | if (!dai) |
290 | { | 526 | { |
291 | qDebug("could not find configured email application."); | 527 | qDebug("could not find configured email application."); |
292 | return false; | 528 | return false; |
293 | } | 529 | } |
294 | channel = dai->_channel; | 530 | channel = dai->_channel; |
295 | message2 = dai->_message2; | 531 | message2 = dai->_message2; |
296 | parameters2 = dai->_parameters2; | 532 | parameters2 = dai->_parameters2; |
297 | } | 533 | } |
298 | 534 | ||
299 | //first check if one of the mailers need the emails right in the message. | 535 | //first check if one of the mailers need the emails right in the message. |
300 | message2 = translateMessage(message2, emails, urls); | 536 | message2 = translateMessage(message2, emails, urls); |
301 | 537 | ||
302 | 538 | ||
303 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 539 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
304 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | 540 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
305 | 541 | ||
306 | 542 | ||
307 | QCopEnvelope e(channel.latin1(), message2.latin1()); | 543 | QCopEnvelope e(channel.latin1(), message2.latin1()); |
308 | //US we need no names in the To field. The emailadresses are enough | 544 | //US we need no names in the To field. The emailadresses are enough |
309 | 545 | ||
310 | passParameters(&e, parameters2, emails, urls); | 546 | passParameters(&e, parameters2, emails, urls); |
311 | 547 | ||
312 | 548 | ||
313 | 549 | ||
314 | #else | 550 | #else |
315 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 551 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
316 | #endif | 552 | #endif |
317 | 553 | ||
318 | return true; | 554 | return true; |
319 | } | 555 | } |
320 | 556 | ||
321 | /************************************************************************** | 557 | /************************************************************************** |
322 | * | 558 | * |
323 | **************************************************************************/ | 559 | **************************************************************************/ |
324 | 560 | ||
325 | 561 | ||
326 | //calls the emailapplication and creates a mail with parameter emails as recipients | 562 | //calls the emailapplication and creates a mail with parameter emails as recipients |
327 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 563 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
328 | { | 564 | { |
329 | #ifndef DESKTOP_VERSION | 565 | #ifndef DESKTOP_VERSION |
330 | QString channel; | 566 | QString channel; |
331 | QString message; | 567 | QString message; |
332 | QString parameters; | 568 | QString parameters; |
333 | 569 | ||
334 | 570 | ||
335 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 571 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
336 | if (client == KPimGlobalPrefs::OTHER_EMC) | 572 | if (client == KPimGlobalPrefs::OTHER_EMC) |
337 | { | 573 | { |
338 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 574 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
339 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 575 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
340 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 576 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
341 | } | 577 | } |
342 | else | 578 | else |
343 | { | 579 | { |
344 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 580 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
345 | if (!dai) | 581 | if (!dai) |
346 | { | 582 | { |
347 | qDebug("could not find configured email application."); | 583 | qDebug("could not find configured email application."); |
348 | return false; | 584 | return false; |
349 | } | 585 | } |
350 | channel = dai->_channel; | 586 | channel = dai->_channel; |
351 | message = dai->_message; | 587 | message = dai->_message; |
352 | parameters = dai->_parameters; | 588 | parameters = dai->_parameters; |
353 | } | 589 | } |
354 | 590 | ||
355 | 591 | ||
356 | //first check if one of the mailers need the emails right in the message. | 592 | //first check if one of the mailers need the emails right in the message. |
357 | message = translateMessage(message, name, emailadress); | 593 | message = translateMessage(message, name, emailadress); |
358 | 594 | ||
359 | 595 | ||
360 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 596 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
361 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 597 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
362 | 598 | ||
363 | QCopEnvelope e(channel.latin1(), message.latin1()); | 599 | QCopEnvelope e(channel.latin1(), message.latin1()); |
364 | //US we need no names in the To field. The emailadresses are enough | 600 | //US we need no names in the To field. The emailadresses are enough |
365 | 601 | ||
366 | passParameters(&e, parameters, name, emailadress); | 602 | passParameters(&e, parameters, name, emailadress); |
367 | 603 | ||
368 | 604 | ||
369 | #else | 605 | #else |
370 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 606 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
371 | #endif | 607 | #endif |
372 | 608 | ||
373 | 609 | ||
374 | return true; | 610 | return true; |
375 | } | 611 | } |
376 | 612 | ||
377 | /************************************************************************** | 613 | /************************************************************************** |
378 | * | 614 | * |
379 | **************************************************************************/ | 615 | **************************************************************************/ |
380 | 616 | ||
381 | //calls the emailapplication and creates a mail with parameter as recipients | 617 | //calls the emailapplication and creates a mail with parameter as recipients |
382 | // parameters format is | 618 | // parameters format is |
383 | // NAME <EMAIL>:SUBJECT | 619 | // NAME <EMAIL>:SUBJECT |
384 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 620 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) |
385 | { | 621 | { |
386 | QString line = adressline; | 622 | QString line = adressline; |
387 | 623 | ||
388 | int first = line.find( "<"); | 624 | int first = line.find( "<"); |
389 | int last = line.find( ">"); | 625 | int last = line.find( ">"); |
390 | QString name = line.left(first); | 626 | QString name = line.left(first); |
391 | QString emailadress = line.mid(first+1, last-first-1); | 627 | QString emailadress = line.mid(first+1, last-first-1); |
392 | 628 | ||
393 | //Subject can not be handled right now. | 629 | //Subject can not be handled right now. |
394 | mailToOneContact( name, emailadress ); | 630 | return mailToOneContact( name, emailadress ); |
631 | |||
395 | } | 632 | } |
396 | 633 | ||
397 | 634 | ||
398 | /************************************************************************** | 635 | /************************************************************************** |
399 | * | 636 | * |
400 | **************************************************************************/ | 637 | **************************************************************************/ |
401 | 638 | ||
402 | //calls the phoneapplication with the number | 639 | //calls the phoneapplication with the number |
403 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 640 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) |
404 | { | 641 | { |
405 | #ifndef DESKTOP_VERSION | 642 | #ifndef DESKTOP_VERSION |
406 | QString channel; | 643 | QString channel; |
407 | QString message; | 644 | QString message; |
408 | QString parameters; | 645 | QString parameters; |
409 | 646 | ||
410 | 647 | ||
411 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 648 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
412 | if (client == KPimGlobalPrefs::OTHER_PHC) | 649 | if (client == KPimGlobalPrefs::OTHER_PHC) |
413 | { | 650 | { |
414 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | 651 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; |
415 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | 652 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; |
416 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | 653 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; |
417 | } | 654 | } |
418 | else | 655 | else |
419 | { | 656 | { |
420 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 657 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
421 | if (!dai) | 658 | if (!dai) |
422 | { | 659 | { |
423 | qDebug("could not find configured phone application."); | 660 | qDebug("could not find configured phone application."); |
424 | return false; | 661 | return false; |
425 | } | 662 | } |
426 | channel = dai->_channel; | 663 | channel = dai->_channel; |
427 | message = dai->_message; | 664 | message = dai->_message; |
428 | parameters = dai->_parameters; | 665 | parameters = dai->_parameters; |
429 | } | 666 | } |
430 | 667 | ||
431 | 668 | ||
432 | //first check if one of the mailers need the emails right in the message. | 669 | //first check if one of the mailers need the emails right in the message. |
433 | message = translateMessage(message, phonenumber, ""); | 670 | message = translateMessage(message, phonenumber, ""); |
434 | 671 | ||
435 | 672 | ||
436 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 673 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
437 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 674 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
438 | 675 | ||
439 | QCopEnvelope e(channel.latin1(), message.latin1()); | 676 | QCopEnvelope e(channel.latin1(), message.latin1()); |
440 | //US we need no names in the To field. The emailadresses are enough | 677 | //US we need no names in the To field. The emailadresses are enough |
441 | 678 | ||
442 | passParameters(&e, parameters, phonenumber, ""); | 679 | passParameters(&e, parameters, phonenumber, ""); |
443 | 680 | ||
444 | 681 | ||
445 | #else | 682 | #else |
446 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); | 683 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
447 | #endif | 684 | #endif |
448 | 685 | ||
449 | 686 | ||
450 | return true; | 687 | return true; |
451 | } | 688 | } |
452 | 689 | ||
453 | /************************************************************************** | 690 | /************************************************************************** |
454 | * | 691 | * |
455 | **************************************************************************/ | 692 | **************************************************************************/ |
456 | 693 | ||
457 | //calls the smsapplication with the number | 694 | //calls the smsapplication with the number |
458 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 695 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
459 | { | 696 | { |
460 | #ifndef DESKTOP_VERSION | 697 | #ifndef DESKTOP_VERSION |
461 | QString channel; | 698 | QString channel; |
462 | QString message; | 699 | QString message; |
463 | QString parameters; | 700 | QString parameters; |
464 | 701 | ||
465 | 702 | ||
466 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 703 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
467 | if (client == KPimGlobalPrefs::OTHER_SMC) | 704 | if (client == KPimGlobalPrefs::OTHER_SMC) |
468 | { | 705 | { |
469 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; | 706 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; |
470 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; | 707 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; |
471 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; | 708 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; |
472 | } | 709 | } |
473 | else | 710 | else |
474 | { | 711 | { |
475 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); | 712 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); |
476 | if (!dai) | 713 | if (!dai) |
477 | { | 714 | { |
478 | qDebug("could not find configured sms application."); | 715 | qDebug("could not find configured sms application."); |
479 | return false; | 716 | return false; |
480 | } | 717 | } |
481 | channel = dai->_channel; | 718 | channel = dai->_channel; |
482 | message = dai->_message; | 719 | message = dai->_message; |
483 | parameters = dai->_parameters; | 720 | parameters = dai->_parameters; |
484 | } | 721 | } |
485 | 722 | ||
486 | 723 | ||
487 | //first check if one of the mailers need the emails right in the message. | 724 | //first check if one of the mailers need the emails right in the message. |
488 | message = translateMessage(message, phonenumber, ""); | 725 | message = translateMessage(message, phonenumber, ""); |
489 | 726 | ||
490 | 727 | ||
491 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 728 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
492 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 729 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
493 | 730 | ||
494 | QCopEnvelope e(channel.latin1(), message.latin1()); | 731 | QCopEnvelope e(channel.latin1(), message.latin1()); |
495 | //US we need no names in the To field. The emailadresses are enough | 732 | //US we need no names in the To field. The emailadresses are enough |
496 | 733 | ||
497 | passParameters(&e, parameters, phonenumber, ""); | 734 | passParameters(&e, parameters, phonenumber, ""); |
498 | 735 | ||
499 | 736 | ||
500 | #else | 737 | #else |
501 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); | 738 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); |
502 | #endif | 739 | #endif |
503 | 740 | ||
504 | 741 | ||
505 | return true; | 742 | return true; |
506 | } | 743 | } |
507 | 744 | ||
508 | /************************************************************************** | 745 | /************************************************************************** |
509 | * | 746 | * |
510 | **************************************************************************/ | 747 | **************************************************************************/ |
511 | 748 | ||
512 | //calls the pagerapplication with the number | 749 | //calls the pagerapplication with the number |
513 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) | 750 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) |
514 | { | 751 | { |
515 | #ifndef DESKTOP_VERSION | 752 | #ifndef DESKTOP_VERSION |
516 | QString channel; | 753 | QString channel; |
517 | QString message; | 754 | QString message; |
518 | QString parameters; | 755 | QString parameters; |
519 | 756 | ||
520 | 757 | ||
521 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 758 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
522 | if (client == KPimGlobalPrefs::OTHER_PAC) | 759 | if (client == KPimGlobalPrefs::OTHER_PAC) |
@@ -554,128 +791,169 @@ bool ExternalAppHandler::callByPager( const QString& pagernumber ) | |||
554 | 791 | ||
555 | #else | 792 | #else |
556 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); | 793 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); |
557 | #endif | 794 | #endif |
558 | 795 | ||
559 | 796 | ||
560 | return true; | 797 | return true; |
561 | } | 798 | } |
562 | 799 | ||
563 | /************************************************************************** | 800 | /************************************************************************** |
564 | * | 801 | * |
565 | **************************************************************************/ | 802 | **************************************************************************/ |
566 | 803 | ||
567 | //calls the faxapplication with the number | 804 | //calls the faxapplication with the number |
568 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) | 805 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) |
569 | { | 806 | { |
570 | #ifndef DESKTOP_VERSION | 807 | #ifndef DESKTOP_VERSION |
571 | QString channel; | 808 | QString channel; |
572 | QString message; | 809 | QString message; |
573 | QString parameters; | 810 | QString parameters; |
574 | 811 | ||
575 | 812 | ||
576 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 813 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
577 | if (client == KPimGlobalPrefs::OTHER_FAC) | 814 | if (client == KPimGlobalPrefs::OTHER_FAC) |
578 | { | 815 | { |
579 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; | 816 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; |
580 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; | 817 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; |
581 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; | 818 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; |
582 | } | 819 | } |
583 | else | 820 | else |
584 | { | 821 | { |
585 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); | 822 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); |
586 | if (!dai) | 823 | if (!dai) |
587 | { | 824 | { |
588 | qDebug("could not find configured fax application."); | 825 | qDebug("could not find configured fax application."); |
589 | return false; | 826 | return false; |
590 | } | 827 | } |
591 | channel = dai->_channel; | 828 | channel = dai->_channel; |
592 | message = dai->_message; | 829 | message = dai->_message; |
593 | parameters = dai->_parameters; | 830 | parameters = dai->_parameters; |
594 | } | 831 | } |
595 | 832 | ||
596 | 833 | ||
597 | //first check if one of the mailers need the emails right in the message. | 834 | //first check if one of the mailers need the emails right in the message. |
598 | message = translateMessage(message, faxnumber, ""); | 835 | message = translateMessage(message, faxnumber, ""); |
599 | 836 | ||
600 | 837 | ||
601 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 838 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
602 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); | 839 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); |
603 | 840 | ||
604 | QCopEnvelope e(channel.latin1(), message.latin1()); | 841 | QCopEnvelope e(channel.latin1(), message.latin1()); |
605 | //US we need no names in the To field. The emailadresses are enough | 842 | //US we need no names in the To field. The emailadresses are enough |
606 | 843 | ||
607 | passParameters(&e, parameters, faxnumber, ""); | 844 | passParameters(&e, parameters, faxnumber, ""); |
608 | 845 | ||
609 | 846 | ||
610 | #else | 847 | #else |
611 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); | 848 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); |
612 | #endif | 849 | #endif |
613 | 850 | ||
614 | 851 | ||
615 | return true; | 852 | return true; |
616 | } | 853 | } |
617 | 854 | ||
618 | /************************************************************************** | 855 | /************************************************************************** |
619 | * | 856 | * |
620 | **************************************************************************/ | 857 | **************************************************************************/ |
621 | 858 | ||
622 | 859 | ||
623 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const | 860 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const |
624 | { | 861 | { |
625 | message = message.replace( QRegExp("%1"), param1 ); | 862 | message = message.replace( QRegExp("%1"), param1 ); |
626 | return message.replace( QRegExp("%2"), param2 ); | 863 | return message.replace( QRegExp("%2"), param2 ); |
627 | } | 864 | } |
628 | 865 | ||
629 | /************************************************************************** | 866 | /************************************************************************** |
630 | * | 867 | * |
631 | **************************************************************************/ | 868 | **************************************************************************/ |
632 | 869 | ||
633 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const | 870 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const |
634 | { | 871 | { |
635 | #ifndef DESKTOP_VERSION | 872 | #ifndef DESKTOP_VERSION |
636 | QMap<QString, QString> valmap; | 873 | QMap<QString, QString> valmap; |
637 | bool useValMap = false; | 874 | bool useValMap = false; |
638 | 875 | ||
639 | // first extract all parts of the parameters. | 876 | // first extract all parts of the parameters. |
640 | QStringList paramlist = QStringList::split(";", parameters); | 877 | QStringList paramlist = QStringList::split(";", parameters); |
641 | 878 | ||
642 | //Now check how many parts we have. | 879 | //Now check how many parts we have. |
643 | //=0 :no params to pass | 880 | //=0 :no params to pass |
644 | //>0 :parameters to pass | 881 | //>0 :parameters to pass |
645 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) | 882 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) |
646 | { | 883 | { |
647 | QString param = (*it); | 884 | QString param = (*it); |
648 | QStringList keyvallist = QStringList::split("=", param); | 885 | QStringList keyvallist = QStringList::split("=", param); |
649 | 886 | ||
650 | //if we have keyvalue pairs, we assume that we pass a map to the envelope | 887 | //if we have keyvalue pairs, we assume that we pass a map to the envelope |
651 | QStringList::Iterator it2 = keyvallist.begin(); | 888 | QStringList::Iterator it2 = keyvallist.begin(); |
652 | QString key = (*it2); | 889 | QString key = (*it2); |
653 | key = key.replace( QRegExp("%1"), param1 ); | 890 | key = key.replace( QRegExp("%1"), param1 ); |
654 | key = key.replace( QRegExp("%2"), param2 ); | 891 | key = key.replace( QRegExp("%2"), param2 ); |
655 | ++it2; | 892 | ++it2; |
656 | 893 | ||
657 | if(it2 != keyvallist.end()) | 894 | if(it2 != keyvallist.end()) |
658 | { | 895 | { |
659 | QString value = (*it2); | 896 | QString value = (*it2); |
660 | value = value.replace( QRegExp("%1"), param1 ); | 897 | value = value.replace( QRegExp("%1"), param1 ); |
661 | value = value.replace( QRegExp("%2"), param2 ); | 898 | value = value.replace( QRegExp("%2"), param2 ); |
662 | 899 | ||
663 | valmap.insert(key, value); | 900 | valmap.insert(key, value); |
664 | useValMap = true; | 901 | useValMap = true; |
665 | } | 902 | } |
666 | else | 903 | else |
667 | { | 904 | { |
668 | // qDebug("pass parameter << %s", key.latin1()); | 905 | // qDebug("pass parameter << %s", key.latin1()); |
669 | (*e) << key; | 906 | (*e) << key; |
670 | } | 907 | } |
671 | } | 908 | } |
672 | 909 | ||
673 | if (useValMap == true) | 910 | if (useValMap == true) |
674 | (*e) << valmap; | 911 | (*e) << valmap; |
675 | 912 | ||
676 | #endif | 913 | #endif |
677 | 914 | ||
678 | } | 915 | } |
679 | 916 | ||
680 | 917 | ||
681 | 918 | ||
919 | /************************************************************************** | ||
920 | * | ||
921 | **************************************************************************/ | ||
922 | |||
923 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) | ||
924 | { | ||
925 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | ||
926 | |||
927 | // if (!res) | ||
928 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | ||
929 | } | ||
930 | |||
931 | |||
932 | |||
933 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid) | ||
934 | { | ||
935 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | ||
936 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(uid, QString::null); | ||
937 | } | ||
938 | |||
939 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | ||
940 | { | ||
941 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | ||
942 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(uid, list1, list2, list3); | ||
943 | } | ||
944 | |||
945 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QString& email) | ||
946 | { | ||
947 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | ||
948 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(uid, email); | ||
949 | } | ||
950 | |||
951 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | ||
952 | { | ||
953 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | ||
954 | return mFindByEmailFromKAPITransfer->sendMessageToSource(uid, list1, list2, list3); | ||
955 | } | ||
956 | |||
957 | |||
958 | |||
959 | |||