1 /* |
|
2 * Copyright (c) 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: Menu item operation watcher. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <mcsmenuoperation.h> |
|
19 #include "carouselpluginwatcher.h" |
|
20 #include "carouselpluginengine.h" |
|
21 |
|
22 // --------------------------------------------------------------------------- |
|
23 // two-phased constructor |
|
24 // --------------------------------------------------------------------------- |
|
25 CCarouselPluginWatcher* CCarouselPluginWatcher::NewL( const Type& aType ) |
|
26 { |
|
27 CCarouselPluginWatcher* self = new (ELeave) CCarouselPluginWatcher( aType ); |
|
28 CleanupStack::PushL( self ); |
|
29 self->ConstructL(); |
|
30 CleanupStack::Pop( self ); |
|
31 return self; |
|
32 } |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // default constructor |
|
36 // --------------------------------------------------------------------------- |
|
37 CCarouselPluginWatcher::CCarouselPluginWatcher( const Type& aType ) |
|
38 : CActive( CActive::EPriorityStandard ), |
|
39 iType( aType ) |
|
40 { |
|
41 CActiveScheduler::Add( this ); |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // destructor |
|
46 // --------------------------------------------------------------------------- |
|
47 CCarouselPluginWatcher::~CCarouselPluginWatcher() |
|
48 { |
|
49 Cancel(); |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // second phase constructor |
|
54 // --------------------------------------------------------------------------- |
|
55 void CCarouselPluginWatcher::ConstructL() |
|
56 { |
|
57 |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // Watch Async |
|
62 // --------------------------------------------------------------------------- |
|
63 void CCarouselPluginWatcher::Watch( CMenuOperation* aOperation) |
|
64 { |
|
65 __ASSERT_DEBUG( KRequestPending == iStatus.Int(), User::Invariant() ); |
|
66 //__ASSERT_DEBUG( !iOperation, User::Invariant() ); |
|
67 iOperation = aOperation; |
|
68 SetActive(); |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // Watch Async |
|
73 // --------------------------------------------------------------------------- |
|
74 void CCarouselPluginWatcher::WatchNotify( MCarouselPluginWatcherObserver* aObserver ) |
|
75 { |
|
76 __ASSERT_DEBUG( KRequestPending == iStatus.Int(), User::Invariant() ); |
|
77 //__ASSERT_DEBUG( !iOperation, User::Invariant() ); |
|
78 iObserver = aObserver; |
|
79 SetActive(); |
|
80 } |
|
81 |
|
82 void CCarouselPluginWatcher::StopAndWatch( CMenuOperation* aOperation, |
|
83 CActiveSchedulerWait* aWaitScheduler ) |
|
84 { |
|
85 __ASSERT_DEBUG( KRequestPending == iStatus.Int(), User::Invariant() ); |
|
86 iWaitScheduler = aWaitScheduler; |
|
87 iOperation = aOperation; |
|
88 SetActive(); |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // Inherited from CActive class |
|
93 // --------------------------------------------------------------------------- |
|
94 void CCarouselPluginWatcher::RunL() |
|
95 { |
|
96 delete iOperation; |
|
97 iOperation = NULL; |
|
98 |
|
99 if( iType == ENotify ) |
|
100 { |
|
101 iObserver->HandleNotifyL(); |
|
102 } |
|
103 if ( iWaitScheduler && iWaitScheduler->IsStarted() ) |
|
104 { |
|
105 Cancel(); |
|
106 iWaitScheduler->AsyncStop(); |
|
107 } |
|
108 //CActiveScheduler::Stop(); |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // Inherited from CActive class |
|
113 // --------------------------------------------------------------------------- |
|
114 void CCarouselPluginWatcher::DoCancel() |
|
115 { |
|
116 delete iOperation; |
|
117 iOperation = NULL; |
|
118 } |
|
119 |
|
120 TInt CCarouselPluginWatcher::GetStatus() |
|
121 { |
|
122 return iStatus.Int(); |
|
123 } |
|
124 |
|