summaryrefslogtreecommitdiffstats
path: root/lib/data/data_providers
diff options
context:
space:
mode:
Diffstat (limited to 'lib/data/data_providers')
-rw-r--r--lib/data/data_providers/app_config_provider.dart50
-rw-r--r--lib/data/data_providers/app_launcher.dart24
-rw-r--r--lib/data/data_providers/app_provider.dart1
-rw-r--r--lib/data/data_providers/audio_notifier.dart4
-rw-r--r--lib/data/data_providers/mediaplayer_notifier.dart4
-rw-r--r--lib/data/data_providers/radio_client.dart18
-rw-r--r--lib/data/data_providers/radio_notifier.dart2
-rw-r--r--lib/data/data_providers/units_notifier.dart2
-rw-r--r--lib/data/data_providers/val_client.dart14
-rw-r--r--lib/data/data_providers/vehicle_notifier.dart12
10 files changed, 66 insertions, 65 deletions
diff --git a/lib/data/data_providers/app_config_provider.dart b/lib/data/data_providers/app_config_provider.dart
index 7ec8d8a..6a4ea02 100644
--- a/lib/data/data_providers/app_config_provider.dart
+++ b/lib/data/data_providers/app_config_provider.dart
@@ -8,9 +8,9 @@ class KuksaConfig {
final String hostname;
final int port;
final String authorization;
- final bool use_tls;
- final List<int> ca_certificate;
- final String tls_server_name;
+ final bool useTls;
+ final List<int> caCertificate;
+ final String tlsServerName;
static String defaultHostname = 'localhost';
static int defaultPort = 55555;
@@ -20,18 +20,18 @@ class KuksaConfig {
{required this.hostname,
required this.port,
required this.authorization,
- required this.use_tls,
- required this.ca_certificate,
- required this.tls_server_name});
+ required this.useTls,
+ required this.caCertificate,
+ required this.tlsServerName});
static KuksaConfig defaultConfig() {
return KuksaConfig(
hostname: KuksaConfig.defaultHostname,
port: KuksaConfig.defaultPort,
authorization: "",
- use_tls: false,
- ca_certificate: [],
- tls_server_name: "");
+ useTls: false,
+ caCertificate: [],
+ tlsServerName: "");
}
}
@@ -120,38 +120,38 @@ class AppConfig {
}
//debugPrint("authorization = $token");
- bool use_tls = false;
+ bool useTls = false;
if (kuksaMap.containsKey('use-tls')) {
var value = kuksaMap['use-tls'];
- if (value is bool) use_tls = value;
+ if (value is bool) useTls = value;
}
//debugPrint("Use TLS = $use_tls");
- List<int> ca_cert = [];
- String ca_path = KuksaConfig.defaultCaCertPath;
+ List<int> caCert = [];
+ String caPath = KuksaConfig.defaultCaCertPath;
if (kuksaMap.containsKey('ca-certificate')) {
- ca_path = kuksaMap['ca-certificate'];
+ caPath = kuksaMap['ca-certificate'];
}
try {
- ca_cert = File(ca_path).readAsBytesSync();
+ caCert = File(caPath).readAsBytesSync();
} catch (_) {
- print("ERROR: Could not read CA certificate file $ca_path");
- ca_cert = [];
+ print("ERROR: Could not read CA certificate file $caPath");
+ caCert = [];
}
//debugPrint("CA cert = $ca_cert");
- String tls_server_name = "";
+ String tlsServerName = "";
if (kuksaMap.containsKey('tls-server-name')) {
- tls_server_name = kuksaMap['tls-server-name'];
+ tlsServerName = kuksaMap['tls-server-name'];
}
return KuksaConfig(
hostname: hostname,
port: port,
authorization: token,
- use_tls: use_tls,
- ca_certificate: ca_cert,
- tls_server_name: tls_server_name);
+ useTls: useTls,
+ caCertificate: caCert,
+ tlsServerName: tlsServerName);
} catch (_) {
debugPrint("Invalid KUKSA.val configuration, using defaults");
return KuksaConfig.defaultConfig();
@@ -217,9 +217,9 @@ final appConfigProvider = Provider((ref) {
hostname: KuksaConfig.defaultHostname,
port: KuksaConfig.defaultPort,
authorization: "",
- use_tls: false,
- ca_certificate: [],
- tls_server_name: "");
+ useTls: false,
+ caCertificate: [],
+ tlsServerName: "");
}
RadioConfig radioConfig;
diff --git a/lib/data/data_providers/app_launcher.dart b/lib/data/data_providers/app_launcher.dart
index 8762643..917dd21 100644
--- a/lib/data/data_providers/app_launcher.dart
+++ b/lib/data/data_providers/app_launcher.dart
@@ -1,6 +1,6 @@
import 'package:flutter_ics_homescreen/export.dart';
-import 'package:protos/applauncher-api.dart';
-import 'package:protos/agl-shell-api.dart';
+import 'package:protos/applauncher_api.dart';
+import 'package:protos/agl_shell_api.dart';
class AppLauncher {
final Ref ref;
@@ -15,13 +15,13 @@ class AppLauncher {
AppLauncher({required this.ref}) {
aglShellChannel = ClientChannel('localhost',
port: 14005,
- options: ChannelOptions(credentials: ChannelCredentials.insecure()));
+ options: const ChannelOptions(credentials: ChannelCredentials.insecure()));
aglShell = AglShellManagerServiceClient(aglShellChannel);
appLauncherChannel = ClientChannel('localhost',
port: 50052,
- options: ChannelOptions(credentials: ChannelCredentials.insecure()));
+ options: const ChannelOptions(credentials: ChannelCredentials.insecure()));
appLauncher = AppLauncherClient(appLauncherChannel);
}
@@ -32,14 +32,14 @@ class AppLauncher {
var response = appLauncher.getStatusEvents(StatusRequest());
await for (var event in response) {
if (event.hasApp()) {
- AppStatus app_status = event.app;
+ AppStatus appStatus = event.app;
debugPrint("Got app status:");
- debugPrint("$app_status");
- if (app_status.hasId() && app_status.hasStatus()) {
- if (app_status.status == "started") {
- activateApp(app_status.id);
- } else if (app_status.status == "terminated") {
- deactivateApp(app_status.id);
+ debugPrint("$appStatus");
+ if (appStatus.hasId() && appStatus.hasStatus()) {
+ if (appStatus.status == "started") {
+ activateApp(appStatus.id);
+ } else if (appStatus.status == "terminated") {
+ deactivateApp(appStatus.id);
}
}
}
@@ -100,7 +100,7 @@ class AppLauncher {
activateApp(String id) async {
if (appStack.last != id) {
var req = ActivateRequest(appId: id);
- var response = aglShell.activateApp(req);
+ aglShell.activateApp(req);
addAppToStack(id);
}
}
diff --git a/lib/data/data_providers/app_provider.dart b/lib/data/data_providers/app_provider.dart
index a74c0fd..ca2c3d4 100644
--- a/lib/data/data_providers/app_provider.dart
+++ b/lib/data/data_providers/app_provider.dart
@@ -18,7 +18,6 @@ import 'package:flutter_ics_homescreen/data/data_providers/play_controller.dart'
import 'package:flutter_ics_homescreen/export.dart';
import 'package:flutter_ics_homescreen/data/models/users.dart';
-import 'package:flutter_ics_homescreen/data/models/mediaplayer_state.dart';
enum AppState {
home,
diff --git a/lib/data/data_providers/audio_notifier.dart b/lib/data/data_providers/audio_notifier.dart
index 76b34a7..4933932 100644
--- a/lib/data/data_providers/audio_notifier.dart
+++ b/lib/data/data_providers/audio_notifier.dart
@@ -1,10 +1,10 @@
import 'package:flutter_ics_homescreen/export.dart';
-import 'package:protos/val-api.dart';
+import 'package:protos/val_api.dart';
class AudioStateNotifier extends Notifier<AudioState> {
@override
AudioState build() {
- return AudioState.initial();
+ return const AudioState.initial();
}
void resetToDefaults() {
diff --git a/lib/data/data_providers/mediaplayer_notifier.dart b/lib/data/data_providers/mediaplayer_notifier.dart
index 2d02e75..bb121c0 100644
--- a/lib/data/data_providers/mediaplayer_notifier.dart
+++ b/lib/data/data_providers/mediaplayer_notifier.dart
@@ -4,7 +4,7 @@ import 'playlist_notifier.dart';
class MediaPlayerStateNotifier extends Notifier<MediaPlayerState> {
@override
MediaPlayerState build() {
- return MediaPlayerState.initial();
+ return const MediaPlayerState.initial();
}
void updatePlayState(PlayState newState) {
@@ -20,6 +20,6 @@ class MediaPlayerStateNotifier extends Notifier<MediaPlayerState> {
}
void reset() {
- state = MediaPlayerState.initial();
+ state = const MediaPlayerState.initial();
}
}
diff --git a/lib/data/data_providers/radio_client.dart b/lib/data/data_providers/radio_client.dart
index 2cde65e..3ee041a 100644
--- a/lib/data/data_providers/radio_client.dart
+++ b/lib/data/data_providers/radio_client.dart
@@ -1,5 +1,5 @@
import 'package:flutter_ics_homescreen/export.dart';
-import 'package:protos/radio-api.dart' as api;
+import 'package:protos/radio_api.dart' as api;
class RadioClient {
final RadioConfig config;
@@ -71,7 +71,7 @@ class RadioClient {
void start() async {
try {
- var response = await stub.start(api.StartRequest());
+ await stub.start(api.StartRequest());
} catch (e) {
print(e);
}
@@ -79,7 +79,7 @@ class RadioClient {
void stop() async {
try {
- var response = await stub.stop(api.StopRequest());
+ await stub.stop(api.StopRequest());
} catch (e) {
print(e);
}
@@ -94,7 +94,7 @@ class RadioClient {
return;
}
try {
- var response = await stub
+ await stub
.setFrequency(api.SetFrequencyRequest(frequency: frequency));
} catch (e) {
print(e);
@@ -109,7 +109,7 @@ class RadioClient {
frequency = radioState.freqMax;
}
try {
- var response = await stub
+ await stub
.setFrequency(api.SetFrequencyRequest(frequency: frequency));
} catch (e) {
print(e);
@@ -125,7 +125,7 @@ class RadioClient {
frequency = radioState.freqMin;
}
try {
- var response = await stub
+ await stub
.setFrequency(api.SetFrequencyRequest(frequency: frequency));
} catch (e) {
print(e);
@@ -135,7 +135,7 @@ class RadioClient {
void scanForward() async {
try {
- var response = await stub.scanStart(api.ScanStartRequest(
+ await stub.scanStart(api.ScanStartRequest(
direction: api.ScanDirection.SCAN_DIRECTION_FORWARD));
} catch (e) {
print(e);
@@ -144,7 +144,7 @@ class RadioClient {
void scanBackward() async {
try {
- var response = await stub.scanStart(api.ScanStartRequest(
+ await stub.scanStart(api.ScanStartRequest(
direction: api.ScanDirection.SCAN_DIRECTION_BACKWARD));
} catch (e) {
print(e);
@@ -153,7 +153,7 @@ class RadioClient {
void scanStop() async {
try {
- var response = await stub.scanStop(api.ScanStopRequest());
+ await stub.scanStop(api.ScanStopRequest());
} catch (e) {
print(e);
}
diff --git a/lib/data/data_providers/radio_notifier.dart b/lib/data/data_providers/radio_notifier.dart
index 90e0df5..3ef4da4 100644
--- a/lib/data/data_providers/radio_notifier.dart
+++ b/lib/data/data_providers/radio_notifier.dart
@@ -3,7 +3,7 @@ import 'package:flutter_ics_homescreen/export.dart';
class RadioStateNotifier extends Notifier<RadioState> {
@override
RadioState build() {
- return RadioState.initial();
+ return const RadioState.initial();
}
void updateBandParameters(
diff --git a/lib/data/data_providers/units_notifier.dart b/lib/data/data_providers/units_notifier.dart
index 26b79da..68c9e65 100644
--- a/lib/data/data_providers/units_notifier.dart
+++ b/lib/data/data_providers/units_notifier.dart
@@ -1,5 +1,5 @@
import 'package:flutter_ics_homescreen/export.dart';
-import 'package:protos/val-api.dart';
+import 'package:protos/val_api.dart';
class UnitsNotifier extends Notifier<Units> {
@override
diff --git a/lib/data/data_providers/val_client.dart b/lib/data/data_providers/val_client.dart
index 5e7339c..173dbfb 100644
--- a/lib/data/data_providers/val_client.dart
+++ b/lib/data/data_providers/val_client.dart
@@ -1,5 +1,5 @@
import 'package:flutter_ics_homescreen/export.dart';
-import 'package:protos/val-api.dart';
+import 'package:protos/val_api.dart';
class ValClient {
final KuksaConfig config;
@@ -11,14 +11,14 @@ class ValClient {
ValClient({required this.config, required this.ref}) {
debugPrint("Connecting to KUKSA.val at ${config.hostname}:${config.port}");
ChannelCredentials creds;
- if (config.use_tls && config.ca_certificate.isNotEmpty) {
+ if (config.useTls && config.caCertificate.isNotEmpty) {
print("Using TLS");
- if (config.tls_server_name.isNotEmpty) {
+ if (config.tlsServerName.isNotEmpty) {
creds = ChannelCredentials.secure(
- certificates: config.ca_certificate,
- authority: config.tls_server_name);
+ certificates: config.caCertificate,
+ authority: config.tlsServerName);
} else {
- creds = ChannelCredentials.secure(certificates: config.ca_certificate);
+ creds = ChannelCredentials.secure(certificates: config.caCertificate);
}
} else {
creds = const ChannelCredentials.insecure();
@@ -133,7 +133,7 @@ class ValClient {
if (config.authorization.isNotEmpty) {
metadata = {'authorization': "Bearer ${config.authorization}"};
}
- debugPrint("Getting {path} value");
+ debugPrint("Getting $path value");
var response =
await stub.get(request, options: CallOptions(metadata: metadata));
if (response.hasError()) {
diff --git a/lib/data/data_providers/vehicle_notifier.dart b/lib/data/data_providers/vehicle_notifier.dart
index 6583f9a..1dc4627 100644
--- a/lib/data/data_providers/vehicle_notifier.dart
+++ b/lib/data/data_providers/vehicle_notifier.dart
@@ -3,12 +3,12 @@
import 'dart:async';
import 'package:flutter_ics_homescreen/export.dart';
-import 'package:protos/val-api.dart';
+import 'package:protos/val_api.dart';
class VehicleNotifier extends Notifier<Vehicle> {
@override
Vehicle build() {
- return Vehicle.initial();
+ return const Vehicle.initial();
}
void updateSpeed(double newValue) {
@@ -103,11 +103,13 @@ class VehicleNotifier extends Notifier<Vehicle> {
// Convert 0-100 to local 0-3 setting
var value = entry.value.uint32;
var fanSpeed = 0;
- if (value > 66)
+ if (value > 66) {
fanSpeed = 3;
- else if (value > 33)
+ }
+ else if (value > 33) {
fanSpeed = 2;
- else if (value > 0) fanSpeed = 1;
+ }
+ else if (value > 0) { fanSpeed = 1; }
state = state.copyWith(fanSpeed: fanSpeed);
}
break;