MCPcopy Create free account
hub / github.com/devkitPro/libctru / NEWS_AddNotification

Function NEWS_AddNotification

libctru/source/services/news.c:30–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30Result NEWS_AddNotification(const u16* title, u32 titleLength, const u16* message, u32 messageLength, const void* imageData, u32 imageSize, bool jpeg)
31{
32 NotificationHeader header = { 0 };
33 header.dataSet = true;
34 header.unread = true;
35 header.enableJPEG = jpeg;
36 header.processID = 0; // Filled automatically from FS:GetProgramLaunchInfo
37 header.time = osGetTime();
38 memcpy(header.title, title, (titleLength < 32 ? titleLength + 1 : 32) * sizeof(u16));
39
40 Result ret = 0;
41 u32 *cmdbuf = getThreadCommandBuffer();
42
43 if (useNewsS) cmdbuf[0] = IPC_MakeHeader(0x1,3,6); // 0x100C6
44 else cmdbuf[0] = IPC_MakeHeader(0x1,3,8); // 0x100C8
45 cmdbuf[1] = sizeof(NotificationHeader);
46 cmdbuf[2] = (messageLength + 1) * sizeof(u16);
47 cmdbuf[3] = imageSize;
48
49 u32 baseIndex = 4;
50 if (!useNewsS) {
51 cmdbuf[baseIndex] = IPC_Desc_CurProcessId();
52 cmdbuf[baseIndex + 1] = 0; // Process ID, Filled automatically by the ARM11 kernel.
53 baseIndex += 2;
54 }
55
56 cmdbuf[baseIndex] = IPC_Desc_Buffer(sizeof(NotificationHeader),IPC_BUFFER_R);
57 cmdbuf[baseIndex + 1] = (u32) &header;
58 cmdbuf[baseIndex + 2] = IPC_Desc_Buffer((messageLength + 1) * sizeof(u16),IPC_BUFFER_R);
59 cmdbuf[baseIndex + 3] = (u32) message;
60 cmdbuf[baseIndex + 4] = IPC_Desc_Buffer(imageSize,IPC_BUFFER_R);
61 cmdbuf[baseIndex + 5] = (u32) imageData;
62
63 if(R_FAILED(ret = svcSendSyncRequest(newsHandle))) return ret;
64
65 return (Result)cmdbuf[1];
66}
67
68Result NEWS_GetTotalNotifications(u32* num)
69{

Callers

nothing calls this directly

Calls 5

osGetTimeFunction · 0.85
getThreadCommandBufferFunction · 0.85
IPC_MakeHeaderFunction · 0.85
IPC_Desc_CurProcessIdFunction · 0.85
IPC_Desc_BufferFunction · 0.85

Tested by

no test coverage detected