Implement unimplemented APIs
[platform/core/appfw/slp-pkgmgr.git] / client / src / PkgSignal.cc
index 7869ac3..216a9e8 100644 (file)
@@ -346,6 +346,20 @@ void PkgSignal::EventCb(const char* event_name, bundle* event_data, void* user_d
     break;
 
 
+    case static_cast<int>(MethodId::AsyncResultForPkgUpgrade):
+    {
+      char* param1_raw  = nullptr;
+      rpc_port_parcel_read_string(p, &param1_raw);
+      std::string param1(param1_raw);
+      free(param1_raw);
+      int param2;
+      rpc_port_parcel_read_int32(p, &param2);
+      ptr->OnAsyncResultForPkgUpgrade(param1, param2);
+
+    }
+    break;
+
+
 
     default:
       _E("Unknown command(%d)", cmd);
@@ -424,6 +438,38 @@ void PkgSignal::AsyncResultForResource(std::string signal, int targetUid, std::s
     throw InvalidIOException();
   }
 }
+
+void PkgSignal::AsyncResultForPkgUpgrade(std::string signal, int progress) {
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+  std::unique_ptr<std::remove_pointer<rpc_port_parcel_h>::type,
+      decltype(rpc_port_parcel_destroy)*> p_auto(p, rpc_port_parcel_destroy);
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::AsyncResultForPkgUpgrade));
+  rpc_port_parcel_write_string(p, signal.c_str());
+  rpc_port_parcel_write_int32(p, progress);
+
+
+  // Send
+  bundle* b = bundle_create();
+  std::unique_ptr<bundle, decltype(bundle_free)*> b_auto(b, bundle_free);
+  if (GetBundleFromParcel(p, b) == nullptr) {
+    _E("Failed to make bundle from parcel");
+    throw InvalidIOException();
+  }
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+  int ret = event_publish_app_event(GetEventName().c_str(), b);
+  if (ret != EVENT_ERROR_NONE) {
+    _E("Failed to publish event. result(%d)", ret);
+    throw InvalidIOException();
+  }
+}
 }  // namespace group
 }  // namespace PkgSignal
 }  // namespace rpc_port