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 - 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 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 <coemain.h> |
19 | 24 |
|
25 |
#include <CVPbkContactStoreUriArray.h> |
|
26 |
#include <CVPbkContactManager.h> |
|
27 |
#include <MVPbkContactStoreList.h> |
|
28 |
#include <MVPbkContactStore.h> |
|
29 |
#include <TVPbkContactStoreUriPtr.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
30 |
#include <CVPbkVCardEng.h> |
19 | 31 |
|
32 |
#include "contactservice.h" |
|
33 |
#include "tcontacts_async.h" |
|
34 |
||
35 |
_LIT( KCntDbUri, "cntdb://c:contacts.cdb" ); |
|
36 |
// ============================ MEMBER FUNCTIONS =============================== |
|
37 |
||
38 |
// ----------------------------------------------------------------------------- |
|
39 |
// CContactsUT::CContactsUT |
|
40 |
// C++ default constructor can NOT contain any code, that |
|
41 |
// might leave. |
|
42 |
// ----------------------------------------------------------------------------- |
|
43 |
// |
|
44 |
CContactsUT::CContactsUT( |
|
45 |
CTestModuleIf& aTestModuleIf ): |
|
46 |
CScriptBase( aTestModuleIf ), |
|
47 |
iErr(KErrNone) |
|
48 |
{ |
|
49 |
} |
|
50 |
||
51 |
// ----------------------------------------------------------------------------- |
|
52 |
// CContactsUT::ConstructL |
|
53 |
// Symbian 2nd phase constructor can leave. |
|
54 |
// ----------------------------------------------------------------------------- |
|
55 |
// |
|
56 |
void CContactsUT::ConstructL() |
|
57 |
{ |
|
58 |
iLog = CStifLogger::NewL( KContactsUTLogPath, |
|
59 |
KContactsUTLogFile, |
|
60 |
CStifLogger::ETxt, |
|
61 |
CStifLogger::EFile, |
|
62 |
EFalse ); |
|
63 |
||
64 |
// Create an URI list |
|
65 |
CVPbkContactStoreUriArray* uriList = CVPbkContactStoreUriArray::NewLC(); |
|
66 |
uriList->AppendL( TVPbkContactStoreUriPtr( KCntDbUri ) ); |
|
67 |
||
68 |
User::LeaveIfError( iRfs.Connect() ); |
|
69 |
//iRfs = CCoeEnv::Static()->FsSession(); |
|
70 |
iContactManager = CVPbkContactManager::NewL( *uriList, &iRfs ); |
|
71 |
||
72 |
// Clean up temporary variable |
|
73 |
CleanupStack::PopAndDestroy( uriList ); |
|
74 |
||
75 |
// Get all contact store list |
|
76 |
iStores = &(iContactManager->ContactStoresL()); |
|
77 |
//iStore = &( iStores->At( (iStores->Count())-1 ) ); |
|
78 |
iStores->OpenAllL( *this ); |
|
79 |
CActiveScheduler::Start(); |
|
80 |
||
81 |
} |
|
82 |
||
83 |
// ----------------------------------------------------------------------------- |
|
84 |
// CContactsUT::NewL |
|
85 |
// Two-phased constructor. |
|
86 |
// ----------------------------------------------------------------------------- |
|
87 |
// |
|
88 |
CContactsUT* CContactsUT::NewL( |
|
89 |
CTestModuleIf& aTestModuleIf ) |
|
90 |
{ |
|
91 |
CContactsUT* self = new (ELeave) CContactsUT( aTestModuleIf ); |
|
92 |
||
93 |
CleanupStack::PushL( self ); |
|
94 |
self->ConstructL(); |
|
95 |
CleanupStack::Pop(); |
|
96 |
||
97 |
return self; |
|
98 |
||
99 |
} |
|
100 |
||
101 |
// Destructor |
|
102 |
CContactsUT::~CContactsUT() |
|
103 |
{ |
|
104 |
||
105 |
// Delete resources allocated from test methods |
|
106 |
Delete(); |
|
107 |
if( iContactManager ) |
|
108 |
{ |
|
109 |
TRAP_IGNORE( iContactManager->ContactStoresL().CloseAll( *this ) ); |
|
110 |
} |
|
111 |
||
112 |
iRfs.Close(); |
|
113 |
iDestStream.Close(); |
|
114 |
||
115 |
delete iVCardEngine; |
|
116 |
delete iContactManager; |
|
117 |
delete iServiceHandle; |
|
118 |
// Delete logger |
|
119 |
delete iLog; |
|
120 |
||
121 |
} |
|
122 |
||
123 |
void CContactsUT::OpenComplete() |
|
124 |
{ |
|
125 |
CActiveScheduler::Stop(); |
|
126 |
//Empty |
|
127 |
} |
|
128 |
||
129 |
void CContactsUT::StoreReady(MVPbkContactStore& aContactStore) |
|
130 |
{ |
|
131 |
_LIT(KStoreReady,"Store Ready\n"); |
|
132 |
iLog->Log(KStoreReady); |
|
133 |
iStore = &aContactStore; |
|
134 |
} |
|
135 |
||
136 |
void CContactsUT::StoreUnavailable(MVPbkContactStore& /*aContactStore*/, |
|
137 |
TInt aReason) |
|
138 |
{ |
|
139 |
_LIT(KStoreUnavailable," Store is unavailable. Reason: "); |
|
140 |
TBuf<5> buf; |
|
141 |
buf.Num(aReason); |
|
142 |
iLog->Log(KStoreUnavailable); |
|
143 |
iLog->Log(buf); |
|
144 |
} |
|
145 |
||
146 |
void CContactsUT::HandleStoreEventL( |
|
147 |
MVPbkContactStore& /*aContactStore*/, |
|
148 |
TVPbkContactStoreEvent aStoreEvent) |
|
149 |
{ |
|
150 |
TBuf<50> buf; |
|
151 |
_LIT(KHandleStoreEventL,"Store Ready\n"); |
|
152 |
iLog->Log(KHandleStoreEventL); |
|
153 |
_LIT(KEvent,"Event Occured:"); |
|
154 |
_LIT(KNullEvent, "No Event\n"); |
|
155 |
_LIT(KContactAdded, "Contact Added\n"); |
|
156 |
_LIT(KContactDeleted, "Contact Deleted\n"); |
|
157 |
_LIT(KContactChanged, "Contact Changed\n"); |
|
158 |
_LIT(KGroupAdded, "Group Added\n"); |
|
159 |
_LIT(KGroupDeleted, "Group Deleted\n"); |
|
160 |
_LIT(KGroupChanged, "Group Changed\n"); |
|
161 |
_LIT(KStoreBackupBeginning, "Store Backup Beginning\n"); |
|
162 |
_LIT(KStoreBackupRestoreCompleted, "Store Backup Restore Completed\n"); |
|
163 |
_LIT(KUnknownChanges, "Unknown Changes\n"); |
|
164 |
||
165 |
switch(aStoreEvent.iEventType) |
|
166 |
{ |
|
167 |
case TVPbkContactStoreEvent::ENullEvent : buf.Append(KNullEvent); |
|
168 |
break; |
|
169 |
case TVPbkContactStoreEvent::EContactAdded : buf.Append(KContactAdded); |
|
170 |
break; |
|
171 |
case TVPbkContactStoreEvent::EContactDeleted : buf.Append(KContactDeleted); |
|
172 |
break; |
|
173 |
case TVPbkContactStoreEvent::EContactChanged : buf.Append(KContactChanged); |
|
174 |
break; |
|
175 |
case TVPbkContactStoreEvent::EGroupAdded : buf.Append(KGroupAdded); |
|
176 |
break; |
|
177 |
case TVPbkContactStoreEvent::EGroupDeleted : buf.Append(KGroupDeleted); |
|
178 |
break; |
|
179 |
case TVPbkContactStoreEvent::EGroupChanged : buf.Append(KGroupChanged); |
|
180 |
break; |
|
181 |
case TVPbkContactStoreEvent::EStoreBackupBeginning :buf.Append(KStoreBackupBeginning); |
|
182 |
break; |
|
183 |
case TVPbkContactStoreEvent::EStoreRestoreBeginning :buf.Append(KStoreBackupRestoreCompleted); |
|
184 |
break; |
|
185 |
case TVPbkContactStoreEvent::EUnknownChanges : buf.Append(KUnknownChanges); |
|
186 |
break; |
|
187 |
} |
|
188 |
||
189 |
iLog->Log(KEvent); |
|
190 |
iLog->Log(buf); |
|
191 |
} |
|
192 |
||
193 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
194 |
||
195 |
// ----------------------------------------------------------------------------- |
|
196 |
// LibEntryL is a polymorphic Dll entry point. |
|
197 |
// Returns: CScriptBase: New CScriptBase derived object |
|
198 |
// ----------------------------------------------------------------------------- |
|
199 |
// |
|
200 |
EXPORT_C CScriptBase* LibEntryL( |
|
201 |
CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework |
|
202 |
{ |
|
203 |
||
204 |
return ( CScriptBase* ) CContactsUT::NewL( aTestModuleIf ); |
|
205 |
||
206 |
} |
|
207 |
||
208 |
||
209 |
// End of File |