voipplugins/ipapputils/voipeventlog/src/voipeventlog.cpp
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2007-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: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include "voipeventlogengine.h"
       
    19 #include "voipeventlogconstants.h"
       
    20 #include "voiperrorentry.h"
       
    21 #include "voipeventloglogger.h" // For logging
       
    22 #include "voipeventlog.h"
       
    23 
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // Constructor
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CVoipEventLog::CVoipEventLog()
       
    32     {
       
    33     }
       
    34 
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // Constructor
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 void CVoipEventLog::ConstructL()
       
    41     {
       
    42     VELLOGSTRING( "CVoipEventLog::ConstructL() - IN" );
       
    43 
       
    44     iEngine = CVoipEventLogEngine::NewL();
       
    45 
       
    46     VELLOGSTRING( "CVoipEventLog::ConstructL() - OUT" );
       
    47     }
       
    48 
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // Constructor
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 EXPORT_C CVoipEventLog* CVoipEventLog::NewL()
       
    55     {
       
    56     CVoipEventLog* self = CVoipEventLog::NewLC();
       
    57     CleanupStack::Pop( self );
       
    58     return self;
       
    59     }
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // Constructor
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 EXPORT_C CVoipEventLog* CVoipEventLog::NewLC()
       
    67     {
       
    68     CVoipEventLog* self = new( ELeave ) CVoipEventLog;
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL();
       
    71     return self;
       
    72     }
       
    73 
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // Destructor
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 EXPORT_C CVoipEventLog::~CVoipEventLog()
       
    80     {
       
    81     VELLOGSTRING( "CVoipEventLog::~CVoipEventLog() - IN" );
       
    82 
       
    83     delete iEngine;
       
    84 
       
    85     VELLOGSTRING( "CVoipEventLog::~CVoipEventLog() - OUT" );
       
    86     }
       
    87 
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // Writes an error data to event log
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 EXPORT_C TInt CVoipEventLog::WriteError( const CVoipErrorEntry& aErrorEntry )
       
    94     {
       
    95     TRAPD( err, DoWriteErrorL( aErrorEntry ) );
       
    96 
       
    97     return err;
       
    98     }
       
    99 
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // Writes an error code to event log
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 EXPORT_C TInt CVoipEventLog::WriteError( TInt aErrorCode )
       
   106     {
       
   107     TRAPD( err, DoWriteErrorL( aErrorCode ) );
       
   108 
       
   109     return err;
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // Reads error count from the log
       
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 EXPORT_C TInt CVoipEventLog::ErrorCount() const
       
   117     {
       
   118     TInt count( 0 );
       
   119     TRAPD( err, iEngine->ErrorCountL( count ) );
       
   120 
       
   121     if( err == KErrNone )
       
   122         {
       
   123         return count;
       
   124         }
       
   125     else
       
   126         {
       
   127         return err;
       
   128         }
       
   129     }
       
   130 
       
   131 // ---------------------------------------------------------------------------
       
   132 // Reads an error informaiton from the log
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 EXPORT_C TInt CVoipEventLog::ReadError( TInt aIndex, CVoipErrorEntry& aErrorEntry ) const
       
   136     {
       
   137     TRAPD( err, iEngine->ReadErrorL( aIndex, aErrorEntry); );
       
   138 
       
   139     return err;
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // Reset log history. After this method has called, all voip errors are cleared
       
   144 // from central repository.
       
   145 // ---------------------------------------------------------------------------
       
   146 //
       
   147 EXPORT_C TInt CVoipEventLog::ResetLog ()
       
   148     {
       
   149     VELLOGSTRING( "CVoipEventLog::ResetLog - IN" );
       
   150     TInt err = iEngine->ResetLogHistory ();
       
   151     return err;
       
   152     }
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // Writes an error data to event log
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 void CVoipEventLog::DoWriteErrorL( const CVoipErrorEntry& aErrorEntry )
       
   159     {
       
   160     iEngine->BeginTransactionLC();
       
   161 
       
   162     iEngine->WriteErrorL( aErrorEntry );
       
   163 
       
   164     iEngine->CommitTransactionL();
       
   165     }
       
   166 
       
   167 // ---------------------------------------------------------------------------
       
   168 // Writes an error code to event log
       
   169 // ---------------------------------------------------------------------------
       
   170 //
       
   171 void CVoipEventLog::DoWriteErrorL( TInt aErrorCode )
       
   172     {
       
   173     CVoipErrorEntry* entry = CVoipErrorEntry::NewLC();
       
   174     entry->SetErrorCode( aErrorCode );
       
   175 
       
   176     DoWriteErrorL( *entry );
       
   177 
       
   178     CleanupStack::PopAndDestroy( entry );
       
   179     }
       
   180