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 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "SystemInfoObserver.h" |
|
21 |
|
22 // ============================ MEMBER FUNCTIONS =============================== |
|
23 |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CSystemInfoObserver::CSystemInfoObserver |
|
27 // Two-phased constructor. |
|
28 // ----------------------------------------------------------------------------- |
|
29 CSystemInfoObserver* CSystemInfoObserver::NewL( MSystemInfoObserverClient* aClient, TInt aId ) |
|
30 { |
|
31 CSystemInfoObserver* self = new ( ELeave ) CSystemInfoObserver( aClient, aId ); |
|
32 CleanupStack::PushL( self ); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop( self ); |
|
35 return self; |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CSystemInfoObserver::CSystemInfoObserver |
|
40 // C++ default constructor can NOT contain any code, that |
|
41 // might leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 CSystemInfoObserver::CSystemInfoObserver( MSystemInfoObserverClient* aClient, TInt aId ) |
|
44 : CActive( EPriorityStandard ), |
|
45 iClient( aClient ), |
|
46 iId( aId ) |
|
47 { |
|
48 } |
|
49 |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CSystemInfoObserver::ConstructL |
|
53 // Symbian 2nd phase constructor can leave. |
|
54 // ----------------------------------------------------------------------------- |
|
55 void CSystemInfoObserver::ConstructL() |
|
56 { |
|
57 CActiveScheduler::Add( this ); |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CSystemInfoObserver::~CSystemInfoObserver() |
|
62 // Destructor |
|
63 // ----------------------------------------------------------------------------- |
|
64 CSystemInfoObserver::~CSystemInfoObserver() |
|
65 { |
|
66 Cancel(); |
|
67 if ( iClient ) |
|
68 { |
|
69 iClient->Close( iId ); |
|
70 } |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CSystemInfoObserver::RequestNotification |
|
75 // ----------------------------------------------------------------------------- |
|
76 void CSystemInfoObserver::RequestNotificationL() |
|
77 { |
|
78 if ( !IsActive() ) |
|
79 { |
|
80 iClient->SubscribeL( iId, iStatus ); |
|
81 SetActive(); |
|
82 } |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CSystemInfoObserver::RunL |
|
87 // ----------------------------------------------------------------------------- |
|
88 void CSystemInfoObserver::RunL() |
|
89 { |
|
90 if( iStatus == KErrNone ) |
|
91 { |
|
92 iClient->UpdateL( iId ); |
|
93 iClient->SubscribeL( iId, iStatus ); // FUTURE consider letting client decide if to do this |
|
94 SetActive(); |
|
95 } |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CSystemInfoObserver::RunError |
|
100 // ----------------------------------------------------------------------------- |
|
101 TInt CSystemInfoObserver::RunError( TInt /*aError*/ ) |
|
102 { |
|
103 return KErrNone; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CSystemInfoObserver::DoCancel |
|
108 // ----------------------------------------------------------------------------- |
|
109 void CSystemInfoObserver::DoCancel() |
|
110 { |
|
111 iClient->Cancel( iId ); |
|
112 } |
|
113 |
|
114 // End of File |
|