80
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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: This is the interface to all the settings.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
|
|
20 |
#include <centralrepository.h>
|
|
21 |
#include <usb.h>
|
|
22 |
#include <usbwatcher.h>
|
|
23 |
#include <UsbWatcherInternalCRKeys.h>
|
|
24 |
#include <USBClassChangeUIPlugin.rsg> // Resources
|
|
25 |
#include <coemain.h>
|
|
26 |
#include <usbpersonalityids.h>
|
|
27 |
#include <avkon.mbg>
|
|
28 |
#include <usbui.mbg>
|
|
29 |
#include <aknappui.h>
|
|
30 |
#include <AknIconArray.h>
|
|
31 |
#include <aknlists.h>
|
|
32 |
#include <featmgr.h>
|
|
33 |
|
|
34 |
#include "USBClassChangeUIPluginModel.h"
|
|
35 |
#include "USBClassChangeUIPluginDebug.h"
|
|
36 |
#include "USBClassChangeUIPlugin.h"
|
|
37 |
#include "USBClassChangeUIPluginView.h"
|
|
38 |
|
|
39 |
_LIT( KFirstTab, "%d\t" );
|
|
40 |
_LIT( KSecondTab, "\t" );
|
|
41 |
_LIT(KUSBUIEmptyString, "0\t \t ");
|
|
42 |
|
|
43 |
#if defined(__WINS__) && !defined(__USB_EMULATION__)
|
|
44 |
// There are two situations under emulator:
|
|
45 |
// 1. Do not use UsbManager and UsbWatcher, which is the normal case, and
|
|
46 |
// 2. Use UsbManagerDummy and UsbWatcherDummy, for UI testing.
|
|
47 |
// Comment the define line for case 2.
|
|
48 |
#define NO_USBWATCHER_USBMANAGER
|
|
49 |
#endif //__WINS__
|
|
50 |
|
|
51 |
// ================= MEMBER FUNCTIONS ==========================================
|
|
52 |
//
|
|
53 |
|
|
54 |
CUSBClassChangeUIPluginModel::CUSBClassChangeUIPluginModel()
|
|
55 |
: CActive( EPriorityNormal ), iUsbWatcherConnected(EFalse)
|
|
56 |
{
|
|
57 |
CActiveScheduler::Add(this);
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
// Destructor
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
//
|
|
65 |
CUSBClassChangeUIPluginModel::~CUSBClassChangeUIPluginModel()
|
|
66 |
{
|
|
67 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::Destructor"));
|
|
68 |
|
|
69 |
Cancel();
|
|
70 |
delete iCRPersonalityWatcher;
|
|
71 |
delete iDeviceStateWatcher;
|
|
72 |
delete iOtgHostStateWatcher;
|
|
73 |
delete iRepository;
|
|
74 |
iUsbModeIndexes.Close();
|
|
75 |
#ifndef NO_USBWATCHER_USBMANAGER //UsbWatcher/UsbManager API N/A
|
|
76 |
iUsbman.Close();
|
|
77 |
iUsbWatcher.Close();
|
|
78 |
iDeviceIDs.Close();
|
|
79 |
#endif //NO_USBWATCHER_USBMANAGER
|
|
80 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::Destructor complete"));
|
|
81 |
}
|
|
82 |
|
|
83 |
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
// CUSBClassChangeUIPluginModel::ConstructL()
|
|
86 |
// Symbian 2nd phase constructor can leave.
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
void CUSBClassChangeUIPluginModel::ConstructL()
|
|
90 |
{
|
|
91 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::ConstructL()"));
|
|
92 |
|
|
93 |
iCRPersonalityWatcher = CUSBClassChangeUIPluginCRWatcher::NewL( *this,
|
|
94 |
KUsbWatcherPersonality);
|
|
95 |
|
|
96 |
iUsbModeIndexes = RArray<TInt>(KUSBClassChangeUISupportedModesGranularity);
|
|
97 |
iRepository = CRepository::NewL( KCRUidUsbWatcher );
|
|
98 |
|
|
99 |
#ifndef NO_USBWATCHER_USBMANAGER //UsbWatcher/UsbManager API N/A
|
|
100 |
User::LeaveIfError(iUsbman.Connect());
|
|
101 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::ConstructL() iUsbman OK"));
|
|
102 |
|
|
103 |
iDeviceStateWatcher = CUSBDeviceStateWatcher::NewL(*this, iUsbman);
|
|
104 |
iOtgHostStateWatcher = CUSBOtgHostStateWatcher::NewL(*this, iUsbman);
|
|
105 |
iDeviceIDs.ReserveL(1);
|
|
106 |
|
|
107 |
#endif //NO_USBWATCHER_USBMANAGER
|
|
108 |
|
|
109 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::ConstructL() complete"));
|
|
110 |
}
|
|
111 |
|
|
112 |
|
|
113 |
// -----------------------------------------------------------------------------
|
|
114 |
// CUSBClassChangeUIPluginModel::NewL
|
|
115 |
// Two-phased constructor.
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
//
|
|
118 |
CUSBClassChangeUIPluginModel* CUSBClassChangeUIPluginModel::NewL()
|
|
119 |
{
|
|
120 |
FLOG(_L("[CUSBClassChangeUIPlugin]\tCUSBClassChangeUIPluginModel:NewL"));
|
|
121 |
CUSBClassChangeUIPluginModel* self
|
|
122 |
= new (ELeave) CUSBClassChangeUIPluginModel();
|
|
123 |
CleanupStack::PushL( self );
|
|
124 |
self->ConstructL();
|
|
125 |
CleanupStack::Pop( self );
|
|
126 |
return self;
|
|
127 |
}
|
|
128 |
|
|
129 |
// -----------------------------------------------------------------------------
|
|
130 |
// CUSBClassChangeUIPluginModel::SetUSBModeL
|
|
131 |
// Sets the Central Repository key to the parameter.
|
|
132 |
// -----------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
void CUSBClassChangeUIPluginModel::SetUSBModeL(TInt aMode)
|
|
135 |
{
|
|
136 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SetUSBModeL()"));
|
|
137 |
|
|
138 |
// Only change the value if necessary
|
|
139 |
TInt usbMode = USBMode();
|
|
140 |
if (usbMode != aMode)
|
|
141 |
{
|
|
142 |
#ifndef NO_USBWATCHER_USBMANAGER //UsbWatcher/UsbManager API N/A
|
|
143 |
// Change the personality asynchrously, result checked in RunL()
|
|
144 |
if( IsActive() )
|
|
145 |
{
|
|
146 |
Cancel();
|
|
147 |
}
|
|
148 |
if ( (!iUsbWatcherConnected) && (iUsbWatcher.Connect() == KErrNone) )
|
|
149 |
{
|
|
150 |
iUsbWatcherConnected = ETrue;
|
|
151 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SetUSBModeL iUsbWatcher connected"));
|
|
152 |
}
|
|
153 |
if (iUsbWatcherConnected)
|
|
154 |
{
|
|
155 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SetUSBModeL setting personality"));
|
|
156 |
iUsbWatcher.SetPersonality(iStatus, aMode);
|
|
157 |
SetActive();
|
|
158 |
}
|
|
159 |
#endif //NO_USBWATCHER_USBMANAGER
|
|
160 |
}
|
|
161 |
|
|
162 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SetUSBModeL complete"));
|
|
163 |
}
|
|
164 |
|
|
165 |
void CUSBClassChangeUIPluginModel::RunL()
|
|
166 |
{
|
|
167 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::RunL()"));
|
|
168 |
|
|
169 |
//Check the return value of SetPersonality()
|
|
170 |
//Leave if KErrDiskFull
|
|
171 |
if( iStatus == KErrDiskFull ) // Other errors not leave
|
|
172 |
{
|
|
173 |
User::Leave( KErrDiskFull );
|
|
174 |
}
|
|
175 |
|
|
176 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::RunL complete"));
|
|
177 |
}
|
|
178 |
|
|
179 |
void CUSBClassChangeUIPluginModel::DoCancel()
|
|
180 |
{
|
|
181 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::DoCancel()"));
|
|
182 |
|
|
183 |
if (iUsbWatcherConnected)
|
|
184 |
{
|
|
185 |
iUsbWatcher.CancelSetPersonality();
|
|
186 |
}
|
|
187 |
|
|
188 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::DoCancel complete()"));
|
|
189 |
}
|
|
190 |
|
|
191 |
// -----------------------------------------------------------------------------
|
|
192 |
// CUSBClassChangeUIPluginModel::USBMode
|
|
193 |
// Returns the value in Central Repository.
|
|
194 |
// -----------------------------------------------------------------------------
|
|
195 |
//
|
|
196 |
TInt CUSBClassChangeUIPluginModel::USBMode()
|
|
197 |
{
|
|
198 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::USBMode()"));
|
|
199 |
TInt mode = 0;
|
|
200 |
iRepository->Get(KUsbWatcherPersonality, mode);
|
|
201 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::USBMode complete"));
|
|
202 |
return mode;
|
|
203 |
}
|
|
204 |
|
|
205 |
// -----------------------------------------------------------------------------
|
|
206 |
// CUSBClassChangeUIPluginModel::GetDeviceState
|
|
207 |
// Gets the current device state
|
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
//
|
|
210 |
TInt CUSBClassChangeUIPluginModel::GetDeviceState(TUsbDeviceState& aState)
|
|
211 |
{
|
|
212 |
#ifdef NO_USBWATCHER_USBMANAGER //UsbWatcher/UsbManager API N/A
|
|
213 |
aState = EUsbDeviceStateUndefined;
|
|
214 |
return KErrNone;
|
|
215 |
#else
|
|
216 |
return iUsbman.GetDeviceState(aState);
|
|
217 |
#endif
|
|
218 |
}
|
|
219 |
|
|
220 |
// -----------------------------------------------------------------------------
|
|
221 |
// CUSBClassChangeUIPluginModel::GetDescription
|
|
222 |
// Gets description for the specified USB mode (personality ID)
|
|
223 |
// -----------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
TInt CUSBClassChangeUIPluginModel::GetDescription(TInt aMode, HBufC*& aDescription)
|
|
226 |
{
|
|
227 |
return iUsbman.GetDescription(aMode, aDescription);
|
|
228 |
}
|
|
229 |
|
|
230 |
// -----------------------------------------------------------------------------
|
|
231 |
// CUSBClassChangeUIPluginModel::UpdateMainContainerReference
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
//
|
|
234 |
void CUSBClassChangeUIPluginModel::SetSettingsObserver(MUSBUIObserver* aObserver)
|
|
235 |
{
|
|
236 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SetSettingsObserver()"));
|
|
237 |
iObserver = aObserver;
|
|
238 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SetSettingsObserver complete"));
|
|
239 |
}
|
|
240 |
|
|
241 |
// -----------------------------------------------------------------------------
|
|
242 |
// CUSBClassChangeUIPluginModel::GetSupportedUSBModesL
|
|
243 |
// Reads the supported USB Modes from USBManager
|
|
244 |
// The lists received as parameters are updated.
|
|
245 |
// -----------------------------------------------------------------------------
|
|
246 |
//
|
|
247 |
void CUSBClassChangeUIPluginModel::SupportedUSBModeArraysL(
|
|
248 |
CDesCArrayFlat& aListBox,CDesCArrayFlat& aListBoxDefault,
|
|
249 |
CDesCArrayFlat& aListBoxActive, CDesCArrayFlat& aPopUpItems,
|
|
250 |
CArrayPtrFlat<CGulIcon>& aIconArray)
|
|
251 |
{
|
|
252 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SupportedUSBModeArraysL()"));
|
|
253 |
RArray<TInt> personalityIds;
|
|
254 |
CleanupClosePushL( personalityIds );
|
|
255 |
HBufC* usbModeListBox = NULL;
|
|
256 |
HBufC* usbModeListBoxActive = NULL;
|
|
257 |
|
|
258 |
// Allocate memory for descriptors to hold texts for listbox
|
|
259 |
usbModeListBox = HBufC::NewLC( KUsbStringDescStringMaxSize );
|
|
260 |
TPtr usbModeListBoxPtr = usbModeListBox->Des();
|
|
261 |
|
|
262 |
usbModeListBoxActive = HBufC::NewLC( KUsbStringDescStringMaxSize );
|
|
263 |
TPtr usbModeListBoxActivePtr = usbModeListBoxActive->Des();
|
|
264 |
|
|
265 |
HBufC* usbDefaultText = NULL;
|
|
266 |
usbDefaultText = CCoeEnv::Static()->AllocReadResourceLC( R_USB_MODE_DEFAULT );
|
|
267 |
|
|
268 |
HBufC* usbActiveText = NULL;
|
|
269 |
usbActiveText = CCoeEnv::Static()->AllocReadResourceLC( R_USB_MODE_ACTIVE );
|
|
270 |
|
|
271 |
//Check phone as modem is supported or not
|
|
272 |
FeatureManager::InitializeLibL();
|
|
273 |
TBool phoneAsModemSupported = FeatureManager::FeatureSupported(
|
|
274 |
KFeatureIdUsbModem );
|
|
275 |
FeatureManager::UnInitializeLib();
|
|
276 |
|
|
277 |
// Get personality ids
|
|
278 |
iPersonalityCount = 0;
|
|
279 |
#ifndef NO_USBWATCHER_USBMANAGER //UsbWatcher/UsbManager API N/A
|
|
280 |
if (iUsbman.GetPersonalityIds(personalityIds) == KErrNone)
|
|
281 |
{
|
|
282 |
FLOG(_L("CUSBClassChangeUIPluginModel::SupportedUSBModeArraysL(): Personality Ids got"));
|
|
283 |
for (TInt i = 0; i < personalityIds.Count(); i++)
|
|
284 |
{
|
|
285 |
FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t i= %d "), i));
|
|
286 |
|
|
287 |
if (personalityIds[i] == KUsbPersonalityIdModemInst)
|
|
288 |
{
|
|
289 |
if (!phoneAsModemSupported)
|
|
290 |
{
|
|
291 |
FLOG(_L("Phone as modem is not supported!"));
|
|
292 |
continue;
|
|
293 |
}
|
|
294 |
}
|
|
295 |
|
|
296 |
TUint32 property;
|
|
297 |
TInt ret = iUsbman.GetPersonalityProperty(personalityIds[i], property);
|
|
298 |
if (ret == KErrNone)
|
|
299 |
{
|
|
300 |
FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin] property\t i= 0x%x "), property));
|
|
301 |
if (property & KUsbPersonalityPropertyHidden)
|
|
302 |
{
|
|
303 |
FLOG(_L("CUSBClassChangeUIPluginModel::SupportedUSBModeArraysL(): The Personality is hidden"));
|
|
304 |
continue;
|
|
305 |
}
|
|
306 |
}
|
|
307 |
else
|
|
308 |
{
|
|
309 |
FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin] Error to get the property\t i= %d "), ret));
|
|
310 |
}
|
|
311 |
|
|
312 |
HBufC* description = NULL;
|
|
313 |
HBufC* detailDescription = NULL;
|
|
314 |
|
|
315 |
if (iUsbman.GetDescription(personalityIds[i], description) == KErrNone)
|
|
316 |
{
|
|
317 |
CleanupStack::PushL(description);
|
|
318 |
FLOG(_L("CUSBClassChangeUIPluginModel::SupportedUSBModeArraysL(): Description read"));
|
|
319 |
//mode strings for setting page
|
|
320 |
TPtr descriptionPtr = description->Des();
|
|
321 |
iUsbModeIndexes.Append(personalityIds[i]);
|
|
322 |
|
|
323 |
//modes with labels for list box
|
|
324 |
usbModeListBoxPtr.Zero();
|
|
325 |
usbModeListBoxActivePtr.Zero();
|
|
326 |
|
|
327 |
usbModeListBoxPtr.Format(KFirstTab, iPersonalityCount);
|
|
328 |
usbModeListBoxPtr.Append(descriptionPtr);
|
|
329 |
usbModeListBoxPtr.Append(KSecondTab);
|
|
330 |
|
|
331 |
usbModeListBoxActivePtr.Copy(usbModeListBoxPtr);
|
|
332 |
|
|
333 |
aListBox.AppendL(usbModeListBoxPtr);
|
|
334 |
|
|
335 |
usbModeListBoxPtr.Append(*usbDefaultText);
|
|
336 |
usbModeListBoxActivePtr.Append(*usbActiveText);
|
|
337 |
|
|
338 |
aListBoxDefault.AppendL(usbModeListBoxPtr);
|
|
339 |
aListBoxActive.AppendL(usbModeListBoxActivePtr);
|
|
340 |
|
|
341 |
CleanupStack::PopAndDestroy(description);
|
|
342 |
//creating the icon list
|
|
343 |
AddIconL (personalityIds[i], aIconArray);
|
|
344 |
if (iUsbman.GetDetailedDescription(personalityIds[i], detailDescription) == KErrNone)
|
|
345 |
{
|
|
346 |
CleanupStack::PushL(detailDescription);
|
|
347 |
aPopUpItems.AppendL(detailDescription->Des());
|
|
348 |
CleanupStack::PopAndDestroy(detailDescription);
|
|
349 |
}
|
|
350 |
else
|
|
351 |
{
|
|
352 |
aPopUpItems.AppendL(KNullDesC);
|
|
353 |
}
|
|
354 |
iPersonalityCount++;
|
|
355 |
}
|
|
356 |
|
|
357 |
}
|
|
358 |
}
|
|
359 |
#endif // NO_USBWATCHER_USBMANAGER
|
|
360 |
|
|
361 |
if (iPersonalityCount == 0)
|
|
362 |
{
|
|
363 |
// Add empty value
|
|
364 |
AddIconL (iPersonalityCount, aIconArray);
|
|
365 |
iUsbModeIndexes.AppendL(0);
|
|
366 |
aPopUpItems.AppendL(KNullDesC);
|
|
367 |
aListBox.AppendL(KUSBUIEmptyString);
|
|
368 |
aListBoxDefault.AppendL(KUSBUIEmptyString);
|
|
369 |
aListBoxActive.AppendL(KUSBUIEmptyString);
|
|
370 |
}
|
|
371 |
|
|
372 |
CleanupStack::PopAndDestroy( usbActiveText );
|
|
373 |
CleanupStack::PopAndDestroy( usbDefaultText );
|
|
374 |
CleanupStack::PopAndDestroy( usbModeListBoxActive );
|
|
375 |
CleanupStack::PopAndDestroy( usbModeListBox );
|
|
376 |
CleanupStack::PopAndDestroy( &personalityIds );
|
|
377 |
|
|
378 |
FLOG(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SupportedUSBModeArraysL() complete"));
|
|
379 |
}
|
|
380 |
|
|
381 |
// ----------------------------------------------------------------------------
|
|
382 |
// CUSBClassChangeUIPluginModel::AddIconL()
|
|
383 |
// creates the icon list
|
|
384 |
//
|
|
385 |
// ----------------------------------------------------------------------------
|
|
386 |
//
|
|
387 |
void CUSBClassChangeUIPluginModel::AddIconL (TInt aMode, CArrayPtrFlat<CGulIcon>& aIconArray )
|
|
388 |
{
|
|
389 |
FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::AddIconL()"));
|
|
390 |
TFileName usbUiIconFilename( KFileDrive );
|
|
391 |
usbUiIconFilename += KDC_APP_BITMAP_DIR;
|
|
392 |
usbUiIconFilename += KUSBUIconFileName;
|
|
393 |
|
|
394 |
switch (aMode)
|
|
395 |
{
|
|
396 |
case KUsbPersonalityIdPCSuite:
|
|
397 |
case KUsbPersonalityIdPCSuiteMTP:
|
|
398 |
CreateAndAppendIconL( KAknsIIDQgnPropUsbPcsuite,
|
|
399 |
usbUiIconFilename,
|
|
400 |
EMbmUsbuiQgn_prop_usb_pcsuite,
|
|
401 |
EMbmUsbuiQgn_prop_usb_pcsuite_mask,
|
|
402 |
aIconArray);
|
|
403 |
break;
|
|
404 |
case KUsbPersonalityIdMS:
|
|
405 |
CreateAndAppendIconL( KAknsIIDQgnPropUsbMemcLarge,
|
|
406 |
usbUiIconFilename,
|
|
407 |
EMbmUsbuiQgn_prop_usb_memc_large,
|
|
408 |
EMbmUsbuiQgn_prop_usb_memc_large_mask,
|
|
409 |
aIconArray);
|
|
410 |
break;
|
|
411 |
case KUsbPersonalityIdPTP:
|
|
412 |
CreateAndAppendIconL( KAknsIIDQgnPropUsbPrint,
|
|
413 |
usbUiIconFilename,
|
|
414 |
EMbmUsbuiQgn_prop_usb_print,
|
|
415 |
EMbmUsbuiQgn_prop_usb_print_mask,
|
|
416 |
aIconArray);
|
|
417 |
break;
|
|
418 |
case KUsbPersonalityIdMTP:
|
|
419 |
CreateAndAppendIconL( KAknsIIDQgnPropUsbMtp,
|
|
420 |
usbUiIconFilename,
|
|
421 |
EMbmUsbuiQgn_prop_usb_mtp,
|
|
422 |
EMbmUsbuiQgn_prop_usb_mtp_mask,
|
|
423 |
aIconArray);
|
|
424 |
break;
|
|
425 |
case KUsbPersonalityIdModemInst:
|
|
426 |
CreateAndAppendIconL( KAknsIIDQgnPropUsbModem,
|
|
427 |
usbUiIconFilename,
|
|
428 |
EMbmUsbuiQgn_prop_usb_modem,
|
|
429 |
EMbmUsbuiQgn_prop_usb_modem_mask,
|
|
430 |
aIconArray);
|
|
431 |
break;
|
|
432 |
default:
|
|
433 |
CreateAndAppendIconL( KAknsIIDQgnPropSetAppsUsb,
|
|
434 |
usbUiIconFilename,
|
|
435 |
EMbmUsbuiQgn_prop_set_apps_usb,
|
|
436 |
EMbmUsbuiQgn_prop_set_apps_usb_mask,
|
|
437 |
aIconArray);
|
|
438 |
break;
|
|
439 |
}
|
|
440 |
FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::AddIconL() completed"));
|
|
441 |
}
|
|
442 |
// ----------------------------------------------------
|
|
443 |
// CUSBClassChangeUIPluginContainer::CreateAndAppendIconL
|
|
444 |
// ----------------------------------------------------
|
|
445 |
void CUSBClassChangeUIPluginModel::CreateAndAppendIconL(
|
|
446 |
const TAknsItemID& aID,
|
|
447 |
const TDesC& aFileName,
|
|
448 |
const TInt aBitmapId,
|
|
449 |
const TInt aMaskId,
|
|
450 |
CArrayPtrFlat<CGulIcon>& aIconArray)
|
|
451 |
{
|
|
452 |
FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::CreateAndAppendIconL"));
|
|
453 |
|
|
454 |
CGulIcon* icon = AknsUtils::CreateGulIconL(AknsUtils::SkinInstance(),
|
|
455 |
aID, aFileName, aBitmapId, aMaskId);
|
|
456 |
|
|
457 |
CleanupStack::PushL(icon);
|
|
458 |
aIconArray.AppendL(icon);
|
|
459 |
CleanupStack::Pop(icon);
|
|
460 |
FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::CreateAndAppendIconL completed"));
|
|
461 |
|
|
462 |
}
|
|
463 |
|
|
464 |
// ----------------------------------------------------------------------------
|
|
465 |
// CUSBClassChangeUIPluginModel::GetPersonalityCount()
|
|
466 |
// Informs the container, that a setting has changed.
|
|
467 |
//
|
|
468 |
// ----------------------------------------------------------------------------
|
|
469 |
//
|
|
470 |
TInt CUSBClassChangeUIPluginModel::PersonalityCount()
|
|
471 |
{
|
|
472 |
FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t PersonalityCount= %d "), iPersonalityCount));
|
|
473 |
return iPersonalityCount;
|
|
474 |
}
|
|
475 |
// ----------------------------------------------------------------------------
|
|
476 |
// CUSBClassChangeUIPluginModel::SettingChangedL()
|
|
477 |
// Informs the container, that a setting has changed.
|
|
478 |
//
|
|
479 |
// ----------------------------------------------------------------------------
|
|
480 |
//
|
|
481 |
void CUSBClassChangeUIPluginModel::SettingChangedL( TUint32 /*aKey*/ )
|
|
482 |
{
|
|
483 |
FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SettingChangedL()"));
|
|
484 |
|
|
485 |
if ( iObserver )
|
|
486 |
{
|
|
487 |
iObserver->SettingChanged();
|
|
488 |
}
|
|
489 |
|
|
490 |
FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::SettingChangedL() completed"));
|
|
491 |
}
|
|
492 |
|
|
493 |
// ----------------------------------------------------------------------------
|
|
494 |
// From MUSBOtgHostStateObserver
|
|
495 |
// Handle Otg Id pin on/off notification
|
|
496 |
// ----------------------------------------------------------------------------
|
|
497 |
void CUSBClassChangeUIPluginModel::OtgHostIdPinStateChanged(TBool aIsIdPinOn)
|
|
498 |
{
|
|
499 |
iDeviceIDs.Reset();
|
|
500 |
if (iObserver)
|
|
501 |
{
|
|
502 |
iObserver->OtgHostIdPinStateChanged(aIsIdPinOn);
|
|
503 |
}
|
|
504 |
}
|
|
505 |
|
|
506 |
// ----------------------------------------------------------------------------
|
|
507 |
// From MUSBOtgHostStateObserver
|
|
508 |
// Handle host event notification
|
|
509 |
// ----------------------------------------------------------------------------
|
|
510 |
void CUSBClassChangeUIPluginModel::HostEventNotify(TDeviceEventInformation aEventInfo)
|
|
511 |
{
|
|
512 |
if (iObserver)
|
|
513 |
{
|
|
514 |
FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::HostEventNotify"));
|
|
515 |
FTRACE( FPrint(_L( "[CUSBClassChangeUIPlugin]\t iEventInfo.iDeviceId = %d" ), aEventInfo.iDeviceId));
|
|
516 |
FTRACE( FPrint(_L( "[CUSBClassChangeUIPlugin]\t iEventInfo.iEventType = %d" ), aEventInfo.iEventType));
|
|
517 |
FTRACE( FPrint(_L( "[CUSBClassChangeUIPlugin]\t iEventInfo.iError = %d" ), aEventInfo.iError));
|
|
518 |
FTRACE( FPrint(_L( "[CUSBClassChangeUIPlugin]\t iEventInfo.iDriverLoadStatus = %d" ), aEventInfo.iDriverLoadStatus));
|
|
519 |
FTRACE( FPrint(_L( "[CUSBClassChangeUIPlugin]\t iEventInfo.iVid = %d" ), aEventInfo.iVid));
|
|
520 |
FTRACE( FPrint(_L( "[CUSBClassChangeUIPlugin]\t iEventInfo.iPid = %d" ), aEventInfo.iPid));
|
|
521 |
|
|
522 |
switch (aEventInfo.iEventType)
|
|
523 |
{
|
|
524 |
case EDeviceAttachment:
|
|
525 |
{
|
|
526 |
iObserver->HostEventNotify(aEventInfo);
|
|
527 |
break;
|
|
528 |
}
|
|
529 |
case EDeviceDetachment:
|
|
530 |
{
|
|
531 |
TInt index = iDeviceIDs.Find(aEventInfo.iDeviceId);
|
|
532 |
if (index >= 0)
|
|
533 |
{
|
|
534 |
iDeviceIDs.Remove(index);
|
|
535 |
}
|
|
536 |
iObserver->HostEventNotify(aEventInfo);
|
|
537 |
break;
|
|
538 |
}
|
|
539 |
case EDriverLoad:
|
|
540 |
{
|
|
541 |
switch (aEventInfo.iDriverLoadStatus)
|
|
542 |
{
|
|
543 |
case EDriverLoadSuccess:
|
|
544 |
case EDriverLoadPartialSuccess:
|
|
545 |
{
|
|
546 |
// Drivers are loaded more or less successfully
|
|
547 |
TInt ret = iDeviceIDs.Append(aEventInfo.iDeviceId);
|
|
548 |
if (ret != KErrNone)
|
|
549 |
{
|
|
550 |
FLOG( _L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::HostEventNotify *** append error"));
|
|
551 |
}
|
|
552 |
iObserver->HostEventNotify(aEventInfo);
|
|
553 |
break;
|
|
554 |
}
|
|
555 |
}
|
|
556 |
break;
|
|
557 |
}
|
|
558 |
}
|
|
559 |
}
|
|
560 |
}
|
|
561 |
|
|
562 |
// ----------------------------------------------------------------------------
|
|
563 |
// Informs the observer that USB device state has changed.
|
|
564 |
// ----------------------------------------------------------------------------
|
|
565 |
void CUSBClassChangeUIPluginModel::DeviceStateChanged(
|
|
566 |
TUsbDeviceState aPreviousState, TUsbDeviceState aCurrentState)
|
|
567 |
{
|
|
568 |
if (iObserver)
|
|
569 |
{
|
|
570 |
iObserver->DeviceStateChanged(aPreviousState, aCurrentState);
|
|
571 |
}
|
|
572 |
}
|
|
573 |
|
|
574 |
// ----------------------------------------------------------------------------
|
|
575 |
// CUSBClassChangeUIPluginModel::GetUsbIds()
|
|
576 |
// Return an RArray of the personality indexes
|
|
577 |
//
|
|
578 |
// ----------------------------------------------------------------------------
|
|
579 |
//
|
|
580 |
RArray<TInt>& CUSBClassChangeUIPluginModel::GetUsbIds()
|
|
581 |
{
|
|
582 |
return iUsbModeIndexes;
|
|
583 |
}
|
|
584 |
// ----------------------------------------------------------------------------
|
|
585 |
// Returns if it's A-device and the driver to the attached pheripheral
|
|
586 |
// is loaded successfully(or partially).
|
|
587 |
// ----------------------------------------------------------------------------
|
|
588 |
//
|
|
589 |
TInt CUSBClassChangeUIPluginModel::HasPeripheralEnabled(TBool& aHasPeripheralEnabled)
|
|
590 |
{
|
|
591 |
aHasPeripheralEnabled = EFalse;
|
|
592 |
#ifdef NO_USBWATCHER_USBMANAGER ////UsbWatcher/UsbManager API N/A
|
|
593 |
return KErrNone;
|
|
594 |
#else
|
|
595 |
TBool idPinOn;
|
|
596 |
TInt ret = iOtgHostStateWatcher->IsIdPinOn(idPinOn);
|
|
597 |
if (ret != KErrNone || !idPinOn)
|
|
598 |
{
|
|
599 |
return ret;
|
|
600 |
}
|
|
601 |
|
|
602 |
//aHasPeripheralEnabled = (iDeviceIDs.Count() > 0 ? ETrue : EFalse);
|
|
603 |
ret = iOtgHostStateWatcher->IsPeripheralConnected(aHasPeripheralEnabled);
|
|
604 |
if (ret != KErrNone)
|
|
605 |
{
|
|
606 |
return ret;
|
|
607 |
}
|
|
608 |
|
|
609 |
FTRACE(FPrint(_L("[CUSBClassChangeUIPlugin]\t CUSBClassChangeUIPluginModel::HasPeripheralEnabled - aHasPeripheralEnabled=%d"), aHasPeripheralEnabled));
|
|
610 |
|
|
611 |
return KErrNone;
|
|
612 |
#endif
|
|
613 |
}
|
|
614 |
|
|
615 |
// End of file
|