Skip to content

Commit

Permalink
enable setting to enable experimental NOISE handshake
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Dec 2, 2023
1 parent 4ffd0c7 commit c0bd9cf
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 6 deletions.
Binary file added resources/common/jni-c-toxcore_noise.dll
Binary file not shown.
Binary file added resources/common/libjni-c-toxcore_noise.jnilib
Binary file not shown.
Binary file added resources/common/libjni-c-toxcore_noise.so
Binary file not shown.
22 changes: 20 additions & 2 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@file:OptIn(ExperimentalComposeUiApi::class, ExperimentalFoundationApi::class)

import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
Expand Down Expand Up @@ -80,6 +81,7 @@ import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathEffect
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.graphics.painter.Painter
Expand Down Expand Up @@ -192,6 +194,7 @@ import java.util.prefs.Preferences
import javax.swing.JFrame
import javax.swing.JPanel
import javax.swing.UIManager
import javax.swing.border.Border

private const val TAG = "trifa.Main.kt"
var tox_running_state_wrapper = "start"
Expand Down Expand Up @@ -350,8 +353,23 @@ fun App()
}
var online_button_text by remember { mutableStateOf("offline") }
Button( // self connection state button
modifier = Modifier.width(120.dp), onClick = {}, colors = ButtonDefaults.buttonColors(), enabled = false) {
Box(modifier = Modifier.size(16.dp).border(1.dp, Color.Black, CircleShape).background(Color(online_button_color_wrapper), CircleShape))
modifier = Modifier.width(120.dp),
onClick = {},
border = BorderStroke(
if (MainActivity.PREF__toxnoise_enabled_to_int_used_for_init == 1)
3.dp
else
0.dp,
if (MainActivity.PREF__toxnoise_enabled_to_int_used_for_init == 1)
Color.Red
else
Color.Transparent
),
colors = ButtonDefaults.buttonColors(),
enabled = false) {
Box(modifier = Modifier.size(16.dp).border(1.dp,
Color.Black,
CircleShape).background(Color(online_button_color_wrapper), CircleShape))
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
Text(getOnlineButtonText(online_button_text))
Thread {
Expand Down
28 changes: 24 additions & 4 deletions src/main/kotlin/com/zoffcc/applications/trifa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class MainActivity
var PREF__v4l2_capture_force_mjpeg: Int = 0 // 0 -> auto, 1 -> force MJPEG video capture with v4l2 devices
var PREF__orbot_enabled_to_int = 0
var PREF__orbot_enabled_to_int_used_for_init = -1
@JvmStatic var PREF__toxnoise_enabled_to_int_used_for_init = -1
var PREF__local_discovery_enabled = 1
var PREF__ipv6_enabled = 1
var PREF__force_udp_only = 0
Expand Down Expand Up @@ -317,16 +318,35 @@ class MainActivity
System.out.println("XXXXX1.1:OS:" + OperatingSystem.getCurrent())
System.out.println("XXXXX1.2:OS:" + OperatingSystem.getName())
System.out.println("XXXXX1.3:OS:" + OperatingSystem.getArchitecture())
var libFile = File(resourcesDir, "libjni-c-toxcore.so")

var use_tox_noise = 0
try
{
if (global_prefs.getBoolean("tox.settings.tox_noise", false))
{
use_tox_noise = 1
}
} catch (_: Exception)
{
}
PREF__toxnoise_enabled_to_int_used_for_init = use_tox_noise

var noise_jni_name_addon = ""
if (use_tox_noise == 1)
{
noise_jni_name_addon = "_noise"
}

var libFile = File(resourcesDir, "libjni-c-toxcore${noise_jni_name_addon}.so")
if (OperatingSystem.getCurrent() == OperatingSystem.LINUX)
{
libFile = File(resourcesDir, "libjni-c-toxcore.so")
libFile = File(resourcesDir, "libjni-c-toxcore${noise_jni_name_addon}.so")
} else if (OperatingSystem.getCurrent() == OperatingSystem.WINDOWS)
{
libFile = File(resourcesDir, "jni-c-toxcore.dll")
libFile = File(resourcesDir, "jni-c-toxcore${noise_jni_name_addon}.dll")
} else if (OperatingSystem.getCurrent() == OperatingSystem.MACOS)
{
libFile = File(resourcesDir, "libjni-c-toxcore.jnilib")
libFile = File(resourcesDir, "libjni-c-toxcore${noise_jni_name_addon}.jnilib")
} else
{
System.out.println("XXXXX1.1:OS:Unknown operating system:EXIT")
Expand Down
23 changes: 23 additions & 0 deletions src/main/kotlin/org/briarproject/briar/desktop/SettingDetails.kt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,29 @@ fun SettingDetails()
}
// ---- tor proxy ----

// ---- enable noise ----
var tox_noise by remember { mutableStateOf(false) }
try
{
if (global_prefs.getBoolean("tox.settings.tox_noise", false))
{
tox_noise = true
}
} catch (_: Exception)
{
}
DetailItem(label = i18n("enable the experimental toxcore with NOISE handshake.\n!! this is experimental and also needs an app restart !!"),
description = (if (tox_noise) i18n("enabled") else i18n("disabled"))) {
Switch(
checked = tox_noise,
onCheckedChange = {
global_prefs.putBoolean("tox.settings.tox_noise", it)
tox_noise = it
},
)
}
// ---- enable noise ----

// database prefs ===================
if (orma != null)
{
Expand Down

0 comments on commit c0bd9cf

Please sign in to comment.