From d3a6ec85cfe779279b00757db01f53f133221f72 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Mon, 7 Jun 2021 19:13:23 -0700 Subject: [PATCH] Handle AVNVersion message and display version on Tor screen --- .../src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt | 1 - lib/cwtch/cwtch.dart | 3 --- lib/cwtch/cwtchNotifier.dart | 4 ++++ lib/cwtch/ffi.dart | 11 ----------- lib/cwtch/gomobile.dart | 5 ----- lib/main.dart | 5 ----- lib/torstatus.dart | 8 +++++++- lib/views/torstatusview.dart | 6 +++++- pubspec.yaml | 13 +++++-------- 9 files changed, 21 insertions(+), 35 deletions(-) diff --git a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt index 3391572..b0b2f60 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt @@ -112,7 +112,6 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : val pass = (a.get("pass") as? String) ?: "" Cwtch.loadProfiles(pass) } - "GetProfiles" -> Result.success(Data.Builder().putString("result", Cwtch.getProfiles()).build()) "NumMessages" -> { val profile = (a.get("profile") as? String) ?: "" val handle = (a.get("contact") as? String) ?: "" diff --git a/lib/cwtch/cwtch.dart b/lib/cwtch/cwtch.dart index 30ce4de..bd31cd1 100644 --- a/lib/cwtch/cwtch.dart +++ b/lib/cwtch/cwtch.dart @@ -31,9 +31,6 @@ abstract class Cwtch { // ignore: non_constant_identifier_names void DebugResetContact(String profileOnion, String contactHandle); - // ignore: non_constant_identifier_names - Future GetProfiles(); - // ignore: non_constant_identifier_names Future NumMessages(String profile, String handle); // ignore: non_constant_identifier_names diff --git a/lib/cwtch/cwtchNotifier.dart b/lib/cwtch/cwtchNotifier.dart index 4b576be..8e912f1 100644 --- a/lib/cwtch/cwtchNotifier.dart +++ b/lib/cwtch/cwtchNotifier.dart @@ -192,6 +192,10 @@ class CwtchNotifier { print("acn status: $data"); torStatus.handleUpdate(int.parse(data["Progress"]), data["Status"]); break; + case "ACNVersion": + print("acn version: $data"); + torStatus.updateVersion(data["Data"]); + break; case "UpdateServerInfo": profileCN.getProfile(data["ProfileOnion"])?.replaceServers(data["ServerList"]); break; diff --git a/lib/cwtch/ffi.dart b/lib/cwtch/ffi.dart index 595c208..0ee6416 100644 --- a/lib/cwtch/ffi.dart +++ b/lib/cwtch/ffi.dart @@ -194,17 +194,6 @@ class CwtchFfi implements Cwtch { LoadProfiles(ut8pass, ut8pass.length); } - // ignore: non_constant_identifier_names - Future GetProfiles() async { - var getProfilesC = library.lookup>("c_GetProfiles"); - // ignore: non_constant_identifier_names - final GetProfiles = getProfilesC.asFunction(); - - Pointer jsonProfilesBytes = GetProfiles(); - String jsonProfiles = jsonProfilesBytes.toDartString(); - return jsonProfiles; - } - // ignore: non_constant_identifier_names Future NumMessages(String profile, String handle) async { var numMessagesC = library.lookup>("c_NumMessages"); diff --git a/lib/cwtch/gomobile.dart b/lib/cwtch/gomobile.dart index 9396164..a44ec5d 100644 --- a/lib/cwtch/gomobile.dart +++ b/lib/cwtch/gomobile.dart @@ -86,11 +86,6 @@ class CwtchGomobile implements Cwtch { cwtchPlatform.invokeMethod("DeleteProfile", {"onion": onion, "pass": pass}); } - Future GetProfiles() { - print("gomobile.dart: GetProfiles()"); - return cwtchPlatform.invokeMethod("GetProfiles"); - } - // ignore: non_constant_identifier_names Future NumMessages(String profile, String handle) { return cwtchPlatform.invokeMethod("NumMessages", {"profile": profile, "contact": handle}); diff --git a/lib/main.dart b/lib/main.dart index 40f87c0..7f61f30 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -55,13 +55,11 @@ class FlwtchState extends State { @override initState() { - print("Init state"); super.initState(); profs = ProfileListState(); notificationClickChannel.setMethodCallHandler(_externalNotificationClicked); shutdownMethodChannel.setMethodCallHandler(shutdown); - print("initState set cwtch..."); if (Platform.isAndroid) { var cwtchNotifier = new CwtchNotifier(profs, globalSettings, globalErrorHandler, globalTorStatus, NullNotificationsManager(), globalAppState); cwtch = CwtchGomobile(cwtchNotifier); @@ -72,9 +70,7 @@ class FlwtchState extends State { var cwtchNotifier = new CwtchNotifier(profs, globalSettings, globalErrorHandler, globalTorStatus, NullNotificationsManager(), globalAppState); cwtch = CwtchFfi(cwtchNotifier); } - print("initState cwtch.Start()..."); cwtch.Start(); - print("initState done!"); } ChangeNotifierProvider getTorStatusProvider() => ChangeNotifierProvider.value(value: globalTorStatus); @@ -86,7 +82,6 @@ class FlwtchState extends State { @override Widget build(BuildContext context) { - //appStatus = AppModel(cwtch: cwtch); globalSettings.initPackageInfo(); return MultiProvider( providers: [ diff --git a/lib/torstatus.dart b/lib/torstatus.dart index 5d0c09a..a6910b5 100644 --- a/lib/torstatus.dart +++ b/lib/torstatus.dart @@ -4,8 +4,9 @@ class TorStatus extends ChangeNotifier { int progress; String status; bool connected; + String version; - TorStatus({this.connected = false, this.progress = 0, this.status = ""}); + TorStatus({this.connected = false, this.progress = 0, this.status = "", this.version = ""}); /// Called by the event bus. handleUpdate(int new_progress, String new_status) { @@ -20,4 +21,9 @@ class TorStatus extends ChangeNotifier { notifyListeners(); } + + updateVersion(String new_version) { + version = new_version; + notifyListeners(); + } } diff --git a/lib/views/torstatusview.dart b/lib/views/torstatusview.dart index 189e4a7..43bb5f0 100644 --- a/lib/views/torstatusview.dart +++ b/lib/views/torstatusview.dart @@ -51,7 +51,11 @@ class _TorStatusView extends State { Provider.of(context, listen: false).cwtch.ResetTor(); }, ), - ) + ), + ListTile( + title: Text(AppLocalizations.of(context)!.torVersion), + subtitle: Text(torStatus.version), + ), ])))); }); }); diff --git a/pubspec.yaml b/pubspec.yaml index 45e488b..979c014 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.0+11 +version: 1.0.0+12 environment: sdk: ">=2.12.0 <3.0.0" @@ -51,16 +51,13 @@ dependencies: path: plugins/window_size ref: e48abe7c3e9ebfe0b81622167c5201d4e783bb81 +# Uncomment to update lokalise translations (see README for list of deps to comment out bc incompatibilities) #dev_dependencies: # flutter_lokalise: any - -# alternatively: flutter pub run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/intl/app_localizations.dart lib/l10n/intl_*.arb --api-token X --project-id Y #flutter_lokalise: -# project_id: "" -# api_token: "" -# include_tags: -# - tag1 -# - tag2 +# project_id: "737094205fceda35c50aa2.60364948" +# api_token: "0407300fe4aa1edf1c1818e56234589e74c83c59" # Read only api Token from Dan + flutter_intl: enabled: true