Add 2 more missing news:s functions

-Add NEWS_SetNotificationMessage
-Add NEWS_SetNotificationImage
-NULL reference handling for NEWS_GetNotificationImage
This commit is contained in:
Lázaro Vieira 2016-05-21 16:51:31 -03:00
parent 7ce124e744
commit c36bdb9013
2 changed files with 53 additions and 5 deletions

View File

@ -58,12 +58,29 @@ Result NEWS_SetNotificationHeader(u32 news_id, const NotificationHeader* header)
*/ */
Result NEWS_GetNotificationHeader(u32 news_id, NotificationHeader* header); Result NEWS_GetNotificationHeader(u32 news_id, NotificationHeader* header);
/**
* @brief Sets a custom message for a specific notification.
* @param news_id Identification number of the notification.
* @param message Pointer to UTF-16 message to set.
* @param size Size of message to set.
*/
Result NEWS_SetNotificationMessage(u32 news_id, const u16* message, u32 size);
/** /**
* @brief Gets the message of a specific notification. * @brief Gets the message of a specific notification.
* @param news_id Identification number of the notification. * @param news_id Identification number of the notification.
* @param message Pointer where UTF-16 message of the notification will be saved. * @param message Pointer where UTF-16 message of the notification will be saved.
* @param size Pointer where size of the message data will be saved in bytes.
*/ */
Result NEWS_GetNotificationMessage(u32 news_id, u16* message); Result NEWS_GetNotificationMessage(u32 news_id, u16* message, u32* size);
/**
* @brief Sets a custom image for a specific notification.
* @param news_id Identification number of the notification.
* @param buffer Pointer to MPO image to set.
* @param size Size of the MPO image to set.
*/
Result NEWS_SetNotificationImage(u32 news_id, const void* buffer, u32 size);
/** /**
* @brief Gets the image of a specific notification. * @brief Gets the image of a specific notification.

View File

@ -90,7 +90,7 @@ Result NEWS_SetNotificationHeader(u32 news_id, const NotificationHeader* header)
cmdbuf[4] = (u32)header; cmdbuf[4] = (u32)header;
if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret; if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }
Result NEWS_GetNotificationHeader(u32 news_id, NotificationHeader* header) Result NEWS_GetNotificationHeader(u32 news_id, NotificationHeader* header)
@ -108,7 +108,22 @@ Result NEWS_GetNotificationHeader(u32 news_id, NotificationHeader* header)
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }
Result NEWS_GetNotificationMessage(u32 news_id, u16* message) Result NEWS_SetNotificationMessage(u32 news_id, const u16* message, u32 size)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x8,2,2);
cmdbuf[1] = news_id;
cmdbuf[2] = size;
cmdbuf[3] = IPC_Desc_Buffer((size_t)0x1780,IPC_BUFFER_R);
cmdbuf[4] = (u32)message;
if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
return (Result)cmdbuf[1];
}
Result NEWS_GetNotificationMessage(u32 news_id, u16* message, u32* size)
{ {
Result ret = 0; Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer(); u32 *cmdbuf = getThreadCommandBuffer();
@ -119,6 +134,22 @@ Result NEWS_GetNotificationMessage(u32 news_id, u16* message)
cmdbuf[3] = IPC_Desc_Buffer((size_t)0x1780,IPC_BUFFER_W); cmdbuf[3] = IPC_Desc_Buffer((size_t)0x1780,IPC_BUFFER_W);
cmdbuf[4] = (u32)message; cmdbuf[4] = (u32)message;
if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
if(size) *size = cmdbuf[2];
return (Result)cmdbuf[1];
}
Result NEWS_SetNotificationImage(u32 news_id, const void* buffer, u32 size)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = IPC_MakeHeader(0x9,2,2);
cmdbuf[1] = news_id;
cmdbuf[2] = size;
cmdbuf[3] = IPC_Desc_Buffer((size_t)0x10000,IPC_BUFFER_R);
cmdbuf[4] = (u32)buffer;
if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret; if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }
@ -135,6 +166,6 @@ Result NEWS_GetNotificationImage(u32 news_id, void* buffer, u32* size)
cmdbuf[4] = (u32)buffer; cmdbuf[4] = (u32)buffer;
if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret; if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
*size = cmdbuf[2]; if(size) *size = cmdbuf[2];
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }