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