Flash storage for received notifications.
More...
|
| void | notification_storage_init (void) |
| | Initialize storage, discarding all stored notifications.
|
| |
| void | notification_storage_lock (void) |
| | Lock the storage mutex (recursive).
|
| |
| void | notification_storage_unlock (void) |
| | Unlock the storage mutex.
|
| |
| void | notification_storage_store (TimelineItem *notification) |
| | Store a notification.
|
| |
| bool | notification_storage_notification_exists (const Uuid *id) |
| | Check whether a notification is stored, including one marked deleted.
|
| |
| size_t | notification_storage_get_len (const Uuid *uuid) |
| | Get the serialized size of a stored notification.
|
| |
| bool | notification_storage_get (const Uuid *id, TimelineItem *item_out) |
| | Read a notification from storage.
|
| |
| void | notification_storage_set_status (const Uuid *id, uint8_t status) |
| | Set the status of a stored notification.
|
| |
| bool | notification_storage_get_status (const Uuid *id, uint8_t *status) |
| | Get the status of a stored notification.
|
| |
| void | notification_storage_remove (const Uuid *id) |
| | Remove a notification by marking it deleted.
|
| |
| bool | notification_storage_find_ancs_notification_id (uint32_t ancs_uid, Uuid *uuid_out) |
| | Find the most recent notification with an ANCS UID.
|
| |
| bool | notification_storage_find_ancs_notification_by_timestamp (TimelineItem *notification, CommonTimelineItemHeader *header_out) |
| | Find a stored notification identical to a given one.
|
| |
| void | notification_storage_iterate (bool(*iter_callback)(void *data, SerializedTimelineItemHeader *header_id), void *data) |
| | Iterate over the headers of all notifications not marked deleted.
|
| |
| void | notification_storage_iterate_strings_after (time_t item_cutoff, AttributeList *attr_list, size_t buffer_size, bool(*iter_callback)(void *data, const CommonTimelineItemHeader *header, const TimelineItem *item), void *data) |
| | Iterate over all notifications, reading selected string attributes of recent ones.
|
| |
| void | notification_storage_rewrite (void(*iter_callback)(TimelineItem *notification, SerializedTimelineItemHeader *header, void *data), void *data) |
| | Rewrite all notifications through a callback.
|
| |
| void | notification_storage_reset_and_init (void) |
| | Discard all notifications and reset the storage state.
|
| |
Flash storage for received notifications.
Notifications are appended to a single file as a SerializedTimelineItemHeader followed by the serialized attributes and actions. Removing a notification only marks it deleted; deleted entries are dropped when the file is compacted, and the oldest notifications are deleted when the file is full. The file is wiped at boot.
Every function takes the storage mutex, which is recursive; use notification_storage_lock() to group several calls.
◆ notification_storage_find_ancs_notification_by_timestamp()
Find a stored notification identical to a given one.
Matches the timestamp, layout and serialized attributes and actions.
- Parameters
-
| notification | Notification to match. |
| [out] | header_out | Header of the matching notification. |
- Returns
- true if a match was found.
◆ notification_storage_find_ancs_notification_id()
| bool notification_storage_find_ancs_notification_id |
( |
uint32_t |
ancs_uid, |
|
|
Uuid * |
uuid_out |
|
) |
| |
Find the most recent notification with an ANCS UID.
iOS can reuse ANCS UIDs after a reconnection, so the newest match wins.
- Parameters
-
| ancs_uid | ANCS UID to look for. |
| [out] | uuid_out | Id of the matching notification. |
- Returns
- true if found.
◆ notification_storage_get()
Read a notification from storage.
- Parameters
-
- Returns
- true on success, false if not found or unreadable.
◆ notification_storage_get_len()
| size_t notification_storage_get_len |
( |
const Uuid * |
uuid | ) |
|
Get the serialized size of a stored notification.
- Parameters
-
- Returns
- Size of the header and payload in bytes, 0 if not found.
◆ notification_storage_get_status()
| bool notification_storage_get_status |
( |
const Uuid * |
id, |
|
|
uint8_t * |
status |
|
) |
| |
Get the status of a stored notification.
- Parameters
-
| id | Notification id. |
| [out] | status | Status, a combination of TimelineItemStatus flags. |
- Returns
- true if found and not marked deleted.
◆ notification_storage_init()
| void notification_storage_init |
( |
void |
| ) |
|
Initialize storage, discarding all stored notifications.
◆ notification_storage_iterate()
Iterate over the headers of all notifications not marked deleted.
Do not call other notification storage functions from iter_callback; doing so corrupts storage.
- Parameters
-
| iter_callback | Called with data and each header; return false to stop. |
| data | Context for iter_callback. |
◆ notification_storage_iterate_strings_after()
Iterate over all notifications, reading selected string attributes of recent ones.
For notifications with a timestamp at or after item_cutoff, the string attributes listed in attr_list are read into their cstring buffers (buffer_size bytes each, empty when absent) without deserializing or allocating the payload, and the callback gets an item carrying the header and that list. Older notifications get a NULL item. Corrupt and deleted entries are skipped. Callback arguments are only valid during the callback.
Do not call other notification storage functions from iter_callback.
- Parameters
-
| item_cutoff | Oldest timestamp for which strings are read. |
| attr_list | String attributes to read; each cstring points to a buffer of buffer_size. |
| buffer_size | Size of each string buffer in bytes, including the terminator. |
| iter_callback | Called with data, the header and the item or NULL; return false to stop. |
| data | Context for iter_callback. |
◆ notification_storage_lock()
| void notification_storage_lock |
( |
void |
| ) |
|
Lock the storage mutex (recursive).
◆ notification_storage_notification_exists()
| bool notification_storage_notification_exists |
( |
const Uuid * |
id | ) |
|
Check whether a notification is stored, including one marked deleted.
- Parameters
-
- Returns
- true if found.
◆ notification_storage_remove()
| void notification_storage_remove |
( |
const Uuid * |
id | ) |
|
Remove a notification by marking it deleted.
- Parameters
-
◆ notification_storage_reset_and_init()
| void notification_storage_reset_and_init |
( |
void |
| ) |
|
Discard all notifications and reset the storage state.
◆ notification_storage_rewrite()
Rewrite all notifications through a callback.
Each notification not marked deleted is deserialized, passed to iter_callback, and written to a new file along with its header, so changes made by the callback are persisted. Deleted entries are dropped.
- Parameters
-
| iter_callback | Called with each notification, its header and data. |
| data | Context for iter_callback. |
◆ notification_storage_set_status()
| void notification_storage_set_status |
( |
const Uuid * |
id, |
|
|
uint8_t |
status |
|
) |
| |
Set the status of a stored notification.
- Parameters
-
| id | Notification id. |
| status | New status, a combination of TimelineItemStatus flags. |
◆ notification_storage_store()
| void notification_storage_store |
( |
TimelineItem * |
notification | ) |
|
Store a notification.
Storage is compacted, deleting the oldest notifications if needed, when the file is full. On a write error all notifications are discarded.
- Parameters
-
| notification | Notification to store; it is serialized, the caller keeps ownership. |
◆ notification_storage_unlock()
| void notification_storage_unlock |
( |
void |
| ) |
|
Unlock the storage mutex.