|
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: class for holding common config |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <centralrepository.h> |
|
21 #include <CoreApplicationUIsSDKCRKeys.h> |
|
22 #include <ecom/ecom.h> |
|
23 |
|
24 #include "epos_comasupltrace.h" |
|
25 #include "epos_comasuplcommonconfig.h" |
|
26 #include "epos_omasuplconfigurationkeys.h" |
|
27 #include "epos_omasuplconstants.h" |
|
28 #include "epos_comasuplsettings.h" |
|
29 #include "lbs/epos_comasuplposhandlerbase.h" |
|
30 |
|
31 _LIT(KTraceFileName,"SUPL_OMA_PH::EPos_COMASUPLCommonConfig.cpp"); |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // ResetAndDestroy() |
|
35 // Resets & destroys array if leave occurs |
|
36 // ----------------------------------------------------------------------------- |
|
37 void ResetArray(TAny* aArray) |
|
38 { |
|
39 ((RImplInfoPtrArray*)aArray)->ResetAndDestroy(); |
|
40 } |
|
41 |
|
42 //Constructor |
|
43 COMASuplCommonConfig::COMASuplCommonConfig() |
|
44 { |
|
45 } |
|
46 |
|
47 //Destructor |
|
48 COMASuplCommonConfig::~COMASuplCommonConfig() |
|
49 { |
|
50 delete iSuplSettings; |
|
51 iSuplSettings=NULL; |
|
52 |
|
53 delete iPosHandler; |
|
54 iPosHandler=NULL; |
|
55 |
|
56 iIMSI.Close(); |
|
57 delete iTrace; |
|
58 iTrace = NULL; |
|
59 |
|
60 } |
|
61 // |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CSuplSession::NewL |
|
64 // Creates new instance of COMASuplSession |
|
65 // (other items were commented in a header). |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C COMASuplCommonConfig* COMASuplCommonConfig::NewL() |
|
69 { |
|
70 COMASuplCommonConfig* self = new( ELeave ) COMASuplCommonConfig(); |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL(); |
|
73 CleanupStack::Pop(self); |
|
74 return self; |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // COMASuplCommonConfig::ConstuctL() |
|
79 // 2nd phase construction |
|
80 // (other items were commented in a header). |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 |
|
84 void COMASuplCommonConfig::ConstructL() |
|
85 { |
|
86 |
|
87 iTrace = COMASuplTrace::NewL(); |
|
88 ReadOMASuplSettingsL(); |
|
89 LoadPosHandlerL(); |
|
90 ReadOMASuplConfigurationL(); |
|
91 |
|
92 } |
|
93 |
|
94 |
|
95 void COMASuplCommonConfig::ReadOMASuplConfigurationL() |
|
96 { |
|
97 CRepository* ConfigurationCenRepSession = CRepository::NewL(KCRUidOMASuplConfiguration); |
|
98 |
|
99 CleanupStack::PushL(ConfigurationCenRepSession); |
|
100 |
|
101 User::LeaveIfError(ConfigurationCenRepSession->Get(KOMASuplConfigurationUT1, iUT1_StartTimer)); |
|
102 User::LeaveIfError(ConfigurationCenRepSession->Get(KOMASuplConfigurationUT2, iUT2_PosInitTimer)); |
|
103 User::LeaveIfError(ConfigurationCenRepSession->Get(KOMASuplConfigurationUT3, iUT3_PosTimer)); |
|
104 User::LeaveIfError(ConfigurationCenRepSession->Get(KOMASuplConfigurationPrivacyTimer, iPrivacyTimer)); |
|
105 User::LeaveIfError(ConfigurationCenRepSession->Get(KOMASuplConfigurationSuplMode, iSETMode)); |
|
106 User::LeaveIfError(ConfigurationCenRepSession->Get(KOMASuplConfigurationPersistentFailureTimer, iPersistFailTimer)); |
|
107 |
|
108 TInt ret = ConfigurationCenRepSession->Get(KOMASuplConfigurationSuplPermissionQueryUsage, iSuplUsage); |
|
109 |
|
110 if (ret == KErrNone) |
|
111 { |
|
112 if (iSuplUsage <= 0) |
|
113 iSuplUsage = 0; |
|
114 else if (iSuplUsage >=2) |
|
115 iSuplUsage = 2; |
|
116 } |
|
117 else |
|
118 { |
|
119 iSuplUsage = 0; |
|
120 } |
|
121 User::LeaveIfError(ConfigurationCenRepSession->Get(KOMASuplNiDialogTimeOutValue, iSuplInitTimeOut)); |
|
122 |
|
123 CleanupStack::PopAndDestroy(ConfigurationCenRepSession); |
|
124 } |
|
125 |
|
126 EXPORT_C void COMASuplCommonConfig::ReadOMASuplSettingsL() |
|
127 { |
|
128 if( iSuplSettings ) |
|
129 { |
|
130 delete iSuplSettings; |
|
131 iSuplSettings=NULL; |
|
132 } |
|
133 iSuplSettings = COMASuplSettings::NewL(); |
|
134 } |
|
135 |
|
136 void COMASuplCommonConfig::LoadPosHandlerL() |
|
137 { |
|
138 RImplInfoPtrArray pluginArray; |
|
139 |
|
140 REComSession& EComServerSession = REComSession::OpenL(); |
|
141 |
|
142 CleanupStack::PushL(TCleanupItem(*ResetArray, &pluginArray)); |
|
143 REComSession::ListImplementationsL(KOMAPOSHandlerInterfaceUid, pluginArray); |
|
144 |
|
145 TBuf<32> buf; |
|
146 if(pluginArray.Count() > 0) |
|
147 { |
|
148 iTrace->Trace(_L("Plugins Found for POS..."), KTraceFileName, __LINE__); |
|
149 const CImplementationInformation* pluginInformation = pluginArray[0]; |
|
150 TUid pluginUid = pluginInformation->ImplementationUid(); |
|
151 TRAPD(err,iPosHandler = COMASuplPosHandlerBase::NewL(pluginUid)); |
|
152 |
|
153 buf.Copy(_L("Plugins loaded with error ...")); |
|
154 buf.AppendNum(err); |
|
155 iTrace->Trace(buf,KTraceFileName, __LINE__); |
|
156 |
|
157 } |
|
158 else |
|
159 { |
|
160 iPosHandler = NULL; |
|
161 iTrace->Trace(_L("No Plugins Found for POS..."), KTraceFileName, __LINE__); |
|
162 } |
|
163 |
|
164 CleanupStack::PopAndDestroy(1); |
|
165 EComServerSession.Close(); |
|
166 } |
|
167 |
|
168 // end of file |