Changed the recommendation of friends from person link to certificate link.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4838 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-01-23 22:38:50 +00:00
parent ecf49d0e14
commit cb9111ad88
3 changed files with 40 additions and 27 deletions

View File

@ -376,7 +376,7 @@ void FriendList::peerTreeWidgetCostumPopupMenu()
// contextMnu.addAction(QIcon(IMAGE_PEERINFO), tr("Profile View"), this, SLOT(viewprofile()));
// action = contextMnu.addAction(QIcon(IMAGE_EXPORTFRIEND), tr("Export Friend"), this, SLOT(exportfriend()));
if (type == TYPE_GPG) {
if (type == TYPE_GPG || type == TYPE_SSL) {
contextMnu.addAction(QIcon(IMAGE_EXPORTFRIEND), tr("Recommend this Friend to..."), this, SLOT(recommendfriend()));
}
@ -1247,8 +1247,20 @@ void FriendList::recommendfriend()
if (!peer)
return;
std::string peerId = getRsId(peer);
std::list<std::string> ids;
ids.push_back(getRsId(peer));
switch (peer->type()) {
case TYPE_SSL:
ids.push_back(peerId);
break;
case TYPE_GPG:
rsPeers->getAssociatedSSLIds(peerId, ids);
break;
default:
return;
}
MessageComposer::recommendFriend(ids);
}

View File

@ -388,15 +388,15 @@ void MessageComposer::processSettings(bool bLoad)
/* window will destroy itself! */
}
static QString BuildRecommendHtml(std::list<std::string> &peerids)
static QString buildRecommendHtml(std::list<std::string> &sslIds)
{
QString text;
/* process peer ids */
std::list <std::string>::iterator peerid;
for (peerid = peerids.begin(); peerid != peerids.end(); peerid++) {
/* process ssl ids */
std::list <std::string>::iterator sslIt;
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
RetroShareLink link;
if (link.createPerson(*peerid)) {
if (link.createCertificate(*sslIt)) {
text += link.toHtml() + "<br>";
}
}
@ -404,11 +404,11 @@ static QString BuildRecommendHtml(std::list<std::string> &peerids)
return text;
}
void MessageComposer::recommendFriend(std::list <std::string> &peerids)
void MessageComposer::recommendFriend(std::list <std::string> &sslIds)
{
// std::cerr << "MessageComposer::recommendFriend()" << std::endl;
if (peerids.size() == 0) {
if (sslIds.size() == 0) {
return;
}
@ -419,11 +419,11 @@ void MessageComposer::recommendFriend(std::list <std::string> &peerids)
QString sMsgText = tr("I recommend a good friend of me, you can trust him too when you trust me. <br> Copy friend link and paste to Friends list");
sMsgText += "<br><br>";
sMsgText += BuildRecommendHtml(peerids);
sMsgText += buildRecommendHtml(sslIds);
pMsgDialog->insertMsgText(sMsgText);
std::list <std::string>::iterator peerIt;
for (peerIt = peerids.begin(); peerIt != peerids.end(); peerIt++) {
for (peerIt = sslIds.begin(); peerIt != sslIds.end(); peerIt++) {
pMsgDialog->addRecipient(CC, *peerIt, false);
}
@ -2355,7 +2355,7 @@ void MessageComposer::addBcc()
void MessageComposer::addRecommend()
{
std::list<std::string> gpgIds;
std::list<std::string> sslIds;
QTreeWidgetItemIterator itemIterator(ui.msgSendList);
QTreeWidgetItem *item;
@ -2372,35 +2372,36 @@ void MessageComposer::addRecommend()
continue;
}
std::list<std::string>::iterator it;
for (it = groupInfo.peerIds.begin(); it != groupInfo.peerIds.end(); it++) {
if (std::find(gpgIds.begin(), gpgIds.end(), *it) == gpgIds.end()) {
gpgIds.push_back(*it);
std::list<std::string>::iterator gpgIt;
for (gpgIt = groupInfo.peerIds.begin(); gpgIt != groupInfo.peerIds.end(); gpgIt++) {
std::list<std::string> groupSslIds;
rsPeers->getAssociatedSSLIds(*gpgIt, groupSslIds);
std::list<std::string>::iterator sslIt;
for (sslIt = groupSslIds.begin(); sslIt != groupSslIds.end(); sslIt++) {
if (std::find(sslIds.begin(), sslIds.end(), *sslIt) == sslIds.end()) {
sslIds.push_back(*sslIt);
}
}
}
} else {
RsPeerDetails detail;
if (rsPeers->getPeerDetails(id, detail) == false) {
continue;
}
if (std::find(gpgIds.begin(), gpgIds.end(), detail.gpg_id) == gpgIds.end()) {
gpgIds.push_back(detail.gpg_id);
if (std::find(sslIds.begin(), sslIds.end(), id) == sslIds.end()) {
sslIds.push_back(id);
}
}
}
}
if (gpgIds.empty()) {
if (sslIds.empty()) {
return;
}
std::list <std::string>::iterator it;
for (it = gpgIds.begin(); it != gpgIds.end(); it++) {
for (it = sslIds.begin(); it != sslIds.end(); it++) {
addRecipient(CC, *it, false);
}
QString text = BuildRecommendHtml(gpgIds);
QString text = buildRecommendHtml(sslIds);
ui.msgText->textCursor().insertHtml(text);
ui.msgText->setFocus(Qt::OtherFocusReason);
}

View File

@ -48,7 +48,7 @@ public:
~MessageComposer();
static void msgFriend(std::string id, bool group);
static void recommendFriend(std::list <std::string> &peerids);
static void recommendFriend(std::list <std::string> &sslIds);
static MessageComposer *newMsg(const std::string &msgId = "");
static MessageComposer *replyMsg(const std::string &msgId, bool all);