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,
const std::string& authorId, const std::string& peerId)
const std::string& authorId, const RsPeerId& peerId)
{
if(mRep->haveReputation(authorId))
{
return mRep->getReputation(authorId, rep);
}
std::list<std::string> peers;
std::list<RsPeerId> peers;
peers.push_back(peerId);
mRep->loadReputation(authorId, peers);
return false;
@ -70,12 +70,12 @@ GrpAuthEntry::GrpAuthEntry()
MsgRespPending::MsgRespPending(RsGixsReputation* rep, const std::string& peerId, const MsgAuthorV& msgAuthV, int cutOff)
MsgRespPending::MsgRespPending(RsGixsReputation* rep, const RsPeerId& peerId, const MsgAuthorV& msgAuthV, int cutOff)
: AuthorPending(rep, time(NULL)), mPeerId(peerId), mMsgAuthV(msgAuthV), mCutOff(cutOff)
{
}
GrpRespPending::GrpRespPending(RsGixsReputation* rep, const std::string& peerId, const GrpAuthorV& grpAuthV, int cutOff)
GrpRespPending::GrpRespPending(RsGixsReputation* rep, const RsPeerId& peerId, const GrpAuthorV& grpAuthV, int cutOff)
: AuthorPending(rep, time(NULL)), mPeerId(peerId), mGrpAuthV(grpAuthV), mCutOff(cutOff)
{
}

View file

@ -39,11 +39,16 @@
#define USE_NEW_CHUNK_CHECKING_CODE
// This adds a level of indirection to types, so we can easily change them if needed
//
typedef std::string RsCertId;
typedef std::string RsChanId;
typedef std::string RsMsgId;
typedef std::string RsAuthId;
typedef SSLIdType RsPeerId ;
typedef PGPIdType RsPgpId ;
typedef Sha1CheckSum RsFileHash ;
const uint32_t FT_STATE_FAILED = 0x0000 ;
const uint32_t FT_STATE_OKAY = 0x0001 ;

View file

@ -82,7 +82,8 @@ void CreateMsgLinkDialog::createLink()
time_t validity_duration = computeValidityDuration() ;
FriendSelectionWidget::IdType type ;
std::string current_pgp_id = friendSelectionWidget->selectedId(type) ;
std::string scurrent_pgp_id = friendSelectionWidget->selectedId(type) ;
RsPgpId current_pgp_id(scurrent_pgp_id) ;
std::string encrypted_string ;
@ -90,7 +91,7 @@ void CreateMsgLinkDialog::createLink()
RetroShareLink link ;
if(!link.createPrivateChatInvite(validity_duration + time(NULL),QString::fromStdString(current_pgp_id),QString::fromStdString(encrypted_string)) )
if(!link.createPrivateChatInvite(validity_duration + time(NULL),QString::fromStdString(scurrent_pgp_id),QString::fromStdString(encrypted_string)) )
std::cerr << "Cannot create link." << std::endl;
QList<RetroShareLink> links ;

View file

@ -146,7 +146,7 @@ FriendsDialog::FriendsDialog(QWidget *parent)
int messageCount = Settings->getPublicChatHistoryCount();
if (messageCount > 0) {
std::list<HistoryMsg> historyMsgs;
rsHistory->getMessages("", historyMsgs, messageCount);
rsHistory->getMessages(RsPeerId(), historyMsgs, messageCount);
std::list<HistoryMsg>::iterator it;
for (it = historyMsgs.begin(); it != historyMsgs.end(); it++) {
@ -394,7 +394,7 @@ void FriendsDialog::updateStatusString(const QString& peer_id, const QString& st
std::cerr << "FriendsDialog: received group chat typing info. updating gui." << std::endl ;
#endif
QString status = QString::fromUtf8(rsPeers->getPeerName(peer_id.toStdString()).c_str()) + " " + tr(status_string.toLatin1());
QString status = QString::fromUtf8(rsPeers->getPeerName(RsPeerId(peer_id.toStdString())).c_str()) + " " + tr(status_string.toLatin1());
ui.statusStringLabel->setText(status) ; // displays info for 5 secs.
QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ;
@ -750,7 +750,7 @@ void FriendsDialog::on_actionDelete_Chat_History_triggered()
{
if ((QMessageBox::question(this, "RetroShare", tr("Do you really want to physically delete the history?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes) {
on_actionClear_Chat_History_triggered();
rsHistory->clear("");
rsHistory->clear(RsPeerId());
}
}
@ -821,7 +821,7 @@ void FriendsDialog::fileHashingFinished(QList<HashedFile> hashedFiles)
HashedFile& hashedFile = *it;
RetroShareLink link;
if (!link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash),QString::fromStdString(rsPeers->getOwnId())))
if (!link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash),QString::fromStdString(rsPeers->getOwnId().toStdString())))
continue;
mesgString += link.toHtmlSize();

View file

@ -178,8 +178,8 @@ void GenCertDialog::init()
ui.genPGPuser->clear() ;
std::list<PGPIdType> pgpIds;
std::list<PGPIdType>::iterator it;
std::list<RsPgpId> pgpIds;
std::list<RsPgpId>::iterator it;
bool foundGPGKeys = false;
if (!mOnlyGenerateIdentity) {
if (RsAccounts::GetPGPLogins(pgpIds)) {
@ -310,7 +310,7 @@ void GenCertDialog::exportIdentity()
return ;
QVariant data = ui.genPGPuser->itemData(ui.genPGPuser->currentIndex());
PGPIdType gpg_id (data.toString().toStdString()) ;
RsPgpId gpg_id (data.toString().toStdString()) ;
if(RsAccounts::ExportIdentity(fname.toStdString(),gpg_id))
QMessageBox::information(this,tr("Identity saved"),tr("Your identity was successfully saved\nIt is encrypted\n\nYou can now copy it to another computer\nand use the import button to load it")) ;
@ -325,7 +325,7 @@ void GenCertDialog::importIdentity()
if(fname.isNull())
return ;
PGPIdType gpg_id ;
RsPgpId gpg_id ;
std::string err_string ;
if(!RsAccounts::ImportIdentity(fname.toStdString(),gpg_id,err_string))
@ -350,7 +350,7 @@ void GenCertDialog::genPerson()
{
/* Check the data from the GUI. */
std::string genLoc = ui.location_input->text().toUtf8().constData();
PGPIdType PGPId;
RsPgpId PGPId;
bool isHiddenLoc = false;
if (ui.hidden_checkbox->isChecked())
@ -389,7 +389,7 @@ void GenCertDialog::genPerson()
return;
}
QVariant data = ui.genPGPuser->itemData(pgpidx);
PGPId = PGPIdType((data.toString()).toStdString());
PGPId = RsPgpId((data.toString()).toStdString());
} else {
if (ui.password_input->text().length() < 3 || ui.name_input->text().length() < 3 || genLoc.length() < 3) {
/* Message Dialog */

View file

@ -127,11 +127,11 @@ void IdEditDialog::updateIdType(bool pseudo)
else
{
/* get GPG Details from rsPeers */
std::string gpgid = rsPeers->getGPGOwnId();
RsPgpId gpgid = rsPeers->getGPGOwnId();
RsPeerDetails details;
rsPeers->getPeerDetails(gpgid, details);
rsPeers->getGPGDetails(gpgid, details);
ui.lineEdit_GpgId->setText(QString::fromStdString(gpgid));
ui.lineEdit_GpgId->setText(QString::fromStdString(gpgid.toStdString()));
ui.lineEdit_GpgHash->setText(tr("To be generated"));
ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
}

View file

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

View file

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

View file

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

View file

@ -203,7 +203,7 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
QMenu *contextMnu = new QMenu;
PGPIdType peer_id(wi->text(COLUMN_PEERID).toStdString()) ;
RsPgpId peer_id(wi->text(COLUMN_PEERID).toStdString()) ;
// That's what context menus are made for
RsPeerDetails detail;
@ -231,15 +231,15 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
void NetworkDialog::removeUnusedKeys()
{
std::list<PGPIdType> pre_selected ;
std::list<PGPIdType> ids ;
std::list<RsPgpId> pre_selected ;
std::list<RsPgpId> ids ;
rsPeers->getGPGAllList(ids) ;
RsPeerDetails details ;
time_t now = time(NULL) ;
time_t THREE_MONTHS = 3*31*24*60*60 ;//3*DayPerMonth*HoursPerDay*MinPerHour*SecPerMin
for(std::list<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) ;
@ -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("The selected keys below haven't been used in the last 3 months. \nDo you want to delete them permanently ? \n\nNotes: Your old keyring will be backed up.\n The removal may fail when running multiple Retroshare instances on the same machine."),FriendSelectionWidget::MODUS_CHECK,FriendSelectionWidget::SHOW_GPG | FriendSelectionWidget::SHOW_NON_FRIEND_GPG,
FriendSelectionWidget::IDTYPE_GPG, pre_selected) ;
pre_selected) ;
std::cerr << "Removing these keys from the keyring: " << std::endl;
for(std::list<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::string backup_file ;
@ -298,7 +298,7 @@ void NetworkDialog::removeUnusedKeys()
void NetworkDialog::denyFriend()
{
QTreeWidgetItem *wi = getCurrentNeighbour();
PGPIdType peer_id( wi->text(COLUMN_PEERID).toStdString() );
RsPgpId peer_id( wi->text(COLUMN_PEERID).toStdString() );
rsPeers->removeFriend(peer_id) ;
securedUpdateDisplay();
@ -341,7 +341,7 @@ void NetworkDialog::copyLink()
return;
}
std::string peer_id = wi->text(COLUMN_PEERID).toStdString() ;
RsPgpId peer_id ( wi->text(COLUMN_PEERID).toStdString() ) ;
QList<RetroShareLink> urls;
RetroShareLink link;
@ -365,11 +365,11 @@ void NetworkDialog::sendDistantMessage()
}
Sha1CheckSum hash ;
PGPIdType mGpgId(wi->text(COLUMN_PEERID).toStdString()) ;
RsPgpId mGpgId(wi->text(COLUMN_PEERID).toStdString()) ;
if(rsMsgs->getDistantMessageHash(mGpgId,hash))
{
nMsgDialog->addRecipient(MessageComposer::TO, hash.toStdString(), mGpgId.toStdString());
nMsgDialog->addRecipient(MessageComposer::TO, hash, mGpgId);
nMsgDialog->show();
nMsgDialog->activateWindow();
}
@ -397,8 +397,8 @@ void NetworkDialog::insertConnect()
//
// last_time = now ;
std::list<PGPIdType> neighs; //these are GPG ids
std::list<PGPIdType>::iterator it;
std::list<RsPgpId> neighs; //these are GPG ids
std::list<RsPgpId>::iterator it;
rsPeers->getGPGAllList(neighs);
/* get a link to the table */
@ -408,7 +408,7 @@ void NetworkDialog::insertConnect()
int index = 0;
while (index < connectWidget->topLevelItemCount())
{
PGPIdType gpg_widget_id( (connectWidget->topLevelItem(index))->text(COLUMN_PEERID).toStdString() );
RsPgpId gpg_widget_id( (connectWidget->topLevelItem(index))->text(COLUMN_PEERID).toStdString() );
RsPeerDetails detail;
if ( (!rsPeers->getGPGDetails(gpg_widget_id, detail)) || (ui.onlyTrustedKeys->isChecked() && (detail.validLvl < RS_TRUST_LVL_MARGINAL && !detail.accept_connection)))
delete (connectWidget->takeTopLevelItem(index));

View file

@ -109,9 +109,9 @@ void NetworkView::setFreezeState(bool freeze)
class NodeInfo
{
public:
NodeInfo(const std::string& _gpg_id,uint32_t lev) : gpg_id(_gpg_id),friend_level(lev) {}
NodeInfo(const RsPgpId& _gpg_id,uint32_t lev) : gpg_id(_gpg_id),friend_level(lev) {}
std::string gpg_id ;
RsPgpId gpg_id ;
uint32_t friend_level ;
} ;
@ -127,16 +127,16 @@ void NetworkView::updateDisplay()
return ;
/* add all friends */
std::string ownGPGId = rsPeers->getGPGOwnId();
RsPgpId ownGPGId = rsPeers->getGPGOwnId();
//#ifdef DEBUG_NETWORKVIEW
std::cerr << "NetworkView::updateDisplay()" << std::endl;
//#endif
std::deque<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_considered.insert(rsPeers->getOwnId()) ;
nodes_considered.insert(rsPeers->getGPGOwnId()) ;
// Put own id in queue, and empty the queue, treating all nodes.
//
@ -163,7 +163,7 @@ void NetworkView::updateDisplay()
}
RsPeerDetails detail ;
if(!rsPeers->getPeerDetails(info.gpg_id, detail))
if(!rsPeers->getGPGDetails(info.gpg_id, detail))
continue ;
switch(detail.trustLvl)
@ -179,13 +179,13 @@ void NetworkView::updateDisplay()
if(info.friend_level <= _max_friend_level && _node_ids.find(info.gpg_id) == _node_ids.end())
{
_node_ids[info.gpg_id] = ui.graphicsView->addNode(" "+detail.name, detail.name+"@"+detail.gpg_id,type,auth,"",info.gpg_id);
_node_ids[info.gpg_id] = ui.graphicsView->addNode(" "+detail.name, detail.name+"@"+detail.gpg_id.toStdString(),type,auth,"",info.gpg_id.toStdString());
#ifdef DEBUG_NETWORKVIEW
std::cerr << " inserted node " << info.gpg_id << ", type=" << type << ", auth=" << auth << std::endl ;
#endif
}
std::list<std::string> friendList;
std::list<RsPgpId> friendList;
rsDisc->getDiscPgpFriends(info.gpg_id, friendList);
#ifdef DEBUG_NETWORKVIEW
@ -193,7 +193,7 @@ void NetworkView::updateDisplay()
#endif
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())
{
#ifdef DEBUG_NETWORKVIEW
@ -210,12 +210,12 @@ void NetworkView::updateDisplay()
std::cerr << "NetworkView::insertSignatures()" << std::endl;
#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))
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
std::cerr << "NetworkView: Adding Edge: ";

View file

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

View file

@ -960,7 +960,7 @@ void RetroshareDirModel::downloadSelected(const QModelIndexList &list)
{
std::cerr << "RetroshareDirModel::downloadSelected() Calling File Request";
std::cerr << std::endl;
std::list<std::string> srcIds;
std::list<RsPeerId> srcIds;
srcIds.push_back(details.id);
rsFiles -> FileRequest(details.name, details.hash,
details.count, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
@ -980,7 +980,7 @@ void RetroshareDirModel::downloadDirectory(const DirDetails & dirDetails, int pr
{
if (dirDetails.type & DIR_TYPE_FILE)
{
std::list<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()));
srcIds.push_back(dirDetails.id);

View file

@ -376,17 +376,17 @@ bool RetroShareLink::createPublicMsgInvite(time_t time_stamp,const QString& issu
return valid() ;
}
bool RetroShareLink::createPerson(const std::string& id)
bool RetroShareLink::createPerson(const RsPgpId& id)
{
clear();
RsPeerDetails detail;
if (rsPeers->getPeerDetails(id, detail) == false) {
if (rsPeers->getGPGDetails(id, detail) == false) {
std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << id << std::endl;
return false;
}
_hash = QString::fromStdString(id);
_hash = QString::fromStdString(id.toStdString());
_name = QString::fromUtf8(detail.name.c_str());
_type = TYPE_PERSON;
@ -396,14 +396,14 @@ bool RetroShareLink::createPerson(const std::string& id)
return valid();
}
bool RetroShareLink::createCertificate(const std::string& ssl_or_gpg_id)
bool RetroShareLink::createCertificate(const RsPeerId& ssl_id)
{
// This is baaaaaad code:
// - we should not need to parse and re-read a cert in old format.
//
RsPeerDetails detail;
if (rsPeers->getPeerDetails(ssl_or_gpg_id, detail) == false) {
std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_or_gpg_id << std::endl;
if (rsPeers->getPeerDetails(ssl_id, detail) == false) {
std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_id << std::endl;
return false;
}
@ -418,23 +418,23 @@ bool RetroShareLink::createCertificate(const std::string& ssl_or_gpg_id)
_type = TYPE_CERTIFICATE;
_GPGid = QString::fromStdString(detail.gpg_id).right(8);
_GPGid = QString::fromStdString(detail.gpg_id.toStdString()).right(8);
if(detail.isOnlyGPGdetail)
{
_SSLid.clear();
_location.clear();
_ext_ip_port.clear();
_loc_ip_port.clear();
}
else
{
_SSLid = QString::fromStdString(ssl_or_gpg_id) ;
// if(detail.isOnlyGPGdetail)
// {
// _SSLid.clear();
// _location.clear();
// _ext_ip_port.clear();
// _loc_ip_port.clear();
// }
// else
// {
_SSLid = QString::fromStdString(ssl_id.toStdString()) ;
_location = QString::fromUtf8(detail.location.c_str()) ;
_ext_ip_port = QString::fromStdString(detail.extAddr) + ":" + QString::number(detail.extPort) + ";" ;
_loc_ip_port = QString::fromStdString(detail.localAddr) + ":" + QString::number(detail.localPort) + ";" ;
_dyndns_name = QString::fromStdString(detail.dyndns);
}
//}
_name = QString::fromUtf8(detail.name.c_str()) ;
std::cerr << "Found gpg base 64 string = " << _GPGBase64String.toStdString() << std::endl;
@ -449,11 +449,11 @@ bool RetroShareLink::createCertificate(const std::string& ssl_or_gpg_id)
return true;
}
bool RetroShareLink::createUnknwonSslCertificate(const std::string& sslId, const std::string& gpgId)
bool RetroShareLink::createUnknwonSslCertificate(const RsPeerId& sslId, const RsPgpId& gpgId)
{
// first try ssl id
if (createCertificate(sslId)) {
if (gpgId.empty() || _GPGid.toStdString() == gpgId) {
if (gpgId.isNull() || _GPGid.toStdString() == gpgId.toStdString()) {
return true;
}
// wrong gpg id
@ -461,14 +461,14 @@ bool RetroShareLink::createUnknwonSslCertificate(const std::string& sslId, const
}
// then gpg id
if (createCertificate(gpgId)) {
if (createCertificate(sslId)) {
if (!_SSLid.isEmpty()) {
return false;
}
if (sslId.empty()) {
if (sslId.isNull()) {
return true;
}
_SSLid = QString::fromStdString(sslId);
_SSLid = QString::fromStdString(sslId.toStdString());
if (_location.isEmpty()) {
_location = _name;
}
@ -680,15 +680,15 @@ QString RetroShareLink::title() const
case TYPE_PUBLIC_MSG:
{
RsPeerDetails detail;
rsPeers->getPeerDetails(_GPGid.toStdString(), detail) ;
rsPeers->getGPGDetails(RsPgpId(_GPGid.toStdString()), detail) ;
return QString("Click to send a private message to %1 (%2).").arg(QString::fromStdString(detail.name)).arg(_GPGid) ;
}
case TYPE_PRIVATE_CHAT:
{
RsPeerDetails detail;
rsPeers->getPeerDetails(_GPGid.toStdString(), detail) ;
rsPeers->getGPGDetails(RsPgpId(_GPGid.toStdString()), detail) ;
if (_GPGid.toStdString() == rsPeers->getGPGOwnId())
if (_GPGid.toStdString() == rsPeers->getGPGOwnId().toStdString())
return QString("Click to open a private chat canal to %1 (%2).").arg(QString::fromStdString(detail.name)).arg(_GPGid) ;
else
return QString("This is a private chat invite for %1 (%2). You can't use it.").arg(QString::fromStdString(detail.name)).arg(_GPGid) ;
@ -875,7 +875,7 @@ QString RetroShareLink::toString() const
QString RetroShareLink::niceName() const
{
if (type() == TYPE_PERSON) {
return PeerDefs::rsid(name().toUtf8().constData(), hash().toStdString());
return PeerDefs::rsid(name().toUtf8().constData(), RsPgpId(hash().toStdString()));
}
if(type() == TYPE_PRIVATE_CHAT) {
@ -883,7 +883,7 @@ QString RetroShareLink::niceName() const
}
if(type() == TYPE_PUBLIC_MSG) {
RsPeerDetails detail;
rsPeers->getPeerDetails(_GPGid.toStdString(), detail) ;
rsPeers->getGPGDetails(RsPgpId(_GPGid.toStdString()), detail) ;
return QString("Click this link to send a private message to %1 (%2)").arg(QString::fromStdString(detail.name)).arg(_GPGid) ;
}
if(type() == TYPE_CERTIFICATE) {
@ -1095,7 +1095,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
break;
case TYPE_PERSON:
personAdd.append(PeerDefs::rsid(link.name().toUtf8().constData(), link.hash().toStdString()));
personAdd.append(PeerDefs::rsid(link.name().toUtf8().constData(), RsPgpId(link.hash().toStdString())));
break;
}
}
@ -1257,7 +1257,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
QMessageBox::information(NULL,QObject::tr("Chat link is expired"),QObject::tr("This chat link is expired. The destination peer will not answer.")) ;
break ;
}
if(link._GPGid.toStdString() != rsPeers->getGPGOwnId())
if(RsPgpId(link._GPGid.toStdString()) != rsPeers->getGPGOwnId())
{
QMessageBox::information(NULL,QObject::tr("Chat link cannot be decrypted"),QObject::tr("This chat link is encrypted with a key that is not yours. You can't use it. Key ID = ")+link._GPGid) ;
break ;
@ -1296,7 +1296,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
#endif
needNotifySuccess = true;
std::list<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.
@ -1305,7 +1305,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
#ifdef DEBUG_RSLINK
std::cerr << " RetroShareLink::process Adding built-in source " << link.SSLId().toStdString() << std::endl;
#endif
srcIds.push_back(link.SSLId().toStdString()) ;
srcIds.push_back(RsPeerId(link.SSLId().toStdString())) ;
}
// Get a list of available direct sources, in case the file is browsable only.
@ -1349,8 +1349,9 @@ static void processList(const QStringList &list, const QString &textSingular, co
needNotifySuccess = true;
RsPeerDetails detail;
if (rsPeers->getPeerDetails(link.hash().toStdString(), detail)) {
if (detail.gpg_id == rsPeers->getGPGOwnId()) {
if (rsPeers->getPeerDetails(RsPeerId(link.hash().toStdString()), detail))
{
if (RsPgpId(detail.gpg_id) == rsPeers->getGPGOwnId()) {
// it's me, do nothing
break;
}
@ -1361,17 +1362,17 @@ static void processList(const QStringList &list, const QString &textSingular, co
break;
}
if (rsPeers->addFriend("", link.hash().toStdString())) {
if (rsPeers->addFriend(RsPeerId(), RsPgpId(link.hash().toStdString()))) {
ConfCertDialog::loadAll();
personAdded.append(PeerDefs::rsid(detail));
break;
}
personFailed.append(PeerDefs::rsid(link.name().toUtf8().constData(), link.hash().toStdString()));
personFailed.append(PeerDefs::rsid(link.name().toUtf8().constData(), RsPgpId(link.hash().toStdString())));
break;
}
personNotFound.append(PeerDefs::rsid(link.name().toUtf8().constData(), link.hash().toStdString()));
personNotFound.append(PeerDefs::rsid(link.name().toUtf8().constData(), RsPgpId(link.hash().toStdString())));
break;
}
@ -1493,11 +1494,17 @@ static void processList(const QStringList &list, const QString &textSingular, co
std::cerr << " RetroShareLink::process MessageRequest : id : " << link.hash().toStdString() << ", subject : " << link.name().toStdString() << std::endl;
#endif
RsPeerDetails detail;
std::string dm_hash ;
RsFileHash dm_hash ;
if (rsPeers->getPeerDetails(link.hash().toStdString(), detail))
// This is awful, but apparently the hash can be multiple different types. Let's check!
RsPgpId pgp_id(link.hash().toStdString()) ;
RsPeerId ssl_id(link.hash().toStdString()) ;
if(!pgp_id.isNull() && rsPeers->getGPGDetails(pgp_id, detail)
|| !ssl_id.isNull() && rsPeers->getPeerDetails(ssl_id,detail))
{
if (detail.accept_connection || detail.id == rsPeers->getOwnId() || detail.id == rsPeers->getGPGOwnId()) {
if (detail.accept_connection || RsPeerId(detail.id) == rsPeers->getOwnId() || RsPgpId(detail.gpg_id) == rsPeers->getGPGOwnId()) {
MessageComposer *msg = MessageComposer::newMsg();
msg->addRecipient(MessageComposer::TO, detail.id, false);
if (link.subject().isEmpty() == false) {

View file

@ -33,6 +33,9 @@
// -------------+----------------+--------------------------+------------------+-------------+-------------
//
#include <stdint.h>
#include <retroshare/rstypes.h>
#include <QString>
#include <QVector>
#include <QUrl>
@ -72,15 +75,15 @@ class RetroShareLink
bool createFile(const QString& name, uint64_t size, const QString& hash);
bool createExtraFile(const QString& name, uint64_t size, const QString& hash, const QString& ssl_id);
bool createPerson(const std::string& id);
bool createPerson(const RsPgpId &id);
bool createForum(const std::string& id, const std::string& msgId);
bool createChannel(const std::string& id, const std::string& msgId);
bool createSearch(const QString& keywords);
bool createMessage(const std::string& peerId, const QString& subject);
bool createCertificate(const std::string& ssl_or_gpg_id) ;
bool createCertificate(const RsPeerId &ssl_id) ;
bool createPrivateChatInvite(time_t time_stamp,const QString& gpg_id,const QString& encrypted_chat_info) ;
bool createPublicMsgInvite(time_t time_stamp,const QString& pgp_id,const QString& hash) ;
bool createUnknwonSslCertificate(const std::string& sslId, const std::string& gpgId = "") ;
bool createUnknwonSslCertificate(const RsPeerId &sslId, const RsPgpId &gpgId = RsPgpId()) ;
enumType type() const {return _type; }
uint64_t size() const { return _size ; }

View file

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

View file

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

View file

@ -88,7 +88,7 @@ void ServicePermissionDialog::itemAdded(int idType, const QString &id, QTreeWidg
}
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(id.toStdString(), detail)) {
if (!rsPeers->getGPGDetails(RsPgpId(id.toStdString()), detail)) {
return;
}
@ -140,7 +140,7 @@ void ServicePermissionDialog::setPermissions()
}
}
rsPeers->setServicePermissionFlags(ui->servicePermissionList->idFromItem(item), flags);
rsPeers->setServicePermissionFlags(RsPgpId(ui->servicePermissionList->idFromItem(item)), flags);
}
done(Accepted);

View file

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

View file

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

View file

@ -6,11 +6,15 @@
class FriendSelectionDialog : public QDialog
{
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::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL,
FriendSelectionWidget::IdType pre_selected_id_type = FriendSelectionWidget::IDTYPE_SSL,
const std::list<std::string>& pre_selected_ids = std::list<std::string>()) ;
const std::list<RsPgpId>& pre_selected_ids = std::list<RsPgpId>()) ;
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() ;
FriendSelectionDialog(QWidget *parent,const QString& header_string,FriendSelectionWidget::Modus modus,FriendSelectionWidget::ShowTypes show_type,

View file

@ -34,14 +34,21 @@ const QString PeerDefs::nameWithLocation(const RsPeerDetails &details)
return name;
}
const QString PeerDefs::rsid(const std::string &name, const std::string &id)
const QString PeerDefs::rsid(const std::string &name, const RsPgpId &id)
{
if (name.empty()) {
return qApp->translate("PeerDefs", "Unknown") + "@" + QString::fromStdString(id);
return qApp->translate("PeerDefs", "Unknown") + "@" + QString::fromStdString(id.toStdString());
}
return QString::fromUtf8(name.c_str()) + "@" + QString::fromStdString(id);
return QString::fromUtf8(name.c_str()) + "@" + QString::fromStdString(id.toStdString());
}
const QString PeerDefs::rsid(const std::string &name, const RsPeerId &id)
{
if (name.empty()) {
return qApp->translate("PeerDefs", "Unknown") + "@" + QString::fromStdString(id.toStdString());
}
return QString::fromUtf8(name.c_str()) + "@" + QString::fromStdString(id.toStdString());
}
const QString PeerDefs::rsid(const RsPeerDetails &details)

View file

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

View file

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

View file

@ -1575,7 +1575,7 @@ void MessageComposer::editingRecipientFinished()
lineEdit->setText(text);
}
void MessageComposer::addRecipient(enumType type, const std::string& hash,const std::string& pgp_id)
void MessageComposer::addRecipient(enumType type, const Sha1CheckSum& hash,const RsPgpId& pgp_id)
{
_distant_peers[hash] = pgp_id ;
@ -1601,9 +1601,9 @@ void MessageComposer::addRecipient(enumType type, const std::string& hash,const
setRecipientToRow(row, type, hash, false);
}
void MessageComposer::addRecipient(enumType type, const std::string &id, bool group)
void MessageComposer::addRecipient(enumType type, const RsPeerId &id, bool group)
{
std::list<std::string> sslIds;
std::list<RsPeerId> sslIds;
if (group) {
sslIds.push_back(id);
} else {
@ -1613,23 +1613,23 @@ void MessageComposer::addRecipient(enumType type, const std::string &id, bool gr
return;
}
if (detail.isOnlyGPGdetail)
{
if( (!rsPeers->getAssociatedSSLIds(id, sslIds)) || sslIds.empty())
{
std::string hash ;
if(rsMsgs->getDistantMessageHash(id,hash))
addRecipient(type, hash, id);
else
{
QMessageBox::warning(this,tr("PGP key unknown"),tr("You dont have the PGP key of the message sender. So you cannot respond!"),QMessageBox::Ok) ;
return;
}
}
}
else {
// if (detail.isOnlyGPGdetail)
// {
// if( (!rsPeers->getAssociatedSSLIds(id, sslIds)) || sslIds.empty())
// {
// std::string hash ;
// if(rsMsgs->getDistantMessageHash(id,hash))
// addRecipient(type, hash, id);
// else
// {
// QMessageBox::warning(this,tr("PGP key unknown"),tr("You dont have the PGP key of the message sender. So you cannot respond!"),QMessageBox::Ok) ;
// return;
// }
// }
// }
// else {
sslIds.push_back(id);
}
// }
}
std::list<std::string>::const_iterator 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 setQuotedMsg(const QString &msg, const QString &header);
void setMsgText(const QString &msg, bool asHtml = false);
void addRecipient(enumType type, const std::string &id, bool group);
void addRecipient(enumType type, const std::string &hash, const std::string& pgp_id) ;
void addRecipient(enumType type, const RsPeerId &id, bool group);
void addRecipient(enumType type, const Sha1CheckSum &hash, const RsPgpId &pgp_id) ;
public slots:
/* actions to take.... */
@ -220,7 +220,7 @@ private:
Ui::MessageComposer ui;
std::list<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

View file

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