From 2f0b50f09d172251a595884dba7585377b5ccdbd Mon Sep 17 00:00:00 2001 From: jusung son Date: Thu, 28 Mar 2019 16:20:04 +0900 Subject: [PATCH] Add tag implementation for AbstractItem Change-Id: Ibc947cfb699bacee69917e0286633f43928dfebb Signed-off-by: jusung son --- notification-ex/abstract_item.cc | 11 +++++++++++ notification-ex/abstract_item.h | 4 ++-- notification-ex/event_info.cc | 22 +++++++-------------- notification-ex/event_info_implementation.h | 5 ++--- notification-ex/event_info_internal.h | 3 +-- notification-ex/ievent_info.h | 1 - unittest/src/test_abstract_item.cc | 2 ++ unittest/src/test_event_info.cc | 3 +-- 8 files changed, 26 insertions(+), 25 deletions(-) diff --git a/notification-ex/abstract_item.cc b/notification-ex/abstract_item.cc index ef1663f5..4dd60fb1 100644 --- a/notification-ex/abstract_item.cc +++ b/notification-ex/abstract_item.cc @@ -38,6 +38,7 @@ #define ABSTRACT_ITEM_UID_KEY "__ABSTRACT_ITEM_UID_KEY__" #define ABSTRACT_ITEM_TIME_KEY "__ABSTRACT_ITEM_TIME_KEY__" #define ABSTRACT_ITEM_SENDER_APPID_KEY "__ABSTRACT_ITEM_SENDER_APPID_KEY__" +#define ABSTRACT_ITEM_TAG_KEY "__ABSTRACT_ITEM_TAG_KEY__" #define ABSTRACT_ITEM_CHANNEL_KEY "__ABSTRACT_ITEM_CHANNEL_KEY__" #define ABSTRACT_ITEM_VERSION_KEY "__ABSTRACT_ITEM_VERSION_KEY__" #define ABSTRACT_ITEM_HIDE_TIME_KEY "__ABSTRACT_ITEM_HIDE_TIME_KEY__" @@ -142,6 +143,7 @@ Bundle AbstractItem::Serialize() const { b.Add(ABSTRACT_ITEM_HIDE_TIME_KEY, to_string(impl_->hide_time_)); b.Add(ABSTRACT_ITEM_DELETE_TIME_KEY, to_string(impl_->delete_time_)); b.Add(ABSTRACT_ITEM_UID_KEY, to_string(impl_->uid_)); + b.Add(ABSTRACT_ITEM_TAG_KEY, impl_->tag_); timeinfo = localtime(&impl_->time_); strftime (buf, sizeof(buf), "%s", timeinfo); @@ -248,6 +250,7 @@ void AbstractItem::Deserialize(Bundle b) { impl_->sound_path_ = b.GetString(ABSTRACT_ITEM_SOUND_PATH_KEY); impl_->vibration_path_ = b.GetString(ABSTRACT_ITEM_VIBRATION_PATH_KEY); impl_->uid_ = stoi(b.GetString(ABSTRACT_ITEM_UID_KEY)); + impl_->tag_ = b.GetString(ABSTRACT_ITEM_TAG_KEY); time_s = b.GetString(ABSTRACT_ITEM_TIME_KEY); strptime(time_s.c_str(), "%s", &timeinfo); @@ -447,5 +450,13 @@ void AbstractItem::SetSenderAppId(std::string sender_appid) { impl_->sender_appid_ = sender_appid; } +std::string AbstractItem::GetTag() const { + return impl_->tag_; +} + +void AbstractItem::SetTag(std::string tag) { + impl_->tag_ = tag; +} + } // namespace item } // namespace notification diff --git a/notification-ex/abstract_item.h b/notification-ex/abstract_item.h index c7d27268..2ac01a23 100644 --- a/notification-ex/abstract_item.h +++ b/notification-ex/abstract_item.h @@ -263,8 +263,8 @@ class EXPORT_API AbstractItem { std::shared_ptr GetInfo() const; std::string GetSenderAppId() const; void SetSenderAppId(std::string sender_appid); - std::string GetTag(); - void SetTag(); + std::string GetTag() const; + void SetTag(std::string tag); private: class Impl; diff --git a/notification-ex/event_info.cc b/notification-ex/event_info.cc index c220603b..2dbd554a 100644 --- a/notification-ex/event_info.cc +++ b/notification-ex/event_info.cc @@ -32,7 +32,6 @@ #define NOTIFICATION_EX_EVENT_OWNER_KEY "__NOTIFICATION_EX_EVENT_OWNER_KEY__" #define NOTIFICATION_EX_EVENT_CHANNEL_KEY "__NOTIFICATION_EX_EVENT_CHANNEL_KEY__" #define NOTIFICATION_EX_EVENT_ITEM_ID_KEY "__NOTIFICATION_EX_EVENT_ITEM_ID_KEY__" -#define NOTIFICATION_EX_EVENT_TAG_KEY "__NOTIFICATION_EX_EVENT_TAG_KEY__" #define NOTIFICATION_EX_EVENT_UID_KEY "__NOTIFICATION_EX_EVENT_UID_KEY__" #define NOTIFICATION_EX_EVENT_REQUEST_ID_KEY "__NOTIFICATION_EX_EVENT_REQUEST_ID_KEY__" #define NOTIFICATION_EX_EVENT_ERROR_KEY "__NOTIFICATION_EX_EVENT_ERROR_KEY__" @@ -41,17 +40,16 @@ using namespace std; namespace notification { EventInfo::EventInfo(int type, std::string owner, std::string channel, - std::string item_id, std::string tag) - : impl_(new Impl(this, type, owner, channel, item_id, tag)) { + std::string item_id) + : impl_(new Impl(this, type, owner, channel, item_id)) { } EventInfo::~EventInfo() = default; EventInfo::Impl::~Impl() = default; -EventInfo::Impl::Impl(EventInfo* parent, - int type, std::string owner, std::string channel, - std::string item_id, std::string tag) - : type_(type), owner_(owner), channel_(channel), - item_id_(item_id), tag_(tag), parent_(parent) { +EventInfo::Impl::Impl(EventInfo* parent, int type, std::string owner, + std::string channel, std::string item_id) + : type_(type), owner_(owner), channel_(channel), item_id_(item_id), + parent_(parent) { uid_ = getuid(); request_id_ = util::GetRequestId(); error_ = NOTIFICATION_ERROR_NONE; @@ -59,13 +57,12 @@ EventInfo::Impl::Impl(EventInfo* parent, } EventInfo::EventInfo(Bundle serialized) - : impl_(new Impl(this, EventInfo::Post, "", "", "", "")) { + : impl_(new Impl(this, EventInfo::Post, "", "", "")) { string event_str = serialized.GetString(NOTIFICATION_EX_EVENT_TYPE_KEY); impl_->type_ = (int)strtol(event_str.c_str(), NULL, 10); impl_->owner_ = serialized.GetString(NOTIFICATION_EX_EVENT_OWNER_KEY); impl_->channel_ = serialized.GetString(NOTIFICATION_EX_EVENT_CHANNEL_KEY); impl_->item_id_ = serialized.GetString(NOTIFICATION_EX_EVENT_ITEM_ID_KEY); - impl_->tag_ = serialized.GetString(NOTIFICATION_EX_EVENT_TAG_KEY); string uid_str = serialized.GetString(NOTIFICATION_EX_EVENT_UID_KEY); impl_->uid_ = (uid_t)strtol(uid_str.c_str(), NULL, 10); string request_id_str = @@ -99,7 +96,6 @@ Bundle EventInfo::Serialize() const { serialized.Add(NOTIFICATION_EX_EVENT_OWNER_KEY, impl_->owner_); serialized.Add(NOTIFICATION_EX_EVENT_CHANNEL_KEY, impl_->channel_); serialized.Add(NOTIFICATION_EX_EVENT_ITEM_ID_KEY, impl_->item_id_); - serialized.Add(NOTIFICATION_EX_EVENT_TAG_KEY, impl_->tag_); serialized.Add(NOTIFICATION_EX_EVENT_UID_KEY, to_string((int)impl_->uid_)); serialized.Add( NOTIFICATION_EX_EVENT_REQUEST_ID_KEY, to_string(impl_->request_id_)); @@ -129,10 +125,6 @@ string EventInfo::GetItemId() const { return impl_->item_id_; } -string EventInfo::GetTag() const { - return impl_->tag_; -} - uid_t EventInfo::GetUid() const { return impl_->uid_; } diff --git a/notification-ex/event_info_implementation.h b/notification-ex/event_info_implementation.h index d429211c..41ef31fd 100644 --- a/notification-ex/event_info_implementation.h +++ b/notification-ex/event_info_implementation.h @@ -36,14 +36,13 @@ class EventInfo::Impl { private: friend class EventInfo; Impl(EventInfo* parent, int type, std::string owner, std::string channel, - std::string item_id, std::string tag); + std::string item_id); private: int type_; std::string owner_; std::string channel_; std::string item_id_; - std::string tag_; uid_t uid_; int request_id_; NotificationError error_; @@ -51,4 +50,4 @@ class EventInfo::Impl { }; } // namespace notification -#endif // NOTIFICATION_EX_EVENT_INFO_IMPLEMENTATION_H_ \ No newline at end of file +#endif // NOTIFICATION_EX_EVENT_INFO_IMPLEMENTATION_H_ diff --git a/notification-ex/event_info_internal.h b/notification-ex/event_info_internal.h index 234c8615..ada713a5 100644 --- a/notification-ex/event_info_internal.h +++ b/notification-ex/event_info_internal.h @@ -33,7 +33,7 @@ namespace notification { class EventInfo : public IEventInfoInternal { public: EventInfo(int type, std::string owner, std::string channel = "", - std::string item_id = "", std::string tag = ""); + std::string item_id = ""); EventInfo(Bundle serialized); virtual ~EventInfo(); uid_t GetUid() const override; @@ -45,7 +45,6 @@ class EventInfo : public IEventInfoInternal { std::string GetOwner() const override; std::string GetChannel() const override; std::string GetItemId() const override; - std::string GetTag() const override; int GetRequestId() const override; Bundle Serialize() const override; static std::string GetString(int type); diff --git a/notification-ex/ievent_info.h b/notification-ex/ievent_info.h index 57eddb01..690b9748 100644 --- a/notification-ex/ievent_info.h +++ b/notification-ex/ievent_info.h @@ -40,7 +40,6 @@ class EXPORT_API IEventInfo { virtual std::string GetOwner() const = 0; virtual std::string GetChannel() const = 0; virtual std::string GetItemId() const = 0; - virtual std::string GetTag() const = 0; virtual int GetRequestId() const = 0; virtual Bundle Serialize() const = 0; }; diff --git a/unittest/src/test_abstract_item.cc b/unittest/src/test_abstract_item.cc index 2c1e6da5..ecb89720 100644 --- a/unittest/src/test_abstract_item.cc +++ b/unittest/src/test_abstract_item.cc @@ -118,6 +118,7 @@ TEST_F(AbstractItemTest, SerializeDeserialize) { item.SetVibrationPath("vibrationpath"); std::static_pointer_cast(item.GetInfo())->SetUid(3); item.SetSenderAppId("sender"); + item.SetTag("tag"); time(¤t_time); std::static_pointer_cast(item.GetInfo())->SetTime(current_time); @@ -149,6 +150,7 @@ TEST_F(AbstractItemTest, SerializeDeserialize) { ASSERT_EQ(gen_test->GetSoundPath(), "soundpath"); ASSERT_EQ(gen_test->GetVibrationPath(), "vibrationpath"); ASSERT_EQ(gen_test->GetSenderAppId(), "sender"); + ASSERT_EQ(gen_test->GetTag(), "tag"); ASSERT_EQ(gen_test->GetInfo()->GetTime(), current_time); ASSERT_EQ(gen_test->GetStyle()->GetPadding().GetLeft(), 10); diff --git a/unittest/src/test_event_info.cc b/unittest/src/test_event_info.cc index 7daafa62..120cee5d 100644 --- a/unittest/src/test_event_info.cc +++ b/unittest/src/test_event_info.cc @@ -18,14 +18,13 @@ class EventInfoTest : public ::testing::Test { }; TEST_F(EventInfoTest, SerializeDeserialize) { - EventInfo info(EventInfo::Get, "test", "channel", "id", "tag"); + EventInfo info(EventInfo::Get, "test", "channel", "id"); Bundle b = info.Serialize(); EventInfo serialized(b); ASSERT_EQ(serialized.GetEventType(), info.GetEventType()); ASSERT_EQ(serialized.GetOwner(), info.GetOwner()); ASSERT_EQ(serialized.GetChannel(), info.GetChannel()); ASSERT_EQ(serialized.GetItemId(), info.GetItemId()); - ASSERT_EQ(serialized.GetTag(), info.GetTag()); ASSERT_EQ(serialized.GetUid(), info.GetUid()); } -- 2.34.1