From: mk5004.lee Date: Tue, 17 Sep 2019 04:56:41 +0000 (+0900) Subject: Add private_sharing codes for sound and vibration X-Git-Tag: submit/tizen/20191030.063841~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b96ba851a0184882b9d8ababc14008500d2a67c8;p=platform%2Fcore%2Fapi%2Fnotification.git Add private_sharing codes for sound and vibration Change-Id: I6fe3b6fb21e40f9df4ed34fd97d6c9b9b3021302 Signed-off-by: mk5004.lee --- diff --git a/notification-ex/abstract_item.cc b/notification-ex/abstract_item.cc index b4e3e15e..8bca3348 100644 --- a/notification-ex/abstract_item.cc +++ b/notification-ex/abstract_item.cc @@ -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 AbstractItem::GetSharedPath() const { - return {}; + std::list 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> AbstractItem::GetPathMapList() const { - return {}; + std::list> path_map_list; + std::map path_map; + + if (!impl_->priv_sound_path_.empty()) { + path_map.insert(std::pair(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(impl_->vibration_path_, + impl_->priv_vibration_path_)); + path_map_list.push_back(path_map); + } + + return path_map_list; } shared_ptr 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 diff --git a/notification-ex/abstract_item.h b/notification-ex/abstract_item.h index fd463756..a5cef50c 100644 --- a/notification-ex/abstract_item.h +++ b/notification-ex/abstract_item.h @@ -1069,6 +1069,8 @@ class EXPORT_API AbstractItem { private: class Impl; std::unique_ptr impl_; + void UpdateSoundPrivatePath(); + void UpdateVibrationPrivatePath(); }; // class AbstractItem } // namespace item diff --git a/notification-ex/abstract_item_implementation.h b/notification-ex/abstract_item_implementation.h index f943a0c7..431921e0 100644 --- a/notification-ex/abstract_item_implementation.h +++ b/notification-ex/abstract_item_implementation.h @@ -60,7 +60,9 @@ class AbstractItem::Impl { std::vector> 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 info_; std::list hide_viewer_list_; diff --git a/notification-ex/group_item.cc b/notification-ex/group_item.cc index 14888350..cd2569e9 100644 --- a/notification-ex/group_item.cc +++ b/notification-ex/group_item.cc @@ -145,11 +145,14 @@ bool GroupItem::IsItemTypeExist(int type) { list GroupItem::GetSharedPath() const { list 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> GroupItem::GetPathMapList() const { list> 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;