42 #include "private/qdeclarativedebugserver_p.h" 43 #include "private/qdeclarativedebugservice_p.h" 44 #include "private/qdeclarativedebugservice_p_p.h" 45 #include "private/qdeclarativeengine_p.h" 47 #include <QtCore/QDir> 48 #include <QtCore/QPluginLoader> 49 #include <QtCore/QStringList> 51 #include <private/qobject_p.h> 52 #include <private/qcoreapplication_p.h> 125 #ifndef QT_NO_LIBRARY 128 foreach (
const QString &libPath, paths) {
139 foreach (
const QString &pluginPath, pluginCandidates) {
141 if (!loader->
load()) {
146 connection = qobject_cast<QDeclarativeDebugServerConnection*>(instance);
160 &&
d->connection->isConnected()
166 static bool commandLineTested =
false;
169 if (!commandLineTested) {
170 commandLineTested =
true;
173 #ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL 183 "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " 184 "Debugging has not been enabled.").
arg(
211 connection->
setPort(port, block);
214 "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " 215 "Remote debugger plugin has not been found.").
arg(
221 "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " 222 "Format is -qmljsdebugger=port:<port>[,block]").
arg(
229 "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " 230 "QtDeclarative is not configured for debugging.").
arg(
256 qWarning(
"QDeclarativeDebugServer: Invalid hello message");
257 d->connection->disconnect();
262 in >> version >>
d->clientPlugins;
271 d->connection->send(helloAnswer);
276 for (; iter !=
d->plugins.end(); ++iter) {
278 if (
d->clientPlugins.contains(iter.
key()))
280 iter.
value()->d_func()->status = newStatus;
281 iter.
value()->statusChanged(newStatus);
284 qDebug(
"QDeclarativeDebugServer: Connection established");
292 if (name == debugServer) {
299 in >>
d->clientPlugins;
302 for (; iter !=
d->plugins.end(); ++iter) {
305 if (
d->clientPlugins.contains(pluginName))
308 if (oldClientPlugins.
contains(pluginName)
309 !=
d->clientPlugins.contains(pluginName)) {
310 iter.
value()->d_func()->status = newStatus;
311 iter.
value()->statusChanged(newStatus);
315 qWarning(
"QDeclarativeDebugServer: Invalid control message %d", op);
321 if (
d->waitingForMsgFromService == name) {
323 d->_q_deliverMessage(name, message);
324 d->waitingForMsgSucceeded =
true;
341 if (iter == plugins.end()) {
342 qWarning() <<
"QDeclarativeDebugServer: Message received for missing plugin" << serviceName;
344 (*iter)->messageReceived(message);
351 return d->plugins.values();
357 return d->plugins.keys();
363 if (!service ||
d->plugins.contains(service->
name()))
366 d->plugins.insert(service->
name(), service);
367 d->advertisePlugins();
370 if (
d->clientPlugins.contains(service->
name()))
372 service->d_func()->
status = newStatus;
380 if (!service || !
d->plugins.contains(service->
name()))
383 d->plugins.remove(service->
name());
384 d->advertisePlugins();
387 service->d_func()->server = 0;
388 service->d_func()->
status = newStatus;
400 out << service->
name() << message;
402 d->connection->send(msg);
410 || !
d->plugins.contains(service->
name())
411 || !
d->waitingForMsgFromService.isEmpty())
414 d->waitingForMsgFromService = service->
name();
417 d->connection->waitForMessage();
418 }
while (!
d->waitingForMsgSucceeded);
419 d->waitingForMsgSucceeded =
false;
420 d->waitingForMsgFromService.clear();
426 #include "moc_qdeclarativedebugserver_p.cpp" bool hasDebuggingClient() const
The QDir class provides access to directory structures and their contents.
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
void _q_deliverMessage(const QString &serviceName, const QByteArray &message)
virtual void send(const QByteArray &message)=0
#define QT_END_NAMESPACE
This macro expands to.
static QDeclarativeDebugServer * instance()
QString absoluteFilePath(const QString &fileName) const
Returns the absolute path name of a file in the directory.
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
bool load()
Loads the plugin and returns true if the plugin was loaded successfully; otherwise returns false...
QStringList serviceNames() const
static QString qmljsDebugArguments()
The QByteArray class provides an array of bytes.
QString fileName() const
Returns the name of the file, excluding the path.
#define Q_ARG(type, data)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QHash< QString, QDeclarativeDebugService * > plugins
T & value() const
Returns a modifiable reference to the current item's value.
The QString class provides a Unicode character string.
The QHash class is a template class that provides a hash-table-based dictionary.
The QObject class is the base class of all Qt objects.
QString waitingForMsgFromService
bool waitingForMsgSucceeded
static QObjectPrivate * get(QObject *o)
bool exists() const
Returns true if the directory exists; otherwise returns false.
Q_CORE_EXPORT void qDebug(const char *,...)
static bool qml_debugging_enabled
static QDeclarativeDebugServerConnection * loadConnectionPlugin(QPluginLoader *loader, const QString &pluginName)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QDeclarativeDebugServerPrivate()
virtual void setPort(int port, bool bock)=0
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
The QStringList class provides a list of strings.
Q_CORE_EXPORT void qWarning(const char *,...)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
virtual void setServer(QDeclarativeDebugServer *server)=0
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
void setFileName(const QString &fileName)
const Key & key() const
Returns the current item's key as a const reference.
void receiveMessage(const QByteArray &message)
QDeclarativeDebugServer()
void sendMessage(QDeclarativeDebugService *service, const QByteArray &message)
bool removeService(QDeclarativeDebugService *service)
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
bool addService(QDeclarativeDebugService *service)
static QAuServer & server()
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
#define Q_DECLARE_PUBLIC(Class)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
static QStringList libraryPaths()
Returns a list of paths that the application will search when dynamically loading libraries...
bool waitForMessage(QDeclarativeDebugService *service)
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
QList< QDeclarativeDebugService * > services() const
QStringList clientPlugins
const int protocolVersion
QDeclarativeDebugServerConnection * connection
The QDataStream class provides serialization of binary data to a QIODevice.
QObject * instance()
Returns the root component object of the plugin.
The QFileInfo class provides system-independent file information.
virtual void statusChanged(Status)
bool unload()
Unloads the plugin and returns true if the plugin could be unloaded; otherwise returns false...
QStringList entryList(Filters filters=NoFilter, SortFlags sort=NoSort) const
Returns a list of the names of all the files and directories in the directory, ordered according to t...
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
The QList class is a template class that provides lists.
The QPluginLoader class loads a plugin at run-time.