-rw-r--r-- | kabc/addressee.cpp | 82 |
1 files changed, 58 insertions, 24 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 2aca559..295ee4f 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,866 +1,900 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
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 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
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 ) 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 | l.append( t[iii] ); |
260 | KABC::Address::List::Iterator addressIter; | 260 | KABC::Address::List::Iterator addressIter; |
261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
262 | ++addressIter ) { | 262 | ++addressIter ) { |
263 | t = (*addressIter).asList(); | 263 | t = (*addressIter).asList(); |
264 | t.sort(); | 264 | t.sort(); |
265 | for ( iii = 0; iii < t.count(); ++iii) | 265 | for ( iii = 0; iii < t.count(); ++iii) |
266 | l.append( t[iii] ); | 266 | l.append( t[iii] ); |
267 | } | 267 | } |
268 | uint cs = getCsum4List(l); | 268 | uint cs = getCsum4List(l); |
269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
270 | setCsum( dev, QString::number (cs )); | 270 | setCsum( dev, QString::number (cs )); |
271 | } | 271 | } |
272 | 272 | ||
273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
274 | { | 274 | { |
275 | 275 | ||
276 | detach(); | 276 | detach(); |
277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
285 | if ( !mData->birthday.isValid() ) | 285 | if ( !mData->birthday.isValid() ) |
286 | if ( ad.mData->birthday.isValid()) | 286 | if ( ad.mData->birthday.isValid()) |
287 | mData->birthday = ad.mData->birthday; | 287 | mData->birthday = ad.mData->birthday; |
288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
299 | QStringList t; | 299 | QStringList t; |
300 | QStringList tAD; | 300 | QStringList tAD; |
301 | uint iii; | 301 | uint iii; |
302 | if ( isSubSet ) { | 302 | |
303 | // ********** phone numbers | 303 | // ********** phone numbers |
304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
305 | PhoneNumber::List::Iterator phoneItAD; | 305 | PhoneNumber::List::Iterator phoneItAD; |
306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
307 | bool found = false; | 307 | bool found = false; |
308 | PhoneNumber::List::Iterator it; | 308 | PhoneNumber::List::Iterator it; |
309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
310 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 310 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
311 | found = true; | 311 | found = true; |
312 | (*it).setType( ( *phoneItAD ).type() ); | 312 | (*it).setType( ( *phoneItAD ).type() ); |
313 | break; | 313 | break; |
314 | } | ||
315 | } | 314 | } |
316 | if ( ! found ) | ||
317 | mData->phoneNumbers.append( *phoneItAD ); | ||
318 | } | 315 | } |
316 | if ( isSubSet && ! found ) | ||
317 | mData->phoneNumbers.append( *phoneItAD ); | ||
318 | } | ||
319 | if ( isSubSet ) { | ||
319 | // ************* emails; | 320 | // ************* emails; |
320 | t = mData->emails; | 321 | t = mData->emails; |
321 | tAD = ad.mData->emails; | 322 | tAD = ad.mData->emails; |
322 | for ( iii = 0; iii < tAD.count(); ++iii) | 323 | for ( iii = 0; iii < tAD.count(); ++iii) |
323 | if ( !t.contains(tAD[iii] ) ) | 324 | if ( !t.contains(tAD[iii] ) ) |
324 | mData->emails.append( tAD[iii] ); | 325 | mData->emails.append( tAD[iii] ); |
325 | // ************* categories; | ||
326 | t = mData->categories; | ||
327 | tAD = ad.mData->categories; | ||
328 | for ( iii = 0; iii < tAD.count(); ++iii) | ||
329 | if ( !t.contains(tAD[iii] ) ) | ||
330 | mData->categories.append( tAD[iii] ); | ||
331 | |||
332 | |||
333 | } | 326 | } |
334 | 327 | ||
328 | // ************* categories; | ||
329 | t = mData->categories; | ||
330 | tAD = ad.mData->categories; | ||
331 | for ( iii = 0; iii < tAD.count(); ++iii) | ||
332 | if ( !t.contains(tAD[iii] ) ) | ||
333 | mData->categories.append( tAD[iii] ); | ||
335 | QStringList::ConstIterator it; | 334 | QStringList::ConstIterator it; |
336 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 335 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
337 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 336 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
338 | bool found = false; | 337 | bool found = false; |
339 | QStringList::ConstIterator itL; | 338 | QStringList::ConstIterator itL; |
340 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 339 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
341 | if ( (*itL).startsWith( qualifiedName ) ) { | 340 | if ( (*itL).startsWith( qualifiedName ) ) { |
342 | found = true; | 341 | found = true; |
343 | break; | 342 | break; |
344 | } | 343 | } |
345 | } | 344 | } |
346 | if ( ! found ) { | 345 | if ( ! found ) { |
347 | mData->custom.append( *it ); | 346 | mData->custom.append( *it ); |
348 | } | 347 | } |
349 | } | 348 | } |
350 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 349 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
351 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 350 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
352 | if ( !mData->sound.isIntern() ) { | 351 | if ( !mData->sound.isIntern() ) { |
353 | if ( mData->sound.url().isEmpty() ) { | 352 | if ( mData->sound.url().isEmpty() ) { |
354 | mData->sound = ad.mData->sound; | 353 | mData->sound = ad.mData->sound; |
355 | } | 354 | } |
356 | } | 355 | } |
357 | if ( !mData->agent.isIntern() ) { | 356 | if ( !mData->agent.isIntern() ) { |
358 | if ( mData->agent.url().isEmpty() ) { | 357 | if ( mData->agent.url().isEmpty() ) { |
359 | mData->agent = ad.mData->agent; | 358 | mData->agent = ad.mData->agent; |
360 | } | 359 | } |
361 | } | 360 | } |
362 | { | 361 | { |
363 | Key::List::Iterator itA; | 362 | Key::List::Iterator itA; |
364 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 363 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
365 | bool found = false; | 364 | bool found = false; |
366 | Key::List::Iterator it; | 365 | Key::List::Iterator it; |
367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 366 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
368 | if ( (*it) == (*itA)) { | 367 | if ( (*it) == (*itA)) { |
369 | found = true; | 368 | found = true; |
370 | break; | 369 | break; |
371 | 370 | ||
372 | } | 371 | } |
373 | } | 372 | } |
374 | if ( ! found ) { | 373 | if ( ! found ) { |
375 | mData->keys.append( *itA ); | 374 | mData->keys.append( *itA ); |
376 | } | 375 | } |
377 | } | 376 | } |
378 | } | 377 | } |
379 | KABC::Address::List::Iterator addressIterA; | 378 | KABC::Address::List::Iterator addressIterA; |
380 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 379 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
381 | bool found = false; | 380 | bool found = false; |
382 | KABC::Address::List::Iterator addressIter; | 381 | KABC::Address::List::Iterator addressIter; |
383 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 382 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
384 | ++addressIter ) { | 383 | ++addressIter ) { |
385 | if ( (*addressIter) == (*addressIterA)) { | 384 | if ( (*addressIter) == (*addressIterA)) { |
386 | found = true; | 385 | found = true; |
387 | (*addressIter).setType( (*addressIterA).type() ); | 386 | (*addressIter).setType( (*addressIterA).type() ); |
388 | break; | 387 | break; |
389 | } | 388 | } |
390 | 389 | ||
391 | } | 390 | } |
392 | if ( ! found ) { | 391 | if ( isSubSet && ! found ) { |
393 | mData->addresses.append( *addressIterA ); | 392 | mData->addresses.append( *addressIterA ); |
394 | } | 393 | } |
395 | } | 394 | } |
396 | //qDebug("merge contact %s ", ad.uid().latin1()); | 395 | //qDebug("merge contact %s ", ad.uid().latin1()); |
397 | setUid( ad.uid() ); | 396 | setUid( ad.uid() ); |
398 | setRevision( ad.revision() ); | 397 | setRevision( ad.revision() ); |
399 | } | 398 | } |
400 | 399 | ||
401 | bool Addressee::removeVoice() | 400 | bool Addressee::removeVoice() |
402 | { | 401 | { |
403 | PhoneNumber::List phoneN = phoneNumbers(); | 402 | PhoneNumber::List phoneN = phoneNumbers(); |
404 | PhoneNumber::List::Iterator phoneIt; | 403 | PhoneNumber::List::Iterator phoneIt; |
405 | bool found = false; | 404 | bool found = false; |
406 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 405 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
407 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 406 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
408 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 407 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
409 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 408 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
410 | insertPhoneNumber( (*phoneIt) ); | 409 | insertPhoneNumber( (*phoneIt) ); |
411 | found = true; | 410 | found = true; |
412 | } | 411 | } |
413 | } | 412 | } |
414 | 413 | ||
415 | } | 414 | } |
416 | return found; | 415 | return found; |
417 | } | 416 | } |
418 | 417 | ||
419 | bool Addressee::containsAdr(const Addressee& ad ) | 418 | bool Addressee::containsAdr(const Addressee& ad ) |
420 | { | 419 | { |
421 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 420 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
422 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 421 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
423 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 422 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
424 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 423 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
425 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 424 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
426 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 425 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
427 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 426 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
428 | 427 | ||
429 | // compare phone numbers | 428 | // compare phone numbers |
430 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 429 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
431 | PhoneNumber::List::Iterator phoneIt; | 430 | PhoneNumber::List::Iterator phoneIt; |
432 | bool found = false; | 431 | bool found = false; |
433 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 432 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
434 | bool found = false; | 433 | bool found = false; |
435 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 434 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
436 | PhoneNumber::List::Iterator phoneItL; | 435 | PhoneNumber::List::Iterator phoneItL; |
437 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 436 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
438 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 437 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
439 | found = true; | 438 | found = true; |
440 | break; | 439 | break; |
441 | } | 440 | } |
442 | } | 441 | } |
443 | if ( ! found ) | 442 | if ( ! found ) |
444 | return false; | 443 | return false; |
445 | } | 444 | } |
446 | return true; | 445 | return true; |
447 | 446 | ||
448 | } | 447 | } |
449 | void Addressee::simplifyAddresses() | 448 | void Addressee::simplifyAddresses() |
450 | { | 449 | { |
451 | int max = 2; | 450 | int max = 2; |
452 | if ( mData->url.isValid() ) | 451 | if ( mData->url.isValid() ) |
453 | max = 1; | 452 | max = 1; |
454 | if ( mData->addresses.count() <= max ) return ; | 453 | if ( mData->addresses.count() <= max ) return ; |
455 | int count = 0; | 454 | int count = 0; |
456 | Address::List list; | 455 | Address::List list; |
457 | Address::List::Iterator it; | 456 | Address::List::Iterator it; |
458 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 457 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
459 | if ( count >= max ) | 458 | if ( count >= max ) |
460 | list.append( *it ); | 459 | list.append( *it ); |
461 | ++count; | 460 | ++count; |
462 | } | 461 | } |
463 | for( it = list.begin(); it != list.end(); ++it ) { | 462 | for( it = list.begin(); it != list.end(); ++it ) { |
464 | removeAddress( (*it) ); | 463 | removeAddress( (*it) ); |
465 | } | 464 | } |
466 | } | 465 | } |
467 | 466 | ||
468 | // removes all emails but the first | 467 | // removes all emails but the first |
469 | // needed by phone sync | 468 | // needed by phone sync |
470 | void Addressee::simplifyEmails() | 469 | void Addressee::simplifyEmails() |
471 | { | 470 | { |
472 | if ( mData->emails.count() == 0 ) return ; | 471 | if ( mData->emails.count() == 0 ) return ; |
473 | QString email = mData->emails.first(); | 472 | QString email = mData->emails.first(); |
474 | detach(); | 473 | detach(); |
475 | mData->emails.clear(); | 474 | mData->emails.clear(); |
476 | mData->emails.append( email ); | 475 | mData->emails.append( email ); |
477 | } | 476 | } |
478 | 477 | ||
479 | void Addressee::simplifyPhoneNumbers() | 478 | void Addressee::simplifyPhoneNumbers() |
480 | { | 479 | { |
480 | int max = 4; | ||
481 | int inList = mData->phoneNumbers.count(); | ||
481 | KABC::PhoneNumber::List removeNumbers; | 482 | KABC::PhoneNumber::List removeNumbers; |
482 | KABC::PhoneNumber::List::Iterator phoneIter; | 483 | KABC::PhoneNumber::List::Iterator phoneIter; |
484 | if ( inList > max ) { | ||
485 | // delete non-preferred numbers | ||
486 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
487 | ++phoneIter ) { | ||
488 | if ( inList > max ) { | ||
489 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | ||
490 | removeNumbers.append( ( *phoneIter ) ); | ||
491 | --inList; | ||
492 | } | ||
493 | } else | ||
494 | break; | ||
495 | } | ||
496 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | ||
497 | ++phoneIter ) { | ||
498 | removePhoneNumber(( *phoneIter )); | ||
499 | } | ||
500 | // delete preferred numbers | ||
501 | if ( inList > max ) { | ||
502 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | ||
503 | ++phoneIter ) { | ||
504 | if ( inList > max ) { | ||
505 | removeNumbers.append( ( *phoneIter ) ); | ||
506 | --inList; | ||
507 | } else | ||
508 | break; | ||
509 | } | ||
510 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | ||
511 | ++phoneIter ) { | ||
512 | removePhoneNumber(( *phoneIter )); | ||
513 | } | ||
514 | } | ||
515 | } | ||
516 | // remove non-numeric characters | ||
483 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 517 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
484 | ++phoneIter ) { | 518 | ++phoneIter ) { |
485 | if ( ! ( *phoneIter ).simplifyNumber() ) | 519 | if ( ! ( *phoneIter ).simplifyNumber() ) |
486 | removeNumbers.append( ( *phoneIter ) ); | 520 | removeNumbers.append( ( *phoneIter ) ); |
487 | } | 521 | } |
488 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 522 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
489 | ++phoneIter ) { | 523 | ++phoneIter ) { |
490 | removePhoneNumber(( *phoneIter )); | 524 | removePhoneNumber(( *phoneIter )); |
491 | } | 525 | } |
492 | } | 526 | } |
493 | void Addressee::simplifyPhoneNumberTypes() | 527 | void Addressee::simplifyPhoneNumberTypes() |
494 | { | 528 | { |
495 | KABC::PhoneNumber::List::Iterator phoneIter; | 529 | KABC::PhoneNumber::List::Iterator phoneIter; |
496 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 530 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
497 | ++phoneIter ) | 531 | ++phoneIter ) |
498 | ( *phoneIter ).simplifyType(); | 532 | ( *phoneIter ).simplifyType(); |
499 | } | 533 | } |
500 | void Addressee::removeID(const QString &prof) | 534 | void Addressee::removeID(const QString &prof) |
501 | { | 535 | { |
502 | detach(); | 536 | detach(); |
503 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 537 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
504 | 538 | ||
505 | } | 539 | } |
506 | void Addressee::setID( const QString & prof , const QString & id ) | 540 | void Addressee::setID( const QString & prof , const QString & id ) |
507 | { | 541 | { |
508 | detach(); | 542 | detach(); |
509 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 543 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
510 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 544 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
511 | } | 545 | } |
512 | void Addressee::setTempSyncStat( int id ) | 546 | void Addressee::setTempSyncStat( int id ) |
513 | { | 547 | { |
514 | if ( mData->mTempSyncStat == id ) return; | 548 | if ( mData->mTempSyncStat == id ) return; |
515 | detach(); | 549 | detach(); |
516 | mData->mTempSyncStat = id; | 550 | mData->mTempSyncStat = id; |
517 | } | 551 | } |
518 | int Addressee::tempSyncStat() const | 552 | int Addressee::tempSyncStat() const |
519 | { | 553 | { |
520 | return mData->mTempSyncStat; | 554 | return mData->mTempSyncStat; |
521 | } | 555 | } |
522 | 556 | ||
523 | QString Addressee::getID( const QString & prof) | 557 | QString Addressee::getID( const QString & prof) |
524 | { | 558 | { |
525 | return KIdManager::getId ( mData->mExternalId, prof ); | 559 | return KIdManager::getId ( mData->mExternalId, prof ); |
526 | } | 560 | } |
527 | 561 | ||
528 | void Addressee::setCsum( const QString & prof , const QString & id ) | 562 | void Addressee::setCsum( const QString & prof , const QString & id ) |
529 | { | 563 | { |
530 | detach(); | 564 | detach(); |
531 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 565 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
532 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 566 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
533 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 567 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
534 | } | 568 | } |
535 | 569 | ||
536 | QString Addressee::getCsum( const QString & prof) | 570 | QString Addressee::getCsum( const QString & prof) |
537 | { | 571 | { |
538 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 572 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
539 | } | 573 | } |
540 | 574 | ||
541 | void Addressee::setIDStr( const QString & s ) | 575 | void Addressee::setIDStr( const QString & s ) |
542 | { | 576 | { |
543 | detach(); | 577 | detach(); |
544 | mData->mExternalId = s; | 578 | mData->mExternalId = s; |
545 | } | 579 | } |
546 | 580 | ||
547 | QString Addressee::IDStr() const | 581 | QString Addressee::IDStr() const |
548 | { | 582 | { |
549 | return mData->mExternalId; | 583 | return mData->mExternalId; |
550 | } | 584 | } |
551 | 585 | ||
552 | void Addressee::setExternalUID( const QString &id ) | 586 | void Addressee::setExternalUID( const QString &id ) |
553 | { | 587 | { |
554 | if ( id == mData->externalUID ) return; | 588 | if ( id == mData->externalUID ) return; |
555 | detach(); | 589 | detach(); |
556 | mData->empty = false; | 590 | mData->empty = false; |
557 | mData->externalUID = id; | 591 | mData->externalUID = id; |
558 | } | 592 | } |
559 | 593 | ||
560 | QString Addressee::externalUID() const | 594 | QString Addressee::externalUID() const |
561 | { | 595 | { |
562 | return mData->externalUID; | 596 | return mData->externalUID; |
563 | } | 597 | } |
564 | void Addressee::setOriginalExternalUID( const QString &id ) | 598 | void Addressee::setOriginalExternalUID( const QString &id ) |
565 | { | 599 | { |
566 | if ( id == mData->originalExternalUID ) return; | 600 | if ( id == mData->originalExternalUID ) return; |
567 | detach(); | 601 | detach(); |
568 | mData->empty = false; | 602 | mData->empty = false; |
569 | //qDebug("*******Set orig uid %s ", id.latin1()); | 603 | //qDebug("*******Set orig uid %s ", id.latin1()); |
570 | mData->originalExternalUID = id; | 604 | mData->originalExternalUID = id; |
571 | } | 605 | } |
572 | 606 | ||
573 | QString Addressee::originalExternalUID() const | 607 | QString Addressee::originalExternalUID() const |
574 | { | 608 | { |
575 | return mData->originalExternalUID; | 609 | return mData->originalExternalUID; |
576 | } | 610 | } |
577 | 611 | ||
578 | void Addressee::setUid( const QString &id ) | 612 | void Addressee::setUid( const QString &id ) |
579 | { | 613 | { |
580 | if ( id == mData->uid ) return; | 614 | if ( id == mData->uid ) return; |
581 | detach(); | 615 | detach(); |
582 | //qDebug("****setuid %s ", id.latin1()); | 616 | //qDebug("****setuid %s ", id.latin1()); |
583 | mData->empty = false; | 617 | mData->empty = false; |
584 | mData->uid = id; | 618 | mData->uid = id; |
585 | } | 619 | } |
586 | 620 | ||
587 | QString Addressee::uid() const | 621 | QString Addressee::uid() const |
588 | { | 622 | { |
589 | if ( mData->uid.isEmpty() ) | 623 | if ( mData->uid.isEmpty() ) |
590 | mData->uid = KApplication::randomString( 10 ); | 624 | mData->uid = KApplication::randomString( 10 ); |
591 | 625 | ||
592 | return mData->uid; | 626 | return mData->uid; |
593 | } | 627 | } |
594 | 628 | ||
595 | QString Addressee::uidLabel() | 629 | QString Addressee::uidLabel() |
596 | { | 630 | { |
597 | return i18n("Unique Identifier"); | 631 | return i18n("Unique Identifier"); |
598 | } | 632 | } |
599 | 633 | ||
600 | void Addressee::setName( const QString &name ) | 634 | void Addressee::setName( const QString &name ) |
601 | { | 635 | { |
602 | if ( name == mData->name ) return; | 636 | if ( name == mData->name ) return; |
603 | detach(); | 637 | detach(); |
604 | mData->empty = false; | 638 | mData->empty = false; |
605 | mData->name = name; | 639 | mData->name = name; |
606 | } | 640 | } |
607 | 641 | ||
608 | QString Addressee::name() const | 642 | QString Addressee::name() const |
609 | { | 643 | { |
610 | return mData->name; | 644 | return mData->name; |
611 | } | 645 | } |
612 | 646 | ||
613 | QString Addressee::nameLabel() | 647 | QString Addressee::nameLabel() |
614 | { | 648 | { |
615 | return i18n("Name"); | 649 | return i18n("Name"); |
616 | } | 650 | } |
617 | 651 | ||
618 | 652 | ||
619 | void Addressee::setFormattedName( const QString &formattedName ) | 653 | void Addressee::setFormattedName( const QString &formattedName ) |
620 | { | 654 | { |
621 | if ( formattedName == mData->formattedName ) return; | 655 | if ( formattedName == mData->formattedName ) return; |
622 | detach(); | 656 | detach(); |
623 | mData->empty = false; | 657 | mData->empty = false; |
624 | mData->formattedName = formattedName; | 658 | mData->formattedName = formattedName; |
625 | } | 659 | } |
626 | 660 | ||
627 | QString Addressee::formattedName() const | 661 | QString Addressee::formattedName() const |
628 | { | 662 | { |
629 | return mData->formattedName; | 663 | return mData->formattedName; |
630 | } | 664 | } |
631 | 665 | ||
632 | QString Addressee::formattedNameLabel() | 666 | QString Addressee::formattedNameLabel() |
633 | { | 667 | { |
634 | return i18n("Formatted Name"); | 668 | return i18n("Formatted Name"); |
635 | } | 669 | } |
636 | 670 | ||
637 | 671 | ||
638 | void Addressee::setFamilyName( const QString &familyName ) | 672 | void Addressee::setFamilyName( const QString &familyName ) |
639 | { | 673 | { |
640 | if ( familyName == mData->familyName ) return; | 674 | if ( familyName == mData->familyName ) return; |
641 | detach(); | 675 | detach(); |
642 | mData->empty = false; | 676 | mData->empty = false; |
643 | mData->familyName = familyName; | 677 | mData->familyName = familyName; |
644 | } | 678 | } |
645 | 679 | ||
646 | QString Addressee::familyName() const | 680 | QString Addressee::familyName() const |
647 | { | 681 | { |
648 | return mData->familyName; | 682 | return mData->familyName; |
649 | } | 683 | } |
650 | 684 | ||
651 | QString Addressee::familyNameLabel() | 685 | QString Addressee::familyNameLabel() |
652 | { | 686 | { |
653 | return i18n("Family Name"); | 687 | return i18n("Family Name"); |
654 | } | 688 | } |
655 | 689 | ||
656 | 690 | ||
657 | void Addressee::setGivenName( const QString &givenName ) | 691 | void Addressee::setGivenName( const QString &givenName ) |
658 | { | 692 | { |
659 | if ( givenName == mData->givenName ) return; | 693 | if ( givenName == mData->givenName ) return; |
660 | detach(); | 694 | detach(); |
661 | mData->empty = false; | 695 | mData->empty = false; |
662 | mData->givenName = givenName; | 696 | mData->givenName = givenName; |
663 | } | 697 | } |
664 | 698 | ||
665 | QString Addressee::givenName() const | 699 | QString Addressee::givenName() const |
666 | { | 700 | { |
667 | return mData->givenName; | 701 | return mData->givenName; |
668 | } | 702 | } |
669 | 703 | ||
670 | QString Addressee::givenNameLabel() | 704 | QString Addressee::givenNameLabel() |
671 | { | 705 | { |
672 | return i18n("Given Name"); | 706 | return i18n("Given Name"); |
673 | } | 707 | } |
674 | 708 | ||
675 | 709 | ||
676 | void Addressee::setAdditionalName( const QString &additionalName ) | 710 | void Addressee::setAdditionalName( const QString &additionalName ) |
677 | { | 711 | { |
678 | if ( additionalName == mData->additionalName ) return; | 712 | if ( additionalName == mData->additionalName ) return; |
679 | detach(); | 713 | detach(); |
680 | mData->empty = false; | 714 | mData->empty = false; |
681 | mData->additionalName = additionalName; | 715 | mData->additionalName = additionalName; |
682 | } | 716 | } |
683 | 717 | ||
684 | QString Addressee::additionalName() const | 718 | QString Addressee::additionalName() const |
685 | { | 719 | { |
686 | return mData->additionalName; | 720 | return mData->additionalName; |
687 | } | 721 | } |
688 | 722 | ||
689 | QString Addressee::additionalNameLabel() | 723 | QString Addressee::additionalNameLabel() |
690 | { | 724 | { |
691 | return i18n("Additional Names"); | 725 | return i18n("Additional Names"); |
692 | } | 726 | } |
693 | 727 | ||
694 | 728 | ||
695 | void Addressee::setPrefix( const QString &prefix ) | 729 | void Addressee::setPrefix( const QString &prefix ) |
696 | { | 730 | { |
697 | if ( prefix == mData->prefix ) return; | 731 | if ( prefix == mData->prefix ) return; |
698 | detach(); | 732 | detach(); |
699 | mData->empty = false; | 733 | mData->empty = false; |
700 | mData->prefix = prefix; | 734 | mData->prefix = prefix; |
701 | } | 735 | } |
702 | 736 | ||
703 | QString Addressee::prefix() const | 737 | QString Addressee::prefix() const |
704 | { | 738 | { |
705 | return mData->prefix; | 739 | return mData->prefix; |
706 | } | 740 | } |
707 | 741 | ||
708 | QString Addressee::prefixLabel() | 742 | QString Addressee::prefixLabel() |
709 | { | 743 | { |
710 | return i18n("Honorific Prefixes"); | 744 | return i18n("Honorific Prefixes"); |
711 | } | 745 | } |
712 | 746 | ||
713 | 747 | ||
714 | void Addressee::setSuffix( const QString &suffix ) | 748 | void Addressee::setSuffix( const QString &suffix ) |
715 | { | 749 | { |
716 | if ( suffix == mData->suffix ) return; | 750 | if ( suffix == mData->suffix ) return; |
717 | detach(); | 751 | detach(); |
718 | mData->empty = false; | 752 | mData->empty = false; |
719 | mData->suffix = suffix; | 753 | mData->suffix = suffix; |
720 | } | 754 | } |
721 | 755 | ||
722 | QString Addressee::suffix() const | 756 | QString Addressee::suffix() const |
723 | { | 757 | { |
724 | return mData->suffix; | 758 | return mData->suffix; |
725 | } | 759 | } |
726 | 760 | ||
727 | QString Addressee::suffixLabel() | 761 | QString Addressee::suffixLabel() |
728 | { | 762 | { |
729 | return i18n("Honorific Suffixes"); | 763 | return i18n("Honorific Suffixes"); |
730 | } | 764 | } |
731 | 765 | ||
732 | 766 | ||
733 | void Addressee::setNickName( const QString &nickName ) | 767 | void Addressee::setNickName( const QString &nickName ) |
734 | { | 768 | { |
735 | if ( nickName == mData->nickName ) return; | 769 | if ( nickName == mData->nickName ) return; |
736 | detach(); | 770 | detach(); |
737 | mData->empty = false; | 771 | mData->empty = false; |
738 | mData->nickName = nickName; | 772 | mData->nickName = nickName; |
739 | } | 773 | } |
740 | 774 | ||
741 | QString Addressee::nickName() const | 775 | QString Addressee::nickName() const |
742 | { | 776 | { |
743 | return mData->nickName; | 777 | return mData->nickName; |
744 | } | 778 | } |
745 | 779 | ||
746 | QString Addressee::nickNameLabel() | 780 | QString Addressee::nickNameLabel() |
747 | { | 781 | { |
748 | return i18n("Nick Name"); | 782 | return i18n("Nick Name"); |
749 | } | 783 | } |
750 | 784 | ||
751 | 785 | ||
752 | void Addressee::setBirthday( const QDateTime &birthday ) | 786 | void Addressee::setBirthday( const QDateTime &birthday ) |
753 | { | 787 | { |
754 | if ( birthday == mData->birthday ) return; | 788 | if ( birthday == mData->birthday ) return; |
755 | detach(); | 789 | detach(); |
756 | mData->empty = false; | 790 | mData->empty = false; |
757 | mData->birthday = birthday; | 791 | mData->birthday = birthday; |
758 | } | 792 | } |
759 | 793 | ||
760 | QDateTime Addressee::birthday() const | 794 | QDateTime Addressee::birthday() const |
761 | { | 795 | { |
762 | return mData->birthday; | 796 | return mData->birthday; |
763 | } | 797 | } |
764 | 798 | ||
765 | QString Addressee::birthdayLabel() | 799 | QString Addressee::birthdayLabel() |
766 | { | 800 | { |
767 | return i18n("Birthday"); | 801 | return i18n("Birthday"); |
768 | } | 802 | } |
769 | 803 | ||
770 | 804 | ||
771 | QString Addressee::homeAddressStreetLabel() | 805 | QString Addressee::homeAddressStreetLabel() |
772 | { | 806 | { |
773 | return i18n("Home Address Street"); | 807 | return i18n("Home Address Street"); |
774 | } | 808 | } |
775 | 809 | ||
776 | 810 | ||
777 | QString Addressee::homeAddressLocalityLabel() | 811 | QString Addressee::homeAddressLocalityLabel() |
778 | { | 812 | { |
779 | return i18n("Home Address Locality"); | 813 | return i18n("Home Address Locality"); |
780 | } | 814 | } |
781 | 815 | ||
782 | 816 | ||
783 | QString Addressee::homeAddressRegionLabel() | 817 | QString Addressee::homeAddressRegionLabel() |
784 | { | 818 | { |
785 | return i18n("Home Address Region"); | 819 | return i18n("Home Address Region"); |
786 | } | 820 | } |
787 | 821 | ||
788 | 822 | ||
789 | QString Addressee::homeAddressPostalCodeLabel() | 823 | QString Addressee::homeAddressPostalCodeLabel() |
790 | { | 824 | { |
791 | return i18n("Home Address Postal Code"); | 825 | return i18n("Home Address Postal Code"); |
792 | } | 826 | } |
793 | 827 | ||
794 | 828 | ||
795 | QString Addressee::homeAddressCountryLabel() | 829 | QString Addressee::homeAddressCountryLabel() |
796 | { | 830 | { |
797 | return i18n("Home Address Country"); | 831 | return i18n("Home Address Country"); |
798 | } | 832 | } |
799 | 833 | ||
800 | 834 | ||
801 | QString Addressee::homeAddressLabelLabel() | 835 | QString Addressee::homeAddressLabelLabel() |
802 | { | 836 | { |
803 | return i18n("Home Address Label"); | 837 | return i18n("Home Address Label"); |
804 | } | 838 | } |
805 | 839 | ||
806 | 840 | ||
807 | QString Addressee::businessAddressStreetLabel() | 841 | QString Addressee::businessAddressStreetLabel() |
808 | { | 842 | { |
809 | return i18n("Business Address Street"); | 843 | return i18n("Business Address Street"); |
810 | } | 844 | } |
811 | 845 | ||
812 | 846 | ||
813 | QString Addressee::businessAddressLocalityLabel() | 847 | QString Addressee::businessAddressLocalityLabel() |
814 | { | 848 | { |
815 | return i18n("Business Address Locality"); | 849 | return i18n("Business Address Locality"); |
816 | } | 850 | } |
817 | 851 | ||
818 | 852 | ||
819 | QString Addressee::businessAddressRegionLabel() | 853 | QString Addressee::businessAddressRegionLabel() |
820 | { | 854 | { |
821 | return i18n("Business Address Region"); | 855 | return i18n("Business Address Region"); |
822 | } | 856 | } |
823 | 857 | ||
824 | 858 | ||
825 | QString Addressee::businessAddressPostalCodeLabel() | 859 | QString Addressee::businessAddressPostalCodeLabel() |
826 | { | 860 | { |
827 | return i18n("Business Address Postal Code"); | 861 | return i18n("Business Address Postal Code"); |
828 | } | 862 | } |
829 | 863 | ||
830 | 864 | ||
831 | QString Addressee::businessAddressCountryLabel() | 865 | QString Addressee::businessAddressCountryLabel() |
832 | { | 866 | { |
833 | return i18n("Business Address Country"); | 867 | return i18n("Business Address Country"); |
834 | } | 868 | } |
835 | 869 | ||
836 | 870 | ||
837 | QString Addressee::businessAddressLabelLabel() | 871 | QString Addressee::businessAddressLabelLabel() |
838 | { | 872 | { |
839 | return i18n("Business Address Label"); | 873 | return i18n("Business Address Label"); |
840 | } | 874 | } |
841 | 875 | ||
842 | 876 | ||
843 | QString Addressee::homePhoneLabel() | 877 | QString Addressee::homePhoneLabel() |
844 | { | 878 | { |
845 | return i18n("Home Phone"); | 879 | return i18n("Home Phone"); |
846 | } | 880 | } |
847 | 881 | ||
848 | 882 | ||
849 | QString Addressee::businessPhoneLabel() | 883 | QString Addressee::businessPhoneLabel() |
850 | { | 884 | { |
851 | return i18n("Business Phone"); | 885 | return i18n("Business Phone"); |
852 | } | 886 | } |
853 | 887 | ||
854 | 888 | ||
855 | QString Addressee::mobilePhoneLabel() | 889 | QString Addressee::mobilePhoneLabel() |
856 | { | 890 | { |
857 | return i18n("Mobile Phone"); | 891 | return i18n("Mobile Phone"); |
858 | } | 892 | } |
859 | 893 | ||
860 | 894 | ||
861 | QString Addressee::homeFaxLabel() | 895 | QString Addressee::homeFaxLabel() |
862 | { | 896 | { |
863 | return i18n("Home Fax"); | 897 | return i18n("Home Fax"); |
864 | } | 898 | } |
865 | 899 | ||
866 | 900 | ||