b.Add(ABSTRACT_ACTION_TYPE_KEY, std::to_string(GetType()));
b.Add(ABSTRACT_ACTION_IS_LOCAL_KEY, std::to_string(impl_->isLocal_));
if (!impl_->extra_.empty())
- b.Add(ABSTRACT_ACTION_EXTRA_KEY ,impl_->extra_);
+ b.Add(ABSTRACT_ACTION_EXTRA_KEY, impl_->extra_);
return b;
}
#include <memory>
#include <algorithm>
+#include <vector>
#include "notification-ex/exception.h"
#include "notification-ex/abstract_item.h"
Bundle AbstractItem::Serialize() const {
Bundle b;
struct tm timeinfo;
- char buf[80] = {0,};
+ char buf[80] = {0, };
if (impl_->uid_ == 0)
impl_->uid_ = getuid();
impl_->policy_ = static_cast<Policy>(stoi(policy_str));
- impl_->visible_ = (bool)stoi(b.GetString(ABSTRACT_ITEM_VISIBLE_KEY));
+ impl_->visible_ = static_cast<bool>(stoi(b.GetString(ABSTRACT_ITEM_VISIBLE_KEY)));
- impl_->enable_ = (bool)stoi(b.GetString(ABSTRACT_ITEM_ENABLE_KEY));
+ impl_->enable_ = static_cast<bool>(stoi(b.GetString(ABSTRACT_ITEM_ENABLE_KEY)));
vector<string> receiver_group = b.GetStringArray(ABSTRACT_ITEM_RECEIVER_GROUP_KEY);
if (receiver_group.size() != 0) {
#include <dlog.h>
#include <app_control_internal.h>
+#include <string>
+
#include "notification-ex/app_control_action.h"
#include "notification-ex/app_control_action_implementation.h"
#include "notification-ex/exception.h"
return impl_->control_;
}
-} //namespace item
-} //namespace notification
+} // namespace item
+} // namespace notification
reinterpret_cast<char*>(impl_->image_->Serialize().ToRaw().first.get()));
b.Add(CHATMESSAGE_TIME_KEY,
reinterpret_cast<char*>(impl_->time_->Serialize().ToRaw().first.get()));
- b.Add(CHATMESSAGE_TYPE_KEY, std::to_string((int)impl_->type_));
+ b.Add(CHATMESSAGE_TYPE_KEY, std::to_string(static_cast<int>(impl_->type_)));
return b;
}
ChatMessageItem::Impl::~Impl() = default;
} // namespace item
-} // namespace notification_ex
+} // namespace notification
#include <vconf.h>
#include <pkgmgr-info.h>
#include <tzplatform_config.h>
+
#include <string.h>
#include <list>
#include <map>
#include <glib.h>
#include <unistd.h>
+#include <string>
+#include <list>
+
#include "notification-ex/dbus_connection_manager.h"
#include "notification-ex/dbus_event_listener.h"
#include "notification-ex/dbus_event_listener_implementation.h"
#include <glib.h>
#include <unistd.h>
+#include <string>
#include <list>
#include "notification-ex/dbus_connection_manager.h"
case AbstractItem::NullObject :
THROW(ERROR_INVALID_PARAMETER);
case AbstractItem::Text :
- return unique_ptr<AbstractItem>(new TextItem("",""));
+ return unique_ptr<AbstractItem>(new TextItem("", ""));
case AbstractItem::Icon :
return unique_ptr<AbstractItem>(new IconItem(""));
case AbstractItem::Image :
EventInfo::EventInfo(Bundle serialized)
: impl_(new Impl(this, EventInfo::Post, "", "", "")) {
string event_str = serialized.GetString(NOTIFICATION_EX_EVENT_TYPE_KEY);
- impl_->type_ = (int)strtol(event_str.c_str(), NULL, 10);
+ impl_->type_ = std::stoi(event_str, nullptr, 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);
string uid_str = serialized.GetString(NOTIFICATION_EX_EVENT_UID_KEY);
- impl_->uid_ = (uid_t)strtol(uid_str.c_str(), NULL, 10);
+ impl_->uid_ = (uid_t)std::stoi(uid_str, nullptr, 10);
string request_id_str =
serialized.GetString(NOTIFICATION_EX_EVENT_REQUEST_ID_KEY);
- impl_->request_id_ = (int)strtol(request_id_str.c_str(), NULL, 10);
+ impl_->request_id_ = std::stoi(request_id_str, nullptr, 10);
string error_str =
serialized.GetString(NOTIFICATION_EX_EVENT_ERROR_KEY);
impl_->error_ = (NotificationError)strtol(error_str.c_str(), NULL, 10);
}
string EventInfo::GetString(int type) {
- switch(type) {
+ switch (type) {
case Post:
return "Post";
case Update:
Bundle EventInfo::Serialize() const {
Bundle serialized;
- serialized.Add(NOTIFICATION_EX_EVENT_TYPE_KEY, to_string((int)impl_->type_));
+ serialized.Add(NOTIFICATION_EX_EVENT_TYPE_KEY, to_string(static_cast<int>(impl_->type_)));
serialized.Add(NOTIFICATION_EX_EVENT_OWNER_KEY, impl_->owner_);
serialized.Add(NOTIFICATION_EX_EVENT_CHANNEL_KEY, impl_->channel_);
serialized.Add(NOTIFICATION_EX_EVENT_ITEM_ID_KEY, impl_->item_id_);
- serialized.Add(NOTIFICATION_EX_EVENT_UID_KEY, to_string((int)impl_->uid_));
+ serialized.Add(NOTIFICATION_EX_EVENT_UID_KEY, to_string(static_cast<int>(impl_->uid_)));
serialized.Add(
NOTIFICATION_EX_EVENT_REQUEST_ID_KEY, to_string(impl_->request_id_));
serialized.Add(
for (auto& i : impl_->children_list_) {
Bundle serialized = i.get()->Serialize();
serialized.Add(
- GROUP_CHILDREN_TYPE_KEY, to_string((int)i.get()->GetType()));
+ GROUP_CHILDREN_TYPE_KEY, to_string(static_cast<int>(i.get()->GetType())));
arr.push_back(reinterpret_cast<char*>(serialized.ToRaw().first.get()));
}
b.Add(GROUP_CHILDREN_KEY, arr);
}
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_;
+ 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_;
}
} // namespace item
IconTextItem::Impl::~Impl() = default;
} // namespace item
-} // namespace notification_ex
+} // namespace notification
}
int Manager::Hide(shared_ptr<item::AbstractItem> noti) {
- ((IItemInfoInternal*)noti->GetInfo().get())->AddHideViewer(util::GetAppId());
+ (reinterpret_cast<IItemInfoInternal*>(noti->GetInfo().get()))->AddHideViewer(util::GetAppId());
return impl_->SendNotify(noti, EventInfo::Update);
}
return;
}
- switch(type) {
+ switch (type) {
case EventInfo::Post: {
list<shared_ptr<item::AbstractItem>> added;
for (auto& i : serialized) {
using namespace notification;
namespace {
+
class Handle {
public:
- Handle(item::AbstractItem* ref) : ref_(ref) { }
- Handle(std::shared_ptr<item::AbstractItem> ptr)
+ explicit Handle(item::AbstractItem* ref) : ref_(ref) { }
+ explicit Handle(std::shared_ptr<item::AbstractItem> ptr)
: ref_(nullptr), ptr_(move(ptr)) { }
virtual ~Handle() = default;
item::AbstractItem* Get() const {
private:
item::AbstractItem* ref_;
std::shared_ptr<item::AbstractItem> ptr_;
-
};
class ManagerCallbackInfo {
void InvokeAdded(Manager* manager, const IEventInfo& info,
list<shared_ptr<AbstractItem>> addedItem) {
-
noti_ex_item_h* added_item =
(noti_ex_item_h*)calloc(addedItem.size(), sizeof(noti_ex_item_h));
if (added_item == nullptr) {
void OnAdd(const IEventInfo& info,
list<shared_ptr<AbstractItem>> addedItem) override {
cb_->InvokeAdded(this, info, addedItem);
-
}
void OnUpdate(const IEventInfo& info,
void InvokeEvent(Reporter* reporter, const IEventInfo& info,
list<shared_ptr<AbstractItem>> notiList) {
-
noti_ex_item_h* noti_list =
(noti_ex_item_h*)calloc(notiList.size(), sizeof(noti_ex_item_h));
if (noti_list == nullptr) {
private:
unique_ptr<ReporterCallbackInfo> cb_;
};
-}
+
+} // namespace
extern "C" EXPORT_API int noti_ex_action_app_control_create(
noti_ex_action_h *handle, app_control_h app_control,
dynamic_pointer_cast<TextItem>(static_cast<Handle*>(text)->GetPtr()),
dynamic_pointer_cast<ImageItem>(static_cast<Handle*>(image)->GetPtr()),
dynamic_pointer_cast<TimeItem>(static_cast<Handle*>(time)->GetPtr()),
- static_cast<ChatMessageItem::Type>((int)message_type));
+ static_cast<ChatMessageItem::Type>(message_type));
if (p == nullptr) {
LOGE("Out-of-memory");
return NOTI_EX_ERROR_OUT_OF_MEMORY;
extern "C" EXPORT_API int noti_ex_action_execute(noti_ex_action_h handle,
noti_ex_item_h item) {
- if (handle == nullptr || item==nullptr) {
+ if (handle == nullptr || item == nullptr) {
LOGE("Invalid parameter");
return NOTI_EX_ERROR_INVALID_PARAMETER;
}
Bundle TimeItem::Serialize() const {
Bundle b;
struct tm timeinfo;
- char buf[80] = {0,};
+ char buf[80] = {0, };
b = AbstractItem::Serialize();
- //timt_t to tm
+ // timt_t to tm
localtime_r(&impl_->time_, &timeinfo);
- //tm to str
+ // tm to str
strftime (buf, sizeof(buf), "%s", &timeinfo);
b.Add(TIME_KEY, std::string(buf));
AbstractItem::Deserialize(b);
time_s = b.GetString(TIME_KEY);
- //str to tm
+ // str to tm
strptime(time_s.c_str(), "%s", &timeinfo);
- //tm to time_t
+ // tm to time_t
impl_->time_ = mktime(&timeinfo);
}
* limitations under the License.
*/
+#include <string>
+#include <list>
+
#include "notification-ex/abstract_item.h"
#include "notification-ex/visibility_action.h"
#include "notification-ex/visibility_action_implementation.h"
id, visible));
}
-} //namespace item
-} //namespace notification
+} // namespace item
+} // namespace notification