|
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 "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: |
|
15 * Phonebook card converter class definition. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __CPbkvCardConverter_H__ |
|
21 #define __CPbkvCardConverter_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> // CBase |
|
25 #include <MPbkBackgroundProcess.h> |
|
26 #include <cntdef.h> // TContactItemId, CContactIdArray |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class CPbkContactEngine; |
|
30 class CPbkContactItem; |
|
31 class TPbkContactItemField; |
|
32 class CBCardEngine; |
|
33 class CPbkAttachmentFileArray; |
|
34 class MDesC16Array; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * Represents the different 'sending selected detail' menu selections. |
|
40 */ |
|
41 enum TPbkSendvCardChoiceItemEnumerations |
|
42 { |
|
43 ESendCurrentItem = 0, |
|
44 ESendAllData, |
|
45 ESendAllDataWithoutPicture, |
|
46 ECancel |
|
47 }; |
|
48 |
|
49 |
|
50 /** |
|
51 * A process which converts contacts to vCard files. |
|
52 */ |
|
53 class CPbkvCardConverter : |
|
54 public CBase, |
|
55 public MPbkBackgroundProcess |
|
56 { |
|
57 public: // constructor |
|
58 /** |
|
59 * Creates a new instance of this class. |
|
60 * @param aFs file server handle |
|
61 * @param aEngine phonebook contact engine |
|
62 * @param aBCardEngine business card engine |
|
63 */ |
|
64 static CPbkvCardConverter* NewL |
|
65 (RFs& aFs, CPbkContactEngine& aEngine, CBCardEngine& aBCardEngine); |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 */ |
|
70 ~CPbkvCardConverter(); |
|
71 |
|
72 public: // interface |
|
73 /** |
|
74 * Initializes this process to convert aContactId to a vCard file. |
|
75 * @param aContactId id of contact item to convert |
|
76 * @param aField focused field of the contact (can be null) |
|
77 * @param aDataToSend what data of contact to send mapped into |
|
78 * TPbkSendvCardChoiceItemEnumerations |
|
79 */ |
|
80 void ConvertContactL(TContactItemId aContactId, |
|
81 TPbkContactItemField* aField, TInt aDataToSend); |
|
82 |
|
83 /** |
|
84 * Initializes this process to convert aContacts to vCard files. |
|
85 * @param aContacts contact items to convert |
|
86 * @param aDataToSend what data of contact to send mapped into |
|
87 * TPbkSendvCardChoiceItemEnumerations |
|
88 */ |
|
89 void ConvertContactsL(const CContactIdArray& aContacts, |
|
90 TInt aDataToSend); |
|
91 |
|
92 /** |
|
93 * Returns the created vCard file names when the process is finished. |
|
94 */ |
|
95 MDesC16Array& FileNames() const; |
|
96 |
|
97 /** |
|
98 * Returns Phonebook business card engine. |
|
99 */ |
|
100 CBCardEngine& BCardEngine(); |
|
101 |
|
102 /** |
|
103 * Resets the process and destroys any results generated. |
|
104 */ |
|
105 void Reset(); |
|
106 |
|
107 private: // from MPbkBackgroundProcess |
|
108 void StepL(); |
|
109 TInt TotalNumberOfSteps(); |
|
110 TBool IsProcessDone() const; |
|
111 void ProcessFinished(); |
|
112 TInt HandleStepError(TInt aError); |
|
113 void ProcessCanceled(); |
|
114 |
|
115 private: // Implementation |
|
116 CPbkvCardConverter |
|
117 (RFs& aFs, |
|
118 CPbkContactEngine& aEngine, |
|
119 CBCardEngine& aBCardEngine); |
|
120 void ConstructL(); |
|
121 void CreatevCardFileL(TContactItemId aContactId); |
|
122 CPbkContactItem* PrepareContactLC(TContactItemId aContactId); |
|
123 void FillTemporaryContactL(CPbkContactItem& aDestItem, |
|
124 CPbkContactItem& aSourceItem, |
|
125 const TPbkContactItemField& aSourceField) const; |
|
126 void AddFieldToContactL(CPbkContactItem& aDestItem, |
|
127 const TPbkContactItemField& aSourceField) const; |
|
128 |
|
129 private: // Data |
|
130 /// Ref: open file server session |
|
131 RFs& iFs; |
|
132 /// Ref: Phonebook engine |
|
133 CPbkContactEngine& iEngine; |
|
134 /// Ref: Business card engine |
|
135 CBCardEngine& iBCardEngine; |
|
136 /// Own: array of vCard files |
|
137 CPbkAttachmentFileArray* iVcardFiles; |
|
138 /// Own: contacts to convert |
|
139 CContactIdArray* iContacts; |
|
140 /// Ref: the field to send, can be null |
|
141 TPbkContactItemField* iField; |
|
142 /// Own: what data to send |
|
143 /// (mapped into TPbkSendvCardChoiceItemEnumerations) |
|
144 TInt iDataToSend; |
|
145 }; |
|
146 |
|
147 #endif // __CPbkvCardConverter_H__ |
|
148 |
|
149 // End of File |