Files
RedBear-OS/recipes/wip/qt/qtscxml/source/examples/scxml/ftpclient/ftpdatachannel.cpp
T
vasilito ff4ff35918 feat: track all source trees in git — full fork offline-first model
Red Bear OS is a full fork. All sources must be available from git clone
with zero network access. Removed gitignore rules that excluded fetched
source trees under recipes/*/source/, local/recipes/kde/*/source/,
local/recipes/qt/*/source/, and vendor source trees.

Build artifacts (target/, build/, source.tar, *.o, *.so) remain excluded.

127291 files added — kernel, relibc, base, bootloader, pkgar, all KDE/Qt
frameworks, mesa, wayland, DRM drivers, and every other recipe source.
2026-05-14 10:55:53 +01:00

47 lines
1.4 KiB
C++

// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "ftpdatachannel.h"
FtpDataChannel::FtpDataChannel(QObject *parent) : QObject(parent)
{
connect(&m_server, &QTcpServer::newConnection, this, [this]() {
m_socket.reset(m_server.nextPendingConnection());
connect(m_socket.get(), &QTcpSocket::readyRead, this, [this]() {
emit dataReceived(m_socket->readAll());
});
});
}
void FtpDataChannel::listen(const QHostAddress &address)
{
m_server.listen(address);
}
void FtpDataChannel::sendData(const QByteArray &data)
{
if (m_socket)
m_socket->write(QByteArray(data).replace("\n", "\r\n"));
}
void FtpDataChannel::close()
{
if (m_socket)
m_socket->disconnectFromHost();
}
QString FtpDataChannel::portspec() const
{
// Yes, this is a weird format, but say hello to FTP.
QString portSpec;
quint32 ipv4 = m_server.serverAddress().toIPv4Address();
quint16 port = m_server.serverPort();
portSpec += QString::number((ipv4 & 0xff000000) >> 24);
portSpec += ',' + QString::number((ipv4 & 0x00ff0000) >> 16);
portSpec += ',' + QString::number((ipv4 & 0x0000ff00) >> 8);
portSpec += ',' + QString::number(ipv4 & 0x000000ff);
portSpec += ',' + QString::number((port & 0xff00) >> 8);
portSpec += ',' + QString::number(port &0x00ff);
return portSpec;
}