vpnengine/eventviewer/src/eventviewer.cpp
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2000-2009 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:   Event viewer
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <f32file.h>
       
    22 #include <barsc.h>
       
    23 #include <barsread.h>
       
    24 #include <vpnlogmessages.rsg>
       
    25 #include <cmmanagerext.h>
       
    26 #include <cmdestinationext.h>
       
    27 #include <utf.h>
       
    28 
       
    29 #include "eventviewer.h"
       
    30 #include "eventviewer2.h"
       
    31 #include "log_eventviewer.h"
       
    32 
       
    33 /////////////////////////////////////////////
       
    34 // Method IDs
       
    35 ////////////////////////////////////////////
       
    36 #define KGetMostRecentEvent           0
       
    37 #define KGetNextEvent                 1
       
    38 #define KGetPreviousEvent             2
       
    39 #define KGetEventUsingEventNumber     3
       
    40 
       
    41 
       
    42 //////////////////////////////////////////////////////////////
       
    43 // Create EventViewer object
       
    44 /////////////////////////////////////////////////////////////
       
    45 EXPORT_C CEventViewer* CEventViewer::NewL()
       
    46     {
       
    47     CEventViewer *self = new (ELeave) CEventViewer();
       
    48     CleanupStack::PushL(self);
       
    49     self->ConstructL();
       
    50     LOG(Log::Printf(_L("Constructing EventViewer\n")));
       
    51     CleanupStack::Pop();        // self
       
    52     return self;
       
    53     }
       
    54 
       
    55 /////////////////////////////////////////////////////////////
       
    56 // CEventViewer::CEventViewer()
       
    57 // C++ default constructor
       
    58 /////////////////////////////////////////////////////////////
       
    59 //
       
    60 //  CEventViewer::CEventViewer() : iEikonEnv(*iCoeEnv)
       
    61 //      {
       
    62 //      }
       
    63 
       
    64 //////////////////////////////////////////////////////////////
       
    65 // Phase 2 constructor
       
    66 /////////////////////////////////////////////////////////////
       
    67 void CEventViewer::ConstructL()
       
    68     {
       
    69     TInt status = iFS.Connect();
       
    70     if (status != KErrNone)
       
    71         {
       
    72         LOG(Log::Printf(_L("iFS.Connect failed %d\n"), status));
       
    73         User::Leave(status);
       
    74         }
       
    75 
       
    76     status = iEventMediator.Connect();
       
    77     if (status != KErrNone)
       
    78         {
       
    79         LOG(Log::Printf(_L("iEventMediator.Connect failed %d\n"), status));
       
    80         User::Leave(status);
       
    81         }
       
    82     
       
    83     status = OpenLogFile();                             // Open log file and read file header
       
    84     if (status != KErrNone)
       
    85         {
       
    86         LOG(Log::Printf(_L("OpenLogFile failed %d\n"), status));
       
    87         User::Leave(status);
       
    88         }
       
    89     OpenResourceFileL();
       
    90     }
       
    91 //////////////////////////////////////////////////////////////
       
    92 // Destructor
       
    93 /////////////////////////////////////////////////////////////
       
    94 CEventViewer::~CEventViewer()
       
    95     {
       
    96     LOG(Log::Printf(_L("Destructing EventViewer\n")));
       
    97 
       
    98     delete iLogFileBuf;
       
    99     iLogFileBuf = 0;
       
   100     CloseLogFile();
       
   101     delete iResultBuf;
       
   102     iResultBuf = 0;
       
   103     iResourceFile.Close();
       
   104     iFS.Close();
       
   105     iEventMediator.Close();
       
   106     }
       
   107 
       
   108 //////////////////////////////////////////////////////////////
       
   109 // OpenResourceFileL()
       
   110 // Used in ConstructL to get resource file
       
   111 //////////////////////////////////////////////////////////////
       
   112 //
       
   113 void CEventViewer::OpenResourceFileL()
       
   114    {
       
   115    //RResourceFile resourceFile;
       
   116    _LIT(KResourceFile, "\\resource\\vpnlogmessages.rsc");
       
   117 
       
   118    TFileName resourceFileName(KResourceFile);
       
   119    TFileName dllName;
       
   120    Dll::FileName(dllName);
       
   121    TBuf<2> drive = dllName.Left(2);
       
   122    resourceFileName.Insert(0, drive);
       
   123    iResourceFile.OpenL(iFS, resourceFileName);
       
   124    iResourceFile.ConfirmSignatureL();
       
   125    }
       
   126 
       
   127     
       
   128 //////////////////////////////////////////////////////////////
       
   129 // Release resources allocated for a call
       
   130 /////////////////////////////////////////////////////////////
       
   131 //void CEventViewer::ReleaseResourcesL()
       
   132 //    {
       
   133 
       
   134 //    }
       
   135 
       
   136 //////////////////////////////////////////////////////////////////
       
   137 //  
       
   138 // GetMostRecentEvent
       
   139 //
       
   140 /////////////////////////////////////////////////////////////////
       
   141 EXPORT_C TInt CEventViewer::GetMostRecentEvent( 
       
   142                              HBufC*&  aEventText,
       
   143                              TEventProperties& aEventProperties) 
       
   144     {
       
   145     TInt status = GetRequestedEvent(
       
   146                             aEventText,
       
   147                             aEventProperties,
       
   148                             0,         // Event number       
       
   149                             KGetMostRecentEvent);
       
   150     return status;
       
   151     }
       
   152 //////////////////////////////////////////////////////////////////
       
   153 //  
       
   154 // GetNextEvent
       
   155 //
       
   156 /////////////////////////////////////////////////////////////////
       
   157 EXPORT_C TInt CEventViewer::GetNextEvent( 
       
   158                                 HBufC*&  aEventText,
       
   159                                 TEventProperties& aEventProperties)
       
   160     {
       
   161     TInt status = GetRequestedEvent(
       
   162                              aEventText,
       
   163                              aEventProperties,
       
   164                              0,                           // Event number        
       
   165                              KGetNextEvent);
       
   166     return status;
       
   167     }
       
   168 
       
   169 //////////////////////////////////////////////////////////////////
       
   170 //  
       
   171 // GetPrevousEvent
       
   172 //
       
   173 /////////////////////////////////////////////////////////////////
       
   174 EXPORT_C TInt CEventViewer::GetPreviousEvent( 
       
   175                                          HBufC*&  aEventText,
       
   176                                          TEventProperties& aEventProperties)
       
   177     {
       
   178     TInt status = GetRequestedEvent(
       
   179                              aEventText,
       
   180                              aEventProperties,
       
   181                              0,                   // Event number 
       
   182                              KGetPreviousEvent);
       
   183     return status;
       
   184     }
       
   185 
       
   186 //////////////////////////////////////////////////////////////////
       
   187 //  
       
   188 // GetEventUsingEventNumber
       
   189 //
       
   190 /////////////////////////////////////////////////////////////////
       
   191 EXPORT_C TInt CEventViewer::GetEventUsingEventNumber( 
       
   192                                                 HBufC*&  aEventText,
       
   193                                                 TUint32   aEventNumber, 
       
   194                                                 TEventProperties& aEventProperties)
       
   195     {
       
   196     TInt status = GetRequestedEvent(
       
   197                             aEventText,
       
   198                             aEventProperties,
       
   199                             aEventNumber, 
       
   200                             KGetEventUsingEventNumber);
       
   201     return status;
       
   202     }
       
   203 
       
   204 
       
   205 //////////////////////////////////////////////////////////////////
       
   206 //  
       
   207 // GetRequestedEvent - Get Requested Event
       
   208 // This is a common function for API calls. It searches the event
       
   209 // that the API user has requested. The function returns a buffer
       
   210 // containing the event text and TEventProperties structure that
       
   211 // contains  some parameters relating to the event.
       
   212 //
       
   213 /////////////////////////////////////////////////////////////////
       
   214     TInt CEventViewer::GetRequestedEvent( 
       
   215                                           HBufC*&                 aEventText,
       
   216                                           TEventProperties&        aEventProperties,
       
   217                                           TUint32                  aEventNumber, 
       
   218                                           TInt                     aMethodId)
       
   219     {
       
   220     TInt status = 0;              
       
   221     TRAPD (err, status = GetRequestedEventL(
       
   222                                            aEventText,
       
   223                                            aEventProperties,
       
   224                                            aEventNumber, 
       
   225                                            aMethodId))
       
   226     
       
   227     if (err != KErrNone)
       
   228         {
       
   229         LOG(Log::Printf(_L("API request failed, status %d\n"), err));
       
   230 
       
   231         status = err;
       
   232         }
       
   233     return status;
       
   234     }
       
   235     
       
   236 TInt CEventViewer::GetRequestedEventL( 
       
   237                                      HBufC*&                 aEventText,
       
   238                                      TEventProperties&        aEventProperties,
       
   239                                      TUint32                  aEventNumber, 
       
   240                                      TInt                     aMethodId)
       
   241     {
       
   242     TInt status;
       
   243     LOG(Log::Printf(_L("API request received, method =  %d\n"), aMethodId));
       
   244 
       
   245     //
       
   246     // Store the API parameters to this object
       
   247     //
       
   248     iEventText = &aEventText;
       
   249     iEventProperties = &aEventProperties;
       
   250     //
       
   251     // Produce the event number that the user is requesting
       
   252     //
       
   253 
       
   254     switch (aMethodId)
       
   255         {
       
   256         case KGetMostRecentEvent:
       
   257             {
       
   258 
       
   259             // Read the log file to memory buffer if not yet done
       
   260 
       
   261             if (iLogFileBuf == 0)
       
   262                 {
       
   263 
       
   264                 status = ReadWholeLogFileToMemoryBuffer();
       
   265                 if (status != KErrNone)
       
   266                     {
       
   267                     break;
       
   268                     }
       
   269                 TakeCopyOfFileHeader(iCurrFileHeader, iPreviousFileHeader);
       
   270                 }
       
   271 
       
   272             // Check if the log file has been modified and read the log
       
   273             // file header
       
   274 
       
   275             else
       
   276                 {
       
   277                 status = ReadLogFileHeader();
       
   278                 if (status != KErrNone)
       
   279                     {
       
   280                     break;
       
   281                     }
       
   282                 if (IsLogFileModified())
       
   283                     {
       
   284                     TakeCopyOfFileHeader(iCurrFileHeader, iPreviousFileHeader);
       
   285                     }
       
   286                 }
       
   287             iRequestedEventNumber = iCurrFileHeader.iCurrEventNumber;
       
   288             break;
       
   289             }
       
   290             
       
   291         case KGetNextEvent:
       
   292             {
       
   293             iRequestedEventNumber++;
       
   294             break;
       
   295             }
       
   296         case KGetPreviousEvent:
       
   297             {
       
   298             iRequestedEventNumber--;
       
   299             break;
       
   300             }
       
   301         case KGetEventUsingEventNumber:
       
   302             {
       
   303             iRequestedEventNumber = aEventNumber;
       
   304             break;
       
   305             }
       
   306         default:    
       
   307             {
       
   308             break;
       
   309             }
       
   310         }   
       
   311     //
       
   312     // Check the validity of requested event number
       
   313     //
       
   314     
       
   315     if (iRequestedEventNumber == 0 ||
       
   316         iRequestedEventNumber > iCurrFileHeader.iCurrEventNumber ||
       
   317         iLogFileBuf == 0)                // Logfile not yet in memory   
       
   318         {
       
   319         LOG(Log::Printf(_L("API request completed, requested event not found \n")));
       
   320         return KErrNotFound;
       
   321         }
       
   322     //
       
   323     // Search the event from the memory resident log file
       
   324     //
       
   325     status = EventLookup(iRequestedEventNumber);
       
   326     if (status != KErrNone)
       
   327         {
       
   328         return status;              // Event not found
       
   329         }
       
   330     //
       
   331     // Event found, copy the packed format log element parameters to an
       
   332     // unpacked object
       
   333     //
       
   334 
       
   335     CopyPackedLogElemToUnpackedObject(iPositionOfCurrLogElem);
       
   336                 
       
   337     //
       
   338     // Search the event text relating to the MsgId
       
   339     //
       
   340     HBufC* eventTextBuf;
       
   341     eventTextBuf = SearchEventTextL(iUnpackedLogElem.iMsgId);
       
   342     if (eventTextBuf == 0)
       
   343         {
       
   344         return KErrNoMemory;
       
   345         }
       
   346 
       
   347     //
       
   348     // Modify the event text with the descriptor data
       
   349     // DescrPtr points to a list of following elements:
       
   350     //  TInt   DataLength
       
   351     //  TInt8  Data
       
   352     //
       
   353 
       
   354     TUint32 descrDataPosition = iPositionOfCurrLogElem + LOG_ELEM_HEADER_LTH; 
       
   355     HBufC* modifiedEventTextBuf = ModifyEventText(
       
   356                                      eventTextBuf,
       
   357                                     iUnpackedLogElem.iDescrCount,     // Count of descriptor elements
       
   358                                     descrDataPosition);               // Descriptors: lth,lth,...data,data...
       
   359     if (modifiedEventTextBuf == 0)
       
   360         {
       
   361         return KErrNoMemory;
       
   362         }
       
   363     //
       
   364     // An event is available, return data to the caller
       
   365     //
       
   366    *iEventText = modifiedEventTextBuf;           
       
   367     iResultBuf  = 0;
       
   368     iEventProperties->iEventNumber               = iUnpackedLogElem.iEventNumber;     
       
   369     iEventProperties->iMsgId                     = iUnpackedLogElem.iMsgId;
       
   370     TTime tmpTime(iUnpackedLogElem.iTimeStamp);  
       
   371     iEventProperties->iTimeStamp                 = tmpTime;
       
   372     iEventProperties->iSourceComponent           = iUnpackedLogElem.iSourceComponent;
       
   373     iEventProperties->iCategory                  = iUnpackedLogElem.iCategory;
       
   374     LOG(Log::Printf(_L("API request completed OK \n")));
       
   375 
       
   376     return KErrNone;
       
   377 
       
   378     }
       
   379 
       
   380     
       
   381     //////////////////////////////////////////////////////////////////////
       
   382     // EventLookup
       
   383     // This function searches an event from the log file buffer that
       
   384     // matches with the requested event number.
       
   385     //////////////////////////////////////////////////////////////////////
       
   386 TInt CEventViewer::EventLookup(TUint32 aEventNumber)
       
   387     {
       
   388     TUint32 positionOfLogElemEnd = iCurrFileHeader.iPositionOfNextFree;
       
   389     TUint32 positionOfLogElem;
       
   390     TInt    searchGoing = ETrue;
       
   391     TInt status = KErrNone;              
       
   392     iWrappingOccured = EFalse;
       
   393     //
       
   394     // Loop here until matching event found or end of elements reached
       
   395     // or any error found
       
   396     //
       
   397     
       
   398     while (searchGoing && status == KErrNone)
       
   399         {
       
   400     //
       
   401     // Check if wrapping 1
       
   402     //
       
   403         if (positionOfLogElemEnd == EVENTLOG_FILE_HEADER_LTH)
       
   404             {
       
   405 
       
   406 
       
   407             if (iCurrFileHeader.iPositionOfWrapping != 0)
       
   408                 {
       
   409                 positionOfLogElemEnd = iCurrFileHeader.iPositionOfWrapping;  // Wrapping occurs
       
   410                 iWrappingOccured = ETrue;
       
   411                 }
       
   412             else
       
   413                 {
       
   414                 status = KErrNotFound;
       
   415                 continue;
       
   416                 }
       
   417             }
       
   418 
       
   419     //
       
   420     // Produce the start position of an event   
       
   421     //
       
   422 
       
   423         status = GetStartPositionOfLogElem( positionOfLogElemEnd,
       
   424                                             &positionOfLogElem);
       
   425         if (status != KErrNone)
       
   426             {
       
   427             continue;
       
   428             }
       
   429 
       
   430     //
       
   431     // Check if requested event has been found
       
   432     //
       
   433 
       
   434         if (iUnpackedLogElem.iEventNumber != aEventNumber)
       
   435             {
       
   436             positionOfLogElemEnd = positionOfLogElem;
       
   437             continue;                           // Not found, continue
       
   438             }
       
   439     //
       
   440     // Requested event found, stop the loop  
       
   441     //
       
   442         status = KErrNone;
       
   443         iPositionOfCurrLogElem = positionOfLogElem;
       
   444         searchGoing = EFalse;
       
   445 
       
   446         }
       
   447 
       
   448     return status;
       
   449     }
       
   450 
       
   451     
       
   452 /////////////////////////////////////////////////////////////////////
       
   453 // SearchEventText
       
   454 // This function searches from the localization file the text string
       
   455 // relating to the MsgId parameter and allocates an buffer in which
       
   456 // it returns the data to the caller.
       
   457 //
       
   458 /////////////////////////////////////////////////////////////////////
       
   459     
       
   460 HBufC*  CEventViewer::SearchEventTextL( TUint32 aMsgId)
       
   461     {
       
   462     HBufC8* resourceBuf = NULL;
       
   463     HBufC* textDataBuf = NULL;
       
   464 
       
   465     //
       
   466     // MsgId is a code defined in epoc32\include\eventviewererr.rsg
       
   467     // file. It refers to a message in .rsc file.
       
   468     //
       
   469     TInt msgNumber = STATIC_CAST(TInt, aMsgId); 
       
   470     resourceBuf = iResourceFile.AllocReadL( msgNumber);
       
   471     
       
   472     TResourceReader resourceReader;
       
   473 
       
   474     resourceReader.SetBuffer(resourceBuf);
       
   475 
       
   476     textDataBuf = HBufC::New(resourceBuf->Length());
       
   477     if (textDataBuf)
       
   478         {
       
   479         TPtr textDataPtr(textDataBuf->Des());
       
   480 
       
   481         resourceReader.Read((void*)textDataBuf->Ptr(), resourceBuf->Length());
       
   482         textDataPtr.SetLength(resourceBuf->Length()/2);
       
   483         }
       
   484 
       
   485     delete resourceBuf;
       
   486     return textDataBuf;
       
   487     }
       
   488 
       
   489 /////////////////////////////////////////////////////////////////////
       
   490 // ModifyEventText
       
   491 // This function modifies the event text by the descriptors.
       
   492 // Both the event text and descriptors are parameters of the
       
   493 // function.
       
   494 //
       
   495 /////////////////////////////////////////////////////////////////////
       
   496 
       
   497 HBufC*  CEventViewer::ModifyEventText(
       
   498                          HBufC*  aEventTextSrc,
       
   499                          TUint32 aDescrCount,         // Count of descriptor elements
       
   500                          TUint32 aDescrDataPosition)  // Descriptors: lth data lth data.... 
       
   501     {
       
   502     HBufC* modifiedEventText;
       
   503 
       
   504     //
       
   505     // If descriptors exist, build pointer to the first
       
   506     // length definition. The format of descriptor data
       
   507     // is as follows:
       
   508     //   -- TUInt32 Length of parameter 1 (lth1)
       
   509     //   -- TUInt32 Length of parameter 2 (lth2)
       
   510     //   -- TUInt32 Length of parameter n (lthx)
       
   511     //   -- TInt8[lth1] Data 1
       
   512     //   -- TInt8[lth2] Data 2
       
   513     //   -- TInt8[lthx] Data n
       
   514     //              Variable length data, The format of 
       
   515     //              data is defined by the conversion
       
   516     //              specification characters in the text string
       
   517     //
       
   518 
       
   519     //
       
   520     // No descriptors, return localisation data  buffer
       
   521     //
       
   522     if (aDescrCount == 0)
       
   523         {
       
   524         return aEventTextSrc;
       
   525         }
       
   526 
       
   527     //
       
   528     // Build TPtr8 pointer for descriptor list
       
   529     //
       
   530     
       
   531     TInt descrLth = iUnpackedLogElem.iEventLength -
       
   532                            LOG_ELEM_HEADER_LTH -
       
   533                            LOG_ELEM_TRAILER_LTH;
       
   534     TPtr8 logFileBuf (iLogFileBuf->Des()); // Log file in memory
       
   535     TPtr8 descrListPtr (const_cast<TUint8*>(logFileBuf.Ptr())+ aDescrDataPosition, // Data ptr
       
   536                        descrLth,   // Data length
       
   537                        descrLth);  // Max length
       
   538     //
       
   539     // Modify the localisation data buffer with  the descriptor data 
       
   540     //
       
   541     modifiedEventText = FormatEvent(
       
   542                                  aDescrCount,
       
   543                                  descrListPtr,
       
   544                                  aEventTextSrc->Des());
       
   545 
       
   546 
       
   547     delete aEventTextSrc;
       
   548     return modifiedEventText;
       
   549     }
       
   550 
       
   551 
       
   552 /////////////////////////////////////////////////////////////////////
       
   553 // GetIapName
       
   554 // These functions are used to convert an IAP ID to IAP name.
       
   555 //
       
   556 ////////////////////////////////////////////////////////////////////
       
   557 EXPORT_C TInt EventViewer::GetIapName(TUint32 aIapId, TIapName& aIapName)
       
   558     {
       
   559     TRAPD(err, DoGetIapNameL(aIapId, aIapName));
       
   560     return err;
       
   561     }
       
   562 
       
   563 EXPORT_C TInt EventViewer::GetSnapName(TUint32 aSnapId, TIapName& aSnapName)
       
   564     {
       
   565     TRAPD(err, DoGetSnapNameL(aSnapId, aSnapName));
       
   566     return err;
       
   567     }
       
   568 
       
   569 EXPORT_C TInt EventViewer::GetIapNames(TUint32 aIapId1, TIapName& aIapName1,
       
   570                                         TUint32 aIapId2, TIapName& aIapName2)
       
   571     {
       
   572     TRAPD(err, DoGetIapNamesL(aIapId1, aIapName1, aIapId2, aIapName2));
       
   573     return err;
       
   574     }
       
   575 
       
   576 void EventViewer::DoGetIapNameL(TUint32 aIapId, TIapName& aIapName)
       
   577     {
       
   578     using namespace CMManager;
       
   579     
       
   580     RCmManagerExt cmManagerExt;
       
   581     cmManagerExt.OpenL();
       
   582     CleanupClosePushL(cmManagerExt);
       
   583     
       
   584     RCmConnectionMethodExt connectionMethod = cmManagerExt.ConnectionMethodL( aIapId );
       
   585     CleanupClosePushL(connectionMethod);
       
   586     
       
   587     HBufC* cmName = connectionMethod.GetStringAttributeL(ECmName); // Ownership passed
       
   588     
       
   589     aIapName.Copy(*cmName);
       
   590     delete cmName;
       
   591     cmName = NULL;
       
   592     
       
   593     CleanupStack::PopAndDestroy(&connectionMethod);
       
   594     CleanupStack::PopAndDestroy(&cmManagerExt);
       
   595     }
       
   596 
       
   597 void EventViewer::DoGetIapNamesL(TUint32 aIapId1, TIapName& aIapName1,
       
   598                                   TUint32 aIapId2, TIapName& aIapName2)
       
   599     {
       
   600     using namespace CMManager;
       
   601     
       
   602     RCmManagerExt cmManagerExt;
       
   603     cmManagerExt.OpenL();
       
   604     CleanupClosePushL(cmManagerExt);
       
   605     
       
   606     RCmConnectionMethodExt connectionMethod1 = cmManagerExt.ConnectionMethodL( aIapId1 );
       
   607     CleanupClosePushL(connectionMethod1);
       
   608     
       
   609     HBufC* cmName1 = connectionMethod1.GetStringAttributeL(ECmName);
       
   610     CleanupStack::PushL(cmName1);
       
   611     
       
   612     aIapName1.Copy(*cmName1);
       
   613 
       
   614     RCmConnectionMethodExt connectionMethod2 = cmManagerExt.ConnectionMethodL( aIapId2 );
       
   615     CleanupClosePushL(connectionMethod2);
       
   616     
       
   617     HBufC* cmName2 = connectionMethod2.GetStringAttributeL(ECmName); // Ownership passed
       
   618     
       
   619     aIapName2.Copy(*cmName2);
       
   620     
       
   621     delete cmName2;
       
   622     cmName2 = NULL;
       
   623     CleanupStack::PopAndDestroy(4);
       
   624     }
       
   625 
       
   626 
       
   627 void EventViewer::DoGetSnapNameL(TUint32 aSnapId, TIapName& aSnapName)
       
   628     {
       
   629     RCmManagerExt cmManagerExt;
       
   630     cmManagerExt.OpenL();
       
   631     CleanupClosePushL(cmManagerExt);
       
   632     
       
   633     RCmDestinationExt destination = cmManagerExt.DestinationL( aSnapId );
       
   634     CleanupClosePushL(destination);
       
   635     
       
   636     HBufC* snapName16bit = destination.NameLC();            
       
   637     CnvUtfConverter::ConvertFromUnicodeToUtf8(aSnapName, *snapName16bit);    
       
   638     CleanupStack::PopAndDestroy(snapName16bit);
       
   639     
       
   640     CleanupStack::PopAndDestroy(); //destination
       
   641     CleanupStack::PopAndDestroy(); //cmManagerExt
       
   642     }
       
   643 
       
   644 /////////////////////////////////////////////////////////////////////
       
   645 // DeleteLogFile
       
   646 // This function deletes the eventlog.bin file
       
   647 //
       
   648 ////////////////////////////////////////////////////////////////////
       
   649 EXPORT_C TInt CEventViewer::DeleteLogFile()
       
   650     {
       
   651     TRAPD(err, DoDeleteLogFileL());
       
   652     return err;
       
   653     }