phoneengine/loghandling/src/cpelogexternaldata.cpp
changeset 37 ba76fc04e6c2
child 51 f39ed5e045e0
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2003 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:  This file contains the implementation of CPELogExternalData class 
       
    15 *                member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 //  INCLUDE FILES
       
    22 #include "cpelogexternaldata.h"
       
    23 #include "cpeloghandling.h"
       
    24 #include "cpeloginfo.h"
       
    25 #include <centralrepository.h>
       
    26 #include <LogsDomainCRKeys.h>
       
    27 #include <talogger.h>
       
    28 
       
    29 // EXTERNAL DATA STRUCTURES
       
    30 // None
       
    31 
       
    32 // EXTERNAL FUNCTION PROTOTYPES  
       
    33 /// None
       
    34 
       
    35 // CONSTANTS
       
    36 // None
       
    37 
       
    38 // MACROS
       
    39 // None
       
    40 
       
    41 // LOCAL CONSTANTS AND MACROS
       
    42 // None
       
    43 
       
    44 // MODULE DATA STRUCTURES
       
    45 // None
       
    46 
       
    47 // LOCAL FUNCTION PROTOTYPES
       
    48 // None
       
    49 
       
    50 
       
    51 // ================= MEMBER FUNCTIONS =======================
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CPELogExternalData::NewL
       
    55 // Two-phased constructor.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CPELogExternalData* CPELogExternalData::NewL
       
    59         ( 
       
    60         CPELogHandling& aOwner
       
    61         )  
       
    62     {
       
    63     TEFLOGSTRING(KTAOBJECT, "LOG CPELogExternalData::NewL start.");
       
    64     CPELogExternalData* self = 
       
    65         new ( ELeave ) CPELogExternalData( aOwner );
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL();
       
    68     CleanupStack::Pop( self );
       
    69     TEFLOGSTRING(KTAOBJECT, "LOG CPELogExternalData::NewL complete.");
       
    70     return self;
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CPELogExternalData::~CPELogExternalData
       
    75 // Destructor.
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 /*****************************************************
       
    79 *    Series 60 Customer / REPOSITORY
       
    80 *    Series 60  REPOSITORY API
       
    81 *****************************************************/
       
    82 CPELogExternalData::~CPELogExternalData()
       
    83     {
       
    84     TEFLOGSTRING( KTAOBJECT, "LOG CPELogExternalData::~CPELogExternalData" );
       
    85     delete iRepository;
       
    86     }
       
    87     
       
    88 // -----------------------------------------------------------------------------
       
    89 // CPELogExternalData::CPELogExternalData
       
    90 // C++ default constructor can NOT contain any code, that
       
    91 // might leave.
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 CPELogExternalData::CPELogExternalData
       
    95         ( 
       
    96         CPELogHandling& aOwner
       
    97         ) : iOwner( aOwner ),
       
    98             iFirstCallStartTime( 0 )
       
    99     {
       
   100     TEFLOGSTRING( KTAOBJECT, "LOG CPELogExternalData::CPELogExternalData" );
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CPELogExternalData::ConstructL
       
   105 // Symbian 2nd phase constructor can leave.
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 /*****************************************************
       
   109 *    Series 60 Customer / REPOSITORY
       
   110 *    Series 60  REPOSITORY API
       
   111 *****************************************************/
       
   112 void CPELogExternalData::ConstructL()
       
   113     {
       
   114     TEFLOGSTRING( KTAOBJECT, "LOG CPELogExternalData::ConstructL" );
       
   115 
       
   116     iRepository = CRepository::NewL( KCRUidLogs );
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CPELogExternalData::UpdateCallTimers
       
   121 // Write call durations to TASharedData.
       
   122 // (other items were commented in a header).
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 void CPELogExternalData::UpdateCallTimers
       
   126         ( 
       
   127         const CPELogInfo& aLogInfo // Call information
       
   128         )
       
   129     {
       
   130     TInt duration( 0 );
       
   131 
       
   132     duration = aLogInfo.Duration().Int();
       
   133 
       
   134     switch( aLogInfo.CurrentLine() )
       
   135         {
       
   136         case CCCECallParameters::ECCELineTypePrimary:
       
   137             {
       
   138             if ( RMobileCall::EMobileOriginated == aLogInfo.CallDirection() )
       
   139                 {
       
   140                 if ( CPELogInfo::EPEVoIPEvent == aLogInfo.EventType() )
       
   141                     {
       
   142                     UpdateTimer( KLogsDialledCallsTimerVoIP, 
       
   143                         duration, *iRepository );
       
   144                     }
       
   145                 else
       
   146                     {
       
   147                     UpdateTimer( KLogsDialledCallsTimerLine1, 
       
   148                         duration, *iRepository );
       
   149                     }
       
   150                 }
       
   151             else if ( RMobileCall::EMobileTerminated == aLogInfo.CallDirection() )
       
   152                 {
       
   153                 if( CPELogInfo::EPEVoIPEvent == aLogInfo.EventType() )
       
   154                     {
       
   155                     UpdateTimer( KLogsReceivedCallsTimerVoIP, 
       
   156                         duration, *iRepository );
       
   157                     }
       
   158                 else
       
   159                     {
       
   160                     UpdateTimer( KLogsReceivedCallsTimerLine1, 
       
   161                         duration, *iRepository );
       
   162                     }
       
   163                 }
       
   164             }
       
   165             break;
       
   166         case CCCECallParameters::ECCELineTypeAux:
       
   167             {
       
   168             if( RMobileCall::EMobileOriginated == aLogInfo.CallDirection() ) 
       
   169                 {
       
   170                 UpdateTimer( KLogsDialledCallsTimerLine2, 
       
   171                     duration, *iRepository );
       
   172                 }
       
   173             else  if ( RMobileCall::EMobileTerminated == aLogInfo.CallDirection() )
       
   174                 {
       
   175                 UpdateTimer( KLogsReceivedCallsTimerLine2, 
       
   176                     duration, *iRepository );
       
   177                 }
       
   178             }
       
   179             break;
       
   180         default:
       
   181             {
       
   182             TEFLOGSTRING2( KTAINT, "LOG CPELogExternalData::UpdateCallTimers(): FAILED. Unexpected line: %d", aLogInfo.CurrentLine() );
       
   183             }
       
   184             break;
       
   185         }    
       
   186     }
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // CPELogExternalData::UpdateLastCallTimerByLine
       
   190 // Updates line specific last call timers to shared data.
       
   191 // (other items were commented in a header).
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 /*****************************************************
       
   195 *    Series 60 Customer / REPOSITORY
       
   196 *    Series 60  REPOSITORY API
       
   197 *****************************************************/
       
   198 void CPELogExternalData::UpdateLastCallTimerByLine
       
   199         ( 
       
   200         const CPELogInfo& aLogInfo 
       
   201         )
       
   202     {
       
   203     TInt errorCode( KErrNone );
       
   204 
       
   205     switch( aLogInfo.CurrentLine() )
       
   206         {
       
   207         case CCCECallParameters::ECCELineTypePrimary:
       
   208             {
       
   209             if ( CPELogInfo::EPEVoIPEvent == aLogInfo.EventType() )
       
   210                 {
       
   211                 TEFLOGSTRING( KTAREQOUT, 
       
   212                 "LOG CPELogExternalData::UpdateLastCallTimerByLine > CRepository::Set(KLogsLastCallTimerVoIP)" )
       
   213                 errorCode = iRepository->Set( 
       
   214                     KLogsLastCallTimerVoIP, aLogInfo.Duration().Int() );
       
   215                 }
       
   216             else
       
   217                 {
       
   218                 TEFLOGSTRING( KTAREQOUT, 
       
   219                 "LOG CPELogExternalData::UpdateLastCallTimerByLine > CRepository::Set(KLogsLastCallTimerLine1)" )
       
   220                 errorCode = iRepository->Set( 
       
   221                     KLogsLastCallTimerLine1, aLogInfo.Duration().Int() );                
       
   222                 }
       
   223             }
       
   224             break;
       
   225         case CCCECallParameters::ECCELineTypeAux:
       
   226             {
       
   227             TEFLOGSTRING( KTAREQOUT, 
       
   228             "LOG CPELogExternalData::UpdateLastCallTimerByLine > CRepository::Set(KLogsLastCallTimerLine2)" );
       
   229 
       
   230             errorCode = iRepository->Set( KLogsLastCallTimerLine2, aLogInfo.Duration().Int() );
       
   231             }
       
   232             break;
       
   233         default:
       
   234             errorCode = KErrArgument;
       
   235             break;
       
   236         } 
       
   237 
       
   238     if ( errorCode != KErrNone )
       
   239        {
       
   240        TEFLOGSTRING2( KTAERROR, "LOG CPELogExternalData::UpdateLastCallTimerByLine(): FAILED. ErrorCode: %d", errorCode );
       
   241        }
       
   242    
       
   243     }
       
   244 
       
   245 // -----------------------------------------------------------------------------
       
   246 // CPELogExternalData::UpdateLastCallTimer
       
   247 // Updates the last call timer to shared data.
       
   248 // (other items were commented in a header).
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 /*****************************************************
       
   252 *    Series 60 Customer / REPOSITORY
       
   253 *    Series 60  REPOSITORY API
       
   254 *****************************************************/
       
   255 TInt CPELogExternalData::UpdateLastCallTimer
       
   256         ( 
       
   257         const CPELogInfo& aLogInfo
       
   258         )
       
   259     {
       
   260     TInt errorCode( KErrNone );
       
   261 
       
   262     // No ongoing entries (calls) -> update last active call timer to shared data.
       
   263     // In multicall cases time is from start of first to end of last.
       
   264     TTimeIntervalSeconds startsDelta;
       
   265     aLogInfo.CallStartTime().SecondsFrom( iFirstCallStartTime, startsDelta );
       
   266     TEFLOGSTRING2( KTAINT, "LOG CPELogExternalData::UpdateLastCallTimer(): StartsDelta: %d", startsDelta.Int() );
       
   267 
       
   268     TInt duration = startsDelta.Int() + aLogInfo.Duration().Int();
       
   269 
       
   270     TEFLOGSTRING2( KTAREQOUT, 
       
   271         "LOG CPELogExternalData::UpdateLastCallTimer > CRepository::Set(KLogsActualLastCallTimer, %d )", duration );
       
   272     errorCode = iRepository->Set( KLogsActualLastCallTimer, duration );
       
   273     if ( errorCode != KErrNone )
       
   274         {
       
   275         TEFLOGSTRING2( KTAERROR, "LOG CPELogExternalData::UpdateLastCallTimer(): FAILED setting actual last call timer. ErrorCode: %d", errorCode );
       
   276         }        
       
   277     iFirstCallStartTime = 0;
       
   278     return duration;
       
   279     }
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CPELogExternalData::IncreaseMissedCallValue
       
   283 // Increase missed call's counter.
       
   284 // (other items were commented in a header).
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 /*****************************************************
       
   288 *    Series 60 Customer / REPOSITORY
       
   289 *    Series 60  REPOSITORY API
       
   290 *****************************************************/
       
   291 void CPELogExternalData::IncreaseMissedCallValue( const TInt aCallId )
       
   292     {
       
   293     TInt errorCode( KErrNone );
       
   294     TInt value;
       
   295     
       
   296     TEFLOGSTRING( KTAREQOUT, 
       
   297         "LOG CPELogExternalData::IncreaseMissedCallValue > CRepository::Get" );
       
   298     errorCode = iRepository->Get( KLogsNewMissedCalls, value );
       
   299 
       
   300     if ( errorCode == KErrNone )
       
   301         {
       
   302         ++value;
       
   303         TEFLOGSTRING2( KTAREQOUT, 
       
   304             "LOG CPELogExternalData::IncreaseMissedCallValue > CRepository::Set. value = %d"
       
   305             , value );
       
   306         errorCode = iRepository->Set( KLogsNewMissedCalls, value );
       
   307         iOwner.ResetMissedCalls( aCallId );
       
   308         }
       
   309     else
       
   310         {
       
   311         TEFLOGSTRING2( KTAERROR, 
       
   312             "LOG CPELogExternalData::IncreaseMissedCallValue(): Failed: %d", errorCode );
       
   313         }
       
   314     }
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // CPELogExternalData::SetFirstCallStartTime
       
   318 // Set the call start time on the connected state.
       
   319 // (other items were commented in a header).
       
   320 // -----------------------------------------------------------------------------
       
   321 //
       
   322 void CPELogExternalData::SetFirstCallStartTime
       
   323         (
       
   324         const TTime& aFirstCallStartTime
       
   325         )
       
   326     {
       
   327     iFirstCallStartTime = aFirstCallStartTime;
       
   328     }    
       
   329 
       
   330 // -----------------------------------------------------------------------------
       
   331 // CPELogExternalData::UpdateTimer
       
   332 // Updates the desired timer to shared data.
       
   333 // -----------------------------------------------------------------------------
       
   334 //
       
   335 /*****************************************************
       
   336 *    Series 60 Customer / REPOSITORY
       
   337 *    Series 60  REPOSITORY API
       
   338 *****************************************************/
       
   339 void CPELogExternalData::UpdateTimer
       
   340         ( 
       
   341         const TUint32 aTimer, 
       
   342         TInt aDuration,
       
   343         CRepository& aRepository
       
   344         )
       
   345     {
       
   346     TEFLOGSTRING( KTAREQOUT, 
       
   347         "LOG CPELogExternalData::UpdateTimer > CRepository::Get" );    
       
   348     TInt errorCode( KErrNone );
       
   349     TInt value( 0 );
       
   350     errorCode = aRepository.Get( aTimer, value );
       
   351     
       
   352     if ( errorCode == KErrNone )
       
   353         {
       
   354         value += aDuration;
       
   355         
       
   356         TEFLOGSTRING( KTAREQOUT, 
       
   357             "LOG CPELogExternalData::UpdateTimer > CRepository::Set" );
       
   358         
       
   359         errorCode = aRepository.Set( aTimer, value );
       
   360         }
       
   361     
       
   362     if ( errorCode != KErrNone )
       
   363         {
       
   364         TEFLOGSTRING2( KTAERROR, 
       
   365             "LOG CPELogExternalData::UpdateTimer(): Failed: %d", errorCode );
       
   366         }
       
   367     }
       
   368         
       
   369 // End of File