14 * Description: Manages note showing in UI |
14 * Description: Manages note showing in UI |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
|
19 #include <bautils.h> |
|
20 #include <featmgr.h> |
|
21 #include <aknSDData.h> |
|
22 #include <secondarydisplay/dunsecondarydisplayapi.h> |
19 #include "DunNoteHandler.h" |
23 #include "DunNoteHandler.h" |
20 #include "DunDebug.h" |
24 #include "DunDebug.h" |
|
25 |
|
26 _LIT( KDunUtilsDriveSpec, "z:" ); |
|
27 _LIT( KDunUtilsResourceFileName, "dunutils.rsc" ); |
|
28 |
|
29 const TInt KDunCoverEnumStart = (ECmdNone + 1); // start after ECmdNone |
|
30 const TInt KDunPtr8toPtr16Divider = 2; // Divider for converting |
|
31 const TInt KDunThreeItemsToPop = 3; |
21 |
32 |
22 // ======== MEMBER FUNCTIONS ======== |
33 // ======== MEMBER FUNCTIONS ======== |
23 |
34 |
24 // --------------------------------------------------------------------------- |
35 // --------------------------------------------------------------------------- |
25 // Two-phased constructor. |
36 // Two-phased constructor. |
100 if ( !iNote ) |
111 if ( !iNote ) |
101 { |
112 { |
102 FTRACE(FPrint( _L("CDunNoteHandler::Stop() (iNote not initialized!) complete") )); |
113 FTRACE(FPrint( _L("CDunNoteHandler::Stop() (iNote not initialized!) complete") )); |
103 return KErrGeneral; |
114 return KErrGeneral; |
104 } |
115 } |
105 iNote->Close(); |
116 iNote->CancelConfirmationQuery(); |
|
117 Cancel(); |
106 iNoteState = EDunStateIdle; |
118 iNoteState = EDunStateIdle; |
107 FTRACE(FPrint( _L("CDunNoteHandler::Stop() complete") )); |
119 FTRACE(FPrint( _L("CDunNoteHandler::Stop() complete") )); |
108 return KErrNone; |
120 return KErrNone; |
109 } |
121 } |
110 |
122 |
111 // --------------------------------------------------------------------------- |
123 // --------------------------------------------------------------------------- |
112 // CDunNoteHandler::CDunNoteHandler |
124 // CDunNoteHandler::CDunNoteHandler |
113 // --------------------------------------------------------------------------- |
125 // --------------------------------------------------------------------------- |
114 // |
126 // |
115 CDunNoteHandler::CDunNoteHandler() |
127 CDunNoteHandler::CDunNoteHandler() : |
|
128 CActive( EPriorityStandard ) |
116 { |
129 { |
117 Initialize(); |
130 Initialize(); |
118 } |
131 } |
119 |
132 |
120 // --------------------------------------------------------------------------- |
133 // --------------------------------------------------------------------------- |
149 if ( iNote ) |
163 if ( iNote ) |
150 { |
164 { |
151 FTRACE(FPrint( _L("CDunNoteHandler::DoIssueRequestL() (ERROR) complete") )); |
165 FTRACE(FPrint( _L("CDunNoteHandler::DoIssueRequestL() (ERROR) complete") )); |
152 User::Leave( KErrGeneral ); |
166 User::Leave( KErrGeneral ); |
153 } |
167 } |
154 |
168 HBufC16* unicodeString = NULL; |
155 CHbDeviceMessageBoxSymbian* messageBox = |
169 ReadResourceTextL( R_DUN_MAXIMUM_DIALUPS, unicodeString ); |
156 CHbDeviceMessageBoxSymbian::NewL( |
170 CAknGlobalConfirmationQuery* note = CAknGlobalConfirmationQuery::NewLC(); |
157 CHbDeviceMessageBoxSymbian::EWarning); |
171 // Publish cover UI note data |
158 CleanupStack::PushL(messageBox); |
172 CAknSDData* sdData = CAknSDData::NewL( KDunNoteCategory, |
159 //ToDo: Need to use localised strings. |
173 ECmdMaxNumber - KDunCoverEnumStart, |
160 _LIT(KText, "Maximum number of dialup-connections. Dial-up failed."); |
174 KNullDesC8 ); |
161 messageBox->SetTextL(KText); |
175 note->SetSecondaryDisplayData( sdData ); // ownership transferred |
162 messageBox->SetObserver(this); |
176 // Start to show note |
163 messageBox->SetTimeout(0); |
177 iStatus = KRequestPending; |
164 messageBox->ShowL(); |
178 iNoteState = EDunStateUiNoting; |
165 CleanupStack::Pop(messageBox); |
179 note->ShowConfirmationQueryL( iStatus, |
166 iNote = messageBox; |
180 *unicodeString, |
|
181 R_AVKON_SOFTKEYS_OK_EMPTY, |
|
182 R_QGN_NOTE_ERROR_ANIM, |
|
183 KNullDesC, |
|
184 0, |
|
185 0, |
|
186 CAknQueryDialog::EErrorTone ); |
|
187 CleanupStack::Pop( note ); |
|
188 delete unicodeString; |
|
189 iNote = note; |
167 FTRACE(FPrint( _L("CDunNoteHandler::DoIssueRequestL() complete") )); |
190 FTRACE(FPrint( _L("CDunNoteHandler::DoIssueRequestL() complete") )); |
168 } |
191 } |
169 |
192 |
170 // --------------------------------------------------------------------------- |
193 // --------------------------------------------------------------------------- |
171 // From class MHbDeviceMessageBoxObserver. |
194 // Reads resource string |
172 // Gets called on dialog close. |
195 // --------------------------------------------------------------------------- |
173 // --------------------------------------------------------------------------- |
196 // |
174 // |
197 void CDunNoteHandler::ReadResourceTextL( TInt aResourceId, HBufC16*& aUnicode ) |
175 void CDunNoteHandler::MessageBoxClosed( |
198 { |
176 const CHbDeviceMessageBoxSymbian* /*aMessageBox*/, |
199 FTRACE(FPrint( _L("CDunNoteHandler::ReadNoteResourceL()") )); |
177 CHbDeviceMessageBoxSymbian::TButtonId /*aButton*/ ) |
200 // Connect to file server (for resource file reading) |
178 { |
201 RFs fileSession; |
179 FTRACE(FPrint( _L("CDunNoteHandler::MessageBoxClosed()" ) )); |
202 CleanupClosePushL<RFs>( fileSession ); |
|
203 User::LeaveIfError( fileSession.Connect() ); |
|
204 // Create dunutils.rsc path and file name |
|
205 TFileName fileName; |
|
206 fileName = KDunUtilsDriveSpec; |
|
207 fileName += KDC_RESOURCE_FILES_DIR; |
|
208 fileName += KDunUtilsResourceFileName; |
|
209 // Find nearest language file for resource |
|
210 BaflUtils::NearestLanguageFile( fileSession, fileName ); |
|
211 // Read note resource |
|
212 RResourceFile resourceFile; |
|
213 CleanupClosePushL<RResourceFile>( resourceFile ); |
|
214 resourceFile.OpenL( fileSession, fileName ); |
|
215 resourceFile.ConfirmSignatureL(); |
|
216 HBufC8* readBuffer = resourceFile.AllocReadLC( aResourceId ); |
|
217 // Convert read HBufC8 to HBufC16 |
|
218 const TPtrC16 ptr16(reinterpret_cast<const TUint16*> |
|
219 (readBuffer->Ptr()), |
|
220 (readBuffer->Size() / KDunPtr8toPtr16Divider) ); |
|
221 aUnicode = HBufC16::NewL( ptr16.Length() ); |
|
222 *aUnicode = ptr16; |
|
223 CleanupStack::PopAndDestroy( KDunThreeItemsToPop ); // readBuffer, resourceFile, fileSession |
|
224 FTRACE(FPrint( _L("CDunNoteHandler::ReadNoteResourceL() complete") )); |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // From class CActive. |
|
229 // Gets called when UI note dismissed |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 void CDunNoteHandler::RunL() |
|
233 { |
|
234 FTRACE(FPrint( _L("CDunNoteHandler::RunL()" ) )); |
180 iNoteState = EDunStateIdle; |
235 iNoteState = EDunStateIdle; |
181 delete iNote; |
236 delete iNote; |
182 iNote = NULL; |
237 iNote = NULL; |
183 FTRACE(FPrint( _L("CDunNoteHandler::MessageBoxClosed() complete" ) )); |
238 FTRACE(FPrint( _L("CDunNoteHandler::RunL() complete" ) )); |
184 } |
239 } |
|
240 |
|
241 // --------------------------------------------------------------------------- |
|
242 // From class CActive. |
|
243 // Gets called on cancel |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void CDunNoteHandler::DoCancel() |
|
247 { |
|
248 } |