vpnengine/dmadipsecvpn/src/eventlogger.cpp
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2003-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: Implementation of CEventLogger
       
    15 *
       
    16 */
       
    17 
       
    18 #include <utf.h>
       
    19 
       
    20 #include "eventlogger.h"
       
    21 #include "vpnlogger.h"
       
    22 #include "eventviewer.h"
       
    23 
       
    24 #include "dmadadapterimplconst.h"
       
    25 #include <vpnlogmessages.rsg>
       
    26 
       
    27 _LIT(KUnknownPolicy, "unknown");
       
    28 _LIT8(KUnknownVpnAp, "unknown");
       
    29 _LIT8(KUnknownIap, "unknown");
       
    30 
       
    31 
       
    32 CEventLogger* CEventLogger::NewL()
       
    33     {
       
    34     CEventLogger* self = new (ELeave) CEventLogger();
       
    35     CleanupStack::PushL(self);
       
    36     self->ConstructL();
       
    37     CleanupStack::Pop(self);
       
    38     return self;
       
    39     }
       
    40 
       
    41 CEventLogger::CEventLogger()
       
    42     {
       
    43     }
       
    44     
       
    45 void CEventLogger::ConstructL()
       
    46     {
       
    47     User::LeaveIfError(iEventMediator.Connect());
       
    48     }
       
    49 
       
    50 CEventLogger::~CEventLogger()
       
    51     {
       
    52     iEventMediator.Close();
       
    53     }
       
    54 
       
    55 void CEventLogger::LogEvent(RVpnServ& vpnApi, TUint aMsgId, const TDesC* aDes1, TInt aInt1, TInt aInt2)
       
    56     {
       
    57     TRACE("CEventLogger::LogEvent");
       
    58     
       
    59     TVpnPolicyDetails policyDetails;
       
    60 
       
    61     if (aMsgId == R_VPN_MSG_CREATED_VPN_ACCESS_POINT_WITH_AP ||
       
    62         aMsgId == R_VPN_MSG_CREATED_VPN_ACCESS_POINT_WITH_SNAP)
       
    63         {
       
    64         // Descriptor parameter 1 is a policy ID
       
    65         if (aDes1 && aDes1->Length() > 0)
       
    66             {
       
    67             TInt err = KErrNone;
       
    68             err = vpnApi.GetPolicyDetails(*aDes1, policyDetails);
       
    69             
       
    70             // If we cannot find the policy name...
       
    71             if (err)
       
    72                 {
       
    73                 // ...use the policy ID as the name
       
    74                 policyDetails.iName.Copy(*aDes1);
       
    75                 }
       
    76             }
       
    77         else
       
    78             {
       
    79             // Completely unknown policy reference
       
    80             policyDetails.iName.Copy(KUnknownPolicy);
       
    81             }
       
    82         }
       
    83 
       
    84     // Make a 8 bit copy of the policy name
       
    85     
       
    86     HBufC8* nameCopy = HBufC8::New(policyDetails.iName.Length());   
       
    87     if (!nameCopy)
       
    88         {
       
    89         return;
       
    90         }
       
    91 
       
    92     TPtr8 nameCopyPtr = nameCopy->Des();
       
    93     CnvUtfConverter::ConvertFromUnicodeToUtf8(nameCopyPtr, policyDetails.iName);
       
    94     LogEvent(aMsgId, nameCopy, aInt1, aInt2);
       
    95 
       
    96     delete nameCopy;
       
    97     }
       
    98         
       
    99 void CEventLogger::LogEvent(TUint aMsgId, const TDesC8* aDes1, TInt aInt1, TInt aInt2)
       
   100   	{
       
   101   	TRACE("CEventLogger::LogEvent 2");
       
   102   	
       
   103     TUid sourceUid = TUid::Uid(KDmAdDllUid);    
       
   104 
       
   105     TIapName vpnApName(KUnknownVpnAp);
       
   106     TIapName realConnectionName(KUnknownIap);
       
   107                 
       
   108     switch (aMsgId)
       
   109         {
       
   110         case R_VPN_MSG_CREATED_VPN_ACCESS_POINT_WITH_AP:
       
   111             EventViewer::GetIapNames(aInt1, vpnApName, aInt2, realConnectionName);
       
   112 
       
   113             //The return value is ignored
       
   114             iEventMediator.ReportLogEvent(sourceUid, EInfo,
       
   115                                           R_VPN_MSG_CREATED_VPN_ACCESS_POINT_WITH_AP,
       
   116                                           3, &vpnApName, aDes1, &realConnectionName);
       
   117             break;
       
   118         case R_VPN_MSG_CREATED_VPN_ACCESS_POINT_WITH_SNAP:
       
   119             EventViewer::GetIapName(aInt1, vpnApName);
       
   120             EventViewer::GetSnapName(aInt2, realConnectionName);
       
   121 
       
   122             iEventMediator.ReportLogEvent(sourceUid, EInfo,
       
   123                                           R_VPN_MSG_CREATED_VPN_ACCESS_POINT_WITH_SNAP,
       
   124                                           3, &vpnApName, aDes1, &realConnectionName);
       
   125             
       
   126             break;
       
   127         default:
       
   128             return;
       
   129         }
       
   130     }