summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp15
-rw-r--r--kaddressbook/kabcore.cpp29
2 files changed, 11 insertions, 33 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index 487e8a5..2dda968 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -31,437 +31,434 @@
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 39
40 40
41#include "externalapphandler.h" 41#include "externalapphandler.h"
42#include "addresseeview.h" 42#include "addresseeview.h"
43 43
44 44
45//US #ifndef DESKTOP_VERSION 45//US #ifndef DESKTOP_VERSION
46//US #include <qtopia/qcopenvelope_qws.h> 46//US #include <qtopia/qcopenvelope_qws.h>
47//US #include <qpe/qpeapplication.h> 47//US #include <qpe/qpeapplication.h>
48//US #endif 48//US #endif
49 49
50//US static int kphoneInstalled = 0; 50//US static int kphoneInstalled = 0;
51 51
52using namespace KPIM; 52using namespace KPIM;
53 53
54AddresseeView::AddresseeView( QWidget *parent, const char *name ) 54AddresseeView::AddresseeView( QWidget *parent, const char *name )
55//US : KTextBrowser( parent, name ) 55//US : KTextBrowser( parent, name )
56 : QTextBrowser( parent, name ) 56 : QTextBrowser( parent, name )
57 57
58 58
59{ 59{
60//US setWrapPolicy( QTextEdit::AtWordBoundary ); 60//US setWrapPolicy( QTextEdit::AtWordBoundary );
61 setLinkUnderline( false ); 61 setLinkUnderline( false );
62 // setVScrollBarMode( QScrollView::AlwaysOff ); 62 // setVScrollBarMode( QScrollView::AlwaysOff );
63 //setHScrollBarMode( QScrollView::AlwaysOff ); 63 //setHScrollBarMode( QScrollView::AlwaysOff );
64 64
65//US QStyleSheet *sheet = styleSheet(); 65//US QStyleSheet *sheet = styleSheet();
66//US QStyleSheetItem *link = sheet->item( "a" ); 66//US QStyleSheetItem *link = sheet->item( "a" );
67//US link->setColor( KGlobalSettings::linkColor() ); 67//US link->setColor( KGlobalSettings::linkColor() );
68 68
69} 69}
70 70
71void AddresseeView::setSource(const QString& n) 71void AddresseeView::setSource(const QString& n)
72{ 72{
73 //qDebug("********AddresseeView::setSource %s", n.latin1()); 73 //qDebug("********AddresseeView::setSource %s", n.latin1());
74 74
75 if ( n.left( 6 ) == "mailto" ) 75 if ( n.left( 6 ) == "mailto" )
76 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); 76 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
77 else if ( n.left( 7 ) == "phoneto" ) 77 else if ( n.left( 7 ) == "phoneto" )
78 ExternalAppHandler::instance()->callByPhone( n.mid(8) ); 78 ExternalAppHandler::instance()->callByPhone( n.mid(8) );
79 else if ( n.left( 5 ) == "faxto" ) 79 else if ( n.left( 5 ) == "faxto" )
80 ExternalAppHandler::instance()->callByFax( n.mid(6) ); 80 ExternalAppHandler::instance()->callByFax( n.mid(6) );
81 else if ( n.left( 5 ) == "smsto" ) 81 else if ( n.left( 5 ) == "smsto" )
82 ExternalAppHandler::instance()->callBySMS( n.mid(6) ); 82 ExternalAppHandler::instance()->callBySMS( n.mid(6) );
83 else if ( n.left( 7 ) == "pagerto" ) 83 else if ( n.left( 7 ) == "pagerto" )
84 ExternalAppHandler::instance()->callByPager( n.mid(8) ); 84 ExternalAppHandler::instance()->callByPager( n.mid(8) );
85 else if ( n.left( 5 ) == "sipto" ) 85 else if ( n.left( 5 ) == "sipto" )
86 ExternalAppHandler::instance()->callBySIP( n.mid(6) ); 86 ExternalAppHandler::instance()->callBySIP( n.mid(6) );
87 87
88} 88}
89void AddresseeView::setAddressee( const KABC::Addressee& addr ) 89void AddresseeView::setAddressee( const KABC::Addressee& addr )
90{ 90{
91 ExternalAppHandler* eah = ExternalAppHandler::instance(); 91 ExternalAppHandler* eah = ExternalAppHandler::instance();
92 bool kemailAvail = eah->isEmailAppAvailable(); 92 bool kemailAvail = eah->isEmailAppAvailable();
93 bool kphoneAvail = eah->isPhoneAppAvailable(); 93 bool kphoneAvail = eah->isPhoneAppAvailable();
94 bool kfaxAvail = eah->isFaxAppAvailable(); 94 bool kfaxAvail = eah->isFaxAppAvailable();
95 bool ksmsAvail = eah->isSMSAppAvailable(); 95 bool ksmsAvail = eah->isSMSAppAvailable();
96 bool kpagerAvail = eah->isPagerAppAvailable(); 96 bool kpagerAvail = eah->isPagerAppAvailable();
97 bool ksipAvail = eah->isSIPAppAvailable(); 97 bool ksipAvail = eah->isSIPAppAvailable();
98 98
99 99
100 mAddressee = addr; 100 mAddressee = addr;
101 // clear view 101 // clear view
102 setText( QString::null ); 102 setText( QString::null );
103 103
104 if ( mAddressee.isEmpty() ) 104 if ( mAddressee.isEmpty() )
105 return; 105 return;
106 106
107 QString name = ( mAddressee.assembledName().isEmpty() ? 107 QString name = ( mAddressee.assembledName().isEmpty() ?
108 mAddressee.formattedName() : mAddressee.assembledName() ); 108 mAddressee.formattedName() : mAddressee.assembledName() );
109 109
110 QString dynamicPart; 110 QString dynamicPart;
111 111
112 QStringList emails = mAddressee.emails(); 112 QStringList emails = mAddressee.emails();
113 QStringList::ConstIterator emailIt; 113 QStringList::ConstIterator emailIt;
114 QString type = i18n( "Email" ); 114 QString type = i18n( "Email" );
115 emailIt = emails.begin(); 115 emailIt = emails.begin();
116 if ( emailIt != emails.end() ) { 116 if ( emailIt != emails.end() ) {
117 if ( kemailAvail ) { 117 if ( kemailAvail ) {
118 dynamicPart += QString( 118 dynamicPart += QString(
119 "<tr><td align=\"right\"><b>%1</b></td>" 119 "<tr><td align=\"right\"><b>%1</b></td>"
120 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 120 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
121 .arg( type ) 121 .arg( type )
122 .arg( name ) 122 .arg( name )
123 .arg( *emailIt ) 123 .arg( *emailIt )
124 .arg( *emailIt ); 124 .arg( *emailIt );
125 ++emailIt; 125 ++emailIt;
126 } else { 126 } else {
127 dynamicPart += QString( 127 dynamicPart += QString(
128 "<tr><td align=\"right\"><b>%1</b></td>" 128 "<tr><td align=\"right\"><b>%1</b></td>"
129 "<td align=\"left\">%2</td></tr>" ) 129 "<td align=\"left\">%2</td></tr>" )
130 .arg( type ) 130 .arg( type )
131 .arg( *emailIt ); 131 .arg( *emailIt );
132 ++emailIt; 132 ++emailIt;
133 } 133 }
134 } 134 }
135 if ( mAddressee.birthday().date().isValid() ) { 135 if ( mAddressee.birthday().date().isValid() ) {
136 dynamicPart += QString( 136 dynamicPart += QString(
137 "<tr><td align=\"right\"><b>%1</b></td>" 137 "<tr><td align=\"right\"><b>%1</b></td>"
138 "<td align=\"left\">%2</td></tr>" ) 138 "<td align=\"left\">%2</td></tr>" )
139 .arg( i18n ("Birthday") ) 139 .arg( i18n ("Birthday") )
140 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); 140 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
141 } 141 }
142 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); 142 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
143 KABC::PhoneNumber::List::ConstIterator phoneIt; 143 KABC::PhoneNumber::List::ConstIterator phoneIt;
144 QString extension; 144 QString extension;
145 int phonetype; 145 int phonetype;
146 QString sms; 146 QString sms;
147 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 147 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
148 phonetype = (*phoneIt).type(); 148 phonetype = (*phoneIt).type();
149 if (ksmsAvail && 149 if (ksmsAvail &&
150 ( 150 (
151 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || 151 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
152 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) 152 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
153 ) 153 )
154 ) 154 )
155 { 155 {
156 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) 156 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
157 .arg( (*phoneIt).number() ); 157 .arg( (*phoneIt).number() );
158 158
159 } 159 }
160 else 160 else
161 sms = ""; 161 sms = "";
162 162
163 extension = QString::null; 163 extension = QString::null;
164 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { 164 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
165 if (kfaxAvail) extension = "faxto:"; 165 if (kfaxAvail) extension = "faxto:";
166 } 166 }
167 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { 167 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
168 if (kpagerAvail) extension = "pagerto:"; 168 if (kpagerAvail) extension = "pagerto:";
169 } 169 }
170 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { 170 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
171 if (ksipAvail) extension = "sipto:"; 171 if (ksipAvail) extension = "sipto:";
172 } 172 }
173 else if (kphoneAvail) { 173 else if (kphoneAvail) {
174 extension = "phoneto:"; 174 extension = "phoneto:";
175 } 175 }
176 else 176 else
177 extension = QString::null; 177 extension = QString::null;
178 178
179 if ( !extension.isEmpty() ) { 179 if ( !extension.isEmpty() ) {
180 dynamicPart += QString( 180 dynamicPart += QString(
181 "<tr><td align=\"right\"><b>%1</b></td>" 181 "<tr><td align=\"right\"><b>%1</b></td>"
182 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) 182 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
183 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 183 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
184 .arg( extension ) 184 .arg( extension )
185 .arg( (*phoneIt).number() ) 185 .arg( (*phoneIt).number() )
186 .arg( (*phoneIt).number() ) 186 .arg( (*phoneIt).number() )
187 .arg( sms ); 187 .arg( sms );
188 188
189 } else { 189 } else {
190 dynamicPart += QString( 190 dynamicPart += QString(
191 "<tr><td align=\"right\"><b>%1</b></td>" 191 "<tr><td align=\"right\"><b>%1</b></td>"
192 "<td align=\"left\">%2 %3</td></tr>" ) 192 "<td align=\"left\">%2 %3</td></tr>" )
193 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 193 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
194 .arg( (*phoneIt).number() ) 194 .arg( (*phoneIt).number() )
195 .arg( sms ); 195 .arg( sms );
196 } 196 }
197 } 197 }
198 198
199 199
200 for ( ; emailIt != emails.end(); ++emailIt ) { 200 for ( ; emailIt != emails.end(); ++emailIt ) {
201 if ( kemailAvail ) { 201 if ( kemailAvail ) {
202 dynamicPart += QString( 202 dynamicPart += QString(
203 "<tr><td align=\"right\"><b>%1</b></td>" 203 "<tr><td align=\"right\"><b>%1</b></td>"
204 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 204 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
205 .arg( type ) 205 .arg( type )
206 .arg( name ) 206 .arg( name )
207 .arg( *emailIt ) 207 .arg( *emailIt )
208 .arg( *emailIt ); 208 .arg( *emailIt );
209 } else { 209 } else {
210 dynamicPart += QString( 210 dynamicPart += QString(
211 "<tr><td align=\"right\"><b>%1</b></td>" 211 "<tr><td align=\"right\"><b>%1</b></td>"
212 "<td align=\"left\">%2</td></tr>" ) 212 "<td align=\"left\">%2</td></tr>" )
213 .arg( type ) 213 .arg( type )
214 .arg( *emailIt ); 214 .arg( *emailIt );
215 } 215 }
216 } 216 }
217 217
218 if ( !mAddressee.url().url().isEmpty() ) { 218 if ( !mAddressee.url().url().isEmpty() ) {
219 dynamicPart += QString( 219 dynamicPart += QString(
220 "<tr><td align=\"right\"><b>%1</b></td>" 220 "<tr><td align=\"right\"><b>%1</b></td>"
221 "<td align=\"left\">%2</td></tr>" ) 221 "<td align=\"left\">%2</td></tr>" )
222 .arg( i18n( "Homepage" ) ) 222 .arg( i18n( "Homepage" ) )
223//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); 223//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) );
224 .arg( mAddressee.url().url() ); 224 .arg( mAddressee.url().url() );
225 //qDebug("AddresseeView::setAddressee has to be verified."); 225 //qDebug("AddresseeView::setAddressee has to be verified.");
226 } 226 }
227 227
228 KABC::Address::List addresses = mAddressee.addresses(); 228 KABC::Address::List addresses = mAddressee.addresses();
229 KABC::Address::List::ConstIterator addrIt; 229 KABC::Address::List::ConstIterator addrIt;
230 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 230 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
231 if ( true /*(*addrIt).label().isEmpty()*/ ) { 231 if ( true /*(*addrIt).label().isEmpty()*/ ) {
232 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 232 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
233//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 233//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
234 //qDebug("adresss %s ",formattedAddress.latin1() ); 234 //qDebug("adresss %s ",formattedAddress.latin1() );
235 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 235 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
236 //qDebug("AddresseeView::setAddressee has to be verified."); 236 //qDebug("AddresseeView::setAddressee has to be verified.");
237 237
238 dynamicPart += QString( 238 dynamicPart += QString(
239 "<tr><td align=\"right\"><b>%1</b></td>" 239 "<tr><td align=\"right\"><b>%1</b></td>"
240 "<td align=\"left\">%2</td></tr>" ) 240 "<td align=\"left\">%2</td></tr>" )
241 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 241 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
242 .arg( formattedAddress ); 242 .arg( formattedAddress );
243 } else { 243 } else {
244 244
245 dynamicPart += QString( 245 dynamicPart += QString(
246 "<tr><td align=\"right\"><b>%1</b></td>" 246 "<tr><td align=\"right\"><b>%1</b></td>"
247 "<td align=\"left\">%2</td></tr>" ) 247 "<td align=\"left\">%2</td></tr>" )
248 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 248 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
249//US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); 249//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
250 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); 250 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
251 251
252 } 252 }
253 } 253 }
254 254
255 QString notes; 255 QString notes;
256 if ( !mAddressee.note().isEmpty() ) { 256 if ( !mAddressee.note().isEmpty() ) {
257 notes = QString( 257 notes = QString(
258 "<tr>" 258 "<tr>"
259 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label 259 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label
260 "<td align=\"left\">%2</td>" // note 260 "<td align=\"left\">%2</td>" // note
261 "</tr>" ).arg( i18n( "Notes" ) ) 261 "</tr>" ).arg( i18n( "Notes" ) )
262//US .arg( mAddressee.note().replace( '\n', "<br>" ) ); 262//US .arg( mAddressee.note().replace( '\n', "<br>" ) );
263 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); 263 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
264 //qDebug("AddresseeView::setAddressee has to be verified."); 264 //qDebug("AddresseeView::setAddressee has to be verified.");
265 } 265 }
266 266
267 QString aRole = ""; 267 QString aRole = "";
268 QString aOrga = ""; 268 QString aOrga = "";
269 if ( true /*!mAddressee.role().isEmpty()*/ ) { 269 if ( true /*!mAddressee.role().isEmpty()*/ ) {
270 aRole = "<tr>" 270 aRole = "<tr>"
271 "<td align=\"left\">" + mAddressee.role() + "</td>" 271 "<td align=\"left\">" + mAddressee.role() + "</td>"
272 "</tr>"; 272 "</tr>";
273 } 273 }
274 if ( true /*!mAddressee.organization().isEmpty()*/ ) { 274 if ( true /*!mAddressee.organization().isEmpty()*/ ) {
275 aOrga = "<tr>" 275 aOrga = "<tr>"
276 "<td align=\"left\">" + mAddressee.organization() + "</td>" ; 276 "<td align=\"left\">" + mAddressee.organization() + "</td>" ;
277 "</tr>"; 277 "</tr>";
278 } 278 }
279 mText = ""; 279 mText = "";
280 QString picString = ""; 280 QString picString = "";
281 KABC::Picture picture = mAddressee.photo(); 281 KABC::Picture picture = mAddressee.photo();
282 bool picAvailintern = false; 282 bool picAvailintern = false;
283 bool picAvailUrl = false; 283 bool picAvailUrl = false;
284 if (! picture.undefined() ) { 284 if (! picture.undefined() ) {
285 picAvailintern = (picture.isIntern() && !picture.data().isNull()); 285 picAvailintern = (picture.isIntern() && !picture.data().isNull());
286 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); 286 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
287 } 287 }
288 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { 288 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
289 if ( picAvailintern ) { 289 if ( picAvailintern ) {
290 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); 290 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
291 } else { 291 } else {
292 if ( picAvailUrl ) { 292 if ( picAvailUrl ) {
293 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); 293 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() ));
294 } else { 294 } else {
295 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); 295 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) );
296 } 296 }
297 } 297 }
298 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; 298 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
299 mText = QString::fromLatin1( 299 mText = QString::fromLatin1(
300 "<html>" 300 "<html>"
301 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color 301 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color
302 "<table>" 302 "<table>"
303 "<tr>" 303 "<tr>"
304 "<td rowspan=\"3\" align=\"right\" valign=\"top\">" 304 "<td rowspan=\"3\" align=\"right\" valign=\"top\">"
305 "%3" 305 "%3"
306 "</td>" 306 "</td>"
307 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name 307 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name
308 "</tr>" 308 "</tr>"
309 "%5" // role 309 "%5" // role
310 "%6" // organization 310 "%6" // organization
311 "<td colspan=\"2\">&nbsp;</td>" 311 "<td colspan=\"2\">&nbsp;</td>"
312 "%7" // dynamic part 312 "%7" // dynamic part
313 "%8" // notes 313 "%8" // notes
314 "</table>" 314 "</table>"
315 "</body>" 315 "</body>"
316 "</html>") 316 "</html>")
317//US 317//US
318 .arg( /*KGlobalSettings::textColor().name()*/ "black" ) 318 .arg( /*KGlobalSettings::textColor().name()*/ "black" )
319//US 319//US
320 .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) 320 .arg( /*KGlobalSettings::baseColor().name()*/ "white" )
321 .arg( picString ) 321 .arg( picString )
322 .arg( name ) 322 .arg( name )
323 .arg( aRole ) 323 .arg( aRole )
324 .arg( aOrga ) 324 .arg( aOrga )
325 .arg( dynamicPart ) 325 .arg( dynamicPart )
326 .arg( notes ); 326 .arg( notes );
327 327
328 } else { // no picture! 328 } else { // no picture!
329 329
330mText = "<table width=\"100%\">\n"; 330mText = "<table width=\"100%\">\n";
331 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 331 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
332#ifdef DESKTOP_VERSION 332#ifdef DESKTOP_VERSION
333 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; 333 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>";
334#else 334#else
335 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>"; 335 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>";
336#endif 336#endif
337 337
338#ifdef DESKTOP_VERSION 338#ifdef DESKTOP_VERSION
339 mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>"; 339 mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>";
340#else 340#else
341 mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>"; 341 mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>";
342#endif 342#endif
343 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 343 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
344 344
345 mText += "<table><td colspan=\"2\">&nbsp;</td>"; 345 mText += "<table><td colspan=\"2\">&nbsp;</td>";
346 /* 346 /*
347 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" 347 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>"
348 "<td align=\"left\"><b>%2</b></td></tr>" ) 348 "<td align=\"left\"><b>%2</b></td></tr>" )
349 .arg( i18n(" ") ) 349 .arg( i18n(" ") )
350 .arg( name ); 350 .arg( name );
351 */ 351 */
352 if ( ! mAddressee.role().isEmpty() ) 352 if ( ! mAddressee.role().isEmpty() )
353 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 353 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
354 "<td align=\"left\">%2</td></tr>" ) 354 "<td align=\"left\">%2</td></tr>" )
355 .arg( i18n(" ") ) 355 .arg( i18n(" ") )
356 .arg( mAddressee.role()); 356 .arg( mAddressee.role());
357 if ( ! mAddressee.organization().isEmpty() ) 357 if ( ! mAddressee.organization().isEmpty() )
358 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 358 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
359 "<td align=\"left\">%2</td></tr>" ) 359 "<td align=\"left\">%2</td></tr>" )
360 .arg( i18n(" ") ) 360 .arg( i18n(" ") )
361 .arg( mAddressee.organization()); 361 .arg( mAddressee.organization());
362 mText += dynamicPart; 362 mText += dynamicPart;
363 mText += notes; 363 mText += notes;
364 mText += "</table>"; 364 mText += "</table>";
365 365
366 } 366 }
367 367
368 // at last display it... 368 // at last display it...
369 setText( mText ); 369 setText( mText );
370 370
371} 371}
372 372
373KABC::Addressee AddresseeView::addressee() const 373KABC::Addressee AddresseeView::addressee() const
374{ 374{
375 return mAddressee; 375 return mAddressee;
376} 376}
377void AddresseeView::addTag(const QString & tag,const QString & text) 377void AddresseeView::addTag(const QString & tag,const QString & text)
378{ 378{
379 if ( text.isEmpty() ) 379 if ( text.isEmpty() )
380 return; 380 return;
381 int number=text.contains("\n"); 381 int number=text.contains("\n");
382 QString str = "<" + tag + ">"; 382 QString str = "<" + tag + ">";
383 QString tmpText=text; 383 QString tmpText=text;
384 QString tmpStr=str; 384 QString tmpStr=str;
385 if(number !=-1) 385 if(number !=-1)
386 { 386 {
387 if (number > 0) { 387 if (number > 0) {
388 int pos=0; 388 int pos=0;
389 QString tmp; 389 QString tmp;
390 for(int i=0;i<=number;i++) { 390 for(int i=0;i<=number;i++) {
391 pos=tmpText.find("\n"); 391 pos=tmpText.find("\n");
392 tmp=tmpText.left(pos); 392 tmp=tmpText.left(pos);
393 tmpText=tmpText.right(tmpText.length()-pos-1); 393 tmpText=tmpText.right(tmpText.length()-pos-1);
394 tmpStr+=tmp+"<br>"; 394 tmpStr+=tmp+"<br>";
395 } 395 }
396 } 396 }
397 else tmpStr += tmpText; 397 else tmpStr += tmpText;
398 tmpStr+="</" + tag + ">"; 398 tmpStr+="</" + tag + ">";
399 mText.append(tmpStr); 399 mText.append(tmpStr);
400 } 400 }
401 else 401 else
402 { 402 {
403 str += text + "</" + tag + ">"; 403 str += text + "</" + tag + ">";
404 mText.append(str); 404 mText.append(str);
405 } 405 }
406} 406}
407 407
408AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, 408AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name,
409 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) 409 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false)
410{ 410{
411 findButton( Close )->setText( i18n("Cancel Sync")); 411 findButton( Close )->setText( i18n("Cancel Sync"));
412 findButton( Ok )->setText( i18n("Remote")); 412 findButton( Ok )->setText( i18n("Remote"));
413 findButton( User1 )->setText( i18n("Local")); 413 findButton( User1 )->setText( i18n("Local"));
414 QWidget* topframe = new QWidget( this ); 414 QWidget* topframe = new QWidget( this );
415 //QVBox* topframe = new QVBox( this );
416 setMainWidget( topframe ); 415 setMainWidget( topframe );
417 QBoxLayout* bl; 416 QBoxLayout* bl;
418 if ( QApplication::desktop()->width() < 640 ) { 417 if ( QApplication::desktop()->width() < 640 ) {
419 bl = new QVBoxLayout( topframe ); 418 bl = new QVBoxLayout( topframe );
420
421 } else { 419 } else {
422 bl = new QHBoxLayout( topframe ); 420 bl = new QHBoxLayout( topframe );
423
424 } 421 }
425 QVBox* subframe = new QVBox( topframe ); 422 QVBox* subframe = new QVBox( topframe );
426 bl->addWidget(subframe ); 423 bl->addWidget(subframe );
427 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); 424 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe );
425 if ( takeloc )
426 lab->setBackgroundColor(Qt::green.light() );
428 AddresseeView * av = new AddresseeView( subframe ); 427 AddresseeView * av = new AddresseeView( subframe );
429 av->setAddressee( loc ); 428 av->setAddressee( loc );
430 subframe = new QVBox( topframe ); 429 subframe = new QVBox( topframe );
431 bl->addWidget(subframe ); 430 bl->addWidget(subframe );
432 lab = new QLabel( i18n("Remote Addressee"), subframe ); 431 lab = new QLabel( i18n("Remote Addressee"), subframe );
432 if ( !takeloc )
433 lab->setBackgroundColor(Qt::green.light() );
433 av = new AddresseeView( subframe ); 434 av = new AddresseeView( subframe );
434 av->setAddressee( rem ); 435 av->setAddressee( rem );
435 436 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote()));
436 QObject::connect(findButton( Ok ),SIGNAL(clicked()), 437 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local()));
437 SLOT(slot_remote()));
438 QObject::connect(this,SIGNAL(user1Clicked()),
439 SLOT(slot_local()));
440#ifndef DESKTOP_VERSION 438#ifndef DESKTOP_VERSION
441 showMaximized(); 439 showMaximized();
442#else 440#else
443 resize ( 640, 400 ); 441 resize ( 640, 400 );
444#endif 442#endif
445} 443}
446 444
447int AddresseeChooser::executeD( bool local ) 445int AddresseeChooser::executeD( bool local )
448{ 446{
449 mSyncResult = 3; 447 mSyncResult = 3;
450 if ( local ) 448 if ( local )
451 findButton( User1 )->setFocus(); 449 findButton( User1 )->setFocus();
452 else 450 else
453 findButton( Ok )->setFocus(); 451 findButton( Ok )->setFocus();
454 exec(); 452 exec();
455 qDebug("returning %d ",mSyncResult );
456 return mSyncResult; 453 return mSyncResult;
457} 454}
458void AddresseeChooser::slot_remote() 455void AddresseeChooser::slot_remote()
459{ 456{
460 mSyncResult = 2; 457 mSyncResult = 2;
461 accept(); 458 accept();
462} 459}
463void AddresseeChooser::slot_local() 460void AddresseeChooser::slot_local()
464{ 461{
465 mSyncResult = 1; 462 mSyncResult = 1;
466 accept(); 463 accept();
467} 464}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index b1a951c..cc8eb52 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2246,767 +2246,748 @@ bool KABCore::syncWithFile( QString fn , bool quick )
2246 int result = 0; 2246 int result = 0;
2247 if ( !quick ) { 2247 if ( !quick ) {
2248 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2248 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2249 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2249 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2250 mess, 2250 mess,
2251 i18n("Sync"), i18n("Cancel"), 0, 2251 i18n("Sync"), i18n("Cancel"), 0,
2252 0, 1 ); 2252 0, 1 );
2253 if ( result ) 2253 if ( result )
2254 return false; 2254 return false;
2255 } 2255 }
2256 if ( KABPrefs::instance()->mAskForPreferences ) 2256 if ( KABPrefs::instance()->mAskForPreferences )
2257 edit_sync_options(); 2257 edit_sync_options();
2258 if ( result == 0 ) { 2258 if ( result == 0 ) {
2259 //qDebug("Now sycing ... "); 2259 //qDebug("Now sycing ... ");
2260 if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) 2260 if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) )
2261 setCaption( i18n("Synchronization successful") ); 2261 setCaption( i18n("Synchronization successful") );
2262 else 2262 else
2263 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 2263 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2264 if ( ! quick ) 2264 if ( ! quick )
2265 KABPrefs::instance()->mLastSyncedLocalFile = fn; 2265 KABPrefs::instance()->mLastSyncedLocalFile = fn;
2266 setModified(); 2266 setModified();
2267 } 2267 }
2268 return ret; 2268 return ret;
2269} 2269}
2270void KABCore::quickSyncLocalFile() 2270void KABCore::quickSyncLocalFile()
2271{ 2271{
2272 2272
2273 if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { 2273 if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2274 qDebug("quick syncLocalFile() successful "); 2274 qDebug("quick syncLocalFile() successful ");
2275 2275
2276 } 2276 }
2277} 2277}
2278void KABCore::multiSync( bool askforPrefs ) 2278void KABCore::multiSync( bool askforPrefs )
2279{ 2279{
2280 if (mBlockSaveFlag) 2280 if (mBlockSaveFlag)
2281 return; 2281 return;
2282 mBlockSaveFlag = true; 2282 mBlockSaveFlag = true;
2283 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 2283 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
2284 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2284 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2285 question, 2285 question,
2286 i18n("Yes"), i18n("No"), 2286 i18n("Yes"), i18n("No"),
2287 0, 0 ) != 0 ) { 2287 0, 0 ) != 0 ) {
2288 mBlockSaveFlag = false; 2288 mBlockSaveFlag = false;
2289 setCaption(i18n("Aborted! Nothing synced!")); 2289 setCaption(i18n("Aborted! Nothing synced!"));
2290 return; 2290 return;
2291 } 2291 }
2292 mCurrentSyncDevice = i18n("Multiple profiles") ; 2292 mCurrentSyncDevice = i18n("Multiple profiles") ;
2293 KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; 2293 KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs;
2294 if ( askforPrefs ) { 2294 if ( askforPrefs ) {
2295 edit_sync_options(); 2295 edit_sync_options();
2296 KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; 2296 KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs;
2297 } 2297 }
2298 setCaption(i18n("Multiple sync started.") ); 2298 setCaption(i18n("Multiple sync started.") );
2299 qApp->processEvents(); 2299 qApp->processEvents();
2300 int num = ringSync() ; 2300 int num = ringSync() ;
2301 if ( num > 1 ) 2301 if ( num > 1 )
2302 ringSync(); 2302 ringSync();
2303 mBlockSaveFlag = false; 2303 mBlockSaveFlag = false;
2304 if ( num ) 2304 if ( num )
2305 save(); 2305 save();
2306 if ( num ) 2306 if ( num )
2307 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 2307 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
2308 else 2308 else
2309 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 2309 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
2310 return; 2310 return;
2311} 2311}
2312int KABCore::ringSync() 2312int KABCore::ringSync()
2313{ 2313{
2314 int syncedProfiles = 0; 2314 int syncedProfiles = 0;
2315 int i; 2315 int i;
2316 QTime timer; 2316 QTime timer;
2317 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2317 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2318 QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; 2318 QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames;
2319 KSyncProfile* temp = new KSyncProfile (); 2319 KSyncProfile* temp = new KSyncProfile ();
2320 KABPrefs::instance()->mAskForPreferences = false; 2320 KABPrefs::instance()->mAskForPreferences = false;
2321 for ( i = 0; i < syncProfileNames.count(); ++i ) { 2321 for ( i = 0; i < syncProfileNames.count(); ++i ) {
2322 mCurrentSyncProfile = i; 2322 mCurrentSyncProfile = i;
2323 temp->setName(syncProfileNames[mCurrentSyncProfile]); 2323 temp->setName(syncProfileNames[mCurrentSyncProfile]);
2324 temp->readConfig(&config); 2324 temp->readConfig(&config);
2325 if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { 2325 if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) {
2326 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 2326 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
2327 ++syncedProfiles; 2327 ++syncedProfiles;
2328 // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2328 // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2329 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2329 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2330 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2330 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2331 KABPrefs::instance()->mWriteBackInFuture = 0; 2331 KABPrefs::instance()->mWriteBackInFuture = 0;
2332 if ( temp->getWriteBackFuture() ) 2332 if ( temp->getWriteBackFuture() )
2333 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2333 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2334 KABPrefs::instance()->mShowSyncSummary = false; 2334 KABPrefs::instance()->mShowSyncSummary = false;
2335 mCurrentSyncDevice = syncProfileNames[i] ; 2335 mCurrentSyncDevice = syncProfileNames[i] ;
2336 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; 2336 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName;
2337 if ( i == 0 ) { 2337 if ( i == 0 ) {
2338 syncSharp(); 2338 syncSharp();
2339 } else { 2339 } else {
2340 if ( temp->getIsLocalFileSync() ) { 2340 if ( temp->getIsLocalFileSync() ) {
2341 if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) 2341 if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) )
2342 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 2342 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
2343 } else { 2343 } else {
2344 if ( temp->getIsPhoneSync() ) { 2344 if ( temp->getIsPhoneSync() ) {
2345 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 2345 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
2346 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 2346 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
2347 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 2347 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
2348 syncPhone(); 2348 syncPhone();
2349 } else 2349 } else
2350 syncRemote( temp, false ); 2350 syncRemote( temp, false );
2351 2351
2352 } 2352 }
2353 } 2353 }
2354 timer.start(); 2354 timer.start();
2355 setCaption(i18n("Multiple sync in progress ... please wait!") ); 2355 setCaption(i18n("Multiple sync in progress ... please wait!") );
2356 while ( timer.elapsed () < 2000 ) { 2356 while ( timer.elapsed () < 2000 ) {
2357 qApp->processEvents(); 2357 qApp->processEvents();
2358#ifndef _WIN32_ 2358#ifndef _WIN32_
2359 sleep (1); 2359 sleep (1);
2360#endif 2360#endif
2361 } 2361 }
2362 2362
2363 } 2363 }
2364 2364
2365 } 2365 }
2366 delete temp; 2366 delete temp;
2367 return syncedProfiles; 2367 return syncedProfiles;
2368} 2368}
2369 2369
2370void KABCore::syncRemote( KSyncProfile* prof, bool ask) 2370void KABCore::syncRemote( KSyncProfile* prof, bool ask)
2371{ 2371{
2372 QString question; 2372 QString question;
2373 if ( ask ) { 2373 if ( ask ) {
2374 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 2374 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2375 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2375 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2376 question, 2376 question,
2377 i18n("Yes"), i18n("No"), 2377 i18n("Yes"), i18n("No"),
2378 0, 0 ) != 0 ) 2378 0, 0 ) != 0 )
2379 return; 2379 return;
2380 } 2380 }
2381 QString command = prof->getPreSyncCommandAB(); 2381 QString command = prof->getPreSyncCommandAB();
2382 int fi; 2382 int fi;
2383 if ( (fi = command.find("$PWD$")) > 0 ) { 2383 if ( (fi = command.find("$PWD$")) > 0 ) {
2384 QString pwd = getPassword(); 2384 QString pwd = getPassword();
2385 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2385 command = command.left( fi )+ pwd + command.mid( fi+5 );
2386 2386
2387 } 2387 }
2388 int maxlen = 30; 2388 int maxlen = 30;
2389 if ( QApplication::desktop()->width() > 320 ) 2389 if ( QApplication::desktop()->width() > 320 )
2390 maxlen += 25; 2390 maxlen += 25;
2391 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2391 setCaption ( i18n( "Copy remote file to local machine..." ) );
2392 int fileSize = 0; 2392 int fileSize = 0;
2393 int result = system ( command ); 2393 int result = system ( command );
2394 // 0 : okay 2394 // 0 : okay
2395 // 256: no such file or dir 2395 // 256: no such file or dir
2396 // 2396 //
2397 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2397 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2398 if ( result != 0 ) { 2398 if ( result != 0 ) {
2399 int len = maxlen; 2399 int len = maxlen;
2400 while ( len < command.length() ) { 2400 while ( len < command.length() ) {
2401 command.insert( len , "\n" ); 2401 command.insert( len , "\n" );
2402 len += maxlen +2; 2402 len += maxlen +2;
2403 } 2403 }
2404 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2404 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2405 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2405 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2406 question, 2406 question,
2407 i18n("Okay!")) ; 2407 i18n("Okay!")) ;
2408 setCaption ("KO/Pi"); 2408 setCaption ("KO/Pi");
2409 return; 2409 return;
2410 } 2410 }
2411 setCaption ( i18n( "Copying succeed." ) ); 2411 setCaption ( i18n( "Copying succeed." ) );
2412 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 2412 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2413 if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { 2413 if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) {
2414// Event* e = mView->getLastSyncEvent(); 2414// Event* e = mView->getLastSyncEvent();
2415// e->setReadOnly( false ); 2415// e->setReadOnly( false );
2416// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2416// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2417// e->setReadOnly( true ); 2417// e->setReadOnly( true );
2418 if ( KABPrefs::instance()->mWriteBackFile ) { 2418 if ( KABPrefs::instance()->mWriteBackFile ) {
2419 command = prof->getPostSyncCommandAB(); 2419 command = prof->getPostSyncCommandAB();
2420 int fi; 2420 int fi;
2421 if ( (fi = command.find("$PWD$")) > 0 ) { 2421 if ( (fi = command.find("$PWD$")) > 0 ) {
2422 QString pwd = getPassword(); 2422 QString pwd = getPassword();
2423 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2423 command = command.left( fi )+ pwd + command.mid( fi+5 );
2424 2424
2425 } 2425 }
2426 setCaption ( i18n( "Writing back file ..." ) ); 2426 setCaption ( i18n( "Writing back file ..." ) );
2427 result = system ( command ); 2427 result = system ( command );
2428 qDebug("KO: Writing back file result: %d ", result); 2428 qDebug("KO: Writing back file result: %d ", result);
2429 if ( result != 0 ) { 2429 if ( result != 0 ) {
2430 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 2430 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2431 return; 2431 return;
2432 } else { 2432 } else {
2433 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2433 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2434 } 2434 }
2435 } 2435 }
2436 } 2436 }
2437 return; 2437 return;
2438} 2438}
2439#include <qpushbutton.h> 2439#include <qpushbutton.h>
2440#include <qradiobutton.h> 2440#include <qradiobutton.h>
2441#include <qbuttongroup.h> 2441#include <qbuttongroup.h>
2442void KABCore::edit_sync_options() 2442void KABCore::edit_sync_options()
2443{ 2443{
2444 //mDialogManager->showSyncOptions(); 2444 //mDialogManager->showSyncOptions();
2445 //KABPrefs::instance()->mSyncAlgoPrefs 2445 //KABPrefs::instance()->mSyncAlgoPrefs
2446 QDialog dia( this, "dia", true ); 2446 QDialog dia( this, "dia", true );
2447 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 2447 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2448 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 2448 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2449 QVBoxLayout lay ( &dia ); 2449 QVBoxLayout lay ( &dia );
2450 lay.setSpacing( 2 ); 2450 lay.setSpacing( 2 );
2451 lay.setMargin( 3 ); 2451 lay.setMargin( 3 );
2452 lay.addWidget(&gr); 2452 lay.addWidget(&gr);
2453 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 2453 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2454 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 2454 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2455 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 2455 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2456 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 2456 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2457 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 2457 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2458 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 2458 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2459 //QRadioButton both( i18n("Take both on conflict"), &gr ); 2459 //QRadioButton both( i18n("Take both on conflict"), &gr );
2460 QPushButton pb ( "OK", &dia); 2460 QPushButton pb ( "OK", &dia);
2461 lay.addWidget( &pb ); 2461 lay.addWidget( &pb );
2462 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2462 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2463 switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { 2463 switch ( KABPrefs::instance()->mSyncAlgoPrefs ) {
2464 case 0: 2464 case 0:
2465 loc.setChecked( true); 2465 loc.setChecked( true);
2466 break; 2466 break;
2467 case 1: 2467 case 1:
2468 rem.setChecked( true ); 2468 rem.setChecked( true );
2469 break; 2469 break;
2470 case 2: 2470 case 2:
2471 newest.setChecked( true); 2471 newest.setChecked( true);
2472 break; 2472 break;
2473 case 3: 2473 case 3:
2474 ask.setChecked( true); 2474 ask.setChecked( true);
2475 break; 2475 break;
2476 case 4: 2476 case 4:
2477 f_loc.setChecked( true); 2477 f_loc.setChecked( true);
2478 break; 2478 break;
2479 case 5: 2479 case 5:
2480 f_rem.setChecked( true); 2480 f_rem.setChecked( true);
2481 break; 2481 break;
2482 case 6: 2482 case 6:
2483 // both.setChecked( true); 2483 // both.setChecked( true);
2484 break; 2484 break;
2485 default: 2485 default:
2486 break; 2486 break;
2487 } 2487 }
2488 if ( dia.exec() ) { 2488 if ( dia.exec() ) {
2489 KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2489 KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2490 } 2490 }
2491 2491
2492 2492
2493} 2493}
2494QString KABCore::getPassword( ) 2494QString KABCore::getPassword( )
2495{ 2495{
2496 QString retfile = ""; 2496 QString retfile = "";
2497 QDialog dia ( this, "input-dialog", true ); 2497 QDialog dia ( this, "input-dialog", true );
2498 QLineEdit lab ( &dia ); 2498 QLineEdit lab ( &dia );
2499 lab.setEchoMode( QLineEdit::Password ); 2499 lab.setEchoMode( QLineEdit::Password );
2500 QVBoxLayout lay( &dia ); 2500 QVBoxLayout lay( &dia );
2501 lay.setMargin(7); 2501 lay.setMargin(7);
2502 lay.setSpacing(7); 2502 lay.setSpacing(7);
2503 lay.addWidget( &lab); 2503 lay.addWidget( &lab);
2504 dia.setFixedSize( 230,50 ); 2504 dia.setFixedSize( 230,50 );
2505 dia.setCaption( i18n("Enter password") ); 2505 dia.setCaption( i18n("Enter password") );
2506 QPushButton pb ( "OK", &dia); 2506 QPushButton pb ( "OK", &dia);
2507 lay.addWidget( &pb ); 2507 lay.addWidget( &pb );
2508 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2508 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2509 dia.show(); 2509 dia.show();
2510 int res = dia.exec(); 2510 int res = dia.exec();
2511 if ( res ) 2511 if ( res )
2512 retfile = lab.text(); 2512 retfile = lab.text();
2513 dia.hide(); 2513 dia.hide();
2514 qApp->processEvents(); 2514 qApp->processEvents();
2515 return retfile; 2515 return retfile;
2516 2516
2517} 2517}
2518#include <libkcal/syncdefines.h> 2518#include <libkcal/syncdefines.h>
2519 2519
2520KABC::Addressee KABCore::getLastSyncAddressee() 2520KABC::Addressee KABCore::getLastSyncAddressee()
2521{ 2521{
2522 Addressee lse; 2522 Addressee lse;
2523 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2523 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2524 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2524 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2525 if (lse.isEmpty()) { 2525 if (lse.isEmpty()) {
2526 qDebug("Creating new last-syncAddressee "); 2526 qDebug("Creating new last-syncAddressee ");
2527 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2527 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2528 QString sum = ""; 2528 QString sum = "";
2529 if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 2529 if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
2530 sum = "E: "; 2530 sum = "E: ";
2531 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2531 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2532 lse.setRevision( mLastAddressbookSync ); 2532 lse.setRevision( mLastAddressbookSync );
2533 lse.setCategories( i18n("SyncEvent") ); 2533 lse.setCategories( i18n("SyncEvent") );
2534 mAddressBook->insertAddressee( lse ); 2534 mAddressBook->insertAddressee( lse );
2535 } 2535 }
2536 return lse; 2536 return lse;
2537} 2537}
2538int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2538int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2539{ 2539{
2540 2540
2541 //void setZaurusId(int id); 2541 //void setZaurusId(int id);
2542 // int zaurusId() const; 2542 // int zaurusId() const;
2543 // void setZaurusUid(int id); 2543 // void setZaurusUid(int id);
2544 // int zaurusUid() const; 2544 // int zaurusUid() const;
2545 // void setZaurusStat(int id); 2545 // void setZaurusStat(int id);
2546 // int zaurusStat() const; 2546 // int zaurusStat() const;
2547 // 0 equal 2547 // 0 equal
2548 // 1 take local 2548 // 1 take local
2549 // 2 take remote 2549 // 2 take remote
2550 // 3 cancel 2550 // 3 cancel
2551 QDateTime lastSync = mLastAddressbookSync; 2551 QDateTime lastSync = mLastAddressbookSync;
2552 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2552 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2553 bool remCh, locCh; 2553 bool remCh, locCh;
2554 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2554 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2555 //if ( remCh ) 2555 //if ( remCh )
2556 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2556 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2557 locCh = ( local->revision() > mLastAddressbookSync ); 2557 locCh = ( local->revision() > mLastAddressbookSync );
2558 if ( !remCh && ! locCh ) { 2558 if ( !remCh && ! locCh ) {
2559 //qDebug("both not changed "); 2559 //qDebug("both not changed ");
2560 lastSync = local->revision().addDays(1); 2560 lastSync = local->revision().addDays(1);
2561 } else { 2561 } else {
2562 if ( locCh ) { 2562 if ( locCh ) {
2563 //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); 2563 //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1());
2564 lastSync = local->revision().addDays( -1 ); 2564 lastSync = local->revision().addDays( -1 );
2565 if ( !remCh ) 2565 if ( !remCh )
2566 remote->setRevision( lastSync.addDays( -1 ) ); 2566 remote->setRevision( lastSync.addDays( -1 ) );
2567 } else { 2567 } else {
2568 //qDebug(" not loc changed "); 2568 //qDebug(" not loc changed ");
2569 lastSync = local->revision().addDays( 1 ); 2569 lastSync = local->revision().addDays( 1 );
2570 if ( remCh ) 2570 if ( remCh )
2571 remote->setRevision( lastSync.addDays( 1 ) ); 2571 remote->setRevision( lastSync.addDays( 1 ) );
2572 2572
2573 } 2573 }
2574 } 2574 }
2575 full = true; 2575 full = true;
2576 if ( mode < SYNC_PREF_ASK ) 2576 if ( mode < SYNC_PREF_ASK )
2577 mode = SYNC_PREF_ASK; 2577 mode = SYNC_PREF_ASK;
2578 } else { 2578 } else {
2579 if ( local->revision() == remote->revision() ) 2579 if ( local->revision() == remote->revision() )
2580 return 0; 2580 return 0;
2581 2581
2582 } 2582 }
2583 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2583 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2584 2584
2585 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 2585 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
2586 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2586 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2587 //full = true; //debug only 2587 //full = true; //debug only
2588 if ( full ) { 2588 if ( full ) {
2589 bool equ = ( (*local) == (*remote) ); 2589 bool equ = ( (*local) == (*remote) );
2590 if ( equ ) { 2590 if ( equ ) {
2591 //qDebug("equal "); 2591 //qDebug("equal ");
2592 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2592 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2593 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2593 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2594 } 2594 }
2595 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2595 if ( mode < SYNC_PREF_FORCE_LOCAL )
2596 return 0; 2596 return 0;
2597 2597
2598 }//else //debug only 2598 }//else //debug only
2599 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2599 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2600 } 2600 }
2601 int result; 2601 int result;
2602 bool localIsNew; 2602 bool localIsNew;
2603 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2603 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2604 2604
2605 if ( full && mode < SYNC_PREF_NEWEST ) 2605 if ( full && mode < SYNC_PREF_NEWEST )
2606 mode = SYNC_PREF_ASK; 2606 mode = SYNC_PREF_ASK;
2607 2607
2608 switch( mode ) { 2608 switch( mode ) {
2609 case SYNC_PREF_LOCAL: 2609 case SYNC_PREF_LOCAL:
2610 if ( lastSync > remote->revision() ) 2610 if ( lastSync > remote->revision() )
2611 return 1; 2611 return 1;
2612 if ( lastSync > local->revision() ) 2612 if ( lastSync > local->revision() )
2613 return 2; 2613 return 2;
2614 return 1; 2614 return 1;
2615 break; 2615 break;
2616 case SYNC_PREF_REMOTE: 2616 case SYNC_PREF_REMOTE:
2617 if ( lastSync > remote->revision() ) 2617 if ( lastSync > remote->revision() )
2618 return 1; 2618 return 1;
2619 if ( lastSync > local->revision() ) 2619 if ( lastSync > local->revision() )
2620 return 2; 2620 return 2;
2621 return 2; 2621 return 2;
2622 break; 2622 break;
2623 case SYNC_PREF_NEWEST: 2623 case SYNC_PREF_NEWEST:
2624 if ( local->revision() > remote->revision() ) 2624 if ( local->revision() > remote->revision() )
2625 return 1; 2625 return 1;
2626 else 2626 else
2627 return 2; 2627 return 2;
2628 break; 2628 break;
2629 case SYNC_PREF_ASK: 2629 case SYNC_PREF_ASK:
2630 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); 2630 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() );
2631 if ( lastSync > remote->revision() ) 2631 if ( lastSync > remote->revision() )
2632 return 1; 2632 return 1;
2633 if ( lastSync > local->revision() ) 2633 if ( lastSync > local->revision() )
2634 return 2; 2634 return 2;
2635 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() );
2636 localIsNew = local->revision() >= remote->revision(); 2635 localIsNew = local->revision() >= remote->revision();
2637#if 0 2636 //qDebug("conflict! ************************************** ");
2638 if ( localIsNew )
2639 getEventViewerDialog()->setColorMode( 1 );
2640 else
2641 getEventViewerDialog()->setColorMode( 2 );
2642 getEventViewerDialog()->setIncidence(local);
2643 if ( localIsNew )
2644 getEventViewerDialog()->setColorMode( 2 );
2645 else
2646 getEventViewerDialog()->setColorMode( 1 );
2647 getEventViewerDialog()->addIncidence(remote);
2648 getEventViewerDialog()->setColorMode( 0 );
2649 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
2650 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
2651 getEventViewerDialog()->showMe();
2652 result = getEventViewerDialog()->executeS( localIsNew );
2653#endif
2654 qDebug("conflict! ************************************** ");
2655 { 2637 {
2656 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2638 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2657 result = acd.executeD(localIsNew); 2639 result = acd.executeD(localIsNew);
2658 return result; 2640 return result;
2659 } 2641 }
2660 break; 2642 break;
2661 case SYNC_PREF_FORCE_LOCAL: 2643 case SYNC_PREF_FORCE_LOCAL:
2662 return 1; 2644 return 1;
2663 break; 2645 break;
2664 case SYNC_PREF_FORCE_REMOTE: 2646 case SYNC_PREF_FORCE_REMOTE:
2665 return 2; 2647 return 2;
2666 break; 2648 break;
2667 2649
2668 default: 2650 default:
2669 // SYNC_PREF_TAKE_BOTH not implemented 2651 // SYNC_PREF_TAKE_BOTH not implemented
2670 break; 2652 break;
2671 } 2653 }
2672 return 0; 2654 return 0;
2673} 2655}
2674bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2656bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2675{ 2657{
2676 bool syncOK = true; 2658 bool syncOK = true;
2677 int addedAddressee = 0; 2659 int addedAddressee = 0;
2678 int addedAddresseeR = 0; 2660 int addedAddresseeR = 0;
2679 int deletedAddresseeR = 0; 2661 int deletedAddresseeR = 0;
2680 int deletedAddresseeL = 0; 2662 int deletedAddresseeL = 0;
2681 int changedLocal = 0; 2663 int changedLocal = 0;
2682 int changedRemote = 0; 2664 int changedRemote = 0;
2683 //QPtrList<Addressee> el = local->rawAddressees(); 2665 //QPtrList<Addressee> el = local->rawAddressees();
2684 Addressee addresseeR; 2666 Addressee addresseeR;
2685 QString uid; 2667 QString uid;
2686 int take; 2668 int take;
2687 Addressee addresseeL; 2669 Addressee addresseeL;
2688 Addressee addresseeRSync; 2670 Addressee addresseeRSync;
2689 Addressee addresseeLSync; 2671 Addressee addresseeLSync;
2690 KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2672 KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2691 KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2673 KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2692 bool fullDateRange = false; 2674 bool fullDateRange = false;
2693 local->resetTempSyncStat(); 2675 local->resetTempSyncStat();
2694 mLastAddressbookSync = QDateTime::currentDateTime(); 2676 mLastAddressbookSync = QDateTime::currentDateTime();
2695 QDateTime modifiedCalendar = mLastAddressbookSync;; 2677 QDateTime modifiedCalendar = mLastAddressbookSync;;
2696 addresseeLSync = getLastSyncAddressee(); 2678 addresseeLSync = getLastSyncAddressee();
2697 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2679 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2698 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2680 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2699 if ( !addresseeR.isEmpty() ) { 2681 if ( !addresseeR.isEmpty() ) {
2700 addresseeRSync = addresseeR; 2682 addresseeRSync = addresseeR;
2701 remote->removeAddressee(addresseeR ); 2683 remote->removeAddressee(addresseeR );
2702 2684
2703 } else { 2685 } else {
2704 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2686 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2705 addresseeRSync = addresseeLSync ; 2687 addresseeRSync = addresseeLSync ;
2706 } else { 2688 } else {
2707 qDebug("FULLDATE 1"); 2689 qDebug("FULLDATE 1");
2708 fullDateRange = true; 2690 fullDateRange = true;
2709 Addressee newAdd; 2691 Addressee newAdd;
2710 addresseeRSync = newAdd; 2692 addresseeRSync = newAdd;
2711 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2693 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2712 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2694 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2713 addresseeRSync.setRevision( mLastAddressbookSync ); 2695 addresseeRSync.setRevision( mLastAddressbookSync );
2714 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2696 addresseeRSync.setCategories( i18n("SyncAddressee") );
2715 } 2697 }
2716 } 2698 }
2717 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2699 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2718 qDebug("FULLDATE 2"); 2700 qDebug("FULLDATE 2");
2719 fullDateRange = true; 2701 fullDateRange = true;
2720 } 2702 }
2721 if ( ! fullDateRange ) { 2703 if ( ! fullDateRange ) {
2722 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2704 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2723 2705
2724 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2706 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2725 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2707 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2726 fullDateRange = true; 2708 fullDateRange = true;
2727 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2709 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2728 } 2710 }
2729 } 2711 }
2730 fullDateRange = true; // debug only! 2712 fullDateRange = true; // debug only!
2731 if ( fullDateRange ) 2713 if ( fullDateRange )
2732 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2714 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2733 else 2715 else
2734 mLastAddressbookSync = addresseeLSync.revision(); 2716 mLastAddressbookSync = addresseeLSync.revision();
2735 // for resyncing if own file has changed 2717 // for resyncing if own file has changed
2736 // PENDING fixme later when implemented 2718 // PENDING fixme later when implemented
2737#if 0 2719#if 0
2738 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2720 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2739 mLastAddressbookSync = loadedFileVersion; 2721 mLastAddressbookSync = loadedFileVersion;
2740 qDebug("setting mLastAddressbookSync "); 2722 qDebug("setting mLastAddressbookSync ");
2741 } 2723 }
2742#endif 2724#endif
2743 2725
2744 //qDebug("*************************** "); 2726 //qDebug("*************************** ");
2745 qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2727 qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2746 QStringList er = remote->uidList(); 2728 QStringList er = remote->uidList();
2747 Addressee inR ;//= er.first(); 2729 Addressee inR ;//= er.first();
2748 Addressee inL; 2730 Addressee inL;
2749 QProgressBar bar( er.count(),0 ); 2731 QProgressBar bar( er.count(),0 );
2750 bar.setCaption (i18n("Syncing - close to abort!") ); 2732 bar.setCaption (i18n("Syncing - close to abort!") );
2751 2733
2752 int w = 300; 2734 int w = 300;
2753 if ( QApplication::desktop()->width() < 320 ) 2735 if ( QApplication::desktop()->width() < 320 )
2754 w = 220; 2736 w = 220;
2755 int h = bar.sizeHint().height() ; 2737 int h = bar.sizeHint().height() ;
2756 int dw = QApplication::desktop()->width(); 2738 int dw = QApplication::desktop()->width();
2757 int dh = QApplication::desktop()->height(); 2739 int dh = QApplication::desktop()->height();
2758 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2740 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2759 bar.show(); 2741 bar.show();
2760 int modulo = (er.count()/10)+1; 2742 int modulo = (er.count()/10)+1;
2761 int incCounter = 0; 2743 int incCounter = 0;
2762 while ( incCounter < er.count()) { 2744 while ( incCounter < er.count()) {
2763 if ( ! bar.isVisible() ) 2745 if ( ! bar.isVisible() )
2764 return false; 2746 return false;
2765 if ( incCounter % modulo == 0 ) 2747 if ( incCounter % modulo == 0 )
2766 bar.setProgress( incCounter ); 2748 bar.setProgress( incCounter );
2767 uid = er[ incCounter ]; 2749 uid = er[ incCounter ];
2768 bool skipIncidence = false; 2750 bool skipIncidence = false;
2769 if ( uid.left(19) == QString("last-syncAddressee-") ) 2751 if ( uid.left(19) == QString("last-syncAddressee-") )
2770 skipIncidence = true; 2752 skipIncidence = true;
2771 QString idS; 2753 QString idS;
2772 qApp->processEvents(); 2754 qApp->processEvents();
2773 if ( !skipIncidence ) { 2755 if ( !skipIncidence ) {
2774 inL = local->findByUid( uid ); 2756 inL = local->findByUid( uid );
2775 inR = remote->findByUid( uid ); 2757 inR = remote->findByUid( uid );
2776 //inL.setResource( 0 ); 2758 //inL.setResource( 0 );
2777 //inR.setResource( 0 ); 2759 //inR.setResource( 0 );
2778 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2760 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2779 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2761 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2780 //qDebug("take %d %s ", take, inL.summary().latin1()); 2762 //qDebug("take %d %s ", take, inL.summary().latin1());
2781 if ( take == 3 ) 2763 if ( take == 3 )
2782 return false; 2764 return false;
2783 if ( take == 1 ) {// take local 2765 if ( take == 1 ) {// take local
2784 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2766 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2785 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2767 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2786 local->insertAddressee( inL, false ); 2768 local->insertAddressee( inL, false );
2787 } 2769 }
2788 else 2770 else
2789 idS = inR.IDStr(); 2771 idS = inR.IDStr();
2790 remote->removeAddressee( inR ); 2772 remote->removeAddressee( inR );
2791 inR = inL; 2773 inR = inL;
2792 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2774 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2793 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 2775 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
2794 inR.setIDStr( idS ); 2776 inR.setIDStr( idS );
2795 inR.setResource( 0 ); 2777 inR.setResource( 0 );
2796 remote->insertAddressee( inR , false); 2778 remote->insertAddressee( inR , false);
2797 ++changedRemote; 2779 ++changedRemote;
2798 } else { 2780 } else {
2799 idS = inL.IDStr(); 2781 idS = inL.IDStr();
2800 local->removeAddressee( inL ); 2782 local->removeAddressee( inL );
2801 inL = inR; 2783 inL = inR;
2802 inL.setIDStr( idS ); 2784 inL.setIDStr( idS );
2803 inL.setResource( 0 ); 2785 inL.setResource( 0 );
2804 local->insertAddressee( inL , false ); 2786 local->insertAddressee( inL , false );
2805 ++changedLocal; 2787 ++changedLocal;
2806 } 2788 }
2807 } 2789 }
2808 } else { // no conflict 2790 } else { // no conflict
2809 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2791 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2810 QString des = addresseeLSync.note(); 2792 QString des = addresseeLSync.note();
2811 QString pref = "a"; 2793 QString pref = "a";
2812 if ( des.find(pref+ inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2794 if ( des.find(pref+ inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2813 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2795 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2814 ++deletedAddresseeR; 2796 ++deletedAddresseeR;
2815 } else { 2797 } else {
2816 inR.setRevision( modifiedCalendar ); 2798 inR.setRevision( modifiedCalendar );
2817 remote->insertAddressee( inR, false ); 2799 remote->insertAddressee( inR, false );
2818 inL = inR; 2800 inL = inR;
2819 inL.setResource( 0 ); 2801 inL.setResource( 0 );
2820 local->insertAddressee( inL , false); 2802 local->insertAddressee( inL , false);
2821 ++addedAddressee; 2803 ++addedAddressee;
2822 } 2804 }
2823 } else { 2805 } else {
2824 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2806 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2825 inR.setRevision( modifiedCalendar ); 2807 inR.setRevision( modifiedCalendar );
2826 remote->insertAddressee( inR, false ); 2808 remote->insertAddressee( inR, false );
2827 inR.setResource( 0 ); 2809 inR.setResource( 0 );
2828 local->insertAddressee( inR, false ); 2810 local->insertAddressee( inR, false );
2829 ++addedAddressee; 2811 ++addedAddressee;
2830 } else { 2812 } else {
2831 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2813 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2832 remote->removeAddressee( inR ); 2814 remote->removeAddressee( inR );
2833 ++deletedAddresseeR; 2815 ++deletedAddresseeR;
2834 } 2816 }
2835 } 2817 }
2836 } 2818 }
2837 } 2819 }
2838 ++incCounter; 2820 ++incCounter;
2839 } 2821 }
2840 er.clear(); 2822 er.clear();
2841 QStringList el = remote->uidList(); 2823 QStringList el = remote->uidList();
2842 modulo = (el.count()/10)+1; 2824 modulo = (el.count()/10)+1;
2843 bar.setCaption (i18n("Add / remove addressees") ); 2825 bar.setCaption (i18n("Add / remove addressees") );
2844 bar.setTotalSteps ( el.count() ) ; 2826 bar.setTotalSteps ( el.count() ) ;
2845 bar.show(); 2827 bar.show();
2846 incCounter = 0; 2828 incCounter = 0;
2847 while ( incCounter < el.count()) { 2829 while ( incCounter < el.count()) {
2848 2830
2849 qApp->processEvents(); 2831 qApp->processEvents();
2850 if ( ! bar.isVisible() ) 2832 if ( ! bar.isVisible() )
2851 return false; 2833 return false;
2852 if ( incCounter % modulo == 0 ) 2834 if ( incCounter % modulo == 0 )
2853 bar.setProgress( incCounter ); 2835 bar.setProgress( incCounter );
2854 uid = el[ incCounter ]; 2836 uid = el[ incCounter ];
2855 bool skipIncidence = false; 2837 bool skipIncidence = false;
2856 if ( uid.left(19) == QString("last-syncAddressee-") ) 2838 if ( uid.left(19) == QString("last-syncAddressee-") )
2857 skipIncidence = true; 2839 skipIncidence = true;
2858 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2840 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2859 skipIncidence = true; 2841 skipIncidence = true;
2860 if ( !skipIncidence ) { 2842 if ( !skipIncidence ) {
2861 inL = local->findByUid( uid ); 2843 inL = local->findByUid( uid );
2862 inR = remote->findByUid( uid ); 2844 inR = remote->findByUid( uid );
2863 if ( inR.isEmpty() ) { 2845 if ( inR.isEmpty() ) {
2864 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2846 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2865 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2847 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2866 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2848 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2867 local->removeAddressee( inL ); 2849 local->removeAddressee( inL );
2868 ++deletedAddresseeL; 2850 ++deletedAddresseeL;
2869 } else { 2851 } else {
2870 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2852 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2871 inL.removeID(mCurrentSyncDevice ); 2853 inL.removeID(mCurrentSyncDevice );
2872 ++addedAddresseeR; 2854 ++addedAddresseeR;
2873 //qDebug("remote added Incidence %s ", inL.summary().latin1()); 2855 //qDebug("remote added Incidence %s ", inL.summary().latin1());
2874 inL.setRevision( modifiedCalendar ); 2856 inL.setRevision( modifiedCalendar );
2875 local->insertAddressee( inL, false ); 2857 local->insertAddressee( inL, false );
2876 inR = inL; 2858 inR = inL;
2877 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2859 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2878 inR.setResource( 0 ); 2860 inR.setResource( 0 );
2879 remote->insertAddressee( inR, false ); 2861 remote->insertAddressee( inR, false );
2880 } 2862 }
2881 } 2863 }
2882 } else { 2864 } else {
2883 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2865 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2884 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2866 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2885 local->removeAddressee( inL ); 2867 local->removeAddressee( inL );
2886 ++deletedAddresseeL; 2868 ++deletedAddresseeL;
2887 } else { 2869 } else {
2888 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2870 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2889 ++addedAddresseeR; 2871 ++addedAddresseeR;
2890 inL.setRevision( modifiedCalendar ); 2872 inL.setRevision( modifiedCalendar );
2891 local->insertAddressee( inL, false ); 2873 local->insertAddressee( inL, false );
2892 inR = inL; 2874 inR = inL;
2893 inR.setResource( 0 ); 2875 inR.setResource( 0 );
2894 remote->insertAddressee( inR, false ); 2876 remote->insertAddressee( inR, false );
2895 } 2877 }
2896 } 2878 }
2897 } 2879 }
2898 } 2880 }
2899 } 2881 }
2900 ++incCounter; 2882 ++incCounter;
2901 } 2883 }
2902 el.clear(); 2884 el.clear();
2903 bar.hide(); 2885 bar.hide();
2904 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2886 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2905 // get rid of micro seconds 2887 // get rid of micro seconds
2906 QTime t = mLastAddressbookSync.time(); 2888 QTime t = mLastAddressbookSync.time();
2907 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2889 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2908 addresseeLSync.setRevision( mLastAddressbookSync ); 2890 addresseeLSync.setRevision( mLastAddressbookSync );
2909 addresseeRSync.setRevision( mLastAddressbookSync ); 2891 addresseeRSync.setRevision( mLastAddressbookSync );
2910 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2892 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2911 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2893 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2912 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2894 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2913 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2895 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2914 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2896 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2915 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2897 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2916 2898
2917 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2899 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2918 remote->insertAddressee( addresseeRSync, false ); 2900 remote->insertAddressee( addresseeRSync, false );
2919 local->insertAddressee( addresseeLSync, false ); 2901 local->insertAddressee( addresseeLSync, false );
2920 QString mes; 2902 QString mes;
2921 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2903 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2922 if ( KABPrefs::instance()->mShowSyncSummary ) { 2904 if ( KABPrefs::instance()->mShowSyncSummary ) {
2923 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2905 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2924 } 2906 }
2925 qDebug( mes ); 2907 qDebug( mes );
2926 return syncOK; 2908 return syncOK;
2927} 2909}
2928 2910
2929bool KABCore::syncAB(QString filename, int mode) 2911bool KABCore::syncAB(QString filename, int mode)
2930{ 2912{
2931 2913
2932 //pending prepare addresseeview for output 2914 //pending prepare addresseeview for output
2933 //pending detect, if remote file has REV field. if not switch to external sync 2915 //pending detect, if remote file has REV field. if not switch to external sync
2934 mGlobalSyncMode = SYNC_MODE_NORMAL; 2916 mGlobalSyncMode = SYNC_MODE_NORMAL;
2935 AddressBook abLocal(filename,"syncContact"); 2917 AddressBook abLocal(filename,"syncContact");
2936 bool syncOK = false; 2918 bool syncOK = false;
2937 if ( abLocal.load() ) { 2919 if ( abLocal.load() ) {
2938 qDebug("AB loaded %s mode %d",filename.latin1(), mode ); 2920 qDebug("AB loaded %s mode %d",filename.latin1(), mode );
2939 AddressBook::Iterator it; 2921 AddressBook::Iterator it;
2940 //QStringList vcards; 2922 //QStringList vcards;
2941 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2923 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2942 // qDebug("Name %s ", (*it).familyName().latin1()); 2924 // qDebug("Name %s ", (*it).familyName().latin1());
2943 //} 2925 //}
2944 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2926 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2945 if ( syncOK ) { 2927 if ( syncOK ) {
2946 if ( KABPrefs::instance()->mWriteBackFile ) 2928 if ( KABPrefs::instance()->mWriteBackFile )
2947 { 2929 {
2948 qDebug("saving remote AB "); 2930 qDebug("saving remote AB ");
2949 abLocal.saveAB(); 2931 abLocal.saveAB();
2950 } 2932 }
2951 } 2933 }
2952 setModified(); 2934 setModified();
2953 2935
2954 } 2936 }
2955 if ( syncOK ) 2937 if ( syncOK )
2956 mViewManager->refreshView(); 2938 mViewManager->refreshView();
2957 return syncOK; 2939 return syncOK;
2958#if 0 2940#if 0
2959 2941
2960 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2942 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2961 getEventViewerDialog()->setSyncMode( true ); 2943 getEventViewerDialog()->setSyncMode( true );
2962 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2944 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2963 getEventViewerDialog()->setSyncMode( false ); 2945 getEventViewerDialog()->setSyncMode( false );
2964 if ( syncOK ) { 2946 if ( syncOK ) {
2965 if ( KOPrefs::instance()->mWriteBackFile ) 2947 if ( KOPrefs::instance()->mWriteBackFile )
2966 { 2948 {
2967 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2949 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2968 storage->save(); 2950 storage->save();
2969 } 2951 }
2970 } 2952 }
2971 setModified(); 2953 setModified();
2972 } 2954 }
2973 2955
2974#endif 2956#endif
2975} 2957}
2976 2958
2977
2978void KABCore::confSync() 2959void KABCore::confSync()
2979{ 2960{
2980 static KSyncPrefsDialog* sp = 0; 2961 static KSyncPrefsDialog* sp = 0;
2981 if ( ! sp ) { 2962 if ( ! sp ) {
2982 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 2963 sp = new KSyncPrefsDialog( this, "syncprefs", true );
2983 } 2964 }
2984 sp->usrReadConfig(); 2965 sp->usrReadConfig();
2985#ifndef DESKTOP_VERSION 2966#ifndef DESKTOP_VERSION
2986 sp->showMaximized(); 2967 sp->showMaximized();
2987#else 2968#else
2988 sp->show(); 2969 sp->show();
2989#endif 2970#endif
2990 sp->exec(); 2971 sp->exec();
2991 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 2972 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
2992 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 2973 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
2993 fillSyncMenu(); 2974 fillSyncMenu();
2994} 2975}
2995void KABCore::syncSharp() 2976void KABCore::syncSharp()
2996{ 2977{
2997 if ( mModified ) 2978 if ( mModified )
2998 save(); 2979 save();
2999 qDebug("pending syncSharp() "); 2980 qDebug("pending syncSharp() ");
3000 //mView->syncSharp(); 2981 //mView->syncSharp();
3001 setModified(); 2982 setModified();
3002 2983
3003} 2984}
3004void KABCore::syncPhone() 2985void KABCore::syncPhone()
3005{ 2986{
3006 if ( mModified ) 2987 if ( mModified )
3007 save(); 2988 save();
3008 qDebug("pending syncPhone(); "); 2989 qDebug("pending syncPhone(); ");
3009 //mView->syncPhone(); 2990 //mView->syncPhone();
3010 setModified(); 2991 setModified();
3011 2992
3012} 2993}