selfprivacy.org.app/lib/logic/models/server_status.dart

54 lines
1.1 KiB
Dart
Raw Normal View History

2021-01-21 23:01:42 +02:00
class ServerStatus {
final StatusTypes http;
final StatusTypes imap;
final StatusTypes smtp;
ServerStatus({
2021-03-15 17:39:44 +02:00
required this.http,
2021-01-21 23:01:42 +02:00
this.imap = StatusTypes.nodata,
this.smtp = StatusTypes.nodata,
});
ServerStatus fromJson(Map<String, dynamic> json) {
return ServerStatus(
http: statusTypeFromNumber(json['http']),
imap: statusTypeFromNumber(json['imap']),
smtp: statusTypeFromNumber(json['smtp']),
);
}
}
2021-03-15 17:39:44 +02:00
StatusTypes statusTypeFromNumber(int? number) {
2021-01-21 23:01:42 +02:00
if (number == 0) {
return StatusTypes.ok;
} else if (number == 1) {
return StatusTypes.error;
} else if (number == 2) {
return StatusTypes.wrongArgument;
} else if (number == 3) {
return StatusTypes.wrongFunction;
} else if (number == 4) {
return StatusTypes.noRights;
} else if (number == 5) {
return StatusTypes.notInstalled;
} else if (number == 6) {
return StatusTypes.notConfigured;
} else if (number == 7) {
return StatusTypes.off;
} else {
throw Exception('wrong status');
}
}
enum StatusTypes {
ok,
error,
wrongArgument,
wrongFunction,
noRights,
notInstalled,
notConfigured,
off,
nodata,
}