| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import '../../core/app_version.dart';
- /// The authenticated details needed by the library and playback services.
- /// Keep this out of widgets; [toString] deliberately omits the token.
- class JellyfinConnection {
- const JellyfinConnection({
- required this.baseUrl,
- required this.accessToken,
- required this.userId,
- required this.deviceId,
- required this.userName,
- });
- final Uri baseUrl;
- final String accessToken;
- final String userId;
- final String deviceId;
- final String userName;
- String get authorizationHeader {
- final parts = [
- 'Client="CarDash"',
- 'Device="CarDash"',
- 'DeviceId="$deviceId"',
- 'Version="$appVersion"',
- 'Token="$accessToken"',
- ];
- return 'MediaBrowser ${parts.join(', ')}';
- }
- Map<String, String> get apiHeaders => {
- 'Authorization': authorizationHeader,
- 'Accept': 'application/json',
- };
- @override
- String toString() => 'JellyfinConnection($baseUrl, user: $userName)';
- }
- /// Public identity of a Jellyfin server.
- class JellyfinServerInfo {
- const JellyfinServerInfo({required this.name, required this.version});
- final String name;
- final String version;
- }
- /// A pending Quick Connect request. The code is shown to the user; the secret
- /// is exchanged for an access token once the user approves the device.
- class JellyfinQuickConnect {
- const JellyfinQuickConnect({required this.code, required this.secret});
- final String code;
- final String secret;
- }
- /// The signed-in Jellyfin user for this device.
- class JellyfinUser {
- const JellyfinUser({required this.id, required this.name});
- final String id;
- final String name;
- }
- /// An access token plus the user it belongs to.
- class JellyfinSession {
- const JellyfinSession({
- required this.accessToken,
- required this.userId,
- required this.userName,
- });
- final String accessToken;
- final String userId;
- final String userName;
- }
- /// A Jellyfin request failed. [JellyfinUnreachable] means the server could not
- /// be contacted at all; [JellyfinAuthException] means the saved token is no
- /// longer accepted.
- class JellyfinException implements Exception {
- JellyfinException(this.message);
- final String message;
- @override
- String toString() => message;
- }
- class JellyfinUnreachable extends JellyfinException {
- JellyfinUnreachable(super.message);
- }
- class JellyfinAuthException extends JellyfinException {
- JellyfinAuthException(super.message);
- }
|