author | zecke <zecke> | 2003-02-16 22:25:46 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-16 22:25:46 (UTC) |
commit | 4d0e8ffd8518fe24ed94cfcf92eeff666b014094 (patch) (unidiff) | |
tree | 86a0bec752418c409cbc9ad95d6479997dfaf909 /libopie2/opiepim | |
parent | 8ecc375c803dc57b160bd0335891fcaf4f6de1df (diff) | |
download | opie-4d0e8ffd8518fe24ed94cfcf92eeff666b014094.zip opie-4d0e8ffd8518fe24ed94cfcf92eeff666b014094.tar.gz opie-4d0e8ffd8518fe24ed94cfcf92eeff666b014094.tar.bz2 |
0000276 Fix for that bug.. or better temp workaround
A Preferred Number is HOME|VOICE
A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test
triggers both
and the cell phone number overrides the other entries..
as a temp I check that it's not equal to HOME|VOICE|CELL before setting the
number
The right and final fix would be to reorder the if statement to make it
if else based and the less common thing put to the bottom
OTodoAccessVcal fix the date for beaming
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | 82 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessvcal.cpp | 7 |
2 files changed, 54 insertions, 35 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp index 1dc6b48..622d40a 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | |||
@@ -1,356 +1,372 @@ | |||
1 | /* | 1 | /* |
2 | * VCard Backend for the OPIE-Contact Database. | 2 | * VCard Backend for the OPIE-Contact Database. |
3 | * | 3 | * |
4 | * Copyright (C) 2000 Trolltech AS. All rights reserved. | 4 | * Copyright (C) 2000 Trolltech AS. All rights reserved. |
5 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 5 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
6 | * | 6 | * |
7 | * ===================================================================== | 7 | * ===================================================================== |
8 | *This program is free software; you can redistribute it and/or | 8 | *This program is free software; you can redistribute it and/or |
9 | *modify it under the terms of the GNU Library General Public | 9 | *modify it under the terms of the GNU Library General Public |
10 | * License as published by the Free Software Foundation; either | 10 | * License as published by the Free Software Foundation; either |
11 | * version 2 of the License, or (at your option) any later version. | 11 | * version 2 of the License, or (at your option) any later version. |
12 | * ===================================================================== | 12 | * ===================================================================== |
13 | * ToDo: | 13 | * ToDo: |
14 | * | 14 | * |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * Version: $Id$ | 16 | * Version: $Id$ |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * History: | 18 | * History: |
19 | * $Log$ | 19 | * $Log$ |
20 | * Revision 1.7 2003/02/16 22:25:46 zecke | ||
21 | * 0000276 Fix for that bug.. or better temp workaround | ||
22 | * A Preferred Number is HOME|VOICE | ||
23 | * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test | ||
24 | * triggers both | ||
25 | * and the cell phone number overrides the other entries.. | ||
26 | * | ||
27 | * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the | ||
28 | * number | ||
29 | * | ||
30 | * The right and final fix would be to reorder the if statement to make it | ||
31 | * if else based and the less common thing put to the bottom | ||
32 | * | ||
33 | * OTodoAccessVcal fix the date for beaming | ||
34 | * | ||
20 | * Revision 1.6 2003/01/13 15:49:31 eilers | 35 | * Revision 1.6 2003/01/13 15:49:31 eilers |
21 | * Fixing crash when businesscard.vcf is missing.. | 36 | * Fixing crash when businesscard.vcf is missing.. |
22 | * | 37 | * |
23 | * Revision 1.5 2002/12/07 13:26:22 eilers | 38 | * Revision 1.5 2002/12/07 13:26:22 eilers |
24 | * Fixing bug in storing anniversary.. | 39 | * Fixing bug in storing anniversary.. |
25 | * | 40 | * |
26 | * Revision 1.4 2002/11/13 14:14:51 eilers | 41 | * Revision 1.4 2002/11/13 14:14:51 eilers |
27 | * Added sorted for Contacts.. | 42 | * Added sorted for Contacts.. |
28 | * | 43 | * |
29 | * Revision 1.3 2002/11/11 16:41:09 kergoth | 44 | * Revision 1.3 2002/11/11 16:41:09 kergoth |
30 | * no default arguments in implementation | 45 | * no default arguments in implementation |
31 | * | 46 | * |
32 | * Revision 1.2 2002/11/10 15:41:53 eilers | 47 | * Revision 1.2 2002/11/10 15:41:53 eilers |
33 | * Bugfixes.. | 48 | * Bugfixes.. |
34 | * | 49 | * |
35 | * Revision 1.1 2002/11/09 14:34:52 eilers | 50 | * Revision 1.1 2002/11/09 14:34:52 eilers |
36 | * Added VCard Backend. | 51 | * Added VCard Backend. |
37 | * | 52 | * |
38 | */ | 53 | */ |
39 | #include "ocontactaccessbackend_vcard.h" | 54 | #include "ocontactaccessbackend_vcard.h" |
40 | #include "../../library/backend/vobject_p.h" | 55 | #include "../../library/backend/vobject_p.h" |
41 | #include "../../library/backend/qfiledirect_p.h" | 56 | #include "../../library/backend/qfiledirect_p.h" |
42 | 57 | ||
43 | #include <qpe/timeconversion.h> | 58 | #include <qpe/timeconversion.h> |
44 | 59 | ||
45 | #include <qfile.h> | 60 | #include <qfile.h> |
46 | 61 | ||
47 | OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename ): | 62 | OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename ): |
48 | m_dirty( false ), | 63 | m_dirty( false ), |
49 | m_file( filename ) | 64 | m_file( filename ) |
50 | { | 65 | { |
51 | load(); | 66 | load(); |
52 | } | 67 | } |
53 | 68 | ||
54 | 69 | ||
55 | bool OContactAccessBackend_VCard::load () | 70 | bool OContactAccessBackend_VCard::load () |
56 | { | 71 | { |
57 | m_map.clear(); | 72 | m_map.clear(); |
58 | m_dirty = false; | 73 | m_dirty = false; |
59 | 74 | ||
60 | VObject* obj = 0l; | 75 | VObject* obj = 0l; |
61 | 76 | ||
62 | if ( QFile( m_file ).exists() ){ | 77 | if ( QFile( m_file ).exists() ){ |
63 | obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 78 | obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
64 | if ( !obj ) | 79 | if ( !obj ) |
65 | return false; | 80 | return false; |
66 | }else{ | 81 | }else{ |
67 | qWarning("File \"%s\" not found !", m_file.latin1() ); | 82 | qWarning("File \"%s\" not found !", m_file.latin1() ); |
68 | return false; | 83 | return false; |
69 | } | 84 | } |
70 | 85 | ||
71 | while ( obj ) { | 86 | while ( obj ) { |
72 | OContact con = parseVObject( obj ); | 87 | OContact con = parseVObject( obj ); |
73 | /* | 88 | /* |
74 | * if uid is 0 assign a new one | 89 | * if uid is 0 assign a new one |
75 | * this at least happens on | 90 | * this at least happens on |
76 | * Nokia6210 | 91 | * Nokia6210 |
77 | */ | 92 | */ |
78 | if ( con.uid() == 0 ){ | 93 | if ( con.uid() == 0 ){ |
79 | con.setUid( 1 ); | 94 | con.setUid( 1 ); |
80 | qWarning("assigned new uid %d",con.uid() ); | 95 | qWarning("assigned new uid %d",con.uid() ); |
81 | } | 96 | } |
82 | 97 | ||
83 | m_map.insert( con.uid(), con ); | 98 | m_map.insert( con.uid(), con ); |
84 | 99 | ||
85 | VObject *t = obj; | 100 | VObject *t = obj; |
86 | obj = nextVObjectInList(obj); | 101 | obj = nextVObjectInList(obj); |
87 | cleanVObject( t ); | 102 | cleanVObject( t ); |
88 | } | 103 | } |
89 | 104 | ||
90 | return true; | 105 | return true; |
91 | 106 | ||
92 | } | 107 | } |
93 | bool OContactAccessBackend_VCard::reload() | 108 | bool OContactAccessBackend_VCard::reload() |
94 | { | 109 | { |
95 | return load(); | 110 | return load(); |
96 | } | 111 | } |
97 | bool OContactAccessBackend_VCard::save() | 112 | bool OContactAccessBackend_VCard::save() |
98 | { | 113 | { |
99 | if (!m_dirty ) | 114 | if (!m_dirty ) |
100 | return true; | 115 | return true; |
101 | 116 | ||
102 | QFileDirect file( m_file ); | 117 | QFileDirect file( m_file ); |
103 | if (!file.open(IO_WriteOnly ) ) | 118 | if (!file.open(IO_WriteOnly ) ) |
104 | return false; | 119 | return false; |
105 | 120 | ||
106 | VObject *obj; | 121 | VObject *obj; |
107 | obj = newVObject( VCCalProp ); | 122 | obj = newVObject( VCCalProp ); |
108 | addPropValue( obj, VCVersionProp, "1.0" ); | 123 | addPropValue( obj, VCVersionProp, "1.0" ); |
109 | 124 | ||
110 | VObject *vo; | 125 | VObject *vo; |
111 | for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 126 | for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
112 | vo = createVObject( *it ); | 127 | vo = createVObject( *it ); |
113 | writeVObject( file.directHandle() , vo ); | 128 | writeVObject( file.directHandle() , vo ); |
114 | cleanVObject( vo ); | 129 | cleanVObject( vo ); |
115 | } | 130 | } |
116 | cleanStrTbl(); | 131 | cleanStrTbl(); |
117 | 132 | ||
118 | m_dirty = false; | 133 | m_dirty = false; |
119 | return true; | 134 | return true; |
120 | 135 | ||
121 | 136 | ||
122 | } | 137 | } |
123 | void OContactAccessBackend_VCard::clear () | 138 | void OContactAccessBackend_VCard::clear () |
124 | { | 139 | { |
125 | m_map.clear(); | 140 | m_map.clear(); |
126 | m_dirty = true; // ??? sure ? (se) | 141 | m_dirty = true; // ??? sure ? (se) |
127 | } | 142 | } |
128 | 143 | ||
129 | bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) | 144 | bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) |
130 | { | 145 | { |
131 | m_map.insert( newcontact.uid(), newcontact ); | 146 | m_map.insert( newcontact.uid(), newcontact ); |
132 | m_dirty = true; | 147 | m_dirty = true; |
133 | return true; | 148 | return true; |
134 | } | 149 | } |
135 | 150 | ||
136 | bool OContactAccessBackend_VCard::remove ( int uid ) | 151 | bool OContactAccessBackend_VCard::remove ( int uid ) |
137 | { | 152 | { |
138 | m_map.remove( uid ); | 153 | m_map.remove( uid ); |
139 | m_dirty = true; | 154 | m_dirty = true; |
140 | return true; | 155 | return true; |
141 | } | 156 | } |
142 | 157 | ||
143 | bool OContactAccessBackend_VCard::replace ( const OContact &contact ) | 158 | bool OContactAccessBackend_VCard::replace ( const OContact &contact ) |
144 | { | 159 | { |
145 | m_map.replace( contact.uid(), contact ); | 160 | m_map.replace( contact.uid(), contact ); |
146 | m_dirty = true; | 161 | m_dirty = true; |
147 | return true; | 162 | return true; |
148 | } | 163 | } |
149 | 164 | ||
150 | OContact OContactAccessBackend_VCard::find ( int uid ) const | 165 | OContact OContactAccessBackend_VCard::find ( int uid ) const |
151 | { | 166 | { |
152 | return m_map[uid]; | 167 | return m_map[uid]; |
153 | } | 168 | } |
154 | 169 | ||
155 | QArray<int> OContactAccessBackend_VCard::allRecords() const | 170 | QArray<int> OContactAccessBackend_VCard::allRecords() const |
156 | { | 171 | { |
157 | QArray<int> ar( m_map.count() ); | 172 | QArray<int> ar( m_map.count() ); |
158 | QMap<int, OContact>::ConstIterator it; | 173 | QMap<int, OContact>::ConstIterator it; |
159 | int i = 0; | 174 | int i = 0; |
160 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 175 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |
161 | ar[i] = it.key(); | 176 | ar[i] = it.key(); |
162 | i++; | 177 | i++; |
163 | } | 178 | } |
164 | return ar; | 179 | return ar; |
165 | } | 180 | } |
166 | 181 | ||
167 | // Not implemented | 182 | // Not implemented |
168 | QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int ) | 183 | QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int ) |
169 | { | 184 | { |
170 | QArray<int> ar(0); | 185 | QArray<int> ar(0); |
171 | return ar; | 186 | return ar; |
172 | } | 187 | } |
173 | 188 | ||
174 | // Not implemented | 189 | // Not implemented |
175 | QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const | 190 | QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const |
176 | { | 191 | { |
177 | QArray<int> ar(0); | 192 | QArray<int> ar(0); |
178 | return ar; | 193 | return ar; |
179 | } | 194 | } |
180 | 195 | ||
181 | const uint OContactAccessBackend_VCard::querySettings() | 196 | const uint OContactAccessBackend_VCard::querySettings() |
182 | { | 197 | { |
183 | return 0; // No search possible | 198 | return 0; // No search possible |
184 | } | 199 | } |
185 | 200 | ||
186 | bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const | 201 | bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const |
187 | { | 202 | { |
188 | return false; // No search possible, therefore all settings invalid ;) | 203 | return false; // No search possible, therefore all settings invalid ;) |
189 | } | 204 | } |
190 | 205 | ||
191 | bool OContactAccessBackend_VCard::wasChangedExternally() | 206 | bool OContactAccessBackend_VCard::wasChangedExternally() |
192 | { | 207 | { |
193 | return false; // Don't expect concurrent access | 208 | return false; // Don't expect concurrent access |
194 | } | 209 | } |
195 | 210 | ||
196 | // Not implemented | 211 | // Not implemented |
197 | QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int ) | 212 | QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int ) |
198 | { | 213 | { |
199 | QArray<int> ar(0); | 214 | QArray<int> ar(0); |
200 | return ar; | 215 | return ar; |
201 | } | 216 | } |
202 | 217 | ||
203 | // *** Private stuff *** | 218 | // *** Private stuff *** |
204 | 219 | ||
205 | 220 | ||
206 | OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) | 221 | OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) |
207 | { | 222 | { |
208 | OContact c; | 223 | OContact c; |
209 | 224 | ||
210 | VObjectIterator it; | 225 | VObjectIterator it; |
211 | initPropIterator( &it, obj ); | 226 | initPropIterator( &it, obj ); |
212 | while( moreIteration( &it ) ) { | 227 | while( moreIteration( &it ) ) { |
213 | VObject *o = nextVObject( &it ); | 228 | VObject *o = nextVObject( &it ); |
214 | QCString name = vObjectName( o ); | 229 | QCString name = vObjectName( o ); |
215 | QCString value = vObjectStringZValue( o ); | 230 | QCString value = vObjectStringZValue( o ); |
216 | if ( name == VCNameProp ) { | 231 | if ( name == VCNameProp ) { |
217 | VObjectIterator nit; | 232 | VObjectIterator nit; |
218 | initPropIterator( &nit, o ); | 233 | initPropIterator( &nit, o ); |
219 | while( moreIteration( &nit ) ) { | 234 | while( moreIteration( &nit ) ) { |
220 | VObject *o = nextVObject( &nit ); | 235 | VObject *o = nextVObject( &nit ); |
221 | QCString name = vObjectTypeInfo( o ); | 236 | QCString name = vObjectTypeInfo( o ); |
222 | QString value = vObjectStringZValue( o ); | 237 | QString value = vObjectStringZValue( o ); |
223 | if ( name == VCNamePrefixesProp ) | 238 | if ( name == VCNamePrefixesProp ) |
224 | c.setTitle( value ); | 239 | c.setTitle( value ); |
225 | else if ( name == VCNameSuffixesProp ) | 240 | else if ( name == VCNameSuffixesProp ) |
226 | c.setSuffix( value ); | 241 | c.setSuffix( value ); |
227 | else if ( name == VCFamilyNameProp ) | 242 | else if ( name == VCFamilyNameProp ) |
228 | c.setLastName( value ); | 243 | c.setLastName( value ); |
229 | else if ( name == VCGivenNameProp ) | 244 | else if ( name == VCGivenNameProp ) |
230 | c.setFirstName( value ); | 245 | c.setFirstName( value ); |
231 | else if ( name == VCAdditionalNamesProp ) | 246 | else if ( name == VCAdditionalNamesProp ) |
232 | c.setMiddleName( value ); | 247 | c.setMiddleName( value ); |
233 | } | 248 | } |
234 | } | 249 | } |
235 | else if ( name == VCAdrProp ) { | 250 | else if ( name == VCAdrProp ) { |
236 | bool work = TRUE; // default address is work address | 251 | bool work = TRUE; // default address is work address |
237 | QString street; | 252 | QString street; |
238 | QString city; | 253 | QString city; |
239 | QString region; | 254 | QString region; |
240 | QString postal; | 255 | QString postal; |
241 | QString country; | 256 | QString country; |
242 | 257 | ||
243 | VObjectIterator nit; | 258 | VObjectIterator nit; |
244 | initPropIterator( &nit, o ); | 259 | initPropIterator( &nit, o ); |
245 | while( moreIteration( &nit ) ) { | 260 | while( moreIteration( &nit ) ) { |
246 | VObject *o = nextVObject( &nit ); | 261 | VObject *o = nextVObject( &nit ); |
247 | QCString name = vObjectName( o ); | 262 | QCString name = vObjectName( o ); |
248 | QString value = vObjectStringZValue( o ); | 263 | QString value = vObjectStringZValue( o ); |
249 | if ( name == VCHomeProp ) | 264 | if ( name == VCHomeProp ) |
250 | work = FALSE; | 265 | work = FALSE; |
251 | else if ( name == VCWorkProp ) | 266 | else if ( name == VCWorkProp ) |
252 | work = TRUE; | 267 | work = TRUE; |
253 | else if ( name == VCStreetAddressProp ) | 268 | else if ( name == VCStreetAddressProp ) |
254 | street = value; | 269 | street = value; |
255 | else if ( name == VCCityProp ) | 270 | else if ( name == VCCityProp ) |
256 | city = value; | 271 | city = value; |
257 | else if ( name == VCRegionProp ) | 272 | else if ( name == VCRegionProp ) |
258 | region = value; | 273 | region = value; |
259 | else if ( name == VCPostalCodeProp ) | 274 | else if ( name == VCPostalCodeProp ) |
260 | postal = value; | 275 | postal = value; |
261 | else if ( name == VCCountryNameProp ) | 276 | else if ( name == VCCountryNameProp ) |
262 | country = value; | 277 | country = value; |
263 | } | 278 | } |
264 | if ( work ) { | 279 | if ( work ) { |
265 | c.setBusinessStreet( street ); | 280 | c.setBusinessStreet( street ); |
266 | c.setBusinessCity( city ); | 281 | c.setBusinessCity( city ); |
267 | c.setBusinessCountry( country ); | 282 | c.setBusinessCountry( country ); |
268 | c.setBusinessZip( postal ); | 283 | c.setBusinessZip( postal ); |
269 | c.setBusinessState( region ); | 284 | c.setBusinessState( region ); |
270 | } else { | 285 | } else { |
271 | c.setHomeStreet( street ); | 286 | c.setHomeStreet( street ); |
272 | c.setHomeCity( city ); | 287 | c.setHomeCity( city ); |
273 | c.setHomeCountry( country ); | 288 | c.setHomeCountry( country ); |
274 | c.setHomeZip( postal ); | 289 | c.setHomeZip( postal ); |
275 | c.setHomeState( region ); | 290 | c.setHomeState( region ); |
276 | } | 291 | } |
277 | } | 292 | } |
278 | else if ( name == VCTelephoneProp ) { | 293 | else if ( name == VCTelephoneProp ) { |
279 | enum { | 294 | enum { |
280 | HOME = 0x01, | 295 | HOME = 0x01, |
281 | WORK = 0x02, | 296 | WORK = 0x02, |
282 | VOICE = 0x04, | 297 | VOICE = 0x04, |
283 | CELL = 0x08, | 298 | CELL = 0x08, |
284 | FAX = 0x10, | 299 | FAX = 0x10, |
285 | PAGER = 0x20, | 300 | PAGER = 0x20, |
286 | UNKNOWN = 0x80 | 301 | UNKNOWN = 0x80 |
287 | }; | 302 | }; |
288 | int type = 0; | 303 | int type = 0; |
289 | 304 | ||
290 | VObjectIterator nit; | 305 | VObjectIterator nit; |
291 | initPropIterator( &nit, o ); | 306 | initPropIterator( &nit, o ); |
292 | while( moreIteration( &nit ) ) { | 307 | while( moreIteration( &nit ) ) { |
293 | VObject *o = nextVObject( &nit ); | 308 | VObject *o = nextVObject( &nit ); |
294 | QCString name = vObjectTypeInfo( o ); | 309 | QCString name = vObjectTypeInfo( o ); |
295 | if ( name == VCHomeProp ) | 310 | if ( name == VCHomeProp ) |
296 | type |= HOME; | 311 | type |= HOME; |
297 | else if ( name == VCWorkProp ) | 312 | else if ( name == VCWorkProp ) |
298 | type |= WORK; | 313 | type |= WORK; |
299 | else if ( name == VCVoiceProp ) | 314 | else if ( name == VCVoiceProp ) |
300 | type |= VOICE; | 315 | type |= VOICE; |
301 | else if ( name == VCCellularProp ) | 316 | else if ( name == VCCellularProp ) |
302 | type |= CELL; | 317 | type |= CELL; |
303 | else if ( name == VCFaxProp ) | 318 | else if ( name == VCFaxProp ) |
304 | type |= FAX; | 319 | type |= FAX; |
305 | else if ( name == VCPagerProp ) | 320 | else if ( name == VCPagerProp ) |
306 | type |= PAGER; | 321 | type |= PAGER; |
307 | else if ( name == VCPreferredProp ) | 322 | else if ( name == VCPreferredProp ) |
308 | ; | 323 | ; |
309 | else | 324 | else |
310 | type |= UNKNOWN; | 325 | type |= UNKNOWN; |
311 | } | 326 | } |
312 | if ( (type & UNKNOWN) != UNKNOWN ) { | 327 | if ( (type & UNKNOWN) != UNKNOWN ) { |
313 | if ( ( type & (HOME|WORK) ) == 0 ) // default | 328 | if ( ( type & (HOME|WORK) ) == 0 ) // default |
314 | type |= HOME; | 329 | type |= HOME; |
315 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default | 330 | if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default |
316 | type |= VOICE; | 331 | type |= VOICE; |
317 | 332 | ||
318 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) | 333 | qWarning("value %s %d", value.data(), type ); |
334 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) | ||
319 | c.setHomePhone( value ); | 335 | c.setHomePhone( value ); |
320 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) | 336 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) |
321 | c.setHomeFax( value ); | 337 | c.setHomeFax( value ); |
322 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) | 338 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) |
323 | c.setHomeMobile( value ); | 339 | c.setHomeMobile( value ); |
324 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) | 340 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) ) |
325 | c.setBusinessPhone( value ); | 341 | c.setBusinessPhone( value ); |
326 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) | 342 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) |
327 | c.setBusinessFax( value ); | 343 | c.setBusinessFax( value ); |
328 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) | 344 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) |
329 | c.setBusinessMobile( value ); | 345 | c.setBusinessMobile( value ); |
330 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) | 346 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) |
331 | c.setBusinessPager( value ); | 347 | c.setBusinessPager( value ); |
332 | } | 348 | } |
333 | } | 349 | } |
334 | else if ( name == VCEmailAddressProp ) { | 350 | else if ( name == VCEmailAddressProp ) { |
335 | QString email = vObjectStringZValue( o ); | 351 | QString email = vObjectStringZValue( o ); |
336 | bool valid = TRUE; | 352 | bool valid = TRUE; |
337 | VObjectIterator nit; | 353 | VObjectIterator nit; |
338 | initPropIterator( &nit, o ); | 354 | initPropIterator( &nit, o ); |
339 | while( moreIteration( &nit ) ) { | 355 | while( moreIteration( &nit ) ) { |
340 | VObject *o = nextVObject( &nit ); | 356 | VObject *o = nextVObject( &nit ); |
341 | QCString name = vObjectTypeInfo( o ); | 357 | QCString name = vObjectTypeInfo( o ); |
342 | if ( name != VCInternetProp && name != VCHomeProp && | 358 | if ( name != VCInternetProp && name != VCHomeProp && |
343 | name != VCWorkProp && | 359 | name != VCWorkProp && |
344 | name != VCPreferredProp ) | 360 | name != VCPreferredProp ) |
345 | // ### preffered should map to default email | 361 | // ### preffered should map to default email |
346 | valid = FALSE; | 362 | valid = FALSE; |
347 | } | 363 | } |
348 | if ( valid ) { | 364 | if ( valid ) { |
349 | c.insertEmail( email ); | 365 | c.insertEmail( email ); |
350 | } | 366 | } |
351 | } | 367 | } |
352 | else if ( name == VCURLProp ) { | 368 | else if ( name == VCURLProp ) { |
353 | VObjectIterator nit; | 369 | VObjectIterator nit; |
354 | initPropIterator( &nit, o ); | 370 | initPropIterator( &nit, o ); |
355 | while( moreIteration( &nit ) ) { | 371 | while( moreIteration( &nit ) ) { |
356 | VObject *o = nextVObject( &nit ); | 372 | VObject *o = nextVObject( &nit ); |
@@ -377,203 +393,203 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) | |||
377 | } | 393 | } |
378 | } | 394 | } |
379 | else if ( name == VCTitleProp ) { | 395 | else if ( name == VCTitleProp ) { |
380 | c.setJobTitle( value ); | 396 | c.setJobTitle( value ); |
381 | } | 397 | } |
382 | else if ( name == "X-Qtopia-Profession" ) { | 398 | else if ( name == "X-Qtopia-Profession" ) { |
383 | c.setProfession( value ); | 399 | c.setProfession( value ); |
384 | } | 400 | } |
385 | else if ( name == "X-Qtopia-Manager" ) { | 401 | else if ( name == "X-Qtopia-Manager" ) { |
386 | c.setManager( value ); | 402 | c.setManager( value ); |
387 | } | 403 | } |
388 | else if ( name == "X-Qtopia-Assistant" ) { | 404 | else if ( name == "X-Qtopia-Assistant" ) { |
389 | c.setAssistant( value ); | 405 | c.setAssistant( value ); |
390 | } | 406 | } |
391 | else if ( name == "X-Qtopia-Spouse" ) { | 407 | else if ( name == "X-Qtopia-Spouse" ) { |
392 | c.setSpouse( value ); | 408 | c.setSpouse( value ); |
393 | } | 409 | } |
394 | else if ( name == "X-Qtopia-Gender" ) { | 410 | else if ( name == "X-Qtopia-Gender" ) { |
395 | c.setGender( value ); | 411 | c.setGender( value ); |
396 | } | 412 | } |
397 | else if ( name == "X-Qtopia-Anniversary" ) { | 413 | else if ( name == "X-Qtopia-Anniversary" ) { |
398 | c.setAnniversary( convVCardDateToDate( value ) ); | 414 | c.setAnniversary( convVCardDateToDate( value ) ); |
399 | } | 415 | } |
400 | else if ( name == "X-Qtopia-Nickname" ) { | 416 | else if ( name == "X-Qtopia-Nickname" ) { |
401 | c.setNickname( value ); | 417 | c.setNickname( value ); |
402 | } | 418 | } |
403 | else if ( name == "X-Qtopia-Children" ) { | 419 | else if ( name == "X-Qtopia-Children" ) { |
404 | c.setChildren( value ); | 420 | c.setChildren( value ); |
405 | } | 421 | } |
406 | else if ( name == VCBirthDateProp ) { | 422 | else if ( name == VCBirthDateProp ) { |
407 | // Reading Birthdate regarding RFC 2425 (5.8.4) | 423 | // Reading Birthdate regarding RFC 2425 (5.8.4) |
408 | c.setBirthday( convVCardDateToDate( value ) ); | 424 | c.setBirthday( convVCardDateToDate( value ) ); |
409 | 425 | ||
410 | } | 426 | } |
411 | 427 | ||
412 | #if 0 | 428 | #if 0 |
413 | else { | 429 | else { |
414 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); | 430 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); |
415 | VObjectIterator nit; | 431 | VObjectIterator nit; |
416 | initPropIterator( &nit, o ); | 432 | initPropIterator( &nit, o ); |
417 | while( moreIteration( &nit ) ) { | 433 | while( moreIteration( &nit ) ) { |
418 | VObject *o = nextVObject( &nit ); | 434 | VObject *o = nextVObject( &nit ); |
419 | QCString name = vObjectName( o ); | 435 | QCString name = vObjectName( o ); |
420 | QString value = vObjectStringZValue( o ); | 436 | QString value = vObjectStringZValue( o ); |
421 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); | 437 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); |
422 | } | 438 | } |
423 | } | 439 | } |
424 | #endif | 440 | #endif |
425 | } | 441 | } |
426 | c.setFileAs(); | 442 | c.setFileAs(); |
427 | return c; | 443 | return c; |
428 | } | 444 | } |
429 | 445 | ||
430 | 446 | ||
431 | VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) | 447 | VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) |
432 | { | 448 | { |
433 | VObject *vcard = newVObject( VCCardProp ); | 449 | VObject *vcard = newVObject( VCCardProp ); |
434 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 450 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
435 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 451 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
436 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 452 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
437 | 453 | ||
438 | // full name | 454 | // full name |
439 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); | 455 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); |
440 | 456 | ||
441 | // name properties | 457 | // name properties |
442 | VObject *name = safeAddProp( vcard, VCNameProp ); | 458 | VObject *name = safeAddProp( vcard, VCNameProp ); |
443 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); | 459 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); |
444 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); | 460 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); |
445 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); | 461 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); |
446 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); | 462 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); |
447 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); | 463 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); |
448 | 464 | ||
449 | // home properties | 465 | // home properties |
450 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); | 466 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); |
451 | safeAddProp( home_adr, VCHomeProp ); | 467 | safeAddProp( home_adr, VCHomeProp ); |
452 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); | 468 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); |
453 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); | 469 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); |
454 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); | 470 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); |
455 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); | 471 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); |
456 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); | 472 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); |
457 | 473 | ||
458 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); | 474 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); |
459 | safeAddProp( home_phone, VCHomeProp ); | 475 | safeAddProp( home_phone, VCHomeProp ); |
460 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); | 476 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); |
461 | safeAddProp( home_phone, VCHomeProp ); | 477 | safeAddProp( home_phone, VCHomeProp ); |
462 | safeAddProp( home_phone, VCCellularProp ); | 478 | safeAddProp( home_phone, VCCellularProp ); |
463 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); | 479 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); |
464 | safeAddProp( home_phone, VCHomeProp ); | 480 | safeAddProp( home_phone, VCHomeProp ); |
465 | safeAddProp( home_phone, VCFaxProp ); | 481 | safeAddProp( home_phone, VCFaxProp ); |
466 | 482 | ||
467 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); | 483 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); |
468 | safeAddProp( url, VCHomeProp ); | 484 | safeAddProp( url, VCHomeProp ); |
469 | 485 | ||
470 | // work properties | 486 | // work properties |
471 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); | 487 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); |
472 | safeAddProp( work_adr, VCWorkProp ); | 488 | safeAddProp( work_adr, VCWorkProp ); |
473 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); | 489 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); |
474 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); | 490 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); |
475 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); | 491 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); |
476 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); | 492 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); |
477 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); | 493 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); |
478 | 494 | ||
479 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); | 495 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); |
480 | safeAddProp( work_phone, VCWorkProp ); | 496 | safeAddProp( work_phone, VCWorkProp ); |
481 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); | 497 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); |
482 | safeAddProp( work_phone, VCWorkProp ); | 498 | safeAddProp( work_phone, VCWorkProp ); |
483 | safeAddProp( work_phone, VCCellularProp ); | 499 | safeAddProp( work_phone, VCCellularProp ); |
484 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); | 500 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); |
485 | safeAddProp( work_phone, VCWorkProp ); | 501 | safeAddProp( work_phone, VCWorkProp ); |
486 | safeAddProp( work_phone, VCFaxProp ); | 502 | safeAddProp( work_phone, VCFaxProp ); |
487 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); | 503 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); |
488 | safeAddProp( work_phone, VCWorkProp ); | 504 | safeAddProp( work_phone, VCWorkProp ); |
489 | safeAddProp( work_phone, VCPagerProp ); | 505 | safeAddProp( work_phone, VCPagerProp ); |
490 | 506 | ||
491 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); | 507 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); |
492 | safeAddProp( url, VCWorkProp ); | 508 | safeAddProp( url, VCWorkProp ); |
493 | 509 | ||
494 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); | 510 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); |
495 | safeAddProp( title, VCWorkProp ); | 511 | safeAddProp( title, VCWorkProp ); |
496 | 512 | ||
497 | 513 | ||
498 | QStringList emails = c.emailList(); | 514 | QStringList emails = c.emailList(); |
499 | emails.prepend( c.defaultEmail() ); | 515 | emails.prepend( c.defaultEmail() ); |
500 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 516 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
501 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); | 517 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); |
502 | safeAddProp( email, VCInternetProp ); | 518 | safeAddProp( email, VCInternetProp ); |
503 | } | 519 | } |
504 | 520 | ||
505 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); | 521 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); |
506 | 522 | ||
507 | // Exporting Birthday regarding RFC 2425 (5.8.4) | 523 | // Exporting Birthday regarding RFC 2425 (5.8.4) |
508 | if ( c.birthday().isValid() ){ | 524 | if ( c.birthday().isValid() ){ |
509 | qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); | 525 | qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); |
510 | safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); | 526 | safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); |
511 | } | 527 | } |
512 | 528 | ||
513 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 529 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
514 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 530 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
515 | safeAddPropValue( org, VCOrgNameProp, c.company() ); | 531 | safeAddPropValue( org, VCOrgNameProp, c.company() ); |
516 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); | 532 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); |
517 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); | 533 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); |
518 | } | 534 | } |
519 | 535 | ||
520 | // some values we have to export as custom fields | 536 | // some values we have to export as custom fields |
521 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); | 537 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); |
522 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); | 538 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); |
523 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); | 539 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); |
524 | 540 | ||
525 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); | 541 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); |
526 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); | 542 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |
527 | if ( c.anniversary().isValid() ){ | 543 | if ( c.anniversary().isValid() ){ |
528 | qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); | 544 | qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); |
529 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); | 545 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); |
530 | } | 546 | } |
531 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 547 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
532 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 548 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
533 | 549 | ||
534 | return vcard; | 550 | return vcard; |
535 | } | 551 | } |
536 | 552 | ||
537 | QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const | 553 | QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const |
538 | { | 554 | { |
539 | QString str_rfc2425 = QString("%1-%2-%3") | 555 | QString str_rfc2425 = QString("%1-%2-%3") |
540 | .arg( d.year() ) | 556 | .arg( d.year() ) |
541 | .arg( d.month(), 2 ) | 557 | .arg( d.month(), 2 ) |
542 | .arg( d.day(), 2 ); | 558 | .arg( d.day(), 2 ); |
543 | // Now replace spaces with "0"... | 559 | // Now replace spaces with "0"... |
544 | int pos = 0; | 560 | int pos = 0; |
545 | while ( ( pos = str_rfc2425.find (' ') ) > 0 ) | 561 | while ( ( pos = str_rfc2425.find (' ') ) > 0 ) |
546 | str_rfc2425.replace( pos, 1, "0" ); | 562 | str_rfc2425.replace( pos, 1, "0" ); |
547 | 563 | ||
548 | return str_rfc2425; | 564 | return str_rfc2425; |
549 | } | 565 | } |
550 | 566 | ||
551 | QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) | 567 | QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) |
552 | { | 568 | { |
553 | int monthPos = datestr.find('-'); | 569 | int monthPos = datestr.find('-'); |
554 | int dayPos = datestr.find('-', monthPos+1 ); | 570 | int dayPos = datestr.find('-', monthPos+1 ); |
555 | int sep_ignore = 1; | 571 | int sep_ignore = 1; |
556 | if ( monthPos == -1 || dayPos == -1 ) { | 572 | if ( monthPos == -1 || dayPos == -1 ) { |
557 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | 573 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); |
558 | // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) | 574 | // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) |
559 | if ( datestr.length() == 8 ){ | 575 | if ( datestr.length() == 8 ){ |
560 | monthPos = 4; | 576 | monthPos = 4; |
561 | dayPos = 6; | 577 | dayPos = 6; |
562 | sep_ignore = 0; | 578 | sep_ignore = 0; |
563 | qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | 579 | qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); |
564 | } else { | 580 | } else { |
565 | return QDate(); | 581 | return QDate(); |
566 | } | 582 | } |
567 | } | 583 | } |
568 | int y = datestr.left( monthPos ).toInt(); | 584 | int y = datestr.left( monthPos ).toInt(); |
569 | int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); | 585 | int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); |
570 | int d = datestr.mid( dayPos + sep_ignore ).toInt(); | 586 | int d = datestr.mid( dayPos + sep_ignore ).toInt(); |
571 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); | 587 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); |
572 | QDate date ( y,m,d ); | 588 | QDate date ( y,m,d ); |
573 | return date; | 589 | return date; |
574 | } | 590 | } |
575 | 591 | ||
576 | VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 592 | VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
577 | { | 593 | { |
578 | VObject *ret = 0; | 594 | VObject *ret = 0; |
579 | if ( o && !value.isEmpty() ) | 595 | if ( o && !value.isEmpty() ) |
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp index e96cc3c..309f9e1 100644 --- a/libopie2/opiepim/backend/otodoaccessvcal.cpp +++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp | |||
@@ -29,67 +29,70 @@ namespace { | |||
29 | event.setCompleted( true ); | 29 | event.setCompleted( true ); |
30 | }else{ | 30 | }else{ |
31 | event.setCompleted( false ); | 31 | event.setCompleted( false ); |
32 | } | 32 | } |
33 | }else | 33 | }else |
34 | event.setCompleted( false ); | 34 | event.setCompleted( false ); |
35 | // priority | 35 | // priority |
36 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { | 36 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { |
37 | name = vObjectStringZValue( ob ); | 37 | name = vObjectStringZValue( ob ); |
38 | bool ok; | 38 | bool ok; |
39 | event.setPriority(name.toInt(&ok) ); | 39 | event.setPriority(name.toInt(&ok) ); |
40 | } | 40 | } |
41 | //due date | 41 | //due date |
42 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ | 42 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ |
43 | event.setHasDueDate( true ); | 43 | event.setHasDueDate( true ); |
44 | name = vObjectStringZValue( ob ); | 44 | name = vObjectStringZValue( ob ); |
45 | event.setDueDate( TimeConversion::fromISO8601( name).date() ); | 45 | event.setDueDate( TimeConversion::fromISO8601( name).date() ); |
46 | } | 46 | } |
47 | // categories | 47 | // categories |
48 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ | 48 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ |
49 | name = vObjectStringZValue( ob ); | 49 | name = vObjectStringZValue( ob ); |
50 | qWarning("Categories:%s", name.data() ); | 50 | qWarning("Categories:%s", name.data() ); |
51 | } | 51 | } |
52 | 52 | ||
53 | event.setUid( 1 ); | 53 | event.setUid( 1 ); |
54 | return event; | 54 | return event; |
55 | }; | 55 | }; |
56 | static VObject *vobjByEvent( const OTodo &event ) { | 56 | static VObject *vobjByEvent( const OTodo &event ) { |
57 | VObject *task = newVObject( VCTodoProp ); | 57 | VObject *task = newVObject( VCTodoProp ); |
58 | if( task == 0 ) | 58 | if( task == 0 ) |
59 | return 0l; | 59 | return 0l; |
60 | 60 | ||
61 | if( event.hasDueDate() ) | 61 | if( event.hasDueDate() ) { |
62 | QTime time(0, 0, 0); | ||
63 | QDateTime date(event.dueDate(), time ); | ||
62 | addPropValue( task, VCDueProp, | 64 | addPropValue( task, VCDueProp, |
63 | TimeConversion::toISO8601( event.dueDate() ) ); | 65 | TimeConversion::toISO8601( date ) ); |
66 | } | ||
64 | 67 | ||
65 | if( event.isCompleted() ) | 68 | if( event.isCompleted() ) |
66 | addPropValue( task, VCStatusProp, "COMPLETED"); | 69 | addPropValue( task, VCStatusProp, "COMPLETED"); |
67 | 70 | ||
68 | QString string = QString::number(event.priority() ); | 71 | QString string = QString::number(event.priority() ); |
69 | addPropValue( task, VCPriorityProp, string.local8Bit() ); | 72 | addPropValue( task, VCPriorityProp, string.local8Bit() ); |
70 | 73 | ||
71 | addPropValue( task, VCCategoriesProp, | 74 | addPropValue( task, VCCategoriesProp, |
72 | event.idsToString( event.categories() ).local8Bit() ); | 75 | event.idsToString( event.categories() ).local8Bit() ); |
73 | 76 | ||
74 | addPropValue( task, VCDescriptionProp, | 77 | addPropValue( task, VCDescriptionProp, |
75 | event.description().local8Bit() ); | 78 | event.description().local8Bit() ); |
76 | 79 | ||
77 | addPropValue( task, VCSummaryProp, | 80 | addPropValue( task, VCSummaryProp, |
78 | event.summary().local8Bit() ); | 81 | event.summary().local8Bit() ); |
79 | return task; | 82 | return task; |
80 | }; | 83 | }; |
81 | } | 84 | } |
82 | 85 | ||
83 | OTodoAccessVCal::OTodoAccessVCal( const QString& path ) | 86 | OTodoAccessVCal::OTodoAccessVCal( const QString& path ) |
84 | : m_dirty(false), m_file( path ) | 87 | : m_dirty(false), m_file( path ) |
85 | { | 88 | { |
86 | } | 89 | } |
87 | OTodoAccessVCal::~OTodoAccessVCal() { | 90 | OTodoAccessVCal::~OTodoAccessVCal() { |
88 | } | 91 | } |
89 | bool OTodoAccessVCal::load() { | 92 | bool OTodoAccessVCal::load() { |
90 | m_map.clear(); | 93 | m_map.clear(); |
91 | m_dirty = false; | 94 | m_dirty = false; |
92 | 95 | ||
93 | VObject* vcal = 0l; | 96 | VObject* vcal = 0l; |
94 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 97 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
95 | if (!vcal ) | 98 | if (!vcal ) |