Skip to content

Commit

Permalink
Merge branch 'rustdesk:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbo8418 authored Jun 30, 2024
2 parents 307a630 + 7631746 commit 430ea6a
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 60 deletions.
2 changes: 1 addition & 1 deletion flutter/lib/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ Future<void> initGlobalFFI() async {
_globalFFI = FFI(null);
debugPrint("_globalFFI init end");
// after `put`, can also be globally found by Get.find<FFI>();
Get.put(_globalFFI, permanent: true);
Get.put<FFI>(_globalFFI, permanent: true);
}

String translate(String name) {
Expand Down
104 changes: 52 additions & 52 deletions flutter/lib/common/shared_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ class PrivacyModeState {

static void init(String id) {
final key = tag(id);
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<RxString>(tag: key)) {
final RxString state = ''.obs;
Get.put(state, tag: key);
Get.put<RxString>(state, tag: key);
}
}

static void delete(String id) {
final key = tag(id);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<RxString>(tag: key)) {
Get.delete<RxString>(tag: key);
} else {
Get.find<RxString>(tag: key).value = '';
}
Expand All @@ -33,18 +33,18 @@ class BlockInputState {

static void init(String id) {
final key = tag(id);
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<RxBool>(tag: key)) {
final RxBool state = false.obs;
Get.put(state, tag: key);
Get.put<RxBool>(state, tag: key);
} else {
Get.find<RxBool>(tag: key).value = false;
}
}

static void delete(String id) {
final key = tag(id);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<RxBool>(tag: key)) {
Get.delete<RxBool>(tag: key);
}
}

Expand All @@ -56,18 +56,18 @@ class CurrentDisplayState {

static void init(String id) {
final key = tag(id);
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<RxInt>(tag: key)) {
final RxInt state = RxInt(0);
Get.put(state, tag: key);
Get.put<RxInt>(state, tag: key);
} else {
Get.find<RxInt>(tag: key).value = 0;
}
}

static void delete(String id) {
final key = tag(id);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<RxInt>(tag: key)) {
Get.delete<RxInt>(tag: key);
}
}

Expand Down Expand Up @@ -105,16 +105,16 @@ class ConnectionTypeState {

static void init(String id) {
final key = tag(id);
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<ConnectionType>(tag: key)) {
final ConnectionType collectionType = ConnectionType();
Get.put(collectionType, tag: key);
Get.put<ConnectionType>(collectionType, tag: key);
}
}

static void delete(String id) {
final key = tag(id);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<ConnectionType>(tag: key)) {
Get.delete<ConnectionType>(tag: key);
}
}

Expand All @@ -127,18 +127,18 @@ class FingerprintState {

static void init(String id) {
final key = tag(id);
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<RxString>(tag: key)) {
final RxString state = ''.obs;
Get.put(state, tag: key);
Get.put<RxString>(state, tag: key);
} else {
Get.find<RxString>(tag: key).value = '';
}
}

static void delete(String id) {
final key = tag(id);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<RxString>(tag: key)) {
Get.delete<RxString>(tag: key);
}
}

Expand All @@ -150,18 +150,18 @@ class ShowRemoteCursorState {

static void init(String id) {
final key = tag(id);
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<RxBool>(tag: key)) {
final RxBool state = false.obs;
Get.put(state, tag: key);
Get.put<RxBool>(state, tag: key);
} else {
Get.find<RxBool>(tag: key).value = false;
}
}

static void delete(String id) {
final key = tag(id);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<RxBool>(tag: key)) {
Get.delete<RxBool>(tag: key);
}
}

Expand All @@ -173,18 +173,18 @@ class ShowRemoteCursorLockState {

static void init(String id) {
final key = tag(id);
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<RxBool>(tag: key)) {
final RxBool state = false.obs;
Get.put(state, tag: key);
Get.put<RxBool>(state, tag: key);
} else {
Get.find<RxBool>(tag: key).value = false;
}
}

static void delete(String id) {
final key = tag(id);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<RxBool>(tag: key)) {
Get.delete<RxBool>(tag: key);
}
}

Expand All @@ -196,19 +196,19 @@ class KeyboardEnabledState {

static void init(String id) {
final key = tag(id);
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<RxBool>(tag: key)) {
// Server side, default true
final RxBool state = true.obs;
Get.put(state, tag: key);
Get.put<RxBool>(state, tag: key);
} else {
Get.find<RxBool>(tag: key).value = true;
}
}

static void delete(String id) {
final key = tag(id);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<RxBool>(tag: key)) {
Get.delete<RxBool>(tag: key);
}
}

Expand All @@ -220,18 +220,18 @@ class RemoteCursorMovedState {

static void init(String id) {
final key = tag(id);
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<RxBool>(tag: key)) {
final RxBool state = false.obs;
Get.put(state, tag: key);
Get.put<RxBool>(state, tag: key);
} else {
Get.find<RxBool>(tag: key).value = false;
}
}

static void delete(String id) {
final key = tag(id);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<RxBool>(tag: key)) {
Get.delete<RxBool>(tag: key);
}
}

Expand All @@ -243,18 +243,18 @@ class RemoteCountState {

static void init() {
final key = tag();
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<RxInt>(tag: key)) {
final RxInt state = 1.obs;
Get.put(state, tag: key);
Get.put<RxInt>(state, tag: key);
} else {
Get.find<RxInt>(tag: key).value = 1;
}
}

static void delete() {
final key = tag();
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<RxInt>(tag: key)) {
Get.delete<RxInt>(tag: key);
}
}

Expand All @@ -266,18 +266,18 @@ class PeerBoolOption {

static void init(String id, String opt, bool Function() init_getter) {
final key = tag(id, opt);
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<RxBool>(tag: key)) {
final RxBool value = RxBool(init_getter());
Get.put(value, tag: key);
Get.put<RxBool>(value, tag: key);
} else {
Get.find<RxBool>(tag: key).value = init_getter();
}
}

static void delete(String id, String opt) {
final key = tag(id, opt);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<RxBool>(tag: key)) {
Get.delete<RxBool>(tag: key);
}
}

Expand All @@ -290,18 +290,18 @@ class PeerStringOption {

static void init(String id, String opt, String Function() init_getter) {
final key = tag(id, opt);
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<RxString>(tag: key)) {
final RxString value = RxString(init_getter());
Get.put(value, tag: key);
Get.put<RxString>(value, tag: key);
} else {
Get.find<RxString>(tag: key).value = init_getter();
}
}

static void delete(String id, String opt) {
final key = tag(id, opt);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<RxString>(tag: key)) {
Get.delete<RxString>(tag: key);
}
}

Expand All @@ -314,18 +314,18 @@ class UnreadChatCountState {

static void init(String id) {
final key = tag(id);
if (!Get.isRegistered(tag: key)) {
if (!Get.isRegistered<RxInt>(tag: key)) {
final RxInt state = RxInt(0);
Get.put(state, tag: key);
Get.put<RxInt>(state, tag: key);
} else {
Get.find<RxInt>(tag: key).value = 0;
}
}

static void delete(String id) {
final key = tag(id);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
if (Get.isRegistered<RxInt>(tag: key)) {
Get.delete<RxInt>(tag: key);
}
}

Expand Down
6 changes: 4 additions & 2 deletions flutter/lib/desktop/pages/desktop_setting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ class DesktopSettingPage extends StatefulWidget {
}
if (Get.isRegistered<PageController>(tag: _kSettingPageControllerTag)) {
DesktopTabPage.onAddSetting(initialPage: page);
PageController controller = Get.find(tag: _kSettingPageControllerTag);
Rx<SettingsTabKey> selected = Get.find(tag: _kSettingPageTabKeyTag);
PageController controller =
Get.find<PageController>(tag: _kSettingPageControllerTag);
Rx<SettingsTabKey> selected =
Get.find<Rx<SettingsTabKey>>(tag: _kSettingPageTabKeyTag);
selected.value = page;
controller.jumpToPage(index);
} else {
Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/desktop/pages/desktop_tab_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DesktopTabPage extends StatefulWidget {
static void onAddSetting(
{SettingsTabKey initialPage = SettingsTabKey.general}) {
try {
DesktopTabController tabController = Get.find();
DesktopTabController tabController = Get.find<DesktopTabController>();
tabController.add(TabInfo(
key: kTabLabelSettingPage,
label: kTabLabelSettingPage,
Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/desktop/pages/file_manager_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class _FileManagerPageState extends State<FileManagerPage>
_ffi.dialogManager
.showLoading(translate('Connecting...'), onCancel: closeConnection);
});
Get.put(_ffi, tag: 'ft_${widget.id}');
Get.put<FFI>(_ffi, tag: 'ft_${widget.id}');
if (!isLinux) {
WakelockPlus.enable();
}
Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/desktop/pages/port_forward_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class _PortForwardPageState extends State<PortForwardPage>
isSharedPassword: widget.isSharedPassword,
forceRelay: widget.forceRelay,
isRdp: widget.isRDP);
Get.put(_ffi, tag: 'pf_${widget.id}');
Get.put<FFI>(_ffi, tag: 'pf_${widget.id}');
debugPrint("Port forward page init success with id ${widget.id}");
widget.tabController.onSelected?.call(widget.id);
}
Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/desktop/pages/remote_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class _RemotePageState extends State<RemotePage>
super.initState();
_initStates(widget.id);
_ffi = FFI(widget.sessionId);
Get.put(_ffi, tag: widget.id);
Get.put<FFI>(_ffi, tag: widget.id);
_ffi.imageModel.addCallbackOnFirstImage((String peerId) {
showKBLayoutTypeChooserIfNeeded(
_ffi.ffiModel.pi.platform, _ffi.dialogManager);
Expand Down
2 changes: 1 addition & 1 deletion flutter/lib/desktop/pages/server_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class _DesktopServerPageState extends State<DesktopServerPage>
void initState() {
gFFI.ffiModel.updateEventListener(gFFI.sessionId, "");
windowManager.addListener(this);
Get.put(tabController);
Get.put<DesktopTabController>(tabController);
tabController.onRemoved = (_, id) {
onRemoveId(id);
};
Expand Down

0 comments on commit 430ea6a

Please sign in to comment.