mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-08 01:20:27 +00:00
feat: move native communication to FFI (#1457)
This commit is contained in:
86 files changed
+4558
-886
No files matched your search
@@ -13,6 +13,7 @@ class DownloaderConfig {
|
||||
ScriptConfig script = ScriptConfig();
|
||||
AutoTorrentConfig autoTorrent = AutoTorrentConfig();
|
||||
ArchiveConfig archive = ArchiveConfig();
|
||||
ApiServerConfig api = ApiServerConfig();
|
||||
bool autoStartTasks;
|
||||
bool autoDeleteMissingFileTasks;
|
||||
|
||||
@@ -28,6 +29,21 @@ class DownloaderConfig {
|
||||
Map<String, dynamic> toJson() => _$DownloaderConfigToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class ApiServerConfig {
|
||||
bool enable;
|
||||
String network;
|
||||
String address;
|
||||
String token;
|
||||
|
||||
ApiServerConfig({this.enable = false, this.network = 'tcp', this.address = '127.0.0.1:9999', this.token = ''});
|
||||
|
||||
factory ApiServerConfig.fromJson(Map<String, dynamic>? json) =>
|
||||
json == null ? ApiServerConfig() : _$ApiServerConfigFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ApiServerConfigToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class ProtocolConfig {
|
||||
HttpConfig http = HttpConfig();
|
||||
@@ -102,6 +118,12 @@ class ExtraConfig {
|
||||
bool notifyWhenNewVersion;
|
||||
bool desktopNotification;
|
||||
bool backgroundLocationKeepAlive;
|
||||
WindowStateConfig windowState;
|
||||
Map<String, String> bookmarks;
|
||||
List<String> createHistory;
|
||||
bool runAsMenubarApp;
|
||||
bool analyticsEnabled;
|
||||
String analyticsClientId;
|
||||
List<DownloadCategory> downloadCategories;
|
||||
|
||||
ExtraConfigBt bt = ExtraConfigBt();
|
||||
@@ -117,8 +139,14 @@ class ExtraConfig {
|
||||
this.notifyWhenNewVersion = true,
|
||||
this.desktopNotification = true,
|
||||
this.backgroundLocationKeepAlive = false,
|
||||
WindowStateConfig? windowState,
|
||||
this.bookmarks = const {},
|
||||
this.createHistory = const [],
|
||||
this.runAsMenubarApp = false,
|
||||
this.analyticsEnabled = true,
|
||||
this.analyticsClientId = '',
|
||||
this.downloadCategories = const [],
|
||||
});
|
||||
}) : windowState = windowState ?? WindowStateConfig();
|
||||
|
||||
factory ExtraConfig.fromJson(Map<String, dynamic>? json) =>
|
||||
json == null ? ExtraConfig() : _$ExtraConfigFromJson(json);
|
||||
@@ -126,6 +154,20 @@ class ExtraConfig {
|
||||
Map<String, dynamic> toJson() => _$ExtraConfigToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class WindowStateConfig {
|
||||
bool isMaximized;
|
||||
double? width;
|
||||
double? height;
|
||||
|
||||
WindowStateConfig({this.isMaximized = false, this.width, this.height});
|
||||
|
||||
factory WindowStateConfig.fromJson(Map<String, dynamic>? json) =>
|
||||
json == null ? WindowStateConfig() : _$WindowStateConfigFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$WindowStateConfigToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class DownloadCategory {
|
||||
String name;
|
||||
|
||||
@@ -19,7 +19,8 @@ DownloaderConfig _$DownloaderConfigFromJson(Map<String, dynamic> json) =>
|
||||
..webhook = WebhookConfig.fromJson(json['webhook'] as Map<String, dynamic>?)
|
||||
..script = ScriptConfig.fromJson(json['script'] as Map<String, dynamic>?)
|
||||
..autoTorrent = AutoTorrentConfig.fromJson(json['autoTorrent'] as Map<String, dynamic>?)
|
||||
..archive = ArchiveConfig.fromJson(json['archive'] as Map<String, dynamic>?);
|
||||
..archive = ArchiveConfig.fromJson(json['archive'] as Map<String, dynamic>?)
|
||||
..api = ApiServerConfig.fromJson(json['api'] as Map<String, dynamic>?);
|
||||
|
||||
Map<String, dynamic> _$DownloaderConfigToJson(DownloaderConfig instance) => <String, dynamic>{
|
||||
'downloadDir': instance.downloadDir,
|
||||
@@ -31,10 +32,25 @@ Map<String, dynamic> _$DownloaderConfigToJson(DownloaderConfig instance) => <Str
|
||||
'script': instance.script.toJson(),
|
||||
'autoTorrent': instance.autoTorrent.toJson(),
|
||||
'archive': instance.archive.toJson(),
|
||||
'api': instance.api.toJson(),
|
||||
'autoStartTasks': instance.autoStartTasks,
|
||||
'autoDeleteMissingFileTasks': instance.autoDeleteMissingFileTasks,
|
||||
};
|
||||
|
||||
ApiServerConfig _$ApiServerConfigFromJson(Map<String, dynamic> json) => ApiServerConfig(
|
||||
enable: json['enable'] as bool? ?? false,
|
||||
network: json['network'] as String? ?? 'tcp',
|
||||
address: json['address'] as String? ?? '127.0.0.1:9999',
|
||||
token: json['token'] as String? ?? '',
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ApiServerConfigToJson(ApiServerConfig instance) => <String, dynamic>{
|
||||
'enable': instance.enable,
|
||||
'network': instance.network,
|
||||
'address': instance.address,
|
||||
'token': instance.token,
|
||||
};
|
||||
|
||||
ProtocolConfig _$ProtocolConfigFromJson(Map<String, dynamic> json) => ProtocolConfig()
|
||||
..http = HttpConfig.fromJson(json['http'] as Map<String, dynamic>)
|
||||
..bt = BtConfig.fromJson(json['bt'] as Map<String, dynamic>)
|
||||
@@ -101,6 +117,14 @@ ExtraConfig _$ExtraConfigFromJson(Map<String, dynamic> json) =>
|
||||
notifyWhenNewVersion: json['notifyWhenNewVersion'] as bool? ?? true,
|
||||
desktopNotification: json['desktopNotification'] as bool? ?? true,
|
||||
backgroundLocationKeepAlive: json['backgroundLocationKeepAlive'] as bool? ?? false,
|
||||
windowState: json['windowState'] == null
|
||||
? null
|
||||
: WindowStateConfig.fromJson(json['windowState'] as Map<String, dynamic>?),
|
||||
bookmarks: (json['bookmarks'] as Map<String, dynamic>?)?.map((k, e) => MapEntry(k, e as String)) ?? const {},
|
||||
createHistory: (json['createHistory'] as List<dynamic>?)?.map((e) => e as String).toList() ?? const [],
|
||||
runAsMenubarApp: json['runAsMenubarApp'] as bool? ?? false,
|
||||
analyticsEnabled: json['analyticsEnabled'] as bool? ?? true,
|
||||
analyticsClientId: json['analyticsClientId'] as String? ?? '',
|
||||
downloadCategories:
|
||||
(json['downloadCategories'] as List<dynamic>?)
|
||||
?.map((e) => DownloadCategory.fromJson(e as Map<String, dynamic>))
|
||||
@@ -120,11 +144,29 @@ Map<String, dynamic> _$ExtraConfigToJson(ExtraConfig instance) => <String, dynam
|
||||
'notifyWhenNewVersion': instance.notifyWhenNewVersion,
|
||||
'desktopNotification': instance.desktopNotification,
|
||||
'backgroundLocationKeepAlive': instance.backgroundLocationKeepAlive,
|
||||
'windowState': instance.windowState.toJson(),
|
||||
'bookmarks': instance.bookmarks,
|
||||
'createHistory': instance.createHistory,
|
||||
'runAsMenubarApp': instance.runAsMenubarApp,
|
||||
'analyticsEnabled': instance.analyticsEnabled,
|
||||
'analyticsClientId': instance.analyticsClientId,
|
||||
'downloadCategories': instance.downloadCategories.map((e) => e.toJson()).toList(),
|
||||
'bt': instance.bt.toJson(),
|
||||
'githubMirror': instance.githubMirror.toJson(),
|
||||
};
|
||||
|
||||
WindowStateConfig _$WindowStateConfigFromJson(Map<String, dynamic> json) => WindowStateConfig(
|
||||
isMaximized: json['isMaximized'] as bool? ?? false,
|
||||
width: (json['width'] as num?)?.toDouble(),
|
||||
height: (json['height'] as num?)?.toDouble(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$WindowStateConfigToJson(WindowStateConfig instance) => <String, dynamic>{
|
||||
'isMaximized': instance.isMaximized,
|
||||
'width': ?instance.width,
|
||||
'height': ?instance.height,
|
||||
};
|
||||
|
||||
DownloadCategory _$DownloadCategoryFromJson(Map<String, dynamic> json) => DownloadCategory(
|
||||
name: json['name'] as String,
|
||||
path: json['path'] as String,
|
||||
|
||||
Reference in new issue
Block a user