vpnengine/dmadengine/src/dmadrtnode.cpp
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2002 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 CDmAdRtNode.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "DmAdRtNode.h"
       
    20 #include "dmadcallback.h"
       
    21 #include "dmadcommand.h"
       
    22 #include "dmadutil.h"
       
    23 #include "vpnlogger.h"
       
    24 
       
    25 DMAD_EXPORT_C CDmAdRtNode* CDmAdRtNode::NewL(const TDesC8& aUri, const TDesC8& aLuid, MDmAdCallBack* aCallBack, MDmAdRtNodeDataApi* aRtNodeDataApi)
       
    26     {
       
    27     TRACE("CDmAdRtNode::NewL");
       
    28     
       
    29     CDmAdRtNode *self = new (ELeave) CDmAdRtNode(aRtNodeDataApi);
       
    30     CleanupStack::PushL(self);
       
    31     self->ConstructL(aUri, aLuid, aCallBack);
       
    32     CleanupStack::Pop();        // self
       
    33     return self;
       
    34     }
       
    35 
       
    36 void CDmAdRtNode::ConstructL(const TDesC8& aUri, const TDesC8& aLuid, MDmAdCallBack* aCallBack)
       
    37     {
       
    38     TRACE("CDmAdRtNode::ConstructL");
       
    39     
       
    40     DEBUG_LOG1(_L8("aUri: %S"), &aUri);
       
    41     DEBUG_LOG(_L("aLuid:"));
       
    42     DEBUG_LOG_HEX(aLuid);
       
    43     
       
    44     iCommands = new (ELeave) CArrayPtrFlat<CDmAdCommand>(4);
       
    45     iUri = aUri.AllocL();
       
    46     iLuid = aLuid.AllocL();
       
    47     iData = iRtNodeDataApi->CreateDmAdRtNodeDataL(aUri, aCallBack);
       
    48     }
       
    49     
       
    50 CDmAdRtNode::CDmAdRtNode(MDmAdRtNodeDataApi* aRtNodeDataApi)
       
    51     : iRtNodeDataApi(aRtNodeDataApi), iSomeLeafAddedToRtNode(EFalse), iJustFetched(ETrue)
       
    52     {
       
    53     TRACE("CDmAdRtNode::CDmAdRtNode");
       
    54     }
       
    55 
       
    56 DMAD_EXPORT_C CDmAdRtNode::~CDmAdRtNode()
       
    57     {
       
    58     TRACE("CDmAdRtNode::~CDmAdRtNode");
       
    59     
       
    60     CDmAdCommand::CleanupOperationDeleteCArrayPtr(iCommands);
       
    61     delete iUri;
       
    62     delete iLuid;
       
    63     iRtNodeDataApi->DeleteDmAdRtNodeData(iData);
       
    64     }
       
    65     
       
    66 DMAD_EXPORT_C TPtrC8 CDmAdRtNode::Uri(void) const
       
    67     {
       
    68     TRACE("CDmAdRtNode::Uri");
       
    69     
       
    70     __ASSERT_ALWAYS(iUri != NULL, User::Invariant());
       
    71     
       
    72     TPtrC8 ret(*iUri);
       
    73     return ret;
       
    74     }
       
    75 
       
    76 DMAD_EXPORT_C TPtrC8 CDmAdRtNode::Luid(void) const
       
    77     {
       
    78     TRACE("CDmAdRtNode::Luid");
       
    79     
       
    80     __ASSERT_ALWAYS(iLuid != NULL, User::Invariant());
       
    81     
       
    82     TPtrC8 ret(*iLuid);
       
    83     return ret;
       
    84     }
       
    85 
       
    86 DMAD_EXPORT_C void CDmAdRtNode::SetLuidL(const TDesC8& aLuid)
       
    87     {
       
    88     TRACE("CDmAdRtNode::SetLuidL");
       
    89     
       
    90     DEBUG_LOG1(_L8("Node uri: %S"), iUri);
       
    91     DEBUG_LOG(_L("aLuid:"));
       
    92     DEBUG_LOG_HEX(aLuid);    
       
    93     
       
    94     __ASSERT_ALWAYS(aLuid.Length() > 0, User::Invariant());
       
    95     
       
    96         
       
    97     delete iLuid;
       
    98     iLuid = NULL;
       
    99     
       
   100     iLuid = aLuid.AllocL();
       
   101     }
       
   102     
       
   103     
       
   104 void CDmAdRtNode::CleanupOperationDeleteCArrayPtr(TAny* aPtr)
       
   105     {    
       
   106     __ASSERT_ALWAYS(aPtr != NULL, User::Invariant());
       
   107     
       
   108     CArrayPtr<CDmAdRtNode>* array = REINTERPRET_CAST(CArrayPtr<CDmAdRtNode>*,aPtr);
       
   109     array->ResetAndDestroy();
       
   110     delete array;
       
   111     }
       
   112 
       
   113 
       
   114 void CDmAdRtNode::AppendCommandL(CDmAdCommand* aCommand)
       
   115     {
       
   116     TRACE("CDmAdRtNode::AppendCommandL");
       
   117     
       
   118     iCommands->AppendL(aCommand);
       
   119     iJustFetched = EFalse;
       
   120     }
       
   121 
       
   122 void CDmAdRtNode::AddLeafObjectL(const TDesC8& aUri, const TDesC8& aObject, TInt aStatusRef)
       
   123     {
       
   124     TRACE("CDmAdRtNode::AddLeafObjectL");
       
   125     
       
   126     CDmAdCommand* command = CDmAdCommand::NewLC(aUri, aStatusRef, ETrue);
       
   127 
       
   128     iRtNodeDataApi->UpdateLeafDataL(iData, aUri, aObject);
       
   129     iSomeLeafAddedToRtNode = ETrue;
       
   130     
       
   131     AppendCommandL(command);
       
   132     CleanupStack::Pop(); //command
       
   133     }
       
   134 
       
   135 void CDmAdRtNode::UpdateLeafObjectL(const TDesC8& aUri, const TDesC8& aObject, TInt aStatusRef)
       
   136     {
       
   137     TRACE("CDmAdRtNode::UpdateLeafObjectL");
       
   138     
       
   139     CDmAdCommand* command = CDmAdCommand::NewLC(aUri, aStatusRef, ETrue);
       
   140     
       
   141     iRtNodeDataApi->UpdateLeafDataL(iData, aUri, aObject);
       
   142     
       
   143     AppendCommandL(command);
       
   144     CleanupStack::Pop(); //command
       
   145     }
       
   146     
       
   147 TBool CDmAdRtNode::IsSomeChild(const TDesC8& aSomeParentUri) const
       
   148     {
       
   149     TRACE("CDmAdRtNode::IsSomeChild");
       
   150     
       
   151     TPtrC8 someParentUri(TDmAdUtil::RemoveDotSlash(aSomeParentUri));
       
   152     TPtrC8 uri(TDmAdUtil::RemoveDotSlash(*iUri));
       
   153     if (uri.Find(someParentUri) == 0)
       
   154         {
       
   155         return ETrue;
       
   156         }
       
   157     else
       
   158         {
       
   159         return EFalse;
       
   160         }
       
   161     }
       
   162     
       
   163 TBool CDmAdRtNode::AreUriTypesSame(const TDesC8& aUri)
       
   164     {
       
   165     TRACE("CDmAdRtNode::AreUriTypesSameL");
       
   166     
       
   167     return iRtNodeDataApi->AreUriTypesSame(iData, aUri);
       
   168     }
       
   169