usbmgmt/usbmgr/device/classdrivers/ncm/classimplementation/ncmpktdrv/server/src/ncmsession.cpp
branchRCL_3
changeset 15 f92a4f87e424
equal deleted inserted replaced
14:d3e8e7d462dd 15:f92a4f87e424
       
     1 /*
       
     2 * Copyright (c) 2010 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  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 #include "ncmserverconsts.h"
       
    26 #include "ncmsession.h"
       
    27 #include "ncmengine.h"
       
    28 #include "OstTraceDefinitions.h"
       
    29 #ifdef OST_TRACE_COMPILER_IN_USE
       
    30 #include "ncmsessionTraces.h"
       
    31 #endif
       
    32 
       
    33 
       
    34 
       
    35 CNcmSession* CNcmSession::NewL(CNcmEngine& aEngine)
       
    36     {
       
    37     CNcmSession* self = new(ELeave) CNcmSession(aEngine);
       
    38     return self;
       
    39     }
       
    40 
       
    41 CNcmSession::CNcmSession(CNcmEngine& aEngine)
       
    42     : iNcmEngine(aEngine)
       
    43     {
       
    44     }
       
    45 
       
    46 CNcmSession::~CNcmSession()
       
    47     {
       
    48     }
       
    49 
       
    50 void CNcmSession::ServiceL(const RMessage2& aMessage)
       
    51     {
       
    52     OstTraceFunctionEntry0(CNCMSESSION_SERVICEL);
       
    53 
       
    54     OstTraceExt3(TRACE_NORMAL,CNCMSESSION_SERVICEL_DUP01, "CNcmSession::ServiceL %d %d %d", aMessage.Function(),
       
    55         aMessage.Int0(), aMessage.Int1());
       
    56 
       
    57     switch ( aMessage.Function() )
       
    58         {
       
    59     case ENcmTransferHandle:
       
    60         {
       
    61         RMessagePtr2 messagePtr(aMessage);
       
    62         TInt ret = iNcmEngine.Start(messagePtr);
       
    63 
       
    64         aMessage.Complete(ret);
       
    65         break;
       
    66         }
       
    67 
       
    68     case ENcmSetIapId:
       
    69         {
       
    70         TInt iap  = aMessage.Int0();
       
    71         TInt ret = iNcmEngine.SetStateToWatcher(ENcmSetTypeIapId, iap);
       
    72 
       
    73         aMessage.Complete(ret);
       
    74         }
       
    75         break;
       
    76 
       
    77     case ENcmSetDhcpResult:
       
    78         {
       
    79         TInt result = aMessage.Int0();
       
    80         TInt ret =  iNcmEngine.SetStateToWatcher(ENcmSetTypeDhcpReturn, result);
       
    81 
       
    82         aMessage.Complete(ret);
       
    83         }
       
    84         break;
       
    85 
       
    86     case ENcmDhcpProvisionNotify:
       
    87         {
       
    88         TInt ret = iNcmEngine.RegisterNotify(aMessage);
       
    89 
       
    90         if (KErrNone != ret)
       
    91             {
       
    92             aMessage.Complete(ret);
       
    93             }
       
    94         }
       
    95         break;
       
    96 
       
    97     case ENcmDhcpProvisionNotifyCancel:
       
    98         {
       
    99         iNcmEngine.DeRegisterNotify();
       
   100         aMessage.Complete(KErrNone);
       
   101         }
       
   102         break;
       
   103 
       
   104     case ENcmTransferBufferSize:
       
   105         {
       
   106         TInt size  = aMessage.Int0();
       
   107         TInt ret = iNcmEngine.SetInEpBufferSize(size);
       
   108         aMessage.Complete(ret);
       
   109         }
       
   110         break;
       
   111 
       
   112     default:
       
   113         // Unknown function, panic the user
       
   114         aMessage.Panic(KNcmSrvPanic, ENcmBadNcmMessage);
       
   115         break;
       
   116         }
       
   117     }