Merge "Add color-depth attribute on splash screen" into tizen accepted/tizen/common/20160511.141652 accepted/tizen/ivi/20160512.045926 accepted/tizen/mobile/20160512.045711 accepted/tizen/tv/20160512.045804 accepted/tizen/wearable/20160512.045742 submit/tizen/20160510.044059
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 10 May 2016 06:21:55 +0000 (23:21 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Tue, 10 May 2016 06:21:55 +0000 (23:21 -0700)
src/common/pkgmgr_registration.cc

index 665027d..73c1e67 100644 (file)
@@ -14,7 +14,7 @@ namespace bf = boost::filesystem;
 
 namespace {
 
-bool RegisterCertificate(
+bool RegisterCertificates(
     const common_installer::CertificateInfo& cert_info,
     const std::string& pkgid, uid_t uid) {
   pkgmgr_instcertinfo_h handle;
@@ -24,53 +24,65 @@ bool RegisterCertificate(
   }
 
   const auto& author_cert = cert_info.author_certificate.get();
-  if (pkgmgr_installer_set_cert_value(handle, PM_SET_AUTHOR_SIGNER_CERT,
-      const_cast<char*>(author_cert->getBase64().c_str())) < 0) {
-    pkgmgr_installer_destroy_certinfo_set_handle(handle);
-    LOG(ERROR) << "pkgmgrInstallerSetCertValue fail";
-    return false;
+  if (author_cert) {
+    if (pkgmgr_installer_set_cert_value(handle, PM_SET_AUTHOR_SIGNER_CERT,
+        const_cast<char*>(author_cert->getBase64().c_str())) < 0) {
+      pkgmgr_installer_destroy_certinfo_set_handle(handle);
+      LOG(ERROR) << "pkgmgrInstallerSetCertValue fail";
+      return false;
+    }
   }
 
   const auto& author_im_cert = cert_info.author_intermediate_certificate.get();
-  if (pkgmgr_installer_set_cert_value(handle, PM_SET_AUTHOR_INTERMEDIATE_CERT,
-      const_cast<char*>(author_im_cert->getBase64().c_str())) < 0) {
-    pkgmgr_installer_destroy_certinfo_set_handle(handle);
-    LOG(ERROR) << "pkgmgrInstallerSetCertValue fail";
-    return false;
+  if (author_im_cert) {
+    if (pkgmgr_installer_set_cert_value(handle, PM_SET_AUTHOR_INTERMEDIATE_CERT,
+        const_cast<char*>(author_im_cert->getBase64().c_str())) < 0) {
+      pkgmgr_installer_destroy_certinfo_set_handle(handle);
+      LOG(ERROR) << "pkgmgrInstallerSetCertValue fail";
+      return false;
+    }
   }
 
   const auto& author_root_cert = cert_info.author_root_certificate.get();
-  if (pkgmgr_installer_set_cert_value(handle, PM_SET_AUTHOR_ROOT_CERT,
-      const_cast<char*>(author_root_cert->getBase64().c_str())) < 0) {
-    pkgmgr_installer_destroy_certinfo_set_handle(handle);
-    LOG(ERROR) << "pkgmgrInstallerSetCertValue fail";
-    return false;
+  if (author_root_cert) {
+    if (pkgmgr_installer_set_cert_value(handle, PM_SET_AUTHOR_ROOT_CERT,
+        const_cast<char*>(author_root_cert->getBase64().c_str())) < 0) {
+      pkgmgr_installer_destroy_certinfo_set_handle(handle);
+      LOG(ERROR) << "pkgmgrInstallerSetCertValue fail";
+      return false;
+    }
   }
 
   const auto& dist_cert = cert_info.distributor_certificate.get();
-  if (pkgmgr_installer_set_cert_value(handle, PM_SET_DISTRIBUTOR_SIGNER_CERT,
-      const_cast<char*>(dist_cert->getBase64().c_str())) < 0) {
-    pkgmgr_installer_destroy_certinfo_set_handle(handle);
-    LOG(ERROR) << "pkgmgrInstallerSetCertValue fail";
-    return false;
+  if (dist_cert) {
+    if (pkgmgr_installer_set_cert_value(handle, PM_SET_DISTRIBUTOR_SIGNER_CERT,
+        const_cast<char*>(dist_cert->getBase64().c_str())) < 0) {
+      pkgmgr_installer_destroy_certinfo_set_handle(handle);
+      LOG(ERROR) << "pkgmgrInstallerSetCertValue fail";
+      return false;
+    }
   }
 
   const auto& dist_im_cert =
       cert_info.distributor_intermediate_certificate.get();
-  if (pkgmgr_installer_set_cert_value(handle,
-      PM_SET_DISTRIBUTOR_INTERMEDIATE_CERT,
-      const_cast<char*>(dist_im_cert->getBase64().c_str())) < 0) {
-    pkgmgr_installer_destroy_certinfo_set_handle(handle);
-    LOG(ERROR) << "pkgmgrInstallerSetCertValue fail";
-    return false;
+  if (dist_im_cert) {
+    if (pkgmgr_installer_set_cert_value(handle,
+        PM_SET_DISTRIBUTOR_INTERMEDIATE_CERT,
+        const_cast<char*>(dist_im_cert->getBase64().c_str())) < 0) {
+      pkgmgr_installer_destroy_certinfo_set_handle(handle);
+      LOG(ERROR) << "pkgmgrInstallerSetCertValue fail";
+      return false;
+    }
   }
 
   const auto& dist_root_cert = cert_info.distributor_root_certificate.get();
-  if (pkgmgr_installer_set_cert_value(handle, PM_SET_DISTRIBUTOR_ROOT_CERT,
-      const_cast<char*>(dist_root_cert->getBase64().c_str())) < 0) {
-    pkgmgr_installer_destroy_certinfo_set_handle(handle);
-    LOG(ERROR) << "pkgmgrInstallerSetCertValue fail";
-    return false;
+  if (dist_root_cert) {
+    if (pkgmgr_installer_set_cert_value(handle, PM_SET_DISTRIBUTOR_ROOT_CERT,
+        const_cast<char*>(dist_root_cert->getBase64().c_str())) < 0) {
+      pkgmgr_installer_destroy_certinfo_set_handle(handle);
+      LOG(ERROR) << "pkgmgrInstallerSetCertValue fail";
+      return false;
+    }
   }
 
   if (pkgmgr_installer_save_certinfo(pkgid.c_str(), handle, uid) < 0) {
@@ -156,11 +168,9 @@ bool RegisterAppInPkgmgr(manifest_x* manifest,
     return false;
   }
 
-  if (!!cert_info.author_certificate.get()) {
-    if (!RegisterCertificate(cert_info, pkgid, uid)) {
-      LOG(ERROR) << "Failed to register author certificate";
-      return false;
-    }
+  if (!RegisterCertificates(cert_info, pkgid, uid)) {
+    LOG(ERROR) << "Failed to register author certificate";
+    return false;
   }
 
   return true;
@@ -186,11 +196,8 @@ bool UpgradeAppInPkgmgr(manifest_x* manifest,
   }
 
   (void) pkgmgr_installer_delete_certinfo(pkgid.c_str());
-  if (!!cert_info.author_certificate.get()) {
-    if (!RegisterCertificate(cert_info, pkgid, uid)) {
-      return false;
-    }
-  }
+  if (!RegisterCertificates(cert_info, pkgid, uid))
+    return false;
 
   return true;
 }