networkprotocolmodules/common/suplrrlpasn1/src/rrlpprotocolerror.cpp
branchGCC_SURGE
changeset 49 5f20f71a57a3
parent 41 ec40843d536a
parent 45 15a2125aa2f3
equal deleted inserted replaced
41:ec40843d536a 49:5f20f71a57a3
     1 // Copyright (c) 2008-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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19  
       
    20 */
       
    21 
       
    22 #include "RRLP-Messages.h"
       
    23 #include "rrlpprotocolerror.h"
       
    24 #include "supldevloggermacros.h" 
       
    25 
       
    26 /**
       
    27 Static Factory Constructor
       
    28 */
       
    29 EXPORT_C CRrlpProtocolError* CRrlpProtocolError::NewL(TBool aIsOutgoing)
       
    30 	{
       
    31 	SUPLLOG(ELogP1, "CRrlpProtocolError::NewL() Begin\n");
       
    32 	CRrlpProtocolError* self = new (ELeave) CRrlpProtocolError(aIsOutgoing);
       
    33 	CleanupStack::PushL(self);
       
    34 	self->ConstructL();
       
    35 	SUPLLOG(ELogP1, "CRrlpProtocolError::NewL() End\n");
       
    36 	CleanupStack::Pop(self);
       
    37 	return self;
       
    38 	}
       
    39 
       
    40 
       
    41 /**
       
    42 Private default constructor
       
    43 */
       
    44 CRrlpProtocolError::CRrlpProtocolError(TBool aIsOutgoing)
       
    45  : CRrlpMessageBase(ERrlpProtocolError, aIsOutgoing)
       
    46 	{
       
    47 	}
       
    48 
       
    49 
       
    50 /**
       
    51 Second stage constructor
       
    52 */
       
    53 void CRrlpProtocolError::ConstructL()
       
    54 	{
       
    55 	// call base class ConstructL to create data structures.
       
    56 	CRrlpMessageBase::ConstructL();
       
    57 
       
    58 	// construct messaage specific data 
       
    59 	// containers if this is an outgoing message
       
    60 	if (iIsOutgoingMessage)
       
    61 		{
       
    62 		// local reference to context object
       
    63 		OSCTXT* pctxt = iControl->getCtxtPtr();
       
    64 
       
    65 		iData->component.t = T_RRLP_Component_protocolError;
       
    66 		iData->component.u.protocolError = (ASN1T_ProtocolError*)rtxMemAllocZ(pctxt, sizeof(ASN1T_ProtocolError));
       
    67 	   	LeaveIfAllocErrorL();
       
    68 		}
       
    69 	}
       
    70 
       
    71 
       
    72 /**
       
    73 Destructor
       
    74 */
       
    75 CRrlpProtocolError::~CRrlpProtocolError()
       
    76 	{
       
    77 	SUPLLOG(ELogP1, "CRrlpProtocolError::~CRrlpProtocolError() Begin\n");
       
    78 	SUPLLOG(ELogP1, "CRrlpProtocolError::~CRrlpProtocolError() End\n");
       
    79 	}
       
    80 
       
    81 
       
    82 /** 
       
    83 SetProtocolError()
       
    84 
       
    85 @param  aErrorCode - the outgoing RRLP Protocol error code
       
    86 @return error indication, KErrNone otherwise
       
    87 */
       
    88 EXPORT_C TInt CRrlpProtocolError::SetProtocolError(const TRrlpErrorCode& aErrorCode)
       
    89 	{
       
    90 	SUPLLOG(ELogP8, "CRrlpProtocolError::SetProtocolError() Begin\n");
       
    91 	SUPLLOG2(ELogP8, "    - TRrlpErrorCode aLocError = %d", aErrorCode);
       
    92 	
       
    93 	__ASSERT_DEBUG(iIsOutgoingMessage, User::Invariant());
       
    94 	__ASSERT_DEBUG(iData->component.u.protocolError != NULL, User::Invariant());
       
    95 	
       
    96 	iData->component.u.protocolError->errorCause = aErrorCode;
       
    97 
       
    98 	SUPLLOG(ELogP1, "CRrlpProtocolError::SetProtocolError() End\n");
       
    99 	return KErrNone;
       
   100 	}
       
   101 
       
   102 
       
   103 /** 
       
   104 ProtocolError()
       
   105 
       
   106 @param  aErrorCode on return, populated with the received RRLP Error Code
       
   107 @return error indication, KErrNone otherwise
       
   108 */
       
   109 EXPORT_C TInt CRrlpProtocolError::GetProtocolError(TRrlpErrorCode& aErrorCode)
       
   110 	{
       
   111 	SUPLLOG(ELogP8, "CRrlpProtocolError::ProtocolError() Begin\n");
       
   112 	__ASSERT_DEBUG(!iIsOutgoingMessage, User::Invariant());
       
   113 	__ASSERT_DEBUG(iData->component.u.protocolError != NULL, User::Invariant());
       
   114 	
       
   115 	aErrorCode = (TRrlpErrorCode)iData->component.u.protocolError->errorCause;
       
   116 	
       
   117 	SUPLLOG2(ELogP8, "    - TRrlpErrorCode aLocError = %d", aErrorCode);
       
   118 	SUPLLOG(ELogP1, "CRrlpProtocolError::ProtocolError() End\n");
       
   119 	return KErrNone;
       
   120 	}
       
   121 	
       
   122 	
       
   123 /**
       
   124 GetExtendedReference()
       
   125 
       
   126 Populates aRrlpRef if Rel-5 Extended Reference is present in the received message
       
   127 
       
   128 @param  aRrlpRef local copy of the session reference details
       
   129 @return KErrNotFound if the extended reference parameters are not present,
       
   130         KErrNone otherwise
       
   131 */
       
   132 TInt CRrlpProtocolError::GetExtendedReference(TRrlpReference& aRrlpRef)
       
   133 	{
       
   134 	__ASSERT_DEBUG(iData->component.u.protocolError != NULL, User::Invariant());
       
   135 	
       
   136 	if (iData->component.u.protocolError->m.rel_5_ProtocolError_ExtensionPresent !=0)
       
   137 		{
       
   138 		if (iData->component.u.protocolError->rel_5_ProtocolError_Extension.m.extended_referencePresent !=0)
       
   139 			{
       
   140 			aRrlpRef.aRel5EntendedRefPresent = ETrue;
       
   141 			aRrlpRef.aRel5SmlcCode = iData->component.u.protocolError->rel_5_ProtocolError_Extension.extended_reference.smlc_code;
       
   142 			aRrlpRef.aRel5TransactionId = iData->component.u.protocolError->rel_5_ProtocolError_Extension.extended_reference.transaction_ID;
       
   143 			}
       
   144 		else
       
   145 			{
       
   146 			return KErrNotFound;
       
   147 			}
       
   148 		}
       
   149 	else
       
   150 		{
       
   151 		return KErrNotFound;
       
   152 		}
       
   153 	return KErrNone;
       
   154 	}
       
   155 
       
   156 
       
   157 /**
       
   158 SetExtendedReference()
       
   159 
       
   160 Sets the extended reference parameters in the outgoing message, if they are set
       
   161 in the passed container.
       
   162 
       
   163 @param aRrlpRef on return, populated with the session reference details
       
   164 @return KErrNotFound if no extended reference data is present, 
       
   165 		KErrNone otherwise
       
   166 */	
       
   167 TInt CRrlpProtocolError::SetExtendedReference(const TRrlpReference& aRrlpRef)
       
   168 	{
       
   169 	__ASSERT_DEBUG(iData->component.u.protocolError != NULL, User::Invariant());
       
   170 	
       
   171 	// if present, populate the optional Rel-5 extended reference
       
   172 	if (aRrlpRef.aRel5EntendedRefPresent)
       
   173 		{
       
   174 		// mark the optional component present
       
   175 		iData->component.u.protocolError->m.rel_5_ProtocolError_ExtensionPresent = 1;
       
   176 		iData->component.u.protocolError->rel_5_ProtocolError_Extension.m.extended_referencePresent = 1;
       
   177 		ASN1T_Extended_reference* extendedRef = &iData->component.u.protocolError->rel_5_ProtocolError_Extension.extended_reference;
       
   178 		extendedRef->smlc_code = aRrlpRef.aRel5SmlcCode;
       
   179 		extendedRef->transaction_ID = aRrlpRef.aRel5TransactionId;
       
   180 		}
       
   181 	else
       
   182 		{
       
   183 		return KErrNotFound;
       
   184 		}
       
   185 	
       
   186 	return KErrNone;
       
   187 	}
       
   188 	
       
   189