forked from telegramdesktop/tdesktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.h
126 lines (89 loc) · 2.85 KB
/
application.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace Core {
class Launcher;
class UpdateChecker;
} // namespace Core
bool InternalPassportLink(const QString &url);
bool StartUrlRequiresActivate(const QString &url);
class Application : public QApplication, private QAbstractNativeEventFilter {
Q_OBJECT
public:
Application(not_null<Core::Launcher*> launcher, int &argc, char **argv);
int execute();
void createMessenger();
void refreshGlobalProxy();
void postponeCall(FnMut<void()> &&callable);
bool notify(QObject *receiver, QEvent *e) override;
void activateWindowDelayed(not_null<QWidget*> widget);
void pauseDelayedWindowActivations();
void resumeDelayedWindowActivations();
~Application();
signals:
void adjustSingleTimers();
// Single instance application
public slots:
void socketConnected();
void socketError(QLocalSocket::LocalSocketError e);
void socketDisconnected();
void socketWritten(qint64 bytes);
void socketReading();
void newInstanceConnected();
void readClients();
void removeClients();
void startApplication(); // will be done in exec()
void closeApplication(); // will be done in aboutToQuit()
protected:
bool event(QEvent *e) override;
private:
typedef QPair<QLocalSocket*, QByteArray> LocalClient;
typedef QList<LocalClient> LocalClients;
struct PostponedCall {
int loopNestingLevel = 0;
FnMut<void()> callable;
};
bool nativeEventFilter(
const QByteArray &eventType,
void *message,
long *result) override;
void processPostponedCalls(int level);
const Qt::HANDLE _mainThreadId = nullptr;
int _eventNestingLevel = 0;
int _loopNestingLevel = 0;
std::vector<int> _previousLoopNestingLevels;
std::vector<PostponedCall> _postponedCalls;
QPointer<QWidget> _windowForDelayedActivation;
bool _delayedActivationsPaused = false;
not_null<Core::Launcher*> _launcher;
std::unique_ptr<Messenger> _messengerInstance;
QString _localServerName, _localSocketReadData;
QLocalServer _localServer;
QLocalSocket _localSocket;
LocalClients _localClients;
bool _secondInstance = false;
void singleInstanceChecked();
private:
std::unique_ptr<Core::UpdateChecker> _updateChecker;
};
namespace Core {
inline Application &App() {
Expects(QCoreApplication::instance() != nullptr);
return *static_cast<Application*>(QCoreApplication::instance());
}
} // namespace Core
namespace Sandbox {
QRect availableGeometry();
QRect screenGeometry(const QPoint &p);
void setActiveWindow(QWidget *window);
bool isSavingSession();
void execExternal(const QString &cmd);
void adjustSingleTimers();
void refreshGlobalProxy();
void connect(const char *signal, QObject *object, const char *method);
void launch();
} // namespace Sandbox