static void prompt_onFriendRequest(ToxWindow *self, uint8_t *key, uint8_t *data, uint16_t length) { // make sure message data is null-terminated data[length - 1] = 0; PromptBuf *prt = self->promptbuf; prep_prompt_win(); wprintw(self->window, "\n"); print_time(self->window); uint8_t msg[MAX_STR_SIZE]; snprintf(msg, sizeof(msg), "Friend request with the message '%s'\n", data); wprintw(self->window, "%s", msg); write_to_log(msg, "", prt->log, true); int n = add_friend_request(key); if (n == -1) { uint8_t *errmsg = "Friend request queue is full. Discarding request.\n"; wprintw(self->window, "%s", errmsg); write_to_log(errmsg, "", prt->log, true); return; } wprintw(self->window, "Type \"/accept %d\" to accept it.\n", n); alert_window(self, WINDOW_ALERT_1, true); }
static void prompt_onFriendRequest(ToxWindow *self, Tox *m, const uint8_t *key, const uint8_t *data, uint16_t length) { ChatContext *ctx = self->chatwin; uint8_t timefrmt[TIME_STR_SIZE]; get_time_str(timefrmt, sizeof(timefrmt)); uint8_t msg[MAX_STR_SIZE]; snprintf(msg, sizeof(msg), "Friend request with the message '%s'", data); line_info_add(self, timefrmt, NULL, NULL, msg, SYS_MSG, 0, 0); write_to_log(msg, "", ctx->log, true); int n = add_friend_request(key); if (n == -1) { uint8_t *errmsg = "Friend request queue is full. Discarding request."; line_info_add(self, NULL, NULL, NULL, errmsg, SYS_MSG, 0, 0); write_to_log(errmsg, "", ctx->log, true); return; } snprintf(msg, sizeof(msg), "Type \"/accept %d\" to accept it.", n); line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0); alert_window(self, WINDOW_ALERT_1, true); }
static void prompt_onFriendRequest(ToxWindow *self, Tox *m, const char *key, const char *data, size_t length) { ChatContext *ctx = self->chatwin; char timefrmt[TIME_STR_SIZE]; get_time_str(timefrmt, sizeof(timefrmt)); line_info_add(self, timefrmt, NULL, NULL, SYS_MSG, 0, 0, "Friend request with the message '%s'", data); write_to_log("Friend request with the message '%s'", "", ctx->log, true); int n = add_friend_request(key, data); if (n == -1) { const char *errmsg = "Friend request queue is full. Discarding request."; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg); return; } line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Type \"/accept %d\" or \"/decline %d\"", n, n); sound_notify(self, generic_message, NT_WNDALERT_1 | NT_NOTIFWND, NULL); }