From: hyunho Date: Wed, 20 Mar 2019 02:21:34 +0000 (+0900) Subject: Hide private event info using interface X-Git-Tag: submit/tizen/20190326.074206~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e9154136b29f11bfd025fd1f752f3e1c2259fbf8;p=platform%2Fcore%2Fapi%2Fnotification.git Hide private event info using interface Change-Id: I314475eb35498358cceb4141672cfcc08aaf3b2f Signed-off-by: hyunho --- diff --git a/notification-ex/dbus_event_listener.cc b/notification-ex/dbus_event_listener.cc index 2346b599..0ff42d19 100644 --- a/notification-ex/dbus_event_listener.cc +++ b/notification-ex/dbus_event_listener.cc @@ -23,6 +23,7 @@ #include "notification-ex/dbus_event_listener_implementation.h" #include "notification-ex/exception.h" #include "notification-ex/ex_util.h" +#include "notification-ex/event_info_internal.h" #ifdef LOG_TAG #undef LOG_TAG @@ -206,11 +207,11 @@ void DBusEventListener::UnRegisterObserver(IEventObserver* observer) { } void DBusEventListener::NotifyObserver( - const EventInfo& info, list serialized) { + const IEventInfo& info, list serialized) { impl_->observer_->OnEvent(info, serialized); } -list DBusEventListener::NotifyObserver(const EventInfo& info) { +list DBusEventListener::NotifyObserver(const IEventInfo& info) { return impl_->observer_->OnRequest(info); } diff --git a/notification-ex/dbus_event_listener.h b/notification-ex/dbus_event_listener.h index ea1452bb..15b1fde7 100644 --- a/notification-ex/dbus_event_listener.h +++ b/notification-ex/dbus_event_listener.h @@ -29,8 +29,8 @@ class EXPORT_API DBusEventListener : public IEventListener { void RegisterObserver(IEventObserver* observer) override; void UnRegisterObserver(IEventObserver* observer) override; void NotifyObserver( - const EventInfo& info, std::list serialized) override; - std::list NotifyObserver(const EventInfo& info) override; + const IEventInfo& info, std::list serialized) override; + std::list NotifyObserver(const IEventInfo& info) override; private: class Impl; diff --git a/notification-ex/dbus_sender.cc b/notification-ex/dbus_sender.cc index 760a5a0f..1e43ac7d 100644 --- a/notification-ex/dbus_sender.cc +++ b/notification-ex/dbus_sender.cc @@ -23,7 +23,7 @@ #include "notification-ex/dbus_connection_manager.h" #include "notification-ex/dbus_sender.h" #include "notification-ex/dbus_sender_implementation.h" -#include "notification-ex/event_info.h" +#include "notification-ex/event_info_internal.h" #include "notification-ex/ex_util.h" #ifdef LOG_TAG @@ -76,7 +76,7 @@ bool DBusSender::Impl::EmitSignal(string bus_name, string signal_name, return result; } -void DBusSender::Notify(const EventInfo& info, list serialized, +void DBusSender::Notify(const IEventInfo& info, list serialized, string dest_appid) { string signal_name = EventInfo::GetString(info.GetEventType()); string appid = util::GetAppId(); @@ -131,7 +131,7 @@ GDBusMessage* DBusSender::Impl::MethodCall(string appid, string method_name, return reply; } -std::list DBusSender::Request(const EventInfo& info) { +std::list DBusSender::Request(const IEventInfo& info) { string appid = util::GetAppId(); string method_name = EventInfo::GetString(info.GetEventType()); Bundle serialized = info.Serialize(); diff --git a/notification-ex/dbus_sender.h b/notification-ex/dbus_sender.h index b9c9659d..7e86e8e7 100644 --- a/notification-ex/dbus_sender.h +++ b/notification-ex/dbus_sender.h @@ -19,7 +19,7 @@ #include "notification-ex/ex_bundle.h" #include "notification-ex/event_sender_interface.h" -#include "notification-ex/event_info.h" +#include "notification-ex/ievent_info.h" #ifndef EXPORT_API #define EXPORT_API __attribute__((visibility("default"))) @@ -32,9 +32,9 @@ class EXPORT_API DBusSender : public IEventSender { DBusSender(std::string path); virtual ~DBusSender(); - void Notify(const EventInfo& info, std::list serialized, + void Notify(const IEventInfo& info, std::list serialized, std::string dest_appid = "") override; - std::list Request(const EventInfo& info) override; + std::list Request(const IEventInfo& info) override; private: class Impl; diff --git a/notification-ex/event_info.cc b/notification-ex/event_info.cc index 552159a0..d6562fba 100644 --- a/notification-ex/event_info.cc +++ b/notification-ex/event_info.cc @@ -15,10 +15,11 @@ */ #include +#include #include -#include "notification-ex/event_info.h" +#include "notification-ex/event_info_internal.h" #include "notification-ex/event_info_implementation.h" #ifdef LOG_TAG @@ -31,35 +32,39 @@ #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__" using namespace std; namespace notification { -EventInfo::EventInfo(EventInfo::EventType type, std::string owner, +EventInfo::EventInfo(IEventInfo::EventType type, std::string owner, std::string channel, std::string item_id, std::string tag) : impl_(new Impl(this, type, owner, channel, item_id, tag)) { } EventInfo::~EventInfo() = default; EventInfo::Impl::~Impl() = default; -EventInfo::Impl::Impl(EventInfo* parent, EventInfo::EventType type, std::string owner, +EventInfo::Impl::Impl(EventInfo* parent, IEventInfo::EventType 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) { + uid_ = getuid(); LOGI("EventInfo impl created"); } EventInfo::EventInfo(Bundle serialized) : impl_(new Impl(this, EventInfo::Post, "", "", "", "")) { string event_str = serialized.GetString(NOTIFICATION_EX_EVENT_TYPE_KEY); - impl_->type_ = (EventInfo::EventType)(int)strtol(event_str.c_str(), NULL, 10); + impl_->type_ = (IEventInfo::EventType)(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 EventInfo::GetString(EventInfo::EventType type) { +string EventInfo::GetString(IEventInfo::EventType type) { switch(type) { case Post: return "Post"; @@ -84,11 +89,12 @@ Bundle EventInfo::Serialize() const { 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_)); return serialized; } -EventInfo::EventType EventInfo::GetEventType() const { +IEventInfo::EventType EventInfo::GetEventType() const { return impl_->type_; } @@ -108,4 +114,12 @@ string EventInfo::GetTag() const { return impl_->tag_; } +uid_t EventInfo::GetUid() const { + return impl_->uid_; +} + +void EventInfo::SetUid(uid_t uid) { + impl_->uid_ = uid; +} + } // namespace notification diff --git a/notification-ex/event_info.h b/notification-ex/event_info.h deleted file mode 100644 index 5b998b3e..00000000 --- a/notification-ex/event_info.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NOTIFICATION_EX_EVENT_INFO_H_ -#define NOTIFICATION_EX_EVENT_INFO_H_ - -#include -#include - -#include "notification-ex/ex_bundle.h" - -#ifndef EXPORT_API -#define EXPORT_API __attribute__((visibility("default"))) -#endif - -namespace notification { - -class EXPORT_API EventInfo { - public: - enum EventType { - Post, - Update, - Delete, - Get, - }; - EventInfo(EventType type, std::string owner, - std::string channel = "", - std::string item_id = "", - std::string tag = ""); - EventInfo(Bundle serialized); - ~EventInfo(); - - static std::string GetString(EventType type); - EventType GetEventType() const; - std::string GetOwner() const; - std::string GetChannel() const; - std::string GetItemId() const; - std::string GetTag() const; - Bundle Serialize() const; - - private: - class Impl; - std::unique_ptr impl_; -}; - -} // namespace notification - -#endif // NOTIFICATION_EX_EVENT_INFO_H_ diff --git a/notification-ex/event_info_implementation.h b/notification-ex/event_info_implementation.h index 9ec2fb63..5eeec292 100644 --- a/notification-ex/event_info_implementation.h +++ b/notification-ex/event_info_implementation.h @@ -21,7 +21,10 @@ #include #include +#include + #include "notification-ex/dbus_sender.h" +#include "notification-ex/ievent_info.h" namespace notification { @@ -31,7 +34,7 @@ class EventInfo::Impl { private: friend class EventInfo; - Impl(EventInfo* parent, EventInfo::EventType type, std::string owner, + Impl(EventInfo* parent, IEventInfo::EventType type, std::string owner, std::string channel, std::string item_id, std::string tag); private: @@ -40,6 +43,7 @@ class EventInfo::Impl { std::string channel_; std::string item_id_; std::string tag_; + uid_t uid_; EventInfo* parent_; }; diff --git a/notification-ex/event_info_internal.h b/notification-ex/event_info_internal.h new file mode 100644 index 00000000..6cf8bbfe --- /dev/null +++ b/notification-ex/event_info_internal.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NOTIFICATION_EX_EVENT_INFO_INTERNAL_H_ +#define NOTIFICATION_EX_EVENT_INFO_INTERNAL_H_ + +#include +#include + +#include "notification-ex/ex_bundle.h" +#include "notification-ex/ievent_info_internal.h" + +#ifndef EXPORT_API +#define EXPORT_API __attribute__((visibility("default"))) +#endif + +namespace notification { + +class EventInfo : public IEventInfoInternal { + public: + EventInfo(IEventInfo::EventType type, std::string owner, + std::string channel = "", + std::string item_id = "", + std::string tag = ""); + EventInfo(Bundle serialized); + virtual ~EventInfo(); + uid_t GetUid() const override; + void SetUid(uid_t uid) override; + EventType GetEventType() const override; + std::string GetOwner() const override; + std::string GetChannel() const override; + std::string GetItemId() const override; + std::string GetTag() const override; + Bundle Serialize() const override; + static std::string GetString(EventType type); + + private: + class Impl; + std::unique_ptr impl_; +}; + +} // namespace notification + +#endif // NOTIFICATION_EX_EVENT_INFO_INTERNAL_H_ diff --git a/notification-ex/event_listener_interface.h b/notification-ex/event_listener_interface.h index 7d95807c..c59908bf 100644 --- a/notification-ex/event_listener_interface.h +++ b/notification-ex/event_listener_interface.h @@ -17,8 +17,10 @@ #ifndef NOTIFICATION_EX_EVENT_LISTENER_INTERFACE_H_ #define NOTIFICATION_EX_EVENT_LISTENER_INTERFACE_H_ +#include + #include "notification-ex/event_observer_interface.h" -#include "notification-ex/event_info.h" +#include "notification-ex/ievent_info.h" #ifndef EXPORT_API #define EXPORT_API __attribute__((visibility("default"))) @@ -31,8 +33,8 @@ class EXPORT_API IEventListener { virtual ~IEventListener() = default; virtual void RegisterObserver(IEventObserver* observer) = 0; virtual void UnRegisterObserver(IEventObserver* observer) = 0; - virtual void NotifyObserver(const EventInfo& info, std::list serialized) = 0; - virtual std::list NotifyObserver(const EventInfo& info) = 0; + virtual void NotifyObserver(const IEventInfo& info, std::list serialized) = 0; + virtual std::list NotifyObserver(const IEventInfo& info) = 0; }; } // namespace notification diff --git a/notification-ex/event_observer_interface.h b/notification-ex/event_observer_interface.h index a94abe8e..e3192a50 100644 --- a/notification-ex/event_observer_interface.h +++ b/notification-ex/event_observer_interface.h @@ -17,8 +17,10 @@ #ifndef NOTIFICATION_EX_OBSERVER_INTERFACE_H_ #define NOTIFICATION_EX_OBSERVER_INTERFACE_H_ +#include + #include "notification-ex/ex_bundle.h" -#include "notification-ex/event_info.h" +#include "notification-ex/ievent_info.h" #ifndef EXPORT_API #define EXPORT_API __attribute__((visibility("default"))) @@ -29,8 +31,8 @@ namespace notification { class EXPORT_API IEventObserver { public: virtual ~IEventObserver() = default; - virtual void OnEvent(const EventInfo& info, std::list serialized) = 0; - virtual std::list OnRequest(const EventInfo& info) = 0; + virtual void OnEvent(const IEventInfo& info, std::list serialized) = 0; + virtual std::list OnRequest(const IEventInfo& info) = 0; }; } // namespace notification diff --git a/notification-ex/event_sender_interface.h b/notification-ex/event_sender_interface.h index fcefaec2..8b8bb1f0 100644 --- a/notification-ex/event_sender_interface.h +++ b/notification-ex/event_sender_interface.h @@ -17,8 +17,10 @@ #ifndef NOTIFICATION_EX_EVENT_SENDER_INTERFACE_H_ #define NOTIFICATION_EX_EVENT_SENDER_INTERFACE_H_ +#include + #include "notification-ex/ex_bundle.h" -#include "notification-ex/event_info.h" +#include "notification-ex/ievent_info.h" #ifndef EXPORT_API #define EXPORT_API __attribute__((visibility("default"))) @@ -28,9 +30,9 @@ namespace notification { class EXPORT_API IEventSender { public: - virtual void Notify(const EventInfo& info, std::list serialized, + virtual void Notify(const IEventInfo& info, std::list serialized, std::string dest_appid = "") = 0; - virtual std::list Request(const EventInfo &info) = 0; + virtual std::list Request(const IEventInfo &info) = 0; }; } // namespace notification diff --git a/notification-ex/ievent_info.h b/notification-ex/ievent_info.h new file mode 100644 index 00000000..f7847ef5 --- /dev/null +++ b/notification-ex/ievent_info.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NOTIFICATION_EX_IEVENT_INFO_H_ +#define NOTIFICATION_EX_IEVENT_INFO_H_ + +#include "notification-ex/ex_bundle.h" + +namespace notification { + +#ifndef EXPORT_API +#define EXPORT_API __attribute__((visibility("default"))) +#endif + +class EXPORT_API IEventInfo { + public: + enum EventType { + Post, + Update, + Delete, + Get, + }; + virtual ~IEventInfo() = default; + virtual EventType GetEventType() const = 0; + 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 Bundle Serialize() const = 0; +}; + +} // nampace notification +#endif // NOTIFICATION_EX_IEVENT_INFO_H_ diff --git a/notification-ex/ievent_info_internal.h b/notification-ex/ievent_info_internal.h new file mode 100644 index 00000000..7ed5f3b7 --- /dev/null +++ b/notification-ex/ievent_info_internal.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NOTIFICATION_EX_IEVENT_INFO_INTERNAL_H_ +#define NOTIFICATION_EX_IEVENT_INFO_INTERNAL_H_ + +#include "notification-ex/ievent_info.h" + +namespace notification { + +class IEventInfoInternal : public IEventInfo { + public: + virtual ~IEventInfoInternal() = default; + virtual uid_t GetUid() const = 0; + virtual void SetUid(uid_t uid) = 0; +}; + +} // nampace notification +#endif // NOTIFICATION_EX_IEVENT_INFO_INTERNAL_H_ diff --git a/notification-ex/manager.cc b/notification-ex/manager.cc index e0cd39bc..8ad885b6 100644 --- a/notification-ex/manager.cc +++ b/notification-ex/manager.cc @@ -23,7 +23,7 @@ #include "notification-ex/item_inflator.h" #include "notification-ex/manager.h" #include "notification-ex/manager_implementation.h" -#include "notification-ex/event_info.h" +#include "notification-ex/event_info_internal.h" #include "notification-ex/dbus_connection_manager.h" #include "notification-ex/ex_util.h" #include "notification-ex/item_info_internal.h" @@ -61,7 +61,7 @@ Manager::Impl::Impl(Manager* parent, } void Manager::Impl::SendNotify(shared_ptr noti, - EventInfo::EventType type) { + IEventInfo::EventType type) { Bundle serialized = noti->Serialize(); EventInfo info(type, util::GetAppId(), noti->GetChannel()); list serialized_list {serialized}; @@ -106,7 +106,7 @@ list> Manager::Get() { return gen_list; } -void Manager::SendEvent(const EventInfo& info, +void Manager::SendEvent(const IEventInfo& info, shared_ptr noti) { Bundle serialized = noti->Serialize(); Bundle serialized_info = info.Serialize(); @@ -114,7 +114,7 @@ void Manager::SendEvent(const EventInfo& info, impl_->sender_->Notify(info, serialized_list, noti->GetSenderAppId()); } -list Manager::OnRequest(const EventInfo& info) { +list Manager::OnRequest(const IEventInfo& info) { list> item_list = OnRequestEvent(info); list serialized_list; for (auto& i : item_list) { @@ -123,9 +123,9 @@ list Manager::OnRequest(const EventInfo& info) { return serialized_list; } -void Manager::OnEvent(const EventInfo& info, list serialized) { +void Manager::OnEvent(const IEventInfo& info, list serialized) { shared_ptr gen_item; - const EventInfo::EventType type = info.GetEventType(); + const IEventInfo::EventType type = info.GetEventType(); switch(type) { case EventInfo::Post: { list> added; @@ -159,19 +159,19 @@ void Manager::OnEvent(const EventInfo& info, list serialized) { } } -void Manager::OnAdd(const EventInfo& info, +void Manager::OnAdd(const IEventInfo& info, list> addedItem) { } -void Manager::OnUpdate(const EventInfo& info, +void Manager::OnUpdate(const IEventInfo& info, shared_ptr updatedItem) { } -void Manager::OnDelete(const EventInfo& info, +void Manager::OnDelete(const IEventInfo& info, shared_ptr deletedItem) { } -list> Manager::OnRequestEvent(const EventInfo& info) { +list> Manager::OnRequestEvent(const IEventInfo& info) { return list>({}); } diff --git a/notification-ex/manager.h b/notification-ex/manager.h index 7168b2ce..65e802ad 100644 --- a/notification-ex/manager.h +++ b/notification-ex/manager.h @@ -43,17 +43,17 @@ class EXPORT_API Manager : public IEventObserver { void Remove(std::shared_ptr noti); void Hide(std::shared_ptr noti); std::shared_ptr FindByRootID(std::string id); - void SendEvent(const EventInfo& info, std::shared_ptr noti); - void OnEvent(const EventInfo& info, std::list serialized) override; - std::list OnRequest(const EventInfo& info) override; + void SendEvent(const IEventInfo& info, std::shared_ptr noti); + void OnEvent(const IEventInfo& info, std::list serialized) override; + std::list OnRequest(const IEventInfo& info) override; static std::string GetPath(); protected: - virtual void OnAdd(const EventInfo& info, std::list> addedItem); - virtual void OnUpdate(const EventInfo& info, std::shared_ptr updatedItem); - virtual void OnDelete(const EventInfo& info, std::shared_ptr deletedItem); + virtual void OnAdd(const IEventInfo& info, std::list> addedItem); + virtual void OnUpdate(const IEventInfo& info, std::shared_ptr updatedItem); + virtual void OnDelete(const IEventInfo& info, std::shared_ptr deletedItem); virtual std::list> OnRequestEvent( - const EventInfo& info); + const IEventInfo& info); private: class Impl; diff --git a/notification-ex/manager_implementation.h b/notification-ex/manager_implementation.h index 667cff78..4b76ca6d 100644 --- a/notification-ex/manager_implementation.h +++ b/notification-ex/manager_implementation.h @@ -36,7 +36,7 @@ class Manager::Impl { private: friend class Manager; void SendNotify(std::shared_ptr noti, - EventInfo::EventType type); + IEventInfo::EventType type); std::unique_ptr sender_; std::unique_ptr listener_; std::string receiver_group_; diff --git a/notification-ex/reporter.cc b/notification-ex/reporter.cc index 2c9a4a29..cfe5097b 100644 --- a/notification-ex/reporter.cc +++ b/notification-ex/reporter.cc @@ -22,7 +22,7 @@ #include "notification-ex/reporter.h" #include "notification-ex/reporter_implementation.h" -#include "notification-ex/event_info.h" +#include "notification-ex/event_info_internal.h" #include "notification-ex/item_inflator.h" #include "notification-ex/dbus_connection_manager.h" #include "notification-ex/ex_util.h" @@ -56,7 +56,7 @@ Reporter::Impl::Impl(Reporter* parent, } void Reporter::Impl::SendNotify(shared_ptr noti, - EventInfo::EventType type) { + IEventInfo::EventType type) { Bundle serialized = noti->Serialize(); EventInfo info(type, util::GetAppId(), noti->GetChannel()); list serialized_list {serialized}; @@ -99,14 +99,14 @@ std::shared_ptr Reporter::FindByRootID(std::string id) { return gen_item; } -void Reporter::SendEvent(const EventInfo& info, +void Reporter::SendEvent(const IEventInfo& info, shared_ptr noti) { Bundle serialized = noti->Serialize(); list serialized_list {serialized}; impl_->sender_->Notify(info, serialized_list); } -void Reporter::OnEvent(const EventInfo& info, list serialized) { +void Reporter::OnEvent(const IEventInfo& info, list serialized) { list> item_list; for (auto& i : serialized) { shared_ptr gen_item = ItemInflator::Create(i); @@ -115,11 +115,11 @@ void Reporter::OnEvent(const EventInfo& info, list serialized) { OnEvent(info, item_list); } -list> Reporter::OnRequestEvent(const EventInfo& info) { +list> Reporter::OnRequestEvent(const IEventInfo& info) { return list>({}); } -list Reporter::OnRequest(const EventInfo& info) { +list Reporter::OnRequest(const IEventInfo& info) { list> item_list = OnRequestEvent(info); list serialized_list; for (auto& i : item_list) { @@ -129,7 +129,7 @@ list Reporter::OnRequest(const EventInfo& info) { } void Reporter::OnEvent( - const EventInfo& info, list> notiList) { + const IEventInfo& info, list> notiList) { } string Reporter::GetPath() { diff --git a/notification-ex/reporter.h b/notification-ex/reporter.h index 3b5fd966..d416abad 100644 --- a/notification-ex/reporter.h +++ b/notification-ex/reporter.h @@ -21,7 +21,7 @@ #include #include -#include "notification-ex/event_info.h" +#include "notification-ex/ievent_info.h" #include "notification-ex/event_observer_interface.h" #include "notification-ex/event_sender_interface.h" #include "notification-ex/event_listener_interface.h" @@ -39,18 +39,18 @@ class EXPORT_API Reporter : public IEventObserver { std::unique_ptr listener); virtual ~Reporter(); - void SendEvent(const EventInfo& info, std::shared_ptr noti); + void SendEvent(const IEventInfo& info, std::shared_ptr noti); void Post(std::shared_ptr noti); void Post(std::list> notiList); void Update(std::shared_ptr noti); void Remove(std::shared_ptr noti); std::shared_ptr FindByRootID(std::string id); - virtual void OnEvent(const EventInfo& info, + virtual void OnEvent(const IEventInfo& info, std::list> notiList); virtual std::list> OnRequestEvent( - const EventInfo& info); - void OnEvent(const EventInfo& info, std::list serialized) override; - std::list OnRequest(const EventInfo& info) override; + const IEventInfo& info); + void OnEvent(const IEventInfo& info, std::list serialized) override; + std::list OnRequest(const IEventInfo& info) override; static std::string GetPath(); private: diff --git a/notification-ex/reporter_implementation.h b/notification-ex/reporter_implementation.h index dc63b887..4a0c41d5 100644 --- a/notification-ex/reporter_implementation.h +++ b/notification-ex/reporter_implementation.h @@ -36,7 +36,7 @@ class Reporter::Impl { private: friend class Reporter; void SendNotify(std::shared_ptr noti, - EventInfo::EventType type); + IEventInfo::EventType type); std::unique_ptr sender_; std::unique_ptr listener_; Reporter* parent_; diff --git a/unittest/src/test_event_info.cc b/unittest/src/test_event_info.cc index b1f20dc2..7daafa62 100644 --- a/unittest/src/test_event_info.cc +++ b/unittest/src/test_event_info.cc @@ -4,7 +4,7 @@ #include -#include "notification-ex/event_info.h" +#include "notification-ex/event_info_internal.h" using namespace notification; using namespace std; @@ -26,6 +26,7 @@ TEST_F(EventInfoTest, SerializeDeserialize) { ASSERT_EQ(serialized.GetChannel(), info.GetChannel()); ASSERT_EQ(serialized.GetItemId(), info.GetItemId()); ASSERT_EQ(serialized.GetTag(), info.GetTag()); + ASSERT_EQ(serialized.GetUid(), info.GetUid()); } TEST_F(EventInfoTest, GetString) {