connectivitymodules/SeCon/plugins/ftp/src/sconftppluginutils.cpp
branchRCL_3
changeset 20 4a793f564d72
parent 0 d0791faffa3f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivitymodules/SeCon/plugins/ftp/src/sconftppluginutils.cpp	Wed Sep 01 12:20:56 2010 +0100
@@ -0,0 +1,129 @@
+/*
+* 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
+
+
+