author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 23 | 50974a8b132e |
parent 5 | 989d2f495d90 |
permissions | -rw-r--r-- |
5 | 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 the License "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: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
// INCLUDE FILES |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
22 |
#include <StifTestInterface.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
23 |
#include "tcomplugin.h" |
5 | 24 |
#include <CVPbkContactStoreUriArray.h> |
25 |
#include <TVPbkContactStoreUriPtr.h> |
|
26 |
#include <CVPbkContactManager.h> |
|
27 |
#include <MVPbkContactStoreList.h> |
|
28 |
#include <MVPbkContactStore.h> |
|
29 |
||
30 |
_LIT( KCntDbUri, "cntdb://c:contacts.cdb" ); |
|
31 |
// EXTERNAL DATA STRUCTURES |
|
32 |
//extern ?external_data; |
|
33 |
||
34 |
// EXTERNAL FUNCTION PROTOTYPES |
|
35 |
//extern ?external_function( ?arg_type,?arg_type ); |
|
36 |
||
37 |
// CONSTANTS |
|
38 |
//const ?type ?constant_var = ?constant; |
|
39 |
||
40 |
// MACROS |
|
41 |
//#define ?macro ?macro_def |
|
42 |
||
43 |
// LOCAL CONSTANTS AND MACROS |
|
44 |
//const ?type ?constant_var = ?constant; |
|
45 |
//#define ?macro_name ?macro_def |
|
46 |
||
47 |
// MODULE DATA STRUCTURES |
|
48 |
//enum ?declaration |
|
49 |
//typedef ?declaration |
|
50 |
||
51 |
// LOCAL FUNCTION PROTOTYPES |
|
52 |
//?type ?function_name( ?arg_type, ?arg_type ); |
|
53 |
||
54 |
||
55 |
// ----------------------------------------------------------------------------- |
|
56 |
// CTestProvider::CTestProvider |
|
57 |
// C++ default constructor can NOT contain any code, that |
|
58 |
// might leave. |
|
59 |
// ----------------------------------------------------------------------------- |
|
60 |
// |
|
61 |
CTestProvider::CTestProvider( |
|
62 |
CTestModuleIf& aTestModuleIf ): |
|
63 |
CScriptBase( aTestModuleIf ) |
|
64 |
{ |
|
65 |
iCancelled = 0; |
|
66 |
} |
|
67 |
||
68 |
// ----------------------------------------------------------------------------- |
|
69 |
// CTestProvider::ConstructL |
|
70 |
// Symbian 2nd phase constructor can leave. |
|
71 |
// ----------------------------------------------------------------------------- |
|
72 |
// |
|
73 |
void CTestProvider::ConstructL() |
|
74 |
{ |
|
75 |
||
76 |
iLog = CStifLogger::NewL( KContactsUTLogPath, |
|
77 |
KContactsUTLogFile, |
|
78 |
CStifLogger::ETxt, |
|
79 |
CStifLogger::EFile, |
|
80 |
EFalse ); |
|
81 |
||
82 |
// Create an URI list |
|
83 |
CVPbkContactStoreUriArray* uriList = CVPbkContactStoreUriArray::NewLC(); |
|
84 |
uriList->AppendL( TVPbkContactStoreUriPtr( KCntDbUri ) ); |
|
85 |
||
86 |
User::LeaveIfError( iFSession.Connect() ); |
|
87 |
iContactManager = CVPbkContactManager::NewL( *uriList, &iFSession ); |
|
88 |
||
89 |
// Clean up temporary variable |
|
90 |
CleanupStack::PopAndDestroy( uriList ); |
|
91 |
||
92 |
// Get all contact store list |
|
93 |
iStores = &(iContactManager->ContactStoresL()); |
|
94 |
iStores->OpenAllL( *this ); |
|
95 |
CActiveScheduler::Start(); |
|
96 |
} |
|
97 |
||
98 |
// ----------------------------------------------------------------------------- |
|
99 |
// CTestProvider::NewL |
|
100 |
// Two-phased constructor. |
|
101 |
// ----------------------------------------------------------------------------- |
|
102 |
// |
|
103 |
CTestProvider* CTestProvider::NewL( |
|
104 |
CTestModuleIf& aTestModuleIf ) |
|
105 |
{ |
|
106 |
CTestProvider* self = new (ELeave) CTestProvider( aTestModuleIf ); |
|
107 |
||
108 |
CleanupStack::PushL( self ); |
|
109 |
self->ConstructL(); |
|
110 |
CleanupStack::Pop(); |
|
111 |
||
112 |
return self; |
|
113 |
||
114 |
} |
|
115 |
||
116 |
// Destructor |
|
117 |
CTestProvider::~CTestProvider() |
|
118 |
{ |
|
119 |
||
120 |
// Delete resources allocated from test methods |
|
121 |
Delete(); |
|
122 |
||
123 |
||
124 |
if( iContactManager ) |
|
125 |
{ |
|
126 |
TRAP_IGNORE( iContactManager->ContactStoresL().CloseAll( *this ) ); |
|
127 |
} |
|
128 |
||
129 |
iFSession.Close(); |
|
130 |
||
131 |
delete iContactManager; |
|
132 |
delete iLog; |
|
133 |
||
134 |
} |
|
135 |
||
136 |
void CTestProvider::OpenComplete() |
|
137 |
{ |
|
138 |
CActiveScheduler::Stop(); |
|
139 |
//Empty |
|
140 |
} |
|
141 |
||
142 |
void CTestProvider::StoreReady(MVPbkContactStore& aContactStore) |
|
143 |
{ |
|
144 |
_LIT(KStoreReady,"Store Ready\n"); |
|
145 |
iLog->Log(KStoreReady); |
|
146 |
iStore = &aContactStore; |
|
147 |
} |
|
148 |
||
149 |
void CTestProvider::StoreUnavailable(MVPbkContactStore& /*aContactStore*/, |
|
150 |
TInt aReason) |
|
151 |
{ |
|
152 |
_LIT(KStoreUnavailable," Store is unavailable. Reason: "); |
|
153 |
TBuf<5> buf; |
|
154 |
buf.Num(aReason); |
|
155 |
iLog->Log(KStoreUnavailable); |
|
156 |
iLog->Log(buf); |
|
157 |
} |
|
158 |
void CTestProvider::HandleStoreEventL( |
|
159 |
MVPbkContactStore& /*aContactStore*/, |
|
160 |
TVPbkContactStoreEvent aStoreEvent) |
|
161 |
{ |
|
162 |
TBuf<50> buf; |
|
163 |
_LIT(KHandleStoreEventL,"Store Ready\n"); |
|
164 |
iLog->Log(KHandleStoreEventL); |
|
165 |
_LIT(KEvent,"Event Occured:"); |
|
166 |
_LIT(KNullEvent, "No Event\n"); |
|
167 |
_LIT(KContactAdded, "Contact Added\n"); |
|
168 |
_LIT(KContactDeleted, "Contact Deleted\n"); |
|
169 |
_LIT(KContactChanged, "Contact Changed\n"); |
|
170 |
_LIT(KGroupAdded, "Group Added\n"); |
|
171 |
_LIT(KGroupDeleted, "Group Deleted\n"); |
|
172 |
_LIT(KGroupChanged, "Group Changed\n"); |
|
173 |
_LIT(KStoreBackupBeginning, "Store Backup Beginning\n"); |
|
174 |
_LIT(KStoreBackupRestoreCompleted, "Store Backup Restore Completed\n"); |
|
175 |
_LIT(KUnknownChanges, "Unknown Changes\n"); |
|
176 |
||
177 |
switch(aStoreEvent.iEventType) |
|
178 |
{ |
|
179 |
case TVPbkContactStoreEvent::ENullEvent : buf.Append(KNullEvent); |
|
180 |
break; |
|
181 |
case TVPbkContactStoreEvent::EContactAdded : buf.Append(KContactAdded); |
|
182 |
break; |
|
183 |
case TVPbkContactStoreEvent::EContactDeleted : buf.Append(KContactDeleted); |
|
184 |
break; |
|
185 |
case TVPbkContactStoreEvent::EContactChanged : buf.Append(KContactChanged); |
|
186 |
break; |
|
187 |
case TVPbkContactStoreEvent::EGroupAdded : buf.Append(KGroupAdded); |
|
188 |
break; |
|
189 |
case TVPbkContactStoreEvent::EGroupDeleted : buf.Append(KGroupDeleted); |
|
190 |
break; |
|
191 |
case TVPbkContactStoreEvent::EGroupChanged : buf.Append(KGroupChanged); |
|
192 |
break; |
|
193 |
case TVPbkContactStoreEvent::EStoreBackupBeginning :buf.Append(KStoreBackupBeginning); |
|
194 |
break; |
|
195 |
case TVPbkContactStoreEvent::EStoreRestoreBeginning :buf.Append(KStoreBackupRestoreCompleted); |
|
196 |
break; |
|
197 |
case TVPbkContactStoreEvent::EUnknownChanges : buf.Append(KUnknownChanges); |
|
198 |
break; |
|
199 |
} |
|
200 |
||
201 |
iLog->Log(KEvent); |
|
202 |
iLog->Log(buf); |
|
203 |
} |
|
204 |
||
205 |
||
206 |
||
207 |
||
208 |
||
209 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
210 |
||
211 |
// ----------------------------------------------------------------------------- |
|
212 |
// LibEntryL is a polymorphic Dll entry point. |
|
213 |
// Returns: CScriptBase: New CScriptBase derived object |
|
214 |
// ----------------------------------------------------------------------------- |
|
215 |
// |
|
216 |
EXPORT_C CScriptBase* LibEntryL( |
|
217 |
CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework |
|
218 |
{ |
|
219 |
||
220 |
return ( CScriptBase* ) CTestProvider::NewL( aTestModuleIf ); |
|
221 |
||
222 |
} |
|
223 |
||
224 |
// ----------------------------------------------------------------------------- |
|
225 |
// E32Dll is a DLL entry point function. |
|
226 |
// Returns: KErrNone |
|
227 |
// ----------------------------------------------------------------------------- |
|
228 |
// |
|
229 |
#ifndef EKA2 // Hide Dll entry point to EKA2 |
|
230 |
GLDEF_C TInt E32Dll( |
|
231 |
TDllReason /*aReason*/) // Reason code |
|
232 |
{ |
|
233 |
return(KErrNone); |
|
234 |
||
235 |
} |
|
236 |
#endif // EKA2 |
|
237 |
||
238 |
// End of File |