improve tox add friend/group, creating the contact directly
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android-23]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android-23]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android-23]) (push) Has been cancelled
ContinuousDelivery / windows (push) Has been cancelled
ContinuousDelivery / windows-asan (push) Has been cancelled
ContinuousDelivery / dumpsyms (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled
ContinuousIntegration / linux (push) Has been cancelled
ContinuousIntegration / linux-arm (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android-23]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android-23]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android-23]) (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
Some checks failed
ContinuousDelivery / linux-ubuntu (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android-23]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android-23]) (push) Has been cancelled
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android-23]) (push) Has been cancelled
ContinuousDelivery / windows (push) Has been cancelled
ContinuousDelivery / windows-asan (push) Has been cancelled
ContinuousDelivery / dumpsyms (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled
ContinuousIntegration / linux (push) Has been cancelled
ContinuousIntegration / linux-arm (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android-23]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android-23]) (push) Has been cancelled
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android-23]) (push) Has been cancelled
ContinuousIntegration / macos (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
and add new group creation
This commit is contained in:
2
external/solanaceae_tox
vendored
2
external/solanaceae_tox
vendored
Submodule external/solanaceae_tox updated: 178f08ee96...91ae0671b0
@@ -67,7 +67,7 @@ MainScreen::MainScreen(const SimpleConfigModel& conf_, SDL_Renderer* renderer_,
|
||||
cg(conf, os, rmm, cs, sdlrtu, contact_tc, msg_tc, theme),
|
||||
sw(conf),
|
||||
osui(os),
|
||||
tuiu(tc, conf, &tpi),
|
||||
tuiu(tc, tcm, conf, &tpi),
|
||||
tdch(tpi),
|
||||
tnui(tpi),
|
||||
smui(os, sm),
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include "./tox_client.hpp"
|
||||
|
||||
#include <solanaceae/toxcore/tox_private_interface.hpp>
|
||||
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
|
||||
|
||||
#include <tox/tox.h>
|
||||
|
||||
@@ -10,6 +11,9 @@
|
||||
|
||||
#include <solanaceae/util/config_model.hpp>
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/handle.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <misc/cpp/imgui_stdlib.h>
|
||||
|
||||
@@ -17,9 +21,10 @@
|
||||
|
||||
ToxUIUtils::ToxUIUtils(
|
||||
ToxClient& tc,
|
||||
ToxContactModel2& tcm,
|
||||
ConfigModelI& conf,
|
||||
ToxPrivateI* tp
|
||||
) : _tc(tc), _conf(conf), _tp(tp) {
|
||||
) : _tc(tc), _tcm(tcm), _conf(conf), _tp(tp) {
|
||||
}
|
||||
|
||||
void ToxUIUtils::render(void) {
|
||||
@@ -29,7 +34,7 @@ void ToxUIUtils::render(void) {
|
||||
if (ImGui::BeginMenuBar()) {
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu("Tox")) {
|
||||
ImGui::SeparatorText("Friends/Groups");
|
||||
ImGui::SeparatorText("Friends");
|
||||
|
||||
if (ImGui::MenuItem("add Friend by ID", nullptr, _show_add_friend_window)) {
|
||||
_show_add_friend_window = !_show_add_friend_window;
|
||||
@@ -37,6 +42,8 @@ void ToxUIUtils::render(void) {
|
||||
if (ImGui::MenuItem("copy own ToxID")) {
|
||||
ImGui::SetClipboardText(_tc.toxSelfGetAddressStr().c_str());
|
||||
}
|
||||
|
||||
ImGui::SeparatorText("Groups");
|
||||
if (ImGui::MenuItem("join Group by ID (ngc)", nullptr, _show_add_group_window)) {
|
||||
_show_add_group_window = !_show_add_group_window;
|
||||
}
|
||||
@@ -62,6 +69,10 @@ void ToxUIUtils::render(void) {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("new Group (ngc)", nullptr, _show_new_group_window)) {
|
||||
_show_new_group_window = !_show_new_group_window;
|
||||
}
|
||||
|
||||
ImGui::SeparatorText("DHT");
|
||||
|
||||
if (ImGui::MenuItem("rerun bootstrap")) {
|
||||
@@ -111,7 +122,10 @@ void ToxUIUtils::render(void) {
|
||||
|
||||
static Tox_Err_Friend_Add err = Tox_Err_Friend_Add::TOX_ERR_FRIEND_ADD_OK;
|
||||
if (ImGui::Button("add")) {
|
||||
auto [_, err_r] = _tc.toxFriendAdd(hex2bin(std::string_view{tox_id, std::size(tox_id)-1}), message);
|
||||
auto [_, err_r] = _tcm.createContactFriend(
|
||||
std::string_view{tox_id, std::size(tox_id)-1},
|
||||
message
|
||||
);
|
||||
err = err_r;
|
||||
|
||||
{ // reset everything
|
||||
@@ -143,8 +157,8 @@ void ToxUIUtils::render(void) {
|
||||
|
||||
static Tox_Err_Group_Join err = Tox_Err_Group_Join::TOX_ERR_GROUP_JOIN_OK;
|
||||
if (ImGui::Button("join/reconnect")) {
|
||||
auto [_, err_r] = _tc.toxGroupJoin(
|
||||
hex2bin(std::string_view{_chat_id, std::size(_chat_id)-1}),
|
||||
auto [_, err_r] = _tcm.createContactGroupJoin(
|
||||
std::string_view{_chat_id, std::size(_chat_id)-1},
|
||||
self_name,
|
||||
password
|
||||
);
|
||||
@@ -168,5 +182,59 @@ void ToxUIUtils::render(void) {
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
if (_show_new_group_window) {
|
||||
if (ImGui::Begin("Tox new Group", &_show_new_group_window)) {
|
||||
ImGui::TextDisabled("NGC refers to the New DHT enabled Group Chats.");
|
||||
ImGui::TextDisabled("Connecting via ID might take a very long time.");
|
||||
|
||||
static int privacy_state{Tox_Group_Privacy_State::TOX_GROUP_PRIVACY_STATE_PUBLIC};
|
||||
ImGui::Combo("privacy state", &privacy_state, "public\0private\0");
|
||||
ImGui::SetItemTooltip("Public groups get announced to the DHT.\nAnyone can scrape the DHT and find your group.\n\nPrivate groups can not be joined via ID (DHT lookup).");
|
||||
|
||||
static std::string name;
|
||||
ImGui::InputText("name of the group", &name);
|
||||
|
||||
static std::string self_name = _conf.get_string("tox", "name").value_or("default_tomato");
|
||||
ImGui::InputText("name of yourself", &self_name);
|
||||
|
||||
static std::string password;
|
||||
ImGui::InputText("password for group", &password);
|
||||
|
||||
static Tox_Err_Group_New err = Tox_Err_Group_New::TOX_ERR_GROUP_NEW_OK;
|
||||
static Tox_Err_Group_Set_Password err_pw = Tox_Err_Group_Set_Password::TOX_ERR_GROUP_SET_PASSWORD_OK;
|
||||
if (ImGui::Button("create")) {
|
||||
auto [new_c, err_r, err_pw_r] = _tcm.createContactGroupNew(
|
||||
static_cast<Tox_Group_Privacy_State>(privacy_state),
|
||||
name,
|
||||
self_name,
|
||||
password
|
||||
);
|
||||
err = err_r;
|
||||
err_pw = err_pw_r;
|
||||
|
||||
{ // reset everything
|
||||
for (size_t i = 0; i < name.size(); i++) {
|
||||
name.at(i) = '\0';
|
||||
}
|
||||
name.clear();
|
||||
|
||||
self_name = _conf.get_string("tox", "name").value_or("default_tomato");
|
||||
|
||||
for (size_t i = 0; i < password.size(); i++) {
|
||||
password.at(i) = '\0';
|
||||
}
|
||||
password.clear();
|
||||
}
|
||||
}
|
||||
if (err != Tox_Err_Group_New::TOX_ERR_GROUP_NEW_OK || err_pw != Tox_Err_Group_Set_Password::TOX_ERR_GROUP_SET_PASSWORD_OK) {
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("error creating group!");
|
||||
ImGui::Text("group: '%s' (%d)", tox_err_group_new_to_string(err), err);
|
||||
ImGui::Text("pw: '%s' (%d)", tox_err_group_set_password_to_string(err_pw), err_pw);
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,12 +5,15 @@
|
||||
class ToxClient;
|
||||
struct ConfigModelI;
|
||||
struct ToxPrivateI;
|
||||
class ToxContactModel2;
|
||||
|
||||
class ToxUIUtils {
|
||||
bool _show_add_friend_window {false};
|
||||
bool _show_add_group_window {false};
|
||||
bool _show_new_group_window {false};
|
||||
|
||||
ToxClient& _tc;
|
||||
ToxContactModel2& _tcm;
|
||||
ConfigModelI& _conf;
|
||||
ToxPrivateI* _tp {nullptr};
|
||||
|
||||
@@ -19,6 +22,7 @@ class ToxUIUtils {
|
||||
public:
|
||||
ToxUIUtils(
|
||||
ToxClient& tc,
|
||||
ToxContactModel2& tcm,
|
||||
ConfigModelI& conf,
|
||||
ToxPrivateI* tp = nullptr
|
||||
);
|
||||
|
Reference in New Issue
Block a user