upnp/upnpstack/upnphttptransfer/src/httptransfertimer.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 /** @file
       
     2 * Copyright (c) 2007 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 the class CHttpTransferTimer.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // User include files
       
    20 #include "httptransfertimer.h"
       
    21 #include "httptransfertimerobserver.h"
       
    22 
       
    23 // --------------------------------------------------------------------------
       
    24 // CHttpTransferTimer::NewL
       
    25 // (See comments in header file)
       
    26 // --------------------------------------------------------------------------
       
    27 //
       
    28 CHttpTransferTimer* CHttpTransferTimer::NewL( 
       
    29                                       TInt aInterval,
       
    30                                       MHttpTransferTimerObserver* aCallback )
       
    31     {
       
    32     CHttpTransferTimer* self = new (ELeave) 
       
    33                                 CHttpTransferTimer( aInterval, aCallback );
       
    34     CleanupStack::PushL( self );
       
    35     self->ConstructL();
       
    36     CleanupStack::Pop( self );
       
    37     return self;
       
    38     }
       
    39 
       
    40 // --------------------------------------------------------------------------
       
    41 // CHttpTransferTimer::CHttpTransferTimer
       
    42 // (See comments in header file)
       
    43 // --------------------------------------------------------------------------
       
    44 //
       
    45 CHttpTransferTimer::CHttpTransferTimer( 
       
    46                                        TInt aInterval,
       
    47                                        MHttpTransferTimerObserver* aCallback)
       
    48     {
       
    49     iInterval = aInterval;
       
    50     iCallback = aCallback;
       
    51     }
       
    52 
       
    53 // --------------------------------------------------------------------------
       
    54 // CHttpTransferTimer::ConstructL
       
    55 // (See comments in header file)
       
    56 // --------------------------------------------------------------------------
       
    57 //
       
    58 void CHttpTransferTimer::ConstructL()
       
    59     {
       
    60 
       
    61     // Create CHeartbeat object
       
    62     iHeartbeat = CHeartbeat::NewL( EPriorityLow );
       
    63 
       
    64     iCounter = 0;
       
    65 
       
    66     // Start the heartbeat timer (beating on every second)
       
    67     iHeartbeat->Start( ETwelveOClock, this );
       
    68     }
       
    69 
       
    70 // --------------------------------------------------------------------------
       
    71 // CHttpTransferTimer::~CHttpTransferTimer()
       
    72 // (See comments in header file)
       
    73 // --------------------------------------------------------------------------
       
    74 //
       
    75 CHttpTransferTimer::~CHttpTransferTimer()
       
    76     {
       
    77     // Cancel any outstanding request
       
    78     if( iHeartbeat )
       
    79         {
       
    80         iHeartbeat->Cancel();
       
    81         delete iHeartbeat;
       
    82         }
       
    83     }
       
    84 
       
    85 // --------------------------------------------------------------------------
       
    86 // CHttpTransferTimer::Beat()
       
    87 // (See comments in header file)
       
    88 // --------------------------------------------------------------------------
       
    89 //
       
    90 void CHttpTransferTimer::Beat()
       
    91     {
       
    92     // Increase heartbeat counter
       
    93     iCounter++;
       
    94 
       
    95     // If interval is reached, do the call back
       
    96     if( iCounter == iInterval )
       
    97         {
       
    98         if( iCallback )
       
    99             {
       
   100             iCallback->TimerCallback();
       
   101             }
       
   102         iCounter = 0;
       
   103         }
       
   104     }
       
   105 
       
   106 //  End of File