author | Mikko Sunikka <mikko.sunikka@nokia.com> |
Fri, 06 Nov 2009 13:05:00 +0200 | |
changeset 19 | 8d692d9f828f |
parent 10 | fc9cf246af83 |
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 CLF framework |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include <mclfitemlistmodel.h> |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
20 |
#include <mclfsortingstyle.h> |
5 | 21 |
|
22 |
#include "mgclfoperationobserver.h" |
|
23 |
#include "mgservice.h" |
|
24 |
#include "mgoperationobserver.h" |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
25 |
#include "asynchrequestmanager.h" |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
26 |
#include "mgpostfilter.h" |
5 | 27 |
|
28 |
||
29 |
// ----------------------------------------------------------------------------- |
|
30 |
// CClfOperationObserver::NewL |
|
31 |
// Returns the instance of CClfOperationObserver. |
|
32 |
// ----------------------------------------------------------------------------- |
|
33 |
CClfOperationObserver* CClfOperationObserver::NewL() |
|
34 |
{ |
|
35 |
CClfOperationObserver* self = new ( ELeave )CClfOperationObserver(); |
|
36 |
return self; |
|
37 |
} |
|
38 |
||
39 |
||
40 |
//----------------------------------------------------------------------------- |
|
41 |
//CClfOperationObserver::HandleOperationEventL |
|
42 |
//This Function called by the CLF Framework when the list of media items are ready |
|
43 |
// ----------------------------------------------------------------------------- |
|
44 |
||
45 |
void CClfOperationObserver::HandleOperationEventL( |
|
46 |
TCLFOperationEvent aOperationEvent, |
|
47 |
TInt aError ) |
|
48 |
{ |
|
49 |
TMgOperationEvent mgEvent; |
|
50 |
||
51 |
aOperationEvent == ECLFRefreshComplete? |
|
52 |
mgEvent = EMgRefreshComplete:mgEvent = EMgModelOutdated; |
|
53 |
||
54 |
||
55 |
if ( NULL != iMGService ) |
|
56 |
{ |
|
57 |
// clear the state so that next request can be taken |
|
58 |
iMGService->Clear(); |
|
59 |
} |
|
60 |
||
61 |
if( NULL != iServiceObserver ) //Asynchronous |
|
62 |
{ |
|
63 |
||
64 |
iServiceObserver->MgNotifyL( iTransactionID,iListModel, mgEvent, aError ); |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
65 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
66 |
// calling request complete on asyncrequestmanager |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
67 |
iAsyncRequestManager->RequestComplete( iTransactionID ); |
5 | 68 |
|
69 |
//Ownership of the List model is transfered to the Iterator class |
|
70 |
iListModel = NULL; |
|
71 |
//In future at the time of supporting back to back call |
|
72 |
//call delete this |
|
73 |
iServiceObserver = NULL; |
|
74 |
iMGService = NULL; |
|
75 |
||
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
76 |
delete this; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
77 |
|
5 | 78 |
} |
79 |
||
80 |
} |
|
81 |
||
82 |
||
83 |
||
84 |
||
85 |
// ----------------------------------------------------------------------------- |
|
86 |
// CClfOperationObserver::SetMemberVar |
|
87 |
// set the member varibale for the current request. |
|
88 |
// ----------------------------------------------------------------------------- |
|
89 |
void CClfOperationObserver::SetMemberVar( TUint aTransactionID, |
|
90 |
MMgOperationObserver* aServiceObserver, |
|
91 |
MCLFItemListModel* aListModel, |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
92 |
CMgService* aMGService,CAsynchRequestManager* aAsyncReqManager, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
93 |
CPostFilter* aFilter,MCLFSortingStyle* aSortingStyle) |
5 | 94 |
{ |
95 |
||
96 |
iServiceObserver = aServiceObserver; |
|
97 |
iListModel = aListModel; |
|
98 |
iMGService = aMGService; |
|
99 |
iTransactionID = aTransactionID; |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
100 |
iAsyncRequestManager = aAsyncReqManager; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
101 |
iFilter = aFilter; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
102 |
iSortingStyle= aSortingStyle; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
103 |
|
5 | 104 |
} |
105 |
||
106 |
||
107 |
// ----------------------------------------------------------------------------- |
|
108 |
// CClfOperationObserver::Cancel |
|
109 |
// Cancel the pending asynchronous request |
|
110 |
// ----------------------------------------------------------------------------- |
|
111 |
void CClfOperationObserver::CancelL() |
|
112 |
{ |
|
113 |
TMgOperationEvent mgEvent = EMgModelCancel; |
|
114 |
if( iListModel ) |
|
115 |
{ |
|
116 |
iListModel->CancelRefresh(); |
|
117 |
delete iListModel; |
|
118 |
iListModel = NULL; |
|
119 |
} |
|
120 |
||
121 |
iServiceObserver->MgNotifyL(iTransactionID, NULL , mgEvent, KErrNone ); |
|
122 |
iMGService = NULL; |
|
123 |
iTransactionID = 0; |
|
124 |
//In future at the time of supporting back to back call |
|
125 |
//call delete this |
|
126 |
iServiceObserver = NULL; |
|
127 |
||
128 |
||
129 |
} |
|
130 |
||
131 |
// ----------------------------------------------------------------------------- |
|
132 |
// CClfOperationObserver::CClfOperationObserver |
|
133 |
// Destructor |
|
134 |
// ----------------------------------------------------------------------------- |
|
135 |
||
136 |
CClfOperationObserver::~CClfOperationObserver() |
|
137 |
||
138 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
139 |
|
5 | 140 |
// If this observer is waiting for response |
141 |
// then cancel the request |
|
142 |
if( iListModel ) |
|
143 |
{ |
|
144 |
/*iListModel->CancelRefresh(); |
|
145 |
delete iListModel; |
|
146 |
iListModel = NULL;*/ |
|
147 |
CancelL(); |
|
148 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
149 |
if(iAsyncRequestManager) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
150 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
151 |
iAsyncRequestManager = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
152 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
153 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
154 |
if(iFilter) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
155 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
156 |
delete iFilter; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
157 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
158 |
if(iSortingStyle) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
159 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
160 |
delete iSortingStyle; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
161 |
} |
5 | 162 |
//In future at the time of supporting |
163 |
// back to back Calls we have to delete the iServiceOberver |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
164 |
iServiceObserver = NULL; |
5 | 165 |
} |
166 |
||
167 |
// ----------------------------------------------------------------------------- |
|
168 |
// CClfOperationObserver::CClfOperationObserver |
|
169 |
// Constructor |
|
170 |
// ----------------------------------------------------------------------------- |
|
171 |
||
172 |
CClfOperationObserver::CClfOperationObserver(): |
|
173 |
iServiceObserver( NULL ), |
|
174 |
iListModel( NULL ), |
|
175 |
iMGService ( NULL ), |
|
176 |
iTransactionID(0) |
|
177 |
{ |
|
178 |
||
179 |
} |