Skip to content

Commit

Permalink
youtube and instagram preview display added (instead of messages with…
Browse files Browse the repository at this point in the history
… only one such link)
  • Loading branch information
john-preston committed Nov 12, 2014
1 parent e0ef1d4 commit a75f57b
Show file tree
Hide file tree
Showing 25 changed files with 871 additions and 123 deletions.
2 changes: 1 addition & 1 deletion MSVC.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ There go to Qt directory

and after that run configure

configure -debug-and-release -opensource -confirm-license -static -opengl desktop -mp -nomake examples -platform win32-msvc2013
configure -debug-and-release -opensource -confirm-license -static -I "D:\TBuild\Libraries\OpenSSL-Win32\include" -L "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib" -l Gdi32 -opengl desktop -openssl-linked OPENSSL_LIBS_DEBUG="D:\TBuild\Libraries\OpenSSL-Win32\lib\VC\static\ssleay32MTd.lib D:\TBuild\Libraries\OpenSSL-Win32\lib\VC\static\libeay32MTd.lib" OPENSSL_LIBS_RELEASE="D:\TBuild\Libraries\OpenSSL-Win32\lib\VC\static\ssleay32MT.lib D:\TBuild\Libraries\OpenSSL-Win32\lib\VC\static\libeay32MT.lib" -mp -nomake examples -platform win32-msvc2013

to configure Qt build. After configuration is complete run

Expand Down
46 changes: 43 additions & 3 deletions Telegram/PrepareWin.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
@echo OFF

set "AppVersionStr=0.6.7"
echo.
echo Preparing version %AppVersionStr%..
echo.

set "PATH=%PATH%;C:\Program Files\7-Zip;C:\Program Files (x86)\Inno Setup 5"
cd ..\Win32\Deploy
call ..\..\..\TelegramPrivate\Sign.bat tsetup.0.6.7.exe

call ..\..\..\TelegramPrivate\Sign.bat Telegram.exe
if %errorlevel% neq 0 goto error1

call ..\..\..\TelegramPrivate\Sign.bat Updater.exe
if %errorlevel% neq 0 goto error1

iscc ..\..\Telegram\Setup.iss
if %errorlevel% neq 0 goto error1

call ..\..\..\TelegramPrivate\Sign.bat tsetup.%AppVersionStr%.exe
if %errorlevel% neq 0 goto error1

call Prepare.exe -path Telegram.exe -path Updater.exe
mkdir deploy\0.6.7\Telegram
move deploy\0.6.7\Telegram.exe deploy\0.6.7\Telegram\
if %errorlevel% neq 0 goto error1

cd deploy\%AppVersionStr%
mkdir Telegram
move Telegram.exe Telegram\
7z a -mx9 tportable.%AppVersionStr%.zip Telegram\
if %errorlevel% neq 0 goto error2

echo .
echo Version %AppVersionStr% is ready for deploy!
echo .

cd ..\..\..\..\Telegram
goto eof

:error2
cd ..\..
:error1
cd ..\..\Telegram
echo ERROR occured!
exit /b %errorlevel%

:eof
3 changes: 3 additions & 0 deletions Telegram/Resources/style.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1635,3 +1635,6 @@ usernameDone: flatButton(btnSelectDone) {
usernameCancel: flatButton(btnSelectCancel) {
width: 167px;
}

youtubeIcon: sprite(336px, 221px, 60px, 60px);
instagramIcon: sprite(336px, 283px, 60px, 60px);
4 changes: 0 additions & 4 deletions Telegram/SignWin.bat

This file was deleted.

1 change: 0 additions & 1 deletion Telegram/SourceFiles/_other/prepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,5 @@ int main(int argc, char *argv[])
}
}
int res = prepare(f, paths);
system("PAUSE");
return res;
}
65 changes: 40 additions & 25 deletions Telegram/SourceFiles/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ namespace {
typedef QHash<AudioId, AudioData*> AudiosData;
AudiosData audiosData;

typedef QHash<QString, ImageLinkData*> ImageLinksData;
ImageLinksData imageLinksData;

typedef QHash<DocumentId, DocumentData*> DocumentsData;
DocumentsData documentsData;

Expand Down Expand Up @@ -561,13 +564,20 @@ namespace App {
}

void feedWereDeleted(const QVector<MTPint> &msgsIds) {
bool resized = false;
for (QVector<MTPint>::const_iterator i = msgsIds.cbegin(), e = msgsIds.cend(); i != e; ++i) {
MsgsData::const_iterator j = msgsData.constFind(i->v);
if (j != msgsData.cend()) {
History *h = (*j)->history();
(*j)->destroy();
if (App::main() && h->peer == App::main()->peer()) {
resized = true;
}
}
}
if (resized) {
App::main()->itemResized(0);
}
}

void feedUserLinks(const MTPVector<MTPcontacts_Link> &links) {
Expand Down Expand Up @@ -911,14 +921,6 @@ namespace App {
return result;
}

void forgetPhotos() {
lastPhotos.clear();
lastPhotosMap.clear();
for (PhotosData::const_iterator i = photosData.cbegin(), e = photosData.cend(); i != e; ++i) {
i.value()->forget();
}
}

VideoData *video(const VideoId &video, VideoData *convert, const uint64 &access, int32 user, int32 date, int32 duration, int32 w, int32 h, const ImagePtr &thumb, int32 dc, int32 size) {
if (convert) {
if (convert->id != video) {
Expand Down Expand Up @@ -967,12 +969,6 @@ namespace App {
return result;
}

void forgetVideos() {
for (VideosData::const_iterator i = videosData.cbegin(), e = videosData.cend(); i != e; ++i) {
i.value()->forget();
}
}

AudioData *audio(const AudioId &audio, AudioData *convert, const uint64 &access, int32 user, int32 date, int32 duration, int32 dc, int32 size) {
if (convert) {
if (convert->id != audio) {
Expand Down Expand Up @@ -1015,12 +1011,6 @@ namespace App {
return result;
}

void forgetAudios() {
for (AudiosData::const_iterator i = audiosData.cbegin(), e = audiosData.cend(); i != e; ++i) {
i.value()->forget();
}
}

DocumentData *document(const DocumentId &document, DocumentData *convert, const uint64 &access, int32 user, int32 date, const QString &name, const QString &mime, const ImagePtr &thumb, int32 dc, int32 size) {
if (convert) {
if (convert->id != document) {
Expand Down Expand Up @@ -1067,10 +1057,38 @@ namespace App {
return result;
}

void forgetDocuments() {
ImageLinkData *imageLink(const QString &imageLink, ImageLinkType type, const QString &url) {
ImageLinksData::const_iterator i = imageLinksData.constFind(imageLink);
ImageLinkData *result;
if (i == imageLinksData.cend()) {
result = new ImageLinkData(imageLink);
imageLinksData.insert(imageLink, result);
result->type = type;
result->openl = TextLinkPtr(new TextLink(url));
} else {
result = i.value();
}
return result;
}

void forgetMedia() {
lastPhotos.clear();
lastPhotosMap.clear();
for (PhotosData::const_iterator i = photosData.cbegin(), e = photosData.cend(); i != e; ++i) {
i.value()->forget();
}
for (VideosData::const_iterator i = videosData.cbegin(), e = videosData.cend(); i != e; ++i) {
i.value()->forget();
}
for (AudiosData::const_iterator i = audiosData.cbegin(), e = audiosData.cend(); i != e; ++i) {
i.value()->forget();
}
for (DocumentsData::const_iterator i = documentsData.cbegin(), e = documentsData.cend(); i != e; ++i) {
i.value()->forget();
}
for (ImageLinksData::const_iterator i = imageLinksData.cbegin(), e = imageLinksData.cend(); i != e; ++i) {
i.value()->thumb->forget();
}
}

MTPPhoto photoFromUserPhoto(MTPint userId, MTPint date, const MTPUserProfilePhoto &photo) {
Expand Down Expand Up @@ -1854,10 +1872,7 @@ namespace App {
void checkImageCacheSize() {
int64 nowImageCacheSize = imageCacheSize();
if (nowImageCacheSize > serviceImageCacheSize + MemoryForImageCache) {
App::forgetPhotos();
App::forgetVideos();
App::forgetAudios();
App::forgetDocuments();
App::forgetMedia();
serviceImageCacheSize = imageCacheSize();
}
}
Expand Down
6 changes: 2 additions & 4 deletions Telegram/SourceFiles/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,11 @@ namespace App {
ChatData *chat(int32 chat);
QString peerName(const PeerData *peer, bool forDialogs = false);
PhotoData *photo(const PhotoId &photo, PhotoData *convert = 0, const uint64 &access = 0, int32 user = 0, int32 date = 0, const ImagePtr &thumb = ImagePtr(), const ImagePtr &medium = ImagePtr(), const ImagePtr &full = ImagePtr());
void forgetPhotos();
VideoData *video(const VideoId &video, VideoData *convert = 0, const uint64 &access = 0, int32 user = 0, int32 date = 0, int32 duration = 0, int32 w = 0, int32 h = 0, const ImagePtr &thumb = ImagePtr(), int32 dc = 0, int32 size = 0);
void forgetVideos();
AudioData *audio(const AudioId &audio, AudioData *convert = 0, const uint64 &access = 0, int32 user = 0, int32 date = 0, int32 duration = 0, int32 dc = 0, int32 size = 0);
void forgetAudios();
DocumentData *document(const DocumentId &document, DocumentData *convert = 0, const uint64 &access = 0, int32 user = 0, int32 date = 0, const QString &name = QString(), const QString &mime = QString(), const ImagePtr &thumb = ImagePtr(), int32 dc = 0, int32 size = 0);
void forgetDocuments();
ImageLinkData *imageLink(const QString &imageLink, ImageLinkType type = InvalidImageLink, const QString &url = QString());
void forgetMedia();

MTPPhoto photoFromUserPhoto(MTPint userId, MTPint date, const MTPUserProfilePhoto &photo);

Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ void Application::startApp() {
MTP::setStateChangedHandler(mtpStateChanged);
MTP::setSessionResetHandler(mtpSessionReset);

initImageLinkManager();
App::initMedia();

if (MTP::authedId()) {
Expand Down Expand Up @@ -746,6 +747,7 @@ Application::~Application() {
socket.close();
closeApplication();
App::deinitMedia();
deinitImageLinkManager();
mainApp = 0;
delete updateReply;
delete ::uploader;
Expand Down
Binary file modified Telegram/SourceFiles/art/sprite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Telegram/SourceFiles/art/sprite_200x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Telegram/SourceFiles/boxes/connectionbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ void ConnectionBox::onSave() {
}
App::writeConfig();
MTP::restart();
reinitImageLinkManager();
emit closed();
}

Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ enum {
UsernameCheckTimeout = 200,

MaxMessageSize = 4096,
MaxHttpRedirects = 5, // when getting external data/images
};

#ifdef Q_OS_WIN
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/gui/flattextarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ QString FlatTextarea::getText(int32 start, int32 end) const {
QString t(fragment.text());
if (!full) {
if (p < start) {
t = t.mid(start - p, end - start - p);
t = t.mid(start - p, end - start);
} else if (e > end) {
t = t.mid(0, end - p);
}
Expand Down
54 changes: 53 additions & 1 deletion Telegram/SourceFiles/gui/images.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const QPixmap &Image::pixBlurred(int32 w, int32 h) const {
w *= cIntRetinaFactor();
h *= cIntRetinaFactor();
}
uint64 k = 0x8000000000000000L | (uint64(w) << 32) | uint64(h);
uint64 k = 0x8000000000000000LL | (uint64(w) << 32) | uint64(h);
Sizes::const_iterator i = _sizesCache.constFind(k);
if (i == _sizesCache.cend()) {
QPixmap p(pixBlurredNoCache(w, h));
Expand All @@ -101,6 +101,58 @@ const QPixmap &Image::pixBlurred(int32 w, int32 h) const {
return i.value();
}

const QPixmap &Image::pixSingle(int32 w, int32 h) const {
restore();
checkload();

if (w <= 0 || !width() || !height()) {
w = width() * cIntRetinaFactor();
} else if (cRetina()) {
w *= cIntRetinaFactor();
h *= cIntRetinaFactor();
}
uint64 k = 0LL;
Sizes::const_iterator i = _sizesCache.constFind(k);
if (i == _sizesCache.cend() || i->width() != w || h && i->height() != h) {
if (i != _sizesCache.cend()) {
globalAquiredSize -= int64(i->width()) * i->height() * 4;
}
QPixmap p(pixNoCache(w, h, true));
if (cRetina()) p.setDevicePixelRatio(cRetinaFactor());
i = _sizesCache.insert(k, p);
if (!p.isNull()) {
globalAquiredSize += int64(p.width()) * p.height() * 4;
}
}
return i.value();
}

const QPixmap &Image::pixBlurredSingle(int32 w, int32 h) const {
restore();
checkload();

if (w <= 0 || !width() || !height()) {
w = width() * cIntRetinaFactor();
} else if (cRetina()) {
w *= cIntRetinaFactor();
h *= cIntRetinaFactor();
}
uint64 k = 0x8000000000000000LL | 0LL;
Sizes::const_iterator i = _sizesCache.constFind(k);
if (i == _sizesCache.cend() || i->width() != w || h && i->height() != h) {
if (i != _sizesCache.cend()) {
globalAquiredSize -= int64(i->width()) * i->height() * 4;
}
QPixmap p(pixBlurredNoCache(w, h));
if (cRetina()) p.setDevicePixelRatio(cRetinaFactor());
i = _sizesCache.insert(k, p);
if (!p.isNull()) {
globalAquiredSize += int64(p.width()) * p.height() * 4;
}
}
return i.value();
}

namespace {
static inline uint64 _blurGetColors(const uchar *p) {
return p[0] + (p[1] << 16) + ((uint64)p[2] << 32);
Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/gui/images.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class Image {
}
const QPixmap &pix(int32 w = 0, int32 h = 0) const;
const QPixmap &pixBlurred(int32 w = 0, int32 h = 0) const;
const QPixmap &pixSingle(int32 w = 0, int32 h = 0) const;
const QPixmap &pixBlurredSingle(int32 w = 0, int32 h = 0) const;
QPixmap pixNoCache(int32 w = 0, int32 h = 0, bool smooth = false) const;
QPixmap pixBlurredNoCache(int32 w, int32 h = 0) const;

Expand Down
Loading

0 comments on commit a75f57b

Please sign in to comment.