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 "plugin/dmtPlugin.hpp" 18 #include "DmtJavaPluginTree.h" 19 #include "DmtJavaPluginManager.h" 20 #include "DmtJavaPluginCommon.h" 21 22 // Support exec plugin 23 extern "C" 24 SYNCML_DM_RET_STATUS_T DMT_PluginLib_Execute2( 25 const char* pPath, 26 DMMap<DMString, DMString>& mapParameters, 27 const char* pArgs, 28 const char* pCorrelator, 29 PDmtTree pTree, 30 DMString& results 31 ) 32 { 33 DmtJavaPlugin_Debug("Enter DMT_PluginLib_Execute2...\n"); 34 DmtJavaPlugin_Debug("Plugin path = %s\n", pPath); 35 36 results = ""; 37 38 PDmtJavaPluginManager pJavaPluginManager(new DmtJavaPluginManager(pPath, mapParameters)); 39 if (pJavaPluginManager == NULL) 40 { 41 DmtJavaPlugin_Debug("Fail to create DmtJavaPluginManager\n"); 42 return SYNCML_DM_FAIL; 43 } 44 45 DmtJavaPlugin_Debug("Calling DmtJavaPluginManager::ExecuteNode...\n"); 46 SYNCML_DM_RET_STATUS_T retcode = pJavaPluginManager->ExecuteNode(pArgs, pCorrelator, pTree, results); 47 DmtJavaPlugin_Debug("DmtJavaPluginManager::ExecuteNode -> retcode = %d\n", retcode); 48 49 return retcode; 50 } 51 52 //Support read write data plugin 53 extern "C" 54 SYNCML_DM_RET_STATUS_T DMT_PluginLib_Data_GetPluginTree( 55 const char* pPath, 56 DMMap<DMString, DMString>& mapParameters, 57 PDmtAPIPluginTree& pPluginTree 58 ) 59 { 60 DmtJavaPlugin_Debug("Enter DMT_PluginLib_Data_GetPluginTree...\n"); 61 DmtJavaPlugin_Debug("Plugin path = %s\n", pPath); 62 63 PDmtJavaPluginTree pJavaPluginTree = new DmtJavaPluginTree(pPath, mapParameters); 64 if (pJavaPluginTree == NULL) 65 { 66 DmtJavaPlugin_Debug("Fail to create DmtJavaPluginTree\n"); 67 return SYNCML_DM_FAIL; 68 } 69 70 DmtJavaPlugin_Debug("Calling DmtJavaPluginTree::BuildPluginTree...\n"); 71 SYNCML_DM_RET_STATUS_T retcode = pJavaPluginTree->BuildPluginTree(); 72 DmtJavaPlugin_Debug("DmtJavaPluginManager::BuildPluginTree -> retcode = %d\n", retcode); 73 74 pPluginTree = (retcode != SYNCML_DM_SUCCESS ? NULL : pJavaPluginTree); 75 76 return retcode; 77 } 78 79 extern "C" 80 int DMT_PluginLib_GetAPIVersion(void) 81 { 82 return DMT_PLUGIN_VERSION_1_1; 83 } 84