diff --git a/libretroshare/src/gxs/rsdataservice.cc b/libretroshare/src/gxs/rsdataservice.cc index 2c33de48e..30226f376 100644 --- a/libretroshare/src/gxs/rsdataservice.cc +++ b/libretroshare/src/gxs/rsdataservice.cc @@ -283,9 +283,7 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c) c.getString(COL_ORIG_GRP_ID, tempId); grpMeta->mOrigGrpId = tempId; c.getString(COL_GRP_SERV_STRING, grpMeta->mServiceString); - - c.getString(COL_HASH, tempId); - grpMeta->mHash = tempId ; + c.getString(COL_HASH, grpMeta->mHash); grpMeta->mSignFlags = c.getInt32(COL_GRP_SIGN_FLAGS); grpMeta->mPublishTs = c.getInt32(COL_TIME_STAMP); @@ -393,22 +391,21 @@ RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c) char* data = NULL; - std::string gId,tempId; + std::string gId; c.getString(COL_GRP_ID, gId); msgMeta->mGroupId = RsGxsGroupId(gId); - c.getString(COL_MSG_ID, tempId) ; - msgMeta->mMsgId = tempId ; - + std::string temp; + c.getString(COL_MSG_ID, temp); + msgMeta->mMsgId = temp; // without these, a msg is meaningless ok &= (!msgMeta->mGroupId.isNull()) && (!msgMeta->mMsgId.isNull()); - c.getString(COL_ORIG_MSG_ID, tempId) ; - msgMeta->mOrigMsgId = tempId ; + c.getString(COL_ORIG_MSG_ID, temp); + msgMeta->mOrigMsgId = temp; c.getString(COL_IDENTITY, msgMeta->mAuthorId); c.getString(COL_MSG_NAME, msgMeta->mMsgName); c.getString(COL_MSG_SERV_STRING, msgMeta->mServiceString); - c.getString(COL_HASH, tempId) ; - msgMeta->mHash = tempId; + c.getString(COL_HASH, msgMeta->mHash); msgMeta->recvTS = c.getInt32(COL_MSG_RECV_TS); offset = 0; @@ -422,8 +419,10 @@ RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c) offset = 0; data_len = 0; // thread and parent id - c.getString(COL_THREAD_ID, tempId) ; msgMeta->mThreadId = tempId ; - c.getString(COL_PARENT_ID, tempId) ; msgMeta->mParentId = tempId ; + c.getString(COL_THREAD_ID, temp); + msgMeta->mThreadId = temp; + c.getString(COL_PARENT_ID, temp); + msgMeta->mParentId = temp; // local meta msgMeta->mMsgStatus = c.getInt32(COL_MSG_STATUS); @@ -445,12 +444,13 @@ RsNxsMsg* RsDataService::locked_getMessage(RetroCursor &c) RsNxsMsg* msg = new RsNxsMsg(mServType); bool ok = true; - std::string tempId ; uint32_t data_len = 0, offset = 0; char* data = NULL; c.getStringT(COL_ACT_GROUP_ID, msg->grpId); - c.getString(COL_ACT_MSG_ID, tempId) ; msg->msgId = tempId ; + std::string temp; + c.getString(COL_ACT_MSG_ID, temp); + msg->msgId = temp; ok &= (!msg->grpId.isNull()) && (!msg->msgId.isNull()); @@ -522,7 +522,7 @@ int RsDataService::storeMessage(std::map &msg) cv.put(KEY_MSG_ID, msgMetaPtr->mMsgId.toStdString()); cv.put(KEY_GRP_ID, msgMetaPtr->mGroupId.toStdString()); cv.put(KEY_NXS_SERV_STRING, msgMetaPtr->mServiceString); - cv.put(KEY_NXS_HASH, msgMetaPtr->mHash.toStdString()); + cv.put(KEY_NXS_HASH, msgMetaPtr->mHash); cv.put(KEY_RECV_TS, (int32_t)msgMetaPtr->recvTS); @@ -631,7 +631,7 @@ int RsDataService::storeGroup(std::map &grp) cv.put(KEY_GRP_ORIGINATOR, grpMetaPtr->mOriginator.toStdString()); cv.put(KEY_GRP_AUTHEN_FLAGS, (int32_t)grpMetaPtr->mAuthenFlags); cv.put(KEY_PARENT_GRP_ID, grpMetaPtr->mParentGrpId.toStdString()); - cv.put(KEY_NXS_HASH, grpMetaPtr->mHash.toStdString()); + cv.put(KEY_NXS_HASH, grpMetaPtr->mHash); cv.put(KEY_RECV_TS, (int32_t)grpMetaPtr->mRecvTS); if(! (grpMetaPtr->mAuthorId.empty()) ){ @@ -723,7 +723,7 @@ int RsDataService::updateGroup(std::map &grp) cv.put(KEY_GRP_INTERNAL_CIRCLE, grpMetaPtr->mInternalCircle); cv.put(KEY_GRP_ORIGINATOR, grpMetaPtr->mOriginator.toStdString()); cv.put(KEY_GRP_AUTHEN_FLAGS, (int32_t)grpMetaPtr->mAuthenFlags); - cv.put(KEY_NXS_HASH, grpMetaPtr->mHash.toStdString()); + cv.put(KEY_NXS_HASH, grpMetaPtr->mHash); if(! (grpMetaPtr->mAuthorId.empty()) ){ cv.put(KEY_NXS_IDENTITY, grpMetaPtr->mAuthorId); @@ -1416,9 +1416,10 @@ void RsDataService::locked_getMessageOffsets(const RsGxsGroupId& grpId, std::vec { RsGxsMessageId msgId; int32_t msgLen; - int32_t msgOffSet; - std::string tempId ; - c->getString(0, tempId) ; msgId = tempId; + int32_t msgOffSet; + std::string temp; + c->getString(0, temp); + msgId = temp; msgOffSet = c->getInt32(1); msgLen = c->getInt32(2); diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index c8a08b740..17057acc6 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -690,7 +690,9 @@ int RsGenExchange::createMessage(RsNxsMsg* msg) // get hash of msg data to create msg id pqihash hash; hash.addData(allMsgData, allMsgDataLen); - hash.Complete(msg->msgId); + std::string hashId; + hash.Complete(hashId); + msg->msgId = hashId; // assign msg id to msg meta msg->metaData->mMsgId = msg->msgId; @@ -1769,7 +1771,7 @@ void RsGenExchange::publishMsgs() { // empty orig msg id means this is the original // msg - if(msg->metaData->mOrigMsgId.isNull()) + if(msg->metaData->mOrigMsgId.isNull()) { msg->metaData->mOrigMsgId = msg->metaData->mMsgId; } @@ -2218,7 +2220,7 @@ void RsGenExchange::processRecvdData() } -void RsGenExchange::computeHash(const RsTlvBinaryData& data, RsFileHash& hash) +void RsGenExchange::computeHash(const RsTlvBinaryData& data, std::string& hash) { pqihash pHash; pHash.addData(data.bin_data, data.bin_len); diff --git a/libretroshare/src/gxs/rsgxsdata.cc b/libretroshare/src/gxs/rsgxsdata.cc index d790ea5c3..18dadb962 100644 --- a/libretroshare/src/gxs/rsgxsdata.cc +++ b/libretroshare/src/gxs/rsgxsdata.cc @@ -228,10 +228,10 @@ bool RsGxsMsgMetaData::serialise(void *data, uint32_t *size) offset += 8; ok &= mGroupId.serialise(data, *size, offset); - ok &= mMsgId.serialise(data, *size, offset) ; - ok &= mThreadId.serialise(data, *size, offset) ; - ok &= mParentId.serialise(data, *size, offset) ; - ok &= mOrigMsgId.serialise(data, *size, offset) ; + ok &= mMsgId.serialise(data, *size, offset); + ok &= mThreadId.serialise(data, *size, offset); + ok &= mParentId.serialise(data, *size, offset); + ok &= mOrigMsgId.serialise(data, *size, offset); ok &= SetTlvString(data, *size, &offset, 0, mAuthorId); ok &= signSet.SetTlv(data, *size, &offset); @@ -255,10 +255,10 @@ bool RsGxsMsgMetaData::deserialise(void *data, uint32_t *size) if(!ok) return false; ok &= mGroupId.deserialise(data, *size, offset); - ok &= mMsgId.serialise(data, *size, offset) ; - ok &= mThreadId.serialise(data, *size,offset) ; - ok &= mParentId.serialise(data, *size, offset) ; - ok &= mOrigMsgId.serialise(data, *size, offset) ; + ok &= mMsgId.deserialise(data, *size, offset); + ok &= mThreadId.deserialise(data, *size, offset); + ok &= mParentId.deserialise(data, *size, offset); + ok &= mOrigMsgId.deserialise(data, *size, offset); ok &= GetTlvString(data, *size, &offset, 0, mAuthorId); ok &= signSet.GetTlv(data, *size, &offset); diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 36b952818..a30385ce5 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -1490,7 +1490,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr) std::vector &msgMetaV = result[grpId]; std::vector::const_iterator vit = msgMetaV.begin(); - std::set msgIdSet; + std::set msgIdSet; // put ids in set for each searching for(; vit != msgMetaV.end(); vit++) @@ -1517,7 +1517,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr) for(; llit != msgItemL.end(); llit++) { RsNxsSyncMsgItem*& syncItem = *llit; - const RsGxsMessageId& msgId = syncItem->msgId; + const RsGxsMessageId& msgId = syncItem->msgId; if(msgIdSet.find(msgId) == msgIdSet.end()){ @@ -2221,7 +2221,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsg* item) if(grpMeta == NULL) return; - req[item->grpId] = std::vector(); + req[item->grpId] = std::vector(); mDataStore->retrieveGxsMsgMetaData(req, metaResult); std::vector& msgMetas = metaResult[item->grpId]; diff --git a/libretroshare/src/retroshare/rsgxscommon.h b/libretroshare/src/retroshare/rsgxscommon.h index 79ffd9952..bfb172b72 100644 --- a/libretroshare/src/retroshare/rsgxscommon.h +++ b/libretroshare/src/retroshare/rsgxscommon.h @@ -37,7 +37,7 @@ class RsGxsFile public: RsGxsFile(); std::string mName; - RsFileHash mHash; + RsFileHash mHash; uint64_t mSize; //std::string mPath; }; diff --git a/libretroshare/src/retroshare/rsgxsifacetypes.h b/libretroshare/src/retroshare/rsgxsifacetypes.h index 5c37b6409..d8f855fc6 100644 --- a/libretroshare/src/retroshare/rsgxsifacetypes.h +++ b/libretroshare/src/retroshare/rsgxsifacetypes.h @@ -16,7 +16,7 @@ #include typedef GXSGroupId RsGxsGroupId; -typedef RsFileHash RsGxsMessageId; +typedef Sha1CheckSum RsGxsMessageId; typedef std::map > GxsMsgIdResult; typedef std::pair RsGxsGrpMsgIdPair; diff --git a/libretroshare/src/retroshare/rsids.h b/libretroshare/src/retroshare/rsids.h index daacf20f7..71aac52e7 100644 --- a/libretroshare/src/retroshare/rsids.h +++ b/libretroshare/src/retroshare/rsids.h @@ -145,14 +145,17 @@ template s return res ; } - +void chris_test(); template t_RsGenericIdType::t_RsGenericIdType(const std::string& s) { try { int n=0; if(s.length() != ID_SIZE_IN_BYTES*2) + { throw std::runtime_error("t_RsGenericIdType<>::t_RsGenericIdType(std::string&): supplied string in constructor has wrong size.") ; + chris_test(); + } for(uint32_t i = 0; i < ID_SIZE_IN_BYTES; ++i) { @@ -176,6 +179,7 @@ template t catch(std::exception& e) { std::cerr << e.what() << std::endl; + chris_test(); clear() ; } } @@ -212,6 +216,5 @@ typedef t_RsGenericIdType< PGP_KEY_FINGERPRINT_SIZE, true, RS_GENERIC_ID_PGP_F typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_GROUP_ID_TYPE > GXSGroupId ; typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_ID_TYPE > GXSId ; -typedef t_RsGenericIdType< SHA1_SIZE , false, RS_GENERIC_ID_GXS_MSG_ID_TYPE > GXSMsgId ; typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_CIRCLE_ID_TYPE > GXSCircleId ; diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 52ff96877..c90647f2a 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -1401,7 +1401,7 @@ int RsServer::StartupRetroShare() RsGxsNetService* gxsid_ns = new RsGxsNetService( RS_SERVICE_GXSV2_TYPE_GXSID, gxsid_ds, nxsMgr, mGxsIdService, mGxsIdService, mGxsCircles, - false); // don't synchronise group automatic (need explicit group request) + true); // don't synchronise group automatic (need explicit group request) mGxsIdService->setNes(gxsid_ns); /**** GxsCircle service ****/ @@ -1815,3 +1815,10 @@ int RsServer::StartupRetroShare() return 1; } + + +void chris_test() +{ + std::cout << "tested\n"; +} + diff --git a/libretroshare/src/serialiser/rsnxsitems.cc b/libretroshare/src/serialiser/rsnxsitems.cc index 04eebce71..00d9227e3 100644 --- a/libretroshare/src/serialiser/rsnxsitems.cc +++ b/libretroshare/src/serialiser/rsnxsitems.cc @@ -204,7 +204,7 @@ bool RsNxsSerialiser::serialiseNxsSynMsgItem(RsNxsSyncMsgItem *item, void *data, ok &= setRawUInt32(data, *size, &offset, item->transactionNumber); ok &= setRawUInt8(data, *size, &offset, item->flag); ok &= item->grpId.serialise(data, *size, offset); - ok &= item->msgId.serialise(data, *size, offset) ; + ok &= item->msgId.serialise(data, *size, offset); ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_NAME, item->authorId); if(offset != tlvsize){ @@ -253,7 +253,7 @@ bool RsNxsSerialiser::serialiseNxsMsg(RsNxsMsg *item, void *data, uint32_t *size ok &= setRawUInt32(data, *size, &offset, item->transactionNumber); ok &= setRawUInt8(data, *size, &offset, item->pos); - ok &= item->msgId.serialise(data, tlvsize, offset) ; + ok &= item->msgId.serialise(data, *size, offset); ok &= item->grpId.serialise(data, *size, offset); ok &= item->msg.SetTlv(data, tlvsize, &offset); ok &= item->meta.SetTlv(data, *size, &offset); @@ -643,7 +643,7 @@ RsNxsMsg* RsNxsSerialiser::deserialNxsMsg(void *data, uint32_t *size){ ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber)); ok &= getRawUInt8(data, *size, &offset, &(item->pos)); - ok &= item->msgId.deserialise(data, *size, offset) ; + ok &= item->msgId.deserialise(data, *size, offset); ok &= item->grpId.deserialise(data, *size, offset); ok &= item->msg.GetTlv(data, *size, &offset); ok &= item->meta.GetTlv(data, *size, &offset); @@ -917,7 +917,7 @@ RsNxsSyncMsgItem* RsNxsSerialiser::deserialNxsSyncMsgItem(void *data, uint32_t * ok &= getRawUInt32(data, *size, &offset, &(item->transactionNumber)); ok &= getRawUInt8(data, *size, &offset, &(item->flag)); ok &= item->grpId.deserialise(data, *size, offset); - ok &= item->msgId.deserialise(data, *size, offset) ; + ok &= item->msgId.deserialise(data, *size, offset); ok &= GetTlvString(data, *size, &offset, TLV_TYPE_STR_NAME, item->authorId); if (offset != rssize) diff --git a/libretroshare/src/serialiser/rsnxsitems.h b/libretroshare/src/serialiser/rsnxsitems.h index 36551bd7e..93c3f48ab 100644 --- a/libretroshare/src/serialiser/rsnxsitems.h +++ b/libretroshare/src/serialiser/rsnxsitems.h @@ -296,7 +296,7 @@ public: uint8_t pos; /// used for splitting up msg uint8_t count; /// number of split up messages RsGxsGroupId grpId; /// group id, forms part of version id - RsFileHash msgId; /// msg id + RsGxsMessageId msgId; /// msg id static int refcount; /*! diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index 3005241d3..8a5e29cb9 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -598,7 +598,7 @@ void p3GxsChannels::handleUnprocessedPost(const RsGxsChannelPost &msg) for(fit = msg.mFiles.begin(); fit != msg.mFiles.end(); fit++) { std::string fname = fit->mName; - RsFileHash hash = fit->mHash; + Sha1CheckSum hash = Sha1CheckSum(fit->mHash); uint64_t size = fit->mSize; std::list srcIds; @@ -685,6 +685,7 @@ bool p3GxsChannels::autoDownloadEnabled(const RsGxsGroupId &id) bool SSGxsChannelGroup::load(const std::string &input) { + char line[RSGXSCHANNEL_MAX_SERVICE_STRING]; int download_val; mAutoDownload = false; if (1 == sscanf(input.c_str(), "D:%d", &download_val)) @@ -831,10 +832,11 @@ bool p3GxsChannels::ExtraFileHash(const std::string &path, std::string filename) } -bool p3GxsChannels::ExtraFileRemove(const RsFileHash &hash) +bool p3GxsChannels::ExtraFileRemove(const std::string &hash) { TransferRequestFlags tflags = RS_FILE_REQ_ANONYMOUS_ROUTING | RS_FILE_REQ_EXTRA; - return rsFiles->ExtraFileRemove(hash, tflags); + RsFileHash fh = RsFileHash(hash); + return rsFiles->ExtraFileRemove(fh, tflags); } @@ -1015,7 +1017,7 @@ void p3GxsChannels::dummy_tick() RsGxsGroupId grpId = ref.mGroupId; RsGxsMessageId parentId = ref.mMsgId; mGenThreadId = ref.mThreadId; - if (mGenThreadId.isNull()) + if (mGenThreadId.empty()) { mGenThreadId = parentId; } @@ -1037,7 +1039,7 @@ void p3GxsChannels::dummy_tick() RsGxsGroupId grpId = ref.mGroupId; RsGxsMessageId parentId = ref.mMsgId; mGenThreadId = ref.mThreadId; - if (mGenThreadId.isNull()) + if (mGenThreadId.empty()) { mGenThreadId = parentId; } @@ -1059,7 +1061,7 @@ void p3GxsChannels::dummy_tick() RsGxsGroupId grpId = ref.mGroupId; RsGxsMessageId parentId = ref.mMsgId; mGenThreadId = ref.mThreadId; - if (mGenThreadId.isNull()) + if (mGenThreadId.empty()) { mGenThreadId = parentId; } @@ -1107,7 +1109,7 @@ bool p3GxsChannels::generateComment(uint32_t &token, const RsGxsGroupId &grpId, std::string rndId = genRandomId(); rs_sprintf(msg.mComment, "Channel Comment: GroupId: %s, ThreadId: %s, ParentId: %s + some randomness: %s", - grpId.toStdString().c_str(), threadId.toStdString().c_str(), parentId.toStdString().c_str(), rndId.c_str()); + grpId.toStdString().c_str(), threadId.c_str(), parentId.c_str(), rndId.c_str()); msg.mMeta.mMsgName = msg.mComment; diff --git a/libretroshare/src/services/p3gxscommon.cc b/libretroshare/src/services/p3gxscommon.cc index 602bf6cb7..d3ad5b1eb 100644 --- a/libretroshare/src/services/p3gxscommon.cc +++ b/libretroshare/src/services/p3gxscommon.cc @@ -414,14 +414,14 @@ bool p3GxsCommentService::createGxsVote(uint32_t &token, RsGxsVote &vote) std::cerr << std::endl; /* vote must be associated with another item */ - if (vote.mMeta.mThreadId.isNull()) + if (vote.mMeta.mThreadId.isNull()) { std::cerr << "p3GxsCommentService::createGxsVote() ERROR Missing Required ThreadId"; std::cerr << std::endl; return false; } - if (vote.mMeta.mParentId.isNull()) + if (vote.mMeta.mParentId.isNull()) { std::cerr << "p3GxsCommentService::createGxsVote() ERROR Missing Required ParentId"; std::cerr << std::endl; diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index 03dbfc7ba..651c33506 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -396,7 +396,7 @@ void p3GxsForums::dummy_tick() RsGxsGroupId grpId = ref.mGroupId; RsGxsMessageId parentId = ref.mMsgId; mGenThreadId = ref.mThreadId; - if (mGenThreadId.isNull()) + if (mGenThreadId.isNull()) { mGenThreadId = parentId; } @@ -420,7 +420,7 @@ bool p3GxsForums::generateMessage(uint32_t &token, const RsGxsGroupId &grpId, co std::string rndId = genRandomId(); rs_sprintf(msg.mMsg, "Forum Msg: GroupId: %s, ThreadId: %s, ParentId: %s + some randomness: %s", - grpId.toStdString().c_str(), threadId.toStdString().c_str(), parentId.toStdString().c_str(), rndId.c_str()); + grpId.toStdString().c_str(), threadId.toStdString().c_str(), parentId.toStdString().c_str(), rndId.c_str()); msg.mMeta.mMsgName = msg.mMsg; diff --git a/libretroshare/src/services/p3postbase.cc b/libretroshare/src/services/p3postbase.cc index d67ab1d4c..ef5f9dfe0 100644 --- a/libretroshare/src/services/p3postbase.cc +++ b/libretroshare/src/services/p3postbase.cc @@ -429,7 +429,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed) } /* 3 types expected: PostedPost, Comment and Vote */ - if (parentId.isNull()) + if (parentId.isNull()) { /* we don't care about top-level (Posts) */ std::cerr << "\tIgnoring TopLevel Item"; diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index aa2a4f4f0..53ae421b6 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -88,9 +88,9 @@ void GxsCommentTreeWidget::customPopUpMenu(const QPoint& point) { QMenu contextMnu( this ); QAction* action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Reply to Comment"), this, SLOT(replyToComment())); - action->setDisabled(mCurrentMsgId.empty()); + action->setDisabled(mCurrentMsgId.isNull()); action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Submit Comment"), this, SLOT(makeComment())); - action->setDisabled(mThreadId.first.empty()); + action->setDisabled(mThreadId.first.isNull()); contextMnu.addSeparator(); @@ -100,7 +100,7 @@ void GxsCommentTreeWidget::customPopUpMenu(const QPoint& point) action->setDisabled(mVoterId.empty()); - if (!mCurrentMsgId.empty()) + if (!mCurrentMsgId.isNull()) { contextMnu.addSeparator(); QMenu *rep_menu = contextMnu.addMenu(tr("Reputation")); @@ -264,12 +264,12 @@ void GxsCommentTreeWidget::clearItems() void GxsCommentTreeWidget::completeItems() { /* handle pending items */ - std::string parentId; + RsGxsMessageId parentId; QTreeWidgetItem *parent = NULL; QList topLevelItems; - std::map::iterator lit; - std::multimap::iterator pit; + std::map::iterator lit; + std::multimap::iterator pit; std::cerr << "GxsCommentTreeWidget::completeItems() " << mPendingInsertMap.size(); std::cerr << " PendingItems"; @@ -334,7 +334,7 @@ void GxsCommentTreeWidget::completeItems() } -void GxsCommentTreeWidget::addItem(std::string itemId, std::string parentId, QTreeWidgetItem *item) +void GxsCommentTreeWidget::addItem(RsGxsMessageId itemId, RsGxsMessageId parentId, QTreeWidgetItem *item) { std::cerr << "GxsCommentTreeWidget::addItem() Id: " << itemId; std::cerr << " ParentId: " << parentId; @@ -343,7 +343,7 @@ void GxsCommentTreeWidget::addItem(std::string itemId, std::string parentId, QTr /* store in map -> for children */ mLoadingMap[itemId] = item; - std::map::iterator it; + std::map::iterator it; it = mLoadingMap.find(parentId); if (it != mLoadingMap.end()) { @@ -437,10 +437,10 @@ void GxsCommentTreeWidget::service_loadThread(const uint32_t &token) text = QString::number(comment.mOwnVote); item->setText(PCITEM_COLUMN_OWNVOTE, text); - text = QString::fromUtf8(comment.mMeta.mMsgId.c_str()); + text = QString::fromUtf8(comment.mMeta.mMsgId.toStdString().c_str()); item->setText(PCITEM_COLUMN_MSGID, text); - text = QString::fromUtf8(comment.mMeta.mParentId.c_str()); + text = QString::fromUtf8(comment.mMeta.mParentId.toStdString().c_str()); item->setText(PCITEM_COLUMN_PARENTID, text); @@ -467,7 +467,7 @@ QTreeWidgetItem *GxsCommentTreeWidget::service_createMissingItem(const RsGxsMess item->setText(PCITEM_COLUMN_MSGID, text); - text = QString::fromUtf8(parent.c_str()); + text = QString::fromUtf8(parent.toStdString().c_str()); item->setText(PCITEM_COLUMN_PARENTID, text); return item; diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h index 275d34507..26109bda5 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h @@ -60,7 +60,7 @@ protected: void loadThread(const uint32_t &token); - void addItem(std::string itemId, std::string parentId, QTreeWidgetItem *item); + void addItem(RsGxsMessageId itemId, RsGxsMessageId parentId, QTreeWidgetItem *item); public slots: void customPopUpMenu(const QPoint& point); @@ -88,8 +88,8 @@ protected: RsGxsMessageId mCurrentMsgId; RsGxsId mVoterId; - std::map mLoadingMap; - std::multimap mPendingInsertMap; + std::map mLoadingMap; + std::multimap mPendingInsertMap; TokenQueue *mTokenQueue; RsTokenService *mRsTokenService; diff --git a/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp b/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp index 56a9264ba..28a10f64f 100644 --- a/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp @@ -167,7 +167,7 @@ void GxsFeedItem::requestGroupMeta() return; } - std::list ids; + std::list ids; ids.push_back(mGroupId); RsTokReqOptions opts; diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index 1b2815453..4b0d25172 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -46,7 +46,7 @@ //#define ENABLE_GENERATE /** Constructor */ -CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &pId) +CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId) : QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId) { /* Invoke the Qt Designer generated object setup routine */ @@ -71,7 +71,7 @@ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string & mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui.forumSubject); mStateHelper->addClear(CREATEGXSFORUMMSG_PARENTMSG, ui.forumName); - QString text = pId.empty() ? tr("Start New Thread") : tr("Post Forum Message"); + QString text = pId.isNull() ? tr("Start New Thread") : tr("Post Forum Message"); setWindowTitle(text); ui.headerFrame->setHeaderImage(QPixmap(":/images/konversation64.png")); @@ -119,7 +119,7 @@ void CreateGxsForumMsg::newMsg() /* fill in the available OwnIds for signing */ ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, ""); - if (mForumId.empty()) { + if (mForumId.isNull()) { mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false); mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false); mStateHelper->clear(CREATEGXSFORUMMSG_FORUMINFO); @@ -135,7 +135,7 @@ void CreateGxsForumMsg::newMsg() RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; - std::list groupIds; + std::list groupIds; groupIds.push_back(mForumId); std::cerr << "ForumsV2Dialog::newMsg() Requesting Group Summary(" << mForumId << ")"; @@ -145,7 +145,7 @@ void CreateGxsForumMsg::newMsg() mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEGXSFORUMMSG_FORUMINFO); } - if (mParentId.empty()) + if (mParentId.isNull()) { mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, true); mParentMsgLoaded = true; @@ -171,7 +171,7 @@ void CreateGxsForumMsg::newMsg() void CreateGxsForumMsg::loadFormInformation() { - if (!mParentId.empty()) { + if (!mParentId.isNull()) { if (mParentMsgLoaded) { mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, true); mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, false); @@ -205,7 +205,7 @@ void CreateGxsForumMsg::loadFormInformation() QString name = QString::fromUtf8(mForumMeta.mGroupName.c_str()); QString subj; - if (!mParentId.empty()) + if (!mParentId.isNull()) { QString title = QString::fromUtf8(mParentMsg.mMeta.mMsgName.c_str()); name += " " + tr("In Reply to") + ": "; @@ -373,7 +373,8 @@ void CreateGxsForumMsg::fileHashingFinished(QList hashedFiles) for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) { HashedFile& hashedFile = *it; RetroShareLink link; - if (link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash))) { + if (link.createFile(hashedFile.filename, hashedFile.size, + QString::fromStdString(hashedFile.hash.toStdString()))) { mesgString += link.toHtmlSize() + "
"; } } diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.h b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.h index 8f82926fd..7a0b5e773 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.h +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.h @@ -35,7 +35,7 @@ class CreateGxsForumMsg : public QDialog, public TokenResponse Q_OBJECT public: - CreateGxsForumMsg(const std::string &fId, const std::string &pId); + CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId); ~CreateGxsForumMsg(); void newMsg(); /* cleanup */ @@ -59,8 +59,8 @@ private: void loadForumInfo(const uint32_t &token); void loadParentMsg(const uint32_t &token); - std::string mForumId; - std::string mParentId; + RsGxsGroupId mForumId; + RsGxsMessageId mParentId; bool mParentMsgLoaded; bool mForumMetaLoaded; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index fbeaaceee..4a4f60dda 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -86,7 +86,7 @@ #define TOKEN_TYPE_INSERT_POST 2 #define TOKEN_TYPE_REPLY_MESSAGE 3 -GxsForumThreadWidget::GxsForumThreadWidget(const std::string &forumId, QWidget *parent) : +GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget *parent) : RsGxsUpdateBroadcastWidget(rsGxsForums, parent), ui(new Ui::GxsForumThreadWidget) { @@ -256,16 +256,16 @@ void GxsForumThreadWidget::processSettings(bool load) mInProcessSettings = false; } -void GxsForumThreadWidget::setForumId(const std::string &forumId) +void GxsForumThreadWidget::setForumId(const RsGxsGroupId &forumId) { if (mForumId == forumId) { - if (!forumId.empty()) { + if (!forumId.isNull()) { return; } } mForumId = forumId; - ui->forumName->setText(mForumId.empty () ? "" : tr("Loading")); + ui->forumName->setText(mForumId.isNull () ? "" : tr("Loading")); mNewCount = 0; mUnreadCount = 0; @@ -276,7 +276,7 @@ void GxsForumThreadWidget::setForumId(const std::string &forumId) QString GxsForumThreadWidget::forumName(bool withUnreadCount) { - QString name = mForumId.empty () ? tr("No name") : ui->forumName->text(); + QString name = mForumId.isNull () ? tr("No name") : ui->forumName->text(); if (withUnreadCount && mUnreadCount) { name += QString(" (%1)").arg(mUnreadCount); @@ -414,7 +414,7 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) contextMnu.addAction(newthreadAct); contextMnu.addAction(replyauthorAct); QAction* action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink())); - action->setEnabled(!mForumId.empty() && !mThreadId.empty()); + action->setEnabled(!mForumId.isNull() && !mThreadId.isNull()); contextMnu.addSeparator(); contextMnu.addAction(markMsgAsRead); contextMnu.addAction(markMsgAsReadChildren); @@ -489,7 +489,7 @@ void GxsForumThreadWidget::clickedThread(QTreeWidgetItem *item, int column) return; } - if (mForumId.empty() || !IS_GROUP_SUBSCRIBED(mSubscribeFlags)) { + if (mForumId.isNull() || !IS_GROUP_SUBSCRIBED(mSubscribeFlags)) { return; } @@ -804,7 +804,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum item->setText(COLUMN_THREAD_DATE, text); item->setData(COLUMN_THREAD_DATE, ROLE_THREAD_SORT, sort); - item->setText(COLUMN_THREAD_AUTHOR, QString::fromStdString(msg.mMeta.mAuthorId.toStdString())); + item->setText(COLUMN_THREAD_AUTHOR, QString::fromStdString(msg.mMeta.mAuthorId)); //item->setId(msg.mMeta.mAuthorId, COLUMN_THREAD_AUTHOR); //#TODO #if 0 @@ -840,7 +840,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum item->setText(COLUMN_THREAD_CONTENT, doc.toPlainText().replace(QString("\n"), QString(" "))); } - item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID, QString::fromStdString(msg.mMeta.mMsgId)); + item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID, QString::fromStdString(msg.mMeta.mMsgId.toStdString())); //#TODO #if 0 if (IS_GROUP_SUBSCRIBED(subscribeFlags) && !(msginfo.mMsgFlags & RS_DISTRIB_MISSING_MSG)) { @@ -857,11 +857,11 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum return item; } -QTreeWidgetItem *GxsForumThreadWidget::generateMissingItem(const std::string &msgId) +QTreeWidgetItem *GxsForumThreadWidget::generateMissingItem(const RsGxsMessageId &msgId) { GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole); item->setText(COLUMN_THREAD_TITLE, tr("[ ... Missing Message ... ]")); - item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID, QString::fromStdString(msgId)); + item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID, QString::fromStdString(msgId.toStdString())); item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING, true); return item; @@ -891,7 +891,7 @@ void GxsForumThreadWidget::insertThreads() mSubscribeFlags = 0; mForumDescription.clear(); - if (mForumId.empty()) + if (mForumId.isNull()) { /* not an actual forum - clear */ mStateHelper->setActive(TOKEN_TYPE_CURRENTFORUM, false); @@ -899,8 +899,8 @@ void GxsForumThreadWidget::insertThreads() mStateHelper->clear(TOKEN_TYPE_CURRENTFORUM); mStateHelper->clear(TOKEN_TYPE_INSERT_POST); /* clear last stored forumID */ - mForumId.erase(); - mLastForumID.erase(); + mForumId.clear(); + mLastForumID.clear(); #ifdef DEBUG_FORUMS std::cerr << "GxsForumsDialog::insertThreads() Current Thread Invalid" << std::endl; @@ -1131,7 +1131,7 @@ void GxsForumThreadWidget::fillChildren(QTreeWidgetItem *parentItem, QTreeWidget void GxsForumThreadWidget::insertPost() { - if (mForumId.empty()) + if (mForumId.isNull()) { mStateHelper->setActive(TOKEN_TYPE_CURRENTFORUM, false); mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false); @@ -1143,7 +1143,7 @@ void GxsForumThreadWidget::insertPost() return; } - if (mThreadId.empty()) + if (mThreadId.isNull()) { mStateHelper->setActive(TOKEN_TYPE_INSERT_POST, false); mStateHelper->clear(TOKEN_TYPE_INSERT_POST); @@ -1169,7 +1169,7 @@ void GxsForumThreadWidget::insertPost() return; } - mStateHelper->setWidgetEnabled(ui->newmessageButton, (IS_GROUP_SUBSCRIBED(mSubscribeFlags) && mThreadId.empty() == false)); + mStateHelper->setWidgetEnabled(ui->newmessageButton, (IS_GROUP_SUBSCRIBED(mSubscribeFlags) && mThreadId.isNull() == false)); /* blank text, incase we get nothing */ ui->postText->clear(); @@ -1227,7 +1227,8 @@ void GxsForumThreadWidget::insertPostData(const RsGxsForumMsg &msg) ui->time_label->setText(DateTime::formatLongDateTime(msg.mMeta.mPublishTs)); - std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId); + std::string authorName; + //= rsPeers->getPeerName(msg.mMeta.mAuthorId); QString text = QString::fromUtf8(authorName.c_str()); if (text.isEmpty()) @@ -1424,7 +1425,7 @@ void GxsForumThreadWidget::setMsgReadStatus(QList &rows, bool void GxsForumThreadWidget::markMsgAsReadUnread (bool read, bool children, bool forum) { - if (mForumId.empty() || !IS_GROUP_SUBSCRIBED(mSubscribeFlags)) { + if (mForumId.isNull() || !IS_GROUP_SUBSCRIBED(mSubscribeFlags)) { return; } @@ -1499,7 +1500,7 @@ void GxsForumThreadWidget::setAllMsgReadStatus(bool read) void GxsForumThreadWidget::copyMessageLink() { - if (mForumId.empty() || mThreadId.empty()) { + if (mForumId.isNull() || mThreadId.isNull()) { return; } @@ -1524,7 +1525,7 @@ void GxsForumThreadWidget::copyMessageLink() void GxsForumThreadWidget::createmessage() { - if (mForumId.empty () || !IS_GROUP_SUBSCRIBED(mSubscribeFlags)) { + if (mForumId.isNull () || !IS_GROUP_SUBSCRIBED(mSubscribeFlags)) { return; } @@ -1536,12 +1537,12 @@ void GxsForumThreadWidget::createmessage() void GxsForumThreadWidget::createthread() { - if (mForumId.empty ()) { + if (mForumId.isNull ()) { QMessageBox::information(this, tr("RetroShare"), tr("No Forum Selected!")); return; } - CreateGxsForumMsg *cfm = new CreateGxsForumMsg(mForumId, ""); + CreateGxsForumMsg *cfm = new CreateGxsForumMsg(mForumId, RsGxsMessageId()); cfm->show(); /* window will destroy itself! */ @@ -1550,7 +1551,7 @@ void GxsForumThreadWidget::createthread() static QString buildReplyHeader(const RsMsgMetaData &meta) { RetroShareLink link; - link.createMessage(meta.mAuthorId, ""); + //link.createMessage(meta.mAuthorId, ""); QString from = link.toHtml(); QString header = QString("-----%1-----").arg(QApplication::translate("GxsForumsDialog", "Original Message")); @@ -1567,7 +1568,7 @@ static QString buildReplyHeader(const RsMsgMetaData &meta) void GxsForumThreadWidget::replytomessage() { - if (mForumId.empty() || mThreadId.empty()) { + if (mForumId.isNull() || mThreadId.isNull()) { QMessageBox::information(this, tr("RetroShare"),tr("You cant reply to a non-existant Message")); return; } @@ -1587,14 +1588,14 @@ void GxsForumThreadWidget::replyMessageData(const RsGxsForumMsg &msg) } // NB: TODO REMOVE rsPeers references. - if (rsPeers->getPeerName(msg.mMeta.mAuthorId) !="") + if (rsPeers->getPeerName(RsPeerId(msg.mMeta.mAuthorId)) !="") { MessageComposer *msgDialog = MessageComposer::newMsg(); msgDialog->setTitleText(QString::fromUtf8(msg.mMeta.mMsgName.c_str()), MessageComposer::REPLY); msgDialog->setQuotedMsg(QString::fromUtf8(msg.mMsg.c_str()), buildReplyHeader(msg.mMeta)); - msgDialog->addRecipient(MessageComposer::TO, msg.mMeta.mAuthorId, false); + //msgDialog->addRecipient(MessageComposer::TO, msg.mMeta.mAuthorId, false); msgDialog->show(); msgDialog->activateWindow(); @@ -1678,7 +1679,7 @@ bool GxsForumThreadWidget::filterItem(QTreeWidgetItem *item, const QString &text /** Request / Response of Data ********************************/ /*********************** **** **** **** ***********************/ -void GxsForumThreadWidget::requestGroupSummary_CurrentForum(const std::string &forumId) +void GxsForumThreadWidget::requestGroupSummary_CurrentForum(const RsGxsGroupId &forumId) { ui->progressBar->reset(); mStateHelper->setLoading(TOKEN_TYPE_CURRENTFORUM, true); @@ -1690,7 +1691,7 @@ void GxsForumThreadWidget::requestGroupSummary_CurrentForum(const std::string &f mThreadQueue->cancelActiveRequestTokens(TOKEN_TYPE_CURRENTFORUM); - std::list grpIds; + std::list grpIds; grpIds.push_back(forumId); std::cerr << "GxsForumsDialog::requestGroupSummary_CurrentForum(" << forumId << ")"; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index f55773c1d..e120f47c7 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -25,7 +25,7 @@ class GxsForumThreadWidget : public RsGxsUpdateBroadcastWidget, public TokenResp Q_PROPERTY(QColor textColorMissing READ textColorMissing WRITE setTextColorMissing) public: - explicit GxsForumThreadWidget(const std::string &forumId, QWidget *parent = NULL); + explicit GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget *parent = NULL); ~GxsForumThreadWidget(); QColor textColorRead() const { return mTextColorRead; } @@ -40,15 +40,15 @@ public: void setTextColorNotSubscribed(QColor color) { mTextColorNotSubscribed = color; } void setTextColorMissing(QColor color) { mTextColorMissing = color; } - std::string forumId() { return mForumId; } - void setForumId(const std::string &forumId); + RsGxsGroupId forumId() { return mForumId; } + void setForumId(const RsGxsGroupId &forumId); QString forumName(bool withUnreadCount); QIcon forumIcon(); unsigned int newCount() { return mNewCount; } unsigned int unreadCount() { return mUnreadCount; } QTreeWidgetItem *convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn); - QTreeWidgetItem *generateMissingItem(const std::string &msgId); + QTreeWidgetItem *generateMissingItem(const RsGxsMessageId &msgId); void setAllMsgReadStatus(bool read); @@ -129,9 +129,9 @@ private: void processSettings(bool bLoad); - std::string mForumId; - std::string mLastForumID; - std::string mThreadId; + RsGxsGroupId mForumId; + RsGxsGroupId mLastForumID; + RsGxsMessageId mThreadId; QString mForumDescription; int mSubscribeFlags; bool mInProcessSettings; @@ -143,7 +143,7 @@ private: unsigned int mUnreadCount; unsigned int mNewCount; - void requestGroupSummary_CurrentForum(const std::string &forumId); + void requestGroupSummary_CurrentForum(const RsGxsGroupId &forumId); void loadGroupSummary_CurrentForum(const uint32_t &token); void requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &msgId); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp index 4062caa81..db353e087 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp @@ -172,7 +172,7 @@ void GxsForumsDialog::settingsChanged() } } else { if (!mThreadWidget) { - mThreadWidget = createThreadWidget(""); + mThreadWidget = createThreadWidget(RsGxsGroupId()); // remove close button of the the first tab ui.threadTabWidget->hideCloseButton(ui.threadTabWidget->indexOf(mThreadWidget)); } @@ -181,7 +181,7 @@ void GxsForumsDialog::settingsChanged() void GxsForumsDialog::forumListCustomPopupMenu(QPoint /*point*/) { - int subscribeFlags = ui.forumTreeWidget->subscribeFlags(QString::fromStdString(mForumId)); + int subscribeFlags = ui.forumTreeWidget->subscribeFlags(QString::fromStdString(mForumId.toStdString())); QMenu contextMnu(this); @@ -200,14 +200,14 @@ void GxsForumsDialog::forumListCustomPopupMenu(QPoint /*point*/) #endif QAction *action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe to Forum"), this, SLOT(subscribeToForum())); - action->setDisabled (mForumId.empty() || IS_GROUP_SUBSCRIBED(subscribeFlags)); + action->setDisabled (mForumId.isNull() || IS_GROUP_SUBSCRIBED(subscribeFlags)); action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe to Forum"), this, SLOT(unsubscribeToForum())); - action->setEnabled (!mForumId.empty() && IS_GROUP_SUBSCRIBED(subscribeFlags)); + action->setEnabled (!mForumId.isNull() && IS_GROUP_SUBSCRIBED(subscribeFlags)); if (!Settings->getForumOpenAllInNewTab()) { action = contextMnu.addAction(QIcon(""), tr("Open in new tab"), this, SLOT(openInNewTab())); - if (mForumId.empty() || forumThreadWidget(mForumId)) { + if (mForumId.isNull() || forumThreadWidget(mForumId)) { action->setEnabled(false); } } @@ -217,31 +217,31 @@ void GxsForumsDialog::forumListCustomPopupMenu(QPoint /*point*/) contextMnu.addAction(QIcon(IMAGE_NEWFORUM), tr("New Forum"), this, SLOT(newforum())); action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Forum Details"), this, SLOT(showForumDetails())); - action->setEnabled (!mForumId.empty ()); + action->setEnabled (!mForumId.isNull()); action = contextMnu.addAction(QIcon(":/images/settings16.png"), tr("Edit Forum Details"), this, SLOT(editForumDetails())); - action->setEnabled (!mForumId.empty () && IS_GROUP_ADMIN(subscribeFlags)); + action->setEnabled (!mForumId.isNull() && IS_GROUP_ADMIN(subscribeFlags)); QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Forum"), &contextMnu); connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) ); - shareKeyAct->setEnabled(!mForumId.empty() && IS_GROUP_ADMIN(subscribeFlags)); + shareKeyAct->setEnabled(!mForumId.isNull() && IS_GROUP_ADMIN(subscribeFlags)); contextMnu.addAction( shareKeyAct); QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Forum" ), &contextMnu); connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreForumKeys() ) ); - restoreKeysAct->setEnabled(!mForumId.empty() && !IS_GROUP_ADMIN(subscribeFlags)); + restoreKeysAct->setEnabled(!mForumId.isNull() && !IS_GROUP_ADMIN(subscribeFlags)); contextMnu.addAction( restoreKeysAct); action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyForumLink())); - action->setEnabled(!mForumId.empty()); + action->setEnabled(!mForumId.isNull()); contextMnu.addSeparator(); action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsRead())); - action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags)); + action->setEnabled (!mForumId.isNull() && IS_GROUP_SUBSCRIBED(subscribeFlags)); action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread())); - action->setEnabled (!mForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags)); + action->setEnabled (!mForumId.isNull() && IS_GROUP_SUBSCRIBED(subscribeFlags)); contextMnu.exec(QCursor::pos()); } @@ -265,7 +265,7 @@ void GxsForumsDialog::updateDisplay(bool complete) void GxsForumsDialog::forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo, GroupItemInfo &groupItemInfo) { - groupItemInfo.id = QString::fromStdString(forumInfo.mGroupId); + groupItemInfo.id = QString::fromStdString(forumInfo.mGroupId.toStdString()); groupItemInfo.name = QString::fromUtf8(forumInfo.mGroupName.c_str()); //groupItemInfo.description = QString::fromUtf8(forumInfo.forumDesc); groupItemInfo.popularity = forumInfo.mPop; @@ -350,10 +350,10 @@ void GxsForumsDialog::insertForumsData(const std::list &forumLi ui.forumTreeWidget->fillGroupItems(popularForums, popList); ui.forumTreeWidget->fillGroupItems(otherForums, otherList); - updateMessageSummaryList(""); + updateMessageSummaryList(RsGxsGroupId()); } -GxsForumThreadWidget *GxsForumsDialog::forumThreadWidget(const std::string &forumId) +GxsForumThreadWidget *GxsForumsDialog::forumThreadWidget(const RsGxsGroupId &forumId) { int tabCount = ui.threadTabWidget->count(); for (int index = 0; index < tabCount; ++index) { @@ -370,7 +370,7 @@ GxsForumThreadWidget *GxsForumsDialog::forumThreadWidget(const std::string &foru return NULL; } -GxsForumThreadWidget *GxsForumsDialog::createThreadWidget(const std::string &forumId) +GxsForumThreadWidget *GxsForumsDialog::createThreadWidget(const RsGxsGroupId &forumId) { GxsForumThreadWidget *threadWidget = new GxsForumThreadWidget(forumId); int index = ui.threadTabWidget->addTab(threadWidget, threadWidget->forumName(true)); @@ -383,14 +383,14 @@ GxsForumThreadWidget *GxsForumsDialog::createThreadWidget(const std::string &for void GxsForumsDialog::changedForum(const QString &forumId) { mForumId = forumId.toStdString(); - if (mForumId.empty()) { + if (mForumId.isNull()) { return; } // requestGroupSummary_CurrentForum(mForumId); /* search exisiting tab */ - GxsForumThreadWidget *threadWidget = forumThreadWidget(mForumId); + GxsForumThreadWidget *threadWidget = forumThreadWidget(mForumId); if (!threadWidget) { if (mThreadWidget) { @@ -399,7 +399,7 @@ void GxsForumsDialog::changedForum(const QString &forumId) threadWidget->setForumId(mForumId); } else { /* create new tab */ - threadWidget = createThreadWidget(mForumId); + threadWidget = createThreadWidget(mForumId); } } @@ -408,7 +408,7 @@ void GxsForumsDialog::changedForum(const QString &forumId) void GxsForumsDialog::forumTreeMiddleButtonClicked(QTreeWidgetItem *item) { - openForumInNewTab(ui.forumTreeWidget->itemId(item).toStdString()); + openForumInNewTab(RsGxsGroupId(ui.forumTreeWidget->itemId(item).toStdString())); } void GxsForumsDialog::openInNewTab() @@ -416,9 +416,9 @@ void GxsForumsDialog::openInNewTab() openForumInNewTab(mForumId); } -void GxsForumsDialog::openForumInNewTab(const std::string &forumId) +void GxsForumsDialog::openForumInNewTab(const RsGxsGroupId &forumId) { - if (forumId.empty()) { + if (forumId.isNull()) { return; } @@ -453,7 +453,7 @@ void GxsForumsDialog::threadTabChanged(int index) return; } - ui.forumTreeWidget->activateId(QString::fromStdString(threadWidget->forumId()), false); + ui.forumTreeWidget->activateId(QString::fromStdString(threadWidget->forumId().toStdString()), false); } void GxsForumsDialog::threadTabInfoChanged(QWidget *widget) @@ -474,7 +474,7 @@ void GxsForumsDialog::threadTabInfoChanged(QWidget *widget) void GxsForumsDialog::copyForumLink() { - if (mForumId.empty()) { + if (mForumId.isNull()) { return; } @@ -531,7 +531,7 @@ void GxsForumsDialog::unsubscribeToForum() void GxsForumsDialog::forumSubscribe(bool subscribe) { - if (mForumId.empty()) { + if (mForumId.isNull()) { return; } @@ -542,7 +542,7 @@ void GxsForumsDialog::forumSubscribe(bool subscribe) void GxsForumsDialog::showForumDetails() { - if (mForumId.empty()) { + if (mForumId.isNull()) { return; } @@ -552,7 +552,7 @@ void GxsForumsDialog::showForumDetails() void GxsForumsDialog::editForumDetails() { - if (mForumId.empty()) { + if (mForumId.isNull()) { return; } @@ -565,11 +565,11 @@ void GxsForumsDialog::editForumDetails() void GxsForumsDialog::shareKey() { - ShareKey shareUi(this, mForumId, FORUM_KEY_SHARE); + ShareKey shareUi(this, mForumId.toStdString(), FORUM_KEY_SHARE); shareUi.exec(); } -void GxsForumsDialog::updateMessageSummaryList(std::string forumId) +void GxsForumsDialog::updateMessageSummaryList( RsGxsGroupId forumId) { QTreeWidgetItem *items[2] = { yourForums, subscribedForums }; @@ -583,7 +583,7 @@ void GxsForumsDialog::updateMessageSummaryList(std::string forumId) continue; } - if (forumId.empty() || childId == forumId) { + if (forumId.isNull() || childId == forumId.toStdString()) { /* calculate unread messages */ unsigned int newMessageCount = 0; unsigned int unreadMessageCount = 0; @@ -595,7 +595,7 @@ void GxsForumsDialog::updateMessageSummaryList(std::string forumId) ui.forumTreeWidget->setUnreadCount(childItem, unreadMessageCount); - if (forumId.empty() == false) { + if (forumId.isNull() == false) { /* Calculate only this forum */ break; } @@ -604,13 +604,13 @@ void GxsForumsDialog::updateMessageSummaryList(std::string forumId) } } -bool GxsForumsDialog::navigate(const std::string& forumId, const std::string& msgId) +bool GxsForumsDialog::navigate(const RsGxsGroupId forumId, const std::string& msgId) { - if (forumId.empty()) { + if (forumId.isNull()) { return false; } - if (ui.forumTreeWidget->activateId(QString::fromStdString(forumId), msgId.empty()) == NULL) { + if (ui.forumTreeWidget->activateId(QString::fromStdString(forumId.toStdString()), msgId.empty()) == NULL) { return false; } @@ -718,7 +718,7 @@ void GxsForumsDialog::acknowledgeSubscribeChange(const uint32_t &token) /*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/ -//void GxsForumsDialog::requestGroupSummary_CurrentForum(const std::string &forumId) +//void GxsForumsDialog::requestGroupSummary_CurrentForum(const RsGxsGroupId &forumId) //{ // RsTokReqOptions opts; // opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h index 344f2d7a0..9f517eb50 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h @@ -49,7 +49,7 @@ public: // virtual UserNotify *getUserNotify(QObject *parent); - bool navigate(const std::string& forumId, const std::string& msgId); + bool navigate(const RsGxsGroupId forumId, const std::string& msgId); // Callback for all Loads. virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); @@ -90,11 +90,11 @@ private slots: private: void insertForums(); - void updateMessageSummaryList(std::string forumId); + void updateMessageSummaryList( RsGxsGroupId forumId); // void forumInfoToGroupItemInfo(const ForumInfo &forumInfo, GroupItemInfo &groupItemInfo); void forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo, GroupItemInfo &groupItemInfo); - void openForumInNewTab(const std::string &forumId); + void openForumInNewTab(const RsGxsGroupId &forumId); void forumSubscribe(bool subscribe); void processSettings(bool load); @@ -108,13 +108,13 @@ private: // subscribe/unsubscribe ack. void acknowledgeSubscribeChange(const uint32_t &token); - GxsForumThreadWidget *forumThreadWidget(const std::string &forumId); - GxsForumThreadWidget *createThreadWidget(const std::string &forumId); + GxsForumThreadWidget *forumThreadWidget(const RsGxsGroupId &forumId); + GxsForumThreadWidget *createThreadWidget(const RsGxsGroupId &forumId); -// void requestGroupSummary_CurrentForum(const std::string &forumId); +// void requestGroupSummary_CurrentForum(const RsGxsGroupId &forumId); // void loadGroupSummary_CurrentForum(const uint32_t &token); - std::string mForumId; + RsGxsGroupId mForumId; TokenQueue *mForumQueue; GxsForumThreadWidget *mThreadWidget; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp index 65f6b8573..f6c6eb0a7 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.cpp @@ -101,7 +101,7 @@ void GxsForumsFillThread::run() opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; opts.mOptions = RS_TOKREQOPT_MSG_LATEST; - std::list grpIds; + std::list grpIds; grpIds.push_back(mForumId); #ifdef DEBUG_FORUMS @@ -169,7 +169,7 @@ void GxsForumsFillThread::run() const RsGxsForumMsg &msg = *msgIt; - if (!msg.mMeta.mParentId.empty()) { + if (!msg.mMeta.mParentId.isNull()) { ++msgIt; continue; } @@ -179,7 +179,7 @@ void GxsForumsFillThread::run() #endif QTreeWidgetItem *item = mParent->convertMsgToThreadWidget(msg, mUseChildTS, mFilterColumn); - threadList.push_back(QPair(msg.mMeta.mMsgId, item)); + threadList.push_back(QPair(msg.mMeta.mMsgId.toStdString(), item)); calculateExpand(msg, item); mItems.append(item); @@ -209,7 +209,7 @@ void GxsForumsFillThread::run() for (msgIt = msgs.begin(); msgIt != msgs.end(); ) { const RsGxsForumMsg &msg = *msgIt; - if (msg.mMeta.mParentId != threadPair.first) { + if (msg.mMeta.mParentId.toStdString() != threadPair.first) { ++msgIt; continue; } @@ -228,7 +228,7 @@ void GxsForumsFillThread::run() calculateExpand(msg, item); /* add item to process list */ - threadList.push_back(QPair(msg.mMeta.mMsgId, item)); + threadList.push_back(QPair(msg.mMeta.mMsgId.toStdString(), item)); if (++step >= steps) { step = 0; @@ -275,7 +275,7 @@ void GxsForumsFillThread::run() /* add dummy item */ QTreeWidgetItem *item = mParent->generateMissingItem(msg.mMeta.mParentId); - threadList.push_back(QPair(msg.mMeta.mParentId, item)); + threadList.push_back(QPair(msg.mMeta.mParentId.toStdString(), item)); mItems.append(item); break; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.h b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.h index 80f27f851..7eb888851 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsFillThread.h @@ -2,6 +2,7 @@ #define GXSFORUMSFILLTHREAD_H #include +#include "retroshare/rsgxsifacetypes.h" class GxsForumThreadWidget; class RsGxsForumMsg; @@ -25,7 +26,7 @@ signals: void status(QString text); public: - std::string mForumId; + RsGxsGroupId mForumId; int mFilterColumn; int mSubscribeFlags; bool mFillComplete; diff --git a/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp b/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp index 21f088fd8..2ccf35d99 100644 --- a/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp +++ b/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp @@ -112,23 +112,23 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WindowFlags flags) createPageAction(QIcon(IMAGE_PHOTO), tr("Photos"), grp)); #endif - PostedDialog *postedDialog = NULL; - ui.stackPages->add(postedDialog = new PostedDialog(ui.stackPages), - createPageAction(QIcon(IMAGE_POSTED), tr("Posted Links"), grp)); - postedDialog->setup(); - - WikiDialog *wikiDialog = NULL; - ui.stackPages->add(wikiDialog = new WikiDialog(ui.stackPages), - createPageAction(QIcon(IMAGE_WIKI), tr("Wiki Pages"), grp)); - +// PostedDialog *postedDialog = NULL; +// ui.stackPages->add(postedDialog = new PostedDialog(ui.stackPages), +// createPageAction(QIcon(IMAGE_POSTED), tr("Posted Links"), grp)); +// postedDialog->setup(); +// +// WikiDialog *wikiDialog = NULL; +// ui.stackPages->add(wikiDialog = new WikiDialog(ui.stackPages), +// createPageAction(QIcon(IMAGE_WIKI), tr("Wiki Pages"), grp)); +// GxsForumsDialog *gxsforumsDialog = NULL; ui.stackPages->add(gxsforumsDialog = new GxsForumsDialog(ui.stackPages), createPageAction(QIcon(IMAGE_GXSFORUMS), tr("GxsForums"), grp)); - - ChannelDialog *gxschannelDialog = NULL; - ui.stackPages->add(gxschannelDialog = new ChannelDialog(ui.stackPages), - createPageAction(QIcon(IMAGE_GXSCHANNELS), tr("GxsChannels"), grp)); - gxschannelDialog->setup(); +// +// ChannelDialog *gxschannelDialog = NULL; +// ui.stackPages->add(gxschannelDialog = new ChannelDialog(ui.stackPages), +// createPageAction(QIcon(IMAGE_GXSCHANNELS), tr("GxsChannels"), grp)); +// gxschannelDialog->setup(); // THESE HAVE TO BE CONVERTED TO VEG FORMAT #if USE_VEG_SERVICE