]> Chaos Git - corbenik/ctrulib.git/commitdiff
Add 2 more missing news:s functions
authorLázaro Vieira <lazaro-e-nemo@hotmail.com>
Sat, 21 May 2016 19:51:31 +0000 (16:51 -0300)
committerLázaro Vieira <lazaro-e-nemo@hotmail.com>
Sat, 21 May 2016 19:51:31 +0000 (16:51 -0300)
-Add NEWS_SetNotificationMessage
-Add NEWS_SetNotificationImage
-NULL reference handling for NEWS_GetNotificationImage

libctru/include/3ds/services/news.h
libctru/source/services/news.c

index 15c54ae8547e0b6fe3f3bde94eaaf9b997f467f1..6403f1beb7ee8021e0715f6b59ff120b5ffeef4b 100644 (file)
@@ -58,12 +58,29 @@ Result NEWS_SetNotificationHeader(u32 news_id, const 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.
  * @param news_id Identification number of the notification.
  * @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, 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_GetNotificationMessage(u32 news_id, u16* message);
+Result NEWS_SetNotificationImage(u32 news_id, const void* buffer, u32 size);
 
 /**
  * @brief Gets the image of a specific notification.
index 32048bca432449cff5ef8764adff7d4a88ec8120..cf7663d0ee75b5b6e5b2b8357efcb2227aabe105 100644 (file)
@@ -90,7 +90,7 @@ Result NEWS_SetNotificationHeader(u32 news_id, const NotificationHeader* header)
        cmdbuf[4] = (u32)header;
        
        if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
-       return (Result)cmdbuf[1];       
+       return (Result)cmdbuf[1];
 }
 
 Result NEWS_GetNotificationHeader(u32 news_id, NotificationHeader* header)
@@ -108,7 +108,22 @@ Result NEWS_GetNotificationHeader(u32 news_id, NotificationHeader* header)
        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;
        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[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;
        return (Result)cmdbuf[1];
 }
@@ -135,6 +166,6 @@ Result NEWS_GetNotificationImage(u32 news_id, void* buffer, u32* size)
        cmdbuf[4] = (u32)buffer;
        
        if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
-       *size = cmdbuf[2];
-       return (Result)cmdbuf[1];       
+       if(size) *size = cmdbuf[2];
+       return (Result)cmdbuf[1];
 }
\ No newline at end of file