multimediacommsengine/mmcecli/src/mcefcmsgexchange.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 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 
       
    20 
       
    21 #include "mcefcmsgexchange.h"
       
    22 #include "mcemanager.h"
       
    23 #include "mceitcsender.h"
       
    24 #include "mceserial.h"
       
    25 
       
    26 EXPORT_C CMceFcMsgExchange* CMceFcMsgExchange::NewL(
       
    27 				CMceManager& aManager,
       
    28 				const TDesC8& aType)
       
    29 	{
       
    30     CMceFcMsgExchange* self = new (ELeave) CMceFcMsgExchange(aManager);
       
    31     CleanupStack::PushL(self);
       
    32     self->ConstructL(aType);
       
    33     CleanupStack::Pop(self);
       
    34     return self;
       
    35 	}
       
    36         
       
    37 CMceFcMsgExchange::~CMceFcMsgExchange()
       
    38 	{
       
    39 	delete iType;
       
    40 	}
       
    41 
       
    42 EXPORT_C void CMceFcMsgExchange::InitializeL(
       
    43 	CMceSession& aSession, TInt aPort, MMceFcMsgObserver& aObserver)
       
    44 	{
       
    45 	aSession.SetFCObserver(&aObserver);
       
    46     
       
    47     TMceIds ids;
       
    48 	ids.iAppUID = iManager.AppUid().iUid;
       
    49 	ids.iSessionID = aSession.Id();
       
    50     
       
    51 	ids.Set( KMceIdsIndexFCPort, aPort );
       
    52 	    
       
    53 	if(aSession.iFlatData->iType == CMceComSession::EOutSession)
       
    54 		{
       
    55 		aSession.ITCSender().WriteL(ids, EMceItcInitFC, *iType );				
       
    56 		}
       
    57     else // insession
       
    58         {
       
    59         aSession.ITCSender().WriteL(ids, EMceItcUpdateFC, *iType );				
       
    60         }
       
    61 	}
       
    62 
       
    63 EXPORT_C void CMceFcMsgExchange::SendL(CMceSession& aSession, HBufC8* aMessage)
       
    64 	{
       
    65 	TMceIds ids;
       
    66 	ids.iAppUID = iManager.AppUid().iUid;
       
    67 	ids.iSessionID = aSession.Id();
       
    68 	
       
    69 	aSession.ITCSender().WriteL(ids, EMceItcSendFCMsg, *aMessage );
       
    70     delete aMessage;	
       
    71 	}
       
    72 
       
    73 EXPORT_C MDesC8Array*
       
    74 CMceFcMsgExchange::MediaAttributeLinesL(CMceSession& aSession)
       
    75 	{
       
    76 	TMceIds ids;
       
    77 	ids.iAppUID = iManager.AppUid().iUid;
       
    78 	ids.iSessionID = aSession.Id();
       
    79 	ids.iMsgType = EMceItcMsgTypeFC;
       
    80 	
       
    81 	return aSession.ITCSender().ReadArrayL(ids, EMceItcFCGetMediaLines );
       
    82 	}
       
    83 
       
    84 EXPORT_C void CMceFcMsgExchange::UpdateL(
       
    85 					 CMceSession& aSession,
       
    86 					 CDesC8Array* aMediaAttributeLines)
       
    87 	{
       
    88 	TMceIds ids;
       
    89 	ids.iAppUID = iManager.AppUid().iUid;
       
    90 	ids.iSessionID = aSession.Id();
       
    91 	ids.iMsgType = EMceItcMsgTypeFC;
       
    92 
       
    93 	CMceMsgTextArray* attributeLines =
       
    94 		new (ELeave) CMceMsgTextArray( *aMediaAttributeLines );
       
    95 	CleanupStack::PushL( attributeLines );
       
    96 	aSession.ITCSender().SendL( ids, EMceItcFCSetMediaLines, *attributeLines );
       
    97 	CleanupStack::PopAndDestroy( attributeLines );
       
    98 	
       
    99 	delete aMediaAttributeLines;
       
   100 	}
       
   101 
       
   102 void CMceFcMsgExchange::ConstructL(const TDesC8& aType)
       
   103 	{
       
   104 	iType = aType.AllocL();
       
   105 	}
       
   106 
       
   107 CMceFcMsgExchange::CMceFcMsgExchange(CMceManager& aManager):
       
   108 	iManager(aManager)	
       
   109 	{	
       
   110 	}