mirror of
				https://github.com/Tha14/toxic.git
				synced 2025-10-31 18:56:51 +01:00 
			
		
		
		
	Compare commits
	
		
			53 Commits
		
	
	
		
			ngc
			...
			tcp_new_gr
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 7ed031b9bf | ||
| 6ef2c784c5 | |||
|  | 058057c64d | ||
| 146b00b8ca | |||
|  | 85024bfce8 | ||
| 129bb6ba68 | |||
|  | 68b4713ef7 | ||
|  | 46eb69412e | ||
|  | f47b4c1c3c | ||
|  | 22eb6797b1 | ||
|  | 0edad7b862 | ||
|  | cc80da00fc | ||
|  | 32efac931c | ||
|  | 4f936e5f9c | ||
|  | 529d905bd0 | ||
|  | 631b1d8b08 | ||
|  | 9ac8d517e9 | ||
|  | 90152f5e17 | ||
|  | 4d501aeb2a | ||
|  | 1b9f4f337a | ||
|  | 812f2d1ff9 | ||
|  | 2eeb1de20d | ||
|  | ba896fd124 | ||
|  | 3ff3516e42 | ||
|  | 2ef3d68173 | ||
|  | 7a099f86c8 | ||
|  | 9a629072b3 | ||
|  | 27259ff23f | ||
|  | f786b7ae6a | ||
|  | cd4a5e5fde | ||
|  | 0b32b985f1 | ||
|  | 5851cb2dd8 | ||
|  | 1847025213 | ||
|  | 1a2320b035 | ||
|  | 1211899a40 | ||
|  | 5dabaac804 | ||
|  | 4f26171e3f | ||
|  | fa075f1972 | ||
|  | cbf3145aee | ||
|  | 06bdb0d167 | ||
|  | 0212391d7d | ||
|  | 535a8402d6 | ||
|  | 2c51afd9ef | ||
|  | 4aca8b6ecb | ||
|  | 28be56aad9 | ||
|  | 38004367a1 | ||
|  | 5499bb6645 | ||
|  | ed8ba89cd8 | ||
|  | 812210d63f | ||
|  | cec96e1ea3 | ||
|  | eb7e6151a2 | ||
|  | 22ca3704d2 | ||
|  | fdfaaf953f | 
| @@ -2,12 +2,12 @@ | |||||||
| .\"     Title: toxic.conf | .\"     Title: toxic.conf | ||||||
| .\"    Author: [see the "AUTHORS" section] | .\"    Author: [see the "AUTHORS" section] | ||||||
| .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> | .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> | ||||||
| .\"      Date: 2021-05-24 | .\"      Date: 2020-11-12 | ||||||
| .\"    Manual: Toxic Manual | .\"    Manual: Toxic Manual | ||||||
| .\"    Source: toxic __VERSION__ | .\"    Source: toxic __VERSION__ | ||||||
| .\"  Language: English | .\"  Language: English | ||||||
| .\" | .\" | ||||||
| .TH "TOXIC\&.CONF" "5" "2021\-05\-24" "toxic __VERSION__" "Toxic Manual" | .TH "TOXIC\&.CONF" "5" "2020\-11\-12" "toxic __VERSION__" "Toxic Manual" | ||||||
| .\" ----------------------------------------------------------------- | .\" ----------------------------------------------------------------- | ||||||
| .\" * Define some portability stuff | .\" * Define some portability stuff | ||||||
| .\" ----------------------------------------------------------------- | .\" ----------------------------------------------------------------- | ||||||
| @@ -138,6 +138,11 @@ Show welcome message on startup\&. true or false | |||||||
| Enable friend connection change notifications\&. true or false | Enable friend connection change notifications\&. true or false | ||||||
| .RE | .RE | ||||||
| .PP | .PP | ||||||
|  | \fBshow_group_connection_msg\fR | ||||||
|  | .RS 4 | ||||||
|  | Enable group connection change notifications (does not include quit messages)\&. true or false | ||||||
|  | .RE | ||||||
|  | .PP | ||||||
| \fBnodelist_update_freq\fR | \fBnodelist_update_freq\fR | ||||||
| .RS 4 | .RS 4 | ||||||
| How often in days to update the DHT nodes list\&. (integer; 0 to disable) | How often in days to update the DHT nodes list\&. (integer; 0 to disable) | ||||||
|   | |||||||
| @@ -87,6 +87,9 @@ OPTIONS | |||||||
|     *show_connection_msg*;; |     *show_connection_msg*;; | ||||||
|         Enable friend connection change notifications. true or false |         Enable friend connection change notifications. true or false | ||||||
|  |  | ||||||
|  |     *show_group_connection_msg*;; | ||||||
|  |         Enable group connection change notifications (does not include quit messages). true or false | ||||||
|  |  | ||||||
|     *nodelist_update_freq*;; |     *nodelist_update_freq*;; | ||||||
|         How often in days to update the DHT nodes list. (integer; 0 to disable) |         How often in days to update the DHT nodes list. (integer; 0 to disable) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -56,6 +56,9 @@ ui = { | |||||||
|   // true to show friend connection change messages on the home screen |   // true to show friend connection change messages on the home screen | ||||||
|   show_connection_msg=true; |   show_connection_msg=true; | ||||||
|  |  | ||||||
|  |   // true to show peer connection change messages in groups (setting to false does not include user quit messages) | ||||||
|  |   show_group_connection_msg=true; | ||||||
|  |  | ||||||
|   // How often in days to update the DHT nodes list. (0 to disable updates) |   // How often in days to update the DHT nodes list. (0 to disable updates) | ||||||
|   nodeslist_update_freq=7; |   nodeslist_update_freq=7; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -114,7 +114,6 @@ apk add \ | |||||||
|     libsodium-dev \ |     libsodium-dev \ | ||||||
|     libsodium-static \ |     libsodium-static \ | ||||||
|     linux-headers \ |     linux-headers \ | ||||||
|     msgpack-c-dev \ |  | ||||||
|     ncurses-dev \ |     ncurses-dev \ | ||||||
|     ncurses-static \ |     ncurses-static \ | ||||||
|     ncurses-terminfo \ |     ncurses-terminfo \ | ||||||
| @@ -137,20 +136,27 @@ mkdir -p "$BUILD_DIR" | |||||||
| cd "$BUILD_DIR" | cd "$BUILD_DIR" | ||||||
|  |  | ||||||
| # The git hash of the c-toxcore version we're using | # The git hash of the c-toxcore version we're using | ||||||
| TOXCORE_VERSION="v0.2.16" | TOXCORE_VERSION="02996f06850fb565fa5520cb4e1daa8c616b41c1" | ||||||
|  |  | ||||||
| # The sha256sum of the c-toxcore tarball for TOXCORE_VERSION | TOXCORE_FILENAME="toxcore-$TOXCORE_VERSION.tar.gz" | ||||||
| TOXCORE_HASH="653aa42654b607f0940cecfac873e9ce55605119a90d1dc454d1090ff6ca29c0" |  | ||||||
|  |  | ||||||
| TOXCORE_FILENAME="c-toxcore-$TOXCORE_VERSION.tar.gz" | wget --timeout=10 -O "$TOXCORE_FILENAME" "https://github.com/JFreegman/toxcore/archive/$TOXCORE_VERSION.tar.gz" | ||||||
|  |  | ||||||
| wget --timeout=10 -O "$TOXCORE_FILENAME" "https://github.com/TokTok/c-toxcore/archive/$TOXCORE_VERSION.tar.gz" |  | ||||||
| check_sha256 "$TOXCORE_HASH" "$TOXCORE_FILENAME" |  | ||||||
| tar -o -xf "$TOXCORE_FILENAME" | tar -o -xf "$TOXCORE_FILENAME" | ||||||
| rm "$TOXCORE_FILENAME" | rm "$TOXCORE_FILENAME" | ||||||
| cd c-toxcore* |  | ||||||
|  | cd toxcore* | ||||||
|  | mkdir -p "third_party" && cd "third_party" | ||||||
|  |  | ||||||
|  | CMP_VERSION="074e0df43e8a61ea938c4f77f65d1fbccc0c3bf9" | ||||||
|  | CMP_FILENAME="cmp-$CMP_VERSION.tar.gz" | ||||||
|  | wget --timeout=10 -O "$CMP_FILENAME" "https://github.com/TokTok/cmp/archive/$CMP_VERSION.tar.gz" | ||||||
|  | tar -o -xf "$CMP_FILENAME" | ||||||
|  |  | ||||||
|  | mv cmp\-*/* "cmp/" | ||||||
|  | cd .. | ||||||
|  |  | ||||||
| cmake -B_build -H. \ | cmake -B_build -H. \ | ||||||
|  |       -DUSE_TEST_NETWORK=ON \ | ||||||
|       -DENABLE_STATIC=ON \ |       -DENABLE_STATIC=ON \ | ||||||
|       -DENABLE_SHARED=OFF \ |       -DENABLE_SHARED=OFF \ | ||||||
|       -DCMAKE_BUILD_TYPE=Release \ |       -DCMAKE_BUILD_TYPE=Release \ | ||||||
|   | |||||||
| @@ -593,14 +593,15 @@ int load_DHT_nodeslist(void) | |||||||
|     memcpy(node->ip4, TESTNET_IP, sizeof(TESTNET_IP)); |     memcpy(node->ip4, TESTNET_IP, sizeof(TESTNET_IP)); | ||||||
|  |  | ||||||
|     struct Node *node2 = &Nodes.list[1]; |     struct Node *node2 = &Nodes.list[1]; | ||||||
|     node2->have_ip6 = true; |     node2->have_ip4 = true; | ||||||
|     node2->port = TESTNET_PORT2; |     node2->port = TESTNET_PORT2; | ||||||
|     memcpy(node2->key, TESTNET_KEY2, sizeof(TESTNET_KEY2)); |     memcpy(node2->key, TESTNET_KEY2, sizeof(TESTNET_KEY2)); | ||||||
|     memcpy(node2->ip6, TESTNET_IP2, sizeof(TESTNET_IP2)); |     memcpy(node2->ip4, TESTNET_IP2, sizeof(TESTNET_IP2)); | ||||||
|  |  | ||||||
|     Nodes.count = 2; |     Nodes.count = 2; | ||||||
|  |  | ||||||
| #if 0 | #if 0 | ||||||
|  |  | ||||||
|     if (thread_data.active) { |     if (thread_data.active) { | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
| @@ -623,6 +624,7 @@ int load_DHT_nodeslist(void) | |||||||
|         thread_data.active = false; |         thread_data.active = false; | ||||||
|         return -5; |         return -5; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     return 0; |     return 0; | ||||||
|   | |||||||
| @@ -134,7 +134,7 @@ static void set_self_typingstatus(ToxWindow *self, Tox *m, bool is_typing) | |||||||
|  |  | ||||||
|     ChatContext *ctx = self->chatwin; |     ChatContext *ctx = self->chatwin; | ||||||
|  |  | ||||||
|     TOX_ERR_SET_TYPING err; |     Tox_Err_Set_Typing err; | ||||||
|     tox_self_set_typing(m, self->num, is_typing, &err); |     tox_self_set_typing(m, self->num, is_typing, &err); | ||||||
|  |  | ||||||
|     if (err != TOX_ERR_SET_TYPING_OK) { |     if (err != TOX_ERR_SET_TYPING_OK) { | ||||||
|   | |||||||
| @@ -1129,7 +1129,7 @@ int game_packet_send(const GameData *game, const uint8_t *data, size_t length, G | |||||||
|     memcpy(packet + 1 + GAME_PACKET_HEADER_SIZE, data, length); |     memcpy(packet + 1 + GAME_PACKET_HEADER_SIZE, data, length); | ||||||
|     packet_length += length; |     packet_length += length; | ||||||
|  |  | ||||||
|     TOX_ERR_FRIEND_CUSTOM_PACKET err; |     Tox_Err_Friend_Custom_Packet err; | ||||||
|  |  | ||||||
|     if (!tox_friend_send_lossless_packet(game->tox, game->friend_number, packet, packet_length, &err)) { |     if (!tox_friend_send_lossless_packet(game->tox, game->friend_number, packet, packet_length, &err)) { | ||||||
|         fprintf(stderr, "failed to send game packet: error %d\n", err); |         fprintf(stderr, "failed to send game packet: error %d\n", err); | ||||||
|   | |||||||
| @@ -90,20 +90,20 @@ void cmd_ignore(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[ | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     Tox_Err_Group_Toggle_Ignore err; |     Tox_Err_Group_Set_Ignore err; | ||||||
|     tox_group_toggle_ignore(m, self->num, peer_id, true, &err); |     tox_group_set_ignore(m, self->num, peer_id, true, &err); | ||||||
|  |  | ||||||
|     switch (err) { |     switch (err) { | ||||||
|         case TOX_ERR_GROUP_TOGGLE_IGNORE_OK: { |         case TOX_ERR_GROUP_SET_IGNORE_OK: { | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         case TOX_ERR_GROUP_TOGGLE_IGNORE_SELF: { |         case TOX_ERR_GROUP_SET_IGNORE_SELF: { | ||||||
|             line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "You cannot ignore yourself."); |             line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "You cannot ignore yourself."); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         case TOX_ERR_GROUP_TOGGLE_IGNORE_PEER_NOT_FOUND: { |         case TOX_ERR_GROUP_SET_IGNORE_PEER_NOT_FOUND: { | ||||||
|             line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "The specified nick or public key is invalid."); |             line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "The specified nick or public key is invalid."); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| @@ -791,20 +791,20 @@ void cmd_unignore(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     Tox_Err_Group_Toggle_Ignore err; |     Tox_Err_Group_Set_Ignore err; | ||||||
|     tox_group_toggle_ignore(m, self->num, peer_id, false, &err); |     tox_group_set_ignore(m, self->num, peer_id, false, &err); | ||||||
|  |  | ||||||
|     switch (err) { |     switch (err) { | ||||||
|         case TOX_ERR_GROUP_TOGGLE_IGNORE_OK: { |         case TOX_ERR_GROUP_SET_IGNORE_OK: { | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         case TOX_ERR_GROUP_TOGGLE_IGNORE_SELF: { |         case TOX_ERR_GROUP_SET_IGNORE_SELF: { | ||||||
|             line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "You cannot unignore yourself."); |             line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "You cannot unignore yourself."); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         case TOX_ERR_GROUP_TOGGLE_IGNORE_PEER_NOT_FOUND: { |         case TOX_ERR_GROUP_SET_IGNORE_PEER_NOT_FOUND: { | ||||||
|             line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "The specified nick or public key is invalid."); |             line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "The specified nick or public key is invalid."); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -68,7 +68,7 @@ static int max_groupchat_index = 0; | |||||||
| extern struct user_settings *user_settings; | extern struct user_settings *user_settings; | ||||||
| extern struct Winthread Winthread; | extern struct Winthread Winthread; | ||||||
|  |  | ||||||
| #define GROUP_SIDEBAR_OFFSET 2    /* Offset for the peer number box at the top of the statusbar */ | #define GROUP_SIDEBAR_OFFSET 3    /* Offset for the peer number box at the top of the statusbar */ | ||||||
|  |  | ||||||
| /* groupchat command names used for tab completion. */ | /* groupchat command names used for tab completion. */ | ||||||
| static const char *group_cmd_list[] = { | static const char *group_cmd_list[] = { | ||||||
| @@ -991,7 +991,9 @@ static void groupchat_onGroupPeerJoin(ToxWindow *self, Tox *m, uint32_t groupnum | |||||||
|             ++chat->max_idx; |             ++chat->max_idx; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (timed_out(chat->time_connected, 7)) {   /* ignore join messages when we first connect to the group */ |         if (timed_out(chat->time_connected, 60) | ||||||
|  |                 && user_settings->show_group_connection_msg == | ||||||
|  |                 SHOW_GROUP_CONNECTION_MSG_ON) {   /* ignore join messages when we first connect to the group */ | ||||||
|             line_info_add(self, true, peer->name, NULL, CONNECTION, 0, GREEN, "has joined the room"); |             line_info_add(self, true, peer->name, NULL, CONNECTION, 0, GREEN, "has joined the room"); | ||||||
|  |  | ||||||
|             write_to_log("has joined the room", peer->name, self->chatwin->log, true); |             write_to_log("has joined the room", peer->name, self->chatwin->log, true); | ||||||
| @@ -1027,14 +1029,16 @@ void groupchat_onGroupPeerExit(ToxWindow *self, Tox *m, uint32_t groupnumber, ui | |||||||
|         if (length > 0) { |         if (length > 0) { | ||||||
|             line_info_add(self, true, name, NULL, DISCONNECTION, 0, RED, "[Quit]: %s", part_message); |             line_info_add(self, true, name, NULL, DISCONNECTION, 0, RED, "[Quit]: %s", part_message); | ||||||
|             snprintf(log_str, sizeof(log_str), "has left the room (%s)", part_message); |             snprintf(log_str, sizeof(log_str), "has left the room (%s)", part_message); | ||||||
|         } else { |             write_to_log(log_str, name, self->chatwin->log, true); | ||||||
|  |             sound_notify(self, silent, NT_WNDALERT_2, NULL); | ||||||
|  |         } else if (user_settings->show_group_connection_msg == SHOW_GROUP_CONNECTION_MSG_ON) { | ||||||
|             const char *exit_string = get_group_exit_string(exit_type); |             const char *exit_string = get_group_exit_string(exit_type); | ||||||
|             line_info_add(self, true, name, NULL, DISCONNECTION, 0, RED, "[%s]", exit_string); |             line_info_add(self, true, name, NULL, DISCONNECTION, 0, RED, "[%s]", exit_string); | ||||||
|             snprintf(log_str, sizeof(log_str), "[%s]", exit_string); |             snprintf(log_str, sizeof(log_str), "[%s]", exit_string); | ||||||
|  |             write_to_log(log_str, name, self->chatwin->log, true); | ||||||
|  |             sound_notify(self, silent, NT_WNDALERT_2, NULL); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         write_to_log(log_str, name, self->chatwin->log, true); |  | ||||||
|         sound_notify(self, silent, NT_WNDALERT_2, NULL); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     int peer_index = get_peer_index(groupnumber, peer_id); |     int peer_index = get_peer_index(groupnumber, peer_id); | ||||||
| @@ -1372,7 +1376,7 @@ static void send_group_message(ToxWindow *self, Tox *m, uint32_t groupnumber, co | |||||||
|  |  | ||||||
|     Tox_Err_Group_Send_Message err; |     Tox_Err_Group_Send_Message err; | ||||||
|  |  | ||||||
|     if (!tox_group_send_message(m, groupnumber, type, (uint8_t *) msg, strlen(msg), &err)) { |     if (!tox_group_send_message(m, groupnumber, type, (uint8_t *) msg, strlen(msg), NULL, &err)) { | ||||||
|         if (err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS) { |         if (err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS) { | ||||||
|             const Tox_Group_Role role = tox_group_self_get_role(m, groupnumber, NULL); |             const Tox_Group_Role role = tox_group_self_get_role(m, groupnumber, NULL); | ||||||
|  |  | ||||||
| @@ -1669,14 +1673,15 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m) | |||||||
|         mvwhline(ctx->sidebar, 1, 1, ACS_HLINE, SIDEBAR_WIDTH - 1); |         mvwhline(ctx->sidebar, 1, 1, ACS_HLINE, SIDEBAR_WIDTH - 1); | ||||||
|         wattroff(ctx->sidebar, COLOR_PAIR(BLUE)); |         wattroff(ctx->sidebar, COLOR_PAIR(BLUE)); | ||||||
|  |  | ||||||
|         int maxlines = y2 - GROUP_SIDEBAR_OFFSET - CHATBOX_HEIGHT; |         const int maxlines = y2 - GROUP_SIDEBAR_OFFSET - CHATBOX_HEIGHT; | ||||||
|         uint32_t i, offset = 0; |         uint32_t offset = 0; | ||||||
|  |  | ||||||
|         pthread_mutex_lock(&Winthread.lock); |         pthread_mutex_lock(&Winthread.lock); | ||||||
|         uint32_t max_idx = chat->max_idx; |         const uint32_t max_idx = chat->max_idx; | ||||||
|  |         const uint32_t start = chat->side_pos; | ||||||
|         pthread_mutex_unlock(&Winthread.lock); |         pthread_mutex_unlock(&Winthread.lock); | ||||||
|  |  | ||||||
|         for (i = 0; i < max_idx && i < maxlines; ++i) { |         for (uint32_t i = start; i < max_idx && offset < maxlines; ++i) { | ||||||
|             pthread_mutex_lock(&Winthread.lock); |             pthread_mutex_lock(&Winthread.lock); | ||||||
|  |  | ||||||
|             if (!chat->peer_list[i].active) { |             if (!chat->peer_list[i].active) { | ||||||
| @@ -1686,22 +1691,21 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m) | |||||||
|  |  | ||||||
|             wmove(ctx->sidebar, offset + 2, 1); |             wmove(ctx->sidebar, offset + 2, 1); | ||||||
|  |  | ||||||
|             int p = i + chat->side_pos; |             const int maxlen_offset = chat->peer_list[i].role == TOX_GROUP_ROLE_USER ? 2 : 3; | ||||||
|             int maxlen_offset = chat->peer_list[p].role == TOX_GROUP_ROLE_USER ? 2 : 3; |  | ||||||
|  |  | ||||||
|             /* truncate nick to fit in side panel without modifying list */ |             /* truncate nick to fit in side panel without modifying list */ | ||||||
|             char tmpnck[TOX_MAX_NAME_LENGTH]; |             char tmpnck[TOX_MAX_NAME_LENGTH]; | ||||||
|             int maxlen = SIDEBAR_WIDTH - maxlen_offset; |             const int maxlen = SIDEBAR_WIDTH - maxlen_offset; | ||||||
|  |  | ||||||
|             memcpy(tmpnck, chat->peer_list[p].name, maxlen); |             memcpy(tmpnck, chat->peer_list[i].name, maxlen); | ||||||
|  |  | ||||||
|             tmpnck[maxlen] = '\0'; |             tmpnck[maxlen] = '\0'; | ||||||
|  |  | ||||||
|             int namecolour = WHITE; |             int namecolour = WHITE; | ||||||
|  |  | ||||||
|             if (chat->peer_list[p].status == TOX_USER_STATUS_AWAY) { |             if (chat->peer_list[i].status == TOX_USER_STATUS_AWAY) { | ||||||
|                 namecolour = YELLOW; |                 namecolour = YELLOW; | ||||||
|             } else if (chat->peer_list[p].status == TOX_USER_STATUS_BUSY) { |             } else if (chat->peer_list[i].status == TOX_USER_STATUS_BUSY) { | ||||||
|                 namecolour = RED; |                 namecolour = RED; | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -1709,13 +1713,13 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m) | |||||||
|             const char *rolesig = ""; |             const char *rolesig = ""; | ||||||
|             int rolecolour = WHITE; |             int rolecolour = WHITE; | ||||||
|  |  | ||||||
|             if (chat->peer_list[p].role == TOX_GROUP_ROLE_FOUNDER) { |             if (chat->peer_list[i].role == TOX_GROUP_ROLE_FOUNDER) { | ||||||
|                 rolesig = "&"; |                 rolesig = "&"; | ||||||
|                 rolecolour = BLUE; |                 rolecolour = BLUE; | ||||||
|             } else if (chat->peer_list[p].role == TOX_GROUP_ROLE_MODERATOR) { |             } else if (chat->peer_list[i].role == TOX_GROUP_ROLE_MODERATOR) { | ||||||
|                 rolesig = "+"; |                 rolesig = "+"; | ||||||
|                 rolecolour = GREEN; |                 rolecolour = GREEN; | ||||||
|             } else if (chat->peer_list[p].role == TOX_GROUP_ROLE_OBSERVER) { |             } else if (chat->peer_list[i].role == TOX_GROUP_ROLE_OBSERVER) { | ||||||
|                 rolesig = "-"; |                 rolesig = "-"; | ||||||
|                 rolecolour = MAGENTA; |                 rolecolour = MAGENTA; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -186,7 +186,6 @@ static void help_draw_global(ToxWindow *self) | |||||||
|     wprintw(win, "  /nick <nick>               : Set your nickname\n"); |     wprintw(win, "  /nick <nick>               : Set your nickname\n"); | ||||||
|     wprintw(win, "  /nospam <value>            : Change part of your Tox ID to stop spam\n"); |     wprintw(win, "  /nospam <value>            : Change part of your Tox ID to stop spam\n"); | ||||||
|     wprintw(win, "  /log <on> or <off>         : Enable/disable logging\n"); |     wprintw(win, "  /log <on> or <off>         : Enable/disable logging\n"); | ||||||
|     wprintw(win, "  /conference <type>         : Create a conference where type: text | audio\n"); |  | ||||||
|     wprintw(win, "  /myid                      : Print your Tox ID\n"); |     wprintw(win, "  /myid                      : Print your Tox ID\n"); | ||||||
|     wprintw(win, "  /group <name>              : Create a new group chat\n"); |     wprintw(win, "  /group <name>              : Create a new group chat\n"); | ||||||
| #ifdef GAMES | #ifdef GAMES | ||||||
|   | |||||||
| @@ -144,11 +144,14 @@ static struct line_info *line_info_ret_queue(struct history *hst) | |||||||
|  */ |  */ | ||||||
| static int print_n_chars(WINDOW *win, const wchar_t *s, size_t n, int max_y) | static int print_n_chars(WINDOW *win, const wchar_t *s, size_t n, int max_y) | ||||||
| { | { | ||||||
|  |     // we use an array to represent a single wchar in order to get around an ncurses | ||||||
|  |     // bug with waddnwstr() that overreads the memory address by one byte when | ||||||
|  |     // supplied with a single wchar. | ||||||
|  |     wchar_t ch[2] = {0}; | ||||||
|     bool newline = false; |     bool newline = false; | ||||||
|     wchar_t ch; |  | ||||||
|  |  | ||||||
|     for (size_t i = 0; i < n && (ch = s[i]); ++i) { |     for (size_t i = 0; i < n && (ch[0] = s[i]); ++i) { | ||||||
|         if (ch == L'\n') { |         if (ch[0] == L'\n') { | ||||||
|             newline = true; |             newline = true; | ||||||
|  |  | ||||||
|             int x; |             int x; | ||||||
| @@ -165,11 +168,11 @@ static int print_n_chars(WINDOW *win, const wchar_t *s, size_t n, int max_y) | |||||||
|  |  | ||||||
|         if (win) { |         if (win) { | ||||||
| #ifdef HAVE_WIDECHAR | #ifdef HAVE_WIDECHAR | ||||||
|             waddnwstr(win, &ch, 1); |             waddnwstr(win, ch, 1); | ||||||
| #else | #else | ||||||
|             char b; |             char b; | ||||||
|  |  | ||||||
|             if (wcstombs(&b, &ch, sizeof(char)) != 1) { |             if (wcstombs(&b, ch, sizeof(char)) != 1) { | ||||||
|                 continue; |                 continue; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -48,7 +48,7 @@ void cqueue_add(struct chat_queue *q, const char *msg, size_t len, uint8_t type, | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     struct cqueue_msg *new_m = malloc(sizeof(struct cqueue_msg)); |     struct cqueue_msg *new_m = calloc(1, sizeof(struct cqueue_msg)); | ||||||
|  |  | ||||||
|     if (new_m == NULL) { |     if (new_m == NULL) { | ||||||
|         exit_toxic_err("failed in cqueue_message", FATALERR_MEMORY); |         exit_toxic_err("failed in cqueue_message", FATALERR_MEMORY); | ||||||
| @@ -62,6 +62,7 @@ void cqueue_add(struct chat_queue *q, const char *msg, size_t len, uint8_t type, | |||||||
|     new_m->time_added = get_unix_time(); |     new_m->time_added = get_unix_time(); | ||||||
|     new_m->receipt = -1; |     new_m->receipt = -1; | ||||||
|     new_m->next = NULL; |     new_m->next = NULL; | ||||||
|  |     new_m->noread_flag = false; | ||||||
|  |  | ||||||
|     if (q->root == NULL) { |     if (q->root == NULL) { | ||||||
|         new_m->prev = NULL; |         new_m->prev = NULL; | ||||||
| @@ -203,7 +204,7 @@ void cqueue_try_send(ToxWindow *self, Tox *m) | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         TOX_ERR_FRIEND_SEND_MESSAGE err; |         Tox_Err_Friend_Send_Message err; | ||||||
|         Tox_Message_Type type = msg->type == OUT_MSG ? TOX_MESSAGE_TYPE_NORMAL : TOX_MESSAGE_TYPE_ACTION; |         Tox_Message_Type type = msg->type == OUT_MSG ? TOX_MESSAGE_TYPE_NORMAL : TOX_MESSAGE_TYPE_ACTION; | ||||||
|         uint32_t receipt = tox_friend_send_message(m, self->num, type, (uint8_t *) msg->message, msg->len, &err); |         uint32_t receipt = tox_friend_send_message(m, self->num, type, (uint8_t *) msg->message, msg->len, &err); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -20,9 +20,10 @@ | |||||||
|  * |  * | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|  | #include "api.h" | ||||||
|  |  | ||||||
| #ifdef PYTHON | #ifdef PYTHON | ||||||
| #include <Python.h> | #include <Python.h> | ||||||
| #include "api.h" |  | ||||||
|  |  | ||||||
| #include "execute.h" | #include "execute.h" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -63,6 +63,7 @@ static struct ui_strings { | |||||||
|     const char *show_typing_other; |     const char *show_typing_other; | ||||||
|     const char *show_welcome_msg; |     const char *show_welcome_msg; | ||||||
|     const char *show_connection_msg; |     const char *show_connection_msg; | ||||||
|  |     const char *show_group_connection_msg; | ||||||
|     const char *nodeslist_update_freq; |     const char *nodeslist_update_freq; | ||||||
|     const char *autosave_freq; |     const char *autosave_freq; | ||||||
|  |  | ||||||
| @@ -99,6 +100,7 @@ static struct ui_strings { | |||||||
|     "show_typing_other", |     "show_typing_other", | ||||||
|     "show_welcome_msg", |     "show_welcome_msg", | ||||||
|     "show_connection_msg", |     "show_connection_msg", | ||||||
|  |     "show_group_connection_msg", | ||||||
|     "nodeslist_update_freq", |     "nodeslist_update_freq", | ||||||
|     "autosave_freq", |     "autosave_freq", | ||||||
|     "line_join", |     "line_join", | ||||||
| @@ -136,6 +138,7 @@ static void ui_defaults(struct user_settings *settings) | |||||||
|     settings->show_typing_other = SHOW_TYPING_ON; |     settings->show_typing_other = SHOW_TYPING_ON; | ||||||
|     settings->show_welcome_msg = SHOW_WELCOME_MSG_ON; |     settings->show_welcome_msg = SHOW_WELCOME_MSG_ON; | ||||||
|     settings->show_connection_msg = SHOW_CONNECTION_MSG_ON; |     settings->show_connection_msg = SHOW_CONNECTION_MSG_ON; | ||||||
|  |     settings->show_group_connection_msg = SHOW_GROUP_CONNECTION_MSG_ON; | ||||||
|     settings->nodeslist_update_freq = 1; |     settings->nodeslist_update_freq = 1; | ||||||
|     settings->autosave_freq = 600; |     settings->autosave_freq = 600; | ||||||
|  |  | ||||||
| @@ -405,6 +408,7 @@ int settings_load(struct user_settings *s, const char *patharg) | |||||||
|         config_setting_lookup_bool(setting, ui_strings.show_typing_other, &s->show_typing_other); |         config_setting_lookup_bool(setting, ui_strings.show_typing_other, &s->show_typing_other); | ||||||
|         config_setting_lookup_bool(setting, ui_strings.show_welcome_msg, &s->show_welcome_msg); |         config_setting_lookup_bool(setting, ui_strings.show_welcome_msg, &s->show_welcome_msg); | ||||||
|         config_setting_lookup_bool(setting, ui_strings.show_connection_msg, &s->show_connection_msg); |         config_setting_lookup_bool(setting, ui_strings.show_connection_msg, &s->show_connection_msg); | ||||||
|  |         config_setting_lookup_bool(setting, ui_strings.show_group_connection_msg, &s->show_group_connection_msg); | ||||||
|  |  | ||||||
|         config_setting_lookup_int(setting, ui_strings.history_size, &s->history_size); |         config_setting_lookup_int(setting, ui_strings.history_size, &s->history_size); | ||||||
|         config_setting_lookup_int(setting, ui_strings.notification_timeout, &s->notification_timeout); |         config_setting_lookup_int(setting, ui_strings.notification_timeout, &s->notification_timeout); | ||||||
|   | |||||||
| @@ -54,6 +54,7 @@ struct user_settings { | |||||||
|     int show_typing_other; /* boolean */ |     int show_typing_other; /* boolean */ | ||||||
|     int show_welcome_msg;  /* boolean */ |     int show_welcome_msg;  /* boolean */ | ||||||
|     int show_connection_msg;  /* boolean */ |     int show_connection_msg;  /* boolean */ | ||||||
|  |     int show_group_connection_msg;  /* boolean */ | ||||||
|     int nodeslist_update_freq;  /* int (<= 0 to disable updates) */ |     int nodeslist_update_freq;  /* int (<= 0 to disable updates) */ | ||||||
|     int autosave_freq; /* int (<= 0 to disable autosave) */ |     int autosave_freq; /* int (<= 0 to disable autosave) */ | ||||||
|  |  | ||||||
| @@ -122,6 +123,9 @@ enum settings_values { | |||||||
|     SHOW_CONNECTION_MSG_OFF = 0, |     SHOW_CONNECTION_MSG_OFF = 0, | ||||||
|     SHOW_CONNECTION_MSG_ON = 1, |     SHOW_CONNECTION_MSG_ON = 1, | ||||||
|  |  | ||||||
|  |     SHOW_GROUP_CONNECTION_MSG_OFF = 0, | ||||||
|  |     SHOW_GROUP_CONNECTION_MSG_ON = 1, | ||||||
|  |  | ||||||
|     DFLT_HST_SIZE = 700, |     DFLT_HST_SIZE = 700, | ||||||
|  |  | ||||||
|     MPLEX_OFF = 0, |     MPLEX_OFF = 0, | ||||||
|   | |||||||
							
								
								
									
										20
									
								
								src/toxic.c
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								src/toxic.c
									
									
									
									
									
								
							| @@ -37,6 +37,7 @@ | |||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <sys/socket.h> | #include <sys/socket.h> | ||||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||||
|  | #include <sys/time.h> | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
| #include <termios.h> | #include <termios.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
| @@ -267,12 +268,21 @@ void cb_toxcore_logger(Tox *m, TOX_LOG_LEVEL level, const char *file, uint32_t l | |||||||
|         fp = stderr; |         fp = stderr; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const time_t t = time(NULL); |     struct timeval tv; | ||||||
|     struct tm *tmp = gmtime(&t); |  | ||||||
|     char timestamp[200]; |     gettimeofday(&tv, NULL); | ||||||
|     strftime(timestamp, sizeof(timestamp), "%F %T", tmp); |  | ||||||
|  |     struct tm tmp; | ||||||
|  |  | ||||||
|  |     gmtime_r(&tv.tv_sec, &tmp); | ||||||
|  |  | ||||||
|  |     char timestamp[200]; | ||||||
|  |  | ||||||
|  |     strftime(timestamp, sizeof(timestamp), "%F %T", &tmp); | ||||||
|  |  | ||||||
|  |     fprintf(fp, "%c %s.%06ld %s:%u(%s) - %s\n", tox_log_level_show(level)[0], timestamp, tv.tv_usec, file, line, func, | ||||||
|  |             message); | ||||||
|  |  | ||||||
|     fprintf(fp, "[%c] %s %s:%u(%s) - %s\n", tox_log_level_show(level)[0], timestamp, file, line, func, message); |  | ||||||
|     fflush(fp); |     fflush(fp); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -152,7 +152,7 @@ void on_group_invite(Tox *m, uint32_t friendnumber, const uint8_t *invite_data, | |||||||
|                      const uint8_t *group_name, |                      const uint8_t *group_name, | ||||||
|                      size_t group_name_length, void *userdata); |                      size_t group_name_length, void *userdata); | ||||||
| void on_group_message(Tox *m, uint32_t groupnumber, uint32_t peernumber, TOX_MESSAGE_TYPE type, | void on_group_message(Tox *m, uint32_t groupnumber, uint32_t peernumber, TOX_MESSAGE_TYPE type, | ||||||
|                       const uint8_t *message, size_t length, void *userdata); |                       const uint8_t *message, size_t length, uint32_t message_id, void *userdata); | ||||||
| void on_group_private_message(Tox *m, uint32_t groupnumber, uint32_t peernumber, TOX_MESSAGE_TYPE type, | void on_group_private_message(Tox *m, uint32_t groupnumber, uint32_t peernumber, TOX_MESSAGE_TYPE type, | ||||||
|                               const uint8_t *message, size_t length, |                               const uint8_t *message, size_t length, | ||||||
|                               void *userdata); |                               void *userdata); | ||||||
|   | |||||||
| @@ -395,8 +395,10 @@ void on_group_invite(Tox *m, uint32_t friendnumber, const uint8_t *invite_data, | |||||||
| } | } | ||||||
|  |  | ||||||
| void on_group_message(Tox *m, uint32_t groupnumber, uint32_t peer_id, TOX_MESSAGE_TYPE type, | void on_group_message(Tox *m, uint32_t groupnumber, uint32_t peer_id, TOX_MESSAGE_TYPE type, | ||||||
|                       const uint8_t *message, size_t length, void *userdata) |                       const uint8_t *message, size_t length, uint32_t message_id, void *userdata) | ||||||
| { | { | ||||||
|  |     UNUSED_VAR(message_id); | ||||||
|  |  | ||||||
|     char msg[MAX_STR_SIZE + 1]; |     char msg[MAX_STR_SIZE + 1]; | ||||||
|     length = copy_tox_str(msg, sizeof(msg), (const char *) message, length); |     length = copy_tox_str(msg, sizeof(msg), (const char *) message, length); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user