|
1 /* |
|
2 * Copyright (c) 2006 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: Command handler of the engine. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CVTENGCOMMANDHANDLER_H |
|
21 #define CVTENGCOMMANDHANDLER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include "MVtEngCommandHandler.h" |
|
26 #include "mvtengoperationobserver.h" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class CVtEngHandlerContainer; |
|
30 class CVtEngOperation; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 |
|
34 /** |
|
35 * Handler for commands from client. |
|
36 * |
|
37 * @lib videoteleng |
|
38 * @since 2.6 |
|
39 */ |
|
40 NONSHARABLE_CLASS( CVtEngCommandHandler ) : public CBase, |
|
41 public MVtEngCommandHandler, |
|
42 public MVtEngOperationObserver |
|
43 { |
|
44 public: // constructor and destructors |
|
45 |
|
46 static CVtEngCommandHandler* NewL( |
|
47 CVtEngHandlerContainer& aHandlers ); |
|
48 |
|
49 virtual ~CVtEngCommandHandler(); |
|
50 |
|
51 public: // from MVtEngCommandHandler |
|
52 |
|
53 /** |
|
54 * @see MVtEngCommandHandler |
|
55 */ |
|
56 virtual void ExecuteL( |
|
57 const TVtEngCommandId aCommand, |
|
58 TDesC8* aParams ); |
|
59 |
|
60 /** |
|
61 * @see MVtEngCommandHandler |
|
62 */ |
|
63 virtual TInt CancelCommand( const TVtEngCommandId aCommandId ); |
|
64 |
|
65 /** |
|
66 * @see MVtEngCommandHandler |
|
67 */ |
|
68 virtual TInt GetCommandCaps( |
|
69 const TVtEngCommandId aCommand ); |
|
70 |
|
71 /** |
|
72 * @see MVtEngCommandHandler |
|
73 */ |
|
74 virtual TVtEngCommandId PendingCommand(); |
|
75 |
|
76 /** |
|
77 * @see MVtEngCommandHandler |
|
78 */ |
|
79 virtual void AddObserverL( MVtEngCommandObserver& aObserver ); |
|
80 |
|
81 /** |
|
82 * @see MVtEngCommandHandler |
|
83 */ |
|
84 virtual void RemoveObserver( MVtEngCommandObserver& aObserver ); |
|
85 |
|
86 public: // from MVtEngOperationObserver |
|
87 |
|
88 /** |
|
89 * Handles command completion. |
|
90 * @param aCommand command id |
|
91 * @param aResult Symbian OS error code. |
|
92 */ |
|
93 virtual void CommandCompleteL( |
|
94 const TVtEngCommandId aCommand, |
|
95 const TInt aResult ); |
|
96 |
|
97 /** |
|
98 * Sets pending asynch operation |
|
99 * @param aActiveOp pending operation or NULL. |
|
100 */ |
|
101 virtual void SetOperation( CVtEngOperation* aActiveOp ); |
|
102 |
|
103 private: // constructors |
|
104 |
|
105 /** |
|
106 * Second phase constructor |
|
107 */ |
|
108 void ConstructL(); |
|
109 |
|
110 /** |
|
111 * c++ constructor |
|
112 */ |
|
113 CVtEngCommandHandler( CVtEngHandlerContainer& aHandlers ); |
|
114 |
|
115 private: |
|
116 |
|
117 void AddToPoolL( TVtEngCommandId aCommand ); |
|
118 |
|
119 /** |
|
120 * Validates command |
|
121 */ |
|
122 void ValidateL( |
|
123 const TVtEngCommandId aCommandId, |
|
124 TDesC8* aParams ); |
|
125 |
|
126 /** |
|
127 * Check if command is async. |
|
128 */ |
|
129 void CheckAsynchronity( |
|
130 const TVtEngCommandId aCommandId, |
|
131 TInt& aCaps ); |
|
132 |
|
133 /** |
|
134 * Check if command is supported. |
|
135 */ |
|
136 void CheckSupport( |
|
137 const TVtEngCommandId aCommandId, |
|
138 TInt& aCaps ); |
|
139 |
|
140 /** |
|
141 * Check if command is applicable in current state. |
|
142 */ |
|
143 void CheckState( |
|
144 const TVtEngCommandId aCommandId, |
|
145 TInt& aCaps ); |
|
146 |
|
147 private: // command pool |
|
148 |
|
149 struct TVtOpItem |
|
150 { |
|
151 TVtEngCommandId iId; |
|
152 CVtEngOperation* iOperation; |
|
153 }; |
|
154 /** |
|
155 * Command pool for commands instantiated at construction |
|
156 * time to guarantee certain operations. |
|
157 */ |
|
158 NONSHARABLE_CLASS( CVtEngCmdPool ): public CArrayPtrFlat<CVtEngOperation> |
|
159 { |
|
160 public: // constructor and destructor |
|
161 |
|
162 // Constructor |
|
163 CVtEngCmdPool( TInt aGranularity ); |
|
164 |
|
165 // Destructor |
|
166 ~CVtEngCmdPool(); |
|
167 |
|
168 public: // data structures |
|
169 |
|
170 |
|
171 public: // new methods |
|
172 |
|
173 /** |
|
174 * Returns operation stored in the pool. |
|
175 * @param aId command id |
|
176 * @return operation or NULL if not found. |
|
177 */ |
|
178 CVtEngOperation* Get( const TVtEngCommandId aId ); |
|
179 |
|
180 }; |
|
181 |
|
182 private: // Data members |
|
183 |
|
184 RPointerArray<MVtEngCommandObserver> iObservers; |
|
185 CVtEngHandlerContainer& iHandlers; |
|
186 CVtEngOperation* iActiveOp; |
|
187 CVtEngCmdPool* iCommandPool; |
|
188 |
|
189 }; |
|
190 |
|
191 #endif //CVTENGCOMMANDHANDLER_H |
|
192 |
|
193 // End of File |