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