syncmlfw/dm/hostserver/dmhostservers/src/nsmldmhostserver4.cpp
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Specialized DM Host Server. In practice differs from 
       
    15 *				 the other servers only on the capability and the name.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // ------------------------------------------------------------------------------------------------
       
    21 // Includes
       
    22 // ------------------------------------------------------------------------------------------------
       
    23 #include <nsmldebug.h>
       
    24 #include "nsmldmclientandserver.h"
       
    25 #include "nsmldmhostserver4.h"
       
    26 
       
    27 // ------------------------------------------------------------------------------------------------
       
    28 // CNSmlDMHostServer4::LaunchServer()
       
    29 //	Launches the server.
       
    30 //	Calls the common code part (InitHostServer) of all specialized DM Host Servers.
       
    31 //	@param (TAny*). Not used in this function. 
       
    32 //	  			    Kept here for possible future needs.
       
    33 //	@return TInt. Return value from InitHostServer function.
       
    34 // ------------------------------------------------------------------------------------------------
       
    35 TInt CNSmlDMHostServer4::LaunchServer ( TAny* /*aStarted*/ )
       
    36     {
       
    37     return InitHostServer ( KNSmlDmHostServer4Name(), (TThreadFunction) ThreadFunction );
       
    38     }
       
    39 
       
    40 // ------------------------------------------------------------------------------------------------
       
    41 // CNSmlDMHostServer4::ThreadFunction()
       
    42 //	Calls the NewL for creating the DM Host Server 4 instance.
       
    43 //	This ThreadFunction is called when the 'common initialization actions' 
       
    44 //	are successfully run.
       
    45 //	Starts the active scheduler.
       
    46 //	@param aStarted. Not used.
       
    47 //	@return TInt. Returns always KErrNone.
       
    48 // ------------------------------------------------------------------------------------------------
       
    49 TInt CNSmlDMHostServer4::ThreadFunction ( TAny* /*aStarted*/ )
       
    50     {
       
    51 	CNSmlDMHostServer4* hs = NULL;
       
    52     TRAPD ( err, ( hs = CNSmlDMHostServer4::NewL ( KNSmlDmHostServer4Name() ) ) );
       
    53     RProcess::Rendezvous( err );
       
    54 	__ASSERT_ALWAYS ( !err, PanicServer ( ESvrCreateServer ) );    
       
    55     CActiveScheduler::Start();
       
    56     delete hs;
       
    57     return KErrNone;
       
    58     }
       
    59 
       
    60 // ------------------------------------------------------------------------------------------------
       
    61 // CNSmlDMHostServer4::NewL()
       
    62 //	Creates a new instance of DM Host Server 4.
       
    63 //	Adds the server with the specified name to the active scheduler, 
       
    64 //	and issues the first request for messages. 
       
    65 //	Signals the global semaphore, which releases the client (DM Tree Module)
       
    66 //	from the waiting state.
       
    67 //	@param aServerName. The name of the server: "nsmldmhostserver4".
       
    68 //	@return CNSmlDMHostServer4*. The created server instance.
       
    69 // ------------------------------------------------------------------------------------------------
       
    70 CNSmlDMHostServer4* CNSmlDMHostServer4::NewL ( const TDesC& aServerName )
       
    71 	{
       
    72 	CNSmlDMHostServer4* pS = new (ELeave) CNSmlDMHostServer4();
       
    73 	CleanupStack::PushL ( pS );
       
    74 	pS->StartL ( aServerName );
       
    75 	CleanupStack::Pop(); // pS
       
    76 	return pS;
       
    77 	}
       
    78 
       
    79 // ------------------------------------------------------------------------------------------------
       
    80 // CNSmlDMHostServer4::~CNSmlDMHostServer4()
       
    81 //	Destructor.
       
    82 // ------------------------------------------------------------------------------------------------
       
    83 CNSmlDMHostServer4::~CNSmlDMHostServer4()
       
    84 	{
       
    85 	_DBG_FILE("CNSmlDMHostServer4::~CNSmlDMHostServer4(): begin");
       
    86 	_DBG_FILE("CNSmlDMHostServer4::~CNSmlDMHostServer4(): end");
       
    87 	}
       
    88 
       
    89 // ------------------------------------------------------------------------------------------------
       
    90 // CNSmlDMHostServer4::CNSmlDMHostServer4()
       
    91 //	C++ constructor.
       
    92 // ------------------------------------------------------------------------------------------------
       
    93 CNSmlDMHostServer4::CNSmlDMHostServer4()
       
    94 	{
       
    95 	}
       
    96 
       
    97 // ------------------------------------------------------------------------------------------------
       
    98 // CNSmlDMHostServer4::PanicServer()
       
    99 //	Panics the server.
       
   100 //	This is called if the instance creation of DM Host Server 4 leaves,
       
   101 //	e.g. due to call 'StartL' CServer2 -function.
       
   102 //	@param aPanic. The panic reason code.
       
   103 // ------------------------------------------------------------------------------------------------
       
   104 void CNSmlDMHostServer4::PanicServer ( TNSmlDmHostServerPanic aPanic )
       
   105     {
       
   106 	_LIT ( KTxtDmHostServer4,"NSmlDmHostServer4");
       
   107 	User::Panic ( KTxtDmHostServer4, aPanic );
       
   108     }
       
   109 
       
   110 // ------------------------------------------------------------------------------------------------
       
   111 // CNSmlDMHostServer4::NewSessionL()
       
   112 //	Calls CallNewSessionL.
       
   113 //	@param aVersion. The version of the server.
       
   114 //	@param aMessage. An object which encapsulates a client request.
       
   115 //	@return CSession2*. The created new session instance.
       
   116 // ------------------------------------------------------------------------------------------------
       
   117 CSession2* CNSmlDMHostServer4::NewSessionL ( const TVersion& aVersion, const RMessage2& aMessage ) const
       
   118 	{ 
       
   119     return CallNewSessionL ( aVersion, aMessage );
       
   120    	}
       
   121 
       
   122 // ------------------------------------------------------------------------------------------------
       
   123 // E32Main
       
   124 // Entry point when the server is launched.
       
   125 // ------------------------------------------------------------------------------------------------
       
   126 GLDEF_C TInt E32Main()
       
   127     {
       
   128     return CNSmlDMHostServer4::LaunchServer(NULL);
       
   129     }
       
   130 
       
   131 // End of file