finished add a Friend with RetroShare ID in ConnectFriendWizard

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3240 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-07-01 19:04:41 +00:00
parent 6008ef5e22
commit 840f077826

View File

@ -1062,29 +1062,39 @@ bool RsidPage::isComplete() const {
int RsidPage::nextId() const { int RsidPage::nextId() const {
std::string rsidstr;
rsidstr = friendRsidEdit->text().toStdString();
QString rsidstring = friendRsidEdit->text(); QString rsidstring = friendRsidEdit->text();
if (rsidstr.empty() == false) { if (rsidstring.isEmpty() == false) {
RsPeerDetails pd; // search for peer id in string
if ( rsPeers->getPeerDetails(rsidstr, pd) ) { std::string rsidstr;
wizard()->setField(SSL_ID_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.id)); int nIndex = rsidstring.indexOf("@");
wizard()->setField(GPG_ID_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.gpg_id)); if (nIndex >= 0) {
wizard()->setField(LOCATION_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.location)); // found "@", extract peer id from string
//wizard()->setField(CERT_STRING_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(certstr)); rsidstr = rsidstring.mid(nIndex + 1).toStdString();
} else {
// maybe its only the peer id
rsidstr = rsidstring.toStdString();
}
RsPeerDetails pd;
if ( rsPeers->getPeerDetails(rsidstr, pd) ) {
wizard()->setField(SSL_ID_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.id));
wizard()->setField(GPG_ID_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.gpg_id));
wizard()->setField(LOCATION_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.location));
//wizard()->setField(CERT_STRING_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(certstr));
wizard()->setField("ext_friend_ip", QString::fromStdString(pd.extAddr)); wizard()->setField("ext_friend_ip", QString::fromStdString(pd.extAddr));
wizard()->setField("ext_friend_port", QString::number(pd.extPort)); wizard()->setField("ext_friend_port", QString::number(pd.extPort));
wizard()->setField("local_friend_ip", QString::fromStdString(pd.localAddr)); wizard()->setField("local_friend_ip", QString::fromStdString(pd.localAddr));
wizard()->setField("local_friend_port", QString::number(pd.localPort)); wizard()->setField("local_friend_port", QString::number(pd.localPort));
wizard()->setField("dyndns", QString::fromStdString(pd.dyndns)); wizard()->setField("dyndns", QString::fromStdString(pd.dyndns));
return ConnectFriendWizard::Page_Conclusion ; return ConnectFriendWizard::Page_Conclusion ;
} else { } else {
wizard()->setField("errorMessage", QString(tr("This Peer %1 is not available in your Network")).arg(rsidstring) ); wizard()->setField("errorMessage", QString(tr("This Peer %1 is not available in your Network")).arg(rsidstring) );
return ConnectFriendWizard::Page_ErrorMessage; return ConnectFriendWizard::Page_ErrorMessage;
} }
} }
return ConnectFriendWizard::Page_Rsid;
} }