realtimenetprots/sipfw/SIP/SIPSec/IpSecPlugin/src/CSipSecSaDbMsgSender.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2004-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 // Name          : CSipSecSaDbMsgSender.cpp
       
    15 // Part of       : SIPSec
       
    16 // Version       : SIP/4.0 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include <pfkey_send.h>
       
    22 #include "CSipSecSaDbMsgSender.h"
       
    23 #include "MSipSecSaDbSendReceiveObserver.h"
       
    24 
       
    25 // ----------------------------------------------------------------------------
       
    26 // CSipSecSaDbMsgSender::NewL
       
    27 // ----------------------------------------------------------------------------
       
    28 //
       
    29 CSipSecSaDbMsgSender* CSipSecSaDbMsgSender::NewL(
       
    30 	MSipSecSaDbSendReceiveObserver& aObserver, 
       
    31 	RSADB& aSadb )
       
    32 	{
       
    33 	CSipSecSaDbMsgSender* 
       
    34 		self = CSipSecSaDbMsgSender::NewLC( aObserver, aSadb );
       
    35 	CleanupStack::Pop( self );
       
    36 	return self;
       
    37 	}
       
    38 	
       
    39 // ----------------------------------------------------------------------------
       
    40 // CSipSecSaDbMsgSender::NewLC
       
    41 // ----------------------------------------------------------------------------
       
    42 //
       
    43 CSipSecSaDbMsgSender* CSipSecSaDbMsgSender::NewLC(
       
    44 	MSipSecSaDbSendReceiveObserver& aObserver, 
       
    45 	RSADB& aSadb )
       
    46 	{
       
    47 	CSipSecSaDbMsgSender* 
       
    48 		self = new (ELeave) CSipSecSaDbMsgSender( aObserver, aSadb );
       
    49 	CleanupStack::PushL( self );
       
    50 	self->ConstructL();
       
    51 	return self;
       
    52 	}
       
    53 
       
    54 // ----------------------------------------------------------------------------
       
    55 // CSipSecSaDbMsgSender::CSipSecSaDbMsgSender
       
    56 // ----------------------------------------------------------------------------
       
    57 //
       
    58 CSipSecSaDbMsgSender::CSipSecSaDbMsgSender( 
       
    59 	MSipSecSaDbSendReceiveObserver& aObserver, 
       
    60 	RSADB& aSadb ) :
       
    61 	CSipSecSaDbMsgTransport( aObserver, aSadb )
       
    62 	{
       
    63 	}
       
    64 	
       
    65 // ----------------------------------------------------------------------------
       
    66 // CSipSecSaDbMsgSender::~CSipSecSaDbMsgSender
       
    67 // ----------------------------------------------------------------------------
       
    68 //
       
    69 CSipSecSaDbMsgSender::~CSipSecSaDbMsgSender()
       
    70 	{
       
    71 	Cancel();
       
    72 	}
       
    73 
       
    74 // ----------------------------------------------------------------------------
       
    75 // CSipSecSaDbMsgSender::SendL
       
    76 // ----------------------------------------------------------------------------
       
    77 //
       
    78 void CSipSecSaDbMsgSender::SendL( TPfkeySendMsgBase* aMessage, TInt aMsgType )
       
    79 	{
       
    80 	__ASSERT_ALWAYS( !IsActive(), User::Leave( KErrInUse ) );
       
    81 	
       
    82 	// Sender takes ownership of aMessage
       
    83 	StoreMessageL( aMessage, aMsgType ); 
       
    84 	iSaDb.FinalizeAndSend( *iMsg, iStatus );
       
    85 	SetActive();
       
    86 	}
       
    87 
       
    88 // ----------------------------------------------------------------------------
       
    89 // CSipSecSaDbMsgSender::RunL
       
    90 // ----------------------------------------------------------------------------
       
    91 //
       
    92 void CSipSecSaDbMsgSender::RunL()
       
    93 	{
       
    94     RemoveMessage();
       
    95 	iObserver.MessageSentL( iStatus.Int(), iMsgType );
       
    96 	}
       
    97 	
       
    98 // -----------------------------------------------------------------------------
       
    99 // CSipSecSaDbMsgSender::RunError
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 TInt CSipSecSaDbMsgSender::RunError( TInt aError )
       
   103 	{
       
   104 	if ( aError != KErrNoMemory )
       
   105 		{
       
   106 		return KErrNone;
       
   107 		}
       
   108 	return aError;
       
   109 	}
       
   110 
       
   111 // ----------------------------------------------------------------------------
       
   112 // CSipSecSaDbMsgSender::DoCancel
       
   113 // ----------------------------------------------------------------------------
       
   114 //
       
   115 void CSipSecSaDbMsgSender::DoCancel()
       
   116 	{
       
   117 	iSaDb.CancelSend();
       
   118 	RemoveMessage();
       
   119 	}
       
   120 
       
   121 // ----------------------------------------------------------------------------
       
   122 // CSipSecSaDbMsgSender::StoreMessageL
       
   123 // ----------------------------------------------------------------------------
       
   124 //	
       
   125 void CSipSecSaDbMsgSender::StoreMessageL( 
       
   126     TPfkeySendMsgBase* aMessage, 
       
   127     TInt aMsgType )
       
   128     {
       
   129     __ASSERT_ALWAYS( aMessage, User::Leave( KErrArgument ) );
       
   130     
       
   131     RemoveMessage();
       
   132     iMsg = aMessage;
       
   133     iMsgType = aMsgType;
       
   134     }
       
   135 // ----------------------------------------------------------------------------
       
   136 // CSipSecSaDbMsgSender::RemoveMessage
       
   137 // ----------------------------------------------------------------------------
       
   138 //	
       
   139 void CSipSecSaDbMsgSender::RemoveMessage()
       
   140     {
       
   141     delete iMsg;
       
   142     iMsg = 0;
       
   143     }
       
   144 	
       
   145 // End of File