|
1 /* |
|
2 * Copyright (c) 2004 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: CNcnSubscriber implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include <e32svr.h> |
|
22 #include "NcnSubscriber.h" |
|
23 #include "NcnDebug.h" |
|
24 #include "NcnSubscribeHandler.h" |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 // ============================= MEMBER FUNCTIONS ============================= |
|
29 |
|
30 // ---------------------------------------------------------------------------- |
|
31 // CSysApSubscriber::NewL() |
|
32 // ---------------------------------------------------------------------------- |
|
33 CNcnSubscriber* CNcnSubscriber::NewL( MNcnSubscribeHandler& aPropertyResponder, const TUid& aCategory, TUint aKey ) |
|
34 { |
|
35 CNcnSubscriber* self = new (ELeave) CNcnSubscriber( aPropertyResponder, aCategory, aKey ); |
|
36 CleanupStack::PushL( self ); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop(); //self |
|
39 return self; |
|
40 } |
|
41 |
|
42 // ---------------------------------------------------------------------------- |
|
43 // CNcnSubscriber::ConstructL() |
|
44 // ---------------------------------------------------------------------------- |
|
45 void CNcnSubscriber::ConstructL() |
|
46 { |
|
47 CActiveScheduler::Add( this ); |
|
48 iProperty.Attach( iCategory, iKey ); |
|
49 } |
|
50 |
|
51 // ---------------------------------------------------------------------------- |
|
52 // CNcnSubscriber::Subscribe() |
|
53 // ---------------------------------------------------------------------------- |
|
54 void CNcnSubscriber::Subscribe() |
|
55 { |
|
56 iProperty.Cancel(); |
|
57 iProperty.Subscribe( iStatus ); |
|
58 SetActive(); |
|
59 } |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // CNcnSubscriber::CNcnSubscriber() |
|
63 // ---------------------------------------------------------------------------- |
|
64 CNcnSubscriber::CNcnSubscriber( MNcnSubscribeHandler& aPropertyResponder, const TUid& aCategory, TUint aKey ) : |
|
65 CActive( EPriorityStandard ), |
|
66 iPropertyResponder( aPropertyResponder ), |
|
67 iCategory( aCategory), |
|
68 iKey( aKey ) |
|
69 { |
|
70 } |
|
71 |
|
72 // ---------------------------------------------------------------------------- |
|
73 // CNcnSubscriber::RunL() |
|
74 // ---------------------------------------------------------------------------- |
|
75 void CNcnSubscriber::RunL() |
|
76 { |
|
77 Subscribe(); |
|
78 iPropertyResponder.HandlePropertyChangedL( iCategory, iKey ); |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // CNcnSubscriber::DoCancel() |
|
83 // ---------------------------------------------------------------------------- |
|
84 void CNcnSubscriber::DoCancel() |
|
85 { |
|
86 iProperty.Cancel(); |
|
87 } |
|
88 |
|
89 // ---------------------------------------------------------------------------- |
|
90 // CNcnSubscriber::RunError() |
|
91 // ---------------------------------------------------------------------------- |
|
92 TInt CNcnSubscriber::RunError( TInt aError ) |
|
93 { |
|
94 NCN_RDEBUG_INT(_L("CNcnSubscriber::RunError: error: %d"), aError ); |
|
95 return aError; |
|
96 } |
|
97 |
|
98 // ---------------------------------------------------------------------------- |
|
99 // CNcnSubscriber::~CNcnSubscriber() |
|
100 // ---------------------------------------------------------------------------- |
|
101 CNcnSubscriber::~CNcnSubscriber() |
|
102 { |
|
103 Cancel(); |
|
104 iProperty.Close(); |
|
105 } |
|
106 |
|
107 // End of File |
|
108 |
|
109 |
|
110 |