Add local UDP discovery and invitation delivery for chat clients
This commit is contained in:
1 parent
aad295c9d0
commit
28826e050c
43 files changed
+1934
-43
No files matched your search
@@ -209,6 +209,7 @@ MainWindow::~MainWindow() {
|
||||
s_mainWindow = nullptr;
|
||||
m_cpuLoadTimer->stop();
|
||||
gui_bridge_set_cpu_load_cb(nullptr);
|
||||
gui_bridge_set_local_invite_cb(nullptr);
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_SYS, "desktop CPU indicator polling stopped");
|
||||
if (m_messageNotification) m_messageNotification->dismiss("shutdown");
|
||||
m_messageNotification.reset();
|
||||
@@ -441,6 +442,22 @@ void MainWindow::setupSoundFromConfig() {
|
||||
|
||||
void MainWindow::setupBridgeCallbacks() {
|
||||
s_mainWindow = this;
|
||||
gui_bridge_set_local_invite_cb([](const uint8_t* data, int len) {
|
||||
if (!s_mainWindow || len < 10 || 9 + data[8] >= len) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_DISCOVERY, "invalid local invitation event bytes=%d", len); return;
|
||||
}
|
||||
QString name = QString::fromUtf8((const char*)data + 9, data[8]);
|
||||
QString link = QString::fromUtf8((const char*)data + 9 + data[8], len - 9 - data[8]);
|
||||
auto* window = s_mainWindow;
|
||||
auto* prompt = new QMessageBox(QMessageBox::Question, QCoreApplication::translate("ChatGui", "Invitation"),
|
||||
QCoreApplication::translate("ChatGui", "%1 sent an invitation over the local network. Connect?").arg(name),
|
||||
QMessageBox::Yes | QMessageBox::No, window);
|
||||
prompt->setTextFormat(Qt::PlainText); prompt->setAttribute(Qt::WA_DeleteOnClose);
|
||||
QObject::connect(prompt, &QMessageBox::finished, window, [window, link](int result) {
|
||||
if (result == QMessageBox::Yes) window->onMessageLinkActivated(link);
|
||||
});
|
||||
prompt->open();
|
||||
});
|
||||
gui_bridge_set_cpu_load_cb([](int percent) {
|
||||
if (!s_mainWindow) return;
|
||||
s_mainWindow->m_cpuLoadPending = false;
|
||||
|
||||
Reference in new issue
Block a user