2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Merged with master.

This commit is contained in:
John Preston
2016-04-01 12:54:32 +04:00
35 changed files with 771 additions and 396 deletions

View File

@@ -174,21 +174,19 @@ namespace App {
return main() ? main()->api() : 0;
}
namespace {
bool loggedOut() {
Window *w(wnd());
if (cHasPasscode()) {
cSetHasPasscode(false);
}
if (audioPlayer()) {
audioPlayer()->stopAndClear();
}
if (w) {
if (Window *w = wnd()) {
w->tempDirDelete(Local::ClearManagerAll);
w->notifyClearFast();
w->setupIntro(true);
}
MainWidget *m(main());
if (m) m->destroyData();
MTP::authed(0);
Local::reset();
@@ -199,13 +197,14 @@ namespace App {
globalNotifyChatsPtr = UnknownNotifySettings;
if (App::uploader()) App::uploader()->clear();
clearStorageImages();
if (w) {
if (Window *w = wnd()) {
w->getTitle()->updateBackButton();
w->updateTitleStatus();
w->getTitle()->resizeEvent(0);
}
return true;
}
} // namespace
void logOut() {
if (MTP::started()) {
@@ -431,13 +430,17 @@ namespace App {
bool showPhone = !isServiceUser(data->id) && !d.is_self() && !d.is_contact() && !d.is_mutual_contact();
bool showPhoneChanged = !isServiceUser(data->id) && !d.is_self() && ((showPhone && data->contact) || (!showPhone && !data->contact));
if (minimal) {
showPhoneChanged = false;
showPhone = !isServiceUser(data->id) && (data->id != peerFromUser(MTP::authedId())) && !data->contact;
}
// see also Local::readPeer
QString pname = (showPhoneChanged || phoneChanged || nameChanged) ? ((showPhone && !phone.isEmpty()) ? formatPhone(phone) : QString()) : data->nameOrPhone;
if (!minimal && d.is_self() && uname != data->username) {
SignalHandlers::setSelfUsername(uname);
SignalHandlers::setCrashAnnotation("Username", uname);
}
data->setName(fname, lname, pname, uname);
if (d.has_photo()) {
@@ -1444,12 +1447,12 @@ namespace App {
PeerData *peerByName(const QString &username) {
QString uname(username.trimmed());
for (PeersData::const_iterator i = peersData.cbegin(), e = peersData.cend(); i != e; ++i) {
if (!i.value()->userName().compare(uname, Qt::CaseInsensitive)) {
return i.value();
for_const (PeerData *peer, peersData) {
if (!peer->userName().compare(uname, Qt::CaseInsensitive)) {
return peer;
}
}
return 0;
return nullptr;
}
void updateImage(ImagePtr &old, ImagePtr now) {
@@ -1855,20 +1858,20 @@ namespace App {
cSetSavedPeers(SavedPeers());
cSetSavedPeersByTime(SavedPeersByTime());
cSetRecentInlineBots(RecentInlineBots());
for (PeersData::const_iterator i = peersData.cbegin(), e = peersData.cend(); i != e; ++i) {
delete *i;
for_const (PeerData *peer, peersData) {
delete peer;
}
peersData.clear();
for (PhotosData::const_iterator i = ::photosData.cbegin(), e = ::photosData.cend(); i != e; ++i) {
delete *i;
for_const (PhotoData *photo, ::photosData) {
delete photo;
}
::photosData.clear();
for (DocumentsData::const_iterator i = ::documentsData.cbegin(), e = ::documentsData.cend(); i != e; ++i) {
delete *i;
for_const (DocumentData *document, ::documentsData) {
delete document;
}
::documentsData.clear();
for (WebPagesData::const_iterator i = webPagesData.cbegin(), e = webPagesData.cend(); i != e; ++i) {
delete *i;
for_const (WebPageData *webpage, webPagesData) {
delete webpage;
}
webPagesData.clear();
if (api()) api()->clearWebPageRequests();