63
|
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 USIM UI Extension view manager.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "CPsu2CheckAvailabeSimStore.h"
|
|
21 |
|
|
22 |
// Phonebook 2
|
|
23 |
#include <MPbk2AppUi.h>
|
|
24 |
#include <MPbk2ApplicationServices.h>
|
|
25 |
|
|
26 |
// Virtual Phonebook
|
|
27 |
#include <CVPbkContactManager.h>
|
|
28 |
#include <TVPbkContactStoreUriPtr.h>
|
|
29 |
#include <MVPbkContactStoreList.h>
|
|
30 |
#include <MVPbkContactStore.h>
|
|
31 |
#include <CVPbkContactStoreUriArray.h>
|
|
32 |
|
|
33 |
#include <VPbkContactStoreUris.h>
|
|
34 |
#include <MVPbkContactStoreInfo.h>
|
|
35 |
#include <MVPbkContactStoreProperties.h>
|
|
36 |
|
|
37 |
// Debugging headers
|
|
38 |
#include <Pbk2Debug.h>
|
|
39 |
|
|
40 |
|
|
41 |
// --------------------------------------------------------------------------
|
|
42 |
// CPsu2CheckAvailabeSimStore::CPsu2CheckAvailabeSimStore
|
|
43 |
// --------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
CPsu2CheckAvailabeSimStore::CPsu2CheckAvailabeSimStore()
|
|
46 |
{
|
|
47 |
// Do nothing
|
|
48 |
}
|
|
49 |
|
|
50 |
// --------------------------------------------------------------------------
|
|
51 |
// CPsu2CheckAvailabeSimStore::~CPsu2CheckAvailabeSimStore
|
|
52 |
// --------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
CPsu2CheckAvailabeSimStore::~CPsu2CheckAvailabeSimStore()
|
|
55 |
{
|
|
56 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
|
|
57 |
("CPsu2CheckAvailabeSimStore::~CPsu2CheckAvailabeSimStore") );
|
|
58 |
|
|
59 |
CloseStores();
|
|
60 |
delete iValidSourceStoreUris;
|
|
61 |
delete iReadyStores;
|
|
62 |
}
|
|
63 |
|
|
64 |
// --------------------------------------------------------------------------
|
|
65 |
// CPsu2CheckAvailabeSimStore::ConstructL
|
|
66 |
// --------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
void CPsu2CheckAvailabeSimStore::ConstructL()
|
|
69 |
{
|
|
70 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
|
|
71 |
("CPsu2CheckAvailabeSimStore::ConstructL") );
|
|
72 |
|
|
73 |
iReadyStores = CVPbkContactStoreUriArray::NewL();
|
|
74 |
|
|
75 |
iValidSourceStoreUris = CVPbkContactStoreUriArray::NewL();
|
|
76 |
iValidSourceStoreUris->AppendL(
|
|
77 |
VPbkContactStoreUris::SimGlobalOwnNumberUri() );
|
|
78 |
iValidSourceStoreUris->AppendL(
|
|
79 |
VPbkContactStoreUris::SimGlobalSdnUri() );
|
|
80 |
iValidSourceStoreUris->AppendL(
|
|
81 |
VPbkContactStoreUris::SimGlobalAdnUri() );
|
|
82 |
|
|
83 |
iStoreList = &Phonebook2::Pbk2AppUi()->ApplicationServices().
|
|
84 |
ContactManager().ContactStoresL();
|
|
85 |
|
|
86 |
OpenSimStoresL();
|
|
87 |
}
|
|
88 |
|
|
89 |
// --------------------------------------------------------------------------
|
|
90 |
// CPsu2CheckAvailabeSimStore::NewL
|
|
91 |
// --------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
CPsu2CheckAvailabeSimStore* CPsu2CheckAvailabeSimStore::NewL()
|
|
94 |
{
|
|
95 |
CPsu2CheckAvailabeSimStore* self = new(ELeave)CPsu2CheckAvailabeSimStore;
|
|
96 |
CleanupStack::PushL( self );
|
|
97 |
self->ConstructL();
|
|
98 |
CleanupStack::Pop( self );
|
|
99 |
return self;
|
|
100 |
}
|
|
101 |
|
|
102 |
// --------------------------------------------------------------------------
|
|
103 |
// CPsu2CheckAvailabeSimStore::IsContactsAvailabe
|
|
104 |
// --------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
TBool CPsu2CheckAvailabeSimStore::IsContactsAvailabe( const TDesC& aUri )
|
|
107 |
{
|
|
108 |
if ( iReadyStores->IsIncluded( TVPbkContactStoreUriPtr(aUri) ) )
|
|
109 |
{
|
|
110 |
MVPbkContactStore* source = iStoreList->Find( aUri );
|
|
111 |
if ( source )
|
|
112 |
{
|
|
113 |
TInt result(0);
|
|
114 |
TRAPD( error, result = source->StoreInfo().NumberOfContactsL() );
|
|
115 |
if ( !error )
|
|
116 |
{
|
|
117 |
return TBool(result);
|
|
118 |
}
|
|
119 |
}
|
|
120 |
}
|
|
121 |
return EFalse;
|
|
122 |
}
|
|
123 |
|
|
124 |
// --------------------------------------------------------------------------
|
|
125 |
// CPsu2CheckAvailabeSimStore::StoreReady
|
|
126 |
// --------------------------------------------------------------------------
|
|
127 |
//
|
|
128 |
void CPsu2CheckAvailabeSimStore::StoreReady(
|
|
129 |
MVPbkContactStore& aContactStore )
|
|
130 |
{
|
|
131 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
|
|
132 |
("CPsu2CheckAvailabeSimStore::StoreReady") );
|
|
133 |
|
|
134 |
TVPbkContactStoreUriPtr uri = aContactStore.StoreProperties().Uri();
|
|
135 |
if ( !iReadyStores->IsIncluded( uri ) )
|
|
136 |
{
|
|
137 |
TRAPD( error, iReadyStores->AppendL( uri ) ); // TRAPD
|
|
138 |
if ( error != KErrNone )
|
|
139 |
{
|
|
140 |
StoreUnavailable( aContactStore, error );
|
|
141 |
}
|
|
142 |
}
|
|
143 |
}
|
|
144 |
|
|
145 |
// --------------------------------------------------------------------------
|
|
146 |
// CPsu2CheckAvailabeSimStore::StoreUnavailable
|
|
147 |
// --------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
void CPsu2CheckAvailabeSimStore::StoreUnavailable
|
|
150 |
( MVPbkContactStore& aContactStore, TInt /*aReason*/ )
|
|
151 |
{
|
|
152 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
|
|
153 |
("CPsu2CheckAvailabeSimStore::StoreUnavailable") );
|
|
154 |
|
|
155 |
TVPbkContactStoreUriPtr uri = aContactStore.StoreProperties().Uri();
|
|
156 |
if ( iReadyStores->IsIncluded( uri ) )
|
|
157 |
{
|
|
158 |
iReadyStores->Remove( uri );
|
|
159 |
}
|
|
160 |
}
|
|
161 |
|
|
162 |
// --------------------------------------------------------------------------
|
|
163 |
// CPsu2CheckAvailabeSimStore::HandleStoreEventL
|
|
164 |
// --------------------------------------------------------------------------
|
|
165 |
//
|
|
166 |
void CPsu2CheckAvailabeSimStore::HandleStoreEventL
|
|
167 |
( MVPbkContactStore& /*aContactStore*/,
|
|
168 |
TVPbkContactStoreEvent /*aStoreEvent*/ )
|
|
169 |
{
|
|
170 |
// No action
|
|
171 |
}
|
|
172 |
|
|
173 |
// --------------------------------------------------------------------------
|
|
174 |
// CPsu2CheckAvailabeSimStore::OpenSimStoresL
|
|
175 |
// --------------------------------------------------------------------------
|
|
176 |
//
|
|
177 |
void CPsu2CheckAvailabeSimStore::OpenSimStoresL()
|
|
178 |
{
|
|
179 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
|
|
180 |
("CPsu2CheckAvailabeSimStore::OpenSimStoresL") );
|
|
181 |
|
|
182 |
const TInt count = iValidSourceStoreUris->Count();
|
|
183 |
for ( TInt i = 0; i < count; ++i )
|
|
184 |
{
|
|
185 |
Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager().
|
|
186 |
LoadContactStoreL( (*iValidSourceStoreUris)[i] );
|
|
187 |
MVPbkContactStore* source =
|
|
188 |
iStoreList->Find( (*iValidSourceStoreUris)[i] );
|
|
189 |
if ( source )
|
|
190 |
{
|
|
191 |
source->OpenL( *this );
|
|
192 |
}
|
|
193 |
}
|
|
194 |
}
|
|
195 |
|
|
196 |
// --------------------------------------------------------------------------
|
|
197 |
// CPsu2CheckAvailabeSimStore::CloseStores
|
|
198 |
// --------------------------------------------------------------------------
|
|
199 |
//
|
|
200 |
void CPsu2CheckAvailabeSimStore::CloseStores()
|
|
201 |
{
|
|
202 |
const TInt count = iValidSourceStoreUris->Count();
|
|
203 |
for ( TInt i = 0; i < count; ++i )
|
|
204 |
{
|
|
205 |
MVPbkContactStore* source =
|
|
206 |
iStoreList->Find( (*iValidSourceStoreUris)[i] );
|
|
207 |
if ( source )
|
|
208 |
{
|
|
209 |
source->Close( *this );
|
|
210 |
}
|
|
211 |
}
|
|
212 |
}
|
|
213 |
|
|
214 |
|
|
215 |
// End of File
|