Qt 4.8
Public Functions | Static Public Functions | Private Functions | Friends | List of all members
QDeclarativeDebugServer Class Reference

#include <qdeclarativedebugserver_p.h>

Inheritance diagram for QDeclarativeDebugServer:
QObject

Public Functions

bool addService (QDeclarativeDebugService *service)
 
bool hasDebuggingClient () const
 
void receiveMessage (const QByteArray &message)
 
bool removeService (QDeclarativeDebugService *service)
 
void sendMessage (QDeclarativeDebugService *service, const QByteArray &message)
 
QStringList serviceNames () const
 
QList< QDeclarativeDebugService * > services () const
 
void setConnection (QDeclarativeDebugServerConnection *connection)
 
bool waitForMessage (QDeclarativeDebugService *service)
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Static Public Functions

static QDeclarativeDebugServerinstance ()
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Private Functions

 QDeclarativeDebugServer ()
 

Friends

class QDeclarativeDebugService
 
class QDeclarativeDebugServicePrivate
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 57 of file qdeclarativedebugserver_p.h.

Constructors and Destructors

◆ QDeclarativeDebugServer()

QDeclarativeDebugServer::QDeclarativeDebugServer ( )
private

Definition at line 239 of file qdeclarativedebugserver.cpp.

241 {
242 }
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

Functions

◆ addService()

bool QDeclarativeDebugServer::addService ( QDeclarativeDebugService service)

Definition at line 360 of file qdeclarativedebugserver.cpp.

361 {
363  if (!service || d->plugins.contains(service->name()))
364  return false;
365 
366  d->plugins.insert(service->name(), service);
367  d->advertisePlugins();
368 
370  if (d->clientPlugins.contains(service->name()))
372  service->d_func()->status = newStatus;
373  service->statusChanged(newStatus);
374  return true;
375 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ hasDebuggingClient()

bool QDeclarativeDebugServer::hasDebuggingClient ( ) const

Definition at line 156 of file qdeclarativedebugserver.cpp.

Referenced by QDeclarativeDebugService::hasDebuggingClient().

157 {
159  return d->connection
160  && d->connection->isConnected()
161  && d->gotHello;
162 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ instance()

QDeclarativeDebugServer * QDeclarativeDebugServer::instance ( )
static

Definition at line 164 of file qdeclarativedebugserver.cpp.

Referenced by QDeclarativeDebugService::hasDebuggingClient(), QDeclarativeDebugService::isDebuggingEnabled(), and QDeclarativeDebugService::QDeclarativeDebugService().

165 {
166  static bool commandLineTested = false;
167  static QDeclarativeDebugServer *server = 0;
168 
169  if (!commandLineTested) {
170  commandLineTested = true;
171 
173 #ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL
174  // ### remove port definition when protocol is changed
175  int port = 0;
176  bool block = false;
177  bool ok = false;
178 
179  // format: qmljsdebugger=port:3768[,block] OR qmljsdebugger=ost[,block]
180  if (!appD->qmljsDebugArguments().isEmpty()) {
183  "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
184  "Debugging has not been enabled.").arg(
185  appD->qmljsDebugArguments());
186  return 0;
187  }
188 
189  QString pluginName;
190  if (appD->qmljsDebugArguments().indexOf(QLatin1String("port:")) == 0) {
191  int separatorIndex = appD->qmljsDebugArguments().indexOf(QLatin1Char(','));
192  port = appD->qmljsDebugArguments().mid(5, separatorIndex - 5).toInt(&ok);
193  pluginName = QLatin1String("qmldbg_tcp");
194  } else if (appD->qmljsDebugArguments().contains(QLatin1String("ost"))) {
195  pluginName = QLatin1String("qmldbg_ost");
196  ok = true;
197  }
198 
199  block = appD->qmljsDebugArguments().contains(QLatin1String("block"));
200 
201  if (ok) {
202  server = new QDeclarativeDebugServer();
203 
204  QPluginLoader *loader = new QPluginLoader(server);
207  if (connection) {
208  server->d_func()->connection = connection;
209 
210  connection->setServer(server);
211  connection->setPort(port, block);
212  } else {
214  "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
215  "Remote debugger plugin has not been found.").arg(
216  appD->qmljsDebugArguments());
217  }
218 
219  } else {
221  "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
222  "Format is -qmljsdebugger=port:<port>[,block]").arg(
223  appD->qmljsDebugArguments());
224  }
225  }
226 #else
227  if (!appD->qmljsDebugArguments().isEmpty()) {
229  "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
230  "QtDeclarative is not configured for debugging.").arg(
231  appD->qmljsDebugArguments());
232  }
233 #endif
234  }
235 
236  return server;
237 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
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 ...
Definition: qstring.cpp:6090
static QString qmljsDebugArguments()
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
static QDeclarativeDebugServerConnection * loadConnectionPlugin(QPluginLoader *loader, const QString &pluginName)
virtual void setPort(int port, bool bock)=0
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define qApp
Q_CORE_EXPORT void qWarning(const char *,...)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
virtual void setServer(QDeclarativeDebugServer *server)=0
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...
Definition: qstring.cpp:3706
static QAuServer & server()
Definition: qsound.cpp:79
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QPluginLoader class loads a plugin at run-time.
Definition: qpluginloader.h:62

◆ receiveMessage()

void QDeclarativeDebugServer::receiveMessage ( const QByteArray message)

Definition at line 244 of file qdeclarativedebugserver.cpp.

245 {
247 
248  QDataStream in(message);
249  if (!d->gotHello) {
250  QString name;
251  int op;
252  in >> name >> op;
253 
254  if (name != QLatin1String("QDeclarativeDebugServer")
255  || op != 0) {
256  qWarning("QDeclarativeDebugServer: Invalid hello message");
257  d->connection->disconnect();
258  return;
259  }
260 
261  int version;
262  in >> version >> d->clientPlugins;
263 
264  // Send the hello answer immediately, since it needs to arrive before
265  // the plugins below start sending messages.
266  QByteArray helloAnswer;
267  {
268  QDataStream out(&helloAnswer, QIODevice::WriteOnly);
269  out << QString(QLatin1String("QDeclarativeDebugClient")) << 0 << protocolVersion << d->plugins.keys();
270  }
271  d->connection->send(helloAnswer);
272 
273  d->gotHello = true;
274 
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);
282  }
283 
284  qDebug("QDeclarativeDebugServer: Connection established");
285  } else {
286 
287  QString debugServer(QLatin1String("QDeclarativeDebugServer"));
288 
289  QString name;
290  in >> name;
291 
292  if (name == debugServer) {
293  int op = -1;
294  in >> op;
295 
296  if (op == 1) {
297  // Service Discovery
298  QStringList oldClientPlugins = d->clientPlugins;
299  in >> d->clientPlugins;
300 
302  for (; iter != d->plugins.end(); ++iter) {
303  const QString pluginName = iter.key();
305  if (d->clientPlugins.contains(pluginName))
307 
308  if (oldClientPlugins.contains(pluginName)
309  != d->clientPlugins.contains(pluginName)) {
310  iter.value()->d_func()->status = newStatus;
311  iter.value()->statusChanged(newStatus);
312  }
313  }
314  } else {
315  qWarning("QDeclarativeDebugServer: Invalid control message %d", op);
316  }
317  } else {
318  QByteArray message;
319  in >> message;
320 
321  if (d->waitingForMsgFromService == name) {
322  // deliver directly so that it is delivered before waitForMessage is returning.
323  d->_q_deliverMessage(name, message);
324  d->waitingForMsgSucceeded = true;
325  } else {
326  // deliver message in next event loop run.
327  // Fixes the case that the service does start it's own event loop ...,
328  // but the networking code doesn't deliver any new messages because readyRead
329  // hasn't returned.
330  QMetaObject::invokeMethod(this, "_q_deliverMessage", Qt::QueuedConnection,
331  Q_ARG(QString, name),
332  Q_ARG(QByteArray, message));
333  }
334  }
335  }
336 }
double d
Definition: qnumeric_p.h:62
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define Q_ARG(type, data)
Definition: qobjectdefs.h:246
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
T & value() const
Returns a modifiable reference to the current item&#39;s value.
Definition: qhash.h:348
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
const char * name
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Q_CORE_EXPORT void qWarning(const char *,...)
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
const Key & key() const
Returns the current item&#39;s key as a const reference.
Definition: qhash.h:347
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
const int protocolVersion
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71

◆ removeService()

bool QDeclarativeDebugServer::removeService ( QDeclarativeDebugService service)

Definition at line 377 of file qdeclarativedebugserver.cpp.

378 {
380  if (!service || !d->plugins.contains(service->name()))
381  return false;
382 
383  d->plugins.remove(service->name());
384  d->advertisePlugins();
385 
387  service->d_func()->server = 0;
388  service->d_func()->status = newStatus;
389  service->statusChanged(newStatus);
390  return true;
391 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ sendMessage()

void QDeclarativeDebugServer::sendMessage ( QDeclarativeDebugService service,
const QByteArray message 
)

Definition at line 393 of file qdeclarativedebugserver.cpp.

395 {
397  QByteArray msg;
398  {
400  out << service->name() << message;
401  }
402  d->connection->send(msg);
403 }
double d
Definition: qnumeric_p.h:62
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define Q_D(Class)
Definition: qglobal.h:2482
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71

◆ serviceNames()

QStringList QDeclarativeDebugServer::serviceNames ( ) const

Definition at line 354 of file qdeclarativedebugserver.cpp.

355 {
357  return d->plugins.keys();
358 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ services()

QList< QDeclarativeDebugService * > QDeclarativeDebugServer::services ( ) const

Definition at line 348 of file qdeclarativedebugserver.cpp.

349 {
351  return d->plugins.values();
352 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setConnection()

void QDeclarativeDebugServer::setConnection ( QDeclarativeDebugServerConnection connection)

◆ waitForMessage()

bool QDeclarativeDebugServer::waitForMessage ( QDeclarativeDebugService service)

Definition at line 405 of file qdeclarativedebugserver.cpp.

406 {
408 
409  if (!service
410  || !d->plugins.contains(service->name())
411  || !d->waitingForMsgFromService.isEmpty())
412  return false;
413 
414  d->waitingForMsgFromService = service->name();
415 
416  do {
417  d->connection->waitForMessage();
418  } while (!d->waitingForMsgSucceeded);
419  d->waitingForMsgSucceeded = false;
420  d->waitingForMsgFromService.clear();
421  return true;
422 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

Friends and Related Functions

◆ QDeclarativeDebugService

Definition at line 81 of file qdeclarativedebugserver_p.h.

◆ QDeclarativeDebugServicePrivate

Definition at line 82 of file qdeclarativedebugserver_p.h.


The documentation for this class was generated from the following files: