Loading...
Searching...
No Matches
plugin_source.h File Reference

The struct the framework keeps the weather, calendar, and stock source choices in, for a face built with a plugin define, and the checks that decide which of them it keeps. More...

#include "system/settings/settings.h"
#include <stddef.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  PluginSourceSettings
 The saved choices, version byte first. More...

Macros

#define PLUGIN_SOURCE_KEEPS_WEATHER   0
 1 when the watch keeps the weather source choice, for a face with PLUGIN_WEATHER and WEATHER_PROVIDER
#define PLUGIN_SOURCE_KEEPS_CALENDAR   0
 1 when the watch keeps the calendar source choice, for a face with PLUGIN_CALENDAR and CALENDAR_SOURCE
#define PLUGIN_SOURCE_KEEPS_STOCK   0
 1 when the watch keeps the stock source choice, for a face with PLUGIN_STOCKS and STOCK_PROVIDER
#define PLUGIN_SOURCE_KEEPS_ANY   (PLUGIN_SOURCE_KEEPS_WEATHER || PLUGIN_SOURCE_KEEPS_CALENDAR || PLUGIN_SOURCE_KEEPS_STOCK)
 The watch keeps at least one source choice, so the framework's schema joins the chain.
#define PLUGIN_SOURCE_WEATHER_LEN   12
 The size of the weather source buffer. weatherapi is the longest value the settings page saves, and its 10 characters plus its end leave one byte spare.
#define PLUGIN_SOURCE_CALENDAR_LEN   8
 The size of the calendar source buffer. plugin is the longest value the settings page saves, and its 6 characters plus its end leave one byte spare.
#define PLUGIN_SOURCE_STOCK_LEN   14
 The size of the stock source buffer. alphavantage is the longest value the settings page saves, and its 12 characters plus its end leave one byte spare.
#define PLUGIN_SOURCE_VERSION   2
 The schema's version, raised by one with each appended field.
#define PLUGIN_SOURCE_FIRST_SIZE   21
 The struct's size in its first release, which never changes.
#define PLUGIN_SOURCE_WEATHER_FIELD
 The field the framework keeps the weather source in, with a comma after it, or nothing when the watch keeps no weather choice.
#define PLUGIN_SOURCE_CALENDAR_FIELD
 The field the framework keeps the calendar source in, with a comma after it, or nothing when the watch keeps no calendar choice. It works as the weather one does.
#define PLUGIN_SOURCE_STOCK_FIELD
 The field the framework keeps the stock source in, with a comma after it, or nothing when the watch keeps no stock choice. It works as the weather one does.
#define PLUGIN_SOURCE_FIELDS   PLUGIN_SOURCE_WEATHER_FIELD PLUGIN_SOURCE_CALENDAR_FIELD PLUGIN_SOURCE_STOCK_FIELD
 The framework schema's whole field table, for inside its braces.

Functions

static bool plugin_source_write_needed (const PluginSourceSettings *now, const PluginSourceSettings *on_flash, bool on_flash_known)
 Whether a save has to write the choices to flash.

Detailed Description

The struct the framework keeps the weather, calendar, and stock source choices in, for a face built with a plugin define, and the checks that decide which of them it keeps.

The watch never reads the choice. It stores what the settings page saves and sends it back when the phone asks for the watch's settings, so a wearer who picked the Pebble app's plugin still has it after the Pebble app is reinstalled. settings.c builds its schema from PLUGIN_SOURCE_FIELDS and walks it after the face's own, on SETTINGS_PLUGIN_SOURCE_KEY, so the face writes no field of its own for it. A save skips the write while flash already holds the choices.

A kind keeps its choice when its define is on and the face declares its select key. The build refuses the select key beside a plugin only providers list, so a plugin only kind keeps nothing. The build also writes each kept kind's default as PLUGIN_SOURCE_WEATHER_DEFAULT, PLUGIN_SOURCE_CALENDAR_DEFAULT, or PLUGIN_SOURCE_STOCK_DEFAULT, from the face's providers list, so the watch's default is always the settings page's. The build stops when the face's own picker does not offer it, or when the page opens on another source.