|
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: Callback wrapper for Publish and Subscribe* |
|
15 */ |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 |
|
20 #include <e32svr.h> |
|
21 #include <f32file.h> |
|
22 #include "CamPropertyWatcher.h" |
|
23 #include "CamPropertyObserver.h" |
|
24 #include "CamUtility.h" |
|
25 |
|
26 // ========================= MEMBER FUNCTIONS ================================ |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CCamPropertyWatcher::NewL |
|
30 // Two phase construction |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CCamPropertyWatcher* CCamPropertyWatcher::NewL( MPropertyObserver& aPropertyObserver, |
|
34 const TUid& aCategory, |
|
35 const TUint aKey ) |
|
36 { |
|
37 CCamPropertyWatcher* self = new(ELeave) CCamPropertyWatcher( aPropertyObserver, |
|
38 aCategory, |
|
39 aKey ); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop( self ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CCamPropertyWatcher::Destructor |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CCamPropertyWatcher::~CCamPropertyWatcher() |
|
51 { |
|
52 PRINT( _L("Camera => ~CCamPropertyWatcher") ); |
|
53 Cancel(); |
|
54 iProperty.Close(); |
|
55 PRINT( _L("Camera <= ~CCamPropertyWatcher") ); |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CCamPropertyWatcher::Subscribe |
|
60 // Request notification of change events |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CCamPropertyWatcher::Subscribe() |
|
64 { |
|
65 PRINT( _L( "Camera => CCamPropertyWatcher::Subscribe()" ) ) |
|
66 iProperty.Subscribe( iStatus ); |
|
67 SetActive(); |
|
68 PRINT( _L( "Camera <= CCamPropertyWatcher::Subscribe()" ) ) |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CCamPropertyWatcher::Get |
|
73 // Return the current value |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 TInt CCamPropertyWatcher::Get( TInt& aValue ) |
|
77 { |
|
78 return iProperty.Get( aValue ); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CCamPropertyWatcher::CCamPropertyWatcher |
|
83 // Constructor |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 CCamPropertyWatcher::CCamPropertyWatcher( MPropertyObserver& aPropertyObserver, |
|
87 const TUid& aCategory, |
|
88 const TUint aKey ) : |
|
89 CActive( EPriorityStandard ), |
|
90 iPropertyObserver( aPropertyObserver ), |
|
91 iCategory( aCategory), |
|
92 iKey( aKey ) |
|
93 { |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CCamPropertyWatcher::ConstructL |
|
98 // Second phase construction |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CCamPropertyWatcher::ConstructL() |
|
102 { |
|
103 CActiveScheduler::Add( this ); |
|
104 User::LeaveIfError( iProperty.Attach( iCategory, iKey ) ); |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CCamPropertyWatcher::RunL |
|
109 // Handle notification of value change |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void CCamPropertyWatcher::RunL() |
|
113 { |
|
114 PRINT( _L( "Camera => CCamPropertyWatcher::RunL()" ) ) |
|
115 const TInt error ( iStatus.Int() ); |
|
116 PRINT1( _L( "Camera CCamPropertyWatcher::RunL() status = %d" ), error ) |
|
117 Subscribe(); |
|
118 if ( error == KErrNone ) |
|
119 { |
|
120 PRINT( _L( "Camera CCamPropertyWatcher::RunL() calling HandlePropertyChangedL" ) ) |
|
121 iPropertyObserver.HandlePropertyChangedL( iCategory, iKey ); |
|
122 } |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CCamPropertyWatcher::DoCancel |
|
127 // Handle cancellation |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CCamPropertyWatcher::DoCancel() |
|
131 { |
|
132 iProperty.Cancel(); |
|
133 } |
|
134 |
|
135 // End of File |