2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

audio documents playback added, audio documents suppress on voice message, and both suppress on notify added

This commit is contained in:
John Preston
2015-07-01 00:07:05 +03:00
parent 387694f477
commit f7d55005c4
19 changed files with 1422 additions and 477 deletions

View File

@@ -413,6 +413,27 @@ struct AudioData {
int32 md5[8];
};
struct AudioMsgId {
AudioMsgId() : audio(0), msgId(0) {
}
AudioMsgId(AudioData *audio, MsgId msgId) : audio(audio), msgId(msgId) {
}
operator bool() const {
return audio;
}
AudioData *audio;
MsgId msgId;
};
inline bool operator<(const AudioMsgId &a, const AudioMsgId &b) {
return quintptr(a.audio) < quintptr(b.audio) || (quintptr(a.audio) == quintptr(b.audio) && a.msgId < b.msgId);
}
inline bool operator==(const AudioMsgId &a, const AudioMsgId &b) {
return a.audio == b.audio && a.msgId == b.msgId;
}
inline bool operator!=(const AudioMsgId &a, const AudioMsgId &b) {
return !(a == b);
}
class AudioLink : public ITextLink {
TEXT_LINK_CLASS(AudioLink)
@@ -455,7 +476,18 @@ public:
void onClick(Qt::MouseButton button) const;
};
struct StickerData {
enum DocumentType {
FileDocument = 0,
VideoDocument = 1,
SongDocument = 2,
StickerDocument = 3,
AnimatedDocument = 4,
};
struct DocumentAdditionalData {
};
struct StickerData : public DocumentAdditionalData {
StickerData() : set(MTP_inputStickerSetEmpty()) {
}
ImagePtr img;
@@ -467,20 +499,20 @@ struct StickerData {
StorageImageLocation loc; // doc thumb location
};
enum DocumentType {
FileDocument = 0,
VideoDocument = 1,
AudioDocument = 2,
StickerDocument = 3,
AnimatedDocument = 4,
struct SongData : public DocumentAdditionalData {
SongData() : duration(0) {
}
int32 duration;
QString title, performer;
};
struct DocumentData {
DocumentData(const DocumentId &id, const uint64 &access = 0, int32 date = 0, const QVector<MTPDocumentAttribute> &attributes = QVector<MTPDocumentAttribute>(), const QString &mime = QString(), const ImagePtr &thumb = ImagePtr(), int32 dc = 0, int32 size = 0);
void setattributes(const QVector<MTPDocumentAttribute> &attributes);
void forget() {
thumb->forget();
if (sticker) sticker->img->forget();
if (sticker()) sticker()->img->forget();
replyPreview->forget();
}
@@ -510,15 +542,20 @@ struct DocumentData {
loader = 0;
}
~DocumentData() {
delete sticker;
delete _additional;
}
QString already(bool check = false);
StickerData *sticker() {
return (type == StickerDocument) ? static_cast<StickerData*>(_additional) : 0;
}
SongData *song() {
return (type == SongDocument) ? static_cast<SongData*>(_additional) : 0;
}
DocumentId id;
DocumentType type;
QSize dimensions;
int32 duration;
uint64 access;
int32 date;
QString name, mime;
@@ -534,11 +571,32 @@ struct DocumentData {
FileLocation location;
QByteArray data;
StickerData *sticker;
DocumentAdditionalData *_additional;
int32 md5[8];
};
struct SongMsgId {
SongMsgId() : song(0), msgId(0) {
}
SongMsgId(DocumentData *song, MsgId msgId) : song(song), msgId(msgId) {
}
operator bool() const {
return song;
}
DocumentData *song;
MsgId msgId;
};
inline bool operator<(const SongMsgId &a, const SongMsgId &b) {
return quintptr(a.song) < quintptr(b.song) || (quintptr(a.song) == quintptr(b.song) && a.msgId < b.msgId);
}
inline bool operator==(const SongMsgId &a, const SongMsgId &b) {
return a.song == b.song && a.msgId == b.msgId;
}
inline bool operator!=(const SongMsgId &a, const SongMsgId &b) {
return !(a == b);
}
class DocumentLink : public ITextLink {
TEXT_LINK_CLASS(DocumentLink)