syncmlfw/common/obex/obexcommserver/src/nsmlobexcommserver.cpp
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2002 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:  SyncML Obex server internal server module
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <nsmldebug.h>
       
    20 
       
    21 #include "nsmlobexcommserver.h"
       
    22 #include "nsmlobexdefs.h"
       
    23 
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CNSmlObexCommServer::NewL
       
    29 // Two-phased constructor.
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 EXPORT_C CNSmlObexCommServer* CNSmlObexCommServer::NewL( const TDesC& aServerName )
       
    33 	{
       
    34 	_DBG_FILE("CNSmlObexCommServer::NewL(): begin");
       
    35 	CNSmlObexCommServer *pS = new (ELeave) CNSmlObexCommServer();
       
    36 	CleanupStack::PushL(pS);
       
    37 	pS->ConstructL();
       
    38 	pS->StartL(aServerName);
       
    39 	CleanupStack::Pop(); // pS
       
    40 	_DBG_FILE("CNSmlObexCommServer::NewL(): end");
       
    41 	return pS;
       
    42 	}
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CNSmlObexCommServer::~CNSmlObexCommServer
       
    46 // Destructor.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 EXPORT_C CNSmlObexCommServer::~CNSmlObexCommServer()
       
    50 	{
       
    51 	_DBG_FILE("CNSmlObexCommServer::~CNSmlObexCommServer(): begin");
       
    52 	delete iSendBuffer;
       
    53 	delete iRecvBuffer;
       
    54 	delete iClientReceiveTimeOut;
       
    55 	delete iServerGetSendTimeOut;
       
    56 	_DBG_FILE("CNSmlObexCommServer::~CNSmlObexCommServer(): end");
       
    57 	}
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CNSmlObexCommServer::NewSessionL
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 CSession2* CNSmlObexCommServer::NewSessionL( const TVersion& aVersion,
       
    64     const RMessage2& /*aMessage*/ ) const
       
    65 	{
       
    66 	_DBG_FILE("CNSmlObexCommServer::NewSessionL(): begin");
       
    67 	if( iSessionCount > 1 )
       
    68 		{
       
    69 		_DBG_FILE("CNSmlObexCommServer - too many sessions, leaving");
       
    70 		User::Leave(KErrCouldNotConnect);
       
    71 		}
       
    72 	TVersion v(KNSmlObexCommServerVersionMajor, KNSmlObexCommServerVersionMinor, 0);
       
    73 	if( !User::QueryVersionSupported(v,aVersion) )
       
    74 		{
       
    75 		_DBG_FILE("CNSmlObexCommServer::NewSessionL(): wrong version offered -> BAIL OUT!");
       
    76 		User::Leave(KErrNotSupported);
       
    77 		}
       
    78 	_DBG_FILE("CNSmlObexCommServer::NewSessionL(): end");
       
    79 	return CNSmlObexCommSession::NewL( *CONST_CAST(CNSmlObexCommServer*, this));	
       
    80 	}
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CNSmlObexCommServer::CNSmlObexCommServer
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 CNSmlObexCommServer::CNSmlObexCommServer() : CServer2(EPriorityStandard)
       
    87 	{
       
    88 	}
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CNSmlObexCommServer::ConstructL
       
    92 // Symbian 2nd phase constructor.
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CNSmlObexCommServer::ConstructL()
       
    96 	{
       
    97 	_DBG_FILE("CNSmlObexCommServer::ConstructL(): begin");
       
    98 	iClientReceiveTimeOut = CNSmlTimeOut::NewL();
       
    99 	iServerGetSendTimeOut = CNSmlTimeOut::NewL();
       
   100 	_DBG_FILE("CNSmlObexCommServer::ConstructL(): end");
       
   101 	}
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CNSmlObexCommServer::IncrementSessions
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CNSmlObexCommServer::IncrementSessions()
       
   108 	{
       
   109 	_DBG_FILE("CNSmlObexCommServer::IncrementSessions(): begin");
       
   110 	iSessionCount++;
       
   111 	_DBG_FILE("CNSmlObexCommServer::IncrementSessions(): end");
       
   112 	}
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CNSmlObexCommServer::DecrementSessions
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CNSmlObexCommServer::DecrementSessions()
       
   119 	{
       
   120 	_DBG_FILE("CNSmlObexCommServer::DecrementSessions(): begin");
       
   121 	iSessionCount--;
       
   122 	if( !iSessionCount )
       
   123 		{
       
   124 		Shutdown();
       
   125 		}
       
   126 	_DBG_FILE("CNSmlObexCommServer::DecrementSessions(): end");
       
   127 	}
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CNSmlObexCommServer::Shutdown
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 void CNSmlObexCommServer::Shutdown()
       
   134 	{
       
   135 	_DBG_FILE("CNSmlObexCommServer::Shutdown(): begin");
       
   136 	CActiveScheduler::Stop();
       
   137 	_DBG_FILE("CNSmlObexCommServer::Shutdown(): end");
       
   138 	}
       
   139 
       
   140 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   141 
       
   142 //End of File