summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-10-29 16:39:40 (UTC)
committer zautrix <zautrix>2005-10-29 16:39:40 (UTC)
commit898dbabef6d747447999add46201315d04f85f63 (patch) (unidiff)
treefb247cbbd99ca6918400547e16484a58a8ba1523
parent1360f8e3b5da58b561f868643d2d5f04b874cee7 (diff)
downloadkdepimpi-898dbabef6d747447999add46201315d04f85f63.zip
kdepimpi-898dbabef6d747447999add46201315d04f85f63.tar.gz
kdepimpi-898dbabef6d747447999add46201315d04f85f63.tar.bz2
commit
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp6
-rw-r--r--korganizer/koeventviewer.cpp24
-rw-r--r--libkcal/person.cpp8
-rw-r--r--libkcal/person.h1
-rw-r--r--libkdepim/externalapphandler.cpp111
5 files changed, 125 insertions, 25 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index aae923c..5c24acf 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -1,349 +1,351 @@
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 <qvbox.h> 33#include <qvbox.h>
34#include <qlabel.h> 34#include <qlabel.h>
35#include <qwidget.h> 35#include <qwidget.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qapplication.h> 37#include <qapplication.h>
38#include <qpushbutton.h> 38#include <qpushbutton.h>
39#ifdef DESKTOP_VERSION 39#ifdef DESKTOP_VERSION
40#include <qpaintdevicemetrics.h> 40#include <qpaintdevicemetrics.h>
41#include <qprinter.h> 41#include <qprinter.h>
42#include <qpainter.h> 42#include <qpainter.h>
43#endif 43#endif
44 44
45 45
46#include <qstylesheet.h> 46#include <qstylesheet.h>
47#include "externalapphandler.h" 47#include "externalapphandler.h"
48#include <kabc/addresseeview.h> 48#include <kabc/addresseeview.h>
49 49
50 50
51//US #ifndef DESKTOP_VERSION 51//US #ifndef DESKTOP_VERSION
52//US #include <qtopia/qcopenvelope_qws.h> 52//US #include <qtopia/qcopenvelope_qws.h>
53//US #include <qpe/qpeapplication.h> 53//US #include <qpe/qpeapplication.h>
54//US #endif 54//US #endif
55 55
56//US static int kphoneInstalled = 0; 56//US static int kphoneInstalled = 0;
57 57
58using namespace KABC; 58using namespace KABC;
59bool AddresseeView::sFullDetailsMode = false; 59bool AddresseeView::sFullDetailsMode = false;
60 60
61AddresseeView::AddresseeView( QWidget *parent, const char *name ) 61AddresseeView::AddresseeView( QWidget *parent, const char *name )
62 : QTextBrowser( parent, name ) 62 : QTextBrowser( parent, name )
63 63
64 64
65{ 65{
66//US setWrapPolicy( QTextEdit::AtWordBoundary ); 66//US setWrapPolicy( QTextEdit::AtWordBoundary );
67 setLinkUnderline( false ); 67 setLinkUnderline( false );
68 // setVScrollBarMode( QScrollView::AlwaysOff ); 68 // setVScrollBarMode( QScrollView::AlwaysOff );
69 //setHScrollBarMode( QScrollView::AlwaysOff ); 69 //setHScrollBarMode( QScrollView::AlwaysOff );
70 70
71//US QStyleSheet *sheet = styleSheet(); 71//US QStyleSheet *sheet = styleSheet();
72//US QStyleSheetItem *link = sheet->item( "a" ); 72//US QStyleSheetItem *link = sheet->item( "a" );
73//US link->setColor( KGlobalSettings::linkColor() ); 73//US link->setColor( KGlobalSettings::linkColor() );
74 74
75 75
76} 76}
77void AddresseeView::printMe() 77void AddresseeView::printMe()
78{ 78{
79#ifdef DESKTOP_VERSION 79#ifdef DESKTOP_VERSION
80 QPrinter printer; 80 QPrinter printer;
81 if (!printer.setup() ) 81 if (!printer.setup() )
82 return; 82 return;
83 QPainter p; 83 QPainter p;
84 p.begin ( &printer ); 84 p.begin ( &printer );
85 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 85 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
86 float dx, dy; 86 float dx, dy;
87 int wid = (m.width() * 9)/10; 87 int wid = (m.width() * 9)/10;
88 dx = (float) wid/(float)contentsWidth (); 88 dx = (float) wid/(float)contentsWidth ();
89 dy = (float)(m.height()) / (float)contentsHeight (); 89 dy = (float)(m.height()) / (float)contentsHeight ();
90 float scale; 90 float scale;
91 // scale to fit the width or height of the paper 91 // scale to fit the width or height of the paper
92 if ( dx < dy ) 92 if ( dx < dy )
93 scale = dx; 93 scale = dx;
94 else 94 else
95 scale = dy; 95 scale = dy;
96 p.translate( m.width()/10,0 ); 96 p.translate( m.width()/10,0 );
97 p.scale( scale, scale ); 97 p.scale( scale, scale );
98 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 98 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
99 p.end(); 99 p.end();
100#endif 100#endif
101} 101}
102void AddresseeView::setSource(const QString& n) 102void AddresseeView::setSource(const QString& n)
103{ 103{
104 //qDebug("********AddresseeView::setSource %s", n.latin1()); 104 //qDebug("********AddresseeView::setSource %s", n.latin1());
105 105
106 if ( n == "allDetails" ) { 106 if ( n == "allDetails" ) {
107 sFullDetailsMode = true; 107 sFullDetailsMode = true;
108 setAddressee( mCurrentContact ); 108 setAddressee( mCurrentContact );
109 } else if ( n == "notAllDetails" ) { 109 } else if ( n == "notAllDetails" ) {
110 sFullDetailsMode = false; 110 sFullDetailsMode = false;
111 setAddressee( mCurrentContact ); 111 setAddressee( mCurrentContact );
112 } else if ( n.left( 6 ) == "mailto" ) 112 } else if ( n.left( 6 ) == "mailto" )
113 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); 113 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
114 else if ( n.left( 7 ) == "phoneto" ) 114 else if ( n.left( 7 ) == "phoneto" )
115 ExternalAppHandler::instance()->callByPhone( n.mid(8) ); 115 ExternalAppHandler::instance()->callByPhone( n.mid(8) );
116 else if ( n.left( 5 ) == "faxto" ) 116 else if ( n.left( 5 ) == "faxto" )
117 ExternalAppHandler::instance()->callByFax( n.mid(6) ); 117 ExternalAppHandler::instance()->callByFax( n.mid(6) );
118 else if ( n.left( 5 ) == "smsto" ) 118 else if ( n.left( 5 ) == "smsto" )
119 ExternalAppHandler::instance()->callBySMS( n.mid(6) ); 119 ExternalAppHandler::instance()->callBySMS( n.mid(6) );
120 else if ( n.left( 7 ) == "pagerto" ) 120 else if ( n.left( 7 ) == "pagerto" )
121 ExternalAppHandler::instance()->callByPager( n.mid(8) ); 121 ExternalAppHandler::instance()->callByPager( n.mid(8) );
122 else if ( n.left( 5 ) == "sipto" ) 122 else if ( n.left( 5 ) == "sipto" )
123 ExternalAppHandler::instance()->callBySIP( n.mid(6) ); 123 ExternalAppHandler::instance()->callBySIP( n.mid(6) );
124 124
125} 125}
126void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) 126void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
127{ 127{
128 bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); 128 bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable();
129 // mAddressee = addr; 129 // mAddressee = addr;
130 // clear view 130 // clear view
131 //setText( QString::null ); 131 //setText( QString::null );
132 mCurrentContact = mAddressee; 132 mCurrentContact = mAddressee;
133 if ( mAddressee.isEmpty() ) { 133 if ( mAddressee.isEmpty() ) {
134 setText( QString::null); 134 setText( QString::null);
135 return; 135 return;
136 } 136 }
137#if 0 137#if 0
138 QString name = ( mAddressee.assembledName().isEmpty() ? 138 QString name = ( mAddressee.assembledName().isEmpty() ?
139 mAddressee.formattedName() : mAddressee.assembledName() ); 139 mAddressee.formattedName() : mAddressee.assembledName() );
140#endif 140#endif
141 141
142 QString name = mAddressee.realName(); 142 QString name = mAddressee.realName();
143 143 QString assName = mAddressee.assembledName();
144 if ( assName.isEmpty() )
145 assName = name;
144 QString dynamicPart; 146 QString dynamicPart;
145 147
146 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); 148 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true );
147 QStringList emails = mAddressee.emails(); 149 QStringList emails = mAddressee.emails();
148 QStringList::ConstIterator emailIt; 150 QStringList::ConstIterator emailIt;
149 QString type = i18n( "Email" ); 151 QString type = i18n( "Email" );
150 emailIt = emails.begin(); 152 emailIt = emails.begin();
151 if ( emailIt != emails.end() ) { 153 if ( emailIt != emails.end() ) {
152 if ( kemailAvail ) { 154 if ( kemailAvail ) {
153 dynamicPart += QString( 155 dynamicPart += QString(
154 "<tr><td align=\"right\"><b>%1</b></td>" 156 "<tr><td align=\"right\"><b>%1</b></td>"
155 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 157 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
156 .arg( type ) 158 .arg( type )
157 .arg( name ) 159 .arg( assName )
158 .arg( *emailIt ) 160 .arg( *emailIt )
159 .arg( *emailIt ); 161 .arg( *emailIt );
160 ++emailIt; 162 ++emailIt;
161 } else { 163 } else {
162 dynamicPart += QString( 164 dynamicPart += QString(
163 "<tr><td align=\"right\"><b>%1</b></td>" 165 "<tr><td align=\"right\"><b>%1</b></td>"
164 "<td align=\"left\">%2</td></tr>" ) 166 "<td align=\"left\">%2</td></tr>" )
165 .arg( type ) 167 .arg( type )
166 .arg( *emailIt ); 168 .arg( *emailIt );
167 ++emailIt; 169 ++emailIt;
168 } 170 }
169 } 171 }
170 if ( mAddressee.birthday().date().isValid() ) { 172 if ( mAddressee.birthday().date().isValid() ) {
171 dynamicPart += QString( 173 dynamicPart += QString(
172 "<tr><td align=\"right\"><b>%1</b></td>" 174 "<tr><td align=\"right\"><b>%1</b></td>"
173 "<td align=\"left\">%2</td></tr>" ) 175 "<td align=\"left\">%2</td></tr>" )
174 .arg( i18n ("Birthday") ) 176 .arg( i18n ("Birthday") )
175 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); 177 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
176 } 178 }
177 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); 179 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false );
178 180
179 for ( ; emailIt != emails.end(); ++emailIt ) { 181 for ( ; emailIt != emails.end(); ++emailIt ) {
180 if ( kemailAvail ) { 182 if ( kemailAvail ) {
181 dynamicPart += QString( 183 dynamicPart += QString(
182 "<tr><td align=\"right\"><b>%1</b></td>" 184 "<tr><td align=\"right\"><b>%1</b></td>"
183 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 185 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
184 .arg( type ) 186 .arg( type )
185 .arg( name ) 187 .arg( name )
186 .arg( *emailIt ) 188 .arg( *emailIt )
187 .arg( *emailIt ); 189 .arg( *emailIt );
188 } else { 190 } else {
189 dynamicPart += QString( 191 dynamicPart += QString(
190 "<tr><td align=\"right\"><b>%1</b></td>" 192 "<tr><td align=\"right\"><b>%1</b></td>"
191 "<td align=\"left\">%2</td></tr>" ) 193 "<td align=\"left\">%2</td></tr>" )
192 .arg( type ) 194 .arg( type )
193 .arg( *emailIt ); 195 .arg( *emailIt );
194 } 196 }
195 } 197 }
196 198
197 199
198 200
199 KABC::Address::List addresses = mAddressee.addresses(); 201 KABC::Address::List addresses = mAddressee.addresses();
200 KABC::Address::List::ConstIterator addrIt; 202 KABC::Address::List::ConstIterator addrIt;
201 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 203 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
202 if ( true /*(*addrIt).label().isEmpty()*/ ) { 204 if ( true /*(*addrIt).label().isEmpty()*/ ) {
203 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 205 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
204//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 206//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
205 //qDebug("adresss %s ",formattedAddress.latin1() ); 207 //qDebug("adresss %s ",formattedAddress.latin1() );
206 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 208 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
207 //qDebug("AddresseeView::setAddressee has to be verified."); 209 //qDebug("AddresseeView::setAddressee has to be verified.");
208 210
209 dynamicPart += QString( 211 dynamicPart += QString(
210 "<tr><td align=\"right\"><b>%1</b></td>" 212 "<tr><td align=\"right\"><b>%1</b></td>"
211 "<td align=\"left\">%2</td></tr>" ) 213 "<td align=\"left\">%2</td></tr>" )
212 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 214 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
213 .arg( formattedAddress ); 215 .arg( formattedAddress );
214 } else { 216 } else {
215 217
216 dynamicPart += QString( 218 dynamicPart += QString(
217 "<tr><td align=\"right\"><b>%1</b></td>" 219 "<tr><td align=\"right\"><b>%1</b></td>"
218 "<td align=\"left\">%2</td></tr>" ) 220 "<td align=\"left\">%2</td></tr>" )
219 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 221 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
220//US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); 222//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
221 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); 223 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
222 224
223 } 225 }
224 } 226 }
225 227
226 228
227 QString notes; 229 QString notes;
228 if ( sFullDetailsMode ) { 230 if ( sFullDetailsMode ) {
229 notes = QString( 231 notes = QString(
230 "<tr><td align=\"right\"><b>%1</b></td>" 232 "<tr><td align=\"right\"><b>%1</b></td>"
231 "<td align=\"left\"><a href=\"notAllDetails\">%4</a></td></tr>" ) 233 "<td align=\"left\"><a href=\"notAllDetails\">%4</a></td></tr>" )
232 .arg( i18n("Details") ) 234 .arg( i18n("Details") )
233 .arg( i18n("Hide!") ); 235 .arg( i18n("Hide!") );
234 236
235 QString tempX = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); 237 QString tempX = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
236 if ( !tempX.isEmpty() ) { 238 if ( !tempX.isEmpty() ) {
237 if ( tempX == "male" || tempX == "female" ) { 239 if ( tempX == "male" || tempX == "female" ) {
238 notes += QString( 240 notes += QString(
239 "<tr><td align=\"right\"><b>%1</b></td>" 241 "<tr><td align=\"right\"><b>%1</b></td>"
240 "<td align=\"left\">%2</td></tr>" ) 242 "<td align=\"left\">%2</td></tr>" )
241 .arg( i18n( "" ) ) 243 .arg( i18n( "" ) )
242 .arg( i18n(tempX) ); 244 .arg( i18n(tempX) );
243 } 245 }
244 } 246 }
245 247
246 248
247 tempX = mAddressee.secrecy().asString(); 249 tempX = mAddressee.secrecy().asString();
248 250
249 notes += QString( 251 notes += QString(
250 "<tr><td align=\"right\"><b>%1</b></td>" 252 "<tr><td align=\"right\"><b>%1</b></td>"
251 "<td align=\"left\">%2</td></tr>" ) 253 "<td align=\"left\">%2</td></tr>" )
252 .arg( "" ) 254 .arg( "" )
253 .arg( tempX ); 255 .arg( tempX );
254 256
255 257
256 tempX = mAddressee.categories().join(" - "); 258 tempX = mAddressee.categories().join(" - ");
257 if ( !tempX.isEmpty() ) { 259 if ( !tempX.isEmpty() ) {
258 notes += QString( 260 notes += QString(
259 "<tr><td align=\"right\"><b>%1</b></td>" 261 "<tr><td align=\"right\"><b>%1</b></td>"
260 "<td align=\"left\">%2</td></tr>" ) 262 "<td align=\"left\">%2</td></tr>" )
261 .arg( i18n( "Category" ) ) 263 .arg( i18n( "Category" ) )
262 .arg( tempX ); 264 .arg( tempX );
263 } 265 }
264 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Profession" ); 266 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Profession" );
265 if ( !tempX.isEmpty() ) { 267 if ( !tempX.isEmpty() ) {
266 notes += QString( 268 notes += QString(
267 "<tr><td align=\"right\"><b>%1</b></td>" 269 "<tr><td align=\"right\"><b>%1</b></td>"
268 "<td align=\"left\">%2</td></tr>" ) 270 "<td align=\"left\">%2</td></tr>" )
269 .arg( i18n( "Profession" ) ) 271 .arg( i18n( "Profession" ) )
270 .arg( tempX ); 272 .arg( tempX );
271 } 273 }
272 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Office" ); 274 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Office" );
273 if ( !tempX.isEmpty() ) { 275 if ( !tempX.isEmpty() ) {
274 notes += QString( 276 notes += QString(
275 "<tr><td align=\"right\"><b>%1</b></td>" 277 "<tr><td align=\"right\"><b>%1</b></td>"
276 "<td align=\"left\">%2</td></tr>" ) 278 "<td align=\"left\">%2</td></tr>" )
277 .arg( i18n( "Office" ) ) 279 .arg( i18n( "Office" ) )
278 .arg( tempX ); 280 .arg( tempX );
279 } 281 }
280 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Department" ); 282 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Department" );
281 if ( !tempX.isEmpty() ) { 283 if ( !tempX.isEmpty() ) {
282 notes += QString( 284 notes += QString(
283 "<tr><td align=\"right\"><b>%1</b></td>" 285 "<tr><td align=\"right\"><b>%1</b></td>"
284 "<td align=\"left\">%2</td></tr>" ) 286 "<td align=\"left\">%2</td></tr>" )
285 .arg( i18n( "Department" ) ) 287 .arg( i18n( "Department" ) )
286 .arg( tempX ); 288 .arg( tempX );
287 } 289 }
288 290
289 tempX = mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ); 291 tempX = mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" );
290 if ( !tempX.isEmpty() ) { 292 if ( !tempX.isEmpty() ) {
291 notes += QString( 293 notes += QString(
292 "<tr><td align=\"right\"><b>%1</b></td>" 294 "<tr><td align=\"right\"><b>%1</b></td>"
293 "<td align=\"left\">%2</td></tr>" ) 295 "<td align=\"left\">%2</td></tr>" )
294 .arg( i18n( "Manager" ) ) 296 .arg( i18n( "Manager" ) )
295 .arg( tempX ); 297 .arg( tempX );
296 } 298 }
297 tempX = mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ); 299 tempX = mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" );
298 if ( !tempX.isEmpty() ) { 300 if ( !tempX.isEmpty() ) {
299 notes += QString( 301 notes += QString(
300 "<tr><td align=\"right\"><b>%1</b></td>" 302 "<tr><td align=\"right\"><b>%1</b></td>"
301 "<td align=\"left\">%2</td></tr>" ) 303 "<td align=\"left\">%2</td></tr>" )
302 .arg( i18n( "Assistant" ) ) 304 .arg( i18n( "Assistant" ) )
303 .arg( tempX ); 305 .arg( tempX );
304 } 306 }
305 if ( !mAddressee.url().url().isEmpty() ) { 307 if ( !mAddressee.url().url().isEmpty() ) {
306 notes += QString( 308 notes += QString(
307 "<tr><td align=\"right\"><b>%1</b></td>" 309 "<tr><td align=\"right\"><b>%1</b></td>"
308 "<td align=\"left\">%2</td></tr>" ) 310 "<td align=\"left\">%2</td></tr>" )
309 .arg( i18n( "Homepage" ) ) 311 .arg( i18n( "Homepage" ) )
310 .arg( mAddressee.url().url() ); 312 .arg( mAddressee.url().url() );
311 } 313 }
312 tempX = mAddressee.nickName(); 314 tempX = mAddressee.nickName();
313 if ( !tempX.isEmpty() ) { 315 if ( !tempX.isEmpty() ) {
314 notes += QString( 316 notes += QString(
315 "<tr><td align=\"right\"><b>%1</b></td>" 317 "<tr><td align=\"right\"><b>%1</b></td>"
316 "<td align=\"left\">%2</td></tr>" ) 318 "<td align=\"left\">%2</td></tr>" )
317 .arg( i18n( "Nickname" ) ) 319 .arg( i18n( "Nickname" ) )
318 .arg( tempX ); 320 .arg( tempX );
319 } 321 }
320 tempX = mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ); 322 tempX = mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" );
321 if ( !tempX.isEmpty() ) { 323 if ( !tempX.isEmpty() ) {
322 notes += QString( 324 notes += QString(
323 "<tr><td align=\"right\"><b>%1</b></td>" 325 "<tr><td align=\"right\"><b>%1</b></td>"
324 "<td align=\"left\">%2</td></tr>" ) 326 "<td align=\"left\">%2</td></tr>" )
325 .arg( i18n( "Messanger" ) ) 327 .arg( i18n( "Messanger" ) )
326 .arg( tempX ); 328 .arg( tempX );
327 } 329 }
328 330
329 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Anniversary" ); 331 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Anniversary" );
330 if ( !tempX.isEmpty() ) { 332 if ( !tempX.isEmpty() ) {
331 QDate dt = KGlobal::locale()->readDate( tempX, "%Y-%m-%d"); 333 QDate dt = KGlobal::locale()->readDate( tempX, "%Y-%m-%d");
332 if ( dt.isValid () ) { 334 if ( dt.isValid () ) {
333 tempX = KGlobal::locale()->formatDate(dt, true); 335 tempX = KGlobal::locale()->formatDate(dt, true);
334 notes += QString( 336 notes += QString(
335 "<tr><td align=\"right\"><b>%1</b></td>" 337 "<tr><td align=\"right\"><b>%1</b></td>"
336 "<td align=\"left\">%2</td></tr>" ) 338 "<td align=\"left\">%2</td></tr>" )
337 .arg( i18n( "Anniversary" ) ) 339 .arg( i18n( "Anniversary" ) )
338 .arg( tempX ); 340 .arg( tempX );
339 } 341 }
340 } 342 }
341 tempX = mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ); 343 tempX = mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" );
342 if ( !tempX.isEmpty() ) { 344 if ( !tempX.isEmpty() ) {
343 notes += QString( 345 notes += QString(
344 "<tr><td align=\"right\"><b>%1</b></td>" 346 "<tr><td align=\"right\"><b>%1</b></td>"
345 "<td align=\"left\">%2</td></tr>" ) 347 "<td align=\"left\">%2</td></tr>" )
346 .arg( i18n( "Spouse" ) ) 348 .arg( i18n( "Spouse" ) )
347 .arg( tempX ); 349 .arg( tempX );
348 } 350 }
349 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Children" ); 351 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Children" );
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 976ee2c..02b54da 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,441 +1,449 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <kabc/stdaddressbook.h> 38#include <kabc/stdaddressbook.h>
39 39
40#ifndef KORG_NODCOP 40#ifndef KORG_NODCOP
41#include <dcopclient.h> 41#include <dcopclient.h>
42#include "korganizer.h" 42#include "korganizer.h"
43#include "koprefs.h" 43#include "koprefs.h"
44#include "actionmanager.h" 44#include "actionmanager.h"
45#endif 45#endif
46 46
47#include "koeventviewer.h" 47#include "koeventviewer.h"
48//#ifndef KORG_NOKABC 48//#ifndef KORG_NOKABC
49//#include <kabc/stdaddressbook.h> 49//#include <kabc/stdaddressbook.h>
50//#define size count 50//#define size count
51//#endif 51//#endif
52 52
53#ifdef DESKTOP_VERSION 53#ifdef DESKTOP_VERSION
54#include <kabc/addresseedialog.h> 54#include <kabc/addresseedialog.h>
55#include <kabc/addresseeview.h> 55#include <kabc/addresseeview.h>
56#include <qprinter.h> 56#include <qprinter.h>
57#include <qpainter.h> 57#include <qpainter.h>
58#include <qpaintdevicemetrics.h> 58#include <qpaintdevicemetrics.h>
59#else //DESKTOP_VERSION 59#else //DESKTOP_VERSION
60#include <externalapphandler.h>
61#include <qtopia/qcopenvelope_qws.h> 60#include <qtopia/qcopenvelope_qws.h>
62#endif //DESKTOP_VERSION 61#endif //DESKTOP_VERSION
62#include <externalapphandler.h>
63 63
64KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 64KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
65 : QTextBrowser(parent,name) 65 : QTextBrowser(parent,name)
66{ 66{
67 mSyncMode = false; 67 mSyncMode = false;
68 mColorMode = 0; 68 mColorMode = 0;
69} 69}
70 70
71KOEventViewer::~KOEventViewer() 71KOEventViewer::~KOEventViewer()
72{ 72{
73} 73}
74 74
75void KOEventViewer::printMe() 75void KOEventViewer::printMe()
76{ 76{
77#ifdef DESKTOP_VERSION 77#ifdef DESKTOP_VERSION
78 78
79 KOPrintPrefs pp ( this ); 79 KOPrintPrefs pp ( this );
80 if (!pp.exec() ) 80 if (!pp.exec() )
81 return; 81 return;
82 int scaleval = pp.printMode() ; 82 int scaleval = pp.printMode() ;
83 83
84 QPrinter printer; 84 QPrinter printer;
85 if (!printer.setup() ) 85 if (!printer.setup() )
86 return; 86 return;
87 QPainter p; 87 QPainter p;
88 p.begin ( &printer ); 88 p.begin ( &printer );
89 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 89 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
90 float dx, dy; 90 float dx, dy;
91 int wid = (m.width() * 9)/10; 91 int wid = (m.width() * 9)/10;
92 dx = (float) wid/(float)contentsWidth (); 92 dx = (float) wid/(float)contentsWidth ();
93 dy = (float)(m.height()) / (float)contentsHeight (); 93 dy = (float)(m.height()) / (float)contentsHeight ();
94 float scale; 94 float scale;
95 // scale to fit the width or height of the paper 95 // scale to fit the width or height of the paper
96 if ( dx < dy ) 96 if ( dx < dy )
97 scale = dx; 97 scale = dx;
98 else 98 else
99 scale = dy; 99 scale = dy;
100 100
101 p.translate( m.width()/10,0 ); 101 p.translate( m.width()/10,0 );
102 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 102 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
103 p.scale( scale, scale ); 103 p.scale( scale, scale );
104 } 104 }
105 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 105 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
106 p.end(); 106 p.end();
107#endif 107#endif
108 108
109} 109}
110void KOEventViewer::setSource(const QString& n) 110void KOEventViewer::setSource(const QString& n)
111{ 111{
112 112
113 if ( n.left(8) == "todo_uid" ) { 113 if ( n.left(8) == "todo_uid" ) {
114 int midstr = 9; 114 int midstr = 9;
115#ifdef DESKTOP_VERSION 115#ifdef DESKTOP_VERSION
116 midstr = 11; 116 midstr = 11;
117#endif 117#endif
118 //qDebug("-%s- ", n.mid(midstr).latin1()); 118 //qDebug("-%s- ", n.mid(midstr).latin1());
119 emit showIncidence( n.mid(midstr) ); 119 emit showIncidence( n.mid(midstr) );
120 return; 120 return;
121 } 121 }
122 122
123 if ( n.left(3) == "uid" ) 123 if ( n.left(3) == "uid" )
124#ifdef DESKTOP_VERSION 124#ifdef DESKTOP_VERSION
125 { 125 {
126 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 126 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
127 KABC::AddressBook::Iterator it; 127 KABC::AddressBook::Iterator it;
128 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 128 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
129 // LR I do not understand, why the uid string is different on zaurus and desktop 129 // LR I do not understand, why the uid string is different on zaurus and desktop
130 QString uid = "uid://"+(*it).uid(); 130 QString uid = "uid://"+(*it).uid();
131 131
132 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 132 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
133 if (n == uid ) { 133 if (n == uid ) {
134 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 134 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
135 QDialog dia( this,"dia123", true ); 135 QDialog dia( this,"dia123", true );
136 dia.setCaption( i18n("Details of attendee") ); 136 dia.setCaption( i18n("Details of attendee") );
137 QVBoxLayout lay ( &dia ); 137 QVBoxLayout lay ( &dia );
138 KABC::AddresseeView av ( &dia ); 138 KABC::AddresseeView av ( &dia );
139 av.setAddressee( (*it) ); 139 av.setAddressee( (*it) );
140 lay.addWidget( &av ); 140 lay.addWidget( &av );
141 if ( QApplication::desktop()->width() < 480 ) 141 if ( QApplication::desktop()->width() < 480 )
142 dia.resize( 220, 240); 142 dia.resize( 220, 240);
143 else { 143 else {
144 dia.resize( 400,400); 144 dia.resize( 400,400);
145 } 145 }
146 dia.exec(); 146 dia.exec();
147 break; 147 break;
148 } 148 }
149 } 149 }
150 return; 150 return;
151 } 151 }
152#else 152#else
153 { 153 {
154 if ( "uid:organizer" == n ) { 154 if ( "uid:organizer" == n ) {
155 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); 155 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
156 return; 156 return;
157 } 157 }
158 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 158 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
159 if (attendees.count()) { 159 if (attendees.count()) {
160 Attendee *a; 160 Attendee *a;
161 for(a=attendees.first();a;a=attendees.next()) { 161 for(a=attendees.first();a;a=attendees.next()) {
162 if ( "uid:"+a->uid() == n ) { 162 if ( "uid:"+a->uid() == n ) {
163 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 163 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
164 return; 164 return;
165 } 165 }
166 } 166 }
167 } 167 }
168 return; 168 return;
169 } 169 }
170 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 170 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
171 // the result should now arrive through method insertAttendees 171 // the result should now arrive through method insertAttendees
172 //QString uid = "uid:"+(*it).uid(); 172 //QString uid = "uid:"+(*it).uid();
173#endif 173#endif
174 if ( n.left(6) == "mailto" ) { 174 if ( n.left(6) == "mailto" ) {
175 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 175 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
176#ifndef DESKTOP_VERSION 176 //#ifndef DESKTOP_VERSION
177 if ( n.mid(7,3) == "ALL" ) { 177 if ( n.mid(7,3) == "ALL" ) {
178 mailToAttendees( true ); 178 mailToAttendees( true );
179 } else if ( n.mid(7,4) == "RSVP" ) { 179 } else if ( n.mid(7,4) == "RSVP" ) {
180 mailToAttendees( false ); 180 mailToAttendees( false );
181 } else { 181 } else {
182 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 182 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
183 e << n.mid(7); 183 //QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
184 //e << n.mid(7);
184 } 185 }
185#endif 186 //#endif
186 187
187 } 188 }
188 189
189 190
190#ifndef KORG_NODCOP 191#ifndef KORG_NODCOP
191 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 192 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
192 QString tmpStr; 193 QString tmpStr;
193 if (n.startsWith("mailto:")) { 194 if (n.startsWith("mailto:")) {
194 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 195 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
195 //emit showIncidence(n); 196 //emit showIncidence(n);
196 return; 197 return;
197 } else if (n.startsWith("uid:")) { 198 } else if (n.startsWith("uid:")) {
198 DCOPClient *client = KApplication::kApplication()->dcopClient(); 199 DCOPClient *client = KApplication::kApplication()->dcopClient();
199 const QByteArray noParamData; 200 const QByteArray noParamData;
200 const QByteArray paramData; 201 const QByteArray paramData;
201 QByteArray replyData; 202 QByteArray replyData;
202 QCString replyTypeStr; 203 QCString replyTypeStr;
203#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 204#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
204 bool foundAbbrowser = PING_ABBROWSER; 205 bool foundAbbrowser = PING_ABBROWSER;
205 206
206 if (foundAbbrowser) { 207 if (foundAbbrowser) {
207 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 208 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
208 //client->send("kaddressbook","KAddressBookIface", 209 //client->send("kaddressbook","KAddressBookIface",
209 QDataStream arg(paramData, IO_WriteOnly); 210 QDataStream arg(paramData, IO_WriteOnly);
210 arg << n.mid(6); 211 arg << n.mid(6);
211 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 212 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
212 return; 213 return;
213 } else { 214 } else {
214 /* 215 /*
215 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 216 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
216 We start it without its main interface 217 We start it without its main interface
217 */ 218 */
218 KIconLoader* iconLoader = new KIconLoader(); 219 KIconLoader* iconLoader = new KIconLoader();
219 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 220 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
220 ActionManager::setStartedKAddressBook(true); 221 ActionManager::setStartedKAddressBook(true);
221 tmpStr = "kaddressbook --editor-only --uid "; 222 tmpStr = "kaddressbook --editor-only --uid ";
222 tmpStr += KProcess::quote(n.mid(6)); 223 tmpStr += KProcess::quote(n.mid(6));
223 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 224 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
224 return; 225 return;
225 } 226 }
226 } else { 227 } else {
227 //QTextBrowser::setSource(n); 228 //QTextBrowser::setSource(n);
228 } 229 }
229#endif 230#endif
230} 231}
231void KOEventViewer::mailToAttendees( bool all ) 232void KOEventViewer::mailToAttendees( bool all )
232{ 233{
233 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 234 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
234 if (attendees.count() == 0) return; 235 if (attendees.count() == 0) return;
235 QStringList nameList; 236 QStringList nameList;
236 QStringList emailList; 237 QStringList emailList;
237 QStringList uidList; 238 QStringList uidList;
238 Attendee* a; 239 Attendee* a;
239 for(a=attendees.first();a;a=attendees.next()) { 240 for(a=attendees.first();a;a=attendees.next()) {
240 if ( !all && !a->RSVP() ) continue; 241 if ( !all && !a->RSVP() ) continue;
241 if (!a->email().isEmpty()) { 242 if (!a->email().isEmpty()) {
242 nameList.append (a->name() ); 243#ifndef DESKTOP_VERSION
244 nameList.append (a->realName() );
243 emailList.append (a->email() ); 245 emailList.append (a->email() );
244 uidList.append (a->uid() ); 246 uidList.append (a->uid() );
247#else
248 emailList.append(a->realName() +" <" + a->email() +">");
249#endif
245 } 250 }
246 } 251 }
247 QString uid = "ComposeMailUIpick2"+mMailSubject;
248#ifndef DESKTOP_VERSION 252#ifndef DESKTOP_VERSION
253 QString uid = "ComposeMailUIpick2"+mMailSubject;
249 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 254 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
255
256#else
257 ExternalAppHandler::instance()->mailToMultipleContacts( emailList.join(","), mMailSubject );
250#endif 258#endif
251 259
252} 260}
253void KOEventViewer::addTag(const QString & tag,const QString & text) 261void KOEventViewer::addTag(const QString & tag,const QString & text)
254{ 262{
255 int number=text.contains("\n"); 263 int number=text.contains("\n");
256 QString str = "<" + tag + ">"; 264 QString str = "<" + tag + ">";
257 QString tmpText=text; 265 QString tmpText=text;
258 QString tmpStr=str; 266 QString tmpStr=str;
259 if(number !=-1) 267 if(number !=-1)
260 { 268 {
261 if (number > 0) { 269 if (number > 0) {
262 int pos=0; 270 int pos=0;
263 QString tmp; 271 QString tmp;
264 for(int i=0;i<=number;i++) { 272 for(int i=0;i<=number;i++) {
265 pos=tmpText.find("\n"); 273 pos=tmpText.find("\n");
266 tmp=tmpText.left(pos); 274 tmp=tmpText.left(pos);
267 tmpText=tmpText.right(tmpText.length()-pos-1); 275 tmpText=tmpText.right(tmpText.length()-pos-1);
268 tmpStr+=tmp+"<br>"; 276 tmpStr+=tmp+"<br>";
269 } 277 }
270 } 278 }
271 else tmpStr += tmpText; 279 else tmpStr += tmpText;
272 tmpStr+="</" + tag + ">"; 280 tmpStr+="</" + tag + ">";
273 mText.append(tmpStr); 281 mText.append(tmpStr);
274 } 282 }
275 else 283 else
276 { 284 {
277 str += text + "</" + tag + ">"; 285 str += text + "</" + tag + ">";
278 mText.append(str); 286 mText.append(str);
279 } 287 }
280} 288}
281 289
282void KOEventViewer::setColorMode( int m ) 290void KOEventViewer::setColorMode( int m )
283{ 291{
284 mColorMode = m; 292 mColorMode = m;
285} 293}
286void KOEventViewer::appendEvent(Event *event, int mode ) 294void KOEventViewer::appendEvent(Event *event, int mode )
287{ 295{
288 mMailSubject = ""; 296 mMailSubject = "";
289 mCurrentIncidence = event; 297 mCurrentIncidence = event;
290 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 298 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
291 bool wideScreen = ( QApplication::desktop()->width() >= 640 ); 299 bool wideScreen = ( QApplication::desktop()->width() >= 640 );
292 topLevelWidget()->setCaption(i18n("Event Viewer")); 300 topLevelWidget()->setCaption(i18n("Event Viewer"));
293 if ( mode == 0 ) { 301 if ( mode == 0 ) {
294 addTag("h2",deTag(event->summary())); 302 addTag("h2",deTag(event->summary()));
295 formatReadOnly(event); 303 formatReadOnly(event);
296 } 304 }
297 else { 305 else {
298 if ( mColorMode == 1 ) { 306 if ( mColorMode == 1 ) {
299 mText +="<font color=\"#00A000\">"; 307 mText +="<font color=\"#00A000\">";
300 } 308 }
301 if ( mColorMode == 2 ) { 309 if ( mColorMode == 2 ) {
302 mText +="<font color=\"#C00000\">"; 310 mText +="<font color=\"#C00000\">";
303 } 311 }
304 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 312 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
305 if ( mode == 1 ) { 313 if ( mode == 1 ) {
306 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 314 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
307 } else { 315 } else {
308 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 316 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
309 } 317 }
310 formatReadOnly(event); 318 formatReadOnly(event);
311 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 319 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
312 if ( mColorMode ) 320 if ( mColorMode )
313 mText += "</font>"; 321 mText += "</font>";
314 } 322 }
315 mMailSubject += i18n( "Meeting " )+ event->summary(); 323 mMailSubject += i18n( "Meeting " )+ event->summary();
316 if (event->cancelled ()) { 324 if (event->cancelled ()) {
317 mText +="<font color=\"#B00000\">"; 325 mText +="<font color=\"#B00000\">";
318 addTag("i",i18n("This event has been cancelled!")); 326 addTag("i",i18n("This event has been cancelled!"));
319 mText.append("<br>"); 327 mText.append("<br>");
320 mText += "</font>"; 328 mText += "</font>";
321 mMailSubject += i18n("(cancelled)"); 329 mMailSubject += i18n("(cancelled)");
322 } 330 }
323 331
324 if (event->doesFloat()) { 332 if (event->doesFloat()) {
325 if (event->isMultiDay()) { 333 if (event->isMultiDay()) {
326 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 334 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
327 .arg(event->dtStartDateStr(shortDate)) 335 .arg(event->dtStartDateStr(shortDate))
328 .arg(event->dtEndDateStr(shortDate))); 336 .arg(event->dtEndDateStr(shortDate)));
329 mText.append(i18n("<p><b>Duration:</b> %1 days</p>") 337 mText.append(i18n("<p><b>Duration:</b> %1 days</p>")
330 .arg(event->dtStart().daysTo(event->dtEnd())+1)); 338 .arg(event->dtStart().daysTo(event->dtEnd())+1));
331 } else { 339 } else {
332 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 340 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
333 } 341 }
334 } else { 342 } else {
335 if (event->isMultiDay()) { 343 if (event->isMultiDay()) {
336 mText.append(i18n("<p><b>From:</b> %1</p> ") 344 mText.append(i18n("<p><b>From:</b> %1</p> ")
337 .arg(event->dtStartStr( shortDate))); 345 .arg(event->dtStartStr( shortDate)));
338 mText.append(i18n("<p><b>To:</b> %1</p>") 346 mText.append(i18n("<p><b>To:</b> %1</p>")
339 .arg(event->dtEndStr(shortDate))); 347 .arg(event->dtEndStr(shortDate)));
340 } else { 348 } else {
341 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 349 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
342 .arg(event->dtStartTimeStr()) 350 .arg(event->dtStartTimeStr())
343 .arg(event->dtEndTimeStr())); 351 .arg(event->dtEndTimeStr()));
344 mText.append(i18n("<p><b>On:</b> %1</p> ") 352 mText.append(i18n("<p><b>On:</b> %1</p> ")
345 .arg(event->dtStartDateStr( shortDate ))); 353 .arg(event->dtStartDateStr( shortDate )));
346 } 354 }
347 } 355 }
348 if (!event->location().isEmpty()) { 356 if (!event->location().isEmpty()) {
349 addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); 357 addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) );
350 mMailSubject += i18n(" at ") + event->location(); 358 mMailSubject += i18n(" at ") + event->location();
351 } 359 }
352 if (event->doesRecur()) { 360 if (event->doesRecur()) {
353 361
354 QString recurText = event->recurrenceText(); 362 QString recurText = event->recurrenceText();
355 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 363 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
356 bool ok; 364 bool ok;
357 QDate start = QDate::currentDate(); 365 QDate start = QDate::currentDate();
358 QDateTime next; 366 QDateTime next;
359 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 367 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
360 if ( ok ) { 368 if ( ok ) {
361 if ( wideScreen ){ 369 if ( wideScreen ){
362 addTag("p",i18n("<b>Next recurrence is on:</b>") +" " + KGlobal::locale()->formatDate( next.date(), shortDate ) ); 370 addTag("p",i18n("<b>Next recurrence is on:</b>") +" " + KGlobal::locale()->formatDate( next.date(), shortDate ) );
363 } else { 371 } else {
364 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 372 addTag("p",i18n("<b>Next recurrence is on:</b>") );
365 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 373 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
366 } 374 }
367 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); 375 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true );
368 376
369 } else { 377 } else {
370 bool last; 378 bool last;
371 QDate nextd; 379 QDate nextd;
372 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 380 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
373 if ( last ) { 381 if ( last ) {
374 if ( wideScreen ){ 382 if ( wideScreen ){
375 addTag("p",i18n("<b>Last recurrence was on:</b>") +" " + KGlobal::locale()->formatDate( nextd, shortDate )); 383 addTag("p",i18n("<b>Last recurrence was on:</b>") +" " + KGlobal::locale()->formatDate( nextd, shortDate ));
376 } else{ 384 } else{
377 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 385 addTag("p",i18n("<b>Last recurrence was on:</b>") );
378 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); 386 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
379 } 387 }
380 } 388 }
381 } 389 }
382 } else { 390 } else {
383 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 391 mMailSubject += i18n(" - " )+event->dtStartStr( true );
384 392
385 } 393 }
386 394
387 395
388 if (event->isAlarmEnabled()) { 396 if (event->isAlarmEnabled()) {
389 Alarm *alarm =event->alarms().first() ; 397 Alarm *alarm =event->alarms().first() ;
390 QDateTime t = alarm->time(); 398 QDateTime t = alarm->time();
391 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 399 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
392 if(wideScreen ){ 400 if(wideScreen ){
393 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); 401 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate ));
394 }else{ 402 }else{
395 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 403 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
396 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 404 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
397 } 405 }
398 //addTag("p",s); 406 //addTag("p",s);
399 } 407 }
400 408
401 addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); 409 addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr());
402 410
403 formatCategories(event); 411 formatCategories(event);
404 412
405 formatAttendees(event); 413 formatAttendees(event);
406 414
407 if ( KOPrefs::instance()->mEVshowCreated ) { 415 if ( KOPrefs::instance()->mEVshowCreated ) {
408 if(wideScreen ){ 416 if(wideScreen ){
409 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 417 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
410 }else{ 418 }else{
411 addTag("p",i18n("<b>Created: ") +" </b>"); 419 addTag("p",i18n("<b>Created: ") +" </b>");
412 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 420 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
413 } 421 }
414 422
415 423
416 } 424 }
417 if ( KOPrefs::instance()->mEVshowChanged ) { 425 if ( KOPrefs::instance()->mEVshowChanged ) {
418 if(wideScreen ){ 426 if(wideScreen ){
419 addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); 427 addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) );
420 }else{ 428 }else{
421 addTag("p",i18n("<b>Last modified: ") +" </b>"); 429 addTag("p",i18n("<b>Last modified: ") +" </b>");
422 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 430 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
423 } 431 }
424 432
425 } 433 }
426 if ( KOPrefs::instance()->mEVshowDetails ) { 434 if ( KOPrefs::instance()->mEVshowDetails ) {
427 if (!event->description().isEmpty()) { 435 if (!event->description().isEmpty()) {
428 addTag("p",i18n("<b>Details: </b>")); 436 addTag("p",i18n("<b>Details: </b>"));
429 addTag("p",deTag(event->description())); 437 addTag("p",deTag(event->description()));
430 } 438 }
431 } 439 }
432 setText(mText); 440 setText(mText);
433 //QWhatsThis::add(this,mText); 441 //QWhatsThis::add(this,mText);
434 442
435} 443}
436 444
437void KOEventViewer::appendTodo(Todo *event, int mode ) 445void KOEventViewer::appendTodo(Todo *event, int mode )
438{ 446{
439 mMailSubject = ""; 447 mMailSubject = "";
440 mCurrentIncidence = event; 448 mCurrentIncidence = event;
441 topLevelWidget()->setCaption(i18n("Todo Viewer")); 449 topLevelWidget()->setCaption(i18n("Todo Viewer"));
@@ -481,353 +489,353 @@ void KOEventViewer::appendTodo(Todo *event, int mode )
481 mMailSubject += i18n("(cancelled)"); 489 mMailSubject += i18n("(cancelled)");
482 } 490 }
483 491
484 492
485 493
486 if (event->doesRecur()) { 494 if (event->doesRecur()) {
487 495
488 QString recurText = event->recurrence()->recurrenceText(); 496 QString recurText = event->recurrence()->recurrenceText();
489 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); 497 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>");
490 498
491 } 499 }
492 if (event->hasStartDate()) { 500 if (event->hasStartDate()) {
493 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 501 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
494 } 502 }
495 if (event->hasDueDate()) { 503 if (event->hasDueDate()) {
496 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 504 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
497 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 505 mMailSubject += i18n(" - " )+event->dtDueStr( true );
498 } 506 }
499 if (!event->location().isEmpty()) { 507 if (!event->location().isEmpty()) {
500 addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); 508 addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) );
501 mMailSubject += i18n(" at ") + event->location(); 509 mMailSubject += i18n(" at ") + event->location();
502 } 510 }
503 mText.append(i18n("<p><b>Priority:</b> %2</p>") 511 mText.append(i18n("<p><b>Priority:</b> %2</p>")
504 .arg(QString::number(event->priority()))); 512 .arg(QString::number(event->priority())));
505 513
506 if (event->isAlarmEnabled()) { 514 if (event->isAlarmEnabled()) {
507 Alarm *alarm =event->alarms().first() ; 515 Alarm *alarm =event->alarms().first() ;
508 QDateTime t = alarm->time(); 516 QDateTime t = alarm->time();
509 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 517 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
510 if ( wideScreen ) { 518 if ( wideScreen ) {
511 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); 519 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate ));
512 } else { 520 } else {
513 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 521 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
514 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 522 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
515 } 523 }
516 } 524 }
517 525
518 addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); 526 addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr());
519 527
520 formatCategories(event); 528 formatCategories(event);
521 529
522 formatAttendees(event); 530 formatAttendees(event);
523 531
524 if ( KOPrefs::instance()->mEVshowCreated ) { 532 if ( KOPrefs::instance()->mEVshowCreated ) {
525 if(wideScreen ){ 533 if(wideScreen ){
526 534
527 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 535 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
528 536
529 } else { 537 } else {
530 addTag("p",i18n("<b>Created: ") +" </b>"); 538 addTag("p",i18n("<b>Created: ") +" </b>");
531 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 539 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
532 } 540 }
533 } 541 }
534 if ( KOPrefs::instance()->mEVshowChanged ) { 542 if ( KOPrefs::instance()->mEVshowChanged ) {
535 if(wideScreen ){ 543 if(wideScreen ){
536 addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); 544 addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) );
537 545
538 } else { 546 } else {
539 addTag("p",i18n("<b>Last modified: ") +" </b>"); 547 addTag("p",i18n("<b>Last modified: ") +" </b>");
540 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 548 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
541 } 549 }
542 } 550 }
543 if ( event->relatedTo() ) { 551 if ( event->relatedTo() ) {
544 addTag("b",i18n("Parent todo:<br>")); 552 addTag("b",i18n("Parent todo:<br>"));
545 553
546 QString t_name = "[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] ";// +event->relatedTo()->summary()); 554 QString t_name = "[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] ";// +event->relatedTo()->summary());
547 555
548 mText += t_name; 556 mText += t_name;
549 mText += "<a href=\"todo_uid:" + event->relatedTo()->uid() + "\">"; 557 mText += "<a href=\"todo_uid:" + event->relatedTo()->uid() + "\">";
550 mText += deTag(event->relatedTo()->summary()); 558 mText += deTag(event->relatedTo()->summary());
551 mText += "</a><br>"; 559 mText += "</a><br>";
552 560
553 // mText.append(deTag("[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] " +event->relatedTo()->summary()) +"<br>"); 561 // mText.append(deTag("[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] " +event->relatedTo()->summary()) +"<br>");
554 } 562 }
555 QPtrList<Incidence> Relations = event->relations(); 563 QPtrList<Incidence> Relations = event->relations();
556 Incidence *to; 564 Incidence *to;
557 if ( Relations.first() ) 565 if ( Relations.first() )
558 addTag("b",i18n("Sub todos:<br>")); 566 addTag("b",i18n("Sub todos:<br>"));
559 for (to=Relations.first();to;to=Relations.next()) { 567 for (to=Relations.first();to;to=Relations.next()) {
560 QString t_name = "[" +QString::number(((Todo*)to)->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%] ";// +to->relatedTo()->summary()); 568 QString t_name = "[" +QString::number(((Todo*)to)->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%] ";// +to->relatedTo()->summary());
561 mText += t_name; 569 mText += t_name;
562 mText += "<a href=\"todo_uid:" + to->uid() + "\">"; 570 mText += "<a href=\"todo_uid:" + to->uid() + "\">";
563 mText += deTag(to->summary()); 571 mText += deTag(to->summary());
564 mText += "</a><br>"; 572 mText += "</a><br>";
565 573
566 } 574 }
567 575
568 if ( KOPrefs::instance()->mEVshowDetails ) { 576 if ( KOPrefs::instance()->mEVshowDetails ) {
569 if (!event->description().isEmpty()) { 577 if (!event->description().isEmpty()) {
570 addTag("p",i18n("<b>Details: </b>")); 578 addTag("p",i18n("<b>Details: </b>"));
571 addTag("p",deTag(event->description())); 579 addTag("p",deTag(event->description()));
572 } 580 }
573 } 581 }
574 setText(mText); 582 setText(mText);
575} 583}
576 584
577void KOEventViewer::formatCategories(Incidence *event) 585void KOEventViewer::formatCategories(Incidence *event)
578{ 586{
579 if (!event->categoriesStr().isEmpty()) { 587 if (!event->categoriesStr().isEmpty()) {
580 if (event->categories().count() == 1) { 588 if (event->categories().count() == 1) {
581 addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); 589 addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace());
582 } else { 590 } else {
583 addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; 591 addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ;
584 } 592 }
585 } 593 }
586} 594}
587void KOEventViewer::formatAttendees(Incidence *event) 595void KOEventViewer::formatAttendees(Incidence *event)
588{ 596{
589 QPtrList<Attendee> attendees = event->attendees(); 597 QPtrList<Attendee> attendees = event->attendees();
590 if (attendees.count()) { 598 if (attendees.count()) {
591 599
592 600
593 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 601 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
594 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 602 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
595 addTag("h3",i18n("Organizer")); 603 addTag("h3",i18n("Organizer"));
596 mText.append("<ul><li>"); 604 mText.append("<ul><li>");
597#ifndef KORG_NOKABC 605#ifndef KORG_NOKABC
598 606
599#ifdef DESKTOP_VERSION 607#ifdef DESKTOP_VERSION
600 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 608 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
601 KABC::Addressee::List addressList; 609 KABC::Addressee::List addressList;
602 addressList = add_book->findByEmail(event->organizer()); 610 addressList = add_book->findByEmail(event->organizer());
603 KABC::Addressee o = addressList.first(); 611 KABC::Addressee o = addressList.first();
604 if (!o.isEmpty() && addressList.size()<2) { 612 if (!o.isEmpty() && addressList.size()<2) {
605 mText += "<a href=\"uid:" + o.uid() + "\">"; 613 mText += "<a href=\"uid:" + o.uid() + "\">";
606 mText += o.formattedName(); 614 mText += o.formattedName();
607 mText += "</a>\n"; 615 mText += "</a>\n";
608 } else { 616 } else {
609 mText.append(event->organizer()); 617 mText.append(event->organizer());
610 } 618 }
611#else //DESKTOP_VERSION 619#else //DESKTOP_VERSION
612 mText += "<a href=\"uid:organizer\">"; 620 mText += "<a href=\"uid:organizer\">";
613 mText += event->organizer(); 621 mText += event->organizer();
614 mText += "</a>\n"; 622 mText += "</a>\n";
615#endif //DESKTOP_VERSION 623#endif //DESKTOP_VERSION
616 624
617 625
618#else 626#else
619 mText.append(event->organizer()); 627 mText.append(event->organizer());
620#endif 628#endif
621 629
622 if (iconPath) { 630 if (iconPath) {
623 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 631 mText += " <a href=\"mailto:" + event->organizer() + "\">";
624 mText += "<IMG src=\"" + iconPath + "\">"; 632 mText += "<IMG src=\"" + iconPath + "\">";
625 mText += "</a>\n"; 633 mText += "</a>\n";
626 } 634 }
627 mText.append("</li></ul>"); 635 mText.append("</li></ul>");
628 636
629 addTag("h3",i18n("Attendees")); 637 addTag("h3",i18n("Attendees"));
630 Attendee *a; 638 Attendee *a;
631 mText.append("<ul>"); 639 mText.append("<ul>");
632 int a_count = 0; 640 int a_count = 0;
633 int a_count_nr = 0; 641 int a_count_nr = 0;
634 642
635 for(a=attendees.first();a;a=attendees.next()) { 643 for(a=attendees.first();a;a=attendees.next()) {
636#ifndef KORG_NOKABC 644#ifndef KORG_NOKABC
637#ifdef DESKTOP_VERSION 645#ifdef DESKTOP_VERSION
638 if (a->name().isEmpty()) { 646 if (a->name().isEmpty()) {
639 addressList = add_book->findByEmail(a->email()); 647 addressList = add_book->findByEmail(a->email());
640 KABC::Addressee o = addressList.first(); 648 KABC::Addressee o = addressList.first();
641 if (!o.isEmpty() && addressList.size()<2) { 649 if (!o.isEmpty() && addressList.size()<2) {
642 mText += "<a href=\"uid:" + o.uid() + "\">"; 650 mText += "<a href=\"uid:" + o.uid() + "\">";
643 mText += o.formattedName(); 651 mText += o.formattedName();
644 mText += "</a>\n"; 652 mText += "</a>\n";
645 } else { 653 } else {
646 mText += "<li>"; 654 mText += "<li>";
647 mText.append(a->email()); 655 mText.append(a->email());
648 mText += "\n"; 656 mText += "\n";
649 } 657 }
650 } else { 658 } else {
651 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 659 mText += "<li><a href=\"uid:" + a->uid() + "\">";
652 if (!a->name().isEmpty()) mText += a->name(); 660 if (!a->name().isEmpty()) mText += a->name();
653 else mText += a->email(); 661 else mText += a->email();
654 mText += "</a>\n"; 662 mText += "</a>\n";
655 } 663 }
656#else //DESKTOP_VERSION 664#else //DESKTOP_VERSION
657 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 665 mText += "<li><a href=\"uid:" + a->uid() + "\">";
658 if (!a->name().isEmpty()) mText += a->name(); 666 if (!a->name().isEmpty()) mText += a->name();
659 else mText += a->email(); 667 else mText += a->email();
660 mText += "</a>\n"; 668 mText += "</a>\n";
661#endif //DESKTOP_VERSION 669#endif //DESKTOP_VERSION
662#else 670#else
663 //qDebug("nokabc "); 671 //qDebug("nokabc ");
664 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 672 mText += "<li><a href=\"uid:" + a->uid() + "\">";
665 if (!a->name().isEmpty()) mText += a->name(); 673 if (!a->name().isEmpty()) mText += a->name();
666 else mText += a->email(); 674 else mText += a->email();
667 mText += "</a>\n"; 675 mText += "</a>\n";
668#endif 676#endif
669 677
670 678
671 if (!a->email().isEmpty()) { 679 if (!a->email().isEmpty()) {
672 if (iconPath) { 680 if (iconPath) {
673 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 681 mText += "<a href=\"mailto:" + a->realName() +" <" + a->email() + ">:" + mMailSubject + "\">";
674 if ( a->RSVP() ) { 682 if ( a->RSVP() ) {
675 ++a_count_nr; 683 ++a_count_nr;
676 mText += "<IMG src=\"" + iconPath + "\">"; 684 mText += "<IMG src=\"" + iconPath + "\">";
677 } 685 }
678 else { 686 else {
679 ++a_count; 687 ++a_count;
680 mText += "<IMG src=\"" + NOiconPath + "\">"; 688 mText += "<IMG src=\"" + NOiconPath + "\">";
681 } 689 }
682 mText += "</a>\n"; 690 mText += "</a>\n";
683 } 691 }
684 } 692 }
685 if (a->status() != Attendee::NeedsAction ) 693 if (a->status() != Attendee::NeedsAction )
686 mText +="[" + a->statusStr() + "] "; 694 mText +="[" + a->statusStr() + "] ";
687 if (a->role() == Attendee::Chair ) 695 if (a->role() == Attendee::Chair )
688 mText +="(" + a->roleStr().left(1) + ".)"; 696 mText +="(" + a->roleStr().left(1) + ".)";
689 } 697 }
690 mText.append("</li></ul>"); 698 mText.append("</li></ul>");
691 if ( (a_count+a_count_nr) > 1 ) { 699 if ( (a_count+a_count_nr) > 1 ) {
692 mText += "<a href=\"mailto:ALL\">"; 700 mText += "<a href=\"mailto:ALL\">";
693 mText += i18n( "Mail to all" ); 701 mText += i18n( "Mail to all" );
694 mText += "</a> ( "; 702 mText += "</a> ( ";
695 mText += "<IMG src=\"" + iconPath + "\">"; 703 mText += "<IMG src=\"" + iconPath + "\">";
696 mText += i18n( " and " ); 704 mText += i18n( " and " );
697 mText += "<IMG src=\"" + NOiconPath + "\"> )"; 705 mText += "<IMG src=\"" + NOiconPath + "\"> )";
698 mText += "<br>\n"; 706 mText += "<br>\n";
699 707
700 708
701 } 709 }
702 if ( a_count_nr > 1 ) { 710 if ( a_count_nr > 1 ) {
703 mText += "<a href=\"mailto:RSVP\">"; 711 mText += "<a href=\"mailto:RSVP\">";
704 mText += i18n( "Mail to selected" ); 712 mText += i18n( "Mail to selected" );
705 mText += "</a> ( "; 713 mText += "</a> ( ";
706 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); 714 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath );
707 mText += "<br>\n"; 715 mText += "<br>\n";
708 } 716 }
709 } 717 }
710 718
711} 719}
712void KOEventViewer::appendJournal(Journal *jour, int mode ) 720void KOEventViewer::appendJournal(Journal *jour, int mode )
713{ 721{
714 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 722 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
715 QString text_d = i18n("Journal from: "); 723 QString text_d = i18n("Journal from: ");
716 if ( !jour->summary().isEmpty() ) 724 if ( !jour->summary().isEmpty() )
717 text_d = jour->summary(); 725 text_d = jour->summary();
718 if (mode == 0 ) { 726 if (mode == 0 ) {
719 addTag("h2", text_d ); 727 addTag("h2", text_d );
720 } 728 }
721 else { 729 else {
722 if ( mode == 1 ) { 730 if ( mode == 1 ) {
723 addTag("h3",i18n( "Local: " ) + text_d ); 731 addTag("h3",i18n( "Local: " ) + text_d );
724 } else { 732 } else {
725 addTag("h3",i18n( "Remote: " ) + text_d ); 733 addTag("h3",i18n( "Remote: " ) + text_d );
726 } 734 }
727 } 735 }
728 topLevelWidget()->setCaption(i18n("Journal viewer")); 736 topLevelWidget()->setCaption(i18n("Journal viewer"));
729 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 737 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
730 formatReadOnly(jour); 738 formatReadOnly(jour);
731 addTag("p","<b>"+i18n( "Last modified: " ) + "</b>"+KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 739 addTag("p","<b>"+i18n( "Last modified: " ) + "</b>"+KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
732 740
733 if (!jour->description().isEmpty()) { 741 if (!jour->description().isEmpty()) {
734 addTag("p",deTag(jour->description())); 742 addTag("p",deTag(jour->description()));
735 } 743 }
736 setText(mText); 744 setText(mText);
737} 745}
738 746
739void KOEventViewer::formatReadOnly(Incidence *event) 747void KOEventViewer::formatReadOnly(Incidence *event)
740{ 748{
741 int id = event->calID(); 749 int id = event->calID();
742 if ( id > 1 ) { 750 if ( id > 1 ) {
743 addTag("p", "<em>("+i18n("Calendar:")+" " + KOPrefs::instance()->getCalendar( id )->mName + ")</em>"); 751 addTag("p", "<em>("+i18n("Calendar:")+" " + KOPrefs::instance()->getCalendar( id )->mName + ")</em>");
744 } 752 }
745 if (event->isReadOnly()) { 753 if (event->isReadOnly()) {
746 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 754 addTag("p","<em>(" + i18n("read-only") + ")</em>");
747 } 755 }
748} 756}
749void KOEventViewer::setSyncMode( bool b ) 757void KOEventViewer::setSyncMode( bool b )
750{ 758{
751 mSyncMode = b; 759 mSyncMode = b;
752} 760}
753 761
754void KOEventViewer::setTodo(Todo *event, bool clearV ) 762void KOEventViewer::setTodo(Todo *event, bool clearV )
755{ 763{
756 if ( clearV ) 764 if ( clearV )
757 clearEvents(); 765 clearEvents();
758 if ( mSyncMode ) { 766 if ( mSyncMode ) {
759 if ( clearV ) 767 if ( clearV )
760 appendTodo(event,1 ); 768 appendTodo(event,1 );
761 else 769 else
762 appendTodo(event,2); 770 appendTodo(event,2);
763 } else 771 } else
764 appendTodo(event); 772 appendTodo(event);
765} 773}
766void KOEventViewer::setJournal(Journal *event, bool clearV ) 774void KOEventViewer::setJournal(Journal *event, bool clearV )
767{ 775{
768 if ( clearV ) 776 if ( clearV )
769 clearEvents(); 777 clearEvents();
770 if ( mSyncMode ) { 778 if ( mSyncMode ) {
771 if ( clearV ) 779 if ( clearV )
772 appendJournal(event, 1); 780 appendJournal(event, 1);
773 else 781 else
774 appendJournal(event, 2); 782 appendJournal(event, 2);
775 } else 783 } else
776 appendJournal(event); 784 appendJournal(event);
777} 785}
778 786
779void KOEventViewer::setEvent(Event *event) 787void KOEventViewer::setEvent(Event *event)
780{ 788{
781 clearEvents(); 789 clearEvents();
782 if ( mSyncMode ) 790 if ( mSyncMode )
783 appendEvent(event, 1); 791 appendEvent(event, 1);
784 else 792 else
785 appendEvent(event); 793 appendEvent(event);
786} 794}
787 795
788void KOEventViewer::addEvent(Event *event) 796void KOEventViewer::addEvent(Event *event)
789{ 797{
790 if ( mSyncMode ) 798 if ( mSyncMode )
791 appendEvent(event, 2); 799 appendEvent(event, 2);
792 else 800 else
793 appendEvent(event); 801 appendEvent(event);
794} 802}
795 803
796void KOEventViewer::clearEvents(bool now) 804void KOEventViewer::clearEvents(bool now)
797{ 805{
798 mText = ""; 806 mText = "";
799 if (now) setText(mText); 807 if (now) setText(mText);
800} 808}
801 809
802void KOEventViewer::addText(QString text) 810void KOEventViewer::addText(QString text)
803{ 811{
804 mText.append(text); 812 mText.append(text);
805 setText(mText); 813 setText(mText);
806} 814}
807QString KOEventViewer::deTag(QString text) 815QString KOEventViewer::deTag(QString text)
808{ 816{
809#if QT_VERSION >= 0x030000 817#if QT_VERSION >= 0x030000
810 text.replace( '<' , "&lt;" ); 818 text.replace( '<' , "&lt;" );
811 text.replace( '>' , "&gt;" ); 819 text.replace( '>' , "&gt;" );
812#else 820#else
813 if ( text.find ('<') >= 0 ) { 821 if ( text.find ('<') >= 0 ) {
814 text.replace( QRegExp("<") , "&lt;" ); 822 text.replace( QRegExp("<") , "&lt;" );
815 } 823 }
816 if ( text.find ('>') >= 0 ) { 824 if ( text.find ('>') >= 0 ) {
817 text.replace( QRegExp(">") , "&gt;" ); 825 text.replace( QRegExp(">") , "&gt;" );
818 } 826 }
819#endif 827#endif
820 return text; 828 return text;
821} 829}
822void KOEventViewer::keyPressEvent ( QKeyEvent * e ) 830void KOEventViewer::keyPressEvent ( QKeyEvent * e )
823{ 831{
824 switch ( e->key() ) { 832 switch ( e->key() ) {
825 case Qt::Key_Return: 833 case Qt::Key_Return:
826 case Qt::Key_Enter : 834 case Qt::Key_Enter :
827 e->ignore(); 835 e->ignore();
828 break; 836 break;
829 default: 837 default:
830 QTextBrowser::keyPressEvent ( e ); 838 QTextBrowser::keyPressEvent ( e );
831 break; 839 break;
832 } 840 }
833} 841}
diff --git a/libkcal/person.cpp b/libkcal/person.cpp
index aca28c2..858805d 100644
--- a/libkcal/person.cpp
+++ b/libkcal/person.cpp
@@ -1,77 +1,83 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kdebug.h> 21#include <kdebug.h>
22#include <klocale.h> 22#include <klocale.h>
23 23
24#include "person.h" 24#include "person.h"
25 25
26using namespace KCal; 26using namespace KCal;
27 27
28Person::Person( const QString &fullName ) 28Person::Person( const QString &fullName )
29{ 29{
30 int emailPos = fullName.find( '<' ); 30 int emailPos = fullName.find( '<' );
31 if ( emailPos < 0 ) { 31 if ( emailPos < 0 ) {
32 setEmail(fullName); 32 setEmail(fullName);
33 } else { 33 } else {
34 setEmail(fullName.mid( emailPos + 1, fullName.length() - 1 )); 34 setEmail(fullName.mid( emailPos + 1, fullName.length() - 1 ));
35 setName(fullName.left( emailPos - 2 )); 35 setName(fullName.left( emailPos - 2 ));
36 } 36 }
37} 37}
38 38
39Person::Person( const QString &name, const QString &email ) 39Person::Person( const QString &name, const QString &email )
40{ 40{
41 setName(name); 41 setName(name);
42 setEmail(email); 42 setEmail(email);
43} 43}
44 44
45 45
46bool KCal::operator==( const Person& p1, const Person& p2 ) 46bool KCal::operator==( const Person& p1, const Person& p2 )
47{ 47{
48 return ( p1.name() == p2.name() && 48 return ( p1.name() == p2.name() &&
49 p1.email() == p2.email() ); 49 p1.email() == p2.email() );
50} 50}
51 51
52 52QString Person::realName() const
53{
54 int ccc = mName.find (',');
55 if ( ccc < 0 )
56 return mName;
57 return mName.mid( ccc+1 ).stripWhiteSpace() + " " + mName.left( ccc ).stripWhiteSpace();
58}
53QString Person::fullName() const 59QString Person::fullName() const
54{ 60{
55 if( mName.isEmpty() ) { 61 if( mName.isEmpty() ) {
56 return mEmail; 62 return mEmail;
57 } else { 63 } else {
58 if( mEmail.isEmpty() ) 64 if( mEmail.isEmpty() )
59 return mName; 65 return mName;
60 else 66 else
61 return mName + " <" + mEmail + ">"; 67 return mName + " <" + mEmail + ">";
62 } 68 }
63} 69}
64 70
65void Person::setName(const QString &name) 71void Person::setName(const QString &name)
66{ 72{
67 mName = name; 73 mName = name;
68} 74}
69 75
70void Person::setEmail(const QString &email) 76void Person::setEmail(const QString &email)
71{ 77{
72 if (email.left(7).lower() == "mailto:") { 78 if (email.left(7).lower() == "mailto:") {
73 mEmail = email.mid(7); 79 mEmail = email.mid(7);
74 } else { 80 } else {
75 mEmail = email; 81 mEmail = email;
76 } 82 }
77} 83}
diff --git a/libkcal/person.h b/libkcal/person.h
index c46c5f0..3cec153 100644
--- a/libkcal/person.h
+++ b/libkcal/person.h
@@ -1,50 +1,51 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KCAL_PERSON_H 20#ifndef KCAL_PERSON_H
21#define KCAL_PERSON_H 21#define KCAL_PERSON_H
22 22
23#include <qstring.h> 23#include <qstring.h>
24 24
25namespace KCal { 25namespace KCal {
26 26
27class Person 27class Person
28{ 28{
29 public: 29 public:
30 Person() {} 30 Person() {}
31 Person( const QString &fullName ); 31 Person( const QString &fullName );
32 Person( const QString &name, const QString &email ); 32 Person( const QString &name, const QString &email );
33 33
34 QString fullName( ) const; 34 QString fullName( ) const;
35 35
36 void setName(const QString &); 36 void setName(const QString &);
37 QString name() const { return mName; } 37 QString name() const { return mName; }
38 QString realName() const;
38 39
39 void setEmail(const QString &); 40 void setEmail(const QString &);
40 QString email() const { return mEmail; } 41 QString email() const { return mEmail; }
41 42
42 private: 43 private:
43 QString mName; 44 QString mName;
44 QString mEmail; 45 QString mEmail;
45}; 46};
46 47
47 bool operator==( const Person& p1, const Person& p2 ); 48 bool operator==( const Person& p1, const Person& p2 );
48} 49}
49 50
50#endif 51#endif
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 2ce6926..edefda4 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -1,233 +1,234 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30#include <stdlib.h> 30#include <stdlib.h>
31 31
32#include <qfile.h> 32#include <qfile.h>
33#include <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#endif 43#endif
43 44
44#include <kstaticdeleter.h> 45#include <kstaticdeleter.h>
45#include <kmessagebox.h> 46#include <kmessagebox.h>
46 47
47 48
48#include "externalapphandler.h" 49#include "externalapphandler.h"
49 50
50#include "kpimglobalprefs.h" 51#include "kpimglobalprefs.h"
51 52
52//uncomment line to get debug output 53//uncomment line to get debug output
53//#define DEBUG_EXT_APP_HANDLER 54//#define DEBUG_EXT_APP_HANDLER
54 55
55/********************************************************************************* 56/*********************************************************************************
56 * 57 *
57 ********************************************************************************/ 58 ********************************************************************************/
58 59
59 60
60QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 61QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
61 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) 62 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
62{ 63{
63 //sourceMessage passes later three parameters: sourceChannel, uid, param1 64 //sourceMessage passes later three parameters: sourceChannel, uid, param1
64 if (_usedSourceParameters == 0) 65 if (_usedSourceParameters == 0)
65 _sourceMessageParameters = "QString,QString)"; 66 _sourceMessageParameters = "QString,QString)";
66 else if (_usedSourceParameters == 1) 67 else if (_usedSourceParameters == 1)
67 _sourceMessageParameters = "(QString,QString,QString)"; 68 _sourceMessageParameters = "(QString,QString,QString)";
68 else if (_usedSourceParameters == 2) 69 else if (_usedSourceParameters == 2)
69 _sourceMessageParameters = "(QString,QString,QString,QString)"; 70 _sourceMessageParameters = "(QString,QString,QString,QString)";
70 else if (_usedSourceParameters == 3) 71 else if (_usedSourceParameters == 3)
71 _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; 72 _sourceMessageParameters = "(QString,QString,QString,QString,QString)";
72} 73}
73 74
74/*********************************************************************************/ 75/*********************************************************************************/
75 76
76QCopTransferItem::QCopTransferItem() 77QCopTransferItem::QCopTransferItem()
77{ 78{
78} 79}
79 80
80/*********************************************************************************/ 81/*********************************************************************************/
81bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) 82bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3)
82{ 83{
83 84
84#ifndef DESKTOP_VERSION 85#ifndef DESKTOP_VERSION
85 //sourceMessage passes two parameters: sourceChannel, uid 86 //sourceMessage passes two parameters: sourceChannel, uid
86 QString sourceMessage = _sourceMessage + _sourceMessageParameters; 87 QString sourceMessage = _sourceMessage + _sourceMessageParameters;
87#ifdef DEBUG_EXT_APP_HANDLER 88#ifdef DEBUG_EXT_APP_HANDLER
88 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); 89 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1());
89 qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); 90 qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1());
90#endif 91#endif
91 92
92 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); 93 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
93 94
94 e << _sourceChannel << uid; 95 e << _sourceChannel << uid;
95 96
96 if (_usedSourceParameters == 1) 97 if (_usedSourceParameters == 1)
97 e << param1; 98 e << param1;
98 else if (_usedSourceParameters == 2) 99 else if (_usedSourceParameters == 2)
99 e << param1 << param2; 100 e << param1 << param2;
100 else if (_usedSourceParameters == 3) 101 else if (_usedSourceParameters == 3)
101 e << param1 << param2 << param3; 102 e << param1 << param2 << param3;
102 103
103 qApp->processEvents(); 104 qApp->processEvents();
104 105
105 return true; 106 return true;
106 107
107#else 108#else
108 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 109 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
109 return false; 110 return false;
110#endif 111#endif
111 112
112} 113}
113 114
114 115
115/*********************************************************************************/ 116/*********************************************************************************/
116void QCopTransferItem::setSourceChannel(const QString& sourceChannel) 117void QCopTransferItem::setSourceChannel(const QString& sourceChannel)
117{ 118{
118 119
119 if ( !sourceChannel.isEmpty()) 120 if ( !sourceChannel.isEmpty())
120 _sourceChannel = sourceChannel; 121 _sourceChannel = sourceChannel;
121} 122}
122 123
123 124
124/*********************************************************************************/ 125/*********************************************************************************/
125bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 126bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
126{ 127{
127 128
128 // copied from old mail2 129 // copied from old mail2
129/* 130/*
130 static int ii = 0; 131 static int ii = 0;
131 132
132 // block second call 133 // block second call
133 if ( ii < 2 ) { 134 if ( ii < 2 ) {
134 ++ii; 135 ++ii;
135 if ( ii > 1 ) { 136 if ( ii > 1 ) {
136 qDebug("qcop call blocked "); 137 qDebug("qcop call blocked ");
137 return true; 138 return true;
138 } 139 }
139 } 140 }
140*/ 141*/
141 142
142// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); 143// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
143 144
144 //we are in the target and get a request from the source 145 //we are in the target and get a request from the source
145 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) 146 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
146 { 147 {
147 148
148 QDataStream stream( data, IO_ReadOnly ); 149 QDataStream stream( data, IO_ReadOnly );
149 150
150 151
151 QString sourceChannel; 152 QString sourceChannel;
152 QString uid; 153 QString uid;
153 QString param1; 154 QString param1;
154 QString param2; 155 QString param2;
155 QString param3; 156 QString param3;
156 157
157 stream >> sourceChannel >> uid; 158 stream >> sourceChannel >> uid;
158 159
159 if (_usedSourceParameters == 0) 160 if (_usedSourceParameters == 0)
160 { 161 {
161 emit receivedMessageFromSource(sourceChannel, uid); 162 emit receivedMessageFromSource(sourceChannel, uid);
162 } 163 }
163 else if (_usedSourceParameters == 1) 164 else if (_usedSourceParameters == 1)
164 { 165 {
165 stream >> param1; 166 stream >> param1;
166 emit receivedMessageFromSource(sourceChannel, uid, param1); 167 emit receivedMessageFromSource(sourceChannel, uid, param1);
167 } 168 }
168 else if (_usedSourceParameters == 2) 169 else if (_usedSourceParameters == 2)
169 { 170 {
170 stream >> param1 >> param2; 171 stream >> param1 >> param2;
171 emit receivedMessageFromSource(sourceChannel, uid, param1, param2); 172 emit receivedMessageFromSource(sourceChannel, uid, param1, param2);
172 } 173 }
173 else if (_usedSourceParameters == 3) 174 else if (_usedSourceParameters == 3)
174 { 175 {
175 stream >> param1 >> param2 >> param3; 176 stream >> param1 >> param2 >> param3;
176 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); 177 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3);
177 } 178 }
178 179
179 return true; 180 return true;
180 } 181 }
181 182
182 return false; 183 return false;
183} 184}
184 185
185 186
186/********************************************************************************* 187/*********************************************************************************
187 * 188 *
188 ********************************************************************************/ 189 ********************************************************************************/
189 190
190 191
191QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 192QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
192 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 193 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
193{ 194{
194 //targetMessage returns later two parameters: uid, and map<qstring,qstring> 195 //targetMessage returns later two parameters: uid, and map<qstring,qstring>
195 _targetMessageParameters = "(QString,QMAP<QString,QString>)"; 196 _targetMessageParameters = "(QString,QMAP<QString,QString>)";
196} 197}
197 198
198/*********************************************************************************/ 199/*********************************************************************************/
199bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) 200bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap)
200{ 201{
201#ifndef DESKTOP_VERSION 202#ifndef DESKTOP_VERSION
202 //targetMessage passes two parameters: uid, map 203 //targetMessage passes two parameters: uid, map
203 QString targetMessage = _targetMessage + _targetMessageParameters; 204 QString targetMessage = _targetMessage + _targetMessageParameters;
204 205
205#ifdef DEBUG_EXT_APP_HANDLER 206#ifdef DEBUG_EXT_APP_HANDLER
206 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 207 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
207 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); 208 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
208#endif 209#endif
209 210
210 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 211 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
211 //US we need no names in the To field. The emailadresses are enough 212 //US we need no names in the To field. The emailadresses are enough
212 213
213 e << uid << nameEmailMap; 214 e << uid << nameEmailMap;
214 215
215 qApp->processEvents(); 216 qApp->processEvents();
216 217
217 return true; 218 return true;
218 219
219#else 220#else
220 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 221 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
221 return false; 222 return false;
222#endif 223#endif
223 224
224} 225}
225 226
226 227
227/*********************************************************************************/ 228/*********************************************************************************/
228bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 229bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
229{ 230{
230 bool res = QCopTransferItem::appMessage( cmsg, data ); 231 bool res = QCopTransferItem::appMessage( cmsg, data );
231 232
232 if (res == false) 233 if (res == false)
233 { 234 {
@@ -245,699 +246,781 @@ bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& da
245 246
246 emit receivedMessageFromTarget(uid, adrMap); 247 emit receivedMessageFromTarget(uid, adrMap);
247 248
248 249
249 return true; 250 return true;
250 } 251 }
251 } 252 }
252 253
253 return false; 254 return false;
254} 255}
255 256
256 257
257/********************************************************************************* 258/*********************************************************************************
258 * 259 *
259 ********************************************************************************/ 260 ********************************************************************************/
260 261
261QCopListTransferItem::~QCopListTransferItem() 262QCopListTransferItem::~QCopListTransferItem()
262{ 263{
263 264
264} 265}
265 266
266QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 267QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
267 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 268 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
268{ 269{
269 //targetMessage returns later two parameters: uid, and three lists 270 //targetMessage returns later two parameters: uid, and three lists
270 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; 271 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)";
271} 272}
272 273
273/*********************************************************************************/ 274/*********************************************************************************/
274bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) 275bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6)
275{ 276{
276#ifndef DESKTOP_VERSION 277#ifndef DESKTOP_VERSION
277 //targetMessage passes two parameters: uid, map 278 //targetMessage passes two parameters: uid, map
278 QString targetMessage = _targetMessage + _targetMessageParameters; 279 QString targetMessage = _targetMessage + _targetMessageParameters;
279 280
280#ifdef DEBUG_EXT_APP_HANDLER 281#ifdef DEBUG_EXT_APP_HANDLER
281 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 282 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
282 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); 283 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1());
283 284
284 285
285 for ( int i = 0; i < list3.count(); i++) 286 for ( int i = 0; i < list3.count(); i++)
286 qDebug("listentry list3: %s",list3[i].latin1()); 287 qDebug("listentry list3: %s",list3[i].latin1());
287#endif 288#endif
288 289
289 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 290 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
290 //US we need no names in the To field. The emailadresses are enough 291 //US we need no names in the To field. The emailadresses are enough
291 292
292 e << uid << list1 << list2 << list3 << list4 << list5 << list6; 293 e << uid << list1 << list2 << list3 << list4 << list5 << list6;
293 294
294 qApp->processEvents(); 295 qApp->processEvents();
295 296
296 return true; 297 return true;
297 298
298#else 299#else
299 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 300 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
300 return false; 301 return false;
301#endif 302#endif
302 303
303} 304}
304 305
305 306
306/*********************************************************************************/ 307/*********************************************************************************/
307bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 308bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
308{ 309{
309 bool res = QCopTransferItem::appMessage( cmsg, data ); 310 bool res = QCopTransferItem::appMessage( cmsg, data );
310#ifdef DEBUG_EXT_APP_HANDLER 311#ifdef DEBUG_EXT_APP_HANDLER
311 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 312 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
312#endif 313#endif
313 314
314 if (res == false) 315 if (res == false)
315 { 316 {
316 QDataStream stream( data, IO_ReadOnly ); 317 QDataStream stream( data, IO_ReadOnly );
317 318
318#ifdef DEBUG_EXT_APP_HANDLER 319#ifdef DEBUG_EXT_APP_HANDLER
319 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 320 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
320#endif 321#endif
321 322
322 //we are in the source and get an answer from the target 323 //we are in the source and get an answer from the target
323 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 324 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
324 { 325 {
325 QStringList list1; 326 QStringList list1;
326 QStringList list2; 327 QStringList list2;
327 QStringList list3; 328 QStringList list3;
328 QStringList list4; 329 QStringList list4;
329 QStringList list5; 330 QStringList list5;
330 QStringList list6; 331 QStringList list6;
331 QString uid; 332 QString uid;
332 333
333#ifdef DEBUG_EXT_APP_HANDLER 334#ifdef DEBUG_EXT_APP_HANDLER
334 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 335 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
335#endif 336#endif
336 337
337 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; 338 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6;
338 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); 339 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6);
339 340
340 341
341 return true; 342 return true;
342 } 343 }
343 } 344 }
344 345
345 return false; 346 return false;
346} 347}
347 348
348 349
349 350
350/********************************************************************************* 351/*********************************************************************************
351 * 352 *
352 ********************************************************************************/ 353 ********************************************************************************/
353 354
354 355
355ExternalAppHandler *ExternalAppHandler::sInstance = 0; 356ExternalAppHandler *ExternalAppHandler::sInstance = 0;
356static KStaticDeleter<ExternalAppHandler> staticDeleter; 357static KStaticDeleter<ExternalAppHandler> staticDeleter;
357 358
358ExternalAppHandler::ExternalAppHandler() 359ExternalAppHandler::ExternalAppHandler()
359{ 360{
360 mDefaultItems.setAutoDelete(true); 361 mDefaultItems.setAutoDelete(true);
361 362
362 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); 363 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
363 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); 364 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&)));
364 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 365 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
365 366
366//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); 367//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
367//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); 368//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
368//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 369//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
369 370
370 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); 371 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
371 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&))); 372 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&)));
372 373
373 374
374 375
375 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); 376 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList");
376 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); 377 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&)));
377 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 378 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
378 379
379 380
380} 381}
381 382
382ExternalAppHandler::~ExternalAppHandler() 383ExternalAppHandler::~ExternalAppHandler()
383{ 384{
384 delete mNameEmailUidListFromKAPITransfer; 385 delete mNameEmailUidListFromKAPITransfer;
385 //delete mFindByEmailFromKAPITransfer; 386 //delete mFindByEmailFromKAPITransfer;
386 delete mDisplayDetails; 387 delete mDisplayDetails;
387 delete mBirthdayListFromKAPITransfer; 388 delete mBirthdayListFromKAPITransfer;
388} 389}
389 390
390void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, 391void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid,
391 const QStringList& nameList, 392 const QStringList& nameList,
392 const QStringList& emailList, 393 const QStringList& emailList,
393 const QStringList& uidList, 394 const QStringList& uidList,
394 const QStringList&, 395 const QStringList&,
395 const QStringList&, 396 const QStringList&,
396 const QStringList& ) 397 const QStringList& )
397{ 398{
398 // this method is a conevnient way to reduce the number of parameters I have to pass 399 // this method is a conevnient way to reduce the number of parameters I have to pass
399 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); 400 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList);
400} 401}
401 402
402 403
403void ExternalAppHandler::loadConfig() 404void ExternalAppHandler::loadConfig()
404{ 405{
405 406
406 mDefaultItems.clear(); 407 mDefaultItems.clear();
407 mEmailAppAvailable = UNDEFINED; 408 mEmailAppAvailable = UNDEFINED;
408 mPhoneAppAvailable = UNDEFINED; 409 mPhoneAppAvailable = UNDEFINED;
409 mFaxAppAvailable = UNDEFINED; 410 mFaxAppAvailable = UNDEFINED;
410 mSMSAppAvailable = UNDEFINED; 411 mSMSAppAvailable = UNDEFINED;
411 mPagerAppAvailable = UNDEFINED; 412 mPagerAppAvailable = UNDEFINED;
412 mSIPAppAvailable = UNDEFINED; 413 mSIPAppAvailable = UNDEFINED;
413 414
414 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 415 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
415 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 416 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
416 QString qtpath = QString::fromLatin1( getenv("QTDIR") ); 417 QString qtpath = QString::fromLatin1( getenv("QTDIR") );
417 418
418 //if qtopiapath is not set, fallback to qt 419 //if qtopiapath is not set, fallback to qt
419 if (qtopiapath.isEmpty()) 420 if (qtopiapath.isEmpty())
420 qtopiapath = qtpath; 421 qtopiapath = qtpath;
421 422
422 //if opiepath is not set, fallback to qtopia 423 //if opiepath is not set, fallback to qtopia
423 if (opiepath.isEmpty()) 424 if (opiepath.isEmpty())
424 opiepath = qtopiapath; 425 opiepath = qtopiapath;
425 426
426 427
427 428
428 //mailclients 429 //mailclients
429 QString mailmsg1 = "writeMail(QString,QString)"; 430 QString mailmsg1 = "writeMail(QString,QString)";
430 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 431 QString mailmsg2 = "writeMail(QMap(QString,QString))";
431 432
432 QString undefined = ""; 433 QString undefined = "";
433 434
434 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 435 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
435 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 436 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
436 437
438#ifdef DESKTOP_VERSION
439 QString appPath;
440#ifdef _WIN32_
441 appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe";
442#else
443 appPath = "/usr/bin/thunderbird";
444#endif
445 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1");
446
447#ifdef _WIN32_
448 appPath = "C:\\Programme\\Mozilla\\mozilla.exe";
449#else
450 appPath = "/usr/bin/mozilla";
451#endif
452 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1");
453
454
455
456#else
437 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 457 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
438 ( QFile::exists( opiepath + "/bin/ompi" )) || 458 ( QFile::exists( opiepath + "/bin/ompi" )) ||
439 ( QFile::exists( qtpath + "/bin/ompi" ))) 459 ( QFile::exists( qtpath + "/bin/ompi" )))
440 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 460 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
441 461
442 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || 462 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) ||
443 ( QFile::exists( qtpath + "/bin/qtmail" ))) 463 ( QFile::exists( qtpath + "/bin/qtmail" )))
444 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 464 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
445 465
446 if ( QFile::exists( opiepath + "/bin/opiemail" )) 466 if ( QFile::exists( opiepath + "/bin/opiemail" ))
447 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 467 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
448 468
449 if ( QFile::exists( opiepath + "/bin/mailit" )) 469 if ( QFile::exists( opiepath + "/bin/mailit" ))
450 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 470 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
451 471#endif
452 472
453 473
454 //phoneclients 474 //phoneclients
455 475
456 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 476 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
457 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 477 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
458 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 478 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
459 ( QFile::exists( opiepath + "/bin/kppi" ))) 479 ( QFile::exists( opiepath + "/bin/kppi" )))
460 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 480 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
461 481
462 //faxclients 482 //faxclients
463 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 483 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
464 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 484 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
465 485
466 //smsclients 486 //smsclients
467 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 487 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
468 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 488 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
469 489
470 //pagerclients 490 //pagerclients
471 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 491 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
472 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 492 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
473 493
474 //sipclients 494 //sipclients
475 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); 495 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined);
476 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); 496 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined);
477 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 497 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
478 ( QFile::exists( opiepath + "/bin/kppi" ))) 498 ( QFile::exists( opiepath + "/bin/kppi" )))
479 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 499 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
480 500
481} 501}
482 502
483ExternalAppHandler *ExternalAppHandler::instance() 503ExternalAppHandler *ExternalAppHandler::instance()
484{ 504{
485 if ( !sInstance ) { 505 if ( !sInstance ) {
486 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 506 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
487 sInstance->loadConfig(); 507 sInstance->loadConfig();
488 } 508 }
489 509
490 return sInstance; 510 return sInstance;
491} 511}
492 512
493void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 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)
494{ 514{
495 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 515 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
496 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); 516 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
497 mDefaultItems.append(dai); 517 mDefaultItems.append(dai);
498} 518}
499 519
500 520
501QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 521QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
502{ 522{
503 QList<DefaultAppItem> list; 523 QList<DefaultAppItem> list;
504 524
505 DefaultAppItem* dai; 525 DefaultAppItem* dai;
506 526
507 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 527 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
508 { 528 {
509 if (dai->_type == type) 529 if (dai->_type == type)
510 list.append(dai); 530 list.append(dai);
511 } 531 }
512 532
513 return list; 533 return list;
514} 534}
515 535
516DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 536DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
517{ 537{
518 DefaultAppItem* dai; 538 DefaultAppItem* dai;
519 539
520 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 540 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
521 { 541 {
522 if (dai->_type == type && dai->_id == clientid) 542 if (dai->_type == type && dai->_id == clientid)
523 return dai; 543 return dai;
524 } 544 }
525 545
526 return 0; 546 return 0;
527} 547}
528 548
529bool ExternalAppHandler::isEmailAppAvailable() 549bool ExternalAppHandler::isEmailAppAvailable()
530{ 550{
531#ifndef DESKTOP_VERSION 551
532 if (mEmailAppAvailable == UNDEFINED) 552 if (mEmailAppAvailable == UNDEFINED)
533 { 553 {
534 int client = KPimGlobalPrefs::instance()->mEmailClient; 554 int client = KPimGlobalPrefs::instance()->mEmailClient;
535 if (client == KPimGlobalPrefs::NONE_EMC) 555 if (client == KPimGlobalPrefs::NONE_EMC)
536 mEmailAppAvailable = UNAVAILABLE; 556 mEmailAppAvailable = UNAVAILABLE;
537 else 557 else
538 mEmailAppAvailable = AVAILABLE; 558 mEmailAppAvailable = AVAILABLE;
539 } 559 }
540 return (mEmailAppAvailable == AVAILABLE); 560 return (mEmailAppAvailable == AVAILABLE);
541 561
542#else //DESKTOP_VERSION
543 return false;
544#endif //DESKTOP_VERSION
545} 562}
546 563
547bool ExternalAppHandler::isSMSAppAvailable() 564bool ExternalAppHandler::isSMSAppAvailable()
548{ 565{
549#ifndef DESKTOP_VERSION 566#ifndef DESKTOP_VERSION
550 if (mSMSAppAvailable == UNDEFINED) 567 if (mSMSAppAvailable == UNDEFINED)
551 { 568 {
552 int client = KPimGlobalPrefs::instance()->mSMSClient; 569 int client = KPimGlobalPrefs::instance()->mSMSClient;
553 if (client == KPimGlobalPrefs::NONE_SMC) 570 if (client == KPimGlobalPrefs::NONE_SMC)
554 mSMSAppAvailable = UNAVAILABLE; 571 mSMSAppAvailable = UNAVAILABLE;
555 else 572 else
556 mSMSAppAvailable = AVAILABLE; 573 mSMSAppAvailable = AVAILABLE;
557 } 574 }
558 575
559 return (mSMSAppAvailable == AVAILABLE); 576 return (mSMSAppAvailable == AVAILABLE);
560#else //DESKTOP_VERSION 577#else //DESKTOP_VERSION
561 return false; 578 return false;
562#endif //DESKTOP_VERSION 579#endif //DESKTOP_VERSION
563} 580}
564 581
565bool ExternalAppHandler::isPhoneAppAvailable() 582bool ExternalAppHandler::isPhoneAppAvailable()
566{ 583{
567#ifndef DESKTOP_VERSION 584#ifndef DESKTOP_VERSION
568 if (mPhoneAppAvailable == UNDEFINED) 585 if (mPhoneAppAvailable == UNDEFINED)
569 { 586 {
570 int client = KPimGlobalPrefs::instance()->mPhoneClient; 587 int client = KPimGlobalPrefs::instance()->mPhoneClient;
571 if (client == KPimGlobalPrefs::NONE_PHC) 588 if (client == KPimGlobalPrefs::NONE_PHC)
572 mPhoneAppAvailable = UNAVAILABLE; 589 mPhoneAppAvailable = UNAVAILABLE;
573 else 590 else
574 mPhoneAppAvailable = AVAILABLE; 591 mPhoneAppAvailable = AVAILABLE;
575 } 592 }
576 593
577 return (mPhoneAppAvailable == AVAILABLE); 594 return (mPhoneAppAvailable == AVAILABLE);
578#else //DESKTOP_VERSION 595#else //DESKTOP_VERSION
579 return false; 596 return false;
580#endif //DESKTOP_VERSION 597#endif //DESKTOP_VERSION
581} 598}
582 599
583bool ExternalAppHandler::isFaxAppAvailable() 600bool ExternalAppHandler::isFaxAppAvailable()
584{ 601{
585#ifndef DESKTOP_VERSION 602#ifndef DESKTOP_VERSION
586 if (mFaxAppAvailable == UNDEFINED) 603 if (mFaxAppAvailable == UNDEFINED)
587 { 604 {
588 int client = KPimGlobalPrefs::instance()->mFaxClient; 605 int client = KPimGlobalPrefs::instance()->mFaxClient;
589 if (client == KPimGlobalPrefs::NONE_FAC) 606 if (client == KPimGlobalPrefs::NONE_FAC)
590 mFaxAppAvailable = UNAVAILABLE; 607 mFaxAppAvailable = UNAVAILABLE;
591 else 608 else
592 mFaxAppAvailable = AVAILABLE; 609 mFaxAppAvailable = AVAILABLE;
593 } 610 }
594 611
595 return (mFaxAppAvailable == AVAILABLE); 612 return (mFaxAppAvailable == AVAILABLE);
596#else //DESKTOP_VERSION 613#else //DESKTOP_VERSION
597 return false; 614 return false;
598#endif //DESKTOP_VERSION 615#endif //DESKTOP_VERSION
599} 616}
600 617
601bool ExternalAppHandler::isPagerAppAvailable() 618bool ExternalAppHandler::isPagerAppAvailable()
602{ 619{
603#ifndef DESKTOP_VERSION 620#ifndef DESKTOP_VERSION
604 if (mPagerAppAvailable == UNDEFINED) 621 if (mPagerAppAvailable == UNDEFINED)
605 { 622 {
606 int client = KPimGlobalPrefs::instance()->mPagerClient; 623 int client = KPimGlobalPrefs::instance()->mPagerClient;
607 if (client == KPimGlobalPrefs::NONE_PAC) 624 if (client == KPimGlobalPrefs::NONE_PAC)
608 mPagerAppAvailable = UNAVAILABLE; 625 mPagerAppAvailable = UNAVAILABLE;
609 else 626 else
610 mPagerAppAvailable = AVAILABLE; 627 mPagerAppAvailable = AVAILABLE;
611 } 628 }
612 629
613 return (mPagerAppAvailable == AVAILABLE); 630 return (mPagerAppAvailable == AVAILABLE);
614#else //DESKTOP_VERSION 631#else //DESKTOP_VERSION
615 return false; 632 return false;
616#endif //DESKTOP_VERSION 633#endif //DESKTOP_VERSION
617} 634}
618 635
619 636
620bool ExternalAppHandler::isSIPAppAvailable() 637bool ExternalAppHandler::isSIPAppAvailable()
621{ 638{
622#ifndef DESKTOP_VERSION 639#ifndef DESKTOP_VERSION
623 if (mSIPAppAvailable == UNDEFINED) 640 if (mSIPAppAvailable == UNDEFINED)
624 { 641 {
625 int client = KPimGlobalPrefs::instance()->mSipClient; 642 int client = KPimGlobalPrefs::instance()->mSipClient;
626 if (client == KPimGlobalPrefs::NONE_SIC) 643 if (client == KPimGlobalPrefs::NONE_SIC)
627 mSIPAppAvailable = UNAVAILABLE; 644 mSIPAppAvailable = UNAVAILABLE;
628 else 645 else
629 mSIPAppAvailable = AVAILABLE; 646 mSIPAppAvailable = AVAILABLE;
630 } 647 }
631 648
632 return (mSIPAppAvailable == AVAILABLE); 649 return (mSIPAppAvailable == AVAILABLE);
633#else //DESKTOP_VERSION 650#else //DESKTOP_VERSION
634 return false; 651 return false;
635#endif //DESKTOP_VERSION 652#endif //DESKTOP_VERSION
636} 653}
637 654
638/************************************************************************** 655/**************************************************************************
639 * 656 *
640 **************************************************************************/ 657 **************************************************************************/
641 658
642 659
643//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 660//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
644bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 661bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
645{ 662{
646 663
647#ifndef DESKTOP_VERSION 664#ifndef DESKTOP_VERSION
648 QString channel; 665 QString channel;
649 QString message2; 666 QString message2;
650 QString parameters2; 667 QString parameters2;
651 668
652 669
653 int client = KPimGlobalPrefs::instance()->mEmailClient; 670 int client = KPimGlobalPrefs::instance()->mEmailClient;
654 if (client == KPimGlobalPrefs::OTHER_EMC) 671 if (client == KPimGlobalPrefs::OTHER_EMC)
655 { 672 {
656 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 673 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
657 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 674 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
658 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 675 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
659 } 676 }
660 else 677 else
661 { 678 {
662 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 679 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
663 if (!dai) 680 if (!dai)
664 { 681 {
665 qDebug("could not find configured email application."); 682 qDebug("could not find configured email application.");
666 return false; 683 return false;
667 } 684 }
668 channel = dai->_channel; 685 channel = dai->_channel;
669 message2 = dai->_message2; 686 message2 = dai->_message2;
670 parameters2 = dai->_parameters2; 687 parameters2 = dai->_parameters2;
671 } 688 }
672 689
673 //first check if one of the mailers need the emails right in the message. 690 //first check if one of the mailers need the emails right in the message.
674 message2 = translateMessage(message2, emails, urls); 691 message2 = translateMessage(message2, emails, urls);
675 692
676 693
677#ifdef DEBUG_EXT_APP_HANDLER 694#ifdef DEBUG_EXT_APP_HANDLER
678 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 695 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
679 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 696 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
680#endif 697#endif
681 698
682 699
683 QCopEnvelope e(channel.latin1(), message2.latin1()); 700 QCopEnvelope e(channel.latin1(), message2.latin1());
684 //US we need no names in the To field. The emailadresses are enough 701 //US we need no names in the To field. The emailadresses are enough
685 702
686 passParameters(&e, parameters2, emails, urls); 703 passParameters(&e, parameters2, emails, urls);
687 704
688 705
689 706
690#else 707#else
691 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 708 //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1());
709
710 QString channel;
711 QString message2;
712 QString parameters2;
713 QString message;
714 QString parameters;
715
716
717 int client = KPimGlobalPrefs::instance()->mEmailClient;
718 if (client == KPimGlobalPrefs::OTHER_EMC)
719 {
720 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
721 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
722 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
723 }
724 else
725 {
726 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
727 if (!dai)
728 {
729 qDebug("could not find configured email application.");
730 return false;
731 }
732 channel = dai->_channel;
733 message2 = dai->_message2;
734 parameters2 = dai->_parameters2;
735 message = dai->_message;
736 parameters = dai->_parameters;
737 }
738
739 //first check if one of the mailers need the emails right in the message.
740 message2 = translateMessage(message2, emails, urls);
741#ifdef DEBUG_EXT_APP_HANDLER
742 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
743 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
744#endif
745 qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() );
746 //KMessageBox::sorry( 0, message2 );
747 QProcess * proc = new QProcess( this );
748 QStringList list = QStringList::split( " ", message );
749 int i = 0;
750 proc->addArgument( channel );
751 while ( i < list.count ( ) ) {
752 //qDebug("add%sdd ",list[i].stripWhiteSpace().latin1() );
753 proc->addArgument( list[i].stripWhiteSpace() );
754 ++i;
755 }
756 parameters2 = translateMessage(parameters2, urls, "" );
757 QString arg = "to='%1'";
758 arg = arg.arg( emails ) + ","+parameters2;;
759
760 //qDebug("2add%sdd ",arg.latin1() );
761 proc->addArgument( arg);
762 proc->launch("");
692#endif 763#endif
693 764
694 return true; 765 return true;
695} 766}
696 767
697/************************************************************************** 768/**************************************************************************
698 * 769 *
699 **************************************************************************/ 770 **************************************************************************/
700 771
701 772
702//calls the emailapplication and creates a mail with parameter emails as recipients 773//calls the emailapplication and creates a mail with parameter emails as recipients
703bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 774bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
704{ 775{
705#ifndef DESKTOP_VERSION 776
706 QString channel; 777 QString channel;
707 QString message; 778 QString message;
708 QString parameters; 779 QString parameters;
709 780
710 781
711 int client = KPimGlobalPrefs::instance()->mEmailClient; 782 int client = KPimGlobalPrefs::instance()->mEmailClient;
712 if (client == KPimGlobalPrefs::OTHER_EMC) 783 if (client == KPimGlobalPrefs::OTHER_EMC)
713 { 784 {
714 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 785 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
715 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 786 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
716 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 787 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
717 } 788 }
718 else 789 else
719 { 790 {
720 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 791 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
721 if (!dai) 792 if (!dai)
722 { 793 {
723 qDebug("could not find configured email application."); 794 qDebug("could not find configured email application.");
724 return false; 795 return false;
725 } 796 }
726 channel = dai->_channel; 797 channel = dai->_channel;
727 message = dai->_message; 798 message = dai->_message;
728 parameters = dai->_parameters; 799 parameters = dai->_parameters;
729 } 800 }
730 801
731 802#ifdef DESKTOP_VERSION
803 //message = channel + " " +message + " \""+ parameters + "\"";
804#endif
732 //first check if one of the mailers need the emails right in the message. 805 //first check if one of the mailers need the emails right in the message.
733 message = translateMessage(message, name, emailadress); 806 message = translateMessage(message, name, emailadress);
734 807
735
736#ifdef DEBUG_EXT_APP_HANDLER 808#ifdef DEBUG_EXT_APP_HANDLER
737 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 809 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
738 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); 810 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
739#endif 811#endif
740 812
813#ifndef DESKTOP_VERSION
741 QCopEnvelope e(channel.latin1(), message.latin1()); 814 QCopEnvelope e(channel.latin1(), message.latin1());
742 //US we need no names in the To field. The emailadresses are enough 815 //US we need no names in the To field. The emailadresses are enough
743 816
744 passParameters(&e, parameters, name, emailadress); 817 passParameters(&e, parameters, name, emailadress);
745 818#else // DESKTOP_VERSION
746 819
747#else 820 //KMessageBox::sorry( 0, message );
748 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 821 QProcess * proc = new QProcess( this );
822 QStringList list = QStringList::split( " ", message );
823 int i = 0;
824 proc->addArgument( channel );
825 while ( i < list.count ( ) ) {
826 //qDebug("add%sdd ",list[i].latin1() );
827 proc->addArgument( list[i] );
828 ++i;
829 }
830 parameters = translateMessage(parameters, name, emailadress);
831 proc->addArgument( parameters );
832 proc->launch("");
749#endif 833#endif
750 834
751
752 return true; 835 return true;
753} 836}
754 837
755/************************************************************************** 838/**************************************************************************
756 * 839 *
757 **************************************************************************/ 840 **************************************************************************/
758 841
759//calls the emailapplication and creates a mail with parameter as recipients 842//calls the emailapplication and creates a mail with parameter as recipients
760// parameters format is 843// parameters format is
761// NAME <EMAIL>:SUBJECT 844// NAME <EMAIL>:SUBJECT
762bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 845bool ExternalAppHandler::mailToOneContact( const QString& adressline )
763{ 846{
764 QString line = adressline; 847 QString line = adressline;
765 848
766 int first = line.find( "<"); 849 int first = line.find( "<");
767 int last = line.find( ">"); 850 int last = line.find( ">");
768 QString name = line.left(first); 851 QString name = line.left(first);
769 QString emailadress = line.mid(first+1, last-first-1); 852 QString emailadress = line.mid(first+1, last-first-1);
770 853
771 //Subject can not be handled right now. 854 //Subject can not be handled right now.
772 return mailToOneContact( name, emailadress ); 855 return mailToOneContact( name, emailadress );
773 856
774} 857}
775 858
776 859
777/************************************************************************** 860/**************************************************************************
778 * 861 *
779 **************************************************************************/ 862 **************************************************************************/
780 863
781//calls the phoneapplication with the number 864//calls the phoneapplication with the number
782bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 865bool ExternalAppHandler::callByPhone( const QString& phonenumber )
783{ 866{
784#ifndef DESKTOP_VERSION 867#ifndef DESKTOP_VERSION
785 QString channel; 868 QString channel;
786 QString message; 869 QString message;
787 QString parameters; 870 QString parameters;
788 871
789 872
790 int client = KPimGlobalPrefs::instance()->mPhoneClient; 873 int client = KPimGlobalPrefs::instance()->mPhoneClient;
791 if (client == KPimGlobalPrefs::OTHER_PHC) 874 if (client == KPimGlobalPrefs::OTHER_PHC)
792 { 875 {
793 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 876 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
794 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 877 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
795 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 878 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
796 } 879 }
797 else 880 else
798 { 881 {
799 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 882 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
800 if (!dai) 883 if (!dai)
801 { 884 {
802 qDebug("could not find configured phone application."); 885 qDebug("could not find configured phone application.");
803 return false; 886 return false;
804 } 887 }
805 channel = dai->_channel; 888 channel = dai->_channel;
806 message = dai->_message; 889 message = dai->_message;
807 parameters = dai->_parameters; 890 parameters = dai->_parameters;
808 } 891 }
809 892
810 893
811 //first check if one of the mailers need the emails right in the message. 894 //first check if one of the mailers need the emails right in the message.
812 message = translateMessage(message, phonenumber, ""); 895 message = translateMessage(message, phonenumber, "");
813 896
814 897
815#ifdef DEBUG_EXT_APP_HANDLER 898#ifdef DEBUG_EXT_APP_HANDLER
816 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 899 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
817 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 900 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
818#endif 901#endif
819 902
820 QCopEnvelope e(channel.latin1(), message.latin1()); 903 QCopEnvelope e(channel.latin1(), message.latin1());
821 //US we need no names in the To field. The emailadresses are enough 904 //US we need no names in the To field. The emailadresses are enough
822 905
823 passParameters(&e, parameters, phonenumber, ""); 906 passParameters(&e, parameters, phonenumber, "");
824 907
825 908
826#else 909#else
827 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 910 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
828#endif 911#endif
829 912
830 913
831 return true; 914 return true;
832} 915}
833 916
834/************************************************************************** 917/**************************************************************************
835 * 918 *
836 **************************************************************************/ 919 **************************************************************************/
837 920
838//calls the smsapplication with the number 921//calls the smsapplication with the number
839bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 922bool ExternalAppHandler::callBySMS( const QString& phonenumber )
840{ 923{
841#ifndef DESKTOP_VERSION 924#ifndef DESKTOP_VERSION
842 QString channel; 925 QString channel;
843 QString message; 926 QString message;
844 QString parameters; 927 QString parameters;
845 928
846 929
847 int client = KPimGlobalPrefs::instance()->mSMSClient; 930 int client = KPimGlobalPrefs::instance()->mSMSClient;
848 if (client == KPimGlobalPrefs::OTHER_SMC) 931 if (client == KPimGlobalPrefs::OTHER_SMC)
849 { 932 {
850 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 933 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
851 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 934 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
852 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 935 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
853 } 936 }
854 else 937 else
855 { 938 {
856 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 939 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
857 if (!dai) 940 if (!dai)
858 { 941 {
859 qDebug("could not find configured sms application."); 942 qDebug("could not find configured sms application.");
860 return false; 943 return false;
861 } 944 }
862 channel = dai->_channel; 945 channel = dai->_channel;
863 message = dai->_message; 946 message = dai->_message;
864 parameters = dai->_parameters; 947 parameters = dai->_parameters;
865 } 948 }
866 949
867 950
868 //first check if one of the mailers need the emails right in the message. 951 //first check if one of the mailers need the emails right in the message.
869 message = translateMessage(message, phonenumber, ""); 952 message = translateMessage(message, phonenumber, "");
870 953
871 954
872#ifdef DEBUG_EXT_APP_HANDLER 955#ifdef DEBUG_EXT_APP_HANDLER
873 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 956 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
874 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 957 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
875#endif 958#endif
876 959
877 QCopEnvelope e(channel.latin1(), message.latin1()); 960 QCopEnvelope e(channel.latin1(), message.latin1());
878 //US we need no names in the To field. The emailadresses are enough 961 //US we need no names in the To field. The emailadresses are enough
879 962
880 passParameters(&e, parameters, phonenumber, ""); 963 passParameters(&e, parameters, phonenumber, "");
881 964
882 965
883#else 966#else
884 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); 967 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) );
885#endif 968#endif
886 969
887 970
888 return true; 971 return true;
889} 972}
890 973
891/************************************************************************** 974/**************************************************************************
892 * 975 *
893 **************************************************************************/ 976 **************************************************************************/
894 977
895//calls the pagerapplication with the number 978//calls the pagerapplication with the number
896bool ExternalAppHandler::callByPager( const QString& pagernumber ) 979bool ExternalAppHandler::callByPager( const QString& pagernumber )
897{ 980{
898#ifndef DESKTOP_VERSION 981#ifndef DESKTOP_VERSION
899 QString channel; 982 QString channel;
900 QString message; 983 QString message;
901 QString parameters; 984 QString parameters;
902 985
903 986
904 int client = KPimGlobalPrefs::instance()->mPagerClient; 987 int client = KPimGlobalPrefs::instance()->mPagerClient;
905 if (client == KPimGlobalPrefs::OTHER_PAC) 988 if (client == KPimGlobalPrefs::OTHER_PAC)
906 { 989 {
907 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 990 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
908 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 991 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
909 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 992 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
910 } 993 }
911 else 994 else
912 { 995 {
913 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 996 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
914 if (!dai) 997 if (!dai)
915 { 998 {
916 qDebug("could not find configured pager application."); 999 qDebug("could not find configured pager application.");
917 return false; 1000 return false;
918 } 1001 }
919 channel = dai->_channel; 1002 channel = dai->_channel;
920 message = dai->_message; 1003 message = dai->_message;
921 parameters = dai->_parameters; 1004 parameters = dai->_parameters;
922 } 1005 }
923 1006
924 1007
925 //first check if one of the mailers need the emails right in the message. 1008 //first check if one of the mailers need the emails right in the message.
926 message = translateMessage(message, pagernumber, ""); 1009 message = translateMessage(message, pagernumber, "");
927 1010
928 1011
929#ifdef DEBUG_EXT_APP_HANDLER 1012#ifdef DEBUG_EXT_APP_HANDLER
930 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1013 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
931 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 1014 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
932#endif 1015#endif
933 1016
934 QCopEnvelope e(channel.latin1(), message.latin1()); 1017 QCopEnvelope e(channel.latin1(), message.latin1());
935 //US we need no names in the To field. The emailadresses are enough 1018 //US we need no names in the To field. The emailadresses are enough
936 1019
937 passParameters(&e, parameters, pagernumber, ""); 1020 passParameters(&e, parameters, pagernumber, "");
938 1021
939 1022
940#else 1023#else
941 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 1024 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
942#endif 1025#endif
943 1026