Skip to content

Local

Local::Local

Constructs a local store from existing data (stored from dump()) and the user's secret key for generating the data encryption key. To construct a blank local store (i.e. with no pre-existing dumped data to load) pass std::nullopt as the second argument.

Declaration

Local(std::span<const unsigned char> ed25519_secretkey,
      std::optional<std::span<const unsigned char>> dumped);

Parameters

  • ed25519_secretkey — contains the libsodium secret key used to encrypt/decrypt the data when pushing/pulling from the swarm. This can either be the full 64-byte value (which is technically the 32-byte seed followed by the 32-byte pubkey), or just the 32-byte seed of the secret key.
  • dumped — either std::nullopt to construct a new, empty object; or binary state data that was previously dumped from an instance of this class by calling dump().

Returns

  • Local - Constructor

Local::encryption_domain

Returns the domain. Is constant, will always return "Local"

Declaration

const char* encryption_domain() const override { return "Local"; }

Parameters

This endpoint takes no inputs.

Returns

  • const char* - Will return "Local"

Local::get_ios_notification_sound

Returns the setting indicating which sound should play when receiving a notification on iOS.

Declaration

int64_t get_ios_notification_sound() const;

Parameters

This endpoint takes no inputs.

Returns

  • notify_sound — integer indicating the sound that should be played when receiving a notification on iOS.

Local::get_notification_content

Returns the setting indicating what notification content should be displayed.

Declaration

notify_content get_notification_content() const;

Parameters

This endpoint takes no inputs.

Returns

  • notify_content — enum indicating the content that should be shown within a notification.

Local::get_setting

Accesses the setting for the provided key. Can have three values:

  • std::nullopt — the value has not been given an explicit value so the client should use its default.
  • true — the value is explicitly enabled
  • false — the value is explicitly disabled

Declaration

std::optional<bool> get_setting(std::string key) const;

Parameters

  • key — key that a setting was previously stored against.

Returns

  • std::optional<bool> - true/false if the value has been set; std::nullopt if the value has not been set.

Local::get_theme

Returns the setting indicating which theme the client should use.

Declaration

theme get_theme() const;

Parameters

This endpoint takes no inputs.

Returns

  • theme — enum indicating which theme the client should use.

Local::get_theme_primary_color

Returns the setting indicating which primary color the client should use.

Declaration

theme_primary_color get_theme_primary_color() const;

Parameters

This endpoint takes no inputs.

Returns

  • theme_primary_color — enum indicating which primary color the client should use.

Local::needs_push

Always returns false as the local store should never be pushed to the swarm.

Declaration

bool needs_push() const override { return false; };

Parameters

This endpoint takes no inputs.

Returns

  • bool — Returns false

Local::push

Since the loal store should never be pushed this functions is overwritten to always return empty data in case a client doesn't respect the needs_push flag.

Declaration

std::tuple<seqno_t, std::vector<std::vector<unsigned char>>, std::vector<std::string>> push()
        override {

Parameters

This endpoint takes no inputs.

Returns

  • std::tuple<seqno_t, std::vector<unsigned char>, std::vector<std::string>> - Returns a tuple containing
  • seqno_t — sequence number of 0
  • std::vector<unsigned char> — empty data vector
  • std::vector<std::string> — empty list of message hashes

Local::set_ios_notification_sound

Sets the setting indicating which sound should be played when receiving receiving a notification on iOS.

Declaration

void set_ios_notification_sound(int64_t value);

Parameters

  • value — Updated notification sound setting

Returns

Local::set_notification_content

Sets the setting indicating what notification content should be displayed.

Declaration

void set_notification_content(notify_content value);

Parameters

  • value — Updated notification content setting

Returns

Local::set_setting

Sets the setting. This is typically invoked with either true or false, but can also be called withstd::nullopt` to explicitly clear the value.

Declaration

void set_setting(std::string key, std::optional<bool> enabled);

Parameters

  • key — key that a setting was previously stored against.
  • enabled — value that should be stored locally against the key, or std::nullopt to drop the setting from the local storage (and thus use the client's default).

Returns

Local::set_theme

Sets the setting indicating which theme the client should use.

Declaration

void set_theme(theme value);

Parameters

  • value — Updated theme setting

Returns

Local::size_settings

Returns the number of settings

Declaration

size_t size_settings() const;

Parameters

This endpoint takes no inputs.

Returns

  • size_t - Returns the number of settings

Local::storage_namespace

The local config should never be pushed so just provide the UserProfile namespace as a fallback. Is constant, will always return 2

Declaration

Namespace storage_namespace() const override { return Namespace::UserProfile; }

Parameters

This endpoint takes no inputs.

Returns

  • Namespace - Will return 2