zeroconf/server/src/cinternalmessagequeue.cpp
changeset 14 da856f45b798
equal deleted inserted replaced
12:78fbd574edf4 14:da856f45b798
       
     1 // Copyright (c) 2008-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 // cinternalmessagequeue.cpp
       
    15 // 
       
    16 //
       
    17 /**
       
    18 @file
       
    19 @internalTechnology
       
    20 */
       
    21 //User include
       
    22 #include "cinternalmessagequeue.h"
       
    23 #include "mdnsserver.h"
       
    24 __FLOG_STMT(_LIT8(KComponent,"MDNSServer");)
       
    25 /*
       
    26  * Two phase constructor
       
    27  * @param aServer reference to the server
       
    28  */
       
    29 CInternalMessageQueue* CInternalMessageQueue::NewL(CMdnsServer& aServer)
       
    30     {
       
    31     CInternalMessageQueue* self = new (ELeave)CInternalMessageQueue(aServer);
       
    32     CleanupStack::PushL(self);
       
    33     self->ConstructL();
       
    34     CleanupStack::Pop();//self
       
    35     return self;
       
    36     }
       
    37 
       
    38 //Destructor
       
    39 CInternalMessageQueue:: ~CInternalMessageQueue()
       
    40     {
       
    41     __FLOG(_L8("CInternalMessageQueue::~CInternalMessageQueue - Exit"));
       
    42     __FLOG_CLOSE;
       
    43     }
       
    44  
       
    45 /*
       
    46  * When this is called reads the first request form the 
       
    47  * queue and start processing.
       
    48  */
       
    49 void CInternalMessageQueue::StartProcessing()
       
    50     {
       
    51     __FLOG(_L8("CInternalMessageQueue::StartProcessing - Entry"));
       
    52     if(iMessageQueue.Count() == 0)
       
    53         {
       
    54         return;
       
    55         }
       
    56     else
       
    57         {
       
    58         TMessageObject message = iMessageQueue[0];
       
    59         iServer.ProcessQueuedMessage(message.MessageObject(),message.Type(),message.SessionId());
       
    60         iMessageQueue.Remove(0);
       
    61         }
       
    62     __FLOG(_L8("CInternalMessageQueue::StartProcessing - Exit"));
       
    63     }
       
    64 
       
    65 /*
       
    66  * @return count returns the count of messageQueue
       
    67  */
       
    68 
       
    69 TInt CInternalMessageQueue::Count()
       
    70     {
       
    71     __FLOG(_L8("CInternalMessageQueue::Count - Entry Exit"));
       
    72     return iMessageQueue.Count();
       
    73     }
       
    74  
       
    75 /*
       
    76  * Interface to append the message to the queue
       
    77  * @param aType represents the type of message.
       
    78  * @param aMessage RMessage object of the query or publish request.
       
    79  * @param aSessionId session to which request is made.
       
    80  */
       
    81 void CInternalMessageQueue::AppendMessageL(TMessageType aType, const RMessage2& aMessage,TInt aSessionId )
       
    82     {
       
    83     __FLOG(_L8("CInternalMessageQueue::AppendMessageL - Entry"));
       
    84     TMessageObject messageObject(aType,aMessage,aSessionId);
       
    85     iMessageQueue.AppendL(messageObject);
       
    86     __FLOG(_L8("CInternalMessageQueue::AppendMessageL - Exit"));
       
    87     }
       
    88 
       
    89 /*
       
    90  * Two phase constructor.
       
    91  */
       
    92 void CInternalMessageQueue::ConstructL()
       
    93     {
       
    94     __FLOG_OPEN(KMDNSSubsystem, KComponent);  
       
    95     __FLOG(_L8("CInternalMessageQueue::ConstructL -Entry  Exit"));
       
    96     }
       
    97 
       
    98 /*
       
    99  * Constructor
       
   100  * @param aServer reference to the server.
       
   101  */
       
   102 CInternalMessageQueue::CInternalMessageQueue(CMdnsServer& aServer): iServer(aServer)
       
   103     {
       
   104     
       
   105     }
       
   106