diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index dc1f0baee9..2c17f7b831 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -951,7 +951,7 @@ void AppClass::killDownloadSessions() { } } -void AppClass::photoUpdated(const FullMsgId &msgId, const MTPInputFile &file) { +void AppClass::photoUpdated(const FullMsgId &msgId, bool silent, const MTPInputFile &file) { if (!App::self()) return; QMap::iterator i = photoUpdates.find(msgId); @@ -1040,7 +1040,7 @@ void AppClass::uploadProfilePhoto(const QImage &tosend, const PeerId &peerId) { ReadyLocalMedia ready(PreparePhoto, file, filename, filesize, data, id, id, qsl("jpg"), peerId, photo, photoThumbs, MTP_documentEmpty(MTP_long(0)), jpeg, false, false, 0); - connect(App::uploader(), SIGNAL(photoReady(const FullMsgId&, const MTPInputFile&)), App::app(), SLOT(photoUpdated(const FullMsgId&, const MTPInputFile&)), Qt::UniqueConnection); + connect(App::uploader(), SIGNAL(photoReady(const FullMsgId&,bool,const MTPInputFile&)), App::app(), SLOT(photoUpdated(const FullMsgId&,bool,const MTPInputFile&)), Qt::UniqueConnection); FullMsgId newId(peerToChannel(peerId), clientMsgId()); App::app()->regPhotoUpdate(peerId, newId); diff --git a/Telegram/SourceFiles/application.h b/Telegram/SourceFiles/application.h index d823ab1f2c..acae496077 100644 --- a/Telegram/SourceFiles/application.h +++ b/Telegram/SourceFiles/application.h @@ -191,7 +191,7 @@ public slots: void doMtpUnpause(); - void photoUpdated(const FullMsgId &msgId, const MTPInputFile &file); + void photoUpdated(const FullMsgId &msgId, bool silent, const MTPInputFile &file); void onSwitchDebugMode(); void onSwitchTestMode(); diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index 5330c1331e..492189aa43 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -398,7 +398,7 @@ void MediaView::updateDropdown() { _btnSaveAs->setVisible(true); _btnCopy->setVisible((_doc && fileShown()) || (_photo && _photo->loaded())); _btnForward->setVisible(_canForward); - _btnDelete->setVisible(_canDelete || (_photo && App::self() && App::self()->photoId == _photo->id) || (_photo && _photo->peer && _photo->peer->photoId == _photo->id && (_photo->peer->isChat() || (_photo->peer->isChannel() && _photo->peer->asChannel()->amCreator())))); + _btnDelete->setVisible(_canDelete || (_photo && App::self() && _user == App::self()) || (_photo && _photo->peer && _photo->peer->photoId == _photo->id && (_photo->peer->isChat() || (_photo->peer->isChannel() && _photo->peer->asChannel()->amCreator())))); _btnViewAll->setVisible((_overview != OverviewCount) && _history); _btnViewAll->setText(lang(_doc ? lng_mediaview_files_all : lng_mediaview_photos_all)); _dropdown.updateButtons(); @@ -707,6 +707,21 @@ void MediaView::onDelete() { if (!_msgid) { if (App::self() && _photo && App::self()->photoId == _photo->id) { App::app()->peerClearPhoto(App::self()->id); + } else if (_user && _user == App::self()) { + for (int32 i = 0, l = _user->photos.size(); i != l; ++i) { + if (_user->photos.at(i) == _photo) { + _user->photos.removeAt(i); + MTP::send(MTPphotos_DeletePhotos(MTP_vector(1, MTP_inputPhoto(MTP_long(_photo->id), MTP_long(_photo->access)))), rpcDone(&MediaView::deletePhotosDone), rpcFail(&MediaView::deletePhotosFail)); + if (_user->photos.isEmpty()) { + hide(); + } else if (i + 1 < l) { + showPhoto(_user->photos.at(i), _user); + } else { + showPhoto(_user->photos.at(i - 1), _user); + } + break; + } + } } else if (_photo->peer && _photo->peer->photoId == _photo->id) { App::app()->peerClearPhoto(_photo->peer->id); } @@ -2090,6 +2105,15 @@ void MediaView::userPhotosLoaded(UserData *u, const MTPphotos_Photos &photos, mt if (App::wnd()) App::wnd()->mediaOverviewUpdated(u, OverviewCount); } +void MediaView::deletePhotosDone(const MTPVector &result) { +} + +bool MediaView::deletePhotosFail(const RPCError &error) { + if (mtpIsFlood(error)) return false; + + return true; +} + void MediaView::updateHeader() { int32 index = _index, count = 0, addcount = (_migrated && _overview != OverviewCount) ? _migrated->overviewCount(_overview) : 0; if (_history) { diff --git a/Telegram/SourceFiles/mediaview.h b/Telegram/SourceFiles/mediaview.h index 3007e574eb..1736bcf109 100644 --- a/Telegram/SourceFiles/mediaview.h +++ b/Telegram/SourceFiles/mediaview.h @@ -107,7 +107,9 @@ private: void loadBack(); void userPhotosLoaded(UserData *u, const MTPphotos_Photos &photos, mtpRequestId req); - void filesLoaded(History *h, const MTPmessages_Messages &msgs, mtpRequestId req); + + void deletePhotosDone(const MTPVector &result); + bool deletePhotosFail(const RPCError &error); void updateHeader(); void snapXY(); diff --git a/Telegram/SourceFiles/mtproto/mtpConnection.cpp b/Telegram/SourceFiles/mtproto/mtpConnection.cpp index 3da8619852..9e0e10a49c 100644 --- a/Telegram/SourceFiles/mtproto/mtpConnection.cpp +++ b/Telegram/SourceFiles/mtproto/mtpConnection.cpp @@ -2054,8 +2054,8 @@ void MTProtoConnectionPrivate::socketStart(bool afterConfig) { _pingId = _pingMsgId = _pingIdToSend = _pingSendAt = 0; _pingSender.stop(); - if (!noIPv4) DEBUG_LOG(("MTP Info: creating IPv4 connection to %1:%2 (tcp) and %1:%2 (http)..").arg(ip[IPv4address][TcpProtocol].c_str()).arg(port[IPv4address][TcpProtocol]).arg(ip[IPv4address][HttpProtocol].c_str()).arg(port[IPv4address][HttpProtocol])); - if (!noIPv6) DEBUG_LOG(("MTP Info: creating IPv6 connection to [%1]:%2 (tcp) and [%1]:%2 (http)..").arg(ip[IPv6address][TcpProtocol].c_str()).arg(port[IPv6address][TcpProtocol]).arg(ip[IPv4address][HttpProtocol].c_str()).arg(port[IPv4address][HttpProtocol])); + if (!noIPv4) DEBUG_LOG(("MTP Info: creating IPv4 connection to %1:%2 (tcp) and %3:%4 (http)..").arg(ip[IPv4address][TcpProtocol].c_str()).arg(port[IPv4address][TcpProtocol]).arg(ip[IPv4address][HttpProtocol].c_str()).arg(port[IPv4address][HttpProtocol])); + if (!noIPv6) DEBUG_LOG(("MTP Info: creating IPv6 connection to [%1]:%2 (tcp) and [%3]:%4 (http)..").arg(ip[IPv6address][TcpProtocol].c_str()).arg(port[IPv6address][TcpProtocol]).arg(ip[IPv4address][HttpProtocol].c_str()).arg(port[IPv4address][HttpProtocol])); _waitForConnectedTimer.start(_waitForConnected); if (_conn4) {