#define ABSTRACT_ACTION_IS_LOCAL_KEY "__ABSTRACT_ACTION_IS_LOCAL_KEY__"
#define ABSTRACT_ACTION_EXTRA_KEY "__ABSTRACT_ACTION_EXTRA_KEY__"
-using namespace tizen_base;
-
namespace notification {
namespace item {
AbstractAction::AbstractAction(bool isLocal)
#include <memory>
#include <string>
-#include <bundle_cpp.h>
+#include "notification-ex/ex_bundle.h"
#ifndef EXPORT_API
#define EXPORT_API __attribute__((visibility("default")))
* @param[in] b Bundle type data
* @return The type of action
*/
- static int GetType(tizen_base::Bundle b);
+ static int GetType(Bundle b);
/**
* @brief Serialize the data of AbstractAction.
* @since_tizen 5.5
* @return Bundle type data
*/
- virtual tizen_base::Bundle Serialize() const = 0;
+ virtual Bundle Serialize() const = 0;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- virtual void Deserialize(tizen_base::Bundle b) = 0;
+ virtual void Deserialize(Bundle b) = 0;
/**
* @brief Gets whether local or not.
#define ABSTRACT_ITEM_TRUE "TRUE"
using namespace std;
-using namespace tizen_base;
namespace notification {
namespace item {
#define NOTIFICATION_EX_ABSTRACT_ITEM_H_
#include <time.h>
-#include <bundle_cpp.h>
#include <memory>
#include <string>
#include <list>
#include "notification-ex/abstract_action.h"
+#include "notification-ex/ex_bundle.h"
#include "notification-ex/iitem_info.h"
#ifndef EXPORT_API
* @since_tizen 5.5
* @return Bundle type data
*/
- virtual tizen_base::Bundle Serialize() const = 0;
+ virtual Bundle Serialize() const = 0;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- virtual void Deserialize(tizen_base::Bundle b) = 0;
+ virtual void Deserialize(Bundle b) = 0;
/**
* @brief Finds the AbstractItem using by notification item id.
* @since_tizen 5.5
* @return The type of notification item
*/
- static int GetType(tizen_base::Bundle b);
+ static int GetType(Bundle b);
/**
* @brief Gets the path of shared file location.
*/
#include <dlog.h>
-#include <bundle_cpp.h>
#include <memory>
namespace notification {
namespace item {
-std::shared_ptr<AbstractAction> ActionInflator::Create(tizen_base::Bundle b) {
+std::shared_ptr<AbstractAction> ActionInflator::Create(Bundle b) {
std::shared_ptr<AbstractAction> action =
FactoryManager::GetInst().CreateAction(AbstractAction::GetType(b));
action.get()->Deserialize(b);
* @since_tizen 5.5
* @param[in] b Bundle type data
*/
- static std::shared_ptr<AbstractAction> Create(tizen_base::Bundle b);
+ static std::shared_ptr<AbstractAction> Create(Bundle b);
};
} // namespace item
#define LOG_TAG "NOTIFICATION_EX"
#define APPCONTROL_ACTION_KEY "__APPCONTROL_ACTION_KEY__"
-using namespace tizen_base;
-
namespace notification {
namespace item {
app_control_export_as_bundle(impl_->control_, &control_b);
if (control_b == NULL) {
LOGE("failed to get bundle from app_control");
- return {};
+ return nullptr;
}
bundle_encode(control_b, &control_raw, &len);
if (len <= 0) {
LOGE("bundle encode failed");
- return {};
+ return nullptr;
}
b = AbstractAction::Serialize();
* @since_tizen 5.5
* @return Bundle type data
*/
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- void Deserialize(tizen_base::Bundle b) override;
+ void Deserialize(Bundle b) override;
/**
* @brief Gets whether local or not.
#define BUTTON_TITLE_KEY "__BUTTON_TITLE_KEY__"
using namespace std;
-using namespace tizen_base;
-
namespace notification {
namespace item {
* @since_tizen 5.5
* @return Bundle type data
*/
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- void Deserialize(tizen_base::Bundle b) override;
+ void Deserialize(Bundle b) override;
/**
* @brief Finds the AbstractItem using by notification item id.
#define CHATMESSAGE_TIME_KEY "__CHATMESSAGE_TIME_KEY__"
#define CHATMESSAGE_TYPE_KEY "__CHATMESSAGE_TYPE_KEY__"
-using namespace tizen_base;
-
namespace notification {
namespace item {
* @since_tizen 5.5
* @return Bundle type data
*/
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- void Deserialize(tizen_base::Bundle b) override;
+ void Deserialize(Bundle b) override;
/**
* @brief Finds the AbstractItem using by notification item id.
#define CHECKBOX_TITLE_KEY "__CHECKBOX_TITLE_KEY__"
#define CHECKBOX_CHECKED_KEY "__CHECKBOX_CHECKED_KEY__"
-using namespace tizen_base;
-
namespace notification {
namespace item {
* @since_tizen 5.5
* @return Bundle type data
*/
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- void Deserialize(tizen_base::Bundle b) override;
+ void Deserialize(Bundle b) override;
/**
* @brief Finds the AbstractItem using by notification item id.
#define NOTI_LIMIT 100
using namespace std;
-using namespace tizen_base;
using namespace notification::item;
namespace notification {
#include <string>
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
+#include "notification-ex/ex_bundle.h"
namespace notification {
#define MAX_PACKAGE_STR_SIZE 512
using namespace std;
-using namespace tizen_base;
-
namespace notification {
DBusEventListener::DBusEventListener(string path)
void RegisterObserver(IEventObserver* observer) override;
void UnRegisterObserver(IEventObserver* observer) override;
void NotifyObserver(
- const IEventInfo& info, std::list<tizen_base::Bundle> serialized) override;
- std::list<tizen_base::Bundle> NotifyObserver(const IEventInfo& info) override;
+ const IEventInfo& info, std::list<Bundle> serialized) override;
+ std::list<Bundle> NotifyObserver(const IEventInfo& info) override;
private:
class Impl;
#define MAX_PACKAGE_STR_SIZE 512
using namespace std;
-using namespace tizen_base;
namespace notification {
DBusSender::DBusSender(string path) : impl_(new Impl(this, path)) {
#ifndef NOTIFICATION_EX_DBUS_SENDER_H_
#define NOTIFICATION_EX_DBUS_SENDER_H_
-#include <bundle_cpp.h>
-
+#include "notification-ex/ex_bundle.h"
#include "notification-ex/event_sender_interface.h"
#include "notification-ex/ievent_info.h"
public:
DBusSender(std::string path);
virtual ~DBusSender();
- void Notify(const IEventInfo& info, std::list<tizen_base::Bundle> serialized,
+ void Notify(const IEventInfo& info, std::list<Bundle> serialized,
std::string dest_appid = "") override;
- std::list<tizen_base::Bundle> Request(const IEventInfo& info) override;
+ std::list<Bundle> Request(const IEventInfo& info) override;
private:
class Impl;
#ifndef NOTIFICATION_EX_DBUS_SENDER_IMPLEMENTATION_H_
#define NOTIFICATION_EX_DBUS_SENDER_IMPLEMENTATION_H_
-#include <bundle_cpp.h>
-
#include <string>
#include <memory>
#include <list>
std::string GetBusName(
std::string appid, std::string dest_appid) const;
bool EmitSignal(std::string bus_name, std::string signal_name, GVariant* data);
- GDBusMessage* MethodCall(std::string appid, std::string method_name,
- tizen_base::Bundle serialized);
+ GDBusMessage* MethodCall(std::string appid, std::string method_name, Bundle serialized);
std::string path_;
DBusSender* parent_;
};
#define ENTRY_TEXT_KEY "__ENTRY_TEXT_KEY__"
#define ENTRY_LIMIT_KEY "__ENTRY_LIMIT_KEY__"
-using namespace tizen_base;
-
namespace notification {
namespace item {
* @since_tizen 5.5
* @return Bundle type data
*/
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- void Deserialize(tizen_base::Bundle b) override;
+ void Deserialize(Bundle b) override;
/**
* @brief Finds the AbstractItem using by notification item id.
#define NOTIFICATION_EX_EVENT_ERROR_KEY "__NOTIFICATION_EX_EVENT_ERROR_KEY__"
using namespace std;
-using namespace tizen_base;
namespace notification {
EventInfo::EventInfo(int type, std::string owner, std::string channel,
#ifndef NOTIFICATION_EX_EVENT_INFO_INTERNAL_H_
#define NOTIFICATION_EX_EVENT_INFO_INTERNAL_H_
-#include <bundle_cpp.h>
-
#include <string>
#include <list>
#include "notification-ex/common.h"
+#include "notification-ex/ex_bundle.h"
#include "notification-ex/ievent_info_internal.h"
#ifndef EXPORT_API
public:
EventInfo(int type, std::string owner, std::string channel = "",
std::string item_id = "");
- EventInfo(tizen_base::Bundle serialized);
+ EventInfo(Bundle serialized);
virtual ~EventInfo();
uid_t GetUid() const override;
void SetUid(uid_t uid) override;
std::string GetChannel() const override;
std::string GetItemId() const override;
int GetRequestId() const override;
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
static std::string GetString(int type);
private:
virtual ~IEventListener() = default;
virtual void RegisterObserver(IEventObserver* observer) = 0;
virtual void UnRegisterObserver(IEventObserver* observer) = 0;
- virtual void NotifyObserver(const IEventInfo& info,
- std::list<tizen_base::Bundle> serialized) = 0;
- virtual std::list<tizen_base::Bundle> NotifyObserver(const IEventInfo& info) = 0;
+ virtual void NotifyObserver(const IEventInfo& info, std::list<Bundle> serialized) = 0;
+ virtual std::list<Bundle> NotifyObserver(const IEventInfo& info) = 0;
};
} // namespace notification
#ifndef NOTIFICATION_EX_OBSERVER_INTERFACE_H_
#define NOTIFICATION_EX_OBSERVER_INTERFACE_H_
-#include <bundle_cpp.h>
-
#include <list>
+#include "notification-ex/ex_bundle.h"
#include "notification-ex/ievent_info.h"
#ifndef EXPORT_API
class EXPORT_API IEventObserver {
public:
virtual ~IEventObserver() = default;
- virtual void OnEvent(const IEventInfo& info,
- std::list<tizen_base::Bundle> serialized) = 0;
- virtual std::list<tizen_base::Bundle> OnRequest(const IEventInfo& info) = 0;
+ virtual void OnEvent(const IEventInfo& info, std::list<Bundle> serialized) = 0;
+ virtual std::list<Bundle> OnRequest(const IEventInfo& info) = 0;
};
} // namespace notification
#ifndef NOTIFICATION_EX_EVENT_SENDER_INTERFACE_H_
#define NOTIFICATION_EX_EVENT_SENDER_INTERFACE_H_
-#include <bundle_cpp.h>
-
#include <list>
+#include "notification-ex/ex_bundle.h"
#include "notification-ex/ievent_info.h"
#ifndef EXPORT_API
class EXPORT_API IEventSender {
public:
- virtual void Notify(const IEventInfo& info,
- std::list<tizen_base::Bundle> serialized,
+ virtual void Notify(const IEventInfo& info, std::list<Bundle> serialized,
std::string dest_appid = "") = 0;
- virtual std::list<tizen_base::Bundle> Request(const IEventInfo &info) = 0;
+ virtual std::list<Bundle> Request(const IEventInfo &info) = 0;
};
} // namespace notification
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NOTIFICATION_EX_BUNDLE_H_
+#define NOTIFICATION_EX_BUNDLE_H_
+
+#include <bundle.h>
+
+#include <string>
+#include <vector>
+#include <memory>
+#include <cstdio>
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace notification {
+class EXPORT_API Bundle final {
+ public:
+ using BundleRaw =
+ std::pair<std::unique_ptr<bundle_raw, decltype(std::free)*>, int>;
+
+ class KeyInfo final {
+ public:
+ KeyInfo(const bundle_keyval_t* handle, std::string name)
+ : handle_(handle), name_(std::move(name)) {}
+
+ bundle_type GetType() const {
+ return static_cast<bundle_type>(
+ bundle_keyval_get_type(const_cast<bundle_keyval_t*>(handle_)));
+ }
+
+ bool IsArray() const {
+ return bundle_keyval_type_is_array(const_cast<bundle_keyval_t*>(handle_));
+ }
+
+ const std::string& GetName() const {
+ return name_;
+ }
+
+ private:
+ const bundle_keyval_t* handle_;
+ std::string name_;
+ };
+
+ Bundle() {
+ handle_ = bundle_create();
+ }
+
+ Bundle(BundleRaw raw) {
+ handle_ = bundle_decode(raw.first.get(), raw.second);
+ }
+
+
+ Bundle(const std::string& raw) {
+ handle_ = bundle_decode(reinterpret_cast<const bundle_raw*>(raw.c_str()),
+ raw.length());
+ }
+
+ Bundle(bundle* b, bool copy = true, bool own = true)
+ : own_(own), copy_(copy) {
+ if (!copy_)
+ handle_ = b;
+ else
+ handle_ = bundle_dup(b);
+ }
+
+ ~Bundle() {
+ if (handle_ && (own_ || copy_))
+ bundle_free(handle_);
+ }
+
+ Bundle(const Bundle& b) {
+ handle_ = bundle_dup(b.handle_);
+ }
+
+ Bundle& operator = (const Bundle& b) {
+ handle_ = bundle_dup(b.handle_);
+ return *this;
+ }
+
+ Bundle(Bundle&& b) noexcept {
+ handle_ = b.handle_;
+ b.handle_ = nullptr;
+ }
+
+ Bundle& operator = (Bundle&& b) noexcept {
+ handle_ = b.handle_;
+ b.handle_ = nullptr;
+ return *this;
+ }
+
+ std::vector<KeyInfo> GetKeys() {
+ std::vector<KeyInfo> v;
+
+ bundle_foreach(handle_, [](const char *key, const int type,
+ const bundle_keyval_t *kv, void *user_data) {
+ auto* v = static_cast<std::vector<KeyInfo>*>(user_data);
+ v->emplace_back(kv, key);
+ }, &v);
+
+ return v;
+ }
+
+ int Add(const std::string& key, const std::string& val) {
+ return bundle_add_str(handle_, key.c_str(), val.c_str());
+ }
+
+ int Add(const std::string& key, const std::vector<std::string>& val) {
+ std::vector<const char*> v;
+ for (auto& i : val) {
+ v.push_back(i.c_str());
+ }
+
+ return bundle_add_str_array(handle_, key.c_str(), v.data(), v.size());
+ }
+
+ int Add(const std::string& key, const std::vector<unsigned char>& val) {
+ return bundle_add_byte(handle_, key.c_str(), val.data(), val.size());
+ }
+
+ int Merge(Bundle& b) {
+ std::vector<KeyInfo> keys = b.GetKeys();
+ for (auto& k : keys) {
+ int ret;
+ if (k.IsArray())
+ ret = Add(k.GetName(), b.GetStringArray(k.GetName()));
+ else
+ ret = Add(k.GetName(), b.GetString(k.GetName()));
+ if (ret != 0)
+ return ret;
+ }
+ return 0;
+ }
+
+ int Delete(const std::string& key) {
+ return bundle_del(handle_, key.c_str());
+ }
+
+ std::string GetString(const std::string& key) const {
+ char* str = nullptr;
+ bundle_get_str(handle_, key.c_str(), &str);
+
+ if (!str)
+ return "";
+
+ return std::string(str);
+ }
+
+ std::vector<std::string> GetStringArray(const std::string& key) const {
+ std::vector<std::string> v;
+
+ const char** str_array = nullptr;
+ int len = 0;
+
+ str_array = bundle_get_str_array(handle_, key.c_str(), &len);
+
+ for (int i = 0; i < len; i++) {
+ v.emplace_back(str_array[i]);
+ }
+
+ return v;
+ }
+
+ std::vector<unsigned char> GetByte(const std::string& key) const {
+ size_t size;
+ unsigned char* bytes = nullptr;
+ bundle_get_byte(handle_, key.c_str(),
+ reinterpret_cast<void**>(&bytes), &size);
+ return std::vector<unsigned char>(bytes, bytes + size);
+ }
+
+ BundleRaw ToRaw() {
+ bundle_raw* raw = nullptr;
+ int len = 0;
+ bundle_encode(handle_, &raw, &len);
+
+ return BundleRaw(
+ std::unique_ptr<bundle_raw, decltype(std::free)*>(raw, std::free), len);
+ }
+
+ int GetCount() const {
+ return bundle_get_count(handle_);
+ }
+
+ bundle_type GetType(const std::string& key) const {
+ return static_cast<bundle_type>(bundle_get_type(handle_, key.c_str()));
+ }
+
+ bundle* GetHandle() const {
+ return handle_;
+ }
+
+ bundle* Detach() {
+ auto* h = handle_;
+ handle_ = nullptr;
+ return h;
+ }
+
+ private:
+ bundle* handle_;
+ bool own_ = true;
+ bool copy_ = true;
+};
+
+} // namespace notification
+
+#endif // NOTIFICATION_EX_BUNDLE_H_
#define GROUP_APP_LABEL_KEY "__GROUP_APP_LABEL_KEY__"
using namespace std;
-using namespace tizen_base;
namespace notification {
namespace item {
* @since_tizen 5.5
* @return Bundle type data
*/
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- void Deserialize(tizen_base::Bundle b) override;
+ void Deserialize(Bundle b) override;
/**
* @brief Finds the AbstractItem using by notification item id.
#define ICONTEXT_PATH_KEY "__ICONTEXT_PATH_KEY__"
#define ICONTEXT_TITLE_KEY "__ICONTEXT_TITLE_KEY__"
-using namespace tizen_base;
-
namespace notification {
namespace item {
* @since_tizen 5.5
* @return Bundle type data
*/
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- void Deserialize(tizen_base::Bundle b) override;
+ void Deserialize(Bundle b) override;
/**
* @brief Finds the AbstractItem using by notification item id.
#ifndef NOTIFICATION_EX_IEVENT_INFO_H_
#define NOTIFICATION_EX_IEVENT_INFO_H_
-#include <bundle_cpp.h>
+#include "notification-ex/ex_bundle.h"
namespace notification {
virtual std::string GetChannel() const = 0;
virtual std::string GetItemId() const = 0;
virtual int GetRequestId() const = 0;
- virtual tizen_base::Bundle Serialize() const = 0;
+ virtual Bundle Serialize() const = 0;
};
} // namespace notification
#define LOG_TAG "NOTIFICATION_EX"
#define IMAGE_PATH_KEY "__IMAGE_PATH_KEY__"
-using namespace tizen_base;
-
namespace notification {
namespace item {
* @since_tizen 5.5
* @return Bundle type data
*/
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- void Deserialize(tizen_base::Bundle b) override;
+ void Deserialize(Bundle b) override;
/**
* @brief Finds the AbstractItem using by notification item id.
#define INPUT_SELECTOR_CONTENTS_KEY "__INPUT_SELECTOR_CONTENTS_KEY__"
using namespace std;
-using namespace tizen_base;
-
namespace notification {
namespace item {
* @since_tizen 5.5
* @return Bundle type data
*/
- virtual tizen_base::Bundle Serialize() const override;
+ virtual Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- virtual void Deserialize(tizen_base::Bundle b) override;
+ virtual void Deserialize(Bundle b) override;
/**
* @brief Finds the AbstractItem using by notification item id.
namespace notification {
namespace item {
-unique_ptr<AbstractItem> ItemInflator::Create(tizen_base::Bundle b) {
+unique_ptr<AbstractItem> ItemInflator::Create(Bundle b) {
unique_ptr<AbstractItem> item =
FactoryManager::GetInst().CreateItem(AbstractItem::GetType(b));
item.get()->Deserialize(b);
* @since_tizen 5.5
* @param[in] b Bundle type data
*/
- static std::unique_ptr<AbstractItem> Create(tizen_base::Bundle b);
+ static std::unique_ptr<AbstractItem> Create(Bundle b);
};
} // namespace item
#define NOTIFICATION_EX_MANAGER_OBJECT_PATH "/org/tizen/notification_ex_manager"
using namespace std;
-using namespace tizen_base;
using namespace notification::item;
namespace notification {
int Hide(std::shared_ptr<item::AbstractItem> noti);
std::unique_ptr<item::AbstractItem> FindByRootID(std::string id);
int SendEvent(const IEventInfo& info, std::shared_ptr<item::AbstractItem> noti);
- void OnEvent(const IEventInfo& info,
- std::list<tizen_base::Bundle> serialized) override;
- std::list<tizen_base::Bundle> OnRequest(const IEventInfo& info) override;
+ void OnEvent(const IEventInfo& info, std::list<Bundle> serialized) override;
+ std::list<Bundle> OnRequest(const IEventInfo& info) override;
void SendError(const IEventInfo& info, NotificationError error);
int GetCount() const;
static std::string GetPath();
MockSender();
virtual ~MockSender();
- void Notify(tizen_base::Bundle serialized) override;
+ void Notify(Bundle serialized) override;
};
} // namespace notification
#define LOG_TAG "NOTIFICATION_EX"
using namespace std;
-using namespace tizen_base;
-
namespace notification {
namespace item {
* @since_tizen 5.5
* @return Bundle type data
*/
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- void Deserialize(tizen_base::Bundle b) override;
+ void Deserialize(Bundle b) override;
/**
* @brief Finds the AbstractItem using by notification item id.
#define PROGRESS_MAX_KEY "__PROGRESS_MAX_KEY__"
using namespace std;
-using namespace tizen_base;
-
namespace notification {
namespace item {
* @since_tizen 5.5
* @return Bundle type data
*/
- virtual tizen_base::Bundle Serialize() const override;
+ virtual Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- virtual void Deserialize(tizen_base::Bundle b) override;
+ virtual void Deserialize(Bundle b) override;
/**
* @brief Finds the AbstractItem using by notification item id.
#define NOTIFICATION_EX_REPORTER_OBJECT_PATH "/org/tizen/notification_ex_reporter"
using namespace std;
-using namespace tizen_base;
using namespace notification::item;
namespace notification {
virtual std::list<std::shared_ptr<item::AbstractItem>> OnRequestEvent(
const IEventInfo& info);
virtual void OnError(NotificationError error, int requestId);
- void OnEvent(const IEventInfo& info,
- std::list<tizen_base::Bundle> serialized) override;
- std::list<tizen_base::Bundle> OnRequest(const IEventInfo& info) override;
+ void OnEvent(const IEventInfo& info, std::list<Bundle> serialized) override;
+ std::list<Bundle> OnRequest(const IEventInfo& info) override;
static std::string GetPath();
private:
#include "notification-ex/progress_item.h"
#include "notification-ex/time_item.h"
#include "notification-ex/visibility_action.h"
+#include "notification-ex/ex_bundle.h"
#include "notification-ex/event_info_internal.h"
#include "notification-ex/manager.h"
#include "notification-ex/dbus_sender.h"
#define EXPORT_API __attribute__((visibility("default")))
using namespace std;
-using namespace tizen_base;
using namespace notification::item;
using namespace notification;
#define TEXT_CONTENTS_KEY "__TEXT_CONTENTS_KEY__"
#define TEXT_HYPERLINK_KEY "__TEXT_HYPERLINK_KEY__"
-using namespace tizen_base;
-
namespace notification {
namespace item {
TextItem::TextItem(std::string id, std::string text, std::string hyperlink,
* @since_tizen 5.5
* @return Bundle type data
*/
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- void Deserialize(tizen_base::Bundle b) override;
+ void Deserialize(Bundle b) override;
/**
* @brief Finds the AbstractItem using by notification item id.
#define LOG_TAG "NOTIFICATION_EX"
#define TIME_KEY "__TIME_KEY__"
-using namespace tizen_base;
-
namespace notification {
namespace item {
* @since_tizen 5.5
* @return Bundle type data
*/
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- void Deserialize(tizen_base::Bundle b) override;
+ void Deserialize(Bundle b) override;
/**
* @brief Finds the AbstractItem using by notification item id.
#define VISIBILITY_ACTION_ENTITY_KEY "__VISIBILITY_ACTION_VISIBLE_KEY__"
#define VISIBILITY_ACTION_ENTITY_SIZE_KEY "__VISIBILITY_ACTION_ENTITY_SIZE_KEY__"
-using namespace tizen_base;
-
namespace notification {
namespace item {
* @since_tizen 5.5
* @return Bundle type data
*/
- tizen_base::Bundle Serialize() const override;
+ Bundle Serialize() const override;
/**
* @brief Deserialize the serialized data.
* @since_tizen 5.5
* @param[in] b The serialized Bundle data
*/
- void Deserialize(tizen_base::Bundle b) override;
+ void Deserialize(Bundle b) override;
/**
* @brief Gets whether local or not.
#define MY_ITEM_TYPE AbstractItem::Type::Custom + 1
using namespace notification;
-using namespace tizen_base;
using namespace notification::item;
namespace {
#include "notification-ex/app_control_action.h"
#include "notification-ex/action_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string>
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/ex_bundle.h"
+
+using ::testing::AtLeast;
+using namespace notification;
+
+TEST(Bundle, CtorDtor) {
+ Bundle bundle;
+}
+
+TEST(Bundle, CopyCtor) {
+ Bundle bundle;
+ bundle.Add("TestKey", "TestVal");
+
+ Bundle b2(bundle);
+ EXPECT_EQ(b2.GetString("TestKey"), "TestVal");
+}
+
+TEST(Bundle, MoveCtor) {
+ Bundle bundle;
+ bundle.Add("TestKey", "TestVal");
+
+ Bundle b2(std::move(bundle));
+ EXPECT_EQ(b2.GetString("TestKey"), "TestVal");
+}
+
+TEST(Bundle, AddStringGetString) {
+ Bundle bundle;
+ bundle.Add("TestKey", "TestVal");
+
+ EXPECT_EQ(bundle.GetString("TestKey"), "TestVal");
+}
+
+TEST(Bundle, AddByteGetByte) {
+ Bundle bundle;
+ std::vector<unsigned char> v = { 0, 1, 2, 3};
+ bundle.Add("TestKey", v);
+ auto v2 = bundle.GetByte("TestKey");
+
+ EXPECT_EQ(v2.size(), 4);
+ EXPECT_EQ(v2[0], 0);
+ EXPECT_EQ(v2[1], 1);
+ EXPECT_EQ(v2[2], 2);
+ EXPECT_EQ(v2[3], 3);
+}
+
+TEST(Bundle, AddStringArrayGetStringArray) {
+ Bundle bundle;
+ bundle.Add("TestKey", { "TestVal1", "TestVal2", "TestVal3" });
+
+ auto v = bundle.GetStringArray("TestKey");
+
+ EXPECT_EQ(v.size(), 3);
+ EXPECT_EQ(v[0], "TestVal1");
+ EXPECT_EQ(v[1], "TestVal2");
+ EXPECT_EQ(v[2], "TestVal3");
+}
+
+TEST(Bundle, ToRaw) {
+ Bundle bundle;
+ bundle.Add("TestKey", "TestVal");
+
+ auto r = bundle.ToRaw();
+ Bundle b2(std::move(r));
+ EXPECT_EQ(bundle.GetString("TestKey"), "TestVal");
+}
+
+TEST(Bundle, GetCount) {
+ Bundle bundle;
+ bundle.Add("TestKey1", "TestVal1");
+ bundle.Add("TestKey2", "TestVal2");
+
+ EXPECT_EQ(bundle.GetCount(), 2);
+}
+
+TEST(Bundle, Delete) {
+ Bundle bundle;
+ int r = bundle.Add("TestKey1", "TestVal1");
+ EXPECT_EQ(r, 0);
+
+ r = bundle.Delete("TestKey1");
+ EXPECT_EQ(r, 0);
+
+ EXPECT_EQ(bundle.GetString("TestKey1"), "");
+}
+
+TEST(Bundle, GetKeys) {
+ Bundle bundle;
+ bundle.Add("TestKey1", "TestVal1");
+ bundle.Add("TestKey2", "TestVal2");
+ bundle.Add("TestKey3", "TestVal3");
+
+ auto v = bundle.GetKeys();
+
+ EXPECT_EQ(bundle.GetCount(), 3);
+
+ for (auto& i : v) {
+ EXPECT_EQ(i.GetType(), BUNDLE_TYPE_STR);
+ }
+}
#include "notification-ex/button_item.h"
#include "notification-ex/item_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
using namespace std;
#include "notification-ex/chat_message_item.h"
#include "notification-ex/item_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
#include "notification-ex/checkbox_item.h"
#include "notification-ex/item_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
#include "notification-ex/entry_item.h"
#include "notification-ex/item_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
#include "notification-ex/event_info_internal.h"
-using namespace tizen_base;
using namespace notification;
using namespace std;
#include "notification-ex/item_inflator.h"
#include "unittest/mock/app_common.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
using namespace std;
#include "notification-ex/icon_item.h"
#include "notification-ex/item_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
#include "notification-ex/icon_text_item.h"
#include "notification-ex/item_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
#include "notification-ex/image_item.h"
#include "notification-ex/item_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
#include "notification-ex/input_selector_item.h"
#include "notification-ex/item_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
using namespace std;
#include "notification-ex/progress_item.h"
#include "notification-ex/item_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
using namespace std;
#include "notification-ex/text_item.h"
#include "notification-ex/item_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
#include "notification-ex/time_item.h"
#include "notification-ex/item_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;
#include "notification-ex/visibility_action.h"
#include "notification-ex/action_inflator.h"
-using namespace tizen_base;
using namespace notification;
using namespace notification::item;