bearermanagement/mpm/src/mpmconnpermquerytimer.cpp
author Simon Howkins <simonh@symbian.org>
Thu, 18 Nov 2010 15:05:52 +0000
branchRCL_3
changeset 76 40780c2f3a6b
parent 55 fc7b30ed2058
permissions -rw-r--r--
Adjusted to avoid exports, etc, from a top-level bld.inf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
 * All rights reserved.
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
 *
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
 * Initial Contributors:
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
 *
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
 * Contributors:
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
 *
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
 * Description: Implementation of class CMPMConnPermQueryTimer.
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
 * This timer is used for preventing excessive connection permission queries,
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
 * when the used has cancelled the previous connection permission query.
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
 *
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
 */
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include "mpmlogger.h"
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include "mpmserver.h"
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include "mpmexpirytimer.h"
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include "mpmconnpermquerytimer.h"
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
// ---------------------------------------------------------------------------
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
// Creates a new object by calling the two-phased constructor.
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
// ---------------------------------------------------------------------------
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
//
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
CMPMConnPermQueryTimer* CMPMConnPermQueryTimer::NewL( CMPMServer* aServer )
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
    {
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
    MPMLOGSTRING( "CMPMConnPermQueryTimer::NewL" )
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
            
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
    CMPMConnPermQueryTimer* self = new( ELeave ) CMPMConnPermQueryTimer( aServer );
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
    CleanupStack::PushL( self );
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
    self->ConstructL();
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
    CleanupStack::Pop( self );
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
    return self;
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
    }
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
// ---------------------------------------------------------------------------
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
// Default C++ constructor.
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
// ---------------------------------------------------------------------------
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
//
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
CMPMConnPermQueryTimer::CMPMConnPermQueryTimer( CMPMServer* aServer ) :
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
    iServer( aServer )
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
    {
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
    MPMLOGSTRING( "CMPMConnPermQueryTimer::CMPMConnPermQueryTimer" )
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
    }
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
// ---------------------------------------------------------------------------
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
// Symbian 2nd phase constructor.
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
// ---------------------------------------------------------------------------
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
//
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
void CMPMConnPermQueryTimer::ConstructL()
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
    {
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
    MPMLOGSTRING( "CMPMConnPermQueryTimer::ConstructL" )
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
    iExpiryTimer = CMPMExpiryTimer::NewL( *this, KTimeout );
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
    }
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
// ---------------------------------------------------------------------------
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
// Destructor.
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
// ---------------------------------------------------------------------------
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
//
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
CMPMConnPermQueryTimer::~CMPMConnPermQueryTimer()
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
    {
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
    MPMLOGSTRING( "CMPMConnPermQueryTimer::~CMPMConnPermQueryTimer" )
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
    if ( iExpiryTimer )
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
        {
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
        iExpiryTimer->Cancel();
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
        delete iExpiryTimer;
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
        }
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
    }
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
// ---------------------------------------------------------------------------
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
// Start the timer.
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
// ---------------------------------------------------------------------------
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
//
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
void CMPMConnPermQueryTimer::StartTimer()
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
    {
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
    MPMLOGSTRING( "CMPMConnPermQueryTimer::StartTimer" )
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
    if ( iExpiryTimer )
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
        {
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
        iExpiryTimer->Cancel();
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
        iExpiryTimer->Start();    
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
        }
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
    }
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
// ---------------------------------------------------------------------------
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
// Handles the timeout.
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
// ---------------------------------------------------------------------------
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
//
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
void CMPMConnPermQueryTimer::HandleTimedOut()
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    {
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
    MPMLOGSTRING( "CMPMConnPermQueryTimer::HandleTimedOut" )
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
    iServer->ResetConnPermQueryTimer();
fc7b30ed2058 Revision: 201030
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
    }