#include "notification-ex/group_item.h"
#include "notification-ex/group_item_implementation.h"
#include "notification-ex/factory_manager.h"
+#include "notification-ex/ex_util.h"
#include "notification-ex/exception.h"
#ifdef LOG_TAG
GroupItem::Impl::Impl(GroupItem* parent)
: parent_(parent) {
LOGI("GroupItem created");
+ char* name;
+ int ret = app_get_name(&name);
+ if (ret != APP_ERROR_NONE) {
+ app_label_ = util::GetAppId();
+ } else {
+ app_label_ = string(name);
+ free(name);
+ }
}
GroupItem::~GroupItem() {
b = AbstractItem::Serialize();
b.Add(GROUP_DIRECTION_KEY, impl_->is_vertical_ ?
GROUP_DIRECTION_VERTICAL : GROUP_DIRECTION_HORIZONTAL);
- if (!impl_->app_label_.empty())
- b.Add(GROUP_APP_LABEL_KEY, impl_->app_label_);
+ b.Add(GROUP_APP_LABEL_KEY, impl_->app_label_);
if (impl_->children_list_.size() == 0)
return b;
return FactoryManager::GetInst().GetNullItem();
}
+AbstractItem& GroupItem::FindByMainType(MainType type) {
+ if (GetMainType() == type)
+ return *this;
+
+ for (auto& i : impl_->children_list_) {
+ auto& re = i.get()->FindByMainType(type);
+ if (re.GetType() != NullObject)
+ return re;
+ }
+ return FactoryManager::GetInst().GetNullItem();
+}
+
bool GroupItem::IsItemTypeExist(int type) {
if (GetType() == type)
return true;
list<string> GroupItem::GetSharedPath() const {
list<string> ret;
+ auto r = AbstractItem::GetSharedPath();
+ for (auto& shared_path_r : r)
+ ret.push_back(move(shared_path_r));
+
for (auto& i : impl_->children_list_) {
- auto s = i->GetSharedPath();
- for (auto& j : s) {
- ret.push_back(move(j));
- }
+ auto c = i->GetSharedPath();
+ for (auto& shared_path_c : c)
+ ret.push_back(move(shared_path_c));
}
return ret;
}
+void GroupItem::SetSharedPath() {
+ for (auto& i : impl_->children_list_)
+ i->SetSharedPath();
+}
+
+list<map<string, string>> GroupItem::GetPathMapList() const {
+ list<map<string, string>> path_map_list;
+
+ auto r = AbstractItem::GetPathMapList();
+ for (auto& path_map_r : r)
+ path_map_list.push_back(move(path_map_r));
+
+ for (auto& i : impl_->children_list_) {
+ auto c = i->GetPathMapList();
+ for (auto& path_map_c : c)
+ path_map_list.push_back(move(path_map_c));
+ }
+
+ return path_map_list;
+}
+
void GroupItem::AddChild(shared_ptr<AbstractItem> child) {
impl_->children_list_.emplace_back(child);
}
}
}
+void GroupItem::RemoveChildren() {
+ for (auto& i : impl_->children_list_) {
+ impl_->children_list_.remove(i);
+ }
+}
+
list<shared_ptr<AbstractItem>> GroupItem::GetChildren() {
return impl_->children_list_;
}
}
string GroupItem::GetAppLabel() {
- if (impl_->app_label_.empty()) {
- char* name;
- int ret = app_get_name(&name);
- if (ret != APP_ERROR_NONE)
- THROW(ERROR_IO_ERROR);
- impl_->app_label_ = string(name);
- }
return impl_->app_label_;
}