63
|
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: The contact view
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef CVPBKSIMCONTACTVIEW_H
|
|
21 |
#define CVPBKSIMCONTACTVIEW_H
|
|
22 |
|
|
23 |
// INCLUDES
|
|
24 |
#include <e32base.h>
|
|
25 |
#include <MVPbkSimCntView.h>
|
|
26 |
#include <MVPbkSimStoreObserver.h>
|
|
27 |
#include <RVPbkStreamedIntArray.h>
|
|
28 |
#include <VPbkSimStoreCommon.h>
|
|
29 |
|
|
30 |
// FORWARD DECLARATIONS
|
|
31 |
class MVPbkSimViewObserver;
|
|
32 |
class CVPbkSimContactBuf;
|
|
33 |
class CVPbkSimFieldTypeFilter;
|
|
34 |
class MVPbkSimViewFindObserver;
|
|
35 |
class MDesCArray;
|
|
36 |
class MVPbkSimContact;
|
|
37 |
template <class MVPbkSimViewObserver> class CVPbkAsyncObjectOperation;
|
|
38 |
|
|
39 |
// FORWARD DECLARATIONS
|
|
40 |
namespace VPbkSimStoreImpl {
|
|
41 |
class CSimCntSortUtil;
|
|
42 |
}
|
|
43 |
|
|
44 |
// CLASS DECLARATION
|
|
45 |
|
|
46 |
/**
|
|
47 |
* A class for a sorted view from a store. View can be optionally filtered
|
|
48 |
* and it also can have name that identifies it.
|
|
49 |
*/
|
|
50 |
class CVPbkSimContactView :
|
|
51 |
public CBase,
|
|
52 |
public MVPbkSimCntView,
|
|
53 |
private MVPbkSimStoreObserver
|
|
54 |
{
|
|
55 |
public: // Constructors and destructor
|
|
56 |
/**
|
|
57 |
* Two-phased constructor.
|
|
58 |
*
|
|
59 |
* @param aSortOrder The sort order for the view.
|
|
60 |
* @param aConstructionPolicy Defines how the view is constructed.
|
|
61 |
* @param aParentStore The parent store of the view.
|
|
62 |
* @param aViewName The name of the view. Use KNullDesC
|
|
63 |
* for unnamed view.
|
|
64 |
* @param aFilter Field type filter.
|
|
65 |
* @return A new instance of this class.
|
|
66 |
*/
|
|
67 |
IMPORT_C static CVPbkSimContactView* NewLC(
|
|
68 |
const RVPbkSimFieldTypeArray& aSortOrder,
|
|
69 |
TVPbkSimViewConstructionPolicy aConstructionPolicy,
|
|
70 |
MVPbkSimCntStore& aParentStore,
|
|
71 |
const TDesC& aViewName,
|
|
72 |
CVPbkSimFieldTypeFilter* aFilter );
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Destructor.
|
|
76 |
*/
|
|
77 |
virtual ~CVPbkSimContactView();
|
|
78 |
|
|
79 |
public: // From MVPbkSimCntView
|
|
80 |
const TDesC& Name() const;
|
|
81 |
MVPbkSimCntStore& ParentStore() const;
|
|
82 |
void OpenL(
|
|
83 |
MVPbkSimViewObserver& aObserver );
|
|
84 |
void Close(
|
|
85 |
MVPbkSimViewObserver& aObserver );
|
|
86 |
TInt CountL() const;
|
|
87 |
MVPbkSimContact& ContactAtL(
|
|
88 |
TInt aIndex );
|
|
89 |
void ChangeSortOrderL(
|
|
90 |
const RVPbkSimFieldTypeArray& aSortOrder );
|
|
91 |
TInt MapSimIndexToViewIndexL(
|
|
92 |
TInt aSimIndex );
|
|
93 |
MVPbkSimStoreOperation* ContactMatchingPrefixL(
|
|
94 |
const MDesCArray& aFindStrings,
|
|
95 |
MVPbkSimViewFindObserver& aObserver );
|
|
96 |
const RVPbkSimFieldTypeArray& SortOrderL() const;
|
|
97 |
|
|
98 |
private: // From MVPbkSimStoreObserver
|
|
99 |
void StoreReady(
|
|
100 |
MVPbkSimCntStore& aStore );
|
|
101 |
void StoreError(
|
|
102 |
MVPbkSimCntStore& aStore, TInt aError );
|
|
103 |
void StoreNotAvailable(
|
|
104 |
MVPbkSimCntStore& aStore );
|
|
105 |
void StoreContactEvent(
|
|
106 |
TEvent aEvent, TInt aSimIndex );
|
|
107 |
|
|
108 |
private: // Types
|
|
109 |
/// A simple contact for the view.
|
|
110 |
/// The view is a list of sim indexes in certain order.
|
|
111 |
struct TViewContact
|
|
112 |
{
|
|
113 |
TViewContact( TInt aSimIndex ) : iSimIndex( aSimIndex ) {}
|
|
114 |
TInt iSimIndex;
|
|
115 |
};
|
|
116 |
|
|
117 |
private: // Implementation
|
|
118 |
CVPbkSimContactView( MVPbkSimCntStore& aParentStore,
|
|
119 |
TVPbkSimViewConstructionPolicy aConstructionPolicy );
|
|
120 |
void ConstructL(
|
|
121 |
const RVPbkSimFieldTypeArray& aSortOrder,
|
|
122 |
const TDesC& aViewName );
|
|
123 |
/// Calls SortL in TRAP
|
|
124 |
void Sort();
|
|
125 |
/// Does the view sorting
|
|
126 |
void SortL();
|
|
127 |
/// Handle SortL failure
|
|
128 |
TInt SortError( TInt aError );
|
|
129 |
TBool IsSorting() const;
|
|
130 |
/// Starts asynchronous sorting
|
|
131 |
void StartSorting();
|
|
132 |
/// A handler for StoreContactEvent
|
|
133 |
void HandleStoreContactEventL( TEvent aEvent, TInt aSimIndex );
|
|
134 |
void HandleContactAddedL( TInt aSimIndex );
|
|
135 |
void HandleContactRemoved( TInt aSimIndex );
|
|
136 |
void HandleContactChangedL( TInt aSimIndex );
|
|
137 |
/// Inserts a new view contact to the correct place in the array
|
|
138 |
TInt InsertViewContactL(
|
|
139 |
const MVPbkSimContact& aContact );
|
|
140 |
/// Finds the index for the new contact if the view is sorted
|
|
141 |
TInt SortedIndexL(
|
|
142 |
const MVPbkSimContact& aLeft );
|
|
143 |
/// Finds the index for the new contact if the view is not sorted
|
|
144 |
TInt UnsortedIndex(
|
|
145 |
const MVPbkSimContact& aLeft );
|
|
146 |
/// Removes the view contact to aSimIndex, Returns removed view index.
|
|
147 |
TInt RemoveViewContact(
|
|
148 |
TInt aSimIndex );
|
|
149 |
/// Resets the current sort order and copies types from the source
|
|
150 |
void ResetAndCopySortOrderL(
|
|
151 |
const RVPbkSimFieldTypeArray& aSource );
|
|
152 |
/// Resets the view
|
|
153 |
void Reset();
|
|
154 |
/// Inspects whether the contact passes the filtering criteria
|
|
155 |
TBool PassesFilter(
|
|
156 |
const MVPbkSimContact& aContact,
|
|
157 |
const CVPbkSimFieldTypeFilter* aFilter ) const;
|
|
158 |
// View state changes
|
|
159 |
void SetToReadyState();
|
|
160 |
void SetToNotReadyState();
|
|
161 |
void SetToUnavailableState();
|
|
162 |
TBool ViewStateReady() const;
|
|
163 |
TBool ViewStateUnavailable() const;
|
|
164 |
TBool ViewStateNotReady() const;
|
|
165 |
/// A function called by iAsyncOperation
|
|
166 |
void DoViewOpenCallbackL( MVPbkSimViewObserver& aObserver );
|
|
167 |
/// A function called by iAsyncOperation
|
|
168 |
void DoViewUnavailableCallbackL( MVPbkSimViewObserver& aObserver );
|
|
169 |
/// A function called by iAsyncOperation
|
|
170 |
void DoViewErrorCallback( MVPbkSimViewObserver& aObserver,
|
|
171 |
TInt aError );
|
|
172 |
static TBool CompareViewContactSimIndex( const TViewContact& aLeft,
|
|
173 |
const TViewContact& aRight );
|
|
174 |
static TInt IdleSortCallback( TAny* aThis );
|
|
175 |
|
|
176 |
public:
|
|
177 |
TBool IsMatch(
|
|
178 |
const RVPbkSimFieldTypeArray& aSortOrder,
|
|
179 |
TVPbkSimViewConstructionPolicy aConstructionPolicy,
|
|
180 |
const TDesC& aViewName );
|
|
181 |
|
|
182 |
private: // Data
|
|
183 |
/// Own: The name of view that is given by the client
|
|
184 |
HBufC* iViewName;
|
|
185 |
/// Ref: The parent store of the view
|
|
186 |
MVPbkSimCntStore& iParentStore;
|
|
187 |
/// Own: The sort order of this view
|
|
188 |
RVPbkSimFieldTypeArray iSortOrder;
|
|
189 |
/// Own: The observer of the view
|
|
190 |
RPointerArray<MVPbkSimViewObserver> iObservers;
|
|
191 |
/// Own: An array of view contacts
|
|
192 |
RArray<TViewContact> iViewContacts;
|
|
193 |
/// Own: The sorting utility
|
|
194 |
VPbkSimStoreImpl::CSimCntSortUtil* iSortUtil;
|
|
195 |
/// Own: The current sim contact read with ContactAtL
|
|
196 |
CVPbkSimContactBuf* iCurrentContact;
|
|
197 |
/// Own: Defines how the view is created
|
|
198 |
TVPbkSimViewConstructionPolicy iConstructionPolicy;
|
|
199 |
/// Own: State indicator
|
|
200 |
TInt iViewState;
|
|
201 |
/// Own: Async operations for the opening the view
|
|
202 |
CVPbkAsyncObjectOperation<MVPbkSimViewObserver>* iAsyncOperation;
|
|
203 |
/// Own: Field type filter
|
|
204 |
CVPbkSimFieldTypeFilter* iFilter;
|
|
205 |
/// Own: A contact that can be used
|
|
206 |
CVPbkSimContactBuf* iTempContactForSorting;
|
|
207 |
/// Own: An idle for starting async sorting.
|
|
208 |
CIdle* iIdleSort;
|
|
209 |
};
|
|
210 |
|
|
211 |
#endif // CVPBKSIMCONTACTVIEW_H
|
|
212 |
|
|
213 |
// End of File
|