Use int type for EventType to extend 46/202246/1
authorJunghoon Park <jh9216.park@samsung.com>
Tue, 26 Mar 2019 08:21:36 +0000 (17:21 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Tue, 26 Mar 2019 08:21:36 +0000 (17:21 +0900)
Change-Id: Ifdab1a45108eefb6eb3a411ab36af2eda210a682
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
notification-ex/event_info.cc
notification-ex/event_info_implementation.h
notification-ex/event_info_internal.h
notification-ex/ievent_info.h
notification-ex/ievent_info_internal.h
notification-ex/manager.cc

index f88ea82a24ef0b55ca08b215f5948db0bdd42739..c220603bb4d3dc58453f26b729a770e3a105b64e 100644 (file)
 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;
 }
 
index 4e0d11e2bf2dae5700f5cfb4d02435f24ac2d86f..d429211c22b0b9cb9a4fbb2f26f1436fa21df05f 100644 (file)
@@ -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_;
index 90bf0c2924caed6ad850828a94d7edb5a9771588..234c8615bf9c95be830a0c07212329b4b6ebf0bb 100644 (file)
@@ -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;
index 89f16c7e5a236a187066b10910d0ddf13045b18d..57eddb01d6b905ffc7524a8cfc522d64aa54af28 100644 (file)
@@ -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;
index 15c669c1ba55868a32d6b998f613214992f8e9a2..d5ef3a639f9a47cb8043acfa3a5a76b5eee3e30e 100644 (file)
@@ -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
index f1abd0a1fffd76ab8b719565a33f0e18b3fa43ff..b99d6e9ccdfa24d7e6eff3758125a1aa8e2a4462 100644 (file)
@@ -136,7 +136,7 @@ list<Bundle> Manager::OnRequest(const IEventInfo& info) {
 
 void Manager::OnEvent(const IEventInfo& info, list<Bundle> serialized) {
   shared_ptr<AbstractItem> gen_item;
-  const IEventInfo::EventType type = info.GetEventType();
+  int type = info.GetEventType();
   NotificationError error =
       (static_cast<const IEventInfoInternal&>(info)).GetError();
   if (error != NOTIFICATION_ERROR_NONE) {
@@ -177,6 +177,8 @@ void Manager::OnEvent(const IEventInfo& info, list<Bundle> serialized) {
       break;
     case EventInfo::Error:
       break;
+    case EventInfo::Custom:
+      break;
   }
 }