mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-22 19:53:43 +08:00
update: rust/ rename to win32_api.rs
fix: setForegroundWindow
This commit is contained in:
parent
288df33b39
commit
3dbf993099
@ -23,7 +23,7 @@ import 'api/api.dart';
|
|||||||
import 'common/helper/system_helper.dart';
|
import 'common/helper/system_helper.dart';
|
||||||
import 'common/io/rs_http.dart';
|
import 'common/io/rs_http.dart';
|
||||||
import 'common/rust/frb_generated.dart';
|
import 'common/rust/frb_generated.dart';
|
||||||
import 'common/rust/api/rs_process.dart' as rs_process;
|
import 'common/rust/api/win32_api.dart' as win32;
|
||||||
import 'data/app_version_data.dart';
|
import 'data/app_version_data.dart';
|
||||||
import 'generated/no_l10n_strings.dart';
|
import 'generated/no_l10n_strings.dart';
|
||||||
import 'ui/home/downloader/home_downloader_ui.dart';
|
import 'ui/home/downloader/home_downloader_ui.dart';
|
||||||
@ -158,7 +158,7 @@ class AppGlobalModel extends _$AppGlobalModel {
|
|||||||
}
|
}
|
||||||
state = state.copyWith(deviceUUID: deviceUUID, appLocale: locale);
|
state = state.copyWith(deviceUUID: deviceUUID, appLocale: locale);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await rs_process.setForegroundWindow(windowName: "SCToolBox");
|
await win32.setForegroundWindow(windowName: "SCToolBox");
|
||||||
dPrint("exit: db is locking ...");
|
dPrint("exit: db is locking ...");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -183,6 +183,7 @@ class AppGlobalModel extends _$AppGlobalModel {
|
|||||||
// init windows
|
// init windows
|
||||||
|
|
||||||
windowManager.waitUntilReadyToShow().then((_) async {
|
windowManager.waitUntilReadyToShow().then((_) async {
|
||||||
|
await windowManager.setTitle("SCToolBox");
|
||||||
await windowManager.setSize(const Size(1280, 810));
|
await windowManager.setSize(const Size(1280, 810));
|
||||||
await windowManager.setMinimumSize(const Size(1280, 810));
|
await windowManager.setMinimumSize(const Size(1280, 810));
|
||||||
await windowManager.setSkipTaskbar(false);
|
await windowManager.setSkipTaskbar(false);
|
||||||
|
@ -23,10 +23,6 @@ Stream<RsProcessStreamData> start(
|
|||||||
Future<void> write({required int rsPid, required String data, dynamic hint}) =>
|
Future<void> write({required int rsPid, required String data, dynamic hint}) =>
|
||||||
RustLib.instance.api.write(rsPid: rsPid, data: data, hint: 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 {
|
class RsProcessStreamData {
|
||||||
final RsProcessStreamDataType dataType;
|
final RsProcessStreamDataType dataType;
|
||||||
final String data;
|
final String data;
|
||||||
|
@ -18,3 +18,7 @@ Future<void> sendNotify(
|
|||||||
appName: appName,
|
appName: appName,
|
||||||
appId: appId,
|
appId: appId,
|
||||||
hint: hint);
|
hint: hint);
|
||||||
|
|
||||||
|
Future<bool> setForegroundWindow({required String windowName, dynamic hint}) =>
|
||||||
|
RustLib.instance.api
|
||||||
|
.setForegroundWindow(windowName: windowName, hint: hint);
|
@ -4,8 +4,8 @@
|
|||||||
// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field
|
// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field
|
||||||
|
|
||||||
import 'api/http_api.dart';
|
import 'api/http_api.dart';
|
||||||
import 'api/notify_api.dart';
|
|
||||||
import 'api/rs_process.dart';
|
import 'api/rs_process.dart';
|
||||||
|
import 'api/win32_api.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'frb_generated.io.dart' if (dart.library.html) 'frb_generated.web.dart';
|
import 'frb_generated.io.dart' if (dart.library.html) 'frb_generated.web.dart';
|
||||||
@ -57,7 +57,7 @@ class RustLib extends BaseEntrypoint<RustLibApi, RustLibApiImpl, RustLibWire> {
|
|||||||
String get codegenVersion => '2.0.0-dev.32';
|
String get codegenVersion => '2.0.0-dev.32';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get rustContentHash => -1186168522;
|
int get rustContentHash => 1453545208;
|
||||||
|
|
||||||
static const kDefaultExternalLibraryLoaderConfig =
|
static const kDefaultExternalLibraryLoaderConfig =
|
||||||
ExternalLibraryLoaderConfig(
|
ExternalLibraryLoaderConfig(
|
||||||
@ -83,6 +83,14 @@ abstract class RustLibApi extends BaseApi {
|
|||||||
Future<void> setDefaultHeader(
|
Future<void> setDefaultHeader(
|
||||||
{required Map<String, String> headers, dynamic hint});
|
{required Map<String, String> headers, dynamic hint});
|
||||||
|
|
||||||
|
Stream<RsProcessStreamData> start(
|
||||||
|
{required String executable,
|
||||||
|
required List<String> arguments,
|
||||||
|
required String workingDirectory,
|
||||||
|
dynamic hint});
|
||||||
|
|
||||||
|
Future<void> write({required int rsPid, required String data, dynamic hint});
|
||||||
|
|
||||||
Future<void> sendNotify(
|
Future<void> sendNotify(
|
||||||
{String? summary,
|
{String? summary,
|
||||||
String? body,
|
String? body,
|
||||||
@ -91,14 +99,6 @@ abstract class RustLibApi extends BaseApi {
|
|||||||
dynamic hint});
|
dynamic hint});
|
||||||
|
|
||||||
Future<bool> setForegroundWindow({required String windowName, dynamic hint});
|
Future<bool> setForegroundWindow({required String windowName, dynamic hint});
|
||||||
|
|
||||||
Stream<RsProcessStreamData> start(
|
|
||||||
{required String executable,
|
|
||||||
required List<String> arguments,
|
|
||||||
required String workingDirectory,
|
|
||||||
dynamic hint});
|
|
||||||
|
|
||||||
Future<void> write({required int rsPid, required String data, dynamic hint});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
||||||
@ -212,60 +212,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
argNames: ["headers"],
|
argNames: ["headers"],
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> sendNotify(
|
|
||||||
{String? summary,
|
|
||||||
String? body,
|
|
||||||
String? appName,
|
|
||||||
String? appId,
|
|
||||||
dynamic hint}) {
|
|
||||||
return handler.executeNormal(NormalTask(
|
|
||||||
callFfi: (port_) {
|
|
||||||
var arg0 = cst_encode_opt_String(summary);
|
|
||||||
var arg1 = cst_encode_opt_String(body);
|
|
||||||
var arg2 = cst_encode_opt_String(appName);
|
|
||||||
var arg3 = cst_encode_opt_String(appId);
|
|
||||||
return wire.wire_send_notify(port_, arg0, arg1, arg2, arg3);
|
|
||||||
},
|
|
||||||
codec: DcoCodec(
|
|
||||||
decodeSuccessData: dco_decode_unit,
|
|
||||||
decodeErrorData: dco_decode_AnyhowException,
|
|
||||||
),
|
|
||||||
constMeta: kSendNotifyConstMeta,
|
|
||||||
argValues: [summary, body, appName, appId],
|
|
||||||
apiImpl: this,
|
|
||||||
hint: hint,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskConstMeta get kSendNotifyConstMeta => const TaskConstMeta(
|
|
||||||
debugName: "send_notify",
|
|
||||||
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
|
@override
|
||||||
Stream<RsProcessStreamData> start(
|
Stream<RsProcessStreamData> start(
|
||||||
{required String executable,
|
{required String executable,
|
||||||
@ -322,6 +268,60 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
argNames: ["rsPid", "data"],
|
argNames: ["rsPid", "data"],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> sendNotify(
|
||||||
|
{String? summary,
|
||||||
|
String? body,
|
||||||
|
String? appName,
|
||||||
|
String? appId,
|
||||||
|
dynamic hint}) {
|
||||||
|
return handler.executeNormal(NormalTask(
|
||||||
|
callFfi: (port_) {
|
||||||
|
var arg0 = cst_encode_opt_String(summary);
|
||||||
|
var arg1 = cst_encode_opt_String(body);
|
||||||
|
var arg2 = cst_encode_opt_String(appName);
|
||||||
|
var arg3 = cst_encode_opt_String(appId);
|
||||||
|
return wire.wire_send_notify(port_, arg0, arg1, arg2, arg3);
|
||||||
|
},
|
||||||
|
codec: DcoCodec(
|
||||||
|
decodeSuccessData: dco_decode_unit,
|
||||||
|
decodeErrorData: dco_decode_AnyhowException,
|
||||||
|
),
|
||||||
|
constMeta: kSendNotifyConstMeta,
|
||||||
|
argValues: [summary, body, appName, appId],
|
||||||
|
apiImpl: this,
|
||||||
|
hint: hint,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskConstMeta get kSendNotifyConstMeta => const TaskConstMeta(
|
||||||
|
debugName: "send_notify",
|
||||||
|
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"],
|
||||||
|
);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
AnyhowException dco_decode_AnyhowException(dynamic raw) {
|
AnyhowException dco_decode_AnyhowException(dynamic raw) {
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field
|
// ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field
|
||||||
|
|
||||||
import 'api/http_api.dart';
|
import 'api/http_api.dart';
|
||||||
import 'api/notify_api.dart';
|
|
||||||
import 'api/rs_process.dart';
|
import 'api/rs_process.dart';
|
||||||
|
import 'api/win32_api.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:ffi' as ffi;
|
import 'dart:ffi' as ffi;
|
||||||
@ -555,58 +555,6 @@ class RustLibWire implements BaseWire {
|
|||||||
late final _wire_set_default_header = _wire_set_default_headerPtr.asFunction<
|
late final _wire_set_default_header = _wire_set_default_headerPtr.asFunction<
|
||||||
void Function(int, ffi.Pointer<wire_cst_list_record_string_string>)>();
|
void Function(int, ffi.Pointer<wire_cst_list_record_string_string>)>();
|
||||||
|
|
||||||
void wire_send_notify(
|
|
||||||
int port_,
|
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> summary,
|
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> body,
|
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> app_name,
|
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> app_id,
|
|
||||||
) {
|
|
||||||
return _wire_send_notify(
|
|
||||||
port_,
|
|
||||||
summary,
|
|
||||||
body,
|
|
||||||
app_name,
|
|
||||||
app_id,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
late final _wire_send_notifyPtr = _lookup<
|
|
||||||
ffi.NativeFunction<
|
|
||||||
ffi.Void Function(
|
|
||||||
ffi.Int64,
|
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>)>>(
|
|
||||||
'frbgen_starcitizen_doctor_wire_send_notify');
|
|
||||||
late final _wire_send_notify = _wire_send_notifyPtr.asFunction<
|
|
||||||
void Function(
|
|
||||||
int,
|
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
|
||||||
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(
|
void wire_start(
|
||||||
int port_,
|
int port_,
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> executable,
|
ffi.Pointer<wire_cst_list_prim_u_8_strict> executable,
|
||||||
@ -660,6 +608,58 @@ class RustLibWire implements BaseWire {
|
|||||||
late final _wire_write = _wire_writePtr.asFunction<
|
late final _wire_write = _wire_writePtr.asFunction<
|
||||||
void Function(int, int, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
|
void Function(int, int, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
|
||||||
|
|
||||||
|
void wire_send_notify(
|
||||||
|
int port_,
|
||||||
|
ffi.Pointer<wire_cst_list_prim_u_8_strict> summary,
|
||||||
|
ffi.Pointer<wire_cst_list_prim_u_8_strict> body,
|
||||||
|
ffi.Pointer<wire_cst_list_prim_u_8_strict> app_name,
|
||||||
|
ffi.Pointer<wire_cst_list_prim_u_8_strict> app_id,
|
||||||
|
) {
|
||||||
|
return _wire_send_notify(
|
||||||
|
port_,
|
||||||
|
summary,
|
||||||
|
body,
|
||||||
|
app_name,
|
||||||
|
app_id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
late final _wire_send_notifyPtr = _lookup<
|
||||||
|
ffi.NativeFunction<
|
||||||
|
ffi.Void Function(
|
||||||
|
ffi.Int64,
|
||||||
|
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
||||||
|
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
||||||
|
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
||||||
|
ffi.Pointer<wire_cst_list_prim_u_8_strict>)>>(
|
||||||
|
'frbgen_starcitizen_doctor_wire_send_notify');
|
||||||
|
late final _wire_send_notify = _wire_send_notifyPtr.asFunction<
|
||||||
|
void Function(
|
||||||
|
int,
|
||||||
|
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
||||||
|
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
||||||
|
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>)>();
|
||||||
|
|
||||||
ffi.Pointer<ffi.Uint64> cst_new_box_autoadd_u_64(
|
ffi.Pointer<ffi.Uint64> cst_new_box_autoadd_u_64(
|
||||||
int value,
|
int value,
|
||||||
) {
|
) {
|
||||||
|
@ -16,8 +16,7 @@ import 'package:starcitizen_doctor/common/conf/url_conf.dart';
|
|||||||
import 'package:starcitizen_doctor/common/helper/log_helper.dart';
|
import 'package:starcitizen_doctor/common/helper/log_helper.dart';
|
||||||
import 'package:starcitizen_doctor/common/helper/system_helper.dart';
|
import 'package:starcitizen_doctor/common/helper/system_helper.dart';
|
||||||
import 'package:starcitizen_doctor/common/io/rs_http.dart';
|
import 'package:starcitizen_doctor/common/io/rs_http.dart';
|
||||||
import 'package:starcitizen_doctor/common/rust/api/notify_api.dart'
|
import 'package:starcitizen_doctor/common/rust/api/win32_api.dart' as win32;
|
||||||
as notify_api;
|
|
||||||
import 'package:starcitizen_doctor/common/utils/async.dart';
|
import 'package:starcitizen_doctor/common/utils/async.dart';
|
||||||
import 'package:starcitizen_doctor/common/utils/base_utils.dart';
|
import 'package:starcitizen_doctor/common/utils/base_utils.dart';
|
||||||
import 'package:starcitizen_doctor/common/utils/log.dart';
|
import 'package:starcitizen_doctor/common/utils/log.dart';
|
||||||
@ -291,7 +290,7 @@ class HomeUIModel extends _$HomeUIModel {
|
|||||||
_appUpdateTimer?.cancel();
|
_appUpdateTimer?.cancel();
|
||||||
_appUpdateTimer = null;
|
_appUpdateTimer = null;
|
||||||
// 发送通知
|
// 发送通知
|
||||||
await notify_api.sendNotify(
|
await win32.sendNotify(
|
||||||
summary: S.current.home_localization_new_version_available,
|
summary: S.current.home_localization_new_version_available,
|
||||||
body:
|
body:
|
||||||
S.current.home_localization_new_version_installed(updates.first),
|
S.current.home_localization_new_version_installed(updates.first),
|
||||||
|
@ -4,4 +4,4 @@
|
|||||||
pub mod http_api;
|
pub mod http_api;
|
||||||
|
|
||||||
pub mod rs_process;
|
pub mod rs_process;
|
||||||
pub mod notify_api;
|
pub mod win32_api;
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
use notify_rust::Notification;
|
|
||||||
|
|
||||||
pub fn send_notify(summary: Option<String>, body: Option<String>, app_name: Option<String>, app_id: Option<String>) -> anyhow::Result<()> {
|
|
||||||
let mut n = Notification::new();
|
|
||||||
if let Some(summary) = summary {
|
|
||||||
n.summary(&summary);
|
|
||||||
}
|
|
||||||
if let Some(body) = body {
|
|
||||||
n.body(&body);
|
|
||||||
}
|
|
||||||
if let Some(app_name) = app_name {
|
|
||||||
n.appname(&app_name);
|
|
||||||
}
|
|
||||||
if let Some(app_id) = app_id {
|
|
||||||
n.app_id(&app_id);
|
|
||||||
}
|
|
||||||
n.show()?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
@ -9,9 +9,6 @@ use tokio::io::AsyncWriteExt;
|
|||||||
use tokio::io::BufReader;
|
use tokio::io::BufReader;
|
||||||
use tokio::process::ChildStdin;
|
use tokio::process::ChildStdin;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use windows::core::{HSTRING, PCWSTR};
|
|
||||||
use windows::Win32::Foundation::HWND;
|
|
||||||
use windows::Win32::UI::WindowsAndMessaging;
|
|
||||||
|
|
||||||
use crate::frb_generated::StreamSink;
|
use crate::frb_generated::StreamSink;
|
||||||
|
|
||||||
@ -163,18 +160,4 @@ async fn _process_output<R>(
|
|||||||
};
|
};
|
||||||
stream_sink.add(message).unwrap();
|
stream_sink.add(message).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_foreground_window(window_name: &str) -> anyhow::Result<bool> {
|
|
||||||
let window_name_p: PCWSTR = PCWSTR(HSTRING::from(window_name).as_ptr());
|
|
||||||
let h = unsafe { WindowsAndMessaging::FindWindowW(PCWSTR::null(), window_name_p) };
|
|
||||||
if h == HWND::default() {
|
|
||||||
return Ok(false);
|
|
||||||
}
|
|
||||||
let sr = unsafe { WindowsAndMessaging::ShowWindow(h, WindowsAndMessaging::SW_RESTORE) };
|
|
||||||
if !sr.as_bool() {
|
|
||||||
return Ok(false);
|
|
||||||
}
|
|
||||||
let r = unsafe { WindowsAndMessaging::SetForegroundWindow(h) };
|
|
||||||
Ok(r.as_bool())
|
|
||||||
}
|
|
36
rust/src/api/win32_api.rs
Normal file
36
rust/src/api/win32_api.rs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
use notify_rust::Notification;
|
||||||
|
use windows::core::{HSTRING, PCWSTR};
|
||||||
|
use windows::Win32::Foundation::HWND;
|
||||||
|
use windows::Win32::UI::WindowsAndMessaging;
|
||||||
|
|
||||||
|
pub fn send_notify(summary: Option<String>, body: Option<String>, app_name: Option<String>, app_id: Option<String>) -> anyhow::Result<()> {
|
||||||
|
let mut n = Notification::new();
|
||||||
|
if let Some(summary) = summary {
|
||||||
|
n.summary(&summary);
|
||||||
|
}
|
||||||
|
if let Some(body) = body {
|
||||||
|
n.body(&body);
|
||||||
|
}
|
||||||
|
if let Some(app_name) = app_name {
|
||||||
|
n.appname(&app_name);
|
||||||
|
}
|
||||||
|
if let Some(app_id) = app_id {
|
||||||
|
n.app_id(&app_id);
|
||||||
|
}
|
||||||
|
n.show()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_foreground_window(window_name: &str) -> anyhow::Result<bool> {
|
||||||
|
let window_name_p: PCWSTR = PCWSTR(HSTRING::from(window_name).as_ptr());
|
||||||
|
let h = unsafe { WindowsAndMessaging::FindWindowW(PCWSTR::null(), window_name_p) };
|
||||||
|
if h == HWND::default() {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
let sr = unsafe { WindowsAndMessaging::ShowWindow(h, WindowsAndMessaging::SW_RESTORE) };
|
||||||
|
if !sr.as_bool() {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
let r = unsafe { WindowsAndMessaging::SetForegroundWindow(h) };
|
||||||
|
Ok(r.as_bool())
|
||||||
|
}
|
@ -204,25 +204,6 @@ pub extern "C" fn frbgen_starcitizen_doctor_wire_set_default_header(
|
|||||||
wire_set_default_header_impl(port_, headers)
|
wire_set_default_header_impl(port_, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn frbgen_starcitizen_doctor_wire_send_notify(
|
|
||||||
port_: i64,
|
|
||||||
summary: *mut wire_cst_list_prim_u_8_strict,
|
|
||||||
body: *mut wire_cst_list_prim_u_8_strict,
|
|
||||||
app_name: *mut wire_cst_list_prim_u_8_strict,
|
|
||||||
app_id: *mut wire_cst_list_prim_u_8_strict,
|
|
||||||
) {
|
|
||||||
wire_send_notify_impl(port_, summary, body, app_name, app_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn frbgen_starcitizen_doctor_wire_set_foreground_window(
|
|
||||||
port_: i64,
|
|
||||||
window_name: *mut wire_cst_list_prim_u_8_strict,
|
|
||||||
) {
|
|
||||||
wire_set_foreground_window_impl(port_, window_name)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn frbgen_starcitizen_doctor_wire_start(
|
pub extern "C" fn frbgen_starcitizen_doctor_wire_start(
|
||||||
port_: i64,
|
port_: i64,
|
||||||
@ -243,6 +224,25 @@ pub extern "C" fn frbgen_starcitizen_doctor_wire_write(
|
|||||||
wire_write_impl(port_, rs_pid, data)
|
wire_write_impl(port_, rs_pid, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn frbgen_starcitizen_doctor_wire_send_notify(
|
||||||
|
port_: i64,
|
||||||
|
summary: *mut wire_cst_list_prim_u_8_strict,
|
||||||
|
body: *mut wire_cst_list_prim_u_8_strict,
|
||||||
|
app_name: *mut wire_cst_list_prim_u_8_strict,
|
||||||
|
app_id: *mut wire_cst_list_prim_u_8_strict,
|
||||||
|
) {
|
||||||
|
wire_send_notify_impl(port_, summary, body, app_name, app_id)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn frbgen_starcitizen_doctor_wire_set_foreground_window(
|
||||||
|
port_: i64,
|
||||||
|
window_name: *mut wire_cst_list_prim_u_8_strict,
|
||||||
|
) {
|
||||||
|
wire_set_foreground_window_impl(port_, window_name)
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn frbgen_starcitizen_doctor_cst_new_box_autoadd_u_64(value: u64) -> *mut u64 {
|
pub extern "C" fn frbgen_starcitizen_doctor_cst_new_box_autoadd_u_64(value: u64) -> *mut u64 {
|
||||||
flutter_rust_bridge::for_generated::new_leak_box_ptr(value)
|
flutter_rust_bridge::for_generated::new_leak_box_ptr(value)
|
||||||
|
@ -31,7 +31,7 @@ flutter_rust_bridge::frb_generated_boilerplate!(
|
|||||||
default_rust_auto_opaque = RustAutoOpaqueNom,
|
default_rust_auto_opaque = RustAutoOpaqueNom,
|
||||||
);
|
);
|
||||||
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0-dev.32";
|
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0-dev.32";
|
||||||
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -1186168522;
|
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 1453545208;
|
||||||
|
|
||||||
// Section: executor
|
// Section: executor
|
||||||
|
|
||||||
@ -139,57 +139,6 @@ fn wire_set_default_header_impl(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
fn wire_send_notify_impl(
|
|
||||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
|
||||||
summary: impl CstDecode<Option<String>>,
|
|
||||||
body: impl CstDecode<Option<String>>,
|
|
||||||
app_name: impl CstDecode<Option<String>>,
|
|
||||||
app_id: impl CstDecode<Option<String>>,
|
|
||||||
) {
|
|
||||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::DcoCodec, _, _>(
|
|
||||||
flutter_rust_bridge::for_generated::TaskInfo {
|
|
||||||
debug_name: "send_notify",
|
|
||||||
port: Some(port_),
|
|
||||||
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
|
|
||||||
},
|
|
||||||
move || {
|
|
||||||
let api_summary = summary.cst_decode();
|
|
||||||
let api_body = body.cst_decode();
|
|
||||||
let api_app_name = app_name.cst_decode();
|
|
||||||
let api_app_id = app_id.cst_decode();
|
|
||||||
move |context| {
|
|
||||||
transform_result_dco((move || {
|
|
||||||
crate::api::notify_api::send_notify(
|
|
||||||
api_summary,
|
|
||||||
api_body,
|
|
||||||
api_app_name,
|
|
||||||
api_app_id,
|
|
||||||
)
|
|
||||||
})())
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
fn wire_set_foreground_window_impl(
|
|
||||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
|
||||||
window_name: impl CstDecode<String>,
|
|
||||||
) {
|
|
||||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::DcoCodec, _, _>(
|
|
||||||
flutter_rust_bridge::for_generated::TaskInfo {
|
|
||||||
debug_name: "set_foreground_window",
|
|
||||||
port: Some(port_),
|
|
||||||
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
|
|
||||||
},
|
|
||||||
move || {
|
|
||||||
let api_window_name = window_name.cst_decode();
|
|
||||||
move |context| {
|
|
||||||
transform_result_dco((move || {
|
|
||||||
crate::api::rs_process::set_foreground_window(&api_window_name)
|
|
||||||
})())
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
fn wire_start_impl(
|
fn wire_start_impl(
|
||||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||||
executable: impl CstDecode<String>,
|
executable: impl CstDecode<String>,
|
||||||
@ -259,6 +208,57 @@ fn wire_write_impl(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
fn wire_send_notify_impl(
|
||||||
|
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||||
|
summary: impl CstDecode<Option<String>>,
|
||||||
|
body: impl CstDecode<Option<String>>,
|
||||||
|
app_name: impl CstDecode<Option<String>>,
|
||||||
|
app_id: impl CstDecode<Option<String>>,
|
||||||
|
) {
|
||||||
|
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::DcoCodec, _, _>(
|
||||||
|
flutter_rust_bridge::for_generated::TaskInfo {
|
||||||
|
debug_name: "send_notify",
|
||||||
|
port: Some(port_),
|
||||||
|
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
|
||||||
|
},
|
||||||
|
move || {
|
||||||
|
let api_summary = summary.cst_decode();
|
||||||
|
let api_body = body.cst_decode();
|
||||||
|
let api_app_name = app_name.cst_decode();
|
||||||
|
let api_app_id = app_id.cst_decode();
|
||||||
|
move |context| {
|
||||||
|
transform_result_dco((move || {
|
||||||
|
crate::api::win32_api::send_notify(
|
||||||
|
api_summary,
|
||||||
|
api_body,
|
||||||
|
api_app_name,
|
||||||
|
api_app_id,
|
||||||
|
)
|
||||||
|
})())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
fn wire_set_foreground_window_impl(
|
||||||
|
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||||
|
window_name: impl CstDecode<String>,
|
||||||
|
) {
|
||||||
|
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::DcoCodec, _, _>(
|
||||||
|
flutter_rust_bridge::for_generated::TaskInfo {
|
||||||
|
debug_name: "set_foreground_window",
|
||||||
|
port: Some(port_),
|
||||||
|
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
|
||||||
|
},
|
||||||
|
move || {
|
||||||
|
let api_window_name = window_name.cst_decode();
|
||||||
|
move |context| {
|
||||||
|
transform_result_dco((move || {
|
||||||
|
crate::api::win32_api::set_foreground_window(&api_window_name)
|
||||||
|
})())
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Section: dart2rust
|
// Section: dart2rust
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
|||||||
FlutterWindow window(project);
|
FlutterWindow window(project);
|
||||||
Win32Window::Point origin(0, 0);
|
Win32Window::Point origin(0, 0);
|
||||||
Win32Window::Size size(1280, 720);
|
Win32Window::Size size(1280, 720);
|
||||||
if (!window.Create(L"SCToolBox", origin, size)) {
|
if (!window.Create(L"SCToolBox_init", origin, size)) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
window.SetQuitOnClose(true);
|
window.SetQuitOnClose(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user