#include <dlog.h>
#include <stdio.h>
#include <stdlib.h>
+#include <notification_type.h>
+#include <notification_viewer.h>
#include <iostream>
#include <sstream>
manager_->SendEvent(info, noti);
}
+ void LaunchDefaultViewer(list<shared_ptr<item::AbstractItem>> item,
+ notification_op_type_e status) {
+ int64_t priv_id;
+ if (item.size() == 0)
+ return;
+
+ if (item.size() > 1)
+ priv_id = NOTIFICATION_PRIV_ID_NONE;
+ else
+ priv_id = static_pointer_cast<IItemInfoInternal>(
+ item.front()->GetInfo())->GetPrivateId();
+
+ LaunchDefaultViewer(priv_id, status,
+ static_pointer_cast<IItemInfoInternal>(
+ item.front()->GetInfo())->GetUid());
+ }
+ void LaunchDefaultViewer(shared_ptr<item::AbstractItem> item,
+ notification_op_type_e status) {
+ LaunchDefaultViewer(
+ static_pointer_cast<IItemInfoInternal>(item->GetInfo())->GetPrivateId(),
+ status,
+ static_pointer_cast<IItemInfoInternal>(item->GetInfo())->GetUid());
+ }
+
+ void LaunchDefaultViewer(int64_t privId, notification_op_type_e status,
+ uid_t uid) {
+ int ret = notification_launch_default_viewer(
+ static_cast<int>(privId), status, uid);
+ if (ret != ERROR_NONE)
+ ERR("Failed to launch default viewer [%d]", ret);
+ }
+
unique_ptr<Reporter> reporter_;
unique_ptr<Manager> manager_;
map<string, string> hide_map_;
ret = DBManager::InsertNotification(addedItem);
if (ret == ERROR_NONE) {
facade_->DelegateReporterEvent(info, addedItem);
+ facade_->LaunchDefaultViewer(addedItem, NOTIFICATION_OP_INSERT);
} else {
DBG("SendError !!!");
SendError(info, static_cast<NotificationError>(ret));
ret = DBManager::UpdateNotification(updatedItem);
if (ret == ERROR_NONE) {
facade_->DelegateReporterEvent(info, updatedItem);
+ facade_->LaunchDefaultViewer(updatedItem, NOTIFICATION_OP_UPDATE);
} else {
SendError(info, static_cast<NotificationError>(ret));
}
}
- void DoDelete(const IEventInfo& info,
+ int DoDelete(const IEventInfo& info,
shared_ptr<item::AbstractItem> deletedItem) {
int ret = DBManager::DeleteNotification(deletedItem);
if (ret == ERROR_NONE) {
} else {
SendError(info, static_cast<NotificationError>(ret));
}
+ return ret;
}
void OnDelete(const IEventInfo& info,
for (auto& i : noti_list) {
DoDelete(info, i);
}
+ facade_->LaunchDefaultViewer(noti_list, NOTIFICATION_OP_DELETE_ALL);
} else {
- DoDelete(info, deletedItem);
+ int ret = DoDelete(info, deletedItem);
+ if (ret == ERROR_NONE)
+ facade_->LaunchDefaultViewer(deletedItem, NOTIFICATION_OP_DELETE);
}
}
unique_ptr<DBusSender>(new DBusSender(Reporter::GetPath())),
unique_ptr<DBusEventListener>(new DBusEventListener(Manager::GetPath())))));
+ notification_init_default_viewer();
+
return ERROR_NONE;
}
static GList *_dnd_alarm_id_list;
-static char *default_viewer;
-
typedef struct _dnd_alarm_id {
uid_t uid;
alarm_id_t dnd_start_id;
return ret;
}
- if (default_viewer != NULL) {
- ret = notification_launch_default_viewer(default_viewer,
- priv_id, NOTIFICATION_OP_INSERT, uid);
- if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Failed to launch default viewer [%d]", ret);
- ret = NOTIFICATION_ERROR_NONE;
- }
+ ret = notification_launch_default_viewer(priv_id,
+ NOTIFICATION_OP_INSERT, uid);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ ERR("Failed to launch default viewer [%d]", ret);
+ ret = NOTIFICATION_ERROR_NONE;
}
+
*reply_body = g_variant_new("(i)", priv_id);
if (*reply_body == NULL) {
ERR("Failed to make reply");
return ret;
}
- if (default_viewer != NULL) {
- ret = notification_launch_default_viewer(default_viewer,
- priv_id, NOTIFICATION_OP_UPDATE, uid);
- if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Failed to launch default viewer [%d]", ret);
- ret = NOTIFICATION_ERROR_NONE;
- }
+ ret = notification_launch_default_viewer(priv_id,
+ NOTIFICATION_OP_UPDATE, uid);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ ERR("Failed to launch default viewer [%d]", ret);
+ ret = NOTIFICATION_ERROR_NONE;
}
*reply_body = g_variant_new("(i)", priv_id);
if (ret != NOTIFICATION_ERROR_NONE)
return ret;
- if (default_viewer != NULL) {
- ret = notification_launch_default_viewer(default_viewer,
- NOTIFICATION_PRIV_ID_NONE,
- NOTIFICATION_OP_DELETE,
- uid);
- if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Failed to launch default viewer [%d]", ret);
- ret = NOTIFICATION_ERROR_NONE;
- }
+ ret = notification_launch_default_viewer(NOTIFICATION_PRIV_ID_NONE,
+ NOTIFICATION_OP_DELETE,
+ uid);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ ERR("Failed to launch default viewer [%d]", ret);
+ ret = NOTIFICATION_ERROR_NONE;
}
}
free(list_deleted);
- if (default_viewer != NULL) {
- ret = notification_launch_default_viewer(default_viewer,
- NOTIFICATION_PRIV_ID_NONE,
- NOTIFICATION_OP_DELETE_ALL,
- param_uid);
- if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Failed to launch default viewer [%d]", ret);
- ret = NOTIFICATION_ERROR_NONE;
- }
+ ret = notification_launch_default_viewer(NOTIFICATION_PRIV_ID_NONE,
+ NOTIFICATION_OP_DELETE_ALL,
+ param_uid);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ ERR("Failed to launch default viewer [%d]", ret);
+ ret = NOTIFICATION_ERROR_NONE;
}
}
return ret;
}
- if (default_viewer != NULL) {
- ret = notification_launch_default_viewer(default_viewer,
- NOTIFICATION_PRIV_ID_NONE,
- NOTIFICATION_OP_DELETE_ALL,
- param_uid);
- if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Failed to launch default viewer [%d]", ret);
- ret = NOTIFICATION_ERROR_NONE;
- }
+ ret = notification_launch_default_viewer(NOTIFICATION_PRIV_ID_NONE,
+ NOTIFICATION_OP_DELETE_ALL,
+ param_uid);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ ERR("Failed to launch default viewer [%d]", ret);
+ ret = NOTIFICATION_ERROR_NONE;
}
}
*/
HAPI int notification_service_init(void)
{
-#define DEFAULT_VIEWER_CONF_FILE "/usr/share/notification/notification.ini"
-
int ret, i;
int count = 0;
uid_t *uids = NULL;
return NOTIFICATION_ERROR_IO_ERROR;
}
- notification_get_default_viewer(DEFAULT_VIEWER_CONF_FILE, &default_viewer);
+ notification_init_default_viewer();
notification_noti_init_data();
notification_system_setting_init_system_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER));