mmsharing/livecommsui/lcui/tsrc/ipvtengine/src/mccdatareceiver.cpp
branchRCL_3
changeset 23 bc78a40cd63c
parent 22 73a1feb507fb
child 24 6c57ef9392d2
equal deleted inserted replaced
22:73a1feb507fb 23:bc78a40cd63c
     1 /*
       
     2 * Copyright (c) 2006 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:  
       
    15 *
       
    16 */
       
    17 
       
    18         
       
    19 // INCLUDE FILES
       
    20 #include "mccdatareceiver.h"
       
    21 
       
    22 
       
    23 // ============================ MEMBER FUNCTIONS ===============================
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CMccDataReceiver::CMccDataReceiver
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 CMccDataReceiver::CMccDataReceiver( MMccDataReceiverObserver& aObserver )
       
    30 	: CActive( EPriorityStandard ), iObserver( &aObserver )
       
    31 	{
       
    32 	CActiveScheduler::Add(this);
       
    33 	}
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CMccDataReceiver::ConstructL
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 void CMccDataReceiver::ConstructL()
       
    40     {
       
    41 
       
    42     TInt err = iMsgQueue.CreateGlobal(_L("IP-VT-Queue2"), 5, EOwnerProcess );
       
    43     if ( err )
       
    44         {
       
    45         User::LeaveIfError( iMsgQueue.OpenGlobal(_L("IP-VT-Queue2")));
       
    46         }
       
    47 
       
    48     iMsgQueue.ReceiveBlocking( iInitData );
       
    49 
       
    50     iMsgQueue.NotifyDataAvailable( iStatus );
       
    51     SetActive();
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CMccDataReceiver::NewL
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CMccDataReceiver* CMccDataReceiver::NewL( MMccDataReceiverObserver& aObserver )
       
    59     {
       
    60     CMccDataReceiver* self = 
       
    61     	new ( ELeave ) CMccDataReceiver( aObserver );
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop( self );
       
    65     return self;
       
    66     }
       
    67 	
       
    68 // -----------------------------------------------------------------------------
       
    69 // CMccDataReceiver::~CMccDataReceiver
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CMccDataReceiver::~CMccDataReceiver()
       
    73     {
       
    74     Cancel();
       
    75 	iMsgQueue.Close();
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CMccDataReceiver::DoCancel
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void CMccDataReceiver::DoCancel()
       
    83 	{
       
    84 	iMsgQueue.CancelDataAvailable();	
       
    85 	}
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CMccDataReceiver::RunL
       
    89 // -----------------------------------------------------------------------------
       
    90 //	
       
    91 void CMccDataReceiver::RunL()
       
    92 	{
       
    93 	TDataMessage buffer;
       
    94 	iMsgQueue.Receive( buffer );
       
    95 	iObserver->DataReceived( buffer );
       
    96         iMsgQueue.NotifyDataAvailable( iStatus );
       
    97         SetActive();
       
    98 	}
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CMccDataReceiver::RunError
       
   102 // -----------------------------------------------------------------------------
       
   103 //	
       
   104 TInt CMccDataReceiver::RunError(TInt /*aError*/)
       
   105 	{
       
   106 	return KErrNone;
       
   107 	}