summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/addresseeview.cpp6
-rw-r--r--libkdepim/externalapphandler.cpp81
-rw-r--r--libkdepim/externalapphandler.h8
3 files changed, 93 insertions, 2 deletions
diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp
index 5c69010..b4717d7 100644
--- a/libkdepim/addresseeview.cpp
+++ b/libkdepim/addresseeview.cpp
@@ -1,257 +1,263 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <kabc/address.h> 22#include <kabc/address.h>
23#include <kabc/addressee.h> 23#include <kabc/addressee.h>
24#include <kabc/phonenumber.h> 24#include <kabc/phonenumber.h>
25#include <kglobal.h> 25#include <kglobal.h>
26//US#include <kglobalsettings.h> 26//US#include <kglobalsettings.h>
27#include <kiconloader.h> 27#include <kiconloader.h>
28#include <klocale.h> 28#include <klocale.h>
29//US #include <kstringhandler.h> 29//US #include <kstringhandler.h>
30#include <qscrollview.h> 30#include <qscrollview.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qapplication.h> 33#include <qapplication.h>
34 34
35 35
36#include "externalapphandler.h" 36#include "externalapphandler.h"
37#include "addresseeview.h" 37#include "addresseeview.h"
38 38
39 39
40//US #ifndef DESKTOP_VERSION 40//US #ifndef DESKTOP_VERSION
41//US #include <qtopia/qcopenvelope_qws.h> 41//US #include <qtopia/qcopenvelope_qws.h>
42//US #include <qpe/qpeapplication.h> 42//US #include <qpe/qpeapplication.h>
43//US #endif 43//US #endif
44 44
45//US static int kphoneInstalled = 0; 45//US static int kphoneInstalled = 0;
46 46
47using namespace KPIM; 47using namespace KPIM;
48 48
49AddresseeView::AddresseeView( QWidget *parent, const char *name ) 49AddresseeView::AddresseeView( QWidget *parent, const char *name )
50//US : KTextBrowser( parent, name ) 50//US : KTextBrowser( parent, name )
51 : QTextBrowser( parent, name ) 51 : QTextBrowser( parent, name )
52 52
53 53
54{ 54{
55//US setWrapPolicy( QTextEdit::AtWordBoundary ); 55//US setWrapPolicy( QTextEdit::AtWordBoundary );
56 setLinkUnderline( false ); 56 setLinkUnderline( false );
57 // setVScrollBarMode( QScrollView::AlwaysOff ); 57 // setVScrollBarMode( QScrollView::AlwaysOff );
58 //setHScrollBarMode( QScrollView::AlwaysOff ); 58 //setHScrollBarMode( QScrollView::AlwaysOff );
59 59
60//US QStyleSheet *sheet = styleSheet(); 60//US QStyleSheet *sheet = styleSheet();
61//US QStyleSheetItem *link = sheet->item( "a" ); 61//US QStyleSheetItem *link = sheet->item( "a" );
62//US link->setColor( KGlobalSettings::linkColor() ); 62//US link->setColor( KGlobalSettings::linkColor() );
63 63
64} 64}
65 65
66void AddresseeView::setSource(const QString& n) 66void AddresseeView::setSource(const QString& n)
67{ 67{
68 //qDebug("********AddresseeView::setSource %s", n.latin1()); 68 //qDebug("********AddresseeView::setSource %s", n.latin1());
69 69
70 if ( n.left( 6 ) == "mailto" ) 70 if ( n.left( 6 ) == "mailto" )
71 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); 71 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
72 else if ( n.left( 7 ) == "phoneto" ) 72 else if ( n.left( 7 ) == "phoneto" )
73 ExternalAppHandler::instance()->callByPhone( n.mid(8) ); 73 ExternalAppHandler::instance()->callByPhone( n.mid(8) );
74 else if ( n.left( 5 ) == "faxto" ) 74 else if ( n.left( 5 ) == "faxto" )
75 ExternalAppHandler::instance()->callByFax( n.mid(6) ); 75 ExternalAppHandler::instance()->callByFax( n.mid(6) );
76 else if ( n.left( 5 ) == "smsto" ) 76 else if ( n.left( 5 ) == "smsto" )
77 ExternalAppHandler::instance()->callBySMS( n.mid(6) ); 77 ExternalAppHandler::instance()->callBySMS( n.mid(6) );
78 else if ( n.left( 7 ) == "pagerto" ) 78 else if ( n.left( 7 ) == "pagerto" )
79 ExternalAppHandler::instance()->callByPager( n.mid(8) ); 79 ExternalAppHandler::instance()->callByPager( n.mid(8) );
80 else if ( n.left( 5 ) == "sipto" )
81 ExternalAppHandler::instance()->callBySIP( n.mid(6) );
80 82
81} 83}
82void AddresseeView::setAddressee( const KABC::Addressee& addr ) 84void AddresseeView::setAddressee( const KABC::Addressee& addr )
83{ 85{
84 ExternalAppHandler* eah = ExternalAppHandler::instance(); 86 ExternalAppHandler* eah = ExternalAppHandler::instance();
85 bool kemailAvail = eah->isEmailAppAvailable(); 87 bool kemailAvail = eah->isEmailAppAvailable();
86 bool kphoneAvail = eah->isPhoneAppAvailable(); 88 bool kphoneAvail = eah->isPhoneAppAvailable();
87 bool kfaxAvail = eah->isFaxAppAvailable(); 89 bool kfaxAvail = eah->isFaxAppAvailable();
88 bool ksmsAvail = eah->isSMSAppAvailable(); 90 bool ksmsAvail = eah->isSMSAppAvailable();
89 bool kpagerAvail = eah->isPagerAppAvailable(); 91 bool kpagerAvail = eah->isPagerAppAvailable();
92 bool ksipAvail = eah->isSIPAppAvailable();
90 93
91 94
92 mAddressee = addr; 95 mAddressee = addr;
93 // clear view 96 // clear view
94 setText( QString::null ); 97 setText( QString::null );
95 98
96 if ( mAddressee.isEmpty() ) 99 if ( mAddressee.isEmpty() )
97 return; 100 return;
98 101
99 QString name = ( mAddressee.assembledName().isEmpty() ? 102 QString name = ( mAddressee.assembledName().isEmpty() ?
100 mAddressee.formattedName() : mAddressee.assembledName() ); 103 mAddressee.formattedName() : mAddressee.assembledName() );
101 104
102 QString dynamicPart; 105 QString dynamicPart;
103 106
104 QStringList emails = mAddressee.emails(); 107 QStringList emails = mAddressee.emails();
105 QStringList::ConstIterator emailIt; 108 QStringList::ConstIterator emailIt;
106 QString type = i18n( "Email" ); 109 QString type = i18n( "Email" );
107 emailIt = emails.begin(); 110 emailIt = emails.begin();
108 if ( emailIt != emails.end() ) { 111 if ( emailIt != emails.end() ) {
109 if ( kemailAvail ) { 112 if ( kemailAvail ) {
110 dynamicPart += QString( 113 dynamicPart += QString(
111 "<tr><td align=\"right\"><b>%1</b></td>" 114 "<tr><td align=\"right\"><b>%1</b></td>"
112 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 115 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
113 .arg( type ) 116 .arg( type )
114 .arg( name ) 117 .arg( name )
115 .arg( *emailIt ) 118 .arg( *emailIt )
116 .arg( *emailIt ); 119 .arg( *emailIt );
117 ++emailIt; 120 ++emailIt;
118 } else { 121 } else {
119 dynamicPart += QString( 122 dynamicPart += QString(
120 "<tr><td align=\"right\"><b>%1</b></td>" 123 "<tr><td align=\"right\"><b>%1</b></td>"
121 "<td align=\"left\">%2</td></tr>" ) 124 "<td align=\"left\">%2</td></tr>" )
122 .arg( type ) 125 .arg( type )
123 .arg( *emailIt ); 126 .arg( *emailIt );
124 ++emailIt; 127 ++emailIt;
125 } 128 }
126 } 129 }
127 if ( mAddressee.birthday().date().isValid() ) { 130 if ( mAddressee.birthday().date().isValid() ) {
128 dynamicPart += QString( 131 dynamicPart += QString(
129 "<tr><td align=\"right\"><b>%1</b></td>" 132 "<tr><td align=\"right\"><b>%1</b></td>"
130 "<td align=\"left\">%2</td></tr>" ) 133 "<td align=\"left\">%2</td></tr>" )
131 .arg( i18n ("Birthday") ) 134 .arg( i18n ("Birthday") )
132 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); 135 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
133 } 136 }
134 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); 137 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
135 KABC::PhoneNumber::List::ConstIterator phoneIt; 138 KABC::PhoneNumber::List::ConstIterator phoneIt;
136 QString extension; 139 QString extension;
137 int phonetype; 140 int phonetype;
138 QString sms; 141 QString sms;
139 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 142 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
140 phonetype = (*phoneIt).type(); 143 phonetype = (*phoneIt).type();
141 if (ksmsAvail && 144 if (ksmsAvail &&
142 ( 145 (
143 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || 146 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
144 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) 147 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
145 ) 148 )
146 ) 149 )
147 { 150 {
148 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) 151 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
149 .arg( (*phoneIt).number() ); 152 .arg( (*phoneIt).number() );
150 153
151 } 154 }
152 else 155 else
153 sms = ""; 156 sms = "";
154 157
155 extension = QString::null; 158 extension = QString::null;
156 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { 159 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
157 if (kfaxAvail) extension = "faxto:"; 160 if (kfaxAvail) extension = "faxto:";
158 } 161 }
159 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { 162 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
160 if (kpagerAvail) extension = "pagerto:"; 163 if (kpagerAvail) extension = "pagerto:";
161 } 164 }
165 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
166 if (ksipAvail) extension = "sipto:";
167 }
162 else if (kphoneAvail) { 168 else if (kphoneAvail) {
163 extension = "phoneto:"; 169 extension = "phoneto:";
164 } 170 }
165 else 171 else
166 extension = QString::null; 172 extension = QString::null;
167 173
168 if ( !extension.isEmpty() ) { 174 if ( !extension.isEmpty() ) {
169 dynamicPart += QString( 175 dynamicPart += QString(
170 "<tr><td align=\"right\"><b>%1</b></td>" 176 "<tr><td align=\"right\"><b>%1</b></td>"
171 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) 177 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
172 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 178 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
173 .arg( extension ) 179 .arg( extension )
174 .arg( (*phoneIt).number() ) 180 .arg( (*phoneIt).number() )
175 .arg( (*phoneIt).number() ) 181 .arg( (*phoneIt).number() )
176 .arg( sms ); 182 .arg( sms );
177 183
178 } else { 184 } else {
179 dynamicPart += QString( 185 dynamicPart += QString(
180 "<tr><td align=\"right\"><b>%1</b></td>" 186 "<tr><td align=\"right\"><b>%1</b></td>"
181 "<td align=\"left\">%2 %3</td></tr>" ) 187 "<td align=\"left\">%2 %3</td></tr>" )
182 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 188 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
183 .arg( (*phoneIt).number() ) 189 .arg( (*phoneIt).number() )
184 .arg( sms ); 190 .arg( sms );
185 } 191 }
186 } 192 }
187 193
188 194
189 for ( ; emailIt != emails.end(); ++emailIt ) { 195 for ( ; emailIt != emails.end(); ++emailIt ) {
190 if ( kemailAvail ) { 196 if ( kemailAvail ) {
191 dynamicPart += QString( 197 dynamicPart += QString(
192 "<tr><td align=\"right\"><b>%1</b></td>" 198 "<tr><td align=\"right\"><b>%1</b></td>"
193 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 199 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
194 .arg( type ) 200 .arg( type )
195 .arg( name ) 201 .arg( name )
196 .arg( *emailIt ) 202 .arg( *emailIt )
197 .arg( *emailIt ); 203 .arg( *emailIt );
198 } else { 204 } else {
199 dynamicPart += QString( 205 dynamicPart += QString(
200 "<tr><td align=\"right\"><b>%1</b></td>" 206 "<tr><td align=\"right\"><b>%1</b></td>"
201 "<td align=\"left\">%2</td></tr>" ) 207 "<td align=\"left\">%2</td></tr>" )
202 .arg( type ) 208 .arg( type )
203 .arg( *emailIt ); 209 .arg( *emailIt );
204 } 210 }
205 } 211 }
206 212
207 if ( !mAddressee.url().url().isEmpty() ) { 213 if ( !mAddressee.url().url().isEmpty() ) {
208 dynamicPart += QString( 214 dynamicPart += QString(
209 "<tr><td align=\"right\"><b>%1</b></td>" 215 "<tr><td align=\"right\"><b>%1</b></td>"
210 "<td align=\"left\">%2</td></tr>" ) 216 "<td align=\"left\">%2</td></tr>" )
211 .arg( i18n( "Homepage" ) ) 217 .arg( i18n( "Homepage" ) )
212//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); 218//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) );
213 .arg( mAddressee.url().url() ); 219 .arg( mAddressee.url().url() );
214 //qDebug("AddresseeView::setAddressee has to be verified."); 220 //qDebug("AddresseeView::setAddressee has to be verified.");
215 } 221 }
216 222
217 KABC::Address::List addresses = mAddressee.addresses(); 223 KABC::Address::List addresses = mAddressee.addresses();
218 KABC::Address::List::ConstIterator addrIt; 224 KABC::Address::List::ConstIterator addrIt;
219 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 225 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
220 if ( true /*(*addrIt).label().isEmpty()*/ ) { 226 if ( true /*(*addrIt).label().isEmpty()*/ ) {
221 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 227 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
222//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 228//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
223 //qDebug("adresss %s ",formattedAddress.latin1() ); 229 //qDebug("adresss %s ",formattedAddress.latin1() );
224 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 230 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
225 //qDebug("AddresseeView::setAddressee has to be verified."); 231 //qDebug("AddresseeView::setAddressee has to be verified.");
226 232
227 dynamicPart += QString( 233 dynamicPart += QString(
228 "<tr><td align=\"right\"><b>%1</b></td>" 234 "<tr><td align=\"right\"><b>%1</b></td>"
229 "<td align=\"left\">%2</td></tr>" ) 235 "<td align=\"left\">%2</td></tr>" )
230 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 236 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
231 .arg( formattedAddress ); 237 .arg( formattedAddress );
232 } else { 238 } else {
233 239
234 dynamicPart += QString( 240 dynamicPart += QString(
235 "<tr><td align=\"right\"><b>%1</b></td>" 241 "<tr><td align=\"right\"><b>%1</b></td>"
236 "<td align=\"left\">%2</td></tr>" ) 242 "<td align=\"left\">%2</td></tr>" )
237 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 243 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
238//US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); 244//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
239 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); 245 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
240 246
241 } 247 }
242 } 248 }
243 249
244 QString notes; 250 QString notes;
245 if ( !mAddressee.note().isEmpty() ) { 251 if ( !mAddressee.note().isEmpty() ) {
246 notes = QString( 252 notes = QString(
247 "<tr>" 253 "<tr>"
248 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label 254 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label
249 "<td align=\"left\">%2</td>" // note 255 "<td align=\"left\">%2</td>" // note
250 "</tr>" ).arg( i18n( "Notes" ) ) 256 "</tr>" ).arg( i18n( "Notes" ) )
251//US .arg( mAddressee.note().replace( '\n', "<br>" ) ); 257//US .arg( mAddressee.note().replace( '\n', "<br>" ) );
252 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); 258 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
253 //qDebug("AddresseeView::setAddressee has to be verified."); 259 //qDebug("AddresseeView::setAddressee has to be verified.");
254 } 260 }
255 261
256 QString aRole = ""; 262 QString aRole = "";
257 QString aOrga = ""; 263 QString aOrga = "";
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 5ba32b6..fa56ee9 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -262,379 +262,402 @@ QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QStri
262/*********************************************************************************/ 262/*********************************************************************************/
263bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 263bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
264{ 264{
265#ifndef DESKTOP_VERSION 265#ifndef DESKTOP_VERSION
266 //targetMessage passes two parameters: uid, map 266 //targetMessage passes two parameters: uid, map
267 QString targetMessage = _targetMessage + _targetMessageParameters; 267 QString targetMessage = _targetMessage + _targetMessageParameters;
268 268
269 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 269 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
270 qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1()); 270 qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1());
271 271
272 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 272 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
273 //US we need no names in the To field. The emailadresses are enough 273 //US we need no names in the To field. The emailadresses are enough
274 274
275 e << uid << list1 << list2 << list3; 275 e << uid << list1 << list2 << list3;
276 276
277 qApp->processEvents(); 277 qApp->processEvents();
278 278
279 return true; 279 return true;
280 280
281#else 281#else
282 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 282 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
283 return false; 283 return false;
284#endif 284#endif
285 285
286} 286}
287 287
288 288
289/*********************************************************************************/ 289/*********************************************************************************/
290bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 290bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
291{ 291{
292 bool res = QCopTransferItem::appMessage( cmsg, data ); 292 bool res = QCopTransferItem::appMessage( cmsg, data );
293 293
294 if (res == false) 294 if (res == false)
295 { 295 {
296 QDataStream stream( data, IO_ReadOnly ); 296 QDataStream stream( data, IO_ReadOnly );
297 297
298// qDebug("QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 298// qDebug("QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
299 299
300 //we are in the source and get an answer from the target 300 //we are in the source and get an answer from the target
301 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 301 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
302 { 302 {
303 QStringList list1; 303 QStringList list1;
304 QStringList list2; 304 QStringList list2;
305 QStringList list3; 305 QStringList list3;
306 QString uid; 306 QString uid;
307 307
308 stream >> uid >> list1 >> list2 >> list3; 308 stream >> uid >> list1 >> list2 >> list3;
309 emit receivedMessageFromTarget(uid, list1, list2, list3); 309 emit receivedMessageFromTarget(uid, list1, list2, list3);
310 310
311 311
312 return true; 312 return true;
313 } 313 }
314 } 314 }
315 315
316 return false; 316 return false;
317} 317}
318 318
319 319
320 320
321/********************************************************************************* 321/*********************************************************************************
322 * 322 *
323 ********************************************************************************/ 323 ********************************************************************************/
324 324
325 325
326ExternalAppHandler *ExternalAppHandler::sInstance = 0; 326ExternalAppHandler *ExternalAppHandler::sInstance = 0;
327static KStaticDeleter<ExternalAppHandler> staticDeleter; 327static KStaticDeleter<ExternalAppHandler> staticDeleter;
328 328
329ExternalAppHandler::ExternalAppHandler() 329ExternalAppHandler::ExternalAppHandler()
330{ 330{
331 mDefaultItems.setAutoDelete(true); 331 mDefaultItems.setAutoDelete(true);
332 332
333 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); 333 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
334 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); 334 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&)));
335 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 335 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
336 336
337//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); 337//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
338//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); 338//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
339//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 339//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
340 340
341 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); 341 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
342 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 342 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
343} 343}
344 344
345ExternalAppHandler::~ExternalAppHandler() 345ExternalAppHandler::~ExternalAppHandler()
346{ 346{
347} 347}
348 348
349void ExternalAppHandler::loadConfig() 349void ExternalAppHandler::loadConfig()
350{ 350{
351 351
352 mDefaultItems.clear(); 352 mDefaultItems.clear();
353 mEmailAppAvailable = UNDEFINED; 353 mEmailAppAvailable = UNDEFINED;
354 mPhoneAppAvailable = UNDEFINED; 354 mPhoneAppAvailable = UNDEFINED;
355 mFaxAppAvailable = UNDEFINED; 355 mFaxAppAvailable = UNDEFINED;
356 mSMSAppAvailable = UNDEFINED; 356 mSMSAppAvailable = UNDEFINED;
357 mPagerAppAvailable = UNDEFINED; 357 mPagerAppAvailable = UNDEFINED;
358 358 mSIPAppAvailable = UNDEFINED;
359 359
360 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 360 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
361 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 361 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
362 362
363 if (opiepath.isEmpty()) 363 if (opiepath.isEmpty())
364 opiepath = qtopiapath; 364 opiepath = qtopiapath;
365 365
366 //mailclients 366 //mailclients
367 QString mailmsg1 = "writeMail(QString,QString)"; 367 QString mailmsg1 = "writeMail(QString,QString)";
368 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 368 QString mailmsg2 = "writeMail(QMap(QString,QString))";
369 369
370 QString undefined = ""; 370 QString undefined = "";
371 371
372 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 372 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
373 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 373 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
374 374
375 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 375 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
376 ( QFile::exists( opiepath + "/bin/ompi" ))) 376 ( QFile::exists( opiepath + "/bin/ompi" )))
377 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 377 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
378 378
379 if ( QFile::exists( qtopiapath + "/bin/qtmail" )) 379 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
380 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 380 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
381 381
382 if ( QFile::exists( opiepath + "/bin/opiemail" )) 382 if ( QFile::exists( opiepath + "/bin/opiemail" ))
383 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 383 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
384 384
385 385
386 386
387 //phoneclients 387 //phoneclients
388 388
389 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 389 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
390 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 390 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
391 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 391 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
392 ( QFile::exists( opiepath + "/bin/kppi" ))) 392 ( QFile::exists( opiepath + "/bin/kppi" )))
393 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 393 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
394 394
395 //faxclients 395 //faxclients
396 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 396 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
397 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 397 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
398 398
399 //smsclients 399 //smsclients
400 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 400 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
401 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 401 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
402 402
403 //pagerclients 403 //pagerclients
404 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 404 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
405 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 405 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
406 406
407 //sipclients
408 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No sip client installed", undefined, undefined, undefined, undefined, undefined);
409 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other sip client", undefined, undefined, undefined, undefined, undefined);
410
407} 411}
408 412
409ExternalAppHandler *ExternalAppHandler::instance() 413ExternalAppHandler *ExternalAppHandler::instance()
410{ 414{
411 if ( !sInstance ) { 415 if ( !sInstance ) {
412 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 416 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
413 sInstance->loadConfig(); 417 sInstance->loadConfig();
414 } 418 }
415 419
416 return sInstance; 420 return sInstance;
417} 421}
418 422
419void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 423void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
420{ 424{
421 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 425 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
422 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); 426 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
423 mDefaultItems.append(dai); 427 mDefaultItems.append(dai);
424} 428}
425 429
426 430
427QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 431QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
428{ 432{
429 QList<DefaultAppItem> list; 433 QList<DefaultAppItem> list;
430 434
431 DefaultAppItem* dai; 435 DefaultAppItem* dai;
432 436
433 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 437 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
434 { 438 {
435 if (dai->_type == type) 439 if (dai->_type == type)
436 list.append(dai); 440 list.append(dai);
437 } 441 }
438 442
439 return list; 443 return list;
440} 444}
441 445
442DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 446DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
443{ 447{
444 DefaultAppItem* dai; 448 DefaultAppItem* dai;
445 449
446 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 450 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
447 { 451 {
448 if (dai->_type == type && dai->_id == clientid) 452 if (dai->_type == type && dai->_id == clientid)
449 return dai; 453 return dai;
450 } 454 }
451 455
452 return 0; 456 return 0;
453} 457}
454 458
455bool ExternalAppHandler::isEmailAppAvailable() 459bool ExternalAppHandler::isEmailAppAvailable()
456{ 460{
457#ifndef DESKTOP_VERSION 461#ifndef DESKTOP_VERSION
458 if (mEmailAppAvailable == UNDEFINED) 462 if (mEmailAppAvailable == UNDEFINED)
459 { 463 {
460 int client = KPimGlobalPrefs::instance()->mEmailClient; 464 int client = KPimGlobalPrefs::instance()->mEmailClient;
461 if (client == KPimGlobalPrefs::NONE_EMC) 465 if (client == KPimGlobalPrefs::NONE_EMC)
462 mEmailAppAvailable = UNAVAILABLE; 466 mEmailAppAvailable = UNAVAILABLE;
463 else 467 else
464 mEmailAppAvailable = AVAILABLE; 468 mEmailAppAvailable = AVAILABLE;
465 } 469 }
466 return (mEmailAppAvailable == AVAILABLE); 470 return (mEmailAppAvailable == AVAILABLE);
467 471
468#else //DESKTOP_VERSION 472#else //DESKTOP_VERSION
469 return false; 473 return false;
470#endif //DESKTOP_VERSION 474#endif //DESKTOP_VERSION
471} 475}
472 476
473bool ExternalAppHandler::isSMSAppAvailable() 477bool ExternalAppHandler::isSMSAppAvailable()
474{ 478{
475#ifndef DESKTOP_VERSION 479#ifndef DESKTOP_VERSION
476 if (mSMSAppAvailable == UNDEFINED) 480 if (mSMSAppAvailable == UNDEFINED)
477 { 481 {
478 int client = KPimGlobalPrefs::instance()->mSMSClient; 482 int client = KPimGlobalPrefs::instance()->mSMSClient;
479 if (client == KPimGlobalPrefs::NONE_SMC) 483 if (client == KPimGlobalPrefs::NONE_SMC)
480 mSMSAppAvailable = UNAVAILABLE; 484 mSMSAppAvailable = UNAVAILABLE;
481 else 485 else
482 mSMSAppAvailable = AVAILABLE; 486 mSMSAppAvailable = AVAILABLE;
483 } 487 }
484 488
485 return (mSMSAppAvailable == AVAILABLE); 489 return (mSMSAppAvailable == AVAILABLE);
486#else //DESKTOP_VERSION 490#else //DESKTOP_VERSION
487 return false; 491 return false;
488#endif //DESKTOP_VERSION 492#endif //DESKTOP_VERSION
489} 493}
490 494
491bool ExternalAppHandler::isPhoneAppAvailable() 495bool ExternalAppHandler::isPhoneAppAvailable()
492{ 496{
493#ifndef DESKTOP_VERSION 497#ifndef DESKTOP_VERSION
494 if (mPhoneAppAvailable == UNDEFINED) 498 if (mPhoneAppAvailable == UNDEFINED)
495 { 499 {
496 int client = KPimGlobalPrefs::instance()->mPhoneClient; 500 int client = KPimGlobalPrefs::instance()->mPhoneClient;
497 if (client == KPimGlobalPrefs::NONE_PHC) 501 if (client == KPimGlobalPrefs::NONE_PHC)
498 mPhoneAppAvailable = UNAVAILABLE; 502 mPhoneAppAvailable = UNAVAILABLE;
499 else 503 else
500 mPhoneAppAvailable = AVAILABLE; 504 mPhoneAppAvailable = AVAILABLE;
501 } 505 }
502 506
503 return (mPhoneAppAvailable == AVAILABLE); 507 return (mPhoneAppAvailable == AVAILABLE);
504#else //DESKTOP_VERSION 508#else //DESKTOP_VERSION
505 return false; 509 return false;
506#endif //DESKTOP_VERSION 510#endif //DESKTOP_VERSION
507} 511}
508 512
509bool ExternalAppHandler::isFaxAppAvailable() 513bool ExternalAppHandler::isFaxAppAvailable()
510{ 514{
511#ifndef DESKTOP_VERSION 515#ifndef DESKTOP_VERSION
512 if (mFaxAppAvailable == UNDEFINED) 516 if (mFaxAppAvailable == UNDEFINED)
513 { 517 {
514 int client = KPimGlobalPrefs::instance()->mFaxClient; 518 int client = KPimGlobalPrefs::instance()->mFaxClient;
515 if (client == KPimGlobalPrefs::NONE_FAC) 519 if (client == KPimGlobalPrefs::NONE_FAC)
516 mFaxAppAvailable = UNAVAILABLE; 520 mFaxAppAvailable = UNAVAILABLE;
517 else 521 else
518 mFaxAppAvailable = AVAILABLE; 522 mFaxAppAvailable = AVAILABLE;
519 } 523 }
520 524
521 return (mFaxAppAvailable == AVAILABLE); 525 return (mFaxAppAvailable == AVAILABLE);
522#else //DESKTOP_VERSION 526#else //DESKTOP_VERSION
523 return false; 527 return false;
524#endif //DESKTOP_VERSION 528#endif //DESKTOP_VERSION
525} 529}
526 530
527bool ExternalAppHandler::isPagerAppAvailable() 531bool ExternalAppHandler::isPagerAppAvailable()
528{ 532{
529#ifndef DESKTOP_VERSION 533#ifndef DESKTOP_VERSION
530 if (mPagerAppAvailable == UNDEFINED) 534 if (mPagerAppAvailable == UNDEFINED)
531 { 535 {
532 int client = KPimGlobalPrefs::instance()->mPagerClient; 536 int client = KPimGlobalPrefs::instance()->mPagerClient;
533 if (client == KPimGlobalPrefs::NONE_PAC) 537 if (client == KPimGlobalPrefs::NONE_PAC)
534 mPagerAppAvailable = UNAVAILABLE; 538 mPagerAppAvailable = UNAVAILABLE;
535 else 539 else
536 mPagerAppAvailable = AVAILABLE; 540 mPagerAppAvailable = AVAILABLE;
537 } 541 }
538 542
539 return (mPagerAppAvailable == AVAILABLE); 543 return (mPagerAppAvailable == AVAILABLE);
540#else //DESKTOP_VERSION 544#else //DESKTOP_VERSION
541 return false; 545 return false;
542#endif //DESKTOP_VERSION 546#endif //DESKTOP_VERSION
543} 547}
544 548
549
550bool ExternalAppHandler::isSIPAppAvailable()
551{
552#ifndef DESKTOP_VERSION
553 if (mSIPAppAvailable == UNDEFINED)
554 {
555 int client = KPimGlobalPrefs::instance()->mSipClient;
556 if (client == KPimGlobalPrefs::NONE_SIC)
557 mSIPAppAvailable = UNAVAILABLE;
558 else
559 mSIPAppAvailable = AVAILABLE;
560 }
561
562 return (mSIPAppAvailable == AVAILABLE);
563#else //DESKTOP_VERSION
564 return false;
565#endif //DESKTOP_VERSION
566}
567
545/************************************************************************** 568/**************************************************************************
546 * 569 *
547 **************************************************************************/ 570 **************************************************************************/
548 571
549 572
550//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 573//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
551bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 574bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
552{ 575{
553 576
554#ifndef DESKTOP_VERSION 577#ifndef DESKTOP_VERSION
555 QString channel; 578 QString channel;
556 QString message2; 579 QString message2;
557 QString parameters2; 580 QString parameters2;
558 581
559 582
560 int client = KPimGlobalPrefs::instance()->mEmailClient; 583 int client = KPimGlobalPrefs::instance()->mEmailClient;
561 if (client == KPimGlobalPrefs::OTHER_EMC) 584 if (client == KPimGlobalPrefs::OTHER_EMC)
562 { 585 {
563 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 586 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
564 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 587 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
565 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 588 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
566 } 589 }
567 else 590 else
568 { 591 {
569 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 592 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
570 if (!dai) 593 if (!dai)
571 { 594 {
572 qDebug("could not find configured email application."); 595 qDebug("could not find configured email application.");
573 return false; 596 return false;
574 } 597 }
575 channel = dai->_channel; 598 channel = dai->_channel;
576 message2 = dai->_message2; 599 message2 = dai->_message2;
577 parameters2 = dai->_parameters2; 600 parameters2 = dai->_parameters2;
578 } 601 }
579 602
580 //first check if one of the mailers need the emails right in the message. 603 //first check if one of the mailers need the emails right in the message.
581 message2 = translateMessage(message2, emails, urls); 604 message2 = translateMessage(message2, emails, urls);
582 605
583 606
584 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 607 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
585 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 608 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
586 609
587 610
588 QCopEnvelope e(channel.latin1(), message2.latin1()); 611 QCopEnvelope e(channel.latin1(), message2.latin1());
589 //US we need no names in the To field. The emailadresses are enough 612 //US we need no names in the To field. The emailadresses are enough
590 613
591 passParameters(&e, parameters2, emails, urls); 614 passParameters(&e, parameters2, emails, urls);
592 615
593 616
594 617
595#else 618#else
596 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 619 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
597#endif 620#endif
598 621
599 return true; 622 return true;
600} 623}
601 624
602/************************************************************************** 625/**************************************************************************
603 * 626 *
604 **************************************************************************/ 627 **************************************************************************/
605 628
606 629
607//calls the emailapplication and creates a mail with parameter emails as recipients 630//calls the emailapplication and creates a mail with parameter emails as recipients
608bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 631bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
609{ 632{
610#ifndef DESKTOP_VERSION 633#ifndef DESKTOP_VERSION
611 QString channel; 634 QString channel;
612 QString message; 635 QString message;
613 QString parameters; 636 QString parameters;
614 637
615 638
616 int client = KPimGlobalPrefs::instance()->mEmailClient; 639 int client = KPimGlobalPrefs::instance()->mEmailClient;
617 if (client == KPimGlobalPrefs::OTHER_EMC) 640 if (client == KPimGlobalPrefs::OTHER_EMC)
618 { 641 {
619 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 642 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
620 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 643 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
621 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 644 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
622 } 645 }
623 else 646 else
624 { 647 {
625 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 648 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
626 if (!dai) 649 if (!dai)
627 { 650 {
628 qDebug("could not find configured email application."); 651 qDebug("could not find configured email application.");
629 return false; 652 return false;
630 } 653 }
631 channel = dai->_channel; 654 channel = dai->_channel;
632 message = dai->_message; 655 message = dai->_message;
633 parameters = dai->_parameters; 656 parameters = dai->_parameters;
634 } 657 }
635 658
636 659
637 //first check if one of the mailers need the emails right in the message. 660 //first check if one of the mailers need the emails right in the message.
638 message = translateMessage(message, name, emailadress); 661 message = translateMessage(message, name, emailadress);
639 662
640 663
@@ -808,192 +831,248 @@ bool ExternalAppHandler::callByPager( const QString& pagernumber )
808 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 831 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
809 } 832 }
810 else 833 else
811 { 834 {
812 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 835 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
813 if (!dai) 836 if (!dai)
814 { 837 {
815 qDebug("could not find configured pager application."); 838 qDebug("could not find configured pager application.");
816 return false; 839 return false;
817 } 840 }
818 channel = dai->_channel; 841 channel = dai->_channel;
819 message = dai->_message; 842 message = dai->_message;
820 parameters = dai->_parameters; 843 parameters = dai->_parameters;
821 } 844 }
822 845
823 846
824 //first check if one of the mailers need the emails right in the message. 847 //first check if one of the mailers need the emails right in the message.
825 message = translateMessage(message, pagernumber, ""); 848 message = translateMessage(message, pagernumber, "");
826 849
827 850
828 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 851 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
829 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 852 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
830 853
831 QCopEnvelope e(channel.latin1(), message.latin1()); 854 QCopEnvelope e(channel.latin1(), message.latin1());
832 //US we need no names in the To field. The emailadresses are enough 855 //US we need no names in the To field. The emailadresses are enough
833 856
834 passParameters(&e, parameters, pagernumber, ""); 857 passParameters(&e, parameters, pagernumber, "");
835 858
836 859
837#else 860#else
838 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 861 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
839#endif 862#endif
840 863
841 864
842 return true; 865 return true;
843} 866}
844 867
845/************************************************************************** 868/**************************************************************************
846 * 869 *
847 **************************************************************************/ 870 **************************************************************************/
848 871
849//calls the faxapplication with the number 872//calls the faxapplication with the number
850bool ExternalAppHandler::callByFax( const QString& faxnumber ) 873bool ExternalAppHandler::callByFax( const QString& faxnumber )
851{ 874{
852#ifndef DESKTOP_VERSION 875#ifndef DESKTOP_VERSION
853 QString channel; 876 QString channel;
854 QString message; 877 QString message;
855 QString parameters; 878 QString parameters;
856 879
857 880
858 int client = KPimGlobalPrefs::instance()->mFaxClient; 881 int client = KPimGlobalPrefs::instance()->mFaxClient;
859 if (client == KPimGlobalPrefs::OTHER_FAC) 882 if (client == KPimGlobalPrefs::OTHER_FAC)
860 { 883 {
861 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 884 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
862 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 885 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
863 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 886 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
864 } 887 }
865 else 888 else
866 { 889 {
867 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 890 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
868 if (!dai) 891 if (!dai)
869 { 892 {
870 qDebug("could not find configured fax application."); 893 qDebug("could not find configured fax application.");
871 return false; 894 return false;
872 } 895 }
873 channel = dai->_channel; 896 channel = dai->_channel;
874 message = dai->_message; 897 message = dai->_message;
875 parameters = dai->_parameters; 898 parameters = dai->_parameters;
876 } 899 }
877 900
878 901
879 //first check if one of the mailers need the emails right in the message. 902 //first check if one of the mailers need the emails right in the message.
880 message = translateMessage(message, faxnumber, ""); 903 message = translateMessage(message, faxnumber, "");
881 904
882 905
883 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 906 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
884 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 907 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
885 908
886 QCopEnvelope e(channel.latin1(), message.latin1()); 909 QCopEnvelope e(channel.latin1(), message.latin1());
887 //US we need no names in the To field. The emailadresses are enough 910 //US we need no names in the To field. The emailadresses are enough
888 911
889 passParameters(&e, parameters, faxnumber, ""); 912 passParameters(&e, parameters, faxnumber, "");
890 913
891 914
892#else 915#else
893 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 916 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
894#endif 917#endif
895 918
896 919
897 return true; 920 return true;
898} 921}
899 922
900/************************************************************************** 923/**************************************************************************
901 * 924 *
902 **************************************************************************/ 925 **************************************************************************/
903 926
927//calls the sipapplication with the number
928bool ExternalAppHandler::callBySIP( const QString& sipnumber )
929{
930#ifndef DESKTOP_VERSION
931 QString channel;
932 QString message;
933 QString parameters;
934
935
936 int client = KPimGlobalPrefs::instance()->mSipClient;
937 if (client == KPimGlobalPrefs::OTHER_SIC)
938 {
939 channel = KPimGlobalPrefs::instance()->mSipOtherChannel;
940 message = KPimGlobalPrefs::instance()->mSipOtherMessage;
941 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters;
942 }
943 else
944 {
945 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client);
946 if (!dai)
947 {
948 qDebug("could not find configured sip application.");
949 return false;
950 }
951 channel = dai->_channel;
952 message = dai->_message;
953 parameters = dai->_parameters;
954 }
955
956
957 //first check if one of the sip apps need the emails right in the message.
958 message = translateMessage(message, sipnumber, "");
959
960
961 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
962 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1());
963
964 QCopEnvelope e(channel.latin1(), message.latin1());
965 //US we need no names in the To field. The emailadresses are enough
966
967 passParameters(&e, parameters, sipnumber, "");
968
969
970#else
971 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) );
972#endif
973
974
975 return true;
976}
977
978
979/**************************************************************************
980 *
981 **************************************************************************/
982
904 983
905QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 984QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
906{ 985{
907 message = message.replace( QRegExp("%1"), param1 ); 986 message = message.replace( QRegExp("%1"), param1 );
908 return message.replace( QRegExp("%2"), param2 ); 987 return message.replace( QRegExp("%2"), param2 );
909} 988}
910 989
911/************************************************************************** 990/**************************************************************************
912 * 991 *
913 **************************************************************************/ 992 **************************************************************************/
914 993
915void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const 994void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
916{ 995{
917#ifndef DESKTOP_VERSION 996#ifndef DESKTOP_VERSION
918 QMap<QString, QString> valmap; 997 QMap<QString, QString> valmap;
919 bool useValMap = false; 998 bool useValMap = false;
920 999
921 // first extract all parts of the parameters. 1000 // first extract all parts of the parameters.
922 QStringList paramlist = QStringList::split(";", parameters); 1001 QStringList paramlist = QStringList::split(";", parameters);
923 1002
924 //Now check how many parts we have. 1003 //Now check how many parts we have.
925 //=0 :no params to pass 1004 //=0 :no params to pass
926 //>0 :parameters to pass 1005 //>0 :parameters to pass
927 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 1006 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
928 { 1007 {
929 QString param = (*it); 1008 QString param = (*it);
930 QStringList keyvallist = QStringList::split("=", param); 1009 QStringList keyvallist = QStringList::split("=", param);
931 1010
932 //if we have keyvalue pairs, we assume that we pass a map to the envelope 1011 //if we have keyvalue pairs, we assume that we pass a map to the envelope
933 QStringList::Iterator it2 = keyvallist.begin(); 1012 QStringList::Iterator it2 = keyvallist.begin();
934 QString key = (*it2); 1013 QString key = (*it2);
935 key = key.replace( QRegExp("%1"), param1 ); 1014 key = key.replace( QRegExp("%1"), param1 );
936 key = key.replace( QRegExp("%2"), param2 ); 1015 key = key.replace( QRegExp("%2"), param2 );
937 ++it2; 1016 ++it2;
938 1017
939 if(it2 != keyvallist.end()) 1018 if(it2 != keyvallist.end())
940 { 1019 {
941 QString value = (*it2); 1020 QString value = (*it2);
942 value = value.replace( QRegExp("%1"), param1 ); 1021 value = value.replace( QRegExp("%1"), param1 );
943 value = value.replace( QRegExp("%2"), param2 ); 1022 value = value.replace( QRegExp("%2"), param2 );
944 1023
945 valmap.insert(key, value); 1024 valmap.insert(key, value);
946 useValMap = true; 1025 useValMap = true;
947 } 1026 }
948 else 1027 else
949 { 1028 {
950 // qDebug("pass parameter << %s", key.latin1()); 1029 // qDebug("pass parameter << %s", key.latin1());
951 (*e) << key; 1030 (*e) << key;
952 } 1031 }
953 } 1032 }
954 1033
955 if (useValMap == true) 1034 if (useValMap == true)
956 (*e) << valmap; 1035 (*e) << valmap;
957 1036
958#endif 1037#endif
959 1038
960} 1039}
961 1040
962 1041
963 1042
964/************************************************************************** 1043/**************************************************************************
965 * 1044 *
966 **************************************************************************/ 1045 **************************************************************************/
967 1046
968void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) 1047void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data )
969{ 1048{
970 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1049 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
971 if (!res) 1050 if (!res)
972 res = mDisplayDetails->appMessage( cmsg, data ); 1051 res = mDisplayDetails->appMessage( cmsg, data );
973 1052
974// if (!res) 1053// if (!res)
975// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1054// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
976} 1055}
977 1056
978 1057
979 1058
980bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1059bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
981{ 1060{
982 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1061 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
983 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); 1062 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid);
984} 1063}
985 1064
986bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1065bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
987{ 1066{
988 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1067 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
989 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); 1068 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3);
990} 1069}
991 1070
992bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) 1071bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email)
993{ 1072{
994 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1073 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
995 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); 1074 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email);
996} 1075}
997 1076
998bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1077bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
999{ 1078{
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h
index 1b04b2b..cfe577b 100644
--- a/libkdepim/externalapphandler.h
+++ b/libkdepim/externalapphandler.h
@@ -64,198 +64,204 @@ class QCopTransferItem : public QObject
64 int _usedSourceParameters; 64 int _usedSourceParameters;
65 QString _sourceChannel; 65 QString _sourceChannel;
66 QString _sourceMessage; 66 QString _sourceMessage;
67 QString _sourceMessageParameters; 67 QString _sourceMessageParameters;
68 QString _targetChannel; 68 QString _targetChannel;
69 QString _targetMessage; 69 QString _targetMessage;
70 QString _targetMessageParameters; 70 QString _targetMessageParameters;
71 71
72}; 72};
73 73
74/********************************************************************************* 74/*********************************************************************************
75 * 75 *
76 ********************************************************************************/ 76 ********************************************************************************/
77 77
78class QCopMapTransferItem : public QCopTransferItem 78class QCopMapTransferItem : public QCopTransferItem
79{ 79{
80 Q_OBJECT 80 Q_OBJECT
81 public: 81 public:
82 QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); 82 QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
83 83
84 bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap); 84 bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap);
85 85
86 86
87 virtual bool appMessage( const QCString& msg, const QByteArray& data ); 87 virtual bool appMessage( const QCString& msg, const QByteArray& data );
88 88
89 89
90 signals: 90 signals:
91 void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); 91 void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap);
92 92
93}; 93};
94 94
95/********************************************************************************* 95/*********************************************************************************
96 * 96 *
97 ********************************************************************************/ 97 ********************************************************************************/
98 98
99class QCopListTransferItem : public QCopTransferItem 99class QCopListTransferItem : public QCopTransferItem
100{ 100{
101 Q_OBJECT 101 Q_OBJECT
102 public: 102 public:
103 QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); 103 QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
104 104
105 bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3); 105 bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3);
106 106
107 107
108 virtual bool appMessage( const QCString& msg, const QByteArray& data ); 108 virtual bool appMessage( const QCString& msg, const QByteArray& data );
109 109
110 110
111 signals: 111 signals:
112 void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3); 112 void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3);
113 113
114}; 114};
115 115
116/********************************************************************************* 116/*********************************************************************************
117 * 117 *
118 ********************************************************************************/ 118 ********************************************************************************/
119 119
120 120
121class DefaultAppItem 121class DefaultAppItem
122{ 122{
123 public: 123 public:
124 DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) 124 DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2)
125 : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) 125 : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2)
126 {} 126 {}
127 127
128 DefaultAppItem() 128 DefaultAppItem()
129 { } 129 { }
130 130
131 public: 131 public:
132 int _type; 132 int _type;
133 int _id; 133 int _id;
134 QString _label; 134 QString _label;
135 QString _channel; 135 QString _channel;
136 QString _message; 136 QString _message;
137 QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; 137 QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ;
138 QString _message2; 138 QString _message2;
139 QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; 139 QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ;
140 140
141}; 141};
142 142
143/********************************************************************************* 143/*********************************************************************************
144 * 144 *
145 ********************************************************************************/ 145 ********************************************************************************/
146 146
147class ExternalAppHandler : public QObject 147class ExternalAppHandler : public QObject
148{ 148{
149 Q_OBJECT 149 Q_OBJECT
150 public: 150 public:
151 virtual ~ExternalAppHandler(); 151 virtual ~ExternalAppHandler();
152 152
153 static ExternalAppHandler *instance(); 153 static ExternalAppHandler *instance();
154 154
155 enum Types { 155 enum Types {
156 EMAIL = 0, 156 EMAIL = 0,
157 PHONE = 1, 157 PHONE = 1,
158 SMS = 2, 158 SMS = 2,
159 FAX = 3, 159 FAX = 3,
160 PAGER = 4 160 PAGER = 4,
161 SIP = 5
161 }; 162 };
162 163
163 enum Availability { 164 enum Availability {
164 UNDEFINED = -1, 165 UNDEFINED = -1,
165 UNAVAILABLE = 0, 166 UNAVAILABLE = 0,
166 AVAILABLE = 1 167 AVAILABLE = 1
167 }; 168 };
168 169
169 //calls the emailapplication with a number of attachments that need to be send. 170 //calls the emailapplication with a number of attachments that need to be send.
170 //either parameter can be left empty. 171 //either parameter can be left empty.
171 bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); 172 bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls );
172 173
173 //calls the emailapplication and creates a mail with parameter emailadress as recipients 174 //calls the emailapplication and creates a mail with parameter emailadress as recipients
174 bool mailToOneContact( const QString& name, const QString& emailadress ); 175 bool mailToOneContact( const QString& name, const QString& emailadress );
175 176
176 //calls the emailapplication and creates a mail with parameter as recipients 177 //calls the emailapplication and creates a mail with parameter as recipients
177 // parameters format is 178 // parameters format is
178 // NAME <EMAIL>:SUBJECT 179 // NAME <EMAIL>:SUBJECT
179 bool mailToOneContact( const QString& adressline ); 180 bool mailToOneContact( const QString& adressline );
180 181
181 //calls the phoneapplication with the number 182 //calls the phoneapplication with the number
182 bool callByPhone( const QString& phonenumber ); 183 bool callByPhone( const QString& phonenumber );
183 184
184 //calls the smsapplication with the number 185 //calls the smsapplication with the number
185 bool callBySMS( const QString& phonenumber ); 186 bool callBySMS( const QString& phonenumber );
186 187
187 //calls the pagerapplication with the number 188 //calls the pagerapplication with the number
188 bool callByPager( const QString& pagernumber ); 189 bool callByPager( const QString& pagernumber );
189 190
190 //calls the faxapplication with the number 191 //calls the faxapplication with the number
191 bool callByFax( const QString& faxnumber ); 192 bool callByFax( const QString& faxnumber );
192 193
194 //calls the sipapplication with the number
195 bool callBySIP( const QString& sipnumber );
196
193 bool isEmailAppAvailable(); 197 bool isEmailAppAvailable();
194 bool isSMSAppAvailable(); 198 bool isSMSAppAvailable();
195 bool isPhoneAppAvailable(); 199 bool isPhoneAppAvailable();
196 bool isFaxAppAvailable(); 200 bool isFaxAppAvailable();
197 bool isPagerAppAvailable(); 201 bool isPagerAppAvailable();
202 bool isSIPAppAvailable();
198 203
199 204
200 //Call this method on the source when you want to select names from the addressbook by using QCop 205 //Call this method on the source when you want to select names from the addressbook by using QCop
201 bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid); 206 bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid);
202 //Call this method on the target when you want to return the name/email map to the source (client). 207 //Call this method on the target when you want to return the name/email map to the source (client).
203 bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); 208 bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid);
204 209
205 bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email); 210 bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email);
206 bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); 211 bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid);
207 212
208 bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid); 213 bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid);
209 214
210 215
211 //loadConfig clears the cache and checks again if the applications are available or not 216 //loadConfig clears the cache and checks again if the applications are available or not
212 void loadConfig(); 217 void loadConfig();
213 218
214 QList<DefaultAppItem> getAvailableDefaultItems(Types); 219 QList<DefaultAppItem> getAvailableDefaultItems(Types);
215 DefaultAppItem* getDefaultItem(Types, int); 220 DefaultAppItem* getDefaultItem(Types, int);
216 221
217 public slots: 222 public slots:
218 void appMessage( const QCString& msg, const QByteArray& data ); 223 void appMessage( const QCString& msg, const QByteArray& data );
219 224
220 225
221 signals: 226 signals:
222 // Emmitted when the target app receives a request from the source app 227 // Emmitted when the target app receives a request from the source app
223 void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid); 228 void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid);
224 229
225 // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi 230 // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi
226 // The first parameter is a uniqueid. It can be used to identify the event 231 // The first parameter is a uniqueid. It can be used to identify the event
227 void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); 232 void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList);
228 233
229 void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email); 234 void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email);
230 void receivedFindBbyEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); 235 void receivedFindBbyEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList);
231 236
232 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 237 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
233 238
234 239
235 private: 240 private:
236 ExternalAppHandler(); 241 ExternalAppHandler();
237 QList<DefaultAppItem> mDefaultItems; 242 QList<DefaultAppItem> mDefaultItems;
238 243
239 Availability mEmailAppAvailable; 244 Availability mEmailAppAvailable;
240 Availability mPhoneAppAvailable; 245 Availability mPhoneAppAvailable;
241 Availability mFaxAppAvailable; 246 Availability mFaxAppAvailable;
242 Availability mSMSAppAvailable; 247 Availability mSMSAppAvailable;
243 Availability mPagerAppAvailable; 248 Availability mPagerAppAvailable;
249 Availability mSIPAppAvailable;
244 250
245 QCopListTransferItem* mNameEmailUidListFromKAPITransfer; 251 QCopListTransferItem* mNameEmailUidListFromKAPITransfer;
246 QCopListTransferItem* mFindByEmailFromKAPITransfer; 252 QCopListTransferItem* mFindByEmailFromKAPITransfer;
247 QCopTransferItem* mDisplayDetails; 253 QCopTransferItem* mDisplayDetails;
248 254
249 255
250 void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); 256 void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2);
251 257
252 QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; 258 QString& translateMessage(QString& message, const QString& param1, const QString& param2) const;
253 void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; 259 void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const;
254 260
255 261
256 static ExternalAppHandler *sInstance; 262 static ExternalAppHandler *sInstance;
257 263
258}; 264};
259 265
260 266
261#endif 267#endif