-
Notifications
You must be signed in to change notification settings - Fork 71
/
TargetApplicationProxy.h
61 lines (44 loc) · 1.52 KB
/
TargetApplicationProxy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include "RootObjectList.h"
#include "lib/NetstringReader.h"
#include "lib/ObjectProxy.h"
#include <QtCore/QHash>
#include <QtCore/QObject>
#include <QtNetwork/QLocalSocket>
class ExternalObjectProxy;
class QLocalSocket;
namespace service
{
class InspectorRequest;
class InspectorResponse;
class QtObject;
}
/** Represents an external Qt process. */
class TargetApplicationProxy : public QObject , public RootObjectList
{
Q_OBJECT
public:
TargetApplicationProxy();
bool connectToTarget(int pid);
void disconnect();
/** Return a list of top-level widgets in the application. */
QList<ObjectProxy::Pointer> fetchTopLevelWidgets();
ObjectProxy::Pointer fetchProxy(int objectId);
// helpers to issue requests to the target process
bool fetchObject(ExternalObjectProxy* proxy, bool fetchProperties);
void updateProperty(int objectId, const ObjectProxy::Property& property);
ObjectProxy::Pointer pickWidget();
// implements RootObjectList
/** Same as fetchTopLevelWidgets() */
virtual QList<ObjectProxy::Pointer> rootObjects();
private Q_SLOTS:
void socketError(QLocalSocket::LocalSocketError error);
void socketStateChanged(QLocalSocket::LocalSocketState state);
private:
void updateProxy(const service::QtObject& object, ExternalObjectProxy* proxy);
bool sendRequest(const service::InspectorRequest& request,
service::InspectorResponse* response);
QLocalSocket* m_socket;
QHash<int,ObjectProxy::Pointer> m_objectProxies;
NetstringReader m_messageReader;
};