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
This commit is contained in:
csoler 2014-02-13 13:02:46 +00:00
parent 919003814a
commit 37dd5821b9
27 changed files with 229 additions and 169 deletions

View file

@ -47,14 +47,14 @@ bool AuthorPending::expired() const
} }
bool AuthorPending::getAuthorRep(GixsReputation& rep, bool AuthorPending::getAuthorRep(GixsReputation& rep,
const std::string& authorId, const std::string& peerId) const std::string& authorId, const RsPeerId& peerId)
{ {
if(mRep->haveReputation(authorId)) if(mRep->haveReputation(authorId))
{ {
return mRep->getReputation(authorId, rep); return mRep->getReputation(authorId, rep);
} }
std::list<std::string> peers; std::list<RsPeerId> peers;
peers.push_back(peerId); peers.push_back(peerId);
mRep->loadReputation(authorId, peers); mRep->loadReputation(authorId, peers);
return false; 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) : 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) : AuthorPending(rep, time(NULL)), mPeerId(peerId), mGrpAuthV(grpAuthV), mCutOff(cutOff)
{ {
} }

View file

@ -39,11 +39,16 @@
#define USE_NEW_CHUNK_CHECKING_CODE #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 RsCertId;
typedef std::string RsChanId; typedef std::string RsChanId;
typedef std::string RsMsgId; typedef std::string RsMsgId;
typedef std::string RsAuthId; typedef std::string RsAuthId;
typedef SSLIdType RsPeerId ; typedef SSLIdType RsPeerId ;
typedef PGPIdType RsPgpId ;
typedef Sha1CheckSum RsFileHash ;
const uint32_t FT_STATE_FAILED = 0x0000 ; const uint32_t FT_STATE_FAILED = 0x0000 ;
const uint32_t FT_STATE_OKAY = 0x0001 ; const uint32_t FT_STATE_OKAY = 0x0001 ;

View file

@ -82,7 +82,8 @@ void CreateMsgLinkDialog::createLink()
time_t validity_duration = computeValidityDuration() ; time_t validity_duration = computeValidityDuration() ;
FriendSelectionWidget::IdType type ; 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 ; std::string encrypted_string ;
@ -90,7 +91,7 @@ void CreateMsgLinkDialog::createLink()
RetroShareLink link ; 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; std::cerr << "Cannot create link." << std::endl;
QList<RetroShareLink> links ; QList<RetroShareLink> links ;

View file

@ -146,7 +146,7 @@ FriendsDialog::FriendsDialog(QWidget *parent)
int messageCount = Settings->getPublicChatHistoryCount(); int messageCount = Settings->getPublicChatHistoryCount();
if (messageCount > 0) { if (messageCount > 0) {
std::list<HistoryMsg> historyMsgs; std::list<HistoryMsg> historyMsgs;
rsHistory->getMessages("", historyMsgs, messageCount); rsHistory->getMessages(RsPeerId(), historyMsgs, messageCount);
std::list<HistoryMsg>::iterator it; std::list<HistoryMsg>::iterator it;
for (it = historyMsgs.begin(); it != historyMsgs.end(); 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 ; std::cerr << "FriendsDialog: received group chat typing info. updating gui." << std::endl ;
#endif #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. ui.statusStringLabel->setText(status) ; // displays info for 5 secs.
QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ; 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) { 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(); on_actionClear_Chat_History_triggered();
rsHistory->clear(""); rsHistory->clear(RsPeerId());
} }
} }
@ -821,7 +821,7 @@ void FriendsDialog::fileHashingFinished(QList<HashedFile> hashedFiles)
HashedFile& hashedFile = *it; HashedFile& hashedFile = *it;
RetroShareLink link; 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; continue;
mesgString += link.toHtmlSize(); mesgString += link.toHtmlSize();

View file

@ -178,8 +178,8 @@ void GenCertDialog::init()
ui.genPGPuser->clear() ; ui.genPGPuser->clear() ;
std::list<PGPIdType> pgpIds; std::list<RsPgpId> pgpIds;
std::list<PGPIdType>::iterator it; std::list<RsPgpId>::iterator it;
bool foundGPGKeys = false; bool foundGPGKeys = false;
if (!mOnlyGenerateIdentity) { if (!mOnlyGenerateIdentity) {
if (RsAccounts::GetPGPLogins(pgpIds)) { if (RsAccounts::GetPGPLogins(pgpIds)) {
@ -310,7 +310,7 @@ void GenCertDialog::exportIdentity()
return ; return ;
QVariant data = ui.genPGPuser->itemData(ui.genPGPuser->currentIndex()); 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)) 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")) ; 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()) if(fname.isNull())
return ; return ;
PGPIdType gpg_id ; RsPgpId gpg_id ;
std::string err_string ; std::string err_string ;
if(!RsAccounts::ImportIdentity(fname.toStdString(),gpg_id,err_string)) if(!RsAccounts::ImportIdentity(fname.toStdString(),gpg_id,err_string))
@ -350,7 +350,7 @@ void GenCertDialog::genPerson()
{ {
/* Check the data from the GUI. */ /* Check the data from the GUI. */
std::string genLoc = ui.location_input->text().toUtf8().constData(); std::string genLoc = ui.location_input->text().toUtf8().constData();
PGPIdType PGPId; RsPgpId PGPId;
bool isHiddenLoc = false; bool isHiddenLoc = false;
if (ui.hidden_checkbox->isChecked()) if (ui.hidden_checkbox->isChecked())
@ -389,7 +389,7 @@ void GenCertDialog::genPerson()
return; return;
} }
QVariant data = ui.genPGPuser->itemData(pgpidx); QVariant data = ui.genPGPuser->itemData(pgpidx);
PGPId = PGPIdType((data.toString()).toStdString()); PGPId = RsPgpId((data.toString()).toStdString());
} else { } else {
if (ui.password_input->text().length() < 3 || ui.name_input->text().length() < 3 || genLoc.length() < 3) { if (ui.password_input->text().length() < 3 || ui.name_input->text().length() < 3 || genLoc.length() < 3) {
/* Message Dialog */ /* Message Dialog */

View file

@ -127,11 +127,11 @@ void IdEditDialog::updateIdType(bool pseudo)
else else
{ {
/* get GPG Details from rsPeers */ /* get GPG Details from rsPeers */
std::string gpgid = rsPeers->getGPGOwnId(); RsPgpId gpgid = rsPeers->getGPGOwnId();
RsPeerDetails details; 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_GpgHash->setText(tr("To be generated"));
ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str())); ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
} }

View file

@ -1260,7 +1260,7 @@ void MainWindow::setStatus(QObject *pObject, int nStatus)
nStatus = RS_STATUS_INACTIVE; nStatus = RS_STATUS_INACTIVE;
} }
rsStatus->sendStatus("", nStatus); rsStatus->sendStatus(RsPeerId(), nStatus);
/* set status in all status objects, but the calling one */ /* set status in all status objects, but the calling one */
for (std::set <QObject*>::iterator it = m_apStatusObjects.begin(); it != m_apStatusObjects.end(); it++) { for (std::set <QObject*>::iterator it = m_apStatusObjects.begin(); it != m_apStatusObjects.end(); it++) {

View file

@ -847,7 +847,7 @@ void MessagesDialog::insertMessages()
bool gotInfo; bool gotInfo;
QString text; QString text;
std::string ownId = rsPeers->getOwnId(); RsPeerId ownId = rsPeers->getOwnId();
rsMsgs -> getMessageSummaries(msgList); rsMsgs -> getMessageSummaries(msgList);
@ -1114,7 +1114,7 @@ void MessagesDialog::insertMessages()
text.clear(); text.clear();
std::list<std::string>::const_iterator pit; std::list<RsPeerId>::const_iterator pit;
for (pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++) for (pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++)
{ {
if (text.isEmpty() == false) { if (text.isEmpty() == false) {
@ -1148,7 +1148,7 @@ void MessagesDialog::insertMessages()
// internal data // internal data
QString msgId = QString::fromStdString(it->msgId); 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(msgId, ROLE_MSGID);
item[COLUMN_DATA]->setData(it->msgflags, ROLE_MSGFLAGS); item[COLUMN_DATA]->setData(it->msgflags, ROLE_MSGFLAGS);

View file

@ -154,7 +154,7 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags)
// add self nick // add self nick
RsPeerDetails pd; RsPeerDetails pd;
std::string ownId = rsPeers->getOwnId(); RsPeerId ownId = rsPeers->getOwnId();
if (rsPeers->getPeerDetails(ownId, pd)) { if (rsPeers->getPeerDetails(ownId, pd)) {
/* calculate only once */ /* calculate only once */
m_nickName = QString::fromUtf8(pd.name.c_str()); m_nickName = QString::fromUtf8(pd.name.c_str());
@ -163,7 +163,7 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags)
/* Show nick and current state */ /* Show nick and current state */
StatusInfo statusInfo; StatusInfo statusInfo;
rsStatus->getOwnStatus(statusInfo); rsStatus->getOwnStatus(statusInfo);
updateOwnStatus(QString::fromStdString(ownId), statusInfo.status); updateOwnStatus(QString::fromStdString(ownId.toStdString()), statusInfo.status);
MainWindow *pMainWindow = MainWindow::getInstance(); MainWindow *pMainWindow = MainWindow::getInstance();
if (pMainWindow) { if (pMainWindow) {
@ -251,7 +251,7 @@ void MessengerWindow::savestatusmessage()
void MessengerWindow::updateOwnStatus(const QString &peer_id, int status) void MessengerWindow::updateOwnStatus(const QString &peer_id, int status)
{ {
// add self nick + own status // add self nick + own status
if (peer_id.toStdString() == rsPeers->getOwnId()) if (peer_id == QString::fromStdString(rsPeers->getOwnId().toStdString()))
{ {
// my status has changed // my status has changed

View file

@ -203,7 +203,7 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
QMenu *contextMnu = new QMenu; 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 // That's what context menus are made for
RsPeerDetails detail; RsPeerDetails detail;
@ -231,15 +231,15 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
void NetworkDialog::removeUnusedKeys() void NetworkDialog::removeUnusedKeys()
{ {
std::list<PGPIdType> pre_selected ; std::list<RsPgpId> pre_selected ;
std::list<PGPIdType> ids ; std::list<RsPgpId> ids ;
rsPeers->getGPGAllList(ids) ; rsPeers->getGPGAllList(ids) ;
RsPeerDetails details ; RsPeerDetails details ;
time_t now = time(NULL) ; time_t now = time(NULL) ;
time_t THREE_MONTHS = 3*31*24*60*60 ;//3*DayPerMonth*HoursPerDay*MinPerHour*SecPerMin time_t THREE_MONTHS = 3*31*24*60*60 ;//3*DayPerMonth*HoursPerDay*MinPerHour*SecPerMin
for(std::list<PGPIdType>::const_iterator it(ids.begin());it!=ids.end();++it) for(std::list<RsPgpId>::const_iterator it(ids.begin());it!=ids.end();++it)
{ {
rsPeers->getGPGDetails(*it,details) ; rsPeers->getGPGDetails(*it,details) ;
@ -255,13 +255,13 @@ void NetworkDialog::removeUnusedKeys()
} }
} }
std::list<PGPIdType> selected = FriendSelectionDialog::selectFriends(NULL, std::list<RsPgpId> selected = FriendSelectionDialog::selectFriends_PGP(NULL,
tr("Clean keyring"), 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, 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; std::cerr << "Removing these keys from the keyring: " << std::endl;
for(std::list<PGPIdType>::const_iterator it(selected.begin());it!=selected.end();++it) for(std::list<RsPgpId>::const_iterator it(selected.begin());it!=selected.end();++it)
std::cerr << " " << *it << std::endl; std::cerr << " " << *it << std::endl;
std::string backup_file ; std::string backup_file ;
@ -298,7 +298,7 @@ void NetworkDialog::removeUnusedKeys()
void NetworkDialog::denyFriend() void NetworkDialog::denyFriend()
{ {
QTreeWidgetItem *wi = getCurrentNeighbour(); QTreeWidgetItem *wi = getCurrentNeighbour();
PGPIdType peer_id( wi->text(COLUMN_PEERID).toStdString() ); RsPgpId peer_id( wi->text(COLUMN_PEERID).toStdString() );
rsPeers->removeFriend(peer_id) ; rsPeers->removeFriend(peer_id) ;
securedUpdateDisplay(); securedUpdateDisplay();
@ -341,7 +341,7 @@ void NetworkDialog::copyLink()
return; return;
} }
std::string peer_id = wi->text(COLUMN_PEERID).toStdString() ; RsPgpId peer_id ( wi->text(COLUMN_PEERID).toStdString() ) ;
QList<RetroShareLink> urls; QList<RetroShareLink> urls;
RetroShareLink link; RetroShareLink link;
@ -365,11 +365,11 @@ void NetworkDialog::sendDistantMessage()
} }
Sha1CheckSum hash ; Sha1CheckSum hash ;
PGPIdType mGpgId(wi->text(COLUMN_PEERID).toStdString()) ; RsPgpId mGpgId(wi->text(COLUMN_PEERID).toStdString()) ;
if(rsMsgs->getDistantMessageHash(mGpgId,hash)) if(rsMsgs->getDistantMessageHash(mGpgId,hash))
{ {
nMsgDialog->addRecipient(MessageComposer::TO, hash.toStdString(), mGpgId.toStdString()); nMsgDialog->addRecipient(MessageComposer::TO, hash, mGpgId);
nMsgDialog->show(); nMsgDialog->show();
nMsgDialog->activateWindow(); nMsgDialog->activateWindow();
} }
@ -397,8 +397,8 @@ void NetworkDialog::insertConnect()
// //
// last_time = now ; // last_time = now ;
std::list<PGPIdType> neighs; //these are GPG ids std::list<RsPgpId> neighs; //these are GPG ids
std::list<PGPIdType>::iterator it; std::list<RsPgpId>::iterator it;
rsPeers->getGPGAllList(neighs); rsPeers->getGPGAllList(neighs);
/* get a link to the table */ /* get a link to the table */
@ -408,7 +408,7 @@ void NetworkDialog::insertConnect()
int index = 0; int index = 0;
while (index < connectWidget->topLevelItemCount()) 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; RsPeerDetails detail;
if ( (!rsPeers->getGPGDetails(gpg_widget_id, detail)) || (ui.onlyTrustedKeys->isChecked() && (detail.validLvl < RS_TRUST_LVL_MARGINAL && !detail.accept_connection))) if ( (!rsPeers->getGPGDetails(gpg_widget_id, detail)) || (ui.onlyTrustedKeys->isChecked() && (detail.validLvl < RS_TRUST_LVL_MARGINAL && !detail.accept_connection)))
delete (connectWidget->takeTopLevelItem(index)); delete (connectWidget->takeTopLevelItem(index));

View file

@ -109,9 +109,9 @@ void NetworkView::setFreezeState(bool freeze)
class NodeInfo class NodeInfo
{ {
public: 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 ; uint32_t friend_level ;
} ; } ;
@ -127,16 +127,16 @@ void NetworkView::updateDisplay()
return ; return ;
/* add all friends */ /* add all friends */
std::string ownGPGId = rsPeers->getGPGOwnId(); RsPgpId ownGPGId = rsPeers->getGPGOwnId();
//#ifdef DEBUG_NETWORKVIEW //#ifdef DEBUG_NETWORKVIEW
std::cerr << "NetworkView::updateDisplay()" << std::endl; std::cerr << "NetworkView::updateDisplay()" << std::endl;
//#endif //#endif
std::deque<NodeInfo> nodes_to_treat ; // list of nodes to be treated. Used as a queue. The int is the level of friendness std::deque<NodeInfo> nodes_to_treat ; // list of nodes to be treated. Used as a queue. The int is the level of friendness
std::set<std::string> nodes_considered ; // list of nodes already considered. Eases lookup. std::set<RsPgpId> nodes_considered ; // list of nodes already considered. Eases lookup.
nodes_to_treat.push_front(NodeInfo(ownGPGId,0)) ; // initialize queue with own id. 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. // Put own id in queue, and empty the queue, treating all nodes.
// //
@ -163,7 +163,7 @@ void NetworkView::updateDisplay()
} }
RsPeerDetails detail ; RsPeerDetails detail ;
if(!rsPeers->getPeerDetails(info.gpg_id, detail)) if(!rsPeers->getGPGDetails(info.gpg_id, detail))
continue ; continue ;
switch(detail.trustLvl) 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()) 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 #ifdef DEBUG_NETWORKVIEW
std::cerr << " inserted node " << info.gpg_id << ", type=" << type << ", auth=" << auth << std::endl ; std::cerr << " inserted node " << info.gpg_id << ", type=" << type << ", auth=" << auth << std::endl ;
#endif #endif
} }
std::list<std::string> friendList; std::list<RsPgpId> friendList;
rsDisc->getDiscPgpFriends(info.gpg_id, friendList); rsDisc->getDiscPgpFriends(info.gpg_id, friendList);
#ifdef DEBUG_NETWORKVIEW #ifdef DEBUG_NETWORKVIEW
@ -193,8 +193,8 @@ void NetworkView::updateDisplay()
#endif #endif
if(info.friend_level+1 <= _max_friend_level) if(info.friend_level+1 <= _max_friend_level)
for(std::list<std::string>::const_iterator sit(friendList.begin()); sit != friendList.end(); ++sit) for(std::list<RsPgpId>::const_iterator sit(friendList.begin()); sit != friendList.end(); ++sit)
if(nodes_considered.find(*sit) == nodes_considered.end()) if(nodes_considered.find(*sit) == nodes_considered.end())
{ {
#ifdef DEBUG_NETWORKVIEW #ifdef DEBUG_NETWORKVIEW
std::cerr << " adding to queue: " << *sit << ", with level " << info.friend_level+1 << std::endl ; 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; std::cerr << "NetworkView::insertSignatures()" << std::endl;
#endif #endif
for(std::map<std::string,GraphWidget::NodeId>::const_iterator it(_node_ids.begin()); it != _node_ids.end(); it++) for(std::map<RsPgpId,GraphWidget::NodeId>::const_iterator it(_node_ids.begin()); it != _node_ids.end(); it++)
{ {
std::list<std::string> friendList ; std::list<RsPgpId> friendList ;
if(rsDisc->getDiscPgpFriends(it->first,friendList)) if(rsDisc->getDiscPgpFriends(it->first,friendList))
for(std::list<std::string>::const_iterator sit(friendList.begin()); sit != friendList.end(); sit++) for(std::list<RsPgpId>::const_iterator sit(friendList.begin()); sit != friendList.end(); sit++)
{ {
#ifdef DEBUG_NETWORKVIEW #ifdef DEBUG_NETWORKVIEW
std::cerr << "NetworkView: Adding Edge: "; std::cerr << "NetworkView: Adding Edge: ";

View file

@ -24,6 +24,8 @@
#include <QGraphicsScene> #include <QGraphicsScene>
#include <retroshare/rstypes.h>
#include "RsAutoUpdatePage.h" #include "RsAutoUpdatePage.h"
#include "ui_NetworkView.h" #include "ui_NetworkView.h"
@ -60,7 +62,7 @@ class NetworkView : public RsAutoUpdatePage
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::NetworkView ui; Ui::NetworkView ui;
uint _max_friend_level ; uint _max_friend_level ;
std::map<std::string,GraphWidget::NodeId> _node_ids ; std::map<RsPgpId,GraphWidget::NodeId> _node_ids ;
bool _should_update ; bool _should_update ;
}; };

View file

@ -960,7 +960,7 @@ void RetroshareDirModel::downloadSelected(const QModelIndexList &list)
{ {
std::cerr << "RetroshareDirModel::downloadSelected() Calling File Request"; std::cerr << "RetroshareDirModel::downloadSelected() Calling File Request";
std::cerr << std::endl; std::cerr << std::endl;
std::list<std::string> srcIds; std::list<RsPeerId> srcIds;
srcIds.push_back(details.id); srcIds.push_back(details.id);
rsFiles -> FileRequest(details.name, details.hash, rsFiles -> FileRequest(details.name, details.hash,
details.count, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds); 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) if (dirDetails.type & DIR_TYPE_FILE)
{ {
std::list<std::string> srcIds; std::list<RsPeerId> srcIds;
QString cleanPath = QDir::cleanPath(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()) + "/" + QString::fromUtf8(dirDetails.path.substr(prefixLen).c_str())); QString cleanPath = QDir::cleanPath(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()) + "/" + QString::fromUtf8(dirDetails.path.substr(prefixLen).c_str()));
srcIds.push_back(dirDetails.id); srcIds.push_back(dirDetails.id);

View file

@ -376,17 +376,17 @@ bool RetroShareLink::createPublicMsgInvite(time_t time_stamp,const QString& issu
return valid() ; return valid() ;
} }
bool RetroShareLink::createPerson(const std::string& id) bool RetroShareLink::createPerson(const RsPgpId& id)
{ {
clear(); clear();
RsPeerDetails detail; 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; std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << id << std::endl;
return false; return false;
} }
_hash = QString::fromStdString(id); _hash = QString::fromStdString(id.toStdString());
_name = QString::fromUtf8(detail.name.c_str()); _name = QString::fromUtf8(detail.name.c_str());
_type = TYPE_PERSON; _type = TYPE_PERSON;
@ -396,14 +396,14 @@ bool RetroShareLink::createPerson(const std::string& id)
return valid(); return valid();
} }
bool RetroShareLink::createCertificate(const std::string& ssl_or_gpg_id) bool RetroShareLink::createCertificate(const RsPeerId& ssl_id)
{ {
// This is baaaaaad code: // This is baaaaaad code:
// - we should not need to parse and re-read a cert in old format. // - we should not need to parse and re-read a cert in old format.
// //
RsPeerDetails detail; RsPeerDetails detail;
if (rsPeers->getPeerDetails(ssl_or_gpg_id, detail) == false) { if (rsPeers->getPeerDetails(ssl_id, detail) == false) {
std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_or_gpg_id << std::endl; std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_id << std::endl;
return false; return false;
} }
@ -418,23 +418,23 @@ bool RetroShareLink::createCertificate(const std::string& ssl_or_gpg_id)
_type = TYPE_CERTIFICATE; _type = TYPE_CERTIFICATE;
_GPGid = QString::fromStdString(detail.gpg_id).right(8); _GPGid = QString::fromStdString(detail.gpg_id.toStdString()).right(8);
if(detail.isOnlyGPGdetail) // if(detail.isOnlyGPGdetail)
{ // {
_SSLid.clear(); // _SSLid.clear();
_location.clear(); // _location.clear();
_ext_ip_port.clear(); // _ext_ip_port.clear();
_loc_ip_port.clear(); // _loc_ip_port.clear();
} // }
else // else
{ // {
_SSLid = QString::fromStdString(ssl_or_gpg_id) ; _SSLid = QString::fromStdString(ssl_id.toStdString()) ;
_location = QString::fromUtf8(detail.location.c_str()) ; _location = QString::fromUtf8(detail.location.c_str()) ;
_ext_ip_port = QString::fromStdString(detail.extAddr) + ":" + QString::number(detail.extPort) + ";" ; _ext_ip_port = QString::fromStdString(detail.extAddr) + ":" + QString::number(detail.extPort) + ";" ;
_loc_ip_port = QString::fromStdString(detail.localAddr) + ":" + QString::number(detail.localPort) + ";" ; _loc_ip_port = QString::fromStdString(detail.localAddr) + ":" + QString::number(detail.localPort) + ";" ;
_dyndns_name = QString::fromStdString(detail.dyndns); _dyndns_name = QString::fromStdString(detail.dyndns);
} //}
_name = QString::fromUtf8(detail.name.c_str()) ; _name = QString::fromUtf8(detail.name.c_str()) ;
std::cerr << "Found gpg base 64 string = " << _GPGBase64String.toStdString() << std::endl; 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; 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 // first try ssl id
if (createCertificate(sslId)) { if (createCertificate(sslId)) {
if (gpgId.empty() || _GPGid.toStdString() == gpgId) { if (gpgId.isNull() || _GPGid.toStdString() == gpgId.toStdString()) {
return true; return true;
} }
// wrong gpg id // wrong gpg id
@ -461,14 +461,14 @@ bool RetroShareLink::createUnknwonSslCertificate(const std::string& sslId, const
} }
// then gpg id // then gpg id
if (createCertificate(gpgId)) { if (createCertificate(sslId)) {
if (!_SSLid.isEmpty()) { if (!_SSLid.isEmpty()) {
return false; return false;
} }
if (sslId.empty()) { if (sslId.isNull()) {
return true; return true;
} }
_SSLid = QString::fromStdString(sslId); _SSLid = QString::fromStdString(sslId.toStdString());
if (_location.isEmpty()) { if (_location.isEmpty()) {
_location = _name; _location = _name;
} }
@ -680,15 +680,15 @@ QString RetroShareLink::title() const
case TYPE_PUBLIC_MSG: case TYPE_PUBLIC_MSG:
{ {
RsPeerDetails detail; 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) ; return QString("Click to send a private message to %1 (%2).").arg(QString::fromStdString(detail.name)).arg(_GPGid) ;
} }
case TYPE_PRIVATE_CHAT: case TYPE_PRIVATE_CHAT:
{ {
RsPeerDetails detail; 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) ; return QString("Click to open a private chat canal to %1 (%2).").arg(QString::fromStdString(detail.name)).arg(_GPGid) ;
else else
return QString("This is a private chat invite for %1 (%2). You can't use it.").arg(QString::fromStdString(detail.name)).arg(_GPGid) ; 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 QString RetroShareLink::niceName() const
{ {
if (type() == TYPE_PERSON) { 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) { if(type() == TYPE_PRIVATE_CHAT) {
@ -883,7 +883,7 @@ QString RetroShareLink::niceName() const
} }
if(type() == TYPE_PUBLIC_MSG) { if(type() == TYPE_PUBLIC_MSG) {
RsPeerDetails detail; 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) ; return QString("Click this link to send a private message to %1 (%2)").arg(QString::fromStdString(detail.name)).arg(_GPGid) ;
} }
if(type() == TYPE_CERTIFICATE) { if(type() == TYPE_CERTIFICATE) {
@ -1095,7 +1095,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
break; break;
case TYPE_PERSON: 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; 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.")) ; QMessageBox::information(NULL,QObject::tr("Chat link is expired"),QObject::tr("This chat link is expired. The destination peer will not answer.")) ;
break ; 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) ; 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 ; break ;
@ -1296,7 +1296,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
#endif #endif
needNotifySuccess = true; needNotifySuccess = true;
std::list<std::string> srcIds; std::list<RsPeerId> srcIds;
// Add the link built-in source. This is needed for EXTRA files, where the source is specified in the link. // 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 #ifdef DEBUG_RSLINK
std::cerr << " RetroShareLink::process Adding built-in source " << link.SSLId().toStdString() << std::endl; std::cerr << " RetroShareLink::process Adding built-in source " << link.SSLId().toStdString() << std::endl;
#endif #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. // 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 #ifdef DEBUG_RSLINK
std::cerr << " adding peerid " << (*it).peerId << std::endl ; std::cerr << " adding peerid " << (*it).peerId << std::endl ;
#endif #endif
srcIds.push_back((*it).peerId) ; srcIds.push_back((*it).peerId) ;
} }
QString cleanname = link.name() ; QString cleanname = link.name() ;
@ -1337,7 +1337,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
} else { } else {
fileExist.append(link.name()); fileExist.append(link.name());
} }
break; break;
} }
case TYPE_PERSON: case TYPE_PERSON:
@ -1349,29 +1349,30 @@ static void processList(const QStringList &list, const QString &textSingular, co
needNotifySuccess = true; needNotifySuccess = true;
RsPeerDetails detail; RsPeerDetails detail;
if (rsPeers->getPeerDetails(link.hash().toStdString(), detail)) { if (rsPeers->getPeerDetails(RsPeerId(link.hash().toStdString()), detail))
if (detail.gpg_id == rsPeers->getGPGOwnId()) { {
// it's me, do nothing if (RsPgpId(detail.gpg_id) == rsPeers->getGPGOwnId()) {
break; // it's me, do nothing
} break;
}
if (detail.accept_connection) { if (detail.accept_connection) {
// peer connection is already accepted // peer connection is already accepted
personExist.append(PeerDefs::rsid(detail)); personExist.append(PeerDefs::rsid(detail));
break; break;
} }
if (rsPeers->addFriend("", link.hash().toStdString())) { if (rsPeers->addFriend(RsPeerId(), RsPgpId(link.hash().toStdString()))) {
ConfCertDialog::loadAll(); ConfCertDialog::loadAll();
personAdded.append(PeerDefs::rsid(detail)); personAdded.append(PeerDefs::rsid(detail));
break; break;
} }
personFailed.append(PeerDefs::rsid(link.name().toUtf8().constData(), link.hash().toStdString())); personFailed.append(PeerDefs::rsid(link.name().toUtf8().constData(), RsPgpId(link.hash().toStdString())));
break; 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; 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; std::cerr << " RetroShareLink::process MessageRequest : id : " << link.hash().toStdString() << ", subject : " << link.name().toStdString() << std::endl;
#endif #endif
RsPeerDetails detail; 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(); MessageComposer *msg = MessageComposer::newMsg();
msg->addRecipient(MessageComposer::TO, detail.id, false); msg->addRecipient(MessageComposer::TO, detail.id, false);
if (link.subject().isEmpty() == false) { if (link.subject().isEmpty() == false) {

View file

@ -33,6 +33,9 @@
// -------------+----------------+--------------------------+------------------+-------------+------------- // -------------+----------------+--------------------------+------------------+-------------+-------------
// //
#include <stdint.h> #include <stdint.h>
#include <retroshare/rstypes.h>
#include <QString> #include <QString>
#include <QVector> #include <QVector>
#include <QUrl> #include <QUrl>
@ -72,15 +75,15 @@ class RetroShareLink
bool createFile(const QString& name, uint64_t size, const QString& hash); 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 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 createForum(const std::string& id, const std::string& msgId);
bool createChannel(const std::string& id, const std::string& msgId); bool createChannel(const std::string& id, const std::string& msgId);
bool createSearch(const QString& keywords); bool createSearch(const QString& keywords);
bool createMessage(const std::string& peerId, const QString& subject); 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 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 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; } enumType type() const {return _type; }
uint64_t size() const { return _size ; } uint64_t size() const { return _size ; }

View file

@ -325,7 +325,7 @@ void SearchDialog::searchtableWidgetCostumPopupMenu( QPoint /*point*/ )
contextMnu.exec(QCursor::pos()); contextMnu.exec(QCursor::pos());
} }
void SearchDialog::getSourceFriendsForHash(const std::string& hash,std::list<std::string>& srcIds) void SearchDialog::getSourceFriendsForHash(const std::string& hash,std::list<RsPeerId>& srcIds)
{ {
std::cerr << "Searching sources for file " << hash << std::endl ; std::cerr << "Searching sources for file " << hash << std::endl ;
srcIds.clear(); srcIds.clear();
@ -359,7 +359,7 @@ void SearchDialog::download()
{ {
std::cerr << "SearchDialog::download() Calling File Request"; std::cerr << "SearchDialog::download() Calling File Request";
std::cerr << std::endl; std::cerr << std::endl;
std::list<std::string> srcIds; std::list<RsPeerId> srcIds;
std::string hash = item->text(SR_HASH_COL).toStdString(); std::string hash = item->text(SR_HASH_COL).toStdString();
getSourceFriendsForHash(hash,srcIds) ; getSourceFriendsForHash(hash,srcIds) ;
@ -369,7 +369,7 @@ void SearchDialog::download()
else else
{ {
std::cout << "isuing file request from search dialog: -" << (item->text(SR_NAME_COL)).toStdString() << "-" << hash << "-" << (item->text(SR_SIZE_COL)).toULongLong() << "-ids=" ; 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<std::string>::const_iterator it(srcIds.begin());it!=srcIds.end();++it) for(std::list<RsPeerId>::const_iterator it(srcIds.begin());it!=srcIds.end();++it)
std::cout << *it << "-" << std::endl ; std::cout << *it << "-" << std::endl ;
} }
} }
@ -382,7 +382,7 @@ void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString
{ {
if (!item->childCount()) if (!item->childCount())
{ {
std::list<std::string> srcIds; std::list<RsPeerId> srcIds;
QString path = QString::fromStdString(rsFiles->getDownloadDirectory()) QString path = QString::fromStdString(rsFiles->getDownloadDirectory())
+ "/" + base + "/"; + "/" + base + "/";
@ -403,7 +403,7 @@ void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString
<< "-" << hash << "-" << hash
<< "-" << (item->text(SR_SIZE_COL)).toULongLong() << "-" << (item->text(SR_SIZE_COL)).toULongLong()
<< "-ids=" ; << "-ids=" ;
for(std::list<std::string>::const_iterator it(srcIds.begin()); for(std::list<RsPeerId>::const_iterator it(srcIds.begin());
it!=srcIds.end();++it) it!=srcIds.end();++it)
std::cout << *it << "-" << std::endl ; std::cout << *it << "-" << std::endl ;
} else { } else {

View file

@ -114,7 +114,7 @@ private:
void insertDirectory(const QString &txt, qulonglong searchId, const DirDetails &dir); void insertDirectory(const QString &txt, qulonglong searchId, const DirDetails &dir);
void setIconAndType(QTreeWidgetItem *item, const QString& filename); void setIconAndType(QTreeWidgetItem *item, const QString& filename);
void downloadDirectory(const QTreeWidgetItem *item, const QString &base); void downloadDirectory(const QTreeWidgetItem *item, const QString &base);
void getSourceFriendsForHash(const std::string& hash,std::list<std::string>& srcIds); void getSourceFriendsForHash(const std::string& hash,std::list<RsPeerId> &srcIds);
/** the advanced search dialog instance */ /** the advanced search dialog instance */
AdvancedSearchDialog * advSearchDialog; AdvancedSearchDialog * advSearchDialog;

View file

@ -88,7 +88,7 @@ void ServicePermissionDialog::itemAdded(int idType, const QString &id, QTreeWidg
} }
RsPeerDetails detail; RsPeerDetails detail;
if (!rsPeers->getPeerDetails(id.toStdString(), detail)) { if (!rsPeers->getGPGDetails(RsPgpId(id.toStdString()), detail)) {
return; 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); done(Accepted);

View file

@ -57,7 +57,7 @@ StartDialog::StartDialog(QWidget *parent)
for(it = accountIds.begin(), i = 0; it != accountIds.end(); it++, i++) for(it = accountIds.begin(), i = 0; it != accountIds.end(); it++, i++)
{ {
const QVariant & userData = QVariant(QString::fromStdString((*it).toStdString())); const QVariant & userData = QVariant(QString::fromStdString((*it).toStdString()));
PGPIdType gpgid ; RsPgpId gpgid ;
std::string name, email, location; std::string name, email, location;
RsAccounts::GetAccountDetails(*it, gpgid, 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()); QString accountName = QString::fromUtf8(name.c_str()) + " (" + QString::fromStdString(gpgid.toStdString()).right(8) + ") - " + QString::fromUtf8(location.c_str());

View file

@ -4,25 +4,58 @@
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include "FriendSelectionDialog.h" #include "FriendSelectionDialog.h"
std::list<std::string> FriendSelectionDialog::selectFriends(QWidget *parent,const QString& caption,const QString& header_text, std::list<RsPgpId> FriendSelectionDialog::selectFriends(QWidget *parent,const QString& caption,const QString& header_text,
FriendSelectionWidget::Modus modus, FriendSelectionWidget::Modus modus,
FriendSelectionWidget::ShowTypes show_type, FriendSelectionWidget::ShowTypes show_type,
FriendSelectionWidget::IdType pre_selected_id_type, const std::list<RsPgpId>& pre_selected_ids)
const std::list<std::string>& 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) ; dialog.setWindowTitle(caption) ;
if(QDialog::Rejected == dialog.exec()) if(QDialog::Rejected == dialog.exec())
return std::list<std::string>() ; return std::list<std::string>() ;
std::list<std::string> ids ; std::list<std::string> sids ;
dialog.friends_widget->selectedIds(pre_selected_id_type,ids,false) ; dialog.friends_widget->selectedIds(pre_selected_id_type,ids,false) ;
return ids ; std::list<RsPgpId> ids ;
for(std::list<std::string>::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<RsPeerId> FriendSelectionDialog::selectFriends(QWidget *parent,const QString& caption,const QString& header_text,
FriendSelectionWidget::Modus modus,
FriendSelectionWidget::ShowTypes show_type,
const std::list<RsPeerId>& 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::string>() ;
std::list<std::string> sids ;
dialog.friends_widget->selectedIds(pre_selected_id_type,ids,false) ;
std::list<RsPeerId> ids ;
for(std::list<std::string>::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, FriendSelectionDialog::FriendSelectionDialog(QWidget *parent,const QString& header_text,
FriendSelectionWidget::Modus modus, FriendSelectionWidget::Modus modus,
FriendSelectionWidget::ShowTypes show_type, FriendSelectionWidget::ShowTypes show_type,

View file

@ -6,12 +6,16 @@
class FriendSelectionDialog : public QDialog class FriendSelectionDialog : public QDialog
{ {
public: public:
static std::list<std::string> selectFriends(QWidget *parent,const QString& caption,const QString& header_string, static std::list<RsPgpId> selectFriends_PGP(QWidget *parent,const QString& caption,const QString& header_string,
FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI, FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI,
FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL, FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL,
FriendSelectionWidget::IdType pre_selected_id_type = FriendSelectionWidget::IDTYPE_SSL, const std::list<RsPgpId>& pre_selected_ids = std::list<RsPgpId>()) ;
const std::list<std::string>& pre_selected_ids = std::list<std::string>()) ;
private: static std::list<RsPeerId> 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<RsPeerId>& pre_selected_ids = std::list<RsPeerId>()) ;
private:
virtual ~FriendSelectionDialog() ; virtual ~FriendSelectionDialog() ;
FriendSelectionDialog(QWidget *parent,const QString& header_string,FriendSelectionWidget::Modus modus,FriendSelectionWidget::ShowTypes show_type, FriendSelectionDialog(QWidget *parent,const QString& header_string,FriendSelectionWidget::Modus modus,FriendSelectionWidget::ShowTypes show_type,
FriendSelectionWidget::IdType pre_selected_id_type, FriendSelectionWidget::IdType pre_selected_id_type,

View file

@ -34,14 +34,21 @@ const QString PeerDefs::nameWithLocation(const RsPeerDetails &details)
return name; return name;
} }
const QString PeerDefs::rsid(const std::string &name, const RsPgpId &id)
const QString PeerDefs::rsid(const std::string &name, const std::string &id)
{ {
if (name.empty()) { 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) const QString PeerDefs::rsid(const RsPeerDetails &details)

View file

@ -33,7 +33,8 @@ public:
static const QString nameWithLocation(const RsPeerDetails &details); static const QString nameWithLocation(const RsPeerDetails &details);
static const QString rsid(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 QString rsidFromId(const std::string &id, QString *name = NULL);
static const std::string idFromRsid(const QString &rsid, bool check); static const std::string idFromRsid(const QString &rsid, bool check);
}; };

View file

@ -110,7 +110,7 @@ public:
private: private:
ImHistoryBrowser *m_historyBrowser; ImHistoryBrowser *m_historyBrowser;
std::string m_peerId; RsPeerId m_peerId;
volatile bool stopped; volatile bool stopped;
}; };

View file

@ -1575,7 +1575,7 @@ void MessageComposer::editingRecipientFinished()
lineEdit->setText(text); 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 ; _distant_peers[hash] = pgp_id ;
@ -1601,9 +1601,9 @@ void MessageComposer::addRecipient(enumType type, const std::string& hash,const
setRecipientToRow(row, type, hash, false); 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<std::string> sslIds; std::list<RsPeerId> sslIds;
if (group) { if (group) {
sslIds.push_back(id); sslIds.push_back(id);
} else { } else {
@ -1613,23 +1613,23 @@ void MessageComposer::addRecipient(enumType type, const std::string &id, bool gr
return; return;
} }
if (detail.isOnlyGPGdetail) // if (detail.isOnlyGPGdetail)
{ // {
if( (!rsPeers->getAssociatedSSLIds(id, sslIds)) || sslIds.empty()) // if( (!rsPeers->getAssociatedSSLIds(id, sslIds)) || sslIds.empty())
{ // {
std::string hash ; // std::string hash ;
if(rsMsgs->getDistantMessageHash(id,hash)) // if(rsMsgs->getDistantMessageHash(id,hash))
addRecipient(type, hash, id); // addRecipient(type, hash, id);
else // 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) ; // 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; // return;
} // }
} // }
} // }
else { // else {
sslIds.push_back(id); sslIds.push_back(id);
} // }
} }
std::list<std::string>::const_iterator sslIt; std::list<std::string>::const_iterator sslIt;
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) { for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {

View file

@ -67,8 +67,8 @@ public:
void setTitleText(const QString &title, enumMessageType type = NORMAL); void setTitleText(const QString &title, enumMessageType type = NORMAL);
void setQuotedMsg(const QString &msg, const QString &header); void setQuotedMsg(const QString &msg, const QString &header);
void setMsgText(const QString &msg, bool asHtml = false); void setMsgText(const QString &msg, bool asHtml = false);
void addRecipient(enumType type, const std::string &id, bool group); void addRecipient(enumType type, const RsPeerId &id, bool group);
void addRecipient(enumType type, const std::string &hash, const std::string& pgp_id) ; void addRecipient(enumType type, const Sha1CheckSum &hash, const RsPgpId &pgp_id) ;
public slots: public slots:
/* actions to take.... */ /* actions to take.... */
@ -220,7 +220,7 @@ private:
Ui::MessageComposer ui; Ui::MessageComposer ui;
std::list<FileInfo> _recList ; std::list<FileInfo> _recList ;
std::map<std::string,std::string> _distant_peers ; // pairs (hash,pgp_id) std::map<RsFileHash,RsPgpId> _distant_peers ; // pairs (hash,pgp_id)
}; };
#endif #endif

View file

@ -311,7 +311,6 @@ HEADERS += rshare.h \
gui/AboutDialog.h \ gui/AboutDialog.h \
gui/CreateMsgLinkDialog.h \ gui/CreateMsgLinkDialog.h \
gui/NetworkView.h \ gui/NetworkView.h \
gui/TrustView.h \
gui/MessengerWindow.h \ gui/MessengerWindow.h \
gui/FriendsDialog.h \ gui/FriendsDialog.h \
gui/ServicePermissionDialog.h \ gui/ServicePermissionDialog.h \
@ -524,7 +523,6 @@ FORMS += gui/StartDialog.ui \
gui/MainWindow.ui \ gui/MainWindow.ui \
gui/CreateMsgLinkDialog.ui \ gui/CreateMsgLinkDialog.ui \
gui/NetworkView.ui \ gui/NetworkView.ui \
gui/TrustView.ui \
gui/MessengerWindow.ui \ gui/MessengerWindow.ui \
gui/FriendsDialog.ui \ gui/FriendsDialog.ui \
gui/SearchDialog.ui \ gui/SearchDialog.ui \
@ -630,7 +628,6 @@ SOURCES += main.cpp \
gui/MainWindow.cpp \ gui/MainWindow.cpp \
gui/CreateMsgLinkDialog.cpp \ gui/CreateMsgLinkDialog.cpp \
gui/NetworkView.cpp \ gui/NetworkView.cpp \
gui/TrustView.cpp \
gui/MessengerWindow.cpp \ gui/MessengerWindow.cpp \
gui/FriendsDialog.cpp \ gui/FriendsDialog.cpp \
gui/ServicePermissionDialog.cpp \ gui/ServicePermissionDialog.cpp \