Add private_sharing codes for sound and vibration 61/213961/5
authormk5004.lee <mk5004.lee@samsung.com>
Tue, 17 Sep 2019 04:56:41 +0000 (13:56 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Tue, 8 Oct 2019 05:59:09 +0000 (14:59 +0900)
Change-Id: I6fe3b6fb21e40f9df4ed34fd97d6c9b9b3021302
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
notification-ex/abstract_item.cc
notification-ex/abstract_item.h
notification-ex/abstract_item_implementation.h
notification-ex/group_item.cc

index b4e3e15..8bca334 100644 (file)
@@ -31,6 +31,7 @@
 #include "notification-ex/ex_util.h"
 #include "notification-ex/action_inflator.h"
 #include "notification-ex/factory_manager.h"
+#include "notification-ex/shared_file.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -422,14 +423,42 @@ string AbstractItem::GetId() const {
 }
 
 std::list<std::string> AbstractItem::GetSharedPath() const {
-  return {};
+  std::list<std::string> ret;
+
+  if (!impl_->priv_sound_path_.empty())
+    ret.push_back(impl_->priv_sound_path_);
+
+  if (!impl_->priv_vibration_path_.empty())
+    ret.push_back(impl_->priv_vibration_path_);
+
+  return ret;
 }
 
 void AbstractItem::SetSharedPath() {
+  if (!impl_->priv_sound_path_.empty())
+    impl_->sound_path_ = impl_->priv_sound_path_;
+
+  if (!impl_->priv_vibration_path_.empty())
+    impl_->vibration_path_ = impl_->priv_vibration_path_;
 }
 
 std::list<std::map<std::string, std::string>> AbstractItem::GetPathMapList() const {
-  return {};
+  std::list<std::map<std::string, std::string>> path_map_list;
+  std::map<std::string, std::string> path_map;
+
+  if (!impl_->priv_sound_path_.empty()) {
+    path_map.insert(std::pair<std::string, std::string>(impl_->sound_path_,
+        impl_->priv_sound_path_));
+    path_map_list.push_back(path_map);
+  }
+
+  if (!impl_->priv_vibration_path_.empty()) {
+    path_map.insert(std::pair<std::string, std::string>(impl_->vibration_path_,
+        impl_->priv_vibration_path_));
+    path_map_list.push_back(path_map);
+  }
+
+  return path_map_list;
 }
 
 shared_ptr<AbstractAction> AbstractItem::GetAction() const {
@@ -513,10 +542,12 @@ void AbstractItem::SetChannel(string channel) {
 
 void AbstractItem::SetSoundPath(std::string path) {
   impl_->sound_path_ = path;
+  UpdateSoundPrivatePath();
 }
 
 void AbstractItem::SetVibrationPath(std::string path) {
   impl_->vibration_path_ = path;
+  UpdateVibrationPrivatePath();
 }
 
 std::string AbstractItem::GetSoundPath() const {
@@ -628,5 +659,35 @@ void AbstractItem::SetMultiLanguage(
   impl_->multi_lang_arr_ = multi_arr;
 }
 
+void AbstractItem::UpdateSoundPrivatePath() {
+  SharedFile* shared_file = new SharedFile();
+  if (!shared_file->IsPrivatePath(impl_->sound_path_)) {
+    delete(shared_file);
+    return;
+  }
+
+  std::string path = shared_file->GetDataPath(AbstractItem::GetSenderAppId(),
+            impl_->sound_path_);
+  if (!path.empty())
+    impl_->priv_sound_path_ = path;
+
+  delete(shared_file);
+}
+
+void AbstractItem::UpdateVibrationPrivatePath() {
+  SharedFile* shared_file = new SharedFile();
+  if (!shared_file->IsPrivatePath(impl_->vibration_path_)) {
+    delete(shared_file);
+    return;
+  }
+
+  std::string path = shared_file->GetDataPath(AbstractItem::GetSenderAppId(),
+            impl_->vibration_path_);
+  if (!path.empty())
+    impl_->priv_vibration_path_ = path;
+
+  delete(shared_file);
+}
+
 }  // namespace item
 }  // namespace notification
index fd46375..a5cef50 100644 (file)
@@ -1069,6 +1069,8 @@ class EXPORT_API AbstractItem {
  private:
   class Impl;
   std::unique_ptr<Impl> impl_;
+  void UpdateSoundPrivatePath();
+  void UpdateVibrationPrivatePath();
 };  // class AbstractItem
 
 }  // namespace item
index f943a0c..431921e 100644 (file)
@@ -60,7 +60,9 @@ class AbstractItem::Impl {
   std::vector<std::shared_ptr<MultiLanguage>> multi_lang_arr_;
   AbstractItem* parent_;
   std::string sound_path_;
+  std::string priv_sound_path_;
   std::string vibration_path_;
+  std::string priv_vibration_path_;
   std::string sender_appid_;
   std::shared_ptr<IItemInfo> info_;
   std::list<std::string> hide_viewer_list_;
index 1488835..cd2569e 100644 (file)
@@ -145,11 +145,14 @@ bool GroupItem::IsItemTypeExist(int type) {
 list<string> GroupItem::GetSharedPath() const {
   list<string> ret;
 
+  auto r = AbstractItem::GetSharedPath();
+  for (auto& shared_path_r : r)
+    ret.push_back(move(shared_path_r));
+
   for (auto& i : impl_->children_list_) {
-    auto s = i->GetSharedPath();
-    for (auto& j : s) {
-      ret.push_back(move(j));
-    }
+    auto c = i->GetSharedPath();
+    for (auto& shared_path_c : c)
+      ret.push_back(move(shared_path_c));
   }
 
   return ret;
@@ -163,11 +166,14 @@ void GroupItem::SetSharedPath() {
 list<map<string, string>> GroupItem::GetPathMapList() const {
   list<map<string, string>> path_map_list;
 
+  auto r = AbstractItem::GetPathMapList();
+  for (auto& path_map_r : r)
+    path_map_list.push_back(move(path_map_r));
+
   for (auto& i : impl_->children_list_) {
-    auto path_map_list_ = i->GetPathMapList();
-    for (auto& path_map : path_map_list_) {
-      path_map_list.push_back(move(path_map));
-    }
+    auto c = i->GetPathMapList();
+    for (auto& path_map_c : c)
+      path_map_list.push_back(move(path_map_c));
   }
 
   return path_map_list;