SET(TARGET_PKG_CLEARDATA "pkg_cleardata")
SET(TARGET_INSTALL_PRELOAD_PKG "install_preload_pkg")
SET(TARGET_PKG_UPGRADE "pkg_upgrade")
+SET(TARGET_RSC_COPY "rsc-copy")
SET(TARGET_RSC_SLICE "rsc-slice")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
%{_bindir}/pkg_cleardata
%{_bindir}/pkginfo
%{_bindir}/rsc-slice
+%{_bindir}/rsc-copy
%{_bindir}/pkg_upgrade
%attr(0755,root,root) %{_bindir}/install_preload_pkg
%{_datadir}/mime/packages/mime.wac.xml
ADD_SUBDIRECTORY(pkg_upgrade)
ADD_SUBDIRECTORY(pkgcmd)
ADD_SUBDIRECTORY(pkginfo)
+ADD_SUBDIRECTORY(rsc-copy)
ADD_SUBDIRECTORY(rsc-slice)
--- /dev/null
+# Target - sources
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SRCS)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+# Target - definition
+ADD_EXECUTABLE(${TARGET_RSC_COPY} ${SRCS})
+
+# Dependency
+APPLY_PKG_CONFIG(${TARGET_RSC_COPY} PUBLIC
+ AUL_DEPS
+ GLIB_DEPS
+ BUNDLE_DEPS
+)
+
+# Install
+INSTALL(TARGETS ${TARGET_RSC_COPY} DESTINATION bin)
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ABSTRACT_REQUEST_HANDLER_HH_
+#define ABSTRACT_REQUEST_HANDLER_HH_
+
+#include <list>
+#include <string>
+
+#include "include/error_type.hh"
+#include "include/rsc_path_info.hh"
+
+namespace rsc_handler {
+
+class AbstractRequestHandler {
+ public:
+ AbstractRequestHandler(std::string pkgid, std::list<RscPathInfo> path_list) :
+ pkgid_(pkgid), path_list_(path_list) {};
+
+ virtual ErrorType Execute() = 0;
+
+ protected:
+ std::string GetRootPath();
+
+ private:
+ std::string pkgid_;
+ std::list<RscPathInfo> path_list_;
+};
+
+} // rsc_handler
+
+#endif // ABSTRACT_REQUEST_HANDLER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CONDITION_VALIDATOR_HH_
+#define CONDITION_VALIDATOR_HH_
+
+#include <list>
+#include <string>
+
+#include "include/rsc_path_info.hh"
+
+namespace rsc_handler {
+
+class ConditionValidator {
+ public:
+ ConditionValidator(std::list<RscPathInfo> list);
+ bool ValidateCondition();
+
+ private:
+ std::list<RscPathInfo> path_info_list_;
+};
+
+} // rsc_handler
+
+#endif // CONDITION_VALIDATOR_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COPY_REQUEST_HANDLER_HH_
+#define COPY_REQUEST_HANDLER_HH_
+
+#include <list>
+#include <string>
+
+#include "include/abstract_request_handler.hh"
+#include "include/error_type.hh"
+#include "include/rsc_path_info.hh"
+
+namespace rsc_handler {
+
+class CopyRequestHandler : public AbstractRequestHandler {
+ public:
+ ErrorType Execute() override;
+};
+
+} // rsc_handler
+
+#endif // COPY_REQUEST_HANDLER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ERROR_TYPE_HH_
+#define ERROR_TYPE_HH_
+
+namespace rsc_handler {
+
+enum ErrorType {
+ ERROR_NONE = 0,
+ ERROR_INVALID_PARAMETER,
+ ERROR_PKG_NOT_FOUND,
+ ERROR_PERMISSION_DENIED,
+ ERROR_SYSTEM_ERROR,
+ ERROR_OUT_OF_SPACE,
+ ERROR_OUT_OF_MEMORY
+};
+
+} // namespace rsc_handler
+
+#endif // ERROR_TYPE_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EVENT_SIGNAL_SENDER_HH_
+#define EVENT_SIGNAL_SENDER_HH_
+
+#include <string>
+
+#include "include/request_type.hh"
+
+namespace rsc_handler {
+
+class EventSignalSender {
+ public:
+ EventSignalSender(std::string pkgid, ReqType req_type);
+ bool SendStart();
+ bool SendOK();
+ bool SendFail();
+
+ private:
+ std::string pkgid_;
+ ReqType req_type_;
+};
+
+} // rsc_handler
+
+#endif // PARAM_CHECKER_HH_
--- /dev/null
+// Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef LOGGING_HH_
+#define LOGGING_HH_
+
+#include <dlog.h>
+
+#ifndef PROJECT_TAG
+#define PROJECT_TAG "PKGMGR_TOOL"
+#endif
+
+#ifdef LOG
+#undef LOG
+#endif
+
+#include <cassert>
+#include <climits>
+#include <cstdio>
+#include <cstring>
+#include <iomanip>
+#include <iostream>
+#include <memory>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#ifndef __FILENAME__
+#define __FILENAME__ \
+ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
+#endif
+
+namespace utils {
+
+enum class LogLevel {
+ LOG_ERROR,
+ LOG_WARNING,
+ LOG_INFO,
+ LOG_DEBUG,
+};
+
+log_priority LogLevelToPriority(LogLevel level);
+
+template<LogLevel> struct LogTag;
+template<> struct LogTag<LogLevel::LOG_ERROR> {
+ static constexpr const char* value = "\033[1;31m| ERROR |\033[0m";
+};
+template<> struct LogTag<LogLevel::LOG_WARNING> {
+ static constexpr const char* value = "\033[1;33m| WARNING |\033[0m";
+};
+template<> struct LogTag<LogLevel::LOG_INFO> {
+ static constexpr const char* value = "\033[1;32m| INFO |\033[0m";
+};
+template<> struct LogTag<LogLevel::LOG_DEBUG> {
+ static constexpr const char* value = "\033[0m| DEBUG |\033[0m";
+};
+
+template <class charT, class traits = std::char_traits<charT>>
+class StringStream : private std::basic_ostringstream<charT, traits> {
+ public:
+ using std::basic_ostringstream<charT, traits>::str;
+
+ template <class T>
+ StringStream& operator<<(const T& value) {
+ static_cast<std::basic_ostringstream<charT, traits> &>(*this) << value;
+ return *this;
+ }
+};
+
+// Interface class for logging backends. The custom LogBackend which wants
+// log using LOG() macro should be implement following interface.
+class ILogBackend {
+ public:
+ virtual void WriteLog(LogLevel level, const std::string& tag,
+ const std::string& logstr) = 0;
+};
+
+class DLogBackend : public ILogBackend {
+ public:
+ void WriteLog(LogLevel level, const std::string& tag,
+ const std::string& logstr) override {
+ dlog_print(LogLevelToPriority(level), tag.c_str(), "%s",
+ Escape(logstr).c_str());
+ }
+
+ private:
+ // Since LogCatcher passes input to dlog_print(), the input which contains
+ // format string(such as %d, %n) can cause unexpected result.
+ // This is simple function to escape '%'.
+ // NOTE: Is there any gorgeous way instead of this?
+ std::string Escape(const std::string& str) const {
+ std::string escaped = std::string(str);
+ size_t start_pos = 0;
+ std::string from = "%";
+ std::string to = "%%";
+ while ((start_pos = escaped.find(from, start_pos)) != std::string::npos) {
+ escaped.replace(start_pos, from.length(), to);
+ start_pos += to.length();
+ }
+ return escaped;
+ }
+};
+
+class LogCore {
+ public:
+ // Do not call this function at destructor of global object
+ static LogCore& GetCore() {
+ static LogCore core;
+ return core;
+ }
+
+ void AddLogBackend(std::shared_ptr<ILogBackend> backend) {
+ backend_list_.emplace_back(backend);
+ }
+
+ void Log(LogLevel level, const std::string& tag, const std::string& log) {
+ for (auto& backend : backend_list_)
+ backend->WriteLog(level, tag, log);
+ }
+
+ private:
+ LogCore() {
+ // add default dlog backend
+ AddLogBackend(std::shared_ptr<ILogBackend>(new DLogBackend()));
+ }
+ ~LogCore() = default;
+ LogCore(const LogCore&) = delete;
+ LogCore& operator=(const LogCore&) = delete;
+
+ std::vector<std::shared_ptr<ILogBackend>> backend_list_;
+};
+
+class LogCatcher {
+ public:
+ LogCatcher(LogLevel level, const char* tag)
+ : level_(level), tag_(tag) { }
+
+ void operator&(const StringStream<char>& str) const {
+ LogCore::GetCore().Log(level_, tag_, str.str());
+ }
+
+ private:
+ LogLevel level_;
+ std::string tag_;
+};
+
+} // namespace utils
+
+
+inline static const constexpr char* __tag_for_logging() {
+ return "";
+}
+
+inline static const constexpr char* __tag_for_project() {
+ return PROJECT_TAG;
+}
+
+// To be defined in class namespace if user want different log tag for given
+// scope
+#define SCOPE_LOG_TAG(TAG) \
+ inline static const constexpr char* __tag_for_logging() { \
+ return #TAG; \
+ } \
+
+// Simple logging macro of following usage:
+// LOG(LEVEL) << object_1 << object_2 << object_n;
+// where:
+// LEVEL = ERROR | WARNING | INFO | DEBUG
+#define LOG(LEVEL) \
+ ::utils::LogCatcher( \
+ ::utils::LogLevel::LOG_ ## LEVEL, __tag_for_project()) \
+ & ::utils::StringStream<char>() \
+ << std::string(::utils::LogTag<::utils::LogLevel::LOG_ ## LEVEL>::value) \
+ << " " << std::setw(25) << std::left << __tag_for_logging() \
+ << " : " << std::setw(36) \
+ << (std::string(__FILENAME__) + ":" + std::to_string(__LINE__)).c_str() \
+ << std::setw(0) << " : " \
+
+#endif // LOGGING_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PARAM_CHECKER_HH_
+#define PARAM_CHECKER_HH_
+
+#include <list>
+#include <string>
+
+#include "include/request_type.hh"
+#include "include/rsc_path_info.hh"
+
+namespace rsc_handler {
+
+class ParamChecker {
+ public:
+ ParamChecker(int argc, char* argv[]);
+ ReqType GetRequestType();
+ std::string GetPkgID() const;
+ const std::list<RscPathInfo>& GetPathList() const;
+ bool Validate();
+
+ private:
+ std::list<RscPathInfo> path_info_list_;
+};
+
+} // rsc_handler
+
+#endif // PARAM_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef REMOVE_REQUEST_HANDLER_HH_
+#define REMOVE_REQUEST_HANDLER_HH_
+
+#include <list>
+#include <string>
+
+#include "include/abstract_request_handler.hh"
+#include "include/error_type.hh"
+#include "include/rsc_path_info.hh"
+
+namespace rsc_handler {
+
+class RemoveRequestHandler : public AbstractRequestHandler {
+ public:
+ ErrorType Execute() override;
+};
+
+} // rsc_handler
+
+#endif // REMOVE_REQUEST_HANDLER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef REQUEST_HANDLER_INVOKER_HH_
+#define REQUEST_HANDLER_INVOKER_HH_
+
+#include "include/param_checker.hh"
+#include "include/event_signal_sender.hh"
+
+namespace rsc_handler {
+
+class RequestHandlerInvoker {
+ public:
+
+ RequestHandlerInvoker(ParamChecker option, EventSignalSender signal);
+
+ bool Validate();
+ bool Execute();
+
+ private:
+ ParamChecker option_;
+ EventSignalSender signal_;
+};
+
+} // rsc_handler
+
+#endif // REQUEST_HANDLER_INVOKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef REQUEST_TYPE_HH_
+#define REQUEST_TYPE_HH_
+
+namespace rsc_handler {
+
+enum ReqType {
+ REQ_TYPE_NEW = 0,
+ REQ_TYPE_REMOVE = 1,
+ REQ_TYPE_UNINSTALL,
+ REQ_TYPE_UNKNOWN
+};
+
+} // namespace rsc_handler
+
+#endif // REQUEST_TYPE_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RSC_HANDLER_HH_
+#define RSC_HANDLER_HH_
+
+#include <memory>
+
+#include "include/request_handler_invoker.hh"
+
+namespace rsc_handler {
+
+class RscHandler {
+ public:
+ RscHandler() {};
+ //~RscHandler();
+ bool Init(int argc, char* argv[]);
+ bool Run();
+
+ private:
+ std::unique_ptr<rsc_handler::RequestHandlerInvoker> handler_;
+};
+
+} // rsc_handler
+
+#endif // RSC_HANDLER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RSC_PATH_INFO_HH_
+#define RSC_PATH_INFO_HH_
+
+#include <string>
+
+namespace rsc_handler {
+
+class RscPathInfo {
+ public:
+ RscPathInfo(std::string src, std::string dst);
+
+ const std::string& GetSrcPath() const;
+ const std::string& GetDstPath() const;
+
+ private:
+ std::string src_;
+ std::string dst_;
+};
+
+} // rsc_handler
+
+#endif // RSC_PATH_INFO_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNINSTALL_REQUEST_HANDLER_HH_
+#define UNINSTALL_REQUEST_HANDLER_HH_
+
+#include <list>
+#include <string>
+
+#include "include/abstract_request_handler.hh"
+#include "include/error_type.hh"
+#include "include/rsc_path_info.hh"
+
+namespace rsc_handler {
+
+class UninstallRequestHandler : public AbstractRequestHandler {
+ public:
+ ErrorType Execute() override;
+};
+
+} // rsc_handler
+
+#endif // UNINSTALL_REQUEST_HANDLER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "include/abstract_request_handler.hh"
+
+#include <iostream>
+
+#include "include/request_type.hh"
+#include "include/rsc_path_info.hh"
+
+namespace rsc_handler {
+
+std::string AbstractRequestHandler::GetRootPath() {
+ std::cout << "AbstractRequestHandler::GetRootPath" << std::endl;
+
+ std::string root_path("to_be_added_with_tzplatform/");
+ root_path += pkgid_;
+
+ return root_path;
+}
+
+
+} // namesapce rsc_handler
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "include/condition_validator.hh"
+
+#include <iostream>
+
+#include "include/request_type.hh"
+#include "include/rsc_path_info.hh"
+
+namespace rsc_handler {
+
+ConditionValidator::ConditionValidator(std::list<RscPathInfo> list) :
+ path_info_list_(list) {}
+
+bool ConditionValidator::ValidateCondition() {
+ std::cout << "ConditionValidator::ValidateCondition" << std::endl;
+
+ return true;
+}
+
+} // namespace rsc_handler
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "include/copy_request_handler.hh"
+
+#include <iostream>
+
+#include "include/error_type.hh"
+#include "include/rsc_path_info.hh"
+
+namespace rsc_handler {
+
+ErrorType CopyRequestHandler::Execute() {
+ std::cout << "CopyRequestHandler::Execute" << std::endl;
+
+ return ErrorType::ERROR_NONE;
+}
+
+} // namespace rsc_handler
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "include/event_signal_sender.hh"
+
+#include <iostream>
+#include <string>
+
+#include "include/request_type.hh"
+
+namespace rsc_handler {
+
+EventSignalSender::EventSignalSender(std::string pkgid, ReqType req_type) :
+ pkgid_(pkgid), req_type_(req_type) {}
+
+bool EventSignalSender::SendStart() {
+ std::cout << "EventSignalSender::SendStart" << std::endl;
+
+ return true;
+}
+
+bool SendOK() {
+ std::cout << "EventSignalSender::SendOK" << std::endl;
+
+ return true;
+}
+
+bool SendFail() {
+ std::cout << "EventSignalSender::SendFail" << std::endl;
+
+ return true;
+}
+
+} // namespace rsc_handler
--- /dev/null
+// Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "logging.hh"
+
+namespace utils {
+
+log_priority LogLevelToPriority(LogLevel level) {
+ switch (level) {
+ case LogLevel::LOG_ERROR:
+ return log_priority::DLOG_ERROR;
+ case LogLevel::LOG_WARNING:
+ return log_priority::DLOG_WARN;
+ case LogLevel::LOG_INFO:
+ return log_priority::DLOG_INFO;
+ case LogLevel::LOG_DEBUG:
+ return log_priority::DLOG_DEBUG;
+ default:
+ return log_priority::DLOG_UNKNOWN;
+ }
+}
+
+} // namespace utils
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "include/param_checker.hh"
+
+#include <iostream>
+
+#include "include/request_type.hh"
+#include "include/rsc_path_info.hh"
+
+namespace rsc_handler {
+
+ParamChecker::ParamChecker(int argc, char* argv[]) {
+ std::cout << "ParamChecker::ParamChecker" << std::endl;
+}
+
+std::string ParamChecker::GetPkgID() const {
+ std::cout << "ParamChecker::GetPkgID" << std::endl;
+
+ return "test_text";
+}
+
+ReqType ParamChecker::GetRequestType() {
+ std::cout << "ParamChecker::GetRequestType" << std::endl;
+
+ return ReqType::REQ_TYPE_UNKNOWN;
+}
+
+const std::list<RscPathInfo>& ParamChecker::GetPathList() const {
+ std::cout << "ParamChecker::GetPathList()" << std::endl;
+
+ return path_info_list_;
+}
+
+bool ParamChecker::Validate() {
+ std::cout << "ParamChecker::Validate" << std::endl;
+
+ return true;
+}
+
+} // namespace rsc_handler
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "include/remove_request_handler.hh"
+
+#include <iostream>
+
+#include "include/error_type.hh"
+#include "include/rsc_path_info.hh"
+
+namespace rsc_handler {
+
+ErrorType RemoveRequestHandler::Execute() {
+ std::cout << "RemoveRequestHandler::Execute" << std::endl;
+
+ return ErrorType::ERROR_NONE;
+}
+
+} // namespace rsc_handler
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "include/request_handler_invoker.hh"
+
+#include <iostream>
+
+#include "include/event_signal_sender.hh"
+#include "include/param_checker.hh"
+#include "include/request_type.hh"
+
+namespace rsc_handler {
+
+RequestHandlerInvoker::RequestHandlerInvoker(
+ ParamChecker option, EventSignalSender signal) :
+ option_(option), signal_(signal) {}
+
+bool RequestHandlerInvoker::Validate() {
+ std::cout << "RequestHandlerInvoker::Validate" << std::endl;
+
+ return true;
+}
+
+bool RequestHandlerInvoker::Execute() {
+ std::cout << "RequestHandlerInvoker::Execute" << std::endl;
+
+ return true;
+}
+
+} // namespace rsc_handler
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+
+#include "include/rsc_handler.hh"
+#include "include/logging.hh"
+
+int main(int argc, char *argv[]) {
+ try {
+ rsc_handler::RscHandler handler;
+ if (!handler.Init(argc, argv)) {
+ LOG(ERROR) << "Failed to initliaze handler";
+ return -1;
+ }
+
+ if (!handler.Run()) {
+ LOG(ERROR) << "Failed to handle request";
+ return -1;
+ }
+ } catch (...) {
+ LOG(ERROR) << "Exception occured";
+ return -1;
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "include/rsc_handler.hh"
+
+#include <iostream>
+
+#include "include/event_signal_sender.hh"
+#include "include/param_checker.hh"
+#include "include/request_handler_invoker.hh"
+
+namespace rsc_handler {
+
+bool RscHandler::Init(int argc, char* argv[]) {
+ std::cout << "RscHandler::Init" << std::endl;
+
+ rsc_handler::ParamChecker option(argc, argv);
+ if (!option.Validate()) {
+ // TODO(jungh.yeon) : error logs
+ return false;
+ }
+
+ rsc_handler::EventSignalSender signal(
+ option.GetPkgID(), option.GetRequestType());
+
+ rsc_handler::RequestHandlerInvoker handler(option, signal);
+ if (!handler.Validate()) {
+ // TODO(jungh.yeon) : error logs
+ return false;
+ }
+
+ return true;
+}
+
+bool RscHandler::Run() {
+ std::cout << "RscHandler::Run" << std::endl;
+
+ return true;
+}
+
+} // namespace rsc_handler
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "include/rsc_path_info.hh"
+
+#include <iostream>
+#include <string>
+
+namespace rsc_handler {
+
+RscPathInfo::RscPathInfo(std::string src, std::string dst) :
+ src_(src), dst_(dst) {}
+
+const std::string& RscPathInfo::GetSrcPath() const {
+ return src_;
+}
+
+const std::string& RscPathInfo::GetDstPath() const {
+ return dst_;
+}
+
+} // namespace rsc_handler
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "include/uninstall_request_handler.hh"
+
+#include <iostream>
+
+#include "include/error_type.hh"
+#include "include/rsc_path_info.hh"
+
+namespace rsc_handler {
+
+ErrorType UninstallRequestHandler::Execute() {
+ std::cout << "UninstallRequestHandler::Execute" << std::endl;
+
+ return ErrorType::ERROR_NONE;
+}
+
+
+} // namespace rsc_handler