# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1268984932 -7200 # Node ID 8c311f9acc5ea2024e078374955171092ae7ec85 # Parent 7e15987c450072d930a73570d3fdd4195b69cf8e Revision: 201007 Kit: 201011 diff -r 7e15987c4500 -r 8c311f9acc5e layers.sysdef.xml --- a/layers.sysdef.xml Tue Feb 02 00:52:37 2010 +0200 +++ b/layers.sysdef.xml Fri Mar 19 09:48:52 2010 +0200 @@ -1,24 +1,23 @@ - ]> - + - + - + + + + + - - - - - diff -r 7e15987c4500 -r 8c311f9acc5e sysdef_1_4_0.dtd --- a/sysdef_1_4_0.dtd Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 7e15987c4500 -r 8c311f9acc5e sysdef_1_5_1.dtd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdef_1_5_1.dtd Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 7e15987c4500 -r 8c311f9acc5e tsrc/group/bld.inf --- a/tsrc/group/bld.inf Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* -* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Build information file for project -* -*/ - - -PRJ_PLATFORMS -DEFAULT - -//build files for shortlinkconn -#include "../../../shortlinkconn/localconnectivityservice/lcstylustap/tsrc/LcStylusTapTest/group/bld.inf" -#include "../../../shortlinkconn/localconnectivityservice/generichid/tsrc/GenericHidTest/group/bld.inf" - -//build files for usb -#include "../../usbclasses/msmmplugin/tsrc/MsmmPluginTest/group/bld.inf" -#include "../../usbuis/usbui/tsrc/USBUiApiTest/group/bld.inf" -#include "../../usbuis/usbuinotif/tsrc/USBUiNotifApiTest/group/bld.inf" -#include "../../usbclasses/usbhidclassdriver/tsrc/UsbHidClassDriverTest/group/bld.inf" - - -PRJ_EXPORTS - - -PRJ_MMPFILES - -PRJ_TESTMMPFILES - -PRJ_TESTEXPORTS diff -r 7e15987c4500 -r 8c311f9acc5e usbclasses/usbmscpersonality/inc/CUsbActiveMscHandlerMdrv.h --- a/usbclasses/usbmscpersonality/inc/CUsbActiveMscHandlerMdrv.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbclasses/usbmscpersonality/inc/CUsbActiveMscHandlerMdrv.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -415,6 +415,11 @@ TBool iMountChanged; /** + * If query note shown by us + */ + TBool iIsQueryNoteShown; + + /** * Used to load devenccommonutils.dll and check the device encryption status */ RLibrary iLibrary; diff -r 7e15987c4500 -r 8c311f9acc5e usbclasses/usbmscpersonality/src/CUsbActiveMscHandlerMdrv.cpp --- a/usbclasses/usbmscpersonality/src/CUsbActiveMscHandlerMdrv.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbclasses/usbmscpersonality/src/CUsbActiveMscHandlerMdrv.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -47,7 +47,9 @@ // ---------------------------------------------------------------------------- // CUsbActiveMscHandler::CUsbActiveMscHandler(TUsbPersonalityParams& aPersonalityParams) - : CUsbPersonalityPlugin(aPersonalityParams), iMountChanged(EFalse) + : CUsbPersonalityPlugin(aPersonalityParams), + iMountChanged(EFalse), + iIsQueryNoteShown(EFalse) { CActiveScheduler::Add( this ); } @@ -256,9 +258,13 @@ RemoveMassStorageFileSystem(); - // Remove all queries shown by this personality - iPersonalityParams.PersonalityNotifier().CancelQuery(KQueriesNotifier); - + if (iIsQueryNoteShown) + { + // Remove all queries shown by this personality + iPersonalityParams.PersonalityNotifier().CancelQuery(KQueriesNotifier); + iIsQueryNoteShown = EFalse; + } + iMscState = EUsbMscStateIdle; iRequestStatus = &aStatus; @@ -295,6 +301,7 @@ { if ( GlobalSystemState() == EUsbGSStateCategoryNormal ) { + iIsQueryNoteShown = ETrue; // if the error is something abnormal, note still needs to be shown iQueryParams().iQuery = EUSBStorageMediaFailure; iPersonalityParams.PersonalityNotifier().ShowQuery( @@ -491,6 +498,7 @@ { FLOG( _L( "[USBWATCHER]\tCUsbActiveMscHandler::GetDrives: No removable drives found." ) ); + iIsQueryNoteShown = ETrue; iQueryParams().iQuery = EUSBStorageMediaFailure; iPersonalityParams.PersonalityNotifier().ShowQuery(KQueriesNotifier, iQueryParams, iDummy); diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/group/usbotgwatcher.mmp --- a/usbengines/usbotgwatcher/group/usbotgwatcher.mmp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/group/usbotgwatcher.mmp Fri Mar 19 09:48:52 2010 +0200 @@ -39,16 +39,18 @@ SOURCE cusbotgwatcher.cpp SOURCE cusbservicecontrol.cpp -SOURCE cusbpersonalityswitch.cpp SOURCE cusbstate.cpp SOURCE cusbstatehostabase.cpp -SOURCE cusbstatehostainitiatebase.cpp SOURCE cusbstatehostainitiate.cpp SOURCE cusbstatehostahost.cpp SOURCE cusbstatehostaperipheral.cpp -SOURCE cusbstatehostaidle.cpp -SOURCE cusbstatehosthandle.cpp +SOURCE cusbstatehosthandle.cpp +SOURCE cusbstatehostdelayhandle.cpp +SOURCE cusbstatehostdelayattachedhandle.cpp +SOURCE cusbstatehostdelaynotattachedhandle.cpp +SOURCE cusbstatehosthandledropping.cpp +SOURCE cusbstatehostundefined.cpp SOURCE cusbwaitnotifier.cpp SOURCE cusbnotifmanager.cpp diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbbusactivityobserver.h --- a/usbengines/usbotgwatcher/inc/cusbbusactivityobserver.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbbusactivityobserver.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Monitors USB activity + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Monitors USB activity + * + */ #ifndef C_USBBUSACTIVITYOBSERVER_H #define C_USBBUSACTIVITYOBSERVER_H @@ -39,13 +38,13 @@ * Called when when bus is in Idle, and some activity appears on the bus */ virtual void BusActiveL() = 0; - + /** - * Called when when error happened - * @param aError errorcode - */ - virtual void BusActivityErrorL(TInt aError) = 0; - + * Called when when error happened + * @param aError errorcode + */ + virtual void BusActivityErrorL(TInt aError) = 0; + }; /** @@ -82,13 +81,13 @@ * Adds subscriber for the notification * @param aObserver Observer */ - void SubscribeL(MUsbBusActivityObserver* aObserver); + void SubscribeL(MUsbBusActivityObserver& aObserver); /** * Removes observer * @param aObserver Observer */ - void UnsubscribeL(MUsbBusActivityObserver* aObserver); + void UnsubscribeL(MUsbBusActivityObserver& aObserver); private: @@ -126,7 +125,7 @@ /** * The observer reports state changes to own observers - * Owns + * Not owns */ RPointerArray iObservers; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbhosteventnotificationobserver.h --- a/usbengines/usbotgwatcher/inc/cusbhosteventnotificationobserver.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbhosteventnotificationobserver.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Monitors host events + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Monitors host events + * + */ #ifndef C_USBHOSTEVENTNOTIFICATIONOBSERVER_H #define C_USBHOSTEVENTNOTIFICATIONOBSERVER_H @@ -63,11 +62,11 @@ * @param aInfo additional information */ virtual void DriverLoadFailureL(TDeviceEventInformation aInfo) = 0; - + /** - * Called when error happens while observing - * @param aError error code - */ + * Called when error happens while observing + * @param aError error code + */ virtual void HostEventNotificationErrorL(TInt aError) = 0; }; @@ -96,13 +95,13 @@ * Add observer to list of observers * @param aObserver observer */ - void SubscribeL(MUsbHostEventNotificationObserver* aObserver); + void SubscribeL(MUsbHostEventNotificationObserver& aObserver); /** * Removes observer from list of observers * @param aObserver Observer */ - void UnsubscribeL(MUsbHostEventNotificationObserver* aObserver); + void UnsubscribeL(MUsbHostEventNotificationObserver& aObserver); private: @@ -142,7 +141,7 @@ /** * The observer reports changes to own observers - * Owns + * Not owns */ RPointerArray iObservers; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbidpinobserver.h --- a/usbengines/usbotgwatcher/inc/cusbidpinobserver.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbidpinobserver.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Monitors ID pin change + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Monitors ID pin change + * + */ #ifndef C_USBIDPINOBSERVER_H #define C_USBIDPINOBSERVER_H @@ -39,13 +38,12 @@ * IdPin appeared */ virtual void IdPinOnL() = 0; - + /** * IdPin error * @param aError error code */ virtual void IdPinErrorL(TInt aError) = 0; - }; @@ -67,7 +65,7 @@ * @return instance of the objects of this class */ static CUsbIdPinObserver* NewL(); - + /** * Destructor. */ @@ -83,13 +81,13 @@ * Add observer * @param aObserver Observer */ - void SubscribeL(MUsbIdPinObserver* aObserver); + void SubscribeL(MUsbIdPinObserver& aObserver); /** * Remove observer * @param aObserver Observer */ - void UnsubscribeL(MUsbIdPinObserver* aObserver); + void UnsubscribeL(MUsbIdPinObserver& aObserver); private: @@ -128,7 +126,7 @@ /** * The observer reports state changes to its own observers - * Own + * Not own */ RPointerArray iObservers; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbindicatornotifier.h --- a/usbengines/usbotgwatcher/inc/cusbindicatornotifier.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbindicatornotifier.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Blink/show Usb indicator notifier implementation + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Blink/show Usb indicator notifier implementation + * + */ #ifndef C_USBINDICATORNOTIFIER_H #define C_USBINDICATORNOTIFIER_H @@ -23,13 +22,11 @@ #include // SAknSmallIndicatorParams #include // SAknNotifierPackage #include // EAknIndicatorUSBConnection - #include "cusbtimer.h" #include "cusbnotifier.h" #include "cusbvbusobserver.h" #include "cusbotgwatcher.h" - /** * Class implements functionality of showing/blinking usb indicator * Class does not provide method to get response from the user @@ -43,7 +40,7 @@ * @param aOtgWatcher provides VBus observer and usb otg watcher state notifications * @return Pointer to the new instance of CUsbIndicatorNotifier */ - static CUsbIndicatorNotifier* NewL(CUsbNotifManager* aNotifManager, CUsbOtgWatcher* aOtgWatcher); + static CUsbIndicatorNotifier* NewL(CUsbNotifManager& aNotifManager, CUsbOtgWatcher& aOtgWatcher); /** * Destructor. @@ -56,7 +53,7 @@ * @param aState new state */ virtual void OtgWatcherStateChangedL(TUsbStateIds aState); - + // From MUsbVBusObserver /** * VBus down event received @@ -69,10 +66,9 @@ /** * error handler * @param aError error code - */ + */ virtual void VBusObserverErrorL(TInt aError); - - + // From base class CUsbNotifier /** * Start to show notifier @@ -98,7 +94,7 @@ * @param aNotifManger parent * @param aOtgWatcher Otg watcher */ - CUsbIndicatorNotifier(CUsbNotifManager* aNotifManager, CUsbOtgWatcher* aOtgWatcher); + CUsbIndicatorNotifier(CUsbNotifManager& aNotifManager, CUsbOtgWatcher& aOtgWatcher); /** * 2nd phase constructor. @@ -110,7 +106,7 @@ * @param aState Indicator states */ void SetIndicatorStateL(const TInt aState); - + /** * Show/hide static icon of the indicator. * If the indicator is blinking, stop blinking it and show/hide the static @@ -118,17 +114,17 @@ * @param aVisible ETrue - Show the indicator, EFalse - Hide the indicator */ void ShowStaticL(TBool aVisible); - + /** * Blinks indicator */ void BlinkL(); - + /** * Sets indicator accordingly */ void SetIndicatorL(); - + private: // data @@ -136,8 +132,8 @@ * OtgWatcher * not own */ - CUsbOtgWatcher* iOtgWatcher; - + CUsbOtgWatcher& iOtgWatcher; + /** * Switch timer for showing/hiding the usb indicator interleavingly for * animating the indicator. diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbmessagenotificationobserver.h --- a/usbengines/usbotgwatcher/inc/cusbmessagenotificationobserver.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbmessagenotificationobserver.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Observes notifications from usb + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Observes notifications from usb + * + */ #ifndef C_USBMESSAGENOTIFICATIONOBSERVER_H #define C_USBMESSAGENOTIFICATIONOBSERVER_H @@ -58,12 +57,12 @@ * Called when session requested */ virtual void SessionRequestedL() = 0; - + /** - * Called when error happened - * @param aError error code - */ - virtual void MessageNotificationErrorL(TInt aError) = 0; + * Called when error happened + * @param aError error code + */ + virtual void MessageNotificationErrorL(TInt aError) = 0; }; /** @@ -90,13 +89,13 @@ * Subscribes for notifications * @param aObserver observer */ - void SubscribeL(MUsbMessageNotificationObserver* aObserver); + void SubscribeL(MUsbMessageNotificationObserver& aObserver); /** * Unsubscribe from notifications * @param aObserver Observer */ - void UnsubscribeL(MUsbMessageNotificationObserver* aObserver); + void UnsubscribeL(MUsbMessageNotificationObserver& aObserver); private: @@ -139,7 +138,7 @@ /** * The observer reports to own observers - * Owns + * Not owns */ RPointerArray iObservers; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbnotenotifier.h --- a/usbengines/usbotgwatcher/inc/cusbnotenotifier.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbnotenotifier.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Base classes for Usb notifier wrapper + * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Base classes for Usb notifier wrapper + * + */ #ifndef C_CUSBNOTENOTIFIER_H #define C_CUSBNOTENOTIFIER_H @@ -38,62 +37,67 @@ */ class CNotifierActive : public CActive { - public: - /** - * Default constructor - * @param aNotifier RNotifier API - * @param aUsbNoteNotifier the note notifier container - */ - CNotifierActive(RNotifier& aNotifier, CUsbNoteNotifier* aUsbNoteNotifier); - - /** - * Destructor - */ - virtual ~CNotifierActive(); - - /** - * Start to show the notifier - */ - void StartL(); - - protected: - // From base class CActive - /** - * Caled when outstanding request completed - */ - void RunL(); + public: + /** + * Default constructor + * @param aNotifier RNotifier API + * @param aUsbNoteNotifier the note notifier container + */ + CNotifierActive(RNotifier& aNotifier, CUsbNoteNotifier& aUsbNoteNotifier); + + /** + * Destructor + */ + virtual ~CNotifierActive(); + + /** + * Start to show the notifier + */ + void StartL(); + + protected: + // From base class CActive + /** + * Caled when outstanding request completed + */ + void RunL(); - /** - * Called when outstanding request cancelled - */ - void DoCancel(); + /** + * Called when outstanding request cancelled + */ + void DoCancel(); - /** - * Called when RunL leaves - * @param aError errorcode - * @return errorcode - */ - TInt RunError(TInt aError); + /** + * Called when RunL leaves + * @param aError errorcode + * @return errorcode + */ + TInt RunError(TInt aError); - private: - // data + private: + // data - /** - * The note notifier container - * Not Own - */ - CUsbNoteNotifier* iUsbNoteNotifier; - - /** - * RNotifier API - * Not Own - */ - RNotifier& iNotifier; + /** + * The note notifier container + * Not Own + */ + CUsbNoteNotifier& iUsbNoteNotifier; + + /** + * RNotifier API + * Not Own + */ + RNotifier& iNotifier; /** * Response from notifier */ TPckg iRes; + + /** + * Notifier id pckg buffer + */ + TPckgBuf iNotifIdPckg; }; public: @@ -122,14 +126,14 @@ * @param acat Category * @param aNotidId id */ - CUsbNoteNotifier(RNotifier& aNotifier, CUsbNotifManager* aNotifManager, + CUsbNoteNotifier(RNotifier& aNotifier, CUsbNotifManager& aNotifManager, TUid aCat, TUint aNotifId); /** * 2nd phase constructor. */ void ConstructL(); - + private: // data @@ -138,7 +142,7 @@ * Own */ CNotifierActive* iNotifierActive; - + /** * RNotifier API * Not Own diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbnotifier.h --- a/usbengines/usbotgwatcher/inc/cusbnotifier.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbnotifier.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Base classes for Usb notifier wrapper + * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Base classes for Usb notifier wrapper + * + */ #ifndef C_CUSBNOTIFIER_H #define C_CUSBNOTIFIER_H @@ -62,7 +61,7 @@ * @param acat Category * @param aNotidId id */ - CUsbNotifier(CUsbNotifManager* aNotifManager, TUid aCat, TUint aNotifId); + CUsbNotifier(CUsbNotifManager& aNotifManager, TUid aCat, TUint aNotifId); /** * Set by child-class if the concrete notifier needs feedback from end-user @@ -77,7 +76,7 @@ * All notifiers are created, destroied and manupulated by the manager. * Not own */ - CUsbNotifManager* iNotifManager; + CUsbNotifManager& iNotifManager; /** * Category of the notifier. Needed for cancelling diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbnotifmanager.h --- a/usbengines/usbotgwatcher/inc/cusbnotifmanager.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbnotifmanager.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Manages notifiers + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Manages notifiers + * + */ #ifndef C_USBNOTIFMANAGER_H #define C_USBNOTIFMANAGER_H @@ -58,7 +57,7 @@ * aObserver will receive notification when completed */ static CWaitNotifierInfo* NewL(CUsbNotifier* aWaitNotifier, - MWaitNotifierObserver* aObserver); + MWaitNotifierObserver& aObserver); /** * Destructor @@ -83,7 +82,7 @@ * @param aObserver Observer */ CWaitNotifierInfo(CUsbNotifier* aWaitNotifier, - MWaitNotifierObserver* aObserver); + MWaitNotifierObserver& aObserver); /** * 2nd phase construction @@ -102,7 +101,7 @@ * observer * not owns */ - MWaitNotifierObserver* iObserver; + MWaitNotifierObserver& iObserver; }; /** @@ -119,7 +118,7 @@ * 2phase construction * @param aOtgWatcher OtgWatcher is a parent class */ - static CUsbNotifManager* NewL(CUsbOtgWatcher* aOtgWatcher); + static CUsbNotifManager* NewL(CUsbOtgWatcher& aOtgWatcher); /** * Destructor @@ -133,20 +132,20 @@ * @param aObserver will receive notifications */ void ShowNotifierL(TUid aCat, TUint aNotifId, - MWaitNotifierObserver* aObserver = NULL); + MWaitNotifierObserver* aObserver); /** * Closes and deletes all the notifiers */ void CloseAllNotifiers(); - + /** * Calls back Notifier show is over * @param aWaitNotifier wait notifier * @param aResult result (was any errors or not) * @param aFeedback user press (cancel or any other) */ - void NotifierShowCompletedL(CUsbNotifier* aWaitNotifier, TInt aResult, + void NotifierShowCompletedL(CUsbNotifier& aWaitNotifier, TInt aResult, TInt aFeedback); private: @@ -160,7 +159,7 @@ /** * Second phase construction */ - void ConstructL(CUsbOtgWatcher* aOtgWatcher); + void ConstructL(CUsbOtgWatcher& aOtgWatcher); private: // data diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbotgstateobserver.h --- a/usbengines/usbotgwatcher/inc/cusbotgstateobserver.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbotgstateobserver.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Observes OTG states + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Observes OTG states + * + */ #ifndef C_USBOTGSTATEOBSERVER_H #define C_USBOTGSTATEOBSERVER_H @@ -64,12 +63,12 @@ * Local device is B, and get to Host state */ virtual void BHostL() = 0; - + /** * Error handler * @param aError error code */ - virtual void OtgStateErrorL(TInt aError) = 0; + virtual void OtgStateErrorL(TInt aError) = 0; }; /** @@ -101,13 +100,13 @@ * Subscribes for getting notifications * @param aObserver Observer */ - void SubscribeL(MUsbOtgStateObserver* aObserver); + void SubscribeL(MUsbOtgStateObserver& aObserver); /** * Unsubscribes from getting notifications * @param aObserver Observer */ - void UnsubscribeL(MUsbOtgStateObserver* aObserver); + void UnsubscribeL(MUsbOtgStateObserver& aObserver); private: @@ -151,7 +150,7 @@ /** * The observer reports state changes to own observers - * Owns + * Not owns */ RPointerArray iObservers; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbotgwatcher.h --- a/usbengines/usbotgwatcher/inc/cusbotgwatcher.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbotgwatcher.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: OTG watcher state machine owner + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: OTG watcher state machine owner + * + */ #ifndef C_USBOTGWATCHER_H #define C_USBOTGWATCHER_H @@ -88,17 +87,20 @@ friend class CtUsbOtgWatcher; public: + /** * Two-phased constructor. * @param aUsb usbman API */ - IMPORT_C static CUsbOtgWatcher* NewL(RUsb& aUsb); + IMPORT_C + static CUsbOtgWatcher* NewL(RUsb& aUsb); /** * Check ID-Pin state * @return ETrue if the ID-Pin is present (A-Device) */ - IMPORT_C TBool IsDeviceA(); + IMPORT_C + TBool IsDeviceA(); /** * Destructor. @@ -159,7 +161,7 @@ /** * Id Pin On * @param aError - */ + */ void IdPinErrorL(TInt aError); // From VBus observer @@ -225,7 +227,7 @@ /** * error * @param aError error happened - */ + */ void BusActivityErrorL(TInt aError); // From Host Event notification observer @@ -257,7 +259,7 @@ /** * Error happened during observing * @param aError error code - */ + */ void HostEventNotificationErrorL(TInt aError); // From message notification observer @@ -285,9 +287,9 @@ /** * Error handler * @param error code - */ + */ void MessageNotificationErrorL(TInt aError); - + // From CUsbServiceControl /** * called when request for usb services is completed @@ -348,32 +350,34 @@ CUsbNotifManager* NotifManager(); /** * @return Handle state + * @param aStateId state id */ - CUsbStateHostHandle* HostHandle() const; + CUsbStateHostHandle* HostHandle(TUsbStateIds aStateId) const; /** * Handles problems in host functioning * @param aWhatKindOf problem Id to be handled + * @param aInState state id where to handle */ - void HandleHostProblemL(TInt aWhatKindOf); - + void HandleHostProblemL(TInt aWhatKindOf, TUsbStateIds aInState); + /** * Add observer to USb Otg state machine * @param aObserver Observer */ - void SubscribeL(MUsbOtgWatcherStateObserver* aObserver); + void SubscribeL(MUsbOtgWatcherStateObserver& aObserver); /** * Remove observer from UsbOtg state observer * @param aObserver Observer */ - void UnsubscribeL(MUsbOtgWatcherStateObserver* aObserver); + void UnsubscribeL(MUsbOtgWatcherStateObserver& aObserver); /** * Used for test purposes */ void PrintStateToLog(); - + private: /** @@ -405,12 +409,12 @@ * @param aNewStateId new host state (id) */ void ChangeHostStateL(TUsbStateIds aNewStateId); - + /** * Used for test purposes * @return KErrNone if test is OK, otherwise errorcode */ - TInt SelfTestL(); + TInt SelfTestL(); private: // data @@ -491,12 +495,18 @@ * Own. */ CUsbServiceControl* iUsbServiceControl; - + /** * The observer reports state changes to its own observers * Not Own */ RPointerArray iOtgStateObservers; + + /** + * The observer reports state changes to its own observers + * Not Own + */ + CUsbServiceControl::TUsbServiceRequest iUsbServiceRequest; }; #endif // C_USBOTGWATCHER_H diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbpersonalityswitch.h --- a/usbengines/usbotgwatcher/inc/cusbpersonalityswitch.h Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +0,0 @@ -/* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Personality switch function. - * -*/ - -#ifndef C_USBPERSONALITYSWITCH_H -#define C_USBPERSONALITYSWITCH_H - -#include -#include - -const TInt KGetAllPersonalitiesReq = 0x82; -const TInt KSetPersonalityReq = 0x89; - -const TInt KNumOfPersShift = 3; -const TInt KCurrPersShift = 2; -const TInt KFirstPersonalityIdShift = 4; -const TInt KLenghtOfPersonalityData = 2; - -class MUsbPersonalitySwitchObserver - { -public: - enum TState - { - EIdle = 0, - ERequestingAllPersonalities, - ERequestingSetPersonality, - EGetAllPersonalitiesCompleted, - ESetPersonalityCompleted, - ERequestCancelled, - ERequestFailed - }; -public: - virtual void UsbPersonalitySwitchStateChangedL(TState aState, TInt aData) = 0; - }; - -/* * - * Reads personalities, if possible, switches peripheral to mass storage. - * It is assumed that USB is started already - */ -NONSHARABLE_CLASS(CUsbPersonalitySwitch) : public CActive - { - enum TState - { - EIdle = 0, - EGetAllPersonalities, - ESetPersonality /*, - EGetAllPersResult, - EGetSetPersResult*/ - }; - -public: - - /** - * Two-phased constructor - * - * @param aObserver will get call back - * @param aTimerId timer id - */ - static CUsbPersonalitySwitch * NewL(MUsbPersonalitySwitchObserver* aObserver); - - /** - * Destructor. - */ - virtual ~CUsbPersonalitySwitch(); - - /** - * calls RunL after aMilliseconds - * @param aMilliseconds time in millisecs - */ - TInt SwitchPersonalityL(TUint32 aDeviceId, TInt aPersonalityToBeSet); - - void CancelSwitchPersonalityL(); - -public: - - // from base class CActive - /** - * Called when request is completed - */ - void RunL(); - - /** - * called when RunL leaves - * @param aError error code - * @return error code - */ - TInt RunError(TInt aError); - - /** - * Called when request is cancelled - */ - void DoCancel(); - -private: - - /** - * Default constructor - * @param aObserver will get call back - * @param aTimerId timer id - */ - CUsbPersonalitySwitch(MUsbPersonalitySwitchObserver* aObserver); - - /** - * 2nd phase construction - */ - void ConstructL(); - - void Reset(); - -private: - // data - - /** - * Observer - * not own - */ - MUsbPersonalitySwitchObserver* iObserver; - - RUsbInterface iUsbInterface; - - /** - * timer id - */ - TInt iPersonalityToBeSet; - - RUsbInterface::TUsbTransferRequestDetails iTransfer; - - RBuf8 iSendData; - - RBuf8 iRcvData; - - TState iState; - }; - -#endif // C_USBPERSONALITYSWITCH_H diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbservicecontrol.h --- a/usbengines/usbotgwatcher/inc/cusbservicecontrol.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbservicecontrol.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #ifndef C_USBSERVICECONTROL_H #define C_USBSERVICECONTROL_H @@ -50,12 +49,19 @@ public: + enum TUsbServiceRequest + { + ERequestUndefined, + EStartUsbService, + EStopUsbService + }; + /** * Two-phased constructor. * @param aObserver Observer * @param aUsb RUsb API */ - static CUsbServiceControl* NewL(MUsbServiceControlObserver* aObserver, + static CUsbServiceControl* NewL(MUsbServiceControlObserver& aObserver, RUsb& aUsb); /** @@ -107,7 +113,7 @@ * @param aObserver receives call back when service started or stopped * @param aUsb usbman API */ - CUsbServiceControl(MUsbServiceControlObserver* aObserver, RUsb& aUsb); + CUsbServiceControl(MUsbServiceControlObserver& aObserver, RUsb& aUsb); /** * 2nd phase construction @@ -120,7 +126,7 @@ * Observer * not own */ - MUsbServiceControlObserver* iObserver; + MUsbServiceControlObserver& iObserver; /** * RUsb API diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstate.h --- a/usbengines/usbotgwatcher/inc/cusbstate.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbstate.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Base class for states in state machine + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Base class for states in state machine + * + */ #ifndef C_USBSTATE_H #define C_USBSTATE_H @@ -70,25 +69,25 @@ * This might be used in switching states in watcher. New state object searched by its id * @return Id */ - virtual TUsbStateIds Id(); - + virtual TUsbStateIds Id() = 0; + /** * Destruction */ virtual ~CUsbState(); - + /** * Two-phased constructor. * @param aWatcher owner */ - static CUsbState* NewL(CUsbOtgWatcher* aWatcher); + //static CUsbState* NewL(CUsbOtgWatcher& aWatcher); protected: /** * default constructor is protected to be able to be inherited be child classes * @param aOwner owner of the state */ - CUsbState(CUsbOtgWatcher* aOwner); + CUsbState(CUsbOtgWatcher& aOwner); /* * * Changes state in Device state machine @@ -102,12 +101,12 @@ */ void ChangeHostStateL(TUsbStateIds aNewStateId); -private: - /** - * 2nd phase construction + * Handles special situation (error, or something else) + * @param aWhat to hande (id) + * @param aWhereTohandle state id where to handle */ - void ConstructL(); + virtual void HandleL(TInt aWhat, TUsbStateIds aWhereTohandle); /** * State machine calls this, state object to perform any initial @@ -129,6 +128,11 @@ */ /** + * 2nd phase construction + */ + void ConstructL(); + + /** * Sets personality */ virtual void SetPersonalityL(); @@ -271,7 +275,7 @@ * Owner * Not own. */ - CUsbOtgWatcher* iWatcher; + CUsbOtgWatcher& iWatcher; }; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstatehostabase.h --- a/usbengines/usbotgwatcher/inc/cusbstatehostabase.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbstatehostabase.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,25 +1,25 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation of the conctet state + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation of the conctet state + * + */ #ifndef C_USBSTATEHOSTABASE_H #define C_USBSTATEHOSTABASE_H #include "cusbstate.h" +#include "definitions.h" class CUsbOtgWatcher; /** @@ -40,20 +40,13 @@ * default construction * @param aWatcher owner */ - CUsbStateHostABase(CUsbOtgWatcher* aWatcher); + CUsbStateHostABase(CUsbOtgWatcher& aWatcher); /** * second phase construction */ void ConstructL(); - /** - * Handles special situation (error, or something else) - * @param aWhat to hande (id) - */ - virtual void HandleL(TInt aWhat); - - //from CUsbState // From VBus observer /** * VBus down @@ -71,6 +64,16 @@ */ virtual void AVBusErrorL(); + /** + * VBus error happen + */ + virtual void AHostL(); + + /** + * VBus error happen + */ + virtual void APeripheralL(); + // From bus activity observer /** * Bus is in idle @@ -88,6 +91,10 @@ */ virtual void MessageNotificationReceivedL(TInt aMessage); /** + * SRP request received + */ + virtual void SrpReceivedL(); + /** * Connected to hub in wrong level */ virtual void BadHubPositionL(); diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstatehostahost.h --- a/usbengines/usbotgwatcher/inc/cusbstatehostahost.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbstatehostahost.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,31 +1,26 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation of the concret state + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation of the concret state + * + */ #ifndef C_USBSTATEHOSTAHOST_H #define C_USBSTATEHOSTAHOST_H -#include "cusbotgwatcher.h" #include "cusbstatehostabase.h" -#ifndef STIF -#include "cusbtimer.h" -#else -#include "mockcusbtimer.h" -#endif + +class CUsbOtgWatcher; /** * This class implements behaviour in Host state (Drivers loaded, device is in Host role) @@ -39,7 +34,7 @@ * Two-phased constructor. * @param aWatcher Owner */ - static CUsbStateHostAHost* NewL(CUsbOtgWatcher* aWatcher); + static CUsbStateHostAHost* NewL(CUsbOtgWatcher& aWatcher); /** * Destructor. @@ -52,7 +47,7 @@ * Default construction * @param aWatcher owner */ - CUsbStateHostAHost(CUsbOtgWatcher* aWatcher); + CUsbStateHostAHost(CUsbOtgWatcher& aWatcher); /** * 2nd phase construction @@ -72,38 +67,27 @@ * trigger it and transition will not happen. This forces the transition in such cases. * */ - void JustAdvancedToThisStateL(); + virtual void JustAdvancedToThisStateL(); /** * State machine calls this, state object to perform any initial * activity, just before leaving this state * */ - void JustBeforeLeavingThisStateL(); + virtual void JustBeforeLeavingThisStateL(); - // From OTG state observer - /** - * Became a Host when A - */ - void AHostL(); - - /** - * Became a Peripheral when A - */ - void APeripheralL(); - // From Host Event notification observer /** * Device is detached * @param aInfo Device event data */ - void DeviceDetachedL(TDeviceEventInformation aInfo); + virtual void DeviceDetachedL(TDeviceEventInformation aInfo); // From message notification observer /** * Connected to hub in wrong level */ - void BadHubPositionL(); + virtual void BadHubPositionL(); private: // data diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstatehostaidle.h --- a/usbengines/usbotgwatcher/inc/cusbstatehostaidle.h Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Iplementation of the concret state - * -*/ - - -#ifndef C_USBSTATEHOSTAIDLE_H -#define C_USBSTATEHOSTAIDLE_H - -#include "cusbotgwatcher.h" -#include "cusbstatehostainitiatebase.h" -#ifndef STIF -#include "cusbtimer.h" -#else -#include "mockcusbtimer.h" -#endif - -/** - * This class implements basic behaviour in Idle state (VBus down, IdPin on) - * - */ -NONSHARABLE_CLASS( CUsbStateHostAIdle ) : public CUsbStateHostAInitiateBase - - { - -public: - - /** - * Two-phased constructor. - * @param aWatcher owner - */ - static CUsbStateHostAIdle* NewL(CUsbOtgWatcher* aWatcher); - - /** - * Destructor. - */ - virtual ~CUsbStateHostAIdle(); - -private: - - /** - * Default construction - * @param aWatcher owner - */ - CUsbStateHostAIdle(CUsbOtgWatcher* aWatcher); - - /** - * 2nd phase construction - */ - void ConstructL(); - - //from CUsbState - /** - * State id - * @return state id - */ - TUsbStateIds Id(); - - /** - * This is called when switched to this state, - * because If all conditions for transition to another state exist, nothing will - * trigger it and transition will not happen. This forces the transition in such cases. - * - */ - void JustAdvancedToThisStateL(); - - }; - -#endif // C_USBSTATEHOSTAIDLE_H diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstatehostainitiate.h --- a/usbengines/usbotgwatcher/inc/cusbstatehostainitiate.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbstatehostainitiate.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,37 +1,39 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation of the concret state + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation of the concret state + * + */ #ifndef C_USBSTATEHOSTAINITIATE_H #define C_USBSTATEHOSTAINITIATE_H -#include "cusbotgwatcher.h" -#include "cusbstatehostainitiatebase.h" +#include "cusbstatehostabase.h" + #ifndef STIF #include "cusbtimer.h" #else #include "mockcusbtimer.h" #endif +class CUsbOtgWatcher; + /** * This class implements behaviour when Id pin just detected (initiating host role, loading drivers) * */ -NONSHARABLE_CLASS( CUsbStateHostAInitiate ) : public CUsbStateHostAInitiateBase +NONSHARABLE_CLASS( CUsbStateHostAInitiate ) : public CUsbStateHostABase, +MUsbTimerObserver { friend class CtUsbOtgWatcher; @@ -41,7 +43,7 @@ * Two-phased constructor. * @param aWatcher owner */ - static CUsbStateHostAInitiate* NewL(CUsbOtgWatcher* aWatcher); + static CUsbStateHostAInitiate* NewL(CUsbOtgWatcher& aWatcher); /** * Destructor. @@ -50,11 +52,18 @@ private: + // From MUsbTimerObserver + /** + * timer expired call back + * @param aTimerId timer id + */ + void TimerElapsedL(TUsbTimerId aTimerId); + /** * default construction * @param aWatcher owner */ - CUsbStateHostAInitiate(CUsbOtgWatcher* aWatcher); + CUsbStateHostAInitiate(CUsbOtgWatcher& aWatcher); /** * 2nd phase construction @@ -75,14 +84,54 @@ * */ void JustAdvancedToThisStateL(); - + /** * This is called when switched to this state, * because If all conditions for transition to another state exist, nothing will * trigger it and transition will not happen. This forces the transition in such cases. * */ - virtual void JustBeforeLeavingThisStateL(); + void JustBeforeLeavingThisStateL(); + + // From VBus observer + /** + * VBus up + */ + void VBusUpL(); + + // From Host Event notification observer + /** + * Device is attached + * @param Device event data + */ + void DeviceAttachedL(TDeviceEventInformation); + + /** + * Device is detached + * @param Device event data + */ + void DriverLoadSuccessL(TDeviceEventInformation); + + /** + * Drivers loaded partially + * @param Device event data + */ + void DriverLoadPartialSuccessL(TDeviceEventInformation); + + /** + * Drivers loading failed + * @param Device event data + */ + void DriverLoadFailureL(TDeviceEventInformation); + +private: + // data + + /* + * attachment timer + * own + */ + CUsbTimer* iAttachmentTimer; }; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstatehostainitiatebase.h --- a/usbengines/usbotgwatcher/inc/cusbstatehostainitiatebase.h Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +0,0 @@ -/* -* Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implements concrete state - * -*/ - - -#ifndef C_USBSTATEHOSTAINITIATEBASE_H -#define C_USBSTATEHOSTAINITIATEBASE_H - -#include "cusbotgwatcher.h" -#include "cusbstatehostabase.h" -#include "cusbpersonalityswitch.h" -#ifndef STIF -#include "cusbtimer.h" -#else -#include "mockcusbtimer.h" -#endif - -/** - * This class implements besic behaviour when Id pin on, and vbus just turned down or just turned on, - * specific concrete case/state is implemented in subclass - */ -NONSHARABLE_CLASS( CUsbStateHostAInitiateBase ) : public CUsbStateHostABase, - MUsbTimerObserver, MUsbPersonalitySwitchObserver - - { - friend class CTestUsbOtgWatcher; - -public: - - /** - * Destructor. - */ - virtual ~CUsbStateHostAInitiateBase(); - - // From MUsbTimerObserver - /** - * timer expired call back - * @param aTimerId timer id - */ - void TimerElapsedL(TUsbTimerId aTimerId); - - void UsbPersonalitySwitchStateChangedL(MUsbPersonalitySwitchObserver::TState aState, TInt aData); - -protected: - - /** - * Default construction - * @param aWatcher owner - */ - CUsbStateHostAInitiateBase(CUsbOtgWatcher* aWatcher); - - /** - * 2nd phase construction - */ - void ConstructL(); - - //from CUsbState - - /** - * This is called when switched to this state, - * because If all conditions for transition to another state exist, nothing will - * trigger it and transition will not happen. This forces the transition in such cases. - * - */ - virtual void JustBeforeLeavingThisStateL(); - - // From VBus observer - /** - * VBus down - */ - virtual void VBusDownL(); - /** - * VBus UP - */ - virtual void VBusUpL(); - - /** - * AHost - */ - virtual void AHostL(); - - /** - * APeripheral - */ - virtual void APeripheralL(); - - // From Host Event notification observer - /** - * Device is attached - * @param Device event data - */ - virtual void DeviceAttachedL(TDeviceEventInformation); - /** - * Device is detached - * @param Device event data - */ - virtual void DriverLoadSuccessL(TDeviceEventInformation); - /** - * Drivers loaded partially - * @param Device event data - */ - virtual void DriverLoadPartialSuccessL(TDeviceEventInformation); - /** - * Drivers loading failed - * @param Device event data - */ - virtual void DriverLoadFailureL(TDeviceEventInformation); - - // From message notification observer - /** - * SRP request received - */ - virtual void SrpReceivedL(); - -protected: - // data - - /* - * attachment timer - * own - */ - CUsbTimer* iAttachmentTimer; - - CUsbPersonalitySwitch* iUsbPersonalitySwitch; - }; - -#endif // C_USBSTATEHOSTAINITIATEBASE_H diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstatehostaperipheral.h --- a/usbengines/usbotgwatcher/inc/cusbstatehostaperipheral.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbstatehostaperipheral.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,31 +1,26 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implements concrete state + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implements concrete state + * + */ #ifndef C_USBSTATEHOSTAPERIPHERAL_H #define C_USBSTATEHOSTAPERIPHERAL_H -#include "cusbotgwatcher.h" #include "cusbstatehostabase.h" -#ifndef STIF -#include "cusbtimer.h" -#else -#include "mockcusbtimer.h" -#endif + +class CUsbOtgWatcher; /** * This class implements behaviour when A device performs peripheral role, from OTG point of view @@ -40,7 +35,7 @@ * Two-phased constructor. * @param aWatcher owner */ - static CUsbStateHostAPeripheral* NewL(CUsbOtgWatcher* aWatcher); + static CUsbStateHostAPeripheral* NewL(CUsbOtgWatcher& aWatcher); /** * Destructor. @@ -53,20 +48,13 @@ * default constructor * @param aWatcher owner */ - CUsbStateHostAPeripheral(CUsbOtgWatcher* aWatcher); + CUsbStateHostAPeripheral(CUsbOtgWatcher& aWatcher); /** * 2nd phase construction */ void ConstructL(); - /** - * State machine calls this, state object to perform any initial - * activity, once just entered this state - * - */ - void JustAdvancedToThisStateL(); - //from CUsbState /** * state id diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstatehostdelayattachedhandle.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbengines/usbotgwatcher/inc/cusbstatehostdelayattachedhandle.h Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implements concrete state + * + */ + +#ifndef C_USBSTATEHOSTDALAYATTACHEDHANDLE_H +#define C_USBSTATEHOSTDALAYATTACHEDHANDLE_H + +#include "cusbstatehostdelayhandle.h" + +#ifndef STIF +#include "cusbtimer.h" +#else +#include "mockcusbtimer.h" +#endif + +class CUsbOtgWatcher; + +/** + * problem handling, device is attached, vbus not dropping + * + */ +NONSHARABLE_CLASS( CUsbStateHostDelayAttachedHandle ) : public CUsbStateHostDelayHandle, +public MUsbTimerObserver + { + friend class CtUsbOtgWatcher; + friend class CUsbOtgWatcher; + +public: + + /** + * Two-phased constructor. + * @param aWatcher owner + */ + static CUsbStateHostDelayAttachedHandle* NewL(CUsbOtgWatcher& aWatcher); + + /** + * Destructor. + */ + virtual ~CUsbStateHostDelayAttachedHandle(); + +protected: + + // From MUsbTimerObserver + /** + * Call back when timer expired + * @param aTimerId timer id + */ + void TimerElapsedL(TUsbTimerId aTimerId); + + /** + * Device is detached + * @param aInfo Device event data + */ + virtual void DeviceDetachedL(TDeviceEventInformation aInfo); + + //from CUsbState + /** + * State id + * @return state id + */ + virtual TUsbStateIds Id(); + + /** + * This is called when leaving this state, + * + */ + virtual void JustBeforeLeavingThisStateL(); + + /** + * handles issue + */ + virtual void DoHandleL(); + + /** + * Default constructor + * @param aWatcher owner + */ + CUsbStateHostDelayAttachedHandle(CUsbOtgWatcher& aWatcher); + + /** + * 2nd phase construction + */ + void ConstructL(); + + // data + +private: + /** + * drivers not found + * own + */ + CUsbTimer* iDriversNotFoundTimer; + }; + +#endif // C_USBSTATEHOSTDELAYATTACHEDHANDLE_H diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstatehostdelayhandle.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbengines/usbotgwatcher/inc/cusbstatehostdelayhandle.h Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implements concrete state + * + */ + +#ifndef C_USBSTATEHOSTDELAYHANDLE_H +#define C_USBSTATEHOSTDELAYHANDLE_H + +#include "cusbstatehosthandle.h" + +class CUsbOtgWatcher; + +/** + * problem handling, vbus not dropping + * + */ +NONSHARABLE_CLASS( CUsbStateHostDelayHandle ) : public CUsbStateHostHandle + { + friend class CtUsbOtgWatcher; + friend class CUsbOtgWatcher; + +public: + + /** + * Destructor. + */ + virtual ~CUsbStateHostDelayHandle(); + +protected: + + // From VBus observer + /** + * VBus up + */ + virtual void VBusUpL(); + + // From Host Event notification observer + /** + * Device is attached + * @param aInfo Device event data + */ + virtual void DeviceAttachedL(TDeviceEventInformation aInfo); + + /** + * Default constructor + * @param aWatcher owner + */ + CUsbStateHostDelayHandle(CUsbOtgWatcher& aWatcher); + + /** + * 2nd phase construction + */ + void ConstructL(); + + // data + +private: + }; + +#endif // C_USBSTATEHOSTDELAYHANDLE_H diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstatehostdelaynotattachedhandle.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbengines/usbotgwatcher/inc/cusbstatehostdelaynotattachedhandle.h Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implements concrete state + * + */ + +#ifndef C_USBSTATEHOSTDELAYANOTTTACHEDHANDLE_H +#define C_USBSTATEHOSTDELAYNOTATTACHEDHANDLE_H + +#include "cusbstatehostdelayattachedhandle.h" + +#ifndef STIF +#include "cusbtimer.h" +#else +#include "mockcusbtimer.h" +#endif + +class CUsbOtgWatcher; +/** + * problem handling, device is not attached, vbus not dropping + * + */ +NONSHARABLE_CLASS( CUsbStateHostDelayNotAttachedHandle ) : public CUsbStateHostDelayHandle, +MUsbTimerObserver + { + friend class CtUsbOtgWatcher; + friend class CUsbOtgWatcher; + +public: + + /** + * Two-phased constructor. + * @param aWatcher owner + */ + static CUsbStateHostDelayNotAttachedHandle* NewL(CUsbOtgWatcher& aWatcher); + + /** + * Destructor. + */ + virtual ~CUsbStateHostDelayNotAttachedHandle(); + +private: + + // From MUsbTimerObserver + /** + * Call back when timer expired + * @param aTimerId timer id + */ + void TimerElapsedL(TUsbTimerId aTimerId); + + /** + * Device is detached + * @param aInfo Device event data + */ + void DeviceDetachedL(TDeviceEventInformation aInfo); + + // From OTG state observer + /** + * Became to Idle when A + */ + void AIdleL(); + + //from CUsbState + /** + * State id + * @return state id + */ + TUsbStateIds Id(); + + /** + * This is called when leaving this state, + * + */ + void JustBeforeLeavingThisStateL(); + + /** + * handles issue + */ + void DoHandleL(); + + /** + * Default constructor + * @param aWatcher owner + */ + CUsbStateHostDelayNotAttachedHandle(CUsbOtgWatcher& aWatcher); + + /** + * 2nd phase construction + */ + void ConstructL(); + + // data + + /** + * too much power timer + * own + */ + CUsbTimer* iTooMuchPowerTimer; + + }; + +#endif // C_USBSTATEHOSTDELAYNOTATTACHEDHANDLE_H diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstatehosthandle.h --- a/usbengines/usbotgwatcher/inc/cusbstatehosthandle.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbstatehosthandle.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,43 +1,32 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implements concrete state + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implements concrete state + * + */ #ifndef C_USBSTATEHOSTHANDLE_H #define C_USBSTATEHOSTHANDLE_H -#include "cusbotgwatcher.h" -#include "cusbstate.h" +#include "cusbstatehostabase.h" -#ifndef STIF -#include "cusbnotifmanager.h" -#include "cusbtimer.h" -#else -#include "mockcusbnotifmanager.h" -#include "mockcusbtimer.h" -#endif +class CUsbOtgWatcher; /** - * This class implements behaviour when some problem needs vbus drop, and mostly, user action. + * problem handling base class * */ -NONSHARABLE_CLASS( CUsbStateHostHandle ) : public CUsbState, - MWaitNotifierObserver, - MUsbTimerObserver -// this means only one wait notifier at a time can be shown by this state, might be redesigned +NONSHARABLE_CLASS( CUsbStateHostHandle ) : public CUsbStateHostABase { friend class CtUsbOtgWatcher; friend class CUsbOtgWatcher; @@ -45,12 +34,6 @@ public: /** - * Two-phased constructor. - * @param aWatcher owner - */ - static CUsbStateHostHandle* NewL(CUsbOtgWatcher* aWatcher); - - /** * Destructor. */ virtual ~CUsbStateHostHandle(); @@ -61,136 +44,19 @@ */ void SetWhat(TInt aWhat); - // from MWaitNotifierObserver - /** - * Callback when notifier is completed - * @param aFeedback how notifier completed - */ - void WaitNotifierCompletedL(TInt aFeedback); - - // From MUsbTimerObserver - /** - * Call back when timer expired - * @param aTimerId timer id - */ - void TimerElapsedL(TUsbTimerId aTimerId); - -private: - - // From VBus observer - /** - * VBus down - */ - void VBusDownL(); - - // From OTG state observer - /** - * Became to Idle when A - */ - void AIdleL(); - /** - * Became a Host when A - */ - void AHostL(); - /** - * Became a peripheral when A - */ - void APeripheralL(); - /** - * VBus error happen - */ - void AVBusErrorL(); - /** - * Became to Idle when B - */ - void BIdleL(); - /** - * Became a peripheral when B - */ - void BPeripheralL(); - /** - * Became a Host when B - */ - void BHostL(); - - // From bus activity observer - /** - * Bus is in idle - */ - void BusIdleL(); - /** - * Bus active - */ - void BusActiveL(); - - // From Host Event notification observer - /** - * Device is attached - * @param aInfo Device event data - */ - void DeviceAttachedL(TDeviceEventInformation aInfo); - /** - * Device is detached - * @param aInfo Device event data - */ - void DeviceDetachedL(TDeviceEventInformation aInfo); - - /** - * Drivers successfully loaded - * @param aInfo Device event data - */ - virtual void DriverLoadSuccessL(TDeviceEventInformation aInfo); - /** - * Drivers loaded partially - * @param aInfo Device event data - */ - virtual void DriverLoadPartialSuccessL(TDeviceEventInformation aInfo); - /** - * Drivers loading failed - * @param aInfo Device event data - */ - virtual void DriverLoadFailureL(TDeviceEventInformation aInfo); +protected: // From message notification observer /** * Message received * @param aMessage message id */ - void MessageNotificationReceivedL(TInt aMessage); - /** - * Connected to hub in wrong level - */ - void BadHubPositionL(); - /** - * VBus error happened - */ - void VBusErrorL(); - /** - * SRP request received - */ - void SrpReceivedL(); + virtual void MessageNotificationReceivedL(TInt aMessage); + /** * Session request received */ - void SessionRequestedL(); - - /** - * Default constructor - * @param aWatcher owner - */ - CUsbStateHostHandle(CUsbOtgWatcher* aWatcher); - - /** - * 2nd phase construction - */ - void ConstructL(); - - //from CUsbState - /** - * State id - * @return state id - */ - TUsbStateIds Id(); + virtual void SessionRequestedL(); /** * This is called when switched to this state, @@ -198,20 +64,24 @@ * trigger it and transition will not happen. This forces the transition in such cases. * */ - void JustAdvancedToThisStateL(); - - /** - * This is called when leaving this state, - * - */ - void JustBeforeLeavingThisStateL(); + virtual void JustAdvancedToThisStateL(); /** * handles issue */ - void DoHandleL(); + virtual void DoHandleL() = 0; -private: + /** + * Default constructor + * @param aWatcher owner + */ + CUsbStateHostHandle(CUsbOtgWatcher& aWatcher); + + /** + * 2nd phase construction + */ + void ConstructL(); + // data /** @@ -219,17 +89,7 @@ */ TInt iWhat; - /** - * too much power timer - * own - */ - CUsbTimer* iTooMuchPowerTimer; - - /** - * drivers not found - * own - */ - CUsbTimer* iDriversNotFoundTimer; +private: }; #endif // C_USBSTATEHOSTHANDLE_H diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstatehosthandledropping.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbengines/usbotgwatcher/inc/cusbstatehosthandledropping.h Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implements concrete state + * + */ + +#ifndef C_USBSTATEHOSTHANDLEDROPPING_H +#define C_USBSTATEHOSTHANDLEDROPPING_H + +#include "cusbstatehosthandle.h" + +#ifndef STIF +#include "cusbnotifmanager.h" +#else +#include "mockcusbnotifmanager.h" +#endif + +class CUsbOtgWatcher; + +/** + * problem handling class, dropping vbus + * + */ +NONSHARABLE_CLASS( CUsbStateHostHandleDropping ) : public CUsbStateHostHandle, +MWaitNotifierObserver +// this means only one wait notifier at a time can be shown by this state, might be redesigned + + { + friend class CtUsbOtgWatcher; + friend class CUsbOtgWatcher; + +public: + + /** + * Two-phased constructor. + * @param aWatcher owner + */ + static CUsbStateHostHandleDropping* NewL(CUsbOtgWatcher& aWatcher); + + /** + * Destructor. + */ + virtual ~CUsbStateHostHandleDropping(); + +private: + + // from MWaitNotifierObserver + /** + * Callback when notifier is completed + * @param aFeedback how notifier completed + */ + void WaitNotifierCompletedL(TInt aFeedback); + + // From VBus observer + /** + * VBus up + */ + void VBusUpL(); + + /** + * VBus down + */ + void VBusDownL(); + + // From Host Event notification observer + /** + * Device is attached + * @param aInfo Device event data + */ + void DeviceAttachedL(TDeviceEventInformation aInfo); + + /** + * Device is detached + * @param aInfo Device event data + */ + void DeviceDetachedL(TDeviceEventInformation aInfo); + + /** + * Drivers successfully loaded + * @param aInfo Device event data + */ + void DriverLoadSuccessL(TDeviceEventInformation aInfo); + + /** + * Drivers loaded partially + * @param aInfo Device event data + */ + void DriverLoadPartialSuccessL(TDeviceEventInformation aInfo); + + /** + * Drivers loading failed + * @param aInfo Device event data + */ + void DriverLoadFailureL(TDeviceEventInformation aInfo); + + // From message notification observer + /** + * Message received + * @param aMessage message id + */ + void MessageNotificationReceivedL(TInt aMessage); + + //from CUsbState + /** + * State id + * @return state id + */ + virtual TUsbStateIds Id(); + + /** + * This is called when leaving this state, + * + */ + void JustBeforeLeavingThisStateL(); + + /** + * handles issue + */ + void DoHandleL(); + + /** + * Default constructor + * @param aWatcher owner + */ + CUsbStateHostHandleDropping(CUsbOtgWatcher& aWatcher); + + /** + * 2nd phase construction + */ + void ConstructL(); + + }; + +#endif // C_USBSTATEHOSTDROPPINGHANDLE_H diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbstatehostundefined.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbengines/usbotgwatcher/inc/cusbstatehostundefined.h Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation of the concret state + * + */ + +#ifndef C_USBSTATEHOSTUNDEFINED_H +#define C_USBSTATEHOSTUNDEFINED_H + +#include "cusbstatehostabase.h" +class CUsbOtgWatcher; +/** + * This class implements behaviour in undefined state (when host) + * + */ +NONSHARABLE_CLASS( CUsbStateHostUndefined ) : public CUsbStateHostABase + { +public: + + /** + * Destruction + */ + virtual ~CUsbStateHostUndefined(); + + /** + * Two-phased constructor. + * @param aWatcher owner + */ + static CUsbStateHostUndefined* NewL(CUsbOtgWatcher& aWatcher); + +private: + /** + * default constructor is protected to be able to be inherited by child classes + * @param aOwner owner of the state + */ + CUsbStateHostUndefined(CUsbOtgWatcher& aOwner); + + /** + * Second phase construction + */ + void ConstructL(); + + /** + * This function is needed to find a real state by id + * This might be used in switching states in watcher. New state object searched by its id + * @return Id + */ + virtual TUsbStateIds Id(); + + // From VBus observer + /** + * VBus down + */ + virtual void VBusDownL(); + + /** + * VBus UP + */ + virtual void VBusUpL(); + + /** + * VBus error + */ + virtual void VBusErrorL(); + + /** + * AVBus Error + */ + virtual void AVBusErrorL(); + + /** + * Became to Idle when B + */ + virtual void BIdleL(); + + /** + * Became to Peripheral when B + */ + virtual void BPeripheralL(); + + // From Host Event notification observer + /** + * Device is detached + * @param aInfo Device event data + */ + virtual void DeviceDetachedL(TDeviceEventInformation aInfo); + + // From message notification observer + /** + * Message received + * @param aMessage message id + */ + virtual void MessageNotificationReceivedL(TInt aMessage); + /** + * SRP request received + */ + virtual void SrpReceivedL(); + /** + * Connected to hub in wrong level + */ + virtual void BadHubPositionL(); + /** + * Session request received + */ + virtual void SessionRequestedL(); + +private: + // data + }; + +#endif // C_USBSTATEHOSTUNDEFINED_H diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbtimer.h --- a/usbengines/usbotgwatcher/inc/cusbtimer.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbtimer.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,19 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: timer + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: timer + * + */ #ifndef C_USBTIMER_H #define C_USBTIMER_H @@ -65,7 +65,7 @@ * @param aObserver will get call back * @param aTimerId timer id */ - static CUsbTimer * NewL(MUsbTimerObserver* aObserver, + static CUsbTimer * NewL(MUsbTimerObserver& aObserver, TUsbTimerId aTimerId); /** @@ -106,7 +106,7 @@ * @param aObserver will get call back * @param aTimerId timer id */ - CUsbTimer(MUsbTimerObserver* aObserver, TUsbTimerId aTimerId); + CUsbTimer(MUsbTimerObserver& aObserver, TUsbTimerId aTimerId); /** * 2nd phase construction @@ -120,7 +120,7 @@ * Observer * not own */ - MUsbTimerObserver* iObserver; + MUsbTimerObserver& iObserver; /** * RTimer API diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbvbusobserver.h --- a/usbengines/usbotgwatcher/inc/cusbvbusobserver.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbvbusobserver.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implements VBus observer + * Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implements VBus observer + * + */ #ifndef C_USBVBUSOBSERVER_H #define C_USBVBUSOBSERVER_H @@ -41,7 +40,7 @@ /** * error handler * @param aError error code - */ + */ virtual void VBusObserverErrorL(TInt aError)=0; }; @@ -80,13 +79,13 @@ * Adds observer to a list * @param aObserver observer */ - void SubscribeL(MUsbVBusObserver* aObserver); + void SubscribeL(MUsbVBusObserver& aObserver); /** * removes observer from list * @param aObserver observer */ - void UnsubscribeL(MUsbVBusObserver* aObserver); + void UnsubscribeL(MUsbVBusObserver& aObserver); private: @@ -128,7 +127,7 @@ /** * The observer reports state changes to own observers - * Own + * Not owns */ RPointerArray iObservers; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbwaitnotifier.h --- a/usbengines/usbotgwatcher/inc/cusbwaitnotifier.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbwaitnotifier.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Usb waiting notifier implementation + * Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Usb waiting notifier implementation + * + */ #ifndef C_USBWAITNOTIFIER_H #define C_USBWAITNOTIFIER_H @@ -39,7 +38,7 @@ * @return Pointer to the new instance of CUsbWaitNotifier */ static CUsbWaitNotifier* NewL(RNotifier& aNotifier, - CUsbNotifManager* aNotifManager, TUint aNotifId); + CUsbNotifManager& aNotifManager, TUint aNotifId); /** * Destructor. @@ -54,7 +53,7 @@ * @param aNotifManager Owner of the class, will destroy the object when needed * @param aNotifId Id of the notifier */ - CUsbWaitNotifier(RNotifier& aNotifier, CUsbNotifManager* aNotifManager, + CUsbWaitNotifier(RNotifier& aNotifier, CUsbNotifManager& aNotifManager, TUint aNotifId); /** diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/cusbwarningnotifier.h --- a/usbengines/usbotgwatcher/inc/cusbwarningnotifier.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/cusbwarningnotifier.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Usb warning notifier implementation + * Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Usb warning notifier implementation + * + */ #ifndef C_USBWARNINGNOTIFIER_H #define C_USBWARNINGNOTIFIER_H @@ -40,7 +39,7 @@ * @return Pointer to the new instance of CUsbWarningNotifier */ static CUsbWarningNotifier* NewL(RNotifier& aNotifier, - CUsbNotifManager* aNotifManager, TUint aNotifId); + CUsbNotifManager& aNotifManager, TUint aNotifId); /** * Destructor. @@ -56,7 +55,7 @@ * @param aNotifId Id of the notifier */ CUsbWarningNotifier(RNotifier& aNotifier, - CUsbNotifManager* aNotifManager, TUint aNotifId); + CUsbNotifManager& aNotifManager, TUint aNotifId); /** * 2nd phase construction diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/debug.h --- a/usbengines/usbotgwatcher/inc/debug.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/debug.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,118 +1,161 @@ /* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* This material, including documentation and any related computer +* programs, is protected by copyright controlled by Nokia. All +* rights are reserved. Copying, including reproducing, storing +* adapting or translating, any or all of this material requires the +* prior written consent of Nokia. This material also contains +* confidential information which may not be disclosed to others +* without the prior written consent of Nokia. * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * -* Description: Central place for debug-type macros & functions +* Description: Debug macros and declarations. * */ +#ifndef DEBUG_H +#define DEBUG_H -#ifndef _USBWATCHER_DEBUG_H -#define _USBWATCHER_DEBUG_H +////////////////////////////////////////////////////////////////////////////// +// Here are parameters need to be modified. +// Component name +#define MODULE_NAME "USBOTGWATCHER" +////////////////////////////////////////////////////////////////////////////// + + +// For handling unicode strings as L##MACRO is interpreted as LMACRO +#define WIDEN2( x ) L##x +#define WIDEN( x ) WIDEN2( x ) + +_LIT( KUsbPanicModule, ""WIDEN( MODULE_NAME ) ); #ifdef _DEBUG -// Enable this to enable memory tracing -//#define MEMTRACE - -// Following define is to enable OOM -// situations in SRCS -// SHOULD NEVER BE IN RELEASES. -//#define TEST_OOM - -#ifdef __WINS__ - -// File logging for WINS -#define __FLOGGING__ +// Comment this line out if using real-time debugging +//#define LOG_TO_FILE +// =========================================================================== +#if defined ( LOG_TO_FILE ) +// =========================================================================== +// Add corresponding libabry in mmp file +// LIBRARY flogger.lib +// The log file is located at +// c:\logs\usb\MODULE_NAME.txt -#else - -// Logging with RDebug for target HW -#define __CLOGGING__ - -#endif //__WINS__ - -#endif // Debug - -#if defined ( __FLOGGING__ ) - -_LIT( KLogFile,"UsbWatcher.txt" ); -_LIT( KLogDir,"usb" ); - -#include #include -#define FLOG( a ) { FPrint( a ); } - -#define FLOGHEX( value, len ) { RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, "", " ",value, len ); } - -#define FTRACE( a ) { a; } +#define DESC( x ) TPtrC( ( const TText* ) ( x ) ) +#define DESC8( x ) TPtrC8( ( const TUint8* ) ( x ) ) +_LIT( KUsbLogDir, "USB" ); +_LIT( KUsbLogFile, ""WIDEN(MODULE_NAME)L".txt" ); -inline void FPrint( const TRefByValue aFmt, ... ) -{ - VA_LIST list; - VA_START( list, aFmt ); - RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list ); +// s: c string. +#define LOG(s) RFileLogger::WriteFormat( KUsbLogDir, \ + KUsbLogFile, EFileLoggingModeAppend, \ + DESC8( "["MODULE_NAME"] "##s ) ) - // If memory tracing is activated. -#ifdef MEMTRACE - TInt size; - User::Heap().AllocSize( size ); - RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( "[USBWATCHER]\tmemory\tMemory usage: %d high: %d" ), size, User::Heap().Size() ); -#endif -} +// s: c string contains "%x" +// v: varaible corresponding to %x +#define LOG1(s, v) RFileLogger::WriteFormat( KUsbLogDir, \ + KUsbLogFile, EFileLoggingModeAppend, \ + DESC8( "["MODULE_NAME"] "##s ), v) +// s: c string contains "%x%y" +// v1: varaible corresponding to %x +// v2: varaible corresponding to %y +#define LOG2(s, v1, v2) RFileLogger::WriteFormat( KUsbLogDir, \ + KUsbLogFile, EFileLoggingModeAppend, \ + DESC8( "["MODULE_NAME"] "##s ), v1, v2) -inline void FHex( const TUint8* aPtr, TInt aLen ) -{ - RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen ); -} +// s: c string contains "%x%y%z" +// v1: varaible corresponding to %x +// v2: varaible corresponding to %y +// v3: varaible corresponding to %z +#define LOG3(s, v1, v2, v3) RFileLogger::WriteFormat( KUsbLogDir, \ + KUsbLogFile, EFileLoggingModeAppend, \ + DESC8( "["MODULE_NAME"] "##s ), v1, v2, v3 ) -inline void FHex( const TDesC8& aDes ) -{ - FHex( aDes.Ptr(), aDes.Length() ); -} +class TFuncLogger + { +public: + TFuncLogger(const TDesC8& aFuncName) + { + iFuncName.Set( aFuncName ); + RFileLogger::WriteFormat( KUsbLogDir, KUsbLogFile, EFileLoggingModeAppend, + DESC8( "["MODULE_NAME"] >>%s" ), iFuncName.Ptr() ); + } + ~TFuncLogger() + { + RFileLogger::WriteFormat( KUsbLogDir, KUsbLogFile, + EFileLoggingModeAppend, + DESC8( "["MODULE_NAME"] <<%s" ), iFuncName.Ptr() ); + } +private: + TPtrC8 iFuncName; + }; +// =========================================================================== +#else //Real-time logging +// =========================================================================== +#include -// RDebug logging -#elif defined(__CLOGGING__) +// Paramters same as above. +#define LOG( str ) { RDebug::Printf( "["MODULE_NAME"] %s", str ); } -#include - -#define FLOG( a ) { RDebug::Print( a ); } - -#define FLOGHEX( a ) +#define LOG1( s, v ) { RDebug::Printf( "["MODULE_NAME"] "##s , v ); } -#define FTRACE( a ) { a; } +#define LOG2( s, v1,v2 ) { RDebug::Printf( "["MODULE_NAME"] "##s , v1, v2 ); } -// Declare the FPrint function +#define LOG3( s, v1, v2, v3 ) { RDebug::Printf( "["MODULE_NAME"] "##s , \ + v1, v2, v3); } -inline void FPrint( const TRefByValue aFmt, ... ) -{ - VA_LIST list; - VA_START( list,aFmt ); - TInt tmpInt = VA_ARG( list, TInt ); - TInt tmpInt2 = VA_ARG( list, TInt ); - TInt tmpInt3 = VA_ARG( list, TInt ); - VA_END( list ); - RDebug::Print( aFmt, tmpInt, tmpInt2, tmpInt3 ); -} +class TFuncLogger + { +public: + TFuncLogger(const TPtrC8& aFuncName) : iFuncName( aFuncName ) + { + RDebug::Printf( "["MODULE_NAME"] >>%s", iFuncName.Ptr()); + } + ~TFuncLogger() + { + RDebug::Printf( "["MODULE_NAME"] <<%s", iFuncName.Ptr()); + } +private: + TPtrC8 iFuncName; + }; +#endif // LOG_TO_FILE + +#define LEAVE( exp ) {volatile TInt err = exp; \ + LOG3( "LEAVE(%d) @file: %s, line: %d", err, __FILE__, __LINE__ );\ + User::Leave( err );} + +#define LEAVEIFERROR( exp ) {volatile TInt err = exp; if(err < 0) LEAVE(err);} + +#define PANIC( exp ) {volatile TInt err = exp; \ + LOG3( "PANIC(%d) @file: %s, line: %d", err, __FILE__, __LINE__ );\ + User::Panic( KUsbPanicModule, err );} -#else // No loggings --> reduced code size +#define LOG_FUNC TFuncLogger __instrument(TPtrC8((TUint8*)__PRETTY_FUNCTION__)); + +#else // _DEBUG +// =========================================================================== -#define FLOG( a ) -#define FLOGHEX( a ) -#define FTRACE( a ) +#define LOG( s ) +#define LOG1( s, v ) +#define LOG2( s, v1, v2 ) +#define LOG3( s, v1, v2, v3 ) +#define LOG_FUNC_ENTRY +#define LOG_FUNC_EXIT +#define LEAVE( exp ) User::Leave( exp ); +#define LEAVEIFERROR( exp ) User::LeaveIfError( exp ); +#define PANIC( err ) User::Panic( KUsbPanicModule, err ); +#define LOG_FUNC +// =========================================================================== +#endif // _DEBUG +// =========================================================================== +#endif // DEBUG_H -#endif //_DEBUG - -#endif // USBDEVCON_DEBUG_H - +// End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/definitions.h --- a/usbengines/usbotgwatcher/inc/definitions.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/definitions.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Definitions for otgwatcher + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Definitions for otgwatcher + * + */ #ifndef DEFENITIONS_H #define DEFENITIONS_H @@ -38,14 +37,15 @@ */ enum TUsbStateIds { - EUsbStateUndefined, - + EUsbStateHostUndefined, + EUsbStateHostAInitiate, EUsbStateHostAHost, EUsbStateHostAPeripheral, - EUsbStateHostAIdle, - EUsbStateHostHandle + EUsbStateHostDelayAttachedHandle, + EUsbStateHostDelayNotAttachedHandle, + EUsbStateHostHandleDropping }; const TInt KUsbWatcherPeripheralIsNotConnected = 0; // means not(KUsbWatcherPeripheralIsConnected) diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/errors.h --- a/usbengines/usbotgwatcher/inc/errors.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/errors.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: File contains error codes, from Watcher perspective + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: File contains error codes, from Watcher perspective + * + */ #ifndef ERRORS_H #define ERRORS_H @@ -38,7 +37,11 @@ EUsbWatcherVBusObserverError, EUsbWatcherHostEventNotificationError, EUsbWatcherOtgStateError, - EUsbWatcherMessageNotificationError + EUsbWatcherMessageNotificationError, + EUsbWatcherCanNotStartSession, + EUsbWatcherCanNotEnableDriverLoading, + EUsbWatcherCanNotClearBusError, + EUsbWatcherCanNotRaiseVBus }; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/inc/panic.h --- a/usbengines/usbotgwatcher/inc/panic.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/inc/panic.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Central place for debug-type macros & functions + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Central place for debug-type macros & functions + * + */ #ifndef USBWATCHER_PANIC_H #define USBWATCHER_PANIC_H #include @@ -107,10 +106,15 @@ EWrongTimerId, //66 EUnexpectedNotifId, //67 EUnknownUsbServiceState, //68 - EUnexpectedUsbServiceState, //69 + EUnexpectedUsbServiceState, //69 EUnexpectedUsbSwitchPersonalityState, //70 - - ECanNotFindUsbOtgWatcherStateObserver //71 + + ECanNotFindUsbOtgWatcherStateObserver, //71 + ENoObserverToUnsubscribe, // 72 + EObserverAlreadyExists, //73 + EIdForNotDefinedStateRequested, //74 + ECanNotFindHostEventNotificationObserver, //75 + ENoTimersDefinedForThisClass //76 }; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbbusactivityobserver.cpp --- a/usbengines/usbotgwatcher/src/cusbbusactivityobserver.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbbusactivityobserver.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include @@ -40,8 +39,7 @@ // void CUsbBusActivityObserver::ConstructL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::ConstructL" ) ); + LOG_FUNC User::LeaveIfError(iBusActivity.Attach(KUidUsbManCategory, KUsbOtgConnectionIdleProperty)); @@ -54,8 +52,7 @@ // CUsbBusActivityObserver* CUsbBusActivityObserver::NewL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::NewL" ) ); + LOG_FUNC CUsbBusActivityObserver* self = new (ELeave) CUsbBusActivityObserver(); CleanupStack::PushL(self); @@ -71,8 +68,7 @@ CUsbBusActivityObserver::~CUsbBusActivityObserver() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::~CUsbBusActivityObserver" ) ); + LOG_FUNC Cancel(); @@ -89,20 +85,16 @@ CUsbBusActivityObserver::TBusActivity CUsbBusActivityObserver::BusActivity() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::BusActivity" ) ); - TInt val(0); TInt err = iBusActivity.Get(val); if (KErrNone != err) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::BusActivity CanNotGetBusActivityProperty" ) ); - Panic(ECanNotGetBusActivityProperty); + LOG("ECanNotGetBusActivityProperty" ); + Panic( ECanNotGetBusActivityProperty); } - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::State = %d" ), val )); - return (0 == val ? EBusActive : EBusIdle); } @@ -111,11 +103,18 @@ // // --------------------------------------------------------------------------- // -void CUsbBusActivityObserver::SubscribeL(MUsbBusActivityObserver* aObserver) +void CUsbBusActivityObserver::SubscribeL(MUsbBusActivityObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::SubscribeL" ) ); + LOG_FUNC - User::LeaveIfError(iObservers.Append(aObserver)); + // check if the same observer already exist in a list + if (KErrNotFound != iObservers.Find(&aObserver)) + { + LOG( "Observer already exists" ); + Panic( EObserverAlreadyExists); + return; + } + iObservers.AppendL(&aObserver); if (KFirst == iObservers.Count()) // first item { @@ -129,31 +128,21 @@ // // --------------------------------------------------------------------------- // -void CUsbBusActivityObserver::UnsubscribeL(MUsbBusActivityObserver* aObserver) +void CUsbBusActivityObserver::UnsubscribeL(MUsbBusActivityObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::UnsubscribeL" ) ); + LOG_FUNC - if (0 == iObservers.Count()) // no items + TInt i(iObservers.Find(&aObserver)); + if (KErrNotFound == i) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::UnsubscribeL No observers" ) ); + LOG( "Observer not found" ); + Panic( ECanNotFindBusActivityObserver); return; } - - TInt i(0); - while (i < iObservers.Count() && aObserver != iObservers[i]) - ++i; - if (aObserver == iObservers[i]) // found - { - iObservers.Remove(i); - } - else - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::UnsubscribeL CanNotFindBusActivityObserver " ) ); - Panic(ECanNotFindBusActivityObserver); - } + iObservers.Remove(i); - if (0 == iObservers.Count()) // no items + if (0 == iObservers.Count()) // no observers anymore { // cancel pending request Cancel(); @@ -166,15 +155,17 @@ // void CUsbBusActivityObserver::RunL() { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::RunL iStatus = %d" ), iStatus.Int())); + LOG_FUNC + + LOG1( "iStatus = %d" , iStatus.Int()); // if error occured, inform observers - if(KErrNone != iStatus.Int()) + if (KErrNone != iStatus.Int()) { for (TInt i(0); i < iObservers.Count(); ++i) - { - iObservers[i]->BusActivityErrorL(iStatus.Int()); - } + { + iObservers[i]->BusActivityErrorL(iStatus.Int()); + } } // re-issue request first @@ -188,7 +179,7 @@ { case EBusIdle: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::RunL BusIdle" ) ); + LOG("BusIdle"); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -199,7 +190,7 @@ case EBusActive: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::RunL BusActive" ) ); + LOG("BusActive"); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -210,8 +201,8 @@ default: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::RunL BusActive WrongBusState" ) ); - Panic(EWrongBusState); + LOG("WrongBusState" ); + Panic( EWrongBusState); } } @@ -232,9 +223,10 @@ // TInt CUsbBusActivityObserver::RunError(TInt aError) { + LOG_FUNC - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbBusActivityObserver::RunError aError = %d" ), aError)); - + LOG1( "aError = %d", aError ); + // try to continue return KErrNone; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbhosteventnotificationobserver.cpp --- a/usbengines/usbotgwatcher/src/cusbhosteventnotificationobserver.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbhosteventnotificationobserver.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include @@ -41,8 +40,7 @@ // void CUsbHostEventNotificationObserver::ConstructL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::ConstructL" ) ); + LOG_FUNC } @@ -53,8 +51,7 @@ CUsbHostEventNotificationObserver* CUsbHostEventNotificationObserver::NewL( RUsb* aUsb) { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::NewL" ) ); + LOG_FUNC CUsbHostEventNotificationObserver* self = new (ELeave) CUsbHostEventNotificationObserver(aUsb); @@ -70,8 +67,7 @@ // CUsbHostEventNotificationObserver::~CUsbHostEventNotificationObserver() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::~CUsbHostEventNotificationObserver" ) ); + LOG_FUNC Cancel(); @@ -84,11 +80,19 @@ // --------------------------------------------------------------------------- // void CUsbHostEventNotificationObserver::SubscribeL( - MUsbHostEventNotificationObserver* aObserver) + MUsbHostEventNotificationObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::SubscribeL" ) ); + LOG_FUNC - User::LeaveIfError(iObservers.Append(aObserver)); + // check if the same observer already exist in a list + if (KErrNotFound != iObservers.Find(&aObserver)) + { + LOG("Observer already exists" ); + Panic( EObserverAlreadyExists); + return; + } + + iObservers.AppendL(&aObserver); if (KFirst == iObservers.Count()) // first item { @@ -103,30 +107,21 @@ // --------------------------------------------------------------------------- // void CUsbHostEventNotificationObserver::UnsubscribeL( - MUsbHostEventNotificationObserver* aObserver) + MUsbHostEventNotificationObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::UnsubscribeL" ) ); - if (0 == iObservers.Count()) // no items + LOG_FUNC + + TInt i(iObservers.Find(&aObserver)); + if (KErrNotFound == i) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::UnsubscribeL No observers" ) ); + LOG("Observer not found"); + Panic( ECanNotFindHostEventNotificationObserver); return; } - - TInt i(0); - while (i < iObservers.Count() && aObserver != iObservers[i]) - ++i; - if (aObserver == iObservers[i]) // found - { - iObservers.Remove(i); - } - else - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::UnsubscribeL CanNotFindIdPinObserver" ) ); - Panic(ECanNotFindIdPinObserver); - } + iObservers.Remove(i); - if (0 == iObservers.Count()) // no items + if (0 == iObservers.Count()) // no observers anymore { // cancel pending request Cancel(); @@ -139,17 +134,19 @@ // void CUsbHostEventNotificationObserver::RunL() { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iStatus = %d" ), iStatus.Int())); + LOG_FUNC + + LOG1( "iStatus = %d", iStatus.Int()); - // if error occured, tell to Observers - if(KErrNone != iStatus.Int()) + // if error occured, tell to Observers + if (KErrNone != iStatus.Int()) + { + for (TInt i(0); i < iObservers.Count(); ++i) { - for (TInt i(0); i < iObservers.Count(); ++i) - { - iObservers[i]->HostEventNotificationErrorL(iStatus.Int()); - } - return; + iObservers[i]->HostEventNotificationErrorL(iStatus.Int()); } + return; + } TDeviceEventInformation dei(iEventInfo); @@ -157,20 +154,20 @@ iUsb->HostEventNotification(iStatus, iEventInfo); SetActive(); - // Log the event - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iEventInfo.iDeviceId = %d" ), dei.iDeviceId)); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iEventInfo.iEventType = %d" ), dei.iEventType)); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iEventInfo.iError = %d" ), dei.iError)); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iEventInfo.iDriverLoadStatus = %d" ), dei.iDriverLoadStatus)); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iEventInfo.iVid = %d" ), dei.iVid)); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL iEventInfo.iPid = %d" ), dei.iPid)); + // Log the event + LOG1( "iEventInfo.iDeviceId = %d" , dei.iDeviceId); + LOG1( "iEventInfo.iEventType = %d" , dei.iEventType); + LOG1( "iEventInfo.iError = %d" , dei.iError); + LOG1( "iEventInfo.iDriverLoadStatus = %d" , dei.iDriverLoadStatus); + LOG1( "iEventInfo.iVid = %d" , dei.iVid); + LOG1( "iEventInfo.iPid = %d" , dei.iPid); // then process property change switch (dei.iEventType) { case EDeviceAttachment: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL DeviceAttachment" ) ); + LOG("DeviceAttachment" ); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -181,7 +178,7 @@ case EDeviceDetachment: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL DeviceDetachment" ) ); + LOG( "DeviceDetachment" ); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -196,7 +193,7 @@ { case EDriverLoadSuccess: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL DriverLoadSuccess" ) ); + LOG( "DriverLoadSuccess" ); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -207,7 +204,7 @@ } case EDriverLoadPartialSuccess: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL DriverLoadPartialSuccess" ) ); + LOG( "DriverLoadPartialSuccess" ); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -218,7 +215,7 @@ } case EDriverLoadFailure: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL DriverLoadFailure" ) ); + LOG( "DriverLoadFailure"); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -228,8 +225,8 @@ } default: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL DriverLoadFailure WrongDriverLoadStatus" ) ); - Panic(EWrongDriverLoadStatus); + LOG("WrongDriverLoadStatus" ); + Panic( EWrongDriverLoadStatus); } } break; @@ -237,8 +234,8 @@ } default: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunL WrongHostEventNotification" ) ); - Panic(EWrongHostEventNotification); + LOG( "WrongHostEventNotification" ); + Panic( EWrongHostEventNotification); } } @@ -260,8 +257,9 @@ // TInt CUsbHostEventNotificationObserver::RunError(TInt aError) { + LOG_FUNC - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbHostEventNotificationObserver::RunError aError = %d" ), aError)); + LOG1( "aError = %d" , aError); // try to recover and continue return KErrNone; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbidpinobserver.cpp --- a/usbengines/usbotgwatcher/src/cusbidpinobserver.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbidpinobserver.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include @@ -40,8 +39,7 @@ // void CUsbIdPinObserver::ConstructL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::ConstructL" ) ); + LOG_FUNC User::LeaveIfError(iIdPin.Attach(KUidUsbManCategory, KUsbOtgIdPinPresentProperty)); @@ -54,8 +52,7 @@ // CUsbIdPinObserver* CUsbIdPinObserver::NewL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::NewL" ) ); + LOG_FUNC CUsbIdPinObserver* self = new (ELeave) CUsbIdPinObserver(); CleanupStack::PushL(self); @@ -70,8 +67,7 @@ // CUsbIdPinObserver::~CUsbIdPinObserver() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::~CUsbIdPinObserver" ) ); + LOG_FUNC Cancel(); @@ -89,33 +85,35 @@ /* this getter is not const, because for some reason RProperty::Get is not const */ { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::IdPin" ) ); - TInt val(0); TInt err = iIdPin.Get(val); if (KErrNone != err) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::IdPin CanNotGetIdPinProperty" ) ); - Panic(ECanNotGetIdPinProperty); + LOG("CanNotGetIdPinProperty" ); + Panic( ECanNotGetIdPinProperty); } - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::IdPin = %d" ), val )); - - // not found in docs clear definition of this property. Verification is needed - return (0 == val ? EIdPinOff : EIdPinOn); + return (EFalse == val ? EIdPinOff : EIdPinOn); } // --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // -void CUsbIdPinObserver::SubscribeL(MUsbIdPinObserver* aObserver) +void CUsbIdPinObserver::SubscribeL(MUsbIdPinObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::SubscribeL" ) ); + LOG_FUNC - User::LeaveIfError(iObservers.Append(aObserver)); + // check if the same observer already exist in a list + if (KErrNotFound != iObservers.Find(&aObserver)) + { + LOG("Observer already exists" ); + Panic( EObserverAlreadyExists); + return; + } + iObservers.AppendL(&aObserver); if (KFirst == iObservers.Count()) // first item { @@ -129,30 +127,21 @@ // // --------------------------------------------------------------------------- // -void CUsbIdPinObserver::UnsubscribeL(MUsbIdPinObserver* aObserver) +void CUsbIdPinObserver::UnsubscribeL(MUsbIdPinObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::UnsubscribeL" ) ); - if (0 == iObservers.Count()) // no items + LOG_FUNC + + TInt i(iObservers.Find(&aObserver)); + if (KErrNotFound == i) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::UnsubscribeL No observers" ) ); + LOG("Observer not found"); + Panic( ECanNotFindIdPinObserver); return; } - - TInt i(0); - while (i < iObservers.Count() && aObserver != iObservers[i]) - ++i; - if (aObserver == iObservers[i]) // found - { - iObservers.Remove(i); - } - else - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIdPinObserver::UnsubscribeL CanNotGetIdPinObserver" ) ); - Panic(ECanNotFindIdPinObserver); - } + iObservers.Remove(i); - if (0 == iObservers.Count()) // no items + if (0 == iObservers.Count()) // no observers anymore { // cancel pending request Cancel(); @@ -165,17 +154,19 @@ // void CUsbIdPinObserver::RunL() { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::RunL iStatus = %d" ), iStatus.Int())); + LOG_FUNC + + LOG1( "iStatus = %d" , iStatus.Int()); - // if error occured, tell to Observers - if(KErrNone != iStatus.Int()) + // if error occured, tell to Observers + if (KErrNone != iStatus.Int()) + { + for (TInt i(0); i < iObservers.Count(); ++i) { - for (TInt i(0); i < iObservers.Count(); ++i) - { - iObservers[i]->IdPinErrorL(iStatus.Int()); - } - return; + iObservers[i]->IdPinErrorL(iStatus.Int()); } + return; + } // re-issue request first iIdPin.Subscribe(iStatus); @@ -189,7 +180,7 @@ { case EIdPinOn: { - FLOG(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::RunL IdPin ON")); + LOG("IdPin ON"); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -201,7 +192,7 @@ case EIdPinOff: { - FLOG(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::RunL IdPin OFF")); + LOG("IdPin OFF"); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -213,8 +204,8 @@ default: { - FLOG(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::RunL WrongIdPinState")); - Panic(EWrongIdPinState); + LOG("WrongIdPinState"); + Panic( EWrongIdPinState); } } @@ -235,8 +226,9 @@ // TInt CUsbIdPinObserver::RunError(TInt aError) { + LOG_FUNC - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbIdPinObserver::RunError aError = %d" ), aError)); + LOG1( "aError = %d", aError); // try to continue return KErrNone; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbindicatornotifier.cpp --- a/usbengines/usbotgwatcher/src/cusbindicatornotifier.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbindicatornotifier.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Blink/show Usb indicator notifier implementation + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Blink/show Usb indicator notifier implementation + * + */ #include #include @@ -33,11 +32,13 @@ // Two-phased constructor. // ----------------------------------------------------------------------------- // -CUsbIndicatorNotifier* CUsbIndicatorNotifier::NewL(CUsbNotifManager* aNotifManager, CUsbOtgWatcher* aOtgWatcher) +CUsbIndicatorNotifier* CUsbIndicatorNotifier::NewL( + CUsbNotifManager& aNotifManager, CUsbOtgWatcher& aOtgWatcher) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::NewL" )); + LOG_FUNC - CUsbIndicatorNotifier* self = new (ELeave) CUsbIndicatorNotifier(aNotifManager, aOtgWatcher); + CUsbIndicatorNotifier* self = new (ELeave) CUsbIndicatorNotifier( + aNotifManager, aOtgWatcher); CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(self); @@ -50,34 +51,30 @@ // CUsbIndicatorNotifier::~CUsbIndicatorNotifier() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::~CUsbIndicatorNotifier" ) ); - + LOG_FUNC + Close(); delete iIconBlinkingTimer; - - // Unsubscribe from VBus change notifications - if(iOtgWatcher) + + if (iOtgWatcher.VBusObserver()) { - if(iOtgWatcher->VBusObserver()) - { - TRAPD(err, iOtgWatcher->VBusObserver()->UnsubscribeL(this)); - err=err; // to avoid warning; - } - - // Unsubscribe from otg watcher states change notifications - TRAPD(err, iOtgWatcher->UnsubscribeL(this)); - err=err; // to avoid warning; + TRAP_IGNORE(iOtgWatcher.VBusObserver()->UnsubscribeL(*this)); } + + // Unsubscribe from otg watcher states change notifications + TRAP_IGNORE(iOtgWatcher.UnsubscribeL(*this)); } // --------------------------------------------------------------------------- // C++ constructor // --------------------------------------------------------------------------- // -CUsbIndicatorNotifier::CUsbIndicatorNotifier(CUsbNotifManager* aNotifManager, CUsbOtgWatcher* aOtgWatcher) : - CUsbNotifier(aNotifManager, KUsbUiNotifOtgIndicator, NULL), iOtgWatcher(aOtgWatcher) +CUsbIndicatorNotifier::CUsbIndicatorNotifier(CUsbNotifManager& aNotifManager, + CUsbOtgWatcher& aOtgWatcher) : + CUsbNotifier(aNotifManager, KUsbUiNotifOtgIndicator, NULL), iOtgWatcher( + aOtgWatcher) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::CUsbIndicatorNotifier" ) ); + LOG_FUNC //To be changed to EAknIndicatorStateAnimate and remove iIconBlinkingTimer //when AVKON implements animation form of usb indicator. @@ -90,16 +87,16 @@ // void CUsbIndicatorNotifier::ConstructL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::ConstructL" ) ); - + LOG_FUNC + // Subscribe for VBus change notifications - iOtgWatcher->VBusObserver()->SubscribeL(this); - + iOtgWatcher.VBusObserver()->SubscribeL(*this); + // Subscribe for otg watcher states change notifications - iOtgWatcher->SubscribeL(this); + iOtgWatcher.SubscribeL(*this); - iIconBlinkingTimer = CUsbTimer::NewL(this, EIconBlinkingTimer); - + iIconBlinkingTimer = CUsbTimer::NewL(*this, EIconBlinkingTimer); + // check here for condition to set usb indicator SetIndicatorL(); @@ -113,11 +110,15 @@ // void CUsbIndicatorNotifier::ShowStaticL(TBool aVisible) { - FTRACE( FPrint (_L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::ShowStaticL, aVisible=%d" ), aVisible)); + LOG_FUNC + + LOG1("aVisible = %d" , aVisible); iIconBlinkingTimer->Cancel(); - SetIndicatorStateL(aVisible ? EAknIndicatorStateOn : EAknIndicatorStateOff); + SetIndicatorStateL(aVisible + ? EAknIndicatorStateOn + : EAknIndicatorStateOff); } // --------------------------------------------------------------------------- @@ -126,7 +127,7 @@ // void CUsbIndicatorNotifier::BlinkL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::BlinkL" )); + LOG_FUNC // Will be canceled if active in After() iIconBlinkingTimer->After(0); @@ -138,8 +139,8 @@ // void CUsbIndicatorNotifier::ShowL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::ShowL" ) ); - + LOG_FUNC + ShowStaticL(ETrue); } @@ -149,8 +150,8 @@ // void CUsbIndicatorNotifier::Close() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::Close" ) ); - + LOG_FUNC + iIconBlinkingTimer->Cancel(); TRAP_IGNORE( ShowStaticL(EFalse) ); } @@ -165,10 +166,14 @@ { case EIconBlinkingTimer: { - SetIndicatorStateL(iIndicatorState ? EAknIndicatorStateOn : EAknIndicatorStateOff); + SetIndicatorStateL(iIndicatorState + ? EAknIndicatorStateOn + : EAknIndicatorStateOff); - iIndicatorState = (iIndicatorState == EAknIndicatorStateOn - ? EAknIndicatorStateOff : EAknIndicatorStateOn); + iIndicatorState + = (iIndicatorState == EAknIndicatorStateOn + ? EAknIndicatorStateOff + : EAknIndicatorStateOn); // Will be canceled if active in After() iIconBlinkingTimer->After(KUsbIndicatorBlinkingInterval); @@ -176,8 +181,7 @@ } default: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::TimerElapsedL - Unknown timer" ) ); - + LOG1("Unknown timer id = %d", aTimerId) Panic(EWrongTimerId); } } @@ -189,11 +193,13 @@ // void CUsbIndicatorNotifier::SetIndicatorStateL(const TInt aState) { - FTRACE( FPrint (_L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::SetIndicatorStateL - aState=%d" ), aState)); + + LOG1( "USB indicator State = %d" , aState); - CAknSmallIndicator* indicator = CAknSmallIndicator::NewLC(TUid::Uid(EAknIndicatorUSBConnection)); - indicator->SetIndicatorStateL( aState ); - CleanupStack::PopAndDestroy( indicator ); //indicator + CAknSmallIndicator* indicator = CAknSmallIndicator::NewLC(TUid::Uid( + EAknIndicatorUSBConnection)); + indicator->SetIndicatorStateL(aState); + CleanupStack::PopAndDestroy(indicator); //indicator } // --------------------------------------------------------------------------- @@ -202,7 +208,6 @@ // void CUsbIndicatorNotifier::OtgWatcherStateChangedL(TUsbStateIds aState) { - FTRACE( FPrint (_L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::OtgWatcherStateChangedL - aState=%d" ), aState)); SetIndicatorL(); } @@ -212,7 +217,6 @@ // void CUsbIndicatorNotifier::VBusDownL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::VBusDownL" ) ); SetIndicatorL(); } @@ -222,7 +226,6 @@ // void CUsbIndicatorNotifier::VBusUpL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::VBusUpL" ) ); SetIndicatorL(); } @@ -232,8 +235,7 @@ // void CUsbIndicatorNotifier::VBusObserverErrorL(TInt aError) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::VBusObserverErrorL" ) ); - // do not care + // do nothing } // --------------------------------------------------------------------------- @@ -242,24 +244,22 @@ // void CUsbIndicatorNotifier::SetIndicatorL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbIndicatorNotifier::SetIndicatorL" ) ); - - if (!(iOtgWatcher->IsDeviceA())) + if (!(iOtgWatcher.IsDeviceA())) { // if B, than other party (usbwatcher) takes care of usb indicator // in combined usbwatcher (if role swap allowed) one class has to manage usb indicator return; } - + // if VBus Up and we are host -> show indicator - if ((iOtgWatcher->VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp) && - (iOtgWatcher->CurrentHostState()->Id() == EUsbStateHostAHost)) + if ((iOtgWatcher.VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp) + && (iOtgWatcher.CurrentHostState()->Id() == EUsbStateHostAHost)) { ShowStaticL(ETrue); } // if VBus up and we are not host -> Blink indicator - else if((iOtgWatcher->VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp) && - (iOtgWatcher->CurrentHostState()->Id() != EUsbStateHostAHost)) + else if ((iOtgWatcher.VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp) + && (iOtgWatcher.CurrentHostState()->Id() != EUsbStateHostAHost)) { BlinkL(); } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbmessagenotificationobserver.cpp --- a/usbengines/usbotgwatcher/src/cusbmessagenotificationobserver.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbmessagenotificationobserver.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include #include @@ -22,7 +21,7 @@ #include "cusbmessagenotificationobserver.h" -#include "definitions.h" +#include "definitions.h" #include "debug.h" #include "panic.h" @@ -42,8 +41,7 @@ // void CUsbMessageNotificationObserver::ConstructL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::ConstructL" ) ); + LOG_FUNC } @@ -54,8 +52,7 @@ CUsbMessageNotificationObserver* CUsbMessageNotificationObserver::NewL( RUsb* aUsb) { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::NewL" ) ); + LOG_FUNC CUsbMessageNotificationObserver* self = new (ELeave) CUsbMessageNotificationObserver(aUsb); @@ -71,8 +68,7 @@ // CUsbMessageNotificationObserver::~CUsbMessageNotificationObserver() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::~CUsbMessageNotificationObserver" ) ); + LOG_FUNC Cancel(); @@ -85,11 +81,18 @@ // --------------------------------------------------------------------------- // void CUsbMessageNotificationObserver::SubscribeL( - MUsbMessageNotificationObserver* aObserver) + MUsbMessageNotificationObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::SubscribeL" ) ); + LOG_FUNC - User::LeaveIfError(iObservers.Append(aObserver)); + // check if the same observer already exist in a list + if (KErrNotFound != iObservers.Find(&aObserver)) + { + LOG("Observer already exists"); + Panic( EObserverAlreadyExists); + return; + } + iObservers.AppendL(&aObserver); if (KFirst == iObservers.Count()) // first item { @@ -103,29 +106,19 @@ // --------------------------------------------------------------------------- // void CUsbMessageNotificationObserver::UnsubscribeL( - MUsbMessageNotificationObserver* aObserver) + MUsbMessageNotificationObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::UnsubscribeL" ) ); + LOG_FUNC - if (0 == iObservers.Count()) // no items - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::UnsubscribeL No observers" ) ); - return; - } - - TInt i(0); - while (i < iObservers.Count() && aObserver != iObservers[i]) - ++i; + TInt i(iObservers.Find(&aObserver)); + if (KErrNotFound == i) + { + LOG("Observer not found" ) + Panic( ECanNotFindMessageNotificationObserver); + return; + } - if (aObserver == iObservers[i]) // found - { - iObservers.Remove(i); - } - else - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::UnsubscribeL CanNotFindMessageNotificationObserver" ) ); - Panic(ECanNotFindMessageNotificationObserver); - } + iObservers.Remove(i); if (0 == iObservers.Count()) // no items { @@ -140,13 +133,16 @@ // void CUsbMessageNotificationObserver::RunL() { + // Log the event + LOG1( "Message notification observer iMessage = %d" , iMessage); + // if error occured, tell to Observers - if(KErrNone != iStatus.Int()) + if (KErrNone != iStatus.Int()) { for (TInt i(0); i < iObservers.Count(); ++i) - { - iObservers[i]->MessageNotificationErrorL(iStatus.Int()); - } + { + iObservers[i]->MessageNotificationErrorL(iStatus.Int()); + } return; } @@ -156,15 +152,12 @@ iUsb->MessageNotification(iStatus, iMessage); SetActive(); - // Log the event - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::RunL iMessage = %d" ), message)); - // then process property change switch (message) { case KErrUsbBadHubPosition: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::RunL HubBadPosition" ) ); + LOG("HubBadPosition" ); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -174,7 +167,7 @@ } case KErrUsbOtgVbusError: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::RunL VBusError" ) ); + LOG( "VBusError"); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -184,7 +177,7 @@ } case KUsbMessageSrpReceived: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::RunL SRP received" ) ); + LOG("SRP received" ); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -194,7 +187,7 @@ } case KUsbMessageRequestSession: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::RunL Session Requested" ) ); + LOG("Session requested" ); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -205,6 +198,7 @@ // notify states with other messages default: { + for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->MessageNotificationReceivedL(message); @@ -231,8 +225,9 @@ // TInt CUsbMessageNotificationObserver::RunError(TInt aError) { + LOG_FUNC - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbMessageNotificationObserver::RunError aError = %d" ), aError)); + LOG1( "aError = %d" , aError); // try to recover and continue return KErrNone; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbnotenotifier.cpp --- a/usbengines/usbotgwatcher/src/cusbnotenotifier.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbnotenotifier.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Base classes for Usb notifier wrapper + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Base classes for Usb notifier wrapper + * + */ #include "cusbnotifmanager.h" #include "cusbnotenotifier.h" @@ -29,12 +28,9 @@ // --------------------------------------------------------------------------- // CUsbNoteNotifier::CUsbNoteNotifier(RNotifier& aNotifier, - CUsbNotifManager* aNotifManager, TUid aCat, TUint aNotifId) : - CUsbNotifier(aNotifManager, aCat, aNotifId), - iNotifier(aNotifier) + CUsbNotifManager& aNotifManager, TUid aCat, TUint aNotifId) : + CUsbNotifier(aNotifManager, aCat, aNotifId), iNotifier(aNotifier) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::CUsbNoteNotifier" ) ); - } // --------------------------------------------------------------------------- @@ -43,9 +39,10 @@ // void CUsbNoteNotifier::ConstructL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::ConstructL" ) ); + LOG_FUNC - iNotifierActive = new(ELeave)CUsbNoteNotifier::CNotifierActive(iNotifier, this); + iNotifierActive = new (ELeave) CUsbNoteNotifier::CNotifierActive( + iNotifier, *this); } // --------------------------------------------------------------------------- @@ -54,8 +51,8 @@ // CUsbNoteNotifier::~CUsbNoteNotifier() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::~CUsbNoteNotifier" ) ); - + LOG_FUNC + delete iNotifierActive; } @@ -65,7 +62,9 @@ // void CUsbNoteNotifier::ShowL() { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNoteNotifier::ShowL aCat = 0x%X aNotifId = 0x%X" ), iCat, iNotifId)); + LOG_FUNC + + LOG2( "aCat = 0x%X aNotifId = 0x%X" , iCat, iNotifId); iNotifierActive->StartL(); } @@ -76,22 +75,18 @@ // void CUsbNoteNotifier::Close() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::Close" ) ); } - // ======== MEMBER FUNCTIONS ======== // --------------------------------------------------------------------------- // C++ default constructor // --------------------------------------------------------------------------- // -CUsbNoteNotifier::CNotifierActive::CNotifierActive(RNotifier& aNotifier, - CUsbNoteNotifier* aUsbNoteNotifier) : - CUsbNoteNotifier::CNotifierActive::CActive(EPriorityStandard), - iUsbNoteNotifier(aUsbNoteNotifier), - iNotifier(aNotifier), - iRes(0) +CUsbNoteNotifier::CNotifierActive::CNotifierActive(RNotifier& aNotifier, + CUsbNoteNotifier& aUsbNoteNotifier) : + CUsbNoteNotifier::CNotifierActive::CActive(EPriorityStandard), + iUsbNoteNotifier(aUsbNoteNotifier), iNotifier(aNotifier), iRes(0) { CActiveScheduler::Add(this); } @@ -111,19 +106,16 @@ // void CUsbNoteNotifier::CNotifierActive::StartL() { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNoteNotifier::CNotifierActive::ShowL aCat = 0x%X aNotifId = 0x%X" ), - iUsbNoteNotifier->iCat, iUsbNoteNotifier->iNotifId)); + LOG_FUNC if (IsActive()) { - Panic(ENotifierIsActiveAlready); + Panic( ENotifierIsActiveAlready); return; - } - - TPckgBuf pckg; - pckg() = iUsbNoteNotifier->iNotifId; - - iNotifier.StartNotifierAndGetResponse(iStatus, iUsbNoteNotifier->iCat, pckg, iRes); + } + + iNotifIdPckg() = iUsbNoteNotifier.iNotifId; + iNotifier.StartNotifierAndGetResponse(iStatus, iUsbNoteNotifier.iCat, iNotifIdPckg, iRes); SetActive(); } @@ -133,15 +125,18 @@ // void CUsbNoteNotifier::CNotifierActive::RunL() { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCCUsbNoteNotifier::CNotifierActive::RunL iStatus = %d" ), iStatus.Int())); + LOG_FUNC + + LOG1( "iStatus = %d" , iStatus.Int()); // if error occured, deal with it in RunError User::LeaveIfError(iStatus.Int()); - iNotifier.CancelNotifier(iUsbNoteNotifier->iCat); + iNotifier.CancelNotifier(iUsbNoteNotifier.iCat); // report to owner that show is over - iUsbNoteNotifier->iNotifManager->NotifierShowCompletedL(iUsbNoteNotifier, KErrNone, iRes()); + iUsbNoteNotifier.iNotifManager.NotifierShowCompletedL(iUsbNoteNotifier, + KErrNone, iRes()); } // --------------------------------------------------------------------------- @@ -150,9 +145,7 @@ // void CUsbNoteNotifier::CNotifierActive::DoCancel() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbNoteNotifier::CNotifierActive::DoCancel" ) ); - - iNotifier.CancelNotifier(iUsbNoteNotifier->iCat); + iNotifier.CancelNotifier(iUsbNoteNotifier.iCat); } // --------------------------------------------------------------------------- @@ -161,9 +154,11 @@ // TInt CUsbNoteNotifier::CNotifierActive::RunError(TInt aError) { - FTRACE( FPrint(_L("[USBOTGWATCHER]\tCUsbNoteNotifier::CNotifierActive::RunError aError = %d" ), aError)); + LOG_FUNC - iNotifier.CancelNotifier(iUsbNoteNotifier->iCat); + LOG1("aError = %d" , aError); + + iNotifier.CancelNotifier(iUsbNoteNotifier.iCat); // try to continue return KErrNone; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbnotifier.cpp --- a/usbengines/usbotgwatcher/src/cusbnotifier.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbnotifier.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,24 +1,23 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Base classes for Usb notifier wrapper + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Base classes for Usb notifier wrapper + * + */ #include "cusbnotifmanager.h" #include "cusbnotifier.h" - + #include "debug.h" #include "panic.h" @@ -30,7 +29,7 @@ // CUsbNotifier::~CUsbNotifier() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifier::~CUsbNotifier" ) ); + LOG_FUNC } // --------------------------------------------------------------------------- @@ -46,12 +45,11 @@ // C++ constructor // --------------------------------------------------------------------------- // -CUsbNotifier::CUsbNotifier(CUsbNotifManager* aNotifManager, TUid aCat, +CUsbNotifier::CUsbNotifier(CUsbNotifManager& aNotifManager, TUid aCat, TUint aNotifId) : iNotifManager(aNotifManager), iCat(aCat), iNotifId(aNotifId), iIsFeedbackNeeded(EFalse) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifier::CUsbNotifier" ) ); } // --------------------------------------------------------------------------- @@ -60,7 +58,6 @@ // void CUsbNotifier::SetFeedbackNeeded() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifier::SetFeedbackNeeded" ) ); iIsFeedbackNeeded = ETrue; } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbnotifmanager.cpp --- a/usbengines/usbotgwatcher/src/cusbnotifmanager.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbnotifmanager.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,19 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include @@ -30,7 +30,7 @@ // --------------------------------------------------------------------------- // CWaitNotifierInfo::CWaitNotifierInfo(CUsbNotifier* aWaitNotifier, - MWaitNotifierObserver* aObserver) : + MWaitNotifierObserver& aObserver) : iWaitNotifier(aWaitNotifier), iObserver(aObserver) { } @@ -41,7 +41,7 @@ // void CWaitNotifierInfo::ConstructL() { - FLOG( _L( "[USBOTGWATCHER]\tCWaitNotifierInfo::ConstructL" ) ); + LOG_FUNC // owenrship for iWaitNotifier transferred in default constructor. // this object is responsible for deletion of the iWaitNotifier then } @@ -51,9 +51,10 @@ // --------------------------------------------------------------------------- // CWaitNotifierInfo* CWaitNotifierInfo::NewL(CUsbNotifier* aWaitNotifier, - MWaitNotifierObserver* aObserver) + MWaitNotifierObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCWaitNotifierInfo::NewL" ) ); + LOG_FUNC + CWaitNotifierInfo* self = new (ELeave) CWaitNotifierInfo(aWaitNotifier, aObserver); CleanupStack::PushL(self); @@ -68,7 +69,7 @@ // CWaitNotifierInfo::~CWaitNotifierInfo() { - FLOG( _L( "[USBOTGWATCHER]\tCWaitNotifierInfo::~CWaitNotifierInfo" ) ); + LOG_FUNC delete iWaitNotifier; } @@ -87,18 +88,16 @@ // MWaitNotifierObserver* CWaitNotifierInfo::Observer() const { - return iObserver; + return &iObserver; } - // --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // -CUsbNotifManager* CUsbNotifManager::NewL(CUsbOtgWatcher* aOtgWatcher) +CUsbNotifManager* CUsbNotifManager::NewL(CUsbOtgWatcher& aOtgWatcher) { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::NewL" ) ); + LOG_FUNC CUsbNotifManager* self = new (ELeave) CUsbNotifManager(); CleanupStack::PushL(self); @@ -111,14 +110,13 @@ // // --------------------------------------------------------------------------- // -void CUsbNotifManager::ConstructL(CUsbOtgWatcher* aOtgWatcher) +void CUsbNotifManager::ConstructL(CUsbOtgWatcher& aOtgWatcher) { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::ConstructL" ) ); + LOG_FUNC User::LeaveIfError(iNotifier.Connect()); - - iIndicatorNotifier = CUsbIndicatorNotifier::NewL(this, aOtgWatcher); + + iIndicatorNotifier = CUsbIndicatorNotifier::NewL(*this, aOtgWatcher); } @@ -128,7 +126,6 @@ // CUsbNotifManager::CUsbNotifManager() { - } // --------------------------------------------------------------------------- @@ -137,13 +134,12 @@ // CUsbNotifManager::~CUsbNotifManager() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::~CUsbNotifManager" ) ); + LOG_FUNC CloseAllNotifiers(); - + delete iIndicatorNotifier; - + iNotifier.Close(); } @@ -155,16 +151,17 @@ void CUsbNotifManager::ShowNotifierL(TUid aCat, TUint aNotifId, MWaitNotifierObserver* aObserver) { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNotifManager::ShowNotifier aCat = 0x%X aNotifId = %d, aObserver=0x%X" ), - aCat, aNotifId, aObserver)); + LOG_FUNC + + LOG3( "aCat = 0x%X aNotifId = %d, aObserver=0x%X" , aCat, aNotifId, aObserver); // remove non-feedback notifiers from the list for (TUint i(0); i < iWaitNotifiers.Count(); ++i) { - CWaitNotifierInfo* waitNotifier = iWaitNotifiers[i]; - if (!(waitNotifier->WaitNotifier()->IsFeedbackNeeded())) + CWaitNotifierInfo* waitNotifierInfo = iWaitNotifiers[i]; + if (!(waitNotifierInfo->WaitNotifier()->IsFeedbackNeeded())) { - delete waitNotifier; + delete waitNotifierInfo; iWaitNotifiers.Remove(i); } } @@ -183,41 +180,42 @@ if (aCat == KUsbUiNotifOtgError) { __ASSERT_ALWAYS(aObserver != NULL, Panic(EWrongNotifierCategory)); - notifier = CUsbWaitNotifier::NewL(iNotifier, this, aNotifId); + notifier = CUsbWaitNotifier::NewL(iNotifier, *this, aNotifId); } else if (aCat == KUsbUiNotifOtgWarning) { - notifier = CUsbWarningNotifier::NewL(iNotifier, this, aNotifId); + notifier = CUsbWarningNotifier::NewL(iNotifier, *this, aNotifId); } else { - FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::ShowNotifierL - Unexpected aCat" ) ); + LOG1("Unexpected aCat = 0x%X", aCat ); Panic(EWrongNotifierCategory); } CleanupStack::PushL(notifier); - - iWaitNotifiers.AppendL(CWaitNotifierInfo::NewL(notifier, aObserver)); - FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::ShowNotifierL - Start to show note" ) ); + iWaitNotifiers.AppendL(CWaitNotifierInfo::NewL(notifier, *aObserver)); + notifier->ShowL(); - CleanupStack::Pop(notifier); + CleanupStack::Pop(notifier); } // --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // -void CUsbNotifManager::NotifierShowCompletedL(CUsbNotifier* aWaitNotifier, +void CUsbNotifManager::NotifierShowCompletedL(CUsbNotifier& aWaitNotifier, TInt aResult, TInt aFeedback) { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbNotifManager::NotifierShowCompleted aResult = %d" ), aResult)); + LOG_FUNC + + LOG1( "aResult = %d", aResult); // remove Notifier from the list for (TUint i(0); i < iWaitNotifiers.Count(); ++i) { - if (aWaitNotifier == iWaitNotifiers[i]->WaitNotifier()) + if (&aWaitNotifier == iWaitNotifiers[i]->WaitNotifier()) { MWaitNotifierObserver* observer = iWaitNotifiers[i]->Observer(); @@ -236,7 +234,7 @@ // void CUsbNotifManager::CloseAllNotifiers() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbNotifManager::CloseAllNotifiers" ) ); + LOG_FUNC iWaitNotifiers.ResetAndDestroy(); iIndicatorNotifier->Close(); diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbotgstateobserver.cpp --- a/usbengines/usbotgwatcher/src/cusbotgstateobserver.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbotgstateobserver.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include "cusbotgstateobserver.h" @@ -38,8 +37,7 @@ // void CUsbOtgStateObserver::ConstructL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::ConstructL" ) ); + LOG_FUNC User::LeaveIfError(iOtgState.Attach(KUidUsbManCategory, KUsbOtgStateProperty)); @@ -52,8 +50,7 @@ // CUsbOtgStateObserver* CUsbOtgStateObserver::NewL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::NewL" ) ); + LOG_FUNC CUsbOtgStateObserver* self = new (ELeave) CUsbOtgStateObserver(); CleanupStack::PushL(self); @@ -68,8 +65,7 @@ // CUsbOtgStateObserver::~CUsbOtgStateObserver() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::~CUsbOtgStateObserver" ) ); + LOG_FUNC Cancel(); @@ -85,21 +81,16 @@ // TUsbOtgState CUsbOtgStateObserver::OtgState() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::OtgState" ) ); - TInt val(0); TInt err = iOtgState.Get(val); if (KErrNone != err) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::StOtgState CanNotGetOtgStateProperty" ) ); - Panic(ECanNotGetOtgStateProperty); + LOG("CanNotGetOtgStateProperty" ); + Panic( ECanNotGetOtgStateProperty); } - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::OtgState = %d" ), val )); - return (TUsbOtgState) val; } @@ -108,11 +99,18 @@ // // --------------------------------------------------------------------------- // -void CUsbOtgStateObserver::SubscribeL(MUsbOtgStateObserver* aObserver) +void CUsbOtgStateObserver::SubscribeL(MUsbOtgStateObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::SubscribeL" ) ); + LOG_FUNC - User::LeaveIfError(iObservers.Append(aObserver)); + // check if the same observer already exist in a list + if (KErrNotFound != iObservers.Find(&aObserver)) + { + LOG( "Observer already exists" ); + Panic( EObserverAlreadyExists); + return; + } + iObservers.AppendL(&aObserver); if (KFirst == iObservers.Count()) // first item { @@ -126,31 +124,21 @@ // // --------------------------------------------------------------------------- // -void CUsbOtgStateObserver::UnsubscribeL(MUsbOtgStateObserver* aObserver) +void CUsbOtgStateObserver::UnsubscribeL(MUsbOtgStateObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::UnsubscribeL" ) ); + LOG_FUNC - if (0 == iObservers.Count()) // no items - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::UnsubscribeL No observers" ) ); - return; - } - - TInt i(0); - while (i < iObservers.Count() && aObserver != iObservers[i]) - ++i; - - if (aObserver == iObservers[i]) // found + TInt i(iObservers.Find(&aObserver)); + if (KErrNotFound == i) { - iObservers.Remove(i); - } - else - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::UnsubscribeL CanNotFindOtgStateObserver" ) ); - Panic(ECanNotFindOtgStateObserver); + LOG("Observer not found"); + Panic( ECanNotFindOtgStateObserver); + return; } - if (0 == iObservers.Count()) // no items + iObservers.Remove(i); + + if (0 == iObservers.Count()) // no observers anymore { // cancel pending request Cancel(); @@ -163,18 +151,20 @@ // void CUsbOtgStateObserver::RunL() { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::RunL iStatus = %d" ), iStatus.Int())); + LOG_FUNC + + LOG1( "iStatus = %d" , iStatus.Int()); // if error occured, tell to Observers - if(KErrNone != iStatus.Int()) + if (KErrNone != iStatus.Int()) { for (TInt i(0); i < iObservers.Count(); ++i) - { - iObservers[i]->OtgStateErrorL(iStatus.Int()); - } + { + iObservers[i]->OtgStateErrorL(iStatus.Int()); + } return; } - + // re-issue request first iOtgState.Subscribe(iStatus); SetActive(); @@ -186,12 +176,12 @@ { case EUsbOtgStateReset: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == RESET" ) ); + LOG("OTGState == RESET" ); break; } case EUsbOtgStateAIdle: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == AIdle" ) ); + LOG("OTGState == AIdle" ); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->AIdleL(); @@ -200,7 +190,7 @@ } case EUsbOtgStateAHost: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == AHost" ) ); + LOG( "OTGState == AHost"); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->AHostL(); @@ -209,7 +199,7 @@ } case EUsbOtgStateAPeripheral: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == APeripheral" ) ); + LOG("OTGState == APeripheral" ); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->APeripheralL(); @@ -218,7 +208,7 @@ } case EUsbOtgStateAVbusError: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == AVBusError" ) ); + LOG("OTGState == AVBusError" ); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->AVBusErrorL(); @@ -227,7 +217,7 @@ } case EUsbOtgStateBIdle: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == BIdle" ) ); + LOG( "OTGState == BIdle" ); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->BIdleL(); @@ -236,7 +226,7 @@ } case EUsbOtgStateBPeripheral: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == BPeripheral" ) ); + LOG("OTGState == BPeripheral" ); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->BPeripheralL(); @@ -245,7 +235,7 @@ } case EUsbOtgStateBHost: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL OTGState == BHost" ) ); + LOG("OTGState == BHost" ); for (TInt i(0); i < iObservers.Count(); ++i) { iObservers[i]->BHostL(); @@ -254,8 +244,8 @@ } default: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOTGStateObserver::RunL WrongOtgState" ) ); - Panic(EWrongOtgState); + LOG("WrongOtgState" ); + Panic( EWrongOtgState); } } @@ -276,8 +266,9 @@ // TInt CUsbOtgStateObserver::RunError(TInt aError) { + LOG_FUNC - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgStateObserver::RunError aError = %d" ), aError)); + LOG1( "aError = %d" , aError); // try to continue return KErrNone; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbotgwatcher.cpp --- a/usbengines/usbotgwatcher/src/cusbotgwatcher.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbotgwatcher.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,46 +1,42 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include #include #include - #include "cusbotgwatcher.h" #include "cusbstate.h" - #include "cusbstatehostainitiate.h" #include "cusbstatehostahost.h" #include "cusbstatehostaperipheral.h" -#include "cusbstatehostaidle.h" #include "cusbstatehosthandle.h" - +#include "cusbstatehostdelayhandle.h" +#include "cusbstatehostdelayattachedhandle.h" +#include "cusbstatehostdelaynotattachedhandle.h" +#include "cusbstatehosthandledropping.h" +#include "cusbstatehostundefined.h" #include "cusbwarningnotifier.h" - #ifndef STIF #include "cusbnotifmanager.h" #else #include "mockcusbnotifmanager.h" #endif - #include "errors.h" #include "debug.h" #include "panic.h" - _LIT_SECURITY_POLICY_PASS( KAlwaysPassPolicy ); _LIT_SECURITY_POLICY_C1( KLocalServicesPolicy, ECapabilityLocalServices ); @@ -49,9 +45,10 @@ // --------------------------------------------------------------------------- // CUsbOtgWatcher::CUsbOtgWatcher(RUsb& aUsbMan) : - iUsb(aUsbMan), iPersonalityId(KUsbPersonalityIdMTP) + iUsb(aUsbMan), iPersonalityId(KUsbPersonalityIdMTP), iUsbServiceRequest( + CUsbServiceControl::ERequestUndefined) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::CUsbOtgWatcher" ) ); + LOG_FUNC } // --------------------------------------------------------------------------- @@ -60,31 +57,35 @@ // void CUsbOtgWatcher::ConstructL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::ConstructL" ) ); + LOG_FUNC #ifdef _DEBUG SelfTestL(); #endif #ifndef STIF - User::LeaveIfError(RProperty::Define( KPSUidUsbWatcher, - KUsbWatcherIsPeripheralConnected, RProperty::EInt, KAlwaysPassPolicy, - KLocalServicesPolicy ) ); + User::LeaveIfError(RProperty::Define(KPSUidUsbWatcher, + KUsbWatcherIsPeripheralConnected, RProperty::EInt, + KAlwaysPassPolicy, KLocalServicesPolicy)); - User::LeaveIfError( RProperty::Set( KPSUidUsbWatcher, + User::LeaveIfError(RProperty::Set(KPSUidUsbWatcher, KUsbWatcherIsPeripheralConnected, - KUsbWatcherPeripheralIsNotConnected ) ); + KUsbWatcherPeripheralIsNotConnected)); #endif - - iUsbServiceControl = CUsbServiceControl::NewL(this, iUsb); + + iUsbServiceControl = CUsbServiceControl::NewL(*this, iUsb); - User::LeaveIfError(iStates.Append(CUsbState::NewL(this))); - User::LeaveIfError(iStates.Append(CUsbStateHostAInitiate::NewL(this))); - User::LeaveIfError(iStates.Append(CUsbStateHostAHost::NewL(this))); - User::LeaveIfError(iStates.Append(CUsbStateHostAPeripheral::NewL(this))); - User::LeaveIfError(iStates.Append(CUsbStateHostAIdle::NewL(this))); - User::LeaveIfError(iStates.Append(CUsbStateHostHandle::NewL(this))); + User::LeaveIfError(iStates.Append(CUsbStateHostUndefined::NewL(*this))); + User::LeaveIfError(iStates.Append(CUsbStateHostAInitiate::NewL(*this))); + User::LeaveIfError(iStates.Append(CUsbStateHostAHost::NewL(*this))); + User::LeaveIfError(iStates.Append(CUsbStateHostAPeripheral::NewL(*this))); + + User::LeaveIfError(iStates.Append(CUsbStateHostDelayAttachedHandle::NewL( + *this))); + User::LeaveIfError(iStates.Append( + CUsbStateHostDelayNotAttachedHandle::NewL(*this))); + User::LeaveIfError(iStates.Append( + CUsbStateHostHandleDropping::NewL(*this))); iIdPinObserver = CUsbIdPinObserver::NewL(); iVBusObserver = CUsbVBusObserver::NewL(); @@ -94,14 +95,19 @@ &iUsb); iMessageNotificationObserver = CUsbMessageNotificationObserver::NewL( &iUsb); - - iHostState = iStates[EUsbStateUndefined]; - + + iHostState = iStates[EUsbStateHostUndefined]; + // Notif manager must be created at least after VBus observer and iHostState initialization // to allow USb indicator subscribe to its notifications at construction and check their's current states - iNotifManager = CUsbNotifManager::NewL(this); + iNotifManager = CUsbNotifManager::NewL(*this); - iIdPinObserver->SubscribeL(this); + iVBusObserver->SubscribeL(*this); + iOtgStateObserver->SubscribeL(*this); + iBusActivityObserver->SubscribeL(*this); + iHostEventNotificationObserver->SubscribeL(*this); + iMessageNotificationObserver->SubscribeL(*this); + iIdPinObserver->SubscribeL(*this); if (CUsbIdPinObserver::EIdPinOn == iIdPinObserver->IdPin()) { @@ -128,7 +134,7 @@ // EXPORT_C CUsbOtgWatcher* CUsbOtgWatcher::NewL(RUsb& aUsbMan) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::NewL" ) ); + LOG_FUNC CUsbOtgWatcher* self = new (ELeave) CUsbOtgWatcher(aUsbMan); CleanupStack::PushL(self); @@ -143,15 +149,41 @@ // CUsbOtgWatcher::~CUsbOtgWatcher() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::~CUsbOtgWatcher" ) ); - + LOG_FUNC + #ifndef STIF - RProperty::Delete( KPSUidUsbWatcher, KUsbWatcherIsPeripheralConnected ); + RProperty::Delete(KPSUidUsbWatcher, KUsbWatcherIsPeripheralConnected); #endif - + // delete Notif manager before VBus observer, due to USB indicator observes VBus delete iNotifManager; - + + if (iIdPinObserver) + { + TRAP_IGNORE(iIdPinObserver->UnsubscribeL(*this)); + } + + if (iVBusObserver) + { + TRAP_IGNORE(iVBusObserver->UnsubscribeL(*this)); + } + if (iOtgStateObserver) + { + TRAP_IGNORE(iOtgStateObserver->UnsubscribeL(*this)); + } + if (iBusActivityObserver) + { + TRAP_IGNORE(iBusActivityObserver->UnsubscribeL(*this)); + } + if (iHostEventNotificationObserver) + { + TRAP_IGNORE(iHostEventNotificationObserver->UnsubscribeL(*this)); + } + if (iMessageNotificationObserver) + { + TRAP_IGNORE(iMessageNotificationObserver->UnsubscribeL(*this)); + } + delete iIdPinObserver; delete iVBusObserver; delete iOtgStateObserver; @@ -160,11 +192,11 @@ delete iMessageNotificationObserver; iOtgStateObservers.Close(); - + // Destroy states iStates.ResetAndDestroy(); iStates.Close(); - + delete iUsbServiceControl; iUsb.Close(); @@ -178,8 +210,9 @@ void CUsbOtgWatcher::SetPersonalityL(TRequestStatus& /*aStatus*/, TInt aPersonality) { + LOG_FUNC - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SetPersonalityL aPersonality = %d" ), aPersonality)); + LOG1( "aPersonality = %d" , aPersonality); // watcher keeps this value, no need to pass it to request object // state can read it from watcher when needed @@ -199,7 +232,7 @@ // void CUsbOtgWatcher::CancelSetPersonalityL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::CancelSetPersonalityL" ) ); + LOG_FUNC iState->CancelSetPersonalityL(); } @@ -210,7 +243,7 @@ // void CUsbOtgWatcher::SetPreviousPersonalityL(TRequestStatus& /*aStatus*/) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SetPreviousPersonalityL" ) ); + LOG_FUNC // maybe more complex processing needed here iState->SetPreviousPersonalityL(); @@ -222,7 +255,7 @@ // void CUsbOtgWatcher::SetPreviousPersonalityL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SetPreviousPersonalityL" ) ); + LOG_FUNC iState->SetPreviousPersonalityL(); } @@ -233,7 +266,7 @@ // void CUsbOtgWatcher::CancelSetPreviousPersonalityL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::CancelSetPreviousPersonalityL" ) ); + LOG_FUNC iState->CancelSetPreviousPersonalityL(); } @@ -244,7 +277,7 @@ // void CUsbOtgWatcher::SetPreviousPreviousPersonalityOnDisconnectL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SetPreviousPreviousPersonalityOnDisconnectL" ) ); + LOG_FUNC } @@ -255,19 +288,22 @@ // void CUsbOtgWatcher::StartSessionL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::StartSessionL" ) ); + LOG_FUNC if (!CanStartSessionL()) { - HandleHostProblemL(EUsbWatcherErrorInConnection); + HandleHostProblemL(EUsbWatcherCanNotStartSession, + EUsbStateHostHandleDropping); return; } + iUsbServiceRequest = CUsbServiceControl::EStartUsbService; TInt err = iUsbServiceControl->StartL(iPersonalityId); if (KErrNone != err) { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::StartSessionL Can not start usb services. reason = %d" ), err)); - HandleHostProblemL(EUsbWatcherCanNotStartUsbServices); + LOG1( "Can not start usb services. err = %d" , err); + HandleHostProblemL(EUsbWatcherCanNotStartUsbServices, + EUsbStateHostHandleDropping); return; } @@ -280,11 +316,12 @@ // // --------------------------------------------------------------------------- // -void CUsbOtgWatcher::HandleHostProblemL(TInt aWhatKindOf) +void CUsbOtgWatcher::HandleHostProblemL(TInt aWhatKindOf, + TUsbStateIds aInState) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::HandleProblemL" ) ); - HostHandle()->SetWhat(aWhatKindOf); - ChangeHostStateL(EUsbStateHostHandle); + LOG_FUNC + HostHandle(aInState)->SetWhat(aWhatKindOf); + ChangeHostStateL(aInState); } // --------------------------------------------------------------------------- @@ -293,7 +330,7 @@ // void CUsbOtgWatcher::IdPinOnL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinOnL" ) ); + LOG_FUNC StartSessionL(); } @@ -303,37 +340,24 @@ // void CUsbOtgWatcher::IdPinOffL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinOffL" ) ); - - // for example, USB failed to start - if(NULL == iHostState) return; + LOG_FUNC - iVBusObserver->UnsubscribeL(this); - iOtgStateObserver->UnsubscribeL(this); - iBusActivityObserver->UnsubscribeL(this); - iHostEventNotificationObserver->UnsubscribeL(this); - iMessageNotificationObserver->UnsubscribeL(this); - - iHostState->JustBeforeLeavingThisStateL(); - - iHostState = NULL; + ChangeHostStateL(EUsbStateHostUndefined); iNotifManager->CloseAllNotifiers(); - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinOffL Before DisableFunctionDriverLoad " ) ); Usb().DisableFunctionDriverLoading(); - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinOffL Before TryStop" ) ); + iUsbServiceRequest = CUsbServiceControl::EStopUsbService; + TInt err = iUsbServiceControl->StopL(); - TInt err = iUsbServiceControl->StopL(); + LOG1( "iUsbServiceControl->Stop() err = %d", err ); if (KErrNone != err) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinOnL ErrorStoppingUsbServices" ) ); + LOG( "ErrorStoppingUsbServices" ); Panic(ECanNotStopUsbServices); } - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinOffL iUsbServiceControl->Stop() OK" ) ); } // --------------------------------------------------------------------------- @@ -342,9 +366,8 @@ // void CUsbOtgWatcher::IdPinErrorL(TInt aError) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::IdPinErrorL" ) ); - __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); - HandleHostProblemL(EUsbWatcherIdPinError); + __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); + HandleHostProblemL(EUsbWatcherIdPinError, EUsbStateHostHandleDropping); } @@ -355,7 +378,6 @@ // void CUsbOtgWatcher::VBusDownL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::VBusDownL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->VBusDownL(); } @@ -366,7 +388,6 @@ // void CUsbOtgWatcher::VBusUpL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::VBusUpL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->VBusUpL(); } @@ -377,9 +398,9 @@ // void CUsbOtgWatcher::VBusObserverErrorL(TInt aError) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::VBusObserverErrorL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); - HandleHostProblemL(EUsbWatcherVBusObserverError); + HandleHostProblemL(EUsbWatcherVBusObserverError, + EUsbStateHostHandleDropping); } // From OTG state observer @@ -389,7 +410,6 @@ // void CUsbOtgWatcher::AIdleL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::AIdleL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->AIdleL(); } @@ -400,7 +420,6 @@ // void CUsbOtgWatcher::AHostL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::AHostL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->AHostL(); } @@ -411,7 +430,6 @@ // void CUsbOtgWatcher::APeripheralL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::APeripheralL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->APeripheralL(); } @@ -422,7 +440,6 @@ // void CUsbOtgWatcher::AVBusErrorL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::AVBusErrorL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->AVBusErrorL(); } @@ -433,7 +450,6 @@ // void CUsbOtgWatcher::BIdleL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BIdleL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->BIdleL(); } @@ -444,7 +460,6 @@ // void CUsbOtgWatcher::BPeripheralL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BPeripheralL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->BPeripheralL(); } @@ -455,7 +470,6 @@ // void CUsbOtgWatcher::BHostL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BHostL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->BHostL(); } @@ -466,9 +480,8 @@ // void CUsbOtgWatcher::OtgStateErrorL(TInt aError) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::OtgStateErrorL" ) ); -__ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); -HandleHostProblemL(EUsbWatcherOtgStateError); + __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); + HandleHostProblemL(EUsbWatcherOtgStateError, EUsbStateHostHandleDropping); } // From bus activity observer @@ -478,7 +491,6 @@ // void CUsbOtgWatcher::BusIdleL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BusIdleL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->BusIdleL(); } @@ -489,7 +501,6 @@ // void CUsbOtgWatcher::BusActiveL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BusActiveL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->BusActiveL(); } @@ -500,7 +511,6 @@ // void CUsbOtgWatcher::BusActivityErrorL(TInt aError) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BusActivityErrorL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); // no action, continue } @@ -512,7 +522,6 @@ // void CUsbOtgWatcher::DeviceAttachedL(TDeviceEventInformation aTdi) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::DeviceAttachedL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->DeviceAttachedL(aTdi); } @@ -523,7 +532,6 @@ // void CUsbOtgWatcher::DeviceDetachedL(TDeviceEventInformation aTdi) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::DeviceDetachedL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->DeviceDetachedL(aTdi); } @@ -534,7 +542,6 @@ // void CUsbOtgWatcher::DriverLoadSuccessL(TDeviceEventInformation aTdi) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::DriverLoadSuccessL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->DriverLoadSuccessL(aTdi); } @@ -545,7 +552,6 @@ // void CUsbOtgWatcher::DriverLoadPartialSuccessL(TDeviceEventInformation aTdi) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::DriverLoadPartialSuccessL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->DriverLoadPartialSuccessL(aTdi); } @@ -556,7 +562,6 @@ // void CUsbOtgWatcher::DriverLoadFailureL(TDeviceEventInformation aTdi) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::DriverLoadFailureL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->DriverLoadFailureL(aTdi); } @@ -567,9 +572,9 @@ // void CUsbOtgWatcher::HostEventNotificationErrorL(TInt aError) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::HostEventNotificationErrorL" ) ); -__ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); -HandleHostProblemL(EUsbWatcherHostEventNotificationError); + __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); + HandleHostProblemL(EUsbWatcherHostEventNotificationError, + EUsbStateHostHandleDropping); } // From message notification observer @@ -579,7 +584,6 @@ // void CUsbOtgWatcher::MessageNotificationReceivedL(TInt aMessage) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::MessageNotificationReceivedL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->MessageNotificationReceivedL(aMessage); } @@ -590,7 +594,6 @@ // void CUsbOtgWatcher::BadHubPositionL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::BadHubPositionL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->BadHubPositionL(); } @@ -601,7 +604,6 @@ // void CUsbOtgWatcher::VBusErrorL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::VBusErrorL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->VBusErrorL(); } @@ -612,7 +614,6 @@ // void CUsbOtgWatcher::SrpReceivedL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SrpReceivedL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->SrpReceivedL(); } @@ -623,7 +624,6 @@ // void CUsbOtgWatcher::SessionRequestedL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SessionRequestedL" ) ); __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); iHostState->SessionRequestedL(); } @@ -634,9 +634,9 @@ // void CUsbOtgWatcher::MessageNotificationErrorL(TInt aError) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::MessageNotificationErrorL" ) ); - __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); - HandleHostProblemL(EUsbWatcherMessageNotificationError); + __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); + HandleHostProblemL(EUsbWatcherMessageNotificationError, + EUsbStateHostHandleDropping); } // --------------------------------------------------------------------------- @@ -735,11 +735,11 @@ // // --------------------------------------------------------------------------- // -CUsbStateHostHandle* CUsbOtgWatcher::HostHandle() const +CUsbStateHostHandle* CUsbOtgWatcher::HostHandle(TUsbStateIds aInState) const { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::HostHandle" ) ); - __ASSERT_DEBUG(iStates[EUsbStateHostHandle] != NULL, Panic(EBadState)); - return (CUsbStateHostHandle*) iStates[EUsbStateHostHandle]; + __ASSERT_DEBUG(iStates[aInState] != NULL, Panic(EBadState)); + + return (CUsbStateHostHandle*) iStates[aInState]; } // --------------------------------------------------------------------------- @@ -748,20 +748,13 @@ // void CUsbOtgWatcher::ChangeStateL(TUsbStateIds aNewStateId) { + LOG_FUNC - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::ChangeStateL aNewState = %d" ), aNewStateId)); + LOG1( "aNewState = %d" , aNewStateId); if (NULL != iState) { - if (aNewStateId == iState->Id()) - { - return; // we already in the target state - } - else - { - - iState->JustBeforeLeavingThisStateL(); - } + iState->JustBeforeLeavingThisStateL(); } // sets new state @@ -785,20 +778,13 @@ // void CUsbOtgWatcher::ChangeHostStateL(TUsbStateIds aNewStateId) { + LOG_FUNC - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::ChangeHostStateL aNewState = %d" ), aNewStateId)); + LOG1( "aNewState = %d", aNewStateId); if (NULL != iHostState) { - if (aNewStateId == iHostState->Id()) - { - return; // we already in the target state - } - else - { - - iHostState->JustBeforeLeavingThisStateL(); - } + iHostState->JustBeforeLeavingThisStateL(); } // set new state @@ -813,7 +799,7 @@ __ASSERT_DEBUG(iHostState != NULL, Panic(EBadState)); iHostState->JustAdvancedToThisStateL(); // checks if there are conditions for advancing to another state(s) - + // notify state change to observers for (TInt i(0); i < iOtgStateObservers.Count(); ++i) { @@ -837,18 +823,19 @@ // void CUsbOtgWatcher::PrintStateToLog() { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::PrintStateToLog IdPin = %d" ), iIdPinObserver->IdPin())); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::PrintStateToLog VBus = %d" ), iVBusObserver->VBus())); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::PrintStateToLog OtgState = %d" ), iOtgStateObserver->OtgState())); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::PrintStateToLog BusActivity = %d" ), iBusActivityObserver->BusActivity())); - - TInt isPeripheralConnected(KUsbWatcherPeripheralIsNotConnected); - - RProperty::Get( KPSUidUsbWatcher, KUsbWatcherIsPeripheralConnected, - isPeripheralConnected ); - - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::PrintStateToLog IsPeripheralConnected = %d" ), isPeripheralConnected)); - + LOG1( "Current state id = %d" , iHostState->Id()); + LOG1( "IdPin = %d" , iIdPinObserver->IdPin()); + LOG1( "VBus = %d" , iVBusObserver->VBus()); + LOG1( "OtgState = %d" , iOtgStateObserver->OtgState()); + LOG1( "BusActivity = %d" , iBusActivityObserver->BusActivity()); + + TInt isPeripheralConnected(KUsbWatcherPeripheralIsNotConnected); + + RProperty::Get(KPSUidUsbWatcher, KUsbWatcherIsPeripheralConnected, + isPeripheralConnected); + + LOG1( "IsPeripheralConnected = %d" , isPeripheralConnected); + } // --------------------------------------------------------------------------- @@ -866,35 +853,46 @@ // void CUsbOtgWatcher::UsbServiceControlReqCompletedL(TInt aError) { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompleted Error returned by UsbServiceControl = %d" ), aError)); - - switch(aError) - { - case KErrInUse: - // usb services already started (this might happen if more than one idpin on event come) + LOG_FUNC + + LOG1( "aError = %d" , aError); + + switch (aError) { - return; + case KErrInUse: + // usb services already started (this might happen if more than one idpin on event come) + { + return; + } + + case KErrNone: + { + break; // do normal routine + } + + default: // handle the issue + { + if (iUsbServiceRequest == CUsbServiceControl::EStartUsbService) // Handle only start issues + { + HandleHostProblemL(EUsbWatcherCanNotStartUsbServices, + EUsbStateHostHandleDropping); + } + + iUsbServiceRequest = CUsbServiceControl::ERequestUndefined; + return; + } } - - case KErrNone: - { - break; // do normal routine - } - - default: // handle the issue - { - HandleHostProblemL(EUsbWatcherCanNotStartUsbServices); - return; - } - } + + iUsbServiceRequest = CUsbServiceControl::ERequestUndefined; TUsbServiceState serviceState; TInt err = iUsb.GetServiceState(serviceState); if (KErrNone != err) { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompleted Error when requesting GetServiceState = %d" ), err)); - HandleHostProblemL(EUsbWatcherCanNotStartUsbServices); + LOG1( "Error when requesting GetServiceState = %d" , err); + HandleHostProblemL(EUsbWatcherCanNotStartUsbServices, + EUsbStateHostHandleDropping); return; } @@ -902,42 +900,36 @@ { case EUsbServiceIdle: // just stopped usb service { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompletedL UsbServiceState == EUsbServiceIdle" ) ); + LOG("UsbServiceState == EUsbServiceIdle" ); // do nothing break; } case EUsbServiceStarted: // just started usb service { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompletedL UsbServiceState == EUsbServiceStarted" ) ); - - iHostState = iStates[EUsbStateHostAInitiate]; - - iHostState->JustAdvancedToThisStateL(); // do any initial activity, once advanced to the state + LOG( "UsbServiceState == EUsbServiceStarted" ); - iVBusObserver->SubscribeL(this); - iOtgStateObserver->SubscribeL(this); - iBusActivityObserver->SubscribeL(this); - iHostEventNotificationObserver->SubscribeL(this); - iMessageNotificationObserver->SubscribeL(this); + ChangeHostStateL(EUsbStateHostAInitiate); break; } case EUsbServiceStarting: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompletedL UsbServiceState == EUsbServiceStarting" ) ); + LOG("UsbServiceState == EUsbServiceStarting" ); // should not receive that, due to call back is called when service stopped or started // therefore scream + // no break statement here } case EUsbServiceStopping: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompletedL UsbServiceState == EUsbServiceStopping" ) ); + LOG("UsbServiceState == EUsbServiceStopping" ); // should not receive that, due to call back is called when service stopped or started // therefore scream + // no break statement here } case EUsbServiceFatalError: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UsbServiceControlReqCompletedL UsbServiceState == EUsbServiceFatalError" ) ); + LOG( "UsbServiceState == EUsbServiceFatalError" ); Panic(EUnexpectedUsbServiceState); break; } @@ -947,7 +939,6 @@ Panic(EUnknownUsbServiceState); } } - } // --------------------------------------------------------------------------- @@ -957,21 +948,19 @@ TInt CUsbOtgWatcher::SelfTestL() { #ifdef _DEBUG - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Creating observers." ) ); + LOG_FUNC // create all the observers iIdPinObserver = CUsbIdPinObserver::NewL(); iVBusObserver = CUsbVBusObserver::NewL(); iOtgStateObserver = CUsbOtgStateObserver::NewL(); - iBusActivityObserver = - CUsbBusActivityObserver::NewL(); - iHostEventNotificationObserver = - CUsbHostEventNotificationObserver::NewL(&iUsb); - iMessageNotificationObserver = - CUsbMessageNotificationObserver::NewL(&iUsb); + iBusActivityObserver = CUsbBusActivityObserver::NewL(); + iHostEventNotificationObserver = CUsbHostEventNotificationObserver::NewL( + &iUsb); + iMessageNotificationObserver = CUsbMessageNotificationObserver::NewL( + &iUsb); - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Observers getters." ) ); + LOG( "Observers getters" ); if (iIdPinObserver != IdPinObserver()) { @@ -998,11 +987,11 @@ User::Leave(KErrGeneral); } - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Observers destructors." ) ); + LOG( "Observers destructors" ); // idpinobserver is deleted later // Vbus observer is deleted later - + delete iOtgStateObserver; iOtgStateObserver = 0; delete iBusActivityObserver; @@ -1012,68 +1001,72 @@ delete iMessageNotificationObserver; iMessageNotificationObserver = 0; - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Creating states." ) ); + LOG("Creating states"); - User::LeaveIfError(iStates.Append(CUsbState::NewL(this))); - User::LeaveIfError(iStates.Append(CUsbStateHostAInitiate::NewL(this))); - User::LeaveIfError(iStates.Append(CUsbStateHostAHost::NewL(this))); - User::LeaveIfError(iStates.Append(CUsbStateHostAPeripheral::NewL(this))); - User::LeaveIfError(iStates.Append(CUsbStateHostAIdle::NewL(this))); - User::LeaveIfError(iStates.Append(CUsbStateHostHandle::NewL(this))); + User::LeaveIfError(iStates.Append(CUsbStateHostUndefined::NewL(*this))); + User::LeaveIfError(iStates.Append(CUsbStateHostAInitiate::NewL(*this))); + User::LeaveIfError(iStates.Append(CUsbStateHostAHost::NewL(*this))); + User::LeaveIfError(iStates.Append(CUsbStateHostAPeripheral::NewL(*this))); + User::LeaveIfError(iStates.Append(CUsbStateHostDelayAttachedHandle::NewL( + *this))); + User::LeaveIfError(iStates.Append( + CUsbStateHostDelayNotAttachedHandle::NewL(*this))); + User::LeaveIfError(iStates.Append( + CUsbStateHostHandleDropping::NewL(*this))); - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Check State()" ) ); + LOG("Check State()" ); if (iStates[EUsbStateHostAInitiate] != State(EUsbStateHostAInitiate)) { User::Leave(KErrGeneral); } - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Check CurrentHostState()" ) ); - + + LOG("Check CurrentHostState()" ); + iHostState = iStates[EUsbStateHostAInitiate]; - - if (iStates[EUsbStateHostAInitiate] != CurrentHostState()) + + if (iStates[EUsbStateHostAInitiate] != CurrentHostState()) { User::Leave(KErrGeneral); } - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL NotifManager and WarningNotifier." ) ); - CUsbNotifManager* usbnotifmanager = CUsbNotifManager::NewL(this); + LOG("NotifManager and WarningNotifier." ); + + CUsbNotifManager* usbnotifmanager = CUsbNotifManager::NewL(*this); RNotifier rnotifier; User::LeaveIfError(rnotifier.Connect()); CUsbWarningNotifier* usbnotifier = CUsbWarningNotifier::NewL(rnotifier, - usbnotifmanager, EUsbOtgPartiallySupportedDevice); + *usbnotifmanager, EUsbOtgPartiallySupportedDevice); usbnotifier->IsFeedbackNeeded(); - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL NotifManager and WarningNotifier destruction." ) ); + LOG( "NotifManager and WarningNotifier destruction." ); delete usbnotifier; rnotifier.Close(); - delete usbnotifmanager; - + delete usbnotifmanager; + // VBus observer is deleted here, due to it is used by usbnotifmanager.usbindicatornotifier delete iVBusObserver; iVBusObserver = 0; - + // id pin observer is deleted here due to it is used by usbnotifmanager.usbindicatornotifier delete iIdPinObserver; iIdPinObserver = 0; - - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Destructing states." ) ); - + + LOG("Destructing states"); + iStates.ResetAndDestroy(); - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL Check UsbServiceControl" ) ); + LOG( "Check UsbServiceControl" ); - CUsbServiceControl* usbServiceControl = CUsbServiceControl::NewL(this, + CUsbServiceControl* usbServiceControl = CUsbServiceControl::NewL(*this, iUsb); usbServiceControl->RunError(KErrNone); delete usbServiceControl; - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SelfTestL All completed OK." ) ); + LOG("All completed OK" ); #endif - return KErrNone; + return KErrNone; } @@ -1081,11 +1074,18 @@ // // --------------------------------------------------------------------------- // -void CUsbOtgWatcher::SubscribeL(MUsbOtgWatcherStateObserver* aObserver) +void CUsbOtgWatcher::SubscribeL(MUsbOtgWatcherStateObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::SubscribeL" ) ); + LOG_FUNC - User::LeaveIfError(iOtgStateObservers.Append(aObserver)); + // check if the same observer already exist in a list + if (KErrNotFound != iOtgStateObservers.Find(&aObserver)) + { + LOG( "Observer already exists" ); + Panic(EObserverAlreadyExists); + return; + } + iOtgStateObservers.AppendL(&aObserver); } @@ -1093,26 +1093,17 @@ // // --------------------------------------------------------------------------- // -void CUsbOtgWatcher::UnsubscribeL(MUsbOtgWatcherStateObserver* aObserver) +void CUsbOtgWatcher::UnsubscribeL(MUsbOtgWatcherStateObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UnsubscribeL" ) ); - if (0 == iOtgStateObservers.Count()) // no items + LOG_FUNC + + TInt i(iOtgStateObservers.Find(&aObserver)); + if (KErrNotFound == i) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UnsubscribeL No observers" ) ); + LOG( "Observer not found" ); + Panic(ECanNotFindUsbOtgWatcherStateObserver); return; } - - TInt i(0); - while (i < iOtgStateObservers.Count() && aObserver != iOtgStateObservers[i]) - ++i; - if (aObserver == iOtgStateObservers[i]) // found - { - iOtgStateObservers.Remove(i); - } - else - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbOtgWatcher::UnsubscribeL CanNotGetUsbOtgStateWatcherObserver" ) ); - Panic(ECanNotFindUsbOtgWatcherStateObserver); - } + iOtgStateObservers.Remove(i); } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbpersonalityswitch.cpp --- a/usbengines/usbotgwatcher/src/cusbpersonalityswitch.cpp Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,299 +0,0 @@ -/* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Switches personality - * -*/ - -#include -#include -#include - -#include "cusbpersonalityswitch.h" - -#include "panic.h" -#include "debug.h" - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CUsbPersonalitySwitch::CUsbPersonalitySwitch( - MUsbPersonalitySwitchObserver* aObserver) : - CActive(CActive::EPriorityStandard), iObserver(aObserver), iState(EIdle) - { - CActiveScheduler::Add(this); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CUsbPersonalitySwitch::~CUsbPersonalitySwitch() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::~CUsbPersonalitySwitch" ) ); - Cancel(); - iUsbInterface.Close(); - iSendData.Close(); - iRcvData.Close(); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbPersonalitySwitch::ConstructL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::ConstructL" ) ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CUsbPersonalitySwitch* CUsbPersonalitySwitch::NewL( - MUsbPersonalitySwitchObserver* aObserver) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::NewL" ) ); - - CUsbPersonalitySwitch* self = new (ELeave) CUsbPersonalitySwitch( - aObserver); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); // pop self - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -TInt CUsbPersonalitySwitch::SwitchPersonalityL(TUint32 aDeviceId, - TInt aPersonalityToBeSet) - { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::SwitchPersonality aDeviceId %d, aPersonalityToBeSet %d" ), aDeviceId, aPersonalityToBeSet)) - - if (IsActive() || EIdle != iState) - { - Cancel(); - iObserver->UsbPersonalitySwitchStateChangedL( - MUsbPersonalitySwitchObserver::ERequestCancelled, KErrNone); - } - - // create usb interface for the device id - TUint32 token(0); // = RFdc.InterfaceToken(); - TInt err = iUsbInterface.Open(token); - - FTRACE(FPrint(_L("[USBOTGWATCHER]\tCUsbPersonalitySwitch::SwitchPersonality UsbInterface Open err = %d" ), err)); - if (KErrNone != err) - { - return err; - } - - iPersonalityToBeSet = aPersonalityToBeSet; - - // get list of supported personalities - iTransfer.iRequestType = KUsbRequestType_DirToHost - | KUsbRequestType_TypeVendor | KUsbRequestType_DestDevice; - - iTransfer.iRequest = KGetAllPersonalitiesReq; - iTransfer.iValue = 0; - iTransfer.iIndex = 0; - iTransfer.iFlags - = RUsbInterface::TUsbTransferRequestDetails::EShortTransferOk; - - Reset(); - - iState = EGetAllPersonalities; - - FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::SwitchPersonalityL Sending GetAllPersonalities request." ) ); - iUsbInterface.Ep0Transfer(iTransfer, iSendData, iRcvData, iStatus); - SetActive(); - - iObserver->UsbPersonalitySwitchStateChangedL( - MUsbPersonalitySwitchObserver::ERequestingAllPersonalities, - KErrNone); - - return KErrNone; - } - -void CUsbPersonalitySwitch::CancelSwitchPersonalityL() - { - FLOG(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::CancelSwitchPersonalityL")); - - if (IsActive()) - { - Cancel(); - iObserver->UsbPersonalitySwitchStateChangedL( - MUsbPersonalitySwitchObserver::ERequestCancelled, KErrNone); - } - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbPersonalitySwitch::RunL() - { - - if (KErrNone != iStatus.Int()) - { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL iStatus %d" ), iStatus.Int())); - User::Leave(iStatus.Int()); - } - - switch (iState) - { - - case EGetAllPersonalities: - { - FLOG(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL GetAllPersonalities completed.")); - - TInt numOfPersonalities = iRcvData[KNumOfPersShift]; - FTRACE(FPrint(_L("[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL Amount of personalities in peripheral = %d" ), numOfPersonalities)); - - // if no personalities then return - if (0 == numOfPersonalities) - { - FLOG(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL No personailies found in peripheral.")); - Reset(); - iObserver->UsbPersonalitySwitchStateChangedL( - MUsbPersonalitySwitchObserver::EGetAllPersonalitiesCompleted, - KErrNotFound); - return; - } - - // if needed pers already set, then return - TInt currentPersonality = iRcvData[KCurrPersShift]; - if (iPersonalityToBeSet == currentPersonality) - { - FLOG(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL Needed personality already set in peripheral.")); - Reset(); - iObserver->UsbPersonalitySwitchStateChangedL( - MUsbPersonalitySwitchObserver::EGetAllPersonalitiesCompleted, - KErrInUse); - return; - } - - // check if device supports needed personality - TInt count(0); - while (count < numOfPersonalities && iPersonalityToBeSet - != iRcvData[KFirstPersonalityIdShift - + KLenghtOfPersonalityData * count]) - { - ++count; - } - - if (count == numOfPersonalities) // not found == not supported - { - FLOG(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL Peripheral does not support needed personality.")); - Reset(); - iObserver->UsbPersonalitySwitchStateChangedL( - MUsbPersonalitySwitchObserver::EGetAllPersonalitiesCompleted, - KErrNotFound); - return; - } - - iObserver->UsbPersonalitySwitchStateChangedL( - MUsbPersonalitySwitchObserver::EGetAllPersonalitiesCompleted, - KErrNone); - - // set personality - iTransfer.iRequestType = KUsbRequestType_DirToDev - | KUsbRequestType_TypeVendor | KUsbRequestType_DestDevice; - - iTransfer.iRequest = KSetPersonalityReq; - iTransfer.iValue = iPersonalityToBeSet; - iTransfer.iIndex = 0; - iTransfer.iFlags - = RUsbInterface::TUsbTransferRequestDetails::EShortTransferOk; - - iSendData.Close(); - iRcvData.Close(); - - iState = ESetPersonality; - - FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL Sending SetPersonality request." ) ); - iUsbInterface.Ep0Transfer(iTransfer, iSendData, iRcvData, iStatus); - SetActive(); - iObserver->UsbPersonalitySwitchStateChangedL( - MUsbPersonalitySwitchObserver::ERequestingSetPersonality, - KErrNone); - - break; - } - case ESetPersonality: - { - FLOG(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL SetPersonality completed.")); - Reset(); - iObserver->UsbPersonalitySwitchStateChangedL( - MUsbPersonalitySwitchObserver::ESetPersonalityCompleted, - KErrNone); - - break; - } - /* case EGetAllPersResult: - { - FLOG( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL GetAllPersResult completed."); - - break; - } - case EGetSetPersResult: - { - FLOG( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunL GetSetPersResult completed."); - - break; - } */ - - case EIdle: // do not break - default: - { - Panic(EUnexpectedUsbSwitchPersonalityState); - } - } - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -TInt CUsbPersonalitySwitch::RunError(TInt aError) - { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::RunError aError %d" ), aError )); - Reset(); - TRAP_IGNORE (iObserver->UsbPersonalitySwitchStateChangedL( - MUsbPersonalitySwitchObserver::ERequestFailed, aError) ); - return KErrNone; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbPersonalitySwitch::DoCancel() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::DoCancel" ) ) - - iUsbInterface.CancelEP0Transfer(); - Reset(); - } - -void CUsbPersonalitySwitch::Reset() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbPersonalitySwitch::Reset" ) ) - - iState = EIdle; - iSendData.Close(); - iRcvData.Close(); - } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbservicecontrol.cpp --- a/usbengines/usbotgwatcher/src/cusbservicecontrol.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbservicecontrol.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include @@ -26,7 +25,7 @@ // // --------------------------------------------------------------------------- // -CUsbServiceControl::CUsbServiceControl(MUsbServiceControlObserver* aObserver, +CUsbServiceControl::CUsbServiceControl(MUsbServiceControlObserver& aObserver, RUsb& aUsb) : CActive(CActive::EPriorityStandard), iObserver(aObserver), iUsb(aUsb), iPersonalityId(0) @@ -40,7 +39,8 @@ // CUsbServiceControl::~CUsbServiceControl() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::~CUsbServiceControl" ) ); + LOG_FUNC + Cancel(); } @@ -50,7 +50,7 @@ // void CUsbServiceControl::ConstructL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::ConstructL" ) ); + LOG_FUNC } // --------------------------------------------------------------------------- @@ -58,9 +58,9 @@ // --------------------------------------------------------------------------- // CUsbServiceControl* CUsbServiceControl::NewL( - MUsbServiceControlObserver* aObserver, RUsb& aUsb) + MUsbServiceControlObserver& aObserver, RUsb& aUsb) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::NewL" ) ); + LOG_FUNC CUsbServiceControl* self = new (ELeave) CUsbServiceControl(aObserver, aUsb); @@ -76,7 +76,9 @@ // TInt CUsbServiceControl::StartL(TInt aPersonalityId) { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::Start aPersonalityId = %d" ), aPersonalityId)); + LOG_FUNC + + LOG1( "aPersonalityId = %d" , aPersonalityId); TUsbServiceState serviceState; TInt err = iUsb.GetServiceState(serviceState); @@ -90,12 +92,12 @@ { case EUsbServiceIdle: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceIdle" ) ); + LOG( "UsbServiceState == EUsbServiceIdle" ); iPersonalityId = aPersonalityId; // when request completed, this will indicate that we started what we wanted if (IsActive()) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Request is outstanding, cancelling first." ) ); + LOG("Request is outstanding, cancelling first" ); Cancel(); } iUsb.TryStart(aPersonalityId, iStatus); @@ -105,20 +107,20 @@ case EUsbServiceStarted: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceStarted" ) ); + LOG("UsbServiceState == EUsbServiceStarted"); TInt currentPersonality(0); err = iUsb.GetCurrentPersonalityId(currentPersonality); if (KErrNone != err) { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Error getting current personality err = %d" ), err)); + LOG1( "Error getting current personality err = %d" , err); return err; } if (aPersonalityId == currentPersonality) // already started { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Personality already started" ) ); - iObserver->UsbServiceControlReqCompletedL(KErrInUse); + LOG("Personality already started" ); + iObserver.UsbServiceControlReqCompletedL(KErrInUse); return KErrNone; } @@ -133,13 +135,13 @@ } case EUsbServiceStarting: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceStarting" ) ); + LOG("UsbServiceState == EUsbServiceStarting" ); // do exactly the same as in case of EUsbServiceStopping; // break statement is not required here } case EUsbServiceStopping: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceStopping" ) ); + LOG( "UsbServiceState == EUsbServiceStopping" ); // subscribe for usb service state change, and start new usb service once current one started/stopped iPersonalityId = aPersonalityId; // this will indicate that we want to start this personality @@ -147,7 +149,7 @@ // this check is needed due to usb service might be stopping by other client if (IsActive()) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Request outstanding. Waiting for completion." ) ); + LOG( "Request outstanding. Waiting for completion" ); return KErrNone; // when the outstanding request get completed, we start usb services with iPersonalityId } @@ -159,12 +161,12 @@ } case EUsbServiceFatalError: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceFatalError" ) ); + LOG( "UsbServiceState == EUsbServiceFatalError" ); return KErrGeneral; } default: { - Panic(EUnknownUsbServiceState); + Panic( EUnknownUsbServiceState); } } @@ -178,11 +180,13 @@ // TInt CUsbServiceControl::StopL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop" ) ); + LOG_FUNC TUsbServiceState serviceState; TInt err = iUsb.GetServiceState(serviceState); + LOG2("err = %d; serviceState = %d" , err, serviceState); + if (KErrNone != err) { return err; @@ -192,18 +196,18 @@ { case EUsbServiceIdle: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop UsbServiceState == EUsbServiceIdle" ) ); + LOG("UsbServiceState == EUsbServiceIdle" ); return KErrNone; } case EUsbServiceStarted: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop UsbServiceState == EUsbServiceStarted" ) ); + LOG("UsbServiceState == EUsbServiceStarted" ); if (IsActive()) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop Request is outstanding, cancelling it." ) ); + LOG("Request is outstanding, cancelling it" ); Cancel(); } iUsb.TryStop(iStatus); @@ -213,13 +217,13 @@ } case EUsbServiceStopping: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop UsbServiceState == EUsbServiceStopping" ) ); + LOG( "UsbServiceState == EUsbServiceStopping" ); // do exactly the same as in case of EUsbServiceStarting; // break statement is not required here } case EUsbServiceStarting: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop UsbServiceState == EUsbServiceStarting" ) ); + LOG("UsbServiceState == EUsbServiceStarting" ); // subscribe for usb service state change, and stop usb service once current one started iPersonalityId = 0; // this will indicate that we do not want to start this personality @@ -227,7 +231,7 @@ // this check is needed due to usb service might be starting by other client if (IsActive()) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Stop Request is outstanding, waiting for completion. " ) ); + LOG("Request is outstanding, waiting for completion" ); return KErrNone; // when this request get completed, we request to stop usb services } @@ -239,12 +243,12 @@ } case EUsbServiceFatalError: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceFatalError" ) ); + LOG("UsbServiceState == EUsbServiceFatalError" ); return KErrGeneral; } default: { - Panic(EUnknownUsbServiceState); + Panic( EUnknownUsbServiceState); } } return KErrNone; @@ -256,11 +260,13 @@ // void CUsbServiceControl::RunL() { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL iStatus %d" ), iStatus.Int())); + LOG_FUNC + + LOG1("iStatus = %d" , iStatus.Int()); + if (KErrNone != iStatus.Int()) { - //User::Leave(iStatus.Int()); - iObserver->UsbServiceControlReqCompletedL(iStatus.Int()); + iObserver.UsbServiceControlReqCompletedL(iStatus.Int()); return; } @@ -269,108 +275,104 @@ if (KErrNone != err) { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL error while getting service state %d" ), err)); - //User::Leave(err); - iObserver->UsbServiceControlReqCompletedL(err); - return; + LOG1("Error while getting service state %d" , err); + iObserver.UsbServiceControlReqCompletedL(err); + return; } switch (serviceState) { case EUsbServiceIdle: // usb service stopped { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL UsbServiceState == EUsbServiceIdle" ) ); + LOG("UsbServiceState == EUsbServiceIdle" ); if (iPersonalityId != 0) // during service stopping, requested to start it { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL Requested to start personality %d. Starting it." ), iPersonalityId)); + LOG1("Requested to start personality %d. Starting it." , iPersonalityId); TInt personalityId = iPersonalityId; iPersonalityId = 0; // reset err = StartL(personalityId); - if(KErrNone != err) + if (KErrNone != err) { - iObserver->UsbServiceControlReqCompletedL(err); + iObserver.UsbServiceControlReqCompletedL(err); } return; } // otherwise, we've done, notify - iObserver->UsbServiceControlReqCompletedL(KErrNone); + iObserver.UsbServiceControlReqCompletedL(KErrNone); break; } case EUsbServiceStarted: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceStarted" ) ); + LOG("UsbServiceState == EUsbServiceStarted" ); TInt currentPersonality(0); err = iUsb.GetCurrentPersonalityId(currentPersonality); if (KErrNone != err) { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL error while getting PersonalityId err = %d" ), err)); - //User::Leave(err); - iObserver->UsbServiceControlReqCompletedL(err); - return; + LOG1("Error while getting PersonalityId err = %d" , err); + iObserver.UsbServiceControlReqCompletedL(err); + return; } if (iPersonalityId == currentPersonality) // already done { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Personality already started." ) ); + LOG("Personality already started" ); iPersonalityId = 0; - iObserver->UsbServiceControlReqCompletedL(KErrNone); + iObserver.UsbServiceControlReqCompletedL(KErrNone); return; } if (iPersonalityId == 0) // during service start requested to stop it { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start Requested to stop personality. Stopping." ) ); + LOG("Requested to stop personality. Stopping." ); err = StopL(); - if(KErrNone != err) + if (KErrNone != err) { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL error while stopping personality err = %d" ), err)); - iObserver->UsbServiceControlReqCompletedL(err); + LOG1("Error while stopping personality err = %d" , err); + iObserver.UsbServiceControlReqCompletedL(err); } return; } // otherwise, during service start, requested to start it with another personality - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL Requested to start personality %d. Starting it." ), iPersonalityId)); + LOG1( "Requested to start personality %d. Starting it.", iPersonalityId); TInt personalityId = iPersonalityId; iPersonalityId = 0; // reset - //User::LeaveIfError(Start(personalityId)); err = StartL(personalityId); - if(KErrNone != err) + if (KErrNone != err) { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunL error while starting personality err = %d" ), err)); - iObserver->UsbServiceControlReqCompletedL(err); + LOG1("Error while starting personality err = %d" , err); + iObserver.UsbServiceControlReqCompletedL(err); } break; } case EUsbServiceStarting: { - // do exactly same as in EUsbServiceStopping - // break statement is not required here - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start State == EUsbServiceStarting. Continue." ) ); + // do exactly same as in EUsbServiceStopping + // break statement is not required here + LOG("State == EUsbServiceStarting. Continue." ); } case EUsbServiceStopping: { - // we are not interested in these states, just continue monitoring - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start State == EUsbServiceStopping. Continue." ) ); + // we are not interested in these states, just continue monitoring + LOG("State == EUsbServiceStopping. Continue." ); iUsb.ServiceStateNotification(iServiceState, iStatus); SetActive(); break; } case EUsbServiceFatalError: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::Start UsbServiceState == EUsbServiceFatalError" ) ); - //User::Leave(KErrGeneral); - iObserver->UsbServiceControlReqCompletedL(KErrGeneral); + LOG("UsbServiceState == EUsbServiceFatalError" ); + iObserver.UsbServiceControlReqCompletedL(KErrGeneral); break; } default: { - Panic(EUnknownUsbServiceState); + Panic( EUnknownUsbServiceState); } } @@ -382,8 +384,9 @@ // TInt CUsbServiceControl::RunError(TInt aError) { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbServiceControl::RunError aError %d" ), aError )); - //TRAP_IGNORE(iObserver->UsbServiceControlReqCompletedL(aError)); + LOG_FUNC + LOG1("aError = %d", aError ); + TRAP_IGNORE(iObserver.UsbServiceControlReqCompletedL(aError)); return KErrNone; } @@ -394,10 +397,10 @@ // void CUsbServiceControl::DoCancel() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::DoCancel Cancelling interest to Usb TryStart.")) + LOG( "Cancelling interest to Usb TryStart.") iUsb.CancelInterest(RUsb::ETryStart); - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::DoCancel Cancelling interest to Usb TrySop.")) + LOG( "Cancelling interest to Usb TrySop.") iUsb.CancelInterest(RUsb::ETryStop); - FLOG( _L( "[USBOTGWATCHER]\tCUsbServiceControl::DoCancel Cancelling interest to usb states notifications.")) + LOG("Cancelling interest to usb states notifications.") iUsb.ServiceStateNotificationCancel(); } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstate.cpp --- a/usbengines/usbotgwatcher/src/cusbstate.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbstate.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include "cusbstate.h" @@ -25,7 +24,7 @@ // // --------------------------------------------------------------------------- // -CUsbState::CUsbState(CUsbOtgWatcher* aWatcher) : +CUsbState::CUsbState(CUsbOtgWatcher& aWatcher) : iWatcher(aWatcher) { } @@ -42,19 +41,6 @@ // // --------------------------------------------------------------------------- // -CUsbState* CUsbState::NewL(CUsbOtgWatcher* aWatcher) - { - CUsbState* self = new (ELeave) CUsbState(aWatcher); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// void CUsbState::ConstructL() { @@ -64,17 +50,9 @@ // // --------------------------------------------------------------------------- // -TUsbStateIds CUsbState::Id() - { - return EUsbStateUndefined; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// void CUsbState::JustAdvancedToThisStateL() { + iWatcher.PrintStateToLog(); } // --------------------------------------------------------------------------- @@ -92,7 +70,7 @@ void CUsbState::ChangeStateL(TUsbStateIds aNewStateId) { - iWatcher->ChangeStateL(aNewStateId); + iWatcher.ChangeStateL(aNewStateId); } @@ -103,8 +81,21 @@ void CUsbState::ChangeHostStateL(TUsbStateIds aNewStateId) { - iWatcher->ChangeHostStateL(aNewStateId); + iWatcher.ChangeHostStateL(aNewStateId); + + } +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbState::HandleL(TInt aWhat, TUsbStateIds aWhereToHandle) + { + LOG_FUNC + + LOG2( "aWhat = %d aWhere = %d" , aWhat, aWhereToHandle); + + iWatcher.HandleHostProblemL(aWhat, aWhereToHandle); } // --------------------------------------------------------------------------- @@ -156,7 +147,7 @@ // void CUsbState::IdPinOffL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::IdPinOffL" ) ); + LOG_FUNC Panic(EIdPinOffNotExpected); } @@ -166,7 +157,7 @@ // void CUsbState::IdPinOnL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::IdPinOnL" ) ); + LOG_FUNC Panic(EIdPinOnNotExpected); } @@ -177,7 +168,7 @@ // void CUsbState::VBusDownL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::VBusDownL" ) ); + LOG_FUNC Panic(EVBusDownNotExpected); } @@ -187,7 +178,8 @@ // void CUsbState::VBusUpL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::VBusUpL" ) ); + LOG_FUNC + Panic(EVBusUpNotExpected); } // From OTG state observer @@ -197,7 +189,7 @@ // void CUsbState::AIdleL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::AIdleL" ) ); + LOG_FUNC Panic(EAIdleNotExpected); } @@ -207,7 +199,7 @@ // void CUsbState::AHostL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::AHostL" ) ); + LOG_FUNC Panic(EAHostNotExpected); } @@ -217,7 +209,7 @@ // void CUsbState::APeripheralL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::APeripheralL" ) ); + LOG_FUNC Panic(EAPeripheralNotExpected); } @@ -227,7 +219,7 @@ // void CUsbState::AVBusErrorL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::AVBusErrorL" ) ); + LOG_FUNC Panic(EAVBusErrorNotExpected); } @@ -237,7 +229,7 @@ // void CUsbState::BIdleL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::BIdleL" ) ); + LOG_FUNC Panic(EBIdleNotExpected); } @@ -247,7 +239,7 @@ // void CUsbState::BPeripheralL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::BPeripheralL" ) ); + LOG_FUNC Panic(EBPeripheralNotExpected); } @@ -257,7 +249,7 @@ // void CUsbState::BHostL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::BHostL" ) ); + LOG_FUNC Panic(EBHostNotExpected); } @@ -268,7 +260,7 @@ // void CUsbState::BusIdleL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::BusIdleL" ) ); + LOG_FUNC Panic(EBusIdleNotExpected); } @@ -278,7 +270,7 @@ // void CUsbState::BusActiveL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::BusActiveL" ) ); + LOG_FUNC Panic(EBusActiveNotExpected); } @@ -289,7 +281,7 @@ // void CUsbState::DeviceAttachedL(TDeviceEventInformation) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DeviceAttachedL" ) ); + LOG_FUNC Panic(EDeviceAttachedNotExpected); } @@ -299,7 +291,7 @@ // void CUsbState::DeviceDetachedL(TDeviceEventInformation) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DeviceDetachedL" ) ); + LOG_FUNC Panic(EDeviceDetachedNotExpected); } @@ -309,7 +301,7 @@ // void CUsbState::DriverLoadSuccessL(TDeviceEventInformation) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadSuccessL" ) ); + LOG_FUNC Panic(EDriverLoadSuccessNotExpected); } @@ -319,7 +311,7 @@ // void CUsbState::DriverLoadPartialSuccessL(TDeviceEventInformation) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadPartialSuccessL" ) ); + LOG_FUNC Panic(EDriverLoadPartialSuccessNotExpected); } @@ -329,7 +321,7 @@ // void CUsbState::DriverLoadFailureL(TDeviceEventInformation) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadFailureL" ) ); + LOG_FUNC Panic(EDriverLoadFailureNotExpected); } @@ -339,7 +331,7 @@ // void CUsbState::BadHubPositionL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::BadHubPositionL" ) ); + LOG_FUNC Panic(EBadHubPositionNotExpected); } @@ -349,7 +341,7 @@ // void CUsbState::VBusErrorL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::VBusErrorL" ) ); + LOG_FUNC Panic(EVBusErrorNotExpected); } @@ -359,7 +351,7 @@ // void CUsbState::MessageNotificationReceivedL(TInt) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::MessageNotificationReceivedL" ) ); + LOG_FUNC Panic(EMessageNotificationNotExpected); } @@ -369,7 +361,7 @@ // void CUsbState::SrpReceivedL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::SrpReceivedL" ) ); + LOG_FUNC Panic(ESrpNotExpected); } @@ -379,6 +371,6 @@ // void CUsbState::SessionRequestedL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::SessionRequestedL" ) ); + LOG_FUNC Panic(ESessionRequestNotExpected); } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstatehostabase.cpp --- a/usbengines/usbotgwatcher/src/cusbstatehostabase.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbstatehostabase.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include #include @@ -22,7 +21,7 @@ #include #include "cusbstatehostabase.h" -#include "cusbstatehosthandle.h" +#include "cusbstatehosthandledropping.h" #include "errors.h" @@ -33,7 +32,7 @@ // // --------------------------------------------------------------------------- // -CUsbStateHostABase::CUsbStateHostABase(CUsbOtgWatcher* aWatcher) : +CUsbStateHostABase::CUsbStateHostABase(CUsbOtgWatcher& aWatcher) : CUsbState(aWatcher) { } @@ -44,7 +43,7 @@ // void CUsbStateHostABase::ConstructL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::ConstructL" ) ); + LOG_FUNC } // --------------------------------------------------------------------------- @@ -53,29 +52,28 @@ // CUsbStateHostABase::~CUsbStateHostABase() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::~CUsbStateHostABase" ) ); - + LOG_FUNC } // From VBus observer // --------------------------------------------------------------------------- -// +// VBus can be dropped by lower leyer in case of a critical problem // --------------------------------------------------------------------------- // void CUsbStateHostABase::VBusDownL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::VBusDownL" ) ); - ChangeHostStateL(EUsbStateHostAIdle); + LOG_FUNC + HandleL(EUsbWatcherErrorInConnection, EUsbStateHostHandleDropping); } // From OTG state observer // --------------------------------------------------------------------------- -// +// // --------------------------------------------------------------------------- // void CUsbStateHostABase::AIdleL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::AIdleL" ) ); + LOG_FUNC // do nothing } @@ -83,12 +81,32 @@ // // --------------------------------------------------------------------------- // +void CUsbStateHostABase::AHostL() + { + LOG_FUNC + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostABase::APeripheralL() + { + LOG_FUNC + ChangeHostStateL( EUsbStateHostAPeripheral); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// void CUsbStateHostABase::AVBusErrorL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::AVBusErrorL" ) ); + LOG_FUNC // No need to handle BusClearError error code, due to Bus will be dropped anyway - iWatcher->Usb().BusClearError(); - HandleL(EUsbWatcherErrDeviceRequiresTooMuchPower); + iWatcher.Usb().BusClearError(); + HandleL(EUsbWatcherErrDeviceRequiresTooMuchPower, + EUsbStateHostHandleDropping); } // From bus activity observer @@ -98,7 +116,7 @@ // void CUsbStateHostABase::BusIdleL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::BusIdleL" ) ); + LOG_FUNC //do nothing } @@ -108,7 +126,7 @@ // void CUsbStateHostABase::BusActiveL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::BusActiveL" ) ); + LOG_FUNC // do nothing } @@ -119,43 +137,21 @@ // void CUsbStateHostABase::MessageNotificationReceivedL(TInt aMessage) { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostABase::MessageNotificationReceivedL = %d" ), aMessage)); + LOG_FUNC + LOG1( "aMessage = %d" , aMessage); switch (aMessage) { // OTGDI - case KErrUsbOtgEventQueueOverflow: // = -6670; - case KErrUsbOtgStateQueueOverflow:// = -6671; - case KErrUsbOtgMessageQueueOverflow: // = -6672; - - case KErrUsbOtgBadState:// = -6675; - case KErrUsbOtgStackNotStarted:// = -6680; - //case KErrUsbOtgVbusAlreadyRaised:// = -6681; - //case KErrUsbOtgSrpForbidden:// = -6682; - case KErrUsbOtgHnpNotResponding:// = -6683; - //case KErrUsbOtgHnpBusDrop:// = -6684; - case KErrUsbOtgBusControlProblem:// = -6685; - case KErrUsbOtgVbusPowerUpError:// = -6686; - case KErrUsbOtgHnpEnableProblem:// = -6687; - case KErrUsbOtgVbusError:// = -6690; - case KErrUsbOtgSrpTimeout:// = -6691; - //case KErrUsbOtgSrpActive:// = -6692; - //case KErrUsbOtgSrpNotPermitted:// = -6693; - //case KErrUsbOtgHnpNotPermitted:// = -6694; - //case KErrUsbOtgHnpNotEnabled:// = -6695; - //case KErrUsbOtgHnpNotSuspended:// = -6696; - //case KErrUsbOtgVbusPowerUpNotPermitted:// = -6697; - //case KErrUsbOtgVbusPowerDownNotPermitted:// = -6698; - //case KErrUsbOtgVbusClearErrorNotPermitted:// = -6699; - // hosterrors.h + // hosterrors.h case KErrUsbConfigurationHasNoInterfaces: case KErrUsbInterfaceCountMismatch: case KErrUsbDuplicateInterfaceNumbers: @@ -163,15 +159,15 @@ case KErrUsbDeviceDetachedDuringDriverLoading: case KErrUsbAttachmentFailureGeneralError: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::MessageNotificationReceivedL ErrorInConnection" ) ); - HandleL(EUsbWatcherErrorInConnection); + LOG( "ErrorInConnection" ); + HandleL(EUsbWatcherErrorInConnection, EUsbStateHostHandleDropping); break; } - // OTGDI - //case KErrUsbOtgPeriphNotSupported: // = -6688 + // OTGDI + case KErrUsbOtgPeriphNotSupported: // = -6688, for OPT only - // USBDI + // USBDI case KErrUsbRequestsPending: case KErrUsbBadAddress: case KErrUsbNoAddress: @@ -188,20 +184,22 @@ case KErrUsbBadDescriptorTopology: case KErrUsbDeviceRejected: case KErrUsbDeviceFailed: - case KErrUsbBadDevice: + case KErrUsbBadDevice: // = -6656 case KErrUsbBadHub: case KErrUsbEventOverflow: + case KErrUsbBadDeviceAttached: - // hosterrors.h + // hosterrors.h case KErrUsbUnsupportedDevice: { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::MessageNotificationReceivedL UnsupportedDevice" ) ); - HandleL(EUsbWatcherErrUnsupportedDevice); + LOG( "UnsupportedDevice" ); + HandleL(EUsbWatcherErrUnsupportedDevice, + EUsbStateHostHandleDropping); break; } default: { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostABase::MessageNotificationReceivedL Unhandled message = %d" ), aMessage)); + LOG1( "Unhandled message = %d" , aMessage); break; } @@ -215,8 +213,8 @@ // void CUsbStateHostABase::BadHubPositionL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::BadHubPositionL" ) ); - HandleL(EUsbWatcherHubsNotSupported); + LOG_FUNC + HandleL(EUsbWatcherHubsNotSupported, EUsbStateHostHandleDropping); } // --------------------------------------------------------------------------- @@ -225,10 +223,28 @@ // void CUsbStateHostABase::VBusErrorL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::VBusErrorL" ) ); + LOG_FUNC // No error code handling after BusClearError call, due to bus will be dropped anyway - iWatcher->Usb().BusClearError(); - HandleL(EUsbWatcherErrDeviceRequiresTooMuchPower); + iWatcher.Usb().BusClearError(); + HandleL(EUsbWatcherErrDeviceRequiresTooMuchPower, + EUsbStateHostHandleDropping); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostABase::SrpReceivedL() + { + LOG_FUNC + + TInt err = iWatcher.Usb().BusRespondSrp(); + if (KErrNone != err) + { + LOG1( "BusRespondSrp error = %d" , err ); + iWatcher.HandleHostProblemL(EUsbWatcherErrorInConnection, + EUsbStateHostHandleDropping); + } } // --------------------------------------------------------------------------- @@ -237,33 +253,21 @@ // void CUsbStateHostABase::SessionRequestedL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::SessionRequestedL" ) ); + LOG_FUNC - if (iWatcher->VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp) + if (iWatcher.VBusObserver()->VBus() == CUsbVBusObserver::EVBusUp) { - // session already ongoing; BusRequest() in this case returns KErrUsbOtgBadState... - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::SessionRequestedL() VBus is already UP; ignore Session request." ) ); + // session already ongoing; BusRequest() in this case returns KErrUsbOtgBadState... + LOG( "VBus is already UP; ignore Session request." ); return; } - TInt err = iWatcher->Usb().BusRequest(); + TInt err = iWatcher.Usb().BusRequest(); if (KErrNone != err && KErrUsbOtgVbusAlreadyRaised != err) // sometimes this also comes... { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostABase::SessionRequestedL BusRequestError err = %d" ), err)); - iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection); + LOG1( "BusRequestError err = %d" , err); + iWatcher.HandleHostProblemL(EUsbWatcherErrorInConnection, + EUsbStateHostHandleDropping); return; } - - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostABase::SessionRequestedL Session started OK (or VBUS already UP) err = %d" ), err)); } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostABase::HandleL(TInt aWhat) - { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostABase::HandleL aWhat = %d" ), aWhat)); - - iWatcher->HandleHostProblemL(aWhat); - } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstatehostahost.cpp --- a/usbengines/usbotgwatcher/src/cusbstatehostahost.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbstatehostahost.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include #include @@ -22,15 +21,8 @@ #include "cusbstatehostahost.h" #include "cusbnotifmanager.h" -#ifndef STIF -#include "cusbtimer.h" -#else -#include "mockcusbtimer.h" -#endif #include "definitions.h" - #include "errors.h" - #include "debug.h" #include "panic.h" @@ -38,7 +30,7 @@ // // --------------------------------------------------------------------------- // -CUsbStateHostAHost::CUsbStateHostAHost(CUsbOtgWatcher* aWatcher) : +CUsbStateHostAHost::CUsbStateHostAHost(CUsbOtgWatcher& aWatcher) : CUsbStateHostABase(aWatcher) { } @@ -49,7 +41,7 @@ // void CUsbStateHostAHost::ConstructL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::ConstructL" ) ); + LOG_FUNC CUsbStateHostABase::ConstructL(); @@ -59,9 +51,9 @@ // // --------------------------------------------------------------------------- // -CUsbStateHostAHost* CUsbStateHostAHost::NewL(CUsbOtgWatcher* aWatcher) +CUsbStateHostAHost* CUsbStateHostAHost::NewL(CUsbOtgWatcher& aWatcher) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::NewL" ) ); + LOG_FUNC CUsbStateHostAHost* self = new (ELeave) CUsbStateHostAHost(aWatcher); CleanupStack::PushL(self); @@ -76,7 +68,7 @@ // CUsbStateHostAHost::~CUsbStateHostAHost() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::~CUsbStateHostAHost" ) ); + LOG_FUNC } @@ -86,8 +78,6 @@ // TUsbStateIds CUsbStateHostAHost::Id() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::Id" ) ); - return EUsbStateHostAHost; } @@ -97,13 +87,15 @@ // void CUsbStateHostAHost::JustAdvancedToThisStateL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::JustAdvancedToThisStateL" ) ); - - User::LeaveIfError( RProperty::Set( KPSUidUsbWatcher, - KUsbWatcherIsPeripheralConnected, - KUsbWatcherPeripheralIsConnected ) ); - - iWatcher->PrintStateToLog(); + LOG_FUNC + + // do general things + CUsbStateHostABase::JustAdvancedToThisStateL(); + + User::LeaveIfError(RProperty::Set(KPSUidUsbWatcher, + KUsbWatcherIsPeripheralConnected, + KUsbWatcherPeripheralIsConnected)); + } // --------------------------------------------------------------------------- @@ -112,31 +104,14 @@ // void CUsbStateHostAHost::JustBeforeLeavingThisStateL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::JustBeforeLeavingThisStateL" ) ); - - User::LeaveIfError( RProperty::Set( KPSUidUsbWatcher, - KUsbWatcherIsPeripheralConnected, - KUsbWatcherPeripheralIsNotConnected ) ); - } + LOG_FUNC -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAHost::AHostL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::AHostL" ) ); - // do nothing - } + User::LeaveIfError(RProperty::Set(KPSUidUsbWatcher, + KUsbWatcherIsPeripheralConnected, + KUsbWatcherPeripheralIsNotConnected)); -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAHost::APeripheralL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::AHostL" ) ); - ChangeHostStateL(EUsbStateHostAPeripheral); + // do general things + CUsbStateHostABase::JustBeforeLeavingThisStateL(); } // --------------------------------------------------------------------------- @@ -145,8 +120,8 @@ // void CUsbStateHostAHost::DeviceDetachedL(TDeviceEventInformation) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::DeviceDetachedL" ) ); - ChangeHostStateL(EUsbStateHostAInitiate); + LOG_FUNC + ChangeHostStateL( EUsbStateHostAInitiate); } // --------------------------------------------------------------------------- @@ -155,6 +130,6 @@ // void CUsbStateHostAHost::BadHubPositionL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::BadHubPositionL" ) ); - Panic(EBadHubPositionEventNotExpected); + LOG_FUNC + Panic( EBadHubPositionEventNotExpected); } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstatehostaidle.cpp --- a/usbengines/usbotgwatcher/src/cusbstatehostaidle.cpp Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -/* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation - * -*/ - - -#include "cusbstatehostaidle.h" -#include "cusbnotifmanager.h" - -#ifndef STIF -#include "cusbtimer.h" -#else -#include "mockcusbtimer.h" -#endif -#include "definitions.h" - -#include "errors.h" -#include "debug.h" -#include "panic.h" - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CUsbStateHostAIdle::CUsbStateHostAIdle(CUsbOtgWatcher* aWatcher) : - CUsbStateHostAInitiateBase(aWatcher) - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAIdle::ConstructL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::ConstructL" ) ); - - CUsbStateHostAInitiateBase::ConstructL(); - } -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// - -CUsbStateHostAIdle* CUsbStateHostAIdle::NewL(CUsbOtgWatcher* aWatcher) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::NewL" ) ); - - CUsbStateHostAIdle* self = new (ELeave) CUsbStateHostAIdle(aWatcher); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CUsbStateHostAIdle::~CUsbStateHostAIdle() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::~CUsbStateHostAIdle" ) ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -TUsbStateIds CUsbStateHostAIdle::Id() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::Id" ) ); - - return EUsbStateHostAIdle; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAIdle::JustAdvancedToThisStateL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::JustAdvancedToThisStateL" ) ); - - iWatcher->PrintStateToLog(); - - // do BusDrop, if Up - if (CUsbVBusObserver::EVBusUp == iWatcher->VBusObserver()->VBus()) - { - TInt err = iWatcher->Usb().BusDrop(); - if (err != KErrNone) - { - err = iWatcher->Usb().BusClearError(); - if (KErrNone != err) - { - iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection); - } - } - } - } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstatehostainitiate.cpp --- a/usbengines/usbotgwatcher/src/cusbstatehostainitiate.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbstatehostainitiate.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,32 +1,33 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ +#include #include "cusbstatehostainitiate.h" #ifndef STIF +#include "cusbtimer.h" #include "cusbnotifmanager.h" -#include "cusbtimer.h" #else #include "mockcusbnotifmanager.h" #include "mockcusbtimer.h" #endif -#include "definitions.h" +#include "definitions.h" #include "errors.h" + #include "debug.h" #include "panic.h" @@ -34,8 +35,8 @@ // // --------------------------------------------------------------------------- // -CUsbStateHostAInitiate::CUsbStateHostAInitiate(CUsbOtgWatcher* aWatcher) : - CUsbStateHostAInitiateBase(aWatcher) +CUsbStateHostAInitiate::CUsbStateHostAInitiate(CUsbOtgWatcher& aWatcher) : + CUsbStateHostABase(aWatcher) { } @@ -45,18 +46,21 @@ // void CUsbStateHostAInitiate::ConstructL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::ConstructL" ) ); + LOG_FUNC - CUsbStateHostAInitiateBase::ConstructL(); + CUsbStateHostABase::ConstructL(); + + iAttachmentTimer = CUsbTimer::NewL(*this, EDeviceAttachmentTimer); + } // --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // -CUsbStateHostAInitiate* CUsbStateHostAInitiate::NewL(CUsbOtgWatcher* aWatcher) +CUsbStateHostAInitiate* CUsbStateHostAInitiate::NewL(CUsbOtgWatcher& aWatcher) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::NewL" ) ); + LOG_FUNC CUsbStateHostAInitiate* self = new (ELeave) CUsbStateHostAInitiate( aWatcher); @@ -72,7 +76,9 @@ // CUsbStateHostAInitiate::~CUsbStateHostAInitiate() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::~CUsbStateHostAInitiate" ) ); + LOG_FUNC + + delete iAttachmentTimer; } // --------------------------------------------------------------------------- @@ -81,9 +87,21 @@ // TUsbStateIds CUsbStateHostAInitiate::Id() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::Id" ) ); + return EUsbStateHostAInitiate; + } - return EUsbStateHostAInitiate; +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostAInitiate::JustBeforeLeavingThisStateL() + { + LOG_FUNC + + iAttachmentTimer->Cancel(); + + // do general things + CUsbStateHostABase::JustBeforeLeavingThisStateL(); } // --------------------------------------------------------------------------- @@ -92,24 +110,24 @@ // void CUsbStateHostAInitiate::JustAdvancedToThisStateL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::JustAdvancedToThisStateL" ) ); + LOG_FUNC - iWatcher->PrintStateToLog(); + // do general things + CUsbStateHostABase::JustAdvancedToThisStateL(); - TInt err = iWatcher->Usb().EnableFunctionDriverLoading(); + TInt err = iWatcher.Usb().EnableFunctionDriverLoading(); if (KErrNone != err) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::JustAdvancedToThisStateL EnableFunctionDriverLoading error" ) ); - iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection); + LOG1( "EnableFunctionDriverLoading err = %d", err ); + iWatcher.HandleHostProblemL(EUsbWatcherCanNotEnableDriverLoading, + EUsbStateHostHandleDropping); return; } - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::JustAdvancedToThisStateL EnableFunctionDriverLoading(); = %d" ), err)); - // do BusRequest, if down - if (CUsbVBusObserver::EVBusUp != iWatcher->VBusObserver()->VBus()) + if (CUsbVBusObserver::EVBusUp != iWatcher.VBusObserver()->VBus()) { const TUint maxTrial = 3; TInt busReqErr(KErrGeneral); @@ -117,15 +135,17 @@ while (count < maxTrial && KErrNone != busReqErr) { - busReqErr = iWatcher->Usb().BusRequest(); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::JustAdvancedToThisStateL BusRequest() = %d" ), err)); + busReqErr = iWatcher.Usb().BusRequest(); + LOG1( "BusRequest() err = %d" , err); if (KErrNone != busReqErr) { - err = iWatcher->Usb().BusClearError(); + err = iWatcher.Usb().BusClearError(); if (KErrNone != err) { - iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection); + iWatcher.HandleHostProblemL( + EUsbWatcherCanNotClearBusError, + EUsbStateHostHandleDropping); return; } } @@ -133,7 +153,8 @@ } if (KErrNone != busReqErr) { - iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection); + iWatcher.HandleHostProblemL(EUsbWatcherCanNotRaiseVBus, + EUsbStateHostHandleDropping); return; } } @@ -143,13 +164,127 @@ } +// From TimerObserver +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostAInitiate::TimerElapsedL(TUsbTimerId aTimerId) + { + LOG_FUNC + + switch (aTimerId) + { + case EDeviceAttachmentTimer: + { + LOG("AttachmentTimer" ); + HandleL(EUsbWatcherErrDandlingCable, EUsbStateHostHandleDropping); + break; + } + default: + { + LOG1( "Unknown timer id = %d", aTimerId ); + Panic( EWrongTimerId); + } + } + } + +// From VBus observer +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostAInitiate::VBusUpL() + { + LOG_FUNC + } + +// From Host Event notification observer // --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // -void CUsbStateHostAInitiate::JustBeforeLeavingThisStateL() +void CUsbStateHostAInitiate::DeviceAttachedL(TDeviceEventInformation aTdi) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiate::JustBeforeLeavingThisStateL" ) ); - - CUsbStateHostAInitiateBase::JustBeforeLeavingThisStateL(); + LOG_FUNC + + iAttachmentTimer->Cancel(); + + // check if an OTG device connected + TOtgDescriptor otgDescriptor; + + // ignore all the errors, assume we connected to not otg + TInt err = iWatcher.Usb().GetOtgDescriptor(aTdi.iDeviceId, otgDescriptor); + LOG1("GetOtgDescriptor() err = %d", err ); + + TBool hnpSupported(otgDescriptor.iAttributes & EUsbOtgHNPSupported); + TBool srpSupported(otgDescriptor.iAttributes & EUsbOtgSRPSupported); + + // OTG device supports both hnp and srp + if (hnpSupported && srpSupported) + { + + HandleL(EUsbWatcherConnectedToOTG, EUsbStateHostHandleDropping); + return; + } + + if (KErrNone != aTdi.iError) + { + switch (aTdi.iError) + // error in attachement + { + case KErrBadPower: + { + LOG( "TooMuchPower" ); + HandleL( + EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration, + EUsbStateHostDelayNotAttachedHandle); + break; + } + default: + { + LOG1("AttachmentError aTdi.iError = %d" , aTdi.iError ); + HandleL(EUsbWatcherErrUnsupportedDevice, + EUsbStateHostHandleDropping); + break; + } + } + + return; + } } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostAInitiate::DriverLoadSuccessL(TDeviceEventInformation) + { + LOG_FUNC + ChangeHostStateL( EUsbStateHostAHost); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostAInitiate::DriverLoadPartialSuccessL( + TDeviceEventInformation) + { + LOG_FUNC + iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgWarning, + EUsbOtgPartiallySupportedDevice, NULL); + ChangeHostStateL( EUsbStateHostAHost); + + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostAInitiate::DriverLoadFailureL(TDeviceEventInformation aDei) + { + LOG_FUNC + + HandleL(EUsbWatcherErrDriversNotFound, EUsbStateHostDelayAttachedHandle); + } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstatehostainitiatebase.cpp --- a/usbengines/usbotgwatcher/src/cusbstatehostainitiatebase.cpp Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,317 +0,0 @@ -/* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation - * -*/ - - -#include -#include - -#include "cusbstatehostainitiatebase.h" -#ifndef STIF -#include "cusbnotifmanager.h" -#include "cusbtimer.h" -#else -#include "mockcusbnotifmanager.h" -#include "mockcusbtimer.h" -#endif - -#include "definitions.h" -#include "errors.h" - -#include "debug.h" -#include "panic.h" - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CUsbStateHostAInitiateBase::CUsbStateHostAInitiateBase( - CUsbOtgWatcher* aWatcher) : - CUsbStateHostABase(aWatcher) - { - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAInitiateBase::ConstructL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::ConstructL" ) ); - - CUsbStateHostABase::ConstructL(); - - iAttachmentTimer = CUsbTimer::NewL(this, EDeviceAttachmentTimer); - - //iUsbPersonalitySwitch = CUsbPersonalitySwitch::NewL(this); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -CUsbStateHostAInitiateBase::~CUsbStateHostAInitiateBase() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::~CUsbStateHostAInitiateBase" ) ); - - delete iAttachmentTimer; - //delete iUsbPersonalitySwitch; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAInitiateBase::JustBeforeLeavingThisStateL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::JustBeforeLeavingThisStateL" ) ); - iAttachmentTimer->Cancel(); - } - -// From TimerObserver -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAInitiateBase::TimerElapsedL(TUsbTimerId aTimerId) - { - switch (aTimerId) - { - case EDeviceAttachmentTimer: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::TimerElapsedL - AttachmentTimer" ) ); - HandleL(EUsbWatcherErrDandlingCable); - break; - } - default: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::TimerElapsedL - Unknown timer" ) ); - Panic(EWrongTimerId); - } - } - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAInitiateBase::VBusUpL() - { - // start timer, waiting for device attachment - iAttachmentTimer->After(KTimeToWaitForDeviceAttachment); - } - -// From VBus observer -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAInitiateBase::VBusDownL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::VBusDownL" ) ); - iAttachmentTimer->Cancel(); - - CUsbStateHostABase::VBusDownL(); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAInitiateBase::AHostL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::AHostL" ) ); - // do nothing - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAInitiateBase::APeripheralL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::AHostL" ) ); - ChangeHostStateL(EUsbStateHostAPeripheral); - } - -// From Host Event notification observer -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAInitiateBase::DeviceAttachedL(TDeviceEventInformation aTdi) - { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL aTdi.iDeviceId = %d" ), aTdi.iDeviceId)); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL aTdi.iEventType = %d" ), aTdi.iEventType)); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL aTdi.iError = %d" ), aTdi.iError)); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL aTdi.iDriverLoadStatus = %d" ), aTdi.iDriverLoadStatus)); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL aTdi.iVid = %d" ), aTdi.iVid)); - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL aTdi.iPid = %d" ), aTdi.iPid)); - - iAttachmentTimer->Cancel(); - - // check if an OTG device connected - TOtgDescriptor otgDescriptor; - - // ignore all the errors, assume we connected to not otg - TInt err = iWatcher->Usb().GetOtgDescriptor(aTdi.iDeviceId, otgDescriptor); - - TBool hnpSupported(otgDescriptor.iAttributes & EUsbOtgHNPSupported); - TBool srpSupported(otgDescriptor.iAttributes & EUsbOtgSRPSupported); - - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL GetOtgDescriptor err = %d, HNP supported = %d, SRP supported = %d" ), err, hnpSupported, srpSupported)); - - // OTG device supports both hnp and srp - if(hnpSupported && srpSupported) - { - HandleL(EUsbWatcherConnectedToOTG); - return; - } - - if (KErrNone != aTdi.iError) - { - switch (aTdi.iError) - // error in attachement - { - case KErrBadPower: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL TooMuchPower" ) ); - HandleL(EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration); - break; - } - default: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DeviceAttachedL AttachmentError" ) ); - HandleL(EUsbWatcherErrUnsupportedDevice); - break; - } - - } - - return; - } - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAInitiateBase::DriverLoadSuccessL(TDeviceEventInformation) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DriverLoadSuccessL" ) ); - ChangeHostStateL(EUsbStateHostAHost); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAInitiateBase::DriverLoadPartialSuccessL( - TDeviceEventInformation) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DriverLoadPartialSuccessL" ) ); - iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgWarning, - EUsbOtgPartiallySupportedDevice, NULL); - ChangeHostStateL(EUsbStateHostAHost); - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAInitiateBase::DriverLoadFailureL( - TDeviceEventInformation aDei) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::DriverLoadFailureL" ) ); - - // try initiate to switch to mass storage - /* if (KErrNone != iUsbPersonalitySwitch->SwitchPersonalityL(aDei.iDeviceId, - KUsbPersonalityIdMS )) - {*/ - HandleL(EUsbWatcherErrDriversNotFound); - // } - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAInitiateBase::SrpReceivedL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::SrpReceivedL" ) ); - if (CUsbVBusObserver::EVBusUp != iWatcher->VBusObserver()->VBus()) - { - TInt err = iWatcher->Usb().BusRespondSrp(); - if (KErrNone != err) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::SrpReceivedL BusRespondSrp error" ) ); - iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection); - } - } - } - -void CUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL( - MUsbPersonalitySwitchObserver::TState aState, TInt aData) - { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL aState = %d aData = %d" ), TInt(aState), aData)); - - switch (aState) - { - case ERequestingAllPersonalities: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL ERequestingAllPersonalities" ) ); - break; - } - case ERequestingSetPersonality: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL ERequestingSetPersonality" ) ); - break; - } - case EGetAllPersonalitiesCompleted: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL EGetAllPersonalitiesCompleted" ) ); - if (KErrNotFound == aData) - { - // no supported or needed personality/ies in the peripheral - HandleL(EUsbWatcherErrDriversNotFound); - } - break; - } - case ESetPersonalityCompleted: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL ESetPersonalityCompleted" ) ); - - break; - } - case ERequestCancelled: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL ERequestCancelled" ) ); - break; - } - case ERequestFailed: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAInitiateBase::UsbPersonalitySwitchStateChangedL ERequestFailed" ) ); - HandleL(EUsbWatcherErrDriversNotFound); - break; - } - default: - { - Panic(EUnexpectedUsbSwitchPersonalityState); - } - } - } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstatehostaperipheral.cpp --- a/usbengines/usbotgwatcher/src/cusbstatehostaperipheral.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbstatehostaperipheral.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,33 +1,24 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include #include "cusbstatehostaperipheral.h" -#ifndef STIF -#include "cusbnotifmanager.h" -#include "cusbtimer.h" -#else -#include "mockcusbnotifmanager.h" -#include "mockcusbtimer.h" -#endif - #include "errors.h" #include "debug.h" #include "panic.h" @@ -36,7 +27,7 @@ // // --------------------------------------------------------------------------- // -CUsbStateHostAPeripheral::CUsbStateHostAPeripheral(CUsbOtgWatcher* aWatcher) : +CUsbStateHostAPeripheral::CUsbStateHostAPeripheral(CUsbOtgWatcher& aWatcher) : CUsbStateHostABase(aWatcher) { } @@ -47,7 +38,7 @@ // void CUsbStateHostAPeripheral::ConstructL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAPeripheral::ConstructL" ) ); + LOG_FUNC CUsbStateHostABase::ConstructL(); } @@ -57,9 +48,9 @@ // --------------------------------------------------------------------------- // CUsbStateHostAPeripheral* CUsbStateHostAPeripheral::NewL( - CUsbOtgWatcher* aWatcher) + CUsbOtgWatcher& aWatcher) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAPeripheral::NewL" ) ); + LOG_FUNC CUsbStateHostAPeripheral* self = new (ELeave) CUsbStateHostAPeripheral( aWatcher); @@ -75,17 +66,7 @@ // CUsbStateHostAPeripheral::~CUsbStateHostAPeripheral() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAPeripheral::~CUsbStateHostAPeripheral" ) ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostAPeripheral::JustAdvancedToThisStateL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAPeripheral::JustAdvancedToThisStateL" ) ); - iWatcher->PrintStateToLog(); + LOG_FUNC } // --------------------------------------------------------------------------- @@ -94,7 +75,6 @@ // TUsbStateIds CUsbStateHostAPeripheral::Id() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAPeripheral::Id" ) ); return EUsbStateHostAPeripheral; } @@ -106,7 +86,7 @@ // void CUsbStateHostAPeripheral::AHostL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAPeripheral::AHostL" ) ); - ChangeHostStateL(EUsbStateHostAInitiate); + LOG_FUNC + ChangeHostStateL( EUsbStateHostAInitiate); } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstatehostdelayattachedhandle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbengines/usbotgwatcher/src/cusbstatehostdelayattachedhandle.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ + +#include + +#include "cusbstatehostdelayattachedhandle.h" +#ifndef STIF +#include "cusbtimer.h" +#else +#include "mockcusbtimer.h" +#endif + +#include "errors.h" +#include "debug.h" +#include "panic.h" + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostDelayAttachedHandle::CUsbStateHostDelayAttachedHandle( + CUsbOtgWatcher& aWatcher) : + CUsbStateHostDelayHandle(aWatcher) + { + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostDelayAttachedHandle* CUsbStateHostDelayAttachedHandle::NewL( + CUsbOtgWatcher& aWatcher) + { + LOG_FUNC + + CUsbStateHostDelayAttachedHandle* self = + new (ELeave) CUsbStateHostDelayAttachedHandle(aWatcher); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayAttachedHandle::ConstructL() + { + LOG_FUNC + + CUsbStateHostDelayHandle::ConstructL(); + iDriversNotFoundTimer = CUsbTimer::NewL(*this, EDriversNotFoundTimer); + + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostDelayAttachedHandle::~CUsbStateHostDelayAttachedHandle() + { + LOG_FUNC + + delete iDriversNotFoundTimer; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +TUsbStateIds CUsbStateHostDelayAttachedHandle::Id() + { + return EUsbStateHostDelayAttachedHandle; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayAttachedHandle::JustBeforeLeavingThisStateL() + { + LOG_FUNC + + iDriversNotFoundTimer->Cancel(); + + // do general things + CUsbStateHostDelayHandle::JustBeforeLeavingThisStateL(); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayAttachedHandle::DoHandleL() + { + LOG_FUNC + LOG1( "iWhat = %d" , iWhat); + + switch (iWhat) + { + case EUsbWatcherErrDriversNotFound: + { + LOG("DriversNotFound" ); + + iDriversNotFoundTimer->After(KTimeDriversNotFound); + break; + + } + + default: + { + LOG1("Unexpected request id = %d" , iWhat ); + Panic( EUnexpectedSituationToHandle); + break; + } + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayAttachedHandle::DeviceDetachedL( + TDeviceEventInformation) + { + LOG_FUNC + + ChangeHostStateL( EUsbStateHostAInitiate); + } + +// From TimerObserver +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayAttachedHandle::TimerElapsedL(TUsbTimerId aTimerId) + { + LOG_FUNC + + switch (aTimerId) + { + case EDriversNotFoundTimer: + { + LOG( "EDriversNotFoundTimer" ); + HandleL(EUsbWatcherErrUnsupportedDevice, + EUsbStateHostHandleDropping); + + break; + } + default: + { + LOG1( "Unknown timer id = %d", aTimerId ); + Panic( EWrongTimerId); + } + } + } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstatehostdelayhandle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbengines/usbotgwatcher/src/cusbstatehostdelayhandle.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ + +#include "cusbstatehostdelayhandle.h" + +#include "errors.h" +#include "debug.h" +#include "panic.h" + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostDelayHandle::CUsbStateHostDelayHandle(CUsbOtgWatcher& aWatcher) : + CUsbStateHostHandle(aWatcher) + { + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayHandle::ConstructL() + { + LOG_FUNC + + CUsbStateHostHandle::ConstructL(); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostDelayHandle::~CUsbStateHostDelayHandle() + { + LOG_FUNC + } + +///////////////////////////////////////////////////////////////////////////////////// +// From VBus observer +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayHandle::VBusUpL() + { + LOG_FUNC + // this is not expected, due to in this state vbus already up, since entering the state + Panic( EVBusUpNotExpected); + } + +// From Host Event notification observer +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayHandle::DeviceAttachedL( + TDeviceEventInformation aDevEventInfo) + { + LOG_FUNC + + ChangeHostStateL( EUsbStateHostAInitiate); + iWatcher.DeviceAttachedL(aDevEventInfo); + } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstatehostdelaynotattachedhandle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbengines/usbotgwatcher/src/cusbstatehostdelaynotattachedhandle.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ + +#include "cusbstatehostdelaynotattachedhandle.h" + +#include "errors.h" +#include "debug.h" +#include "panic.h" + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostDelayNotAttachedHandle::CUsbStateHostDelayNotAttachedHandle( + CUsbOtgWatcher& aWatcher) : + CUsbStateHostDelayHandle(aWatcher) + { + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostDelayNotAttachedHandle* CUsbStateHostDelayNotAttachedHandle::NewL( + CUsbOtgWatcher& aWatcher) + { + LOG_FUNC + + CUsbStateHostDelayNotAttachedHandle* self = + new (ELeave) CUsbStateHostDelayNotAttachedHandle(aWatcher); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayNotAttachedHandle::ConstructL() + { + LOG_FUNC + + CUsbStateHostDelayHandle::ConstructL(); + + iTooMuchPowerTimer = CUsbTimer::NewL(*this, ETooMuchPowerRequiredTimer); + + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostDelayNotAttachedHandle::~CUsbStateHostDelayNotAttachedHandle() + { + LOG_FUNC + + delete iTooMuchPowerTimer; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +TUsbStateIds CUsbStateHostDelayNotAttachedHandle::Id() + { + return EUsbStateHostDelayNotAttachedHandle; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayNotAttachedHandle::JustBeforeLeavingThisStateL() + { + LOG_FUNC + + iTooMuchPowerTimer->Cancel(); + + // do general things + CUsbStateHostDelayHandle::JustBeforeLeavingThisStateL(); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayNotAttachedHandle::DoHandleL() + { + LOG_FUNC + LOG1( "iWhat = %d" , iWhat); + + switch (iWhat) + { + case EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration: + { + LOG("EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration" ); + + iTooMuchPowerTimer->After(KTimeTooMuchPowerRequired); + break; + } + + default: + { + LOG1("Unexpected request id = %d", iWhat); + Panic( EUnexpectedSituationToHandle); + break; + } + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayNotAttachedHandle::AIdleL() + { + LOG_FUNC + + // Exit on AIdle, due to Detachment not comes, + // because no corresponding attachment with err == KErrNone + ChangeHostStateL( EUsbStateHostAInitiate); + + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayNotAttachedHandle::DeviceDetachedL( + TDeviceEventInformation) + { + LOG_FUNC + Panic( EDeviceDetachedNotExpected); + + } + +// From TimerObserver +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostDelayNotAttachedHandle::TimerElapsedL(TUsbTimerId aTimerId) + { + LOG_FUNC + switch (aTimerId) + { + case ETooMuchPowerRequiredTimer: + { + LOG("ETooMuchPowerRequiredTimer" ); + HandleL(EUsbWatcherErrDeviceRequiresTooMuchPower, + EUsbStateHostHandleDropping); + break; + } + default: + { + LOG1("Unknown timer id = %d", aTimerId ); + Panic( EWrongTimerId); + } + } + } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstatehosthandle.cpp --- a/usbengines/usbotgwatcher/src/cusbstatehosthandle.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbstatehosthandle.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,29 +1,21 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - - -#include + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include "cusbstatehosthandle.h" -#ifndef STIF -#include "cusbnotifmanager.h" -#else -#include "mockcusbnotifmanager.h" -#endif #include "errors.h" #include "debug.h" @@ -33,8 +25,8 @@ // // --------------------------------------------------------------------------- // -CUsbStateHostHandle::CUsbStateHostHandle(CUsbOtgWatcher* aWatcher) : - CUsbState(aWatcher) +CUsbStateHostHandle::CUsbStateHostHandle(CUsbOtgWatcher& aWatcher) : + CUsbStateHostABase(aWatcher) { } @@ -42,27 +34,11 @@ // // --------------------------------------------------------------------------- // -CUsbStateHostHandle* CUsbStateHostHandle::NewL(CUsbOtgWatcher* aWatcher) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::NewL" ) ); - - CUsbStateHostHandle* self = new (ELeave) CUsbStateHostHandle(aWatcher); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// void CUsbStateHostHandle::ConstructL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::ConstructL" ) ); + LOG_FUNC - iTooMuchPowerTimer = CUsbTimer::NewL(this, ETooMuchPowerRequiredTimer); - iDriversNotFoundTimer = CUsbTimer::NewL(this, EDriversNotFoundTimer); + CUsbStateHostABase::ConstructL(); } @@ -72,21 +48,7 @@ // CUsbStateHostHandle::~CUsbStateHostHandle() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::~CUsbStateHostHandle" ) ); - - delete iTooMuchPowerTimer; - delete iDriversNotFoundTimer; - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -TUsbStateIds CUsbStateHostHandle::Id() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::Id" ) ); - - return EUsbStateHostHandle; + LOG_FUNC } // --------------------------------------------------------------------------- @@ -95,467 +57,34 @@ // void CUsbStateHostHandle::JustAdvancedToThisStateL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::JustAdvancedToThisStateL" ) ); - iWatcher->PrintStateToLog(); + LOG_FUNC + // first do general things + CUsbStateHostABase::JustAdvancedToThisStateL(); + + // then, do specific things DoHandleL(); + } // --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // -void CUsbStateHostHandle::JustBeforeLeavingThisStateL() - { - iTooMuchPowerTimer->Cancel(); - iDriversNotFoundTimer->Cancel(); - - iWatcher->NotifManager()->CloseAllNotifiers(); - } -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// void CUsbStateHostHandle::SetWhat(TInt aWhat) { iWhat = aWhat; } -// this means only one wait notifier at a time can be shown by this state -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::WaitNotifierCompletedL(TInt /*aFeedback*/) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL" ) ); - switch (iWhat) - { - case EUsbWatcherErrDriversNotFound: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL DriversNotFound" ) ); - ChangeHostStateL(EUsbStateHostAInitiate); - break; - } - case EUsbWatcherHubsNotSupported: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherHubsNotSupported" ) ); - ChangeHostStateL(EUsbStateHostAInitiate); - break; - } - case EUsbWatcherErrDeviceRequiresTooMuchPower: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrDeviceRequiresTooMuchPower" ) ); - ChangeHostStateL(EUsbStateHostAInitiate); - break; - } - case EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration" ) ); - ChangeHostStateL(EUsbStateHostAInitiate); - break; - } - case EUsbWatcherErrUnsupportedDevice: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrUnsupportedDevice" ) ); - ChangeHostStateL(EUsbStateHostAInitiate); - break; - } - case EUsbWatcherConnectedToOTG: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherConnectedToOTG" ) ); - ChangeHostStateL(EUsbStateHostAInitiate); - break; - } - case EUsbWatcherErrDandlingCable: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrDandlingCable" ) ); - ChangeHostStateL(EUsbStateHostAInitiate); - break; - } - case EUsbWatcherNoActivity: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherNoActivity" ) ); - ChangeHostStateL(EUsbStateHostAInitiate); - break; - } - case EUsbWatcherErrorInConnection: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrorInConnection" ) ); - ChangeHostStateL(EUsbStateHostAInitiate); - break; - } - case EUsbWatcherCanNotStartUsbServices: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherCanNotStartUsbServices" ) ); - - break; - } - // errors from observers mapped to one - case EUsbWatcherIdPinError: - case EUsbWatcherVBusObserverError: - case EUsbWatcherHostEventNotificationError: - case EUsbWatcherOtgStateError: - case EUsbWatcherMessageNotificationError: - { - // try to restore - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL Error in observer" ) ); - ChangeHostStateL(EUsbStateHostAInitiate); - break; - } - default: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL Unexpected situation to be handled" ) ); - Panic(EUnexpectedSituationToHandle); - break; - } - - } - } - +// From message notification observer // --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // -void CUsbStateHostHandle::DoHandleL() - { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL iWhat = %d" ), iWhat)); - - if (iTooMuchPowerTimer) - iTooMuchPowerTimer->Cancel(); - - switch (iWhat) - { - case EUsbWatcherErrDriversNotFound: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL DriversNotFound" ) ); - - iDriversNotFoundTimer->After(KTimeDriversNotFound); - break; - - } - case EUsbWatcherHubsNotSupported: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherHubsNotSupported" ) ); - // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped - iWatcher->Usb().BusDrop(); - iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, - EUsbOtgHubUnsupported, this); - break; - } - case EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration" ) ); - - iTooMuchPowerTimer->After(KTimeTooMuchPowerRequired); - break; - } - case EUsbWatcherErrDeviceRequiresTooMuchPower: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrDeviceRequiresTooMuchPower" ) ); - // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped - iWatcher->Usb().BusDrop(); - iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, - EUsbOtgTooMuchPower, this); - break; - } - case EUsbWatcherErrUnsupportedDevice: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrUnsupportedDevice" ) ); - // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped - iWatcher->Usb().BusDrop(); - iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, - EUsbOtgUnsupportedDevice, this); - break; - } - case EUsbWatcherConnectedToOTG: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherConnectedToOTG" ) ); - - // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped - iWatcher->Usb().BusDrop(); - iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, - EUsbOtgUnsupportedDevice, this); - break; - } - case EUsbWatcherErrDandlingCable: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrDandlingCable" ) ); - // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped - iWatcher->Usb().BusDrop(); - iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, - EUsbOtgErrorAttachTimedOut, this); - break; - } - case EUsbWatcherNoActivity: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherNoActivity" ) ); - // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped - iWatcher->Usb().BusDrop(); - iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, - EUsbOtgUnsupportedDevice, this); - - break; - } - case EUsbWatcherErrorInConnection: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrorInConnection" ) ); - // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped - iWatcher->Usb().BusDrop(); - iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, - EUsbOtgErrorInConnection, this); - break; - } - case EUsbWatcherCanNotStartUsbServices: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherCanNotStartUsbServices" ) ); - iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, - EUsbOtgErrorInConnection, this); - break; - } - // errors from observers mapped to one - case EUsbWatcherIdPinError: - case EUsbWatcherVBusObserverError: - case EUsbWatcherHostEventNotificationError: - case EUsbWatcherOtgStateError: - case EUsbWatcherMessageNotificationError: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL Error from observer" ) ); - // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped - iWatcher->Usb().BusDrop(); - iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, - EUsbOtgErrorInConnection, this); - break; - } - default: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL Unexpected situation to be handled" ) ); - Panic(EUnexpectedSituationToHandle); - break; - } - } - } - -///////////////////////////////////////////////////////////////////////////////////// -// just ignore all the events -// From VBus observer -void CUsbStateHostHandle::VBusDownL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::VBusDownL" ) ); - } - -// From OTG state observer -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::AIdleL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::AIdleL" ) ); - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::AHostL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::AHostL" ) ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::APeripheralL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::APeripheralL" ) ); - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::AVBusErrorL() +void CUsbStateHostHandle::MessageNotificationReceivedL(TInt aMessage) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::AVBusErrorL" ) ); - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::BIdleL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BIdleL" ) ); - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::BPeripheralL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BPeripheralL" ) ); - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::BHostL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BHostL" ) ); - - } - -// From bus activity observer -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::BusIdleL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BusIdleL" ) ); - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::BusActiveL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BusActiveL" ) ); - - } - -// From Host Event notification observer -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::DeviceAttachedL( - TDeviceEventInformation aDevEventInfo) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL" ) ); - - if (iTooMuchPowerTimer->IsActive() || iDriversNotFoundTimer->IsActive()) - { - ChangeHostStateL(EUsbStateHostAInitiate); - iWatcher->DeviceAttachedL(aDevEventInfo); - return; - } - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL Unexpected situation" ) ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::DeviceDetachedL(TDeviceEventInformation) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceDetachedL" ) ); - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::DriverLoadSuccessL(TDeviceEventInformation) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadSuccessL" ) ); - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::DriverLoadPartialSuccessL(TDeviceEventInformation) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadPartialSuccessL" ) ); - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::DriverLoadFailureL(TDeviceEventInformation) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadFailureL" ) ); - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::BadHubPositionL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BadHubPositionL" ) ); - - if (iTooMuchPowerTimer->IsActive()) - { - ChangeHostStateL(EUsbStateHostAInitiate); - iWatcher->BadHubPositionL(); - } - else - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL Unexpected situation" ) ); - } - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::VBusErrorL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::VBusErrorL" ) ); - - iWatcher->Usb().BusClearError(); - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::VBusErrorL Unexpected situation" ) ); - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::MessageNotificationReceivedL(TInt) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::MessageNotificationReceivedL" ) ); - - } - -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::SrpReceivedL() - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::SrpReceivedL" ) ); - - if (CUsbVBusObserver::EVBusUp != iWatcher->VBusObserver()->VBus()) - { - TInt err = iWatcher->Usb().BusRespondSrp(); - if (KErrNone != err) - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::SrpReceivedL BusRespondSrp error" ) ); - iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection); - } - else - { - ChangeHostStateL(EUsbStateHostAInitiate); - } - } + LOG_FUNC + LOG1( "Unhandled message aMessage = %d" , aMessage); } @@ -565,41 +94,5 @@ // void CUsbStateHostHandle::SessionRequestedL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::SessionRequestedL" ) ); - + LOG_FUNC } - -// From TimerObserver -// --------------------------------------------------------------------------- -// -// --------------------------------------------------------------------------- -// -void CUsbStateHostHandle::TimerElapsedL(TUsbTimerId aTimerId) - { - switch (aTimerId) - { - case ETooMuchPowerRequiredTimer: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::TimerElapsedL - ETooMuchPowerRequiredTimer" ) ); - iWatcher->Usb().BusDrop(); - iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, - EUsbOtgTooMuchPowerRequired, this); - break; - } - case EDriversNotFoundTimer: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::TimerElapsedL - EDriversNotFoundTimer" ) ); - // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped - iWatcher->Usb().BusDrop(); - iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, - EUsbOtgUnsupportedDevice, this); - - break; - } - default: - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::TimerElapsedL - Unknown timer" ) ); - Panic(EWrongTimerId); - } - } - } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstatehosthandledropping.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbengines/usbotgwatcher/src/cusbstatehosthandledropping.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,382 @@ +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ + +#include +#include + +#include "cusbstatehosthandledropping.h" +#ifndef STIF +#include "cusbnotifmanager.h" +#else +#include "mockcusbnotifmanager.h" +#endif + +#include "errors.h" +#include "debug.h" +#include "panic.h" + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostHandleDropping::CUsbStateHostHandleDropping( + CUsbOtgWatcher& aWatcher) : + CUsbStateHostHandle(aWatcher) + { + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostHandleDropping* CUsbStateHostHandleDropping::NewL( + CUsbOtgWatcher& aWatcher) + { + LOG_FUNC + + CUsbStateHostHandleDropping* self = + new (ELeave) CUsbStateHostHandleDropping(aWatcher); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostHandleDropping::ConstructL() + { + LOG_FUNC + CUsbStateHostHandle::ConstructL(); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostHandleDropping::~CUsbStateHostHandleDropping() + { + LOG_FUNC + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +TUsbStateIds CUsbStateHostHandleDropping::Id() + { + return EUsbStateHostHandleDropping; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostHandleDropping::JustBeforeLeavingThisStateL() + { + LOG_FUNC + + iWatcher.NotifManager()->CloseAllNotifiers(); + + // do general things + CUsbStateHostHandle::JustBeforeLeavingThisStateL(); + } + +// this means only one wait notifier at a time can be shown by this state +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostHandleDropping::WaitNotifierCompletedL(TInt /*aFeedback*/) + { + LOG_FUNC + + switch (iWhat) + { + case EUsbWatcherHubsNotSupported: + { + LOG( "EUsbWatcherHubsNotSupported" ); + ChangeHostStateL( EUsbStateHostAInitiate); + break; + } + case EUsbWatcherErrDeviceRequiresTooMuchPower: + { + LOG( "EUsbWatcherErrDeviceRequiresTooMuchPower" ); + ChangeHostStateL( EUsbStateHostAInitiate); + break; + } + case EUsbWatcherErrUnsupportedDevice: + { + LOG("EUsbWatcherErrUnsupportedDevice" ); + ChangeHostStateL( EUsbStateHostAInitiate); + break; + } + case EUsbWatcherConnectedToOTG: + { + LOG("EUsbWatcherConnectedToOTG" ); + ChangeHostStateL( EUsbStateHostAInitiate); + break; + } + case EUsbWatcherErrDandlingCable: + { + LOG("EUsbWatcherErrDandlingCable" ); + ChangeHostStateL( EUsbStateHostAInitiate); + break; + } + case EUsbWatcherNoActivity: + { + LOG("EUsbWatcherNoActivity" ); + ChangeHostStateL( EUsbStateHostAInitiate); + break; + } + case EUsbWatcherErrorInConnection: + { + LOG( "EUsbWatcherErrorInConnection" ); + ChangeHostStateL( EUsbStateHostAInitiate); + break; + } + + // fatal errors + case EUsbWatcherCanNotStartUsbServices: + { + LOG( "EUsbWatcherCanNotStartUsbServices" ); + + // no break here + } + + // no break statement for following cases + case EUsbWatcherIdPinError: + case EUsbWatcherVBusObserverError: + case EUsbWatcherHostEventNotificationError: + case EUsbWatcherOtgStateError: + case EUsbWatcherMessageNotificationError: + case EUsbWatcherCanNotStartSession: + case EUsbWatcherCanNotEnableDriverLoading: + case EUsbWatcherCanNotClearBusError: + case EUsbWatcherCanNotRaiseVBus: + { + LOG("Fatal error" ); + ChangeHostStateL( EUsbStateHostUndefined); + break; + } + default: + { + LOG1("Unexpected situation to be handled iWhat = %d" , iWhat ); + Panic( EUnexpectedSituationToHandle); + break; + } + + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostHandleDropping::DoHandleL() + { + LOG_FUNC + + LOG1( "iWhat = %d" , iWhat); + + // Drop VBus first + // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped + iWatcher.Usb().BusDrop(); + + switch (iWhat) + { + + case EUsbWatcherHubsNotSupported: + { + LOG("EUsbWatcherHubsNotSupported" ); + iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, + EUsbOtgHubUnsupported, this); + break; + } + case EUsbWatcherErrDeviceRequiresTooMuchPower: + { + LOG("EUsbWatcherErrDeviceRequiresTooMuchPower" ); + iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, + EUsbOtgTooMuchPower, this); + break; + } + case EUsbWatcherErrUnsupportedDevice: + { + LOG("EUsbWatcherErrUnsupportedDevice" ); + iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, + EUsbOtgUnsupportedDevice, this); + break; + } + case EUsbWatcherConnectedToOTG: + { + LOG("EUsbWatcherConnectedToOTG" ); + iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, + EUsbOtgUnsupportedDevice, this); + + break; + } + case EUsbWatcherErrDandlingCable: + { + LOG( "EUsbWatcherErrDandlingCable" ); + iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, + EUsbOtgErrorAttachTimedOut, this); + break; + } + case EUsbWatcherNoActivity: + { + LOG( "EUsbWatcherNoActivity" ); + iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, + EUsbOtgUnsupportedDevice, this); + + break; + } + case EUsbWatcherErrorInConnection: + { + LOG("EUsbWatcherErrorInConnection" ); + iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, + EUsbOtgErrorInConnection, this); + break; + } + case EUsbWatcherCanNotStartUsbServices: + { + LOG("EUsbWatcherCanNotStartUsbServices" ); + // no break here + } + // no break in following cases + case EUsbWatcherIdPinError: + case EUsbWatcherVBusObserverError: + case EUsbWatcherHostEventNotificationError: + case EUsbWatcherOtgStateError: + case EUsbWatcherMessageNotificationError: + case EUsbWatcherCanNotStartSession: + case EUsbWatcherCanNotEnableDriverLoading: + case EUsbWatcherCanNotClearBusError: + case EUsbWatcherCanNotRaiseVBus: + { + LOG1( "Fatal error iWhat = %d", iWhat ); + iWatcher.NotifManager()->ShowNotifierL(KUsbUiNotifOtgError, + EUsbOtgErrorInConnection, this); + break; + } + default: + { + LOG1("Unexpected situation to be handled iWhat = %d", iWhat ); + Panic( EUnexpectedSituationToHandle); + break; + } + } + } + +///////////////////////////////////////////////////////////////////////////////////// +// From VBus observer +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostHandleDropping::VBusUpL() + { + LOG_FUNC + ChangeHostStateL( EUsbStateHostAInitiate); + } + +// --------------------------------------------------------------------------- +// this is expected in the state, for example after calling BusDrop +// --------------------------------------------------------------------------- +// +void CUsbStateHostHandleDropping::VBusDownL() + { + LOG_FUNC + } + +// From Host Event notification observer +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostHandleDropping::DeviceAttachedL( + TDeviceEventInformation aDevEventInfo) + { + LOG_FUNC + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostHandleDropping::DeviceDetachedL(TDeviceEventInformation) + { + LOG_FUNC + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostHandleDropping::DriverLoadSuccessL(TDeviceEventInformation) + { + LOG_FUNC + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostHandleDropping::DriverLoadPartialSuccessL( + TDeviceEventInformation) + { + LOG_FUNC + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostHandleDropping::DriverLoadFailureL(TDeviceEventInformation) + { + LOG_FUNC + } + +// From message notification observer +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostHandleDropping::MessageNotificationReceivedL(TInt aMessage) + { + LOG_FUNC + + LOG1( "aMessage = %d", aMessage ) + + switch (aMessage) + { + // USBDI + case KEventUsbBadDeviceDetached: + { + LOG("BadDeviceDetached" ); + ChangeHostStateL( EUsbStateHostUndefined); + break; + } + default: + { + LOG1( "Unhandled message aMessage = %d" , aMessage); + break; + } + + } + } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbstatehostundefined.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbengines/usbotgwatcher/src/cusbstatehostundefined.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ + +#include "cusbstatehostundefined.h" + +#include "definitions.h" +#include "errors.h" + +#include "debug.h" +#include "panic.h" + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostUndefined::CUsbStateHostUndefined(CUsbOtgWatcher& aWatcher) : + CUsbStateHostABase(aWatcher) + { + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostUndefined* CUsbStateHostUndefined::NewL(CUsbOtgWatcher& aWatcher) + { + LOG_FUNC + + CUsbStateHostUndefined* self = new (ELeave) CUsbStateHostUndefined( + aWatcher); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostUndefined::ConstructL() + { + LOG_FUNC + + CUsbStateHostABase::ConstructL(); + + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CUsbStateHostUndefined::~CUsbStateHostUndefined() + { + LOG_FUNC + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +TUsbStateIds CUsbStateHostUndefined::Id() + { + return EUsbStateHostUndefined; + } + +// From VBus observer +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostUndefined::VBusDownL() + { + LOG_FUNC + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostUndefined::VBusUpL() + { + LOG_FUNC + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostUndefined::VBusErrorL() + { + LOG_FUNC + iWatcher.Usb().BusClearError(); + } + +// From OTG state observer +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostUndefined::AVBusErrorL() + { + LOG_FUNC + iWatcher.Usb().BusClearError(); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostUndefined::BIdleL() + { + LOG_FUNC + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostUndefined::BPeripheralL() + { + LOG_FUNC + } + +// From host state observer +void CUsbStateHostUndefined::DeviceDetachedL(TDeviceEventInformation /*aInfo*/) + { + LOG_FUNC + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostUndefined::SrpReceivedL() + { + LOG_FUNC + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostUndefined::SessionRequestedL() + { + LOG_FUNC + } + +// From message notification observer +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostUndefined::MessageNotificationReceivedL(TInt aMessage) + { + LOG_FUNC + LOG1( "Unhandled message aMessage = %d" , aMessage); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CUsbStateHostUndefined::BadHubPositionL() + { + LOG_FUNC + Panic( EBadHubPositionNotExpected); + } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbtimer.cpp --- a/usbengines/usbotgwatcher/src/cusbtimer.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbtimer.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include "cusbtimer.h" @@ -24,7 +23,7 @@ // // --------------------------------------------------------------------------- // -CUsbTimer::CUsbTimer(MUsbTimerObserver* aObserver, TUsbTimerId aTimerId) : +CUsbTimer::CUsbTimer(MUsbTimerObserver& aObserver, TUsbTimerId aTimerId) : CActive(CActive::EPriorityStandard), iObserver(aObserver), iTimerId( aTimerId) { @@ -37,7 +36,7 @@ // CUsbTimer::~CUsbTimer() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbTimer::~CUsbTimer" ) ); + LOG_FUNC Cancel(); iTimer.Close(); } @@ -48,7 +47,7 @@ // void CUsbTimer::ConstructL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbTimer::ConstructL" ) ); + LOG_FUNC User::LeaveIfError(iTimer.CreateLocal()); } @@ -56,12 +55,11 @@ // // --------------------------------------------------------------------------- // -CUsbTimer* CUsbTimer::NewL(MUsbTimerObserver* anObserver, - TUsbTimerId aTimerId) +CUsbTimer* CUsbTimer::NewL(MUsbTimerObserver& aObserver, TUsbTimerId aTimerId) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbTimer::NewL" ) ); + LOG_FUNC - CUsbTimer* self = new (ELeave) CUsbTimer(anObserver, aTimerId); + CUsbTimer* self = new (ELeave) CUsbTimer(aObserver, aTimerId); CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(self); // pop self @@ -74,9 +72,7 @@ // void CUsbTimer::After(TInt aMilliseconds) { -// FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbTimer::After aMilliseconds %d, timerId=%d" ), aMilliseconds, iTimerId)) - - if (IsActive()) // should we panic here? or just restart timer + if (IsActive()) { Cancel(); } @@ -93,13 +89,12 @@ void CUsbTimer::RunL() { - if(KErrNone != iStatus.Int()) + if (KErrNone != iStatus.Int()) { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbTimer::RunL iStatus %d" ), iStatus.Int())); User::Leave(iStatus.Int()); } - iObserver->TimerElapsedL(iTimerId); + iObserver.TimerElapsedL(iTimerId); } // --------------------------------------------------------------------------- @@ -108,7 +103,8 @@ // TInt CUsbTimer::RunError(TInt aError) { - FTRACE(FPrint(_L( "[USBOTGWATCHER]\tCUsbTimer::RunError aError %d" ), aError )); + LOG_FUNC + LOG1( "aError = %d" , aError ); return KErrNone; } @@ -119,6 +115,5 @@ // void CUsbTimer::DoCancel() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbTimer::DoCancel" ) ) iTimer.Cancel(); } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbvbusobserver.cpp --- a/usbengines/usbotgwatcher/src/cusbvbusobserver.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbvbusobserver.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Implementation + * + */ #include @@ -40,8 +39,7 @@ // void CUsbVBusObserver::ConstructL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::ConstructL" ) ); + LOG_FUNC User::LeaveIfError(iVBus.Attach(KUidUsbManCategory, KUsbOtgVBusPoweredProperty)); @@ -54,8 +52,7 @@ // CUsbVBusObserver* CUsbVBusObserver::NewL() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::NewL" ) ); + LOG_FUNC CUsbVBusObserver* self = new (ELeave) CUsbVBusObserver(); CleanupStack::PushL(self); @@ -70,8 +67,7 @@ // CUsbVBusObserver::~CUsbVBusObserver() { - - FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::~CUsbVBusObserver" ) ); + LOG_FUNC Cancel(); @@ -85,24 +81,19 @@ // // --------------------------------------------------------------------------- // -CUsbVBusObserver::TState CUsbVBusObserver::VBus() /* not const, because for some reason RProperty::Get is not const! */ +CUsbVBusObserver::TState CUsbVBusObserver::VBus() /* not const, because for some reason RProperty::Get is not const */ { - FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::VBus" ) ); - TInt val(0); TInt err = iVBus.Get(val); if (KErrNone != err) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::VBus CanNotGetVBusProperty" ) ); - Panic(ECanNotGetVBusProperty); + LOG("CanNotGetVBusProperty" ) + Panic( ECanNotGetVBusProperty); } - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::VBus = %d" ), val )); - - // not found in docs clear definition of this property. Verification is needed return (0 == val ? EVBusDown : EVBusUp); } @@ -110,13 +101,19 @@ // // --------------------------------------------------------------------------- // -void CUsbVBusObserver::SubscribeL(MUsbVBusObserver* aObserver) +void CUsbVBusObserver::SubscribeL(MUsbVBusObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::SubscribeL" ) ); + LOG_FUNC - User::LeaveIfError(iObservers.Append(aObserver)); - - FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::SubscribeL Observer appended." ) ); + // check if the same observer already exist in a list + if (KErrNotFound != iObservers.Find(&aObserver)) + { + LOG( "Observer already exists" ); + Panic( EObserverAlreadyExists); + return; + } + + iObservers.AppendL(&aObserver); if (KFirst == iObservers.Count()) // first item { @@ -129,39 +126,24 @@ // // --------------------------------------------------------------------------- // -void CUsbVBusObserver::UnsubscribeL(MUsbVBusObserver* aObserver) +void CUsbVBusObserver::UnsubscribeL(MUsbVBusObserver& aObserver) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::UnsubscribeL" ) ); - - if (0 == iObservers.Count()) // no items + LOG_FUNC + + TInt i(iObservers.Find(&aObserver)); + if (KErrNotFound == i) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::UnsubscribeL No observers" ) ); + LOG("Observer not found" ); + Panic( ECanNotFindVBusObserver); return; } - - TInt i(0); - while (i < iObservers.Count() && aObserver != iObservers[i]) - { - ++i; - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::UnsubscribeL i = %d" ), i )); - } - if (aObserver == iObservers[i]) // found - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::UnsubscribeL Removing item" ) ); - iObservers.Remove(i); - } - else - { - FLOG( _L( "[USBOTGWATCHER]\tCUsbVBusObserver::UnsubscribeL CanNotFindVBusObserver" ) ); - Panic(ECanNotFindVBusObserver); - } - + iObservers.Remove(i); + if (0 == iObservers.Count()) // no observers anymore { // cancel pending request, if any Cancel(); - return; } } @@ -171,17 +153,19 @@ // void CUsbVBusObserver::RunL() { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::RunL iStatus = %d" ), iStatus.Int())); + LOG_FUNC + + LOG1( "iStatus = %d" , iStatus.Int()); - // if error occured, tell to Observers - if(KErrNone != iStatus.Int()) + // if error occured, tell to Observers + if (KErrNone != iStatus.Int()) + { + for (TInt i(0); i < iObservers.Count(); ++i) { - for (TInt i(0); i < iObservers.Count(); ++i) - { - iObservers[i]->VBusObserverErrorL(iStatus.Int()); - } - return; + iObservers[i]->VBusObserverErrorL(iStatus.Int()); } + return; + } // re-issue request first iVBus.Subscribe(iStatus); @@ -195,7 +179,7 @@ { case EVBusUp: { - FLOG(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::RunL VBus UP")); + LOG("VBus UP"); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -207,7 +191,7 @@ case EVBusDown: { - FLOG(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::RunL VBus DOWN")); + LOG("VBus DOWN"); for (TInt i(0); i < iObservers.Count(); ++i) { @@ -219,7 +203,8 @@ default: { - Panic(EWrongVBusState); + LOG("WrongVBusState"); + Panic( EWrongVBusState); } } @@ -240,8 +225,9 @@ // TInt CUsbVBusObserver::RunError(TInt aError) { + LOG_FUNC - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbVBusObserver::RunError aError = %d" ), aError)); + LOG1( "aError = %d" , aError); // try to continue return KErrNone; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbwaitnotifier.cpp --- a/usbengines/usbotgwatcher/src/cusbwaitnotifier.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbwaitnotifier.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Usb waiting notifier implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Usb waiting notifier implementation + * + */ #include #include @@ -32,9 +31,9 @@ // ----------------------------------------------------------------------------- // CUsbWaitNotifier* CUsbWaitNotifier::NewL(RNotifier& aNotifier, - CUsbNotifManager* aNotifManager, TUint aNotifId) + CUsbNotifManager& aNotifManager, TUint aNotifId) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbWaitNotifier::NewL" ) ); + LOG_FUNC CUsbWaitNotifier* self = new (ELeave) CUsbWaitNotifier(aNotifier, aNotifManager, aNotifId); @@ -50,7 +49,7 @@ // CUsbWaitNotifier::~CUsbWaitNotifier() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbWaitNotifier::~CUsbWaitNotifier" ) ); + LOG_FUNC } // --------------------------------------------------------------------------- @@ -58,7 +57,7 @@ // --------------------------------------------------------------------------- // CUsbWaitNotifier::CUsbWaitNotifier(RNotifier& aNotifier, - CUsbNotifManager* aNotifManager, TUint aNotifId) : + CUsbNotifManager& aNotifManager, TUint aNotifId) : CUsbNoteNotifier(aNotifier, aNotifManager, KUsbUiNotifOtgError, aNotifId) { SetFeedbackNeeded(); @@ -70,7 +69,7 @@ // void CUsbWaitNotifier::ConstructL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbWaitNotifier::ConstructL" ) ); + LOG_FUNC CUsbNoteNotifier::ConstructL(); } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/cusbwarningnotifier.cpp --- a/usbengines/usbotgwatcher/src/cusbwarningnotifier.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/cusbwarningnotifier.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,20 +1,19 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Usb warning notifier implementation + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". * -*/ - + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Usb warning notifier implementation + * + */ #include #include @@ -34,9 +33,11 @@ // ----------------------------------------------------------------------------- // CUsbWarningNotifier* CUsbWarningNotifier::NewL(RNotifier& aNotifier, - CUsbNotifManager* aNotifManager, TUint aNotifId) + CUsbNotifManager& aNotifManager, TUint aNotifId) { - FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbWarningNotifier::NewL aNotifId = %d" ), aNotifId)); + LOG_FUNC + + LOG1( "aNotifId = %d" , aNotifId); CUsbWarningNotifier* self = new (ELeave) CUsbWarningNotifier(aNotifier, aNotifManager, aNotifId); @@ -52,7 +53,7 @@ // CUsbWarningNotifier::~CUsbWarningNotifier() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbWarningNotifier::~CUsbWarningNotifier" ) ); + LOG_FUNC } // --------------------------------------------------------------------------- @@ -60,11 +61,10 @@ // --------------------------------------------------------------------------- // CUsbWarningNotifier::CUsbWarningNotifier(RNotifier& aNotifier, - CUsbNotifManager* aNotifManager, TUint aNotifId) : + CUsbNotifManager& aNotifManager, TUint aNotifId) : CUsbNoteNotifier(aNotifier, aNotifManager, KUsbUiNotifOtgWarning, aNotifId) { - FLOG( _L( "[USBOTGWATCHER]\tCUsbWarningNotifier::CUsbWarningNotifier" ) ); } // ----------------------------------------------------------------------------- @@ -73,7 +73,7 @@ // void CUsbWarningNotifier::ConstructL() { - FLOG( _L( "[USBOTGWATCHER]\tCUsbWarningNotifier::ConstructL" ) ); + LOG_FUNC CUsbNoteNotifier::ConstructL(); } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbotgwatcher/src/panic.cpp --- a/usbengines/usbotgwatcher/src/panic.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbotgwatcher/src/panic.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,26 +1,25 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Central place for debug-type macros & functions -* -*/ - + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Central place for debug-type macros & functions + * + */ #include "panic.h" void Panic(TUsbWatcherPanic aCategory) -{ + { #ifdef _DEBUG - User::Panic(KUsbWatcherPanic, aCategory); + User::Panic(KUsbWatcherPanic, aCategory); #endif -} + } diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbremotepersonality/src/csetpersonality.cpp --- a/usbengines/usbremotepersonality/src/csetpersonality.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbremotepersonality/src/csetpersonality.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -117,7 +117,6 @@ case KErrNone: { result =CRemotePersonalityHandler::ESuccess; - iUsbWatcher->SetPreviousPersonalityOnDisconnect(); break; } case KErrNotFound: diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbwatcher/group/bld.inf --- a/usbengines/usbwatcher/group/bld.inf Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbwatcher/group/bld.inf Fri Mar 19 09:48:52 2010 +0200 @@ -47,4 +47,8 @@ ../rom/mtp_symbian_temp.iby CORE_MW_LAYER_IBY_EXPORT_PATH(mtp_symbian_temp.iby) +// usbacmconfiguration.hby is included by usbacm.iby to define ACM configuration +// We use this one to overwrite the os default one +../rom/usbacmconfiguration.hby CORE_MW_LAYER_IBY_EXPORT_PATH(usbacmconfiguration.hby) + // End of file diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbwatcher/inc/cusbactivepersonalityhandler.h --- a/usbengines/usbwatcher/inc/cusbactivepersonalityhandler.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbwatcher/inc/cusbactivepersonalityhandler.h Fri Mar 19 09:48:52 2010 +0200 @@ -212,6 +212,11 @@ TPtrC8 iDummy; /** + * Dummy descriptor buf + */ + TBuf8<1> iDummyBuf; + + /** * Buffer where selected personality is stored by the ask * on connection. */ @@ -252,6 +257,11 @@ */ TUsbActivePersonalityState iState; + /** + * Cleanup process or normal process in various states + */ + TBool isFailureCleanup; + /** * Request to be completed. */ @@ -271,6 +281,11 @@ * The device state. */ TUsbDeviceState iDeviceState; + + /** + * Packages for queries + */ + TUSBQueriesNotifierParamsPckg iQueryParams; }; #endif // CUSBACTIVEPERSONALITYHANDLER_H diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbwatcher/inc/cusbwatcher.h --- a/usbengines/usbwatcher/inc/cusbwatcher.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbwatcher/inc/cusbwatcher.h Fri Mar 19 09:48:52 2010 +0200 @@ -170,7 +170,7 @@ * @param aPersonalityId Current personality id setting * @return KErrNone in case of success */ - inline TInt WritePersonalityId( TInt aPersonalityId ); + TInt WritePersonalityId( TInt aPersonalityId ); /** * This method is called by the CUsbActiveState class when there is diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbwatcher/inc/cusbwatcher.inl --- a/usbengines/usbwatcher/inc/cusbwatcher.inl Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbwatcher/inc/cusbwatcher.inl Fri Mar 19 09:48:52 2010 +0200 @@ -28,14 +28,4 @@ return iSupportedPersonalities; } -// ---------------------------------------------------------------------------- -// Write new personality to central repository. -// ---------------------------------------------------------------------------- -// -inline TInt CUsbWatcher::WritePersonalityId( TInt aPersonalityId ) - { - return iPersonalityRepository->Set( KUsbWatcherPersonality, - aPersonalityId); - } - // End of file diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbwatcher/inc/debug.h --- a/usbengines/usbwatcher/inc/debug.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbwatcher/inc/debug.h Fri Mar 19 09:48:52 2010 +0200 @@ -137,15 +137,16 @@ }; #endif // LOG_TO_FILE -#define LEAVE( exp ) {volatile TInt err = exp; \ - LOG3( "LEAVE(%d) @file: %s, line: %d", err, __FILE__, __LINE__ );\ - User::Leave( err );} +#define LEAVE( exp ) {volatile TInt err_ = exp; \ + LOG3( "LEAVE(%d) @file: %s, line: %d", err_, __FILE__, __LINE__ );\ + User::Leave( err_ );} -#define LEAVEIFERROR( exp ) {volatile TInt err = exp; if(err < 0) LEAVE(err);} +#define LEAVEIFERROR( exp ) {volatile TInt err__ = exp; \ + if(err__ < 0) LEAVE(err__);} -#define PANIC( exp ) {volatile TInt err = exp; \ - LOG3( "PANIC(%d) @file: %s, line: %d", err, __FILE__, __LINE__ );\ - User::Panic( KUsbPanicModule, err );} +#define PANIC( exp ) {volatile TInt err_ = exp; \ + LOG3( "PANIC(%d) @file: %s, line: %d", err_, __FILE__, __LINE__ );\ + User::Panic( KUsbPanicModule, err_ );} #define LOG_FUNC TFuncLogger __instrument(TPtrC8((TUint8*)__PRETTY_FUNCTION__)); diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbwatcher/rom/mtp_symbian_temp.iby --- a/usbengines/usbwatcher/rom/mtp_symbian_temp.iby Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbwatcher/rom/mtp_symbian_temp.iby Fri Mar 19 09:48:52 2010 +0200 @@ -185,18 +185,6 @@ #endif // SYMBIAN_EXCLUDE_MTP #endif // MTP_TASKDP_IBY -// contactdp -#ifndef MTP_CONTACTDP_IBY -#define MTP_CONTACTDP_IBY -#if !defined(SYMBIAN_EXCLUDE_MTP) -// MTP Data Provider API -ECOM_PLUGIN(mtpcontactdp.dll, mtpcontactdp.rsc) -// MTP plugin registration resource file -data=EPOCROOT##epoc32\data\Z\resource\mtp\102872bd.rsc resource\mtp\102872bd.rsc -data=EPOCROOT##epoc32\data\Z\resource\apps\mtpcontactviewdefinition.rsc resource\apps\mtpcontactviewdefinition.rsc -#endif // SYMBIAN_EXCLUDE_MTP -#endif // MTP_CONTACTDP_IBY - // bluetooth #ifndef MTP_BT_IBY #define MTP_BT_IBY diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbwatcher/rom/usbacmconfiguration.hby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbengines/usbwatcher/rom/usbacmconfiguration.hby Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Configuration for ACM functions +* +*/ + +#ifndef USBACMCONFIGURATION_HBY +#define USBACMCONFIGURATION_HBY + +#define USBACM_PATCHDATA_KUSBACMNUMBEROFACMFUNCTIONS 2 + +// USBACM_PATCHDATA_KUSBACMPROTOCOLNUMACM[X] is referring to the Xth ACM *function* +// which is accessed by the (X-1)th ACM *port* + +#define USBACM_PATCHDATA_KUSBACMPROTOCOLNUMACM1 1 +//0x01 - code taken from USBCDC 1.1 Table 17- Hayes compatible modem + +#define USBACM_PATCHDATA_KUSBACMPROTOCOLNUMACM2 255 +//0xFF - Vendor-specific + +//#define USBACM_PATCHDATA_KUSBACMPROTOCOLNUMACM3 1 +//#define USBACM_PATCHDATA_KUSBACMPROTOCOLNUMACM4 1 +//#define USBACM_PATCHDATA_KUSBACMPROTOCOLNUMACM5 1 + +// To enable an ACM function, you need to change the +// value of USBACM_PATCHDATA_KUSBACMNUMBEROFACMFUNCTIONS, +// uncomment one define line then replace the protocol number with +// the ACM protocol number expected. +// + +#endif // USBACMCONFIGURATION_HBY diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbwatcher/src/cusbactivepersonalityhandler.cpp --- a/usbengines/usbwatcher/src/cusbactivepersonalityhandler.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbwatcher/src/cusbactivepersonalityhandler.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -26,6 +26,7 @@ #include //for global system state #include "cusbactivepersonalityhandler.h" #include "cusbglobalsystemstateobserver.h" +#include // CONSTANTS // const TInt KSerialNumberLength = 12; @@ -44,6 +45,7 @@ : CActive( EPriorityStandard ) , iUsbMan( aUsbMan ) , iOwner( aOwner ) + , isFailureCleanup( EFalse ) { CActiveScheduler::Add( this ); } @@ -221,6 +223,7 @@ LOG( "PersonalityHandler created" ); iCurrentPersonalityHandler->PreparePersonalityStart( iStatus ); iState = EUsbPersonalityPrepareStart; + isFailureCleanup = EFalse; SetActive(); } else @@ -242,7 +245,8 @@ iRequestStatus = &aStatus; iState = EUsbPersonalityPrepareStop; - + isFailureCleanup = EFalse; + // prepare current personality for stop and return if( iCurrentPersonalityHandler ) { @@ -284,6 +288,11 @@ } break; } + case EUsbDeviceStateUndefined: + { + iPersonalityNotifier->CancelQuery(KQueriesNotifier); + break; + } default: // We do not handle other state here LOG( "DeviceStatechange ignored by ActivePersonalityhandler or EUsbDeviceStateConfigured" ); @@ -302,9 +311,45 @@ // outstanding request. We must not come here. // ---------------------------------------------------------------------------- // -TInt CUsbActivePersonalityHandler::RunError( TInt /*aError*/ ) +TInt CUsbActivePersonalityHandler::RunError( TInt aError ) { LOG_FUNC + + LOG2("Returned error: %d, iState: %d", aError, iState); + + if (KErrNoMemory == aError) + { + iQueryParams().iQuery = EUSBNotEnoughRam; + iPersonalityParams->PersonalityNotifier().ShowQuery(KQueriesNotifier, + iQueryParams, iDummyBuf); + } + + //only handle error when TryStart fails now + //clean up work to be done in the personality + if (iState == EUsbPersonalityStartUsb) + { + iState = EUsbPersonalityPrepareStop; + isFailureCleanup = ETrue; + + // prepare current personality for stop and return + if( iCurrentPersonalityHandler ) + { + LOG( "Call PersonalityPlugin to prepare stop" ); + iCurrentPersonalityHandler->PreparePersonalityStop( iStatus ); + SetActive(); + } + else + { + LOG( "No current PersonalityPlugin" ); + } + + //complete StartPersonality with aError + User::RequestComplete( iRequestStatus, aError ); + } + else + { + LOG( "Ignore error in other states" ); + } return KErrNone; } @@ -318,10 +363,8 @@ LOG_FUNC TInt ret = iStatus.Int(); - if( KErrNone != ret ) - { - LOG1( "ERROR: CUsbActivePersonalityHandler::RunL iStatus = %d", ret ); - } + + LOG2( "CUsbActivePersonalityHandler::RunL iStatus = %d, iState = %d", ret, iState ); switch( iState ) { @@ -340,6 +383,7 @@ break; case EUsbPersonalityStartUsb: + LEAVEIFERROR( ret ); LOG( "EUsbPersonalityStartUsb" ); iState = EUsbPersonalityFinishStart; if( iCurrentPersonalityHandler ) @@ -396,8 +440,12 @@ iPersonalityParams->PersonalityNotifier().CancelQuery( KCableConnectedNotifierUid ); } - User::RequestComplete( iRequestStatus, ret ); - + //the request should be completed with error code in RunError if failed + if ( !isFailureCleanup ) + { + User::RequestComplete( iRequestStatus, ret ); + } + iState = EUsbPersonalityIdle; break; diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbwatcher/src/cusbwatcher.cpp --- a/usbengines/usbwatcher/src/cusbwatcher.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbwatcher/src/cusbwatcher.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -251,7 +251,7 @@ aStateOld); break; } - LOG1( "Starting USB personality in device state: %d", aStateNew ); + LOG1( "Starting USB personality in device state: %d", aStateNew ); iPersonalityHandler->StateChangeNotify( aStateOld, aStateNew ); // Check AskOnConnection setting every time if( ( iSupportedPersonalities.Count() > 1 ) && @@ -387,11 +387,13 @@ case EUsbStarting: LOG( "Personality started" ); Notify( ret ); - iState = EUsbStarted; if( iStopStartScenario ) { iStopStartScenario = EFalse; } + //check if StartPersonality() fails + LEAVEIFERROR( ret ); + iState = EUsbStarted; break; case EUsbStopping: @@ -453,10 +455,21 @@ // This method is not called cause RunL() never leaves. // ---------------------------------------------------------------------------- // -TInt CUsbWatcher::RunError(TInt /*aError*/) +TInt CUsbWatcher::RunError(TInt aError) { LOG_FUNC - // Left empty cause this can't happend + + LOG2("Returned error: %d, iState: %d", aError, iState); + if ( iState == EUsbStarting ) + { + RProperty::Set( KPSUidUsbWatcher, + KUsbWatcherSelectedPersonality, + KUsbWatcherSelectedPersonalityNone ); + LOG( "personality set to none" ); + + iState = EUsbIdle; + } + return KErrNone; } @@ -1032,4 +1045,38 @@ return iOtgWatcher ? iOtgWatcher->IsDeviceA() : EFalse; } +// ---------------------------------------------------------------------------- +// Write new personality to central repository. +// ---------------------------------------------------------------------------- +// +TInt CUsbWatcher::WritePersonalityId( TInt aPersonalityId ) + { + LOG_FUNC + + // Save as the default personality only if it is not hidden + TUint32 property(0); + TInt ret = iUsbMan.GetPersonalityProperty( aPersonalityId, property ); + if ( ret == KErrNone ) + { + LOG2( "Personality %d property: 0x%x", aPersonalityId, property ); + } + else + { + //Not fatal, treat as non-hidden + LOG1( "ERROR: GetPersonalityProperty = %d", ret ); + property = 0; + } + if ( property & KUsbPersonalityPropertyHidden ) //Bitwise AND + { + LOG( "Hidden personality not saved to central repository" ); + ret = KErrNone; + } + else + { + ret = iPersonalityRepository->Set( KUsbWatcherPersonality, + aPersonalityId ); + } + return ret; + } + // End of file diff -r 7e15987c4500 -r 8c311f9acc5e usbengines/usbwatcher/src/usbman_pcsmtppam.rss --- a/usbengines/usbwatcher/src/usbman_pcsmtppam.rss Tue Feb 02 00:52:37 2010 +0200 +++ b/usbengines/usbwatcher/src/usbman_pcsmtppam.rss Fri Mar 19 09:48:52 2010 +0200 @@ -104,7 +104,7 @@ , PERSONALITY { - bDeviceClass = 0xFF; + bDeviceClass = 0x00; bDeviceSubClass = 0x00; protocol = 0x00; numConfigurations = 0x01; diff -r 7e15987c4500 -r 8c311f9acc5e usbservices_plat/usb_notifier_api/inc/usbuinotif.h --- a/usbservices_plat/usb_notifier_api/inc/usbuinotif.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbservices_plat/usb_notifier_api/inc/usbuinotif.h Fri Mar 19 09:48:52 2010 +0200 @@ -63,7 +63,8 @@ EUSBPossibleDataLossCable, EUSBPossibleDataLossMMC, EUSBChangeFromMassStorage, - EUSBNoMemoryCard + EUSBNoMemoryCard, + EUSBNotEnoughRam }; /** diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/group/bld.inf --- a/usbuis/group/bld.inf Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/group/bld.inf Fri Mar 19 09:48:52 2010 +0200 @@ -19,5 +19,4 @@ #include "../usbui/group/bld.inf" #include "../usbuinotif/group/bld.inf" #include "../imageprintuiprovider/group/bld.inf" -#include "../imageprintui/group/bld.inf" -#include "../rndisui/group/bld.inf" \ No newline at end of file +#include "../imageprintui/group/bld.inf" \ No newline at end of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/help/data/xhtml.zip Binary file usbuis/usbui/help/data/xhtml.zip has changed diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/help/inc/usb.hlp.hrh --- a/usbuis/usbui/help/inc/usb.hlp.hrh Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbui/help/inc/usb.hlp.hrh Fri Mar 19 09:48:52 2010 +0200 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -25,4 +25,4 @@ _LIT(KUSB_HLP_MAIN, "USB_HLP_MAIN"); // _LIT(KUSB_HLP_PRINT_SETTINGS, "USB_HLP_PRINT_SETTINGS"); // -#endif +#endif \ No newline at end of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/bmarm/usbuiapitestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/bmarm/usbuiapitestu.def Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) + diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/bwins/usbuiapitestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/bwins/usbuiapitestu.def Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) + diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/conf/ui_usbuiapitest.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/conf/ui_usbuiapitest.cfg Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,399 @@ +/* +* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Test script config file +* +*/ + +// USBUiApiTest Module - total ... tc + +// USBUiApiTest Api Tests (... tc) + +//[Test] +//title Example Api Test +//create USBUiApiTest tester +//tester ExecuteApiTestBlock ExampleTestL API option 1 a +//delete tester +//[Endtest] + +// USB UI tests - total 14 tc +///////////////////// +//Ovi->MS +[Test] +title Change USB Connection Ovi Suite to MS Manual/KeyDown +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDownArrow //OVI +pause 500 +presskey global EKeyDownArrow //MS +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MS +delete tester +[Endtest] + +[Test] +title Change USB Connection Ovi Suite to MS Manual/KeyUp +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyUpArrow //OVI +pause 500 +presskey global EKeyUpArrow //MODEM +pause 500 +presskey global EKeyUpArrow //MTP +pause 500 +presskey global EKeyUpArrow //MS +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MS +delete tester +[Endtest] +///////////////////////// +//Ovi->MTP +[Test] +title Change USB Connection Ovi Suite to MTP Manual/KeyUp +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyUpArrow //OVI +pause 500 +presskey global EKeyUpArrow //MODEM +pause 500 +presskey global EKeyUpArrow //MTP +pause 500 +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MTP +delete tester +[Endtest] + +[Test] +title Change USB Connection Ovi Suite to MTP Manual/KeyDown +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDownArrow //OVI +pause 500 +presskey global EKeyDownArrow //MS +pause 500 +presskey global EKeyDownArrow //MTP +pause 500 +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MTP +delete tester +[Endtest] +///////////////////////// +//MS->Ovi +[Test] +title Change USB Connection MS to Ovi Suite Manual +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF MS +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyUpArrow //OVI +pause 500 +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF PCSUITE +delete tester +[Endtest] +///////////////////////// +//MS->MTP +[Test] +title Change USB Connection MS to MTP Manual +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF MS +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDownArrow //OVI +pause 500 +presskey global EKeyDownArrow //MS +pause 500 +presskey global EKeyDownArrow //MTP +pause 500 +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MTP +delete tester +[Endtest] +///////////////////////// +//MTP->Ovi +[Test] +title Change USB Connection MTP to Ovi Suite Manual/KeyDown +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF MTP +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDownArrow //OVI +pause 500 +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF PCSUITE +delete tester +[Endtest] +///////////////////////// +//MTP->MS +[Test] +title Change USB Connection MTP to MS Manual/KeyDown +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF MTP +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDownArrow //OVI +pause 500 +presskey global EKeyDownArrow //MS +pause 500 +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MS +delete tester +[Endtest] +///////////////////////// +//OVI->MODEM +[Test] +title Change USB Connection OVI to Modem Manual/KeyDown +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDownArrow //OVI +pause 500 +presskey global EKeyDownArrow //MS +pause 500 +presskey global EKeyDownArrow //MTP +pause 500 +presskey global EKeyDownArrow //MODEM +pause 500 +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MODEM +delete tester +[Endtest] +///////////////////////// +//MODEM->OVI +[Test] +title Change USB Connection Modem to MS Options Menu/KeyUp +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF MODEM +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyUpArrow //OVI +pause 500 +presskey global EKeyUpArrow //MODEM +pause 500 +presskey global EKeyUpArrow //MTP +pause 500 +presskey global EKeyUpArrow //MS +pause 500 +presskey global EKeyDevice0 +pause 1000 +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MS +delete tester +[Endtest] +///////////////////////// +//Change In Options Menu +//MS->MTP +[Test] +title Change USB Connection MS to MTP Change In Options Menu +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF MS +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDownArrow //OVI +pause 500 +presskey global EKeyDownArrow //MS +pause 500 +presskey global EKeyDownArrow //MTP +pause 500 +presskey global EKeyDevice0 +pause 2000 +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MTP +delete tester +[Endtest] +///////////////////////// +//MTP->Ovi +[Test] +title Change USB Connection MTP to Ovi Suite Change In Options Menu +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF MTP +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDownArrow //OVI +pause 500 +presskey global EKeyDevice0 +pause 2000 +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF PCSUITE +delete tester +[Endtest] +///////////////////////// +//Ovi->MS +[Test] +title Change USB Connection Ovi Suite to MS Change In Options Menu +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDownArrow //OVI +pause 500 +presskey global EKeyDownArrow //MS +pause 500 +presskey global EKeyDevice0 +pause 2000 +presskey global EKeyEnter +pause 1000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest USB_CONN_MODE OFF MS +delete tester +[Endtest] +///////////////////////// +//Exit +[Test] +title USB Application Exit/Device Key 1 Exit +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDevice1 +pause 2000 +tester ExecuteApiTestBlock FinishTest CANCELLED +delete tester +[Endtest] +///////////////////////// +//OPTIONS Cancel / EXIT +[Test] +title USB Application Cancelled/Options Key 1 Exit +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDevice0 //OPTIONS +pause 500 +presskey global EKeyDevice1 //CANCEL OPTIONS +pause 500 +presskey global EKeyDevice1 //EXIT +pause 2000 +tester ExecuteApiTestBlock FinishTest CANCELLED +delete tester +[Endtest] +///////////////////////// +//EXIT WHEN NOT SELECTED +[Test] +title USB Application Exit/Options Menu Exit nothing selected +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDevice0 //OPTIONS/HELP +pause 500 +presskey global EKeyDownArrow //EXIT +pause 500 +presskey global EKeyDevice0 //SELECT EXIT +pause 2000 +tester ExecuteApiTestBlock FinishTest CANCELLED +delete tester +[Endtest] +///////////////////////// +//EXIT WHEN SELECTED +[Test] +title USB Application Exit/Options Menu Exit Ovi Suite selected +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDownArrow //OVI +pause 500 +presskey global EKeyDevice0 //OPTIONS/SELECT +pause 500 +presskey global EKeyDownArrow //Help +pause 500 +presskey global EKeyDownArrow //EXIT +pause 500 +presskey global EKeyDevice0 //SELECT EXIT +pause 2000 +tester ExecuteApiTestBlock FinishTest CANCELLED +delete tester +[Endtest] +///////////////////////// +//Help +[Test] +title USB Application Help Option Entered/Key 1 Exit +create USBUiApiTest tester +tester ExecuteApiTestBlock LaunchUsbUiApp OFF PCSUITE +tester ExecuteApiTestBlock TurnLightsOn +pause 4000 +presskey global EKeyDevice0 //OPTIONS +pause 500 +presskey global EKeyEnter //ENTER HELP +pause 5000 +presskey global EKeyDevice1 //KEY EXIT HELP +pause 500 +presskey global EKeyDevice1 //KEY EXIT USB +pause 2000 +tester ExecuteApiTestBlock FinishTest CANCELLED +delete tester +[Endtest] + +// Add new api tests here +// ... + + +// USBUiApiTest Module Tests (... tc) + + +// Add new module tests here +// ... + + +// USBUiApiTest Branch Tests (... tc) + + +// Add new branch tests here +// ... diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/eabi/usbuiapitestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/eabi/usbuiapitestu.def Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/group/Bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/group/Bld.inf Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +PRJ_PLATFORMS +DEFAULT + +PRJ_TESTEXPORTS + +PRJ_EXPORTS + +PRJ_TESTMMPFILES +USBUiApiTest.mmp + +PRJ_MMPFILES + +// End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/group/build_sis_ats.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/group/build_sis_ats.bat Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,27 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +rd /S /Q \epoc32\BUILD +del usbuiapitest.sisx +call bldmake bldfiles +call abld reallyclean armv5 +call abld test build armv5 +call makesis usbuiapitest.pkg +call signsis usbuiapitest.sis usbuiapitest.sisx x:\rd.cer x:\rd-key.pem + +del usbuiapitest.sis + +call pause \ No newline at end of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/group/build_sis_phone.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/group/build_sis_phone.bat Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,27 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +rd /S /Q \epoc32\BUILD +del usbuiapitest_phone.sisx +call bldmake bldfiles +call abld reallyclean armv5 +call abld test build armv5 +call makesis usbuiapitest_phone.pkg +call signsis usbuiapitest_phone.sis usbuiapitest_phone.sisx x:\rd.cer x:\rd-key.pem + +del usbuiapitest_phone.sis + +call pause \ No newline at end of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/group/usbuiapitest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/group/usbuiapitest.mmp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: TYPE TESTSCRIPT +* +*/ + + +#if defined(__S60_) + // To get the OSEXT_LAYER_SYSTEMINCLUDE-definition + #include +#endif + +TARGET usbuiapitest.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +CAPABILITY ALL -TCB + +DEFFILE usbuiapitest.def + +//#define ATS +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../../inc + +SOURCEPATH ../src +SOURCE usbuiapitest.cpp +SOURCE usbuiapitestblocks.cpp + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY stiftestengine.lib +LIBRARY centralrepository.lib +LIBRARY apparc.lib +LIBRARY apgrfx.lib + +LANG SC + +// End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/group/usbuiapitest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/group/usbuiapitest.pkg Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,62 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: Installation file for STIF +; +; + +; Languages +&EN + +; Provide value for uid +#{"STIF"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 5.2 +[0x20022E6D], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"/epoc32/release/armv5/udeb/usbuiapitest.dll"-"c:/Sys/Bin/usbuiapitest.dll" + +"../init/usbuiapitest.ini"-"e:/testing/init/usbuiapitest.ini" +"../conf/ui_usbuiapitest.cfg"-"e:/testing/conf/ui_usbuiapitest.cfg" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/group/usbuiapitest_phone.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/group/usbuiapitest_phone.pkg Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,62 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: Installation file for STIF +; +; + +; Languages +&EN + +; Provide value for uid +#{"STIF"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 5.2 +[0x20022E6D], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"/epoc32/release/armv5/urel/usbuiapitest.dll"-"c:/Sys/Bin/usbuiapitest.dll" + +"../init/usbuiapitest_phone.ini"-"c:/testframework/testframework.ini" +"../conf/ui_usbuiapitest.cfg"-"c:/testframework/ui_usbuiapitest.cfg" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/inc/usbuiapitest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/inc/usbuiapitest.h Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,259 @@ +/* +* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef USBUIAPITEST_H +#define USBUIAPITEST_H + +// INCLUDES +#include +#include +#include +#include + +#include "coreapplicationuisdomainpskeys.h" +#include +#include +#include +#include +#include +#include + +#include "USBClassChangeUI.h" +// CONSTANTS +_LIT( KUsbAppFileName, "usbclasschangeui" ); + +// MACROS +//#define ?macro ?macro_def +#define TEST_CLASS_VERSION_MAJOR 0 +#define TEST_CLASS_VERSION_MINOR 0 +#define TEST_CLASS_VERSION_BUILD 0 + +// Logging path +//_LIT( KUSBUiApiTestLogPath, "\\logs\\testframework\\USBUiApiTest\\" ); + +// Logging path for ATS - for phone builds comment this line +_LIT( KUSBUiApiTestLogPath, "e:\\testing\\stiflogs\\" ); + +// Log file +_LIT( KUSBUiApiTestLogFile, "USBUiApiTest.txt" ); +_LIT( KUSBUiApiTestLogFileWithTitle, "USBUiApiTest_[%S].txt" ); + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; +class CUSBUiApiTest; + +// DATA TYPES +//enum ?declaration + +enum TUSBUiApiTestResult + { + ETestCasePassed, + ETestCaseFailed + }; + +enum TUSBAppTestOption + { + EAppCancelled = 0, + EAskOnConnectionSettingChanged,//1 + EUsbConnectionModeSettingChanged//2 + }; + +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +NONSHARABLE_CLASS( TUSBUiApiTestBlockParams ) + { + public: + TPtrC iTestBlockName; + + TPtrC iTestOption1; + TPtrC iTestOption2; + TPtrC iTestOption3; + + TInt iTestIntOption1; + TInt iTestIntOption2; + + TChar iTestCharOption1; + TChar iTestCharOption2; + }; + +/** +* CUSBUiApiTest test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS( CUSBUiApiTest ) : public CScriptBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CUSBUiApiTest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CUSBUiApiTest(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + protected: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // Functions from base classes + + /** + * From ?base_class ?member_description + */ + //?type ?member_function(); + + private: + + /** + * C++ default constructor. + */ + CUSBUiApiTest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Test methods are listed below. + */ + + virtual TInt ExecuteApiTestBlock( CStifItemParser& aItem ); + virtual TInt ExecuteModuleTestBlock( CStifItemParser& aItem ); + virtual TInt ExecuteBranchTestBlock( CStifItemParser& aItem ); + + /** + * Method used to log version of test class + */ + void SendTestClassVersion(); + + //ADD NEW METHOD DEC HERE + //[TestMethods] - Do not remove + + void GetTestBlockParamsL( CStifItemParser& aItem ); + + void DoExecuteApiTestBlockL( CStifItemParser& aItem, TUSBUiApiTestResult& aTestResult ); + void DoExecuteModuleTestBlockL( CStifItemParser& aItem, TUSBUiApiTestResult& aTestResult ); + void DoExecuteBranchTestBlockL( CStifItemParser& aItem, TUSBUiApiTestResult& aTestResult ); + + void ExampleTestL( TPtrC aTestOption, TPtrC aTestSubOption, + TInt aTestIntOption, TInt aTestCharOption, TUSBUiApiTestResult& aTestResult ); + + virtual TInt LaunchUsbUiApp( TPtrC aTestOption, TPtrC aTestSubOption, TUSBUiApiTestResult& aTestResult ); + virtual TInt FinishTest( TPtrC aTestOption, TPtrC aTestSubOption, TPtrC aTestSubOption2, TUSBUiApiTestResult& aTestResult ); + TInt GetTestOption( TPtrC aOptionString, TUSBAppTestOption& aOption ); + TInt GetAskOnConnectionOptionFromString( TPtrC aOptionString, TInt& aOption ); + TInt GetUsbPersonalityOptionFromString( TPtrC aOptionString, TInt& aOption ); + TBool IsUsbAppRunning(); + TInt GetUsbSettings( TInt& aUsbPersinalityId, TInt& aAskOnConnectionSetting ); + TInt SetUsbSettings( TInt aUsbPersinalityId, TInt aAskOnConnectionSetting ); + + TInt TurnLightsOn( ); + + + + inline void Trace(TRefByValue aFmt, ...); + inline void Trace(TRefByValue aFmt, ...); + + public: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + protected: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + private: // Data + TUSBUiApiTestBlockParams iTestBlockParams; + + RApaLsSession iApaLsSession; + + CApaCommandLine *iCommandLine; + CRepository *iRepository; + + TSecureId iUsbAppSecureId; + TInt iAskOnConnectionSettingBackup; + TInt iUsbPersonalityBackup; + TInt iTestAskOnConnectionSetting; + TInt iTestUsbPersonality; + + public: // Friend classes + //?friend_class_declaration; + protected: // Friend classes + //?friend_class_declaration; + private: // Friend classes + //?friend_class_declaration; + + }; + +#include "USBUiApiTestDebug.inl" + +#endif // USBUIAPITEST_H + +// End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/inc/usbuiapitestdebug.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/inc/usbuiapitestdebug.inl Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { +public: + void Overflow(TDes8& /*aDes*/) {} + }; + +NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { +public: + void Overflow(TDes16& /*aDes*/) {} + }; + + +_LIT8(KStifTestPrefix8, "[STIF_LOG] "); +_LIT(KStifTestPrefix, "[STIF_LOG] "); + +const TInt KMaxLogLineLength = 512; + +#define TRACE_INFO(p) { Trace p; } + +void CUSBUiApiTest::Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); + TOverflowTruncate8 overflow; + RBuf8 buf8; + buf8.Create( KMaxLogLineLength ); + buf8.Append( KStifTestPrefix8 ); + buf8.AppendFormatList(aFmt, list, &overflow); + + RBuf16 buf16; + buf16.Create( KMaxLogLineLength ); + buf16.Copy(buf8); + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); + iLog->Log(tmpFmt, &buf16); + buf8.Close(); + buf16.Close(); + }; + +void CUSBUiApiTest::Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); + RBuf16 theFinalString; + theFinalString.Create( KMaxLogLineLength ); + theFinalString.Append( KStifTestPrefix ); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList(aFmt,list,&overflow); + RDebug::Print(theFinalString); + iLog->Log(theFinalString); + theFinalString.Close(); + }; diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/init/usbuiapitest.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/init/usbuiapitest.ini Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,235 @@ +# +# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# + XML, Test report will be xml type, for example 'TestReport.xml'. +# Note, that xml format is available only when output is set to FILE. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= e:\testing\logs\ +TestReportFileName= USBUiApiTest_TestReport + +TestReportFormat= TXT # Possible values: TXT, HTML or XML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds +UITestingSupport= YES # Possible values: YES or NO +#SeparateProcesses= YES # Possible values: YES or NO (default: NO) +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= USBUiApiTestUSBUiApiTestUSBUiApiTest +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= e:\testing\conf\ui_USBUiApiTest.cfg +[End_Module] + + +# Load testmoduleUSBUiApiTest, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleUSBUiApiTest used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleUSBUiApiTest used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO +#AddTestCaseTitle= YES # Possible values: YES or NO +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set filters to be used by ConsoleUI. +# If you want to use filter with ConsoleUI, simply remove comments +# from section below and provide valid filter entries. +# Each filter line has to start with "filter= " keyword. +# Filter can contain special wildcard characters: +# * which stands for none or any literal; +# ? which stands for single character. +# Filters are not case-sensitive. + +#[Filters] +#filter= *math* +#filter= *radio* +#[End_Filters] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/init/usbuiapitest_phone.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/init/usbuiapitest_phone.ini Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,235 @@ +# +# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# + XML, Test report will be xml type, for example 'TestReport.xml'. +# Note, that xml format is available only when output is set to FILE. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= c:\logs\testframework\USBUiApiTest\ +TestReportFileName= testreport + +TestReportFormat= TXT # Possible values: TXT, HTML or XML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds +UITestingSupport= YES # Possible values: YES or NO +#SeparateProcesses= YES # Possible values: YES or NO (default: NO) +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= USBUiApiTestUSBUiApiTestUSBUiApiTest +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= c:\testframework\ui_USBUiApiTest.cfg +[End_Module] + + +# Load testmoduleUSBUiApiTest, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleUSBUiApiTest used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleUSBUiApiTest used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO +#AddTestCaseTitle= YES # Possible values: YES or NO +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set filters to be used by ConsoleUI. +# If you want to use filter with ConsoleUI, simply remove comments +# from section below and provide valid filter entries. +# Each filter line has to start with "filter= " keyword. +# Filter can contain special wildcard characters: +# * which stands for none or any literal; +# ? which stands for single character. +# Filters are not case-sensitive. + +#[Filters] +#filter= *math* +#filter= *radio* +#[End_Filters] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/src/usbuiapitest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/src/usbuiapitest.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,205 @@ +/* +* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +// INCLUDE FILES +#include +#include "USBUiApiTest.h" +#include + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CUSBUiApiTest::CUSBUiApiTest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CUSBUiApiTest::CUSBUiApiTest( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CUSBUiApiTest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CUSBUiApiTest::ConstructL() + { + //Read logger settings to check whether test case name is to be + //appended to log file name. + RSettingServer settingServer; + TInt ret = settingServer.Connect(); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Struct to StifLogger settigs. + TLoggerSettings loggerSettings; + // Parse StifLogger defaults from STIF initialization file. + ret = settingServer.GetLoggerSettings(loggerSettings); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Close Setting server session + settingServer.Close(); + + TFileName logFileName; + + if(loggerSettings.iAddTestCaseTitle) + { + TName title; + TestModuleIf().GetTestCaseTitleL(title); + logFileName.Format(KUSBUiApiTestLogFileWithTitle, &title); + } + else + { + logFileName.Copy(KUSBUiApiTestLogFile); + } + + iLog = CStifLogger::NewL( KUSBUiApiTestLogPath, + logFileName, + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse ); + + SendTestClassVersion(); + + iCommandLine = CApaCommandLine::NewL(); + iUsbAppSecureId = TSecureId( KUidUSBClassChangeUI ); + iRepository = CRepository::NewL( KCRUidUsbWatcher ); + } + +// ----------------------------------------------------------------------------- +// CUSBUiApiTest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CUSBUiApiTest* CUSBUiApiTest::NewL( + CTestModuleIf& aTestModuleIf ) + { + CUSBUiApiTest* self = new (ELeave) CUSBUiApiTest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +// Destructor +CUSBUiApiTest::~CUSBUiApiTest() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iLog; + + } + +//----------------------------------------------------------------------------- +// CUSBUiApiTest::SendTestClassVersion +// Method used to send version of test class +//----------------------------------------------------------------------------- +// +void CUSBUiApiTest::SendTestClassVersion() + { + TVersion moduleVersion; + moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; + moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; + moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; + + TFileName moduleName; + moduleName = _L("USBUiApiTest.dll"); + + TBool newVersionOfMethod = ETrue; + TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CUSBUiApiTest::NewL( aTestModuleIf ); + + } + + +// End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbui/tsrc/usbuiapitest/src/usbuiapitestblocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbui/tsrc/usbuiapitest/src/usbuiapitestblocks.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,701 @@ +/* +* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +// [INCLUDE FILES] - do not remove +#include +#include +#include +#include "USBUiApiTest.h" + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CUSBUiApiTest::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CUSBUiApiTest::Delete() + { + iApaLsSession.Close(); + delete iCommandLine; + iCommandLine = NULL; + delete iRepository; + iRepository = NULL; + } + +// ----------------------------------------------------------------------------- +// CUSBUiApiTest::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CUSBUiApiTest::RunMethodL( + CStifItemParser& aItem ) + { + + static TStifFunctionInfo const KFunctions[] = + { + //ADD NEW ENTRY HERE + // [test cases entries] - Do not remove + ENTRY( "ExecuteApiTestBlock", CUSBUiApiTest::ExecuteApiTestBlock ), + ENTRY( "ExecuteModuleTestBlock", CUSBUiApiTest::ExecuteModuleTestBlock ), + ENTRY( "ExecuteBranchTestBlock", CUSBUiApiTest::ExecuteBranchTestBlock ), + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + + } + +// ----------------------------------------------------------------------------- +// CUSBUiApiTest::GetTestBlockParamsL +// ----------------------------------------------------------------------------- + +void CUSBUiApiTest::GetTestBlockParamsL( CStifItemParser& aItem ) + { + TRACE_INFO( _L(">>> GetTestBlockParamsL") ); + + // Add new test block branches below, get all required test parameters + if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) ) + { + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) ); + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); + User::LeaveIfError( aItem.GetNextInt( iTestBlockParams.iTestIntOption1 ) ); + User::LeaveIfError( aItem.GetNextChar( iTestBlockParams.iTestCharOption1 ) ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "LaunchUsbUiApp" ) ) ) + { + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) ); + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "TurnLightsOn" ) ) ) + { + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FinishTest" ) ) ) + { + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) ); + if( iTestBlockParams.iTestOption1.Compare(_L("CANCELLED")) == KErrNotFound ) + { + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption3 ) ); + } + } + else + { + TRACE_INFO( _L("GetTestBlockParamsL() Test type: not found") ); + User::Leave( KErrNotFound ); + } + TRACE_INFO( _L("<<< GetTestBlockParamsL") ); + } + +// ----------------------------------------------------------------------------- +// CUSBUiApiTest::ExecuteApiTestBlock +// ----------------------------------------------------------------------------- + +TInt CUSBUiApiTest::ExecuteApiTestBlock( CStifItemParser& aItem ) + { + TRACE_INFO( _L(">>> ExecuteApiTestBlock") ); + + TInt res; + TUSBUiApiTestResult testResult; + + TRAP( res, DoExecuteApiTestBlockL( aItem, testResult ) ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("DoExecuteApiTestBlockL error: %d"), res) ); + return res; + } + + STIF_ASSERT_EQUALS( ETestCasePassed, testResult ); + TRACE_INFO( _L("Test case passed") ); + TRACE_INFO( _L("<<< ExecuteApiTestBlock") ); + + return KErrNone; + } + + +void CUSBUiApiTest::DoExecuteApiTestBlockL( CStifItemParser& aItem, TUSBUiApiTestResult& aTestResult ) + { + TRACE_INFO( _L(">>>DoExecuteApiTestBlockL") ); + + User::LeaveIfError( aItem.GetString( _L( "ExecuteApiTestBlock" ), iTestBlockParams.iTestBlockName ) ); + TRACE_INFO( (_L("Api test type: %S"), &iTestBlockParams.iTestBlockName) ); + + GetTestBlockParamsL( aItem ); + + // Add new API test block branches with optional test parameters here + if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) ) + { + ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, + iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "LaunchUsbUiApp" ) ) ) + { + LaunchUsbUiApp( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FinishTest" ) ) ) + { + FinishTest( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, iTestBlockParams.iTestOption3, aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "TurnLightsOn" ) ) ) + { + TurnLightsOn( ); + } + else + { + TRACE_INFO( _L("DoExecuteApiTestBlockL() Test type: not found") ); + User::Leave( KErrNotFound ); + } + + TRACE_INFO( _L("<<>>ExecuteModuleTestBlock") ); + + TInt res; + TUSBUiApiTestResult testResult; + + TRAP( res, DoExecuteModuleTestBlockL( aItem, testResult ) ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("DoExecuteModuleTestBlockL error: %d"), res) ); + return res; + } + + STIF_ASSERT_EQUALS( ETestCasePassed, testResult ); + TRACE_INFO( _L("Test case passed") ); + TRACE_INFO( _L("<<>>DoExecuteModuleTestBlockL") ); + + User::LeaveIfError( aItem.GetString( _L( "ExecuteModuleTestBlock" ), iTestBlockParams.iTestBlockName ) ); + TRACE_INFO( (_L("Module test type: %S"), &iTestBlockParams.iTestBlockName) ); + + GetTestBlockParamsL( aItem ); + + // Add new module test block branches with optional test parameters here + if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) ) + { + ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, + iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult ); + } + else + { + TRACE_INFO( _L("DoExecuteModuleTestBlockL() Test type: not found") ); + User::Leave( KErrNotFound ); + } + + TRACE_INFO( _L("<<>>ExecuteBranchTestBlock") ); + + TInt res; + TUSBUiApiTestResult testResult; + + TRAP( res, DoExecuteBranchTestBlockL( aItem, testResult ) ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("DoExecuteBranchTestBlockL error: %d"), res) ); + return res; + } + + STIF_ASSERT_EQUALS( ETestCasePassed, testResult ); + TRACE_INFO( _L("Test case passed") ); + TRACE_INFO( _L("<<>>DoExecuteBranchTestBlockL") ); + + User::LeaveIfError( aItem.GetString( _L( "ExecuteBranchTestBlock" ), iTestBlockParams.iTestBlockName ) ); + TRACE_INFO( (_L("Branch test type: %S"), &iTestBlockParams.iTestBlockName) ); + + GetTestBlockParamsL( aItem ); + + // Add new branch test block branches with optional test parameters here + if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) ) + { + ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, + iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult ); + } + else + { + TRACE_INFO( _L("DoExecuteBranchTestBlockL() Test type: not found") ); + User::Leave( KErrNotFound ); + } + + TRACE_INFO( _L("<<SetCommandL( EApaCommandRun ); + iCommandLine->SetExecutableNameL( KUsbAppFileName ); + + res = iApaLsSession.Connect(); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("Connecting to application server failed with value: %d"), res) ); + return res; + + } + STIF_LOG("iApaLsSession.Connect OK"); + + res = iApaLsSession.StartApp( *iCommandLine ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("Starting application failed with value: %d"), res) ); + iApaLsSession.Close(); + return res; + } + STIF_LOG("iApaLsSession.StartApp OK"); + + if ( !IsUsbAppRunning() ) + { + TRACE_INFO( _L("Usb application launch error") ); + iApaLsSession.Close(); + return KErrGeneral; + } + STIF_LOG("IsUsbAppRunning OK"); + + TRACE_INFO( _L("Usb application started") ); + + aTestResult = ETestCasePassed; + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CUSBUiApiTest::FinishTest +// ----------------------------------------------------------------------------- + +TInt CUSBUiApiTest::FinishTest( TPtrC aTestOption, TPtrC aTestSubOption, TPtrC aTestSubOption2, TUSBUiApiTestResult& aTestResult ) + { + TRACE_INFO( _L(">>>FinishTest") ); + + TInt res; + TUSBAppTestOption option; + TBool isAppRunning; + TInt actualAskOnConnectionSetting; + TInt expectedAskOnConnectionSetting; + TInt actualPersonalityIdSetting; + TInt expectedPersonalityIdSetting; + + res = GetTestOption( aTestOption, option ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("GetTestOption failed with value: %d"), res) ); + iApaLsSession.Close(); + return res; + } + TRACE_INFO( (_L("GetTestOption OK: %d"),option) ); + + if ( option == EAskOnConnectionSettingChanged || option == EUsbConnectionModeSettingChanged ) + { + res = GetAskOnConnectionOptionFromString( aTestSubOption, expectedAskOnConnectionSetting ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("GetAskOnConnectionOptionFromString failed with value: %d"), res) ); + iApaLsSession.Close(); + return res; + } + TRACE_INFO( (_L("GetAskOnConnectionOptionFromString OK: %d"), expectedAskOnConnectionSetting) ); + + res = GetUsbPersonalityOptionFromString( aTestSubOption2, expectedPersonalityIdSetting ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("GetUsbPersonalityOptionFromString failed with value: %d"), res) ); + iApaLsSession.Close(); + return res; + } + TRACE_INFO( (_L("GetUsbPersonalityOptionFromString OK %d"), expectedPersonalityIdSetting) ); + } + + isAppRunning = IsUsbAppRunning(); + + res = GetUsbSettings( actualPersonalityIdSetting, actualAskOnConnectionSetting ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("Getting usb settings failed with value (cenrep): %d"), res) ); + iApaLsSession.Close(); + return res; + } + TRACE_INFO( (_L("GetUsbSettings OK: %d, %d"), actualPersonalityIdSetting, actualAskOnConnectionSetting) ); + + res = SetUsbSettings( iUsbPersonalityBackup, iAskOnConnectionSettingBackup ); + if ( res != KErrNone ) + TRACE_INFO( _L("Failed to restore original usb settings!") ); + TRACE_INFO( (_L("SetUsbSettings OK: %d, %d"), iUsbPersonalityBackup, iAskOnConnectionSettingBackup) ); + + iApaLsSession.Close(); + + switch( option ) + { + case EAskOnConnectionSettingChanged: + case EUsbConnectionModeSettingChanged: + TRACE_INFO( (_L("Actual USB ask on connection setting value: %d, expected: %d"), actualAskOnConnectionSetting, expectedAskOnConnectionSetting) ); + STIF_ASSERT_EQUALS( expectedAskOnConnectionSetting, actualAskOnConnectionSetting ); + TRACE_INFO( (_L("Actual USB personality setting value: %d, expected: %d"), actualPersonalityIdSetting, expectedPersonalityIdSetting) ); + STIF_ASSERT_EQUALS( expectedPersonalityIdSetting, actualPersonalityIdSetting ); + TRACE_INFO( (_L("USB app is running: %d, expected: %d"), isAppRunning, EFalse) ); + STIF_ASSERT_FALSE( isAppRunning ); + break; + case EAppCancelled: + TRACE_INFO( (_L("USB app is running: %d, expected: %d"), isAppRunning, EFalse) ); + STIF_ASSERT_FALSE( isAppRunning ); + break; + default: + return KErrNotFound; + } + + TRACE_INFO( _L("Test case passed!") ); + aTestResult = ETestCasePassed; + + TRACE_INFO( _L("<< Get( KUsbWatcherChangeOnConnectionSetting, aAskOnConnectionSetting ); + if ( res != KErrNone ) + return res; + + res = iRepository -> Get( KUsbWatcherPersonality, aUsbPersonalityId ); + if ( res != KErrNone ) + return res; + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CUSBUiApiTest::SetUsbSettings +// ----------------------------------------------------------------------------- + +TInt CUSBUiApiTest::SetUsbSettings( TInt aUsbPersonalityId, TInt aAskOnConnectionSetting ) + { + TInt res; + res = iRepository -> Set( KUsbWatcherChangeOnConnectionSetting, aAskOnConnectionSetting ); + if ( res != KErrNone ) + return res; + + res = iRepository -> Set( KUsbWatcherPersonality, aUsbPersonalityId ); + if ( res != KErrNone ) + return res; + + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// CUSBUiApiTest::TurnLightsOn +// ----------------------------------------------------------------------------- + +TInt CUSBUiApiTest::TurnLightsOn( ) + { + TInt res; + res = RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOn); + res = RProperty::Set(KPSUidCoreApplicationUIs, KLightsVTForcedLightsOn, EForcedLightsOn); + return res; + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= +// None + +// [End of File] - Do not remove diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/BWINS/usbuinotifu.def --- a/usbuis/usbuinotif/BWINS/usbuinotifu.def Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - ?NotifierArray@@YAPAV?$CArrayPtr@VMEikSrvNotifierBase2@@@@XZ @ 1 NONAME ; class CArrayPtr * NotifierArray(void) - diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/EABI/usbuinotifu.def --- a/usbuis/usbuinotif/EABI/usbuinotifu.def Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - _Z13NotifierArrayv @ 1 NONAME - diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/data/usbuinotif.rss --- a/usbuis/usbuinotif/data/usbuinotif.rss Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/data/usbuinotif.rss Fri Mar 19 09:48:52 2010 +0200 @@ -244,8 +244,8 @@ RESOURCE TBUF r_usb_otg_error_unrecoverable { buf = qtn_usb_otg_error_unrecoverable; } -RESOURCE TBUF r_usb_otg_warning_partial_supported { - buf = qtn_usb_otg_warning_partial_supported; } +RESOURCE TBUF r_usb_otg_warning_partial_support { + buf = qtn_usb_otg_warning_partial_support; } RESOURCE TBUF r_usb_no_memory_card { buf = qtn_usb_mode_query_no_memory_card; } @@ -262,4 +262,7 @@ RESOURCE TBUF r_usb_msmm_error_out_of_memory { buf = qtn_memlo_not_enough_memory; } +RESOURCE TBUF r_usb_error_memory_not_enough { + buf = qtn_usb_error_memory_not_enough; } + // End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/group/bld.inf --- a/usbuis/usbuinotif/group/bld.inf Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/group/bld.inf Fri Mar 19 09:48:52 2010 +0200 @@ -28,7 +28,6 @@ PRJ_MMPFILES usbuinotif.mmp -usbavkonnotif.mmp PRJ_TESTMMPFILES diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/group/usbavkonnotif.mmp --- a/usbuis/usbuinotif/group/usbavkonnotif.mmp Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of "Eclipse Public License v1.0" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: Project definition file for project USBUINotif. - * - */ - -#include -#include //this is needed for RESOURCE_FILES_DIR - -TARGET usbavkonnotif.dll -TARGETTYPE dll -UID 0x101fdfae 0x102068DD -TARGETPATH SHARED_LIB_DIR - -CAPABILITY CAP_GENERAL_DLL -VENDORID VID_DEFAULT - -SOURCEPATH ../src - -SOURCE usbuincableconnectednotifier.cpp usbavkonmain.cpp -SOURCE usbnotifier.cpp - -USERINCLUDE ../inc - -SYSTEMINCLUDE ../../inc ../../../inc MW_LAYER_PLATFORM_EXPORT_PATH(SecondaryDisplay/) //for internal and private API headers - -MW_LAYER_SYSTEMINCLUDE -LIBRARY ECOM.LIB // Symbian E-Com Plugin definitions and types -LIBRARY euser.lib cone.lib // Symbian OS frameworklibraries -LIBRARY avkon.lib // UI library -LIBRARY bafl.lib // Basic Application Framework -LIBRARY commonengine.lib // Series 60 common components -LIBRARY eikcoctl.lib eiksrv.lib // Eikon libraries -LIBRARY eikdlg.lib // Eikon dialogs -LIBRARY estor.lib // for Cover Display UI support -LIBRARY FeatMgr.lib // for fetching if Cover Display is supported -LIBRARY centralrepository.lib // Central Repository -LIBRARY aknmemorycardui.lib // for unlocking the MMC -LIBRARY efsrv.lib // File server -LIBRARY eikcore.lib // for icons -LIBRARY aknskins.lib -LIBRARY aknskinsrv.lib -LIBRARY aknicon.lib -LIBRARY egul.lib -LIBRARY usbman.lib // for personality IDs and descriptions -LIBRARY aknnotifierwrapper.lib // Avkon's notifier wrapper -LIBRARY apparc.lib -LIBRARY akncapserverclient.lib // for suppressing the application key - -DEBUGLIBRARY flogger.lib // File logging services diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/group/usbuinotif.mmp --- a/usbuis/usbuinotif/group/usbuinotif.mmp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/group/usbuinotif.mmp Fri Mar 19 09:48:52 2010 +0200 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -29,14 +29,11 @@ SOURCEPATH ../src SOURCE usbuinmain.cpp SOURCE usbnotifier.cpp +SOURCE usbuincableconnectednotifier.cpp SOURCE usbuinqueriesnotifiermdrv.cpp SOURCE usbuinotifotgwarning.cpp SOURCE usbuinotifotgerror.cpp SOURCE usbuinotifmsmmerror.cpp -SOURCE usbuinotifdialerwatcher.cpp - - - // ECom resource file START RESOURCE ../data/102068DC.rss TARGET usbuinotif.rsc @@ -51,8 +48,9 @@ USERINCLUDE ../inc -SYSTEMINCLUDE ../../inc ../../../inc MW_LAYER_PLATFORM_EXPORT_PATH(SecondaryDisplay/) //for internal and private API headers -SYSTEMINCLUDE /epoc32/include/ecom +SYSTEMINCLUDE ../../inc ../../../inc MW_LAYER_PLATFORM_EXPORT_PATH(secondarydisplay/) //for internal and private API headers +SYSTEMINCLUDE /EPOC32/INCLUDE/ECOM +SYSTEMINCLUDE /epoc32/include/mw/hb/hbcore MW_LAYER_SYSTEMINCLUDE @@ -67,7 +65,6 @@ LIBRARY estor.lib // for Cover Display UI support LIBRARY FeatMgr.lib // for fetching if Cover Display is supported LIBRARY centralrepository.lib // Central Repository -LIBRARY aknmemorycardui.lib // for unlocking the MMC LIBRARY efsrv.lib // File server LIBRARY eikcore.lib // for icons LIBRARY aknskins.lib @@ -78,8 +75,7 @@ LIBRARY aknnotifierwrapper.lib // Avkon's notifier wrapper LIBRARY apparc.lib LIBRARY akncapserverclient.lib // for suppressing the application key -LIBRARY viewcli.lib -LIBRARY featmgr.lib +LIBRARY hbcore.lib DEBUGLIBRARY flogger.lib // File logging services diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/inc/usbuincableconnectednotifier.h --- a/usbuis/usbuinotif/inc/usbuincableconnectednotifier.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/inc/usbuincableconnectednotifier.h Fri Mar 19 09:48:52 2010 +0200 @@ -20,8 +20,8 @@ // INCLUDES -#include -#include +#include +#include #include "usbnotifier.h" // Base class // CLASS DECLARATION @@ -31,8 +31,8 @@ * * @lib */ -NONSHARABLE_CLASS(CUSBUICableConnectedNotifier) : public CUSBUINotifierBase, - public MEikCommandObserver +NONSHARABLE_CLASS(CUSBUICableConnectedNotifier) : public CUSBUINotifierBase, + public MHbDeviceDialogObserver { public: // Constructors and destructor @@ -84,10 +84,22 @@ void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); + +private: + // functions from MHbDeviceDialogObserver + /** - * Handles the command on USB connected note - */ - void ProcessCommandL(TInt aCommandId); + * lunches the QT usb ui setting + * @param aData is a CHbSymbianVariantMap daya which contains the keys + */ + void DataReceived(CHbSymbianVariantMap& aData); + /* + * Virtual function from MHbDeviceDialogObserver + * Not implemented + */ + void DeviceDialogClosed(TInt aCompletionCode); + + private: //New functions @@ -98,10 +110,12 @@ void GetCurrentIdL(TInt& aCurrentPersonality); /** * Get the mode name and header for current personality + * The parameters are pushed to the cleanup stack in order + * aDescription, aHeader. * @param aDescription The returned current personality string. * @param aHeader The header string for message query. */ - void GetPersonalityStringL(HBufC*& aHeader,HBufC*& aDescription ); + void GetPersonalityStringLC(HBufC*& aHeader,HBufC*& aDescription ); /** * Runs the connected discreet note @@ -110,26 +124,28 @@ /** - * creates the USB UI setting view - * @param aProcessName The process name (USBClassChangeUI.exe) + * launches the (USB) application + * @param aProcessName The process name (*.exe) * @param TUidType */ - void CreateChosenViewL(const TDesC & aProcessName,const TUidType & aUidType) const; + void LaunchApplication(const TDesC & aProcessName,const TUidType & aUidType) const; + + /** + * Adds a parameter to the dialog parameters. + */ + void AddParameterL( + CHbSymbianVariantMap* aParameters, + const TDesC& aKey, + const TAny* aData, + CHbSymbianVariant::TType aDataType); + private: /** * C++ default constructor. */ CUSBUICableConnectedNotifier(); - /** - * Waiter for canceling notifier. Canceling is not posible when note is visible - */ - CActiveSchedulerWait iNoteWaiter; - - /** - * Note visible - */ - TBool iNoteVisible; + CHbDeviceDialog* iDialog; }; #endif // USBUINCABLECONNECTEDNOTIFIER_H diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/inc/usbuinotifdialerwatcher.h --- a/usbuis/usbuinotif/inc/usbuinotifdialerwatcher.h Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -/* -* Copyright (c) 2007, 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Declares USB dialer activation watcher class - * -*/ - -#ifndef C_USBUINOTIFDIALERWATCHER_H -#define C_USBUINOTIFDIALERWATCHER_H - -#include -#include -#include -#include - - -/** - * Dialer activation callback - * - * This class specifies the functions when dialer is activated - * or note can be reactivated - * - */ -class MDialerNotifier - { -public: - /** - * The function to be when Dialaer is activated - * - */ - virtual void DialerActivated() = 0; - - /** - * The function to be when Dialaer is deactivated - * and note can be shown again - * - */ - virtual void ReActivateDialog() = 0; - }; - -/** - * - * This class will check if application key is pressed when error note is active. - * When application key is pressed dialer view is activated and error notifier is - * informed so it can dismis dialog. When dialer is deactivated error notifier is - * notified that dialog can be again shown. - * - */ -NONSHARABLE_CLASS( CUsbuinotifDialerWatcher): public CCoeControl, - public MVwsSessionWrapperObserver - - { -public: - /** - * Two-phased constructor. - * @param aDialerKeyNotifier Callback interface for dialer activation/deactivation - * @return dialer watcher - */ - - static CUsbuinotifDialerWatcher* NewL( MDialerNotifier* aDialerNotifier ); - - /** - * Two-phased constructor. - * @param aDialerKeyNotifier Callback interface for dialer activation/deactivation - * @return dialer watcher - */ - static CUsbuinotifDialerWatcher* NewLC( MDialerNotifier* aDialerNotifier ); - - /** - * Destructor - */ - virtual ~CUsbuinotifDialerWatcher(); - -private: - - /** - * From CCoeControl - * @param aKeyEvent Key Event - * @param aType Type of event - */ - TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); - -private: - - /** - * From MVwsSessionWrapperObserver - * @param aEvent View event - */ - void HandleViewEventL(const TVwsViewEvent &aEvent); - - -private: - - /** - * Constructor - * @param aDialerKeyNotifier Callback interface for dialer activation/deactivation - */ - CUsbuinotifDialerWatcher( MDialerNotifier* aDialerKeyNotifier ); - - /** - * Two-phased constructor. - */ - void ConstructL(); - -private: - // Member variables - - /** - * The observer for this objects events - * Not own. - */ - MDialerNotifier* iNotify; - - /** - * The observer for this objects events - * Own. - */ - CVwsSessionWrapper* iwsSession; - - /** - * Is notifier allready notified. - */ - TBool iNotified; - }; -#endif // C_USBUINOTIFDIALERWATCHER_H diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/inc/usbuinotifmsmmerror.h --- a/usbuis/usbuinotif/inc/usbuinotifmsmmerror.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/inc/usbuinotifmsmmerror.h Fri Mar 19 09:48:52 2010 +0200 @@ -23,8 +23,6 @@ #include "usbnotifier.h" // Base class #include // AVKON component -#include "usbuinotifdialerwatcher.h" - #define KUsbUiNotifOtgGeneralQueryGranularity 3 // CLASS DECLARATION @@ -34,7 +32,7 @@ * * @lib */ -NONSHARABLE_CLASS(CUsbUiNotifMSMMError) : public CUSBUINotifierBase, public MDialerNotifier +NONSHARABLE_CLASS(CUsbUiNotifMSMMError) : public CUSBUINotifierBase { public: @@ -97,23 +95,6 @@ */ void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); - -private: - - /** - * From MDialerNotifier - * The function to be when Dialaer is activated - * - */ - void DialerActivated(); - - /** - * From MDialerNotifier - * The function to be when Dialaer is deactivated - * and note can be shown again - * - */ - void ReActivateDialog(); private: @@ -140,14 +121,5 @@ CAknQueryDialog* iQuery; RArray iStringIds; TInt iErrorId; - /** - * Dialer watcher - * Own. - */ - CUsbuinotifDialerWatcher* iDialerWatcher; - /** - * Dialog is dismissed. - */ - TBool iDismissed; }; #endif // USBUINOTIFMSMMERROR_H diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/inc/usbuinotifotgerror.h --- a/usbuis/usbuinotif/inc/usbuinotifotgerror.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/inc/usbuinotifotgerror.h Fri Mar 19 09:48:52 2010 +0200 @@ -23,8 +23,6 @@ #include "usbnotifier.h" // Base class #include // AVKON component -#include "usbuinotifdialerwatcher.h" - #define KUsbUiNotifOtgGeneralQueryGranularity 3 // CLASS DECLARATION @@ -34,7 +32,7 @@ * * @lib */ -NONSHARABLE_CLASS(CUsbUiNotifOtgError) : public CUSBUINotifierBase, public MDialerNotifier +NONSHARABLE_CLASS(CUsbUiNotifOtgError) : public CUSBUINotifierBase { public: // Constructors and destructor @@ -87,23 +85,6 @@ */ void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); - -private: - - /** - * From MDialerNotifier - * The function to be when Dialaer is activated - * - */ - void DialerActivated(); - - /** - * From MDialerNotifier - * The function to be when Dialaer is deactivated - * and note can be shown again - * - */ - void ReActivateDialog(); private: @@ -130,14 +111,5 @@ CAknQueryDialog* iQuery; RArray iStringIds; TInt iErrorId; - /** - * Dialer watcher - * Own. - */ - CUsbuinotifDialerWatcher* iDialerWatcher; - /** - * Dialog is dismissed. - */ - TBool iDismissed; }; #endif // USBUINOTIFOTGERROR_H diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/inc/usbuinqueriesnotifier.h --- a/usbuis/usbuinotif/inc/usbuinqueriesnotifier.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/inc/usbuinqueriesnotifier.h Fri Mar 19 09:48:52 2010 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -22,7 +22,6 @@ #include "usbnotifier.h" // Base class #include // AVKON component -#include // CLASS DECLARATION @@ -31,8 +30,7 @@ * * @lib */ -NONSHARABLE_CLASS(CUSBUIQueriesNotifier) : public CUSBUINotifierBase, - public MAknMemoryCardDialogObserver +NONSHARABLE_CLASS(CUSBUIQueriesNotifier) : public CUSBUINotifierBase { public: // Constructors and destructor @@ -47,15 +45,6 @@ */ virtual ~CUSBUIQueriesNotifier(); -public: - // from MAknMemoryCardDialogObserver - - /** - * To be notified when unlock completed - * @param TInt aResult - * @return void - */ - void UnlockComplete(TInt aResult); private: // Functions from base class @@ -104,15 +93,6 @@ private: // New functions - /** - * Unlock the locked memory card - * First inform user that the memory card is locked and then show the - * memory card dialog for unlocking. - * @param aStringHolder The string for the query. - * @param aCoverDialogId The dialog ID for the cover UI. - * @return KErrNone - user accepted, KErrCancel - End call key pressed - */ - TInt UnlockMemoryCardL(const TDesC& aStringHolder, TInt aCoverDialogId); /** * Show query dialog @@ -144,8 +124,6 @@ CAknQueryDialog* iUSBQueryDlg; TUSBUIQueries iQueryType; // To store the type of the query TInt iDriveLetter; // For MMC locked case - // Used for possible Cancel while the dialog is showing - CAknMemoryCardDialog* iMemoryCardDialog; }; #endif // USBUINQUERIESNOTIFIER_H diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/inc/usbuinqueriesnotifiermdrv.h --- a/usbuis/usbuinotif/inc/usbuinqueriesnotifiermdrv.h Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/inc/usbuinqueriesnotifiermdrv.h Fri Mar 19 09:48:52 2010 +0200 @@ -106,7 +106,7 @@ * @return KErrNone - accepted, KErrCancel - Cancel or End call key */ TInt QueryUserResponseL(const TDesC& aStringHolder, TInt aCoverDialogId, - TBool aIsCancelKey); + TBool aIsCancelKey, TBool aIsErrorQuery); /** * Get attributes for the query dialog @@ -117,7 +117,7 @@ * @param aIsCancelKey Returned info about showing the Cancel key. * @return The string holder for the query. */ - HBufC* GetQueryAttributesLC(TInt& aCoverDialogId, TBool& aIsCancelKey); + HBufC* GetQueryAttributesLC(TInt& aCoverDialogId, TBool& aIsCancelKey, TBool& aIsErrorQuery); private: // Data diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/loc/usbuinotif.loc --- a/usbuis/usbuinotif/loc/usbuinotif.loc Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/loc/usbuinotif.loc Fri Mar 19 09:48:52 2010 +0200 @@ -139,6 +139,11 @@ // #define qtn_usb_otg_general_mass_storage_error "General Mass storage error" +//d: Memory not enough or full error +//l: popup_note_window +//r: 5.2 +#define qtn_usb_error_memory_not_enough "Memory full. Close some applications and try to connect USB cable again" + // End of USB_OTG // End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/rom/usbuinotif.iby --- a/usbuis/usbuinotif/rom/usbuinotif.iby Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/rom/usbuinotif.iby Fri Mar 19 09:48:52 2010 +0200 @@ -22,7 +22,6 @@ #ifdef __USB_MULTIPERSONALITY ECOM_PLUGIN(usbuinotif.dll, 102068DC.rsc) -file=ABI_DIR\BUILD_DIR\usbavkonnotif.dll SHARED_LIB_DIR\usbavkonnotif.dll #endif //__USB_MULTIPERSONALITY #endif //__USBUINOTIF_IBY__ \ No newline at end of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/src/usbavkonmain.cpp --- a/usbuis/usbuinotif/src/usbavkonmain.cpp Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of "Eclipse Public License v1.0" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: Methods for USB UI notifiers. - * - */ - -// INCLUDE FILES -#include -#include - -#include "usbuincableconnectednotifier.h" -#include "usbuinqueriesnotifier.h" -#include "usbuinotifdebug.h" - -// CONSTANTS -const TInt KUSBUINotifierArrayIncrement = 1; - - -// ================= EXPORTED FUNCTIONS ======================================= - -// ---------------------------------------------------------------------------- -// -// Instantiate notifiers -// -// ---------------------------------------------------------------------------- - -LOCAL_C void CreateUSBUINotifiersL( - CArrayPtrFlat* aNotifiers ) - { - FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL")); - - CUSBUICableConnectedNotifier* cableConnectedNotifier = - CUSBUICableConnectedNotifier::NewL(); - CleanupStack::PushL( cableConnectedNotifier ); - aNotifiers->AppendL( cableConnectedNotifier ); - CleanupStack::Pop( cableConnectedNotifier ); - - - FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL completed")); - } - -// ---------------------------------------------------------------------------- -// -// Lib main entry point: Creates a notifiers array. -// -// ---------------------------------------------------------------------------- - -EXPORT_C CArrayPtr* NotifierArray() - { - FLOG(_L("[USBUINOTIF]\t NotifierArray")); - - CArrayPtrFlat* notifiers = NULL; - - TRAPD( err, notifiers = - new (ELeave)CArrayPtrFlat( - KUSBUINotifierArrayIncrement )); - - if ( err == KErrNone ) - { - if( notifiers ) - { - TRAPD( errCreate, CreateUSBUINotifiersL( notifiers )); - if( errCreate ) - { - TInt count = notifiers->Count(); - while(count--) - { - (*notifiers)[count]->Release(); - } - delete notifiers; - notifiers = NULL; - } - - FLOG(_L("[USBUINOTIF]\t NotifierArray completed")); - } - } - else - { - FLOG(_L("[USBUINOTIF]\t NotifierArray Failed!!!")); - } - - return notifiers; - } - -// End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/src/usbuincableconnectednotifier.cpp --- a/usbuis/usbuinotif/src/usbuincableconnectednotifier.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/src/usbuincableconnectednotifier.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -21,32 +21,20 @@ #include #include // Localisation stringloader #include // Unicode character conversion utilities -#include -#include +#include #include // Own resources #include #include -//for loading icons USB fork and empty -#include -#include -#include -#include -//for cover display support -#include -#include // Dialog index for cover UI -#include #include // KExecutableImageUid -#include #include "usbuincableconnectednotifier.h" // Own class definition #include "usbuinotifdebug.h" // Debugging macros #include "UsbWatcherInternalCRKeys.h" -#include "usbpersonalityids.h" #include "usbuinotif.hrh" // Literals -_LIT(KUSBExe, "usbclasschangeui.exe"); -const TInt KUSBUIUid = 0x102068E2; +_LIT(KUSBExe, "usbapplication.exe"); +const TInt KUSBUIUid = 0x2002BCA3; _LIT(KFileDrive,"z:"); _LIT(KUSBUIconFileName, "usbui.mif"); @@ -75,8 +63,7 @@ // might leave. // ---------------------------------------------------------------------------- // -CUSBUICableConnectedNotifier::CUSBUICableConnectedNotifier(): - iNoteVisible(EFalse) +CUSBUICableConnectedNotifier::CUSBUICableConnectedNotifier() { FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::default constructor")); } @@ -92,6 +79,8 @@ //this virtual function call is to the local CUSBUICableConnectedNotifier:: //Cancel, not to any possibly derived class implementation. Cancel(); + delete iDialog; + FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::destructor completed")); } @@ -146,7 +135,7 @@ void CUSBUICableConnectedNotifier::RunL() { FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::RunL")); - iNoteVisible = ETrue; + DisableKeylock(); SuppressAppSwitching(ETrue); RunQueryL(); @@ -164,12 +153,8 @@ void CUSBUICableConnectedNotifier::Cancel() { FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::Cancel() ")); - // Not allowed to cancel this one before note is closed. - if ( iNoteVisible ) - { - iNoteWaiter.Start(); - } - + + iDialog->Cancel(); // cancel the dialog, if it is active CompleteMessage(KErrCancel); CUSBUINotifierBase::Cancel(); @@ -181,7 +166,7 @@ // Get the strings for ask on connection message query // ----------------------------------------------------------------------------------------------------------- // -void CUSBUICableConnectedNotifier::GetPersonalityStringL( +void CUSBUICableConnectedNotifier::GetPersonalityStringLC( HBufC*& aHeader,HBufC*& aDescription ) { FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::GetPersonalityStringL")); @@ -193,9 +178,9 @@ User::LeaveIfError(usbman.GetDescription(CurrentPersonalityID, aDescription)); CleanupStack::PopAndDestroy(&usbman); - + CleanupStack::PushL(aDescription); aHeader = StringLoader::LoadL(R_USB_MODE_MSG_HEADER); - + CleanupStack::PushL(aHeader); FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::GetPersonalityStringL completed")); } @@ -207,24 +192,45 @@ void CUSBUICableConnectedNotifier::RunQueryL() { FLOG( _L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::RunQueryL()")); - - HBufC* header = NULL; - HBufC* description =NULL; - GetPersonalityStringL(header, description); - - CleanupStack::PushL(header); - CleanupStack::PushL(description); - - TFileName usbUiIconFilename( KFileDrive ); - usbUiIconFilename += KDC_APP_BITMAP_DIR; - usbUiIconFilename += KUSBUIconFileName; - iNoteVisible = ETrue; - CAknDiscreetPopup::ShowGlobalPopupL(*header,*description, KAknsIIDQgnPropUsb, AknIconUtils::AvkonIconFileName(), - EMbmAvkonQgn_prop_usb, EMbmAvkonQgn_prop_usb_mask,KAknDiscreetPopupDurationLong, EUSBUICmdDiscreetTapped,( MEikCommandObserver* ) this); + + _LIT(KNotificationType,"com.nokia.hb.devicenotificationdialog/1.0"); + _LIT(KTouchActivation, "touchActivation"); + _LIT(KIconName, "iconName"); + _LIT(KTitle, "title"); + _LIT(KText, "text"); + + HBufC* header = NULL; + HBufC* description =NULL; + GetPersonalityStringLC(header, description); - CleanupStack::PopAndDestroy(description); + TFileName usbUiIconFilename( KFileDrive ); + usbUiIconFilename += KDC_APP_BITMAP_DIR; + usbUiIconFilename += KUSBUIconFileName; + if( iDialog ) + { + delete iDialog; + iDialog = NULL; + } + iDialog = CHbDeviceDialog::NewL(); + CHbSymbianVariantMap *parameters =CHbSymbianVariantMap::NewL(); + CleanupStack::PushL(parameters); + + AddParameterL(parameters, KTitle, header, CHbSymbianVariant::EDes); + AddParameterL(parameters, KText, description, CHbSymbianVariant::EDes); + AddParameterL(parameters, KIconName, &usbUiIconFilename, CHbSymbianVariant::EDes); + TBool activation=ETrue; + AddParameterL(parameters, KTouchActivation, &activation, CHbSymbianVariant::EBool); + + FLOG( _L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::RunQueryL() show") ); + TBool error = iDialog->Show(KNotificationType ,*parameters, this); + FTRACE( FPrint( + _L( "[USBUINOTIF]\t CUSBUICableConnectedNotifier::RunQueryL() error = %d" ), + error ) ); + + CleanupStack::PopAndDestroy(parameters); CleanupStack::PopAndDestroy(header); - + CleanupStack::PopAndDestroy(description); + FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::RunQueryL completed")); } // ---------------------------------------------------------------------------- @@ -239,51 +245,100 @@ CRepository* repository = CRepository::NewL(KCRUidUsbWatcher); CleanupStack::PushL(repository); // Get the current USB mode - repository->Get(KUsbWatcherPersonality, aCurrentPersonality); + TInt ret = repository->Get(KUsbWatcherPersonality, aCurrentPersonality); + FTRACE( FPrint( + _L( "[USBWATCHER]\t CUSBUICableConnectedNotifier::GetCurrentIdL() ret = %d" ), + ret ) ); CleanupStack::PopAndDestroy(repository); FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::GetCurrentIdL completed")); } // ---------------------------------------------------------------------------- -// CUSBUICableConnectedNotifier::ProcessCommandL() -// when discreet pop up is tapped the command will be handled here +// CUSBUICableConnectedNotifier::DataReceived +// launches the QT usb ui setting // ---------------------------------------------------------------------------- // -void CUSBUICableConnectedNotifier::ProcessCommandL(TInt aCommandId) +void CUSBUICableConnectedNotifier::DataReceived(CHbSymbianVariantMap& aData) { - switch ( aCommandId ) - { - case EUSBUICmdDiscreetTapped: - { - TUidType uidtype(KExecutableImageUid, TUid::Uid(0x00),TUid::Uid(KUSBUIUid)); - CreateChosenViewL(KUSBExe(),uidtype); - } - case EAknDiscreetPopupCmdClose: - if ( iNoteWaiter.IsStarted() ) + FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::DataReceived")); + _LIT(KResult, "result"); + _LIT(KActivated, "activated"); + TInt result = 0; + MDesCArray& keys = aData.Keys(); + HBufC* key = NULL; + for(TInt i = 0; i < keys.MdcaCount(); i++) + { + result = keys.MdcaPoint(i).Compare(KResult); + if (result == 0) + { + key = HBufC::New(KResult().Length()); + if (key) { - iNoteWaiter.AsyncStop(); + *key = KResult; + const CHbSymbianVariant* variant = aData.Get(*key); + delete key; + HBufC* value = static_cast(variant->Data()); + result = value->Des().Compare(KActivated); + if (result == 0) + { + TUidType uidtype(KExecutableImageUid, TUid::Uid(0x00), + TUid::Uid(KUSBUIUid)); + LaunchApplication(KUSBExe(), uidtype); + } + break; } - iNoteVisible = EFalse; - CompleteMessage( KErrCancel ); - break; - default: - - break; - } + } + } } + +// ---------------------------------------------------------------------------- +// CUSBUICableConnectedNotifier::DeviceDialogClosed +// ---------------------------------------------------------------------------- +// + void CUSBUICableConnectedNotifier::DeviceDialogClosed(TInt aCompletionCode) + { + FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::DeviceDialogClosed()")); + CompleteMessage(aCompletionCode); + } + // --------------------------------------------------------------------------- -// CUSBUICableConnectedNotifier::CreateChosenViewL() -// creates the USB UI setting view +// CUSBUICableConnectedNotifier::LaunchApplication() +// launches the application // --------------------------------------------------------------------------- // - void CUSBUICableConnectedNotifier::CreateChosenViewL(const TDesC & aProcessName,const TUidType & aUidType) const +void CUSBUICableConnectedNotifier::LaunchApplication(const TDesC & aProcessName, + const TUidType & aUidType) const { - FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::CreateDesiredViewL() ")); - RProcess usbUiProcess; - User::LeaveIfError(usbUiProcess.Create(aProcessName, KNullDesC, aUidType)); - usbUiProcess.Resume(); - usbUiProcess.Close(); - FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::CreateDesiredViewL() ")); + FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::LaunchApplication()")); + RProcess usbUiProcess; + TInt result = usbUiProcess.Create(aProcessName, KNullDesC, aUidType); + FTRACE( FPrint( + _L( "[USBUINOTIF]\t CUSBUICableConnectedNotifier::LaunchApplication() result = %d" ), + result ) ); + usbUiProcess.Resume(); + usbUiProcess.Close(); + FLOG(_L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::LaunchApplication() completed")); + } +// --------------------------------------------------------------------------- +// CUSBUICableConnectedNotifier::AddParameter() +// Adds a string parameter to the dialog parameters. +// --------------------------------------------------------------------------- +// +void CUSBUICableConnectedNotifier::AddParameterL( + CHbSymbianVariantMap* aParameters, + const TDesC& aKey, + const TAny* aData, + CHbSymbianVariant::TType aDataType) + { + FLOG( _L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::AddStringParameter()") ); + FTRACE( FPrint( + _L( "[USBWATCHER]\t CUSBUICableConnectedNotifier::RunQueryL() aKey = %S" ), + &aKey ) ); + CHbSymbianVariant* variant = CHbSymbianVariant::NewL(aData, aDataType); + //aParameters takes variant ownership + User::LeaveIfError(aParameters->Add(aKey, variant)); + FLOG( _L("[USBUINOTIF]\t CUSBUICableConnectedNotifier::AddStringParameter() completed") ); } + // End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/src/usbuinmain.cpp --- a/usbuis/usbuinotif/src/usbuinmain.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/src/usbuinmain.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -20,21 +20,17 @@ #include #include #include -#include -#include #include "usbuincableconnectednotifier.h" #include "usbuinqueriesnotifier.h" - - #include "usbuinotifdebug.h" #include "usbuinotifotgwarning.h" #include "usbuinotifotgerror.h" #include "usbuinotifmsmmerror.h" // CONSTANTS -const TInt KUSBUINotifierArrayIncrement = 4; -_LIT( KUSBUINotifdll, "usbavkonnotif.dll" ); +const TInt KUSBUINotifierArrayIncrement = 5; + // ================= EXPORTED FUNCTIONS ======================================= // ---------------------------------------------------------------------------- // @@ -46,20 +42,12 @@ { FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL")); - /* The CableconnectionNotifier is created on the Avkon Wrapper - * because it contains the discreet popups which are only possible - * to be launched in a UI framework - */ - CAknCommonNotifierWrapper* master = - CAknCommonNotifierWrapper::NewL(KCableConnectedNotifierUid, - KCableConnectedNotifierUid, - MEikSrvNotifierBase2::ENotifierPriorityVHigh, - KUSBUINotifdll, - 1); // no synchronous reply used. - CleanupStack::PushL(master); - - aNotifiers->AppendL(master ); - CleanupStack::Pop( master ); + CUSBUICableConnectedNotifier* cableConnectedNotifier = + CUSBUICableConnectedNotifier::NewL(); + CleanupStack::PushL( cableConnectedNotifier ); + aNotifiers->AppendL( cableConnectedNotifier ); + CleanupStack::Pop( cableConnectedNotifier ); + CUSBUIQueriesNotifier* queriesNotifier = CUSBUIQueriesNotifier::NewL(); CleanupStack::PushL( queriesNotifier ); aNotifiers->AppendL( queriesNotifier ); @@ -128,11 +116,7 @@ const TImplementationProxy ImplementationTable[] = { -#ifdef __EABI__ - {{0x10281F23},(TFuncPtr)NotifierArray}, -#else - {{0x10281F23},NotifierArray}, -#endif + IMPLEMENTATION_PROXY_ENTRY( 0x10281F23, NotifierArray ) }; EXPORT_C const TImplementationProxy* ImplementationGroupProxy( diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/src/usbuinotifdialerwatcher.cpp --- a/usbuis/usbuinotif/src/usbuinotifdialerwatcher.cpp Tue Feb 02 00:52:37 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -/* -* Copyright (c) 2007, 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: USB dialer activation watcher class - * -*/ - - -#include -#include -#include -#include -#include - - -#include "usbuinotifdialerwatcher.h" -#include "debug.h" -#include "usbuinotifdebug.h" - -// ======== MEMBER FUNCTIONS ======== -// --------------------------------------------------------------------------- -// NewL -// --------------------------------------------------------------------------- -// -CUsbuinotifDialerWatcher* CUsbuinotifDialerWatcher::NewL( MDialerNotifier* aDialerNotifier ) - { - FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher::NewL")) - CUsbuinotifDialerWatcher* self = CUsbuinotifDialerWatcher::NewLC( aDialerNotifier); - CleanupStack::Pop( self ); - return self; - } - -// --------------------------------------------------------------------------- -// NewLC -// --------------------------------------------------------------------------- -// -CUsbuinotifDialerWatcher* CUsbuinotifDialerWatcher::NewLC( MDialerNotifier* aDialerNotifier ) - { - FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher::NewLC")) - CUsbuinotifDialerWatcher* self = new ( ELeave ) CUsbuinotifDialerWatcher( aDialerNotifier ); - CleanupStack::PushL( self ); - self->ConstructL( ); - return self; - } - -// --------------------------------------------------------------------------- -// CUsbuinotifDialerWatcher() -// --------------------------------------------------------------------------- -// -CUsbuinotifDialerWatcher::CUsbuinotifDialerWatcher( MDialerNotifier* aDialerNotifier ) : - iNotify( aDialerNotifier ) - { - FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher::CUsbuinotifDialerWatcher")) - } - -// --------------------------------------------------------------------------- -// Destructor -// --------------------------------------------------------------------------- -// -CUsbuinotifDialerWatcher::~CUsbuinotifDialerWatcher() - { - FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher Destructor")) - CCoeAppUi* appui=CEikonEnv::Static()->AppUi(); - appui->RemoveFromStack(this); - delete iwsSession; - } - -// --------------------------------------------------------------------------- -// ConstructL() -// --------------------------------------------------------------------------- -// -void CUsbuinotifDialerWatcher::ConstructL() - { - FLOG(_L("[USBUINOTIF]\t CUsbuinotifDialerWatcher ConstructL")); - CCoeAppUi* appui=CEikonEnv::Static()->AppUi(); - appui->AddToStackL(this,ECoeStackPriorityCba); - } - -// --------------------------------------------------------------------------- -// HandleViewEventL() -// --------------------------------------------------------------------------- -// -void CUsbuinotifDialerWatcher::HandleViewEventL(const TVwsViewEvent& /*aEvent*/) - { - FLOG((_L("[USBUINOTIF]\t HandleViewEventL "))); - - if ( !iNotified ) - { - iNotify->ReActivateDialog(); - iNotified=ETrue; - } - FLOG(_L("[USBUINOTIF]\t HandleViewEventL Done")); - } - -// --------------------------------------------------------------------------- -// OfferKeyEventL -// --------------------------------------------------------------------------- -// -TKeyResponse CUsbuinotifDialerWatcher::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode /*aType*/) - { - if (aKeyEvent.iScanCode == EStdKeyApplication0) - { - if ( !iwsSession ) - { - iwsSession = CVwsSessionWrapper::NewL(*this); - } - iNotified=EFalse; - const TVwsViewId viewId(KScutDiallerUid, KScutDiallerViewId ); - TUid msgId = KScutDiallerViewCommand; - iwsSession->CreateActivateViewEvent( viewId, msgId, KNullDesC8 ); - CCoeAppUi* appui=CEikonEnv::Static()->AppUi(); - iNotify->DialerActivated(); - iwsSession->NotifyNextDeactivation(viewId); - } - - return EKeyWasNotConsumed; - } - diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp --- a/usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/src/usbuinotifmsmmerror.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -24,7 +24,6 @@ #include #include #include -#include #include // pck #include // Own resources @@ -68,8 +67,6 @@ //this virtual function call is to local CUsbUiNotifMSMMError::Cancel, //not to any possibly derived class implementation. Cancel(); - delete iDialerWatcher; - delete iQuery; } void CUsbUiNotifMSMMError::ConstructL() @@ -144,28 +141,16 @@ { FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::RunL")); TInt returnValue = KErrNone; - FeatureManager::InitializeLibL(); - if ( FeatureManager::FeatureSupported( KFeatureIdFfKeypadNoSendKey ) ) - { - if (!iDialerWatcher) - { - iDialerWatcher = CUsbuinotifDialerWatcher::NewL(this); - } - } - iDismissed=EFalse; + DisableKeylock(); SuppressAppSwitching( ETrue ); //Excute dialog and check return value returnValue = QueryUserResponseL(); - if (!iDismissed) - { - SuppressAppSwitching( EFalse ); - RestoreKeylock(); - delete iDialerWatcher; - iDialerWatcher = NULL; - CompleteMessage( returnValue ); - } + + SuppressAppSwitching( EFalse ); + RestoreKeylock(); + CompleteMessage( returnValue ); FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::RunL() completed")); } @@ -178,56 +163,17 @@ void CUsbUiNotifMSMMError::Cancel() { FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel")); - // If dialog is not dismissed this is normal cancel and if query - // doesn't exsist notifier is canceled during dismission - if (!iDismissed || !iQuery ) - { - delete iDialerWatcher; - iDialerWatcher = NULL; - CompleteMessage( KErrCancel ); - } if (iQuery) { delete iQuery; iQuery = NULL; } - + CompleteMessage( KErrCancel ); FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::Cancel() completed")); } // ---------------------------------------------------------------------------- -// CUsbUiNotifOtgError::DialerActivated -// Release all own resources (member variables) -// ---------------------------------------------------------------------------- -// -void CUsbUiNotifMSMMError::DialerActivated() - { - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::AppKeyPressed()")); - if ( iQuery ) - { - iDismissed=ETrue; - Cancel(); - } - } - -// ---------------------------------------------------------------------------- -// CUsbUiNotifOtgError::ReActivateDialog -// Release all own resources (member variables) -// ---------------------------------------------------------------------------- -// -void CUsbUiNotifMSMMError::ReActivateDialog() - { - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ReActivateDialog()")); - if ( !IsActive()) - { - SetActive(); - iStatus = KRequestPending; - TRequestStatus* stat = &iStatus; - User::RequestComplete( stat, KErrNone ); - } - } -// ---------------------------------------------------------------------------- // CUsbUiNotifMSMMError::QueryUserResponseL // Show query dialog. // ---------------------------------------------------------------------------- @@ -237,17 +183,9 @@ FLOG(_L("[USBUINOTIF]\t CUsbUiNotifMSMMError::QueryUserResponseL")); TInt returnValue = KErrNone; TInt resourceId = R_USB_QUERY_OTG_ERROR; - if (iDismissed) - { - iQuery = CAknQueryDialog::NewL(); - } - else - { - iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone ); - } - - - iDismissed=EFalse; + + iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone ); + if (iCoverDisplaySupported) { iQuery->PublishDialogL( iErrorId, KUsbUiNotifMsmmError ); diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/src/usbuinotifotgerror.cpp --- a/usbuis/usbuinotif/src/usbuinotifotgerror.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/src/usbuinotifotgerror.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -23,7 +23,6 @@ #include // Localisation stringloader #include #include -#include #include // pck #include // Own resources @@ -67,8 +66,6 @@ //this virtual function call is to local CUsbUiNotifOtgError::Cancel, //not to any possibly derived class implementation. Cancel(); - delete iDialerWatcher; - delete iQuery; } void CUsbUiNotifOtgError::ConstructL() @@ -108,18 +105,24 @@ { User::Leave( KErrInUse ); } - - iMessage = aMessage; - iNeedToCompleteMessage = ETrue; - iReplySlot = aReplySlot; - + // Get parameters // - iErrorId = 0; + TPckgC pckg( iErrorId ); pckg.Set( aBuffer ); iErrorId = pckg(); - + + FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::GetParamsL iErrorId: %d"), iErrorId )); + if ( iErrorId < 0 || iErrorId >= iStringIds.Count() ) + { + User::Leave( KErrArgument); + } + + iMessage = aMessage; + iNeedToCompleteMessage = ETrue; + iReplySlot = aReplySlot; + SetActive(); iStatus = KRequestPending; TRequestStatus* stat = &iStatus; @@ -136,29 +139,16 @@ { FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::RunL")); TInt returnValue = KErrNone; - FeatureManager::InitializeLibL(); - if ( FeatureManager::FeatureSupported( KFeatureIdFfKeypadNoSendKey ) ) - { - if (!iDialerWatcher) - { - iDialerWatcher = CUsbuinotifDialerWatcher::NewL(this); - } - } - FeatureManager::UnInitializeLib(); - iDismissed=EFalse; + DisableKeylock(); SuppressAppSwitching( ETrue ); //Excute dialog and check return value returnValue = QueryUserResponseL(); - if (!iDismissed) - { - SuppressAppSwitching( EFalse ); - RestoreKeylock(); - delete iDialerWatcher; - iDialerWatcher = NULL; - CompleteMessage( returnValue ); - } + + SuppressAppSwitching( EFalse ); + RestoreKeylock(); + CompleteMessage( returnValue ); FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::RunL() completed")); } @@ -170,54 +160,15 @@ // void CUsbUiNotifOtgError::Cancel() { - FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel")); - - // If dialog is not dismissed this is normal cancel and if query - // doesn't exsist notifier is canceled during dismission - if (!iDismissed || !iQuery ) - { - delete iDialerWatcher; - iDialerWatcher = NULL; - CompleteMessage( KErrCancel ); - } + FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel")); if (iQuery) { delete iQuery; iQuery = NULL; } - FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel() completed")); - } + CompleteMessage( KErrCancel ); -// ---------------------------------------------------------------------------- -// CUsbUiNotifOtgError::DialerActivated -// Release all own resources (member variables) -// ---------------------------------------------------------------------------- -// -void CUsbUiNotifOtgError::DialerActivated() - { - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::AppKeyPressed()")); - if ( iQuery ) - { - iDismissed=ETrue; - Cancel(); - } - } - -// ---------------------------------------------------------------------------- -// CUsbUiNotifOtgError::ReActivateDialog -// Release all own resources (member variables) -// ---------------------------------------------------------------------------- -// -void CUsbUiNotifOtgError::ReActivateDialog() - { - FLOG(_L("[USBUINOTIF]\t CUSBUINotifierBase::ReActivateDialog()")); - if ( !IsActive()) - { - SetActive(); - iStatus = KRequestPending; - TRequestStatus* stat = &iStatus; - User::RequestComplete( stat, KErrNone ); - } + FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::Cancel() completed")); } // ---------------------------------------------------------------------------- @@ -230,17 +181,9 @@ FLOG(_L("[USBUINOTIF]\t CUsbUiNotifOtgError::QueryUserResponseL")); TInt returnValue = KErrNone; TInt resourceId = R_USB_QUERY_OTG_ERROR; - if (iDismissed) - { - iQuery = CAknQueryDialog::NewL(); - } - else - { - iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone ); - } - - - iDismissed=EFalse; + + iQuery = CAknQueryDialog::NewL( CAknQueryDialog::EErrorTone ); + if (iCoverDisplaySupported) { iQuery->PublishDialogL( iErrorId, KUsbUiNotifOtgError ); diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/src/usbuinotifotgwarning.cpp --- a/usbuis/usbuinotif/src/usbuinotifotgwarning.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/src/usbuinotifotgwarning.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -73,7 +73,7 @@ void CUsbUiNotifOtgWarning::ConstructL() { CUSBUINotifierBase::ConstructL(); - iStringIds.AppendL( R_USB_OTG_WARNING_PARTIAL_SUPPORTED); + iStringIds.AppendL( R_USB_OTG_WARNING_PARTIAL_SUPPORT); } // ---------------------------------------------------------------------------- @@ -123,18 +123,24 @@ if (iNote || iReplySlot != 0 || iNeedToCompleteMessage) { User::Leave( KErrInUse ); - } - - iMessage = aMessage; - iNeedToCompleteMessage = ETrue; - iReplySlot = aReplySlot; + } // Get parameters // TPckgC pckg( iNoteId ); pckg.Set( aBuffer ); iNoteId = pckg(); + + FTRACE(FPrint(_L("[USBUINOTIF]\t CUsbUiNotifOtgWarning::GetParamsL iNoteId: %d"), iNoteId )); + if ( iNoteId < 0 || iNoteId >= iStringIds.Count() ) + { + User::Leave( KErrArgument); + } + iMessage = aMessage; + iNeedToCompleteMessage = ETrue; + iReplySlot = aReplySlot; + SetActive(); iStatus = KRequestPending; TRequestStatus* stat = &iStatus; diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/src/usbuinqueriesnotifiermdrv.cpp --- a/usbuis/usbuinotif/src/usbuinqueriesnotifiermdrv.cpp Tue Feb 02 00:52:37 2010 +0200 +++ b/usbuis/usbuinotif/src/usbuinqueriesnotifiermdrv.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -163,13 +163,14 @@ FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::RunL")); TBool isCancelKey = EFalse; + TBool isErrorQuery = EFalse; TInt returnValue = KErrNone; // for cover display support TInt coverDialogId = EUSBCoverInvalidDialogId; // Choose text and other query attributes // - HBufC* stringHolder = GetQueryAttributesLC( coverDialogId, isCancelKey ); + HBufC* stringHolder = GetQueryAttributesLC( coverDialogId, isCancelKey, isErrorQuery ); //check if query text string loading was successful if (NULL != stringHolder) @@ -177,7 +178,7 @@ DisableKeylock(); SuppressAppSwitching( ETrue ); returnValue = QueryUserResponseL( *stringHolder, coverDialogId, - isCancelKey ); + isCancelKey, isErrorQuery ); SuppressAppSwitching( EFalse ); RestoreKeylock(); CleanupStack::PopAndDestroy( stringHolder ); @@ -219,7 +220,7 @@ // ---------------------------------------------------------------------------- // TInt CUSBUIQueriesNotifier::QueryUserResponseL(const TDesC& aStringHolder, - TInt aCoverDialogId, TBool aIsCancelKey) + TInt aCoverDialogId, TBool aIsCancelKey, TBool aIsErrorQuery) { FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::QueryUserResponseL")); TInt returnValue = KErrNone; @@ -228,7 +229,13 @@ // Show dialog with or without the Cancel // - if (aIsCancelKey) + if (aIsErrorQuery) + { + // aIsErrorQuery flag is set in GetQueryAttributesLC() + // there is no defined QueryDialogError in resources so QueryOTGerror is used (contains Stop icon) + iUSBQueryDlg->PrepareLC( R_USB_QUERY_OTG_ERROR ); + } + else if (aIsCancelKey) { iUSBQueryDlg->PrepareLC( R_USB_QUERY_WITH_CANCEL ); } @@ -270,11 +277,12 @@ // ---------------------------------------------------------------------------- // HBufC* CUSBUIQueriesNotifier::GetQueryAttributesLC(TInt& aCoverDialogId, - TBool& aIsCancelKey) + TBool& aIsCancelKey, TBool& aIsErrorQuery) { FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::GetQueryAttributesLC")); HBufC* stringHolder = NULL; // The text for the query aIsCancelKey = EFalse; + aIsErrorQuery = EFalse; switch (iQueryType) { case EUSBStorageMediaFailure: @@ -299,6 +307,15 @@ stringHolder = StringLoader::LoadLC( R_USB_NO_MEMORY_CARD ); aCoverDialogId = EUSBCoverNoMemoryCard; break; + } + case EUSBNotEnoughRam: + { + FLOG(_L("[USBUINOTIF]\t CUSBUIQueriesNotifier::EUSBNotEnoughRam")); + stringHolder = StringLoader::LoadLC( R_USB_ERROR_MEMORY_NOT_ENOUGH ); + aCoverDialogId = EUSBCoverNoMemoryCard; + //set flag to change the icon of querydialog (see QueryUserResponseL()) + aIsErrorQuery = ETrue; + break; } default: { diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/bmarm/usbuinotifapitestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/bmarm/usbuinotifapitestu.def Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) + diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/bwins/usbuinotifapitestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/bwins/usbuinotifapitestu.def Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) + diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/conf/ui_usbuinotifapitest.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/conf/ui_usbuinotifapitest.cfg Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,230 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Test script config file +* +*/ + +// UsbUiNotifApiTest Module - total 21 tc + +// UsbUiNotifApiTest Api Tests (... tc) + +// Cable connected notifier tests (3) + +[Test] +title USB Ovi Suite Personality Info (Cable Connected Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock CableConnectedNotifierTest PCSUITEMTP +pause 4000 +delete tester +[Endtest] + +[Test] +title USB MS Personality Info (Cable Connected Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock CableConnectedNotifierTest MS +pause 4000 +delete tester +[Endtest] + +[Test] +title USB MTP Personality Info (Cable Connected Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock CableConnectedNotifierTest MTP +pause 4000 +delete tester +[Endtest] + + +[Test] +title USB No Memory Card Query Accepted (USB Queries Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbQueriesNotifierTest EUSBNoMemoryCard +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title USB Storage Media Failure Query Accepted/Device Key Enter Pressed (USB Queries Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbQueriesNotifierTest EUSBStorageMediaFailure +pause 3000 +presskey global EKeyEnter +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title USB Storage Media Failure Query Accepted/Device Key 0 Pressed (USB Queries Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbQueriesNotifierTest EUSBStorageMediaFailure +pause 1000 +presskey global EKeyDevice0 +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title USB Change From Mass Storage Query Accepted/Device Key Enter Pressed (USB Queries Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbQueriesNotifierTest EUSBChangeFromMassStorage +pause 3000 +presskey global EKeyEnter +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title USB Change From Mass Storage Query Accepted/Device Key 0 Pressed (USB Queries Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbQueriesNotifierTest EUSBChangeFromMassStorage +pause 3000 +presskey global EKeyDevice0 +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title USB Change From Mass Storage Query Cancelled (USB Queries Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbQueriesNotifierTest EUSBChangeFromMassStorage +pause 3000 +presskey global EKeyDevice1 +tester ExecuteApiTestBlock FinishQuery CANCEL +delete tester +[Endtest] + + +[Test] +title OTG Error too much power (Otg Error Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbOTGErrorNotifierTests EUsbOtgTooMuchPower +pause 3000 +presskey global EKeyDevice0 +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title OTG Error too much power (Otg Error Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbOTGErrorNotifierTests EUsbOtgTooMuchPowerRequired +pause 3000 +presskey global EKeyDevice0 +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title OTG Error unsupported device (Otg Error Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbOTGErrorNotifierTests EUsbOtgUnsupportedDevice +pause 3000 +presskey global EKeyDevice0 +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title OTG Error Hub not supported device (Otg Error Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbOTGErrorNotifierTests EUsbOtgHubUnsupported +pause 3000 +presskey global EKeyDevice0 +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title OTG Error error in connection (Otg Error Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbOTGErrorNotifierTests EUsbOtgErrorInConnection +pause 3000 +presskey global EKeyDevice0 +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title OTG Attach timed out (Otg Error Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbOTGErrorNotifierTests EUsbOtgErrorAttachTimedOut +pause 3000 +presskey global EKeyDevice0 +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title OTG Partially supported device (Otg Warning Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbOTGWarningNotifierTests EUsbOtgPartiallySupportedDevice +pause 500 +presskey global EKeyDevice0 +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title Load and Unload notifiers +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock LoadNotifiers +pause 500 +tester ExecuteApiTestBlock UnLoadNotifiers +delete tester +[Endtest] + +[Test] +title MSMM error test (MSMM error Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbMSMMNotifierTests EUsbMSMMGeneralError +pause 500 +presskey global EKeyDevice0 +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title MSMM error test (MSMM error Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbMSMMNotifierTests EUsbMSMMUnknownFileSystem +pause 500 +presskey global EKeyDevice0 +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +[Test] +title MSMM error test (MSMM error Notifier Test) +create UsbUiNotifApiTest tester +tester ExecuteApiTestBlock UsbMSMMNotifierTests EUsbMSMMOutOfMemory +pause 500 +presskey global EKeyDevice0 +tester ExecuteApiTestBlock FinishQuery ACCEPT +delete tester +[Endtest] + +// Add new api tests here +// ... + + +// UsbUiNotifApiTest Module Tests (... tc) + +// Add new module tests here +// ... + + +// UsbUiNotifApiTest Branch Tests (... tc) + +// Add new branch tests here +// ... diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/eabi/usbuinotifapitestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/eabi/usbuinotifapitestu.def Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/group/bld.inf Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build file +* +*/ + + + +PRJ_PLATFORMS +DEFAULT + +PRJ_TESTEXPORTS + +PRJ_EXPORTS + +PRJ_TESTMMPFILES +usbuinotifapitest.mmp + +PRJ_MMPFILES + +// End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/group/build_sis_ats.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/group/build_sis_ats.bat Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,22 @@ +@rem +@rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +@rem All rights reserved. +@rem This component and the accompanying materials are made available +@rem under the terms of "Eclipse Public License v1.0" +@rem which accompanies this distribution, and is available +@rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +@rem +@rem Initial Contributors: +@rem Nokia Corporation - initial contribution. +@rem +@rem Contributors: +@rem +@rem Description: Test script config file +@rem +@rem + + +call bldmake bldfiles +call abld test build armv5 +call makesis usbuinotifapitest.pkg +call signsis usbuinotifapitest.sis usbuinotifapitest.sisx x:\rd.cer x:\rd-key.pem diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/group/build_sis_phone.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/group/build_sis_phone.bat Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,24 @@ +@rem +@rem Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +@rem All rights reserved. +@rem This component and the accompanying materials are made available +@rem under the terms of "Eclipse Public License v1.0" +@rem which accompanies this distribution, and is available +@rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +@rem +@rem Initial Contributors: +@rem Nokia Corporation - initial contribution. +@rem +@rem Contributors: +@rem +@rem Description: Test script config file +@rem +@rem + +rd /q /s x:\epoc32\BUILD + +call bldmake bldfiles +call abld test build armv5 +call makesis usbuinotifapitest_phone.pkg +call signsis usbuinotifapitest_phone.sis usbuinotifapitest_phone.sisx x:\rd.cer x:\rd-key.pem +call pause \ No newline at end of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/group/usbuinotifapitest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/group/usbuinotifapitest.mmp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: TYPE TESTSCRIPT +* +*/ + + +#if defined(__S60_) + // To get the OSEXT_LAYER_SYSTEMINCLUDE-definition + #include +#endif + +TARGET usbuinotifapitest.dll +TARGETTYPE dll +UID 0x1000008D 0x101FB3E3 + +CAPABILITY ALL -TCB + +DEFFILE usbuinotifapitest.def + +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../../inc + +SOURCEPATH ../src +SOURCE usbuinotifapitest.cpp +SOURCE usbuinotifapitestblocks.cpp + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY stiftestengine.lib +LIBRARY centralrepository.lib +LIBRARY usbman.lib +LIBRARY usbwatcher.lib +LIBRARY ecom.lib + +LANG SC + +// End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/group/usbuinotifapitest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/group/usbuinotifapitest.pkg Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,62 @@ +; +; Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; + +; Languages +&EN + +; Provide value for uid +#{"STIF"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 5.2 +[0x20022E6D], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"/epoc32/release/armv5/udeb/usbuinotifapitest.dll"-"c:/sys/bin/usbuinotifapitest.dll" + +"../init/usbuinotifapitest.ini"-"e:/testing/init/usbuinotifapitest.ini" +"../conf/ui_usbuinotifapitest.cfg"-"e:/testing/conf/ui_usbuinotifapitest.cfg" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/group/usbuinotifapitest_phone.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/group/usbuinotifapitest_phone.pkg Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,62 @@ +; +; Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; + +; Languages +&EN + +; Provide value for uid +#{"STIF"},(0x00000000),1,1,0,TYPE=SA + +; Series60 product id for S60 5.2 +[0x20022E6D], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia"} + +; Unique Vendor name +:"Nokia" + +; Logo +; None + +; Package signature - Optional +; None + +; Start of Package body + +; Condition blocks +; None + +; Options list +; None + +; Install files +"/epoc32/release/armv5/udeb/usbuinotifapitest.dll"-"c:/sys/bin/usbuinotifapitest.dll" + +"../init/usbuinotifapitest_phone.ini"-"c:/testframework/testframework.ini" +"../conf/ui_usbuinotifapitest.cfg"-"c:/testframework/ui_usbuinotifapitest.cfg" + +; Embedded SIS +; None + +; End of Package body + +; PKG dependencies +; None + +; PKG capabilities +; None diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/inc/usbuinotifapitest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/inc/usbuinotifapitest.h Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,273 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef USBUINOTIFAPITEST_H +#define USBUINOTIFAPITEST_H + +// INCLUDES +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def +#define TEST_CLASS_VERSION_MAJOR 0 +#define TEST_CLASS_VERSION_MINOR 0 +#define TEST_CLASS_VERSION_BUILD 0 + +// Logging path +//_LIT( KUsbUiNotifApiTestLogPath, "\\logs\\testframework\\UsbUiNotifApiTest\\" ); + +// Logging path for ATS - for phone builds comment this line +_LIT( KUsbUiNotifApiTestLogPath, "e:\\testing\\stiflogs\\" ); + +// Log file +_LIT( KUsbUiNotifApiTestLogFile, "UsbUiNotifApiTest.txt" ); +_LIT( KUsbUiNotifApiTestLogFileWithTitle, "UsbUiNotifApiTest_[%S].txt" ); + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; +class CUsbUiNotifApiTest; + +// DATA TYPES +//enum ?declaration + +enum TUsbUiNotifApiTestResult + { + ETestCasePassed, + ETestCaseFailed + }; + +enum TTestOption + { + EQueryDiscarded = 0, + EQueryAccepted, + EQueryCanceled + }; +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +NONSHARABLE_CLASS( TUsbUiNotifApiTestBlockParams ) + { + public: + TPtrC iTestBlockName; + + TPtrC iTestOption1; + TPtrC iTestOption2; + TPtrC iTestOption3; + + TInt iTestIntOption1; + TInt iTestIntOption2; + + TChar iTestCharOption1; + TChar iTestCharOption2; + }; + +/** +* CUsbUiNotifApiTest test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS( CUsbUiNotifApiTest ) : public CScriptBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CUsbUiNotifApiTest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CUsbUiNotifApiTest(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + protected: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + protected: // Functions from base classes + + /** + * From ?base_class ?member_description + */ + //?type ?member_function(); + + private: + + /** + * C++ default constructor. + */ + CUsbUiNotifApiTest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Test methods are listed below. + */ + + virtual TInt ExecuteApiTestBlock( CStifItemParser& aItem ); + virtual TInt ExecuteModuleTestBlock( CStifItemParser& aItem ); + virtual TInt ExecuteBranchTestBlock( CStifItemParser& aItem ); + + + + /** + * Method used to log version of test class + */ + void SendTestClassVersion(); + + //ADD NEW METHOD DEC HERE + //[TestMethods] - Do not remove + + void GetTestBlockParamsL( CStifItemParser& aItem ); + + void DoExecuteApiTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult ); + void DoExecuteModuleTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult ); + void DoExecuteBranchTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult ); + + void ExampleTestL( TPtrC aTestOption, TPtrC aTestSubOption, + TInt aTestIntOption, TInt aTestCharOption, TUsbUiNotifApiTestResult& aTestResult ); + + void CableConnectedNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ); + void ConnectionNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ); + void UsbQueriesNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ); + void UsbOTGErrorNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ); + void UsbOTGWarningNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ); + TInt FinishQuery( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ); + void LoadNotifiersL( TUsbUiNotifApiTestResult& aTestResult ); + void UnLoadNotifiers ( TUsbUiNotifApiTestResult& aTestResult ); + void Update( TUsbUiNotifApiTestResult& aTestResult ); + //void Cancelnotifier( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ); + void Notifierstart( TUsbUiNotifApiTestResult& aTestResult ); + //void AsyncConnectionNotifier ( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ); + void UsbMSMMNotifierTests ( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ); + + TInt GetTestOption( TPtrC aOptionString, TTestOption& aOption ); + TInt GetPersonalityIdFromString( TPtrC aOptionString, TInt& aPersonalityId ); + TInt GetQueryType( TPtrC aTypeString, TUSBUIQueries& aQueryType ); + TInt GetOTGErrorType( TPtrC aTypeString, TUsbUiNotifOtgError& aQueryType ); + TInt GetOTGWarningType( TPtrC aTypeString, TUsbUiNotifOtgWarning& aQueryType ); + TInt GetMSMMrrorType( TPtrC aTypeString, THostMsErrCode& aQueryType ); + + inline void Trace(TRefByValue aFmt, ...); + inline void Trace(TRefByValue aFmt, ...); + + public: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + protected: // Data + // ?one_line_short_description_of_data + //?data_declaration; + + private: // Data + TUsbUiNotifApiTestBlockParams iTestBlockParams; + + RNotifier *iNotifier; + RUsbWatcher* iUsbWatcher; + + CRepository* iRepository; + + TUSBConnectionNotifierParamsPckg iConnectionNotifierResponseParamsPckg; + TRequestStatus iReqStatus; + TInt iPersonalityIdBackup; + TBool iCompleteQuery; + TPckg iRes; + CArrayPtr* iNotifierArray; + TUid iInstanceUid; + THostMsErrData iErrData; + THostMsErrorDataPckg iErrPckg ; + + // Reserved pointer for future extension + //TAny* iReserved; + + public: // Friend classes + //?friend_class_declaration; + protected: // Friend classes + //?friend_class_declaration; + private: // Friend classes + //?friend_class_declaration; + + }; + +#include "UsbUiNotifApiTestDebug.inl" + +#endif // USBUINOTIFAPITEST_H + +// End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/inc/usbuinotifapitestdebug.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/inc/usbuinotifapitestdebug.inl Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include + +NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { +public: + void Overflow(TDes8& /*aDes*/) {} + }; + +NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { +public: + void Overflow(TDes16& /*aDes*/) {} + }; + + +_LIT8(KStifTestPrefix8, "[STIF_LOG] "); +_LIT(KStifTestPrefix, "[STIF_LOG] "); + +const TInt KMaxLogLineLength = 512; + +#define TRACE_INFO(p) { Trace p; } + +void CUsbUiNotifApiTest::Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); + TOverflowTruncate8 overflow; + RBuf8 buf8; + buf8.Create( KMaxLogLineLength ); + buf8.Append( KStifTestPrefix8 ); + buf8.AppendFormatList(aFmt, list, &overflow); + + RBuf16 buf16; + buf16.Create( KMaxLogLineLength ); + buf16.Copy(buf8); + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); + iLog->Log(tmpFmt, &buf16); + buf8.Close(); + buf16.Close(); + }; + +void CUsbUiNotifApiTest::Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); + RBuf16 theFinalString; + theFinalString.Create( KMaxLogLineLength ); + theFinalString.Append( KStifTestPrefix ); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList(aFmt,list,&overflow); + RDebug::Print(theFinalString); + iLog->Log(theFinalString); + theFinalString.Close(); + }; diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/init/usbuinotifapitest.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/init/usbuinotifapitest.ini Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,235 @@ +# +# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# + XML, Test report will be xml type, for example 'TestReport.xml'. +# Note, that xml format is available only when output is set to FILE. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= e:\testing\logs\ +TestReportFileName= UsbUiNotifApiTest_TestReport + +TestReportFormat= TXT # Possible values: TXT, HTML or XML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds +UITestingSupport= YES # Possible values: YES or NO +#SeparateProcesses= YES # Possible values: YES or NO (default: NO) +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= UsbUiNotifApiTestUsbUiNotifApiTestUsbUiNotifApiTest +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= e:\testing\conf\ui_USBUiNotifApiTest.cfg +[End_Module] + + +# Load testmoduleUsbUiNotifApiTest, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleUsbUiNotifApiTest used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleUsbUiNotifApiTest used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO +#AddTestCaseTitle= YES # Possible values: YES or NO +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set filters to be used by ConsoleUI. +# If you want to use filter with ConsoleUI, simply remove comments +# from section below and provide valid filter entries. +# Each filter line has to start with "filter= " keyword. +# Filter can contain special wildcard characters: +# * which stands for none or any literal; +# ? which stands for single character. +# Filters are not case-sensitive. + +#[Filters] +#filter= *math* +#filter= *radio* +#[End_Filters] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/init/usbuinotifapitest_phone.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/init/usbuinotifapitest_phone.ini Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,235 @@ +# +# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# + +# +# This is STIF initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# + XML, Test report will be xml type, for example 'TestReport.xml'. +# Note, that xml format is available only when output is set to FILE. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= c:\logs\testframework\UsbUiNotifApiTest\ +TestReportFileName= testreport + +TestReportFormat= TXT # Possible values: TXT, HTML or XML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +Timeout= 0 # Default timeout value for each test case. In milliseconds +UITestingSupport= YES # Possible values: YES or NO +#SeparateProcesses= YES # Possible values: YES or NO (default: NO) +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= UsbUiNotifApiTestUsbUiNotifApiTestUsbUiNotifApiTest +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= testscripter +TestCaseFile= c:\testframework\ui_UsbUiNotifApiTest.cfg +[End_Module] + + +# Load testmoduleUsbUiNotifApiTest, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleUsbUiNotifApiTest used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleUsbUiNotifApiTest used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIF logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# +# - Will write log file in unicode format. +# + YES, Log file will be written in unicode format +# + NO, Log will be written as normal, not unicode, file. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +#FileUnicode= YES # Possible values: YES or NO +#AddTestCaseTitle= YES # Possible values: YES or NO +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set filters to be used by ConsoleUI. +# If you want to use filter with ConsoleUI, simply remove comments +# from section below and provide valid filter entries. +# Each filter line has to start with "filter= " keyword. +# Filter can contain special wildcard characters: +# * which stands for none or any literal; +# ? which stands for single character. +# Filters are not case-sensitive. + +#[Filters] +#filter= *math* +#filter= *radio* +#[End_Filters] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/src/usbuinotifapitest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/src/usbuinotifapitest.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,207 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +// INCLUDE FILES +#include +#include "UsbUiNotifApiTest.h" +#include + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CUsbUiNotifApiTest::CUsbUiNotifApiTest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CUsbUiNotifApiTest::CUsbUiNotifApiTest( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ), + iRes(0) + { + } + +// ----------------------------------------------------------------------------- +// CUsbUiNotifApiTest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CUsbUiNotifApiTest::ConstructL() + { + //Read logger settings to check whether test case name is to be + //appended to log file name. + RSettingServer settingServer; + TInt ret = settingServer.Connect(); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Struct to StifLogger settigs. + TLoggerSettings loggerSettings; + // Parse StifLogger defaults from STIF initialization file. + ret = settingServer.GetLoggerSettings(loggerSettings); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Close Setting server session + settingServer.Close(); + + TFileName logFileName; + + if(loggerSettings.iAddTestCaseTitle) + { + TName title; + TestModuleIf().GetTestCaseTitleL(title); + logFileName.Format(KUsbUiNotifApiTestLogFileWithTitle, &title); + } + else + { + logFileName.Copy(KUsbUiNotifApiTestLogFile); + } + + iLog = CStifLogger::NewL( KUsbUiNotifApiTestLogPath, + logFileName, + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse ); + + SendTestClassVersion(); + + iNotifier = new ( ELeave ) RNotifier(); + iUsbWatcher = new ( ELeave ) RUsbWatcher(); + iRepository = CRepository::NewL( KCRUidUsbWatcher ); + } + +// ----------------------------------------------------------------------------- +// CUsbUiNotifApiTest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CUsbUiNotifApiTest* CUsbUiNotifApiTest::NewL( + CTestModuleIf& aTestModuleIf ) + { + CUsbUiNotifApiTest* self = new (ELeave) CUsbUiNotifApiTest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +// Destructor +CUsbUiNotifApiTest::~CUsbUiNotifApiTest() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iLog; + + } + +//----------------------------------------------------------------------------- +// CUsbUiNotifApiTest::SendTestClassVersion +// Method used to send version of test class +//----------------------------------------------------------------------------- +// +void CUsbUiNotifApiTest::SendTestClassVersion() + { + TVersion moduleVersion; + moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; + moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; + moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; + + TFileName moduleName; + moduleName = _L("UsbUiNotifApiTest.dll"); + + TBool newVersionOfMethod = ETrue; + TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CScriptBase* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + + return ( CScriptBase* ) CUsbUiNotifApiTest::NewL( aTestModuleIf ); + + } + + +// End of File diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuinotif/tsrc/usbuinotifapitest/src/usbuinotifapitestblocks.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuinotif/tsrc/usbuinotifapitest/src/usbuinotifapitestblocks.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,976 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +// [INCLUDE FILES] - do not remove +#include +#include +#include +#include +#include "UsbUiNotifApiTest.h" + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CUsbUiNotifApiTest::Delete +// Delete here all resources allocated and opened from test methods. +// Called from destructor. +// ----------------------------------------------------------------------------- +// +void CUsbUiNotifApiTest::Delete() + { + iNotifier -> Close(); + delete iNotifier; + iNotifier = NULL; + iUsbWatcher -> Close(); + delete iUsbWatcher; + iUsbWatcher = NULL; + delete iRepository; + iRepository = NULL; + } + +// ----------------------------------------------------------------------------- +// CUsbUiNotifApiTest::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CUsbUiNotifApiTest::RunMethodL( + CStifItemParser& aItem ) + { + + static TStifFunctionInfo const KFunctions[] = + { + //ADD NEW ENTRY HERE + // [test cases entries] - Do not remove + ENTRY( "ExecuteApiTestBlock", CUsbUiNotifApiTest::ExecuteApiTestBlock ), + ENTRY( "ExecuteModuleTestBlock", CUsbUiNotifApiTest::ExecuteModuleTestBlock ), + ENTRY( "ExecuteBranchTestBlock", CUsbUiNotifApiTest::ExecuteBranchTestBlock ), + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + + } + +// ----------------------------------------------------------------------------- +// CUsbUiNotifApiTest::GetTestBlockParamsL +// ----------------------------------------------------------------------------- + +void CUsbUiNotifApiTest::GetTestBlockParamsL( CStifItemParser& aItem ) + { + TRACE_INFO( _L(">>> GetTestBlockParamsL") ); + + // Add new test block branches below, get all required test parameters + if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) ) + { + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) ); + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); + User::LeaveIfError( aItem.GetNextInt( iTestBlockParams.iTestIntOption1 ) ); + User::LeaveIfError( aItem.GetNextChar( iTestBlockParams.iTestCharOption1 ) ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CableConnectedNotifierTest" ) ) ) + { + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) ) + { + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FinishQuery" ) ) ) + { + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGErrorNotifierTests" ) ) ) + { + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGWarningNotifierTests" ) ) ) + { + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "LoadNotifiers" ) ) ) + { + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UnLoadNotifiers" ) ) ) + { + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbMSMMNotifierTests" ) ) ) + { + User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); + } + else + { + TRACE_INFO( _L("GetTestBlockParamsL() Test type: not found") ); + User::Leave( KErrNotFound ); + } + TRACE_INFO( _L("<<< GetTestBlockParamsL") ); + } + +// ----------------------------------------------------------------------------- +// CUsbUiNotifApiTest::ExecuteApiTestBlock +// ----------------------------------------------------------------------------- + +TInt CUsbUiNotifApiTest::ExecuteApiTestBlock( CStifItemParser& aItem ) + { + TRACE_INFO( _L(">>> ExecuteApiTestBlock") ); + + TInt res; + TUsbUiNotifApiTestResult testResult = ETestCaseFailed; + + TRAP( res, DoExecuteApiTestBlockL( aItem, testResult ) ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("DoExecuteApiTestBlockL error: %d"), res) ); + return res; + } + + STIF_ASSERT_EQUALS( ETestCasePassed, testResult ); + TRACE_INFO( _L("Test case passed") ); + + TRACE_INFO( _L("<<< ExecuteApiTestBlock") ); + + return KErrNone; + } + + +void CUsbUiNotifApiTest::DoExecuteApiTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult ) + { + TRACE_INFO( _L(">>>DoExecuteApiTestBlockL") ); + + User::LeaveIfError( aItem.GetString( _L( "ExecuteApiTestBlock" ), iTestBlockParams.iTestBlockName ) ); + TRACE_INFO( (_L("Api test type: %S"), &iTestBlockParams.iTestBlockName) ); + + GetTestBlockParamsL( aItem ); + + // Add new API test block branches with optional test parameters here + if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) ) + { + ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, + iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CableConnectedNotifierTest" ) ) ) + { + CableConnectedNotifierTest( iTestBlockParams.iTestOption2, aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) ) + { + UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FinishQuery" ) ) ) + { + FinishQuery( iTestBlockParams.iTestOption2, aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) ) + { + UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) ) + { + UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) ) + { + UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGErrorNotifierTests" ) ) ) + { + UsbOTGErrorNotifierTests( iTestBlockParams.iTestOption2, aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGWarningNotifierTests" ) ) ) + { + UsbOTGWarningNotifierTests( iTestBlockParams.iTestOption2, aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "LoadNotifiers" ) ) ) + { + LoadNotifiersL( aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UnLoadNotifiers" ) ) ) + { + UnLoadNotifiers( aTestResult ); + } + else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbMSMMNotifierTests" ) ) ) + { + UsbMSMMNotifierTests( iTestBlockParams.iTestOption2, aTestResult ); + } + else + { + TRACE_INFO( _L("DoExecuteApiTestBlockL() Test type: not found") ); + User::Leave( KErrNotFound ); + } + + TRACE_INFO( _L("<<>>ExecuteModuleTestBlock") ); + + TInt res; + TUsbUiNotifApiTestResult testResult; + + TRAP( res, DoExecuteModuleTestBlockL( aItem, testResult ) ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("DoExecuteModuleTestBlockL error: %d"), res) ); + return res; + } + + STIF_ASSERT_EQUALS( ETestCasePassed, testResult ); + TRACE_INFO( _L("Test case passed") ); + TRACE_INFO( _L("<<>>DoExecuteModuleTestBlockL") ); + + User::LeaveIfError( aItem.GetString( _L( "ExecuteModuleTestBlock" ), iTestBlockParams.iTestBlockName ) ); + TRACE_INFO( (_L("Module test type: %S"), &iTestBlockParams.iTestBlockName) ); + + GetTestBlockParamsL( aItem ); + + // Add new module test block branches with optional test parameters here + if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) ) + { + ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, + iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult ); + } + else + { + TRACE_INFO( _L("DoExecuteModuleTestBlockL() Test type: not found") ); + User::Leave( KErrNotFound ); + } + + TRACE_INFO( _L("<<>>ExecuteBranchTestBlock") ); + + TInt res; + TUsbUiNotifApiTestResult testResult; + + TRAP( res, DoExecuteBranchTestBlockL( aItem, testResult ) ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("DoExecuteBranchTestBlockL error: %d"), res) ); + return res; + } + + STIF_ASSERT_EQUALS( ETestCasePassed, testResult ); + TRACE_INFO( _L("Test case passed") ); + TRACE_INFO( _L("<<>>DoExecuteBranchTestBlockL") ); + + User::LeaveIfError( aItem.GetString( _L( "ExecuteBranchTestBlock" ), iTestBlockParams.iTestBlockName ) ); + TRACE_INFO( (_L("Branch test type: %S"), &iTestBlockParams.iTestBlockName) ); + + GetTestBlockParamsL( aItem ); + + // Add new branch test block branches with optional test parameters here + if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) ) + { + ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, + iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult ); + } + else + { + TRACE_INFO( _L("DoExecuteBranchTestBlockL() Test type: not found") ); + User::Leave( KErrNotFound ); + } + + TRACE_INFO( _L("<<>>ExampleTestL") ); + + if ( !aTestOption.Compare( _L( "API" ) ) ) + { + TRACE_INFO( (_L("Api test option: %S"), &aTestOption) ); + TRACE_INFO( (_L("Api test sub-option: %S"), &aTestSubOption) ); + TRACE_INFO( (_L("Api test int option: %d"), aTestIntOption) ); + TRACE_INFO( (_L("Api test char option: %c"), aTestCharOption) ); + } + else if ( !aTestOption.Compare( _L( "MODULE" ) ) ) + { + TRACE_INFO( (_L("Module test option: %S"), &aTestOption) ); + TRACE_INFO( (_L("Module test sub-option: %S"), &aTestSubOption) ); + TRACE_INFO( (_L("Module test int option: %d"), aTestIntOption) ); + TRACE_INFO( (_L("Module test char option: %c"), aTestCharOption) ); + } + else if ( !aTestOption.Compare( _L( "BRANCH" ) ) ) + { + TRACE_INFO( (_L("Branch test option: %S"), &aTestOption) ); + TRACE_INFO( (_L("Branch test sub-option: %S"), &aTestSubOption) ); + TRACE_INFO( (_L("Branch test int option: %d"), aTestIntOption) ); + TRACE_INFO( (_L("Branch test char option: %c"), aTestCharOption) ); + } + else + { + TRACE_INFO( _L("Invalid test parameter") ); + User::Leave( KErrNotFound ); + } + + aTestResult = ETestCasePassed; + + TRACE_INFO( _L("<<>>CableConnectedNotifierTest") ); + + TInt res; + TUSBConnectionNotifierParamsPckg emptyNotifierInputPckg; + TPtrC displayedUsbPersonalityName( KNullDesC ); + TInt displayedUsbPersonalityId; + + res = GetPersonalityIdFromString( aTestSubOption, displayedUsbPersonalityId ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("GetPersonalityIdFromString failed with value: %d"), res) ); + return; + } + + res = iRepository -> Get( KUsbWatcherPersonality, iPersonalityIdBackup ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("Personality backup failed with value (cenrep): %d"), res) ); + return; + } + + res = iUsbWatcher -> Connect(); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("Failed to connect UsbWatcher with value: %d"), res) ); + return; + } + TRACE_INFO( _L("UsbWatcher connected") ); + + iUsbWatcher -> SetPersonality( iReqStatus, displayedUsbPersonalityId, ETrue, ETrue ); + User::WaitForRequest( iReqStatus ); + if ( iReqStatus.Int() != KErrNone ) + { + TRACE_INFO( (_L("Failed to set usb personality with value: %d"), iReqStatus.Int()) ); + iUsbWatcher -> Close(); + return; + } + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); + iUsbWatcher -> Close(); + return; + } + TRACE_INFO( _L("RNotifier connected") ); + + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KCableConnectedNotifierUid, emptyNotifierInputPckg, iConnectionNotifierResponseParamsPckg ); + User::WaitForRequest( iReqStatus ); + + TRACE_INFO((_L("StartNotifierAndGetResponse Status: %d, expected: %d"), iReqStatus.Int(), KErrCancel)); + if(iReqStatus.Int() == KErrCancel) + aTestResult = ETestCasePassed; + + TRACE_INFO( _L("<<>>UsbQueriesNotifierTest") ); + TInt res; + TUSBUIQueries usbQueryType; + + + res = GetQueryType( aTestSubOption, usbQueryType ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("GetQueryType failed with value: %d"), res) ); + return; + } + + TUSBQueriesNotiferParams notifierParams; + notifierParams.iDrive = 'c'; + notifierParams.iQuery = usbQueryType; + TUSBQueriesNotifierParamsPckg notifierParamsPckg( notifierParams ); + TPckgBuf output; + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); + return; + } + TRACE_INFO( _L("RNotifier connected") ); + + switch( usbQueryType ) + { + case EUSBNoMemoryCard: + iCompleteQuery = ETrue; + break; + case EUSBStorageMediaFailure: + case EUSBChangeFromMassStorage: + iCompleteQuery = EFalse; + break; + default: + break; + } + + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KQueriesNotifier, notifierParamsPckg, output ); + + aTestResult = ETestCasePassed; + + TRACE_INFO( _L("<<>>UsbOTGErrorNotifierTests") ); + + TInt res; + TUsbUiNotifOtgError usbOTGErrorType; + + res = GetOTGErrorType( aTestSubOption, usbOTGErrorType ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("usbOTGErrorType failed with value: %d"), res) ); + return; + } + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); + return; + } + TRACE_INFO( _L("RNotifier connected") ); + + TPckgBuf notifierParamsPckg; + notifierParamsPckg() = usbOTGErrorType; + iCompleteQuery = EFalse; + + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgError, notifierParamsPckg, iRes ); + + aTestResult = ETestCasePassed; + + TRACE_INFO( _L("<<>>UsbOTGWarningNotifierTests") ); + + TInt res; + TUsbUiNotifOtgWarning usbOTGWarningType; + + + res = GetOTGWarningType( aTestSubOption, usbOTGWarningType ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("usbOTGErrorType failed with value: %d"), res) ); + return; + } + + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); + return; + } + TRACE_INFO( _L("RNotifier connected") ); + + TPckgBuf notifierParamsPckg; + notifierParamsPckg() = usbOTGWarningType; + iCompleteQuery = EFalse; + + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgWarning, notifierParamsPckg, iRes ); + + aTestResult = ETestCasePassed; + + TRACE_INFO( _L("<<>>UsbMSMMNotifierTests") ); + + TInt res; + THostMsErrCode usbMSMMNErrorType; + + res = GetMSMMrrorType( aTestSubOption, usbMSMMNErrorType ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("MSMMrrorType failed with value: %d"), res) ); + return; + } + iErrData.iError=usbMSMMNErrorType; + iErrPckg = iErrData; + res = iNotifier -> Connect(); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); + return; + } + TRACE_INFO( _L("RNotifier connected") ); + + TPckgBuf notifierParamsPckg; + notifierParamsPckg() = usbMSMMNErrorType; + iCompleteQuery = EFalse; + + iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifMsmmError, iErrPckg, iRes ); + + aTestResult = ETestCasePassed; + + TRACE_INFO( _L("<<>>FinishQuery") ); + + TInt res; + TTestOption option; + + if ( iCompleteQuery ) + { + TRequestStatus* statPtr = &iReqStatus; + User::RequestComplete( statPtr, KErrNone ); + } + + res = GetTestOption( aTestSubOption, option ); + if ( res != KErrNone ) + { + TRACE_INFO( (_L("GetTestOption failed with value: %d"), res) ); + iNotifier -> Close(); + return res; + } + + User::WaitForRequest( iReqStatus ); + iNotifier -> Close(); + + switch( option ) + { + case EQueryAccepted: + TRACE_INFO( (_L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone) ); + STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); + break; + case EQueryCanceled: + TRACE_INFO( (_L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel) ); + STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); + break; + default: + return KErrNotFound; + } + + aTestResult = ETestCasePassed; + + TRACE_INFO( _L("<<>>LoadNotifiersL") ); + + iNotifierArray = reinterpret_cast*>( + REComSession::CreateImplementationL(TUid::Uid(0x10281F23), iInstanceUid)); + + aTestResult = ETestCasePassed; + + TRACE_INFO( _L("<<>>UnLoadNotifiers") ); + + TInt count = iNotifierArray->Count(); + TInt i=0; + for (i=0; iAt(i)->Release(); + } + iNotifierArray->Reset(); + delete iNotifierArray; + REComSession::DestroyedImplementation(iInstanceUid); + + aTestResult = ETestCasePassed; + + TRACE_INFO( _L("<<>>Update") ); + TInt count = iNotifierArray->Count(); + TInt i=0; + _LIT8(test, "test"); + TBuf8<32> buf(test); + for (i=0; iAt(i)->UpdateL(buf); + } + + aTestResult = ETestCasePassed; + + TRACE_INFO( _L("<<>>Notifierstart") ); + TInt count = iNotifierArray->Count(); + TInt i=0; + _LIT8(test, "test"); + TBuf8<32> buf(test); + for (i=0; iAt(i)->StartL(buf); + } + + aTestResult = ETestCasePassed; + + TRACE_INFO( _L("<<>>GetQueryType") ); + if ( !aTypeString.Compare( _L( "EUSBNoMemoryCard" ) ) ) + { + aQueryType = EUSBNoMemoryCard; + TRACE_INFO( _L("Query type: EUSBNoMemoryCard") ); + } + else if ( !aTypeString.Compare( _L( "EUSBStorageMediaFailure" ) ) ) + { + aQueryType = EUSBStorageMediaFailure; + TRACE_INFO( _L("Query type: EUSBStorageMediaFailure") ); + } + else if ( !aTypeString.Compare( _L( "EUSBChangeFromMassStorage" ) ) ) + { + aQueryType = EUSBChangeFromMassStorage; + TRACE_INFO( _L("Query type: EUSBChangeFromMassStorage") ); + } + else + { + TRACE_INFO( _L("Query type: not supported") ); + return KErrNotFound; + } + TRACE_INFO( _L("<<>>GetOTGErrorType") ); + + if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPower" ) ) ) + { + aQueryType = EUsbOtgTooMuchPower; + TRACE_INFO( _L("Query type: EUsbOtgTooMuchPower") ); + } + else if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPowerRequired" ) ) ) + { + aQueryType = EUsbOtgTooMuchPowerRequired; + TRACE_INFO( _L("Query type: EUsbOtgTooMuchPowerRequired") ); + } + else if ( !aTypeString.Compare( _L( "EUsbOtgUnsupportedDevice" ) ) ) + { + aQueryType = EUsbOtgUnsupportedDevice; + TRACE_INFO( _L("Query type: EUsbOtgUnsupportedDevice") ); + } + else if ( !aTypeString.Compare( _L( "EUsbOtgHubUnsupported" ) ) ) + { + aQueryType = EUsbOtgHubUnsupported; + TRACE_INFO( _L("Query type: EUsbOtgHubUnsupported") ); + } + else if ( !aTypeString.Compare( _L( "EUsbOtgErrorInConnection" ) ) ) + { + aQueryType = EUsbOtgErrorInConnection; + TRACE_INFO( _L("Query type: EUsbOtgErrorInConnection") ); + } + else if ( !aTypeString.Compare( _L( "EUsbOtgErrorAttachTimedOut" ) ) ) + { + aQueryType = EUsbOtgErrorAttachTimedOut; + TRACE_INFO( _L("Query type: EUsbOtgErrorAttachTimedOut") ); + } + else + { + TRACE_INFO( _L("Query type: not supported") ); + return KErrNotFound; + } + + TRACE_INFO( _L("<<>>GetOTGWarningType") ); + + if ( !aTypeString.Compare( _L( "EUsbOtgPartiallySupportedDevice" ) ) ) + { + aQueryType = EUsbOtgPartiallySupportedDevice; + TRACE_INFO( _L("Query type: EUsbOtgPartiallySupportedDevice;") ); + } + else + { + TRACE_INFO( _L("Query type: not supported") ); + return KErrNotFound; + } + + TRACE_INFO( _L("<<>>GetMSMMrrorType") ); + if ( !aTypeString.Compare( _L( "EUsbMSMMGeneralError" ) ) ) + { + aQueryType = EHostMsErrGeneral; + TRACE_INFO( _L("Query type: EUsbOtgPartiallySupportedDevice;") ); + } + else if ( !aTypeString.Compare( _L( "EUsbMSMMUnknownFileSystem" ) ) ) + { + aQueryType = EHostMsErrUnknownFileSystem; + TRACE_INFO( _L("Query type: EUsbMSMMUnknownFileSystem") ); + } + else if ( !aTypeString.Compare( _L( "EUsbMSMMOutOfMemory" ) ) ) + { + aQueryType = EHostMsErrOutOfMemory; + TRACE_INFO( _L("Query type: EUsbMSMMOutOfMemory") ); + } + else + { + TRACE_INFO( _L("Query type: not supported") ); + return KErrNotFound; + } + + TRACE_INFO( _L("<< + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/icons/usb_icon_mode_4.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/icons/usb_icon_mode_4.svg Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/icons/usb_icon_mode_5.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/icons/usb_icon_mode_5.svg Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/inc/mydebug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/inc/mydebug.h Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef MYDEBUG_H +#define MYDEBUG_H + +#include + +#if defined(_DEBUG) + inline QDebug myDebug() + { + return qDebug(); + } +#else + inline QNoDebug myDebug() + { + return QNoDebug(); + } +#endif + + +#endif // MYDEBUG_H diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/inc/usbmainview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/inc/usbmainview.h Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef USBMAINVIEW_H +#define USBMAINVIEW_H + +#include +#include + +class UsbUiSettingModel; +class QGraphicsLinearLayout; +class HbListWidgetItem; +class HbListWidget; +class HbTextEdit; +class HbRadioButtonList; + +class UsbMainView : public HbView +{ + Q_OBJECT + friend class TestUsbUiModelActive; + +public: + explicit UsbMainView( QObject *parent = 0 ); + virtual ~UsbMainView(); + +public slots: + /** + * Update view item(s) between the selected rows. + * @param topLeft The top row index + * @param bottomRight The bottom row index + */ + void updateSettingItems(const QModelIndex &topLeft, const QModelIndex &bottomRight); + + /* + * Set the personality user has selected in the radio button list + * @param personalityIndex The selection index in the radio button list + */ + void setPersonality( int personalityIndex ); + +signals: + +private: + /* + * creates the main view window row by row + */ + void createMainView(); + /* + * creates the first row in the view containing an icon and a mode name + * @param localPropertiesGroup main view layout + */ + void createIconNameRow(QGraphicsLinearLayout *localPropertiesGroup); + /* + * creates the second row from the view containing the description of the selected mode + * @param localPropertiesGroup main view layout + */ + void createDescriptionArea(QGraphicsLinearLayout *localPropertiesGroup); + /* + * creates the third row from the view containing the radio button list of the existing usb modes + * @param localPropertiesGroup main view layout + */ + void createRadioButtonArea(QGraphicsLinearLayout *localPropertiesGroup); + +private: + // main view layout owned by this class + QGraphicsLinearLayout *mMainLayout; + // setting model not owned by the view, + // has to be deleted + UsbUiSettingModel *mModel; + //owned by the view + HbListWidgetItem *mListItem; + // owned by the view + HbListWidget *mlist; + // owned by the view + HbTextEdit *mlabel; + // owned by the view + HbRadioButtonList *mradio; + // not owned by the view + // need to be deleted + HbIcon *mIcon ; +}; + +#endif /* USBMAINVIEW_H */ diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/inc/usbuimodelactive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/inc/usbuimodelactive.h Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef USBUIMODELACTIVE_H +#define USBUIMODELACTIVE_H + +#include +#include +#include + +class UsbUiModelActivePrivate; + +/*! + \class UsbUiModelActive + \brief Helper class for using active objects in Qt classes. + + UsbUiModelActive is a helper class for using active objects + from any Qt class. It wraps a CActive-derived class in an interface + that uses Qt's signal-slot mechanism for communicating status changes + of the active object. + + */ +class UsbUiModelActive : public QObject +{ + Q_OBJECT + friend class UsbUiModelActivePrivate; + +public: + explicit UsbUiModelActive( int priority = CActive::EPriorityStandard, + QObject *parent = NULL ); + ~UsbUiModelActive(); + + inline TRequestStatus &RequestStatus(); + inline void SetActive(); + inline void Cancel(); + inline bool IsActive(); + +public: + int SetUsbPersonality(int personality); + void CancelSetPersonality(); + +signals: + void requestCompleted( int status ); + +private: + /*! + * emits a signal when the request is completed + * @param status is the error + */ + void emitRequestCompleted( int status ); + +private: + UsbUiModelActivePrivate *d; + + /** Handle to USBWatcher for setting the personality */ + RUsbWatcher iUsbWatcher; +}; + + +/*! + \class UsbUiModelActivePrivate + \brief Private class of UsbUiModelActive, for using active objects in Qt classes. + + UsbUiModelActivePrivate is a helper class for using active objects + from any Qt class. It derives from CActive and allows other classes to use + it for passing to asynchronous function calls through its RequestStatus method. + + */ +class UsbUiModelActivePrivate : public CActive +{ + friend class UsbUiModelActive; + +public: + explicit UsbUiModelActivePrivate( UsbUiModelActive *parent, int priority ); + ~UsbUiModelActivePrivate(); + +private: + virtual void RunL(); + virtual void DoCancel(); + virtual TInt RunError( TInt aError ); + +private: + UsbUiModelActive *q; + +}; + +inline bool UsbUiModelActive::IsActive() +{ + return d->IsActive(); +} + +inline TRequestStatus &UsbUiModelActive::RequestStatus() +{ + return d->iStatus; +} + +inline void UsbUiModelActive::SetActive() +{ + d->SetActive(); +} + +inline void UsbUiModelActive::Cancel() +{ + d->Cancel(); +} + +#endif /* USBUIMODELACTIVE_H */ diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/inc/usbuisettingmodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/inc/usbuisettingmodel.h Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,168 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef USBUISETTINGMODEL_H +#define USBUISETTINGMODEL_H + + +#include +#include +#include +#include +#include + +const int KDefaultColumn = 0; +typedef QList< QMap< int, QVariant > > UsbUiModelDataSource; + +class RUsb; +class UsbUiModelActive; + +class UsbUiSettingModel : public QAbstractItemModel +{ + Q_OBJECT + friend class TestUsbUiModelActive; + +public: +enum usbSettingsIndex { + DefaultMode, + Description, + UsbModeList, + EndOfSettings + }; +enum SettingsRoleValues { + SettingType = Qt::UserRole, + SettingsModeNameList, + }; +public: + UsbUiSettingModel( QObject *parent = 0 ); + virtual ~UsbUiSettingModel(); + + /* + * Returns the index of the item in the model specified by the given row, column and parent index. + * @param row is the row number of the specified item + * @param column is the column number of the specified item + * @param parent QModelIndex parent + */ + virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const; + /* + * Returns QModelIndex() because this model item has no parent + * @param child is the index of item model, the parent of which is going to be returned + * @param child is not used in here + */ + virtual QModelIndex parent( const QModelIndex &child ) const; + /* + * Returns the number of rows under the given parent + * @param parent QModelIndex parent + */ + virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; + /* + * Returns the number of columns for the children of the given parent. + * @param parent QModelIndex parent + */ + virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; + /* + *Returns the data stored under the given role for the item referred to by the index. + */ + virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; + /* + * Sets the role data for the item at index to value. Returns true if successful; otherwise returns false. + */ + virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ); + + const QModelIndex* sourceData() const; + +public slots: + /* + * Provides notification of changes in selected usb mode + * @param key is not used + * @param value is the value read from cenrep key + */ + void usbModeChanged( const XQSettingsKey &key, const QVariant &value ); + /* + * it checks the response from usbwatcher to see if the new mode change has been successful + * it will go back to the previous personality if it has not been successfull + * @param status is the error code returned from usbwatcher + */ + void setPersonalityCompleted (int status ); + +private: + /* + * creats the logical name of the modename string for the list + * @param modeId is the usb personality id + */ + QString modeListName( int modeId ); + /* + * Get the current USB personality ID + * Returns 0, if the key is missing or the value cannot be converted + * to integer. + * @return The current personality id + */ + int currentMode(); + /* + * sets the value to different roles of the model's first row + */ + void setDefaultModeSetting(); + /* + * sets the value to different roles of the model's description row + */ + void setDescriptionSetting(); + /** + * Set the USB mode list and the current selection in the list. + * The personality IDs are stored to mPersonalityIds and the personality names + * to mSettingsList. + * @param modeId The current mode ID + */ + bool setUsbModelistSetting( int modeId ); + /** + * calls the model's set functions + * @param modeId The current mode ID + */ + void setUsbSettings( int modeId ); + /** + * updates the model rows and emits signal datachanged + * @param newPersonality is the new personality id + */ + void setNewUsbMode(int newPersonality); + + /** + * Check from the USB Manager if the USB personality is hidden. + * @param usbman Already opened USB Manager session + * @param personalityId The ID of the personality to be checked. + * @return For hidden personality, true is returned. + */ + bool isPersonalityHidden(RUsb &usbman, TInt personalityId); + + /** + * Check if the USB personality is hidden. + * The personality is hidden, if it does not exist in mPersonalityIds. + * @param personalityId The ID of the personality to be checked. + * @return For hidden personality, true is returned. + */ + bool isPersonalityHidden(TInt personalityId); + private: + + UsbUiModelDataSource mSettingsList; + int mCurrentMode; + // stored, so that we can show the correct personality when it fails to set the new one + int mPreviousMode; + + XQSettingsManager mSettingsManager; + QList mPersonalityIds; + UsbUiModelActive *mModelActive; +}; + +#endif // USBUISETTINGMODEL_H diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/inc/usbviewmanager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/inc/usbviewmanager.h Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef USBVIEWMANAGER_H +#define USBVIEWMANAGER_H + +#include "usbmainview.h" + + +class HbMainWindow; + +class UsbViewManager : public QObject + { + Q_OBJECT + +public: + explicit UsbViewManager(HbMainWindow* mainWindow, QObject *parent = 0 ); + ~UsbViewManager(); + + void addView(); + +private: + HbMainWindow* mWindow; + UsbMainView* mMainView; // owned + + }; + + +#endif /* USBVIEWMANAGER_H */ diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/rom/usbsettings.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/rom/usbsettings.iby Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef USBSETTING_IBY +#define USBSETTING_IBY +// Use standard macros +#include + +file=/epoc32/release/armv5/urel/usbapplication.exe PROGRAMS_DIR/usbapplication.exe +data=/epoc32/data/z/private/10003a3f/import/apps/usbapplication_reg.rsc /private/10003a3f/import/apps/usbapplication_reg.rsc + +#endif diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/rom/usbsettingsresources.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/rom/usbsettingsresources.iby Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef USBSETTINGRESOURCES_IBY +#define USBSETTINGRESOURCES_IBY +// Use standard macros +#include + +data=/epoc32/data/z/resource/apps/usbapplication.rsc APP_RESOURCE_DIR/usbapplication.rsc + +#endif diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/src/main.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include +#include +#include +#include "usbviewmanager.h" + +int main(int argc, char *argv[]) +{ + HbApplication app(argc, argv); + + // add translator for application library + QString locale = QLocale::system().name(); + QTranslator translator; + QString filename = QString("usbapplication_") + locale; +#ifdef Q_OS_SYMBIAN + // TRAP is must here, otherwise it crashes +TRAP_IGNORE( + bool loaded(false); + loaded = translator.load( filename, QString("z:/resource/qt/translations") ); + if (!loaded) + translator.load(filename, QString("c:/resource/qt/translations") ); +); +#else + translator.load(filename, QString("resource") ); +#endif //Q_OS_SYMBIAN + app.installTranslator(&translator); + + HbMainWindow mainWindow; + + // create the view manager, which handles 3 HbViews and add into mainWindow. + UsbViewManager* mViewManager = new UsbViewManager( &mainWindow, &app ); + mViewManager->addView(); + + mainWindow.show(); + return app.exec(); +} diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/src/usbapplication.qm Binary file usbuis/usbuiqt/src/usbapplication.qm has changed diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/src/usbapplication.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/src/usbapplication.qrc Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,6 @@ + + + + usbview.docml + + diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/src/usbapplication.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/src/usbapplication.ts Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,126 @@ + + + + + + Description for USB Ovi Suite personality. This gives user help about the selected personality. + Manage your phone with Ovi Suite and sync your media content. + Manage your phone with Ovi Suite and sync your media content. + + Text ID + description + Te + False + + + USB mode name for Ovi Suite personality. This is used in USB application in a radio button list. Note that this string should use exactly the same words as txt_usb_modename_5. + Ovi Suite + Ovi Suite + + Comment + modelistname + Co + False + + + USB mode name for Mass storage personality. This is used in USB application in a radio button list. Note that this string should use exactly the same words as txt_usb_modename_2. + Mass storage + Mass storage + + Layout ID + modelistname + La + False + + + USB mode name for Mass storage personality. This is used in USB application as the default (selected) mode. + Mass storage + Mass storage + + View ID (draft) + modename + Vi + False + + + USB mode name for Phone as modem personality. This is used in USB application in a radio button list. Note that this string should use exactly the same words as txt_usb_modename_6. + Connect PC to Web + Connect PC to Web + + + modelistname + + False + + + Description for USB Mass storage personality. This gives user help about the selected personality. + Access your phoneÂ’s memory card from the device you are connected to. + Access your phoneÂ’s memory card from the device you are connected to. + + Position ID + description + Po + False + + + USB mode name for MTP personality. This is used in USB application in a radio button list. Note that this string should use exactly the same words as txt_usb_modename_4. + Media transfer + Media transfer + + + modelistname + + False + + + USB mode name for Ovi Suite personality. This is used in USB application as the default (selected) mode. + Ovi Suite + Ovi Suite + + File name + modename + Fi + False + + + Description for USB Phone as Modem personality. This gives user help about the selected personality. + Use your mobile phone as a modem + Use your mobile phone as a modem + + + description + + False + + + Description for USB MTP personality. This gives user help about the selected personality. + Sync your media content with Windows Media Player or Nokia Ovi Player, or connect to compatible stereos. + Sync your media content with Windows Media Player or Nokia Ovi Player, or connect to compatible stereos. + + + description + + False + + + USB mode name for Phone as Modem personality. This is used in USB application as the default (selected) mode. + Connect PC to Web + Connect PC to Web + + + modename + + False + + + USB mode name for MTP personality. This is used in USB application as the default (selected) mode. + Media transfer + Media transfer + + + modename + + False + + + diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/src/usbapplication.xls Binary file usbuis/usbuiqt/src/usbapplication.xls has changed diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/src/usbapplication_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/src/usbapplication_reg.rss Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,18 @@ +// ============================================================================ +// * Generated by qmake (2.01a) (Qt 4.6.0) on: 2009-12-16T13:39:42 +// * This file is generated by qmake and should not be modified by the +// * user. +// ============================================================================ + +#include +#include + +UID2 KUidAppRegistrationResourceFile +UID3 0xECD2B4FE + +RESOURCE APP_REGISTRATION_INFO + { + app_file="usbapplication"; + localisable_resource_file="\\resource\\apps\\usbapplication"; + + } diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/src/usbicons.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/src/usbicons.qrc Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,7 @@ + + + ../icons/usb_icon_mode_2.svg + ../icons/usb_icon_mode_4.svg + ../icons/usb_icon_mode_5.svg + + diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/src/usbmainview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/src/usbmainview.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,180 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "usbmainview.h" +#include +#include +#include +#include +#include +#include + +#include "usbuisettingmodel.h" +#include "mydebug.h" +/*! + * default constructor + */ +UsbMainView::UsbMainView( QObject *parent ) +: HbView(), mModel(NULL) +{ + myDebug() << ">>> UsbMainView::UsbMainView"; + setParent( parent ); + setTitle( qtTrId("USB") ); + mMainLayout = new QGraphicsLinearLayout( Qt::Vertical, this ); + mModel = new UsbUiSettingModel(); + createMainView(); + setLayout( mMainLayout ); + myDebug() << "<<< UsbMainView::UsbMainView"; +} + +/*! + * creates the main view + */ +void UsbMainView::createMainView() +{ + myDebug() << ">>> UsbMainView::createMainView"; + QGraphicsLinearLayout *mainViewLayout = new QGraphicsLinearLayout( Qt::Vertical, mMainLayout ); + mListItem = NULL; + mlist = NULL; + mlabel = NULL; + mradio = NULL; + mIcon = NULL; + createIconNameRow( mainViewLayout ); + createDescriptionArea( mainViewLayout ); + createRadioButtonArea( mainViewLayout ); + mMainLayout->addItem( mainViewLayout ); + bool connected = connect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), + this, SLOT( updateSettingItems( QModelIndex, QModelIndex ) ) ); + myDebug() << "<<< UsbMainView::createMainView model connected=" << connected; + connected = connect(mradio, SIGNAL( itemSelected( int ) ), + this, SLOT( setPersonality( int ) ) ); + myDebug() << "<<< UsbMainView::createMainView mradio connected=" << connected; + myDebug() << "<<< UsbMainView::createMainView"; +} +/*! + * creating the creates the first row in the view containing an icon and a mode name + */ +void UsbMainView::createIconNameRow( QGraphicsLinearLayout *aLocalPropertiesGroup ) +{ + myDebug() << ">>> UsbMainView::createIconNameRow"; + QGraphicsLinearLayout *listLayout = new QGraphicsLinearLayout( Qt::Vertical, mMainLayout ); + mlist = new HbListWidget( this ); + mlist->setMaximumSize( 300, 50 ); //todo + mListItem= new HbListWidgetItem(); + QModelIndex index = mModel->index( UsbUiSettingModel::DefaultMode, KDefaultColumn ); + // QVariant iconName = mModel->data( index, Qt::DecorationRole ); + mIcon = new HbIcon( mModel->data( index, Qt::DecorationRole ).toString() ); + mListItem->setDecorationIcon( *mIcon ); + mListItem->setText( mModel->data( index,Qt::DisplayRole ).toString() ); + mListItem->setText( mModel->data( index,Qt::DisplayRole ).toString() ); + mlist->insertItem( 1, mListItem ); + listLayout->addItem( mlist ); + aLocalPropertiesGroup->addItem( listLayout ); + myDebug() << "<<< UsbMainView::createIconNameRow"; +} +/*! + * creates the second row from the view containing the description of the selected mode + */ +void UsbMainView::createDescriptionArea( QGraphicsLinearLayout *aLocalPropertiesGroup ) +{ + myDebug() << ">>> UsbMainView::createDescriptionArea"; + QGraphicsLinearLayout *desLayout = new QGraphicsLinearLayout( Qt::Vertical, mMainLayout ); + QModelIndex index = mModel->index( UsbUiSettingModel::Description, KDefaultColumn ); + mlabel = new HbTextEdit( mModel->data( index, Qt::DisplayRole ).toString() ); + mlabel->setReadOnly( true ); + mlabel->setCursorVisibility( Hb::TextCursorHidden ); + desLayout->addItem( mlabel ); + desLayout->setAlignment( mlabel, Qt::AlignTop ); + aLocalPropertiesGroup->addItem( desLayout ); + myDebug() << "<<< UsbMainView::createDescriptionArea"; +} + +/*! + * creates the third row from the view containing the radio button list of the existing usb modes + */ +void UsbMainView::createRadioButtonArea(QGraphicsLinearLayout *aLocalPropertiesGroup) +{ + myDebug() << ">>> UsbMainView::createRadioButtonArea"; + QGraphicsLinearLayout *radioLayout = new QGraphicsLinearLayout( Qt::Vertical, mMainLayout ); + QModelIndex index = mModel->index( UsbUiSettingModel::UsbModeList, KDefaultColumn ); + QStringList radioList = mModel->data( index, UsbUiSettingModel::SettingsModeNameList ).toStringList(); + int selectedIndex = mModel->data( index, Qt::EditRole ).toInt(); + mradio = new HbRadioButtonList( radioList, selectedIndex ); + radioLayout->addItem( mradio ); + radioLayout->setAlignment( mradio, Qt::AlignBottom ); + aLocalPropertiesGroup->addItem(radioLayout); + myDebug() << "<<< UsbMainView::createRadioButtonArea"; +} + +/*! + Slot for receiving notification of data changes from the model. + Identify the setting changed and update the corresponding UI item. + */ +void UsbMainView::updateSettingItems(const QModelIndex &topLeft, const QModelIndex &bottomRight) +{ + myDebug() << ">>> UsbMainView::updateSettingItems"; + // update only the part of the view specified by the model row(s) + for ( int row = topLeft.row(); row <= bottomRight.row(); row++ ) { + myDebug() << " UsbMainView::updateSettingItems row=" << row; + QModelIndex index = mModel->index( row, KDefaultColumn ); + // Distinguish which setting value is changed. + switch ( row ) { + case UsbUiSettingModel::DefaultMode : + // set the selected personality icon and name + mIcon->setIconName( mModel->data( index, Qt::DecorationRole ).toString() ); + mListItem->setDecorationIcon( *mIcon ); + mListItem->setText( mModel->data( index,Qt::DisplayRole ).toString() ); + break; + case UsbUiSettingModel::Description : + // set the description of the selected personality. + mlabel->setPlainText( mModel->data( index, Qt::DisplayRole ).toString() ); + mlabel->setReadOnly( true ); + mlabel->setCursorVisibility( Hb::TextCursorHidden ); + break; + case UsbUiSettingModel::UsbModeList : + // only the selection can change, no changes in the list of personalities + mradio->setSelected( mModel->data( index, Qt::EditRole ).toInt() ); + break; + default : + myDebug() << " UsbMainView::updateSettingItems unknown row " << row; + break; + } + } + myDebug() << "<<< UsbMainView::updateSettingItems"; +} + +/* + * Slot for receiving notification from the change in radio button list + */ +void UsbMainView::setPersonality( int personalityIndex ) +{ + myDebug() << ">>> UsbMainView::setPersonality"; + QModelIndex index = mModel->index( UsbUiSettingModel::UsbModeList, KDefaultColumn ); + mModel->setData( index, personalityIndex, Qt::EditRole ); + myDebug() << "<<< UsbMainView::setPersonality"; +} + +/*! + * Destructor + * destructs the items which are not owned by this class + */ +UsbMainView::~UsbMainView() +{ + myDebug() << ">>> UsbMainView::~UsbMainView"; + delete mModel; + delete mIcon; + myDebug() << "<<< UsbMainView::~UsbMainView"; +} diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/src/usbuimodelactive.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/src/usbuimodelactive.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,136 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "usbuimodelactive.h" +#include "mydebug.h" + +//const ?type ?constant_var = ?constant; + + +/*! + Constructor. + */ +UsbUiModelActive::UsbUiModelActive( int priority, QObject *parent ) +: QObject( parent ) +{ + myDebug() << ">>> UsbUiModelActive::UsbUiModelActive"; + d = new UsbUiModelActivePrivate( this, priority ); + int err= iUsbWatcher.Connect(); + myDebug() << "iUsbWatcher.Connect() returned "; + myDebug() << err; + myDebug() << "<<< UsbUiModelActive::UsbUiModelActive"; +} + +/*! + Destructor. + */ +UsbUiModelActive::~UsbUiModelActive() +{ + myDebug() << ">>> UsbUiModelActive::~UsbUiModelActive"; + delete d; + iUsbWatcher.Close(); + myDebug() << "<<< UsbUiModelActive::~UsbUiModelActive"; +} +/*! + * emits a signal when the request is completed + */ +void UsbUiModelActive::emitRequestCompleted( int status ) +{ + myDebug() << ">>> UsbUiModelActive::emitRequestCompleted status: "; + myDebug() << status; + emit requestCompleted( status ); + myDebug() << "<<< UsbUiModelActive::emitRequestCompleted"; +} + +/*! + * UsbUiModelActive::SetUSBModeL + * Sets the Central Repository key to the parameter. + */ +int UsbUiModelActive::SetUsbPersonality(int personality) + { + myDebug() << ">>> UsbUiModelActive::SetUsbPersonality"; + myDebug() << "requested personality is "; + myDebug() << personality; + // Change the personality asynchrously, result checked in RunL() + if( IsActive() ) + { + Cancel(); + } + myDebug() << "setting new personality"; + iUsbWatcher.SetPersonality(RequestStatus(), personality); + SetActive(); + myDebug() << "<<< UsbUiModelActive::SetUsbPersonality, returns 0"; + return 0; + } +/*! + * cancles the personality set in usbwatcher + */ +void UsbUiModelActive::CancelSetPersonality() + { + iUsbWatcher.CancelSetPersonality(); + } + +/*! + Constructor. + */ +UsbUiModelActivePrivate::UsbUiModelActivePrivate( + UsbUiModelActive *parent, int priority ) +: CActive( (TInt) priority ), q( parent ) +{ + myDebug() << ">>> UsbUiModelActivePrivate::UsbUiModelActivePrivate"; + CActiveScheduler::Add( this ); + myDebug() << "<<< UsbUiModelActivePrivate::UsbUiModelActivePrivate"; +} + + +/*! + Destructor. + */ +UsbUiModelActivePrivate::~UsbUiModelActivePrivate() +{ + Cancel(); +} + + +/*! + * Called by the active scheduler when the request has been completed. + */ +void UsbUiModelActivePrivate::RunL() +{ + myDebug() << ">>> UsbUiModelActivePrivate::RunL"; + q->emitRequestCompleted( iStatus.Int() ); + myDebug() << "<<< UsbUiModelActivePrivate::RunL"; +} + + +/*! + Called by the active scheduler when the request has been cancelled. + */ +void UsbUiModelActivePrivate::DoCancel() +{ + q->CancelSetPersonality(); +} + + +/*! + Called by the active scheduler when an error in RunL has occurred. + */ +TInt UsbUiModelActivePrivate::RunError( TInt aError ) +{ + q->emitRequestCompleted( aError ); + return KErrNone; +} diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/src/usbuisettingmodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/src/usbuisettingmodel.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,362 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "usbuisettingmodel.h" +#include "usbuimodelactive.h" +#include "mydebug.h" +#include +#include +#include +#include + +const QString TextIdPrefix = ("txt_usb_"); +const QString ModeIconNamePrefix = (":/icons/usb_icon_mode_"); + +/*! + Constructor. + */ +UsbUiSettingModel::UsbUiSettingModel( QObject *parent ) + : QAbstractItemModel( parent ) +{ + mModelActive = new UsbUiModelActive(); + + for ( int i = 0; i < UsbUiSettingModel::EndOfSettings; i++ ) { + // Initialize the list with empty values. + mSettingsList.append( QMap< int, QVariant >() ); + } + + mCurrentMode = currentMode(); + mPreviousMode = mCurrentMode; + setUsbSettings(mCurrentMode); + bool ret = mSettingsManager.startMonitoring( + XQSettingsKey( XQSettingsKey::TargetCentralRepository, + KCRUidUsbWatcher.iUid, KUsbWatcherPersonality ) ); + myDebug() << ">>> UsbUiSettingModel::startMonitoring value=" + << ret; + + // signal: personality changed in the central repository + connect( &mSettingsManager, + SIGNAL( valueChanged( const XQSettingsKey&, const QVariant& ) ), + this, + SLOT( usbModeChanged( const XQSettingsKey&, const QVariant& ) ) ); + + // signal: response from usbwatcher to our attempt to set the personality + connect( mModelActive, + SIGNAL( requestCompleted( int status ) ), + this, + SLOT( setPersonalityCompleted (int status ))); + +} +/*! + * calls the model's set functions to initialize the model's data + */ +void UsbUiSettingModel::setUsbSettings( int aModeId ) + { + setUsbModelistSetting( aModeId ); + setDefaultModeSetting(); + setDescriptionSetting(); + } + +/*! + Destructor. + */ +UsbUiSettingModel::~UsbUiSettingModel() +{ + myDebug() << ">>> UsbUiSettingModel::~UsbUiSettingModel"; + mSettingsManager.stopMonitoring( + XQSettingsKey( XQSettingsKey::TargetCentralRepository, + KCRUidUsbWatcher.iUid, KUsbWatcherPersonality ) ); + delete mModelActive; + myDebug() << "<<< UsbUiSettingModel::~UsbUiSettingModel"; +} + +/*! + Provides notification of changes in selected usb mode + */ +void UsbUiSettingModel::usbModeChanged( const XQSettingsKey &key, + const QVariant &value ) +{ +Q_UNUSED(key); + myDebug() << ">>> UsbUiSettingModel::usbModeChanged"; + // key is not checked, as we monitor only one key + + setNewUsbMode(value.toInt()); + + myDebug() << "<<< UsbUiSettingModel::usbModeChanged"; +} +/*! + * updates the model rows and emits signal datachanged + */ +void UsbUiSettingModel::setNewUsbMode(int newPersonality) + + { + myDebug() << ">>> UsbUiSettingModel::setNewUsbMode value=" + << newPersonality; + + mCurrentMode = newPersonality; + setUsbSettings(mCurrentMode); + + emit dataChanged( createIndex( DefaultMode, KDefaultColumn ), + createIndex( UsbModeList, KDefaultColumn ) ); + + myDebug() << "<<< UsbUiSettingModel::setNewUsbMode"; + } +/*! + * Returns the index of the item in the model specified by the given row, column and parent index. + */ +QModelIndex UsbUiSettingModel::index( int row, int column, const QModelIndex &parent ) const +{ + return hasIndex( row, column, parent ) ? createIndex( row, column ) : QModelIndex(); +} + + +/* + This model does not support hierarchy, so this returns an empty model index. + */ +QModelIndex UsbUiSettingModel::parent( const QModelIndex &child ) const +{ + Q_UNUSED( child ); + return QModelIndex(); +} +/*! + * Returns the number of rows under the given parent + */ +int UsbUiSettingModel::rowCount( const QModelIndex &parent ) const +{ + Q_UNUSED( parent ); + return mSettingsList.count(); +} + + +/*! + * Returns the number of columns for the children of the given parent. + * This model is one-dimensional, so this returns 1. + */ +int UsbUiSettingModel::columnCount( const QModelIndex &parent ) const +{ + Q_UNUSED( parent ); + return 1; +} +/*! + * Returns the data stored under the given role for the item referred to by the index. + */ +QVariant UsbUiSettingModel::data( const QModelIndex &index, int role ) const +{ + return mSettingsList.value( index.row() ).value( role ); +} + + +/*! + * This is called when usb mode is changed, it only sets the personality when the given role is EditRole + */ +bool UsbUiSettingModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + myDebug() << ">>> UsbUiSettingModel::setData"; + bool success = false; + if ( role == Qt::EditRole ) { + // Only allow changes on the value with role EditRole. Others are managed here. + switch ( index.row() ) { + case UsbModeList: { + mModelActive->SetUsbPersonality( mPersonalityIds.at( value.toInt() ) ); + success = true; + // also update the rest of the model with the about to be selected mode right away + setNewUsbMode(mPersonalityIds.at( value.toInt() )); + break; + } + case DefaultMode: + //no break + case Description: + //no break + default: + myDebug() << " UsbUiSettingModel::setData not supported row " << index.row(); + break; + } + } + myDebug() << "<<< UsbUiSettingModel::setData return " << success; + return success; +} + +/*! + * Getter for the source data. + */ +const QModelIndex* UsbUiSettingModel::sourceData() const +{ + return new QModelIndex( createIndex( 0, 0 ) ); +} + +/*! + * creats the logical name of the modename string for the list + */ +QString UsbUiSettingModel::modeListName( int modeId ) +{ + QString textId = TextIdPrefix + "modelistname_" + QString::number( modeId ); + QString modeName = qtTrId( textId.toAscii() ); + return modeName; +} + +/*! + * Get the current USB mode (personality) ID + */ +int UsbUiSettingModel::currentMode() +{ + myDebug() << ">>> UsbUiSettingModel::CurrentMode"; + int currentMode = mSettingsManager.readItemValue( + XQSettingsKey( XQSettingsKey::TargetCentralRepository, + KCRUidUsbWatcher.iUid, KUsbWatcherPersonality ) ).toInt(); + myDebug() << "<<< UsbUiSettingModel::CurrentMode " << currentMode; + return currentMode; +} + +/*! + * sets the value to different roles of the model's first row + */ +void UsbUiSettingModel::setDefaultModeSetting() +{ + QString iconName; + QString modeName; + //empty iconName and modeName are used for a hidden personality + if ( !isPersonalityHidden(mCurrentMode) ) { + iconName = ModeIconNamePrefix + QString::number( mCurrentMode ) + ".svg"; + QString textId = TextIdPrefix + "modename_" + QString::number( mCurrentMode ); + modeName = qtTrId( textId.toAscii() ); + } + + myDebug() << ">>> UsbUiSettingModel::setDefaultModeSetting iconName=" + << iconName << " modeName=" << modeName; + QMap< int, QVariant > val = mSettingsList.at( DefaultMode ); + if ( val.isEmpty() ) { + val[ SettingType ] = QVariant( DefaultMode ); + } + val[ Qt::DecorationRole ] = QVariant(iconName) ; + val[ Qt::DisplayRole ]= QVariant(modeName) ; + mSettingsList.replace( DefaultMode, val ); + myDebug() << "<<< UsbUiSettingModel::setDefaultModeSetting"; +} + +/*! + Updates all values related to the mode description. + */ +void UsbUiSettingModel::setDescriptionSetting() +{ + QString description; + //the description will be empty for a hidden personality + if ( !isPersonalityHidden(mCurrentMode) ) { + QString textId = TextIdPrefix + "description_" + + QString::number( mCurrentMode ); + description = qtTrId( textId.toAscii() ); + } + myDebug() << ">>> UsbUiSettingModel::setDescriptionSetting description=" + << description; + QMap< int, QVariant > val = mSettingsList.at( Description ); + if ( val.isEmpty() ) { + + val[ SettingType ] = QVariant( Description ); + + } + // The display role stores the string representation of the actual value. + val[ Qt::DisplayRole ] = QVariant( description ); + mSettingsList.replace( Description, val ); + myDebug() << "<<< UsbUiSettingModel::setDescriptionSetting"; +} + +/*! + Updates all values related to the visibility setting. + Updates the selectable USB modes only in the 1st call. + */ +bool UsbUiSettingModel::setUsbModelistSetting( int aModeId ) +{ + myDebug() << ">>> UsbUiSettingModel::setUsbModelistSetting aModeIndex=" + << aModeId; + bool ret = true; + QMap< int, QVariant > val = mSettingsList.at(UsbModeList); + if ( val.isEmpty() ) { + val[ SettingType ] = QVariant( UsbModeList ); + + RUsb iUsbman; + if ( iUsbman.Connect() == KErrNone ) { + + RArray personalityIds; + mPersonalityIds.clear(); + if ( iUsbman.GetPersonalityIds( personalityIds ) == KErrNone ) { + QStringList modeList; + for ( int i = 0; i < personalityIds.Count(); i++ ) { + if ( !isPersonalityHidden(iUsbman, personalityIds[i]) ) { + mPersonalityIds.append( personalityIds[i] ); + modeList.append( modeListName( mPersonalityIds[i] ) ); + } + } + val[ SettingsModeNameList ] = QVariant( modeList ); + } + } + else{ + ret = false; + } + iUsbman.Close(); + } + //index will be -1 for hidden personality + val[ Qt::EditRole ] = QVariant( mPersonalityIds.indexOf(aModeId) ); + mSettingsList.replace( UsbModeList, val ); + myDebug() << "<<< UsbUiSettingModel::setUsbModelistSetting"; + return ret; +} + +/*! + * it checks the response from usbwatcher to see if the new mode change has been successful + * it will go back to the previous personality if it has not been successfull + */ +void UsbUiSettingModel::setPersonalityCompleted (int status ) +{ + myDebug() << ">>> UsbUiSettingModel::setPersonalityCompleted status= " + << status; + // status contains Symbian error code from usbwatcher + // if the status is KErrNone, we are ready to process the next request + if (status != KErrNone) + { + // changing the personality failed, so we need to set back the previous personality + // the value will be read from central repository and also updates mCurrentMode + mPreviousMode = mSettingsManager.readItemValue( + XQSettingsKey( XQSettingsKey::TargetCentralRepository, + KCRUidUsbWatcher.iUid, KUsbWatcherPersonality ) ).toInt(); + setNewUsbMode(mPreviousMode); + } + + // after handling the return code we know the the current personality works + // and we will not go back to the previous one + mPreviousMode = mCurrentMode; + myDebug() << "<<< UsbUiSettingModel::setPersonalityCompleted"; +} + +bool UsbUiSettingModel::isPersonalityHidden(RUsb &usbman, TInt personalityId) +{ + myDebug() << ">>> UsbUiSettingModel::isPersonalityHidden from USB Manager"; + bool hidden = false; + TUint32 property = 0; + TInt ret = usbman.GetPersonalityProperty(personalityId, property); + if (ret == KErrNone) { + myDebug() << "property " << property; + if (property & KUsbPersonalityPropertyHidden) { + hidden = true; + } + } + myDebug() << "<<< UsbUiSettingModel::isPersonalityHidden " << hidden; + return hidden; +} + +bool UsbUiSettingModel::isPersonalityHidden(TInt personalityId) +{ + return ( mPersonalityIds.indexOf(personalityId) == -1 ); +} diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/src/usbviewmanager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/src/usbviewmanager.cpp Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include "UsbViewManager.h" +#include "UsbMainView.h" + + +UsbViewManager::UsbViewManager( HbMainWindow* mainWindow, QObject *parent ) +: QObject( parent ), + mWindow(mainWindow) + { + } + +UsbViewManager::~UsbViewManager() + { + + } + +/*! + Create views(main view, gadget gallery view and gadget details view). + Add them to MainWindow. + */ +void UsbViewManager::addView() + { + // Create main view and add + mMainView = new UsbMainView( this ); + mWindow->addView(mMainView); + + } + diff -r 7e15987c4500 -r 8c311f9acc5e usbuis/usbuiqt/usbapplication.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbuis/usbuiqt/usbapplication.pro Fri Mar 19 09:48:52 2010 +0200 @@ -0,0 +1,71 @@ +# +# ============================================================================ +# Name : usbapplication.pro +# Part of : USB / USB Settings Application *** Info from the SWAD +# Description : Project definition file for project USB Settings Application +# Version : %version: 6 % << Don't touch! Updated by Synergy at check-out. +# +# Copyright © 2009 Nokia. All rights reserved. +# This material, including documentation and any related computer +# programs, is protected by copyright controlled by Nokia. All +# rights are reserved. Copying, including reproducing, storing, +# adapting or translating, any or all of this material requires the +# prior written consent of Nokia. This material also contains +# confidential information which may not be disclosed to others +# without the prior written consent of Nokia. +# ============================================================================ +# + +TEMPLATE = app +TARGET = usbapplication +QT += core \ + gui \ + xml +HEADERS += inc/usbuisettingmodel.h \ + inc/usbuimodelactive.h \ + inc/usbviewmanager.h \ + inc/usbmainview.h +SOURCES += src/usbuisettingmodel.cpp \ + src/usbuimodelactive.cpp \ + src/usbviewmanager.cpp \ + src/usbmainview.cpp \ + src/main.cpp \ + src/usbapplication_reg.rss +INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE +LIBS += -lcentralrepository +LIBS += -lusbwatcher +LIBS += -lxqsettingsmanager +LIBS += -lusbman +LIBS += -lhbcore +LIBS += -lhbwidgets +LIBS += -lhbtools +FORMS += +RESOURCES += src/usbicons.qrc \ + src/usbapplication.qrc +CONFIG += qt \ + hb + +symbian: { + TARGET.UID3 = 0x2002BCA3 + TARGET.CAPABILITY = LocalServices \ + WriteDeviceData + + # for pkg + usbuitranslation.sources = src/usbapplication.qm + usbuitranslation.path = /resource + DEPLOYMENT += usbuitranslation + + BLD_INF_RULES.prj_exports += "./src/usbapplication.qm z:/resource/qt/translations/usbapplication.qm +} + +# placeholder for creating sis file +createsis.commands += ( makesis -v usbapplication.pkg ); \ + && \ + ( signsis.exe usbapplication.sis usbapplication_signed.sisx Nokia_RnDCert_02.der Nokia_RnDCert_02.key ); \ + && \ + ( del usbapplication.sis ); +QMAKE_EXTRA_TARGETS += createsis + +BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include " \ + "rom/usbsettings.iby CORE_MW_LAYER_IBY_EXPORT_PATH(usbsettings.iby)" \ + "rom/usbsettingsresources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(usbsettingsresources.iby)"