|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 @prototype |
|
20 */ |
|
21 |
|
22 |
|
23 #include <metadatabase.h> |
|
24 #include <commsdattypeinfov1_1.h> |
|
25 #include <cdblen.h> |
|
26 #include <comms-infras/ss_tiermanagerutils.h> |
|
27 #include <comms-infras/ss_log.h> |
|
28 |
|
29 #include "agentqueryconnsettingsimpl.h" |
|
30 #include "agentmessages.h" |
|
31 #include "CAgentAdapter.h" |
|
32 |
|
33 #ifdef __CFLOG_ACTIVE |
|
34 #define KAgentCprTag KESockConnectionTag |
|
35 _LIT8(KAgentCprSubTag, "agentcpr"); |
|
36 #endif |
|
37 |
|
38 |
|
39 namespace ESock |
|
40 { |
|
41 // Not using it so for the time being just forward declare |
|
42 class MPlatsecApiExt; |
|
43 } |
|
44 |
|
45 |
|
46 using namespace ESock; |
|
47 |
|
48 |
|
49 CAgentQueryConnSettingsImpl::~CAgentQueryConnSettingsImpl() |
|
50 { |
|
51 } |
|
52 |
|
53 |
|
54 |
|
55 TInt CAgentQueryConnSettingsImpl::GetInt(CommsDat::TMDBElementId aElementId, TUint32& aValue, ESock::MPlatsecApiExt* /*aPlatsecApiExt*/) |
|
56 { |
|
57 __CFLOG_VAR((KAgentCprTag, KAgentCprSubTag, _L8("CAgentQueryConnSettingsImpl %08x:\tGetInt()"), this)); |
|
58 |
|
59 if (aElementId == (CommsDat::KCDTIdIAPRecord | CommsDat::KCDTIdRecordTag)) |
|
60 { |
|
61 aValue = iProvisionInfo.IapId(); |
|
62 return KErrNone; |
|
63 } |
|
64 else if (aElementId == CommsDat::KCDTIdMaxConnectionAttempts) |
|
65 { |
|
66 aValue = iProvisionInfo.ReconnectAttempts(); |
|
67 return KErrNone; |
|
68 } |
|
69 |
|
70 CCommsDatIapView* iapView = NULL; |
|
71 TInt err; |
|
72 TRAP(err, iapView = CCommsDatIapView::NewL(iProvisionInfo.IapId())); |
|
73 CleanupStack::PushL(iapView); |
|
74 if (err != KErrNone) |
|
75 { |
|
76 CleanupStack::PopAndDestroy(iapView); |
|
77 return err; |
|
78 } |
|
79 err = iapView->GetInt(aElementId, aValue); |
|
80 CleanupStack::PopAndDestroy(iapView); |
|
81 return err; |
|
82 } |
|
83 |
|
84 |
|
85 TInt CAgentQueryConnSettingsImpl::GetInt(CommsDat::TMDBElementId aElementId, TInt& aValue, ESock::MPlatsecApiExt* /*aPlatsecApiExt*/) |
|
86 { |
|
87 __CFLOG_VAR((KAgentCprTag, KAgentCprSubTag, _L8("CAgentQueryConnSettingsImpl %08x:\tGetInt()"), this)); |
|
88 |
|
89 if (aElementId == (CommsDat::KCDTIdIAPRecord | CommsDat::KCDTIdRecordTag)) |
|
90 { |
|
91 aValue = iProvisionInfo.IapId(); |
|
92 return KErrNone; |
|
93 } |
|
94 else if (aElementId == CommsDat::KCDTIdMaxConnectionAttempts) |
|
95 { |
|
96 aValue = iProvisionInfo.ReconnectAttempts(); |
|
97 return KErrNone; |
|
98 } |
|
99 |
|
100 CCommsDatIapView* iapView = NULL; |
|
101 TInt err; |
|
102 TRAP(err, iapView = CCommsDatIapView::NewL(iProvisionInfo.IapId())); |
|
103 CleanupStack::PushL(iapView); |
|
104 if (err != KErrNone) |
|
105 { |
|
106 CleanupStack::PopAndDestroy(iapView); |
|
107 return err; |
|
108 } |
|
109 err = iapView->GetInt(aElementId, aValue); |
|
110 CleanupStack::PopAndDestroy(iapView); |
|
111 return err; |
|
112 } |
|
113 |
|
114 |
|
115 TInt CAgentQueryConnSettingsImpl::GetBool(CommsDat::TMDBElementId aElementId, TBool& aValue, ESock::MPlatsecApiExt* /*aPlatsecApiExt*/) |
|
116 { |
|
117 __CFLOG_VAR((KAgentCprTag, KAgentCprSubTag, _L8("CAgentQueryConnSettingsImpl %08x:\tGetBool()"), this)); |
|
118 |
|
119 //[399TODO] RZ: This is a hack that needs fixing. No way we hardcode element ids here. |
|
120 if (aElementId == (CommsDat::KCDTIdIAPRecord | CommsDat::KCDTIdRecordTag)) |
|
121 { |
|
122 return KErrArgument; |
|
123 } |
|
124 |
|
125 CCommsDatIapView* iapView = NULL; |
|
126 TInt err; |
|
127 TRAP(err, iapView = CCommsDatIapView::NewL(iProvisionInfo.IapId())); |
|
128 CleanupStack::PushL(iapView); |
|
129 if (err != KErrNone) |
|
130 { |
|
131 CleanupStack::PopAndDestroy(iapView); |
|
132 return err; |
|
133 } |
|
134 err = iapView->GetBool(aElementId, aValue); |
|
135 CleanupStack::PopAndDestroy(iapView); |
|
136 return err; |
|
137 } |
|
138 |
|
139 |
|
140 TInt CAgentQueryConnSettingsImpl::GetText(CommsDat::TMDBElementId aElementId, HBufC8*& aValue, ESock::MPlatsecApiExt* /*aPlatsecApiExt*/) |
|
141 { |
|
142 __CFLOG_VAR((KAgentCprTag, KAgentCprSubTag, _L8("CAgentQueryConnSettingsImpl %08x:\tGetText()"), this)); |
|
143 |
|
144 //[399TODO] RZ: This is a hack that needs fixing. No way we hardcode element ids here. |
|
145 if (aElementId == (CommsDat::KCDTIdIAPRecord | CommsDat::KCDTIdRecordTag)) |
|
146 { |
|
147 return KErrArgument; |
|
148 } |
|
149 |
|
150 CCommsDatIapView* iapView = NULL; |
|
151 TInt err; |
|
152 TRAP(err, iapView = CCommsDatIapView::NewL(iProvisionInfo.IapId())); |
|
153 CleanupStack::PushL(iapView); |
|
154 if (err != KErrNone) |
|
155 { |
|
156 CleanupStack::PopAndDestroy(iapView); |
|
157 return err; |
|
158 } |
|
159 err = iapView->GetText(aElementId, aValue); |
|
160 CleanupStack::PopAndDestroy(iapView); |
|
161 return err; |
|
162 } |
|
163 |
|
164 |
|
165 TInt CAgentQueryConnSettingsImpl::GetText(CommsDat::TMDBElementId aElementId, HBufC16*& aValue, ESock::MPlatsecApiExt* /*aPlatsecApiExt*/) |
|
166 { |
|
167 __CFLOG_VAR((KAgentCprTag, KAgentCprSubTag, _L8("CAgentQueryConnSettingsImpl %08x:\tGetText()"), this)); |
|
168 |
|
169 //[399TODO] RZ: This is a hack that needs fixing. No way we hardcode element ids here. |
|
170 if (aElementId == (CommsDat::KCDTIdIAPRecord | CommsDat::KCDTIdRecordTag)) |
|
171 { |
|
172 return KErrArgument; |
|
173 } |
|
174 |
|
175 TInt err; |
|
176 switch (aElementId) |
|
177 { |
|
178 // Fields of type EText to send to the agent |
|
179 case CommsDat::KCDTIdPortName: |
|
180 { |
|
181 RBuf16 buffer; |
|
182 err = buffer.Create(KCommsDbSvrMaxFieldLength); |
|
183 if (err != KErrNone) |
|
184 { |
|
185 return err; |
|
186 } |
|
187 |
|
188 err = iProvisionInfo.AgentAdapter()->ReadPortName(buffer); |
|
189 if (err == KErrNone) |
|
190 { |
|
191 err = AnswerTextQuery(buffer, aValue); |
|
192 } |
|
193 buffer.Close(); |
|
194 return err; |
|
195 } |
|
196 |
|
197 // Fields of type EText to be obtained from the provision info |
|
198 case CommsDat::KCDTIdBearerAgent: |
|
199 { |
|
200 err = AnswerTextQuery(iProvisionInfo.AgentName(), aValue); |
|
201 return err; |
|
202 } |
|
203 } |
|
204 |
|
205 CCommsDatIapView* iapView = NULL; |
|
206 TRAP(err, iapView = CCommsDatIapView::NewL(iProvisionInfo.IapId())); |
|
207 CleanupStack::PushL(iapView); |
|
208 if (err != KErrNone) |
|
209 { |
|
210 CleanupStack::PopAndDestroy(iapView); |
|
211 return err; |
|
212 } |
|
213 err = iapView->GetText(aElementId, aValue); |
|
214 CleanupStack::PopAndDestroy(iapView); |
|
215 return err; |
|
216 } |
|
217 |
|
218 |
|
219 TInt CAgentQueryConnSettingsImpl::AnswerTextQuery(const TDesC8& aSourceValue, HBufC8*& aValue) |
|
220 { |
|
221 aValue = HBufC8::NewMax(aSourceValue.Length()); |
|
222 if (aValue != NULL) |
|
223 { |
|
224 *aValue = aSourceValue; |
|
225 return KErrNone; |
|
226 } |
|
227 return KErrNoMemory; |
|
228 } |
|
229 |
|
230 TInt CAgentQueryConnSettingsImpl::AnswerTextQuery(const TDesC16& aSourceValue, HBufC16*& aValue) |
|
231 { |
|
232 aValue = HBufC16::NewMax(aSourceValue.Length()); |
|
233 if (aValue != NULL) |
|
234 { |
|
235 *aValue = aSourceValue; |
|
236 return KErrNone; |
|
237 } |
|
238 return KErrNoMemory; |
|
239 } |
|
240 |
|
241 |
|
242 |
|
243 |