Compare commits
2 Commits
9d12e53259
...
3bba095cdd
Author | SHA1 | Date | |
---|---|---|---|
3bba095cdd | |||
bc090bdaa8 |
37
external/toxcore/c-toxcore/toxcore/group_chats.c
vendored
37
external/toxcore/c-toxcore/toxcore/group_chats.c
vendored
@ -170,7 +170,11 @@ static void kill_group_friend_connection(const GC_Session *c, const GC_Chat *cha
|
|||||||
|
|
||||||
uint16_t gc_get_wrapped_packet_size(uint16_t length, Net_Packet_Type packet_type)
|
uint16_t gc_get_wrapped_packet_size(uint16_t length, Net_Packet_Type packet_type)
|
||||||
{
|
{
|
||||||
assert(length <= MAX_GC_PACKET_CHUNK_SIZE);
|
if (packet_type == NET_PACKET_GC_LOSSY) {
|
||||||
|
assert(length <= MAX_GC_CUSTOM_LOSSY_PACKET_SIZE);
|
||||||
|
} else {
|
||||||
|
assert(length <= MAX_GC_PACKET_CHUNK_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
const uint16_t min_header_size = packet_type == NET_PACKET_GC_LOSSY
|
const uint16_t min_header_size = packet_type == NET_PACKET_GC_LOSSY
|
||||||
? GC_MIN_LOSSY_PAYLOAD_SIZE
|
? GC_MIN_LOSSY_PAYLOAD_SIZE
|
||||||
@ -215,9 +219,13 @@ GC_Connection *get_gc_connection(const GC_Chat *chat, int peer_number)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the amount of empty padding a packet of designated length should have. */
|
/** Returns the amount of empty padding a packet of designated length should have. */
|
||||||
static uint16_t group_packet_padding_length(uint16_t length)
|
static uint16_t group_packet_padding_length(uint16_t length, uint8_t net_packet_type)
|
||||||
{
|
{
|
||||||
return (MAX_GC_PACKET_CHUNK_SIZE - length) % GC_MAX_PACKET_PADDING;
|
if (net_packet_type == NET_PACKET_GC_LOSSY) {
|
||||||
|
return (MAX_GC_CUSTOM_LOSSY_PACKET_SIZE - length) % GC_MAX_PACKET_PADDING;
|
||||||
|
} else {
|
||||||
|
return (MAX_GC_PACKET_CHUNK_SIZE - length) % GC_MAX_PACKET_PADDING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gc_get_self_nick(const GC_Chat *chat, uint8_t *nick)
|
void gc_get_self_nick(const GC_Chat *chat, uint8_t *nick)
|
||||||
@ -1473,7 +1481,7 @@ int group_packet_wrap(
|
|||||||
uint16_t packet_size, const uint8_t *data, uint16_t length, uint64_t message_id,
|
uint16_t packet_size, const uint8_t *data, uint16_t length, uint64_t message_id,
|
||||||
uint8_t gp_packet_type, uint8_t net_packet_type)
|
uint8_t gp_packet_type, uint8_t net_packet_type)
|
||||||
{
|
{
|
||||||
const uint16_t padding_len = group_packet_padding_length(length);
|
const uint16_t padding_len = group_packet_padding_length(length, net_packet_type);
|
||||||
const uint16_t min_packet_size = net_packet_type == NET_PACKET_GC_LOSSLESS
|
const uint16_t min_packet_size = net_packet_type == NET_PACKET_GC_LOSSLESS
|
||||||
? length + padding_len + CRYPTO_MAC_SIZE + 1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + GC_MESSAGE_ID_BYTES + 1
|
? length + padding_len + CRYPTO_MAC_SIZE + 1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + GC_MESSAGE_ID_BYTES + 1
|
||||||
: length + padding_len + CRYPTO_MAC_SIZE + 1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + 1;
|
: length + padding_len + CRYPTO_MAC_SIZE + 1 + ENC_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + 1;
|
||||||
@ -1483,9 +1491,16 @@ int group_packet_wrap(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > MAX_GC_PACKET_CHUNK_SIZE) {
|
if (net_packet_type == NET_PACKET_GC_LOSSY) {
|
||||||
LOGGER_ERROR(log, "Packet payload size (%u) exceeds maximum (%u)", length, MAX_GC_PACKET_CHUNK_SIZE);
|
if (length > MAX_GC_CUSTOM_LOSSY_PACKET_SIZE) {
|
||||||
return -1;
|
LOGGER_ERROR(log, "Packet payload size (%u) exceeds maximum (%u)", length, MAX_GC_CUSTOM_LOSSY_PACKET_SIZE);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (length > MAX_GC_PACKET_CHUNK_SIZE) {
|
||||||
|
LOGGER_ERROR(log, "Packet payload size (%u) exceeds maximum (%u)", length, MAX_GC_PACKET_CHUNK_SIZE);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *plain = (uint8_t *)malloc(packet_size);
|
uint8_t *plain = (uint8_t *)malloc(packet_size);
|
||||||
@ -1551,7 +1566,7 @@ non_null()
|
|||||||
static bool send_lossy_group_packet(const GC_Chat *chat, const GC_Connection *gconn, const uint8_t *data,
|
static bool send_lossy_group_packet(const GC_Chat *chat, const GC_Connection *gconn, const uint8_t *data,
|
||||||
uint16_t length, uint8_t packet_type)
|
uint16_t length, uint8_t packet_type)
|
||||||
{
|
{
|
||||||
assert(length <= MAX_GC_PACKET_CHUNK_SIZE);
|
assert(length <= MAX_GC_CUSTOM_LOSSY_PACKET_SIZE);
|
||||||
|
|
||||||
if (!gconn->handshaked || gconn->pending_delete) {
|
if (!gconn->handshaked || gconn->pending_delete) {
|
||||||
return false;
|
return false;
|
||||||
@ -6392,13 +6407,13 @@ static int handle_gc_udp_packet(void *object, const IP_Port *ipp, const uint8_t
|
|||||||
|
|
||||||
if (length <= MIN_UDP_PACKET_SIZE) {
|
if (length <= MIN_UDP_PACKET_SIZE) {
|
||||||
LOGGER_WARNING(m->log, "Got UDP packet with invalid length: %u (expected %u to %u)", length,
|
LOGGER_WARNING(m->log, "Got UDP packet with invalid length: %u (expected %u to %u)", length,
|
||||||
MIN_UDP_PACKET_SIZE, MAX_GC_PACKET_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
|
MIN_UDP_PACKET_SIZE, MAX_GC_CUSTOM_LOSSY_PACKET_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > MAX_GC_PACKET_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE) {
|
if (length > MAX_GC_CUSTOM_LOSSY_PACKET_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE) {
|
||||||
LOGGER_WARNING(m->log, "Got UDP packet with invalid length: %u (expected %u to %u)", length,
|
LOGGER_WARNING(m->log, "Got UDP packet with invalid length: %u (expected %u to %u)", length,
|
||||||
MIN_UDP_PACKET_SIZE, MAX_GC_PACKET_CHUNK_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
|
MIN_UDP_PACKET_SIZE, MAX_GC_CUSTOM_LOSSY_PACKET_SIZE + MIN_UDP_PACKET_SIZE + ENC_PUBLIC_KEY_SIZE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#define MAX_GC_MESSAGE_SIZE GROUP_MAX_MESSAGE_LENGTH
|
#define MAX_GC_MESSAGE_SIZE GROUP_MAX_MESSAGE_LENGTH
|
||||||
#define MAX_GC_MESSAGE_RAW_SIZE (MAX_GC_MESSAGE_SIZE + GC_MESSAGE_PSEUDO_ID_SIZE)
|
#define MAX_GC_MESSAGE_RAW_SIZE (MAX_GC_MESSAGE_SIZE + GC_MESSAGE_PSEUDO_ID_SIZE)
|
||||||
#define MAX_GC_CUSTOM_LOSSLESS_PACKET_SIZE 1373
|
#define MAX_GC_CUSTOM_LOSSLESS_PACKET_SIZE 1373
|
||||||
#define MAX_GC_CUSTOM_LOSSY_PACKET_SIZE MAX_GC_PACKET_CHUNK_SIZE
|
#define MAX_GC_CUSTOM_LOSSY_PACKET_SIZE 1000
|
||||||
#define MAX_GC_PASSWORD_SIZE 32
|
#define MAX_GC_PASSWORD_SIZE 32
|
||||||
#define MAX_GC_SAVED_INVITES 10
|
#define MAX_GC_SAVED_INVITES 10
|
||||||
#define MAX_GC_PEERS_DEFAULT 100
|
#define MAX_GC_PEERS_DEFAULT 100
|
||||||
|
2
external/toxcore/c-toxcore/toxcore/tox.h
vendored
2
external/toxcore/c-toxcore/toxcore/tox.h
vendored
@ -3310,7 +3310,7 @@ uint32_t tox_group_max_message_length(void);
|
|||||||
/**
|
/**
|
||||||
* Maximum length of a group custom lossy packet.
|
* Maximum length of a group custom lossy packet.
|
||||||
*/
|
*/
|
||||||
#define TOX_GROUP_MAX_CUSTOM_LOSSY_PACKET_LENGTH 500
|
#define TOX_GROUP_MAX_CUSTOM_LOSSY_PACKET_LENGTH 1000
|
||||||
|
|
||||||
uint32_t tox_group_max_custom_lossy_packet_length(void);
|
uint32_t tox_group_max_custom_lossy_packet_length(void);
|
||||||
|
|
||||||
|
@ -52,6 +52,9 @@ add_executable(tomato
|
|||||||
./send_image_popup.hpp
|
./send_image_popup.hpp
|
||||||
./send_image_popup.cpp
|
./send_image_popup.cpp
|
||||||
|
|
||||||
|
./settings_window.hpp
|
||||||
|
./settings_window.cpp
|
||||||
|
|
||||||
./chat_gui4.hpp
|
./chat_gui4.hpp
|
||||||
./chat_gui4.cpp
|
./chat_gui4.cpp
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,8 @@ MainScreen::MainScreen(SDL_Renderer* renderer_, std::string save_path, std::stri
|
|||||||
mmil(rmm),
|
mmil(rmm),
|
||||||
tam(rmm, cr, conf),
|
tam(rmm, cr, conf),
|
||||||
sdlrtu(renderer_),
|
sdlrtu(renderer_),
|
||||||
cg(conf, rmm, cr, sdlrtu)
|
cg(conf, rmm, cr, sdlrtu),
|
||||||
|
sw(conf)
|
||||||
{
|
{
|
||||||
tel.subscribeAll(tc);
|
tel.subscribeAll(tc);
|
||||||
|
|
||||||
@ -87,11 +88,29 @@ Screen* MainScreen::poll(bool& quit) {
|
|||||||
|
|
||||||
tam.iterate();
|
tam.iterate();
|
||||||
|
|
||||||
|
// HACK: render the tomato main window first, with proper flags set.
|
||||||
|
// flags need to be set the first time begin() is called.
|
||||||
|
// and plugins are run before the main cg is run.
|
||||||
|
{
|
||||||
|
// TODO: maybe render cg earlier? or move the main window out of cg?
|
||||||
|
constexpr auto bg_window_flags =
|
||||||
|
ImGuiWindowFlags_NoDecoration |
|
||||||
|
ImGuiWindowFlags_NoMove |
|
||||||
|
ImGuiWindowFlags_NoResize |
|
||||||
|
ImGuiWindowFlags_NoSavedSettings |
|
||||||
|
ImGuiWindowFlags_MenuBar |
|
||||||
|
ImGuiWindowFlags_NoBringToFrontOnFocus;
|
||||||
|
|
||||||
|
ImGui::Begin("tomato", nullptr, bg_window_flags);
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
pm.tick(time_delta);
|
pm.tick(time_delta);
|
||||||
|
|
||||||
mts.iterate();
|
mts.iterate();
|
||||||
|
|
||||||
cg.render();
|
cg.render();
|
||||||
|
sw.render();
|
||||||
|
|
||||||
if constexpr (false) {
|
if constexpr (false) {
|
||||||
ImGui::ShowDemoWindow();
|
ImGui::ShowDemoWindow();
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "./sdlrenderer_texture_uploader.hpp"
|
#include "./sdlrenderer_texture_uploader.hpp"
|
||||||
#include "./chat_gui4.hpp"
|
#include "./chat_gui4.hpp"
|
||||||
|
#include "./settings_window.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -57,6 +58,7 @@ struct MainScreen final : public Screen {
|
|||||||
//OpenGLTextureUploader ogltu;
|
//OpenGLTextureUploader ogltu;
|
||||||
|
|
||||||
ChatGui4 cg;
|
ChatGui4 cg;
|
||||||
|
SettingsWindow sw;
|
||||||
|
|
||||||
MainScreen(SDL_Renderer* renderer_, std::string save_path, std::string save_password, std::vector<std::string> plugins);
|
MainScreen(SDL_Renderer* renderer_, std::string save_path, std::string save_password, std::vector<std::string> plugins);
|
||||||
~MainScreen(void);
|
~MainScreen(void);
|
||||||
|
35
src/settings_window.cpp
Normal file
35
src/settings_window.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include "./settings_window.hpp"
|
||||||
|
|
||||||
|
#include <imgui/imgui.h>
|
||||||
|
#include <imgui/misc/cpp/imgui_stdlib.h>
|
||||||
|
|
||||||
|
SettingsWindow::SettingsWindow(ConfigModelI& conf) : _conf(conf) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWindow::render(void) {
|
||||||
|
{ // main window menubar injection
|
||||||
|
// assumes the window "tomato" was rendered already by cg
|
||||||
|
if (ImGui::Begin("tomato")) {
|
||||||
|
if (ImGui::BeginMenuBar()) {
|
||||||
|
ImGui::Separator();
|
||||||
|
if (ImGui::BeginMenu("Settings")) {
|
||||||
|
if (ImGui::MenuItem("show settings window")) {
|
||||||
|
_show_window = true;
|
||||||
|
}
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_show_window) {
|
||||||
|
if (ImGui::Begin("Settings", &_show_window)) {
|
||||||
|
ImGui::Text("Settings here sldjflsadfs");
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
14
src/settings_window.hpp
Normal file
14
src/settings_window.hpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct ConfigModelI;
|
||||||
|
|
||||||
|
class SettingsWindow {
|
||||||
|
bool _show_window {false};
|
||||||
|
ConfigModelI& _conf;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SettingsWindow(ConfigModelI& conf);
|
||||||
|
|
||||||
|
void render(void);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user