#include "Config.h"
+#ifdef __TIZEN__
+#include <appfw/app_common.h>
+#endif
using namespace OIC;
using namespace rapidxml;
Config::Config(void *args)
{
std::string path = ".";
-/**
- * For Tizen Platform, specifiy the absolute location of config file. It is required for
- * Tizen 2.3 EFL App to work.
- */
-#ifdef __TIZEN__
- if (loadConfigFile("/opt/usr/apps/org.iotivity.service.ppm.ppmsampleapp/lib/pluginmanager.xml")
- != PM_S_OK)
-#else
#ifdef ANDROID
JavaVM *jvm = (JavaVM *)args;
JNIEnv *env;
jmethodID mid = env->GetStaticMethodID(cls, "getPackageName", "()Ljava/lang/String;");
jstring jpath = (jstring)env->CallStaticObjectMethod(cls, mid);
path = env->GetStringUTFChars(jpath, 0);
-
- if(path != ".")
+ if (path != ".")
path = "/data/data/" + path + "/files";
+#elif __TIZEN__
+ char *app_id = NULL;
+ int res = app_get_id(&app_id);
+ if (APP_ERROR_NONE == res)
+ {
+ path = "/opt/usr/apps/";
+ path += app_id;
+ path += "/lib";
+ }
+ free(app_id);
#endif
if (loadConfigFile(path + "/pluginmanager.xml") != PM_S_OK)
-#endif //#ifdef __TIZEN__
{
fprintf(stderr, "PM Configuration file is not exist current Folder.\n" );
exit(EXIT_FAILURE);
Config::~Config(void)
{
- if (s_configinstance)
+ if (s_configinstance)
{
s_configinstance->deleteinstance();
s_configinstance = NULL;
PMRESULT Config::loadConfigFile(const std::string configfilepath)
{
// Read the xml file
- xml_document< char > doc;
+ xml_document< char > doc;
std::basic_ifstream< char > xmlFile(configfilepath.c_str());
if (!xmlFile.good())
{
// Find our root node
xml_node< char > *root_node = doc.first_node("pluginManager");
- if(!root_node)
+ if (!root_node)
{
throw parse_error("No Root Element", 0);
}
PMRESULT Config::getXmlData(xml_node<> *pluginInfo, std::string key)
{
- xml_attribute<> *iAttr = NULL;
+ if (pluginInfo == NULL)
+ {
+ return PM_S_FALSE;
+ }
+
std::string value = "";
- if (iAttr = pluginInfo->first_attribute(key.c_str()))
+ xml_attribute<> *iAttr = pluginInfo->first_attribute(key.c_str());
+ if (iAttr)
{
value = iAttr->value();
setValue(key, value);
{
return "";
}
-}
\ No newline at end of file
+}