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 diff --git a/LIBCWTCH-GO-MACOS.version b/LIBCWTCH-GO-MACOS.version index d97a086c..05e99b26 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-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 43e720bb..05e99b26 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-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 06d41f35..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 { @@ -358,7 +359,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") ?: "" @@ -426,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/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 f4a198d5..60a6bb25 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..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), @@ -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 { 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()); } 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"