omasuplasnconverterstubimpl/src/asnimplementationbase.cpp
changeset 0 0ce1b5ce9557
equal deleted inserted replaced
-1:000000000000 0:0ce1b5ce9557
       
     1 /*
       
     2 * Copyright (c) 2009 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: Implementation of ASN plugin
       
    15 *
       
    16 */
       
    17 
       
    18 #include "asnimplementationbase.h"
       
    19 #include <e32base.h>
       
    20 #include "epos_comasuplstart.h"
       
    21 #include "epos_comasuplresponse.h"
       
    22 #include "epos_comasuplposinit.h"
       
    23 #include "epos_comasuplpos.h"
       
    24 #include "epos_comasuplinit.h"
       
    25 #include "epos_comasuplend.h"
       
    26 #include "epos_comasuplauthrequest.h"
       
    27 #include "epos_comasuplauthresponse.h"
       
    28 #include "cstubsuplstart.h"
       
    29 #include "cstubsuplresponse.h"
       
    30 #include "cstubsuplposinit.h"
       
    31 #include "cstubsuplpos.h"
       
    32 #include "cstubsuplinit.h"
       
    33 #include "cstubsuplend.h"
       
    34 #include "cstubsuplauthrequest.h"
       
    35 #include "cstubsuplauthresponse.h"
       
    36 
       
    37 CAsnImplementationBase::CAsnImplementationBase()
       
    38     {
       
    39     
       
    40     }
       
    41 // -----------------------------------------------------------------------------
       
    42 // CAsnImplementationBase::NewL
       
    43 // Other Items were commented in a header
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 EXPORT_C CAsnImplementationBase* CAsnImplementationBase::NewL()
       
    47     {
       
    48     CAsnImplementationBase* self = new (ELeave) CAsnImplementationBase;
       
    49     CleanupStack::PushL(self);
       
    50     self->ConstructL();
       
    51     CleanupStack::Pop();
       
    52     return self;
       
    53     }
       
    54 // -----------------------------------------------------------------------------
       
    55 // CAsnImplementationBase::EncodeL
       
    56 // Other Items were commented in a header
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 HBufC8* CAsnImplementationBase::EncodeL(COMASuplAsnMessageBase* asnMessage, TInt& aErrorCode)
       
    60     {
       
    61     //Initialize your library for encoding...
       
    62     
       
    63     //Encoding operations to be done here!!
       
    64     HBufC8* encodedBuffer;
       
    65     if ( asnMessage )
       
    66         encodedBuffer = asnMessage->EncodeL(aErrorCode);
       
    67     else 
       
    68         encodedBuffer = NULL;
       
    69         
       
    70     return encodedBuffer;
       
    71     }
       
    72 // -----------------------------------------------------------------------------
       
    73 // CAsnImplementationBase::DecodeL
       
    74 // Other Items were commented in a header
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 COMASuplAsnMessageBase* CAsnImplementationBase::DecodeL(const TPtrC8& /*aPacket*/,TInt& aErrorCode,TInt& aUnConsumedBytes )
       
    78     {
       
    79     COMASuplAsnMessageBase* self = NULL;
       
    80     aErrorCode = 0;
       
    81     aUnConsumedBytes = 0;
       
    82     
       
    83 		//Decoding operations to be done here!!!
       
    84 		//Here you will have to decode the buffer using your own ASN library and return the object of appropriate SUPL message class.
       
    85 		//e.g. if you finds that decoded message is SUPL_RESPONSE,create object of SUPL_RESPONSE class and call appropriate set methods to fill its all mandatory 
       
    86 		//and optional methods. For demostration purpose, here are some set methods for SUPL_RESPONSE
       
    87 		//
       
    88 		//CStubSuplResponse* lOMASuplResponse = CStubSuplResponse::NewL();
       
    89 		//CleanupStack::PushL(lOMASuplResponse);			
       
    90 		//TOMASuplVersion lVersion;
       
    91 		//TInt lMajor = 1;
       
    92 		//TInt lMinor = 0;
       
    93 		//TInt lServInd; = 0;
       
    94 		//lVersion.SetSuplVersion(lMajor,lMinor,lServInd);
       
    95 		//COMASuplSessionID* lSessionId = COMASuplSessionID::NewL();//Set all parameters needed for session id.
       
    96 		//lOMASuplResponse->SetMessageBase(lVersion, lSessionId);
       
    97 		//lOMASuplResponse->SetMessageLength(20);
       
    98 		//TInt lPosMethod = 1;
       
    99 		//lOMASuplResponse->SetSuplResponse((TOMASuplPosMethod)lPosMethod);
       
   100 		//CleanupStack::Pop();
       
   101 		//aErrorCode = KErrNone;
       
   102 		//aUnConsumedBytes  = 0;
       
   103 		// return lOMASuplResponse;
       
   104 
       
   105     return self;
       
   106     }
       
   107 // -----------------------------------------------------------------------------
       
   108 // CAsnImplementationBase::CreateOMASuplMessageL
       
   109 // Other Items were commented in a header
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 COMASuplAsnMessageBase* CAsnImplementationBase::CreateOMASuplMessageL(COMASuplAsnMessageBase::TSuplMessageType aOMASuplMessageType)
       
   113     {
       
   114     COMASuplAsnMessageBase* suplMsg = NULL;
       
   115     // Creating operations!!
       
   116     switch ( aOMASuplMessageType )
       
   117         {
       
   118         case COMASuplAsnMessageBase::ESUPL_START :
       
   119             {
       
   120             suplMsg = CStubSuplStart::NewL();
       
   121             break;
       
   122             }
       
   123         case COMASuplAsnMessageBase::ESUPL_RESPONSE :
       
   124             {
       
   125             suplMsg = CStubSuplResponse::NewL();
       
   126             break;
       
   127             }
       
   128         case COMASuplAsnMessageBase::ESUPL_POSINIT :
       
   129             {
       
   130             suplMsg = CStubSuplPosInit::NewL();
       
   131             break;
       
   132             }
       
   133         case COMASuplAsnMessageBase::ESUPL_POS :
       
   134             {
       
   135             suplMsg = CStubSuplPos::NewL();
       
   136             break;
       
   137             }
       
   138         case COMASuplAsnMessageBase::ESUPL_INIT : 
       
   139             {
       
   140             suplMsg = CStubSuplInit::NewL();
       
   141             break;
       
   142             }
       
   143         case COMASuplAsnMessageBase::ESUPL_END :
       
   144             {
       
   145             suplMsg = CStubSuplEnd::NewL();
       
   146             break;
       
   147             }
       
   148         case COMASuplAsnMessageBase::ESUPL_AUTH_REQ :
       
   149             {
       
   150             suplMsg = CStubSuplAuthRequest::NewL();
       
   151             break;
       
   152             }
       
   153         case COMASuplAsnMessageBase::ESUPL_AUTH_RESP :
       
   154             {
       
   155             suplMsg = CStubSuplAuthResponse::NewL();
       
   156             break;
       
   157             }
       
   158         default : break ;
       
   159         }
       
   160     return suplMsg;
       
   161     }
       
   162 // -----------------------------------------------------------------------------
       
   163 // CAsnImplementationBase::~CAsnImplementationBase
       
   164 // Other Items were commented in a header
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 CAsnImplementationBase::~CAsnImplementationBase()
       
   168     {
       
   169     
       
   170     }
       
   171 // -----------------------------------------------------------------------------
       
   172 // CAsnImplementationBase::ConstructL
       
   173 // Other Items were commented in a header
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 void CAsnImplementationBase::ConstructL()
       
   177     {
       
   178     }
       
   179 
       
   180 TOMASuplVersion CAsnImplementationBase::GetSuplMessageVersionL(TInt& aErrorCode,const TPtrC8& aSuplAsnMessage)
       
   181 	{
       
   182 	TOMASuplVersion version;
       
   183 	return version;
       
   184 	}