Add Serialize/Deserialize for AbstractItem private/for/tizen
authorSukHyung, Kang <shine.kang@samsung.com>
Fri, 8 Mar 2019 07:57:43 +0000 (16:57 +0900)
committerSukHyung, Kang <shine.kang@samsung.com>
Fri, 8 Mar 2019 07:57:43 +0000 (16:57 +0900)
Change-Id: I2dbe4f957d6c5d55722eb1c339e10782fc5a7e52
Signed-off-by: SukHyung, Kang <shine.kang@samsung.com>
notification-ex/abstract_item.cc

index c6397a21fb72a2e1340855798dea35eeda4bb281..2da1b9f5e1ea9e409f0afea1f3c9b3994cd89575 100644 (file)
 
 #define ABSTRACT_ITEM_TYPE_KEY "__ABSTRACT_ITEM_TYPE_KEY__"
 #define ABSTRACT_ITEM_ID_KEY "__ABSTRACT_ITEM_ID_KEY__"
+#define ABSTRACT_ITEM_CHANNEL_KEY "__ABSTRACT_ITEM_CHANNEL_KEY__"
+#define ABSTRACT_ITEM_VERSION_KEY "__ABSTRACT_ITEM_VERSION_KEY__"
+#define ABSTRACT_ITEM_HIDE_TIME_KEY "__ABSTRACT_ITEM_HIDE_TIME_KEY__"
+#define ABSTRACT_ITEM_DELETE_TIME_KEY "__ABSTRACT_ITEM_DELETE_TIME_KEY__"
+#define ABSTRACT_ITEM_CAN_RECEIVE_KEY "__ABSTRACT_ITEM_CAN_RECEIVE_KEY__"
+#define ABSTRACT_ITEM_SOUND_PATH_KEY "__ABSTRACT_ITEM_SOUND_PATH_KEY__"
+#define ABSTRACT_ITEM_VIBRATION_PATH_KEY "__ABSTRACT_ITEM_VIBRATION_PATH_KEY__"
+#define ABSTRACT_ITEM_POLICY_KEY "__ABSTRACT_ITEM_POLICY_KEY__"
+#define ABSTRACT_ITEM_VISIBLE_KEY "__ABSTRACT_ITEM_VISIBLE_KEY__"
+#define ABSTRACT_ITEM_ENABLE_KEY "__ABSTRACT_ITEM_ENABLE_KEY__"
+#define ABSTRACT_ITEM_TRUE "TRUE"
+#define ABSTRACT_ITEM_FALSE "FALSE"
 
 using namespace std;
 namespace notification {
@@ -62,8 +74,36 @@ AbstractItem::~AbstractItem() = default;
 
 Bundle AbstractItem::Serialize() {
   Bundle b;
+
+  if (!impl_->id_.empty())
+    b.Add(ABSTRACT_ITEM_ID_KEY, impl_->id_);
+
+  if (!impl_->channel_.empty())
+    b.Add(ABSTRACT_ITEM_CHANNEL_KEY, impl_->channel_);
+
   b.Add(ABSTRACT_ITEM_TYPE_KEY, to_string((int)impl_->type_));
-  b.Add(ABSTRACT_ITEM_ID_KEY, impl_->id_);
+
+  b.Add(ABSTRACT_ITEM_VERSION_KEY, to_string((int)impl_->version_));
+  b.Add(ABSTRACT_ITEM_HIDE_TIME_KEY, to_string((int)impl_->hide_time_));
+  b.Add(ABSTRACT_ITEM_DELETE_TIME_KEY, to_string((int)impl_->delete_time_));
+
+  if (!impl_->can_receive_.empty())
+    b.Add(ABSTRACT_ITEM_CAN_RECEIVE_KEY, impl_->can_receive_);
+
+  if (!impl_->sound_path_.empty())
+    b.Add(ABSTRACT_ITEM_SOUND_PATH_KEY, impl_->sound_path_);
+
+  if (!impl_->vibration_path_.empty())
+    b.Add(ABSTRACT_ITEM_VIBRATION_PATH_KEY, impl_->vibration_path_);
+
+  b.Add(ABSTRACT_ITEM_VISIBLE_KEY, impl_->visible_ ?
+      ABSTRACT_ITEM_TRUE : ABSTRACT_ITEM_FALSE);
+
+  b.Add(ABSTRACT_ITEM_ENABLE_KEY, impl_->enable_ ?
+      ABSTRACT_ITEM_TRUE : ABSTRACT_ITEM_FALSE);
+
+  b.Add(ABSTRACT_ITEM_POLICY_KEY, to_string((int)impl_->policy_));
+
   return b;
 }
 
@@ -75,6 +115,22 @@ void AbstractItem::Deserialize(Bundle 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));
+
+  impl_->channel_ = b.GetString(ABSTRACT_ITEM_CHANNEL_KEY);
+  impl_->version_ = stoi(b.GetString(ABSTRACT_ITEM_VERSION_KEY));
+  impl_->hide_time_ = stoi(b.GetString(ABSTRACT_ITEM_HIDE_TIME_KEY));
+  impl_->delete_time_ = stoi(b.GetString(ABSTRACT_ITEM_DELETE_TIME_KEY));
+  impl_->can_receive_ = b.GetString(ABSTRACT_ITEM_CAN_RECEIVE_KEY);
+  impl_->sound_path_ = b.GetString(ABSTRACT_ITEM_SOUND_PATH_KEY);
+  impl_->vibration_path_ = b.GetString(ABSTRACT_ITEM_VIBRATION_PATH_KEY);
+
+  string policy_str = b.GetString(ABSTRACT_ITEM_POLICY_KEY);
+
+  impl_->policy_ = static_cast<Policy>(stoi(policy_str));
+
+  impl_->visible_ = (b.GetString(ABSTRACT_ITEM_VISIBLE_KEY) == ABSTRACT_ITEM_TRUE);
+
+  impl_->enable_ = (b.GetString(ABSTRACT_ITEM_ENABLE_KEY) == ABSTRACT_ITEM_TRUE);
 }
 
 string AbstractItem::GetId() const {