FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
tdesktop/Telegram/SourceFiles/auth_session.h at dev · 0Knowledge/tdesktop · GitHub
0Knowledge
/
tdesktop
Public
forked from
telegramdesktop/tdesktop
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
tdesktop
/
Telegram
/
SourceFiles
/
auth_session.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
367 lines (315 loc) · 9.81 KB
Breadcrumbs
tdesktop
/
Telegram
/
SourceFiles
/
auth_session.h
Copy path
File metadata and controls
367 lines (315 loc) · 9.81 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
/*
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
#
include
<
rpl/event_stream.h
>
#
include
<
rpl/filter.h
>
#
include
<
rpl/variable.h
>
#
include
"
base/timer.h
"
#
include
"
data/data_auto_download.h
"
class
ApiWrap
;
enum
class
SendFilesWay
;
namespace
Ui
{
enum
class
InputSubmitSettings
;
}
//
namespace Ui
namespace
Support
{
enum
class
SwitchSettings
;
class
Helper
;
class
Templates
;
}
//
namespace Support
namespace
Data
{
class
Session
;
}
//
namespace Data
namespace
Storage
{
class
Downloader
;
class
Uploader
;
class
Facade
;
}
//
namespace Storage
namespace
Window
{
namespace
Notifications
{
class
System
;
}
//
namespace Notifications
enum
class
Column
;
}
//
namespace Window
namespace
Calls
{
class
Instance
;
}
//
namespace Calls
namespace
ChatHelpers
{
enum
class
SelectorTab
;
}
//
namespace ChatHelpers
namespace
Core
{
class
Changelogs
;
}
//
namespace Core
class
AuthSessionSettings
final
{
public:
void
moveFrom
(AuthSessionSettings &&other) {
_variables =
std::move
(other.
_variables
);
}
QByteArray
serialize
()
const
;
void
constructFromSerialized
(
const
QByteArray &serialized);
void
setLastSeenWarningSeen
(
bool
lastSeenWarningSeen) {
_variables.
lastSeenWarningSeen
= lastSeenWarningSeen;
}
bool
lastSeenWarningSeen
()
const
{
return
_variables.
lastSeenWarningSeen
;
}
void
setSendFilesWay
(SendFilesWay way) {
_variables.
sendFilesWay
= way;
}
SendFilesWay
sendFilesWay
()
const
{
return
_variables.
sendFilesWay
;
}
void
setSendSubmitWay
(Ui::InputSubmitSettings value) {
_variables.
sendSubmitWay
= value;
}
Ui::InputSubmitSettings
sendSubmitWay
()
const
{
return
_variables.
sendSubmitWay
;
}
void
setSupportSwitch
(Support::SwitchSettings value) {
_variables.
supportSwitch
= value;
}
Support::SwitchSettings
supportSwitch
()
const
{
return
_variables.
supportSwitch
;
}
void
setSupportFixChatsOrder
(
bool
fix) {
_variables.
supportFixChatsOrder
= fix;
}
bool
supportFixChatsOrder
()
const
{
return
_variables.
supportFixChatsOrder
;
}
void
setSupportTemplatesAutocomplete
(
bool
enabled) {
_variables.
supportTemplatesAutocomplete
= enabled;
}
bool
supportTemplatesAutocomplete
()
const
{
return
_variables.
supportTemplatesAutocomplete
;
}
void
setSupportChatsTimeSlice
(
int
slice);
int
supportChatsTimeSlice
()
const
;
rpl::producer<
int
>
supportChatsTimeSliceValue
()
const
;
void
setSupportAllSearchResults
(
bool
all);
bool
supportAllSearchResults
()
const
;
rpl::producer<
bool
>
supportAllSearchResultsValue
()
const
;
ChatHelpers::SelectorTab
selectorTab
()
const
{
return
_variables.
selectorTab
;
}
void
setSelectorTab
(ChatHelpers::SelectorTab tab) {
_variables.
selectorTab
= tab;
}
bool
tabbedSelectorSectionEnabled
()
const
{
return
_variables.
tabbedSelectorSectionEnabled
;
}
void
setTabbedSelectorSectionEnabled
(
bool
enabled);
bool
thirdSectionInfoEnabled
()
const
{
return
_variables.
thirdSectionInfoEnabled
;
}
void
setThirdSectionInfoEnabled
(
bool
enabled);
rpl::producer<
bool
>
thirdSectionInfoEnabledValue
()
const
;
int
thirdSectionExtendedBy
()
const
{
return
_variables.
thirdSectionExtendedBy
;
}
void
setThirdSectionExtendedBy
(
int
savedValue) {
_variables.
thirdSectionExtendedBy
= savedValue;
}
bool
tabbedReplacedWithInfo
()
const
{
return
_tabbedReplacedWithInfo;
}
void
setTabbedReplacedWithInfo
(
bool
enabled);
rpl::producer<
bool
>
tabbedReplacedWithInfoValue
()
const
;
void
setSmallDialogsList
(
bool
enabled) {
_variables.
smallDialogsList
= enabled;
}
bool
smallDialogsList
()
const
{
return
_variables.
smallDialogsList
;
}
void
setLastTimeVideoPlayedAt
(TimeMs time) {
_lastTimeVideoPlayedAt = time;
}
TimeMs
lastTimeVideoPlayedAt
()
const
{
return
_lastTimeVideoPlayedAt;
}
void
setSoundOverride
(
const
QString &key,
const
QString &path) {
_variables.
soundOverrides
.
insert
(key, path);
}
void
clearSoundOverrides
() {
_variables.
soundOverrides
.
clear
();
}
QString
getSoundPath
(
const
QString &key)
const
;
void
setTabbedSelectorSectionTooltipShown
(
int
shown) {
_variables.
tabbedSelectorSectionTooltipShown
= shown;
}
int
tabbedSelectorSectionTooltipShown
()
const
{
return
_variables.
tabbedSelectorSectionTooltipShown
;
}
void
setFloatPlayerColumn
(Window::Column column) {
_variables.
floatPlayerColumn
= column;
}
Window::Column
floatPlayerColumn
()
const
{
return
_variables.
floatPlayerColumn
;
}
void
setFloatPlayerCorner
(RectPart corner) {
_variables.
floatPlayerCorner
= corner;
}
RectPart
floatPlayerCorner
()
const
{
return
_variables.
floatPlayerCorner
;
}
void
setDialogsWidthRatio
(float64 ratio);
float64
dialogsWidthRatio
()
const
;
rpl::producer<float64>
dialogsWidthRatioChanges
()
const
;
void
setThirdColumnWidth
(
int
width);
int
thirdColumnWidth
()
const
;
rpl::producer<
int
>
thirdColumnWidthChanges
()
const
;
void
setGroupStickersSectionHidden
(PeerId peerId) {
_variables.
groupStickersSectionHidden
.
insert
(peerId);
}
bool
isGroupStickersSectionHidden
(PeerId peerId)
const
{
return
_variables.
groupStickersSectionHidden
.
contains
(peerId);
}
void
removeGroupStickersSectionHidden
(PeerId peerId) {
_variables.
groupStickersSectionHidden
.
remove
(peerId);
}
Data::AutoDownload::Full &
autoDownload
() {
return
_variables.
autoDownload
;
}
const
Data::AutoDownload::Full &
autoDownload
()
const
{
return
_variables.
autoDownload
;
}
bool
hadLegacyCallsPeerToPeerNobody
()
const
{
return
_variables.
hadLegacyCallsPeerToPeerNobody
;
}
bool
includeMutedCounter
()
const
{
return
_variables.
includeMutedCounter
;
}
void
setIncludeMutedCounter
(
bool
value) {
_variables.
includeMutedCounter
= value;
}
bool
countUnreadMessages
()
const
{
return
_variables.
countUnreadMessages
;
}
void
setCountUnreadMessages
(
bool
value) {
_variables.
countUnreadMessages
= value;
}
bool
exeLaunchWarning
()
const
{
return
_variables.
exeLaunchWarning
;
}
void
setExeLaunchWarning
(
bool
warning) {
_variables.
exeLaunchWarning
= warning;
}
private:
struct
Variables
{
Variables
();
static
constexpr
auto
kDefaultDialogsWidthRatio
=
5
. /
14
;
static
constexpr
auto
kDefaultThirdColumnWidth
=
0
;
bool
lastSeenWarningSeen =
false
;
SendFilesWay sendFilesWay;
ChatHelpers::SelectorTab selectorTab;
//
per-window
bool
tabbedSelectorSectionEnabled =
false
;
//
per-window
int
tabbedSelectorSectionTooltipShown =
0
;
QMap<QString, QString> soundOverrides;
Window::Column floatPlayerColumn;
//
per-window
RectPart floatPlayerCorner;
//
per-window
base::flat_set<PeerId> groupStickersSectionHidden;
bool
thirdSectionInfoEnabled =
true
;
//
per-window
bool
smallDialogsList =
false
;
//
per-window
int
thirdSectionExtendedBy = -
1
;
//
per-window
rpl::variable<float64> dialogsWidthRatio
=
kDefaultDialogsWidthRatio
;
//
per-window
rpl::variable<
int
> thirdColumnWidth
=
kDefaultThirdColumnWidth
;
//
per-window
Ui::InputSubmitSettings sendSubmitWay;
bool
hadLegacyCallsPeerToPeerNobody =
false
;
bool
includeMutedCounter =
true
;
bool
countUnreadMessages =
true
;
bool
exeLaunchWarning =
true
;
Data::AutoDownload::Full autoDownload;
static
constexpr
auto
kDefaultSupportChatsLimitSlice
=
7
*
24
*
60
*
60
;
Support::SwitchSettings supportSwitch;
bool
supportFixChatsOrder =
true
;
bool
supportTemplatesAutocomplete =
true
;
rpl::variable<
int
> supportChatsTimeSlice
=
kDefaultSupportChatsLimitSlice
;
rpl::variable<
bool
> supportAllSearchResults =
false
;
};
rpl::event_stream<
bool
> _thirdSectionInfoEnabledValue;
bool
_tabbedReplacedWithInfo =
false
;
rpl::event_stream<
bool
> _tabbedReplacedWithInfoValue;
Variables _variables;
TimeMs _lastTimeVideoPlayedAt =
0
;
};
class
AuthSession
;
AuthSession &
Auth
();
class
AuthSession
final
: public base::has_weak_ptr
, private base::Subscriber {
public:
AuthSession
(
const
MTPUser &user);
AuthSession
(
const
AuthSession &other) =
delete
;
AuthSession &
operator
=(
const
AuthSession &other) =
delete
;
static
bool
Exists
();
UserId
userId
()
const
;
PeerId
userPeerId
()
const
;
not_null<UserData*>
user
()
const
{
return
_user;
}
bool
validateSelf
(
const
MTPUser &user);
Storage::Downloader &
downloader
() {
return
*_downloader;
}
Storage::Uploader &
uploader
() {
return
*_uploader;
}
Storage::Facade &
storage
() {
return
*_storage;
}
base::Observable<
void
> &
downloaderTaskFinished
();
Window::Notifications::System &
notifications
() {
return
*_notifications;
}
Data::Session &
data
() {
return
*_data;
}
AuthSessionSettings &
settings
() {
return
_settings;
}
void
moveSettingsFrom
(AuthSessionSettings &&other);
void
saveSettingsDelayed
(TimeMs delay =
kDefaultSaveDelay
);
ApiWrap &
api
() {
return
*_api;
}
Calls::Instance &
calls
() {
return
*_calls;
}
void
checkAutoLock
();
void
checkAutoLockIn
(TimeMs time);
rpl::lifetime &
lifetime
() {
return
_lifetime;
}
base::Observable<DocumentData*> documentUpdated;
base::Observable<std::pair<not_null<HistoryItem*>, MsgId>> messageIdChanging;
bool
supportMode
()
const
;
Support::Helper &
supportHelper
()
const
;
Support::Templates &
supportTemplates
()
const
;
~AuthSession
();
private:
static
constexpr
auto
kDefaultSaveDelay
= TimeMs(
1000
);
AuthSessionSettings _settings;
base::Timer _saveDataTimer;
TimeMs _shouldLockAt =
0
;
base::Timer _autoLockTimer;
const
std::unique_ptr<ApiWrap> _api;
const
std::unique_ptr<Calls::Instance> _calls;
const
std::unique_ptr<Storage::Downloader> _downloader;
const
std::unique_ptr<Storage::Uploader> _uploader;
const
std::unique_ptr<Storage::Facade> _storage;
const
std::unique_ptr<Window::Notifications::System> _notifications;
//
_data depends on _downloader / _uploader / _notifications.
const
std::unique_ptr<Data::Session> _data;
const
not_null<UserData*> _user;
//
_changelogs depends on _data, subscribes on chats loading event.
const
std::unique_ptr<Core::Changelogs> _changelogs;
const
std::unique_ptr<Support::Helper> _supportHelper;
rpl::lifetime _lifetime;
};
Back
|
FazBrowse Home
|
New Git URL