Rename all OPDS-prefixed models to generic names (Server, Feed, Entry, Link, StreamLink), expand the ServerSoftware interface to cover all server interactions, and implement a full Kavita REST API client that replaces the OPDS delegation. - Rename OPDS* models to generic names across ~60 files - Add database migrations 13 (opds_id → entry_id) and 14 (unify credentials) - Create OPDSServerSoftware wrapping existing OPDS services - Create KavitaApiClient for direct Kavita REST API calls - Create KavitaFeedMapper to convert Kavita JSON to Feed/Entry models - Rewrite KavitaServerSoftware to use native API (no OPDS delegation) - Unify server credentials (remove softwareUsername/softwarePassword) - Simplify add/edit server UI to single auth section - Add test connection button to server add/edit screens - Add progress indicator to PublicationCard using local and server data - Eliminate softwareType branching in reader screens - Add EntryProgress and fetchEntryProgress to ServerSoftware interface - Fix Entry.acquisitionLink crash on empty links - Add 59 new tests covering models, services, and providers
36 lines
1.5 KiB
Dart
36 lines
1.5 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:worldhopper/models/server.dart';
|
|
import 'package:worldhopper/services/server_software/kavita_server_software.dart';
|
|
import 'package:worldhopper/services/server_software/opds_server_software.dart';
|
|
import 'package:worldhopper/services/server_software/server_software.dart';
|
|
import 'package:worldhopper/services/server_software/server_software_type.dart';
|
|
|
|
/// Registry / dispatcher for server-software-specific operations.
|
|
class ServerSoftwareService {
|
|
final OPDSServerSoftware _opds = OPDSServerSoftware();
|
|
final KavitaServerSoftware _kavita = KavitaServerSoftware();
|
|
|
|
/// Detect the server software type from the server URL.
|
|
/// Note: Kavita detection returns false (base URLs are not distinguishable).
|
|
/// Users should select Kavita from the dropdown.
|
|
ServerSoftwareType detect(Server server) {
|
|
if (_kavita.detectFromUrl(server)) return ServerSoftwareType.kavita;
|
|
return ServerSoftwareType.generic;
|
|
}
|
|
|
|
/// Get the [ServerSoftware] implementation for a given server.
|
|
ServerSoftware getImplementation(Server server) {
|
|
final type = server.softwareType ?? ServerSoftwareType.generic;
|
|
debugPrint('ServerSoftwareService: dispatching to $type for ${server.id}');
|
|
return switch (type) {
|
|
ServerSoftwareType.kavita => _kavita,
|
|
ServerSoftwareType.generic => _opds,
|
|
};
|
|
}
|
|
|
|
/// Clear any cached tokens/state for the given server.
|
|
void clearCachedState(String serverId) {
|
|
_kavita.clearCachedState(serverId);
|
|
_opds.clearCachedState(serverId);
|
|
}
|
|
}
|