feat: Change App Name, add rust/set_foreground_window

This commit is contained in:
2024-04-28 21:50:36 +08:00
parent e9c494096f
commit c5549cf4c8
9 changed files with 160 additions and 39 deletions

View File

@ -23,6 +23,10 @@ Stream<RsProcessStreamData> start(
Future<void> write({required int rsPid, required String data, dynamic hint}) =>
RustLib.instance.api.write(rsPid: rsPid, data: data, hint: hint);
Future<bool> setForegroundWindow({required String windowName, dynamic hint}) =>
RustLib.instance.api
.setForegroundWindow(windowName: windowName, hint: hint);
class RsProcessStreamData {
final RsProcessStreamDataType dataType;
final String data;

View File

@ -57,7 +57,7 @@ class RustLib extends BaseEntrypoint<RustLibApi, RustLibApiImpl, RustLibWire> {
String get codegenVersion => '2.0.0-dev.32';
@override
int get rustContentHash => 1067953400;
int get rustContentHash => -1186168522;
static const kDefaultExternalLibraryLoaderConfig =
ExternalLibraryLoaderConfig(
@ -90,6 +90,8 @@ abstract class RustLibApi extends BaseApi {
String? appId,
dynamic hint});
Future<bool> setForegroundWindow({required String windowName, dynamic hint});
Stream<RsProcessStreamData> start(
{required String executable,
required List<String> arguments,
@ -241,6 +243,29 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
argNames: ["summary", "body", "appName", "appId"],
);
@override
Future<bool> setForegroundWindow({required String windowName, dynamic hint}) {
return handler.executeNormal(NormalTask(
callFfi: (port_) {
var arg0 = cst_encode_String(windowName);
return wire.wire_set_foreground_window(port_, arg0);
},
codec: DcoCodec(
decodeSuccessData: dco_decode_bool,
decodeErrorData: dco_decode_AnyhowException,
),
constMeta: kSetForegroundWindowConstMeta,
argValues: [windowName],
apiImpl: this,
hint: hint,
));
}
TaskConstMeta get kSetForegroundWindowConstMeta => const TaskConstMeta(
debugName: "set_foreground_window",
argNames: ["windowName"],
);
@override
Stream<RsProcessStreamData> start(
{required String executable,
@ -323,6 +348,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return raw as String;
}
@protected
bool dco_decode_bool(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return raw as bool;
}
@protected
int dco_decode_box_autoadd_u_64(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
@ -498,6 +529,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return utf8.decoder.convert(inner);
}
@protected
bool sse_decode_bool(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return deserializer.buffer.getUint8() != 0;
}
@protected
int sse_decode_box_autoadd_u_64(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
@ -679,9 +716,9 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
}
@protected
bool sse_decode_bool(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
return deserializer.buffer.getUint8() != 0;
bool cst_encode_bool(bool raw) {
// Codec=Cst (C-struct based), see doc to use other codecs
return raw;
}
@protected
@ -765,6 +802,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
sse_encode_list_prim_u_8_strict(utf8.encoder.convert(self), serializer);
}
@protected
void sse_encode_bool(bool self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
serializer.buffer.putUint8(self ? 1 : 0);
}
@protected
void sse_encode_box_autoadd_u_64(int self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
@ -924,10 +967,4 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
void sse_encode_unit(void self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
}
@protected
void sse_encode_bool(bool self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
serializer.buffer.putUint8(self ? 1 : 0);
}
}

View File

@ -34,6 +34,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected
String dco_decode_String(dynamic raw);
@protected
bool dco_decode_bool(dynamic raw);
@protected
int dco_decode_box_autoadd_u_64(dynamic raw);
@ -109,6 +112,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected
String sse_decode_String(SseDeserializer deserializer);
@protected
bool sse_decode_bool(SseDeserializer deserializer);
@protected
int sse_decode_box_autoadd_u_64(SseDeserializer deserializer);
@ -174,9 +180,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected
void sse_decode_unit(SseDeserializer deserializer);
@protected
bool sse_decode_bool(SseDeserializer deserializer);
@protected
ffi.Pointer<wire_cst_list_prim_u_8_strict> cst_encode_AnyhowException(
AnyhowException raw) {
@ -306,6 +309,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
wireObj.data = cst_encode_opt_list_prim_u_8_strict(apiObj.data);
}
@protected
bool cst_encode_bool(bool raw);
@protected
int cst_encode_i_32(int raw);
@ -345,6 +351,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected
void sse_encode_String(String self, SseSerializer serializer);
@protected
void sse_encode_bool(bool self, SseSerializer serializer);
@protected
void sse_encode_box_autoadd_u_64(int self, SseSerializer serializer);
@ -412,9 +421,6 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected
void sse_encode_unit(void self, SseSerializer serializer);
@protected
void sse_encode_bool(bool self, SseSerializer serializer);
}
// Section: wire_class
@ -582,6 +588,25 @@ class RustLibWire implements BaseWire {
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
void wire_set_foreground_window(
int port_,
ffi.Pointer<wire_cst_list_prim_u_8_strict> window_name,
) {
return _wire_set_foreground_window(
port_,
window_name,
);
}
late final _wire_set_foreground_windowPtr = _lookup<
ffi.NativeFunction<
ffi.Void Function(
ffi.Int64, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>>(
'frbgen_starcitizen_doctor_wire_set_foreground_window');
late final _wire_set_foreground_window =
_wire_set_foreground_windowPtr.asFunction<
void Function(int, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
void wire_start(
int port_,
ffi.Pointer<wire_cst_list_prim_u_8_strict> executable,