mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 08:29:32 -05:00
renamed SSGXSChannelGroup to GxsChannelGroupInfo, mCount in RsGxsChannelPost to mAttachmentCount and added a mCommentCount member. Also added some missing override in p3gxschannels.cc
This commit is contained in:
parent
207dfabbca
commit
dc90d6f6dc
@ -71,14 +71,15 @@ struct RsGxsChannelGroup : RsSerializable, RsGxsGenericGroupData
|
||||
|
||||
struct RsGxsChannelPost : RsSerializable, RsGxsGenericMsgData
|
||||
{
|
||||
RsGxsChannelPost() : mCount(0), mSize(0) {}
|
||||
RsGxsChannelPost() : mAttachmentCount(0), mSize(0) {}
|
||||
|
||||
std::set<RsGxsMessageId> mOlderVersions;
|
||||
std::string mMsg; // UTF8 encoded.
|
||||
|
||||
std::list<RsGxsFile> mFiles;
|
||||
uint32_t mCount; // auto calced.
|
||||
uint64_t mSize; // auto calced.
|
||||
uint32_t mAttachmentCount; // auto calced.
|
||||
uint32_t mCommentCount; // auto calced.
|
||||
uint64_t mSize; // auto calced.
|
||||
|
||||
RsGxsImage mThumbnail;
|
||||
|
||||
@ -92,8 +93,9 @@ struct RsGxsChannelPost : RsSerializable, RsGxsGenericMsgData
|
||||
|
||||
RS_SERIAL_PROCESS(mMsg);
|
||||
RS_SERIAL_PROCESS(mFiles);
|
||||
RS_SERIAL_PROCESS(mCount);
|
||||
RS_SERIAL_PROCESS(mSize);
|
||||
RS_SERIAL_PROCESS(mAttachmentCount);
|
||||
RS_SERIAL_PROCESS(mCommentCount);
|
||||
RS_SERIAL_PROCESS(mSize);
|
||||
RS_SERIAL_PROCESS(mThumbnail);
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ bool RsGxsChannelPostItem::toChannelPost(RsGxsChannelPost &post, bool moveImage)
|
||||
post.mThumbnail.copy((uint8_t *) mThumbnail.binData.bin_data, mThumbnail.binData.bin_len);
|
||||
}
|
||||
|
||||
post.mCount = 0;
|
||||
post.mAttachmentCount = 0;
|
||||
post.mSize = 0;
|
||||
std::list<RsTlvFileItem>::iterator fit;
|
||||
for(fit = mAttachment.items.begin(); fit != mAttachment.items.end(); ++fit)
|
||||
@ -148,7 +148,7 @@ bool RsGxsChannelPostItem::toChannelPost(RsGxsChannelPost &post, bool moveImage)
|
||||
fi.mHash = fit->hash;
|
||||
|
||||
post.mFiles.push_back(fi);
|
||||
post.mCount++;
|
||||
post.mAttachmentCount++;
|
||||
post.mSize += fi.mSize;
|
||||
}
|
||||
return true;
|
||||
|
@ -675,7 +675,7 @@ bool p3GxsChannels::setChannelDownloadDirectory(
|
||||
}
|
||||
|
||||
/* extract from ServiceString */
|
||||
SSGxsChannelGroup ss;
|
||||
GxsChannelGroupInfo ss;
|
||||
ss.load(it->second.mServiceString);
|
||||
|
||||
if (directory == ss.mDownloadDirectory)
|
||||
@ -728,7 +728,7 @@ bool p3GxsChannels::getChannelDownloadDirectory(const RsGxsGroupId & groupId,std
|
||||
}
|
||||
|
||||
/* extract from ServiceString */
|
||||
SSGxsChannelGroup ss;
|
||||
GxsChannelGroupInfo ss;
|
||||
ss.load(it->second.mServiceString);
|
||||
directory = ss.mDownloadDirectory;
|
||||
|
||||
@ -1729,14 +1729,14 @@ bool p3GxsChannels::autoDownloadEnabled(const RsGxsGroupId &groupId,bool& enable
|
||||
}
|
||||
|
||||
/* extract from ServiceString */
|
||||
SSGxsChannelGroup ss;
|
||||
GxsChannelGroupInfo ss;
|
||||
ss.load(it->second.mServiceString);
|
||||
enabled = ss.mAutoDownload;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SSGxsChannelGroup::load(const std::string &input)
|
||||
bool GxsChannelGroupInfo::load(const std::string &input)
|
||||
{
|
||||
if(input.empty())
|
||||
{
|
||||
@ -1785,7 +1785,7 @@ bool SSGxsChannelGroup::load(const std::string &input)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string SSGxsChannelGroup::save() const
|
||||
std::string GxsChannelGroupInfo::save() const
|
||||
{
|
||||
std::string output = "v2 ";
|
||||
|
||||
@ -1827,7 +1827,7 @@ bool p3GxsChannels::setAutoDownload(const RsGxsGroupId& groupId, bool enabled)
|
||||
}
|
||||
|
||||
/* extract from ServiceString */
|
||||
SSGxsChannelGroup ss;
|
||||
GxsChannelGroupInfo ss;
|
||||
ss.load(it->second.mServiceString);
|
||||
if (enabled == ss.mAutoDownload)
|
||||
{
|
||||
|
@ -35,11 +35,12 @@
|
||||
#include <string>
|
||||
|
||||
|
||||
// This class is only a helper to parse the channel group service string.
|
||||
|
||||
class SSGxsChannelGroup
|
||||
class GxsChannelGroupInfo
|
||||
{
|
||||
public:
|
||||
SSGxsChannelGroup(): mAutoDownload(false), mDownloadDirectory("") {}
|
||||
GxsChannelGroupInfo(): mAutoDownload(false), mDownloadDirectory("") {}
|
||||
bool load(const std::string &input);
|
||||
std::string save() const;
|
||||
|
||||
@ -55,31 +56,31 @@ class p3GxsChannels: public RsGenExchange, public RsGxsChannels,
|
||||
public:
|
||||
p3GxsChannels( RsGeneralDataService* gds, RsNetworkExchangeService* nes,
|
||||
RsGixs* gixs );
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
virtual RsServiceInfo getServiceInfo() override;
|
||||
|
||||
virtual void service_tick();
|
||||
virtual void service_tick() override;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
virtual RsSerialiser* setupSerialiser(); // @see p3Config::setupSerialiser()
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList); // @see p3Config::saveList(bool &cleanup, std::list<RsItem *>&)
|
||||
virtual bool loadList(std::list<RsItem *>& loadList); // @see p3Config::loadList(std::list<RsItem *>&)
|
||||
virtual RsSerialiser* setupSerialiser() override; // @see p3Config::setupSerialiser()
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList) override; // @see p3Config::saveList(bool &cleanup, std::list<RsItem *>&)
|
||||
virtual bool loadList(std::list<RsItem *>& loadList) override; // @see p3Config::loadList(std::list<RsItem *>&)
|
||||
|
||||
virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id);
|
||||
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string);
|
||||
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSearchResults> &results) ;
|
||||
virtual bool clearDistantSearchResults(TurtleRequestId req);
|
||||
virtual bool getDistantSearchResultGroupData(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group);
|
||||
virtual DistantSearchGroupStatus getDistantSearchStatus(const RsGxsGroupId& group_id) ;
|
||||
virtual TurtleRequestId turtleGroupRequest(const RsGxsGroupId& group_id) override;
|
||||
virtual TurtleRequestId turtleSearchRequest(const std::string& match_string) override;
|
||||
virtual bool retrieveDistantSearchResults(TurtleRequestId req, std::map<RsGxsGroupId, RsGxsGroupSearchResults> &results) override;
|
||||
virtual bool clearDistantSearchResults(TurtleRequestId req) override;
|
||||
virtual bool getDistantSearchResultGroupData(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group) override;
|
||||
virtual DistantSearchGroupStatus getDistantSearchStatus(const RsGxsGroupId& group_id) override;
|
||||
|
||||
// Overloaded to cache new groups.
|
||||
virtual RsGenExchange::ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet);
|
||||
virtual RsGenExchange::ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet) override;
|
||||
|
||||
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes);
|
||||
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) override;
|
||||
|
||||
// Overloaded from RsTickEvent.
|
||||
virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
||||
virtual void handle_event(uint32_t event_type, const std::string &elabel) override;
|
||||
|
||||
public:
|
||||
|
||||
@ -97,18 +98,18 @@ virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &p
|
||||
|
||||
//virtual bool groupRestoreKeys(const std::string &groupId);
|
||||
virtual bool groupShareKeys(
|
||||
const RsGxsGroupId &groupId, const std::set<RsPeerId>& peers);
|
||||
const RsGxsGroupId &groupId, const std::set<RsPeerId>& peers) override;
|
||||
|
||||
virtual bool createGroup(uint32_t &token, RsGxsChannelGroup &group);
|
||||
virtual bool createPost(uint32_t &token, RsGxsChannelPost &post);
|
||||
virtual bool createGroup(uint32_t &token, RsGxsChannelGroup &group) override;
|
||||
virtual bool createPost(uint32_t &token, RsGxsChannelPost &post) override;
|
||||
|
||||
virtual bool updateGroup(uint32_t &token, RsGxsChannelGroup &group);
|
||||
virtual bool updateGroup(uint32_t &token, RsGxsChannelGroup &group) override;
|
||||
|
||||
// no tokens... should be cached.
|
||||
virtual bool setChannelAutoDownload(const RsGxsGroupId &groupId, bool enabled);
|
||||
virtual bool getChannelAutoDownload(const RsGxsGroupId &groupid, bool& enabled);
|
||||
virtual bool setChannelDownloadDirectory(const RsGxsGroupId &groupId, const std::string& directory);
|
||||
virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::string& directory);
|
||||
virtual bool setChannelAutoDownload(const RsGxsGroupId &groupId, bool enabled) override;
|
||||
virtual bool getChannelAutoDownload(const RsGxsGroupId &groupid, bool& enabled) override;
|
||||
virtual bool setChannelDownloadDirectory(const RsGxsGroupId &groupId, const std::string& directory) override;
|
||||
virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::string& directory) override;
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
/// @see RsGxsChannels::turtleSearchRequest
|
||||
|
@ -573,9 +573,9 @@ void GxsChannelPostItem::fill()
|
||||
|
||||
ui->datetimelabel->setText(DateTime::formatLongDateTime(mPost.mMeta.mPublishTs));
|
||||
|
||||
if ( (mPost.mCount != 0) || (mPost.mSize != 0) ) {
|
||||
if ( (mPost.mAttachmentCount != 0) || (mPost.mSize != 0) ) {
|
||||
ui->filelabel->setVisible(true);
|
||||
ui->filelabel->setText(QString("(%1 %2) %3").arg(mPost.mCount).arg( (mPost.mCount > 1)?tr("Files"):tr("File")).arg(misc::friendlyUnit(mPost.mSize)));
|
||||
ui->filelabel->setText(QString("(%1 %2) %3").arg(mPost.mAttachmentCount).arg( (mPost.mAttachmentCount > 1)?tr("Files"):tr("File")).arg(misc::friendlyUnit(mPost.mSize)));
|
||||
} else {
|
||||
ui->filelabel->setVisible(false);
|
||||
}
|
||||
|
@ -222,8 +222,8 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
||||
|
||||
QString info_text = QDateTime::fromMSecsSinceEpoch(qint64(1000)*post.mMeta.mPublishTs).toString(Qt::DefaultLocaleShortDate);
|
||||
|
||||
if(post.mCount > 0)
|
||||
info_text += ", " + QString::number(post.mCount)+ " " +((post.mCount>1)?tr("files"):tr("file")) + " (" + misc::friendlyUnit(qulonglong(post.mSize)) + ")" ;
|
||||
if(post.mAttachmentCount > 0)
|
||||
info_text += ", " + QString::number(post.mAttachmentCount)+ " " +((post.mAttachmentCount>1)?tr("files"):tr("file")) + " (" + misc::friendlyUnit(qulonglong(post.mSize)) + ")" ;
|
||||
|
||||
painter->drawText(QPoint(p.x()+0.5*font_height,y),info_text);
|
||||
y += font_height;
|
||||
|
Loading…
Reference in New Issue
Block a user