dlog
capi-appfw-app-control
capi-appfw-app-common
+ aul
+ uuid
)
FOREACH(flag ${notification-ex_CFLAGS})
return std::stoi(b.GetString(ABSTRACT_ACTION_TYPE_KEY));
}
-Bundle AbstractAction::Serialize() {
+Bundle AbstractAction::Serialize() const {
Bundle b;
b.Add(ABSTRACT_ACTION_TYPE_KEY, std::to_string(GetType()));
virtual int GetType() const = 0;
static int GetType(Bundle b);
- virtual Bundle Serialize() = 0;
+ virtual Bundle Serialize() const = 0;
virtual void Deserialize(Bundle b) = 0;
virtual bool IsLocal() const = 0;
virtual void Execute(std::shared_ptr<AbstractItem> item) = 0;
*/
#include <dlog.h>
+#include <uuid/uuid.h>
#include <memory>
#include <algorithm>
#include "notification-ex/abstract_item.h"
#include "notification-ex/abstract_item_implementation.h"
#include "notification-ex/item_info_internal.h"
+#include "notification-ex/ex_util.h"
#ifdef LOG_TAG
#undef LOG_TAG
#define ABSTRACT_ITEM_TYPE_KEY "__ABSTRACT_ITEM_TYPE_KEY__"
#define ABSTRACT_ITEM_ID_KEY "__ABSTRACT_ITEM_ID_KEY__"
+#define ABSTRACT_ITEM_SENDER_APPID_KEY "__ABSTRACT_ITEM_SENDER_APPID_KEY__"
using namespace std;
namespace notification {
namespace item {
-AbstractItem::AbstractItem(std::shared_ptr<AbstractAction> action)
- : impl_(new Impl(this, action)) {
+string AbstractItem::Impl::GenerateItemId() {
+ char uuid[37];
+ uuid_t u;
+ uuid_generate(u);
+ uuid_unparse(u, uuid);
+ string id = util::GetAppId();
+ return string(uuid) + ":" + id;
+}
+
+AbstractItem::AbstractItem(
+ std::shared_ptr<AbstractAction> action)
+ : impl_(new Impl(this, action)) {
}
AbstractItem::AbstractItem(std::string id,
std::shared_ptr<AbstractAction> action)
- : impl_(new Impl(this, id, action)) {
+ : impl_(new Impl(this, id, action)) {
}
AbstractItem::Impl::Impl(AbstractItem* parent, string id,
std::shared_ptr<AbstractAction> action)
- : id_(id), action_(action), parent_(parent),
+ : id_(id), action_(action), parent_(parent),
info_(std::make_shared<ItemInfo>(this)) {
- LOGI("Item created");
+
+ if (id_.empty())
+ id_ = GenerateItemId();
+ sender_appid_ = util::GetAppId();
+ LOGI("GroupItem created (%s)", id_.c_str());
}
AbstractItem::Impl::Impl(AbstractItem* parent,
std::shared_ptr<AbstractAction> action)
- : action_(action), parent_(parent),
+ : action_(action), parent_(parent),
info_(std::make_shared<ItemInfo>(this)) {
- LOGI("Item created");
+ LOGI("GroupItem created");
+
+ id_ = GenerateItemId();
+ sender_appid_ = util::GetAppId();
+ LOGI("GroupItem created (%s)", id_.c_str());
}
AbstractItem::~AbstractItem() = default;
-Bundle AbstractItem::Serialize() {
+Bundle AbstractItem::Serialize() const {
Bundle b;
b.Add(ABSTRACT_ITEM_TYPE_KEY, to_string(GetType()));
b.Add(ABSTRACT_ITEM_ID_KEY, impl_->id_);
+ b.Add(ABSTRACT_ITEM_SENDER_APPID_KEY, GetSenderAppId().c_str());
return b;
}
string id_str = b.GetString(ABSTRACT_ITEM_ID_KEY);
impl_->id_ = id_str;
+ impl_->sender_appid_ = b.GetString(ABSTRACT_ITEM_SENDER_APPID_KEY);
}
string AbstractItem::GetId() const {
impl_->receiver_group_list_.remove(receiver_group);
}
+list<string> AbstractItem::GetReceiverList() {
+ return impl_->receiver_group_list_;
+}
+
bool AbstractItem::CanReceive(std::string id) const {
+ if (impl_->receiver_group_list_.size() == 0)
+ return true;
list<string>::iterator iter =
std::find(impl_->receiver_group_list_.begin(),
impl_->receiver_group_list_.end(), id);
void AbstractItem::SetSoundPath(std::string path) {
impl_->sound_path_ = path;
}
+
void AbstractItem::SetVibrationPath(std::string path) {
impl_->vibration_path_ = path;
}
+
std::string AbstractItem::GetSoundPath() const {
return impl_->sound_path_;
}
+
std::string AbstractItem::GetVibrationPath() const {
return impl_->vibration_path_;
}
+std::string AbstractItem::GetSenderAppId() const {
+ return impl_->sender_appid_;
+}
+
+void AbstractItem::SetSenderAppId(std::string sender_appid) {
+ impl_->sender_appid_ = sender_appid;
+}
+
+time_t AbstractItem::GetTime() {
+ return impl_->time_;
+}
+
+int AbstractItem::GetUid() {
+ return impl_->uid_;
+}
+
+void AbstractItem::SetUid(int uid) {
+ impl_->uid_ = uid;
+}
+
+int AbstractItem::GetRequestId() {
+ return impl_->request_id_;
+}
+
} // namespace item
} // namespace notification
#include <memory>
#include <string>
+#include <list>
#include "notification-ex/abstract_action.h"
#include "notification-ex/ex_bundle.h"
};
public:
- AbstractItem(std::shared_ptr<AbstractAction> action =
- std::shared_ptr<AbstractAction>({}));
- AbstractItem(std::string id, std::shared_ptr<AbstractAction> action =
- std::shared_ptr<AbstractAction>({}));
+ AbstractItem(
+ std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
+ AbstractItem(std::string id,
+ std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
virtual ~AbstractItem() = 0;
- virtual Bundle Serialize() = 0;
+ virtual Bundle Serialize() const = 0;
virtual void Deserialize(Bundle b) = 0;
virtual AbstractItem& FindByID(std::string id) = 0;
virtual int GetType() const = 0;
void SetEnable(bool enable);
void AddReceiver(std::string receiver_group);
void RemoveReceiver(std::string receiver_group);
+ std::list<std::string> GetReceiverList();
bool CanReceive(std::string id) const;
void SetPolicy(Policy policy);
Policy GetPolicy() const;
std::string GetSoundPath() const;
std::string GetVibrationPath() const;
std::shared_ptr<IItemInfo> GetInfo() const;
+ std::string GetSenderAppId() const;
+ void SetSenderAppId(std::string sender_appid);
+ std::string GetTag();
+ void SetTag();
+ time_t GetTime();
+ int GetUid();
+ void SetUid(int uid);
+ int GetRequestId();
private:
class Impl;
private:
Impl(AbstractItem* parent);
- Impl(AbstractItem* parent, std::shared_ptr<AbstractAction> action =
- std::shared_ptr<AbstractAction>({}));
+ Impl(AbstractItem* parent,
+ std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
Impl(AbstractItem* parent, std::string id,
- std::shared_ptr<AbstractAction> action =
- std::shared_ptr<AbstractAction>({}));
+ std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
private:
friend class AbstractItem;
+ std::string GenerateItemId();
std::string channel_;
std::string id_;
std::shared_ptr<LEDInfo> led_ = nullptr;
AbstractItem* parent_;
std::string sound_path_;
std::string vibration_path_;
+ std::string sender_appid_;
std::shared_ptr<IItemInfo> info_;
+ std::list<std::string> hide_viewer_list_;
+ std::string tag_;
+ time_t time_ = 0;
+ int uid_ = 0;
+ int request_id_ = 0;
};
} // namespace item
return AbstractAction::AppControl;
}
-Bundle AppControlAction::Serialize() {
+Bundle AppControlAction::Serialize() const {
Bundle b;
bundle* control_b = NULL;
bundle_raw* control_raw;
virtual ~AppControlAction();
int GetType() const override;
- Bundle Serialize() override;
+ Bundle Serialize() const override;
void Deserialize(Bundle b) override;
bool IsLocal() const override;
void Execute(std::shared_ptr<AbstractItem> item) override;
return AbstractItem::Button;
}
-Bundle ButtonItem::Serialize() {
+Bundle ButtonItem::Serialize() const {
Bundle b;
b = AbstractItem::Serialize();
b.Add(BUTTON_TITLE_KEY, impl_->title_);
std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
virtual ~ButtonItem();
- Bundle Serialize() override;
+ Bundle Serialize() const override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
int GetType() const override;
return AbstractItem::ChatMessage;
}
-Bundle ChatMessageItem::Serialize() {
+Bundle ChatMessageItem::Serialize() const {
Bundle b;
b = AbstractItem::Serialize();
virtual ~ChatMessageItem();
int GetType() const override;
- Bundle Serialize() override;
+ Bundle Serialize() const override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
TextItem& GetNameItem() const;
return AbstractItem::CheckBox;
}
-Bundle CheckBoxItem::Serialize() {
+Bundle CheckBoxItem::Serialize() const {
Bundle b;
b = AbstractItem::Serialize();
std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
virtual ~CheckBoxItem();
- Bundle Serialize() override;
+ Bundle Serialize() const override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
int GetType() const override;
namespace notification {
-typedef enum _notification_error {
+enum NotificationError {
NOTIFICATION_ERROR_NONE = TIZEN_ERROR_NONE, /**< Success */
NOTIFICATION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
NOTIFICATION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
NOTIFICATION_ERROR_NOT_EXIST_ID = TIZEN_ERROR_NOTIFICATION | 0x04, /**< Not exist private ID */
NOTIFICATION_ERROR_SERVICE_NOT_READY = TIZEN_ERROR_NOTIFICATION | 0x05, /**< No response from notification service */
NOTIFICATION_ERROR_MAX_EXCEEDED = TIZEN_ERROR_NOTIFICATION | 0x06, /**< Max notification count exceeded (@b Since: 3.0) */
-} notification_error_e;
+};
} // 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.
+ */
+
+#include <dlog.h>
+#include <glib.h>
+
+#include "notification-ex/exception.h"
+#include "notification-ex/dbus_connection_manager.h"
+#include "notification-ex/ex_util.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+
+#define NOTIFICATION_EX_BUS_NAME_PREFIX "org.tizen.notification_ex._"
+#define NOTIFICATION_EX_INTERFACE "org.tizen.notification_ex"
+#define DATA_PROVIDER_MASTER_ID "data-provider-master"
+
+using namespace std;
+namespace notification {
+
+DBusConnectionManager::DBusConnectionManager() = default;
+DBusConnectionManager::~DBusConnectionManager() = default;
+DBusConnectionManager& DBusConnectionManager::GetInst() {
+ static DBusConnectionManager w_inst;
+ int ret;
+ if (w_inst.connection_ == nullptr) {
+ ret = w_inst.Init();
+ if (ret != NOTIFICATION_ERROR_NONE)
+ THROW(ret);
+ }
+ return w_inst;
+}
+
+bool DBusConnectionManager::IsDataProviderMaster() const {
+ return is_DPM_;
+}
+
+bool DBusConnectionManager::IsDataProviderMaster(string appid) const {
+ if (appid == DATA_PROVIDER_MASTER_ID)
+ return true;
+ return false;
+}
+
+string DBusConnectionManager::GetDataProviderMasterName() const {
+ return GetBusName(DATA_PROVIDER_MASTER_ID);
+}
+
+string DBusConnectionManager::GetInterfaceName() const {
+ return NOTIFICATION_EX_INTERFACE;
+}
+
+GDBusConnection* DBusConnectionManager::GetConnection() {
+ return connection_;
+}
+
+std::string DBusConnectionManager::GetBusName(string appid) const {
+ if (appid.empty())
+ return "";
+
+ if (IsDataProviderMaster(appid))
+ return string(NOTIFICATION_EX_BUS_NAME_PREFIX) + DATA_PROVIDER_MASTER_ID;
+
+ char* encoded_str = g_compute_checksum_for_string(G_CHECKSUM_MD5,
+ appid.c_str(), -1);
+ if (encoded_str == NULL)
+ return "";
+
+ return string(NOTIFICATION_EX_BUS_NAME_PREFIX) + encoded_str;
+}
+
+int DBusConnectionManager::Init() {
+ GError* error = nullptr;
+ connection_ = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (connection_ == NULL) {
+ if (error != NULL) {
+ LOGE("Failed to get dbus [%s]", error->message);
+ g_error_free(error);
+ }
+ return NOTIFICATION_ERROR_IO_ERROR;
+ }
+
+ string appid = util::GetAppId();
+ if (appid.empty())
+ return NOTIFICATION_ERROR_IO_ERROR;
+
+ if (IsDataProviderMaster(appid))
+ is_DPM_ = true;
+
+ string encoded_name = GetBusName(appid);
+ LOGI("own name %s", encoded_name.c_str());
+ int owner_id = g_bus_own_name_on_connection(connection_, encoded_name.c_str(),
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ NULL, NULL, NULL, NULL);
+ if (!owner_id) {
+ g_object_unref(connection_);
+ LOGE("g_bus_own_name_on_connection, error");
+ return NOTIFICATION_ERROR_IO_ERROR;
+ }
+ return NOTIFICATION_ERROR_NONE;
+}
+
+} // nampace notification
\ No newline at end of file
#ifndef NOTIFICATION_EX_DBUS_MANAGER_H_
#define NOTIFICATION_EX_DBUS_MANAGER_H_
+#include <gio/gio.h>
+
#include <string>
+#include "notification-ex/ex_bundle.h"
+
namespace notification {
-class DBusConnectionManager {
+class EXPORT_API DBusConnectionManager {
public:
static DBusConnectionManager& GetInst();
- GDbusConnection& GetConnection();
+ GDBusConnection* GetConnection();
+ bool IsDataProviderMaster(std::string appid) const;
+ std::string GetDataProviderMasterName() const;
+ std::string GetInterfaceName() const;
+ std::string GetBusName(std::string appid) const;
private:
+ bool IsDataProviderMaster() const;
DBusConnectionManager();
~DBusConnectionManager();
- GDbusConnection connection_;
+ int Init();
+ GDBusConnection* connection_ = nullptr;
+ bool is_DPM_ = false;
};
} // 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.
+ */
+
+#include <dlog.h>
+#include <glib.h>
+#include <unistd.h>
+
+#include "notification-ex/dbus_connection_manager.h"
+#include "notification-ex/dbus_event_listener.h"
+#include "notification-ex/dbus_event_listener_implementation.h"
+#include "notification-ex/exception.h"
+#include "notification-ex/ex_util.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+
+#define MAX_PACKAGE_STR_SIZE 512
+
+using namespace std;
+namespace notification {
+
+DBusEventListener::DBusEventListener(string path)
+ : impl_(new Impl(this, path)) {
+ LOGW("Created (%s)", path.c_str());
+}
+
+DBusEventListener::~DBusEventListener() {
+ LOGW("Destroyed");
+}
+
+DBusEventListener::Impl::~Impl() = default;
+
+DBusEventListener::Impl::Impl(DBusEventListener* parent, string path)
+ : subscribe_id_(0), registration_id_(0), path_(path), parent_(parent) {
+ LOGI("ButtonItem impl created");
+}
+
+void DBusEventListener::Impl::SignalCb(GDBusConnection* connection,
+ const gchar* sender_name,
+ const gchar* object_path,
+ const gchar* interface_name,
+ const gchar* signal_name,
+ GVariant* parameters,
+ void* user_data) {
+ DBusEventListener* dl = static_cast<DBusEventListener*>(user_data);
+ char* appid = nullptr;
+ GVariantIter *iter = nullptr;
+ char* event_info_raw = nullptr;
+ g_variant_get(parameters, "(ssa(s))", &appid, &event_info_raw, &iter);
+
+ LOGI("signal callback!! (%s)", appid);
+ string sender_appid = string(appid);
+ string cur_appid = util::GetAppId();
+ if (sender_appid == cur_appid)
+ return;
+ if ((!DBusConnectionManager::GetInst().IsDataProviderMaster(cur_appid)
+ && !DBusConnectionManager::GetInst().IsDataProviderMaster(sender_appid))
+ || (cur_appid == sender_appid))
+ return;
+
+ LOGE("%s : %s", cur_appid.c_str(), sender_appid.c_str());
+
+ char* raw = nullptr;
+ list<Bundle> ret_list;
+ while (g_variant_iter_loop(iter, "(s)", &raw) && raw != nullptr) {
+ Bundle ret(raw);
+ ret_list.emplace_back(ret);
+ }
+
+ Bundle b(event_info_raw);
+ EventInfo info(b);
+ dl->NotifyObserver(info, ret_list);
+}
+
+void DBusEventListener::Impl::OnMethodCall(
+ GDBusConnection *conn, const gchar *sender, const gchar *object_path,
+ const gchar *iface_name, const gchar *method_name,
+ GVariant *parameters, GDBusMethodInvocation *invocation,
+ gpointer user_data) {
+ LOGI("method_name[%s] sender[%s]", method_name, sender);
+ DBusEventListener* dl = static_cast<DBusEventListener*>(user_data);
+ GVariant *reply_body = NULL;
+ if (g_strcmp0(method_name, "Get") == 0) {
+ char* appid = NULL;
+ char* serialized = NULL;
+ g_variant_get(parameters, "(&s&s)", &appid, &serialized);
+
+ Bundle b(serialized);
+ EventInfo info(b);
+ list<Bundle> result = dl->NotifyObserver(info);
+ GVariantBuilder* builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+ for (auto& i : result) {
+ g_variant_builder_add(builder, "(s)",
+ reinterpret_cast<char*>(i.ToRaw().first.get()));
+ }
+ reply_body = g_variant_new("(a(s))", builder);
+ g_variant_builder_unref(builder);
+ }
+ g_dbus_method_invocation_return_value(invocation, reply_body);
+}
+
+int DBusEventListener::Impl::RegisterGDBusInterface() {
+ static const GDBusInterfaceVTable interface_vtable = {
+ OnMethodCall,
+ nullptr,
+ nullptr
+ };
+ static gchar introspection_xml[] =
+ " <node>"
+ " <interface name='org.tizen.notification_ex'>"
+ " <method name='Get'>"
+ " <arg type='s' name='appid' direction='in'/>"
+ " <arg type='s' name='serialized' direction='in'/>"
+ " <arg type='a(s)' name='noti_arr' direction='out'/>"
+ " </method>"
+ " </interface>"
+ " </node>";
+ GError *error = NULL;
+ GDBusNodeInfo *introspection_data =
+ g_dbus_node_info_new_for_xml(introspection_xml, &error);
+ if (!introspection_data) {
+ LOGE("g_dbus_node_info_new_for_xml is failed.");
+ if (error != NULL) {
+ LOGE("g_dbus_node_info_new_for_xml err [%s]", error->message);
+ g_error_free(error);
+ }
+ return NOTIFICATION_ERROR_IO_ERROR;
+ }
+
+ registration_id_ = g_dbus_connection_register_object(
+ DBusConnectionManager::GetInst().GetConnection(),
+ path_.c_str(), introspection_data->interfaces[0],
+ &interface_vtable, this, NULL, NULL);
+ g_dbus_node_info_unref(introspection_data);
+ if (registration_id_ == 0) {
+ LOGE("register object fail");
+ return NOTIFICATION_ERROR_IO_ERROR;
+ }
+
+ LOGI("RegisterGDBusInterface success");
+ return NOTIFICATION_ERROR_NONE;
+}
+
+void DBusEventListener::Impl::UnRegisterGDBusInterface() {
+ g_dbus_connection_unregister_object(
+ DBusConnectionManager::GetInst().GetConnection(),
+ registration_id_);
+}
+
+bool DBusEventListener::Impl::SubscribeSignal() {
+ subscribe_id_ = g_dbus_connection_signal_subscribe(
+ DBusConnectionManager::GetInst().GetConnection(),
+ NULL,
+ DBusConnectionManager::GetInst().GetInterfaceName().c_str(),
+ NULL,
+ path_.c_str(),
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ SignalCb,
+ this,
+ NULL);
+ return subscribe_id_ > 0;
+}
+
+void DBusEventListener::Impl::UnSubscribeSignal() {
+ g_dbus_connection_signal_unsubscribe(
+ DBusConnectionManager::GetInst().GetConnection(), subscribe_id_);
+ subscribe_id_ = 0;
+}
+
+void DBusEventListener::RegisterObserver(IEventObserver* observer) {
+ if (impl_->subscribe_id_ == 0) {
+ impl_->SubscribeSignal();
+ } else {
+ impl_->UnSubscribeSignal();
+ impl_->SubscribeSignal();
+ }
+
+ if (impl_->registration_id_ == 0) {
+ impl_->RegisterGDBusInterface();
+ } else {
+ impl_->UnRegisterGDBusInterface();
+ impl_->RegisterGDBusInterface();
+ }
+ impl_->observer_ = observer;
+}
+
+void DBusEventListener::UnRegisterObserver(IEventObserver* observer) {
+ impl_->UnSubscribeSignal();
+ impl_->observer_ = NULL;
+}
+
+void DBusEventListener::NotifyObserver(
+ const EventInfo& info, list<Bundle> serialized) {
+ impl_->observer_->OnEvent(info, serialized);
+}
+
+list<Bundle> DBusEventListener::NotifyObserver(const EventInfo& info) {
+ return impl_->observer_->OnRequest(info);
+}
+
+} // nampace notification
\ No newline at end of file
#ifndef NOTIFICATION_EX_DBUS_LISTENER_H_
#define NOTIFICATION_EX_DBUS_LISTENER_H_
-#include "notification-ex/observer_interface.h"
+#include <gio/gio.h>
+
+#include "notification-ex/event_listener_interface.h"
namespace notification {
-class EXPORT_API DBusEventsListener : public IEventListener {
+class EXPORT_API DBusEventListener : public IEventListener {
public:
- DBusEventsListener();
- ~DBusEventsListener();
+ DBusEventListener(std::string path);
+ ~DBusEventListener();
+
+ void RegisterObserver(IEventObserver* observer) override;
+ void UnRegisterObserver(IEventObserver* observer) override;
+ void NotifyObserver(
+ const EventInfo& info, std::list<Bundle> serialized) override;
+ std::list<Bundle> NotifyObserver(const EventInfo& info) override;
- void RegisterObserver(IEventObserver observer) override;
- void UnRegisterObserver(IEventObserver observer) override;
- void NotifyAll() override;
+ private:
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // 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_DBUS_EVENT_LISTENER_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_DBUS_EVENT_LISTENER_IMPLEMENTATION_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/dbus_event_listener.h"
+
+namespace notification {
+
+class DBusEventListener::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class DBusEventListener;
+ Impl(DBusEventListener* parent, std::string path);
+
+ private:
+ void UnRegisterGDBusInterface();
+ int RegisterGDBusInterface();
+ static void OnMethodCall(
+ GDBusConnection *conn, const gchar *sender, const gchar *object_path,
+ const gchar *iface_name, const gchar *method_name,
+ GVariant *parameters, GDBusMethodInvocation *invocation,
+ gpointer user_data);
+
+ static GDBusInterfaceVTable InterfaceVtable;
+ static void SignalCb(GDBusConnection* connection,
+ const gchar* sender_name,
+ const gchar* object_path,
+ const gchar* interface_name,
+ const gchar* signal_name,
+ GVariant* parameters,
+ void* user_data);
+ bool SubscribeSignal();
+ void UnSubscribeSignal();
+ IEventObserver* observer_ = nullptr;
+ int subscribe_id_;
+ int registration_id_;
+ std::string path_;
+ DBusEventListener* parent_;
+};
+
+} // nampace notification
+#endif // NOTIFICATION_EX_DBUS_EVENT_LISTENER_IMPLEMENTATION_H_
--- /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 <dlog.h>
+#include <glib.h>
+#include <unistd.h>
+
+#include <list>
+
+#include "notification-ex/dbus_connection_manager.h"
+#include "notification-ex/dbus_sender.h"
+#include "notification-ex/dbus_sender_implementation.h"
+#include "notification-ex/event_info.h"
+#include "notification-ex/ex_util.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+
+#define MAX_PACKAGE_STR_SIZE 512
+
+using namespace std;
+namespace notification {
+
+DBusSender::DBusSender(string path)
+ : impl_(new Impl(this, path)) {
+ LOGW("Created (%s)", path.c_str());
+}
+
+DBusSender::Impl::~Impl() = default;
+
+DBusSender::Impl::Impl(DBusSender* parent, string path)
+ : path_(path), parent_(parent) {
+ LOGI("ButtonItem impl created");
+}
+
+DBusSender::~DBusSender() {
+ LOGW("Destroyed");
+}
+
+bool DBusSender::Impl::EmitSignal(string bus_name,
+ string signal_name, GVariant* data) {
+ GError* err = NULL;
+ gboolean result = TRUE;
+
+ result = g_dbus_connection_emit_signal(
+ DBusConnectionManager::GetInst().GetConnection(),
+ bus_name.empty() ? NULL : bus_name.c_str(),
+ path_.c_str(),
+ DBusConnectionManager::GetInst().GetInterfaceName().c_str(),
+ signal_name.c_str(), data, &err);
+ if (result == FALSE) {
+ LOGE("g_dbus_connection_emit_signal() is failed");
+ if (err != NULL) {
+ LOGE("g_dbus_connection_emit_signal() err : %s",
+ err->message);
+ g_error_free(err);
+ }
+ } else {
+ LOGI("Successfully emit signal to %s, %s, %s",
+ bus_name.c_str(), path_.c_str(), signal_name.c_str());
+ }
+ return result;
+}
+
+void DBusSender::Notify(const EventInfo& info,
+ list<Bundle> serialized, string dest_appid) {
+ string signal_name = EventInfo::GetString(info.GetEventType());
+ string appid = util::GetAppId();
+ string bus_name = "";
+
+ GVariantBuilder* builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+ for (auto& i : serialized) {
+ g_variant_builder_add(builder, "(s)",
+ reinterpret_cast<char*>(i.ToRaw().first.get()));
+ }
+
+ GVariant* data = g_variant_new("(ssa(s))",
+ appid.c_str(),
+ reinterpret_cast<char*>(info.Serialize().ToRaw().first.get()), builder);
+ if (!DBusConnectionManager::GetInst().IsDataProviderMaster(appid)) {
+ bus_name = DBusConnectionManager::GetInst().GetDataProviderMasterName();
+ impl_->EmitSignal(bus_name, signal_name, data);
+ } else {
+ bus_name = DBusConnectionManager::GetInst().GetBusName(dest_appid);
+ LOGE("bus name %s, %s", dest_appid.c_str(), bus_name.c_str());
+ impl_->EmitSignal(bus_name, signal_name, data);
+ }
+ g_variant_builder_unref(builder);
+}
+
+GDBusMessage* DBusSender::Impl::MethodCall(string appid,
+ string method_name, Bundle serialized) {
+ GError* err = nullptr;
+ GDBusMessage* msg = g_dbus_message_new_method_call(
+ DBusConnectionManager::GetInst().GetDataProviderMasterName().c_str(),
+ path_.c_str(),
+ DBusConnectionManager::GetInst().GetInterfaceName().c_str(),
+ method_name.c_str());
+ if (!msg) {
+ LOGE("Can't allocate new method call");
+ return nullptr;
+ }
+
+ g_dbus_message_set_body(msg,
+ g_variant_new("(ss)",
+ appid.c_str(),
+ reinterpret_cast<char*>(serialized.ToRaw().first.get())
+ )
+ );
+
+ LOGI("send message !! (%s) (%s) (%s)",
+ path_.c_str(), method_name.c_str(), appid.c_str());
+ GDBusMessage* reply = g_dbus_connection_send_message_with_reply_sync(
+ DBusConnectionManager::GetInst().GetConnection(), msg,
+ G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &err);
+
+ return reply;
+}
+
+std::list<Bundle> DBusSender::Request(const EventInfo& info) {
+ string appid = util::GetAppId();
+ string method_name = EventInfo::GetString(info.GetEventType());
+ Bundle serialized = info.Serialize();
+
+ GDBusMessage* reply = impl_->MethodCall(appid, method_name, serialized);
+ GVariant *reply_body = g_dbus_message_get_body(reply);
+
+ GVariantIter *iter = nullptr;
+ list<Bundle> ret_list;
+ g_variant_get(reply_body, "(a(s))", &iter);
+ char* raw = nullptr;
+ while (g_variant_iter_loop(iter, "(s)", &raw) && raw != nullptr) {
+ Bundle ret(raw);
+ ret_list.emplace_back(ret);
+ }
+
+ return ret_list;
+}
+
+} // nampace notification
\ No newline at end of file
#ifndef NOTIFICATION_EX_DBUS_SENDER_H_
#define NOTIFICATION_EX_DBUS_SENDER_H_
+#include <gio/gio.h>
+
#include "notification-ex/ex_bundle.h"
+#include "notification-ex/event_sender_interface.h"
+#include "notification-ex/event_info.h"
#ifndef EXPORT_API
#define EXPORT_API __attribute__((visibility("default")))
namespace notification {
-class EXPORT_API DBusSender : public IEventsSender {
+class EXPORT_API DBusSender : public IEventSender {
public:
- DBusSender();
+ DBusSender(std::string path);
virtual ~DBusSender();
- void Notify(Bundle serialized) override;
+ void Notify(const EventInfo& info, std::list<Bundle> serialized,
+ std::string dest_appid = "") override;
+ std::list<Bundle> Request(const EventInfo& info) override;
+
+ private:
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // 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_DBUS_SENDER_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_DBUS_SENDER_IMPLEMENTATION_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/dbus_sender.h"
+
+namespace notification {
+
+class DBusSender::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class DBusSender;
+ Impl(DBusSender* parent, std::string path);
+
+ private:
+ bool EmitSignal(std::string bus_name, std::string signal_name, GVariant* data);
+ GDBusMessage* MethodCall(std::string appid, std::string method_name, Bundle serialized);
+ std::string path_;
+ DBusSender* parent_;
+};
+
+} // nampace notification
+#endif // NOTIFICATION_EX_DBUS_SENDER_IMPLEMENTATION_H_
\ No newline at end of file
return AbstractItem::Entry;
}
-Bundle EntryItem::Serialize() {
+Bundle EntryItem::Serialize() const {
Bundle b;
b = AbstractItem::Serialize();
std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
virtual ~EntryItem();
- Bundle Serialize() override;
+ Bundle Serialize() const override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
int GetType() const override;
--- /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 <dlog.h>
+
+#include <memory>
+
+#include "notification-ex/event_info.h"
+#include "notification-ex/event_info_implementation.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+#define NOTIFICATION_EX_EVENT_TYPE_KEY "__NOTIFICATION_EX_EVENT_TYPE_KEY__"
+#define NOTIFICATION_EX_EVENT_OWNER_KEY "__NOTIFICATION_EX_EVENT_OWNER_KEY__"
+#define NOTIFICATION_EX_EVENT_CHANNEL_KEY "__NOTIFICATION_EX_EVENT_CHANNEL_KEY__"
+#define NOTIFICATION_EX_EVENT_ITEM_ID_KEY "__NOTIFICATION_EX_EVENT_ITEM_ID_KEY__"
+#define NOTIFICATION_EX_EVENT_TAG_KEY "__NOTIFICATION_EX_EVENT_TAG_KEY__"
+
+using namespace std;
+namespace notification {
+
+EventInfo::EventInfo(EventInfo::EventType type, std::string owner,
+ std::string channel, std::string item_id, std::string tag)
+ : impl_(new Impl(this, type, owner, channel, item_id, tag)) {
+}
+EventInfo::~EventInfo() = default;
+EventInfo::Impl::~Impl() = default;
+
+EventInfo::Impl::Impl(EventInfo* parent, EventInfo::EventType type, std::string owner,
+ std::string channel, std::string item_id, std::string tag)
+ : type_(type), owner_(owner), channel_(channel), item_id_(item_id),
+ tag_(tag), parent_(parent) {
+ LOGI("EventInfo impl created");
+}
+
+EventInfo::EventInfo(Bundle serialized) {
+ string event_str = serialized.GetString(NOTIFICATION_EX_EVENT_TYPE_KEY);
+ impl_->type_ = static_cast<EventInfo::EventType>(strtol(event_str.c_str(), NULL, 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);
+ impl_->tag_ = serialized.GetString(NOTIFICATION_EX_EVENT_TAG_KEY);
+}
+
+string EventInfo::GetString(EventInfo::EventType type) {
+ switch(type) {
+ case Post:
+ return "Post";
+ break;
+ case Update:
+ return "Update";
+ break;
+ case Delete:
+ return "Delete";
+ break;
+ case Get:
+ return "Get";
+ break;
+ }
+ return "";
+}
+
+Bundle EventInfo::Serialize() const {
+ Bundle serialized;
+ serialized.Add(NOTIFICATION_EX_EVENT_TYPE_KEY, to_string((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_TAG_KEY, impl_->tag_);
+
+ return serialized;
+}
+
+EventInfo::EventType EventInfo::GetEventType() const {
+ return impl_->type_;
+}
+
+string EventInfo::GetOwner() const {
+ return impl_->owner_;
+}
+
+string EventInfo::GetChannel() const {
+ return impl_->channel_;
+}
+
+string EventInfo::GetItemId() const {
+ return impl_->item_id_;
+}
+
+string EventInfo::GetTag() const {
+ return impl_->tag_;
+}
+
+} // namespace notification
#define NOTIFICATION_EX_EVENT_INFO_H_
#include <string>
+#include <list>
+
+#include "notification-ex/ex_bundle.h"
#ifndef EXPORT_API
#define EXPORT_API __attribute__((visibility("default")))
class EXPORT_API EventInfo {
public:
- EventInfo();
+ enum EventType {
+ Post,
+ Update,
+ Delete,
+ Get,
+ };
+ EventInfo(EventType type, std::string owner,
+ std::string channel = "",
+ std::string item_id = "",
+ std::string tag = "");
+ EventInfo(Bundle serialized);
~EventInfo();
- int GetEventType() const;
+ static std::string GetString(EventType type);
+ EventType GetEventType() const;
std::string GetOwner() const;
- int GetChannel();
+ std::string GetChannel() const;
+ std::string GetItemId() const;
+ std::string GetTag() const;
+ Bundle Serialize() const;
private:
- int type_;
- std::string owner_;
- int channel_;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // 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_EVENT_INFO_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_EVENT_INFO_IMPLEMENTATION_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/dbus_sender.h"
+
+namespace notification {
+
+class EventInfo::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class EventInfo;
+ Impl(EventInfo* parent, EventInfo::EventType type, std::string owner,
+ std::string channel, std::string item_id, std::string tag);
+
+ private:
+ EventType type_;
+ std::string owner_;
+ std::string channel_;
+ std::string item_id_;
+ std::string tag_;
+ EventInfo* parent_;
+};
+
+} // nampace notification
+#endif // NOTIFICATION_EX_EVENT_INFO_IMPLEMENTATION_H_
\ No newline at end of file
#ifndef NOTIFICATION_EX_EVENT_LISTENER_INTERFACE_H_
#define NOTIFICATION_EX_EVENT_LISTENER_INTERFACE_H_
-#include "notification-ex/observer_interface.h"
+#include "notification-ex/event_observer_interface.h"
+#include "notification-ex/event_info.h"
#ifndef EXPORT_API
#define EXPORT_API __attribute__((visibility("default")))
namespace notification {
-class EXPORT_API IEventsListener {
+class EXPORT_API IEventListener {
public:
- virtual ~IEventsListener() = 0;
-
- virtual void RegisterObserver(IEventObserver observer) = 0;
- virtual void UnRegisterObserver(IEventObserver observer) = 0;
- virtual void NotifyAll() = 0;
+ virtual ~IEventListener() = default;
+ virtual void RegisterObserver(IEventObserver* observer) = 0;
+ virtual void UnRegisterObserver(IEventObserver* observer) = 0;
+ virtual void NotifyObserver(const EventInfo& info, std::list<Bundle> serialized) = 0;
+ virtual std::list<Bundle> NotifyObserver(const EventInfo& info) = 0;
};
} // namespace notification
class EXPORT_API IEventObserver {
public:
- virtual ~IEventObserver() = 0;
-
- virtual void OnEvent(EventInfo info, std::shared_ptr<AbstractItem> noti) = 0;
+ virtual ~IEventObserver() = default;
+ virtual void OnEvent(const EventInfo& info, std::list<Bundle> serialized) = 0;
+ virtual std::list<Bundle> OnRequest(const EventInfo& info) = 0;
};
} // namespace notification
#ifndef NOTIFICATION_EX_EVENT_SENDER_INTERFACE_H_
#define NOTIFICATION_EX_EVENT_SENDER_INTERFACE_H_
-#include "notification-ex/bundle.h"
+#include "notification-ex/ex_bundle.h"
+#include "notification-ex/event_info.h"
#ifndef EXPORT_API
#define EXPORT_API __attribute__((visibility("default")))
namespace notification {
-class EXPORT_API IEventsSender {
+class EXPORT_API IEventSender {
public:
- virtual ~IEventsSender() = 0;
-
- virtual void Notify(Bundle serialized) = 0;
+ virtual void Notify(const EventInfo& info, std::list<Bundle> serialized,
+ std::string dest_appid = "") = 0;
+ virtual std::list<Bundle> Request(const EventInfo &info) = 0;
};
} // namespace notification
#endif
namespace notification {
-namespace item {
class EXPORT_API Bundle final {
public:
using BundleRaw =
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 Remove(const std::string& key) {
return bundle_del(handle_, key.c_str());
}
bool copy_ = true;
};
-} // namespace item
} // namespace notification
#endif // NOTIFICATION_EX_BUNDLE_H_
--- /dev/null
+/*
+ * Copyright (c) 2018 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 <dlog.h>
+#include <aul.h>
+#include <aul.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <string>
+
+#include "notification-ex/ex_util.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+#define MAX_PACKAGE_STR_SIZE 512
+
+using namespace std;
+namespace notification {
+namespace util {
+ GQuark GetQuarkFromString(string str) {
+ return g_quark_from_string(str.c_str());
+ }
+
+ std::string GetQuarkToString(GQuark quark) {
+ return g_quark_to_string(quark);
+ }
+
+ string GetAppId() {
+ static string appid = "";
+ char appid_buf[MAX_PACKAGE_STR_SIZE] = {0, };
+
+ if (!appid.empty()) {
+ LOGI("appid(%s)", appid.c_str());
+ return appid;
+ }
+
+ int pid = getpid();
+ int ret = aul_app_get_appid_bypid(pid, appid_buf, sizeof(appid_buf));
+ if (ret == AUL_R_OK) {
+ appid = string(appid_buf);
+ } else {
+ int fd, i;
+ int last_slash_index = 0;
+ char proc_buf[MAX_PACKAGE_STR_SIZE] = { 0, };
+
+ snprintf(proc_buf, sizeof(proc_buf), "/proc/%d/cmdline", pid);
+
+ fd = open(proc_buf, O_RDONLY);
+ if (fd < 0) {
+ LOGE("Fail to get appid (%d)", errno);
+ return "";
+ }
+
+ ret = read(fd, appid_buf, sizeof(appid_buf) - 1);
+ if (ret <= 0) {
+ LOGE("Fail to get appid (%d)", errno);
+ close(fd);
+ return "";
+ }
+ close(fd);
+
+ for (i = 0 ; i < ret ; i++) {
+ if (appid_buf[i] == '/')
+ last_slash_index = i;
+ }
+
+ if (last_slash_index == (ret - 1)) {
+ LOGE("Fail to get appid (%s)", appid_buf);
+ return "";
+ }
+
+ if (last_slash_index == 0)
+ appid = string(appid_buf);
+ else
+ appid = string(&appid_buf[last_slash_index + 1]);
+ }
+
+ LOGI("appid(%s)", appid.c_str());
+ return appid;
+ }
+} // namespace util
+} // namespace watchface_complication
--- /dev/null
+/*
+ * Copyright (c) 2018 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_EX_UTIL_H_
+#define NOTIFICATION_EX_EX_UTIL_H_
+
+#include <gmodule.h>
+
+#include <string>
+
+namespace notification {
+namespace util {
+ std::string GetAppId();
+ std::string GetAppId();
+ GQuark GetQuarkFromString(std::string str);
+ std::string GetQuarkToString(GQuark quark);
+} // namespace util
+} // namespace notification
+
+#endif // NOTIFICATION_EX_EX_UTIL_H_
return AbstractItem::Group;
}
-Bundle GroupItem::Serialize() {
+Bundle GroupItem::Serialize() const {
Bundle b;
b = AbstractItem::Serialize();
b.Add(GROUP_DIRECTION_KEY, impl_->is_vertical_ ?
virtual ~GroupItem();
public:
- virtual Bundle Serialize() override;
+ virtual Bundle Serialize() const override;
virtual void Deserialize(Bundle b) override;
virtual AbstractItem& FindByID(std::string id) override;
int GetType() const override;
return AbstractItem::IconText;
}
-Bundle IconTextItem::Serialize() {
+Bundle IconTextItem::Serialize() const {
Bundle b;
b = AbstractItem::Serialize();
virtual ~IconTextItem();
- Bundle Serialize() override;
+ Bundle Serialize() const override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
int GetType() const override;
virtual ~IItemInfoInternal() = default;
virtual int GetHideTime() const = 0;
virtual int GetDeleteTime() const = 0;
+ virtual void AddHideViewer(std::string appid) = 0;
+ virtual void RemoveHideViewer(std::string appid) = 0;
+ virtual std::list<std::string> GetHideViewerList() const = 0;
};
} // namespace item
return AbstractItem::Image;
}
-Bundle ImageItem::Serialize() {
+Bundle ImageItem::Serialize() const {
Bundle b;
b = AbstractItem::Serialize();
b.Add(IMAGE_PATH_KEY, impl_->imagePath_);
virtual ~ImageItem();
int GetType() const override;
- Bundle Serialize() override;
+ Bundle Serialize() const override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
std::string GetImagePath() const;
return AbstractItem::InputSelector;
}
-Bundle InputSelectorItem::Serialize() {
+Bundle InputSelectorItem::Serialize() const {
Bundle b;
b = AbstractItem::Serialize();
vector<string> contents_vector {
virtual ~InputSelectorItem();
public:
- virtual Bundle Serialize() override;
+ virtual Bundle Serialize() const override;
virtual void Deserialize(Bundle b) override;
virtual AbstractItem& FindByID(std::string id) override;
int GetType() const override;
#include <dlog.h>
#include <memory>
+#include <algorithm>
#include "notification-ex/item_info_internal.h"
return impl_->delete_time_;
}
+void AbstractItem::Impl::ItemInfo::AddHideViewer(std::string appid) {
+ if (find(impl_->hide_viewer_list_.begin(),
+ impl_->hide_viewer_list_.end(), appid) !=
+ impl_->hide_viewer_list_.end()) {
+ return;
+ }
+ impl_->hide_viewer_list_.push_back(appid);
+}
+
+void AbstractItem::Impl::ItemInfo::RemoveHideViewer(std::string appid) {
+ impl_->hide_viewer_list_.remove(appid);
+}
+
+std::list<std::string> AbstractItem::Impl::ItemInfo::GetHideViewerList() const {
+ return impl_->hide_viewer_list_;
+}
+
+
} // namespace item
} // namespace notification
void SetVersion(int ver) override;
int GetHideTime() const override;
int GetDeleteTime() const override;
+ void AddHideViewer(std::string appid) override;
+ void RemoveHideViewer(std::string appid) override;
+ std::list<std::string> GetHideViewerList() const override;
private:
AbstractItem::Impl* impl_;
--- /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 <dlog.h>
+#include <glib.h>
+#include <unistd.h>
+
+#include <list>
+
+#include "notification-ex/item_inflator.h"
+#include "notification-ex/manager.h"
+#include "notification-ex/manager_implementation.h"
+#include "notification-ex/event_info.h"
+#include "notification-ex/dbus_connection_manager.h"
+#include "notification-ex/ex_util.h"
+#include "notification-ex/item_info_internal.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+
+#define MAX_PACKAGE_STR_SIZE 512
+#define NOTIFICATION_EX_MANAGER_OBJECT_PATH "/org/tizen/notification_ex_manager"
+
+using namespace std;
+using namespace notification::item;
+namespace notification {
+
+Manager::Manager(IEventSender* sender, IEventListener* listener, string receiver_group)
+ : impl_(new Impl(this, sender, listener, receiver_group)) {
+}
+Manager::~Manager() = default;
+
+Manager::Impl::~Impl() {
+ listener_->UnRegisterObserver(parent_);
+}
+Manager::Impl::Impl(Manager* parent,
+ IEventSender* sender, IEventListener* listener, string receiver_group)
+ : sender_(sender), listener_(listener), receiver_group_(receiver_group),
+ parent_(parent) {
+ LOGI("impl created");
+ listener_->RegisterObserver(parent_);
+}
+
+void Manager::Impl::SendNotify(shared_ptr<item::AbstractItem> noti,
+ EventInfo::EventType type) {
+ Bundle serialized = noti->Serialize();
+ EventInfo info(type, util::GetAppId(), noti->GetChannel());
+ list<Bundle> serialized_list {serialized};
+
+ /* Reply to Sender */
+ sender_->Notify(info, serialized_list, noti->GetSenderAppId());
+}
+
+void Manager::Update(shared_ptr<item::AbstractItem> noti) {
+ impl_->SendNotify(noti, EventInfo::Update);
+}
+
+void Manager::Remove(shared_ptr<item::AbstractItem> noti) {
+ impl_->SendNotify(noti, EventInfo::Delete);
+}
+
+void Manager::Hide(shared_ptr<item::AbstractItem> noti) {
+ ((IItemInfoInternal*)noti->GetInfo().get())->AddHideViewer(util::GetAppId());
+ impl_->SendNotify(noti, EventInfo::Update);
+}
+
+shared_ptr<item::AbstractItem> Manager::FindByRootID(string id) {
+ EventInfo info(EventInfo::Get,
+ util::GetAppId(), "", id);
+ list<Bundle> result = impl_->sender_->Request(info);
+ if (result.size() == 0) {
+ LOGE("Fail to get noti");
+ return shared_ptr<item::AbstractItem>({});
+ }
+ Bundle b = result.front();
+ shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+ return gen_item;
+}
+
+list<shared_ptr<item::AbstractItem>> Manager::Get() {
+ EventInfo info(EventInfo::Get, util::GetAppId(), "");
+ list<Bundle> result = impl_->sender_->Request(info);
+ list<shared_ptr<item::AbstractItem>> gen_list;
+ for (auto& i : result) {
+ shared_ptr<AbstractItem> gen_item = ItemInflator::Create(i);
+ gen_list.emplace_back(gen_item);
+ }
+ return gen_list;
+}
+
+void Manager::SendEvent(const EventInfo& info, shared_ptr<item::AbstractItem> noti) {
+ Bundle serialized = noti->Serialize();
+ Bundle serialized_info = info.Serialize();
+ list<Bundle> serialized_list {serialized};
+ impl_->sender_->Notify(info, serialized_list, noti->GetSenderAppId());
+}
+
+list<Bundle> Manager::OnRequest(const EventInfo& info) {
+ list<shared_ptr<item::AbstractItem>> item_list = OnRequestEvent(info);
+ list<Bundle> serialized_list;
+ for (auto& i : item_list) {
+ serialized_list.push_back(i->Serialize());
+ }
+ return serialized_list;
+}
+
+void Manager::OnEvent(const EventInfo& info, list<Bundle> serialized) {
+ shared_ptr<AbstractItem> gen_item;
+ const EventInfo::EventType type = info.GetEventType();
+ switch(type) {
+ case EventInfo::Post:
+ {
+ list<shared_ptr<item::AbstractItem>> added;
+ for (auto& i : serialized) {
+ gen_item = ItemInflator::Create(i);
+ if (gen_item->CanReceive(impl_->receiver_group_))
+ added.emplace_back(gen_item);
+ }
+ if (added.size() > 0)
+ OnAdd(info, added);
+ break;
+ }
+ case EventInfo::Update:
+ {
+ for (auto& i : serialized) {
+ gen_item = ItemInflator::Create(i);
+ if (gen_item->CanReceive(impl_->receiver_group_))
+ OnUpdate(info, gen_item);
+ }
+ break;
+ }
+ case EventInfo::Delete:
+ for (auto& i : serialized) {
+ gen_item = ItemInflator::Create(i);
+ if (gen_item->CanReceive(impl_->receiver_group_))
+ OnDelete(info, gen_item);
+ }
+ break;
+ case EventInfo::Get:
+ break;
+ }
+}
+
+void Manager::OnAdd(const EventInfo& info, list<shared_ptr<item::AbstractItem>> addedItem) {
+}
+
+void Manager::OnUpdate(const EventInfo& info, shared_ptr<item::AbstractItem> updatedItem) {
+}
+
+void Manager::OnDelete(const EventInfo& info, shared_ptr<item::AbstractItem> deletedItem) {
+}
+
+list<shared_ptr<item::AbstractItem>> Manager::OnRequestEvent(const EventInfo& info) {
+ return list<shared_ptr<item::AbstractItem>>({});
+}
+
+string Manager::GetPath() {
+ return NOTIFICATION_EX_MANAGER_OBJECT_PATH;
+}
+
+} // nampace notification
\ No newline at end of file
#include <list>
#include "notification-ex/abstract_item.h"
+#include "notification-ex/event_observer_interface.h"
+#include "notification-ex/event_sender_interface.h"
+#include "notification-ex/event_listener_interface.h"
#ifndef EXPORT_API
#define EXPORT_API __attribute__((visibility("default")))
class EXPORT_API Manager : public IEventObserver {
public:
- Manager(IEventsSender* sender, IEventsListener* listener);
+ Manager(IEventSender* sender, IEventListener* listener, std::string receiver_group = "");
virtual ~Manager();
+ std::list<std::shared_ptr<item::AbstractItem>> Get();
void Update(std::shared_ptr<item::AbstractItem> noti);
void Remove(std::shared_ptr<item::AbstractItem> noti);
void Hide(std::shared_ptr<item::AbstractItem> noti);
std::shared_ptr<item::AbstractItem> FindByRootID(std::string id);
- void SendEvent(EventInfo info, std::shared_ptr<item::AbstractItem> noti);
- void OnEvent(EventInfo info, std::shared_ptr<AbstractItem> notiList) override;
+ void SendEvent(const EventInfo& info, std::shared_ptr<item::AbstractItem> noti);
+ void OnEvent(const EventInfo& info, std::list<Bundle> serialized) override;
+ std::list<Bundle> OnRequest(const EventInfo& info) override;
+ static std::string GetPath();
protected:
- virtual void OnAdd(std::list<std::shared_ptr<item::AbstractItem>> addedItem);
- virtual void OnUpdate(shared_ptr<item::AbstractItem> updatedItem);
- virtual void OnDelete(shared_ptr<item::AbstractItem> deletedItem);
+ virtual void OnAdd(const EventInfo& info, std::list<std::shared_ptr<item::AbstractItem>> addedItem);
+ virtual void OnUpdate(const EventInfo& info, std::shared_ptr<item::AbstractItem> updatedItem);
+ virtual void OnDelete(const EventInfo& info, std::shared_ptr<item::AbstractItem> deletedItem);
+ virtual std::list<std::shared_ptr<item::AbstractItem>> OnRequestEvent(
+ const EventInfo& info);
private:
- IEventsSender* sender_;
- IEventsListener* receiver_;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
+
};
} // 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_MANAGER_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_MANAGER_IMPLEMENTATION_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/manager.h"
+
+namespace notification {
+
+class Manager::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ Impl(Manager* parent,
+ IEventSender* sender, IEventListener* listener, std::string receiver_group);
+
+ private:
+ friend class Manager;
+ void SendNotify(std::shared_ptr<item::AbstractItem> noti,
+ EventInfo::EventType type);
+ IEventSender* sender_;
+ IEventListener* listener_;
+ std::string receiver_group_;
+ Manager* parent_;
+};
+
+} // namespace notification
+
+#endif // NOTIFICATION_EX_MANAGER_IMPLEMENTATION_H_
namespace notification {
-class EXPORT_API MockSender : public IEventsSender {
+class EXPORT_API MockSender : public IEventSender {
public:
MockSender();
virtual ~MockSender();
Name: notification-ex
Description: Support development of the notification
Version: @VERSION@
-Libs: -L${libdir}
+Libs: -L${libdir} -lnotification-ex
Cflags: -I${includedir}
-cppflags: -I${includedir}
\ No newline at end of file
+cppflags: -I${includedir}
return AbstractItem::NullObject;
}
-Bundle NullItem::Serialize() {
+Bundle NullItem::Serialize() const {
Bundle b;
b = AbstractItem::Serialize();
return b;
std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
virtual ~NullItem();
int GetType() const override;
- Bundle Serialize() override;
+ Bundle Serialize() const override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
};
return AbstractItem::Progress;
}
-Bundle ProgressItem::Serialize() {
+Bundle ProgressItem::Serialize() const {
Bundle b;
b = AbstractItem::Serialize();
b.Add(PROGRESS_MIN_KEY, to_string(impl_->min_));
virtual ~ProgressItem();
public:
- virtual Bundle Serialize() override;
+ virtual Bundle Serialize() const override;
virtual void Deserialize(Bundle b) override;
virtual AbstractItem& FindByID(std::string id) override;
int GetType() const override;
--- /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 <dlog.h>
+#include <glib.h>
+#include <unistd.h>
+
+#include <list>
+
+#include "notification-ex/reporter.h"
+#include "notification-ex/reporter_implementation.h"
+#include "notification-ex/event_info.h"
+#include "notification-ex/item_inflator.h"
+#include "notification-ex/dbus_connection_manager.h"
+#include "notification-ex/ex_util.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+
+#define MAX_PACKAGE_STR_SIZE 512
+#define NOTIFICATION_EX_REPORTER_OBJECT_PATH "/org/tizen/notification_ex_reporter"
+
+using namespace std;
+using namespace notification::item;
+namespace notification {
+
+Reporter::Reporter(IEventSender* sender, IEventListener* listener)
+ : impl_(new Impl(this, sender, listener)) {
+}
+Reporter::~Reporter() = default;
+
+Reporter::Impl::~Impl() {
+ listener_->UnRegisterObserver(parent_);
+}
+Reporter::Impl::Impl(Reporter* parent,
+ IEventSender* sender, IEventListener* listener)
+ : sender_(sender), listener_(listener), parent_(parent) {
+ LOGI("impl created");
+ listener_->RegisterObserver(parent_);
+}
+
+void Reporter::Impl::SendNotify(shared_ptr<item::AbstractItem> noti,
+ EventInfo::EventType type) {
+ Bundle serialized = noti->Serialize();
+ EventInfo info(type, util::GetAppId(), noti->GetChannel());
+ list<Bundle> serialized_list {serialized};
+ sender_->Notify(info, serialized_list);
+}
+
+void Reporter::Post(std::shared_ptr<item::AbstractItem> noti) {
+ LOGI("Post noti");
+ impl_->SendNotify(noti, EventInfo::Post);
+}
+
+void Reporter::Post(std::list<std::shared_ptr<AbstractItem>> notiList) {
+ EventInfo info(EventInfo::Post, util::GetAppId(), "");
+ list<Bundle> serialized_list;
+ for (auto& i : notiList) {
+ Bundle b = i->Serialize();
+ serialized_list.push_back(b);
+ }
+ impl_->sender_->Notify(info, serialized_list);
+}
+
+void Reporter::Update(std::shared_ptr<AbstractItem> noti) {
+ impl_->SendNotify(noti, EventInfo::Update);
+}
+
+void Reporter::Remove(std::shared_ptr<AbstractItem> noti) {
+ impl_->SendNotify(noti, EventInfo::Delete);
+}
+
+std::shared_ptr<AbstractItem> Reporter::FindByRootID(std::string id) {
+ Bundle serialized;
+ EventInfo info(EventInfo::Get,
+ util::GetAppId(), "", id);
+ list<Bundle> result = impl_->sender_->Request(info);
+ if (result.size() == 0) {
+ LOGE("Fail to get noti");
+ return shared_ptr<item::AbstractItem>({});
+ }
+ Bundle b = result.front();
+ shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+ return gen_item;
+}
+
+void Reporter::SendEvent(const EventInfo& info, shared_ptr<item::AbstractItem> noti) {
+ Bundle serialized = noti->Serialize();
+ list<Bundle> serialized_list {serialized};
+ impl_->sender_->Notify(info, serialized_list);
+}
+
+void Reporter::OnEvent(const EventInfo& info, list<Bundle> serialized) {
+ list<shared_ptr<item::AbstractItem>> item_list;
+ for (auto& i : serialized) {
+ shared_ptr<AbstractItem> gen_item = ItemInflator::Create(i);
+ item_list.emplace_back(gen_item);
+ }
+ OnEvent(info, item_list);
+}
+
+list<shared_ptr<item::AbstractItem>> Reporter::OnRequestEvent(const EventInfo& info) {
+ return list<shared_ptr<item::AbstractItem>>({});
+}
+
+list<Bundle> Reporter::OnRequest(const EventInfo& info) {
+ list<shared_ptr<item::AbstractItem>> item_list = OnRequestEvent(info);
+ list<Bundle> serialized_list;
+ for (auto& i : item_list) {
+ serialized_list.push_back(i->Serialize());
+ }
+ return serialized_list;
+}
+
+void Reporter::OnEvent(
+ const EventInfo& info, list<shared_ptr<item::AbstractItem>> notiList) {
+}
+
+string Reporter::GetPath() {
+ return NOTIFICATION_EX_REPORTER_OBJECT_PATH;
+}
+
+} // nampace notification
\ No newline at end of file
#include <string>
#include <list>
-#include "notification-ex/abstract_item.h"
#include "notification-ex/event_info.h"
+#include "notification-ex/event_observer_interface.h"
+#include "notification-ex/event_sender_interface.h"
+#include "notification-ex/event_listener_interface.h"
+#include "notification-ex/abstract_item.h"
#ifndef EXPORT_API
#define EXPORT_API __attribute__((visibility("default")))
namespace notification {
-class EXPORT_API Repoter : public IEventObserver {
+class EXPORT_API Reporter : public IEventObserver {
public:
- Repoter(IEventsSender* sender, IEventsListener* listener);
- virtual ~Repoter();
+ Reporter(IEventSender* sender, IEventListener* listener);
+ virtual ~Reporter();
+ void SendEvent(const EventInfo& info, std::shared_ptr<item::AbstractItem> noti);
void Post(std::shared_ptr<item::AbstractItem> noti);
- void Post(std::list<std::shared_ptr<AbstractItem>> notiList);
- void Update(std::shared_ptr<AbstractItem> noti);
- void Remove(std::shared_ptr<AbstractItem> noti);
- std::shared_ptr<AbstractItem> FindByRootID(std::string id);
- void OnEvent(EventInfo info, std::shared_ptr<AbstractItem> notiList) override;
+ void Post(std::list<std::shared_ptr<item::AbstractItem>> notiList);
+ void Update(std::shared_ptr<item::AbstractItem> noti);
+ void Remove(std::shared_ptr<item::AbstractItem> noti);
+ std::shared_ptr<item::AbstractItem> FindByRootID(std::string id);
+ virtual void OnEvent(const EventInfo& info,
+ std::list<std::shared_ptr<item::AbstractItem>> notiList);
+ virtual std::list<std::shared_ptr<item::AbstractItem>> OnRequestEvent(
+ const EventInfo& info);
+ void OnEvent(const EventInfo& info, std::list<Bundle> serialized) override;
+ std::list<Bundle> OnRequest(const EventInfo& info) override;
+ static std::string GetPath();
private:
- IEventsSender* sender_;
- IEventsListener* receiver_;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // 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_REPORTER_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_REPORTER_IMPLEMENTATION_H_
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "notification-ex/reporter.h"
+
+namespace notification {
+
+class Reporter::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ Impl(Reporter* parent,
+ IEventSender* sender, IEventListener* listener);
+
+ private:
+ friend class Reporter;
+ void SendNotify(std::shared_ptr<item::AbstractItem> noti,
+ EventInfo::EventType type);
+ IEventSender* sender_;
+ IEventListener* listener_;
+ Reporter* parent_;
+};
+
+} // namespace notification
+
+#endif // NOTIFICATION_EX_REPORTER_IMPLEMENTATION_H_
return AbstractItem::Text;
}
-Bundle TextItem::Serialize() {
+Bundle TextItem::Serialize() const {
Bundle b;
b = AbstractItem::Serialize();
std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
virtual ~TextItem();
int GetType() const override;
- Bundle Serialize() override;
+ Bundle Serialize() const override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
void SetContents(std::string contents);
return AbstractItem::Time;
}
-Bundle TimeItem::Serialize() {
+Bundle TimeItem::Serialize() const {
Bundle b;
struct tm* timeinfo;
char buf[80] = {0,};
virtual ~TimeItem();
int GetType() const override;
- Bundle Serialize() override;
+ Bundle Serialize() const override;
void Deserialize(Bundle b) override;
AbstractItem& FindByID(std::string id) override;
time_t GetTime() const;
return AbstractAction::Visibility;
}
-Bundle VisibilityAction::Serialize() {
+Bundle VisibilityAction::Serialize() const {
char buf_key[128];
char buf_data[128];
Bundle b;
virtual ~VisibilityAction();
int GetType() const override;
- Bundle Serialize() override;
+ Bundle Serialize() const override;
void Deserialize(Bundle b) override;
bool IsLocal() const override;
void Execute(std::shared_ptr<AbstractItem> item) override;
BuildRequires: pkgconfig(security-manager)
BuildRequires: pkgconfig(libsmack)
BuildRequires: pkgconfig(gmock)
+BuildRequires: pkgconfig(uuid)
BuildRequires: cmake
Requires(post): /sbin/ldconfig
dlog
gmock
capi-appfw-app-control
+ glib-2.0
+ aul
)
FOREACH(flag ${notification-ex_unittests_CFLAGS})
#include "notification-ex/button_item.h"
#include "notification-ex/item_inflator.h"
+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 notification;
using namespace notification::item;
class ChatMessageItemTest : public ::testing::Test {
#include "notification-ex/checkbox_item.h"
#include "notification-ex/item_inflator.h"
+using namespace notification;
using namespace notification::item;
class CheckBoxItemTest : public ::testing::Test {
#include "notification-ex/entry_item.h"
#include "notification-ex/item_inflator.h"
+using namespace notification;
using namespace notification::item;
namespace {
#include "notification-ex/item_inflator.h"
#include "unittest/mock/app_common.h"
+using namespace notification;
using namespace notification::item;
using namespace std;
#include "notification-ex/icon_item.h"
#include "notification-ex/item_inflator.h"
+using namespace notification;
using namespace notification::item;
class IconItemTest : public ::testing::Test {
#include "notification-ex/icon_text_item.h"
#include "notification-ex/item_inflator.h"
+using namespace notification;
using namespace notification::item;
class IconTextItemTest : public ::testing::Test {
#include "notification-ex/image_item.h"
#include "notification-ex/item_inflator.h"
+using namespace notification;
using namespace notification::item;
class ImageItemTest : public ::testing::Test {
#include "notification-ex/input_selector_item.h"
#include "notification-ex/item_inflator.h"
+using namespace notification;
using namespace notification::item;
using namespace std;
#include "notification-ex/progress_item.h"
#include "notification-ex/item_inflator.h"
+using namespace notification;
using namespace notification::item;
using namespace std;
#include "notification-ex/text_item.h"
#include "notification-ex/item_inflator.h"
+using namespace notification;
using namespace notification::item;
namespace {
#include "notification-ex/time_item.h"
#include "notification-ex/item_inflator.h"
+using namespace notification;
using namespace notification::item;
class TimeItemTest : public ::testing::Test {