cleaned debug info and disabled local circles before merge

This commit is contained in:
csoler 2016-03-24 19:46:08 -04:00
parent 7d8001b60d
commit 44cadc22b2
6 changed files with 87 additions and 67 deletions

View File

@ -61,7 +61,7 @@ static const uint32_t INDEX_AUTHEN_ADMIN = 0x00000040; // admin key
#define GXS_MASK "GXS_MASK_HACK"
#define GEN_EXCH_DEBUG 1
//#define GEN_EXCH_DEBUG 1
#define MSG_CLEANUP_PERIOD 60*5 // 5 minutes
#define INTEGRITY_CHECK_PERIOD 60*30 // 30 minutes

View File

@ -223,14 +223,14 @@
NXS_NET_DEBUG_7 encryption/decryption of transactions
***/
#define NXS_NET_DEBUG_0 1
#define NXS_NET_DEBUG_1 1
//#define NXS_NET_DEBUG_0 1
//#define NXS_NET_DEBUG_1 1
//#define NXS_NET_DEBUG_2 1
//#define NXS_NET_DEBUG_3 1
#define NXS_NET_DEBUG_4 1
#define NXS_NET_DEBUG_5 1
//#define NXS_NET_DEBUG_4 1
//#define NXS_NET_DEBUG_5 1
//#define NXS_NET_DEBUG_6 1
#define NXS_NET_DEBUG_7 1
//#define NXS_NET_DEBUG_7 1
#define GIXS_CUT_OFF 0
//#define NXS_FRAG
@ -252,6 +252,13 @@
#define GROUP_STATS_UPDATE_NB_PEERS 2 // number of peers to which the group stats are asked
#define MAX_ALLOWED_GXS_MESSAGE_SIZE 199000 // 200,000 bytes including signature and headers
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_UNKNOWN = 0x00 ;
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_NO_ERROR = 0x01 ;
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_CIRCLE_ERROR = 0x02 ;
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_ENCRYPTION_ERROR = 0x03 ;
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_SERIALISATION_ERROR = 0x04 ;
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ;
// Debug system to allow to print only for some IDs (group, Peer, etc)
#if defined(NXS_NET_DEBUG_0) || defined(NXS_NET_DEBUG_1) || defined(NXS_NET_DEBUG_2) || defined(NXS_NET_DEBUG_3) \
@ -264,9 +271,6 @@ static const uint32_t service_to_print = 0x218 ; //
class nullstream: public std::ostream {};
#if defined(NXS_NET_DEBUG_0) || defined(NXS_NET_DEBUG_1) || defined(NXS_NET_DEBUG_2) || defined(NXS_NET_DEBUG_3) \
|| defined(NXS_NET_DEBUG_4) || defined(NXS_NET_DEBUG_5) || defined(NXS_NET_DEBUG_6) || defined(NXS_NET_DEBUG_7)
static std::string nice_time_stamp(time_t now,time_t TS)
{
if(TS == 0)
@ -278,14 +282,7 @@ static std::string nice_time_stamp(time_t now,time_t TS)
return s.str() ;
}
}
#endif
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_UNKNOWN = 0x00 ;
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_NO_ERROR = 0x01 ;
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_CIRCLE_ERROR = 0x02 ;
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_ENCRYPTION_ERROR = 0x03 ;
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_SERIALISATION_ERROR = 0x04 ;
static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ;
static std::ostream& gxsnetdebug(const RsPeerId& peer_id,const RsGxsGroupId& grp_id,uint32_t service_type)
{
@ -1931,9 +1928,9 @@ void RsGxsNetService::updateServerSyncTS()
{
RsGxsMetaDataTemporaryMap<RsGxsGrpMetaData> gxsMap;
//#ifdef NXS_NET_DEBUG_0
#ifdef NXS_NET_DEBUG_0
GXSNETDEBUG___<< "updateServerSyncTS(): updating last modification time stamp of local data." << std::endl;
//#endif
#endif
{
RS_STACK_MUTEX(mNxsMutex) ;
@ -2512,8 +2509,8 @@ void RsGxsNetService::locked_processCompletedIncomingTrans(NxsTransaction* tr)
std::cerr << "RsGxsNetService::processCompletedTransactions(): item did not caste to msg" << std::endl;
}
#warning We need here to queue all incoming items into a list where the vetting will be checked
#warning in order to avoid someone without the proper rights to post in a group protected with an external circle
//#warning We need here to queue all incoming items into a list where the vetting will be checked
//#warning in order to avoid someone without the proper rights to post in a group protected with an external circle
#ifdef NXS_FRAG
// (cyril) This code does not work. Since we do not really need message fragmenting, I won't fix it.

View File

@ -281,7 +281,9 @@ IdDialog::IdDialog(QWidget *parent) :
void IdDialog::updateCirclesDisplay(bool)
{
#ifdef ID_DEBUG
std::cerr << "!!Updating circles display!" << std::endl;
#endif
requestCircleGroupMeta() ;
}
@ -292,8 +294,10 @@ void IdDialog::requestCircleGroupMeta()
{
mStateHelper->setLoading(CIRCLESDIALOG_GROUPMETA, true);
#ifdef ID_DEBUG
std::cerr << "CirclesDialog::requestGroupMeta()";
std::cerr << std::endl;
#endif
mCircleQueue->cancelActiveRequestTokens(CIRCLESDIALOG_GROUPMETA);
@ -308,8 +312,10 @@ void IdDialog::requestCircleGroupData(const RsGxsCircleId& circle_id)
{
mStateHelper->setLoading(CIRCLESDIALOG_GROUPDATA, true);
#ifdef ID_DEBUG
std::cerr << "CirclesDialog::requestGroupData()";
std::cerr << std::endl;
#endif
mCircleQueue->cancelActiveRequestTokens(CIRCLESDIALOG_GROUPDATA);
@ -327,8 +333,10 @@ void IdDialog::loadCircleGroupMeta(const uint32_t &token)
{
mStateHelper->setLoading(CIRCLESDIALOG_GROUPMETA, false);
#ifdef ID_DEBUG
std::cerr << "CirclesDialog::loadCircleGroupMeta()";
std::cerr << std::endl;
#endif
std::list<RsGroupMetaData> groupInfo;
std::list<RsGroupMetaData>::iterator vit;
@ -372,14 +380,18 @@ void IdDialog::loadCircleGroupMeta(const uint32_t &token)
for(vit = groupInfo.begin(); vit != groupInfo.end();)
{
#ifdef ID_DEBUG
std::cerr << "CirclesDialog::loadCircleGroupMeta() GroupId: " << vit->mGroupId << " Group: " << vit->mGroupName << std::endl;
#endif
QList<QTreeWidgetItem*> clist = ui->treeWidget_membership->findItems( QString::fromStdString(vit->mGroupId.toStdString()), Qt::MatchExactly|Qt::MatchRecursive, CIRCLEGROUP_CIRCLE_COL_GROUPID);
if(clist.empty())
{
++vit ;
#ifdef ID_DEBUG
std::cerr << " group not already in list." << std::endl;
#endif
continue ;
}
@ -404,26 +416,34 @@ void IdDialog::loadCircleGroupMeta(const uint32_t &token)
if(subscribed && !admin && item->parent() != mExternalSubCircleItem)
{
#ifdef ID_DEBUG
std::cerr << " Existing group is not in subscribed items although it is subscribed. Removing." << std::endl;
#endif
delete item ;
++vit ;
continue ;
}
if(!subscribed && !admin && item->parent() != mExternalOtherCircleItem)
{
#ifdef ID_DEBUG
std::cerr << " Existing group is not in subscribed items although it is subscribed. Removing." << std::endl;
#endif
delete item ;
++vit ;
continue ;
}
if(item->text(CIRCLEGROUP_CIRCLE_COL_GROUPNAME) != QString::fromUtf8(vit->mGroupName.c_str()))
{
#ifdef ID_DEBUG
std::cerr << " Existing group has a new name. Updating it in the tree." << std::endl;
#endif
item->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, QString::fromUtf8(vit->mGroupName.c_str()));
}
// the item is at the right place. Just remove it from the list of items to add.
#ifdef ID_DEBUG
std::cerr << " item already in place. Removing from list." << std::endl;
#endif
vit = groupInfo.erase(vit) ;
}
@ -443,17 +463,23 @@ void IdDialog::loadCircleGroupMeta(const uint32_t &token)
if (vit->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)
{
#ifdef ID_DEBUG
std::cerr << " adding item for group " << vit->mGroupId << " to admin"<< std::endl;
#endif
mExternalAdminCircleItem->addChild(groupItem);
}
else if (vit->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)
{
#ifdef ID_DEBUG
std::cerr << " adding item for group " << vit->mGroupId << " to subscribed"<< std::endl;
#endif
mExternalSubCircleItem->addChild(groupItem);
}
else
{
#ifdef ID_DEBUG
std::cerr << " adding item for group " << vit->mGroupId << " to others"<< std::endl;
#endif
mExternalOtherCircleItem->addChild(groupItem);
}
}
@ -474,7 +500,9 @@ static void mark_matching_tree(QTreeWidget *w, const std::set<RsGxsId>& members,
void IdDialog::loadCircleGroupData(const uint32_t& token)
{
#ifdef ID_DEBUG
std::cerr << "Loading circle info" << std::endl;
#endif
std::vector<RsGxsCircleGroup> circle_grp_v ;
rsGxsCircles->getGroupData(token, circle_grp_v);
@ -508,26 +536,10 @@ void IdDialog::loadCircleGroupData(const uint32_t& token)
return ;
}
// /* update friend lists */
// RsGxsCircleDetails details;
//
// if(!rsGxsCircles->getCircleDetails(id, details))
// {
// std::cerr << "(EE) Cannot load circle details. Weird." << std::endl;
// return ;
// }
/* now mark all the members */
std::set<RsGxsId> members = cg.mInvitedMembers;
// for(std::map<RsPgpId, std::set<RsGxsId> >::iterator it = details.mAllowedSignedPeers.begin(); it != details.mAllowedSignedPeers.end(); ++it)
// for(std::set<RsGxsId>::const_iterator it2=it->second.begin();it2!=it->second.end();++it2)
// {
// members.insert( (*it2) ) ;
// std::cerr << "Circle member: " << it->first << std::endl;
// }
mark_matching_tree(ui->idTreeWidget, members, RSID_COL_KEYID) ;
mStateHelper->setLoading(CIRCLESDIALOG_GROUPDATA, false);
@ -652,8 +664,10 @@ void IdDialog::circle_selected()
{
QTreeWidgetItem *item = ui->treeWidget_membership->currentItem();
#ifdef ID_DEBUG
std::cerr << "CirclesDialog::circle_selected() valid circle chosen";
std::cerr << std::endl;
#endif
if ((!item) || (!item->parent()))
{
@ -1399,8 +1413,10 @@ void IdDialog::loadRequest(const TokenQueue * queue, const TokenRequest &req)
if(queue == mCircleQueue)
{
#ifdef ID_DEBUG
std::cerr << "CirclesDialog::loadRequest() UserType: " << req.mUserType;
std::cerr << std::endl;
#endif
/* now switch on req */
switch(req.mUserType)
@ -1455,7 +1471,9 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
if(item_flags & RSID_FILTER_OWNED_BY_YOU)
one_item_owned_by_you = true ;
#ifdef ID_DEBUG
std::cerr << " item flags = " << item_flags << std::endl;
#endif
RsGxsId keyId((*it)->text(RSID_COL_KEYID).toStdString());
RsReputations::ReputationInfo info ;

View File

@ -312,10 +312,11 @@ void GxsGroupDialog::setupDefaults()
#ifndef RS_USE_CIRCLES
ui.typeGroup->setEnabled(false);
ui.typeLocal->setEnabled(false);
ui.typeGroup_3->setEnabled(false);
ui.typeLocal_3->setEnabled(false);
#endif
ui.typeLocal->setEnabled(false); // for now, since local circles not fully tested.
ui.typeLocal->setToolTip(tr("This feature is not yet available, but it will be available very soon!")); // for now, since local circles not fully tested.
}
void GxsGroupDialog::setupVisibility()

View File

@ -199,6 +199,7 @@ void GxsIdChooser::setEntryEnabled(int indx,bool enabled)
{
removeItem(indx) ;
#ifdef TO_REMOVE
// bool disable = !enabled ;
//
// QSortFilterProxyModel* model = qobject_cast<QSortFilterProxyModel*>(QComboBox::model());
@ -218,12 +219,14 @@ void GxsIdChooser::setEntryEnabled(int indx,bool enabled)
// model->setData(ii,QVariant(v),Qt::UserRole-1) ;
//
// std::cerr << "model data after operation: " << model->data(ii,Qt::UserRole-1).toUInt() << std::endl;
#endif
}
uint32_t GxsIdChooser::countEnabledEntries() const
{
return count() ;
#ifdef TO_REMOVE
// uint32_t res = 0 ;
// QSortFilterProxyModel* model = qobject_cast<QSortFilterProxyModel*>(QComboBox::model());
//
@ -238,6 +241,7 @@ uint32_t GxsIdChooser::countEnabledEntries() const
// }
//
// return res ;
#endif
}
void GxsIdChooser::loadPrivateIds()

View File

@ -126,7 +126,8 @@ void CreateGxsForumMsg::newMsg()
mForumMetaLoaded = false;
/* fill in the available OwnIds for signing */
std::cerr << "Initing ID chooser. Sign flags = " << std::hex << mForumMeta.mSignFlags << std::dec << std::endl;
//std::cerr << "Initing ID chooser. Sign flags = " << std::hex << mForumMeta.mSignFlags << std::dec << std::endl;
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
@ -148,8 +149,7 @@ void CreateGxsForumMsg::newMsg()
std::list<RsGxsGroupId> groupIds;
groupIds.push_back(mForumId);
std::cerr << "ForumsV2Dialog::newMsg() Requesting Group Summary(" << mForumId << ")";
std::cerr << std::endl;
//std::cerr << "ForumsV2Dialog::newMsg() Requesting Group Summary(" << mForumId << ")"<< std::endl;
uint32_t token;
mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEGXSFORUMMSG_FORUMINFO);
@ -168,8 +168,8 @@ void CreateGxsForumMsg::newMsg()
std::vector<RsGxsMessageId> &vect = msgIds[mForumId];
vect.push_back(mParentId);
std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")";
std::cerr << std::endl;
//std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")";
//std::cerr << std::endl;
uint32_t token;
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_PARENTMSG);
@ -183,8 +183,8 @@ void CreateGxsForumMsg::loadFormInformation()
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, true);
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, false);
} else {
std::cerr << "CreateGxsForumMsg::loadMsgInformation() ParentMsg not Loaded Yet";
std::cerr << std::endl;
//std::cerr << "CreateGxsForumMsg::loadMsgInformation() ParentMsg not Loaded Yet";
//std::cerr << std::endl;
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false);
@ -199,18 +199,18 @@ void CreateGxsForumMsg::loadFormInformation()
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, true);
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, false);
} else {
std::cerr << "CreateGxsForumMsg::loadMsgInformation() ForumMeta not Loaded Yet";
std::cerr << std::endl;
//std::cerr << "CreateGxsForumMsg::loadMsgInformation() ForumMeta not Loaded Yet";
//std::cerr << std::endl;
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
return;
}
std::cerr << "CreateGxsForumMsg::loadMsgInformation() Data Available!";
std::cerr << std::endl;
//std::cerr << "CreateGxsForumMsg::loadMsgInformation() Data Available!";
//std::cerr << std::endl;
std::cerr << "CreateGxsForumMsg::loadMsgInformation() using signFlags=" << std::hex << mForumMeta.mSignFlags << std::dec << std::endl;
//std::cerr << "CreateGxsForumMsg::loadMsgInformation() using signFlags=" << std::hex << mForumMeta.mSignFlags << std::dec << std::endl;
if(mForumMeta.mSignFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG)
ui.idChooser->setFlags(IDCHOOSER_ID_REQUIRED | IDCHOOSER_NON_ANONYMOUS) ;
@ -305,8 +305,8 @@ void CreateGxsForumMsg::createMsg()
case GxsIdChooser::KnowId:
case GxsIdChooser::UnKnowId:
msg.mMeta.mAuthorId = authorId;
std::cerr << "CreateGxsForumMsg::createMsg() AuthorId: " << authorId;
std::cerr << std::endl;
//std::cerr << "CreateGxsForumMsg::createMsg() AuthorId: " << authorId;
//std::cerr << std::endl;
break;
case GxsIdChooser::None:
@ -333,8 +333,8 @@ void CreateGxsForumMsg::createMsg()
return;
}//switch (ui.idChooser->getChosenId(authorId))
} else {
std::cerr << "CreateGxsForumMsg::createMsg() No Signature (for now :)";
std::cerr << std::endl;
//std::cerr << "CreateGxsForumMsg::createMsg() No Signature (for now :)";
//std::cerr << std::endl;
QMessageBox::warning(this, tr("RetroShare"),tr("Please choose Signing Id, it is required"), QMessageBox::Ok, QMessageBox::Ok);
return;
}//if (ui.signBox->isChecked())
@ -413,7 +413,7 @@ void CreateGxsForumMsg::addFile()
void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
{
std::cerr << "CreateGxsForumMsg::fileHashingFinished() started." << std::endl;
//std::cerr << "CreateGxsForumMsg::fileHashingFinished() started." << std::endl;
QString mesgString;
@ -436,8 +436,8 @@ void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
void CreateGxsForumMsg::loadForumInfo(const uint32_t &token)
{
std::cerr << "CreateGxsForumMsg::loadForumInfo()";
std::cerr << std::endl;
//std::cerr << "CreateGxsForumMsg::loadForumInfo()";
//std::cerr << std::endl;
std::list<RsGroupMetaData> groupInfo;
rsGxsForums->getGroupSummary(token, groupInfo);
@ -451,7 +451,7 @@ void CreateGxsForumMsg::loadForumInfo(const uint32_t &token)
if(!fi.mCircleId.isNull())
{
std::cerr << "Circle ID is not null: " << fi.mCircleId << ": loading circle info to add constraint to the GXS ID chooser." << std::endl;
//std::cerr << "Circle ID is not null: " << fi.mCircleId << ": loading circle info to add constraint to the GXS ID chooser." << std::endl;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
@ -476,7 +476,7 @@ void CreateGxsForumMsg::loadForumInfo(const uint32_t &token)
}
void CreateGxsForumMsg::loadForumCircleInfo(const uint32_t& token)
{
std::cerr << "Loading forum circle info" << std::endl;
//std::cerr << "Loading forum circle info" << std::endl;
std::vector<RsGxsCircleGroup> circle_grp_v ;
rsGxsCircles->getGroupData(token, circle_grp_v);
@ -498,10 +498,10 @@ void CreateGxsForumMsg::loadForumCircleInfo(const uint32_t& token)
mForumCircleData = cg;
mForumCircleLoaded = true;
std::cerr << "Loaded content of circle " << cg.mMeta.mGroupId << std::endl;
//std::cerr << "Loaded content of circle " << cg.mMeta.mGroupId << std::endl;
for(std::set<RsGxsId>::const_iterator it(cg.mInvitedMembers.begin());it!=cg.mInvitedMembers.end();++it)
std::cerr << " added constraint to circle element " << *it << std::endl;
//for(std::set<RsGxsId>::const_iterator it(cg.mInvitedMembers.begin());it!=cg.mInvitedMembers.end();++it)
// std::cerr << " added constraint to circle element " << *it << std::endl;
ui.idChooser->setIdConstraintSet(cg.mInvitedMembers) ;
ui.idChooser->setFlags(IDCHOOSER_NO_CREATE | ui.idChooser->flags()) ; // since there's a circle involved, no ID creation can be needed
@ -509,15 +509,15 @@ void CreateGxsForumMsg::loadForumCircleInfo(const uint32_t& token)
RsGxsId tmpid ;
if(ui.idChooser->countEnabledEntries() == 0)
{
QMessageBox::information(NULL,tr("No compatible ID for this forum"),tr("Sorry, but this forum is restricted to a circle that contains none of your identities. As a consequence you cannot post in this forum, since your posts could not be propagated.")) ;
QMessageBox::information(NULL,tr("No compatible ID for this forum"),tr("None of your identities is allowed to post in this forum. This could be due to the forum being limited to a circle that contains none of your identities, or forum flags requiring a PGP-signed identity.")) ;
close() ;
}
}
void CreateGxsForumMsg::loadParentMsg(const uint32_t &token)
{
std::cerr << "CreateGxsForumMsg::loadParentMsg()";
std::cerr << std::endl;
//std::cerr << "CreateGxsForumMsg::loadParentMsg()";
//std::cerr << std::endl;
// Only grab one.... ignore more (shouldn't be any).
std::vector<RsGxsForumMsg> msgs;
@ -544,8 +544,8 @@ void CreateGxsForumMsg::loadParentMsg(const uint32_t &token)
void CreateGxsForumMsg::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
std::cerr << "CreateGxsForum::loadRequest() UserType: " << req.mUserType;
std::cerr << std::endl;
//std::cerr << "CreateGxsForum::loadRequest() UserType: " << req.mUserType;
//std::cerr << std::endl;
if (queue == mForumQueue)
{