presadap12/impsplugin/src/cimpsplugin.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     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:  IMPS Protocol implementation for Presence Framework
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <badesca.h>
       
    20 #include <ecom/implementationproxy.h>
       
    21 
       
    22 #include <ximpserviceinfo.h>
       
    23 #include <ximpbase.h>
       
    24 #include <ximpidentity.h>
       
    25 #include <presenceinfo.h>
       
    26 #include <ximpprotocolconnectionhost.h>
       
    27 #include <FeatMgr.h>
       
    28 #include <bldvariant.hrh>
       
    29 #include "CImpsPlugin.h"
       
    30 #include "ImpsDebugPrint.h"
       
    31 #include "CImpsConnection.h"
       
    32 #include "impsplugin12uid.h"
       
    33 #include "ximpcontextclientinfo.h"
       
    34 
       
    35 _LIT( KImpsPlugin, "CImpsPlugin" );
       
    36 
       
    37 // ======== MEMBER FUNCTIONS ========
       
    38 
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // Key value pair table to identify correct constructor
       
    42 // function for the requested interface.
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 const TImplementationProxy ImplementationTable[] =
       
    46     {
       
    47     IMPLEMENTATION_PROXY_ENTRY( KImps12PluginAdaptationUid3, CImpsPlugin::NewL )
       
    48     };
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Exported function to return the implementation proxy table
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
    56     {
       
    57     IMPS_DP( D_IMPS_LIT( "ImplementationGroupProxy() Start" ) );
       
    58 
       
    59     aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
       
    60     IMPS_DP( D_IMPS_LIT( "ImplementationGroupProxy() End" ) );
       
    61 
       
    62     return ImplementationTable;
       
    63     }
       
    64 
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // CImpsPlugin::CImpsPlugin()
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 CImpsPlugin::CImpsPlugin()
       
    71     {
       
    72     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::CImpsPlugin() Start-End" ) );
       
    73     }
       
    74 
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // CImpsPlugin::ConstructL()
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 void CImpsPlugin::ConstructL()
       
    81     {
       
    82     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::ConstructL() Start-End" ) );
       
    83 
       
    84     FeatureManager::InitializeLibL();
       
    85 
       
    86     if ( FeatureManager::FeatureSupported( KFeatureIdPresence ) &&
       
    87          FeatureManager::FeatureSupported( KFeatureIdPresenceFramework ) &&
       
    88          FeatureManager::FeatureSupported( KFeatureIdIm )  )
       
    89         {
       
    90         //construct the plugin
       
    91         }
       
    92     else
       
    93         {
       
    94         IMPS_DP( D_IMPS_LIT( "CImpsPlugin::ConstructL() Feature Not Supported" ) );
       
    95         User::Leave( KErrNotSupported );
       
    96         }
       
    97 
       
    98     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::ConstructL() End" ) );
       
    99     }
       
   100 
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CImpsPlugin::NewLC()
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 CImpsPlugin* CImpsPlugin::NewLC()
       
   107     {
       
   108     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::NewLC() Start" ) );
       
   109 
       
   110     CImpsPlugin* self = CImpsPlugin::NewL();
       
   111     CleanupStack::PushL( self );
       
   112 
       
   113     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::NewLC() End" ) );
       
   114     return self;
       
   115     }
       
   116 
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // CImpsPlugin::NewL()
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 CImpsPlugin* CImpsPlugin::NewL()
       
   123     {
       
   124     IMPS_DP( D_IMPS_LIT( "=============================START=========================================" ) );
       
   125     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::NewL() Start" ) );
       
   126 
       
   127     CImpsPlugin* self = new( ELeave ) CImpsPlugin();
       
   128     CleanupStack::PushL( self );
       
   129     self->ConstructL();
       
   130     CleanupStack::Pop( self );
       
   131 
       
   132     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::NewL() End :Address of %d" ), &self );
       
   133     return self;
       
   134     }
       
   135 
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // CImpsPlugin::CImpsPlugin()
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 CImpsPlugin::~CImpsPlugin()
       
   142     {
       
   143     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::~CImpsPlugin() Start" ) );
       
   144     FeatureManager::UnInitializeLib();
       
   145 
       
   146     iConnections.ResetAndDestroy();
       
   147 
       
   148     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::~CImpsPlugin() End" ) );
       
   149     IMPS_DP( D_IMPS_LIT( "=============================END=========================================" ) );
       
   150     }
       
   151 
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // CImpsPlugin::PrimeHost()
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 void CImpsPlugin::PrimeHost( MXIMPProtocolPluginHost& aHost )
       
   158     {
       
   159     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::PrimeHost() Start" ) );
       
   160 
       
   161     iHost = &aHost;
       
   162 
       
   163     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::PrimeHost() End" ) );
       
   164     }
       
   165 
       
   166 
       
   167 // ---------------------------------------------------------------------------
       
   168 // CImpsPlugin::AcquireConnectionL()
       
   169 // ---------------------------------------------------------------------------
       
   170 //
       
   171 MXIMPProtocolConnection& CImpsPlugin::AcquireConnectionL(
       
   172     const MXIMPServiceInfo& aServiceInfo,
       
   173     const MXIMPContextClientInfo& aClientCtxInfo )
       
   174     {
       
   175     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::AcquireConnectionL() Start" ) );
       
   176 
       
   177     CImpsConnection* connection = CImpsConnection::NewL( aServiceInfo, aClientCtxInfo );
       
   178 
       
   179     IMPS_DP( D_IMPS_LIT( " CImpsPlugin::AcquireConnectionL:service address::%S" ), &( aServiceInfo.ServiceAddress() ) );
       
   180     IMPS_DP( D_IMPS_LIT( " CImpsPlugin::AcquireConnectionL:user ID::%S" ), &( aServiceInfo.UserId() ) );
       
   181     IMPS_DP( D_IMPS_LIT( " CImpsPlugin::AcquireConnectionL:user password::%S" ), &( aServiceInfo.Password() ) );
       
   182     IMPS_DP( D_IMPS_LIT( " CImpsPlugin::AcquireConnectionL:Client ID::%S" ), &( aClientCtxInfo.ClientId().Identity() ) );
       
   183     CleanupStack::PushL( connection );
       
   184     iConnections.AppendL( connection );
       
   185     CleanupStack::Pop( connection );
       
   186 
       
   187     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::AcquireConnectionL() End" ) );
       
   188     return *connection;
       
   189     }
       
   190 
       
   191 
       
   192 // ---------------------------------------------------------------------------
       
   193 // CImpsPlugin::ReleaseConnection()
       
   194 // ---------------------------------------------------------------------------
       
   195 //
       
   196 void CImpsPlugin::ReleaseConnection( MXIMPProtocolConnection& aConnection )
       
   197     {
       
   198     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::ReleaseConnection() Start" ) );
       
   199 
       
   200     TInt connectionsCount = iConnections.Count();
       
   201 
       
   202     for ( TInt i( connectionsCount - 1 ); i >= 0; i-- )
       
   203         {
       
   204         MXIMPProtocolConnection* tmp = iConnections[i];
       
   205         if ( tmp == &aConnection )
       
   206             {
       
   207             delete iConnections[i];
       
   208             iConnections.Remove( i );
       
   209             }
       
   210         }
       
   211 
       
   212     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::ReleaseConnection() End" ) );
       
   213     }
       
   214 
       
   215 
       
   216 // ---------------------------------------------------------------------------
       
   217 // CImpsPlugin::GetInterface()
       
   218 // ---------------------------------------------------------------------------
       
   219 //
       
   220 TAny* CImpsPlugin::GetInterface( TInt32 aInterfaceId,
       
   221                                  TIfGetOps aOptions  )
       
   222     {
       
   223     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::GetInterface() Start" ) );
       
   224 
       
   225     if ( aInterfaceId == MXIMPProtocolPlugin::KInterfaceId )
       
   226         {
       
   227         MXIMPProtocolPlugin* self = this;
       
   228         return self;
       
   229         }
       
   230 
       
   231     if ( aOptions == MXIMPBase::EPanicIfUnknown )
       
   232 
       
   233         {
       
   234         User::Panic( KImpsPlugin, KErrExtensionNotSupported );
       
   235         }
       
   236 
       
   237     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::GetInterface() End" ) );
       
   238     return NULL;
       
   239     }
       
   240 
       
   241 
       
   242 // ---------------------------------------------------------------------------
       
   243 // CImpsPlugin::GetInterface()
       
   244 // ---------------------------------------------------------------------------
       
   245 //
       
   246 const TAny* CImpsPlugin::GetInterface( TInt32 aInterfaceId,
       
   247                                        TIfGetOps aOptions ) const
       
   248     {
       
   249     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::GetInterface() const Start" ) );
       
   250 
       
   251     if ( aInterfaceId == MXIMPProtocolPlugin::KInterfaceId )
       
   252         {
       
   253         const MXIMPProtocolPlugin* self = this;
       
   254         return self;
       
   255         }
       
   256 
       
   257     if ( aOptions == MXIMPBase::EPanicIfUnknown )
       
   258 
       
   259         {
       
   260         User::Panic( KImpsPlugin, KErrExtensionNotSupported );
       
   261         }
       
   262 
       
   263     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::GetInterface() const End" ) );
       
   264 
       
   265     return NULL;
       
   266     }
       
   267 
       
   268 
       
   269 // ---------------------------------------------------------------------------
       
   270 // CImpsPlugin::GetInterfaceId()
       
   271 // ---------------------------------------------------------------------------
       
   272 //
       
   273 TInt32 CImpsPlugin::GetInterfaceId() const
       
   274     {
       
   275     IMPS_DP( D_IMPS_LIT( "CImpsPlugin::GetInterface() without parameters Start-End" ) );
       
   276     return MXIMPProtocolPlugin::KInterfaceId;
       
   277     }
       
   278 
       
   279 
       
   280 // End of file
       
   281