realtimenetprots/sipfw/SIP/Server/src/CSipCSReceiveQueue.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2005-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          : CSipCSReceiveQueue.cpp
       
    15 // Part of       : SIPServerCore
       
    16 // Version       : SIP/4.0 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #include "CSipCSReceiveQueue.h"
       
    23 #include "sipmessage.h"
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CSipCSReceiveQueue::CSipCSReceiveQueue
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 CSipCSReceiveQueue::CSipCSReceiveQueue ()
       
    30 	{
       
    31     iReceiveItems.Reset();
       
    32 	}	
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CSipCSReceiveQueue::~CSipCSReceiveQueue
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CSipCSReceiveQueue::~CSipCSReceiveQueue ()
       
    39 	{
       
    40 	while (iReceiveItems.Count() > 0) 
       
    41         {
       
    42         RemoveFirst();
       
    43         }
       
    44 	iReceiveItems.Close();
       
    45 	}
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CSipCSReceiveQueue::IsEmpty
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 TBool CSipCSReceiveQueue::IsEmpty () const
       
    52 	{ 
       
    53 	return (iReceiveItems.Count() == 0); 
       
    54 	}
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CSipCSReceiveQueue::First
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 TSipCSReceiveItem& CSipCSReceiveQueue::First ()
       
    61 	{
       
    62     __ASSERT_ALWAYS (iReceiveItems.Count() > 0, 
       
    63                      User::Panic(KNullDesC, KErrGeneral));
       
    64     return iReceiveItems[0];
       
    65 	}
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CSipCSReceiveQueue::AddLast
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 TInt CSipCSReceiveQueue::AddLast (const TSipCSReceiveItem& aItem)
       
    72     {
       
    73 	return iReceiveItems.Append(aItem);
       
    74     }
       
    75     
       
    76 // -----------------------------------------------------------------------------
       
    77 // CSipCSReceiveQueue::RemoveFirst
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CSipCSReceiveQueue::RemoveFirst ()
       
    81 	{
       
    82 	if (iReceiveItems.Count() > 0) 
       
    83         {
       
    84         TSipCSReceiveItem& item = iReceiveItems[0];
       
    85         delete item.Headers();
       
    86         delete item.Content();
       
    87 	    iReceiveItems.Remove(0);
       
    88         }
       
    89 	}
       
    90 	
       
    91 // -----------------------------------------------------------------------------
       
    92 // CSipCSReceiveQueue::RemoveSIPRequestsWith
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CSipCSReceiveQueue::RemoveSIPRequestsWith (TTransactionId aTransactionId)
       
    96 	{
       
    97 	for (TInt i=iReceiveItems.Count()-1; i>=0; i--)
       
    98 		{
       
    99 		TSipCSReceiveItem& item = iReceiveItems[i];
       
   100 		if (item.Ids().iRequestId ==  aTransactionId && 
       
   101 		    item.ContainsSIPRequest())
       
   102 			{
       
   103         	delete item.Headers();
       
   104         	delete item.Content();
       
   105 	    	iReceiveItems.Remove(i);
       
   106 			}
       
   107 		}
       
   108 	}