2015-04-02 10:33:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2015-04-02 10:33:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/abstract_box.h"
|
2018-11-20 10:03:44 +00:00
|
|
|
#include "mtproto/sender.h"
|
|
|
|
#include "base/timer.h"
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
class ConfirmBox;
|
|
|
|
|
2016-10-27 21:19:38 +00:00
|
|
|
namespace Ui {
|
|
|
|
class IconButton;
|
2016-11-11 13:46:04 +00:00
|
|
|
class LinkButton;
|
2016-10-27 21:19:38 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2019-07-25 18:55:11 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
2019-11-27 08:02:56 +00:00
|
|
|
class SessionsBox : public Ui::BoxContent {
|
2016-10-20 16:32:15 +00:00
|
|
|
public:
|
2019-07-25 18:55:11 +00:00
|
|
|
SessionsBox(QWidget*, not_null<Main::Session*> session);
|
2016-10-20 16:32:15 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
2016-10-20 16:32:15 +00:00
|
|
|
private:
|
2018-11-20 10:03:44 +00:00
|
|
|
struct Entry {
|
|
|
|
uint64 hash = 0;
|
2016-10-20 16:32:15 +00:00
|
|
|
|
2018-11-20 10:03:44 +00:00
|
|
|
bool incomplete = false;
|
|
|
|
TimeId activeTime = 0;
|
|
|
|
int nameWidth, activeWidth, infoWidth, ipWidth;
|
2016-10-20 16:32:15 +00:00
|
|
|
QString name, active, info, ip;
|
|
|
|
};
|
2018-11-20 10:03:44 +00:00
|
|
|
struct Full {
|
|
|
|
Entry current;
|
|
|
|
std::vector<Entry> incomplete;
|
|
|
|
std::vector<Entry> list;
|
|
|
|
};
|
2016-10-20 16:32:15 +00:00
|
|
|
class Inner;
|
2018-11-20 10:03:44 +00:00
|
|
|
class List;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2018-11-20 10:03:44 +00:00
|
|
|
static Entry ParseEntry(const MTPDauthorization &data);
|
|
|
|
static void ResizeEntry(Entry &entry);
|
|
|
|
void setLoading(bool loading);
|
|
|
|
void shortPollSessions();
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2018-11-20 10:03:44 +00:00
|
|
|
void got(const MTPaccount_Authorizations &result);
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2018-11-20 10:03:44 +00:00
|
|
|
void terminateOne(uint64 hash);
|
2015-10-12 21:02:10 +00:00
|
|
|
void terminateAll();
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2019-07-25 18:55:11 +00:00
|
|
|
const not_null<Main::Session*> _session;
|
2019-11-27 08:02:56 +00:00
|
|
|
MTP::Sender _api;
|
2019-07-25 18:55:11 +00:00
|
|
|
|
2018-11-20 10:03:44 +00:00
|
|
|
bool _loading = false;
|
|
|
|
Full _data;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2018-11-20 10:03:44 +00:00
|
|
|
QPointer<Inner> _inner;
|
2016-12-13 17:07:56 +00:00
|
|
|
QPointer<ConfirmBox> _terminateBox;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2018-11-20 10:03:44 +00:00
|
|
|
base::Timer _shortPollTimer;
|
|
|
|
mtpRequestId _shortPollRequest = 0;
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
};
|