mmserv/voipaudioservices/VoIPServer/src/VoIPQueueHandlerSrv.cpp
changeset 0 71ca22bcf22a
child 3 4f62049db6ac
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2  * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  Implements message queue handler for handling messages
       
    15  *                passed between VoIPAudioServices threads.
       
    16  *
       
    17  */
       
    18 
       
    19 #include <voipaudiocommon.h>
       
    20 #include "VoIPSharedData.h"
       
    21 #include "VoIPQueueHandlerSrv.h"
       
    22 
       
    23 // ----------------------------------------------------------------------------
       
    24 // CQueueHandlerSrv::NewL
       
    25 // Symbian constructor
       
    26 // ----------------------------------------------------------------------------
       
    27 //
       
    28 CQueueHandlerSrv* CQueueHandlerSrv::NewL(MQueueHandlerObserverSrv* aObserver,
       
    29         RMsgQueue<TVoIPMsgBuf>* aMsgQueue)
       
    30     {
       
    31     CQueueHandlerSrv* self = new (ELeave) CQueueHandlerSrv(aMsgQueue);
       
    32     CleanupStack::PushL(self);
       
    33     self->ConstructL(aObserver);
       
    34     CleanupStack::Pop(self);
       
    35     return self;
       
    36     }
       
    37 
       
    38 // ----------------------------------------------------------------------------
       
    39 // CQueueHandlerSrv::ConstructL
       
    40 // Second phase constructor.
       
    41 // ----------------------------------------------------------------------------
       
    42 //
       
    43 void CQueueHandlerSrv::ConstructL(MQueueHandlerObserverSrv* aObserver)
       
    44     {
       
    45     iObserver = aObserver;
       
    46     }
       
    47 
       
    48 // ----------------------------------------------------------------------------
       
    49 // CQueueHandlerSrv::~CQueueHandlerSrv
       
    50 // Destructor.
       
    51 // ----------------------------------------------------------------------------
       
    52 //
       
    53 CQueueHandlerSrv::~CQueueHandlerSrv()
       
    54     {
       
    55     Cancel();
       
    56     }
       
    57 
       
    58 // ----------------------------------------------------------------------------
       
    59 // CQueueHandlerSrv::~CQueueHandlerSrv
       
    60 // Destructor.
       
    61 // ----------------------------------------------------------------------------
       
    62 //
       
    63 CQueueHandlerSrv::CQueueHandlerSrv(RMsgQueue<TVoIPMsgBuf>* aMsgQueue) :
       
    64     CActive(CActive::EPriorityStandard),
       
    65     //  CActive(CActive::EPriorityHigh),
       
    66     iMsgQueue(aMsgQueue)
       
    67     {
       
    68     CActiveScheduler::Add(this);
       
    69     }
       
    70 
       
    71 // ----------------------------------------------------------------------------
       
    72 // CQueueHandlerSrv::Start
       
    73 // Start listening for events on queue 0.
       
    74 // ----------------------------------------------------------------------------
       
    75 //
       
    76 void CQueueHandlerSrv::Start()
       
    77     {
       
    78     if (!IsActive())
       
    79         {
       
    80         iMsgQueue->NotifyDataAvailable(iStatus);
       
    81         SetActive();
       
    82         }
       
    83     }
       
    84 
       
    85 // ----------------------------------------------------------------------------
       
    86 // CQueueHandlerSrv::DoCancel
       
    87 // Cancel outstanding request
       
    88 // ----------------------------------------------------------------------------
       
    89 //
       
    90 void CQueueHandlerSrv::DoCancel()
       
    91     {
       
    92     iMsgQueue->CancelDataAvailable();
       
    93     }
       
    94 
       
    95 // ----------------------------------------------------------------------------
       
    96 // CQueueHandlerSrv::RunL
       
    97 // Process requests.
       
    98 // ----------------------------------------------------------------------------
       
    99 //
       
   100 void CQueueHandlerSrv::RunL()
       
   101     {
       
   102     TVoIPMsgBuf msgBuf;
       
   103     TInt err = iMsgQueue->Receive(msgBuf);
       
   104 
       
   105     if (err == KErrNone)
       
   106         {
       
   107         iObserver->Event(msgBuf.iRequest, msgBuf.iStatus);
       
   108         }
       
   109 
       
   110     Start();
       
   111     }
       
   112 
       
   113 // ----------------------------------------------------------------------------
       
   114 // CQueueHandlerSrv::RunError
       
   115 // Process requests.
       
   116 // ----------------------------------------------------------------------------
       
   117 //
       
   118 TInt CQueueHandlerSrv::RunError(TInt aError)
       
   119     {
       
   120     // RunL can actually leave if any iObserver->Event leave is not trapped
       
   121     //    iObserver->Event(ECmdGeneralError, aError);
       
   122     return aError;
       
   123     }
       
   124 
       
   125 // ----------------------------------------------------------------------------
       
   126 // CQueueHandlerSrv::Status
       
   127 // Return request status.
       
   128 // ----------------------------------------------------------------------------
       
   129 //
       
   130 TRequestStatus* CQueueHandlerSrv::Status()
       
   131     {
       
   132     return &iStatus;
       
   133     }
       
   134 
       
   135 // End of File