connectivitymodules/SeCon/plugins/ftp/src/sconftppluginutils.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:20:56 +0100
branchRCL_3
changeset 20 4a793f564d72
parent 0 d0791faffa3f
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201032 Kit: 201035

/*
* Copyright (c) 2005-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:  File Transfer Profile Plug-in utilities
*
*/


// INCLUDE FILES
#include <obexconstants.h>
#include "sconftppluginutils.h"
#include "debug.h"

// ============================= MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// TFTPpluginUtils::ConvertFTPResponseCode( TInt aError )
// Converts Symbian error code to OBEX error code
// -----------------------------------------------------------------------------
//
TInt TFTPpluginUtils::ConvertFTPResponseCode( TInt aError )
	{
	LOGGER_WRITE_1( "TFTPpluginUtils::ConvertFTPResponseCode : begin Code  %d", aError );
	TInt obexErr ( KErrIrObexRespBadRequest );
	switch( aError )
		{
		case KErrNone:
			obexErr = KErrNone;
			break;
		case KErrNotFound:
			obexErr = KErrIrObexRespNotFound;
			break;
		case KErrGeneral:
		case KErrCancel:
			obexErr = KErrIrObexRespBadRequest;
			break;
		case KErrNoMemory:
			obexErr = KErrIrObexRespDatabaseFull;
			break;
		case KErrNotSupported:
			obexErr = KErrIrObexRespNotImplemented;
			break;
		case KErrArgument:
		case KErrTotalLossOfPrecision:
		case KErrBadHandle:
		case KErrOverflow:
		case KErrUnderflow:
		case KErrAlreadyExists:
			obexErr = KErrIrObexRespConflict;
			break;
		case KErrPathNotFound:
		case KErrDied:
			obexErr = KErrIrObexRespNotFound;
			break;
		case KErrInUse:
			obexErr = KErrIrObexRespTimedOut;
			break;
		case KErrServerTerminated:
			obexErr = KErrIrObexRespNotFound;
			break;
		case KErrServerBusy:
		case KErrCompletion:
		case KErrNotReady:
		case KErrUnknown:
		case KErrCorrupt:
			obexErr = KErrIrObexRespForbidden;
			break;
		case KErrAccessDenied:
		case KErrLocked:
			obexErr = KErrIrObexRespUnauthorized;
			break;
		case KErrWrite:
		case KErrDisMounted:
		case KErrEof:
			obexErr = KErrIrObexRespForbidden;
			break;
		case KErrDiskFull:
			obexErr = KErrIrObexRespDatabaseFull;
			break;
		case KErrBadDriver:
		case KErrBadName:
			obexErr = KErrIrObexRespPreCondFailed;
			break;
		case KErrCommsLineFail:
		case KErrCommsFrame:
		case KErrCommsOverrun:
		case KErrCommsParity:
		case KErrTimedOut:
		case KErrCouldNotConnect:
		case KErrCouldNotDisconnect:
		case KErrBadLibraryEntryPoint:
		case KErrBadDescriptor:
		case KErrAbort:
			obexErr = KErrIrObexRespForbidden;
			break;
		case KErrTooBig:
			obexErr = KErrIrObexRespReqEntityTooLarge;
			break;
		case KErrDivideByZero:
		case KErrBadPower:
		case KErrDirFull:
		case KErrHardwareNotAvailable:
			obexErr = KErrIrObexRespForbidden;
			break;
		case KErrDisconnected: // System is shutting down
		    obexErr = KErrIrObexRespMethodNotAllowed;
		    break;
		default:
			obexErr = KErrIrObexRespBadRequest;
			break;
		};
	LOGGER_WRITE_1( "TFTPpluginUtils::ConvertFTPResponseCode : returned %d", obexErr );
	return obexErr;
};

//End of file