1 bcardeng.h |
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * A class to convert Phonebook items to vCard stream and vice versa |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __BCARDENG_H__ |
|
21 #define __BCARDENG_H__ |
|
22 |
|
23 |
|
24 // INCLUDES |
|
25 #include <badesca.h> // CDesCArrayFlat |
|
26 #include "PbkFields.hrh" // TPbkFieldId |
|
27 |
|
28 |
|
29 // CONSTANTS |
|
30 _LIT(KPbkvCardFileExtension, ".vcf"); |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CPbkContactEngine; |
|
34 class CPbkContactItem; |
|
35 class RWriteStream; |
|
36 class CBCardFieldUidMapping; |
|
37 class CBCardExportProperty; |
|
38 class CParserVCard; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 /** |
|
43 * The business card engine is able to import and export vCards and Compact |
|
44 * Business Cards to and from Phonebook. |
|
45 */ |
|
46 class CBCardEngine : public CBase |
|
47 { |
|
48 public: // Constructors and destructor |
|
49 /** |
|
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. |
|
53 */ |
|
54 IMPORT_C static CBCardEngine* NewL(CPbkContactEngine* aEngine); |
|
55 |
|
56 /** |
|
57 * Destructor |
|
58 */ |
|
59 IMPORT_C ~CBCardEngine(); |
|
60 |
|
61 public: // The main public interface |
|
62 /** |
|
63 * Reads a vCard record from a stream into a Phonebook contact |
|
64 * item. |
|
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 |
|
69 */ |
|
70 IMPORT_C void ImportBusinessCardL(CPbkContactItem& aDestItem, |
|
71 RReadStream &aSourceStream); |
|
72 |
|
73 /** |
|
74 * Writes a vCard record with information from a Phonebook contact |
|
75 * item. |
|
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 |
|
79 * should be read from |
|
80 */ |
|
81 IMPORT_C void ExportBusinessCardL(RWriteStream& aDestStream, |
|
82 CPbkContactItem& aSourceItem); |
|
83 |
|
84 /** |
|
85 * Reads a Compact Business Card record from a stream into a Phonebook |
|
86 * contact item. |
|
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 |
|
91 * is read from |
|
92 * @return ETrue on success |
|
93 */ |
|
94 IMPORT_C TBool ImportCompactBusinessCardL(CPbkContactItem& aDestItem, |
|
95 RReadStream &aSourceStream); |
|
96 |
|
97 /** |
|
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 |
|
101 */ |
|
102 IMPORT_C TBool SupportsFieldType(TPbkFieldId aFieldId); |
|
103 |
|
104 private: // Constructors |
|
105 CBCardEngine(); |
|
106 void ConstructL(CPbkContactEngine* aEngine); |
|
107 |
|
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; |
|
116 |
|
117 private: |
|
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; |
|
130 }; |
|
131 |
|
132 #endif // __BCARDENG_H__ |
|
133 |
|
134 // End of File |