1 /* |
|
2 * Copyright (c) 2007-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: Implements CSCSettingsUiDialog methods |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <avkon.rsg> |
|
20 #include <stringloader.h> |
|
21 #include <aknglobalnote.h> |
|
22 #include <cscsettingsui.rsg> |
|
23 #include <aknglobalmsgquery.h> |
|
24 |
|
25 #include "cscsettingsuilogger.h" |
|
26 #include "cscsettingsuidialog.h" |
|
27 #include "mcscsettingsuidialogobserver.h" |
|
28 |
|
29 const TInt KMsgQueryTextMaxLength = 512; |
|
30 _LIT( KNextLine, "\n" ); |
|
31 _LIT( KInvalidConnectionAddress, "::1" ); |
|
32 |
|
33 // ======== MEMBER FUNCTIONS ======== |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CCSCSettingsUiDialog::CCSCSettingsUiDialog( |
|
39 MCSCSettingsUiDialogObserver& aObserver ) |
|
40 : CActive ( EPriorityHigh ), |
|
41 iObserver( aObserver ) |
|
42 { |
|
43 } |
|
44 |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 void CCSCSettingsUiDialog::ConstructL() |
|
50 { |
|
51 CSCSETUIDEBUG( "CCSCSettingsUiDialog::ConstructL - begin" ); |
|
52 |
|
53 CActiveScheduler::Add( this ); |
|
54 |
|
55 CSCSETUIDEBUG( "CCSCSettingsUiDialog::ConstructL - end" ); |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CCSCSettingsUiDialog* CCSCSettingsUiDialog::NewL( |
|
63 MCSCSettingsUiDialogObserver& aObserver ) |
|
64 { |
|
65 CCSCSettingsUiDialog* self = CCSCSettingsUiDialog::NewLC( aObserver ); |
|
66 CleanupStack::Pop( self ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CCSCSettingsUiDialog* CCSCSettingsUiDialog::NewLC( |
|
75 MCSCSettingsUiDialogObserver& aObserver ) |
|
76 { |
|
77 CCSCSettingsUiDialog* self = |
|
78 new ( ELeave ) CCSCSettingsUiDialog( aObserver ); |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL(); |
|
81 return self; |
|
82 } |
|
83 |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 CCSCSettingsUiDialog::~CCSCSettingsUiDialog() |
|
89 { |
|
90 Cancel(); |
|
91 delete iMsgQuery; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CCSCSettingsUiDialog::LaunchMessageQueryL |
|
96 // Launches a service information message query. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 void CCSCSettingsUiDialog::LaunchMessageQueryL( |
|
100 const TDesC& aUsername, |
|
101 const TDesC& aDomain, |
|
102 const TDesC& aAddress, |
|
103 const TDesC& aSsid, |
|
104 const TDesC& aMac, |
|
105 TBool aDisabled ) |
|
106 { |
|
107 CSCSETUIDEBUG( "CCSCSettingsUiDialog::LaunchMessageQueryL" ); |
|
108 |
|
109 if ( !IsActive() ) |
|
110 { |
|
111 // Create data to be shown in service information message query. |
|
112 HBufC* queryText = HBufC::NewLC( KMsgQueryTextMaxLength ); |
|
113 CreateTextForMsgQueryL( |
|
114 queryText, |
|
115 aUsername, |
|
116 aDomain, |
|
117 aAddress, |
|
118 aSsid, |
|
119 aMac, |
|
120 aDisabled ); |
|
121 |
|
122 // Create header text to be shown in information message query. |
|
123 HBufC* headerText = StringLoader::LoadLC( |
|
124 R_CSCSETTINGSUI_SERVICE_INFO_TEXT ); |
|
125 |
|
126 if ( iMsgQuery ) |
|
127 { |
|
128 delete iMsgQuery; |
|
129 iMsgQuery = NULL; |
|
130 } |
|
131 |
|
132 // Show message query with appropriate header and data. |
|
133 iMsgQuery = CAknGlobalMsgQuery::NewL(); |
|
134 iMsgQuery->ShowMsgQueryL( |
|
135 iStatus, |
|
136 *queryText, |
|
137 R_AVKON_SOFTKEYS_OK_EMPTY, |
|
138 *headerText, |
|
139 KNullDesC ); |
|
140 |
|
141 SetActive(); |
|
142 CleanupStack::PopAndDestroy( headerText ); |
|
143 CleanupStack::PopAndDestroy( queryText ); |
|
144 } |
|
145 } |
|
146 |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CCSCSettingsUiDialog::DestroyMessageQuery |
|
150 // Destroys a service information message query. |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CCSCSettingsUiDialog::DestroyMessageQuery() |
|
154 { |
|
155 Cancel(); |
|
156 } |
|
157 |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // From CActive |
|
161 // CCSCSettingsUiDialog::RunL |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void CCSCSettingsUiDialog::RunL() |
|
165 { |
|
166 } |
|
167 |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // From CActive |
|
171 // CCSCSettingsUiDialog::DoCancel |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CCSCSettingsUiDialog::DoCancel() |
|
175 { |
|
176 iMsgQuery->CancelMsgQuery(); |
|
177 } |
|
178 |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CCSCSettingsUiDialog::CreateTextForMsgQueryL |
|
182 // Creates text for service information message query. |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 void CCSCSettingsUiDialog::CreateTextForMsgQueryL( |
|
186 HBufC* aText, |
|
187 const TDesC& aUsername, |
|
188 const TDesC& aDomain, |
|
189 const TDesC& aAddress, |
|
190 const TDesC& aSsid, |
|
191 const TDesC& aMac, |
|
192 TBool aDisabled ) const |
|
193 { |
|
194 CSCSETUIDEBUG( "CCSCSettingsUiDialog::CreateTextForMsgQueryL - begin" ); |
|
195 |
|
196 if ( aText == NULL ) |
|
197 { |
|
198 User::Leave( KErrBadHandle ); |
|
199 } |
|
200 |
|
201 // Load resources to memory. |
|
202 HBufC* unavailable = StringLoader::LoadLC( |
|
203 R_CSCSETTINGSUI_SERV_INFO_VALUE_UNAVAILABLE ); |
|
204 HBufC* unavailbleWhenOffile = StringLoader::LoadLC( |
|
205 R_CSCSETTINGSUI_SERV_INFO_VALUE_UNAVAILABLE_WHEN_OFFLINE ); |
|
206 |
|
207 // Add username information to query text. |
|
208 HBufC* resource = StringLoader::LoadLC( |
|
209 R_CSCSETTINGSUI_SERVICE_INFO_USERNAME_TEXT ); |
|
210 CreateItemToMsgQuery( aText, resource, unavailbleWhenOffile, aUsername ); |
|
211 CleanupStack::PopAndDestroy( resource ); |
|
212 |
|
213 // Add domain information to query text. |
|
214 resource = StringLoader::LoadLC( |
|
215 R_CSCSETTINGSUI_SERVICE_INFO_DOMAIN_TEXT ); |
|
216 |
|
217 if ( aDisabled ) |
|
218 { |
|
219 CreateItemToMsgQuery( aText, resource, unavailable, KNullDesC ); |
|
220 } |
|
221 else |
|
222 { |
|
223 CreateItemToMsgQuery( aText, resource, unavailbleWhenOffile, aDomain ); |
|
224 } |
|
225 |
|
226 CleanupStack::PopAndDestroy( resource ); |
|
227 |
|
228 // Add connection address information to query text. |
|
229 resource = StringLoader::LoadLC( |
|
230 R_CSCSETTINGSUI_SERVICE_INFO_ADDRESS_TEXT ); |
|
231 if ( !aAddress.Compare( KInvalidConnectionAddress ) && !aDisabled ) |
|
232 { |
|
233 CreateItemToMsgQuery( |
|
234 aText, resource, unavailable, KNullDesC ); |
|
235 } |
|
236 else if ( !aDisabled ) |
|
237 { |
|
238 CreateItemToMsgQuery( |
|
239 aText, resource, unavailable, aAddress ); |
|
240 } |
|
241 else |
|
242 { |
|
243 CreateItemToMsgQuery( |
|
244 aText, resource, unavailable, KNullDesC ); |
|
245 } |
|
246 |
|
247 CleanupStack::PopAndDestroy( resource ); |
|
248 |
|
249 // Add WLAN SSID information to query text. |
|
250 resource = StringLoader::LoadLC( |
|
251 R_CSCSETTINGSUI_SERVICE_INFO_WLAN_SSID_TEXT ); |
|
252 |
|
253 if ( aDisabled ) |
|
254 { |
|
255 CreateItemToMsgQuery( aText, resource, unavailable, KNullDesC ); |
|
256 } |
|
257 else |
|
258 { |
|
259 CreateItemToMsgQuery( aText, resource, unavailable, aSsid ); |
|
260 } |
|
261 |
|
262 CleanupStack::PopAndDestroy( resource ); |
|
263 |
|
264 // Add WLAN MAC address information to query text. |
|
265 resource = StringLoader::LoadLC( |
|
266 R_CSCSETTINGSUI_SERVICE_INFO_WLAN_MAC_TEXT ); |
|
267 |
|
268 CreateItemToMsgQuery( aText, resource, unavailable, aMac ); |
|
269 |
|
270 CleanupStack::PopAndDestroy( resource ); |
|
271 |
|
272 // PopAndDestroy resources. |
|
273 CleanupStack::PopAndDestroy( unavailbleWhenOffile ); |
|
274 CleanupStack::PopAndDestroy( unavailable ); |
|
275 |
|
276 CSCSETUIDEBUG( "CCSCSettingsUiDialog::CreateTextForMsgQueryL - end" ); |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CCSCSettingsUiDialog::CreateItemToMsgQuery |
|
281 // Creates an item for service information message query. |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 void CCSCSettingsUiDialog::CreateItemToMsgQuery( |
|
285 HBufC* aText, |
|
286 HBufC* aItem, |
|
287 HBufC* aAdditionalValue, |
|
288 const TDesC& aData ) const |
|
289 { |
|
290 if ( aText && aItem ) |
|
291 { |
|
292 aText->Des().Append( *aItem ); |
|
293 aText->Des().Append( KNextLine ); |
|
294 if ( aData.Length() ) |
|
295 { |
|
296 aText->Des().Append( aData ); |
|
297 } |
|
298 else if ( aAdditionalValue ) |
|
299 { |
|
300 aText->Des().Append( *aAdditionalValue ); |
|
301 } |
|
302 else |
|
303 { |
|
304 // nothing to do |
|
305 } |
|
306 |
|
307 aText->Des().Append( KNextLine ); |
|
308 } |
|
309 } |
|