You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.7 KiB
Plaintext
79 lines
1.7 KiB
Plaintext
unit Stickers;
|
|
{$I forRnQConfig.inc}
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Classes;
|
|
|
|
type
|
|
PMemoryStream = ^TMemoryStream;
|
|
|
|
function getSticker(ext, sticker: String; fsPtr: PMemoryStream = nil; forceSize: String = ''): RawByteString;
|
|
|
|
implementation
|
|
|
|
uses
|
|
SysUtils, Base64,
|
|
RDGlobal, RnQGlobal, RnQNet;
|
|
|
|
function getSticker(ext, sticker: String; fsPtr: PMemoryStream = nil; forceSize: String = ''): RawByteString;
|
|
var
|
|
URL, fn, size: string;
|
|
stickerForChat: RawByteString;
|
|
fs: TMemoryStream;
|
|
pfs: PMemoryStream;
|
|
begin
|
|
if fsPtr = nil then
|
|
begin
|
|
fs := TMemoryStream.Create;
|
|
pfs := @fs;
|
|
end
|
|
else
|
|
pfs := fsPtr;
|
|
|
|
if not (forceSize = '') then
|
|
size := forceSize
|
|
else
|
|
case StickerResolution of
|
|
0:
|
|
size := 'small';
|
|
1:
|
|
size := 'medium';
|
|
2:
|
|
size := 'large';
|
|
end;
|
|
|
|
URL := 'http://www.icq.com/store/stickers/' + ext + '/' + sticker + '/' + size;
|
|
fn := myPath + 'Stickers\' + ext + '_' + sticker + '_' + size + '.png';
|
|
|
|
if EnableStickersCache then
|
|
begin
|
|
if not FileExists(fn) then
|
|
begin
|
|
if not DirectoryExists(myPath + 'Stickers\') then
|
|
CreateDir(myPath + 'Stickers\');
|
|
LoadFromURL(URL, fn);
|
|
end;
|
|
pfs.LoadFromFile(fn);
|
|
end
|
|
else
|
|
LoadFromURL(URL, pfs^);
|
|
|
|
pfs.Seek(0, 0);
|
|
SetLength(stickerForChat, pfs.size);
|
|
if pfs.size > 0 then
|
|
begin
|
|
pfs.ReadBuffer(stickerForChat[1], pfs.size);
|
|
Result := AnsiString(' |
|
end else
|
|
Result := '';
|
|
|
|
if fsPtr = nil then
|
|
pfs.Free
|
|
else
|
|
pfs.Seek(0, 0);
|
|
end;
|
|
|
|
end.
|