devsoundextensions/addeddevsoundcontrol/AddedDevSoundControlMsgHdlr/src/AddedDevSoundControlMsgHdlr.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     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:   Message handler for AddedDevSoundControl CI.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "AddedDevSoundControlCI.h"
       
    22 #include "AddedDevSoundControlMsgHdlr.h"
       
    23 #include "AddedDevSoundControlMsgs.h"
       
    24 
       
    25 // EXTERNAL DATA STRUCTURES
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 // MACROS
       
    32 
       
    33 // LOCAL CONSTANTS AND MACROS
       
    34 
       
    35 // MODULE DATA STRUCTURES
       
    36 
       
    37 // LOCAL FUNCTION PROTOTYPES
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 
       
    41 // ============================= LOCAL FUNCTIONS ===============================
       
    42 
       
    43 // ============================ MEMBER FUNCTIONS ===============================
       
    44 
       
    45 /**
       
    46  * CAddedDevSoundControlMsgHdlr::CAddedDevSoundControlMsgHdlr
       
    47  * C++ default constructor can NOT contain any code, that might leave.
       
    48  */
       
    49 CAddedDevSoundControlMsgHdlr::CAddedDevSoundControlMsgHdlr(
       
    50                               MAddedDevSoundControl* aAddedDSControlCI) :
       
    51 	CMMFObject(KUidAddedDevSoundControlInterface)
       
    52     {
       
    53     iAddedDSControlCI = aAddedDSControlCI;
       
    54     }
       
    55 
       
    56 /**
       
    57  * CAddedDevSoundControlMsgHdlr::ConstructL
       
    58  * Symbian 2nd phase constructor can leave.
       
    59  */
       
    60 void CAddedDevSoundControlMsgHdlr::ConstructL()
       
    61     {
       
    62     }
       
    63 
       
    64 /**
       
    65  * CAddedDevSoundControlMsgHdlr::NewL
       
    66  * Two-phased constructor.
       
    67  */
       
    68 EXPORT_C CAddedDevSoundControlMsgHdlr*
       
    69 CAddedDevSoundControlMsgHdlr::NewL(TAny* aAddedDSControlCI)
       
    70     {
       
    71     MAddedDevSoundControl* addedDevSoundControlCI =
       
    72             (MAddedDevSoundControl*)aAddedDSControlCI;
       
    73     CAddedDevSoundControlMsgHdlr* self =
       
    74             new (ELeave) CAddedDevSoundControlMsgHdlr(addedDevSoundControlCI);
       
    75     CleanupStack::PushL( self );
       
    76     self->ConstructL();
       
    77     CleanupStack::Pop( self );
       
    78 
       
    79     return self;
       
    80     }
       
    81 
       
    82 /**
       
    83  * Destructor
       
    84  */
       
    85 CAddedDevSoundControlMsgHdlr::~CAddedDevSoundControlMsgHdlr()
       
    86 	{
       
    87 	delete iAddedDSControlCI;
       
    88 	}
       
    89 
       
    90 /**
       
    91  * CAddedDevSoundControlMsgHdlr::HandleRequest
       
    92  * Handles messages from the proxy.
       
    93  * Calls a subfunction, which determines what custom interface to call.
       
    94  * A subfunction is used to contain multiple leaving functions for a single
       
    95  * trap.
       
    96  * (other items were commented in a header).
       
    97  */
       
    98 void CAddedDevSoundControlMsgHdlr::HandleRequest(TMMFMessage& aMessage)
       
    99 	{
       
   100 	ASSERT(
       
   101 	aMessage.Destination().InterfaceId() == KUidAddedDevSoundControlInterface);
       
   102 
       
   103 	TRAPD(error, DoHandleRequestL(aMessage));
       
   104 	if (error)
       
   105 		{
       
   106 		aMessage.Complete(error);
       
   107 		}
       
   108 	}
       
   109 
       
   110 /**
       
   111  * CAddedDevSoundControlMsgHdlr::DoHandleRequestL
       
   112  * Determines which custom interface to call.
       
   113  * (other items were commented in a header).
       
   114  */
       
   115 void CAddedDevSoundControlMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
       
   116 	{
       
   117 	switch(aMessage.Function())
       
   118 		{
       
   119 		case EAddedDSControlSetHwAwareness:
       
   120 			{
       
   121     		DoSetHwAwarenessL(aMessage);
       
   122 			break;
       
   123 			}
       
   124 		case EAddedDSControlPauseAndFlush:
       
   125 			{
       
   126     		DoPauseAndFlushL(aMessage);
       
   127 			break;
       
   128 			}
       
   129 		default:
       
   130 			{
       
   131 			aMessage.Complete(KErrNotSupported);
       
   132 			}
       
   133 		}
       
   134 	}
       
   135 
       
   136 /**
       
   137  * CAddedDevSoundControlMsgHdlr::DoSetHwAwarenessL
       
   138  * Handles EAddedDSControlSetHwAwareness message from the proxy and calls 
       
   139  * custom interface method.
       
   140  *
       
   141  * (other items were commented in a header).
       
   142  */
       
   143 void CAddedDevSoundControlMsgHdlr::DoSetHwAwarenessL(TMMFMessage& aMessage)
       
   144     {
       
   145 	TPckgBuf<TBool> pckg;
       
   146 	aMessage.ReadData1FromClientL(pckg);
       
   147 	TInt status = iAddedDSControlCI->SetHwAwareness(pckg());
       
   148     aMessage.Complete(status);
       
   149     }
       
   150 
       
   151 /**
       
   152  * CAddedDevSoundControlMsgHdlr::DoPauseAndFlushL
       
   153  * Handles EAddedDSControlPauseAndFlush message from the proxy and calls 
       
   154  * custom interface method.
       
   155  *
       
   156  * (other items were commented in a header).
       
   157  */
       
   158 void CAddedDevSoundControlMsgHdlr::DoPauseAndFlushL(TMMFMessage& aMessage)
       
   159     {
       
   160 	TInt status = iAddedDSControlCI->PauseAndFlush();
       
   161     aMessage.Complete(status);
       
   162     }
       
   163 
       
   164 // End of File