multimediacommsengine/mmcecli/src/mcereferreceiver.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 "mcemanager.h"
       
    22 #include "mcerefer.h"
       
    23 #include "mcereferreceiver.h"
       
    24 #include "mce.h"
       
    25 #include "mceserial.h"
       
    26 #include "mceclilogs.h"
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CMceReferReceiver::CMceReferReceiver
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 CMceReferReceiver::CMceReferReceiver( RMce& aMce,
       
    33                                           CMceRefer& aRefer )
       
    34  : CMceItcReceiverBase( aMce ),
       
    35    iRefer( aRefer )
       
    36 	{
       
    37 	iIdsPckg().iAppUID = aRefer.Manager().AppUid().iUid;
       
    38 	iIdsPckg().iManagerType = KMceCSSIPEvent;
       
    39 	iIdsPckg().iSessionID = aRefer.Id();
       
    40 	
       
    41     Init();
       
    42 	
       
    43 	}
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CMceReferReceiver::~CMceReferReceiver
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CMceReferReceiver::~CMceReferReceiver () 
       
    50 	{
       
    51 	}
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CMceReferReceiver::IncomingEventL
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void CMceReferReceiver::IncomingEventL( TMceItcCallBack aEvent, TMceIds& aIds, 
       
    58                                           const TDesC8& aContext )
       
    59 	{
       
    60     MCECLI_DEBUG("CMceReferReceiver::IncomingEventL, Entry");
       
    61     MCECLI_DEBUG_DVALUE("context size", aContext.Length() );
       
    62 	
       
    63 	switch ( aEvent )
       
    64 	    {
       
    65 	    case EMceItcStateChanged:
       
    66 	        {
       
    67             MCECLI_DEBUG("CMceReferReceiver::IncomingEventL, incoming event. \
       
    68 passing to refer");
       
    69         CMceMsgBase* message = DecodeMessageLC( aIds, aContext );
       
    70 	        User::LeaveIfError( message ? KErrNone : KErrGeneral );
       
    71             message->PushL();
       
    72 
       
    73             iRefer.EventReceivedL( aIds, *message );
       
    74             
       
    75             message->Pop();
       
    76         	CleanupStack::PopAndDestroy( message );
       
    77 	        
       
    78 	        break;
       
    79 	        }
       
    80         default:
       
    81             {
       
    82             MCECLI_DEBUG("CMceReferReceiver::IncomingEventL, not supported");
       
    83             User::Leave( KErrNotSupported );
       
    84             }
       
    85 	    }
       
    86 	
       
    87     MCECLI_DEBUG("CMceReferReceiver::IncomingEventL, Exit");
       
    88 	}
       
    89 
       
    90 	
       
    91 // -----------------------------------------------------------------------------
       
    92 // CMceReferReceiver::IncomingEventL
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CMceReferReceiver::IncomingEventL( TMceItcCallBack aEvent, TMceIds& aIds, 
       
    96                                           const TDesC8& aContext, 
       
    97                                           HBufC8* aContent )
       
    98 	{
       
    99     MCECLI_DEBUG("CMceReferReceiver::IncomingEventL, Entry");
       
   100     MCECLI_DEBUG_DVALUE("context size", aContext.Length() );
       
   101     MCECLI_DEBUG_DVALUE("content size", aContent ? aContent->Length() : 0 );
       
   102     
       
   103 	switch ( aEvent )
       
   104 	    {
       
   105 	    case EMceItcStateChanged:
       
   106 	        {
       
   107             MCECLI_DEBUG("CMceReferReceiver::IncomingEventL, incoming event. \
       
   108 passing to refer");
       
   109 	        CMceMsgBase* message = DecodeMessageLC( aIds, aContext );
       
   110 	        User::LeaveIfError( message ? KErrNone : KErrGeneral );
       
   111             message->PushL();
       
   112 
       
   113             iRefer.EventReceivedL( aIds, *message, aContent );
       
   114             
       
   115             message->Pop();
       
   116         	CleanupStack::PopAndDestroy( message );
       
   117 	        break;
       
   118 	        }
       
   119 	   default:
       
   120             {
       
   121             MCECLI_DEBUG("CMceReferReceiver::IncomingEventL, not supported");
       
   122             User::Leave( KErrNotSupported );
       
   123             }
       
   124 	    }
       
   125 	    
       
   126     MCECLI_DEBUG("CMceReferReceiver::IncomingEventL, Exit");
       
   127 	}
       
   128 
       
   129 	
       
   130 // -----------------------------------------------------------------------------
       
   131 // CMceReferReceiver::IncomingEventL
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void CMceReferReceiver::IncomingEventL( TMceItcCallBack /*aEvent*/, TMceIds& aIds )
       
   135 	{
       
   136     MCECLI_DEBUG("CMceReferReceiver::IncomingEventL, Entry");
       
   137 		
       
   138     iRefer.EventReceivedL( aIds );
       
   139     
       
   140     MCECLI_DEBUG("CMceReferReceiver::IncomingEventL, Exit");
       
   141 	}
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CMceReferReceiver::ErrorOccuredL
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 void CMceReferReceiver::ErrorOccuredL (TMceIds& /*aIds*/, TInt aError )
       
   148 	{
       
   149     MCECLI_DEBUG("CMceReferReceiver::IncomingEventL, Entry");
       
   150     iRefer.ErrorOccuredL( aError );
       
   151     MCECLI_DEBUG("CMceReferReceiver::ErrorOccuredL, Exit");
       
   152 	}
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CMceReferReceiver::DecodeMessageL
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 CMceMsgBase* CMceReferReceiver::DecodeMessageLC( TMceIds& aIds, 
       
   159                                                    const TDesC8& aContext )
       
   160     {
       
   161     CMceMsgBase* message = NULL;
       
   162     switch ( aIds.iMsgType )
       
   163         {
       
   164         case EMceItcMsgTypeSIPReply:
       
   165             {
       
   166             message = new (ELeave) CMceMsgSIPReply();
       
   167         	break;
       
   168             }
       
   169         default:
       
   170 	        {
       
   171 	        }
       
   172         }
       
   173         
       
   174     if ( message )
       
   175         {
       
   176     	CleanupStack::PushL( message );
       
   177         message->DecodeL( aContext );
       
   178         }
       
   179 
       
   180     return message;            
       
   181     }
       
   182     
       
   183     
       
   184     
       
   185     
       
   186     
       
   187     
       
   188