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