summaryrefslogtreecommitdiffabout
path: root/libkdepim/externalapphandler.cpp
Unidiff
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index f376e6c..3fc548a 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -10,65 +10,67 @@
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 <qtimer.h> 33#include <qtimer.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qregexp.h> 35#include <qregexp.h>
36 36
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include <qtopia/qcopenvelope_qws.h> 39#include <qtopia/qcopenvelope_qws.h>
40#else 40#else
41#include <qapplication.h> 41#include <qapplication.h>
42#include <qprocess.h> 42#include <q3process.h>
43//Added by qt3to4:
44#include <Q3CString>
43#endif 45#endif
44 46
45#include <kstaticdeleter.h> 47#include <kstaticdeleter.h>
46#include <kmessagebox.h> 48#include <kmessagebox.h>
47 49
48 50
49#include "externalapphandler.h" 51#include "externalapphandler.h"
50 52
51#include "kpimglobalprefs.h" 53#include "kpimglobalprefs.h"
52 54
53//uncomment line to get debug output 55//uncomment line to get debug output
54//#define DEBUG_EXT_APP_HANDLER 56//#define DEBUG_EXT_APP_HANDLER
55 57
56/********************************************************************************* 58/*********************************************************************************
57 * 59 *
58 ********************************************************************************/ 60 ********************************************************************************/
59 61
60 62
61QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 63QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
62 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) 64 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
63{ 65{
64 //sourceMessage passes later three parameters: sourceChannel, uid, param1 66 //sourceMessage passes later three parameters: sourceChannel, uid, param1
65 if (_usedSourceParameters == 0) 67 if (_usedSourceParameters == 0)
66 _sourceMessageParameters = "QString,QString)"; 68 _sourceMessageParameters = "QString,QString)";
67 else if (_usedSourceParameters == 1) 69 else if (_usedSourceParameters == 1)
68 _sourceMessageParameters = "(QString,QString,QString)"; 70 _sourceMessageParameters = "(QString,QString,QString)";
69 else if (_usedSourceParameters == 2) 71 else if (_usedSourceParameters == 2)
70 _sourceMessageParameters = "(QString,QString,QString,QString)"; 72 _sourceMessageParameters = "(QString,QString,QString,QString)";
71 else if (_usedSourceParameters == 3) 73 else if (_usedSourceParameters == 3)
72 _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; 74 _sourceMessageParameters = "(QString,QString,QString,QString,QString)";
73} 75}
74 76
@@ -94,88 +96,88 @@ bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& pa
94 96
95 e << _sourceChannel << uid; 97 e << _sourceChannel << uid;
96 98
97 if (_usedSourceParameters == 1) 99 if (_usedSourceParameters == 1)
98 e << param1; 100 e << param1;
99 else if (_usedSourceParameters == 2) 101 else if (_usedSourceParameters == 2)
100 e << param1 << param2; 102 e << param1 << param2;
101 else if (_usedSourceParameters == 3) 103 else if (_usedSourceParameters == 3)
102 e << param1 << param2 << param3; 104 e << param1 << param2 << param3;
103 105
104 qApp->processEvents(); 106 qApp->processEvents();
105 107
106 return true; 108 return true;
107 109
108#else 110#else
109 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 111 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
110 return false; 112 return false;
111#endif 113#endif
112 114
113} 115}
114 116
115 117
116/*********************************************************************************/ 118/*********************************************************************************/
117void QCopTransferItem::setSourceChannel(const QString& sourceChannel) 119void QCopTransferItem::setSourceChannel(const QString& sourceChannel)
118{ 120{
119 121
120 if ( !sourceChannel.isEmpty()) 122 if ( !sourceChannel.isEmpty())
121 _sourceChannel = sourceChannel; 123 _sourceChannel = sourceChannel;
122} 124}
123 125
124 126
125/*********************************************************************************/ 127/*********************************************************************************/
126bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 128bool QCopTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data )
127{ 129{
128 130
129 // copied from old mail2 131 // copied from old mail2
130/* 132/*
131 static int ii = 0; 133 static int ii = 0;
132 134
133 // block second call 135 // block second call
134 if ( ii < 2 ) { 136 if ( ii < 2 ) {
135 ++ii; 137 ++ii;
136 if ( ii > 1 ) { 138 if ( ii > 1 ) {
137 qDebug("qcop call blocked "); 139 qDebug("qcop call blocked ");
138 return true; 140 return true;
139 } 141 }
140 } 142 }
141*/ 143*/
142 144
143// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); 145// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
144 146
145 //we are in the target and get a request from the source 147 //we are in the target and get a request from the source
146 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) 148 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
147 { 149 {
148 150
149 QDataStream stream( data, IO_ReadOnly ); 151 QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly );
150 152
151 153
152 QString sourceChannel; 154 QString sourceChannel;
153 QString uid; 155 QString uid;
154 QString param1; 156 QString param1;
155 QString param2; 157 QString param2;
156 QString param3; 158 QString param3;
157 159
158 stream >> sourceChannel >> uid; 160 stream >> sourceChannel >> uid;
159 161
160 if (_usedSourceParameters == 0) 162 if (_usedSourceParameters == 0)
161 { 163 {
162 emit receivedMessageFromSource(sourceChannel, uid); 164 emit receivedMessageFromSource(sourceChannel, uid);
163 } 165 }
164 else if (_usedSourceParameters == 1) 166 else if (_usedSourceParameters == 1)
165 { 167 {
166 stream >> param1; 168 stream >> param1;
167 emit receivedMessageFromSource(sourceChannel, uid, param1); 169 emit receivedMessageFromSource(sourceChannel, uid, param1);
168 } 170 }
169 else if (_usedSourceParameters == 2) 171 else if (_usedSourceParameters == 2)
170 { 172 {
171 stream >> param1 >> param2; 173 stream >> param1 >> param2;
172 emit receivedMessageFromSource(sourceChannel, uid, param1, param2); 174 emit receivedMessageFromSource(sourceChannel, uid, param1, param2);
173 } 175 }
174 else if (_usedSourceParameters == 3) 176 else if (_usedSourceParameters == 3)
175 { 177 {
176 stream >> param1 >> param2 >> param3; 178 stream >> param1 >> param2 >> param3;
177 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); 179 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3);
178 } 180 }
179 181
180 return true; 182 return true;
181 } 183 }
@@ -197,71 +199,71 @@ QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString
197} 199}
198 200
199/*********************************************************************************/ 201/*********************************************************************************/
200bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) 202bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap)
201{ 203{
202#ifndef DESKTOP_VERSION 204#ifndef DESKTOP_VERSION
203 //targetMessage passes two parameters: uid, map 205 //targetMessage passes two parameters: uid, map
204 QString targetMessage = _targetMessage + _targetMessageParameters; 206 QString targetMessage = _targetMessage + _targetMessageParameters;
205 207
206#ifdef DEBUG_EXT_APP_HANDLER 208#ifdef DEBUG_EXT_APP_HANDLER
207 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 209 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
208 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); 210 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
209#endif 211#endif
210 212
211 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 213 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
212 //US we need no names in the To field. The emailadresses are enough 214 //US we need no names in the To field. The emailadresses are enough
213 215
214 e << uid << nameEmailMap; 216 e << uid << nameEmailMap;
215 217
216 qApp->processEvents(); 218 qApp->processEvents();
217 219
218 return true; 220 return true;
219 221
220#else 222#else
221 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 223 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
222 return false; 224 return false;
223#endif 225#endif
224 226
225} 227}
226 228
227 229
228/*********************************************************************************/ 230/*********************************************************************************/
229bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 231bool QCopMapTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data )
230{ 232{
231 bool res = QCopTransferItem::appMessage( cmsg, data ); 233 bool res = QCopTransferItem::appMessage( cmsg, data );
232 234
233 if (res == false) 235 if (res == false)
234 { 236 {
235 QDataStream stream( data, IO_ReadOnly ); 237 QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly );
236 238
237// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); 239// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() );
238 240
239 //we are in the source and get an answer from the target 241 //we are in the source and get an answer from the target
240 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 242 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
241 { 243 {
242 QMap<QString,QString> adrMap; 244 QMap<QString,QString> adrMap;
243 QString uid; 245 QString uid;
244 246
245 stream >> uid >> adrMap; 247 stream >> uid >> adrMap;
246 248
247 emit receivedMessageFromTarget(uid, adrMap); 249 emit receivedMessageFromTarget(uid, adrMap);
248 250
249 251
250 return true; 252 return true;
251 } 253 }
252 } 254 }
253 255
254 return false; 256 return false;
255} 257}
256 258
257 259
258/********************************************************************************* 260/*********************************************************************************
259 * 261 *
260 ********************************************************************************/ 262 ********************************************************************************/
261 263
262QCopListTransferItem::~QCopListTransferItem() 264QCopListTransferItem::~QCopListTransferItem()
263{ 265{
264 266
265} 267}
266 268
267QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 269QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
@@ -276,74 +278,74 @@ bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QString
276{ 278{
277#ifndef DESKTOP_VERSION 279#ifndef DESKTOP_VERSION
278 //targetMessage passes two parameters: uid, map 280 //targetMessage passes two parameters: uid, map
279 QString targetMessage = _targetMessage + _targetMessageParameters; 281 QString targetMessage = _targetMessage + _targetMessageParameters;
280 282
281#ifdef DEBUG_EXT_APP_HANDLER 283#ifdef DEBUG_EXT_APP_HANDLER
282 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 284 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
283 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); 285 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1());
284 286
285 287
286 for ( int i = 0; i < list3.count(); i++) 288 for ( int i = 0; i < list3.count(); i++)
287 qDebug("listentry list3: %s",list3[i].latin1()); 289 qDebug("listentry list3: %s",list3[i].latin1());
288#endif 290#endif
289 291
290 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 292 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
291 //US we need no names in the To field. The emailadresses are enough 293 //US we need no names in the To field. The emailadresses are enough
292 294
293 e << uid << list1 << list2 << list3 << list4 << list5 << list6; 295 e << uid << list1 << list2 << list3 << list4 << list5 << list6;
294 296
295 qApp->processEvents(); 297 qApp->processEvents();
296 298
297 return true; 299 return true;
298 300
299#else 301#else
300 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 302 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
301 return false; 303 return false;
302#endif 304#endif
303 305
304} 306}
305 307
306 308
307/*********************************************************************************/ 309/*********************************************************************************/
308bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 310bool QCopListTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data )
309{ 311{
310 bool res = QCopTransferItem::appMessage( cmsg, data ); 312 bool res = QCopTransferItem::appMessage( cmsg, data );
311#ifdef DEBUG_EXT_APP_HANDLER 313#ifdef DEBUG_EXT_APP_HANDLER
312 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 314 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
313#endif 315#endif
314 316
315 if (res == false) 317 if (res == false)
316 { 318 {
317 QDataStream stream( data, IO_ReadOnly ); 319 QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly );
318 320
319#ifdef DEBUG_EXT_APP_HANDLER 321#ifdef DEBUG_EXT_APP_HANDLER
320 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 322 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
321#endif 323#endif
322 324
323 //we are in the source and get an answer from the target 325 //we are in the source and get an answer from the target
324 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 326 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
325 { 327 {
326 QStringList list1; 328 QStringList list1;
327 QStringList list2; 329 QStringList list2;
328 QStringList list3; 330 QStringList list3;
329 QStringList list4; 331 QStringList list4;
330 QStringList list5; 332 QStringList list5;
331 QStringList list6; 333 QStringList list6;
332 QString uid; 334 QString uid;
333 335
334#ifdef DEBUG_EXT_APP_HANDLER 336#ifdef DEBUG_EXT_APP_HANDLER
335 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 337 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
336#endif 338#endif
337 339
338 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; 340 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6;
339 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); 341 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6);
340 342
341 343
342 return true; 344 return true;
343 } 345 }
344 } 346 }
345 347
346 return false; 348 return false;
347} 349}
348 350
349 351
@@ -489,67 +491,67 @@ void ExternalAppHandler::loadConfig()
489 491
490 //pagerclients 492 //pagerclients
491 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 493 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
492 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 494 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
493 495
494 //sipclients 496 //sipclients
495 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); 497 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined);
496 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); 498 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined);
497 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 499 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
498 ( QFile::exists( opiepath + "/bin/kppi" ))) 500 ( QFile::exists( opiepath + "/bin/kppi" )))
499 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 501 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
500 502
501} 503}
502 504
503ExternalAppHandler *ExternalAppHandler::instance() 505ExternalAppHandler *ExternalAppHandler::instance()
504{ 506{
505 if ( !sInstance ) { 507 if ( !sInstance ) {
506 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 508 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
507 sInstance->loadConfig(); 509 sInstance->loadConfig();
508 } 510 }
509 511
510 return sInstance; 512 return sInstance;
511} 513}
512 514
513void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 515void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
514{ 516{
515 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 517 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
516 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); 518 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
517 mDefaultItems.append(dai); 519 mDefaultItems.append(dai);
518} 520}
519 521
520 522
521QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 523Q3PtrList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
522{ 524{
523 QList<DefaultAppItem> list; 525 Q3PtrList<DefaultAppItem> list;
524 526
525 DefaultAppItem* dai; 527 DefaultAppItem* dai;
526 528
527 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 529 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
528 { 530 {
529 if (dai->_type == type) 531 if (dai->_type == type)
530 list.append(dai); 532 list.append(dai);
531 } 533 }
532 534
533 return list; 535 return list;
534} 536}
535 537
536DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 538DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
537{ 539{
538 DefaultAppItem* dai; 540 DefaultAppItem* dai;
539 541
540 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 542 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
541 { 543 {
542 if (dai->_type == type && dai->_id == clientid) 544 if (dai->_type == type && dai->_id == clientid)
543 return dai; 545 return dai;
544 } 546 }
545 547
546 return 0; 548 return 0;
547} 549}
548 550
549bool ExternalAppHandler::isEmailAppAvailable() 551bool ExternalAppHandler::isEmailAppAvailable()
550{ 552{
551 553
552 if (mEmailAppAvailable == UNDEFINED) 554 if (mEmailAppAvailable == UNDEFINED)
553 { 555 {
554 int client = KPimGlobalPrefs::instance()->mEmailClient; 556 int client = KPimGlobalPrefs::instance()->mEmailClient;
555 if (client == KPimGlobalPrefs::NONE_EMC) 557 if (client == KPimGlobalPrefs::NONE_EMC)
@@ -717,169 +719,169 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS
717 int client = KPimGlobalPrefs::instance()->mEmailClient; 719 int client = KPimGlobalPrefs::instance()->mEmailClient;
718 if (client == KPimGlobalPrefs::OTHER_EMC) 720 if (client == KPimGlobalPrefs::OTHER_EMC)
719 { 721 {
720 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 722 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
721 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 723 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
722 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2; 724 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2;
723 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 725 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
724 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2; 726 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2;
725 } 727 }
726 else 728 else
727 { 729 {
728 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 730 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
729 if (!dai) 731 if (!dai)
730 { 732 {
731 qDebug("could not find configured email application."); 733 qDebug("could not find configured email application.");
732 return false; 734 return false;
733 } 735 }
734 channel = dai->_channel; 736 channel = dai->_channel;
735 message2 = dai->_message2; 737 message2 = dai->_message2;
736 parameters2 = dai->_parameters2; 738 parameters2 = dai->_parameters2;
737 message = dai->_message; 739 message = dai->_message;
738 parameters = dai->_parameters; 740 parameters = dai->_parameters;
739 } 741 }
740 742
741 //first check if one of the mailers need the emails right in the message. 743 //first check if one of the mailers need the emails right in the message.
742 message2 = translateMessage(message2, emails, urls); 744 message2 = translateMessage(message2, emails, urls);
743#ifdef DEBUG_EXT_APP_HANDLER 745#ifdef DEBUG_EXT_APP_HANDLER
744 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 746 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
745 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 747 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
746#endif 748#endif
747 qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); 749 qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() );
748 //KMessageBox::sorry( 0, message2 ); 750 //KMessageBox::sorry( 0, message2 );
749 QProcess * proc = new QProcess( this ); 751 Q3Process * proc = new Q3Process( this );
750 int i = 0; 752 int i = 0;
751 proc->addArgument( channel ); 753 proc->addArgument( channel );
752 754
753 if ( message.find (" " ) > 0 ) { 755 if ( message.find (" " ) > 0 ) {
754 QStringList list = QStringList::split( " ", message ); 756 QStringList list = QStringList::split( " ", message );
755 int i = 0; 757 int i = 0;
756 while ( i < list.count ( ) ) { 758 while ( i < list.count ( ) ) {
757 //qDebug("add%sdd ",list[i].latin1() ); 759 //qDebug("add%sdd ",list[i].latin1() );
758 proc->addArgument( list[i] ); 760 proc->addArgument( list[i] );
759 //KMessageBox::sorry( 0,list[i]); 761 //KMessageBox::sorry( 0,list[i]);
760 ++i; 762 ++i;
761 } 763 }
762 } else { 764 } else {
763 proc->addArgument(message ); 765 proc->addArgument(message );
764 //KMessageBox::sorry( 0, message ); 766 //KMessageBox::sorry( 0, message );
765 767
766 } 768 }
767 769
768 parameters2 = translateMessage(parameters2, urls, "" ); 770 parameters2 = translateMessage(parameters2, urls, "" );
769 QString arg = "to='%1'"; 771 QString arg = "to='%1'";
770 arg = arg.arg( emails ) + ","+parameters2;; 772 arg = arg.arg( emails ) + ","+parameters2;;
771 773
772 //KMessageBox::sorry( 0,arg ); 774 //KMessageBox::sorry( 0,arg );
773 //qDebug("2add%sdd ",arg.latin1() ); 775 //qDebug("2add%sdd ",arg.latin1() );
774 proc->addArgument( arg); 776 proc->addArgument( arg);
775 proc->launch(""); 777 proc->launch(QString());
776#endif 778#endif
777 779
778 return true; 780 return true;
779} 781}
780 782
781/************************************************************************** 783/**************************************************************************
782 * 784 *
783 **************************************************************************/ 785 **************************************************************************/
784 786
785 787
786//calls the emailapplication and creates a mail with parameter emails as recipients 788//calls the emailapplication and creates a mail with parameter emails as recipients
787bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 789bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
788{ 790{
789 791
790 QString channel; 792 QString channel;
791 QString message; 793 QString message;
792 QString parameters; 794 QString parameters;
793 795
794 796
795 int client = KPimGlobalPrefs::instance()->mEmailClient; 797 int client = KPimGlobalPrefs::instance()->mEmailClient;
796 if (client == KPimGlobalPrefs::OTHER_EMC) 798 if (client == KPimGlobalPrefs::OTHER_EMC)
797 { 799 {
798 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 800 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
799 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 801 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
800 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 802 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
801 } 803 }
802 else 804 else
803 { 805 {
804 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 806 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
805 if (!dai) 807 if (!dai)
806 { 808 {
807 qDebug("could not find configured email application."); 809 qDebug("could not find configured email application.");
808 return false; 810 return false;
809 } 811 }
810 channel = dai->_channel; 812 channel = dai->_channel;
811 message = dai->_message; 813 message = dai->_message;
812 parameters = dai->_parameters; 814 parameters = dai->_parameters;
813 } 815 }
814 816
815#ifdef DESKTOP_VERSION 817#ifdef DESKTOP_VERSION
816 //message = channel + " " +message + " \""+ parameters + "\""; 818 //message = channel + " " +message + " \""+ parameters + "\"";
817#endif 819#endif
818 //first check if one of the mailers need the emails right in the message. 820 //first check if one of the mailers need the emails right in the message.
819 message = translateMessage(message, name, emailadress); 821 message = translateMessage(message, name, emailadress);
820 822
821#ifdef DEBUG_EXT_APP_HANDLER 823#ifdef DEBUG_EXT_APP_HANDLER
822 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 824 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
823 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); 825 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
824#endif 826#endif
825 827
826#ifndef DESKTOP_VERSION 828#ifndef DESKTOP_VERSION
827 QCopEnvelope e(channel.latin1(), message.latin1()); 829 QCopEnvelope e(channel.latin1(), message.latin1());
828 //US we need no names in the To field. The emailadresses are enough 830 //US we need no names in the To field. The emailadresses are enough
829 831
830 passParameters(&e, parameters, name, emailadress); 832 passParameters(&e, parameters, name, emailadress);
831#else // DESKTOP_VERSION 833#else // DESKTOP_VERSION
832 834
833 //KMessageBox::sorry( 0,channel ); 835 //KMessageBox::sorry( 0,channel );
834 QProcess * proc = new QProcess( this ); 836 Q3Process * proc = new Q3Process( this );
835 proc->addArgument( channel ); 837 proc->addArgument( channel );
836 if ( message.find (" " ) > 0 ) { 838 if ( message.find (" " ) > 0 ) {
837 QStringList list = QStringList::split( " ", message ); 839 QStringList list = QStringList::split( " ", message );
838 int i = 0; 840 int i = 0;
839 while ( i < list.count ( ) ) { 841 while ( i < list.count ( ) ) {
840 //qDebug("add%sdd ",list[i].latin1() ); 842 //qDebug("add%sdd ",list[i].latin1() );
841 proc->addArgument( list[i] ); 843 proc->addArgument( list[i] );
842 //KMessageBox::sorry( 0,list[i]); 844 //KMessageBox::sorry( 0,list[i]);
843 ++i; 845 ++i;
844 } 846 }
845 } else { 847 } else {
846 proc->addArgument(message ); 848 proc->addArgument(message );
847 849
848 } 850 }
849 parameters = translateMessage(parameters, name, emailadress); 851 parameters = translateMessage(parameters, name, emailadress);
850 852
851 //KMessageBox::information(0,parameters); 853 //KMessageBox::information(0,parameters);
852 proc->addArgument( parameters ); 854 proc->addArgument( parameters );
853 proc->launch(""); 855 proc->launch(QString());
854#endif 856#endif
855 857
856 return true; 858 return true;
857} 859}
858 860
859/************************************************************************** 861/**************************************************************************
860 * 862 *
861 **************************************************************************/ 863 **************************************************************************/
862 864
863//calls the emailapplication and creates a mail with parameter as recipients 865//calls the emailapplication and creates a mail with parameter as recipients
864// parameters format is 866// parameters format is
865// NAME <EMAIL>:SUBJECT 867// NAME <EMAIL>:SUBJECT
866bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 868bool ExternalAppHandler::mailToOneContact( const QString& adressline )
867{ 869{
868 QString line = adressline; 870 QString line = adressline;
869 871
870 int first = line.find( "<"); 872 int first = line.find( "<");
871 int last = line.find( ">"); 873 int last = line.find( ">");
872 QString name = line.left(first); 874 QString name = line.left(first);
873 QString emailadress = line.mid(first+1, last-first-1); 875 QString emailadress = line.mid(first+1, last-first-1);
874 876
875 //Subject can not be handled right now. 877 //Subject can not be handled right now.
876 return mailToOneContact( name, emailadress ); 878 return mailToOneContact( name, emailadress );
877 879
878} 880}
879 881
880 882
881/************************************************************************** 883/**************************************************************************
882 * 884 *
883 **************************************************************************/ 885 **************************************************************************/
884 886
885//calls the phoneapplication with the number 887//calls the phoneapplication with the number
@@ -1203,65 +1205,65 @@ void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& paramete
1203 key = key.replace( QRegExp("%2"), param2 ); 1205 key = key.replace( QRegExp("%2"), param2 );
1204 ++it2; 1206 ++it2;
1205 1207
1206 if(it2 != keyvallist.end()) 1208 if(it2 != keyvallist.end())
1207 { 1209 {
1208 QString value = (*it2); 1210 QString value = (*it2);
1209 value = value.replace( QRegExp("%1"), param1 ); 1211 value = value.replace( QRegExp("%1"), param1 );
1210 value = value.replace( QRegExp("%2"), param2 ); 1212 value = value.replace( QRegExp("%2"), param2 );
1211 1213
1212 valmap.insert(key, value); 1214 valmap.insert(key, value);
1213 useValMap = true; 1215 useValMap = true;
1214 } 1216 }
1215 else 1217 else
1216 { 1218 {
1217 // qDebug("pass parameter << %s", key.latin1()); 1219 // qDebug("pass parameter << %s", key.latin1());
1218 (*e) << key; 1220 (*e) << key;
1219 } 1221 }
1220 } 1222 }
1221 1223
1222 if (useValMap == true) 1224 if (useValMap == true)
1223 (*e) << valmap; 1225 (*e) << valmap;
1224 1226
1225#endif 1227#endif
1226 1228
1227} 1229}
1228 1230
1229 1231
1230 1232
1231/************************************************************************** 1233/**************************************************************************
1232 * 1234 *
1233 **************************************************************************/ 1235 **************************************************************************/
1234 1236
1235void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) 1237void ExternalAppHandler::appMessage( const Q3CString& cmsg, const QByteArray& data )
1236{ 1238{
1237 qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this); 1239 qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this);
1238 if ( cmsg == "nextView()" ) { 1240 if ( cmsg == "nextView()" ) {
1239 qDebug("nextView()"); 1241 qDebug("nextView()");
1240 QTimer::singleShot( 0, this, SIGNAL ( nextView() )); 1242 QTimer::singleShot( 0, this, SIGNAL ( nextView() ));
1241 return; 1243 return;
1242 } 1244 }
1243 if ( cmsg == "callContactdialog()" ) { 1245 if ( cmsg == "callContactdialog()" ) {
1244 qDebug("callContactdialog()"); 1246 qDebug("callContactdialog()");
1245 QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() )); 1247 QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() ));
1246 return; 1248 return;
1247 } 1249 }
1248 if ( cmsg == "doRingSync" ) { 1250 if ( cmsg == "doRingSync" ) {
1249 qDebug("doRingSync"); 1251 qDebug("doRingSync");
1250 QTimer::singleShot( 0, this, SIGNAL ( doRingSync() )); 1252 QTimer::singleShot( 0, this, SIGNAL ( doRingSync() ));
1251 return; 1253 return;
1252 } 1254 }
1253 1255
1254 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1256 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1255 if (!res) 1257 if (!res)
1256 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); 1258 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data );
1257 1259
1258 if (!res) 1260 if (!res)
1259 res = mDisplayDetails->appMessage( cmsg, data ); 1261 res = mDisplayDetails->appMessage( cmsg, data );
1260 1262
1261// if (!res) 1263// if (!res)
1262// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1264// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1263} 1265}
1264 1266
1265 1267
1266 1268
1267bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1269bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid)