|
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: Power save mode client class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <psmclientobserver.h> |
|
20 #include "psmclientimpl.h" |
|
21 #include "psmsettingsimpl.h" |
|
22 #include "psmclientactive.h" |
|
23 #include "psmtrace.h" |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CPsmClientImpl::CPsmClientImpl |
|
27 // Two-phased constructor. |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CPsmClientImpl::CPsmClientImpl( MPsmClientObserver& aObserver ) : |
|
31 iObserver( aObserver ) |
|
32 { |
|
33 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::CPsmClientImpl()" ) ) ); |
|
34 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::CPsmClientImpl - return" ) ) ); |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CPsmClientImpl::ConstructL |
|
39 // Two-phased constructor. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 void CPsmClientImpl::ConstructL() |
|
43 { |
|
44 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::ConstructL()" ) ) ); |
|
45 |
|
46 // Connect to PSM server |
|
47 User::LeaveIfError( iPsmServer.Connect() ); |
|
48 |
|
49 // Create an instance of settings provider |
|
50 iSettings = new ( ELeave ) CPsmSettingsImpl( iPsmServer ); |
|
51 |
|
52 // Create active object |
|
53 iActive = new ( ELeave ) CPsmClientActive( iObserver ); |
|
54 |
|
55 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::ConstructL - return" ) ) ); |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CPsmClientImpl::~CPsmClientImpl |
|
60 // Destructor |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CPsmClientImpl::~CPsmClientImpl() |
|
64 { |
|
65 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::~CPsmClientImpl()" ) ) ); |
|
66 |
|
67 if ( iActive->IsActive() ) |
|
68 { |
|
69 CancelPowerSaveModeChange(); |
|
70 } |
|
71 |
|
72 if ( iActive ) |
|
73 { |
|
74 delete iActive; |
|
75 iActive = NULL; |
|
76 } |
|
77 |
|
78 if ( iSettings ) |
|
79 { |
|
80 delete iSettings; |
|
81 iSettings = NULL; |
|
82 } |
|
83 |
|
84 iPsmServer.Close(); |
|
85 |
|
86 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::~CPsmClientImpl - return" ) ) ); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CPsmClientImpl::ChangePowerSaveMode |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CPsmClientImpl::ChangePowerSaveMode( const TInt aPsmMode ) |
|
94 { |
|
95 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::ChangePowerSaveMode()" ) ) ); |
|
96 |
|
97 if ( iActive->IsActive() ) |
|
98 { |
|
99 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::ChangePowerSaveMode() - Already active!" ) ) ); |
|
100 iActive->Cancel(); |
|
101 } |
|
102 |
|
103 // Send asynchronous message and set this object to active |
|
104 iPsmServer.SendReceiveAsync( |
|
105 EPsmServerNotifyModeChange, |
|
106 TIpcArgs( aPsmMode ), |
|
107 iActive->RequestStatus() ); |
|
108 |
|
109 iActive->SetActive(); |
|
110 |
|
111 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::ChangePowerSaveMode - return" ) ) ); |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CPsmClientImpl::CancelPowerSaveModeChange |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CPsmClientImpl::CancelPowerSaveModeChange() |
|
119 { |
|
120 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::CancelPowerSaveModeChange()" ) ) ); |
|
121 |
|
122 if ( iActive->IsActive() ) |
|
123 { |
|
124 // Send cancel asynchronous message |
|
125 iPsmServer.SendReceiveSync( EPsmServerCancelModeChange, TIpcArgs() ); |
|
126 } |
|
127 |
|
128 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::CancelPowerSaveModeChange - return" ) ) ); |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CPsmClientImpl::RequestPowerSaveModeNotification |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CPsmClientImpl::RequestPowerSaveModeNotification() |
|
136 { |
|
137 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::RequestPowerSaveModeNotification()" ) ) ); |
|
138 |
|
139 if ( iActive->IsActive() ) |
|
140 { |
|
141 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::RequestPowerSaveModeNotification() - Already active!" ) ) ); |
|
142 iActive->Cancel(); |
|
143 } |
|
144 |
|
145 // Send asynchronous message and set this object to active |
|
146 iPsmServer.SendReceiveAsync( |
|
147 EPsmServerModeChangeNotificationRequest, |
|
148 TIpcArgs(), |
|
149 iActive->RequestStatus() ); |
|
150 |
|
151 iActive->SetActive(); |
|
152 |
|
153 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::RequestPowerSaveModeNotification - return" ) ) ); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CPsmClientImpl::CancelPowerSaveModeNotificationRequest |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CPsmClientImpl::CancelPowerSaveModeNotificationRequest() |
|
161 { |
|
162 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::CancelPowerSaveModeNotificationRequest()" ) ) ); |
|
163 |
|
164 if ( iActive->IsActive() ) |
|
165 { |
|
166 // Send cancel asynchronous message |
|
167 iPsmServer.SendReceiveSync( EPsmServerCancelModeChangeNotificationRequest, TIpcArgs() ); |
|
168 } |
|
169 |
|
170 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::CancelPowerSaveModeNotificationRequest - return" ) ) ); |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CPsmClientImpl::PsmSettings |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 CPsmSettings& CPsmClientImpl::PsmSettings() const |
|
178 { |
|
179 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::PsmSettings()" ) ) ); |
|
180 COMPONENT_TRACE( ( _L( "PSM Client - CPsmClientImpl::PsmSettings - return" ) ) ); |
|
181 return *iSettings; |
|
182 } |
|
183 |
|
184 // End of file |