ID cleaning. Saving progress.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7122 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-02-16 16:39:09 +00:00
parent 11ef4fab9e
commit 14788b578b
18 changed files with 137 additions and 120 deletions

View file

@ -214,7 +214,7 @@ void IdEditDialog::loadExistingId(uint32_t token)
rsPeers->getGPGDetails(mEditGroup.mPgpId, details);
ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
ui.lineEdit_GpgId->setText(QString::fromStdString(mEditGroup.mPgpId));
ui.lineEdit_GpgId->setText(QString::fromStdString(mEditGroup.mPgpId.toStdString()));
}
else
{

View file

@ -288,7 +288,7 @@ void RetroShareLink::fromUrl(const QUrl& url)
if (url.host() == HOST_MESSAGE) {
_type = TYPE_MESSAGE;
std::string id = urlQuery.queryItemValue(MESSAGE_ID).toStdString();
createMessage(id, urlQuery.queryItemValue(MESSAGE_SUBJECT));
createMessage(RsPeerId(id), urlQuery.queryItemValue(MESSAGE_SUBJECT));
return;
}
@ -551,11 +551,11 @@ bool RetroShareLink::createSearch(const QString& keywords)
return valid();
}
bool RetroShareLink::createMessage(const std::string& peerId, const QString& subject)
bool RetroShareLink::createMessage(const RsPeerId& peerId, const QString& subject)
{
clear();
_hash = QString::fromStdString(peerId);
_hash = QString::fromStdString(peerId.toStdString());
PeerDefs::rsidFromId(peerId, &_name);
_subject = subject;
@ -698,13 +698,13 @@ QString RetroShareLink::title() const
case TYPE_FILE:
return QString("%1 (%2)").arg(hash()).arg(misc::friendlyUnit(size()));
case TYPE_PERSON:
return PeerDefs::rsidFromId(hash().toStdString());
return PeerDefs::rsidFromId(RsPeerId(hash().toStdString()));
case TYPE_FORUM:
case TYPE_CHANNEL:
case TYPE_SEARCH:
break;
case TYPE_MESSAGE:
return PeerDefs::rsidFromId(hash().toStdString());
return PeerDefs::rsidFromId(RsPeerId(hash().toStdString()));
case TYPE_CERTIFICATE:
return QObject::tr("Click to add this RetroShare cert to your PGP keyring\nand open the Make Friend Wizard.\n") + QString("PGP Id = ") + GPGId() + QString("\nSSLId = ")+SSLId();
}
@ -1230,19 +1230,20 @@ static void processList(const QStringList &list, const QString &textSingular, co
break ;
case TYPE_PUBLIC_MSG:
{
std::cerr << "Opening a public msg window " << std::endl;
std::cerr << " time_stamp = " << link._time_stamp << std::endl;
std::cerr << " hash = " << link._hash.toStdString() << std::endl;
std::cerr << " Issuer Id = " << link._GPGid.toStdString() << std::endl;
if(link._time_stamp < time(NULL))
{
QMessageBox::information(NULL,QObject::tr("Messaging link is expired"),QObject::tr("This Messaging link is expired. The destination peer will not receive it.")) ;
break ;
}
MessageComposer::msgDistantPeer(link._hash.toStdString(),link._GPGid.toStdString()) ;
{
std::cerr << "(!!) Distant messages from links is disabled for now" << std::endl;
// std::cerr << "Opening a public msg window " << std::endl;
// std::cerr << " time_stamp = " << link._time_stamp << std::endl;
// std::cerr << " hash = " << link._hash.toStdString() << std::endl;
// std::cerr << " Issuer Id = " << link._GPGid.toStdString() << std::endl;
//
// if(link._time_stamp < time(NULL))
// {
// QMessageBox::information(NULL,QObject::tr("Messaging link is expired"),QObject::tr("This Messaging link is expired. The destination peer will not receive it.")) ;
// break ;
// }
//
// MessageComposer::msgDistantPeer(link._hash.toStdString(),link._GPGid.toStdString()) ;
}
break ;
case TYPE_PRIVATE_CHAT:
@ -1530,7 +1531,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
messageReceipientNotAccepted.append(PeerDefs::nameWithLocation(detail));
}
} else {
messageReceipientUnknown.append(PeerDefs::rsidFromId(link.hash().toStdString()));
messageReceipientUnknown.append(PeerDefs::rsidFromId(RsPeerId(link.hash().toStdString())));
}
break;

View file

@ -79,7 +79,7 @@ class RetroShareLink
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 createMessage(const RsPeerId& peerId, const QString& subject);
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) ;

View file

@ -271,8 +271,8 @@ void BwCtrlWindow::updateBandwidth()
peerTreeWidget->clear();
RsConfigDataRates totalRates;
std::map<std::string, RsConfigDataRates> rateMap;
std::map<std::string, RsConfigDataRates>::iterator it;
std::map<RsPeerId, RsConfigDataRates> rateMap;
std::map<RsPeerId, RsConfigDataRates>::iterator it;
rsConfig->getTotalBandwidthRates(totalRates);
rsConfig->getAllBandwidthRates(rateMap);
@ -325,7 +325,7 @@ void BwCtrlWindow::updateBandwidth()
std::string name = rsPeers->getPeerName(it->first);
peer_item -> setData(COLUMN_PEERID, Qt::DisplayRole, QString::fromStdString(it->first));
peer_item -> setData(COLUMN_PEERID, Qt::DisplayRole, QString::fromStdString(it->first.toStdString()));
peer_item -> setData(COLUMN_RSNAME, Qt::DisplayRole, QString::fromStdString(name));
peer_item -> setData(COLUMN_IN_RATE, Qt::DisplayRole, it->second.mRateIn);

View file

@ -4,12 +4,12 @@
#include <QDialogButtonBox>
#include "FriendSelectionDialog.h"
std::list<RsPgpId> FriendSelectionDialog::selectFriends(QWidget *parent,const QString& caption,const QString& header_text,
std::list<RsPgpId> FriendSelectionDialog::selectFriends_PGP(QWidget *parent,const QString& caption,const QString& header_text,
FriendSelectionWidget::Modus modus,
FriendSelectionWidget::ShowTypes show_type,
const std::list<RsPgpId>& pre_selected_ids)
{
FriendSelectionDialog dialog(parent,header_text,modus,show_type,IDTYPE_GPG,pre_selected_ids) ;
FriendSelectionDialog dialog(parent,header_text,modus,show_type,FriendSelectionWidget::IDTYPE_GPG,pre_selected_ids) ;
dialog.setWindowTitle(caption) ;
@ -17,7 +17,7 @@ std::list<RsPgpId> FriendSelectionDialog::selectFriends(QWidget *parent,const QS
return std::list<std::string>() ;
std::list<std::string> sids ;
dialog.friends_widget->selectedIds(pre_selected_id_type,ids,false) ;
dialog.friends_widget->selectedIds(pre_selected_ids,false) ;
std::list<RsPgpId> ids ;
for(std::list<std::string>::const_iterator it(sids.begin());it!=sids.end();++it)
@ -30,12 +30,12 @@ std::list<RsPgpId> FriendSelectionDialog::selectFriends(QWidget *parent,const QS
}
return ids ;
}
std::list<RsPeerId> FriendSelectionDialog::selectFriends(QWidget *parent,const QString& caption,const QString& header_text,
std::list<RsPeerId> FriendSelectionDialog::selectFriends_SSL(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) ;
FriendSelectionDialog dialog(parent,header_text,modus,show_type,FriendSelectionWidget::IDTYPE_SSL,pre_selected_ids) ;
dialog.setWindowTitle(caption) ;
@ -43,7 +43,7 @@ std::list<RsPeerId> FriendSelectionDialog::selectFriends(QWidget *parent,const Q
return std::list<std::string>() ;
std::list<std::string> sids ;
dialog.friends_widget->selectedIds(pre_selected_id_type,ids,false) ;
dialog.friends_widget->selectedIds(pre_selected_ids,false) ;
std::list<RsPeerId> ids ;
for(std::list<std::string>::const_iterator it(sids.begin());it!=sids.end();++it)

View file

@ -1,6 +1,7 @@
#pragma once
#include <QDialog>
#include <retroshare/rstypes.h>
#include <gui/common/FriendSelectionWidget.h>
class FriendSelectionDialog : public QDialog

View file

@ -254,7 +254,7 @@ void MimeTextEdit::pasteLink()
void MimeTextEdit::pasteOwnCertificateLink()
{
RetroShareLink link;
std::string ownId = rsPeers->getOwnId();
RsPeerId ownId = rsPeers->getOwnId();
if (link.createCertificate(ownId)) {
insertHtml(link.toHtml() + " ");

View file

@ -56,7 +56,7 @@ const QString PeerDefs::rsid(const RsPeerDetails &details)
return rsid(details.name, details.id);
}
const QString PeerDefs::rsidFromId(const std::string &id, QString *name /* = NULL*/)
const QString PeerDefs::rsidFromId(const RsPeerId &id, QString *name /* = NULL*/)
{
QString rsid;
@ -91,18 +91,18 @@ const QString PeerDefs::rsidFromId(const std::string &id, QString *name /* = NUL
return rsid;
}
const std::string PeerDefs::idFromRsid(const QString &rsid, bool check)
RsPeerId PeerDefs::idFromRsid(const QString &rsid, bool check)
{
// search for cert id in string
std::string id;
RsPeerId id;
int index = rsid.indexOf("@");
if (index >= 0) {
// found "@", extract cert id from string
id = rsid.mid(index + 1).toStdString();
id = RsPeerId(rsid.mid(index + 1).toStdString());
} else {
// maybe its only the cert id
id = rsid.toStdString();
id = RsPeerId(rsid.toStdString());
}
if (check) {

View file

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

View file

@ -227,7 +227,7 @@ void RsCollectionDialog::download()
if(!QDir(QApplication::applicationDirPath()).mkpath(cleanPath))
QMessageBox::warning(NULL,QObject::tr("Unable to make path"),QObject::tr("Unable to make path:")+"<br> "+cleanPath) ;
rsFiles->FileRequest(dlinfo.name.toUtf8().constData(), dlinfo.hash.toUtf8().constData(), dlinfo.size, cleanPath.toUtf8().constData(), RS_FILE_REQ_ANONYMOUS_ROUTING, std::list<std::string>());
rsFiles->FileRequest(dlinfo.name.toUtf8().constData(), dlinfo.hash.toUtf8().constData(), dlinfo.size, cleanPath.toUtf8().constData(), RS_FILE_REQ_ANONYMOUS_ROUTING, std::list<RsPeerId>());
}
else
std::cerr<<"Skipping file : " << dlinfo.name.toStdString() << std::endl;

View file

@ -299,8 +299,8 @@ void DhtWindow::updateNetPeers()
{
QTreeWidget *peerTreeWidget = ui->peerTreeWidget;
std::list<std::string> peerIds;
std::list<std::string>::iterator it;
std::list<RsPeerId> peerIds;
std::list<RsPeerId>::iterator it;
rsDht->getNetPeerList(peerIds);
@ -386,7 +386,7 @@ void DhtWindow::updateNetPeers()
peer_item -> setData(PTW_COL_PEERID, Qt::DisplayRole, QString::fromStdString(status.mDhtId));
peer_item -> setData(PTW_COL_RSNAME, Qt::DisplayRole, QString::fromStdString(name));
peer_item -> setData(PTW_COL_RSID, Qt::DisplayRole, QString::fromStdString(status.mRsId));
peer_item -> setData(PTW_COL_RSID, Qt::DisplayRole, QString::fromStdString(status.mRsId.toStdString()));
QString dhtstate;
switch(status.mDhtState)

View file

@ -69,7 +69,7 @@
const uint32_t SFI_DEFAULT_PERIOD = (30 * 3600 * 24); /* 30 Days */
/** Constructor */
SubFileItem::SubFileItem(const std::string &hash, const std::string &name, const std::string &path, uint64_t size, uint32_t flags, const std::string &srcId)
SubFileItem::SubFileItem(const std::string &hash, const std::string &name, const std::string &path, uint64_t size, uint32_t flags, const RsPeerId &srcId)
:QWidget(NULL), mPath(path), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId)
{
/* Invoke the Qt Designer generated object setup routine */
@ -598,7 +598,7 @@ void SubFileItem::download()
std::cerr << std::endl;
#endif
std::list<std::string> sources ;
std::list<RsPeerId> sources ;
std::string destination;
#if 0
@ -623,7 +623,7 @@ void SubFileItem::download()
std::cerr << "SubFileItem::download() Calling File Request";
std::cerr << std::endl;
if (mSrcId != "")
if (!mSrcId.isNull())
sources.push_back(mSrcId);
rsFiles->FileRequest(mFileName, mFileHash, mFileSize, destination, RS_FILE_REQ_ANONYMOUS_ROUTING, sources);

View file

@ -24,6 +24,7 @@
#include "ui_SubFileItem.h"
#include <stdint.h>
#include <retroshare/rstypes.h>
const uint32_t SFI_MASK_STATE = 0x000f;
const uint32_t SFI_MASK_TYPE = 0x00f0;
//const uint32_t SFI_MASK_FT = 0x0f00;
@ -55,7 +56,7 @@ class SubFileItem : public QWidget, private Ui::SubFileItem
public:
/** Default Constructor */
SubFileItem(const std::string &hash, const std::string &name, const std::string &path, uint64_t size, uint32_t flags, const std::string &srcId);
SubFileItem(const std::string &hash, const std::string &name, const std::string &path, uint64_t size, uint32_t flags, const RsPeerId &srcId);
void smaller();
@ -96,7 +97,7 @@ private:
std::string mFileHash;
std::string mFileName;
uint64_t mFileSize;
std::string mSrcId;
RsPeerId mSrcId;
std::string mChannelId;
uint32_t mMode;

View file

@ -359,24 +359,27 @@ void MessageComposer::processSettings(bool bLoad)
Settings->endGroup();
}
/*static*/ void MessageComposer::msgDistantPeer(const std::string& hash,const std::string& pgp_id)
/*static*/ void MessageComposer::msgDistantPeer(const RsPgpId& pgp_id)
{
// std::cerr << "MessageComposer::msgfriend()" << std::endl;
/* create a message */
Sha1CheckSum hash ;
rsMsgs->getDistantMessageHash(pgp_id,hash) ;
MessageComposer *pMsgDialog = MessageComposer::newMsg();
if (pMsgDialog == NULL)
return;
pMsgDialog->addRecipient(TO, hash,pgp_id) ;
pMsgDialog->addRecipient(TO, hash,pgp_id) ;
pMsgDialog->show();
/* window will destroy itself! */
}
/*static*/ void MessageComposer::msgFriend(const std::string &id, bool group)
/*static*/ void MessageComposer::msgFriend(const RsPeerId &id, bool group)
{
// std::cerr << "MessageComposer::msgfriend()" << std::endl;
@ -391,19 +394,20 @@ void MessageComposer::processSettings(bool bLoad)
pMsgDialog->addRecipient(TO, id, true);
} else {
RsPeerDetails detail;
if (rsPeers->getPeerDetails(id, detail) && detail.accept_connection) {
if (detail.isOnlyGPGdetail) {
//put all sslChilds in message list
std::list<std::string> sslIds;
rsPeers->getAssociatedSSLIds(id, sslIds);
std::list<std::string>::const_iterator it;
for (it = sslIds.begin(); it != sslIds.end(); it++) {
pMsgDialog->addRecipient(TO, *it, false);
}
} else {
if (rsPeers->getPeerDetails(id, detail) && detail.accept_connection)
{
// if (detail.isOnlyGPGdetail) {
// //put all sslChilds in message list
// std::list<RsPeerId> sslIds;
// rsPeers->getAssociatedSSLIds(id, sslIds);
//
// std::list<RsPeerId>::const_iterator it;
// for (it = sslIds.begin(); it != sslIds.end(); it++) {
// pMsgDialog->addRecipient(TO, *it, false);
// }
// } else {
pMsgDialog->addRecipient(TO, detail.id, false);
}
// }
}
}
@ -412,12 +416,12 @@ void MessageComposer::processSettings(bool bLoad)
/* window will destroy itself! */
}
static QString buildRecommendHtml(const std::list<std::string> &sslIds, const std::string &excludeId = "")
static QString buildRecommendHtml(const std::list<RsPeerId> &sslIds, const RsPeerId& excludeId = RsPeerId())
{
QString text;
/* process ssl ids */
std::list <std::string>::const_iterator sslIt;
std::list <RsPeerId>::const_iterator sslIt;
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
if (*sslIt == excludeId) {
continue;
@ -436,7 +440,7 @@ QString MessageComposer::recommendMessage()
return tr("Hello,<br>I recommend a good friend of mine; you can trust them too when you trust me. <br>");
}
void MessageComposer::recommendFriend(const std::list <std::string> &sslIds, const std::string &to, const QString &msg, bool autoSend)
void MessageComposer::recommendFriend(const std::list <RsPeerId> &sslIds, const RsPeerId &to, const QString &msg, bool autoSend)
{
// std::cerr << "MessageComposer::recommendFriend()" << std::endl;
@ -455,12 +459,12 @@ void MessageComposer::recommendFriend(const std::list <std::string> &sslIds, con
composer->setTitleText(tr("You have a friend recommendation"));
composer->msgFlags |= RS_MSG_FRIEND_RECOMMENDATION;
if (!to.empty()) {
if (!to.isNull()) {
composer->addRecipient(TO, to, false);
}
std::string ownId = rsPeers->getOwnId();
RsPgpId ownPgpId = rsPeers->getGPGOwnId();
RetroShareLink link;
link.createPerson(ownId);
link.createPerson(ownPgpId);
QString sMsgText = msg.isEmpty() ? recommendMessage() : msg;
sMsgText += "<br><br>";
@ -470,7 +474,7 @@ void MessageComposer::recommendFriend(const std::list <std::string> &sslIds, con
sMsgText += tr("Thanks, <br>The RetroShare Team");
composer->setMsgText(sMsgText);
std::list <std::string>::const_iterator peerIt;
std::list <RsPeerId>::const_iterator peerIt;
for (peerIt = sslIds.begin(); peerIt != sslIds.end(); peerIt++) {
if (*peerIt == to) {
continue;
@ -490,9 +494,9 @@ void MessageComposer::recommendFriend(const std::list <std::string> &sslIds, con
/* window will destroy itself! */
}
void MessageComposer::sendConnectAttemptMsg(const std::string &gpgId, const std::string &sslId, const QString &sslName)
void MessageComposer::sendConnectAttemptMsg(const RsPgpId &gpgId, const RsPeerId &sslId, const QString &sslName)
{
if (gpgId.empty()) {
if (gpgId.isNull()) {
return;
}
@ -637,8 +641,8 @@ void MessageComposer::buildCompleter()
std::list<RsGroupInfo>::iterator groupIt;
rsPeers->getGroupInfoList(groupInfoList);
std::list<std::string> peers;
std::list<std::string>::iterator peerIt;
std::list<RsPeerId> peers;
std::list<RsPeerId>::iterator peerIt;
rsPeers->getFriendList(peers);
// create completer list for friends
@ -679,11 +683,11 @@ void MessageComposer::peerStatusChanged(const QString& peer_id, int status)
for (row = 0; row < rowCount; row++) {
enumType type;
std::string id;
RsPeerId id;
bool group;
if (getRecipientFromRow(row, type, id, group) && id.empty() == false) {
if (group == false && QString::fromStdString(id) == peer_id) {
if (getRecipientFromRow(row, type, id, group) && !id.isNull() ) {
if (group == false && QString::fromStdString(id.toStdString()) == peer_id) {
QTableWidgetItem *item = ui.recipientWidget->item(row, COLUMN_RECIPIENT_ICON);
if (item) {
item->setIcon(QIcon(StatusDefs::imageUser(status)));
@ -761,7 +765,7 @@ void MessageComposer::calculateTitle()
setWindowTitle(tr("Compose") + ": " + misc::removeNewLine(ui.titleEdit->text()));
}
static void calculateGroupsOfSslIds(std::list<RsGroupInfo> &existingGroupInfos, std::list<std::string> &checkSslIds, std::list<std::string> &checkGroupIds)
static void calculateGroupsOfSslIds(const std::list<RsGroupInfo> &existingGroupInfos, std::list<RsPeerId> &checkSslIds, std::list<std::string> &checkGroupIds)
{
checkGroupIds.clear();
@ -770,24 +774,24 @@ static void calculateGroupsOfSslIds(std::list<RsGroupInfo> &existingGroupInfos,
return;
}
std::map<std::string, std::string> sslToGpg;
std::map<std::string, std::list<std::string> > gpgToSslIds;
std::map<RsPeerId, RsPgpId> sslToGpg;
std::map<RsPgpId, std::list<RsPeerId> > gpgToSslIds;
std::list<RsGroupInfo> groupInfos;
// iterate all groups
std::list<RsGroupInfo>::iterator groupInfoIt;
std::list<RsGroupInfo>::const_iterator groupInfoIt;
for (groupInfoIt = existingGroupInfos.begin(); groupInfoIt != existingGroupInfos.end(); groupInfoIt++) {
if (groupInfoIt->peerIds.empty()) {
continue;
}
// iterate all assigned peers (gpg id's)
std::list<std::string>::iterator peerIt;
std::list<RsPgpId>::const_iterator peerIt;
for (peerIt = groupInfoIt->peerIds.begin(); peerIt != groupInfoIt->peerIds.end(); peerIt++) {
std::list<std::string> sslIds;
std::list<RsPeerId> sslIds;
std::map<std::string, std::list<std::string> >::iterator it = gpgToSslIds.find(*peerIt);
std::map<RsPgpId, std::list<RsPeerId> >::const_iterator it = gpgToSslIds.find(*peerIt);
if (it == gpgToSslIds.end()) {
rsPeers->getAssociatedSSLIds(*peerIt, sslIds);
@ -797,7 +801,7 @@ static void calculateGroupsOfSslIds(std::list<RsGroupInfo> &existingGroupInfos,
}
// iterate all ssl id's
std::list<std::string>::const_iterator sslIt;
std::list<RsPeerId>::const_iterator sslIt;
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
// search in ssl list
if (std::find(checkSslIds.begin(), checkSslIds.end(), *sslIt) == checkSslIds.end()) {
@ -820,11 +824,11 @@ static void calculateGroupsOfSslIds(std::list<RsGroupInfo> &existingGroupInfos,
// remove all ssl id's of all found groups from the list
for (groupInfoIt = groupInfos.begin(); groupInfoIt != groupInfos.end(); groupInfoIt++) {
// iterate all assigned peers (gpg id's)
std::list<std::string>::iterator peerIt;
std::list<RsPgpId>::const_iterator peerIt;
for (peerIt = groupInfoIt->peerIds.begin(); peerIt != groupInfoIt->peerIds.end(); peerIt++) {
std::list<std::string> sslIds;
std::list<RsPeerId> sslIds;
std::map<std::string, std::list<std::string> >::iterator it = gpgToSslIds.find(*peerIt);
std::map<RsPgpId, std::list<RsPeerId> >::iterator it = gpgToSslIds.find(*peerIt);
if (it == gpgToSslIds.end()) {
rsPeers->getAssociatedSSLIds(*peerIt, sslIds);
@ -834,10 +838,10 @@ static void calculateGroupsOfSslIds(std::list<RsGroupInfo> &existingGroupInfos,
}
// iterate all ssl id's
std::list<std::string>::const_iterator sslIt;
std::list<RsPeerId>::const_iterator sslIt;
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
// search in ssl list
std::list<std::string>::iterator it = std::find(checkSslIds.begin(), checkSslIds.end(), *sslIt);
std::list<RsPeerId>::iterator it = std::find(checkSslIds.begin(), checkSslIds.end(), *sslIt);
if (it != checkSslIds.end()) {
checkSslIds.erase(it);
}
@ -848,6 +852,7 @@ static void calculateGroupsOfSslIds(std::list<RsGroupInfo> &existingGroupInfos,
}
}
#ifdef SUSPENDED
MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
{
MessageComposer *msgComposer = new MessageComposer();
@ -888,7 +893,7 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
std::list<std::string> groupIds;
std::list<std::string>::iterator groupIt;
std::list<std::string>::iterator it;
std::list<RsPeerId>::iterator it;
calculateGroupsOfSslIds(groupInfoList, msgInfo.msgto, groupIds);
for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) {
@ -927,6 +932,7 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
return msgComposer;
}
#endif
QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo)
{
@ -935,7 +941,7 @@ QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo)
QString from = link.toHtml();
QString to;
std::list<std::string>::const_iterator it;
std::list<RsPeerId>::const_iterator it;
for (it = msgInfo.msgto.begin(); it != msgInfo.msgto.end(); it++) {
if (link.createMessage(*it, "")) {
if (!to.isEmpty()) {
@ -1029,15 +1035,15 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all)
msgComposer->addRecipient(MessageComposer::TO, msgInfo.srcId, false);
if (all) {
std::string ownId = rsPeers->getOwnId();
RsPeerId ownId = rsPeers->getOwnId();
for (std::list<std::string>::iterator tli = msgInfo.msgto.begin(); tli != msgInfo.msgto.end(); tli++) {
for (std::list<RsPeerId>::iterator tli = msgInfo.msgto.begin(); tli != msgInfo.msgto.end(); tli++) {
if (ownId != *tli) {
msgComposer->addRecipient(MessageComposer::TO, *tli, false) ;
}
}
for (std::list<std::string>::iterator tli = msgInfo.msgcc.begin(); tli != msgInfo.msgcc.end(); tli++) {
for (std::list<RsPeerId>::iterator tli = msgInfo.msgcc.begin(); tli != msgInfo.msgcc.end(); tli++) {
if (ownId != *tli) {
msgComposer->addRecipient(MessageComposer::TO, *tli, false) ;
}
@ -1137,6 +1143,7 @@ void MessageComposer::sendMessage()
bool MessageComposer::sendMessage_internal(bool bDraftbox)
{
#ifdef SUSPENDED
/* construct a message */
MessageInfo mi;
@ -1171,7 +1178,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
}
/* get the ids from the send list */
std::list<std::string> peers;
std::list<RsPeerId> peers;
rsPeers->getFriendList(peers);
/* add own id */
@ -1185,7 +1192,8 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
std::string id;
bool group;
if (getRecipientFromRow(row, type, id, group) && id.empty() == false) {
if (getRecipientFromRow(row, type, id, group) && !id.empty())
{
if (group) {
RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(id, groupInfo) == false) {
@ -1195,10 +1203,10 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
std::list<std::string>::const_iterator groupIt;
for (groupIt = groupInfo.peerIds.begin(); groupIt != groupInfo.peerIds.end(); groupIt++) {
std::list<std::string> sslIds;
std::list<RsPeerId> sslIds;
rsPeers->getAssociatedSSLIds(*groupIt, sslIds);
std::list<std::string>::const_iterator sslIt;
std::list<RsPeerId>::const_iterator sslIt;
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
if (std::find(peers.begin(), peers.end(), *sslIt) == peers.end()) {
// no friend
@ -1318,6 +1326,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
}
}
ui.msgText->document()->setModified(false);
#endif
return true;
}
@ -1343,10 +1352,10 @@ void MessageComposer::addEmptyRecipient()
}
}
setRecipientToRow(lastRow, TO, "", false);
setRecipientToRow(lastRow, TO, RsPeerId(), false);
}
bool MessageComposer::getRecipientFromRow(int row, enumType &type, std::string &id, bool &group)
bool MessageComposer::getRecipientFromRow(int row, enumType &type, RsPeerId &id, bool &group)
{
if (row >= ui.recipientWidget->rowCount()) {
return false;
@ -1358,13 +1367,13 @@ bool MessageComposer::getRecipientFromRow(int row, enumType &type, std::string &
}
type = (enumType) cb->itemData(cb->currentIndex(), Qt::UserRole).toInt();
id = ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->data(ROLE_RECIPIENT_ID).toString().toStdString();
id = RsPeerId(ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->data(ROLE_RECIPIENT_ID).toString().toStdString());
group = ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->data(ROLE_RECIPIENT_GROUP).toBool();
return true;
}
void MessageComposer::setRecipientToRow(int row, enumType type, std::string id, bool group)
void MessageComposer::setRecipientToRow(int row, enumType type, const RsPeerId &id, bool group)
{
if (row + 1 > ui.recipientWidget->rowCount()) {
ui.recipientWidget->setRowCount(row + 1);
@ -1399,7 +1408,7 @@ void MessageComposer::setRecipientToRow(int row, enumType type, std::string id,
QIcon icon;
QString name;
if (!id.empty())
if (!id.isNull())
{
if (group)
{
@ -1538,10 +1547,10 @@ void MessageComposer::editingRecipientFinished()
}
// start with peers
std::list<std::string> peers;
std::list<RsPeerId> peers;
rsPeers->getFriendList(peers);
std::list<std::string>::iterator peerIt;
std::list<RsPeerId>::iterator peerIt;
for (peerIt = peers.begin(); peerIt != peers.end(); peerIt++) {
RsPeerDetails details;
if (!rsPeers->getPeerDetails(*peerIt, details)) {
@ -1570,7 +1579,7 @@ void MessageComposer::editingRecipientFinished()
}
}
setRecipientToRow(row, type, "", false);
setRecipientToRow(row, type, RsPeerId(), false);
lineEdit->setStyleSheet(QString(STYLE_FAIL).arg(lineEdit->objectName()));
lineEdit->setText(text);
}
@ -1601,6 +1610,9 @@ void MessageComposer::addRecipient(enumType type, const Sha1CheckSum& hash,const
setRecipientToRow(row, type, hash, false);
}
void MessageComposer::addRecipient(enumType type, const RsPgpId &id, bool group)
{
}
void MessageComposer::addRecipient(enumType type, const RsPeerId &id, bool group)
{
std::list<RsPeerId> sslIds;

View file

@ -48,13 +48,13 @@ public:
MessageComposer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
~MessageComposer();
static void msgFriend(const std::string &id, bool group);
static void msgDistantPeer(const std::string& hash,const std::string& pgp_id) ;
static void msgDistantPeer(const std::string& pgp_id) ;
static void msgFriend(const RsPeerId &id, bool group);
//static void msgDistantPeer(const std::string& hash,const std::string& pgp_id) ;
static void msgDistantPeer(const RsPgpId& pgp_id) ;
static QString recommendMessage();
static void recommendFriend(const std::list <std::string> &sslIds, const std::string &to = "", const QString &msg = "", bool autoSend = false);
static void sendConnectAttemptMsg(const std::string &gpgId, const std::string &sslId, const QString &sslName);
static void recommendFriend(const std::list <RsPeerId> &sslIds, const RsPeerId &to = RsPeerId(), const QString &msg = "", bool autoSend = false);
static void sendConnectAttemptMsg(const RsPgpId &gpgId, const RsPeerId &sslId, const QString &sslName);
static MessageComposer *newMsg(const std::string &msgId = "");
static MessageComposer *replyMsg(const std::string &msgId, bool all);
@ -173,8 +173,8 @@ private:
void calculateTitle();
void addEmptyRecipient();
bool getRecipientFromRow(int row, enumType &type, std::string &id, bool &group);
void setRecipientToRow(int row, enumType type, std::string id, bool group);
bool getRecipientFromRow(int row, enumType &type, RsPeerId &id, bool &group);
void setRecipientToRow(int row, enumType type, const RsPeerId& id, bool group);
void clearTagLabels();
void showTagLabels();

View file

@ -77,16 +77,16 @@ void CryptoPage::showEvent ( QShowEvent * /*event*/ )
ui.name->setText(QString::fromUtf8(detail.name.c_str()));
ui.country->setText(QString::fromUtf8(detail.location.c_str()));
ui.peerid->setText(QString::fromStdString(detail.id));
ui.pgpid->setText(QString::fromStdString(detail.gpg_id));
ui.pgpfingerprint->setText(misc::fingerPrintStyleSplit(QString::fromStdString(detail.fpr)));
ui.peerid->setText(QString::fromStdString(detail.id.toStdString()));
ui.pgpid->setText(QString::fromStdString(detail.gpg_id.toStdString()));
ui.pgpfingerprint->setText(misc::fingerPrintStyleSplit(QString::fromStdString(detail.fpr.toStdString())));
/* set retroshare version */
std::string version;
rsDisc->getPeerVersion(detail.id, version);
ui.version->setText(QString::fromStdString(version));
std::list<std::string> ids;
std::list<RsPgpId> ids;
ids.clear();
rsPeers->getGPGAcceptedList(ids);
int friends = ids.size();
@ -119,7 +119,7 @@ void
CryptoPage::copyRSLink()
{
RetroShareLink link ;
std::string ownId = rsPeers->getOwnId() ;
RsPeerId ownId = rsPeers->getOwnId() ;
if( link.createCertificate(ownId) )
{

View file

@ -33,7 +33,7 @@
RSettings::RSettings(const QString settingsGroup)
: QSettings(SETTINGS_FILE, QSettings::IniFormat)
{
std::string sPreferedId;
RsPeerId sPreferedId;
m_bValid = RsAccounts::GetPreferredAccountId(sPreferedId);
if (!settingsGroup.isEmpty())

View file

@ -37,7 +37,9 @@ MessageToaster::MessageToaster(const std::string &peerId, const QString &title,
ui.subjectLabel->setToolTip(title);
ui.textLabel->setText(message);
ui.textLabel->setToolTip(message);
ui.toasterLabel->setText(ui.toasterLabel->text() + " " + QString::fromUtf8(rsPeers->getPeerName(peerId).c_str()));
std::string name = (!RsPeerId(peerId).isNull())? (rsPeers->getPeerName(RsPeerId(peerId))): (rsPeers->getGPGName(RsPgpId(peerId))) ;
ui.toasterLabel->setText(ui.toasterLabel->text() + " " + QString::fromUtf8(name.c_str()));
}
void MessageToaster::openmessageClicked()