author | zautrix <zautrix> | 2004-09-19 09:11:04 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-19 09:11:04 (UTC) |
commit | 953277a85e6ec5630ab0d64b4d68815e4e4f9906 (patch) (unidiff) | |
tree | 0a6acbc3ecd65784c1e875159b720849bc27dc48 | |
parent | 787181d34f0d195ad72c9cf6aedbc317b6dd713e (diff) | |
download | kdepimpi-953277a85e6ec5630ab0d64b4d68815e4e4f9906.zip kdepimpi-953277a85e6ec5630ab0d64b4d68815e4e4f9906.tar.gz kdepimpi-953277a85e6ec5630ab0d64b4d68815e4e4f9906.tar.bz2 |
More AB sync
-rw-r--r-- | kabc/addressee.cpp | 9 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 16 |
2 files changed, 12 insertions, 13 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index d6b70c4..c34f671 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -15,550 +15,549 @@ | |||
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 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (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 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | 46 | ||
47 | struct Addressee::AddresseeData : public KShared | 47 | struct 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 | KURL url; | 69 | KURL url; |
70 | Secrecy secrecy; | 70 | Secrecy secrecy; |
71 | Picture logo; | 71 | Picture logo; |
72 | Picture photo; | 72 | Picture photo; |
73 | Sound sound; | 73 | Sound sound; |
74 | Agent agent; | 74 | Agent agent; |
75 | QString mExternalId; | 75 | QString mExternalId; |
76 | PhoneNumber::List phoneNumbers; | 76 | PhoneNumber::List phoneNumbers; |
77 | Address::List addresses; | 77 | Address::List addresses; |
78 | Key::List keys; | 78 | Key::List keys; |
79 | QStringList emails; | 79 | QStringList emails; |
80 | QStringList categories; | 80 | QStringList categories; |
81 | QStringList custom; | 81 | QStringList custom; |
82 | int mTempSyncStat; | 82 | int mTempSyncStat; |
83 | Resource *resource; | 83 | Resource *resource; |
84 | 84 | ||
85 | bool empty :1; | 85 | bool empty :1; |
86 | bool changed :1; | 86 | bool changed :1; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | Addressee::Addressee() | 89 | Addressee::Addressee() |
90 | { | 90 | { |
91 | mData = new AddresseeData; | 91 | mData = new AddresseeData; |
92 | mData->empty = true; | 92 | mData->empty = true; |
93 | mData->changed = false; | 93 | mData->changed = false; |
94 | mData->resource = 0; | 94 | mData->resource = 0; |
95 | mData->mExternalId = ":"; | 95 | mData->mExternalId = ":"; |
96 | mData->revision = QDateTime ( QDate( 2004,1,1)); | 96 | mData->revision = QDateTime ( QDate( 2004,1,1)); |
97 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 97 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
98 | } | 98 | } |
99 | 99 | ||
100 | Addressee::~Addressee() | 100 | Addressee::~Addressee() |
101 | { | 101 | { |
102 | } | 102 | } |
103 | 103 | ||
104 | Addressee::Addressee( const Addressee &a ) | 104 | Addressee::Addressee( const Addressee &a ) |
105 | { | 105 | { |
106 | mData = a.mData; | 106 | mData = a.mData; |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee &Addressee::operator=( const Addressee &a ) | 109 | Addressee &Addressee::operator=( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | return (*this); | 112 | return (*this); |
113 | } | 113 | } |
114 | 114 | ||
115 | Addressee Addressee::copy() | 115 | Addressee Addressee::copy() |
116 | { | 116 | { |
117 | Addressee a; | 117 | Addressee a; |
118 | *(a.mData) = *mData; | 118 | *(a.mData) = *mData; |
119 | return a; | 119 | return a; |
120 | } | 120 | } |
121 | 121 | ||
122 | void Addressee::detach() | 122 | void Addressee::detach() |
123 | { | 123 | { |
124 | if ( mData.count() == 1 ) return; | 124 | if ( mData.count() == 1 ) return; |
125 | *this = copy(); | 125 | *this = copy(); |
126 | } | 126 | } |
127 | 127 | ||
128 | bool Addressee::operator==( const Addressee &a ) const | 128 | bool Addressee::operator==( const Addressee &a ) const |
129 | { | 129 | { |
130 | if ( uid() != a.uid() ) return false; | 130 | if ( uid() != a.uid() ) return false; |
131 | if ( mData->name != a.mData->name ) return false; | 131 | if ( mData->name != a.mData->name ) return false; |
132 | if ( mData->formattedName != a.mData->formattedName ) return false; | 132 | if ( mData->formattedName != a.mData->formattedName ) return false; |
133 | if ( mData->familyName != a.mData->familyName ) return false; | 133 | if ( mData->familyName != a.mData->familyName ) return false; |
134 | if ( mData->givenName != a.mData->givenName ) return false; | 134 | if ( mData->givenName != a.mData->givenName ) return false; |
135 | if ( mData->additionalName != a.mData->additionalName ) return false; | 135 | if ( mData->additionalName != a.mData->additionalName ) return false; |
136 | if ( mData->prefix != a.mData->prefix ) return false; | 136 | if ( mData->prefix != a.mData->prefix ) return false; |
137 | if ( mData->suffix != a.mData->suffix ) return false; | 137 | if ( mData->suffix != a.mData->suffix ) return false; |
138 | if ( mData->nickName != a.mData->nickName ) return false; | 138 | if ( mData->nickName != a.mData->nickName ) return false; |
139 | if ( mData->birthday != a.mData->birthday ) return false; | 139 | if ( mData->birthday != a.mData->birthday ) return false; |
140 | if ( mData->mailer != a.mData->mailer ) return false; | 140 | if ( mData->mailer != a.mData->mailer ) return false; |
141 | if ( mData->timeZone != a.mData->timeZone ) return false; | 141 | if ( mData->timeZone != a.mData->timeZone ) return false; |
142 | if ( mData->geo != a.mData->geo ) return false; | 142 | if ( mData->geo != a.mData->geo ) return false; |
143 | if ( mData->title != a.mData->title ) return false; | 143 | if ( mData->title != a.mData->title ) return false; |
144 | if ( mData->role != a.mData->role ) return false; | 144 | if ( mData->role != a.mData->role ) return false; |
145 | if ( mData->organization != a.mData->organization ) return false; | 145 | if ( mData->organization != a.mData->organization ) return false; |
146 | if ( mData->note != a.mData->note ) return false; | 146 | if ( mData->note != a.mData->note ) return false; |
147 | if ( mData->productId != a.mData->productId ) return false; | 147 | if ( mData->productId != a.mData->productId ) return false; |
148 | if ( mData->revision != a.mData->revision ) return false; | 148 | if ( mData->revision != a.mData->revision ) return false; |
149 | if ( mData->sortString != a.mData->sortString ) return false; | 149 | if ( mData->sortString != a.mData->sortString ) return false; |
150 | if ( mData->secrecy != a.mData->secrecy ) return false; | 150 | if ( mData->secrecy != a.mData->secrecy ) return false; |
151 | if ( mData->logo != a.mData->logo ) return false; | 151 | if ( mData->logo != a.mData->logo ) return false; |
152 | if ( mData->photo != a.mData->photo ) return false; | 152 | if ( mData->photo != a.mData->photo ) return false; |
153 | if ( mData->sound != a.mData->sound ) return false; | 153 | if ( mData->sound != a.mData->sound ) return false; |
154 | if ( mData->agent != a.mData->agent ) return false; | 154 | if ( mData->agent != a.mData->agent ) return false; |
155 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 155 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
156 | ( mData->url != a.mData->url ) ) return false; | 156 | ( mData->url != a.mData->url ) ) return false; |
157 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 157 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
158 | if ( mData->addresses != a.mData->addresses ) return false; | 158 | if ( mData->addresses != a.mData->addresses ) return false; |
159 | if ( mData->keys != a.mData->keys ) return false; | 159 | if ( mData->keys != a.mData->keys ) return false; |
160 | if ( mData->emails != a.mData->emails ) return false; | 160 | if ( mData->emails != a.mData->emails ) return false; |
161 | if ( mData->categories != a.mData->categories ) return false; | 161 | if ( mData->categories != a.mData->categories ) return false; |
162 | if ( mData->custom != a.mData->custom ) return false; | 162 | if ( mData->custom != a.mData->custom ) return false; |
163 | 163 | ||
164 | return true; | 164 | return true; |
165 | } | 165 | } |
166 | 166 | ||
167 | bool Addressee::operator!=( const Addressee &a ) const | 167 | bool Addressee::operator!=( const Addressee &a ) const |
168 | { | 168 | { |
169 | return !( a == *this ); | 169 | return !( a == *this ); |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::isEmpty() const | 172 | bool Addressee::isEmpty() const |
173 | { | 173 | { |
174 | return mData->empty; | 174 | return mData->empty; |
175 | } | 175 | } |
176 | ulong Addressee::getCsum4List( const QStringList & attList) | 176 | ulong Addressee::getCsum4List( const QStringList & attList) |
177 | { | 177 | { |
178 | int max = attList.count(); | 178 | int max = attList.count(); |
179 | ulong cSum = 0; | 179 | ulong cSum = 0; |
180 | int j,k,i; | 180 | int j,k,i; |
181 | int add; | 181 | int add; |
182 | for ( i = 0; i < max ; ++i ) { | 182 | for ( i = 0; i < max ; ++i ) { |
183 | QString s = attList[i]; | 183 | QString s = attList[i]; |
184 | if ( ! s.isEmpty() ){ | 184 | if ( ! s.isEmpty() ){ |
185 | j = s.length(); | 185 | j = s.length(); |
186 | for ( k = 0; k < j; ++k ) { | 186 | for ( k = 0; k < j; ++k ) { |
187 | int mul = k +1; | 187 | int mul = k +1; |
188 | add = s[k].unicode (); | 188 | add = s[k].unicode (); |
189 | if ( k < 16 ) | 189 | if ( k < 16 ) |
190 | mul = mul * mul; | 190 | mul = mul * mul; |
191 | int ii = i+1; | 191 | int ii = i+1; |
192 | add = add * mul *ii*ii*ii; | 192 | add = add * mul *ii*ii*ii; |
193 | cSum += add; | 193 | cSum += add; |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | } | 197 | } |
198 | //QString dump = attList.join(","); | 198 | //QString dump = attList.join(","); |
199 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 199 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
200 | 200 | ||
201 | return cSum; | 201 | return cSum; |
202 | 202 | ||
203 | } | 203 | } |
204 | void Addressee::computeCsum(const QString &dev) | 204 | void Addressee::computeCsum(const QString &dev) |
205 | { | 205 | { |
206 | QStringList l; | 206 | QStringList l; |
207 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 207 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
208 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 208 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
209 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 209 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
210 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 210 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
211 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 211 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
212 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 212 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
213 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 213 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
214 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 214 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
215 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 215 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
216 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 216 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
217 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 217 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
218 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 218 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
219 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 219 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
220 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 220 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
221 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 221 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
222 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 222 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
223 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 223 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
224 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 224 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
225 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 225 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
226 | // if ( !mData->logo.isEmpty() ) l.append( ); | 226 | // if ( !mData->logo.isEmpty() ) l.append( ); |
227 | //if ( !mData->photo.isEmpty() ) l.append( ); | 227 | //if ( !mData->photo.isEmpty() ) l.append( ); |
228 | //if ( !mData->sound.isEmpty() ) l.append( ); | 228 | //if ( !mData->sound.isEmpty() ) l.append( ); |
229 | //if ( !mData->agent.isEmpty() ) l.append( ); | 229 | //if ( !mData->agent.isEmpty() ) l.append( ); |
230 | //if ( mData->url.isValid() ) l.append( ); | 230 | //if ( mData->url.isValid() ) l.append( ); |
231 | #if 0 | 231 | #if 0 |
232 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 232 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
233 | if ( !mData->addresses.isEmpty() ) l.append( ); | 233 | if ( !mData->addresses.isEmpty() ) l.append( ); |
234 | //if ( !mData->keys.isEmpty() ) l.append( ); | 234 | //if ( !mData->keys.isEmpty() ) l.append( ); |
235 | if ( !mData->emails.isEmpty() ) l.append( ); | 235 | if ( !mData->emails.isEmpty() ) l.append( ); |
236 | if ( !mData->categories .isEmpty() ) l.append( ); | 236 | if ( !mData->categories .isEmpty() ) l.append( ); |
237 | if ( !mData->custom.isEmpty() ) l.append( ); | 237 | if ( !mData->custom.isEmpty() ) l.append( ); |
238 | #endif | 238 | #endif |
239 | KABC::PhoneNumber::List phoneNumbers; | 239 | KABC::PhoneNumber::List phoneNumbers; |
240 | KABC::PhoneNumber::List::Iterator phoneIter; | 240 | KABC::PhoneNumber::List::Iterator phoneIter; |
241 | 241 | ||
242 | QStringList t; | 242 | QStringList t; |
243 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 243 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
244 | ++phoneIter ) | 244 | ++phoneIter ) |
245 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 245 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
246 | t.sort(); | 246 | t.sort(); |
247 | uint iii; | 247 | uint iii; |
248 | for ( iii = 0; iii < t.count(); ++iii) | 248 | for ( iii = 0; iii < t.count(); ++iii) |
249 | l.append( t[iii] ); | 249 | l.append( t[iii] ); |
250 | t = mData->emails; | 250 | t = mData->emails; |
251 | t.sort(); | 251 | t.sort(); |
252 | for ( iii = 0; iii < t.count(); ++iii) | 252 | for ( iii = 0; iii < t.count(); ++iii) |
253 | l.append( t[iii] ); | 253 | l.append( t[iii] ); |
254 | t = mData->categories; | 254 | t = mData->categories; |
255 | t.sort(); | 255 | t.sort(); |
256 | for ( iii = 0; iii < t.count(); ++iii) | 256 | for ( iii = 0; iii < t.count(); ++iii) |
257 | l.append( t[iii] ); | 257 | l.append( t[iii] ); |
258 | t = mData->custom; | 258 | t = mData->custom; |
259 | t.sort(); | 259 | t.sort(); |
260 | for ( iii = 0; iii < t.count(); ++iii) | 260 | for ( iii = 0; iii < t.count(); ++iii) |
261 | l.append( t[iii] ); | 261 | l.append( t[iii] ); |
262 | KABC::Address::List::Iterator addressIter; | 262 | KABC::Address::List::Iterator addressIter; |
263 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 263 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
264 | ++addressIter ) { | 264 | ++addressIter ) { |
265 | t = (*addressIter).asList(); | 265 | t = (*addressIter).asList(); |
266 | t.sort(); | 266 | t.sort(); |
267 | for ( iii = 0; iii < t.count(); ++iii) | 267 | for ( iii = 0; iii < t.count(); ++iii) |
268 | l.append( t[iii] ); | 268 | l.append( t[iii] ); |
269 | } | 269 | } |
270 | uint cs = getCsum4List(l); | 270 | uint cs = getCsum4List(l); |
271 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 271 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
272 | setCsum( dev, QString::number (cs )); | 272 | setCsum( dev, QString::number (cs )); |
273 | } | 273 | } |
274 | void Addressee::removeID(const QString &prof) | 274 | void Addressee::removeID(const QString &prof) |
275 | { | 275 | { |
276 | detach(); | 276 | detach(); |
277 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 277 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
278 | 278 | ||
279 | } | 279 | } |
280 | void Addressee::setID( const QString & prof , const QString & id ) | 280 | void Addressee::setID( const QString & prof , const QString & id ) |
281 | { | 281 | { |
282 | detach(); | 282 | detach(); |
283 | qDebug("setID1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | ||
284 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 283 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
285 | qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 284 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
286 | } | 285 | } |
287 | void Addressee::setTempSyncStat( int id ) | 286 | void Addressee::setTempSyncStat( int id ) |
288 | { | 287 | { |
289 | if ( mData->mTempSyncStat == id ) return; | 288 | if ( mData->mTempSyncStat == id ) return; |
290 | detach(); | 289 | detach(); |
291 | mData->mTempSyncStat = id; | 290 | mData->mTempSyncStat = id; |
292 | } | 291 | } |
293 | int Addressee::tempSyncStat() const | 292 | int Addressee::tempSyncStat() const |
294 | { | 293 | { |
295 | return mData->mTempSyncStat; | 294 | return mData->mTempSyncStat; |
296 | } | 295 | } |
297 | 296 | ||
298 | QString Addressee::getID( const QString & prof) | 297 | QString Addressee::getID( const QString & prof) |
299 | { | 298 | { |
300 | return KIdManager::getId ( mData->mExternalId, prof ); | 299 | return KIdManager::getId ( mData->mExternalId, prof ); |
301 | } | 300 | } |
302 | 301 | ||
303 | void Addressee::setCsum( const QString & prof , const QString & id ) | 302 | void Addressee::setCsum( const QString & prof , const QString & id ) |
304 | { | 303 | { |
305 | detach(); | 304 | detach(); |
306 | qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 305 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
307 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 306 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
308 | qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 307 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
309 | } | 308 | } |
310 | 309 | ||
311 | QString Addressee::getCsum( const QString & prof) | 310 | QString Addressee::getCsum( const QString & prof) |
312 | { | 311 | { |
313 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 312 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
314 | } | 313 | } |
315 | 314 | ||
316 | void Addressee::setIDStr( const QString & s ) | 315 | void Addressee::setIDStr( const QString & s ) |
317 | { | 316 | { |
318 | detach(); | 317 | detach(); |
319 | mData->mExternalId = s; | 318 | mData->mExternalId = s; |
320 | } | 319 | } |
321 | 320 | ||
322 | QString Addressee::IDStr() const | 321 | QString Addressee::IDStr() const |
323 | { | 322 | { |
324 | return mData->mExternalId; | 323 | return mData->mExternalId; |
325 | } | 324 | } |
326 | 325 | ||
327 | 326 | ||
328 | void Addressee::setUid( const QString &id ) | 327 | void Addressee::setUid( const QString &id ) |
329 | { | 328 | { |
330 | if ( id == mData->uid ) return; | 329 | if ( id == mData->uid ) return; |
331 | detach(); | 330 | detach(); |
332 | mData->empty = false; | 331 | mData->empty = false; |
333 | mData->uid = id; | 332 | mData->uid = id; |
334 | } | 333 | } |
335 | 334 | ||
336 | QString Addressee::uid() const | 335 | QString Addressee::uid() const |
337 | { | 336 | { |
338 | if ( mData->uid.isEmpty() ) | 337 | if ( mData->uid.isEmpty() ) |
339 | mData->uid = KApplication::randomString( 10 ); | 338 | mData->uid = KApplication::randomString( 10 ); |
340 | 339 | ||
341 | return mData->uid; | 340 | return mData->uid; |
342 | } | 341 | } |
343 | 342 | ||
344 | QString Addressee::uidLabel() | 343 | QString Addressee::uidLabel() |
345 | { | 344 | { |
346 | return i18n("Unique Identifier"); | 345 | return i18n("Unique Identifier"); |
347 | } | 346 | } |
348 | 347 | ||
349 | void Addressee::setName( const QString &name ) | 348 | void Addressee::setName( const QString &name ) |
350 | { | 349 | { |
351 | if ( name == mData->name ) return; | 350 | if ( name == mData->name ) return; |
352 | detach(); | 351 | detach(); |
353 | mData->empty = false; | 352 | mData->empty = false; |
354 | mData->name = name; | 353 | mData->name = name; |
355 | } | 354 | } |
356 | 355 | ||
357 | QString Addressee::name() const | 356 | QString Addressee::name() const |
358 | { | 357 | { |
359 | return mData->name; | 358 | return mData->name; |
360 | } | 359 | } |
361 | 360 | ||
362 | QString Addressee::nameLabel() | 361 | QString Addressee::nameLabel() |
363 | { | 362 | { |
364 | return i18n("Name"); | 363 | return i18n("Name"); |
365 | } | 364 | } |
366 | 365 | ||
367 | 366 | ||
368 | void Addressee::setFormattedName( const QString &formattedName ) | 367 | void Addressee::setFormattedName( const QString &formattedName ) |
369 | { | 368 | { |
370 | if ( formattedName == mData->formattedName ) return; | 369 | if ( formattedName == mData->formattedName ) return; |
371 | detach(); | 370 | detach(); |
372 | mData->empty = false; | 371 | mData->empty = false; |
373 | mData->formattedName = formattedName; | 372 | mData->formattedName = formattedName; |
374 | } | 373 | } |
375 | 374 | ||
376 | QString Addressee::formattedName() const | 375 | QString Addressee::formattedName() const |
377 | { | 376 | { |
378 | return mData->formattedName; | 377 | return mData->formattedName; |
379 | } | 378 | } |
380 | 379 | ||
381 | QString Addressee::formattedNameLabel() | 380 | QString Addressee::formattedNameLabel() |
382 | { | 381 | { |
383 | return i18n("Formatted Name"); | 382 | return i18n("Formatted Name"); |
384 | } | 383 | } |
385 | 384 | ||
386 | 385 | ||
387 | void Addressee::setFamilyName( const QString &familyName ) | 386 | void Addressee::setFamilyName( const QString &familyName ) |
388 | { | 387 | { |
389 | if ( familyName == mData->familyName ) return; | 388 | if ( familyName == mData->familyName ) return; |
390 | detach(); | 389 | detach(); |
391 | mData->empty = false; | 390 | mData->empty = false; |
392 | mData->familyName = familyName; | 391 | mData->familyName = familyName; |
393 | } | 392 | } |
394 | 393 | ||
395 | QString Addressee::familyName() const | 394 | QString Addressee::familyName() const |
396 | { | 395 | { |
397 | return mData->familyName; | 396 | return mData->familyName; |
398 | } | 397 | } |
399 | 398 | ||
400 | QString Addressee::familyNameLabel() | 399 | QString Addressee::familyNameLabel() |
401 | { | 400 | { |
402 | return i18n("Family Name"); | 401 | return i18n("Family Name"); |
403 | } | 402 | } |
404 | 403 | ||
405 | 404 | ||
406 | void Addressee::setGivenName( const QString &givenName ) | 405 | void Addressee::setGivenName( const QString &givenName ) |
407 | { | 406 | { |
408 | if ( givenName == mData->givenName ) return; | 407 | if ( givenName == mData->givenName ) return; |
409 | detach(); | 408 | detach(); |
410 | mData->empty = false; | 409 | mData->empty = false; |
411 | mData->givenName = givenName; | 410 | mData->givenName = givenName; |
412 | } | 411 | } |
413 | 412 | ||
414 | QString Addressee::givenName() const | 413 | QString Addressee::givenName() const |
415 | { | 414 | { |
416 | return mData->givenName; | 415 | return mData->givenName; |
417 | } | 416 | } |
418 | 417 | ||
419 | QString Addressee::givenNameLabel() | 418 | QString Addressee::givenNameLabel() |
420 | { | 419 | { |
421 | return i18n("Given Name"); | 420 | return i18n("Given Name"); |
422 | } | 421 | } |
423 | 422 | ||
424 | 423 | ||
425 | void Addressee::setAdditionalName( const QString &additionalName ) | 424 | void Addressee::setAdditionalName( const QString &additionalName ) |
426 | { | 425 | { |
427 | if ( additionalName == mData->additionalName ) return; | 426 | if ( additionalName == mData->additionalName ) return; |
428 | detach(); | 427 | detach(); |
429 | mData->empty = false; | 428 | mData->empty = false; |
430 | mData->additionalName = additionalName; | 429 | mData->additionalName = additionalName; |
431 | } | 430 | } |
432 | 431 | ||
433 | QString Addressee::additionalName() const | 432 | QString Addressee::additionalName() const |
434 | { | 433 | { |
435 | return mData->additionalName; | 434 | return mData->additionalName; |
436 | } | 435 | } |
437 | 436 | ||
438 | QString Addressee::additionalNameLabel() | 437 | QString Addressee::additionalNameLabel() |
439 | { | 438 | { |
440 | return i18n("Additional Names"); | 439 | return i18n("Additional Names"); |
441 | } | 440 | } |
442 | 441 | ||
443 | 442 | ||
444 | void Addressee::setPrefix( const QString &prefix ) | 443 | void Addressee::setPrefix( const QString &prefix ) |
445 | { | 444 | { |
446 | if ( prefix == mData->prefix ) return; | 445 | if ( prefix == mData->prefix ) return; |
447 | detach(); | 446 | detach(); |
448 | mData->empty = false; | 447 | mData->empty = false; |
449 | mData->prefix = prefix; | 448 | mData->prefix = prefix; |
450 | } | 449 | } |
451 | 450 | ||
452 | QString Addressee::prefix() const | 451 | QString Addressee::prefix() const |
453 | { | 452 | { |
454 | return mData->prefix; | 453 | return mData->prefix; |
455 | } | 454 | } |
456 | 455 | ||
457 | QString Addressee::prefixLabel() | 456 | QString Addressee::prefixLabel() |
458 | { | 457 | { |
459 | return i18n("Honorific Prefixes"); | 458 | return i18n("Honorific Prefixes"); |
460 | } | 459 | } |
461 | 460 | ||
462 | 461 | ||
463 | void Addressee::setSuffix( const QString &suffix ) | 462 | void Addressee::setSuffix( const QString &suffix ) |
464 | { | 463 | { |
465 | if ( suffix == mData->suffix ) return; | 464 | if ( suffix == mData->suffix ) return; |
466 | detach(); | 465 | detach(); |
467 | mData->empty = false; | 466 | mData->empty = false; |
468 | mData->suffix = suffix; | 467 | mData->suffix = suffix; |
469 | } | 468 | } |
470 | 469 | ||
471 | QString Addressee::suffix() const | 470 | QString Addressee::suffix() const |
472 | { | 471 | { |
473 | return mData->suffix; | 472 | return mData->suffix; |
474 | } | 473 | } |
475 | 474 | ||
476 | QString Addressee::suffixLabel() | 475 | QString Addressee::suffixLabel() |
477 | { | 476 | { |
478 | return i18n("Honorific Suffixes"); | 477 | return i18n("Honorific Suffixes"); |
479 | } | 478 | } |
480 | 479 | ||
481 | 480 | ||
482 | void Addressee::setNickName( const QString &nickName ) | 481 | void Addressee::setNickName( const QString &nickName ) |
483 | { | 482 | { |
484 | if ( nickName == mData->nickName ) return; | 483 | if ( nickName == mData->nickName ) return; |
485 | detach(); | 484 | detach(); |
486 | mData->empty = false; | 485 | mData->empty = false; |
487 | mData->nickName = nickName; | 486 | mData->nickName = nickName; |
488 | } | 487 | } |
489 | 488 | ||
490 | QString Addressee::nickName() const | 489 | QString Addressee::nickName() const |
491 | { | 490 | { |
492 | return mData->nickName; | 491 | return mData->nickName; |
493 | } | 492 | } |
494 | 493 | ||
495 | QString Addressee::nickNameLabel() | 494 | QString Addressee::nickNameLabel() |
496 | { | 495 | { |
497 | return i18n("Nick Name"); | 496 | return i18n("Nick Name"); |
498 | } | 497 | } |
499 | 498 | ||
500 | 499 | ||
501 | void Addressee::setBirthday( const QDateTime &birthday ) | 500 | void Addressee::setBirthday( const QDateTime &birthday ) |
502 | { | 501 | { |
503 | if ( birthday == mData->birthday ) return; | 502 | if ( birthday == mData->birthday ) return; |
504 | detach(); | 503 | detach(); |
505 | mData->empty = false; | 504 | mData->empty = false; |
506 | mData->birthday = birthday; | 505 | mData->birthday = birthday; |
507 | } | 506 | } |
508 | 507 | ||
509 | QDateTime Addressee::birthday() const | 508 | QDateTime Addressee::birthday() const |
510 | { | 509 | { |
511 | return mData->birthday; | 510 | return mData->birthday; |
512 | } | 511 | } |
513 | 512 | ||
514 | QString Addressee::birthdayLabel() | 513 | QString Addressee::birthdayLabel() |
515 | { | 514 | { |
516 | return i18n("Birthday"); | 515 | return i18n("Birthday"); |
517 | } | 516 | } |
518 | 517 | ||
519 | 518 | ||
520 | QString Addressee::homeAddressStreetLabel() | 519 | QString Addressee::homeAddressStreetLabel() |
521 | { | 520 | { |
522 | return i18n("Home Address Street"); | 521 | return i18n("Home Address Street"); |
523 | } | 522 | } |
524 | 523 | ||
525 | 524 | ||
526 | QString Addressee::homeAddressLocalityLabel() | 525 | QString Addressee::homeAddressLocalityLabel() |
527 | { | 526 | { |
528 | return i18n("Home Address Locality"); | 527 | return i18n("Home Address Locality"); |
529 | } | 528 | } |
530 | 529 | ||
531 | 530 | ||
532 | QString Addressee::homeAddressRegionLabel() | 531 | QString Addressee::homeAddressRegionLabel() |
533 | { | 532 | { |
534 | return i18n("Home Address Region"); | 533 | return i18n("Home Address Region"); |
535 | } | 534 | } |
536 | 535 | ||
537 | 536 | ||
538 | QString Addressee::homeAddressPostalCodeLabel() | 537 | QString Addressee::homeAddressPostalCodeLabel() |
539 | { | 538 | { |
540 | return i18n("Home Address Postal Code"); | 539 | return i18n("Home Address Postal Code"); |
541 | } | 540 | } |
542 | 541 | ||
543 | 542 | ||
544 | QString Addressee::homeAddressCountryLabel() | 543 | QString Addressee::homeAddressCountryLabel() |
545 | { | 544 | { |
546 | return i18n("Home Address Country"); | 545 | return i18n("Home Address Country"); |
547 | } | 546 | } |
548 | 547 | ||
549 | 548 | ||
550 | QString Addressee::homeAddressLabelLabel() | 549 | QString Addressee::homeAddressLabelLabel() |
551 | { | 550 | { |
552 | return i18n("Home Address Label"); | 551 | return i18n("Home Address Label"); |
553 | } | 552 | } |
554 | 553 | ||
555 | 554 | ||
556 | QString Addressee::businessAddressStreetLabel() | 555 | QString Addressee::businessAddressStreetLabel() |
557 | { | 556 | { |
558 | return i18n("Business Address Street"); | 557 | return i18n("Business Address Street"); |
559 | } | 558 | } |
560 | 559 | ||
561 | 560 | ||
562 | QString Addressee::businessAddressLocalityLabel() | 561 | QString Addressee::businessAddressLocalityLabel() |
563 | { | 562 | { |
564 | return i18n("Business Address Locality"); | 563 | return i18n("Business Address Locality"); |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 56f6af2..fa0c51f 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2299,724 +2299,724 @@ void KABCore::multiSync( bool askforPrefs ) | |||
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 | } |
2312 | int KABCore::ringSync() | 2312 | int 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 | ||
2370 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) | 2370 | void 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> |
2442 | void KABCore::edit_sync_options() | 2442 | void 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 | } |
2494 | QString KABCore::getPassword( ) | 2494 | QString 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 | ||
2520 | KABC::Addressee KABCore::getLastSyncAddressee() | 2520 | KABC::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 | } |
2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2539 | { | 2539 | { |
2540 | 2540 | ||
2541 | //void setZaurusId(int id); | 2541 | //void setZaurusId(int id); |
2542 | // int zaurusId() const; | 2542 | // int zaurusId() const; |
2543 | // void setZaurusUid(int id); | 2543 | // void setZaurusUid(int id); |
2544 | // int zaurusUid() const; | 2544 | // int zaurusUid() const; |
2545 | // void setZaurusStat(int id); | 2545 | // void setZaurusStat(int id); |
2546 | // int zaurusStat() const; | 2546 | // int zaurusStat() const; |
2547 | // 0 equal | 2547 | // 0 equal |
2548 | // 1 take local | 2548 | // 1 take local |
2549 | // 2 take remote | 2549 | // 2 take remote |
2550 | // 3 cancel | 2550 | // 3 cancel |
2551 | QDateTime lastSync = mLastAddressbookSync; | 2551 | QDateTime lastSync = mLastAddressbookSync; |
2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2553 | bool remCh, locCh; | 2553 | bool remCh, locCh; |
2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2555 | if ( remCh ) | 2555 | |
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 | } |
2658 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2658 | bool 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; |
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 | } | 2771 | } |
2772 | else | 2772 | else |
2773 | idS = inR.IDStr(); | 2773 | idS = inR.IDStr(); |
2774 | remote->removeAddressee( inR ); | 2774 | remote->removeAddressee( inR ); |
2775 | inR = inL; | 2775 | inR = inL; |
2776 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2776 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2777 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 2777 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
2778 | inR.setIDStr( idS ); | 2778 | inR.setIDStr( idS ); |
2779 | inR.setResource( 0 ); | 2779 | inR.setResource( 0 ); |
2780 | remote->insertAddressee( inR , false); | 2780 | remote->insertAddressee( inR , false); |
2781 | ++changedRemote; | 2781 | ++changedRemote; |
2782 | } else { | 2782 | } else { |
2783 | idS = inL.IDStr(); | 2783 | idS = inL.IDStr(); |
2784 | local->removeAddressee( inL ); | 2784 | local->removeAddressee( inL ); |
2785 | inL = inR; | 2785 | inL = inR; |
2786 | inL.setIDStr( idS ); | 2786 | inL.setIDStr( idS ); |
2787 | inL.setResource( 0 ); | 2787 | inL.setResource( 0 ); |
2788 | local->insertAddressee( inL , false ); | 2788 | local->insertAddressee( inL , false ); |
2789 | ++changedLocal; | 2789 | ++changedLocal; |
2790 | } | 2790 | } |
2791 | } | 2791 | } |
2792 | } else { // no conflict | 2792 | } else { // no conflict |
2793 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2793 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2794 | QString des = addresseeLSync.note(); | 2794 | QString des = addresseeLSync.note(); |
2795 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2795 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2796 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2796 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2797 | remote->insertAddressee( inR, false ); | 2797 | remote->insertAddressee( inR, false ); |
2798 | ++deletedAddresseeR; | 2798 | ++deletedAddresseeR; |
2799 | } else { | 2799 | } else { |
2800 | inR.setRevision( modifiedCalendar ); | 2800 | inR.setRevision( modifiedCalendar ); |
2801 | remote->insertAddressee( inR, false ); | 2801 | remote->insertAddressee( inR, false ); |
2802 | inL = inR; | 2802 | inL = inR; |
2803 | inL.setResource( 0 ); | 2803 | inL.setResource( 0 ); |
2804 | local->insertAddressee( inL , false); | 2804 | local->insertAddressee( inL , false); |
2805 | ++addedAddressee; | 2805 | ++addedAddressee; |
2806 | } | 2806 | } |
2807 | } else { | 2807 | } else { |
2808 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2808 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2809 | inR.setRevision( modifiedCalendar ); | 2809 | inR.setRevision( modifiedCalendar ); |
2810 | remote->insertAddressee( inR, false ); | 2810 | remote->insertAddressee( inR, false ); |
2811 | inR.setResource( 0 ); | 2811 | inR.setResource( 0 ); |
2812 | local->insertAddressee( inR, false ); | 2812 | local->insertAddressee( inR, false ); |
2813 | ++addedAddressee; | 2813 | ++addedAddressee; |
2814 | } else { | 2814 | } else { |
2815 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2815 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2816 | remote->removeAddressee( inR ); | 2816 | remote->removeAddressee( inR ); |
2817 | ++deletedAddresseeR; | 2817 | ++deletedAddresseeR; |
2818 | } | 2818 | } |
2819 | } | 2819 | } |
2820 | } | 2820 | } |
2821 | } | 2821 | } |
2822 | ++incCounter; | 2822 | ++incCounter; |
2823 | } | 2823 | } |
2824 | er.clear(); | 2824 | er.clear(); |
2825 | QStringList el = local->uidList(); | 2825 | QStringList el = local->uidList(); |
2826 | modulo = (el.count()/10)+1; | 2826 | modulo = (el.count()/10)+1; |
2827 | bar.setCaption (i18n("Add / remove addressees") ); | 2827 | bar.setCaption (i18n("Add / remove addressees") ); |
2828 | bar.setTotalSteps ( el.count() ) ; | 2828 | bar.setTotalSteps ( el.count() ) ; |
2829 | bar.show(); | 2829 | bar.show(); |
2830 | incCounter = 0; | 2830 | incCounter = 0; |
2831 | while ( incCounter < el.count()) { | 2831 | while ( incCounter < el.count()) { |
2832 | qApp->processEvents(); | 2832 | qApp->processEvents(); |
2833 | if ( ! bar.isVisible() ) | 2833 | if ( ! bar.isVisible() ) |
2834 | return false; | 2834 | return false; |
2835 | if ( incCounter % modulo == 0 ) | 2835 | if ( incCounter % modulo == 0 ) |
2836 | bar.setProgress( incCounter ); | 2836 | bar.setProgress( incCounter ); |
2837 | uid = el[ incCounter ]; | 2837 | uid = el[ incCounter ]; |
2838 | bool skipIncidence = false; | 2838 | bool skipIncidence = false; |
2839 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2839 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2840 | skipIncidence = true; | 2840 | skipIncidence = true; |
2841 | if ( !skipIncidence ) { | 2841 | if ( !skipIncidence ) { |
2842 | inL = local->findByUid( uid ); | 2842 | inL = local->findByUid( uid ); |
2843 | inR = remote->findByUid( uid ); | 2843 | inR = remote->findByUid( uid ); |
2844 | if ( inR.isEmpty() ) { | 2844 | if ( inR.isEmpty() ) { |
2845 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2845 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2846 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2846 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2847 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2847 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2848 | local->removeAddressee( inL ); | 2848 | local->removeAddressee( inL ); |
2849 | ++deletedAddresseeL; | 2849 | ++deletedAddresseeL; |
2850 | } else { | 2850 | } else { |
2851 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2851 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2852 | inL.removeID(mCurrentSyncDevice ); | 2852 | inL.removeID(mCurrentSyncDevice ); |
2853 | ++addedAddresseeR; | 2853 | ++addedAddresseeR; |
2854 | inL.setRevision( modifiedCalendar ); | 2854 | inL.setRevision( modifiedCalendar ); |
2855 | local->insertAddressee( inL, false ); | 2855 | local->insertAddressee( inL, false ); |
2856 | inR = inL; | 2856 | inR = inL; |
2857 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2857 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2858 | inR.setResource( 0 ); | 2858 | inR.setResource( 0 ); |
2859 | remote->insertAddressee( inR, false ); | 2859 | remote->insertAddressee( inR, false ); |
2860 | } | 2860 | } |
2861 | } | 2861 | } |
2862 | } else { | 2862 | } else { |
2863 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2863 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2864 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2864 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2865 | local->removeAddressee( inL ); | 2865 | local->removeAddressee( inL ); |
2866 | ++deletedAddresseeL; | 2866 | ++deletedAddresseeL; |
2867 | } else { | 2867 | } else { |
2868 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2868 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2869 | ++addedAddresseeR; | 2869 | ++addedAddresseeR; |
2870 | inL.setRevision( modifiedCalendar ); | 2870 | inL.setRevision( modifiedCalendar ); |
2871 | local->insertAddressee( inL, false ); | 2871 | local->insertAddressee( inL, false ); |
2872 | inR = inL; | 2872 | inR = inL; |
2873 | inR.setResource( 0 ); | 2873 | inR.setResource( 0 ); |
2874 | remote->insertAddressee( inR, false ); | 2874 | remote->insertAddressee( inR, false ); |
2875 | } | 2875 | } |
2876 | } | 2876 | } |
2877 | } | 2877 | } |
2878 | } | 2878 | } |
2879 | } | 2879 | } |
2880 | ++incCounter; | 2880 | ++incCounter; |
2881 | } | 2881 | } |
2882 | el.clear(); | 2882 | el.clear(); |
2883 | bar.hide(); | 2883 | bar.hide(); |
2884 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2884 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2885 | // get rid of micro seconds | 2885 | // get rid of micro seconds |
2886 | QTime t = mLastAddressbookSync.time(); | 2886 | QTime t = mLastAddressbookSync.time(); |
2887 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2887 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2888 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2888 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2889 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2889 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2890 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2890 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2891 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2891 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2892 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2892 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2893 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2893 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2894 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2894 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2895 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2895 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2896 | addresseeRSync.setNote( "" ) ; | 2896 | addresseeRSync.setNote( "" ) ; |
2897 | addresseeLSync.setNote( "" ); | 2897 | addresseeLSync.setNote( "" ); |
2898 | 2898 | ||
2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2900 | remote->insertAddressee( addresseeRSync, false ); | 2900 | remote->insertAddressee( addresseeRSync, false ); |
2901 | local->insertAddressee( addresseeLSync, false ); | 2901 | local->insertAddressee( addresseeLSync, false ); |
2902 | QString mes; | 2902 | 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 ); | 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 ); |
2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { | 2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { |
2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2906 | } | 2906 | } |
2907 | qDebug( mes ); | 2907 | qDebug( mes ); |
2908 | return syncOK; | 2908 | return syncOK; |
2909 | } | 2909 | } |
2910 | 2910 | ||
2911 | bool KABCore::syncAB(QString filename, int mode) | 2911 | bool KABCore::syncAB(QString filename, int mode) |
2912 | { | 2912 | { |
2913 | 2913 | ||
2914 | //pending prepare addresseeview for output | 2914 | //pending prepare addresseeview for output |
2915 | //pending detect, if remote file has REV field. if not switch to external sync | 2915 | //pending detect, if remote file has REV field. if not switch to external sync |
2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2917 | AddressBook abLocal(filename,"syncContact"); | 2917 | AddressBook abLocal(filename,"syncContact"); |
2918 | bool syncOK = false; | 2918 | bool syncOK = false; |
2919 | if ( abLocal.load() ) { | 2919 | if ( abLocal.load() ) { |
2920 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); | 2920 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2921 | bool external = false; | 2921 | bool external = false; |
2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2923 | if ( ! lse.isEmpty() ) { | 2923 | if ( ! lse.isEmpty() ) { |
2924 | if ( lse.familyName().left(4) == "!E: " ) | 2924 | if ( lse.familyName().left(4) == "!E: " ) |
2925 | external = true; | 2925 | external = true; |
2926 | } else { | 2926 | } else { |
2927 | bool found = false; | 2927 | bool found = false; |
2928 | QDateTime dt( QDate( 2004,1,1)); | 2928 | QDateTime dt( QDate( 2004,1,1)); |
2929 | AddressBook::Iterator it; | 2929 | AddressBook::Iterator it; |
2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2931 | if ( (*it).revision() != dt ) { | 2931 | if ( (*it).revision() != dt ) { |
2932 | found = true; | 2932 | found = true; |
2933 | break; | 2933 | break; |
2934 | } | 2934 | } |
2935 | } | 2935 | } |
2936 | external = ! found; | 2936 | external = ! found; |
2937 | } | 2937 | } |
2938 | 2938 | ||
2939 | if ( external ) { | 2939 | if ( external ) { |
2940 | qDebug("**********Setting vcf mode to external "); | 2940 | qDebug("Setting vcf mode to external "); |
2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2942 | AddressBook::Iterator it; | 2942 | AddressBook::Iterator it; |
2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2945 | (*it).computeCsum( mCurrentSyncDevice ); | 2945 | (*it).computeCsum( mCurrentSyncDevice ); |
2946 | } | 2946 | } |
2947 | } | 2947 | } |
2948 | //AddressBook::Iterator it; | 2948 | //AddressBook::Iterator it; |
2949 | //QStringList vcards; | 2949 | //QStringList vcards; |
2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2951 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2951 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2952 | //} | 2952 | //} |
2953 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2953 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2954 | if ( syncOK ) { | 2954 | if ( syncOK ) { |
2955 | if ( KABPrefs::instance()->mWriteBackFile ) | 2955 | if ( KABPrefs::instance()->mWriteBackFile ) |
2956 | { | 2956 | { |
2957 | if ( external ) | 2957 | if ( external ) |
2958 | abLocal.removeDeletedAddressees(); | 2958 | abLocal.removeDeletedAddressees(); |
2959 | qDebug("saving remote AB "); | 2959 | qDebug("Saving remote AB "); |
2960 | abLocal.saveAB(); | 2960 | abLocal.saveAB(); |
2961 | } | 2961 | } |
2962 | } | 2962 | } |
2963 | setModified(); | 2963 | setModified(); |
2964 | 2964 | ||
2965 | } | 2965 | } |
2966 | if ( syncOK ) | 2966 | if ( syncOK ) |
2967 | mViewManager->refreshView(); | 2967 | mViewManager->refreshView(); |
2968 | return syncOK; | 2968 | return syncOK; |
2969 | #if 0 | 2969 | #if 0 |
2970 | 2970 | ||
2971 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2971 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2972 | getEventViewerDialog()->setSyncMode( true ); | 2972 | getEventViewerDialog()->setSyncMode( true ); |
2973 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2973 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2974 | getEventViewerDialog()->setSyncMode( false ); | 2974 | getEventViewerDialog()->setSyncMode( false ); |
2975 | if ( syncOK ) { | 2975 | if ( syncOK ) { |
2976 | if ( KOPrefs::instance()->mWriteBackFile ) | 2976 | if ( KOPrefs::instance()->mWriteBackFile ) |
2977 | { | 2977 | { |
2978 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2978 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2979 | storage->save(); | 2979 | storage->save(); |
2980 | } | 2980 | } |
2981 | } | 2981 | } |
2982 | setModified(); | 2982 | setModified(); |
2983 | } | 2983 | } |
2984 | 2984 | ||
2985 | #endif | 2985 | #endif |
2986 | } | 2986 | } |
2987 | 2987 | ||
2988 | void KABCore::confSync() | 2988 | void KABCore::confSync() |
2989 | { | 2989 | { |
2990 | static KSyncPrefsDialog* sp = 0; | 2990 | static KSyncPrefsDialog* sp = 0; |
2991 | if ( ! sp ) { | 2991 | if ( ! sp ) { |
2992 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 2992 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
2993 | } | 2993 | } |
2994 | sp->usrReadConfig(); | 2994 | sp->usrReadConfig(); |
2995 | #ifndef DESKTOP_VERSION | 2995 | #ifndef DESKTOP_VERSION |
2996 | sp->showMaximized(); | 2996 | sp->showMaximized(); |
2997 | #else | 2997 | #else |
2998 | sp->show(); | 2998 | sp->show(); |
2999 | #endif | 2999 | #endif |
3000 | sp->exec(); | 3000 | sp->exec(); |
3001 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 3001 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
3002 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 3002 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
3003 | fillSyncMenu(); | 3003 | fillSyncMenu(); |
3004 | } | 3004 | } |
3005 | void KABCore::syncSharp() | 3005 | void KABCore::syncSharp() |
3006 | { | 3006 | { |
3007 | if ( mModified ) | 3007 | if ( mModified ) |
3008 | save(); | 3008 | save(); |
3009 | qDebug("pending syncSharp() "); | 3009 | qDebug("pending syncSharp() "); |
3010 | //mView->syncSharp(); | 3010 | //mView->syncSharp(); |
3011 | setModified(); | 3011 | setModified(); |
3012 | 3012 | ||
3013 | } | 3013 | } |
3014 | void KABCore::syncPhone() | 3014 | void KABCore::syncPhone() |
3015 | { | 3015 | { |
3016 | if ( mModified ) | 3016 | if ( mModified ) |
3017 | save(); | 3017 | save(); |
3018 | qDebug("pending syncPhone(); "); | 3018 | qDebug("pending syncPhone(); "); |
3019 | //mView->syncPhone(); | 3019 | //mView->syncPhone(); |
3020 | setModified(); | 3020 | setModified(); |
3021 | 3021 | ||
3022 | } | 3022 | } |