diff -r 25fce757be94 -r e02eb84a14d2 usbclasses/pictbridgeengine/src/dpsptpnotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usbclasses/pictbridgeengine/src/dpsptpnotifier.cpp Wed Sep 01 12:20:49 2010 +0100 @@ -0,0 +1,132 @@ +/* +* Copyright (c) 2006, 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: This class implements functions of setting personality to +* MTP. +* Version : %version: 10.1.4 % +* +*/ + + +#include +#include "dpsptpnotifier.h" +#include "dpsusbnotifier.h" +#include "dpsconst.h" + +#ifdef _DEBUG +# define IF_DEBUG(t) {RDebug::t;} +#else +# define IF_DEBUG(t) +#endif + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CDpsPtpNotifier* CDpsPtpNotifier::NewL(CDpsUsbNotifier* aParent) + { + IF_DEBUG(Print(_L("CDpsPtpNotifier::NewL"))); + CDpsPtpNotifier* self = new(ELeave) CDpsPtpNotifier(aParent); + return self; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +CDpsPtpNotifier::CDpsPtpNotifier(CDpsUsbNotifier* aParent) : + CActive(EPriorityNormal), iNotifier(aParent) + { + IF_DEBUG(Print(_L(">>>CDpsPtpNotifier::Ctor"))); + CActiveScheduler::Add(this); + IF_DEBUG(Print(_L("<<>>CDpsPtpNotifier::"))); + Cancel(); + IF_DEBUG(Print(_L("<<>>CDpsPtpNotifier::ChangePtpPersonality"))); + if (!IsActive()) + { + TInt personalityId = KUsbPersonalityIdMTP; + iNotifier->iUsbM.GetCurrentPersonalityId(personalityId); + IF_DEBUG(Print(_L("CDpsPtpNotifier::ChangePtpPersonality, current personality= %d"), personalityId)); + if(KUsbPersonalityIdPCSuiteMTP == personalityId) + { + TRequestStatus* statusPtr = &iStatus; + User::RequestComplete(statusPtr, KErrNone); + SetActive(); + } + else + { + iNotifier->iUsbW.SetPersonality(iStatus, KUsbPersonalityIdMTP, ETrue); + SetActive(); + } + } + IF_DEBUG(Print(_L("<<>>CDpsPtpNotifier::RunL %d"), iStatus.Int())); + if (KErrNone == iStatus.Int()) + { + iNotifier->iPersonality = KUsbPersonalityIdMTP; + TInt ret = iNotifier->ConnectState(); + if (ret != KErrNone) + { + IF_DEBUG(Print(_L("error happened %d"), ret)); + } + } + iNotifier->PtpNotify(iStatus.Int()); + IF_DEBUG(Print(_L("<<>>CDpsPtpNotifier::DoCancel"))); + iNotifier->iUsbW.CancelSetPersonality(); + IF_DEBUG(Print(_L("<<