emailuis/uicomponents/src/fsinteractioninterval.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2006-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:  CFsInteractionInterval is a utility class that can be used 
       
    15 *                as specify intervals that adapt to user input.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "emailtrace.h"
       
    21 #include "fsinteractioninterval.h"  // Class definition
       
    22 
       
    23 
       
    24 CFsInteractionInterval::CFsInteractionInterval(TReal32 aScalar)
       
    25         : iScalar(aScalar), iLastTimeMs(0)
       
    26     {
       
    27     FUNC_LOG;
       
    28     iLastTime.UniversalTime();
       
    29     }
       
    30 
       
    31 
       
    32 void CFsInteractionInterval::SetScalar(TReal32 aScalar)
       
    33     {
       
    34     FUNC_LOG;
       
    35     iScalar = aScalar;
       
    36     }
       
    37     
       
    38     
       
    39 TReal32 CFsInteractionInterval::Scalar() const
       
    40     {
       
    41     FUNC_LOG;
       
    42     return iScalar;
       
    43     }
       
    44     
       
    45 
       
    46 TInt CFsInteractionInterval::Interval(TInt aIntervalTime)
       
    47     {
       
    48     FUNC_LOG;
       
    49     TTime now;
       
    50     
       
    51     now.UniversalTime();
       
    52     
       
    53     TInt64 delta;
       
    54     TUint32 elapsed(0);
       
    55     
       
    56     delta = now.MicroSecondsFrom( iLastTime ).Int64() / 1000;
       
    57     elapsed = delta;
       
    58     
       
    59     if(iScalar * elapsed < aIntervalTime)
       
    60         {
       
    61         // The last movement is probably still going on.
       
    62         aIntervalTime = TInt(elapsed * iScalar);
       
    63         }
       
    64     
       
    65     iLastTime = now;
       
    66     return aIntervalTime;
       
    67     /*
       
    68     TUint32 now = CHuiStatic::MilliSecondsSinceStart();
       
    69     TUint32 elapsed = now - iLastTimeMs;
       
    70     
       
    71     if(iScalar * elapsed < aIntervalTime)
       
    72         {
       
    73         // The last movement is probably still going on.
       
    74         aIntervalTime = TInt(elapsed * iScalar);
       
    75         }
       
    76         
       
    77     iLastTimeMs = now;
       
    78     
       
    79     return aIntervalTime;
       
    80     */
       
    81     }
       
    82