|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Phonebook 2 default attribute modification processor. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPBK2DEFAULTATTRIBUTEPROCESS_H |
|
20 #define CPBK2DEFAULTATTRIBUTEPROCESS_H |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <e32base.h> |
|
24 #include <MVPbkContactAttributeManager.h> |
|
25 #include <VPbkFieldType.hrh> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CVPbkContactManager; |
|
29 class MVPbkStoreContact; |
|
30 class MVPbkStoreContactField; |
|
31 class MVPbkContactOperationBase; |
|
32 class MPbk2DefaultAttributeProcessObserver; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * Phonebook 2 default attribute modification processor. |
|
38 * Responsible for: |
|
39 * - wrapping Virtual Phonebook attribute manager for |
|
40 * default attribute set and removal |
|
41 * - removing the previously set default attribute from the contact, |
|
42 * when updating existing default attribute to another field |
|
43 */ |
|
44 NONSHARABLE_CLASS(CPbk2DefaultAttributeProcess) : |
|
45 public CBase, |
|
46 private MVPbkSetAttributeObserver |
|
47 { |
|
48 public: // Construction and destruction |
|
49 |
|
50 /** |
|
51 * Creates a new instance of this class. |
|
52 * |
|
53 * @param aManager Virtual Phonebook contact manager. |
|
54 * @param aContact Contact to operate with. |
|
55 * @return A new instance of this class. |
|
56 */ |
|
57 IMPORT_C static CPbk2DefaultAttributeProcess* NewL( |
|
58 CVPbkContactManager& aManager, |
|
59 MVPbkStoreContact& aContact, |
|
60 MPbk2DefaultAttributeProcessObserver& aObserver ); |
|
61 |
|
62 /** |
|
63 * Destructor. |
|
64 */ |
|
65 ~CPbk2DefaultAttributeProcess(); |
|
66 |
|
67 public: // Interface |
|
68 |
|
69 /** |
|
70 * Sets given default attribute to given contact field. |
|
71 * Also removes the given default attribute from the |
|
72 * contact fields they were previously assigned to. |
|
73 * |
|
74 * @param aDefaultType Attribute to set. |
|
75 * @param aField Contact field to set |
|
76 * the attribute to. |
|
77 */ |
|
78 IMPORT_C void SetDefaultL( |
|
79 TVPbkDefaultType aDefaultType, |
|
80 MVPbkStoreContactField& aField ); |
|
81 |
|
82 /** |
|
83 * Removes the given default attribute from given contact field. |
|
84 * |
|
85 * @param aDefaultType Attribute to remove. |
|
86 */ |
|
87 IMPORT_C void RemoveDefaultL( |
|
88 TVPbkDefaultType aDefaultType ); |
|
89 |
|
90 /** |
|
91 * Sets given default attributes to given contact field. |
|
92 * Also removes given default attributes from the |
|
93 * contact fields they were previously assigned to. |
|
94 * |
|
95 * @param aDefaultProperties Attributes to set. |
|
96 * Ownership of the array is taken. |
|
97 * @param aField Contact field to set |
|
98 * the attributes to. |
|
99 */ |
|
100 IMPORT_C void SetDefaultsL( |
|
101 CArrayFixFlat<TVPbkDefaultType>* aDefaultProperties, |
|
102 MVPbkStoreContactField& aField ); |
|
103 |
|
104 /** |
|
105 * Removes given default attributes from given contact field. |
|
106 * |
|
107 * @param aDefaultProperties Attributes to remove. |
|
108 * Ownership of the array is taken. |
|
109 */ |
|
110 IMPORT_C void RemoveDefaultsL( |
|
111 CArrayFixFlat<TVPbkDefaultType>* aDefaultProperties ); |
|
112 |
|
113 private: // From MVPbkSetAttributeObserver |
|
114 void AttributeOperationComplete( |
|
115 MVPbkContactOperationBase& aOperation ); |
|
116 void AttributeOperationFailed( |
|
117 MVPbkContactOperationBase& aOperation, |
|
118 TInt aError ); |
|
119 |
|
120 private: // Implementation |
|
121 CPbk2DefaultAttributeProcess( |
|
122 CVPbkContactManager& aManager, |
|
123 MVPbkStoreContact& aContact, |
|
124 MPbk2DefaultAttributeProcessObserver& aObserver ); |
|
125 MVPbkStoreContactField* FindContactFieldWithAttributeL( |
|
126 TVPbkDefaultType aDefaultType ); |
|
127 void DoSetL( |
|
128 TVPbkDefaultType aDefaultType ); |
|
129 TBool DoRemoveL( |
|
130 TVPbkDefaultType aDefaultType ); |
|
131 TBool DoRemovePreviousL( |
|
132 TVPbkDefaultType aDefaultType ); |
|
133 void SetNextL(); |
|
134 void RemoveNextL(); |
|
135 TVPbkDefaultType NextAttribute(); |
|
136 |
|
137 private: // Data |
|
138 /// Ref: Virtual Phonebook contact manager |
|
139 CVPbkContactManager& iManager; |
|
140 /// Ref: Contact |
|
141 MVPbkStoreContact& iContact; |
|
142 /// Ref: Attribute observer |
|
143 MPbk2DefaultAttributeProcessObserver& iObserver; |
|
144 /// Own: Set attribute operation |
|
145 MVPbkContactOperationBase* iSetAttributeOperation; |
|
146 /// Own: Remove attribute operation |
|
147 MVPbkContactOperationBase* iRemoveAttributeOperation; |
|
148 /// Own: Remove previous attribute operation |
|
149 MVPbkContactOperationBase* iRemovePreviousAttributeOperation; |
|
150 /// Ref: Field the attribute is set to |
|
151 MVPbkStoreContactField* iSetAttributeField; |
|
152 /// Own: Field containing the default attribute to be removed |
|
153 MVPbkStoreContactField* iRemoveAttributeField; |
|
154 /// Own: Array of default attributes to operate with |
|
155 CArrayFixFlat<TVPbkDefaultType>* iDefaultAttributes; |
|
156 /// Own: Attribute type |
|
157 TVPbkDefaultType iAttributeType; |
|
158 }; |
|
159 |
|
160 #endif // CPBK2DEFAULTATTRIBUTEPROCESS_H |
|
161 |
|
162 // End of File |