extern "C" {
#endif
+#define NOTI_EX_INPUT_SELECTOR_REPLY "__NOTI_EX_INPUT_SELECTOR_REPLY__"
+
int noti_ex_item_free_string_list(char** list, int count);
int noti_ex_item_group_remove_children(noti_ex_item_h handle);
int noti_ex_item_time_set_time(noti_ex_item_h handle, time_t time);
int noti_ex_led_info_set_color(noti_ex_led_info_h handle,
noti_ex_color_h color);
+int noti_ex_item_icon_create(noti_ex_item_h *handle, const char *id,
+ const char *icon_path);
+int noti_ex_item_icon_get_icon_path(noti_ex_item_h handle, char **icon_path);
+
+int noti_ex_item_button_set_image(noti_ex_item_h handle, char *path);
+int noti_ex_item_button_get_image(noti_ex_item_h handle, char **path);
+
+int noti_ex_reporter_delete_by_channel(noti_ex_manager_h handle, char *channel,
+ int *request_id);
+int noti_ex_manager_delete_by_channel(noti_ex_manager_h handle, char *channel,
+ int *request_id);
+
#ifdef __cplusplus
}
#endif
#define LOG_TAG "NOTIFICATION_EX"
#define BUTTON_TITLE_KEY "__BUTTON_TITLE_KEY__"
+#define BUTTON_IMAGE_KEY "__BUTTON_IMAGE_KEY__"
using namespace std;
using namespace tizen_base;
Bundle b;
b = AbstractItem::Serialize();
b.Add(BUTTON_TITLE_KEY, impl_->title_);
+ if (!impl_->img_path_.empty())
+ b.Add(BUTTON_IMAGE_KEY, impl_->img_path_);
return b;
}
void ButtonItem::Deserialize(Bundle b) {
AbstractItem::Deserialize(b);
impl_->title_ = b.GetString(BUTTON_TITLE_KEY);
+ impl_->img_path_ = b.GetString(BUTTON_IMAGE_KEY);
}
bool ButtonItem::IsItemTypeExist(int type) {
return impl_->title_;
}
+void ButtonItem::SetImgPath(string path) {
+ impl_->img_path_ = path;
+}
+
+std::string ButtonItem::GetImgPath() const {
+ return impl_->img_path_;
+}
+
} // namespace item
} // namespace notification
*/
std::string GetTitle() const;
+ /**
+ * @brief Gets the image path of ButtonItem.
+ * @since_tizen 5.5
+ * @return The path of image
+ */
+ std::string GetImgPath() const;
+
+ /**
+ * @brief Sets the image path of ButtonItem.
+ * @since_tizen 5.5
+ * @param[in] path Image path
+ */
+ void SetImgPath(std::string path);
+
private:
class Impl;
std::unique_ptr<Impl> impl_;
friend class ButtonItem;
std::string title_;
+ std::string img_path_;
ButtonItem* parent_;
};
}
list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList(
- string app_id, uid_t uid) {
+ string app_id, uid_t uid, string channel) {
char* query;
list<shared_ptr<item::AbstractItem>> item_list;
- query = sqlite3_mprintf("SELECT data FROM noti_ex_list"
- " WHERE uid = %d AND app_id = %Q ORDER BY insert_time DESC",
- uid, app_id.c_str());
+ if (!channel.empty()) {
+ query = sqlite3_mprintf("SELECT data FROM noti_ex_list WHERE uid = %d "
+ "AND app_id = %Q AND channel = %Q ORDER BY insert_time DESC", uid,
+ app_id.c_str(), channel.c_str());
+ } else {
+ query = sqlite3_mprintf("SELECT data FROM noti_ex_list WHERE uid = %d "
+ "AND app_id = %Q ORDER BY insert_time DESC", uid, app_id.c_str());
+ }
+
if (!query) {
LOGE("OOM - sql query");
return item_list;
static int GetCount(const std::string& app_id, uid_t uid, int* count);
static int DeleteNotification(std::shared_ptr<item::AbstractItem> deletedItem);
static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(uid_t uid, std::string channel = "");
- static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(std::string app_id, uid_t uid);
+ static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(std::string app_id, uid_t uid, std::string channel = "");
static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(std::string app_id, std::string root_id, uid_t uid);
static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(std::string app_id, int64_t private_id, uid_t uid);
return info.GetRequestId();
}
+int Manager::DeleteByChannel(string channel) {
+ Bundle serialized;
+ EventInfo info(EventInfo::DeleteAll, util::GetAppId(), channel);
+ list<Bundle> serialized_list {serialized};
+ impl_->sender_->Notify(info, serialized_list, util::GetAppId());
+ return info.GetRequestId();
+}
+
int Manager::GetCount() const {
EventInfo info(EventInfo::Count, util::GetAppId(), "");
int num = impl_->sender_->RequestNumber(info);
int Update(std::shared_ptr<item::AbstractItem> noti);
int Delete(std::shared_ptr<item::AbstractItem> noti);
int DeleteAll();
+ int DeleteByChannel(std::string channel);
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);
return info.GetRequestId();
}
+int Reporter::DeleteByChannel(string channel) {
+ Bundle serialized;
+ EventInfo info(EventInfo::DeleteAll, util::GetAppId(), channel);
+ list<Bundle> serialized_list {serialized};
+ impl_->sender_->Notify(info, serialized_list, util::GetAppId());
+ return info.GetRequestId();
+}
+
std::unique_ptr<AbstractItem> Reporter::FindByRootID(std::string id) {
Bundle serialized;
EventInfo info(EventInfo::Get, util::GetAppId(), "", id);
int Update(std::shared_ptr<item::AbstractItem> noti);
int Delete(std::shared_ptr<item::AbstractItem> noti);
int DeleteAll();
+ int DeleteByChannel(std::string channel);
std::unique_ptr<item::AbstractItem> FindByRootID(std::string id);
virtual void OnEvent(const IEventInfo& info,
std::list<std::shared_ptr<item::AbstractItem>> notiList);
#include "notification-ex/dbus_event_listener.h"
#include "notification-ex/exception.h"
#include "notification-ex/iitem_info_internal.h"
+#include "notification-ex/icon_item.h"
#ifdef LOG_TAG
#undef LOG_TAG
return NOTI_EX_ERROR_NONE;
}
+extern "C" EXPORT_API int noti_ex_item_button_set_image(
+ noti_ex_item_h handle, char *path) {
+ if (handle == nullptr || path == nullptr) {
+ LOGE("Invalid parameter");
+ return NOTI_EX_ERROR_INVALID_PARAMETER;
+ }
+
+ Handle* h = static_cast<Handle*>(handle);
+ if (!h->IsValidType(AbstractItem::Button)) {
+ LOGE("Invalid handle type");
+ return NOTI_EX_ERROR_INVALID_PARAMETER;
+ }
+
+ ButtonItem* p = static_cast<ButtonItem*>(h->Get());
+ p->SetImgPath(path);
+
+ return NOTI_EX_ERROR_NONE;
+}
+
+extern "C" EXPORT_API int noti_ex_item_button_get_image(
+ noti_ex_item_h handle, char **path) {
+ if (handle == nullptr || path == nullptr) {
+ LOGE("Invalid parameter");
+ return NOTI_EX_ERROR_INVALID_PARAMETER;
+ }
+
+ Handle* h = static_cast<Handle*>(handle);
+ if (!h->IsValidType(AbstractItem::Button)) {
+ LOGE("Invalid handle type");
+ return NOTI_EX_ERROR_INVALID_PARAMETER;
+ }
+
+ ButtonItem* p = static_cast<ButtonItem*>(h->Get());
+ if (!p->GetImgPath().empty())
+ *path = strdup(p->GetImgPath().c_str());
+ else
+ *path = nullptr;
+
+ return NOTI_EX_ERROR_NONE;
+}
+
extern "C" EXPORT_API int noti_ex_item_chat_message_create(
noti_ex_item_h *handle, const char *id, noti_ex_item_h name,
noti_ex_item_h text, noti_ex_item_h image, noti_ex_item_h time,
return NOTI_EX_ERROR_NONE;
}
+extern "C" EXPORT_API int noti_ex_manager_delete_by_channel(
+ noti_ex_manager_h handle, char* channel, int* request_id) {
+ if (handle == nullptr || channel == nullptr || request_id == nullptr) {
+ LOGE("Invalid parameter");
+ return NOTI_EX_ERROR_INVALID_PARAMETER;
+ }
+
+ try {
+ ManagerStub* stub = static_cast<ManagerStub*>(handle);
+ *request_id = stub->DeleteByChannel(channel);
+ } catch (Exception &ex) {
+ LOGE("%s %d", ex.what(), ex.GetErrorCode());
+ return NOTI_EX_ERROR_IO_ERROR;
+ }
+
+ return NOTI_EX_ERROR_NONE;
+}
+
extern "C" EXPORT_API int noti_ex_manager_hide(noti_ex_manager_h handle,
noti_ex_item_h noti, int *request_id) {
if (handle == nullptr || noti == nullptr || request_id == nullptr) {
return NOTI_EX_ERROR_NONE;
}
+extern "C" EXPORT_API int noti_ex_reporter_delete_by_channel(
+ noti_ex_reporter_h handle, char* channel, int* request_id) {
+ if (handle == nullptr || channel == nullptr || request_id == nullptr) {
+ LOGE("Invalid parameter");
+ return NOTI_EX_ERROR_INVALID_PARAMETER;
+ }
+
+ try {
+ ReporterStub* stub = static_cast<ReporterStub*>(handle);
+ *request_id = stub->DeleteByChannel(channel);
+ } catch (Exception &ex) {
+ LOGE("%s %d", ex.what(), ex.GetErrorCode());
+ return NOTI_EX_ERROR_IO_ERROR;
+ }
+
+ return NOTI_EX_ERROR_NONE;
+}
+
extern "C" EXPORT_API int noti_ex_reporter_find_by_root_id(
noti_ex_reporter_h handle, const char *root_id, noti_ex_item_h *item) {
if (handle == nullptr || root_id == nullptr || item == nullptr) {
return NOTI_EX_ERROR_NONE;
}
+
+extern "C" EXPORT_API int noti_ex_item_icon_create(noti_ex_item_h *handle,
+ const char *id, const char *icon_path) {
+ if (handle == nullptr || icon_path == nullptr) {
+ LOGE("Invalid parameter");
+ return NOTI_EX_ERROR_INVALID_PARAMETER;
+ }
+
+ IconItem* p;
+ if (id)
+ p = new (std::nothrow) IconItem(id, icon_path);
+ else
+ p = new (std::nothrow) IconItem(icon_path);
+
+ if (p == nullptr) {
+ LOGE("Out-of-memory");
+ return NOTI_EX_ERROR_OUT_OF_MEMORY;
+ }
+
+ *handle = new Handle(shared_ptr<AbstractItem>(p));
+
+ return NOTI_EX_ERROR_NONE;
+}
+
+int noti_ex_item_icon_get_icon_path(noti_ex_item_h handle, char **icon_path) {
+ if (handle == nullptr || icon_path == nullptr) {
+ LOGE("Invalid parameter");
+ return NOTI_EX_ERROR_INVALID_PARAMETER;
+ }
+
+ Handle* h = static_cast<Handle*>(handle);
+ if (!h->IsValidType(AbstractItem::Icon)) {
+ LOGE("Invalid handle type");
+ return NOTI_EX_ERROR_INVALID_PARAMETER;
+ }
+
+ IconItem* p = static_cast<IconItem*>(h->Get());
+ if (!p->GetImagePath().empty()) {
+ *icon_path = strdup(p->GetImagePath().c_str());
+ if (*icon_path == nullptr) {
+ LOGE("Out-of-memory");
+ return NOTI_EX_ERROR_OUT_OF_MEMORY;
+ }
+ } else {
+ *icon_path = nullptr;
+ }
+
+ return NOTI_EX_ERROR_NONE;
+}