os/mm/devsoundextensions/ciextnfactoryplugins/ciextnserverplugin/src/ciextnserverpluginwrapper.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2  * Copyright (c) 2002-2008 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:   Class definition of server plugin wrapper implementing S60 custom interface.
    15  *
    16  */
    17 
    18 #include "ciextnserverpluginwrapper.h"
    19 #include "citraces.h"
    20 #include <AudioInputMessageTypes.h>
    21 #include <ecom.h>
    22 
    23 #define KMuxTempBufferSize 20
    24 
    25 #ifdef __WINSCW__
    26 class MyMCustomInterface
    27     {
    28 public:
    29     virtual TAny* CustomInterface(TUid aCustomeInterface) = 0;
    30     virtual void Release() = 0;
    31     virtual void PassDestructionKey(TUid aUid) = 0;
    32     };
    33 #endif
    34 
    35 CIExtnServerPluginWrapper* CIExtnServerPluginWrapper::NewL(
    36         MCustomInterface& aInterfaceRef)
    37     {
    38     DEB_TRACE0(_L("CIExtnServerPluginWrapper::NewL Begin"));
    39     CIExtnServerPluginWrapper* self = new (ELeave) CIExtnServerPluginWrapper(
    40             aInterfaceRef);
    41     CleanupStack::PushL(self);
    42     self->ConstructL();
    43     CleanupStack::Pop(self);
    44     DEB_TRACE0(_L("CIExtnServerPluginWrapper::NewL End"));
    45     return self;
    46     }
    47 
    48 CIExtnServerPluginWrapper::~CIExtnServerPluginWrapper()
    49     {
    50     DEB_TRACE0(_L("CIExtnServerPluginWrappers::~CIExtnServerPluginWrapper Begin"));
    51     DEB_TRACE0(_L("CIExtnServerPluginWrapper::~CIExtnServerPluginWrapper End"));
    52     }
    53 
    54 CIExtnServerPluginWrapper::CIExtnServerPluginWrapper(
    55         MCustomInterface& aInterfaceRef) :
    56     iCustomInterfaceRef(&aInterfaceRef)
    57     {
    58     }
    59 
    60 void CIExtnServerPluginWrapper::ConstructL()
    61     {
    62 #ifdef __WINSCW__
    63     DEB_TRACE0(_L("Try Loading CI Stub Plugin"));
    64     TUid interfaceUid =
    65         {
    66         0x10207C71
    67         };
    68     TAny* pluginRef;
    69     TRAPD(error, pluginRef = REComSession::CreateImplementationL( interfaceUid, iDtor_ID_Key ));
    70     if (pluginRef)
    71         {
    72         DEB_TRACE1(_L("CreateImplementationL Uid [0x%x]"), iDtor_ID_Key.iUid);
    73         iCustomInterfaceStub = (MyMCustomInterface*) pluginRef;
    74         iCustomInterfaceStub->PassDestructionKey(iDtor_ID_Key);
    75         DEB_TRACE0(_L("CI Stub Loaded"));
    76         }
    77 #endif    
    78 
    79     }
    80 
    81 MCustomInterface* CIExtnServerPluginWrapper::GetInterface()
    82     {
    83     DEB_TRACE0(_L("CIExtnServerPluginWrappers::GetInterface"));
    84     return (MCustomInterface*) this;
    85     }
    86 
    87 TAny* CIExtnServerPluginWrapper::CustomInterface(TUid aInterfaceId)
    88     {
    89     DEB_TRACE0(_L("*CI* CIExtnServerPluginWrapper::CustomInterface"));
    90     TAny* pluginRef = NULL;
    91     pluginRef = iCustomInterfaceRef->CustomInterface(aInterfaceId);
    92 #ifdef __WINSCW__
    93     if (!pluginRef)
    94         {
    95         DEB_TRACE0(_L("*CI* Try Loading CI Stub if present"));
    96         pluginRef = iCustomInterfaceStub->CustomInterface(aInterfaceId);
    97         if (pluginRef)
    98             {
    99             DEB_TRACE0(_L("*CI* CI Stub Loaded"));
   100             }
   101         }
   102 #endif
   103     return pluginRef;
   104     }
   105 
   106 void CIExtnServerPluginWrapper::Release()
   107     {
   108     DEB_TRACE0(_L("CIExtnServerPluginWrappers::Release >> ENTER"));
   109 #ifdef __WINSCW__    
   110     iCustomInterfaceStub->Release();
   111 #endif    
   112     DEB_TRACE0(_L("CIExtnServerPluginWrappers::Release >> EXIT"));
   113     delete this;
   114     }
   115 
   116 /*
   117  TAny* CIExtnServerPluginWrapper::CustomInterface(TUid aInterfaceId)
   118  {
   119  DEB_TRACE0(_L("CIExtnServerPluginWrappers::CustomInterface"));
   120  TUid interfaceUid =
   121  {
   122  0x10207C49
   123  };
   124  TEComResolverParams resolverParams;
   125  DEB_TRACE1(_L("Findig CustomInterface with Uid [0x%x]"),aInterfaceId.iUid);
   126  TInt uidAsInteger = aInterfaceId.iUid;
   127  TBuf8<KMuxTempBufferSize> tempBuffer;
   128  tempBuffer.Num(uidAsInteger, EHex);
   129  resolverParams.SetDataType(tempBuffer);
   130 
   131  TAny* ptr = NULL;
   132  TRAPD(err, ptr=REComSession::CreateImplementationL(
   133  interfaceUid,
   134  _FOFF(CIExtnServerPluginWrapper, iDtor_ID_Key),resolverParams));
   135  if (err != KErrNone)
   136  {
   137  DEB_TRACE1(_L("No Custom Interface found:  Error [%d]"),err);
   138  }
   139  if (ptr)
   140  {
   141  DEB_TRACE1(_L("Stub Present for Uid [0x%x]"),interfaceUid);
   142  return ptr;
   143  }
   144  else
   145  {
   146  return iCustomInterfaceRef->CustomInterface(aInterfaceId);
   147  }
   148  }
   149  */