From 80b73d2bc5fbaea6d006d67ab62e2f0633368ae5 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 17 Feb 2014 22:23:45 +0000 Subject: [PATCH] ID cleaning git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7127 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/NetworkDialog.cpp | 6 +- retroshare-gui/src/gui/RetroShareLink.cpp | 6 +- retroshare-gui/src/gui/common/AvatarDefs.cpp | 10 +- .../src/gui/common/AvatarWidget.cpp | 22 +-- retroshare-gui/src/gui/common/FriendList.cpp | 125 +++++++----------- retroshare-gui/src/gui/common/FriendList.h | 2 +- .../src/gui/common/FriendSelectionWidget.cpp | 20 +-- retroshare-gui/src/gui/common/PeerDefs.cpp | 4 +- .../src/gui/connect/ConfCertDialog.h | 2 +- .../src/gui/msgs/MessageComposer.cpp | 97 +++++++------- retroshare-gui/src/gui/msgs/MessageComposer.h | 9 +- retroshare-gui/src/gui/msgs/MessageWidget.cpp | 10 +- retroshare-gui/src/gui/notifyqt.cpp | 17 +-- 13 files changed, 151 insertions(+), 179 deletions(-) diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 795af52e4..3e02aed60 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -364,12 +364,12 @@ void NetworkDialog::sendDistantMessage() return; } - Sha1CheckSum hash ; + DistantMsgPeerId pid ; RsPgpId mGpgId(wi->text(COLUMN_PEERID).toStdString()) ; - if(rsMsgs->getDistantMessageHash(mGpgId,hash)) + if(rsMsgs->getDistantMessagePeerId(mGpgId,pid)) { - nMsgDialog->addRecipient(MessageComposer::TO, hash, mGpgId); + nMsgDialog->addRecipient(MessageComposer::TO, pid, mGpgId); nMsgDialog->show(); nMsgDialog->activateWindow(); } diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 933ad3528..85ab165ba 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -1495,7 +1495,7 @@ 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; - RsFileHash dm_hash ; + DistantMsgPeerId dm_pid ; // This is awful, but apparently the hash can be multiple different types. Let's check! @@ -1514,10 +1514,10 @@ static void processList(const QStringList &list, const QString &textSingular, co msg->show(); messageStarted.append(PeerDefs::nameWithLocation(detail)); } - else if(rsMsgs->getDistantMessageHash(detail.gpg_id,dm_hash)) + else if(rsMsgs->getDistantMessagePeerId(detail.gpg_id,dm_pid)) { MessageComposer *msg = MessageComposer::newMsg(); - msg->addRecipient(MessageComposer::TO, dm_hash,detail.gpg_id) ; + msg->addRecipient(MessageComposer::TO, dm_pid,detail.gpg_id) ; if (link.subject().isEmpty() == false) { msg->setTitleText(link.subject()); diff --git a/retroshare-gui/src/gui/common/AvatarDefs.cpp b/retroshare-gui/src/gui/common/AvatarDefs.cpp index ed582f60e..09dad1c56 100644 --- a/retroshare-gui/src/gui/common/AvatarDefs.cpp +++ b/retroshare-gui/src/gui/common/AvatarDefs.cpp @@ -51,7 +51,7 @@ void AvatarDefs::getAvatarFromSslId(const std::string& sslId, QPixmap &avatar, c int size = 0; /* get avatar */ - rsMsgs->getAvatarData(sslId, data, size); + rsMsgs->getAvatarData(RsPeerId(sslId), data, size); if (size == 0) { avatar = QPixmap(defaultImage); return; @@ -68,14 +68,14 @@ void AvatarDefs::getAvatarFromGpgId(const std::string& gpgId, QPixmap &avatar, c unsigned char *data = NULL; int size = 0; - if (gpgId == rsPeers->getGPGOwnId()) { + if (RsPgpId(gpgId) == rsPeers->getGPGOwnId()) { /* Its me */ rsMsgs->getOwnAvatarData(data,size); } else { /* get the first available avatar of one of the ssl ids */ - std::list sslIds; - if (rsPeers->getAssociatedSSLIds(gpgId, sslIds)) { - std::list::iterator sslId; + std::list sslIds; + if (rsPeers->getAssociatedSSLIds(RsPgpId(gpgId), sslIds)) { + std::list::iterator sslId; for (sslId = sslIds.begin(); sslId != sslIds.end(); sslId++) { rsMsgs->getAvatarData(*sslId, data, size); if (size) { diff --git a/retroshare-gui/src/gui/common/AvatarWidget.cpp b/retroshare-gui/src/gui/common/AvatarWidget.cpp index 4e4074e60..9ee1f4baa 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.cpp +++ b/retroshare-gui/src/gui/common/AvatarWidget.cpp @@ -107,13 +107,13 @@ void AvatarWidget::setFrameType(FrameType type) } refreshStatus(); - updateAvatar(QString::fromStdString(mId)); + updateAvatar(QString::fromStdString(mId.toStdString())); Rshare::refreshStyleSheet(this, false); } void AvatarWidget::setId(const RsPeerId &id) { mId = id; - mPgpId = rsPeers->getGPGId(id) ; +// mPgpId = rsPeers->getGPGId(id) ; // mFlag.isGpg = false ; if (mId == rsPeers->getOwnId()) { @@ -133,13 +133,13 @@ void AvatarWidget::setId(const RsPeerId &id) void AvatarWidget::setOwnId() { - setId(rsPeers->getOwnId(), false); + setId(rsPeers->getOwnId()); } void AvatarWidget::setDefaultAvatar(const QString &avatar) { defaultAvatar = avatar; - updateAvatar(QString::fromStdString(mId)); + updateAvatar(QString::fromStdString(mId.toStdString())); } void AvatarWidget::refreshStatus() @@ -161,7 +161,7 @@ void AvatarWidget::refreshStatus() // No check of return value. Non existing status info is handled as offline. rsStatus->getStatus(mId, statusInfo); } - updateStatus(QString::fromStdString(statusInfo.id), statusInfo.status); + updateStatus(QString::fromStdString(statusInfo.id.toStdString()), statusInfo.status); break; } } @@ -173,12 +173,12 @@ void AvatarWidget::updateStatus(const QString peerId, int status) return; } - if (mId.empty()) { + if (mId.isNull()) { mPeerState = status; Rshare::refreshStyleSheet(this, false); } else { /* set style for status */ - if (mId == peerId.toStdString()) { + if (mId.toStdString() == peerId.toStdString()) { // the peers status has changed mPeerState = status; setEnabled(((uint32_t) status == RS_STATUS_OFFLINE) ? false : true); @@ -189,7 +189,7 @@ void AvatarWidget::updateStatus(const QString peerId, int status) void AvatarWidget::updateAvatar(const QString &peerId) { - if (mId.empty()) { + if (mId.isNull()) { QPixmap avatar(defaultAvatar); setPixmap(avatar); return; @@ -227,9 +227,9 @@ void AvatarWidget::updateAvatar(const QString &peerId) // return; //} - if (mId == peerId.toStdString()) { + if (mId.toStdString() == peerId.toStdString()) { QPixmap avatar; - AvatarDefs::getAvatarFromSslId(mId, avatar, defaultAvatar); + AvatarDefs::getAvatarFromSslId(mId.toStdString(), avatar, defaultAvatar); setPixmap(avatar); return; } @@ -238,6 +238,6 @@ void AvatarWidget::updateAvatar(const QString &peerId) void AvatarWidget::updateOwnAvatar() { if (mFlag.isOwnId) { - updateAvatar(QString::fromStdString(mId)); + updateAvatar(QString::fromStdString(mId.toStdString())); } } diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index 3e9104dcb..95ffc62a3 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -429,7 +429,7 @@ void FriendList::peerTreeWidgetCostumPopupMenu() GroupDefs::sortByName(groupInfoList); - std::string gpgId = getRsId(c); + RsPgpId gpgId ( getRsId(c)); QTreeWidgetItem *parent = c->parent(); @@ -632,7 +632,7 @@ void FriendList::insertPeers() case TYPE_GPG: { QTreeWidgetItem *parent = item->parent(); - std::string gpg_widget_id = getRsId(item); + RsPgpId gpg_widget_id ( getRsId(item)); // remove items that are not friends anymore if (std::find(gpgFriends.begin(), gpgFriends.end(), gpg_widget_id) == gpgFriends.end()) { @@ -752,7 +752,7 @@ void FriendList::insertPeers() while (childIndex < childCount) { QTreeWidgetItem *gpgItemLoop = groupItem->child(childIndex); if (gpgItemLoop->type() == TYPE_GPG) { - if (std::find(groupInfo->peerIds.begin(), groupInfo->peerIds.end(), getRsId(gpgItemLoop)) == groupInfo->peerIds.end()) { + if (std::find(groupInfo->peerIds.begin(), groupInfo->peerIds.end(), RsPgpId(getRsId(gpgItemLoop))) == groupInfo->peerIds.end()) { delete(groupItem->takeChild(groupItem->indexOfChild(gpgItemLoop))); childCount = groupItem->childCount(); continue; @@ -803,14 +803,14 @@ void FriendList::insertPeers() int itemCount = groupItem ? groupItem->childCount() : peerTreeWidget->topLevelItemCount(); for (int index = 0; index < itemCount; index++) { gpgItemLoop = groupItem ? groupItem->child(index) : peerTreeWidget->topLevelItem(index); - if (gpgItemLoop->type() == TYPE_GPG && getRsId(gpgItemLoop) == gpgId) { + if (gpgItemLoop->type() == TYPE_GPG && getRsId(gpgItemLoop) == gpgId.toStdString()) { gpgItem = gpgItemLoop; break; } } RsPeerDetails detail; - if ((!rsPeers->getPeerDetails(gpgId, detail) || !detail.accept_connection) && detail.gpg_id != ownId) { + if ((!rsPeers->getGPGDetails(gpgId, detail) || !detail.accept_connection) && detail.gpg_id != ownId) { // don't accept anymore connection, remove from the view if (gpgItem) { if (groupItem) { @@ -837,7 +837,7 @@ void FriendList::insertPeers() gpgItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter); /* not displayed, used to find back the item */ - gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id)); + gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id.toStdString())); } if (mBigName && !mHideState && isStatusColumnHidden) { @@ -855,7 +855,7 @@ void FriendList::insertPeers() int childIndex = 0; while (childIndex < childCount) { std::string ssl_id = getRsId(gpgItem->child(childIndex)); - if (!rsPeers->isFriend(ssl_id)) { + if (!rsPeers->isFriend(RsPeerId(ssl_id))) { delete (gpgItem->takeChild(childIndex)); // count again childCount = gpgItem->childCount(); @@ -870,23 +870,23 @@ void FriendList::insertPeers() bool gpg_hasPrivateChat = false; int bestPeerState = 0; // for gpg item unsigned int bestRSState = 0; // for gpg item - std::string bestSslId; // for gpg item + RsPeerId bestSslId; // for gpg item QString bestCustomStateString;// for gpg item - std::list sslContacts; + std::list sslContacts; QDateTime lastContact; QString itemIP; rsPeers->getAssociatedSSLIds(detail.gpg_id, sslContacts); - for (std::list::iterator sslIt = sslContacts.begin(); sslIt != sslContacts.end(); sslIt++) { + for (std::list::iterator sslIt = sslContacts.begin(); sslIt != sslContacts.end(); sslIt++) { QTreeWidgetItem *sslItem = NULL; - std::string sslId = *sslIt; + RsPeerId sslId = *sslIt; //find the corresponding sslItem child item of the gpg item bool newChild = true; childCount = gpgItem->childCount(); for (int childIndex = 0; childIndex < childCount; childIndex++) { // we assume, that only ssl items are child of the gpg item, so we don't need to test the type - if (getRsId(gpgItem->child(childIndex)) == sslId) { + if (getRsId(gpgItem->child(childIndex)) == sslId.toStdString()) { sslItem = gpgItem->child(childIndex); newChild = false; break; @@ -917,7 +917,7 @@ void FriendList::insertPeers() } /* not displayed, used to find back the item */ - sslItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(sslDetail.id)); + sslItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(sslDetail.id.toStdString())); QString sText; QString customStateString; @@ -1146,7 +1146,7 @@ void FriendList::insertPeers() // only set the avatar image the first time, or when it changed // otherwise getAvatarFromSslId sends request packages to peers. QPixmap avatar; - AvatarDefs::getAvatarFromSslId(bestSslId, avatar); + AvatarDefs::getAvatarFromSslId(bestSslId.toStdString(), avatar); QIcon avatar_icon(avatar); gpgItem->setIcon(COLUMN_AVATAR, avatar_icon); } @@ -1160,7 +1160,7 @@ void FriendList::insertPeers() gpgItem->setData(COLUMN_IP, Qt::DisplayRole, QVariant()); gpgItem->setData(COLUMN_IP, ROLE_SORT, "2 " + itemIP); - if (openPeers != NULL && openPeers->find(gpgId) != openPeers->end()) { + if (openPeers != NULL && openPeers->find(gpgId.toStdString()) != openPeers->end()) { gpgItem->setExpanded(true); } } @@ -1287,7 +1287,7 @@ void FriendList::chatfriend(QTreeWidgetItem *pPeer) } std::string id = getRsId(pPeer); - ChatDialog::chatFriend(id); + ChatDialog::chatFriend(RsPeerId(id)); } void FriendList::addFriend() @@ -1311,7 +1311,8 @@ void FriendList::msgfriend() return; std::string id = getRsId(peer); - MessageComposer::msgFriend(id, (peer->type() == TYPE_GROUP)); + + MessageComposer::msgFriend(RsPeerId(id), (peer->type() == TYPE_GROUP)); } void FriendList::recommendfriend() @@ -1322,14 +1323,15 @@ void FriendList::recommendfriend() return; std::string peerId = getRsId(peer); - std::list ids; + std::list ids; - switch (peer->type()) { + switch (peer->type()) + { case TYPE_SSL: - ids.push_back(peerId); + ids.push_back(RsPeerId(peerId)); break; case TYPE_GPG: - rsPeers->getAssociatedSSLIds(peerId, ids); + rsPeers->getAssociatedSSLIds(RsPgpId(peerId), ids); break; default: return; @@ -1348,8 +1350,9 @@ void FriendList::copyFullCertificate() { QTreeWidgetItem *c = getCurrentPeer(); QList urls; - RetroShareLink link ; - link.createCertificate(getRsId(c)) ; + RetroShareLink link ; + + link.createCertificate(RsPeerId(getRsId(c))) ; urls.push_back(link); std::cerr << "link: " << std::endl; @@ -1464,9 +1467,12 @@ void FriendList::removefriend() if (rsPeers) { + if(RsPgpId(getRsId(c)).isNull()) + return ; + if ((QMessageBox::question(this, "RetroShare", tr("Do you want to remove this Friend?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes) { - rsPeers->removeFriend(getRsId(c)); + rsPeers->removeFriend(RsPgpId(getRsId(c))); } } } @@ -1492,22 +1498,22 @@ void FriendList::connectfriend() for (int childIndex = 0; childIndex < childCount; childIndex++) { QTreeWidgetItem *item = c->child(childIndex); if (item->type() == TYPE_SSL) { - rsPeers->connectAttempt(getRsId(item)); + rsPeers->connectAttempt(RsPeerId(getRsId(item))); item->setIcon(COLUMN_NAME,(QIcon(IMAGE_CONNECT2))); // Launch ProgressDialog, only if single SSL child. if (childCount == 1) { - ConnectProgressDialog::showProgress(getRsId(item)); + ConnectProgressDialog::showProgress(RsPeerId(getRsId(item))); } } } } else { //this is a SSL key - rsPeers->connectAttempt(getRsId(c)); + rsPeers->connectAttempt(RsPeerId(getRsId(c))); c->setIcon(COLUMN_NAME,(QIcon(IMAGE_CONNECT2))); // Launch ProgressDialog. - ConnectProgressDialog::showProgress(getRsId(c)); + ConnectProgressDialog::showProgress(RsPeerId(getRsId(c))); } } } @@ -1515,7 +1521,12 @@ void FriendList::connectfriend() /* GUI stuff -> don't do anything directly with Control */ void FriendList::configurefriend() { - ConfCertDialog::showIt(getRsId(getCurrentPeer()), ConfCertDialog::PageDetails); + if(!RsPeerId(getRsId(getCurrentPeer())).isNull()) + ConfCertDialog::showIt(RsPeerId(getRsId(getCurrentPeer())), ConfCertDialog::PageDetails); + else if(!RsPgpId(getRsId(getCurrentPeer())).isNull()) + ConfCertDialog::showIt(RsPgpId(getRsId(getCurrentPeer())), ConfCertDialog::PageDetails); + else + std::cerr << "FriendList::configurefriend: id is not an SSL nor a PGP id." << std::endl; } // void FriendList::showLobby() @@ -1548,7 +1559,7 @@ void FriendList::configurefriend() // ChatDialog::closeChat(vpeer_id); // } -void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list &sslIds) +void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list &sslIds) { if (item == NULL) { return; @@ -1558,16 +1569,16 @@ void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list switch (item->type()) { case TYPE_SSL: - sslIds.push_back(peerId); + sslIds.push_back(RsPeerId(peerId)); break; case TYPE_GPG: - rsPeers->getAssociatedSSLIds(peerId, sslIds); + rsPeers->getAssociatedSSLIds(RsPgpId(peerId), sslIds); break; case TYPE_GROUP: { RsGroupInfo groupInfo; if (rsPeers->getGroupInfo(peerId, groupInfo)) { - std::list::iterator gpgIt; + std::list::iterator gpgIt; for (gpgIt = groupInfo.peerIds.begin(); gpgIt != groupInfo.peerIds.end(); ++gpgIt) { rsPeers->getAssociatedSSLIds(*gpgIt, sslIds); } @@ -1577,42 +1588,6 @@ void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list } } -#ifdef TO_REMOVE -void FriendList::inviteToLobby() -{ - QTreeWidgetItem *c = getCurrentPeer(); - - std::list sslIds; - getSslIdsFromItem(c, sslIds); - - std::string lobby_id = qobject_cast(sender())->data().toString().toStdString(); - if (lobby_id.empty()) - return; - - ChatLobbyId lobbyId = QString::fromStdString(lobby_id).toULongLong(); - - // add to group - std::list::iterator it; - for (it = sslIds.begin(); it != sslIds.end(); ++it) { - rsMsgs->invitePeerToLobby(lobbyId, *it); - } - - std::string vpeer_id; - if (rsMsgs->getVirtualPeerId(lobbyId, vpeer_id)) - ChatDialog::chatFriend(vpeer_id); -} - -void FriendList::createchatlobby() -{ - QTreeWidgetItem *c = getCurrentPeer(); - - std::list sslIds; - getSslIdsFromItem(c, sslIds); - - CreateLobbyDialog(sslIds).exec(); -} -#endif - void FriendList::addToGroup() { QTreeWidgetItem *c = getCurrentPeer(); @@ -1626,9 +1601,9 @@ void FriendList::addToGroup() } std::string groupId = qobject_cast(sender())->data().toString().toStdString(); - std::string gpgId = getRsId(c); + RsPgpId gpgId ( getRsId(c)); - if (gpgId.empty() || groupId.empty()) { + if (gpgId.isNull() || groupId.empty()) { return; } @@ -1652,9 +1627,9 @@ void FriendList::moveToGroup() } std::string groupId = qobject_cast(sender())->data().toString().toStdString(); - std::string gpgId = getRsId(c); + RsPgpId gpgId ( getRsId(c)); - if (gpgId.empty() || groupId.empty()) { + if (gpgId.isNull() || groupId.empty()) { return; } @@ -1681,9 +1656,9 @@ void FriendList::removeFromGroup() } std::string groupId = qobject_cast(sender())->data().toString().toStdString(); - std::string gpgId = getRsId(c); + RsPgpId gpgId ( getRsId(c)); - if (gpgId.empty()) { + if (gpgId.isNull()) { return; } diff --git a/retroshare-gui/src/gui/common/FriendList.h b/retroshare-gui/src/gui/common/FriendList.h index 637b741d0..c435e3d6e 100644 --- a/retroshare-gui/src/gui/common/FriendList.h +++ b/retroshare-gui/src/gui/common/FriendList.h @@ -125,7 +125,7 @@ private: static bool filterItem(QTreeWidgetItem *item, const QString &text); void updateHeader(); void initializeHeader(bool afterLoadSettings); - void getSslIdsFromItem(QTreeWidgetItem *item, std::list &sslIds); + void getSslIdsFromItem(QTreeWidgetItem *item, std::list &sslIds); private slots: void groupsChanged(); diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 061b7e08a..658dcfb5b 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -211,7 +211,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons } item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state))); - item->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id)); + item->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id.toStdString())); item->setData(COLUMN_DATA, ROLE_SORT, "2 " + name); } @@ -233,19 +233,19 @@ void FriendSelectionWidget::secured_fillList() mInFillList = true; // get selected items - std::list sslIdsSelected; + std::list sslIdsSelected; if (mShowTypes & SHOW_SSL) { - selectedSslIds(sslIdsSelected, true); + selectedIds(sslIdsSelected,true); } std::list groupIdsSelected; if (mShowTypes & SHOW_GROUP) { - selectedGroupIds(groupIdsSelected); + selectedIds(groupIdsSelected,true); } - std::list gpgIdsSelected; + std::list gpgIdsSelected; if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) { - selectedGpgIds(gpgIdsSelected, true); + selectedIds(gpgIdsSelected,true); } // remove old items @@ -256,16 +256,16 @@ void FriendSelectionWidget::secured_fillList() std::list::iterator groupIt; rsPeers->getGroupInfoList(groupInfoList); - std::list gpgIds; - std::list::iterator gpgIt; + std::list gpgIds; + std::list::iterator gpgIt; if(mShowTypes & SHOW_NON_FRIEND_GPG) rsPeers->getGPGAllList(gpgIds); else rsPeers->getGPGAcceptedList(gpgIds); - std::list sslIds; - std::list::iterator sslIt; + std::list sslIds; + std::list::iterator sslIt; if ((mShowTypes & (SHOW_SSL | SHOW_GPG)) == SHOW_SSL) { rsPeers->getFriendList(sslIds); diff --git a/retroshare-gui/src/gui/common/PeerDefs.cpp b/retroshare-gui/src/gui/common/PeerDefs.cpp index e3945bb78..02bcf4c51 100644 --- a/retroshare-gui/src/gui/common/PeerDefs.cpp +++ b/retroshare-gui/src/gui/common/PeerDefs.cpp @@ -61,7 +61,7 @@ const QString PeerDefs::rsidFromId(const RsPeerId &id, QString *name /* = NULL*/ QString rsid; std::string peerName = rsPeers->getPeerName(id); - std::string hash ; + DistantMsgPeerId pid ; if(!peerName.empty()) { @@ -71,7 +71,7 @@ const QString PeerDefs::rsidFromId(const RsPeerId &id, QString *name /* = NULL*/ *name = QString::fromUtf8(peerName.c_str()); } } - else if(rsMsgs->getDistantMessageHash(rsPeers->getGPGOwnId(),hash) && hash == id) + else if(rsMsgs->getDistantMessagePeerId(rsPeers->getGPGOwnId(),pid) && pid == id) { // not a real peer. Try from hash for distant messages diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.h b/retroshare-gui/src/gui/connect/ConfCertDialog.h index 90a3d7260..949c0667c 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.h +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.h @@ -37,7 +37,7 @@ public: template static void showIt(const ID_CLASS& id, enumPage page) { - ConfCertDialog *confdialog = instance(id); + ConfCertDialog *confdialog = confdialog = instance(id); switch (page) { case PageDetails: diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index ae3da397a..f39aa684e 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -365,14 +365,14 @@ void MessageComposer::processSettings(bool bLoad) /* create a message */ - Sha1CheckSum hash ; - rsMsgs->getDistantMessageHash(pgp_id,hash) ; + DistantMsgPeerId pid ; + rsMsgs->getDistantMessagePeerId(pgp_id,pid) ; MessageComposer *pMsgDialog = MessageComposer::newMsg(); if (pMsgDialog == NULL) return; - pMsgDialog->addRecipient(TO, hash,pgp_id) ; + pMsgDialog->addRecipient(TO,pid,pgp_id) ; pMsgDialog->show(); /* window will destroy itself! */ @@ -683,11 +683,11 @@ void MessageComposer::peerStatusChanged(const QString& peer_id, int status) for (row = 0; row < rowCount; row++) { enumType type; - RsPeerId id; + std::string id; bool group; - if (getRecipientFromRow(row, type, id, group) && !id.isNull() ) { - if (group == false && QString::fromStdString(id.toStdString()) == peer_id) { + if (getRecipientFromRow(row, type, id, group) && !id.empty() ) { + if (group == false && QString::fromStdString(id) == peer_id) { QTableWidgetItem *item = ui.recipientWidget->item(row, COLUMN_RECIPIENT_ICON); if (item) { item->setIcon(QIcon(StatusDefs::imageUser(status))); @@ -1352,10 +1352,10 @@ void MessageComposer::addEmptyRecipient() } } - setRecipientToRow(lastRow, TO, RsPeerId(), false); + setRecipientToRow(lastRow, TO,"", false); } -bool MessageComposer::getRecipientFromRow(int row, enumType &type, RsPeerId &id, bool &group) +bool MessageComposer::getRecipientFromRow(int row, enumType &type, std::string &id, bool &group) { if (row >= ui.recipientWidget->rowCount()) { return false; @@ -1367,13 +1367,13 @@ bool MessageComposer::getRecipientFromRow(int row, enumType &type, RsPeerId &id, } type = (enumType) cb->itemData(cb->currentIndex(), Qt::UserRole).toInt(); - id = RsPeerId(ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->data(ROLE_RECIPIENT_ID).toString().toStdString()); + id = ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->data(ROLE_RECIPIENT_ID).toString().toStdString(); group = ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->data(ROLE_RECIPIENT_GROUP).toBool(); return true; } -void MessageComposer::setRecipientToRow(int row, enumType type, const RsPeerId &id, bool group) +void MessageComposer::setRecipientToRow(int row, enumType type, const std::string& id, bool group) { if (row + 1 > ui.recipientWidget->rowCount()) { ui.recipientWidget->setRowCount(row + 1); @@ -1408,7 +1408,7 @@ void MessageComposer::setRecipientToRow(int row, enumType type, const RsPeerId & QIcon icon; QString name; - if (!id.isNull()) + if (!id.empty()) { if (group) { @@ -1419,31 +1419,30 @@ void MessageComposer::setRecipientToRow(int row, enumType type, const RsPeerId & name = GroupDefs::name(groupInfo); } else { name = tr("Unknown"); - id.clear(); } } else { RsPeerDetails details; - if(_distant_peers.find(id) != _distant_peers.end()) + if(_distant_peers.find(RsPeerId(id)) != _distant_peers.end()) { - if(!rsPeers->getPeerDetails(_distant_peers[id], details)) + if(!rsPeers->getGPGDetails(_distant_peers[RsPeerId(id)], details)) { - std::cerr << "Can't get peer details from " << _distant_peers[id] << std::endl; + std::cerr << "Can't get peer details from " << _distant_peers[RsPeerId(id)] << std::endl; return ; } - name = tr("Distant peer (name: %2, PGP key: %1)").arg(QString::fromStdString(_distant_peers[id])).arg(QString::fromStdString(details.name)) ; + name = tr("Distant peer (name: %2, PGP key: %1)").arg(QString::fromStdString(_distant_peers[RsPeerId(id)].toStdString())).arg(QString::fromStdString(details.name)) ; icon = QIcon(StatusDefs::imageUser(RS_STATUS_ONLINE)); } - else if(rsPeers->getPeerDetails(id, details) && (!details.isOnlyGPGdetail)) + else if(rsPeers->getPeerDetails(RsPeerId(id), details) && (!details.isOnlyGPGdetail)) { name = PeerDefs::nameWithLocation(details); StatusInfo peerStatusInfo; // No check of return value. Non existing status info is handled as offline. - rsStatus->getStatus(id, peerStatusInfo); + rsStatus->getStatus(RsPeerId(id), peerStatusInfo); icon = QIcon(StatusDefs::imageUser(peerStatusInfo.status)); } @@ -1451,7 +1450,6 @@ void MessageComposer::setRecipientToRow(int row, enumType type, const RsPeerId & { icon = QIcon(StatusDefs::imageUser(RS_STATUS_OFFLINE)); name = tr("Unknown friend"); - id.clear(); } } } @@ -1560,7 +1558,7 @@ void MessageComposer::editingRecipientFinished() QString name = PeerDefs::nameWithLocation(details); if (text.compare(name, Qt::CaseSensitive) == 0) { // found it - setRecipientToRow(row, type, details.id, false); + setRecipientToRow(row, type, details.id.toStdString(), false); return; } } @@ -1579,14 +1577,14 @@ void MessageComposer::editingRecipientFinished() } } - setRecipientToRow(row, type, RsPeerId(), false); + setRecipientToRow(row, type, "", false); lineEdit->setStyleSheet(QString(STYLE_FAIL).arg(lineEdit->objectName())); lineEdit->setText(text); } -void MessageComposer::addRecipient(enumType type, const Sha1CheckSum& hash,const RsPgpId& pgp_id) +void MessageComposer::addRecipient(enumType type, const DistantMsgPeerId& pid,const RsPgpId& pgp_id) { - _distant_peers[hash] = pgp_id ; + _distant_peers[pid] = pgp_id ; int rowCount = ui.recipientWidget->rowCount(); int row; @@ -1601,17 +1599,14 @@ void MessageComposer::addRecipient(enumType type, const Sha1CheckSum& hash,const if (rowId.empty()) // use row break; - if (rowId == hash && rowType == type) // existing row + if (rowId == pid.toStdString() && rowType == type) // existing row break; } else // use row break; } - setRecipientToRow(row, type, hash, false); -} -void MessageComposer::addRecipient(enumType type, const RsPgpId &id, bool group) -{ + setRecipientToRow(row, type, pid.toStdString(), false); } void MessageComposer::addRecipient(enumType type, const RsPeerId &id, bool group) { @@ -1643,7 +1638,7 @@ void MessageComposer::addRecipient(enumType type, const RsPeerId &id, bool group sslIds.push_back(id); // } } - std::list::const_iterator sslIt; + std::list::const_iterator sslIt; for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) { // search existing or empty row int rowCount = ui.recipientWidget->rowCount(); @@ -1659,7 +1654,7 @@ void MessageComposer::addRecipient(enumType type, const RsPeerId &id, bool group break; } - if (rowId == *sslIt && rowType == type && group == rowGroup) { + if (rowId == (*sslIt).toStdString() && rowType == type && group == rowGroup) { // existing row break; } @@ -1669,7 +1664,7 @@ void MessageComposer::addRecipient(enumType type, const RsPeerId &id, bool group } } - setRecipientToRow(row, type, *sslIt, group); + setRecipientToRow(row, type, (*sslIt).toStdString(), group); } } @@ -2306,28 +2301,28 @@ void MessageComposer::fileHashingFinished(QList hashedFiles) void MessageComposer::addContact(enumType type) { - std::list ids; - ui.friendSelectionWidget->selectedGroupIds(ids); + // std::list ids; + // ui.friendSelectionWidget->selectedIds(ids,false); + // + // std::list::iterator idIt; + // for (idIt = ids.begin(); idIt != ids.end(); idIt++) { + // addRecipient(type, *idIt, true); + // } - std::list::iterator idIt; - for (idIt = ids.begin(); idIt != ids.end(); idIt++) { - addRecipient(type, *idIt, true); - } - - ids.empty(); - ui.friendSelectionWidget->selectedSslIds(ids, true); - for (idIt = ids.begin(); idIt != ids.end(); idIt++) { + std::list ids ; + ui.friendSelectionWidget->selectedIds(ids, true); + for (std::list::const_iterator idIt = ids.begin(); idIt != ids.end(); idIt++) { addRecipient(type, *idIt, false); } - ids.empty(); - ui.friendSelectionWidget->selectedGpgIds(ids, true); - for (idIt = ids.begin(); idIt != ids.end(); idIt++) + std::list id2 ; + ui.friendSelectionWidget->selectedIds(id2, true); + for (std::list::const_iterator idIt = id2.begin(); idIt != id2.end(); idIt++) { - std::string hash ; + DistantMsgPeerId pid ; - if(rsMsgs->getDistantMessageHash(*idIt,hash)) - addRecipient(type, hash, *idIt); + if(rsMsgs->getDistantMessagePeerId(*idIt,pid)) + addRecipient(type, pid, *idIt); } } @@ -2356,14 +2351,14 @@ void MessageComposer::addBcc() void MessageComposer::addRecommend() { - std::list sslIds; - ui.friendSelectionWidget->selectedSslIds(sslIds, false); + std::list sslIds; + ui.friendSelectionWidget->selectedIds(sslIds, false); if (sslIds.empty()) { return; } - std::list ::iterator it; + std::list ::iterator it; for (it = sslIds.begin(); it != sslIds.end(); it++) { addRecipient(CC, *it, false); } @@ -2382,7 +2377,7 @@ void MessageComposer::friendDetails() return; } - ConfCertDialog::showIt(id, ConfCertDialog::PageDetails); + ConfCertDialog::showIt(RsPeerId(id), ConfCertDialog::PageDetails); } void MessageComposer::tagAboutToShow() diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index 8731e4fbc..e07743cf9 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -24,6 +24,7 @@ #include #include +#include #include "ui_MessageComposer.h" class QAction; @@ -68,7 +69,7 @@ public: void setQuotedMsg(const QString &msg, const QString &header); void setMsgText(const QString &msg, bool asHtml = false); void addRecipient(enumType type, const RsPeerId &id, bool group); - void addRecipient(enumType type, const Sha1CheckSum &hash, const RsPgpId &pgp_id) ; + void addRecipient(enumType type, const DistantMsgPeerId &pid, const RsPgpId &pgp_id) ; public slots: /* actions to take.... */ @@ -173,8 +174,8 @@ private: void calculateTitle(); void addEmptyRecipient(); - bool getRecipientFromRow(int row, enumType &type, RsPeerId &id, bool &group); - void setRecipientToRow(int row, enumType type, const RsPeerId& id, bool group); + bool getRecipientFromRow(int row, enumType &type, std::string &id, bool &group); + void setRecipientToRow(int row, enumType type, const std::string &id, bool group); void clearTagLabels(); void showTagLabels(); @@ -220,7 +221,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/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index f8e197b1e..a04994977 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -303,7 +303,7 @@ void MessageWidget::getcurrentrecommended() return; } - std::list srcIds; + std::list srcIds; srcIds.push_back(msgInfo.srcId); QModelIndexList list = ui.msgList->selectionModel()->selectedIndexes(); @@ -352,7 +352,7 @@ void MessageWidget::getallrecommended() /* do the requests */ for(it = recList.begin(); it != recList.end(); it++) { std::cerr << "MessageWidget::getallrecommended() Calling File Request" << std::endl; - std::list srcIds; + std::list srcIds; srcIds.push_back(msgInfo.srcId); rsFiles->FileRequest(it->fname, it->hash, it->size, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds); } @@ -497,7 +497,7 @@ void MessageWidget::fill(const std::string &msgId) ui.msgList->insertTopLevelItems(0, items); /* iterate through the sources */ - std::list::const_iterator pit; + std::list::const_iterator pit; RetroShareLink link; QString text; @@ -545,9 +545,9 @@ void MessageWidget::fill(const std::string &msgId) ui.dateText->setText(DateTime::formatDateTime(msgInfo.ts)); - std::string ownId = rsPeers->getOwnId(); + RsPeerId ownId = rsPeers->getOwnId(); - std::string srcId; + RsPeerId srcId; if ((msgInfo.msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX) { // outgoing message are from me srcId = ownId; diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index e28fefbd3..a056858c7 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -817,7 +817,7 @@ void NotifyQt::UpdateGUI() // do not show when active break; } - toaster = new Toaster(new ChatToaster(id, QString::fromUtf8(msg.c_str()))); + toaster = new Toaster(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); } break; case RS_POPUP_GROUPCHAT: @@ -832,7 +832,7 @@ void NotifyQt::UpdateGUI() } } } - toaster = new Toaster(new GroupChatToaster(id, QString::fromUtf8(msg.c_str()))); + toaster = new Toaster(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); } break; case RS_POPUP_CHATLOBBY: @@ -849,7 +849,7 @@ void NotifyQt::UpdateGUI() // participant is muted break; } - toaster = new Toaster(new ChatLobbyToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str()))); + toaster = new Toaster(new ChatLobbyToaster(RsPeerId(id), QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str()))); } break; case RS_POPUP_CONNECT_ATTEMPT: @@ -858,7 +858,7 @@ void NotifyQt::UpdateGUI() // id = gpgid // title = ssl name // msg = peer id - toaster = new Toaster(new FriendRequestToaster(id, QString::fromUtf8(title.c_str()), msg)); + toaster = new Toaster(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg))); } break; } @@ -921,6 +921,7 @@ void NotifyQt::testToaster(uint notifyFlags, /*RshareSettings::enumToasterPositi QString message = tr("This is a test."); RsPeerId id = rsPeers->getOwnId(); + RsPgpId pgpid = rsPeers->getGPGOwnId(); uint pos = 0; @@ -946,16 +947,16 @@ void NotifyQt::testToaster(uint notifyFlags, /*RshareSettings::enumToasterPositi toaster = new Toaster(new DownloadToaster(id.toStdString(), title)); break; case RS_POPUP_CHAT: - toaster = new Toaster(new ChatToaster(id.toStdString(), message)); + toaster = new Toaster(new ChatToaster(id, message)); break; case RS_POPUP_GROUPCHAT: - toaster = new Toaster(new GroupChatToaster(id.toStdString(), message)); + toaster = new Toaster(new GroupChatToaster(id, message)); break; case RS_POPUP_CHATLOBBY: - toaster = new Toaster(new ChatLobbyToaster(id.toStdString(), title, message)); + toaster = new Toaster(new ChatLobbyToaster(id, title, message)); break; case RS_POPUP_CONNECT_ATTEMPT: - toaster = new Toaster(new FriendRequestToaster(id.toStdString(), title, id.toStdString())); + toaster = new Toaster(new FriendRequestToaster(pgpid, title, id)); break; }