summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-02-24 20:15:06 (UTC)
committer mickeyl <mickeyl>2004-02-24 20:15:06 (UTC)
commita1a6a1013eae9a4ca4607f2d656c98821a30f431 (patch) (unidiff)
tree1622cd7992b061d9105965fcd3adbceda8504499
parent17eafbf019590393ccd01647c5c9d5d880b95e39 (diff)
downloadopie-a1a6a1013eae9a4ca4607f2d656c98821a30f431.zip
opie-a1a6a1013eae9a4ca4607f2d656c98821a30f431.tar.gz
opie-a1a6a1013eae9a4ca4607f2d656c98821a30f431.tar.bz2
substitute hack with another hack to enforce LGPL compliance
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp15
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp17
-rw-r--r--libopie2/opiepim/private/vobject_p.h408
3 files changed, 428 insertions, 12 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index b569f8b..ffa6a7d 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -1,591 +1,596 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * VCard Backend for the OPIE-Contact Database. 30 * VCard Backend for the OPIE-Contact Database.
31 */ 31 */
32#include <opie2/ocontactaccessbackend_vcard.h>
33#include "../../../../library/backend/vobject_p.h"
34#include "../../../../library/backend/qfiledirect_p.h"
35 32
33
34#include "vobject_p.h"
35
36/* OPIE */
37#include <opie2/ocontactaccessbackend_vcard.h>
36#include <qpe/timeconversion.h> 38#include <qpe/timeconversion.h>
37 39
40//FIXME: Hack to allow direct access to FILE* fh. Rewrite this!
41#define protected public
38#include <qfile.h> 42#include <qfile.h>
43#undef protected
39 44
40namespace Opie { 45namespace Opie {
41 46
42OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& , const QString& filename ): 47OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& , const QString& filename ):
43 m_dirty( false ), 48 m_dirty( false ),
44 m_file( filename ) 49 m_file( filename )
45{ 50{
46 load(); 51 load();
47} 52}
48 53
49 54
50bool OPimContactAccessBackend_VCard::load () 55bool OPimContactAccessBackend_VCard::load ()
51{ 56{
52 m_map.clear(); 57 m_map.clear();
53 m_dirty = false; 58 m_dirty = false;
54 59
55 VObject* obj = 0l; 60 VObject* obj = 0l;
56 61
57 if ( QFile::exists(m_file) ){ 62 if ( QFile::exists(m_file) ){
58 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 63 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
59 if ( !obj ) 64 if ( !obj )
60 return false; 65 return false;
61 }else{ 66 }else{
62 qWarning("File \"%s\" not found !", m_file.latin1() ); 67 qWarning("File \"%s\" not found !", m_file.latin1() );
63 return false; 68 return false;
64 } 69 }
65 70
66 while ( obj ) { 71 while ( obj ) {
67 OPimContact con = parseVObject( obj ); 72 OPimContact con = parseVObject( obj );
68 /* 73 /*
69 * if uid is 0 assign a new one 74 * if uid is 0 assign a new one
70 * this at least happens on 75 * this at least happens on
71 * Nokia6210 76 * Nokia6210
72 */ 77 */
73 if ( con.uid() == 0 ){ 78 if ( con.uid() == 0 ){
74 con.setUid( 1 ); 79 con.setUid( 1 );
75 qWarning("assigned new uid %d",con.uid() ); 80 qWarning("assigned new uid %d",con.uid() );
76 } 81 }
77 82
78 m_map.insert( con.uid(), con ); 83 m_map.insert( con.uid(), con );
79 84
80 VObject *t = obj; 85 VObject *t = obj;
81 obj = nextVObjectInList(obj); 86 obj = nextVObjectInList(obj);
82 cleanVObject( t ); 87 cleanVObject( t );
83 } 88 }
84 89
85 return true; 90 return true;
86 91
87} 92}
88bool OPimContactAccessBackend_VCard::reload() 93bool OPimContactAccessBackend_VCard::reload()
89{ 94{
90 return load(); 95 return load();
91} 96}
92bool OPimContactAccessBackend_VCard::save() 97bool OPimContactAccessBackend_VCard::save()
93{ 98{
94 if (!m_dirty ) 99 if (!m_dirty )
95 return true; 100 return true;
96 101
97 QFileDirect file( m_file ); 102 QFile file( m_file );
98 if (!file.open(IO_WriteOnly ) ) 103 if (!file.open(IO_WriteOnly ) )
99 return false; 104 return false;
100 105
101 VObject *obj; 106 VObject *obj;
102 obj = newVObject( VCCalProp ); 107 obj = newVObject( VCCalProp );
103 addPropValue( obj, VCVersionProp, "1.0" ); 108 addPropValue( obj, VCVersionProp, "1.0" );
104 109
105 VObject *vo; 110 VObject *vo;
106 for(QMap<int, OPimContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 111 for(QMap<int, OPimContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
107 vo = createVObject( *it ); 112 vo = createVObject( *it );
108 writeVObject( file.directHandle() , vo ); 113 writeVObject( file.fh, vo ); //FIXME: HACK!!!
109 cleanVObject( vo ); 114 cleanVObject( vo );
110 } 115 }
111 cleanStrTbl(); 116 cleanStrTbl();
112 deleteVObject( obj ); 117 deleteVObject( obj );
113 118
114 m_dirty = false; 119 m_dirty = false;
115 return true; 120 return true;
116 121
117 122
118} 123}
119void OPimContactAccessBackend_VCard::clear () 124void OPimContactAccessBackend_VCard::clear ()
120{ 125{
121 m_map.clear(); 126 m_map.clear();
122 m_dirty = true; // ??? sure ? (se) 127 m_dirty = true; // ??? sure ? (se)
123} 128}
124 129
125bool OPimContactAccessBackend_VCard::add ( const OPimContact& newcontact ) 130bool OPimContactAccessBackend_VCard::add ( const OPimContact& newcontact )
126{ 131{
127 m_map.insert( newcontact.uid(), newcontact ); 132 m_map.insert( newcontact.uid(), newcontact );
128 m_dirty = true; 133 m_dirty = true;
129 return true; 134 return true;
130} 135}
131 136
132bool OPimContactAccessBackend_VCard::remove ( int uid ) 137bool OPimContactAccessBackend_VCard::remove ( int uid )
133{ 138{
134 m_map.remove( uid ); 139 m_map.remove( uid );
135 m_dirty = true; 140 m_dirty = true;
136 return true; 141 return true;
137} 142}
138 143
139bool OPimContactAccessBackend_VCard::replace ( const OPimContact &contact ) 144bool OPimContactAccessBackend_VCard::replace ( const OPimContact &contact )
140{ 145{
141 m_map.replace( contact.uid(), contact ); 146 m_map.replace( contact.uid(), contact );
142 m_dirty = true; 147 m_dirty = true;
143 return true; 148 return true;
144} 149}
145 150
146OPimContact OPimContactAccessBackend_VCard::find ( int uid ) const 151OPimContact OPimContactAccessBackend_VCard::find ( int uid ) const
147{ 152{
148 return m_map[uid]; 153 return m_map[uid];
149} 154}
150 155
151QArray<int> OPimContactAccessBackend_VCard::allRecords() const 156QArray<int> OPimContactAccessBackend_VCard::allRecords() const
152{ 157{
153 QArray<int> ar( m_map.count() ); 158 QArray<int> ar( m_map.count() );
154 QMap<int, OPimContact>::ConstIterator it; 159 QMap<int, OPimContact>::ConstIterator it;
155 int i = 0; 160 int i = 0;
156 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 161 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
157 ar[i] = it.key(); 162 ar[i] = it.key();
158 i++; 163 i++;
159 } 164 }
160 return ar; 165 return ar;
161} 166}
162 167
163// Not implemented 168// Not implemented
164QArray<int> OPimContactAccessBackend_VCard::queryByExample ( const OPimContact&, int, const QDateTime& ) 169QArray<int> OPimContactAccessBackend_VCard::queryByExample ( const OPimContact&, int, const QDateTime& )
165{ 170{
166 QArray<int> ar(0); 171 QArray<int> ar(0);
167 return ar; 172 return ar;
168} 173}
169 174
170// Not implemented 175// Not implemented
171QArray<int> OPimContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const 176QArray<int> OPimContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const
172{ 177{
173 QArray<int> ar(0); 178 QArray<int> ar(0);
174 return ar; 179 return ar;
175} 180}
176 181
177const uint OPimContactAccessBackend_VCard::querySettings() 182const uint OPimContactAccessBackend_VCard::querySettings()
178{ 183{
179 return 0; // No search possible 184 return 0; // No search possible
180} 185}
181 186
182bool OPimContactAccessBackend_VCard::hasQuerySettings (uint ) const 187bool OPimContactAccessBackend_VCard::hasQuerySettings (uint ) const
183{ 188{
184 return false; // No search possible, therefore all settings invalid ;) 189 return false; // No search possible, therefore all settings invalid ;)
185} 190}
186 191
187bool OPimContactAccessBackend_VCard::wasChangedExternally() 192bool OPimContactAccessBackend_VCard::wasChangedExternally()
188{ 193{
189 return false; // Don't expect concurrent access 194 return false; // Don't expect concurrent access
190} 195}
191 196
192// Not implemented 197// Not implemented
193QArray<int> OPimContactAccessBackend_VCard::sorted( bool , int, int, int ) 198QArray<int> OPimContactAccessBackend_VCard::sorted( bool , int, int, int )
194{ 199{
195 QArray<int> ar(0); 200 QArray<int> ar(0);
196 return ar; 201 return ar;
197} 202}
198 203
199// *** Private stuff *** 204// *** Private stuff ***
200 205
201 206
202OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj ) 207OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
203{ 208{
204 OPimContact c; 209 OPimContact c;
205 210
206 VObjectIterator it; 211 VObjectIterator it;
207 initPropIterator( &it, obj ); 212 initPropIterator( &it, obj );
208 while( moreIteration( &it ) ) { 213 while( moreIteration( &it ) ) {
209 VObject *o = nextVObject( &it ); 214 VObject *o = nextVObject( &it );
210 QCString name = vObjectName( o ); 215 QCString name = vObjectName( o );
211 QCString value = vObjectStringZValue( o ); 216 QCString value = vObjectStringZValue( o );
212 if ( name == VCNameProp ) { 217 if ( name == VCNameProp ) {
213 VObjectIterator nit; 218 VObjectIterator nit;
214 initPropIterator( &nit, o ); 219 initPropIterator( &nit, o );
215 while( moreIteration( &nit ) ) { 220 while( moreIteration( &nit ) ) {
216 VObject *o = nextVObject( &nit ); 221 VObject *o = nextVObject( &nit );
217 QCString name = vObjectTypeInfo( o ); 222 QCString name = vObjectTypeInfo( o );
218 QString value = vObjectStringZValue( o ); 223 QString value = vObjectStringZValue( o );
219 if ( name == VCNamePrefixesProp ) 224 if ( name == VCNamePrefixesProp )
220 c.setTitle( value ); 225 c.setTitle( value );
221 else if ( name == VCNameSuffixesProp ) 226 else if ( name == VCNameSuffixesProp )
222 c.setSuffix( value ); 227 c.setSuffix( value );
223 else if ( name == VCFamilyNameProp ) 228 else if ( name == VCFamilyNameProp )
224 c.setLastName( value ); 229 c.setLastName( value );
225 else if ( name == VCGivenNameProp ) 230 else if ( name == VCGivenNameProp )
226 c.setFirstName( value ); 231 c.setFirstName( value );
227 else if ( name == VCAdditionalNamesProp ) 232 else if ( name == VCAdditionalNamesProp )
228 c.setMiddleName( value ); 233 c.setMiddleName( value );
229 } 234 }
230 } 235 }
231 else if ( name == VCAdrProp ) { 236 else if ( name == VCAdrProp ) {
232 bool work = TRUE; // default address is work address 237 bool work = TRUE; // default address is work address
233 QString street; 238 QString street;
234 QString city; 239 QString city;
235 QString region; 240 QString region;
236 QString postal; 241 QString postal;
237 QString country; 242 QString country;
238 243
239 VObjectIterator nit; 244 VObjectIterator nit;
240 initPropIterator( &nit, o ); 245 initPropIterator( &nit, o );
241 while( moreIteration( &nit ) ) { 246 while( moreIteration( &nit ) ) {
242 VObject *o = nextVObject( &nit ); 247 VObject *o = nextVObject( &nit );
243 QCString name = vObjectName( o ); 248 QCString name = vObjectName( o );
244 QString value = vObjectStringZValue( o ); 249 QString value = vObjectStringZValue( o );
245 if ( name == VCHomeProp ) 250 if ( name == VCHomeProp )
246 work = FALSE; 251 work = FALSE;
247 else if ( name == VCWorkProp ) 252 else if ( name == VCWorkProp )
248 work = TRUE; 253 work = TRUE;
249 else if ( name == VCStreetAddressProp ) 254 else if ( name == VCStreetAddressProp )
250 street = value; 255 street = value;
251 else if ( name == VCCityProp ) 256 else if ( name == VCCityProp )
252 city = value; 257 city = value;
253 else if ( name == VCRegionProp ) 258 else if ( name == VCRegionProp )
254 region = value; 259 region = value;
255 else if ( name == VCPostalCodeProp ) 260 else if ( name == VCPostalCodeProp )
256 postal = value; 261 postal = value;
257 else if ( name == VCCountryNameProp ) 262 else if ( name == VCCountryNameProp )
258 country = value; 263 country = value;
259 } 264 }
260 if ( work ) { 265 if ( work ) {
261 c.setBusinessStreet( street ); 266 c.setBusinessStreet( street );
262 c.setBusinessCity( city ); 267 c.setBusinessCity( city );
263 c.setBusinessCountry( country ); 268 c.setBusinessCountry( country );
264 c.setBusinessZip( postal ); 269 c.setBusinessZip( postal );
265 c.setBusinessState( region ); 270 c.setBusinessState( region );
266 } else { 271 } else {
267 c.setHomeStreet( street ); 272 c.setHomeStreet( street );
268 c.setHomeCity( city ); 273 c.setHomeCity( city );
269 c.setHomeCountry( country ); 274 c.setHomeCountry( country );
270 c.setHomeZip( postal ); 275 c.setHomeZip( postal );
271 c.setHomeState( region ); 276 c.setHomeState( region );
272 } 277 }
273 } 278 }
274 else if ( name == VCTelephoneProp ) { 279 else if ( name == VCTelephoneProp ) {
275 enum { 280 enum {
276 HOME = 0x01, 281 HOME = 0x01,
277 WORK = 0x02, 282 WORK = 0x02,
278 VOICE = 0x04, 283 VOICE = 0x04,
279 CELL = 0x08, 284 CELL = 0x08,
280 FAX = 0x10, 285 FAX = 0x10,
281 PAGER = 0x20, 286 PAGER = 0x20,
282 UNKNOWN = 0x80 287 UNKNOWN = 0x80
283 }; 288 };
284 int type = 0; 289 int type = 0;
285 290
286 VObjectIterator nit; 291 VObjectIterator nit;
287 initPropIterator( &nit, o ); 292 initPropIterator( &nit, o );
288 while( moreIteration( &nit ) ) { 293 while( moreIteration( &nit ) ) {
289 VObject *o = nextVObject( &nit ); 294 VObject *o = nextVObject( &nit );
290 QCString name = vObjectTypeInfo( o ); 295 QCString name = vObjectTypeInfo( o );
291 if ( name == VCHomeProp ) 296 if ( name == VCHomeProp )
292 type |= HOME; 297 type |= HOME;
293 else if ( name == VCWorkProp ) 298 else if ( name == VCWorkProp )
294 type |= WORK; 299 type |= WORK;
295 else if ( name == VCVoiceProp ) 300 else if ( name == VCVoiceProp )
296 type |= VOICE; 301 type |= VOICE;
297 else if ( name == VCCellularProp ) 302 else if ( name == VCCellularProp )
298 type |= CELL; 303 type |= CELL;
299 else if ( name == VCFaxProp ) 304 else if ( name == VCFaxProp )
300 type |= FAX; 305 type |= FAX;
301 else if ( name == VCPagerProp ) 306 else if ( name == VCPagerProp )
302 type |= PAGER; 307 type |= PAGER;
303 else if ( name == VCPreferredProp ) 308 else if ( name == VCPreferredProp )
304 ; 309 ;
305 else 310 else
306 type |= UNKNOWN; 311 type |= UNKNOWN;
307 } 312 }
308 if ( (type & UNKNOWN) != UNKNOWN ) { 313 if ( (type & UNKNOWN) != UNKNOWN ) {
309 if ( ( type & (HOME|WORK) ) == 0 ) // default 314 if ( ( type & (HOME|WORK) ) == 0 ) // default
310 type |= HOME; 315 type |= HOME;
311 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 316 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
312 type |= VOICE; 317 type |= VOICE;
313 318
314 qWarning("value %s %d", value.data(), type ); 319 qWarning("value %s %d", value.data(), type );
315 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) 320 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
316 c.setHomePhone( value ); 321 c.setHomePhone( value );
317 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 322 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
318 c.setHomeFax( value ); 323 c.setHomeFax( value );
319 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 324 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
320 c.setHomeMobile( value ); 325 c.setHomeMobile( value );
321 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) ) 326 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) )
322 c.setBusinessPhone( value ); 327 c.setBusinessPhone( value );
323 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 328 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
324 c.setBusinessFax( value ); 329 c.setBusinessFax( value );
325 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 330 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
326 c.setBusinessMobile( value ); 331 c.setBusinessMobile( value );
327 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) 332 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
328 c.setBusinessPager( value ); 333 c.setBusinessPager( value );
329 } 334 }
330 } 335 }
331 else if ( name == VCEmailAddressProp ) { 336 else if ( name == VCEmailAddressProp ) {
332 QString email = vObjectStringZValue( o ); 337 QString email = vObjectStringZValue( o );
333 bool valid = TRUE; 338 bool valid = TRUE;
334 VObjectIterator nit; 339 VObjectIterator nit;
335 initPropIterator( &nit, o ); 340 initPropIterator( &nit, o );
336 while( moreIteration( &nit ) ) { 341 while( moreIteration( &nit ) ) {
337 VObject *o = nextVObject( &nit ); 342 VObject *o = nextVObject( &nit );
338 QCString name = vObjectTypeInfo( o ); 343 QCString name = vObjectTypeInfo( o );
339 if ( name != VCInternetProp && name != VCHomeProp && 344 if ( name != VCInternetProp && name != VCHomeProp &&
340 name != VCWorkProp && 345 name != VCWorkProp &&
341 name != VCPreferredProp ) 346 name != VCPreferredProp )
342 // ### preffered should map to default email 347 // ### preffered should map to default email
343 valid = FALSE; 348 valid = FALSE;
344 } 349 }
345 if ( valid ) { 350 if ( valid ) {
346 c.insertEmail( email ); 351 c.insertEmail( email );
347 } 352 }
348 } 353 }
349 else if ( name == VCURLProp ) { 354 else if ( name == VCURLProp ) {
350 VObjectIterator nit; 355 VObjectIterator nit;
351 initPropIterator( &nit, o ); 356 initPropIterator( &nit, o );
352 while( moreIteration( &nit ) ) { 357 while( moreIteration( &nit ) ) {
353 VObject *o = nextVObject( &nit ); 358 VObject *o = nextVObject( &nit );
354 QCString name = vObjectTypeInfo( o ); 359 QCString name = vObjectTypeInfo( o );
355 if ( name == VCHomeProp ) 360 if ( name == VCHomeProp )
356 c.setHomeWebpage( value ); 361 c.setHomeWebpage( value );
357 else if ( name == VCWorkProp ) 362 else if ( name == VCWorkProp )
358 c.setBusinessWebpage( value ); 363 c.setBusinessWebpage( value );
359 } 364 }
360 } 365 }
361 else if ( name == VCOrgProp ) { 366 else if ( name == VCOrgProp ) {
362 VObjectIterator nit; 367 VObjectIterator nit;
363 initPropIterator( &nit, o ); 368 initPropIterator( &nit, o );
364 while( moreIteration( &nit ) ) { 369 while( moreIteration( &nit ) ) {
365 VObject *o = nextVObject( &nit ); 370 VObject *o = nextVObject( &nit );
366 QCString name = vObjectName( o ); 371 QCString name = vObjectName( o );
367 QString value = vObjectStringZValue( o ); 372 QString value = vObjectStringZValue( o );
368 if ( name == VCOrgNameProp ) 373 if ( name == VCOrgNameProp )
369 c.setCompany( value ); 374 c.setCompany( value );
370 else if ( name == VCOrgUnitProp ) 375 else if ( name == VCOrgUnitProp )
371 c.setDepartment( value ); 376 c.setDepartment( value );
372 else if ( name == VCOrgUnit2Prop ) 377 else if ( name == VCOrgUnit2Prop )
373 c.setOffice( value ); 378 c.setOffice( value );
374 } 379 }
375 } 380 }
376 else if ( name == VCTitleProp ) { 381 else if ( name == VCTitleProp ) {
377 c.setJobTitle( value ); 382 c.setJobTitle( value );
378 } 383 }
379 else if ( name == "X-Qtopia-Profession" ) { 384 else if ( name == "X-Qtopia-Profession" ) {
380 c.setProfession( value ); 385 c.setProfession( value );
381 } 386 }
382 else if ( name == "X-Qtopia-Manager" ) { 387 else if ( name == "X-Qtopia-Manager" ) {
383 c.setManager( value ); 388 c.setManager( value );
384 } 389 }
385 else if ( name == "X-Qtopia-Assistant" ) { 390 else if ( name == "X-Qtopia-Assistant" ) {
386 c.setAssistant( value ); 391 c.setAssistant( value );
387 } 392 }
388 else if ( name == "X-Qtopia-Spouse" ) { 393 else if ( name == "X-Qtopia-Spouse" ) {
389 c.setSpouse( value ); 394 c.setSpouse( value );
390 } 395 }
391 else if ( name == "X-Qtopia-Gender" ) { 396 else if ( name == "X-Qtopia-Gender" ) {
392 c.setGender( value ); 397 c.setGender( value );
393 } 398 }
394 else if ( name == "X-Qtopia-Anniversary" ) { 399 else if ( name == "X-Qtopia-Anniversary" ) {
395 c.setAnniversary( convVCardDateToDate( value ) ); 400 c.setAnniversary( convVCardDateToDate( value ) );
396 } 401 }
397 else if ( name == "X-Qtopia-Nickname" ) { 402 else if ( name == "X-Qtopia-Nickname" ) {
398 c.setNickname( value ); 403 c.setNickname( value );
399 } 404 }
400 else if ( name == "X-Qtopia-Children" ) { 405 else if ( name == "X-Qtopia-Children" ) {
401 c.setChildren( value ); 406 c.setChildren( value );
402 } 407 }
403 else if ( name == VCBirthDateProp ) { 408 else if ( name == VCBirthDateProp ) {
404 // Reading Birthdate regarding RFC 2425 (5.8.4) 409 // Reading Birthdate regarding RFC 2425 (5.8.4)
405 c.setBirthday( convVCardDateToDate( value ) ); 410 c.setBirthday( convVCardDateToDate( value ) );
406 411
407 } 412 }
408 else if ( name == VCCommentProp ) { 413 else if ( name == VCCommentProp ) {
409 c.setNotes( value ); 414 c.setNotes( value );
410 } 415 }
411#if 0 416#if 0
412 else { 417 else {
413 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 418 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
414 VObjectIterator nit; 419 VObjectIterator nit;
415 initPropIterator( &nit, o ); 420 initPropIterator( &nit, o );
416 while( moreIteration( &nit ) ) { 421 while( moreIteration( &nit ) ) {
417 VObject *o = nextVObject( &nit ); 422 VObject *o = nextVObject( &nit );
418 QCString name = vObjectName( o ); 423 QCString name = vObjectName( o );
419 QString value = vObjectStringZValue( o ); 424 QString value = vObjectStringZValue( o );
420 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 425 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
421 } 426 }
422 } 427 }
423#endif 428#endif
424 } 429 }
425 c.setFileAs(); 430 c.setFileAs();
426 return c; 431 return c;
427} 432}
428 433
429 434
430VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c ) 435VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c )
431{ 436{
432 VObject *vcard = newVObject( VCCardProp ); 437 VObject *vcard = newVObject( VCCardProp );
433 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 438 safeAddPropValue( vcard, VCVersionProp, "2.1" );
434 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 439 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
435 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 440 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
436 441
437 // full name 442 // full name
438 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 443 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
439 444
440 // name properties 445 // name properties
441 VObject *name = safeAddProp( vcard, VCNameProp ); 446 VObject *name = safeAddProp( vcard, VCNameProp );
442 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 447 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
443 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 448 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
444 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); 449 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
445 safeAddPropValue( name, VCNamePrefixesProp, c.title() ); 450 safeAddPropValue( name, VCNamePrefixesProp, c.title() );
446 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); 451 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
447 452
448 // home properties 453 // home properties
449 VObject *home_adr= safeAddProp( vcard, VCAdrProp ); 454 VObject *home_adr= safeAddProp( vcard, VCAdrProp );
450 safeAddProp( home_adr, VCHomeProp ); 455 safeAddProp( home_adr, VCHomeProp );
451 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); 456 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
452 safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); 457 safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
453 safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); 458 safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
454 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); 459 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
455 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); 460 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
456 461
457 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); 462 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
458 safeAddProp( home_phone, VCHomeProp ); 463 safeAddProp( home_phone, VCHomeProp );
459 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); 464 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
460 safeAddProp( home_phone, VCHomeProp ); 465 safeAddProp( home_phone, VCHomeProp );
461 safeAddProp( home_phone, VCCellularProp ); 466 safeAddProp( home_phone, VCCellularProp );
462 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); 467 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
463 safeAddProp( home_phone, VCHomeProp ); 468 safeAddProp( home_phone, VCHomeProp );
464 safeAddProp( home_phone, VCFaxProp ); 469 safeAddProp( home_phone, VCFaxProp );
465 470
466 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); 471 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
467 safeAddProp( url, VCHomeProp ); 472 safeAddProp( url, VCHomeProp );
468 473
469 // work properties 474 // work properties
470 VObject *work_adr= safeAddProp( vcard, VCAdrProp ); 475 VObject *work_adr= safeAddProp( vcard, VCAdrProp );
471 safeAddProp( work_adr, VCWorkProp ); 476 safeAddProp( work_adr, VCWorkProp );
472 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); 477 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
473 safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); 478 safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
474 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 479 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
475 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 480 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
476 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 481 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
477 482
478 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 483 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
479 safeAddProp( work_phone, VCWorkProp ); 484 safeAddProp( work_phone, VCWorkProp );
480 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 485 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
481 safeAddProp( work_phone, VCWorkProp ); 486 safeAddProp( work_phone, VCWorkProp );
482 safeAddProp( work_phone, VCCellularProp ); 487 safeAddProp( work_phone, VCCellularProp );
483 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 488 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
484 safeAddProp( work_phone, VCWorkProp ); 489 safeAddProp( work_phone, VCWorkProp );
485 safeAddProp( work_phone, VCFaxProp ); 490 safeAddProp( work_phone, VCFaxProp );
486 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 491 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
487 safeAddProp( work_phone, VCWorkProp ); 492 safeAddProp( work_phone, VCWorkProp );
488 safeAddProp( work_phone, VCPagerProp ); 493 safeAddProp( work_phone, VCPagerProp );
489 494
490 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 495 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
491 safeAddProp( url, VCWorkProp ); 496 safeAddProp( url, VCWorkProp );
492 497
493 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 498 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
494 safeAddProp( title, VCWorkProp ); 499 safeAddProp( title, VCWorkProp );
495 500
496 501
497 QStringList emails = c.emailList(); 502 QStringList emails = c.emailList();
498 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045 503 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045
499 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 504 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
500 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 505 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
501 safeAddProp( email, VCInternetProp ); 506 safeAddProp( email, VCInternetProp );
502 } 507 }
503 508
504 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 509 safeAddPropValue( vcard, VCNoteProp, c.notes() );
505 510
506 // Exporting Birthday regarding RFC 2425 (5.8.4) 511 // Exporting Birthday regarding RFC 2425 (5.8.4)
507 if ( c.birthday().isValid() ){ 512 if ( c.birthday().isValid() ){
508 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); 513 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() );
509 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); 514 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
510 } 515 }
511 516
512 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 517 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
513 VObject *org = safeAddProp( vcard, VCOrgProp ); 518 VObject *org = safeAddProp( vcard, VCOrgProp );
514 safeAddPropValue( org, VCOrgNameProp, c.company() ); 519 safeAddPropValue( org, VCOrgNameProp, c.company() );
515 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 520 safeAddPropValue( org, VCOrgUnitProp, c.department() );
516 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 521 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
517 } 522 }
518 523
519 // some values we have to export as custom fields 524 // some values we have to export as custom fields
520 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 525 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
521 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 526 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
522 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 527 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
523 528
524 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 529 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
525 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 530 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
526 if ( c.anniversary().isValid() ){ 531 if ( c.anniversary().isValid() ){
527 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); 532 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() );
528 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); 533 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) );
529 } 534 }
530 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 535 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
531 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 536 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
532 537
533 return vcard; 538 return vcard;
534} 539}
535 540
536QString OPimContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const 541QString OPimContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const
537{ 542{
538 QString str_rfc2425 = QString("%1-%2-%3") 543 QString str_rfc2425 = QString("%1-%2-%3")
539 .arg( d.year() ) 544 .arg( d.year() )
540 .arg( d.month(), 2 ) 545 .arg( d.month(), 2 )
541 .arg( d.day(), 2 ); 546 .arg( d.day(), 2 );
542 // Now replace spaces with "0"... 547 // Now replace spaces with "0"...
543 int pos = 0; 548 int pos = 0;
544 while ( ( pos = str_rfc2425.find (' ') ) > 0 ) 549 while ( ( pos = str_rfc2425.find (' ') ) > 0 )
545 str_rfc2425.replace( pos, 1, "0" ); 550 str_rfc2425.replace( pos, 1, "0" );
546 551
547 return str_rfc2425; 552 return str_rfc2425;
548} 553}
549 554
550QDate OPimContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) 555QDate OPimContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr )
551{ 556{
552 int monthPos = datestr.find('-'); 557 int monthPos = datestr.find('-');
553 int dayPos = datestr.find('-', monthPos+1 ); 558 int dayPos = datestr.find('-', monthPos+1 );
554 int sep_ignore = 1; 559 int sep_ignore = 1;
555 if ( monthPos == -1 || dayPos == -1 ) { 560 if ( monthPos == -1 || dayPos == -1 ) {
556 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 561 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
557 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) 562 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD )
558 if ( datestr.length() == 8 ){ 563 if ( datestr.length() == 8 ){
559 monthPos = 4; 564 monthPos = 4;
560 dayPos = 6; 565 dayPos = 6;
561 sep_ignore = 0; 566 sep_ignore = 0;
562 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 567 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
563 } else { 568 } else {
564 return QDate(); 569 return QDate();
565 } 570 }
566 } 571 }
567 int y = datestr.left( monthPos ).toInt(); 572 int y = datestr.left( monthPos ).toInt();
568 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); 573 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
569 int d = datestr.mid( dayPos + sep_ignore ).toInt(); 574 int d = datestr.mid( dayPos + sep_ignore ).toInt();
570 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); 575 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos);
571 QDate date ( y,m,d ); 576 QDate date ( y,m,d );
572 return date; 577 return date;
573} 578}
574 579
575VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) 580VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value )
576{ 581{
577 VObject *ret = 0; 582 VObject *ret = 0;
578 if ( o && !value.isEmpty() ) 583 if ( o && !value.isEmpty() )
579 ret = addPropValue( o, prop, value.latin1() ); 584 ret = addPropValue( o, prop, value.latin1() );
580 return ret; 585 return ret;
581} 586}
582 587
583VObject* OPimContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) 588VObject* OPimContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop)
584{ 589{
585 VObject *ret = 0; 590 VObject *ret = 0;
586 if ( o ) 591 if ( o )
587 ret = addProp( o, prop ); 592 ret = addProp( o, prop );
588 return ret; 593 return ret;
589} 594}
590 595
591} 596}
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index 0a1baf9..03d4479 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -1,282 +1,285 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <qfile.h>
30
31#include <qtopia/private/vobject_p.h>
32#include <qtopia/timeconversion.h>
33#include <qtopia/private/qfiledirect_p.h>
34 29
30/* OPIE */
31#include "vobject_p.h"
32#include <qpe/timeconversion.h>
35#include <opie2/otodoaccessvcal.h> 33#include <opie2/otodoaccessvcal.h>
36 34
35//FIXME: Hack to allow direct access to FILE* fh. Rewrite this!
36#define protected public
37#include <qfile.h>
38#undef protected
39
37using namespace Opie; 40using namespace Opie;
38 41
39namespace { 42namespace {
40 static OPimTodo eventByVObj( VObject *obj ){ 43 static OPimTodo eventByVObj( VObject *obj ){
41 OPimTodo event; 44 OPimTodo event;
42 VObject *ob; 45 VObject *ob;
43 QCString name; 46 QCString name;
44 // no uid, attendees, ... and no fun 47 // no uid, attendees, ... and no fun
45 // description 48 // description
46 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ 49 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){
47 name = vObjectStringZValue( ob ); 50 name = vObjectStringZValue( ob );
48#if 0 51#if 0
49 event.setDescription( name ); 52 event.setDescription( name );
50#else 53#else
51 event.setSummary( name ); 54 event.setSummary( name );
52#endif 55#endif
53 } 56 }
54 // summary 57 // summary
55 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { 58 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) {
56 name = vObjectStringZValue( ob ); 59 name = vObjectStringZValue( ob );
57#if 0 60#if 0
58 event.setSummary( name ); 61 event.setSummary( name );
59#else 62#else
60 event.setDescription( name ); 63 event.setDescription( name );
61#endif 64#endif
62 } 65 }
63 // completed 66 // completed
64 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ 67 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){
65 name = vObjectStringZValue( ob ); 68 name = vObjectStringZValue( ob );
66 if( name == "COMPLETED" ){ 69 if( name == "COMPLETED" ){
67 event.setCompleted( true ); 70 event.setCompleted( true );
68 }else{ 71 }else{
69 event.setCompleted( false ); 72 event.setCompleted( false );
70 } 73 }
71 }else 74 }else
72 event.setCompleted( false ); 75 event.setCompleted( false );
73 // priority 76 // priority
74 if ((ob = isAPropertyOf(obj, VCPriorityProp))) { 77 if ((ob = isAPropertyOf(obj, VCPriorityProp))) {
75 name = vObjectStringZValue( ob ); 78 name = vObjectStringZValue( ob );
76 bool ok; 79 bool ok;
77 event.setPriority(name.toInt(&ok) ); 80 event.setPriority(name.toInt(&ok) );
78 } 81 }
79 //due date 82 //due date
80 if((ob = isAPropertyOf(obj, VCDueProp)) ){ 83 if((ob = isAPropertyOf(obj, VCDueProp)) ){
81 event.setHasDueDate( true ); 84 event.setHasDueDate( true );
82 name = vObjectStringZValue( ob ); 85 name = vObjectStringZValue( ob );
83 event.setDueDate( TimeConversion::fromISO8601( name).date() ); 86 event.setDueDate( TimeConversion::fromISO8601( name).date() );
84 } 87 }
85 // categories 88 // categories
86 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ 89 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){
87 name = vObjectStringZValue( ob ); 90 name = vObjectStringZValue( ob );
88 qWarning("Categories:%s", name.data() ); 91 qWarning("Categories:%s", name.data() );
89 } 92 }
90 93
91 event.setUid( 1 ); 94 event.setUid( 1 );
92 return event; 95 return event;
93 }; 96 };
94 static VObject *vobjByEvent( const OPimTodo &event ) { 97 static VObject *vobjByEvent( const OPimTodo &event ) {
95 VObject *task = newVObject( VCTodoProp ); 98 VObject *task = newVObject( VCTodoProp );
96 if( task == 0 ) 99 if( task == 0 )
97 return 0l; 100 return 0l;
98 101
99 if( event.hasDueDate() ) { 102 if( event.hasDueDate() ) {
100 QTime time(0, 0, 0); 103 QTime time(0, 0, 0);
101 QDateTime date(event.dueDate(), time ); 104 QDateTime date(event.dueDate(), time );
102 addPropValue( task, VCDueProp, 105 addPropValue( task, VCDueProp,
103 TimeConversion::toISO8601( date ) ); 106 TimeConversion::toISO8601( date ) );
104 } 107 }
105 108
106 if( event.isCompleted() ) 109 if( event.isCompleted() )
107 addPropValue( task, VCStatusProp, "COMPLETED"); 110 addPropValue( task, VCStatusProp, "COMPLETED");
108 111
109 QString string = QString::number(event.priority() ); 112 QString string = QString::number(event.priority() );
110 addPropValue( task, VCPriorityProp, string.local8Bit() ); 113 addPropValue( task, VCPriorityProp, string.local8Bit() );
111 114
112 addPropValue( task, VCCategoriesProp, 115 addPropValue( task, VCCategoriesProp,
113 event.idsToString( event.categories() ).local8Bit() ); 116 event.idsToString( event.categories() ).local8Bit() );
114 117
115#if 0 118#if 0
116 119
117 // There seems a misrepresentation between summary in otodoevent 120 // There seems a misrepresentation between summary in otodoevent
118 // and summary in vcard. 121 // and summary in vcard.
119 // The same with description.. 122 // The same with description..
120 // Description is summary and vice versa.. Argh.. (eilers) 123 // Description is summary and vice versa.. Argh.. (eilers)
121 124
122 125
123 addPropValue( task, VCDescriptionProp, 126 addPropValue( task, VCDescriptionProp,
124 event.description().local8Bit() ); 127 event.description().local8Bit() );
125 128
126 addPropValue( task, VCSummaryProp, 129 addPropValue( task, VCSummaryProp,
127 event.summary().local8Bit() ); 130 event.summary().local8Bit() );
128 131
129#else 132#else
130 addPropValue( task, VCDescriptionProp, 133 addPropValue( task, VCDescriptionProp,
131 event.summary().local8Bit() ); 134 event.summary().local8Bit() );
132 135
133 addPropValue( task, VCSummaryProp, 136 addPropValue( task, VCSummaryProp,
134 event.description().local8Bit() ); 137 event.description().local8Bit() );
135#endif 138#endif
136 return task; 139 return task;
137}; 140};
138} 141}
139 142
140namespace Opie { 143namespace Opie {
141OPimTodoAccessVCal::OPimTodoAccessVCal( const QString& path ) 144OPimTodoAccessVCal::OPimTodoAccessVCal( const QString& path )
142 : m_dirty(false), m_file( path ) 145 : m_dirty(false), m_file( path )
143{ 146{
144} 147}
145OPimTodoAccessVCal::~OPimTodoAccessVCal() { 148OPimTodoAccessVCal::~OPimTodoAccessVCal() {
146} 149}
147bool OPimTodoAccessVCal::load() { 150bool OPimTodoAccessVCal::load() {
148 m_map.clear(); 151 m_map.clear();
149 m_dirty = false; 152 m_dirty = false;
150 153
151 VObject* vcal = 0l; 154 VObject* vcal = 0l;
152 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 155 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
153 if (!vcal ) 156 if (!vcal )
154 return false; 157 return false;
155 158
156 // Iterate over the list 159 // Iterate over the list
157 VObjectIterator it; 160 VObjectIterator it;
158 VObject* vobj; 161 VObject* vobj;
159 162
160 initPropIterator(&it, vcal); 163 initPropIterator(&it, vcal);
161 164
162 while( moreIteration( &it ) ) { 165 while( moreIteration( &it ) ) {
163 vobj = ::nextVObject( &it ); 166 vobj = ::nextVObject( &it );
164 QCString name = ::vObjectName( vobj ); 167 QCString name = ::vObjectName( vobj );
165 if( name == VCTodoProp ){ 168 if( name == VCTodoProp ){
166 OPimTodo to = eventByVObj( vobj ); 169 OPimTodo to = eventByVObj( vobj );
167 m_map.insert( to.uid(), to ); 170 m_map.insert( to.uid(), to );
168 } 171 }
169 } 172 }
170 173
171 // Should I do a delete vcal? 174 // Should I do a delete vcal?
172 175
173 return true; 176 return true;
174} 177}
175bool OPimTodoAccessVCal::reload() { 178bool OPimTodoAccessVCal::reload() {
176 return load(); 179 return load();
177} 180}
178bool OPimTodoAccessVCal::save() { 181bool OPimTodoAccessVCal::save() {
179 if (!m_dirty ) 182 if (!m_dirty )
180 return true; 183 return true;
181 184
182 QFileDirect file( m_file ); 185 QFile file( m_file );
183 if (!file.open(IO_WriteOnly ) ) 186 if (!file.open(IO_WriteOnly ) )
184 return false; 187 return false;
185 188
186 VObject *obj; 189 VObject *obj;
187 obj = newVObject( VCCalProp ); 190 obj = newVObject( VCCalProp );
188 addPropValue( obj, VCVersionProp, "1.0" ); 191 addPropValue( obj, VCVersionProp, "1.0" );
189 VObject *vo; 192 VObject *vo;
190 for(QMap<int, OPimTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 193 for(QMap<int, OPimTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
191 vo = vobjByEvent( it.data() ); 194 vo = vobjByEvent( it.data() );
192 addVObjectProp(obj, vo ); 195 addVObjectProp(obj, vo );
193 } 196 }
194 writeVObject( file.directHandle(), obj ); 197 writeVObject( file.fh, obj ); //FIXME: HACK!!!
195 cleanVObject( obj ); 198 cleanVObject( obj );
196 cleanStrTbl(); 199 cleanStrTbl();
197 200
198 m_dirty = false; 201 m_dirty = false;
199 return true; 202 return true;
200} 203}
201void OPimTodoAccessVCal::clear() { 204void OPimTodoAccessVCal::clear() {
202 m_map.clear(); 205 m_map.clear();
203 m_dirty = true; 206 m_dirty = true;
204} 207}
205bool OPimTodoAccessVCal::add( const OPimTodo& to ) { 208bool OPimTodoAccessVCal::add( const OPimTodo& to ) {
206 m_map.insert( to.uid(), to ); 209 m_map.insert( to.uid(), to );
207 m_dirty = true; 210 m_dirty = true;
208 return true; 211 return true;
209} 212}
210bool OPimTodoAccessVCal::remove( int uid ) { 213bool OPimTodoAccessVCal::remove( int uid ) {
211 m_map.remove( uid ); 214 m_map.remove( uid );
212 m_dirty = true; 215 m_dirty = true;
213 return true; 216 return true;
214} 217}
215void OPimTodoAccessVCal::removeAllCompleted() { 218void OPimTodoAccessVCal::removeAllCompleted() {
216 for ( QMap<int, OPimTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { 219 for ( QMap<int, OPimTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) {
217 if ( (*it).isCompleted() ) 220 if ( (*it).isCompleted() )
218 m_map.remove( it ); 221 m_map.remove( it );
219 } 222 }
220} 223}
221bool OPimTodoAccessVCal::replace( const OPimTodo& to ) { 224bool OPimTodoAccessVCal::replace( const OPimTodo& to ) {
222 m_map.replace( to.uid(), to ); 225 m_map.replace( to.uid(), to );
223 m_dirty = true; 226 m_dirty = true;
224 return true; 227 return true;
225} 228}
226OPimTodo OPimTodoAccessVCal::find(int uid )const { 229OPimTodo OPimTodoAccessVCal::find(int uid )const {
227 return m_map[uid]; 230 return m_map[uid];
228} 231}
229QArray<int> OPimTodoAccessVCal::sorted( bool, int, int, int ) { 232QArray<int> OPimTodoAccessVCal::sorted( bool, int, int, int ) {
230 QArray<int> ar(0); 233 QArray<int> ar(0);
231 return ar; 234 return ar;
232} 235}
233QArray<int> OPimTodoAccessVCal::allRecords()const { 236QArray<int> OPimTodoAccessVCal::allRecords()const {
234 QArray<int> ar( m_map.count() ); 237 QArray<int> ar( m_map.count() );
235 QMap<int, OPimTodo>::ConstIterator it; 238 QMap<int, OPimTodo>::ConstIterator it;
236 int i = 0; 239 int i = 0;
237 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 240 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
238 ar[i] = it.key(); 241 ar[i] = it.key();
239 i++; 242 i++;
240 } 243 }
241 return ar; 244 return ar;
242} 245}
243QArray<int> OPimTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const { 246QArray<int> OPimTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const {
244 QArray<int> ar(0); 247 QArray<int> ar(0);
245 return ar; 248 return ar;
246} 249}
247QArray<int> OPimTodoAccessVCal::queryByExample( const OPimTodo&, int, const QDateTime& ) { 250QArray<int> OPimTodoAccessVCal::queryByExample( const OPimTodo&, int, const QDateTime& ) {
248 QArray<int> ar(0); 251 QArray<int> ar(0);
249 return ar; 252 return ar;
250} 253}
251QArray<int> OPimTodoAccessVCal::effectiveToDos( const QDate& , 254QArray<int> OPimTodoAccessVCal::effectiveToDos( const QDate& ,
252 const QDate& , 255 const QDate& ,
253 bool ) { 256 bool ) {
254 QArray<int> ar(0); 257 QArray<int> ar(0);
255 return ar; 258 return ar;
256} 259}
257QArray<int> OPimTodoAccessVCal::overDue() { 260QArray<int> OPimTodoAccessVCal::overDue() {
258 QArray<int> ar(0); 261 QArray<int> ar(0);
259 return ar; 262 return ar;
260} 263}
261QBitArray OPimTodoAccessVCal::supports()const { 264QBitArray OPimTodoAccessVCal::supports()const {
262 static QBitArray ar = sup(); 265 static QBitArray ar = sup();
263 266
264 return ar; 267 return ar;
265} 268}
266QBitArray OPimTodoAccessVCal::sup() { 269QBitArray OPimTodoAccessVCal::sup() {
267 QBitArray ar ( OPimTodo::CompletedDate +1 ); 270 QBitArray ar ( OPimTodo::CompletedDate +1 );
268 ar.fill( true ); 271 ar.fill( true );
269 272
270 ar[OPimTodo::CrossReference] = false; 273 ar[OPimTodo::CrossReference] = false;
271 ar[OPimTodo::State ] = false; 274 ar[OPimTodo::State ] = false;
272 ar[OPimTodo::Reminders] = false; 275 ar[OPimTodo::Reminders] = false;
273 ar[OPimTodo::Notifiers] = false; 276 ar[OPimTodo::Notifiers] = false;
274 ar[OPimTodo::Maintainer] = false; 277 ar[OPimTodo::Maintainer] = false;
275 ar[OPimTodo::Progress] = false; 278 ar[OPimTodo::Progress] = false;
276 ar[OPimTodo::Alarms ] = false; 279 ar[OPimTodo::Alarms ] = false;
277 ar[OPimTodo::Recurrence] = false; 280 ar[OPimTodo::Recurrence] = false;
278 281
279 return ar; 282 return ar;
280} 283}
281 284
282} 285}
diff --git a/libopie2/opiepim/private/vobject_p.h b/libopie2/opiepim/private/vobject_p.h
new file mode 100644
index 0000000..3c9d0d3
--- a/dev/null
+++ b/libopie2/opiepim/private/vobject_p.h
@@ -0,0 +1,408 @@
1/***************************************************************************
2(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
3Business Machines Corporation and Siemens Rolm Communications Inc.
4
5For purposes of this license notice, the term Licensors shall mean,
6collectively, Apple Computer, Inc., AT&T Corp., International
7Business Machines Corporation and Siemens Rolm Communications Inc.
8The term Licensor shall mean any of the Licensors.
9
10Subject to acceptance of the following conditions, permission is hereby
11granted by Licensors without the need for written agreement and without
12license or royalty fees, to use, copy, modify and distribute this
13software for any purpose.
14
15The above copyright notice and the following four paragraphs must be
16reproduced in all copies of this software and any software including
17this software.
18
19THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
20ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
21MODIFICATIONS.
22
23IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
24INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
25OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26DAMAGE.
27
28EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
29INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
30IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31PURPOSE.
32
33The software is provided with RESTRICTED RIGHTS. Use, duplication, or
34disclosure by the government are subject to restrictions set forth in
35DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
36
37***************************************************************************/
38
39/*
40
41The vCard/vCalendar C interface is implemented in the set
42of files as follows:
43
44vcc.y, yacc source, and vcc.c, the yacc output you will use
45implements the core parser
46
47vobject.c implements an API that insulates the caller from
48the parser and changes in the vCard/vCalendar BNF
49
50port.h defines compilation environment dependent stuff
51
52vcc.h and vobject.h are header files for their .c counterparts
53
54vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions
55which you may find useful.
56
57test.c is a standalone test driver that exercises some of
58the features of the APIs provided. Invoke test.exe on a
59VCARD/VCALENDAR input text file and you will see the pretty
60print output of the internal representation (this pretty print
61output should give you a good idea of how the internal
62representation looks like -- there is one such output in the
63following too). Also, a file with the .out suffix is generated
64to show that the internal representation can be written back
65in the original text format.
66
67For more information on this API see the readme.txt file
68which accompanied this distribution.
69
70 Also visit:
71
72 http://www.versit.com
73 http://www.ralden.com
74
75*/
76
77// No tr() anywhere in this file
78
79
80#ifndef __VOBJECT_H__
81#define __VOBJECT_H__ 1
82
83#include <qstring.h>
84
85 #define vCardClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCard"
86 #define vCalendarClipboardFormat"+//ISBN 1-887687-00-9::versit::PDI//vCalendar"
87
88/* The above strings vCardClipboardFormat and vCalendarClipboardFormat
89are globally unique IDs which can be used to generate clipboard format
90ID's as per the requirements of a specific platform. For example, in
91Windows they are used as the parameter in a call to RegisterClipboardFormat.
92For example:
93
94 CLIPFORMAT foo = RegisterClipboardFormat(vCardClipboardFormat);
95
96*/
97
98 #define vCardMimeType "text/x-vCard"
99 #define vCalendarMimeType"text/x-vCalendar"
100
101#undef DLLEXPORT
102#include <qtopia/global.h>
103#if defined(QTOPIA_MAKEDLL)
104#define DLLEXPORT(t) __declspec(dllexport) t
105#elif defined(QTOPIA_DLL)
106#define DLLEXPORT(t) __declspec(dllimport) t
107#else
108#define DLLEXPORT(t) t
109#endif
110
111#ifndef FALSE
112 #define FALSE0
113#endif
114#ifndef TRUE
115 #define TRUE1
116#endif
117
118#include <stdlib.h>
119#include <stdio.h>
120
121
122 #define VC7bitProp "7BIT"
123 #define VC8bitProp "8BIT"
124 #define VCAAlarmProp "AALARM"
125 #define VCAdditionalNamesProp"ADDN"
126 #define VCAdrProp "ADR"
127 #define VCAgentProp "AGENT"
128 #define VCAIFFProp "AIFF"
129 #define VCAOLProp "AOL"
130 #define VCAppleLinkProp "APPLELINK"
131 #define VCAttachProp "ATTACH"
132 #define VCAttendeeProp "ATTENDEE"
133 #define VCATTMailProp "ATTMAIL"
134 #define VCAudioContentProp "AUDIOCONTENT"
135 #define VCAVIProp "AVI"
136 #define VCBase64Prop "BASE64"
137 #define VCBBSProp "BBS"
138 #define VCBirthDateProp "BDAY"
139 #define VCBMPProp "BMP"
140 #define VCBodyProp "BODY"
141 #define VCBusinessRoleProp "ROLE"
142 #define VCCalProp "VCALENDAR"
143 #define VCCaptionProp "CAP"
144 #define VCCardProp "VCARD"
145 #define VCCarProp "CAR"
146 #define VCCategoriesProp "CATEGORIES"
147 #define VCCellularProp "CELL"
148 #define VCCGMProp "CGM"
149 #define VCCharSetProp "CHARSET"
150 #define VCCIDProp "CID"
151 #define VCCISProp "CIS"
152 #define VCCityProp "L"
153 #define VCClassProp "CLASS"
154 #define VCCommentProp "NOTE"
155 #define VCCompletedProp "COMPLETED"
156 #define VCContentIDProp "CONTENT-ID"
157 #define VCCountryNameProp "C"
158 #define VCDAlarmProp "DALARM"
159 #define VCDataSizeProp "DATASIZE"
160 #define VCDayLightProp "DAYLIGHT"
161 #define VCDCreatedProp "DCREATED"
162#define VCDeliveryLabelProp "LABEL"
163 #define VCDescriptionProp "DESCRIPTION"
164 #define VCDIBProp "DIB"
165 #define VCDisplayStringProp "DISPLAYSTRING"
166 #define VCDomesticProp "DOM"
167 #define VCDTendProp "DTEND"
168 #define VCDTstartProp "DTSTART"
169 #define VCDueProp "DUE"
170 #define VCEmailAddressProp "EMAIL"
171 #define VCEncodingProp "ENCODING"
172 #define VCEndProp "END"
173 #define VCEventProp "VEVENT"
174 #define VCEWorldProp "EWORLD"
175 #define VCExNumProp "EXNUM"
176 #define VCExpDateProp "EXDATE"
177 #define VCExpectProp "EXPECT"
178 #define VCExtAddressProp "EXT ADD"
179 #define VCFamilyNameProp "F"
180 #define VCFaxProp "FAX"
181 #define VCFullNameProp "FN"
182 #define VCGeoProp "GEO"
183 #define VCGeoLocationProp "GEO"
184 #define VCGIFProp "GIF"
185 #define VCGivenNameProp "G"
186 #define VCGroupingProp "Grouping"
187 #define VCHomeProp "HOME"
188 #define VCIBMMailProp "IBMMail"
189 #define VCInlineProp "INLINE"
190 #define VCInternationalProp "INTL"
191 #define VCInternetProp "INTERNET"
192 #define VCISDNProp "ISDN"
193 #define VCJPEGProp "JPEG"
194 #define VCLanguageProp "LANG"
195 #define VCLastModifiedProp "LAST-MODIFIED"
196 #define VCLastRevisedProp "REV"
197 #define VCLocationProp "LOCATION"
198 #define VCLogoProp "LOGO"
199 #define VCMailerProp "MAILER"
200 #define VCMAlarmProp "MALARM"
201 #define VCMCIMailProp "MCIMAIL"
202 #define VCMessageProp "MSG"
203 #define VCMETProp "MET"
204 #define VCModemProp "MODEM"
205 #define VCMPEG2Prop "MPEG2"
206 #define VCMPEGProp "MPEG"
207 #define VCMSNProp "MSN"
208 #define VCNamePrefixesProp "NPRE"
209 #define VCNameProp "N"
210 #define VCNameSuffixesProp "NSUF"
211 #define VCNoteProp "NOTE"
212 #define VCOrgNameProp "ORGNAME"
213 #define VCOrgProp "ORG"
214 #define VCOrgUnit2Prop "OUN2"
215 #define VCOrgUnit3Prop "OUN3"
216 #define VCOrgUnit4Prop "OUN4"
217 #define VCOrgUnitProp "OUN"
218 #define VCPagerProp "PAGER"
219 #define VCPAlarmProp "PALARM"
220 #define VCParcelProp "PARCEL"
221 #define VCPartProp "PART"
222 #define VCPCMProp "PCM"
223 #define VCPDFProp "PDF"
224 #define VCPGPProp "PGP"
225 #define VCPhotoProp "PHOTO"
226 #define VCPICTProp "PICT"
227 #define VCPMBProp "PMB"
228 #define VCPostalBoxProp "BOX"
229 #define VCPostalCodeProp "PC"
230 #define VCPostalProp "POSTAL"
231 #define VCPowerShareProp "POWERSHARE"
232 #define VCPreferredProp "PREF"
233 #define VCPriorityProp "PRIORITY"
234 #define VCProcedureNameProp "PROCEDURENAME"
235 #define VCProdIdProp "PRODID"
236 #define VCProdigyProp "PRODIGY"
237 #define VCPronunciationProp "SOUND"
238 #define VCPSProp "PS"
239 #define VCPublicKeyProp "KEY"
240 #define VCQPProp "QP"
241 #define VCQuickTimeProp "QTIME"
242 #define VCQuotedPrintableProp"QUOTED-PRINTABLE"
243 #define VCRDateProp "RDATE"
244 #define VCRegionProp "R"
245 #define VCRelatedToProp "RELATED-TO"
246 #define VCRepeatCountProp "REPEATCOUNT"
247 #define VCResourcesProp "RESOURCES"
248 #define VCRNumProp "RNUM"
249 #define VCRoleProp "ROLE"
250 #define VCRRuleProp "RRULE"
251 #define VCRSVPProp "RSVP"
252 #define VCRunTimeProp "RUNTIME"
253 #define VCSequenceProp "SEQUENCE"
254 #define VCSnoozeTimeProp "SNOOZETIME"
255 #define VCStartProp "START"
256 #define VCStatusProp "STATUS"
257 #define VCStreetAddressProp "STREET"
258 #define VCSubTypeProp "SUBTYPE"
259 #define VCSummaryProp "SUMMARY"
260 #define VCTelephoneProp "TEL"
261 #define VCTIFFProp "TIFF"
262 #define VCTimeZoneProp "TZ"
263 #define VCTitleProp "TITLE"
264 #define VCTLXProp "TLX"
265 #define VCTodoProp "VTODO"
266 #define VCTranspProp "TRANSP"
267 #define VCUniqueStringProp "UID"
268 #define VCURLProp "URL"
269 #define VCURLValueProp "URLVAL"
270 #define VCValueProp "VALUE"
271 #define VCVersionProp "VERSION"
272 #define VCVideoProp "VIDEO"
273 #define VCVoiceProp "VOICE"
274 #define VCWAVEProp "WAVE"
275 #define VCWMFProp "WMF"
276 #define VCWorkProp "WORK"
277 #define VCX400Prop "X400"
278 #define VCX509Prop "X509"
279 #define VCXRuleProp "XRULE"
280
281
282typedef struct VObject VObject;
283
284typedef struct VObjectIterator {
285 VObject* start;
286 VObject* next;
287 } VObjectIterator;
288
289extern DLLEXPORT(VObject*) newVObject(const char *id);
290extern DLLEXPORT(void) deleteVObject(VObject *p);
291extern DLLEXPORT(char*) dupStr(const char *s, unsigned int size);
292extern DLLEXPORT(void) deleteStr(const char *p);
293extern DLLEXPORT(void) unUseStr(const char *s);
294
295extern DLLEXPORT(void) setVObjectName(VObject *o, const char* id);
296extern DLLEXPORT(void) setVObjectStringZValue(VObject *o, const char *s);
297extern DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s);
298extern DLLEXPORT(void) setVObjectIntegerValue(VObject *o, unsigned int i);
299extern DLLEXPORT(void) setVObjectLongValue(VObject *o, unsigned long l);
300extern DLLEXPORT(void) setVObjectAnyValue(VObject *o, void *t);
301extern DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size);
302extern DLLEXPORT(VObject*) setValueWithSize_(VObject *prop, void *val, unsigned int size);
303
304extern DLLEXPORT(const char*) vObjectName(VObject *o);
305extern DLLEXPORT(const char*) vObjectStringZValue(VObject *o);
306extern DLLEXPORT(unsigned int) vObjectIntegerValue(VObject *o);
307extern DLLEXPORT(unsigned long) vObjectLongValue(VObject *o);
308extern DLLEXPORT(void*) vObjectAnyValue(VObject *o);
309extern DLLEXPORT(VObject*) vObjectVObjectValue(VObject *o);
310extern DLLEXPORT(void) setVObjectVObjectValue(VObject *o, VObject *p);
311
312extern DLLEXPORT(VObject*) addVObjectProp(VObject *o, VObject *p);
313extern DLLEXPORT(VObject*) addProp(VObject *o, const char *id);
314extern DLLEXPORT(VObject*) addProp_(VObject *o, const char *id);
315extern DLLEXPORT(VObject*) addPropValue(VObject *o, const char *p, const char *v);
316extern DLLEXPORT(VObject*) addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size);
317extern DLLEXPORT(VObject*) addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size);
318extern DLLEXPORT(VObject*) addGroup(VObject *o, const char *g);
319extern DLLEXPORT(void) addList(VObject **o, VObject *p);
320
321extern DLLEXPORT(VObject*) isAPropertyOf(VObject *o, const char *id);
322
323extern DLLEXPORT(VObject*) nextVObjectInList(VObject *o);
324extern DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o);
325extern DLLEXPORT(int) moreIteration(VObjectIterator *i);
326extern DLLEXPORT(VObject*) nextVObject(VObjectIterator *i);
327
328extern DLLEXPORT(const char*) lookupStr(const char *s);
329extern DLLEXPORT(void) cleanStrTbl();
330
331extern DLLEXPORT(void) cleanVObject(VObject *o);
332extern DLLEXPORT(void) cleanVObjects(VObject *list);
333
334extern DLLEXPORT(const char*) lookupProp(const char* str);
335extern DLLEXPORT(const char*) lookupProp_(const char* str);
336
337extern DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o);
338extern DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list);
339
340extern DLLEXPORT(int) vObjectValueType(VObject *o);
341
342/* return type of vObjectValueType: */
343 #define VCVT_NOVALUE0
344 /* if the VObject has no value associated with it. */
345 #define VCVT_STRINGZ1
346 /* if the VObject has value set by setVObjectStringZValue. */
347 #define VCVT_UINT 2
348 /* if the VObject has value set by setVObjectIntegerValue. */
349 #define VCVT_ULONG 3
350 /* if the VObject has value set by setVObjectLongValue. */
351 #define VCVT_RAW 4
352 /* if the VObject has value set by setVObjectAnyValue. */
353 #define VCVT_VOBJECT5
354 /* if the VObject has value set by setVObjectVObjectValue. */
355
356extern DLLEXPORT(const char**) fieldedProp;
357
358/***************************************************
359 * The methods below are implemented in vcc.c (generated from vcc.y )
360 ***************************************************/
361
362/* NOTE regarding printVObject and writeVObject
363
364The functions below are not exported from the DLL because they
365take a FILE* as a parameter, which cannot be passed across a DLL
366interface (at least that is my experience). Instead you can use
367their companion functions which take file names or pointers
368to memory. However, if you are linking this code into
369your build directly then you may find them a more convenient API
370and you can go ahead and use them. If you try to use them with
371the DLL LIB you will get a link error.
372*/
373extern DLLEXPORT(void) writeVObject(FILE *fp, VObject *o);
374
375
376
377typedef void (*MimeErrorHandler)(char *);
378
379extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler);
380
381extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len);
382extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname);
383
384
385/* NOTE regarding Parse_MIME_FromFile
386The function above, Parse_MIME_FromFile, comes in two flavors,
387neither of which is exported from the DLL. Each version takes
388a CFile or FILE* as a parameter, neither of which can be
389passed across a DLL interface (at least that is my experience).
390If you are linking this code into your build directly then
391you may find them a more convenient API that the other flavors
392that take a file name. If you use them with the DLL LIB you
393will get a link error.
394*/
395
396
397#if INCLUDEMFC
398extern DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file);
399#else
400extern DLLEXPORT(VObject*) Parse_MIME_FromFile(FILE *file);
401#endif
402
403extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o);
404
405
406#endif /* __VOBJECT_H__ */
407
408