summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp13
-rw-r--r--kabc/addressee.h2
-rw-r--r--kabc/plugins/qtopia/qtopiaE.pro2
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp7
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.h1
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp78
-rw-r--r--kaddressbook/kabcore.cpp87
-rw-r--r--libkcal/sharpformat.cpp6
-rw-r--r--libkcal/syncdefines.h2
9 files changed, 141 insertions, 57 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 3a2dc5f..fda62f1 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,1143 +1,1156 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@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/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46 46
47struct Addressee::AddresseeData : public KShared 47struct Addressee::AddresseeData : public KShared
48{ 48{
49 QString uid; 49 QString uid;
50 QString name; 50 QString name;
51 QString formattedName; 51 QString formattedName;
52 QString familyName; 52 QString familyName;
53 QString givenName; 53 QString givenName;
54 QString additionalName; 54 QString additionalName;
55 QString prefix; 55 QString prefix;
56 QString suffix; 56 QString suffix;
57 QString nickName; 57 QString nickName;
58 QDateTime birthday; 58 QDateTime birthday;
59 QString mailer; 59 QString mailer;
60 TimeZone timeZone; 60 TimeZone timeZone;
61 Geo geo; 61 Geo geo;
62 QString title; 62 QString title;
63 QString role; 63 QString role;
64 QString organization; 64 QString organization;
65 QString note; 65 QString note;
66 QString productId; 66 QString productId;
67 QDateTime revision; 67 QDateTime revision;
68 QString sortString; 68 QString sortString;
69 QString externalUID; 69 QString externalUID;
70 QString originalExternalUID;
70 KURL url; 71 KURL url;
71 Secrecy secrecy; 72 Secrecy secrecy;
72 Picture logo; 73 Picture logo;
73 Picture photo; 74 Picture photo;
74 Sound sound; 75 Sound sound;
75 Agent agent; 76 Agent agent;
76 QString mExternalId; 77 QString mExternalId;
77 PhoneNumber::List phoneNumbers; 78 PhoneNumber::List phoneNumbers;
78 Address::List addresses; 79 Address::List addresses;
79 Key::List keys; 80 Key::List keys;
80 QStringList emails; 81 QStringList emails;
81 QStringList categories; 82 QStringList categories;
82 QStringList custom; 83 QStringList custom;
83 int mTempSyncStat; 84 int mTempSyncStat;
84 Resource *resource; 85 Resource *resource;
85 86
86 bool empty :1; 87 bool empty :1;
87 bool changed :1; 88 bool changed :1;
88}; 89};
89 90
90Addressee::Addressee() 91Addressee::Addressee()
91{ 92{
92 mData = new AddresseeData; 93 mData = new AddresseeData;
93 mData->empty = true; 94 mData->empty = true;
94 mData->changed = false; 95 mData->changed = false;
95 mData->resource = 0; 96 mData->resource = 0;
96 mData->mExternalId = ":"; 97 mData->mExternalId = ":";
97 mData->revision = QDateTime ( QDate( 2004,1,1)); 98 mData->revision = QDateTime ( QDate( 2004,1,1));
98 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 99 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
99} 100}
100 101
101Addressee::~Addressee() 102Addressee::~Addressee()
102{ 103{
103} 104}
104 105
105Addressee::Addressee( const Addressee &a ) 106Addressee::Addressee( const Addressee &a )
106{ 107{
107 mData = a.mData; 108 mData = a.mData;
108} 109}
109 110
110Addressee &Addressee::operator=( const Addressee &a ) 111Addressee &Addressee::operator=( const Addressee &a )
111{ 112{
112 mData = a.mData; 113 mData = a.mData;
113 return (*this); 114 return (*this);
114} 115}
115 116
116Addressee Addressee::copy() 117Addressee Addressee::copy()
117{ 118{
118 Addressee a; 119 Addressee a;
119 *(a.mData) = *mData; 120 *(a.mData) = *mData;
120 return a; 121 return a;
121} 122}
122 123
123void Addressee::detach() 124void Addressee::detach()
124{ 125{
125 if ( mData.count() == 1 ) return; 126 if ( mData.count() == 1 ) return;
126 *this = copy(); 127 *this = copy();
127} 128}
128 129
129bool Addressee::operator==( const Addressee &a ) const 130bool Addressee::operator==( const Addressee &a ) const
130{ 131{
131 if ( uid() != a.uid() ) return false; 132 if ( uid() != a.uid() ) return false;
132 if ( mData->name != a.mData->name ) return false; 133 if ( mData->name != a.mData->name ) return false;
133 if ( mData->formattedName != a.mData->formattedName ) return false; 134 if ( mData->formattedName != a.mData->formattedName ) return false;
134 if ( mData->familyName != a.mData->familyName ) return false; 135 if ( mData->familyName != a.mData->familyName ) return false;
135 if ( mData->givenName != a.mData->givenName ) return false; 136 if ( mData->givenName != a.mData->givenName ) return false;
136 if ( mData->additionalName != a.mData->additionalName ) return false; 137 if ( mData->additionalName != a.mData->additionalName ) return false;
137 if ( mData->prefix != a.mData->prefix ) return false; 138 if ( mData->prefix != a.mData->prefix ) return false;
138 if ( mData->suffix != a.mData->suffix ) return false; 139 if ( mData->suffix != a.mData->suffix ) return false;
139 if ( mData->nickName != a.mData->nickName ) return false; 140 if ( mData->nickName != a.mData->nickName ) return false;
140 if ( mData->birthday != a.mData->birthday ) return false; 141 if ( mData->birthday != a.mData->birthday ) return false;
141 if ( mData->mailer != a.mData->mailer ) return false; 142 if ( mData->mailer != a.mData->mailer ) return false;
142 if ( mData->timeZone != a.mData->timeZone ) return false; 143 if ( mData->timeZone != a.mData->timeZone ) return false;
143 if ( mData->geo != a.mData->geo ) return false; 144 if ( mData->geo != a.mData->geo ) return false;
144 if ( mData->title != a.mData->title ) return false; 145 if ( mData->title != a.mData->title ) return false;
145 if ( mData->role != a.mData->role ) return false; 146 if ( mData->role != a.mData->role ) return false;
146 if ( mData->organization != a.mData->organization ) return false; 147 if ( mData->organization != a.mData->organization ) return false;
147 if ( mData->note != a.mData->note ) return false; 148 if ( mData->note != a.mData->note ) return false;
148 if ( mData->productId != a.mData->productId ) return false; 149 if ( mData->productId != a.mData->productId ) return false;
149 //if ( mData->revision != a.mData->revision ) return false; 150 //if ( mData->revision != a.mData->revision ) return false;
150 if ( mData->sortString != a.mData->sortString ) return false; 151 if ( mData->sortString != a.mData->sortString ) return false;
151 if ( mData->secrecy != a.mData->secrecy ) return false; 152 if ( mData->secrecy != a.mData->secrecy ) return false;
152 if ( mData->logo != a.mData->logo ) return false; 153 if ( mData->logo != a.mData->logo ) return false;
153 if ( mData->photo != a.mData->photo ) return false; 154 if ( mData->photo != a.mData->photo ) return false;
154 if ( mData->sound != a.mData->sound ) return false; 155 if ( mData->sound != a.mData->sound ) return false;
155 if ( mData->agent != a.mData->agent ) return false; 156 if ( mData->agent != a.mData->agent ) return false;
156 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 157 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
157 ( mData->url != a.mData->url ) ) return false; 158 ( mData->url != a.mData->url ) ) return false;
158 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 159 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
159 if ( mData->addresses != a.mData->addresses ) return false; 160 if ( mData->addresses != a.mData->addresses ) return false;
160 if ( mData->keys != a.mData->keys ) return false; 161 if ( mData->keys != a.mData->keys ) return false;
161 if ( mData->emails != a.mData->emails ) return false; 162 if ( mData->emails != a.mData->emails ) return false;
162 if ( mData->categories != a.mData->categories ) return false; 163 if ( mData->categories != a.mData->categories ) return false;
163 if ( mData->custom != a.mData->custom ) return false; 164 if ( mData->custom != a.mData->custom ) return false;
164 165
165 return true; 166 return true;
166} 167}
167 168
168bool Addressee::operator!=( const Addressee &a ) const 169bool Addressee::operator!=( const Addressee &a ) const
169{ 170{
170 return !( a == *this ); 171 return !( a == *this );
171} 172}
172 173
173bool Addressee::isEmpty() const 174bool Addressee::isEmpty() const
174{ 175{
175 return mData->empty; 176 return mData->empty;
176} 177}
177ulong Addressee::getCsum4List( const QStringList & attList) 178ulong Addressee::getCsum4List( const QStringList & attList)
178{ 179{
179 int max = attList.count(); 180 int max = attList.count();
180 ulong cSum = 0; 181 ulong cSum = 0;
181 int j,k,i; 182 int j,k,i;
182 int add; 183 int add;
183 for ( i = 0; i < max ; ++i ) { 184 for ( i = 0; i < max ; ++i ) {
184 QString s = attList[i]; 185 QString s = attList[i];
185 if ( ! s.isEmpty() ){ 186 if ( ! s.isEmpty() ){
186 j = s.length(); 187 j = s.length();
187 for ( k = 0; k < j; ++k ) { 188 for ( k = 0; k < j; ++k ) {
188 int mul = k +1; 189 int mul = k +1;
189 add = s[k].unicode (); 190 add = s[k].unicode ();
190 if ( k < 16 ) 191 if ( k < 16 )
191 mul = mul * mul; 192 mul = mul * mul;
192 int ii = i+1; 193 int ii = i+1;
193 add = add * mul *ii*ii*ii; 194 add = add * mul *ii*ii*ii;
194 cSum += add; 195 cSum += add;
195 } 196 }
196 } 197 }
197 198
198 } 199 }
199 //QString dump = attList.join(","); 200 //QString dump = attList.join(",");
200 //qDebug("csum: %d %s", cSum,dump.latin1()); 201 //qDebug("csum: %d %s", cSum,dump.latin1());
201 202
202 return cSum; 203 return cSum;
203 204
204} 205}
205void Addressee::computeCsum(const QString &dev) 206void Addressee::computeCsum(const QString &dev)
206{ 207{
207 QStringList l; 208 QStringList l;
208 if ( !mData->name.isEmpty() ) l.append(mData->name); 209 if ( !mData->name.isEmpty() ) l.append(mData->name);
209 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 210 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
210 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 211 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
211 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 212 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
212 if ( !mData->additionalName ) l.append( mData->additionalName ); 213 if ( !mData->additionalName ) l.append( mData->additionalName );
213 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 214 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
214 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 215 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
215 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 216 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
216 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 217 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
217 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 218 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
218 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 219 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
219 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 220 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
220 if ( !mData->title .isEmpty() ) l.append( mData->title ); 221 if ( !mData->title .isEmpty() ) l.append( mData->title );
221 if ( !mData->role.isEmpty() ) l.append( mData->role ); 222 if ( !mData->role.isEmpty() ) l.append( mData->role );
222 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 223 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
223 if ( !mData->note.isEmpty() ) l.append( mData->note ); 224 if ( !mData->note.isEmpty() ) l.append( mData->note );
224 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 225 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
225 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 226 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
226 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 227 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
227 // if ( !mData->logo.isEmpty() ) l.append( ); 228 // if ( !mData->logo.isEmpty() ) l.append( );
228 //if ( !mData->photo.isEmpty() ) l.append( ); 229 //if ( !mData->photo.isEmpty() ) l.append( );
229 //if ( !mData->sound.isEmpty() ) l.append( ); 230 //if ( !mData->sound.isEmpty() ) l.append( );
230 //if ( !mData->agent.isEmpty() ) l.append( ); 231 //if ( !mData->agent.isEmpty() ) l.append( );
231 //if ( mData->url.isValid() ) l.append( ); 232 //if ( mData->url.isValid() ) l.append( );
232#if 0 233#if 0
233 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 234 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
234 if ( !mData->addresses.isEmpty() ) l.append( ); 235 if ( !mData->addresses.isEmpty() ) l.append( );
235 //if ( !mData->keys.isEmpty() ) l.append( ); 236 //if ( !mData->keys.isEmpty() ) l.append( );
236 if ( !mData->emails.isEmpty() ) l.append( ); 237 if ( !mData->emails.isEmpty() ) l.append( );
237 if ( !mData->categories .isEmpty() ) l.append( ); 238 if ( !mData->categories .isEmpty() ) l.append( );
238 if ( !mData->custom.isEmpty() ) l.append( ); 239 if ( !mData->custom.isEmpty() ) l.append( );
239#endif 240#endif
240 KABC::PhoneNumber::List phoneNumbers; 241 KABC::PhoneNumber::List phoneNumbers;
241 KABC::PhoneNumber::List::Iterator phoneIter; 242 KABC::PhoneNumber::List::Iterator phoneIter;
242 243
243 QStringList t; 244 QStringList t;
244 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 245 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
245 ++phoneIter ) 246 ++phoneIter )
246 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 247 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
247 t.sort(); 248 t.sort();
248 uint iii; 249 uint iii;
249 for ( iii = 0; iii < t.count(); ++iii) 250 for ( iii = 0; iii < t.count(); ++iii)
250 l.append( t[iii] ); 251 l.append( t[iii] );
251 t = mData->emails; 252 t = mData->emails;
252 t.sort(); 253 t.sort();
253 for ( iii = 0; iii < t.count(); ++iii) 254 for ( iii = 0; iii < t.count(); ++iii)
254 l.append( t[iii] ); 255 l.append( t[iii] );
255 t = mData->categories; 256 t = mData->categories;
256 t.sort(); 257 t.sort();
257 for ( iii = 0; iii < t.count(); ++iii) 258 for ( iii = 0; iii < t.count(); ++iii)
258 l.append( t[iii] ); 259 l.append( t[iii] );
259 t = mData->custom; 260 t = mData->custom;
260 t.sort(); 261 t.sort();
261 for ( iii = 0; iii < t.count(); ++iii) 262 for ( iii = 0; iii < t.count(); ++iii)
262 l.append( t[iii] ); 263 l.append( t[iii] );
263 KABC::Address::List::Iterator addressIter; 264 KABC::Address::List::Iterator addressIter;
264 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 265 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
265 ++addressIter ) { 266 ++addressIter ) {
266 t = (*addressIter).asList(); 267 t = (*addressIter).asList();
267 t.sort(); 268 t.sort();
268 for ( iii = 0; iii < t.count(); ++iii) 269 for ( iii = 0; iii < t.count(); ++iii)
269 l.append( t[iii] ); 270 l.append( t[iii] );
270 } 271 }
271 uint cs = getCsum4List(l); 272 uint cs = getCsum4List(l);
272 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 273 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
273 setCsum( dev, QString::number (cs )); 274 setCsum( dev, QString::number (cs ));
274} 275}
275 276
276void Addressee::mergeContact( const Addressee& ad ) 277void Addressee::mergeContact( const Addressee& ad )
277{ 278{
278 279
279 detach(); 280 detach();
280 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 281 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
281 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 282 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
282 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 283 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
283 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 284 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
284 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 285 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
285 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 286 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
286 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 287 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
287 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 288 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
288 if ( !mData->birthday.isValid() ) 289 if ( !mData->birthday.isValid() )
289 if ( ad.mData->birthday.isValid()) 290 if ( ad.mData->birthday.isValid())
290 mData->birthday = ad.mData->birthday; 291 mData->birthday = ad.mData->birthday;
291 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 292 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
292 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 293 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
293 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 294 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
294 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 295 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
295 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 296 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
296 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 297 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
297 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 298 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
298 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 299 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
299 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 300 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
300 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 301 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
301 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 302 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
302 303
303 // pending: 304 // pending:
304 // merging phonenumbers 305 // merging phonenumbers
305 // merging addresses 306 // merging addresses
306 // merging emails; 307 // merging emails;
307 // merging categories; 308 // merging categories;
308 // merging custom; 309 // merging custom;
309 // merging keys 310 // merging keys
310} 311}
311 312
312void Addressee::removeID(const QString &prof) 313void Addressee::removeID(const QString &prof)
313{ 314{
314 detach(); 315 detach();
315 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 316 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
316 317
317} 318}
318void Addressee::setID( const QString & prof , const QString & id ) 319void Addressee::setID( const QString & prof , const QString & id )
319{ 320{
320 detach(); 321 detach();
321 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 322 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
322 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 323 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
323} 324}
324void Addressee::setTempSyncStat( int id ) 325void Addressee::setTempSyncStat( int id )
325{ 326{
326 if ( mData->mTempSyncStat == id ) return; 327 if ( mData->mTempSyncStat == id ) return;
327 detach(); 328 detach();
328 mData->mTempSyncStat = id; 329 mData->mTempSyncStat = id;
329} 330}
330int Addressee::tempSyncStat() const 331int Addressee::tempSyncStat() const
331{ 332{
332 return mData->mTempSyncStat; 333 return mData->mTempSyncStat;
333} 334}
334 335
335QString Addressee::getID( const QString & prof) 336QString Addressee::getID( const QString & prof)
336{ 337{
337 return KIdManager::getId ( mData->mExternalId, prof ); 338 return KIdManager::getId ( mData->mExternalId, prof );
338} 339}
339 340
340void Addressee::setCsum( const QString & prof , const QString & id ) 341void Addressee::setCsum( const QString & prof , const QString & id )
341{ 342{
342 detach(); 343 detach();
343 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 344 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
344 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 345 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
345 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 346 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
346} 347}
347 348
348QString Addressee::getCsum( const QString & prof) 349QString Addressee::getCsum( const QString & prof)
349{ 350{
350 return KIdManager::getCsum ( mData->mExternalId, prof ); 351 return KIdManager::getCsum ( mData->mExternalId, prof );
351} 352}
352 353
353void Addressee::setIDStr( const QString & s ) 354void Addressee::setIDStr( const QString & s )
354{ 355{
355 detach(); 356 detach();
356 mData->mExternalId = s; 357 mData->mExternalId = s;
357} 358}
358 359
359QString Addressee::IDStr() const 360QString Addressee::IDStr() const
360{ 361{
361 return mData->mExternalId; 362 return mData->mExternalId;
362} 363}
363 364
364void Addressee::setExternalUID( const QString &id ) 365void Addressee::setExternalUID( const QString &id )
365{ 366{
366 if ( id == mData->externalUID ) return; 367 if ( id == mData->externalUID ) return;
367 detach(); 368 detach();
368 mData->empty = false; 369 mData->empty = false;
369 mData->externalUID = id; 370 mData->externalUID = id;
370} 371}
371 372
372QString Addressee::externalUID() const 373QString Addressee::externalUID() const
373{ 374{
374 return mData->externalUID; 375 return mData->externalUID;
375} 376}
377void Addressee::setOriginalExternalUID( const QString &id )
378{
379 if ( id == mData->originalExternalUID ) return;
380 detach();
381 mData->empty = false;
382 mData->originalExternalUID = id;
383}
384
385QString Addressee::originalExternalUID() const
386{
387 return mData->originalExternalUID;
388}
376 389
377void Addressee::setUid( const QString &id ) 390void Addressee::setUid( const QString &id )
378{ 391{
379 if ( id == mData->uid ) return; 392 if ( id == mData->uid ) return;
380 detach(); 393 detach();
381 mData->empty = false; 394 mData->empty = false;
382 mData->uid = id; 395 mData->uid = id;
383} 396}
384 397
385QString Addressee::uid() const 398QString Addressee::uid() const
386{ 399{
387 if ( mData->uid.isEmpty() ) 400 if ( mData->uid.isEmpty() )
388 mData->uid = KApplication::randomString( 10 ); 401 mData->uid = KApplication::randomString( 10 );
389 402
390 return mData->uid; 403 return mData->uid;
391} 404}
392 405
393QString Addressee::uidLabel() 406QString Addressee::uidLabel()
394{ 407{
395 return i18n("Unique Identifier"); 408 return i18n("Unique Identifier");
396} 409}
397 410
398void Addressee::setName( const QString &name ) 411void Addressee::setName( const QString &name )
399{ 412{
400 if ( name == mData->name ) return; 413 if ( name == mData->name ) return;
401 detach(); 414 detach();
402 mData->empty = false; 415 mData->empty = false;
403 mData->name = name; 416 mData->name = name;
404} 417}
405 418
406QString Addressee::name() const 419QString Addressee::name() const
407{ 420{
408 return mData->name; 421 return mData->name;
409} 422}
410 423
411QString Addressee::nameLabel() 424QString Addressee::nameLabel()
412{ 425{
413 return i18n("Name"); 426 return i18n("Name");
414} 427}
415 428
416 429
417void Addressee::setFormattedName( const QString &formattedName ) 430void Addressee::setFormattedName( const QString &formattedName )
418{ 431{
419 if ( formattedName == mData->formattedName ) return; 432 if ( formattedName == mData->formattedName ) return;
420 detach(); 433 detach();
421 mData->empty = false; 434 mData->empty = false;
422 mData->formattedName = formattedName; 435 mData->formattedName = formattedName;
423} 436}
424 437
425QString Addressee::formattedName() const 438QString Addressee::formattedName() const
426{ 439{
427 return mData->formattedName; 440 return mData->formattedName;
428} 441}
429 442
430QString Addressee::formattedNameLabel() 443QString Addressee::formattedNameLabel()
431{ 444{
432 return i18n("Formatted Name"); 445 return i18n("Formatted Name");
433} 446}
434 447
435 448
436void Addressee::setFamilyName( const QString &familyName ) 449void Addressee::setFamilyName( const QString &familyName )
437{ 450{
438 if ( familyName == mData->familyName ) return; 451 if ( familyName == mData->familyName ) return;
439 detach(); 452 detach();
440 mData->empty = false; 453 mData->empty = false;
441 mData->familyName = familyName; 454 mData->familyName = familyName;
442} 455}
443 456
444QString Addressee::familyName() const 457QString Addressee::familyName() const
445{ 458{
446 return mData->familyName; 459 return mData->familyName;
447} 460}
448 461
449QString Addressee::familyNameLabel() 462QString Addressee::familyNameLabel()
450{ 463{
451 return i18n("Family Name"); 464 return i18n("Family Name");
452} 465}
453 466
454 467
455void Addressee::setGivenName( const QString &givenName ) 468void Addressee::setGivenName( const QString &givenName )
456{ 469{
457 if ( givenName == mData->givenName ) return; 470 if ( givenName == mData->givenName ) return;
458 detach(); 471 detach();
459 mData->empty = false; 472 mData->empty = false;
460 mData->givenName = givenName; 473 mData->givenName = givenName;
461} 474}
462 475
463QString Addressee::givenName() const 476QString Addressee::givenName() const
464{ 477{
465 return mData->givenName; 478 return mData->givenName;
466} 479}
467 480
468QString Addressee::givenNameLabel() 481QString Addressee::givenNameLabel()
469{ 482{
470 return i18n("Given Name"); 483 return i18n("Given Name");
471} 484}
472 485
473 486
474void Addressee::setAdditionalName( const QString &additionalName ) 487void Addressee::setAdditionalName( const QString &additionalName )
475{ 488{
476 if ( additionalName == mData->additionalName ) return; 489 if ( additionalName == mData->additionalName ) return;
477 detach(); 490 detach();
478 mData->empty = false; 491 mData->empty = false;
479 mData->additionalName = additionalName; 492 mData->additionalName = additionalName;
480} 493}
481 494
482QString Addressee::additionalName() const 495QString Addressee::additionalName() const
483{ 496{
484 return mData->additionalName; 497 return mData->additionalName;
485} 498}
486 499
487QString Addressee::additionalNameLabel() 500QString Addressee::additionalNameLabel()
488{ 501{
489 return i18n("Additional Names"); 502 return i18n("Additional Names");
490} 503}
491 504
492 505
493void Addressee::setPrefix( const QString &prefix ) 506void Addressee::setPrefix( const QString &prefix )
494{ 507{
495 if ( prefix == mData->prefix ) return; 508 if ( prefix == mData->prefix ) return;
496 detach(); 509 detach();
497 mData->empty = false; 510 mData->empty = false;
498 mData->prefix = prefix; 511 mData->prefix = prefix;
499} 512}
500 513
501QString Addressee::prefix() const 514QString Addressee::prefix() const
502{ 515{
503 return mData->prefix; 516 return mData->prefix;
504} 517}
505 518
506QString Addressee::prefixLabel() 519QString Addressee::prefixLabel()
507{ 520{
508 return i18n("Honorific Prefixes"); 521 return i18n("Honorific Prefixes");
509} 522}
510 523
511 524
512void Addressee::setSuffix( const QString &suffix ) 525void Addressee::setSuffix( const QString &suffix )
513{ 526{
514 if ( suffix == mData->suffix ) return; 527 if ( suffix == mData->suffix ) return;
515 detach(); 528 detach();
516 mData->empty = false; 529 mData->empty = false;
517 mData->suffix = suffix; 530 mData->suffix = suffix;
518} 531}
519 532
520QString Addressee::suffix() const 533QString Addressee::suffix() const
521{ 534{
522 return mData->suffix; 535 return mData->suffix;
523} 536}
524 537
525QString Addressee::suffixLabel() 538QString Addressee::suffixLabel()
526{ 539{
527 return i18n("Honorific Suffixes"); 540 return i18n("Honorific Suffixes");
528} 541}
529 542
530 543
531void Addressee::setNickName( const QString &nickName ) 544void Addressee::setNickName( const QString &nickName )
532{ 545{
533 if ( nickName == mData->nickName ) return; 546 if ( nickName == mData->nickName ) return;
534 detach(); 547 detach();
535 mData->empty = false; 548 mData->empty = false;
536 mData->nickName = nickName; 549 mData->nickName = nickName;
537} 550}
538 551
539QString Addressee::nickName() const 552QString Addressee::nickName() const
540{ 553{
541 return mData->nickName; 554 return mData->nickName;
542} 555}
543 556
544QString Addressee::nickNameLabel() 557QString Addressee::nickNameLabel()
545{ 558{
546 return i18n("Nick Name"); 559 return i18n("Nick Name");
547} 560}
548 561
549 562
550void Addressee::setBirthday( const QDateTime &birthday ) 563void Addressee::setBirthday( const QDateTime &birthday )
551{ 564{
552 if ( birthday == mData->birthday ) return; 565 if ( birthday == mData->birthday ) return;
553 detach(); 566 detach();
554 mData->empty = false; 567 mData->empty = false;
555 mData->birthday = birthday; 568 mData->birthday = birthday;
556} 569}
557 570
558QDateTime Addressee::birthday() const 571QDateTime Addressee::birthday() const
559{ 572{
560 return mData->birthday; 573 return mData->birthday;
561} 574}
562 575
563QString Addressee::birthdayLabel() 576QString Addressee::birthdayLabel()
564{ 577{
565 return i18n("Birthday"); 578 return i18n("Birthday");
566} 579}
567 580
568 581
569QString Addressee::homeAddressStreetLabel() 582QString Addressee::homeAddressStreetLabel()
570{ 583{
571 return i18n("Home Address Street"); 584 return i18n("Home Address Street");
572} 585}
573 586
574 587
575QString Addressee::homeAddressLocalityLabel() 588QString Addressee::homeAddressLocalityLabel()
576{ 589{
577 return i18n("Home Address Locality"); 590 return i18n("Home Address Locality");
578} 591}
579 592
580 593
581QString Addressee::homeAddressRegionLabel() 594QString Addressee::homeAddressRegionLabel()
582{ 595{
583 return i18n("Home Address Region"); 596 return i18n("Home Address Region");
584} 597}
585 598
586 599
587QString Addressee::homeAddressPostalCodeLabel() 600QString Addressee::homeAddressPostalCodeLabel()
588{ 601{
589 return i18n("Home Address Postal Code"); 602 return i18n("Home Address Postal Code");
590} 603}
591 604
592 605
593QString Addressee::homeAddressCountryLabel() 606QString Addressee::homeAddressCountryLabel()
594{ 607{
595 return i18n("Home Address Country"); 608 return i18n("Home Address Country");
596} 609}
597 610
598 611
599QString Addressee::homeAddressLabelLabel() 612QString Addressee::homeAddressLabelLabel()
600{ 613{
601 return i18n("Home Address Label"); 614 return i18n("Home Address Label");
602} 615}
603 616
604 617
605QString Addressee::businessAddressStreetLabel() 618QString Addressee::businessAddressStreetLabel()
606{ 619{
607 return i18n("Business Address Street"); 620 return i18n("Business Address Street");
608} 621}
609 622
610 623
611QString Addressee::businessAddressLocalityLabel() 624QString Addressee::businessAddressLocalityLabel()
612{ 625{
613 return i18n("Business Address Locality"); 626 return i18n("Business Address Locality");
614} 627}
615 628
616 629
617QString Addressee::businessAddressRegionLabel() 630QString Addressee::businessAddressRegionLabel()
618{ 631{
619 return i18n("Business Address Region"); 632 return i18n("Business Address Region");
620} 633}
621 634
622 635
623QString Addressee::businessAddressPostalCodeLabel() 636QString Addressee::businessAddressPostalCodeLabel()
624{ 637{
625 return i18n("Business Address Postal Code"); 638 return i18n("Business Address Postal Code");
626} 639}
627 640
628 641
629QString Addressee::businessAddressCountryLabel() 642QString Addressee::businessAddressCountryLabel()
630{ 643{
631 return i18n("Business Address Country"); 644 return i18n("Business Address Country");
632} 645}
633 646
634 647
635QString Addressee::businessAddressLabelLabel() 648QString Addressee::businessAddressLabelLabel()
636{ 649{
637 return i18n("Business Address Label"); 650 return i18n("Business Address Label");
638} 651}
639 652
640 653
641QString Addressee::homePhoneLabel() 654QString Addressee::homePhoneLabel()
642{ 655{
643 return i18n("Home Phone"); 656 return i18n("Home Phone");
644} 657}
645 658
646 659
647QString Addressee::businessPhoneLabel() 660QString Addressee::businessPhoneLabel()
648{ 661{
649 return i18n("Business Phone"); 662 return i18n("Business Phone");
650} 663}
651 664
652 665
653QString Addressee::mobilePhoneLabel() 666QString Addressee::mobilePhoneLabel()
654{ 667{
655 return i18n("Mobile Phone"); 668 return i18n("Mobile Phone");
656} 669}
657 670
658 671
659QString Addressee::homeFaxLabel() 672QString Addressee::homeFaxLabel()
660{ 673{
661 return i18n("Home Fax"); 674 return i18n("Home Fax");
662} 675}
663 676
664 677
665QString Addressee::businessFaxLabel() 678QString Addressee::businessFaxLabel()
666{ 679{
667 return i18n("Business Fax"); 680 return i18n("Business Fax");
668} 681}
669 682
670 683
671QString Addressee::carPhoneLabel() 684QString Addressee::carPhoneLabel()
672{ 685{
673 return i18n("Car Phone"); 686 return i18n("Car Phone");
674} 687}
675 688
676 689
677QString Addressee::isdnLabel() 690QString Addressee::isdnLabel()
678{ 691{
679 return i18n("ISDN"); 692 return i18n("ISDN");
680} 693}
681 694
682 695
683QString Addressee::pagerLabel() 696QString Addressee::pagerLabel()
684{ 697{
685 return i18n("Pager"); 698 return i18n("Pager");
686} 699}
687 700
688QString Addressee::sipLabel() 701QString Addressee::sipLabel()
689{ 702{
690 return i18n("SIP"); 703 return i18n("SIP");
691} 704}
692 705
693QString Addressee::emailLabel() 706QString Addressee::emailLabel()
694{ 707{
695 return i18n("Email Address"); 708 return i18n("Email Address");
696} 709}
697 710
698 711
699void Addressee::setMailer( const QString &mailer ) 712void Addressee::setMailer( const QString &mailer )
700{ 713{
701 if ( mailer == mData->mailer ) return; 714 if ( mailer == mData->mailer ) return;
702 detach(); 715 detach();
703 mData->empty = false; 716 mData->empty = false;
704 mData->mailer = mailer; 717 mData->mailer = mailer;
705} 718}
706 719
707QString Addressee::mailer() const 720QString Addressee::mailer() const
708{ 721{
709 return mData->mailer; 722 return mData->mailer;
710} 723}
711 724
712QString Addressee::mailerLabel() 725QString Addressee::mailerLabel()
713{ 726{
714 return i18n("Mail Client"); 727 return i18n("Mail Client");
715} 728}
716 729
717 730
718void Addressee::setTimeZone( const TimeZone &timeZone ) 731void Addressee::setTimeZone( const TimeZone &timeZone )
719{ 732{
720 if ( timeZone == mData->timeZone ) return; 733 if ( timeZone == mData->timeZone ) return;
721 detach(); 734 detach();
722 mData->empty = false; 735 mData->empty = false;
723 mData->timeZone = timeZone; 736 mData->timeZone = timeZone;
724} 737}
725 738
726TimeZone Addressee::timeZone() const 739TimeZone Addressee::timeZone() const
727{ 740{
728 return mData->timeZone; 741 return mData->timeZone;
729} 742}
730 743
731QString Addressee::timeZoneLabel() 744QString Addressee::timeZoneLabel()
732{ 745{
733 return i18n("Time Zone"); 746 return i18n("Time Zone");
734} 747}
735 748
736 749
737void Addressee::setGeo( const Geo &geo ) 750void Addressee::setGeo( const Geo &geo )
738{ 751{
739 if ( geo == mData->geo ) return; 752 if ( geo == mData->geo ) return;
740 detach(); 753 detach();
741 mData->empty = false; 754 mData->empty = false;
742 mData->geo = geo; 755 mData->geo = geo;
743} 756}
744 757
745Geo Addressee::geo() const 758Geo Addressee::geo() const
746{ 759{
747 return mData->geo; 760 return mData->geo;
748} 761}
749 762
750QString Addressee::geoLabel() 763QString Addressee::geoLabel()
751{ 764{
752 return i18n("Geographic Position"); 765 return i18n("Geographic Position");
753} 766}
754 767
755 768
756void Addressee::setTitle( const QString &title ) 769void Addressee::setTitle( const QString &title )
757{ 770{
758 if ( title == mData->title ) return; 771 if ( title == mData->title ) return;
759 detach(); 772 detach();
760 mData->empty = false; 773 mData->empty = false;
761 mData->title = title; 774 mData->title = title;
762} 775}
763 776
764QString Addressee::title() const 777QString Addressee::title() const
765{ 778{
766 return mData->title; 779 return mData->title;
767} 780}
768 781
769QString Addressee::titleLabel() 782QString Addressee::titleLabel()
770{ 783{
771 return i18n("Title"); 784 return i18n("Title");
772} 785}
773 786
774 787
775void Addressee::setRole( const QString &role ) 788void Addressee::setRole( const QString &role )
776{ 789{
777 if ( role == mData->role ) return; 790 if ( role == mData->role ) return;
778 detach(); 791 detach();
779 mData->empty = false; 792 mData->empty = false;
780 mData->role = role; 793 mData->role = role;
781} 794}
782 795
783QString Addressee::role() const 796QString Addressee::role() const
784{ 797{
785 return mData->role; 798 return mData->role;
786} 799}
787 800
788QString Addressee::roleLabel() 801QString Addressee::roleLabel()
789{ 802{
790 return i18n("Role"); 803 return i18n("Role");
791} 804}
792 805
793 806
794void Addressee::setOrganization( const QString &organization ) 807void Addressee::setOrganization( const QString &organization )
795{ 808{
796 if ( organization == mData->organization ) return; 809 if ( organization == mData->organization ) return;
797 detach(); 810 detach();
798 mData->empty = false; 811 mData->empty = false;
799 mData->organization = organization; 812 mData->organization = organization;
800} 813}
801 814
802QString Addressee::organization() const 815QString Addressee::organization() const
803{ 816{
804 return mData->organization; 817 return mData->organization;
805} 818}
806 819
807QString Addressee::organizationLabel() 820QString Addressee::organizationLabel()
808{ 821{
809 return i18n("Organization"); 822 return i18n("Organization");
810} 823}
811 824
812 825
813void Addressee::setNote( const QString &note ) 826void Addressee::setNote( const QString &note )
814{ 827{
815 if ( note == mData->note ) return; 828 if ( note == mData->note ) return;
816 detach(); 829 detach();
817 mData->empty = false; 830 mData->empty = false;
818 mData->note = note; 831 mData->note = note;
819} 832}
820 833
821QString Addressee::note() const 834QString Addressee::note() const
822{ 835{
823 return mData->note; 836 return mData->note;
824} 837}
825 838
826QString Addressee::noteLabel() 839QString Addressee::noteLabel()
827{ 840{
828 return i18n("Note"); 841 return i18n("Note");
829} 842}
830 843
831 844
832void Addressee::setProductId( const QString &productId ) 845void Addressee::setProductId( const QString &productId )
833{ 846{
834 if ( productId == mData->productId ) return; 847 if ( productId == mData->productId ) return;
835 detach(); 848 detach();
836 mData->empty = false; 849 mData->empty = false;
837 mData->productId = productId; 850 mData->productId = productId;
838} 851}
839 852
840QString Addressee::productId() const 853QString Addressee::productId() const
841{ 854{
842 return mData->productId; 855 return mData->productId;
843} 856}
844 857
845QString Addressee::productIdLabel() 858QString Addressee::productIdLabel()
846{ 859{
847 return i18n("Product Identifier"); 860 return i18n("Product Identifier");
848} 861}
849 862
850 863
851void Addressee::setRevision( const QDateTime &revision ) 864void Addressee::setRevision( const QDateTime &revision )
852{ 865{
853 if ( revision == mData->revision ) return; 866 if ( revision == mData->revision ) return;
854 detach(); 867 detach();
855 mData->empty = false; 868 mData->empty = false;
856 mData->revision = revision; 869 mData->revision = revision;
857} 870}
858 871
859QDateTime Addressee::revision() const 872QDateTime Addressee::revision() const
860{ 873{
861 return mData->revision; 874 return mData->revision;
862} 875}
863 876
864QString Addressee::revisionLabel() 877QString Addressee::revisionLabel()
865{ 878{
866 return i18n("Revision Date"); 879 return i18n("Revision Date");
867} 880}
868 881
869 882
870void Addressee::setSortString( const QString &sortString ) 883void Addressee::setSortString( const QString &sortString )
871{ 884{
872 if ( sortString == mData->sortString ) return; 885 if ( sortString == mData->sortString ) return;
873 detach(); 886 detach();
874 mData->empty = false; 887 mData->empty = false;
875 mData->sortString = sortString; 888 mData->sortString = sortString;
876} 889}
877 890
878QString Addressee::sortString() const 891QString Addressee::sortString() const
879{ 892{
880 return mData->sortString; 893 return mData->sortString;
881} 894}
882 895
883QString Addressee::sortStringLabel() 896QString Addressee::sortStringLabel()
884{ 897{
885 return i18n("Sort String"); 898 return i18n("Sort String");
886} 899}
887 900
888 901
889void Addressee::setUrl( const KURL &url ) 902void Addressee::setUrl( const KURL &url )
890{ 903{
891 if ( url == mData->url ) return; 904 if ( url == mData->url ) return;
892 detach(); 905 detach();
893 mData->empty = false; 906 mData->empty = false;
894 mData->url = url; 907 mData->url = url;
895} 908}
896 909
897KURL Addressee::url() const 910KURL Addressee::url() const
898{ 911{
899 return mData->url; 912 return mData->url;
900} 913}
901 914
902QString Addressee::urlLabel() 915QString Addressee::urlLabel()
903{ 916{
904 return i18n("URL"); 917 return i18n("URL");
905} 918}
906 919
907 920
908void Addressee::setSecrecy( const Secrecy &secrecy ) 921void Addressee::setSecrecy( const Secrecy &secrecy )
909{ 922{
910 if ( secrecy == mData->secrecy ) return; 923 if ( secrecy == mData->secrecy ) return;
911 detach(); 924 detach();
912 mData->empty = false; 925 mData->empty = false;
913 mData->secrecy = secrecy; 926 mData->secrecy = secrecy;
914} 927}
915 928
916Secrecy Addressee::secrecy() const 929Secrecy Addressee::secrecy() const
917{ 930{
918 return mData->secrecy; 931 return mData->secrecy;
919} 932}
920 933
921QString Addressee::secrecyLabel() 934QString Addressee::secrecyLabel()
922{ 935{
923 return i18n("Security Class"); 936 return i18n("Security Class");
924} 937}
925 938
926 939
927void Addressee::setLogo( const Picture &logo ) 940void Addressee::setLogo( const Picture &logo )
928{ 941{
929 if ( logo == mData->logo ) return; 942 if ( logo == mData->logo ) return;
930 detach(); 943 detach();
931 mData->empty = false; 944 mData->empty = false;
932 mData->logo = logo; 945 mData->logo = logo;
933} 946}
934 947
935Picture Addressee::logo() const 948Picture Addressee::logo() const
936{ 949{
937 return mData->logo; 950 return mData->logo;
938} 951}
939 952
940QString Addressee::logoLabel() 953QString Addressee::logoLabel()
941{ 954{
942 return i18n("Logo"); 955 return i18n("Logo");
943} 956}
944 957
945 958
946void Addressee::setPhoto( const Picture &photo ) 959void Addressee::setPhoto( const Picture &photo )
947{ 960{
948 if ( photo == mData->photo ) return; 961 if ( photo == mData->photo ) return;
949 detach(); 962 detach();
950 mData->empty = false; 963 mData->empty = false;
951 mData->photo = photo; 964 mData->photo = photo;
952} 965}
953 966
954Picture Addressee::photo() const 967Picture Addressee::photo() const
955{ 968{
956 return mData->photo; 969 return mData->photo;
957} 970}
958 971
959QString Addressee::photoLabel() 972QString Addressee::photoLabel()
960{ 973{
961 return i18n("Photo"); 974 return i18n("Photo");
962} 975}
963 976
964 977
965void Addressee::setSound( const Sound &sound ) 978void Addressee::setSound( const Sound &sound )
966{ 979{
967 if ( sound == mData->sound ) return; 980 if ( sound == mData->sound ) return;
968 detach(); 981 detach();
969 mData->empty = false; 982 mData->empty = false;
970 mData->sound = sound; 983 mData->sound = sound;
971} 984}
972 985
973Sound Addressee::sound() const 986Sound Addressee::sound() const
974{ 987{
975 return mData->sound; 988 return mData->sound;
976} 989}
977 990
978QString Addressee::soundLabel() 991QString Addressee::soundLabel()
979{ 992{
980 return i18n("Sound"); 993 return i18n("Sound");
981} 994}
982 995
983 996
984void Addressee::setAgent( const Agent &agent ) 997void Addressee::setAgent( const Agent &agent )
985{ 998{
986 if ( agent == mData->agent ) return; 999 if ( agent == mData->agent ) return;
987 detach(); 1000 detach();
988 mData->empty = false; 1001 mData->empty = false;
989 mData->agent = agent; 1002 mData->agent = agent;
990} 1003}
991 1004
992Agent Addressee::agent() const 1005Agent Addressee::agent() const
993{ 1006{
994 return mData->agent; 1007 return mData->agent;
995} 1008}
996 1009
997QString Addressee::agentLabel() 1010QString Addressee::agentLabel()
998{ 1011{
999 return i18n("Agent"); 1012 return i18n("Agent");
1000} 1013}
1001 1014
1002 1015
1003 1016
1004void Addressee::setNameFromString( const QString &str ) 1017void Addressee::setNameFromString( const QString &str )
1005{ 1018{
1006 setFormattedName( str ); 1019 setFormattedName( str );
1007 setName( str ); 1020 setName( str );
1008 1021
1009 static bool first = true; 1022 static bool first = true;
1010 static QStringList titles; 1023 static QStringList titles;
1011 static QStringList suffixes; 1024 static QStringList suffixes;
1012 static QStringList prefixes; 1025 static QStringList prefixes;
1013 1026
1014 if ( first ) { 1027 if ( first ) {
1015 first = false; 1028 first = false;
1016 titles += i18n( "Dr." ); 1029 titles += i18n( "Dr." );
1017 titles += i18n( "Miss" ); 1030 titles += i18n( "Miss" );
1018 titles += i18n( "Mr." ); 1031 titles += i18n( "Mr." );
1019 titles += i18n( "Mrs." ); 1032 titles += i18n( "Mrs." );
1020 titles += i18n( "Ms." ); 1033 titles += i18n( "Ms." );
1021 titles += i18n( "Prof." ); 1034 titles += i18n( "Prof." );
1022 1035
1023 suffixes += i18n( "I" ); 1036 suffixes += i18n( "I" );
1024 suffixes += i18n( "II" ); 1037 suffixes += i18n( "II" );
1025 suffixes += i18n( "III" ); 1038 suffixes += i18n( "III" );
1026 suffixes += i18n( "Jr." ); 1039 suffixes += i18n( "Jr." );
1027 suffixes += i18n( "Sr." ); 1040 suffixes += i18n( "Sr." );
1028 1041
1029 prefixes += "van"; 1042 prefixes += "van";
1030 prefixes += "von"; 1043 prefixes += "von";
1031 prefixes += "de"; 1044 prefixes += "de";
1032 1045
1033 KConfig config( locateLocal( "config", "kabcrc") ); 1046 KConfig config( locateLocal( "config", "kabcrc") );
1034 config.setGroup( "General" ); 1047 config.setGroup( "General" );
1035 titles += config.readListEntry( "Prefixes" ); 1048 titles += config.readListEntry( "Prefixes" );
1036 titles.remove( "" ); 1049 titles.remove( "" );
1037 prefixes += config.readListEntry( "Inclusions" ); 1050 prefixes += config.readListEntry( "Inclusions" );
1038 prefixes.remove( "" ); 1051 prefixes.remove( "" );
1039 suffixes += config.readListEntry( "Suffixes" ); 1052 suffixes += config.readListEntry( "Suffixes" );
1040 suffixes.remove( "" ); 1053 suffixes.remove( "" );
1041 } 1054 }
1042 1055
1043 // clear all name parts 1056 // clear all name parts
1044 setPrefix( "" ); 1057 setPrefix( "" );
1045 setGivenName( "" ); 1058 setGivenName( "" );
1046 setAdditionalName( "" ); 1059 setAdditionalName( "" );
1047 setFamilyName( "" ); 1060 setFamilyName( "" );
1048 setSuffix( "" ); 1061 setSuffix( "" );
1049 1062
1050 if ( str.isEmpty() ) 1063 if ( str.isEmpty() )
1051 return; 1064 return;
1052 1065
1053 int i = str.find(','); 1066 int i = str.find(',');
1054 if( i < 0 ) { 1067 if( i < 0 ) {
1055 QStringList parts = QStringList::split( " ", str ); 1068 QStringList parts = QStringList::split( " ", str );
1056 int leftOffset = 0; 1069 int leftOffset = 0;
1057 int rightOffset = parts.count() - 1; 1070 int rightOffset = parts.count() - 1;
1058 1071
1059 QString suffix; 1072 QString suffix;
1060 while ( rightOffset >= 0 ) { 1073 while ( rightOffset >= 0 ) {
1061 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1074 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1062 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1075 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1063 rightOffset--; 1076 rightOffset--;
1064 } else 1077 } else
1065 break; 1078 break;
1066 } 1079 }
1067 setSuffix( suffix ); 1080 setSuffix( suffix );
1068 1081
1069 if ( rightOffset < 0 ) 1082 if ( rightOffset < 0 )
1070 return; 1083 return;
1071 1084
1072 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1085 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1073 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1086 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1074 rightOffset--; 1087 rightOffset--;
1075 } else 1088 } else
1076 setFamilyName( parts[ rightOffset ] ); 1089 setFamilyName( parts[ rightOffset ] );
1077 1090
1078 QString prefix; 1091 QString prefix;
1079 while ( leftOffset < rightOffset ) { 1092 while ( leftOffset < rightOffset ) {
1080 if ( titles.contains( parts[ leftOffset ] ) ) { 1093 if ( titles.contains( parts[ leftOffset ] ) ) {
1081 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1094 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1082 leftOffset++; 1095 leftOffset++;
1083 } else 1096 } else
1084 break; 1097 break;
1085 } 1098 }
1086 setPrefix( prefix ); 1099 setPrefix( prefix );
1087 1100
1088 if ( leftOffset < rightOffset ) { 1101 if ( leftOffset < rightOffset ) {
1089 setGivenName( parts[ leftOffset ] ); 1102 setGivenName( parts[ leftOffset ] );
1090 leftOffset++; 1103 leftOffset++;
1091 } 1104 }
1092 1105
1093 QString additionalName; 1106 QString additionalName;
1094 while ( leftOffset < rightOffset ) { 1107 while ( leftOffset < rightOffset ) {
1095 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1108 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1096 leftOffset++; 1109 leftOffset++;
1097 } 1110 }
1098 setAdditionalName( additionalName ); 1111 setAdditionalName( additionalName );
1099 } else { 1112 } else {
1100 QString part1 = str.left( i ); 1113 QString part1 = str.left( i );
1101 QString part2 = str.mid( i + 1 ); 1114 QString part2 = str.mid( i + 1 );
1102 1115
1103 QStringList parts = QStringList::split( " ", part1 ); 1116 QStringList parts = QStringList::split( " ", part1 );
1104 int leftOffset = 0; 1117 int leftOffset = 0;
1105 int rightOffset = parts.count() - 1; 1118 int rightOffset = parts.count() - 1;
1106 1119
1107 QString suffix; 1120 QString suffix;
1108 while ( rightOffset >= 0 ) { 1121 while ( rightOffset >= 0 ) {
1109 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1122 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1110 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1123 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1111 rightOffset--; 1124 rightOffset--;
1112 } else 1125 } else
1113 break; 1126 break;
1114 } 1127 }
1115 setSuffix( suffix ); 1128 setSuffix( suffix );
1116 1129
1117 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1130 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1118 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1131 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1119 rightOffset--; 1132 rightOffset--;
1120 } else 1133 } else
1121 setFamilyName( parts[ rightOffset ] ); 1134 setFamilyName( parts[ rightOffset ] );
1122 1135
1123 QString prefix; 1136 QString prefix;
1124 while ( leftOffset < rightOffset ) { 1137 while ( leftOffset < rightOffset ) {
1125 if ( titles.contains( parts[ leftOffset ] ) ) { 1138 if ( titles.contains( parts[ leftOffset ] ) ) {
1126 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1139 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1127 leftOffset++; 1140 leftOffset++;
1128 } else 1141 } else
1129 break; 1142 break;
1130 } 1143 }
1131 1144
1132 parts = QStringList::split( " ", part2 ); 1145 parts = QStringList::split( " ", part2 );
1133 1146
1134 leftOffset = 0; 1147 leftOffset = 0;
1135 rightOffset = parts.count(); 1148 rightOffset = parts.count();
1136 1149
1137 while ( leftOffset < rightOffset ) { 1150 while ( leftOffset < rightOffset ) {
1138 if ( titles.contains( parts[ leftOffset ] ) ) { 1151 if ( titles.contains( parts[ leftOffset ] ) ) {
1139 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1152 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1140 leftOffset++; 1153 leftOffset++;
1141 } else 1154 } else
1142 break; 1155 break;
1143 } 1156 }
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 3ba7777..8baa888 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,841 +1,843 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@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/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37#include <ksharedptr.h> 37#include <ksharedptr.h>
38#include <kurl.h> 38#include <kurl.h>
39 39
40#include "address.h" 40#include "address.h"
41#include "agent.h" 41#include "agent.h"
42#include "geo.h" 42#include "geo.h"
43#include "key.h" 43#include "key.h"
44#include "phonenumber.h" 44#include "phonenumber.h"
45#include "picture.h" 45#include "picture.h"
46#include "secrecy.h" 46#include "secrecy.h"
47#include "sound.h" 47#include "sound.h"
48#include "timezone.h" 48#include "timezone.h"
49 49
50namespace KABC { 50namespace KABC {
51 51
52class Resource; 52class Resource;
53 53
54/** 54/**
55 @short address book entry 55 @short address book entry
56 56
57 This class represents an entry in the address book. 57 This class represents an entry in the address book.
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 115 void setExternalUID( const QString &id );
116 QString externalUID() const; 116 QString externalUID() const;
117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const;
117 void mergeContact( const Addressee& ad ); 119 void mergeContact( const Addressee& ad );
118 /** 120 /**
119 Set unique identifier. 121 Set unique identifier.
120 */ 122 */
121 void setUid( const QString &uid ); 123 void setUid( const QString &uid );
122 /** 124 /**
123 Return unique identifier. 125 Return unique identifier.
124 */ 126 */
125 QString uid() const; 127 QString uid() const;
126 /** 128 /**
127 Return translated label for uid field. 129 Return translated label for uid field.
128 */ 130 */
129 static QString uidLabel(); 131 static QString uidLabel();
130 132
131 /** 133 /**
132 Set name. 134 Set name.
133 */ 135 */
134 void setName( const QString &name ); 136 void setName( const QString &name );
135 /** 137 /**
136 Return name. 138 Return name.
137 */ 139 */
138 QString name() const; 140 QString name() const;
139 /** 141 /**
140 Return translated label for name field. 142 Return translated label for name field.
141 */ 143 */
142 static QString nameLabel(); 144 static QString nameLabel();
143 145
144 /** 146 /**
145 Set formatted name. 147 Set formatted name.
146 */ 148 */
147 void setFormattedName( const QString &formattedName ); 149 void setFormattedName( const QString &formattedName );
148 /** 150 /**
149 Return formatted name. 151 Return formatted name.
150 */ 152 */
151 QString formattedName() const; 153 QString formattedName() const;
152 /** 154 /**
153 Return translated label for formattedName field. 155 Return translated label for formattedName field.
154 */ 156 */
155 static QString formattedNameLabel(); 157 static QString formattedNameLabel();
156 158
157 /** 159 /**
158 Set family name. 160 Set family name.
159 */ 161 */
160 void setFamilyName( const QString &familyName ); 162 void setFamilyName( const QString &familyName );
161 /** 163 /**
162 Return family name. 164 Return family name.
163 */ 165 */
164 QString familyName() const; 166 QString familyName() const;
165 /** 167 /**
166 Return translated label for familyName field. 168 Return translated label for familyName field.
167 */ 169 */
168 static QString familyNameLabel(); 170 static QString familyNameLabel();
169 171
170 /** 172 /**
171 Set given name. 173 Set given name.
172 */ 174 */
173 void setGivenName( const QString &givenName ); 175 void setGivenName( const QString &givenName );
174 /** 176 /**
175 Return given name. 177 Return given name.
176 */ 178 */
177 QString givenName() const; 179 QString givenName() const;
178 /** 180 /**
179 Return translated label for givenName field. 181 Return translated label for givenName field.
180 */ 182 */
181 static QString givenNameLabel(); 183 static QString givenNameLabel();
182 184
183 /** 185 /**
184 Set additional names. 186 Set additional names.
185 */ 187 */
186 void setAdditionalName( const QString &additionalName ); 188 void setAdditionalName( const QString &additionalName );
187 /** 189 /**
188 Return additional names. 190 Return additional names.
189 */ 191 */
190 QString additionalName() const; 192 QString additionalName() const;
191 /** 193 /**
192 Return translated label for additionalName field. 194 Return translated label for additionalName field.
193 */ 195 */
194 static QString additionalNameLabel(); 196 static QString additionalNameLabel();
195 197
196 /** 198 /**
197 Set honorific prefixes. 199 Set honorific prefixes.
198 */ 200 */
199 void setPrefix( const QString &prefix ); 201 void setPrefix( const QString &prefix );
200 /** 202 /**
201 Return honorific prefixes. 203 Return honorific prefixes.
202 */ 204 */
203 QString prefix() const; 205 QString prefix() const;
204 /** 206 /**
205 Return translated label for prefix field. 207 Return translated label for prefix field.
206 */ 208 */
207 static QString prefixLabel(); 209 static QString prefixLabel();
208 210
209 /** 211 /**
210 Set honorific suffixes. 212 Set honorific suffixes.
211 */ 213 */
212 void setSuffix( const QString &suffix ); 214 void setSuffix( const QString &suffix );
213 /** 215 /**
214 Return honorific suffixes. 216 Return honorific suffixes.
215 */ 217 */
216 QString suffix() const; 218 QString suffix() const;
217 /** 219 /**
218 Return translated label for suffix field. 220 Return translated label for suffix field.
219 */ 221 */
220 static QString suffixLabel(); 222 static QString suffixLabel();
221 223
222 /** 224 /**
223 Set nick name. 225 Set nick name.
224 */ 226 */
225 void setNickName( const QString &nickName ); 227 void setNickName( const QString &nickName );
226 /** 228 /**
227 Return nick name. 229 Return nick name.
228 */ 230 */
229 QString nickName() const; 231 QString nickName() const;
230 /** 232 /**
231 Return translated label for nickName field. 233 Return translated label for nickName field.
232 */ 234 */
233 static QString nickNameLabel(); 235 static QString nickNameLabel();
234 236
235 /** 237 /**
236 Set birthday. 238 Set birthday.
237 */ 239 */
238 void setBirthday( const QDateTime &birthday ); 240 void setBirthday( const QDateTime &birthday );
239 /** 241 /**
240 Return birthday. 242 Return birthday.
241 */ 243 */
242 QDateTime birthday() const; 244 QDateTime birthday() const;
243 /** 245 /**
244 Return translated label for birthday field. 246 Return translated label for birthday field.
245 */ 247 */
246 static QString birthdayLabel(); 248 static QString birthdayLabel();
247 249
248 /** 250 /**
249 Return translated label for homeAddressStreet field. 251 Return translated label for homeAddressStreet field.
250 */ 252 */
251 static QString homeAddressStreetLabel(); 253 static QString homeAddressStreetLabel();
252 254
253 /** 255 /**
254 Return translated label for homeAddressLocality field. 256 Return translated label for homeAddressLocality field.
255 */ 257 */
256 static QString homeAddressLocalityLabel(); 258 static QString homeAddressLocalityLabel();
257 259
258 /** 260 /**
259 Return translated label for homeAddressRegion field. 261 Return translated label for homeAddressRegion field.
260 */ 262 */
261 static QString homeAddressRegionLabel(); 263 static QString homeAddressRegionLabel();
262 264
263 /** 265 /**
264 Return translated label for homeAddressPostalCode field. 266 Return translated label for homeAddressPostalCode field.
265 */ 267 */
266 static QString homeAddressPostalCodeLabel(); 268 static QString homeAddressPostalCodeLabel();
267 269
268 /** 270 /**
269 Return translated label for homeAddressCountry field. 271 Return translated label for homeAddressCountry field.
270 */ 272 */
271 static QString homeAddressCountryLabel(); 273 static QString homeAddressCountryLabel();
272 274
273 /** 275 /**
274 Return translated label for homeAddressLabel field. 276 Return translated label for homeAddressLabel field.
275 */ 277 */
276 static QString homeAddressLabelLabel(); 278 static QString homeAddressLabelLabel();
277 279
278 /** 280 /**
279 Return translated label for businessAddressStreet field. 281 Return translated label for businessAddressStreet field.
280 */ 282 */
281 static QString businessAddressStreetLabel(); 283 static QString businessAddressStreetLabel();
282 284
283 /** 285 /**
284 Return translated label for businessAddressLocality field. 286 Return translated label for businessAddressLocality field.
285 */ 287 */
286 static QString businessAddressLocalityLabel(); 288 static QString businessAddressLocalityLabel();
287 289
288 /** 290 /**
289 Return translated label for businessAddressRegion field. 291 Return translated label for businessAddressRegion field.
290 */ 292 */
291 static QString businessAddressRegionLabel(); 293 static QString businessAddressRegionLabel();
292 294
293 /** 295 /**
294 Return translated label for businessAddressPostalCode field. 296 Return translated label for businessAddressPostalCode field.
295 */ 297 */
296 static QString businessAddressPostalCodeLabel(); 298 static QString businessAddressPostalCodeLabel();
297 299
298 /** 300 /**
299 Return translated label for businessAddressCountry field. 301 Return translated label for businessAddressCountry field.
300 */ 302 */
301 static QString businessAddressCountryLabel(); 303 static QString businessAddressCountryLabel();
302 304
303 /** 305 /**
304 Return translated label for businessAddressLabel field. 306 Return translated label for businessAddressLabel field.
305 */ 307 */
306 static QString businessAddressLabelLabel(); 308 static QString businessAddressLabelLabel();
307 309
308 /** 310 /**
309 Return translated label for homePhone field. 311 Return translated label for homePhone field.
310 */ 312 */
311 static QString homePhoneLabel(); 313 static QString homePhoneLabel();
312 314
313 /** 315 /**
314 Return translated label for businessPhone field. 316 Return translated label for businessPhone field.
315 */ 317 */
316 static QString businessPhoneLabel(); 318 static QString businessPhoneLabel();
317 319
318 /** 320 /**
319 Return translated label for mobilePhone field. 321 Return translated label for mobilePhone field.
320 */ 322 */
321 static QString mobilePhoneLabel(); 323 static QString mobilePhoneLabel();
322 324
323 /** 325 /**
324 Return translated label for homeFax field. 326 Return translated label for homeFax field.
325 */ 327 */
326 static QString homeFaxLabel(); 328 static QString homeFaxLabel();
327 329
328 /** 330 /**
329 Return translated label for businessFax field. 331 Return translated label for businessFax field.
330 */ 332 */
331 static QString businessFaxLabel(); 333 static QString businessFaxLabel();
332 334
333 /** 335 /**
334 Return translated label for carPhone field. 336 Return translated label for carPhone field.
335 */ 337 */
336 static QString carPhoneLabel(); 338 static QString carPhoneLabel();
337 339
338 /** 340 /**
339 Return translated label for isdn field. 341 Return translated label for isdn field.
340 */ 342 */
341 static QString isdnLabel(); 343 static QString isdnLabel();
342 344
343 /** 345 /**
344 Return translated label for pager field. 346 Return translated label for pager field.
345 */ 347 */
346 static QString pagerLabel(); 348 static QString pagerLabel();
347 349
348 /** 350 /**
349 Return translated label for sip field. 351 Return translated label for sip field.
350 */ 352 */
351 static QString sipLabel(); 353 static QString sipLabel();
352 354
353 /** 355 /**
354 Return translated label for email field. 356 Return translated label for email field.
355 */ 357 */
356 static QString emailLabel(); 358 static QString emailLabel();
357 359
358 /** 360 /**
359 Set mail client. 361 Set mail client.
360 */ 362 */
361 void setMailer( const QString &mailer ); 363 void setMailer( const QString &mailer );
362 /** 364 /**
363 Return mail client. 365 Return mail client.
364 */ 366 */
365 QString mailer() const; 367 QString mailer() const;
366 /** 368 /**
367 Return translated label for mailer field. 369 Return translated label for mailer field.
368 */ 370 */
369 static QString mailerLabel(); 371 static QString mailerLabel();
370 372
371 /** 373 /**
372 Set time zone. 374 Set time zone.
373 */ 375 */
374 void setTimeZone( const TimeZone &timeZone ); 376 void setTimeZone( const TimeZone &timeZone );
375 /** 377 /**
376 Return time zone. 378 Return time zone.
377 */ 379 */
378 TimeZone timeZone() const; 380 TimeZone timeZone() const;
379 /** 381 /**
380 Return translated label for timeZone field. 382 Return translated label for timeZone field.
381 */ 383 */
382 static QString timeZoneLabel(); 384 static QString timeZoneLabel();
383 385
384 /** 386 /**
385 Set geographic position. 387 Set geographic position.
386 */ 388 */
387 void setGeo( const Geo &geo ); 389 void setGeo( const Geo &geo );
388 /** 390 /**
389 Return geographic position. 391 Return geographic position.
390 */ 392 */
391 Geo geo() const; 393 Geo geo() const;
392 /** 394 /**
393 Return translated label for geo field. 395 Return translated label for geo field.
394 */ 396 */
395 static QString geoLabel(); 397 static QString geoLabel();
396 398
397 /** 399 /**
398 Set title. 400 Set title.
399 */ 401 */
400 void setTitle( const QString &title ); 402 void setTitle( const QString &title );
401 /** 403 /**
402 Return title. 404 Return title.
403 */ 405 */
404 QString title() const; 406 QString title() const;
405 /** 407 /**
406 Return translated label for title field. 408 Return translated label for title field.
407 */ 409 */
408 static QString titleLabel(); 410 static QString titleLabel();
409 411
410 /** 412 /**
411 Set role. 413 Set role.
412 */ 414 */
413 void setRole( const QString &role ); 415 void setRole( const QString &role );
414 /** 416 /**
415 Return role. 417 Return role.
416 */ 418 */
417 QString role() const; 419 QString role() const;
418 /** 420 /**
419 Return translated label for role field. 421 Return translated label for role field.
420 */ 422 */
421 static QString roleLabel(); 423 static QString roleLabel();
422 424
423 /** 425 /**
424 Set organization. 426 Set organization.
425 */ 427 */
426 void setOrganization( const QString &organization ); 428 void setOrganization( const QString &organization );
427 /** 429 /**
428 Return organization. 430 Return organization.
429 */ 431 */
430 QString organization() const; 432 QString organization() const;
431 /** 433 /**
432 Return translated label for organization field. 434 Return translated label for organization field.
433 */ 435 */
434 static QString organizationLabel(); 436 static QString organizationLabel();
435 437
436 /** 438 /**
437 Set note. 439 Set note.
438 */ 440 */
439 void setNote( const QString &note ); 441 void setNote( const QString &note );
440 /** 442 /**
441 Return note. 443 Return note.
442 */ 444 */
443 QString note() const; 445 QString note() const;
444 /** 446 /**
445 Return translated label for note field. 447 Return translated label for note field.
446 */ 448 */
447 static QString noteLabel(); 449 static QString noteLabel();
448 450
449 /** 451 /**
450 Set product identifier. 452 Set product identifier.
451 */ 453 */
452 void setProductId( const QString &productId ); 454 void setProductId( const QString &productId );
453 /** 455 /**
454 Return product identifier. 456 Return product identifier.
455 */ 457 */
456 QString productId() const; 458 QString productId() const;
457 /** 459 /**
458 Return translated label for productId field. 460 Return translated label for productId field.
459 */ 461 */
460 static QString productIdLabel(); 462 static QString productIdLabel();
461 463
462 /** 464 /**
463 Set revision date. 465 Set revision date.
464 */ 466 */
465 void setRevision( const QDateTime &revision ); 467 void setRevision( const QDateTime &revision );
466 /** 468 /**
467 Return revision date. 469 Return revision date.
468 */ 470 */
469 QDateTime revision() const; 471 QDateTime revision() const;
470 /** 472 /**
471 Return translated label for revision field. 473 Return translated label for revision field.
472 */ 474 */
473 static QString revisionLabel(); 475 static QString revisionLabel();
474 476
475 /** 477 /**
476 Set sort string. 478 Set sort string.
477 */ 479 */
478 void setSortString( const QString &sortString ); 480 void setSortString( const QString &sortString );
479 /** 481 /**
480 Return sort string. 482 Return sort string.
481 */ 483 */
482 QString sortString() const; 484 QString sortString() const;
483 /** 485 /**
484 Return translated label for sortString field. 486 Return translated label for sortString field.
485 */ 487 */
486 static QString sortStringLabel(); 488 static QString sortStringLabel();
487 489
488 /** 490 /**
489 Set URL. 491 Set URL.
490 */ 492 */
491 void setUrl( const KURL &url ); 493 void setUrl( const KURL &url );
492 /** 494 /**
493 Return URL. 495 Return URL.
494 */ 496 */
495 KURL url() const; 497 KURL url() const;
496 /** 498 /**
497 Return translated label for url field. 499 Return translated label for url field.
498 */ 500 */
499 static QString urlLabel(); 501 static QString urlLabel();
500 502
501 /** 503 /**
502 Set security class. 504 Set security class.
503 */ 505 */
504 void setSecrecy( const Secrecy &secrecy ); 506 void setSecrecy( const Secrecy &secrecy );
505 /** 507 /**
506 Return security class. 508 Return security class.
507 */ 509 */
508 Secrecy secrecy() const; 510 Secrecy secrecy() const;
509 /** 511 /**
510 Return translated label for secrecy field. 512 Return translated label for secrecy field.
511 */ 513 */
512 static QString secrecyLabel(); 514 static QString secrecyLabel();
513 515
514 /** 516 /**
515 Set logo. 517 Set logo.
516 */ 518 */
517 void setLogo( const Picture &logo ); 519 void setLogo( const Picture &logo );
518 /** 520 /**
519 Return logo. 521 Return logo.
520 */ 522 */
521 Picture logo() const; 523 Picture logo() const;
522 /** 524 /**
523 Return translated label for logo field. 525 Return translated label for logo field.
524 */ 526 */
525 static QString logoLabel(); 527 static QString logoLabel();
526 528
527 /** 529 /**
528 Set photo. 530 Set photo.
529 */ 531 */
530 void setPhoto( const Picture &photo ); 532 void setPhoto( const Picture &photo );
531 /** 533 /**
532 Return photo. 534 Return photo.
533 */ 535 */
534 Picture photo() const; 536 Picture photo() const;
535 /** 537 /**
536 Return translated label for photo field. 538 Return translated label for photo field.
537 */ 539 */
538 static QString photoLabel(); 540 static QString photoLabel();
539 541
540 /** 542 /**
541 Set sound. 543 Set sound.
542 */ 544 */
543 void setSound( const Sound &sound ); 545 void setSound( const Sound &sound );
544 /** 546 /**
545 Return sound. 547 Return sound.
546 */ 548 */
547 Sound sound() const; 549 Sound sound() const;
548 /** 550 /**
549 Return translated label for sound field. 551 Return translated label for sound field.
550 */ 552 */
551 static QString soundLabel(); 553 static QString soundLabel();
552 554
553 /** 555 /**
554 Set agent. 556 Set agent.
555 */ 557 */
556 void setAgent( const Agent &agent ); 558 void setAgent( const Agent &agent );
557 /** 559 /**
558 Return agent. 560 Return agent.
559 */ 561 */
560 Agent agent() const; 562 Agent agent() const;
561 /** 563 /**
562 Return translated label for agent field. 564 Return translated label for agent field.
563 */ 565 */
564 static QString agentLabel(); 566 static QString agentLabel();
565 567
566 /** 568 /**
567 Set name fields by parsing the given string and trying to associate the 569 Set name fields by parsing the given string and trying to associate the
568 parts of the string with according fields. This function should probably 570 parts of the string with according fields. This function should probably
569 be a bit more clever. 571 be a bit more clever.
570 */ 572 */
571 void setNameFromString( const QString & ); 573 void setNameFromString( const QString & );
572 574
573 /** 575 /**
574 Return the name of the addressee. This is calculated from all the name 576 Return the name of the addressee. This is calculated from all the name
575 fields. 577 fields.
576 */ 578 */
577 QString realName() const; 579 QString realName() const;
578 580
579 /** 581 /**
580 Return the name that consists of all name parts. 582 Return the name that consists of all name parts.
581 */ 583 */
582 QString assembledName() const; 584 QString assembledName() const;
583 585
584 /** 586 /**
585 Return email address including real name. 587 Return email address including real name.
586 588
587 @param email Email address to be used to construct the full email string. 589 @param email Email address to be used to construct the full email string.
588 If this is QString::null the preferred email address is used. 590 If this is QString::null the preferred email address is used.
589 */ 591 */
590 QString fullEmail( const QString &email=QString::null ) const; 592 QString fullEmail( const QString &email=QString::null ) const;
591 593
592 /** 594 /**
593 Insert an email address. If the email address already exists in this 595 Insert an email address. If the email address already exists in this
594 addressee it is not duplicated. 596 addressee it is not duplicated.
595 597
596 @param email Email address 598 @param email Email address
597 @param preferred Set to true, if this is the preferred email address of 599 @param preferred Set to true, if this is the preferred email address of
598 the addressee. 600 the addressee.
599 */ 601 */
600 void insertEmail( const QString &email, bool preferred=false ); 602 void insertEmail( const QString &email, bool preferred=false );
601 603
602 /** 604 /**
603 Remove email address. If the email address doesn't exist, nothing happens. 605 Remove email address. If the email address doesn't exist, nothing happens.
604 */ 606 */
605 void removeEmail( const QString &email ); 607 void removeEmail( const QString &email );
606 608
607 /** 609 /**
608 Return preferred email address. This is the first email address or the 610 Return preferred email address. This is the first email address or the
609 last one added with @ref insertEmail() with a set preferred parameter. 611 last one added with @ref insertEmail() with a set preferred parameter.
610 */ 612 */
611 QString preferredEmail() const; 613 QString preferredEmail() const;
612 614
613 /** 615 /**
614 Return list of all email addresses. 616 Return list of all email addresses.
615 */ 617 */
616 QStringList emails() const; 618 QStringList emails() const;
617 619
618 /** 620 /**
619 Set the emails to @param. 621 Set the emails to @param.
620 The first email address gets the preferred one! 622 The first email address gets the preferred one!
621 @param list The list of email addresses. 623 @param list The list of email addresses.
622 */ 624 */
623 void setEmails( const QStringList& list); 625 void setEmails( const QStringList& list);
624 626
625 /** 627 /**
626 Insert a phone number. If a phone number with the same id already exists 628 Insert a phone number. If a phone number with the same id already exists
627 in this addressee it is not duplicated. 629 in this addressee it is not duplicated.
628 */ 630 */
629 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 631 void insertPhoneNumber( const PhoneNumber &phoneNumber );
630 632
631 /** 633 /**
632 Remove phone number. If no phone number with the given id exists for this 634 Remove phone number. If no phone number with the given id exists for this
633 addresse nothing happens. 635 addresse nothing happens.
634 */ 636 */
635 void removePhoneNumber( const PhoneNumber &phoneNumber ); 637 void removePhoneNumber( const PhoneNumber &phoneNumber );
636 638
637 /** 639 /**
638 Return phone number, which matches the given type. 640 Return phone number, which matches the given type.
639 */ 641 */
640 PhoneNumber phoneNumber( int type ) const; 642 PhoneNumber phoneNumber( int type ) const;
641 643
642 /** 644 /**
643 Return list of all phone numbers. 645 Return list of all phone numbers.
644 */ 646 */
645 PhoneNumber::List phoneNumbers() const; 647 PhoneNumber::List phoneNumbers() const;
646 648
647 /** 649 /**
648 Return list of phone numbers with a special type. 650 Return list of phone numbers with a special type.
649 */ 651 */
650 PhoneNumber::List phoneNumbers( int type ) const; 652 PhoneNumber::List phoneNumbers( int type ) const;
651 653
652 /** 654 /**
653 Return phone number with the given id. 655 Return phone number with the given id.
654 */ 656 */
655 PhoneNumber findPhoneNumber( const QString &id ) const; 657 PhoneNumber findPhoneNumber( const QString &id ) const;
656 658
657 /** 659 /**
658 Insert a key. If a key with the same id already exists 660 Insert a key. If a key with the same id already exists
659 in this addressee it is not duplicated. 661 in this addressee it is not duplicated.
660 */ 662 */
661 void insertKey( const Key &key ); 663 void insertKey( const Key &key );
662 664
663 /** 665 /**
664 Remove a key. If no key with the given id exists for this 666 Remove a key. If no key with the given id exists for this
665 addresse nothing happens. 667 addresse nothing happens.
666 */ 668 */
667 void removeKey( const Key &key ); 669 void removeKey( const Key &key );
668 670
669 /** 671 /**
670 Return key, which matches the given type. 672 Return key, which matches the given type.
671 If @p type == Key::Custom you can specify a string 673 If @p type == Key::Custom you can specify a string
672 that should match. If you leave the string empty, the first 674 that should match. If you leave the string empty, the first
673 key with a custom value is returned. 675 key with a custom value is returned.
674 */ 676 */
675 Key key( int type, QString customTypeString = QString::null ) const; 677 Key key( int type, QString customTypeString = QString::null ) const;
676 678
677 /** 679 /**
678 Return list of all keys. 680 Return list of all keys.
679 */ 681 */
680 Key::List keys() const; 682 Key::List keys() const;
681 683
682 /** 684 /**
683 Set the list of keys 685 Set the list of keys
684 @param keys The keys to be set. 686 @param keys The keys to be set.
685 */ 687 */
686 void setKeys( const Key::List& keys); 688 void setKeys( const Key::List& keys);
687 689
688 /** 690 /**
689 Return list of keys with a special type. 691 Return list of keys with a special type.
690 If @p type == Key::Custom you can specify a string 692 If @p type == Key::Custom you can specify a string
691 that should match. If you leave the string empty, all custom 693 that should match. If you leave the string empty, all custom
692 keys will be returned. 694 keys will be returned.
693 */ 695 */
694 Key::List keys( int type, QString customTypeString = QString::null ) const; 696 Key::List keys( int type, QString customTypeString = QString::null ) const;
695 697
696 /** 698 /**
697 Return key with the given id. 699 Return key with the given id.
698 */ 700 */
699 Key findKey( const QString &id ) const; 701 Key findKey( const QString &id ) const;
700 702
701 /** 703 /**
702 Insert an address. If an address with the same id already exists 704 Insert an address. If an address with the same id already exists
703 in this addressee it is not duplicated. 705 in this addressee it is not duplicated.
704 */ 706 */
705 void insertAddress( const Address &address ); 707 void insertAddress( const Address &address );
706 708
707 /** 709 /**
708 Remove address. If no address with the given id exists for this 710 Remove address. If no address with the given id exists for this
709 addresse nothing happens. 711 addresse nothing happens.
710 */ 712 */
711 void removeAddress( const Address &address ); 713 void removeAddress( const Address &address );
712 714
713 /** 715 /**
714 Return address, which matches the given type. 716 Return address, which matches the given type.
715 */ 717 */
716 Address address( int type ) const; 718 Address address( int type ) const;
717 719
718 /** 720 /**
719 Return list of all addresses. 721 Return list of all addresses.
720 */ 722 */
721 Address::List addresses() const; 723 Address::List addresses() const;
722 724
723 /** 725 /**
724 Return list of addresses with a special type. 726 Return list of addresses with a special type.
725 */ 727 */
726 Address::List addresses( int type ) const; 728 Address::List addresses( int type ) const;
727 729
728 /** 730 /**
729 Return address with the given id. 731 Return address with the given id.
730 */ 732 */
731 Address findAddress( const QString &id ) const; 733 Address findAddress( const QString &id ) const;
732 734
733 /** 735 /**
734 Insert category. If the category already exists it is not duplicated. 736 Insert category. If the category already exists it is not duplicated.
735 */ 737 */
736 void insertCategory( const QString & ); 738 void insertCategory( const QString & );
737 739
738 /** 740 /**
739 Remove category. 741 Remove category.
740 */ 742 */
741 void removeCategory( const QString & ); 743 void removeCategory( const QString & );
742 744
743 /** 745 /**
744 Return, if addressee has the given category. 746 Return, if addressee has the given category.
745 */ 747 */
746 bool hasCategory( const QString & ) const; 748 bool hasCategory( const QString & ) const;
747 749
748 /** 750 /**
749 Set categories to given value. 751 Set categories to given value.
750 */ 752 */
751 void setCategories( const QStringList & ); 753 void setCategories( const QStringList & );
752 754
753 /** 755 /**
754 Return list of all set categories. 756 Return list of all set categories.
755 */ 757 */
756 QStringList categories() const; 758 QStringList categories() const;
757 759
758 /** 760 /**
759 Insert custom entry. The entry is identified by the name of the inserting 761 Insert custom entry. The entry is identified by the name of the inserting
760 application and a unique name. If an entry with the given app and name 762 application and a unique name. If an entry with the given app and name
761 already exists its value is replaced with the new given value. 763 already exists its value is replaced with the new given value.
762 */ 764 */
763 void insertCustom( const QString &app, const QString &name, 765 void insertCustom( const QString &app, const QString &name,
764 const QString &value ); 766 const QString &value );
765 767
766 /** 768 /**
767 Remove custom entry. 769 Remove custom entry.
768 */ 770 */
769 void removeCustom( const QString &app, const QString &name ); 771 void removeCustom( const QString &app, const QString &name );
770 772
771 /** 773 /**
772 Return value of custom entry, identified by app and entry name. 774 Return value of custom entry, identified by app and entry name.
773 */ 775 */
774 QString custom( const QString &app, const QString &name ) const; 776 QString custom( const QString &app, const QString &name ) const;
775 777
776 /** 778 /**
777 Set all custom entries. 779 Set all custom entries.
778 */ 780 */
779 void setCustoms( const QStringList & ); 781 void setCustoms( const QStringList & );
780 782
781 /** 783 /**
782 Return list of all custom entries. 784 Return list of all custom entries.
783 */ 785 */
784 QStringList customs() const; 786 QStringList customs() const;
785 787
786 /** 788 /**
787 Parse full email address. The result is given back in fullName and email. 789 Parse full email address. The result is given back in fullName and email.
788 */ 790 */
789 static void parseEmailAddress( const QString &rawEmail, QString &fullName, 791 static void parseEmailAddress( const QString &rawEmail, QString &fullName,
790 QString &email ); 792 QString &email );
791 793
792 /** 794 /**
793 Debug output. 795 Debug output.
794 */ 796 */
795 void dump() const; 797 void dump() const;
796 798
797 /** 799 /**
798 Returns string representation of the addressee. 800 Returns string representation of the addressee.
799 */ 801 */
800 QString asString() const; 802 QString asString() const;
801 803
802 /** 804 /**
803 Set resource where the addressee is from. 805 Set resource where the addressee is from.
804 */ 806 */
805 void setResource( Resource *resource ); 807 void setResource( Resource *resource );
806 808
807 /** 809 /**
808 Return pointer to resource. 810 Return pointer to resource.
809 */ 811 */
810 Resource *resource() const; 812 Resource *resource() const;
811 813
812 /** 814 /**
813 Return resourcelabel. 815 Return resourcelabel.
814 */ 816 */
815 //US 817 //US
816 static QString resourceLabel(); 818 static QString resourceLabel();
817 819
818 /** 820 /**
819 Mark addressee as changed. 821 Mark addressee as changed.
820 */ 822 */
821 void setChanged( bool value ); 823 void setChanged( bool value );
822 824
823 /** 825 /**
824 Return whether the addressee is changed. 826 Return whether the addressee is changed.
825 */ 827 */
826 bool changed() const; 828 bool changed() const;
827 829
828 private: 830 private:
829 Addressee copy(); 831 Addressee copy();
830 void detach(); 832 void detach();
831 833
832 struct AddresseeData; 834 struct AddresseeData;
833 mutable KSharedPtr<AddresseeData> mData; 835 mutable KSharedPtr<AddresseeData> mData;
834}; 836};
835 837
836QDataStream &operator<<( QDataStream &, const Addressee & ); 838QDataStream &operator<<( QDataStream &, const Addressee & );
837QDataStream &operator>>( QDataStream &, Addressee & ); 839QDataStream &operator>>( QDataStream &, Addressee & );
838 840
839} 841}
840 842
841#endif 843#endif
diff --git a/kabc/plugins/qtopia/qtopiaE.pro b/kabc/plugins/qtopia/qtopiaE.pro
index 148da2a..c0aa960 100644
--- a/kabc/plugins/qtopia/qtopiaE.pro
+++ b/kabc/plugins/qtopia/qtopiaE.pro
@@ -1,27 +1,27 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3 3
4TARGET = microkabc_qtopia 4TARGET = microkabc_qtopia
5 5
6INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include 6INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include
7 7
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
10DESTDIR = $(QPEDIR)/lib 10DESTDIR = $(QPEDIR)/lib
11LIBS += -lmicrokde 11LIBS += -lmicrokde
12LIBS += -lmicrokabc 12LIBS += -lmicrokabc
13LIBS += -L$(QPEDIR)/lib 13LIBS += -L$(QPEDIR)/lib
14LIBS += -lqpepim 14LIBS += -lqpepim
15LIBS += -lqpe 15LIBS += -lqpe
16 16
17INTERFACES = \ 17INTERFACES = \
18 18
19HEADERS = \ 19HEADERS = \
20 resourceqtopia.h \ 20 resourceqtopia.h \
21 resourceqtopiaconfig.h \ 21 resourceqtopiaconfig.h \
22 qtopiaconverter.h 22 qtopiaconverter.h
23 23
24SOURCES = \ 24SOURCES = \
25 resourceqtopia.cpp \ 25 resourceqtopia.cpp \
26 resourceqtopiaconfig.cpp \ 26 resourceqtopiaconfig.cpp \
27 qtopiaconverter.cpp 27 qtopiaconverter.cpp
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index 7d00a3f..de45e63 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -1,369 +1,376 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@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/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28//US 28//US
29#include "kglobal.h" 29#include "kglobal.h"
30 30
31 31
32#include "qtopiaconverter.h" 32#include "qtopiaconverter.h"
33 33
34#include <qpe/categories.h> 34#include <qpe/categories.h>
35#include <libkdepim/ksyncprofile.h>
35//US #include <qpe/categoryselect.h> 36//US #include <qpe/categoryselect.h>
36 37
37 38
38using namespace KABC; 39using namespace KABC;
39 40
40QtopiaConverter::QtopiaConverter() : catDB(0) 41QtopiaConverter::QtopiaConverter() : catDB(0)
41{ 42{
42} 43}
43 44
44QtopiaConverter::~QtopiaConverter() 45QtopiaConverter::~QtopiaConverter()
45{ 46{
46 deinit(); 47 deinit();
47} 48}
48 49
49bool QtopiaConverter::init() 50bool QtopiaConverter::init()
50{ 51{
51 catDB = new Categories(); 52 catDB = new Categories();
52 53
53 if (!catDB) 54 if (!catDB)
54 return false; 55 return false;
55 56
56 catDB->load( categoryFileName() ); 57 catDB->load( categoryFileName() );
57 return true; 58 return true;
58} 59}
59 60
60void QtopiaConverter::deinit() 61void QtopiaConverter::deinit()
61{ 62{
62 if (catDB) 63 if (catDB)
63 { 64 {
64 delete catDB; 65 delete catDB;
65 catDB = 0; 66 catDB = 0;
66 } 67 }
67} 68}
68 69
69bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) 70bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr )
70{ 71{
71 // name 72 // name
72 addr.setFormattedName(contact.fileAs()); 73 addr.setFormattedName(contact.fileAs());
73 addr.setFamilyName( contact.lastName() ); 74 addr.setFamilyName( contact.lastName() );
74 addr.setGivenName( contact.firstName() ); 75 addr.setGivenName( contact.firstName() );
75 addr.setAdditionalName( contact.middleName() ); 76 addr.setAdditionalName( contact.middleName() );
76 addr.setPrefix( contact.nameTitle() ); 77 addr.setPrefix( contact.nameTitle() );
77 addr.setSuffix( contact.suffix() ); 78 addr.setSuffix( contact.suffix() );
79
80 addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
78 QString exuid = contact.uid().toString(); 81 QString exuid = contact.uid().toString();
82 addr.setOriginalExternalUID( exuid );
79 int ente = exuid.find( "-0000"); 83 int ente = exuid.find( "-0000");
80 if ( exuid.left(1) == "{" ) 84 if ( exuid.left(1) == "{" )
81 exuid = exuid.mid(1); 85 exuid = exuid.mid(1);
82 if ( ente > -1 ) 86 if ( ente > -1 )
83 exuid = exuid.left( ente-1 ); 87 exuid = exuid.left( ente-1 );
84 addr.setExternalUID( exuid ); 88 addr.setExternalUID( exuid );
85 //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() ); 89 //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() );
86 90
87 // email 91 // email
88 QStringList emails = contact.emailList(); 92 QStringList emails = contact.emailList();
89 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 93 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
90 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 94 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
91 } 95 }
92 96
93 if (!contact.defaultEmail().isEmpty()) 97 if (!contact.defaultEmail().isEmpty())
94 addr.insertEmail(contact.defaultEmail(), true); 98 addr.insertEmail(contact.defaultEmail(), true);
95 99
96 // home 100 // home
97 if ((!contact.homeStreet().isEmpty()) || 101 if ((!contact.homeStreet().isEmpty()) ||
98 (!contact.homeCity().isEmpty()) || 102 (!contact.homeCity().isEmpty()) ||
99 (!contact.homeState().isEmpty()) || 103 (!contact.homeState().isEmpty()) ||
100 (!contact.homeZip().isEmpty()) || 104 (!contact.homeZip().isEmpty()) ||
101 (!contact.homeCountry().isEmpty())) 105 (!contact.homeCountry().isEmpty()))
102 { 106 {
103 Address homeaddress; 107 Address homeaddress;
104 homeaddress.setType(Address::Home); 108 homeaddress.setType(Address::Home);
105//US homeaddress.setPostOfficeBox( "" ); 109//US homeaddress.setPostOfficeBox( "" );
106//US homeaddress.setExtended( "" ); 110//US homeaddress.setExtended( "" );
107 homeaddress.setStreet( contact.homeStreet() ); 111 homeaddress.setStreet( contact.homeStreet() );
108 homeaddress.setLocality( contact.homeCity() ); 112 homeaddress.setLocality( contact.homeCity() );
109 homeaddress.setRegion( contact.homeState() ); 113 homeaddress.setRegion( contact.homeState() );
110 homeaddress.setPostalCode( contact.homeZip() ); 114 homeaddress.setPostalCode( contact.homeZip() );
111 homeaddress.setCountry( contact.homeCountry() ); 115 homeaddress.setCountry( contact.homeCountry() );
112 116
113 addr.insertAddress( homeaddress ); 117 addr.insertAddress( homeaddress );
114 } 118 }
115 119
116 if (!contact.homePhone().isEmpty()) 120 if (!contact.homePhone().isEmpty())
117 { 121 {
118 PhoneNumber homephone; 122 PhoneNumber homephone;
119 homephone.setType( PhoneNumber::Home ); 123 homephone.setType( PhoneNumber::Home );
120 homephone.setNumber( contact.homePhone() ); 124 homephone.setNumber( contact.homePhone() );
121 addr.insertPhoneNumber( homephone ); 125 addr.insertPhoneNumber( homephone );
122 } 126 }
123 127
124 if (!contact.homeFax().isEmpty()) 128 if (!contact.homeFax().isEmpty())
125 { 129 {
126 PhoneNumber homefax; 130 PhoneNumber homefax;
127 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); 131 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax );
128 homefax.setNumber( contact.homeFax() ); 132 homefax.setNumber( contact.homeFax() );
129 addr.insertPhoneNumber( homefax ); 133 addr.insertPhoneNumber( homefax );
130 } 134 }
131 135
132 if (!contact.homeMobile().isEmpty()) 136 if (!contact.homeMobile().isEmpty())
133 { 137 {
134 PhoneNumber homemobile; 138 PhoneNumber homemobile;
135 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); 139 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell );
136 homemobile.setNumber( contact.homeMobile() ); 140 homemobile.setNumber( contact.homeMobile() );
137 addr.insertPhoneNumber( homemobile ); 141 addr.insertPhoneNumber( homemobile );
138 } 142 }
139 143
140 addr.setUrl( contact.homeWebpage() ); 144 addr.setUrl( contact.homeWebpage() );
141 145
142 146
143 // business 147 // business
144 if ((!contact.businessStreet().isEmpty()) || 148 if ((!contact.businessStreet().isEmpty()) ||
145 (!contact.businessCity().isEmpty()) || 149 (!contact.businessCity().isEmpty()) ||
146 (!contact.businessState().isEmpty()) || 150 (!contact.businessState().isEmpty()) ||
147 (!contact.businessZip().isEmpty()) || 151 (!contact.businessZip().isEmpty()) ||
148 (!contact.businessCountry().isEmpty())) 152 (!contact.businessCountry().isEmpty()))
149 { 153 {
150 Address businessaddress; 154 Address businessaddress;
151 businessaddress.setType(Address::Work); 155 businessaddress.setType(Address::Work);
152//US businessaddress.setPostOfficeBox( "" ); 156//US businessaddress.setPostOfficeBox( "" );
153//US businessaddress.setExtended( "" ); 157//US businessaddress.setExtended( "" );
154 businessaddress.setStreet( contact.businessStreet() ); 158 businessaddress.setStreet( contact.businessStreet() );
155 businessaddress.setLocality( contact.businessCity() ); 159 businessaddress.setLocality( contact.businessCity() );
156 businessaddress.setRegion( contact.businessState() ); 160 businessaddress.setRegion( contact.businessState() );
157 businessaddress.setPostalCode( contact.businessZip() ); 161 businessaddress.setPostalCode( contact.businessZip() );
158 businessaddress.setCountry( contact.businessCountry() ); 162 businessaddress.setCountry( contact.businessCountry() );
159 163
160 addr.insertAddress( businessaddress ); 164 addr.insertAddress( businessaddress );
161 } 165 }
162 166
163 167
164 if (!contact.businessPhone().isEmpty()) 168 if (!contact.businessPhone().isEmpty())
165 { 169 {
166 PhoneNumber businessphone; 170 PhoneNumber businessphone;
167 businessphone.setType( PhoneNumber::Work ); 171 businessphone.setType( PhoneNumber::Work );
168 businessphone.setNumber( contact.businessPhone() ); 172 businessphone.setNumber( contact.businessPhone() );
169 addr.insertPhoneNumber( businessphone ); 173 addr.insertPhoneNumber( businessphone );
170 } 174 }
171 175
172 if (!contact.businessFax().isEmpty()) 176 if (!contact.businessFax().isEmpty())
173 { 177 {
174 PhoneNumber businessfax; 178 PhoneNumber businessfax;
175 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); 179 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax );
176 businessfax.setNumber( contact.businessFax() ); 180 businessfax.setNumber( contact.businessFax() );
177 addr.insertPhoneNumber( businessfax ); 181 addr.insertPhoneNumber( businessfax );
178 } 182 }
179 183
180 if (!contact.businessMobile().isEmpty()) 184 if (!contact.businessMobile().isEmpty())
181 { 185 {
182 PhoneNumber businessmobile; 186 PhoneNumber businessmobile;
183 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); 187 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell );
184 businessmobile.setNumber( contact.businessMobile() ); 188 businessmobile.setNumber( contact.businessMobile() );
185 addr.insertPhoneNumber( businessmobile ); 189 addr.insertPhoneNumber( businessmobile );
186 } 190 }
187 191
188 if (!contact.businessPager().isEmpty()) 192 if (!contact.businessPager().isEmpty())
189 { 193 {
190 PhoneNumber businesspager; 194 PhoneNumber businesspager;
191 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); 195 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager );
192 businesspager.setNumber( contact.businessPager() ); 196 businesspager.setNumber( contact.businessPager() );
193 addr.insertPhoneNumber( businesspager ); 197 addr.insertPhoneNumber( businesspager );
194 } 198 }
195 199
196 addr.setRole( contact.jobTitle() ); //? 200 addr.setRole( contact.jobTitle() ); //?
197 addr.setOrganization( contact.company() ); 201 addr.setOrganization( contact.company() );
198 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); 202 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() );
199 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); 203 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() );
200 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); 204 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() );
201 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); 205 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() );
202 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); 206 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() );
203 207
204 //personal 208 //personal
205 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); 209 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() );
206 // qtopia uses this categorization: 210 // qtopia uses this categorization:
207 // enum GenderType { UnspecifiedGender=0, Male, Female }; 211 // enum GenderType { UnspecifiedGender=0, Male, Female };
208 if (contact.gender() == PimContact::Male) 212 if (contact.gender() == PimContact::Male)
209 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); 213 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
210 else if (contact.gender() == PimContact::Female) 214 else if (contact.gender() == PimContact::Female)
211 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); 215 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
212 216
213 if (contact.anniversary().isValid()) { 217 if (contact.anniversary().isValid()) {
214 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); 218 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
215//US 219//US
216// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); 220// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1());
217 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 221 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
218 } 222 }
219 223
220 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); 224 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
221 if (contact.birthday().isValid()) 225 if (contact.birthday().isValid())
222 addr.setBirthday( contact.birthday() ); 226 addr.setBirthday( contact.birthday() );
223 227
224 addr.setNickName( contact.nickname() ); 228 addr.setNickName( contact.nickname() );
225 229
226 // others 230 // others
227 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. 231 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
228 QString notes = contact.notes(); 232 QString notes = contact.notes();
229 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; 233 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n";
230 234
231 addr.setNote( contact.notes() ); 235 addr.setNote( contact.notes() );
232 236
233 237
234 238
235//US QString groups() const { return find( Qtopia::Groups ); } 239//US QString groups() const { return find( Qtopia::Groups ); }
236//US QStringList groupList() const; 240//US QStringList groupList() const;
237 241
238 QArray<int> catArray = contact.categories(); 242 QArray<int> catArray = contact.categories();
239 QString cat; 243 QString cat;
240 244
241 for ( unsigned int i=0; i < catArray.size(); i++ ) { 245 for ( unsigned int i=0; i < catArray.size(); i++ ) {
242 cat = catDB->label("contact", catArray[i]); 246 cat = catDB->label("contact", catArray[i]);
243 if ( cat.isEmpty() ) 247 if ( cat.isEmpty() )
244 addr.insertCategory(QString::number(catArray[i])); 248 addr.insertCategory(QString::number(catArray[i]));
245 else 249 else
246 addr.insertCategory( cat ); 250 addr.insertCategory( cat );
247 } 251 }
248 252
249 return true; 253 return true;
250} 254}
251 255
252bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact ) 256bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact )
253{ 257{
258
259
260
254 // name 261 // name
255 contact.setLastName(addr.familyName()); 262 contact.setLastName(addr.familyName());
256 contact.setFirstName(addr.givenName()); 263 contact.setFirstName(addr.givenName());
257 contact.setMiddleName(addr.additionalName()); 264 contact.setMiddleName(addr.additionalName());
258 contact.setNameTitle(addr.prefix()); 265 contact.setNameTitle(addr.prefix());
259 contact.setSuffix(addr.suffix()); 266 contact.setSuffix(addr.suffix());
260 contact.setFileAs(); 267 contact.setFileAs();
261 268
262 269
263 // email 270 // email
264 QStringList emails = addr.emails(); 271 QStringList emails = addr.emails();
265 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 272 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
266 contact.insertEmail(*it); 273 contact.insertEmail(*it);
267 } 274 }
268 contact.setDefaultEmail( addr.preferredEmail() ); 275 contact.setDefaultEmail( addr.preferredEmail() );
269 276
270 277
271 // home 278 // home
272 const Address homeaddress = addr.address(Address::Home); 279 const Address homeaddress = addr.address(Address::Home);
273 if (!homeaddress.isEmpty()) { 280 if (!homeaddress.isEmpty()) {
274 contact.setHomeStreet(homeaddress.street()); 281 contact.setHomeStreet(homeaddress.street());
275 contact.setHomeCity(homeaddress.locality()); 282 contact.setHomeCity(homeaddress.locality());
276 contact.setHomeState(homeaddress.region()); 283 contact.setHomeState(homeaddress.region());
277 contact.setHomeZip(homeaddress.postalCode()); 284 contact.setHomeZip(homeaddress.postalCode());
278 contact.setHomeCountry(homeaddress.country()); 285 contact.setHomeCountry(homeaddress.country());
279 } 286 }
280 287
281 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); 288 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
282 if (!homephone.number().isEmpty()) 289 if (!homephone.number().isEmpty())
283 contact.setHomePhone(homephone.number()); 290 contact.setHomePhone(homephone.number());
284 291
285 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); 292 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
286 if (!homefax.number().isEmpty()) 293 if (!homefax.number().isEmpty())
287 contact.setHomeFax(homefax.number()); 294 contact.setHomeFax(homefax.number());
288 295
289 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); 296 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
290 if (!homemobile.number().isEmpty()) 297 if (!homemobile.number().isEmpty())
291 contact.setHomeMobile(homemobile.number()); 298 contact.setHomeMobile(homemobile.number());
292 299
293 contact.setHomeWebpage(addr.url().url()); 300 contact.setHomeWebpage(addr.url().url());
294 301
295 302
296 // business 303 // business
297 const Address businessaddress = addr.address(Address::Work); 304 const Address businessaddress = addr.address(Address::Work);
298 if (!businessaddress.isEmpty()) { 305 if (!businessaddress.isEmpty()) {
299 contact.setBusinessStreet(businessaddress.street()); 306 contact.setBusinessStreet(businessaddress.street());
300 contact.setBusinessCity(businessaddress.locality()); 307 contact.setBusinessCity(businessaddress.locality());
301 contact.setBusinessState(businessaddress.region()); 308 contact.setBusinessState(businessaddress.region());
302 contact.setBusinessZip(businessaddress.postalCode()); 309 contact.setBusinessZip(businessaddress.postalCode());
303 contact.setBusinessCountry(businessaddress.country()); 310 contact.setBusinessCountry(businessaddress.country());
304 } 311 }
305 312
306 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); 313 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
307 if (!businessphone.number().isEmpty()) 314 if (!businessphone.number().isEmpty())
308 contact.setBusinessPhone(businessphone.number()); 315 contact.setBusinessPhone(businessphone.number());
309 316
310 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); 317 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
311 if (!businessfax.number().isEmpty()) 318 if (!businessfax.number().isEmpty())
312 contact.setBusinessFax(businessfax.number()); 319 contact.setBusinessFax(businessfax.number());
313 320
314 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); 321 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
315 if (!businessmobile.number().isEmpty()) 322 if (!businessmobile.number().isEmpty())
316 contact.setBusinessMobile(businessmobile.number()); 323 contact.setBusinessMobile(businessmobile.number());
317 324
318 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); 325 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
319 if (!businesspager.number().isEmpty()) 326 if (!businesspager.number().isEmpty())
320 contact.setBusinessPager(businesspager.number()); 327 contact.setBusinessPager(businesspager.number());
321 328
322 contact.setJobTitle(addr.role()); 329 contact.setJobTitle(addr.role());
323 contact.setCompany(addr.organization()); 330 contact.setCompany(addr.organization());
324 331
325 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); 332 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" ));
326 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); 333 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
327 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); 334 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" ));
328 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); 335 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
329 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); 336 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" ));
330 337
331 //personal 338 //personal
332 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); 339 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" ));
333 // qtopia uses this categorization: 340 // qtopia uses this categorization:
334 // enum GenderType { UnspecifiedGender=0, Male, Female }; 341 // enum GenderType { UnspecifiedGender=0, Male, Female };
335 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); 342 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" );
336 if (gt = "male") 343 if (gt = "male")
337 contact.setGender(PimContact::Male); 344 contact.setGender(PimContact::Male);
338 else if (gt = "female") 345 else if (gt = "female")
339 contact.setGender(PimContact::Female); 346 contact.setGender(PimContact::Female);
340 else 347 else
341 contact.setGender(PimContact::UnspecifiedGender); 348 contact.setGender(PimContact::UnspecifiedGender);
342 349
343 350
344 QDate dt = KGlobal::locale()->readDate( 351 QDate dt = KGlobal::locale()->readDate(
345 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate 352 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
346 contact.setAnniversary( dt ); 353 contact.setAnniversary( dt );
347 354
348 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); 355 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" ));
349 356
350 contact.setBirthday(addr.birthday().date()); 357 contact.setBirthday(addr.birthday().date());
351 contact.setNickname(addr.nickName()); 358 contact.setNickname(addr.nickName());
352 359
353 // other 360 // other
354 contact.setNotes(addr.note()); 361 contact.setNotes(addr.note());
355 362
356//US QString groups() const { return find( Qtopia::Groups ); } 363//US QString groups() const { return find( Qtopia::Groups ); }
357//US QStringList groupList() const; 364//US QStringList groupList() const;
358 365
359 366
360 QStringList cats = addr.categories(); 367 QStringList cats = addr.categories();
361 368
362 QArray<int> iar; 369 QArray<int> iar;
363 if ( !cats.isEmpty() ) { 370 if ( !cats.isEmpty() ) {
364 QArray<int> iar = catDB->ids("contact", cats); 371 QArray<int> iar = catDB->ids("contact", cats);
365 contact.setCategories(iar); 372 contact.setCategories(iar);
366 } 373 }
367 374
368 return true; 375 return true;
369} 376}
diff --git a/kabc/plugins/qtopia/qtopiaconverter.h b/kabc/plugins/qtopia/qtopiaconverter.h
index 8f4c698..012a6e2 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.h
+++ b/kabc/plugins/qtopia/qtopiaconverter.h
@@ -1,79 +1,80 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@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/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24$Id$ 24$Id$
25*/ 25*/
26 26
27#ifndef KABC_QTOPIACONVERTER_H 27#ifndef KABC_QTOPIACONVERTER_H
28#define KABC_QTOPIACONVERTER_H 28#define KABC_QTOPIACONVERTER_H
29 29
30#include <qstring.h> 30#include <qstring.h>
31 31
32#include "addressee.h" 32#include "addressee.h"
33#include <qpe/pim/contact.h> 33#include <qpe/pim/contact.h>
34#include <qpe/quuid.h>
34 35
35class Categories; 36class Categories;
36 37
37namespace KABC { 38namespace KABC {
38 39
39class QtopiaConverter 40class QtopiaConverter
40{ 41{
41public: 42public:
42 43
43 /** 44 /**
44 * Constructor. 45 * Constructor.
45 */ 46 */
46 QtopiaConverter(); 47 QtopiaConverter();
47 48
48 /** 49 /**
49 * Destructor. 50 * Destructor.
50 */ 51 */
51 virtual ~QtopiaConverter(); 52 virtual ~QtopiaConverter();
52 53
53 bool init(); 54 bool init();
54 void deinit(); 55 void deinit();
55 56
56 /** 57 /**
57 * Converts a vcard string to an addressee. 58 * Converts a vcard string to an addressee.
58 * 59 *
59 * @param contact The qtopia contact. 60 * @param contact The qtopia contact.
60 * @param addr The addressee. 61 * @param addr The addressee.
61 */ 62 */
62 bool qtopiaToAddressee( const PimContact &contact, Addressee &addr ); 63 bool qtopiaToAddressee( const PimContact &contact, Addressee &addr );
63 64
64 /** 65 /**
65 * Converts an addressee to a vcard string. 66 * Converts an addressee to a vcard string.
66 * 67 *
67 * @param addr The addressee. 68 * @param addr The addressee.
68 * @param contact The qtopia contact. 69 * @param contact The qtopia contact.
69 */ 70 */
70 bool addresseeToQtopia( const Addressee &addr, PimContact &contact ); 71 bool addresseeToQtopia( const Addressee &addr, PimContact &contact );
71 72
72 private: 73 private:
73 Categories* catDB; 74 Categories* catDB;
74 75
75 76
76}; 77};
77 78
78} 79}
79#endif 80#endif
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 48a9f22..935a1cf 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -1,322 +1,346 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
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/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27#include <sys/types.h> 27#include <sys/types.h>
28#include <sys/stat.h> 28#include <sys/stat.h>
29#include <unistd.h> 29#include <unistd.h>
30 30
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qfileinfo.h> 33#include <qfileinfo.h>
34#include <qregexp.h> 34#include <qregexp.h>
35//US #include <qtimer.h> 35//US #include <qtimer.h>
36 36
37#include <kapplication.h> 37#include <kapplication.h>
38#include <kconfig.h> 38#include <kconfig.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41//US #include <ksavefile.h> 41//US #include <ksavefile.h>
42#include <kstandarddirs.h> 42#include <kstandarddirs.h>
43#include <kmessagebox.h> 43#include <kmessagebox.h>
44 44
45#include <qpe/pim/addressbookaccess.h> 45#include <qpe/pim/addressbookaccess.h>
46 46
47 47
48#include "resourceqtopiaconfig.h" 48#include "resourceqtopiaconfig.h"
49#include "stdaddressbook.h" 49#include "stdaddressbook.h"
50 50
51#include "qtopiaconverter.h" 51#include "qtopiaconverter.h"
52#include "syncprefwidget.h" 52#include "syncprefwidget.h"
53 53
54#include "resourceqtopia.h" 54#include "resourceqtopia.h"
55#include <libkdepim/ksyncprofile.h>
56#include <qpe/quuid.h>
55 57
56using namespace KABC; 58using namespace KABC;
57extern "C" 59extern "C"
58{ 60{
59 void *init_microkabc_qtopia() 61 void *init_microkabc_qtopia()
60 { 62 {
61 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidgetContainer>(); 63 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidgetContainer>();
62 } 64 }
63} 65}
64 66
65ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable ) 67ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable )
66 : Resource( config, syncable ), mConverter (0) 68 : Resource( config, syncable ), mConverter (0)
67{ 69{
68 // we can not choose the filename. Therefore use the default to display 70 // we can not choose the filename. Therefore use the default to display
69 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 71 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
70 init( fileName ); 72 init( fileName );
71} 73}
72 74
73ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable ) 75ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable )
74 : Resource( 0, syncable ) 76 : Resource( 0, syncable )
75{ 77{
76 init( fileName ); 78 init( fileName );
77} 79}
78 80
79void ResourceQtopia::init( const QString &fileName ) 81void ResourceQtopia::init( const QString &fileName )
80{ 82{
81 83
82 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 84 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
83 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 85 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
84 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 86 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
85 87
86 setFileName( fileName ); 88 setFileName( fileName );
87} 89}
88 90
89ResourceQtopia::~ResourceQtopia() 91ResourceQtopia::~ResourceQtopia()
90{ 92{
91 if (mConverter != 0) 93 if (mConverter != 0)
92 delete mConverter; 94 delete mConverter;
93 95
94 if(mAccess != 0) 96 if(mAccess != 0)
95 delete mAccess; 97 delete mAccess;
96} 98}
97 99
98void ResourceQtopia::writeConfig( KConfig *config ) 100void ResourceQtopia::writeConfig( KConfig *config )
99{ 101{
100 Resource::writeConfig( config ); 102 Resource::writeConfig( config );
101} 103}
102 104
103Ticket *ResourceQtopia::requestSaveTicket() 105Ticket *ResourceQtopia::requestSaveTicket()
104{ 106{
105 kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl; 107 kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl;
106 108
107 qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1()); 109 qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1());
108 110
109 if ( !addressBook() ) return 0; 111 if ( !addressBook() ) return 0;
110 112
111 if ( !lock( fileName() ) ) { 113 if ( !lock( fileName() ) ) {
112 kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '" 114 kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '"
113 << fileName() << "'" << endl; 115 << fileName() << "'" << endl;
114 return 0; 116 return 0;
115 } 117 }
116 return createTicket( this ); 118 return createTicket( this );
117} 119}
118 120
119 121
120bool ResourceQtopia::doOpen() 122bool ResourceQtopia::doOpen()
121{ 123{
122 qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1()); 124 qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1());
123 125
124 mAccess = new AddressBookAccess(); 126 mAccess = new AddressBookAccess();
125 127
126 if ( !mAccess ) { 128 if ( !mAccess ) {
127 qDebug("Unable to load file() %s", fileName().latin1()); 129 qDebug("Unable to load file() %s", fileName().latin1());
128 return false; 130 return false;
129 } 131 }
130 132
131 133
132 if (mConverter == 0) 134 if (mConverter == 0)
133 { 135 {
134 mConverter = new QtopiaConverter(); 136 mConverter = new QtopiaConverter();
135 bool res = mConverter->init(); 137 bool res = mConverter->init();
136 if ( !res ) 138 if ( !res )
137 { 139 {
138 QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file"); 140 QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file");
139 qDebug(msg); 141 qDebug(msg);
140 delete mAccess; 142 delete mAccess;
141 mAccess = 0; 143 mAccess = 0;
142 return false; 144 return false;
143 } 145 }
144 } 146 }
145 147
146 return true; 148 return true;
147} 149}
148 150
149void ResourceQtopia::doClose() 151void ResourceQtopia::doClose()
150{ 152{
151 qDebug("ResourceQtopia::doClose: %s", fileName().latin1()); 153 qDebug("ResourceQtopia::doClose: %s", fileName().latin1());
152 154
153 if(mAccess) 155 if(mAccess)
154 { 156 {
155 delete mAccess; 157 delete mAccess;
156 mAccess = 0; 158 mAccess = 0;
157 } 159 }
158 // it seems so, that deletion of access deletes backend as well 160 // it seems so, that deletion of access deletes backend as well
159 //delete backend; 161 //delete backend;
160 162
161 return; 163 return;
162} 164}
163 165
164bool ResourceQtopia::load() 166bool ResourceQtopia::load()
165{ 167{
166 qDebug("ResourceQtopia::load: %s", fileName().latin1()); 168 qDebug("ResourceQtopia::load: %s", fileName().latin1());
167 169
168 AddressBookIterator it(*mAccess); 170 AddressBookIterator it(*mAccess);
169 const PimContact* contact; 171 const PimContact* contact;
170 bool res; 172 bool res;
171 173
172 for (contact=it.toFirst(); it.current(); ++it) 174 for (contact=it.toFirst(); it.current(); ++it)
173 { 175 {
174 contact = it.current(); 176 contact = it.current();
175 177
176 KABC::Addressee addressee; 178 KABC::Addressee addressee;
177 179
178 res = mConverter->qtopiaToAddressee( (*contact), addressee ); 180 res = mConverter->qtopiaToAddressee( (*contact), addressee );
179 181
180 if ( !addressee.isEmpty() && res ) 182 if ( !addressee.isEmpty() && res )
181 { 183 {
182 addressee.setResource( this ); 184 addressee.setResource( this );
183 addressBook()->insertAddressee( addressee ); 185 addressBook()->insertAddressee( addressee );
184 } 186 }
185 } 187 }
186 188
187 return true; 189 return true;
188} 190}
189 191
190bool ResourceQtopia::save( Ticket *ticket ) 192bool ResourceQtopia::save( Ticket *ticket )
191{ 193{
192 qDebug("ResourceQtopia::save: %s", fileName().latin1()); 194 qDebug("ResourceQtopia::save: %s", fileName().latin1());
193 195
194 mDirWatch.stopScan(); 196 mDirWatch.stopScan();
195 197
196 KABC::AddressBook::Iterator it; 198 KABC::AddressBook::Iterator it;
197 bool res; 199 bool res;
198 200
199 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 201 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
200 PimContact c; 202 //KABC::Addressee addressee = (*it);
201 KABC::Addressee addressee = (*it); 203 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
202 204 QUuid uid( (*it).originalExternalUID() );
203 res = mConverter->addresseeToQtopia( *it, c ); 205 bool ok;
204 if (res == true) 206 PimContact c = mAccess->contactForId( uid, &ok );
205 { 207 res = mConverter->addresseeToQtopia( *it, c );
206 mAccess->addContact(c); 208 if (res == true) {
207// if (res == false) 209 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
208// qDebug("Unable to append Contact %s", c.fullName().latin1()); 210 mAccess->addContact(c);
211 KABC::Addressee addressee;
212 mConverter->qtopiaToAddressee( c, addressee );
213 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
214 addressBook()->insertAddressee( addressee );
215
216 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
217 if ( ok )
218 mAccess->removeContact(c);
219 else
220 qDebug("Error revoe contact from qtopia ");
221 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
222 if ( ok ) {
223 mAccess->updateContact(c);
224 KABC::Addressee addressee;
225 mConverter->qtopiaToAddressee( c, addressee );
226 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
227 addressBook()->insertAddressee( addressee );
228 }
229 else
230 qDebug("Error update contact from qtopia ");
231
232 }
233
234 } else {
235 qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1());
236 }
237 }
209 } 238 }
210 else
211 {
212 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
213 }
214 }
215 239
216// mAccess->addressBookUpdated(); 240 // mAccess->addressBookUpdated();
217 241
218 mDirWatch.startScan(); 242 mDirWatch.startScan();
219 243
220 delete ticket; 244 delete ticket;
221 unlock( fileName() ); 245 unlock( fileName() );
222 246
223 return true; 247 return true;
224} 248}
225 249
226bool ResourceQtopia::lock( const QString &lockfileName ) 250bool ResourceQtopia::lock( const QString &lockfileName )
227{ 251{
228 qDebug("ResourceQtopia::lock: %s", fileName().latin1()); 252 qDebug("ResourceQtopia::lock: %s", fileName().latin1());
229 253
230 kdDebug(5700) << "ResourceQtopia::lock()" << endl; 254 kdDebug(5700) << "ResourceQtopia::lock()" << endl;
231 255
232 QString fn = lockfileName; 256 QString fn = lockfileName;
233 257
234 KURL url(fn); 258 KURL url(fn);
235 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 259 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
236 260
237 kdDebug(5700) << "-- lock name: " << lockName << endl; 261 kdDebug(5700) << "-- lock name: " << lockName << endl;
238 262
239 if (QFile::exists( lockName )) 263 if (QFile::exists( lockName ))
240 { 264 {
241 qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1()); 265 qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1());
242 return false; 266 return false;
243 } 267 }
244 268
245 QString lockUniqueName; 269 QString lockUniqueName;
246 lockUniqueName = fn + KApplication::randomString( 8 ); 270 lockUniqueName = fn + KApplication::randomString( 8 );
247 271
248 url = lockUniqueName; 272 url = lockUniqueName;
249//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 273//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
250 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 274 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
251 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 275 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
252 276
253 // Create unique file 277 // Create unique file
254 QFile file( mLockUniqueName ); 278 QFile file( mLockUniqueName );
255 file.open( IO_WriteOnly ); 279 file.open( IO_WriteOnly );
256 file.close(); 280 file.close();
257 281
258 // Create lock file 282 // Create lock file
259 int result = 0; 283 int result = 0;
260#ifndef _WIN32_ 284#ifndef _WIN32_
261 result = ::link( QFile::encodeName( mLockUniqueName ), 285 result = ::link( QFile::encodeName( mLockUniqueName ),
262 QFile::encodeName( lockName ) ); 286 QFile::encodeName( lockName ) );
263#endif 287#endif
264 if ( result == 0 ) { 288 if ( result == 0 ) {
265 addressBook()->emitAddressBookLocked(); 289 addressBook()->emitAddressBookLocked();
266 return true; 290 return true;
267 } 291 }
268 292
269 // TODO: check stat 293 // TODO: check stat
270 294
271 return false; 295 return false;
272} 296}
273 297
274void ResourceQtopia::unlock( const QString &fileName ) 298void ResourceQtopia::unlock( const QString &fileName )
275{ 299{
276 qDebug("ResourceQtopia::unlock() %s", fileName.latin1()); 300 qDebug("ResourceQtopia::unlock() %s", fileName.latin1());
277 301
278 QString fn = fileName; 302 QString fn = fileName;
279 KURL url(fn); 303 KURL url(fn);
280 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 304 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
281 305
282 QFile::remove( lockName ); 306 QFile::remove( lockName );
283 QFile::remove( mLockUniqueName ); 307 QFile::remove( mLockUniqueName );
284 addressBook()->emitAddressBookUnlocked(); 308 addressBook()->emitAddressBookUnlocked();
285} 309}
286 310
287void ResourceQtopia::setFileName( const QString &newFileName ) 311void ResourceQtopia::setFileName( const QString &newFileName )
288{ 312{
289 mDirWatch.stopScan(); 313 mDirWatch.stopScan();
290 mDirWatch.removeFile( fileName() ); 314 mDirWatch.removeFile( fileName() );
291 315
292 Resource::setFileName( newFileName ); 316 Resource::setFileName( newFileName );
293 317
294 mDirWatch.addFile( fileName() ); 318 mDirWatch.addFile( fileName() );
295 mDirWatch.startScan(); 319 mDirWatch.startScan();
296} 320}
297 321
298 322
299void ResourceQtopia::fileChanged() 323void ResourceQtopia::fileChanged()
300{ 324{
301 // There is a small theoretical chance that KDirWatch calls us before 325 // There is a small theoretical chance that KDirWatch calls us before
302 // we are fully constructed 326 // we are fully constructed
303 if (!addressBook()) 327 if (!addressBook())
304 return; 328 return;
305 329
306 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); 330 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) );
307 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { 331 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
308 load(); 332 load();
309 addressBook()->emitAddressBookChanged(); 333 addressBook()->emitAddressBookChanged();
310 } 334 }
311} 335}
312 336
313void ResourceQtopia::removeAddressee( const Addressee &addr ) 337void ResourceQtopia::removeAddressee( const Addressee &addr )
314{ 338{
315} 339}
316 340
317void ResourceQtopia::cleanUp() 341void ResourceQtopia::cleanUp()
318{ 342{
319 unlock( fileName() ); 343 unlock( fileName() );
320} 344}
321 345
322//US #include "resourceqtopia.moc" 346//US #include "resourceqtopia.moc"
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d6482fb..b3d88de 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1987,1038 +1987,1073 @@ void KABCore::configureResources()
1987 1987
1988 1988
1989/* this method will be called through the QCop interface from Ko/Pi to select addresses 1989/* this method will be called through the QCop interface from Ko/Pi to select addresses
1990 * for the attendees list of an event. 1990 * for the attendees list of an event.
1991 */ 1991 */
1992void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 1992void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
1993{ 1993{
1994 QStringList nameList; 1994 QStringList nameList;
1995 QStringList emailList; 1995 QStringList emailList;
1996 QStringList uidList; 1996 QStringList uidList;
1997 1997
1998 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 1998 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
1999 uint i=0; 1999 uint i=0;
2000 for (i=0; i < list.count(); i++) 2000 for (i=0; i < list.count(); i++)
2001 { 2001 {
2002 nameList.append(list[i].realName()); 2002 nameList.append(list[i].realName());
2003 emailList.append(list[i].preferredEmail()); 2003 emailList.append(list[i].preferredEmail());
2004 uidList.append(list[i].uid()); 2004 uidList.append(list[i].uid());
2005 } 2005 }
2006 2006
2007 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2007 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2008 2008
2009} 2009}
2010 2010
2011/* this method will be called through the QCop interface from other apps to show details of a contact. 2011/* this method will be called through the QCop interface from other apps to show details of a contact.
2012 */ 2012 */
2013void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2013void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2014{ 2014{
2015 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2015 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2016 2016
2017 QString foundUid = QString::null; 2017 QString foundUid = QString::null;
2018 if ( ! uid.isEmpty() ) { 2018 if ( ! uid.isEmpty() ) {
2019 Addressee adrr = mAddressBook->findByUid( uid ); 2019 Addressee adrr = mAddressBook->findByUid( uid );
2020 if ( !adrr.isEmpty() ) { 2020 if ( !adrr.isEmpty() ) {
2021 foundUid = uid; 2021 foundUid = uid;
2022 } 2022 }
2023 if ( email == "sendbacklist" ) { 2023 if ( email == "sendbacklist" ) {
2024 //qDebug("ssssssssssssssssssssssend "); 2024 //qDebug("ssssssssssssssssssssssend ");
2025 QStringList nameList; 2025 QStringList nameList;
2026 QStringList emailList; 2026 QStringList emailList;
2027 QStringList uidList; 2027 QStringList uidList;
2028 nameList.append(adrr.realName()); 2028 nameList.append(adrr.realName());
2029 emailList = adrr.emails(); 2029 emailList = adrr.emails();
2030 uidList.append( adrr.preferredEmail()); 2030 uidList.append( adrr.preferredEmail());
2031 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2031 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2032 return; 2032 return;
2033 } 2033 }
2034 2034
2035 } 2035 }
2036 2036
2037 if ( email == "sendbacklist" ) 2037 if ( email == "sendbacklist" )
2038 return; 2038 return;
2039 if (foundUid.isEmpty()) 2039 if (foundUid.isEmpty())
2040 { 2040 {
2041 //find the uid of the person first 2041 //find the uid of the person first
2042 Addressee::List namelist; 2042 Addressee::List namelist;
2043 Addressee::List emaillist; 2043 Addressee::List emaillist;
2044 2044
2045 if (!name.isEmpty()) 2045 if (!name.isEmpty())
2046 namelist = mAddressBook->findByName( name ); 2046 namelist = mAddressBook->findByName( name );
2047 2047
2048 if (!email.isEmpty()) 2048 if (!email.isEmpty())
2049 emaillist = mAddressBook->findByEmail( email ); 2049 emaillist = mAddressBook->findByEmail( email );
2050 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2050 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2051 //check if we have a match in Namelist and Emaillist 2051 //check if we have a match in Namelist and Emaillist
2052 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2052 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2053 foundUid = emaillist[0].uid(); 2053 foundUid = emaillist[0].uid();
2054 } 2054 }
2055 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2055 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2056 foundUid = namelist[0].uid(); 2056 foundUid = namelist[0].uid();
2057 else 2057 else
2058 { 2058 {
2059 for (int i = 0; i < namelist.count(); i++) 2059 for (int i = 0; i < namelist.count(); i++)
2060 { 2060 {
2061 for (int j = 0; j < emaillist.count(); j++) 2061 for (int j = 0; j < emaillist.count(); j++)
2062 { 2062 {
2063 if (namelist[i] == emaillist[j]) 2063 if (namelist[i] == emaillist[j])
2064 { 2064 {
2065 foundUid = namelist[i].uid(); 2065 foundUid = namelist[i].uid();
2066 } 2066 }
2067 } 2067 }
2068 } 2068 }
2069 } 2069 }
2070 } 2070 }
2071 else 2071 else
2072 { 2072 {
2073 foundUid = uid; 2073 foundUid = uid;
2074 } 2074 }
2075 2075
2076 if (!foundUid.isEmpty()) 2076 if (!foundUid.isEmpty())
2077 { 2077 {
2078 2078
2079 // raise Ka/Pi if it is in the background 2079 // raise Ka/Pi if it is in the background
2080#ifndef DESKTOP_VERSION 2080#ifndef DESKTOP_VERSION
2081#ifndef KORG_NODCOP 2081#ifndef KORG_NODCOP
2082 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2082 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2083#endif 2083#endif
2084#endif 2084#endif
2085 2085
2086 mMainWindow->showMaximized(); 2086 mMainWindow->showMaximized();
2087 mMainWindow-> raise(); 2087 mMainWindow-> raise();
2088 2088
2089 mViewManager->setSelected( "", false); 2089 mViewManager->setSelected( "", false);
2090 mViewManager->refreshView( "" ); 2090 mViewManager->refreshView( "" );
2091 mViewManager->setSelected( foundUid, true ); 2091 mViewManager->setSelected( foundUid, true );
2092 mViewManager->refreshView( foundUid ); 2092 mViewManager->refreshView( foundUid );
2093 2093
2094 if ( !mMultipleViewsAtOnce ) 2094 if ( !mMultipleViewsAtOnce )
2095 { 2095 {
2096 setDetailsVisible( true ); 2096 setDetailsVisible( true );
2097 mActionDetails->setChecked(true); 2097 mActionDetails->setChecked(true);
2098 } 2098 }
2099 } 2099 }
2100} 2100}
2101 2101
2102 2102
2103void KABCore::faq() 2103void KABCore::faq()
2104{ 2104{
2105 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2105 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2106} 2106}
2107 2107
2108 2108
2109void KABCore::fillSyncMenu() 2109void KABCore::fillSyncMenu()
2110{ 2110{
2111 if ( syncMenu->count() ) 2111 if ( syncMenu->count() )
2112 syncMenu->clear(); 2112 syncMenu->clear();
2113 syncMenu->insertItem( i18n("Configure..."), 0 ); 2113 syncMenu->insertItem( i18n("Configure..."), 0 );
2114 syncMenu->insertSeparator(); 2114 syncMenu->insertSeparator();
2115 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 2115 syncMenu->insertItem( i18n("Multiple sync"), 1 );
2116 syncMenu->insertSeparator(); 2116 syncMenu->insertSeparator();
2117 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2117 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2118 config.setGroup("General"); 2118 config.setGroup("General");
2119 QStringList prof = config.readListEntry("SyncProfileNames"); 2119 QStringList prof = config.readListEntry("SyncProfileNames");
2120 KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 2120 KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
2121 if ( prof.count() < 3 ) { 2121 if ( prof.count() < 3 ) {
2122 prof.clear(); 2122 prof.clear();
2123 prof << i18n("Sharp_DTM"); 2123 prof << i18n("Sharp_DTM");
2124 prof << i18n("Local_file"); 2124 prof << i18n("Local_file");
2125 prof << i18n("Last_file"); 2125 prof << i18n("Last_file");
2126 KSyncProfile* temp = new KSyncProfile (); 2126 KSyncProfile* temp = new KSyncProfile ();
2127 temp->setName( prof[0] ); 2127 temp->setName( prof[0] );
2128 temp->writeConfig(&config); 2128 temp->writeConfig(&config);
2129 temp->setName( prof[1] ); 2129 temp->setName( prof[1] );
2130 temp->writeConfig(&config); 2130 temp->writeConfig(&config);
2131 temp->setName( prof[2] ); 2131 temp->setName( prof[2] );
2132 temp->writeConfig(&config); 2132 temp->writeConfig(&config);
2133 config.setGroup("General"); 2133 config.setGroup("General");
2134 config.writeEntry("SyncProfileNames",prof); 2134 config.writeEntry("SyncProfileNames",prof);
2135 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 2135 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
2136 config.sync(); 2136 config.sync();
2137 delete temp; 2137 delete temp;
2138 } 2138 }
2139 KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 2139 KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
2140 KABPrefs::instance()->mSyncProfileNames = prof; 2140 KABPrefs::instance()->mSyncProfileNames = prof;
2141 int i; 2141 int i;
2142 for ( i = 0; i < prof.count(); ++i ) { 2142 for ( i = 0; i < prof.count(); ++i ) {
2143 2143
2144 syncMenu->insertItem( prof[i], 1000+i ); 2144 syncMenu->insertItem( prof[i], 1000+i );
2145 if ( i == 2 ) 2145 if ( i == 2 )
2146 syncMenu->insertSeparator(); 2146 syncMenu->insertSeparator();
2147 } 2147 }
2148 QDir app_dir; 2148 QDir app_dir;
2149 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 2149 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
2150 syncMenu->setItemEnabled( false , 1000 ); 2150 syncMenu->setItemEnabled( false , 1000 );
2151 } 2151 }
2152 //probaly useless 2152 //probaly useless
2153 //mView->setupExternSyncProfiles(); 2153 //mView->setupExternSyncProfiles();
2154} 2154}
2155void KABCore::slotSyncMenu( int action ) 2155void KABCore::slotSyncMenu( int action )
2156{ 2156{
2157 //qDebug("syncaction %d ", action); 2157 //qDebug("syncaction %d ", action);
2158 if ( action == 0 ) { 2158 if ( action == 0 ) {
2159 2159
2160 // seems to be a Qt2 event handling bug 2160 // seems to be a Qt2 event handling bug
2161 // syncmenu.clear causes a segfault at first time 2161 // syncmenu.clear causes a segfault at first time
2162 // when we call it after the main event loop, it is ok 2162 // when we call it after the main event loop, it is ok
2163 // same behaviour when calling OM/Pi via QCOP for the first time 2163 // same behaviour when calling OM/Pi via QCOP for the first time
2164 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 2164 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
2165 //confSync(); 2165 //confSync();
2166 2166
2167 return; 2167 return;
2168 } 2168 }
2169 if ( action == 1 ) { 2169 if ( action == 1 ) {
2170 multiSync( true ); 2170 multiSync( true );
2171 return; 2171 return;
2172 } 2172 }
2173 2173
2174 if (mBlockSaveFlag) 2174 if (mBlockSaveFlag)
2175 return; 2175 return;
2176 mBlockSaveFlag = true; 2176 mBlockSaveFlag = true;
2177 mCurrentSyncProfile = action - 1000 ; 2177 mCurrentSyncProfile = action - 1000 ;
2178 mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; 2178 mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ;
2179 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; 2179 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ;
2180 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2180 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2181 KSyncProfile* temp = new KSyncProfile (); 2181 KSyncProfile* temp = new KSyncProfile ();
2182 temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2182 temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2183 temp->readConfig(&config); 2183 temp->readConfig(&config);
2184 KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2184 KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2185 KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 2185 KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2186 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2186 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2187 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2187 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2188 KABPrefs::instance()->mWriteBackInFuture = 0; 2188 KABPrefs::instance()->mWriteBackInFuture = 0;
2189 if ( temp->getWriteBackFuture() ) 2189 if ( temp->getWriteBackFuture() )
2190 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2190 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2191 KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 2191 KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2192 if ( action == 1000 ) { 2192 if ( action == 1000 ) {
2193 syncSharp(); 2193 syncSharp();
2194 2194
2195 } else if ( action == 1001 ) { 2195 } else if ( action == 1001 ) {
2196 syncLocalFile(); 2196 syncLocalFile();
2197 2197
2198 } else if ( action == 1002 ) { 2198 } else if ( action == 1002 ) {
2199 quickSyncLocalFile(); 2199 quickSyncLocalFile();
2200 2200
2201 } else if ( action >= 1003 ) { 2201 } else if ( action >= 1003 ) {
2202 if ( temp->getIsLocalFileSync() ) { 2202 if ( temp->getIsLocalFileSync() ) {
2203 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 2203 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
2204 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 2204 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
2205 } else { 2205 } else {
2206 if ( temp->getIsPhoneSync() ) { 2206 if ( temp->getIsPhoneSync() ) {
2207 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 2207 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
2208 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 2208 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
2209 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 2209 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
2210 syncPhone(); 2210 syncPhone();
2211 } else 2211 } else
2212 syncRemote( temp ); 2212 syncRemote( temp );
2213 2213
2214 } 2214 }
2215 } 2215 }
2216 delete temp; 2216 delete temp;
2217 mBlockSaveFlag = false; 2217 mBlockSaveFlag = false;
2218} 2218}
2219 2219
2220void KABCore::syncLocalFile() 2220void KABCore::syncLocalFile()
2221{ 2221{
2222 2222
2223 QString fn =KABPrefs::instance()->mLastSyncedLocalFile; 2223 QString fn =KABPrefs::instance()->mLastSyncedLocalFile;
2224 2224
2225 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2225 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2226 if ( fn == "" ) 2226 if ( fn == "" )
2227 return; 2227 return;
2228 if ( syncWithFile( fn, false ) ) { 2228 if ( syncWithFile( fn, false ) ) {
2229 qDebug("syncLocalFile() successful "); 2229 qDebug("syncLocalFile() successful ");
2230 } 2230 }
2231 2231
2232} 2232}
2233bool KABCore::syncWithFile( QString fn , bool quick ) 2233bool KABCore::syncWithFile( QString fn , bool quick )
2234{ 2234{
2235 bool ret = false; 2235 bool ret = false;
2236 QFileInfo info; 2236 QFileInfo info;
2237 info.setFile( fn ); 2237 info.setFile( fn );
2238 QString mess; 2238 QString mess;
2239 bool loadbup = true; 2239 bool loadbup = true;
2240 if ( !info. exists() ) { 2240 if ( !info. exists() ) {
2241 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2241 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2242 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2242 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2243 mess ); 2243 mess );
2244 return ret; 2244 return ret;
2245 } 2245 }
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 ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2529 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
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 2555
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 if ( mode <= SYNC_PREF_ASK ) 2561 if ( mode <= SYNC_PREF_ASK )
2562 return 0; 2562 return 0;
2563 } else { 2563 } else {
2564 if ( locCh ) { 2564 if ( locCh ) {
2565 //qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); 2565 //qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1());
2566 lastSync = local->revision().addDays( -1 ); 2566 lastSync = local->revision().addDays( -1 );
2567 if ( !remCh ) 2567 if ( !remCh )
2568 remote->setRevision( lastSync.addDays( -1 ) ); 2568 remote->setRevision( lastSync.addDays( -1 ) );
2569 } else { 2569 } else {
2570 //qDebug(" not loc changed "); 2570 //qDebug(" not loc changed ");
2571 lastSync = local->revision().addDays( 1 ); 2571 lastSync = local->revision().addDays( 1 );
2572 if ( remCh ) 2572 if ( remCh )
2573 remote->setRevision( lastSync.addDays( 1 ) ); 2573 remote->setRevision( lastSync.addDays( 1 ) );
2574 2574
2575 } 2575 }
2576 } 2576 }
2577 full = true; 2577 full = true;
2578 if ( mode < SYNC_PREF_ASK ) 2578 if ( mode < SYNC_PREF_ASK )
2579 mode = SYNC_PREF_ASK; 2579 mode = SYNC_PREF_ASK;
2580 } else { 2580 } else {
2581 if ( local->revision() == remote->revision() ) 2581 if ( local->revision() == remote->revision() )
2582 return 0; 2582 return 0;
2583 2583
2584 } 2584 }
2585 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2585 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2586 2586
2587 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 2587 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
2588 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2588 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2589 //full = true; //debug only 2589 //full = true; //debug only
2590 if ( full ) { 2590 if ( full ) {
2591 bool equ = ( (*local) == (*remote) ); 2591 bool equ = ( (*local) == (*remote) );
2592 if ( equ ) { 2592 if ( equ ) {
2593 //qDebug("equal "); 2593 //qDebug("equal ");
2594 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2594 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2595 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2595 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2596 } 2596 }
2597 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2597 if ( mode < SYNC_PREF_FORCE_LOCAL )
2598 return 0; 2598 return 0;
2599 2599
2600 }//else //debug only 2600 }//else //debug only
2601 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2601 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2602 } 2602 }
2603 int result; 2603 int result;
2604 bool localIsNew; 2604 bool localIsNew;
2605 //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() ); 2605 //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() );
2606 2606
2607 if ( full && mode < SYNC_PREF_NEWEST ) 2607 if ( full && mode < SYNC_PREF_NEWEST )
2608 mode = SYNC_PREF_ASK; 2608 mode = SYNC_PREF_ASK;
2609 2609
2610 switch( mode ) { 2610 switch( mode ) {
2611 case SYNC_PREF_LOCAL: 2611 case SYNC_PREF_LOCAL:
2612 if ( lastSync > remote->revision() ) 2612 if ( lastSync > remote->revision() )
2613 return 1; 2613 return 1;
2614 if ( lastSync > local->revision() ) 2614 if ( lastSync > local->revision() )
2615 return 2; 2615 return 2;
2616 return 1; 2616 return 1;
2617 break; 2617 break;
2618 case SYNC_PREF_REMOTE: 2618 case SYNC_PREF_REMOTE:
2619 if ( lastSync > remote->revision() ) 2619 if ( lastSync > remote->revision() )
2620 return 1; 2620 return 1;
2621 if ( lastSync > local->revision() ) 2621 if ( lastSync > local->revision() )
2622 return 2; 2622 return 2;
2623 return 2; 2623 return 2;
2624 break; 2624 break;
2625 case SYNC_PREF_NEWEST: 2625 case SYNC_PREF_NEWEST:
2626 if ( local->revision() > remote->revision() ) 2626 if ( local->revision() > remote->revision() )
2627 return 1; 2627 return 1;
2628 else 2628 else
2629 return 2; 2629 return 2;
2630 break; 2630 break;
2631 case SYNC_PREF_ASK: 2631 case SYNC_PREF_ASK:
2632 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); 2632 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() );
2633 if ( lastSync > remote->revision() ) 2633 if ( lastSync > remote->revision() )
2634 return 1; 2634 return 1;
2635 if ( lastSync > local->revision() ) 2635 if ( lastSync > local->revision() )
2636 return 2; 2636 return 2;
2637 localIsNew = local->revision() >= remote->revision(); 2637 localIsNew = local->revision() >= remote->revision();
2638 //qDebug("conflict! ************************************** "); 2638 //qDebug("conflict! ************************************** ");
2639 { 2639 {
2640 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2640 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2641 result = acd.executeD(localIsNew); 2641 result = acd.executeD(localIsNew);
2642 return result; 2642 return result;
2643 } 2643 }
2644 break; 2644 break;
2645 case SYNC_PREF_FORCE_LOCAL: 2645 case SYNC_PREF_FORCE_LOCAL:
2646 return 1; 2646 return 1;
2647 break; 2647 break;
2648 case SYNC_PREF_FORCE_REMOTE: 2648 case SYNC_PREF_FORCE_REMOTE:
2649 return 2; 2649 return 2;
2650 break; 2650 break;
2651 2651
2652 default: 2652 default:
2653 // SYNC_PREF_TAKE_BOTH not implemented 2653 // SYNC_PREF_TAKE_BOTH not implemented
2654 break; 2654 break;
2655 } 2655 }
2656 return 0; 2656 return 0;
2657} 2657}
2658bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2658bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2659{ 2659{
2660 bool syncOK = true; 2660 bool syncOK = true;
2661 int addedAddressee = 0; 2661 int addedAddressee = 0;
2662 int addedAddresseeR = 0; 2662 int addedAddresseeR = 0;
2663 int deletedAddresseeR = 0; 2663 int deletedAddresseeR = 0;
2664 int deletedAddresseeL = 0; 2664 int deletedAddresseeL = 0;
2665 int changedLocal = 0; 2665 int changedLocal = 0;
2666 int changedRemote = 0; 2666 int changedRemote = 0;
2667 //QPtrList<Addressee> el = local->rawAddressees(); 2667 //QPtrList<Addressee> el = local->rawAddressees();
2668 Addressee addresseeR; 2668 Addressee addresseeR;
2669 QString uid; 2669 QString uid;
2670 int take; 2670 int take;
2671 Addressee addresseeL; 2671 Addressee addresseeL;
2672 Addressee addresseeRSync; 2672 Addressee addresseeRSync;
2673 Addressee addresseeLSync; 2673 Addressee addresseeLSync;
2674 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2674 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2675 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2675 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2676 bool fullDateRange = false; 2676 bool fullDateRange = false;
2677 local->resetTempSyncStat(); 2677 local->resetTempSyncStat();
2678 mLastAddressbookSync = QDateTime::currentDateTime(); 2678 mLastAddressbookSync = QDateTime::currentDateTime();
2679 QDateTime modifiedCalendar = mLastAddressbookSync;; 2679 QDateTime modifiedCalendar = mLastAddressbookSync;;
2680 addresseeLSync = getLastSyncAddressee(); 2680 addresseeLSync = getLastSyncAddressee();
2681 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2681 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2682 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2682 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2683 if ( !addresseeR.isEmpty() ) { 2683 if ( !addresseeR.isEmpty() ) {
2684 addresseeRSync = addresseeR; 2684 addresseeRSync = addresseeR;
2685 remote->removeAddressee(addresseeR ); 2685 remote->removeAddressee(addresseeR );
2686 2686
2687 } else { 2687 } else {
2688 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2688 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2689 addresseeRSync = addresseeLSync ; 2689 addresseeRSync = addresseeLSync ;
2690 } else { 2690 } else {
2691 qDebug("FULLDATE 1"); 2691 qDebug("FULLDATE 1");
2692 fullDateRange = true; 2692 fullDateRange = true;
2693 Addressee newAdd; 2693 Addressee newAdd;
2694 addresseeRSync = newAdd; 2694 addresseeRSync = newAdd;
2695 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2695 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2696 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2696 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2697 addresseeRSync.setRevision( mLastAddressbookSync ); 2697 addresseeRSync.setRevision( mLastAddressbookSync );
2698 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2698 addresseeRSync.setCategories( i18n("SyncAddressee") );
2699 } 2699 }
2700 } 2700 }
2701 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2701 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2702 qDebug("FULLDATE 2"); 2702 qDebug("FULLDATE 2");
2703 fullDateRange = true; 2703 fullDateRange = true;
2704 } 2704 }
2705 if ( ! fullDateRange ) { 2705 if ( ! fullDateRange ) {
2706 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2706 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2707 2707
2708 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2708 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2709 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2709 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2710 fullDateRange = true; 2710 fullDateRange = true;
2711 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2711 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2712 } 2712 }
2713 } 2713 }
2714 // fullDateRange = true; // debug only! 2714 // fullDateRange = true; // debug only!
2715 if ( fullDateRange ) 2715 if ( fullDateRange )
2716 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2716 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2717 else 2717 else
2718 mLastAddressbookSync = addresseeLSync.revision(); 2718 mLastAddressbookSync = addresseeLSync.revision();
2719 // for resyncing if own file has changed 2719 // for resyncing if own file has changed
2720 // PENDING fixme later when implemented 2720 // PENDING fixme later when implemented
2721#if 0 2721#if 0
2722 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2722 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2723 mLastAddressbookSync = loadedFileVersion; 2723 mLastAddressbookSync = loadedFileVersion;
2724 qDebug("setting mLastAddressbookSync "); 2724 qDebug("setting mLastAddressbookSync ");
2725 } 2725 }
2726#endif 2726#endif
2727 2727
2728 //qDebug("*************************** "); 2728 //qDebug("*************************** ");
2729 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2729 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2730 QStringList er = remote->uidList(); 2730 QStringList er = remote->uidList();
2731 Addressee inR ;//= er.first(); 2731 Addressee inR ;//= er.first();
2732 Addressee inL; 2732 Addressee inL;
2733 QProgressBar bar( er.count(),0 ); 2733 QProgressBar bar( er.count(),0 );
2734 bar.setCaption (i18n("Syncing - close to abort!") ); 2734 bar.setCaption (i18n("Syncing - close to abort!") );
2735 2735
2736 int w = 300; 2736 int w = 300;
2737 if ( QApplication::desktop()->width() < 320 ) 2737 if ( QApplication::desktop()->width() < 320 )
2738 w = 220; 2738 w = 220;
2739 int h = bar.sizeHint().height() ; 2739 int h = bar.sizeHint().height() ;
2740 int dw = QApplication::desktop()->width(); 2740 int dw = QApplication::desktop()->width();
2741 int dh = QApplication::desktop()->height(); 2741 int dh = QApplication::desktop()->height();
2742 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2742 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2743 bar.show(); 2743 bar.show();
2744 int modulo = (er.count()/10)+1; 2744 int modulo = (er.count()/10)+1;
2745 int incCounter = 0; 2745 int incCounter = 0;
2746 while ( incCounter < er.count()) { 2746 while ( incCounter < er.count()) {
2747 if ( ! bar.isVisible() ) 2747 if ( ! bar.isVisible() )
2748 return false; 2748 return false;
2749 if ( incCounter % modulo == 0 ) 2749 if ( incCounter % modulo == 0 )
2750 bar.setProgress( incCounter ); 2750 bar.setProgress( incCounter );
2751 uid = er[ incCounter ]; 2751 uid = er[ incCounter ];
2752 bool skipIncidence = false; 2752 bool skipIncidence = false;
2753 if ( uid.left(19) == QString("last-syncAddressee-") ) 2753 if ( uid.left(19) == QString("last-syncAddressee-") )
2754 skipIncidence = true; 2754 skipIncidence = true;
2755 QString idS; 2755 QString idS,OidS;
2756 qApp->processEvents(); 2756 qApp->processEvents();
2757 if ( !skipIncidence ) { 2757 if ( !skipIncidence ) {
2758 inL = local->findByUid( uid ); 2758 inL = local->findByUid( uid );
2759 inR = remote->findByUid( uid ); 2759 inR = remote->findByUid( uid );
2760 //inL.setResource( 0 ); 2760 //inL.setResource( 0 );
2761 //inR.setResource( 0 ); 2761 //inR.setResource( 0 );
2762 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2762 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2763 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2763 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2764 //qDebug("take %d %s ", take, inL.summary().latin1()); 2764 //qDebug("take %d %s ", take, inL.summary().latin1());
2765 if ( take == 3 ) 2765 if ( take == 3 )
2766 return false; 2766 return false;
2767 if ( take == 1 ) {// take local 2767 if ( take == 1 ) {// take local
2768 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2768 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2769 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2769 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2770 local->insertAddressee( inL, false ); 2770 local->insertAddressee( inL, false );
2771 idS = inR.externalUID();
2772 OidS = inR.originalExternalUID();
2771 } 2773 }
2772 else 2774 else
2773 idS = inR.IDStr(); 2775 idS = inR.IDStr();
2774 remote->removeAddressee( inR ); 2776 remote->removeAddressee( inR );
2775 inR = inL; 2777 inR = inL;
2776 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2778 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2777 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 2779 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2780 inR.setOriginalExternalUID( OidS );
2781 inR.setExternalUID( idS );
2782 } else {
2778 inR.setIDStr( idS ); 2783 inR.setIDStr( idS );
2784 }
2779 inR.setResource( 0 ); 2785 inR.setResource( 0 );
2780 remote->insertAddressee( inR , false); 2786 remote->insertAddressee( inR , false);
2781 ++changedRemote; 2787 ++changedRemote;
2782 } else { 2788 } else { // take == 2 take remote
2783 idS = inL.IDStr(); 2789 idS = inL.IDStr();
2784 local->removeAddressee( inL ); 2790 local->removeAddressee( inL );
2785 inL = inR; 2791 inL = inR;
2786 inL.setIDStr( idS ); 2792 inL.setIDStr( idS );
2787 inL.setResource( 0 ); 2793 inL.setResource( 0 );
2788 local->insertAddressee( inL , false ); 2794 local->insertAddressee( inL , false );
2789 ++changedLocal; 2795 ++changedLocal;
2790 } 2796 }
2791 } 2797 }
2792 } else { // no conflict 2798 } else { // no conflict
2793 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2799 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2794 QString des = addresseeLSync.note(); 2800 QString des = addresseeLSync.note();
2795 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2801 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2796 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2802 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2797 remote->insertAddressee( inR, false ); 2803 remote->insertAddressee( inR, false );
2798 ++deletedAddresseeR; 2804 ++deletedAddresseeR;
2799 } else { 2805 } else {
2800 inR.setRevision( modifiedCalendar ); 2806 inR.setRevision( modifiedCalendar );
2801 remote->insertAddressee( inR, false ); 2807 remote->insertAddressee( inR, false );
2802 inL = inR; 2808 inL = inR;
2803 inL.setResource( 0 ); 2809 inL.setResource( 0 );
2804 local->insertAddressee( inL , false); 2810 local->insertAddressee( inL , false);
2805 ++addedAddressee; 2811 ++addedAddressee;
2806 } 2812 }
2807 } else { 2813 } else {
2808 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2814 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2809 inR.setRevision( modifiedCalendar ); 2815 inR.setRevision( modifiedCalendar );
2810 remote->insertAddressee( inR, false ); 2816 remote->insertAddressee( inR, false );
2811 inR.setResource( 0 ); 2817 inR.setResource( 0 );
2812 local->insertAddressee( inR, false ); 2818 local->insertAddressee( inR, false );
2813 ++addedAddressee; 2819 ++addedAddressee;
2814 } else { 2820 } else {
2815 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2821 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2816 remote->removeAddressee( inR ); 2822 remote->removeAddressee( inR );
2817 ++deletedAddresseeR; 2823 ++deletedAddresseeR;
2818 } 2824 }
2819 } 2825 }
2820 } 2826 }
2821 } 2827 }
2822 ++incCounter; 2828 ++incCounter;
2823 } 2829 }
2824 er.clear(); 2830 er.clear();
2825 QStringList el = local->uidList(); 2831 QStringList el = local->uidList();
2826 modulo = (el.count()/10)+1; 2832 modulo = (el.count()/10)+1;
2827 bar.setCaption (i18n("Add / remove addressees") ); 2833 bar.setCaption (i18n("Add / remove addressees") );
2828 bar.setTotalSteps ( el.count() ) ; 2834 bar.setTotalSteps ( el.count() ) ;
2829 bar.show(); 2835 bar.show();
2830 incCounter = 0; 2836 incCounter = 0;
2831 while ( incCounter < el.count()) { 2837 while ( incCounter < el.count()) {
2832 qApp->processEvents(); 2838 qApp->processEvents();
2833 if ( ! bar.isVisible() ) 2839 if ( ! bar.isVisible() )
2834 return false; 2840 return false;
2835 if ( incCounter % modulo == 0 ) 2841 if ( incCounter % modulo == 0 )
2836 bar.setProgress( incCounter ); 2842 bar.setProgress( incCounter );
2837 uid = el[ incCounter ]; 2843 uid = el[ incCounter ];
2838 bool skipIncidence = false; 2844 bool skipIncidence = false;
2839 if ( uid.left(19) == QString("last-syncAddressee-") ) 2845 if ( uid.left(19) == QString("last-syncAddressee-") )
2840 skipIncidence = true; 2846 skipIncidence = true;
2841 if ( !skipIncidence ) { 2847 if ( !skipIncidence ) {
2842 inL = local->findByUid( uid ); 2848 inL = local->findByUid( uid );
2843 inR = remote->findByUid( uid ); 2849 inR = remote->findByUid( uid );
2844 if ( inR.isEmpty() ) { 2850 if ( inR.isEmpty() ) {
2845 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2851 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2846 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2852 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2847 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2853 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2848 local->removeAddressee( inL ); 2854 local->removeAddressee( inL );
2849 ++deletedAddresseeL; 2855 ++deletedAddresseeL;
2850 } else { 2856 } else {
2851 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2857 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2852 inL.removeID(mCurrentSyncDevice ); 2858 inL.removeID(mCurrentSyncDevice );
2853 ++addedAddresseeR; 2859 ++addedAddresseeR;
2854 inL.setRevision( modifiedCalendar ); 2860 inL.setRevision( modifiedCalendar );
2855 local->insertAddressee( inL, false ); 2861 local->insertAddressee( inL, false );
2856 inR = inL; 2862 inR = inL;
2857 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2863 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2858 inR.setResource( 0 ); 2864 inR.setResource( 0 );
2859 remote->insertAddressee( inR, false ); 2865 remote->insertAddressee( inR, false );
2860 } 2866 }
2861 } 2867 }
2862 } else { 2868 } else {
2863 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2869 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2864 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2870 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2865 local->removeAddressee( inL ); 2871 local->removeAddressee( inL );
2866 ++deletedAddresseeL; 2872 ++deletedAddresseeL;
2867 } else { 2873 } else {
2868 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2874 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2869 ++addedAddresseeR; 2875 ++addedAddresseeR;
2870 inL.setRevision( modifiedCalendar ); 2876 inL.setRevision( modifiedCalendar );
2871 local->insertAddressee( inL, false ); 2877 local->insertAddressee( inL, false );
2872 inR = inL; 2878 inR = inL;
2873 inR.setResource( 0 ); 2879 inR.setResource( 0 );
2874 remote->insertAddressee( inR, false ); 2880 remote->insertAddressee( inR, false );
2875 } 2881 }
2876 } 2882 }
2877 } 2883 }
2878 } 2884 }
2879 } 2885 }
2880 ++incCounter; 2886 ++incCounter;
2881 } 2887 }
2882 el.clear(); 2888 el.clear();
2883 bar.hide(); 2889 bar.hide();
2884 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2890 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2885 // get rid of micro seconds 2891 // get rid of micro seconds
2886 QTime t = mLastAddressbookSync.time(); 2892 QTime t = mLastAddressbookSync.time();
2887 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2893 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2888 addresseeLSync.setRevision( mLastAddressbookSync ); 2894 addresseeLSync.setRevision( mLastAddressbookSync );
2889 addresseeRSync.setRevision( mLastAddressbookSync ); 2895 addresseeRSync.setRevision( mLastAddressbookSync );
2890 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2896 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2891 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2897 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2892 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2898 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2893 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2899 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2894 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2900 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2895 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2901 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2896 addresseeRSync.setNote( "" ) ; 2902 addresseeRSync.setNote( "" ) ;
2897 addresseeLSync.setNote( "" ); 2903 addresseeLSync.setNote( "" );
2898 2904
2899 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2905 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2900 remote->insertAddressee( addresseeRSync, false ); 2906 remote->insertAddressee( addresseeRSync, false );
2901 local->insertAddressee( addresseeLSync, false ); 2907 local->insertAddressee( addresseeLSync, false );
2902 QString mes; 2908 QString mes;
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 ); 2909 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 );
2904 if ( KABPrefs::instance()->mShowSyncSummary ) { 2910 if ( KABPrefs::instance()->mShowSyncSummary ) {
2905 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2911 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2906 } 2912 }
2907 qDebug( mes ); 2913 qDebug( mes );
2908 return syncOK; 2914 return syncOK;
2909} 2915}
2910 2916
2911bool KABCore::syncAB(QString filename, int mode) 2917bool KABCore::syncAB(QString filename, int mode)
2912{ 2918{
2913 2919
2914 //pending prepare addresseeview for output 2920 //pending prepare addresseeview for output
2915 //pending detect, if remote file has REV field. if not switch to external sync 2921 //pending detect, if remote file has REV field. if not switch to external sync
2916 mGlobalSyncMode = SYNC_MODE_NORMAL; 2922 mGlobalSyncMode = SYNC_MODE_NORMAL;
2917 AddressBook abLocal(filename,"syncContact"); 2923 AddressBook abLocal(filename,"syncContact");
2918 bool syncOK = false; 2924 bool syncOK = false;
2919 if ( abLocal.load() ) { 2925 if ( abLocal.load() ) {
2920 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2926 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2921 bool external = false; 2927 bool external = false;
2922 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2923 if ( ! lse.isEmpty() ) {
2924 if ( lse.familyName().left(4) == "!E: " )
2925 external = true;
2926 } else {
2927 bool found = false;
2928 QDateTime dt( QDate( 2004,1,1));
2929 AddressBook::Iterator it;
2930 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2931 if ( (*it).revision() != dt ) {
2932 found = true;
2933 break;
2934 }
2935 }
2936 external = ! found;
2937 }
2938 2928
2939 if ( external ) { 2929 if ( filename.right(4) == ".xml") {
2940 qDebug("Setting vcf mode to external ");
2941 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2930 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2942 AddressBook::Iterator it; 2931 AddressBook::Iterator it;
2943 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2932 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2944 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2933 (*it).setID( mCurrentSyncDevice, (*it).externalUID() );
2945 (*it).computeCsum( mCurrentSyncDevice ); 2934 (*it).computeCsum( mCurrentSyncDevice );
2946 } 2935 }
2936 abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice );
2937
2938 } else {
2939 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2940 if ( ! lse.isEmpty() ) {
2941 if ( lse.familyName().left(4) == "!E: " )
2942 external = true;
2943 } else {
2944 bool found = false;
2945 QDateTime dt( QDate( 2004,1,1));
2946 AddressBook::Iterator it;
2947 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2948 if ( (*it).revision() != dt ) {
2949 found = true;
2950 break;
2951 }
2952 }
2953 external = ! found;
2954 }
2955
2956 if ( external ) {
2957 qDebug("Setting vcf mode to external ");
2958 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2959 AddressBook::Iterator it;
2960 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2961 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2962 (*it).computeCsum( mCurrentSyncDevice );
2963 }
2964 }
2947 } 2965 }
2948 //AddressBook::Iterator it; 2966 //AddressBook::Iterator it;
2949 //QStringList vcards; 2967 //QStringList vcards;
2950 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2968 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2951 // qDebug("Name %s ", (*it).familyName().latin1()); 2969 // qDebug("Name %s ", (*it).familyName().latin1());
2952 //} 2970 //}
2953 if ( filename.right(4) == ".xml")
2954 abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice );
2955 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2971 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2956 if ( syncOK ) { 2972 if ( syncOK ) {
2957 if ( KABPrefs::instance()->mWriteBackFile ) 2973 if ( KABPrefs::instance()->mWriteBackFile )
2958 { 2974 {
2959 if ( external ) 2975 if ( external && filename.right(4) != ".xml")
2960 abLocal.removeDeletedAddressees(); 2976 abLocal.removeDeletedAddressees();
2961 qDebug("Saving remote AB "); 2977 qDebug("Saving remote AB ");
2962 abLocal.saveAB(); 2978 abLocal.saveAB();
2979 if ( external && filename.right(4) == ".xml") {
2980 // afterwrite processing
2981 AddressBook::Iterator it;
2982 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2983 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
2984 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
2985 Addressee ad = mAddressBook->findByUid( ( (*it).uid() ));
2986 if ( ad.isEmpty() ) {
2987 qDebug("ERROR ad empty ");
2988 } else {
2989 (*it).computeCsum( mCurrentSyncDevice );
2990 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
2991 ad.setID( mCurrentSyncDevice, (*it).externalUID() );
2992 ad.setCsum( mCurrentSyncDevice, (*it).getCsum( mCurrentSyncDevice ) );
2993 mAddressBook->insertAddressee( ad );
2994 }
2995 }
2996 }
2997 }
2963 } 2998 }
2964 } 2999 }
2965 setModified(); 3000 setModified();
2966 3001
2967 } 3002 }
2968 if ( syncOK ) 3003 if ( syncOK )
2969 mViewManager->refreshView(); 3004 mViewManager->refreshView();
2970 return syncOK; 3005 return syncOK;
2971#if 0 3006#if 0
2972 3007
2973 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 3008 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2974 getEventViewerDialog()->setSyncMode( true ); 3009 getEventViewerDialog()->setSyncMode( true );
2975 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 3010 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2976 getEventViewerDialog()->setSyncMode( false ); 3011 getEventViewerDialog()->setSyncMode( false );
2977 if ( syncOK ) { 3012 if ( syncOK ) {
2978 if ( KOPrefs::instance()->mWriteBackFile ) 3013 if ( KOPrefs::instance()->mWriteBackFile )
2979 { 3014 {
2980 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3015 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2981 storage->save(); 3016 storage->save();
2982 } 3017 }
2983 } 3018 }
2984 setModified(); 3019 setModified();
2985 } 3020 }
2986 3021
2987#endif 3022#endif
2988} 3023}
2989 3024
2990void KABCore::confSync() 3025void KABCore::confSync()
2991{ 3026{
2992 static KSyncPrefsDialog* sp = 0; 3027 static KSyncPrefsDialog* sp = 0;
2993 if ( ! sp ) { 3028 if ( ! sp ) {
2994 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 3029 sp = new KSyncPrefsDialog( this, "syncprefs", true );
2995 } 3030 }
2996 sp->usrReadConfig(); 3031 sp->usrReadConfig();
2997#ifndef DESKTOP_VERSION 3032#ifndef DESKTOP_VERSION
2998 sp->showMaximized(); 3033 sp->showMaximized();
2999#else 3034#else
3000 sp->show(); 3035 sp->show();
3001#endif 3036#endif
3002 sp->exec(); 3037 sp->exec();
3003 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 3038 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
3004 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 3039 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
3005 fillSyncMenu(); 3040 fillSyncMenu();
3006} 3041}
3007void KABCore::syncSharp() 3042void KABCore::syncSharp()
3008{ 3043{
3009 if ( mModified ) 3044 if ( mModified )
3010 save(); 3045 save();
3011 qDebug("pending syncSharp() "); 3046 qDebug("pending syncSharp() ");
3012 //mView->syncSharp(); 3047 //mView->syncSharp();
3013 setModified(); 3048 setModified();
3014 3049
3015} 3050}
3016void KABCore::syncPhone() 3051void KABCore::syncPhone()
3017{ 3052{
3018 if ( mModified ) 3053 if ( mModified )
3019 save(); 3054 save();
3020 qDebug("pending syncPhone(); "); 3055 qDebug("pending syncPhone(); ");
3021 //mView->syncPhone(); 3056 //mView->syncPhone();
3022 setModified(); 3057 setModified();
3023 3058
3024} 3059}
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index e7fc670..d56eab6 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -1,1035 +1,1035 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@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 <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qclipboard.h> 28#include <qclipboard.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qxml.h> 32#include <qxml.h>
33#include <qlabel.h> 33#include <qlabel.h>
34 34
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kglobal.h> 37#include <kglobal.h>
38 38
39#include "calendar.h" 39#include "calendar.h"
40#include "alarm.h" 40#include "alarm.h"
41#include "recurrence.h" 41#include "recurrence.h"
42#include "calendarlocal.h" 42#include "calendarlocal.h"
43 43
44#include "sharpformat.h" 44#include "sharpformat.h"
45#include "syncdefines.h" 45#include "syncdefines.h"
46 46
47using namespace KCal; 47using namespace KCal;
48 48
49//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY 49//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
50// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 50// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
51 51
52//ARSD silentalarm = 0 52//ARSD silentalarm = 0
53// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly 53// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
54// 12 RFRQ 54// 12 RFRQ
55// 13 RPOS pos = 4. monday in month 55// 13 RPOS pos = 4. monday in month
56// 14 RDYS days: 1 mon/ 2 tue .. 64 sun 56// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
57// 15 REND 0 = no end/ 1 = end 57// 15 REND 0 = no end/ 1 = end
58// 16 REDT rec end dt 58// 16 REDT rec end dt
59//ALSD 59//ALSD
60//ALED 60//ALED
61//MDAY 61//MDAY
62 62
63class SharpParser : public QObject 63class SharpParser : public QObject
64{ 64{
65 public: 65 public:
66 SharpParser( Calendar *calendar ) : mCalendar( calendar ) { 66 SharpParser( Calendar *calendar ) : mCalendar( calendar ) {
67 oldCategories = 0; 67 oldCategories = 0;
68 } 68 }
69 69
70 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) 70 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName )
71 { 71 {
72 int i = 1; 72 int i = 1;
73 bool skip = true; 73 bool skip = true;
74 int max = attList.count() -2; 74 int max = attList.count() -2;
75 while ( i < max ) { 75 while ( i < max ) {
76 if ( !attList[i].isEmpty() ) { 76 if ( !attList[i].isEmpty() ) {
77 skip = false; 77 skip = false;
78 break; 78 break;
79 } 79 }
80 ++i ; 80 ++i ;
81 } 81 }
82 if ( skip ) 82 if ( skip )
83 return false; 83 return false;
84 ulong cSum = SharpFormat::getCsum(attList ); 84 ulong cSum = SharpFormat::getCsum(attList );
85 85
86 if ( qName == "Event" ) { 86 if ( qName == "Event" ) {
87 Event *event; 87 Event *event;
88 event = existingCalendar->event( "Sharp_DTM",attList[0] ); 88 event = existingCalendar->event( "Sharp_DTM",attList[0] );
89 if ( event ) 89 if ( event )
90 event = (Event*)event->clone(); 90 event = (Event*)event->clone();
91 else 91 else
92 event = new Event; 92 event = new Event;
93 event->setID("Sharp_DTM", attList[0] ); 93 event->setID("Sharp_DTM", attList[0] );
94 event->setCsum( "Sharp_DTM", QString::number( cSum )); 94 event->setCsum( "Sharp_DTM", QString::number( cSum ));
95 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 95 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
96 96
97 event->setSummary( attList[2] ); 97 event->setSummary( attList[2] );
98 event->setLocation( attList[3] ); 98 event->setLocation( attList[3] );
99 event->setDescription( attList[4] ); 99 event->setDescription( attList[4] );
100 if ( attList[7] == "1" ) { 100 if ( attList[7] == "1" ) {
101 event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); 101 event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) ));
102 event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); 102 event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 )));
103 event->setFloats( true ); 103 event->setFloats( true );
104 } else { 104 } else {
105 event->setFloats( false ); 105 event->setFloats( false );
106 event->setDtStart( fromString( attList[5] ) ); 106 event->setDtStart( fromString( attList[5] ) );
107 event->setDtEnd( fromString( attList[6] )); 107 event->setDtEnd( fromString( attList[6] ));
108 } 108 }
109 109
110 QString rtype = attList[11]; 110 QString rtype = attList[11];
111 if ( rtype != "255" ) { 111 if ( rtype != "255" ) {
112 // qDebug("recurs "); 112 // qDebug("recurs ");
113 QDate startDate = event->dtStart().date(); 113 QDate startDate = event->dtStart().date();
114 114
115 QString freqStr = attList[12]; 115 QString freqStr = attList[12];
116 int freq = freqStr.toInt(); 116 int freq = freqStr.toInt();
117 117
118 QString hasEndDateStr = attList[15] ; 118 QString hasEndDateStr = attList[15] ;
119 bool hasEndDate = hasEndDateStr == "1"; 119 bool hasEndDate = hasEndDateStr == "1";
120 120
121 QString endDateStr = attList[16]; 121 QString endDateStr = attList[16];
122 QDate endDate = fromString( endDateStr ).date(); 122 QDate endDate = fromString( endDateStr ).date();
123 123
124 QString weekDaysStr = attList[14]; 124 QString weekDaysStr = attList[14];
125 uint weekDaysNum = weekDaysStr.toInt(); 125 uint weekDaysNum = weekDaysStr.toInt();
126 126
127 QBitArray weekDays( 7 ); 127 QBitArray weekDays( 7 );
128 int i; 128 int i;
129 int bb = 1; 129 int bb = 1;
130 for( i = 1; i <= 7; ++i ) { 130 for( i = 1; i <= 7; ++i ) {
131 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 131 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
132 bb = 2 << (i-1); 132 bb = 2 << (i-1);
133 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 133 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
134 } 134 }
135 // qDebug("next "); 135 // qDebug("next ");
136 QString posStr = attList[13]; 136 QString posStr = attList[13];
137 int pos = posStr.toInt(); 137 int pos = posStr.toInt();
138 Recurrence *r = event->recurrence(); 138 Recurrence *r = event->recurrence();
139 139
140 if ( rtype == "0" ) { 140 if ( rtype == "0" ) {
141 if ( hasEndDate ) r->setDaily( freq, endDate ); 141 if ( hasEndDate ) r->setDaily( freq, endDate );
142 else r->setDaily( freq, -1 ); 142 else r->setDaily( freq, -1 );
143 } else if ( rtype == "1" ) { 143 } else if ( rtype == "1" ) {
144 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 144 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
145 else r->setWeekly( freq, weekDays, -1 ); 145 else r->setWeekly( freq, weekDays, -1 );
146 } else if ( rtype == "3" ) { 146 } else if ( rtype == "3" ) {
147 if ( hasEndDate ) 147 if ( hasEndDate )
148 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 148 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
149 else 149 else
150 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); 150 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
151 r->addMonthlyDay( startDate.day() ); 151 r->addMonthlyDay( startDate.day() );
152 } else if ( rtype == "2" ) { 152 } else if ( rtype == "2" ) {
153 if ( hasEndDate ) 153 if ( hasEndDate )
154 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 154 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
155 else 155 else
156 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); 156 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
157 QBitArray days( 7 ); 157 QBitArray days( 7 );
158 days.fill( false ); 158 days.fill( false );
159 days.setBit( startDate.dayOfWeek() - 1 ); 159 days.setBit( startDate.dayOfWeek() - 1 );
160 r->addMonthlyPos( pos, days ); 160 r->addMonthlyPos( pos, days );
161 } else if ( rtype == "4" ) { 161 } else if ( rtype == "4" ) {
162 if ( hasEndDate ) 162 if ( hasEndDate )
163 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 163 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
164 else 164 else
165 r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); 165 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
166 r->addYearlyNum( startDate.month() ); 166 r->addYearlyNum( startDate.month() );
167 } 167 }
168 } else { 168 } else {
169 event->recurrence()->unsetRecurs(); 169 event->recurrence()->unsetRecurs();
170 } 170 }
171 171
172 QString categoryList = attList[1] ; 172 QString categoryList = attList[1] ;
173 event->setCategories( lookupCategories( categoryList ) ); 173 event->setCategories( lookupCategories( categoryList ) );
174 174
175 // strange 0 semms to mean: alarm enabled 175 // strange 0 semms to mean: alarm enabled
176 if ( attList[8] == "0" ) { 176 if ( attList[8] == "0" ) {
177 Alarm *alarm; 177 Alarm *alarm;
178 if ( event->alarms().count() > 0 ) 178 if ( event->alarms().count() > 0 )
179 alarm = event->alarms().first(); 179 alarm = event->alarms().first();
180 else { 180 else {
181 alarm = new Alarm( event ); 181 alarm = new Alarm( event );
182 event->addAlarm( alarm ); 182 event->addAlarm( alarm );
183 alarm->setType( Alarm::Audio ); 183 alarm->setType( Alarm::Audio );
184 } 184 }
185 //alarm->setType( Alarm::Audio ); 185 //alarm->setType( Alarm::Audio );
186 alarm->setEnabled( true ); 186 alarm->setEnabled( true );
187 int alarmOffset = attList[9].toInt(); 187 int alarmOffset = attList[9].toInt();
188 alarm->setStartOffset( alarmOffset * -60 ); 188 alarm->setStartOffset( alarmOffset * -60 );
189 } else { 189 } else {
190 Alarm *alarm; 190 Alarm *alarm;
191 if ( event->alarms().count() > 0 ) { 191 if ( event->alarms().count() > 0 ) {
192 alarm = event->alarms().first(); 192 alarm = event->alarms().first();
193 alarm->setType( Alarm::Audio ); 193 alarm->setType( Alarm::Audio );
194 alarm->setStartOffset( -60*15 ); 194 alarm->setStartOffset( -60*15 );
195 alarm->setEnabled( false ); 195 alarm->setEnabled( false );
196 } 196 }
197 } 197 }
198 198
199 mCalendar->addEvent( event); 199 mCalendar->addEvent( event);
200 } else if ( qName == "Todo" ) { 200 } else if ( qName == "Todo" ) {
201 Todo *todo; 201 Todo *todo;
202 202
203 todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); 203 todo = existingCalendar->todo( "Sharp_DTM", attList[0] );
204 if (todo ) 204 if (todo )
205 todo = (Todo*)todo->clone(); 205 todo = (Todo*)todo->clone();
206 else 206 else
207 todo = new Todo; 207 todo = new Todo;
208 208
209//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 209//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1
210// 0 1 2 3 4 5 6 7 8 210// 0 1 2 3 4 5 6 7 8
211//1,,,,,1,4,Loch zumachen,"" 211//1,,,,,1,4,Loch zumachen,""
212//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " 212//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" "
213//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes 213//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes
214 214
215 todo->setID( "Sharp_DTM", attList[0]); 215 todo->setID( "Sharp_DTM", attList[0]);
216 todo->setCsum( "Sharp_DTM", QString::number( cSum )); 216 todo->setCsum( "Sharp_DTM", QString::number( cSum ));
217 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 217 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
218 218
219 todo->setSummary( attList[7] ); 219 todo->setSummary( attList[7] );
220 todo->setDescription( attList[8]); 220 todo->setDescription( attList[8]);
221 221
222 int priority = attList[6].toInt(); 222 int priority = attList[6].toInt();
223 if ( priority == 0 ) priority = 3; 223 if ( priority == 0 ) priority = 3;
224 todo->setPriority( priority ); 224 todo->setPriority( priority );
225 225
226 QString categoryList = attList[1]; 226 QString categoryList = attList[1];
227 todo->setCategories( lookupCategories( categoryList ) ); 227 todo->setCategories( lookupCategories( categoryList ) );
228 228
229 229
230 230
231 QString hasDateStr = attList[3]; // due 231 QString hasDateStr = attList[3]; // due
232 if ( !hasDateStr.isEmpty() ) { 232 if ( !hasDateStr.isEmpty() ) {
233 if ( hasDateStr.right(6) == "000000" ) { 233 if ( hasDateStr.right(6) == "000000" ) {
234 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); 234 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) );
235 todo->setFloats( true ); 235 todo->setFloats( true );
236 } 236 }
237 else { 237 else {
238 todo->setDtDue( fromString( hasDateStr ) ); 238 todo->setDtDue( fromString( hasDateStr ) );
239 todo->setFloats( false ); 239 todo->setFloats( false );
240 } 240 }
241 241
242 todo->setHasDueDate( true ); 242 todo->setHasDueDate( true );
243 } 243 }
244 hasDateStr = attList[2];//start 244 hasDateStr = attList[2];//start
245 if ( !hasDateStr.isEmpty() ) { 245 if ( !hasDateStr.isEmpty() ) {
246 246
247 todo->setDtStart( fromString( hasDateStr ) ); 247 todo->setDtStart( fromString( hasDateStr ) );
248 todo->setHasStartDate( true); 248 todo->setHasStartDate( true);
249 } else 249 } else
250 todo->setHasStartDate( false ); 250 todo->setHasStartDate( false );
251 hasDateStr = attList[4];//completed 251 hasDateStr = attList[4];//completed
252 if ( !hasDateStr.isEmpty() ) { 252 if ( !hasDateStr.isEmpty() ) {
253 todo->setCompleted(fromString( hasDateStr ) ); 253 todo->setCompleted(fromString( hasDateStr ) );
254 } 254 }
255 QString completedStr = attList[5]; 255 QString completedStr = attList[5];
256 if ( completedStr == "0" ) 256 if ( completedStr == "0" )
257 todo->setCompleted( true ); 257 todo->setCompleted( true );
258 else 258 else
259 todo->setCompleted( false ); 259 todo->setCompleted( false );
260 mCalendar->addTodo( todo ); 260 mCalendar->addTodo( todo );
261 261
262 } else if ( qName == "Category" ) { 262 } else if ( qName == "Category" ) {
263 /* 263 /*
264 QString id = attributes.value( "id" ); 264 QString id = attributes.value( "id" );
265 QString name = attributes.value( "name" ); 265 QString name = attributes.value( "name" );
266 setCategory( id, name ); 266 setCategory( id, name );
267 */ 267 */
268 } 268 }
269 //qDebug("end "); 269 //qDebug("end ");
270 return true; 270 return true;
271 } 271 }
272 272
273 273
274 void setCategoriesList ( QStringList * c ) 274 void setCategoriesList ( QStringList * c )
275 { 275 {
276 oldCategories = c; 276 oldCategories = c;
277 } 277 }
278 278
279 QDateTime fromString ( QString s, bool useTz = true ) { 279 QDateTime fromString ( QString s, bool useTz = true ) {
280 QDateTime dt; 280 QDateTime dt;
281 int y,m,t,h,min,sec; 281 int y,m,t,h,min,sec;
282 y = s.mid(0,4).toInt(); 282 y = s.mid(0,4).toInt();
283 m = s.mid(4,2).toInt(); 283 m = s.mid(4,2).toInt();
284 t = s.mid(6,2).toInt(); 284 t = s.mid(6,2).toInt();
285 h = s.mid(9,2).toInt(); 285 h = s.mid(9,2).toInt();
286 min = s.mid(11,2).toInt(); 286 min = s.mid(11,2).toInt();
287 sec = s.mid(13,2).toInt(); 287 sec = s.mid(13,2).toInt();
288 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); 288 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
289 int offset = KGlobal::locale()->localTimeOffset( dt ); 289 int offset = KGlobal::locale()->localTimeOffset( dt );
290 if ( useTz ) 290 if ( useTz )
291 dt = dt.addSecs ( offset*60); 291 dt = dt.addSecs ( offset*60);
292 return dt; 292 return dt;
293 293
294 } 294 }
295 protected: 295 protected:
296 QDateTime toDateTime( const QString &value ) 296 QDateTime toDateTime( const QString &value )
297 { 297 {
298 QDateTime dt; 298 QDateTime dt;
299 dt.setTime_t( value.toUInt() ); 299 dt.setTime_t( value.toUInt() );
300 300
301 return dt; 301 return dt;
302 } 302 }
303 303
304 QStringList lookupCategories( const QString &categoryList ) 304 QStringList lookupCategories( const QString &categoryList )
305 { 305 {
306 QStringList categoryIds = QStringList::split( ";", categoryList ); 306 QStringList categoryIds = QStringList::split( ";", categoryList );
307 QStringList categories; 307 QStringList categories;
308 QStringList::ConstIterator it; 308 QStringList::ConstIterator it;
309 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { 309 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) {
310 QString cate = category( *it ); 310 QString cate = category( *it );
311 if ( oldCategories ) { 311 if ( oldCategories ) {
312 if ( ! oldCategories->contains( cate ) ) 312 if ( ! oldCategories->contains( cate ) )
313 oldCategories->append( cate ); 313 oldCategories->append( cate );
314 } 314 }
315 categories.append(cate ); 315 categories.append(cate );
316 } 316 }
317 return categories; 317 return categories;
318 } 318 }
319 319
320 private: 320 private:
321 Calendar *mCalendar; 321 Calendar *mCalendar;
322 QStringList * oldCategories; 322 QStringList * oldCategories;
323 static QString category( const QString &id ) 323 static QString category( const QString &id )
324 { 324 {
325 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); 325 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id );
326 if ( it == mCategoriesMap.end() ) return id; 326 if ( it == mCategoriesMap.end() ) return id;
327 else return *it; 327 else return *it;
328 } 328 }
329 329
330 static void setCategory( const QString &id, const QString &name ) 330 static void setCategory( const QString &id, const QString &name )
331 { 331 {
332 mCategoriesMap.insert( id, name ); 332 mCategoriesMap.insert( id, name );
333 } 333 }
334 334
335 static QMap<QString,QString> mCategoriesMap; 335 static QMap<QString,QString> mCategoriesMap;
336}; 336};
337 337
338QMap<QString,QString> SharpParser::mCategoriesMap; 338QMap<QString,QString> SharpParser::mCategoriesMap;
339 339
340SharpFormat::SharpFormat() 340SharpFormat::SharpFormat()
341{ 341{
342 mCategories = 0; 342 mCategories = 0;
343} 343}
344 344
345SharpFormat::~SharpFormat() 345SharpFormat::~SharpFormat()
346{ 346{
347} 347}
348ulong SharpFormat::getCsum( const QStringList & attList) 348ulong SharpFormat::getCsum( const QStringList & attList)
349{ 349{
350 int max = attList.count() -1; 350 int max = attList.count() -1;
351 ulong cSum = 0; 351 ulong cSum = 0;
352 int j,k,i; 352 int j,k,i;
353 int add; 353 int add;
354 for ( i = 1; i < max ; ++i ) { 354 for ( i = 1; i < max ; ++i ) {
355 QString s = attList[i]; 355 QString s = attList[i];
356 if ( ! s.isEmpty() ){ 356 if ( ! s.isEmpty() ){
357 j = s.length(); 357 j = s.length();
358 for ( k = 0; k < j; ++k ) { 358 for ( k = 0; k < j; ++k ) {
359 int mul = k +1; 359 int mul = k +1;
360 add = s[k].unicode (); 360 add = s[k].unicode ();
361 if ( k < 16 ) 361 if ( k < 16 )
362 mul = mul * mul; 362 mul = mul * mul;
363 add = add * mul *i*i*i; 363 add = add * mul *i*i*i;
364 cSum += add; 364 cSum += add;
365 } 365 }
366 } 366 }
367 } 367 }
368 return cSum; 368 return cSum;
369 369
370} 370}
371#include <stdlib.h> 371#include <stdlib.h>
372#define DEBUGMODE false 372#define DEBUGMODE false
373//#define DEBUGMODE true 373//#define DEBUGMODE true
374bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) 374bool SharpFormat::load( Calendar *calendar, Calendar *existngCal )
375{ 375{
376 376
377 377
378 bool debug = DEBUGMODE; 378 bool debug = DEBUGMODE;
379 QString text; 379 QString text;
380 QString codec = "utf8"; 380 QString codec = "utf8";
381 QLabel status ( i18n("Reading events ..."), 0 ); 381 QLabel status ( i18n("Reading events ..."), 0 );
382 382
383 int w = status.sizeHint().width()+20 ; 383 int w = status.sizeHint().width()+20 ;
384 if ( w < 200 ) w = 200; 384 if ( w < 200 ) w = 200;
385 int h = status.sizeHint().height()+20 ; 385 int h = status.sizeHint().height()+20 ;
386 int dw = QApplication::desktop()->width(); 386 int dw = QApplication::desktop()->width();
387 int dh = QApplication::desktop()->height(); 387 int dh = QApplication::desktop()->height();
388 status.setCaption(i18n("Reading DTM Data") ); 388 status.setCaption(i18n("Reading DTM Data") );
389 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 389 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
390 status.show(); 390 status.show();
391 status.raise(); 391 status.raise();
392 qApp->processEvents(); 392 qApp->processEvents();
393 QString fileName; 393 QString fileName;
394 if ( ! debug ) { 394 if ( ! debug ) {
395 fileName = "/tmp/kopitempout"; 395 fileName = "/tmp/kopitempout";
396 QString command ="db2file datebook -r -c "+ codec + " > " + fileName; 396 QString command ="db2file datebook -r -c "+ codec + " > " + fileName;
397 system ( command.latin1() ); 397 system ( command.latin1() );
398 } else { 398 } else {
399 fileName = "/tmp/events.txt"; 399 fileName = "/tmp/events.txt";
400 400
401 } 401 }
402 QFile file( fileName ); 402 QFile file( fileName );
403 if (!file.open( IO_ReadOnly ) ) { 403 if (!file.open( IO_ReadOnly ) ) {
404 return false; 404 return false;
405 405
406 } 406 }
407 QTextStream ts( &file ); 407 QTextStream ts( &file );
408 ts.setCodec( QTextCodec::codecForName("utf8") ); 408 ts.setCodec( QTextCodec::codecForName("utf8") );
409 text = ts.read(); 409 text = ts.read();
410 file.close(); 410 file.close();
411 status.setText( i18n("Processing events ...") ); 411 status.setText( i18n("Processing events ...") );
412 status.raise(); 412 status.raise();
413 qApp->processEvents(); 413 qApp->processEvents();
414 fromString2Cal( calendar, existngCal, text, "Event" ); 414 fromString2Cal( calendar, existngCal, text, "Event" );
415 status.setText( i18n("Reading todos ...") ); 415 status.setText( i18n("Reading todos ...") );
416 qApp->processEvents(); 416 qApp->processEvents();
417 if ( ! debug ) { 417 if ( ! debug ) {
418 fileName = "/tmp/kopitempout"; 418 fileName = "/tmp/kopitempout";
419 QString command = "db2file todo -r -c " + codec+ " > " + fileName; 419 QString command = "db2file todo -r -c " + codec+ " > " + fileName;
420 system ( command.latin1() ); 420 system ( command.latin1() );
421 } else { 421 } else {
422 fileName = "/tmp/todo.txt"; 422 fileName = "/tmp/todo.txt";
423 } 423 }
424 file.setName( fileName ); 424 file.setName( fileName );
425 if (!file.open( IO_ReadOnly ) ) { 425 if (!file.open( IO_ReadOnly ) ) {
426 return false; 426 return false;
427 427
428 } 428 }
429 ts.setDevice( &file ); 429 ts.setDevice( &file );
430 text = ts.read(); 430 text = ts.read();
431 file.close(); 431 file.close();
432 432
433 status.setText( i18n("Processing todos ...") ); 433 status.setText( i18n("Processing todos ...") );
434 status.raise(); 434 status.raise();
435 qApp->processEvents(); 435 qApp->processEvents();
436 fromString2Cal( calendar, existngCal, text, "Todo" ); 436 fromString2Cal( calendar, existngCal, text, "Todo" );
437 return true; 437 return true;
438} 438}
439int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) 439int SharpFormat::getNumFromRecord( QString answer, Incidence* inc )
440{ 440{
441 int retval = -1; 441 int retval = -1;
442 QStringList templist; 442 QStringList templist;
443 QString tempString; 443 QString tempString;
444 int start = 0; 444 int start = 0;
445 int len = answer.length(); 445 int len = answer.length();
446 int end = answer.find ("\n",start)+1; 446 int end = answer.find ("\n",start)+1;
447 bool ok = true; 447 bool ok = true;
448 start = end; 448 start = end;
449 int ccc = 0; 449 int ccc = 0;
450 while ( start > 0 ) { 450 while ( start > 0 ) {
451 templist.clear(); 451 templist.clear();
452 ok = true; 452 ok = true;
453 int loopCount = 0; 453 int loopCount = 0;
454 while ( ok ) { 454 while ( ok ) {
455 ++loopCount; 455 ++loopCount;
456 if ( loopCount > 25 ) { 456 if ( loopCount > 25 ) {
457 qDebug("KO: Error in while loop"); 457 qDebug("KO: Error in while loop");
458 ok = false; 458 ok = false;
459 start = 0; 459 start = 0;
460 break; 460 break;
461 } 461 }
462 if ( ok ) 462 if ( ok )
463 tempString = getPart( answer, ok, start ); 463 tempString = getPart( answer, ok, start );
464 if ( start >= len || start == 0 ) { 464 if ( start >= len || start == 0 ) {
465 start = 0; 465 start = 0;
466 ok = false; 466 ok = false;
467 } 467 }
468 if ( tempString.right(1) =="\n" ) 468 if ( tempString.right(1) =="\n" )
469 tempString = tempString.left( tempString.length()-1); 469 tempString = tempString.left( tempString.length()-1);
470 470
471 templist.append( tempString ); 471 templist.append( tempString );
472 } 472 }
473 ++ccc; 473 ++ccc;
474 if ( ccc == 2 && loopCount < 25 ) { 474 if ( ccc == 2 && loopCount < 25 ) {
475 start = 0; 475 start = 0;
476 bool ok; 476 bool ok;
477 int newnum = templist[0].toInt( &ok ); 477 int newnum = templist[0].toInt( &ok );
478 if ( ok && newnum > 0) { 478 if ( ok && newnum > 0) {
479 retval = newnum; 479 retval = newnum;
480 inc->setID( "Sharp_DTM",templist[0] ); 480 inc->setID( "Sharp_DTM",templist[0] );
481 inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) )); 481 inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) ));
482 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 482 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
483 } 483 }
484 if ( ok && newnum == -1 ) { 484 if ( ok && newnum == -1 ) {
485 qDebug("Error writing back %s ", inc->summary().latin1()); 485 qDebug("Error writing back %s ", inc->summary().latin1());
486 } 486 }
487 } 487 }
488 } 488 }
489 //qDebug("getNumFromRecord returning : %d ", retval); 489 //qDebug("getNumFromRecord returning : %d ", retval);
490 return retval; 490 return retval;
491} 491}
492bool SharpFormat::save( Calendar *calendar) 492bool SharpFormat::save( Calendar *calendar)
493{ 493{
494 494
495 QLabel status ( i18n("Processing/adding events ..."), 0 ); 495 QLabel status ( i18n("Processing/adding events ..."), 0 );
496 int w = status.sizeHint().width()+20 ; 496 int w = status.sizeHint().width()+20 ;
497 if ( w < 200 ) w = 200; 497 if ( w < 200 ) w = 200;
498 int h = status.sizeHint().height()+20 ; 498 int h = status.sizeHint().height()+20 ;
499 int dw = QApplication::desktop()->width(); 499 int dw = QApplication::desktop()->width();
500 int dh = QApplication::desktop()->height(); 500 int dh = QApplication::desktop()->height();
501 status.setCaption(i18n("Writing DTM Data") ); 501 status.setCaption(i18n("Writing DTM Data") );
502 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 502 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
503 status.show(); 503 status.show();
504 status.raise(); 504 status.raise();
505 qApp->processEvents(); 505 qApp->processEvents();
506 bool debug = DEBUGMODE; 506 bool debug = DEBUGMODE;
507 QString codec = "utf8"; 507 QString codec = "utf8";
508 QString answer; 508 QString answer;
509 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; 509 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n";
510 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; 510 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n";
511 QString command; 511 QString command;
512 QPtrList<Event> er = calendar->rawEvents(); 512 QPtrList<Event> er = calendar->rawEvents();
513 Event* ev = er.first(); 513 Event* ev = er.first();
514 QString fileName = "/tmp/kopitempout"; 514 QString fileName = "/tmp/kopitempout";
515 int i = 0; 515 int i = 0;
516 QString changeString = ePrefix; 516 QString changeString = ePrefix;
517 QString deleteString = ePrefix; 517 QString deleteString = ePrefix;
518 bool deleteEnt = false; 518 bool deleteEnt = false;
519 bool changeEnt = false; 519 bool changeEnt = false;
520 QString message = i18n("Processing event # "); 520 QString message = i18n("Processing event # ");
521 int procCount = 0; 521 int procCount = 0;
522 while ( ev ) { 522 while ( ev ) {
523 //qDebug("i %d ", ++i); 523 //qDebug("i %d ", ++i);
524 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 524 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
525 status.setText ( message + QString::number ( ++procCount ) ); 525 status.setText ( message + QString::number ( ++procCount ) );
526 qApp->processEvents(); 526 qApp->processEvents();
527 QString eString = getEventString( ev ); 527 QString eString = getEventString( ev );
528 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 528 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
529 // deleting empty strings does not work. 529 // deleting empty strings does not work.
530 // we write first and x and then delete the record with the x 530 // we write first and x and then delete the record with the x
531 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 531 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
532 changeString += eString + "\n"; 532 changeString += eString + "\n";
533 deleteString += eString + "\n"; 533 deleteString += eString + "\n";
534 deleteEnt = true; 534 deleteEnt = true;
535 changeEnt = true; 535 changeEnt = true;
536 } 536 }
537 else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new 537 else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new
538 QString fileNameIn = "/tmp/kopitempin"; 538 QString fileNameIn = "/tmp/kopitempin";
539 QFile fileIn( fileNameIn ); 539 QFile fileIn( fileNameIn );
540 if (!fileIn.open( IO_WriteOnly ) ) { 540 if (!fileIn.open( IO_WriteOnly ) ) {
541 return false; 541 return false;
542 } 542 }
543 QTextStream tsIn( &fileIn ); 543 QTextStream tsIn( &fileIn );
544 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 544 tsIn.setCodec( QTextCodec::codecForName("utf8") );
545 tsIn << ePrefix << eString ; 545 tsIn << ePrefix << eString ;
546 fileIn.close(); 546 fileIn.close();
547 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 547 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
548 command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName; 548 command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName;
549 qDebug("command ++++++++ "); 549 //qDebug("command ++++++++ ");
550 qDebug("%s ",command.latin1()); 550 //qDebug("%s ",command.latin1());
551 qDebug("command -------- "); 551 //qDebug("command -------- ");
552 system ( command.utf8() ); 552 system ( command.utf8() );
553 QFile file( fileName ); 553 QFile file( fileName );
554 if (!file.open( IO_ReadOnly ) ) { 554 if (!file.open( IO_ReadOnly ) ) {
555 return false; 555 return false;
556 556
557 } 557 }
558 QTextStream ts( &file ); 558 QTextStream ts( &file );
559 ts.setCodec( QTextCodec::codecForName("utf8") ); 559 ts.setCodec( QTextCodec::codecForName("utf8") );
560 answer = ts.read(); 560 answer = ts.read();
561 file.close(); 561 file.close();
562 //qDebug("answer \n%s ", answer.latin1()); 562 //qDebug("answer \n%s ", answer.latin1());
563 getNumFromRecord( answer, ev ) ; 563 getNumFromRecord( answer, ev ) ;
564 564
565 } 565 }
566 else { // change existing 566 else { // change existing
567 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); 567 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() );
568 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 568 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
569 changeString += eString + "\n"; 569 changeString += eString + "\n";
570 changeEnt = true; 570 changeEnt = true;
571 571
572 } 572 }
573 } 573 }
574 ev = er.next(); 574 ev = er.next();
575 } 575 }
576 status.setText ( i18n("Changing events ...") ); 576 status.setText ( i18n("Changing events ...") );
577 qApp->processEvents(); 577 qApp->processEvents();
578 //qDebug("changing... "); 578 //qDebug("changing... ");
579 if ( changeEnt ) { 579 if ( changeEnt ) {
580 QFile file( fileName ); 580 QFile file( fileName );
581 if (!file.open( IO_WriteOnly ) ) { 581 if (!file.open( IO_WriteOnly ) ) {
582 return false; 582 return false;
583 583
584 } 584 }
585 QTextStream ts( &file ); 585 QTextStream ts( &file );
586 ts.setCodec( QTextCodec::codecForName("utf8") ); 586 ts.setCodec( QTextCodec::codecForName("utf8") );
587 ts << changeString ; 587 ts << changeString ;
588 file.close(); 588 file.close();
589 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; 589 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName;
590 system ( command.latin1() ); 590 system ( command.latin1() );
591 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 591 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
592 592
593 } 593 }
594 status.setText ( i18n("Deleting events ...") ); 594 status.setText ( i18n("Deleting events ...") );
595 qApp->processEvents(); 595 qApp->processEvents();
596 //qDebug("deleting... "); 596 //qDebug("deleting... ");
597 if ( deleteEnt ) { 597 if ( deleteEnt ) {
598 QFile file( fileName ); 598 QFile file( fileName );
599 if (!file.open( IO_WriteOnly ) ) { 599 if (!file.open( IO_WriteOnly ) ) {
600 return false; 600 return false;
601 601
602 } 602 }
603 QTextStream ts( &file ); 603 QTextStream ts( &file );
604 ts.setCodec( QTextCodec::codecForName("utf8") ); 604 ts.setCodec( QTextCodec::codecForName("utf8") );
605 ts << deleteString; 605 ts << deleteString;
606 file.close(); 606 file.close();
607 command = "db2file datebook -d -c " + codec+ " < "+ fileName; 607 command = "db2file datebook -d -c " + codec+ " < "+ fileName;
608 system ( command.latin1() ); 608 system ( command.latin1() );
609 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 609 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
610 } 610 }
611 611
612 612
613 changeString = tPrefix; 613 changeString = tPrefix;
614 deleteString = tPrefix; 614 deleteString = tPrefix;
615 status.setText ( i18n("Processing todos ...") ); 615 status.setText ( i18n("Processing todos ...") );
616 qApp->processEvents(); 616 qApp->processEvents();
617 QPtrList<Todo> tl = calendar->rawTodos(); 617 QPtrList<Todo> tl = calendar->rawTodos();
618 Todo* to = tl.first(); 618 Todo* to = tl.first();
619 i = 0; 619 i = 0;
620 message = i18n("Processing todo # "); 620 message = i18n("Processing todo # ");
621 procCount = 0; 621 procCount = 0;
622 while ( to ) { 622 while ( to ) {
623 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 623 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
624 status.setText ( message + QString::number ( ++procCount ) ); 624 status.setText ( message + QString::number ( ++procCount ) );
625 qApp->processEvents(); 625 qApp->processEvents();
626 QString eString = getTodoString( to ); 626 QString eString = getTodoString( to );
627 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 627 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
628 // deleting empty strings does not work. 628 // deleting empty strings does not work.
629 // we write first and x and then delete the record with the x 629 // we write first and x and then delete the record with the x
630 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 630 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
631 changeString += eString + "\n"; 631 changeString += eString + "\n";
632 deleteString += eString + "\n"; 632 deleteString += eString + "\n";
633 deleteEnt = true; 633 deleteEnt = true;
634 changeEnt = true; 634 changeEnt = true;
635 } 635 }
636 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new 636 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new
637 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; 637 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName;
638 system ( command.utf8() ); 638 system ( command.utf8() );
639 QFile file( fileName ); 639 QFile file( fileName );
640 if (!file.open( IO_ReadOnly ) ) { 640 if (!file.open( IO_ReadOnly ) ) {
641 return false; 641 return false;
642 642
643 } 643 }
644 QTextStream ts( &file ); 644 QTextStream ts( &file );
645 ts.setCodec( QTextCodec::codecForName("utf8") ); 645 ts.setCodec( QTextCodec::codecForName("utf8") );
646 answer = ts.read(); 646 answer = ts.read();
647 file.close(); 647 file.close();
648 //qDebug("answer \n%s ", answer.latin1()); 648 //qDebug("answer \n%s ", answer.latin1());
649 getNumFromRecord( answer, to ) ; 649 getNumFromRecord( answer, to ) ;
650 650
651 } 651 }
652 else { // change existing 652 else { // change existing
653 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); 653 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() );
654 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 654 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
655 changeString += eString + "\n"; 655 changeString += eString + "\n";
656 changeEnt = true; 656 changeEnt = true;
657 657
658 } 658 }
659 } 659 }
660 660
661 to = tl.next(); 661 to = tl.next();
662 } 662 }
663 status.setText ( i18n("Changing todos ...") ); 663 status.setText ( i18n("Changing todos ...") );
664 qApp->processEvents(); 664 qApp->processEvents();
665 //qDebug("changing... "); 665 //qDebug("changing... ");
666 if ( changeEnt ) { 666 if ( changeEnt ) {
667 QFile file( fileName ); 667 QFile file( fileName );
668 if (!file.open( IO_WriteOnly ) ) { 668 if (!file.open( IO_WriteOnly ) ) {
669 return false; 669 return false;
670 670
671 } 671 }
672 QTextStream ts( &file ); 672 QTextStream ts( &file );
673 ts.setCodec( QTextCodec::codecForName("utf8") ); 673 ts.setCodec( QTextCodec::codecForName("utf8") );
674 ts << changeString ; 674 ts << changeString ;
675 file.close(); 675 file.close();
676 command = "db2file todo -w -g -c " + codec+ " < "+ fileName; 676 command = "db2file todo -w -g -c " + codec+ " < "+ fileName;
677 system ( command.latin1() ); 677 system ( command.latin1() );
678 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 678 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
679 679
680 } 680 }
681 status.setText ( i18n("Deleting todos ...") ); 681 status.setText ( i18n("Deleting todos ...") );
682 qApp->processEvents(); 682 qApp->processEvents();
683 //qDebug("deleting... "); 683 //qDebug("deleting... ");
684 if ( deleteEnt ) { 684 if ( deleteEnt ) {
685 QFile file( fileName ); 685 QFile file( fileName );
686 if (!file.open( IO_WriteOnly ) ) { 686 if (!file.open( IO_WriteOnly ) ) {
687 return false; 687 return false;
688 688
689 } 689 }
690 QTextStream ts( &file ); 690 QTextStream ts( &file );
691 ts.setCodec( QTextCodec::codecForName("utf8") ); 691 ts.setCodec( QTextCodec::codecForName("utf8") );
692 ts << deleteString; 692 ts << deleteString;
693 file.close(); 693 file.close();
694 command = "db2file todo -d -c " + codec+ " < "+ fileName; 694 command = "db2file todo -d -c " + codec+ " < "+ fileName;
695 system ( command.latin1() ); 695 system ( command.latin1() );
696 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 696 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
697 } 697 }
698 698
699 return true; 699 return true;
700} 700}
701QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) 701QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ )
702{ 702{
703 QString datestr; 703 QString datestr;
704 QString timestr; 704 QString timestr;
705 int offset = KGlobal::locale()->localTimeOffset( dti ); 705 int offset = KGlobal::locale()->localTimeOffset( dti );
706 QDateTime dt; 706 QDateTime dt;
707 if (useTZ) 707 if (useTZ)
708 dt = dti.addSecs ( -(offset*60)); 708 dt = dti.addSecs ( -(offset*60));
709 else 709 else
710 dt = dti; 710 dt = dti;
711 if(dt.date().isValid()){ 711 if(dt.date().isValid()){
712 const QDate& date = dt.date(); 712 const QDate& date = dt.date();
713 datestr.sprintf("%04d%02d%02d", 713 datestr.sprintf("%04d%02d%02d",
714 date.year(), date.month(), date.day()); 714 date.year(), date.month(), date.day());
715 } 715 }
716 if(dt.time().isValid()){ 716 if(dt.time().isValid()){
717 const QTime& time = dt.time(); 717 const QTime& time = dt.time();
718 timestr.sprintf("T%02d%02d%02d", 718 timestr.sprintf("T%02d%02d%02d",
719 time.hour(), time.minute(), time.second()); 719 time.hour(), time.minute(), time.second());
720 } 720 }
721 return datestr + timestr; 721 return datestr + timestr;
722} 722}
723QString SharpFormat::getEventString( Event* event ) 723QString SharpFormat::getEventString( Event* event )
724{ 724{
725 QStringList list; 725 QStringList list;
726 list.append( event->getID("Sharp_DTM") ); 726 list.append( event->getID("Sharp_DTM") );
727 list.append( event->categories().join(",") ); 727 list.append( event->categories().join(",") );
728 if ( !event->summary().isEmpty() ) 728 if ( !event->summary().isEmpty() )
729 list.append( event->summary() ); 729 list.append( event->summary() );
730 else 730 else
731 list.append("" ); 731 list.append("" );
732 if ( !event->location().isEmpty() ) 732 if ( !event->location().isEmpty() )
733 list.append( event->location() ); 733 list.append( event->location() );
734 else 734 else
735 list.append("" ); 735 list.append("" );
736 if ( !event->description().isEmpty() ) 736 if ( !event->description().isEmpty() )
737 list.append( event->description() ); 737 list.append( event->description() );
738 else 738 else
739 list.append( "" ); 739 list.append( "" );
740 if ( event->doesFloat () ) { 740 if ( event->doesFloat () ) {
741 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); 741 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false ));
742 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 742 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6
743 list.append( "1" ); 743 list.append( "1" );
744 744
745 } 745 }
746 else { 746 else {
747 list.append( dtToString( event->dtStart()) ); 747 list.append( dtToString( event->dtStart()) );
748 list.append( dtToString( event->dtEnd()) ); //6 748 list.append( dtToString( event->dtEnd()) ); //6
749 list.append( "0" ); 749 list.append( "0" );
750 } 750 }
751 bool noAlarm = true; 751 bool noAlarm = true;
752 if ( event->alarms().count() > 0 ) { 752 if ( event->alarms().count() > 0 ) {
753 Alarm * al = event->alarms().first(); 753 Alarm * al = event->alarms().first();
754 if ( al->enabled() ) { 754 if ( al->enabled() ) {
755 noAlarm = false; 755 noAlarm = false;
756 list.append( "0" ); // yes, 0 == alarm 756 list.append( "0" ); // yes, 0 == alarm
757 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); 757 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) );
758 if ( al->type() == Alarm::Audio ) 758 if ( al->type() == Alarm::Audio )
759 list.append( "1" ); // type audio 759 list.append( "1" ); // type audio
760 else 760 else
761 list.append( "0" ); // type silent 761 list.append( "0" ); // type silent
762 } 762 }
763 } 763 }
764 if ( noAlarm ) { 764 if ( noAlarm ) {
765 list.append( "1" ); // yes, 1 == no alarm 765 list.append( "1" ); // yes, 1 == no alarm
766 list.append( "0" ); // no alarm offset 766 list.append( "0" ); // no alarm offset
767 list.append( "1" ); // type 767 list.append( "1" ); // type
768 } 768 }
769 // next is: 11 769 // next is: 11
770 // next is: 11-16 are recurrence 770 // next is: 11-16 are recurrence
771 Recurrence* rec = event->recurrence(); 771 Recurrence* rec = event->recurrence();
772 772
773 bool writeEndDate = false; 773 bool writeEndDate = false;
774 switch ( rec->doesRecur() ) 774 switch ( rec->doesRecur() )
775 { 775 {
776 case Recurrence::rDaily: // 0 776 case Recurrence::rDaily: // 0
777 list.append( "0" ); 777 list.append( "0" );
778 list.append( QString::number( rec->frequency() ));//12 778 list.append( QString::number( rec->frequency() ));//12
779 list.append( "0" ); 779 list.append( "0" );
780 list.append( "0" ); 780 list.append( "0" );
781 writeEndDate = true; 781 writeEndDate = true;
782 break; 782 break;
783 case Recurrence::rWeekly:// 1 783 case Recurrence::rWeekly:// 1
784 list.append( "1" ); 784 list.append( "1" );
785 list.append( QString::number( rec->frequency()) );//12 785 list.append( QString::number( rec->frequency()) );//12
786 list.append( "0" ); 786 list.append( "0" );
787 { 787 {
788 int days = 0; 788 int days = 0;
789 QBitArray weekDays = rec->days(); 789 QBitArray weekDays = rec->days();
790 int i; 790 int i;
791 for( i = 1; i <= 7; ++i ) { 791 for( i = 1; i <= 7; ++i ) {
792 if ( weekDays[i-1] ) { 792 if ( weekDays[i-1] ) {
793 days += 1 << (i-1); 793 days += 1 << (i-1);
794 } 794 }
795 } 795 }
796 list.append( QString::number( days ) ); 796 list.append( QString::number( days ) );
797 } 797 }
798 //pending weekdays 798 //pending weekdays
799 writeEndDate = true; 799 writeEndDate = true;
800 800
801 break; 801 break;
802 case Recurrence::rMonthlyPos:// 2 802 case Recurrence::rMonthlyPos:// 2
803 list.append( "2" ); 803 list.append( "2" );
804 list.append( QString::number( rec->frequency()) );//12 804 list.append( QString::number( rec->frequency()) );//12
805 805
806 writeEndDate = true; 806 writeEndDate = true;
807 { 807 {
808 int count = 1; 808 int count = 1;
809 QPtrList<Recurrence::rMonthPos> rmp; 809 QPtrList<Recurrence::rMonthPos> rmp;
810 rmp = rec->monthPositions(); 810 rmp = rec->monthPositions();
811 if ( rmp.first()->negative ) 811 if ( rmp.first()->negative )
812 count = 5 - rmp.first()->rPos - 1; 812 count = 5 - rmp.first()->rPos - 1;
813 else 813 else
814 count = rmp.first()->rPos - 1; 814 count = rmp.first()->rPos - 1;
815 list.append( QString::number( count ) ); 815 list.append( QString::number( count ) );
816 816
817 } 817 }
818 818
819 list.append( "0" ); 819 list.append( "0" );
820 break; 820 break;
821 case Recurrence::rMonthlyDay:// 3 821 case Recurrence::rMonthlyDay:// 3
822 list.append( "3" ); 822 list.append( "3" );
823 list.append( QString::number( rec->frequency()) );//12 823 list.append( QString::number( rec->frequency()) );//12
824 list.append( "0" ); 824 list.append( "0" );
825 list.append( "0" ); 825 list.append( "0" );
826 writeEndDate = true; 826 writeEndDate = true;
827 break; 827 break;
828 case Recurrence::rYearlyMonth://4 828 case Recurrence::rYearlyMonth://4
829 list.append( "4" ); 829 list.append( "4" );
830 list.append( QString::number( rec->frequency()) );//12 830 list.append( QString::number( rec->frequency()) );//12
831 list.append( "0" ); 831 list.append( "0" );
832 list.append( "0" ); 832 list.append( "0" );
833 writeEndDate = true; 833 writeEndDate = true;
834 break; 834 break;
835 835
836 default: 836 default:
837 list.append( "255" ); 837 list.append( "255" );
838 list.append( QString() ); 838 list.append( QString() );
839 list.append( "0" ); 839 list.append( "0" );
840 list.append( QString() ); 840 list.append( QString() );
841 list.append( "0" ); 841 list.append( "0" );
842 list.append( "20991231T000000" ); 842 list.append( "20991231T000000" );
843 break; 843 break;
844 } 844 }
845 if ( writeEndDate ) { 845 if ( writeEndDate ) {
846 846
847 if ( rec->endDate().isValid() ) { // 15 + 16 847 if ( rec->endDate().isValid() ) { // 15 + 16
848 list.append( "1" ); 848 list.append( "1" );
849 list.append( dtToString( rec->endDate()) ); 849 list.append( dtToString( rec->endDate()) );
850 } else { 850 } else {
851 list.append( "0" ); 851 list.append( "0" );
852 list.append( "20991231T000000" ); 852 list.append( "20991231T000000" );
853 } 853 }
854 854
855 } 855 }
856 if ( event->doesFloat () ) { 856 if ( event->doesFloat () ) {
857 list.append( dtToString( event->dtStart(), false ).left( 8 )); 857 list.append( dtToString( event->dtStart(), false ).left( 8 ));
858 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 858 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6
859 859
860 } 860 }
861 else { 861 else {
862 list.append( QString() ); 862 list.append( QString() );
863 list.append( QString() ); 863 list.append( QString() );
864 864
865 } 865 }
866 if (event->dtStart().date() == event->dtEnd().date() ) 866 if (event->dtStart().date() == event->dtEnd().date() )
867 list.append( "0" ); 867 list.append( "0" );
868 else 868 else
869 list.append( "1" ); 869 list.append( "1" );
870 870
871 871
872 for(QStringList::Iterator it=list.begin(); 872 for(QStringList::Iterator it=list.begin();
873 it!=list.end(); ++it){ 873 it!=list.end(); ++it){
874 QString& s = (*it); 874 QString& s = (*it);
875 s.replace(QRegExp("\""), "\"\""); 875 s.replace(QRegExp("\""), "\"\"");
876 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ 876 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
877 s.prepend('\"'); 877 s.prepend('\"');
878 s.append('\"'); 878 s.append('\"');
879 } else if(s.isEmpty() && !s.isNull()){ 879 } else if(s.isEmpty() && !s.isNull()){
880 s = "\"\""; 880 s = "\"\"";
881 } 881 }
882 } 882 }
883 return list.join(","); 883 return list.join(",");
884 884
885 885
886} 886}
887QString SharpFormat::getTodoString( Todo* todo ) 887QString SharpFormat::getTodoString( Todo* todo )
888{ 888{
889 QStringList list; 889 QStringList list;
890 list.append( todo->getID("Sharp_DTM") ); 890 list.append( todo->getID("Sharp_DTM") );
891 list.append( todo->categories().join(",") ); 891 list.append( todo->categories().join(",") );
892 892
893 if ( todo->hasStartDate() ) { 893 if ( todo->hasStartDate() ) {
894 list.append( dtToString( todo->dtStart()) ); 894 list.append( dtToString( todo->dtStart()) );
895 } else 895 } else
896 list.append( QString() ); 896 list.append( QString() );
897 897
898 if ( todo->hasDueDate() ) { 898 if ( todo->hasDueDate() ) {
899 QTime tim; 899 QTime tim;
900 if ( todo->doesFloat()) { 900 if ( todo->doesFloat()) {
901 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; 901 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ;
902 } else { 902 } else {
903 list.append( dtToString(todo->dtDue() ) ); 903 list.append( dtToString(todo->dtDue() ) );
904 } 904 }
905 } else 905 } else
906 list.append( QString() ); 906 list.append( QString() );
907 907
908 if ( todo->isCompleted() ) { 908 if ( todo->isCompleted() ) {
909 list.append( dtToString( todo->completed()) ); 909 list.append( dtToString( todo->completed()) );
910 list.append( "0" ); // yes 0 == completed 910 list.append( "0" ); // yes 0 == completed
911 } else { 911 } else {
912 list.append( dtToString( todo->completed()) ); 912 list.append( dtToString( todo->completed()) );
913 list.append( "1" ); 913 list.append( "1" );
914 } 914 }
915 list.append( QString::number( todo->priority() )); 915 list.append( QString::number( todo->priority() ));
916 if( ! todo->summary().isEmpty() ) 916 if( ! todo->summary().isEmpty() )
917 list.append( todo->summary() ); 917 list.append( todo->summary() );
918 else 918 else
919 list.append( "" ); 919 list.append( "" );
920 if (! todo->description().isEmpty() ) 920 if (! todo->description().isEmpty() )
921 list.append( todo->description() ); 921 list.append( todo->description() );
922 else 922 else
923 list.append( "" ); 923 list.append( "" );
924 for(QStringList::Iterator it=list.begin(); 924 for(QStringList::Iterator it=list.begin();
925 it!=list.end(); ++it){ 925 it!=list.end(); ++it){
926 QString& s = (*it); 926 QString& s = (*it);
927 s.replace(QRegExp("\""), "\"\""); 927 s.replace(QRegExp("\""), "\"\"");
928 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ 928 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
929 s.prepend('\"'); 929 s.prepend('\"');
930 s.append('\"'); 930 s.append('\"');
931 } else if(s.isEmpty() && !s.isNull()){ 931 } else if(s.isEmpty() && !s.isNull()){
932 s = "\"\""; 932 s = "\"\"";
933 } 933 }
934 } 934 }
935 return list.join(","); 935 return list.join(",");
936} 936}
937QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) 937QString SharpFormat::getPart( const QString & text, bool &ok, int &start )
938{ 938{
939 //qDebug("start %d ", start); 939 //qDebug("start %d ", start);
940 940
941 QString retval =""; 941 QString retval ="";
942 if ( text.at(start) == '"' ) { 942 if ( text.at(start) == '"' ) {
943 if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { 943 if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) {
944 start = start +2; 944 start = start +2;
945 if ( text.mid( start,1) == "," ) { 945 if ( text.mid( start,1) == "," ) {
946 start += 1; 946 start += 1;
947 } 947 }
948 retval = ""; 948 retval = "";
949 if ( text.mid( start,1) == "\n" ) { 949 if ( text.mid( start,1) == "\n" ) {
950 start += 1; 950 start += 1;
951 ok = false; 951 ok = false;
952 } 952 }
953 return retval; 953 return retval;
954 } 954 }
955 int hk = start+1; 955 int hk = start+1;
956 hk = text.find ('"',hk); 956 hk = text.find ('"',hk);
957 while ( text.at(hk+1) == '"' ) 957 while ( text.at(hk+1) == '"' )
958 hk = text.find ('"',hk+2); 958 hk = text.find ('"',hk+2);
959 retval = text.mid( start+1, hk-start-1); 959 retval = text.mid( start+1, hk-start-1);
960 start = hk+1; 960 start = hk+1;
961 retval.replace( QRegExp("\"\""), "\""); 961 retval.replace( QRegExp("\"\""), "\"");
962 if ( text.mid( start,1) == "," ) { 962 if ( text.mid( start,1) == "," ) {
963 start += 1; 963 start += 1;
964 } 964 }
965 if ( text.mid( start,1) == "\n" ) { 965 if ( text.mid( start,1) == "\n" ) {
966 start += 1; 966 start += 1;
967 ok = false; 967 ok = false;
968 } 968 }
969 //qDebug("retval***%s*** ",retval.latin1() ); 969 //qDebug("retval***%s*** ",retval.latin1() );
970 return retval; 970 return retval;
971 971
972 } else { 972 } else {
973 int nl = text.find ("\n",start); 973 int nl = text.find ("\n",start);
974 int kom = text.find (',',start); 974 int kom = text.find (',',start);
975 if ( kom < nl ) { 975 if ( kom < nl ) {
976 // qDebug("kom < nl %d ", kom); 976 // qDebug("kom < nl %d ", kom);
977 retval = text.mid(start, kom-start); 977 retval = text.mid(start, kom-start);
978 start = kom+1; 978 start = kom+1;
979 return retval; 979 return retval;
980 } else { 980 } else {
981 if ( nl == kom ) { 981 if ( nl == kom ) {
982 // qDebug(" nl == kom "); 982 // qDebug(" nl == kom ");
983 start = 0; 983 start = 0;
984 ok = false; 984 ok = false;
985 return "0"; 985 return "0";
986 } 986 }
987 // qDebug(" nl < kom ", nl); 987 // qDebug(" nl < kom ", nl);
988 retval = text.mid( start, nl-start); 988 retval = text.mid( start, nl-start);
989 ok = false; 989 ok = false;
990 start = nl+1; 990 start = nl+1;
991 return retval; 991 return retval;
992 } 992 }
993 } 993 }
994} 994}
995bool SharpFormat::fromString( Calendar *calendar, const QString & text) 995bool SharpFormat::fromString( Calendar *calendar, const QString & text)
996{ 996{
997 return false; 997 return false;
998} 998}
999bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type) 999bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type)
1000{ 1000{
1001 // qDebug("test %s ", text.latin1()); 1001 // qDebug("test %s ", text.latin1());
1002 QStringList templist; 1002 QStringList templist;
1003 QString tempString; 1003 QString tempString;
1004 int start = 0; 1004 int start = 0;
1005 int len = text.length(); 1005 int len = text.length();
1006 int end = text.find ("\n",start)+1; 1006 int end = text.find ("\n",start)+1;
1007 bool ok = true; 1007 bool ok = true;
1008 start = end; 1008 start = end;
1009 SharpParser handler( calendar ); 1009 SharpParser handler( calendar );
1010 handler.setCategoriesList( mCategories ); 1010 handler.setCategoriesList( mCategories );
1011 while ( start > 0 ) { 1011 while ( start > 0 ) {
1012 templist.clear(); 1012 templist.clear();
1013 ok = true; 1013 ok = true;
1014 while ( ok ) { 1014 while ( ok ) {
1015 tempString = getPart( text, ok, start ); 1015 tempString = getPart( text, ok, start );
1016 if ( start >= len || start == 0 ) { 1016 if ( start >= len || start == 0 ) {
1017 start = 0; 1017 start = 0;
1018 ok = false; 1018 ok = false;
1019 } 1019 }
1020 if ( tempString.right(1) =="\n" ) 1020 if ( tempString.right(1) =="\n" )
1021 tempString = tempString.left( tempString.length()-1); 1021 tempString = tempString.left( tempString.length()-1);
1022 //if ( ok ) 1022 //if ( ok )
1023 templist.append( tempString ); 1023 templist.append( tempString );
1024 //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); 1024 //qDebug("%d ---%s---", templist.count(),tempString.latin1() );
1025 } 1025 }
1026 handler.startElement( existingCalendar, templist, type ); 1026 handler.startElement( existingCalendar, templist, type );
1027 } 1027 }
1028 1028
1029 return false; 1029 return false;
1030} 1030}
1031 1031
1032QString SharpFormat::toString( Calendar * ) 1032QString SharpFormat::toString( Calendar * )
1033{ 1033{
1034 return QString::null; 1034 return QString::null;
1035} 1035}
diff --git a/libkcal/syncdefines.h b/libkcal/syncdefines.h
index 57642ec..704a670 100644
--- a/libkcal/syncdefines.h
+++ b/libkcal/syncdefines.h
@@ -1,22 +1,24 @@
1 1
2#ifndef _KSYNC_DEFINES_H_ 2#ifndef _KSYNC_DEFINES_H_
3#define _KSYNC_DEFINES_H_ 3#define _KSYNC_DEFINES_H_
4 4
5#define SYNC_PREF_LOCAL 0 5#define SYNC_PREF_LOCAL 0
6#define SYNC_PREF_REMOTE 1 6#define SYNC_PREF_REMOTE 1
7#define SYNC_PREF_NEWEST 2 7#define SYNC_PREF_NEWEST 2
8#define SYNC_PREF_ASK 3 8#define SYNC_PREF_ASK 3
9#define SYNC_PREF_FORCE_LOCAL 4 9#define SYNC_PREF_FORCE_LOCAL 4
10#define SYNC_PREF_FORCE_REMOTE 5 10#define SYNC_PREF_FORCE_REMOTE 5
11#define SYNC_PREF_TAKE_BOTH 6 11#define SYNC_PREF_TAKE_BOTH 6
12 12
13#define SYNC_MODE_NORMAL 0 13#define SYNC_MODE_NORMAL 0
14#define SYNC_MODE_EXTERNAL 1 14#define SYNC_MODE_EXTERNAL 1
15 15
16#define SYNC_TEMPSTATE_INITIAL 0 16#define SYNC_TEMPSTATE_INITIAL 0
17#define SYNC_TEMPSTATE_ADDED_EXTERNAL -1
17#define SYNC_TEMPSTATE_NEW_EXTERNAL -2 18#define SYNC_TEMPSTATE_NEW_EXTERNAL -2
18#define SYNC_TEMPSTATE_DELETE -3 19#define SYNC_TEMPSTATE_DELETE -3
19#define SYNC_TEMPSTATE_NEW_ID -4 20#define SYNC_TEMPSTATE_NEW_ID -4
21#define SYNC_TEMPSTATE_NEW_CSUM -5
20 22
21 23
22#endif 24#endif