Merge pull request #16 from RetroShare/master

update to master
This commit is contained in:
defnax 2019-10-04 19:05:12 +02:00 committed by GitHub
commit bd0482b939
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 118 additions and 51 deletions

View File

@ -1493,6 +1493,11 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp)
std::cerr << "RsDataService::retrieveGxsGrpMetaData() " << mDbName << ", Requests: " << requestedGroups << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl; std::cerr << "RsDataService::retrieveGxsGrpMetaData() " << mDbName << ", Requests: " << requestedGroups << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl;
#endif #endif
/* Remove not found entries as stated in the documentation */
for(auto i = grp.begin(); i != grp.end();)
if(!i->second) i = grp.erase(i);
else ++i;
return 1; return 1;
} }

View File

@ -48,13 +48,12 @@ public:
* This allows modification of local * This allows modification of local
* meta data items of a message * meta data items of a message
*/ */
class MsgLocMetaData { struct MsgLocMetaData {
MsgLocMetaData() = default;
MsgLocMetaData(const MsgLocMetaData& meta): msgId(meta.msgId), val(meta.val) {}
public: RsGxsGrpMsgIdPair msgId;
MsgLocMetaData(const MsgLocMetaData& meta){ msgId = meta.msgId; val = meta.val;} ContentValue val;
MsgLocMetaData() {}
RsGxsGrpMsgIdPair msgId;
ContentValue val;
}; };
typedef std::map<RsGxsGroupId,RsGxsGrpMetaData*> RsGxsGrpMetaTemporaryMap; typedef std::map<RsGxsGroupId,RsGxsGrpMetaData*> RsGxsGrpMetaTemporaryMap;
@ -63,14 +62,12 @@ typedef std::map<RsGxsGroupId,RsGxsGrpMetaData*> RsGxsGrpMetaTemporaryMap;
* This allows modification of local * This allows modification of local
* meta data items of a group * meta data items of a group
*/ */
class GrpLocMetaData { struct GrpLocMetaData {
GrpLocMetaData() = default;
public: GrpLocMetaData(const GrpLocMetaData& meta): grpId(meta.grpId), val(meta.val) {}
GrpLocMetaData(const GrpLocMetaData& meta){ grpId = meta.grpId; val = meta.val;}
GrpLocMetaData(){}
RsGxsGroupId grpId;
ContentValue val;
RsGxsGroupId grpId;
ContentValue val;
}; };
/*! /*!

View File

@ -1009,18 +1009,14 @@ bool RsGxsDataAccess::getGroupSummary(GroupMetaReq* req)
} }
bool RsGxsDataAccess::getGroupList(GroupIdReq* req) bool RsGxsDataAccess::getGroupList(GroupIdReq* req)
{ { return getGroupList(req->mGroupIds, req->Options, req->mGroupIdResult); }
getGroupList(req->mGroupIds, req->Options, req->mGroupIdResult);
return true;
}
bool RsGxsDataAccess::getGroupList(const std::list<RsGxsGroupId>& grpIdsIn, const RsTokReqOptions& opts, std::list<RsGxsGroupId>& grpIdsOut) bool RsGxsDataAccess::getGroupList(const std::list<RsGxsGroupId>& grpIdsIn, const RsTokReqOptions& opts, std::list<RsGxsGroupId>& grpIdsOut)
{ {
RsGxsGrpMetaTemporaryMap grpMeta; RsGxsGrpMetaTemporaryMap grpMeta;
for(auto lit = grpIdsIn.begin(); lit != grpIdsIn.end(); ++lit) for(auto lit = grpIdsIn.begin(); lit != grpIdsIn.end(); ++lit)
grpMeta[*lit] = NULL; grpMeta[*lit] = nullptr;
mDataStore->retrieveGxsGrpMetaData(grpMeta); mDataStore->retrieveGxsGrpMetaData(grpMeta);

View File

@ -101,7 +101,6 @@ class RsGxsChannels: public RsGxsIfaceHelper, public RsGxsCommentService
{ {
public: public:
explicit RsGxsChannels(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {} explicit RsGxsChannels(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {}
virtual ~RsGxsChannels() {}
/** /**
* @brief Create channel. Blocking API. * @brief Create channel. Blocking API.
@ -544,4 +543,6 @@ public:
RS_DEPRECATED_FOR(turtleChannelRequest) RS_DEPRECATED_FOR(turtleChannelRequest)
virtual bool retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group)=0; virtual bool retrieveDistantGroup(const RsGxsGroupId& group_id,RsGxsChannelGroup& distant_group)=0;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
virtual ~RsGxsChannels();
}; };

View File

@ -1015,7 +1015,7 @@ bool p3GxsChannels::getChannelsInfo(
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
if( !requestGroupInfo(token, opts, chanIds) if( !requestGroupInfo(token, opts, chanIds)
|| waitToken(token) != RsTokenService::COMPLETE ) return false; || waitToken(token) != RsTokenService::COMPLETE ) return false;
return getGroupData(token, channelsInfo); return getGroupData(token, channelsInfo) && !channelsInfo.empty();
} }
bool p3GxsChannels::getContentSummaries( bool p3GxsChannels::getContentSummaries(
@ -2532,3 +2532,5 @@ void p3GxsChannels::cleanTimedOutCallbacks()
else ++cbpt; else ++cbpt;
} // RS_STACK_MUTEX(mDistantChannelsCallbacksMapMutex) } // RS_STACK_MUTEX(mDistantChannelsCallbacksMapMutex)
} }
RsGxsChannels::~RsGxsChannels() = default;

View File

@ -111,13 +111,13 @@ virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::strin
/// @see RsGxsChannels::turtleSearchRequest /// @see RsGxsChannels::turtleSearchRequest
virtual bool turtleSearchRequest(const std::string& matchString, virtual bool turtleSearchRequest(const std::string& matchString,
const std::function<void (const RsGxsGroupSummary&)>& multiCallback, const std::function<void (const RsGxsGroupSummary&)>& multiCallback,
rstime_t maxWait = 300 ); rstime_t maxWait = 300 ) override;
/// @see RsGxsChannels::turtleChannelRequest /// @see RsGxsChannels::turtleChannelRequest
virtual bool turtleChannelRequest( virtual bool turtleChannelRequest(
const RsGxsGroupId& channelId, const RsGxsGroupId& channelId,
const std::function<void (const RsGxsChannelGroup& result)>& multiCallback, const std::function<void (const RsGxsChannelGroup& result)>& multiCallback,
rstime_t maxWait = 300 ); rstime_t maxWait = 300 ) override;
/// @see RsGxsChannels::localSearchRequest /// @see RsGxsChannels::localSearchRequest
virtual bool localSearchRequest(const std::string& matchString, virtual bool localSearchRequest(const std::string& matchString,
@ -178,26 +178,26 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
/// Implementation of @see RsGxsChannels::getChannelsSummaries /// Implementation of @see RsGxsChannels::getChannelsSummaries
virtual bool getChannelsSummaries(std::list<RsGroupMetaData>& channels); bool getChannelsSummaries(std::list<RsGroupMetaData>& channels) override;
/// Implementation of @see RsGxsChannels::getChannelsInfo /// Implementation of @see RsGxsChannels::getChannelsInfo
virtual bool getChannelsInfo( bool getChannelsInfo(
const std::list<RsGxsGroupId>& chanIds, const std::list<RsGxsGroupId>& chanIds,
std::vector<RsGxsChannelGroup>& channelsInfo ); std::vector<RsGxsChannelGroup>& channelsInfo ) override;
/// Implementation of @see RsGxsChannels::getChannelContent /// Implementation of @see RsGxsChannels::getChannelContent
virtual bool getChannelContent( const RsGxsGroupId& channelId, bool getChannelContent( const RsGxsGroupId& channelId,
const std::set<RsGxsMessageId>& contentsIds, const std::set<RsGxsMessageId>& contentsIds,
std::vector<RsGxsChannelPost>& posts, std::vector<RsGxsChannelPost>& posts,
std::vector<RsGxsComment>& comments ); std::vector<RsGxsComment>& comments ) override;
/// Implementation of @see RsGxsChannels::getContentSummaries /// Implementation of @see RsGxsChannels::getContentSummaries
virtual bool getContentSummaries( bool getContentSummaries(
const RsGxsGroupId& channelId, const RsGxsGroupId& channelId,
std::vector<RsMsgMetaData>& summaries ) override; std::vector<RsMsgMetaData>& summaries ) override;
/// Implementation of @see RsGxsChannels::createChannelV2 /// Implementation of @see RsGxsChannels::createChannelV2
virtual bool createChannelV2( bool createChannelV2(
const std::string& name, const std::string& description, const std::string& name, const std::string& description,
const RsGxsImage& thumbnail = RsGxsImage(), const RsGxsImage& thumbnail = RsGxsImage(),
const RsGxsId& authorId = RsGxsId(), const RsGxsId& authorId = RsGxsId(),
@ -207,12 +207,8 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string) std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string)
) override; ) override;
/// @deprecated Implementation of @see RsGxsChannels::createComment
RS_DEPRECATED_FOR(createCommentV2)
virtual bool createComment(RsGxsComment& comment) override;
/// Implementation of @see RsGxsChannels::createComment /// Implementation of @see RsGxsChannels::createComment
virtual bool createCommentV2( bool createCommentV2(
const RsGxsGroupId& channelId, const RsGxsGroupId& channelId,
const RsGxsMessageId& threadId, const RsGxsMessageId& threadId,
const std::string& comment, const std::string& comment,
@ -224,11 +220,7 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
) override; ) override;
/// Implementation of @see RsGxsChannels::editChannel /// Implementation of @see RsGxsChannels::editChannel
virtual bool editChannel(RsGxsChannelGroup& channel) override; bool editChannel(RsGxsChannelGroup& channel) override;
/// @deprecated Implementation of @see RsGxsChannels::createPost
RS_DEPRECATED_FOR(createPostV2)
virtual bool createPost(RsGxsChannelPost& post) override;
/// Implementation of @see RsGxsChannels::createPostV2 /// Implementation of @see RsGxsChannels::createPostV2
bool createPostV2( bool createPostV2(
@ -241,12 +233,8 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string) std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string)
) override; ) override;
/// @deprecated Implementation of @see RsGxsChannels::createVote
RS_DEPRECATED_FOR(createVoteV2)
virtual bool createVote(RsGxsVote& vote) override;
/// Implementation of @see RsGxsChannels::createVoteV2 /// Implementation of @see RsGxsChannels::createVoteV2
virtual bool createVoteV2( bool createVoteV2(
const RsGxsGroupId& channelId, const RsGxsMessageId& postId, const RsGxsGroupId& channelId, const RsGxsMessageId& postId,
const RsGxsMessageId& commentId, const RsGxsId& authorId, const RsGxsMessageId& commentId, const RsGxsId& authorId,
RsGxsVoteType vote, RsGxsVoteType vote,
@ -255,8 +243,8 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
) override; ) override;
/// Implementation of @see RsGxsChannels::subscribeToChannel /// Implementation of @see RsGxsChannels::subscribeToChannel
virtual bool subscribeToChannel( const RsGxsGroupId &groupId, bool subscribeToChannel( const RsGxsGroupId &groupId,
bool subscribe ); bool subscribe ) override;
/// Implementation of @see RsGxsChannels::setPostRead /// Implementation of @see RsGxsChannels::setPostRead
virtual bool markRead(const RsGxsGrpMsgIdPair& msgId, bool read); virtual bool markRead(const RsGxsGrpMsgIdPair& msgId, bool read);
@ -266,7 +254,20 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
/// Implementation of @see RsGxsChannels::createChannel /// Implementation of @see RsGxsChannels::createChannel
RS_DEPRECATED_FOR(createChannelV2) RS_DEPRECATED_FOR(createChannelV2)
virtual bool createChannel(RsGxsChannelGroup& channel) override; bool createChannel(RsGxsChannelGroup& channel) override;
/// @deprecated Implementation of @see RsGxsChannels::createPost
RS_DEPRECATED_FOR(createPostV2)
bool createPost(RsGxsChannelPost& post) override;
/// @deprecated Implementation of @see RsGxsChannels::createComment
RS_DEPRECATED_FOR(createCommentV2)
bool createComment(RsGxsComment& comment) override;
/// @deprecated Implementation of @see RsGxsChannels::createVote
RS_DEPRECATED_FOR(createVoteV2)
bool createVote(RsGxsVote& vote) override;
protected: protected:
// Overloaded from GxsTokenQueue for Request callbacks. // Overloaded from GxsTokenQueue for Request callbacks.

View File

@ -25,6 +25,7 @@
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QDropEvent> #include <QDropEvent>
#include <QPushButton> #include <QPushButton>
#include <QTextDocumentFragment>
#include <retroshare/rsgxsforums.h> #include <retroshare/rsgxsforums.h>
#include <retroshare/rsgxscircles.h> #include <retroshare/rsgxscircles.h>
@ -103,6 +104,8 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums())); connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums()));
connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile())); connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile()));
connect(ui.attachPictureButton, SIGNAL(clicked()), this, SLOT(addPicture()));
connect(ui.forumMessage, SIGNAL(textChanged()), this, SLOT(checkLength()));
connect(ui.generateCheckBox, SIGNAL(toggled(bool)), ui.generateSpinBox, SLOT(setEnabled(bool))); connect(ui.generateCheckBox, SIGNAL(toggled(bool)), ui.generateSpinBox, SLOT(setEnabled(bool)));
setAcceptDrops(true); setAcceptDrops(true);
@ -337,6 +340,23 @@ void CreateGxsForumMsg::loadFormInformation()
//ui.forumMessage->setText(""); //ui.forumMessage->setText("");
} }
static const uint32_t MAX_ALLOWED_GXS_MESSAGE_SIZE = 199000;
void CreateGxsForumMsg::checkLength()
{
QString text;
RsHtml::optimizeHtml(ui.forumMessage, text);
std::wstring msg = text.toStdWString();
int charRemains = MAX_ALLOWED_GXS_MESSAGE_SIZE - msg.length();
if(charRemains >= 0)
text = tr("It remains %1 characters after HTML conversion.").arg(charRemains);
else
text = tr("Warning: This message is too big of %1 characters after HTML conversion.").arg((0-charRemains));
ui.buttonBox->button(QDialogButtonBox::Ok)->setToolTip(text);
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(charRemains>=0);
ui.infoLabel->setText(text);
}
void CreateGxsForumMsg::createMsg() void CreateGxsForumMsg::createMsg()
{ {
QString name = misc::removeNewLine(ui.forumSubject->text()); QString name = misc::removeNewLine(ui.forumSubject->text());
@ -489,6 +509,18 @@ void CreateGxsForumMsg::addFile()
} }
} }
void CreateGxsForumMsg::addPicture()
{
QString file;
if (misc::getOpenFileName(window(), RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg *.jpeg)", file)) {
QString encodedImage;
if (RsHtml::makeEmbeddedImage(file, encodedImage, 640*480, MAX_ALLOWED_GXS_MESSAGE_SIZE - 200)) {
QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage);
ui.forumMessage->textCursor().insertFragment(fragment);
}
}
}
void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles) void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
{ {
//std::cerr << "CreateGxsForumMsg::fileHashingFinished() started." << std::endl; //std::cerr << "CreateGxsForumMsg::fileHashingFinished() started." << std::endl;

View File

@ -51,6 +51,8 @@ private slots:
void smileyWidgetForums(); void smileyWidgetForums();
void addSmileys(); void addSmileys();
void addFile(); void addFile();
void addPicture();
void checkLength();
void reject(); void reject();
protected: protected:

View File

@ -200,6 +200,29 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="attachPictureButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Attach a Picture</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/attach-image.png</normaloff>:/icons/png/attach-image.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
@ -259,6 +282,13 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="infoLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -268,7 +298,7 @@ p, li { white-space: pre-wrap; }
<string>Attach files via drag and drop</string> <string>Attach files via drag and drop</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_7"> <layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0"> <item row="1" column="0">
<widget class="HashBox" name="hashBox"> <widget class="HashBox" name="hashBox">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum"> <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
@ -369,6 +399,7 @@ p, li { white-space: pre-wrap; }
<resources> <resources>
<include location="../images.qrc"/> <include location="../images.qrc"/>
<include location="../emojione.qrc"/> <include location="../emojione.qrc"/>
<include location="../icons.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>