-rw-r--r-- | kabc/addressee.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index d5a110a..3d4992c 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -188,106 +188,116 @@ ulong Addressee::getCsum4List( const QStringList & attList) | |||
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | l.append( t[iii] ); | 259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
260 | int find = t[iii].find (':')+1; | ||
261 | //qDebug("lennnn %d %d ", find, t[iii].length()); | ||
262 | if ( find < t[iii].length()) | ||
263 | l.append( t[iii] ); | ||
264 | |||
265 | } | ||
260 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
262 | ++addressIter ) { | 268 | ++addressIter ) { |
263 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
264 | t.sort(); | 270 | t.sort(); |
265 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
266 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
267 | } | 273 | } |
268 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
269 | //qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 275 | #if 1 |
276 | for ( iii = 0; iii < l.count(); ++iii) | ||
277 | qDebug("%d***%s***",iii,l[iii].latin1()); | ||
278 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | ||
279 | #endif | ||
270 | setCsum( dev, QString::number (cs )); | 280 | setCsum( dev, QString::number (cs )); |
271 | } | 281 | } |
272 | 282 | ||
273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 283 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
274 | { | 284 | { |
275 | 285 | ||
276 | detach(); | 286 | detach(); |
277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 287 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 288 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 289 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 290 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 291 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 292 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 293 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 294 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
285 | if ( !mData->birthday.isValid() ) | 295 | if ( !mData->birthday.isValid() ) |
286 | if ( ad.mData->birthday.isValid()) | 296 | if ( ad.mData->birthday.isValid()) |
287 | mData->birthday = ad.mData->birthday; | 297 | mData->birthday = ad.mData->birthday; |
288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 298 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 299 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 300 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 301 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 302 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 303 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
@@ -1090,49 +1100,52 @@ QString Addressee::noteLabel() | |||
1090 | void Addressee::setProductId( const QString &productId ) | 1100 | void Addressee::setProductId( const QString &productId ) |
1091 | { | 1101 | { |
1092 | if ( productId == mData->productId ) return; | 1102 | if ( productId == mData->productId ) return; |
1093 | detach(); | 1103 | detach(); |
1094 | mData->empty = false; | 1104 | mData->empty = false; |
1095 | mData->productId = productId; | 1105 | mData->productId = productId; |
1096 | } | 1106 | } |
1097 | 1107 | ||
1098 | QString Addressee::productId() const | 1108 | QString Addressee::productId() const |
1099 | { | 1109 | { |
1100 | return mData->productId; | 1110 | return mData->productId; |
1101 | } | 1111 | } |
1102 | 1112 | ||
1103 | QString Addressee::productIdLabel() | 1113 | QString Addressee::productIdLabel() |
1104 | { | 1114 | { |
1105 | return i18n("Product Identifier"); | 1115 | return i18n("Product Identifier"); |
1106 | } | 1116 | } |
1107 | 1117 | ||
1108 | 1118 | ||
1109 | void Addressee::setRevision( const QDateTime &revision ) | 1119 | void Addressee::setRevision( const QDateTime &revision ) |
1110 | { | 1120 | { |
1111 | if ( revision == mData->revision ) return; | 1121 | if ( revision == mData->revision ) return; |
1112 | detach(); | 1122 | detach(); |
1113 | mData->empty = false; | 1123 | mData->empty = false; |
1114 | mData->revision = revision; | 1124 | mData->revision = QDateTime( revision.date(), |
1125 | QTime (revision.time().hour(), | ||
1126 | revision.time().minute(), | ||
1127 | revision.time().second())); | ||
1115 | } | 1128 | } |
1116 | 1129 | ||
1117 | QDateTime Addressee::revision() const | 1130 | QDateTime Addressee::revision() const |
1118 | { | 1131 | { |
1119 | return mData->revision; | 1132 | return mData->revision; |
1120 | } | 1133 | } |
1121 | 1134 | ||
1122 | QString Addressee::revisionLabel() | 1135 | QString Addressee::revisionLabel() |
1123 | { | 1136 | { |
1124 | return i18n("Revision Date"); | 1137 | return i18n("Revision Date"); |
1125 | } | 1138 | } |
1126 | 1139 | ||
1127 | 1140 | ||
1128 | void Addressee::setSortString( const QString &sortString ) | 1141 | void Addressee::setSortString( const QString &sortString ) |
1129 | { | 1142 | { |
1130 | if ( sortString == mData->sortString ) return; | 1143 | if ( sortString == mData->sortString ) return; |
1131 | detach(); | 1144 | detach(); |
1132 | mData->empty = false; | 1145 | mData->empty = false; |
1133 | mData->sortString = sortString; | 1146 | mData->sortString = sortString; |
1134 | } | 1147 | } |
1135 | 1148 | ||
1136 | QString Addressee::sortString() const | 1149 | QString Addressee::sortString() const |
1137 | { | 1150 | { |
1138 | return mData->sortString; | 1151 | return mData->sortString; |