author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:44:03 +0100 | |
branch | GCC_SURGE |
changeset 63 | ef2686f7597e |
parent 26 | 0ae0f29418cd |
parent 38 | 218231f2b3b3 |
permissions | -rw-r--r-- |
35 | 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 |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
20 |
#include <hb/hbwidgets/hbdevicemessageboxsymbian.h> // dialog |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
21 |
#include <hb/hbcore/hbtextresolversymbian.h> |
35 | 22 |
#include <usbuinotif.h> // pck |
23 |
#include "usbuinotifotgerror.h" // Own class definition |
|
24 |
#include "usbuinotifdebug.h" // Debugging macros |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
25 |
|
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
26 |
// CONSTANTS |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
27 |
/** granularity for allocating error strings */ |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
28 |
const TInt KUsbOtgErrorGranularity = 7; |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
29 |
|
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
30 |
|
35 | 31 |
// ================= MEMBER FUNCTIONS ========================================= |
32 |
||
33 |
// ---------------------------------------------------------------------------- |
|
34 |
// CUsbUiNotifOtgError::NewL |
|
35 |
// Two-phased constructor. |
|
36 |
// ---------------------------------------------------------------------------- |
|
37 |
// |
|
38 |
CUsbUiNotifOtgError* CUsbUiNotifOtgError::NewL() |
|
39 |
{ |
|
40 |
CUsbUiNotifOtgError* self = new (ELeave) CUsbUiNotifOtgError(); |
|
41 |
CleanupStack::PushL( self ); |
|
42 |
self->ConstructL(); |
|
43 |
CleanupStack::Pop( self ); |
|
44 |
return self; |
|
45 |
} |
|
46 |
||
47 |
// ---------------------------------------------------------------------------- |
|
48 |
// CUsbUiNotifOtgError::CUsbUiNotifOtgError |
|
49 |
// C++ default constructor can NOT contain any code, that |
|
50 |
// might leave. |
|
51 |
// ---------------------------------------------------------------------------- |
|
52 |
// |
|
53 |
CUsbUiNotifOtgError::CUsbUiNotifOtgError() : |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
54 |
iStringIds(NULL) |
35 | 55 |
{ |
56 |
} |
|
57 |
||
58 |
// ---------------------------------------------------------------------------- |
|
59 |
// Destructor |
|
60 |
// ---------------------------------------------------------------------------- |
|
61 |
// |
|
62 |
CUsbUiNotifOtgError::~CUsbUiNotifOtgError() |
|
63 |
{ |
|
64 |
//Make sure that the request is completed. Note that inside the destructor, |
|
65 |
//this virtual function call is to local CUsbUiNotifOtgError::Cancel, |
|
66 |
//not to any possibly derived class implementation. |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
67 |
delete iStringIds; |
35 | 68 |
Cancel(); |
69 |
} |
|
70 |
||
71 |
void CUsbUiNotifOtgError::ConstructL() |
|
72 |
{ |
|
73 |
CUSBUINotifierBase::ConstructL(); |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
74 |
iStringIds = new (ELeave) CDesCArrayFlat(KUsbOtgErrorGranularity); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
75 |
_LIT(KCurrentLimit, "txt_usb_info_error_in_usb_connection_disconnect_d"); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
76 |
_LIT(KTooMuchCurrent, "txt_usb_info_unsupported_usb_device_disconnect_de"); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
77 |
_LIT(KUnsupported, "txt_usb_info_unsupported_usb_device_disconnect_de"); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
78 |
_LIT(KHubUnsupported, "txt_usb_info_hubs_are_not_supported_disconnect_us"); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
79 |
_LIT(KUnRecoverable, "txt_usb_info_error_in_usb_connection_disconnect_d"); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
80 |
_LIT(KAttachTimeOut, "txt_usb_info_remove_usb_cable_or_connect_a_device"); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
81 |
_LIT(KNotEnoughMemory, "txt_usb_info_memory_full_close_some_applications"); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
82 |
iStringIds->AppendL( KCurrentLimit); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
83 |
iStringIds->AppendL( KTooMuchCurrent); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
84 |
iStringIds->AppendL( KUnsupported); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
85 |
iStringIds->AppendL( KHubUnsupported); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
86 |
iStringIds->AppendL( KUnRecoverable); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
87 |
iStringIds->AppendL( KAttachTimeOut); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
88 |
iStringIds->AppendL( KNotEnoughMemory); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
89 |
|
35 | 90 |
} |
91 |
||
92 |
// ---------------------------------------------------------------------------- |
|
93 |
// CUsbUiNotifOtgError::RegisterL |
|
94 |
// Register notifier. |
|
95 |
// ---------------------------------------------------------------------------- |
|
96 |
// |
|
97 |
CUsbUiNotifOtgError::TNotifierInfo CUsbUiNotifOtgError::RegisterL() |
|
98 |
{ |
|
99 |
iInfo.iUid = KUsbUiNotifOtgError; |
|
100 |
iInfo.iChannel = KUsbUiNotifOtgError; |
|
101 |
iInfo.iPriority = ENotifierPriorityVHigh; |
|
102 |
return iInfo; |
|
103 |
} |
|
104 |
||
105 |
// ---------------------------------------------------------------------------- |
|
106 |
// CUsbUiNotifOtgError::GetParamsL |
|
107 |
// Jump to RunL as soon as possible. |
|
108 |
// ---------------------------------------------------------------------------- |
|
109 |
// |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
110 |
void CUsbUiNotifOtgError::StartDialogL(const TDesC8& aBuffer, TInt aReplySlot, |
35 | 111 |
const RMessagePtr2& aMessage) |
112 |
{ |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
113 |
FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::StartDialogL")); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
114 |
if (iReplySlot != 0 || iNeedToCompleteMessage) |
35 | 115 |
{ |
116 |
User::Leave( KErrInUse ); |
|
117 |
} |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
118 |
|
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
119 |
InitializeTextResolver(); |
35 | 120 |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
121 |
TInt errorId = 0; |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
122 |
TPckgC<TInt> pckg( errorId ); |
35 | 123 |
pckg.Set( aBuffer ); |
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
124 |
errorId = pckg(); |
35 | 125 |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
126 |
FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL iErrorId: %d"), errorId )); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
127 |
if ( errorId < 0 || errorId >= iStringIds->MdcaCount()) |
35 | 128 |
{ |
129 |
User::Leave( KErrArgument); |
|
130 |
} |
|
131 |
iMessage = aMessage; |
|
132 |
iNeedToCompleteMessage = ETrue; |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
133 |
iReplySlot = aReplySlot; |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
134 |
|
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
135 |
if (iQuery) |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
136 |
{ |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
137 |
delete iQuery; |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
138 |
iQuery = NULL; |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
139 |
} |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
140 |
|
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
141 |
iQuery = CHbDeviceMessageBoxSymbian::NewL( |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
142 |
CHbDeviceMessageBoxSymbian::EWarning, this); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
143 |
iQuery->SetTimeout(0); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
144 |
HBufC* stringHolder = HbTextResolverSymbian::LoadLC(iStringIds->MdcaPoint(errorId) ); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
145 |
iQuery->SetTextL(*stringHolder); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
146 |
iQuery->ShowL(); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
147 |
CleanupStack::PopAndDestroy( stringHolder ); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
148 |
|
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
149 |
|
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
150 |
FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::StartDialogL completed")); |
35 | 151 |
} |
152 |
||
153 |
// ---------------------------------------------------------------------------- |
|
154 |
// CUsbUiNotifOtgError::Cancel |
|
155 |
// Release all own resources (member variables) |
|
156 |
// ---------------------------------------------------------------------------- |
|
157 |
// |
|
158 |
void CUsbUiNotifOtgError::Cancel() |
|
159 |
{ |
|
160 |
FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel")); |
|
161 |
if (iQuery) |
|
162 |
{ |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
163 |
iQuery->Close(); |
35 | 164 |
delete iQuery; |
165 |
iQuery = NULL; |
|
166 |
} |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
167 |
CUSBUINotifierBase::Cancel(); |
35 | 168 |
|
169 |
FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel() completed")); |
|
170 |
} |
|
171 |
// ---------------------------------------------------------------------------- |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
172 |
// Call back function to observe device message box closing. |
35 | 173 |
// ---------------------------------------------------------------------------- |
174 |
// |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
175 |
void CUsbUiNotifOtgError::MessageBoxClosed( |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
176 |
const CHbDeviceMessageBoxSymbian* /*aMessageBox*/, |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
177 |
CHbDeviceMessageBoxSymbian::TButtonId aButton) |
35 | 178 |
{ |
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
179 |
FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed")); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
180 |
int returnValue = KErrNone; |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
181 |
|
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
182 |
//iQuery will be deleted in Cancel. If Cancel is not called, it will be |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
183 |
//deleted next time the query is shown. |
35 | 184 |
|
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
185 |
if (aButton == CHbDeviceMessageBoxSymbian::EAcceptButton) |
35 | 186 |
{ |
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
187 |
returnValue = KErrNone; |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
188 |
} |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
189 |
else |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
190 |
{ |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
191 |
returnValue = KErrCancel; |
35 | 192 |
} |
193 |
||
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
194 |
CompleteMessage( returnValue ); |
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
195 |
|
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
196 |
FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::MessageBoxClosed completed")); |
35 | 197 |
} |
198 |
||
38
218231f2b3b3
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
199 |
|
35 | 200 |
// End of File |