Add ReqTypeToString() 53/255853/3
authorChanggyu Choi <changyu.choi@samsung.com>
Wed, 24 Mar 2021 08:16:39 +0000 (17:16 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Wed, 24 Mar 2021 08:39:08 +0000 (17:39 +0900)
Change-Id: I7751f887dc23be2aaec57c590ad763dae345be0a
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
src/common/request_type.cc [new file with mode: 0644]
src/common/request_type.hh
src/server/worker_thread.cc

diff --git a/src/common/request_type.cc b/src/common/request_type.cc
new file mode 100644 (file)
index 0000000..e84c154
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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 "request_type.hh"
+
+namespace pkgmgr_common {
+
+const std::string& ReqTypeToString(ReqType type) {
+  static std::string convertArray[] = {
+      "GET_PKG_INFO"
+      "GET_APP_INFO",
+      "SET_PKG_INFO",
+      "SET_CERT_INFO",
+      "GET_CERT_INFO",
+      "GET_PKG_DEP_INFO",
+      "QUERY",
+      "COMMAND",
+      "ERROR_REQ_TYPE"
+  };
+  if (type <= ReqType::REQ_TYPE_NONE
+     || type >= ReqType::MAX)
+    return convertArray[ReqType::MAX];
+
+  return convertArray[type];
+}
+
+}  // namespace pkgmgr_common
\ No newline at end of file
index 8ef9811..2d6a4e7 100644 (file)
 #ifndef COMMON_REQUEST_TYPE_HH_
 #define COMMON_REQUEST_TYPE_HH_
 
+#include <string>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
 namespace pkgmgr_common {
 
 enum ReqType {
@@ -32,6 +38,8 @@ enum ReqType {
   MAX
 };
 
+EXPORT_API const std::string& ReqTypeToString(ReqType type);
+
 }  // namespace pkgmgr_common
 
 #endif  // COMMON_REQUEST_TYPE_HH_
index 24cb4a6..5cb648f 100644 (file)
@@ -103,8 +103,8 @@ void WorkerThread::Run() {
       continue;
     }
     pkgmgr_common::ReqType type = req->GetRequestType();
-    LOGD("Request type(%d), pid(%d)",
-        static_cast<int>(type), req->GetSenderPID());
+    LOGD("Request type(%s), pid(%d)",
+        pkgmgr_common::ReqTypeToString(type).c_str(), req->GetSenderPID());
     if (type <= pkgmgr_common::ReqType::REQ_TYPE_NONE
             || type >= pkgmgr_common::ReqType::MAX) {
       LOGE("Request type is invalid (%d)", static_cast<int>(type));