impl_->uid_ = uid;
}
-int AbstractItem::GetRequestId() {
- return impl_->request_id_;
-}
-
} // namespace item
} // namespace notification
time_t GetTime();
int GetUid();
void SetUid(int uid);
- int GetRequestId();
private:
class Impl;
} // namespace notification
#endif // NOTIFICATION_EX_APP_CONTROL_ACTION_H_
-
}; // class ChatMessageItem
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_CHAT_MESSAGE_ITEM_H_
};
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_CHAT_MESSAGE_ITEM_IMPLEMENTATION_H_
CheckBoxItem::Impl::~Impl() = default;
} // namespace item
-} // namespace notification_ex
+} // namespace notification
}; // class CheckBoxItem
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_CHECKBOX_ITEM_H_
};
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_CHECKBOX_ITEM_IMPLEMENTATION_H_
return NOTIFICATION_ERROR_NONE;
}
-} // nampace notification
+} // namespace notification
return impl_->observer_->OnRequest(info);
}
-} // nampace notification
+} // namespace notification
DBusEventListener* parent_;
};
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_DBUS_EVENT_LISTENER_IMPLEMENTATION_H_
return ret_list;
}
-} // nampace notification
+} // namespace notification
DBusSender* parent_;
};
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_DBUS_SENDER_IMPLEMENTATION_H_
\ No newline at end of file
}; // class EntryItem
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_ENTRY_ITEM_H_
\ No newline at end of file
#include "notification-ex/event_info_internal.h"
#include "notification-ex/event_info_implementation.h"
+#include "notification-ex/ex_util.h"
#ifdef LOG_TAG
#undef LOG_TAG
#define NOTIFICATION_EX_EVENT_ITEM_ID_KEY "__NOTIFICATION_EX_EVENT_ITEM_ID_KEY__"
#define NOTIFICATION_EX_EVENT_TAG_KEY "__NOTIFICATION_EX_EVENT_TAG_KEY__"
#define NOTIFICATION_EX_EVENT_UID_KEY "__NOTIFICATION_EX_EVENT_UID_KEY__"
+#define NOTIFICATION_EX_EVENT_REQUEST_ID_KEY "__NOTIFICATION_EX_EVENT_REQUEST_ID_KEY__"
using namespace std;
namespace notification {
-EventInfo::EventInfo(IEventInfo::EventType type, std::string owner,
- std::string channel, std::string item_id, std::string tag)
+EventInfo::EventInfo(IEventInfo::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, IEventInfo::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) {
+EventInfo::Impl::Impl(EventInfo* parent,
+ IEventInfo::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) {
uid_ = getuid();
+ request_id_ = util::GetRequestId();
LOGI("EventInfo impl created");
}
impl_->tag_ = serialized.GetString(NOTIFICATION_EX_EVENT_TAG_KEY);
string uid_str = serialized.GetString(NOTIFICATION_EX_EVENT_UID_KEY);
impl_->uid_ = (uid_t)strtol(uid_str.c_str(), NULL, 10);
+ string request_id_str =
+ serialized.GetString(NOTIFICATION_EX_EVENT_REQUEST_ID_KEY);
+ impl_->request_id_ = (int)strtol(request_id_str.c_str(), NULL, 10);
}
string EventInfo::GetString(IEventInfo::EventType type) {
serialized.Add(NOTIFICATION_EX_EVENT_ITEM_ID_KEY, impl_->item_id_);
serialized.Add(NOTIFICATION_EX_EVENT_TAG_KEY, impl_->tag_);
serialized.Add(NOTIFICATION_EX_EVENT_UID_KEY, to_string((int)impl_->uid_));
+ serialized.Add(
+ NOTIFICATION_EX_EVENT_REQUEST_ID_KEY, to_string(impl_->request_id_));
return serialized;
}
impl_->uid_ = uid;
}
+int EventInfo::GetRequestId() const {
+ return impl_->request_id_;
+}
+
} // namespace notification
private:
friend class EventInfo;
- Impl(EventInfo* parent, IEventInfo::EventType type, std::string owner,
- std::string channel, std::string item_id, std::string tag);
+ Impl(EventInfo* parent, IEventInfo::EventType type,
+ std::string owner, std::string channel,
+ std::string item_id, std::string tag);
private:
EventType type_;
std::string item_id_;
std::string tag_;
uid_t uid_;
+ int request_id_;
EventInfo* parent_;
};
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_EVENT_INFO_IMPLEMENTATION_H_
\ No newline at end of file
std::string GetChannel() const override;
std::string GetItemId() const override;
std::string GetTag() const override;
+ int GetRequestId() const override;
Bundle Serialize() const override;
static std::string GetString(EventType type);
return 0;
}
- int Remove(const std::string& key) {
+ int Delete(const std::string& key) {
return bundle_del(handle_, key.c_str());
}
return g_quark_to_string(quark);
}
+int GetRequestId() {
+ static int id = 0;
+ g_atomic_int_inc(&id);
+ return id;
+}
+
string GetAppId() {
static string appid = "";
char appid_buf[MAX_PACKAGE_STR_SIZE] = {0, };
std::string GetAppId();
GQuark GetQuarkFromString(std::string str);
std::string GetQuarkToString(GQuark quark);
+ int GetRequestId();
} // namespace util
} // namespace notification
}
} // namespace item
-} // namespace notification_ex
-
+} // namespace notification
}; // class IconItem
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_ICON_ITEM_H_
};
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_ICON_ITEM_IMPLEMENTATION_H_
}; // class IconTextItem
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_ICON_TEXT_ITEM_H_
};
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_ICON_TEXT_ITEM_IMPLEMENTATION_H_
virtual std::string GetChannel() const = 0;
virtual std::string GetItemId() const = 0;
virtual std::string GetTag() const = 0;
+ virtual int GetRequestId() const = 0;
virtual Bundle Serialize() const = 0;
};
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_IEVENT_INFO_H_
virtual void SetUid(uid_t uid) = 0;
};
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_IEVENT_INFO_INTERNAL_H_
};
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_IITEM_INFO_H_
};
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_IITEM_INFO_INTERNAL_H_
}; //class ImageItem
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_IMAGE_ITEM_H_
};
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_IMAGE_ITEM_IMPLEMENTATION_H_
* limitations under the License.
*/
-#ifndef NOTIFICATION_EX_ITEM_INFO_H_
-#define NOTIFICATION_EX_ITEM_INFO_H_
+#ifndef NOTIFICATION_EX_ITEM_INFO_INTERNAL_H_
+#define NOTIFICATION_EX_ITEM_INFO_INTERNAL_H_
#include "notification-ex/abstract_item_implementation.h"
#include "notification-ex/iitem_info_internal.h"
};
} // namespace item
-} // nampace notification
-#endif // NOTIFICATION_EX_ITEM_INFO_H_
+} // namespace notification
+#endif // NOTIFICATION_EX_ITEM_INFO_INTERNAL_H_
listener_->RegisterObserver(parent_);
}
-void Manager::Impl::SendNotify(shared_ptr<item::AbstractItem> noti,
+int Manager::Impl::SendNotify(shared_ptr<item::AbstractItem> noti,
IEventInfo::EventType type) {
Bundle serialized = noti->Serialize();
EventInfo info(type, util::GetAppId(), noti->GetChannel());
/* Reply to Sender */
sender_->Notify(info, serialized_list, noti->GetSenderAppId());
+ return info.GetRequestId();
}
-void Manager::Update(shared_ptr<item::AbstractItem> noti) {
- impl_->SendNotify(noti, EventInfo::Update);
+int Manager::Update(shared_ptr<item::AbstractItem> noti) {
+ return impl_->SendNotify(noti, EventInfo::Update);
}
-void Manager::Remove(shared_ptr<item::AbstractItem> noti) {
- impl_->SendNotify(noti, EventInfo::Delete);
+int Manager::Delete(shared_ptr<item::AbstractItem> noti) {
+ return impl_->SendNotify(noti, EventInfo::Delete);
}
-void Manager::Hide(shared_ptr<item::AbstractItem> noti) {
+int Manager::Hide(shared_ptr<item::AbstractItem> noti) {
((IItemInfoInternal*)noti->GetInfo().get())->AddHideViewer(util::GetAppId());
- impl_->SendNotify(noti, EventInfo::Update);
+ return impl_->SendNotify(noti, EventInfo::Update);
}
shared_ptr<item::AbstractItem> Manager::FindByRootID(string id) {
return gen_list;
}
-void Manager::SendEvent(const IEventInfo& info,
+int Manager::SendEvent(const IEventInfo& 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());
+ return info.GetRequestId();
}
list<Bundle> Manager::OnRequest(const IEventInfo& info) {
return NOTIFICATION_EX_MANAGER_OBJECT_PATH;
}
-} // nampace notification
+} // namespace notification
#include <list>
#include <memory>
+#include "notification-ex/common.h"
#include "notification-ex/abstract_item.h"
#include "notification-ex/event_observer_interface.h"
#include "notification-ex/event_sender_interface.h"
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);
+ int Update(std::shared_ptr<item::AbstractItem> noti);
+ int Delete(std::shared_ptr<item::AbstractItem> noti);
+ int Hide(std::shared_ptr<item::AbstractItem> noti);
std::shared_ptr<item::AbstractItem> FindByRootID(std::string id);
- void SendEvent(const IEventInfo& info, std::shared_ptr<item::AbstractItem> noti);
+ int SendEvent(const IEventInfo& info, std::shared_ptr<item::AbstractItem> noti);
void OnEvent(const IEventInfo& info, std::list<Bundle> serialized) override;
std::list<Bundle> OnRequest(const IEventInfo& info) override;
static std::string GetPath();
private:
friend class Manager;
- void SendNotify(std::shared_ptr<item::AbstractItem> noti,
+ int SendNotify(std::shared_ptr<item::AbstractItem> noti,
IEventInfo::EventType type);
std::unique_ptr<IEventSender> sender_;
std::unique_ptr<IEventListener> listener_;
listener_->RegisterObserver(parent_);
}
-void Reporter::Impl::SendNotify(shared_ptr<item::AbstractItem> noti,
+int Reporter::Impl::SendNotify(shared_ptr<item::AbstractItem> noti,
IEventInfo::EventType type) {
Bundle serialized = noti->Serialize();
EventInfo info(type, util::GetAppId(), noti->GetChannel());
list<Bundle> serialized_list {serialized};
sender_->Notify(info, serialized_list);
+ return info.GetRequestId();
}
-void Reporter::Post(std::shared_ptr<item::AbstractItem> noti) {
+int Reporter::Post(std::shared_ptr<item::AbstractItem> noti) {
LOGI("Post noti");
- impl_->SendNotify(noti, EventInfo::Post);
+ return impl_->SendNotify(noti, EventInfo::Post);
}
-void Reporter::Post(std::list<std::shared_ptr<AbstractItem>> notiList) {
+int Reporter::Post(std::list<std::shared_ptr<AbstractItem>> notiList) {
EventInfo info(EventInfo::Post, util::GetAppId(), "");
list<Bundle> serialized_list;
for (auto& i : notiList) {
serialized_list.push_back(b);
}
impl_->sender_->Notify(info, serialized_list);
+ return info.GetRequestId();
}
-void Reporter::Update(std::shared_ptr<AbstractItem> noti) {
- impl_->SendNotify(noti, EventInfo::Update);
+int Reporter::Update(std::shared_ptr<AbstractItem> noti) {
+ return impl_->SendNotify(noti, EventInfo::Update);
}
-void Reporter::Remove(std::shared_ptr<AbstractItem> noti) {
- impl_->SendNotify(noti, EventInfo::Delete);
+int Reporter::Delete(std::shared_ptr<AbstractItem> noti) {
+ return impl_->SendNotify(noti, EventInfo::Delete);
}
std::shared_ptr<AbstractItem> Reporter::FindByRootID(std::string id) {
return gen_item;
}
-void Reporter::SendEvent(const IEventInfo& info,
+int Reporter::SendEvent(const IEventInfo& info,
shared_ptr<item::AbstractItem> noti) {
Bundle serialized = noti->Serialize();
list<Bundle> serialized_list {serialized};
impl_->sender_->Notify(info, serialized_list);
+ return info.GetRequestId();
}
void Reporter::OnEvent(const IEventInfo& info, list<Bundle> serialized) {
return NOTIFICATION_EX_REPORTER_OBJECT_PATH;
}
-} // nampace notification
+} // namespace notification
std::unique_ptr<IEventListener> listener);
virtual ~Reporter();
- void SendEvent(const IEventInfo& info, std::shared_ptr<item::AbstractItem> noti);
- void Post(std::shared_ptr<item::AbstractItem> noti);
- 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);
+ int SendEvent(const IEventInfo& info, std::shared_ptr<item::AbstractItem> noti);
+ int Post(std::shared_ptr<item::AbstractItem> noti);
+ int Post(std::list<std::shared_ptr<item::AbstractItem>> notiList);
+ int Update(std::shared_ptr<item::AbstractItem> noti);
+ int Delete(std::shared_ptr<item::AbstractItem> noti);
std::shared_ptr<item::AbstractItem> FindByRootID(std::string id);
virtual void OnEvent(const IEventInfo& info,
std::list<std::shared_ptr<item::AbstractItem>> notiList);
private:
friend class Reporter;
- void SendNotify(std::shared_ptr<item::AbstractItem> noti,
+ int SendNotify(std::shared_ptr<item::AbstractItem> noti,
IEventInfo::EventType type);
std::unique_ptr<IEventSender> sender_;
std::unique_ptr<IEventListener> listener_;
}; // class TextItem
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_TEXT_ITEM_H_
\ No newline at end of file
TimeItem::Impl::~Impl() = default;
} // namespace item
-} // namespace notification_ex
+} // namespace notification
}; // class TimeItem
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_TIME_ITEM_H_
};
} // namespace item
-} // nampace notification
+} // namespace notification
#endif // NOTIFICATION_EX_TIME_ITEM_IMPLEMENTATION_H_
ASSERT_EQ(gen_test->GetId(), "test_id");
ASSERT_EQ(gen_test->GetType(), MY_ITEM_TYPE);
ASSERT_EQ(gen_test->GetUid(), 3);
- ASSERT_EQ(gen_test->GetRequestId(), 0);
ASSERT_EQ(gen_test->GetEnable(), false);
ASSERT_EQ(gen_test->GetVisible(),false);
ASSERT_EQ(gen_test->GetPolicy(), AbstractItem::Policy::OnBootClear);
EXPECT_EQ(bundle.GetCount(), 2);
}
-TEST(Bundle, Remove) {
+TEST(Bundle, Delete) {
Bundle bundle;
int r = bundle.Add("TestKey1", "TestVal1");
EXPECT_EQ(r, 0);
- r = bundle.Remove("TestKey1");
+ r = bundle.Delete("TestKey1");
EXPECT_EQ(r, 0);
EXPECT_EQ(bundle.GetString("TestKey1"), "");