|
1 /* |
|
2 * Copyright (c) 2005 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: Model SIPSettings plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <escapeutils.h> |
|
24 #include <StringLoader.h> |
|
25 #include <gssipsettingspluginrsc.rsg> //GUI Resource |
|
26 #include "sipsettingsmodel.h" |
|
27 #include "gssipmodel.h" |
|
28 #include "mgssipprofilehandler.h" |
|
29 #include "gssippluginlogger.h" |
|
30 #include "gssippluginlogger.h" |
|
31 |
|
32 // CONSTANTS |
|
33 const TInt KSIPGranularity = 5; |
|
34 _LIT( KSIPLockedIcon, "0\t" ); |
|
35 _LIT( KSIPEmptyIcon, "1\t" ); |
|
36 _LIT( KTab, "\t" ); |
|
37 |
|
38 // ============================ MEMBER FUNCTIONS =============================== |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CSIPSettingsModel::NewL |
|
42 // Two-phased constructor. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CSIPSettingsModel* CSIPSettingsModel::NewL( MGSSIPProfileHandler* aHandler ) |
|
46 { |
|
47 __GSLOGSTRING("CSIPSettingsModel::NewL" ) |
|
48 CSIPSettingsModel* self = |
|
49 new ( ELeave ) CSIPSettingsModel( aHandler ); |
|
50 |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop( self ); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CSIPSettingsModel::CSIPSettingsModel |
|
60 // C++ default constructor can NOT contain any code, that |
|
61 // might leave. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CSIPSettingsModel::CSIPSettingsModel( MGSSIPProfileHandler* aHandler ) |
|
65 : iHandler( aHandler ) |
|
66 { |
|
67 __GSLOGSTRING( "[GSSIPSettingsPlugin] CSIPSettingsModel::CSIPSettingsModel()" ) |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CSIPSettingsModel::ConstructL |
|
72 // Symbian 2nd phase constructor can leave. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CSIPSettingsModel::ConstructL() |
|
76 { |
|
77 __GSLOGSTRING("CSIPSettingsModel::ConstructL" ) |
|
78 iRegisteredTxt = StringLoader::LoadL( R_QTN_PROFILE_LIST_PROFILE_REG ); |
|
79 iNotRegisteredTxt = StringLoader::LoadL( |
|
80 R_QTN_PROFILE_LIST_PROFILE_NOT_REG ); |
|
81 iErrorInReg = StringLoader::LoadL( R_QTN_PROFILE_LIST_PROFILE_REG_FAILED ); |
|
82 } |
|
83 |
|
84 // Destructor |
|
85 CSIPSettingsModel::~CSIPSettingsModel() |
|
86 { |
|
87 __GSLOGSTRING( "[GSSIPSettingsPlugin] CSIPSettingsModel::~CSIPSettingsModel()" ) |
|
88 delete iRegisteredTxt; |
|
89 delete iNotRegisteredTxt; |
|
90 delete iErrorInReg; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CSIPSettingsModel::DefaultProfileIndex |
|
95 // Returns the default profile index |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 TInt CSIPSettingsModel::DefaultProfileIndex() |
|
99 { |
|
100 TInt index = iHandler->DefaultProfileIndex(); |
|
101 __GSLOGSTRING1("CSIPSettingsModel::DefaultProfileIndex index: %d", index) |
|
102 return index; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CSIPSettingsModel::SetDefaultProfileL |
|
107 // Sets the new default profile |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CSIPSettingsModel::SetDefaultProfileL( |
|
111 TInt aIndex ) |
|
112 { |
|
113 __GSLOGSTRING1("CSIPSettingsModel::SetDefaultProfileL index: %d", aIndex) |
|
114 iHandler->SetDefaultProfileL( aIndex ); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CSIPSettingsModel::ListOfProfileNamesL |
|
119 // Returns the list of profile names |
|
120 // ----------------------------------------------------------------------------- |
|
121 CDesCArray* CSIPSettingsModel::ListOfProfileNamesL() |
|
122 { |
|
123 __GSLOGSTRING("CSIPSettingsModel::ListOfProfileNamesL " ) |
|
124 CArrayPtr<CSIPManagedProfile>* list = iHandler->ProfileArray(); |
|
125 |
|
126 CDesCArray* array = new ( ELeave ) CDesCArrayFlat( KSIPGranularity ); |
|
127 CleanupStack::PushL( array ); |
|
128 TInt err(KErrNone); |
|
129 |
|
130 for ( TInt i = 0; i < list->Count(); i++ ) |
|
131 { |
|
132 const TDesC8* providerName = 0; |
|
133 err = list->At(i)->GetParameter( KSIPProviderName, providerName ); |
|
134 User::LeaveIfError( err ); |
|
135 |
|
136 HBufC8* decodedProvider = |
|
137 EscapeUtils::EscapeDecodeL( *providerName ); |
|
138 CleanupStack::PushL( decodedProvider ); |
|
139 |
|
140 HBufC* providerName16 = |
|
141 EscapeUtils::ConvertToUnicodeFromUtf8L( decodedProvider->Des() ); |
|
142 CleanupStack::PushL( providerName16 ); |
|
143 |
|
144 array->AppendL( providerName16->Des() ); |
|
145 |
|
146 CleanupStack::PopAndDestroy( providerName16 ); |
|
147 CleanupStack::PopAndDestroy( decodedProvider ); |
|
148 } |
|
149 |
|
150 CleanupStack::Pop( array ); |
|
151 return array; |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CSIPSettingsModel::ProfileNameLC |
|
156 // Returns the name of the queried profile |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 HBufC* CSIPSettingsModel::ProfileNameLC( TInt aIndex ) |
|
160 { |
|
161 __GSLOGSTRING("CSIPSettingsModel::ProfileNameLC" ) |
|
162 const TDesC8* providerName = 0; |
|
163 TInt err = iHandler->ProfileArray()->At( aIndex )-> |
|
164 GetParameter( KSIPProviderName, providerName ); |
|
165 User::LeaveIfError( err ); |
|
166 |
|
167 HBufC8* decodedProvider = |
|
168 EscapeUtils::EscapeDecodeL( *providerName ); |
|
169 CleanupStack::PushL( decodedProvider ); |
|
170 HBufC* buf = EscapeUtils::ConvertToUnicodeFromUtf8L( *providerName ); |
|
171 CleanupStack::PopAndDestroy( decodedProvider ); |
|
172 CleanupStack::PushL( buf ); |
|
173 return buf; |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CSIPSettingsModel::NumOfProfiles |
|
178 // Returns the number of the profiles |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 TInt CSIPSettingsModel::NumOfProfiles() |
|
182 { |
|
183 return MdcaCount(); |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CSIPSettingsModel::MdcaCount |
|
188 // Returns the number of list items |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TInt CSIPSettingsModel::MdcaCount() const |
|
192 { |
|
193 return iHandler->ProfileArray()->Count(); |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CSIPSettingsModel::MdcaPoint |
|
198 // Returns the list item pointed by an index |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 TPtrC16 CSIPSettingsModel::MdcaPoint( |
|
202 TInt aIndex ) const |
|
203 { |
|
204 __GSLOGSTRING("CSIPSettingsModel::MdcaPoint" ) |
|
205 iBuf.Zero(); |
|
206 |
|
207 // Get profile locked information. |
|
208 TBool locked( EFalse ); |
|
209 TInt err = iHandler->ProfileArray()->At( aIndex )-> |
|
210 GetParameter( KSIPProfileLocked, locked ); |
|
211 |
|
212 // Set icon index information for secure icon. |
|
213 if ( err == KErrNone && locked ) |
|
214 { |
|
215 iBuf.Append( KSIPLockedIcon ); |
|
216 } |
|
217 else |
|
218 { |
|
219 iBuf.Append( KSIPEmptyIcon ); |
|
220 } |
|
221 |
|
222 const TDesC8* providerName = 0; |
|
223 err = iHandler->ProfileArray()->At( aIndex )-> |
|
224 GetParameter( KSIPProviderName, providerName ); |
|
225 |
|
226 HBufC8* decodedProvider = NULL; |
|
227 TRAP( err, |
|
228 decodedProvider = EscapeUtils::EscapeDecodeL( *providerName ) ); |
|
229 |
|
230 if ( err == KErrNone ) |
|
231 { |
|
232 HBufC* name = NULL; |
|
233 TRAP( err, name = |
|
234 EscapeUtils::ConvertToUnicodeFromUtf8L( *decodedProvider ) ) |
|
235 |
|
236 if ( err == KErrNone && name ) |
|
237 { |
|
238 iBuf.Append( *name ); |
|
239 delete name; |
|
240 name = NULL; |
|
241 } |
|
242 } |
|
243 delete decodedProvider; |
|
244 |
|
245 iBuf.Append( KTab ); |
|
246 |
|
247 TBool bStatus( EFalse ); |
|
248 err = iHandler->ProfileArray()->At( aIndex )-> |
|
249 GetParameter(KSIPProfileRegistered, bStatus); |
|
250 |
|
251 if( err || iHandler->ErrorInRegistration( aIndex ) ) |
|
252 { |
|
253 iBuf.Append( iErrorInReg->Des() ); |
|
254 } |
|
255 else |
|
256 { |
|
257 if( bStatus ) |
|
258 { |
|
259 iBuf.Append( iRegisteredTxt->Des() ); |
|
260 } |
|
261 else |
|
262 { |
|
263 iBuf.Append( iNotRegisteredTxt->Des() ); |
|
264 } |
|
265 } |
|
266 |
|
267 return iBuf; |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CSIPSettingsModel::CreateNewProfileL |
|
272 // Creates new profile and prepares it for editing |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 void CSIPSettingsModel::CreateNewProfileL( |
|
276 TInt aIndex ) |
|
277 { |
|
278 __GSLOGSTRING("CSIPSettingsModel::CreateNewProfileL" ) |
|
279 iHandler->CreateAndEditProfileL( aIndex ); |
|
280 } |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // CSIPSettingsModel::EditProfileL |
|
284 // Prepares the selected profile for editing |
|
285 // ----------------------------------------------------------------------------- |
|
286 // |
|
287 TBool CSIPSettingsModel::EditProfileL( TInt aIndex ) |
|
288 { |
|
289 __GSLOGSTRING("CSIPSettingsModel::EditProfileL" ) |
|
290 return iHandler->EditProfileL( aIndex ); |
|
291 } |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // CSIPSettingsModel::DeleteProfileL |
|
295 // Deletes profile |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void CSIPSettingsModel::DeleteProfileL( TInt aIndex ) |
|
299 { |
|
300 __GSLOGSTRING("CSIPSettingsModel::DeleteProfileL" ) |
|
301 iHandler->DeleteProfileL( aIndex ); |
|
302 } |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
|
305 // CSIPSettingsModel::CheckProfileForDeleteLC |
|
306 // Checks if profile can be deleted. |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 void CSIPSettingsModel::CheckProfileForDeleteL( |
|
310 TInt aIndex, TBool& aIsUse, TBool& aDefault, TBool& aLocked ) |
|
311 { |
|
312 (static_cast<CGSSIPModel*>( iHandler ) )-> |
|
313 CheckProfileForDeleteL( aIndex, aIsUse, aDefault, aLocked ); |
|
314 } |
|
315 // End of File |