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