diff --git a/LIBCWTCH-GO.version b/LIBCWTCH-GO.version index 6184cfee..8e14a4e8 100644 --- a/LIBCWTCH-GO.version +++ b/LIBCWTCH-GO.version @@ -1 +1 @@ -2023-08-31-11-56-v0.0.6-2-gf32ad74 \ No newline at end of file +2023-09-13-11-52-v0.0.6-4-g3e9c9c3 \ No newline at end of file diff --git a/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt b/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt index ac807b5d..63ce3e2c 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt @@ -406,6 +406,13 @@ class MainActivity: FlutterActivity() { val profile: String = call.argument("profile") ?: "" Cwtch.activatePeerEngine(profile) } + "ConfigureConnections" -> { + val profile: String = call.argument("profile") ?: "" + val listen: Boolean = call.argument("listen") ?: false + val peers: Boolean = call.argument("peers") ?: false + val servers: Boolean = call.argument("servers") ?: false + Cwtch.configureConnections(profile, listen, peers, servers) + } "DeactivatePeerEngine" -> { val profile: String = call.argument("profile") ?: "" Cwtch.deactivatePeerEngine(profile) diff --git a/lib/cwtch/cwtch.dart b/lib/cwtch/cwtch.dart index f930d260..c93b54d7 100644 --- a/lib/cwtch/cwtch.dart +++ b/lib/cwtch/cwtch.dart @@ -46,6 +46,9 @@ abstract class Cwtch { void UnblockContact(String profileOnion, int contactHandle); void AttemptReconnection(String profileOnion, String onion); + void AttemptReconnectionServer(String profileOnion, String onion); + void DisconnectFromPeer(String profileOnion, String onion); + void DisconnectFromServer(String profileOnion, String onion); // ignore: non_constant_identifier_names Future GetMessage(String profile, int handle, int index); @@ -151,4 +154,6 @@ abstract class Cwtch { // ignore: non_constant_identifier_names Future SearchConversations(String profile, String pattern); void DeleteServerInfo(String profile, String handle); + + void ConfigureConnections(String onion, bool listen, bool peers, bool servers); } diff --git a/lib/cwtch/cwtchNotifier.dart b/lib/cwtch/cwtchNotifier.dart index 6c48edb5..f5e79355 100644 --- a/lib/cwtch/cwtchNotifier.dart +++ b/lib/cwtch/cwtchNotifier.dart @@ -70,8 +70,18 @@ class CwtchNotifier { case "NewPeer": // EnvironmentConfig.debugLog("NewPeer $data"); // if tag != v1-defaultPassword then it is either encrypted OR it is an unencrypted account created during pre-beta... - profileCN.add(data["Identity"], data["name"], data["picture"], data["defaultPicture"], data["ContactsJson"], data["ServerList"], data["Online"] == "true", data["autostart"] == "true", - data["tag"] != "v1-defaultPassword"); + profileCN.add( + data["Identity"], + data["name"], + data["picture"], + data["defaultPicture"], + data["ContactsJson"], + data["ServerList"], + data["Online"] == "true", + data["autostart"] == "true", + data["tag"] != "v1-defaultPassword", + data["appearOffline"] == "true", + ); // Update Profile Attributes EnvironmentConfig.debugLog("Looking up Profile Attributes ${data["Identity"]} ${profileCN.getProfile(data["Identity"])}"); diff --git a/lib/cwtch/ffi.dart b/lib/cwtch/ffi.dart index 057eb904..47479ce9 100644 --- a/lib/cwtch/ffi.dart +++ b/lib/cwtch/ffi.dart @@ -45,6 +45,9 @@ typedef VoidFromStringIntStringStringStringFn = void Function(Pointer, int typedef void_from_string_string_int_int_function = Void Function(Pointer, Int32, Pointer, Int32, Int64, Int64); typedef VoidFromStringStringIntIntFn = void Function(Pointer, int, Pointer, int, int, int); +typedef void_from_string_bool_bool_bool = Void Function(Pointer, Int32, Bool, Bool, Bool); +typedef VoidFromStringBoolBoolBool = void Function(Pointer, int, bool, bool, bool); + typedef void_from_string_string_byte_function = Void Function(Pointer, Int32, Pointer, Int32, Int8); typedef VoidFromStringStringByteFn = void Function(Pointer, int, Pointer, int, int); @@ -1041,6 +1044,42 @@ class CwtchFfi implements Cwtch { malloc.free(utf8onion); } + @override + void AttemptReconnectionServer(String profile, String onion) { + // ignore: non_constant_identifier_names + var queueJoinServerC = library.lookup>("c_QueueJoinServer"); + final QueueJoinServerC = queueJoinServerC.asFunction(); + final utf8profile = profile.toNativeUtf8(); + final utf8onion = onion.toNativeUtf8(); + QueueJoinServerC(utf8profile, utf8profile.length, utf8onion, utf8onion.length); + malloc.free(utf8profile); + malloc.free(utf8onion); + } + + @override + void DisconnectFromPeer(String profile, String onion) { + // ignore: non_constant_identifier_names + var disconnectFromPeerC = library.lookup>("c_DisconnectFromPeer"); + final DisconnectFromPeerC = disconnectFromPeerC.asFunction(); + final utf8profile = profile.toNativeUtf8(); + final utf8onion = onion.toNativeUtf8(); + DisconnectFromPeerC(utf8profile, utf8profile.length, utf8onion, utf8onion.length); + malloc.free(utf8profile); + malloc.free(utf8onion); + } + + @override + void DisconnectFromServer(String profile, String onion) { + // ignore: non_constant_identifier_names + var disconnectFromServerC = library.lookup>("c_DisconnectFromServer"); + final DisconnectFromServerC = disconnectFromServerC.asFunction(); + final utf8profile = profile.toNativeUtf8(); + final utf8onion = onion.toNativeUtf8(); + DisconnectFromServerC(utf8profile, utf8profile.length, utf8onion, utf8onion.length); + malloc.free(utf8profile); + malloc.free(utf8onion); + } + @override Future SearchConversations(String profile, String pattern) async { var searchConversationsC = library.lookup>("c_SearchConversations"); @@ -1061,4 +1100,15 @@ class CwtchFfi implements Cwtch { Future> PlatformChannelInfo() { return Future.value(HashMap()); } + + @override + void ConfigureConnections(String profile, bool listen, bool peers, bool servers) { + var configureConnections = library.lookup>("c_ConfigureConnections"); + // ignore: non_constant_identifier_names + final ConfigureConnections = configureConnections.asFunction(); + final utf8profile = profile.toNativeUtf8(); + ConfigureConnections(utf8profile, utf8profile.length, listen, peers, servers); + malloc.free(utf8profile); + return; + } } diff --git a/lib/cwtch/gomobile.dart b/lib/cwtch/gomobile.dart index fdd22556..dd06c280 100644 --- a/lib/cwtch/gomobile.dart +++ b/lib/cwtch/gomobile.dart @@ -439,8 +439,28 @@ class CwtchGomobile implements Cwtch { cwtchPlatform.invokeMethod("PeerWithOnion", {"ProfileOnion": profile, "onion": onion}); } + @override + void AttemptReconnectionServer(String profile, String onion) { + cwtchPlatform.invokeMethod("QueueJoinServer", {"ProfileOnion": profile, "onion": onion}); + } + + @override + void DisconnectFromPeer(String profile, String onion) { + cwtchPlatform.invokeMethod("DisconnectFromPeer", {"ProfileOnion": profile, "onion": onion}); + } + + @override + void DisconnectFromServer(String profile, String onion) { + cwtchPlatform.invokeMethod("DisconnectFromServer", {"ProfileOnion": profile, "onion": onion}); + } + @override Future SearchConversations(String profile, String pattern) async { return await cwtchPlatform.invokeMethod("SearchConversations", {"ProfileOnion": profile, "pattern": pattern}); } + + @override + void ConfigureConnections(String profile, bool listen, bool peers, bool servers) { + cwtchPlatform.invokeMethod("ConfigureConnections", {"ProfileOnion": profile, "listen": listen, "peers": peers, "servers": servers}); + } } diff --git a/lib/l10n/intl_cy.arb b/lib/l10n/intl_cy.arb index d2ca4b8c..5052dcb5 100644 --- a/lib/l10n/intl_cy.arb +++ b/lib/l10n/intl_cy.arb @@ -1,6 +1,9 @@ { "@@locale": "cy", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Mewn gwirionedd dileu gweinydd", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Grwpiau rydw i'n eu cynnal ar y gweinydd hwn", diff --git a/lib/l10n/intl_da.arb b/lib/l10n/intl_da.arb index 1e26a2bf..0bf6babd 100644 --- a/lib/l10n/intl_da.arb +++ b/lib/l10n/intl_da.arb @@ -1,6 +1,9 @@ { "@@locale": "da", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Ja fjern server", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Grupper som jeg er vært for på denne server", diff --git a/lib/l10n/intl_de.arb b/lib/l10n/intl_de.arb index d2e5b3d0..2d1e98dc 100644 --- a/lib/l10n/intl_de.arb +++ b/lib/l10n/intl_de.arb @@ -1,6 +1,9 @@ { "@@locale": "de", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Server wirklich löschen", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Gruppen, in denen ich bin, werden auf diesem Server gehostet", diff --git a/lib/l10n/intl_el.arb b/lib/l10n/intl_el.arb index aa587944..e134909d 100644 --- a/lib/l10n/intl_el.arb +++ b/lib/l10n/intl_el.arb @@ -1,6 +1,9 @@ { "@@locale": "el", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Really Delete Server?", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Known Groups on this Cwtch Server", diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index e4e1229d..b55b54f7 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -1,6 +1,9 @@ { "@@locale": "en", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Really Delete Server?", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Known Groups on this Cwtch Server", diff --git a/lib/l10n/intl_es.arb b/lib/l10n/intl_es.arb index 8ef62797..a5987e20 100644 --- a/lib/l10n/intl_es.arb +++ b/lib/l10n/intl_es.arb @@ -1,6 +1,9 @@ { "@@locale": "es", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Realmente eliminar el servidor", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Grupos alojados en este servidor en los que estoy", diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index 9b747aa9..c990831d 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -1,6 +1,9 @@ { "@@locale": "fr", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Supprimer vraiment le serveur", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Les groupes dont je fais partie sont hébergés sur ce serveur", diff --git a/lib/l10n/intl_it.arb b/lib/l10n/intl_it.arb index 66141be6..88756a23 100644 --- a/lib/l10n/intl_it.arb +++ b/lib/l10n/intl_it.arb @@ -1,6 +1,9 @@ { "@@locale": "it", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Elimina davvero il server", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Gruppi di cui sono parte su questo server", diff --git a/lib/l10n/intl_ja.arb b/lib/l10n/intl_ja.arb index d1e9a54b..fa5713b7 100644 --- a/lib/l10n/intl_ja.arb +++ b/lib/l10n/intl_ja.arb @@ -1,6 +1,9 @@ { "@@locale": "ja", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Really Delete Server?", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Known Groups on this Cwtch Server", diff --git a/lib/l10n/intl_ko.arb b/lib/l10n/intl_ko.arb index a29d8d72..88fc28cc 100644 --- a/lib/l10n/intl_ko.arb +++ b/lib/l10n/intl_ko.arb @@ -1,6 +1,9 @@ { "@@locale": "ko", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Really Delete Server?", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Known Groups on this Cwtch Server", diff --git a/lib/l10n/intl_lb.arb b/lib/l10n/intl_lb.arb index 0ebd024f..e93bd626 100644 --- a/lib/l10n/intl_lb.arb +++ b/lib/l10n/intl_lb.arb @@ -1,6 +1,9 @@ { "@@locale": "lb", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Really Delete Server?", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Known Groups on this Cwtch Server", diff --git a/lib/l10n/intl_nl.arb b/lib/l10n/intl_nl.arb index ebb60fa5..1bc7cb2e 100644 --- a/lib/l10n/intl_nl.arb +++ b/lib/l10n/intl_nl.arb @@ -1,6 +1,9 @@ { "@@locale": "nl", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Server echt verwijderen", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Groepen waarin ik zit gehost op deze server", diff --git a/lib/l10n/intl_no.arb b/lib/l10n/intl_no.arb index 109060ee..e5bb5b1d 100644 --- a/lib/l10n/intl_no.arb +++ b/lib/l10n/intl_no.arb @@ -1,6 +1,9 @@ { "@@locale": "no", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Slette tjener", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Grupper jeg er vert for på denne tjeneren", diff --git a/lib/l10n/intl_pl.arb b/lib/l10n/intl_pl.arb index 64cd3993..99cacc4a 100644 --- a/lib/l10n/intl_pl.arb +++ b/lib/l10n/intl_pl.arb @@ -1,6 +1,9 @@ { "@@locale": "pl", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Usuń", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Grupy na tym serwerze, których jesteś członkiem", diff --git a/lib/l10n/intl_pt.arb b/lib/l10n/intl_pt.arb index 63a0b5c5..5294fdae 100644 --- a/lib/l10n/intl_pt.arb +++ b/lib/l10n/intl_pt.arb @@ -1,6 +1,9 @@ { "@@locale": "pt", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Really Delete Server?", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Known Groups on this Cwtch Server", diff --git a/lib/l10n/intl_pt_BR.arb b/lib/l10n/intl_pt_BR.arb index b43a339c..66e6c12a 100644 --- a/lib/l10n/intl_pt_BR.arb +++ b/lib/l10n/intl_pt_BR.arb @@ -1,6 +1,9 @@ { "@@locale": "pt_BR", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Realmente excluir servidor", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Grupos nos quais estou hospedado neste servidor", diff --git a/lib/l10n/intl_ro.arb b/lib/l10n/intl_ro.arb index efa6a3ec..9059473f 100644 --- a/lib/l10n/intl_ro.arb +++ b/lib/l10n/intl_ro.arb @@ -1,6 +1,9 @@ { "@@locale": "ro", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Sigur doriți sa ștergeți serverul", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Grupurile în care mă aflu care sunt găzduite pe acest server", diff --git a/lib/l10n/intl_ru.arb b/lib/l10n/intl_ru.arb index 7b0ab6cc..345e9a55 100644 --- a/lib/l10n/intl_ru.arb +++ b/lib/l10n/intl_ru.arb @@ -1,6 +1,9 @@ { "@@locale": "ru", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Вы точно хотите удалить сервер?", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Группы, в которых я нахожусь, размещены на этом сервере", diff --git a/lib/l10n/intl_sk.arb b/lib/l10n/intl_sk.arb index 30122657..74787043 100644 --- a/lib/l10n/intl_sk.arb +++ b/lib/l10n/intl_sk.arb @@ -1,6 +1,9 @@ { "@@locale": "sk", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Vážne vymazať server?", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Skupiny ktorých som členom a sú hostované na tomto servery", diff --git a/lib/l10n/intl_sv.arb b/lib/l10n/intl_sv.arb index c77ffe0b..444128b6 100644 --- a/lib/l10n/intl_sv.arb +++ b/lib/l10n/intl_sv.arb @@ -1,6 +1,9 @@ { "@@locale": "sv", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Bekräfta borttagning av servern", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Grupper jag är med i på den här servern", diff --git a/lib/l10n/intl_sw.arb b/lib/l10n/intl_sw.arb index de8e06f5..c1aa47f9 100644 --- a/lib/l10n/intl_sw.arb +++ b/lib/l10n/intl_sw.arb @@ -1,6 +1,9 @@ { "@@locale": "sw", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Futa kabisa seva", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Vikundi nilivyopangishwa kwenye seva hii", diff --git a/lib/l10n/intl_tr.arb b/lib/l10n/intl_tr.arb index ca4565d6..cbb6310f 100644 --- a/lib/l10n/intl_tr.arb +++ b/lib/l10n/intl_tr.arb @@ -1,6 +1,9 @@ { "@@locale": "tr", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Sunucuyu gerçekten sil", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Bu sunucuda içinde bulunduğum gruplar", diff --git a/lib/l10n/intl_uk.arb b/lib/l10n/intl_uk.arb index e9d7fe4c..d2bf1d2d 100644 --- a/lib/l10n/intl_uk.arb +++ b/lib/l10n/intl_uk.arb @@ -1,6 +1,9 @@ { "@@locale": "uk", - "@@last_modified": "2023-08-21T19:40:19+02:00", + "@@last_modified": "2023-09-13T18:51:59+02:00", + "contactDisconnect": "Disconnect from Contact (if you do not have Appear Offline set this contact may still be able to reestablish a connection to you)", + "profileAppearOfflineDescription": "By default, when Cwtch profile is enabled it automatically attempts to connect to know contacts, and allows inbound connections. This settings disables those actions and allows you to choose, manually, which contacts to connect to.", + "profileAppearOffline": "Appear Offline", "deleteServerConfirmBtn": "Really Delete Server?", "cannotDeleteServerIfActiveGroups": "There are active groups associated with this Cwtch Server. Please delete them prior to deleting this Cwtch Server entry.", "groupsOnThisServerLabel": "Known Groups on this Cwtch Server", diff --git a/lib/models/contact.dart b/lib/models/contact.dart index 00499dc1..d370ddb6 100644 --- a/lib/models/contact.dart +++ b/lib/models/contact.dart @@ -70,6 +70,9 @@ class ContactInfoState extends ChangeNotifier { var _hoveredIndex = -1; var _pendingScroll = -1; + DateTime _lastRetryTime = DateTime.now(); + DateTime loaded = DateTime.now(); + ContactInfoState( this.profileOnion, this.identifier, @@ -124,6 +127,12 @@ class ContactInfoState extends ChangeNotifier { MessageDraft get messageDraft => this._messageDraft; + DateTime get lastRetryTime => this._lastRetryTime; + set lastRetryTime(DateTime lastRetryTime) { + this._lastRetryTime = lastRetryTime; + notifyListeners(); + } + set antispamTickets(int antispamTickets) { this._antispamTickets = antispamTickets; notifyListeners(); diff --git a/lib/models/profile.dart b/lib/models/profile.dart index 49a3e4c4..63860da1 100644 --- a/lib/models/profile.dart +++ b/lib/models/profile.dart @@ -33,6 +33,7 @@ class ProfileInfoState extends ChangeNotifier { bool _autostart = true; bool _enabled = false; + bool _appearOffline = false; ProfileInfoState({ required this.onion, @@ -45,6 +46,7 @@ class ProfileInfoState extends ChangeNotifier { online = false, autostart = true, encrypted = true, + appearOffline = false, String, }) { this._nickname = nickname; @@ -57,6 +59,7 @@ class ProfileInfoState extends ChangeNotifier { if (autostart) { this._enabled = true; } + this._appearOffline = appearOffline; this._encrypted = encrypted; _contacts.connectServers(this._servers); @@ -175,12 +178,17 @@ class ProfileInfoState extends ChangeNotifier { } bool get autostart => this._autostart; - set autostart(bool newVal) { this._autostart = newVal; notifyListeners(); } + bool get appearOffline => this._appearOffline; + set appearOffline(bool newVal) { + this._appearOffline = newVal; + notifyListeners(); + } + String get defaultImagePath => this._defaultImagePath; set defaultImagePath(String newVal) { diff --git a/lib/models/profilelist.dart b/lib/models/profilelist.dart index 12587018..83d5363f 100644 --- a/lib/models/profilelist.dart +++ b/lib/models/profilelist.dart @@ -10,7 +10,7 @@ class ProfileListState extends ChangeNotifier { List _profiles = []; int get num => _profiles.length; - void add(String onion, String name, String picture, String defaultPicture, String contactsJson, String serverJson, bool online, bool autostart, bool encrypted) { + void add(String onion, String name, String picture, String defaultPicture, String contactsJson, String serverJson, bool online, bool autostart, bool encrypted, bool appearOffline) { var idx = _profiles.indexWhere((element) => element.onion == onion); if (idx == -1) { _profiles.add(ProfileInfoState( @@ -22,7 +22,8 @@ class ProfileListState extends ChangeNotifier { serversJson: serverJson, online: online, autostart: autostart, - encrypted: encrypted)); + encrypted: encrypted, + appearOffline: appearOffline)); } else { _profiles[idx].updateFrom(onion, name, picture, contactsJson, serverJson, online); } diff --git a/lib/views/addeditprofileview.dart b/lib/views/addeditprofileview.dart index a0513b22..8a0419cf 100644 --- a/lib/views/addeditprofileview.dart +++ b/lib/views/addeditprofileview.dart @@ -237,6 +237,9 @@ class _AddEditProfileViewState extends State { Provider.of(context).enabled = value; if (value) { Provider.of(context, listen: false).cwtch.ActivatePeerEngine(Provider.of(context).onion); + if (Provider.of(context).appearOffline == false) { + Provider.of(context, listen: false).cwtch.ConfigureConnections(Provider.of(context).onion, true, true, true); + } } else { Provider.of(context, listen: false).cwtch.DeactivatePeerEngine(Provider.of(context).onion); } @@ -265,6 +268,25 @@ class _AddEditProfileViewState extends State { secondary: Icon(CwtchIcons.favorite_24dp, color: Provider.of(context).current().mainTextColor), ), + // Auto start + SwitchListTile( + title: Text(AppLocalizations.of(context)!.profileAppearOffline, style: TextStyle(color: Provider.of(context).current().mainTextColor)), + subtitle: Text(AppLocalizations.of(context)!.profileAppearOfflineDescription), + value: Provider.of(context).appearOffline, + onChanged: (bool value) { + Provider.of(context).appearOffline = value; + + if (!Provider.of(context).onion.isEmpty) { + Provider.of(context, listen: false) + .cwtch + .SetProfileAttribute(Provider.of(context).onion, "profile.appear-offline", value ? "true" : "false"); + } + }, + activeTrackColor: Provider.of(context).theme.defaultButtonColor, + inactiveTrackColor: Provider.of(context).theme.defaultButtonDisabledColor, + secondary: Icon(CwtchIcons.favorite_24dp, color: Provider.of(context).current().mainTextColor), + ), + Visibility( visible: Provider.of(context).onion.isEmpty, child: SizedBox( diff --git a/lib/views/contactsview.dart b/lib/views/contactsview.dart index 0cbe7dd1..3799ce74 100644 --- a/lib/views/contactsview.dart +++ b/lib/views/contactsview.dart @@ -121,7 +121,6 @@ class _ContactsViewState extends State { child: Scaffold( endDrawerEnableOpenDragGesture: false, drawerEnableOpenDragGesture: false, - appBar: AppBar( leading: Stack(children: [ Align( @@ -154,7 +153,6 @@ class _ContactsViewState extends State { }), ) ]), - title: Row(children: [ PopupMenuButton( icon: ProfileImage( @@ -351,7 +349,10 @@ class _ContactsViewState extends State { physics: BouncingScrollPhysics(), semanticChildCount: tilesSearchResult.length, itemBuilder: (context, index) { - return tilesSearchResult.elementAt(index); + if (tilesSearchResult.length > index) { + return tilesSearchResult.elementAt(index); + } + return Container(); }, separatorBuilder: (BuildContext context, int index) { return Divider(height: 1); diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index f0c8a989..89a355a1 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -106,6 +106,26 @@ class _MessageViewState extends State { splashRadius: Material.defaultSplashRadius / 2, icon: Icon(CwtchIcons.manage_files), tooltip: AppLocalizations.of(context)!.manageSharedFiles, onPressed: _pushFileSharingSettings)); } + if (Provider.of(context, listen: false).isOnline()) { + appBarButtons.add(IconButton( + splashRadius: Material.defaultSplashRadius / 2, + icon: Icon(Icons.speaker_notes_off), + tooltip: AppLocalizations.of(context)!.contactDisconnect, + onPressed: () { + if (Provider.of(context, listen: false).isGroup) { + Provider.of(context, listen: false) + .cwtch + .DisconnectFromServer(Provider.of(context, listen: false).onion, Provider.of(context, listen: false).server!); + } else { + Provider.of(context, listen: false) + .cwtch + .DisconnectFromPeer(Provider.of(context, listen: false).onion, Provider.of(context, listen: false).onion); + } + // reset the disconnect button to allow for immediate connection... + Provider.of(context, listen: false).lastRetryTime = DateTime.now().subtract(Duration(minutes: 2)); + })); + } + var profile = Provider.of(context, listen: false).profileOnion; var conversation = Provider.of(context, listen: false).identifier; diff --git a/lib/widgets/messagelist.dart b/lib/widgets/messagelist.dart index cc79af9b..0b3bd4d7 100644 --- a/lib/widgets/messagelist.dart +++ b/lib/widgets/messagelist.dart @@ -47,21 +47,39 @@ class _MessageListState extends State { // With the message cache in place this is no longer necessary bool loadMessages = true; - var reconnectButton = Visibility( - visible: isP2P, - child: Padding( - padding: EdgeInsets.all(2), - child: Tooltip( + // if it's been more than 2 minutes since we last clicked the button let users click the button again + // OR if users have never clicked the button AND they appear offline, then they can click the button + // NOTE: all these listeners are false...this is not ideal, but if they were true we would end up rebuilding the message view every tick (which would kill performance) + // any significant changes in state e.g. peer offline or button clicks will trigger a rebuild anyway + bool canReconnect = DateTime.now().difference(Provider.of(context, listen: false).lastRetryTime).abs() > Duration(seconds: 60) || + Provider.of(context, listen: false).appearOffline && + (Provider.of(context, listen: false).lastRetryTime == Provider.of(context, listen: false).loaded); + + var reconnectButton = Padding( + padding: EdgeInsets.all(2), + child: canReconnect + ? Tooltip( message: AppLocalizations.of(context)!.retryConnectionTooltip, child: ElevatedButton( style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.all(20))), child: Text(AppLocalizations.of(context)!.retryConnection), onPressed: () { - Provider.of(context, listen: false) - .cwtch - .AttemptReconnection(Provider.of(context, listen: false).onion, Provider.of(context, listen: false).onion); + if (Provider.of(context, listen: false).isGroup) { + Provider.of(context, listen: false) + .cwtch + .AttemptReconnectionServer(Provider.of(context, listen: false).onion, Provider.of(context, listen: false).server!); + } else { + Provider.of(context, listen: false) + .cwtch + .AttemptReconnection(Provider.of(context, listen: false).onion, Provider.of(context, listen: false).onion); + } + Provider.of(context, listen: false).lastRetryTime = DateTime.now(); + setState(() { + // force update of this view...otherwise the button won't be removed fast enough... + }); }, - )))); + )) + : CircularProgressIndicator(color: Provider.of(context).theme.defaultButtonTextColor)); return RepaintBoundary( child: Container(