accessoryservices/remotecontrolfw/server/src/messagerecipients.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-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  @internalComponent
       
    19 */
       
    20 
       
    21 #include "messagerecipients.h"
       
    22 #include <bluetooth/logger.h>
       
    23 
       
    24 #ifdef __FLOG_ACTIVE
       
    25 _LIT8(KLogComponent, LOG_COMPONENT_REMCON_SERVER);
       
    26 #endif
       
    27 
       
    28 CMessageRecipients* CMessageRecipients::NewL()
       
    29 	{
       
    30 	LOG_STATIC_FUNC
       
    31 	return new(ELeave) CMessageRecipients();
       
    32 	}
       
    33 
       
    34 CMessageRecipients::CMessageRecipients()
       
    35 :	iClientInfo(_FOFF(TClientInfo, iLink)),
       
    36 	iIter(iClientInfo),
       
    37 	iConstIter(iClientInfo)
       
    38 	{
       
    39 	LOG_FUNC
       
    40 	}
       
    41 
       
    42 CMessageRecipients::~CMessageRecipients()
       
    43 	{
       
    44 	LOG_FUNC
       
    45 	iIter.SetToFirst();
       
    46 	TClientInfo* client;
       
    47 	while ((client = iIter++) != NULL)
       
    48 		{
       
    49 		iClientInfo.Remove(*client);
       
    50 		delete client;
       
    51 		}
       
    52 	}
       
    53 
       
    54 TUint& CMessageRecipients::TransactionId()
       
    55 	{
       
    56 	return iTransactionId;
       
    57 	}
       
    58 
       
    59 TSglQue<TClientInfo>& CMessageRecipients::Clients()
       
    60 	{
       
    61 	return iClientInfo;
       
    62 	}
       
    63 
       
    64 TClientInfoConstIter& CMessageRecipients::ConstIter()
       
    65 	{
       
    66 	return iConstIter;
       
    67 	}
       
    68 
       
    69 void CMessageRecipients::RemoveAndDestroyClient(const TClientInfo& aClientInfo)
       
    70 	{
       
    71 	iIter.SetToFirst();
       
    72 	TClientInfo* client;
       
    73 	while ((client = iIter++) != NULL)
       
    74 		{
       
    75 		if (client->ProcessId() == aClientInfo.ProcessId() && client->SecureId() == aClientInfo.SecureId())
       
    76 			{
       
    77 			iClientInfo.Remove(*client);
       
    78 			delete client;
       
    79 			}
       
    80 		}
       
    81 	}
       
    82 
       
    83 CMessageRecipientsList* CMessageRecipientsList::NewL()
       
    84 	{
       
    85 	return new(ELeave) CMessageRecipientsList();
       
    86 	}
       
    87 
       
    88 CMessageRecipientsList::CMessageRecipientsList()
       
    89 	:iMessages(_FOFF(CMessageRecipients, iLink)),
       
    90 	iIter(iMessages)
       
    91 	{
       
    92 	}
       
    93 
       
    94 CMessageRecipientsList::~CMessageRecipientsList()
       
    95 	{
       
    96 	iIter.SetToFirst();
       
    97 	CMessageRecipients* message;
       
    98 	while ((message = iIter++) != NULL)
       
    99 		{
       
   100 		iMessages.Remove(*message);
       
   101 		delete message;
       
   102 		}
       
   103 	}
       
   104 
       
   105 TSglQue<CMessageRecipients>& CMessageRecipientsList::Messages()
       
   106 	{
       
   107 	return iMessages;
       
   108 	}
       
   109 
       
   110 TSglQueIter<CMessageRecipients>& CMessageRecipientsList::Iter()
       
   111 	{
       
   112 	return iIter;
       
   113 	}
       
   114 
       
   115 void CMessageRecipientsList::RemoveAndDestroyMessage(const TUint aTransactionId)
       
   116 	{
       
   117 	iIter.SetToFirst();
       
   118 	CMessageRecipients* message;
       
   119 	while ((message = iIter++) != NULL)
       
   120 		{
       
   121 		if (message->TransactionId() == aTransactionId)
       
   122 			{
       
   123 			iMessages.Remove(*message);
       
   124 			delete message;
       
   125 			}
       
   126 		}
       
   127 	}
       
   128 
       
   129 CMessageRecipients* CMessageRecipientsList::Message(TUint aTransactionId)
       
   130 	{
       
   131 	iIter.SetToFirst();
       
   132 	CMessageRecipients* message;
       
   133 	while ((message = iIter++) != NULL)
       
   134 		{
       
   135 		if (message->TransactionId() == aTransactionId)
       
   136 			{
       
   137 			break;
       
   138 			}
       
   139 		}
       
   140 	return message;
       
   141 	}