upnpavcontroller/upnpavcontrollerserver/src/upnpaverrorhandler.cpp
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2008 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:      errror handling in AVController
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <e32std.h>
       
    25 #include <e32base.h>
       
    26 #include <upnperrors.h>
       
    27 
       
    28 #include "upnpaverrorhandler.h"
       
    29 
       
    30 // CONSTANTS
       
    31 const TInt KMaxSymbianErrorCode = -100;
       
    32 const TInt KMinActionErrorCode = 700;
       
    33 
       
    34 // --------------------------------------------------------------------------
       
    35 // UPnPAVErrorHandler::ConvertToSymbianErrorCode
       
    36 // Returns the Symbian error code (e32err.h) corresponding the given UPnP
       
    37 // error code.
       
    38 // --------------------------------------------------------------------------
       
    39 TInt UPnPAVErrorHandler::ConvertToSymbianErrorCode(
       
    40                               TInt aUPnPErrorCode,
       
    41                               TUPnPErrorCodeType aErrorType )
       
    42     {
       
    43     TInt convertedErrorCode = KErrGeneral;
       
    44 
       
    45     if( aUPnPErrorCode == EHttpOk ||  /* 200 */
       
    46         aUPnPErrorCode == KErrNone )
       
    47         {
       
    48         convertedErrorCode = KErrNone;
       
    49         }
       
    50     // Don't convert Symbian error codes
       
    51     else if( aUPnPErrorCode < 0 &&
       
    52              aUPnPErrorCode > KMaxSymbianErrorCode ) 
       
    53         {
       
    54         convertedErrorCode = aUPnPErrorCode;
       
    55         }
       
    56     else
       
    57         {
       
    58         if ( aUPnPErrorCode > 0 && 
       
    59              aUPnPErrorCode < KMinActionErrorCode )
       
    60             {
       
    61             convertedErrorCode = ConvertGeneralErrorCode( aUPnPErrorCode );
       
    62             }
       
    63         else if( aErrorType == EUPnPConnectionManagerError )
       
    64             {
       
    65             convertedErrorCode = ConvertCMErrorCode( aUPnPErrorCode );
       
    66             }
       
    67         else if( aErrorType == EUPnPContentDirectoryError )
       
    68             {
       
    69             convertedErrorCode = ConvertCDSErrorCode( aUPnPErrorCode );
       
    70             }
       
    71         else if( aErrorType == EUPnPRenderingControlError )
       
    72             {
       
    73             convertedErrorCode = ConvertRCErrorCode( aUPnPErrorCode );
       
    74             }
       
    75         else if( aErrorType == EUPnPAVTransportError )
       
    76             {
       
    77             convertedErrorCode = ConvertAVTErrorCode( aUPnPErrorCode );
       
    78             }
       
    79         else if( aErrorType == EUPnPHTTPError )
       
    80             {
       
    81             convertedErrorCode = ConvertHTTPErrorCode( aUPnPErrorCode );
       
    82             }
       
    83         else
       
    84             {
       
    85             convertedErrorCode = KErrGeneral; 
       
    86             }
       
    87         }
       
    88 
       
    89     return convertedErrorCode;
       
    90     }
       
    91 
       
    92 // --------------------------------------------------------------------------
       
    93 // UPnPAVErrorHandler::ConvertGeneralErrorCode
       
    94 // Returns the Symbian error code (e32err.h) corresponding to the
       
    95 // given general UPnP error code.
       
    96 // --------------------------------------------------------------------------
       
    97 TInt UPnPAVErrorHandler::ConvertGeneralErrorCode(
       
    98                              TInt aUPnPErrorCode )
       
    99     {
       
   100     TInt convertedErrorCode = KErrGeneral;
       
   101 
       
   102     switch( aUPnPErrorCode )
       
   103         {
       
   104         case EInvalidAction: /* 400 */
       
   105             // fall through
       
   106         case EInvalidVar: /* 404 */
       
   107             // fall through
       
   108         case ENotImplemented: /* 602 */
       
   109             {
       
   110             convertedErrorCode = KErrNotSupported;
       
   111             break;
       
   112             }
       
   113         case EInvalidArgs: /* 402 */
       
   114             // fall through
       
   115         case EArgumentValue: /* 600 */
       
   116             // fall through
       
   117         case EArgumentRange: /* 601 */
       
   118             // fall through
       
   119         case EStringTooLong: /* 605 */
       
   120             {
       
   121             convertedErrorCode = KErrArgument;
       
   122             break;
       
   123             }
       
   124         case EInternalServerError: /* 500 */
       
   125             {
       
   126             convertedErrorCode = KErrGeneral;
       
   127             break;
       
   128             }
       
   129         case EActionFailed: /* 501 */
       
   130             {
       
   131             convertedErrorCode = KErrGeneral;
       
   132             break;
       
   133             }
       
   134         case EHttpInsufficientStorage:
       
   135             {
       
   136             convertedErrorCode = KErrDiskFull;
       
   137             break;
       
   138             }     
       
   139         case EOutOfMemory: /* 603 */
       
   140             {
       
   141             //Server has no memory
       
   142             convertedErrorCode = KErrServerBusy;
       
   143             break;
       
   144             }
       
   145         case EHumanIntervention: /* 604 */
       
   146             {
       
   147             convertedErrorCode = KErrDied;
       
   148             break;
       
   149             }
       
   150         case ENotAuthorized: /* 606 */
       
   151             // fall through
       
   152         case ESignatureFailure: /* 607 */
       
   153             // fall through
       
   154         case ESignatureMissing: /* 608 */
       
   155             // fall through
       
   156         case ENotEncrypted: /* 609 */
       
   157             {
       
   158             convertedErrorCode = KErrAccessDenied;
       
   159             break;
       
   160             }
       
   161         case EInvalidUrl: /* 611 */
       
   162             // fall through
       
   163         case ENoSession: /* 612 */
       
   164             {
       
   165             convertedErrorCode = KErrNotFound;
       
   166             break;
       
   167             }
       
   168         default:
       
   169             {
       
   170             convertedErrorCode = KErrGeneral;
       
   171             break;
       
   172             }
       
   173         }
       
   174     return convertedErrorCode; 
       
   175     }
       
   176 
       
   177 // --------------------------------------------------------------------------
       
   178 // UPnPAVErrorHandler::ConvertCMErrorCode
       
   179 // Returns the Symbian error code (e32err.h) corresponding to the 
       
   180 // given Connection Manager error code.
       
   181 // --------------------------------------------------------------------------
       
   182 TInt UPnPAVErrorHandler::ConvertCMErrorCode(
       
   183                               TInt aUPnPErrorCode )
       
   184     {
       
   185     TInt convertedErrorCode = KErrGeneral;
       
   186     switch( aUPnPErrorCode )
       
   187         {
       
   188         case ENoSuchObject: /* 701 */
       
   189             // fall through
       
   190         case EInvalidCurrentTag: /* 702 */
       
   191             // fall through
       
   192         case EInvalidNewTag: /* 703 */
       
   193             // fall through
       
   194         case ERequiredTag: /* 704 */
       
   195             {
       
   196             convertedErrorCode = KErrCouldNotConnect;
       
   197             break;
       
   198             }
       
   199         case EReadOnlyTag: /* 705 */
       
   200             {
       
   201             convertedErrorCode = KErrAccessDenied;
       
   202             break;
       
   203             }
       
   204         case EParameterMismatch : /* 706 */
       
   205             {
       
   206             convertedErrorCode = KErrArgument;
       
   207             break;
       
   208             }
       
   209         default:
       
   210             {
       
   211             convertedErrorCode = KErrGeneral;
       
   212             break;
       
   213             }
       
   214         }
       
   215     return convertedErrorCode; 
       
   216     }
       
   217 
       
   218 // --------------------------------------------------------------------------
       
   219 // UPnPAVErrorHandler::ConvertCDSErrorCode
       
   220 // Returns the Symbian error code (e32err.h) corresponding to the 
       
   221 // given Content Directory error code.
       
   222 // --------------------------------------------------------------------------
       
   223 TInt UPnPAVErrorHandler::ConvertCDSErrorCode(
       
   224                               TInt aUPnPErrorCode )
       
   225     {
       
   226     TInt convertedErrorCode = KErrGeneral;
       
   227     switch( aUPnPErrorCode )
       
   228         {
       
   229         case ENoSuchObject: /* 701 */
       
   230             // fall through
       
   231         case ENoContainer: /* 710 */
       
   232             // fall through
       
   233         case ENoSourceResource: /* 714 */
       
   234             // fall through
       
   235         case ENoDestinationResource: /* 718 */
       
   236             {
       
   237             convertedErrorCode = KErrNotFound;
       
   238             break;
       
   239             }
       
   240         case EInvalidCurrentTag: /* 702 */
       
   241             // fall through
       
   242         case EInvalidNewTag: /* 703 */
       
   243             // fall through
       
   244         case EParameterMismatch : /* 706 */
       
   245             // fall through
       
   246         case EBadMetadata: /* 712 */
       
   247             {
       
   248             convertedErrorCode = KErrArgument;
       
   249             break;
       
   250             }
       
   251         case ERequiredTag: /* 704 */
       
   252             // fall through
       
   253         case EReadOnlyTag: /* 705 */
       
   254             // fall through
       
   255         case ERestrictedObject: /* 711 */
       
   256             // fall through
       
   257         case ERestrictedParentObject: /* 713 */
       
   258             // fall through
       
   259         case ESourceAccess: /* 715 */
       
   260             // fall through
       
   261         case EDestinationAccess: /* 719 */
       
   262             {
       
   263             convertedErrorCode = KErrAccessDenied;
       
   264             break;
       
   265             }
       
   266         case EInvalidSearch: /* 708 */
       
   267             // fall through
       
   268         case EInvalidSort: /* 709 */
       
   269             {
       
   270             convertedErrorCode = KErrNotSupported;
       
   271             break;
       
   272             }
       
   273         case ETransferBusy: /* 716 */
       
   274             {
       
   275             convertedErrorCode = KErrInUse;
       
   276             break;
       
   277             }
       
   278        default:
       
   279             {
       
   280             convertedErrorCode = KErrGeneral;
       
   281             break;
       
   282             }
       
   283         }
       
   284     return convertedErrorCode; 
       
   285     }
       
   286 
       
   287 // --------------------------------------------------------------------------
       
   288 // UPnPAVErrorHandler::ConvertRCErrorCode
       
   289 // Returns the Symbian error code (e32err.h) corresponding to the 
       
   290 // given Rendering Control error code.
       
   291 // --------------------------------------------------------------------------
       
   292 TInt UPnPAVErrorHandler::ConvertRCErrorCode(
       
   293                               TInt aUPnPErrorCode )
       
   294     {
       
   295     TInt convertedErrorCode = KErrGeneral;
       
   296     switch( aUPnPErrorCode )
       
   297         {
       
   298         case ENoSuchObject: /* 701 */
       
   299             // fall through
       
   300         case EInvalidCurrentTag: /* 702 */
       
   301             {
       
   302             convertedErrorCode = KErrArgument;
       
   303             break;
       
   304             }
       
   305        default:
       
   306             {
       
   307             convertedErrorCode = KErrGeneral;
       
   308             break;
       
   309             }
       
   310         }
       
   311     return convertedErrorCode; 
       
   312     }
       
   313 
       
   314 // --------------------------------------------------------------------------
       
   315 // UPnPAVErrorHandler::ConvertAVTErrorCode
       
   316 // Returns the Symbian error code (e32err.h) corresponding to the 
       
   317 // given AV Transport error code.
       
   318 // --------------------------------------------------------------------------
       
   319 TInt UPnPAVErrorHandler::ConvertAVTErrorCode(
       
   320                               TInt aUPnPErrorCode )
       
   321     {
       
   322     TInt convertedErrorCode = KErrGeneral;
       
   323     switch( aUPnPErrorCode )
       
   324         {
       
   325         case ENoSuchObject: /* 701 */
       
   326             // fall through
       
   327         case ERequiredTag: /* 704 */
       
   328             // fall through
       
   329         case EInvalidSearch: /* 708 */
       
   330             // fall through
       
   331         case ENoContainer: /* 710 */
       
   332             // fall through
       
   333         case EBadMetadata: /* 712 */
       
   334             // fall through
       
   335         case ERestrictedParentObject: /* 713 */
       
   336             // fall through
       
   337         case ENoSourceResource: /* 714 */
       
   338             // fall through
       
   339         case ENoFileTransfer: /* 717 */
       
   340             {
       
   341             convertedErrorCode = KErrNotSupported;
       
   342             break;
       
   343             }
       
   344         case EInvalidCurrentTag: /* 702 */
       
   345             // fall through
       
   346         case ETransferBusy: /* 716 */
       
   347             {
       
   348             convertedErrorCode = KErrNotFound;
       
   349             break;
       
   350             }
       
   351         case EInvalidNewTag: /* 703 */
       
   352             {
       
   353             convertedErrorCode = KErrHardwareNotAvailable;
       
   354             break;
       
   355             }
       
   356         case EReadOnlyTag: /* 705 */
       
   357             {
       
   358             convertedErrorCode = KErrLocked;
       
   359             break;
       
   360             }
       
   361         case EParameterMismatch : /* 706 */
       
   362             {
       
   363             convertedErrorCode = KErrWrite;
       
   364             break;
       
   365             }
       
   366         case EInvalidSort: /* 709 */
       
   367             {
       
   368             convertedErrorCode = KErrDiskFull;
       
   369             break;
       
   370             }
       
   371         case ESourceAccess: /* 715 */
       
   372             {
       
   373             convertedErrorCode = KErrInUse;
       
   374             break;
       
   375             }
       
   376         case ENoDestinationResource: /* 718 */
       
   377             {
       
   378             convertedErrorCode = KErrArgument;
       
   379             break;
       
   380             }
       
   381        default:
       
   382             {
       
   383             convertedErrorCode = KErrGeneral;
       
   384             break;
       
   385             }
       
   386         }
       
   387     return convertedErrorCode;
       
   388     }
       
   389 
       
   390 // --------------------------------------------------------------------------
       
   391 // UPnPAVErrorHandler::ConvertHTTPErrorCode
       
   392 // Returns the Symbian error code (e32err.h) corresponding to the 
       
   393 // given HTTP error code.
       
   394 // --------------------------------------------------------------------------
       
   395 TInt UPnPAVErrorHandler::ConvertHTTPErrorCode(
       
   396                               TInt /*aUPnPErrorCode*/ )
       
   397     {
       
   398     TInt convertedErrorCode = KErrDisconnected;
       
   399         
       
   400     return convertedErrorCode;
       
   401     }
       
   402 
       
   403 // End of File