#include <pkgmgr-info.h>
#include <bundle.h>
#include <bundle_internal.h>
+#include <tzplatform_config.h>
#include <iostream>
#include <sstream>
ERR("Failed to launch default viewer [%d]", ret);
}
+ uid_t GetUid(const IEventInfo& info) {
+ uid_t validated_uid =
+ static_cast<const IEventInfoInternal&>(info).GetValidatedUid();
+
+ return validated_uid > NORMAL_UID_BASE ?
+ validated_uid : tzplatform_getuid(TZ_SYS_DEFAULT_USER);
+ }
unique_ptr<Reporter> reporter_;
unique_ptr<Manager> manager_;
map<string, string> hide_map_;
DBG("Delete !!!");
if (info.GetEventType() == IEventInfo::EventType::DeleteAll) {
list<shared_ptr<item::AbstractItem>> noti_list =
- DBManager::GetNotificationList(((const IEventInfoInternal&)info).GetUid());
+ DBManager::GetNotificationList(facade_->GetUid(info));
for (auto& i : noti_list) {
DoDelete(info, i);
}
list<shared_ptr<item::AbstractItem>> item_list;
DBG("Get report !!! %s", info.GetItemId().c_str());
- item_list = DBManager::GetNotificationList(
- ((const IEventInfoInternal&)info).GetUid(),
+ item_list = DBManager::GetNotificationList(facade_->GetUid(info),
((const IEventInfoInternal&)info).GetChannel().c_str());
facade_->shared_file_.SetPrivateSharing(item_list,
int OnRequestNumber(const IEventInfo& info) override {
DBG("Get count !!! %s", info.GetItemId().c_str());
- return DBManager::GetNotificationList(
- ((const IEventInfoInternal&)info).GetUid()).size();
+ return DBManager::GetNotificationList(facade_->GetUid(info)).size();
}
int UpdateHideApp(shared_ptr<item::AbstractItem> updatedItem) {
DBG("Add !!!");
int ret;
+ ret = ValidateUid(info, addedItem);
+ if (ret != ERROR_NONE) {
+ SendError(info, static_cast<NotificationError>(ret));
+ return;
+ }
+
SetIndirectRequest(info, addedItem);
ret = DBManager::InsertNotification(addedItem);
DBG("Update !!!");
int ret;
+ ret = ValidateUid(info, updatedItem);
+ if (ret != ERROR_NONE) {
+ SendError(info, static_cast<NotificationError>(ret));
+ return;
+ }
+
UpdateHideApp(updatedItem);
SetIndirectRequest(info, updatedItem);
DBG("Delete !!!");
if (info.GetEventType() == IEventInfo::EventType::DeleteAll) {
list<shared_ptr<item::AbstractItem>> noti_list =
- DBManager::GetNotificationList(info.GetOwner(),
- ((const IEventInfoInternal&)info).GetUid());
+ DBManager::GetNotificationList(info.GetOwner(), facade_->GetUid(info));
for (auto& i : noti_list) {
DoDelete(info, i);
}
list<shared_ptr<item::AbstractItem>> OnRequestEvent(const IEventInfo& info) override {
DBG("Get !!! %s", info.GetOwner().c_str());
+ uid_t uid = facade_->GetUid(info);
if (info.GetItemId().empty()) {
/* get */
- return DBManager::GetNotificationList(info.GetOwner(),
- ((const IEventInfoInternal&)info).GetUid());
+ return DBManager::GetNotificationList(info.GetOwner(), uid);
} else {
/* FindByRootID */
- return DBManager::GetNotificationList(info.GetOwner(), info.GetItemId(),
- ((const IEventInfoInternal&)info).GetUid());
+ return DBManager::GetNotificationList(info.GetOwner(), info.GetItemId(), uid);
}
}
bundle_free(b);
}
+ int ValidateUid(const IEventInfo& info, list<shared_ptr<AbstractItem>> addedItem) {
+ int ret;
+ for (auto& i : addedItem) {
+ ret = ValidateUid(info, i);
+ if (ret != ERROR_NONE)
+ return ret;
+ }
+
+ return ERROR_NONE;
+ }
+
+ int ValidateUid(const IEventInfo& info, shared_ptr<AbstractItem> addedItem) {
+ uid_t validated_uid = static_cast<const IEventInfoInternal&>(info).GetValidatedUid();
+ uid_t item_uid = static_pointer_cast<IItemInfoInternal>
+ (addedItem->GetInfo())->GetUid();
+
+ if (validated_uid <= NORMAL_UID_BASE) {
+ static_pointer_cast<IItemInfoInternal>
+ (addedItem->GetInfo())->SetUid(tzplatform_getuid(TZ_SYS_DEFAULT_USER));
+ } else if (validated_uid != item_uid) {
+ ERR("Invalid sender uid[%d] noti_uid[%d]", validated_uid, item_uid);
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ return ERROR_NONE;
+ }
+
public:
DPMManager(std::unique_ptr<IEventSender> sender,
std::unique_ptr<IEventListener> listener)