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) 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: Implementation of export observer for the Contacts Service API. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
#include "exportstorelistobserver.h" |
|
21 |
||
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
22 |
#include <CVPbkVCardEng.h>//for the vcard engin |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
23 |
#include <CVPbkContactManager.h>// for iContactManager |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
24 |
#include <MVPbkContactStore.h>// for iContactStore |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
25 |
#include <TVPbkContactStoreUriPtr.h>//used in SetupL |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
26 |
#include <MVPbkContactStoreList.h>//used in SetupL to get contact stores |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
27 |
#include <MVPbkStoreContactField.h>//used in AddFieldToContactL |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
28 |
#include <MVPbkStoreContact.h>// used in many function to get the store contact |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
29 |
#include <MVPbkContactFieldTextData.h>//for the field text data |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
30 |
#include <TVPbkFieldTypeMapping.h>//used in CreateFieldTypeL() |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
31 |
#include <MVPbkFieldType.h>//return type of CreateFieldTypeL() |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
32 |
#include <MVPbkContactOperationBase.h>//for observer |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
33 |
#include <MVPbkContactFieldDateTimeData.h>//Used in AddDateFieldToContactL |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
34 |
#include <MVPbkContactLink.h>//for param in ContactsSaved() |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
35 |
#include <CVPbkContactStoreUriArray.h>//used in SetupL |
19 | 36 |
|
37 |
||
38 |
// --------------------------------------------------------------------------- |
|
39 |
// Static method to create an instance of the export store list observer. |
|
40 |
// --------------------------------------------------------------------------- |
|
41 |
// |
|
42 |
CExportStoreListObserver* CExportStoreListObserver::NewL(CContactService* aContactService,RFs &aFs,const TFileName& aFileName, const TDesC8& aContactId,MContactCallback *aCallback, TInt aTransId) |
|
43 |
{ |
|
44 |
CExportStoreListObserver* self = new( ELeave ) CExportStoreListObserver( ); |
|
45 |
CleanupStack::PushL(self); |
|
46 |
self->ConstructL(aContactService,aFs,aFileName,aContactId,aCallback, aTransId ); |
|
47 |
CleanupStack::Pop(self); |
|
48 |
return self; |
|
49 |
||
50 |
} |
|
51 |
||
52 |
// --------------------------------------------------------------------------- |
|
53 |
// Destructor |
|
54 |
// --------------------------------------------------------------------------- |
|
55 |
CExportStoreListObserver::~CExportStoreListObserver() |
|
56 |
{ |
|
57 |
iDest.Close(); |
|
58 |
delete iLinkArray; |
|
59 |
if(iOp) |
|
60 |
{ |
|
61 |
delete iOp; |
|
62 |
} |
|
63 |
if(iContactStore) |
|
64 |
{ |
|
65 |
iContactStore->Close(*this); |
|
66 |
} |
|
67 |
||
68 |
} |
|
69 |
||
70 |
// --------------------------------------------------------------------------- |
|
71 |
// Constructor |
|
72 |
// --------------------------------------------------------------------------- |
|
73 |
CExportStoreListObserver::CExportStoreListObserver() |
|
74 |
{ |
|
75 |
||
76 |
} |
|
77 |
||
78 |
//---------------------------------------------------------------------------- |
|
79 |
// Symbian Second phase constructor |
|
80 |
//---------------------------------------------------------------------------- |
|
81 |
||
82 |
void CExportStoreListObserver::ConstructL( CContactService* aContactService, RFs &aFs,const TFileName& aFileName,const TDesC8& aContactId,MContactCallback *aCallback, TInt aTransId) |
|
83 |
{ |
|
84 |
iFs=aFs; |
|
85 |
iFileName=aFileName; |
|
86 |
||
87 |
iLinkArray = (&(aContactService->GetContactManager()))->CreateLinksLC(aContactId); |
|
88 |
iContactLink = &(iLinkArray->At(0)); |
|
89 |
||
90 |
iCallback=aCallback; |
|
91 |
iTransId = aTransId; |
|
92 |
iOp = NULL; |
|
93 |
CleanupStack::Pop(); //iLinkArray |
|
94 |
} |
|
95 |
/* |
|
96 |
------------------------------------------------------------------------------------- |
|
97 |
CExportStoreListObserver::Cancel() |
|
98 |
Description : Cancel implementation relevant to Export Observer |
|
99 |
Return values : KErrorNone on Success and KErrGeneral on Failure |
|
100 |
------------------------------------------------------------------------------------- |
|
101 |
*/ |
|
102 |
||
103 |
void CExportStoreListObserver::Cancel() |
|
104 |
{ |
|
105 |
iCallback->HandleReturnValue(EOpCancel, KErrNone, iTransId); |
|
106 |
delete this; |
|
107 |
} |
|
108 |
||
109 |
// --------------------------------------------------------------------------- |
|
110 |
// Method to set vcard engine. |
|
111 |
// --------------------------------------------------------------------------- |
|
112 |
||
113 |
void CExportStoreListObserver::SetEngine(CVPbkVCardEng* aEngine) |
|
114 |
{ |
|
115 |
iEngine=aEngine; |
|
116 |
} |
|
117 |
||
118 |
// --------------------------------------------------------------------------- |
|
119 |
// Method to set the contact store. |
|
120 |
// --------------------------------------------------------------------------- |
|
121 |
||
122 |
void CExportStoreListObserver::SetContactStore(MVPbkContactStore* aContactStore) |
|
123 |
{ |
|
124 |
iContactStore=aContactStore; |
|
125 |
} |
|
126 |
||
127 |
//---------------------------------------------------------------------------- |
|
128 |
// Method to set the contact service |
|
129 |
//---------------------------------------------------------------------------- |
|
130 |
void CExportStoreListObserver::SetContactService(CContactService* aContactService) |
|
131 |
{ |
|
132 |
iContactService = aContactService; |
|
133 |
} |
|
134 |
||
135 |
// --------------------------------------------------------------------------- |
|
136 |
// Called when OpenL async call is successfull. |
|
137 |
// --------------------------------------------------------------------------- |
|
138 |
||
139 |
void CExportStoreListObserver::StoreReady( MVPbkContactStore& /* aContactStore */) |
|
140 |
{ |
|
141 |
TInt error; |
|
142 |
error = iDest.Create( iFs, iFileName, EFileWrite ); |
|
143 |
if(error != KErrNone) |
|
144 |
{ |
|
145 |
iContactService->RequestComplete(iTransId); |
|
146 |
iCallback->HandleReturnValue( EOpComplete, error, iTransId ); |
|
147 |
delete this; |
|
148 |
} |
|
149 |
else |
|
150 |
{ |
|
151 |
TRAPD(err,iOp = iEngine->ExportVCardL( iDest, *iContactLink, *this )); |
|
152 |
if( err!=KErrNone ) |
|
153 |
{ |
|
154 |
iContactService->RequestComplete(iTransId); |
|
155 |
iCallback->HandleReturnValue(EOpComplete, err,iTransId); |
|
156 |
delete this; |
|
157 |
} |
|
158 |
} |
|
159 |
} |
|
160 |
||
161 |
// --------------------------------------------------------------------------- |
|
162 |
// Called when OpenL is failed. |
|
163 |
// --------------------------------------------------------------------------- |
|
164 |
||
165 |
void CExportStoreListObserver::StoreUnavailable( |
|
166 |
MVPbkContactStore& /*aContactStore*/, |
|
167 |
TInt aReason ) |
|
168 |
{ |
|
169 |
iContactService->RequestComplete(iTransId); |
|
170 |
iCallback->HandleReturnValue(EOpError, aReason, iTransId ); |
|
171 |
delete this; |
|
172 |
} |
|
173 |
||
174 |
// --------------------------------------------------------------------------- |
|
175 |
// |
|
176 |
// --------------------------------------------------------------------------- |
|
177 |
||
178 |
void CExportStoreListObserver::HandleStoreEventL( |
|
179 |
MVPbkContactStore& /*aContactStore*/, |
|
180 |
TVPbkContactStoreEvent /*aStoreEvent*/ ) |
|
181 |
{ |
|
182 |
// Indication not needed. |
|
183 |
} |
|
184 |
||
185 |
void CExportStoreListObserver::OpenComplete() |
|
186 |
{ |
|
187 |
// Indication not needed. |
|
188 |
} |
|
189 |
||
190 |
||
191 |
// --------------------------------------------------------------------------- |
|
192 |
// Delete the completed operation object and close the write stream. |
|
193 |
// --------------------------------------------------------------------------- |
|
194 |
||
195 |
void CExportStoreListObserver::VPbkSingleContactOperationComplete( |
|
196 |
MVPbkContactOperationBase& aOperation, |
|
197 |
MVPbkStoreContact* ) |
|
198 |
{ |
|
199 |
delete &aOperation; |
|
200 |
iOp = NULL; |
|
201 |
iContactService->RequestComplete(iTransId); |
|
202 |
iCallback->HandleReturnValue(EOpComplete, KErrNone,iTransId); |
|
203 |
delete this; |
|
204 |
} |
|
205 |
||
206 |
// --------------------------------------------------------------------------- |
|
207 |
// Delete the completed operation object and close the write stream. |
|
208 |
// --------------------------------------------------------------------------- |
|
209 |
||
210 |
void CExportStoreListObserver::VPbkSingleContactOperationFailed( |
|
211 |
MVPbkContactOperationBase& aOperation, TInt aError ) |
|
212 |
{ |
|
213 |
delete &aOperation; |
|
214 |
iOp = NULL; |
|
215 |
iContactService->RequestComplete(iTransId); |
|
216 |
iCallback->HandleReturnValue( EOpError, aError, iTransId ); |
|
217 |
delete this; |
|
218 |
} |