2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2015-10-03 13:16:42 +00:00
|
|
|
Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "dialogswidget.h"
|
|
|
|
#include "historywidget.h"
|
|
|
|
#include "profilewidget.h"
|
2014-08-15 11:19:32 +00:00
|
|
|
#include "overviewwidget.h"
|
2015-07-03 08:47:16 +00:00
|
|
|
#include "playerwidget.h"
|
2015-03-19 09:18:19 +00:00
|
|
|
#include "apiwrap.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
class Window;
|
2014-06-16 09:31:10 +00:00
|
|
|
struct DialogRow;
|
2014-05-30 08:53:19 +00:00
|
|
|
class MainWidget;
|
2014-12-12 16:27:03 +00:00
|
|
|
class ConfirmBox;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-12-15 15:55:45 +00:00
|
|
|
class TopBarWidget : public TWidget, public Animated {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
TopBarWidget(MainWidget *w);
|
|
|
|
|
|
|
|
void enterEvent(QEvent *e);
|
2014-12-15 15:55:45 +00:00
|
|
|
void enterFromChildEvent(QEvent *e);
|
2014-05-30 08:53:19 +00:00
|
|
|
void leaveEvent(QEvent *e);
|
2014-12-15 15:55:45 +00:00
|
|
|
void leaveToChildEvent(QEvent *e);
|
2014-05-30 08:53:19 +00:00
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
|
|
|
|
bool animStep(float64 ms);
|
|
|
|
void enableShadow(bool enable = true);
|
|
|
|
|
2014-06-14 19:32:11 +00:00
|
|
|
void startAnim();
|
|
|
|
void stopAnim();
|
2014-05-30 08:53:19 +00:00
|
|
|
void showAll();
|
2015-09-20 08:55:41 +00:00
|
|
|
void showSelected(uint32 selCount, bool canDelete = false);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
void updateWideMode();
|
|
|
|
|
2014-08-21 12:18:56 +00:00
|
|
|
FlatButton *mediaTypeButton();
|
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
void grabStart() {
|
|
|
|
_sideShadow.hide();
|
|
|
|
}
|
|
|
|
void grabFinish() {
|
|
|
|
_sideShadow.setVisible(cWideMode());
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void onForwardSelection();
|
|
|
|
void onDeleteSelection();
|
|
|
|
void onClearSelection();
|
2014-12-15 15:55:45 +00:00
|
|
|
void onInfoClicked();
|
2014-05-30 08:53:19 +00:00
|
|
|
void onAddContact();
|
|
|
|
void onEdit();
|
|
|
|
void onDeleteContact();
|
|
|
|
void onDeleteContactSure();
|
|
|
|
void onDeleteAndExit();
|
|
|
|
void onDeleteAndExitSure();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
void clicked();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
MainWidget *main();
|
|
|
|
anim::fvalue a_over;
|
|
|
|
|
2015-09-06 10:17:09 +00:00
|
|
|
PeerData *_selPeer;
|
2014-05-30 08:53:19 +00:00
|
|
|
uint32 _selCount;
|
2015-09-20 08:55:41 +00:00
|
|
|
bool _canDelete;
|
2014-05-30 08:53:19 +00:00
|
|
|
QString _selStr;
|
2014-12-22 23:11:37 +00:00
|
|
|
int32 _selStrLeft, _selStrWidth;
|
2014-06-14 19:32:11 +00:00
|
|
|
|
|
|
|
bool _animating;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
FlatButton _clearSelection;
|
|
|
|
FlatButton _forward, _delete;
|
2014-12-22 23:11:37 +00:00
|
|
|
int32 _selectionButtonsWidth, _forwardDeleteWidth;
|
|
|
|
|
2014-12-15 15:55:45 +00:00
|
|
|
FlatButton _info;
|
2014-05-30 08:53:19 +00:00
|
|
|
FlatButton _edit, _leaveGroup, _addContact, _deleteContact;
|
2014-08-21 12:18:56 +00:00
|
|
|
FlatButton _mediaType;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-17 08:31:48 +00:00
|
|
|
PlainShadow _sideShadow;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
|
2014-08-15 11:19:32 +00:00
|
|
|
enum StackItemType {
|
|
|
|
HistoryStackItem,
|
|
|
|
ProfileStackItem,
|
|
|
|
OverviewStackItem,
|
|
|
|
};
|
|
|
|
|
|
|
|
class StackItem {
|
|
|
|
public:
|
|
|
|
StackItem(PeerData *peer) : peer(peer) {
|
|
|
|
}
|
|
|
|
virtual StackItemType type() const = 0;
|
|
|
|
virtual ~StackItem() {
|
|
|
|
}
|
|
|
|
PeerData *peer;
|
|
|
|
};
|
|
|
|
|
|
|
|
class StackItemHistory : public StackItem {
|
|
|
|
public:
|
2015-07-17 19:17:37 +00:00
|
|
|
StackItemHistory(PeerData *peer, MsgId msgId, QList<MsgId> replyReturns, bool kbWasHidden) : StackItem(peer),
|
|
|
|
msgId(msgId), replyReturns(replyReturns), kbWasHidden(kbWasHidden) {
|
2014-08-15 11:19:32 +00:00
|
|
|
}
|
|
|
|
StackItemType type() const {
|
|
|
|
return HistoryStackItem;
|
|
|
|
}
|
2015-07-17 19:17:37 +00:00
|
|
|
MsgId msgId;
|
2015-03-24 10:00:27 +00:00
|
|
|
QList<MsgId> replyReturns;
|
2015-06-19 12:39:33 +00:00
|
|
|
bool kbWasHidden;
|
2014-08-15 11:19:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class StackItemProfile : public StackItem {
|
|
|
|
public:
|
2015-09-06 10:17:09 +00:00
|
|
|
StackItemProfile(PeerData *peer, int32 lastScrollTop) : StackItem(peer), lastScrollTop(lastScrollTop) {
|
2014-08-15 11:19:32 +00:00
|
|
|
}
|
|
|
|
StackItemType type() const {
|
|
|
|
return ProfileStackItem;
|
|
|
|
}
|
|
|
|
int32 lastScrollTop;
|
|
|
|
};
|
|
|
|
|
|
|
|
class StackItemOverview : public StackItem {
|
|
|
|
public:
|
|
|
|
StackItemOverview(PeerData *peer, MediaOverviewType mediaType, int32 lastWidth, int32 lastScrollTop) : StackItem(peer), mediaType(mediaType), lastWidth(lastWidth), lastScrollTop(lastScrollTop) {
|
|
|
|
}
|
|
|
|
StackItemType type() const {
|
|
|
|
return OverviewStackItem;
|
|
|
|
}
|
|
|
|
MediaOverviewType mediaType;
|
|
|
|
int32 lastWidth, lastScrollTop;
|
|
|
|
};
|
|
|
|
|
|
|
|
class StackItems : public QVector<StackItem*> {
|
|
|
|
public:
|
|
|
|
bool contains(PeerData *peer) const {
|
|
|
|
for (int32 i = 0, l = size(); i < l; ++i) {
|
|
|
|
if (at(i)->peer == peer) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
void clear() {
|
|
|
|
for (int32 i = 0, l = size(); i < l; ++i) {
|
|
|
|
delete at(i);
|
|
|
|
}
|
|
|
|
QVector<StackItem*>::clear();
|
|
|
|
}
|
|
|
|
~StackItems() {
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
class MainWidget : public TWidget, public RPCSender {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
MainWidget(Window *window);
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
void keyPressEvent(QKeyEvent *e);
|
|
|
|
|
2014-12-12 16:27:03 +00:00
|
|
|
void updateWideMode();
|
|
|
|
bool needBackButton();
|
2015-07-17 19:17:37 +00:00
|
|
|
void showDialogs();
|
2014-12-12 16:27:03 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void paintTopBar(QPainter &p, float64 over, int32 decreaseWidth);
|
|
|
|
TopBarWidget *topBar();
|
|
|
|
|
2015-07-03 08:47:16 +00:00
|
|
|
PlayerWidget *player();
|
|
|
|
int32 contentScrollAddToY() const;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void animShow(const QPixmap &bgAnimCache, bool back = false);
|
2015-10-17 14:52:26 +00:00
|
|
|
bool animStep_show(float64 ms);
|
|
|
|
void animStop_show();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void start(const MTPUser &user);
|
2015-05-19 15:46:45 +00:00
|
|
|
|
2014-12-03 13:10:32 +00:00
|
|
|
void openLocalUrl(const QString &str);
|
2015-09-06 10:17:09 +00:00
|
|
|
void openPeerByName(const QString &name, bool toProfile = false, const QString &startToken = QString());
|
2015-04-30 13:53:36 +00:00
|
|
|
void joinGroupByHash(const QString &hash);
|
2015-05-19 15:46:45 +00:00
|
|
|
void stickersBox(const MTPInputStickerSet &set);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void startFull(const MTPVector<MTPUser> &users);
|
2014-12-12 16:27:03 +00:00
|
|
|
bool started();
|
2014-05-30 08:53:19 +00:00
|
|
|
void applyNotifySetting(const MTPNotifyPeer &peer, const MTPPeerNotifySettings &settings, History *history = 0);
|
|
|
|
void gotNotifySetting(MTPInputNotifyPeer peer, const MTPPeerNotifySettings &settings);
|
2015-04-04 20:01:34 +00:00
|
|
|
bool failNotifySetting(MTPInputNotifyPeer peer, const RPCError &error);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void updateNotifySetting(PeerData *peer, bool enabled);
|
|
|
|
|
2015-01-02 14:55:24 +00:00
|
|
|
void incrementSticker(DocumentData *sticker);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void activate();
|
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void createDialog(History *history);
|
2015-11-13 15:14:33 +00:00
|
|
|
void removeDialog(History *history);
|
2015-10-14 11:51:37 +00:00
|
|
|
void dlgUpdated(DialogRow *row = 0);
|
2015-10-03 10:09:09 +00:00
|
|
|
void dlgUpdated(History *row, MsgId msgId);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void windowShown();
|
|
|
|
|
2015-08-30 14:57:21 +00:00
|
|
|
void sentUpdatesReceived(uint64 randomId, const MTPUpdates &updates);
|
|
|
|
void sentUpdatesReceived(const MTPUpdates &updates) {
|
|
|
|
return sentUpdatesReceived(0, updates);
|
|
|
|
}
|
2015-09-23 17:43:08 +00:00
|
|
|
void inviteToChannelDone(ChannelData *channel, const MTPUpdates &updates);
|
2015-11-13 15:14:33 +00:00
|
|
|
void msgUpdated(const HistoryItem *msg);
|
2014-05-30 08:53:19 +00:00
|
|
|
void historyToDown(History *hist);
|
|
|
|
void dialogsToUp();
|
2015-03-19 09:18:19 +00:00
|
|
|
void newUnreadMsg(History *history, HistoryItem *item);
|
2014-05-30 08:53:19 +00:00
|
|
|
void historyWasRead();
|
2015-06-17 19:43:03 +00:00
|
|
|
void historyCleared(History *history);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-08-22 07:41:39 +00:00
|
|
|
void peerBefore(const PeerData *inPeer, MsgId inMsg, PeerData *&outPeer, MsgId &outMsg);
|
|
|
|
void peerAfter(const PeerData *inPeer, MsgId inMsg, PeerData *&outPeer, MsgId &outMsg);
|
2014-12-15 15:55:45 +00:00
|
|
|
PeerData *historyPeer();
|
2014-05-30 08:53:19 +00:00
|
|
|
PeerData *peer();
|
2015-07-17 19:17:37 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
PeerData *activePeer();
|
2014-07-04 11:12:54 +00:00
|
|
|
MsgId activeMsgId();
|
2015-07-17 19:17:37 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
PeerData *profilePeer();
|
2015-07-03 08:47:16 +00:00
|
|
|
PeerData *overviewPeer();
|
2014-08-21 12:18:56 +00:00
|
|
|
bool mediaTypeSwitch();
|
2015-09-06 10:17:09 +00:00
|
|
|
void showPeerProfile(PeerData *peer, bool back = false, int32 lastScrollTop = -1);
|
2014-08-21 12:18:56 +00:00
|
|
|
void showMediaOverview(PeerData *peer, MediaOverviewType type, bool back = false, int32 lastScrollTop = -1);
|
2014-08-15 11:19:32 +00:00
|
|
|
void showBackFromStack();
|
2015-07-17 19:17:37 +00:00
|
|
|
void orderWidgets();
|
2014-05-30 08:53:19 +00:00
|
|
|
QRect historyRect() const;
|
|
|
|
|
2015-10-27 02:39:02 +00:00
|
|
|
void onSendFileConfirm(const FileLoadResultPtr &file, bool ctrlShiftEnter);
|
|
|
|
void onSendFileCancel(const FileLoadResultPtr &file);
|
2015-10-28 02:41:13 +00:00
|
|
|
void onShareContactConfirm(const QString &phone, const QString &fname, const QString &lname, MsgId replyTo, bool ctrlShiftEnter);
|
|
|
|
void onShareContactCancel();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void destroyData();
|
|
|
|
void updateOnlineDisplayIn(int32 msecs);
|
|
|
|
|
|
|
|
void addNewContact(int32 uid, bool show = true);
|
|
|
|
|
|
|
|
bool isActive() const;
|
|
|
|
bool historyIsActive() const;
|
2015-01-26 13:04:41 +00:00
|
|
|
bool lastWasOnline() const;
|
|
|
|
uint64 lastSetOnline() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
int32 dlgsWidth() const;
|
|
|
|
|
2014-12-12 16:27:03 +00:00
|
|
|
void forwardLayer(int32 forwardSelected = 0); // -1 - send paths
|
2014-05-30 08:53:19 +00:00
|
|
|
void deleteLayer(int32 selectedCount = -1); // -1 - context item, else selected, -2 - cancel upload
|
|
|
|
void shareContactLayer(UserData *contact);
|
2015-10-18 12:49:34 +00:00
|
|
|
void shareUrlLayer(const QString &url, const QString &text);
|
2014-12-12 16:27:03 +00:00
|
|
|
void hiderLayer(HistoryHider *h);
|
2014-05-30 08:53:19 +00:00
|
|
|
void noHider(HistoryHider *destroyed);
|
2015-09-07 07:52:37 +00:00
|
|
|
bool onForward(const PeerId &peer, ForwardWhatMessages what);
|
2015-10-18 12:49:34 +00:00
|
|
|
bool onShareUrl(const PeerId &peer, const QString &url, const QString &text);
|
2014-05-30 08:53:19 +00:00
|
|
|
void onShareContact(const PeerId &peer, UserData *contact);
|
2014-07-18 10:37:34 +00:00
|
|
|
void onSendPaths(const PeerId &peer);
|
2015-06-27 13:02:00 +00:00
|
|
|
void onFilesOrForwardDrop(const PeerId &peer, const QMimeData *data);
|
2015-04-04 20:01:34 +00:00
|
|
|
bool selectingPeer(bool withConfirm = false);
|
2014-05-30 08:53:19 +00:00
|
|
|
void offerPeer(PeerId peer);
|
|
|
|
void dialogsActivate();
|
|
|
|
|
2015-06-24 17:24:48 +00:00
|
|
|
DragState getDragState(const QMimeData *mime);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
bool leaveChatFailed(PeerData *peer, const RPCError &e);
|
2015-08-04 15:01:47 +00:00
|
|
|
void deleteHistoryAfterLeave(PeerData *peer, const MTPUpdates &updates);
|
2014-05-30 08:53:19 +00:00
|
|
|
void deleteHistoryPart(PeerData *peer, const MTPmessages_AffectedHistory &result);
|
2015-09-07 07:52:37 +00:00
|
|
|
void deleteMessages(PeerData *peer, const QVector<MTPint> &ids);
|
2014-05-30 08:53:19 +00:00
|
|
|
void deletedContact(UserData *user, const MTPcontacts_Link &result);
|
2015-09-24 08:58:10 +00:00
|
|
|
void deleteConversation(PeerData *peer, bool deleteHistory = true);
|
2014-05-30 08:53:19 +00:00
|
|
|
void clearHistory(PeerData *peer);
|
|
|
|
void removeContact(UserData *user);
|
|
|
|
|
2015-09-16 13:04:08 +00:00
|
|
|
void addParticipants(PeerData *chatOrChannel, const QVector<UserData*> &users);
|
2015-06-15 17:19:24 +00:00
|
|
|
bool addParticipantFail(UserData *user, const RPCError &e);
|
2015-11-02 22:33:57 +00:00
|
|
|
bool addParticipantsFail(ChannelData *channel, const RPCError &e); // for multi invite in channels
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void kickParticipant(ChatData *chat, UserData *user);
|
|
|
|
bool kickParticipantFail(ChatData *chat, const RPCError &e);
|
|
|
|
|
|
|
|
void checkPeerHistory(PeerData *peer);
|
|
|
|
void checkedHistory(PeerData *peer, const MTPmessages_Messages &result);
|
|
|
|
|
2015-09-09 07:46:31 +00:00
|
|
|
bool sendMessageFail(const RPCError &error);
|
2015-01-05 20:17:33 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void forwardSelectedItems();
|
|
|
|
void deleteSelectedItems();
|
|
|
|
void clearSelectedItems();
|
|
|
|
|
|
|
|
DialogsIndexed &contactsList();
|
2015-06-15 17:19:24 +00:00
|
|
|
DialogsIndexed &dialogsList();
|
2014-06-15 12:31:03 +00:00
|
|
|
|
2015-10-23 16:06:56 +00:00
|
|
|
void sendMessage(History *hist, const QString &text, MsgId replyTo, bool broadcast, WebPageId webPageId = 0);
|
2015-03-24 10:00:27 +00:00
|
|
|
void saveRecentHashtags(const QString &text);
|
2014-06-15 12:31:03 +00:00
|
|
|
|
|
|
|
void readServerHistory(History *history, bool force = true);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-11-13 15:14:33 +00:00
|
|
|
uint64 animActiveTime(const HistoryItem *msg) const;
|
2014-07-04 11:12:54 +00:00
|
|
|
void stopAnimActive();
|
|
|
|
|
2015-06-15 17:19:24 +00:00
|
|
|
void sendBotCommand(const QString &cmd, MsgId msgId);
|
2015-06-17 19:43:03 +00:00
|
|
|
void insertBotCommand(const QString &cmd);
|
2015-06-10 15:54:24 +00:00
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void searchMessages(const QString &query, PeerData *inPeer);
|
2014-08-15 11:19:32 +00:00
|
|
|
void preloadOverviews(PeerData *peer);
|
2015-07-03 08:47:16 +00:00
|
|
|
void mediaOverviewUpdated(PeerData *peer, MediaOverviewType type);
|
2014-08-20 19:13:00 +00:00
|
|
|
void changingMsgId(HistoryItem *row, MsgId newId);
|
2014-10-10 12:46:20 +00:00
|
|
|
void itemRemoved(HistoryItem *item);
|
|
|
|
void itemReplaced(HistoryItem *oldItem, HistoryItem *newItem);
|
2015-04-04 20:01:34 +00:00
|
|
|
void itemResized(HistoryItem *row, bool scrollToIt = false);
|
2014-08-15 11:19:32 +00:00
|
|
|
|
|
|
|
void loadMediaBack(PeerData *peer, MediaOverviewType type, bool many = false);
|
2014-10-22 18:39:03 +00:00
|
|
|
void peerUsernameChanged(PeerData *peer);
|
2014-07-16 06:58:36 +00:00
|
|
|
|
2014-11-12 20:30:26 +00:00
|
|
|
void checkLastUpdate(bool afterSleep);
|
2014-11-25 12:15:29 +00:00
|
|
|
void showAddContact();
|
2014-11-18 12:40:43 +00:00
|
|
|
void showNewGroup();
|
2014-11-12 20:30:26 +00:00
|
|
|
|
2015-09-20 08:55:41 +00:00
|
|
|
void serviceNotification(const QString &msg, const MTPMessageMedia &media);
|
2014-12-12 16:27:03 +00:00
|
|
|
void serviceHistoryDone(const MTPmessages_Messages &msgs);
|
|
|
|
bool serviceHistoryFail(const RPCError &error);
|
|
|
|
|
2015-01-26 13:04:41 +00:00
|
|
|
bool isIdle() const;
|
2015-02-03 15:02:46 +00:00
|
|
|
|
|
|
|
void clearCachedBackground();
|
|
|
|
QPixmap cachedBackground(const QRect &forRect, int &x, int &y);
|
|
|
|
void backgroundParams(const QRect &forRect, QRect &to, QRect &from) const;
|
|
|
|
void updateScrollColors();
|
|
|
|
|
|
|
|
void setChatBackground(const App::WallPaper &wp);
|
|
|
|
bool chatBackgroundLoading();
|
|
|
|
void checkChatBackground();
|
|
|
|
ImagePtr newBackgroundThumb();
|
2015-03-19 09:18:19 +00:00
|
|
|
|
|
|
|
ApiWrap *api();
|
|
|
|
void updateReplyTo();
|
2015-06-18 17:24:54 +00:00
|
|
|
void updateBotKeyboard();
|
2015-03-24 10:00:27 +00:00
|
|
|
|
|
|
|
void pushReplyReturn(HistoryItem *item);
|
2015-01-26 13:04:41 +00:00
|
|
|
|
2015-03-24 10:00:27 +00:00
|
|
|
bool hasForwardingItems();
|
|
|
|
void fillForwardingInfo(Text *&from, Text *&text, bool &serviceColor, ImagePtr &preview);
|
|
|
|
void updateForwardingTexts();
|
|
|
|
void cancelForwarding();
|
2015-09-21 20:57:42 +00:00
|
|
|
void finishForwarding(History *hist, bool broadcast); // send them
|
2015-03-24 10:00:27 +00:00
|
|
|
|
2015-04-30 13:53:36 +00:00
|
|
|
void audioMarkRead(AudioData *data);
|
|
|
|
void videoMarkRead(VideoData *data);
|
|
|
|
void mediaMarkRead(const HistoryItemsMap &items);
|
|
|
|
|
2015-04-07 23:03:32 +00:00
|
|
|
void webPageUpdated(WebPageData *page);
|
2015-04-30 13:53:36 +00:00
|
|
|
void updateMutedIn(int32 seconds);
|
2015-04-07 23:03:32 +00:00
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
void updateStickers();
|
2015-07-03 15:55:22 +00:00
|
|
|
void botCommandsChanged(UserData *bot);
|
2015-05-19 15:46:45 +00:00
|
|
|
|
2015-07-17 19:17:37 +00:00
|
|
|
void choosePeer(PeerId peerId, MsgId showAtMsgId); // does offerPeer or showPeerHistory
|
|
|
|
void clearBotStartToken(PeerData *peer);
|
|
|
|
|
2015-09-07 15:53:46 +00:00
|
|
|
void contactsReceived();
|
|
|
|
|
2015-09-13 08:41:27 +00:00
|
|
|
void ptsWaiterStartTimerFor(ChannelData *channel, int32 ms); // ms <= 0 - stop timer
|
2015-09-21 20:57:42 +00:00
|
|
|
void feedUpdates(const MTPUpdates &updates, uint64 randomId = 0);
|
2015-09-13 08:41:27 +00:00
|
|
|
void feedUpdate(const MTPUpdate &update);
|
2015-09-12 19:00:56 +00:00
|
|
|
void updateAfterDrag();
|
2015-09-13 08:41:27 +00:00
|
|
|
|
2015-09-16 13:04:08 +00:00
|
|
|
void ctrlEnterSubmitUpdated();
|
|
|
|
void setInnerFocus();
|
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void scheduleViewIncrement(HistoryItem *item);
|
|
|
|
|
2015-09-19 09:13:21 +00:00
|
|
|
HistoryItem *atTopImportantMsg(int32 &bottomUnderScrollTop) const;
|
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void gotRangeDifference(ChannelData *channel, const MTPupdates_ChannelDifference &diff);
|
|
|
|
void onSelfParticipantUpdated(ChannelData *channel);
|
|
|
|
|
2015-10-01 14:05:05 +00:00
|
|
|
bool contentOverlapped(const QRect &globalRect);
|
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
QPixmap grabTopBar();
|
|
|
|
QPixmap grabInner();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
~MainWidget();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
void peerUpdated(PeerData *peer);
|
|
|
|
void peerNameChanged(PeerData *peer, const PeerData::Names &oldNames, const PeerData::NameFirstChars &oldChars);
|
|
|
|
void peerPhotoChanged(PeerData *peer);
|
|
|
|
void dialogRowReplaced(DialogRow *oldRow, DialogRow *newRow);
|
|
|
|
void dialogsUpdated();
|
2015-07-17 19:17:37 +00:00
|
|
|
void showPeerAsync(quint64 peerId, qint32 showAtMsgId);
|
2015-05-19 15:46:45 +00:00
|
|
|
void stickersUpdated();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
2015-04-07 23:03:32 +00:00
|
|
|
void webPagesUpdate();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void videoLoadProgress(mtpFileLoader *loader);
|
|
|
|
void videoLoadFailed(mtpFileLoader *loader, bool started);
|
|
|
|
void videoLoadRetry();
|
|
|
|
void audioLoadProgress(mtpFileLoader *loader);
|
|
|
|
void audioLoadFailed(mtpFileLoader *loader, bool started);
|
|
|
|
void audioLoadRetry();
|
2015-06-30 21:07:05 +00:00
|
|
|
void audioPlayProgress(const AudioMsgId &audioId);
|
2014-05-30 08:53:19 +00:00
|
|
|
void documentLoadProgress(mtpFileLoader *loader);
|
|
|
|
void documentLoadFailed(mtpFileLoader *loader, bool started);
|
|
|
|
void documentLoadRetry();
|
2015-06-30 21:07:05 +00:00
|
|
|
void documentPlayProgress(const SongMsgId &songId);
|
2015-07-03 08:47:16 +00:00
|
|
|
void hidePlayer();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void dialogsCancelled();
|
|
|
|
|
|
|
|
void onParentResize(const QSize &newSize);
|
|
|
|
void getDifference();
|
2015-09-13 08:41:27 +00:00
|
|
|
void onGetDifferenceTimeByPts();
|
|
|
|
void onGetDifferenceTimeAfterFail();
|
2015-04-16 14:59:42 +00:00
|
|
|
void mtpPing();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-01-26 13:04:41 +00:00
|
|
|
void updateOnline(bool gotOtherOffline = false);
|
|
|
|
void checkIdleFinish();
|
2014-05-30 08:53:19 +00:00
|
|
|
void updateOnlineDisplay();
|
|
|
|
|
2015-07-17 19:17:37 +00:00
|
|
|
void showPeerHistory(quint64 peer, qint32 msgId, bool back = false);
|
2014-05-30 08:53:19 +00:00
|
|
|
void onTopBarClick();
|
2015-10-03 10:09:09 +00:00
|
|
|
void onHistoryShown(History *history, MsgId atMsgId);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-08-04 15:01:47 +00:00
|
|
|
void searchInPeer(PeerData *peer);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void onUpdateNotifySettings();
|
|
|
|
|
2014-08-21 12:18:56 +00:00
|
|
|
void onPhotosSelect();
|
|
|
|
void onVideosSelect();
|
2015-10-23 19:24:05 +00:00
|
|
|
void onSongsSelect();
|
2014-08-21 12:18:56 +00:00
|
|
|
void onDocumentsSelect();
|
|
|
|
void onAudiosSelect();
|
2015-08-28 15:15:56 +00:00
|
|
|
void onLinksSelect();
|
2014-08-21 12:18:56 +00:00
|
|
|
|
2014-12-12 16:27:03 +00:00
|
|
|
void onForwardCancel(QObject *obj = 0);
|
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
void onCacheBackground();
|
|
|
|
|
2015-04-30 13:53:36 +00:00
|
|
|
void onInviteImport();
|
|
|
|
|
|
|
|
void onUpdateMuted();
|
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
void onStickersInstalled(uint64 setId);
|
2015-09-21 20:57:42 +00:00
|
|
|
void onFullPeerUpdated(PeerData *peer);
|
|
|
|
|
|
|
|
void onViewsIncrement();
|
2015-09-25 07:47:32 +00:00
|
|
|
void onActiveChannelUpdateFull();
|
2015-05-19 15:46:45 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
private:
|
|
|
|
|
2015-09-06 10:17:09 +00:00
|
|
|
void sendReadRequest(PeerData *peer, MsgId upTo);
|
|
|
|
void channelWasRead(PeerData *peer, const MTPBool &result);
|
2015-10-29 19:10:49 +00:00
|
|
|
void historyWasRead(PeerData *peer, const MTPmessages_AffectedMessages &result);
|
2015-09-06 10:17:09 +00:00
|
|
|
bool readRequestFail(PeerData *peer, const RPCError &error);
|
|
|
|
void readRequestDone(PeerData *peer);
|
|
|
|
|
2015-09-07 07:52:37 +00:00
|
|
|
void messagesAffected(PeerData *peer, const MTPmessages_AffectedMessages &result);
|
2015-09-19 09:13:21 +00:00
|
|
|
void overviewLoaded(History *h, const MTPmessages_Messages &msgs, mtpRequestId req);
|
2014-08-15 11:19:32 +00:00
|
|
|
|
2014-12-12 16:27:03 +00:00
|
|
|
bool _started;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
uint64 failedObjId;
|
|
|
|
QString failedFileName;
|
|
|
|
void loadFailed(mtpFileLoader *loader, bool started, const char *retrySlot);
|
|
|
|
|
2015-03-24 10:00:27 +00:00
|
|
|
SelectedItemSet _toForward;
|
|
|
|
Text _toForwardFrom, _toForwardText;
|
|
|
|
int32 _toForwardNameVersion;
|
|
|
|
|
2015-04-07 23:03:32 +00:00
|
|
|
QMap<WebPageId, bool> _webPagesUpdated;
|
|
|
|
QTimer _webPageUpdater;
|
|
|
|
|
2015-04-30 13:53:36 +00:00
|
|
|
SingleTimer _updateMutedTimer;
|
|
|
|
|
2015-09-13 08:41:27 +00:00
|
|
|
enum GetChannelDifferenceFrom {
|
|
|
|
GetChannelDifferenceFromUnknown,
|
|
|
|
GetChannelDifferenceFromPtsGap,
|
|
|
|
GetChannelDifferenceFromFail,
|
|
|
|
};
|
|
|
|
void getChannelDifference(ChannelData *channel, GetChannelDifferenceFrom from = GetChannelDifferenceFromUnknown);
|
2014-05-30 08:53:19 +00:00
|
|
|
void gotDifference(const MTPupdates_Difference &diff);
|
|
|
|
bool failDifference(const RPCError &e);
|
|
|
|
void feedDifference(const MTPVector<MTPUser> &users, const MTPVector<MTPChat> &chats, const MTPVector<MTPMessage> &msgs, const MTPVector<MTPUpdate> &other);
|
|
|
|
void gotState(const MTPupdates_State &state);
|
|
|
|
void updSetState(int32 pts, int32 date, int32 qts, int32 seq);
|
2015-09-13 08:41:27 +00:00
|
|
|
void gotChannelDifference(ChannelData *channel, const MTPupdates_ChannelDifference &diff);
|
|
|
|
bool failChannelDifference(ChannelData *channel, const RPCError &err);
|
|
|
|
void failDifferenceStartTimerFor(ChannelData *channel);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void feedUpdateVector(const MTPVector<MTPUpdate> &updates, bool skipMessageIds = false);
|
2014-05-30 08:53:19 +00:00
|
|
|
void feedMessageIds(const MTPVector<MTPUpdate> &updates);
|
|
|
|
|
|
|
|
void updateReceived(const mtpPrime *from, const mtpPrime *end);
|
|
|
|
bool updateFail(const RPCError &e);
|
|
|
|
|
2015-09-06 10:17:09 +00:00
|
|
|
void usernameResolveDone(QPair<bool, QString> toProfileStartToken, const MTPcontacts_ResolvedPeer &result);
|
2014-12-05 13:44:27 +00:00
|
|
|
bool usernameResolveFail(QString name, const RPCError &error);
|
2014-12-03 13:10:32 +00:00
|
|
|
|
2015-04-30 13:53:36 +00:00
|
|
|
void inviteCheckDone(QString hash, const MTPChatInvite &invite);
|
|
|
|
bool inviteCheckFail(const RPCError &error);
|
|
|
|
QString _inviteHash;
|
|
|
|
void inviteImportDone(const MTPUpdates &result);
|
|
|
|
bool inviteImportFail(const RPCError &error);
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void hideAll();
|
|
|
|
void showAll();
|
|
|
|
|
2014-08-15 11:19:32 +00:00
|
|
|
void overviewPreloaded(PeerData *data, const MTPmessages_Messages &result, mtpRequestId req);
|
|
|
|
bool overviewFailed(PeerData *data, const RPCError &error, mtpRequestId req);
|
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
Animation _a_show;
|
|
|
|
QPixmap _cacheUnder, _cacheOver;
|
|
|
|
anim::ivalue a_coordUnder, a_coordOver;
|
|
|
|
anim::fvalue a_shadow;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
int32 _dialogsWidth;
|
|
|
|
|
|
|
|
DialogsWidget dialogs;
|
|
|
|
HistoryWidget history;
|
|
|
|
ProfileWidget *profile;
|
2014-08-15 11:19:32 +00:00
|
|
|
OverviewWidget *overview;
|
2015-07-03 08:47:16 +00:00
|
|
|
PlayerWidget _player;
|
2014-05-30 08:53:19 +00:00
|
|
|
TopBarWidget _topBar;
|
2014-12-12 16:27:03 +00:00
|
|
|
ConfirmBox *_forwardConfirm; // for narrow mode
|
2015-07-17 19:17:37 +00:00
|
|
|
HistoryHider *_hider;
|
2014-08-15 11:19:32 +00:00
|
|
|
StackItems _stack;
|
2015-07-17 19:17:37 +00:00
|
|
|
PeerData *_peerInStack;
|
|
|
|
MsgId _msgIdInStack;
|
|
|
|
|
2015-07-03 08:47:16 +00:00
|
|
|
int32 _playerHeight;
|
|
|
|
int32 _contentScrollAddToY;
|
|
|
|
|
2014-08-21 12:18:56 +00:00
|
|
|
Dropdown _mediaType;
|
|
|
|
int32 _mediaTypeMask;
|
|
|
|
|
2015-09-13 08:41:27 +00:00
|
|
|
int32 updDate, updQts, updSeq;
|
2014-11-12 20:30:26 +00:00
|
|
|
SingleTimer noUpdatesTimer;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-09-13 08:41:27 +00:00
|
|
|
bool ptsUpdated(int32 pts, int32 ptsCount);
|
|
|
|
bool ptsUpdated(int32 pts, int32 ptsCount, const MTPUpdates &updates);
|
|
|
|
bool ptsUpdated(int32 pts, int32 ptsCount, const MTPUpdate &update);
|
2015-09-20 09:54:22 +00:00
|
|
|
void ptsApplySkippedUpdates();
|
2015-09-13 08:41:27 +00:00
|
|
|
PtsWaiter _ptsWaiter;
|
|
|
|
|
|
|
|
typedef QMap<ChannelData*, uint64> ChannelGetDifferenceTime;
|
|
|
|
ChannelGetDifferenceTime _channelGetDifferenceTimeByPts, _channelGetDifferenceTimeAfterFail;
|
|
|
|
uint64 _getDifferenceTimeByPts, _getDifferenceTimeAfterFail;
|
|
|
|
|
|
|
|
bool getDifferenceTimeChanged(ChannelData *channel, int32 ms, ChannelGetDifferenceTime &channelCurTime, uint64 &curTime);
|
|
|
|
|
|
|
|
SingleTimer _byPtsTimer;
|
|
|
|
|
|
|
|
QMap<int32, MTPUpdates> _bySeqUpdates;
|
|
|
|
SingleTimer _bySeqTimer;
|
|
|
|
|
2015-01-26 13:04:41 +00:00
|
|
|
mtpRequestId _onlineRequest;
|
|
|
|
SingleTimer _onlineTimer, _onlineUpdater, _idleFinishTimer;
|
|
|
|
bool _lastWasOnline;
|
|
|
|
uint64 _lastSetOnline;
|
|
|
|
bool _isIdle;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QSet<PeerData*> updateNotifySettingPeers;
|
2014-11-12 20:30:26 +00:00
|
|
|
SingleTimer updateNotifySettingTimer;
|
2014-06-15 12:31:03 +00:00
|
|
|
|
2015-09-16 21:15:13 +00:00
|
|
|
typedef QMap<PeerData*, QPair<mtpRequestId, MsgId> > ReadRequests;
|
2014-06-15 12:31:03 +00:00
|
|
|
ReadRequests _readRequests;
|
2015-09-06 10:17:09 +00:00
|
|
|
typedef QMap<PeerData*, MsgId> ReadRequestsPending;
|
|
|
|
ReadRequestsPending _readRequestsPending;
|
2014-08-15 11:19:32 +00:00
|
|
|
|
|
|
|
typedef QMap<PeerData*, mtpRequestId> OverviewsPreload;
|
|
|
|
OverviewsPreload _overviewPreload[OverviewCount], _overviewLoad[OverviewCount];
|
2014-11-05 17:43:32 +00:00
|
|
|
|
|
|
|
int32 _failDifferenceTimeout; // growing timeout for getDifference calls, if it fails
|
2015-09-13 08:41:27 +00:00
|
|
|
typedef QMap<ChannelData*, int32> ChannelFailDifferenceTimeout;
|
|
|
|
ChannelFailDifferenceTimeout _channelFailDifferenceTimeout; // growing timeout for getChannelDifference calls, if it fails
|
2014-11-12 20:30:26 +00:00
|
|
|
SingleTimer _failDifferenceTimer;
|
|
|
|
|
|
|
|
uint64 _lastUpdateTime;
|
2015-09-21 20:57:42 +00:00
|
|
|
bool _handlingChannelDifference;
|
2015-02-03 15:02:46 +00:00
|
|
|
|
|
|
|
QPixmap _cachedBackground;
|
|
|
|
QRect _cachedFor, _willCacheFor;
|
|
|
|
int _cachedX, _cachedY;
|
|
|
|
SingleTimer _cacheBackgroundTimer;
|
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
typedef QMap<ChannelData*, bool> UpdatedChannels;
|
|
|
|
UpdatedChannels _updatedChannels;
|
|
|
|
|
|
|
|
typedef QMap<MsgId, bool> ViewsIncrementMap;
|
|
|
|
typedef QMap<PeerData*, ViewsIncrementMap> ViewsIncrement;
|
|
|
|
ViewsIncrement _viewsIncremented, _viewsToIncrement;
|
|
|
|
typedef QMap<PeerData*, mtpRequestId> ViewsIncrementRequests;
|
|
|
|
ViewsIncrementRequests _viewsIncrementRequests;
|
|
|
|
typedef QMap<mtpRequestId, PeerData*> ViewsIncrementByRequest;
|
|
|
|
ViewsIncrementByRequest _viewsIncrementByRequest;
|
|
|
|
SingleTimer _viewsIncrementTimer;
|
|
|
|
void viewsIncrementDone(QVector<MTPint> ids, const MTPVector<MTPint> &result, mtpRequestId req);
|
|
|
|
bool viewsIncrementFail(const RPCError &error, mtpRequestId req);
|
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
App::WallPaper *_background;
|
|
|
|
|
2015-03-19 09:18:19 +00:00
|
|
|
ApiWrap *_api;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|