PebbleOS
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
attribute.h File Reference
#include <pbl/util/string_list.h>
#include <stdint.h>
#include <stdbool.h>

Data Structures

struct  Uint32List
 Variable-length list of 32-bit values. More...
 
struct  Attribute
 Attribute: an id and a value whose type depends on the id. More...
 
struct  AttributeList
 List of attributes. More...
 
union  Attribute.__unnamed79__
 Value; the member matching the type of Attribute::id is valid. More...
 

Macros

#define ATTRIBUTE_ICON_LARGE_SIZE_PX   80
 Size of large icons, in pixels.
 
#define ATTRIBUTE_ICON_SMALL_SIZE_PX   50
 Size of small icons, in pixels.
 
#define ATTRIBUTE_ICON_TINY_SIZE_PX   25
 Size of tiny icons, in pixels.
 
#define ATTRIBUTE_TITLE_MAX_LEN   64
 Maximum length of a title, in bytes.
 
#define ATTRIBUTE_SUBTITLE_MAX_LEN   64
 Maximum length of a subtitle, in bytes.
 
#define ATTRIBUTE_APP_GLANCE_SUBTITLE_MAX_LEN   (150)
 Maximum length of an app glance subtitle template string, in bytes.
 
#define Uint32ListSize(num_values)   (sizeof(Uint32List) + (num_values) * sizeof(uint32_t))
 Size in bytes of a Uint32List holding a number of values.
 

Enumerations

enum  AttributeId {
  AttributeIdUnused = 0 , AttributeIdTitle = 1 , AttributeIdSubtitle = 2 , AttributeIdBody = 3 ,
  AttributeIdIconTiny = 4 , AttributeIdIconSmall = 5 , AttributeIdIconLarge = 6 , AttributeIdAncsAction = 7 ,
  AttributeIdCannedResponses = 8 , AttributeIdShortTitle = 9 , AttributeIdIconPin = 10 , AttributeIdLocationName = 11 ,
  AttributeIdSender = 12 , AttributeIdLaunchCode = 13 , AttributeIdLastUpdated = 14 , AttributeIdRankAway = 15 ,
  AttributeIdRankHome = 16 , AttributeIdNameAway = 17 , AttributeIdNameHome = 18 , AttributeIdRecordAway = 19 ,
  AttributeIdRecordHome = 20 , AttributeIdScoreAway = 21 , AttributeIdScoreHome = 22 , AttributeIdSportsGameState = 23 ,
  AttributeIdBroadcaster = 24 , AttributeIdHeadings = 25 , AttributeIdParagraphs = 26 , AttributeIdPrimaryColor = 27 ,
  AttributeIdBgColor = 28 , AttributeIdSecondaryColor = 29 , AttributeIdAppName = 30 , AttributeIdDisplayRecurring = 31 ,
  AttributeIdiOSAppIdentifier = 32 , AttributeIdEmojiSupported = 33 , AttributeIdAncsId = 34 , AttributeIdHealthInsightType = 35 ,
  AttributeIdShortSubtitle = 36 , AttributeIdTimestamp = 37 , AttributeIdDisplayTime = 38 , AttributeIdAddress = 39 ,
  AttributeIdMuteDayOfWeek = 40 , AttributeIdMetricNames = 41 , AttributeIdMetricValues = 42 , AttributeIdMetricIcons = 43 ,
  AttributeIdHealthActivityType = 44 , AttributeIdAlarmKind = 45 , AttributeIdAuthCode = 46 , AttributeIdSubtitleTemplateString = 47 ,
  AttributeIdIcon = 48 , AttributeIdVibrationPattern = 49 , AttributeIdMuteExpiration = 50 , AttributeIdNotificationFilteringRules = 51 ,
  AttributeIdImageAspectRatio = 52 , AttributeIdWeatherPinKind = 53 , NumAttributeIds
}
 Attribute identifiers, as used on the wire. More...
 

Functions

void attribute_init_string (Attribute *attribute, char *buffer, AttributeId attribute_id)
 Initialize a string attribute.
 
bool attribute_copy (Attribute *dest, const Attribute *src, uint8_t **buffer, uint8_t *const buffer_end)
 Deep copy an attribute, placing its string or list data in a buffer.
 
bool attribute_list_copy (AttributeList *out, const AttributeList *in, uint8_t *buffer, uint8_t *const buffer_end)
 Deep copy an attribute list into one contiguous buffer.
 
size_t attribute_list_get_buffer_size (const AttributeList *list)
 Get the size of a buffer holding a deep copy of an attribute list.
 
size_t attribute_list_get_string_buffer_size (const AttributeList *list)
 Get the size of the string and list data of an attribute list.
 
void attribute_list_add_cstring (AttributeList *list, AttributeId id, const char *cstring)
 Add a string attribute, or replace the value of an existing one.
 
void attribute_list_add_uint32 (AttributeList *list, AttributeId id, uint32_t uint32)
 Add a uint32 attribute, or replace the value of an existing one.
 
void attribute_list_add_resource_id (AttributeList *list, AttributeId id, uint32_t resource_id)
 Add a resource id attribute, or replace the value of an existing one.
 
void attribute_list_add_uint8 (AttributeList *list, AttributeId id, uint8_t uint8)
 Add a uint8 attribute, or replace the value of an existing one.
 
void attribute_list_add_string_list (AttributeList *list, AttributeId id, struct pbl_string_list *string_list)
 Add a string list attribute, or replace the value of an existing one.
 
void attribute_list_add_uint32_list (AttributeList *list, AttributeId id, Uint32List *uint32_list)
 Add a Uint32List attribute, or replace the value of an existing one.
 
void attribute_list_add_attribute (AttributeList *list, const Attribute *new_attribute)
 Add an attribute, or replace an existing one with the same id.
 
void attribute_list_init_list (uint8_t num_attributes, AttributeList *list_out)
 Allocate a zeroed attribute list on the kernel heap.
 
void attribute_list_destroy_list (AttributeList *list)
 Free the attributes array of a list.
 
Attribute * attribute_find (const AttributeList *attr_list, AttributeId id)
 Find an attribute by id.
 
const char * attribute_get_string (const AttributeList *attr_list, AttributeId id, char *default_value)
 Get a string attribute.
 
struct pbl_string_list * attribute_get_string_list (const AttributeList *attr_list, AttributeId id)
 Get a string list attribute.
 
uint8_t attribute_get_uint8 (const AttributeList *attr_list, AttributeId id, uint8_t default_value)
 Get a uint8 attribute.
 
uint32_t attribute_get_uint32 (const AttributeList *attr_list, AttributeId id, uint32_t default_value)
 Get a uint32 or resource id attribute.
 
Uint32List * attribute_get_uint32_list (const AttributeList *attr_list, AttributeId id)
 Get a Uint32List attribute.
 
size_t attribute_list_serialize (const AttributeList *attr_list, uint8_t *buffer, uint8_t *buf_end)
 Serialize an attribute list.
 
size_t attribute_list_get_serialized_size (const AttributeList *attr_list)
 Get the serialized size of an attribute list.
 
bool attribute_check_serialized_list (const uint8_t *cursor, const uint8_t *val_end, uint8_t num_attributes, bool has_attribute[])
 Check that a serialized attribute list is well formed and record which ids it contains.
 
int32_t attribute_get_buffer_size_for_serialized_attributes (uint8_t num_attributes, const uint8_t **cursor, const uint8_t *end)
 Get the size of the buffer needed to deserialize attributes.
 
bool attribute_deserialize_list (char **buffer, char *const buf_end, const uint8_t **cursor, const uint8_t *payload_end, AttributeList *attr_list)
 Deserialize attributes into an attribute list.