#ifndef C8_STEALTH_H
#define C8_STEALTH_H

#include <stdbool.h>

/*
 * Stealth mode, for screenshots and recordings: `[stealth] on = true` in
 * config.ini (PC settings' General page). While it's on, whatever is
 * drawn that names the user or the machine shows a made-up stand-in
 * instead. Only what is shown changes: logins, connections, paths and
 * ids used underneath stay the real ones.
 *
 * The stand-in persona is lowtide (`[stealth] name`, `login`, `host`,
 * `email`, `handle` change it); addresses are from the ranges kept for
 * documentation (192.0.2.0/24, 2001:db8::/32, 00:00:5e:00:53:xx), names
 * of networks, devices, places and people from short lists, each real
 * one keeping the same stand-in for the life of the program.
 *
 * Needs a GLib main loop for c8_stealth_watch; the rest is plain calls.
 */

/* config.ini's folder, for programs given --config (default
 * $XDG_CONFIG_HOME/cont8nuum). Call before anything else here. */
void c8_stealth_config_dir(const char *dir);

/* Whether it's on: read once, then kept up to date by the watch (or
 * read again on every call when nothing watches nor reloads) */
bool c8_stealth(void);

/* For a program that watches config.ini itself (the compositor): read it
 * now, and from then on only when this is called. True when anything
 * changed. */
bool c8_stealth_reload(void);

/* fn runs when it's turned on or off, or the persona changes; draw again
 * from it. Watches config.ini's folder from the first call. */
void c8_stealth_watch(void (*fn)(void *data), void *data);
void c8_stealth_unwatch(void (*fn)(void *data), void *data);

/* The persona. Fine to call while off (they're what it would show). */
const char *c8_stealth_name(void); // real name: lowtide
const char *c8_stealth_login(void); // login name: lowtide
const char *c8_stealth_host(void); // PC name: lowtide-pc
const char *c8_stealth_email(void); // lowtide@example.com
const char *c8_stealth_handle(void); // lowtide.example.com
const char *c8_stealth_home(void); // /home/lowtide

/* Text with the real login, real name, PC name and home folder replaced
 * by the persona's (whole words only). Newly allocated (g_free); a copy
 * of s when it's off. NULL gives NULL. For paths, titles, command
 * output. */
char *c8_stealth_text(const char *s);

/* The same, but s itself when off or unchanged, else a string kept for
 * the program's life (one per distinct input): for draw fns, which
 * can't free */
const char *c8_stealth_show(const char *s);

/* A made-up name standing for a real one of a kind, s itself when off.
 * Kept for the program's life, so don't call it with unbounded input. */
enum c8_stealth_kind {
	C8_STEALTH_WIFI, // a network's name: "Coffee shop"
	C8_STEALTH_DEVICE, // another machine or a gadget: "laptop"
	C8_STEALTH_PLACE, // a town: "Riverside"
	C8_STEALTH_PERSON, // someone else: "Robin"
	C8_STEALTH_ADDRESS, // IPv4, IPv6 or MAC: one of the same form
};
const char *c8_stealth_alias(enum c8_stealth_kind kind, const char *s);

#endif
