]> Chaos Git - corbenik/ctrulib.git/commitdiff
Added some missing news:s funcs and updated header.
authorRinnegatamante <rinnegatamante@gmail.com>
Sat, 23 Jan 2016 11:47:14 +0000 (12:47 +0100)
committerRinnegatamante <rinnegatamante@gmail.com>
Sat, 23 Jan 2016 11:47:14 +0000 (12:47 +0100)
Added some missing news:s funcs and updated header.

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

index 5c265f687a6a17b2696e609417fce6dff11c3047..15c54ae8547e0b6fe3f3bde94eaaf9b997f467f1 100644 (file)
@@ -4,6 +4,22 @@
  */
 #pragma once
 
+/// Notification header data.
+typedef struct {
+       bool dataSet;
+       bool unread;
+       bool enableJPEG;
+       bool isSpotPass;
+       bool isOptedOut;
+       u8 unkData[3];
+       u64 processID;
+       u8 unkData2[8];
+       u64 jumpParam;
+       u8 unkData3[8];
+       u64 time;
+       u16 title[32];
+} NotificationHeader;
+
 /// Initializes NEWS.
 Result newsInit(void);
 
@@ -21,3 +37,38 @@ void newsExit(void);
  * @param jpeg Whether the image is a JPEG or not.
  */
 Result NEWS_AddNotification(const u16* title, u32 titleLength, const u16* message, u32 messageLength, const void* imageData, u32 imageSize, bool jpeg);
+
+/**
+ * @brief Gets current total notifications number.
+ * @param num Pointer where total number will be saved.
+ */
+Result NEWS_GetTotalNotifications(u32* num);
+
+/**
+ * @brief Sets a custom header for a specific notification.
+ * @param news_id Identification number of the notification.
+ * @param header Pointer to notification header to set.
+ */
+Result NEWS_SetNotificationHeader(u32 news_id, const NotificationHeader* header);
+
+/**
+ * @brief Gets the header of a specific notification.
+ * @param news_id Identification number of the notification.
+ * @param header Pointer where header of the notification will be saved.
+ */
+Result NEWS_GetNotificationHeader(u32 news_id, NotificationHeader* header);
+
+/**
+ * @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.
+ */
+Result NEWS_GetNotificationMessage(u32 news_id, u16* message);
+
+/**
+ * @brief Gets the image of a specific notification.
+ * @param news_id Identification number of the notification.
+ * @param buffer Pointer where MPO image of the notification will be saved.
+ * @param size Pointer where size of the image data will be saved in bytes.
+ */
+Result NEWS_GetNotificationImage(u32 news_id, void* buffer, u32* size);
\ No newline at end of file
index c2108cc15d623433210f56351d9653dd7c010c7d..206d1b48f52176fd9eb59b88706fe8ac060e5b8a 100644 (file)
@@ -8,18 +8,6 @@
 #include <3ds/services/news.h>
 #include <3ds/ipc.h>
 
-typedef struct {
-       bool dataSet;
-       bool unread;
-       bool enableJPEG;
-       u8 unkFlag1;
-       u8 unkFlag2;
-       u64 processID;
-       u8 unkData[24];
-       u64 time;
-       u16 title[32];
-} NotificationHeader;
-
 static Handle newsHandle;
 static int newsRefCount;
 static bool useNewsS;
@@ -75,3 +63,77 @@ Result NEWS_AddNotification(const u16* title, u32 titleLength, const u16* messag
 
        return (Result)cmdbuf[1];
 }
+
+Result NEWS_GetTotalNotifications(u32* num)
+{
+       Result ret = 0;
+       u32 *cmdbuf = getThreadCommandBuffer();
+
+       cmdbuf[0] = IPC_MakeHeader(0x5,0,0);
+       
+       if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
+       
+       *num = cmdbuf[2];
+       return (Result)cmdbuf[1];
+}
+
+Result NEWS_SetNotificationHeader(u32 news_id, const NotificationHeader* header)
+{
+       Result ret = 0;
+       u32 *cmdbuf = getThreadCommandBuffer();
+
+       cmdbuf[0] = IPC_MakeHeader(0x7,2,2);
+       cmdbuf[1] = news_id;
+       cmdbuf[2] = sizeof(NotificationHeader);
+       cmdbuf[3] = IPC_Desc_Buffer(sizeof(NotificationHeader),IPC_BUFFER_R);
+       cmdbuf[4] = (u32)header;
+       
+       if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
+       return (Result)cmdbuf[1];       
+}
+
+Result NEWS_GetNotificationHeader(u32 news_id, NotificationHeader* header)
+{
+       Result ret = 0;
+       u32 *cmdbuf = getThreadCommandBuffer();
+
+       cmdbuf[0] = IPC_MakeHeader(0xB,2,2);
+       cmdbuf[1] = news_id;
+       cmdbuf[2] = sizeof(NotificationHeader);
+       cmdbuf[3] = IPC_Desc_Buffer(sizeof(NotificationHeader),IPC_BUFFER_W);
+       cmdbuf[4] = (u32)header;
+       
+       if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
+       return (Result)cmdbuf[1];
+}
+
+Result NEWS_GetNotificationMessage(u32 news_id, u16* message)
+{
+       Result ret = 0;
+       u32 *cmdbuf = getThreadCommandBuffer();
+
+       cmdbuf[0] = IPC_MakeHeader(0xC,2,2);
+       cmdbuf[1] = news_id;
+       cmdbuf[2] = 0x1780; // Default size used by Notifications Applet
+       cmdbuf[3] = IPC_Desc_Buffer((size_t)0x1780,IPC_BUFFER_W);
+       cmdbuf[4] = (u32)message;
+       
+       if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
+       return (Result)cmdbuf[1];
+}
+
+Result NEWS_GetNotificationImage(u32 news_id, void* buffer, u32* size)
+{
+       Result ret = 0;
+       u32 *cmdbuf = getThreadCommandBuffer();
+
+       cmdbuf[0] = IPC_MakeHeader(0xD,2,2);
+       cmdbuf[1] = news_id;
+       cmdbuf[2] = 0x10000; // Default size used by Notifications Applet
+       cmdbuf[3] = IPC_Desc_Buffer((size_t)0x10000,IPC_BUFFER_W);
+       cmdbuf[4] = (u32)buffer;
+       
+       if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
+       *size = cmdbuf[2];
+       return (Result)cmdbuf[1];       
+}
\ No newline at end of file