webservices/wsframework/inc/senserviceinvocationframework.inl
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-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:           Defines the ECom interface for Sen Service Invocation
       
    15 *                Framework plug-ins
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 #include <SenCredential2.h>
       
    27 
       
    28 // Interface's (abstract base class's) static factory method implementation.
       
    29 // Asks ECOM plug-in framework to instantiate appropriate concrete plug-in
       
    30 // implementation.
       
    31 inline CSIF* CSIF::NewL(MSenCoreServiceManager& aManager)
       
    32     {
       
    33     // Caller wants to instantiate the default plug-in - ID-WSF  
       
    34 #ifndef RD_SEN_COMPILE_SIS_PACKAGE_FILES      
       
    35     const TUid KIDWSFInterfaceUid = {0x101F96FA};
       
    36 #else
       
    37     const TUid KIDWSFInterfaceUid = {0x101F9731};
       
    38 #endif    
       
    39 
       
    40     TAny* constructorParameters = reinterpret_cast<TAny*>(&aManager);
       
    41 
       
    42     // Find implementation for our interface.
       
    43     // - KIDWSFInterfaceUid is the UID of our custom ECOM interface.
       
    44     // - This call will leave, if the plugin architecture cannot find any implementation.
       
    45     // - The returned pointer points to one of the interface implementations.
       
    46     TUid dtor_id_key;
       
    47     TAny* intf = REComSession::CreateImplementationL ( KIDWSFInterfaceUid, dtor_id_key, constructorParameters );
       
    48     //TAny* intf = REComSession::CreateImplementationL ( KIDWSFUid, _FOFF (CSIF, dtor_id_key), constructorParameters );
       
    49     CSIF* sif = reinterpret_cast <CSIF*> (intf);
       
    50     if ( sif )
       
    51         {
       
    52         
       
    53         // Resolve the DataType of this plug-in (ECOM cue):
       
    54         RImplInfoPtrArray ecomInfoArray;
       
    55         REComSession::ListImplementationsL( KIDWSFInterfaceUid, ecomInfoArray );
       
    56 
       
    57         TInt infoCount(ecomInfoArray.Count());
       
    58         // NOTE: current code uses the plug-in that has highest version number
       
    59         //TInt index_with_highest_version(0);
       
    60         CImplementationInformation* match = NULL;
       
    61         for (TInt i=0; i<infoCount; i++)
       
    62             {
       
    63             CImplementationInformation* candidate = ecomInfoArray[i];
       
    64             if( !match || candidate->Version() > match->Version() )
       
    65                 {
       
    66                 match = candidate;
       
    67                 // index of plug-in with highest version number
       
    68                 //index_with_highest_version = i;
       
    69                 }
       
    70             }
       
    71         CleanupStack::PushL( sif );
       
    72         sif->iData = new (ELeave) TSifData();
       
    73         sif->iData->iDtor_ID_Key = dtor_id_key;
       
    74         if( match )
       
    75             {
       
    76             sif->iData->iCue = match->DataType().AllocL();
       
    77             }
       
    78         CleanupStack::Pop( sif );
       
    79         ecomInfoArray.ResetAndDestroy();        
       
    80         }
       
    81 
       
    82     return sif;
       
    83     }
       
    84 
       
    85 // Interface's (abstract base class's) static factory method implementation.
       
    86 // Asks ECOM plug-in framework to instantiate appropriate concrete plug-in
       
    87 // implementation.
       
    88 inline CSIF* CSIF::NewL(const TDesC8& aCue, MSenCoreServiceManager& aManager)
       
    89     {
       
    90 #ifndef RD_SEN_COMPILE_SIS_PACKAGE_FILES    
       
    91     const TUid KCSIFInterfaceUid = {0x101F96F9};
       
    92 #else
       
    93     const TUid KCSIFInterfaceUid = {0x101F9730};
       
    94 #endif    
       
    95     //const TUid KCSIFResolverUid = {0x101F614E}; // default resolver used, not needed..
       
    96 
       
    97     TEComResolverParams resolverParams;
       
    98     resolverParams.SetDataType( aCue );
       
    99     //resolverParams.SetWildcardMatch(ETrue); 
       
   100     resolverParams.SetWildcardMatch(EFalse); 
       
   101 
       
   102     TAny* constructorParameters = reinterpret_cast<TAny*>(&aManager);
       
   103     
       
   104 
       
   105     // Find implementation for our interface.
       
   106     // - XXX is the UID of our custom ECOM
       
   107     //   interface. It is defined in EComInterfaceDefinition.h          
       
   108     // - This call will leave, if the plugin architecture cannot find implementation.
       
   109     // - The returned pointer points to one of the interface implementations
       
   110     TUid dtor_id_key;
       
   111     TAny* intf = REComSession::CreateImplementationL (KCSIFInterfaceUid, dtor_id_key, constructorParameters, resolverParams); 
       
   112     // TAny* intf = REComSession::CreateImplementationL (KCSIFInterfaceUid, _FOFF (CSIF, dtor_id_key), constructorParameters, resolverParams); 
       
   113 
       
   114     CSIF* sif = reinterpret_cast<CSIF*> (intf);
       
   115     if ( sif )
       
   116         {
       
   117         CleanupStack::PushL( sif );
       
   118         sif->iData = new (ELeave) TSifData();
       
   119         sif->iData->iDtor_ID_Key = dtor_id_key;
       
   120         sif->iData->iCue = aCue.AllocL();
       
   121         CleanupStack::Pop( sif );
       
   122         }
       
   123 
       
   124     return sif;
       
   125     }
       
   126 
       
   127 // Interface's (abstract base class's) destructor
       
   128 inline CSIF::~CSIF()
       
   129     {
       
   130     // If in the NewL some memory is reserved for member data, it must be
       
   131     // released here.
       
   132     if( iData ) // actually, this MUST always be true
       
   133         {
       
   134         // Inform the ECOM framework that this specific instance of the
       
   135         // interface has been destroyed.
       
   136         REComSession::DestroyedImplementation ( iData->iDtor_ID_Key );
       
   137         iData->Close(); // de-allocates iData members
       
   138         delete iData;
       
   139         iData = NULL;
       
   140         }
       
   141     }
       
   142 
       
   143 inline TPtrC8 CSIF::Cue() const
       
   144     {
       
   145     if(iData && iData->iCue)
       
   146         return *(iData->iCue);
       
   147     else
       
   148         return KNullDesC8();
       
   149     }
       
   150     
       
   151 inline void CSIF::TSifData::Close()
       
   152     {
       
   153     delete iCue;
       
   154     iCue = NULL;
       
   155     }
       
   156     
       
   157 
       
   158 // End of File