|
1 /* |
|
2 * Copyright (c) 2002-2009 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 "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include "CCLFEventHandler.h" |
|
22 #include "MCLFEventHandlerObserver.h" |
|
23 #include "MGDebugPrint.h" |
|
24 |
|
25 // MACROS |
|
26 // Macro for calling a member function through function pointer |
|
27 #define CLF_CALL_MEMBER_FN( aObject, aPtrToMember ) \ |
|
28 (( aObject ).*( aPtrToMember )) |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CCLFEventHandler::CCLFEventHandler |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CCLFEventHandler::CCLFEventHandler( CCLFServerProxy& aEventHandler, |
|
37 MCLFEventHandlerObserver& aObserver ) |
|
38 : CActive( CActive::EPriorityStandard ), |
|
39 iEventHandler( aEventHandler ), |
|
40 iObserver( aObserver ), |
|
41 iOperationFunction( &CCLFServerProxy::GetUpdateEndEvent ), |
|
42 iCancelFunction( &CCLFServerProxy::CancelGetEvent ), |
|
43 iObserverFunction( &MCLFEventHandlerObserver::HandleUpdateEndEventL ) |
|
44 { |
|
45 CActiveScheduler::Add( this ); |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CCLFEventHandler::NewL |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CCLFEventHandler* CCLFEventHandler::NewL( CCLFServerProxy& aEventHandler, |
|
53 MCLFEventHandlerObserver& aObserver ) |
|
54 { |
|
55 return new( ELeave ) CCLFEventHandler( aEventHandler, aObserver ); |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CCLFEventHandler::~CCLFEventHandler |
|
60 // Destructor |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CCLFEventHandler::~CCLFEventHandler() |
|
64 { |
|
65 Cancel(); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CCLFEventHandler::DoCancel |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CCLFEventHandler::DoCancel() |
|
73 { |
|
74 CLF_CALL_MEMBER_FN( iEventHandler, iCancelFunction )(); |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CCLFEventHandler::RunL |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CCLFEventHandler::RunL() |
|
82 { |
|
83 // observer function can leave |
|
84 CLF_CALL_MEMBER_FN( iObserver, iObserverFunction )( iStatus.Int() ); |
|
85 DoStart(); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CCLFDbItemProvider::RunError |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 TInt CCLFEventHandler::RunError( const TInt aError ) |
|
93 { |
|
94 MG_DEBUG2( re1, "[CLF]\t CCLFEventHandler::RunError: %d", aError ); |
|
95 |
|
96 return aError; |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CCLFEventHandler::ObserverUpdateEndEvent |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CCLFEventHandler::ObserverUpdateEndEvent() |
|
104 { |
|
105 Cancel(); |
|
106 iOperationFunction = &CCLFServerProxy::GetUpdateEndEvent; |
|
107 iCancelFunction = &CCLFServerProxy::CancelGetEvent; |
|
108 iObserverFunction = &MCLFEventHandlerObserver::HandleUpdateEndEventL; |
|
109 DoStart(); |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CCLFEventHandler::ObserverUpdateStartEvent |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CCLFEventHandler::ObserverUpdateStartEvent() |
|
117 { |
|
118 Cancel(); |
|
119 iOperationFunction = &CCLFServerProxy::GetUpdateStartEvent; |
|
120 iCancelFunction = &CCLFServerProxy::CancelGetUpdateStartEvent; |
|
121 iObserverFunction = &MCLFEventHandlerObserver::HandleUpdateStartEventL; |
|
122 DoStart(); |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CCLFEventHandler::DoStart |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void CCLFEventHandler::DoStart() |
|
130 { |
|
131 CLF_CALL_MEMBER_FN( iEventHandler, iOperationFunction )( iStatus ); |
|
132 SetActive(); |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CCLFEventHandler::GetChangedItemsL |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CCLFEventHandler::GetChangedItemsL( RArray<TUint>& aItemArray ) |
|
140 { |
|
141 User::LeaveIfError( iEventHandler.FetchItemListData( aItemArray ) ); |
|
142 } |
|
143 |
|
144 // End of File |