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/hbcore/hbtextresolversymbian.h> |
22 #include <utf.h> // Unicode character conversion utilities |
|
23 #include <StringLoader.h> // Localisation stringloader |
|
24 #include <AknQueryDialog.h> |
|
25 #include <aknnotewrappers.h> |
|
26 |
|
27 #include <usbuinotif.h> // pck |
22 #include <usbuinotif.h> // pck |
28 #include <usbuinotif.rsg> // Own resources |
|
29 #include "usbuinotifotgerror.h" // Own class definition |
23 #include "usbuinotifotgerror.h" // Own class definition |
30 #include "usbuinotifdebug.h" // Debugging macros |
24 #include "usbuinotifdebug.h" // Debugging macros |
31 #include "usbuinotifsecondarydisplay.h" // Dialog index for cover UI |
25 |
|
26 // CONSTANTS |
|
27 /** granularity for allocating error strings */ |
|
28 const TInt KUsbOtgErrorGranularity = 7; |
|
29 |
|
30 |
32 // ================= MEMBER FUNCTIONS ========================================= |
31 // ================= MEMBER FUNCTIONS ========================================= |
33 |
32 |
34 // ---------------------------------------------------------------------------- |
33 // ---------------------------------------------------------------------------- |
35 // CUsbUiNotifOtgError::NewL |
34 // CUsbUiNotifOtgError::NewL |
36 // Two-phased constructor. |
35 // Two-phased constructor. |
63 CUsbUiNotifOtgError::~CUsbUiNotifOtgError() |
62 CUsbUiNotifOtgError::~CUsbUiNotifOtgError() |
64 { |
63 { |
65 //Make sure that the request is completed. Note that inside the destructor, |
64 //Make sure that the request is completed. Note that inside the destructor, |
66 //this virtual function call is to local CUsbUiNotifOtgError::Cancel, |
65 //this virtual function call is to local CUsbUiNotifOtgError::Cancel, |
67 //not to any possibly derived class implementation. |
66 //not to any possibly derived class implementation. |
|
67 delete iStringIds; |
68 Cancel(); |
68 Cancel(); |
69 } |
69 } |
70 |
70 |
71 void CUsbUiNotifOtgError::ConstructL() |
71 void CUsbUiNotifOtgError::ConstructL() |
72 { |
72 { |
73 CUSBUINotifierBase::ConstructL(); |
73 CUSBUINotifierBase::ConstructL(); |
74 iStringIds.AppendL( R_USB_OTG_ERROR_CURRENT_LIMIT); |
74 iStringIds = new (ELeave) CDesCArrayFlat(KUsbOtgErrorGranularity); |
75 iStringIds.AppendL( R_USB_OTG_ERROR_TOO_MUCH_CURRENT_REQUIRED); |
75 _LIT(KCurrentLimit, "txt_usb_info_error_in_usb_connection_disconnect_d"); |
76 iStringIds.AppendL( R_USB_OTG_ERROR_UNSUPPORTED); |
76 _LIT(KTooMuchCurrent, "txt_usb_info_unsupported_usb_device_disconnect_de"); |
77 iStringIds.AppendL( R_USB_OTG_ERROR_HUB_UNSUPPORTED); |
77 _LIT(KUnsupported, "txt_usb_info_unsupported_usb_device_disconnect_de"); |
78 iStringIds.AppendL( R_USB_OTG_ERROR_UNRECOVERABLE); |
78 _LIT(KHubUnsupported, "txt_usb_info_hubs_are_not_supported_disconnect_us"); |
79 iStringIds.AppendL( R_USB_OTG_ERROR_ATTACH_TIMEDOUT); |
79 _LIT(KUnRecoverable, "txt_usb_info_error_in_usb_connection_disconnect_d"); |
80 iStringIds.AppendL( R_USB_ERROR_MEMORY_NOT_ENOUGH); |
80 _LIT(KAttachTimeOut, "txt_usb_info_remove_usb_cable_or_connect_a_device"); |
|
81 _LIT(KNotEnoughMemory, "txt_usb_info_memory_full_close_some_applications"); |
|
82 iStringIds->AppendL( KCurrentLimit); |
|
83 iStringIds->AppendL( KTooMuchCurrent); |
|
84 iStringIds->AppendL( KUnsupported); |
|
85 iStringIds->AppendL( KHubUnsupported); |
|
86 iStringIds->AppendL( KUnRecoverable); |
|
87 iStringIds->AppendL( KAttachTimeOut); |
|
88 iStringIds->AppendL( KNotEnoughMemory); |
|
89 |
81 } |
90 } |
82 |
91 |
83 // ---------------------------------------------------------------------------- |
92 // ---------------------------------------------------------------------------- |
84 // CUsbUiNotifOtgError::RegisterL |
93 // CUsbUiNotifOtgError::RegisterL |
85 // Register notifier. |
94 // Register notifier. |
96 // ---------------------------------------------------------------------------- |
105 // ---------------------------------------------------------------------------- |
97 // CUsbUiNotifOtgError::GetParamsL |
106 // CUsbUiNotifOtgError::GetParamsL |
98 // Jump to RunL as soon as possible. |
107 // Jump to RunL as soon as possible. |
99 // ---------------------------------------------------------------------------- |
108 // ---------------------------------------------------------------------------- |
100 // |
109 // |
101 void CUsbUiNotifOtgError::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, |
110 void CUsbUiNotifOtgError::StartDialogL(const TDesC8& aBuffer, TInt aReplySlot, |
102 const RMessagePtr2& aMessage) |
111 const RMessagePtr2& aMessage) |
103 { |
112 { |
104 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL")); |
113 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::StartDialogL")); |
105 if (iQuery || iReplySlot != 0 || iNeedToCompleteMessage) |
114 if (iReplySlot != 0 || iNeedToCompleteMessage) |
106 { |
115 { |
107 User::Leave( KErrInUse ); |
116 User::Leave( KErrInUse ); |
108 } |
117 } |
109 |
118 |
110 // Get parameters |
119 InitializeTextResolver(); |
111 // |
120 |
112 |
121 TInt errorId = 0; |
113 TPckgC<TInt> pckg( iErrorId ); |
122 TPckgC<TInt> pckg( errorId ); |
114 pckg.Set( aBuffer ); |
123 pckg.Set( aBuffer ); |
115 iErrorId = pckg(); |
124 errorId = pckg(); |
116 |
125 |
117 FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL iErrorId: %d"), iErrorId )); |
126 FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL iErrorId: %d"), errorId )); |
118 if ( iErrorId < 0 || iErrorId >= iStringIds.Count() ) |
127 if ( errorId < 0 || errorId >= iStringIds->MdcaCount()) |
119 { |
128 { |
120 User::Leave( KErrArgument); |
129 User::Leave( KErrArgument); |
121 } |
130 } |
122 |
|
123 iMessage = aMessage; |
131 iMessage = aMessage; |
124 iNeedToCompleteMessage = ETrue; |
132 iNeedToCompleteMessage = ETrue; |
125 iReplySlot = aReplySlot; |
133 iReplySlot = aReplySlot; |
126 |
134 |
127 SetActive(); |
135 if (iQuery) |
128 iStatus = KRequestPending; |
136 { |
129 TRequestStatus* stat = &iStatus; |
137 delete iQuery; |
130 User::RequestComplete( stat, KErrNone ); |
138 iQuery = NULL; |
131 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL() completed")); |
139 } |
132 } |
140 |
133 |
141 iQuery = CHbDeviceMessageBoxSymbian::NewL( |
134 // ---------------------------------------------------------------------------- |
142 CHbDeviceMessageBoxSymbian::EWarning, this); |
135 // CUsbUiNotifOtgError::RunL |
143 iQuery->SetTimeout(0); |
136 // Ask user response and return it to caller. |
144 HBufC* stringHolder = HbTextResolverSymbian::LoadLC(iStringIds->MdcaPoint(errorId) ); |
137 // ---------------------------------------------------------------------------- |
145 iQuery->SetTextL(*stringHolder); |
138 // |
146 iQuery->ShowL(); |
139 void CUsbUiNotifOtgError::RunL() |
147 CleanupStack::PopAndDestroy( stringHolder ); |
140 { |
148 |
141 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::RunL")); |
149 |
142 TInt returnValue = KErrNone; |
150 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::StartDialogL completed")); |
143 |
|
144 DisableKeylock(); |
|
145 SuppressAppSwitching( ETrue ); |
|
146 |
|
147 //Excute dialog and check return value |
|
148 returnValue = QueryUserResponseL(); |
|
149 |
|
150 SuppressAppSwitching( EFalse ); |
|
151 RestoreKeylock(); |
|
152 CompleteMessage( returnValue ); |
|
153 |
|
154 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::RunL() completed")); |
|
155 } |
151 } |
156 |
152 |
157 // ---------------------------------------------------------------------------- |
153 // ---------------------------------------------------------------------------- |
158 // CUsbUiNotifOtgError::Cancel |
154 // CUsbUiNotifOtgError::Cancel |
159 // Release all own resources (member variables) |
155 // Release all own resources (member variables) |
162 void CUsbUiNotifOtgError::Cancel() |
158 void CUsbUiNotifOtgError::Cancel() |
163 { |
159 { |
164 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel")); |
160 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel")); |
165 if (iQuery) |
161 if (iQuery) |
166 { |
162 { |
|
163 iQuery->Close(); |
167 delete iQuery; |
164 delete iQuery; |
168 iQuery = NULL; |
165 iQuery = NULL; |
169 } |
166 } |
170 CompleteMessage( KErrCancel ); |
167 CUSBUINotifierBase::Cancel(); |
171 |
168 |
172 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel() completed")); |
169 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel() completed")); |
173 } |
170 } |
174 |
171 // ---------------------------------------------------------------------------- |
175 // ---------------------------------------------------------------------------- |
172 // Call back function to observe device message box closing. |
176 // CUsbUiNotifOtgError::QueryUserResponseL |
173 // ---------------------------------------------------------------------------- |
177 // Show query dialog. |
174 // |
178 // ---------------------------------------------------------------------------- |
175 void CUsbUiNotifOtgError::MessageBoxClosed( |
179 // |
176 const CHbDeviceMessageBoxSymbian* /*aMessageBox*/, |
180 TInt CUsbUiNotifOtgError::QueryUserResponseL() |
177 CHbDeviceMessageBoxSymbian::TButtonId aButton) |
181 { |
178 { |
182 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::QueryUserResponseL")); |
179 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed")); |
183 TInt returnValue = KErrNone; |
180 int returnValue = KErrNone; |
184 TInt resourceId = R_USB_QUERY_OTG_ERROR; |
181 |
185 |
182 //iQuery will be deleted in Cancel. If Cancel is not called, it will be |
186 iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone ); |
183 //deleted next time the query is shown. |
187 |
184 |
188 if (iCoverDisplaySupported) |
185 if (aButton == CHbDeviceMessageBoxSymbian::EAcceptButton) |
189 { |
186 { |
190 iQuery->PublishDialogL( iErrorId, KUsbUiNotifOtgError ); |
187 returnValue = KErrNone; |
|
188 } |
|
189 else |
|
190 { |
|
191 returnValue = KErrCancel; |
191 } |
192 } |
192 HBufC *stringHolder = StringLoader::LoadLC( iStringIds[iErrorId] ); |
193 |
193 |
194 CompleteMessage( returnValue ); |
194 TInt keypress = iQuery->ExecuteLD( resourceId, *stringHolder ); |
195 |
195 |
196 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed completed")); |
196 CleanupStack::PopAndDestroy( stringHolder ); |
197 } |
197 |
198 |
198 iQuery = NULL; // Dialog destroyed |
|
199 |
|
200 returnValue = keypress ? KErrNone : KErrCancel; //OK? |
|
201 |
|
202 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::QueryUserResponseL completed")); |
|
203 return returnValue; |
|
204 } |
|
205 |
199 |
206 // End of File |
200 // End of File |