2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * A class to convert Phonebook items to vCard stream and vice versa
20 #ifndef __BCARDENG_H__
21 #define __BCARDENG_H__
25 #include <badesca.h> // CDesCArrayFlat
26 #include "PbkFields.hrh" // TPbkFieldId
30 _LIT(KPbkvCardFileExtension, ".vcf");
32 // FORWARD DECLARATIONS
33 class CPbkContactEngine;
34 class CPbkContactItem;
36 class CBCardFieldUidMapping;
37 class CBCardExportProperty;
43 * The business card engine is able to import and export vCards and Compact
44 * Business Cards to and from Phonebook.
46 class CBCardEngine : public CBase
48 public: // Constructors and destructor
50 * Creates a new instance of this class.
51 * @param aEngine An open Phonebook Engine object which CBCardEngine
52 * uses to import and export vCard data.
54 IMPORT_C static CBCardEngine* NewL(CPbkContactEngine* aEngine);
59 IMPORT_C ~CBCardEngine();
61 public: // The main public interface
63 * Reads a vCard record from a stream into a Phonebook contact
65 * @param aDestItem Phonebook contact item where the information
66 * should be written to. The item should be writable. The
67 * caller should commit the changes.
68 * @param aSourceStream A stream where the vCard data is read from
70 IMPORT_C void ImportBusinessCardL(CPbkContactItem& aDestItem,
71 RReadStream &aSourceStream);
74 * Writes a vCard record with information from a Phonebook contact
76 * @param aDestStream A stream where the vCard data is written to.
77 * The data written to the stream is not Committed by this method.
78 * @param aSourceItem Phonebook contact item where the information
81 IMPORT_C void ExportBusinessCardL(RWriteStream& aDestStream,
82 CPbkContactItem& aSourceItem);
85 * Reads a Compact Business Card record from a stream into a Phonebook
87 * @param aDestItem Phonebook contact item where the information
88 * must be written to. The item must be writable.
89 * The caller should commit the changes.
90 * @param aSourceStream A stream where the Compact Business Card
92 * @return ETrue on success
94 IMPORT_C TBool ImportCompactBusinessCardL(CPbkContactItem& aDestItem,
95 RReadStream &aSourceStream);
98 * Checks if given field is supported by the vCard format
99 * @param aFieldId Field id type
100 * @return ETrue if given field is supported, EFalse otherwise
102 IMPORT_C TBool SupportsFieldType(TPbkFieldId aFieldId);
104 private: // Constructors
106 void ConstructL(CPbkContactEngine* aEngine);
108 private: // Private utility methods
109 void ProcessExportPropertyL(
110 CParserVCard& aParser,
111 CPbkContactItem& aSourceItem,
112 const CBCardExportProperty& aExportProperty);
113 TInt GetLineFromStreamL(TDes& aBuf, RReadStream& aSourceStream);
114 TInt GetByteFromStream(TUint8& aByte, RReadStream& aSourceStream);
115 class CBCardFieldAction;
118 /// Own: Filename for picture
119 HBufC* iPictureFileName;
120 /// Own: Filename for thumbnail
121 HBufC* iThumbnailFileName;
122 /// Own: Instance for property name-Uid mapping
123 CBCardFieldUidMapping* iNameUidMap;
124 /// Own: Instance for contact field handling
125 CBCardFieldAction* iFieldAction;
126 /// Ref: Phonebook engine
127 CPbkContactEngine* iEngine;
128 /// Own: Array of CBCardExportProperty instances for exporting contact
129 RPointerArray<CBCardExportProperty> iExportProperties;
132 #endif // __BCARDENG_H__