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>
|
|
20 |
|
|
21 |
#include "mgclfoperationobserver.h"
|
|
22 |
#include "mgservice.h"
|
|
23 |
#include "mgoperationobserver.h"
|
|
24 |
|
|
25 |
|
|
26 |
// -----------------------------------------------------------------------------
|
|
27 |
// CClfOperationObserver::NewL
|
|
28 |
// Returns the instance of CClfOperationObserver.
|
|
29 |
// -----------------------------------------------------------------------------
|
|
30 |
CClfOperationObserver* CClfOperationObserver::NewL()
|
|
31 |
{
|
|
32 |
CClfOperationObserver* self = new ( ELeave )CClfOperationObserver();
|
|
33 |
return self;
|
|
34 |
}
|
|
35 |
|
|
36 |
|
|
37 |
//-----------------------------------------------------------------------------
|
|
38 |
//CClfOperationObserver::HandleOperationEventL
|
|
39 |
//This Function called by the CLF Framework when the list of media items are ready
|
|
40 |
// -----------------------------------------------------------------------------
|
|
41 |
|
|
42 |
void CClfOperationObserver::HandleOperationEventL(
|
|
43 |
TCLFOperationEvent aOperationEvent,
|
|
44 |
TInt aError )
|
|
45 |
{
|
|
46 |
TMgOperationEvent mgEvent;
|
|
47 |
|
|
48 |
aOperationEvent == ECLFRefreshComplete?
|
|
49 |
mgEvent = EMgRefreshComplete:mgEvent = EMgModelOutdated;
|
|
50 |
|
|
51 |
|
|
52 |
if ( NULL != iMGService )
|
|
53 |
{
|
|
54 |
// clear the state so that next request can be taken
|
|
55 |
iMGService->Clear();
|
|
56 |
}
|
|
57 |
|
|
58 |
if( NULL != iServiceObserver ) //Asynchronous
|
|
59 |
{
|
|
60 |
|
|
61 |
iServiceObserver->MgNotifyL( iTransactionID,iListModel, mgEvent, aError );
|
|
62 |
|
|
63 |
//Ownership of the List model is transfered to the Iterator class
|
|
64 |
iListModel = NULL;
|
|
65 |
//In future at the time of supporting back to back call
|
|
66 |
//call delete this
|
|
67 |
iServiceObserver = NULL;
|
|
68 |
iMGService = NULL;
|
|
69 |
|
|
70 |
}
|
|
71 |
|
|
72 |
}
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
// CClfOperationObserver::SetMemberVar
|
|
79 |
// set the member varibale for the current request.
|
|
80 |
// -----------------------------------------------------------------------------
|
|
81 |
void CClfOperationObserver::SetMemberVar( TUint aTransactionID,
|
|
82 |
MMgOperationObserver* aServiceObserver,
|
|
83 |
MCLFItemListModel* aListModel,
|
|
84 |
CMgService* aMGService )
|
|
85 |
{
|
|
86 |
|
|
87 |
iServiceObserver = aServiceObserver;
|
|
88 |
iListModel = aListModel;
|
|
89 |
iMGService = aMGService;
|
|
90 |
iTransactionID = aTransactionID;
|
|
91 |
|
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
// CClfOperationObserver::Cancel
|
|
97 |
// Cancel the pending asynchronous request
|
|
98 |
// -----------------------------------------------------------------------------
|
|
99 |
void CClfOperationObserver::CancelL()
|
|
100 |
{
|
|
101 |
TMgOperationEvent mgEvent = EMgModelCancel;
|
|
102 |
if( iListModel )
|
|
103 |
{
|
|
104 |
iListModel->CancelRefresh();
|
|
105 |
delete iListModel;
|
|
106 |
iListModel = NULL;
|
|
107 |
}
|
|
108 |
|
|
109 |
iServiceObserver->MgNotifyL(iTransactionID, NULL , mgEvent, KErrNone );
|
|
110 |
iMGService = NULL;
|
|
111 |
iTransactionID = 0;
|
|
112 |
//In future at the time of supporting back to back call
|
|
113 |
//call delete this
|
|
114 |
iServiceObserver = NULL;
|
|
115 |
|
|
116 |
|
|
117 |
}
|
|
118 |
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
// CClfOperationObserver::CClfOperationObserver
|
|
121 |
// Destructor
|
|
122 |
// -----------------------------------------------------------------------------
|
|
123 |
|
|
124 |
CClfOperationObserver::~CClfOperationObserver()
|
|
125 |
|
|
126 |
{
|
|
127 |
|
|
128 |
// If this observer is waiting for response
|
|
129 |
// then cancel the request
|
|
130 |
if( iListModel )
|
|
131 |
{
|
|
132 |
/*iListModel->CancelRefresh();
|
|
133 |
delete iListModel;
|
|
134 |
iListModel = NULL;*/
|
|
135 |
CancelL();
|
|
136 |
}
|
|
137 |
|
|
138 |
//In future at the time of supporting
|
|
139 |
// back to back Calls we have to delete the iServiceOberver
|
|
140 |
|
|
141 |
}
|
|
142 |
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
// CClfOperationObserver::CClfOperationObserver
|
|
145 |
// Constructor
|
|
146 |
// -----------------------------------------------------------------------------
|
|
147 |
|
|
148 |
CClfOperationObserver::CClfOperationObserver():
|
|
149 |
iServiceObserver( NULL ),
|
|
150 |
iListModel( NULL ),
|
|
151 |
iMGService ( NULL ),
|
|
152 |
iTransactionID(0)
|
|
153 |
{
|
|
154 |
|
|
155 |
}
|