|
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 the License "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: Class to handle subscriptions from PS* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 #include "videochpssubscriber.h" |
|
20 |
|
21 |
|
22 // ----------------------------------------------------------------------------- |
|
23 // CVcxNsCHPSSubscriber::CVcxConnUtilSubscriber() |
|
24 // ----------------------------------------------------------------------------- |
|
25 // |
|
26 CVcxNsCHPSSubscriber::CVcxNsCHPSSubscriber( const TUid aUid, |
|
27 const TUint32 aKey, |
|
28 RProperty::TType aType, |
|
29 MCHPSObserver* aObserver ) : |
|
30 CActive( EPriorityStandard ), |
|
31 iUid( aUid ), |
|
32 iKey( aKey ), |
|
33 iKeyType(aType), |
|
34 iObserver( aObserver ) |
|
35 { |
|
36 // NOP |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CVcxNsCHPSSubscriber::NewL() |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CVcxNsCHPSSubscriber* CVcxNsCHPSSubscriber::NewL( const TUid aUid, |
|
44 const TUint32 aKey, |
|
45 RProperty::TType aType, |
|
46 MCHPSObserver* aObserver ) |
|
47 { |
|
48 if( aType != RProperty::EInt ) |
|
49 { |
|
50 User::Leave( KErrNotSupported ); |
|
51 } |
|
52 CVcxNsCHPSSubscriber* self = |
|
53 new( ELeave ) CVcxNsCHPSSubscriber( aUid, aKey, aType, aObserver ); |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL(); |
|
56 CleanupStack::Pop( self ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CVcxNsCHPSSubscriber::ConstructL() |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void CVcxNsCHPSSubscriber::ConstructL() |
|
65 { |
|
66 iInitialized = EFalse; |
|
67 User::LeaveIfError( iProperty.Attach( iUid, iKey ) ); |
|
68 CActiveScheduler::Add( this ); |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CVcxNsCHPSSubscriber::~CVcxNsCHPSSubscriber() |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CVcxNsCHPSSubscriber::~CVcxNsCHPSSubscriber() |
|
76 { |
|
77 if( IsActive() ) |
|
78 { |
|
79 Cancel(); |
|
80 } |
|
81 iProperty.Close(); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CVcxNsCHPSSubscriber::Get() |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 TInt CVcxNsCHPSSubscriber::Get( TInt& aValue ) |
|
89 { |
|
90 return iProperty.Get( aValue ); |
|
91 } |
|
92 |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CVcxNsCHPSSubscriber::Start() |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CVcxNsCHPSSubscriber::Start() |
|
99 { |
|
100 if( !IsActive() ) |
|
101 { |
|
102 iProperty.Subscribe( iStatus ); |
|
103 SetActive(); |
|
104 iInitialized = ETrue; |
|
105 } |
|
106 } |
|
107 |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CVcxNsCHPSSubscriber::DoCancel() |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 void CVcxNsCHPSSubscriber::DoCancel() |
|
114 { |
|
115 if( IsActive() ) |
|
116 { |
|
117 iProperty.Cancel(); |
|
118 } |
|
119 |
|
120 iInitialized = EFalse; |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CVcxNsCHPSSubscriber::RunL() |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CVcxNsCHPSSubscriber::RunL() |
|
128 { |
|
129 // resubscribe before processing new |
|
130 // value to prevent missing updates |
|
131 iProperty.Subscribe( iStatus ); |
|
132 SetActive(); |
|
133 |
|
134 if( iInitialized ) |
|
135 { |
|
136 TInt intValue; |
|
137 |
|
138 if(iKeyType == RProperty::EInt ) |
|
139 { |
|
140 if( iProperty.Get( intValue ) == KErrNone && iObserver ) |
|
141 { |
|
142 iObserver->ValueChanged( iKey, intValue ); |
|
143 } |
|
144 } |
|
145 } |
|
146 iInitialized = ETrue; |
|
147 } |
|
148 // end of file |