Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement more options and fix general bugs #229

Merged
merged 15 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AppImageBuilder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ AppDir:
command: ./AppRun
AppImage:
arch: x86_64
comp: None
comp: gzip
update-information: guess
30 changes: 23 additions & 7 deletions lib/api/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ import 'package:xml2json/xml2json.dart';
export 'events.dart';
export 'ptz.dart';

enum ServerAdditionResponse {
validated,
versionMismatch,
unknown;
}

class API {
static final API instance = API();

Expand All @@ -49,7 +55,10 @@ class API {
/// If the attributes present in [Server] are correct, then the
/// returned object will have [Server.serverUUID] & [Server.cookie]
/// present in it otherwise `null`.
Future<Server> checkServerCredentials(Server server) async {
Future<(ServerAdditionResponse response, Server server)>
checkServerCredentials(
Server server,
) async {
debugPrint('Checking server credentials for server ${server.id}');
try {
final uri = Uri.https(
Expand Down Expand Up @@ -79,12 +88,19 @@ class API {
);

if (response.statusCode == 200) {
if (body == 'Route error!') {
server.online = false;
return (ServerAdditionResponse.versionMismatch, server);
}
final json = await compute(jsonDecode, body);
return server.copyWith(
serverUUID: json['server_uuid'],
cookie:
response.headers['set-cookie'] ?? response.headers['Set-Cookie'],
online: true,
return (
ServerAdditionResponse.validated,
server.copyWith(
serverUUID: json['server_uuid'],
cookie: response.headers['set-cookie'] ??
response.headers['Set-Cookie'],
online: true,
)
);
} else {
debugPrint(body);
Expand All @@ -97,7 +113,7 @@ class API {

server.online = false;
}
return server;
return (ServerAdditionResponse.unknown, server);
}

/// Gets [Device] devices present on the [server] after login.
Expand Down
2 changes: 1 addition & 1 deletion lib/api/api_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ abstract class APIHelpers {
int attempts = 50,
}) async {
final events = await API.instance.getEvents(
await API.instance.checkServerCredentials(server),
(await API.instance.checkServerCredentials(server)).$2,
);
debugPrint(events.map((e) => e.id).toList().toString());
Future<String?> getThumbnailForMediaID(int mediaID) async {
Expand Down
4 changes: 2 additions & 2 deletions lib/firebase_messaging_background_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ abstract class FirebaseConfiguration {
storage.add({kStorageNotificationToken: token});
for (final server in ServersProvider.instance.servers) {
API.instance.registerNotificationToken(
await API.instance.checkServerCredentials(server),
(await API.instance.checkServerCredentials(server)).$2,
token,
);
}
Expand All @@ -456,7 +456,7 @@ abstract class FirebaseConfiguration {
await storage.add({kStorageNotificationToken: token});
for (final server in ServersProvider.instance.servers) {
API.instance.registerNotificationToken(
await API.instance.checkServerCredentials(server),
(await API.instance.checkServerCredentials(server)).$2,
token,
);
}
Expand Down
73 changes: 56 additions & 17 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@
}
}
},
"serverAlreadyAdded": "The {serverName} server is already added",
"serverAlreadyAdded": "The {serverName} server is already added.",
"@serverAlreadyAdded": {
"placeholders": {
"serverName": {
"type": "String"
}
}
},
"serverVersionMismatch": "Tried to add a server with an unsupported version. Please upgrade your server and try again!",
"noServersAvailable": "No servers available",
"error": "Error",
"videoError": "An error happened while trying to play the video.",
Expand Down Expand Up @@ -159,8 +160,6 @@
}
}
},
"dateFormat": "Date Format",
"timeFormat": "Time Format",
"nDevices": "{n, plural, =0{No devices} =1{1 device} other{{n} devices}}",
"@nDevices": {
"placeholders": {
Expand Down Expand Up @@ -215,8 +214,6 @@
"cameraRefreshPeriodDescription": "The interval between camera refreshes. It ensures the camera video is still valid from time to time.",
"@Layouts": {},
"cycle": "Cycle",
"cycleTogglePeriod": "Layout cycle toggle period",
"cycleTogglePeriodDescription": "The interval between layout changes when the cycle mode is enabled.",
"fallbackLayoutName": "Layout {layout}",
"@fallbackLayoutName": {
"placeholders": {
Expand Down Expand Up @@ -451,11 +448,6 @@
}
}
},
"@BETA FEATURES": {},
"betaFeatures": "Beta features",
"matrixedViewZoom": "Matrixed view zoom",
"matrixedViewZoomDescription": "Zoom in on a 16x16 matrix view to see more detail.",
"matrixType": "Matrix type",
"@CURRENT TASKS": {},
"currentTasks": "Current tasks",
"noCurrentTasks": "No tasks",
Expand All @@ -464,14 +456,65 @@
"taskDownloadingEvent": "Downloading event",
"@@@SETTINGS": {},
"defaultField": "Default",
"@@APPEARANCE": {},
"@@GENERAL": {},
"general": "General",
"cycleTogglePeriod": "Layout cycle toggle period",
"cycleTogglePeriodDescription": "The interval between layout changes when the cycle mode is enabled.",
"notifications": "Notifications",
"notificationsEnabled": "Notifications enabled",
"notificationClickBehavior": "Notification Click Behavior",
"notificationClickBehaviorDescription": "Choose what happens when you click on a notification.",
"showEventsScreen": "Show events history",
"@@EVENTS_AND_DOWNLOADS": {},
"chooseEveryDownloadsLocation": "Choose the location for every download",
"chooseEveryDownloadsLocationDescription": "Whether to choose the location for each download or use the default location. When enabled, you will be prompted to choose the download directory for each download.",
"allowCloseWhenDownloading": "Allow closing the app when downloading",
"events": "Events",
"initialEventSpeed": "Initial event speed",
"initialEventVolume": "Initial event volume",
"differentEventColors": "Different events by colors",
"differentEventColorsDescription": "Whether to show different colors for events in the timeline. This assists to easily differentiate the events.",
"initialTimelinePoint": "Initial point",
"initialTimelinePointDescription": "The initial point of the timeline.",
"beginningInitialPoint": "Beginning",
"firstEventInitialPoint": "First event",
"hourAgoInitialPoint": "1 hour ago",
"@@APPLICATION": {},
"theme": "Theme",
"themeDescription": "Change the appearance of the app",
"system": "System",
"light": "Light",
"dark": "Dark",
"@@MISC": {},
"general": "General",
"dateFormat": "Date Format",
"dateFormatDescription": "What format to use for displaying dates",
"timeFormat": "Time Format",
"timeFormatDescription": "What format to use for displaying time",
"@@PRIVACY_AND_SECURITY": {},
"privacyAndSecurity": "Privacy and Security",
"allowDataCollection": "Allow Bluecherry to collect usage data",
"allowDataCollectionDescription": "Allow Bluecherry to collect data to improve the app and provide better services. Data is collected anonymously and does not contain any personal information.",
"automaticallyReportErrors": "Automatically report errors",
"automaticallyReportErrorsDescription": "Automatically send error reports to Bluecherry to help improve the app. Error reports may contain personal information.",
"privacyPolicy": "Privacy Policy",
"termsOfService": "Terms of Service",
"@@ADVANCED_OPTIONS": {},
"matrixZoom": "Area Magnification",
"matrixedViewZoom": "Area Magnification enabled",
"matrixedViewZoomDescription": "Magnify a area of the matrix view when selected. This is useful when you have a lot of cameras and want to see a specific area in more detail, or when a multicast stream is provided.",
"matrixType": "Matrix type",
"defaultMatrixSize": "Default Magnification Proportion",
"softwareZoom": "Software zoom",
"softwareZoomDescription": "When enabled, the magnification will not happen in the GPU. This is useful when the hardware magnification is not working properly.",
"softwareZoomDescriptionMacOS": "When enabled, the magnification will not happen in the GPU. This is useful when the hardware magnification is not working properly. On macOS, this can not be disabled.",
"developerOptions": "Developer options",
"openLogFile": "Open log file",
"openAppDataDirectory": "Open app data directory",
"debugInfo": "Debug info",
"debugInfoDescription": "Display useful information for debugging, such as video metadata and other useful information for debugging purposes.",
"restoreDefaults": "Restore Defaults",
"restoreDefaultsDescription": "Restore all settings to their default values. This will not affect the servers you have added.",
"areYouSure": "Are you sure?",
"areYouSureDescription": "This will restore all settings to their default values. This will not affect your servers or any other data.",
"miscellaneous": "Miscellaneous",
"wakelock": "Keep screen awake",
"wakelockDescription": "Keep screen awake while watching live streams or recordings.",
Expand All @@ -490,10 +533,6 @@
}
}
},
"@Notification click": {},
"notificationClickBehavior": "Notification Click Behavior",
"notificationClickBehaviorDescription": "Choose what happens when you click on a notification.",
"showEventsScreen": "Show events history",
"@@STREAMING": {},
"streamingSettings": "Streaming settings",
"streamingType": "Streaming type",
Expand Down
71 changes: 55 additions & 16 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
}
}
},
"serverVersionMismatch": "Tried to add a server with an unsupported version. Please upgrade your server and try again!",
"noServersAvailable": "Aucun serveur disponible",
"error": "Erreur",
"videoError": "Une erreur est survenue lors de la lecture de la vidé.",
Expand Down Expand Up @@ -153,8 +154,6 @@
}
}
},
"dateFormat": "Format de la date",
"timeFormat": "Format de l'heure",
"nDevices": "{n} appareils",
"@nDevices": {
"placeholders": {
Expand Down Expand Up @@ -205,8 +204,6 @@
"cameraRefreshPeriodDescription": "The interval between camera refreshes. It ensures the camera video is still valid from time to time.",
"@Layouts": {},
"cycle": "Cycle",
"cycleTogglePeriod": "Durée du cycle de basculement",
"cycleTogglePeriodDescription": "The interval between layout changes when the cycle mode is enabled.",
"fallbackLayoutName": "Disposition {layout}",
"@fallbackLayoutName": {
"placeholders": {
Expand Down Expand Up @@ -427,11 +424,6 @@
}
}
},
"@BETA FEATURES": {},
"betaFeatures": "Beta features",
"matrixedViewZoom": "Matrixed view zoom",
"matrixedViewZoomDescription": "Zoom in on a 16x16 matrixed view to see more detail.",
"matrixType": "Matrix type",
"@CURRENT TASKS": {},
"currentTasks": "Tâche courante",
"noCurrentTasks": "Aucune tâche",
Expand All @@ -440,14 +432,65 @@
"taskDownloadingEvent": "Téléchargement de l'évènement",
"@@@SETTINGS": {},
"defaultField": "Default",
"@@APPEARANCE": {},
"@@GENERAL": {},
"general": "Général",
"cycleTogglePeriod": "Durée du cycle de basculement",
"cycleTogglePeriodDescription": "The interval between layout changes when the cycle mode is enabled.",
"notifications": "Notifications",
"notificationsEnabled": "Notifications enabled",
"notificationClickBehavior": "Action de clic sur les notifications",
"notificationClickBehaviorDescription": "Choose what happens when you click on a notification.",
"showEventsScreen": "Montrer le navigateur d'événements",
"@@EVENTS_AND_DOWNLOADS": {},
"chooseEveryDownloadsLocation": "Choose the location for every download",
"chooseEveryDownloadsLocationDescription": "Whether to choose the location for each download or use the default location. When enabled, you will be prompted to choose the download directory for each download.",
"allowCloseWhenDownloading": "Block the app from closing when there are ongoing downloads",
"events": "Events",
"initialEventSpeed": "Initial speed",
"initialEventVolume": "Initial volume",
"differentEventColors": "Different event colors",
"differentEventColorsDescription": "Whether to show different colors for events in the timeline. This assists to easily differentiate the events.",
"initialTimelinePoint": "Initial point",
"initialTimelinePointDescription": "The initial point of the timeline.",
"beginningInitialPoint": "Beginning",
"firstEventInitialPoint": "First event",
"hourAgoInitialPoint": "1 hour ago",
"@@APPLICATION": {},
"theme": "Thème",
"themeDescription": "Modifier l'apparence de l'application",
"system": "Système",
"light": "Clair",
"dark": "Sombre",
"@@MISC": {},
"general": "Général",
"dateFormat": "Format de la date",
"dateFormatDescription": "What format to use for displaying dates",
"timeFormat": "Format de l'heure",
"timeFormatDescription": "What format to use for displaying time",
"@@PRIVACY_AND_SECURITY": {},
"privacyAndSecurity": "Privacy and Security",
"allowDataCollection": "Allow Bluecherry to collect usage data",
"allowDataCollectionDescription": "Allow Bluecherry to collect data to improve the app and provide better services. Data is collected anonymously and does not contain any personal information.",
"automaticallyReportErrors": "Automatically report errors",
"automaticallyReportErrorsDescription": "Automatically send error reports to Bluecherry to help improve the app. Error reports may contain personal information.",
"privacyPolicy": "Privacy Policy",
"termsOfService": "Terms of Service",
"@@ADVANCED_OPTIONS": {},
"matrixZoom": "Matrix Zoom",
"matrixedViewZoom": "Matrixed view zoom",
"matrixedViewZoomDescription": "Zoom in on a 16x16 matrixed view to see more detail.",
"matrixType": "Matrix type",
"defaultMatrixSize": "Default Matrix Size",
"softwareZoom": "Software zoom",
"softwareZoomDescription": "When enabled, the matrix zoom will not happen in the GPU. This is useful when the hardware zoom is not working properly.",
"softwareZoomDescriptionMacOS": "When enabled, the matrix zoom will not happen in the GPU. This is useful when the hardware zoom is not working properly. On macOS, this can not be disabled.",
"developerOptions": "Developer options",
"openLogFile": "Open log file",
"openAppDataDirectory": "Open app data directory",
"debugInfo": "Debug info",
"debugInfoDescription": "Display useful information for debugging, such as video metadata and other useful information for debugging purposes.",
"restoreDefaults": "Restore Defaults",
"restoreDefaultsDescription": "Restore all settings to their default values. This will not affect the servers you have added.",
"areYouSure": "Are you sure?",
"areYouSureDescription": "This will restore all settings to their default values. This will not affect your servers or any other data.",
"miscellaneous": "Divers",
"wakelock": "Keep screen on",
"wakelockDescription": "Keep screen on while watching live streams or recordings.",
Expand All @@ -464,10 +507,6 @@
"time": {}
}
},
"@Notification click": {},
"notificationClickBehavior": "Action de clic sur les notifications",
"notificationClickBehaviorDescription": "Choose what happens when you click on a notification.",
"showEventsScreen": "Montrer le navigateur d'événements",
"@@STREAMING": {},
"streamingSettings": "Paramètre de diffusion",
"streamingType": "Type de diffusion",
Expand Down
Loading
Loading