mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-07-12 17:50:02 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bea89e9111 | |||
| 499ce0190a | |||
| 91bde91238 | |||
| 3e31ba102d | |||
| 263c5eefd3 |
@@ -181,7 +181,7 @@ sudo docker run -d \
|
|||||||
-e MAX_PORT=xxxxx \
|
-e MAX_PORT=xxxxx \
|
||||||
-v /var/lib/crossdesk:/var/lib/crossdesk \
|
-v /var/lib/crossdesk:/var/lib/crossdesk \
|
||||||
-v /var/log/crossdesk:/var/log/crossdesk \
|
-v /var/log/crossdesk:/var/log/crossdesk \
|
||||||
crossdesk/crossdesk-server:v1.1.3
|
crossdesk/crossdesk-server:v1.1.6
|
||||||
```
|
```
|
||||||
|
|
||||||
上述命令中,用户需注意的参数如下:
|
上述命令中,用户需注意的参数如下:
|
||||||
@@ -208,7 +208,7 @@ sudo docker run -d \
|
|||||||
-e MAX_PORT=60000 \
|
-e MAX_PORT=60000 \
|
||||||
-v /var/lib/crossdesk:/var/lib/crossdesk \
|
-v /var/lib/crossdesk:/var/lib/crossdesk \
|
||||||
-v /var/log/crossdesk:/var/log/crossdesk \
|
-v /var/log/crossdesk:/var/log/crossdesk \
|
||||||
crossdesk/crossdesk-server:v1.1.3
|
crossdesk/crossdesk-server:v1.1.6
|
||||||
```
|
```
|
||||||
|
|
||||||
**注意**:
|
**注意**:
|
||||||
|
|||||||
+2
-2
@@ -189,7 +189,7 @@ sudo docker run -d \
|
|||||||
-e MAX_PORT=xxxxx \
|
-e MAX_PORT=xxxxx \
|
||||||
-v /var/lib/crossdesk:/var/lib/crossdesk \
|
-v /var/lib/crossdesk:/var/lib/crossdesk \
|
||||||
-v /var/log/crossdesk:/var/log/crossdesk \
|
-v /var/log/crossdesk:/var/log/crossdesk \
|
||||||
crossdesk/crossdesk-server:v1.1.3
|
crossdesk/crossdesk-server:v1.1.6
|
||||||
```
|
```
|
||||||
|
|
||||||
The parameters you need to pay attention to are as follows:
|
The parameters you need to pay attention to are as follows:
|
||||||
@@ -216,7 +216,7 @@ sudo docker run -d \
|
|||||||
-e MAX_PORT=60000 \
|
-e MAX_PORT=60000 \
|
||||||
-v /var/lib/crossdesk:/var/lib/crossdesk \
|
-v /var/lib/crossdesk:/var/lib/crossdesk \
|
||||||
-v /var/log/crossdesk:/var/log/crossdesk \
|
-v /var/log/crossdesk:/var/log/crossdesk \
|
||||||
crossdesk/crossdesk-server:v1.1.3
|
crossdesk/crossdesk-server:v1.1.6
|
||||||
```
|
```
|
||||||
|
|
||||||
**Notes**
|
**Notes**
|
||||||
|
|||||||
@@ -165,7 +165,21 @@ static int InputTextCallback(ImGuiInputTextCallbackData* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Render::ConnectTo(const std::string& remote_id, const char* password,
|
int Render::ConnectTo(const std::string& remote_id, const char* password,
|
||||||
bool remember_password) {
|
bool remember_password, bool bypass_presence_check) {
|
||||||
|
if (!bypass_presence_check && !device_presence_.IsOnline(remote_id)) {
|
||||||
|
int ret =
|
||||||
|
RequestSingleDevicePresence(remote_id, password, remember_password);
|
||||||
|
if (ret != 0) {
|
||||||
|
offline_warning_text_ =
|
||||||
|
localization::device_offline[localization_language_index_];
|
||||||
|
show_offline_warning_window_ = true;
|
||||||
|
LOG_WARN("Presence probe failed for [{}], ret={}", remote_id, ret);
|
||||||
|
} else {
|
||||||
|
LOG_INFO("Presence probe requested for [{}] before connect", remote_id);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_INFO("Connect to [{}]", remote_id);
|
LOG_INFO("Connect to [{}]", remote_id);
|
||||||
focused_remote_id_ = remote_id;
|
focused_remote_id_ = remote_id;
|
||||||
|
|
||||||
|
|||||||
+81
-1
@@ -1605,6 +1605,7 @@ void Render::MainLoop() {
|
|||||||
UpdateLabels();
|
UpdateLabels();
|
||||||
HandleRecentConnections();
|
HandleRecentConnections();
|
||||||
HandleConnectionStatusChange();
|
HandleConnectionStatusChange();
|
||||||
|
HandlePendingPresenceProbe();
|
||||||
HandleStreamWindow();
|
HandleStreamWindow();
|
||||||
HandleServerWindow();
|
HandleServerWindow();
|
||||||
|
|
||||||
@@ -1684,6 +1685,84 @@ void Render::HandleConnectionStatusChange() {
|
|||||||
need_to_send_recent_connections_ = false;
|
need_to_send_recent_connections_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Render::HandlePendingPresenceProbe() {
|
||||||
|
bool has_action = false;
|
||||||
|
bool should_connect = false;
|
||||||
|
bool remember_password = false;
|
||||||
|
std::string remote_id;
|
||||||
|
std::string password;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(pending_presence_probe_mutex_);
|
||||||
|
if (!pending_presence_probe_ || !pending_presence_result_ready_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
has_action = true;
|
||||||
|
should_connect = pending_presence_online_;
|
||||||
|
remote_id = pending_presence_remote_id_;
|
||||||
|
password = pending_presence_password_;
|
||||||
|
remember_password = pending_presence_remember_password_;
|
||||||
|
|
||||||
|
pending_presence_probe_ = false;
|
||||||
|
pending_presence_result_ready_ = false;
|
||||||
|
pending_presence_online_ = false;
|
||||||
|
pending_presence_remote_id_.clear();
|
||||||
|
pending_presence_password_.clear();
|
||||||
|
pending_presence_remember_password_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!has_action) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (should_connect) {
|
||||||
|
ConnectTo(remote_id, password.c_str(), remember_password, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
offline_warning_text_ =
|
||||||
|
localization::device_offline[localization_language_index_];
|
||||||
|
show_offline_warning_window_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Render::RequestSingleDevicePresence(const std::string& remote_id,
|
||||||
|
const char* password,
|
||||||
|
bool remember_password) {
|
||||||
|
if (!signal_connected_ || !peer_) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(pending_presence_probe_mutex_);
|
||||||
|
pending_presence_probe_ = true;
|
||||||
|
pending_presence_result_ready_ = false;
|
||||||
|
pending_presence_online_ = false;
|
||||||
|
pending_presence_remote_id_ = remote_id;
|
||||||
|
pending_presence_password_ = password ? password : "";
|
||||||
|
pending_presence_remember_password_ = remember_password;
|
||||||
|
}
|
||||||
|
|
||||||
|
nlohmann::json j;
|
||||||
|
j["type"] = "recent_connections_presence";
|
||||||
|
j["user_id"] = client_id_;
|
||||||
|
j["devices"] = nlohmann::json::array({remote_id});
|
||||||
|
auto s = j.dump();
|
||||||
|
|
||||||
|
int ret = SendSignalMessage(peer_, s.data(), s.size());
|
||||||
|
if (ret != 0) {
|
||||||
|
std::lock_guard<std::mutex> lock(pending_presence_probe_mutex_);
|
||||||
|
pending_presence_probe_ = false;
|
||||||
|
pending_presence_result_ready_ = false;
|
||||||
|
pending_presence_online_ = false;
|
||||||
|
pending_presence_remote_id_.clear();
|
||||||
|
pending_presence_password_.clear();
|
||||||
|
pending_presence_remember_password_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void Render::HandleStreamWindow() {
|
void Render::HandleStreamWindow() {
|
||||||
if (need_to_create_stream_window_) {
|
if (need_to_create_stream_window_) {
|
||||||
CreateStreamWindow();
|
CreateStreamWindow();
|
||||||
@@ -2256,7 +2335,8 @@ void Render::ProcessSdlEvent(const SDL_Event& event) {
|
|||||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||||
case SDL_EVENT_MOUSE_WHEEL:
|
case SDL_EVENT_MOUSE_WHEEL:
|
||||||
if (focus_on_stream_window_) {
|
if (focus_on_stream_window_ && stream_window_ &&
|
||||||
|
SDL_GetWindowID(stream_window_) == event.motion.windowID) {
|
||||||
ProcessMouseEvent(event);
|
ProcessMouseEvent(event);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
+12
-1
@@ -194,6 +194,7 @@ class Render {
|
|||||||
void UpdateInteractions();
|
void UpdateInteractions();
|
||||||
void HandleRecentConnections();
|
void HandleRecentConnections();
|
||||||
void HandleConnectionStatusChange();
|
void HandleConnectionStatusChange();
|
||||||
|
void HandlePendingPresenceProbe();
|
||||||
void HandleStreamWindow();
|
void HandleStreamWindow();
|
||||||
void HandleServerWindow();
|
void HandleServerWindow();
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
@@ -235,6 +236,7 @@ class Render {
|
|||||||
bool ConnectionStatusWindow(
|
bool ConnectionStatusWindow(
|
||||||
std::shared_ptr<SubStreamWindowProperties>& props);
|
std::shared_ptr<SubStreamWindowProperties>& props);
|
||||||
int ShowRecentConnections();
|
int ShowRecentConnections();
|
||||||
|
bool OpenUrl(const std::string& url);
|
||||||
void Hyperlink(const std::string& label, const std::string& url,
|
void Hyperlink(const std::string& label, const std::string& url,
|
||||||
const float window_width);
|
const float window_width);
|
||||||
int FileTransferWindow(std::shared_ptr<SubStreamWindowProperties>& props);
|
int FileTransferWindow(std::shared_ptr<SubStreamWindowProperties>& props);
|
||||||
@@ -242,7 +244,9 @@ class Render {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int ConnectTo(const std::string& remote_id, const char* password,
|
int ConnectTo(const std::string& remote_id, const char* password,
|
||||||
bool remember_password);
|
bool remember_password, bool bypass_presence_check = false);
|
||||||
|
int RequestSingleDevicePresence(const std::string& remote_id,
|
||||||
|
const char* password, bool remember_password);
|
||||||
int CreateMainWindow();
|
int CreateMainWindow();
|
||||||
int DestroyMainWindow();
|
int DestroyMainWindow();
|
||||||
int CreateStreamWindow();
|
int CreateStreamWindow();
|
||||||
@@ -689,6 +693,13 @@ class Render {
|
|||||||
std::unordered_map<std::string, std::string> connection_host_names_;
|
std::unordered_map<std::string, std::string> connection_host_names_;
|
||||||
std::string selected_server_remote_id_ = "";
|
std::string selected_server_remote_id_ = "";
|
||||||
std::string selected_server_remote_hostname_ = "";
|
std::string selected_server_remote_hostname_ = "";
|
||||||
|
std::mutex pending_presence_probe_mutex_;
|
||||||
|
bool pending_presence_probe_ = false;
|
||||||
|
bool pending_presence_result_ready_ = false;
|
||||||
|
bool pending_presence_online_ = false;
|
||||||
|
std::string pending_presence_remote_id_ = "";
|
||||||
|
std::string pending_presence_password_ = "";
|
||||||
|
bool pending_presence_remember_password_ = false;
|
||||||
FileTransferState file_transfer_;
|
FileTransferState file_transfer_;
|
||||||
};
|
};
|
||||||
} // namespace crossdesk
|
} // namespace crossdesk
|
||||||
|
|||||||
@@ -48,6 +48,15 @@ void Render::OnSignalMessageCb(const char* message, size_t size,
|
|||||||
std::string id = dev["id"].get<std::string>();
|
std::string id = dev["id"].get<std::string>();
|
||||||
bool online = dev["online"].get<bool>();
|
bool online = dev["online"].get<bool>();
|
||||||
render->device_presence_.SetOnline(id, online);
|
render->device_presence_.SetOnline(id, online);
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(
|
||||||
|
render->pending_presence_probe_mutex_);
|
||||||
|
if (render->pending_presence_probe_ &&
|
||||||
|
render->pending_presence_remote_id_ == id) {
|
||||||
|
render->pending_presence_result_ready_ = true;
|
||||||
|
render->pending_presence_online_ = online;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type == "presence_update") {
|
} else if (type == "presence_update") {
|
||||||
@@ -57,6 +66,15 @@ void Render::OnSignalMessageCb(const char* message, size_t size,
|
|||||||
bool online = j["online"].get<bool>();
|
bool online = j["online"].get<bool>();
|
||||||
if (!id.empty()) {
|
if (!id.empty()) {
|
||||||
render->device_presence_.SetOnline(id, online);
|
render->device_presence_.SetOnline(id, online);
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(
|
||||||
|
render->pending_presence_probe_mutex_);
|
||||||
|
if (render->pending_presence_probe_ &&
|
||||||
|
render->pending_presence_remote_id_ == id) {
|
||||||
|
render->pending_presence_result_ready_ = true;
|
||||||
|
render->pending_presence_online_ = online;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -498,9 +516,9 @@ void Render::OnReceiveDataBufferCb(const char* data, size_t size,
|
|||||||
const double bps =
|
const double bps =
|
||||||
(static_cast<double>(delta_bytes) * 8.0) / delta_seconds;
|
(static_cast<double>(delta_bytes) * 8.0) / delta_seconds;
|
||||||
if (bps > 0.0) {
|
if (bps > 0.0) {
|
||||||
const double capped = (std::min)(
|
const double capped =
|
||||||
bps,
|
(std::min)(bps, static_cast<double>(
|
||||||
static_cast<double>((std::numeric_limits<uint32_t>::max)()));
|
(std::numeric_limits<uint32_t>::max)()));
|
||||||
estimated_rate_bps = static_cast<uint32_t>(capped);
|
estimated_rate_bps = static_cast<uint32_t>(capped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,40 @@
|
|||||||
|
|
||||||
namespace crossdesk {
|
namespace crossdesk {
|
||||||
|
|
||||||
|
bool Render::OpenUrl(const std::string& url) {
|
||||||
|
#if defined(_WIN32)
|
||||||
|
int wide_len = MultiByteToWideChar(CP_UTF8, 0, url.c_str(), -1, nullptr, 0);
|
||||||
|
if (wide_len <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring wide_url(static_cast<size_t>(wide_len), L'\0');
|
||||||
|
MultiByteToWideChar(CP_UTF8, 0, url.c_str(), -1, &wide_url[0], wide_len);
|
||||||
|
if (!wide_url.empty() && wide_url.back() == L'\0') {
|
||||||
|
wide_url.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring cmd = L"cmd.exe /c start \"\" \"" + wide_url + L"\"";
|
||||||
|
STARTUPINFOW startup_info = {sizeof(startup_info)};
|
||||||
|
PROCESS_INFORMATION process_info = {};
|
||||||
|
if (!CreateProcessW(nullptr, &cmd[0], nullptr, nullptr, FALSE,
|
||||||
|
CREATE_NO_WINDOW, nullptr, nullptr, &startup_info,
|
||||||
|
&process_info)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(process_info.hThread);
|
||||||
|
CloseHandle(process_info.hProcess);
|
||||||
|
return true;
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
std::string cmd = "open " + url;
|
||||||
|
return system(cmd.c_str()) == 0;
|
||||||
|
#else
|
||||||
|
std::string cmd = "xdg-open " + url;
|
||||||
|
return system(cmd.c_str()) == 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Render::Hyperlink(const std::string& label, const std::string& url,
|
void Render::Hyperlink(const std::string& label, const std::string& url,
|
||||||
const float window_width) {
|
const float window_width) {
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 0, 255, 255));
|
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 0, 255, 255));
|
||||||
@@ -27,35 +61,7 @@ void Render::Hyperlink(const std::string& label, const std::string& url,
|
|||||||
ImGui::SetWindowFontScale(1.0f);
|
ImGui::SetWindowFontScale(1.0f);
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||||
#if defined(_WIN32)
|
OpenUrl(url);
|
||||||
int wide_len =
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, url.c_str(), -1, nullptr, 0);
|
|
||||||
if (wide_len > 0) {
|
|
||||||
std::wstring wide_url(static_cast<size_t>(wide_len), L'\0');
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, url.c_str(), -1, &wide_url[0],
|
|
||||||
wide_len);
|
|
||||||
if (!wide_url.empty() && wide_url.back() == L'\0') {
|
|
||||||
wide_url.pop_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring cmd = L"cmd.exe /c start \"\" \"" + wide_url + L"\"";
|
|
||||||
STARTUPINFOW startup_info = {sizeof(startup_info)};
|
|
||||||
PROCESS_INFORMATION process_info = {};
|
|
||||||
if (CreateProcessW(nullptr, &cmd[0], nullptr, nullptr, FALSE,
|
|
||||||
CREATE_NO_WINDOW, nullptr, nullptr, &startup_info,
|
|
||||||
&process_info)) {
|
|
||||||
CloseHandle(process_info.hThread);
|
|
||||||
CloseHandle(process_info.hProcess);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
std::string cmd = "open " + url;
|
|
||||||
#else
|
|
||||||
std::string cmd = "xdg-open " + url;
|
|
||||||
#endif
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
system(cmd.c_str()); // open browser
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
@@ -184,14 +183,7 @@ int Render::UpdateNotificationWindow() {
|
|||||||
localization::update[localization_language_index_].c_str())) {
|
localization::update[localization_language_index_].c_str())) {
|
||||||
// open download page
|
// open download page
|
||||||
std::string url = "https://crossdesk.cn";
|
std::string url = "https://crossdesk.cn";
|
||||||
#if defined(_WIN32)
|
OpenUrl(url);
|
||||||
std::string cmd = "start " + url;
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
std::string cmd = "open " + url;
|
|
||||||
#else
|
|
||||||
std::string cmd = "xdg-open " + url;
|
|
||||||
#endif
|
|
||||||
system(cmd.c_str());
|
|
||||||
show_update_notification_window_ = false;
|
show_update_notification_window_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user