smsprotocols/smsstack/smsprot/Src/smspmain.cpp
changeset 0 3553901f7fa8
child 19 630d2f34d719
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Implements various functions
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #include <e32std.h>
       
    23 #include "Gsmuelem.h"
       
    24 #include <exterror.h>
       
    25 #include "smspmain.h"
       
    26 #include "smsstacklog.h"
       
    27 
       
    28 
       
    29 /**
       
    30  *  convert an internal EPOC error to an RP specific error
       
    31  *  
       
    32  *  @param aError EPOC specific error
       
    33  *  @return TInt RP specific error
       
    34  */
       
    35 GLREF_C TInt ErrorToRPError(TInt aError)
       
    36 	{
       
    37 	TInt rpError;
       
    38 	//  ETEL extended errors mapping function according to GSM 04.11 also see exterror.h.
       
    39 	//  Internal EPOC errors - currently map only memory related errors are mapped to
       
    40 	//  KErrGsmSMSMemoryCapacityExceeded. All other errors are mapped to
       
    41 	//  KErrGsmSMSUnspecifiedProtocolError.
       
    42 	//  In addition all correct, MT related RL errors, are retained.
       
    43 	switch (aError)
       
    44 		{
       
    45 		case KErrDiskFull:
       
    46 		case KErrNoMemory:
       
    47 			rpError = KErrGsmSMSMemoryCapacityExceeded;
       
    48 			break;
       
    49 
       
    50 		case KErrGsmSMSMemoryCapacityExceeded:
       
    51 		case KErrGsmSMSInvalidShortMessageTransferReferenceValue:
       
    52 		case KErrGsmSMSUnspecifiedInvalidMessage:
       
    53 		case KErrGsmSMSInvalidMandatoryInformation:
       
    54 		case KErrGsmSMSNonExistentMessageType:
       
    55 		case KErrGsmSMSIncompatibleMessageWithSmsProtocolState:
       
    56 		case KErrGsmSMSInformationElementNotImplemented:
       
    57 		case KErrGsmSMSUnspecifiedProtocolError:
       
    58 		    rpError = aError;
       
    59 		    break;
       
    60 
       
    61 		default:
       
    62 			rpError = KErrGsmSMSUnspecifiedProtocolError;
       
    63 			break;
       
    64 		}
       
    65 	LOGSMSPROT3("ErrorToRPError (%d->%d)", aError, rpError);
       
    66 
       
    67 	return rpError;
       
    68 	} // ErrorToRPError
       
    69 
       
    70 
       
    71 /**
       
    72  *  convert an internal EPOC error to an TP specific error
       
    73  *  
       
    74  *  @param aError EPOC specific error
       
    75  *  @return TInt RP specific error
       
    76  */
       
    77 GLREF_C TInt ErrorToTPError(TInt aError)
       
    78     {
       
    79     TInt tpError;
       
    80     //  ETEL errors
       
    81     if( (aError<=KErrGsmSmsBase) && (aError>=KErrGsmSMSUnspecifiedErrorCause) )
       
    82         {
       
    83         tpError = TSmsFailureCause::ESmsErrorErrorInMS;
       
    84         }
       
    85     else
       
    86         {
       
    87         switch (aError)
       
    88             {
       
    89             case KErrDiskFull:
       
    90             case KErrNoMemory:
       
    91                 {
       
    92                 tpError = TSmsFailureCause::ESmsErrorMemoryCapacityExceded;
       
    93                 } break;
       
    94             case KErrNotFound:
       
    95             default:
       
    96                 {
       
    97                 tpError = TSmsFailureCause::ESmsErrorErrorInMS;
       
    98                 } break;
       
    99             }
       
   100         }
       
   101     LOGSMSPROT3("ErrorToTPError (%d->%d)", aError, tpError);
       
   102     return tpError;
       
   103 	}
       
   104 
       
   105 GLREF_C TInt FailureCauseToError(TInt aFailureCause)
       
   106     {
       
   107     TInt error=KErrGsmSmsBase-aFailureCause;
       
   108     return error;
       
   109     }
       
   110 
       
   111 /**
       
   112  *  panic in the SmsProt
       
   113  */
       
   114 GLDEF_C void SmspPanic(TSmspPanic aPanic)
       
   115     {
       
   116     // Ignore in code coverage  - panic method
       
   117     BULLSEYE_OFF
       
   118     LOGSMSPROT2("SMSPPANIC %d", aPanic);
       
   119     _LIT(KSmsprotPanic, "SMSP");
       
   120     User::Panic(KSmsprotPanic,aPanic);
       
   121     BULLSEYE_RESTORE
       
   122     }