mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
merged with upstream/master
This commit is contained in:
commit
d1af2e09dc
@ -1559,8 +1559,81 @@ void RsGenExchange::notifyChangedGroupStats(const RsGxsGroupId &grpId)
|
||||
mNotifications.push_back(gc);
|
||||
}
|
||||
|
||||
bool RsGenExchange::checkGroupMetaConsistency(const RsGroupMetaData& meta)
|
||||
{
|
||||
std::cerr << "Checking group consistency:" << std::endl;
|
||||
|
||||
if(meta.mGroupName.empty())
|
||||
{
|
||||
std::cerr << "(EE) cannot create a group with no name." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(meta.mGroupFlags != GXS_SERV::FLAG_PRIVACY_PUBLIC && meta.mGroupFlags != GXS_SERV::FLAG_PRIVACY_RESTRICTED && meta.mGroupFlags != GXS_SERV::FLAG_PRIVACY_PRIVATE)
|
||||
{
|
||||
std::cerr << "(EE) mGroupFlags has incorrect value " << std::hex << meta.mGroupFlags << std::dec << ". A value among GXS_SERV::FLAG_PRIVACY_{PUBLIC,RESTRICTED,PRIVATE} is expected." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
if(meta.mCircleType < GXS_CIRCLE_TYPE_PUBLIC || meta.mCircleType > GXS_CIRCLE_TYPE_YOUR_EYES_ONLY)
|
||||
{
|
||||
std::cerr << "(EE) mCircleType has incorrect value " << std::hex << meta.mCircleType << std::dec << ". A single value among GXS_CIRCLE_TYPE_{PUBLIC,EXTERNAL,YOUR_FRIENDS_ONLY,LOCAL,EXT_SELF,YOUR_EYES_ONLY} is expected." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
if(meta.mCircleType == GXS_CIRCLE_TYPE_EXTERNAL)
|
||||
{
|
||||
if(!meta.mInternalCircle.isNull())
|
||||
{
|
||||
std::cerr << "(EE) Group circle type is EXTERNAL, but an internal circle ID " << meta.mInternalCircle << " was supplied. This is an error." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
if(meta.mCircleId.isNull())
|
||||
{
|
||||
std::cerr << "(EE) Group circle type is EXTERNAL, but no external circle ID was supplied. meta.mCircleId is indeed empty. This is an error." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
if(meta.mCircleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
|
||||
{
|
||||
if(!meta.mCircleId.isNull())
|
||||
{
|
||||
std::cerr << "(EE) Group circle type is YOUR_FRIENDS_ONLY, but an external circle ID " << meta.mCircleId << " was supplied. This is an error." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
if(meta.mInternalCircle.isNull())
|
||||
{
|
||||
std::cerr << "(EE) Group circle type is YOUR_FRIENDS_ONLY, but no internal circle ID was supplied. meta.mInternalCircle is indeed empty. This is an error." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
if(meta.mCircleType == GXS_CIRCLE_TYPE_EXT_SELF)
|
||||
{
|
||||
if(!meta.mCircleId.isNull())
|
||||
{
|
||||
std::cerr << "(EE) Group circle type is EXT_SELF, but an external circle ID " << meta.mCircleId << " was supplied. This is an error." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
if(!meta.mInternalCircle.isNull())
|
||||
{
|
||||
std::cerr << "(EE) Group circle type is EXT_SELF, but an internal circle ID " << meta.mInternalCircle << " was supplied. This is an error." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
std::cerr << "Group is clean." << std::endl;
|
||||
return true ;
|
||||
}
|
||||
|
||||
void RsGenExchange::publishGroup(uint32_t& token, RsGxsGrpItem *grpItem)
|
||||
{
|
||||
if(!checkGroupMetaConsistency(grpItem->meta))
|
||||
{
|
||||
std::cerr << "(EE) Cannot publish group. Some information was not supplied." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
token = mDataAccess->generatePublicToken();
|
||||
@ -1577,6 +1650,12 @@ void RsGenExchange::publishGroup(uint32_t& token, RsGxsGrpItem *grpItem)
|
||||
|
||||
void RsGenExchange::updateGroup(uint32_t& token, RsGxsGrpItem* grpItem)
|
||||
{
|
||||
if(!checkGroupMetaConsistency(grpItem->meta))
|
||||
{
|
||||
std::cerr << "(EE) Cannot update group. Some information was not supplied." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
token = mDataAccess->generatePublicToken();
|
||||
mGroupUpdatePublish.push_back(GroupUpdatePublish(grpItem, token));
|
||||
|
@ -690,6 +690,8 @@ private:
|
||||
|
||||
void publishMsgs();
|
||||
|
||||
bool checkGroupMetaConsistency(const RsGroupMetaData& meta);
|
||||
|
||||
/*!
|
||||
* processes msg local meta changes
|
||||
*/
|
||||
|
@ -3892,16 +3892,14 @@ bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpM
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
if(circleType == GXS_CIRCLE_TYPE_PUBLIC)
|
||||
else if(circleType == GXS_CIRCLE_TYPE_PUBLIC || circleType == GXS_CIRCLE_TYPE_UNKNOWN) // this complies with the fact that p3IdService does not initialise the circle type.
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_4
|
||||
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId)<< " PUBLIC_CIRCLE, can send"<< std::endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
if(circleType == GXS_CIRCLE_TYPE_EXTERNAL)
|
||||
else if(circleType == GXS_CIRCLE_TYPE_EXTERNAL)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_4
|
||||
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId)<< " EXTERNAL_CIRCLE, will be sent encrypted."<< std::endl;
|
||||
@ -3909,8 +3907,7 @@ bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpM
|
||||
should_encrypt = true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
|
||||
else if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_4
|
||||
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " YOUREYESONLY, checking further" << std::endl;
|
||||
@ -3924,8 +3921,11 @@ bool RsGxsNetService::canSendGrpId(const RsPeerId& sslId, RsGxsGrpMetaData& grpM
|
||||
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId)<< " YOUREYESONLY, checking further"<< std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
else
|
||||
{
|
||||
std::cerr << "(EE) unknown value found in circle type for group " << grpMeta.mGroupId << ": " << (int)circleType << ": this is probably a bug in the design of the group creation." << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool RsGxsNetService::checkCanRecvMsgFromPeer(const RsPeerId& sslId, const RsGxsGrpMetaData& grpMeta, RsGxsCircleId& should_encrypt_id)
|
||||
@ -4288,19 +4288,16 @@ bool RsGxsNetService::canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, co
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
if(circleType == GXS_CIRCLE_TYPE_PUBLIC)
|
||||
else if(circleType == GXS_CIRCLE_TYPE_PUBLIC || circleType == GXS_CIRCLE_TYPE_UNKNOWN) // this complies with the fact that p3IdService does not initialise the circle type.
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_4
|
||||
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: PUBLIC => returning true" << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
const RsGxsCircleId& circleId = grpMeta.mCircleId;
|
||||
|
||||
if(circleType == GXS_CIRCLE_TYPE_EXTERNAL)
|
||||
else if(circleType == GXS_CIRCLE_TYPE_EXTERNAL)
|
||||
{
|
||||
const RsGxsCircleId& circleId = grpMeta.mCircleId;
|
||||
#ifdef NXS_NET_DEBUG_4
|
||||
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " Circle type: EXTERNAL => returning true. Msgs ids list will be encrypted." << std::endl;
|
||||
#endif
|
||||
@ -4345,8 +4342,7 @@ bool RsGxsNetService::canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, co
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
|
||||
else if(circleType == GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_4
|
||||
GXSNETDEBUG_PG(sslId,grpMeta.mGroupId) << " YOUREYESONLY, checking further" << std::endl;
|
||||
@ -4357,8 +4353,11 @@ bool RsGxsNetService::canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, co
|
||||
#endif
|
||||
return res ;
|
||||
}
|
||||
|
||||
return false;
|
||||
else
|
||||
{
|
||||
std::cerr << "(EE) unknown value found in circle type for group " << grpMeta.mGroupId << ": " << (int)circleType << ": this is probably a bug in the design of the group creation." << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** inherited methods **/
|
||||
|
@ -52,6 +52,7 @@ typedef RsPgpId RsPgpId;
|
||||
// The meaning of the different circle types is:
|
||||
//
|
||||
//
|
||||
static const uint32_t GXS_CIRCLE_TYPE_UNKNOWN = 0x0000 ; // not known. Is treated as public.
|
||||
static const uint32_t GXS_CIRCLE_TYPE_PUBLIC = 0x0001 ; // not restricted to a circle
|
||||
static const uint32_t GXS_CIRCLE_TYPE_EXTERNAL = 0x0002 ; // restricted to an external circle, made of RsGxsId
|
||||
static const uint32_t GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY = 0x0003 ; // restricted to a subset of friend nodes of a given RS node given by a RsPgpId list
|
||||
|
@ -33,11 +33,13 @@ typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > MsgMetaResult;
|
||||
class RsGxsGrpMetaData;
|
||||
class RsGxsMsgMetaData;
|
||||
|
||||
|
||||
struct RsGroupMetaData
|
||||
{
|
||||
// (csoler) The correct default value to be used in mCircleType is GXS_CIRCLE_TYPE_PUBLIC, which is defined in rsgxscircles.h,
|
||||
// but because of a loop in the includes, I cannot include it here. So I replaced with its current value 0x0001.
|
||||
|
||||
RsGroupMetaData() : mGroupFlags(0), mSignFlags(0), mPublishTs(0),
|
||||
mCircleType(0), mAuthenFlags(0), mSubscribeFlags(0), mPop(0),
|
||||
mCircleType(0x0001), mAuthenFlags(0), mSubscribeFlags(0), mPop(0),
|
||||
mVisibleMsgCount(0), mLastPost(0), mGroupStatus(0) {}
|
||||
|
||||
void operator =(const RsGxsGrpMetaData& rGxsMeta);
|
||||
|
@ -43,6 +43,7 @@ extern RsIdentity *rsIdentity;
|
||||
|
||||
|
||||
// GroupFlags: Only one so far:
|
||||
#warning THIS FLAG OVERLAPS THE FLAGS FOR mGroupFlags. This is an error that should be fixed.
|
||||
#define RSGXSID_GROUPFLAG_REALID 0x0001
|
||||
|
||||
// THESE ARE FLAGS FOR INTERFACE.
|
||||
|
@ -690,6 +690,7 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters ¶ms)
|
||||
RsGxsIdGroup id;
|
||||
|
||||
id.mMeta.mGroupName = params.nickname;
|
||||
id.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC ;
|
||||
id.mImage = params.mImage;
|
||||
|
||||
if (params.isPgpLinked)
|
||||
@ -712,6 +713,7 @@ bool p3IdService::updateIdentity(uint32_t& token, RsGxsIdGroup &group)
|
||||
std::cerr << "p3IdService::updateIdentity()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
group.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC ;
|
||||
|
||||
updateGroup(token, group);
|
||||
|
||||
|
@ -199,7 +199,9 @@ QString GxsChannelPostItem::getTitleLabel()
|
||||
|
||||
QString GxsChannelPostItem::getMsgLabel()
|
||||
{
|
||||
return RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS);
|
||||
//return RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS);
|
||||
// Disabled, because emoticon replacement kills performance.
|
||||
return QString::fromUtf8(mPost.mMsg.c_str());
|
||||
}
|
||||
|
||||
QString GxsChannelPostItem::groupName()
|
||||
@ -359,8 +361,9 @@ void GxsChannelPostItem::fill()
|
||||
/* subject */
|
||||
ui->titleLabel->setText(QString::fromUtf8(mPost.mMeta.mMsgName.c_str()));
|
||||
|
||||
// fill first 4 lines of message
|
||||
ui->subjectLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 4), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||
// fill first 4 lines of message. (csoler) Disabled the replacement of smileys and links, because the cost is too crazy
|
||||
//ui->subjectLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 4), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||
ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 4)) ;
|
||||
|
||||
//QString score = QString::number(post.mTopScore);
|
||||
// scoreLabel->setText(score);
|
||||
|
@ -36,7 +36,9 @@ ChatLobbyToaster::ChatLobbyToaster(const ChatLobbyId &lobby_id, const RsGxsId &s
|
||||
connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide()));
|
||||
|
||||
/* set informations */
|
||||
ui.textLabel->setText(RsHtml().formatText(NULL, message, RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_CLEANSTYLE));
|
||||
//ui.textLabel->setText(RsHtml().formatText(NULL, message, RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_CLEANSTYLE));
|
||||
// Disabled, because emoticon replacement kills performance
|
||||
ui.textLabel->setText(RsHtml().formatText(NULL, message, RSHTML_FORMATTEXT_CLEANSTYLE));
|
||||
ui.avatarWidget->setFrameType(AvatarWidget::NORMAL_FRAME);
|
||||
ui.avatarWidget->setDefaultAvatar(":images/chat_64.png");
|
||||
|
||||
|
@ -34,7 +34,9 @@ ChatToaster::ChatToaster(const RsPeerId &peer_id, const QString &message) : QWid
|
||||
connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide()));
|
||||
|
||||
/* set informations */
|
||||
ui.textLabel->setText(RsHtml().formatText(NULL, message, RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_CLEANSTYLE));
|
||||
//ui.textLabel->setText(RsHtml().formatText(NULL, message, RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_CLEANSTYLE));
|
||||
// emoticons disabled because they kill performance.
|
||||
ui.textLabel->setText(RsHtml().formatText(NULL, message, RSHTML_FORMATTEXT_CLEANSTYLE));
|
||||
ui.toasterLabel->setText(QString::fromUtf8(rsPeers->getPeerName(mPeerId).c_str()));
|
||||
ui.avatarWidget->setFrameType(AvatarWidget::STATUS_FRAME);
|
||||
ui.avatarWidget->setId(ChatId(mPeerId));
|
||||
|
Loading…
Reference in New Issue
Block a user