Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

change ffi flutter_config to flutter_option

dignow7f6b18fc9cfb
diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart
index 328dd4e7a..938be7888 100644
--- a/flutter/lib/common.dart
+++ b/flutter/lib/common.dart
@@ -1422,7 +1422,7 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
debugPrint(
"Saving frame: $windowId: ${pos.width}/${pos.height}, offset:${pos.offsetWidth}/${pos.offsetHeight}");
- await bind.setLocalFlutterConfig(
+ await bind.setLocalFlutterOption(
k: kWindowPrefix + type.name, v: pos.toString());
if (type == WindowType.RemoteDesktop && windowId != null) {
@@ -1436,7 +1436,7 @@ Future _saveSessionWindowPosition(
windowId, kWindowEventGetRemoteList, null);
if (remoteList != null) {
for (final peerId in remoteList.split(',')) {
- bind.mainSetPeerFlutterConfigSync(
+ bind.mainSetPeerFlutterOptionSync(
id: peerId, k: kWindowPrefix + windowType.name, v: pos.toString());
}
}
@@ -1551,15 +1551,15 @@ Future<bool> restoreWindowPosition(WindowType type,
// then we may need to get the position by reading the peer config.
// Because the session may not be read at this time.
if (desktopType == DesktopType.main) {
- pos = bind.mainGetPeerFlutterConfigSync(
+ pos = bind.mainGetPeerFlutterOptionSync(
id: peerId, k: kWindowPrefix + type.name);
} else {
- pos = await bind.sessionGetFlutterConfigByPeerId(
+ pos = await bind.sessionGetFlutterOptionByPeerId(
id: peerId, k: kWindowPrefix + type.name);
}
isRemotePeerPos = pos != null;
}
- pos ??= bind.getLocalFlutterConfig(k: kWindowPrefix + type.name);
+ pos ??= bind.getLocalFlutterOption(k: kWindowPrefix + type.name);
var lpos = LastWindowPosition.loadFromString(pos);
if (lpos == null) {
diff --git a/flutter/lib/common/widgets/peer_tab_page.dart b/flutter/lib/common/widgets/peer_tab_page.dart
index a034ec13d..bf325c920 100644
--- a/flutter/lib/common/widgets/peer_tab_page.dart
+++ b/flutter/lib/common/widgets/peer_tab_page.dart
@@ -64,7 +64,7 @@ class _PeerTabPageState extends State<PeerTabPage>
@override
void initState() {
- final uiType = bind.getLocalFlutterConfig(k: 'peer-card-ui-type');
+ final uiType = bind.getLocalFlutterOption(k: 'peer-card-ui-type');
if (uiType != '') {
peerCardUiType.value = int.parse(uiType) == PeerUiType.list.index
? PeerUiType.list
@@ -174,7 +174,7 @@ class _PeerTabPageState extends State<PeerTabPage>
).paddingSymmetric(horizontal: 4),
onTap: () async {
await handleTabSelection(t);
- await bind.setLocalFlutterConfig(
+ await bind.setLocalFlutterOption(
k: 'peer-tab-index', v: t.toString());
},
onHover: (value) => hover.value = value,
@@ -244,7 +244,7 @@ class _PeerTabPageState extends State<PeerTabPage>
onTap: () async {
final type = types.elementAt(
peerCardUiType.value == types.elementAt(0) ? 1 : 0);
- await bind.setLocalFlutterConfig(
+ await bind.setLocalFlutterOption(
k: 'peer-card-ui-type', v: type.index.toString());
peerCardUiType.value = type;
},
@@ -561,7 +561,7 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
void initState() {
if (!PeerSortType.values.contains(peerSort.value)) {
peerSort.value = PeerSortType.remoteId;
- bind.setLocalFlutterConfig(
+ bind.setLocalFlutterOption(
k: "peer-sorting",
v: peerSort.value,
);
@@ -591,7 +591,7 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
dense: true, (String? v) async {
if (v != null) {
peerSort.value = v;
- await bind.setLocalFlutterConfig(
+ await bind.setLocalFlutterOption(
k: "peer-sorting",
v: peerSort.value,
);
diff --git a/flutter/lib/common/widgets/peers_view.dart b/flutter/lib/common/widgets/peers_view.dart
index e9af1c6e3..5b004b52a 100644
--- a/flutter/lib/common/widgets/peers_view.dart
+++ b/flutter/lib/common/widgets/peers_view.dart
@@ -41,7 +41,7 @@ class LoadEvent {
final peerSearchText = "".obs;
/// for peer sort, global obs value
-final peerSort = bind.getLocalFlutterConfig(k: 'peer-sorting').obs;
+final peerSort = bind.getLocalFlutterOption(k: 'peer-sorting').obs;
// list for listener
final obslist = [peerSearchText, peerSort].obs;
@@ -261,7 +261,7 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
// fallback to id sorting
if (!PeerSortType.values.contains(sortedBy)) {
sortedBy = PeerSortType.remoteId;
- bind.setLocalFlutterConfig(
+ bind.setLocalFlutterOption(
k: "peer-sorting",
v: sortedBy,
);
diff --git a/flutter/lib/desktop/widgets/remote_toolbar.dart b/flutter/lib/desktop/widgets/remote_toolbar.dart
index dcf78b27b..d049804e2 100644
--- a/flutter/lib/desktop/widgets/remote_toolbar.dart
+++ b/flutter/lib/desktop/widgets/remote_toolbar.dart
@@ -36,7 +36,7 @@ class ToolbarState {
late RxBool _pin;
ToolbarState() {
- final s = bind.getLocalFlutterConfig(k: kStoreKey);
+ final s = bind.getLocalFlutterOption(k: kStoreKey);
if (s.isEmpty) {
_initSet(false, false);
return;
@@ -89,7 +89,7 @@ class ToolbarState {
}
_savePin() async {
- bind.setLocalFlutterConfig(
+ bind.setLocalFlutterOption(
k: kStoreKey, v: jsonEncode({'pin': _pin.value}));
}
diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart
index 9c4ff281c..3f546fc22 100644
--- a/flutter/lib/models/model.dart
+++ b/flutter/lib/models/model.dart
@@ -1862,14 +1862,14 @@ Future<void> setCanvasConfig(
p['yCanvas'] = yCanvas;
p['scale'] = scale;
p['currentDisplay'] = currentDisplay;
- await bind.sessionSetFlutterConfig(
+ await bind.sessionSetFlutterOption(
sessionId: sessionId, k: canvasKey, v: jsonEncode(p));
}
Future<Map<String, dynamic>?> getCanvasConfig(SessionID sessionId) async {
if (!isWebDesktop) return null;
var p =
- await bind.sessionGetFlutterConfig(sessionId: sessionId, k: canvasKey);
+ await bind.sessionGetFlutterOption(sessionId: sessionId, k: canvasKey);
if (p == null || p.isEmpty) return null;
try {
Map<String, dynamic> m = json.decode(p);
diff --git a/flutter/lib/models/peer_tab_model.dart b/flutter/lib/models/peer_tab_model.dart
index e7f4192cd..2e65e64bd 100644
--- a/flutter/lib/models/peer_tab_model.dart
+++ b/flutter/lib/models/peer_tab_model.dart
@@ -51,7 +51,7 @@ class PeerTabModel with ChangeNotifier {
PeerTabModel(this.parent) {
// init currentTab
_currentTab =
- int.tryParse(bind.getLocalFlutterConfig(k: 'peer-tab-index')) ?? 0;
+ int.tryParse(bind.getLocalFlutterOption(k: 'peer-tab-index')) ?? 0;
if (_currentTab < 0 || _currentTab >= tabNames.length) {
_currentTab = 0;
}
diff --git a/libs/hbb_common/src/config.rs b/libs/hbb_common/src/config.rs
index 56ffa9a01..c3aa2cfd9 100644
--- a/libs/hbb_common/src/config.rs
+++ b/libs/hbb_common/src/config.rs
@@ -1290,7 +1290,7 @@ impl LocalConfig {
}
}
- pub fn get_flutter_config(k: &str) -> String {
+ pub fn get_flutter_option(k: &str) -> String {
if let Some(v) = LOCAL_CONFIG.read().unwrap().ui_flutter.get(k) {
v.clone()
} else {
@@ -1298,7 +1298,7 @@ impl LocalConfig {
}
}
- pub fn set_flutter_config(k: String, v: String) {
+ pub fn set_flutter_option(k: String, v: String) {
let mut config = LOCAL_CONFIG.write().unwrap();
let v2 = if v.is_empty() { None } else { Some(&v) };
if v2 != config.ui_flutter.get(&k) {
diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs
index 8e0eda98b..7f7af71b4 100644
--- a/src/flutter_ffi.rs
+++ b/src/flutter_ffi.rs
@@ -197,23 +197,23 @@ pub fn session_toggle_option(session_id: SessionID, value: String) {
}
}
-pub fn session_get_flutter_config(session_id: SessionID, k: String) -> Option<String> {
+pub fn session_get_flutter_option(session_id: SessionID, k: String) -> Option<String> {
if let Some(session) = SESSIONS.read().unwrap().get(&session_id) {
- Some(session.get_flutter_config(k))
+ Some(session.get_flutter_option(k))
} else {
None
}
}
-pub fn session_set_flutter_config(session_id: SessionID, k: String, v: String) {
+pub fn session_set_flutter_option(session_id: SessionID, k: String, v: String) {
if let Some(session) = SESSIONS.write().unwrap().get_mut(&session_id) {
- session.save_flutter_config(k, v);
+ session.save_flutter_option(k, v);
}
}
-pub fn session_get_flutter_config_by_peer_id(id: String, k: String) -> Option<String> {
+pub fn session_get_flutter_option_by_peer_id(id: String, k: String) -> Option<String> {
if let Some((_, session)) = SESSIONS.read().unwrap().iter().find(|(_, s)| s.id == id) {
- Some(session.get_flutter_config(k))
+ Some(session.get_flutter_option(k))
} else {
None
}
@@ -224,12 +224,12 @@ pub fn get_next_texture_key() -> SyncReturn<i32> {
SyncReturn(k)
}
-pub fn get_local_flutter_config(k: String) -> SyncReturn<String> {
- SyncReturn(ui_interface::get_local_flutter_config(k))
+pub fn get_local_flutter_option(k: String) -> SyncReturn<String> {
+ SyncReturn(ui_interface::get_local_flutter_option(k))
}
-pub fn set_local_flutter_config(k: String, v: String) {
- ui_interface::set_local_flutter_config(k, v);
+pub fn set_local_flutter_option(k: String, v: String) {
+ ui_interface::set_local_flutter_option(k, v);
}
pub fn get_local_kb_layout_type() -> SyncReturn<String> {
@@ -795,14 +795,14 @@ pub fn main_get_peer_option_sync(id: String, key: String) -> SyncReturn<String>
SyncReturn(get_peer_option(id, key))
}
-// Sometimes we need to get the flutter config of a peer by reading the file.
+// Sometimes we need to get the flutter option of a peer by reading the file.
// Because the session may not be established yet.
-pub fn main_get_peer_flutter_config_sync(id: String, k: String) -> SyncReturn<String> {
- SyncReturn(get_peer_flutter_config(id, k))
+pub fn main_get_peer_flutter_option_sync(id: String, k: String) -> SyncReturn<String> {
+ SyncReturn(get_peer_flutter_option(id, k))
}
-pub fn main_set_peer_flutter_config_sync(id: String, k: String, v: String) -> SyncReturn<()> {
- set_peer_flutter_config(id, k, v);
+pub fn main_set_peer_flutter_option_sync(id: String, k: String, v: String) -> SyncReturn<()> {
+ set_peer_flutter_option(id, k, v);
SyncReturn(())
}
diff --git a/src/ui_interface.rs b/src/ui_interface.rs
index 019cb2d5e..51f848457 100644
--- a/src/ui_interface.rs
+++ b/src/ui_interface.rs
@@ -168,14 +168,14 @@ pub fn set_local_option(key: String, value: String) {
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
#[inline]
-pub fn get_local_flutter_config(key: String) -> String {
- LocalConfig::get_flutter_config(&key)
+pub fn get_local_flutter_option(key: String) -> String {
+ LocalConfig::get_flutter_option(&key)
}
#[cfg(any(target_os = "android", target_os = "ios", feature = "flutter"))]
#[inline]
-pub fn set_local_flutter_config(key: String, value: String) {
- LocalConfig::set_flutter_config(key, value);
+pub fn set_local_flutter_option(key: String, value: String) {
+ LocalConfig::set_flutter_option(key, value);
}
#[cfg(feature = "flutter")]
@@ -210,14 +210,14 @@ pub fn get_peer_option(id: String, name: String) -> String {
#[inline]
#[cfg(feature = "flutter")]
-pub fn get_peer_flutter_config(id: String, name: String) -> String {
+pub fn get_peer_flutter_option(id: String, name: String) -> String {
let c = PeerConfig::load(&id);
c.ui_flutter.get(&name).unwrap_or(&"".to_owned()).to_owned()
}
#[inline]
#[cfg(feature = "flutter")]
-pub fn set_peer_flutter_config(id: String, name: String, value: String) {
+pub fn set_peer_flutter_option(id: String, name: String, value: String) {
let mut c = PeerConfig::load(&id);
if value.is_empty() {
c.ui_flutter.remove(&name);
diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs
index 7ffcaac6d..bbf6d0aec 100644
--- a/src/ui_session_interface.rs
+++ b/src/ui_session_interface.rs
@@ -197,11 +197,11 @@ impl<T: InvokeUiSession> Session<T> {
self.lc.write().unwrap().save_scroll_style(value);
}
- pub fn save_flutter_config(&mut self, k: String, v: String) {
+ pub fn save_flutter_option(&mut self, k: String, v: String) {
self.lc.write().unwrap().save_ui_flutter(k, v);
}
- pub fn get_flutter_config(&self, k: String) -> String {
+ pub fn get_flutter_option(&self, k: String) -> String {
self.lc.read().unwrap().get_ui_flutter(&k)
}