serverlist check password. also libcwtch-go version
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Dan Ballard 2021-11-01 21:45:27 -07:00
parent 562c05183b
commit ed8292ece9
4 changed files with 79 additions and 5 deletions

View File

@ -1 +1 @@
v1.3.1-8-g4529984-2021-11-01-22-03
v1.3.1-14-g63e96f3-2021-11-02-04-31

View File

@ -315,7 +315,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
"CreateServer" -> {
val password = (a.get("Password") as? String) ?: ""
val desc = (a.get("Description") as? String) ?: ""
val autostart = (a.get("Autostart") as? Byte) ?: ""
val autostart = (a.get("Autostart") as? Boolean) ?: false
Cwtch.createServer(password, desc, autostart)
}
"DeleteServer" -> {
@ -332,10 +332,10 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
}
"StopServer" -> {
val serverOnion = (a.get("ServerOnion") as? String) ?: ""
Cwtch.shutdownServer(serverOnion)
Cwtch.stopServer(serverOnion)
}
"StopServers" -> {
Cwtch.shutdownServers()
Cwtch.stopServers()
}
"DestroyServers" -> {
Cwtch.destroyServers()

View File

@ -222,7 +222,7 @@ class CwtchGomobile implements Cwtch {
@override
// ignore: non_constant_identifier_names
void CreateServer(String password, String description, bool autostart) {
cwtchPlatform.invokeMethod("CreateServer", {"Password": password, "Description": description, "Autostart": autostart ? 1 : 0});
cwtchPlatform.invokeMethod("CreateServer", {"Password": password, "Description": description, "Autostart": autostart});
}
@override

View File

@ -1,5 +1,6 @@
import 'package:cwtch/models/servers.dart';
import 'package:cwtch/views/addeditservers.dart';
import 'package:cwtch/widgets/passwordfield.dart';
import 'package:cwtch/widgets/serverrow.dart';
import 'package:flutter/material.dart';
import 'package:cwtch/torstatus.dart';
@ -7,7 +8,9 @@ import 'package:cwtch/widgets/tor_icon.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../cwtch_icons_icons.dart';
import '../main.dart';
import '../settings.dart';
///
class ServersView extends StatefulWidget {
@ -16,8 +19,11 @@ class ServersView extends StatefulWidget {
}
class _ServersView extends State<ServersView> {
final ctrlrPassword = TextEditingController();
@override
void dispose() {
ctrlrPassword.dispose();
super.dispose();
}
@ -26,6 +32,7 @@ class _ServersView extends State<ServersView> {
return Scaffold(
appBar: AppBar(
title: Text("Servers you host"), //AppLocalizations.of(context)!.torNetworkStatus),
actions: getActions(),
),
floatingActionButton: FloatingActionButton(
onPressed: _pushAddServer,
@ -63,6 +70,73 @@ class _ServersView extends State<ServersView> {
));
}
List<Widget> getActions() {
List<Widget> actions = new List<Widget>.empty(growable: true);
// Unlock Profiles
actions.add(IconButton(
icon: Icon(CwtchIcons.lock_open_24px),
color: Provider.of<ServerListState>(context).servers.isEmpty ? Provider.of<Settings>(context).theme.defaultButtonColor() : Provider.of<Settings>(context).theme.mainTextColor(),
tooltip: AppLocalizations.of(context)!.tooltipUnlockProfiles,
onPressed: _modalUnlockServers,
));
return actions;
}
void _modalUnlockServers() {
showModalBottomSheet<void>(
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return Padding(
padding: MediaQuery.of(context).viewInsets,
child: RepaintBoundary(
child: Container(
height: 200, // bespoke value courtesy of the [TextField] docs
child: Center(
child: Padding(
padding: EdgeInsets.all(10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text("Enter password to unlock server"),//AppLocalizations.of(context)!.enterProfilePassword),
SizedBox(
height: 20,
),
CwtchPasswordField(
autofocus: true,
controller: ctrlrPassword,
action: unlock,
validator: (value) {},
),
SizedBox(
height: 20,
),
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
Spacer(),
Expanded(
child: ElevatedButton(
child: Text(AppLocalizations.of(context)!.unlock, semanticsLabel: AppLocalizations.of(context)!.unlock),
onPressed: () {
unlock(ctrlrPassword.value.text);
},
)),
Spacer()
]),
],
))),
)));
});
}
void unlock(String password) {
Provider.of<FlwtchState>(context, listen: false).cwtch.LoadServers(password);
ctrlrPassword.text = "";
Navigator.pop(context);
}
void _pushAddServer() {
Navigator.of(context).push(MaterialPageRoute<void>(
builder: (BuildContext context) {