summaryrefslogtreecommitdiff
path: root/clients/ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'clients/ui.c')
-rw-r--r--clients/ui.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/clients/ui.c b/clients/ui.c
index 2eb2dfe..99ad213 100644
--- a/clients/ui.c
+++ b/clients/ui.c
@@ -338,6 +338,8 @@ static void expand_path(const char *in, char *out, size_t n)
Returns a malloc'd path, or NULL on cancel. */
char *file_browser(struct app *a, const char *start_dir)
{
+ if (ui_web_block("Välj fil"))
+ return NULL;
if (g_quit)
return NULL;
char dir[1024];
@@ -478,6 +480,27 @@ static void safe_fname(const char *in, char *out, size_t n)
out[o] = '\0';
}
+int ui_web_mode(void)
+{
+ static int mode = -1;
+ if (mode < 0) {
+ const char *v = getenv("BOKF_WEB");
+ mode = v && strcmp(v, "1") == 0;
+ }
+ return mode;
+}
+
+int ui_web_block(const char *title)
+{
+ if (!ui_web_mode())
+ return 0;
+ tui_message(title,
+ "Inte tillgängligt i webbversionen ännu: filer kan inte\n"
+ "laddas upp, sparas eller öppnas härifrån.\n"
+ "Använd bokftui på datorn för det.");
+ return 1;
+}
+
/* Open a saved file with xdg-open when a desktop session is present;
otherwise (or on fork failure) show where it was saved. */
static void open_saved(const char *path, const char *title)
@@ -507,6 +530,8 @@ static void open_saved(const char *path, const char *title)
static void save_cache_and_open(const unsigned char *data, size_t n,
const char *filename, const char *title)
{
+ if (ui_web_block(title))
+ return;
char dir[512], path[700], safe[600];
pdf_cache_dir(dir, sizeof dir);
safe_fname(filename, safe, sizeof safe);
@@ -614,6 +639,8 @@ void attachment_download(struct app *a, int64_t att_id)
tui_message("Underlag", "Kunde inte avkoda innehållet.");
goto done;
}
+ if (ui_web_block("Underlag"))
+ goto done;
const char *home = getenv("HOME");
char def[600], dl[512];
snprintf(dl, sizeof dl, "%s/Downloads", home && *home ? home : ".");