|
1 /* |
|
2 * Copyright (c) 2009 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: Stub imlementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <psmsettingsprovider.h> |
|
21 #include <psmsrvdomaincrkeys.h> |
|
22 #include <featmgr.h> |
|
23 #include <CoreApplicationUIsSDKCRKeys.h> // KCRUidCoreApplicationUIs, TCoreAppUIsNetworkConnectionAllowed |
|
24 #include "PSMNetworkPlugin.h" |
|
25 #include "GSNetworkPluginModel.h" |
|
26 #include "GsLogger.h" |
|
27 |
|
28 // CONSTANT DEFINITIONS |
|
29 const TUint32 KPSMNetworkPluginStorageId = 0x2000B593; |
|
30 |
|
31 enum TPSMNetworkPluginKeys |
|
32 { |
|
33 ENetworkMode = 1, |
|
34 }; |
|
35 |
|
36 // |
|
37 // ---------------------------------------------------------------------------------- |
|
38 // CPSMNetworkPlugin::CPSMNetworkPlugin() |
|
39 // ---------------------------------------------------------------------------------- |
|
40 // |
|
41 CPSMNetworkPlugin::CPSMNetworkPlugin( TPsmPluginCTorParams& aInitParams ) : |
|
42 CPsmPluginBase( aInitParams ) |
|
43 { |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CPSMNetworkPlugin::ConstructL() |
|
48 // Symbian 2nd phase constructor can leave. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CPSMNetworkPlugin::ConstructL() |
|
52 { |
|
53 __GSLOGSTRING( "[GS]-->[CPSMNetworkPlugin::ConstructL]" ); |
|
54 |
|
55 iModel = CGSNetworkPluginModel::NewL( NULL,NULL ); |
|
56 iPsmRepository = CRepository::NewL( KCRUidPowerSaveMode ); |
|
57 // Read from CenRep so iPsmMode gets correct init value |
|
58 TInt psmMode; |
|
59 iPsmRepository->Get( KPsmCurrentMode, psmMode ); |
|
60 iPsmMode = ( TPsmsrvMode )psmMode; |
|
61 |
|
62 __GSLOGSTRING( "[GS]<--[CPSMNetworkPlugin::ConstructL]" ); |
|
63 } |
|
64 |
|
65 // |
|
66 // ---------------------------------------------------------------------------------- |
|
67 // CPSMNetworkPlugin::NewL() |
|
68 // ---------------------------------------------------------------------------------- |
|
69 // |
|
70 // Two-phased constructor. |
|
71 CPSMNetworkPlugin* CPSMNetworkPlugin::NewL( TPsmPluginCTorParams& aInitParams ) |
|
72 { |
|
73 CPSMNetworkPlugin* self = new ( ELeave ) CPSMNetworkPlugin( aInitParams ); |
|
74 |
|
75 CleanupStack::PushL( self ); |
|
76 self->ConstructL(); |
|
77 CleanupStack::Pop( self ); |
|
78 |
|
79 return self; |
|
80 } |
|
81 |
|
82 // ---------------------------------------------------------------------------------- |
|
83 // CPSMNetworkPlugin::~CPSMNetworkPlugin() |
|
84 // ---------------------------------------------------------------------------------- |
|
85 // |
|
86 // Destructor. |
|
87 CPSMNetworkPlugin::~CPSMNetworkPlugin() |
|
88 { |
|
89 __GSLOGSTRING( "[CPSMNetworkPlugin::~CPSMNetworkPlugin]" ); |
|
90 delete iModel; |
|
91 iModel = NULL; |
|
92 delete iPsmRepository; |
|
93 iPsmRepository = NULL; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // CPSMNetworkPlugin::IsPhoneOfflineL |
|
98 // |
|
99 // Checks if phone is in offline mode or not. |
|
100 // Return ETrue if phone is in offline mode. |
|
101 // Return EFalse if phone is not in offline mode. |
|
102 // --------------------------------------------------------- |
|
103 // |
|
104 TBool CPSMNetworkPlugin::IsPhoneOfflineL() const |
|
105 { |
|
106 if ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) ) |
|
107 { |
|
108 CRepository* repository = CRepository::NewLC( KCRUidCoreApplicationUIs ); |
|
109 TInt connAllowed = 1; |
|
110 repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed ); |
|
111 CleanupStack::PopAndDestroy(); // repository |
|
112 if ( !connAllowed ) |
|
113 { |
|
114 return ETrue; |
|
115 } |
|
116 } |
|
117 return EFalse; |
|
118 } |
|
119 |
|
120 // ---------------------------------------------------------------------------------- |
|
121 // CPSMNetworkPlugin::NotifyModeChange() |
|
122 // ---------------------------------------------------------------------------------- |
|
123 // |
|
124 void CPSMNetworkPlugin::NotifyModeChange( const TInt aMode ) |
|
125 { |
|
126 TInt err = KErrNone; |
|
127 TRAP( err, DoModeChangeL( aMode ) ); |
|
128 if ( KErrNone != err) |
|
129 {} |
|
130 __GSLOGSTRING2( "[CPSMNetworkPlugin::NotifyModeChange]: Mode:%d Err:%d", aMode, err ); |
|
131 } |
|
132 |
|
133 |
|
134 // ---------------------------------------------------------------------------------- |
|
135 // CPSMNetworkPlugin::NotifyModeChange() |
|
136 // ---------------------------------------------------------------------------------- |
|
137 // |
|
138 void CPSMNetworkPlugin::DoModeChangeL( const TInt aMode ) |
|
139 { |
|
140 TPsmsrvMode newMode = ( TPsmsrvMode )aMode; |
|
141 if ( !IsPhoneOfflineL() && |
|
142 FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ) && |
|
143 iModel->IsNetworkModeVisible() && IsChangeNetworkMode ( iPsmMode, newMode ) ) |
|
144 { |
|
145 RConfigInfoArray infoArray; |
|
146 |
|
147 TPsmsrvConfigInfo info1; |
|
148 info1.iConfigId = ENetworkMode; |
|
149 info1.iConfigType = EConfigTypeInt; |
|
150 info1.iIntValue = iModel->GetNetworkMode(); |
|
151 infoArray.Append( info1 ); |
|
152 |
|
153 __GSLOGSTRING1( "[CPSMNetworkPlugin::NotifyModeChangeL] Switching to mode:%d", aMode ); |
|
154 |
|
155 __GSLOGSTRING1( "[CPSMNetworkPlugin::NotifyModeChangeL]: oldValue info1: %d", infoArray[0].iIntValue ); |
|
156 |
|
157 iSettingsProvider.BackupAndGetSettingsL( infoArray, KPSMNetworkPluginStorageId ); |
|
158 |
|
159 __GSLOGSTRING1( "[CPSMNetworkPlugin::NotifyModeChangeL]: newValue info1: %d", infoArray[0].iIntValue ); |
|
160 |
|
161 // Don't change the network mode if there is ongoing phone call |
|
162 // since this will disconnect it |
|
163 if ( !iModel->IsCallActive() ) |
|
164 { |
|
165 iModel->SetNetworkModeL ( infoArray[0].iIntValue ); |
|
166 } |
|
167 |
|
168 infoArray.Reset(); |
|
169 } |
|
170 } |
|
171 |
|
172 // ---------------------------------------------------------------------------------- |
|
173 // CPSMNetworkPlugin::IsChangeNetworkMode |
|
174 // ---------------------------------------------------------------------------------- |
|
175 // |
|
176 TBool CPSMNetworkPlugin::IsChangeNetworkMode( TPsmsrvMode& aOldMode, TPsmsrvMode aNewMode ) |
|
177 { |
|
178 TPsmsrvMode oldMode = aOldMode; |
|
179 aOldMode = aNewMode; |
|
180 if ( ( oldMode == EPsmsrvModeNormal && aNewMode == EPsmsrvPartialMode ) |
|
181 || ( oldMode == EPsmsrvModePowerSave && aNewMode |
|
182 == EPsmsrvPartialMode ) ) |
|
183 { |
|
184 return EFalse; |
|
185 } |
|
186 else |
|
187 { |
|
188 return ETrue; |
|
189 } |
|
190 } |
|
191 |
|
192 //End of File |
|
193 |
|
194 |