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: Notier part for WLAN Power Save Testing notification dialog |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "wlanpowersavetestnotif.h" |
|
22 #include "wlanpowersavetest.h" |
|
23 #include "ConnectionUiUtilitiesCommon.h" |
|
24 #include "ConnUiUtilsNotif.h" |
|
25 #include "ConnectionDialogsLogger.h" |
|
26 |
|
27 #include <connuiutilsnotif.rsg> |
|
28 #include <StringLoader.h> |
|
29 |
|
30 #include <ConnectionUiUtilities.h> |
|
31 |
|
32 |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================= |
|
35 |
|
36 // --------------------------------------------------------- |
|
37 // CWlanPowerSaveQueryNotif::CWlanPowerSaveQueryNotif() |
|
38 // --------------------------------------------------------- |
|
39 // |
|
40 CWlanPowerSaveQueryNotif::CWlanPowerSaveQueryNotif() |
|
41 : |
|
42 iDialog( NULL ), |
|
43 iDisable( EFalse ), |
|
44 iExitAsync( NULL ) |
|
45 { |
|
46 } |
|
47 |
|
48 |
|
49 // --------------------------------------------------------- |
|
50 // CWlanPowerSaveQueryNotif* CWlanPowerSaveQueryNotif::NewL() |
|
51 // --------------------------------------------------------- |
|
52 // |
|
53 CWlanPowerSaveQueryNotif* CWlanPowerSaveQueryNotif::NewL( |
|
54 const TBool aResourceFileResponsible ) |
|
55 { |
|
56 CWlanPowerSaveQueryNotif* self = new ( ELeave ) CWlanPowerSaveQueryNotif(); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL( KResourceFileName, aResourceFileResponsible ); |
|
59 CleanupStack::Pop(); |
|
60 |
|
61 return self; |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------- |
|
65 // CWlanPowerSaveQueryNotif::~CWlanPowerSaveQueryNotif() |
|
66 // --------------------------------------------------------- |
|
67 // |
|
68 CWlanPowerSaveQueryNotif::~CWlanPowerSaveQueryNotif() |
|
69 { |
|
70 if ( iExitAsync ) |
|
71 { |
|
72 delete iExitAsync; |
|
73 iExitAsync = NULL; |
|
74 } |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------- |
|
78 // CWlanPowerSaveQueryNotif::RegisterL() |
|
79 // --------------------------------------------------------- |
|
80 // |
|
81 CWlanPowerSaveQueryNotif::TNotifierInfo CWlanPowerSaveQueryNotif::RegisterL() |
|
82 { |
|
83 iInfo.iUid = KUidWlanPowerSaveTestNote; |
|
84 iInfo.iPriority = ENotifierPriorityHigh; |
|
85 iInfo.iChannel = KUidWlanPowerSaveTestNote; |
|
86 |
|
87 return iInfo; |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------- |
|
91 // void CWlanPowerSaveQueryNotif::StartL |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 void CWlanPowerSaveQueryNotif::StartL( const TDesC8& /*aBuffer*/, |
|
95 TInt aReplySlot, |
|
96 const RMessagePtr2& aMessage ) |
|
97 { |
|
98 if ( iDialog ) |
|
99 { |
|
100 // Dialog is already on the display |
|
101 aMessage.Complete( KErrServerBusy ); |
|
102 return; |
|
103 } |
|
104 |
|
105 iReplySlot = aReplySlot; |
|
106 iMessage = aMessage; |
|
107 iCancelled = EFalse; |
|
108 |
|
109 iDialog = new ( ELeave ) CWlanPowerSaveQuery( this ); |
|
110 iDialog->PrepareLC( R_POWERSAVE_QUERY ); |
|
111 |
|
112 HBufC* heading = NULL; |
|
113 HBufC* message = NULL; |
|
114 TInt resourceId = 0; |
|
115 |
|
116 resourceId = R_QTN_WLAN_POWER_SAVE_TEST_DLG_TEXT; |
|
117 heading = StringLoader::LoadLC( |
|
118 R_QTN_WLAN_POWER_SAVE_TEST_DLG_TITLE ); |
|
119 |
|
120 CDesCArrayFlat* strings = new( ELeave ) CDesCArrayFlat( 2 ); |
|
121 CleanupStack::PushL( strings ); |
|
122 |
|
123 HBufC* messageBase = StringLoader::LoadL( resourceId, *strings ); |
|
124 |
|
125 CleanupStack::PopAndDestroy( strings ); |
|
126 |
|
127 CleanupStack::PushL( messageBase ); |
|
128 |
|
129 _LIT( KLinkStartTag, "\n<AknMessageQuery Link>" ); |
|
130 _LIT( KLinkEndTag, "</AknMessageQuery Link>" ); |
|
131 |
|
132 HBufC* linkString1 = StringLoader::LoadLC( |
|
133 R_QTN_WLAN_POWER_SAVE_TEST_DLG_LINK ); |
|
134 |
|
135 TInt lenMsg = messageBase->Des().Length()+ |
|
136 linkString1->Des().Length()+ |
|
137 KLinkStartTag().Length()+ |
|
138 KLinkEndTag().Length(); |
|
139 |
|
140 |
|
141 message = HBufC::NewL( lenMsg ); |
|
142 TPtr messagePtr = message->Des(); |
|
143 |
|
144 messagePtr.Append( messageBase->Des() ); |
|
145 |
|
146 messagePtr.Append( KLinkStartTag ); |
|
147 messagePtr.Append( linkString1->Des() ); |
|
148 messagePtr.Append( KLinkEndTag ); |
|
149 |
|
150 CleanupStack::PopAndDestroy( linkString1 ); |
|
151 CleanupStack::PopAndDestroy( messageBase ); |
|
152 |
|
153 CleanupStack::PushL( message ); |
|
154 |
|
155 iDialog->SetMessageTextL( *message ); |
|
156 CleanupStack::PopAndDestroy( message ); |
|
157 |
|
158 iDialog->QueryHeading()->SetTextL( *heading ); |
|
159 CleanupStack::PopAndDestroy( heading ); |
|
160 |
|
161 // Set callback for the link |
|
162 TCallBack callBackFirstLink( DisableTestLinkL, this ); |
|
163 iDialog->SetLink( callBackFirstLink ); |
|
164 |
|
165 iDialog->RunLD(); |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------- |
|
169 // void CWlanPowerSaveQueryNotif::Cancel() |
|
170 // --------------------------------------------------------- |
|
171 // |
|
172 void CWlanPowerSaveQueryNotif::Cancel() |
|
173 { |
|
174 CLOG_ENTERFN( "CWlanPowerSaveQueryNotif::Cancel" ); |
|
175 if ( !iCancelled ) |
|
176 { |
|
177 iCancelled = ETrue; |
|
178 if ( !iMessage.IsNull() ) |
|
179 { |
|
180 iMessage.Complete( KErrCancel ); |
|
181 } |
|
182 |
|
183 delete iDialog; |
|
184 iDialog = NULL; |
|
185 } |
|
186 |
|
187 CLOG_LEAVEFN( "CWlanPowerSaveQueryNotif::Cancel" ); |
|
188 } |
|
189 |
|
190 |
|
191 // --------------------------------------------------------- |
|
192 // void CWlanPowerSaveQueryNotif::CompleteL( TInt aStatus ) |
|
193 // --------------------------------------------------------- |
|
194 // |
|
195 void CWlanPowerSaveQueryNotif::CompleteL( TInt aStatus ) |
|
196 { |
|
197 CLOG_ENTERFN( "CWlanPowerSaveQueryNotif::CompleteL" ); |
|
198 if ( !iMessage.IsNull() ) |
|
199 { |
|
200 iMessage.WriteL( iReplySlot, TPckg< TBool >( iDisable ) ); |
|
201 iMessage.Complete( aStatus ); |
|
202 } |
|
203 |
|
204 iCancelled = ETrue; |
|
205 iDialog = NULL; //deleted by AVKON when OkToExitL completes |
|
206 |
|
207 CLOG_LEAVEFN( "CWlanPowerSaveQueryNotif::CompleteL" ); |
|
208 } |
|
209 |
|
210 |
|
211 // --------------------------------------------------------- |
|
212 // TInt CWlanPowerSaveQueryNotif::DisableTestLinkL() |
|
213 // --------------------------------------------------------- |
|
214 // |
|
215 TInt CWlanPowerSaveQueryNotif::DisableTestLinkL( TAny* aObject ) |
|
216 { |
|
217 CLOG_ENTERFN( "CWlanPowerSaveQueryNotif::DisableTestLinkL" ); |
|
218 CWlanPowerSaveQueryNotif* myself = |
|
219 static_cast<CWlanPowerSaveQueryNotif*>( aObject ); |
|
220 |
|
221 if ( !myself->iExitAsync ) |
|
222 { |
|
223 // Can't exit now. This call could be triggered by a pointer |
|
224 // event. AVKON would crash if exit is done now. |
|
225 // Trigger a one shot active object to delay exit. |
|
226 TCallBack cb( myself->DisableTestLinkL, myself ); |
|
227 myself->iExitAsync = new( ELeave ) CAsyncCallBack( cb, CActive::EPriorityHigh ); |
|
228 myself->iExitAsync->CallBack(); |
|
229 |
|
230 CLOG_LEAVEFN( "CWlanPowerSaveQueryNotif::DisableTestLinkL" ); |
|
231 return 1; |
|
232 } |
|
233 else |
|
234 { |
|
235 // We can exit now. Called by one shot active object. |
|
236 myself->DoDisableTestLinkL(); |
|
237 |
|
238 CLOG_LEAVEFN( "CWlanPowerSaveQueryNotif::DisableTestLinkL" ); |
|
239 return 0; |
|
240 } |
|
241 } |
|
242 |
|
243 |
|
244 // --------------------------------------------------------- |
|
245 // void CWlanPowerSaveQueryNotif::DoDisableTestLinkL() |
|
246 // --------------------------------------------------------- |
|
247 // |
|
248 void CWlanPowerSaveQueryNotif::DoDisableTestLinkL() |
|
249 { |
|
250 CLOG_ENTERFN( "CWlanPowerSaveQueryNotif::DoDisableTestLinkL" ); |
|
251 |
|
252 iDisable = ETrue; |
|
253 |
|
254 iDialog->TryExitL( EAknSoftkeySelect ); |
|
255 |
|
256 CLOG_LEAVEFN( "CWlanPowerSaveQueryNotif::DoDisableTestLinkL" ); |
|
257 } |
|
258 |
|
259 // End of File |
|