Files
MeowOS-For-R3P2/patch_v2/sdk/meow_notify_ipc.h
T

64 lines
3.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* meow_notify_ipc.h — MeowOS SDK 通知 → launcher IPC 桥(内部头,不随 meow_ui.h 发布给应用)。
*
* 定位(任务 #5 SDK↔IPC 桥关键断点):让框架 app 调 meow_notify_send() 的通知真正经
* AF_UNIX IPC 送到 launcher(meow_launcherd)中央存储(meow_notif.c 的 meow_notif_post),
* 通知中心(阶段 B · M5)才能显示。消息通道(FRAMEWORK_DESIGN §1 / meow_ipc.h):
* - MSG_NOTIFY 0x0020 ↑:推送/更新通知(负载 m_notify_t;含 SDK icon→app_icon、urgency);
* - MSG_NOTIFY_ACK 0x0021 ↓:落库结果(m_ack_t,status=launcher 分配的通知 id nid);
* - MSG_NOTIFY_DISMISS 0x0022 ↑:撤下通知(负载 uint32 nid);
* - MSG_NOTIFY_PROGRESS 0x0024 ↑:实时更新通知进度(负载 m_notify_progress_t,仅改内存活跃槽)。
*
* 约定:只做「一次性发送 + 读 ACK」,不造 IPC 订阅循环;SDK 本地活动表(meow_ui_notify.c)
* 保留(app 进程内即时查询/配额自检),真正的通知中心数据在 launcher 中央存储,二者以
* 本接口经 IPC 同步。全部失败路径优雅降级(无 socket/写失败/超时 → 返回 0,不崩)。
*
* 本接口只暴露「SDK 类型出/进 + 状态码」,不把 m_notify_t / 帧格式泄漏给 meow_ui_notify.c;
* 映射层(SDK 枚举 ↔ IPC 字符串/uint32)实现在 meow_notify_ipc.c 内部。
*/
#ifndef MEOW_NOTIFY_IPC_H
#define MEOW_NOTIFY_IPC_H
#include <stdint.h>
#include "meow_ui.h" /* meow_notify */
#ifdef __cplusplus
extern "C" {
#endif
/* 当前 app 的 app_id(env MEOW_LOG_APP,缺省 "app";pthread_once 缓存,线程安全)。 */
const char *meow_notify_ipc_app_id(void);
/* 把一条 SDK meow_notify 映射为 m_notify_t 并一次性发送 MSG_NOTIFY,阻塞读
* MSG_NOTIFY_ACK 取 launcher 分配的通知 id(nid)。replaces_id:0=新建;>0=更新已存在
* 通知(与 freedesktop 语义一致)。成功返回 nid(>0);无 socket/写失败/超时/非 ACK →
* 返回 0(调用方保留本地 id 兜底,不崩)。 */
uint32_t meow_notify_ipc_send(const meow_notify *n, uint32_t replaces_id);
/* 一次性发送 MSG_NOTIFY_DISMISS 撤下 launcher 侧通知。best-effort:写失败/无 socket
* 静默(不崩、不回读 ACK)。 */
void meow_notify_ipc_dismiss(uint32_t nid);
/* 一次性发送 MSG_NOTIFY_PROGRESS 更新 launcher 侧已存在通知的进度(仅改内存活跃槽,
* 不落盘)。best-effort:写失败/无 socket 静默。 */
void meow_notify_ipc_update_progress(uint32_t nid, int progress);
/* 通用一次性请求:发 type+payload 帧,want_ack 时阻塞读一帧应答(忽略其内容,仅确保
* launcher 已处理完再关连接,防「写后即关」丢帧竞态)。返回 0=已发出(want_ack 含读到应答);
* -1=无 socket/写失败/读失败。best-effort,供 SDK 内部 nav / notif_open 复用。 */
int meow_notify_ipc_send_raw(uint16_t type, const void *payload, uint32_t len, int want_ack);
/* 一次性发送 MSG_NOTIF_OPEN(App 前台顶部下滑 → 请求 launcher 展开通知中心叠加会话,
* FRAMEWORK_DESIGN §10.5)。App 只检测+上报、不渲染系统 UI。best-effort:失败静默。 */
void meow_notify_ipc_notif_open(const char *app_id, uint32_t event_seq,
uint16_t origin_x, uint16_t origin_y,
uint16_t hotzone, uint8_t flags);
/* 一次性发送 MSG_NOTIF_CLOSE(App 告知结束/退出 → launcher 收尾兜底,可选用途)。best-effort。 */
void meow_notify_ipc_notif_close(const char *app_id, uint32_t reason);
#ifdef __cplusplus
}
#endif
#endif /* MEOW_NOTIFY_IPC_H */