mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added channel msg thumbnail, you'll lose all your current channel msgs before this rev
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3297 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4157aff291
commit
1f873e023e
@ -55,6 +55,15 @@ class ChannelInfo
|
||||
time_t lastPost;
|
||||
};
|
||||
|
||||
//! for storing a channel msgs thumbnail picture
|
||||
class ChannelMsgThumbnail
|
||||
{
|
||||
public:
|
||||
ChannelMsgThumbnail() : image_thumbnail(NULL), im_thumbnail_size(0) {}
|
||||
|
||||
unsigned char* image_thumbnail;
|
||||
int im_thumbnail_size;
|
||||
};
|
||||
|
||||
//! Stores information on a message within a channel
|
||||
class ChannelMsgInfo
|
||||
@ -73,8 +82,12 @@ class ChannelMsgInfo
|
||||
std::list<FileInfo> files;
|
||||
uint32_t count; /// file count
|
||||
uint64_t size; /// size of all files
|
||||
|
||||
ChannelMsgThumbnail thumbnail;
|
||||
|
||||
};
|
||||
|
||||
|
||||
//! gives a more brief account of a channel message than channelMsgInfo
|
||||
class ChannelMsgSummary
|
||||
{
|
||||
|
@ -42,6 +42,7 @@ void RsChannelMsg::clear()
|
||||
message.clear();
|
||||
|
||||
attachment.TlvClear();
|
||||
thumbnail.TlvClear();
|
||||
}
|
||||
|
||||
std::ostream &RsChannelMsg::print(std::ostream &out, uint16_t indent)
|
||||
@ -65,6 +66,10 @@ std::ostream &RsChannelMsg::print(std::ostream &out, uint16_t indent)
|
||||
out << "Attachment: " << std::endl;
|
||||
attachment.print(out, int_Indent);
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "Thumbnail: " << std::endl;
|
||||
thumbnail.print(out, int_Indent);
|
||||
|
||||
printRsItemEnd(out, "RsChannelMsg", indent);
|
||||
return out;
|
||||
}
|
||||
@ -84,6 +89,7 @@ uint32_t RsChannelSerialiser::sizeMsg(RsChannelMsg *item)
|
||||
s += GetTlvWideStringSize(item->subject);
|
||||
s += GetTlvWideStringSize(item->message);
|
||||
s += item->attachment.TlvSize();
|
||||
s += item->thumbnail.TlvSize();
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -125,6 +131,9 @@ bool RsChannelSerialiser::serialiseMsg(RsChannelMsg *item, void *data, uint3
|
||||
ok &= item->attachment.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsChannelSerialiser::serialiseMsg() Attachment: " << ok << std::endl;
|
||||
|
||||
ok &= item->thumbnail.SetTlv(data, tlvsize, &offset);
|
||||
std::cerr << "RsChannelSerialiser::serialiseMsg() thumbnail: " << ok << std::endl;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
@ -174,7 +183,9 @@ RsChannelMsg *RsChannelSerialiser::deserialiseMsg(void *data, uint32_t *pktsize)
|
||||
/* RsChannelMsg */
|
||||
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_SUBJECT, item->subject);
|
||||
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_MSG, item->message);
|
||||
ok &= item->attachment.GetTlv(data, rssize, &offset);
|
||||
ok &= item->attachment.GetTlv(data, rssize, &offset);
|
||||
ok &= item->thumbnail.GetTlv(data, rssize, &offset);
|
||||
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
|
@ -59,6 +59,7 @@ virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
std::wstring message;
|
||||
|
||||
RsTlvFileSet attachment;
|
||||
RsTlvImage thumbnail;
|
||||
|
||||
};
|
||||
|
||||
|
@ -221,6 +221,15 @@ bool p3Channels::getChannelMessage(std::string fId, std::string mId, ChannelMsgI
|
||||
info.size += fi.size;
|
||||
}
|
||||
|
||||
if((cmsg->thumbnail.binData.bin_data != NULL) && (cmsg->thumbnail.image_type == RSTLV_IMAGE_TYPE_PNG))
|
||||
{
|
||||
info.thumbnail.image_thumbnail =
|
||||
(unsigned char*) cmsg->thumbnail.binData.bin_data;
|
||||
|
||||
info.thumbnail.im_thumbnail_size =
|
||||
cmsg->thumbnail.binData.bin_len;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -250,6 +259,24 @@ bool p3Channels::ChannelMessageSend(ChannelMsgInfo &info)
|
||||
cmsg -> attachment.items.push_back(mfi);
|
||||
}
|
||||
|
||||
// explicit member wise copy for grp image
|
||||
if((info.thumbnail.image_thumbnail != NULL) &&
|
||||
(info.thumbnail.im_thumbnail_size > 0)){
|
||||
|
||||
cmsg->thumbnail.binData.bin_data =
|
||||
new unsigned char[info.thumbnail.im_thumbnail_size];
|
||||
|
||||
memcpy(cmsg->thumbnail.binData.bin_data, info.thumbnail.image_thumbnail,
|
||||
info.thumbnail.im_thumbnail_size*sizeof(unsigned char));
|
||||
cmsg->thumbnail.binData.bin_len = info.thumbnail.im_thumbnail_size;
|
||||
cmsg->thumbnail.image_type = RSTLV_IMAGE_TYPE_PNG;
|
||||
|
||||
}else{
|
||||
|
||||
cmsg->thumbnail.binData.bin_data = NULL;
|
||||
cmsg->thumbnail.binData.bin_len = 0;
|
||||
cmsg->thumbnail.image_type = 0;
|
||||
}
|
||||
|
||||
std::string msgId = publishMsg(cmsg, true);
|
||||
|
||||
|
@ -454,6 +454,11 @@ void CreateChannelMsg::sendMessage(std::wstring subject, std::wstring msg, std::
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* rsChannels */
|
||||
if (rsChannels)
|
||||
{
|
||||
@ -465,6 +470,18 @@ void CreateChannelMsg::sendMessage(std::wstring subject, std::wstring msg, std::
|
||||
msgInfo.subject = subject;
|
||||
msgInfo.msg = msg;
|
||||
msgInfo.files = files;
|
||||
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
|
||||
if(!picture.isNull()){
|
||||
// send chan image
|
||||
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
picture.save(&buffer, "PNG"); // writes image into ba in PNG format
|
||||
msgInfo.thumbnail.image_thumbnail = (unsigned char*) ba.data();
|
||||
msgInfo.thumbnail.im_thumbnail_size = ba.size();
|
||||
}
|
||||
|
||||
rsChannels->ChannelMessageSend(msgInfo);
|
||||
}
|
||||
|
@ -121,6 +121,14 @@ void ChanMsgItem::updateItemStatic()
|
||||
layout->addWidget(fi);
|
||||
}
|
||||
|
||||
if(cmi.thumbnail.image_thumbnail != NULL)
|
||||
{
|
||||
QPixmap thumbnail;
|
||||
thumbnail.loadFromData(cmi.thumbnail.image_thumbnail, cmi.thumbnail.im_thumbnail_size,
|
||||
"PNG");
|
||||
|
||||
label->setPixmap(thumbnail);
|
||||
}
|
||||
|
||||
if (mIsHome)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user