1 /* |
|
2 * Copyright (c) 2007 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 used to emulate the auto focus custom extension* |
|
15 */ |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <e32std.h> |
|
20 |
|
21 #include "CamAppControllerBase.h" |
|
22 #include "TestAFExtension.h" |
|
23 |
|
24 const TInt KAutoFocusTimeout = 1500000; |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ======================= |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // CTestAFExtension::NewL |
|
30 // Symbian OS two-phased constructor |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CTestAFExtension* CTestAFExtension::NewL( CCamAppControllerBase& aController, TBool aFailAutoFocus ) |
|
34 { |
|
35 CTestAFExtension* self = NewLC( aController, aFailAutoFocus ); |
|
36 CleanupStack::Pop( self ); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CTestAFExtension::NewLC |
|
42 // Symbian OS two-phased constructor |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CTestAFExtension* CTestAFExtension::NewLC( CCamAppControllerBase& aController, TBool aFailAutoFocus ) |
|
46 { |
|
47 CTestAFExtension* self = new ( ELeave ) CTestAFExtension( aController, aFailAutoFocus ); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // Destructor |
|
54 CTestAFExtension::~CTestAFExtension() |
|
55 { |
|
56 Cancel(); |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CTestAFExtension::Start |
|
61 // Start 'auto focus' procedure. |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 void CTestAFExtension::Start() |
|
65 { |
|
66 // Notify observers that AF procedure has started |
|
67 TUid uid = KUidCamExtAutoFocus; |
|
68 TAny* p1 = static_cast< TAny* > ( &uid ); |
|
69 TCamExtAutoFocus focusState = ECamExtAutoFocusFocusing; |
|
70 TAny* p2 = static_cast< TAny* > ( &focusState ); |
|
71 iController.Notify( p1, p2 ); |
|
72 After( KAutoFocusTimeout ); |
|
73 } |
|
74 |
|
75 #ifdef CAMERAAPP_UNIT_TEST |
|
76 // --------------------------------------------------------------------------- |
|
77 // CTestAFExtension::SetFailAutoFocus |
|
78 // Set whether or not the autofocus operation returns a failure |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CTestAFExtension::SetFailAutoFocus( TBool aFailAutoFocus ) |
|
82 { |
|
83 iFailAutoFocus = aFailAutoFocus; |
|
84 } |
|
85 #endif |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CTestAFExtension::RunL |
|
89 // From CActive, handle timeout expiration |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 void CTestAFExtension::RunL() |
|
93 { |
|
94 TUid uid = KUidCamExtAutoFocus; |
|
95 TAny* p1 = static_cast< TAny* > ( &uid ); |
|
96 TCamExtAutoFocus focusState; |
|
97 if ( iFailAutoFocus ) |
|
98 { |
|
99 // Notify the controller that focus procedure has failed |
|
100 focusState = ECamExtAutoFocusFailed; |
|
101 } |
|
102 else |
|
103 { |
|
104 // Notify the controller that focus has been achieved |
|
105 focusState = ECamExtAutoFocusFocused; |
|
106 } |
|
107 TAny* p2 = static_cast< TAny* > ( &focusState ); |
|
108 iController.Notify( p1, p2 ); |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CTestAFExtension::CTestAFExtension |
|
113 // C++ constructor |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 CTestAFExtension::CTestAFExtension( CCamAppControllerBase& aController, TBool aFailAutoFocus ) |
|
117 : CTimer( EPriorityStandard ), iController( aController ), iFailAutoFocus( aFailAutoFocus ) |
|
118 { |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // CTestAFExtension::ConstructL |
|
123 // Symbian OS 2nd phase constructor |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CTestAFExtension::ConstructL() |
|
127 { |
|
128 CTimer::ConstructL(); |
|
129 CActiveScheduler::Add( this ); |
|
130 } |
|
131 |
|
132 // End of File |
|