merge of branch v0.6-idclean 7180

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7187 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2014-03-17 20:56:06 +00:00
parent 7815efb16f
commit 0f29d28b1b
397 changed files with 6503 additions and 5702 deletions

View file

@ -51,7 +51,7 @@ void AvatarDefs::getAvatarFromSslId(const std::string& sslId, QPixmap &avatar, c
int size = 0;
/* get avatar */
rsMsgs->getAvatarData(sslId, data, size);
rsMsgs->getAvatarData(RsPeerId(sslId), data, size);
if (size == 0) {
avatar = QPixmap(defaultImage);
return;
@ -68,14 +68,14 @@ void AvatarDefs::getAvatarFromGpgId(const std::string& gpgId, QPixmap &avatar, c
unsigned char *data = NULL;
int size = 0;
if (gpgId == rsPeers->getGPGOwnId()) {
if (RsPgpId(gpgId) == rsPeers->getGPGOwnId()) {
/* Its me */
rsMsgs->getOwnAvatarData(data,size);
} else {
/* get the first available avatar of one of the ssl ids */
std::list<std::string> sslIds;
if (rsPeers->getAssociatedSSLIds(gpgId, sslIds)) {
std::list<std::string>::iterator sslId;
std::list<RsPeerId> sslIds;
if (rsPeers->getAssociatedSSLIds(RsPgpId(gpgId), sslIds)) {
std::list<RsPeerId>::iterator sslId;
for (sslId = sslIds.begin(); sslId != sslIds.end(); sslId++) {
rsMsgs->getAvatarData(*sslId, data, size);
if (size) {

View file

@ -39,7 +39,7 @@ AvatarWidget::AvatarWidget(QWidget *parent) :
ui->setupUi(this);
mFlag.isOwnId = false;
mFlag.isGpg = false;
// mFlag.isGpg = false;
defaultAvatar = ":/images/no_avatar_background.png";
setFrameType(NO_FRAME);
@ -107,39 +107,39 @@ void AvatarWidget::setFrameType(FrameType type)
}
refreshStatus();
updateAvatar(QString::fromStdString(mId));
updateAvatar(QString::fromStdString(mId.toStdString()));
Rshare::refreshStyleSheet(this, false);
}
void AvatarWidget::setId(const std::string &id, bool isGpg)
void AvatarWidget::setId(const RsPeerId &id)
{
mId = id;
mFlag.isGpg = isGpg;
mId = id;
// mPgpId = rsPeers->getGPGId(id) ;
// mFlag.isGpg = false ;
if (mId == rsPeers->getOwnId()) {
mFlag.isOwnId = true;
setToolTip(tr("Click to change your avatar"));
}
if (mId == rsPeers->getOwnId()) {
mFlag.isOwnId = true;
setToolTip(tr("Click to change your avatar"));
}
setPixmap(QPixmap());
setPixmap(QPixmap());
if (mId.empty()) {
setEnabled(false);
}
if (id.isNull()) {
setEnabled(false);
}
refreshStatus();
updateAvatar(QString::fromStdString(mId));
refreshStatus();
updateAvatar(QString::fromStdString(mId.toStdString()));
}
void AvatarWidget::setOwnId()
{
setId(rsPeers->getOwnId(), false);
setId(rsPeers->getOwnId());
}
void AvatarWidget::setDefaultAvatar(const QString &avatar)
{
defaultAvatar = avatar;
updateAvatar(QString::fromStdString(mId));
updateAvatar(QString::fromStdString(mId.toStdString()));
}
void AvatarWidget::refreshStatus()
@ -161,7 +161,7 @@ void AvatarWidget::refreshStatus()
// No check of return value. Non existing status info is handled as offline.
rsStatus->getStatus(mId, statusInfo);
}
updateStatus(QString::fromStdString(statusInfo.id), statusInfo.status);
updateStatus(QString::fromStdString(statusInfo.id.toStdString()), statusInfo.status);
break;
}
}
@ -173,12 +173,12 @@ void AvatarWidget::updateStatus(const QString peerId, int status)
return;
}
if (mId.empty()) {
if (mId.isNull()) {
mPeerState = status;
Rshare::refreshStyleSheet(this, false);
} else {
/* set style for status */
if (mId == peerId.toStdString()) {
if (mId.toStdString() == peerId.toStdString()) {
// the peers status has changed
mPeerState = status;
setEnabled(((uint32_t) status == RS_STATUS_OFFLINE) ? false : true);
@ -189,7 +189,7 @@ void AvatarWidget::updateStatus(const QString peerId, int status)
void AvatarWidget::updateAvatar(const QString &peerId)
{
if (mId.empty()) {
if (mId.isNull()) {
QPixmap avatar(defaultAvatar);
setPixmap(avatar);
return;
@ -202,34 +202,34 @@ void AvatarWidget::updateAvatar(const QString &peerId)
return;
}
if (mFlag.isGpg) {
if (mId == peerId.toStdString()) {
/* called from AvatarWidget with gpg id */
QPixmap avatar;
AvatarDefs::getAvatarFromGpgId(mId, avatar, defaultAvatar);
setPixmap(avatar);
return;
}
//if (mFlag.isGpg) {
// if (mId == peerId.toStdString()) {
// /* called from AvatarWidget with gpg id */
// QPixmap avatar;
// AvatarDefs::getAvatarFromGpgId(mId, avatar, defaultAvatar);
// setPixmap(avatar);
// return;
// }
//
// /* Is this one of the ssl ids of the gpg id ? */
// std::list<std::string> sslIds;
// if (rsPeers->getAssociatedSSLIds(mId, sslIds) == false) {
// return;
// }
//
// if (std::find(sslIds.begin(), sslIds.end(), peerId.toStdString()) != sslIds.end()) {
// /* One of the ssl ids of the gpg id */
// QPixmap avatar;
// AvatarDefs::getAvatarFromGpgId(mId, avatar, defaultAvatar);
// setPixmap(avatar);
// }
//
// return;
//}
/* Is this one of the ssl ids of the gpg id ? */
std::list<std::string> sslIds;
if (rsPeers->getAssociatedSSLIds(mId, sslIds) == false) {
return;
}
if (std::find(sslIds.begin(), sslIds.end(), peerId.toStdString()) != sslIds.end()) {
/* One of the ssl ids of the gpg id */
QPixmap avatar;
AvatarDefs::getAvatarFromGpgId(mId, avatar, defaultAvatar);
setPixmap(avatar);
}
return;
}
if (mId == peerId.toStdString()) {
if (mId.toStdString() == peerId.toStdString()) {
QPixmap avatar;
AvatarDefs::getAvatarFromSslId(mId, avatar, defaultAvatar);
AvatarDefs::getAvatarFromSslId(mId.toStdString(), avatar, defaultAvatar);
setPixmap(avatar);
return;
}
@ -238,6 +238,6 @@ void AvatarWidget::updateAvatar(const QString &peerId)
void AvatarWidget::updateOwnAvatar()
{
if (mFlag.isOwnId) {
updateAvatar(QString::fromStdString(mId));
updateAvatar(QString::fromStdString(mId.toStdString()));
}
}

View file

@ -24,6 +24,7 @@
#include <QLabel>
#include <stdint.h>
#include <retroshare/rstypes.h>
namespace Ui {
class AvatarWidget;
@ -47,8 +48,8 @@ public:
QString frameState();
void setFrameType(FrameType type);
void setId(const std::string& id, bool isGpg);
void setOwnId();
void setId(const RsPeerId &id) ;
void setOwnId();
void setDefaultAvatar(const QString &avatar);
protected:
@ -65,10 +66,11 @@ private:
QString defaultAvatar;
Ui::AvatarWidget *ui;
std::string mId;
RsPeerId mId;
struct {
bool isOwnId : 1;
bool isGpg : 1;
// bool isGpg : 1;
} mFlag;
FrameType mFrameType;
uint32_t mPeerState;

View file

@ -429,7 +429,7 @@ void FriendList::peerTreeWidgetCostumPopupMenu()
GroupDefs::sortByName(groupInfoList);
std::string gpgId = getRsId(c);
RsPgpId gpgId ( getRsId(c));
QTreeWidgetItem *parent = c->parent();
@ -600,7 +600,7 @@ void FriendList::insertPeers()
}
// get ids of existing private chat messages
std::list<std::string> privateChatIds;
std::list<RsPeerId> privateChatIds;
rsMsgs->getPrivateChatQueueIds(true, privateChatIds);
// get existing groups
@ -608,13 +608,13 @@ void FriendList::insertPeers()
std::list<RsGroupInfo>::iterator groupIt;
rsPeers->getGroupInfoList(groupInfoList);
std::list<std::string> gpgFriends;
std::list<std::string>::iterator gpgIt;
std::list<RsPgpId> gpgFriends;
std::list<RsPgpId>::iterator gpgIt;
rsPeers->getGPGAcceptedList(gpgFriends);
//add own gpg id, if we have more than on location (ssl client)
std::list<std::string> ownSslContacts;
std::string ownId = rsPeers->getGPGOwnId();
std::list<RsPeerId> ownSslContacts;
RsPgpId ownId = rsPeers->getGPGOwnId();
rsPeers->getAssociatedSSLIds(ownId, ownSslContacts);
if (ownSslContacts.size() > 0) {
gpgFriends.push_back(ownId);
@ -632,7 +632,7 @@ void FriendList::insertPeers()
case TYPE_GPG:
{
QTreeWidgetItem *parent = item->parent();
std::string gpg_widget_id = getRsId(item);
RsPgpId gpg_widget_id ( getRsId(item));
// remove items that are not friends anymore
if (std::find(gpgFriends.begin(), gpgFriends.end(), gpg_widget_id) == gpgFriends.end()) {
@ -700,7 +700,7 @@ void FriendList::insertPeers()
}
}
std::list<std::string> fillGpgIds;
std::list<RsPgpId> fillGpgIds;
// start with groups
groupIt = groupInfoList.begin();
@ -752,7 +752,7 @@ void FriendList::insertPeers()
while (childIndex < childCount) {
QTreeWidgetItem *gpgItemLoop = groupItem->child(childIndex);
if (gpgItemLoop->type() == TYPE_GPG) {
if (std::find(groupInfo->peerIds.begin(), groupInfo->peerIds.end(), getRsId(gpgItemLoop)) == groupInfo->peerIds.end()) {
if (std::find(groupInfo->peerIds.begin(), groupInfo->peerIds.end(), RsPgpId(getRsId(gpgItemLoop))) == groupInfo->peerIds.end()) {
delete(groupItem->takeChild(groupItem->indexOfChild(gpgItemLoop)));
childCount = groupItem->childCount();
continue;
@ -771,7 +771,7 @@ void FriendList::insertPeers()
// iterate through gpg friends
for (gpgIt = gpgFriends.begin(); gpgIt != gpgFriends.end(); gpgIt++) {
std::string gpgId = *gpgIt;
RsPgpId gpgId = *gpgIt;
if (mShowGroups) {
if (groupInfo) {
@ -803,14 +803,14 @@ void FriendList::insertPeers()
int itemCount = groupItem ? groupItem->childCount() : peerTreeWidget->topLevelItemCount();
for (int index = 0; index < itemCount; index++) {
gpgItemLoop = groupItem ? groupItem->child(index) : peerTreeWidget->topLevelItem(index);
if (gpgItemLoop->type() == TYPE_GPG && getRsId(gpgItemLoop) == gpgId) {
if (gpgItemLoop->type() == TYPE_GPG && getRsId(gpgItemLoop) == gpgId.toStdString()) {
gpgItem = gpgItemLoop;
break;
}
}
RsPeerDetails detail;
if ((!rsPeers->getPeerDetails(gpgId, detail) || !detail.accept_connection) && detail.gpg_id != ownId) {
if ((!rsPeers->getGPGDetails(gpgId, detail) || !detail.accept_connection) && detail.gpg_id != ownId) {
// don't accept anymore connection, remove from the view
if (gpgItem) {
if (groupItem) {
@ -837,7 +837,7 @@ void FriendList::insertPeers()
gpgItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter);
/* not displayed, used to find back the item */
gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id));
gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.gpg_id.toStdString()));
}
if (mBigName && !mHideState && isStatusColumnHidden) {
@ -855,7 +855,7 @@ void FriendList::insertPeers()
int childIndex = 0;
while (childIndex < childCount) {
std::string ssl_id = getRsId(gpgItem->child(childIndex));
if (!rsPeers->isFriend(ssl_id)) {
if (!rsPeers->isFriend(RsPeerId(ssl_id))) {
delete (gpgItem->takeChild(childIndex));
// count again
childCount = gpgItem->childCount();
@ -870,23 +870,23 @@ void FriendList::insertPeers()
bool gpg_hasPrivateChat = false;
int bestPeerState = 0; // for gpg item
unsigned int bestRSState = 0; // for gpg item
std::string bestSslId; // for gpg item
RsPeerId bestSslId; // for gpg item
QString bestCustomStateString;// for gpg item
std::list<std::string> sslContacts;
std::list<RsPeerId> sslContacts;
QDateTime lastContact;
QString itemIP;
rsPeers->getAssociatedSSLIds(detail.gpg_id, sslContacts);
for (std::list<std::string>::iterator sslIt = sslContacts.begin(); sslIt != sslContacts.end(); sslIt++) {
for (std::list<RsPeerId>::iterator sslIt = sslContacts.begin(); sslIt != sslContacts.end(); sslIt++) {
QTreeWidgetItem *sslItem = NULL;
std::string sslId = *sslIt;
RsPeerId sslId = *sslIt;
//find the corresponding sslItem child item of the gpg item
bool newChild = true;
childCount = gpgItem->childCount();
for (int childIndex = 0; childIndex < childCount; childIndex++) {
// we assume, that only ssl items are child of the gpg item, so we don't need to test the type
if (getRsId(gpgItem->child(childIndex)) == sslId) {
if (getRsId(gpgItem->child(childIndex)) == sslId.toStdString()) {
sslItem = gpgItem->child(childIndex);
newChild = false;
break;
@ -917,7 +917,7 @@ void FriendList::insertPeers()
}
/* not displayed, used to find back the item */
sslItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(sslDetail.id));
sslItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(sslDetail.id.toStdString()));
QString sText;
QString customStateString;
@ -1146,7 +1146,7 @@ void FriendList::insertPeers()
// only set the avatar image the first time, or when it changed
// otherwise getAvatarFromSslId sends request packages to peers.
QPixmap avatar;
AvatarDefs::getAvatarFromSslId(bestSslId, avatar);
AvatarDefs::getAvatarFromSslId(bestSslId.toStdString(), avatar);
QIcon avatar_icon(avatar);
gpgItem->setIcon(COLUMN_AVATAR, avatar_icon);
}
@ -1160,7 +1160,7 @@ void FriendList::insertPeers()
gpgItem->setData(COLUMN_IP, Qt::DisplayRole, QVariant());
gpgItem->setData(COLUMN_IP, ROLE_SORT, "2 " + itemIP);
if (openPeers != NULL && openPeers->find(gpgId) != openPeers->end()) {
if (openPeers != NULL && openPeers->find(gpgId.toStdString()) != openPeers->end()) {
gpgItem->setExpanded(true);
}
}
@ -1287,7 +1287,7 @@ void FriendList::chatfriend(QTreeWidgetItem *pPeer)
}
std::string id = getRsId(pPeer);
ChatDialog::chatFriend(id);
ChatDialog::chatFriend(RsPeerId(id));
}
void FriendList::addFriend()
@ -1311,7 +1311,8 @@ void FriendList::msgfriend()
return;
std::string id = getRsId(peer);
MessageComposer::msgFriend(id, (peer->type() == TYPE_GROUP));
MessageComposer::msgFriend(RsPeerId(id), (peer->type() == TYPE_GROUP));
}
void FriendList::recommendfriend()
@ -1322,14 +1323,15 @@ void FriendList::recommendfriend()
return;
std::string peerId = getRsId(peer);
std::list<std::string> ids;
std::list<RsPeerId> ids;
switch (peer->type()) {
switch (peer->type())
{
case TYPE_SSL:
ids.push_back(peerId);
ids.push_back(RsPeerId(peerId));
break;
case TYPE_GPG:
rsPeers->getAssociatedSSLIds(peerId, ids);
rsPeers->getAssociatedSSLIds(RsPgpId(peerId), ids);
break;
default:
return;
@ -1348,8 +1350,9 @@ void FriendList::copyFullCertificate()
{
QTreeWidgetItem *c = getCurrentPeer();
QList<RetroShareLink> urls;
RetroShareLink link ;
link.createCertificate(getRsId(c)) ;
RetroShareLink link ;
link.createCertificate(RsPeerId(getRsId(c))) ;
urls.push_back(link);
std::cerr << "link: " << std::endl;
@ -1464,9 +1467,12 @@ void FriendList::removefriend()
if (rsPeers)
{
if(RsPgpId(getRsId(c)).isNull())
return ;
if ((QMessageBox::question(this, "RetroShare", tr("Do you want to remove this Friend?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes)) == QMessageBox::Yes)
{
rsPeers->removeFriend(getRsId(c));
rsPeers->removeFriend(RsPgpId(getRsId(c)));
}
}
}
@ -1492,22 +1498,22 @@ void FriendList::connectfriend()
for (int childIndex = 0; childIndex < childCount; childIndex++) {
QTreeWidgetItem *item = c->child(childIndex);
if (item->type() == TYPE_SSL) {
rsPeers->connectAttempt(getRsId(item));
rsPeers->connectAttempt(RsPeerId(getRsId(item)));
item->setIcon(COLUMN_NAME,(QIcon(IMAGE_CONNECT2)));
// Launch ProgressDialog, only if single SSL child.
if (childCount == 1)
{
ConnectProgressDialog::showProgress(getRsId(item));
ConnectProgressDialog::showProgress(RsPeerId(getRsId(item)));
}
}
}
} else {
//this is a SSL key
rsPeers->connectAttempt(getRsId(c));
rsPeers->connectAttempt(RsPeerId(getRsId(c)));
c->setIcon(COLUMN_NAME,(QIcon(IMAGE_CONNECT2)));
// Launch ProgressDialog.
ConnectProgressDialog::showProgress(getRsId(c));
ConnectProgressDialog::showProgress(RsPeerId(getRsId(c)));
}
}
}
@ -1515,7 +1521,12 @@ void FriendList::connectfriend()
/* GUI stuff -> don't do anything directly with Control */
void FriendList::configurefriend()
{
ConfCertDialog::showIt(getRsId(getCurrentPeer()), ConfCertDialog::PageDetails);
if(!RsPeerId(getRsId(getCurrentPeer())).isNull())
ConfCertDialog::showIt(RsPeerId(getRsId(getCurrentPeer())), ConfCertDialog::PageDetails);
else if(!RsPgpId(getRsId(getCurrentPeer())).isNull())
ConfCertDialog::showIt(RsPgpId(getRsId(getCurrentPeer())), ConfCertDialog::PageDetails);
else
std::cerr << "FriendList::configurefriend: id is not an SSL nor a PGP id." << std::endl;
}
// void FriendList::showLobby()
@ -1548,7 +1559,7 @@ void FriendList::configurefriend()
// ChatDialog::closeChat(vpeer_id);
// }
void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list<std::string> &sslIds)
void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list<RsPeerId> &sslIds)
{
if (item == NULL) {
return;
@ -1558,16 +1569,16 @@ void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list<std::string>
switch (item->type()) {
case TYPE_SSL:
sslIds.push_back(peerId);
sslIds.push_back(RsPeerId(peerId));
break;
case TYPE_GPG:
rsPeers->getAssociatedSSLIds(peerId, sslIds);
rsPeers->getAssociatedSSLIds(RsPgpId(peerId), sslIds);
break;
case TYPE_GROUP:
{
RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(peerId, groupInfo)) {
std::list<std::string>::iterator gpgIt;
std::list<RsPgpId>::iterator gpgIt;
for (gpgIt = groupInfo.peerIds.begin(); gpgIt != groupInfo.peerIds.end(); ++gpgIt) {
rsPeers->getAssociatedSSLIds(*gpgIt, sslIds);
}
@ -1577,42 +1588,6 @@ void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list<std::string>
}
}
#ifdef TO_REMOVE
void FriendList::inviteToLobby()
{
QTreeWidgetItem *c = getCurrentPeer();
std::list<std::string> sslIds;
getSslIdsFromItem(c, sslIds);
std::string lobby_id = qobject_cast<QAction*>(sender())->data().toString().toStdString();
if (lobby_id.empty())
return;
ChatLobbyId lobbyId = QString::fromStdString(lobby_id).toULongLong();
// add to group
std::list<std::string>::iterator it;
for (it = sslIds.begin(); it != sslIds.end(); ++it) {
rsMsgs->invitePeerToLobby(lobbyId, *it);
}
std::string vpeer_id;
if (rsMsgs->getVirtualPeerId(lobbyId, vpeer_id))
ChatDialog::chatFriend(vpeer_id);
}
void FriendList::createchatlobby()
{
QTreeWidgetItem *c = getCurrentPeer();
std::list<std::string> sslIds;
getSslIdsFromItem(c, sslIds);
CreateLobbyDialog(sslIds).exec();
}
#endif
void FriendList::addToGroup()
{
QTreeWidgetItem *c = getCurrentPeer();
@ -1626,9 +1601,9 @@ void FriendList::addToGroup()
}
std::string groupId = qobject_cast<QAction*>(sender())->data().toString().toStdString();
std::string gpgId = getRsId(c);
RsPgpId gpgId ( getRsId(c));
if (gpgId.empty() || groupId.empty()) {
if (gpgId.isNull() || groupId.empty()) {
return;
}
@ -1652,9 +1627,9 @@ void FriendList::moveToGroup()
}
std::string groupId = qobject_cast<QAction*>(sender())->data().toString().toStdString();
std::string gpgId = getRsId(c);
RsPgpId gpgId ( getRsId(c));
if (gpgId.empty() || groupId.empty()) {
if (gpgId.isNull() || groupId.empty()) {
return;
}
@ -1681,9 +1656,9 @@ void FriendList::removeFromGroup()
}
std::string groupId = qobject_cast<QAction*>(sender())->data().toString().toStdString();
std::string gpgId = getRsId(c);
RsPgpId gpgId ( getRsId(c));
if (gpgId.empty()) {
if (gpgId.isNull()) {
return;
}

View file

@ -125,7 +125,7 @@ private:
static bool filterItem(QTreeWidgetItem *item, const QString &text);
void updateHeader();
void initializeHeader(bool afterLoadSettings);
void getSslIdsFromItem(QTreeWidgetItem *item, std::list<std::string> &sslIds);
void getSslIdsFromItem(QTreeWidgetItem *item, std::list<RsPeerId> &sslIds);
private slots:
void groupsChanged();

View file

@ -4,25 +4,48 @@
#include <QDialogButtonBox>
#include "FriendSelectionDialog.h"
std::list<std::string> 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)
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,pre_selected_id_type,pre_selected_ids) ;
std::list<std::string> psids ;
for(std::list<RsPgpId>::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it)
psids.push_back( (*it).toStdString() ) ;
dialog.setWindowTitle(caption) ;
FriendSelectionDialog dialog(parent,header_text,modus,show_type,FriendSelectionWidget::IDTYPE_GPG,psids) ;
if(QDialog::Rejected == dialog.exec())
return std::list<std::string>() ;
dialog.setWindowTitle(caption) ;
std::list<std::string> ids ;
dialog.friends_widget->selectedIds(pre_selected_id_type,ids,false) ;
if(QDialog::Rejected == dialog.exec())
return std::list<RsPgpId>() ;
return ids ;
std::list<RsPgpId> sids ;
dialog.friends_widget->selectedIds<RsPgpId,FriendSelectionWidget::IDTYPE_GPG>(sids,false) ;
return sids ;
}
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)
{
std::list<std::string> psids ;
for(std::list<RsPeerId>::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it)
psids.push_back( (*it).toStdString() ) ;
FriendSelectionDialog dialog(parent,header_text,modus,show_type,FriendSelectionWidget::IDTYPE_SSL,psids) ;
dialog.setWindowTitle(caption) ;
if(QDialog::Rejected == dialog.exec())
return std::list<RsPeerId>() ;
std::list<RsPeerId> sids ;
dialog.friends_widget->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(sids,false) ;
return sids ;
}
FriendSelectionDialog::FriendSelectionDialog(QWidget *parent,const QString& header_text,
FriendSelectionWidget::Modus modus,
FriendSelectionWidget::ShowTypes show_type,

View file

@ -1,17 +1,22 @@
#pragma once
#include <QDialog>
#include <retroshare/rstypes.h>
#include <gui/common/FriendSelectionWidget.h>
class FriendSelectionDialog : public QDialog
{
public:
static std::list<std::string> selectFriends(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>()) ;
private:
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,
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,
FriendSelectionWidget::IdType pre_selected_id_type,

View file

@ -211,7 +211,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons
}
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
item->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id));
item->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id.toStdString()));
item->setData(COLUMN_DATA, ROLE_SORT, "2 " + name);
}
@ -233,19 +233,19 @@ void FriendSelectionWidget::secured_fillList()
mInFillList = true;
// get selected items
std::list<std::string> sslIdsSelected;
std::list<RsPeerId> sslIdsSelected;
if (mShowTypes & SHOW_SSL) {
selectedSslIds(sslIdsSelected, true);
selectedIds<RsPeerId,IDTYPE_SSL>(sslIdsSelected,true);
}
std::list<std::string> groupIdsSelected;
if (mShowTypes & SHOW_GROUP) {
selectedGroupIds(groupIdsSelected);
selectedIds<std::string,IDTYPE_GROUP>(groupIdsSelected,true);
}
std::list<std::string> gpgIdsSelected;
std::list<RsPgpId> gpgIdsSelected;
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) {
selectedGpgIds(gpgIdsSelected, true);
selectedIds<RsPgpId,IDTYPE_GPG>(gpgIdsSelected,true);
}
// remove old items
@ -256,16 +256,16 @@ void FriendSelectionWidget::secured_fillList()
std::list<RsGroupInfo>::iterator groupIt;
rsPeers->getGroupInfoList(groupInfoList);
std::list<std::string> gpgIds;
std::list<std::string>::iterator gpgIt;
std::list<RsPgpId> gpgIds;
std::list<RsPgpId>::iterator gpgIt;
if(mShowTypes & SHOW_NON_FRIEND_GPG)
rsPeers->getGPGAllList(gpgIds);
else
rsPeers->getGPGAcceptedList(gpgIds);
std::list<std::string> sslIds;
std::list<std::string>::iterator sslIt;
std::list<RsPeerId> sslIds;
std::list<RsPeerId>::iterator sslIt;
if ((mShowTypes & (SHOW_SSL | SHOW_GPG)) == SHOW_SSL) {
rsPeers->getFriendList(sslIds);
@ -333,16 +333,16 @@ void FriendSelectionWidget::secured_fillList()
}
} else {
// we fill the not assigned gpg ids
if (std::find(filledIds.begin(), filledIds.end(), *gpgIt) != filledIds.end()) {
if (std::find(filledIds.begin(), filledIds.end(), (*gpgIt).toStdString()) != filledIds.end()) {
continue;
}
}
// add equal too, its no problem
filledIds.push_back(*gpgIt);
filledIds.push_back((*gpgIt).toStdString());
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(*gpgIt, detail)) {
if (!rsPeers->getGPGDetails(*gpgIt, detail)) {
continue; /* BAD */
}
@ -350,7 +350,7 @@ void FriendSelectionWidget::secured_fillList()
gpgItem = new RSTreeWidgetItem(mCompareRole, IDTYPE_GPG);
QString name = QString::fromUtf8(detail.name.c_str());
gpgItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString(*gpgIt)+")");
gpgItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString( (*gpgIt).toStdString() )+")");
sslIds.clear();
rsPeers->getAssociatedSSLIds(*gpgIt, sslIds);
@ -371,7 +371,7 @@ void FriendSelectionWidget::secured_fillList()
gpgItem->setFlags(Qt::ItemIsUserCheckable | gpgItem->flags());
gpgItem->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.gpg_id));
gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.gpg_id.toStdString()));
gpgItem->setData(COLUMN_DATA, ROLE_SORT, "2 " + name);
if (mListModus == MODUS_CHECK) {
@ -387,7 +387,7 @@ void FriendSelectionWidget::secured_fillList()
gpgItem->setExpanded(true);
emit itemAdded(IDTYPE_GPG, QString::fromStdString(detail.gpg_id), gpgItem);
emit itemAdded(IDTYPE_GPG, QString::fromStdString(detail.gpg_id.toStdString()), gpgItem);
if (mShowTypes & SHOW_SSL) {
// iterate through associated ssl ids
@ -410,7 +410,7 @@ void FriendSelectionWidget::secured_fillList()
// add to the list
gpgItem->addChild(item);
emit itemAdded(IDTYPE_SSL, QString::fromStdString(detail.id), item);
emit itemAdded(IDTYPE_SSL, QString::fromStdString(detail.id.toStdString()), item);
if (std::find(sslIdsSelected.begin(), sslIdsSelected.end(), detail.id) != sslIdsSelected.end()) {
setSelected(mListModus, item, true);
@ -437,13 +437,13 @@ void FriendSelectionWidget::secured_fillList()
}
} else {
// we fill the not assigned ssl ids
if (std::find(filledIds.begin(), filledIds.end(), *sslIt) != filledIds.end()) {
if (std::find(filledIds.begin(), filledIds.end(), (*sslIt).toStdString()) != filledIds.end()) {
continue;
}
}
// add equal too, its no problem
filledIds.push_back(detail.id);
filledIds.push_back(detail.id.toStdString());
// make a widget per friend
QTreeWidgetItem *item = new RSTreeWidgetItem(mCompareRole, IDTYPE_SSL);
@ -462,7 +462,7 @@ void FriendSelectionWidget::secured_fillList()
ui->friendList->addTopLevelItem(item);
}
emit itemAdded(IDTYPE_SSL, QString::fromStdString(detail.id), item);
emit itemAdded(IDTYPE_SSL, QString::fromStdString(detail.id.toStdString()), item);
if (std::find(sslIdsSelected.begin(), sslIdsSelected.end(), detail.id) != sslIdsSelected.end()) {
setSelected(mListModus, item, true);
@ -503,18 +503,20 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
if(RsAutoUpdatePage::eventsLocked())
return ;
RsPeerId peerid(peerId.toStdString()) ;
QString gpgId;
int gpgStatus = RS_STATUS_OFFLINE;
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) {
/* need gpg id and online state */
RsPeerDetails detail;
if (rsPeers->getPeerDetails(peerId.toStdString(), detail)) {
gpgId = QString::fromStdString(detail.gpg_id);
if (rsPeers->getPeerDetails(peerid, detail))
{
gpgId = QString::fromStdString(detail.gpg_id.toStdString());
if (status == (int) RS_STATUS_OFFLINE) {
/* try other locations */
std::list<std::string> sslIds;
std::list<RsPeerId> sslIds;
rsPeers->getAssociatedSSLIds(detail.gpg_id, sslIds);
std::list<StatusInfo> statusInfo;

View file

@ -76,14 +76,23 @@ public:
void start();
int selectedItemCount();
std::string selectedId(IdType &idType);
void selectedSslIds(std::list<std::string> &sslIds, bool onlyDirectSelected) { selectedIds(IDTYPE_SSL, sslIds, onlyDirectSelected); }
void selectedGpgIds(std::list<std::string> &gpgIds, bool onlyDirectSelected) { selectedIds(IDTYPE_GPG, gpgIds, onlyDirectSelected); }
void selectedGroupIds(std::list<std::string> &groupIds) { selectedIds(IDTYPE_GROUP, groupIds, true); }
std::string selectedId(IdType &idType);
void setSelectedSslIds(const std::list<std::string> &sslIds, bool add) { setSelectedIds(IDTYPE_SSL, sslIds, add); }
void setSelectedGpgIds(const std::list<std::string> &gpgIds, bool add) { setSelectedIds(IDTYPE_GPG, gpgIds, add); }
void setSelectedGroupIds(const std::list<std::string> &groupIds, bool add) { setSelectedIds(IDTYPE_GROUP, groupIds, add); }
template<class ID_CLASS,FriendSelectionWidget::IdType TYPE> void selectedIds(std::list<ID_CLASS>& ids, bool onlyDirectSelected)
{
std::list<std::string> tmpids ;
selectedIds(TYPE, tmpids, onlyDirectSelected);
ids.clear() ;
for(std::list<std::string>::const_iterator it(tmpids.begin());it!=tmpids.end();++it)
ids.push_back(ID_CLASS(*it)) ;
}
template<class ID_CLASS,FriendSelectionWidget::IdType TYPE> void setSelectedIds(const std::list<ID_CLASS>& ids, bool add)
{
std::list<std::string> tmpids ;
for(typename std::list<ID_CLASS>::const_iterator it(ids.begin());it!=ids.end();++it)
tmpids.push_back((*it).toStdString()) ;
setSelectedIds(TYPE, tmpids, add);
}
void itemsFromId(IdType idType, const std::string &id, QList<QTreeWidgetItem*> &items);
void items(QList<QTreeWidgetItem*> &items, IdType = IDTYPE_NONE);

View file

@ -45,7 +45,7 @@ public:
QString filename;
QString filepath;
uint64_t size;
std::string hash;
RsFileHash hash;
Flags flag;
public:

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

@ -34,27 +34,33 @@ 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)
{
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;
std::string peerName = rsPeers->getPeerName(id);
std::string hash ;
DistantMsgPeerId pid ;
if(!peerName.empty())
{
@ -64,7 +70,7 @@ const QString PeerDefs::rsidFromId(const std::string &id, QString *name /* = NUL
*name = QString::fromUtf8(peerName.c_str());
}
}
else if(rsMsgs->getDistantMessageHash(rsPeers->getGPGOwnId(),hash) && hash == id)
else if(rsMsgs->getDistantMessagePeerId(rsPeers->getGPGOwnId(),pid) && pid == id)
{
// not a real peer. Try from hash for distant messages
@ -83,19 +89,43 @@ const QString PeerDefs::rsidFromId(const std::string &id, QString *name /* = NUL
return rsid;
}
const QString PeerDefs::rsidFromId(const RsPgpId &id, QString *name /* = NULL*/)
{
QString rsid;
const std::string PeerDefs::idFromRsid(const QString &rsid, bool check)
std::string peerName = rsPeers->getGPGName(id);
if(!peerName.empty())
{
rsid = PeerDefs::rsid(peerName, id);
if (name) {
*name = QString::fromUtf8(peerName.c_str());
}
}
else
{
rsid = PeerDefs::rsid("", id);
if (name)
*name = qApp->translate("PeerDefs", "Unknown");
}
return rsid;
}
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

@ -33,9 +33,11 @@ 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 rsidFromId(const std::string &id, QString *name = NULL);
static const std::string idFromRsid(const QString &rsid, bool check);
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 RsPgpId &id, QString *name = NULL);
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(), RsFileHash(dlinfo.hash.toStdString()), 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

@ -118,7 +118,7 @@ void RsCollectionFile::recursAddElements(QDomDocument& doc,const DirDetails& det
QDomElement f = doc.createElement("File") ;
f.setAttribute(QString("name"),QString::fromUtf8(details.name.c_str())) ;
f.setAttribute(QString("sha1"),QString::fromStdString(details.hash)) ;
f.setAttribute(QString("sha1"),QString::fromStdString(details.hash.toStdString())) ;
f.setAttribute(QString("size"),QString::number(details.count)) ;
e.appendChild(f) ;