|
1 /* |
|
2 * Copyright (c) 2008 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 "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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Converts vCard <-> PIM API |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPIMCARDCONVERTER_H |
|
20 #define CPIMCARDCONVERTER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> // CBase |
|
24 #include <vutil.h> // Versit |
|
25 #include "pimcontact.h" // TPIMContactField |
|
26 #include "pimcommon.h" // TPIMAttribute |
|
27 #include "functionserver.h" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CPIMItem; |
|
31 class RWriteStream; |
|
32 class RReadStream; |
|
33 class CParserVCard; |
|
34 class CPIMContactValidator; |
|
35 class CPIMContactItem; |
|
36 class CPIMCardPropertyConverter; |
|
37 |
|
38 // CLASS DECLARATION |
|
39 |
|
40 /** |
|
41 * Converts PIM Contact Items <-> vCards. |
|
42 * vCards are stored in streams. |
|
43 */ |
|
44 NONSHARABLE_CLASS(CPIMCardConverter): public CBase |
|
45 { |
|
46 public: // Constructors and destructor |
|
47 |
|
48 /** |
|
49 * Two-phased constructor. |
|
50 */ |
|
51 static CPIMCardConverter* NewL( |
|
52 const CPIMContactValidator& aContactValidator, |
|
53 java::util::FunctionServer* aFuncServer); |
|
54 |
|
55 /** |
|
56 * Destructor. |
|
57 */ |
|
58 virtual ~CPIMCardConverter(); |
|
59 |
|
60 public: // New functions |
|
61 |
|
62 /** |
|
63 * Converts Contact Items to vCards. |
|
64 * The converted vCards are stored in a stream. |
|
65 * |
|
66 * @param aStream RWriteStream to write the vCard to. |
|
67 * @param aItem CPIMItem which is to be converted. |
|
68 */ |
|
69 void ItemToStreamL(RWriteStream& aStream, |
|
70 const CPIMItem& aItem, |
|
71 Versit::TVersitCharSet aCharset); |
|
72 |
|
73 /** |
|
74 * Converts vCards to contact items. |
|
75 * |
|
76 * @param aStream RReadStream to be converted. |
|
77 * @param aItemArray Array where the created items are stored |
|
78 * @par Leaving: |
|
79 * @li \c KErrCorrupt - \a No items could be created |
|
80 */ |
|
81 void StreamToItemL(RReadStream& aStream, |
|
82 RPointerArray<CPIMItem>& aItemArray, |
|
83 Versit::TVersitCharSet aCharset); |
|
84 |
|
85 private: |
|
86 |
|
87 /** |
|
88 * Converts vCards to contact items. |
|
89 * |
|
90 * @param aParser vCard to convert |
|
91 * @param aItemArray Array where the created items are stored |
|
92 * @param aParserArray Array where contained vCards are stored |
|
93 */ |
|
94 void ParserToItemL(CParserVCard& aParser, |
|
95 RPointerArray<CPIMItem>& aItemArray, |
|
96 CArrayPtrFlat<CParserVCard>& aParserArray); |
|
97 |
|
98 /** |
|
99 * C++ default constructor. |
|
100 */ |
|
101 CPIMCardConverter(const CPIMContactValidator& aContactValidator, |
|
102 java::util::FunctionServer* aFuncServer); |
|
103 |
|
104 /** |
|
105 * By default Symbian 2nd phase constructor is private. |
|
106 */ |
|
107 void ConstructL(); |
|
108 |
|
109 private: // Data |
|
110 |
|
111 // Validates contacts |
|
112 const CPIMContactValidator& iContactValidator; |
|
113 |
|
114 // Converts properties |
|
115 CPIMCardPropertyConverter* iPropertyConverter; |
|
116 |
|
117 java::util::FunctionServer* iFuncServer; |
|
118 |
|
119 }; |
|
120 |
|
121 #endif // CPIMCARDCONVERTER_H |
|
122 // End of File |