accessoryservices/remotecontrolfw/server/src/server.cpp
branchRCL_3
changeset 22 8cb079868133
parent 21 ccb4f6b3db21
equal deleted inserted replaced
21:ccb4f6b3db21 22:8cb079868133
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
  1738 	LOG_FUNC;
  1738 	LOG_FUNC;
  1739 	LOGINCOMINGPENDINGDELIVERY;
  1739 	LOGINCOMINGPENDINGDELIVERY;
  1740 	LOGINCOMINGDELIVERED;
  1740 	LOGINCOMINGDELIVERED;
  1741 	TInt err = KErrNone;
  1741 	TInt err = KErrNone;
  1742 
  1742 
  1743 	// First off check if the client supports this
  1743 	if ( aSess.ClientAvailable() )
  1744 	if(!aSess.SupportedMessage(aMsg))
  1744 		{
  1745         {
  1745 		// First off check if the client supports this
  1746         err = KErrArgument;
  1746 		if(!aSess.SupportedMessage(aMsg))
  1747         
  1747 			{
  1748         // 'Take ownership' of it by destroying it- it's finished with.
  1748 			err = KErrArgument;
  1749         delete &aMsg;
  1749 
  1750         }
  1750 			// 'Take ownership' of it by destroying it- it's finished with.
  1751 	else if ( aSess.CurrentReceiveMessage().Handle() )
  1751 			delete &aMsg;
  1752 		{
  1752 			}
  1753 		// If the client can take the message now put it on the right queue.
  1753 		else if ( aSess.CurrentReceiveMessage().Handle() )
  1754 
  1754 			{
  1755 		err = aSess.WriteMessageToClient (aMsg);
  1755 			// If the client can take the message now put it on the right queue.
  1756 		// If the message was a command, and it was delivered with no error, 
  1756 
  1757 		// then put it in the 'incoming delivered' log. Otherwise, delete it 
  1757 			err = aSess.WriteMessageToClient (aMsg);
  1758 		// because it's finished with.
  1758 			// If the message was a command, and it was delivered with no error,
  1759 		if ((aMsg.MsgType() == ERemConCommand) || (aMsg.MsgType() == ERemConNotifyCommand))
  1759 			// then put it in the 'incoming delivered' log. Otherwise, delete it
  1760 			{
  1760 			// because it's finished with.
  1761 			if (err == KErrNone )
  1761 			if ((aMsg.MsgType() == ERemConCommand) || (aMsg.MsgType() == ERemConNotifyCommand))
  1762 				{
  1762 				{
  1763 				// We'll need to remember it for the response coming back.
  1763 				if (err == KErrNone )
  1764 				IncomingDelivered().Append(aMsg); 
  1764 					{
       
  1765 					// We'll need to remember it for the response coming back.
       
  1766 					IncomingDelivered().Append(aMsg);
       
  1767 					}
       
  1768 				else
       
  1769 					{
       
  1770 					// 'Take ownership' of it by destroying it- it's finished with.
       
  1771 					delete &aMsg;
       
  1772 					}
  1765 				}
  1773 				}
  1766 			else
  1774 			else
  1767 				{
  1775 				{
  1768 				// 'Take ownership' of it by destroying it- it's finished with.
  1776 				// 'Take ownership' of it by destroying it- it's finished with.
  1769 				delete &aMsg;
  1777 				delete &aMsg;
  1770 				}
  1778 				}
  1771 			}
  1779 			}
  1772 		else
  1780 		else
  1773 			{
  1781 			{
  1774 			// 'Take ownership' of it by destroying it- it's finished with.			
  1782 			IncomingPendingDelivery().Append(aMsg);
  1775 			delete &aMsg;
       
  1776 			}
  1783 			}
  1777 		}
  1784 		}
  1778 	else
  1785 	else
  1779 		{
  1786 		{
       
  1787 		// The client has not yet registered the interfaces they're interested
       
  1788 		// in, so put the message on the incoming pending delivery queue until
       
  1789 		// they do.
       
  1790 		// Return KErrNone to avoid sending a reject. We're assuming that the
       
  1791 		// client will eventually successfully receive the message, as we
       
  1792 		// don't have a better basis on which to operate. This is identical to
       
  1793 		// the case where a client doesn't have an outstanding receive request
       
  1794 		// at this time.
  1780 		IncomingPendingDelivery().Append(aMsg);
  1795 		IncomingPendingDelivery().Append(aMsg);
  1781 		}
  1796 		}
  1782 	
  1797 	
  1783 	LOGINCOMINGPENDINGDELIVERY;
  1798 	LOGINCOMINGPENDINGDELIVERY;
  1784 	LOGINCOMINGDELIVERED;
  1799 	LOGINCOMINGDELIVERED;