wlanutilities/wlansniffer/engine/server/src/wsfservercloser.cpp
branchRCL_3
changeset 24 63be7eb3fc78
parent 23 b852595f5cbe
child 25 f28ada11abbf
equal deleted inserted replaced
23:b852595f5cbe 24:63be7eb3fc78
     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:  Implementation of CWsfServerCloser
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  CLASS HEADER
       
    20 #include "wsfserver.h"
       
    21 
       
    22 
       
    23 /**
       
    24 * Timeout after all closing requirements are met (in microseconds)
       
    25 */
       
    26 static const TInt KServerClosureWaitTimer = 2 * 1000 * 1000; 
       
    27 
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // CWsfServer::CWsfServerCloser::NewL
       
    31 // ---------------------------------------------------------------------------
       
    32 //		
       
    33 CWsfServer::CWsfServerCloser* CWsfServer::CWsfServerCloser::NewL()
       
    34 	{
       
    35 	CWsfServer::CWsfServerCloser* thisPtr = new (ELeave) CWsfServerCloser();
       
    36 	CleanupStack::PushL( thisPtr );
       
    37 	thisPtr->ConstructL();
       
    38 	CleanupStack::Pop( thisPtr );
       
    39 	return thisPtr;
       
    40 	}
       
    41 
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // CWsfServer::CWsfServerCloser::~CWsfServerCloser
       
    45 // ---------------------------------------------------------------------------
       
    46 //		
       
    47 CWsfServer::CWsfServerCloser::~CWsfServerCloser()
       
    48 	{
       
    49 	Cancel();
       
    50 	}
       
    51 
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CWsfServer::CWsfServerCloser::CWsfServerCloser
       
    55 // ---------------------------------------------------------------------------
       
    56 //		
       
    57 CWsfServer::CWsfServerCloser::CWsfServerCloser(): 
       
    58     CTimer( CActive::EPriorityStandard ),
       
    59     iWaitForOwnedConnection( EFalse ),
       
    60     iWaitForBrowserExit( EFalse ),
       
    61     iWaitForClients( EFalse )
       
    62     {
       
    63 	CActiveScheduler::Add( this );
       
    64 	}
       
    65 
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // CWsfServer::CWsfServerCloser::ConstructL
       
    69 // ---------------------------------------------------------------------------
       
    70 //		
       
    71 void CWsfServer::CWsfServerCloser::ConstructL()
       
    72 	{
       
    73 	CTimer::ConstructL();
       
    74 	}
       
    75 
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // CWsfServer::CWsfServerCloser::RunL
       
    79 // ---------------------------------------------------------------------------
       
    80 //		
       
    81 void CWsfServer::CWsfServerCloser::RunL()
       
    82 	{
       
    83 	CActiveScheduler::Stop();
       
    84 	}
       
    85 
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // CWsfServer::CWsfServerCloser::StartClosureWait
       
    89 // ---------------------------------------------------------------------------
       
    90 //		
       
    91 void CWsfServer::CWsfServerCloser::StartClosureWait()
       
    92 	{
       
    93 	Cancel();
       
    94 	
       
    95 	if ( !iWaitForClients && !iWaitForBrowserExit && !iWaitForOwnedConnection )
       
    96 	    {
       
    97 	    After( TTimeIntervalMicroSeconds32( KServerClosureWaitTimer ) );
       
    98 	    }	
       
    99 	}
       
   100 
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CWsfServer::CWsfServerCloser::WaitForClients
       
   104 // ---------------------------------------------------------------------------
       
   105 //		
       
   106 void CWsfServer::CWsfServerCloser::WaitForClients( TBool aWait )
       
   107     {
       
   108     iWaitForClients = aWait;
       
   109     if ( !aWait )
       
   110         {
       
   111         StartClosureWait();
       
   112         }
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // CWsfServer::CWsfServerCloser::WaitForOwnedConnection
       
   117 // ---------------------------------------------------------------------------
       
   118 //		
       
   119 void CWsfServer::CWsfServerCloser::WaitForOwnedConnection( TBool aWait )
       
   120     {
       
   121     iWaitForOwnedConnection = aWait;
       
   122     if ( !aWait )
       
   123         {
       
   124         StartClosureWait();
       
   125         }
       
   126     }
       
   127     
       
   128     
       
   129 // ---------------------------------------------------------------------------
       
   130 // CWsfServer::CWsfServerCloser::WaitForBrowserExit
       
   131 // ---------------------------------------------------------------------------
       
   132 //		
       
   133 void CWsfServer::CWsfServerCloser::WaitForBrowserExit( TBool aWait )
       
   134     {
       
   135     iWaitForBrowserExit = aWait;
       
   136     if ( !aWait )
       
   137         {
       
   138         StartClosureWait();
       
   139         }
       
   140     }
       
   141