Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #include "dmt.hpp"
     18 #include "plugin/dmtPlugin.hpp"
     19 #include "DmtJavaPluginNode.h"
     20 #include "DmtJavaPluginTree.h"
     21 #include "DmtJavaPluginCommon.h"
     22 
     23 DmtJavaPluginNode::DmtJavaPluginNode(PDmtJavaPluginTree ptrTree, const char* path,
     24              const DmtData& data):DmtRWPluginNode()
     25 {
     26     Init(static_cast<PDmtPluginTree>(ptrTree), path, data);
     27     m_javaPluginTree = ptrTree;
     28 }
     29 
     30 DmtJavaPluginNode::~DmtJavaPluginNode()
     31 {
     32     m_javaPluginTree = NULL;
     33 }
     34 
     35 DmtJavaPluginNode::DmtJavaPluginNode(PDmtJavaPluginTree ptrTree, const char* path,
     36              const DMStringVector& childNodeNames):DmtRWPluginNode()
     37 {
     38     Init(static_cast<PDmtPluginTree>(ptrTree), path, childNodeNames);
     39     m_javaPluginTree = ptrTree;
     40 }
     41 
     42 SYNCML_DM_RET_STATUS_T DmtJavaPluginNode::GetValue(DmtData& oData) const
     43 {
     44     DmtJavaPlugin_Debug("Inside DmtJavaPluginNode::GetValue: oData-->\n");
     45     DmtJavaPlugin_Debug("m_strPath.c_str() is %s\n", m_strPath.c_str());
     46     if(!IsLeaf())
     47     {
     48         DmtJavaPlugin_Debug("This is a interior node!\n");
     49         return DmtPluginNode::GetValue(oData);
     50     }
     51     return m_javaPluginTree->GetNodeValueInternal(m_strPath.c_str(), oData);
     52 }
     53 
     54 SYNCML_DM_RET_STATUS_T DmtJavaPluginNode::SetValue(const DmtData& oData)
     55 {
     56      DmtJavaPlugin_Debug("Inside DmtJavaPluginNode::SetValue:\n");
     57      if(!IsLeaf())
     58      {
     59         DmtJavaPlugin_Debug("This is a interior node!\n");
     60         return DmtRWPluginNode::SetValue(oData);
     61      }
     62      SYNCML_DM_RET_STATUS_T res = DmtRWPluginNode::SetValue(oData);
     63      if(res != SYNCML_DM_SUCCESS)
     64      {
     65         DmtJavaPlugin_Debug("update memory tree failed...\n");
     66         return res;
     67      }
     68      DmtJavaPlugin_Debug("m_strPath.c_str() is %s\n", m_strPath.c_str());
     69      return m_javaPluginTree->SetNodeValueInternal(m_strPath.c_str(), oData);
     70 }
     71