summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show 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
@@ -29,13 +29,18 @@
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
@@ -94,7 +99,7 @@ bool OPimContactAccessBackend_VCard::save()
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
@@ -105,7 +110,7 @@ bool OPimContactAccessBackend_VCard::save()
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();
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
@@ -26,14 +26,17 @@
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 {
@@ -179,7 +182,7 @@ bool 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
@@ -191,7 +194,7 @@ bool OPimTodoAccessVCal::save() {
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
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