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