|
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: Videoteleng API extension configuration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CVtEngExtensions.h" |
|
21 #include "VtEngPanic.h" |
|
22 #include "VtEngUtils.h" |
|
23 |
|
24 #include "CVtEngOperation.h" |
|
25 #include "CVtEngMediaHandler.h" |
|
26 #include "CVtEngCameraPreferences.h" |
|
27 #include "cvtengrecord2file.h" |
|
28 |
|
29 #include <cvtlogger.h> |
|
30 |
|
31 // LOCAL CONSTANTS AND MACROS |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CVtEngExtensions::CVtEngExtensions |
|
37 // C++ constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CVtEngExtensions::CVtEngExtensions(): |
|
42 iExtensionArray( KExtensionGranularity ) |
|
43 { |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CVtEngExtensions::ConstructL |
|
48 // Symbian 2nd phase constructor can leave. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CVtEngExtensions::ConstructL() |
|
52 { |
|
53 __VTPRINTENTER( "Extensions.ConstructL" ) |
|
54 __VTPRINTEXIT( "Extensions.ConstructL" ) |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CVtEngExtensions::NewL |
|
59 // Two-phased constructor. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CVtEngExtensions* CVtEngExtensions::NewL() |
|
63 { |
|
64 CVtEngExtensions* self = new( ELeave ) CVtEngExtensions; |
|
65 |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop(); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CVtEngExtensions::~CVtEngExtensions |
|
74 // Destructor. Cannot leave. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 CVtEngExtensions::~CVtEngExtensions() |
|
78 { |
|
79 __VTPRINTENTER( "Extensions.~" ) |
|
80 // Clean and destroy pointer array |
|
81 iExtensionArray.ResetAndDestroy(); |
|
82 __VTPRINTEXIT( "Extensions.~" ) |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CVtEngExtensions::CreateExtensions |
|
87 // |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CVtEngExtensionBase* CVtEngExtensions::CreateExtensionsL( const TUid& aUid, |
|
91 CVtEngMediaHandler& aHandler) |
|
92 { |
|
93 __VTPRINTENTER( "Extensions.CreateExtensions" ) |
|
94 |
|
95 // init local variables |
|
96 TInt error = KErrNotSupported; |
|
97 CVtEngExtensionBase* extension = NULL; |
|
98 |
|
99 // Check if supported UID |
|
100 if ( aUid == KVtEngExtensionCameraPreferences || |
|
101 aUid == KVtEngExtensionRecord2File ) |
|
102 { |
|
103 // Create extension |
|
104 extension = aHandler.CreateExtensionsL( aUid ); |
|
105 |
|
106 // Push it to clean up stack because |
|
107 // it needs to be append in to |
|
108 // array and it can be failed |
|
109 CleanupStack::PushL( extension ); |
|
110 |
|
111 // append extension in to array |
|
112 error = iExtensionArray.Append(extension); |
|
113 if ( error != KErrNone ) |
|
114 { |
|
115 // if append fails |
|
116 // clear clean up stack and leave |
|
117 __VTPRINTEXITR( |
|
118 "Extensions.CreateExtensions iExtension.Append failed %d", |
|
119 error ) |
|
120 CleanupStack::PopAndDestroy(); |
|
121 User::Leave( error ); |
|
122 } |
|
123 // append succesful |
|
124 // pop extension from clena up stack and return |
|
125 __VTPRINTEXITR( |
|
126 "Extensions.CreateExtensions iExtension UID[%d] succesfully Appended", |
|
127 aUid.iUid) |
|
128 CleanupStack::Pop(); |
|
129 return extension; |
|
130 } |
|
131 // not supported UID |
|
132 // leave with error |
|
133 else |
|
134 { |
|
135 __VTPRINTEXITR( |
|
136 "Extensions.CreateExtensions Extension NOTSUPPORTED UID%d", |
|
137 aUid.iUid ) |
|
138 User::Leave( error ); |
|
139 return extension; |
|
140 } |
|
141 |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CVtEngExtensions::GetClientInterface |
|
146 // |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 TInt CVtEngExtensions::GetClientInterface( TAny** aInterfacePtr, |
|
150 const TUid& aUid , CVtEngMediaHandler& aHandler) |
|
151 { |
|
152 __VTPRINTENTER( "Extensions.GetClientInterface" ) |
|
153 // if aInterfacePtr pointer is NULL -> panic |
|
154 __ASSERT_ALWAYS( aInterfacePtr,Panic( EVtEngPanicInvalidPointer ) ); |
|
155 |
|
156 // init local variables |
|
157 CVtEngExtensionBase* extension = NULL; |
|
158 TInt error = KErrGeneral; |
|
159 |
|
160 // initialize IF pointer to be NULL |
|
161 // if correct extension API IF is found |
|
162 // then changed to valid pointer |
|
163 *aInterfacePtr = NULL; |
|
164 |
|
165 // Check if extension is allready in pointer array |
|
166 TInt index = LookupExtensions( aUid ); |
|
167 if ( index != KErrNotFound ) |
|
168 { |
|
169 *aInterfacePtr = iExtensionArray[index]->GetInterface(); |
|
170 __VTPRINTEXITR( "Extensions.GetClientInterface error [%d]", KErrNone ) |
|
171 return KErrNone; |
|
172 } |
|
173 // Create extension |
|
174 else |
|
175 { |
|
176 TRAP( error, extension = CreateExtensionsL( aUid, aHandler ) ); |
|
177 if ( extension && error == KErrNone ) |
|
178 { |
|
179 *aInterfacePtr = extension->GetInterface(); |
|
180 error = KErrNone; |
|
181 } |
|
182 __VTPRINTEXITR( "Extensions.GetClientInterface error [%d]", error ) |
|
183 return error; |
|
184 } |
|
185 } |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CVtEngExtensions::LookupExtensions |
|
188 // |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TInt CVtEngExtensions::LookupExtensions( const TUid& aUid) const |
|
192 { |
|
193 __VTPRINTENTER( "Extensions.LookupExtensions" ) |
|
194 TInt index( iExtensionArray.Count() ); |
|
195 |
|
196 // Loop whole extension array |
|
197 while( index-- ) |
|
198 { |
|
199 // If matches in one of arrays UIDs |
|
200 if( aUid == iExtensionArray[index]->Uid() ) |
|
201 { |
|
202 __VTPRINTEXITR( "Extensions.LookupExtensions index [%d]", index) |
|
203 return index; |
|
204 } |
|
205 } |
|
206 __VTPRINTEXITR("Extensions.LookupExtensions Not Found index [%d]", |
|
207 KErrNotFound) |
|
208 return KErrNotFound; |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CVtEngExtensions::OfferOperationL |
|
213 // |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 TBool CVtEngExtensions::OfferOperationL( CVtEngOperation* aOp ) |
|
217 { |
|
218 __VTPRINTENTER( "Extensions.OfferOperationL" ) |
|
219 |
|
220 TInt index( iExtensionArray.Count() ); |
|
221 |
|
222 // Format cmdComleted as false |
|
223 TBool cmdCompleted = EFalse; |
|
224 // Offer operation to all extension in array |
|
225 while( index-- ) |
|
226 { |
|
227 // If valid extension found |
|
228 if ( iExtensionArray[index]->HandleL( aOp ) ) |
|
229 { |
|
230 cmdCompleted = ETrue; |
|
231 break; |
|
232 } |
|
233 } |
|
234 __VTPRINTEXITR( "Extensions.OfferOperationL cmdCompleted [%d]", |
|
235 cmdCompleted) |
|
236 return cmdCompleted; |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CVtEngExtensions::ValidateCommand |
|
241 // |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 TBool CVtEngExtensions::ValidateCommand( const TVtEngCommandId aCommandId ) |
|
245 { |
|
246 __VTPRINTENTER( "Extensions.ValidateCommand" ) |
|
247 TInt index( iExtensionArray.Count() ); |
|
248 |
|
249 // Format oKToPerform as false |
|
250 TBool oKToPerform = EFalse; |
|
251 // Try validate command in all extensions in array |
|
252 while( index-- ) |
|
253 { |
|
254 // If valid extension found |
|
255 if ( iExtensionArray[index]->ValidateCommand( aCommandId ) ) |
|
256 { |
|
257 oKToPerform = ETrue; |
|
258 break; |
|
259 } |
|
260 } |
|
261 __VTPRINTEXITR( "Extensions.ValidateCommand oKToPerform [%d]", |
|
262 oKToPerform) |
|
263 return oKToPerform; |
|
264 } |
|
265 |
|
266 // End of File |
|
267 |