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.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2014-12-01 10:47:38 +00:00
|
|
|
Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QtNetwork/QLocalSocket>
|
|
|
|
#include <QtNetwork/QLocalServer>
|
|
|
|
#include <QtNetwork/QNetworkReply>
|
|
|
|
|
|
|
|
#include "window.h"
|
|
|
|
#include "pspecific.h"
|
|
|
|
|
|
|
|
class MainWidget;
|
|
|
|
class FileUploader;
|
2015-01-05 20:19:05 +00:00
|
|
|
class Translator;
|
2015-06-03 18:13:01 +00:00
|
|
|
class UpdateDownloader;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
class Application : public PsApplication, public RPCSender {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-06-14 19:32:11 +00:00
|
|
|
Application(int &argc, char **argv);
|
2014-05-30 08:53:19 +00:00
|
|
|
~Application();
|
|
|
|
|
|
|
|
static Application *app();
|
|
|
|
static Window *wnd();
|
2014-12-18 18:40:49 +00:00
|
|
|
static QString language();
|
2014-12-19 21:20:30 +00:00
|
|
|
static int32 languageId();
|
2014-05-30 08:53:19 +00:00
|
|
|
static MainWidget *main();
|
|
|
|
|
|
|
|
enum UpdatingState {
|
|
|
|
UpdatingNone,
|
|
|
|
UpdatingDownload,
|
|
|
|
UpdatingReady,
|
|
|
|
};
|
|
|
|
UpdatingState updatingState();
|
|
|
|
int32 updatingSize();
|
|
|
|
int32 updatingReady();
|
|
|
|
|
|
|
|
FileUploader *uploader();
|
|
|
|
void uploadProfilePhoto(const QImage &tosend, const PeerId &peerId);
|
|
|
|
void regPhotoUpdate(const PeerId &peer, MsgId msgId);
|
|
|
|
void clearPhotoUpdates();
|
|
|
|
bool isPhotoUpdating(const PeerId &peer);
|
|
|
|
void cancelPhotoUpdate(const PeerId &peer);
|
|
|
|
|
|
|
|
void stopUpdate();
|
|
|
|
|
|
|
|
void selfPhotoCleared(const MTPUserProfilePhoto &result);
|
2015-04-02 10:33:19 +00:00
|
|
|
void chatPhotoCleared(PeerId peer, const MTPUpdates &updates);
|
2014-05-30 08:53:19 +00:00
|
|
|
void selfPhotoDone(const MTPphotos_Photo &result);
|
2015-04-02 10:33:19 +00:00
|
|
|
void chatPhotoDone(PeerId peerId, const MTPUpdates &updates);
|
2014-05-30 08:53:19 +00:00
|
|
|
bool peerPhotoFail(PeerId peerId, const RPCError &e);
|
|
|
|
void peerClearPhoto(PeerId peer);
|
|
|
|
|
|
|
|
void writeUserConfigIn(uint64 ms);
|
|
|
|
|
2014-10-30 16:23:44 +00:00
|
|
|
void killDownloadSessionsStart(int32 dc);
|
|
|
|
void killDownloadSessionsStop(int32 dc);
|
|
|
|
|
2014-11-12 20:30:26 +00:00
|
|
|
void checkLocalTime();
|
2015-03-02 12:34:16 +00:00
|
|
|
void checkMapVersion();
|
2014-11-12 20:30:26 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
signals:
|
|
|
|
|
2015-06-03 18:13:01 +00:00
|
|
|
void updateChecking();
|
|
|
|
void updateLatest();
|
|
|
|
void updateDownloading(qint64 ready, qint64 total);
|
|
|
|
void updateReady();
|
|
|
|
void updateFailed();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void peerPhotoDone(PeerId peer);
|
|
|
|
void peerPhotoFail(PeerId peer);
|
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
void adjustSingleTimers();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void startUpdateCheck(bool forceWait = false);
|
|
|
|
void socketConnected();
|
|
|
|
void socketError(QLocalSocket::LocalSocketError e);
|
|
|
|
void socketDisconnected();
|
|
|
|
void socketWritten(qint64 bytes);
|
|
|
|
void socketReading();
|
|
|
|
void newInstanceConnected();
|
|
|
|
void closeApplication();
|
|
|
|
|
|
|
|
void readClients();
|
|
|
|
void removeClients();
|
|
|
|
|
|
|
|
void updateGotCurrent();
|
|
|
|
void updateFailedCurrent(QNetworkReply::NetworkError e);
|
|
|
|
|
|
|
|
void onUpdateReady();
|
|
|
|
void onUpdateFailed();
|
|
|
|
|
|
|
|
void photoUpdated(MsgId msgId, const MTPInputFile &file);
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
void onSwitchDebugMode();
|
|
|
|
void onSwitchTestMode();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-10-30 16:23:44 +00:00
|
|
|
void killDownloadSessions();
|
2014-11-12 20:30:26 +00:00
|
|
|
void onAppStateChanged(Qt::ApplicationState state);
|
2014-10-30 16:23:44 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
QMap<MsgId, PeerId> photoUpdates;
|
|
|
|
|
2014-10-30 16:23:44 +00:00
|
|
|
QMap<int32, uint64> killDownloadSessionTimes;
|
2014-11-12 20:30:26 +00:00
|
|
|
SingleTimer killDownloadSessionsTimer;
|
2014-10-30 16:23:44 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void startApp();
|
|
|
|
|
|
|
|
typedef QPair<QLocalSocket*, QByteArray> ClientSocket;
|
|
|
|
typedef QVector<ClientSocket> ClientSockets;
|
|
|
|
|
|
|
|
QString serverName;
|
|
|
|
QLocalSocket socket;
|
|
|
|
QString socketRead;
|
|
|
|
QLocalServer server;
|
|
|
|
ClientSockets clients;
|
|
|
|
bool closing;
|
|
|
|
|
2015-01-26 13:04:41 +00:00
|
|
|
uint64 lastActionTime;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void execExternal(const QString &cmd);
|
|
|
|
|
|
|
|
Window *window;
|
|
|
|
|
|
|
|
mtpRequestId updateRequestId;
|
|
|
|
QNetworkAccessManager updateManager;
|
|
|
|
QNetworkReply *updateReply;
|
2014-11-12 20:30:26 +00:00
|
|
|
SingleTimer updateCheckTimer;
|
2014-05-30 08:53:19 +00:00
|
|
|
QThread *updateThread;
|
2015-06-03 18:13:01 +00:00
|
|
|
UpdateDownloader *updateDownloader;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QTimer writeUserConfigTimer;
|
2014-11-18 12:40:43 +00:00
|
|
|
|
2015-01-05 20:19:05 +00:00
|
|
|
Translator *_translator;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|