int port;
bool block;
+ QString hostaddress;
QTcpSocket *socket;
QPacketProtocol *protocol;
QTcpServer *tcpServer;
return d->protocol->waitForReadyRead(-1);
}
-void QTcpServerConnection::setPort(int port, bool block)
+void QTcpServerConnection::setPort(int port, bool block, const QString &hostaddress)
{
Q_D(QTcpServerConnection);
d->port = port;
d->block = block;
+ d->hostaddress = hostaddress;
listen();
if (block)
d->tcpServer = new QTcpServer(this);
QObject::connect(d->tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection()));
- if (d->tcpServer->listen(QHostAddress::Any, d->port))
+ QHostAddress hostaddress;
+ if (!d->hostaddress.isEmpty()) {
+ if (!hostaddress.setAddress(d->hostaddress)) {
+ hostaddress = QHostAddress::Any;
+ qDebug("QML Debugger: Incorrect host address provided. So accepting connections "
+ "from any host.");
+ }
+ } else {
+ hostaddress = QHostAddress::Any;
+ }
+ if (d->tcpServer->listen(hostaddress, d->port))
qDebug("QML Debugger: Waiting for connection on port %d...", d->port);
else
qWarning("QML Debugger: Unable to listen to port %d.", d->port);
}
QT_END_NAMESPACE
-
m_pluginName = pluginName;
}
- void setPort(int port, bool block) {
+ void setPort(int port, bool block, QString &hostAddress) {
m_port = port;
m_block = block;
+ m_hostAddress = hostAddress;
}
void run();
QString m_pluginName;
int m_port;
bool m_block;
+ QString m_hostAddress;
};
QQmlDebugServerPrivate::QQmlDebugServerPrivate() :
= server->d_func()->loadConnectionPlugin(m_pluginName);
if (connection) {
connection->setServer(QQmlDebugServer::instance());
- connection->setPort(m_port, m_block);
+ connection->setPort(m_port, m_block, m_hostAddress);
} else {
QCoreApplicationPrivate *appD = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp));
qWarning() << QString(QLatin1String("QML Debugger: Ignoring \"-qmljsdebugger=%1\". "
int port = 0;
bool block = false;
bool ok = false;
+ QString hostAddress;
- // format: qmljsdebugger=port:3768[,block] OR qmljsdebugger=ost[,block]
+ // format: qmljsdebugger=port:3768[,host:<ip address>][,block] OR qmljsdebugger=ost[,block]
if (!appD->qmljsDebugArgumentsString().isEmpty()) {
if (!QQmlEnginePrivate::qml_debugging_enabled) {
qWarning() << QString(QLatin1String(
}
QString pluginName;
- if (appD->qmljsDebugArgumentsString().indexOf(QLatin1String("port:")) == 0) {
- int separatorIndex = appD->qmljsDebugArgumentsString().indexOf(QLatin1Char(','));
- port = appD->qmljsDebugArgumentsString().mid(5, separatorIndex - 5).toInt(&ok);
- pluginName = QStringLiteral("qmldbg_tcp");
- } else if (appD->qmljsDebugArgumentsString().contains(QLatin1String("ost"))) {
- pluginName = QStringLiteral("qmldbg_ost");
- ok = true;
+ QStringList lstjsDebugArguments = appD->qmljsDebugArgumentsString()
+ .split(QLatin1Char(','));
+ foreach (const QString &strArgument, lstjsDebugArguments) {
+ if (strArgument.startsWith(QLatin1String("port:"))) {
+ port = strArgument.mid(5).toInt(&ok);
+ pluginName = QLatin1String("qmldbg_tcp");
+ } else if (strArgument.startsWith(QLatin1String("host:"))) {
+ hostAddress = strArgument.mid(5);
+ } else if (strArgument == QLatin1String("block")) {
+ block = true;
+ } else {
+ qWarning() << QString::fromLatin1("QML Debugger: Invalid argument '%1' "
+ "detected. Ignoring the same.")
+ .arg(strArgument);
+ }
}
- block = appD->qmljsDebugArgumentsString().contains(QLatin1String("block"));
-
if (ok) {
qQmlDebugServer = new QQmlDebugServer();
QQmlDebugServerThread *thread = new QQmlDebugServerThread;
qQmlDebugServer->d_func()->thread = thread;
qQmlDebugServer->moveToThread(thread);
thread->setPluginName(pluginName);
- thread->setPort(port, block);
+ thread->setPort(port, block, hostAddress);
thread->start();
if (block) {