--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/installationservices/swinstallationfw/source/siftransportserver.cpp Fri Mar 19 09:33:35 2010 +0200
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* This file implements the SIF Transport Server.
+*
+*/
+
+
+#include "siftransportserver.h"
+#include "siftransportcommon.h"
+#include <e32property.h>
+
+using namespace Usif;
+
+CSifTransportServer* CSifTransportServer::NewLC(const TDesC& aServerName, const TVersion& aVersion,
+ TransportTaskFactory::GenerateTask aTaskFactory, TInt aShutdownPeriodUs)
+/**
+ Factory function allocates new, initialized instance of
+ CSifServer which is left on the cleanup stack.
+
+ @return New, initialized instance of CSifServer
+ which is left on the cleanup stack.
+ */
+ {
+ CSifTransportServer* self = new (ELeave) CSifTransportServer(aVersion, aTaskFactory);
+ CleanupStack::PushL(self);
+ self->ConstructL(aServerName, aShutdownPeriodUs);
+ return self;
+ }
+
+CSifTransportServer::CSifTransportServer(const TVersion& aVersion, TransportTaskFactory::GenerateTask aTaskFactory)
+/**
+ Initializes the superclass with this server's version.
+ */
+ : CScsServer(aVersion), iTaskFactory(aTaskFactory)
+ {
+ }
+
+void CSifTransportServer::ConstructL(const TDesC& aServerName, TInt aShutdownPeriodUs)
+/**
+ Second-phase construction initializes the superclass and
+ starts the server.
+ */
+ {
+ CScsServer::ConstructL(aShutdownPeriodUs);
+
+ StartL(aServerName);
+ }
+
+
+CSifTransportServer::~CSifTransportServer()
+/**
+ Cleanup the server, in particular close the RFs session.
+ */
+ {
+ }
+
+CScsSession* CSifTransportServer::DoNewSessionL(const RMessage2& /*aMessage*/)
+/**
+ Implement CScsServer by allocating a new instance of CSifSession.
+
+ @param aMessage Standard server-side handle to message. Not used.
+ @return New instance of CSifSession which is owned by the
+ caller.
+ */
+ {
+ return CSifTransportSession::NewL(*this, iTaskFactory);
+ }
+
+namespace
+ {
+ struct TServerStartupInfo
+ {
+ const TDesC* iServerName;
+ const TVersion* iVersion;
+ TransportTaskFactory::GenerateTask iTaskFactory;
+ TInt iShutdownPeriodUs;
+ };
+ }
+
+EXPORT_C CScsServer* CSifTransportServer::NewSifTransportServerLC()
+/**
+ This factory function is called by SCS. It allocates
+ the server object and leaves it on the cleanup stack.
+
+ @return New initialized instance of CScsTestServer.
+ On return this is on the cleanup stack.
+*/
+ {
+ TServerStartupInfo* ssi = static_cast<TServerStartupInfo*>(Dll::Tls());
+ return CSifTransportServer::NewLC(*ssi->iServerName, *ssi->iVersion, ssi->iTaskFactory, ssi->iShutdownPeriodUs);
+ }
+
+namespace Usif
+ {
+ EXPORT_C TInt StartTransportServer(const TDesC& aServerName, const TVersion& aVersion, TransportTaskFactory::GenerateTask aTaskFactory, TInt aShutdownPeriodUs)
+ {
+ // A local object can be used with TLS here because it is read by CSifTransportServer::NewSifTransportServerLC()
+ // before we leave the scope of this function. This is because CSifTransportServer::NewSifTransportServerLC() is a callback
+ // function called by the SCS Server in response to StartScsServer().
+ TServerStartupInfo ssi = {&aServerName, &aVersion, aTaskFactory, aShutdownPeriodUs};
+ Dll::SetTls(&ssi);
+ TInt err = StartScsServer(CSifTransportServer::NewSifTransportServerLC);
+ return err;
+ }
+ }