connectionmonitoring/connectionmonitorui/src/ConnectionInfoBase.cpp
branchRCL_3
changeset 12 ea6e024ea6f9
parent 8 2e6c4614c58e
child 55 fc7b30ed2058
equal deleted inserted replaced
8:2e6c4614c58e 12:ea6e024ea6f9
    72                            RConnectionMonitor* const aConnectionMonitor,
    72                            RConnectionMonitor* const aConnectionMonitor,
    73                            TConnMonBearerType aConnectionBearerType,
    73                            TConnMonBearerType aConnectionBearerType,
    74                            CActiveWrapper* aActiveWrapper ) :
    74                            CActiveWrapper* aActiveWrapper ) :
    75     iConnectionMonitor( aConnectionMonitor ), 
    75     iConnectionMonitor( aConnectionMonitor ), 
    76     iStartTime( NULL ),
    76     iStartTime( NULL ),
       
    77     iLastSpeedUpdate( 0 ),
    77     iDeletedFromCMUI( EFalse ),
    78     iDeletedFromCMUI( EFalse ),
    78     iActiveWrapper( aActiveWrapper )
    79     iActiveWrapper( aActiveWrapper )
    79     {
    80     {
    80     CMUILOGGER_WRITE( "CConnectionInfoBase constuctor - start " );
    81     CMUILOGGER_WRITE( "CConnectionInfoBase constuctor - start " );
    81     iConnectionStatus = EConnectionUninitialized;
    82     iConnectionStatus = EConnectionUninitialized;
    82     iConnectionId = aConnectionId;
    83     iConnectionId = aConnectionId;
    83     iConnectionBearerType = aConnectionBearerType;
    84     iConnectionBearerType = aConnectionBearerType;
    84     iLastSpeedUpdate.UniversalTime();
       
    85     CMUILOGGER_WRITE( "CConnectionInfoBase constuctor - end " );
    85     CMUILOGGER_WRITE( "CConnectionInfoBase constuctor - end " );
    86     }
    86     }
    87 
    87 
    88 
    88 
    89 // ---------------------------------------------------------
    89 // ---------------------------------------------------------
   420 // ---------------------------------------------------------
   420 // ---------------------------------------------------------
   421 //
   421 //
   422 void CConnectionInfoBase::RefreshTransferSpeedsL()
   422 void CConnectionInfoBase::RefreshTransferSpeedsL()
   423     {
   423     {
   424     CMUILOGGER_ENTERFN( "CConnectionInfoBase::RefreshTransferSpeedsL" );
   424     CMUILOGGER_ENTERFN( "CConnectionInfoBase::RefreshTransferSpeedsL" );
       
   425     const TInt KUpdatingIntervalInMillisec = 500;
       
   426     const TInt KStandardKilo = 1000;
       
   427     const TInt KDataKilo = 1024;
       
   428     
   425     TUint up = iUploaded;
   429     TUint up = iUploaded;
   426     TUint down = iDownloaded;
   430     TUint down = iDownloaded;
   427 
   431 
   428     RefreshSentReceivedDataL();
   432     RefreshSentReceivedDataL();
   429 
   433 
   430     TTime now;
   434     TTime now;
   431     now.UniversalTime();
   435     now.UniversalTime();
   432 
   436     
   433     // 100 * 1/1000sec
   437     // calculate time difference in milliseconds
   434     const TUint KOnesec = 1000;
   438     TInt diffTime = I64INT( now.MicroSecondsFrom( iLastSpeedUpdate ).Int64() / 
   435     TUint diffTime = I64LOW( now.MicroSecondsFrom( iLastSpeedUpdate ).Int64() /
   439             TInt64( KStandardKilo ) );
   436                                                         TInt64( 1000 ) );
       
   437 
   440 
   438     if ( iLastSpeedUpdate.Int64() == 0 )
   441     if ( iLastSpeedUpdate.Int64() == 0 )
   439         {
   442         {
   440         iLastSpeedUpdate = now;
   443         iLastSpeedUpdate = now;
   441 
   444 
   443         iUpSpeed.quot = 0;
   446         iUpSpeed.quot = 0;
   444         iUpSpeed.rem = 0;
   447         iUpSpeed.rem = 0;
   445         iDownSpeed.quot = 0;
   448         iDownSpeed.quot = 0;
   446         iDownSpeed.rem = 0;
   449         iDownSpeed.rem = 0;
   447         }
   450         }
   448     else if ( diffTime > 500 )
   451     else if ( diffTime > KUpdatingIntervalInMillisec )         
   449         // at least 1/2sec passed
   452         {
   450         {
   453         // bytes/millisec
   451         // bytes/sec
   454         TInt upSpeed = ( iUploaded - up ) / diffTime;
   452         div_t upSpeed = div( ( iUploaded - up ) * KOnesec, diffTime );
   455         TInt downSpeed = ( iDownloaded - down ) / diffTime;
   453         div_t downSpeed = div( ( iDownloaded - down ) * KOnesec, diffTime );
   456         
       
   457         // bytes/sec       
       
   458         upSpeed *= KStandardKilo;
       
   459         downSpeed *= KStandardKilo;
       
   460     
   454         // kbytes/sec
   461         // kbytes/sec
   455         iUpSpeed = div( upSpeed.quot, 1024 );
   462         iUpSpeed = div( upSpeed, KDataKilo );
   456         iDownSpeed = div( downSpeed.quot, 1024 );
   463         iDownSpeed = div( downSpeed, KDataKilo );
   457 
   464 
   458         iLastSpeedUpdate = now;
   465         iLastSpeedUpdate = now;
   459         }
   466         }
       
   467     
   460     CMUILOGGER_LEAVEFN( "CConnectionInfoBase::RefreshTransferSpeedsL" );
   468     CMUILOGGER_LEAVEFN( "CConnectionInfoBase::RefreshTransferSpeedsL" );
   461     }
   469     }
   462 
   470 
   463 
   471 
   464 // ---------------------------------------------------------
   472 // ---------------------------------------------------------