imstutils/imconversationview/tsrc/imcvuiengine_test/dummytestadaptation/src/cossprotocolplugin.cpp
changeset 0 5e5d6b214f4f
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     1 /*
       
     2 * Copyright (c) 2007-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:  adaptation for open source
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cossprotocolplugin.h"
       
    19 
       
    20 #include "cossprotocolconnection.h"
       
    21 
       
    22 #include <badesca.h>
       
    23 #include <ecom/implementationproxy.h>
       
    24 #include <ximpserviceinfo.h>
       
    25 #include <ximpbase.h>
       
    26 #include <ximpidentity.h>
       
    27 #include <presenceinfo.h>
       
    28 #include <ximpprotocolconnectionhost.h>
       
    29 #include <ximpcontextclientinfo.h>
       
    30 #include <featmgr.h>
       
    31 #include <bldvariant.hrh>
       
    32 
       
    33  
       
    34 // ======== MEMBER FUNCTIONS ========
       
    35 
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // Key value pair table to identify correct constructor
       
    39 // function for the requested interface.
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 const TImplementationProxy ImplementationTable[] =
       
    43 	{
       
    44 	IMPLEMENTATION_PROXY_ENTRY ( 0x20007B6D, COSSProtocolPlugin::NewL )
       
    45 	};
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // Exported function to return the implementation proxy table
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 EXPORT_C const TImplementationProxy* ImplementationGroupProxy ( TInt& aTableCount )
       
    53 	{
       
    54 
       
    55 	aTableCount = sizeof ( ImplementationTable ) / sizeof ( TImplementationProxy );
       
    56 
       
    57 	return ImplementationTable;
       
    58 	}
       
    59 
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // COSSProtocolPlugin::COSSProtocolPlugin()
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 COSSProtocolPlugin::COSSProtocolPlugin()
       
    66 	{
       
    67 
       
    68 	}
       
    69 
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // COSSProtocolPlugin::ConstructL()
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 void COSSProtocolPlugin::ConstructL()
       
    76 	{
       
    77 
       
    78 	}
       
    79 
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // COSSProtocolPlugin::NewLC()
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 COSSProtocolPlugin* COSSProtocolPlugin::NewLC()
       
    86 	{
       
    87 	//LOGGER ( TXT ( "COSSProtocolPlugin::NewLC() Start" ) );
       
    88 
       
    89 	COSSProtocolPlugin* self = COSSProtocolPlugin::NewL();
       
    90 	CleanupStack::PushL ( self );
       
    91 
       
    92 	//LOGGER ( TXT ( "COSSProtocolPlugin::NewLC() End" ) );
       
    93 	return self;
       
    94 	}
       
    95 
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // COSSProtocolPlugin::NewL()
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 COSSProtocolPlugin* COSSProtocolPlugin::NewL()
       
   102 	{
       
   103 	//LOGGER ( TXT ( "=============================START=========================================" ) );
       
   104 	//LOGGER ( TXT ( "COSSProtocolPlugin::NewL() Start" ) );
       
   105 
       
   106 	COSSProtocolPlugin* self = new ( ELeave ) COSSProtocolPlugin();
       
   107 	CleanupStack::PushL ( self );
       
   108 	self->ConstructL();
       
   109 	CleanupStack::Pop ( self );
       
   110 
       
   111 	//LOGGER ( TXT ( "COSSProtocolPlugin::NewL() End :Address of %d" ), &self );
       
   112 	return self;
       
   113 	}
       
   114 
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // COSSProtocolPlugin::~COSSProtocolPlugin()
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 COSSProtocolPlugin::~COSSProtocolPlugin()
       
   121 	{
       
   122 	//LOGGER ( TXT ( "COSSProtocolPlugin::~COSSProtocolPlugin() Start" ) );
       
   123 	//delete iIsoServerLauncher;
       
   124 
       
   125 	iConnections.ResetAndDestroy();
       
   126 
       
   127 	//LOGGER ( TXT ( "COSSProtocolPlugin::~COSSProtocolPlugin() End" ) );
       
   128 	//LOGGER ( TXT ( "=============================END=========================================" ) );
       
   129 	}
       
   130 
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // COSSProtocolPlugin::PrimeHost()
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 void COSSProtocolPlugin::PrimeHost ( MXIMPProtocolPluginHost& aHost )
       
   137 	{
       
   138 	//LOGGER ( TXT ( "COSSProtocolPlugin::PrimeHost() Start" ) );
       
   139 
       
   140 	iHost = &aHost;
       
   141 
       
   142 	//LOGGER ( TXT ( "COSSProtocolPlugin::PrimeHost() End" ) );
       
   143 	}
       
   144 
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // COSSProtocolPlugin::AcquireConnectionL()
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 MXIMPProtocolConnection& COSSProtocolPlugin::AcquireConnectionL (
       
   151     const MXIMPServiceInfo& aServiceInfo,
       
   152     const MXIMPContextClientInfo& aClientCtxInfo )
       
   153 	{
       
   154 	//LOGGER ( TXT ( "COSSProtocolPlugin::AcquireConnectionL() Start" ) );
       
   155 
       
   156 	TInt count = iConnections.Count();
       
   157 	//COSSProtocolConnection* connection = NULL;
       
   158 	// count how many connections are there in plugin
       
   159 	// create new connection if array is empty
       
   160 	// create existing connection based on check if it
       
   161 	if ( count == 0 )
       
   162 		{
       
   163 		COSSProtocolConnection* connection = COSSProtocolConnection::NewL ( aServiceInfo, aClientCtxInfo );
       
   164 		CleanupStack::PushL ( connection );
       
   165 		iConnections.AppendL ( connection );
       
   166 		CleanupStack::Pop ( connection );
       
   167 	//	iIsoServerLauncher->LaunchProcessL();	
       
   168 		//LOGGER ( TXT ( "COSSProtocolPlugin::isoserver launched" ) );
       
   169 		//LOGGER ( TXT ( "COSSProtocolPlugin::AcquireConnectionL() End" ) );
       
   170 		return *connection;
       
   171 
       
   172 		}
       
   173 	else if ( count == 1 )
       
   174 		{
       
   175 		//LOGGER(TXT("COSSProtocolPlugin::AcquireConnectionL() End") );
       
   176 		return *iConnections[0];
       
   177 		}
       
   178 	else
       
   179 		{
       
   180 		// even if there are many connection objects, we just return
       
   181 		// the reference to the first connection object which is 
       
   182 		// initiated by CCH
       
   183 		return *iConnections[0];
       
   184 		//LOGGER(TXT("COSSProtocolPlugin::AcquireConnectionL() End") );
       
   185 		}
       
   186 	}
       
   187 
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // COSSProtocolPlugin::ReleaseConnection()
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 void COSSProtocolPlugin::ReleaseConnection ( MXIMPProtocolConnection& aConnection )
       
   194 	{
       
   195 	//LOGGER ( TXT ( "COSSProtocolPlugin::ReleaseConnection() Start" ) );
       
   196 
       
   197 	TInt connectionsCount = iConnections.Count();
       
   198 
       
   199 	for ( TInt i ( connectionsCount - 1 ); i >= 0; i-- )
       
   200 		{
       
   201 		MXIMPProtocolConnection* tmp = iConnections[i];
       
   202 
       
   203 		if ( tmp == &aConnection )
       
   204 			{
       
   205 			TRAP_IGNORE( iConnections[i]->ReleaseConnectionL() );
       
   206 			delete iConnections[i];
       
   207 			iConnections.Remove ( i );
       
   208 			}
       
   209 		}
       
   210 
       
   211 	//LOGGER ( TXT ( "COSSProtocolPlugin::ReleaseConnection() End" ) );
       
   212 	}
       
   213 
       
   214 
       
   215 // ---------------------------------------------------------------------------
       
   216 // COSSProtocolPlugin::GetInterface()
       
   217 // ---------------------------------------------------------------------------
       
   218 //
       
   219 TAny* COSSProtocolPlugin::GetInterface ( TInt32 aInterfaceId,
       
   220         TIfGetOps aOptions  )
       
   221 	{
       
   222 	//LOGGER ( TXT ( "COSSProtocolPlugin::GetInterface() Start" ) );
       
   223 
       
   224 	if ( aInterfaceId == MXIMPProtocolPlugin::KInterfaceId )
       
   225 		{
       
   226 		MXIMPProtocolPlugin* self = this;
       
   227 		return self;
       
   228 		}
       
   229 
       
   230 	if ( aOptions == MXIMPBase::EPanicIfUnknown )
       
   231 
       
   232 		{
       
   233 	//	User::Panic ( KOSSProtocolPlugin, KErrExtensionNotSupported );
       
   234 		}
       
   235 
       
   236 	//LOGGER ( TXT ( "COSSProtocolPlugin::GetInterface() End" ) );
       
   237 
       
   238 	return NULL;
       
   239 	}
       
   240 
       
   241 
       
   242 // ---------------------------------------------------------------------------
       
   243 // COSSProtocolPlugin::GetInterface()
       
   244 // ---------------------------------------------------------------------------
       
   245 //
       
   246 const TAny* COSSProtocolPlugin::GetInterface ( TInt32 aInterfaceId,
       
   247         TIfGetOps aOptions ) const
       
   248 	{
       
   249 	//LOGGER ( TXT ( "COSSProtocolPlugin::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 ( KOSSProtocolPlugin, KErrExtensionNotSupported );
       
   261 		}
       
   262 
       
   263 	//LOGGER ( TXT ( "COSSProtocolPlugin::GetInterface() const End" ) );
       
   264 
       
   265 	return NULL;
       
   266 	}
       
   267 
       
   268 
       
   269 // ---------------------------------------------------------------------------
       
   270 // COSSProtocolPlugin::GetInterfaceId() const
       
   271 // ---------------------------------------------------------------------------
       
   272 //
       
   273 TInt32 COSSProtocolPlugin::GetInterfaceId() const
       
   274 	{
       
   275 	//LOGGER ( TXT ( "COSSProtocolPlugin::GetInterface() without parameters Start-End" ) );
       
   276 	return MXIMPProtocolPlugin::KInterfaceId;
       
   277 	}
       
   278 
       
   279 
       
   280 // End of file
       
   281