--- a/usbmgmt/usbmgr/usbman/client/SRC/RUsb.cpp Tue Aug 31 17:01:47 2010 +0300
+++ b/usbmgmt/usbmgr/usbman/client/SRC/RUsb.cpp Wed Sep 01 12:35:00 2010 +0100
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003-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"
@@ -19,20 +19,17 @@
#include <usbman.h>
#include <usb.h>
#include <e32base.h>
+#include "rusb.h"
+#include <usb/usblogger.h>
+
+#ifdef __FLOG_ACTIVE
+_LIT8(KLogComponent, "USBMAN");
+#endif
#ifdef __USBMAN_NO_PROCESSES__
#include <e32math.h>
#endif
-#include <usb/usblogger.h>
-
-#include "rusb.h"
-
-#include "OstTraceDefinitions.h"
-#ifdef OST_TRACE_COMPILER_IN_USE
-#include "RUsbTraces.h"
-#endif
-
static TInt StartServer()
//
@@ -112,8 +109,7 @@
server.Close();
- OstTrace1( TRACE_NORMAL, RUSB_STARTSERVER, "::StartServer;USB server started successfully: err=%d", err );
-
+ LOGTEXT2(_L8("USB server started successfully: err = %d\n"),err);
return err;
}
@@ -125,14 +121,14 @@
: iDeviceStatePkg(0), iServiceStatePkg(0), iMessagePkg(0),
iHostPkg(TDeviceEventInformation())
{
- OstTraceFunctionEntry0( RUSB_RUSB_CONS_ENTRY );
- OstTraceFunctionExit0( RUSB_RUSB_CONS_EXIT );
+ LOG_LINE
+ LOG_FUNC
}
EXPORT_C RUsb::~RUsb()
{
- OstTraceFunctionEntry0( RUSB_RUSB_DES_ENTRY );
- OstTraceFunctionExit0( RUSB_RUSB_DES_EXIT );
+ LOG_LINE
+ LOG_FUNC
}
EXPORT_C TVersion RUsb::Version() const
@@ -142,7 +138,9 @@
EXPORT_C TInt RUsb::Connect()
{
- OstTraceFunctionEntry0( RUSB_CONNECT_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
TInt retry = 2;
FOREVER
@@ -152,13 +150,11 @@
if ((err != KErrNotFound) && (err != KErrServerTerminated))
{
- OstTraceFunctionExit0( RUSB_CONNECT_EXIT );
return err;
}
if (--retry == 0)
{
- OstTraceFunctionExit0( RUSB_CONNECT_EXIT_DUP1 );
return err;
}
@@ -166,7 +162,6 @@
if ((err != KErrNone) && (err != KErrAlreadyExists))
{
- OstTraceFunctionExit0( RUSB_CONNECT_EXIT_DUP2 );
return err;
}
}
@@ -174,134 +169,149 @@
EXPORT_C void RUsb::Start(TRequestStatus& aStatus)
{
- OstTraceFunctionEntry0( RUSB_START_ENTRY );
-
+ LOG_LINE
+ LOG_FUNC
+
SendReceive(EUsbStart, aStatus);
- OstTraceFunctionExit0( RUSB_START_EXIT );
}
EXPORT_C void RUsb::StartCancel()
{
- OstTraceFunctionEntry0( RUSB_STARTCANCEL_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
SendReceive(EUsbStartCancel);
- OstTraceFunctionExit0( RUSB_STARTCANCEL_EXIT );
}
EXPORT_C void RUsb::Stop()
{
- OstTraceFunctionEntry0( RUSB_STOP_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
SendReceive(EUsbStop);
- OstTraceFunctionExit0( RUSB_STOP_EXIT );
}
EXPORT_C void RUsb::Stop(TRequestStatus& aStatus)
{
- OstTraceFunctionEntry0( RUSB_STOP_TREQUESTSTATUS_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
SendReceive(EUsbStop, aStatus);
- OstTraceFunctionExit0( RUSB_STOP_TREQUESTSTATUS_EXIT );
}
EXPORT_C void RUsb::StopCancel()
{
- OstTraceFunctionEntry0( RUSB_STOPCANCEL_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
SendReceive(EUsbStopCancel);
- OstTraceFunctionExit0( RUSB_STOPCANCEL_EXIT );
}
EXPORT_C TInt RUsb::GetServiceState(TUsbServiceState& aState)
{
- OstTraceFunctionEntry0( RUSB_GETSERVICESTATE_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
TPckg<TUint32> pkg(aState);
TInt ret=SendReceive(EUsbGetCurrentState, TIpcArgs(&pkg));
aState=(TUsbServiceState)pkg();
- OstTraceFunctionExit0( RUSB_GETSERVICESTATE_EXIT );
return ret;
}
EXPORT_C TInt RUsb::GetCurrentState(TUsbServiceState& aState)
{
- OstTraceFunctionEntry0( RUSB_GETCURRENTSTATE_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
return GetServiceState(aState);
}
EXPORT_C void RUsb::ServiceStateNotification(TUsbServiceState& aState,
TRequestStatus& aStatus)
{
- OstTraceFunctionEntry0( RUSB_SERVICESTATENOTIFICATION_ENTRY );
+ LOG_LINE
+ LOG_FUNC
iServiceStatePkg.Set((TUint8*)&aState, sizeof(TUint32), sizeof(TUint32));
SendReceive(EUsbRegisterServiceObserver, TIpcArgs(&iServiceStatePkg), aStatus);
- OstTraceFunctionExit0( RUSB_SERVICESTATENOTIFICATION_EXIT );
}
EXPORT_C void RUsb::ServiceStateNotificationCancel()
{
- OstTraceFunctionEntry0( RUSB_SERVICESTATENOTIFICATIONCANCEL_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
SendReceive(EUsbCancelServiceObserver);
- OstTraceFunctionExit0( RUSB_SERVICESTATENOTIFICATIONCANCEL_EXIT );
}
EXPORT_C TInt RUsb::GetDeviceState(TUsbDeviceState& aState)
{
- OstTraceFunctionEntry0( RUSB_GETDEVICESTATE_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
TPckg<TUint32> pkg(aState);
TInt ret=SendReceive(EUsbGetCurrentDeviceState, TIpcArgs(&pkg));
aState=(TUsbDeviceState)pkg();
- OstTraceFunctionExit0( RUSB_GETDEVICESTATE_EXIT );
return ret;
}
EXPORT_C void RUsb::DeviceStateNotification(TUint aEventMask, TUsbDeviceState& aState,
TRequestStatus& aStatus)
{
- OstTraceFunctionEntry0( RUSB_DEVICESTATENOTIFICATION_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
iDeviceStatePkg.Set((TUint8*)&aState, sizeof(TUint32), sizeof(TUint32));
SendReceive(EUsbRegisterObserver, TIpcArgs(aEventMask, &iDeviceStatePkg), aStatus);
- OstTraceFunctionExit0( RUSB_DEVICESTATENOTIFICATION_EXIT );
}
EXPORT_C void RUsb::DeviceStateNotificationCancel()
{
- OstTraceFunctionEntry0( RUSB_DEVICESTATENOTIFICATIONCANCEL_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
SendReceive(EUsbCancelObserver);
- OstTraceFunctionExit0( RUSB_DEVICESTATENOTIFICATIONCANCEL_EXIT );
}
EXPORT_C void RUsb::StateNotification(TUint aEventMask, TUsbDeviceState& aState, TRequestStatus& aStatus)
{
- OstTraceFunctionEntry0( RUSB_STATENOTIFICATION_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
DeviceStateNotification(aEventMask, aState, aStatus);
- OstTraceFunctionExit0( RUSB_STATENOTIFICATION_EXIT );
}
EXPORT_C void RUsb::StateNotificationCancel()
{
- OstTraceFunctionEntry0( RUSB_STATENOTIFICATIONCANCEL_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
DeviceStateNotificationCancel();
- OstTraceFunctionExit0( RUSB_STATENOTIFICATIONCANCEL_EXIT );
}
EXPORT_C void RUsb::TryStart(TInt aPersonalityId, TRequestStatus& aStatus)
{
- OstTraceFunctionEntry0( RUSB_TRYSTART_ENTRY );
+ LOG_LINE
+ LOG_FUNC
TIpcArgs ipcArgs(aPersonalityId);
SendReceive(EUsbTryStart, ipcArgs, aStatus);
- OstTraceFunctionExit0( RUSB_TRYSTART_EXIT );
}
EXPORT_C void RUsb::TryStop(TRequestStatus& aStatus)
{
- OstTraceFunctionEntry0( RUSB_TRYSTOP_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
SendReceive(EUsbTryStop, aStatus);
- OstTraceFunctionExit0( RUSB_TRYSTOP_EXIT );
}
EXPORT_C TInt RUsb::CancelInterest(TUsbReqType aMessageId)
{
- OstTraceFunctionEntry0( RUSB_CANCELINTEREST_ENTRY );
+ LOG_LINE
+ LOG_FUNC
TInt messageId;
switch (aMessageId)
@@ -328,7 +338,9 @@
EXPORT_C TInt RUsb::GetDescription(TInt aPersonalityId, HBufC*& aLocalizedPersonalityDescriptor)
{
- OstTraceFunctionEntry0( RUSB_GETDESCRIPTION_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
TInt ret = KErrNone;
// caller is responsible for freeing up memory allocatd for aLocalizedPersonalityDescriptor
TRAP(ret, aLocalizedPersonalityDescriptor = HBufC::NewL(KUsbStringDescStringMaxSize));
@@ -345,31 +357,31 @@
aLocalizedPersonalityDescriptor = NULL;
}
- OstTraceFunctionExit0( RUSB_GETDESCRIPTION_EXIT );
return ret;
}
EXPORT_C TInt RUsb::GetCurrentPersonalityId(TInt& aPersonalityId)
{
- OstTraceFunctionEntry0( RUSB_GETCURRENTPERSONALITYID_ENTRY );
+ LOG_LINE
+ LOG_FUNC
TPckg<TInt> pkg0(aPersonalityId);
TInt ret = SendReceive(EUsbGetCurrentPersonalityId, TIpcArgs(&pkg0));
aPersonalityId = static_cast<TInt>(pkg0());
- OstTraceFunctionExit0( RUSB_GETCURRENTPERSONALITYID_EXIT );
return ret;
}
EXPORT_C TInt RUsb::GetSupportedClasses(TInt aPersonalityId, RArray<TUid>& aClassUids)
{
- OstTraceFunctionEntry0( RUSB_GETSUPPORTEDCLASSES_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
TInt ret = KErrNone;
HBufC8* buf = NULL;
// +1 for the actual count of personality ids
TRAP(ret, buf = HBufC8::NewL((KUsbMaxSupportedClasses + 1)*sizeof (TInt32)));
if (ret != KErrNone)
{
- OstTraceFunctionExit0( RUSB_GETSUPPORTEDCLASSES_EXIT );
return ret;
}
@@ -382,7 +394,6 @@
if (!recvedIds)
{
delete buf;
- OstTraceFunctionExit0( RUSB_GETSUPPORTEDCLASSES_EXIT_DUP1 );
return KErrCorrupt;
}
@@ -421,13 +432,13 @@
}
delete buf;
- OstTraceFunctionExit0( RUSB_GETSUPPORTEDCLASSES_EXIT_DUP2 );
return ret;
}
EXPORT_C TInt RUsb::ClassSupported(TInt aPersonalityId, TUid aClassUid, TBool& aSupported)
{
- OstTraceFunctionEntry0( RUSB_CLASSSUPPORTED_ENTRY );
+ LOG_LINE
+ LOG_FUNC
TPckg<TInt32> pkg2(aSupported);
TIpcArgs ipcArgs(aPersonalityId, aClassUid.iUid, &pkg2);
@@ -439,20 +450,20 @@
aSupported = static_cast<TBool>(pkg2());
}
- OstTraceFunctionExit0( RUSB_CLASSSUPPORTED_EXIT );
return ret;
}
EXPORT_C TInt RUsb::GetPersonalityIds(RArray<TInt>& aPersonalityIds)
{
- OstTraceFunctionEntry0( RUSB_GETPERSONALITYIDS_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
TInt ret = KErrNone;
HBufC8* buf = NULL;
// +1 for the actual count of personality ids
TRAP(ret, buf = HBufC8::NewL((KUsbMaxSupportedPersonalities + 1)*sizeof (TInt)));
if (ret != KErrNone)
{
- OstTraceFunctionExit0( RUSB_GETPERSONALITYIDS_EXIT );
return ret;
}
@@ -465,7 +476,6 @@
if (!recvedIds)
{
delete buf;
- OstTraceFunctionExit0( RUSB_GETPERSONALITYIDS_EXIT_DUP1 );
return KErrCorrupt;
}
@@ -505,7 +515,6 @@
}
delete buf;
- OstTraceFunctionExit0( RUSB_GETPERSONALITYIDS_EXIT_DUP2 );
return ret;
}
@@ -558,14 +567,14 @@
}
EXPORT_C void panic()
- {
- OstTrace1( TRACE_FATAL, RUSB_PANIC, "::panic;Panic reason=%d", EUsbPanicRemovedExport );
- User::Panic(KUsbCliPncCat, EUsbPanicRemovedExport);
+ {
+ _USB_PANIC(KUsbCliPncCat, EUsbPanicRemovedExport);
}
EXPORT_C TInt RUsb::SetCtlSessionMode(TBool aValue)
{
- OstTraceFunctionEntry0( RUSB_SETCTLSESSIONMODE_ENTRY );
+ LOG_LINE
+ LOG_FUNC
TPckg<TBool> pkg(aValue);
return SendReceive(EUsbSetCtlSessionMode, TIpcArgs(&pkg));
@@ -573,82 +582,94 @@
EXPORT_C TInt RUsb::BusRequest()
{
- OstTraceFunctionEntry0( RUSB_BUSREQUEST_ENTRY );
+ LOG_LINE
+ LOG_FUNC
return SendReceive(EUsbBusRequest);
}
EXPORT_C TInt RUsb::BusRespondSrp()
{
- OstTraceFunctionEntry0( RUSB_BUSRESPONDSRP_ENTRY );
+ LOG_LINE
+ LOG_FUNC
return SendReceive(EUsbBusRespondSrp);
}
EXPORT_C TInt RUsb::BusClearError()
{
- OstTraceFunctionEntry0( RUSB_BUSCLEARERROR_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
return SendReceive(EUsbBusClearError);
}
EXPORT_C TInt RUsb::BusDrop()
{
- OstTraceFunctionEntry0( RUSB_BUSDROP_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
return SendReceive(EUsbBusDrop);
}
EXPORT_C void RUsb::MessageNotification(TRequestStatus& aStatus, TInt& aMessage)
{
- OstTraceFunctionEntry0( RUSB_MESSAGENOTIFICATION_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
iMessagePkg.Set((TUint8*)&aMessage, sizeof(TInt), sizeof(TInt));
SendReceive(EUsbRegisterMessageObserver, TIpcArgs(&iMessagePkg), aStatus);
- OstTraceFunctionExit0( RUSB_MESSAGENOTIFICATION_EXIT );
}
EXPORT_C void RUsb::MessageNotificationCancel()
{
- OstTraceFunctionEntry0( RUSB_MESSAGENOTIFICATIONCANCEL_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
SendReceive(EUsbCancelMessageObserver);
- OstTraceFunctionExit0( RUSB_MESSAGENOTIFICATIONCANCEL_EXIT );
}
EXPORT_C void RUsb::HostEventNotification(TRequestStatus& aStatus,
TDeviceEventInformation& aDeviceInformation)
{
- OstTraceFunctionEntry0( RUSB_HOSTEVENTNOTIFICATION_ENTRY );
+ LOG_LINE
+ LOG_FUNC
iHostPkg.Set((TUint8*)&aDeviceInformation, sizeof(TDeviceEventInformation), sizeof(TDeviceEventInformation));
SendReceive(EUsbRegisterHostObserver, TIpcArgs(&iHostPkg), aStatus);
- OstTraceFunctionExit0( RUSB_HOSTEVENTNOTIFICATION_EXIT );
}
EXPORT_C void RUsb::HostEventNotificationCancel()
{
- OstTraceFunctionEntry0( RUSB_HOSTEVENTNOTIFICATIONCANCEL_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
SendReceive(EUsbCancelHostObserver);
- OstTraceFunctionExit0( RUSB_HOSTEVENTNOTIFICATIONCANCEL_EXIT );
}
EXPORT_C TInt RUsb::EnableFunctionDriverLoading()
{
- OstTraceFunctionEntry0( RUSB_ENABLEFUNCTIONDRIVERLOADING_ENTRY );
+ LOG_LINE
+ LOG_FUNC
return SendReceive(EUsbEnableFunctionDriverLoading);
}
EXPORT_C void RUsb::DisableFunctionDriverLoading()
{
- OstTraceFunctionEntry0( RUSB_DISABLEFUNCTIONDRIVERLOADING_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
SendReceive(EUsbDisableFunctionDriverLoading);
- OstTraceFunctionExit0( RUSB_DISABLEFUNCTIONDRIVERLOADING_EXIT );
}
EXPORT_C TInt RUsb::GetSupportedLanguages(TUint aDeviceId, RArray<TUint>& aLangIds)
{
- OstTraceFunctionEntry0( RUSB_GETSUPPORTEDLANGUAGES_ENTRY );
+ LOG_LINE
+ LOG_FUNC
aLangIds.Reset();
@@ -658,7 +679,6 @@
TRAP(ret, buf = HBufC8::NewL((KUsbMaxSupportedLanguageIds + 1)*sizeof (TUint)));
if (ret != KErrNone)
{
- OstTraceFunctionExit0( RUSB_GETSUPPORTEDLANGUAGES_EXIT );
return ret;
}
@@ -671,7 +691,6 @@
if (!recvedIds)
{
delete buf;
- OstTraceFunctionExit0( RUSB_GETSUPPORTEDLANGUAGES_EXIT_DUP1 );
return KErrCorrupt;
}
@@ -689,26 +708,30 @@
}
delete buf;
- OstTraceFunctionExit0( RUSB_GETSUPPORTEDLANGUAGES_EXIT_DUP2 );
return ret;
}
EXPORT_C TInt RUsb::GetManufacturerStringDescriptor(TUint aDeviceId, TUint aLangId, TName& aString)
{
- OstTraceFunctionEntry0( RUSB_GETMANUFACTURERSTRINGDESCRIPTOR_ENTRY );
+ LOG_LINE
+ LOG_FUNC
return SendReceive(EUsbGetManufacturerStringDescriptor, TIpcArgs(aDeviceId, aLangId, &aString));
}
EXPORT_C TInt RUsb::GetProductStringDescriptor(TUint aDeviceId, TUint aLangId, TName& aString)
{
- OstTraceFunctionEntry0( RUSB_GETPRODUCTSTRINGDESCRIPTOR_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
return SendReceive(EUsbGetProductStringDescriptor, TIpcArgs(aDeviceId, aLangId, &aString));
}
EXPORT_C TInt RUsb::GetOtgDescriptor(TUint aDeviceId, TOtgDescriptor& aDescriptor)
{
- OstTraceFunctionEntry0( RUSB_GETOTGDESCRIPTOR_ENTRY );
+ LOG_LINE
+ LOG_FUNC
+
TPckg<TOtgDescriptor> otgDescPkg(aDescriptor);
TIpcArgs args;
@@ -721,22 +744,40 @@
EXPORT_C TInt RUsb::RequestSession()
{
- OstTraceFunctionEntry0( RUSB_REQUESTSESSION_ENTRY );
+ LOG_LINE
+ LOG_FUNC
return SendReceive(EUsbRequestSession);
}
-EXPORT_C TInt RUsb::GetDetailedDescription(TInt /*aPersonalityId*/, HBufC*& /*aLocalizedPersonalityDescriptor*/)
+EXPORT_C TInt RUsb::GetDetailedDescription(TInt aPersonalityId, HBufC*& aLocalizedPersonalityDescriptor)
{
- OstTraceFunctionEntry0( RUSB_GETDETAILEDDESCRIPTION_ENTRY );
- //This API has been deprecated
- OstTraceFunctionExit0( RUSB_GETDETAILEDDESCRIPTION_EXIT );
- return KErrNotSupported;
+ LOG_LINE
+ LOG_FUNC
+
+ TInt ret = KErrNone;
+ // caller is responsible for freeing up memory allocated for aLocalizedPersonalityDescriptor
+ TRAP(ret, aLocalizedPersonalityDescriptor = HBufC::NewL(KUsbStringDescStringMaxSize));
+ if (ret == KErrNone)
+ {
+ TPtr ptr = aLocalizedPersonalityDescriptor->Des();
+ TIpcArgs ipcArgs(0, &ptr);
+ ipcArgs.Set(0, aPersonalityId);
+ ret = SendReceive(EUsbGetDetailedDescription, ipcArgs);
+ }
+ else
+ {
+ // just in case caller tries to free the memory before checking the return code
+ aLocalizedPersonalityDescriptor = NULL;
+ }
+
+ return ret;
}
EXPORT_C TInt RUsb::GetPersonalityProperty(TInt aPersonalityId, TUint32& aProperty)
{
- OstTraceFunctionEntry0( RUSB_GETPERSONALITYPROPERTY_ENTRY );
+ LOG_LINE
+ LOG_FUNC
TPckg<TUint32> pkg(aProperty);
TInt ret = SendReceive(EUsbGetPersonalityProperty, TIpcArgs(aPersonalityId, &pkg));
@@ -744,7 +785,6 @@
{
aProperty = static_cast<TUint32>(pkg());
}
- OstTraceFunctionExit0( RUSB_GETPERSONALITYPROPERTY_EXIT );
return ret;
}