Merge pull request #20 from RetroShare/master

update to master
This commit is contained in:
defnax 2019-10-09 19:18:54 +02:00 committed by GitHub
commit 969ad81913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 93 additions and 112 deletions

View File

@ -1423,65 +1423,44 @@ bool p3GxsChannels::createCommentV2(
RsGxsMessageId& commentMessageId, RsGxsMessageId& commentMessageId,
std::string& errorMessage ) std::string& errorMessage )
{ {
constexpr auto fname = __PRETTY_FUNCTION__;
const auto failure = [&](const std::string& err)
{
errorMessage = err;
RsErr() << fname << " " << err << std::endl;
return false;
};
if(channelId.isNull()) return failure("channelId cannot be null");
if(threadId.isNull()) return failure("threadId cannot be null");
if(parentId.isNull()) return failure("parentId cannot be null");
std::vector<RsGxsChannelGroup> channelsInfo; std::vector<RsGxsChannelGroup> channelsInfo;
if(!getChannelsInfo(std::list<RsGxsGroupId>({channelId}),channelsInfo)) if(!getChannelsInfo(std::list<RsGxsGroupId>({channelId}),channelsInfo))
{ return failure( "Channel with Id " + channelId.toStdString()
errorMessage = "Channel with Id " + channelId.toStdString() + " does not exist." );
+ " does not exist.";
return false;
}
std::vector<RsGxsChannelPost> posts; std::vector<RsGxsChannelPost> posts;
std::vector<RsGxsComment> comments; std::vector<RsGxsComment> comments;
if(!getChannelContent( // does the post thread exist? if(!getChannelContent( // does the post thread exist?
channelId,std::set<RsGxsMessageId>({threadId}), posts, comments )) channelId,std::set<RsGxsMessageId>({threadId}), posts, comments ))
{ return failure( "You cannot comment post " + threadId.toStdString() +
errorMessage = "You cannot comment post " + threadId.toStdString() + " of channel with Id " + channelId.toStdString() +
" of channel with Id " + channelId.toStdString() + ": this post does not exists locally!" );
": this post does not exists locally!";
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
<< std::endl;
return false;
}
// check that the post thread Id is actually that of a post thread // check that the post thread Id is actually that of a post thread
if(posts.size() != 1 || !posts[0].mMeta.mParentId.isNull()) if(posts.size() != 1 || !posts[0].mMeta.mParentId.isNull())
{ return failure( "You cannot comment post " + threadId.toStdString() +
errorMessage = "You cannot comment post " + threadId.toStdString() + " of channel with Id " + channelId.toStdString() +
" of channel with Id " + channelId.toStdString() + ": supplied threadId is not a thread, or parentMsgId is"
": supplied threadId is not a thread, or parentMsgId is not a" + " not a comment!");
" comment!";
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
<< std::endl;
return false;
}
if(!parentId.isNull()) if(!getChannelContent( // does the post thread exist?
{ channelId, std::set<RsGxsMessageId>({parentId}),
if(!getChannelContent( // does the post thread exist? posts, comments ))
channelId,std::set<RsGxsMessageId>({parentId}),posts,comments )) return failure( "You cannot comment post " + parentId.toStdString() +
{ ": supplied parent doesn't exists locally!" );
errorMessage = "You cannot comment post " + parentId.toStdString() +
": supplied parent comment Id is not a comment!";
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
<< std::endl;
return false;
}
else
{
if(comments.size() != 1 || comments[0].mMeta.mParentId.isNull())
{ // is the comment parent actually a comment?
errorMessage = "You cannot comment post "
+ parentId.toStdString()
+ " of channel with Id " + channelId.toStdString() +
": supplied mParentMsgId is not a comment Id!";
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
<< std::endl;
return false;
}
}
}
if(!origCommentId.isNull()) if(!origCommentId.isNull())
{ {
@ -1491,35 +1470,22 @@ bool p3GxsChannels::createCommentV2(
if( !getChannelContent(channelId, s, posts, comments) || if( !getChannelContent(channelId, s, posts, comments) ||
comments.size() != 1 ) comments.size() != 1 )
{ return failure( "You cannot edit comment " +
errorMessage = "You cannot edit comment " origCommentId.toStdString() +
+ origCommentId.toStdString() " of channel with Id " + channelId.toStdString() +
+ " of channel with Id " + channelId.toStdString() ": this comment does not exist locally!");
+ ": this post does not exist locally!";
RsErr() << __PRETTY_FUNCTION__ << " " << errorMessage << std::endl;
return false;
}
const RsGxsId& commentAuthor = comments[0].mMeta.mAuthorId; const RsGxsId& commentAuthor = comments[0].mMeta.mAuthorId;
if(commentAuthor != authorId) if(commentAuthor != authorId)
{ return failure( "Editor identity and creator doesn't match "
errorMessage = "Editor identity and creator doesn't match " + authorId.toStdString() + " != "
+ authorId.toStdString() + " != " + commentAuthor.toStdString() );
+ commentAuthor.toStdString();
RsErr() << __PRETTY_FUNCTION__ << " " << errorMessage << std::endl;
return false;
}
} }
if(!rsIdentity->isOwnId(authorId)) // is the author ID actually ours? if(!rsIdentity->isOwnId(authorId)) // is the author ID actually ours?
{ return failure( "You cannot comment to channel with Id " +
errorMessage = "You cannot comment to channel with Id " + channelId.toStdString() + " with identity " +
channelId.toStdString() + " with identity " + authorId.toStdString() + " because it is not yours." );
authorId.toStdString() + " because it is not yours.";
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
<< std::endl;
return false;
}
// Now create the comment // Now create the comment
RsGxsComment cmt; RsGxsComment cmt;
@ -1532,28 +1498,15 @@ bool p3GxsChannels::createCommentV2(
uint32_t token; uint32_t token;
if(!createNewComment(token, cmt)) if(!createNewComment(token, cmt))
{ return failure("createNewComment failed");
errorMessage = "Failed creating comment.";
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
<< std::endl;
return false;
}
if(waitToken(token) != RsTokenService::COMPLETE) RsTokenService::GxsRequestStatus wSt = waitToken(token);
{ if(wSt != RsTokenService::COMPLETE)
errorMessage = "GXS operation failed."; return failure( "GXS operation waitToken failed with: " +
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage std::to_string(wSt) );
<< std::endl;
return false;
}
if(!RsGenExchange::getPublishedMsgMeta(token, cmt.mMeta)) if(!RsGenExchange::getPublishedMsgMeta(token, cmt.mMeta))
{ return failure("Failure getting created comment data.");
errorMessage = "Failure getting created comment data.";
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
<< std::endl;
return false;
}
commentMessageId = cmt.mMeta.mMsgId; commentMessageId = cmt.mMeta.mMsgId;
return true; return true;

View File

@ -39,14 +39,23 @@
</size> </size>
</property> </property>
<layout class="QGridLayout"> <layout class="QGridLayout">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QFrame" name="titleBarFrame"> <widget class="QFrame" name="toolBarFrame">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::Box</enum> <enum>QFrame::Box</enum>
</property> </property>
@ -54,7 +63,16 @@
<enum>QFrame::Sunken</enum> <enum>QFrame::Sunken</enum>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="margin"> <property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number> <number>2</number>
</property> </property>
<item> <item>
@ -160,6 +178,11 @@
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>StyledLabel</class>
<extends>QLabel</extends>
<header>gui/common/StyledLabel.h</header>
</customwidget>
<customwidget> <customwidget>
<class>RSTreeWidget</class> <class>RSTreeWidget</class>
<extends>QTreeWidget</extends> <extends>QTreeWidget</extends>
@ -171,11 +194,6 @@
<header>gui/common/RSTabWidget.h</header> <header>gui/common/RSTabWidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>StyledLabel</class>
<extends>QLabel</extends>
<header>gui/common/StyledLabel.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="FeedReader_images.qrc"/> <include location="FeedReader_images.qrc"/>

View File

@ -109,7 +109,7 @@ QString PostedDialog::icon(IconType type)
case ICON_POPULAR_GROUP: case ICON_POPULAR_GROUP:
return ""; return "";
case ICON_OTHER_GROUP: case ICON_OTHER_GROUP:
return ":/icons/png/feed-other.png"; return "";
case ICON_SEARCH: case ICON_SEARCH:
return ":/images/find.png"; return ":/images/find.png";
case ICON_DEFAULT: case ICON_DEFAULT:

View File

@ -306,7 +306,7 @@ void PostedItem::fill()
urlstr += messageName(); urlstr += messageName();
urlstr += QString(" </span></a>"); urlstr += QString(" </span></a>");
QString siteurl = url.scheme() + "://" + url.host(); QString siteurl = url.toEncoded();
sitestr = QString("<a href=\"%1\" ><span style=\" text-decoration: underline; color:#0079d3;\"> %2 </span></a>").arg(siteurl).arg(siteurl); sitestr = QString("<a href=\"%1\" ><span style=\" text-decoration: underline; color:#0079d3;\"> %2 </span></a>").arg(siteurl).arg(siteurl);
ui->titleLabel->setText(urlstr); ui->titleLabel->setText(urlstr);

View File

@ -124,6 +124,13 @@ QIcon PostedListWidget::groupIcon()
return QIcon(); return QIcon();
} }
void PostedListWidget::groupIdChanged()
{
mPostIndex = 0;
GxsMessageFramePostWidget::groupIdChanged();
updateShowText();
}
/*****************************************************************************************/ /*****************************************************************************************/
// Overloaded from FeedHolder. // Overloaded from FeedHolder.
QScrollArea *PostedListWidget::getScrollArea() QScrollArea *PostedListWidget::getScrollArea()

View File

@ -44,6 +44,7 @@ public:
/* GxsMessageFrameWidget */ /* GxsMessageFrameWidget */
virtual QIcon groupIcon(); virtual QIcon groupIcon();
virtual void groupIdChanged();
/* FeedHolder */ /* FeedHolder */
virtual QScrollArea *getScrollArea(); virtual QScrollArea *getScrollArea();

View File

@ -303,7 +303,7 @@ border-image: url(:/images/closepressed.png)
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QFrame" name="toolBarFrame"> <widget class="QFrame" name="toolBarFrameTop">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::Box</enum> <enum>QFrame::Box</enum>
</property> </property>

View File

@ -2,7 +2,7 @@
/* Standard rules */ /* Standard rules */
QFrame#toolBarFrame { QFrame#toolBarFrame, QFrame#toolBarFrameTop {
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FEFEFE, stop:1 #E8E8E8); background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FEFEFE, stop:1 #E8E8E8);
border: 1px solid #CCCCCC; border: 1px solid #CCCCCC;
} }

View File

@ -32,13 +32,13 @@ no_retroshare_gui:CONFIG -= retroshare_gui
# Enable GXS distant syncronization # Enable GXS distant syncronization
CONFIG *= gxsdistsync CONFIG *= gxsdistsync
# To disable RetroShare-nogui append the following # To enable RetroShare-nogui append the following
# assignation to qmake command line "CONFIG+=no_retroshare_nogui" # assignation to qmake command line "CONFIG+=retroshare_nogui"
CONFIG *= no_retroshare_nogui CONFIG *= no_retroshare_nogui
retroshare_nogui:CONFIG -= no_retroshare_nogui retroshare_nogui:CONFIG -= no_retroshare_nogui
# To disable cmark append the following # To enable cmark append the following
# assignation to qmake command line "CONFIG+=no_cmark" # assignation to qmake command line "CONFIG+=rs_gui_cmark"
CONFIG *= no_rs_gui_cmark CONFIG *= no_rs_gui_cmark
rs_gui_cmark:CONFIG -= no_rs_gui_cmark rs_gui_cmark:CONFIG -= no_rs_gui_cmark
@ -63,18 +63,19 @@ retroshare_android_notify_service:CONFIG -= no_retroshare_android_notify_service
CONFIG *= no_retroshare_qml_app CONFIG *= no_retroshare_qml_app
retroshare_qml_app:CONFIG -= no_retroshare_qml_app retroshare_qml_app:CONFIG -= no_retroshare_qml_app
# To enable RetroShare service append the following assignation to # To disable RetroShare service append the following assignation to
# qmake command line "CONFIG+=retroshare_service" # qmake command line "CONFIG+=no_retroshare_service"
CONFIG *= retroshare_service CONFIG *= retroshare_service
retroshare_service:CONFIG -= no_retroshare_service no_retroshare_service:CONFIG -= retroshare_service
# To enable libresapi (deprecated) append the following assignation to qmake command line # To enable libresapi (deprecated) append the following assignation to qmake command line
# "CONFIG+=libresapi"
CONFIG+=no_libresapi CONFIG+=no_libresapi
libresapi:CONFIG -= no_libresapi libresapi:CONFIG -= no_libresapi
# To enable libresapi via local socket (unix domain socket or windows named # To enable libresapi via local socket (unix domain socket or windows named
# pipes) append the following assignation to qmake command line # pipes) append the following assignation to qmake command line
#"CONFIG+=libresapilocalserver" # "CONFIG+=libresapilocalserver"
CONFIG *= no_libresapilocalserver CONFIG *= no_libresapilocalserver
libresapilocalserver:CONFIG -= no_libresapilocalserver libresapilocalserver:CONFIG -= no_libresapilocalserver
@ -83,8 +84,8 @@ libresapilocalserver:CONFIG -= no_libresapilocalserver
CONFIG *= no_libresapi_settings CONFIG *= no_libresapi_settings
libresapi_settings:CONFIG -= no_libresapi_settings libresapi_settings:CONFIG -= no_libresapi_settings
# To disable libresapi via HTTP (based on libmicrohttpd) append the following # To enable libresapi via HTTP (based on libmicrohttpd) append the following
# assignation to qmake command line "CONFIG+=no_libresapihttpserver" # assignation to qmake command line "CONFIG+=libresapihttpserver"
CONFIG *= no_libresapihttpserver CONFIG *= no_libresapihttpserver
libresapihttpserver:CONFIG -= no_libresapihttpserver libresapihttpserver:CONFIG -= no_libresapihttpserver
@ -164,7 +165,8 @@ rs_macos10.14:CONFIG -= rs_macos10.11
CONFIG *= no_rs_jsonapi CONFIG *= no_rs_jsonapi
rs_jsonapi:CONFIG -= no_rs_jsonapi rs_jsonapi:CONFIG -= no_rs_jsonapi
# To disable deep search append the following assignation to qmake command line # To enable deep search append the following assignation to qmake command line
# CONFIG *= rs_deep_search
CONFIG *= no_rs_deep_search CONFIG *= no_rs_deep_search
rs_deep_search:CONFIG -= no_rs_deep_search rs_deep_search:CONFIG -= no_rs_deep_search