From 37dd5821b951dac81dfb74fd8475bc2f653a1f6e Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 13 Feb 2014 13:02:46 +0000 Subject: [PATCH] ID cleaning. Saving progress. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7114 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/gxs/rsgxsnetutils.cc | 8 +- libretroshare/src/retroshare/rstypes.h | 5 + .../src/gui/CreateMsgLinkDialog.cpp | 5 +- retroshare-gui/src/gui/FriendsDialog.cpp | 8 +- retroshare-gui/src/gui/GenCertDialog.cpp | 12 +- .../src/gui/Identity/IdEditDialog.cpp | 6 +- retroshare-gui/src/gui/MainWindow.cpp | 2 +- retroshare-gui/src/gui/MessagesDialog.cpp | 6 +- retroshare-gui/src/gui/MessengerWindow.cpp | 6 +- retroshare-gui/src/gui/NetworkDialog.cpp | 28 ++--- retroshare-gui/src/gui/NetworkView.cpp | 26 ++-- retroshare-gui/src/gui/NetworkView.h | 4 +- retroshare-gui/src/gui/RemoteDirModel.cpp | 4 +- retroshare-gui/src/gui/RetroShareLink.cpp | 119 +++++++++--------- retroshare-gui/src/gui/RetroShareLink.h | 9 +- retroshare-gui/src/gui/SearchDialog.cpp | 10 +- retroshare-gui/src/gui/SearchDialog.h | 2 +- .../src/gui/ServicePermissionDialog.cpp | 4 +- retroshare-gui/src/gui/StartDialog.cpp | 2 +- .../src/gui/common/FriendSelectionDialog.cpp | 49 ++++++-- .../src/gui/common/FriendSelectionDialog.h | 16 ++- retroshare-gui/src/gui/common/PeerDefs.cpp | 15 ++- retroshare-gui/src/gui/common/PeerDefs.h | 3 +- .../src/gui/im_history/ImHistoryBrowser.h | 2 +- .../src/gui/msgs/MessageComposer.cpp | 38 +++--- retroshare-gui/src/gui/msgs/MessageComposer.h | 6 +- retroshare-gui/src/retroshare-gui.pro | 3 - 27 files changed, 229 insertions(+), 169 deletions(-) diff --git a/libretroshare/src/gxs/rsgxsnetutils.cc b/libretroshare/src/gxs/rsgxsnetutils.cc index e0beca467..a3d46961e 100644 --- a/libretroshare/src/gxs/rsgxsnetutils.cc +++ b/libretroshare/src/gxs/rsgxsnetutils.cc @@ -47,14 +47,14 @@ bool AuthorPending::expired() const } bool AuthorPending::getAuthorRep(GixsReputation& rep, - const std::string& authorId, const std::string& peerId) + const std::string& authorId, const RsPeerId& peerId) { if(mRep->haveReputation(authorId)) { return mRep->getReputation(authorId, rep); } - std::list peers; + std::list peers; peers.push_back(peerId); mRep->loadReputation(authorId, peers); return false; @@ -70,12 +70,12 @@ GrpAuthEntry::GrpAuthEntry() -MsgRespPending::MsgRespPending(RsGixsReputation* rep, const std::string& peerId, const MsgAuthorV& msgAuthV, int cutOff) +MsgRespPending::MsgRespPending(RsGixsReputation* rep, const RsPeerId& peerId, const MsgAuthorV& msgAuthV, int cutOff) : AuthorPending(rep, time(NULL)), mPeerId(peerId), mMsgAuthV(msgAuthV), mCutOff(cutOff) { } -GrpRespPending::GrpRespPending(RsGixsReputation* rep, const std::string& peerId, const GrpAuthorV& grpAuthV, int cutOff) +GrpRespPending::GrpRespPending(RsGixsReputation* rep, const RsPeerId& peerId, const GrpAuthorV& grpAuthV, int cutOff) : AuthorPending(rep, time(NULL)), mPeerId(peerId), mGrpAuthV(grpAuthV), mCutOff(cutOff) { } diff --git a/libretroshare/src/retroshare/rstypes.h b/libretroshare/src/retroshare/rstypes.h index cdb028a18..9838a4c9c 100644 --- a/libretroshare/src/retroshare/rstypes.h +++ b/libretroshare/src/retroshare/rstypes.h @@ -39,11 +39,16 @@ #define USE_NEW_CHUNK_CHECKING_CODE +// This adds a level of indirection to types, so we can easily change them if needed +// typedef std::string RsCertId; typedef std::string RsChanId; typedef std::string RsMsgId; typedef std::string RsAuthId; + typedef SSLIdType RsPeerId ; +typedef PGPIdType RsPgpId ; +typedef Sha1CheckSum RsFileHash ; const uint32_t FT_STATE_FAILED = 0x0000 ; const uint32_t FT_STATE_OKAY = 0x0001 ; diff --git a/retroshare-gui/src/gui/CreateMsgLinkDialog.cpp b/retroshare-gui/src/gui/CreateMsgLinkDialog.cpp index f4b280385..d84445768 100644 --- a/retroshare-gui/src/gui/CreateMsgLinkDialog.cpp +++ b/retroshare-gui/src/gui/CreateMsgLinkDialog.cpp @@ -82,7 +82,8 @@ void CreateMsgLinkDialog::createLink() time_t validity_duration = computeValidityDuration() ; FriendSelectionWidget::IdType type ; - std::string current_pgp_id = friendSelectionWidget->selectedId(type) ; + std::string scurrent_pgp_id = friendSelectionWidget->selectedId(type) ; + RsPgpId current_pgp_id(scurrent_pgp_id) ; std::string encrypted_string ; @@ -90,7 +91,7 @@ void CreateMsgLinkDialog::createLink() RetroShareLink link ; - if(!link.createPrivateChatInvite(validity_duration + time(NULL),QString::fromStdString(current_pgp_id),QString::fromStdString(encrypted_string)) ) + if(!link.createPrivateChatInvite(validity_duration + time(NULL),QString::fromStdString(scurrent_pgp_id),QString::fromStdString(encrypted_string)) ) std::cerr << "Cannot create link." << std::endl; QList links ; diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index 1bb08604e..065280775 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -146,7 +146,7 @@ FriendsDialog::FriendsDialog(QWidget *parent) int messageCount = Settings->getPublicChatHistoryCount(); if (messageCount > 0) { std::list historyMsgs; - rsHistory->getMessages("", historyMsgs, messageCount); + rsHistory->getMessages(RsPeerId(), historyMsgs, messageCount); std::list::iterator it; for (it = historyMsgs.begin(); it != historyMsgs.end(); it++) { @@ -394,7 +394,7 @@ void FriendsDialog::updateStatusString(const QString& peer_id, const QString& st std::cerr << "FriendsDialog: received group chat typing info. updating gui." << std::endl ; #endif - QString status = QString::fromUtf8(rsPeers->getPeerName(peer_id.toStdString()).c_str()) + " " + tr(status_string.toLatin1()); + QString status = QString::fromUtf8(rsPeers->getPeerName(RsPeerId(peer_id.toStdString())).c_str()) + " " + tr(status_string.toLatin1()); ui.statusStringLabel->setText(status) ; // displays info for 5 secs. QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ; @@ -750,7 +750,7 @@ void FriendsDialog::on_actionDelete_Chat_History_triggered() { if ((QMessageBox::question(this, "RetroShare", tr("Do you really want to physically delete the history?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes) { on_actionClear_Chat_History_triggered(); - rsHistory->clear(""); + rsHistory->clear(RsPeerId()); } } @@ -821,7 +821,7 @@ void FriendsDialog::fileHashingFinished(QList hashedFiles) HashedFile& hashedFile = *it; RetroShareLink link; - if (!link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash),QString::fromStdString(rsPeers->getOwnId()))) + if (!link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash),QString::fromStdString(rsPeers->getOwnId().toStdString()))) continue; mesgString += link.toHtmlSize(); diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index b2923d87f..fb7a5466c 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -178,8 +178,8 @@ void GenCertDialog::init() ui.genPGPuser->clear() ; - std::list pgpIds; - std::list::iterator it; + std::list pgpIds; + std::list::iterator it; bool foundGPGKeys = false; if (!mOnlyGenerateIdentity) { if (RsAccounts::GetPGPLogins(pgpIds)) { @@ -310,7 +310,7 @@ void GenCertDialog::exportIdentity() return ; QVariant data = ui.genPGPuser->itemData(ui.genPGPuser->currentIndex()); - PGPIdType gpg_id (data.toString().toStdString()) ; + RsPgpId gpg_id (data.toString().toStdString()) ; if(RsAccounts::ExportIdentity(fname.toStdString(),gpg_id)) QMessageBox::information(this,tr("Identity saved"),tr("Your identity was successfully saved\nIt is encrypted\n\nYou can now copy it to another computer\nand use the import button to load it")) ; @@ -325,7 +325,7 @@ void GenCertDialog::importIdentity() if(fname.isNull()) return ; - PGPIdType gpg_id ; + RsPgpId gpg_id ; std::string err_string ; if(!RsAccounts::ImportIdentity(fname.toStdString(),gpg_id,err_string)) @@ -350,7 +350,7 @@ void GenCertDialog::genPerson() { /* Check the data from the GUI. */ std::string genLoc = ui.location_input->text().toUtf8().constData(); - PGPIdType PGPId; + RsPgpId PGPId; bool isHiddenLoc = false; if (ui.hidden_checkbox->isChecked()) @@ -389,7 +389,7 @@ void GenCertDialog::genPerson() return; } QVariant data = ui.genPGPuser->itemData(pgpidx); - PGPId = PGPIdType((data.toString()).toStdString()); + PGPId = RsPgpId((data.toString()).toStdString()); } else { if (ui.password_input->text().length() < 3 || ui.name_input->text().length() < 3 || genLoc.length() < 3) { /* Message Dialog */ diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp index 2f0604615..47d15bd0f 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp @@ -127,11 +127,11 @@ void IdEditDialog::updateIdType(bool pseudo) else { /* get GPG Details from rsPeers */ - std::string gpgid = rsPeers->getGPGOwnId(); + RsPgpId gpgid = rsPeers->getGPGOwnId(); RsPeerDetails details; - rsPeers->getPeerDetails(gpgid, details); + rsPeers->getGPGDetails(gpgid, details); - ui.lineEdit_GpgId->setText(QString::fromStdString(gpgid)); + ui.lineEdit_GpgId->setText(QString::fromStdString(gpgid.toStdString())); ui.lineEdit_GpgHash->setText(tr("To be generated")); ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str())); } diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 6e29b6fa4..05c520ebf 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -1260,7 +1260,7 @@ void MainWindow::setStatus(QObject *pObject, int nStatus) nStatus = RS_STATUS_INACTIVE; } - rsStatus->sendStatus("", nStatus); + rsStatus->sendStatus(RsPeerId(), nStatus); /* set status in all status objects, but the calling one */ for (std::set ::iterator it = m_apStatusObjects.begin(); it != m_apStatusObjects.end(); it++) { diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index b4f893695..aa2ee3e5a 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -847,7 +847,7 @@ void MessagesDialog::insertMessages() bool gotInfo; QString text; - std::string ownId = rsPeers->getOwnId(); + RsPeerId ownId = rsPeers->getOwnId(); rsMsgs -> getMessageSummaries(msgList); @@ -1114,7 +1114,7 @@ void MessagesDialog::insertMessages() text.clear(); - std::list::const_iterator pit; + std::list::const_iterator pit; for (pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++) { if (text.isEmpty() == false) { @@ -1148,7 +1148,7 @@ void MessagesDialog::insertMessages() // internal data QString msgId = QString::fromStdString(it->msgId); - item[COLUMN_DATA]->setData(QString::fromStdString(it->srcId), ROLE_SRCID); + item[COLUMN_DATA]->setData(QString::fromStdString(it->srcId.toStdString()), ROLE_SRCID); item[COLUMN_DATA]->setData(msgId, ROLE_MSGID); item[COLUMN_DATA]->setData(it->msgflags, ROLE_MSGFLAGS); diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 58bf81887..c8a6fcb64 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -154,7 +154,7 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags) // add self nick RsPeerDetails pd; - std::string ownId = rsPeers->getOwnId(); + RsPeerId ownId = rsPeers->getOwnId(); if (rsPeers->getPeerDetails(ownId, pd)) { /* calculate only once */ m_nickName = QString::fromUtf8(pd.name.c_str()); @@ -163,7 +163,7 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags) /* Show nick and current state */ StatusInfo statusInfo; rsStatus->getOwnStatus(statusInfo); - updateOwnStatus(QString::fromStdString(ownId), statusInfo.status); + updateOwnStatus(QString::fromStdString(ownId.toStdString()), statusInfo.status); MainWindow *pMainWindow = MainWindow::getInstance(); if (pMainWindow) { @@ -251,7 +251,7 @@ void MessengerWindow::savestatusmessage() void MessengerWindow::updateOwnStatus(const QString &peer_id, int status) { // add self nick + own status - if (peer_id.toStdString() == rsPeers->getOwnId()) + if (peer_id == QString::fromStdString(rsPeers->getOwnId().toStdString())) { // my status has changed diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 4e764a39d..d8dc96265 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -203,7 +203,7 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ ) QMenu *contextMnu = new QMenu; - PGPIdType peer_id(wi->text(COLUMN_PEERID).toStdString()) ; + RsPgpId peer_id(wi->text(COLUMN_PEERID).toStdString()) ; // That's what context menus are made for RsPeerDetails detail; @@ -231,15 +231,15 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ ) void NetworkDialog::removeUnusedKeys() { - std::list pre_selected ; - std::list ids ; + std::list pre_selected ; + std::list ids ; rsPeers->getGPGAllList(ids) ; RsPeerDetails details ; time_t now = time(NULL) ; time_t THREE_MONTHS = 3*31*24*60*60 ;//3*DayPerMonth*HoursPerDay*MinPerHour*SecPerMin - for(std::list::const_iterator it(ids.begin());it!=ids.end();++it) + for(std::list::const_iterator it(ids.begin());it!=ids.end();++it) { rsPeers->getGPGDetails(*it,details) ; @@ -255,13 +255,13 @@ void NetworkDialog::removeUnusedKeys() } } - std::list selected = FriendSelectionDialog::selectFriends(NULL, + std::list selected = FriendSelectionDialog::selectFriends_PGP(NULL, tr("Clean keyring"), tr("The selected keys below haven't been used in the last 3 months. \nDo you want to delete them permanently ? \n\nNotes: Your old keyring will be backed up.\n The removal may fail when running multiple Retroshare instances on the same machine."),FriendSelectionWidget::MODUS_CHECK,FriendSelectionWidget::SHOW_GPG | FriendSelectionWidget::SHOW_NON_FRIEND_GPG, - FriendSelectionWidget::IDTYPE_GPG, pre_selected) ; + pre_selected) ; std::cerr << "Removing these keys from the keyring: " << std::endl; - for(std::list::const_iterator it(selected.begin());it!=selected.end();++it) + for(std::list::const_iterator it(selected.begin());it!=selected.end();++it) std::cerr << " " << *it << std::endl; std::string backup_file ; @@ -298,7 +298,7 @@ void NetworkDialog::removeUnusedKeys() void NetworkDialog::denyFriend() { QTreeWidgetItem *wi = getCurrentNeighbour(); - PGPIdType peer_id( wi->text(COLUMN_PEERID).toStdString() ); + RsPgpId peer_id( wi->text(COLUMN_PEERID).toStdString() ); rsPeers->removeFriend(peer_id) ; securedUpdateDisplay(); @@ -341,7 +341,7 @@ void NetworkDialog::copyLink() return; } - std::string peer_id = wi->text(COLUMN_PEERID).toStdString() ; + RsPgpId peer_id ( wi->text(COLUMN_PEERID).toStdString() ) ; QList urls; RetroShareLink link; @@ -365,11 +365,11 @@ void NetworkDialog::sendDistantMessage() } Sha1CheckSum hash ; - PGPIdType mGpgId(wi->text(COLUMN_PEERID).toStdString()) ; + RsPgpId mGpgId(wi->text(COLUMN_PEERID).toStdString()) ; if(rsMsgs->getDistantMessageHash(mGpgId,hash)) { - nMsgDialog->addRecipient(MessageComposer::TO, hash.toStdString(), mGpgId.toStdString()); + nMsgDialog->addRecipient(MessageComposer::TO, hash, mGpgId); nMsgDialog->show(); nMsgDialog->activateWindow(); } @@ -397,8 +397,8 @@ void NetworkDialog::insertConnect() // // last_time = now ; - std::list neighs; //these are GPG ids - std::list::iterator it; + std::list neighs; //these are GPG ids + std::list::iterator it; rsPeers->getGPGAllList(neighs); /* get a link to the table */ @@ -408,7 +408,7 @@ void NetworkDialog::insertConnect() int index = 0; while (index < connectWidget->topLevelItemCount()) { - PGPIdType gpg_widget_id( (connectWidget->topLevelItem(index))->text(COLUMN_PEERID).toStdString() ); + RsPgpId gpg_widget_id( (connectWidget->topLevelItem(index))->text(COLUMN_PEERID).toStdString() ); RsPeerDetails detail; if ( (!rsPeers->getGPGDetails(gpg_widget_id, detail)) || (ui.onlyTrustedKeys->isChecked() && (detail.validLvl < RS_TRUST_LVL_MARGINAL && !detail.accept_connection))) delete (connectWidget->takeTopLevelItem(index)); diff --git a/retroshare-gui/src/gui/NetworkView.cpp b/retroshare-gui/src/gui/NetworkView.cpp index d1572d036..ffcad1e24 100644 --- a/retroshare-gui/src/gui/NetworkView.cpp +++ b/retroshare-gui/src/gui/NetworkView.cpp @@ -109,9 +109,9 @@ void NetworkView::setFreezeState(bool freeze) class NodeInfo { public: - NodeInfo(const std::string& _gpg_id,uint32_t lev) : gpg_id(_gpg_id),friend_level(lev) {} + NodeInfo(const RsPgpId& _gpg_id,uint32_t lev) : gpg_id(_gpg_id),friend_level(lev) {} - std::string gpg_id ; + RsPgpId gpg_id ; uint32_t friend_level ; } ; @@ -127,16 +127,16 @@ void NetworkView::updateDisplay() return ; /* add all friends */ - std::string ownGPGId = rsPeers->getGPGOwnId(); + RsPgpId ownGPGId = rsPeers->getGPGOwnId(); //#ifdef DEBUG_NETWORKVIEW std::cerr << "NetworkView::updateDisplay()" << std::endl; //#endif std::deque nodes_to_treat ; // list of nodes to be treated. Used as a queue. The int is the level of friendness - std::set nodes_considered ; // list of nodes already considered. Eases lookup. + std::set nodes_considered ; // list of nodes already considered. Eases lookup. nodes_to_treat.push_front(NodeInfo(ownGPGId,0)) ; // initialize queue with own id. - nodes_considered.insert(rsPeers->getOwnId()) ; + nodes_considered.insert(rsPeers->getGPGOwnId()) ; // Put own id in queue, and empty the queue, treating all nodes. // @@ -163,7 +163,7 @@ void NetworkView::updateDisplay() } RsPeerDetails detail ; - if(!rsPeers->getPeerDetails(info.gpg_id, detail)) + if(!rsPeers->getGPGDetails(info.gpg_id, detail)) continue ; switch(detail.trustLvl) @@ -179,13 +179,13 @@ void NetworkView::updateDisplay() if(info.friend_level <= _max_friend_level && _node_ids.find(info.gpg_id) == _node_ids.end()) { - _node_ids[info.gpg_id] = ui.graphicsView->addNode(" "+detail.name, detail.name+"@"+detail.gpg_id,type,auth,"",info.gpg_id); + _node_ids[info.gpg_id] = ui.graphicsView->addNode(" "+detail.name, detail.name+"@"+detail.gpg_id.toStdString(),type,auth,"",info.gpg_id.toStdString()); #ifdef DEBUG_NETWORKVIEW std::cerr << " inserted node " << info.gpg_id << ", type=" << type << ", auth=" << auth << std::endl ; #endif } - std::list friendList; + std::list friendList; rsDisc->getDiscPgpFriends(info.gpg_id, friendList); #ifdef DEBUG_NETWORKVIEW @@ -193,8 +193,8 @@ void NetworkView::updateDisplay() #endif if(info.friend_level+1 <= _max_friend_level) - for(std::list::const_iterator sit(friendList.begin()); sit != friendList.end(); ++sit) - if(nodes_considered.find(*sit) == nodes_considered.end()) + for(std::list::const_iterator sit(friendList.begin()); sit != friendList.end(); ++sit) + if(nodes_considered.find(*sit) == nodes_considered.end()) { #ifdef DEBUG_NETWORKVIEW std::cerr << " adding to queue: " << *sit << ", with level " << info.friend_level+1 << std::endl ; @@ -210,12 +210,12 @@ void NetworkView::updateDisplay() std::cerr << "NetworkView::insertSignatures()" << std::endl; #endif - for(std::map::const_iterator it(_node_ids.begin()); it != _node_ids.end(); it++) + for(std::map::const_iterator it(_node_ids.begin()); it != _node_ids.end(); it++) { - std::list friendList ; + std::list friendList ; if(rsDisc->getDiscPgpFriends(it->first,friendList)) - for(std::list::const_iterator sit(friendList.begin()); sit != friendList.end(); sit++) + for(std::list::const_iterator sit(friendList.begin()); sit != friendList.end(); sit++) { #ifdef DEBUG_NETWORKVIEW std::cerr << "NetworkView: Adding Edge: "; diff --git a/retroshare-gui/src/gui/NetworkView.h b/retroshare-gui/src/gui/NetworkView.h index 7493a1469..aec295898 100644 --- a/retroshare-gui/src/gui/NetworkView.h +++ b/retroshare-gui/src/gui/NetworkView.h @@ -24,6 +24,8 @@ #include +#include + #include "RsAutoUpdatePage.h" #include "ui_NetworkView.h" @@ -60,7 +62,7 @@ class NetworkView : public RsAutoUpdatePage /** Qt Designer generated object */ Ui::NetworkView ui; uint _max_friend_level ; - std::map _node_ids ; + std::map _node_ids ; bool _should_update ; }; diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index a2540bedf..658d4e9fb 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -960,7 +960,7 @@ void RetroshareDirModel::downloadSelected(const QModelIndexList &list) { std::cerr << "RetroshareDirModel::downloadSelected() Calling File Request"; std::cerr << std::endl; - std::list srcIds; + std::list srcIds; srcIds.push_back(details.id); rsFiles -> FileRequest(details.name, details.hash, details.count, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds); @@ -980,7 +980,7 @@ void RetroshareDirModel::downloadDirectory(const DirDetails & dirDetails, int pr { if (dirDetails.type & DIR_TYPE_FILE) { - std::list srcIds; + std::list srcIds; QString cleanPath = QDir::cleanPath(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()) + "/" + QString::fromUtf8(dirDetails.path.substr(prefixLen).c_str())); srcIds.push_back(dirDetails.id); diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 1057e7177..4ddc5a62c 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -376,17 +376,17 @@ bool RetroShareLink::createPublicMsgInvite(time_t time_stamp,const QString& issu return valid() ; } -bool RetroShareLink::createPerson(const std::string& id) +bool RetroShareLink::createPerson(const RsPgpId& id) { clear(); RsPeerDetails detail; - if (rsPeers->getPeerDetails(id, detail) == false) { + if (rsPeers->getGPGDetails(id, detail) == false) { std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << id << std::endl; return false; } - _hash = QString::fromStdString(id); + _hash = QString::fromStdString(id.toStdString()); _name = QString::fromUtf8(detail.name.c_str()); _type = TYPE_PERSON; @@ -396,14 +396,14 @@ bool RetroShareLink::createPerson(const std::string& id) return valid(); } -bool RetroShareLink::createCertificate(const std::string& ssl_or_gpg_id) +bool RetroShareLink::createCertificate(const RsPeerId& ssl_id) { // This is baaaaaad code: // - we should not need to parse and re-read a cert in old format. // RsPeerDetails detail; - if (rsPeers->getPeerDetails(ssl_or_gpg_id, detail) == false) { - std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_or_gpg_id << std::endl; + if (rsPeers->getPeerDetails(ssl_id, detail) == false) { + std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_id << std::endl; return false; } @@ -418,23 +418,23 @@ bool RetroShareLink::createCertificate(const std::string& ssl_or_gpg_id) _type = TYPE_CERTIFICATE; - _GPGid = QString::fromStdString(detail.gpg_id).right(8); + _GPGid = QString::fromStdString(detail.gpg_id.toStdString()).right(8); - if(detail.isOnlyGPGdetail) - { - _SSLid.clear(); - _location.clear(); - _ext_ip_port.clear(); - _loc_ip_port.clear(); - } - else - { - _SSLid = QString::fromStdString(ssl_or_gpg_id) ; + // if(detail.isOnlyGPGdetail) + // { + // _SSLid.clear(); + // _location.clear(); + // _ext_ip_port.clear(); + // _loc_ip_port.clear(); + // } + // else + // { + _SSLid = QString::fromStdString(ssl_id.toStdString()) ; _location = QString::fromUtf8(detail.location.c_str()) ; _ext_ip_port = QString::fromStdString(detail.extAddr) + ":" + QString::number(detail.extPort) + ";" ; _loc_ip_port = QString::fromStdString(detail.localAddr) + ":" + QString::number(detail.localPort) + ";" ; _dyndns_name = QString::fromStdString(detail.dyndns); - } + //} _name = QString::fromUtf8(detail.name.c_str()) ; std::cerr << "Found gpg base 64 string = " << _GPGBase64String.toStdString() << std::endl; @@ -449,11 +449,11 @@ bool RetroShareLink::createCertificate(const std::string& ssl_or_gpg_id) return true; } -bool RetroShareLink::createUnknwonSslCertificate(const std::string& sslId, const std::string& gpgId) +bool RetroShareLink::createUnknwonSslCertificate(const RsPeerId& sslId, const RsPgpId& gpgId) { // first try ssl id if (createCertificate(sslId)) { - if (gpgId.empty() || _GPGid.toStdString() == gpgId) { + if (gpgId.isNull() || _GPGid.toStdString() == gpgId.toStdString()) { return true; } // wrong gpg id @@ -461,14 +461,14 @@ bool RetroShareLink::createUnknwonSslCertificate(const std::string& sslId, const } // then gpg id - if (createCertificate(gpgId)) { + if (createCertificate(sslId)) { if (!_SSLid.isEmpty()) { return false; } - if (sslId.empty()) { + if (sslId.isNull()) { return true; } - _SSLid = QString::fromStdString(sslId); + _SSLid = QString::fromStdString(sslId.toStdString()); if (_location.isEmpty()) { _location = _name; } @@ -680,15 +680,15 @@ QString RetroShareLink::title() const case TYPE_PUBLIC_MSG: { RsPeerDetails detail; - rsPeers->getPeerDetails(_GPGid.toStdString(), detail) ; + rsPeers->getGPGDetails(RsPgpId(_GPGid.toStdString()), detail) ; return QString("Click to send a private message to %1 (%2).").arg(QString::fromStdString(detail.name)).arg(_GPGid) ; } case TYPE_PRIVATE_CHAT: { RsPeerDetails detail; - rsPeers->getPeerDetails(_GPGid.toStdString(), detail) ; + rsPeers->getGPGDetails(RsPgpId(_GPGid.toStdString()), detail) ; - if (_GPGid.toStdString() == rsPeers->getGPGOwnId()) + if (_GPGid.toStdString() == rsPeers->getGPGOwnId().toStdString()) return QString("Click to open a private chat canal to %1 (%2).").arg(QString::fromStdString(detail.name)).arg(_GPGid) ; else return QString("This is a private chat invite for %1 (%2). You can't use it.").arg(QString::fromStdString(detail.name)).arg(_GPGid) ; @@ -875,7 +875,7 @@ QString RetroShareLink::toString() const QString RetroShareLink::niceName() const { if (type() == TYPE_PERSON) { - return PeerDefs::rsid(name().toUtf8().constData(), hash().toStdString()); + return PeerDefs::rsid(name().toUtf8().constData(), RsPgpId(hash().toStdString())); } if(type() == TYPE_PRIVATE_CHAT) { @@ -883,7 +883,7 @@ QString RetroShareLink::niceName() const } if(type() == TYPE_PUBLIC_MSG) { RsPeerDetails detail; - rsPeers->getPeerDetails(_GPGid.toStdString(), detail) ; + rsPeers->getGPGDetails(RsPgpId(_GPGid.toStdString()), detail) ; return QString("Click this link to send a private message to %1 (%2)").arg(QString::fromStdString(detail.name)).arg(_GPGid) ; } if(type() == TYPE_CERTIFICATE) { @@ -1095,7 +1095,7 @@ static void processList(const QStringList &list, const QString &textSingular, co break; case TYPE_PERSON: - personAdd.append(PeerDefs::rsid(link.name().toUtf8().constData(), link.hash().toStdString())); + personAdd.append(PeerDefs::rsid(link.name().toUtf8().constData(), RsPgpId(link.hash().toStdString()))); break; } } @@ -1257,7 +1257,7 @@ static void processList(const QStringList &list, const QString &textSingular, co QMessageBox::information(NULL,QObject::tr("Chat link is expired"),QObject::tr("This chat link is expired. The destination peer will not answer.")) ; break ; } - if(link._GPGid.toStdString() != rsPeers->getGPGOwnId()) + if(RsPgpId(link._GPGid.toStdString()) != rsPeers->getGPGOwnId()) { QMessageBox::information(NULL,QObject::tr("Chat link cannot be decrypted"),QObject::tr("This chat link is encrypted with a key that is not yours. You can't use it. Key ID = ")+link._GPGid) ; break ; @@ -1296,7 +1296,7 @@ static void processList(const QStringList &list, const QString &textSingular, co #endif needNotifySuccess = true; - std::list srcIds; + std::list srcIds; // Add the link built-in source. This is needed for EXTRA files, where the source is specified in the link. @@ -1305,7 +1305,7 @@ static void processList(const QStringList &list, const QString &textSingular, co #ifdef DEBUG_RSLINK std::cerr << " RetroShareLink::process Adding built-in source " << link.SSLId().toStdString() << std::endl; #endif - srcIds.push_back(link.SSLId().toStdString()) ; + srcIds.push_back(RsPeerId(link.SSLId().toStdString())) ; } // Get a list of available direct sources, in case the file is browsable only. @@ -1318,7 +1318,7 @@ static void processList(const QStringList &list, const QString &textSingular, co #ifdef DEBUG_RSLINK std::cerr << " adding peerid " << (*it).peerId << std::endl ; #endif - srcIds.push_back((*it).peerId) ; + srcIds.push_back((*it).peerId) ; } QString cleanname = link.name() ; @@ -1337,7 +1337,7 @@ static void processList(const QStringList &list, const QString &textSingular, co } else { fileExist.append(link.name()); } - break; + break; } case TYPE_PERSON: @@ -1349,29 +1349,30 @@ static void processList(const QStringList &list, const QString &textSingular, co needNotifySuccess = true; RsPeerDetails detail; - if (rsPeers->getPeerDetails(link.hash().toStdString(), detail)) { - if (detail.gpg_id == rsPeers->getGPGOwnId()) { - // it's me, do nothing - break; - } + if (rsPeers->getPeerDetails(RsPeerId(link.hash().toStdString()), detail)) + { + if (RsPgpId(detail.gpg_id) == rsPeers->getGPGOwnId()) { + // it's me, do nothing + break; + } - if (detail.accept_connection) { - // peer connection is already accepted - personExist.append(PeerDefs::rsid(detail)); - break; - } + if (detail.accept_connection) { + // peer connection is already accepted + personExist.append(PeerDefs::rsid(detail)); + break; + } - if (rsPeers->addFriend("", link.hash().toStdString())) { - ConfCertDialog::loadAll(); - personAdded.append(PeerDefs::rsid(detail)); - break; - } + if (rsPeers->addFriend(RsPeerId(), RsPgpId(link.hash().toStdString()))) { + ConfCertDialog::loadAll(); + personAdded.append(PeerDefs::rsid(detail)); + break; + } - personFailed.append(PeerDefs::rsid(link.name().toUtf8().constData(), link.hash().toStdString())); - break; - } + personFailed.append(PeerDefs::rsid(link.name().toUtf8().constData(), RsPgpId(link.hash().toStdString()))); + break; + } - personNotFound.append(PeerDefs::rsid(link.name().toUtf8().constData(), link.hash().toStdString())); + personNotFound.append(PeerDefs::rsid(link.name().toUtf8().constData(), RsPgpId(link.hash().toStdString()))); break; } @@ -1493,11 +1494,17 @@ static void processList(const QStringList &list, const QString &textSingular, co std::cerr << " RetroShareLink::process MessageRequest : id : " << link.hash().toStdString() << ", subject : " << link.name().toStdString() << std::endl; #endif RsPeerDetails detail; - std::string dm_hash ; + RsFileHash dm_hash ; - if (rsPeers->getPeerDetails(link.hash().toStdString(), detail)) + // This is awful, but apparently the hash can be multiple different types. Let's check! + + RsPgpId pgp_id(link.hash().toStdString()) ; + RsPeerId ssl_id(link.hash().toStdString()) ; + + if(!pgp_id.isNull() && rsPeers->getGPGDetails(pgp_id, detail) + || !ssl_id.isNull() && rsPeers->getPeerDetails(ssl_id,detail)) { - if (detail.accept_connection || detail.id == rsPeers->getOwnId() || detail.id == rsPeers->getGPGOwnId()) { + if (detail.accept_connection || RsPeerId(detail.id) == rsPeers->getOwnId() || RsPgpId(detail.gpg_id) == rsPeers->getGPGOwnId()) { MessageComposer *msg = MessageComposer::newMsg(); msg->addRecipient(MessageComposer::TO, detail.id, false); if (link.subject().isEmpty() == false) { diff --git a/retroshare-gui/src/gui/RetroShareLink.h b/retroshare-gui/src/gui/RetroShareLink.h index 582ce0ebc..685b21637 100644 --- a/retroshare-gui/src/gui/RetroShareLink.h +++ b/retroshare-gui/src/gui/RetroShareLink.h @@ -33,6 +33,9 @@ // -------------+----------------+--------------------------+------------------+-------------+------------- // #include + +#include + #include #include #include @@ -72,15 +75,15 @@ class RetroShareLink bool createFile(const QString& name, uint64_t size, const QString& hash); bool createExtraFile(const QString& name, uint64_t size, const QString& hash, const QString& ssl_id); - bool createPerson(const std::string& id); + bool createPerson(const RsPgpId &id); bool createForum(const std::string& id, const std::string& msgId); bool createChannel(const std::string& id, const std::string& msgId); bool createSearch(const QString& keywords); bool createMessage(const std::string& peerId, const QString& subject); - bool createCertificate(const std::string& ssl_or_gpg_id) ; + bool createCertificate(const RsPeerId &ssl_id) ; bool createPrivateChatInvite(time_t time_stamp,const QString& gpg_id,const QString& encrypted_chat_info) ; bool createPublicMsgInvite(time_t time_stamp,const QString& pgp_id,const QString& hash) ; - bool createUnknwonSslCertificate(const std::string& sslId, const std::string& gpgId = "") ; + bool createUnknwonSslCertificate(const RsPeerId &sslId, const RsPgpId &gpgId = RsPgpId()) ; enumType type() const {return _type; } uint64_t size() const { return _size ; } diff --git a/retroshare-gui/src/gui/SearchDialog.cpp b/retroshare-gui/src/gui/SearchDialog.cpp index f289d5210..9961064f5 100644 --- a/retroshare-gui/src/gui/SearchDialog.cpp +++ b/retroshare-gui/src/gui/SearchDialog.cpp @@ -325,7 +325,7 @@ void SearchDialog::searchtableWidgetCostumPopupMenu( QPoint /*point*/ ) contextMnu.exec(QCursor::pos()); } -void SearchDialog::getSourceFriendsForHash(const std::string& hash,std::list& srcIds) +void SearchDialog::getSourceFriendsForHash(const std::string& hash,std::list& srcIds) { std::cerr << "Searching sources for file " << hash << std::endl ; srcIds.clear(); @@ -359,7 +359,7 @@ void SearchDialog::download() { std::cerr << "SearchDialog::download() Calling File Request"; std::cerr << std::endl; - std::list srcIds; + std::list srcIds; std::string hash = item->text(SR_HASH_COL).toStdString(); getSourceFriendsForHash(hash,srcIds) ; @@ -369,7 +369,7 @@ void SearchDialog::download() else { std::cout << "isuing file request from search dialog: -" << (item->text(SR_NAME_COL)).toStdString() << "-" << hash << "-" << (item->text(SR_SIZE_COL)).toULongLong() << "-ids=" ; - for(std::list::const_iterator it(srcIds.begin());it!=srcIds.end();++it) + for(std::list::const_iterator it(srcIds.begin());it!=srcIds.end();++it) std::cout << *it << "-" << std::endl ; } } @@ -382,7 +382,7 @@ void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString { if (!item->childCount()) { - std::list srcIds; + std::list srcIds; QString path = QString::fromStdString(rsFiles->getDownloadDirectory()) + "/" + base + "/"; @@ -403,7 +403,7 @@ void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString << "-" << hash << "-" << (item->text(SR_SIZE_COL)).toULongLong() << "-ids=" ; - for(std::list::const_iterator it(srcIds.begin()); + for(std::list::const_iterator it(srcIds.begin()); it!=srcIds.end();++it) std::cout << *it << "-" << std::endl ; } else { diff --git a/retroshare-gui/src/gui/SearchDialog.h b/retroshare-gui/src/gui/SearchDialog.h index 2beeb2519..f06ec51a6 100644 --- a/retroshare-gui/src/gui/SearchDialog.h +++ b/retroshare-gui/src/gui/SearchDialog.h @@ -114,7 +114,7 @@ private: void insertDirectory(const QString &txt, qulonglong searchId, const DirDetails &dir); void setIconAndType(QTreeWidgetItem *item, const QString& filename); void downloadDirectory(const QTreeWidgetItem *item, const QString &base); - void getSourceFriendsForHash(const std::string& hash,std::list& srcIds); + void getSourceFriendsForHash(const std::string& hash,std::list &srcIds); /** the advanced search dialog instance */ AdvancedSearchDialog * advSearchDialog; diff --git a/retroshare-gui/src/gui/ServicePermissionDialog.cpp b/retroshare-gui/src/gui/ServicePermissionDialog.cpp index c2abd3bc7..d46bb878e 100644 --- a/retroshare-gui/src/gui/ServicePermissionDialog.cpp +++ b/retroshare-gui/src/gui/ServicePermissionDialog.cpp @@ -88,7 +88,7 @@ void ServicePermissionDialog::itemAdded(int idType, const QString &id, QTreeWidg } RsPeerDetails detail; - if (!rsPeers->getPeerDetails(id.toStdString(), detail)) { + if (!rsPeers->getGPGDetails(RsPgpId(id.toStdString()), detail)) { return; } @@ -140,7 +140,7 @@ void ServicePermissionDialog::setPermissions() } } - rsPeers->setServicePermissionFlags(ui->servicePermissionList->idFromItem(item), flags); + rsPeers->setServicePermissionFlags(RsPgpId(ui->servicePermissionList->idFromItem(item)), flags); } done(Accepted); diff --git a/retroshare-gui/src/gui/StartDialog.cpp b/retroshare-gui/src/gui/StartDialog.cpp index 516add40f..f99d92d11 100644 --- a/retroshare-gui/src/gui/StartDialog.cpp +++ b/retroshare-gui/src/gui/StartDialog.cpp @@ -57,7 +57,7 @@ StartDialog::StartDialog(QWidget *parent) for(it = accountIds.begin(), i = 0; it != accountIds.end(); it++, i++) { const QVariant & userData = QVariant(QString::fromStdString((*it).toStdString())); - PGPIdType gpgid ; + RsPgpId gpgid ; std::string name, email, location; RsAccounts::GetAccountDetails(*it, gpgid, name, email, location); QString accountName = QString::fromUtf8(name.c_str()) + " (" + QString::fromStdString(gpgid.toStdString()).right(8) + ") - " + QString::fromUtf8(location.c_str()); diff --git a/retroshare-gui/src/gui/common/FriendSelectionDialog.cpp b/retroshare-gui/src/gui/common/FriendSelectionDialog.cpp index 1ddbfd121..50ea31d78 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionDialog.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionDialog.cpp @@ -4,25 +4,58 @@ #include #include "FriendSelectionDialog.h" -std::list FriendSelectionDialog::selectFriends(QWidget *parent,const QString& caption,const QString& header_text, - FriendSelectionWidget::Modus modus, - FriendSelectionWidget::ShowTypes show_type, - FriendSelectionWidget::IdType pre_selected_id_type, - const std::list& pre_selected_ids) +std::list FriendSelectionDialog::selectFriends(QWidget *parent,const QString& caption,const QString& header_text, + FriendSelectionWidget::Modus modus, + FriendSelectionWidget::ShowTypes show_type, + const std::list& pre_selected_ids) { - FriendSelectionDialog dialog(parent,header_text,modus,show_type,pre_selected_id_type,pre_selected_ids) ; + FriendSelectionDialog dialog(parent,header_text,modus,show_type,IDTYPE_GPG,pre_selected_ids) ; dialog.setWindowTitle(caption) ; if(QDialog::Rejected == dialog.exec()) return std::list() ; - std::list ids ; + std::list sids ; dialog.friends_widget->selectedIds(pre_selected_id_type,ids,false) ; - return ids ; + std::list ids ; + for(std::list::const_iterator it(sids.begin());it!=sids.end();++it) + { + RsPgpId id(*it) ; + if(!id.isNull()) + ids.push_back(id) ; + else + std::cerr << "ERROR in " << __PRETTY_FUNCTION__ << ": string " << *it << " is not a PGP id" << std::endl; + } + return ids ; } +std::list FriendSelectionDialog::selectFriends(QWidget *parent,const QString& caption,const QString& header_text, + FriendSelectionWidget::Modus modus, + FriendSelectionWidget::ShowTypes show_type, + const std::list& pre_selected_ids) +{ + FriendSelectionDialog dialog(parent,header_text,modus,show_type,IDTYPE_SSL,pre_selected_ids) ; + dialog.setWindowTitle(caption) ; + + if(QDialog::Rejected == dialog.exec()) + return std::list() ; + + std::list sids ; + dialog.friends_widget->selectedIds(pre_selected_id_type,ids,false) ; + + std::list ids ; + for(std::list::const_iterator it(sids.begin());it!=sids.end();++it) + { + RsPeerId id(*it) ; + if(!id.isNull()) + ids.push_back(id) ; + else + std::cerr << "ERROR in " << __PRETTY_FUNCTION__ << ": string " << *it << " is not a SSL id" << std::endl; + } + return ids ; +} FriendSelectionDialog::FriendSelectionDialog(QWidget *parent,const QString& header_text, FriendSelectionWidget::Modus modus, FriendSelectionWidget::ShowTypes show_type, diff --git a/retroshare-gui/src/gui/common/FriendSelectionDialog.h b/retroshare-gui/src/gui/common/FriendSelectionDialog.h index 245940ef9..025f0d35a 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionDialog.h +++ b/retroshare-gui/src/gui/common/FriendSelectionDialog.h @@ -6,12 +6,16 @@ class FriendSelectionDialog : public QDialog { public: - static std::list selectFriends(QWidget *parent,const QString& caption,const QString& header_string, - FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI, - FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL, - FriendSelectionWidget::IdType pre_selected_id_type = FriendSelectionWidget::IDTYPE_SSL, - const std::list& pre_selected_ids = std::list()) ; - private: + static std::list selectFriends_PGP(QWidget *parent,const QString& caption,const QString& header_string, + FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI, + FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL, + const std::list& pre_selected_ids = std::list()) ; + + static std::list selectFriends_SSL(QWidget *parent,const QString& caption,const QString& header_string, + FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI, + FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL, + const std::list& pre_selected_ids = std::list()) ; + private: virtual ~FriendSelectionDialog() ; FriendSelectionDialog(QWidget *parent,const QString& header_string,FriendSelectionWidget::Modus modus,FriendSelectionWidget::ShowTypes show_type, FriendSelectionWidget::IdType pre_selected_id_type, diff --git a/retroshare-gui/src/gui/common/PeerDefs.cpp b/retroshare-gui/src/gui/common/PeerDefs.cpp index 7d27d3de1..02b12b814 100644 --- a/retroshare-gui/src/gui/common/PeerDefs.cpp +++ b/retroshare-gui/src/gui/common/PeerDefs.cpp @@ -34,14 +34,21 @@ const QString PeerDefs::nameWithLocation(const RsPeerDetails &details) return name; } - -const QString PeerDefs::rsid(const std::string &name, const std::string &id) +const QString PeerDefs::rsid(const std::string &name, const RsPgpId &id) { if (name.empty()) { - return qApp->translate("PeerDefs", "Unknown") + "@" + QString::fromStdString(id); + return qApp->translate("PeerDefs", "Unknown") + "@" + QString::fromStdString(id.toStdString()); } - return QString::fromUtf8(name.c_str()) + "@" + QString::fromStdString(id); + return QString::fromUtf8(name.c_str()) + "@" + QString::fromStdString(id.toStdString()); +} +const QString PeerDefs::rsid(const std::string &name, const RsPeerId &id) +{ + if (name.empty()) { + return qApp->translate("PeerDefs", "Unknown") + "@" + QString::fromStdString(id.toStdString()); + } + + return QString::fromUtf8(name.c_str()) + "@" + QString::fromStdString(id.toStdString()); } const QString PeerDefs::rsid(const RsPeerDetails &details) diff --git a/retroshare-gui/src/gui/common/PeerDefs.h b/retroshare-gui/src/gui/common/PeerDefs.h index a5eaeb47c..c418b9690 100644 --- a/retroshare-gui/src/gui/common/PeerDefs.h +++ b/retroshare-gui/src/gui/common/PeerDefs.h @@ -33,7 +33,8 @@ public: static const QString nameWithLocation(const RsPeerDetails &details); static const QString rsid(const RsPeerDetails &details); - static const QString rsid(const std::string &name, const std::string &id); + static const QString rsid(const std::string &name, const RsPeerId &id); + static const QString rsid(const std::string &name, const RsPgpId &id); static const QString rsidFromId(const std::string &id, QString *name = NULL); static const std::string idFromRsid(const QString &rsid, bool check); }; diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h index e6e8fb6b2..8d3dd7ca8 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h @@ -110,7 +110,7 @@ public: private: ImHistoryBrowser *m_historyBrowser; - std::string m_peerId; + RsPeerId m_peerId; volatile bool stopped; }; diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index ab10168f1..5f27c67f9 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -1575,7 +1575,7 @@ void MessageComposer::editingRecipientFinished() lineEdit->setText(text); } -void MessageComposer::addRecipient(enumType type, const std::string& hash,const std::string& pgp_id) +void MessageComposer::addRecipient(enumType type, const Sha1CheckSum& hash,const RsPgpId& pgp_id) { _distant_peers[hash] = pgp_id ; @@ -1601,9 +1601,9 @@ void MessageComposer::addRecipient(enumType type, const std::string& hash,const setRecipientToRow(row, type, hash, false); } -void MessageComposer::addRecipient(enumType type, const std::string &id, bool group) +void MessageComposer::addRecipient(enumType type, const RsPeerId &id, bool group) { - std::list sslIds; + std::list sslIds; if (group) { sslIds.push_back(id); } else { @@ -1613,23 +1613,23 @@ void MessageComposer::addRecipient(enumType type, const std::string &id, bool gr return; } - if (detail.isOnlyGPGdetail) - { - if( (!rsPeers->getAssociatedSSLIds(id, sslIds)) || sslIds.empty()) - { - std::string hash ; - if(rsMsgs->getDistantMessageHash(id,hash)) - addRecipient(type, hash, id); - else - { - QMessageBox::warning(this,tr("PGP key unknown"),tr("You dont have the PGP key of the message sender. So you cannot respond!"),QMessageBox::Ok) ; - return; - } - } - } - else { +// if (detail.isOnlyGPGdetail) +// { +// if( (!rsPeers->getAssociatedSSLIds(id, sslIds)) || sslIds.empty()) +// { +// std::string hash ; +// if(rsMsgs->getDistantMessageHash(id,hash)) +// addRecipient(type, hash, id); +// else +// { +// QMessageBox::warning(this,tr("PGP key unknown"),tr("You dont have the PGP key of the message sender. So you cannot respond!"),QMessageBox::Ok) ; +// return; +// } +// } +// } +// else { sslIds.push_back(id); - } +// } } std::list::const_iterator sslIt; for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) { diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index 7a58a0e87..439543006 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -67,8 +67,8 @@ public: void setTitleText(const QString &title, enumMessageType type = NORMAL); void setQuotedMsg(const QString &msg, const QString &header); void setMsgText(const QString &msg, bool asHtml = false); - void addRecipient(enumType type, const std::string &id, bool group); - void addRecipient(enumType type, const std::string &hash, const std::string& pgp_id) ; + void addRecipient(enumType type, const RsPeerId &id, bool group); + void addRecipient(enumType type, const Sha1CheckSum &hash, const RsPgpId &pgp_id) ; public slots: /* actions to take.... */ @@ -220,7 +220,7 @@ private: Ui::MessageComposer ui; std::list _recList ; - std::map _distant_peers ; // pairs (hash,pgp_id) + std::map _distant_peers ; // pairs (hash,pgp_id) }; #endif diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index f314e4e0f..bb020fc0a 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -311,7 +311,6 @@ HEADERS += rshare.h \ gui/AboutDialog.h \ gui/CreateMsgLinkDialog.h \ gui/NetworkView.h \ - gui/TrustView.h \ gui/MessengerWindow.h \ gui/FriendsDialog.h \ gui/ServicePermissionDialog.h \ @@ -524,7 +523,6 @@ FORMS += gui/StartDialog.ui \ gui/MainWindow.ui \ gui/CreateMsgLinkDialog.ui \ gui/NetworkView.ui \ - gui/TrustView.ui \ gui/MessengerWindow.ui \ gui/FriendsDialog.ui \ gui/SearchDialog.ui \ @@ -630,7 +628,6 @@ SOURCES += main.cpp \ gui/MainWindow.cpp \ gui/CreateMsgLinkDialog.cpp \ gui/NetworkView.cpp \ - gui/TrustView.cpp \ gui/MessengerWindow.cpp \ gui/FriendsDialog.cpp \ gui/ServicePermissionDialog.cpp \