vpnui/vpnpolins/src/vpndevlockhandler.cpp
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 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:   Utility classes for device lock handling
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32std.h>
       
    21 
       
    22 #include "vpndevlockhandler.h"
       
    23 #include "policyinstaller_constants.h"
       
    24 #include "logvpncommon.h"
       
    25 #include "vpntcstub.h"
       
    26 
       
    27 
       
    28 // 64bit integer's string representation can be at 
       
    29 // most 20 bytes (+ sign) long...
       
    30 #define MAX_INT_STR_LEN 21
       
    31 
       
    32 
       
    33 //////////////
       
    34 // CVpnDevLockPolicy implementation
       
    35 
       
    36 CVpnDevLockPolicy* CVpnDevLockPolicy::NewL(const TInt aPolicy) 
       
    37     {
       
    38     LOG_("-> CVpnDevLockPolicy::NewL()");
       
    39     
       
    40     CVpnDevLockPolicy* self = new (ELeave) CVpnDevLockPolicy();
       
    41     CleanupStack::PushL(self);
       
    42     self->ConstructL(aPolicy);
       
    43     CleanupStack::Pop(self);
       
    44     
       
    45     LOG_("<- CVpnDevLockPolicy::NewL()");
       
    46     
       
    47     return self;
       
    48     }
       
    49 
       
    50 CVpnDevLockPolicy* CVpnDevLockPolicy::NewLC(const TInt aPolicy) 
       
    51     {
       
    52     LOG_("-> CVpnDevLockPolicy::NewLC()");
       
    53     
       
    54     CVpnDevLockPolicy* self = new (ELeave) CVpnDevLockPolicy();
       
    55     CleanupStack::PushL(self);
       
    56     self->ConstructL(aPolicy);
       
    57     
       
    58     LOG_("<- CVpnDevLockPolicy::NewLC()");
       
    59     
       
    60     return self;
       
    61     }
       
    62 
       
    63 CVpnDevLockPolicy* CVpnDevLockPolicy::NewLC() 
       
    64     {
       
    65     LOG_("-> CVpnDevLockPolicy::NewLC()");
       
    66     
       
    67     CVpnDevLockPolicy* self = new (ELeave) CVpnDevLockPolicy();
       
    68     CleanupStack::PushL(self);
       
    69     self->ConstructL();
       
    70     
       
    71     LOG_("<- CVpnDevLockPolicy::NewLC()");
       
    72     
       
    73     return self;
       
    74     }
       
    75 
       
    76 CVpnDevLockPolicy::CVpnDevLockPolicy()
       
    77     {
       
    78     }
       
    79 
       
    80 CVpnDevLockPolicy::~CVpnDevLockPolicy() 
       
    81     {
       
    82     LOG_("-> CVpnDevLockPolicy::CVpnDevLockPolicy()");
       
    83 
       
    84     // Delete each entry from the policy attributes array, 
       
    85     // and then reset the array itself
       
    86     if (iPolicyArray) 
       
    87         {
       
    88         for (TInt i = iPolicyArray->Count() - 1; i >= 0; i--) 
       
    89             {
       
    90             delete iPolicyArray->At(i);
       
    91             }
       
    92         iPolicyArray->Reset();
       
    93         }
       
    94 
       
    95     delete iPolicyArray;
       
    96 
       
    97     LOG_("<- CVpnDevLockPolicy::CVpnDevLockPolicy()");
       
    98     }
       
    99 
       
   100 void CVpnDevLockPolicy::ConstructL(const TInt aPolicy) 
       
   101     {
       
   102     LOG_("-> CVpnDevLockPolicy::ConstructL()");
       
   103     ConstructL();
       
   104     SetPolicyLevelL(aPolicy);
       
   105     LOG_("<- CVpnDevLockPolicy::ConstructL()");
       
   106     }
       
   107 
       
   108 void CVpnDevLockPolicy::ConstructL()
       
   109     {
       
   110     LOG_("-> CVpnDevLockPolicy::ConstructL()");
       
   111     iPolicyArray = new (ELeave) CArrayFixFlat<CVpnDevLockAttribute*>(3);
       
   112     LOG_("<- CVpnDevLockPolicy::ConstructL()");
       
   113     }
       
   114 
       
   115 void CVpnDevLockPolicy::SetPolicyAttributeL(const TInt aAttrib, const TInt aVal) 
       
   116     {
       
   117     LOG_("-> CVpnDevLockPolicy::SetPolicyAttributeL() int variant");
       
   118 
       
   119     CVpnDevLockAttribute* attrib = CVpnDevLockAttribute::NewL(aAttrib, aVal);
       
   120     CleanupStack::PushL(attrib);
       
   121     iPolicyArray->AppendL(attrib);
       
   122 
       
   123     // ownership's been transferred to array
       
   124     CleanupStack::Pop(attrib); 
       
   125 
       
   126 
       
   127     // Remove this (or rather flag for debug builds only)
       
   128     TInt val(0);
       
   129     attrib->AttributeValueAsIntL(val);
       
   130 
       
   131     LOG_1(" Items in array: %d", iPolicyArray->Count());
       
   132     LOG8_1("  Attrib  ID: %d", attrib->AttributeId());
       
   133     LOG8_1("  Attrib val: %d", val);
       
   134 
       
   135     LOG_("<- CVpnDevLockPolicy::SetPolicyAttributeL() int variant");
       
   136     }
       
   137 
       
   138 
       
   139 void CVpnDevLockPolicy::SetPolicyAttributeL(const TInt aAttrib, const TDesC8& aVal) 
       
   140     {
       
   141     LOG_("-> CVpnDevLockPolicy::SetPolicyAttributeL() str variant");
       
   142 
       
   143     // Create a new attribute and add it to the existing array of attributes
       
   144     CVpnDevLockAttribute* attrib = CVpnDevLockAttribute::NewL(aAttrib, aVal);
       
   145     CleanupStack::PushL(attrib);
       
   146     iPolicyArray->AppendL(attrib);
       
   147     
       
   148     // ownership's been transferred to array
       
   149     CleanupStack::Pop(attrib); 
       
   150 
       
   151     LOG8_1("  Attrib  ID: %d", attrib->AttributeId());
       
   152 
       
   153     LOG_("<- CVpnDevLockPolicy::SetPolicyAttributeL() str variant");
       
   154     }
       
   155 
       
   156 /**
       
   157  * Description of device lock levels (from SUB 415-467)
       
   158  *
       
   159  * 0. Do not enforce device lock
       
   160  *   - installing this policy has no impact on the device lock settings
       
   161  * 1. Enforce device lock with policy 1
       
   162  *   - no special requirements on lock code
       
   163  *   - autolock timeout 30 minutes
       
   164  *   - wipe after 20 unsuccessful unlocking attempts
       
   165  * 2. Enforce device lock with policy 2
       
   166  *   - lock code minimum length 5 characters
       
   167  *   - autolock timeout 10 minutes
       
   168  *   - wipe after 10 unsuccessful unlocking attempts
       
   169  * 3. Enforce device lock with policy 3
       
   170  *   - lock code mimimum length 5 characters
       
   171  *   - both characters and numbers required
       
   172  *   - both upper and lower case letters required
       
   173  *   - passcode expires every 30 days and must be changed
       
   174  *   - new passcode must not match any of the 5 previous passcodes 
       
   175  *   - autolock timeout 5 minutes
       
   176  *   - wipe after 10 unsuccessful unlocking attempts
       
   177  *
       
   178  */
       
   179 void CVpnDevLockPolicy::SetPolicyLevelL(const TInt aPolLevel) 
       
   180     {
       
   181     LOG_("-> CVpnDevLockPolicy::SetPolicyLevelL()");
       
   182 
       
   183     LOG_1(" Setting policy level: %d", aPolLevel);
       
   184 
       
   185     // Setting the policy level
       
   186     // See VPN device lock SUB for exact device lock policy level descriptions
       
   187     switch (aPolLevel) 
       
   188         {
       
   189         case 0:
       
   190             // No changes to existing devlock policy, 
       
   191             // when policy level is 0
       
   192             break;
       
   193         case 1:
       
   194             // Only enforce timeout and max number of passcode attempts
       
   195             SetPolicyAttributeL(RTerminalControl3rdPartySession::ETimeout, 30);
       
   196             SetPolicyAttributeL(RTerminalControl3rdPartySession::EPasscodeMaxAttempts, 20);
       
   197             SetPolicyAttributeL(RTerminalControl3rdPartySession::EMaxTimeout, 30);
       
   198             break;
       
   199         case 2:
       
   200             // Enforce stricter timeout as well, and a minimum length for passcode
       
   201             SetPolicyAttributeL(RTerminalControl3rdPartySession::ETimeout, 10);
       
   202             SetPolicyAttributeL(RTerminalControl3rdPartySession::EPasscodeMinLength, 5);
       
   203             SetPolicyAttributeL(RTerminalControl3rdPartySession::EPasscodeMaxAttempts, 10);
       
   204             SetPolicyAttributeL(RTerminalControl3rdPartySession::EMaxTimeout, 10);
       
   205             break;
       
   206         case 3:
       
   207             // Enforce even more password-related rules
       
   208             SetPolicyAttributeL(RTerminalControl3rdPartySession::ETimeout, 5);
       
   209             SetPolicyAttributeL(RTerminalControl3rdPartySession::EPasscodeMinLength, 5);
       
   210             SetPolicyAttributeL(RTerminalControl3rdPartySession::EPasscodeMaxAttempts, 10);
       
   211             SetPolicyAttributeL(RTerminalControl3rdPartySession::EPasscodeRequireCharsAndNumbers,
       
   212                                 1);
       
   213             SetPolicyAttributeL(RTerminalControl3rdPartySession::EPasscodeRequireUpperAndLower,
       
   214                                 1);
       
   215             SetPolicyAttributeL(RTerminalControl3rdPartySession::EPasscodeExpiration, 30);
       
   216             SetPolicyAttributeL(RTerminalControl3rdPartySession::EPasscodeHistoryBuffer, 5);
       
   217             SetPolicyAttributeL(RTerminalControl3rdPartySession::EMaxTimeout, 5);
       
   218             break;
       
   219         default:
       
   220             // Policy levels 4+ not supported, leave (tried to instantiate an illegal policy)
       
   221             LOG_("<- CVpnDevLockPolicy::SetPolicyLevelL() LEAVE: illegal policy level");
       
   222             User::Leave(KErrNotSupported);
       
   223             break;
       
   224         }
       
   225 
       
   226     LOG_("<- CVpnDevLockPolicy::SetPolicyLevelL()");
       
   227     }
       
   228 
       
   229 TInt CVpnDevLockPolicy::AttributeCount() 
       
   230     {
       
   231     LOG_("-> CVpnDevLockPolicy::AttributeCount()");
       
   232 
       
   233     TInt ret(0);
       
   234     if (iPolicyArray) 
       
   235         {
       
   236         ret = iPolicyArray->Count();
       
   237         }
       
   238 
       
   239     LOG_1("<- CVpnDevLockPolicy::AttributeCount() ret: %d", ret);
       
   240     return ret;
       
   241     }
       
   242 
       
   243 CVpnDevLockAttribute* CVpnDevLockPolicy::GetPolicyAttributeAt(const TInt aIdx) 
       
   244     {
       
   245     LOG_("-> CVpnDevLockPolicy::GetPolicyAttributeAt()");
       
   246     CVpnDevLockAttribute* ret(NULL);
       
   247 
       
   248     if (iPolicyArray && (aIdx < iPolicyArray->Count()))
       
   249         {
       
   250         LOG_1(" Found valid attribute at index %d", aIdx);
       
   251         ret = iPolicyArray->At(aIdx);
       
   252         }
       
   253 
       
   254     LOG_("<- CVpnDevLockPolicy::GetPolicyAttributeAt()");
       
   255     return ret;
       
   256     }
       
   257 
       
   258 
       
   259 //////////////
       
   260 // CVpnDevLockHandler implementation
       
   261 
       
   262 /**
       
   263  * Constructor, and
       
   264  *
       
   265  */
       
   266 CVpnDevLockHandler::CVpnDevLockHandler()
       
   267     {
       
   268     LOG_("-> CVpnDevLockHandler::CVpnDevLockHandler()");
       
   269     
       
   270     LOG_("<- CVpnDevLockHandler::CVpnDevLockHandler()");
       
   271     }
       
   272 
       
   273 void CVpnDevLockHandler::ConstructL() 
       
   274     {
       
   275     // Connect to terminal control (if available)
       
   276     LoadTCLibraryL();
       
   277     }
       
   278 
       
   279 void CVpnDevLockHandler::LoadTCLibraryL()
       
   280     {
       
   281     LOG_("-> CVpnDevLockHandler::LoadTCLibraryL()");
       
   282 
       
   283     TInt status = iTcLib.Load(KVpnDevLockWrapperDll, KNullUid);
       
   284 
       
   285     LOG_1(" DLL load status: %d", status);
       
   286 
       
   287     if (status == KErrNone)
       
   288         {
       
   289         LOG_(" Suitable library found, instantiating dev lock object");
       
   290 
       
   291         TLibraryFunction entry = iTcLib.Lookup(1);
       
   292         
       
   293         // Entry point function (NewTcStubL) might leave,
       
   294         // although it isn't readily obvious from the syntax
       
   295         iTcStub = (CVpnTcStub*)entry();
       
   296 
       
   297         LOG_(" Dev lock object instantiated");
       
   298         iDevLockAvailable = ETrue;
       
   299         }
       
   300     else 
       
   301         {
       
   302         LOG_(" No suitable library found!");
       
   303         iDevLockAvailable = EFalse;
       
   304         }
       
   305     
       
   306     LOG_("<- CVpnDevLockHandler::LoadTCLibraryL()");
       
   307     }
       
   308 
       
   309 CVpnDevLockHandler::~CVpnDevLockHandler() 
       
   310     {
       
   311     LOG_("-> CVpnDevLockHandler::CVpnDevLockHandler()");
       
   312 
       
   313     LOG_(" Deleting TC stub");
       
   314     delete iTcStub;
       
   315 
       
   316     LOG_(" Closing TC library");
       
   317     iTcLib.Close();
       
   318     
       
   319     LOG_("<- CVpnDevLockHandler::CVpnDevLockHandler()");
       
   320     }
       
   321 
       
   322 void CVpnDevLockHandler::TerminalControlSupportsVpnL() 
       
   323     {
       
   324     LOG_("-> CVpnDevLockHandler::TerminalControlSupportsVpnL()");
       
   325 
       
   326     HBufC8* attrib(NULL);
       
   327 
       
   328     // If the lib stub is available, try to read a device lock attribute
       
   329     // (read may fail))
       
   330     if (iTcStub) 
       
   331         {
       
   332         LOG_(" TC stub is valid");
       
   333         attrib = iTcStub->GetTCAttributeL(RTerminalControl3rdPartySession::ETimeout);
       
   334 
       
   335         if (attrib) 
       
   336             {
       
   337             LOG8_1(" Attribute: '%S'", attrib);
       
   338             delete attrib;
       
   339             }
       
   340         else 
       
   341             {
       
   342             LOG_(" Attribute couldn't be read");
       
   343             User::Leave(KErrAccessDenied);
       
   344             }
       
   345         }
       
   346     else 
       
   347         {
       
   348         LOG_(" No stub available, terminating");
       
   349         User::Leave(KErrAccessDenied);
       
   350         }
       
   351 
       
   352     LOG_("<- CVpnDevLockHandler::TerminalControlSupportsVpnL()");
       
   353     }
       
   354 
       
   355 void CVpnDevLockHandler::SetTerminalControlPolicyL(const TInt aPolLevel) 
       
   356     {
       
   357     LOG_("-> CVpnDevLockHandler::SetTerminalControlPolicyL()");
       
   358     LOG_1(" Setting policy level %d", aPolLevel);
       
   359 
       
   360     CVpnDevLockPolicy* devpolicy = CVpnDevLockPolicy::NewL(aPolLevel);
       
   361     CleanupStack::PushL(devpolicy);
       
   362 
       
   363     // Iterate through all the attributes that VPN policy requires.
       
   364     // For each one found, check if it's stricter than the old device lock setting,
       
   365     // and only if that is the case, update the actual value on device.
       
   366 
       
   367     TInt attribs = devpolicy->AttributeCount();
       
   368     LOG_1(" Iterating through %d attributes", attribs);
       
   369     
       
   370     TBool forceLock(EFalse);
       
   371 
       
   372     for (TInt i = 0; i < attribs; i++) 
       
   373         {
       
   374         CVpnDevLockAttribute* attrib = devpolicy->GetPolicyAttributeAt(i);
       
   375         if (!attrib) 
       
   376             {
       
   377             LOG_("<- CVpnDevLockHandler::SetTerminalControlPolicyL() LEAVE: Not found");
       
   378             User::Leave(KErrNotFound);
       
   379             }
       
   380 
       
   381         LOG_1(" Attribute    ID: %d", attrib->AttributeId());
       
   382 
       
   383         // Only set the attribute if the existing one was not as strict
       
   384         // (definition of "strict" depends on attribute's semantics)
       
   385         TBool override(EFalse);
       
   386         TRAPD(err, override = OverrideExistingL(*attrib));
       
   387 
       
   388         if ((err == KErrNone && override) || err == KErrNotFound)
       
   389             {
       
   390             SetDevAttributeL(*attrib);
       
   391             forceLock = ETrue;
       
   392             }
       
   393 
       
   394         }
       
   395 
       
   396     // If at least one lock parameter was (succesfully) changed, force device lock after
       
   397     // import
       
   398     if (forceLock) 
       
   399         {
       
   400         LOG_(" Forcing device lock activation");
       
   401 
       
   402         // Force lock
       
   403         CVpnDevLockAttribute* attrib = CVpnDevLockAttribute::NewL(RTerminalControl3rdPartySession::ELock,
       
   404                                                                   1);
       
   405         CleanupStack::PushL(attrib);
       
   406 
       
   407         // Expire password (force password change)
       
   408         CVpnDevLockAttribute* attrib2 = 
       
   409                                 CVpnDevLockAttribute::NewL(RTerminalControl3rdPartySession::EPasscodeExpiration, -1);
       
   410         CleanupStack::PushL(attrib2);
       
   411 
       
   412         LOG_(" Expiring old passcode");
       
   413         SetDevAttributeL(*attrib2);
       
   414         CleanupStack::PopAndDestroy(attrib2);
       
   415 
       
   416         LOG_(" Forcing device lock");
       
   417         SetDevAttributeL(*attrib);
       
   418         CleanupStack::PopAndDestroy(attrib);
       
   419         }
       
   420     
       
   421     
       
   422     CleanupStack::PopAndDestroy(devpolicy);
       
   423 
       
   424     LOG_("<- CVpnDevLockHandler::SetTerminalControlPolicyL()");
       
   425     }
       
   426 
       
   427 TBool CVpnDevLockHandler::OverrideExistingL(const CVpnDevLockAttribute& aNew) 
       
   428     {
       
   429     LOG_("-> CVpnDevLockHandler::OverrideExisting()");
       
   430     TBool ret(EFalse);
       
   431 
       
   432     HBufC8* existingAttrib = GetDevAttribValueL(aNew.AttributeId());
       
   433     CleanupStack::PushL(existingAttrib);
       
   434 
       
   435     // At the moment, we can rely on the fact that all relevant
       
   436     // attributes are numerical... This may change in future
       
   437     TInt newVal(-1);
       
   438     TInt oldVal(-1);
       
   439     TLex8 lexer(*existingAttrib);
       
   440     User::LeaveIfError(lexer.Val(oldVal));
       
   441     aNew.AttributeValueAsIntL(newVal);
       
   442 
       
   443     switch (aNew.AttributeId()) 
       
   444         {
       
   445         case RTerminalControl3rdPartySession::ETimeout:
       
   446             // If device lock timeout is set to lower value than the old one,
       
   447             // then we need to update the policy
       
   448             LOG_(" Case ETimeout");
       
   449             if (newVal < oldVal || oldVal == 0) 
       
   450                 {
       
   451                 ret = ETrue;
       
   452                 }
       
   453             break;
       
   454         case RTerminalControl3rdPartySession::EPasscodeMinLength:
       
   455             // If passcode minimum length requirement is longer than the
       
   456             // old one, then we need to update the policy
       
   457             LOG_(" Case EPasscodeMinLength");
       
   458             if (newVal > oldVal) 
       
   459                 {
       
   460                 ret = ETrue;
       
   461                 }
       
   462             break;
       
   463         case RTerminalControl3rdPartySession::EPasscodeMaxAttempts:
       
   464             // If max attempts lower, override
       
   465             LOG_(" Case EPasscodeMaxAttempts");
       
   466             if (newVal < oldVal || oldVal == 0) 
       
   467                 {
       
   468                 ret = ETrue;
       
   469                 }
       
   470             break;
       
   471         case RTerminalControl3rdPartySession::EPasscodeRequireCharsAndNumbers:
       
   472             // If alphanum requirement didn't exist before, override
       
   473             LOG_(" Case EPasscodeRequireCharsAndNumbers");
       
   474             if (newVal > oldVal)
       
   475                 {
       
   476                 ret = ETrue;
       
   477                 }
       
   478             break;
       
   479         case RTerminalControl3rdPartySession::EPasscodeRequireUpperAndLower:
       
   480             // If UC/LC requirement didn't exist before, override
       
   481             LOG_(" Case EPasscodeRequireUpperAndLower");
       
   482             if (newVal > oldVal) 
       
   483                 {
       
   484                 ret = ETrue;
       
   485                 }
       
   486             break;
       
   487         case RTerminalControl3rdPartySession::EPasscodeExpiration:
       
   488             // If less days before passcode expiration, override
       
   489             LOG_(" Case EPasscodeExpiration");
       
   490             if (newVal < oldVal || oldVal == 0) 
       
   491                 {
       
   492                 ret = ETrue;
       
   493                 }
       
   494             break;
       
   495         case RTerminalControl3rdPartySession::EPasscodeHistoryBuffer:
       
   496             // If the proposed passcode history is longer, override
       
   497             LOG_(" Case EPasscodeHistoryBuffer");
       
   498             if (newVal > oldVal) 
       
   499                 {
       
   500                 ret = ETrue;
       
   501                 }
       
   502             break;
       
   503         case RTerminalControl3rdPartySession::EMaxTimeout:
       
   504             // If the proposed max timeout is shorter, override
       
   505             LOG_(" Case EMaxTimeout");
       
   506             if ((oldVal == 0) || (newVal < oldVal)) 
       
   507                 {
       
   508                 ret = ETrue;
       
   509                 }
       
   510             break;
       
   511         default:
       
   512             LOG_(" ERROR: Case default, unknown attribute!");
       
   513             User::Leave(KErrNotFound);
       
   514             break;
       
   515         }
       
   516     CleanupStack::PopAndDestroy(existingAttrib);
       
   517 
       
   518     LOG_1("  Old value: %d", oldVal);
       
   519     LOG_1("  New value: %d", newVal);
       
   520     LOG( if (ret) 
       
   521         {
       
   522         LOG_("   => Old value needs to be updated");
       
   523         }
       
   524     );
       
   525 
       
   526     LOG_1("<- CVpnDevLockHandler::OverrideExisting() ret: %d", ret);
       
   527     return ret;
       
   528     }
       
   529 
       
   530 HBufC8* CVpnDevLockHandler::GetDevAttribValueL(const TInt aAttribId) 
       
   531     {
       
   532     LOG_("-> CVpnDevLockHandler::GetDevAttribValueL()");
       
   533 
       
   534     HBufC8* buffer(NULL);
       
   535 
       
   536     if (iTcStub) 
       
   537         {
       
   538         buffer = iTcStub->GetTCAttributeL(aAttribId);
       
   539         if (buffer) 
       
   540             {
       
   541             LOG8_1(" Buffer: '%S'", buffer);
       
   542             }
       
   543         }
       
   544 
       
   545     LOG_("<- CVpnDevLockHandler::GetDevAttribValueL()");
       
   546 
       
   547     return buffer;
       
   548     }
       
   549 
       
   550 void CVpnDevLockHandler::SetDevAttributeL(const CVpnDevLockAttribute& aNew) 
       
   551     {
       
   552     LOG_("-> CVpnDevLockHandler::SetDevAttribValueL()");
       
   553 
       
   554     if (iTcStub) 
       
   555         {
       
   556         iTcStub->SetTCAttributeL(aNew.AttributeId(), aNew.AttributeValue());
       
   557         }
       
   558 
       
   559     LOG_("<- CVpnDevLockHandler::SetDevAttribValueL()");
       
   560     }
       
   561 
       
   562 
       
   563 //////////////
       
   564 // CVpnDevLockAttribute implementation
       
   565 
       
   566 CVpnDevLockAttribute* CVpnDevLockAttribute::NewL(const TInt aId, const TDesC8& aVal) 
       
   567     {
       
   568     LOG_("-> CVpnDevLockAttribute::NewL()");
       
   569     
       
   570     CVpnDevLockAttribute* self = new (ELeave) CVpnDevLockAttribute();
       
   571     CleanupStack::PushL(self);
       
   572     self->ConstructL(aId, aVal);
       
   573     CleanupStack::Pop(self);
       
   574     
       
   575     LOG_("<- CVpnDevLockAttribute::NewL()");
       
   576     return self;
       
   577     }
       
   578 
       
   579 CVpnDevLockAttribute* CVpnDevLockAttribute::NewL(const TInt aId, const TInt aVal) 
       
   580     {
       
   581     LOG_("-> CVpnDevLockAttribute::NewL()");
       
   582     
       
   583     CVpnDevLockAttribute* self = new (ELeave) CVpnDevLockAttribute();
       
   584     CleanupStack::PushL(self);
       
   585     self->ConstructL(aId, aVal);
       
   586     CleanupStack::Pop(self);
       
   587     
       
   588     LOG_("<- CVpnDevLockAttribute::NewL()");
       
   589     return self;
       
   590     }
       
   591 
       
   592 CVpnDevLockAttribute* CVpnDevLockAttribute::NewLC(const TInt aId, const TDesC8& aVal) 
       
   593     {
       
   594     LOG_("-> CVpnDevLockAttribute::NewLC()");
       
   595     
       
   596     CVpnDevLockAttribute* self = new (ELeave) CVpnDevLockAttribute();
       
   597     CleanupStack::PushL(self);
       
   598     self->ConstructL(aId, aVal);
       
   599     
       
   600     LOG_("<- CVpnDevLockAttribute::NewLC()");
       
   601     
       
   602     return self;
       
   603     }
       
   604 
       
   605 CVpnDevLockAttribute::~CVpnDevLockAttribute() 
       
   606     {
       
   607     LOG_("-> CVpnDevLockAttribute::~CVpnDevLockAttribute()");
       
   608     delete iAttributeVal;
       
   609     LOG_("<- CVpnDevLockAttribute::~CVpnDevLockAttribute()");
       
   610     }
       
   611 
       
   612 CVpnDevLockAttribute::CVpnDevLockAttribute() 
       
   613     {
       
   614     LOG_("-> CVpnDevLockAttribute::CVpnDevLockAttribute()");
       
   615     LOG_("<- CVpnDevLockAttribute::CVpnDevLockAttribute()");
       
   616     }
       
   617 
       
   618 void CVpnDevLockAttribute::ConstructL(const TInt aId, const TDesC8& aVal) 
       
   619     {
       
   620     iAttributeId = aId;
       
   621     iAttributeVal = aVal.AllocL();
       
   622     }
       
   623 
       
   624 void CVpnDevLockAttribute::ConstructL(const TInt aId, const TInt aVal) 
       
   625     {
       
   626     // Convert int to a string
       
   627     iAttributeId = aId;
       
   628     TBuf8<MAX_INT_STR_LEN> buf;
       
   629     buf.Num(aVal);
       
   630     iAttributeVal = buf.AllocL();
       
   631     }
       
   632 
       
   633 TPtrC8 CVpnDevLockAttribute::AttributeValue() const
       
   634     {
       
   635     return *iAttributeVal;
       
   636     }
       
   637 
       
   638 void CVpnDevLockAttribute::AttributeValueAsIntL(TInt& aVal) const
       
   639     {
       
   640     if (iAttributeVal)
       
   641         {
       
   642         TLex8 lexer(*iAttributeVal);
       
   643         User::LeaveIfError(lexer.Val(aVal));
       
   644         }
       
   645     }
       
   646 
       
   647 TInt CVpnDevLockAttribute::AttributeId() const
       
   648     {
       
   649     return iAttributeId;
       
   650     }
       
   651 
       
   652 
       
   653 
       
   654 CVpnDevLockHandler* CVpnDevLockHandler::NewL() 
       
   655     {
       
   656     LOG_("-> CVpnDevLockHandler::NewL()");
       
   657     
       
   658     CVpnDevLockHandler* self = new (ELeave) CVpnDevLockHandler();
       
   659     CleanupStack::PushL(self);
       
   660     self->ConstructL();
       
   661     CleanupStack::Pop(self);
       
   662     
       
   663     LOG_("<- CVpnDevLockAttribute::NewL()");
       
   664     return self;
       
   665     }
       
   666 
       
   667 CVpnDevLockHandler* CVpnDevLockHandler::NewLC() 
       
   668     {
       
   669     LOG_("-> CVpnDevLockAttribute::NewLC()");
       
   670     
       
   671     CVpnDevLockHandler* self = new (ELeave) CVpnDevLockHandler();
       
   672     CleanupStack::PushL(self);
       
   673     self->ConstructL();
       
   674     
       
   675     LOG_("<- CVpnDevLockAttribute::NewLC()");
       
   676     
       
   677     return self;
       
   678     }
       
   679