author | zautrix <zautrix> | 2006-02-24 18:49:56 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2006-02-24 18:49:56 (UTC) |
commit | d7738fdfc685192eb2f8317db6ffad3c246001c8 (patch) (unidiff) | |
tree | d9aae6ca97851fd1b53c4d9e74740a5ee2b69ea9 /kabc/addressee.cpp | |
parent | 987757f168bbae56100f2aff763b865e81ceec18 (diff) | |
download | kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.zip kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.gz kdepimpi-d7738fdfc685192eb2f8317db6ffad3c246001c8.tar.bz2 |
kapi sync
-rw-r--r-- | kabc/addressee.cpp | 75 |
1 files changed, 72 insertions, 3 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 6cfac80..e8e440c 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,462 +1,510 @@ | |||
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 <kmessagebox.h> | ||
35 | #include <kidmanager.h> | 36 | #include <kidmanager.h> |
36 | //US | 37 | //US |
37 | #include <kstandarddirs.h> | 38 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 39 | #include <libkcal/syncdefines.h> |
39 | 40 | ||
40 | //US #include "resource.h" | 41 | //US #include "resource.h" |
41 | #include "addressee.h" | 42 | #include "addressee.h" |
42 | 43 | ||
43 | using namespace KABC; | 44 | using namespace KABC; |
44 | 45 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 46 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 47 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 48 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 49 | ||
49 | struct Addressee::AddresseeData : public KShared | 50 | struct Addressee::AddresseeData : public KShared |
50 | { | 51 | { |
51 | QString uid; | 52 | QString uid; |
52 | QString name; | 53 | QString name; |
53 | QString formattedName; | 54 | QString formattedName; |
54 | QString familyName; | 55 | QString familyName; |
55 | QString givenName; | 56 | QString givenName; |
56 | QString additionalName; | 57 | QString additionalName; |
57 | QString prefix; | 58 | QString prefix; |
58 | QString suffix; | 59 | QString suffix; |
59 | QString nickName; | 60 | QString nickName; |
60 | QDateTime birthday; | 61 | QDateTime birthday; |
61 | QString mailer; | 62 | QString mailer; |
62 | TimeZone timeZone; | 63 | TimeZone timeZone; |
63 | Geo geo; | 64 | Geo geo; |
64 | QString title; | 65 | QString title; |
65 | QString role; | 66 | QString role; |
66 | QString organization; | 67 | QString organization; |
67 | QString note; | 68 | QString note; |
68 | QString productId; | 69 | QString productId; |
69 | QDateTime revision; | 70 | QDateTime revision; |
70 | QString sortString; | 71 | QString sortString; |
71 | QString externalUID; | 72 | QString externalUID; |
72 | QString originalExternalUID; | 73 | QString originalExternalUID; |
73 | KURL url; | 74 | KURL url; |
74 | Secrecy secrecy; | 75 | Secrecy secrecy; |
75 | Picture logo; | 76 | Picture logo; |
76 | Picture photo; | 77 | Picture photo; |
77 | Sound sound; | 78 | Sound sound; |
78 | Agent agent; | 79 | Agent agent; |
79 | QString mExternalId; | 80 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 81 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 82 | Address::List addresses; |
82 | Key::List keys; | 83 | Key::List keys; |
83 | QStringList emails; | 84 | QStringList emails; |
84 | QStringList categories; | 85 | QStringList categories; |
85 | QStringList custom; | 86 | QStringList custom; |
86 | int mTempSyncStat; | 87 | int mTempSyncStat; |
87 | Resource *resource; | 88 | Resource *resource; |
88 | 89 | ||
89 | bool empty :1; | 90 | bool empty :1; |
90 | bool changed :1; | 91 | bool changed :1; |
91 | bool tagged :1; | 92 | bool tagged :1; |
92 | }; | 93 | }; |
93 | 94 | ||
94 | Addressee::Addressee() | 95 | Addressee::Addressee() |
95 | { | 96 | { |
96 | mData = new AddresseeData; | 97 | mData = new AddresseeData; |
97 | mData->empty = true; | 98 | mData->empty = true; |
98 | mData->changed = false; | 99 | mData->changed = false; |
99 | mData->resource = 0; | 100 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 101 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 102 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 103 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 104 | } |
104 | 105 | ||
105 | Addressee::~Addressee() | 106 | Addressee::~Addressee() |
106 | { | 107 | { |
107 | } | 108 | } |
108 | 109 | ||
109 | Addressee::Addressee( const Addressee &a ) | 110 | Addressee::Addressee( const Addressee &a ) |
110 | { | 111 | { |
111 | mData = a.mData; | 112 | mData = a.mData; |
112 | } | 113 | } |
113 | 114 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 115 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 116 | { |
116 | mData = a.mData; | 117 | mData = a.mData; |
117 | return (*this); | 118 | return (*this); |
118 | } | 119 | } |
119 | 120 | ||
120 | Addressee Addressee::copy() | 121 | Addressee Addressee::copy() |
121 | { | 122 | { |
122 | Addressee a; | 123 | Addressee a; |
123 | *(a.mData) = *mData; | 124 | *(a.mData) = *mData; |
124 | return a; | 125 | return a; |
125 | } | 126 | } |
126 | 127 | ||
127 | void Addressee::detach() | 128 | void Addressee::detach() |
128 | { | 129 | { |
129 | if ( mData.count() == 1 ) return; | 130 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 131 | *this = copy(); |
131 | } | 132 | } |
132 | 133 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 134 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 135 | { |
135 | if ( uid() != a.uid() ) return false; | 136 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 137 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 138 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 139 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 140 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 141 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 142 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 143 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 144 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 145 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 146 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 147 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 148 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 149 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 150 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 151 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 152 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 153 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 154 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 155 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 156 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 157 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 158 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 159 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 160 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 161 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 162 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 163 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 164 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 165 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 166 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 167 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 168 | if ( mData->custom != a.mData->custom ) return false; |
168 | 169 | ||
169 | return true; | 170 | return true; |
170 | } | 171 | } |
171 | 172 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 173 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 174 | { |
174 | return !( a == *this ); | 175 | return !( a == *this ); |
175 | } | 176 | } |
176 | 177 | ||
177 | bool Addressee::isEmpty() const | 178 | bool Addressee::isEmpty() const |
178 | { | 179 | { |
179 | return mData->empty; | 180 | return mData->empty; |
180 | } | 181 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 182 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 183 | { |
183 | int max = attList.count(); | 184 | int max = attList.count(); |
184 | ulong cSum = 0; | 185 | ulong cSum = 0; |
185 | int j,k,i; | 186 | int j,k,i; |
186 | int add; | 187 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 188 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 189 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 190 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 191 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 192 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 193 | int mul = k +1; |
193 | add = s[k].unicode (); | 194 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 195 | if ( k < 16 ) |
195 | mul = mul * mul; | 196 | mul = mul * mul; |
196 | int ii = i+1; | 197 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 198 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 199 | cSum += add; |
199 | //qDebug("csum: %d %d %d", i,k,cSum); | 200 | //qDebug("csum: %d %d %d", i,k,cSum); |
200 | } | 201 | } |
201 | } | 202 | } |
202 | 203 | ||
203 | } | 204 | } |
204 | //QString dump = attList.join(","); | 205 | //QString dump = attList.join(","); |
205 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 206 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
206 | 207 | ||
207 | return cSum; | 208 | return cSum; |
208 | 209 | ||
209 | } | 210 | } |
210 | void Addressee::computeCsum(const QString &dev) | 211 | void Addressee::computeCsum(const QString &dev) |
211 | { | 212 | { |
212 | QStringList l; | 213 | QStringList l; |
213 | //if ( !mData->name.isEmpty() ) l.append(mData->name); | 214 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
214 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 215 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
215 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 216 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
216 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 217 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
217 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); | 218 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
218 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 219 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
219 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 220 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
220 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 221 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
221 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 222 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
222 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 223 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
223 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 224 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
224 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 225 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
225 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 226 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
226 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 227 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
227 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 228 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
228 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 229 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
229 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 230 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
230 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 231 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
231 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 232 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
232 | if ( !mData->logo.undefined() ) { | 233 | if ( !mData->logo.undefined() ) { |
233 | if ( !mData->logo.isIntern() ) | 234 | if ( !mData->logo.isIntern() ) |
234 | l.append( mData->logo.url() ); | 235 | l.append( mData->logo.url() ); |
235 | else | 236 | else |
236 | l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); | 237 | l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); |
237 | } else { | 238 | } else { |
238 | l.append( "nologo"); | 239 | l.append( "nologo"); |
239 | } | 240 | } |
240 | if ( !mData->photo.undefined() ) { | 241 | if ( !mData->photo.undefined() ) { |
241 | if ( !mData->photo.isIntern() ) | 242 | if ( !mData->photo.isIntern() ) |
242 | l.append( mData->photo.url() ); | 243 | l.append( mData->photo.url() ); |
243 | else | 244 | else |
244 | l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); | 245 | l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); |
245 | } else { | 246 | } else { |
246 | l.append( "nophoto"); | 247 | l.append( "nophoto"); |
247 | } | 248 | } |
248 | #if 0 | 249 | #if 0 |
249 | if ( !mData->sound.undefined() ) { | 250 | if ( !mData->sound.undefined() ) { |
250 | if ( !mData->sound.isIntern() ) | 251 | if ( !mData->sound.isIntern() ) |
251 | l.append( mData->sound.url() ); | 252 | l.append( mData->sound.url() ); |
252 | else | 253 | else |
253 | l.append( QString(mData->sound.data().with()* mData->sound.data().height())); | 254 | l.append( QString(mData->sound.data().with()* mData->sound.data().height())); |
254 | } else { | 255 | } else { |
255 | l.append( "nosound"); | 256 | l.append( "nosound"); |
256 | } | 257 | } |
257 | #endif | 258 | #endif |
258 | //if ( !mData->agent.isEmpty() ) l.append( ); | 259 | //if ( !mData->agent.isEmpty() ) l.append( ); |
259 | if ( mData->url.isValid() ) | 260 | if ( mData->url.isValid() ) |
260 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 261 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
261 | KABC::PhoneNumber::List phoneNumbers; | 262 | KABC::PhoneNumber::List phoneNumbers; |
262 | KABC::PhoneNumber::List::Iterator phoneIter; | 263 | KABC::PhoneNumber::List::Iterator phoneIter; |
263 | 264 | ||
264 | QStringList t; | 265 | QStringList t; |
265 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 266 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
266 | ++phoneIter ) | 267 | ++phoneIter ) |
267 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 268 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
268 | t.sort(); | 269 | t.sort(); |
269 | uint iii; | 270 | uint iii; |
270 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
271 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
272 | t = mData->emails; | 273 | t = mData->emails; |
273 | t.sort(); | 274 | t.sort(); |
274 | for ( iii = 0; iii < t.count(); ++iii) | 275 | for ( iii = 0; iii < t.count(); ++iii) |
275 | l.append( t[iii] ); | 276 | l.append( t[iii] ); |
276 | t = mData->categories; | 277 | t = mData->categories; |
277 | t.sort(); | 278 | t.sort(); |
278 | for ( iii = 0; iii < t.count(); ++iii) | 279 | for ( iii = 0; iii < t.count(); ++iii) |
279 | l.append( t[iii] ); | 280 | l.append( t[iii] ); |
280 | t = mData->custom; | 281 | t = mData->custom; |
281 | t.sort(); | 282 | t.sort(); |
282 | for ( iii = 0; iii < t.count(); ++iii) | 283 | for ( iii = 0; iii < t.count(); ++iii) |
283 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 284 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
284 | int find = t[iii].find (':')+1; | 285 | int find = t[iii].find (':')+1; |
285 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 286 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
286 | if ( find < t[iii].length()) | 287 | if ( find < t[iii].length()) |
287 | l.append( t[iii] ); | 288 | l.append( t[iii] ); |
288 | 289 | ||
289 | } | 290 | } |
290 | KABC::Address::List::Iterator addressIter; | 291 | KABC::Address::List::Iterator addressIter; |
291 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 292 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
292 | ++addressIter ) { | 293 | ++addressIter ) { |
293 | t = (*addressIter).asList(); | 294 | t = (*addressIter).asList(); |
294 | t.sort(); | 295 | t.sort(); |
295 | for ( iii = 0; iii < t.count(); ++iii) | 296 | for ( iii = 0; iii < t.count(); ++iii) |
296 | l.append( t[iii] ); | 297 | l.append( t[iii] ); |
297 | } | 298 | } |
298 | uint cs = getCsum4List(l); | 299 | uint cs = getCsum4List(l); |
299 | 300 | ||
300 | #if 0 | 301 | #if 0 |
301 | for ( iii = 0; iii < l.count(); ++iii) | 302 | for ( iii = 0; iii < l.count(); ++iii) |
302 | qDebug("%d***%s***",iii,l[iii].latin1()); | 303 | qDebug("%d***%s***",iii,l[iii].latin1()); |
303 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 304 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
304 | #endif | 305 | #endif |
305 | 306 | ||
306 | 307 | ||
307 | setCsum( dev, QString::number (cs )); | 308 | setCsum( dev, QString::number (cs )); |
308 | } | 309 | } |
309 | bool Addressee::matchAddress( QRegExp* re ) const | 310 | bool Addressee::matchAddress( QRegExp* re ) const |
310 | { | 311 | { |
311 | KABC::Address::List::Iterator addressIter; | 312 | KABC::Address::List::Iterator addressIter; |
312 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 313 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
313 | ++addressIter ) { | 314 | ++addressIter ) { |
314 | if ( (*addressIter).matchAddress( re ) ) | 315 | if ( (*addressIter).matchAddress( re ) ) |
315 | return true; | 316 | return true; |
316 | } | 317 | } |
317 | return false; | 318 | return false; |
318 | } | 319 | } |
319 | bool Addressee::matchPhoneNumber( QRegExp* re ) const | 320 | bool Addressee::matchPhoneNumber( QRegExp* re ) const |
320 | { | 321 | { |
321 | KABC::PhoneNumber::List::Iterator phoneIter; | 322 | KABC::PhoneNumber::List::Iterator phoneIter; |
322 | 323 | ||
323 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { | 324 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { |
324 | #if QT_VERSION >= 0x030000 | 325 | #if QT_VERSION >= 0x030000 |
325 | if (re->search( (*phoneIter).number() ) == 0) | 326 | if (re->search( (*phoneIter).number() ) == 0) |
326 | #else | 327 | #else |
327 | if (re->match( (*phoneIter).number() ) == 0) | 328 | if (re->match( (*phoneIter).number() ) == 0) |
328 | #endif | 329 | #endif |
329 | return true; | 330 | return true; |
330 | 331 | ||
331 | } | 332 | } |
332 | return false; | 333 | return false; |
333 | 334 | ||
334 | } | 335 | } |
336 | void Addressee::mergeOLContact( const Addressee& ad ) | ||
337 | { | ||
338 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | ||
339 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | ||
340 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | ||
341 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | ||
342 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | ||
343 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | ||
344 | if ( !mData->sound.isIntern() ) { | ||
345 | if ( mData->sound.url().isEmpty() ) { | ||
346 | mData->sound = ad.mData->sound; | ||
347 | } | ||
348 | } | ||
349 | if ( !mData->agent.isIntern() ) { | ||
350 | if ( mData->agent.url().isEmpty() ) { | ||
351 | mData->agent = ad.mData->agent; | ||
352 | } | ||
353 | } | ||
354 | { | ||
355 | Key::List::Iterator itA; | ||
356 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | ||
357 | bool found = false; | ||
358 | Key::List::Iterator it; | ||
359 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | ||
360 | if ( (*it) == (*itA)) { | ||
361 | found = true; | ||
362 | break; | ||
363 | |||
364 | } | ||
365 | } | ||
366 | if ( ! found ) { | ||
367 | mData->keys.append( *itA ); | ||
368 | } | ||
369 | } | ||
370 | } | ||
371 | |||
372 | KABC::Address addthis = otherAddress(); | ||
373 | KABC::Address addother = ad.otherAddress(); | ||
374 | if ( !addthis.isEmpty() && !addother.isEmpty() ) | ||
375 | addthis.setType( addother.type() ); | ||
376 | //qDebug("merge contact %s ", ad.uid().latin1()); | ||
377 | setUid( ad.uid() ); | ||
378 | setRevision( ad.revision() ); | ||
379 | |||
380 | |||
381 | } | ||
382 | |||
335 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 383 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
336 | { | 384 | { |
337 | // merge all standard non-outlook fields. | 385 | // merge all standard non-outlook fields. |
338 | //if isSubSet (e.g. mobile phone sync) merge all fields | 386 | //if isSubSet (e.g. mobile phone sync) merge all fields |
339 | 387 | ||
340 | detach(); | 388 | detach(); |
341 | if ( isSubSet ) { | 389 | if ( isSubSet ) { |
342 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 390 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
343 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 391 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
344 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 392 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
345 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 393 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
346 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 394 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
347 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 395 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
348 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 396 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
349 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 397 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
350 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 398 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
351 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 399 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
352 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 400 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
353 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 401 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
354 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 402 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
355 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 403 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
356 | if ( !mData->birthday.isValid() ) | 404 | if ( !mData->birthday.isValid() ) |
357 | if ( ad.mData->birthday.isValid()) | 405 | if ( ad.mData->birthday.isValid()) |
358 | mData->birthday = ad.mData->birthday; | 406 | mData->birthday = ad.mData->birthday; |
359 | 407 | ||
360 | } | 408 | } |
361 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 409 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
362 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 410 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
363 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 411 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
364 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 412 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
365 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 413 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
366 | QStringList t; | 414 | QStringList t; |
367 | QStringList tAD; | 415 | QStringList tAD; |
368 | uint iii; | 416 | uint iii; |
369 | 417 | ||
370 | // ********** phone numbers | 418 | // ********** phone numbers |
371 | if ( isSubSet ) { | 419 | if ( isSubSet ) { |
372 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 420 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
373 | PhoneNumber::List::Iterator phoneItAD; | 421 | PhoneNumber::List::Iterator phoneItAD; |
374 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 422 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
375 | bool found = false; | 423 | bool found = false; |
376 | PhoneNumber::List::Iterator it; | 424 | PhoneNumber::List::Iterator it; |
377 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 425 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
378 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 426 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
379 | found = true; | 427 | found = true; |
380 | (*it).setType( ( *phoneItAD ).type() ); | 428 | (*it).setType( ( *phoneItAD ).type() ); |
381 | (*it).setNumber( ( *phoneItAD ).number() ); | 429 | (*it).setNumber( ( *phoneItAD ).number() ); |
382 | break; | 430 | break; |
383 | } | 431 | } |
384 | } | 432 | } |
385 | // if ( isSubSet && ! found ) | 433 | // if ( isSubSet && ! found ) |
386 | if ( ! found ) // LR try this one... | 434 | if ( ! found ) // LR try this one... |
387 | mData->phoneNumbers.append( *phoneItAD ); | 435 | mData->phoneNumbers.append( *phoneItAD ); |
388 | } | 436 | } |
389 | } else { | 437 | } else { |
390 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 438 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
391 | PhoneNumber::List::Iterator phoneItAD; | 439 | PhoneNumber::List::Iterator phoneItAD; |
392 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 440 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
393 | bool found = false; | 441 | bool found = false; |
394 | PhoneNumber::List::Iterator it; | 442 | PhoneNumber::List::Iterator it; |
395 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 443 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
396 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 444 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
397 | found = true; | 445 | found = true; |
398 | (*it).setType( ( *phoneItAD ).type() ); | 446 | (*it).setType( ( *phoneItAD ).type() ); |
399 | (*it).setNumber( ( *phoneItAD ).number() ); | 447 | (*it).setNumber( ( *phoneItAD ).number() ); |
400 | break; | 448 | break; |
401 | } | 449 | } |
402 | } | 450 | } |
403 | if ( ! found ) { // append numbers which do not have work or home type | 451 | if ( ! found ) { // append numbers which do not have work or home type |
404 | if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) | 452 | if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) |
405 | mData->phoneNumbers.append( *phoneItAD ); | 453 | mData->phoneNumbers.append( *phoneItAD ); |
406 | } | 454 | } |
407 | } | 455 | } |
408 | } | 456 | } |
409 | if ( isSubSet ) { | 457 | if ( isSubSet ) { |
410 | // ************* emails; | 458 | // ************* emails; |
411 | t = mData->emails; | 459 | t = mData->emails; |
412 | tAD = ad.mData->emails; | 460 | tAD = ad.mData->emails; |
413 | for ( iii = 0; iii < tAD.count(); ++iii) | 461 | for ( iii = 0; iii < tAD.count(); ++iii) |
414 | if ( !t.contains(tAD[iii] ) ) | 462 | if ( !t.contains(tAD[iii] ) ) |
415 | mData->emails.append( tAD[iii] ); | 463 | mData->emails.append( tAD[iii] ); |
416 | } | 464 | } |
417 | 465 | ||
418 | // ************* categories; | 466 | // ************* categories; |
419 | if ( isSubSet ) { | 467 | if ( isSubSet ) { |
420 | t = mData->categories; | 468 | t = mData->categories; |
421 | tAD = ad.mData->categories; | 469 | tAD = ad.mData->categories; |
422 | for ( iii = 0; iii < tAD.count(); ++iii) | 470 | for ( iii = 0; iii < tAD.count(); ++iii) |
423 | if ( !t.contains(tAD[iii] ) ) | 471 | if ( !t.contains(tAD[iii] ) ) |
424 | mData->categories.append( tAD[iii] ); | 472 | mData->categories.append( tAD[iii] ); |
425 | } | 473 | } |
426 | QStringList::ConstIterator it; | 474 | QStringList::ConstIterator it; |
427 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 475 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
428 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 476 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
429 | bool found = false; | 477 | bool found = false; |
430 | QStringList::ConstIterator itL; | 478 | QStringList::ConstIterator itL; |
431 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 479 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
432 | if ( (*itL).startsWith( qualifiedName ) ) { | 480 | if ( (*itL).startsWith( qualifiedName ) ) { |
433 | found = true; | 481 | found = true; |
434 | break; | 482 | break; |
435 | } | 483 | } |
436 | } | 484 | } |
437 | if ( ! found ) { | 485 | if ( ! found ) { |
438 | mData->custom.append( *it ); | 486 | mData->custom.append( *it ); |
439 | } | 487 | } |
440 | } | 488 | } |
441 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 489 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
442 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 490 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
443 | if ( !mData->sound.isIntern() ) { | 491 | if ( !mData->sound.isIntern() ) { |
444 | if ( mData->sound.url().isEmpty() ) { | 492 | if ( mData->sound.url().isEmpty() ) { |
445 | mData->sound = ad.mData->sound; | 493 | mData->sound = ad.mData->sound; |
446 | } | 494 | } |
447 | } | 495 | } |
448 | if ( !mData->agent.isIntern() ) { | 496 | if ( !mData->agent.isIntern() ) { |
449 | if ( mData->agent.url().isEmpty() ) { | 497 | if ( mData->agent.url().isEmpty() ) { |
450 | mData->agent = ad.mData->agent; | 498 | mData->agent = ad.mData->agent; |
451 | } | 499 | } |
452 | } | 500 | } |
453 | { | 501 | { |
454 | Key::List::Iterator itA; | 502 | Key::List::Iterator itA; |
455 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 503 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
456 | bool found = false; | 504 | bool found = false; |
457 | Key::List::Iterator it; | 505 | Key::List::Iterator it; |
458 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 506 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
459 | if ( (*it) == (*itA)) { | 507 | if ( (*it) == (*itA)) { |
460 | found = true; | 508 | found = true; |
461 | break; | 509 | break; |
462 | 510 | ||
@@ -1528,529 +1576,550 @@ void Addressee::setNameFromString( const QString &str ) | |||
1528 | } else | 1576 | } else |
1529 | setFamilyName( parts[ rightOffset ] ); | 1577 | setFamilyName( parts[ rightOffset ] ); |
1530 | 1578 | ||
1531 | QString prefix; | 1579 | QString prefix; |
1532 | while ( leftOffset < rightOffset ) { | 1580 | while ( leftOffset < rightOffset ) { |
1533 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1581 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1534 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1582 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1535 | leftOffset++; | 1583 | leftOffset++; |
1536 | } else | 1584 | } else |
1537 | break; | 1585 | break; |
1538 | } | 1586 | } |
1539 | 1587 | ||
1540 | parts = QStringList::split( " ", part2 ); | 1588 | parts = QStringList::split( " ", part2 ); |
1541 | 1589 | ||
1542 | leftOffset = 0; | 1590 | leftOffset = 0; |
1543 | rightOffset = parts.count(); | 1591 | rightOffset = parts.count(); |
1544 | 1592 | ||
1545 | while ( leftOffset < rightOffset ) { | 1593 | while ( leftOffset < rightOffset ) { |
1546 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1594 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1547 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1595 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1548 | leftOffset++; | 1596 | leftOffset++; |
1549 | } else | 1597 | } else |
1550 | break; | 1598 | break; |
1551 | } | 1599 | } |
1552 | setPrefix( prefix ); | 1600 | setPrefix( prefix ); |
1553 | 1601 | ||
1554 | if ( leftOffset < rightOffset ) { | 1602 | if ( leftOffset < rightOffset ) { |
1555 | setGivenName( parts[ leftOffset ] ); | 1603 | setGivenName( parts[ leftOffset ] ); |
1556 | leftOffset++; | 1604 | leftOffset++; |
1557 | } | 1605 | } |
1558 | 1606 | ||
1559 | QString additionalName; | 1607 | QString additionalName; |
1560 | while ( leftOffset < rightOffset ) { | 1608 | while ( leftOffset < rightOffset ) { |
1561 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1609 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1562 | leftOffset++; | 1610 | leftOffset++; |
1563 | } | 1611 | } |
1564 | setAdditionalName( additionalName ); | 1612 | setAdditionalName( additionalName ); |
1565 | } | 1613 | } |
1566 | } | 1614 | } |
1567 | 1615 | ||
1568 | QString Addressee::realName() const | 1616 | QString Addressee::realName() const |
1569 | { | 1617 | { |
1570 | if ( !formattedName().isEmpty() ) | 1618 | if ( !formattedName().isEmpty() ) |
1571 | return formattedName(); | 1619 | return formattedName(); |
1572 | 1620 | ||
1573 | QString n = assembledName(); | 1621 | QString n = assembledName(); |
1574 | 1622 | ||
1575 | if ( n.isEmpty() ) | 1623 | if ( n.isEmpty() ) |
1576 | n = name(); | 1624 | n = name(); |
1577 | if ( n.isEmpty() ) | 1625 | if ( n.isEmpty() ) |
1578 | n = organization(); | 1626 | n = organization(); |
1579 | return n; | 1627 | return n; |
1580 | } | 1628 | } |
1581 | 1629 | ||
1582 | QString Addressee::assembledName() const | 1630 | QString Addressee::assembledName() const |
1583 | { | 1631 | { |
1584 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1632 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1585 | familyName() + " " + suffix(); | 1633 | familyName() + " " + suffix(); |
1586 | 1634 | ||
1587 | return name.simplifyWhiteSpace(); | 1635 | return name.simplifyWhiteSpace(); |
1588 | } | 1636 | } |
1589 | 1637 | ||
1590 | QString Addressee::fullEmail( const QString &email ) const | 1638 | QString Addressee::fullEmail( const QString &email ) const |
1591 | { | 1639 | { |
1592 | QString e; | 1640 | QString e; |
1593 | if ( email.isNull() ) { | 1641 | if ( email.isNull() ) { |
1594 | e = preferredEmail(); | 1642 | e = preferredEmail(); |
1595 | } else { | 1643 | } else { |
1596 | e = email; | 1644 | e = email; |
1597 | } | 1645 | } |
1598 | if ( e.isEmpty() ) return QString::null; | 1646 | if ( e.isEmpty() ) return QString::null; |
1599 | 1647 | ||
1600 | QString text; | 1648 | QString text; |
1601 | if ( realName().isEmpty() ) | 1649 | if ( realName().isEmpty() ) |
1602 | text = e; | 1650 | text = e; |
1603 | else | 1651 | else |
1604 | text = assembledName() + " <" + e + ">"; | 1652 | text = assembledName() + " <" + e + ">"; |
1605 | 1653 | ||
1606 | return text; | 1654 | return text; |
1607 | } | 1655 | } |
1608 | 1656 | ||
1609 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1657 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1610 | { | 1658 | { |
1611 | detach(); | 1659 | detach(); |
1612 | 1660 | ||
1613 | QStringList::Iterator it = mData->emails.find( email ); | 1661 | QStringList::Iterator it = mData->emails.find( email ); |
1614 | 1662 | ||
1615 | if ( it != mData->emails.end() ) { | 1663 | if ( it != mData->emails.end() ) { |
1616 | if ( !preferred || it == mData->emails.begin() ) return; | 1664 | if ( !preferred || it == mData->emails.begin() ) return; |
1617 | mData->emails.remove( it ); | 1665 | mData->emails.remove( it ); |
1618 | mData->emails.prepend( email ); | 1666 | mData->emails.prepend( email ); |
1619 | } else { | 1667 | } else { |
1620 | if ( preferred ) { | 1668 | if ( preferred ) { |
1621 | mData->emails.prepend( email ); | 1669 | mData->emails.prepend( email ); |
1622 | } else { | 1670 | } else { |
1623 | mData->emails.append( email ); | 1671 | mData->emails.append( email ); |
1624 | } | 1672 | } |
1625 | } | 1673 | } |
1626 | } | 1674 | } |
1627 | 1675 | ||
1628 | void Addressee::removeEmail( const QString &email ) | 1676 | void Addressee::removeEmail( const QString &email ) |
1629 | { | 1677 | { |
1630 | detach(); | 1678 | detach(); |
1631 | 1679 | ||
1632 | QStringList::Iterator it = mData->emails.find( email ); | 1680 | QStringList::Iterator it = mData->emails.find( email ); |
1633 | if ( it == mData->emails.end() ) return; | 1681 | if ( it == mData->emails.end() ) return; |
1634 | 1682 | ||
1635 | mData->emails.remove( it ); | 1683 | mData->emails.remove( it ); |
1636 | } | 1684 | } |
1637 | 1685 | ||
1638 | QString Addressee::preferredEmail() const | 1686 | QString Addressee::preferredEmail() const |
1639 | { | 1687 | { |
1640 | if ( mData->emails.count() == 0 ) return QString::null; | 1688 | if ( mData->emails.count() == 0 ) return QString::null; |
1641 | else return mData->emails.first(); | 1689 | else return mData->emails.first(); |
1642 | } | 1690 | } |
1643 | 1691 | ||
1644 | QStringList Addressee::emails() const | 1692 | QStringList Addressee::emails() const |
1645 | { | 1693 | { |
1646 | return mData->emails; | 1694 | return mData->emails; |
1647 | } | 1695 | } |
1648 | void Addressee::setEmails( const QStringList& emails ) { | 1696 | void Addressee::setEmails( const QStringList& emails ) { |
1649 | detach(); | 1697 | detach(); |
1650 | mData->emails = emails; | 1698 | mData->emails = emails; |
1651 | } | 1699 | } |
1652 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1700 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1653 | { | 1701 | { |
1654 | detach(); | 1702 | detach(); |
1655 | mData->empty = false; | 1703 | mData->empty = false; |
1656 | |||
1657 | PhoneNumber::List::Iterator it; | 1704 | PhoneNumber::List::Iterator it; |
1658 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1705 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1659 | if ( (*it).id() == phoneNumber.id() ) { | 1706 | if ( (*it).id() == phoneNumber.id() ) { |
1660 | *it = phoneNumber; | 1707 | *it = phoneNumber; |
1661 | return; | 1708 | return; |
1662 | } | 1709 | } |
1663 | } | 1710 | } |
1664 | mData->phoneNumbers.append( phoneNumber ); | 1711 | mData->phoneNumbers.append( phoneNumber ); |
1665 | } | 1712 | } |
1666 | 1713 | ||
1667 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1714 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1668 | { | 1715 | { |
1669 | detach(); | 1716 | detach(); |
1670 | 1717 | ||
1671 | PhoneNumber::List::Iterator it; | 1718 | PhoneNumber::List::Iterator it; |
1672 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1719 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1673 | if ( (*it).id() == phoneNumber.id() ) { | 1720 | if ( (*it).id() == phoneNumber.id() ) { |
1674 | mData->phoneNumbers.remove( it ); | 1721 | mData->phoneNumbers.remove( it ); |
1675 | return; | 1722 | return; |
1676 | } | 1723 | } |
1677 | } | 1724 | } |
1678 | } | 1725 | } |
1679 | 1726 | ||
1680 | PhoneNumber Addressee::phoneNumber( int type ) const | 1727 | PhoneNumber Addressee::phoneNumber( int type ) const |
1681 | { | 1728 | { |
1682 | PhoneNumber phoneNumber( "", type ); | 1729 | PhoneNumber phoneNumber( "", type ); |
1683 | PhoneNumber::List::ConstIterator it; | 1730 | PhoneNumber::List::ConstIterator it; |
1684 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1731 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1685 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1732 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1686 | if ( (*it).type() & PhoneNumber::Pref ) | 1733 | if ( (*it).type() & PhoneNumber::Pref ) |
1687 | return (*it); | 1734 | return (*it); |
1688 | else if ( phoneNumber.number().isEmpty() ) | 1735 | else if ( phoneNumber.number().isEmpty() ) |
1689 | phoneNumber = (*it); | 1736 | phoneNumber = (*it); |
1690 | } | 1737 | } |
1691 | } | 1738 | } |
1692 | 1739 | ||
1693 | return phoneNumber; | 1740 | return phoneNumber; |
1694 | } | 1741 | } |
1695 | 1742 | ||
1696 | PhoneNumber::List Addressee::phoneNumbers() const | 1743 | PhoneNumber::List Addressee::phoneNumbers() const |
1697 | { | 1744 | { |
1698 | return mData->phoneNumbers; | 1745 | return mData->phoneNumbers; |
1699 | } | 1746 | } |
1700 | 1747 | ||
1701 | int Addressee::hasPhoneNumberType( int type ) | 1748 | int Addressee::hasPhoneNumberType( int type ) |
1702 | { | 1749 | { |
1703 | int retval = 0; | 1750 | int retval = 0; |
1704 | PhoneNumber::List::ConstIterator it; | 1751 | PhoneNumber::List::ConstIterator it; |
1705 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1752 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1706 | if ( (*it).type() == type ) | 1753 | if ( (*it).type() == type ) |
1707 | ++retval; | 1754 | ++retval; |
1708 | } | 1755 | } |
1709 | return retval; | 1756 | return retval; |
1710 | } | 1757 | } |
1711 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1758 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1712 | { | 1759 | { |
1713 | PhoneNumber::List list; | 1760 | PhoneNumber::List list; |
1714 | 1761 | ||
1715 | PhoneNumber::List::ConstIterator it; | 1762 | PhoneNumber::List::ConstIterator it; |
1716 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1763 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1717 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1764 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1718 | list.append( *it ); | 1765 | list.append( *it ); |
1719 | } | 1766 | } |
1720 | } | 1767 | } |
1721 | return list; | 1768 | return list; |
1722 | } | 1769 | } |
1770 | QString Addressee::phoneNumberString( int type ) const | ||
1771 | { | ||
1772 | |||
1773 | PhoneNumber::List::ConstIterator it; | ||
1774 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | ||
1775 | if ((*it).type() == type ) { | ||
1776 | return ( *it ).number(); | ||
1777 | } | ||
1778 | } | ||
1779 | return ""; | ||
1780 | } | ||
1723 | 1781 | ||
1724 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1782 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1725 | { | 1783 | { |
1726 | PhoneNumber::List::ConstIterator it; | 1784 | PhoneNumber::List::ConstIterator it; |
1727 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1785 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1728 | if ( (*it).id() == id ) { | 1786 | if ( (*it).id() == id ) { |
1729 | return *it; | 1787 | return *it; |
1730 | } | 1788 | } |
1731 | } | 1789 | } |
1732 | return PhoneNumber(); | 1790 | return PhoneNumber(); |
1733 | } | 1791 | } |
1734 | 1792 | ||
1735 | void Addressee::insertKey( const Key &key ) | 1793 | void Addressee::insertKey( const Key &key ) |
1736 | { | 1794 | { |
1737 | detach(); | 1795 | detach(); |
1738 | mData->empty = false; | 1796 | mData->empty = false; |
1739 | 1797 | ||
1740 | Key::List::Iterator it; | 1798 | Key::List::Iterator it; |
1741 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1799 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1742 | if ( (*it).id() == key.id() ) { | 1800 | if ( (*it).id() == key.id() ) { |
1743 | *it = key; | 1801 | *it = key; |
1744 | return; | 1802 | return; |
1745 | } | 1803 | } |
1746 | } | 1804 | } |
1747 | mData->keys.append( key ); | 1805 | mData->keys.append( key ); |
1748 | } | 1806 | } |
1749 | 1807 | ||
1750 | void Addressee::removeKey( const Key &key ) | 1808 | void Addressee::removeKey( const Key &key ) |
1751 | { | 1809 | { |
1752 | detach(); | 1810 | detach(); |
1753 | 1811 | ||
1754 | Key::List::Iterator it; | 1812 | Key::List::Iterator it; |
1755 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1813 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1756 | if ( (*it).id() == key.id() ) { | 1814 | if ( (*it).id() == key.id() ) { |
1757 | mData->keys.remove( key ); | 1815 | mData->keys.remove( key ); |
1758 | return; | 1816 | return; |
1759 | } | 1817 | } |
1760 | } | 1818 | } |
1761 | } | 1819 | } |
1762 | 1820 | ||
1763 | Key Addressee::key( int type, QString customTypeString ) const | 1821 | Key Addressee::key( int type, QString customTypeString ) const |
1764 | { | 1822 | { |
1765 | Key::List::ConstIterator it; | 1823 | Key::List::ConstIterator it; |
1766 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1824 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1767 | if ( (*it).type() == type ) { | 1825 | if ( (*it).type() == type ) { |
1768 | if ( type == Key::Custom ) { | 1826 | if ( type == Key::Custom ) { |
1769 | if ( customTypeString.isEmpty() ) { | 1827 | if ( customTypeString.isEmpty() ) { |
1770 | return *it; | 1828 | return *it; |
1771 | } else { | 1829 | } else { |
1772 | if ( (*it).customTypeString() == customTypeString ) | 1830 | if ( (*it).customTypeString() == customTypeString ) |
1773 | return (*it); | 1831 | return (*it); |
1774 | } | 1832 | } |
1775 | } else { | 1833 | } else { |
1776 | return *it; | 1834 | return *it; |
1777 | } | 1835 | } |
1778 | } | 1836 | } |
1779 | } | 1837 | } |
1780 | return Key( QString(), type ); | 1838 | return Key( QString(), type ); |
1781 | } | 1839 | } |
1782 | void Addressee::setKeys( const Key::List& list ) { | 1840 | void Addressee::setKeys( const Key::List& list ) { |
1783 | detach(); | 1841 | detach(); |
1784 | mData->keys = list; | 1842 | mData->keys = list; |
1785 | } | 1843 | } |
1786 | 1844 | ||
1787 | Key::List Addressee::keys() const | 1845 | Key::List Addressee::keys() const |
1788 | { | 1846 | { |
1789 | return mData->keys; | 1847 | return mData->keys; |
1790 | } | 1848 | } |
1791 | 1849 | ||
1792 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1850 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1793 | { | 1851 | { |
1794 | Key::List list; | 1852 | Key::List list; |
1795 | 1853 | ||
1796 | Key::List::ConstIterator it; | 1854 | Key::List::ConstIterator it; |
1797 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1855 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1798 | if ( (*it).type() == type ) { | 1856 | if ( (*it).type() == type ) { |
1799 | if ( type == Key::Custom ) { | 1857 | if ( type == Key::Custom ) { |
1800 | if ( customTypeString.isEmpty() ) { | 1858 | if ( customTypeString.isEmpty() ) { |
1801 | list.append(*it); | 1859 | list.append(*it); |
1802 | } else { | 1860 | } else { |
1803 | if ( (*it).customTypeString() == customTypeString ) | 1861 | if ( (*it).customTypeString() == customTypeString ) |
1804 | list.append(*it); | 1862 | list.append(*it); |
1805 | } | 1863 | } |
1806 | } else { | 1864 | } else { |
1807 | list.append(*it); | 1865 | list.append(*it); |
1808 | } | 1866 | } |
1809 | } | 1867 | } |
1810 | } | 1868 | } |
1811 | return list; | 1869 | return list; |
1812 | } | 1870 | } |
1813 | 1871 | ||
1814 | Key Addressee::findKey( const QString &id ) const | 1872 | Key Addressee::findKey( const QString &id ) const |
1815 | { | 1873 | { |
1816 | Key::List::ConstIterator it; | 1874 | Key::List::ConstIterator it; |
1817 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1875 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1818 | if ( (*it).id() == id ) { | 1876 | if ( (*it).id() == id ) { |
1819 | return *it; | 1877 | return *it; |
1820 | } | 1878 | } |
1821 | } | 1879 | } |
1822 | return Key(); | 1880 | return Key(); |
1823 | } | 1881 | } |
1824 | 1882 | ||
1825 | QString Addressee::asString() const | 1883 | QString Addressee::asString() const |
1826 | { | 1884 | { |
1827 | return "Smith, agent Smith..."; | 1885 | return "Smith, agent Smith..."; |
1828 | } | 1886 | } |
1829 | 1887 | ||
1830 | void Addressee::dump() const | 1888 | void Addressee::dump() const |
1831 | { | 1889 | { |
1832 | return; | 1890 | return; |
1833 | #if 0 | 1891 | #if 0 |
1834 | kdDebug(5700) << "Addressee {" << endl; | 1892 | kdDebug(5700) << "Addressee {" << endl; |
1835 | 1893 | ||
1836 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1894 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1837 | 1895 | ||
1838 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1896 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1839 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1897 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1840 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1898 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1841 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1899 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1842 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1900 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1843 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1901 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1844 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1902 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1845 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1903 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1846 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1904 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1847 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1905 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1848 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1906 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1849 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1907 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1850 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1908 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1851 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1909 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1852 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1910 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1853 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1911 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1854 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1912 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1855 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1913 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1856 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1914 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1857 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1915 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1858 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1916 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1859 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1917 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1860 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1918 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1861 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1919 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1862 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1920 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1863 | 1921 | ||
1864 | kdDebug(5700) << " Emails {" << endl; | 1922 | kdDebug(5700) << " Emails {" << endl; |
1865 | QStringList e = emails(); | 1923 | QStringList e = emails(); |
1866 | QStringList::ConstIterator it; | 1924 | QStringList::ConstIterator it; |
1867 | for( it = e.begin(); it != e.end(); ++it ) { | 1925 | for( it = e.begin(); it != e.end(); ++it ) { |
1868 | kdDebug(5700) << " " << (*it) << endl; | 1926 | kdDebug(5700) << " " << (*it) << endl; |
1869 | } | 1927 | } |
1870 | kdDebug(5700) << " }" << endl; | 1928 | kdDebug(5700) << " }" << endl; |
1871 | 1929 | ||
1872 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1930 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1873 | PhoneNumber::List p = phoneNumbers(); | 1931 | PhoneNumber::List p = phoneNumbers(); |
1874 | PhoneNumber::List::ConstIterator it2; | 1932 | PhoneNumber::List::ConstIterator it2; |
1875 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1933 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1876 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1934 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1877 | } | 1935 | } |
1878 | kdDebug(5700) << " }" << endl; | 1936 | kdDebug(5700) << " }" << endl; |
1879 | 1937 | ||
1880 | Address::List a = addresses(); | 1938 | Address::List a = addresses(); |
1881 | Address::List::ConstIterator it3; | 1939 | Address::List::ConstIterator it3; |
1882 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1940 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1883 | (*it3).dump(); | 1941 | (*it3).dump(); |
1884 | } | 1942 | } |
1885 | 1943 | ||
1886 | kdDebug(5700) << " Keys {" << endl; | 1944 | kdDebug(5700) << " Keys {" << endl; |
1887 | Key::List k = keys(); | 1945 | Key::List k = keys(); |
1888 | Key::List::ConstIterator it4; | 1946 | Key::List::ConstIterator it4; |
1889 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1947 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1890 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1948 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1891 | " Key: " << (*it4).textData() << | 1949 | " Key: " << (*it4).textData() << |
1892 | " CustomString: " << (*it4).customTypeString() << endl; | 1950 | " CustomString: " << (*it4).customTypeString() << endl; |
1893 | } | 1951 | } |
1894 | kdDebug(5700) << " }" << endl; | 1952 | kdDebug(5700) << " }" << endl; |
1895 | 1953 | ||
1896 | kdDebug(5700) << "}" << endl; | 1954 | kdDebug(5700) << "}" << endl; |
1897 | #endif | 1955 | #endif |
1898 | } | 1956 | } |
1899 | 1957 | ||
1900 | 1958 | ||
1901 | void Addressee::insertAddress( const Address &address ) | 1959 | void Addressee::insertAddress( const Address &address ) |
1902 | { | 1960 | { |
1903 | detach(); | 1961 | detach(); |
1904 | mData->empty = false; | 1962 | mData->empty = false; |
1905 | 1963 | ||
1906 | Address::List::Iterator it; | 1964 | Address::List::Iterator it; |
1907 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1965 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1908 | if ( (*it).id() == address.id() ) { | 1966 | if ( (*it).id() == address.id() ) { |
1909 | *it = address; | 1967 | *it = address; |
1910 | return; | 1968 | return; |
1911 | } | 1969 | } |
1912 | } | 1970 | } |
1913 | mData->addresses.append( address ); | 1971 | mData->addresses.append( address ); |
1914 | } | 1972 | } |
1915 | 1973 | ||
1916 | void Addressee::removeAddress( const Address &address ) | 1974 | void Addressee::removeAddress( const Address &address ) |
1917 | { | 1975 | { |
1918 | detach(); | 1976 | detach(); |
1919 | 1977 | ||
1920 | Address::List::Iterator it; | 1978 | Address::List::Iterator it; |
1921 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1979 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1922 | if ( (*it).id() == address.id() ) { | 1980 | if ( (*it).id() == address.id() ) { |
1923 | mData->addresses.remove( it ); | 1981 | mData->addresses.remove( it ); |
1924 | return; | 1982 | return; |
1925 | } | 1983 | } |
1926 | } | 1984 | } |
1927 | } | 1985 | } |
1928 | 1986 | Address Addressee::otherAddress() const | |
1987 | { | ||
1988 | Address::List::ConstIterator it; | ||
1989 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | ||
1990 | if ( matchBinaryPatternA( (*it).type(), KABC::Address::Work ) ) | ||
1991 | continue; | ||
1992 | if ( matchBinaryPatternA( (*it).type(), KABC::Address::Home ) ) | ||
1993 | continue; | ||
1994 | return (*it); | ||
1995 | } | ||
1996 | return Address(); | ||
1997 | } | ||
1929 | Address Addressee::address( int type ) const | 1998 | Address Addressee::address( int type ) const |
1930 | { | 1999 | { |
1931 | Address address( type ); | 2000 | Address address( type ); |
1932 | Address::List::ConstIterator it; | 2001 | Address::List::ConstIterator it; |
1933 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 2002 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1934 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 2003 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1935 | if ( (*it).type() & Address::Pref ) | 2004 | if ( (*it).type() & Address::Pref ) |
1936 | return (*it); | 2005 | return (*it); |
1937 | else if ( address.isEmpty() ) | 2006 | else if ( address.isEmpty() ) |
1938 | address = (*it); | 2007 | address = (*it); |
1939 | } | 2008 | } |
1940 | } | 2009 | } |
1941 | 2010 | ||
1942 | return address; | 2011 | return address; |
1943 | } | 2012 | } |
1944 | 2013 | ||
1945 | Address::List Addressee::addresses() const | 2014 | Address::List Addressee::addresses() const |
1946 | { | 2015 | { |
1947 | return mData->addresses; | 2016 | return mData->addresses; |
1948 | } | 2017 | } |
1949 | 2018 | ||
1950 | Address::List Addressee::addresses( int type ) const | 2019 | Address::List Addressee::addresses( int type ) const |
1951 | { | 2020 | { |
1952 | Address::List list; | 2021 | Address::List list; |
1953 | 2022 | ||
1954 | Address::List::ConstIterator it; | 2023 | Address::List::ConstIterator it; |
1955 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 2024 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1956 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 2025 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1957 | list.append( *it ); | 2026 | list.append( *it ); |
1958 | } | 2027 | } |
1959 | } | 2028 | } |
1960 | 2029 | ||
1961 | return list; | 2030 | return list; |
1962 | } | 2031 | } |
1963 | 2032 | ||
1964 | Address Addressee::findAddress( const QString &id ) const | 2033 | Address Addressee::findAddress( const QString &id ) const |
1965 | { | 2034 | { |
1966 | Address::List::ConstIterator it; | 2035 | Address::List::ConstIterator it; |
1967 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 2036 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1968 | if ( (*it).id() == id ) { | 2037 | if ( (*it).id() == id ) { |
1969 | return *it; | 2038 | return *it; |
1970 | } | 2039 | } |
1971 | } | 2040 | } |
1972 | return Address(); | 2041 | return Address(); |
1973 | } | 2042 | } |
1974 | 2043 | ||
1975 | void Addressee::insertCategory( const QString &c ) | 2044 | void Addressee::insertCategory( const QString &c ) |
1976 | { | 2045 | { |
1977 | detach(); | 2046 | detach(); |
1978 | mData->empty = false; | 2047 | mData->empty = false; |
1979 | 2048 | ||
1980 | if ( mData->categories.contains( c ) ) return; | 2049 | if ( mData->categories.contains( c ) ) return; |
1981 | 2050 | ||
1982 | mData->categories.append( c ); | 2051 | mData->categories.append( c ); |
1983 | } | 2052 | } |
1984 | 2053 | ||
1985 | void Addressee::removeCategory( const QString &c ) | 2054 | void Addressee::removeCategory( const QString &c ) |
1986 | { | 2055 | { |
1987 | detach(); | 2056 | detach(); |
1988 | 2057 | ||
1989 | QStringList::Iterator it = mData->categories.find( c ); | 2058 | QStringList::Iterator it = mData->categories.find( c ); |
1990 | if ( it == mData->categories.end() ) return; | 2059 | if ( it == mData->categories.end() ) return; |
1991 | 2060 | ||
1992 | mData->categories.remove( it ); | 2061 | mData->categories.remove( it ); |
1993 | } | 2062 | } |
1994 | 2063 | ||
1995 | bool Addressee::hasCategory( const QString &c ) const | 2064 | bool Addressee::hasCategory( const QString &c ) const |
1996 | { | 2065 | { |
1997 | return ( mData->categories.contains( c ) ); | 2066 | return ( mData->categories.contains( c ) ); |
1998 | } | 2067 | } |
1999 | 2068 | ||
2000 | void Addressee::setCategories( const QStringList &c ) | 2069 | void Addressee::setCategories( const QStringList &c ) |
2001 | { | 2070 | { |
2002 | detach(); | 2071 | detach(); |
2003 | mData->empty = false; | 2072 | mData->empty = false; |
2004 | 2073 | ||
2005 | mData->categories = c; | 2074 | mData->categories = c; |
2006 | } | 2075 | } |
2007 | 2076 | ||
2008 | QStringList Addressee::categories() const | 2077 | QStringList Addressee::categories() const |
2009 | { | 2078 | { |
2010 | return mData->categories; | 2079 | return mData->categories; |
2011 | } | 2080 | } |
2012 | 2081 | ||
2013 | void Addressee::insertCustom( const QString &app, const QString &name, | 2082 | void Addressee::insertCustom( const QString &app, const QString &name, |
2014 | const QString &value ) | 2083 | const QString &value ) |
2015 | { | 2084 | { |
2016 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 2085 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
2017 | 2086 | ||
2018 | detach(); | 2087 | detach(); |
2019 | mData->empty = false; | 2088 | mData->empty = false; |
2020 | 2089 | ||
2021 | QString qualifiedName = app + "-" + name + ":"; | 2090 | QString qualifiedName = app + "-" + name + ":"; |
2022 | 2091 | ||
2023 | QStringList::Iterator it; | 2092 | QStringList::Iterator it; |
2024 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 2093 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
2025 | if ( (*it).startsWith( qualifiedName ) ) { | 2094 | if ( (*it).startsWith( qualifiedName ) ) { |
2026 | (*it) = qualifiedName + value; | 2095 | (*it) = qualifiedName + value; |
2027 | return; | 2096 | return; |
2028 | } | 2097 | } |
2029 | } | 2098 | } |
2030 | mData->custom.append( qualifiedName + value ); | 2099 | mData->custom.append( qualifiedName + value ); |
2031 | } | 2100 | } |
2032 | 2101 | ||
2033 | void Addressee::removeCustom( const QString &app, const QString &name) | 2102 | void Addressee::removeCustom( const QString &app, const QString &name) |
2034 | { | 2103 | { |
2035 | detach(); | 2104 | detach(); |
2036 | 2105 | ||
2037 | QString qualifiedName = app + "-" + name + ":"; | 2106 | QString qualifiedName = app + "-" + name + ":"; |
2038 | 2107 | ||
2039 | QStringList::Iterator it; | 2108 | QStringList::Iterator it; |
2040 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 2109 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
2041 | if ( (*it).startsWith( qualifiedName ) ) { | 2110 | if ( (*it).startsWith( qualifiedName ) ) { |
2042 | mData->custom.remove( it ); | 2111 | mData->custom.remove( it ); |
2043 | return; | 2112 | return; |
2044 | } | 2113 | } |
2045 | } | 2114 | } |
2046 | } | 2115 | } |
2047 | 2116 | ||
2048 | QString Addressee::custom( const QString &app, const QString &name ) const | 2117 | QString Addressee::custom( const QString &app, const QString &name ) const |
2049 | { | 2118 | { |
2050 | QString qualifiedName = app + "-" + name + ":"; | 2119 | QString qualifiedName = app + "-" + name + ":"; |
2051 | QString value; | 2120 | QString value; |
2052 | 2121 | ||
2053 | QStringList::ConstIterator it; | 2122 | QStringList::ConstIterator it; |
2054 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 2123 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
2055 | if ( (*it).startsWith( qualifiedName ) ) { | 2124 | if ( (*it).startsWith( qualifiedName ) ) { |
2056 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 2125 | value = (*it).mid( (*it).find( ":" ) + 1 ); |