use GomuksConfig
This commit is contained in:
parent
0cd815dc79
commit
09534a6775
4 changed files with 67 additions and 9 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -1,4 +1,3 @@
|
|||
[submodule "gomuks"]
|
||||
path = gomuks
|
||||
url = https://github.com/Henry-Hiles/gomuks
|
||||
branch = quad/feat/customizable-device-name
|
||||
url = https://github.com/gomuks/gomuks
|
||||
|
|
|
|||
2
gomuks
2
gomuks
|
|
@ -1 +1 @@
|
|||
Subproject commit ae11daa1b14b103688e57accb9c65ad6401cb3ef
|
||||
Subproject commit b11eedca121a7081d3ee48165ba363e722d18d87
|
||||
|
|
@ -20,6 +20,7 @@ import "package:nexus/main.dart";
|
|||
import "package:nexus/models/capabilities.dart";
|
||||
import "package:nexus/models/content/message.dart";
|
||||
import "package:nexus/models/event.dart";
|
||||
import "package:nexus/models/gomuks_config.dart";
|
||||
import "package:nexus/models/oauth_auth_code_response.dart";
|
||||
import "package:nexus/models/open_graph_data.dart";
|
||||
import "package:nexus/models/paginate.dart";
|
||||
|
|
@ -70,14 +71,17 @@ class ClientController extends AsyncNotifier<int> {
|
|||
}
|
||||
}
|
||||
final handle = await Isolate.run(() {
|
||||
final message =
|
||||
"Nexus on ${toBeginningOfSentenceCase(Platform.operatingSystem)}"
|
||||
.toNativeUtf8()
|
||||
.cast<Char>();
|
||||
final bufferPointer = GomuksConfig(
|
||||
matrix: .new(
|
||||
initialDeviceDisplayName:
|
||||
"Nexus on ${toBeginningOfSentenceCase(Platform.operatingSystem)}",
|
||||
),
|
||||
).toJson().toGomuksBufferPtr();
|
||||
|
||||
try {
|
||||
return GomuksInit(message);
|
||||
return GomuksInit(bufferPointer.ref);
|
||||
} finally {
|
||||
calloc.free(message);
|
||||
calloc.free(bufferPointer);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
55
lib/models/gomuks_config.dart
Normal file
55
lib/models/gomuks_config.dart
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "gomuks_config.freezed.dart";
|
||||
part "gomuks_config.g.dart";
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const GomuksConfig({
|
||||
final MatrixConfig? matrix,
|
||||
final PushConfig? push,
|
||||
final MediaConfig? media,
|
||||
}) with _$GomuksConfig {
|
||||
Map<String, Object?> toJson() => _$GomuksConfigToJson(this);
|
||||
|
||||
factory GomuksConfig.fromJson(Map<String, Object?> json) =>
|
||||
_$GomuksConfigFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const MatrixConfig({
|
||||
@JsonKey(name: "disable_http2") final bool disableHttp2 = false,
|
||||
@JsonKey(name: "set_presence") final String? setPresence,
|
||||
@JsonKey(name: "initial_device_display_name")
|
||||
required final String initialDeviceDisplayName,
|
||||
}) with _$MatrixConfig {
|
||||
Map<String, Object?> toJson() => _$MatrixConfigToJson(this);
|
||||
|
||||
factory MatrixConfig.fromJson(Map<String, Object?> json) =>
|
||||
_$MatrixConfigFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const PushConfig({
|
||||
@JsonKey(name: "fcm_gateway") required final String fcmGateway,
|
||||
@JsonKey(name: "vapid_private_key") required final String vapidPrivateKey,
|
||||
@JsonKey(name: "vapid_public_key") required final String vapidPublicKey,
|
||||
}) with _$PushConfig {
|
||||
Map<String, Object?> toJson() => _$PushConfigToJson(this);
|
||||
|
||||
factory PushConfig.fromJson(Map<String, Object?> json) =>
|
||||
_$PushConfigFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const MediaConfig({
|
||||
@JsonKey(name: "thumbnail_size") required final int thumbnailSize,
|
||||
}) with _$MediaConfig {
|
||||
Map<String, Object?> toJson() => _$MediaConfigToJson(this);
|
||||
|
||||
factory MediaConfig.fromJson(Map<String, Object?> json) =>
|
||||
_$MediaConfigFromJson(json);
|
||||
}
|
||||
Loading…
Reference in a new issue