9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: USB UI MSMM Error notifier class. |
14 * Description: USB UI queries notifier class. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 // INCLUDE FILES |
19 // INCLUDE FILES |
20 #include <hb/hbwidgets/hbdevicemessageboxsymbian.h> // dialog |
20 #include <eikenv.h> // Eikon environment |
21 #include <hb/hbwidgets/hbdevicenotificationdialogsymbian.h> //discreet |
21 #include <bautils.h> // BAFL utils (for language file) |
22 #include <hb/hbcore/hbtextresolversymbian.h> |
22 #include <utf.h> // Unicode character conversion utilities |
23 #include <usb/hostms/srverr.h> |
23 #include <StringLoader.h> // Localisation stringloader |
|
24 #include <AknQueryDialog.h> |
|
25 #include <aknnotewrappers.h> |
|
26 #include <usb/hostms/srverr.h> |
|
27 #include <featmgr.h> |
|
28 |
24 #include <usbuinotif.h> // pck |
29 #include <usbuinotif.h> // pck |
|
30 #include <usbuinotif.rsg> // Own resources |
|
31 #include <secondarydisplay/usbuinotifsecondarydisplay.h> // Dialog index for cover UI |
|
32 |
25 #include "usbuinotifmsmmerror.h" // Own class definition |
33 #include "usbuinotifmsmmerror.h" // Own class definition |
26 #include "usbuinotifdebug.h" // Debugging macros |
34 #include "usbuinotifdebug.h" // Debugging macros |
27 |
35 |
28 |
36 |
29 // CONSTANTS |
|
30 /** granularity for allocating error strings */ |
|
31 const TInt KUsbMsmmErrorGranularity = 5; |
|
32 _LIT(KUSBUIconFileName, "qtg_large_usb"); |
|
33 // ================= MEMBER FUNCTIONS ========================================= |
37 // ================= MEMBER FUNCTIONS ========================================= |
34 |
38 |
35 // ---------------------------------------------------------------------------- |
39 // ---------------------------------------------------------------------------- |
36 // CUsbUiNotifOtgError::NewL |
40 // CUsbUiNotifOtgError::NewL |
37 // Two-phased constructor. |
41 // Two-phased constructor. |
64 CUsbUiNotifMSMMError::~CUsbUiNotifMSMMError() |
68 CUsbUiNotifMSMMError::~CUsbUiNotifMSMMError() |
65 { |
69 { |
66 //Make sure that the request is completed. Note that inside the destructor, |
70 //Make sure that the request is completed. Note that inside the destructor, |
67 //this virtual function call is to local CUsbUiNotifMSMMError::Cancel, |
71 //this virtual function call is to local CUsbUiNotifMSMMError::Cancel, |
68 //not to any possibly derived class implementation. |
72 //not to any possibly derived class implementation. |
69 delete iStringIds; |
|
70 Cancel(); |
73 Cancel(); |
|
74 delete iDialerWatcher; |
|
75 delete iQuery; |
71 } |
76 } |
72 |
77 |
73 void CUsbUiNotifMSMMError::ConstructL() |
78 void CUsbUiNotifMSMMError::ConstructL() |
74 { |
79 { |
75 CUSBUINotifierBase::ConstructL(); |
80 CUSBUINotifierBase::ConstructL(); |
76 iStringIds = new (ELeave) CDesCArrayFlat(KUsbMsmmErrorGranularity); |
81 iStringIds.AppendL( R_USB_MSMM_ERROR_GENERAL_MASS_STORAGE_ERROR); |
77 _LIT(KGeneralError,"txt_usb_info_error_in_usb_connection_disconnect_d"); |
82 iStringIds.AppendL( R_USB_MSMM_ERROR_UNKNOWN_FILESYSTEM); |
78 _LIT(KUnknownFileSys, "txt_usb_info_unknown_file_system_disconnect_devic"); |
83 iStringIds.AppendL( R_USB_MSMM_ERROR_OUT_OF_MEMORY); |
79 _LIT(KOutOfMemory, "txt_usb_info_disk_full_remove_some_files_and_try"); |
|
80 _LIT(KSafeToRemove, "txt_usb_dpinfo_safe_to_remove"); |
|
81 _LIT(KUnableToEject,"txt_usb_info_unable_to_eject_the_usb_device_some" ); |
|
82 |
|
83 iStringIds->AppendL(KGeneralError); |
|
84 iStringIds->AppendL(KUnknownFileSys); |
|
85 iStringIds->AppendL(KOutOfMemory); |
|
86 iStringIds->AppendL(KSafeToRemove); |
|
87 iStringIds->AppendL(KUnableToEject); |
|
88 } |
84 } |
89 |
85 |
90 // ---------------------------------------------------------------------------- |
86 // ---------------------------------------------------------------------------- |
91 // CUsbUiNotifMSMMError::RegisterL |
87 // CUsbUiNotifMSMMError::RegisterL |
92 // Register notifier. |
88 // Register notifier. |
103 // ---------------------------------------------------------------------------- |
99 // ---------------------------------------------------------------------------- |
104 // CUsbUiNotifMSMMError::GetParamsL |
100 // CUsbUiNotifMSMMError::GetParamsL |
105 // Jump to RunL as soon as possible. |
101 // Jump to RunL as soon as possible. |
106 // ---------------------------------------------------------------------------- |
102 // ---------------------------------------------------------------------------- |
107 // |
103 // |
108 void CUsbUiNotifMSMMError::StartDialogL(const TDesC8& aBuffer, TInt aReplySlot, |
104 void CUsbUiNotifMSMMError::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, |
109 const RMessagePtr2& aMessage) |
105 const RMessagePtr2& aMessage) |
110 { |
106 { |
111 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::StartDialogL")); |
107 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::GetParamsL")); |
112 if (iReplySlot != 0 || iNeedToCompleteMessage) |
108 if (iQuery || iReplySlot != 0 || iNeedToCompleteMessage) |
113 { |
109 { |
114 User::Leave( KErrInUse ); |
110 User::Leave( KErrInUse ); |
115 } |
111 } |
116 |
|
117 InitializeTextResolver(); |
|
118 |
112 |
119 iMessage = aMessage; |
113 iMessage = aMessage; |
120 iNeedToCompleteMessage = ETrue; |
114 iNeedToCompleteMessage = ETrue; |
121 iReplySlot = aReplySlot; |
115 iReplySlot = aReplySlot; |
122 _LIT(KUsbDisconnected, "txt_usb_dpophead_usb_disconnected"); |
116 |
123 // Get parameters |
117 // Get parameters |
124 // |
118 // |
125 THostMsErrData error; |
119 THostMsErrData error; |
126 TPckgC<THostMsErrData> pckg( error ); |
120 TPckgC<THostMsErrData> pckg( error); |
127 pckg.Set( aBuffer ); |
121 pckg.Set( aBuffer ); |
128 int errorId = EUsbMSMMGeneralError; |
|
129 switch (pckg().iError) |
122 switch (pckg().iError) |
130 { |
123 { |
131 case EHostMsErrUnknownFileSystem: |
124 case EHostMsErrUnknownFileSystem: |
132 errorId = EUsbMSMMUnknownFileSystem; |
125 iErrorId = EUsbMSMMUnknownFileSystem; |
133 break; |
126 break; |
134 case EHostMsErrOutOfMemory: |
127 case EHostMsErrOutOfMemory: |
135 errorId = EUsbMSMMOutOfMemory; |
128 iErrorId = EUsbMSMMOutOfMemory; |
136 break; |
129 break; |
137 case EHostMsErrNone: |
|
138 errorId = EUsbMSMMSafeToRemove; |
|
139 break; |
|
140 case EHostMsErrInUse: |
|
141 errorId = EUsbMSMMUnableToEject; |
|
142 break; |
|
143 default: |
130 default: |
144 errorId = EUsbMSMMGeneralError; |
131 iErrorId = EUsbMSMMGeneralError; |
145 } |
132 } |
146 HBufC* stringHolder = HbTextResolverSymbian::LoadLC(iStringIds->MdcaPoint(errorId)); |
133 |
147 |
134 SetActive(); |
148 |
135 iStatus = KRequestPending; |
149 if ( errorId == EUsbMSMMSafeToRemove) |
136 TRequestStatus* stat = &iStatus; |
150 { |
137 User::RequestComplete( stat, KErrNone ); |
151 // "safe to remove" discreet popup |
138 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::GetParamsL() completed")); |
152 HBufC* header = HbTextResolverSymbian::LoadLC(KUsbDisconnected); |
139 } |
153 if (iDiscreet) |
140 |
|
141 // ---------------------------------------------------------------------------- |
|
142 // CUsbUiNotifMSMMError::RunL |
|
143 // Ask user response and return it to caller. |
|
144 // ---------------------------------------------------------------------------- |
|
145 // |
|
146 void CUsbUiNotifMSMMError::RunL() |
|
147 { |
|
148 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::RunL")); |
|
149 TInt returnValue = KErrNone; |
|
150 FeatureManager::InitializeLibL(); |
|
151 if ( FeatureManager::FeatureSupported( KFeatureIdFfKeypadNoSendKey ) ) |
|
152 { |
|
153 if (!iDialerWatcher) |
154 { |
154 { |
155 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::StartDialogL() deleting previous dialog")); |
155 iDialerWatcher = CUsbuinotifDialerWatcher::NewL(this); |
156 delete iDiscreet; |
|
157 iDiscreet = NULL; |
|
158 } |
156 } |
159 iDiscreet = CHbDeviceNotificationDialogSymbian::NewL(this); |
157 } |
160 iDiscreet->SetTitleL(*header); |
158 iDismissed=EFalse; |
161 iDiscreet->SetTextL(*stringHolder); |
159 DisableKeylock(); |
162 iDiscreet->SetIconNameL(KUSBUIconFileName ); |
160 SuppressAppSwitching( ETrue ); |
163 iDiscreet->ShowL(); |
161 |
164 CleanupStack::PopAndDestroy( header ); |
162 //Excute dialog and check return value |
165 } |
163 returnValue = QueryUserResponseL(); |
166 else |
164 if (!iDismissed) |
167 { |
165 { |
168 //Delete the query in case the client didn't cancel the notifier |
166 SuppressAppSwitching( EFalse ); |
169 //or close the session after the previous query. |
167 RestoreKeylock(); |
170 |
168 delete iDialerWatcher; |
171 if (iQuery) |
169 iDialerWatcher = NULL; |
172 { |
170 CompleteMessage( returnValue ); |
173 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::StartDialogL() deleting previous dialog")); |
171 } |
174 delete iQuery; |
172 |
175 iQuery = NULL; |
173 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::RunL() completed")); |
176 } |
|
177 |
|
178 iQuery = CHbDeviceMessageBoxSymbian::NewL( |
|
179 CHbDeviceMessageBoxSymbian::EWarning, this); |
|
180 iQuery->SetTimeout(0); |
|
181 |
|
182 |
|
183 iQuery->SetTextL(*stringHolder); |
|
184 iQuery->ShowL(); |
|
185 } |
|
186 |
|
187 CleanupStack::PopAndDestroy( stringHolder ); |
|
188 |
|
189 |
|
190 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::StartDialogL() completed")); |
|
191 } |
174 } |
192 |
175 |
193 // ---------------------------------------------------------------------------- |
176 // ---------------------------------------------------------------------------- |
194 // CUsbUiNotifMSMMError::Cancel |
177 // CUsbUiNotifMSMMError::Cancel |
195 // Release all own resources (member variables) |
178 // Release all own resources (member variables) |
196 // ---------------------------------------------------------------------------- |
179 // ---------------------------------------------------------------------------- |
197 // |
180 // |
198 void CUsbUiNotifMSMMError::Cancel() |
181 void CUsbUiNotifMSMMError::Cancel() |
199 { |
182 { |
200 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel")); |
183 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel")); |
|
184 // If dialog is not dismissed this is normal cancel and if query |
|
185 // doesn't exsist notifier is canceled during dismission |
|
186 if (!iDismissed || !iQuery ) |
|
187 { |
|
188 delete iDialerWatcher; |
|
189 iDialerWatcher = NULL; |
|
190 CompleteMessage( KErrCancel ); |
|
191 } |
201 if (iQuery) |
192 if (iQuery) |
202 { |
193 { |
203 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel closing iQuery")); |
|
204 iQuery->Close(); |
|
205 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel iQuery closed")); |
|
206 delete iQuery; |
194 delete iQuery; |
207 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel iQuery deleted")); |
|
208 iQuery = NULL; |
195 iQuery = NULL; |
209 } |
196 } |
210 if (iDiscreet) |
197 |
211 { |
198 |
212 iDiscreet->Close(); |
|
213 delete iDiscreet; |
|
214 iDiscreet = NULL; |
|
215 } |
|
216 CUSBUINotifierBase::Cancel(); |
|
217 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel() completed")); |
199 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel() completed")); |
218 } |
200 } |
219 |
201 |
220 // ---------------------------------------------------------------------------- |
202 // ---------------------------------------------------------------------------- |
221 // Call back function to observe device message box closing. |
203 // CUsbUiNotifOtgError::DialerActivated |
222 // ---------------------------------------------------------------------------- |
204 // Release all own resources (member variables) |
223 // |
205 // ---------------------------------------------------------------------------- |
224 void CUsbUiNotifMSMMError::MessageBoxClosed( |
206 // |
225 const CHbDeviceMessageBoxSymbian* /*aMessageBox*/, |
207 void CUsbUiNotifMSMMError::DialerActivated() |
226 CHbDeviceMessageBoxSymbian::TButtonId aButton) |
208 { |
227 { |
209 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::AppKeyPressed()")); |
228 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed")); |
210 if ( iQuery ) |
229 int returnValue = KErrNone; |
211 { |
|
212 iDismissed=ETrue; |
|
213 Cancel(); |
|
214 } |
|
215 } |
|
216 |
|
217 // ---------------------------------------------------------------------------- |
|
218 // CUsbUiNotifOtgError::ReActivateDialog |
|
219 // Release all own resources (member variables) |
|
220 // ---------------------------------------------------------------------------- |
|
221 // |
|
222 void CUsbUiNotifMSMMError::ReActivateDialog() |
|
223 { |
|
224 FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ReActivateDialog()")); |
|
225 if ( !IsActive()) |
|
226 { |
|
227 SetActive(); |
|
228 iStatus = KRequestPending; |
|
229 TRequestStatus* stat = &iStatus; |
|
230 User::RequestComplete( stat, KErrNone ); |
|
231 } |
|
232 } |
|
233 // ---------------------------------------------------------------------------- |
|
234 // CUsbUiNotifMSMMError::QueryUserResponseL |
|
235 // Show query dialog. |
|
236 // ---------------------------------------------------------------------------- |
|
237 // |
|
238 TInt CUsbUiNotifMSMMError::QueryUserResponseL() |
|
239 { |
|
240 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::QueryUserResponseL")); |
|
241 TInt returnValue = KErrNone; |
|
242 TInt resourceId = R_USB_QUERY_OTG_ERROR; |
|
243 if (iDismissed) |
|
244 { |
|
245 iQuery = CAknQueryDialog::NewL(); |
|
246 } |
|
247 else |
|
248 { |
|
249 iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone ); |
|
250 } |
230 |
251 |
231 //iQuery will be deleted in Cancel. If Cancel is not called, it will be |
|
232 //deleted next time the query is shown. |
|
233 |
|
234 if (aButton == CHbDeviceMessageBoxSymbian::EAcceptButton) |
|
235 { |
|
236 returnValue = KErrNone; |
|
237 } |
|
238 else |
|
239 { |
|
240 returnValue = KErrCancel; |
|
241 } |
|
242 |
|
243 CompleteMessage( returnValue ); |
|
244 |
252 |
245 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed completed")); |
253 iDismissed=EFalse; |
246 } |
254 if (iCoverDisplaySupported) |
247 |
255 { |
248 void CUsbUiNotifMSMMError::NotificationDialogActivated( |
256 iQuery->PublishDialogL( iErrorId, KUsbUiNotifMsmmError ); |
249 const CHbDeviceNotificationDialogSymbian* /*aDialog*/) |
257 } |
250 { |
258 HBufC *stringHolder = StringLoader::LoadLC( iStringIds[iErrorId] ); |
251 |
259 |
252 } |
260 TInt keypress = iQuery->ExecuteLD( resourceId, *stringHolder ); |
253 |
261 |
254 void CUsbUiNotifMSMMError::NotificationDialogClosed( |
262 CleanupStack::PopAndDestroy( stringHolder ); |
255 const CHbDeviceNotificationDialogSymbian* /*aDialog*/, TInt /*aCompletionCode*/) |
263 |
256 { |
264 iQuery = NULL; // Dialog destroyed |
257 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::NotificationDialogClosed()")); |
265 |
258 CompleteMessage( KErrCancel ); |
266 returnValue = keypress ? KErrNone : KErrCancel; //OK? |
259 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::NotificationDialogClosed() complete")); |
267 |
260 } |
268 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::QueryUserResponseL completed")); |
|
269 return returnValue; |
|
270 } |
|
271 |
261 // End of File |
272 // End of File |