Merge pull request 'save profile.autostart on create' (#598) from saveAutostart into trunk
continuous-integration/drone/push Build is pending Details

Reviewed-on: #598
Reviewed-by: Sarah Jamie Lewis <sarah@openprivacy.ca>
This commit is contained in:
Sarah Jamie Lewis 2022-12-12 02:54:32 +00:00
commit c8bdc56507
7 changed files with 13 additions and 13 deletions

View File

@ -1 +1 @@
2022-12-07-17-51-v1.10.1 2022-12-11-12-38-v1.10.1-2-g1e4221c

View File

@ -1 +1 @@
2022-12-07-22-53-v1.10.1 2022-12-11-17-40-v1.10.1-2-g1e4221c

View File

@ -358,7 +358,8 @@ class MainActivity: FlutterActivity() {
"CreateProfile" -> { "CreateProfile" -> {
val nick: String = call.argument("nick") ?: "" val nick: String = call.argument("nick") ?: ""
val pass: String = call.argument("pass") ?: "" val pass: String = call.argument("pass") ?: ""
Cwtch.createProfile(nick, pass) val autostart: Boolean = call.argument("autostart") ?: true
Cwtch.createProfile(nick, pass, autostart)
} }
"LoadProfiles" -> { "LoadProfiles" -> {
val pass: String = call.argument("pass") ?: "" val pass: String = call.argument("pass") ?: ""

View File

@ -11,7 +11,7 @@ abstract class Cwtch {
Future<void> ReconnectCwtchForeground(); Future<void> ReconnectCwtchForeground();
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
void CreateProfile(String nick, String pass); void CreateProfile(String nick, String pass, bool autostart);
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
void ActivatePeerEngine(String profile); void ActivatePeerEngine(String profile);

View File

@ -290,13 +290,13 @@ class CwtchFfi implements Cwtch {
} }
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
void CreateProfile(String nick, String pass) { void CreateProfile(String nick, String pass, bool autostart) {
var createProfileC = library.lookup<NativeFunction<void_from_string_string_function>>("c_CreateProfile"); var createProfileC = library.lookup<NativeFunction<void_from_string_string_byte_function>>("c_CreateProfile");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final CreateProfile = createProfileC.asFunction<VoidFromStringStringFn>(); final CreateProfile = createProfileC.asFunction<VoidFromStringStringByteFn>();
final utf8nick = nick.toNativeUtf8(); final utf8nick = nick.toNativeUtf8();
final ut8pass = pass.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(utf8nick);
malloc.free(ut8pass); malloc.free(ut8pass);
} }

View File

@ -71,8 +71,8 @@ class CwtchGomobile implements Cwtch {
} }
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
void CreateProfile(String nick, String pass) { void CreateProfile(String nick, String pass, bool autostart) {
cwtchPlatform.invokeMethod("CreateProfile", {"nick": nick, "pass": pass}); cwtchPlatform.invokeMethod("CreateProfile", {"nick": nick, "pass": pass, "autostart": autostart});
} }
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names

View File

@ -398,12 +398,11 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
// match (and are provided if the user has requested an encrypted profile). // match (and are provided if the user has requested an encrypted profile).
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
if (Provider.of<ProfileInfoState>(context, listen: false).onion.isEmpty) { if (Provider.of<ProfileInfoState>(context, listen: false).onion.isEmpty) {
// TODO: save autostart in create flow
if (usePassword == true) { if (usePassword == true) {
Provider.of<FlwtchState>(context, listen: false).cwtch.CreateProfile(ctrlrNick.value.text, ctrlrPass.value.text); Provider.of<FlwtchState>(context, listen: false).cwtch.CreateProfile(ctrlrNick.value.text, ctrlrPass.value.text, Provider.of<ProfileInfoState>(context, listen: false).autostart);
Navigator.of(context).pop(); Navigator.of(context).pop();
} else { } else {
Provider.of<FlwtchState>(context, listen: false).cwtch.CreateProfile(ctrlrNick.value.text, DefaultPassword); Provider.of<FlwtchState>(context, listen: false).cwtch.CreateProfile(ctrlrNick.value.text, DefaultPassword, Provider.of<ProfileInfoState>(context, listen: false).autostart);
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
} else { } else {