Add Missing implement in PkgInfoParcel
authorIlho Kim <ilho159.kim@samsung.com>
Mon, 8 Mar 2021 06:57:31 +0000 (15:57 +0900)
committer김일호/Tizen Platform Lab(SR)/Engineer/삼성전자 <ilho159.kim@samsung.com>
Mon, 8 Mar 2021 07:39:45 +0000 (16:39 +0900)
 - Read,Write application is missed

Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/common/parcel/pkginfo_parcelable.cc
test/unit_tests/parcel_utils.cc

index 68cad86e5fb97ebe02833c752a63d04dd4f74783..9e7b7513825a331360d154bd1aade4ae8eefc617 100644 (file)
@@ -120,16 +120,16 @@ void PkgInfoParcelable::WriteProvidesAppdefinedPrivileges(tizen_base::Parcel* pa
 }
 
 void PkgInfoParcelable::WriteApplication(tizen_base::Parcel* parcel, GList* application) const {
-//  std::vector<application_x *> app_vt;
-//
-//  for (GList* tmp = application; tmp; tmp = tmp->next) {
-//    application_x* ptr = reinterpret_cast<application_x*>(tmp->data);
-//    app_vt.push_back(ptr);
-//  }
-//
-//  auto app_list = std::make_unique<AppInfoParcelable>(std::move(app_vt));
-//
-//  WriteParcel(std::move(app_list));
+  std::vector<application_x *> app_vt;
+
+  for (GList* tmp = application; tmp; tmp = tmp->next) {
+    application_x* ptr = reinterpret_cast<application_x*>(tmp->data);
+    app_vt.push_back(ptr);
+  }
+
+  AppInfoParcelable apps(0, std::move(app_vt));
+
+  parcel->WriteParcelable(apps);
 }
 
 void PkgInfoParcelable::WriteCompatibility(tizen_base::Parcel* parcel,
@@ -330,14 +330,11 @@ void PkgInfoParcelable::ReadProvidesAppdefinedPrivileges(tizen_base::Parcel* par
 }
 
 void PkgInfoParcelable::ReadApplication(tizen_base::Parcel* parcel, GList** list) {
-//  const unsigned char *buf = nullptr;
-//  unsigned int size = 0;
-//  ReadParcelRaw(&buf, &size);
-//  auto appinfo_parcel = AppInfoParcelable::Create(buf, size);
-//  auto appinfo_list = appinfo_parcel->GetAppInfo();
-//
-//  for (const auto& application : appinfo_list)
-//    *list = g_list_append(*list, application);
+  AppInfoParcelable apps;
+  parcel->ReadParcelable(&apps);
+
+  for (const auto& application : apps.GetAppInfo())
+    *list = g_list_append(*list, application);
 }
 
 void PkgInfoParcelable::ReadCompatibility(tizen_base::Parcel* parcel, GList** list) {
index 8401e3dcdcd6a9b3b96a5a2db1ae9437bacb6e60..ad05a96fe8b0071f630222057fa987d25259d2fe 100644 (file)
@@ -34,7 +34,6 @@ bool IS_STR_EQ(const char *a, const char *b) {
           << #str_b << "(" << str_b << ")" <<  std::endl;                      \
       return false;                                                            \
     }                                                                          \
-    return true;                                                               \
 } while (0);
 
 #define INT_EQ(a, b) do {                                                      \
@@ -43,7 +42,6 @@ bool IS_STR_EQ(const char *a, const char *b) {
           << #b << "(" << b << ")" <<  std::endl;                              \
       return false;                                                            \
     }                                                                          \
-    return true;                                                               \
 } while (0);
 
 application_x *GetTestApplication(std::string appid) {
@@ -604,7 +602,8 @@ bool IsEqualPackage(package_x *packageA, package_x *packageB) {
 
 bool IsEqualPackages(const std::vector<package_x *>&packagesA,
     const std::vector<package_x *>&packagesB) {
-  if (packagesA.size() != packagesB.size());
+  if (packagesA.size() != packagesB.size())
+    return false;
 
   for (unsigned int i = 0; i < packagesA.size(); ++i) {
     if (!IsEqualPackage(packagesA[i], packagesB[i]))
@@ -668,6 +667,8 @@ bool IsEqualFilter(const pkgmgrinfo_filter_x *filterA,
     STR_EQ(node_a->key, node_b->key);
     STR_EQ(node_a->value, node_b->value);
   }
+
+  return true;
 }
 
 pkgmgr_certinfo_x *GetTestCertInfo() {
@@ -698,4 +699,6 @@ bool IsEqualCertInfo(const pkgmgr_certinfo_x *certA,
     STR_EQ(certA->cert_info[i], certB->cert_info[i]);
   for (int i = 0; i < MAX_CERT_TYPE; ++i)
     INT_EQ(certA->cert_id[i], certB->cert_id[i]);
+
+  return true;
 }