2015-04-02 10:33:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2016-02-08 10:56:18 +00:00
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
2015-04-02 10:33:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "abstractbox.h"
|
|
|
|
|
|
|
|
class ConfirmBox;
|
|
|
|
|
|
|
|
struct SessionData {
|
|
|
|
uint64 hash;
|
|
|
|
|
2015-04-05 08:40:56 +00:00
|
|
|
int32 activeTime;
|
2015-04-06 22:15:29 +00:00
|
|
|
int32 nameWidth, activeWidth, infoWidth, ipWidth;
|
|
|
|
QString name, active, info, ip;
|
2015-04-02 10:33:19 +00:00
|
|
|
};
|
|
|
|
typedef QList<SessionData> SessionsList;
|
|
|
|
|
2015-10-12 21:02:10 +00:00
|
|
|
class SessionsInner : public TWidget, public RPCSender {
|
2015-04-02 10:33:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2015-10-12 21:02:10 +00:00
|
|
|
SessionsInner(SessionsList *list, SessionData *current);
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
|
|
|
|
void listUpdated();
|
|
|
|
|
|
|
|
~SessionsInner();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
void oneTerminated();
|
2015-10-12 21:02:10 +00:00
|
|
|
void allTerminated();
|
|
|
|
void terminateAll();
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void onTerminate();
|
|
|
|
void onTerminateSure();
|
2015-10-12 21:02:10 +00:00
|
|
|
void onTerminateAll();
|
|
|
|
void onTerminateAllSure();
|
2015-04-02 10:33:19 +00:00
|
|
|
void onNoTerminateBox(QObject *obj);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void terminateDone(uint64 hash, const MTPBool &result);
|
|
|
|
bool terminateFail(uint64 hash, const RPCError &error);
|
|
|
|
|
2015-10-12 21:02:10 +00:00
|
|
|
void terminateAllDone(const MTPBool &res);
|
|
|
|
bool terminateAllFail(const RPCError &error);
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
SessionsList *_list;
|
2015-10-12 21:02:10 +00:00
|
|
|
SessionData *_current;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
typedef QMap<uint64, IconedButton*> TerminateButtons;
|
|
|
|
TerminateButtons _terminateButtons;
|
|
|
|
|
|
|
|
uint64 _terminating;
|
2015-10-12 21:02:10 +00:00
|
|
|
LinkButton _terminateAll;
|
2015-04-02 10:33:19 +00:00
|
|
|
ConfirmBox *_terminateBox;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class SessionsBox : public ScrollableBox, public RPCSender {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
SessionsBox();
|
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void onOneTerminated();
|
2015-10-12 21:02:10 +00:00
|
|
|
void onAllTerminated();
|
|
|
|
void onTerminateAll();
|
2015-04-02 10:33:19 +00:00
|
|
|
void onShortPollAuthorizations();
|
|
|
|
void onNewAuthorization();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
void hideAll();
|
|
|
|
void showAll();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void gotAuthorizations(const MTPaccount_Authorizations &result);
|
|
|
|
|
|
|
|
bool _loading;
|
|
|
|
|
|
|
|
SessionData _current;
|
|
|
|
SessionsList _list;
|
|
|
|
|
|
|
|
SessionsInner _inner;
|
2015-10-12 21:02:10 +00:00
|
|
|
ScrollableBoxShadow _shadow;
|
|
|
|
BoxButton _done;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
|
|
|
SingleTimer _shortPollTimer;
|
|
|
|
mtpRequestId _shortPollRequest;
|
|
|
|
|
|
|
|
};
|