|
@@ -22,6 +22,7 @@
|
|
|
#include "uhttp.h"
|
|
#include "uhttp.h"
|
|
|
#include "ujson.h"
|
|
#include "ujson.h"
|
|
|
#include "chat_login.h"
|
|
#include "chat_login.h"
|
|
|
|
|
+#include "img.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
|
#include <string.h>
|
|
#include <string.h>
|
|
@@ -39,6 +40,20 @@
|
|
|
#define PAGE_SIZE 50
|
|
#define PAGE_SIZE 50
|
|
|
#define LIVE_PAGE 50
|
|
#define LIVE_PAGE 50
|
|
|
|
|
|
|
|
|
|
+#define MSG_IMG_MAX 3
|
|
|
|
|
+#define CHAT_IMG_W 480
|
|
|
|
|
+#define CHAT_IMG_H 320
|
|
|
|
|
+#define CHAT_IMG_MAX 16
|
|
|
|
|
+#define CHAT_AVATAR_MAX 64
|
|
|
|
|
+#define CHAT_AVATAR 32
|
|
|
|
|
+#define CHAT_IMG_BUDGET (6u * 1024u * 1024u)
|
|
|
|
|
+#define CHAT_IMG_ARENA_MAX (12u * 1024u * 1024u)
|
|
|
|
|
+#define CHAT_IMG_FETCH_MAX (4u * 1024u * 1024u)
|
|
|
|
|
+#define CHAT_IMG_URL_MAX (UHTTP_HOST_MAX + UHTTP_PATH_MAX + 16)
|
|
|
|
|
+#define CHAT_PIC_QUEUED 0
|
|
|
|
|
+#define CHAT_PIC_READY 1
|
|
|
|
|
+#define CHAT_PIC_FAILED (-1)
|
|
|
|
|
+
|
|
|
#define POLL_CONV_MS 2000
|
|
#define POLL_CONV_MS 2000
|
|
|
#define POLL_CONV_IDLE_MS 5000
|
|
#define POLL_CONV_IDLE_MS 5000
|
|
|
#define POLL_DIR_MS 12000
|
|
#define POLL_DIR_MS 12000
|
|
@@ -78,10 +93,13 @@ struct msg {
|
|
|
char id[48];
|
|
char id[48];
|
|
|
char user_id[48];
|
|
char user_id[48];
|
|
|
char author[48];
|
|
char author[48];
|
|
|
|
|
+ char *author_pic; /* profile picture URL, or NULL */
|
|
|
char created[32]; /* ISO 8601 UTC, sorts as text */
|
|
char created[32]; /* ISO 8601 UTC, sorts as text */
|
|
|
char reply[96]; /* "Name: snippet" */
|
|
char reply[96]; /* "Name: snippet" */
|
|
|
char extra[112]; /* attachments / thread / reactions line */
|
|
char extra[112]; /* attachments / thread / reactions line */
|
|
|
char *body; /* Latin-1, malloc'd */
|
|
char *body; /* Latin-1, malloc'd */
|
|
|
|
|
+ char *img_url[MSG_IMG_MAX]; /* image attachments, malloc'd URLs */
|
|
|
|
|
+ unsigned char nimg;
|
|
|
unsigned char action; /* type "me" */
|
|
unsigned char action; /* type "me" */
|
|
|
int height;
|
|
int height;
|
|
|
int layout_w;
|
|
int layout_w;
|
|
@@ -93,6 +111,7 @@ struct pick {
|
|
|
char id[48];
|
|
char id[48];
|
|
|
char name[64];
|
|
char name[64];
|
|
|
char sub[64];
|
|
char sub[64];
|
|
|
|
|
+ char pic[256];
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
static struct ngui ui;
|
|
static struct ngui ui;
|
|
@@ -403,6 +422,7 @@ static void maybe_save_cookie(void)
|
|
|
/* ---- HTTP / JSON plumbing ---- */
|
|
/* ---- HTTP / JSON plumbing ---- */
|
|
|
|
|
|
|
|
static void paint_now(void);
|
|
static void paint_now(void);
|
|
|
|
|
+static int line_h(void);
|
|
|
|
|
|
|
|
static void net_drop(void)
|
|
static void net_drop(void)
|
|
|
{
|
|
{
|
|
@@ -436,6 +456,472 @@ static int parse_resp(void)
|
|
|
return root;
|
|
return root;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* ---- message images and avatars ---- */
|
|
|
|
|
+
|
|
|
|
|
+struct chat_pic {
|
|
|
|
|
+ char *url;
|
|
|
|
|
+ struct img_image img;
|
|
|
|
|
+ unsigned int bytes; /* RGB565 bytes in the message-image budget */
|
|
|
|
|
+ unsigned int last_used;
|
|
|
|
|
+ int state; /* CHAT_PIC_* */
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+static struct chat_pic chat_images[CHAT_IMG_MAX];
|
|
|
|
|
+static int nchat_images;
|
|
|
|
|
+static unsigned int chat_image_bytes;
|
|
|
|
|
+static struct chat_pic chat_avatars[CHAT_AVATAR_MAX];
|
|
|
|
|
+static int nchat_avatars;
|
|
|
|
|
+static unsigned int chat_pic_clock;
|
|
|
|
|
+static unsigned char *chat_fetch_buf;
|
|
|
|
|
+static unsigned char *chat_arena;
|
|
|
|
|
+static unsigned int chat_arena_size;
|
|
|
|
|
+
|
|
|
|
|
+static void chat_pic_free(struct chat_pic *p)
|
|
|
|
|
+{
|
|
|
|
|
+ free(p->url);
|
|
|
|
|
+ free(p->img.px);
|
|
|
|
|
+ free(p->img.alpha);
|
|
|
|
|
+ memset(p, 0, sizeof(*p));
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static struct chat_pic *chat_pic_find(struct chat_pic *arr, int n,
|
|
|
|
|
+ const char *url)
|
|
|
|
|
+{
|
|
|
|
|
+ int i;
|
|
|
|
|
+
|
|
|
|
|
+ for (i = 0; i < n; i++)
|
|
|
|
|
+ if (arr[i].url && strcmp(arr[i].url, url) == 0)
|
|
|
|
|
+ return &arr[i];
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Pick a cache slot, evicting the least recently used entry when full.
|
|
|
|
|
+ * avatars: their images never change the timeline layout. */
|
|
|
|
|
+static struct chat_pic *chat_pic_slot(struct chat_pic *arr, int *count, int max,
|
|
|
|
|
+ const char *url, int avatars)
|
|
|
|
|
+{
|
|
|
|
|
+ struct chat_pic *p = chat_pic_find(arr, *count, url);
|
|
|
|
|
+ unsigned int best = ~0u;
|
|
|
|
|
+ int i, victim = -1;
|
|
|
|
|
+
|
|
|
|
|
+ if (p)
|
|
|
|
|
+ return p;
|
|
|
|
|
+ if (*count < max) {
|
|
|
|
|
+ p = &arr[*count];
|
|
|
|
|
+ memset(p, 0, sizeof(*p));
|
|
|
|
|
+ p->url = strdup(url);
|
|
|
|
|
+ if (!p->url)
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ (*count)++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ for (i = 0; i < *count; i++) {
|
|
|
|
|
+ if (arr[i].state == CHAT_PIC_QUEUED)
|
|
|
|
|
+ continue;
|
|
|
|
|
+ if (arr[i].last_used < best) {
|
|
|
|
|
+ best = arr[i].last_used;
|
|
|
|
|
+ victim = i;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (victim < 0)
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ p = &arr[victim];
|
|
|
|
|
+ if (!avatars) {
|
|
|
|
|
+ chat_image_bytes -= p->bytes;
|
|
|
|
|
+ msgs_gen++;
|
|
|
|
|
+ }
|
|
|
|
|
+ chat_pic_free(p);
|
|
|
|
|
+ p->url = strdup(url);
|
|
|
|
|
+ if (!p->url)
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ p->state = CHAT_PIC_QUEUED;
|
|
|
|
|
+ p->last_used = ++chat_pic_clock;
|
|
|
|
|
+ return p;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static struct chat_pic *chat_image_slot(const char *url)
|
|
|
|
|
+{
|
|
|
|
|
+ return chat_pic_slot(chat_images, &nchat_images, CHAT_IMG_MAX, url, 0);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static struct chat_pic *chat_avatar_slot(const char *url)
|
|
|
|
|
+{
|
|
|
|
|
+ return chat_pic_slot(chat_avatars, &nchat_avatars, CHAT_AVATAR_MAX,
|
|
|
|
|
+ url, 1);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static int chat_image_room(unsigned int need)
|
|
|
|
|
+{
|
|
|
|
|
+ while (chat_image_bytes + need > CHAT_IMG_BUDGET) {
|
|
|
|
|
+ unsigned int best = ~0u;
|
|
|
|
|
+ int i, victim = -1;
|
|
|
|
|
+
|
|
|
|
|
+ for (i = 0; i < nchat_images; i++) {
|
|
|
|
|
+ if (chat_images[i].state != CHAT_PIC_READY)
|
|
|
|
|
+ continue;
|
|
|
|
|
+ if (chat_images[i].last_used < best) {
|
|
|
|
|
+ best = chat_images[i].last_used;
|
|
|
|
|
+ victim = i;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (victim < 0)
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ chat_image_bytes -= chat_images[victim].bytes;
|
|
|
|
|
+ chat_pic_free(&chat_images[victim]);
|
|
|
|
|
+ msgs_gen++;
|
|
|
|
|
+ }
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static unsigned char *chat_pic_arena_get(unsigned int need)
|
|
|
|
|
+{
|
|
|
|
|
+ if (need <= chat_arena_size)
|
|
|
|
|
+ return chat_arena;
|
|
|
|
|
+ free(chat_arena);
|
|
|
|
|
+ chat_arena = (unsigned char *)malloc(need);
|
|
|
|
|
+ chat_arena_size = chat_arena ? need : 0;
|
|
|
|
|
+ return chat_arena;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static int chat_pic_store(struct chat_pic *p, unsigned int len, int avatar)
|
|
|
|
|
+{
|
|
|
|
|
+ struct img_info info;
|
|
|
|
|
+ struct img_options opt;
|
|
|
|
|
+ struct img_mem mem;
|
|
|
|
|
+ struct img_image decoded;
|
|
|
|
|
+ struct img_blit blit;
|
|
|
|
|
+ unsigned char *arena, *alpha = 0;
|
|
|
|
|
+ unsigned short *px;
|
|
|
|
|
+ unsigned int est, scale, dw, dh, sw, sh, i, need;
|
|
|
|
|
+ int r;
|
|
|
|
|
+
|
|
|
|
|
+ if (img_sniff(chat_fetch_buf, len, &info) != 0)
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ est = img_estimate(&info);
|
|
|
|
|
+ if (est == 0xFFFFFFFFu || est > CHAT_IMG_ARENA_MAX)
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ arena = chat_pic_arena_get(est);
|
|
|
|
|
+ if (!arena)
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ img_mem_init(&mem, arena, est);
|
|
|
|
|
+ opt.max_pixels = 4u * 1024u * 1024u;
|
|
|
|
|
+ r = img_decode(chat_fetch_buf, len, &opt, &mem, &decoded);
|
|
|
|
|
+ if (r != 0 || !decoded.w || !decoded.h)
|
|
|
|
|
+ return -1;
|
|
|
|
|
+
|
|
|
|
|
+ if (avatar) {
|
|
|
|
|
+ sw = (CHAT_AVATAR << 16) / decoded.w;
|
|
|
|
|
+ sh = (CHAT_AVATAR << 16) / decoded.h;
|
|
|
|
|
+ scale = sw < sh ? sw : sh;
|
|
|
|
|
+ dw = dh = CHAT_AVATAR;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ scale = 65536;
|
|
|
|
|
+ if (decoded.w > CHAT_IMG_W)
|
|
|
|
|
+ scale = (CHAT_IMG_W << 16) / decoded.w;
|
|
|
|
|
+ if (((decoded.h * scale) >> 16) > CHAT_IMG_H)
|
|
|
|
|
+ scale = (CHAT_IMG_H << 16) / decoded.h;
|
|
|
|
|
+ dw = (decoded.w * scale) >> 16;
|
|
|
|
|
+ dh = (decoded.h * scale) >> 16;
|
|
|
|
|
+ if (!dw)
|
|
|
|
|
+ dw = 1;
|
|
|
|
|
+ if (!dh)
|
|
|
|
|
+ dh = 1;
|
|
|
|
|
+ need = dw * dh * 2u;
|
|
|
|
|
+ if (chat_image_room(need) != 0)
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ px = (unsigned short *)malloc(dw * dh * 2u);
|
|
|
|
|
+ if (!px)
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ for (i = 0; i < dw * dh; i++)
|
|
|
|
|
+ px[i] = avatar ? 0xFFFF : ui.theme.bg;
|
|
|
|
|
+ if (avatar && decoded.alpha) {
|
|
|
|
|
+ alpha = (unsigned char *)malloc(dw * dh);
|
|
|
|
|
+ if (alpha)
|
|
|
|
|
+ memset(alpha, 255, dw * dh);
|
|
|
|
|
+ }
|
|
|
|
|
+ memset(&blit, 0, sizeof(blit));
|
|
|
|
|
+ blit.dst = px;
|
|
|
|
|
+ blit.dst_w = (int)dw;
|
|
|
|
|
+ blit.dst_h = (int)dh;
|
|
|
|
|
+ blit.clip_x = 0;
|
|
|
|
|
+ blit.clip_y = 0;
|
|
|
|
|
+ blit.clip_w = (int)dw;
|
|
|
|
|
+ blit.clip_h = (int)dh;
|
|
|
|
|
+ blit.x = avatar ? (int)(dw - ((decoded.w * scale) >> 16)) / 2 : 0;
|
|
|
|
|
+ blit.y = avatar ? (int)(dh - ((decoded.h * scale) >> 16)) / 2 : 0;
|
|
|
|
|
+ blit.scale = scale;
|
|
|
|
|
+ blit.bg = avatar ? 0xFFFF : ui.theme.bg;
|
|
|
|
|
+ blit.bg2 = blit.bg;
|
|
|
|
|
+ blit.dst_a = alpha;
|
|
|
|
|
+ blit.flags = alpha ? IMG_BLIT_SAVE_ALPHA :
|
|
|
|
|
+ (decoded.alpha ? IMG_BLIT_OVER_DST : 0);
|
|
|
|
|
+ img_draw(&decoded, &blit);
|
|
|
|
|
+
|
|
|
|
|
+ p->img.format = decoded.format;
|
|
|
|
|
+ p->img.w = dw;
|
|
|
|
|
+ p->img.h = dh;
|
|
|
|
|
+ p->img.px = px;
|
|
|
|
|
+ p->img.alpha = alpha;
|
|
|
|
|
+ p->img.flags = 0;
|
|
|
|
|
+ p->bytes = avatar ? 0 : dw * dh * 2u;
|
|
|
|
|
+ if (!avatar)
|
|
|
|
|
+ chat_image_bytes += p->bytes;
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void chat_pic_load(struct chat_pic *p, int avatar)
|
|
|
|
|
+{
|
|
|
|
|
+ unsigned int len = 0;
|
|
|
|
|
+ int st;
|
|
|
|
|
+
|
|
|
|
|
+ if (!chat_fetch_buf)
|
|
|
|
|
+ chat_fetch_buf = (unsigned char *)malloc(CHAT_IMG_FETCH_MAX);
|
|
|
|
|
+ if (!chat_fetch_buf) {
|
|
|
|
|
+ p->state = CHAT_PIC_FAILED;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ http.jar = &jar;
|
|
|
|
|
+ http.accept = "image/*,*/*";
|
|
|
|
|
+ st = chat_http(&http, 0, p->url, 0, (char *)chat_fetch_buf,
|
|
|
|
|
+ CHAT_IMG_FETCH_MAX, &len);
|
|
|
|
|
+ if (st != 200 || len == 0 || chat_pic_store(p, len, avatar) != 0) {
|
|
|
|
|
+ p->state = CHAT_PIC_FAILED;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ p->state = CHAT_PIC_READY;
|
|
|
|
|
+ p->last_used = ++chat_pic_clock;
|
|
|
|
|
+ if (!avatar) {
|
|
|
|
|
+ msgs_gen++;
|
|
|
|
|
+ if (at_bottom)
|
|
|
|
|
+ tl_scroll.offset = 1 << 28;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ngui_invalidate(&ui);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void chat_media_tick(void)
|
|
|
|
|
+{
|
|
|
|
|
+ int i;
|
|
|
|
|
+
|
|
|
|
|
+ if (screen != SCR_MAIN || offline)
|
|
|
|
|
+ return;
|
|
|
|
|
+ for (i = 0; i < nchat_images; i++) {
|
|
|
|
|
+ if (chat_images[i].state == CHAT_PIC_QUEUED) {
|
|
|
|
|
+ chat_pic_load(&chat_images[i], 0);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for (i = 0; i < nchat_avatars; i++) {
|
|
|
|
|
+ if (chat_avatars[i].state == CHAT_PIC_QUEUED) {
|
|
|
|
|
+ chat_pic_load(&chat_avatars[i], 1);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void chat_media_clear(void)
|
|
|
|
|
+{
|
|
|
|
|
+ int i;
|
|
|
|
|
+
|
|
|
|
|
+ for (i = 0; i < nchat_images; i++)
|
|
|
|
|
+ chat_pic_free(&chat_images[i]);
|
|
|
|
|
+ for (i = 0; i < nchat_avatars; i++)
|
|
|
|
|
+ chat_pic_free(&chat_avatars[i]);
|
|
|
|
|
+ nchat_images = 0;
|
|
|
|
|
+ nchat_avatars = 0;
|
|
|
|
|
+ chat_image_bytes = 0;
|
|
|
|
|
+ free(chat_fetch_buf);
|
|
|
|
|
+ chat_fetch_buf = 0;
|
|
|
|
|
+ free(chat_arena);
|
|
|
|
|
+ chat_arena = 0;
|
|
|
|
|
+ chat_arena_size = 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Refresh/Retry gives failed pictures another chance. */
|
|
|
|
|
+static void chat_media_retry(void)
|
|
|
|
|
+{
|
|
|
|
|
+ int i;
|
|
|
|
|
+
|
|
|
|
|
+ for (i = 0; i < nchat_images; i++)
|
|
|
|
|
+ if (chat_images[i].state == CHAT_PIC_FAILED)
|
|
|
|
|
+ chat_images[i].state = CHAT_PIC_QUEUED;
|
|
|
|
|
+ for (i = 0; i < nchat_avatars; i++)
|
|
|
|
|
+ if (chat_avatars[i].state == CHAT_PIC_FAILED)
|
|
|
|
|
+ chat_avatars[i].state = CHAT_PIC_QUEUED;
|
|
|
|
|
+ ngui_invalidate(&ui);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Resolve a picture URL; Cloudron's older profile-avatar path is rewritten
|
|
|
|
|
+ * to the /api/avatars/ route the current server serves. */
|
|
|
|
|
+static int chat_pic_url(const char *raw, char *out, unsigned int cap)
|
|
|
|
|
+{
|
|
|
|
|
+ static const char old_prefix[] = "/api/v1/profile/avatar/";
|
|
|
|
|
+ const char *p;
|
|
|
|
|
+ char tmp[CHAT_IMG_URL_MAX];
|
|
|
|
|
+ char *q;
|
|
|
|
|
+
|
|
|
|
|
+ if (!raw || !raw[0])
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ p = strstr(raw, old_prefix);
|
|
|
|
|
+ if (p) {
|
|
|
|
|
+ s_copy(tmp, "/api/avatars/", sizeof(tmp));
|
|
|
|
|
+ s_cat(tmp, p + sizeof(old_prefix) - 1, sizeof(tmp));
|
|
|
|
|
+ q = strchr(tmp, '?');
|
|
|
|
|
+ if (q)
|
|
|
|
|
+ *q = '\0';
|
|
|
|
|
+ raw = tmp;
|
|
|
|
|
+ }
|
|
|
|
|
+ return uhttp_resolve(server, raw, out, cap);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static int chat_image_name(const char *mime, const char *filename)
|
|
|
|
|
+{
|
|
|
|
|
+ static const char *const ext[] = {
|
|
|
|
|
+ ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tga",
|
|
|
|
|
+ ".ppm", ".pgm", ".pbm", ".ico", ".cur", ".pam"
|
|
|
|
|
+ };
|
|
|
|
|
+ unsigned int i;
|
|
|
|
|
+
|
|
|
|
|
+ if (mime && strncmp(mime, "image/", 6) == 0)
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ if (!filename)
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ for (i = 0; i < sizeof(ext) / sizeof(ext[0]); i++) {
|
|
|
|
|
+ unsigned int n = (unsigned int)strlen(ext[i]);
|
|
|
|
|
+ unsigned int j;
|
|
|
|
|
+ const char *s = filename + strlen(filename);
|
|
|
|
|
+
|
|
|
|
|
+ if ((unsigned int)strlen(filename) < n)
|
|
|
|
|
+ continue;
|
|
|
|
|
+ s -= n;
|
|
|
|
|
+ for (j = 0; j < n; j++) {
|
|
|
|
|
+ char a = s[j], b = ext[i][j];
|
|
|
|
|
+
|
|
|
|
|
+ if (a >= 'A' && a <= 'Z')
|
|
|
|
|
+ a = (char)(a - 'A' + 'a');
|
|
|
|
|
+ if (a != b)
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (j == n)
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Layout/draw dimensions for one message image. *state is the cache state
|
|
|
|
|
+ * (a missing entry is treated as queued; draw queues it). */
|
|
|
|
|
+static void chat_image_measure(const char *url, int tw, int *dw, int *dh,
|
|
|
|
|
+ unsigned int *scale, int *state)
|
|
|
|
|
+{
|
|
|
|
|
+ struct chat_pic *p = chat_pic_find(chat_images, nchat_images, url);
|
|
|
|
|
+ unsigned int sc = 65536;
|
|
|
|
|
+
|
|
|
|
|
+ if (p && p->state == CHAT_PIC_READY) {
|
|
|
|
|
+ if ((int)p->img.w > tw)
|
|
|
|
|
+ sc = ((unsigned int)tw << 16) / p->img.w;
|
|
|
|
|
+ if (((p->img.h * sc) >> 16) > CHAT_IMG_H)
|
|
|
|
|
+ sc = (CHAT_IMG_H << 16) / p->img.h;
|
|
|
|
|
+ *dw = (int)((p->img.w * sc) >> 16);
|
|
|
|
|
+ *dh = (int)((p->img.h * sc) >> 16);
|
|
|
|
|
+ if (*dw < 1)
|
|
|
|
|
+ *dw = 1;
|
|
|
|
|
+ if (*dh < 1)
|
|
|
|
|
+ *dh = 1;
|
|
|
|
|
+ *scale = sc;
|
|
|
|
|
+ *state = CHAT_PIC_READY;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ *dw = tw < 320 ? tw : 320;
|
|
|
|
|
+ if (*dw < 40)
|
|
|
|
|
+ *dw = 40;
|
|
|
|
|
+ *dh = 120;
|
|
|
|
|
+ *scale = 65536;
|
|
|
|
|
+ *state = p ? p->state : CHAT_PIC_QUEUED;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static struct ngui_rect chat_clip_rect(void)
|
|
|
|
|
+{
|
|
|
|
|
+ if (ui.nclip > 0)
|
|
|
|
|
+ return ui.clip[ui.nclip - 1];
|
|
|
|
|
+ return (struct ngui_rect){ 0, 0, ui.w, ui.h };
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void chat_image_draw(const char *url, int x, int y, int tw)
|
|
|
|
|
+{
|
|
|
|
|
+ struct chat_pic *p = chat_pic_find(chat_images, nchat_images, url);
|
|
|
|
|
+ struct ngui_rect clip = chat_clip_rect();
|
|
|
|
|
+ int dw, dh, state;
|
|
|
|
|
+ unsigned int scale;
|
|
|
|
|
+
|
|
|
|
|
+ if (!p)
|
|
|
|
|
+ p = chat_image_slot(url);
|
|
|
|
|
+ chat_image_measure(url, tw, &dw, &dh, &scale, &state);
|
|
|
|
|
+ if (p && p->state == CHAT_PIC_READY) {
|
|
|
|
|
+ struct img_blit blit;
|
|
|
|
|
+
|
|
|
|
|
+ memset(&blit, 0, sizeof(blit));
|
|
|
|
|
+ blit.dst = ui.px;
|
|
|
|
|
+ blit.dst_w = ui.w;
|
|
|
|
|
+ blit.dst_h = ui.h;
|
|
|
|
|
+ blit.clip_x = clip.x;
|
|
|
|
|
+ blit.clip_y = clip.y;
|
|
|
|
|
+ blit.clip_w = clip.w;
|
|
|
|
|
+ blit.clip_h = clip.h;
|
|
|
|
|
+ blit.x = x;
|
|
|
|
|
+ blit.y = y;
|
|
|
|
|
+ blit.scale = scale;
|
|
|
|
|
+ blit.bg = ui.theme.bg;
|
|
|
|
|
+ blit.bg2 = ui.theme.bg;
|
|
|
|
|
+ blit.flags = p->img.alpha ? IMG_BLIT_OVER_DST : 0;
|
|
|
|
|
+ img_draw(&p->img, &blit);
|
|
|
|
|
+ ngui_frame(&ui, (struct ngui_rect){ x, y, dw, dh },
|
|
|
|
|
+ ui.theme.border);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ struct ngui_rect box = { x, y, dw, dh };
|
|
|
|
|
+
|
|
|
|
|
+ ngui_fill_rect(&ui, box, ui.theme.panel_alt);
|
|
|
|
|
+ ngui_frame(&ui, box, ui.theme.border);
|
|
|
|
|
+ ngui_text_ellipsis(&ui, box, x + 8, y + (dh - line_h()) / 2,
|
|
|
|
|
+ state == CHAT_PIC_FAILED ?
|
|
|
|
|
+ "Image could not be loaded" :
|
|
|
|
|
+ "Loading image...", ui.theme.text_dim);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static int chat_avatar_draw(const char *url, int x, int y, int size,
|
|
|
|
|
+ unsigned short fallback)
|
|
|
|
|
+{
|
|
|
|
|
+ struct chat_pic *p;
|
|
|
|
|
+
|
|
|
|
|
+ if (!url || !url[0])
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ p = chat_pic_find(chat_avatars, nchat_avatars, url);
|
|
|
|
|
+ if (!p)
|
|
|
|
|
+ p = chat_avatar_slot(url);
|
|
|
|
|
+ if (p && p->state == CHAT_PIC_READY) {
|
|
|
|
|
+ struct ngui_rect clip = chat_clip_rect();
|
|
|
|
|
+ struct img_blit blit;
|
|
|
|
|
+
|
|
|
|
|
+ memset(&blit, 0, sizeof(blit));
|
|
|
|
|
+ blit.dst = ui.px;
|
|
|
|
|
+ blit.dst_w = ui.w;
|
|
|
|
|
+ blit.dst_h = ui.h;
|
|
|
|
|
+ blit.clip_x = clip.x;
|
|
|
|
|
+ blit.clip_y = clip.y;
|
|
|
|
|
+ blit.clip_w = clip.w;
|
|
|
|
|
+ blit.clip_h = clip.h;
|
|
|
|
|
+ blit.x = x;
|
|
|
|
|
+ blit.y = y;
|
|
|
|
|
+ blit.scale = ((unsigned int)size << 16) / CHAT_AVATAR;
|
|
|
|
|
+ blit.bg = fallback;
|
|
|
|
|
+ blit.bg2 = fallback;
|
|
|
|
|
+ blit.flags = p->img.alpha ? IMG_BLIT_OVER_DST : 0;
|
|
|
|
|
+ img_draw(&p->img, &blit);
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void go_login(const char *why);
|
|
static void go_login(const char *why);
|
|
|
|
|
|
|
|
/* Common error handling for API calls in the main screen. Returns 1 when
|
|
/* Common error handling for API calls in the main screen. Returns 1 when
|
|
@@ -562,8 +1048,47 @@ static int load_directory(void)
|
|
|
|
|
|
|
|
static void msg_free(struct msg *m)
|
|
static void msg_free(struct msg *m)
|
|
|
{
|
|
{
|
|
|
|
|
+ int i;
|
|
|
|
|
+
|
|
|
free(m->body);
|
|
free(m->body);
|
|
|
m->body = 0;
|
|
m->body = 0;
|
|
|
|
|
+ free(m->author_pic);
|
|
|
|
|
+ m->author_pic = 0;
|
|
|
|
|
+ for (i = 0; i < m->nimg; i++) {
|
|
|
|
|
+ free(m->img_url[i]);
|
|
|
|
|
+ m->img_url[i] = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ m->nimg = 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Resolve and remember one image URL; duplicates and overflowing messages
|
|
|
|
|
+ * are ignored. */
|
|
|
|
|
+static int msg_add_image(struct msg *m, const char *raw)
|
|
|
|
|
+{
|
|
|
|
|
+ char url[CHAT_IMG_URL_MAX];
|
|
|
|
|
+ int i;
|
|
|
|
|
+
|
|
|
|
|
+ if (!raw || !raw[0] || m->nimg >= MSG_IMG_MAX)
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ if (uhttp_resolve(server, raw, url, sizeof(url)) != 0)
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ for (i = 0; i < m->nimg; i++)
|
|
|
|
|
+ if (strcmp(m->img_url[i], url) == 0)
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ m->img_url[m->nimg] = strdup(url);
|
|
|
|
|
+ if (!m->img_url[m->nimg])
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ m->nimg++;
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void msg_set_author_pic(struct msg *m, const char *raw)
|
|
|
|
|
+{
|
|
|
|
|
+ char url[CHAT_IMG_URL_MAX];
|
|
|
|
|
+
|
|
|
|
|
+ if (!raw[0] || chat_pic_url(raw, url, sizeof(url)) != 0)
|
|
|
|
|
+ return;
|
|
|
|
|
+ m->author_pic = strdup(url);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void clear_messages(void)
|
|
static void clear_messages(void)
|
|
@@ -597,16 +1122,21 @@ static void build_extra(struct msg *m, int o)
|
|
|
for (it = ujson_first(&json, ujson_get(&json, o, "attachments"));
|
|
for (it = ujson_first(&json, ujson_get(&json, o, "attachments"));
|
|
|
it >= 0; it = ujson_next(&json, it)) {
|
|
it >= 0; it = ujson_next(&json, it)) {
|
|
|
char name[64];
|
|
char name[64];
|
|
|
|
|
+ const char *mime = ujson_get_str(&json, it, "mime");
|
|
|
|
|
+ const char *fn = ujson_get_str(&json, it, "filename");
|
|
|
|
|
+ const char *url = ujson_get_str(&json, it, "url");
|
|
|
|
|
|
|
|
- to_latin1_line(name, sizeof(name),
|
|
|
|
|
- ujson_get_str(&json, it, "filename"));
|
|
|
|
|
|
|
+ if (chat_image_name(mime, fn) && url[0])
|
|
|
|
|
+ continue; /* drawn inline by the timeline */
|
|
|
|
|
+ to_latin1_line(name, sizeof(name), fn);
|
|
|
if (m->extra[0])
|
|
if (m->extra[0])
|
|
|
s_cat(m->extra, ", ", sizeof(m->extra));
|
|
s_cat(m->extra, ", ", sizeof(m->extra));
|
|
|
else
|
|
else
|
|
|
s_cat(m->extra, "[file] ", sizeof(m->extra));
|
|
s_cat(m->extra, "[file] ", sizeof(m->extra));
|
|
|
s_cat(m->extra, name, sizeof(m->extra));
|
|
s_cat(m->extra, name, sizeof(m->extra));
|
|
|
}
|
|
}
|
|
|
- if (ujson_type(&json, ujson_get(&json, o, "gif")) == UJSON_OBJECT) {
|
|
|
|
|
|
|
+ if (ujson_type(&json, ujson_get(&json, o, "gif")) == UJSON_OBJECT &&
|
|
|
|
|
+ !ujson_get_str(&json, ujson_get(&json, o, "gif"), "url")[0]) {
|
|
|
if (m->extra[0])
|
|
if (m->extra[0])
|
|
|
s_cat(m->extra, " ", sizeof(m->extra));
|
|
s_cat(m->extra, " ", sizeof(m->extra));
|
|
|
s_cat(m->extra, "[GIF]", sizeof(m->extra));
|
|
s_cat(m->extra, "[GIF]", sizeof(m->extra));
|
|
@@ -671,6 +1201,7 @@ static int msg_from_json(struct msg *m, int o)
|
|
|
if (!nm[0])
|
|
if (!nm[0])
|
|
|
nm = ujson_get_str(&json, o, "authorUsername");
|
|
nm = ujson_get_str(&json, o, "authorUsername");
|
|
|
to_latin1_line(m->author, sizeof(m->author), nm[0] ? nm : "?");
|
|
to_latin1_line(m->author, sizeof(m->author), nm[0] ? nm : "?");
|
|
|
|
|
+ msg_set_author_pic(m, ujson_get_str(&json, o, "authorPicture"));
|
|
|
s_copy(m->created, ujson_get_str(&json, o, "createdAt"),
|
|
s_copy(m->created, ujson_get_str(&json, o, "createdAt"),
|
|
|
sizeof(m->created));
|
|
sizeof(m->created));
|
|
|
m->action = strcmp(ujson_get_str(&json, o, "type"), "me") == 0;
|
|
m->action = strcmp(ujson_get_str(&json, o, "type"), "me") == 0;
|
|
@@ -687,8 +1218,39 @@ static int msg_from_json(struct msg *m, int o)
|
|
|
while (len && (body[len - 1] == '\n' || body[len - 1] == ' '))
|
|
while (len && (body[len - 1] == '\n' || body[len - 1] == ' '))
|
|
|
body[--len] = '\0';
|
|
body[--len] = '\0';
|
|
|
m->body = strdup(body);
|
|
m->body = strdup(body);
|
|
|
- if (!m->body)
|
|
|
|
|
|
|
+ if (!m->body) {
|
|
|
|
|
+ msg_free(m);
|
|
|
return -1;
|
|
return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ {
|
|
|
|
|
+ int it;
|
|
|
|
|
+ const char *mime, *fn;
|
|
|
|
|
+
|
|
|
|
|
+ for (it = ujson_first(&json,
|
|
|
|
|
+ ujson_get(&json, o, "attachments"));
|
|
|
|
|
+ it >= 0; it = ujson_next(&json, it)) {
|
|
|
|
|
+ mime = ujson_get_str(&json, it, "mime");
|
|
|
|
|
+ fn = ujson_get_str(&json, it, "filename");
|
|
|
|
|
+ if (chat_image_name(mime, fn) &&
|
|
|
|
|
+ msg_add_image(m, ujson_get_str(&json, it, "url")) != 0) {
|
|
|
|
|
+ msg_free(m);
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ujson_type(&json, ujson_get(&json, o, "gif")) == UJSON_OBJECT &&
|
|
|
|
|
+ msg_add_image(m, ujson_get_str(&json, ujson_get(&json, o, "gif"),
|
|
|
|
|
+ "url")) != 0) {
|
|
|
|
|
+ msg_free(m);
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ujson_type(&json, ujson_get(&json, o, "preview")) == UJSON_OBJECT &&
|
|
|
|
|
+ msg_add_image(m, ujson_get_str(&json,
|
|
|
|
|
+ ujson_get(&json, o, "preview"),
|
|
|
|
|
+ "image")) != 0) {
|
|
|
|
|
+ msg_free(m);
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
rt = ujson_get(&json, o, "replyTo");
|
|
rt = ujson_get(&json, o, "replyTo");
|
|
|
if (ujson_type(&json, rt) == UJSON_OBJECT) {
|
|
if (ujson_type(&json, rt) == UJSON_OBJECT) {
|
|
|
char tmp[96];
|
|
char tmp[96];
|
|
@@ -1034,6 +1596,14 @@ static void load_picks(int dms)
|
|
|
s_copy(p->id, ujson_get_str(&json, it, "id"), sizeof(p->id));
|
|
s_copy(p->id, ujson_get_str(&json, it, "id"), sizeof(p->id));
|
|
|
if (!p->id[0])
|
|
if (!p->id[0])
|
|
|
continue;
|
|
continue;
|
|
|
|
|
+ p->pic[0] = '\0';
|
|
|
|
|
+ {
|
|
|
|
|
+ char url[CHAT_IMG_URL_MAX];
|
|
|
|
|
+
|
|
|
|
|
+ if (chat_pic_url(ujson_get_str(&json, it, "picture"),
|
|
|
|
|
+ url, sizeof(url)) == 0)
|
|
|
|
|
+ s_copy(p->pic, url, sizeof(p->pic));
|
|
|
|
|
+ }
|
|
|
if (dms) {
|
|
if (dms) {
|
|
|
if (strcmp(p->id, me_id) == 0)
|
|
if (strcmp(p->id, me_id) == 0)
|
|
|
continue;
|
|
continue;
|
|
@@ -1140,6 +1710,7 @@ static void go_login(const char *why)
|
|
|
uhttp_jar_clear(&jar);
|
|
uhttp_jar_clear(&jar);
|
|
|
saved_jar_changes = jar.changes;
|
|
saved_jar_changes = jar.changes;
|
|
|
saved_cookie[0] = '\0';
|
|
saved_cookie[0] = '\0';
|
|
|
|
|
+ chat_media_clear();
|
|
|
screen = SCR_SERVER;
|
|
screen = SCR_SERVER;
|
|
|
modal = MODAL_NONE;
|
|
modal = MODAL_NONE;
|
|
|
clear_messages();
|
|
clear_messages();
|
|
@@ -1461,6 +2032,7 @@ static void layout_msg(int i, int width)
|
|
|
{
|
|
{
|
|
|
struct msg *m = &msgs[i];
|
|
struct msg *m = &msgs[i];
|
|
|
int lh = line_h(), h, tw = width - TEXT_X - 12;
|
|
int lh = line_h(), h, tw = width - TEXT_X - 12;
|
|
|
|
|
+ int k;
|
|
|
|
|
|
|
|
if (tw < 40)
|
|
if (tw < 40)
|
|
|
tw = 40;
|
|
tw = 40;
|
|
@@ -1472,6 +2044,14 @@ static void layout_msg(int i, int width)
|
|
|
if (m->reply[0])
|
|
if (m->reply[0])
|
|
|
h += lh + 2;
|
|
h += lh + 2;
|
|
|
h += count_lines(m->body, tw) * lh;
|
|
h += count_lines(m->body, tw) * lh;
|
|
|
|
|
+ for (k = 0; k < m->nimg; k++) {
|
|
|
|
|
+ int dw, dh, state;
|
|
|
|
|
+ unsigned int scale;
|
|
|
|
|
+
|
|
|
|
|
+ chat_image_measure(m->img_url[k], tw, &dw, &dh, &scale,
|
|
|
|
|
+ &state);
|
|
|
|
|
+ h += dh + 6;
|
|
|
|
|
+ }
|
|
|
if (m->extra[0])
|
|
if (m->extra[0])
|
|
|
h += lh + 2;
|
|
h += lh + 2;
|
|
|
h += 2;
|
|
h += 2;
|
|
@@ -1520,7 +2100,7 @@ static unsigned short avatar_color(const char *id)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void draw_avatar(int x, int y, int size, const char *name,
|
|
static void draw_avatar(int x, int y, int size, const char *name,
|
|
|
- const char *id)
|
|
|
|
|
|
|
+ const char *id, const char *pic)
|
|
|
{
|
|
{
|
|
|
struct ngui_rect r = { x, y, size, size };
|
|
struct ngui_rect r = { x, y, size, size };
|
|
|
char ini[2];
|
|
char ini[2];
|
|
@@ -1528,6 +2108,8 @@ static void draw_avatar(int x, int y, int size, const char *name,
|
|
|
|
|
|
|
|
ngui_fill_round_rect(&ui, r, size / 2, size / 2, size / 2, size / 2,
|
|
ngui_fill_round_rect(&ui, r, size / 2, size / 2, size / 2, size / 2,
|
|
|
avatar_color(id));
|
|
avatar_color(id));
|
|
|
|
|
+ if (chat_avatar_draw(pic, x, y, size, avatar_color(id)))
|
|
|
|
|
+ return;
|
|
|
ini[0] = name[0] ? name[0] : '?';
|
|
ini[0] = name[0] ? name[0] : '?';
|
|
|
if (ini[0] >= 'a' && ini[0] <= 'z')
|
|
if (ini[0] >= 'a' && ini[0] <= 'z')
|
|
|
ini[0] = (char)(ini[0] - 'a' + 'A');
|
|
ini[0] = (char)(ini[0] - 'a' + 'A');
|
|
@@ -1853,7 +2435,8 @@ static void draw_message(struct msg *m, int x, int y, int width)
|
|
|
int aw;
|
|
int aw;
|
|
|
|
|
|
|
|
y += PAD_TOP;
|
|
y += PAD_TOP;
|
|
|
- draw_avatar(x + 10, y, AVATAR, m->author, m->user_id);
|
|
|
|
|
|
|
+ draw_avatar(x + 10, y, AVATAR, m->author, m->user_id,
|
|
|
|
|
+ m->author_pic);
|
|
|
ngui_text_px(&ui, tx, y, m->author, (unsigned int)strlen(m->author),
|
|
ngui_text_px(&ui, tx, y, m->author, (unsigned int)strlen(m->author),
|
|
|
ui.theme.text, ui.font_px, 1, 0, 0);
|
|
ui.theme.text, ui.font_px, 1, 0, 0);
|
|
|
aw = text_w(m->author, (unsigned int)strlen(m->author), 1);
|
|
aw = text_w(m->author, (unsigned int)strlen(m->author), 1);
|
|
@@ -1885,6 +2468,19 @@ static void draw_message(struct msg *m, int x, int y, int width)
|
|
|
pos += adv;
|
|
pos += adv;
|
|
|
y += lh;
|
|
y += lh;
|
|
|
}
|
|
}
|
|
|
|
|
+ {
|
|
|
|
|
+ int k;
|
|
|
|
|
+
|
|
|
|
|
+ for (k = 0; k < m->nimg; k++) {
|
|
|
|
|
+ int dw, dh, state;
|
|
|
|
|
+ unsigned int scale;
|
|
|
|
|
+
|
|
|
|
|
+ chat_image_measure(m->img_url[k], tw, &dw, &dh,
|
|
|
|
|
+ &scale, &state);
|
|
|
|
|
+ chat_image_draw(m->img_url[k], tx, y, tw);
|
|
|
|
|
+ y += dh + 6;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if (m->extra[0]) {
|
|
if (m->extra[0]) {
|
|
|
struct ngui_rect er = { tx, y + 2, tw, lh };
|
|
struct ngui_rect er = { tx, y + 2, tw, lh };
|
|
|
|
|
|
|
@@ -2088,7 +2684,8 @@ static void draw_modal(void)
|
|
|
ngui_fill_rect(&ui, (struct ngui_rect){ row.x, y + 43,
|
|
ngui_fill_rect(&ui, (struct ngui_rect){ row.x, y + 43,
|
|
|
row.w, 1 }, ui.theme.border);
|
|
row.w, 1 }, ui.theme.border);
|
|
|
if (modal == MODAL_NEWDM)
|
|
if (modal == MODAL_NEWDM)
|
|
|
- draw_avatar(row.x + 8, y + 6, 30, p->name, p->id);
|
|
|
|
|
|
|
+ draw_avatar(row.x + 8, y + 6, 30, p->name, p->id,
|
|
|
|
|
+ p->pic);
|
|
|
ngui_text_ellipsis(&ui, (struct ngui_rect){ row.x + 48, y,
|
|
ngui_text_ellipsis(&ui, (struct ngui_rect){ row.x + 48, y,
|
|
|
row.w - 160, lh + 4 },
|
|
row.w - 160, lh + 4 },
|
|
|
row.x + 48, y + 4,
|
|
row.x + 48, y + 4,
|
|
@@ -2380,6 +2977,7 @@ static void run_action(void)
|
|
|
case ACT_RETRY:
|
|
case ACT_RETRY:
|
|
|
backoff_ms = 0;
|
|
backoff_ms = 0;
|
|
|
retry_at = 0;
|
|
retry_at = 0;
|
|
|
|
|
+ chat_media_retry();
|
|
|
s_copy(busy, "Refreshing...", sizeof(busy));
|
|
s_copy(busy, "Refreshing...", sizeof(busy));
|
|
|
paint_now();
|
|
paint_now();
|
|
|
busy[0] = '\0';
|
|
busy[0] = '\0';
|
|
@@ -2519,6 +3117,7 @@ void _start(const char *arg)
|
|
|
run_action();
|
|
run_action();
|
|
|
else
|
|
else
|
|
|
poll_tick();
|
|
poll_tick();
|
|
|
|
|
+ chat_media_tick();
|
|
|
/* The offline retry countdown needs a once-a-second repaint. */
|
|
/* The offline retry countdown needs a once-a-second repaint. */
|
|
|
if (offline && screen == SCR_MAIN) {
|
|
if (offline && screen == SCR_MAIN) {
|
|
|
static unsigned int last_tick;
|
|
static unsigned int last_tick;
|