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