1 /* |
|
2 * Copyright (c) 2007-2008 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: Active object for handling toolbar commands |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CamCommandHandlerAo.h" |
|
21 #include "camlogging.h" |
|
22 #include <aknview.h> |
|
23 |
|
24 // ============================ MEMBER FUNCTIONS =============================== |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CCamCommandHandlerAo::CCamCommandHandlerAo |
|
28 // C++ constructor |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CCamCommandHandlerAo::CCamCommandHandlerAo( CAknView* aView ) |
|
32 :CActive( CActive::EPriorityStandard ), iView( aView ) |
|
33 { |
|
34 } |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CCamCommandHandlerAo::~CCamCommandHandlerAo |
|
38 // Destructor |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CCamCommandHandlerAo::~CCamCommandHandlerAo() |
|
42 { |
|
43 Cancel(); |
|
44 iCommandQueue.Close(); |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CCamCommandHandlerAo::NewL |
|
49 // Two-phased constructor. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CCamCommandHandlerAo* CCamCommandHandlerAo::NewL( CAknView* aView ) |
|
53 { |
|
54 CCamCommandHandlerAo* self = new( ELeave ) CCamCommandHandlerAo( aView ); |
|
55 |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop( self ); |
|
59 |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CCamCommandHandlerAo::ConstructL |
|
65 // 2nd phase construction |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CCamCommandHandlerAo::ConstructL() |
|
69 { |
|
70 CActiveScheduler::Add( this ); |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CCamCommandHandlerAo::DoCancel |
|
75 // Cancels the active object |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CCamCommandHandlerAo::DoCancel() |
|
79 { |
|
80 iCommandQueue.Close(); |
|
81 PRINT( _L("Camera => CCamCommandHandlerAo::DoCancel()") ); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CCamCommandHandlerAo::RunL |
|
86 // Checks the command from command queue and sends it to view |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CCamCommandHandlerAo::RunL() |
|
90 { |
|
91 if ( iCommandQueue.Count() ) |
|
92 { |
|
93 TInt command = iCommandQueue[ 0 ]; |
|
94 iCommandQueue.Remove( 0 ); |
|
95 iView->HandleCommandL( command ); |
|
96 } |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CCamCommandHandlerAo::RunError |
|
101 // Called when an error has occurred. |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 TInt CCamCommandHandlerAo::RunError( TInt aError ) |
|
105 { |
|
106 PRINT1( _L("Camera => CCamCommandHandlerAo::RunError( %d )"), aError ); |
|
107 (void)aError; // remove compiler warning |
|
108 |
|
109 iCommandQueue.Close(); |
|
110 |
|
111 PRINT( _L("Camera <= CCamCommandHandlerAo::RunError()")); |
|
112 |
|
113 return KErrNone; |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CCamCommandHandlerAo::HandleCommandL |
|
118 // Adds the command to queue and sets active |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CCamCommandHandlerAo::HandleCommandL( TInt aCommandId ) |
|
122 { |
|
123 PRINT( _L("Camera => CCamCommandHandlerAo::HandleCommandL()")); |
|
124 |
|
125 TInt count = iCommandQueue.Count(); |
|
126 |
|
127 if( count < 1 || iCommandQueue[ count - 1 ] != aCommandId ) |
|
128 { |
|
129 iCommandQueue.AppendL( aCommandId ); |
|
130 } |
|
131 |
|
132 if ( !IsActive() ) |
|
133 { |
|
134 TRequestStatus* statusPtr = &iStatus; |
|
135 User::RequestComplete( statusPtr, KErrNone ); |
|
136 SetActive(); |
|
137 } |
|
138 |
|
139 PRINT( _L("Camera <= CCamCommandHandlerAo::HandleCommandL()")); |
|
140 } |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|