summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMyungKi Lee <mk5004.lee@samsung.com>2019-04-25 01:09:30 +0000
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>2019-04-25 01:09:30 +0000
commit62c6308d448aca69ecce3a2b0f885b61809d1f5b (patch)
tree59687c26abb458fe6d2d0115e723dab744940449
parent0c89997fd531302e11a737c5277ac1f74f61280f (diff)
parent634a04ab57131bb52833f469bb2f030f841bf687 (diff)
downloadnotification-62c6308d448aca69ecce3a2b0f885b61809d1f5b.tar.gz
notification-62c6308d448aca69ecce3a2b0f885b61809d1f5b.tar.bz2
notification-62c6308d448aca69ecce3a2b0f885b61809d1f5b.zip
Merge "Check c++ coding style" into tizen
-rw-r--r--notification-ex/abstract_action.cc2
-rw-r--r--notification-ex/abstract_item.cc7
-rw-r--r--notification-ex/app_control_action.cc6
-rw-r--r--notification-ex/chat_message_item.cc4
-rw-r--r--notification-ex/db_manager.cc1
-rw-r--r--notification-ex/dbus_event_listener.cc3
-rw-r--r--notification-ex/dbus_sender.cc1
-rw-r--r--notification-ex/default_item_factory.cc2
-rw-r--r--notification-ex/event_info.cc12
-rw-r--r--notification-ex/group_item.cc18
-rw-r--r--notification-ex/icon_text_item.cc2
-rw-r--r--notification-ex/manager.cc4
-rw-r--r--notification-ex/stub.cc16
-rw-r--r--notification-ex/time_item.cc10
-rw-r--r--notification-ex/visibility_action.cc7
15 files changed, 52 insertions, 43 deletions
diff --git a/notification-ex/abstract_action.cc b/notification-ex/abstract_action.cc
index e37ee52..82b388b 100644
--- a/notification-ex/abstract_action.cc
+++ b/notification-ex/abstract_action.cc
@@ -61,7 +61,7 @@ Bundle AbstractAction::Serialize() const {
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;
}
diff --git a/notification-ex/abstract_item.cc b/notification-ex/abstract_item.cc
index 359680a..f5206b9 100644
--- a/notification-ex/abstract_item.cc
+++ b/notification-ex/abstract_item.cc
@@ -20,6 +20,7 @@
#include <memory>
#include <algorithm>
+#include <vector>
#include "notification-ex/exception.h"
#include "notification-ex/abstract_item.h"
@@ -128,7 +129,7 @@ AbstractItem::~AbstractItem() = default;
Bundle AbstractItem::Serialize() const {
Bundle b;
struct tm timeinfo;
- char buf[80] = {0,};
+ char buf[80] = {0, };
if (impl_->uid_ == 0)
impl_->uid_ = getuid();
@@ -260,9 +261,9 @@ void AbstractItem::Deserialize(Bundle b) {
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) {
diff --git a/notification-ex/app_control_action.cc b/notification-ex/app_control_action.cc
index d58c8d7..2aa94b6 100644
--- a/notification-ex/app_control_action.cc
+++ b/notification-ex/app_control_action.cc
@@ -17,6 +17,8 @@
#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"
@@ -143,5 +145,5 @@ app_control_h AppControlAction::GetAppControl() const {
return impl_->control_;
}
-} //namespace item
-} //namespace notification
+} // namespace item
+} // namespace notification
diff --git a/notification-ex/chat_message_item.cc b/notification-ex/chat_message_item.cc
index 11e5c4f..ae02fd7 100644
--- a/notification-ex/chat_message_item.cc
+++ b/notification-ex/chat_message_item.cc
@@ -94,7 +94,7 @@ Bundle ChatMessageItem::Serialize() const {
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;
}
@@ -155,4 +155,4 @@ ChatMessageItem::~ChatMessageItem() = default;
ChatMessageItem::Impl::~Impl() = default;
} // namespace item
-} // namespace notification_ex
+} // namespace notification
diff --git a/notification-ex/db_manager.cc b/notification-ex/db_manager.cc
index d238706..d2bef28 100644
--- a/notification-ex/db_manager.cc
+++ b/notification-ex/db_manager.cc
@@ -20,6 +20,7 @@
#include <vconf.h>
#include <pkgmgr-info.h>
#include <tzplatform_config.h>
+
#include <string.h>
#include <list>
#include <map>
diff --git a/notification-ex/dbus_event_listener.cc b/notification-ex/dbus_event_listener.cc
index cc03c2c..65962cb 100644
--- a/notification-ex/dbus_event_listener.cc
+++ b/notification-ex/dbus_event_listener.cc
@@ -18,6 +18,9 @@
#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"
diff --git a/notification-ex/dbus_sender.cc b/notification-ex/dbus_sender.cc
index 2195235..0fc8dab 100644
--- a/notification-ex/dbus_sender.cc
+++ b/notification-ex/dbus_sender.cc
@@ -18,6 +18,7 @@
#include <glib.h>
#include <unistd.h>
+#include <string>
#include <list>
#include "notification-ex/dbus_connection_manager.h"
diff --git a/notification-ex/default_item_factory.cc b/notification-ex/default_item_factory.cc
index 8fa7902..31917f8 100644
--- a/notification-ex/default_item_factory.cc
+++ b/notification-ex/default_item_factory.cc
@@ -48,7 +48,7 @@ unique_ptr<AbstractItem> DefaultItemFactory::CreateItem(int type) {
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 :
diff --git a/notification-ex/event_info.cc b/notification-ex/event_info.cc
index ded0ecf..80fe34a 100644
--- a/notification-ex/event_info.cc
+++ b/notification-ex/event_info.cc
@@ -59,22 +59,22 @@ EventInfo::Impl::Impl(EventInfo* parent, int type, std::string owner,
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:
@@ -92,11 +92,11 @@ string EventInfo::GetString(int type) {
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(
diff --git a/notification-ex/group_item.cc b/notification-ex/group_item.cc
index 430a6d1..2f62075 100644
--- a/notification-ex/group_item.cc
+++ b/notification-ex/group_item.cc
@@ -76,7 +76,7 @@ Bundle GroupItem::Serialize() const {
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);
@@ -153,14 +153,14 @@ bool GroupItem::IsVertical() {
}
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
diff --git a/notification-ex/icon_text_item.cc b/notification-ex/icon_text_item.cc
index 813a230..9718d4e 100644
--- a/notification-ex/icon_text_item.cc
+++ b/notification-ex/icon_text_item.cc
@@ -91,4 +91,4 @@ IconTextItem::~IconTextItem() = default;
IconTextItem::Impl::~Impl() = default;
} // namespace item
-} // namespace notification_ex
+} // namespace notification
diff --git a/notification-ex/manager.cc b/notification-ex/manager.cc
index e5af0fc..df4847e 100644
--- a/notification-ex/manager.cc
+++ b/notification-ex/manager.cc
@@ -98,7 +98,7 @@ int Manager::GetCount() const {
}
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);
}
@@ -156,7 +156,7 @@ void Manager::OnEvent(const IEventInfo& info, list<Bundle> serialized) {
return;
}
- switch(type) {
+ switch (type) {
case EventInfo::Post: {
list<shared_ptr<item::AbstractItem>> added;
for (auto& i : serialized) {
diff --git a/notification-ex/stub.cc b/notification-ex/stub.cc
index 579d421..13056f8 100644
--- a/notification-ex/stub.cc
+++ b/notification-ex/stub.cc
@@ -70,10 +70,11 @@ using namespace notification::item;
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 {
@@ -96,7 +97,6 @@ class Handle {
private:
item::AbstractItem* ref_;
std::shared_ptr<item::AbstractItem> ptr_;
-
};
class ManagerCallbackInfo {
@@ -111,7 +111,6 @@ 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) {
@@ -169,7 +168,6 @@ class ManagerStub : public Manager {
void OnAdd(const IEventInfo& info,
list<shared_ptr<AbstractItem>> addedItem) override {
cb_->InvokeAdded(this, info, addedItem);
-
}
void OnUpdate(const IEventInfo& info,
@@ -211,7 +209,6 @@ class ReporterCallbackInfo {
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) {
@@ -271,7 +268,8 @@ class ReporterStub : public Reporter {
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,
@@ -385,7 +383,7 @@ extern "C" EXPORT_API int noti_ex_item_chat_message_create(
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;
@@ -1427,7 +1425,7 @@ extern "C" EXPORT_API int noti_ex_action_is_local(noti_ex_action_h handle,
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;
}
diff --git a/notification-ex/time_item.cc b/notification-ex/time_item.cc
index b57b9f4..719eb50 100644
--- a/notification-ex/time_item.cc
+++ b/notification-ex/time_item.cc
@@ -60,13 +60,13 @@ int TimeItem::GetType() const {
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));
@@ -80,9 +80,9 @@ void TimeItem::Deserialize(Bundle b) {
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);
}
diff --git a/notification-ex/visibility_action.cc b/notification-ex/visibility_action.cc
index f274eb2..f354d98 100644
--- a/notification-ex/visibility_action.cc
+++ b/notification-ex/visibility_action.cc
@@ -14,6 +14,9 @@
* 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"
@@ -124,5 +127,5 @@ void VisibilityAction::SetVisibility(std::string id, bool visible) {
id, visible));
}
-} //namespace item
-} //namespace notification
+} // namespace item
+} // namespace notification