syncmlfw/common/syncagent/src/nsmlerror.cpp
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Error code conversion
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <in_iface.h>
       
    21 #include "nsmlerror.h"
       
    22 #include "nsmlhttp.h"
       
    23 
       
    24 
       
    25 // ---------------------------------------------------------
       
    26 // TNSmlError::TNSmlError()
       
    27 // Constructor, nothing special in here.
       
    28 // ---------------------------------------------------------
       
    29 //
       
    30 EXPORT_C TNSmlError::TNSmlError() :
       
    31     iErrorCode( KErrNone ),
       
    32     iReserved( NULL )
       
    33 	{
       
    34 	}
       
    35 
       
    36 // ---------------------------------------------------------
       
    37 // TNSmlError::~TNSmlError()
       
    38 // Destructor.
       
    39 // ---------------------------------------------------------
       
    40 //
       
    41 EXPORT_C TNSmlError::~TNSmlError()
       
    42 	{
       
    43 	}
       
    44 
       
    45 // ---------------------------------------------------------
       
    46 // TNSmlError::SetErrorCode( TInt aErrorCode )
       
    47 // Sets error code.
       
    48 // ---------------------------------------------------------
       
    49 //	
       
    50 EXPORT_C void TNSmlError::SetErrorCode( TInt aErrorCode )
       
    51 	{
       
    52 	iErrorCode = aErrorCode;
       
    53 	ErrorCodeConversion();
       
    54 	}
       
    55 
       
    56 // ---------------------------------------------------------
       
    57 // TNSmlError::SyncLogMessage()
       
    58 // Converts native error code to message code for UI
       
    59 // 
       
    60 // ---------------------------------------------------------	
       
    61 EXPORT_C TInt TNSmlError::SyncLogMessageCode()
       
    62 	{
       
    63 	TNSmlCommonAgentMessage syncLogMessage;
       
    64 	if ( iErrorCode >= ESmlVerDTDMissing &&
       
    65 		 iErrorCode <= ESmlVerProtoNotSupported )	
       
    66 		{
       
    67 		 syncLogMessage = ESyncMLVersionNotSupported;
       
    68 		}
       
    69 	else
       
    70 	if ( iErrorCode == ESmlUnsupportedCmd )
       
    71 		{
       
    72 		syncLogMessage = ESyncMLCommandNotSupported;
       
    73 		}
       
    74 	else
       
    75 	if ( iErrorCode >= ESmlFormatNotSupported &&
       
    76 		 iErrorCode <= ESmlTypeInvalid )
       
    77 		{
       
    78 		syncLogMessage = EUnsupportedContentTypeOrFormat;
       
    79 		}
       
    80 	else
       
    81 	if ( iErrorCode >= ESmlCommandInvalid &&
       
    82 		 iErrorCode <= ESmlItemTargetLocURIMissing )
       
    83 		{
       
    84 		syncLogMessage = ESyncMLError;
       
    85 		}
       
    86 	else
       
    87 	if ( iErrorCode >= ESmlResultsInvalid &&
       
    88 		 iErrorCode <= ESmlMaxMsgSizeInvalid )
       
    89 		{
       
    90 		syncLogMessage = ESyncMLError;	
       
    91 		}
       
    92 	else
       
    93 	if ( iErrorCode == ESmlServerIsBusy )
       
    94 		{
       
    95 		syncLogMessage = EServerBusy;
       
    96 		}
       
    97 	else
       
    98 	if ( iErrorCode == ESmlTooLongMessage )
       
    99 		{
       
   100 		syncLogMessage = ESyncMLError;
       
   101 		}
       
   102 	else
       
   103 	if ( iErrorCode == ESmlIncompleteMessage )
       
   104 		{
       
   105 		syncLogMessage = ESyncMLError;
       
   106 		}
       
   107 	else
       
   108 	if ( iErrorCode == ESmlServerUnauthorized )
       
   109 		{
       
   110 		syncLogMessage = ESyncMLServerAuthenticationError;
       
   111 		}
       
   112 	else
       
   113 	if ( iErrorCode == ESmlServerNotResponding )
       
   114 		{
       
   115 		syncLogMessage = EServerNotResponding;
       
   116 		}
       
   117 	else
       
   118 	if ( iErrorCode == TNSmlHTTPErrCode::ENSmlHTTPErr_NotFound || iErrorCode == TNSmlHTTPErrCode::ENSmlHTTPErr_MethodNotAllowed )
       
   119 		{
       
   120 		syncLogMessage = EInvalidURI;
       
   121 		}
       
   122 	else
       
   123 	if ( iErrorCode == TNSmlHTTPErrCode::ENSmlHTTPErrCodeBase + 401 )	
       
   124 		{
       
   125 		syncLogMessage = EHTTPAuthError;
       
   126 		}
       
   127 	else
       
   128 	if ( ( iErrorCode >= TNSmlHTTPErrCode::ENSmlHTTPErrCodeBase + 400 &&
       
   129 		 iErrorCode <= TNSmlHTTPErrCode::ENSmlHTTPErrCodeBase + 599 ) || ( iErrorCode == ESmlCommunicationError ) )	
       
   130 		{
       
   131 		syncLogMessage = ECommunicationError;
       
   132 		}
       
   133 	else
       
   134 	if ( iErrorCode >= ESmlStatusMultipleChoices &&
       
   135 		 iErrorCode <= ESmlStatusUseProxy )	
       
   136 		{
       
   137 		syncLogMessage = ESyncMLError;
       
   138 		}
       
   139 	else
       
   140 	if ( iErrorCode == ESmlStatusBadRequest || iErrorCode == ESmlStatusPaymentRequired )
       
   141 		{
       
   142 		syncLogMessage = ESyncMLError;
       
   143 		}
       
   144 	else
       
   145 	if ( iErrorCode == ESmlStatusUnauthorized )
       
   146 		{
       
   147 		syncLogMessage = ESyncMLClientAuthenticationError;
       
   148 		}
       
   149 	else
       
   150 	if ( iErrorCode == ESmlStatusForbidden || iErrorCode == ESmlStatusNotFound 
       
   151 		|| iErrorCode == ESmlStatusGone)	
       
   152 		{
       
   153 		syncLogMessage = ESyncMLError;
       
   154 		}
       
   155 	else
       
   156 	if ( iErrorCode == ESmlStatusCommandNotAllowed )
       
   157 		{
       
   158 		syncLogMessage = ESyncMLError;
       
   159 		}
       
   160 	else
       
   161 	if ( iErrorCode == ESmlStatusOptFeatureNotSupported || iErrorCode == ESmlStatusCommandNotImplemented )	
       
   162 		{
       
   163 		syncLogMessage = ESyncMLCommandNotSupported;
       
   164 		}
       
   165 	else
       
   166 	if ( iErrorCode == ESmlStatusClientAuthenticationRequired )
       
   167 		{
       
   168 		syncLogMessage = ESyncMLClientAuthenticationError;
       
   169 		}
       
   170 	else
       
   171 	if ( iErrorCode == ESmlStatusRequestTimeout || iErrorCode == ESmlStatusSizeRequired 
       
   172 		|| iErrorCode == ESmlStatusIncompleteCommand || iErrorCode == ESmlStatusEntityTooLarge
       
   173 		|| iErrorCode == ESmlStatusRequestedSizeTooBig || iErrorCode == ESmlStatusUnknownSearchGrammar
       
   174 		|| iErrorCode == ESmlStatusBadCGIScript || iErrorCode == ESmlStatusBadGateway
       
   175 		|| iErrorCode == ESmlStatusAtomicFailed )
       
   176 		{
       
   177 		syncLogMessage = ESyncMLError;
       
   178 		}
       
   179 	else
       
   180 	if ( iErrorCode == ESmlStatusURITooLong )	
       
   181 		{
       
   182 		syncLogMessage = ESyncMLError;
       
   183 		}
       
   184 	else
       
   185 	if ( iErrorCode == ESmlStatusUnsupportedMediaTypeOrFormat )
       
   186 		{
       
   187 		syncLogMessage = EUnsupportedContentTypeOrFormat;
       
   188 		}
       
   189 	else
       
   190 	if ( iErrorCode == ESmlStatusRetryLater || iErrorCode == ESmlStatusDeviceFull 
       
   191 		|| iErrorCode == ESmlStatusCommandFailed || iErrorCode == ESmlStatusServiceUnavailable 
       
   192 		|| iErrorCode == ESmlStatusGatewayTimeout || iErrorCode == ESmlStatusProcessingError 
       
   193 		|| iErrorCode == ESmlStatusDataStoreFailure || iErrorCode == ESmlStatusServerFailure 
       
   194 		|| iErrorCode == ESmlStatusSynchronisationFailed )
       
   195 		{
       
   196 		syncLogMessage = EServerSystemError;
       
   197 		}
       
   198 	else
       
   199 	if ( iErrorCode == ESmlStatusVersionNotSupported 
       
   200 		|| iErrorCode == ESmlStatusProtocolVersionNotSupported )
       
   201 		{
       
   202 		syncLogMessage = ESyncMLVersionNotSupported;
       
   203 		}
       
   204     // 1.2 CHANGES: Offline mode
       
   205     else
       
   206     if ( iErrorCode == ESmlStatusNotPossibleInOfflineMode )
       
   207         {
       
   208         syncLogMessage = ENotPossibleInOfflineMode;
       
   209         }
       
   210     // Changes end
       
   211 	else	
       
   212 		{
       
   213 		syncLogMessage = ESystemError;
       
   214 		}
       
   215 	return syncLogMessage;
       
   216 	}
       
   217 // ---------------------------------------------------------
       
   218 // TNSmlError::SyncLogErrorCode()
       
   219 // 
       
   220 // ---------------------------------------------------------	
       
   221 EXPORT_C TInt TNSmlError::SyncLogErrorCode()
       
   222 	{
       
   223 	return iErrorCode;
       
   224 	}
       
   225 // ---------------------------------------------------------
       
   226 // TNSmlError::ErrorCodeConversion()
       
   227 // Converts some error code to Symbian error codes 
       
   228 // ---------------------------------------------------------	
       
   229 EXPORT_C void TNSmlError::ErrorCodeConversion()
       
   230 	{
       
   231 	if ( iErrorCode == ESmlLowMemory || iErrorCode == ESmlStatusDeviceFull )
       
   232 		{
       
   233 		iErrorCode = KErrDiskFull;
       
   234 		}
       
   235 	}
       
   236