PKG_CHECK_MODULES(TZPLATFORM_CONFIG_DEPS REQUIRED libtzplatform-config)
PKG_CHECK_MODULES(LIBXML_DEPS REQUIRED libxml-2.0)
PKG_CHECK_MODULES(XMLSEC1_DEPS REQUIRED xmlsec1)
+PKG_CHECK_MODULES(WIDGET_MANIFEST_PARSER_DEPS REQUIRED widget-manifest-parser)
FIND_PACKAGE(Boost REQUIRED COMPONENTS system filesystem)
BuildRequires: pkgconfig(libzip)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(xmlsec1)
+BuildRequires: pkgconfig(widget-manifest-parser)
Requires: ca-certificates-tizen
Requires: libtzplatform-config
ctx_->set_file_path(file);
}
-AppInstaller::~AppInstaller() { delete ctx_; }
+AppInstaller::~AppInstaller() { delete ctx_; }
int AppInstaller::AddStep(Step *step) {
}
}
if (it != itEnd) {
- std::cout << "Faillure occurs" << std::endl;
+ std::cout << "Failure occurs" << std::endl;
do {
if ((*it)->undo(ctx_) != APPINST_R_OK) {
std::cout << "Error during undo operation" << std::endl;
#include "common/context_installer.h"
+#include <pkgmgr_installer.h>
#include <tzplatform_config.h>
#include <unistd.h>
namespace common_installer {
-ContextInstaller::ContextInstaller() : uid_(getuid()) {}
+ContextInstaller::ContextInstaller() : req_(PKGMGR_REQ_INVALID),
+ uid_(getuid()),
+ manifest_(new manifest_x()),
+ config_data_(new ConfigData()) {
+}
+
+ContextInstaller::~ContextInstaller() {
+ if (manifest_)
+ pkgmgr_parser_free_manifest_xml(manifest_);
+}
const char* ContextInstaller::GetApplicationPath() {
return uid_ != tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
#include <unistd.h>
#include <sys/types.h>
+#include <memory>
#include <string>
namespace common_installer {
APPINST_R_OK = 0 /**< General success */
};
-class ContextInstaller {
- private :
- // request type: Install, Reinstall, Uninstall, Update.
- int req_;
-
- // manifest information used to generate xml file
- manifest_x* manifest_;
-
- // pkgid used for update or uninstallation processing
- std::string pkgid_;
-
- // uid of the user that request the operation
- uid_t uid_;
+class ConfigData;
+using ConfigDataPtr = std::unique_ptr<ConfigData>;
- // package directory path containing app data
- std::string pkg_path_;
+class ConfigData {
+ public:
+ ConfigData() {}
- // file path used for installation or reinstallation process
- std::string file_path_;
+ std::string application_name() const { return application_name_; }
+ void set_application_name(const std::string& app_name) {
+ application_name_ = app_name;
+ }
+ std::string required_version() const { return required_version_; }
+ void set_required_version(const std::string& required_version) {
+ required_version_ = required_version;
+ }
- // directory path where app data are temporarily extracted
- std::string unpack_directory_;
+ private:
+ std::string application_name_;
+ std::string required_version_;
+};
+class ContextInstaller {
public:
ContextInstaller();
+ ~ContextInstaller();
int request_type() const { return req_; }
void set_request_type(int req) {
- req_ = req;
+ req_ = req;
}
manifest_x* manifest_data() const { return manifest_; }
std::string pkgid() const { return pkgid_; }
void set_pkgid(const std::string& pkgid) {
- pkgid_ = pkgid;
+ pkgid_ = pkgid;
}
std::string pkg_path() const { return pkg_path_; }
void set_pkg_path(const std::string& package_path) {
- pkg_path_ = package_path;
+ pkg_path_ = package_path;
}
std::string file_path() const { return file_path_; }
void set_file_path(const std::string& file_path) {
- file_path_ = file_path;
+ file_path_ = file_path;
}
uid_t uid() const { return uid_; }
std::string unpack_directory() const { return unpack_directory_; }
void set_unpack_directory(const std::string& unpack_dir) {
- unpack_directory_ = unpack_dir;
+ unpack_directory_ = unpack_dir;
}
+ ConfigData* config_data() { return config_data_.get(); }
+
const char* GetApplicationPath();
+
+ private :
+ // request type: Install, Reinstall, Uninstall, Update.
+ int req_;
+
+ // manifest information used to generate xml file
+ manifest_x* manifest_;
+
+ // pkgid used for update or uninstallation processing
+ std::string pkgid_;
+
+ // uid of the user that request the operation
+ uid_t uid_;
+
+ // package directory path containing app data
+ std::string pkg_path_;
+
+ // file path used for installation or reinstallation process
+ std::string file_path_;
+
+ // directory path where app data are temporarily extracted
+ std::string unpack_directory_;
+
+ // data from config.xml
+ ConfigDataPtr config_data_;
};
} // namespace common_installer
# Target - sources
SET(SRCS
wgt_backend.cc
+ step/step_parse.cc
)
# Target - definition
ADD_EXECUTABLE(${TARGET_WGT_BACKEND} ${SRCS})
# Target - deps
APPLY_PKG_CONFIG(${TARGET_WGT_BACKEND} PUBLIC
PKGMGR_INSTALLER_DEPS
+ WIDGET_MANIFEST_PARSER_DEPS
)
+
# Target - in-package deps
TARGET_LINK_LIBRARIES(${TARGET_WGT_BACKEND} ${TARGET_LIBNAME_COMMON})
--- /dev/null
+/* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
+
+#include "wgt/step/step_parse.h"
+
+#include <string.h>
+
+#include <pkgmgr/pkgmgr_parser.h>
+#include <widget-manifest-parser/widget-manifest-parser.h>
+
+#include <cstdio>
+#include <cstdlib>
+#include <iostream>
+
+#include "common/app_installer.h"
+#include "common/context_installer.h"
+#include "common/step/step.h"
+
+namespace wgt {
+namespace parse {
+
+//TODO MAYBE fill later
+//ConfigFileParser::ConfigFileParser(char * file) {
+//}
+
+int StepParse::process(common_installer::ContextInstaller* context) {
+ if (!StepParse::Check(context->unpack_directory())) {
+ std::cout << "[Parse] No config.xml" << std::endl;
+ return common_installer::APPINST_R_ERROR;
+ }
+
+ const ManifestData* data = nullptr;
+ const char* error = nullptr;
+ if (!ParseManifest(config_.c_str(), &data, &error)) {
+ std::cout << "[Parse] Parse failed. " << error << std::endl;
+ if (!ReleaseData(data, error))
+ std::cout << "[Parse] Release data failed." << std::endl;
+ return common_installer::APPINST_R_ERROR;
+ }
+
+ // Copy data from ManifestData to ContextInstaller
+ context->config_data()->set_application_name(
+ std::string(data->name));
+ context->config_data()->set_required_version(
+ std::string(data->api_version));
+ unsigned int privilege_len;
+ privileges_x *ctx_privileges = context->manifest_data()->privileges;
+
+ if(!ctx_privileges) {
+ privileges_x *privileges = reinterpret_cast<privileges_x*>(
+ malloc(sizeof(privileges_x)));
+ if(!privileges)
+ return common_installer::APPINST_R_ERROR;
+
+ memset(privileges, '\0', sizeof(privileges_x));
+ LISTADD(ctx_privileges, privileges);
+ context->manifest_data()->privileges = ctx_privileges;
+ }
+ for (unsigned int i = 0; i < data->privilege_count; ++i) {
+ privilege_x *privilege = reinterpret_cast<privilege_x*>(
+ malloc(sizeof(privilege_x)));
+ if(!privilege)
+ return common_installer::APPINST_R_ERROR;
+
+ privilege_len = strlen(data->privilege_list[i]);
+ char* tmp = reinterpret_cast<char*>(malloc(privilege_len + 1));
+ if(!tmp)
+ return common_installer::APPINST_R_ERROR;
+
+ strcpy(tmp, data->privilege_list[i]);
+ memset(privilege, '\0', sizeof(privilege_x));
+ privilege->text = const_cast<const char*>(tmp);
+ LISTADD(ctx_privileges->privilege, privilege);
+ }
+
+ //--- Test ---
+ std::cout << "[Parse] Read data -[ " << std::endl;
+ std::cout << " package = " << data->package << std::endl;
+ std::cout << " id = " << data->id << std::endl;
+ std::cout << " name = " << data->name << std::endl;
+ std::cout << " short_name = " << data->short_name << std::endl;
+ std::cout << " version = " << data->version << std::endl;
+ std::cout << " icon = " << data->icon << std::endl;
+ std::cout << " api_version = " << data->api_version << std::endl;
+ std::cout << " privileges -[" << std::endl;
+ for (unsigned int i = 0; i < data->privilege_count; ++i)
+ std::cout << " " << data->privilege_list[i] << std::endl;
+ std::cout << " ]-" << std::endl;
+ std::cout << "]-" << std::endl;
+ //--- End Test ---
+
+ if (!ReleaseData(data, error)) {
+ std::cout << "[Parse] Release data failed." << std::endl;
+ return common_installer::APPINST_R_ERROR;
+ }
+
+ return common_installer::APPINST_R_OK;
+}
+
+bool StepParse::Check(const boost::filesystem::path& widget_path) {
+ boost::filesystem::path config = widget_path;
+ config /= "config.xml";
+
+ std::cout << "[Parse] config.xml path: " << config << std::endl;
+
+ if(!boost::filesystem::exists(config))
+ return false;
+
+ config_ = config;
+ return true;
+}
+
+} // namespace parse
+} // namespace wgt
--- /dev/null
+/* 2014, Copyright © Samsung, license APACHE-2.0, see LICENSE file */
+
+#ifndef WGT_STEP_STEP_PARSE_H_
+#define WGT_STEP_STEP_PARSE_H_
+
+#include <boost/filesystem.hpp>
+
+#include "common/app_installer.h"
+#include "common/context_installer.h"
+#include "common/step/step.h"
+
+namespace wgt {
+namespace parse {
+
+//TODO MAYBE fill later
+//class ConfigFileParser {
+// public:
+// ConfigFileParser(char * file);
+//};
+
+class StepParse: public common_installer::Step {
+ public:
+ StepParse() {}
+
+ int process(common_installer::ContextInstaller* context) override;
+ int clean(common_installer::ContextInstaller*) override { return 0; }
+ int undo(common_installer::ContextInstaller*) override { return 0; }
+
+ private:
+ boost::filesystem::path config_;
+ bool Check(const boost::filesystem::path& widget_path);
+};
+
+} // namespace parse
+} // namespace wgt
+
+#endif // WGT_STEP_STEP_PARSE_H_
+++ /dev/null
-/* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
-
-#include <iostream>
-#include <cstdio>
-#include <cstdlib>
-
-#include "common/app_installer.h"
-#include "common/step.h"
-
-namespace {
-
-API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest) {
- _LOGD("parsing start pkgmgr_parser_process_manifest_xml\n");
- xmlTextReaderPtr reader;
- manifest_x *mfx = NULL;
-
- reader = xmlReaderForFile(manifest, NULL, 0);
- if (reader) {
- mfx = malloc(sizeof(manifest_x));
- if (mfx) {
- memset(mfx, '\0', sizeof(manifest_x));
- if (__process_manifest(reader, mfx, GLOBAL_USER) < 0) {
- _LOGD("Parsing Failed\n");
- pkgmgr_parser_free_manifest_xml(mfx);
- mfx = NULL;
- } else {
- _LOGD("Parsing Success\n");
- }
- } else {
- _LOGD("Memory allocation error\n");
- }
- xmlFreeTextReader(reader);
- } else {
- _LOGD("Unable to create xml reader\n");
- }
- return mfx;
-}
-
-} // namespace
-
-namespace wgt {
-namespace parse {
-
-Class ConfigFileParser {
-ConfigFileParser(char * file) {
-}
-}
-
-class Step {
-// process
-
-// clean
-
-// undo
-};
-
-} // namespace parse
-} // namespace wgt
#include "common/step/step_unzip.h"
#include "common/step/step_signature.h"
#include "common/step/step_copy.h"
+#include "wgt/step/step_parse.h"
int main(int argc, char **argv) {
/* get request data */
new common_installer::signature::StepSignature);
installer->AddStep(step_signature.get());
+ wgt::parse::StepParse* step_parse = new
+ wgt::parse::StepParse();
+ installer->AddStep(step_parse);
+
common_installer::copy::StepCopy* step_copy =
new common_installer::copy::StepCopy();
installer->AddStep(step_copy);
installer->Run();
delete step_unpack;
+ delete step_parse;
delete step_copy;
+ delete installer;
break;
}
case PKGMGR_REQ_UNINSTALL: {