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 if(!IsActive()) |
|
67 { |
|
68 iProperty.Subscribe( iStatus ); |
|
69 SetActive(); |
|
70 } |
|
71 PRINT( _L( "Camera <= CCamPropertyWatcher::Subscribe()" ) ) |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CCamPropertyWatcher::Get |
|
76 // Return the current value |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 TInt CCamPropertyWatcher::Get( TInt& aValue ) |
|
80 { |
|
81 return iProperty.Get( aValue ); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CCamPropertyWatcher::CCamPropertyWatcher |
|
86 // Constructor |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 CCamPropertyWatcher::CCamPropertyWatcher( MPropertyObserver& aPropertyObserver, |
|
90 const TUid& aCategory, |
|
91 const TUint aKey ) : |
|
92 CActive( EPriorityStandard ), |
|
93 iPropertyObserver( aPropertyObserver ), |
|
94 iCategory( aCategory), |
|
95 iKey( aKey ) |
|
96 { |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CCamPropertyWatcher::ConstructL |
|
101 // Second phase construction |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CCamPropertyWatcher::ConstructL() |
|
105 { |
|
106 CActiveScheduler::Add( this ); |
|
107 User::LeaveIfError( iProperty.Attach( iCategory, iKey ) ); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CCamPropertyWatcher::RunL |
|
112 // Handle notification of value change |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CCamPropertyWatcher::RunL() |
|
116 { |
|
117 PRINT( _L( "Camera => CCamPropertyWatcher::RunL()" ) ) |
|
118 const TInt error ( iStatus.Int() ); |
|
119 PRINT1( _L( "Camera CCamPropertyWatcher::RunL() status = %d" ), error ) |
|
120 Subscribe(); |
|
121 if ( error == KErrNone ) |
|
122 { |
|
123 PRINT( _L( "Camera CCamPropertyWatcher::RunL() calling HandlePropertyChangedL" ) ) |
|
124 iPropertyObserver.HandlePropertyChangedL( iCategory, iKey ); |
|
125 } |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CCamPropertyWatcher::DoCancel |
|
130 // Handle cancellation |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CCamPropertyWatcher::DoCancel() |
|
134 { |
|
135 iProperty.Cancel(); |
|
136 } |
|
137 |
|
138 // End of File |
|