syncmlfw/dm/hostserver/dmhostservers/src/nsmldmhostserver3.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 17 Dec 2009 09:07:52 +0200
changeset 0 b497e44ab2fc
permissions -rw-r--r--
Revision: 200949 Kit: 200951

/*
* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "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:  Specialized DM Host Server. In practice differs from 
*				 the other servers only on the capability and the name.
*
*/


// ------------------------------------------------------------------------------------------------
// Includes
// ------------------------------------------------------------------------------------------------
#include <nsmldebug.h>
#include "nsmldmclientandserver.h"
#include "nsmldmhostserver3.h"

// ------------------------------------------------------------------------------------------------
// CNSmlDMHostServer3::LaunchServer()
//	Launches the server.
//	Calls the common code part (InitHostServer) of all specialized DM Host Servers.
//	@param (TAny*). Not used in this function. 
//	  			    Kept here for possible future needs.
//	@return TInt. Return value from InitHostServer function.
// ------------------------------------------------------------------------------------------------
TInt CNSmlDMHostServer3::LaunchServer ( TAny* /*aStarted*/ )
    {
    return InitHostServer ( KNSmlDmHostServer3Name(), (TThreadFunction) ThreadFunction );
    }

// ------------------------------------------------------------------------------------------------
// CNSmlDMHostServer3::ThreadFunction()
//	Calls the NewL for creating the DM Host Server 3 instance.
//	This ThreadFunction is called when the 'common initialization actions' 
//	are successfully run.
//	Starts the active scheduler.
//	@param aStarted. Not used.
//	@return TInt. Returns always KErrNone.
// ------------------------------------------------------------------------------------------------
TInt CNSmlDMHostServer3::ThreadFunction ( TAny* /*aStarted*/ )
    {
	CNSmlDMHostServer3* hs = NULL;
    TRAPD ( err, ( hs = CNSmlDMHostServer3::NewL ( KNSmlDmHostServer3Name() ) ) );
    RProcess::Rendezvous( err );
	__ASSERT_ALWAYS ( !err, PanicServer ( ESvrCreateServer ) );    
    
    CActiveScheduler::Start();
    delete hs;
    return KErrNone;
    }

// ------------------------------------------------------------------------------------------------
// CNSmlDMHostServer3::NewL()
//	Creates a new instance of DM Host Server 3.
//	Adds the server with the specified name to the active scheduler, 
//	and issues the first request for messages. 
//	Signals the global semaphore, which releases the client (DM Tree Module)
//	from the waiting state.
//	@param aServerName. The name of the server: "nsmldmhostserver3".
//	@return CNSmlDMHostServer3*. The created server instance.
// ------------------------------------------------------------------------------------------------
CNSmlDMHostServer3* CNSmlDMHostServer3::NewL ( const TDesC& aServerName )
	{
	CNSmlDMHostServer3* pS = new (ELeave) CNSmlDMHostServer3();
	CleanupStack::PushL ( pS );
	pS->StartL ( aServerName );
	CleanupStack::Pop(); // pS
	return pS;
	}

// ------------------------------------------------------------------------------------------------
// CNSmlDMHostServer3::~CNSmlDMHostServer3()
//	Destructor.
// ------------------------------------------------------------------------------------------------
CNSmlDMHostServer3::~CNSmlDMHostServer3()
	{
	_DBG_FILE("CNSmlDMHostServer3::~CNSmlDMHostServer3(): begin");
	_DBG_FILE("CNSmlDMHostServer3::~CNSmlDMHostServer3(): end");
	}

// ------------------------------------------------------------------------------------------------
// CNSmlDMHostServer3::CNSmlDMHostServer3()
//	C++ constructor.
// ------------------------------------------------------------------------------------------------
CNSmlDMHostServer3::CNSmlDMHostServer3()
	{
	}

// ------------------------------------------------------------------------------------------------
// CNSmlDMHostServer3::PanicServer()
//	Panics the server.
//	This is called if the instance creation of DM Host Server 3 leaves,
//	e.g. due to call 'StartL' CServer2 -function.
//	@param aPanic. The panic reason code.
// ------------------------------------------------------------------------------------------------
void CNSmlDMHostServer3::PanicServer ( TNSmlDmHostServerPanic aPanic )
    {
	_LIT ( KTxtDmHostServer3, "NSmlDmHostServer3");
	User::Panic ( KTxtDmHostServer3, aPanic );
    }

// ------------------------------------------------------------------------------------------------
// CNSmlDMHostServer3::NewSessionL()
//	Calls CallNewSessionL.
//	@param aVersion. The version of the server.
//	@param aMessage. An object which encapsulates a client request.
//	@return CSession2*. The created new session instance.
// ------------------------------------------------------------------------------------------------
CSession2* CNSmlDMHostServer3::NewSessionL ( const TVersion& aVersion, const RMessage2& aMessage ) const
	{ 
    return CallNewSessionL ( aVersion, aMessage );
   	}

// ------------------------------------------------------------------------------------------------
// E32Main
// Entry point when the server is launched.
// ------------------------------------------------------------------------------------------------
GLDEF_C TInt E32Main()
    {
    return CNSmlDMHostServer3::LaunchServer(NULL);
    }

// End of file