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) {
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);
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 {
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;
}
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_;
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;
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;
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
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) {
break;
case EventInfo::Error:
break;
+ case EventInfo::Custom:
+ break;
}
}