20
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-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: Contacts Model store contact view implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef VPBKCNTMODEL_CVIEWBASE_H
|
|
20 |
#define VPBKCNTMODEL_CVIEWBASE_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <cntviewbase.h>
|
|
25 |
#include <MVPbkContactView.h>
|
|
26 |
#include <MVPbkContactViewFiltering.h>
|
|
27 |
#include <MVPbkContactStoreObserver.h>
|
|
28 |
#include "CViewContact.h"
|
|
29 |
#include "MCustomContactViewObserver.h"
|
|
30 |
#include "MParentViewForFiltering.h"
|
|
31 |
|
|
32 |
// FORWARD DECLARATIONS
|
|
33 |
class MVPbkContactViewObserver;
|
|
34 |
class CVPbkSortOrder;
|
|
35 |
class CVPbkContactViewDefinition;
|
|
36 |
template<class MVPbkContactViewObserver> class CVPbkAsyncObjectOperation;
|
|
37 |
template<class MFilteredViewSupportObserver> class CVPbkAsyncObjectOperation;
|
|
38 |
|
|
39 |
namespace VPbkCntModel {
|
|
40 |
|
|
41 |
// FORWARD DECLARATIONS
|
|
42 |
class CContactStore;
|
|
43 |
class CContactLink;
|
|
44 |
|
|
45 |
/**
|
|
46 |
* Contacts Model store contact view implementation
|
|
47 |
*/
|
|
48 |
NONSHARABLE_CLASS( CViewBase ): public CBase,
|
|
49 |
public MParentViewForFiltering,
|
|
50 |
public MVPbkContactViewFiltering,
|
|
51 |
public MVPbkContactStoreObserver,
|
|
52 |
public MContactViewObserver,
|
|
53 |
protected MCustomContactViewObserver
|
|
54 |
{
|
|
55 |
public: // Destructor
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Destructor.
|
|
59 |
*/
|
|
60 |
virtual ~CViewBase();
|
|
61 |
|
|
62 |
public: // Interface
|
|
63 |
|
|
64 |
/**
|
|
65 |
* Returns parent contact store.
|
|
66 |
*
|
|
67 |
* @return Parent contact store.
|
|
68 |
*/
|
|
69 |
CContactStore& Store() const;
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Returns native view.
|
|
73 |
*
|
|
74 |
* @return Native view.
|
|
75 |
*/
|
|
76 |
CContactViewBase& NativeView() const;
|
|
77 |
|
|
78 |
/**
|
|
79 |
* Return view's state
|
|
80 |
*
|
|
81 |
* @return ETrue is view is ready other EFalse
|
|
82 |
*/
|
|
83 |
TBool State() const;
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Returns view definition
|
|
87 |
*
|
|
88 |
* @return View definition
|
|
89 |
*/
|
|
90 |
CVPbkContactViewDefinition& ViewDefinition() const;
|
|
91 |
|
|
92 |
protected: // Interface
|
|
93 |
/**
|
|
94 |
* Change sort order
|
|
95 |
* @param aSortOrder
|
|
96 |
*/
|
|
97 |
void ChangeSortOrderL( RContactViewSortOrder& aSortOrder );
|
|
98 |
|
|
99 |
public: // From MVPbkContactViewBase
|
|
100 |
void ChangeSortOrderL(
|
|
101 |
const MVPbkFieldTypeList& aSortOrder );
|
|
102 |
const MVPbkFieldTypeList& SortOrder() const;
|
|
103 |
void RefreshL();
|
|
104 |
virtual TInt ContactCountL() const;
|
|
105 |
virtual const MVPbkViewContact& ContactAtL(
|
|
106 |
TInt aIndex ) const;
|
|
107 |
MVPbkContactLink* CreateLinkLC(
|
|
108 |
TInt aIndex ) const;
|
|
109 |
TInt IndexOfLinkL(
|
|
110 |
const MVPbkContactLink& aContactLink ) const;
|
|
111 |
void AddObserverL(
|
|
112 |
MVPbkContactViewObserver& aObserver );
|
|
113 |
void RemoveObserver(
|
|
114 |
MVPbkContactViewObserver& aObserver );
|
|
115 |
TBool MatchContactStore(
|
|
116 |
const TDesC& aContactStoreUri ) const;
|
|
117 |
TBool MatchContactStoreDomain(
|
|
118 |
const TDesC& aContactStoreDomain ) const;
|
|
119 |
MVPbkContactBookmark* CreateBookmarkLC(
|
|
120 |
TInt aIndex ) const;
|
|
121 |
TInt IndexOfBookmarkL(
|
|
122 |
const MVPbkContactBookmark& aContactBookmark ) const;
|
|
123 |
MVPbkContactViewFiltering* ViewFiltering();
|
|
124 |
|
|
125 |
public: // From MParentViewForFiltering
|
|
126 |
void AddFilteringObserverL( MFilteredViewSupportObserver& aObserver );
|
|
127 |
void RemoveFilteringObserver( MFilteredViewSupportObserver& aObserver );
|
|
128 |
|
|
129 |
public: // From MVPbkContactViewFiltering
|
|
130 |
MVPbkContactViewBase* CreateFilteredViewLC(
|
|
131 |
MVPbkContactViewObserver& aObserver,
|
|
132 |
const MDesCArray& aFindWords,
|
|
133 |
const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
|
|
134 |
void UpdateFilterL(
|
|
135 |
const MDesCArray& aFindWords,
|
|
136 |
const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
|
|
137 |
|
|
138 |
public: // From MVPbkObjectHierarchy
|
|
139 |
MVPbkObjectHierarchy& ParentObject() const;
|
|
140 |
|
|
141 |
public: // From MVPbkContactStoreObserver
|
|
142 |
void StoreReady(
|
|
143 |
MVPbkContactStore& aContactStore );
|
|
144 |
void StoreUnavailable(
|
|
145 |
MVPbkContactStore& aContactStore,
|
|
146 |
TInt aReason );
|
|
147 |
void HandleStoreEventL(
|
|
148 |
MVPbkContactStore& aContactStore,
|
|
149 |
TVPbkContactStoreEvent aStoreEvent );
|
|
150 |
|
|
151 |
protected: // From MContactViewObserver
|
|
152 |
void HandleContactViewEvent(
|
|
153 |
const CContactViewBase& aView,
|
|
154 |
const TContactViewEvent& aEvent );
|
|
155 |
|
|
156 |
private: // From MCustomContactViewObserver
|
|
157 |
void HandleCustomContactViewEvent(
|
|
158 |
const CContactViewBase& aView,
|
|
159 |
const TContactViewEvent& aEvent );
|
|
160 |
|
|
161 |
protected: // Implementation
|
|
162 |
CViewBase(
|
|
163 |
CContactStore& aParentStore );
|
|
164 |
void ConstructL(
|
|
165 |
const CVPbkContactViewDefinition& aViewDefinition,
|
|
166 |
MVPbkContactViewObserver& aObserver,
|
|
167 |
const MVPbkFieldTypeList& aSortOrder );
|
|
168 |
void ConstructL(
|
|
169 |
const CVPbkContactViewDefinition& aViewDefinition,
|
|
170 |
const MVPbkFieldTypeList& aSortOrder );
|
|
171 |
void DoUpdateTypeListL();
|
|
172 |
private: // Implementation
|
|
173 |
RContactViewSortOrder CreateSortOrderL(
|
|
174 |
const MVPbkFieldTypeList& aSortOrder );
|
|
175 |
void DoAddObserverL(
|
|
176 |
MVPbkContactViewObserver& aObserver );
|
|
177 |
void AddObserverError(
|
|
178 |
MVPbkContactViewObserver& aObserver, TInt aError );
|
|
179 |
void DoAddFilteringObserverL(
|
|
180 |
MFilteredViewSupportObserver& aObserver );
|
|
181 |
void DoAddFilteringObserverError(
|
|
182 |
MFilteredViewSupportObserver& aObserver, TInt aError );
|
|
183 |
void InitializeViewL(
|
|
184 |
const CVPbkContactViewDefinition& aViewDefinition,
|
|
185 |
const MVPbkFieldTypeList& aSortOrder );
|
|
186 |
void TeardownView();
|
|
187 |
void SendViewErrorEvent( TInt aError );
|
|
188 |
void SendViewStateEvent();
|
|
189 |
void PurgeAsyncOperations();
|
|
190 |
void LeaveIfIncorrectSortOrderL(
|
|
191 |
const MVPbkFieldTypeList& aSortOrder );
|
|
192 |
|
|
193 |
virtual void DoInitializeViewL(
|
|
194 |
const CVPbkContactViewDefinition& aViewDefinition,
|
|
195 |
RContactViewSortOrder& viewSortOrder ) = 0;
|
|
196 |
virtual void DoTeardownView() = 0;
|
|
197 |
virtual TBool DoChangeSortOrderL(
|
|
198 |
const CVPbkContactViewDefinition& aViewDefinition,
|
|
199 |
RContactViewSortOrder& aSortOrder ) = 0;
|
|
200 |
|
|
201 |
protected: // Data
|
|
202 |
/// Own: Contacts view
|
|
203 |
CContactViewBase* iView;
|
|
204 |
/// Own: Array of observers
|
|
205 |
RPointerArray<MVPbkContactViewObserver> iObservers;
|
|
206 |
/// Ref: an array of observers that filters this view.
|
|
207 |
RPointerArray<MFilteredViewSupportObserver> iFilteringObservers;
|
|
208 |
/// Own: View sort order
|
|
209 |
CVPbkSortOrder* iSortOrder;
|
|
210 |
|
|
211 |
private: // Data
|
|
212 |
/// Ref: Parent contact store
|
|
213 |
CContactStore& iParentStore;
|
|
214 |
/// Own: The defintion of the view from client
|
|
215 |
CVPbkContactViewDefinition* iViewDefinition;
|
|
216 |
/// Own: Link to a contact associated with last event
|
|
217 |
CContactLink* iEventLink;
|
|
218 |
/// Own: View ready indicator
|
|
219 |
TBool iViewReady;
|
|
220 |
/// Own: an async operation for MVPbkContactViewObserver
|
|
221 |
CVPbkAsyncObjectOperation<MVPbkContactViewObserver>* iObserverOp;
|
|
222 |
/// Own: an async operation for MFilteredViewSupportObserver
|
|
223 |
CVPbkAsyncObjectOperation<MFilteredViewSupportObserver>* iFilterObsOp;
|
|
224 |
/// Own: A contact last queried
|
|
225 |
mutable CViewContact* iCurrentContact;
|
|
226 |
};
|
|
227 |
|
|
228 |
|
|
229 |
// INLINE FUNCTIONS
|
|
230 |
|
|
231 |
inline CContactStore& CViewBase::Store() const
|
|
232 |
{
|
|
233 |
return iParentStore;
|
|
234 |
}
|
|
235 |
|
|
236 |
inline CContactViewBase& CViewBase::NativeView() const
|
|
237 |
{
|
|
238 |
return *iView;
|
|
239 |
}
|
|
240 |
|
|
241 |
inline TBool CViewBase::State() const
|
|
242 |
{
|
|
243 |
return iViewReady;
|
|
244 |
}
|
|
245 |
|
|
246 |
inline void CViewBase::ChangeSortOrderL( RContactViewSortOrder& aSortOrder )
|
|
247 |
{
|
|
248 |
DoChangeSortOrderL( *iViewDefinition, aSortOrder );
|
|
249 |
}
|
|
250 |
|
|
251 |
inline CVPbkContactViewDefinition& CViewBase::ViewDefinition() const
|
|
252 |
{
|
|
253 |
return *iViewDefinition;
|
|
254 |
}
|
|
255 |
} // namespace VPbkCntModel
|
|
256 |
|
|
257 |
#endif // VPBKCNTMODEL_CVIEWBASE_H
|
|
258 |
|
|
259 |
// End of File
|