AbstractAction::~AbstractAction() = default;
AbstractAction::Impl::~Impl() = default;
-AbstractAction::Type AbstractAction::GetType(Bundle b) {
- return static_cast<AbstractAction::Type>(
- std::stoi(b.GetString(ABSTRACT_ACTION_TYPE_KEY)));
+int AbstractAction::GetType(Bundle b) {
+ return std::stoi(b.GetString(ABSTRACT_ACTION_TYPE_KEY));
}
Bundle AbstractAction::Serialize() {
NullObject,
AppControl,
Visibility,
- Custom,
+ Custom = 100
};
public:
AbstractAction(bool isLocal, std::string extra);
virtual ~AbstractAction();
- virtual Type GetType() const = 0;
- static Type GetType(Bundle b);
+ virtual int GetType() const = 0;
+ static int GetType(Bundle b);
virtual Bundle Serialize() = 0;
virtual void Deserialize(Bundle b) = 0;
virtual bool IsLocal() const = 0;
namespace notification {
namespace item {
-AbstractItem::AbstractItem(AbstractItem::Type type,
- std::shared_ptr<AbstractAction> action)
- : impl_(new Impl(this, type, action)) {
+AbstractItem::AbstractItem(std::shared_ptr<AbstractAction> action)
+ : impl_(new Impl(this, action)) {
}
-AbstractItem::AbstractItem(std::string id, AbstractItem::Type type,
+AbstractItem::AbstractItem(std::string id,
std::shared_ptr<AbstractAction> action)
- : impl_(new Impl(this, id, type, action)) {
+ : impl_(new Impl(this, id, action)) {
}
AbstractItem::Impl::Impl(AbstractItem* parent, string id,
- AbstractItem::Type type, std::shared_ptr<AbstractAction> action)
- : id_(id), type_(type), action_(action), parent_(parent) {
+ std::shared_ptr<AbstractAction> action)
+ : id_(id), action_(action), parent_(parent) {
LOGI("GroupItem created");
}
AbstractItem::Impl::Impl(AbstractItem* parent,
- AbstractItem::Type type, std::shared_ptr<AbstractAction> action)
- : type_(type), action_(action), parent_(parent) {
+ std::shared_ptr<AbstractAction> action)
+ : action_(action), parent_(parent) {
LOGI("GroupItem created");
}
Bundle AbstractItem::Serialize() {
Bundle b;
- b.Add(ABSTRACT_ITEM_TYPE_KEY, to_string((int)impl_->type_));
+ b.Add(ABSTRACT_ITEM_TYPE_KEY, to_string(GetType()));
b.Add(ABSTRACT_ITEM_ID_KEY, impl_->id_);
return b;
}
string id_str = b.GetString(ABSTRACT_ITEM_ID_KEY);
impl_->id_ = id_str;
- impl_->type_ = static_cast<AbstractItem::Type>(strtol(type_str.c_str(), NULL, 10));
}
string AbstractItem::GetId() const {
return impl_->led_;
}
-AbstractItem::Type AbstractItem::GetType() const {
- return impl_->type_;
-}
-
-AbstractItem::Type AbstractItem::GetType(Bundle b) {
+int AbstractItem::GetType(Bundle b) {
string type_str = b.GetString(ABSTRACT_ITEM_TYPE_KEY);
if (type_str.empty())
THROW(NOTIFICATION_ERROR_IO_ERROR);
- return static_cast<AbstractItem::Type>(strtol(type_str.c_str(), NULL, 10));
+ return strtol(type_str.c_str(), NULL, 10);
}
void AbstractItem::SetVisible(bool visible) {
Entry,
Progress,
Time,
- Custom,
+ Custom = 100
};
enum Policy {
};
public:
- AbstractItem();
- AbstractItem(Type type,
- std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
- AbstractItem(std::string id, Type type,
- std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+ AbstractItem(std::shared_ptr<AbstractAction> action =
+ std::shared_ptr<AbstractAction>({}));
+ AbstractItem(std::string id, std::shared_ptr<AbstractAction> action =
+ std::shared_ptr<AbstractAction>({}));
virtual ~AbstractItem() = 0;
-
virtual Bundle Serialize() = 0;
virtual void Deserialize(Bundle b) = 0;
virtual AbstractItem& FindByID(std::string id) = 0;
+ virtual int GetType() const = 0;
+ static int GetType(Bundle b);
std::string GetId() const;
void SetId(std::string id);
std::shared_ptr<AbstractAction> GetAction() const;
void SetAction(std::shared_ptr<AbstractAction> action) const;
std::shared_ptr<Style> GetStyle() const;
void SetStyle(std::shared_ptr<Style> style);
- Type GetType() const;
- static AbstractItem::Type GetType(Bundle b);
void SetVisible(bool visible);
void SetEnable(bool enable);
void AddReceiver(std::string receiver_group);
private:
Impl(AbstractItem* parent);
- Impl(AbstractItem* parent, AbstractItem::Type type,
- std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
- Impl(AbstractItem* parent, std::string id, AbstractItem::Type type,
- std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+ Impl(AbstractItem* parent, std::shared_ptr<AbstractAction> action =
+ std::shared_ptr<AbstractAction>({}));
+ Impl(AbstractItem* parent, std::string id,
+ std::shared_ptr<AbstractAction> action =
+ std::shared_ptr<AbstractAction>({}));
private:
friend class AbstractItem;
std::shared_ptr<LEDInfo> led_ = nullptr;
Policy policy_ = None;
std::shared_ptr<Style> style_ = nullptr;
- AbstractItem::Type type_;
bool visible_ = true;
bool enable_ = true;
int version_ = 1;
app_control_destroy(control_);
}
-AbstractAction::Type AppControlAction::GetType() const {
+int AppControlAction::GetType() const {
return AbstractAction::AppControl;
}
AppControlAction(app_control_h app_control, std::string extra);
virtual ~AppControlAction();
- AbstractAction::Type GetType() const override;
+ int GetType() const override;
Bundle Serialize() override;
void Deserialize(Bundle b) override;
bool IsLocal() const override;
namespace notification {
namespace item {
-ButtonItem::ButtonItem(string title,
- std::shared_ptr<AbstractAction> action)
- : AbstractItem(AbstractItem::Button, action), impl_(new Impl(this, title)) {
+ButtonItem::ButtonItem(string title, std::shared_ptr<AbstractAction> action)
+ : AbstractItem(action), impl_(new Impl(this, title)) {
}
ButtonItem::ButtonItem(string id, string title,
- std::shared_ptr<AbstractAction> action)
- : AbstractItem(id, AbstractItem::Button, action), impl_(new Impl(this, title)) {
+ std::shared_ptr<AbstractAction> action)
+ : AbstractItem(id, action), impl_(new Impl(this, title)) {
}
ButtonItem::~ButtonItem() = default;
LOGI("ButtonItem impl created");
}
+int ButtonItem::GetType() const {
+ return AbstractItem::Button;
+}
+
Bundle ButtonItem::Serialize() {
Bundle b;
b = AbstractItem::Serialize();
Bundle Serialize() override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
+ int GetType() const override;
std::string GetTitle() const;
private:
ChatMessageItem::ChatMessageItem(std::string id, std::shared_ptr<TextItem> name,
std::shared_ptr<TextItem> text, std::shared_ptr<TextItem> data,
std::shared_ptr<TimeItem> time, Type type, std::shared_ptr<AbstractAction> action)
- : AbstractItem(id, AbstractItem::ChatMessage, action),
+ : AbstractItem(id, action),
impl_(new Impl(this, name, text, data, time, type)) {
}
LOGI("ChatMessageItem impl created");
}
+int ChatMessageItem::GetType() const {
+ return AbstractItem::ChatMessage;
+}
+
Bundle ChatMessageItem::Serialize() {
Bundle b;
b = AbstractItem::Serialize();
TextItem& ChatMessageItem::GetTextItem() const {
return *(impl_->text_);
-
}
TextItem& ChatMessageItem::GetDataItem() const {
return *(impl_->time_);
}
-ChatMessageItem::Type ChatMessageItem::GetType() const {
+ChatMessageItem::Type ChatMessageItem::GetCurType() const {
return impl_->type_;
}
std::shared_ptr<TimeItem> time, Type type,
std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
virtual ~ChatMessageItem();
+ int GetType() const override;
Bundle Serialize() override;
void Deserialize(Bundle b) override;
TextItem& GetTextItem() const;
TextItem& GetDataItem() const;
TimeItem& GetTimeItem() const;
- Type GetType() const;
+ Type GetCurType() const;
private:
class Impl;
CheckBoxItem::CheckBoxItem(std::string id, std::string title, bool checked,
std::shared_ptr<AbstractAction> action)
- : AbstractItem(id, AbstractItem::CheckBox, action),
- impl_(new Impl(this, title, checked)) {
+ : AbstractItem(id, action), impl_(new Impl(this, title, checked)) {
}
CheckBoxItem::Impl::Impl(CheckBoxItem* parent, std::string title, bool checked)
LOGI("CheckBoxItem impl created");
}
+int CheckBoxItem::GetType() const {
+ return AbstractItem::CheckBox;
+}
+
Bundle CheckBoxItem::Serialize() {
Bundle b;
Bundle Serialize() override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
+ int GetType() const override;
std::string GetTitle() const;
bool IsChecked() const;
namespace notification {
namespace item {
-unique_ptr<AbstractAction> DefaultActionFactory::CreateAction(
- AbstractAction::Type type) {
-
+unique_ptr<AbstractAction> DefaultActionFactory::CreateAction(int type) {
switch (type) {
case AbstractAction::NullObject :
THROW(NOTIFICATION_ERROR_INVALID_PARAMETER);
class EXPORT_API DefaultActionFactory : public IActionFactory {
public:
virtual ~DefaultActionFactory() = default;
- std::unique_ptr<AbstractAction> CreateAction(
- AbstractAction::Type type) override;
+ std::unique_ptr<AbstractAction> CreateAction(int type) override;
};
} // namespace item
namespace notification {
namespace item {
-unique_ptr<AbstractItem> DefaultItemFactory::CreateItem(AbstractItem::Type type) {
+unique_ptr<AbstractItem> DefaultItemFactory::CreateItem(int type) {
switch (type) {
case AbstractItem::NullObject :
THROW(NOTIFICATION_ERROR_INVALID_PARAMETER);
class EXPORT_API DefaultItemFactory : public IItemFactory {
public:
virtual ~DefaultItemFactory() = default;
- std::unique_ptr<AbstractItem> CreateItem(AbstractItem::Type type) override;
+ std::unique_ptr<AbstractItem> CreateItem(int type) override;
};
} // namespace item
namespace item {
EntryItem::EntryItem(std::shared_ptr<AbstractAction> action)
- : AbstractItem(AbstractItem::Type::Entry, action), impl_(new Impl(this)) {
+ : AbstractItem(action), impl_(new Impl(this)) {
}
EntryItem::EntryItem(std::string id, std::shared_ptr<AbstractAction> action)
- : AbstractItem(id, AbstractItem::Type::Entry, action), impl_(new Impl(this)) {
+ : AbstractItem(id, action), impl_(new Impl(this)) {
}
EntryItem::Impl::Impl(EntryItem* parent)
EntryItem::~EntryItem() = default;
EntryItem::Impl::~Impl() = default;
+int EntryItem::GetType() const {
+ return AbstractItem::Entry;
+}
+
Bundle EntryItem::Serialize() {
Bundle b;
b = AbstractItem::Serialize();
Bundle Serialize() override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
+ int GetType() const override;
std::string GetText() const;
void SetText(std::string text);
int GetTextLimit() const;
action_factory_ = std::move(factory);
}
-std::unique_ptr<AbstractItem> FactoryManager::CreateItem(
- AbstractItem::Type type) {
+std::unique_ptr<AbstractItem> FactoryManager::CreateItem(int type) {
if (item_factory_.get() == nullptr)
item_factory_.reset(new DefaultItemFactory());
return item_factory_->CreateItem(type);
}
-std::unique_ptr<AbstractAction> FactoryManager::CreateAction(
- AbstractAction::Type type) {
+std::unique_ptr<AbstractAction> FactoryManager::CreateAction(int type) {
if (action_factory_.get() == nullptr)
action_factory_.reset(new DefaultActionFactory());
static FactoryManager& GetInst();
void RegisterFactory(std::unique_ptr<IItemFactory> factory);
void RegisterFactory(std::unique_ptr<IActionFactory> factory);
- std::unique_ptr<AbstractItem> CreateItem(AbstractItem::Type type);
- std::unique_ptr<AbstractAction> CreateAction(AbstractAction::Type type);
+ std::unique_ptr<AbstractItem> CreateItem(int type);
+ std::unique_ptr<AbstractAction> CreateAction(int type);
AbstractItem& GetNullItem();
private:
namespace item {
GroupItem::GroupItem(string id, shared_ptr<AbstractAction> action)
- : AbstractItem(id, AbstractItem::Group), impl_(new Impl(this)) {
+ : AbstractItem(id), impl_(new Impl(this)) {
}
GroupItem::GroupItem(shared_ptr<AbstractAction> action)
- : AbstractItem(AbstractItem::Group), impl_(new Impl(this)) {
+ : AbstractItem(), impl_(new Impl(this)) {
}
GroupItem::Impl::Impl(GroupItem* parent)
GroupItem::~GroupItem() {
}
+int GroupItem::GetType() const {
+ return AbstractItem::Group;
+}
+
Bundle GroupItem::Serialize() {
Bundle b;
b = AbstractItem::Serialize();
virtual Bundle Serialize() override;
virtual void Deserialize(Bundle b) override;
virtual AbstractItem& FindByID(std::string id) override;
+ int GetType() const override;
void SetDirection(bool vertical);
bool IsVertical();
class EXPORT_API IActionFactory {
public:
virtual ~IActionFactory() = default;
- virtual std::unique_ptr<AbstractAction> CreateAction(
- AbstractAction::Type type) = 0;
+ virtual std::unique_ptr<AbstractAction> CreateAction(int type) = 0;
};
} // namespace item
IconItem::~IconItem() = default;
IconItem::Impl::~Impl() = default;
+int IconItem::GetType() const {
+ return AbstractItem::Icon;
+}
+
} // namespace item
} // namespace notification_ex
IconItem(std::string id, std::string iconPath,
std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
virtual ~IconItem();
+ int GetType() const override;
private:
class Impl;
IconTextItem::IconTextItem(std::string id, std::shared_ptr<IconItem> icon,
std::shared_ptr<TextItem> text, std::shared_ptr<AbstractAction> action)
- : AbstractItem(id, AbstractItem::IconText, action),
+ : AbstractItem(id, action),
impl_(new Impl(this, icon, text)) {
}
LOGI("IconTextItem impl created");
}
+int IconTextItem::GetType() const {
+ return AbstractItem::IconText;
+}
+
Bundle IconTextItem::Serialize() {
Bundle b;
b = AbstractItem::Serialize();
Bundle Serialize() override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
+ int GetType() const override;
+
IconItem& GetIconItem() const;
TextItem& GetTextItem() const;
class EXPORT_API IItemFactory {
public:
virtual ~IItemFactory() = default;
- virtual std::unique_ptr<AbstractItem> CreateItem(AbstractItem::Type type) = 0;
+ virtual std::unique_ptr<AbstractItem> CreateItem(int type) = 0;
};
} // namespace item
ImageItem::ImageItem(std::string imagePath,
std::shared_ptr<AbstractAction> action)
- : AbstractItem(AbstractItem::Image, action), impl_(new Impl(this, imagePath)) {
+ : AbstractItem(action), impl_(new Impl(this, imagePath)) {
}
ImageItem::ImageItem(std::string id, std::string imagePath,
std::shared_ptr<AbstractAction> action)
- : AbstractItem(id, AbstractItem::Image, action), impl_(new Impl(this, imagePath)) {
+ : AbstractItem(id, action), impl_(new Impl(this, imagePath)) {
}
ImageItem::Impl::Impl(ImageItem* parent, std::string imagePath)
LOGI("ImageItem impl created");
}
+int ImageItem::GetType() const {
+ return AbstractItem::Image;
+}
+
Bundle ImageItem::Serialize() {
Bundle b;
b = AbstractItem::Serialize();
ImageItem(std::string id, std::string imagePath,
std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
virtual ~ImageItem();
+ int GetType() const override;
Bundle Serialize() override;
void Deserialize(Bundle b) override;
namespace item {
InputSelectorItem::InputSelectorItem(std::shared_ptr<AbstractAction> action)
- : AbstractItem(AbstractItem::InputSelector, action), impl_(new Impl(this)) {
+ : AbstractItem(action), impl_(new Impl(this)) {
}
InputSelectorItem::InputSelectorItem(string id, std::shared_ptr<AbstractAction> action)
- : AbstractItem(id, AbstractItem::InputSelector, action), impl_(new Impl(this)) {
+ : AbstractItem(id, action), impl_(new Impl(this)) {
}
InputSelectorItem::~InputSelectorItem() = default;
LOGI("InputSelectorItem impl created");
}
+int InputSelectorItem::GetType() const {
+ return AbstractItem::InputSelector;
+}
+
Bundle InputSelectorItem::Serialize() {
Bundle b;
b = AbstractItem::Serialize();
virtual Bundle Serialize() override;
virtual void Deserialize(Bundle b) override;
virtual AbstractItem& FindByID(std::string id) override;
+ int GetType() const override;
std::list<std::string> GetContents() const;
void SetContents(std::list<std::string> contents);
namespace item {
NullItem::NullItem(shared_ptr<AbstractAction> action)
- : AbstractItem(AbstractItem::NullObject, action) {
+ : AbstractItem(action) {
}
NullItem::NullItem(string id,
shared_ptr<AbstractAction> action)
- : AbstractItem(id, AbstractItem::NullObject, action) {
+ : AbstractItem(id, action) {
}
NullItem::~NullItem() = default;
+int NullItem::GetType() const {
+ return AbstractItem::NullObject;
+}
+
Bundle NullItem::Serialize() {
Bundle b;
b = AbstractItem::Serialize();
NullItem(std::string id,
std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
virtual ~NullItem();
-
- public:
- virtual Bundle Serialize() override;
- virtual void Deserialize(Bundle b) override;
- virtual AbstractItem& FindByID(std::string id) override;
+ int GetType() const override;
+ Bundle Serialize() override;
+ void Deserialize(Bundle b) override;
+ AbstractItem& FindByID(std::string id) override;
};
} // namespace item
ProgressItem::ProgressItem(float min_val, float current, float max_val,
std::shared_ptr<AbstractAction> action)
- : AbstractItem(AbstractItem::Progress, action),
+ : AbstractItem(action),
impl_(new Impl(min_val, current, max_val, this)) {
}
ProgressItem::ProgressItem(string id, float min_val, float current, float max_val,
std::shared_ptr<AbstractAction> action)
- : AbstractItem(id, AbstractItem::Progress, action),
+ : AbstractItem(id, action),
impl_(new Impl(min_val, current, max_val, this)) {
}
LOGI("ProgressItem impl created");
}
+int ProgressItem::GetType() const {
+ return AbstractItem::Progress;
+}
+
Bundle ProgressItem::Serialize() {
Bundle b;
b = AbstractItem::Serialize();
virtual Bundle Serialize() override;
virtual void Deserialize(Bundle b) override;
virtual AbstractItem& FindByID(std::string id) override;
+ int GetType() const override;
float GetCurrent() const;
void SetCurrent(float current);
namespace item {
TextItem::TextItem(std::string id, std::string text, std::string hyperlink,
std::shared_ptr<AbstractAction> action)
- : AbstractItem(id, AbstractItem::Type::Text, action),
- impl_(new Impl(this, text, hyperlink)) {
+ : AbstractItem(id, action), impl_(new Impl(this, text, hyperlink)) {
}
TextItem::Impl::Impl(TextItem* parent, std::string text, std::string hyperlink)
TextItem::~TextItem() = default;
TextItem::Impl::~Impl() = default;
+int TextItem::GetType() const {
+ return AbstractItem::Text;
+}
+
Bundle TextItem::Serialize() {
Bundle b;
b = AbstractItem::Serialize();
std::string hyperlink = std::string(),
std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
virtual ~TextItem();
-
+ int GetType() const override;
Bundle Serialize() override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
namespace item {
TimeItem::TimeItem(std::shared_ptr<AbstractAction> action)
- : AbstractItem(AbstractItem::Time, action), impl_(new Impl(this, 0)) {
+ : AbstractItem(action), impl_(new Impl(this, 0)) {
time_t current_time;
time(¤t_time);
}
TimeItem::TimeItem(time_t time, std::shared_ptr<AbstractAction> action)
- : AbstractItem(AbstractItem::Time, action), impl_(new Impl(this, time)) {
+ : AbstractItem(action), impl_(new Impl(this, time)) {
}
TimeItem::TimeItem(std::string id, time_t time,
std::shared_ptr<AbstractAction> action)
- : AbstractItem(id, AbstractItem::Time, action), impl_(new Impl(this, time)) {
+ : AbstractItem(id, action), impl_(new Impl(this, time)) {
}
TimeItem::Impl::Impl(TimeItem* parent, time_t time)
LOGI("TimeItem impl created");
}
+int TimeItem::GetType() const {
+ return AbstractItem::Time;
+}
+
Bundle TimeItem::Serialize() {
Bundle b;
struct tm* timeinfo;
std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
virtual ~TimeItem();
-
+ int GetType() const override;
Bundle Serialize() override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
VisibilityAction::~VisibilityAction() = default;
VisibilityAction::Impl::~Impl() = default;
-AbstractAction::Type VisibilityAction::GetType() const {
+int VisibilityAction::GetType() const {
return AbstractAction::Visibility;
}
VisibilityAction(std::string extra);
virtual ~VisibilityAction();
- AbstractAction::Type GetType() const override;
+ int GetType() const override;
Bundle Serialize() override;
void Deserialize(Bundle b) override;
bool IsLocal() const override;
ASSERT_EQ(message.GetNameItem().GetContents(), "name");
ASSERT_EQ(message.GetTextItem().GetContents(), "text");
ASSERT_EQ(message.GetDataItem().GetContents(), "data");
- ASSERT_EQ(message.GetType(), ChatMessageItemTest::type);
+ ASSERT_EQ(message.GetCurType(), ChatMessageItemTest::type);
}
TEST_F(ChatMessageItemTest, FindByIDNullItemReturn) {
ASSERT_EQ(gen_message->GetTextItem().GetContents(), "text");
ASSERT_EQ(gen_message->GetDataItem().GetContents(), "data");
ASSERT_EQ(gen_message->GetTimeItem().GetTime(), ChatMessageItemTest::current_time);
- ASSERT_EQ(gen_message->GetType(), ChatMessageItemTest::type);
+ ASSERT_EQ(gen_message->GetCurType(), ChatMessageItemTest::type);
}