1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
26 /** This constant is for internal use only.
29 _LIT(KVersitTokenVCardVersionNo, "2.1");
32 class CVCard3ParserPlugIn;
37 class CParserVCard : public CVersitParser
40 Adds support for property groups (see CParserGroupedProperty) and agents
41 (see CParserPropertyValueAgent) to the functionality of CVersitParser.
43 Provides a constructor and overrides CVersitParser::InternalizeL(),
44 ExternalizeL(), RecognizeToken(), ConvertAllPropertyDateTimesToMachineLocalL(),
45 ParsePropertyL() and MakePropertyValueL().
47 The vCard data is read from or written to a stream or file, using the InternalizeL()
48 and ExternalizeL() functions. Most users of this class will only need to use
51 If you are sequentially creating and destroying multiple parsers, a major performance
52 improvement may be achieved by using thread local storage to store an instance of
53 CVersitUnicodeUtils which persists and can be used by all of the parsers.
55 See CVersitTlsData for more information.
61 IMPORT_C static CParserVCard* NewL();
62 static CParserVCard* NewL(TBool aParsingAgent);
63 IMPORT_C CArrayPtr<CParserProperty>* GroupOfPropertiesL(const TDesC8& aName) const;
64 public: //from CVersitParser
65 IMPORT_C void InternalizeL(RReadStream& aStream);
66 IMPORT_C void ExternalizeL(RWriteStream& aStream);
67 IMPORT_C void ConvertAllPropertyDateTimesToMachineLocalL(const TTimeIntervalSeconds& aIncrement,const CVersitDaylight* aDaylight);
69 IMPORT_C virtual CParserPropertyValue* MakePropertyValueAgentL(TPtr16 aValue);
70 IMPORT_C CDesC8Array* GetGroupNamesL(TPtr8& aGroupsAndName);
71 protected: // from CVersitParser
72 IMPORT_C void ParsePropertyL();
73 IMPORT_C CParserPropertyValue* MakePropertyValueL(const TUid& aPropertyUid,HBufC16*& aValue);
74 IMPORT_C CParserPropertyValue* MakePropertyValueSoundL(HBufC16*& aValue);
75 public: //from CVersitParser
76 IMPORT_C TUid RecognizeToken(const TDesC8& aToken) const;
77 IMPORT_C void ConvertDateTimesToMachineLocalAndDeleteTZL();
80 CParserVCard(TBool aParsingAgent);
81 private: // from CVersitParser
82 IMPORT_C virtual void Reserved1();
83 IMPORT_C virtual void Reserved2();
87 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
88 NONSHARABLE_CLASS(CParserVCard3) : public CParserVCard
89 /** A vCard 3.0 parser.
91 Overrides CParserVCard::InternalizeL(). Internalizing of vCard 3.0
92 objects is not supported
99 IMPORT_C static CParserVCard3* NewL();
102 public: //from CParserVCard
103 IMPORT_C void InternalizeL(RReadStream& aStream);
108 void CreateParserPlugInL();
111 CVCard3ParserPlugIn* iPlugInImpl;
113 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
115 // CParserGroupedProperty
117 class CParserGroupedProperty : public CParserProperty
118 /** A grouped property.
120 This is a vCard property which may be a member of one or more property groups.
121 It owns an array of descriptors, each of which identifies a group
122 to which the property belongs.
124 An example of how grouped properties may be useful is for a person with two
125 homes. Each home has an address and telephone number, both of which are to
126 be stored on the vCard. The address and telephone number are grouped for each
127 home. A prefix for the address and telephone number properties is provided:
128 one for each home. Each prefix is stored as a property group.
130 When the property is externalised, the identities of all the groups to which
131 the property belongs (i.e. the prefixes) are written to the stream before
132 CParserProperty::ExternalizeL() is called.
134 The class also provides a function which can be used to test whether
135 the property is a member of a given group.
137 Note that the vCard parser stores all properties using this class; if the
138 vCard property is not grouped then the array of property groups is empty.
139 Conversely, the vCalender parser does not have property groups, and so stores
140 all properties using the CParserProperty base class.
146 IMPORT_C static CParserGroupedProperty* NewL(CParserPropertyValue& aPropertyValue, const TDesC8& aName, CDesC8Array* aArrayOfGroups, CArrayPtr<CParserParam>* aArrayOfParams);
147 IMPORT_C CParserGroupedProperty(CDesC8Array* aArrayOfGroups, CArrayPtr<CParserParam>* aArrayOfParams);
148 IMPORT_C ~CParserGroupedProperty();
149 IMPORT_C TBool Group(const TDesC8& aGroup) const;
150 inline void SetGroups(CDesC8Array* aArrayOfGroups);
151 inline const CDesC8Array* Groups();
152 public: //from CParserProperty
153 IMPORT_C TBool SupportsInterface(const TUid& aInterfaceUid) const;
154 IMPORT_C void ExternalizeL(RWriteStream& aStream, CVersitParser* aVersitParser = NULL);
156 CParserGroupedProperty(CParserPropertyValue& aPropertyValue, CDesC8Array* aArrayOfGroups, CArrayPtr<CParserParam>* aArrayOfParams);
157 private: //from CParserProperty
158 IMPORT_C virtual void Reserved();
160 CDesC8Array* iArrayOfGroups;
164 // CParserPropertyValueAgent
166 class CParserPropertyValueAgent : public CParserPropertyValue
167 /** An agent property value parser.
169 An agent property value contains information about a person who is not the
170 main subject of the vCard. It is implemented as a vCard nested within another
171 vCard. The agent's vCard is held in the property value of the parent vCard.
173 We do not support nested agents when parsing an agent's vcard.
175 The UID for an agent property value is KVCardPropertyAgentUid.
181 IMPORT_C CParserPropertyValueAgent(CParserVCard* aValue);
182 IMPORT_C ~CParserPropertyValueAgent();
183 inline CParserVCard* Value() const;
185 public: // from CParserPropertyValue
186 IMPORT_C void ExternalizeL(RWriteStream& aStream,const Versit::TEncodingAndCharset& /*aEncodingCharset*/,TInt /*aLengthOutput*/);
188 CParserVCard* iValue;