|
1 /* |
|
2 * Copyright (c) 2007, 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: USB UI queries notifier class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <eikenv.h> // Eikon environment |
|
21 #include <bautils.h> // BAFL utils (for language file) |
|
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 |
|
28 #include <USBUINotif.rsg> // Own resources |
|
29 #include "usbuinotifotgerror.h" // Own class definition |
|
30 #include "usbuinotifdebug.h" // Debugging macros |
|
31 #include "USBUINotifSecondaryDisplay.h" // Dialog index for cover UI |
|
32 // ================= MEMBER FUNCTIONS ========================================= |
|
33 |
|
34 // ---------------------------------------------------------------------------- |
|
35 // CUsbUiNotifOtgError::NewL |
|
36 // Two-phased constructor. |
|
37 // ---------------------------------------------------------------------------- |
|
38 // |
|
39 CUsbUiNotifOtgError* CUsbUiNotifOtgError::NewL() |
|
40 { |
|
41 CUsbUiNotifOtgError* self = new (ELeave) CUsbUiNotifOtgError(); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ---------------------------------------------------------------------------- |
|
49 // CUsbUiNotifOtgError::CUsbUiNotifOtgError |
|
50 // C++ default constructor can NOT contain any code, that |
|
51 // might leave. |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 CUsbUiNotifOtgError::CUsbUiNotifOtgError() : |
|
55 iStringIds( KUsbUiNotifOtgGeneralQueryGranularity) |
|
56 { |
|
57 } |
|
58 |
|
59 // ---------------------------------------------------------------------------- |
|
60 // Destructor |
|
61 // ---------------------------------------------------------------------------- |
|
62 // |
|
63 CUsbUiNotifOtgError::~CUsbUiNotifOtgError() |
|
64 { |
|
65 //Make sure that the request is completed. Note that inside the destructor, |
|
66 //this virtual function call is to local CUsbUiNotifOtgError::Cancel, |
|
67 //not to any possibly derived class implementation. |
|
68 Cancel(); |
|
69 } |
|
70 |
|
71 void CUsbUiNotifOtgError::ConstructL() |
|
72 { |
|
73 CUSBUINotifierBase::ConstructL(); |
|
74 iStringIds.AppendL( R_USB_OTG_ERROR_CURRENT_LIMIT); |
|
75 iStringIds.AppendL( R_USB_OTG_ERROR_TOO_MUCH_CURRENT_REQUIRED); |
|
76 iStringIds.AppendL( R_USB_OTG_ERROR_UNSUPPORTED); |
|
77 iStringIds.AppendL( R_USB_OTG_ERROR_HUB_UNSUPPORTED); |
|
78 iStringIds.AppendL( R_USB_OTG_ERROR_UNRECOVERABLE); |
|
79 iStringIds.AppendL( R_USB_OTG_ERROR_ATTACH_TIMEDOUT); |
|
80 } |
|
81 |
|
82 // ---------------------------------------------------------------------------- |
|
83 // CUsbUiNotifOtgError::RegisterL |
|
84 // Register notifier. |
|
85 // ---------------------------------------------------------------------------- |
|
86 // |
|
87 CUsbUiNotifOtgError::TNotifierInfo CUsbUiNotifOtgError::RegisterL() |
|
88 { |
|
89 iInfo.iUid = KUsbUiNotifOtgError; |
|
90 iInfo.iChannel = KUsbUiNotifOtgError; |
|
91 iInfo.iPriority = ENotifierPriorityVHigh; |
|
92 return iInfo; |
|
93 } |
|
94 |
|
95 // ---------------------------------------------------------------------------- |
|
96 // CUsbUiNotifOtgError::GetParamsL |
|
97 // Jump to RunL as soon as possible. |
|
98 // ---------------------------------------------------------------------------- |
|
99 // |
|
100 void CUsbUiNotifOtgError::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, |
|
101 const RMessagePtr2& aMessage) |
|
102 { |
|
103 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL")); |
|
104 if (iQuery || iReplySlot != 0 || iNeedToCompleteMessage) |
|
105 { |
|
106 User::Leave( KErrInUse ); |
|
107 } |
|
108 |
|
109 iMessage = aMessage; |
|
110 iNeedToCompleteMessage = ETrue; |
|
111 iReplySlot = aReplySlot; |
|
112 |
|
113 // Get parameters |
|
114 // |
|
115 iErrorId = 0; |
|
116 TPckgC<TInt> pckg( iErrorId ); |
|
117 pckg.Set( aBuffer ); |
|
118 iErrorId = pckg(); |
|
119 |
|
120 SetActive(); |
|
121 iStatus = KRequestPending; |
|
122 TRequestStatus* stat = &iStatus; |
|
123 User::RequestComplete( stat, KErrNone ); |
|
124 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL() completed")); |
|
125 } |
|
126 |
|
127 // ---------------------------------------------------------------------------- |
|
128 // CUsbUiNotifOtgError::RunL |
|
129 // Ask user response and return it to caller. |
|
130 // ---------------------------------------------------------------------------- |
|
131 // |
|
132 void CUsbUiNotifOtgError::RunL() |
|
133 { |
|
134 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::RunL")); |
|
135 TInt returnValue = KErrNone; |
|
136 |
|
137 DisableKeylock(); |
|
138 SuppressAppSwitching( ETrue ); |
|
139 |
|
140 //Excute dialog and check return value |
|
141 returnValue = QueryUserResponseL(); |
|
142 |
|
143 SuppressAppSwitching( EFalse ); |
|
144 RestoreKeylock(); |
|
145 CompleteMessage( returnValue ); |
|
146 |
|
147 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::RunL() completed")); |
|
148 } |
|
149 |
|
150 // ---------------------------------------------------------------------------- |
|
151 // CUsbUiNotifOtgError::Cancel |
|
152 // Release all own resources (member variables) |
|
153 // ---------------------------------------------------------------------------- |
|
154 // |
|
155 void CUsbUiNotifOtgError::Cancel() |
|
156 { |
|
157 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel")); |
|
158 if (iQuery) |
|
159 { |
|
160 delete iQuery; |
|
161 iQuery = NULL; |
|
162 } |
|
163 CompleteMessage( KErrCancel ); |
|
164 |
|
165 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel() completed")); |
|
166 } |
|
167 |
|
168 // ---------------------------------------------------------------------------- |
|
169 // CUsbUiNotifOtgError::QueryUserResponseL |
|
170 // Show query dialog. |
|
171 // ---------------------------------------------------------------------------- |
|
172 // |
|
173 TInt CUsbUiNotifOtgError::QueryUserResponseL() |
|
174 { |
|
175 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::QueryUserResponseL")); |
|
176 TInt returnValue = KErrNone; |
|
177 TInt resourceId = R_USB_QUERY_OTG_ERROR; |
|
178 |
|
179 iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone ); |
|
180 |
|
181 if (iCoverDisplaySupported) |
|
182 { |
|
183 iQuery->PublishDialogL( iErrorId, KUsbUiNotifOtgError ); |
|
184 } |
|
185 HBufC *stringHolder = StringLoader::LoadLC( iStringIds[iErrorId] ); |
|
186 |
|
187 TInt keypress = iQuery->ExecuteLD( resourceId, *stringHolder ); |
|
188 |
|
189 CleanupStack::PopAndDestroy( stringHolder ); |
|
190 |
|
191 iQuery = NULL; // Dialog destroyed |
|
192 |
|
193 returnValue = keypress ? KErrNone : KErrCancel; //OK? |
|
194 |
|
195 FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::QueryUserResponseL completed")); |
|
196 return returnValue; |
|
197 } |
|
198 |
|
199 // End of File |