Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to compose.version 1.6.10-dev1457, update to kotlin.version 2.0.0-Beta4, push notifications, relays (ToxProxy) #170

Merged
merged 38 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7e9129f
Update README.md
zoff99 Feb 28, 2024
4cd3519
.gitignore
zoff99 Mar 1, 2024
881f481
update to compose.version 1.6.10-dev1457
zoff99 Mar 1, 2024
55eab84
update to kotlin.version 2.0.0-Beta4
zoff99 Mar 1, 2024
84f93cd
add rust version of linux notifications JNI lib
zoff99 Feb 25, 2024
dfefeb2
refactor asan run script
zoff99 Feb 25, 2024
c32eafc
tweak asan script, document java mem tuning options
zoff99 Mar 1, 2024
060fe21
create setting to enable triggering push notifications
zoff99 Feb 24, 2024
70ac259
active actual push triggers
zoff99 Feb 24, 2024
753a4ef
actually show and update message delivery status
zoff99 Feb 24, 2024
167b721
fix push triggers and checkmarks
zoff99 Feb 24, 2024
c057340
remove unused var
zoff99 Feb 24, 2024
3bd001e
add setting for toxproxies and refactor settings UI
zoff99 Feb 24, 2024
57fc690
clear tox started flag before killing tox
zoff99 Feb 24, 2024
ddf562a
new state for orma and tox running
zoff99 Feb 24, 2024
c6a3b36
add comment
zoff99 Feb 24, 2024
452d5f2
WIP: add and show friends relays
zoff99 Feb 24, 2024
a38fc49
only add friends proxies when setting is turned on
zoff99 Feb 24, 2024
b088d5d
only use DB when it is actually available
zoff99 Feb 25, 2024
f8c61d7
add function to open URLs in the browser
zoff99 Feb 25, 2024
d3b2420
highlight URLs and make them clickable in messages and groupmessages
zoff99 Feb 25, 2024
20792bd
better url finding regex
zoff99 Feb 27, 2024
42cb99f
show more info in group tooltip
zoff99 Feb 26, 2024
c5c9353
add missing ORM functions for RelayListDB
zoff99 Feb 25, 2024
962136b
delete relays properly
zoff99 Feb 25, 2024
b701b19
WIP: add and remove own relay. and show it with different bg color in…
zoff99 Feb 25, 2024
d88eb76
add more Relay helper functions
zoff99 Feb 25, 2024
2f98374
add setting to add or update own relay
zoff99 Feb 25, 2024
d830056
catch compose runtime exceptions, so that app does not freeze
zoff99 Feb 26, 2024
79ff88e
invite friends and groups to own toxproxy, and send own toxproxy to a…
zoff99 Feb 26, 2024
9685b8d
WIP: receiving offline messages for one-on-one and NGC groups
zoff99 Feb 26, 2024
7d97824
catch null strings
zoff99 Feb 27, 2024
f5fe659
fix import
zoff99 Feb 27, 2024
e99f32b
fix alertdialog exception
zoff99 Feb 27, 2024
05813e6
receive and show private messages in NGC groups
zoff99 Feb 27, 2024
5ce4916
make ngc group id selectable in settings
zoff99 Feb 28, 2024
fa15b5e
show relay on contact list tooltip
zoff99 Mar 1, 2024
cebdcc3
try to repush again less often. check count before reading db values
zoff99 Mar 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ main.db-journal
savedata.tox__backup
trifa_material-*.AppImage
main.db__backup
.kotlin/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ the latest Development Snapshot can be downloaded from [here](https://github.com
<a href="https://github.com/Zoxcore/trifa_material/releases/download/nightly/trifa-material_nightly-x86_64.appimage
"><img src="https://raw.githubusercontent.com/Zoxcore/trifa_material/master/images/on_github_nightly.png" width="200"></a>

## Installation & starting the App [Linux, RasperryPi, Windows and MacOS]
## Installation & starting the App [Linux, Windows and MacOS]

<a href="https://github.com/Zoxcore/trifa_material/releases/latest/"><img src="https://raw.githubusercontent.com/Zoxcore/trifa_material/master/images/Tux.svg" height="45"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/Zoxcore/trifa_material/releases/latest/"><img src="https://raw.githubusercontent.com/Zoxcore/trifa_material/master/images/Windows_logo_-_2012.svg" height="45"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/Zoxcore/trifa_material/releases/latest/"><img src="https://raw.githubusercontent.com/Zoxcore/trifa_material/master/images/Apple_logo_black.svg" height="45"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/Zoxcore/trifa_material/releases/latest/"><img src="https://raw.githubusercontent.com/Zoxcore/trifa_material/master/images/Raspberry_Pi_Logo.svg" height="45"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/Zoxcore/trifa_material/releases/latest/"><img src="https://raw.githubusercontent.com/Zoxcore/trifa_material/master/images/Apple_M1.svg.png" height="45"></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/Zoxcore/trifa_material/releases/latest/"><img src="https://raw.githubusercontent.com/Zoxcore/trifa_material/master/images/AsahiLinux_logo_svg.svg" height="45"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/Zoxcore/trifa_material/releases/latest/"><img src="https://raw.githubusercontent.com/Zoxcore/trifa_material/master/images/NixOS_logo.svg" height="40"></a>
Expand Down
30 changes: 25 additions & 5 deletions asan_run.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
#! /bin/bash

#####################################
#
# config:
#
java_17_or_newer_dir=/usr/lib/jvm/java-17-openjdk-amd64/
asan_runtime_lib=/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0
#
#
#
#####################################



p=$(pwd)
h=$(echo $HOME)

if [ "$1""x" == "buildx" ]; then
cp -av resources/common/libffmpeg_av_jni.so__ASAN resources/common/libffmpeg_av_jni.so
cp -av resources/common/libjni_notifications.so__ASAN resources/common/libjni_notifications.so
cp -av resources/common/libjni-c-toxcore.so__ASAN resources/common/libjni-c-toxcore.so
./gradlew -Dorg.gradle.java.home=/usr/lib/jvm/java-17-openjdk-amd64/ packageDistributionForCurrentOS
./gradlew -Dorg.gradle.java.home=/usr/lib/jvm/java-17-openjdk-amd64/ packageUberJarForCurrentOS
./gradlew -Dorg.gradle.java.home="$java_17_or_newer_dir" packageDistributionForCurrentOS
./gradlew -Dorg.gradle.java.home="$java_17_or_newer_dir" packageUberJarForCurrentOS
fi

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0 \
/usr/lib/jvm/java-17-openjdk-amd64/bin/java -Dapple.awt.application.name=TRIfA \
-Dcom.apple.mrj.application.apple.menu.about.name=TRIfA -Dcompose.application.configure.swing.globals=true -Dcompose.application.resources.dir="$p"/build/compose/tmp/prepareAppResources -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant \
# options to log GC stats, and limit memusage a lot
# -XX:+UseG1GC -XX:MinHeapFreeRatio=1 -XX:MaxHeapFreeRatio=1

LD_PRELOAD="$asan_runtime_lib" \
"$java_17_or_newer_dir"/bin/java -Dapple.awt.application.name=TRIfA \
-Dcom.apple.mrj.application.apple.menu.about.name=TRIfA \
-Dcompose.application.configure.swing.globals=true \
-Dcompose.application.resources.dir="$p"/build/compose/tmp/prepareAppResources \
-Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant \
-cp "$p"/build/compose/jars/trifa_material-linux-x64-1.0.22.jar \
MainKt

6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ org.jetbrains.compose.experimental.uikit.enabled=true
android.defaults.buildfeatures.buildconfig=true
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
compose.version=1.6.0-dev1440
kotlin.version=1.9.22
multiplatform.version=1.9.22
compose.version=1.6.10-dev1457
kotlin.version=2.0.0-Beta4
multiplatform.version=2.0.0-Beta4
Binary file added resources/common/libjni_notifications_rs.so
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/java/com/zoffcc/applications/sorm/GroupDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class GroupDB

// group id is always saved as lower case hex string!! -----------------
@PrimaryKey
String group_identifier = "";
public String group_identifier = "";
// group id is always saved as lower case hex string!! -----------------

@Column(indexed = true, helpers = Column.Helpers.ALL)
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/zoffcc/applications/sorm/OrmaDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1013,5 +1013,11 @@ public BootstrapNodeEntryDB deleteFromBootstrapNodeEntryDB() {
ret.sql_start = "DELETE FROM BootstrapNodeEntryDB";
return ret;
}

public RelayListDB deleteFromRelayListDB() {
RelayListDB ret = new RelayListDB();
ret.sql_start = "DELETE FROM RelayListDB";
return ret;
}
}

21 changes: 15 additions & 6 deletions src/main/java/com/zoffcc/applications/sorm/RelayListDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,28 @@ public class RelayListDB
{
private static final String TAG = "DB.RelayListDB";

// pubkey is always saved as UPPER CASE hex string!! -----------------
@PrimaryKey
String tox_public_key_string = "";
public String tox_public_key_string = "";
// pubkey is always saved as UPPER CASE hex string!! -----------------

@Column(indexed = true, defaultExpr = "0", helpers = Column.Helpers.ALL)
int TOX_CONNECTION; // 0 --> NONE (offline), 1 --> TCP (online), 2 --> UDP (online)
public int TOX_CONNECTION; // 0 --> NONE (offline), 1 --> TCP (online), 2 --> UDP (online)

@Column(indexed = true, defaultExpr = "0", helpers = Column.Helpers.ALL)
int TOX_CONNECTION_on_off; // 0 --> offline, 1 --> online
public int TOX_CONNECTION_on_off; // 0 --> offline, 1 --> online

@Column(indexed = true, defaultExpr = "false", helpers = Column.Helpers.ALL)
boolean own_relay = false; // false --> friends relay, true --> my relay
public boolean own_relay = false; // false --> friends relay, true --> my relay

@Column(indexed = true, defaultExpr = "-1", helpers = Column.Helpers.ALL)
long last_online_timestamp = -1L;
public long last_online_timestamp = -1L;

// pubkey is always saved as UPPER CASE hex string!! -----------------
@Column(indexed = true, defaultExpr = "", helpers = Column.Helpers.ALL)
@Nullable
String tox_public_key_string_of_owner = "";
public String tox_public_key_string_of_owner = "";
// pubkey is always saved as UPPER CASE hex string!! -----------------

static RelayListDB deep_copy(RelayListDB in)
{
Expand Down Expand Up @@ -278,4 +282,9 @@ public RelayListDB tox_public_key_stringEq(String tox_public_key_string)
this.sql_where = this.sql_where + " and tox_public_key_string='" + s(tox_public_key_string) + "' ";
return this;
}

public RelayListDB tox_public_key_string_of_ownerEq(String tox_public_key_string_of_owner) {
this.sql_where = this.sql_where + " and tox_public_key_string_of_owner='" + s(tox_public_key_string_of_owner) + "' ";
return this;
}
}
11 changes: 8 additions & 3 deletions src/main/java/com/zoffcc/applications/trifa/HelperFriend.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static String get_friend_name_from_pubkey(String friend_pubkey)
catch (Exception e)
{
friend_alias_name = "";
e.printStackTrace();
// e.printStackTrace();
}

if ((friend_alias_name == null) || (friend_alias_name.equals("")))
Expand All @@ -143,7 +143,7 @@ static String get_friend_name_from_pubkey(String friend_pubkey)
catch (Exception e)
{
friend_name = "";
e.printStackTrace();
// e.printStackTrace();
}

if ((friend_name != null) && (!friend_name.equals("")))
Expand Down Expand Up @@ -270,6 +270,11 @@ public static void del_g_opts(String key) {
}

static void friend_call_push_url(final String friend_pubkey, final long message_timestamp_circa) {
if (MainActivity.getDB_PREF__send_push_notifications() == false)
{
return;
}

try {
final String pushurl_for_friend = get_pushurl_for_friend(friend_pubkey);

Expand Down Expand Up @@ -411,7 +416,7 @@ static void add_friend_to_system(final String friend_public_key, final boolean a
if (as_friends_relay)
{
// add relay for friend to DB
// TODO // HelperRelay.add_or_update_friend_relay(friend_public_key, owner_public_key);
HelperRelay.add_or_update_friend_relay(friend_public_key, owner_public_key);
}

if (MainActivity.getDB_PREF__U_keep_nospam() == false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,7 @@ static void group_message_add_from_sync(final String group_identifier, final Str
m.text = message;
m.message_id_tox = message_id;
m.was_synced = true;
m.private_message = 0;

if (m.tox_group_peername == null)
{
Expand Down
71 changes: 59 additions & 12 deletions src/main/java/com/zoffcc/applications/trifa/HelperMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import java.util.List;

import static com.zoffcc.applications.trifa.HelperFiletransfer.get_incoming_filetransfer_local_filename;
import static com.zoffcc.applications.trifa.HelperFriend.friend_call_push_url;
import static com.zoffcc.applications.trifa.HelperFriend.main_get_friend;
import static com.zoffcc.applications.trifa.HelperFriend.*;
import static com.zoffcc.applications.trifa.HelperFriend.send_friend_msg_receipt_v2_wrapper;
import static com.zoffcc.applications.trifa.HelperGroup.bytebuffer_to_hexstring;
import static com.zoffcc.applications.trifa.HelperGroup.bytesToHexJava;
import static com.zoffcc.applications.trifa.MainActivity.*;
Expand Down Expand Up @@ -80,7 +80,8 @@ static void process_msgv3_high_level_ack(final long friend_number, String msgV3h
}
m.read = true;
update_message_in_db_read_rcvd_timestamp_rawmsgbytes(m);
// TODO: update message in UI
// update message in UI
modify_text_message(m);
}
catch (Exception e)
{
Expand Down Expand Up @@ -642,15 +643,12 @@ static void update_message_in_db_sent_push_set(final String friend_pubkey, final

// Log.i(TAG, "update_message_in_db_sent_push_set:ts=" + sent_timestamp + " m=" + m);

TrifaToxService.Companion.getOrma().updateMessage().
tox_friendpubkeyEq(friend_pubkey).
idEq(m.id).
sent_push(1).
execute();

m.sent_push = 1;

//*** TODO: ****// update_single_message(m, true);
if (m.sent_push != 1) {
TrifaToxService.Companion.getOrma().updateMessage().tox_friendpubkeyEq(friend_pubkey).idEq(m.id).sent_push(1).execute();
m.sent_push = 1;
// update message in UI
modify_text_message(m);
}
}
catch (Exception e)
{
Expand Down Expand Up @@ -707,4 +705,53 @@ synchronized static void update_message_in_db_no_read_recvedts(final Message m)
e.printStackTrace();
}
}

static void sync_messagev2_answer(ByteBuffer raw_message_buf_wrapped, long friend_number, ByteBuffer msg_id_buffer, String real_sender_as_hex_string, String msg_id_as_hex_string_wrapped)
{
// we got an "msg receipt" from the relay
// Log.i(TAG, "friend_sync_message_v2_cb:TOX_FILE_KIND_MESSAGEV2_ANSWER");
final String message_id_hash_as_hex_string = msg_id_as_hex_string_wrapped;

try
{
// Log.i(TAG, "friend_sync_message_v2_cb:message_id_hash_as_hex_string=" + message_id_hash_as_hex_string +
// " friendpubkey=" + real_sender_as_hex_string);

final List<Message> mlist = TrifaToxService.Companion.getOrma().selectFromMessage().
msg_id_hashEq(message_id_hash_as_hex_string).
tox_friendpubkeyEq(real_sender_as_hex_string).
directionEq(1).
readEq(false).
toList();

if (mlist.size() > 0)
{
final Message m = mlist.get(0);
try
{
long msg_wrapped_sec = MainActivity.tox_messagev2_get_ts_sec(raw_message_buf_wrapped);
long msg_wrapped_ms = MainActivity.tox_messagev2_get_ts_ms(raw_message_buf_wrapped);
m.raw_msgv2_bytes = "";
m.rcvd_timestamp = (msg_wrapped_sec * 1000) + msg_wrapped_ms;
m.read = true;
update_message_in_db_read_rcvd_timestamp_rawmsgbytes(m);
m.resend_count = 2;
update_message_in_db_resend_count(m);
// update message in UI
modify_text_message(m);
}
catch (Exception e)
{
e.printStackTrace();
}
send_friend_msg_receipt_v2_wrapper(friend_number, 4, msg_id_buffer,
(System.currentTimeMillis() / 1000));
}
}
catch (Exception e)
{
}

send_friend_msg_receipt_v2_wrapper(friend_number, 4, msg_id_buffer, (System.currentTimeMillis() / 1000));
}
}
15 changes: 15 additions & 0 deletions src/main/java/com/zoffcc/applications/trifa/HelperOSFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.awt.*;
import java.io.File;
import java.net.URI;

public class HelperOSFile {

Expand Down Expand Up @@ -30,6 +31,20 @@ public static void show_containing_dir_in_explorer(final String filename_with_pa
}
}

public static void open_webpage(String url_string) {
if (url_string == null) {
return;
}
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(new URI(url_string));
} catch (Exception e) {
e.printStackTrace();
}
}
}

public static void show_file_in_explorer_or_open(String filename_with_path)
{
if (OperatingSystem.getCurrent() == OperatingSystem.WINDOWS)
Expand Down
Loading
Loading