use GomuksConfig

This commit is contained in:
Henry Hiles 2026-09-22 09:53:00 -04:00
commit 09534a6775
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
4 changed files with 67 additions and 9 deletions

3
.gitmodules vendored
View file

@ -1,4 +1,3 @@
[submodule "gomuks"] [submodule "gomuks"]
path = gomuks path = gomuks
url = https://github.com/Henry-Hiles/gomuks url = https://github.com/gomuks/gomuks
branch = quad/feat/customizable-device-name

2
gomuks

@ -1 +1 @@
Subproject commit ae11daa1b14b103688e57accb9c65ad6401cb3ef Subproject commit b11eedca121a7081d3ee48165ba363e722d18d87

View file

@ -20,6 +20,7 @@ import "package:nexus/main.dart";
import "package:nexus/models/capabilities.dart"; import "package:nexus/models/capabilities.dart";
import "package:nexus/models/content/message.dart"; import "package:nexus/models/content/message.dart";
import "package:nexus/models/event.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/oauth_auth_code_response.dart";
import "package:nexus/models/open_graph_data.dart"; import "package:nexus/models/open_graph_data.dart";
import "package:nexus/models/paginate.dart"; import "package:nexus/models/paginate.dart";
@ -70,14 +71,17 @@ class ClientController extends AsyncNotifier<int> {
} }
} }
final handle = await Isolate.run(() { final handle = await Isolate.run(() {
final message = final bufferPointer = GomuksConfig(
"Nexus on ${toBeginningOfSentenceCase(Platform.operatingSystem)}" matrix: .new(
.toNativeUtf8() initialDeviceDisplayName:
.cast<Char>(); "Nexus on ${toBeginningOfSentenceCase(Platform.operatingSystem)}",
),
).toJson().toGomuksBufferPtr();
try { try {
return GomuksInit(message); return GomuksInit(bufferPointer.ref);
} finally { } finally {
calloc.free(message); calloc.free(bufferPointer);
} }
}); });

View 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);
}