summaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
AgeCommit message (Expand)Author
2014-08-08mm: memcontrol: rewrite uncharge APIJohannes Weiner
2014-08-08mm: memcontrol: rewrite charge APIJohannes Weiner
2014-06-04mm/swapfile.c: delete the "last_in_cluster < scan_base" loop in the body of s...Chen Yucong
2014-06-04swap: change swap_list_head to plist, add swap_avail_headDan Streetman
2014-06-04swap: change swap_info singly-linked list to list_headDan Streetman
2014-02-06mm/swap: fix race on swap_info reuse between swapoff and swaponWeijie Yang
2014-01-23mm/swapfile.c: do not skip lowest_bit in scan_swap_map() scan loopJamie Liu
2014-01-23mm: dump page when hitting a VM_BUG_ON using VM_BUG_ON_PAGESasha Levin
2013-11-13frontswap: enable call to invalidate area on swapoffKrzysztof Kozlowski
2013-11-13-rwxr-xr-xTelegram/DeployLinux.sh4
-rw
2013-09-11swap: make cluster allocation per-cpuShaohua Li
2013-09-11swap: fix races exposed by swap discardShaohua Li
2013-09-11swap: make swap discard asyncShaohua Li
2013-09-11swap: change block allocation algorithm for SSDShaohua Li
2013-09-11mm/swapfile.c: convert to pr_foo()Andrew Morton
2013-09-11swap: warn when a swap area overflows the maximum sizeRaymond Jennings
2013-08-13mm: save soft-dirty bits on swapped pagesCyrill Gorcunov
2013-07-03swap: discard while swapping only if SWAP_FLAG_DISCARD_PAGESRafael Aquini
2013-06-12frontswap: fix incorrect zeroing and allocation size for frontswap_mapAkinobu Mita
2013-04-30frontswap: get rid of swap_lock dependencyMinchan Kim
2013-04-29mm/: rename random32() to prandom_u32()Akinobu Mita
2013-02-26Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/vir...Linus Torvalds
2013-02-23mm,ksm: swapoff might need to copyHugh Dickins
2013-02-23swap: add per-partition lock for swapfileShaohua Li
2013-02-23swap: make each swap partition have one address_spaceShaohua Li
2013-02-22new helper: file_inode(file)Al Viro
2012-12-11mm, oom: fix race when specifying a thread as the oom originDavid Rientjes
2012-12-11mm, oom: change type of oom_score_adj to shortDavid Rientjes
2012-12-11mm: do not call frontswap_init() during swapoffCesar Eduardo Barros
2012-12-11mm: refactor reinsert of swap_info in sys_swapoff()Cesar Eduardo Barros
2012-11-16swapfile: fix name leak in swapoffXiaotian Feng
2012-10-12vfs: make path_openat take a struct filename pointerJeff Layton
2012-10-12vfs: define struct filename and have getname() return itJeff Layton
2012-07-31mm: swapfile: clean up unuse_pte race handlingJohannes Weiner
2012-07-31swapfile: avoid dereferencing bd_disk during swap_entry_free for network storageMel Gorman
2012-07-31mm: swap: implement generic handler for swap_activateMel Gorman
2012-07-31mm: add support for a filesystem to activate swap files and use direct_IO for...Mel Gorman
2012-07-31mm: methods for teaching filesystems about PG_swapcache pagesMel Gorman
2012-06-15swap: fix shmem swapping when more than 8 areasHugh Dickins
2012-06-04Merge tag 'stable/frontswap.v16-tag' of git://git.kernel.org/pub/scm/linux/ke...Linus Torvalds
2012-05-29memcg: fix/change behavior of shared anon at moving taskKAMEZAWA Hiroyuki
2012-05-29shmem: replace page if mapping excludes its zoneHugh Dickins
2012-05-15mm: frontswap: core swap subsystem hooks and headersDan Magenheimer
2012-03-28swapon: check validity of swap_flagsHugh Dickins
2012-03-22Merge branch 'akpm' (Andrew's patch-bomb)Linus Torvalds
2012-03-21swap: don't do discard if no discard option addedShaohua Li
2012-03-21mm: make swapin readahead skip over holesRik van Riel
2012-03-21mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read modeAndrea Arcangeli
2012-03-21Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/...Linus Torvalds
>10
-rw-r--r--Telegram/SourceFiles/mediaview.cpp2
-rw-r--r--Telegram/SourceFiles/mtproto/mtp.cpp26
-rw-r--r--Telegram/SourceFiles/mtproto/mtp.h3
-rw-r--r--Telegram/SourceFiles/mtproto/mtpAuthKey.h10
-rw-r--r--Telegram/SourceFiles/mtproto/mtpConnection.cpp19
-rw-r--r--Telegram/SourceFiles/mtproto/mtpConnection.h2
-rw-r--r--Telegram/SourceFiles/mtproto/mtpDC.cpp8
-rw-r--r--Telegram/SourceFiles/mtproto/mtpFileLoader.cpp58
-rw-r--r--Telegram/SourceFiles/mtproto/mtpFileLoader.h4
-rw-r--r--Telegram/SourceFiles/mtproto/mtpSession.cpp14
-rw-r--r--Telegram/SourceFiles/mtproto/mtpSession.h7
-rw-r--r--Telegram/SourceFiles/profilewidget.cpp4
-rw-r--r--Telegram/SourceFiles/settingswidget.cpp88
-rw-r--r--Telegram/SourceFiles/settingswidget.h11
-rw-r--r--Telegram/SourceFiles/types.cpp33
-rw-r--r--Telegram/SourceFiles/types.h34
-rw-r--r--Telegram/SourceFiles/window.cpp76
-rw-r--r--Telegram/SourceFiles/window.h32
-rw-r--r--Telegram/Telegram.plist2
-rw-r--r--Telegram/Telegram.pro2
-rw-r--r--Telegram/Telegram.rcbin5550 -> 5550 bytes-rw-r--r--Telegram/Telegram.vcxproj27
-rw-r--r--Telegram/Telegram.vcxproj.filters15
-rw-r--r--Telegram/Telegram.xcodeproj/project.pbxproj12
51 files changed, 1748 insertions, 363 deletions
diff --git a/Telegram/DeployLinux.sh b/Telegram/DeployLinux.sh
index 6b7c5e1dcb..8e3d2b69ac 100755
--- a/Telegram/DeployLinux.sh
+++ b/Telegram/DeployLinux.sh
@@ -1,5 +1,5 @@
-AppVersionStr=0.6.11
-AppVersion=6011
+AppVersionStr=0.6.12
+AppVersion=6012
if [ ! -f "./../Linux/Release/deploy/$AppVersionStr/tlinuxupd$AppVersion" ]; then
echo "tlinuxupd$AppVersion not found!";
diff --git a/Telegram/DeployLinux32.sh b/Telegram/DeployLinux32.sh
index a854aed8e7..653b71f940 100755
--- a/Telegram/DeployLinux32.sh
+++ b/Telegram/DeployLinux32.sh
@@ -1,5 +1,5 @@
-AppVersionStr=0.6.11
-AppVersion=6011
+AppVersionStr=0.6.12
+AppVersion=6012
if [ ! -f "./../Linux/Release/deploy/$AppVersionStr/tlinux32upd$AppVersion" ]; then
echo "tlinux32upd$AppVersion not found!"
diff --git a/Telegram/DeployMacWin.sh b/Telegram/DeployMacWin.sh
index acf1d13112..a62c5b23a1 100755
--- a/Telegram/DeployMacWin.sh
+++ b/Telegram/DeployMacWin.sh
@@ -1,5 +1,5 @@
-AppVersionStr=0.6.11
-AppVersion=6011
+AppVersionStr=0.6.12
+AppVersion=6012
if [ ! -f "./../Mac/Release/deploy/$AppVersionStr/tmacupd$AppVersion" ]; then
echo "tmacupd$AppVersion not found!"
diff --git a/Telegram/DeployWin.sh b/Telegram/DeployWin.sh
index 490a2257b1..f020dfad1a 100644
--- a/Telegram/DeployWin.sh
+++ b/Telegram/DeployWin.sh
@@ -1,5 +1,5 @@
-AppVersionStr=0.6.11
-AppVersion=6011
+AppVersionStr=0.6.12
+AppVersion=6012
if [ ! -f "./../Win32/Deploy/deploy/$AppVersionStr/tupdate$AppVersion" ]; then
echo "tupdate$AppVersion not found!"
diff --git a/Telegram/PrepareLinux.sh b/Telegram/PrepareLinux.sh
index 9c459b8b78..c23dec9f78 100755
--- a/Telegram/PrepareLinux.sh
+++ b/Telegram/PrepareLinux.sh
@@ -1,5 +1,5 @@
-AppVersionStr=0.6.11
-AppVersion=6011
+AppVersionStr=0.6.12
+AppVersion=6012
if [ -d "./../Linux/Release/deploy/$AppVersionStr" ]; then
echo "Deploy folder for version $AppVersionStr already exists!"
diff --git a/Telegram/PrepareLinux32.sh b/Telegram/PrepareLinux32.sh
index 273c89e132..5141fbf8ee 100755
--- a/Telegram/PrepareLinux32.sh
+++ b/Telegram/PrepareLinux32.sh
@@ -1,5 +1,5 @@
-AppVersionStr=0.6.11
-AppVersion=6011
+AppVersionStr=0.6.12
+AppVersion=6012
if [ -d "./../Linux/Release/deploy/$AppVersionStr" ]; then
echo "Deploy folder for version $AppVersionStr already exists!"
diff --git a/Telegram/PrepareMac.sh b/Telegram/PrepareMac.sh
index 3b29a36192..5bc207d648 100755
--- a/Telegram/PrepareMac.sh
+++ b/Telegram/PrepareMac.sh
@@ -1,5 +1,5 @@
-AppVersionStr=0.6.11
-AppVersion=6011
+AppVersionStr=0.6.12
+AppVersion=6012
echo ""
echo "Preparing version $AppVersionStr.."
diff --git a/Telegram/PrepareWin.bat b/Telegram/PrepareWin.bat
index 4e508f9d3d..1bebd5525e 100644
--- a/Telegram/PrepareWin.bat
+++ b/Telegram/PrepareWin.bat
@@ -1,6 +1,6 @@
@echo OFF
-set "AppVersionStr=0.6.11"
+set "AppVersionStr=0.6.12"
echo.
echo Preparing version %AppVersionStr%..
echo.
diff --git a/Telegram/Resources/lang.txt b/Telegram/Resources/lang.txt
index 4b5e00eca1..ed7728c456 100644
--- a/Telegram/Resources/lang.txt
+++ b/Telegram/Resources/lang.txt
@@ -62,6 +62,7 @@ lng_connecting: "Connecting..";
lng_reconnecting: "Reconnect in %1 s..";
lng_reconnecting_try_now: "Try now";
+lng_status_service_notifications: "service notifications";
lng_status_offline: "last seen a long time ago";
lng_status_recently: "last seen recently";
lng_status_last_week: "last seen within a week";
@@ -219,6 +220,15 @@ lng_download_path_clearing: "Clearing..";
lng_download_path_cleared: "Cleared!";
lng_download_path_clear_failed: "Clear failed :(";
+lng_settings_section_cache: "Local storage";
+lng_settings_no_images_cached: "No cached images found!";
+lng_settings_image_cached: "Cached: {count} image, {size}";
+lng_settings_images_cached: "Cached: {count} images, {size}";
+lng_local_images_clear: "Clear All";
+lng_local_images_clearing: "Clearing..";
+lng_local_images_cleared: "Cleared!";
+lng_local_images_clear_failed: "Clear failed :(";
+
lng_settings_section_advanced: "Advanced";
lng_connection_type: "Connection type:";
lng_connection_auto_connecting: "Default (connecting..)";
diff --git a/Telegram/Setup.iss b/Telegram/Setup.iss
index a2e31eca87..7ea4ed9353 100644
--- a/Telegram/Setup.iss
+++ b/Telegram/Setup.iss
@@ -3,9 +3,9 @@
#define MyAppShortName "Telegram"
#define MyAppName "Telegram Desktop"
-#define MyAppVersion "0.6.11"
-#define MyAppVersionZero "0.6.11"
-#define MyAppFullVersion "0.6.11.0"
+#define MyAppVersion "0.6.12"
+#define MyAppVersionZero "0.6.12"
+#define MyAppFullVersion "0.6.12.0"
#define MyAppPublisher "Telegram Messenger LLP"
#define MyAppURL "https://tdesktop.com"
#define MyAppExeName "Telegram.exe"
diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp
index 9db1120c5a..23484b6762 100644
--- a/Telegram/SourceFiles/app.cpp
+++ b/Telegram/SourceFiles/app.cpp
@@ -26,6 +26,8 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
#include "mainwidget.h"
#include <libexif/exif-data.h>
+#include "localstorage.h"
+
namespace {
bool quiting = false;
@@ -114,7 +116,7 @@ namespace App {
bool loggedOut() {
Window *w(wnd());
if (w) {
- w->tempDirDelete();
+ w->tempDirDelete(Local::ClearManagerAll);
w->notifyClearFast();
w->setupIntro(true);
}
@@ -170,7 +172,7 @@ namespace App {
switch (online) {
case -2: {
QDate yesterday(date(now).date());
- yesterday.addDays(-1);
+ yesterday.addDays(-3);
return int32(QDateTime(yesterday).toTime_t());
} break;
@@ -207,7 +209,11 @@ namespace App {
return dNow.secsTo(dTomorrow);
}
- QString onlineText(int32 online, int32 now, bool precise) {
+ QString onlineText(UserData *user, int32 now, bool precise) {
+ if (isServiceUser(user->id)) {
+ return lang(lng_status_service_notifications);
+ }
+ int32 online = user->onlineTill;
if (online <= 0) {
switch (online) {
case 0: return lang(lng_status_offline);
@@ -337,7 +343,7 @@ namespace App {
data->input = MTP_inputPeerForeign(d.vid, d.vaccess_hash);
data->inputUser = MTP_inputUserForeign(d.vid, d.vaccess_hash);
data->setPhone(qs(d.vphone));
- data->setName(textOneLine(qs(d.vfirst_name)), textOneLine(qs(d.vlast_name)), (data->id != 333000 && !data->phone.isEmpty()) ? formatPhone(data->phone) : QString(), textOneLine(qs(d.vusername)));
+ data->setName(textOneLine(qs(d.vfirst_name)), textOneLine(qs(d.vlast_name)), (!isServiceUser(data->id) && !data->phone.isEmpty()) ? formatPhone(data->phone) : QString(), textOneLine(qs(d.vusername)));
data->setPhoto(d.vphoto);
data->access = d.vaccess_hash.v;
wasContact = (data->contact > 0);
@@ -683,7 +689,7 @@ namespace App {
App::main()->removeContact(user);
}
}
- user->setName(textOneLine(user->firstName), textOneLine(user->lastName), (user->contact || user->id == 333000 || user->phone.isEmpty()) ? QString() : App::formatPhone(user->phone), textOneLine(user->username));
+ user->setName(textOneLine(user->firstName), textOneLine(user->lastName), (user->contact || isServiceUser(user->id) || user->phone.isEmpty()) ? QString() : App::formatPhone(user->phone), textOneLine(user->username));
if (App::main()) App::main()->peerUpdated(user);
}
}
@@ -1103,7 +1109,6 @@ namespace App {
result = new ImageLinkData(imageLink);
imageLinksData.insert(imageLink, result);
result->type = type;
- result->openl = TextLinkPtr(new TextLink(url));
} else {
result = i.value();
}
@@ -1655,7 +1660,7 @@ namespace App {
}
QByteArray encrypted(16 + fullSize, Qt::Uninitialized); // 128bit of sha1 - key128, sizeof(data), data
hashSha1(toEncrypt.constData(), toEncrypt.size(), encrypted.data());
- aesEncryptLocal(toEncrypt.constData(), encrypted.data() + 16, fullSize, &MTP::localKey(), encrypted.constData());
+ aesEncryptLocal(toEncrypt.constData(), encrypted.data() + 16, fullSize, &Local::oldKey(), encrypted.constData());
DEBUG_LOG(("App Info: writing user config file"));
QDataStream configStream(&configFile);
@@ -1706,7 +1711,7 @@ namespace App {
}
cSetLocalSalt(salt);
- MTP::createLocalKey(QByteArray(), &salt);
+ Local::createOldKey(&salt);
if (data.size() <= 16 || (data.size() & 0x0F)) {
LOG(("App Error: bad encrypted part size: %1").arg(data.size()));
@@ -1715,7 +1720,7 @@ namespace App {
uint32 fullDataLen = data.size() - 16;
decrypted.resize(fullDataLen);
const char *dataKey = data.constData(), *encrypted = data.constData() + 16;
- aesDecryptLocal(encrypted, decrypted.data(), fullDataLen, &MTP::localKey(), dataKey);
+ aesDecryptLocal(encrypted, decrypted.data(), fullDataLen, &Local::oldKey(), dataKey);
uchar sha1Buffer[20];
if (memcmp(hashSha1(decrypted.constData(), decrypted.size(), sha1Buffer), dataKey, 16)) {
LOG(("App Error: bad decrypt key, data from user-config not decrypted"));
@@ -1942,7 +1947,6 @@ namespace App {
::quiting = true;
}
-
QImage readImage(QByteArray data, QByteArray *format) {
QByteArray tmpFormat;
QImage result;
diff --git a/Telegram/SourceFiles/app.h b/Telegram/SourceFiles/app.h
index 587656aee5..0b5fa18a1d 100644
--- a/Telegram/SourceFiles/app.h
+++ b/Telegram/SourceFiles/app.h
@@ -65,7 +65,7 @@ namespace App {
int32 onlineForSort(int32 online, int32 now);
int32 onlineWillChangeIn(int32 onlineOnServer, int32 nowOnServer);
- QString onlineText(int32 onlineOnServer, int32 nowOnServer, bool precise = false);
+ QString onlineText(UserData *user, int32 nowOnServer, bool precise = false);
void feedUsers(const MTPVector<MTPUser> &users);
void feedChats(const MTPVector<MTPChat> &chats);
diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp
index 2b2306fdb4..c47573876d 100644
--- a/Telegram/SourceFiles/application.cpp
+++ b/Telegram/SourceFiles/application.cpp
@@ -28,6 +28,8 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
#include "boxes/confirmbox.h"
#include "langloaderplain.h"
+#include "localstorage.h"
+
namespace {
Application *mainApp = 0;
FileUploader *uploader = 0;
@@ -131,6 +133,7 @@ Application::Application(int &argc, char **argv) : PsApplication(argc, argv),
}
}
+ Local::start();
style::startManager();
anim::startManager();
historyInit();
@@ -617,9 +620,11 @@ void Application::socketError(QLocalSocket::LocalSocketError e) {
}
void Application::startApp() {
+ Local::ReadMapState state = Local::readMap(QByteArray());
+
App::readUserConfig();
- if (!MTP::localKey().created()) {
- MTP::createLocalKey(QByteArray());
+ if (!Local::oldKey().created()) {
+ Local::createOldKey();
cSetNeedConfigResave(true);
}
if (cNeedConfigResave()) {
@@ -765,6 +770,7 @@ Application::~Application() {
delete window;
style::stopManager();
+ Local::stop();
}
Application *Application::app() {
diff --git a/Telegram/SourceFiles/application.h b/Telegram/SourceFiles/application.h
index 05266a4218..84f8051a58 100644
--- a/Telegram/SourceFiles/application.h
+++ b/Telegram/SourceFiles/application.h
@@ -80,6 +80,8 @@ signals:
void peerPhotoDone(PeerId peer);
void peerPhotoFail(PeerId peer);
+ void adjustSingleTimers();
+
public slots:
void startUpdateCheck(bool forceWait = false);
diff --git a/Telegram/SourceFiles/boxes/addparticipantbox.cpp b/Telegram/SourceFiles/boxes/addparticipantbox.cpp
index c1e02dffe3..9dd608367d 100644
--- a/Telegram/SourceFiles/boxes/addparticipantbox.cpp
+++ b/Telegram/SourceFiles/boxes/addparticipantbox.cpp
@@ -118,7 +118,7 @@ AddParticipantInner::ContactData *AddParticipantInner::contactData(DialogRow *ro
data->inchat = _chat->participants.constFind(user) != _chat->participants.cend();
data->check = false;
data->name.setText(st::profileListNameFont, user->name, _textNameOptions);
- data->online = App::onlineText(user->onlineTill, _time);
+ data->online = App::onlineText(user, _time);
} else {
data = i.value();
}
diff --git a/Telegram/SourceFiles/boxes/contactsbox.cpp b/Telegram/SourceFiles/boxes/contactsbox.cpp
index f7a31bfce0..c98c83c4e7 100644
--- a/Telegram/SourceFiles/boxes/contactsbox.cpp
+++ b/Telegram/SourceFiles/boxes/contactsbox.cpp
@@ -98,7 +98,7 @@ ContactsInner::ContactData *ContactsInner::contactData(DialogRow *row) {
if (i == _contactsData.cend()) {
_contactsData.insert(user, data = new ContactData());
data->name.setText(st::profileListNameFont, user->name, _textNameOptions);
- data->online = App::onlineText(user->onlineTill, _time);
+ data->online = App::onlineText(user, _time);
} else {
data = i.value();
}
diff --git a/Telegram/SourceFiles/boxes/newgroupbox.cpp b/Telegram/SourceFiles/boxes/newgroupbox.cpp
index 72c68509c0..ad6674371c 100644
--- a/Telegram/SourceFiles/boxes/newgroupbox.cpp
+++ b/Telegram/SourceFiles/boxes/newgroupbox.cpp
@@ -99,7 +99,7 @@ NewGroupInner::ContactData *NewGroupInner::contactData(DialogRow *row) {
_contactsData.insert(user, data = new ContactData());
data->check = false;
data->name.setText(st::profileListNameFont, user->name, _textNameOptions);
- data->online = App::onlineText(user->onlineTill, _time);
+ data->online = App::onlineText(user, _time);
} else {
data = i.value();
}
diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h
index 6fa2f9959d..66b74e607d 100644
--- a/Telegram/SourceFiles/config.h
+++ b/Telegram/SourceFiles/config.h
@@ -17,8 +17,8 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
*/
#pragma once
-static const int32 AppVersion = 6011;
-static const wchar_t *AppVersionStr = L"0.6.11";
+static const int32 AppVersion = 6012;
+static const wchar_t *AppVersionStr = L"0.6.12";
static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)";
static const wchar_t *AppName = L"Telegram Desktop";
@@ -101,8 +101,16 @@ enum {
MaxMessageSize = 4096,
MaxHttpRedirects = 5, // when getting external data/images
+
+ WriteMapTimeout = 1000,
+ SaveDraftTimeout = 1000, // save draft after 1 secs of not changing text
+ SaveDraftAnywayTimeout = 5000, // or save anyway each 5 secs
};
+inline bool isServiceUser(uint64 id) {
+ return (id == 333000) || (id == 777000);
+}
+
#ifdef Q_OS_WIN
inline const GUID &cGUID() {
static const GUID gGuid = { 0x87a94ab0, 0xe370, 0x4cde, { 0x98, 0xd3, 0xac, 0xc1, 0x10, 0xc5, 0x96, 0x7d } };
diff --git a/Telegram/SourceFiles/gui/images.cpp b/Telegram/SourceFiles/gui/images.cpp
index 59fb5d235d..f2f6a8e834 100644
--- a/Telegram/SourceFiles/gui/images.cpp
+++ b/Telegram/SourceFiles/gui/images.cpp
@@ -29,18 +29,9 @@ namespace {
return img;
}
- typedef QMap<QByteArray, StorageImage*> StorageImages;
+ typedef QMap<StorageKey, StorageImage*> StorageImages;
StorageImages storageImages;
- QByteArray storageKey(int32 dc, const int64 &volume, int32 local, const int64 &secret) {
- QByteArray result(24, Qt::Uninitialized);
- memcpy(result.data(), &dc, 4);
- memcpy(result.data() + 4, &volume, 8);
- memcpy(result.data() + 12, &local, 4);
- memcpy(result.data() + 16, &secret, 8);
- return result;
- }
-
int64 globalAquiredSize = 0;
}
@@ -480,7 +471,7 @@ bool StorageImage::loaded() const {
}
StorageImage *getImage(int32 width, int32 height, int32 dc, const int64 &volume, int32 local, const int64 &secret, int32 size) {
- QByteArray key(storageKey(dc, volume, local, secret));
+ StorageKey key(storageKey(dc, volume, local));
StorageImages::const_iterator i = storageImages.constFind(key);
if (i == storageImages.cend()) {
i = storageImages.insert(key, new StorageImage(width, height, dc, volume, local, secret, size));
@@ -489,7 +480,7 @@ StorageImage *getImage(int32 width, int32 height, int32 dc, const int64 &volume,
}
StorageImage *getImage(int32 width, int32 height, int32 dc, const int64 &volume, int32 local, const int64 &secret, const QByteArray &bytes) {
- QByteArray key(storageKey(dc, volume, local, secret));
+ StorageKey key(storageKey(dc, volume, local));
StorageImages::const_iterator i = storageImages.constFind(key);
if (i == storageImages.cend()) {
QByteArray bytesArr(bytes);
diff --git a/Telegram/SourceFiles/gui/images.h b/Telegram/SourceFiles/gui/images.h
index edddac9ad1..4d5c275576 100644
--- a/Telegram/SourceFiles/gui/images.h
+++ b/Telegram/SourceFiles/gui/images.h
@@ -53,6 +53,13 @@ public:
void forget() const;
void restore() const;
+ QByteArray savedFormat() const {
+ return format;
+ }
+ QByteArray savedData() const {
+ return saved;
+ }
+
virtual ~Image() {
invalidateSizeCache();
}
@@ -106,6 +113,24 @@ private:
LocalImage *getImage(const QString &file);
LocalImage *getImage(const QPixmap &pixmap, QByteArray format);
+typedef QPair<uint64, uint64> StorageKey;
+inline uint64 storageMix32To64(int32 a, int32 b) {
+ return (uint64(*reinterpret_cast<uint32*>(&a)) << 32) | uint64(*reinterpret_cast<uint32*>(&b));
+}
+inline StorageKey storageKey(int32 dc, const int64 &volume, int32 local) {
+ return StorageKey(storageMix32To64(dc, local), volume);
+}
+inline StorageKey storageKey(const MTPDfileLocation &location) {
+ return storageKey(location.vdc_id.v, location.vvolume_id.v, location.vlocal_id.v);
+}
+struct StorageImageSaved {
+ StorageImageSaved() : type(mtpc_storage_fileUnknown) {
+ }
+ StorageImageSaved(mtpTypeId type, const QByteArray &data) : type(type), data(data) {
+ }
+ mtpTypeId type;
+ QByteArray data;
+};
class StorageImage : public Image {
public:
@@ -123,7 +148,7 @@ public:
void load(bool loadFirst = false, bool prior = true) {
if (loader) {
loader->start(loadFirst, prior);
- check();
+ if (loader) check();
}
}
void checkload() const {
@@ -131,7 +156,7 @@ public:
if (!loader->loading()) {
loader->start(true);
}
- check();
+ if (loader) check();
}
}
diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp
index 516a071954..3018a97219 100644
--- a/Telegram/SourceFiles/history.cpp
+++ b/Telegram/SourceFiles/history.cpp
@@ -27,6 +27,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
#include "gui/filedialog.h"
#include "audio.h"
+#include "localstorage.h"
TextParseOptions _textNameOptions = {
0, // flags
@@ -2132,6 +2133,10 @@ const QString HistoryPhoto::inDialogsText() const {
return lang(lng_in_dlg_photo);
}
+const QString HistoryPhoto::inHistoryText() const {
+ return qsl("[ ") + lang(lng_in_dlg_photo) + qsl(" ]");
+}
+
bool HistoryPhoto::hasPoint(int32 x, int32 y, const HistoryItem *parent, int32 width) const {
if (width < 0) width = w;
return (x >= 0 && y >= 0 && x < width && y < _height);
@@ -2149,6 +2154,40 @@ HistoryMedia *HistoryPhoto::clone() const {
return new HistoryPhoto(*this);
}
+void HistoryPhoto::updateFrom(const MTPMessageMedia &media) {
+ if (media.type() == mtpc_messageMediaPhoto) {
+ const MTPPhoto &photo(media.c_messageMediaPhoto().vphoto);
+ if (photo.type() == mtpc_photo) {
+ const QVector<MTPPhotoSize> &sizes(photo.c_photo().vsizes.c_vector().v);
+ for (QVector<MTPPhotoSize>::const_iterator i = sizes.cbegin(), e = sizes.cend(); i != e; ++i) {
+ char size = 0;
+ const MTPFileLocation *loc = 0;
+ switch (i->type()) {
+ case mtpc_photoSize: {
+ const string &s(i->c_photoSize().vtype.c_string().v);
+ loc = &i->c_photoSize().vlocation;
+ if (s.size()) size = s[0];
+ } break;
+
+ case mtpc_photoCachedSize: {
+ const string &s(i->c_photoCachedSize().vtype.c_string().v);
+ loc = &i->c_photoSize().vlocation;
+ if (s.size()) size = s[0];
+ } break;
+ }
+ if (!loc || loc->type() != mtpc_fileLocation) continue;
+ if (size == 's') {
+ Local::writeImage(storageKey(loc->c_fileLocation()), data->thumb);
+ } else if (size == 'm') {
+ Local::writeImage(storageKey(loc->c_fileLocation()), data->medium);
+ } else if (size == 'x') {
+ Local::writeImage(storageKey(loc->c_fileLocation()), data->full);
+ }
+ }
+ }
+ }
+}
+
void HistoryPhoto::draw(QPainter &p, const HistoryItem *parent, bool selected, int32 width) const {
if (width < 0) width = w;
data->full->load(false, false);
@@ -2314,6 +2353,10 @@ const QString HistoryVideo::inDialogsText() const {
return lang(lng_in_dlg_video);
}
+const QString HistoryVideo::inHistoryText() const {
+ return qsl("[ ") + lang(lng_in_dlg_video) + qsl(" ]");
+}
+
bool HistoryVideo::hasPoint(int32 x, int32 y, const HistoryItem *parent, int32 width) const {
if (width < 0) width = w;
if (width >= _maxw) {
@@ -2611,6 +2654,10 @@ const QString HistoryAudio::inDialogsText() const {
return lang(lng_in_dlg_audio);
}
+const QString HistoryAudio::inHistoryText() const {
+ return qsl("[ ") + lang(lng_in_dlg_audio) + qsl(" ]");
+}
+
bool HistoryAudio::hasPoint(int32 x, int32 y, const HistoryItem *parent, int32 width) const {
if (width < 0) width = w;
if (width >= _maxw) {
@@ -2862,6 +2909,10 @@ const QString HistoryDocument::inDialogsText() const {
return data->name.isEmpty() ? lang(lng_in_dlg_document) : data->name;
}
+const QString HistoryDocument::inHistoryText() const {
+ return qsl("[ ") + lang(lng_in_dlg_document) + (data->name.isEmpty() ? QString() : (qsl(" : ") + data->name)) + qsl(" ]");
+}
+
bool HistoryDocument::hasPoint(int32 x, int32 y, const HistoryItem *parent, int32 width) const {
if (width < 0) width = w;
if (width >= _maxw) {
@@ -2962,6 +3013,10 @@ const QString HistoryContact::inDialogsText() const {
return lang(lng_in_dlg_contact);
}
+const QString HistoryContact::inHistoryText() const {
+ return qsl("[ ") + lang(lng_in_dlg_contact) + qsl(" : ") + name.original(0, 0xFFFF, false) + qsl(", ") + phone + qsl(" ]");
+}
+
bool HistoryContact::hasPoint(int32 x, int32 y, const HistoryItem *parent, int32 width) const {
if (width < 0) width = w;
return (x >= 0 && y <= 0 && x < w && y < _height);
@@ -3060,7 +3115,7 @@ void HistoryContact::updateFrom(const MTPMessageMedia &media) {
}
namespace {
- QRegularExpression reYouTube1(qsl("^(https?://)?(www\\.)?youtube\\.com/watch\\?v=([a-z0-9_-]+)(&|$)"), QRegularExpression::CaseInsensitiveOption);
+ QRegularExpression reYouTube1(qsl("^(https?://)?(www\\.|m\\.)?youtube\\.com/watch\\?([^#]+&)?v=([a-z0-9_-]+)(&|$)"), QRegularExpression::CaseInsensitiveOption);