author | ulf69 <ulf69> | 2004-09-09 18:57:57 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-09 18:57:57 (UTC) |
commit | 880518b6f1d4b06e3df45224c244d9c62f6fb7a9 (patch) (unidiff) | |
tree | 2b0b5a0c7e40481c31f29ff2bd98aa6abb4c6c90 | |
parent | 72860f2b84ba97de9223238d9fb97edc0804cc68 (diff) | |
download | kdepimpi-880518b6f1d4b06e3df45224c244d9c62f6fb7a9.zip kdepimpi-880518b6f1d4b06e3df45224c244d9c62f6fb7a9.tar.gz kdepimpi-880518b6f1d4b06e3df45224c244d9c62f6fb7a9.tar.bz2 |
added sip type to phonnumbers
-rw-r--r-- | kabc/addressee.cpp | 4 | ||||
-rw-r--r-- | kabc/addressee.h | 5 | ||||
-rw-r--r-- | kabc/field.cpp | 8 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 4 | ||||
-rw-r--r-- | kabc/phonenumber.h | 3 | ||||
-rw-r--r-- | kabc/vcard21parser.cpp | 5 | ||||
-rw-r--r-- | kabc/vcard21parser.h | 1 | ||||
-rw-r--r-- | kabc/vcardformatimpl.cpp | 2 | ||||
-rw-r--r-- | kabc/vcardparser/vcardtool.cpp | 1 |
9 files changed, 29 insertions, 4 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index d484073..6b282e2 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1622 +1,1626 @@ | |||
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 | //US | 35 | //US |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | //US #include "resource.h" | 38 | //US #include "resource.h" |
39 | #include "addressee.h" | 39 | #include "addressee.h" |
40 | 40 | ||
41 | using namespace KABC; | 41 | using namespace KABC; |
42 | 42 | ||
43 | static bool matchBinaryPattern( int value, int pattern ); | 43 | static bool matchBinaryPattern( int value, int pattern ); |
44 | 44 | ||
45 | struct Addressee::AddresseeData : public KShared | 45 | struct Addressee::AddresseeData : public KShared |
46 | { | 46 | { |
47 | QString uid; | 47 | QString uid; |
48 | QString name; | 48 | QString name; |
49 | QString formattedName; | 49 | QString formattedName; |
50 | QString familyName; | 50 | QString familyName; |
51 | QString givenName; | 51 | QString givenName; |
52 | QString additionalName; | 52 | QString additionalName; |
53 | QString prefix; | 53 | QString prefix; |
54 | QString suffix; | 54 | QString suffix; |
55 | QString nickName; | 55 | QString nickName; |
56 | QDateTime birthday; | 56 | QDateTime birthday; |
57 | QString mailer; | 57 | QString mailer; |
58 | TimeZone timeZone; | 58 | TimeZone timeZone; |
59 | Geo geo; | 59 | Geo geo; |
60 | QString title; | 60 | QString title; |
61 | QString role; | 61 | QString role; |
62 | QString organization; | 62 | QString organization; |
63 | QString note; | 63 | QString note; |
64 | QString productId; | 64 | QString productId; |
65 | QDateTime revision; | 65 | QDateTime revision; |
66 | QString sortString; | 66 | QString sortString; |
67 | KURL url; | 67 | KURL url; |
68 | Secrecy secrecy; | 68 | Secrecy secrecy; |
69 | Picture logo; | 69 | Picture logo; |
70 | Picture photo; | 70 | Picture photo; |
71 | Sound sound; | 71 | Sound sound; |
72 | Agent agent; | 72 | Agent agent; |
73 | 73 | ||
74 | PhoneNumber::List phoneNumbers; | 74 | PhoneNumber::List phoneNumbers; |
75 | Address::List addresses; | 75 | Address::List addresses; |
76 | Key::List keys; | 76 | Key::List keys; |
77 | QStringList emails; | 77 | QStringList emails; |
78 | QStringList categories; | 78 | QStringList categories; |
79 | QStringList custom; | 79 | QStringList custom; |
80 | 80 | ||
81 | Resource *resource; | 81 | Resource *resource; |
82 | 82 | ||
83 | bool empty :1; | 83 | bool empty :1; |
84 | bool changed :1; | 84 | bool changed :1; |
85 | }; | 85 | }; |
86 | 86 | ||
87 | Addressee::Addressee() | 87 | Addressee::Addressee() |
88 | { | 88 | { |
89 | mData = new AddresseeData; | 89 | mData = new AddresseeData; |
90 | mData->empty = true; | 90 | mData->empty = true; |
91 | mData->changed = false; | 91 | mData->changed = false; |
92 | mData->resource = 0; | 92 | mData->resource = 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | Addressee::~Addressee() | 95 | Addressee::~Addressee() |
96 | { | 96 | { |
97 | } | 97 | } |
98 | 98 | ||
99 | Addressee::Addressee( const Addressee &a ) | 99 | Addressee::Addressee( const Addressee &a ) |
100 | { | 100 | { |
101 | mData = a.mData; | 101 | mData = a.mData; |
102 | } | 102 | } |
103 | 103 | ||
104 | Addressee &Addressee::operator=( const Addressee &a ) | 104 | Addressee &Addressee::operator=( const Addressee &a ) |
105 | { | 105 | { |
106 | mData = a.mData; | 106 | mData = a.mData; |
107 | return (*this); | 107 | return (*this); |
108 | } | 108 | } |
109 | 109 | ||
110 | Addressee Addressee::copy() | 110 | Addressee Addressee::copy() |
111 | { | 111 | { |
112 | Addressee a; | 112 | Addressee a; |
113 | *(a.mData) = *mData; | 113 | *(a.mData) = *mData; |
114 | return a; | 114 | return a; |
115 | } | 115 | } |
116 | 116 | ||
117 | void Addressee::detach() | 117 | void Addressee::detach() |
118 | { | 118 | { |
119 | if ( mData.count() == 1 ) return; | 119 | if ( mData.count() == 1 ) return; |
120 | *this = copy(); | 120 | *this = copy(); |
121 | } | 121 | } |
122 | 122 | ||
123 | bool Addressee::operator==( const Addressee &a ) const | 123 | bool Addressee::operator==( const Addressee &a ) const |
124 | { | 124 | { |
125 | if ( uid() != a.uid() ) return false; | 125 | if ( uid() != a.uid() ) return false; |
126 | if ( mData->name != a.mData->name ) return false; | 126 | if ( mData->name != a.mData->name ) return false; |
127 | if ( mData->formattedName != a.mData->formattedName ) return false; | 127 | if ( mData->formattedName != a.mData->formattedName ) return false; |
128 | if ( mData->familyName != a.mData->familyName ) return false; | 128 | if ( mData->familyName != a.mData->familyName ) return false; |
129 | if ( mData->givenName != a.mData->givenName ) return false; | 129 | if ( mData->givenName != a.mData->givenName ) return false; |
130 | if ( mData->additionalName != a.mData->additionalName ) return false; | 130 | if ( mData->additionalName != a.mData->additionalName ) return false; |
131 | if ( mData->prefix != a.mData->prefix ) return false; | 131 | if ( mData->prefix != a.mData->prefix ) return false; |
132 | if ( mData->suffix != a.mData->suffix ) return false; | 132 | if ( mData->suffix != a.mData->suffix ) return false; |
133 | if ( mData->nickName != a.mData->nickName ) return false; | 133 | if ( mData->nickName != a.mData->nickName ) return false; |
134 | if ( mData->birthday != a.mData->birthday ) return false; | 134 | if ( mData->birthday != a.mData->birthday ) return false; |
135 | if ( mData->mailer != a.mData->mailer ) return false; | 135 | if ( mData->mailer != a.mData->mailer ) return false; |
136 | if ( mData->timeZone != a.mData->timeZone ) return false; | 136 | if ( mData->timeZone != a.mData->timeZone ) return false; |
137 | if ( mData->geo != a.mData->geo ) return false; | 137 | if ( mData->geo != a.mData->geo ) return false; |
138 | if ( mData->title != a.mData->title ) return false; | 138 | if ( mData->title != a.mData->title ) return false; |
139 | if ( mData->role != a.mData->role ) return false; | 139 | if ( mData->role != a.mData->role ) return false; |
140 | if ( mData->organization != a.mData->organization ) return false; | 140 | if ( mData->organization != a.mData->organization ) return false; |
141 | if ( mData->note != a.mData->note ) return false; | 141 | if ( mData->note != a.mData->note ) return false; |
142 | if ( mData->productId != a.mData->productId ) return false; | 142 | if ( mData->productId != a.mData->productId ) return false; |
143 | if ( mData->revision != a.mData->revision ) return false; | 143 | if ( mData->revision != a.mData->revision ) return false; |
144 | if ( mData->sortString != a.mData->sortString ) return false; | 144 | if ( mData->sortString != a.mData->sortString ) return false; |
145 | if ( mData->secrecy != a.mData->secrecy ) return false; | 145 | if ( mData->secrecy != a.mData->secrecy ) return false; |
146 | if ( mData->logo != a.mData->logo ) return false; | 146 | if ( mData->logo != a.mData->logo ) return false; |
147 | if ( mData->photo != a.mData->photo ) return false; | 147 | if ( mData->photo != a.mData->photo ) return false; |
148 | if ( mData->sound != a.mData->sound ) return false; | 148 | if ( mData->sound != a.mData->sound ) return false; |
149 | if ( mData->agent != a.mData->agent ) return false; | 149 | if ( mData->agent != a.mData->agent ) return false; |
150 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 150 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
151 | ( mData->url != a.mData->url ) ) return false; | 151 | ( mData->url != a.mData->url ) ) return false; |
152 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 152 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
153 | if ( mData->addresses != a.mData->addresses ) return false; | 153 | if ( mData->addresses != a.mData->addresses ) return false; |
154 | if ( mData->keys != a.mData->keys ) return false; | 154 | if ( mData->keys != a.mData->keys ) return false; |
155 | if ( mData->emails != a.mData->emails ) return false; | 155 | if ( mData->emails != a.mData->emails ) return false; |
156 | if ( mData->categories != a.mData->categories ) return false; | 156 | if ( mData->categories != a.mData->categories ) return false; |
157 | if ( mData->custom != a.mData->custom ) return false; | 157 | if ( mData->custom != a.mData->custom ) return false; |
158 | 158 | ||
159 | return true; | 159 | return true; |
160 | } | 160 | } |
161 | 161 | ||
162 | bool Addressee::operator!=( const Addressee &a ) const | 162 | bool Addressee::operator!=( const Addressee &a ) const |
163 | { | 163 | { |
164 | return !( a == *this ); | 164 | return !( a == *this ); |
165 | } | 165 | } |
166 | 166 | ||
167 | bool Addressee::isEmpty() const | 167 | bool Addressee::isEmpty() const |
168 | { | 168 | { |
169 | return mData->empty; | 169 | return mData->empty; |
170 | } | 170 | } |
171 | 171 | ||
172 | void Addressee::setUid( const QString &id ) | 172 | void Addressee::setUid( const QString &id ) |
173 | { | 173 | { |
174 | if ( id == mData->uid ) return; | 174 | if ( id == mData->uid ) return; |
175 | detach(); | 175 | detach(); |
176 | mData->empty = false; | 176 | mData->empty = false; |
177 | mData->uid = id; | 177 | mData->uid = id; |
178 | } | 178 | } |
179 | 179 | ||
180 | QString Addressee::uid() const | 180 | QString Addressee::uid() const |
181 | { | 181 | { |
182 | if ( mData->uid.isEmpty() ) | 182 | if ( mData->uid.isEmpty() ) |
183 | mData->uid = KApplication::randomString( 10 ); | 183 | mData->uid = KApplication::randomString( 10 ); |
184 | 184 | ||
185 | return mData->uid; | 185 | return mData->uid; |
186 | } | 186 | } |
187 | 187 | ||
188 | QString Addressee::uidLabel() | 188 | QString Addressee::uidLabel() |
189 | { | 189 | { |
190 | return i18n("Unique Identifier"); | 190 | return i18n("Unique Identifier"); |
191 | } | 191 | } |
192 | 192 | ||
193 | void Addressee::setName( const QString &name ) | 193 | void Addressee::setName( const QString &name ) |
194 | { | 194 | { |
195 | if ( name == mData->name ) return; | 195 | if ( name == mData->name ) return; |
196 | detach(); | 196 | detach(); |
197 | mData->empty = false; | 197 | mData->empty = false; |
198 | mData->name = name; | 198 | mData->name = name; |
199 | } | 199 | } |
200 | 200 | ||
201 | QString Addressee::name() const | 201 | QString Addressee::name() const |
202 | { | 202 | { |
203 | return mData->name; | 203 | return mData->name; |
204 | } | 204 | } |
205 | 205 | ||
206 | QString Addressee::nameLabel() | 206 | QString Addressee::nameLabel() |
207 | { | 207 | { |
208 | return i18n("Name"); | 208 | return i18n("Name"); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | void Addressee::setFormattedName( const QString &formattedName ) | 212 | void Addressee::setFormattedName( const QString &formattedName ) |
213 | { | 213 | { |
214 | if ( formattedName == mData->formattedName ) return; | 214 | if ( formattedName == mData->formattedName ) return; |
215 | detach(); | 215 | detach(); |
216 | mData->empty = false; | 216 | mData->empty = false; |
217 | mData->formattedName = formattedName; | 217 | mData->formattedName = formattedName; |
218 | } | 218 | } |
219 | 219 | ||
220 | QString Addressee::formattedName() const | 220 | QString Addressee::formattedName() const |
221 | { | 221 | { |
222 | return mData->formattedName; | 222 | return mData->formattedName; |
223 | } | 223 | } |
224 | 224 | ||
225 | QString Addressee::formattedNameLabel() | 225 | QString Addressee::formattedNameLabel() |
226 | { | 226 | { |
227 | return i18n("Formatted Name"); | 227 | return i18n("Formatted Name"); |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
231 | void Addressee::setFamilyName( const QString &familyName ) | 231 | void Addressee::setFamilyName( const QString &familyName ) |
232 | { | 232 | { |
233 | if ( familyName == mData->familyName ) return; | 233 | if ( familyName == mData->familyName ) return; |
234 | detach(); | 234 | detach(); |
235 | mData->empty = false; | 235 | mData->empty = false; |
236 | mData->familyName = familyName; | 236 | mData->familyName = familyName; |
237 | } | 237 | } |
238 | 238 | ||
239 | QString Addressee::familyName() const | 239 | QString Addressee::familyName() const |
240 | { | 240 | { |
241 | return mData->familyName; | 241 | return mData->familyName; |
242 | } | 242 | } |
243 | 243 | ||
244 | QString Addressee::familyNameLabel() | 244 | QString Addressee::familyNameLabel() |
245 | { | 245 | { |
246 | return i18n("Family Name"); | 246 | return i18n("Family Name"); |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | void Addressee::setGivenName( const QString &givenName ) | 250 | void Addressee::setGivenName( const QString &givenName ) |
251 | { | 251 | { |
252 | if ( givenName == mData->givenName ) return; | 252 | if ( givenName == mData->givenName ) return; |
253 | detach(); | 253 | detach(); |
254 | mData->empty = false; | 254 | mData->empty = false; |
255 | mData->givenName = givenName; | 255 | mData->givenName = givenName; |
256 | } | 256 | } |
257 | 257 | ||
258 | QString Addressee::givenName() const | 258 | QString Addressee::givenName() const |
259 | { | 259 | { |
260 | return mData->givenName; | 260 | return mData->givenName; |
261 | } | 261 | } |
262 | 262 | ||
263 | QString Addressee::givenNameLabel() | 263 | QString Addressee::givenNameLabel() |
264 | { | 264 | { |
265 | return i18n("Given Name"); | 265 | return i18n("Given Name"); |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | void Addressee::setAdditionalName( const QString &additionalName ) | 269 | void Addressee::setAdditionalName( const QString &additionalName ) |
270 | { | 270 | { |
271 | if ( additionalName == mData->additionalName ) return; | 271 | if ( additionalName == mData->additionalName ) return; |
272 | detach(); | 272 | detach(); |
273 | mData->empty = false; | 273 | mData->empty = false; |
274 | mData->additionalName = additionalName; | 274 | mData->additionalName = additionalName; |
275 | } | 275 | } |
276 | 276 | ||
277 | QString Addressee::additionalName() const | 277 | QString Addressee::additionalName() const |
278 | { | 278 | { |
279 | return mData->additionalName; | 279 | return mData->additionalName; |
280 | } | 280 | } |
281 | 281 | ||
282 | QString Addressee::additionalNameLabel() | 282 | QString Addressee::additionalNameLabel() |
283 | { | 283 | { |
284 | return i18n("Additional Names"); | 284 | return i18n("Additional Names"); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | void Addressee::setPrefix( const QString &prefix ) | 288 | void Addressee::setPrefix( const QString &prefix ) |
289 | { | 289 | { |
290 | if ( prefix == mData->prefix ) return; | 290 | if ( prefix == mData->prefix ) return; |
291 | detach(); | 291 | detach(); |
292 | mData->empty = false; | 292 | mData->empty = false; |
293 | mData->prefix = prefix; | 293 | mData->prefix = prefix; |
294 | } | 294 | } |
295 | 295 | ||
296 | QString Addressee::prefix() const | 296 | QString Addressee::prefix() const |
297 | { | 297 | { |
298 | return mData->prefix; | 298 | return mData->prefix; |
299 | } | 299 | } |
300 | 300 | ||
301 | QString Addressee::prefixLabel() | 301 | QString Addressee::prefixLabel() |
302 | { | 302 | { |
303 | return i18n("Honorific Prefixes"); | 303 | return i18n("Honorific Prefixes"); |
304 | } | 304 | } |
305 | 305 | ||
306 | 306 | ||
307 | void Addressee::setSuffix( const QString &suffix ) | 307 | void Addressee::setSuffix( const QString &suffix ) |
308 | { | 308 | { |
309 | if ( suffix == mData->suffix ) return; | 309 | if ( suffix == mData->suffix ) return; |
310 | detach(); | 310 | detach(); |
311 | mData->empty = false; | 311 | mData->empty = false; |
312 | mData->suffix = suffix; | 312 | mData->suffix = suffix; |
313 | } | 313 | } |
314 | 314 | ||
315 | QString Addressee::suffix() const | 315 | QString Addressee::suffix() const |
316 | { | 316 | { |
317 | return mData->suffix; | 317 | return mData->suffix; |
318 | } | 318 | } |
319 | 319 | ||
320 | QString Addressee::suffixLabel() | 320 | QString Addressee::suffixLabel() |
321 | { | 321 | { |
322 | return i18n("Honorific Suffixes"); | 322 | return i18n("Honorific Suffixes"); |
323 | } | 323 | } |
324 | 324 | ||
325 | 325 | ||
326 | void Addressee::setNickName( const QString &nickName ) | 326 | void Addressee::setNickName( const QString &nickName ) |
327 | { | 327 | { |
328 | if ( nickName == mData->nickName ) return; | 328 | if ( nickName == mData->nickName ) return; |
329 | detach(); | 329 | detach(); |
330 | mData->empty = false; | 330 | mData->empty = false; |
331 | mData->nickName = nickName; | 331 | mData->nickName = nickName; |
332 | } | 332 | } |
333 | 333 | ||
334 | QString Addressee::nickName() const | 334 | QString Addressee::nickName() const |
335 | { | 335 | { |
336 | return mData->nickName; | 336 | return mData->nickName; |
337 | } | 337 | } |
338 | 338 | ||
339 | QString Addressee::nickNameLabel() | 339 | QString Addressee::nickNameLabel() |
340 | { | 340 | { |
341 | return i18n("Nick Name"); | 341 | return i18n("Nick Name"); |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | void Addressee::setBirthday( const QDateTime &birthday ) | 345 | void Addressee::setBirthday( const QDateTime &birthday ) |
346 | { | 346 | { |
347 | if ( birthday == mData->birthday ) return; | 347 | if ( birthday == mData->birthday ) return; |
348 | detach(); | 348 | detach(); |
349 | mData->empty = false; | 349 | mData->empty = false; |
350 | mData->birthday = birthday; | 350 | mData->birthday = birthday; |
351 | } | 351 | } |
352 | 352 | ||
353 | QDateTime Addressee::birthday() const | 353 | QDateTime Addressee::birthday() const |
354 | { | 354 | { |
355 | return mData->birthday; | 355 | return mData->birthday; |
356 | } | 356 | } |
357 | 357 | ||
358 | QString Addressee::birthdayLabel() | 358 | QString Addressee::birthdayLabel() |
359 | { | 359 | { |
360 | return i18n("Birthday"); | 360 | return i18n("Birthday"); |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | QString Addressee::homeAddressStreetLabel() | 364 | QString Addressee::homeAddressStreetLabel() |
365 | { | 365 | { |
366 | return i18n("Home Address Street"); | 366 | return i18n("Home Address Street"); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | QString Addressee::homeAddressLocalityLabel() | 370 | QString Addressee::homeAddressLocalityLabel() |
371 | { | 371 | { |
372 | return i18n("Home Address Locality"); | 372 | return i18n("Home Address Locality"); |
373 | } | 373 | } |
374 | 374 | ||
375 | 375 | ||
376 | QString Addressee::homeAddressRegionLabel() | 376 | QString Addressee::homeAddressRegionLabel() |
377 | { | 377 | { |
378 | return i18n("Home Address Region"); | 378 | return i18n("Home Address Region"); |
379 | } | 379 | } |
380 | 380 | ||
381 | 381 | ||
382 | QString Addressee::homeAddressPostalCodeLabel() | 382 | QString Addressee::homeAddressPostalCodeLabel() |
383 | { | 383 | { |
384 | return i18n("Home Address Postal Code"); | 384 | return i18n("Home Address Postal Code"); |
385 | } | 385 | } |
386 | 386 | ||
387 | 387 | ||
388 | QString Addressee::homeAddressCountryLabel() | 388 | QString Addressee::homeAddressCountryLabel() |
389 | { | 389 | { |
390 | return i18n("Home Address Country"); | 390 | return i18n("Home Address Country"); |
391 | } | 391 | } |
392 | 392 | ||
393 | 393 | ||
394 | QString Addressee::homeAddressLabelLabel() | 394 | QString Addressee::homeAddressLabelLabel() |
395 | { | 395 | { |
396 | return i18n("Home Address Label"); | 396 | return i18n("Home Address Label"); |
397 | } | 397 | } |
398 | 398 | ||
399 | 399 | ||
400 | QString Addressee::businessAddressStreetLabel() | 400 | QString Addressee::businessAddressStreetLabel() |
401 | { | 401 | { |
402 | return i18n("Business Address Street"); | 402 | return i18n("Business Address Street"); |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | QString Addressee::businessAddressLocalityLabel() | 406 | QString Addressee::businessAddressLocalityLabel() |
407 | { | 407 | { |
408 | return i18n("Business Address Locality"); | 408 | return i18n("Business Address Locality"); |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | QString Addressee::businessAddressRegionLabel() | 412 | QString Addressee::businessAddressRegionLabel() |
413 | { | 413 | { |
414 | return i18n("Business Address Region"); | 414 | return i18n("Business Address Region"); |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | QString Addressee::businessAddressPostalCodeLabel() | 418 | QString Addressee::businessAddressPostalCodeLabel() |
419 | { | 419 | { |
420 | return i18n("Business Address Postal Code"); | 420 | return i18n("Business Address Postal Code"); |
421 | } | 421 | } |
422 | 422 | ||
423 | 423 | ||
424 | QString Addressee::businessAddressCountryLabel() | 424 | QString Addressee::businessAddressCountryLabel() |
425 | { | 425 | { |
426 | return i18n("Business Address Country"); | 426 | return i18n("Business Address Country"); |
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | QString Addressee::businessAddressLabelLabel() | 430 | QString Addressee::businessAddressLabelLabel() |
431 | { | 431 | { |
432 | return i18n("Business Address Label"); | 432 | return i18n("Business Address Label"); |
433 | } | 433 | } |
434 | 434 | ||
435 | 435 | ||
436 | QString Addressee::homePhoneLabel() | 436 | QString Addressee::homePhoneLabel() |
437 | { | 437 | { |
438 | return i18n("Home Phone"); | 438 | return i18n("Home Phone"); |
439 | } | 439 | } |
440 | 440 | ||
441 | 441 | ||
442 | QString Addressee::businessPhoneLabel() | 442 | QString Addressee::businessPhoneLabel() |
443 | { | 443 | { |
444 | return i18n("Business Phone"); | 444 | return i18n("Business Phone"); |
445 | } | 445 | } |
446 | 446 | ||
447 | 447 | ||
448 | QString Addressee::mobilePhoneLabel() | 448 | QString Addressee::mobilePhoneLabel() |
449 | { | 449 | { |
450 | return i18n("Mobile Phone"); | 450 | return i18n("Mobile Phone"); |
451 | } | 451 | } |
452 | 452 | ||
453 | 453 | ||
454 | QString Addressee::homeFaxLabel() | 454 | QString Addressee::homeFaxLabel() |
455 | { | 455 | { |
456 | return i18n("Home Fax"); | 456 | return i18n("Home Fax"); |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | QString Addressee::businessFaxLabel() | 460 | QString Addressee::businessFaxLabel() |
461 | { | 461 | { |
462 | return i18n("Business Fax"); | 462 | return i18n("Business Fax"); |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | QString Addressee::carPhoneLabel() | 466 | QString Addressee::carPhoneLabel() |
467 | { | 467 | { |
468 | return i18n("Car Phone"); | 468 | return i18n("Car Phone"); |
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | QString Addressee::isdnLabel() | 472 | QString Addressee::isdnLabel() |
473 | { | 473 | { |
474 | return i18n("ISDN"); | 474 | return i18n("ISDN"); |
475 | } | 475 | } |
476 | 476 | ||
477 | 477 | ||
478 | QString Addressee::pagerLabel() | 478 | QString Addressee::pagerLabel() |
479 | { | 479 | { |
480 | return i18n("Pager"); | 480 | return i18n("Pager"); |
481 | } | 481 | } |
482 | 482 | ||
483 | QString Addressee::sipLabel() | ||
484 | { | ||
485 | return i18n("SIP"); | ||
486 | } | ||
483 | 487 | ||
484 | QString Addressee::emailLabel() | 488 | QString Addressee::emailLabel() |
485 | { | 489 | { |
486 | return i18n("Email Address"); | 490 | return i18n("Email Address"); |
487 | } | 491 | } |
488 | 492 | ||
489 | 493 | ||
490 | void Addressee::setMailer( const QString &mailer ) | 494 | void Addressee::setMailer( const QString &mailer ) |
491 | { | 495 | { |
492 | if ( mailer == mData->mailer ) return; | 496 | if ( mailer == mData->mailer ) return; |
493 | detach(); | 497 | detach(); |
494 | mData->empty = false; | 498 | mData->empty = false; |
495 | mData->mailer = mailer; | 499 | mData->mailer = mailer; |
496 | } | 500 | } |
497 | 501 | ||
498 | QString Addressee::mailer() const | 502 | QString Addressee::mailer() const |
499 | { | 503 | { |
500 | return mData->mailer; | 504 | return mData->mailer; |
501 | } | 505 | } |
502 | 506 | ||
503 | QString Addressee::mailerLabel() | 507 | QString Addressee::mailerLabel() |
504 | { | 508 | { |
505 | return i18n("Mail Client"); | 509 | return i18n("Mail Client"); |
506 | } | 510 | } |
507 | 511 | ||
508 | 512 | ||
509 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 513 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
510 | { | 514 | { |
511 | if ( timeZone == mData->timeZone ) return; | 515 | if ( timeZone == mData->timeZone ) return; |
512 | detach(); | 516 | detach(); |
513 | mData->empty = false; | 517 | mData->empty = false; |
514 | mData->timeZone = timeZone; | 518 | mData->timeZone = timeZone; |
515 | } | 519 | } |
516 | 520 | ||
517 | TimeZone Addressee::timeZone() const | 521 | TimeZone Addressee::timeZone() const |
518 | { | 522 | { |
519 | return mData->timeZone; | 523 | return mData->timeZone; |
520 | } | 524 | } |
521 | 525 | ||
522 | QString Addressee::timeZoneLabel() | 526 | QString Addressee::timeZoneLabel() |
523 | { | 527 | { |
524 | return i18n("Time Zone"); | 528 | return i18n("Time Zone"); |
525 | } | 529 | } |
526 | 530 | ||
527 | 531 | ||
528 | void Addressee::setGeo( const Geo &geo ) | 532 | void Addressee::setGeo( const Geo &geo ) |
529 | { | 533 | { |
530 | if ( geo == mData->geo ) return; | 534 | if ( geo == mData->geo ) return; |
531 | detach(); | 535 | detach(); |
532 | mData->empty = false; | 536 | mData->empty = false; |
533 | mData->geo = geo; | 537 | mData->geo = geo; |
534 | } | 538 | } |
535 | 539 | ||
536 | Geo Addressee::geo() const | 540 | Geo Addressee::geo() const |
537 | { | 541 | { |
538 | return mData->geo; | 542 | return mData->geo; |
539 | } | 543 | } |
540 | 544 | ||
541 | QString Addressee::geoLabel() | 545 | QString Addressee::geoLabel() |
542 | { | 546 | { |
543 | return i18n("Geographic Position"); | 547 | return i18n("Geographic Position"); |
544 | } | 548 | } |
545 | 549 | ||
546 | 550 | ||
547 | void Addressee::setTitle( const QString &title ) | 551 | void Addressee::setTitle( const QString &title ) |
548 | { | 552 | { |
549 | if ( title == mData->title ) return; | 553 | if ( title == mData->title ) return; |
550 | detach(); | 554 | detach(); |
551 | mData->empty = false; | 555 | mData->empty = false; |
552 | mData->title = title; | 556 | mData->title = title; |
553 | } | 557 | } |
554 | 558 | ||
555 | QString Addressee::title() const | 559 | QString Addressee::title() const |
556 | { | 560 | { |
557 | return mData->title; | 561 | return mData->title; |
558 | } | 562 | } |
559 | 563 | ||
560 | QString Addressee::titleLabel() | 564 | QString Addressee::titleLabel() |
561 | { | 565 | { |
562 | return i18n("Title"); | 566 | return i18n("Title"); |
563 | } | 567 | } |
564 | 568 | ||
565 | 569 | ||
566 | void Addressee::setRole( const QString &role ) | 570 | void Addressee::setRole( const QString &role ) |
567 | { | 571 | { |
568 | if ( role == mData->role ) return; | 572 | if ( role == mData->role ) return; |
569 | detach(); | 573 | detach(); |
570 | mData->empty = false; | 574 | mData->empty = false; |
571 | mData->role = role; | 575 | mData->role = role; |
572 | } | 576 | } |
573 | 577 | ||
574 | QString Addressee::role() const | 578 | QString Addressee::role() const |
575 | { | 579 | { |
576 | return mData->role; | 580 | return mData->role; |
577 | } | 581 | } |
578 | 582 | ||
579 | QString Addressee::roleLabel() | 583 | QString Addressee::roleLabel() |
580 | { | 584 | { |
581 | return i18n("Role"); | 585 | return i18n("Role"); |
582 | } | 586 | } |
583 | 587 | ||
584 | 588 | ||
585 | void Addressee::setOrganization( const QString &organization ) | 589 | void Addressee::setOrganization( const QString &organization ) |
586 | { | 590 | { |
587 | if ( organization == mData->organization ) return; | 591 | if ( organization == mData->organization ) return; |
588 | detach(); | 592 | detach(); |
589 | mData->empty = false; | 593 | mData->empty = false; |
590 | mData->organization = organization; | 594 | mData->organization = organization; |
591 | } | 595 | } |
592 | 596 | ||
593 | QString Addressee::organization() const | 597 | QString Addressee::organization() const |
594 | { | 598 | { |
595 | return mData->organization; | 599 | return mData->organization; |
596 | } | 600 | } |
597 | 601 | ||
598 | QString Addressee::organizationLabel() | 602 | QString Addressee::organizationLabel() |
599 | { | 603 | { |
600 | return i18n("Organization"); | 604 | return i18n("Organization"); |
601 | } | 605 | } |
602 | 606 | ||
603 | 607 | ||
604 | void Addressee::setNote( const QString ¬e ) | 608 | void Addressee::setNote( const QString ¬e ) |
605 | { | 609 | { |
606 | if ( note == mData->note ) return; | 610 | if ( note == mData->note ) return; |
607 | detach(); | 611 | detach(); |
608 | mData->empty = false; | 612 | mData->empty = false; |
609 | mData->note = note; | 613 | mData->note = note; |
610 | } | 614 | } |
611 | 615 | ||
612 | QString Addressee::note() const | 616 | QString Addressee::note() const |
613 | { | 617 | { |
614 | return mData->note; | 618 | return mData->note; |
615 | } | 619 | } |
616 | 620 | ||
617 | QString Addressee::noteLabel() | 621 | QString Addressee::noteLabel() |
618 | { | 622 | { |
619 | return i18n("Note"); | 623 | return i18n("Note"); |
620 | } | 624 | } |
621 | 625 | ||
622 | 626 | ||
623 | void Addressee::setProductId( const QString &productId ) | 627 | void Addressee::setProductId( const QString &productId ) |
624 | { | 628 | { |
625 | if ( productId == mData->productId ) return; | 629 | if ( productId == mData->productId ) return; |
626 | detach(); | 630 | detach(); |
627 | mData->empty = false; | 631 | mData->empty = false; |
628 | mData->productId = productId; | 632 | mData->productId = productId; |
629 | } | 633 | } |
630 | 634 | ||
631 | QString Addressee::productId() const | 635 | QString Addressee::productId() const |
632 | { | 636 | { |
633 | return mData->productId; | 637 | return mData->productId; |
634 | } | 638 | } |
635 | 639 | ||
636 | QString Addressee::productIdLabel() | 640 | QString Addressee::productIdLabel() |
637 | { | 641 | { |
638 | return i18n("Product Identifier"); | 642 | return i18n("Product Identifier"); |
639 | } | 643 | } |
640 | 644 | ||
641 | 645 | ||
642 | void Addressee::setRevision( const QDateTime &revision ) | 646 | void Addressee::setRevision( const QDateTime &revision ) |
643 | { | 647 | { |
644 | if ( revision == mData->revision ) return; | 648 | if ( revision == mData->revision ) return; |
645 | detach(); | 649 | detach(); |
646 | mData->empty = false; | 650 | mData->empty = false; |
647 | mData->revision = revision; | 651 | mData->revision = revision; |
648 | } | 652 | } |
649 | 653 | ||
650 | QDateTime Addressee::revision() const | 654 | QDateTime Addressee::revision() const |
651 | { | 655 | { |
652 | return mData->revision; | 656 | return mData->revision; |
653 | } | 657 | } |
654 | 658 | ||
655 | QString Addressee::revisionLabel() | 659 | QString Addressee::revisionLabel() |
656 | { | 660 | { |
657 | return i18n("Revision Date"); | 661 | return i18n("Revision Date"); |
658 | } | 662 | } |
659 | 663 | ||
660 | 664 | ||
661 | void Addressee::setSortString( const QString &sortString ) | 665 | void Addressee::setSortString( const QString &sortString ) |
662 | { | 666 | { |
663 | if ( sortString == mData->sortString ) return; | 667 | if ( sortString == mData->sortString ) return; |
664 | detach(); | 668 | detach(); |
665 | mData->empty = false; | 669 | mData->empty = false; |
666 | mData->sortString = sortString; | 670 | mData->sortString = sortString; |
667 | } | 671 | } |
668 | 672 | ||
669 | QString Addressee::sortString() const | 673 | QString Addressee::sortString() const |
670 | { | 674 | { |
671 | return mData->sortString; | 675 | return mData->sortString; |
672 | } | 676 | } |
673 | 677 | ||
674 | QString Addressee::sortStringLabel() | 678 | QString Addressee::sortStringLabel() |
675 | { | 679 | { |
676 | return i18n("Sort String"); | 680 | return i18n("Sort String"); |
677 | } | 681 | } |
678 | 682 | ||
679 | 683 | ||
680 | void Addressee::setUrl( const KURL &url ) | 684 | void Addressee::setUrl( const KURL &url ) |
681 | { | 685 | { |
682 | if ( url == mData->url ) return; | 686 | if ( url == mData->url ) return; |
683 | detach(); | 687 | detach(); |
684 | mData->empty = false; | 688 | mData->empty = false; |
685 | mData->url = url; | 689 | mData->url = url; |
686 | } | 690 | } |
687 | 691 | ||
688 | KURL Addressee::url() const | 692 | KURL Addressee::url() const |
689 | { | 693 | { |
690 | return mData->url; | 694 | return mData->url; |
691 | } | 695 | } |
692 | 696 | ||
693 | QString Addressee::urlLabel() | 697 | QString Addressee::urlLabel() |
694 | { | 698 | { |
695 | return i18n("URL"); | 699 | return i18n("URL"); |
696 | } | 700 | } |
697 | 701 | ||
698 | 702 | ||
699 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 703 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
700 | { | 704 | { |
701 | if ( secrecy == mData->secrecy ) return; | 705 | if ( secrecy == mData->secrecy ) return; |
702 | detach(); | 706 | detach(); |
703 | mData->empty = false; | 707 | mData->empty = false; |
704 | mData->secrecy = secrecy; | 708 | mData->secrecy = secrecy; |
705 | } | 709 | } |
706 | 710 | ||
707 | Secrecy Addressee::secrecy() const | 711 | Secrecy Addressee::secrecy() const |
708 | { | 712 | { |
709 | return mData->secrecy; | 713 | return mData->secrecy; |
710 | } | 714 | } |
711 | 715 | ||
712 | QString Addressee::secrecyLabel() | 716 | QString Addressee::secrecyLabel() |
713 | { | 717 | { |
714 | return i18n("Security Class"); | 718 | return i18n("Security Class"); |
715 | } | 719 | } |
716 | 720 | ||
717 | 721 | ||
718 | void Addressee::setLogo( const Picture &logo ) | 722 | void Addressee::setLogo( const Picture &logo ) |
719 | { | 723 | { |
720 | if ( logo == mData->logo ) return; | 724 | if ( logo == mData->logo ) return; |
721 | detach(); | 725 | detach(); |
722 | mData->empty = false; | 726 | mData->empty = false; |
723 | mData->logo = logo; | 727 | mData->logo = logo; |
724 | } | 728 | } |
725 | 729 | ||
726 | Picture Addressee::logo() const | 730 | Picture Addressee::logo() const |
727 | { | 731 | { |
728 | return mData->logo; | 732 | return mData->logo; |
729 | } | 733 | } |
730 | 734 | ||
731 | QString Addressee::logoLabel() | 735 | QString Addressee::logoLabel() |
732 | { | 736 | { |
733 | return i18n("Logo"); | 737 | return i18n("Logo"); |
734 | } | 738 | } |
735 | 739 | ||
736 | 740 | ||
737 | void Addressee::setPhoto( const Picture &photo ) | 741 | void Addressee::setPhoto( const Picture &photo ) |
738 | { | 742 | { |
739 | if ( photo == mData->photo ) return; | 743 | if ( photo == mData->photo ) return; |
740 | detach(); | 744 | detach(); |
741 | mData->empty = false; | 745 | mData->empty = false; |
742 | mData->photo = photo; | 746 | mData->photo = photo; |
743 | } | 747 | } |
744 | 748 | ||
745 | Picture Addressee::photo() const | 749 | Picture Addressee::photo() const |
746 | { | 750 | { |
747 | return mData->photo; | 751 | return mData->photo; |
748 | } | 752 | } |
749 | 753 | ||
750 | QString Addressee::photoLabel() | 754 | QString Addressee::photoLabel() |
751 | { | 755 | { |
752 | return i18n("Photo"); | 756 | return i18n("Photo"); |
753 | } | 757 | } |
754 | 758 | ||
755 | 759 | ||
756 | void Addressee::setSound( const Sound &sound ) | 760 | void Addressee::setSound( const Sound &sound ) |
757 | { | 761 | { |
758 | if ( sound == mData->sound ) return; | 762 | if ( sound == mData->sound ) return; |
759 | detach(); | 763 | detach(); |
760 | mData->empty = false; | 764 | mData->empty = false; |
761 | mData->sound = sound; | 765 | mData->sound = sound; |
762 | } | 766 | } |
763 | 767 | ||
764 | Sound Addressee::sound() const | 768 | Sound Addressee::sound() const |
765 | { | 769 | { |
766 | return mData->sound; | 770 | return mData->sound; |
767 | } | 771 | } |
768 | 772 | ||
769 | QString Addressee::soundLabel() | 773 | QString Addressee::soundLabel() |
770 | { | 774 | { |
771 | return i18n("Sound"); | 775 | return i18n("Sound"); |
772 | } | 776 | } |
773 | 777 | ||
774 | 778 | ||
775 | void Addressee::setAgent( const Agent &agent ) | 779 | void Addressee::setAgent( const Agent &agent ) |
776 | { | 780 | { |
777 | if ( agent == mData->agent ) return; | 781 | if ( agent == mData->agent ) return; |
778 | detach(); | 782 | detach(); |
779 | mData->empty = false; | 783 | mData->empty = false; |
780 | mData->agent = agent; | 784 | mData->agent = agent; |
781 | } | 785 | } |
782 | 786 | ||
783 | Agent Addressee::agent() const | 787 | Agent Addressee::agent() const |
784 | { | 788 | { |
785 | return mData->agent; | 789 | return mData->agent; |
786 | } | 790 | } |
787 | 791 | ||
788 | QString Addressee::agentLabel() | 792 | QString Addressee::agentLabel() |
789 | { | 793 | { |
790 | return i18n("Agent"); | 794 | return i18n("Agent"); |
791 | } | 795 | } |
792 | 796 | ||
793 | 797 | ||
794 | 798 | ||
795 | void Addressee::setNameFromString( const QString &str ) | 799 | void Addressee::setNameFromString( const QString &str ) |
796 | { | 800 | { |
797 | setFormattedName( str ); | 801 | setFormattedName( str ); |
798 | setName( str ); | 802 | setName( str ); |
799 | 803 | ||
800 | QStringList titles; | 804 | QStringList titles; |
801 | titles += i18n( "Dr." ); | 805 | titles += i18n( "Dr." ); |
802 | titles += i18n( "Miss" ); | 806 | titles += i18n( "Miss" ); |
803 | titles += i18n( "Mr." ); | 807 | titles += i18n( "Mr." ); |
804 | titles += i18n( "Mrs." ); | 808 | titles += i18n( "Mrs." ); |
805 | titles += i18n( "Ms." ); | 809 | titles += i18n( "Ms." ); |
806 | titles += i18n( "Prof." ); | 810 | titles += i18n( "Prof." ); |
807 | 811 | ||
808 | QStringList suffixes; | 812 | QStringList suffixes; |
809 | suffixes += i18n( "I" ); | 813 | suffixes += i18n( "I" ); |
810 | suffixes += i18n( "II" ); | 814 | suffixes += i18n( "II" ); |
811 | suffixes += i18n( "III" ); | 815 | suffixes += i18n( "III" ); |
812 | suffixes += i18n( "Jr." ); | 816 | suffixes += i18n( "Jr." ); |
813 | suffixes += i18n( "Sr." ); | 817 | suffixes += i18n( "Sr." ); |
814 | 818 | ||
815 | QStringList prefixes; | 819 | QStringList prefixes; |
816 | prefixes += "van"; | 820 | prefixes += "van"; |
817 | prefixes += "von"; | 821 | prefixes += "von"; |
818 | prefixes += "de"; | 822 | prefixes += "de"; |
819 | 823 | ||
820 | //US KConfig config( "kabcrc" ); | 824 | //US KConfig config( "kabcrc" ); |
821 | KConfig config( locateLocal( "config", "kabcrc") ); | 825 | KConfig config( locateLocal( "config", "kabcrc") ); |
822 | config.setGroup( "General" ); | 826 | config.setGroup( "General" ); |
823 | titles += config.readListEntry( "Prefixes" ); | 827 | titles += config.readListEntry( "Prefixes" ); |
824 | titles.remove( "" ); | 828 | titles.remove( "" ); |
825 | prefixes += config.readListEntry( "Inclusions" ); | 829 | prefixes += config.readListEntry( "Inclusions" ); |
826 | prefixes.remove( "" ); | 830 | prefixes.remove( "" ); |
827 | suffixes += config.readListEntry( "Suffixes" ); | 831 | suffixes += config.readListEntry( "Suffixes" ); |
828 | suffixes.remove( "" ); | 832 | suffixes.remove( "" ); |
829 | 833 | ||
830 | // clear all name parts | 834 | // clear all name parts |
831 | setPrefix( "" ); | 835 | setPrefix( "" ); |
832 | setGivenName( "" ); | 836 | setGivenName( "" ); |
833 | setAdditionalName( "" ); | 837 | setAdditionalName( "" ); |
834 | setFamilyName( "" ); | 838 | setFamilyName( "" ); |
835 | setSuffix( "" ); | 839 | setSuffix( "" ); |
836 | 840 | ||
837 | if ( str.isEmpty() ) | 841 | if ( str.isEmpty() ) |
838 | return; | 842 | return; |
839 | 843 | ||
840 | int i = str.find(','); | 844 | int i = str.find(','); |
841 | if( i < 0 ) { | 845 | if( i < 0 ) { |
842 | QStringList parts = QStringList::split( " ", str ); | 846 | QStringList parts = QStringList::split( " ", str ); |
843 | int leftOffset = 0; | 847 | int leftOffset = 0; |
844 | int rightOffset = parts.count() - 1; | 848 | int rightOffset = parts.count() - 1; |
845 | 849 | ||
846 | QString suffix; | 850 | QString suffix; |
847 | while ( rightOffset >= 0 ) { | 851 | while ( rightOffset >= 0 ) { |
848 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 852 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
849 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 853 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
850 | rightOffset--; | 854 | rightOffset--; |
851 | } else | 855 | } else |
852 | break; | 856 | break; |
853 | } | 857 | } |
854 | setSuffix( suffix ); | 858 | setSuffix( suffix ); |
855 | 859 | ||
856 | if ( rightOffset < 0 ) | 860 | if ( rightOffset < 0 ) |
857 | return; | 861 | return; |
858 | 862 | ||
859 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 863 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
860 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 864 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
861 | rightOffset--; | 865 | rightOffset--; |
862 | } else | 866 | } else |
863 | setFamilyName( parts[ rightOffset ] ); | 867 | setFamilyName( parts[ rightOffset ] ); |
864 | 868 | ||
865 | QString prefix; | 869 | QString prefix; |
866 | while ( leftOffset < rightOffset ) { | 870 | while ( leftOffset < rightOffset ) { |
867 | if ( titles.contains( parts[ leftOffset ] ) ) { | 871 | if ( titles.contains( parts[ leftOffset ] ) ) { |
868 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 872 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
869 | leftOffset++; | 873 | leftOffset++; |
870 | } else | 874 | } else |
871 | break; | 875 | break; |
872 | } | 876 | } |
873 | setPrefix( prefix ); | 877 | setPrefix( prefix ); |
874 | 878 | ||
875 | if ( leftOffset < rightOffset ) { | 879 | if ( leftOffset < rightOffset ) { |
876 | setGivenName( parts[ leftOffset ] ); | 880 | setGivenName( parts[ leftOffset ] ); |
877 | leftOffset++; | 881 | leftOffset++; |
878 | } | 882 | } |
879 | 883 | ||
880 | QString additionalName; | 884 | QString additionalName; |
881 | while ( leftOffset < rightOffset ) { | 885 | while ( leftOffset < rightOffset ) { |
882 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 886 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
883 | leftOffset++; | 887 | leftOffset++; |
884 | } | 888 | } |
885 | setAdditionalName( additionalName ); | 889 | setAdditionalName( additionalName ); |
886 | } else { | 890 | } else { |
887 | QString part1 = str.left( i ); | 891 | QString part1 = str.left( i ); |
888 | QString part2 = str.mid( i + 1 ); | 892 | QString part2 = str.mid( i + 1 ); |
889 | 893 | ||
890 | QStringList parts = QStringList::split( " ", part1 ); | 894 | QStringList parts = QStringList::split( " ", part1 ); |
891 | int leftOffset = 0; | 895 | int leftOffset = 0; |
892 | int rightOffset = parts.count() - 1; | 896 | int rightOffset = parts.count() - 1; |
893 | 897 | ||
894 | QString suffix; | 898 | QString suffix; |
895 | while ( rightOffset >= 0 ) { | 899 | while ( rightOffset >= 0 ) { |
896 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 900 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
897 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 901 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
898 | rightOffset--; | 902 | rightOffset--; |
899 | } else | 903 | } else |
900 | break; | 904 | break; |
901 | } | 905 | } |
902 | setSuffix( suffix ); | 906 | setSuffix( suffix ); |
903 | 907 | ||
904 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 908 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
905 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 909 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
906 | rightOffset--; | 910 | rightOffset--; |
907 | } else | 911 | } else |
908 | setFamilyName( parts[ rightOffset ] ); | 912 | setFamilyName( parts[ rightOffset ] ); |
909 | 913 | ||
910 | QString prefix; | 914 | QString prefix; |
911 | while ( leftOffset < rightOffset ) { | 915 | while ( leftOffset < rightOffset ) { |
912 | if ( titles.contains( parts[ leftOffset ] ) ) { | 916 | if ( titles.contains( parts[ leftOffset ] ) ) { |
913 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 917 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
914 | leftOffset++; | 918 | leftOffset++; |
915 | } else | 919 | } else |
916 | break; | 920 | break; |
917 | } | 921 | } |
918 | 922 | ||
919 | parts = QStringList::split( " ", part2 ); | 923 | parts = QStringList::split( " ", part2 ); |
920 | 924 | ||
921 | leftOffset = 0; | 925 | leftOffset = 0; |
922 | rightOffset = parts.count(); | 926 | rightOffset = parts.count(); |
923 | 927 | ||
924 | while ( leftOffset < rightOffset ) { | 928 | while ( leftOffset < rightOffset ) { |
925 | if ( titles.contains( parts[ leftOffset ] ) ) { | 929 | if ( titles.contains( parts[ leftOffset ] ) ) { |
926 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 930 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
927 | leftOffset++; | 931 | leftOffset++; |
928 | } else | 932 | } else |
929 | break; | 933 | break; |
930 | } | 934 | } |
931 | setPrefix( prefix ); | 935 | setPrefix( prefix ); |
932 | 936 | ||
933 | if ( leftOffset < rightOffset ) { | 937 | if ( leftOffset < rightOffset ) { |
934 | setGivenName( parts[ leftOffset ] ); | 938 | setGivenName( parts[ leftOffset ] ); |
935 | leftOffset++; | 939 | leftOffset++; |
936 | } | 940 | } |
937 | 941 | ||
938 | QString additionalName; | 942 | QString additionalName; |
939 | while ( leftOffset < rightOffset ) { | 943 | while ( leftOffset < rightOffset ) { |
940 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 944 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
941 | leftOffset++; | 945 | leftOffset++; |
942 | } | 946 | } |
943 | setAdditionalName( additionalName ); | 947 | setAdditionalName( additionalName ); |
944 | } | 948 | } |
945 | } | 949 | } |
946 | 950 | ||
947 | QString Addressee::realName() const | 951 | QString Addressee::realName() const |
948 | { | 952 | { |
949 | if ( !formattedName().isEmpty() ) | 953 | if ( !formattedName().isEmpty() ) |
950 | return formattedName(); | 954 | return formattedName(); |
951 | 955 | ||
952 | QString n = assembledName(); | 956 | QString n = assembledName(); |
953 | 957 | ||
954 | if ( n.isEmpty() ) | 958 | if ( n.isEmpty() ) |
955 | n = name(); | 959 | n = name(); |
956 | 960 | ||
957 | return n; | 961 | return n; |
958 | } | 962 | } |
959 | 963 | ||
960 | QString Addressee::assembledName() const | 964 | QString Addressee::assembledName() const |
961 | { | 965 | { |
962 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 966 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
963 | familyName() + " " + suffix(); | 967 | familyName() + " " + suffix(); |
964 | 968 | ||
965 | return name.simplifyWhiteSpace(); | 969 | return name.simplifyWhiteSpace(); |
966 | } | 970 | } |
967 | 971 | ||
968 | QString Addressee::fullEmail( const QString &email ) const | 972 | QString Addressee::fullEmail( const QString &email ) const |
969 | { | 973 | { |
970 | QString e; | 974 | QString e; |
971 | if ( email.isNull() ) { | 975 | if ( email.isNull() ) { |
972 | e = preferredEmail(); | 976 | e = preferredEmail(); |
973 | } else { | 977 | } else { |
974 | e = email; | 978 | e = email; |
975 | } | 979 | } |
976 | if ( e.isEmpty() ) return QString::null; | 980 | if ( e.isEmpty() ) return QString::null; |
977 | 981 | ||
978 | QString text; | 982 | QString text; |
979 | if ( realName().isEmpty() ) | 983 | if ( realName().isEmpty() ) |
980 | text = e; | 984 | text = e; |
981 | else | 985 | else |
982 | text = assembledName() + " <" + e + ">"; | 986 | text = assembledName() + " <" + e + ">"; |
983 | 987 | ||
984 | return text; | 988 | return text; |
985 | } | 989 | } |
986 | 990 | ||
987 | void Addressee::insertEmail( const QString &email, bool preferred ) | 991 | void Addressee::insertEmail( const QString &email, bool preferred ) |
988 | { | 992 | { |
989 | detach(); | 993 | detach(); |
990 | 994 | ||
991 | QStringList::Iterator it = mData->emails.find( email ); | 995 | QStringList::Iterator it = mData->emails.find( email ); |
992 | 996 | ||
993 | if ( it != mData->emails.end() ) { | 997 | if ( it != mData->emails.end() ) { |
994 | if ( !preferred || it == mData->emails.begin() ) return; | 998 | if ( !preferred || it == mData->emails.begin() ) return; |
995 | mData->emails.remove( it ); | 999 | mData->emails.remove( it ); |
996 | mData->emails.prepend( email ); | 1000 | mData->emails.prepend( email ); |
997 | } else { | 1001 | } else { |
998 | if ( preferred ) { | 1002 | if ( preferred ) { |
999 | mData->emails.prepend( email ); | 1003 | mData->emails.prepend( email ); |
1000 | } else { | 1004 | } else { |
1001 | mData->emails.append( email ); | 1005 | mData->emails.append( email ); |
1002 | } | 1006 | } |
1003 | } | 1007 | } |
1004 | } | 1008 | } |
1005 | 1009 | ||
1006 | void Addressee::removeEmail( const QString &email ) | 1010 | void Addressee::removeEmail( const QString &email ) |
1007 | { | 1011 | { |
1008 | detach(); | 1012 | detach(); |
1009 | 1013 | ||
1010 | QStringList::Iterator it = mData->emails.find( email ); | 1014 | QStringList::Iterator it = mData->emails.find( email ); |
1011 | if ( it == mData->emails.end() ) return; | 1015 | if ( it == mData->emails.end() ) return; |
1012 | 1016 | ||
1013 | mData->emails.remove( it ); | 1017 | mData->emails.remove( it ); |
1014 | } | 1018 | } |
1015 | 1019 | ||
1016 | QString Addressee::preferredEmail() const | 1020 | QString Addressee::preferredEmail() const |
1017 | { | 1021 | { |
1018 | if ( mData->emails.count() == 0 ) return QString::null; | 1022 | if ( mData->emails.count() == 0 ) return QString::null; |
1019 | else return mData->emails.first(); | 1023 | else return mData->emails.first(); |
1020 | } | 1024 | } |
1021 | 1025 | ||
1022 | QStringList Addressee::emails() const | 1026 | QStringList Addressee::emails() const |
1023 | { | 1027 | { |
1024 | return mData->emails; | 1028 | return mData->emails; |
1025 | } | 1029 | } |
1026 | void Addressee::setEmails( const QStringList& emails ) { | 1030 | void Addressee::setEmails( const QStringList& emails ) { |
1027 | detach(); | 1031 | detach(); |
1028 | mData->emails = emails; | 1032 | mData->emails = emails; |
1029 | } | 1033 | } |
1030 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1034 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1031 | { | 1035 | { |
1032 | detach(); | 1036 | detach(); |
1033 | mData->empty = false; | 1037 | mData->empty = false; |
1034 | 1038 | ||
1035 | PhoneNumber::List::Iterator it; | 1039 | PhoneNumber::List::Iterator it; |
1036 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1040 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1037 | if ( (*it).id() == phoneNumber.id() ) { | 1041 | if ( (*it).id() == phoneNumber.id() ) { |
1038 | *it = phoneNumber; | 1042 | *it = phoneNumber; |
1039 | return; | 1043 | return; |
1040 | } | 1044 | } |
1041 | } | 1045 | } |
1042 | mData->phoneNumbers.append( phoneNumber ); | 1046 | mData->phoneNumbers.append( phoneNumber ); |
1043 | } | 1047 | } |
1044 | 1048 | ||
1045 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1049 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1046 | { | 1050 | { |
1047 | detach(); | 1051 | detach(); |
1048 | 1052 | ||
1049 | PhoneNumber::List::Iterator it; | 1053 | PhoneNumber::List::Iterator it; |
1050 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1054 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1051 | if ( (*it).id() == phoneNumber.id() ) { | 1055 | if ( (*it).id() == phoneNumber.id() ) { |
1052 | mData->phoneNumbers.remove( it ); | 1056 | mData->phoneNumbers.remove( it ); |
1053 | return; | 1057 | return; |
1054 | } | 1058 | } |
1055 | } | 1059 | } |
1056 | } | 1060 | } |
1057 | 1061 | ||
1058 | PhoneNumber Addressee::phoneNumber( int type ) const | 1062 | PhoneNumber Addressee::phoneNumber( int type ) const |
1059 | { | 1063 | { |
1060 | PhoneNumber phoneNumber( "", type ); | 1064 | PhoneNumber phoneNumber( "", type ); |
1061 | PhoneNumber::List::ConstIterator it; | 1065 | PhoneNumber::List::ConstIterator it; |
1062 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1066 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1063 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1067 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1064 | if ( (*it).type() & PhoneNumber::Pref ) | 1068 | if ( (*it).type() & PhoneNumber::Pref ) |
1065 | return (*it); | 1069 | return (*it); |
1066 | else if ( phoneNumber.number().isEmpty() ) | 1070 | else if ( phoneNumber.number().isEmpty() ) |
1067 | phoneNumber = (*it); | 1071 | phoneNumber = (*it); |
1068 | } | 1072 | } |
1069 | } | 1073 | } |
1070 | 1074 | ||
1071 | return phoneNumber; | 1075 | return phoneNumber; |
1072 | } | 1076 | } |
1073 | 1077 | ||
1074 | PhoneNumber::List Addressee::phoneNumbers() const | 1078 | PhoneNumber::List Addressee::phoneNumbers() const |
1075 | { | 1079 | { |
1076 | return mData->phoneNumbers; | 1080 | return mData->phoneNumbers; |
1077 | } | 1081 | } |
1078 | 1082 | ||
1079 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1083 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1080 | { | 1084 | { |
1081 | PhoneNumber::List list; | 1085 | PhoneNumber::List list; |
1082 | 1086 | ||
1083 | PhoneNumber::List::ConstIterator it; | 1087 | PhoneNumber::List::ConstIterator it; |
1084 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1088 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1085 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1089 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1086 | list.append( *it ); | 1090 | list.append( *it ); |
1087 | } | 1091 | } |
1088 | } | 1092 | } |
1089 | return list; | 1093 | return list; |
1090 | } | 1094 | } |
1091 | 1095 | ||
1092 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1096 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1093 | { | 1097 | { |
1094 | PhoneNumber::List::ConstIterator it; | 1098 | PhoneNumber::List::ConstIterator it; |
1095 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1099 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1096 | if ( (*it).id() == id ) { | 1100 | if ( (*it).id() == id ) { |
1097 | return *it; | 1101 | return *it; |
1098 | } | 1102 | } |
1099 | } | 1103 | } |
1100 | return PhoneNumber(); | 1104 | return PhoneNumber(); |
1101 | } | 1105 | } |
1102 | 1106 | ||
1103 | void Addressee::insertKey( const Key &key ) | 1107 | void Addressee::insertKey( const Key &key ) |
1104 | { | 1108 | { |
1105 | detach(); | 1109 | detach(); |
1106 | mData->empty = false; | 1110 | mData->empty = false; |
1107 | 1111 | ||
1108 | Key::List::Iterator it; | 1112 | Key::List::Iterator it; |
1109 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1113 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1110 | if ( (*it).id() == key.id() ) { | 1114 | if ( (*it).id() == key.id() ) { |
1111 | *it = key; | 1115 | *it = key; |
1112 | return; | 1116 | return; |
1113 | } | 1117 | } |
1114 | } | 1118 | } |
1115 | mData->keys.append( key ); | 1119 | mData->keys.append( key ); |
1116 | } | 1120 | } |
1117 | 1121 | ||
1118 | void Addressee::removeKey( const Key &key ) | 1122 | void Addressee::removeKey( const Key &key ) |
1119 | { | 1123 | { |
1120 | detach(); | 1124 | detach(); |
1121 | 1125 | ||
1122 | Key::List::Iterator it; | 1126 | Key::List::Iterator it; |
1123 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1127 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1124 | if ( (*it).id() == key.id() ) { | 1128 | if ( (*it).id() == key.id() ) { |
1125 | mData->keys.remove( key ); | 1129 | mData->keys.remove( key ); |
1126 | return; | 1130 | return; |
1127 | } | 1131 | } |
1128 | } | 1132 | } |
1129 | } | 1133 | } |
1130 | 1134 | ||
1131 | Key Addressee::key( int type, QString customTypeString ) const | 1135 | Key Addressee::key( int type, QString customTypeString ) const |
1132 | { | 1136 | { |
1133 | Key::List::ConstIterator it; | 1137 | Key::List::ConstIterator it; |
1134 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1138 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1135 | if ( (*it).type() == type ) { | 1139 | if ( (*it).type() == type ) { |
1136 | if ( type == Key::Custom ) { | 1140 | if ( type == Key::Custom ) { |
1137 | if ( customTypeString.isEmpty() ) { | 1141 | if ( customTypeString.isEmpty() ) { |
1138 | return *it; | 1142 | return *it; |
1139 | } else { | 1143 | } else { |
1140 | if ( (*it).customTypeString() == customTypeString ) | 1144 | if ( (*it).customTypeString() == customTypeString ) |
1141 | return (*it); | 1145 | return (*it); |
1142 | } | 1146 | } |
1143 | } else { | 1147 | } else { |
1144 | return *it; | 1148 | return *it; |
1145 | } | 1149 | } |
1146 | } | 1150 | } |
1147 | } | 1151 | } |
1148 | return Key( QString(), type ); | 1152 | return Key( QString(), type ); |
1149 | } | 1153 | } |
1150 | void Addressee::setKeys( const Key::List& list ) { | 1154 | void Addressee::setKeys( const Key::List& list ) { |
1151 | detach(); | 1155 | detach(); |
1152 | mData->keys = list; | 1156 | mData->keys = list; |
1153 | } | 1157 | } |
1154 | 1158 | ||
1155 | Key::List Addressee::keys() const | 1159 | Key::List Addressee::keys() const |
1156 | { | 1160 | { |
1157 | return mData->keys; | 1161 | return mData->keys; |
1158 | } | 1162 | } |
1159 | 1163 | ||
1160 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1164 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1161 | { | 1165 | { |
1162 | Key::List list; | 1166 | Key::List list; |
1163 | 1167 | ||
1164 | Key::List::ConstIterator it; | 1168 | Key::List::ConstIterator it; |
1165 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1169 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1166 | if ( (*it).type() == type ) { | 1170 | if ( (*it).type() == type ) { |
1167 | if ( type == Key::Custom ) { | 1171 | if ( type == Key::Custom ) { |
1168 | if ( customTypeString.isEmpty() ) { | 1172 | if ( customTypeString.isEmpty() ) { |
1169 | list.append(*it); | 1173 | list.append(*it); |
1170 | } else { | 1174 | } else { |
1171 | if ( (*it).customTypeString() == customTypeString ) | 1175 | if ( (*it).customTypeString() == customTypeString ) |
1172 | list.append(*it); | 1176 | list.append(*it); |
1173 | } | 1177 | } |
1174 | } else { | 1178 | } else { |
1175 | list.append(*it); | 1179 | list.append(*it); |
1176 | } | 1180 | } |
1177 | } | 1181 | } |
1178 | } | 1182 | } |
1179 | return list; | 1183 | return list; |
1180 | } | 1184 | } |
1181 | 1185 | ||
1182 | Key Addressee::findKey( const QString &id ) const | 1186 | Key Addressee::findKey( const QString &id ) const |
1183 | { | 1187 | { |
1184 | Key::List::ConstIterator it; | 1188 | Key::List::ConstIterator it; |
1185 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1189 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1186 | if ( (*it).id() == id ) { | 1190 | if ( (*it).id() == id ) { |
1187 | return *it; | 1191 | return *it; |
1188 | } | 1192 | } |
1189 | } | 1193 | } |
1190 | return Key(); | 1194 | return Key(); |
1191 | } | 1195 | } |
1192 | 1196 | ||
1193 | QString Addressee::asString() const | 1197 | QString Addressee::asString() const |
1194 | { | 1198 | { |
1195 | return "Smith, agent Smith..."; | 1199 | return "Smith, agent Smith..."; |
1196 | } | 1200 | } |
1197 | 1201 | ||
1198 | void Addressee::dump() const | 1202 | void Addressee::dump() const |
1199 | { | 1203 | { |
1200 | return; | 1204 | return; |
1201 | kdDebug(5700) << "Addressee {" << endl; | 1205 | kdDebug(5700) << "Addressee {" << endl; |
1202 | 1206 | ||
1203 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1207 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1204 | 1208 | ||
1205 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1209 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1206 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1210 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1207 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1211 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1208 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1212 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1209 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1213 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1210 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1214 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1211 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1215 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1212 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1216 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1213 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1217 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1214 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1218 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1215 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1219 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1216 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1220 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1217 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1221 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1218 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1222 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1219 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1223 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1220 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1224 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1221 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1225 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1222 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1226 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1223 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1227 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1224 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1228 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1225 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1229 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1226 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1230 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1227 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1231 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1228 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1232 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1229 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1233 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1230 | 1234 | ||
1231 | kdDebug(5700) << " Emails {" << endl; | 1235 | kdDebug(5700) << " Emails {" << endl; |
1232 | QStringList e = emails(); | 1236 | QStringList e = emails(); |
1233 | QStringList::ConstIterator it; | 1237 | QStringList::ConstIterator it; |
1234 | for( it = e.begin(); it != e.end(); ++it ) { | 1238 | for( it = e.begin(); it != e.end(); ++it ) { |
1235 | kdDebug(5700) << " " << (*it) << endl; | 1239 | kdDebug(5700) << " " << (*it) << endl; |
1236 | } | 1240 | } |
1237 | kdDebug(5700) << " }" << endl; | 1241 | kdDebug(5700) << " }" << endl; |
1238 | 1242 | ||
1239 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1243 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1240 | PhoneNumber::List p = phoneNumbers(); | 1244 | PhoneNumber::List p = phoneNumbers(); |
1241 | PhoneNumber::List::ConstIterator it2; | 1245 | PhoneNumber::List::ConstIterator it2; |
1242 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1246 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1243 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1247 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1244 | } | 1248 | } |
1245 | kdDebug(5700) << " }" << endl; | 1249 | kdDebug(5700) << " }" << endl; |
1246 | 1250 | ||
1247 | Address::List a = addresses(); | 1251 | Address::List a = addresses(); |
1248 | Address::List::ConstIterator it3; | 1252 | Address::List::ConstIterator it3; |
1249 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1253 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1250 | (*it3).dump(); | 1254 | (*it3).dump(); |
1251 | } | 1255 | } |
1252 | 1256 | ||
1253 | kdDebug(5700) << " Keys {" << endl; | 1257 | kdDebug(5700) << " Keys {" << endl; |
1254 | Key::List k = keys(); | 1258 | Key::List k = keys(); |
1255 | Key::List::ConstIterator it4; | 1259 | Key::List::ConstIterator it4; |
1256 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1260 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1257 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1261 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1258 | " Key: " << (*it4).textData() << | 1262 | " Key: " << (*it4).textData() << |
1259 | " CustomString: " << (*it4).customTypeString() << endl; | 1263 | " CustomString: " << (*it4).customTypeString() << endl; |
1260 | } | 1264 | } |
1261 | kdDebug(5700) << " }" << endl; | 1265 | kdDebug(5700) << " }" << endl; |
1262 | 1266 | ||
1263 | kdDebug(5700) << "}" << endl; | 1267 | kdDebug(5700) << "}" << endl; |
1264 | } | 1268 | } |
1265 | 1269 | ||
1266 | 1270 | ||
1267 | void Addressee::insertAddress( const Address &address ) | 1271 | void Addressee::insertAddress( const Address &address ) |
1268 | { | 1272 | { |
1269 | detach(); | 1273 | detach(); |
1270 | mData->empty = false; | 1274 | mData->empty = false; |
1271 | 1275 | ||
1272 | Address::List::Iterator it; | 1276 | Address::List::Iterator it; |
1273 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1277 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1274 | if ( (*it).id() == address.id() ) { | 1278 | if ( (*it).id() == address.id() ) { |
1275 | *it = address; | 1279 | *it = address; |
1276 | return; | 1280 | return; |
1277 | } | 1281 | } |
1278 | } | 1282 | } |
1279 | mData->addresses.append( address ); | 1283 | mData->addresses.append( address ); |
1280 | } | 1284 | } |
1281 | 1285 | ||
1282 | void Addressee::removeAddress( const Address &address ) | 1286 | void Addressee::removeAddress( const Address &address ) |
1283 | { | 1287 | { |
1284 | detach(); | 1288 | detach(); |
1285 | 1289 | ||
1286 | Address::List::Iterator it; | 1290 | Address::List::Iterator it; |
1287 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1291 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1288 | if ( (*it).id() == address.id() ) { | 1292 | if ( (*it).id() == address.id() ) { |
1289 | mData->addresses.remove( it ); | 1293 | mData->addresses.remove( it ); |
1290 | return; | 1294 | return; |
1291 | } | 1295 | } |
1292 | } | 1296 | } |
1293 | } | 1297 | } |
1294 | 1298 | ||
1295 | Address Addressee::address( int type ) const | 1299 | Address Addressee::address( int type ) const |
1296 | { | 1300 | { |
1297 | Address address( type ); | 1301 | Address address( type ); |
1298 | Address::List::ConstIterator it; | 1302 | Address::List::ConstIterator it; |
1299 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1303 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1300 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1304 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1301 | if ( (*it).type() & Address::Pref ) | 1305 | if ( (*it).type() & Address::Pref ) |
1302 | return (*it); | 1306 | return (*it); |
1303 | else if ( address.isEmpty() ) | 1307 | else if ( address.isEmpty() ) |
1304 | address = (*it); | 1308 | address = (*it); |
1305 | } | 1309 | } |
1306 | } | 1310 | } |
1307 | 1311 | ||
1308 | return address; | 1312 | return address; |
1309 | } | 1313 | } |
1310 | 1314 | ||
1311 | Address::List Addressee::addresses() const | 1315 | Address::List Addressee::addresses() const |
1312 | { | 1316 | { |
1313 | return mData->addresses; | 1317 | return mData->addresses; |
1314 | } | 1318 | } |
1315 | 1319 | ||
1316 | Address::List Addressee::addresses( int type ) const | 1320 | Address::List Addressee::addresses( int type ) const |
1317 | { | 1321 | { |
1318 | Address::List list; | 1322 | Address::List list; |
1319 | 1323 | ||
1320 | Address::List::ConstIterator it; | 1324 | Address::List::ConstIterator it; |
1321 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1325 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1322 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1326 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1323 | list.append( *it ); | 1327 | list.append( *it ); |
1324 | } | 1328 | } |
1325 | } | 1329 | } |
1326 | 1330 | ||
1327 | return list; | 1331 | return list; |
1328 | } | 1332 | } |
1329 | 1333 | ||
1330 | Address Addressee::findAddress( const QString &id ) const | 1334 | Address Addressee::findAddress( const QString &id ) const |
1331 | { | 1335 | { |
1332 | Address::List::ConstIterator it; | 1336 | Address::List::ConstIterator it; |
1333 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1337 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1334 | if ( (*it).id() == id ) { | 1338 | if ( (*it).id() == id ) { |
1335 | return *it; | 1339 | return *it; |
1336 | } | 1340 | } |
1337 | } | 1341 | } |
1338 | return Address(); | 1342 | return Address(); |
1339 | } | 1343 | } |
1340 | 1344 | ||
1341 | void Addressee::insertCategory( const QString &c ) | 1345 | void Addressee::insertCategory( const QString &c ) |
1342 | { | 1346 | { |
1343 | detach(); | 1347 | detach(); |
1344 | mData->empty = false; | 1348 | mData->empty = false; |
1345 | 1349 | ||
1346 | if ( mData->categories.contains( c ) ) return; | 1350 | if ( mData->categories.contains( c ) ) return; |
1347 | 1351 | ||
1348 | mData->categories.append( c ); | 1352 | mData->categories.append( c ); |
1349 | } | 1353 | } |
1350 | 1354 | ||
1351 | void Addressee::removeCategory( const QString &c ) | 1355 | void Addressee::removeCategory( const QString &c ) |
1352 | { | 1356 | { |
1353 | detach(); | 1357 | detach(); |
1354 | 1358 | ||
1355 | QStringList::Iterator it = mData->categories.find( c ); | 1359 | QStringList::Iterator it = mData->categories.find( c ); |
1356 | if ( it == mData->categories.end() ) return; | 1360 | if ( it == mData->categories.end() ) return; |
1357 | 1361 | ||
1358 | mData->categories.remove( it ); | 1362 | mData->categories.remove( it ); |
1359 | } | 1363 | } |
1360 | 1364 | ||
1361 | bool Addressee::hasCategory( const QString &c ) const | 1365 | bool Addressee::hasCategory( const QString &c ) const |
1362 | { | 1366 | { |
1363 | return ( mData->categories.contains( c ) ); | 1367 | return ( mData->categories.contains( c ) ); |
1364 | } | 1368 | } |
1365 | 1369 | ||
1366 | void Addressee::setCategories( const QStringList &c ) | 1370 | void Addressee::setCategories( const QStringList &c ) |
1367 | { | 1371 | { |
1368 | detach(); | 1372 | detach(); |
1369 | mData->empty = false; | 1373 | mData->empty = false; |
1370 | 1374 | ||
1371 | mData->categories = c; | 1375 | mData->categories = c; |
1372 | } | 1376 | } |
1373 | 1377 | ||
1374 | QStringList Addressee::categories() const | 1378 | QStringList Addressee::categories() const |
1375 | { | 1379 | { |
1376 | return mData->categories; | 1380 | return mData->categories; |
1377 | } | 1381 | } |
1378 | 1382 | ||
1379 | void Addressee::insertCustom( const QString &app, const QString &name, | 1383 | void Addressee::insertCustom( const QString &app, const QString &name, |
1380 | const QString &value ) | 1384 | const QString &value ) |
1381 | { | 1385 | { |
1382 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1386 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1383 | 1387 | ||
1384 | detach(); | 1388 | detach(); |
1385 | mData->empty = false; | 1389 | mData->empty = false; |
1386 | 1390 | ||
1387 | QString qualifiedName = app + "-" + name + ":"; | 1391 | QString qualifiedName = app + "-" + name + ":"; |
1388 | 1392 | ||
1389 | QStringList::Iterator it; | 1393 | QStringList::Iterator it; |
1390 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1394 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1391 | if ( (*it).startsWith( qualifiedName ) ) { | 1395 | if ( (*it).startsWith( qualifiedName ) ) { |
1392 | (*it) = qualifiedName + value; | 1396 | (*it) = qualifiedName + value; |
1393 | return; | 1397 | return; |
1394 | } | 1398 | } |
1395 | } | 1399 | } |
1396 | 1400 | ||
1397 | mData->custom.append( qualifiedName + value ); | 1401 | mData->custom.append( qualifiedName + value ); |
1398 | } | 1402 | } |
1399 | 1403 | ||
1400 | void Addressee::removeCustom( const QString &app, const QString &name) | 1404 | void Addressee::removeCustom( const QString &app, const QString &name) |
1401 | { | 1405 | { |
1402 | detach(); | 1406 | detach(); |
1403 | 1407 | ||
1404 | QString qualifiedName = app + "-" + name + ":"; | 1408 | QString qualifiedName = app + "-" + name + ":"; |
1405 | 1409 | ||
1406 | QStringList::Iterator it; | 1410 | QStringList::Iterator it; |
1407 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1411 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1408 | if ( (*it).startsWith( qualifiedName ) ) { | 1412 | if ( (*it).startsWith( qualifiedName ) ) { |
1409 | mData->custom.remove( it ); | 1413 | mData->custom.remove( it ); |
1410 | return; | 1414 | return; |
1411 | } | 1415 | } |
1412 | } | 1416 | } |
1413 | } | 1417 | } |
1414 | 1418 | ||
1415 | QString Addressee::custom( const QString &app, const QString &name ) const | 1419 | QString Addressee::custom( const QString &app, const QString &name ) const |
1416 | { | 1420 | { |
1417 | QString qualifiedName = app + "-" + name + ":"; | 1421 | QString qualifiedName = app + "-" + name + ":"; |
1418 | QString value; | 1422 | QString value; |
1419 | 1423 | ||
1420 | QStringList::ConstIterator it; | 1424 | QStringList::ConstIterator it; |
1421 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1425 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1422 | if ( (*it).startsWith( qualifiedName ) ) { | 1426 | if ( (*it).startsWith( qualifiedName ) ) { |
1423 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1427 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1424 | break; | 1428 | break; |
1425 | } | 1429 | } |
1426 | } | 1430 | } |
1427 | 1431 | ||
1428 | return value; | 1432 | return value; |
1429 | } | 1433 | } |
1430 | 1434 | ||
1431 | void Addressee::setCustoms( const QStringList &l ) | 1435 | void Addressee::setCustoms( const QStringList &l ) |
1432 | { | 1436 | { |
1433 | detach(); | 1437 | detach(); |
1434 | mData->empty = false; | 1438 | mData->empty = false; |
1435 | 1439 | ||
1436 | mData->custom = l; | 1440 | mData->custom = l; |
1437 | } | 1441 | } |
1438 | 1442 | ||
1439 | QStringList Addressee::customs() const | 1443 | QStringList Addressee::customs() const |
1440 | { | 1444 | { |
1441 | return mData->custom; | 1445 | return mData->custom; |
1442 | } | 1446 | } |
1443 | 1447 | ||
1444 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1448 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1445 | QString &email) | 1449 | QString &email) |
1446 | { | 1450 | { |
1447 | int startPos, endPos, len; | 1451 | int startPos, endPos, len; |
1448 | QString partA, partB, result; | 1452 | QString partA, partB, result; |
1449 | char endCh = '>'; | 1453 | char endCh = '>'; |
1450 | 1454 | ||
1451 | startPos = rawEmail.find('<'); | 1455 | startPos = rawEmail.find('<'); |
1452 | if (startPos < 0) | 1456 | if (startPos < 0) |
1453 | { | 1457 | { |
1454 | startPos = rawEmail.find('('); | 1458 | startPos = rawEmail.find('('); |
1455 | endCh = ')'; | 1459 | endCh = ')'; |
1456 | } | 1460 | } |
1457 | if (startPos < 0) | 1461 | if (startPos < 0) |
1458 | { | 1462 | { |
1459 | // We couldn't find any separators, so we assume the whole string | 1463 | // We couldn't find any separators, so we assume the whole string |
1460 | // is the email address | 1464 | // is the email address |
1461 | email = rawEmail; | 1465 | email = rawEmail; |
1462 | fullName = ""; | 1466 | fullName = ""; |
1463 | } | 1467 | } |
1464 | else | 1468 | else |
1465 | { | 1469 | { |
1466 | // We have a start position, try to find an end | 1470 | // We have a start position, try to find an end |
1467 | endPos = rawEmail.find(endCh, startPos+1); | 1471 | endPos = rawEmail.find(endCh, startPos+1); |
1468 | 1472 | ||
1469 | if (endPos < 0) | 1473 | if (endPos < 0) |
1470 | { | 1474 | { |
1471 | // We couldn't find the end of the email address. We can only | 1475 | // We couldn't find the end of the email address. We can only |
1472 | // assume the entire string is the email address. | 1476 | // assume the entire string is the email address. |
1473 | email = rawEmail; | 1477 | email = rawEmail; |
1474 | fullName = ""; | 1478 | fullName = ""; |
1475 | } | 1479 | } |
1476 | else | 1480 | else |
1477 | { | 1481 | { |
1478 | // We have a start and end to the email address | 1482 | // We have a start and end to the email address |
1479 | 1483 | ||
1480 | // Grab the name part | 1484 | // Grab the name part |
1481 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1485 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1482 | 1486 | ||
1483 | // grab the email part | 1487 | // grab the email part |
1484 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1488 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1485 | 1489 | ||
1486 | // Check that we do not have any extra characters on the end of the | 1490 | // Check that we do not have any extra characters on the end of the |
1487 | // strings | 1491 | // strings |
1488 | len = fullName.length(); | 1492 | len = fullName.length(); |
1489 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1493 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1490 | fullName = fullName.mid(1, len-2); | 1494 | fullName = fullName.mid(1, len-2); |
1491 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1495 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1492 | fullName = fullName.mid(1, len-2); | 1496 | fullName = fullName.mid(1, len-2); |
1493 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1497 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1494 | fullName = fullName.mid(1, len-2); | 1498 | fullName = fullName.mid(1, len-2); |
1495 | } | 1499 | } |
1496 | } | 1500 | } |
1497 | } | 1501 | } |
1498 | 1502 | ||
1499 | void Addressee::setResource( Resource *resource ) | 1503 | void Addressee::setResource( Resource *resource ) |
1500 | { | 1504 | { |
1501 | detach(); | 1505 | detach(); |
1502 | mData->resource = resource; | 1506 | mData->resource = resource; |
1503 | } | 1507 | } |
1504 | 1508 | ||
1505 | Resource *Addressee::resource() const | 1509 | Resource *Addressee::resource() const |
1506 | { | 1510 | { |
1507 | return mData->resource; | 1511 | return mData->resource; |
1508 | } | 1512 | } |
1509 | 1513 | ||
1510 | //US | 1514 | //US |
1511 | QString Addressee::resourceLabel() | 1515 | QString Addressee::resourceLabel() |
1512 | { | 1516 | { |
1513 | return i18n("Resource"); | 1517 | return i18n("Resource"); |
1514 | } | 1518 | } |
1515 | 1519 | ||
1516 | void Addressee::setChanged( bool value ) | 1520 | void Addressee::setChanged( bool value ) |
1517 | { | 1521 | { |
1518 | detach(); | 1522 | detach(); |
1519 | mData->changed = value; | 1523 | mData->changed = value; |
1520 | } | 1524 | } |
1521 | 1525 | ||
1522 | bool Addressee::changed() const | 1526 | bool Addressee::changed() const |
1523 | { | 1527 | { |
1524 | return mData->changed; | 1528 | return mData->changed; |
1525 | } | 1529 | } |
1526 | 1530 | ||
1527 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1531 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1528 | { | 1532 | { |
1529 | if (!a.mData) return s; | 1533 | if (!a.mData) return s; |
1530 | 1534 | ||
1531 | s << a.uid(); | 1535 | s << a.uid(); |
1532 | 1536 | ||
1533 | s << a.mData->name; | 1537 | s << a.mData->name; |
1534 | s << a.mData->formattedName; | 1538 | s << a.mData->formattedName; |
1535 | s << a.mData->familyName; | 1539 | s << a.mData->familyName; |
1536 | s << a.mData->givenName; | 1540 | s << a.mData->givenName; |
1537 | s << a.mData->additionalName; | 1541 | s << a.mData->additionalName; |
1538 | s << a.mData->prefix; | 1542 | s << a.mData->prefix; |
1539 | s << a.mData->suffix; | 1543 | s << a.mData->suffix; |
1540 | s << a.mData->nickName; | 1544 | s << a.mData->nickName; |
1541 | s << a.mData->birthday; | 1545 | s << a.mData->birthday; |
1542 | s << a.mData->mailer; | 1546 | s << a.mData->mailer; |
1543 | s << a.mData->timeZone; | 1547 | s << a.mData->timeZone; |
1544 | s << a.mData->geo; | 1548 | s << a.mData->geo; |
1545 | s << a.mData->title; | 1549 | s << a.mData->title; |
1546 | s << a.mData->role; | 1550 | s << a.mData->role; |
1547 | s << a.mData->organization; | 1551 | s << a.mData->organization; |
1548 | s << a.mData->note; | 1552 | s << a.mData->note; |
1549 | s << a.mData->productId; | 1553 | s << a.mData->productId; |
1550 | s << a.mData->revision; | 1554 | s << a.mData->revision; |
1551 | s << a.mData->sortString; | 1555 | s << a.mData->sortString; |
1552 | s << a.mData->url; | 1556 | s << a.mData->url; |
1553 | s << a.mData->secrecy; | 1557 | s << a.mData->secrecy; |
1554 | s << a.mData->logo; | 1558 | s << a.mData->logo; |
1555 | s << a.mData->photo; | 1559 | s << a.mData->photo; |
1556 | s << a.mData->sound; | 1560 | s << a.mData->sound; |
1557 | s << a.mData->agent; | 1561 | s << a.mData->agent; |
1558 | s << a.mData->phoneNumbers; | 1562 | s << a.mData->phoneNumbers; |
1559 | s << a.mData->addresses; | 1563 | s << a.mData->addresses; |
1560 | s << a.mData->emails; | 1564 | s << a.mData->emails; |
1561 | s << a.mData->categories; | 1565 | s << a.mData->categories; |
1562 | s << a.mData->custom; | 1566 | s << a.mData->custom; |
1563 | s << a.mData->keys; | 1567 | s << a.mData->keys; |
1564 | return s; | 1568 | return s; |
1565 | } | 1569 | } |
1566 | 1570 | ||
1567 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1571 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1568 | { | 1572 | { |
1569 | if (!a.mData) return s; | 1573 | if (!a.mData) return s; |
1570 | 1574 | ||
1571 | s >> a.mData->uid; | 1575 | s >> a.mData->uid; |
1572 | 1576 | ||
1573 | s >> a.mData->name; | 1577 | s >> a.mData->name; |
1574 | s >> a.mData->formattedName; | 1578 | s >> a.mData->formattedName; |
1575 | s >> a.mData->familyName; | 1579 | s >> a.mData->familyName; |
1576 | s >> a.mData->givenName; | 1580 | s >> a.mData->givenName; |
1577 | s >> a.mData->additionalName; | 1581 | s >> a.mData->additionalName; |
1578 | s >> a.mData->prefix; | 1582 | s >> a.mData->prefix; |
1579 | s >> a.mData->suffix; | 1583 | s >> a.mData->suffix; |
1580 | s >> a.mData->nickName; | 1584 | s >> a.mData->nickName; |
1581 | s >> a.mData->birthday; | 1585 | s >> a.mData->birthday; |
1582 | s >> a.mData->mailer; | 1586 | s >> a.mData->mailer; |
1583 | s >> a.mData->timeZone; | 1587 | s >> a.mData->timeZone; |
1584 | s >> a.mData->geo; | 1588 | s >> a.mData->geo; |
1585 | s >> a.mData->title; | 1589 | s >> a.mData->title; |
1586 | s >> a.mData->role; | 1590 | s >> a.mData->role; |
1587 | s >> a.mData->organization; | 1591 | s >> a.mData->organization; |
1588 | s >> a.mData->note; | 1592 | s >> a.mData->note; |
1589 | s >> a.mData->productId; | 1593 | s >> a.mData->productId; |
1590 | s >> a.mData->revision; | 1594 | s >> a.mData->revision; |
1591 | s >> a.mData->sortString; | 1595 | s >> a.mData->sortString; |
1592 | s >> a.mData->url; | 1596 | s >> a.mData->url; |
1593 | s >> a.mData->secrecy; | 1597 | s >> a.mData->secrecy; |
1594 | s >> a.mData->logo; | 1598 | s >> a.mData->logo; |
1595 | s >> a.mData->photo; | 1599 | s >> a.mData->photo; |
1596 | s >> a.mData->sound; | 1600 | s >> a.mData->sound; |
1597 | s >> a.mData->agent; | 1601 | s >> a.mData->agent; |
1598 | s >> a.mData->phoneNumbers; | 1602 | s >> a.mData->phoneNumbers; |
1599 | s >> a.mData->addresses; | 1603 | s >> a.mData->addresses; |
1600 | s >> a.mData->emails; | 1604 | s >> a.mData->emails; |
1601 | s >> a.mData->categories; | 1605 | s >> a.mData->categories; |
1602 | s >> a.mData->custom; | 1606 | s >> a.mData->custom; |
1603 | s >> a.mData->keys; | 1607 | s >> a.mData->keys; |
1604 | 1608 | ||
1605 | a.mData->empty = false; | 1609 | a.mData->empty = false; |
1606 | 1610 | ||
1607 | return s; | 1611 | return s; |
1608 | } | 1612 | } |
1609 | 1613 | ||
1610 | bool matchBinaryPattern( int value, int pattern ) | 1614 | bool matchBinaryPattern( int value, int pattern ) |
1611 | { | 1615 | { |
1612 | /** | 1616 | /** |
1613 | We want to match all telephonnumbers/addresses which have the bits in the | 1617 | We want to match all telephonnumbers/addresses which have the bits in the |
1614 | pattern set. More are allowed. | 1618 | pattern set. More are allowed. |
1615 | if pattern == 0 we have a special handling, then we want only those with | 1619 | if pattern == 0 we have a special handling, then we want only those with |
1616 | exactly no bit set. | 1620 | exactly no bit set. |
1617 | */ | 1621 | */ |
1618 | if ( pattern == 0 ) | 1622 | if ( pattern == 0 ) |
1619 | return ( value == 0 ); | 1623 | return ( value == 0 ); |
1620 | else | 1624 | else |
1621 | return ( pattern == ( pattern & value ) ); | 1625 | return ( pattern == ( pattern & value ) ); |
1622 | } | 1626 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 393d1cc..27782f9 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,823 +1,828 @@ | |||
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 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | Return, if the address book entry is empty. | 101 | Return, if the address book entry is empty. |
102 | */ | 102 | */ |
103 | bool isEmpty() const; | 103 | bool isEmpty() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Set unique identifier. | 106 | Set unique identifier. |
107 | */ | 107 | */ |
108 | void setUid( const QString &uid ); | 108 | void setUid( const QString &uid ); |
109 | /** | 109 | /** |
110 | Return unique identifier. | 110 | Return unique identifier. |
111 | */ | 111 | */ |
112 | QString uid() const; | 112 | QString uid() const; |
113 | /** | 113 | /** |
114 | Return translated label for uid field. | 114 | Return translated label for uid field. |
115 | */ | 115 | */ |
116 | static QString uidLabel(); | 116 | static QString uidLabel(); |
117 | 117 | ||
118 | /** | 118 | /** |
119 | Set name. | 119 | Set name. |
120 | */ | 120 | */ |
121 | void setName( const QString &name ); | 121 | void setName( const QString &name ); |
122 | /** | 122 | /** |
123 | Return name. | 123 | Return name. |
124 | */ | 124 | */ |
125 | QString name() const; | 125 | QString name() const; |
126 | /** | 126 | /** |
127 | Return translated label for name field. | 127 | Return translated label for name field. |
128 | */ | 128 | */ |
129 | static QString nameLabel(); | 129 | static QString nameLabel(); |
130 | 130 | ||
131 | /** | 131 | /** |
132 | Set formatted name. | 132 | Set formatted name. |
133 | */ | 133 | */ |
134 | void setFormattedName( const QString &formattedName ); | 134 | void setFormattedName( const QString &formattedName ); |
135 | /** | 135 | /** |
136 | Return formatted name. | 136 | Return formatted name. |
137 | */ | 137 | */ |
138 | QString formattedName() const; | 138 | QString formattedName() const; |
139 | /** | 139 | /** |
140 | Return translated label for formattedName field. | 140 | Return translated label for formattedName field. |
141 | */ | 141 | */ |
142 | static QString formattedNameLabel(); | 142 | static QString formattedNameLabel(); |
143 | 143 | ||
144 | /** | 144 | /** |
145 | Set family name. | 145 | Set family name. |
146 | */ | 146 | */ |
147 | void setFamilyName( const QString &familyName ); | 147 | void setFamilyName( const QString &familyName ); |
148 | /** | 148 | /** |
149 | Return family name. | 149 | Return family name. |
150 | */ | 150 | */ |
151 | QString familyName() const; | 151 | QString familyName() const; |
152 | /** | 152 | /** |
153 | Return translated label for familyName field. | 153 | Return translated label for familyName field. |
154 | */ | 154 | */ |
155 | static QString familyNameLabel(); | 155 | static QString familyNameLabel(); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Set given name. | 158 | Set given name. |
159 | */ | 159 | */ |
160 | void setGivenName( const QString &givenName ); | 160 | void setGivenName( const QString &givenName ); |
161 | /** | 161 | /** |
162 | Return given name. | 162 | Return given name. |
163 | */ | 163 | */ |
164 | QString givenName() const; | 164 | QString givenName() const; |
165 | /** | 165 | /** |
166 | Return translated label for givenName field. | 166 | Return translated label for givenName field. |
167 | */ | 167 | */ |
168 | static QString givenNameLabel(); | 168 | static QString givenNameLabel(); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | Set additional names. | 171 | Set additional names. |
172 | */ | 172 | */ |
173 | void setAdditionalName( const QString &additionalName ); | 173 | void setAdditionalName( const QString &additionalName ); |
174 | /** | 174 | /** |
175 | Return additional names. | 175 | Return additional names. |
176 | */ | 176 | */ |
177 | QString additionalName() const; | 177 | QString additionalName() const; |
178 | /** | 178 | /** |
179 | Return translated label for additionalName field. | 179 | Return translated label for additionalName field. |
180 | */ | 180 | */ |
181 | static QString additionalNameLabel(); | 181 | static QString additionalNameLabel(); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | Set honorific prefixes. | 184 | Set honorific prefixes. |
185 | */ | 185 | */ |
186 | void setPrefix( const QString &prefix ); | 186 | void setPrefix( const QString &prefix ); |
187 | /** | 187 | /** |
188 | Return honorific prefixes. | 188 | Return honorific prefixes. |
189 | */ | 189 | */ |
190 | QString prefix() const; | 190 | QString prefix() const; |
191 | /** | 191 | /** |
192 | Return translated label for prefix field. | 192 | Return translated label for prefix field. |
193 | */ | 193 | */ |
194 | static QString prefixLabel(); | 194 | static QString prefixLabel(); |
195 | 195 | ||
196 | /** | 196 | /** |
197 | Set honorific suffixes. | 197 | Set honorific suffixes. |
198 | */ | 198 | */ |
199 | void setSuffix( const QString &suffix ); | 199 | void setSuffix( const QString &suffix ); |
200 | /** | 200 | /** |
201 | Return honorific suffixes. | 201 | Return honorific suffixes. |
202 | */ | 202 | */ |
203 | QString suffix() const; | 203 | QString suffix() const; |
204 | /** | 204 | /** |
205 | Return translated label for suffix field. | 205 | Return translated label for suffix field. |
206 | */ | 206 | */ |
207 | static QString suffixLabel(); | 207 | static QString suffixLabel(); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | Set nick name. | 210 | Set nick name. |
211 | */ | 211 | */ |
212 | void setNickName( const QString &nickName ); | 212 | void setNickName( const QString &nickName ); |
213 | /** | 213 | /** |
214 | Return nick name. | 214 | Return nick name. |
215 | */ | 215 | */ |
216 | QString nickName() const; | 216 | QString nickName() const; |
217 | /** | 217 | /** |
218 | Return translated label for nickName field. | 218 | Return translated label for nickName field. |
219 | */ | 219 | */ |
220 | static QString nickNameLabel(); | 220 | static QString nickNameLabel(); |
221 | 221 | ||
222 | /** | 222 | /** |
223 | Set birthday. | 223 | Set birthday. |
224 | */ | 224 | */ |
225 | void setBirthday( const QDateTime &birthday ); | 225 | void setBirthday( const QDateTime &birthday ); |
226 | /** | 226 | /** |
227 | Return birthday. | 227 | Return birthday. |
228 | */ | 228 | */ |
229 | QDateTime birthday() const; | 229 | QDateTime birthday() const; |
230 | /** | 230 | /** |
231 | Return translated label for birthday field. | 231 | Return translated label for birthday field. |
232 | */ | 232 | */ |
233 | static QString birthdayLabel(); | 233 | static QString birthdayLabel(); |
234 | 234 | ||
235 | /** | 235 | /** |
236 | Return translated label for homeAddressStreet field. | 236 | Return translated label for homeAddressStreet field. |
237 | */ | 237 | */ |
238 | static QString homeAddressStreetLabel(); | 238 | static QString homeAddressStreetLabel(); |
239 | 239 | ||
240 | /** | 240 | /** |
241 | Return translated label for homeAddressLocality field. | 241 | Return translated label for homeAddressLocality field. |
242 | */ | 242 | */ |
243 | static QString homeAddressLocalityLabel(); | 243 | static QString homeAddressLocalityLabel(); |
244 | 244 | ||
245 | /** | 245 | /** |
246 | Return translated label for homeAddressRegion field. | 246 | Return translated label for homeAddressRegion field. |
247 | */ | 247 | */ |
248 | static QString homeAddressRegionLabel(); | 248 | static QString homeAddressRegionLabel(); |
249 | 249 | ||
250 | /** | 250 | /** |
251 | Return translated label for homeAddressPostalCode field. | 251 | Return translated label for homeAddressPostalCode field. |
252 | */ | 252 | */ |
253 | static QString homeAddressPostalCodeLabel(); | 253 | static QString homeAddressPostalCodeLabel(); |
254 | 254 | ||
255 | /** | 255 | /** |
256 | Return translated label for homeAddressCountry field. | 256 | Return translated label for homeAddressCountry field. |
257 | */ | 257 | */ |
258 | static QString homeAddressCountryLabel(); | 258 | static QString homeAddressCountryLabel(); |
259 | 259 | ||
260 | /** | 260 | /** |
261 | Return translated label for homeAddressLabel field. | 261 | Return translated label for homeAddressLabel field. |
262 | */ | 262 | */ |
263 | static QString homeAddressLabelLabel(); | 263 | static QString homeAddressLabelLabel(); |
264 | 264 | ||
265 | /** | 265 | /** |
266 | Return translated label for businessAddressStreet field. | 266 | Return translated label for businessAddressStreet field. |
267 | */ | 267 | */ |
268 | static QString businessAddressStreetLabel(); | 268 | static QString businessAddressStreetLabel(); |
269 | 269 | ||
270 | /** | 270 | /** |
271 | Return translated label for businessAddressLocality field. | 271 | Return translated label for businessAddressLocality field. |
272 | */ | 272 | */ |
273 | static QString businessAddressLocalityLabel(); | 273 | static QString businessAddressLocalityLabel(); |
274 | 274 | ||
275 | /** | 275 | /** |
276 | Return translated label for businessAddressRegion field. | 276 | Return translated label for businessAddressRegion field. |
277 | */ | 277 | */ |
278 | static QString businessAddressRegionLabel(); | 278 | static QString businessAddressRegionLabel(); |
279 | 279 | ||
280 | /** | 280 | /** |
281 | Return translated label for businessAddressPostalCode field. | 281 | Return translated label for businessAddressPostalCode field. |
282 | */ | 282 | */ |
283 | static QString businessAddressPostalCodeLabel(); | 283 | static QString businessAddressPostalCodeLabel(); |
284 | 284 | ||
285 | /** | 285 | /** |
286 | Return translated label for businessAddressCountry field. | 286 | Return translated label for businessAddressCountry field. |
287 | */ | 287 | */ |
288 | static QString businessAddressCountryLabel(); | 288 | static QString businessAddressCountryLabel(); |
289 | 289 | ||
290 | /** | 290 | /** |
291 | Return translated label for businessAddressLabel field. | 291 | Return translated label for businessAddressLabel field. |
292 | */ | 292 | */ |
293 | static QString businessAddressLabelLabel(); | 293 | static QString businessAddressLabelLabel(); |
294 | 294 | ||
295 | /** | 295 | /** |
296 | Return translated label for homePhone field. | 296 | Return translated label for homePhone field. |
297 | */ | 297 | */ |
298 | static QString homePhoneLabel(); | 298 | static QString homePhoneLabel(); |
299 | 299 | ||
300 | /** | 300 | /** |
301 | Return translated label for businessPhone field. | 301 | Return translated label for businessPhone field. |
302 | */ | 302 | */ |
303 | static QString businessPhoneLabel(); | 303 | static QString businessPhoneLabel(); |
304 | 304 | ||
305 | /** | 305 | /** |
306 | Return translated label for mobilePhone field. | 306 | Return translated label for mobilePhone field. |
307 | */ | 307 | */ |
308 | static QString mobilePhoneLabel(); | 308 | static QString mobilePhoneLabel(); |
309 | 309 | ||
310 | /** | 310 | /** |
311 | Return translated label for homeFax field. | 311 | Return translated label for homeFax field. |
312 | */ | 312 | */ |
313 | static QString homeFaxLabel(); | 313 | static QString homeFaxLabel(); |
314 | 314 | ||
315 | /** | 315 | /** |
316 | Return translated label for businessFax field. | 316 | Return translated label for businessFax field. |
317 | */ | 317 | */ |
318 | static QString businessFaxLabel(); | 318 | static QString businessFaxLabel(); |
319 | 319 | ||
320 | /** | 320 | /** |
321 | Return translated label for carPhone field. | 321 | Return translated label for carPhone field. |
322 | */ | 322 | */ |
323 | static QString carPhoneLabel(); | 323 | static QString carPhoneLabel(); |
324 | 324 | ||
325 | /** | 325 | /** |
326 | Return translated label for isdn field. | 326 | Return translated label for isdn field. |
327 | */ | 327 | */ |
328 | static QString isdnLabel(); | 328 | static QString isdnLabel(); |
329 | 329 | ||
330 | /** | 330 | /** |
331 | Return translated label for pager field. | 331 | Return translated label for pager field. |
332 | */ | 332 | */ |
333 | static QString pagerLabel(); | 333 | static QString pagerLabel(); |
334 | 334 | ||
335 | /** | 335 | /** |
336 | Return translated label for sip field. | ||
337 | */ | ||
338 | static QString sipLabel(); | ||
339 | |||
340 | /** | ||
336 | Return translated label for email field. | 341 | Return translated label for email field. |
337 | */ | 342 | */ |
338 | static QString emailLabel(); | 343 | static QString emailLabel(); |
339 | 344 | ||
340 | /** | 345 | /** |
341 | Set mail client. | 346 | Set mail client. |
342 | */ | 347 | */ |
343 | void setMailer( const QString &mailer ); | 348 | void setMailer( const QString &mailer ); |
344 | /** | 349 | /** |
345 | Return mail client. | 350 | Return mail client. |
346 | */ | 351 | */ |
347 | QString mailer() const; | 352 | QString mailer() const; |
348 | /** | 353 | /** |
349 | Return translated label for mailer field. | 354 | Return translated label for mailer field. |
350 | */ | 355 | */ |
351 | static QString mailerLabel(); | 356 | static QString mailerLabel(); |
352 | 357 | ||
353 | /** | 358 | /** |
354 | Set time zone. | 359 | Set time zone. |
355 | */ | 360 | */ |
356 | void setTimeZone( const TimeZone &timeZone ); | 361 | void setTimeZone( const TimeZone &timeZone ); |
357 | /** | 362 | /** |
358 | Return time zone. | 363 | Return time zone. |
359 | */ | 364 | */ |
360 | TimeZone timeZone() const; | 365 | TimeZone timeZone() const; |
361 | /** | 366 | /** |
362 | Return translated label for timeZone field. | 367 | Return translated label for timeZone field. |
363 | */ | 368 | */ |
364 | static QString timeZoneLabel(); | 369 | static QString timeZoneLabel(); |
365 | 370 | ||
366 | /** | 371 | /** |
367 | Set geographic position. | 372 | Set geographic position. |
368 | */ | 373 | */ |
369 | void setGeo( const Geo &geo ); | 374 | void setGeo( const Geo &geo ); |
370 | /** | 375 | /** |
371 | Return geographic position. | 376 | Return geographic position. |
372 | */ | 377 | */ |
373 | Geo geo() const; | 378 | Geo geo() const; |
374 | /** | 379 | /** |
375 | Return translated label for geo field. | 380 | Return translated label for geo field. |
376 | */ | 381 | */ |
377 | static QString geoLabel(); | 382 | static QString geoLabel(); |
378 | 383 | ||
379 | /** | 384 | /** |
380 | Set title. | 385 | Set title. |
381 | */ | 386 | */ |
382 | void setTitle( const QString &title ); | 387 | void setTitle( const QString &title ); |
383 | /** | 388 | /** |
384 | Return title. | 389 | Return title. |
385 | */ | 390 | */ |
386 | QString title() const; | 391 | QString title() const; |
387 | /** | 392 | /** |
388 | Return translated label for title field. | 393 | Return translated label for title field. |
389 | */ | 394 | */ |
390 | static QString titleLabel(); | 395 | static QString titleLabel(); |
391 | 396 | ||
392 | /** | 397 | /** |
393 | Set role. | 398 | Set role. |
394 | */ | 399 | */ |
395 | void setRole( const QString &role ); | 400 | void setRole( const QString &role ); |
396 | /** | 401 | /** |
397 | Return role. | 402 | Return role. |
398 | */ | 403 | */ |
399 | QString role() const; | 404 | QString role() const; |
400 | /** | 405 | /** |
401 | Return translated label for role field. | 406 | Return translated label for role field. |
402 | */ | 407 | */ |
403 | static QString roleLabel(); | 408 | static QString roleLabel(); |
404 | 409 | ||
405 | /** | 410 | /** |
406 | Set organization. | 411 | Set organization. |
407 | */ | 412 | */ |
408 | void setOrganization( const QString &organization ); | 413 | void setOrganization( const QString &organization ); |
409 | /** | 414 | /** |
410 | Return organization. | 415 | Return organization. |
411 | */ | 416 | */ |
412 | QString organization() const; | 417 | QString organization() const; |
413 | /** | 418 | /** |
414 | Return translated label for organization field. | 419 | Return translated label for organization field. |
415 | */ | 420 | */ |
416 | static QString organizationLabel(); | 421 | static QString organizationLabel(); |
417 | 422 | ||
418 | /** | 423 | /** |
419 | Set note. | 424 | Set note. |
420 | */ | 425 | */ |
421 | void setNote( const QString ¬e ); | 426 | void setNote( const QString ¬e ); |
422 | /** | 427 | /** |
423 | Return note. | 428 | Return note. |
424 | */ | 429 | */ |
425 | QString note() const; | 430 | QString note() const; |
426 | /** | 431 | /** |
427 | Return translated label for note field. | 432 | Return translated label for note field. |
428 | */ | 433 | */ |
429 | static QString noteLabel(); | 434 | static QString noteLabel(); |
430 | 435 | ||
431 | /** | 436 | /** |
432 | Set product identifier. | 437 | Set product identifier. |
433 | */ | 438 | */ |
434 | void setProductId( const QString &productId ); | 439 | void setProductId( const QString &productId ); |
435 | /** | 440 | /** |
436 | Return product identifier. | 441 | Return product identifier. |
437 | */ | 442 | */ |
438 | QString productId() const; | 443 | QString productId() const; |
439 | /** | 444 | /** |
440 | Return translated label for productId field. | 445 | Return translated label for productId field. |
441 | */ | 446 | */ |
442 | static QString productIdLabel(); | 447 | static QString productIdLabel(); |
443 | 448 | ||
444 | /** | 449 | /** |
445 | Set revision date. | 450 | Set revision date. |
446 | */ | 451 | */ |
447 | void setRevision( const QDateTime &revision ); | 452 | void setRevision( const QDateTime &revision ); |
448 | /** | 453 | /** |
449 | Return revision date. | 454 | Return revision date. |
450 | */ | 455 | */ |
451 | QDateTime revision() const; | 456 | QDateTime revision() const; |
452 | /** | 457 | /** |
453 | Return translated label for revision field. | 458 | Return translated label for revision field. |
454 | */ | 459 | */ |
455 | static QString revisionLabel(); | 460 | static QString revisionLabel(); |
456 | 461 | ||
457 | /** | 462 | /** |
458 | Set sort string. | 463 | Set sort string. |
459 | */ | 464 | */ |
460 | void setSortString( const QString &sortString ); | 465 | void setSortString( const QString &sortString ); |
461 | /** | 466 | /** |
462 | Return sort string. | 467 | Return sort string. |
463 | */ | 468 | */ |
464 | QString sortString() const; | 469 | QString sortString() const; |
465 | /** | 470 | /** |
466 | Return translated label for sortString field. | 471 | Return translated label for sortString field. |
467 | */ | 472 | */ |
468 | static QString sortStringLabel(); | 473 | static QString sortStringLabel(); |
469 | 474 | ||
470 | /** | 475 | /** |
471 | Set URL. | 476 | Set URL. |
472 | */ | 477 | */ |
473 | void setUrl( const KURL &url ); | 478 | void setUrl( const KURL &url ); |
474 | /** | 479 | /** |
475 | Return URL. | 480 | Return URL. |
476 | */ | 481 | */ |
477 | KURL url() const; | 482 | KURL url() const; |
478 | /** | 483 | /** |
479 | Return translated label for url field. | 484 | Return translated label for url field. |
480 | */ | 485 | */ |
481 | static QString urlLabel(); | 486 | static QString urlLabel(); |
482 | 487 | ||
483 | /** | 488 | /** |
484 | Set security class. | 489 | Set security class. |
485 | */ | 490 | */ |
486 | void setSecrecy( const Secrecy &secrecy ); | 491 | void setSecrecy( const Secrecy &secrecy ); |
487 | /** | 492 | /** |
488 | Return security class. | 493 | Return security class. |
489 | */ | 494 | */ |
490 | Secrecy secrecy() const; | 495 | Secrecy secrecy() const; |
491 | /** | 496 | /** |
492 | Return translated label for secrecy field. | 497 | Return translated label for secrecy field. |
493 | */ | 498 | */ |
494 | static QString secrecyLabel(); | 499 | static QString secrecyLabel(); |
495 | 500 | ||
496 | /** | 501 | /** |
497 | Set logo. | 502 | Set logo. |
498 | */ | 503 | */ |
499 | void setLogo( const Picture &logo ); | 504 | void setLogo( const Picture &logo ); |
500 | /** | 505 | /** |
501 | Return logo. | 506 | Return logo. |
502 | */ | 507 | */ |
503 | Picture logo() const; | 508 | Picture logo() const; |
504 | /** | 509 | /** |
505 | Return translated label for logo field. | 510 | Return translated label for logo field. |
506 | */ | 511 | */ |
507 | static QString logoLabel(); | 512 | static QString logoLabel(); |
508 | 513 | ||
509 | /** | 514 | /** |
510 | Set photo. | 515 | Set photo. |
511 | */ | 516 | */ |
512 | void setPhoto( const Picture &photo ); | 517 | void setPhoto( const Picture &photo ); |
513 | /** | 518 | /** |
514 | Return photo. | 519 | Return photo. |
515 | */ | 520 | */ |
516 | Picture photo() const; | 521 | Picture photo() const; |
517 | /** | 522 | /** |
518 | Return translated label for photo field. | 523 | Return translated label for photo field. |
519 | */ | 524 | */ |
520 | static QString photoLabel(); | 525 | static QString photoLabel(); |
521 | 526 | ||
522 | /** | 527 | /** |
523 | Set sound. | 528 | Set sound. |
524 | */ | 529 | */ |
525 | void setSound( const Sound &sound ); | 530 | void setSound( const Sound &sound ); |
526 | /** | 531 | /** |
527 | Return sound. | 532 | Return sound. |
528 | */ | 533 | */ |
529 | Sound sound() const; | 534 | Sound sound() const; |
530 | /** | 535 | /** |
531 | Return translated label for sound field. | 536 | Return translated label for sound field. |
532 | */ | 537 | */ |
533 | static QString soundLabel(); | 538 | static QString soundLabel(); |
534 | 539 | ||
535 | /** | 540 | /** |
536 | Set agent. | 541 | Set agent. |
537 | */ | 542 | */ |
538 | void setAgent( const Agent &agent ); | 543 | void setAgent( const Agent &agent ); |
539 | /** | 544 | /** |
540 | Return agent. | 545 | Return agent. |
541 | */ | 546 | */ |
542 | Agent agent() const; | 547 | Agent agent() const; |
543 | /** | 548 | /** |
544 | Return translated label for agent field. | 549 | Return translated label for agent field. |
545 | */ | 550 | */ |
546 | static QString agentLabel(); | 551 | static QString agentLabel(); |
547 | 552 | ||
548 | /** | 553 | /** |
549 | Set name fields by parsing the given string and trying to associate the | 554 | Set name fields by parsing the given string and trying to associate the |
550 | parts of the string with according fields. This function should probably | 555 | parts of the string with according fields. This function should probably |
551 | be a bit more clever. | 556 | be a bit more clever. |
552 | */ | 557 | */ |
553 | void setNameFromString( const QString & ); | 558 | void setNameFromString( const QString & ); |
554 | 559 | ||
555 | /** | 560 | /** |
556 | Return the name of the addressee. This is calculated from all the name | 561 | Return the name of the addressee. This is calculated from all the name |
557 | fields. | 562 | fields. |
558 | */ | 563 | */ |
559 | QString realName() const; | 564 | QString realName() const; |
560 | 565 | ||
561 | /** | 566 | /** |
562 | Return the name that consists of all name parts. | 567 | Return the name that consists of all name parts. |
563 | */ | 568 | */ |
564 | QString assembledName() const; | 569 | QString assembledName() const; |
565 | 570 | ||
566 | /** | 571 | /** |
567 | Return email address including real name. | 572 | Return email address including real name. |
568 | 573 | ||
569 | @param email Email address to be used to construct the full email string. | 574 | @param email Email address to be used to construct the full email string. |
570 | If this is QString::null the preferred email address is used. | 575 | If this is QString::null the preferred email address is used. |
571 | */ | 576 | */ |
572 | QString fullEmail( const QString &email=QString::null ) const; | 577 | QString fullEmail( const QString &email=QString::null ) const; |
573 | 578 | ||
574 | /** | 579 | /** |
575 | Insert an email address. If the email address already exists in this | 580 | Insert an email address. If the email address already exists in this |
576 | addressee it is not duplicated. | 581 | addressee it is not duplicated. |
577 | 582 | ||
578 | @param email Email address | 583 | @param email Email address |
579 | @param preferred Set to true, if this is the preferred email address of | 584 | @param preferred Set to true, if this is the preferred email address of |
580 | the addressee. | 585 | the addressee. |
581 | */ | 586 | */ |
582 | void insertEmail( const QString &email, bool preferred=false ); | 587 | void insertEmail( const QString &email, bool preferred=false ); |
583 | 588 | ||
584 | /** | 589 | /** |
585 | Remove email address. If the email address doesn't exist, nothing happens. | 590 | Remove email address. If the email address doesn't exist, nothing happens. |
586 | */ | 591 | */ |
587 | void removeEmail( const QString &email ); | 592 | void removeEmail( const QString &email ); |
588 | 593 | ||
589 | /** | 594 | /** |
590 | Return preferred email address. This is the first email address or the | 595 | Return preferred email address. This is the first email address or the |
591 | last one added with @ref insertEmail() with a set preferred parameter. | 596 | last one added with @ref insertEmail() with a set preferred parameter. |
592 | */ | 597 | */ |
593 | QString preferredEmail() const; | 598 | QString preferredEmail() const; |
594 | 599 | ||
595 | /** | 600 | /** |
596 | Return list of all email addresses. | 601 | Return list of all email addresses. |
597 | */ | 602 | */ |
598 | QStringList emails() const; | 603 | QStringList emails() const; |
599 | 604 | ||
600 | /** | 605 | /** |
601 | Set the emails to @param. | 606 | Set the emails to @param. |
602 | The first email address gets the preferred one! | 607 | The first email address gets the preferred one! |
603 | @param list The list of email addresses. | 608 | @param list The list of email addresses. |
604 | */ | 609 | */ |
605 | void setEmails( const QStringList& list); | 610 | void setEmails( const QStringList& list); |
606 | 611 | ||
607 | /** | 612 | /** |
608 | Insert a phone number. If a phone number with the same id already exists | 613 | Insert a phone number. If a phone number with the same id already exists |
609 | in this addressee it is not duplicated. | 614 | in this addressee it is not duplicated. |
610 | */ | 615 | */ |
611 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 616 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
612 | 617 | ||
613 | /** | 618 | /** |
614 | Remove phone number. If no phone number with the given id exists for this | 619 | Remove phone number. If no phone number with the given id exists for this |
615 | addresse nothing happens. | 620 | addresse nothing happens. |
616 | */ | 621 | */ |
617 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 622 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
618 | 623 | ||
619 | /** | 624 | /** |
620 | Return phone number, which matches the given type. | 625 | Return phone number, which matches the given type. |
621 | */ | 626 | */ |
622 | PhoneNumber phoneNumber( int type ) const; | 627 | PhoneNumber phoneNumber( int type ) const; |
623 | 628 | ||
624 | /** | 629 | /** |
625 | Return list of all phone numbers. | 630 | Return list of all phone numbers. |
626 | */ | 631 | */ |
627 | PhoneNumber::List phoneNumbers() const; | 632 | PhoneNumber::List phoneNumbers() const; |
628 | 633 | ||
629 | /** | 634 | /** |
630 | Return list of phone numbers with a special type. | 635 | Return list of phone numbers with a special type. |
631 | */ | 636 | */ |
632 | PhoneNumber::List phoneNumbers( int type ) const; | 637 | PhoneNumber::List phoneNumbers( int type ) const; |
633 | 638 | ||
634 | /** | 639 | /** |
635 | Return phone number with the given id. | 640 | Return phone number with the given id. |
636 | */ | 641 | */ |
637 | PhoneNumber findPhoneNumber( const QString &id ) const; | 642 | PhoneNumber findPhoneNumber( const QString &id ) const; |
638 | 643 | ||
639 | /** | 644 | /** |
640 | Insert a key. If a key with the same id already exists | 645 | Insert a key. If a key with the same id already exists |
641 | in this addressee it is not duplicated. | 646 | in this addressee it is not duplicated. |
642 | */ | 647 | */ |
643 | void insertKey( const Key &key ); | 648 | void insertKey( const Key &key ); |
644 | 649 | ||
645 | /** | 650 | /** |
646 | Remove a key. If no key with the given id exists for this | 651 | Remove a key. If no key with the given id exists for this |
647 | addresse nothing happens. | 652 | addresse nothing happens. |
648 | */ | 653 | */ |
649 | void removeKey( const Key &key ); | 654 | void removeKey( const Key &key ); |
650 | 655 | ||
651 | /** | 656 | /** |
652 | Return key, which matches the given type. | 657 | Return key, which matches the given type. |
653 | If @p type == Key::Custom you can specify a string | 658 | If @p type == Key::Custom you can specify a string |
654 | that should match. If you leave the string empty, the first | 659 | that should match. If you leave the string empty, the first |
655 | key with a custom value is returned. | 660 | key with a custom value is returned. |
656 | */ | 661 | */ |
657 | Key key( int type, QString customTypeString = QString::null ) const; | 662 | Key key( int type, QString customTypeString = QString::null ) const; |
658 | 663 | ||
659 | /** | 664 | /** |
660 | Return list of all keys. | 665 | Return list of all keys. |
661 | */ | 666 | */ |
662 | Key::List keys() const; | 667 | Key::List keys() const; |
663 | 668 | ||
664 | /** | 669 | /** |
665 | Set the list of keys | 670 | Set the list of keys |
666 | @param keys The keys to be set. | 671 | @param keys The keys to be set. |
667 | */ | 672 | */ |
668 | void setKeys( const Key::List& keys); | 673 | void setKeys( const Key::List& keys); |
669 | 674 | ||
670 | /** | 675 | /** |
671 | Return list of keys with a special type. | 676 | Return list of keys with a special type. |
672 | If @p type == Key::Custom you can specify a string | 677 | If @p type == Key::Custom you can specify a string |
673 | that should match. If you leave the string empty, all custom | 678 | that should match. If you leave the string empty, all custom |
674 | keys will be returned. | 679 | keys will be returned. |
675 | */ | 680 | */ |
676 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 681 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
677 | 682 | ||
678 | /** | 683 | /** |
679 | Return key with the given id. | 684 | Return key with the given id. |
680 | */ | 685 | */ |
681 | Key findKey( const QString &id ) const; | 686 | Key findKey( const QString &id ) const; |
682 | 687 | ||
683 | /** | 688 | /** |
684 | Insert an address. If an address with the same id already exists | 689 | Insert an address. If an address with the same id already exists |
685 | in this addressee it is not duplicated. | 690 | in this addressee it is not duplicated. |
686 | */ | 691 | */ |
687 | void insertAddress( const Address &address ); | 692 | void insertAddress( const Address &address ); |
688 | 693 | ||
689 | /** | 694 | /** |
690 | Remove address. If no address with the given id exists for this | 695 | Remove address. If no address with the given id exists for this |
691 | addresse nothing happens. | 696 | addresse nothing happens. |
692 | */ | 697 | */ |
693 | void removeAddress( const Address &address ); | 698 | void removeAddress( const Address &address ); |
694 | 699 | ||
695 | /** | 700 | /** |
696 | Return address, which matches the given type. | 701 | Return address, which matches the given type. |
697 | */ | 702 | */ |
698 | Address address( int type ) const; | 703 | Address address( int type ) const; |
699 | 704 | ||
700 | /** | 705 | /** |
701 | Return list of all addresses. | 706 | Return list of all addresses. |
702 | */ | 707 | */ |
703 | Address::List addresses() const; | 708 | Address::List addresses() const; |
704 | 709 | ||
705 | /** | 710 | /** |
706 | Return list of addresses with a special type. | 711 | Return list of addresses with a special type. |
707 | */ | 712 | */ |
708 | Address::List addresses( int type ) const; | 713 | Address::List addresses( int type ) const; |
709 | 714 | ||
710 | /** | 715 | /** |
711 | Return address with the given id. | 716 | Return address with the given id. |
712 | */ | 717 | */ |
713 | Address findAddress( const QString &id ) const; | 718 | Address findAddress( const QString &id ) const; |
714 | 719 | ||
715 | /** | 720 | /** |
716 | Insert category. If the category already exists it is not duplicated. | 721 | Insert category. If the category already exists it is not duplicated. |
717 | */ | 722 | */ |
718 | void insertCategory( const QString & ); | 723 | void insertCategory( const QString & ); |
719 | 724 | ||
720 | /** | 725 | /** |
721 | Remove category. | 726 | Remove category. |
722 | */ | 727 | */ |
723 | void removeCategory( const QString & ); | 728 | void removeCategory( const QString & ); |
724 | 729 | ||
725 | /** | 730 | /** |
726 | Return, if addressee has the given category. | 731 | Return, if addressee has the given category. |
727 | */ | 732 | */ |
728 | bool hasCategory( const QString & ) const; | 733 | bool hasCategory( const QString & ) const; |
729 | 734 | ||
730 | /** | 735 | /** |
731 | Set categories to given value. | 736 | Set categories to given value. |
732 | */ | 737 | */ |
733 | void setCategories( const QStringList & ); | 738 | void setCategories( const QStringList & ); |
734 | 739 | ||
735 | /** | 740 | /** |
736 | Return list of all set categories. | 741 | Return list of all set categories. |
737 | */ | 742 | */ |
738 | QStringList categories() const; | 743 | QStringList categories() const; |
739 | 744 | ||
740 | /** | 745 | /** |
741 | Insert custom entry. The entry is identified by the name of the inserting | 746 | Insert custom entry. The entry is identified by the name of the inserting |
742 | application and a unique name. If an entry with the given app and name | 747 | application and a unique name. If an entry with the given app and name |
743 | already exists its value is replaced with the new given value. | 748 | already exists its value is replaced with the new given value. |
744 | */ | 749 | */ |
745 | void insertCustom( const QString &app, const QString &name, | 750 | void insertCustom( const QString &app, const QString &name, |
746 | const QString &value ); | 751 | const QString &value ); |
747 | 752 | ||
748 | /** | 753 | /** |
749 | Remove custom entry. | 754 | Remove custom entry. |
750 | */ | 755 | */ |
751 | void removeCustom( const QString &app, const QString &name ); | 756 | void removeCustom( const QString &app, const QString &name ); |
752 | 757 | ||
753 | /** | 758 | /** |
754 | Return value of custom entry, identified by app and entry name. | 759 | Return value of custom entry, identified by app and entry name. |
755 | */ | 760 | */ |
756 | QString custom( const QString &app, const QString &name ) const; | 761 | QString custom( const QString &app, const QString &name ) const; |
757 | 762 | ||
758 | /** | 763 | /** |
759 | Set all custom entries. | 764 | Set all custom entries. |
760 | */ | 765 | */ |
761 | void setCustoms( const QStringList & ); | 766 | void setCustoms( const QStringList & ); |
762 | 767 | ||
763 | /** | 768 | /** |
764 | Return list of all custom entries. | 769 | Return list of all custom entries. |
765 | */ | 770 | */ |
766 | QStringList customs() const; | 771 | QStringList customs() const; |
767 | 772 | ||
768 | /** | 773 | /** |
769 | Parse full email address. The result is given back in fullName and email. | 774 | Parse full email address. The result is given back in fullName and email. |
770 | */ | 775 | */ |
771 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 776 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
772 | QString &email ); | 777 | QString &email ); |
773 | 778 | ||
774 | /** | 779 | /** |
775 | Debug output. | 780 | Debug output. |
776 | */ | 781 | */ |
777 | void dump() const; | 782 | void dump() const; |
778 | 783 | ||
779 | /** | 784 | /** |
780 | Returns string representation of the addressee. | 785 | Returns string representation of the addressee. |
781 | */ | 786 | */ |
782 | QString asString() const; | 787 | QString asString() const; |
783 | 788 | ||
784 | /** | 789 | /** |
785 | Set resource where the addressee is from. | 790 | Set resource where the addressee is from. |
786 | */ | 791 | */ |
787 | void setResource( Resource *resource ); | 792 | void setResource( Resource *resource ); |
788 | 793 | ||
789 | /** | 794 | /** |
790 | Return pointer to resource. | 795 | Return pointer to resource. |
791 | */ | 796 | */ |
792 | Resource *resource() const; | 797 | Resource *resource() const; |
793 | 798 | ||
794 | /** | 799 | /** |
795 | Return resourcelabel. | 800 | Return resourcelabel. |
796 | */ | 801 | */ |
797 | //US | 802 | //US |
798 | static QString resourceLabel(); | 803 | static QString resourceLabel(); |
799 | 804 | ||
800 | /** | 805 | /** |
801 | Mark addressee as changed. | 806 | Mark addressee as changed. |
802 | */ | 807 | */ |
803 | void setChanged( bool value ); | 808 | void setChanged( bool value ); |
804 | 809 | ||
805 | /** | 810 | /** |
806 | Return whether the addressee is changed. | 811 | Return whether the addressee is changed. |
807 | */ | 812 | */ |
808 | bool changed() const; | 813 | bool changed() const; |
809 | 814 | ||
810 | private: | 815 | private: |
811 | Addressee copy(); | 816 | Addressee copy(); |
812 | void detach(); | 817 | void detach(); |
813 | 818 | ||
814 | struct AddresseeData; | 819 | struct AddresseeData; |
815 | mutable KSharedPtr<AddresseeData> mData; | 820 | mutable KSharedPtr<AddresseeData> mData; |
816 | }; | 821 | }; |
817 | 822 | ||
818 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 823 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
819 | QDataStream &operator>>( QDataStream &, Addressee & ); | 824 | QDataStream &operator>>( QDataStream &, Addressee & ); |
820 | 825 | ||
821 | } | 826 | } |
822 | 827 | ||
823 | #endif | 828 | #endif |
diff --git a/kabc/field.cpp b/kabc/field.cpp index e27970e..d95cd19 100644 --- a/kabc/field.cpp +++ b/kabc/field.cpp | |||
@@ -1,566 +1,572 @@ | |||
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) 2002 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2002 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 <klocale.h> | 29 | #include <klocale.h> |
30 | #include <kconfig.h> | 30 | #include <kconfig.h> |
31 | #include <kconfigbase.h> | 31 | #include <kconfigbase.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | 33 | ||
34 | #include "field.h" | 34 | #include "field.h" |
35 | #include "resource.h" | 35 | #include "resource.h" |
36 | 36 | ||
37 | using namespace KABC; | 37 | using namespace KABC; |
38 | 38 | ||
39 | class Field::FieldImpl | 39 | class Field::FieldImpl |
40 | { | 40 | { |
41 | public: | 41 | public: |
42 | FieldImpl( int fieldId, int category = 0, | 42 | FieldImpl( int fieldId, int category = 0, |
43 | const QString &label = QString::null, | 43 | const QString &label = QString::null, |
44 | const QString &key = QString::null, | 44 | const QString &key = QString::null, |
45 | const QString &app = QString::null ) | 45 | const QString &app = QString::null ) |
46 | : mFieldId( fieldId ), mCategory( category ), mLabel( label ), | 46 | : mFieldId( fieldId ), mCategory( category ), mLabel( label ), |
47 | mKey( key ), mApp( app ) {} | 47 | mKey( key ), mApp( app ) {} |
48 | 48 | ||
49 | enum FieldId | 49 | enum FieldId |
50 | { | 50 | { |
51 | CustomField, | 51 | CustomField, |
52 | FormattedName, | 52 | FormattedName, |
53 | FamilyName, | 53 | FamilyName, |
54 | GivenName, | 54 | GivenName, |
55 | AdditionalName, | 55 | AdditionalName, |
56 | Prefix, | 56 | Prefix, |
57 | Suffix, | 57 | Suffix, |
58 | NickName, | 58 | NickName, |
59 | Birthday, | 59 | Birthday, |
60 | HomeAddressStreet, | 60 | HomeAddressStreet, |
61 | HomeAddressLocality, | 61 | HomeAddressLocality, |
62 | HomeAddressRegion, | 62 | HomeAddressRegion, |
63 | HomeAddressPostalCode, | 63 | HomeAddressPostalCode, |
64 | HomeAddressCountry, | 64 | HomeAddressCountry, |
65 | HomeAddressLabel, | 65 | HomeAddressLabel, |
66 | BusinessAddressStreet, | 66 | BusinessAddressStreet, |
67 | BusinessAddressLocality, | 67 | BusinessAddressLocality, |
68 | BusinessAddressRegion, | 68 | BusinessAddressRegion, |
69 | BusinessAddressPostalCode, | 69 | BusinessAddressPostalCode, |
70 | BusinessAddressCountry, | 70 | BusinessAddressCountry, |
71 | BusinessAddressLabel, | 71 | BusinessAddressLabel, |
72 | HomePhone, | 72 | HomePhone, |
73 | BusinessPhone, | 73 | BusinessPhone, |
74 | MobilePhone, | 74 | MobilePhone, |
75 | HomeFax, | 75 | HomeFax, |
76 | BusinessFax, | 76 | BusinessFax, |
77 | CarPhone, | 77 | CarPhone, |
78 | Isdn, | 78 | Isdn, |
79 | Pager, | 79 | Pager, |
80 | Email, | 80 | Email, |
81 | Mailer, | 81 | Mailer, |
82 | Title, | 82 | Title, |
83 | Role, | 83 | Role, |
84 | Organization, | 84 | Organization, |
85 | Note, | 85 | Note, |
86 | Url, | 86 | Url, |
87 | Resource | 87 | Resource, |
88 | Sip | ||
88 | }; | 89 | }; |
89 | 90 | ||
90 | int fieldId() { return mFieldId; } | 91 | int fieldId() { return mFieldId; } |
91 | int category() { return mCategory; } | 92 | int category() { return mCategory; } |
92 | 93 | ||
93 | QString label() { return mLabel; } | 94 | QString label() { return mLabel; } |
94 | QString key() { return mKey; } | 95 | QString key() { return mKey; } |
95 | QString app() { return mApp; } | 96 | QString app() { return mApp; } |
96 | 97 | ||
97 | private: | 98 | private: |
98 | int mFieldId; | 99 | int mFieldId; |
99 | int mCategory; | 100 | int mCategory; |
100 | 101 | ||
101 | QString mLabel; | 102 | QString mLabel; |
102 | QString mKey; | 103 | QString mKey; |
103 | QString mApp; | 104 | QString mApp; |
104 | }; | 105 | }; |
105 | 106 | ||
106 | 107 | ||
107 | Field::List Field::mAllFields; | 108 | Field::List Field::mAllFields; |
108 | Field::List Field::mDefaultFields; | 109 | Field::List Field::mDefaultFields; |
109 | Field::List Field::mCustomFields; | 110 | Field::List Field::mCustomFields; |
110 | 111 | ||
111 | 112 | ||
112 | Field::Field( FieldImpl *impl ) | 113 | Field::Field( FieldImpl *impl ) |
113 | { | 114 | { |
114 | mImpl = impl; | 115 | mImpl = impl; |
115 | } | 116 | } |
116 | 117 | ||
117 | Field::~Field() | 118 | Field::~Field() |
118 | { | 119 | { |
119 | delete mImpl; | 120 | delete mImpl; |
120 | } | 121 | } |
121 | 122 | ||
122 | QString Field::label() | 123 | QString Field::label() |
123 | { | 124 | { |
124 | switch ( mImpl->fieldId() ) { | 125 | switch ( mImpl->fieldId() ) { |
125 | case FieldImpl::FormattedName: | 126 | case FieldImpl::FormattedName: |
126 | return Addressee::formattedNameLabel(); | 127 | return Addressee::formattedNameLabel(); |
127 | case FieldImpl::FamilyName: | 128 | case FieldImpl::FamilyName: |
128 | return Addressee::familyNameLabel(); | 129 | return Addressee::familyNameLabel(); |
129 | case FieldImpl::GivenName: | 130 | case FieldImpl::GivenName: |
130 | return Addressee::givenNameLabel(); | 131 | return Addressee::givenNameLabel(); |
131 | case FieldImpl::AdditionalName: | 132 | case FieldImpl::AdditionalName: |
132 | return Addressee::additionalNameLabel(); | 133 | return Addressee::additionalNameLabel(); |
133 | case FieldImpl::Prefix: | 134 | case FieldImpl::Prefix: |
134 | return Addressee::prefixLabel(); | 135 | return Addressee::prefixLabel(); |
135 | case FieldImpl::Suffix: | 136 | case FieldImpl::Suffix: |
136 | return Addressee::suffixLabel(); | 137 | return Addressee::suffixLabel(); |
137 | case FieldImpl::NickName: | 138 | case FieldImpl::NickName: |
138 | return Addressee::nickNameLabel(); | 139 | return Addressee::nickNameLabel(); |
139 | case FieldImpl::Birthday: | 140 | case FieldImpl::Birthday: |
140 | return Addressee::birthdayLabel(); | 141 | return Addressee::birthdayLabel(); |
141 | case FieldImpl::HomeAddressStreet: | 142 | case FieldImpl::HomeAddressStreet: |
142 | return Addressee::homeAddressStreetLabel(); | 143 | return Addressee::homeAddressStreetLabel(); |
143 | case FieldImpl::HomeAddressLocality: | 144 | case FieldImpl::HomeAddressLocality: |
144 | return Addressee::homeAddressLocalityLabel(); | 145 | return Addressee::homeAddressLocalityLabel(); |
145 | case FieldImpl::HomeAddressRegion: | 146 | case FieldImpl::HomeAddressRegion: |
146 | return Addressee::homeAddressRegionLabel(); | 147 | return Addressee::homeAddressRegionLabel(); |
147 | case FieldImpl::HomeAddressPostalCode: | 148 | case FieldImpl::HomeAddressPostalCode: |
148 | return Addressee::homeAddressPostalCodeLabel(); | 149 | return Addressee::homeAddressPostalCodeLabel(); |
149 | case FieldImpl::HomeAddressCountry: | 150 | case FieldImpl::HomeAddressCountry: |
150 | return Addressee::homeAddressCountryLabel(); | 151 | return Addressee::homeAddressCountryLabel(); |
151 | case FieldImpl::HomeAddressLabel: | 152 | case FieldImpl::HomeAddressLabel: |
152 | return Addressee::homeAddressLabelLabel(); | 153 | return Addressee::homeAddressLabelLabel(); |
153 | case FieldImpl::BusinessAddressStreet: | 154 | case FieldImpl::BusinessAddressStreet: |
154 | return Addressee::businessAddressStreetLabel(); | 155 | return Addressee::businessAddressStreetLabel(); |
155 | case FieldImpl::BusinessAddressLocality: | 156 | case FieldImpl::BusinessAddressLocality: |
156 | return Addressee::businessAddressLocalityLabel(); | 157 | return Addressee::businessAddressLocalityLabel(); |
157 | case FieldImpl::BusinessAddressRegion: | 158 | case FieldImpl::BusinessAddressRegion: |
158 | return Addressee::businessAddressRegionLabel(); | 159 | return Addressee::businessAddressRegionLabel(); |
159 | case FieldImpl::BusinessAddressPostalCode: | 160 | case FieldImpl::BusinessAddressPostalCode: |
160 | return Addressee::businessAddressPostalCodeLabel(); | 161 | return Addressee::businessAddressPostalCodeLabel(); |
161 | case FieldImpl::BusinessAddressCountry: | 162 | case FieldImpl::BusinessAddressCountry: |
162 | return Addressee::businessAddressCountryLabel(); | 163 | return Addressee::businessAddressCountryLabel(); |
163 | case FieldImpl::BusinessAddressLabel: | 164 | case FieldImpl::BusinessAddressLabel: |
164 | return Addressee::businessAddressLabelLabel(); | 165 | return Addressee::businessAddressLabelLabel(); |
165 | case FieldImpl::HomePhone: | 166 | case FieldImpl::HomePhone: |
166 | return Addressee::homePhoneLabel(); | 167 | return Addressee::homePhoneLabel(); |
167 | case FieldImpl::BusinessPhone: | 168 | case FieldImpl::BusinessPhone: |
168 | return Addressee::businessPhoneLabel(); | 169 | return Addressee::businessPhoneLabel(); |
169 | case FieldImpl::MobilePhone: | 170 | case FieldImpl::MobilePhone: |
170 | return Addressee::mobilePhoneLabel(); | 171 | return Addressee::mobilePhoneLabel(); |
171 | case FieldImpl::HomeFax: | 172 | case FieldImpl::HomeFax: |
172 | return Addressee::homeFaxLabel(); | 173 | return Addressee::homeFaxLabel(); |
173 | case FieldImpl::BusinessFax: | 174 | case FieldImpl::BusinessFax: |
174 | return Addressee::businessFaxLabel(); | 175 | return Addressee::businessFaxLabel(); |
175 | case FieldImpl::CarPhone: | 176 | case FieldImpl::CarPhone: |
176 | return Addressee::carPhoneLabel(); | 177 | return Addressee::carPhoneLabel(); |
177 | case FieldImpl::Isdn: | 178 | case FieldImpl::Isdn: |
178 | return Addressee::isdnLabel(); | 179 | return Addressee::isdnLabel(); |
179 | case FieldImpl::Pager: | 180 | case FieldImpl::Pager: |
180 | return Addressee::pagerLabel(); | 181 | return Addressee::pagerLabel(); |
181 | case FieldImpl::Email: | 182 | case FieldImpl::Email: |
182 | return Addressee::emailLabel(); | 183 | return Addressee::emailLabel(); |
183 | case FieldImpl::Mailer: | 184 | case FieldImpl::Mailer: |
184 | return Addressee::mailerLabel(); | 185 | return Addressee::mailerLabel(); |
185 | case FieldImpl::Title: | 186 | case FieldImpl::Title: |
186 | return Addressee::titleLabel(); | 187 | return Addressee::titleLabel(); |
187 | case FieldImpl::Role: | 188 | case FieldImpl::Role: |
188 | return Addressee::roleLabel(); | 189 | return Addressee::roleLabel(); |
189 | case FieldImpl::Organization: | 190 | case FieldImpl::Organization: |
190 | return Addressee::organizationLabel(); | 191 | return Addressee::organizationLabel(); |
191 | case FieldImpl::Note: | 192 | case FieldImpl::Note: |
192 | return Addressee::noteLabel(); | 193 | return Addressee::noteLabel(); |
193 | case FieldImpl::Url: | 194 | case FieldImpl::Url: |
194 | return Addressee::urlLabel(); | 195 | return Addressee::urlLabel(); |
195 | case FieldImpl::Resource: | 196 | case FieldImpl::Resource: |
196 | return Addressee::resourceLabel(); | 197 | return Addressee::resourceLabel(); |
198 | case FieldImpl::Sip: | ||
199 | return Addressee::sipLabel(); | ||
197 | case FieldImpl::CustomField: | 200 | case FieldImpl::CustomField: |
198 | return mImpl->label(); | 201 | return mImpl->label(); |
199 | default: | 202 | default: |
200 | return i18n("Unknown Field"); | 203 | return i18n("Unknown Field"); |
201 | } | 204 | } |
202 | } | 205 | } |
203 | 206 | ||
204 | int Field::category() | 207 | int Field::category() |
205 | { | 208 | { |
206 | return mImpl->category(); | 209 | return mImpl->category(); |
207 | } | 210 | } |
208 | 211 | ||
209 | QString Field::categoryLabel( int category ) | 212 | QString Field::categoryLabel( int category ) |
210 | { | 213 | { |
211 | switch ( category ) { | 214 | switch ( category ) { |
212 | case All: | 215 | case All: |
213 | return i18n("All"); | 216 | return i18n("All"); |
214 | case Frequent: | 217 | case Frequent: |
215 | return i18n("Frequent"); | 218 | return i18n("Frequent"); |
216 | case Address: | 219 | case Address: |
217 | return i18n("Address"); | 220 | return i18n("Address"); |
218 | case Email: | 221 | case Email: |
219 | return i18n("Email"); | 222 | return i18n("Email"); |
220 | case Personal: | 223 | case Personal: |
221 | return i18n("Personal"); | 224 | return i18n("Personal"); |
222 | case Organization: | 225 | case Organization: |
223 | return i18n("Organization"); | 226 | return i18n("Organization"); |
224 | case CustomCategory: | 227 | case CustomCategory: |
225 | return i18n("Custom"); | 228 | return i18n("Custom"); |
226 | default: | 229 | default: |
227 | return i18n("Undefined"); | 230 | return i18n("Undefined"); |
228 | } | 231 | } |
229 | } | 232 | } |
230 | 233 | ||
231 | QString Field::value( const KABC::Addressee &a ) | 234 | QString Field::value( const KABC::Addressee &a ) |
232 | { | 235 | { |
233 | switch ( mImpl->fieldId() ) { | 236 | switch ( mImpl->fieldId() ) { |
234 | case FieldImpl::FormattedName: | 237 | case FieldImpl::FormattedName: |
235 | return a.formattedName(); | 238 | return a.formattedName(); |
236 | case FieldImpl::FamilyName: | 239 | case FieldImpl::FamilyName: |
237 | return a.familyName(); | 240 | return a.familyName(); |
238 | case FieldImpl::GivenName: | 241 | case FieldImpl::GivenName: |
239 | return a.givenName(); | 242 | return a.givenName(); |
240 | case FieldImpl::AdditionalName: | 243 | case FieldImpl::AdditionalName: |
241 | return a.additionalName(); | 244 | return a.additionalName(); |
242 | case FieldImpl::Prefix: | 245 | case FieldImpl::Prefix: |
243 | return a.prefix(); | 246 | return a.prefix(); |
244 | case FieldImpl::Suffix: | 247 | case FieldImpl::Suffix: |
245 | return a.suffix(); | 248 | return a.suffix(); |
246 | case FieldImpl::NickName: | 249 | case FieldImpl::NickName: |
247 | return a.nickName(); | 250 | return a.nickName(); |
248 | case FieldImpl::Mailer: | 251 | case FieldImpl::Mailer: |
249 | return a.mailer(); | 252 | return a.mailer(); |
250 | case FieldImpl::Title: | 253 | case FieldImpl::Title: |
251 | return a.title(); | 254 | return a.title(); |
252 | case FieldImpl::Role: | 255 | case FieldImpl::Role: |
253 | return a.role(); | 256 | return a.role(); |
254 | case FieldImpl::Organization: | 257 | case FieldImpl::Organization: |
255 | return a.organization(); | 258 | return a.organization(); |
256 | case FieldImpl::Note: | 259 | case FieldImpl::Note: |
257 | return a.note(); | 260 | return a.note(); |
258 | case FieldImpl::Email: | 261 | case FieldImpl::Email: |
259 | return a.preferredEmail(); | 262 | return a.preferredEmail(); |
260 | case FieldImpl::Birthday: | 263 | case FieldImpl::Birthday: |
261 | if ( a.birthday().isValid() ) { | 264 | if ( a.birthday().isValid() ) { |
262 | //the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); | 265 | //the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); |
263 | // But Qt::IsoDate was not specified. | 266 | // But Qt::IsoDate was not specified. |
264 | // QString _oldFormat = KGlobal::locale()->dateFormat(); | 267 | // QString _oldFormat = KGlobal::locale()->dateFormat(); |
265 | // KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate | 268 | // KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate |
266 | QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); | 269 | QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); |
267 | // KGlobal::locale()->setDateFormat(_oldFormat); | 270 | // KGlobal::locale()->setDateFormat(_oldFormat); |
268 | return dt; | 271 | return dt; |
269 | } | 272 | } |
270 | else | 273 | else |
271 | return QString::null; | 274 | return QString::null; |
272 | case FieldImpl::Url: | 275 | case FieldImpl::Url: |
273 | return a.url().prettyURL(); | 276 | return a.url().prettyURL(); |
274 | //US | 277 | //US |
275 | case FieldImpl::Resource: | 278 | case FieldImpl::Resource: |
276 | return a.resource()->resourceName(); | 279 | return a.resource()->resourceName(); |
277 | case FieldImpl::HomePhone: | 280 | case FieldImpl::HomePhone: |
278 | return a.phoneNumber( PhoneNumber::Home ).number(); | 281 | return a.phoneNumber( PhoneNumber::Home ).number(); |
279 | case FieldImpl::BusinessPhone: | 282 | case FieldImpl::BusinessPhone: |
280 | return a.phoneNumber( PhoneNumber::Work ).number(); | 283 | return a.phoneNumber( PhoneNumber::Work ).number(); |
281 | case FieldImpl::MobilePhone: | 284 | case FieldImpl::MobilePhone: |
282 | return a.phoneNumber( PhoneNumber::Cell ).number(); | 285 | return a.phoneNumber( PhoneNumber::Cell ).number(); |
283 | case FieldImpl::HomeFax: | 286 | case FieldImpl::HomeFax: |
284 | return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); | 287 | return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); |
285 | case FieldImpl::BusinessFax: | 288 | case FieldImpl::BusinessFax: |
286 | return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); | 289 | return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); |
287 | case FieldImpl::CarPhone: | 290 | case FieldImpl::CarPhone: |
288 | return a.phoneNumber( PhoneNumber::Car ).number(); | 291 | return a.phoneNumber( PhoneNumber::Car ).number(); |
289 | case FieldImpl::Isdn: | 292 | case FieldImpl::Isdn: |
290 | return a.phoneNumber( PhoneNumber::Isdn ).number(); | 293 | return a.phoneNumber( PhoneNumber::Isdn ).number(); |
291 | case FieldImpl::Pager: | 294 | case FieldImpl::Pager: |
292 | return a.phoneNumber( PhoneNumber::Pager ).number(); | 295 | return a.phoneNumber( PhoneNumber::Pager ).number(); |
296 | case FieldImpl::Sip: | ||
297 | return a.phoneNumber( PhoneNumber::Sip ).number(); | ||
293 | case FieldImpl::HomeAddressStreet: | 298 | case FieldImpl::HomeAddressStreet: |
294 | return a.address( Address::Home ).street(); | 299 | return a.address( Address::Home ).street(); |
295 | case FieldImpl::HomeAddressLocality: | 300 | case FieldImpl::HomeAddressLocality: |
296 | return a.address( Address::Home ).locality(); | 301 | return a.address( Address::Home ).locality(); |
297 | case FieldImpl::HomeAddressRegion: | 302 | case FieldImpl::HomeAddressRegion: |
298 | return a.address( Address::Home ).region(); | 303 | return a.address( Address::Home ).region(); |
299 | case FieldImpl::HomeAddressPostalCode: | 304 | case FieldImpl::HomeAddressPostalCode: |
300 | return a.address( Address::Home ).postalCode(); | 305 | return a.address( Address::Home ).postalCode(); |
301 | case FieldImpl::HomeAddressCountry: | 306 | case FieldImpl::HomeAddressCountry: |
302 | return a.address( Address::Home ).country(); | 307 | return a.address( Address::Home ).country(); |
303 | case FieldImpl::BusinessAddressStreet: | 308 | case FieldImpl::BusinessAddressStreet: |
304 | return a.address( Address::Work ).street(); | 309 | return a.address( Address::Work ).street(); |
305 | case FieldImpl::BusinessAddressLocality: | 310 | case FieldImpl::BusinessAddressLocality: |
306 | return a.address( Address::Work ).locality(); | 311 | return a.address( Address::Work ).locality(); |
307 | case FieldImpl::BusinessAddressRegion: | 312 | case FieldImpl::BusinessAddressRegion: |
308 | return a.address( Address::Work ).region(); | 313 | return a.address( Address::Work ).region(); |
309 | case FieldImpl::BusinessAddressPostalCode: | 314 | case FieldImpl::BusinessAddressPostalCode: |
310 | return a.address( Address::Work ).postalCode(); | 315 | return a.address( Address::Work ).postalCode(); |
311 | case FieldImpl::BusinessAddressCountry: | 316 | case FieldImpl::BusinessAddressCountry: |
312 | return a.address( Address::Work ).country(); | 317 | return a.address( Address::Work ).country(); |
313 | case FieldImpl::CustomField: | 318 | case FieldImpl::CustomField: |
314 | return a.custom( mImpl->app(), mImpl->key() ); | 319 | return a.custom( mImpl->app(), mImpl->key() ); |
315 | default: | 320 | default: |
316 | return QString::null; | 321 | return QString::null; |
317 | } | 322 | } |
318 | } | 323 | } |
319 | 324 | ||
320 | bool Field::setValue( KABC::Addressee &a, const QString &value ) | 325 | bool Field::setValue( KABC::Addressee &a, const QString &value ) |
321 | { | 326 | { |
322 | switch ( mImpl->fieldId() ) { | 327 | switch ( mImpl->fieldId() ) { |
323 | case FieldImpl::FormattedName: | 328 | case FieldImpl::FormattedName: |
324 | a.setFormattedName( value ); | 329 | a.setFormattedName( value ); |
325 | return true; | 330 | return true; |
326 | case FieldImpl::FamilyName: | 331 | case FieldImpl::FamilyName: |
327 | a.setFamilyName( value ); | 332 | a.setFamilyName( value ); |
328 | return true; | 333 | return true; |
329 | case FieldImpl::GivenName: | 334 | case FieldImpl::GivenName: |
330 | a.setGivenName( value ); | 335 | a.setGivenName( value ); |
331 | return true; | 336 | return true; |
332 | case FieldImpl::AdditionalName: | 337 | case FieldImpl::AdditionalName: |
333 | a.setAdditionalName( value ); | 338 | a.setAdditionalName( value ); |
334 | return true; | 339 | return true; |
335 | case FieldImpl::Prefix: | 340 | case FieldImpl::Prefix: |
336 | a.setPrefix( value ); | 341 | a.setPrefix( value ); |
337 | return true; | 342 | return true; |
338 | case FieldImpl::Suffix: | 343 | case FieldImpl::Suffix: |
339 | a.setSuffix( value ); | 344 | a.setSuffix( value ); |
340 | return true; | 345 | return true; |
341 | case FieldImpl::NickName: | 346 | case FieldImpl::NickName: |
342 | a.setNickName( value ); | 347 | a.setNickName( value ); |
343 | return true; | 348 | return true; |
344 | case FieldImpl::Mailer: | 349 | case FieldImpl::Mailer: |
345 | a.setMailer( value ); | 350 | a.setMailer( value ); |
346 | return true; | 351 | return true; |
347 | case FieldImpl::Title: | 352 | case FieldImpl::Title: |
348 | a.setTitle( value ); | 353 | a.setTitle( value ); |
349 | return true; | 354 | return true; |
350 | case FieldImpl::Role: | 355 | case FieldImpl::Role: |
351 | a.setRole( value ); | 356 | a.setRole( value ); |
352 | return true; | 357 | return true; |
353 | case FieldImpl::Organization: | 358 | case FieldImpl::Organization: |
354 | a.setOrganization( value ); | 359 | a.setOrganization( value ); |
355 | return true; | 360 | return true; |
356 | case FieldImpl::Note: | 361 | case FieldImpl::Note: |
357 | a.setNote( value ); | 362 | a.setNote( value ); |
358 | return true; | 363 | return true; |
359 | case FieldImpl::Birthday: | 364 | case FieldImpl::Birthday: |
360 | //US | 365 | //US |
361 | //the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); | 366 | //the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); |
362 | // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? | 367 | // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? |
363 | { | 368 | { |
364 | QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate | 369 | QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate |
365 | a.setBirthday(dt); | 370 | a.setBirthday(dt); |
366 | } | 371 | } |
367 | return true; | 372 | return true; |
368 | case FieldImpl::CustomField: | 373 | case FieldImpl::CustomField: |
369 | a.insertCustom( mImpl->app(), mImpl->key(), value ); | 374 | a.insertCustom( mImpl->app(), mImpl->key(), value ); |
370 | //US never copy the resourcename back to the adressee. | 375 | //US never copy the resourcename back to the adressee. |
371 | case FieldImpl::Resource: | 376 | case FieldImpl::Resource: |
372 | default: | 377 | default: |
373 | return false; | 378 | return false; |
374 | } | 379 | } |
375 | } | 380 | } |
376 | 381 | ||
377 | bool Field::isCustom() | 382 | bool Field::isCustom() |
378 | { | 383 | { |
379 | return mImpl->fieldId() == FieldImpl::CustomField; | 384 | return mImpl->fieldId() == FieldImpl::CustomField; |
380 | } | 385 | } |
381 | 386 | ||
382 | Field::List Field::allFields() | 387 | Field::List Field::allFields() |
383 | { | 388 | { |
384 | if ( mAllFields.isEmpty() ) { | 389 | if ( mAllFields.isEmpty() ) { |
385 | createField( FieldImpl::FormattedName, Frequent ); | 390 | createField( FieldImpl::FormattedName, Frequent ); |
386 | createField( FieldImpl::FamilyName, Frequent ); | 391 | createField( FieldImpl::FamilyName, Frequent ); |
387 | createField( FieldImpl::GivenName, Frequent ); | 392 | createField( FieldImpl::GivenName, Frequent ); |
388 | createField( FieldImpl::AdditionalName ); | 393 | createField( FieldImpl::AdditionalName ); |
389 | createField( FieldImpl::Prefix ); | 394 | createField( FieldImpl::Prefix ); |
390 | createField( FieldImpl::Suffix ); | 395 | createField( FieldImpl::Suffix ); |
391 | createField( FieldImpl::NickName, Personal ); | 396 | createField( FieldImpl::NickName, Personal ); |
392 | createField( FieldImpl::Birthday, Personal ); | 397 | createField( FieldImpl::Birthday, Personal ); |
393 | createField( FieldImpl::HomeAddressStreet, Address|Personal ); | 398 | createField( FieldImpl::HomeAddressStreet, Address|Personal ); |
394 | createField( FieldImpl::HomeAddressLocality, Address|Personal ); | 399 | createField( FieldImpl::HomeAddressLocality, Address|Personal ); |
395 | createField( FieldImpl::HomeAddressRegion, Address|Personal ); | 400 | createField( FieldImpl::HomeAddressRegion, Address|Personal ); |
396 | createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); | 401 | createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); |
397 | createField( FieldImpl::HomeAddressCountry, Address|Personal ); | 402 | createField( FieldImpl::HomeAddressCountry, Address|Personal ); |
398 | createField( FieldImpl::HomeAddressLabel, Address|Personal ); | 403 | createField( FieldImpl::HomeAddressLabel, Address|Personal ); |
399 | createField( FieldImpl::BusinessAddressStreet, Address|Organization ); | 404 | createField( FieldImpl::BusinessAddressStreet, Address|Organization ); |
400 | createField( FieldImpl::BusinessAddressLocality, Address|Organization ); | 405 | createField( FieldImpl::BusinessAddressLocality, Address|Organization ); |
401 | createField( FieldImpl::BusinessAddressRegion, Address|Organization ); | 406 | createField( FieldImpl::BusinessAddressRegion, Address|Organization ); |
402 | createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); | 407 | createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); |
403 | createField( FieldImpl::BusinessAddressCountry, Address|Organization ); | 408 | createField( FieldImpl::BusinessAddressCountry, Address|Organization ); |
404 | createField( FieldImpl::BusinessAddressLabel, Address|Organization ); | 409 | createField( FieldImpl::BusinessAddressLabel, Address|Organization ); |
405 | createField( FieldImpl::HomePhone, Personal|Frequent ); | 410 | createField( FieldImpl::HomePhone, Personal|Frequent ); |
406 | createField( FieldImpl::BusinessPhone, Organization|Frequent ); | 411 | createField( FieldImpl::BusinessPhone, Organization|Frequent ); |
407 | createField( FieldImpl::MobilePhone, Frequent ); | 412 | createField( FieldImpl::MobilePhone, Frequent ); |
408 | createField( FieldImpl::HomeFax ); | 413 | createField( FieldImpl::HomeFax ); |
409 | createField( FieldImpl::BusinessFax ); | 414 | createField( FieldImpl::BusinessFax ); |
410 | createField( FieldImpl::CarPhone ); | 415 | createField( FieldImpl::CarPhone ); |
411 | createField( FieldImpl::Isdn ); | 416 | createField( FieldImpl::Isdn ); |
412 | createField( FieldImpl::Pager ); | 417 | createField( FieldImpl::Pager ); |
413 | createField( FieldImpl::Email, Email|Frequent ); | 418 | createField( FieldImpl::Email, Email|Frequent ); |
414 | createField( FieldImpl::Mailer, Email ); | 419 | createField( FieldImpl::Mailer, Email ); |
415 | createField( FieldImpl::Title, Organization ); | 420 | createField( FieldImpl::Title, Organization ); |
416 | createField( FieldImpl::Role, Organization ); | 421 | createField( FieldImpl::Role, Organization ); |
417 | createField( FieldImpl::Organization, Organization ); | 422 | createField( FieldImpl::Organization, Organization ); |
418 | createField( FieldImpl::Note ); | 423 | createField( FieldImpl::Note ); |
419 | createField( FieldImpl::Url ); | 424 | createField( FieldImpl::Url ); |
420 | createField( FieldImpl::Resource ); | 425 | createField( FieldImpl::Resource ); |
426 | createField( FieldImpl::Sip ); | ||
421 | } | 427 | } |
422 | 428 | ||
423 | return mAllFields; | 429 | return mAllFields; |
424 | } | 430 | } |
425 | 431 | ||
426 | Field::List Field::defaultFields() | 432 | Field::List Field::defaultFields() |
427 | { | 433 | { |
428 | if ( mDefaultFields.isEmpty() ) { | 434 | if ( mDefaultFields.isEmpty() ) { |
429 | createDefaultField( FieldImpl::GivenName ); | 435 | createDefaultField( FieldImpl::GivenName ); |
430 | createDefaultField( FieldImpl::FamilyName ); | 436 | createDefaultField( FieldImpl::FamilyName ); |
431 | createDefaultField( FieldImpl::Email ); | 437 | createDefaultField( FieldImpl::Email ); |
432 | } | 438 | } |
433 | 439 | ||
434 | return mDefaultFields; | 440 | return mDefaultFields; |
435 | } | 441 | } |
436 | 442 | ||
437 | void Field::createField( int id, int category ) | 443 | void Field::createField( int id, int category ) |
438 | { | 444 | { |
439 | mAllFields.append( new Field( new FieldImpl( id, category ) ) ); | 445 | mAllFields.append( new Field( new FieldImpl( id, category ) ) ); |
440 | } | 446 | } |
441 | 447 | ||
442 | void Field::createDefaultField( int id, int category ) | 448 | void Field::createDefaultField( int id, int category ) |
443 | { | 449 | { |
444 | mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); | 450 | mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); |
445 | } | 451 | } |
446 | 452 | ||
447 | void Field::deleteFields() | 453 | void Field::deleteFields() |
448 | { | 454 | { |
449 | Field::List::ConstIterator it; | 455 | Field::List::ConstIterator it; |
450 | 456 | ||
451 | for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { | 457 | for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { |
452 | delete (*it); | 458 | delete (*it); |
453 | } | 459 | } |
454 | mAllFields.clear(); | 460 | mAllFields.clear(); |
455 | 461 | ||
456 | for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { | 462 | for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { |
457 | delete (*it); | 463 | delete (*it); |
458 | } | 464 | } |
459 | mDefaultFields.clear(); | 465 | mDefaultFields.clear(); |
460 | 466 | ||
461 | for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { | 467 | for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { |
462 | delete (*it); | 468 | delete (*it); |
463 | } | 469 | } |
464 | mCustomFields.clear(); | 470 | mCustomFields.clear(); |
465 | } | 471 | } |
466 | 472 | ||
467 | void Field::saveFields( const QString &identifier, | 473 | void Field::saveFields( const QString &identifier, |
468 | const Field::List &fields ) | 474 | const Field::List &fields ) |
469 | { | 475 | { |
470 | KConfig *cfg = KGlobal::config(); | 476 | KConfig *cfg = KGlobal::config(); |
471 | KConfigGroupSaver( cfg, "KABCFields" ); | 477 | KConfigGroupSaver( cfg, "KABCFields" ); |
472 | saveFields( cfg, identifier, fields ); | 478 | saveFields( cfg, identifier, fields ); |
473 | } | 479 | } |
474 | 480 | ||
475 | void Field::saveFields( KConfig *cfg, const QString &identifier, | 481 | void Field::saveFields( KConfig *cfg, const QString &identifier, |
476 | const Field::List &fields ) | 482 | const Field::List &fields ) |
477 | { | 483 | { |
478 | QValueList<int> fieldIds; | 484 | QValueList<int> fieldIds; |
479 | 485 | ||
480 | //US | 486 | //US |
481 | // qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); | 487 | // qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); |
482 | 488 | ||
483 | int custom = 0; | 489 | int custom = 0; |
484 | Field::List::ConstIterator it; | 490 | Field::List::ConstIterator it; |
485 | for( it = fields.begin(); it != fields.end(); ++it ) { | 491 | for( it = fields.begin(); it != fields.end(); ++it ) { |
486 | //US | 492 | //US |
487 | // qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); | 493 | // qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); |
488 | 494 | ||
489 | fieldIds.append( (*it)->mImpl->fieldId() ); | 495 | fieldIds.append( (*it)->mImpl->fieldId() ); |
490 | if( (*it)->isCustom() ) { | 496 | if( (*it)->isCustom() ) { |
491 | QStringList customEntry; | 497 | QStringList customEntry; |
492 | customEntry << (*it)->mImpl->label(); | 498 | customEntry << (*it)->mImpl->label(); |
493 | customEntry << (*it)->mImpl->key(); | 499 | customEntry << (*it)->mImpl->key(); |
494 | customEntry << (*it)->mImpl->app(); | 500 | customEntry << (*it)->mImpl->app(); |
495 | cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + | 501 | cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + |
496 | QString::number( custom++ ), customEntry ); | 502 | QString::number( custom++ ), customEntry ); |
497 | } | 503 | } |
498 | } | 504 | } |
499 | cfg->writeEntry( identifier, fieldIds ); | 505 | cfg->writeEntry( identifier, fieldIds ); |
500 | } | 506 | } |
501 | 507 | ||
502 | Field::List Field::restoreFields( const QString &identifier ) | 508 | Field::List Field::restoreFields( const QString &identifier ) |
503 | { | 509 | { |
504 | //US | 510 | //US |
505 | // qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); | 511 | // qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); |
506 | 512 | ||
507 | KConfig *cfg = KGlobal::config(); | 513 | KConfig *cfg = KGlobal::config(); |
508 | KConfigGroupSaver( cfg, "KABCFields" ); | 514 | KConfigGroupSaver( cfg, "KABCFields" ); |
509 | cfg->setGroup( "KABCFields" ); | 515 | cfg->setGroup( "KABCFields" ); |
510 | 516 | ||
511 | Field::List l = restoreFields( cfg, identifier ); | 517 | Field::List l = restoreFields( cfg, identifier ); |
512 | 518 | ||
513 | return l; | 519 | return l; |
514 | } | 520 | } |
515 | 521 | ||
516 | Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) | 522 | Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) |
517 | { | 523 | { |
518 | QValueList<int> fieldIds = cfg->readIntListEntry( identifier); | 524 | QValueList<int> fieldIds = cfg->readIntListEntry( identifier); |
519 | //US | 525 | //US |
520 | // qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1()); | 526 | // qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1()); |
521 | 527 | ||
522 | Field::List fields; | 528 | Field::List fields; |
523 | 529 | ||
524 | int custom = 0; | 530 | int custom = 0; |
525 | QValueList<int>::ConstIterator it; | 531 | QValueList<int>::ConstIterator it; |
526 | for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) { | 532 | for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) { |
527 | FieldImpl *f = 0; | 533 | FieldImpl *f = 0; |
528 | if ( (*it) == FieldImpl::CustomField ) { | 534 | if ( (*it) == FieldImpl::CustomField ) { |
529 | QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" + | 535 | QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" + |
530 | identifier + "_" + | 536 | identifier + "_" + |
531 | QString::number( custom++ ) ); | 537 | QString::number( custom++ ) ); |
532 | f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ], | 538 | f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ], |
533 | customEntry[ 1 ], customEntry[ 2 ] ); | 539 | customEntry[ 1 ], customEntry[ 2 ] ); |
534 | } else { | 540 | } else { |
535 | f = new FieldImpl( *it ); | 541 | f = new FieldImpl( *it ); |
536 | } | 542 | } |
537 | fields.append( new Field( f ) ); | 543 | fields.append( new Field( f ) ); |
538 | } | 544 | } |
539 | 545 | ||
540 | return fields; | 546 | return fields; |
541 | } | 547 | } |
542 | 548 | ||
543 | bool Field::equals( Field *field ) | 549 | bool Field::equals( Field *field ) |
544 | { | 550 | { |
545 | bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() ); | 551 | bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() ); |
546 | 552 | ||
547 | if ( !sameId ) return false; | 553 | if ( !sameId ) return false; |
548 | 554 | ||
549 | if ( mImpl->fieldId() != FieldImpl::CustomField ) return true; | 555 | if ( mImpl->fieldId() != FieldImpl::CustomField ) return true; |
550 | 556 | ||
551 | return mImpl->key() == field->mImpl->key(); | 557 | return mImpl->key() == field->mImpl->key(); |
552 | } | 558 | } |
553 | 559 | ||
554 | Field *Field::createCustomField( const QString &label, int category, | 560 | Field *Field::createCustomField( const QString &label, int category, |
555 | const QString &key, const QString &app ) | 561 | const QString &key, const QString &app ) |
556 | { | 562 | { |
557 | Field *field = new Field( new FieldImpl( FieldImpl::CustomField, | 563 | Field *field = new Field( new FieldImpl( FieldImpl::CustomField, |
558 | category | CustomCategory, | 564 | category | CustomCategory, |
559 | label, key, app ) ); | 565 | label, key, app ) ); |
560 | //US | 566 | //US |
561 | // qDebug("Field::createCustomField label %s", label.latin1() ); | 567 | // qDebug("Field::createCustomField label %s", label.latin1() ); |
562 | 568 | ||
563 | mCustomFields.append( field ); | 569 | mCustomFields.append( field ); |
564 | 570 | ||
565 | return field; | 571 | return field; |
566 | } | 572 | } |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index 4ad608d..7aeb2ee 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -1,200 +1,202 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <klocale.h> | 29 | #include <klocale.h> |
30 | 30 | ||
31 | #include "phonenumber.h" | 31 | #include "phonenumber.h" |
32 | 32 | ||
33 | using namespace KABC; | 33 | using namespace KABC; |
34 | 34 | ||
35 | PhoneNumber::PhoneNumber() : | 35 | PhoneNumber::PhoneNumber() : |
36 | mType( Home ) | 36 | mType( Home ) |
37 | { | 37 | { |
38 | init(); | 38 | init(); |
39 | } | 39 | } |
40 | 40 | ||
41 | PhoneNumber::PhoneNumber( const QString &number, int type ) : | 41 | PhoneNumber::PhoneNumber( const QString &number, int type ) : |
42 | mType( type ), mNumber( number ) | 42 | mType( type ), mNumber( number ) |
43 | { | 43 | { |
44 | init(); | 44 | init(); |
45 | } | 45 | } |
46 | 46 | ||
47 | PhoneNumber::~PhoneNumber() | 47 | PhoneNumber::~PhoneNumber() |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | void PhoneNumber::init() | 51 | void PhoneNumber::init() |
52 | { | 52 | { |
53 | mId = KApplication::randomString( 8 ); | 53 | mId = KApplication::randomString( 8 ); |
54 | } | 54 | } |
55 | 55 | ||
56 | bool PhoneNumber::operator==( const PhoneNumber &p ) const | 56 | bool PhoneNumber::operator==( const PhoneNumber &p ) const |
57 | { | 57 | { |
58 | if ( mNumber != p.mNumber ) return false; | 58 | if ( mNumber != p.mNumber ) return false; |
59 | if ( mType != p.mType ) return false; | 59 | if ( mType != p.mType ) return false; |
60 | 60 | ||
61 | return true; | 61 | return true; |
62 | } | 62 | } |
63 | 63 | ||
64 | bool PhoneNumber::operator!=( const PhoneNumber &p ) const | 64 | bool PhoneNumber::operator!=( const PhoneNumber &p ) const |
65 | { | 65 | { |
66 | return !( p == *this ); | 66 | return !( p == *this ); |
67 | } | 67 | } |
68 | 68 | ||
69 | void PhoneNumber::setId( const QString &id ) | 69 | void PhoneNumber::setId( const QString &id ) |
70 | { | 70 | { |
71 | mId = id; | 71 | mId = id; |
72 | } | 72 | } |
73 | 73 | ||
74 | QString PhoneNumber::id() const | 74 | QString PhoneNumber::id() const |
75 | { | 75 | { |
76 | return mId; | 76 | return mId; |
77 | } | 77 | } |
78 | 78 | ||
79 | void PhoneNumber::setNumber( const QString &number ) | 79 | void PhoneNumber::setNumber( const QString &number ) |
80 | { | 80 | { |
81 | mNumber = number; | 81 | mNumber = number; |
82 | } | 82 | } |
83 | 83 | ||
84 | QString PhoneNumber::number() const | 84 | QString PhoneNumber::number() const |
85 | { | 85 | { |
86 | return mNumber; | 86 | return mNumber; |
87 | } | 87 | } |
88 | 88 | ||
89 | void PhoneNumber::setType( int type ) | 89 | void PhoneNumber::setType( int type ) |
90 | { | 90 | { |
91 | mType = type; | 91 | mType = type; |
92 | } | 92 | } |
93 | 93 | ||
94 | int PhoneNumber::type() const | 94 | int PhoneNumber::type() const |
95 | { | 95 | { |
96 | return mType; | 96 | return mType; |
97 | } | 97 | } |
98 | 98 | ||
99 | QString PhoneNumber::typeLabel() const | 99 | QString PhoneNumber::typeLabel() const |
100 | { | 100 | { |
101 | QString label; | 101 | QString label; |
102 | bool first = true; | 102 | bool first = true; |
103 | 103 | ||
104 | TypeList list = typeList(); | 104 | TypeList list = typeList(); |
105 | 105 | ||
106 | TypeList::Iterator it; | 106 | TypeList::Iterator it; |
107 | for ( it = list.begin(); it != list.end(); ++it ) { | 107 | for ( it = list.begin(); it != list.end(); ++it ) { |
108 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { | 108 | if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { |
109 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); | 109 | label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); |
110 | if ( first ) | 110 | if ( first ) |
111 | first = false; | 111 | first = false; |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
115 | return label; | 115 | return label; |
116 | } | 116 | } |
117 | 117 | ||
118 | QString PhoneNumber::label() const | 118 | QString PhoneNumber::label() const |
119 | { | 119 | { |
120 | return typeLabel( type() ); | 120 | return typeLabel( type() ); |
121 | } | 121 | } |
122 | 122 | ||
123 | PhoneNumber::TypeList PhoneNumber::typeList() | 123 | PhoneNumber::TypeList PhoneNumber::typeList() |
124 | { | 124 | { |
125 | TypeList list; | 125 | TypeList list; |
126 | 126 | ||
127 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video | 127 | list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video |
128 | << Bbs << Modem << Car << Isdn << Pcs << Pager; | 128 | << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; |
129 | 129 | ||
130 | return list; | 130 | return list; |
131 | } | 131 | } |
132 | 132 | ||
133 | QString PhoneNumber::label( int type ) | 133 | QString PhoneNumber::label( int type ) |
134 | { | 134 | { |
135 | return typeLabel( type ); | 135 | return typeLabel( type ); |
136 | } | 136 | } |
137 | 137 | ||
138 | QString PhoneNumber::typeLabel( int type ) | 138 | QString PhoneNumber::typeLabel( int type ) |
139 | { | 139 | { |
140 | QString typeString; | 140 | QString typeString; |
141 | 141 | ||
142 | if ((type & Home) == Home) | 142 | if ((type & Home) == Home) |
143 | typeString += i18n("Home"); | 143 | typeString += i18n("Home"); |
144 | else if ((type & Work) == Work) | 144 | else if ((type & Work) == Work) |
145 | typeString += i18n("Work"); | 145 | typeString += i18n("Work"); |
146 | 146 | ||
147 | if (!typeString.isEmpty()) | 147 | if (!typeString.isEmpty()) |
148 | typeString += " "; | 148 | typeString += " "; |
149 | 149 | ||
150 | if ((type & Cell) == Cell) | 150 | if ((type & Cell) == Cell) |
151 | typeString += i18n("Mobile"); | 151 | typeString += i18n("Mobile"); |
152 | else if ((type & Fax) == Fax) | 152 | else if ((type & Fax) == Fax) |
153 | typeString += i18n("Fax"); | 153 | typeString += i18n("Fax"); |
154 | else if ((type & Msg) == Msg) | 154 | else if ((type & Msg) == Msg) |
155 | typeString += i18n("Messenger"); | 155 | typeString += i18n("Messenger"); |
156 | else if ((type & Voice) == Voice) { | 156 | else if ((type & Voice) == Voice) { |
157 | // add nothing in case of the Voice flag | 157 | // add nothing in case of the Voice flag |
158 | // typeString += i18n("Voice"); | 158 | // typeString += i18n("Voice"); |
159 | } | 159 | } |
160 | else if ((type & Video) == Video) | 160 | else if ((type & Video) == Video) |
161 | typeString += i18n("Video"); | 161 | typeString += i18n("Video"); |
162 | else if ((type & Bbs) == Bbs) | 162 | else if ((type & Bbs) == Bbs) |
163 | typeString += i18n("Mailbox"); | 163 | typeString += i18n("Mailbox"); |
164 | else if ((type & Modem) == Modem) | 164 | else if ((type & Modem) == Modem) |
165 | typeString += i18n("Modem"); | 165 | typeString += i18n("Modem"); |
166 | else if ((type & Car) == Car) | 166 | else if ((type & Car) == Car) |
167 | typeString += i18n("Car"); | 167 | typeString += i18n("Car"); |
168 | else if ((type & Isdn) == Isdn) | 168 | else if ((type & Isdn) == Isdn) |
169 | typeString += i18n("ISDN"); | 169 | typeString += i18n("ISDN"); |
170 | else if ((type & Pcs) == Pcs) | 170 | else if ((type & Pcs) == Pcs) |
171 | typeString += i18n("PCS"); | 171 | typeString += i18n("PCS"); |
172 | else if ((type & Pager) == Pager) | 172 | else if ((type & Pager) == Pager) |
173 | typeString += i18n("Pager"); | 173 | typeString += i18n("Pager"); |
174 | else if ((type & Sip) == Sip) | ||
175 | typeString += i18n("SIP"); | ||
174 | 176 | ||
175 | // add the prefered flag | 177 | // add the prefered flag |
176 | if (!typeString.isEmpty()) | 178 | if (!typeString.isEmpty()) |
177 | typeString += " "; | 179 | typeString += " "; |
178 | 180 | ||
179 | if ((type & Pref) == Pref) | 181 | if ((type & Pref) == Pref) |
180 | typeString += i18n("(p)"); | 182 | typeString += i18n("(p)"); |
181 | 183 | ||
182 | //if we still have no match, return "other" | 184 | //if we still have no match, return "other" |
183 | if (typeString.isEmpty()) | 185 | if (typeString.isEmpty()) |
184 | return i18n("Other"); | 186 | return i18n("Other"); |
185 | 187 | ||
186 | 188 | ||
187 | return typeString; | 189 | return typeString; |
188 | } | 190 | } |
189 | 191 | ||
190 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) | 192 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) |
191 | { | 193 | { |
192 | return s << phone.mId << phone.mType << phone.mNumber; | 194 | return s << phone.mId << phone.mType << phone.mNumber; |
193 | } | 195 | } |
194 | 196 | ||
195 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) | 197 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) |
196 | { | 198 | { |
197 | s >> phone.mId >> phone.mType >> phone.mNumber; | 199 | s >> phone.mId >> phone.mType >> phone.mNumber; |
198 | 200 | ||
199 | return s; | 201 | return s; |
200 | } | 202 | } |
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h index 6a9c8cb..1df344f 100644 --- a/kabc/phonenumber.h +++ b/kabc/phonenumber.h | |||
@@ -1,165 +1,166 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_PHONENUMBER_H | 28 | #ifndef KABC_PHONENUMBER_H |
29 | #define KABC_PHONENUMBER_H | 29 | #define KABC_PHONENUMBER_H |
30 | 30 | ||
31 | #include <qvaluelist.h> | 31 | #include <qvaluelist.h> |
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | 33 | ||
34 | namespace KABC { | 34 | namespace KABC { |
35 | 35 | ||
36 | /** | 36 | /** |
37 | @short Phonenumber information. | 37 | @short Phonenumber information. |
38 | 38 | ||
39 | This class provides phone number information. A phone number is classified by | 39 | This class provides phone number information. A phone number is classified by |
40 | a type. The following types are available, it's possible to use multiple types | 40 | a type. The following types are available, it's possible to use multiple types |
41 | @ref Types for a number by combining them through a logical or. | 41 | @ref Types for a number by combining them through a logical or. |
42 | */ | 42 | */ |
43 | class PhoneNumber | 43 | class PhoneNumber |
44 | { | 44 | { |
45 | friend QDataStream &operator<<( QDataStream &, const PhoneNumber & ); | 45 | friend QDataStream &operator<<( QDataStream &, const PhoneNumber & ); |
46 | friend QDataStream &operator>>( QDataStream &, PhoneNumber & ); | 46 | friend QDataStream &operator>>( QDataStream &, PhoneNumber & ); |
47 | 47 | ||
48 | public: | 48 | public: |
49 | typedef QValueList<PhoneNumber> List; | 49 | typedef QValueList<PhoneNumber> List; |
50 | typedef QValueList<int> TypeList; | 50 | typedef QValueList<int> TypeList; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | @li @p Home - Home number | 53 | @li @p Home - Home number |
54 | @li @p Work - Office number | 54 | @li @p Work - Office number |
55 | @li @p Msg - Messaging | 55 | @li @p Msg - Messaging |
56 | @li @p Pref - Preferred number | 56 | @li @p Pref - Preferred number |
57 | @li @p Voice - Voice | 57 | @li @p Voice - Voice |
58 | @li @p Fax - Fax machine | 58 | @li @p Fax - Fax machine |
59 | @li @p Cell - Cell phone | 59 | @li @p Cell - Cell phone |
60 | @li @p Video - Video phone | 60 | @li @p Video - Video phone |
61 | @li @p Bbs - Mailbox | 61 | @li @p Bbs - Mailbox |
62 | @li @p Modem - Modem | 62 | @li @p Modem - Modem |
63 | @li @p Car - Car phone | 63 | @li @p Car - Car phone |
64 | @li @p Isdn - ISDN connection | 64 | @li @p Isdn - ISDN connection |
65 | @li @p Pcs - Personal Communication Service | 65 | @li @p Pcs - Personal Communication Service |
66 | @li @p Pager - Pager | 66 | @li @p Pager - Pager |
67 | @li @p SIP - VoIP | ||
67 | */ | 68 | */ |
68 | enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, | 69 | enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, |
69 | Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, | 70 | Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, |
70 | Isdn = 2048, Pcs = 4096, Pager = 8192 }; | 71 | Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 }; |
71 | 72 | ||
72 | /** | 73 | /** |
73 | Create an empty phone number object. | 74 | Create an empty phone number object. |
74 | */ | 75 | */ |
75 | PhoneNumber(); | 76 | PhoneNumber(); |
76 | 77 | ||
77 | /** | 78 | /** |
78 | Create a phonenumber object. | 79 | Create a phonenumber object. |
79 | 80 | ||
80 | @param number Number | 81 | @param number Number |
81 | @param type Type as defined in enum. Multiple types can be | 82 | @param type Type as defined in enum. Multiple types can be |
82 | specified by combining them by a logical or. | 83 | specified by combining them by a logical or. |
83 | */ | 84 | */ |
84 | PhoneNumber( const QString &number, int type = Home ); | 85 | PhoneNumber( const QString &number, int type = Home ); |
85 | 86 | ||
86 | /** | 87 | /** |
87 | Destructor. | 88 | Destructor. |
88 | */ | 89 | */ |
89 | ~PhoneNumber(); | 90 | ~PhoneNumber(); |
90 | 91 | ||
91 | bool operator==( const PhoneNumber & ) const; | 92 | bool operator==( const PhoneNumber & ) const; |
92 | bool operator!=( const PhoneNumber & ) const; | 93 | bool operator!=( const PhoneNumber & ) const; |
93 | 94 | ||
94 | /** | 95 | /** |
95 | Sets the unique identifier. | 96 | Sets the unique identifier. |
96 | */ | 97 | */ |
97 | void setId( const QString &id ); | 98 | void setId( const QString &id ); |
98 | 99 | ||
99 | /** | 100 | /** |
100 | Returns the unique identifier. | 101 | Returns the unique identifier. |
101 | */ | 102 | */ |
102 | QString id() const; | 103 | QString id() const; |
103 | 104 | ||
104 | /** | 105 | /** |
105 | Sets the number. | 106 | Sets the number. |
106 | */ | 107 | */ |
107 | void setNumber( const QString & ); | 108 | void setNumber( const QString & ); |
108 | 109 | ||
109 | /** | 110 | /** |
110 | Returns the number. | 111 | Returns the number. |
111 | */ | 112 | */ |
112 | QString number() const; | 113 | QString number() const; |
113 | 114 | ||
114 | /** | 115 | /** |
115 | Sets the type. Multiple types can be specified by combining them by | 116 | Sets the type. Multiple types can be specified by combining them by |
116 | a logical or. | 117 | a logical or. |
117 | */ | 118 | */ |
118 | void setType( int ); | 119 | void setType( int ); |
119 | 120 | ||
120 | /** | 121 | /** |
121 | Returns the type. Can be a multiple types combined by a logical or. | 122 | Returns the type. Can be a multiple types combined by a logical or. |
122 | */ | 123 | */ |
123 | int type() const; | 124 | int type() const; |
124 | 125 | ||
125 | /** | 126 | /** |
126 | Returns a translated string of all types the address has. | 127 | Returns a translated string of all types the address has. |
127 | */ | 128 | */ |
128 | QString typeLabel() const; | 129 | QString typeLabel() const; |
129 | 130 | ||
130 | /** | 131 | /** |
131 | Returns the translated label for phone number depending on its type. | 132 | Returns the translated label for phone number depending on its type. |
132 | */ | 133 | */ |
133 | QString label() const; | 134 | QString label() const; |
134 | 135 | ||
135 | /** | 136 | /** |
136 | Returns a list of all available types | 137 | Returns a list of all available types |
137 | */ | 138 | */ |
138 | static TypeList typeList(); | 139 | static TypeList typeList(); |
139 | 140 | ||
140 | /** | 141 | /** |
141 | Returns the translated label for phone number type. | 142 | Returns the translated label for phone number type. |
142 | */ | 143 | */ |
143 | static QString typeLabel( int type ); | 144 | static QString typeLabel( int type ); |
144 | 145 | ||
145 | /** | 146 | /** |
146 | Returns the translated label for phone number type. | 147 | Returns the translated label for phone number type. |
147 | @obsolete | 148 | @obsolete |
148 | */ | 149 | */ |
149 | static QString label( int type ); | 150 | static QString label( int type ); |
150 | 151 | ||
151 | private: | 152 | private: |
152 | void init(); | 153 | void init(); |
153 | 154 | ||
154 | QString mId; | 155 | QString mId; |
155 | 156 | ||
156 | int mType; | 157 | int mType; |
157 | QString mNumber; | 158 | QString mNumber; |
158 | }; | 159 | }; |
159 | 160 | ||
160 | QDataStream &operator<<( QDataStream &, const PhoneNumber & ); | 161 | QDataStream &operator<<( QDataStream &, const PhoneNumber & ); |
161 | QDataStream &operator>>( QDataStream &, PhoneNumber & ); | 162 | QDataStream &operator>>( QDataStream &, PhoneNumber & ); |
162 | 163 | ||
163 | } | 164 | } |
164 | 165 | ||
165 | #endif | 166 | #endif |
diff --git a/kabc/vcard21parser.cpp b/kabc/vcard21parser.cpp index b02aac4..277de22 100644 --- a/kabc/vcard21parser.cpp +++ b/kabc/vcard21parser.cpp | |||
@@ -1,606 +1,609 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Mark Westcott <mark@houseoffish.org> | 3 | Copyright (c) 2001 Mark Westcott <mark@houseoffish.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <qmap.h> | 28 | #include <qmap.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | #include <kmdcodec.h> | 30 | #include <kmdcodec.h> |
31 | 31 | ||
32 | #include "vcard21parser.h" | 32 | #include "vcard21parser.h" |
33 | #include "vcardconverter.h" | 33 | #include "vcardconverter.h" |
34 | 34 | ||
35 | using namespace KABC; | 35 | using namespace KABC; |
36 | 36 | ||
37 | bool VCardLineX::isValid() const | 37 | bool VCardLineX::isValid() const |
38 | { | 38 | { |
39 | // Invalid: if it is "begin:vcard" or "end:vcard" | 39 | // Invalid: if it is "begin:vcard" or "end:vcard" |
40 | if ( name == VCARD_BEGIN_N || name == VCARD_END_N ) | 40 | if ( name == VCARD_BEGIN_N || name == VCARD_END_N ) |
41 | return false; | 41 | return false; |
42 | 42 | ||
43 | if ( name[0] == 'x' && name[1] == '-' ) // A custom x- line | 43 | if ( name[0] == 'x' && name[1] == '-' ) // A custom x- line |
44 | return true; | 44 | return true; |
45 | 45 | ||
46 | // This is long but it makes it a bit faster (and saves me from using | 46 | // This is long but it makes it a bit faster (and saves me from using |
47 | // a tree which is probably the ideal situation, but a bit memory heavy) | 47 | // a tree which is probably the ideal situation, but a bit memory heavy) |
48 | switch( name[0] ) { | 48 | switch( name[0] ) { |
49 | case 'a': | 49 | case 'a': |
50 | if ( name == VCARD_ADR && qualified && | 50 | if ( name == VCARD_ADR && qualified && |
51 | (qualifiers.contains(VCARD_ADR_DOM) || | 51 | (qualifiers.contains(VCARD_ADR_DOM) || |
52 | qualifiers.contains(VCARD_ADR_INTL) || | 52 | qualifiers.contains(VCARD_ADR_INTL) || |
53 | qualifiers.contains(VCARD_ADR_POSTAL) || | 53 | qualifiers.contains(VCARD_ADR_POSTAL) || |
54 | qualifiers.contains(VCARD_ADR_HOME) || | 54 | qualifiers.contains(VCARD_ADR_HOME) || |
55 | qualifiers.contains(VCARD_ADR_WORK) || | 55 | qualifiers.contains(VCARD_ADR_WORK) || |
56 | qualifiers.contains(VCARD_ADR_PREF) | 56 | qualifiers.contains(VCARD_ADR_PREF) |
57 | ) ) | 57 | ) ) |
58 | return true; | 58 | return true; |
59 | 59 | ||
60 | if ( name == VCARD_AGENT ) | 60 | if ( name == VCARD_AGENT ) |
61 | return true; | 61 | return true; |
62 | break; | 62 | break; |
63 | 63 | ||
64 | case 'b': | 64 | case 'b': |
65 | if ( name == VCARD_BDAY ) | 65 | if ( name == VCARD_BDAY ) |
66 | return true; | 66 | return true; |
67 | break; | 67 | break; |
68 | 68 | ||
69 | case 'c': | 69 | case 'c': |
70 | if ( name == VCARD_CATEGORIES ) | 70 | if ( name == VCARD_CATEGORIES ) |
71 | return true; | 71 | return true; |
72 | if ( name == VCARD_CLASS && qualified && | 72 | if ( name == VCARD_CLASS && qualified && |
73 | (qualifiers.contains(VCARD_CLASS_PUBLIC) || | 73 | (qualifiers.contains(VCARD_CLASS_PUBLIC) || |
74 | qualifiers.contains(VCARD_CLASS_PRIVATE) || | 74 | qualifiers.contains(VCARD_CLASS_PRIVATE) || |
75 | qualifiers.contains(VCARD_CLASS_CONFIDENTIAL) | 75 | qualifiers.contains(VCARD_CLASS_CONFIDENTIAL) |
76 | ) ) | 76 | ) ) |
77 | return true; | 77 | return true; |
78 | break; | 78 | break; |
79 | 79 | ||
80 | case 'e': | 80 | case 'e': |
81 | if ( name == VCARD_EMAIL && qualified && | 81 | if ( name == VCARD_EMAIL && qualified && |
82 | (qualifiers.contains(VCARD_EMAIL_INTERNET) || | 82 | (qualifiers.contains(VCARD_EMAIL_INTERNET) || |
83 | qualifiers.contains(VCARD_EMAIL_PREF) || | 83 | qualifiers.contains(VCARD_EMAIL_PREF) || |
84 | qualifiers.contains(VCARD_EMAIL_X400) | 84 | qualifiers.contains(VCARD_EMAIL_X400) |
85 | ) ) | 85 | ) ) |
86 | return true; | 86 | return true; |
87 | break; | 87 | break; |
88 | 88 | ||
89 | case 'f': | 89 | case 'f': |
90 | if ( name == VCARD_FN ) | 90 | if ( name == VCARD_FN ) |
91 | return true; | 91 | return true; |
92 | break; | 92 | break; |
93 | 93 | ||
94 | case 'g': | 94 | case 'g': |
95 | if ( name == VCARD_GEO ) | 95 | if ( name == VCARD_GEO ) |
96 | return true; | 96 | return true; |
97 | break; | 97 | break; |
98 | 98 | ||
99 | case 'k': | 99 | case 'k': |
100 | if ( name == VCARD_KEY && qualified && | 100 | if ( name == VCARD_KEY && qualified && |
101 | (qualifiers.contains(VCARD_KEY_X509) || | 101 | (qualifiers.contains(VCARD_KEY_X509) || |
102 | qualifiers.contains(VCARD_KEY_PGP) | 102 | qualifiers.contains(VCARD_KEY_PGP) |
103 | ) ) | 103 | ) ) |
104 | return true; | 104 | return true; |
105 | break; | 105 | break; |
106 | 106 | ||
107 | case 'l': | 107 | case 'l': |
108 | if ( name == VCARD_LABEL ) | 108 | if ( name == VCARD_LABEL ) |
109 | return true; | 109 | return true; |
110 | if ( name == VCARD_LOGO ) | 110 | if ( name == VCARD_LOGO ) |
111 | return true; | 111 | return true; |
112 | break; | 112 | break; |
113 | 113 | ||
114 | case 'm': | 114 | case 'm': |
115 | if ( name == VCARD_MAILER ) | 115 | if ( name == VCARD_MAILER ) |
116 | return true; | 116 | return true; |
117 | break; | 117 | break; |
118 | 118 | ||
119 | case 'n': | 119 | case 'n': |
120 | if ( name == VCARD_N ) | 120 | if ( name == VCARD_N ) |
121 | return true; | 121 | return true; |
122 | if ( name == VCARD_NAME ) | 122 | if ( name == VCARD_NAME ) |
123 | return true; | 123 | return true; |
124 | if ( name == VCARD_NICKNAME ) | 124 | if ( name == VCARD_NICKNAME ) |
125 | return true; | 125 | return true; |
126 | if ( name == VCARD_NOTE ) | 126 | if ( name == VCARD_NOTE ) |
127 | return true; | 127 | return true; |
128 | break; | 128 | break; |
129 | 129 | ||
130 | case 'o': | 130 | case 'o': |
131 | if ( name == VCARD_ORG ) | 131 | if ( name == VCARD_ORG ) |
132 | return true; | 132 | return true; |
133 | break; | 133 | break; |
134 | 134 | ||
135 | case 'p': | 135 | case 'p': |
136 | if ( name == VCARD_PHOTO ) | 136 | if ( name == VCARD_PHOTO ) |
137 | return true; | 137 | return true; |
138 | if ( name == VCARD_PROFILE ) | 138 | if ( name == VCARD_PROFILE ) |
139 | return true; | 139 | return true; |
140 | if ( name == VCARD_PRODID ) | 140 | if ( name == VCARD_PRODID ) |
141 | return true; | 141 | return true; |
142 | break; | 142 | break; |
143 | 143 | ||
144 | case 'r': | 144 | case 'r': |
145 | if ( name == VCARD_ROLE ) | 145 | if ( name == VCARD_ROLE ) |
146 | return true; | 146 | return true; |
147 | if ( name == VCARD_REV ) | 147 | if ( name == VCARD_REV ) |
148 | return true; | 148 | return true; |
149 | break; | 149 | break; |
150 | 150 | ||
151 | case 's': | 151 | case 's': |
152 | if ( name == VCARD_SOURCE ) | 152 | if ( name == VCARD_SOURCE ) |
153 | return true; | 153 | return true; |
154 | if ( name == VCARD_SOUND ) | 154 | if ( name == VCARD_SOUND ) |
155 | return true; | 155 | return true; |
156 | break; | 156 | break; |
157 | 157 | ||
158 | case 't': | 158 | case 't': |
159 | if ( name == VCARD_TEL && qualified && | 159 | if ( name == VCARD_TEL && qualified && |
160 | (qualifiers.contains(VCARD_TEL_HOME) || | 160 | (qualifiers.contains(VCARD_TEL_HOME) || |
161 | qualifiers.contains(VCARD_TEL_WORK) || | 161 | qualifiers.contains(VCARD_TEL_WORK) || |
162 | qualifiers.contains(VCARD_TEL_PREF) || | 162 | qualifiers.contains(VCARD_TEL_PREF) || |
163 | qualifiers.contains(VCARD_TEL_VOICE) || | 163 | qualifiers.contains(VCARD_TEL_VOICE) || |
164 | qualifiers.contains(VCARD_TEL_FAX) || | 164 | qualifiers.contains(VCARD_TEL_FAX) || |
165 | qualifiers.contains(VCARD_TEL_MSG) || | 165 | qualifiers.contains(VCARD_TEL_MSG) || |
166 | qualifiers.contains(VCARD_TEL_CELL) || | 166 | qualifiers.contains(VCARD_TEL_CELL) || |
167 | qualifiers.contains(VCARD_TEL_PAGER) || | 167 | qualifiers.contains(VCARD_TEL_PAGER) || |
168 | qualifiers.contains(VCARD_TEL_BBS) || | 168 | qualifiers.contains(VCARD_TEL_BBS) || |
169 | qualifiers.contains(VCARD_TEL_MODEM) || | 169 | qualifiers.contains(VCARD_TEL_MODEM) || |
170 | qualifiers.contains(VCARD_TEL_CAR) || | 170 | qualifiers.contains(VCARD_TEL_CAR) || |
171 | qualifiers.contains(VCARD_TEL_ISDN) || | 171 | qualifiers.contains(VCARD_TEL_ISDN) || |
172 | qualifiers.contains(VCARD_TEL_VIDEO) || | 172 | qualifiers.contains(VCARD_TEL_VIDEO) || |
173 | qualifiers.contains(VCARD_TEL_PCS) | 173 | qualifiers.contains(VCARD_TEL_PCS) || |
174 | qualifiers.contains(VCARD_TEL_SIP) | ||
174 | ) ) | 175 | ) ) |
175 | return true; | 176 | return true; |
176 | if ( name == VCARD_TZ ) | 177 | if ( name == VCARD_TZ ) |
177 | return true; | 178 | return true; |
178 | if ( name == VCARD_TITLE ) | 179 | if ( name == VCARD_TITLE ) |
179 | return true; | 180 | return true; |
180 | break; | 181 | break; |
181 | 182 | ||
182 | case 'u': | 183 | case 'u': |
183 | if ( name == VCARD_URL ) | 184 | if ( name == VCARD_URL ) |
184 | return true; | 185 | return true; |
185 | if ( name == VCARD_UID ) | 186 | if ( name == VCARD_UID ) |
186 | return true; | 187 | return true; |
187 | break; | 188 | break; |
188 | 189 | ||
189 | case 'v': | 190 | case 'v': |
190 | if ( name == VCARD_VERSION ) | 191 | if ( name == VCARD_VERSION ) |
191 | return true; | 192 | return true; |
192 | break; | 193 | break; |
193 | default: | 194 | default: |
194 | break; | 195 | break; |
195 | } | 196 | } |
196 | 197 | ||
197 | return false; | 198 | return false; |
198 | } | 199 | } |
199 | 200 | ||
200 | 201 | ||
201 | VCard21Parser::VCard21Parser() | 202 | VCard21Parser::VCard21Parser() |
202 | { | 203 | { |
203 | } | 204 | } |
204 | 205 | ||
205 | VCard21Parser::~VCard21Parser() | 206 | VCard21Parser::~VCard21Parser() |
206 | { | 207 | { |
207 | } | 208 | } |
208 | 209 | ||
209 | void VCard21Parser::readFromString(KABC::AddressBook *addressbook, const QString &data) | 210 | void VCard21Parser::readFromString(KABC::AddressBook *addressbook, const QString &data) |
210 | { | 211 | { |
211 | KABC::Addressee mAddressee = readFromString(data); | 212 | KABC::Addressee mAddressee = readFromString(data); |
212 | addressbook->insertAddressee(mAddressee); | 213 | addressbook->insertAddressee(mAddressee); |
213 | } | 214 | } |
214 | 215 | ||
215 | KABC::Addressee VCard21Parser::readFromString( const QString &data) | 216 | KABC::Addressee VCard21Parser::readFromString( const QString &data) |
216 | { | 217 | { |
217 | KABC::Addressee addressee; | 218 | KABC::Addressee addressee; |
218 | VCard21ParserImpl *mVCard = VCard21ParserImpl::parseVCard(data); | 219 | VCard21ParserImpl *mVCard = VCard21ParserImpl::parseVCard(data); |
219 | QString tmpStr; | 220 | QString tmpStr; |
220 | 221 | ||
221 | // Check if parsing failed | 222 | // Check if parsing failed |
222 | if (mVCard == 0) | 223 | if (mVCard == 0) |
223 | { | 224 | { |
224 | kdDebug() << "Parsing failed" << endl; | 225 | kdDebug() << "Parsing failed" << endl; |
225 | return addressee; | 226 | return addressee; |
226 | } | 227 | } |
227 | //set the addressees name and formated name | 228 | //set the addressees name and formated name |
228 | QStringList tmpList = mVCard->getValues(VCARD_N); | 229 | QStringList tmpList = mVCard->getValues(VCARD_N); |
229 | QString formattedName = ""; | 230 | QString formattedName = ""; |
230 | if (tmpList.count() > 0) | 231 | if (tmpList.count() > 0) |
231 | addressee.setFamilyName(tmpList[0]); | 232 | addressee.setFamilyName(tmpList[0]); |
232 | if (tmpList.count() > 1) | 233 | if (tmpList.count() > 1) |
233 | addressee.setGivenName(tmpList[1]); | 234 | addressee.setGivenName(tmpList[1]); |
234 | if (tmpList.count() > 2) | 235 | if (tmpList.count() > 2) |
235 | addressee.setAdditionalName(tmpList[2]); | 236 | addressee.setAdditionalName(tmpList[2]); |
236 | if (tmpList.count() > 3) | 237 | if (tmpList.count() > 3) |
237 | addressee.setPrefix(tmpList[3]); | 238 | addressee.setPrefix(tmpList[3]); |
238 | if (tmpList.count() > 4) | 239 | if (tmpList.count() > 4) |
239 | addressee.setSuffix(tmpList[4]); | 240 | addressee.setSuffix(tmpList[4]); |
240 | 241 | ||
241 | tmpStr = (mVCard->getValue(VCARD_FN)); | 242 | tmpStr = (mVCard->getValue(VCARD_FN)); |
242 | if (!tmpStr.isEmpty()) | 243 | if (!tmpStr.isEmpty()) |
243 | addressee.setFormattedName(tmpStr); | 244 | addressee.setFormattedName(tmpStr); |
244 | 245 | ||
245 | //set the addressee's nick name | 246 | //set the addressee's nick name |
246 | tmpStr = mVCard->getValue(VCARD_NICKNAME); | 247 | tmpStr = mVCard->getValue(VCARD_NICKNAME); |
247 | addressee.setNickName(tmpStr); | 248 | addressee.setNickName(tmpStr); |
248 | //set the addressee's organisation | 249 | //set the addressee's organisation |
249 | tmpStr = mVCard->getValue(VCARD_ORG); | 250 | tmpStr = mVCard->getValue(VCARD_ORG); |
250 | addressee.setOrganization(tmpStr); | 251 | addressee.setOrganization(tmpStr); |
251 | //set the addressee's title | 252 | //set the addressee's title |
252 | tmpStr = mVCard->getValue(VCARD_TITLE); | 253 | tmpStr = mVCard->getValue(VCARD_TITLE); |
253 | addressee.setTitle(tmpStr); | 254 | addressee.setTitle(tmpStr); |
254 | //set the addressee's email - we can only deal with two. The preferenced one and one other. | 255 | //set the addressee's email - we can only deal with two. The preferenced one and one other. |
255 | tmpStr = mVCard->getValue(VCARD_EMAIL, VCARD_EMAIL_INTERNET); | 256 | tmpStr = mVCard->getValue(VCARD_EMAIL, VCARD_EMAIL_INTERNET); |
256 | addressee.insertEmail(tmpStr, false); | 257 | addressee.insertEmail(tmpStr, false); |
257 | tmpStr = mVCard->getValue(VCARD_EMAIL,VCARD_EMAIL_PREF); | 258 | tmpStr = mVCard->getValue(VCARD_EMAIL,VCARD_EMAIL_PREF); |
258 | addressee.insertEmail(tmpStr, true); | 259 | addressee.insertEmail(tmpStr, true); |
259 | //set the addressee's url | 260 | //set the addressee's url |
260 | tmpStr = mVCard->getValue(VCARD_URL); | 261 | tmpStr = mVCard->getValue(VCARD_URL); |
261 | if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_WORK); | 262 | if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_WORK); |
262 | if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_HOME); | 263 | if (tmpStr.isEmpty()) tmpStr = mVCard->getValue(VCARD_URL, VCARD_ADR_HOME); |
263 | if (!tmpStr.isEmpty()) { | 264 | if (!tmpStr.isEmpty()) { |
264 | addressee.setUrl(KURL(tmpStr)); | 265 | addressee.setUrl(KURL(tmpStr)); |
265 | } | 266 | } |
266 | 267 | ||
267 | //set the addressee's birthday | 268 | //set the addressee's birthday |
268 | tmpStr = mVCard->getValue(VCARD_BDAY); | 269 | tmpStr = mVCard->getValue(VCARD_BDAY); |
269 | addressee.setBirthday(VCardStringToDate(tmpStr)); | 270 | addressee.setBirthday(VCardStringToDate(tmpStr)); |
270 | 271 | ||
271 | //set the addressee's phone numbers | 272 | //set the addressee's phone numbers |
272 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { | 273 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { |
273 | if ( (*i).name == VCARD_TEL ) { | 274 | if ( (*i).name == VCARD_TEL ) { |
274 | int type = 0; | 275 | int type = 0; |
275 | if ( (*i).qualified ) { | 276 | if ( (*i).qualified ) { |
276 | if ( (*i).qualifiers.contains( VCARD_TEL_HOME ) ) | 277 | if ( (*i).qualifiers.contains( VCARD_TEL_HOME ) ) |
277 | type |= PhoneNumber::Home; | 278 | type |= PhoneNumber::Home; |
278 | if ( (*i).qualifiers.contains( VCARD_TEL_WORK ) ) | 279 | if ( (*i).qualifiers.contains( VCARD_TEL_WORK ) ) |
279 | type |= PhoneNumber::Work; | 280 | type |= PhoneNumber::Work; |
280 | if ( (*i).qualifiers.contains( VCARD_TEL_PREF ) ) | 281 | if ( (*i).qualifiers.contains( VCARD_TEL_PREF ) ) |
281 | type |= PhoneNumber::Pref; | 282 | type |= PhoneNumber::Pref; |
282 | // if ( (*i).qualifiers.contains( VCARD_TEL_VOICE ) ) | 283 | // if ( (*i).qualifiers.contains( VCARD_TEL_VOICE ) ) |
283 | // type |= PhoneNumber::Voice; | 284 | // type |= PhoneNumber::Voice; |
284 | if ( (*i).qualifiers.contains( VCARD_TEL_FAX ) ) | 285 | if ( (*i).qualifiers.contains( VCARD_TEL_FAX ) ) |
285 | type |= PhoneNumber::Fax; | 286 | type |= PhoneNumber::Fax; |
286 | if ( (*i).qualifiers.contains( VCARD_TEL_MSG ) ) | 287 | if ( (*i).qualifiers.contains( VCARD_TEL_MSG ) ) |
287 | type |= PhoneNumber::Msg; | 288 | type |= PhoneNumber::Msg; |
288 | if ( (*i).qualifiers.contains( VCARD_TEL_CELL ) ) | 289 | if ( (*i).qualifiers.contains( VCARD_TEL_CELL ) ) |
289 | type |= PhoneNumber::Cell; | 290 | type |= PhoneNumber::Cell; |
290 | if ( (*i).qualifiers.contains( VCARD_TEL_PAGER ) ) | 291 | if ( (*i).qualifiers.contains( VCARD_TEL_PAGER ) ) |
291 | type |= PhoneNumber::Pager; | 292 | type |= PhoneNumber::Pager; |
292 | if ( (*i).qualifiers.contains( VCARD_TEL_BBS ) ) | 293 | if ( (*i).qualifiers.contains( VCARD_TEL_BBS ) ) |
293 | type |= PhoneNumber::Bbs; | 294 | type |= PhoneNumber::Bbs; |
294 | if ( (*i).qualifiers.contains( VCARD_TEL_MODEM ) ) | 295 | if ( (*i).qualifiers.contains( VCARD_TEL_MODEM ) ) |
295 | type |= PhoneNumber::Modem; | 296 | type |= PhoneNumber::Modem; |
296 | if ( (*i).qualifiers.contains( VCARD_TEL_CAR ) ) | 297 | if ( (*i).qualifiers.contains( VCARD_TEL_CAR ) ) |
297 | type |= PhoneNumber::Car; | 298 | type |= PhoneNumber::Car; |
298 | if ( (*i).qualifiers.contains( VCARD_TEL_ISDN ) ) | 299 | if ( (*i).qualifiers.contains( VCARD_TEL_ISDN ) ) |
299 | type |= PhoneNumber::Isdn; | 300 | type |= PhoneNumber::Isdn; |
300 | if ( (*i).qualifiers.contains( VCARD_TEL_VIDEO ) ) | 301 | if ( (*i).qualifiers.contains( VCARD_TEL_VIDEO ) ) |
301 | type |= PhoneNumber::Video; | 302 | type |= PhoneNumber::Video; |
302 | if ( (*i).qualifiers.contains( VCARD_TEL_PCS ) ) | 303 | if ( (*i).qualifiers.contains( VCARD_TEL_PCS ) ) |
303 | type |= PhoneNumber::Pcs; | 304 | type |= PhoneNumber::Pcs; |
305 | if ( (*i).qualifiers.contains( VCARD_TEL_SIP ) ) | ||
306 | type |= PhoneNumber::Sip; | ||
304 | } | 307 | } |
305 | addressee.insertPhoneNumber( PhoneNumber( (*i).parameters[ 0 ], type ) ); | 308 | addressee.insertPhoneNumber( PhoneNumber( (*i).parameters[ 0 ], type ) ); |
306 | } | 309 | } |
307 | } | 310 | } |
308 | 311 | ||
309 | //set the addressee's addresses | 312 | //set the addressee's addresses |
310 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { | 313 | for ( QValueListIterator<VCardLineX> i = mVCard->_vcdata->begin();i != mVCard->_vcdata->end(); ++i ) { |
311 | if ( (*i).name == VCARD_ADR ) { | 314 | if ( (*i).name == VCARD_ADR ) { |
312 | int type = 0; | 315 | int type = 0; |
313 | if ( (*i).qualified ) { | 316 | if ( (*i).qualified ) { |
314 | if ( (*i).qualifiers.contains( VCARD_ADR_DOM ) ) | 317 | if ( (*i).qualifiers.contains( VCARD_ADR_DOM ) ) |
315 | type |= Address::Dom; | 318 | type |= Address::Dom; |
316 | if ( (*i).qualifiers.contains( VCARD_ADR_INTL ) ) | 319 | if ( (*i).qualifiers.contains( VCARD_ADR_INTL ) ) |
317 | type |= Address::Intl; | 320 | type |= Address::Intl; |
318 | if ( (*i).qualifiers.contains( VCARD_ADR_POSTAL ) ) | 321 | if ( (*i).qualifiers.contains( VCARD_ADR_POSTAL ) ) |
319 | type |= Address::Postal; | 322 | type |= Address::Postal; |
320 | if ( (*i).qualifiers.contains( VCARD_ADR_PARCEL ) ) | 323 | if ( (*i).qualifiers.contains( VCARD_ADR_PARCEL ) ) |
321 | type |= Address::Parcel; | 324 | type |= Address::Parcel; |
322 | if ( (*i).qualifiers.contains( VCARD_ADR_HOME ) ) | 325 | if ( (*i).qualifiers.contains( VCARD_ADR_HOME ) ) |
323 | type |= Address::Home; | 326 | type |= Address::Home; |
324 | if ( (*i).qualifiers.contains( VCARD_ADR_WORK ) ) | 327 | if ( (*i).qualifiers.contains( VCARD_ADR_WORK ) ) |
325 | type |= Address::Work; | 328 | type |= Address::Work; |
326 | if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) ) | 329 | if ( (*i).qualifiers.contains( VCARD_ADR_PREF ) ) |
327 | type |= Address::Pref; | 330 | type |= Address::Pref; |
328 | } | 331 | } |
329 | addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) ); | 332 | addressee.insertAddress( readAddressFromQStringList( (*i).parameters, type ) ); |
330 | } | 333 | } |
331 | } | 334 | } |
332 | 335 | ||
333 | //set the addressee's delivery label | 336 | //set the addressee's delivery label |
334 | tmpStr = mVCard->getValue(VCARD_LABEL); | 337 | tmpStr = mVCard->getValue(VCARD_LABEL); |
335 | if (!tmpStr.isEmpty()) { | 338 | if (!tmpStr.isEmpty()) { |
336 | qDebug("VCard21Parser::readFromString please verify if replace is correct"); | 339 | qDebug("VCard21Parser::readFromString please verify if replace is correct"); |
337 | //US tmpStr.replace("\r\n","\n"); | 340 | //US tmpStr.replace("\r\n","\n"); |
338 | tmpStr.replace( QRegExp("\r\n"), "\n" ); | 341 | tmpStr.replace( QRegExp("\r\n"), "\n" ); |
339 | Address tmpAddress; | 342 | Address tmpAddress; |
340 | tmpAddress.setLabel(tmpStr); | 343 | tmpAddress.setLabel(tmpStr); |
341 | addressee.insertAddress(tmpAddress); | 344 | addressee.insertAddress(tmpAddress); |
342 | } | 345 | } |
343 | 346 | ||
344 | //set the addressee's notes | 347 | //set the addressee's notes |
345 | tmpStr = mVCard->getValue(VCARD_NOTE); | 348 | tmpStr = mVCard->getValue(VCARD_NOTE); |
346 | qDebug("VCard21Parser::readFromString please verify if correct"); | 349 | qDebug("VCard21Parser::readFromString please verify if correct"); |
347 | //US tmpStr.replace("\r\n","\n"); | 350 | //US tmpStr.replace("\r\n","\n"); |
348 | tmpStr.replace( QRegExp("\r\n"), "\n" ); | 351 | tmpStr.replace( QRegExp("\r\n"), "\n" ); |
349 | addressee.setNote(tmpStr); | 352 | addressee.setNote(tmpStr); |
350 | 353 | ||
351 | //set the addressee's timezone | 354 | //set the addressee's timezone |
352 | tmpStr = mVCard->getValue(VCARD_TZ); | 355 | tmpStr = mVCard->getValue(VCARD_TZ); |
353 | TimeZone tmpZone(tmpStr.toInt()); | 356 | TimeZone tmpZone(tmpStr.toInt()); |
354 | addressee.setTimeZone(tmpZone); | 357 | addressee.setTimeZone(tmpZone); |
355 | 358 | ||
356 | //set the addressee's geographical position | 359 | //set the addressee's geographical position |
357 | tmpList = mVCard->getValues(VCARD_GEO); | 360 | tmpList = mVCard->getValues(VCARD_GEO); |
358 | if (tmpList.count()==2) | 361 | if (tmpList.count()==2) |
359 | { | 362 | { |
360 | tmpStr = tmpList[0]; | 363 | tmpStr = tmpList[0]; |
361 | float glat = tmpStr.toFloat(); | 364 | float glat = tmpStr.toFloat(); |
362 | tmpStr = tmpList[1]; | 365 | tmpStr = tmpList[1]; |
363 | float glong = tmpStr.toFloat(); | 366 | float glong = tmpStr.toFloat(); |
364 | Geo tmpGeo(glat,glong); | 367 | Geo tmpGeo(glat,glong); |
365 | addressee.setGeo(tmpGeo); | 368 | addressee.setGeo(tmpGeo); |
366 | } | 369 | } |
367 | 370 | ||
368 | //set the last revision date | 371 | //set the last revision date |
369 | tmpStr = mVCard->getValue(VCARD_REV); | 372 | tmpStr = mVCard->getValue(VCARD_REV); |
370 | addressee.setRevision(VCardStringToDate(tmpStr)); | 373 | addressee.setRevision(VCardStringToDate(tmpStr)); |
371 | 374 | ||
372 | //set the role of the addressee | 375 | //set the role of the addressee |
373 | tmpStr = mVCard->getValue(VCARD_ROLE); | 376 | tmpStr = mVCard->getValue(VCARD_ROLE); |
374 | addressee.setRole(tmpStr); | 377 | addressee.setRole(tmpStr); |
375 | 378 | ||
376 | return addressee; | 379 | return addressee; |
377 | } | 380 | } |
378 | 381 | ||
379 | 382 | ||
380 | 383 | ||
381 | KABC::Address VCard21Parser::readAddressFromQStringList ( const QStringList &data, const int type ) | 384 | KABC::Address VCard21Parser::readAddressFromQStringList ( const QStringList &data, const int type ) |
382 | { | 385 | { |
383 | KABC::Address mAddress; | 386 | KABC::Address mAddress; |
384 | mAddress.setType( type ); | 387 | mAddress.setType( type ); |
385 | 388 | ||
386 | if ( data.count() > 0 ) | 389 | if ( data.count() > 0 ) |
387 | mAddress.setPostOfficeBox( data[0] ); | 390 | mAddress.setPostOfficeBox( data[0] ); |
388 | if ( data.count() > 1 ) | 391 | if ( data.count() > 1 ) |
389 | mAddress.setExtended( data[1] ); | 392 | mAddress.setExtended( data[1] ); |
390 | if ( data.count() > 2 ) | 393 | if ( data.count() > 2 ) |
391 | mAddress.setStreet( data[2] ); | 394 | mAddress.setStreet( data[2] ); |
392 | if ( data.count() > 3 ) | 395 | if ( data.count() > 3 ) |
393 | mAddress.setLocality( data[3] ); | 396 | mAddress.setLocality( data[3] ); |
394 | if ( data.count() > 4 ) | 397 | if ( data.count() > 4 ) |
395 | mAddress.setRegion( data[4] ); | 398 | mAddress.setRegion( data[4] ); |
396 | if ( data.count() > 5 ) | 399 | if ( data.count() > 5 ) |
397 | mAddress.setPostalCode( data[5] ); | 400 | mAddress.setPostalCode( data[5] ); |
398 | if ( data.count() > 6 ) | 401 | if ( data.count() > 6 ) |
399 | mAddress.setCountry( data[6] ); | 402 | mAddress.setCountry( data[6] ); |
400 | 403 | ||
401 | return mAddress; | 404 | return mAddress; |
402 | } | 405 | } |
403 | 406 | ||
404 | 407 | ||
405 | VCard21ParserImpl *VCard21ParserImpl::parseVCard( const QString& vc, int *err ) | 408 | VCard21ParserImpl *VCard21ParserImpl::parseVCard( const QString& vc, int *err ) |
406 | { | 409 | { |
407 | int _err = 0; | 410 | int _err = 0; |
408 | int _state = VC_STATE_BEGIN; | 411 | int _state = VC_STATE_BEGIN; |
409 | 412 | ||
410 | QValueList<VCardLineX> *_vcdata; | 413 | QValueList<VCardLineX> *_vcdata; |
411 | QValueList<QString> lines; | 414 | QValueList<QString> lines; |
412 | 415 | ||
413 | _vcdata = new QValueList<VCardLineX>; | 416 | _vcdata = new QValueList<VCardLineX>; |
414 | 417 | ||
415 | lines = QStringList::split( QRegExp( "[\x0d\x0a]" ), vc ); | 418 | lines = QStringList::split( QRegExp( "[\x0d\x0a]" ), vc ); |
416 | 419 | ||
417 | // for each line in the vCard | 420 | // for each line in the vCard |
418 | for ( QStringList::Iterator j = lines.begin(); j != lines.end(); ++j ) { | 421 | for ( QStringList::Iterator j = lines.begin(); j != lines.end(); ++j ) { |
419 | VCardLineX _vcl; | 422 | VCardLineX _vcl; |
420 | 423 | ||
421 | // take spaces off the end - ugly but necessary hack | 424 | // take spaces off the end - ugly but necessary hack |
422 | for ( int g = (*j).length()-1; g > 0 && (*j)[g].isSpace(); --g ) | 425 | for ( int g = (*j).length()-1; g > 0 && (*j)[g].isSpace(); --g ) |
423 | (*j)[g] = 0; | 426 | (*j)[g] = 0; |
424 | 427 | ||
425 | // first token: | 428 | // first token: |
426 | // verify state, update if necessary | 429 | // verify state, update if necessary |
427 | if ( _state & VC_STATE_BEGIN) { | 430 | if ( _state & VC_STATE_BEGIN) { |
428 | if ( !qstricmp( (*j).latin1(), VCARD_BEGIN ) ) { | 431 | if ( !qstricmp( (*j).latin1(), VCARD_BEGIN ) ) { |
429 | _state = VC_STATE_BODY; | 432 | _state = VC_STATE_BODY; |
430 | continue; | 433 | continue; |
431 | } else { | 434 | } else { |
432 | _err = VC_ERR_NO_BEGIN; | 435 | _err = VC_ERR_NO_BEGIN; |
433 | break; | 436 | break; |
434 | } | 437 | } |
435 | } else if ( _state & VC_STATE_BODY ) { | 438 | } else if ( _state & VC_STATE_BODY ) { |
436 | if ( !qstricmp( (*j).latin1(), VCARD_END ) ) { | 439 | if ( !qstricmp( (*j).latin1(), VCARD_END ) ) { |
437 | _state |= VC_STATE_END; | 440 | _state |= VC_STATE_END; |
438 | break; | 441 | break; |
439 | } | 442 | } |
440 | 443 | ||
441 | // split into two tokens | 444 | // split into two tokens |
442 | int colon = (*j).find( ':' ); | 445 | int colon = (*j).find( ':' ); |
443 | if ( colon < 0 ) { | 446 | if ( colon < 0 ) { |
444 | _err = VC_ERR_INVALID_LINE; | 447 | _err = VC_ERR_INVALID_LINE; |
445 | break; | 448 | break; |
446 | } | 449 | } |
447 | 450 | ||
448 | QString key = (*j).left( colon ); | 451 | QString key = (*j).left( colon ); |
449 | QString value = (*j).mid( colon + 1 ); | 452 | QString value = (*j).mid( colon + 1 ); |
450 | 453 | ||
451 | // check for qualifiers and | 454 | // check for qualifiers and |
452 | // set name, qualified, qualifier(s) | 455 | // set name, qualified, qualifier(s) |
453 | QStringList keyTokens = QStringList::split( ';', key ); | 456 | QStringList keyTokens = QStringList::split( ';', key ); |
454 | bool qp = false, first_pass = true; | 457 | bool qp = false, first_pass = true; |
455 | bool b64 = false; | 458 | bool b64 = false; |
456 | 459 | ||
457 | if ( keyTokens.count() > 0 ) { | 460 | if ( keyTokens.count() > 0 ) { |
458 | _vcl.qualified = false; | 461 | _vcl.qualified = false; |
459 | _vcl.name = keyTokens[ 0 ].lower(); | 462 | _vcl.name = keyTokens[ 0 ].lower(); |
460 | 463 | ||
461 | for ( QStringList::Iterator z = keyTokens.begin(); z != keyTokens.end(); ++z ) { | 464 | for ( QStringList::Iterator z = keyTokens.begin(); z != keyTokens.end(); ++z ) { |
462 | QString zz = (*z).lower(); | 465 | QString zz = (*z).lower(); |
463 | if ( zz == VCARD_QUOTED_PRINTABLE || zz == VCARD_ENCODING_QUOTED_PRINTABLE ) { | 466 | if ( zz == VCARD_QUOTED_PRINTABLE || zz == VCARD_ENCODING_QUOTED_PRINTABLE ) { |
464 | qp = true; | 467 | qp = true; |
465 | } else if ( zz == VCARD_BASE64 ) { | 468 | } else if ( zz == VCARD_BASE64 ) { |
466 | b64 = true; | 469 | b64 = true; |
467 | } else if ( !first_pass ) { | 470 | } else if ( !first_pass ) { |
468 | _vcl.qualified = true; | 471 | _vcl.qualified = true; |
469 | _vcl.qualifiers.append( zz ); | 472 | _vcl.qualifiers.append( zz ); |
470 | } | 473 | } |
471 | first_pass = false; | 474 | first_pass = false; |
472 | } | 475 | } |
473 | } else { | 476 | } else { |
474 | _err = VC_ERR_INVALID_LINE; | 477 | _err = VC_ERR_INVALID_LINE; |
475 | } | 478 | } |
476 | 479 | ||
477 | if ( _err != 0 ) | 480 | if ( _err != 0 ) |
478 | break; | 481 | break; |
479 | 482 | ||
480 | if ( _vcl.name == VCARD_VERSION ) | 483 | if ( _vcl.name == VCARD_VERSION ) |
481 | _state |= VC_STATE_HAVE_VERSION; | 484 | _state |= VC_STATE_HAVE_VERSION; |
482 | 485 | ||
483 | if ( _vcl.name == VCARD_N || _vcl.name == VCARD_FN ) | 486 | if ( _vcl.name == VCARD_N || _vcl.name == VCARD_FN ) |
484 | _state |= VC_STATE_HAVE_N; | 487 | _state |= VC_STATE_HAVE_N; |
485 | 488 | ||
486 | // second token: | 489 | // second token: |
487 | // split into tokens by ; | 490 | // split into tokens by ; |
488 | // add to parameters vector | 491 | // add to parameters vector |
489 | if ( b64 ) { | 492 | if ( b64 ) { |
490 | if ( value.at( value.length() - 1 ) != '=' ) | 493 | if ( value.at( value.length() - 1 ) != '=' ) |
491 | do { | 494 | do { |
492 | value += *( ++j ); | 495 | value += *( ++j ); |
493 | } while ( (*j).at( (*j).length() - 1 ) != '=' ); | 496 | } while ( (*j).at( (*j).length() - 1 ) != '=' ); |
494 | } else { | 497 | } else { |
495 | if ( qp ) { // join any split lines | 498 | if ( qp ) { // join any split lines |
496 | while ( value.at( value.length() - 1 ) == '=' ) { | 499 | while ( value.at( value.length() - 1 ) == '=' ) { |
497 | value.remove( value.length() - 1, 1 ); | 500 | value.remove( value.length() - 1, 1 ); |
498 | value.append(*( ++j )); | 501 | value.append(*( ++j )); |
499 | } | 502 | } |
500 | } | 503 | } |
501 | _vcl.parameters = QStringList::split( ';', value, true ); | 504 | _vcl.parameters = QStringList::split( ';', value, true ); |
502 | if ( qp ) { // decode the quoted printable | 505 | if ( qp ) { // decode the quoted printable |
503 | for ( QStringList::Iterator z = _vcl.parameters.begin(); z != _vcl.parameters.end(); ++z ) | 506 | for ( QStringList::Iterator z = _vcl.parameters.begin(); z != _vcl.parameters.end(); ++z ) |
504 | *z = KCodecs::quotedPrintableDecode( (*z).latin1() ); | 507 | *z = KCodecs::quotedPrintableDecode( (*z).latin1() ); |
505 | } | 508 | } |
506 | } | 509 | } |
507 | } else { | 510 | } else { |
508 | _err = VC_ERR_INTERNAL; | 511 | _err = VC_ERR_INTERNAL; |
509 | break; | 512 | break; |
510 | } | 513 | } |
511 | 514 | ||
512 | // validate VCardLineX | 515 | // validate VCardLineX |
513 | if ( !_vcl.isValid() ) { | 516 | if ( !_vcl.isValid() ) { |
514 | _err = VC_ERR_INVALID_LINE; | 517 | _err = VC_ERR_INVALID_LINE; |
515 | break; | 518 | break; |
516 | } | 519 | } |
517 | 520 | ||
518 | // add to vector | 521 | // add to vector |
519 | _vcdata->append( _vcl ); | 522 | _vcdata->append( _vcl ); |
520 | } | 523 | } |
521 | 524 | ||
522 | // errors to check at the last minute (exit state related) | 525 | // errors to check at the last minute (exit state related) |
523 | if ( _err == 0 ) { | 526 | if ( _err == 0 ) { |
524 | if ( !( _state & VC_STATE_END ) ) // we have to have an end!! | 527 | if ( !( _state & VC_STATE_END ) ) // we have to have an end!! |
525 | _err = VC_ERR_NO_END; | 528 | _err = VC_ERR_NO_END; |
526 | 529 | ||
527 | if ( !( _state & VC_STATE_HAVE_N ) || // we have to have the mandatories! | 530 | if ( !( _state & VC_STATE_HAVE_N ) || // we have to have the mandatories! |
528 | !( _state & VC_STATE_HAVE_VERSION ) ) | 531 | !( _state & VC_STATE_HAVE_VERSION ) ) |
529 | _err = VC_ERR_MISSING_MANDATORY; | 532 | _err = VC_ERR_MISSING_MANDATORY; |
530 | } | 533 | } |
531 | 534 | ||
532 | // set the error message if we can, and only return an object | 535 | // set the error message if we can, and only return an object |
533 | // if the vCard was valid. | 536 | // if the vCard was valid. |
534 | if ( err ) | 537 | if ( err ) |
535 | *err = _err; | 538 | *err = _err; |
536 | 539 | ||
537 | if ( _err != 0 ) { | 540 | if ( _err != 0 ) { |
538 | delete _vcdata; | 541 | delete _vcdata; |
539 | return 0; | 542 | return 0; |
540 | } | 543 | } |
541 | 544 | ||
542 | return new VCard21ParserImpl( _vcdata ); | 545 | return new VCard21ParserImpl( _vcdata ); |
543 | } | 546 | } |
544 | 547 | ||
545 | VCard21ParserImpl::VCard21ParserImpl(QValueList<VCardLineX> *_vcd) : _vcdata(_vcd) | 548 | VCard21ParserImpl::VCard21ParserImpl(QValueList<VCardLineX> *_vcd) : _vcdata(_vcd) |
546 | { | 549 | { |
547 | } | 550 | } |
548 | 551 | ||
549 | 552 | ||
550 | QString VCard21ParserImpl::getValue(const QString& name, const QString& qualifier) | 553 | QString VCard21ParserImpl::getValue(const QString& name, const QString& qualifier) |
551 | { | 554 | { |
552 | QString failed; | 555 | QString failed; |
553 | const QString lowname = name.lower(); | 556 | const QString lowname = name.lower(); |
554 | const QString lowqualifier = qualifier.lower(); | 557 | const QString lowqualifier = qualifier.lower(); |
555 | 558 | ||
556 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { | 559 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { |
557 | if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) { | 560 | if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) { |
558 | if ((*i).parameters.count() > 0) | 561 | if ((*i).parameters.count() > 0) |
559 | return (*i).parameters[0]; | 562 | return (*i).parameters[0]; |
560 | else return failed; | 563 | else return failed; |
561 | } | 564 | } |
562 | } | 565 | } |
563 | return failed; | 566 | return failed; |
564 | } | 567 | } |
565 | 568 | ||
566 | 569 | ||
567 | QString VCard21ParserImpl::getValue(const QString& name) | 570 | QString VCard21ParserImpl::getValue(const QString& name) |
568 | { | 571 | { |
569 | QString failed; | 572 | QString failed; |
570 | const QString lowname = name.lower(); | 573 | const QString lowname = name.lower(); |
571 | 574 | ||
572 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { | 575 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { |
573 | if ((*i).name == lowname && !(*i).qualified) { | 576 | if ((*i).name == lowname && !(*i).qualified) { |
574 | if ((*i).parameters.count() > 0) | 577 | if ((*i).parameters.count() > 0) |
575 | return (*i).parameters[0]; | 578 | return (*i).parameters[0]; |
576 | else return failed; | 579 | else return failed; |
577 | } | 580 | } |
578 | } | 581 | } |
579 | return failed; | 582 | return failed; |
580 | } | 583 | } |
581 | 584 | ||
582 | 585 | ||
583 | QStringList VCard21ParserImpl::getValues(const QString& name) | 586 | QStringList VCard21ParserImpl::getValues(const QString& name) |
584 | { | 587 | { |
585 | const QString lowname = name.lower(); | 588 | const QString lowname = name.lower(); |
586 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { | 589 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { |
587 | if ((*i).name == lowname && !(*i).qualified) | 590 | if ((*i).name == lowname && !(*i).qualified) |
588 | return (*i).parameters; | 591 | return (*i).parameters; |
589 | } | 592 | } |
590 | // failed. | 593 | // failed. |
591 | return QStringList(); | 594 | return QStringList(); |
592 | } | 595 | } |
593 | 596 | ||
594 | QStringList VCard21ParserImpl::getValues(const QString& name, const QString& qualifier) | 597 | QStringList VCard21ParserImpl::getValues(const QString& name, const QString& qualifier) |
595 | { | 598 | { |
596 | const QString lowname = name.lower(); | 599 | const QString lowname = name.lower(); |
597 | const QString lowqualifier = qualifier.lower(); | 600 | const QString lowqualifier = qualifier.lower(); |
598 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { | 601 | for (QValueListIterator<VCardLineX> i = _vcdata->begin();i != _vcdata->end();++i) { |
599 | if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) | 602 | if ((*i).name == lowname && (*i).qualified && (*i).qualifiers.contains(lowqualifier)) |
600 | return (*i).parameters; | 603 | return (*i).parameters; |
601 | } | 604 | } |
602 | // failed. | 605 | // failed. |
603 | return QStringList(); | 606 | return QStringList(); |
604 | } | 607 | } |
605 | 608 | ||
606 | 609 | ||
diff --git a/kabc/vcard21parser.h b/kabc/vcard21parser.h index 24b0eb2..77e69b6 100644 --- a/kabc/vcard21parser.h +++ b/kabc/vcard21parser.h | |||
@@ -1,225 +1,226 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | 3 | ||
4 | Copyright (c) 2002 Mark Westcott <mark@houseoffish.org> | 4 | Copyright (c) 2002 Mark Westcott <mark@houseoffish.org> |
5 | Copyright (c) 2000 George Staikos <staikos@kde.org> | 5 | Copyright (c) 2000 George Staikos <staikos@kde.org> |
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 | #ifndef KABC_VCARD21FORMAT_H | 29 | #ifndef KABC_VCARD21FORMAT_H |
30 | #define KABC_VCARD21FORMAT_H | 30 | #define KABC_VCARD21FORMAT_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <kdebug.h> | 33 | #include <kdebug.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | #include <qstring.h> | 35 | #include <qstring.h> |
36 | #include <kurl.h> | 36 | #include <kurl.h> |
37 | #include <qvaluelist.h> | 37 | #include <qvaluelist.h> |
38 | 38 | ||
39 | #include "addressee.h" | 39 | #include "addressee.h" |
40 | #include "addressbook.h" | 40 | #include "addressbook.h" |
41 | #include "phonenumber.h" | 41 | #include "phonenumber.h" |
42 | 42 | ||
43 | 43 | ||
44 | #define VCARD_BEGIN "begin:vcard" | 44 | #define VCARD_BEGIN "begin:vcard" |
45 | #define VCARD_END "end:vcard" | 45 | #define VCARD_END "end:vcard" |
46 | #define VCARD_BEGIN_N "begin" | 46 | #define VCARD_BEGIN_N "begin" |
47 | #define VCARD_END_N "end" | 47 | #define VCARD_END_N "end" |
48 | #define VCARD_VERSION "version" | 48 | #define VCARD_VERSION "version" |
49 | 49 | ||
50 | #define VCARD_FN "fn" | 50 | #define VCARD_FN "fn" |
51 | #define VCARD_N "n" | 51 | #define VCARD_N "n" |
52 | 52 | ||
53 | // optional | 53 | // optional |
54 | #define VCARD_NAME "name" | 54 | #define VCARD_NAME "name" |
55 | #define VCARD_NICKNAME "nickname" | 55 | #define VCARD_NICKNAME "nickname" |
56 | #define VCARD_PHOTO "photo" | 56 | #define VCARD_PHOTO "photo" |
57 | #define VCARD_BDAY "bday" | 57 | #define VCARD_BDAY "bday" |
58 | #define VCARD_ADR "adr" | 58 | #define VCARD_ADR "adr" |
59 | 59 | ||
60 | // types | 60 | // types |
61 | #define VCARD_ADR_DOM "dom" | 61 | #define VCARD_ADR_DOM "dom" |
62 | #define VCARD_ADR_INTL "intl" | 62 | #define VCARD_ADR_INTL "intl" |
63 | #define VCARD_ADR_POSTAL "postal" | 63 | #define VCARD_ADR_POSTAL "postal" |
64 | #define VCARD_ADR_PARCEL "parcel" | 64 | #define VCARD_ADR_PARCEL "parcel" |
65 | #define VCARD_ADR_HOME "home" | 65 | #define VCARD_ADR_HOME "home" |
66 | #define VCARD_ADR_WORK "work" | 66 | #define VCARD_ADR_WORK "work" |
67 | #define VCARD_ADR_PREF "pref" | 67 | #define VCARD_ADR_PREF "pref" |
68 | // values | 68 | // values |
69 | #define VCARD_ADR_POBOX "PO Box" | 69 | #define VCARD_ADR_POBOX "PO Box" |
70 | #define VCARD_ADR_EXTADR "Extended Address" | 70 | #define VCARD_ADR_EXTADR "Extended Address" |
71 | #define VCARD_ADR_STREET "Street" | 71 | #define VCARD_ADR_STREET "Street" |
72 | #define VCARD_ADR_LOCALITY "Locality" | 72 | #define VCARD_ADR_LOCALITY "Locality" |
73 | #define VCARD_ADR_REGION "Region" | 73 | #define VCARD_ADR_REGION "Region" |
74 | #define VCARD_ADR_POSTCODE "Postal Code" | 74 | #define VCARD_ADR_POSTCODE "Postal Code" |
75 | #define VCARD_ADR_COUNTRY "Country Name" | 75 | #define VCARD_ADR_COUNTRY "Country Name" |
76 | #define VCARD_LABEL "label" | 76 | #define VCARD_LABEL "label" |
77 | #define VCARD_PROFILE "profile" | 77 | #define VCARD_PROFILE "profile" |
78 | #define VCARD_SOURCE "source" | 78 | #define VCARD_SOURCE "source" |
79 | #define VCARD_TEL "tel" | 79 | #define VCARD_TEL "tel" |
80 | // types | 80 | // types |
81 | #define VCARD_TEL_HOME "home" | 81 | #define VCARD_TEL_HOME "home" |
82 | #define VCARD_TEL_WORK "work" | 82 | #define VCARD_TEL_WORK "work" |
83 | #define VCARD_TEL_PREF "pref" | 83 | #define VCARD_TEL_PREF "pref" |
84 | #define VCARD_TEL_VOICE "voice" | 84 | #define VCARD_TEL_VOICE "voice" |
85 | #define VCARD_TEL_FAX "fax" | 85 | #define VCARD_TEL_FAX "fax" |
86 | #define VCARD_TEL_MSG "msg" | 86 | #define VCARD_TEL_MSG "msg" |
87 | #define VCARD_TEL_CELL "cell" | 87 | #define VCARD_TEL_CELL "cell" |
88 | #define VCARD_TEL_PAGER "pager" | 88 | #define VCARD_TEL_PAGER "pager" |
89 | #define VCARD_TEL_BBS "bbs" | 89 | #define VCARD_TEL_BBS "bbs" |
90 | #define VCARD_TEL_MODEM "modem" | 90 | #define VCARD_TEL_MODEM "modem" |
91 | #define VCARD_TEL_CAR "car" | 91 | #define VCARD_TEL_CAR "car" |
92 | #define VCARD_TEL_ISDN "isdn" | 92 | #define VCARD_TEL_ISDN "isdn" |
93 | #define VCARD_TEL_VIDEO "video" | 93 | #define VCARD_TEL_VIDEO "video" |
94 | #define VCARD_TEL_PCS "pcs" | 94 | #define VCARD_TEL_PCS "pcs" |
95 | #define VCARD_TEL_SIP "sip" | ||
95 | #define VCARD_EMAIL "email" | 96 | #define VCARD_EMAIL "email" |
96 | // types | 97 | // types |
97 | #define VCARD_EMAIL_PREF "pref" | 98 | #define VCARD_EMAIL_PREF "pref" |
98 | #define VCARD_EMAIL_INTERNET "internet" | 99 | #define VCARD_EMAIL_INTERNET "internet" |
99 | #define VCARD_EMAIL_X400 "x400" | 100 | #define VCARD_EMAIL_X400 "x400" |
100 | #define VCARD_TZ "tz" | 101 | #define VCARD_TZ "tz" |
101 | #define VCARD_GEO "geo" | 102 | #define VCARD_GEO "geo" |
102 | #define VCARD_MAILER "mailer" | 103 | #define VCARD_MAILER "mailer" |
103 | #define VCARD_TITLE "title" | 104 | #define VCARD_TITLE "title" |
104 | #define VCARD_ROLE "role" | 105 | #define VCARD_ROLE "role" |
105 | #define VCARD_LOGO "logo" | 106 | #define VCARD_LOGO "logo" |
106 | #define VCARD_AGENT "agent" | 107 | #define VCARD_AGENT "agent" |
107 | #define VCARD_ORG "org" | 108 | #define VCARD_ORG "org" |
108 | #define VCARD_CATEGORIES "categories" | 109 | #define VCARD_CATEGORIES "categories" |
109 | #define VCARD_NOTE "note" | 110 | #define VCARD_NOTE "note" |
110 | #define VCARD_PRODID "prodid" | 111 | #define VCARD_PRODID "prodid" |
111 | #define VCARD_REV "rev" | 112 | #define VCARD_REV "rev" |
112 | #define VCARD_SOUND "sound" | 113 | #define VCARD_SOUND "sound" |
113 | #define VCARD_UID "uid" | 114 | #define VCARD_UID "uid" |
114 | #define VCARD_URL "url" | 115 | #define VCARD_URL "url" |
115 | #define VCARD_CLASS "class" | 116 | #define VCARD_CLASS "class" |
116 | #define VCARD_CLASS_PUBLIC "public" | 117 | #define VCARD_CLASS_PUBLIC "public" |
117 | #define VCARD_CLASS_PRIVATE "private" | 118 | #define VCARD_CLASS_PRIVATE "private" |
118 | #define VCARD_CLASS_CONFIDENTIAL "confidential" | 119 | #define VCARD_CLASS_CONFIDENTIAL "confidential" |
119 | #define VCARD_KEY "key" | 120 | #define VCARD_KEY "key" |
120 | // types | 121 | // types |
121 | #define VCARD_KEY_X509 "x509" | 122 | #define VCARD_KEY_X509 "x509" |
122 | #define VCARD_KEY_PGP "pgp" | 123 | #define VCARD_KEY_PGP "pgp" |
123 | 124 | ||
124 | #define VCARD_QUOTED_PRINTABLE "quoted-printable" | 125 | #define VCARD_QUOTED_PRINTABLE "quoted-printable" |
125 | // this one is a temporary hack until we support TYPE=VALUE | 126 | // this one is a temporary hack until we support TYPE=VALUE |
126 | #define VCARD_ENCODING_QUOTED_PRINTABLE "encoding=quoted-printable" | 127 | #define VCARD_ENCODING_QUOTED_PRINTABLE "encoding=quoted-printable" |
127 | #define VCARD_BASE64 "base64" | 128 | #define VCARD_BASE64 "base64" |
128 | 129 | ||
129 | #define VC_STATE_BEGIN 1 | 130 | #define VC_STATE_BEGIN 1 |
130 | #define VC_STATE_BODY 2 | 131 | #define VC_STATE_BODY 2 |
131 | #define VC_STATE_END 4 | 132 | #define VC_STATE_END 4 |
132 | #define VC_STATE_HAVE_N 8 | 133 | #define VC_STATE_HAVE_N 8 |
133 | #define VC_STATE_HAVE_VERSION 16 | 134 | #define VC_STATE_HAVE_VERSION 16 |
134 | 135 | ||
135 | #define VC_ERR_NO_BEGIN 1 | 136 | #define VC_ERR_NO_BEGIN 1 |
136 | #define VC_ERR_NO_END 2 | 137 | #define VC_ERR_NO_END 2 |
137 | #define VC_ERR_INVALID_LINE 3 | 138 | #define VC_ERR_INVALID_LINE 3 |
138 | #define VC_ERR_INTERNAL 4 | 139 | #define VC_ERR_INTERNAL 4 |
139 | #define VC_ERR_INVALID_NAME 5 | 140 | #define VC_ERR_INVALID_NAME 5 |
140 | #define VC_ERR_MISSING_MANDATORY 6 | 141 | #define VC_ERR_MISSING_MANDATORY 6 |
141 | 142 | ||
142 | namespace KABC { | 143 | namespace KABC { |
143 | 144 | ||
144 | class AddressBook; | 145 | class AddressBook; |
145 | 146 | ||
146 | class VCard21Parser | 147 | class VCard21Parser |
147 | { | 148 | { |
148 | public: | 149 | public: |
149 | 150 | ||
150 | /** | 151 | /** |
151 | * Constructor. | 152 | * Constructor. |
152 | */ | 153 | */ |
153 | VCard21Parser(); | 154 | VCard21Parser(); |
154 | 155 | ||
155 | /** | 156 | /** |
156 | * Destructor. | 157 | * Destructor. |
157 | */ | 158 | */ |
158 | virtual ~VCard21Parser(); | 159 | virtual ~VCard21Parser(); |
159 | 160 | ||
160 | /** | 161 | /** |
161 | * Parses a string in vcard2.1 format and saves the single addressees | 162 | * Parses a string in vcard2.1 format and saves the single addressees |
162 | * to the address book. | 163 | * to the address book. |
163 | * | 164 | * |
164 | * @param ab The address book. | 165 | * @param ab The address book. |
165 | * @param str The vcard string. | 166 | * @param str The vcard string. |
166 | */ | 167 | */ |
167 | void readFromString( KABC::AddressBook *ab, const QString &str ); | 168 | void readFromString( KABC::AddressBook *ab, const QString &str ); |
168 | 169 | ||
169 | /** | 170 | /** |
170 | * FIXME: we need a writeToString method | 171 | * FIXME: we need a writeToString method |
171 | * QString writeToString (KABC::AddressBook *); | 172 | * QString writeToString (KABC::AddressBook *); |
172 | */ | 173 | */ |
173 | 174 | ||
174 | /** | 175 | /** |
175 | * Parses a string in vcard2.1 format and returns the inherent addressee. | 176 | * Parses a string in vcard2.1 format and returns the inherent addressee. |
176 | */ | 177 | */ |
177 | KABC::Addressee readFromString( const QString &data); | 178 | KABC::Addressee readFromString( const QString &data); |
178 | 179 | ||
179 | /** | 180 | /** |
180 | * Helper method to store a address. | 181 | * Helper method to store a address. |
181 | * | 182 | * |
182 | * @param data A string list, that is filled with 'street', 'house number' ... | 183 | * @param data A string list, that is filled with 'street', 'house number' ... |
183 | * @param type The type of the returned address. | 184 | * @param type The type of the returned address. |
184 | */ | 185 | */ |
185 | static KABC::Address readAddressFromQStringList (const QStringList &data, const int type); | 186 | static KABC::Address readAddressFromQStringList (const QStringList &data, const int type); |
186 | }; | 187 | }; |
187 | 188 | ||
188 | } | 189 | } |
189 | 190 | ||
190 | /** | 191 | /** |
191 | * @short Helper class | 192 | * @short Helper class |
192 | */ | 193 | */ |
193 | class VCardLineX | 194 | class VCardLineX |
194 | { | 195 | { |
195 | public: | 196 | public: |
196 | QString name; | 197 | QString name; |
197 | bool qualified; | 198 | bool qualified; |
198 | QValueList<QString> qualifiers; | 199 | QValueList<QString> qualifiers; |
199 | QValueList<QString> parameters; | 200 | QValueList<QString> parameters; |
200 | bool isValid() const; | 201 | bool isValid() const; |
201 | }; | 202 | }; |
202 | 203 | ||
203 | /** | 204 | /** |
204 | * @short Helper class | 205 | * @short Helper class |
205 | */ | 206 | */ |
206 | class VCard21ParserImpl | 207 | class VCard21ParserImpl |
207 | { | 208 | { |
208 | friend class VCardLineX; | 209 | friend class VCardLineX; |
209 | 210 | ||
210 | public: | 211 | public: |
211 | VCard21ParserImpl() { }; | 212 | VCard21ParserImpl() { }; |
212 | virtual ~VCard21ParserImpl() { }; | 213 | virtual ~VCard21ParserImpl() { }; |
213 | static VCard21ParserImpl *parseVCard(const QString& vc, int *err = NULL); | 214 | static VCard21ParserImpl *parseVCard(const QString& vc, int *err = NULL); |
214 | QString getValue(const QString& name, const QString& qualifier); | 215 | QString getValue(const QString& name, const QString& qualifier); |
215 | QString getValue(const QString& name); | 216 | QString getValue(const QString& name); |
216 | QStringList getValues(const QString& name, const QString& qualifier); | 217 | QStringList getValues(const QString& name, const QString& qualifier); |
217 | QStringList getValues(const QString& name); | 218 | QStringList getValues(const QString& name); |
218 | 219 | ||
219 | QValueList<VCardLineX> *_vcdata; | 220 | QValueList<VCardLineX> *_vcdata; |
220 | 221 | ||
221 | private: | 222 | private: |
222 | VCard21ParserImpl (QValueList<VCardLineX> *_vcd); | 223 | VCard21ParserImpl (QValueList<VCardLineX> *_vcd); |
223 | }; | 224 | }; |
224 | 225 | ||
225 | #endif | 226 | #endif |
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index bffaa64..2d6eb3d 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp | |||
@@ -1,1030 +1,1032 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <qfile.h> | 28 | #include <qfile.h> |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | 30 | ||
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kmdcodec.h> | 32 | #include <kmdcodec.h> |
33 | #include <kstandarddirs.h> | 33 | #include <kstandarddirs.h> |
34 | #include <ktempfile.h> | 34 | #include <ktempfile.h> |
35 | 35 | ||
36 | #include <VCard.h> | 36 | #include <VCard.h> |
37 | 37 | ||
38 | #include "addressbook.h" | 38 | #include "addressbook.h" |
39 | #include "vcardformatimpl.h" | 39 | #include "vcardformatimpl.h" |
40 | 40 | ||
41 | using namespace KABC; | 41 | using namespace KABC; |
42 | using namespace VCARD; | 42 | using namespace VCARD; |
43 | 43 | ||
44 | bool VCardFormatImpl::load( Addressee &addressee, QFile *file ) | 44 | bool VCardFormatImpl::load( Addressee &addressee, QFile *file ) |
45 | { | 45 | { |
46 | kdDebug(5700) << "VCardFormat::load()" << endl; | 46 | kdDebug(5700) << "VCardFormat::load()" << endl; |
47 | 47 | ||
48 | QByteArray fdata = file->readAll(); | 48 | QByteArray fdata = file->readAll(); |
49 | QCString data(fdata.data(), fdata.size()+1); | 49 | QCString data(fdata.data(), fdata.size()+1); |
50 | 50 | ||
51 | VCardEntity e( data ); | 51 | VCardEntity e( data ); |
52 | 52 | ||
53 | VCardListIterator it( e.cardList() ); | 53 | VCardListIterator it( e.cardList() ); |
54 | 54 | ||
55 | if ( it.current() ) { | 55 | if ( it.current() ) { |
56 | //US VCard v(*it.current()); | 56 | //US VCard v(*it.current()); |
57 | //US loadAddressee( addressee, v ); | 57 | //US loadAddressee( addressee, v ); |
58 | loadAddressee( addressee, it.current() ); | 58 | loadAddressee( addressee, it.current() ); |
59 | return true; | 59 | return true; |
60 | } | 60 | } |
61 | 61 | ||
62 | return false; | 62 | return false; |
63 | } | 63 | } |
64 | 64 | ||
65 | bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) | 65 | bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) |
66 | { | 66 | { |
67 | kdDebug(5700) << "VCardFormat::loadAll()" << endl; | 67 | kdDebug(5700) << "VCardFormat::loadAll()" << endl; |
68 | 68 | ||
69 | QByteArray fdata = file->readAll(); | 69 | QByteArray fdata = file->readAll(); |
70 | QCString data(fdata.data(), fdata.size()+1); | 70 | QCString data(fdata.data(), fdata.size()+1); |
71 | 71 | ||
72 | VCardEntity e( data ); | 72 | VCardEntity e( data ); |
73 | 73 | ||
74 | VCardListIterator it( e.cardList() ); | 74 | VCardListIterator it( e.cardList() ); |
75 | 75 | ||
76 | for (; it.current(); ++it) { | 76 | for (; it.current(); ++it) { |
77 | //US VCard v(*it.current()); | 77 | //US VCard v(*it.current()); |
78 | Addressee addressee; | 78 | Addressee addressee; |
79 | //US loadAddressee( addressee, v ); | 79 | //US loadAddressee( addressee, v ); |
80 | loadAddressee( addressee, it.current() ); | 80 | loadAddressee( addressee, it.current() ); |
81 | addressee.setResource( resource ); | 81 | addressee.setResource( resource ); |
82 | addressBook->insertAddressee( addressee ); | 82 | addressBook->insertAddressee( addressee ); |
83 | } | 83 | } |
84 | 84 | ||
85 | return true; | 85 | return true; |
86 | } | 86 | } |
87 | 87 | ||
88 | void VCardFormatImpl::save( const Addressee &addressee, QFile *file ) | 88 | void VCardFormatImpl::save( const Addressee &addressee, QFile *file ) |
89 | { | 89 | { |
90 | VCardEntity vcards; | 90 | VCardEntity vcards; |
91 | VCardList vcardlist; | 91 | VCardList vcardlist; |
92 | vcardlist.setAutoDelete( true ); | 92 | vcardlist.setAutoDelete( true ); |
93 | 93 | ||
94 | VCard *v = new VCard; | 94 | VCard *v = new VCard; |
95 | 95 | ||
96 | saveAddressee( addressee, v, false ); | 96 | saveAddressee( addressee, v, false ); |
97 | 97 | ||
98 | vcardlist.append( v ); | 98 | vcardlist.append( v ); |
99 | vcards.setCardList( vcardlist ); | 99 | vcards.setCardList( vcardlist ); |
100 | 100 | ||
101 | QCString vcardData = vcards.asString(); | 101 | QCString vcardData = vcards.asString(); |
102 | file->writeBlock( (const char*)vcardData, vcardData.length() ); | 102 | file->writeBlock( (const char*)vcardData, vcardData.length() ); |
103 | } | 103 | } |
104 | 104 | ||
105 | void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file ) | 105 | void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file ) |
106 | { | 106 | { |
107 | VCardEntity vcards; | 107 | VCardEntity vcards; |
108 | VCardList vcardlist; | 108 | VCardList vcardlist; |
109 | vcardlist.setAutoDelete( true ); | 109 | vcardlist.setAutoDelete( true ); |
110 | 110 | ||
111 | AddressBook::Iterator it; | 111 | AddressBook::Iterator it; |
112 | for ( it = ab->begin(); it != ab->end(); ++it ) { | 112 | for ( it = ab->begin(); it != ab->end(); ++it ) { |
113 | if ( (*it).resource() == resource ) { | 113 | if ( (*it).resource() == resource ) { |
114 | VCard *v = new VCard; | 114 | VCard *v = new VCard; |
115 | saveAddressee( (*it), v, false ); | 115 | saveAddressee( (*it), v, false ); |
116 | (*it).setChanged( false ); | 116 | (*it).setChanged( false ); |
117 | vcardlist.append( v ); | 117 | vcardlist.append( v ); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | vcards.setCardList( vcardlist ); | 121 | vcards.setCardList( vcardlist ); |
122 | 122 | ||
123 | QCString vcardData = vcards.asString(); | 123 | QCString vcardData = vcards.asString(); |
124 | file->writeBlock( (const char*)vcardData, vcardData.length() ); | 124 | file->writeBlock( (const char*)vcardData, vcardData.length() ); |
125 | } | 125 | } |
126 | 126 | ||
127 | bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) | 127 | bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) |
128 | { | 128 | { |
129 | QPtrList<ContentLine> contentLines = v->contentLineList(); | 129 | QPtrList<ContentLine> contentLines = v->contentLineList(); |
130 | ContentLine *cl; | 130 | ContentLine *cl; |
131 | 131 | ||
132 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { | 132 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { |
133 | QCString n = cl->name(); | 133 | QCString n = cl->name(); |
134 | if ( n.left( 2 ) == "X-" ) { | 134 | if ( n.left( 2 ) == "X-" ) { |
135 | n = n.mid( 2 ); | 135 | n = n.mid( 2 ); |
136 | int posDash = n.find( "-" ); | 136 | int posDash = n.find( "-" ); |
137 | addressee.insertCustom( QString::fromUtf8( n.left( posDash ) ), | 137 | addressee.insertCustom( QString::fromUtf8( n.left( posDash ) ), |
138 | QString::fromUtf8( n.mid( posDash + 1 ) ), | 138 | QString::fromUtf8( n.mid( posDash + 1 ) ), |
139 | QString::fromUtf8( cl->value()->asString() ) ); | 139 | QString::fromUtf8( cl->value()->asString() ) ); |
140 | continue; | 140 | continue; |
141 | } | 141 | } |
142 | 142 | ||
143 | EntityType type = cl->entityType(); | 143 | EntityType type = cl->entityType(); |
144 | switch( type ) { | 144 | switch( type ) { |
145 | 145 | ||
146 | case EntityUID: | 146 | case EntityUID: |
147 | addressee.setUid( readTextValue( cl ) ); | 147 | addressee.setUid( readTextValue( cl ) ); |
148 | break; | 148 | break; |
149 | 149 | ||
150 | case EntityEmail: | 150 | case EntityEmail: |
151 | addressee.insertEmail( readTextValue( cl ) ); | 151 | addressee.insertEmail( readTextValue( cl ) ); |
152 | break; | 152 | break; |
153 | 153 | ||
154 | case EntityName: | 154 | case EntityName: |
155 | addressee.setName( readTextValue( cl ) ); | 155 | addressee.setName( readTextValue( cl ) ); |
156 | break; | 156 | break; |
157 | 157 | ||
158 | case EntityFullName: | 158 | case EntityFullName: |
159 | addressee.setFormattedName( readTextValue( cl ) ); | 159 | addressee.setFormattedName( readTextValue( cl ) ); |
160 | break; | 160 | break; |
161 | 161 | ||
162 | case EntityURL: | 162 | case EntityURL: |
163 | addressee.setUrl( KURL( readTextValue( cl ) ) ); | 163 | addressee.setUrl( KURL( readTextValue( cl ) ) ); |
164 | break; | 164 | break; |
165 | 165 | ||
166 | case EntityNickname: | 166 | case EntityNickname: |
167 | addressee.setNickName( readTextValue( cl ) ); | 167 | addressee.setNickName( readTextValue( cl ) ); |
168 | break; | 168 | break; |
169 | 169 | ||
170 | case EntityLabel: | 170 | case EntityLabel: |
171 | // not yet supported by kabc | 171 | // not yet supported by kabc |
172 | break; | 172 | break; |
173 | 173 | ||
174 | case EntityMailer: | 174 | case EntityMailer: |
175 | addressee.setMailer( readTextValue( cl ) ); | 175 | addressee.setMailer( readTextValue( cl ) ); |
176 | break; | 176 | break; |
177 | 177 | ||
178 | case EntityTitle: | 178 | case EntityTitle: |
179 | addressee.setTitle( readTextValue( cl ) ); | 179 | addressee.setTitle( readTextValue( cl ) ); |
180 | break; | 180 | break; |
181 | 181 | ||
182 | case EntityRole: | 182 | case EntityRole: |
183 | addressee.setRole( readTextValue( cl ) ); | 183 | addressee.setRole( readTextValue( cl ) ); |
184 | break; | 184 | break; |
185 | 185 | ||
186 | case EntityOrganisation: | 186 | case EntityOrganisation: |
187 | addressee.setOrganization( readTextValue( cl ) ); | 187 | addressee.setOrganization( readTextValue( cl ) ); |
188 | break; | 188 | break; |
189 | 189 | ||
190 | case EntityNote: | 190 | case EntityNote: |
191 | addressee.setNote( readTextValue( cl ) ); | 191 | addressee.setNote( readTextValue( cl ) ); |
192 | break; | 192 | break; |
193 | 193 | ||
194 | case EntityProductID: | 194 | case EntityProductID: |
195 | addressee.setProductId( readTextValue( cl ) ); | 195 | addressee.setProductId( readTextValue( cl ) ); |
196 | break; | 196 | break; |
197 | 197 | ||
198 | case EntitySortString: | 198 | case EntitySortString: |
199 | addressee.setSortString( readTextValue( cl ) ); | 199 | addressee.setSortString( readTextValue( cl ) ); |
200 | break; | 200 | break; |
201 | 201 | ||
202 | case EntityN: | 202 | case EntityN: |
203 | readNValue( cl, addressee ); | 203 | readNValue( cl, addressee ); |
204 | break; | 204 | break; |
205 | 205 | ||
206 | case EntityAddress: | 206 | case EntityAddress: |
207 | addressee.insertAddress( readAddressValue( cl ) ); | 207 | addressee.insertAddress( readAddressValue( cl ) ); |
208 | break; | 208 | break; |
209 | 209 | ||
210 | case EntityTelephone: | 210 | case EntityTelephone: |
211 | addressee.insertPhoneNumber( readTelephoneValue( cl ) ); | 211 | addressee.insertPhoneNumber( readTelephoneValue( cl ) ); |
212 | break; | 212 | break; |
213 | 213 | ||
214 | case EntityCategories: | 214 | case EntityCategories: |
215 | addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) ); | 215 | addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) ); |
216 | break; | 216 | break; |
217 | 217 | ||
218 | case EntityBirthday: | 218 | case EntityBirthday: |
219 | addressee.setBirthday( readDateValue( cl ) ); | 219 | addressee.setBirthday( readDateValue( cl ) ); |
220 | break; | 220 | break; |
221 | 221 | ||
222 | case EntityRevision: | 222 | case EntityRevision: |
223 | addressee.setRevision( readDateTimeValue( cl ) ); | 223 | addressee.setRevision( readDateTimeValue( cl ) ); |
224 | break; | 224 | break; |
225 | 225 | ||
226 | case EntityGeo: | 226 | case EntityGeo: |
227 | addressee.setGeo( readGeoValue( cl ) ); | 227 | addressee.setGeo( readGeoValue( cl ) ); |
228 | break; | 228 | break; |
229 | 229 | ||
230 | case EntityTimeZone: | 230 | case EntityTimeZone: |
231 | addressee.setTimeZone( readUTCValue( cl ) ); | 231 | addressee.setTimeZone( readUTCValue( cl ) ); |
232 | break; | 232 | break; |
233 | 233 | ||
234 | case EntityVersion: | 234 | case EntityVersion: |
235 | break; | 235 | break; |
236 | 236 | ||
237 | case EntityClass: | 237 | case EntityClass: |
238 | addressee.setSecrecy( readClassValue( cl ) ); | 238 | addressee.setSecrecy( readClassValue( cl ) ); |
239 | break; | 239 | break; |
240 | 240 | ||
241 | case EntityKey: | 241 | case EntityKey: |
242 | addressee.insertKey( readKeyValue( cl ) ); | 242 | addressee.insertKey( readKeyValue( cl ) ); |
243 | break; | 243 | break; |
244 | 244 | ||
245 | case EntityPhoto: | 245 | case EntityPhoto: |
246 | addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) ); | 246 | addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) ); |
247 | break; | 247 | break; |
248 | 248 | ||
249 | case EntityLogo: | 249 | case EntityLogo: |
250 | addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) ); | 250 | addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) ); |
251 | break; | 251 | break; |
252 | 252 | ||
253 | case EntityAgent: | 253 | case EntityAgent: |
254 | addressee.setAgent( readAgentValue( cl ) ); | 254 | addressee.setAgent( readAgentValue( cl ) ); |
255 | break; | 255 | break; |
256 | 256 | ||
257 | case EntitySound: | 257 | case EntitySound: |
258 | addressee.setSound( readSoundValue( cl, addressee ) ); | 258 | addressee.setSound( readSoundValue( cl, addressee ) ); |
259 | break; | 259 | break; |
260 | 260 | ||
261 | default: | 261 | default: |
262 | kdDebug(5700) << "VCardFormat::load(): Unsupported entity: " | 262 | kdDebug(5700) << "VCardFormat::load(): Unsupported entity: " |
263 | << int( type ) << ": " << cl->asString() << endl; | 263 | << int( type ) << ": " << cl->asString() << endl; |
264 | break; | 264 | break; |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { | 268 | for( cl = contentLines.first(); cl; cl = contentLines.next() ) { |
269 | EntityType type = cl->entityType(); | 269 | EntityType type = cl->entityType(); |
270 | if ( type == EntityLabel ) { | 270 | if ( type == EntityLabel ) { |
271 | int type = readAddressParam( cl ); | 271 | int type = readAddressParam( cl ); |
272 | Address address = addressee.address( type ); | 272 | Address address = addressee.address( type ); |
273 | if ( address.isEmpty() ) | 273 | if ( address.isEmpty() ) |
274 | address.setType( type ); | 274 | address.setType( type ); |
275 | 275 | ||
276 | address.setLabel( QString::fromUtf8( cl->value()->asString() ) ); | 276 | address.setLabel( QString::fromUtf8( cl->value()->asString() ) ); |
277 | addressee.insertAddress( address ); | 277 | addressee.insertAddress( address ); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | return true; | 281 | return true; |
282 | } | 282 | } |
283 | 283 | ||
284 | void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern ) | 284 | void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern ) |
285 | { | 285 | { |
286 | //US ContentLine cl; | 286 | //US ContentLine cl; |
287 | //US QString value; | 287 | //US QString value; |
288 | 288 | ||
289 | addTextValue( v, EntityName, addressee.name() ); | 289 | addTextValue( v, EntityName, addressee.name() ); |
290 | addTextValue( v, EntityUID, addressee.uid() ); | 290 | addTextValue( v, EntityUID, addressee.uid() ); |
291 | addTextValue( v, EntityFullName, addressee.formattedName() ); | 291 | addTextValue( v, EntityFullName, addressee.formattedName() ); |
292 | 292 | ||
293 | QStringList emails = addressee.emails(); | 293 | QStringList emails = addressee.emails(); |
294 | QStringList::ConstIterator it4; | 294 | QStringList::ConstIterator it4; |
295 | for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { | 295 | for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { |
296 | addTextValue( v, EntityEmail, *it4 ); | 296 | addTextValue( v, EntityEmail, *it4 ); |
297 | } | 297 | } |
298 | 298 | ||
299 | QStringList customs = addressee.customs(); | 299 | QStringList customs = addressee.customs(); |
300 | QStringList::ConstIterator it5; | 300 | QStringList::ConstIterator it5; |
301 | for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) { | 301 | for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) { |
302 | addCustomValue( v, *it5 ); | 302 | addCustomValue( v, *it5 ); |
303 | } | 303 | } |
304 | 304 | ||
305 | addTextValue( v, EntityURL, addressee.url().url() ); | 305 | addTextValue( v, EntityURL, addressee.url().url() ); |
306 | 306 | ||
307 | addNValue( v, addressee ); | 307 | addNValue( v, addressee ); |
308 | 308 | ||
309 | addTextValue( v, EntityNickname, addressee.nickName() ); | 309 | addTextValue( v, EntityNickname, addressee.nickName() ); |
310 | addTextValue( v, EntityMailer, addressee.mailer() ); | 310 | addTextValue( v, EntityMailer, addressee.mailer() ); |
311 | addTextValue( v, EntityTitle, addressee.title() ); | 311 | addTextValue( v, EntityTitle, addressee.title() ); |
312 | addTextValue( v, EntityRole, addressee.role() ); | 312 | addTextValue( v, EntityRole, addressee.role() ); |
313 | addTextValue( v, EntityOrganisation, addressee.organization() ); | 313 | addTextValue( v, EntityOrganisation, addressee.organization() ); |
314 | addTextValue( v, EntityNote, addressee.note() ); | 314 | addTextValue( v, EntityNote, addressee.note() ); |
315 | addTextValue( v, EntityProductID, addressee.productId() ); | 315 | addTextValue( v, EntityProductID, addressee.productId() ); |
316 | addTextValue( v, EntitySortString, addressee.sortString() ); | 316 | addTextValue( v, EntitySortString, addressee.sortString() ); |
317 | 317 | ||
318 | Address::List addresses = addressee.addresses(); | 318 | Address::List addresses = addressee.addresses(); |
319 | Address::List::ConstIterator it3; | 319 | Address::List::ConstIterator it3; |
320 | for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) { | 320 | for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) { |
321 | addAddressValue( v, *it3 ); | 321 | addAddressValue( v, *it3 ); |
322 | addLabelValue( v, *it3 ); | 322 | addLabelValue( v, *it3 ); |
323 | } | 323 | } |
324 | 324 | ||
325 | PhoneNumber::List phoneNumbers = addressee.phoneNumbers(); | 325 | PhoneNumber::List phoneNumbers = addressee.phoneNumbers(); |
326 | PhoneNumber::List::ConstIterator it2; | 326 | PhoneNumber::List::ConstIterator it2; |
327 | for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) { | 327 | for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) { |
328 | addTelephoneValue( v, *it2 ); | 328 | addTelephoneValue( v, *it2 ); |
329 | } | 329 | } |
330 | 330 | ||
331 | Key::List keys = addressee.keys(); | 331 | Key::List keys = addressee.keys(); |
332 | Key::List::ConstIterator it6; | 332 | Key::List::ConstIterator it6; |
333 | for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) { | 333 | for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) { |
334 | addKeyValue( v, *it6 ); | 334 | addKeyValue( v, *it6 ); |
335 | } | 335 | } |
336 | 336 | ||
337 | addTextValue( v, EntityCategories, addressee.categories().join(",") ); | 337 | addTextValue( v, EntityCategories, addressee.categories().join(",") ); |
338 | 338 | ||
339 | addDateValue( v, EntityBirthday, addressee.birthday().date() ); | 339 | addDateValue( v, EntityBirthday, addressee.birthday().date() ); |
340 | addDateTimeValue( v, EntityRevision, addressee.revision() ); | 340 | addDateTimeValue( v, EntityRevision, addressee.revision() ); |
341 | addGeoValue( v, addressee.geo() ); | 341 | addGeoValue( v, addressee.geo() ); |
342 | addUTCValue( v, addressee.timeZone() ); | 342 | addUTCValue( v, addressee.timeZone() ); |
343 | 343 | ||
344 | addClassValue( v, addressee.secrecy() ); | 344 | addClassValue( v, addressee.secrecy() ); |
345 | 345 | ||
346 | addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern ); | 346 | addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern ); |
347 | addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern ); | 347 | addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern ); |
348 | 348 | ||
349 | addAgentValue( v, addressee.agent() ); | 349 | addAgentValue( v, addressee.agent() ); |
350 | 350 | ||
351 | addSoundValue( v, addressee.sound(), addressee, intern ); | 351 | addSoundValue( v, addressee.sound(), addressee, intern ); |
352 | } | 352 | } |
353 | 353 | ||
354 | void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt ) | 354 | void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt ) |
355 | { | 355 | { |
356 | if ( txt.isEmpty() ) return; | 356 | if ( txt.isEmpty() ) return; |
357 | 357 | ||
358 | ContentLine cl; | 358 | ContentLine cl; |
359 | cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() ); | 359 | cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() ); |
360 | QString value = txt.mid( txt.find( ":" ) + 1 ); | 360 | QString value = txt.mid( txt.find( ":" ) + 1 ); |
361 | if ( value.isEmpty() ) | 361 | if ( value.isEmpty() ) |
362 | return; | 362 | return; |
363 | cl.setValue( new TextValue( value.utf8() ) ); | 363 | cl.setValue( new TextValue( value.utf8() ) ); |
364 | v->add(cl); | 364 | v->add(cl); |
365 | } | 365 | } |
366 | 366 | ||
367 | void VCardFormatImpl::addTextValue( VCard *v, EntityType type, const QString &txt ) | 367 | void VCardFormatImpl::addTextValue( VCard *v, EntityType type, const QString &txt ) |
368 | { | 368 | { |
369 | if ( txt.isEmpty() ) return; | 369 | if ( txt.isEmpty() ) return; |
370 | 370 | ||
371 | ContentLine cl; | 371 | ContentLine cl; |
372 | cl.setName( EntityTypeToParamName( type ) ); | 372 | cl.setName( EntityTypeToParamName( type ) ); |
373 | cl.setValue( new TextValue( txt.utf8() ) ); | 373 | cl.setValue( new TextValue( txt.utf8() ) ); |
374 | v->add(cl); | 374 | v->add(cl); |
375 | } | 375 | } |
376 | 376 | ||
377 | void VCardFormatImpl::addDateValue( VCard *vcard, EntityType type, | 377 | void VCardFormatImpl::addDateValue( VCard *vcard, EntityType type, |
378 | const QDate &date ) | 378 | const QDate &date ) |
379 | { | 379 | { |
380 | if ( !date.isValid() ) return; | 380 | if ( !date.isValid() ) return; |
381 | 381 | ||
382 | ContentLine cl; | 382 | ContentLine cl; |
383 | cl.setName( EntityTypeToParamName( type ) ); | 383 | cl.setName( EntityTypeToParamName( type ) ); |
384 | 384 | ||
385 | DateValue *v = new DateValue( date ); | 385 | DateValue *v = new DateValue( date ); |
386 | cl.setValue( v ); | 386 | cl.setValue( v ); |
387 | vcard->add(cl); | 387 | vcard->add(cl); |
388 | } | 388 | } |
389 | 389 | ||
390 | void VCardFormatImpl::addDateTimeValue( VCard *vcard, EntityType type, | 390 | void VCardFormatImpl::addDateTimeValue( VCard *vcard, EntityType type, |
391 | const QDateTime &dateTime ) | 391 | const QDateTime &dateTime ) |
392 | { | 392 | { |
393 | if ( !dateTime.isValid() ) return; | 393 | if ( !dateTime.isValid() ) return; |
394 | 394 | ||
395 | ContentLine cl; | 395 | ContentLine cl; |
396 | cl.setName( EntityTypeToParamName( type ) ); | 396 | cl.setName( EntityTypeToParamName( type ) ); |
397 | 397 | ||
398 | DateValue *v = new DateValue( dateTime ); | 398 | DateValue *v = new DateValue( dateTime ); |
399 | cl.setValue( v ); | 399 | cl.setValue( v ); |
400 | vcard->add(cl); | 400 | vcard->add(cl); |
401 | } | 401 | } |
402 | 402 | ||
403 | void VCardFormatImpl::addAddressValue( VCard *vcard, const Address &a ) | 403 | void VCardFormatImpl::addAddressValue( VCard *vcard, const Address &a ) |
404 | { | 404 | { |
405 | if ( a.isEmpty() ) | 405 | if ( a.isEmpty() ) |
406 | return; | 406 | return; |
407 | 407 | ||
408 | ContentLine cl; | 408 | ContentLine cl; |
409 | cl.setName( EntityTypeToParamName( EntityAddress ) ); | 409 | cl.setName( EntityTypeToParamName( EntityAddress ) ); |
410 | 410 | ||
411 | AdrValue *v = new AdrValue; | 411 | AdrValue *v = new AdrValue; |
412 | v->setPOBox( a.postOfficeBox().utf8() ); | 412 | v->setPOBox( a.postOfficeBox().utf8() ); |
413 | v->setExtAddress( a.extended().utf8() ); | 413 | v->setExtAddress( a.extended().utf8() ); |
414 | v->setStreet( a.street().utf8() ); | 414 | v->setStreet( a.street().utf8() ); |
415 | v->setLocality( a.locality().utf8() ); | 415 | v->setLocality( a.locality().utf8() ); |
416 | v->setRegion( a.region().utf8() ); | 416 | v->setRegion( a.region().utf8() ); |
417 | v->setPostCode( a.postalCode().utf8() ); | 417 | v->setPostCode( a.postalCode().utf8() ); |
418 | v->setCountryName( a.country().utf8() ); | 418 | v->setCountryName( a.country().utf8() ); |
419 | cl.setValue( v ); | 419 | cl.setValue( v ); |
420 | 420 | ||
421 | addAddressParam( &cl, a.type() ); | 421 | addAddressParam( &cl, a.type() ); |
422 | 422 | ||
423 | vcard->add( cl ); | 423 | vcard->add( cl ); |
424 | } | 424 | } |
425 | 425 | ||
426 | void VCardFormatImpl::addLabelValue( VCard *vcard, const Address &a ) | 426 | void VCardFormatImpl::addLabelValue( VCard *vcard, const Address &a ) |
427 | { | 427 | { |
428 | if ( a.label().isEmpty() ) return; | 428 | if ( a.label().isEmpty() ) return; |
429 | 429 | ||
430 | ContentLine cl; | 430 | ContentLine cl; |
431 | cl.setName( EntityTypeToParamName( EntityLabel ) ); | 431 | cl.setName( EntityTypeToParamName( EntityLabel ) ); |
432 | cl.setValue( new TextValue( a.label().utf8() ) ); | 432 | cl.setValue( new TextValue( a.label().utf8() ) ); |
433 | 433 | ||
434 | addAddressParam( &cl, a.type() ); | 434 | addAddressParam( &cl, a.type() ); |
435 | 435 | ||
436 | vcard->add( cl ); | 436 | vcard->add( cl ); |
437 | } | 437 | } |
438 | 438 | ||
439 | void VCardFormatImpl::addAddressParam( ContentLine *cl, int type ) | 439 | void VCardFormatImpl::addAddressParam( ContentLine *cl, int type ) |
440 | { | 440 | { |
441 | ParamList params; | 441 | ParamList params; |
442 | if ( type & Address::Dom ) params.append( new Param( "TYPE", "dom" ) ); | 442 | if ( type & Address::Dom ) params.append( new Param( "TYPE", "dom" ) ); |
443 | if ( type & Address::Intl ) params.append( new Param( "TYPE", "intl" ) ); | 443 | if ( type & Address::Intl ) params.append( new Param( "TYPE", "intl" ) ); |
444 | if ( type & Address::Parcel ) params.append( new Param( "TYPE", "parcel" ) ); | 444 | if ( type & Address::Parcel ) params.append( new Param( "TYPE", "parcel" ) ); |
445 | if ( type & Address::Postal ) params.append( new Param( "TYPE", "postal" ) ); | 445 | if ( type & Address::Postal ) params.append( new Param( "TYPE", "postal" ) ); |
446 | if ( type & Address::Work ) params.append( new Param( "TYPE", "work" ) ); | 446 | if ( type & Address::Work ) params.append( new Param( "TYPE", "work" ) ); |
447 | if ( type & Address::Home ) params.append( new Param( "TYPE", "home" ) ); | 447 | if ( type & Address::Home ) params.append( new Param( "TYPE", "home" ) ); |
448 | if ( type & Address::Pref ) params.append( new Param( "TYPE", "pref" ) ); | 448 | if ( type & Address::Pref ) params.append( new Param( "TYPE", "pref" ) ); |
449 | cl->setParamList( params ); | 449 | cl->setParamList( params ); |
450 | } | 450 | } |
451 | 451 | ||
452 | void VCardFormatImpl::addGeoValue( VCard *vcard, const Geo &geo ) | 452 | void VCardFormatImpl::addGeoValue( VCard *vcard, const Geo &geo ) |
453 | { | 453 | { |
454 | if ( !geo.isValid() ) return; | 454 | if ( !geo.isValid() ) return; |
455 | 455 | ||
456 | ContentLine cl; | 456 | ContentLine cl; |
457 | cl.setName( EntityTypeToParamName( EntityGeo ) ); | 457 | cl.setName( EntityTypeToParamName( EntityGeo ) ); |
458 | 458 | ||
459 | GeoValue *v = new GeoValue; | 459 | GeoValue *v = new GeoValue; |
460 | v->setLatitude( geo.latitude() ); | 460 | v->setLatitude( geo.latitude() ); |
461 | v->setLongitude( geo.longitude() ); | 461 | v->setLongitude( geo.longitude() ); |
462 | 462 | ||
463 | cl.setValue( v ); | 463 | cl.setValue( v ); |
464 | vcard->add(cl); | 464 | vcard->add(cl); |
465 | } | 465 | } |
466 | 466 | ||
467 | void VCardFormatImpl::addUTCValue( VCard *vcard, const TimeZone &tz ) | 467 | void VCardFormatImpl::addUTCValue( VCard *vcard, const TimeZone &tz ) |
468 | { | 468 | { |
469 | if ( !tz.isValid() ) return; | 469 | if ( !tz.isValid() ) return; |
470 | 470 | ||
471 | ContentLine cl; | 471 | ContentLine cl; |
472 | cl.setName( EntityTypeToParamName( EntityTimeZone ) ); | 472 | cl.setName( EntityTypeToParamName( EntityTimeZone ) ); |
473 | 473 | ||
474 | UTCValue *v = new UTCValue; | 474 | UTCValue *v = new UTCValue; |
475 | 475 | ||
476 | v->setPositive( tz.offset() >= 0 ); | 476 | v->setPositive( tz.offset() >= 0 ); |
477 | v->setHour( (tz.offset() / 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); | 477 | v->setHour( (tz.offset() / 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); |
478 | v->setMinute( (tz.offset() % 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); | 478 | v->setMinute( (tz.offset() % 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); |
479 | 479 | ||
480 | cl.setValue( v ); | 480 | cl.setValue( v ); |
481 | vcard->add(cl); | 481 | vcard->add(cl); |
482 | } | 482 | } |
483 | 483 | ||
484 | void VCardFormatImpl::addClassValue( VCard *vcard, const Secrecy &secrecy ) | 484 | void VCardFormatImpl::addClassValue( VCard *vcard, const Secrecy &secrecy ) |
485 | { | 485 | { |
486 | ContentLine cl; | 486 | ContentLine cl; |
487 | cl.setName( EntityTypeToParamName( EntityClass ) ); | 487 | cl.setName( EntityTypeToParamName( EntityClass ) ); |
488 | 488 | ||
489 | ClassValue *v = new ClassValue; | 489 | ClassValue *v = new ClassValue; |
490 | switch ( secrecy.type() ) { | 490 | switch ( secrecy.type() ) { |
491 | case Secrecy::Public: | 491 | case Secrecy::Public: |
492 | v->setType( (int)ClassValue::Public ); | 492 | v->setType( (int)ClassValue::Public ); |
493 | break; | 493 | break; |
494 | case Secrecy::Private: | 494 | case Secrecy::Private: |
495 | v->setType( (int)ClassValue::Private ); | 495 | v->setType( (int)ClassValue::Private ); |
496 | break; | 496 | break; |
497 | case Secrecy::Confidential: | 497 | case Secrecy::Confidential: |
498 | v->setType( (int)ClassValue::Confidential ); | 498 | v->setType( (int)ClassValue::Confidential ); |
499 | break; | 499 | break; |
500 | } | 500 | } |
501 | 501 | ||
502 | cl.setValue( v ); | 502 | cl.setValue( v ); |
503 | vcard->add(cl); | 503 | vcard->add(cl); |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | Address VCardFormatImpl::readAddressValue( ContentLine *cl ) | 507 | Address VCardFormatImpl::readAddressValue( ContentLine *cl ) |
508 | { | 508 | { |
509 | Address a; | 509 | Address a; |
510 | AdrValue *v = (AdrValue *)cl->value(); | 510 | AdrValue *v = (AdrValue *)cl->value(); |
511 | a.setPostOfficeBox( QString::fromUtf8( v->poBox() ) ); | 511 | a.setPostOfficeBox( QString::fromUtf8( v->poBox() ) ); |
512 | a.setExtended( QString::fromUtf8( v->extAddress() ) ); | 512 | a.setExtended( QString::fromUtf8( v->extAddress() ) ); |
513 | a.setStreet( QString::fromUtf8( v->street() ) ); | 513 | a.setStreet( QString::fromUtf8( v->street() ) ); |
514 | a.setLocality( QString::fromUtf8( v->locality() ) ); | 514 | a.setLocality( QString::fromUtf8( v->locality() ) ); |
515 | a.setRegion( QString::fromUtf8( v->region() ) ); | 515 | a.setRegion( QString::fromUtf8( v->region() ) ); |
516 | a.setPostalCode( QString::fromUtf8( v->postCode() ) ); | 516 | a.setPostalCode( QString::fromUtf8( v->postCode() ) ); |
517 | a.setCountry( QString::fromUtf8( v->countryName() ) ); | 517 | a.setCountry( QString::fromUtf8( v->countryName() ) ); |
518 | 518 | ||
519 | a.setType( readAddressParam( cl ) ); | 519 | a.setType( readAddressParam( cl ) ); |
520 | 520 | ||
521 | return a; | 521 | return a; |
522 | } | 522 | } |
523 | 523 | ||
524 | int VCardFormatImpl::readAddressParam( ContentLine *cl ) | 524 | int VCardFormatImpl::readAddressParam( ContentLine *cl ) |
525 | { | 525 | { |
526 | int type = 0; | 526 | int type = 0; |
527 | ParamList params = cl->paramList(); | 527 | ParamList params = cl->paramList(); |
528 | ParamListIterator it( params ); | 528 | ParamListIterator it( params ); |
529 | QCString tmpStr; | 529 | QCString tmpStr; |
530 | for( ; it.current(); ++it ) { | 530 | for( ; it.current(); ++it ) { |
531 | if ( (*it)->name().upper() == "TYPE" ) { | 531 | if ( (*it)->name().upper() == "TYPE" ) { |
532 | tmpStr = (*it)->value().lower(); | 532 | tmpStr = (*it)->value().lower(); |
533 | if ( tmpStr == "dom" ) type |= Address::Dom; | 533 | if ( tmpStr == "dom" ) type |= Address::Dom; |
534 | else if ( tmpStr == "intl" ) type |= Address::Intl; | 534 | else if ( tmpStr == "intl" ) type |= Address::Intl; |
535 | else if ( tmpStr == "parcel" ) type |= Address::Parcel; | 535 | else if ( tmpStr == "parcel" ) type |= Address::Parcel; |
536 | else if ( tmpStr == "postal" ) type |= Address::Postal; | 536 | else if ( tmpStr == "postal" ) type |= Address::Postal; |
537 | else if ( tmpStr == "work" ) type |= Address::Work; | 537 | else if ( tmpStr == "work" ) type |= Address::Work; |
538 | else if ( tmpStr == "home" ) type |= Address::Home; | 538 | else if ( tmpStr == "home" ) type |= Address::Home; |
539 | else if ( tmpStr == "pref" ) type |= Address::Pref; | 539 | else if ( tmpStr == "pref" ) type |= Address::Pref; |
540 | } | 540 | } |
541 | } | 541 | } |
542 | return type; | 542 | return type; |
543 | } | 543 | } |
544 | 544 | ||
545 | void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a ) | 545 | void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a ) |
546 | { | 546 | { |
547 | ContentLine cl; | 547 | ContentLine cl; |
548 | cl.setName(EntityTypeToParamName( EntityN ) ); | 548 | cl.setName(EntityTypeToParamName( EntityN ) ); |
549 | NValue *v = new NValue; | 549 | NValue *v = new NValue; |
550 | v->setFamily( a.familyName().utf8() ); | 550 | v->setFamily( a.familyName().utf8() ); |
551 | v->setGiven( a.givenName().utf8() ); | 551 | v->setGiven( a.givenName().utf8() ); |
552 | v->setMiddle( a.additionalName().utf8() ); | 552 | v->setMiddle( a.additionalName().utf8() ); |
553 | v->setPrefix( a.prefix().utf8() ); | 553 | v->setPrefix( a.prefix().utf8() ); |
554 | v->setSuffix( a.suffix().utf8() ); | 554 | v->setSuffix( a.suffix().utf8() ); |
555 | 555 | ||
556 | cl.setValue( v ); | 556 | cl.setValue( v ); |
557 | vcard->add(cl); | 557 | vcard->add(cl); |
558 | } | 558 | } |
559 | 559 | ||
560 | void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a ) | 560 | void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a ) |
561 | { | 561 | { |
562 | NValue *v = (NValue *)cl->value(); | 562 | NValue *v = (NValue *)cl->value(); |
563 | a.setFamilyName( QString::fromUtf8( v->family() ) ); | 563 | a.setFamilyName( QString::fromUtf8( v->family() ) ); |
564 | a.setGivenName( QString::fromUtf8( v->given() ) ); | 564 | a.setGivenName( QString::fromUtf8( v->given() ) ); |
565 | a.setAdditionalName( QString::fromUtf8( v->middle() ) ); | 565 | a.setAdditionalName( QString::fromUtf8( v->middle() ) ); |
566 | a.setPrefix( QString::fromUtf8( v->prefix() ) ); | 566 | a.setPrefix( QString::fromUtf8( v->prefix() ) ); |
567 | a.setSuffix( QString::fromUtf8( v->suffix() ) ); | 567 | a.setSuffix( QString::fromUtf8( v->suffix() ) ); |
568 | } | 568 | } |
569 | 569 | ||
570 | void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p ) | 570 | void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p ) |
571 | { | 571 | { |
572 | if ( p.number().isEmpty() ) | 572 | if ( p.number().isEmpty() ) |
573 | return; | 573 | return; |
574 | 574 | ||
575 | ContentLine cl; | 575 | ContentLine cl; |
576 | cl.setName(EntityTypeToParamName(EntityTelephone)); | 576 | cl.setName(EntityTypeToParamName(EntityTelephone)); |
577 | cl.setValue(new TelValue( p.number().utf8() )); | 577 | cl.setValue(new TelValue( p.number().utf8() )); |
578 | 578 | ||
579 | ParamList params; | 579 | ParamList params; |
580 | if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) ); | 580 | if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) ); |
581 | if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) ); | 581 | if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) ); |
582 | if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) ); | 582 | if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) ); |
583 | if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) ); | 583 | if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) ); |
584 | if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) ); | 584 | if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) ); |
585 | if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) ); | 585 | if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) ); |
586 | if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) ); | 586 | if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) ); |
587 | if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) ); | 587 | if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) ); |
588 | if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) ); | 588 | if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) ); |
589 | if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) ); | 589 | if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) ); |
590 | if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) ); | 590 | if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) ); |
591 | if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) ); | 591 | if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) ); |
592 | if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) ); | 592 | if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) ); |
593 | if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) ); | 593 | if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) ); |
594 | if( p.type() & PhoneNumber::Sip ) params.append( new Param( "TYPE", "sip" ) ); | ||
594 | cl.setParamList( params ); | 595 | cl.setParamList( params ); |
595 | 596 | ||
596 | v->add(cl); | 597 | v->add(cl); |
597 | } | 598 | } |
598 | 599 | ||
599 | PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) | 600 | PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) |
600 | { | 601 | { |
601 | PhoneNumber p; | 602 | PhoneNumber p; |
602 | TelValue *value = (TelValue *)cl->value(); | 603 | TelValue *value = (TelValue *)cl->value(); |
603 | p.setNumber( QString::fromUtf8( value->asString() ) ); | 604 | p.setNumber( QString::fromUtf8( value->asString() ) ); |
604 | 605 | ||
605 | int type = 0; | 606 | int type = 0; |
606 | ParamList params = cl->paramList(); | 607 | ParamList params = cl->paramList(); |
607 | ParamListIterator it( params ); | 608 | ParamListIterator it( params ); |
608 | QCString tmpStr; | 609 | QCString tmpStr; |
609 | for( ; it.current(); ++it ) { | 610 | for( ; it.current(); ++it ) { |
610 | if ( (*it)->name() == "TYPE" ) { | 611 | if ( (*it)->name() == "TYPE" ) { |
611 | tmpStr = (*it)->value().lower(); | 612 | tmpStr = (*it)->value().lower(); |
612 | if ( tmpStr == "home" ) type |= PhoneNumber::Home; | 613 | if ( tmpStr == "home" ) type |= PhoneNumber::Home; |
613 | else if ( tmpStr == "work" ) type |= PhoneNumber::Work; | 614 | else if ( tmpStr == "work" ) type |= PhoneNumber::Work; |
614 | else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg; | 615 | else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg; |
615 | else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref; | 616 | else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref; |
616 | else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice; | 617 | else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice; |
617 | else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax; | 618 | else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax; |
618 | else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell; | 619 | else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell; |
619 | else if ( tmpStr == "video" ) type |= PhoneNumber::Video; | 620 | else if ( tmpStr == "video" ) type |= PhoneNumber::Video; |
620 | else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs; | 621 | else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs; |
621 | else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem; | 622 | else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem; |
622 | else if ( tmpStr == "car" ) type |= PhoneNumber::Car; | 623 | else if ( tmpStr == "car" ) type |= PhoneNumber::Car; |
623 | else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn; | 624 | else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn; |
624 | else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs; | 625 | else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs; |
625 | else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager; | 626 | else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager; |
627 | else if ( tmpStr == "sip" ) type |= PhoneNumber::Sip; | ||
626 | } | 628 | } |
627 | } | 629 | } |
628 | p.setType( type ); | 630 | p.setType( type ); |
629 | 631 | ||
630 | return p; | 632 | return p; |
631 | } | 633 | } |
632 | 634 | ||
633 | QString VCardFormatImpl::readTextValue( ContentLine *cl ) | 635 | QString VCardFormatImpl::readTextValue( ContentLine *cl ) |
634 | { | 636 | { |
635 | VCARD::Value *value = cl->value(); | 637 | VCARD::Value *value = cl->value(); |
636 | if ( value ) { | 638 | if ( value ) { |
637 | return QString::fromUtf8( value->asString() ); | 639 | return QString::fromUtf8( value->asString() ); |
638 | } else { | 640 | } else { |
639 | kdDebug(5700) << "No value: " << cl->asString() << endl; | 641 | kdDebug(5700) << "No value: " << cl->asString() << endl; |
640 | return QString::null; | 642 | return QString::null; |
641 | } | 643 | } |
642 | } | 644 | } |
643 | 645 | ||
644 | QDate VCardFormatImpl::readDateValue( ContentLine *cl ) | 646 | QDate VCardFormatImpl::readDateValue( ContentLine *cl ) |
645 | { | 647 | { |
646 | DateValue *dateValue = (DateValue *)cl->value(); | 648 | DateValue *dateValue = (DateValue *)cl->value(); |
647 | if ( dateValue ) | 649 | if ( dateValue ) |
648 | return dateValue->qdate(); | 650 | return dateValue->qdate(); |
649 | else | 651 | else |
650 | return QDate(); | 652 | return QDate(); |
651 | } | 653 | } |
652 | 654 | ||
653 | QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl ) | 655 | QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl ) |
654 | { | 656 | { |
655 | DateValue *dateValue = (DateValue *)cl->value(); | 657 | DateValue *dateValue = (DateValue *)cl->value(); |
656 | if ( dateValue ) | 658 | if ( dateValue ) |
657 | return dateValue->qdt(); | 659 | return dateValue->qdt(); |
658 | else | 660 | else |
659 | return QDateTime(); | 661 | return QDateTime(); |
660 | } | 662 | } |
661 | 663 | ||
662 | Geo VCardFormatImpl::readGeoValue( ContentLine *cl ) | 664 | Geo VCardFormatImpl::readGeoValue( ContentLine *cl ) |
663 | { | 665 | { |
664 | GeoValue *geoValue = (GeoValue *)cl->value(); | 666 | GeoValue *geoValue = (GeoValue *)cl->value(); |
665 | if ( geoValue ) { | 667 | if ( geoValue ) { |
666 | Geo geo( geoValue->latitude(), geoValue->longitude() ); | 668 | Geo geo( geoValue->latitude(), geoValue->longitude() ); |
667 | return geo; | 669 | return geo; |
668 | } else | 670 | } else |
669 | return Geo(); | 671 | return Geo(); |
670 | } | 672 | } |
671 | 673 | ||
672 | TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl ) | 674 | TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl ) |
673 | { | 675 | { |
674 | UTCValue *utcValue = (UTCValue *)cl->value(); | 676 | UTCValue *utcValue = (UTCValue *)cl->value(); |
675 | if ( utcValue ) { | 677 | if ( utcValue ) { |
676 | TimeZone tz; | 678 | TimeZone tz; |
677 | tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1)); | 679 | tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1)); |
678 | return tz; | 680 | return tz; |
679 | } else | 681 | } else |
680 | return TimeZone(); | 682 | return TimeZone(); |
681 | } | 683 | } |
682 | 684 | ||
683 | Secrecy VCardFormatImpl::readClassValue( ContentLine *cl ) | 685 | Secrecy VCardFormatImpl::readClassValue( ContentLine *cl ) |
684 | { | 686 | { |
685 | ClassValue *classValue = (ClassValue *)cl->value(); | 687 | ClassValue *classValue = (ClassValue *)cl->value(); |
686 | if ( classValue ) { | 688 | if ( classValue ) { |
687 | Secrecy secrecy; | 689 | Secrecy secrecy; |
688 | switch ( classValue->type() ) { | 690 | switch ( classValue->type() ) { |
689 | case ClassValue::Public: | 691 | case ClassValue::Public: |
690 | secrecy.setType( Secrecy::Public ); | 692 | secrecy.setType( Secrecy::Public ); |
691 | break; | 693 | break; |
692 | case ClassValue::Private: | 694 | case ClassValue::Private: |
693 | secrecy.setType( Secrecy::Private ); | 695 | secrecy.setType( Secrecy::Private ); |
694 | break; | 696 | break; |
695 | case ClassValue::Confidential: | 697 | case ClassValue::Confidential: |
696 | secrecy.setType( Secrecy::Confidential ); | 698 | secrecy.setType( Secrecy::Confidential ); |
697 | break; | 699 | break; |
698 | } | 700 | } |
699 | 701 | ||
700 | return secrecy; | 702 | return secrecy; |
701 | } else | 703 | } else |
702 | return Secrecy(); | 704 | return Secrecy(); |
703 | } | 705 | } |
704 | 706 | ||
705 | void VCardFormatImpl::addKeyValue( VCARD::VCard *vcard, const Key &key ) | 707 | void VCardFormatImpl::addKeyValue( VCARD::VCard *vcard, const Key &key ) |
706 | { | 708 | { |
707 | ContentLine cl; | 709 | ContentLine cl; |
708 | cl.setName( EntityTypeToParamName( EntityKey ) ); | 710 | cl.setName( EntityTypeToParamName( EntityKey ) ); |
709 | 711 | ||
710 | ParamList params; | 712 | ParamList params; |
711 | if ( key.isBinary() ) { | 713 | if ( key.isBinary() ) { |
712 | cl.setValue( new TextValue( KCodecs::base64Encode( key.binaryData() ) ) ); | 714 | cl.setValue( new TextValue( KCodecs::base64Encode( key.binaryData() ) ) ); |
713 | params.append( new Param( "ENCODING", "b" ) ); | 715 | params.append( new Param( "ENCODING", "b" ) ); |
714 | } else { | 716 | } else { |
715 | cl.setValue( new TextValue( key.textData().utf8() ) ); | 717 | cl.setValue( new TextValue( key.textData().utf8() ) ); |
716 | } | 718 | } |
717 | 719 | ||
718 | switch ( key.type() ) { | 720 | switch ( key.type() ) { |
719 | case Key::X509: | 721 | case Key::X509: |
720 | params.append( new Param( "TYPE", "X509" ) ); | 722 | params.append( new Param( "TYPE", "X509" ) ); |
721 | break; | 723 | break; |
722 | case Key::PGP: | 724 | case Key::PGP: |
723 | params.append( new Param( "TYPE", "PGP" ) ); | 725 | params.append( new Param( "TYPE", "PGP" ) ); |
724 | break; | 726 | break; |
725 | case Key::Custom: | 727 | case Key::Custom: |
726 | params.append( new Param( "TYPE", key.customTypeString().utf8() ) ); | 728 | params.append( new Param( "TYPE", key.customTypeString().utf8() ) ); |
727 | break; | 729 | break; |
728 | } | 730 | } |
729 | 731 | ||
730 | cl.setParamList( params ); | 732 | cl.setParamList( params ); |
731 | vcard->add( cl ); | 733 | vcard->add( cl ); |
732 | } | 734 | } |
733 | 735 | ||
734 | Key VCardFormatImpl::readKeyValue( VCARD::ContentLine *cl ) | 736 | Key VCardFormatImpl::readKeyValue( VCARD::ContentLine *cl ) |
735 | { | 737 | { |
736 | Key key; | 738 | Key key; |
737 | bool isBinary = false; | 739 | bool isBinary = false; |
738 | TextValue *v = (TextValue *)cl->value(); | 740 | TextValue *v = (TextValue *)cl->value(); |
739 | 741 | ||
740 | ParamList params = cl->paramList(); | 742 | ParamList params = cl->paramList(); |
741 | ParamListIterator it( params ); | 743 | ParamListIterator it( params ); |
742 | for( ; it.current(); ++it ) { | 744 | for( ; it.current(); ++it ) { |
743 | if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) | 745 | if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) |
744 | isBinary = true; | 746 | isBinary = true; |
745 | if ( (*it)->name() == "TYPE" ) { | 747 | if ( (*it)->name() == "TYPE" ) { |
746 | if ( (*it)->value().isEmpty() ) | 748 | if ( (*it)->value().isEmpty() ) |
747 | continue; | 749 | continue; |
748 | if ( (*it)->value() == "X509" ) | 750 | if ( (*it)->value() == "X509" ) |
749 | key.setType( Key::X509 ); | 751 | key.setType( Key::X509 ); |
750 | else if ( (*it)->value() == "PGP" ) | 752 | else if ( (*it)->value() == "PGP" ) |
751 | key.setType( Key::PGP ); | 753 | key.setType( Key::PGP ); |
752 | else { | 754 | else { |
753 | key.setType( Key::Custom ); | 755 | key.setType( Key::Custom ); |
754 | key.setCustomTypeString( QString::fromUtf8( (*it)->value() ) ); | 756 | key.setCustomTypeString( QString::fromUtf8( (*it)->value() ) ); |
755 | } | 757 | } |
756 | } | 758 | } |
757 | } | 759 | } |
758 | 760 | ||
759 | 761 | ||
760 | if ( isBinary ) { | 762 | if ( isBinary ) { |
761 | QByteArray data; | 763 | QByteArray data; |
762 | KCodecs::base64Decode( v->asString().stripWhiteSpace(), data ); | 764 | KCodecs::base64Decode( v->asString().stripWhiteSpace(), data ); |
763 | key.setBinaryData( data ); | 765 | key.setBinaryData( data ); |
764 | } else { | 766 | } else { |
765 | key.setTextData( QString::fromUtf8( v->asString() ) ); | 767 | key.setTextData( QString::fromUtf8( v->asString() ) ); |
766 | } | 768 | } |
767 | 769 | ||
768 | return key; | 770 | return key; |
769 | } | 771 | } |
770 | 772 | ||
771 | 773 | ||
772 | void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent ) | 774 | void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent ) |
773 | { | 775 | { |
774 | if ( agent.isIntern() && !agent.addressee() ) | 776 | if ( agent.isIntern() && !agent.addressee() ) |
775 | return; | 777 | return; |
776 | 778 | ||
777 | if ( !agent.isIntern() && agent.url().isEmpty() ) | 779 | if ( !agent.isIntern() && agent.url().isEmpty() ) |
778 | return; | 780 | return; |
779 | 781 | ||
780 | ContentLine cl; | 782 | ContentLine cl; |
781 | cl.setName( EntityTypeToParamName( EntityAgent ) ); | 783 | cl.setName( EntityTypeToParamName( EntityAgent ) ); |
782 | 784 | ||
783 | ParamList params; | 785 | ParamList params; |
784 | if ( agent.isIntern() ) { | 786 | if ( agent.isIntern() ) { |
785 | QString vstr; | 787 | QString vstr; |
786 | Addressee *addr = agent.addressee(); | 788 | Addressee *addr = agent.addressee(); |
787 | if ( addr ) { | 789 | if ( addr ) { |
788 | writeToString( (*addr), vstr ); | 790 | writeToString( (*addr), vstr ); |
789 | 791 | ||
790 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); | 792 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); |
791 | /*US | 793 | /*US |
792 | vstr.replace( ":", "\\:" ); | 794 | vstr.replace( ":", "\\:" ); |
793 | vstr.replace( ",", "\\," ); | 795 | vstr.replace( ",", "\\," ); |
794 | vstr.replace( ";", "\\;" ); | 796 | vstr.replace( ";", "\\;" ); |
795 | vstr.replace( "\r\n", "\\n" ); | 797 | vstr.replace( "\r\n", "\\n" ); |
796 | */ | 798 | */ |
797 | vstr.replace( QRegExp(":"), "\\:" ); | 799 | vstr.replace( QRegExp(":"), "\\:" ); |
798 | vstr.replace( QRegExp(","), "\\," ); | 800 | vstr.replace( QRegExp(","), "\\," ); |
799 | vstr.replace( QRegExp(";"), "\\;" ); | 801 | vstr.replace( QRegExp(";"), "\\;" ); |
800 | vstr.replace( QRegExp("\r\n"), "\\n" ); | 802 | vstr.replace( QRegExp("\r\n"), "\\n" ); |
801 | 803 | ||
802 | cl.setValue( new TextValue( vstr.utf8() ) ); | 804 | cl.setValue( new TextValue( vstr.utf8() ) ); |
803 | } else | 805 | } else |
804 | return; | 806 | return; |
805 | } else { | 807 | } else { |
806 | cl.setValue( new TextValue( agent.url().utf8() ) ); | 808 | cl.setValue( new TextValue( agent.url().utf8() ) ); |
807 | params.append( new Param( "VALUE", "uri" ) ); | 809 | params.append( new Param( "VALUE", "uri" ) ); |
808 | } | 810 | } |
809 | 811 | ||
810 | cl.setParamList( params ); | 812 | cl.setParamList( params ); |
811 | vcard->add( cl ); | 813 | vcard->add( cl ); |
812 | } | 814 | } |
813 | 815 | ||
814 | Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl ) | 816 | Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl ) |
815 | { | 817 | { |
816 | Agent agent; | 818 | Agent agent; |
817 | bool isIntern = true; | 819 | bool isIntern = true; |
818 | TextValue *v = (TextValue *)cl->value(); | 820 | TextValue *v = (TextValue *)cl->value(); |
819 | 821 | ||
820 | ParamList params = cl->paramList(); | 822 | ParamList params = cl->paramList(); |
821 | ParamListIterator it( params ); | 823 | ParamListIterator it( params ); |
822 | for( ; it.current(); ++it ) { | 824 | for( ; it.current(); ++it ) { |
823 | if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" ) | 825 | if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" ) |
824 | isIntern = false; | 826 | isIntern = false; |
825 | } | 827 | } |
826 | 828 | ||
827 | if ( isIntern ) { | 829 | if ( isIntern ) { |
828 | QString vstr = QString::fromUtf8( v->asString() ); | 830 | QString vstr = QString::fromUtf8( v->asString() ); |
829 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); | 831 | qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); |
830 | /*US | 832 | /*US |
831 | vstr.replace( "\\n", "\r\n" ); | 833 | vstr.replace( "\\n", "\r\n" ); |
832 | vstr.replace( "\\:", ":" ); | 834 | vstr.replace( "\\:", ":" ); |
833 | vstr.replace( "\\,", "," ); | 835 | vstr.replace( "\\,", "," ); |
834 | vstr.replace( "\\;", ";" ); | 836 | vstr.replace( "\\;", ";" ); |
835 | */ | 837 | */ |
836 | vstr.replace( QRegExp("\\n"), "\r\n" ); | 838 | vstr.replace( QRegExp("\\n"), "\r\n" ); |
837 | vstr.replace( QRegExp("\\:"), ":" ); | 839 | vstr.replace( QRegExp("\\:"), ":" ); |
838 | vstr.replace( QRegExp("\\,"), "," ); | 840 | vstr.replace( QRegExp("\\,"), "," ); |
839 | vstr.replace( QRegExp("\\;"), ";" ); | 841 | vstr.replace( QRegExp("\\;"), ";" ); |
840 | 842 | ||
841 | Addressee *addr = new Addressee; | 843 | Addressee *addr = new Addressee; |
842 | readFromString( vstr, *addr ); | 844 | readFromString( vstr, *addr ); |
843 | agent.setAddressee( addr ); | 845 | agent.setAddressee( addr ); |
844 | } else { | 846 | } else { |
845 | agent.setUrl( QString::fromUtf8( v->asString() ) ); | 847 | agent.setUrl( QString::fromUtf8( v->asString() ) ); |
846 | } | 848 | } |
847 | 849 | ||
848 | return agent; | 850 | return agent; |
849 | } | 851 | } |
850 | 852 | ||
851 | void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern ) | 853 | void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern ) |
852 | { | 854 | { |
853 | ContentLine cl; | 855 | ContentLine cl; |
854 | cl.setName( EntityTypeToParamName( type ) ); | 856 | cl.setName( EntityTypeToParamName( type ) ); |
855 | 857 | ||
856 | if ( pic.isIntern() && pic.data().isNull() ) | 858 | if ( pic.isIntern() && pic.data().isNull() ) |
857 | return; | 859 | return; |
858 | 860 | ||
859 | if ( !pic.isIntern() && pic.url().isEmpty() ) | 861 | if ( !pic.isIntern() && pic.url().isEmpty() ) |
860 | return; | 862 | return; |
861 | 863 | ||
862 | ParamList params; | 864 | ParamList params; |
863 | if ( pic.isIntern() ) { | 865 | if ( pic.isIntern() ) { |
864 | QImage img = pic.data(); | 866 | QImage img = pic.data(); |
865 | if ( intern ) { // only for vCard export we really write the data inline | 867 | if ( intern ) { // only for vCard export we really write the data inline |
866 | QByteArray data; | 868 | QByteArray data; |
867 | QDataStream s( data, IO_WriteOnly ); | 869 | QDataStream s( data, IO_WriteOnly ); |
868 | s.setVersion( 4 ); // to produce valid png files | 870 | s.setVersion( 4 ); // to produce valid png files |
869 | s << img; | 871 | s << img; |
870 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); | 872 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); |
871 | 873 | ||
872 | } else { // save picture in cache | 874 | } else { // save picture in cache |
873 | QString dir; | 875 | QString dir; |
874 | if ( type == EntityPhoto ) | 876 | if ( type == EntityPhoto ) |
875 | dir = "photos"; | 877 | dir = "photos"; |
876 | if ( type == EntityLogo ) | 878 | if ( type == EntityLogo ) |
877 | dir = "logos"; | 879 | dir = "logos"; |
878 | 880 | ||
879 | img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() ); | 881 | img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() ); |
880 | cl.setValue( new TextValue( "<dummy>" ) ); | 882 | cl.setValue( new TextValue( "<dummy>" ) ); |
881 | } | 883 | } |
882 | params.append( new Param( "ENCODING", "b" ) ); | 884 | params.append( new Param( "ENCODING", "b" ) ); |
883 | if ( !pic.type().isEmpty() ) | 885 | if ( !pic.type().isEmpty() ) |
884 | params.append( new Param( "TYPE", pic.type().utf8() ) ); | 886 | params.append( new Param( "TYPE", pic.type().utf8() ) ); |
885 | } else { | 887 | } else { |
886 | 888 | ||
887 | cl.setValue( new TextValue( pic.url().utf8() ) ); | 889 | cl.setValue( new TextValue( pic.url().utf8() ) ); |
888 | params.append( new Param( "VALUE", "uri" ) ); | 890 | params.append( new Param( "VALUE", "uri" ) ); |
889 | } | 891 | } |
890 | 892 | ||
891 | cl.setParamList( params ); | 893 | cl.setParamList( params ); |
892 | vcard->add( cl ); | 894 | vcard->add( cl ); |
893 | } | 895 | } |
894 | 896 | ||
895 | Picture VCardFormatImpl::readPictureValue( VCARD::ContentLine *cl, VCARD::EntityType type, const Addressee &addr ) | 897 | Picture VCardFormatImpl::readPictureValue( VCARD::ContentLine *cl, VCARD::EntityType type, const Addressee &addr ) |
896 | { | 898 | { |
897 | Picture pic; | 899 | Picture pic; |
898 | bool isInline = false; | 900 | bool isInline = false; |
899 | QString picType; | 901 | QString picType; |
900 | TextValue *v = (TextValue *)cl->value(); | 902 | TextValue *v = (TextValue *)cl->value(); |
901 | 903 | ||
902 | ParamList params = cl->paramList(); | 904 | ParamList params = cl->paramList(); |
903 | ParamListIterator it( params ); | 905 | ParamListIterator it( params ); |
904 | for( ; it.current(); ++it ) { | 906 | for( ; it.current(); ++it ) { |
905 | if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) | 907 | if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) |
906 | isInline = true; | 908 | isInline = true; |
907 | if ( (*it)->name() == "TYPE" && !(*it)->value().isEmpty() ) | 909 | if ( (*it)->name() == "TYPE" && !(*it)->value().isEmpty() ) |
908 | picType = QString::fromUtf8( (*it)->value() ); | 910 | picType = QString::fromUtf8( (*it)->value() ); |
909 | } | 911 | } |
910 | 912 | ||
911 | if ( isInline ) { | 913 | if ( isInline ) { |
912 | QImage img; | 914 | QImage img; |
913 | if ( v->asString() == "<dummy>" ) { // no picture inline stored => picture is in cache | 915 | if ( v->asString() == "<dummy>" ) { // no picture inline stored => picture is in cache |
914 | QString dir; | 916 | QString dir; |
915 | if ( type == EntityPhoto ) | 917 | if ( type == EntityPhoto ) |
916 | dir = "photos"; | 918 | dir = "photos"; |
917 | if ( type == EntityLogo ) | 919 | if ( type == EntityLogo ) |
918 | dir = "logos"; | 920 | dir = "logos"; |
919 | 921 | ||
920 | img.load( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ) ); | 922 | img.load( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ) ); |
921 | } else { | 923 | } else { |
922 | QByteArray data; | 924 | QByteArray data; |
923 | KCodecs::base64Decode( v->asString(), data ); | 925 | KCodecs::base64Decode( v->asString(), data ); |
924 | img.loadFromData( data ); | 926 | img.loadFromData( data ); |
925 | } | 927 | } |
926 | pic.setData( img ); | 928 | pic.setData( img ); |
927 | pic.setType( picType ); | 929 | pic.setType( picType ); |
928 | } else { | 930 | } else { |
929 | pic.setUrl( QString::fromUtf8( v->asString() ) ); | 931 | pic.setUrl( QString::fromUtf8( v->asString() ) ); |
930 | } | 932 | } |
931 | 933 | ||
932 | return pic; | 934 | return pic; |
933 | } | 935 | } |
934 | 936 | ||
935 | void VCardFormatImpl::addSoundValue( VCARD::VCard *vcard, const Sound &sound, const Addressee &addr, bool intern ) | 937 | void VCardFormatImpl::addSoundValue( VCARD::VCard *vcard, const Sound &sound, const Addressee &addr, bool intern ) |
936 | { | 938 | { |
937 | ContentLine cl; | 939 | ContentLine cl; |
938 | cl.setName( EntityTypeToParamName( EntitySound ) ); | 940 | cl.setName( EntityTypeToParamName( EntitySound ) ); |
939 | 941 | ||
940 | if ( sound.isIntern() && sound.data().isNull() ) | 942 | if ( sound.isIntern() && sound.data().isNull() ) |
941 | return; | 943 | return; |
942 | 944 | ||
943 | if ( !sound.isIntern() && sound.url().isEmpty() ) | 945 | if ( !sound.isIntern() && sound.url().isEmpty() ) |
944 | return; | 946 | return; |
945 | 947 | ||
946 | ParamList params; | 948 | ParamList params; |
947 | if ( sound.isIntern() ) { | 949 | if ( sound.isIntern() ) { |
948 | QByteArray data = sound.data(); | 950 | QByteArray data = sound.data(); |
949 | if ( intern ) { // only for vCard export we really write the data inline | 951 | if ( intern ) { // only for vCard export we really write the data inline |
950 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); | 952 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); |
951 | } else { // save sound in cache | 953 | } else { // save sound in cache |
952 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); | 954 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); |
953 | if ( file.open( IO_WriteOnly ) ) { | 955 | if ( file.open( IO_WriteOnly ) ) { |
954 | file.writeBlock( data ); | 956 | file.writeBlock( data ); |
955 | } | 957 | } |
956 | cl.setValue( new TextValue( "<dummy>" ) ); | 958 | cl.setValue( new TextValue( "<dummy>" ) ); |
957 | } | 959 | } |
958 | params.append( new Param( "ENCODING", "b" ) ); | 960 | params.append( new Param( "ENCODING", "b" ) ); |
959 | } else { | 961 | } else { |
960 | cl.setValue( new TextValue( sound.url().utf8() ) ); | 962 | cl.setValue( new TextValue( sound.url().utf8() ) ); |
961 | params.append( new Param( "VALUE", "uri" ) ); | 963 | params.append( new Param( "VALUE", "uri" ) ); |
962 | } | 964 | } |
963 | 965 | ||
964 | cl.setParamList( params ); | 966 | cl.setParamList( params ); |
965 | vcard->add( cl ); | 967 | vcard->add( cl ); |
966 | } | 968 | } |
967 | 969 | ||
968 | Sound VCardFormatImpl::readSoundValue( VCARD::ContentLine *cl, const Addressee &addr ) | 970 | Sound VCardFormatImpl::readSoundValue( VCARD::ContentLine *cl, const Addressee &addr ) |
969 | { | 971 | { |
970 | Sound sound; | 972 | Sound sound; |
971 | bool isInline = false; | 973 | bool isInline = false; |
972 | TextValue *v = (TextValue *)cl->value(); | 974 | TextValue *v = (TextValue *)cl->value(); |
973 | 975 | ||
974 | ParamList params = cl->paramList(); | 976 | ParamList params = cl->paramList(); |
975 | ParamListIterator it( params ); | 977 | ParamListIterator it( params ); |
976 | for( ; it.current(); ++it ) { | 978 | for( ; it.current(); ++it ) { |
977 | if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) | 979 | if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) |
978 | isInline = true; | 980 | isInline = true; |
979 | } | 981 | } |
980 | 982 | ||
981 | if ( isInline ) { | 983 | if ( isInline ) { |
982 | QByteArray data; | 984 | QByteArray data; |
983 | if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache | 985 | if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache |
984 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); | 986 | QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); |
985 | if ( file.open( IO_ReadOnly ) ) { | 987 | if ( file.open( IO_ReadOnly ) ) { |
986 | data = file.readAll(); | 988 | data = file.readAll(); |
987 | file.close(); | 989 | file.close(); |
988 | } | 990 | } |
989 | } else { | 991 | } else { |
990 | KCodecs::base64Decode( v->asString(), data ); | 992 | KCodecs::base64Decode( v->asString(), data ); |
991 | } | 993 | } |
992 | sound.setData( data ); | 994 | sound.setData( data ); |
993 | } else { | 995 | } else { |
994 | sound.setUrl( QString::fromUtf8( v->asString() ) ); | 996 | sound.setUrl( QString::fromUtf8( v->asString() ) ); |
995 | } | 997 | } |
996 | 998 | ||
997 | return sound; | 999 | return sound; |
998 | } | 1000 | } |
999 | 1001 | ||
1000 | bool VCardFormatImpl::readFromString( const QString &vcard, Addressee &addressee ) | 1002 | bool VCardFormatImpl::readFromString( const QString &vcard, Addressee &addressee ) |
1001 | { | 1003 | { |
1002 | VCardEntity e( vcard.utf8() ); | 1004 | VCardEntity e( vcard.utf8() ); |
1003 | VCardListIterator it( e.cardList() ); | 1005 | VCardListIterator it( e.cardList() ); |
1004 | 1006 | ||
1005 | if ( it.current() ) { | 1007 | if ( it.current() ) { |
1006 | //US VCard v(*it.current()); | 1008 | //US VCard v(*it.current()); |
1007 | //US loadAddressee( addressee, v ); | 1009 | //US loadAddressee( addressee, v ); |
1008 | loadAddressee( addressee, it.current() ); | 1010 | loadAddressee( addressee, it.current() ); |
1009 | return true; | 1011 | return true; |
1010 | } | 1012 | } |
1011 | 1013 | ||
1012 | return false; | 1014 | return false; |
1013 | } | 1015 | } |
1014 | 1016 | ||
1015 | bool VCardFormatImpl::writeToString( const Addressee &addressee, QString &vcard ) | 1017 | bool VCardFormatImpl::writeToString( const Addressee &addressee, QString &vcard ) |
1016 | { | 1018 | { |
1017 | VCardEntity vcards; | 1019 | VCardEntity vcards; |
1018 | VCardList vcardlist; | 1020 | VCardList vcardlist; |
1019 | vcardlist.setAutoDelete( true ); | 1021 | vcardlist.setAutoDelete( true ); |
1020 | 1022 | ||
1021 | VCard *v = new VCard; | 1023 | VCard *v = new VCard; |
1022 | 1024 | ||
1023 | saveAddressee( addressee, v, true ); | 1025 | saveAddressee( addressee, v, true ); |
1024 | 1026 | ||
1025 | vcardlist.append( v ); | 1027 | vcardlist.append( v ); |
1026 | vcards.setCardList( vcardlist ); | 1028 | vcards.setCardList( vcardlist ); |
1027 | vcard = QString::fromUtf8( vcards.asString() ); | 1029 | vcard = QString::fromUtf8( vcards.asString() ); |
1028 | 1030 | ||
1029 | return true; | 1031 | return true; |
1030 | } | 1032 | } |
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp index 71f29d7..3fb212e 100644 --- a/kabc/vcardparser/vcardtool.cpp +++ b/kabc/vcardparser/vcardtool.cpp | |||
@@ -1,897 +1,898 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qdatastream.h> | 21 | #include <qdatastream.h> |
22 | #include <qstring.h> | 22 | #include <qstring.h> |
23 | #include <qregexp.h> | 23 | #include <qregexp.h> |
24 | #include <kmdcodec.h> | 24 | #include <kmdcodec.h> |
25 | 25 | ||
26 | #include "agent.h" | 26 | #include "agent.h" |
27 | #include "key.h" | 27 | #include "key.h" |
28 | #include "picture.h" | 28 | #include "picture.h" |
29 | #include "secrecy.h" | 29 | #include "secrecy.h" |
30 | #include "sound.h" | 30 | #include "sound.h" |
31 | 31 | ||
32 | #include "vcardtool.h" | 32 | #include "vcardtool.h" |
33 | 33 | ||
34 | using namespace KABC; | 34 | using namespace KABC; |
35 | 35 | ||
36 | VCardTool::VCardTool() | 36 | VCardTool::VCardTool() |
37 | { | 37 | { |
38 | mAddressTypeMap.insert( "dom", Address::Dom ); | 38 | mAddressTypeMap.insert( "dom", Address::Dom ); |
39 | mAddressTypeMap.insert( "intl", Address::Intl ); | 39 | mAddressTypeMap.insert( "intl", Address::Intl ); |
40 | mAddressTypeMap.insert( "postal", Address::Postal ); | 40 | mAddressTypeMap.insert( "postal", Address::Postal ); |
41 | mAddressTypeMap.insert( "parcel", Address::Parcel ); | 41 | mAddressTypeMap.insert( "parcel", Address::Parcel ); |
42 | mAddressTypeMap.insert( "home", Address::Home ); | 42 | mAddressTypeMap.insert( "home", Address::Home ); |
43 | mAddressTypeMap.insert( "work", Address::Work ); | 43 | mAddressTypeMap.insert( "work", Address::Work ); |
44 | mAddressTypeMap.insert( "pref", Address::Pref ); | 44 | mAddressTypeMap.insert( "pref", Address::Pref ); |
45 | 45 | ||
46 | mPhoneTypeMap.insert( "HOME", PhoneNumber::Home ); | 46 | mPhoneTypeMap.insert( "HOME", PhoneNumber::Home ); |
47 | mPhoneTypeMap.insert( "WORK", PhoneNumber::Work ); | 47 | mPhoneTypeMap.insert( "WORK", PhoneNumber::Work ); |
48 | mPhoneTypeMap.insert( "MSG", PhoneNumber::Msg ); | 48 | mPhoneTypeMap.insert( "MSG", PhoneNumber::Msg ); |
49 | mPhoneTypeMap.insert( "PREF", PhoneNumber::Pref ); | 49 | mPhoneTypeMap.insert( "PREF", PhoneNumber::Pref ); |
50 | mPhoneTypeMap.insert( "VOICE", PhoneNumber::Voice ); | 50 | mPhoneTypeMap.insert( "VOICE", PhoneNumber::Voice ); |
51 | mPhoneTypeMap.insert( "FAX", PhoneNumber::Fax ); | 51 | mPhoneTypeMap.insert( "FAX", PhoneNumber::Fax ); |
52 | mPhoneTypeMap.insert( "CELL", PhoneNumber::Cell ); | 52 | mPhoneTypeMap.insert( "CELL", PhoneNumber::Cell ); |
53 | mPhoneTypeMap.insert( "VIDEO", PhoneNumber::Video ); | 53 | mPhoneTypeMap.insert( "VIDEO", PhoneNumber::Video ); |
54 | mPhoneTypeMap.insert( "BBS", PhoneNumber::Bbs ); | 54 | mPhoneTypeMap.insert( "BBS", PhoneNumber::Bbs ); |
55 | mPhoneTypeMap.insert( "MODEM", PhoneNumber::Modem ); | 55 | mPhoneTypeMap.insert( "MODEM", PhoneNumber::Modem ); |
56 | mPhoneTypeMap.insert( "CAR", PhoneNumber::Car ); | 56 | mPhoneTypeMap.insert( "CAR", PhoneNumber::Car ); |
57 | mPhoneTypeMap.insert( "ISDN", PhoneNumber::Isdn ); | 57 | mPhoneTypeMap.insert( "ISDN", PhoneNumber::Isdn ); |
58 | mPhoneTypeMap.insert( "PCS", PhoneNumber::Pcs ); | 58 | mPhoneTypeMap.insert( "PCS", PhoneNumber::Pcs ); |
59 | mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager ); | 59 | mPhoneTypeMap.insert( "PAGER", PhoneNumber::Pager ); |
60 | mPhoneTypeMap.insert( "SIP", PhoneNumber::Sip ); | ||
60 | } | 61 | } |
61 | 62 | ||
62 | VCardTool::~VCardTool() | 63 | VCardTool::~VCardTool() |
63 | { | 64 | { |
64 | } | 65 | } |
65 | 66 | ||
66 | QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) | 67 | QString VCardTool::createVCards( Addressee::List list, VCard::Version version ) |
67 | { | 68 | { |
68 | VCard::List vCardList; | 69 | VCard::List vCardList; |
69 | 70 | ||
70 | Addressee::List::Iterator addrIt; | 71 | Addressee::List::Iterator addrIt; |
71 | for ( addrIt = list.begin(); addrIt != list.end(); ++addrIt ) { | 72 | for ( addrIt = list.begin(); addrIt != list.end(); ++addrIt ) { |
72 | VCard card; | 73 | VCard card; |
73 | QStringList::ConstIterator strIt; | 74 | QStringList::ConstIterator strIt; |
74 | 75 | ||
75 | // ADR + LABEL | 76 | // ADR + LABEL |
76 | Address::List addresses = (*addrIt).addresses(); | 77 | Address::List addresses = (*addrIt).addresses(); |
77 | for ( Address::List::Iterator it = addresses.begin(); it != addresses.end(); ++it ) { | 78 | for ( Address::List::Iterator it = addresses.begin(); it != addresses.end(); ++it ) { |
78 | QStringList address; | 79 | QStringList address; |
79 | 80 | ||
80 | /*US | 81 | /*US |
81 | address.append( (*it).postOfficeBox().replace( ';', "\\;" ) ); | 82 | address.append( (*it).postOfficeBox().replace( ';', "\\;" ) ); |
82 | address.append( (*it).extended().replace( ';', "\\;" ) ); | 83 | address.append( (*it).extended().replace( ';', "\\;" ) ); |
83 | address.append( (*it).street().replace( ';', "\\;" ) ); | 84 | address.append( (*it).street().replace( ';', "\\;" ) ); |
84 | address.append( (*it).locality().replace( ';', "\\;" ) ); | 85 | address.append( (*it).locality().replace( ';', "\\;" ) ); |
85 | address.append( (*it).region().replace( ';', "\\;" ) ); | 86 | address.append( (*it).region().replace( ';', "\\;" ) ); |
86 | address.append( (*it).postalCode().replace( ';', "\\;" ) ); | 87 | address.append( (*it).postalCode().replace( ';', "\\;" ) ); |
87 | address.append( (*it).country().replace( ';', "\\;" ) ); | 88 | address.append( (*it).country().replace( ';', "\\;" ) ); |
88 | */ | 89 | */ |
89 | //US using the old implementation instead | 90 | //US using the old implementation instead |
90 | //qDebug("VCardTool::createVCards has to be verified"); | 91 | //qDebug("VCardTool::createVCards has to be verified"); |
91 | address.append( (*it).postOfficeBox().replace( QRegExp(";"), "\\;" ) ); | 92 | address.append( (*it).postOfficeBox().replace( QRegExp(";"), "\\;" ) ); |
92 | address.append( (*it).extended().replace( QRegExp(";"), "\\;" ) ); | 93 | address.append( (*it).extended().replace( QRegExp(";"), "\\;" ) ); |
93 | address.append( (*it).street().replace( QRegExp(";"), "\\;" ) ); | 94 | address.append( (*it).street().replace( QRegExp(";"), "\\;" ) ); |
94 | address.append( (*it).locality().replace( QRegExp(";"), "\\;" ) ); | 95 | address.append( (*it).locality().replace( QRegExp(";"), "\\;" ) ); |
95 | address.append( (*it).region().replace( QRegExp(";"), "\\;" ) ); | 96 | address.append( (*it).region().replace( QRegExp(";"), "\\;" ) ); |
96 | address.append( (*it).postalCode().replace( QRegExp(";"), "\\;" ) ); | 97 | address.append( (*it).postalCode().replace( QRegExp(";"), "\\;" ) ); |
97 | address.append( (*it).country().replace( QRegExp(";"), "\\;" ) ); | 98 | address.append( (*it).country().replace( QRegExp(";"), "\\;" ) ); |
98 | 99 | ||
99 | VCardLine adrLine( "ADR", address.join( ";" ) ); | 100 | VCardLine adrLine( "ADR", address.join( ";" ) ); |
100 | VCardLine labelLine( "LABEL", (*it).label() ); | 101 | VCardLine labelLine( "LABEL", (*it).label() ); |
101 | 102 | ||
102 | bool hasLabel = !(*it).label().isEmpty(); | 103 | bool hasLabel = !(*it).label().isEmpty(); |
103 | QMap<QString, int>::Iterator typeIt; | 104 | QMap<QString, int>::Iterator typeIt; |
104 | for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) { | 105 | for ( typeIt = mAddressTypeMap.begin(); typeIt != mAddressTypeMap.end(); ++typeIt ) { |
105 | if ( typeIt.data() & (*it).type() ) { | 106 | if ( typeIt.data() & (*it).type() ) { |
106 | if ( version == VCard::v3_0 ) { | 107 | if ( version == VCard::v3_0 ) { |
107 | adrLine.addParameter( "TYPE", typeIt.key().lower() ); | 108 | adrLine.addParameter( "TYPE", typeIt.key().lower() ); |
108 | } | 109 | } |
109 | else { | 110 | else { |
110 | adrLine.addParameter( "TYPE", typeIt.key() ); | 111 | adrLine.addParameter( "TYPE", typeIt.key() ); |
111 | } | 112 | } |
112 | if ( hasLabel ) { | 113 | if ( hasLabel ) { |
113 | if ( version == VCard::v3_0 ) { | 114 | if ( version == VCard::v3_0 ) { |
114 | labelLine.addParameter( "TYPE", typeIt.key().lower() ); | 115 | labelLine.addParameter( "TYPE", typeIt.key().lower() ); |
115 | } | 116 | } |
116 | else { | 117 | else { |
117 | labelLine.addParameter( "TYPE", typeIt.key() ); | 118 | labelLine.addParameter( "TYPE", typeIt.key() ); |
118 | } | 119 | } |
119 | } | 120 | } |
120 | } | 121 | } |
121 | } | 122 | } |
122 | 123 | ||
123 | card.addLine( adrLine ); | 124 | card.addLine( adrLine ); |
124 | if ( hasLabel ) | 125 | if ( hasLabel ) |
125 | card.addLine( labelLine ); | 126 | card.addLine( labelLine ); |
126 | } | 127 | } |
127 | 128 | ||
128 | // AGENT | 129 | // AGENT |
129 | card.addLine( createAgent( version, (*addrIt).agent() ) ); | 130 | card.addLine( createAgent( version, (*addrIt).agent() ) ); |
130 | 131 | ||
131 | // BDAY | 132 | // BDAY |
132 | card.addLine( VCardLine( "BDAY", createDateTime( (*addrIt).birthday() ) ) ); | 133 | card.addLine( VCardLine( "BDAY", createDateTime( (*addrIt).birthday() ) ) ); |
133 | 134 | ||
134 | // CATEGORIES | 135 | // CATEGORIES |
135 | if ( version == VCard::v3_0 ) { | 136 | if ( version == VCard::v3_0 ) { |
136 | QStringList categories = (*addrIt).categories(); | 137 | QStringList categories = (*addrIt).categories(); |
137 | QStringList::Iterator catIt; | 138 | QStringList::Iterator catIt; |
138 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) | 139 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) |
139 | { | 140 | { |
140 | //US using the old implementation instead | 141 | //US using the old implementation instead |
141 | // qDebug("VCardTool::createVCards has to be verified"); | 142 | // qDebug("VCardTool::createVCards has to be verified"); |
142 | //US (*catIt).replace( ',', "\\," ); | 143 | //US (*catIt).replace( ',', "\\," ); |
143 | (*catIt).replace( QRegExp(","), "\\," ); | 144 | (*catIt).replace( QRegExp(","), "\\," ); |
144 | } | 145 | } |
145 | card.addLine( VCardLine( "CATEGORIES", categories.join( "," ) ) ); | 146 | card.addLine( VCardLine( "CATEGORIES", categories.join( "," ) ) ); |
146 | } | 147 | } |
147 | 148 | ||
148 | // CLASS | 149 | // CLASS |
149 | if ( version == VCard::v3_0 ) { | 150 | if ( version == VCard::v3_0 ) { |
150 | card.addLine( createSecrecy( (*addrIt).secrecy() ) ); | 151 | card.addLine( createSecrecy( (*addrIt).secrecy() ) ); |
151 | } | 152 | } |
152 | 153 | ||
153 | 154 | ||
154 | QStringList emails = (*addrIt).emails(); | 155 | QStringList emails = (*addrIt).emails(); |
155 | bool pref = true; | 156 | bool pref = true; |
156 | for ( strIt = emails.begin(); strIt != emails.end(); ++strIt ) { | 157 | for ( strIt = emails.begin(); strIt != emails.end(); ++strIt ) { |
157 | VCardLine line( "EMAIL", *strIt ); | 158 | VCardLine line( "EMAIL", *strIt ); |
158 | if ( pref == true ) { | 159 | if ( pref == true ) { |
159 | line.addParameter( "TYPE", "PREF" ); | 160 | line.addParameter( "TYPE", "PREF" ); |
160 | pref = false; | 161 | pref = false; |
161 | } | 162 | } |
162 | card.addLine( line ); | 163 | card.addLine( line ); |
163 | } | 164 | } |
164 | 165 | ||
165 | // FN | 166 | // FN |
166 | card.addLine( VCardLine( "FN", (*addrIt).formattedName() ) ); | 167 | card.addLine( VCardLine( "FN", (*addrIt).formattedName() ) ); |
167 | 168 | ||
168 | // GEO | 169 | // GEO |
169 | Geo geo = (*addrIt).geo(); | 170 | Geo geo = (*addrIt).geo(); |
170 | if ( geo.isValid() ) { | 171 | if ( geo.isValid() ) { |
171 | QString str; | 172 | QString str; |
172 | str.sprintf( "%.6f;%.6f", geo.latitude(), geo.longitude() ); | 173 | str.sprintf( "%.6f;%.6f", geo.latitude(), geo.longitude() ); |
173 | card.addLine( VCardLine( "GEO", str ) ); | 174 | card.addLine( VCardLine( "GEO", str ) ); |
174 | } | 175 | } |
175 | 176 | ||
176 | // KEY | 177 | // KEY |
177 | Key::List keys = (*addrIt).keys(); | 178 | Key::List keys = (*addrIt).keys(); |
178 | Key::List::ConstIterator keyIt; | 179 | Key::List::ConstIterator keyIt; |
179 | for ( keyIt = keys.begin(); keyIt != keys.end(); ++keyIt ) | 180 | for ( keyIt = keys.begin(); keyIt != keys.end(); ++keyIt ) |
180 | card.addLine( createKey( *keyIt ) ); | 181 | card.addLine( createKey( *keyIt ) ); |
181 | 182 | ||
182 | // LOGO | 183 | // LOGO |
183 | card.addLine( createPicture( "LOGO", (*addrIt).logo() ) ); | 184 | card.addLine( createPicture( "LOGO", (*addrIt).logo() ) ); |
184 | 185 | ||
185 | // MAILER | 186 | // MAILER |
186 | card.addLine( VCardLine( "MAILER", (*addrIt).mailer() ) ); | 187 | card.addLine( VCardLine( "MAILER", (*addrIt).mailer() ) ); |
187 | 188 | ||
188 | // N | 189 | // N |
189 | QStringList name; | 190 | QStringList name; |
190 | //US using the old implementation instead | 191 | //US using the old implementation instead |
191 | //qDebug("VCardTool::createVCards has to be verified"); | 192 | //qDebug("VCardTool::createVCards has to be verified"); |
192 | /*US | 193 | /*US |
193 | name.append( (*addrIt).familyName().replace( ';', "\\;" ) ); | 194 | name.append( (*addrIt).familyName().replace( ';', "\\;" ) ); |
194 | name.append( (*addrIt).givenName().replace( ';', "\\;" ) ); | 195 | name.append( (*addrIt).givenName().replace( ';', "\\;" ) ); |
195 | name.append( (*addrIt).additionalName().replace( ';', "\\;" ) ); | 196 | name.append( (*addrIt).additionalName().replace( ';', "\\;" ) ); |
196 | name.append( (*addrIt).prefix().replace( ';', "\\;" ) ); | 197 | name.append( (*addrIt).prefix().replace( ';', "\\;" ) ); |
197 | name.append( (*addrIt).suffix().replace( ';', "\\;" ) ); | 198 | name.append( (*addrIt).suffix().replace( ';', "\\;" ) ); |
198 | */ | 199 | */ |
199 | name.append( (*addrIt).familyName().replace( QRegExp(";"), "\\;" ) ); | 200 | name.append( (*addrIt).familyName().replace( QRegExp(";"), "\\;" ) ); |
200 | name.append( (*addrIt).givenName().replace( QRegExp(";"), "\\;" ) ); | 201 | name.append( (*addrIt).givenName().replace( QRegExp(";"), "\\;" ) ); |
201 | name.append( (*addrIt).additionalName().replace( QRegExp(";"), "\\;" ) ); | 202 | name.append( (*addrIt).additionalName().replace( QRegExp(";"), "\\;" ) ); |
202 | name.append( (*addrIt).prefix().replace( QRegExp(";"), "\\;" ) ); | 203 | name.append( (*addrIt).prefix().replace( QRegExp(";"), "\\;" ) ); |
203 | name.append( (*addrIt).suffix().replace( QRegExp(";"), "\\;" ) ); | 204 | name.append( (*addrIt).suffix().replace( QRegExp(";"), "\\;" ) ); |
204 | 205 | ||
205 | if ( !name.join( "" ).isEmpty() ) | 206 | if ( !name.join( "" ).isEmpty() ) |
206 | card.addLine( VCardLine( "N", name.join( ";" ) ) ); | 207 | card.addLine( VCardLine( "N", name.join( ";" ) ) ); |
207 | 208 | ||
208 | // NICKNAME | 209 | // NICKNAME |
209 | if ( version == VCard::v3_0 ) | 210 | if ( version == VCard::v3_0 ) |
210 | card.addLine( VCardLine( "NICKNAME", (*addrIt).nickName() ) ); | 211 | card.addLine( VCardLine( "NICKNAME", (*addrIt).nickName() ) ); |
211 | 212 | ||
212 | // NOTE | 213 | // NOTE |
213 | card.addLine( VCardLine( "NOTE", (*addrIt).note() ) ); | 214 | card.addLine( VCardLine( "NOTE", (*addrIt).note() ) ); |
214 | 215 | ||
215 | // ORG | 216 | // ORG |
216 | card.addLine( VCardLine( "ORG", (*addrIt).organization() ) ); | 217 | card.addLine( VCardLine( "ORG", (*addrIt).organization() ) ); |
217 | 218 | ||
218 | // PHOTO | 219 | // PHOTO |
219 | card.addLine( createPicture( "PHOTO", (*addrIt).photo() ) ); | 220 | card.addLine( createPicture( "PHOTO", (*addrIt).photo() ) ); |
220 | 221 | ||
221 | // PROID | 222 | // PROID |
222 | if ( version == VCard::v3_0 ) | 223 | if ( version == VCard::v3_0 ) |
223 | card.addLine( VCardLine( "PRODID", (*addrIt).productId() ) ); | 224 | card.addLine( VCardLine( "PRODID", (*addrIt).productId() ) ); |
224 | 225 | ||
225 | // REV | 226 | // REV |
226 | card.addLine( VCardLine( "REV", createDateTime( (*addrIt).revision() ) ) ); | 227 | card.addLine( VCardLine( "REV", createDateTime( (*addrIt).revision() ) ) ); |
227 | 228 | ||
228 | // ROLE | 229 | // ROLE |
229 | card.addLine( VCardLine( "ROLE", (*addrIt).role() ) ); | 230 | card.addLine( VCardLine( "ROLE", (*addrIt).role() ) ); |
230 | 231 | ||
231 | // SORT-STRING | 232 | // SORT-STRING |
232 | if ( version == VCard::v3_0 ) | 233 | if ( version == VCard::v3_0 ) |
233 | card.addLine( VCardLine( "SORT-STRING", (*addrIt).sortString() ) ); | 234 | card.addLine( VCardLine( "SORT-STRING", (*addrIt).sortString() ) ); |
234 | 235 | ||
235 | // SOUND | 236 | // SOUND |
236 | card.addLine( createSound( (*addrIt).sound() ) ); | 237 | card.addLine( createSound( (*addrIt).sound() ) ); |
237 | 238 | ||
238 | // TEL | 239 | // TEL |
239 | PhoneNumber::List phoneNumbers = (*addrIt).phoneNumbers(); | 240 | PhoneNumber::List phoneNumbers = (*addrIt).phoneNumbers(); |
240 | PhoneNumber::List::ConstIterator phoneIt; | 241 | PhoneNumber::List::ConstIterator phoneIt; |
241 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 242 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
242 | VCardLine line( "TEL", (*phoneIt).number() ); | 243 | VCardLine line( "TEL", (*phoneIt).number() ); |
243 | 244 | ||
244 | QMap<QString, int>::Iterator typeIt; | 245 | QMap<QString, int>::Iterator typeIt; |
245 | for ( typeIt = mPhoneTypeMap.begin(); typeIt != mPhoneTypeMap.end(); ++typeIt ) { | 246 | for ( typeIt = mPhoneTypeMap.begin(); typeIt != mPhoneTypeMap.end(); ++typeIt ) { |
246 | if ( typeIt.data() & (*phoneIt).type() ) | 247 | if ( typeIt.data() & (*phoneIt).type() ) |
247 | if ( version == VCard::v3_0 ) | 248 | if ( version == VCard::v3_0 ) |
248 | line.addParameter( "TYPE", typeIt.key().lower() ); | 249 | line.addParameter( "TYPE", typeIt.key().lower() ); |
249 | else | 250 | else |
250 | line.addParameter( "TYPE", typeIt.key() ); | 251 | line.addParameter( "TYPE", typeIt.key() ); |
251 | } | 252 | } |
252 | 253 | ||
253 | card.addLine( line ); | 254 | card.addLine( line ); |
254 | } | 255 | } |
255 | 256 | ||
256 | // TITLE | 257 | // TITLE |
257 | card.addLine( VCardLine( "TITLE", (*addrIt).title() ) ); | 258 | card.addLine( VCardLine( "TITLE", (*addrIt).title() ) ); |
258 | 259 | ||
259 | // TZ | 260 | // TZ |
260 | TimeZone timeZone = (*addrIt).timeZone(); | 261 | TimeZone timeZone = (*addrIt).timeZone(); |
261 | if ( timeZone.isValid() ) { | 262 | if ( timeZone.isValid() ) { |
262 | QString str; | 263 | QString str; |
263 | 264 | ||
264 | int neg = 1; | 265 | int neg = 1; |
265 | if ( timeZone.offset() < 0 ) | 266 | if ( timeZone.offset() < 0 ) |
266 | neg = -1; | 267 | neg = -1; |
267 | 268 | ||
268 | str.sprintf( "%c%02d:%02d", ( timeZone.offset() >= 0 ? '+' : '-' ), | 269 | str.sprintf( "%c%02d:%02d", ( timeZone.offset() >= 0 ? '+' : '-' ), |
269 | ( timeZone.offset() / 60 ) * neg, | 270 | ( timeZone.offset() / 60 ) * neg, |
270 | ( timeZone.offset() % 60 ) * neg ); | 271 | ( timeZone.offset() % 60 ) * neg ); |
271 | 272 | ||
272 | card.addLine( VCardLine( "TZ", str ) ); | 273 | card.addLine( VCardLine( "TZ", str ) ); |
273 | } | 274 | } |
274 | 275 | ||
275 | // UID | 276 | // UID |
276 | card.addLine( VCardLine( "UID", (*addrIt).uid() ) ); | 277 | card.addLine( VCardLine( "UID", (*addrIt).uid() ) ); |
277 | 278 | ||
278 | // URL | 279 | // URL |
279 | card.addLine( VCardLine( "URL", (*addrIt).url().url() ) ); | 280 | card.addLine( VCardLine( "URL", (*addrIt).url().url() ) ); |
280 | 281 | ||
281 | // VERSION | 282 | // VERSION |
282 | if ( version == VCard::v2_1 ) | 283 | if ( version == VCard::v2_1 ) |
283 | card.addLine( VCardLine( "VERSION", "2.1" ) ); | 284 | card.addLine( VCardLine( "VERSION", "2.1" ) ); |
284 | if ( version == VCard::v3_0 ) | 285 | if ( version == VCard::v3_0 ) |
285 | card.addLine( VCardLine( "VERSION", "3.0" ) ); | 286 | card.addLine( VCardLine( "VERSION", "3.0" ) ); |
286 | 287 | ||
287 | // X- | 288 | // X- |
288 | QStringList customs = (*addrIt).customs(); | 289 | QStringList customs = (*addrIt).customs(); |
289 | for ( strIt = customs.begin(); strIt != customs.end(); ++strIt ) { | 290 | for ( strIt = customs.begin(); strIt != customs.end(); ++strIt ) { |
290 | QString identifier = "X-" + (*strIt).left( (*strIt).find( ":" ) ); | 291 | QString identifier = "X-" + (*strIt).left( (*strIt).find( ":" ) ); |
291 | QString value = (*strIt).mid( (*strIt).find( ":" ) + 1 ); | 292 | QString value = (*strIt).mid( (*strIt).find( ":" ) + 1 ); |
292 | if ( value.isEmpty() ) | 293 | if ( value.isEmpty() ) |
293 | continue; | 294 | continue; |
294 | 295 | ||
295 | card.addLine( VCardLine( identifier, value ) ); | 296 | card.addLine( VCardLine( identifier, value ) ); |
296 | } | 297 | } |
297 | 298 | ||
298 | vCardList.append( card ); | 299 | vCardList.append( card ); |
299 | } | 300 | } |
300 | 301 | ||
301 | return VCardParser::createVCards( vCardList ); | 302 | return VCardParser::createVCards( vCardList ); |
302 | } | 303 | } |
303 | 304 | ||
304 | Addressee::List VCardTool::parseVCards( const QString& vcard ) | 305 | Addressee::List VCardTool::parseVCards( const QString& vcard ) |
305 | { | 306 | { |
306 | QChar semicolonSep( ';' ); | 307 | QChar semicolonSep( ';' ); |
307 | QChar commaSep( ',' ); | 308 | QChar commaSep( ',' ); |
308 | QString identifier; | 309 | QString identifier; |
309 | 310 | ||
310 | Addressee::List addrList; | 311 | Addressee::List addrList; |
311 | VCard::List vCardList = VCardParser::parseVCards( vcard ); | 312 | VCard::List vCardList = VCardParser::parseVCards( vcard ); |
312 | VCard::List::Iterator cardIt; | 313 | VCard::List::Iterator cardIt; |
313 | for ( cardIt = vCardList.begin(); cardIt != vCardList.end(); ++cardIt ) { | 314 | for ( cardIt = vCardList.begin(); cardIt != vCardList.end(); ++cardIt ) { |
314 | Addressee addr; | 315 | Addressee addr; |
315 | QStringList idents = (*cardIt).identifiers(); | 316 | QStringList idents = (*cardIt).identifiers(); |
316 | QStringList::ConstIterator identIt; | 317 | QStringList::ConstIterator identIt; |
317 | for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) { | 318 | for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) { |
318 | VCard card = (*cardIt); | 319 | VCard card = (*cardIt); |
319 | VCardLine::List lines = card.lines( (*identIt) ); | 320 | VCardLine::List lines = card.lines( (*identIt) ); |
320 | VCardLine::List::Iterator lineIt; | 321 | VCardLine::List::Iterator lineIt; |
321 | 322 | ||
322 | // iterate over the lines | 323 | // iterate over the lines |
323 | for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) { | 324 | for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) { |
324 | QStringList params = (*lineIt).parameterList(); | 325 | QStringList params = (*lineIt).parameterList(); |
325 | 326 | ||
326 | identifier = (*lineIt).identifier().lower(); | 327 | identifier = (*lineIt).identifier().lower(); |
327 | // ADR | 328 | // ADR |
328 | if ( identifier == "adr" ) { | 329 | if ( identifier == "adr" ) { |
329 | Address address; | 330 | Address address; |
330 | QStringList addrParts = splitString( semicolonSep, (*lineIt).value().asString() ); | 331 | QStringList addrParts = splitString( semicolonSep, (*lineIt).value().asString() ); |
331 | if ( addrParts.count() > 0 ) | 332 | if ( addrParts.count() > 0 ) |
332 | address.setPostOfficeBox( addrParts[ 0 ] ); | 333 | address.setPostOfficeBox( addrParts[ 0 ] ); |
333 | if ( addrParts.count() > 1 ) | 334 | if ( addrParts.count() > 1 ) |
334 | address.setExtended( addrParts[ 1 ] ); | 335 | address.setExtended( addrParts[ 1 ] ); |
335 | if ( addrParts.count() > 2 ) | 336 | if ( addrParts.count() > 2 ) |
336 | address.setStreet( addrParts[ 2 ].replace ( QRegExp("\\\\n") , "\n") ); | 337 | address.setStreet( addrParts[ 2 ].replace ( QRegExp("\\\\n") , "\n") ); |
337 | if ( addrParts.count() > 3 ) | 338 | if ( addrParts.count() > 3 ) |
338 | address.setLocality( addrParts[ 3 ] ); | 339 | address.setLocality( addrParts[ 3 ] ); |
339 | if ( addrParts.count() > 4 ) | 340 | if ( addrParts.count() > 4 ) |
340 | address.setRegion( addrParts[ 4 ] ); | 341 | address.setRegion( addrParts[ 4 ] ); |
341 | if ( addrParts.count() > 5 ) | 342 | if ( addrParts.count() > 5 ) |
342 | address.setPostalCode( addrParts[ 5 ] ); | 343 | address.setPostalCode( addrParts[ 5 ] ); |
343 | if ( addrParts.count() > 6 ) | 344 | if ( addrParts.count() > 6 ) |
344 | address.setCountry( addrParts[ 6 ] ); | 345 | address.setCountry( addrParts[ 6 ] ); |
345 | 346 | ||
346 | int type = 0; | 347 | int type = 0; |
347 | 348 | ||
348 | QStringList types = (*lineIt).parameters( "type" ); | 349 | QStringList types = (*lineIt).parameters( "type" ); |
349 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) | 350 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) |
350 | type += mAddressTypeMap[ (*it).lower() ]; | 351 | type += mAddressTypeMap[ (*it).lower() ]; |
351 | 352 | ||
352 | if ( !type ) | 353 | if ( !type ) |
353 | type = Address::Home; // default | 354 | type = Address::Home; // default |
354 | 355 | ||
355 | address.setType( type ); | 356 | address.setType( type ); |
356 | addr.insertAddress( address ); | 357 | addr.insertAddress( address ); |
357 | } | 358 | } |
358 | 359 | ||
359 | // AGENT | 360 | // AGENT |
360 | if ( identifier == "agent" ) | 361 | if ( identifier == "agent" ) |
361 | addr.setAgent( parseAgent( *lineIt ) ); | 362 | addr.setAgent( parseAgent( *lineIt ) ); |
362 | 363 | ||
363 | // BDAY | 364 | // BDAY |
364 | if ( identifier == "bday" ) | 365 | if ( identifier == "bday" ) |
365 | addr.setBirthday( parseDateTime( (*lineIt).value().asString() ) ); | 366 | addr.setBirthday( parseDateTime( (*lineIt).value().asString() ) ); |
366 | 367 | ||
367 | // CATEGORIES | 368 | // CATEGORIES |
368 | if ( identifier == "categories" ) { | 369 | if ( identifier == "categories" ) { |
369 | QStringList categories = splitString( commaSep, (*lineIt).value().asString() ); | 370 | QStringList categories = splitString( commaSep, (*lineIt).value().asString() ); |
370 | addr.setCategories( categories ); | 371 | addr.setCategories( categories ); |
371 | } | 372 | } |
372 | 373 | ||
373 | // CLASS | 374 | // CLASS |
374 | if ( identifier == "class" ) | 375 | if ( identifier == "class" ) |
375 | addr.setSecrecy( parseSecrecy( *lineIt ) ); | 376 | addr.setSecrecy( parseSecrecy( *lineIt ) ); |
376 | 377 | ||
377 | 378 | ||
378 | if ( identifier == "email" ) { | 379 | if ( identifier == "email" ) { |
379 | QStringList types = (*lineIt).parameters( "type" ); | 380 | QStringList types = (*lineIt).parameters( "type" ); |
380 | addr.insertEmail( (*lineIt).value().asString(), types.contains( "PREF" ) ); | 381 | addr.insertEmail( (*lineIt).value().asString(), types.contains( "PREF" ) ); |
381 | } | 382 | } |
382 | 383 | ||
383 | // FN | 384 | // FN |
384 | if ( identifier == "fn" ) | 385 | if ( identifier == "fn" ) |
385 | addr.setFormattedName( (*lineIt).value().asString() ); | 386 | addr.setFormattedName( (*lineIt).value().asString() ); |
386 | 387 | ||
387 | // GEO | 388 | // GEO |
388 | if ( identifier == "geo" ) { | 389 | if ( identifier == "geo" ) { |
389 | Geo geo; | 390 | Geo geo; |
390 | 391 | ||
391 | QStringList geoParts = QStringList::split( ';', (*lineIt).value().asString(), true ); | 392 | QStringList geoParts = QStringList::split( ';', (*lineIt).value().asString(), true ); |
392 | geo.setLatitude( geoParts[ 0 ].toFloat() ); | 393 | geo.setLatitude( geoParts[ 0 ].toFloat() ); |
393 | geo.setLongitude( geoParts[ 1 ].toFloat() ); | 394 | geo.setLongitude( geoParts[ 1 ].toFloat() ); |
394 | 395 | ||
395 | addr.setGeo( geo ); | 396 | addr.setGeo( geo ); |
396 | } | 397 | } |
397 | 398 | ||
398 | // KEY | 399 | // KEY |
399 | if ( identifier == "key" ) | 400 | if ( identifier == "key" ) |
400 | addr.insertKey( parseKey( *lineIt ) ); | 401 | addr.insertKey( parseKey( *lineIt ) ); |
401 | 402 | ||
402 | // LABEL | 403 | // LABEL |
403 | if ( identifier == "label" ) { | 404 | if ( identifier == "label" ) { |
404 | int type = 0; | 405 | int type = 0; |
405 | 406 | ||
406 | QStringList types = (*lineIt).parameters( "type" ); | 407 | QStringList types = (*lineIt).parameters( "type" ); |
407 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) | 408 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) |
408 | type += mAddressTypeMap[ (*it).lower() ]; | 409 | type += mAddressTypeMap[ (*it).lower() ]; |
409 | 410 | ||
410 | if ( !type ) | 411 | if ( !type ) |
411 | type = Address::Home; | 412 | type = Address::Home; |
412 | 413 | ||
413 | KABC::Address::List addressList = addr.addresses(); | 414 | KABC::Address::List addressList = addr.addresses(); |
414 | KABC::Address::List::Iterator it; | 415 | KABC::Address::List::Iterator it; |
415 | for ( it = addressList.begin(); it != addressList.end(); ++it ) { | 416 | for ( it = addressList.begin(); it != addressList.end(); ++it ) { |
416 | if ( (*it).type() == type ) { | 417 | if ( (*it).type() == type ) { |
417 | (*it).setLabel( (*lineIt).value().asString() ); | 418 | (*it).setLabel( (*lineIt).value().asString() ); |
418 | addr.insertAddress( *it ); | 419 | addr.insertAddress( *it ); |
419 | } | 420 | } |
420 | } | 421 | } |
421 | } | 422 | } |
422 | 423 | ||
423 | // LOGO | 424 | // LOGO |
424 | if ( identifier == "logo" ) | 425 | if ( identifier == "logo" ) |
425 | addr.setLogo( parsePicture( *lineIt ) ); | 426 | addr.setLogo( parsePicture( *lineIt ) ); |
426 | 427 | ||
427 | // MAILER | 428 | // MAILER |
428 | if ( identifier == "mailer" ) | 429 | if ( identifier == "mailer" ) |
429 | addr.setMailer( (*lineIt).value().asString() ); | 430 | addr.setMailer( (*lineIt).value().asString() ); |
430 | 431 | ||
431 | // N | 432 | // N |
432 | if ( identifier == "n" ) { | 433 | if ( identifier == "n" ) { |
433 | QStringList nameParts = splitString( semicolonSep, (*lineIt).value().asString() ); | 434 | QStringList nameParts = splitString( semicolonSep, (*lineIt).value().asString() ); |
434 | if ( nameParts.count() > 0 ) | 435 | if ( nameParts.count() > 0 ) |
435 | addr.setFamilyName( nameParts[ 0 ] ); | 436 | addr.setFamilyName( nameParts[ 0 ] ); |
436 | if ( nameParts.count() > 1 ) | 437 | if ( nameParts.count() > 1 ) |
437 | addr.setGivenName( nameParts[ 1 ] ); | 438 | addr.setGivenName( nameParts[ 1 ] ); |
438 | if ( nameParts.count() > 2 ) | 439 | if ( nameParts.count() > 2 ) |
439 | addr.setAdditionalName( nameParts[ 2 ] ); | 440 | addr.setAdditionalName( nameParts[ 2 ] ); |
440 | if ( nameParts.count() > 3 ) | 441 | if ( nameParts.count() > 3 ) |
441 | addr.setPrefix( nameParts[ 3 ] ); | 442 | addr.setPrefix( nameParts[ 3 ] ); |
442 | if ( nameParts.count() > 4 ) | 443 | if ( nameParts.count() > 4 ) |
443 | addr.setSuffix( nameParts[ 4 ] ); | 444 | addr.setSuffix( nameParts[ 4 ] ); |
444 | } | 445 | } |
445 | 446 | ||
446 | // NICKNAME | 447 | // NICKNAME |
447 | if ( identifier == "nickname" ) | 448 | if ( identifier == "nickname" ) |
448 | addr.setNickName( (*lineIt).value().asString() ); | 449 | addr.setNickName( (*lineIt).value().asString() ); |
449 | 450 | ||
450 | // NOTE | 451 | // NOTE |
451 | if ( identifier == "note" ) { | 452 | if ( identifier == "note" ) { |
452 | // #ifdef DESKTOP_VERSION | 453 | // #ifdef DESKTOP_VERSION |
453 | // addr.setNote( (*lineIt).value().asString() ); | 454 | // addr.setNote( (*lineIt).value().asString() ); |
454 | // #else | 455 | // #else |
455 | QString note = (*lineIt).value().asString(); | 456 | QString note = (*lineIt).value().asString(); |
456 | if ( ! note.isEmpty() ) | 457 | if ( ! note.isEmpty() ) |
457 | addr.setNote( note.replace ( QRegExp("\\\\n") , "\n") ); | 458 | addr.setNote( note.replace ( QRegExp("\\\\n") , "\n") ); |
458 | else | 459 | else |
459 | addr.setNote( note ); | 460 | addr.setNote( note ); |
460 | //#endif | 461 | //#endif |
461 | } | 462 | } |
462 | 463 | ||
463 | // ORGANIZATION | 464 | // ORGANIZATION |
464 | if ( identifier == "org" ) | 465 | if ( identifier == "org" ) |
465 | addr.setOrganization( (*lineIt).value().asString() ); | 466 | addr.setOrganization( (*lineIt).value().asString() ); |
466 | 467 | ||
467 | // PHOTO | 468 | // PHOTO |
468 | if ( identifier == "photo" ) | 469 | if ( identifier == "photo" ) |
469 | addr.setPhoto( parsePicture( *lineIt ) ); | 470 | addr.setPhoto( parsePicture( *lineIt ) ); |
470 | 471 | ||
471 | // PROID | 472 | // PROID |
472 | if ( identifier == "prodid" ) | 473 | if ( identifier == "prodid" ) |
473 | addr.setProductId( (*lineIt).value().asString() ); | 474 | addr.setProductId( (*lineIt).value().asString() ); |
474 | 475 | ||
475 | // REV | 476 | // REV |
476 | if ( identifier == "rev" ) | 477 | if ( identifier == "rev" ) |
477 | addr.setRevision( parseDateTime( (*lineIt).value().asString() ) ); | 478 | addr.setRevision( parseDateTime( (*lineIt).value().asString() ) ); |
478 | 479 | ||
479 | // ROLE | 480 | // ROLE |
480 | if ( identifier == "role" ) | 481 | if ( identifier == "role" ) |
481 | addr.setRole( (*lineIt).value().asString() ); | 482 | addr.setRole( (*lineIt).value().asString() ); |
482 | 483 | ||
483 | // SORT-STRING | 484 | // SORT-STRING |
484 | if ( identifier == "sort-string" ) | 485 | if ( identifier == "sort-string" ) |
485 | addr.setSortString( (*lineIt).value().asString() ); | 486 | addr.setSortString( (*lineIt).value().asString() ); |
486 | 487 | ||
487 | // SOUND | 488 | // SOUND |
488 | if ( identifier == "sound" ) | 489 | if ( identifier == "sound" ) |
489 | addr.setSound( parseSound( *lineIt ) ); | 490 | addr.setSound( parseSound( *lineIt ) ); |
490 | 491 | ||
491 | // TEL | 492 | // TEL |
492 | if ( identifier == "tel" ) { | 493 | if ( identifier == "tel" ) { |
493 | PhoneNumber phone; | 494 | PhoneNumber phone; |
494 | phone.setNumber( (*lineIt).value().asString() ); | 495 | phone.setNumber( (*lineIt).value().asString() ); |
495 | 496 | ||
496 | int type = 0; | 497 | int type = 0; |
497 | 498 | ||
498 | QStringList types = (*lineIt).parameters( "type" ); | 499 | QStringList types = (*lineIt).parameters( "type" ); |
499 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) | 500 | for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) |
500 | type += mPhoneTypeMap[(*it).upper()]; | 501 | type += mPhoneTypeMap[(*it).upper()]; |
501 | 502 | ||
502 | if ( !type ) | 503 | if ( !type ) |
503 | type = PhoneNumber::Home; // default | 504 | type = PhoneNumber::Home; // default |
504 | 505 | ||
505 | phone.setType( type ); | 506 | phone.setType( type ); |
506 | 507 | ||
507 | addr.insertPhoneNumber( phone ); | 508 | addr.insertPhoneNumber( phone ); |
508 | } | 509 | } |
509 | 510 | ||
510 | // TITLE | 511 | // TITLE |
511 | if ( identifier == "title" ) | 512 | if ( identifier == "title" ) |
512 | addr.setTitle( (*lineIt).value().asString() ); | 513 | addr.setTitle( (*lineIt).value().asString() ); |
513 | 514 | ||
514 | // TZ | 515 | // TZ |
515 | if ( identifier == "tz" ) { | 516 | if ( identifier == "tz" ) { |
516 | TimeZone tz; | 517 | TimeZone tz; |
517 | QString date = (*lineIt).value().asString(); | 518 | QString date = (*lineIt).value().asString(); |
518 | 519 | ||
519 | int hours = date.mid( 1, 2).toInt(); | 520 | int hours = date.mid( 1, 2).toInt(); |
520 | int minutes = date.mid( 4, 2 ).toInt(); | 521 | int minutes = date.mid( 4, 2 ).toInt(); |
521 | int offset = ( hours * 60 ) + minutes; | 522 | int offset = ( hours * 60 ) + minutes; |
522 | offset = offset * ( date[ 0 ] == '+' ? 1 : -1 ); | 523 | offset = offset * ( date[ 0 ] == '+' ? 1 : -1 ); |
523 | 524 | ||
524 | tz.setOffset( offset ); | 525 | tz.setOffset( offset ); |
525 | addr.setTimeZone( tz ); | 526 | addr.setTimeZone( tz ); |
526 | } | 527 | } |
527 | 528 | ||
528 | // UID | 529 | // UID |
529 | if ( identifier == "uid" ) | 530 | if ( identifier == "uid" ) |
530 | addr.setUid( (*lineIt).value().asString() ); | 531 | addr.setUid( (*lineIt).value().asString() ); |
531 | 532 | ||
532 | // URL | 533 | // URL |
533 | if ( identifier == "url" ) | 534 | if ( identifier == "url" ) |
534 | addr.setUrl( (*lineIt).value().asString() ); | 535 | addr.setUrl( (*lineIt).value().asString() ); |
535 | 536 | ||
536 | // X- | 537 | // X- |
537 | if ( identifier.startsWith( "x-" ) ) { | 538 | if ( identifier.startsWith( "x-" ) ) { |
538 | QString key = (*lineIt).identifier().mid( 2 ); | 539 | QString key = (*lineIt).identifier().mid( 2 ); |
539 | int dash = key.find( "-" ); | 540 | int dash = key.find( "-" ); |
540 | addr.insertCustom( key.left( dash ), key.mid( dash + 1 ), (*lineIt).value().asString() ); | 541 | addr.insertCustom( key.left( dash ), key.mid( dash + 1 ), (*lineIt).value().asString() ); |
541 | } | 542 | } |
542 | } | 543 | } |
543 | } | 544 | } |
544 | 545 | ||
545 | addrList.append( addr ); | 546 | addrList.append( addr ); |
546 | } | 547 | } |
547 | 548 | ||
548 | return addrList; | 549 | return addrList; |
549 | } | 550 | } |
550 | 551 | ||
551 | QDateTime VCardTool::parseDateTime( const QString &str ) | 552 | QDateTime VCardTool::parseDateTime( const QString &str ) |
552 | { | 553 | { |
553 | QDateTime dateTime; | 554 | QDateTime dateTime; |
554 | 555 | ||
555 | if ( str.find( '-' ) == -1 ) { // is base format (yyyymmdd) | 556 | if ( str.find( '-' ) == -1 ) { // is base format (yyyymmdd) |
556 | dateTime.setDate( QDate( str.left( 4 ).toInt(), str.mid( 4, 2 ).toInt(), | 557 | dateTime.setDate( QDate( str.left( 4 ).toInt(), str.mid( 4, 2 ).toInt(), |
557 | str.mid( 6, 2 ).toInt() ) ); | 558 | str.mid( 6, 2 ).toInt() ) ); |
558 | 559 | ||
559 | if ( str.find( 'T' ) ) // has time information yyyymmddThh:mm:ss | 560 | if ( str.find( 'T' ) ) // has time information yyyymmddThh:mm:ss |
560 | dateTime.setTime( QTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(), | 561 | dateTime.setTime( QTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(), |
561 | str.mid( 17, 2 ).toInt() ) ); | 562 | str.mid( 17, 2 ).toInt() ) ); |
562 | 563 | ||
563 | } else { // is extended format yyyy-mm-dd | 564 | } else { // is extended format yyyy-mm-dd |
564 | dateTime.setDate( QDate( str.left( 4 ).toInt(), str.mid( 5, 2 ).toInt(), | 565 | dateTime.setDate( QDate( str.left( 4 ).toInt(), str.mid( 5, 2 ).toInt(), |
565 | str.mid( 8, 2 ).toInt() ) ); | 566 | str.mid( 8, 2 ).toInt() ) ); |
566 | 567 | ||
567 | if ( str.find( 'T' ) ) // has time information yyyy-mm-ddThh:mm:ss | 568 | if ( str.find( 'T' ) ) // has time information yyyy-mm-ddThh:mm:ss |
568 | dateTime.setTime( QTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(), | 569 | dateTime.setTime( QTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(), |
569 | str.mid( 17, 2 ).toInt() ) ); | 570 | str.mid( 17, 2 ).toInt() ) ); |
570 | } | 571 | } |
571 | 572 | ||
572 | return dateTime; | 573 | return dateTime; |
573 | } | 574 | } |
574 | 575 | ||
575 | QString VCardTool::createDateTime( const QDateTime &dateTime ) | 576 | QString VCardTool::createDateTime( const QDateTime &dateTime ) |
576 | { | 577 | { |
577 | QString str; | 578 | QString str; |
578 | 579 | ||
579 | if ( dateTime.date().isValid() ) { | 580 | if ( dateTime.date().isValid() ) { |
580 | str.sprintf( "%4d-%02d-%02d", dateTime.date().year(), dateTime.date().month(), | 581 | str.sprintf( "%4d-%02d-%02d", dateTime.date().year(), dateTime.date().month(), |
581 | dateTime.date().day() ); | 582 | dateTime.date().day() ); |
582 | if ( dateTime.time().isValid() ) { | 583 | if ( dateTime.time().isValid() ) { |
583 | QString tmp; | 584 | QString tmp; |
584 | tmp.sprintf( "T%02d:%02d:%02dZ", dateTime.time().hour(), dateTime.time().minute(), | 585 | tmp.sprintf( "T%02d:%02d:%02dZ", dateTime.time().hour(), dateTime.time().minute(), |
585 | dateTime.time().second() ); | 586 | dateTime.time().second() ); |
586 | str += tmp; | 587 | str += tmp; |
587 | } | 588 | } |
588 | } | 589 | } |
589 | 590 | ||
590 | return str; | 591 | return str; |
591 | } | 592 | } |
592 | 593 | ||
593 | Picture VCardTool::parsePicture( const VCardLine &line ) | 594 | Picture VCardTool::parsePicture( const VCardLine &line ) |
594 | { | 595 | { |
595 | Picture pic; | 596 | Picture pic; |
596 | 597 | ||
597 | QStringList params = line.parameterList(); | 598 | QStringList params = line.parameterList(); |
598 | if ( params.contains( "encoding" ) ) { | 599 | if ( params.contains( "encoding" ) ) { |
599 | QCString cs(line.value().asCString()); | 600 | QCString cs(line.value().asCString()); |
600 | QByteArray input, output; | 601 | QByteArray input, output; |
601 | input = line.value().asCString(); | 602 | input = line.value().asCString(); |
602 | if ( line.parameter( "encoding" ).lower() == "b" ) | 603 | if ( line.parameter( "encoding" ).lower() == "b" ) |
603 | KCodecs::base64Decode( input, output ); | 604 | KCodecs::base64Decode( input, output ); |
604 | else if ( line.parameter( "encoding" ).lower() == "quoted-printable" ) | 605 | else if ( line.parameter( "encoding" ).lower() == "quoted-printable" ) |
605 | KCodecs::quotedPrintableDecode( input, output ); | 606 | KCodecs::quotedPrintableDecode( input, output ); |
606 | 607 | ||
607 | qDebug("********** DECODING OKAY ************** (picture)"); | 608 | qDebug("********** DECODING OKAY ************** (picture)"); |
608 | pic.setData( QImage(output) ); | 609 | pic.setData( QImage(output) ); |
609 | 610 | ||
610 | } | 611 | } |
611 | else if ( params.contains( "value" ) ) { | 612 | else if ( params.contains( "value" ) ) { |
612 | if ( line.parameter( "value" ).lower() == "uri" ) | 613 | if ( line.parameter( "value" ).lower() == "uri" ) |
613 | pic.setUrl( line.value().asString() ); | 614 | pic.setUrl( line.value().asString() ); |
614 | } | 615 | } |
615 | 616 | ||
616 | if ( params.contains( "type" ) ) | 617 | if ( params.contains( "type" ) ) |
617 | pic.setType( line.parameter( "type" ) ); | 618 | pic.setType( line.parameter( "type" ) ); |
618 | 619 | ||
619 | return pic; | 620 | return pic; |
620 | } | 621 | } |
621 | 622 | ||
622 | VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pic ) | 623 | VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pic ) |
623 | { | 624 | { |
624 | // LR fixed | 625 | // LR fixed |
625 | VCardLine line( identifier ); | 626 | VCardLine line( identifier ); |
626 | 627 | ||
627 | if ( pic.isIntern() ) { | 628 | if ( pic.isIntern() ) { |
628 | if ( !pic.data().isNull() ) { | 629 | if ( !pic.data().isNull() ) { |
629 | #if 0 | 630 | #if 0 |
630 | QByteArray input; | 631 | QByteArray input; |
631 | QDataStream s( input, IO_WriteOnly ); | 632 | QDataStream s( input, IO_WriteOnly ); |
632 | s.setVersion( 4 ); | 633 | s.setVersion( 4 ); |
633 | s << pic.data(); | 634 | s << pic.data(); |
634 | line.setValue( input ); | 635 | line.setValue( input ); |
635 | #else | 636 | #else |
636 | QCString input; | 637 | QCString input; |
637 | QDataStream s( input, IO_WriteOnly ); | 638 | QDataStream s( input, IO_WriteOnly ); |
638 | s.setVersion( 4 ); | 639 | s.setVersion( 4 ); |
639 | s << pic.data(); | 640 | s << pic.data(); |
640 | //QCString cs(line.value().asCString()); | 641 | //QCString cs(line.value().asCString()); |
641 | //QImage qi(cs); | 642 | //QImage qi(cs); |
642 | line.setValue( input ); | 643 | line.setValue( input ); |
643 | #endif | 644 | #endif |
644 | 645 | ||
645 | line.addParameter( "encoding", "b" ); | 646 | line.addParameter( "encoding", "b" ); |
646 | line.addParameter( "type", "image/png" ); | 647 | line.addParameter( "type", "image/png" ); |
647 | } | 648 | } |
648 | } else if ( !pic.url().isEmpty() ) { | 649 | } else if ( !pic.url().isEmpty() ) { |
649 | line.setValue( pic.url() ); | 650 | line.setValue( pic.url() ); |
650 | line.addParameter( "value", "URI" ); | 651 | line.addParameter( "value", "URI" ); |
651 | } | 652 | } |
652 | 653 | ||
653 | return line; | 654 | return line; |
654 | } | 655 | } |
655 | 656 | ||
656 | Sound VCardTool::parseSound( const VCardLine &line ) | 657 | Sound VCardTool::parseSound( const VCardLine &line ) |
657 | { | 658 | { |
658 | Sound snd; | 659 | Sound snd; |
659 | 660 | ||
660 | QStringList params = line.parameterList(); | 661 | QStringList params = line.parameterList(); |
661 | if ( params.contains( "encoding" ) ) { | 662 | if ( params.contains( "encoding" ) ) { |
662 | qDebug("VCardTool::parseSound has to be verified"); | 663 | qDebug("VCardTool::parseSound has to be verified"); |
663 | //US snd.setData( line.value().asByteArray() ); | 664 | //US snd.setData( line.value().asByteArray() ); |
664 | //US I am not sure if this is correct | 665 | //US I am not sure if this is correct |
665 | QCString cs(line.value().asCString()); | 666 | QCString cs(line.value().asCString()); |
666 | snd.setData( cs ); | 667 | snd.setData( cs ); |
667 | } | 668 | } |
668 | else if ( params.contains( "value" ) ) { | 669 | else if ( params.contains( "value" ) ) { |
669 | if ( line.parameter( "value" ).lower() == "uri" ) | 670 | if ( line.parameter( "value" ).lower() == "uri" ) |
670 | snd.setUrl( line.value().asString() ); | 671 | snd.setUrl( line.value().asString() ); |
671 | } | 672 | } |
672 | 673 | ||
673 | /* TODO: support sound types | 674 | /* TODO: support sound types |
674 | if ( params.contains( "type" ) ) | 675 | if ( params.contains( "type" ) ) |
675 | snd.setType( line.parameter( "type" ) ); | 676 | snd.setType( line.parameter( "type" ) ); |
676 | */ | 677 | */ |
677 | 678 | ||
678 | return snd; | 679 | return snd; |
679 | } | 680 | } |
680 | 681 | ||
681 | VCardLine VCardTool::createSound( const Sound &snd ) | 682 | VCardLine VCardTool::createSound( const Sound &snd ) |
682 | { | 683 | { |
683 | VCardLine line( "SOUND" ); | 684 | VCardLine line( "SOUND" ); |
684 | 685 | ||
685 | if ( snd.isIntern() ) { | 686 | if ( snd.isIntern() ) { |
686 | if ( !snd.data().isEmpty() ) { | 687 | if ( !snd.data().isEmpty() ) { |
687 | qDebug("VCardTool::createSound has to be verified"); | 688 | qDebug("VCardTool::createSound has to be verified"); |
688 | //US line.setValue( snd.data() ); | 689 | //US line.setValue( snd.data() ); |
689 | 690 | ||
690 | //US I am not sure if this is correct | 691 | //US I am not sure if this is correct |
691 | QCString cs(snd.data()); | 692 | QCString cs(snd.data()); |
692 | line.setValue( cs ); | 693 | line.setValue( cs ); |
693 | 694 | ||
694 | 695 | ||
695 | line.addParameter( "encoding", "b" ); | 696 | line.addParameter( "encoding", "b" ); |
696 | // TODO: need to store sound type!!! | 697 | // TODO: need to store sound type!!! |
697 | } | 698 | } |
698 | } else if ( !snd.url().isEmpty() ) { | 699 | } else if ( !snd.url().isEmpty() ) { |
699 | line.setValue( snd.url() ); | 700 | line.setValue( snd.url() ); |
700 | line.addParameter( "value", "URI" ); | 701 | line.addParameter( "value", "URI" ); |
701 | } | 702 | } |
702 | 703 | ||
703 | return line; | 704 | return line; |
704 | } | 705 | } |
705 | 706 | ||
706 | Key VCardTool::parseKey( const VCardLine &line ) | 707 | Key VCardTool::parseKey( const VCardLine &line ) |
707 | { | 708 | { |
708 | Key key; | 709 | Key key; |
709 | 710 | ||
710 | QStringList params = line.parameterList(); | 711 | QStringList params = line.parameterList(); |
711 | if ( params.contains( "encoding" ) ) { | 712 | if ( params.contains( "encoding" ) ) { |
712 | qDebug("VCardTool::parseKey has to be verified"); | 713 | qDebug("VCardTool::parseKey has to be verified"); |
713 | //US key.setBinaryData( line.value().asByteArray() ); | 714 | //US key.setBinaryData( line.value().asByteArray() ); |
714 | 715 | ||
715 | //US I am not sure if this is correct | 716 | //US I am not sure if this is correct |
716 | QCString cs( line.value().asCString() ); | 717 | QCString cs( line.value().asCString() ); |
717 | key.setBinaryData( cs ); | 718 | key.setBinaryData( cs ); |
718 | } | 719 | } |
719 | else | 720 | else |
720 | key.setTextData( line.value().asString() ); | 721 | key.setTextData( line.value().asString() ); |
721 | 722 | ||
722 | if ( params.contains( "type" ) ) { | 723 | if ( params.contains( "type" ) ) { |
723 | if ( line.parameter( "type" ).lower() == "x509" ) | 724 | if ( line.parameter( "type" ).lower() == "x509" ) |
724 | key.setType( Key::X509 ); | 725 | key.setType( Key::X509 ); |
725 | else if ( line.parameter( "type" ).lower() == "pgp" ) | 726 | else if ( line.parameter( "type" ).lower() == "pgp" ) |
726 | key.setType( Key::PGP ); | 727 | key.setType( Key::PGP ); |
727 | else { | 728 | else { |
728 | key.setType( Key::Custom ); | 729 | key.setType( Key::Custom ); |
729 | key.setCustomTypeString( line.parameter( "type" ) ); | 730 | key.setCustomTypeString( line.parameter( "type" ) ); |
730 | } | 731 | } |
731 | } | 732 | } |
732 | 733 | ||
733 | return key; | 734 | return key; |
734 | } | 735 | } |
735 | 736 | ||
736 | VCardLine VCardTool::createKey( const Key &key ) | 737 | VCardLine VCardTool::createKey( const Key &key ) |
737 | { | 738 | { |
738 | VCardLine line( "KEY" ); | 739 | VCardLine line( "KEY" ); |
739 | 740 | ||
740 | if ( key.isBinary() ) { | 741 | if ( key.isBinary() ) { |
741 | if ( !key.binaryData().isEmpty() ) { | 742 | if ( !key.binaryData().isEmpty() ) { |
742 | qDebug("VCardTool::createKey has to be verified"); | 743 | qDebug("VCardTool::createKey has to be verified"); |
743 | //US line.setValue( key.binaryData() ); | 744 | //US line.setValue( key.binaryData() ); |
744 | //US I am not sure if this is correct | 745 | //US I am not sure if this is correct |
745 | QCString cs(key.binaryData()); | 746 | QCString cs(key.binaryData()); |
746 | line.setValue( cs ); | 747 | line.setValue( cs ); |
747 | 748 | ||
748 | 749 | ||
749 | line.addParameter( "encoding", "b" ); | 750 | line.addParameter( "encoding", "b" ); |
750 | } | 751 | } |
751 | } else if ( !key.textData().isEmpty() ) | 752 | } else if ( !key.textData().isEmpty() ) |
752 | line.setValue( key.textData() ); | 753 | line.setValue( key.textData() ); |
753 | 754 | ||
754 | if ( key.type() == Key::X509 ) | 755 | if ( key.type() == Key::X509 ) |
755 | line.addParameter( "type", "X509" ); | 756 | line.addParameter( "type", "X509" ); |
756 | else if ( key.type() == Key::PGP ) | 757 | else if ( key.type() == Key::PGP ) |
757 | line.addParameter( "type", "PGP" ); | 758 | line.addParameter( "type", "PGP" ); |
758 | else if ( key.type() == Key::Custom ) | 759 | else if ( key.type() == Key::Custom ) |
759 | line.addParameter( "type", key.customTypeString() ); | 760 | line.addParameter( "type", key.customTypeString() ); |
760 | 761 | ||
761 | return line; | 762 | return line; |
762 | } | 763 | } |
763 | 764 | ||
764 | Secrecy VCardTool::parseSecrecy( const VCardLine &line ) | 765 | Secrecy VCardTool::parseSecrecy( const VCardLine &line ) |
765 | { | 766 | { |
766 | Secrecy secrecy; | 767 | Secrecy secrecy; |
767 | 768 | ||
768 | if ( line.value().asString().lower() == "public" ) | 769 | if ( line.value().asString().lower() == "public" ) |
769 | secrecy.setType( Secrecy::Public ); | 770 | secrecy.setType( Secrecy::Public ); |
770 | if ( line.value().asString().lower() == "private" ) | 771 | if ( line.value().asString().lower() == "private" ) |
771 | secrecy.setType( Secrecy::Private ); | 772 | secrecy.setType( Secrecy::Private ); |
772 | if ( line.value().asString().lower() == "confidential" ) | 773 | if ( line.value().asString().lower() == "confidential" ) |
773 | secrecy.setType( Secrecy::Confidential ); | 774 | secrecy.setType( Secrecy::Confidential ); |
774 | 775 | ||
775 | return secrecy; | 776 | return secrecy; |
776 | } | 777 | } |
777 | 778 | ||
778 | VCardLine VCardTool::createSecrecy( const Secrecy &secrecy ) | 779 | VCardLine VCardTool::createSecrecy( const Secrecy &secrecy ) |
779 | { | 780 | { |
780 | VCardLine line( "CLASS" ); | 781 | VCardLine line( "CLASS" ); |
781 | 782 | ||
782 | int type = secrecy.type(); | 783 | int type = secrecy.type(); |
783 | 784 | ||
784 | if ( type == Secrecy::Public ) | 785 | if ( type == Secrecy::Public ) |
785 | line.setValue( "PUBLIC" ); | 786 | line.setValue( "PUBLIC" ); |
786 | else if ( type == Secrecy::Private ) | 787 | else if ( type == Secrecy::Private ) |
787 | line.setValue( "PRIVATE" ); | 788 | line.setValue( "PRIVATE" ); |
788 | else if ( type == Secrecy::Confidential ) | 789 | else if ( type == Secrecy::Confidential ) |
789 | line.setValue( "CONFIDENTIAL" ); | 790 | line.setValue( "CONFIDENTIAL" ); |
790 | 791 | ||
791 | return line; | 792 | return line; |
792 | } | 793 | } |
793 | 794 | ||
794 | Agent VCardTool::parseAgent( const VCardLine &line ) | 795 | Agent VCardTool::parseAgent( const VCardLine &line ) |
795 | { | 796 | { |
796 | Agent agent; | 797 | Agent agent; |
797 | 798 | ||
798 | QStringList params = line.parameterList(); | 799 | QStringList params = line.parameterList(); |
799 | if ( params.contains( "value" ) ) { | 800 | if ( params.contains( "value" ) ) { |
800 | if ( line.parameter( "value" ).lower() == "uri" ) | 801 | if ( line.parameter( "value" ).lower() == "uri" ) |
801 | agent.setUrl( line.value().asString() ); | 802 | agent.setUrl( line.value().asString() ); |
802 | } else { | 803 | } else { |
803 | QString str = line.value().asString(); | 804 | QString str = line.value().asString(); |
804 | 805 | ||
805 | //US using the old implementation instead | 806 | //US using the old implementation instead |
806 | qDebug("VCardTool::parseAgent has to be verified"); | 807 | qDebug("VCardTool::parseAgent has to be verified"); |
807 | /*US | 808 | /*US |
808 | str.replace( "\\n", "\r\n" ); | 809 | str.replace( "\\n", "\r\n" ); |
809 | str.replace( "\\N", "\r\n" ); | 810 | str.replace( "\\N", "\r\n" ); |
810 | str.replace( "\\;", ";" ); | 811 | str.replace( "\\;", ";" ); |
811 | str.replace( "\\:", ":" ); | 812 | str.replace( "\\:", ":" ); |
812 | str.replace( "\\,", "," ); | 813 | str.replace( "\\,", "," ); |
813 | */ | 814 | */ |
814 | str.replace( QRegExp("\\n") , "\r\n" ); | 815 | str.replace( QRegExp("\\n") , "\r\n" ); |
815 | str.replace( QRegExp("\\N") , "\r\n" ); | 816 | str.replace( QRegExp("\\N") , "\r\n" ); |
816 | str.replace( QRegExp("\\;") , ";" ); | 817 | str.replace( QRegExp("\\;") , ";" ); |
817 | str.replace( QRegExp("\\:") , ":" ); | 818 | str.replace( QRegExp("\\:") , ":" ); |
818 | str.replace( QRegExp("\\,") , "," ); | 819 | str.replace( QRegExp("\\,") , "," ); |
819 | 820 | ||
820 | Addressee::List list = parseVCards( str ); | 821 | Addressee::List list = parseVCards( str ); |
821 | if ( list.count() > 0 ) { | 822 | if ( list.count() > 0 ) { |
822 | Addressee *addr = new Addressee; | 823 | Addressee *addr = new Addressee; |
823 | *addr = list[ 0 ]; | 824 | *addr = list[ 0 ]; |
824 | agent.setAddressee( addr ); | 825 | agent.setAddressee( addr ); |
825 | } | 826 | } |
826 | } | 827 | } |
827 | 828 | ||
828 | return agent; | 829 | return agent; |
829 | } | 830 | } |
830 | 831 | ||
831 | VCardLine VCardTool::createAgent( VCard::Version version, const Agent &agent ) | 832 | VCardLine VCardTool::createAgent( VCard::Version version, const Agent &agent ) |
832 | { | 833 | { |
833 | VCardLine line( "AGENT" ); | 834 | VCardLine line( "AGENT" ); |
834 | 835 | ||
835 | if ( agent.isIntern() ) { | 836 | if ( agent.isIntern() ) { |
836 | if ( agent.addressee() != 0 ) { | 837 | if ( agent.addressee() != 0 ) { |
837 | Addressee::List list; | 838 | Addressee::List list; |
838 | list.append( *agent.addressee() ); | 839 | list.append( *agent.addressee() ); |
839 | 840 | ||
840 | QString str = createVCards( list, version ); | 841 | QString str = createVCards( list, version ); |
841 | 842 | ||
842 | //US using the old implementation instead | 843 | //US using the old implementation instead |
843 | qDebug("VCardTool::createAgent has to be verified"); | 844 | qDebug("VCardTool::createAgent has to be verified"); |
844 | /*US | 845 | /*US |
845 | str.replace( "\r\n", "\\n" ); | 846 | str.replace( "\r\n", "\\n" ); |
846 | str.replace( ";", "\\;" ); | 847 | str.replace( ";", "\\;" ); |
847 | str.replace( ":", "\\:" ); | 848 | str.replace( ":", "\\:" ); |
848 | str.replace( ",", "\\," ); | 849 | str.replace( ",", "\\," ); |
849 | */ | 850 | */ |
850 | str.replace( QRegExp("\r\n"), "\\n" ); | 851 | str.replace( QRegExp("\r\n"), "\\n" ); |
851 | str.replace( QRegExp(";"), "\\;" ); | 852 | str.replace( QRegExp(";"), "\\;" ); |
852 | str.replace( QRegExp(":"), "\\:" ); | 853 | str.replace( QRegExp(":"), "\\:" ); |
853 | str.replace( QRegExp(","), "\\," ); | 854 | str.replace( QRegExp(","), "\\," ); |
854 | line.setValue( str ); | 855 | line.setValue( str ); |
855 | } | 856 | } |
856 | } else if ( !agent.url().isEmpty() ) { | 857 | } else if ( !agent.url().isEmpty() ) { |
857 | line.setValue( agent.url() ); | 858 | line.setValue( agent.url() ); |
858 | line.addParameter( "value", "URI" ); | 859 | line.addParameter( "value", "URI" ); |
859 | } | 860 | } |
860 | 861 | ||
861 | return line; | 862 | return line; |
862 | } | 863 | } |
863 | 864 | ||
864 | QStringList VCardTool::splitString( const QChar &sep, const QString &str ) | 865 | QStringList VCardTool::splitString( const QChar &sep, const QString &str ) |
865 | { | 866 | { |
866 | QStringList list; | 867 | QStringList list; |
867 | QString value( str ); | 868 | QString value( str ); |
868 | 869 | ||
869 | int start = 0; | 870 | int start = 0; |
870 | int pos = value.find( sep, start ); | 871 | int pos = value.find( sep, start ); |
871 | 872 | ||
872 | while ( pos != -1 ) { | 873 | while ( pos != -1 ) { |
873 | if ( value[ pos - 1 ] != '\\' ) { | 874 | if ( value[ pos - 1 ] != '\\' ) { |
874 | if ( pos > start && pos <= (int)value.length() ) | 875 | if ( pos > start && pos <= (int)value.length() ) |
875 | list << value.mid( start, pos - start ); | 876 | list << value.mid( start, pos - start ); |
876 | else | 877 | else |
877 | list << QString::null; | 878 | list << QString::null; |
878 | 879 | ||
879 | start = pos + 1; | 880 | start = pos + 1; |
880 | pos = value.find( sep, start ); | 881 | pos = value.find( sep, start ); |
881 | } else { | 882 | } else { |
882 | if ( pos != 0 ) { | 883 | if ( pos != 0 ) { |
883 | value.replace( pos - 1, 2, sep ); | 884 | value.replace( pos - 1, 2, sep ); |
884 | pos = value.find( sep, pos ); | 885 | pos = value.find( sep, pos ); |
885 | } else | 886 | } else |
886 | pos = value.find( sep, pos + 1 ); | 887 | pos = value.find( sep, pos + 1 ); |
887 | } | 888 | } |
888 | } | 889 | } |
889 | 890 | ||
890 | int l = value.length() - 1; | 891 | int l = value.length() - 1; |
891 | if ( value.mid( start, l - start + 1 ).length() > 0 ) | 892 | if ( value.mid( start, l - start + 1 ).length() > 0 ) |
892 | list << value.mid( start, l - start + 1 ); | 893 | list << value.mid( start, l - start + 1 ); |
893 | else | 894 | else |
894 | list << QString::null; | 895 | list << QString::null; |
895 | 896 | ||
896 | return list; | 897 | return list; |
897 | } | 898 | } |