From: Junghoon Park Date: Tue, 26 Mar 2019 08:21:36 +0000 (+0900) Subject: Use int type for EventType to extend X-Git-Tag: submit/tizen/20190328.044251~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c146e850503c4dc95f6f9117f17df35a4f1a2395;p=platform%2Fcore%2Fapi%2Fnotification.git Use int type for EventType to extend Change-Id: Ifdab1a45108eefb6eb3a411ab36af2eda210a682 Signed-off-by: Junghoon Park --- diff --git a/notification-ex/event_info.cc b/notification-ex/event_info.cc index f88ea82a..c220603b 100644 --- a/notification-ex/event_info.cc +++ b/notification-ex/event_info.cc @@ -40,15 +40,15 @@ using namespace std; namespace notification { -EventInfo::EventInfo(IEventInfo::EventType type, - std::string owner, std::string channel, std::string item_id, std::string tag) +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)) { } EventInfo::~EventInfo() = default; EventInfo::Impl::~Impl() = default; EventInfo::Impl::Impl(EventInfo* parent, - IEventInfo::EventType type, std::string owner, std::string channel, + 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) { @@ -61,7 +61,7 @@ EventInfo::Impl::Impl(EventInfo* parent, EventInfo::EventInfo(Bundle serialized) : impl_(new Impl(this, EventInfo::Post, "", "", "", "")) { string event_str = serialized.GetString(NOTIFICATION_EX_EVENT_TYPE_KEY); - impl_->type_ = (IEventInfo::EventType)(int)strtol(event_str.c_str(), NULL, 10); + 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); @@ -76,25 +76,21 @@ EventInfo::EventInfo(Bundle serialized) impl_->error_ = (NotificationError)strtol(error_str.c_str(), NULL, 10); } -string EventInfo::GetString(IEventInfo::EventType type) { +string EventInfo::GetString(int type) { switch(type) { case Post: return "Post"; - break; case Update: return "Update"; - break; case Delete: return "Delete"; - break; case Get: return "Get"; - break; case Error: return "Error"; - break; + default: + return "Custom" + std::to_string(Custom); } - return ""; } Bundle EventInfo::Serialize() const { @@ -113,11 +109,11 @@ Bundle EventInfo::Serialize() const { return serialized; } -IEventInfo::EventType EventInfo::GetEventType() const { +int EventInfo::GetEventType() const { return impl_->type_; } -void EventInfo::SetEventType(EventInfo::EventType type) { +void EventInfo::SetEventType(int type) { impl_->type_ = type; } diff --git a/notification-ex/event_info_implementation.h b/notification-ex/event_info_implementation.h index 4e0d11e2..d429211c 100644 --- a/notification-ex/event_info_implementation.h +++ b/notification-ex/event_info_implementation.h @@ -35,12 +35,11 @@ class EventInfo::Impl { private: friend class EventInfo; - Impl(EventInfo* parent, IEventInfo::EventType type, - std::string owner, std::string channel, + Impl(EventInfo* parent, int type, std::string owner, std::string channel, std::string item_id, std::string tag); private: - EventType type_; + int type_; std::string owner_; std::string channel_; std::string item_id_; diff --git a/notification-ex/event_info_internal.h b/notification-ex/event_info_internal.h index 90bf0c29..234c8615 100644 --- a/notification-ex/event_info_internal.h +++ b/notification-ex/event_info_internal.h @@ -32,25 +32,23 @@ 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(int 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; NotificationError GetError() const override; void SetError(NotificationError error) override; - EventType GetEventType() const override; - void SetEventType(EventType type) override; + int GetEventType() const override; + void SetEventType(int type) override; 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(EventType type); + static std::string GetString(int type); private: class Impl; diff --git a/notification-ex/ievent_info.h b/notification-ex/ievent_info.h index 89f16c7e..57eddb01 100644 --- a/notification-ex/ievent_info.h +++ b/notification-ex/ievent_info.h @@ -33,9 +33,10 @@ class EXPORT_API IEventInfo { Delete, Get, Error, + Custom = 100 }; virtual ~IEventInfo() = default; - virtual EventType GetEventType() const = 0; + virtual int GetEventType() const = 0; virtual std::string GetOwner() const = 0; virtual std::string GetChannel() const = 0; virtual std::string GetItemId() const = 0; diff --git a/notification-ex/ievent_info_internal.h b/notification-ex/ievent_info_internal.h index 15c669c1..d5ef3a63 100644 --- a/notification-ex/ievent_info_internal.h +++ b/notification-ex/ievent_info_internal.h @@ -29,7 +29,7 @@ class IEventInfoInternal : public IEventInfo { virtual void SetUid(uid_t uid) = 0; virtual NotificationError GetError() const = 0; virtual void SetError(NotificationError error) = 0; - virtual void SetEventType(EventType type) = 0; + virtual void SetEventType(int type) = 0; }; } // namespace notification diff --git a/notification-ex/manager.cc b/notification-ex/manager.cc index f1abd0a1..b99d6e9c 100644 --- a/notification-ex/manager.cc +++ b/notification-ex/manager.cc @@ -136,7 +136,7 @@ list Manager::OnRequest(const IEventInfo& info) { void Manager::OnEvent(const IEventInfo& info, list serialized) { shared_ptr gen_item; - const IEventInfo::EventType type = info.GetEventType(); + int type = info.GetEventType(); NotificationError error = (static_cast(info)).GetError(); if (error != NOTIFICATION_ERROR_NONE) { @@ -177,6 +177,8 @@ void Manager::OnEvent(const IEventInfo& info, list serialized) { break; case EventInfo::Error: break; + case EventInfo::Custom: + break; } }