From ff332dee9c3f99776e90a305e26c9727a041b638 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Sat, 10 Dec 2022 17:21:08 -0800 Subject: [PATCH 1/2] save profile.autostart on create --- LIBCWTCH-GO-MACOS.version | 2 +- LIBCWTCH-GO.version | 2 +- .../app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt | 3 ++- lib/cwtch/cwtch.dart | 2 +- lib/cwtch/ffi.dart | 8 ++++---- lib/cwtch/gomobile.dart | 4 ++-- lib/views/addeditprofileview.dart | 5 ++--- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/LIBCWTCH-GO-MACOS.version b/LIBCWTCH-GO-MACOS.version index d97a086c..599bf812 100644 --- a/LIBCWTCH-GO-MACOS.version +++ b/LIBCWTCH-GO-MACOS.version @@ -1 +1 @@ -2022-12-07-17-51-v1.10.1 \ No newline at end of file +2022-12-11-12-38-v1.10.1-2-g1e4221c \ No newline at end of file diff --git a/LIBCWTCH-GO.version b/LIBCWTCH-GO.version index 43e720bb..c5887495 100644 --- a/LIBCWTCH-GO.version +++ b/LIBCWTCH-GO.version @@ -1 +1 @@ -2022-12-07-22-53-v1.10.1 \ No newline at end of file +2022-12-11-17-40-v1.10.1-2-g1e4221c \ 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 06d41f35..692c701e 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt @@ -358,7 +358,8 @@ class MainActivity: FlutterActivity() { "CreateProfile" -> { val nick: String = call.argument("nick") ?: "" val pass: String = call.argument("pass") ?: "" - Cwtch.createProfile(nick, pass) + val autostart: Boolean = call.argument("autostart") ? true + Cwtch.createProfile(nick, pass, autostart) } "LoadProfiles" -> { val pass: String = call.argument("pass") ?: "" diff --git a/lib/cwtch/cwtch.dart b/lib/cwtch/cwtch.dart index 2e920780..69b11de9 100644 --- a/lib/cwtch/cwtch.dart +++ b/lib/cwtch/cwtch.dart @@ -11,7 +11,7 @@ abstract class Cwtch { Future ReconnectCwtchForeground(); // ignore: non_constant_identifier_names - void CreateProfile(String nick, String pass); + void CreateProfile(String nick, String pass, bool autostart); // ignore: non_constant_identifier_names void ActivatePeerEngine(String profile); diff --git a/lib/cwtch/ffi.dart b/lib/cwtch/ffi.dart index ae6867fb..d9f3856d 100644 --- a/lib/cwtch/ffi.dart +++ b/lib/cwtch/ffi.dart @@ -290,13 +290,13 @@ class CwtchFfi implements Cwtch { } // ignore: non_constant_identifier_names - void CreateProfile(String nick, String pass) { - var createProfileC = library.lookup>("c_CreateProfile"); + void CreateProfile(String nick, String pass, bool autostart) { + var createProfileC = library.lookup>("c_CreateProfile"); // ignore: non_constant_identifier_names - final CreateProfile = createProfileC.asFunction(); + final CreateProfile = createProfileC.asFunction(); final utf8nick = nick.toNativeUtf8(); final ut8pass = pass.toNativeUtf8(); - CreateProfile(utf8nick, utf8nick.length, ut8pass, ut8pass.length); + CreateProfile(utf8nick, utf8nick.length, ut8pass, ut8pass.length, autostart ? 1 : 0); malloc.free(utf8nick); malloc.free(ut8pass); } diff --git a/lib/cwtch/gomobile.dart b/lib/cwtch/gomobile.dart index eda73982..91e4d607 100644 --- a/lib/cwtch/gomobile.dart +++ b/lib/cwtch/gomobile.dart @@ -71,8 +71,8 @@ class CwtchGomobile implements Cwtch { } // ignore: non_constant_identifier_names - void CreateProfile(String nick, String pass) { - cwtchPlatform.invokeMethod("CreateProfile", {"nick": nick, "pass": pass}); + void CreateProfile(String nick, String pass, bool autostart) { + cwtchPlatform.invokeMethod("CreateProfile", {"nick": nick, "pass": pass, "autostart": autostart}); } // ignore: non_constant_identifier_names diff --git a/lib/views/addeditprofileview.dart b/lib/views/addeditprofileview.dart index 7498d712..4214ffa1 100644 --- a/lib/views/addeditprofileview.dart +++ b/lib/views/addeditprofileview.dart @@ -398,12 +398,11 @@ class _AddEditProfileViewState extends State { // match (and are provided if the user has requested an encrypted profile). if (_formKey.currentState!.validate()) { if (Provider.of(context, listen: false).onion.isEmpty) { - // TODO: save autostart in create flow if (usePassword == true) { - Provider.of(context, listen: false).cwtch.CreateProfile(ctrlrNick.value.text, ctrlrPass.value.text); + Provider.of(context, listen: false).cwtch.CreateProfile(ctrlrNick.value.text, ctrlrPass.value.text, Provider.of(context, listen: false).autostart); Navigator.of(context).pop(); } else { - Provider.of(context, listen: false).cwtch.CreateProfile(ctrlrNick.value.text, DefaultPassword); + Provider.of(context, listen: false).cwtch.CreateProfile(ctrlrNick.value.text, DefaultPassword, Provider.of(context, listen: false).autostart); Navigator.of(context).pop(); } } else { From c498a0c86a4c48fd6143e883cd9b65631211c620 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Sun, 11 Dec 2022 15:14:05 -0800 Subject: [PATCH 2/2] fix kotlin mainactivity createPeer --- android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 692c701e..ae76d09e 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt @@ -358,7 +358,7 @@ class MainActivity: FlutterActivity() { "CreateProfile" -> { val nick: String = call.argument("nick") ?: "" val pass: String = call.argument("pass") ?: "" - val autostart: Boolean = call.argument("autostart") ? true + val autostart: Boolean = call.argument("autostart") ?: true Cwtch.createProfile(nick, pass, autostart) } "LoadProfiles" -> {