From ff332dee9c3f99776e90a305e26c9727a041b638 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Sat, 10 Dec 2022 17:21:08 -0800 Subject: [PATCH 1/6] 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/6] 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" -> { From 28ce08637b06e2fbf6c607c464492ff66d417fe5 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Mon, 12 Dec 2022 15:10:07 -0800 Subject: [PATCH 3/6] Fix Android File Sharing --- LIBCWTCH-GO-MACOS.version | 2 +- LIBCWTCH-GO.version | 2 +- .../src/main/kotlin/im/cwtch/flwtch/MainActivity.kt | 10 ++++++---- lib/widgets/filebubble.dart | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/LIBCWTCH-GO-MACOS.version b/LIBCWTCH-GO-MACOS.version index 599bf812..05e99b26 100644 --- a/LIBCWTCH-GO-MACOS.version +++ b/LIBCWTCH-GO-MACOS.version @@ -1 +1 @@ -2022-12-11-12-38-v1.10.1-2-g1e4221c \ No newline at end of file +2022-12-12-22-59-v1.10.1-3-g3d0a3a5 \ No newline at end of file diff --git a/LIBCWTCH-GO.version b/LIBCWTCH-GO.version index c5887495..05e99b26 100644 --- a/LIBCWTCH-GO.version +++ b/LIBCWTCH-GO.version @@ -1 +1 @@ -2022-12-11-17-40-v1.10.1-2-g1e4221c \ No newline at end of file +2022-12-12-22-59-v1.10.1-3-g3d0a3a5 \ 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 ae76d09e..39303751 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt @@ -68,7 +68,7 @@ class MainActivity: FlutterActivity() { private val PROFILE_EXPORT_REQUEST_CODE = 236 private val REQUEST_DOZE_WHITELISTING_CODE:Int = 9 private var dlToProfile = "" - private var dlToHandle = "" + private var dlToHandle = 0 private var dlToFileKey = "" private var exportFromPath = "" @@ -128,9 +128,10 @@ class MainActivity: FlutterActivity() { if (requestCode == FILEPICKER_REQUEST_CODE) { val filePath = intent!!.getData().toString(); val manifestPath = StringBuilder().append(this.applicationContext.cacheDir).append("/").append(this.dlToFileKey).toString(); + Log.d("MainActivity:FILEPICKER_REQUEST_CODE", "DownloadableFileCreated"); handleCwtch(MethodCall("DownloadFile", mapOf( "ProfileOnion" to this.dlToProfile, - "handle" to this.dlToHandle, + "conversation" to this.dlToHandle.toInt(), "filepath" to filePath, "manifestpath" to manifestPath, "filekey" to this.dlToFileKey @@ -228,7 +229,7 @@ class MainActivity: FlutterActivity() { var method = call.method // todo change usage patern to match that in FlwtchWorker // Unsafe for anything using int args, causes access time attempt to cast to string which will fail - val argmap: Map = call.arguments as Map + val argmap: Map = call.arguments as Map // the frontend calls Start every time it fires up, but we don't want to *actually* call Cwtch.Start() // in case the ForegroundService is still running. in both cases, however, we *do* want to re-register @@ -255,7 +256,7 @@ class MainActivity: FlutterActivity() { } "CreateDownloadableFile" -> { this.dlToProfile = argmap["ProfileOnion"] ?: "" - this.dlToHandle = argmap["handle"] ?: "" + this.dlToHandle = call.argument("conversation")!! val suggestedName = argmap["filename"] ?: "filename.ext" this.dlToFileKey = argmap["filekey"] ?: "" val intent = Intent(Intent.ACTION_CREATE_DOCUMENT).apply { @@ -427,6 +428,7 @@ class MainActivity: FlutterActivity() { } "DownloadFile" -> { + Log.d("MainActivity.kt", "Cwtch Download File Called...") val profile: String = call.argument("ProfileOnion") ?: "" val conversation: Int = call.argument("conversation") ?: 0 val filepath: String = call.argument("filepath") ?: "" diff --git a/lib/widgets/filebubble.dart b/lib/widgets/filebubble.dart index 323ada54..78781c8f 100644 --- a/lib/widgets/filebubble.dart +++ b/lib/widgets/filebubble.dart @@ -251,7 +251,7 @@ class FileBubbleState extends State { if (Platform.isAndroid) { Provider.of(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil()); Provider.of(context, listen: false).cwtch.SetMessageAttribute(profileOnion, conversation, 0, idx, "file-downloaded", "true"); - ContactInfoState? contact = Provider.of(context).contactList.findContact(Provider.of(context).senderHandle); + ContactInfoState? contact = Provider.of(context, listen: false).contactList.findContact(Provider.of(context, listen: false).senderHandle); if (contact != null) { Provider.of(context, listen: false).cwtch.CreateDownloadableFile(profileOnion, contact.identifier, widget.nameSuggestion, widget.fileKey()); } From 4a11968567fa2fbdf79bbb20c4749ed1eede30ea Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Tue, 13 Dec 2022 09:47:37 -0800 Subject: [PATCH 4/6] update flutter-desktop linux container to use newer build with older glibc for compat --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 205c0142..b2995456 100644 --- a/.drone.yml +++ b/.drone.yml @@ -47,7 +47,7 @@ steps: # #Todo: fix all the lint errors and add `-set_exit_status` above to enforce linting - name: build-linux - image: openpriv/flutter-desktop:linux-fstable-3.3.8 + image: openpriv/flutter-desktop:linux-fstable-3.3.9 volumes: - name: deps path: /root/.pub-cache From 448900b48e007c72c5d293e17310bbed917186a4 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Wed, 14 Dec 2022 16:14:58 -0800 Subject: [PATCH 5/6] no isable profiles till it works --- lib/views/addeditprofileview.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/views/addeditprofileview.dart b/lib/views/addeditprofileview.dart index 4214ffa1..7a48cac6 100644 --- a/lib/views/addeditprofileview.dart +++ b/lib/views/addeditprofileview.dart @@ -172,7 +172,7 @@ class _AddEditProfileViewState extends State { // Enabled Visibility( - visible: Provider.of(context).onion.isNotEmpty, + visible: Provider.of(context).onion.isNotEmpty && !Provider.of(context).enabled, child: SwitchListTile( title: Text(AppLocalizations.of(context)!.profileEnabled, style: TextStyle(color: Provider.of(context).current().mainTextColor)), subtitle: Text(AppLocalizations.of(context)!.profileEnabledDescription), From f7da7b4bb743dfdf50e87ee427f1363333aa9dd7 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Wed, 14 Dec 2022 16:15:30 -0800 Subject: [PATCH 6/6] bump pubspec for 1.10 release --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index f026b451..cc2a8d28 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.9.0+35 +version: 1.10.0+36 environment: sdk: ">=2.15.0 <3.0.0"