author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 18 Jan 2010 21:02:57 +0200 | |
changeset 27 | 02682e02e51f |
parent 23 | 50974a8b132e |
permissions | -rw-r--r-- |
5 | 1 |
/* |
2 |
* Copyright (c) 2007-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: This Class is observer for the mgservice class (core class) |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <liwcommon.h> |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
19 |
#include <MCLFItemListModel.h> |
5 | 20 |
|
21 |
#include "mgserviceobserver.h" |
|
22 |
#include "mgitemslist.h" |
|
23 |
#include "mginterface.h" |
|
24 |
#include "serviceerrno.h" |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
25 |
#include "mgclfoperationobserver.h" |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
26 |
|
5 | 27 |
//using namespace LIW; |
28 |
//Output Keys/arguments |
|
29 |
_LIT8(KResponse,"ReturnValue"); |
|
30 |
_LIT8(KErrorCode,"ErrorCode"); |
|
31 |
||
32 |
// ----------------------------------------------------------------------------- |
|
33 |
// CMgServiceObserver::NewL |
|
34 |
// Returns the instance of CMgServiceObserver. |
|
35 |
// ----------------------------------------------------------------------------- |
|
36 |
CMgServiceObserver* CMgServiceObserver::NewL() |
|
37 |
{ |
|
38 |
||
39 |
CMgServiceObserver* self = new ( ELeave )CMgServiceObserver(); |
|
40 |
CleanupStack::PushL( self ); |
|
41 |
self->ConstructL(); |
|
42 |
CleanupStack::Pop( self ); |
|
43 |
return self; |
|
44 |
||
45 |
} |
|
46 |
||
47 |
||
48 |
||
49 |
||
50 |
||
51 |
// ----------------------------------------------------------------------------- |
|
52 |
// CMgServiceObserver::MgNotify |
|
53 |
// Called by CMgService class when asynch operation complete |
|
54 |
// ----------------------------------------------------------------------------- |
|
55 |
void CMgServiceObserver :: MgNotifyL( TUint aTransactionID, |
|
56 |
MCLFItemListModel* aListModel, |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
57 |
CClfOperationObserver* aOperationObserver, |
5 | 58 |
TMgOperationEvent& aOperationEvent, |
59 |
const TInt& aError ) |
|
60 |
||
61 |
||
62 |
{ |
|
63 |
iOutput->Reset(); |
|
64 |
//const CLiwGenericParamList& temp1 = *iOutput; |
|
65 |
//const CLiwGenericParamList* temp2 = &temp1; |
|
66 |
//delete temp2; |
|
67 |
||
68 |
if ( EMgModelCancel == aOperationEvent ) |
|
69 |
{ |
|
70 |
if( iCallBack ) |
|
71 |
||
72 |
{ |
|
73 |
iOutput->AppendL( TLiwGenericParam ( KErrorCode,TLiwVariant( (TInt32)SErrNone ) ) ); |
|
74 |
TRAP_IGNORE(iCallBack->HandleNotifyL ( aTransactionID, KLiwEventCanceled, *iOutput,*iInput )); |
|
75 |
//self destruction should be done here in future |
|
76 |
// instead of below four lines |
|
77 |
iCallBack = NULL ; |
|
78 |
//iOutput= NULL; |
|
79 |
iInput = NULL; |
|
80 |
iCmdId= EMgBlankCmdId; |
|
81 |
||
82 |
} |
|
83 |
||
84 |
} |
|
85 |
||
86 |
// Fill the Error code inside Generic Param List |
|
87 |
TInt sapiErr = SErrNone; |
|
88 |
if (aError) |
|
89 |
{ |
|
90 |
sapiErr = CMgInterface::SapiError( aError ); |
|
91 |
} |
|
92 |
||
93 |
iOutput->AppendL(TLiwGenericParam(KErrorCode,TLiwVariant((TInt32)sapiErr))); |
|
94 |
// if not error create the iterator class and put it into output list |
|
95 |
if( ( EMgRefreshComplete == aOperationEvent )&& ( KErrNone == aError ) ) |
|
96 |
{ |
|
97 |
// Fill the Iterator in Generic Paaram List |
|
98 |
TLiwVariant response; |
|
99 |
||
100 |
// Iterator will accept the cmd Id and iListmodel and |
|
101 |
// it will become the owner of iListModel,Ownership of |
|
102 |
// Iterator is transfered to consumer |
|
103 |
||
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
104 |
CMgItemsList *iterator = CMgItemsList::NewL( aListModel, aOperationObserver, iCmdId ); |
5 | 105 |
CleanupStack::PushL( iterator ); |
106 |
response.Set( iterator ); |
|
107 |
iOutput->AppendL( TLiwGenericParam ( KResponse, response ) ); |
|
108 |
CleanupStack::Pop( iterator ); |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
109 |
// iterator->DecRef(); //This code is commented because the when the iterator is passed to user by using |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
110 |
//AsIterable() call refCount is not getting increased. As the iterator control is |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
111 |
//with the user we dont need to decrement the ref count here. |
5 | 112 |
} |
113 |
else |
|
114 |
{ |
|
115 |
delete aListModel; |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
116 |
delete aOperationObserver; |
5 | 117 |
aListModel = NULL; |
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
118 |
aOperationObserver = NULL; |
5 | 119 |
} |
120 |
||
121 |
if( NULL != iCallBack ) |
|
122 |
{ |
|
123 |
// call callback of consumer |
|
124 |
if( KErrNone == aError ) |
|
125 |
{ |
|
126 |
TRAP_IGNORE( |
|
127 |
iCallBack->HandleNotifyL |
|
128 |
( aTransactionID, KLiwEventCompleted, *iOutput,*iInput )); |
|
129 |
||
130 |
} |
|
131 |
else |
|
132 |
{ |
|
133 |
iCallBack->HandleNotifyL ( aTransactionID, KLiwEventError, *iOutput,*iInput ); |
|
134 |
} |
|
135 |
||
136 |
} |
|
137 |
||
138 |
iCmdId = EMgBlankCmdId; |
|
139 |
iCallBack = NULL; |
|
140 |
iInput=NULL; |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
141 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
142 |
// For back to back call observer instance should be deleted here |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
143 |
delete this; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
144 |
|
5 | 145 |
} |
146 |
||
147 |
||
148 |
// ----------------------------------------------------------------------------- |
|
149 |
// CMgServiceObserver::SetMemberVar |
|
150 |
// set the member varibale for the current request. |
|
151 |
// ----------------------------------------------------------------------------- |
|
152 |
void CMgServiceObserver::SetMemberVar(const TMgCmdId& aCmdId, |
|
153 |
const CLiwGenericParamList* aInput, |
|
154 |
MLiwNotifyCallback* aCallBack) |
|
155 |
{ |
|
156 |
||
157 |
iCmdId= EMgBlankCmdId; |
|
158 |
||
159 |
iCallBack = aCallBack; |
|
160 |
iInput = aInput; |
|
161 |
iCmdId = aCmdId; |
|
162 |
||
163 |
} |
|
164 |
||
165 |
// ----------------------------------------------------------------------------- |
|
166 |
// CMgServiceObserver::Cancel |
|
167 |
// Cancel the pending asynchronous request |
|
168 |
// ----------------------------------------------------------------------------- |
|
169 |
void CMgServiceObserver::CancelL() |
|
170 |
{ |
|
171 |
if( iCallBack ) |
|
172 |
{ |
|
173 |
iCallBack->HandleNotifyL ( 0, |
|
174 |
KLiwEventCanceled, |
|
175 |
*iOutput, |
|
176 |
*iInput ); |
|
177 |
||
178 |
iCallBack = NULL ; |
|
179 |
iOutput->Reset(); |
|
180 |
iInput = NULL; |
|
181 |
iCmdId= EMgBlankCmdId; |
|
182 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
183 |
// For back to back call support |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
184 |
delete this; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
185 |
|
5 | 186 |
} |
187 |
||
188 |
||
189 |
// ----------------------------------------------------------------------------- |
|
190 |
// CMgServiceObserver::CMgServiceObserver |
|
191 |
// constructor of class |
|
192 |
// ----------------------------------------------------------------------------- |
|
193 |
||
194 |
CMgServiceObserver::CMgServiceObserver() |
|
195 |
:iCallBack(NULL), |
|
196 |
iOutput(NULL), |
|
197 |
iInput(NULL), |
|
198 |
iCmdId(EMgBlankCmdId) |
|
199 |
{ |
|
200 |
||
201 |
} |
|
202 |
||
203 |
// ----------------------------------------------------------------------------- |
|
204 |
// CMgServiceObserver::~CMgServiceObserver |
|
205 |
// Destructor |
|
206 |
// ----------------------------------------------------------------------------- |
|
207 |
||
208 |
CMgServiceObserver::~CMgServiceObserver() |
|
209 |
{ |
|
210 |
//release output Parameter List |
|
211 |
if ( iOutput ) |
|
212 |
{ |
|
213 |
iOutput->Reset(); |
|
214 |
delete iOutput; |
|
215 |
} |
|
216 |
} |
|
217 |
||
218 |
// ----------------------------------------------------------------------------- |
|
219 |
// CMgServiceObserver::ConstructL |
|
220 |
// Destructor |
|
221 |
// ----------------------------------------------------------------------------- |
|
222 |
||
223 |
void CMgServiceObserver::ConstructL() |
|
224 |
{ |
|
225 |
iOutput = CLiwGenericParamList::NewL(); |
|
226 |
} |