Rename some files
authorSangyoon Jang <jeremy.jang@samsung.com>
Tue, 21 Jan 2025 00:41:50 +0000 (09:41 +0900)
committer장상윤/Tizen Platform Lab(SR)/삼성전자 <jeremy.jang@samsung.com>
Tue, 21 Jan 2025 02:09:14 +0000 (11:09 +0900)
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/common/utils/glist_range.h [new file with mode: 0644]
src/pkgmgr_plugin_parser/CMakeLists.txt
src/pkgmgr_plugin_parser/action_registry.hh [new file with mode: 0644]
src/pkgmgr_plugin_parser/action_schema_parser.hh [new file with mode: 0644]
src/pkgmgr_plugin_parser/glist_range.h [deleted file]
src/pkgmgr_plugin_parser/iaction_parser.h [deleted file]
src/pkgmgr_plugin_parser/json_action_parser.cc [deleted file]
src/pkgmgr_plugin_parser/json_action_parser.h [deleted file]
src/pkgmgr_plugin_parser/json_action_schema_parser.cc [new file with mode: 0644]
src/pkgmgr_plugin_parser/json_action_schema_parser.hh [new file with mode: 0644]
src/pkgmgr_plugin_parser/tizen_action_metadata_plugin.cc

diff --git a/src/common/utils/glist_range.h b/src/common/utils/glist_range.h
new file mode 100644 (file)
index 0000000..2de6a2c
--- /dev/null
@@ -0,0 +1,84 @@
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef GLIST_RANGE_H_
+#define GLIST_RANGE_H_
+
+#include <glib.h>
+
+#include <cstddef>
+#include <iterator>
+
+// Range with mutable forward iterator based on GList
+// supporting language foreach construct
+template<typename T>
+class GListRange {
+ public:
+  class Iterator {
+   public:
+    typedef T value_type;
+    typedef T& reference;
+    typedef T* pointer;
+    typedef const T* const_pointer;
+    typedef std::size_t difference_type;
+    typedef std::forward_iterator_tag iterator_category;
+
+    explicit Iterator(std::nullptr_t ptr = nullptr) : ptr_(ptr) { }
+    explicit Iterator(GList* ptr) : ptr_(ptr) { }
+    explicit operator bool() const {
+      return ptr_;
+    }
+    const reference& operator*() const {
+      return reinterpret_cast<const T&>(ptr_->data);
+    }
+    reference& operator*() {
+      return reinterpret_cast<T&>(ptr_->data);
+    }
+    const_pointer operator->() const {
+      return reinterpret_cast<pointer>(&ptr_->data);
+    }
+    pointer operator->() {
+      return reinterpret_cast<pointer>(&ptr_->data);
+    }
+    Iterator& operator++() {
+      ptr_ = g_list_next(ptr_);
+      return *this;
+    }
+    Iterator operator++(int) {
+      Iterator iter(ptr_);
+      ptr_ = g_list_next(ptr_);
+      return iter;
+    }
+    bool operator==(const Iterator& other) const {
+      return ptr_ == other.ptr_;
+    }
+    bool operator!=(const Iterator& other) const {
+      return !this->operator==(other);
+    }
+
+   private:
+    GList* ptr_;
+  };
+
+  explicit GListRange(GList* list) : list_(list) {  }
+  Iterator begin() {
+    return Iterator(list_);
+  }
+  Iterator end() {
+    return Iterator();
+  }
+
+  bool Empty() const noexcept {
+    return !list_;
+  }
+
+  guint Size() const {
+    return g_list_length(list_);
+  }
+
+ private:
+  GList* list_;
+};
+
+#endif  // GLIST_RANGE_H_
index 79244b9d3238ecc53367af1fcef0bfb82177ebb9..4dccfb6273d2348ee8ab2cef60ef2f723232b497 100644 (file)
@@ -2,7 +2,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} ACTION_PLUGIN_SRCS)
 
 ADD_LIBRARY(${TARGET_TIZEN_ACTION_PLUGIN} SHARED ${ACTION_PLUGIN_SRCS})
 TARGET_LINK_LIBRARIES(${TARGET_TIZEN_ACTION_PLUGIN} PRIVATE ${TARGET_TIZEN_THEME} ${TARGET_TIZEN_ACTION_PROVIDER})
-TARGET_INCLUDE_DIRECTORIES(${TARGET_TIZEN_ACTION_PLUGIN} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}../)
+TARGET_INCLUDE_DIRECTORIES(${TARGET_TIZEN_ACTION_PLUGIN} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
 
 APPLY_PKG_CONFIG(${TARGET_TIZEN_ACTION_PLUGIN} PUBLIC
   DLOG_DEPS
diff --git a/src/pkgmgr_plugin_parser/action_registry.hh b/src/pkgmgr_plugin_parser/action_registry.hh
new file mode 100644 (file)
index 0000000..d8367e2
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2025 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 PKGMGR_PLUGIN_PARSER_ACTION_REGISTRY_HH_
+#define PKGMGR_PLUGIN_PARSER_ACTION_REGISTRY_HH_
+
+namespace parser {
+
+class IActionRegistry {
+ public:
+  virtual ~IActionRegistry() = default;
+  virtual bool Install() = 0;
+  virtual bool Uninstall() = 0;
+  virtual bool Update() = 0;
+};
+
+}  // namespace parser
+
+#endif  // PKGMGR_PLUGIN_PARSER_ACTION_REGISTRY_HH_
\ No newline at end of file
diff --git a/src/pkgmgr_plugin_parser/action_schema_parser.hh b/src/pkgmgr_plugin_parser/action_schema_parser.hh
new file mode 100644 (file)
index 0000000..cf3146d
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2024 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 PLGMGR_PLUGIN_PARSER_ACTION_SCHEMA_PARSER_HH_
+#define PLGMGR_PLUGIN_PARSER_ACTION_SCHEMA_PARSER_HH_
+
+#include <string>
+
+namespace parser {
+
+class IActionSchemaParser {
+ public:
+  virtual ~IActionSchemaParser() = default;
+  virtual bool Parse(const std::string& path) = 0;
+};
+
+}  // namespace parser
+
+#endif  // PLGMGR_PLUGIN_PARSER_ACTION_SCHEMA_PARSER_HH_
diff --git a/src/pkgmgr_plugin_parser/glist_range.h b/src/pkgmgr_plugin_parser/glist_range.h
deleted file mode 100644 (file)
index 2de6a2c..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef GLIST_RANGE_H_
-#define GLIST_RANGE_H_
-
-#include <glib.h>
-
-#include <cstddef>
-#include <iterator>
-
-// Range with mutable forward iterator based on GList
-// supporting language foreach construct
-template<typename T>
-class GListRange {
- public:
-  class Iterator {
-   public:
-    typedef T value_type;
-    typedef T& reference;
-    typedef T* pointer;
-    typedef const T* const_pointer;
-    typedef std::size_t difference_type;
-    typedef std::forward_iterator_tag iterator_category;
-
-    explicit Iterator(std::nullptr_t ptr = nullptr) : ptr_(ptr) { }
-    explicit Iterator(GList* ptr) : ptr_(ptr) { }
-    explicit operator bool() const {
-      return ptr_;
-    }
-    const reference& operator*() const {
-      return reinterpret_cast<const T&>(ptr_->data);
-    }
-    reference& operator*() {
-      return reinterpret_cast<T&>(ptr_->data);
-    }
-    const_pointer operator->() const {
-      return reinterpret_cast<pointer>(&ptr_->data);
-    }
-    pointer operator->() {
-      return reinterpret_cast<pointer>(&ptr_->data);
-    }
-    Iterator& operator++() {
-      ptr_ = g_list_next(ptr_);
-      return *this;
-    }
-    Iterator operator++(int) {
-      Iterator iter(ptr_);
-      ptr_ = g_list_next(ptr_);
-      return iter;
-    }
-    bool operator==(const Iterator& other) const {
-      return ptr_ == other.ptr_;
-    }
-    bool operator!=(const Iterator& other) const {
-      return !this->operator==(other);
-    }
-
-   private:
-    GList* ptr_;
-  };
-
-  explicit GListRange(GList* list) : list_(list) {  }
-  Iterator begin() {
-    return Iterator(list_);
-  }
-  Iterator end() {
-    return Iterator();
-  }
-
-  bool Empty() const noexcept {
-    return !list_;
-  }
-
-  guint Size() const {
-    return g_list_length(list_);
-  }
-
- private:
-  GList* list_;
-};
-
-#endif  // GLIST_RANGE_H_
diff --git a/src/pkgmgr_plugin_parser/iaction_parser.h b/src/pkgmgr_plugin_parser/iaction_parser.h
deleted file mode 100644 (file)
index cb3d702..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2024 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 <string>
-
-namespace tas {
-
-class IActionParser {
- public:
-  virtual ~IActionParser() = default;
-  virtual bool Parse(const std::string& json_string) = 0;
-};
-
-}  // namespace tas
diff --git a/src/pkgmgr_plugin_parser/json_action_parser.cc b/src/pkgmgr_plugin_parser/json_action_parser.cc
deleted file mode 100644 (file)
index fcc4daf..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2024 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 <string>
-
-#include "json_action_parser.h"
-
-namespace tas {
-
-JsonActionParser::JsonActionParser() {
-}
-
-JsonActionParser::~JsonActionParser() {
-}
-
-bool JsonActionParser::Parse(const std::string& json_str) {
-  return true;
-}
-
-}  // namespace tas
diff --git a/src/pkgmgr_plugin_parser/json_action_parser.h b/src/pkgmgr_plugin_parser/json_action_parser.h
deleted file mode 100644 (file)
index 3a1a50a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2024 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 <string>
-
-#include "iaction_parser.h"
-
-namespace tas {
-
-class JsonActionParser : public IActionParser {
-  public:
-  JsonActionParser();
-  ~JsonActionParser();
-  bool Parse(const std::string& json_string) override;
-};
-
-}  // namespace tas
\ No newline at end of file
diff --git a/src/pkgmgr_plugin_parser/json_action_schema_parser.cc b/src/pkgmgr_plugin_parser/json_action_schema_parser.cc
new file mode 100644 (file)
index 0000000..a47586e
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2024 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 "pkgmgr_plugin_parser/json_action_schema_parser.hh"
+
+#include <json/json.h>
+
+#include <fstream>
+#include <string>
+
+namespace parser {
+
+bool JsonActionSchemaParser::Parse(const std::string& path) {
+  Json::CharReaderBuilder rbuilder;
+  rbuilder["collectComments"] = false;
+
+  std::ifstream ifs(path);
+  Json::Value root;
+  std::string error;
+  if (!Json::parseFromStream(rbuilder, ifs, &root, &error)) {
+    // LOG(ERROR) << "Failed to read json file: " << error;
+    return false;
+  }
+
+  return true;
+}
+
+}  // namespace parser
diff --git a/src/pkgmgr_plugin_parser/json_action_schema_parser.hh b/src/pkgmgr_plugin_parser/json_action_schema_parser.hh
new file mode 100644 (file)
index 0000000..2fd5a8e
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2024 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 PKGMGR_PLUGIN_PARSER_JSON_ACTION_SCHEMA_PARSER_HH_
+#define PKGMGR_PLUGIN_PARSER_JSON_ACTION_SCHEMA_PARSER_HH_
+
+#include <string>
+
+#include "pkgmgr_plugin_parser/action_schema_parser.hh"
+
+namespace parser {
+
+class JsonActionSchemaParser : public IActionSchemaParser {
+ public:
+  JsonActionSchemaParser() = default;
+  ~JsonActionSchemaParser() = default;
+  bool Parse(const std::string& path) override;
+};
+
+}  // namespace parser
+
+#endif  // PKGMGR_PLUGIN_PARSER_JSON_ACTION_SCHEMA_PARSER_HH_
\ No newline at end of file
index 61311a9f7fcdb89231d17401f2a4a139d72b8b1a..f7c94844fc832afde19174e3a8007f667127b641 100644 (file)
@@ -13,7 +13,7 @@
 #include <cstring>
 #include <string>
 
-#include "glist_range.h"
+#include "common/utils/glist_range.h"
 
 namespace {