|
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 for P&S property watching. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "svppropertywatch.h" |
|
20 #include "svplogger.h" |
|
21 |
|
22 |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // CSVPPropertyWatch::CSVPPropertyWatch |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 CSVPPropertyWatch::CSVPPropertyWatch( MSVPPropertyWatchObserver& aClient, |
|
29 TInt aKey ) : CActive( EPriorityStandard ), iClient( aClient ), |
|
30 iKey( aKey ) |
|
31 { |
|
32 CActiveScheduler::Add( this ); |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CSVPPropertyWatch::ConstructL |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 void CSVPPropertyWatch::ConstructL( const TUid& aCategory ) |
|
40 { |
|
41 SVPDEBUG1("CSVPPropertyWatch::ConstructL - ATTACHING TO PROPERTY..."); |
|
42 User::LeaveIfError( iProperty.Attach( aCategory, iKey ) ); |
|
43 |
|
44 SVPDEBUG1("CSVPPropertyWatch::ConstructL - SUBSCRIBING TO PROPERTY..."); |
|
45 iProperty.Subscribe( iStatus ); |
|
46 |
|
47 SetActive(); |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CSVPPropertyWatch::NewL |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CSVPPropertyWatch* CSVPPropertyWatch::NewL( |
|
55 MSVPPropertyWatchObserver& aClient, |
|
56 const TUid& aCategory, TInt aKey ) |
|
57 { |
|
58 CSVPPropertyWatch* self = new( ELeave ) CSVPPropertyWatch( aClient, |
|
59 aKey ); |
|
60 |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL( aCategory ); |
|
63 CleanupStack::Pop( self ); |
|
64 |
|
65 return self; |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CSVPPropertyWatch::~CSVPPropertyWatch |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CSVPPropertyWatch::~CSVPPropertyWatch() |
|
73 { |
|
74 Cancel(); |
|
75 iProperty.Close(); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CSVPPropertyWatch::DoCancel |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 void CSVPPropertyWatch::DoCancel() |
|
83 { |
|
84 iProperty.Cancel(); |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CSVPPropertyWatch::RunL |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 void CSVPPropertyWatch::RunL() |
|
92 { |
|
93 if( KErrNone == iStatus.Int() ) |
|
94 { |
|
95 // Resubscribe before processing new value to prevent missing updates |
|
96 iProperty.Subscribe( iStatus ); |
|
97 SetActive(); |
|
98 |
|
99 // Property updated, get new value |
|
100 TInt newValue; |
|
101 if ( KErrNotFound == iProperty.Get( newValue ) ) |
|
102 { |
|
103 iClient.PropertyDeleted( iKey ); |
|
104 } |
|
105 else |
|
106 { |
|
107 iClient.ValueChangedL( iKey, newValue ); |
|
108 } |
|
109 } |
|
110 else |
|
111 { |
|
112 User::Leave( iStatus.Int() ); |
|
113 } |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CSVPPropertyWatch::RunError |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 TInt CSVPPropertyWatch::RunError( TInt /* aError */) |
|
121 { |
|
122 return KErrNone; |
|
123 } |
|
124 |