mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-31 20:04:36 -04:00
merged remaining of v0.6-IdCleaning branch (7180->7213) to incorporate global router stuff in trunk
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7214 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0e6302ac6a
commit
1042744685
53 changed files with 2387 additions and 1904 deletions
|
@ -1114,19 +1114,28 @@ void MessagesDialog::insertMessages()
|
|||
|
||||
text.clear();
|
||||
|
||||
std::list<RsPeerId>::const_iterator pit;
|
||||
for (pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++)
|
||||
for(std::list<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); pit++)
|
||||
{
|
||||
if (text.isEmpty() == false) {
|
||||
if (!text.isEmpty())
|
||||
text += ", ";
|
||||
}
|
||||
|
||||
std::string peerName = rsPeers->getPeerName(*pit);
|
||||
if (peerName.empty()) {
|
||||
if (peerName.empty())
|
||||
text += PeerDefs::rsid("", *pit);
|
||||
} else {
|
||||
else
|
||||
text += QString::fromUtf8(peerName.c_str());
|
||||
}
|
||||
for(std::list<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); pit++)
|
||||
{
|
||||
if (!text.isEmpty())
|
||||
text += ", ";
|
||||
|
||||
// We should improve this by showing the real names of each GXS id.
|
||||
std::string peerName = "GXS_id("+(*pit).toStdString() + ")" ;
|
||||
if (peerName.empty())
|
||||
text += PeerDefs::rsid("", *pit);
|
||||
else
|
||||
text += QString::fromUtf8(peerName.c_str());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;
|
||||
|
|
|
@ -221,7 +221,7 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
|
|||
contextMnu->addAction(QIcon(IMAGE_EXPORT), tr("Export my certificate..."), this, SLOT(on_actionExportKey_activated()));
|
||||
|
||||
contextMnu->addAction(QIcon(IMAGE_PEERDETAILS), tr("Peer details..."), this, SLOT(peerdetails()));
|
||||
contextMnu->addAction(QIcon(IMAGE_MESSAGE), tr("Send Message"), this, SLOT(sendDistantMessage()));
|
||||
//contextMnu->addAction(QIcon(IMAGE_MESSAGE), tr("Send Message"), this, SLOT(sendDistantMessage()));
|
||||
contextMnu->addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyLink()));
|
||||
contextMnu->addSeparator() ;
|
||||
contextMnu->addAction(QIcon(IMAGE_CLEAN_UNUSED), tr("Remove unused keys..."), this, SLOT(removeUnusedKeys()));
|
||||
|
@ -352,30 +352,30 @@ void NetworkDialog::copyLink()
|
|||
RSLinkClipboard::copyLinks(urls);
|
||||
}
|
||||
|
||||
void NetworkDialog::sendDistantMessage()
|
||||
{
|
||||
QTreeWidgetItem *wi = getCurrentNeighbour();
|
||||
if (wi == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MessageComposer *nMsgDialog = MessageComposer::newMsg();
|
||||
if (nMsgDialog == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
DistantMsgPeerId pid ;
|
||||
RsPgpId mGpgId(wi->text(COLUMN_PEERID).toStdString()) ;
|
||||
|
||||
if(rsMsgs->getDistantMessagePeerId(mGpgId,pid))
|
||||
{
|
||||
nMsgDialog->addRecipient(MessageComposer::TO, pid, mGpgId);
|
||||
nMsgDialog->show();
|
||||
nMsgDialog->activateWindow();
|
||||
}
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
//void NetworkDialog::sendDistantMessage()
|
||||
//{
|
||||
// QTreeWidgetItem *wi = getCurrentNeighbour();
|
||||
// if (wi == NULL) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// MessageComposer *nMsgDialog = MessageComposer::newMsg();
|
||||
// if (nMsgDialog == NULL) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// DistantMsgPeerId pid ;
|
||||
// RsPgpId mGpgId(wi->text(COLUMN_PEERID).toStdString()) ;
|
||||
//
|
||||
// if(rsMsgs->getDistantMessagePeerId(mGpgId,pid))
|
||||
// {
|
||||
// nMsgDialog->addRecipient(MessageComposer::TO, pid, mGpgId);
|
||||
// nMsgDialog->show();
|
||||
// nMsgDialog->activateWindow();
|
||||
// }
|
||||
//
|
||||
// /* window will destroy itself! */
|
||||
//}
|
||||
|
||||
void NetworkDialog::updateDisplay()
|
||||
{
|
||||
|
|
|
@ -72,7 +72,7 @@ private slots:
|
|||
// void deleteCert() ;
|
||||
void peerdetails();
|
||||
void copyLink();
|
||||
void sendDistantMessage();
|
||||
// void sendDistantMessage();
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void connectTreeWidgetCostumPopupMenu( QPoint point );
|
||||
//void unvalidGPGKeyWidgetCostumPopupMenu( QPoint point );
|
||||
|
|
|
@ -565,7 +565,23 @@ bool RetroShareLink::createMessage(const RsPeerId& peerId, const QString& subjec
|
|||
|
||||
return valid();
|
||||
}
|
||||
bool RetroShareLink::createMessage(const RsGxsId& peerId, const QString& subject)
|
||||
{
|
||||
clear();
|
||||
|
||||
_hash = QString::fromStdString(peerId.toStdString());
|
||||
|
||||
//PeerDefs::rsidFromId(peerId, &_name);
|
||||
_name = QString::fromStdString("GXS_id("+peerId.toStdString()+")") ;
|
||||
// do something better here!!
|
||||
_subject = subject;
|
||||
|
||||
_type = TYPE_MESSAGE;
|
||||
|
||||
check();
|
||||
|
||||
return valid();
|
||||
}
|
||||
void RetroShareLink::clear()
|
||||
{
|
||||
_valid = false;
|
||||
|
@ -1507,14 +1523,15 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
|||
{
|
||||
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);
|
||||
msg->addRecipient(MessageComposer::TO, detail.id);
|
||||
if (link.subject().isEmpty() == false) {
|
||||
msg->setTitleText(link.subject());
|
||||
}
|
||||
msg->show();
|
||||
messageStarted.append(PeerDefs::nameWithLocation(detail));
|
||||
}
|
||||
else if(rsMsgs->getDistantMessagePeerId(detail.gpg_id,dm_pid))
|
||||
}
|
||||
#ifdef SUSPENDED
|
||||
else if(rsMsgs->getDistantMessagePeerId(detail.gpg_id,dm_pid))
|
||||
{
|
||||
MessageComposer *msg = MessageComposer::newMsg();
|
||||
msg->addRecipient(MessageComposer::TO, dm_pid,detail.gpg_id) ;
|
||||
|
@ -1525,7 +1542,8 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
|||
msg->show();
|
||||
messageStarted.append(PeerDefs::nameWithLocation(detail));
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
messageReceipientNotAccepted.append(PeerDefs::nameWithLocation(detail));
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include <retroshare/rstypes.h>
|
||||
#include <retroshare/rsgxsifacetypes.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
@ -79,7 +80,8 @@ 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 RsPeerId& peerId, const QString& subject);
|
||||
bool createMessage(const RsPeerId &peerId, const QString& subject);
|
||||
bool createMessage(const RsGxsId &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) ;
|
||||
|
|
|
@ -1312,7 +1312,7 @@ void FriendList::msgfriend()
|
|||
|
||||
std::string id = getRsId(peer);
|
||||
|
||||
MessageComposer::msgFriend(RsPeerId(id), (peer->type() == TYPE_GROUP));
|
||||
MessageComposer::msgFriend(RsPeerId(id)) ;
|
||||
}
|
||||
|
||||
void FriendList::recommendfriend()
|
||||
|
|
|
@ -46,6 +46,27 @@ std::list<RsPeerId> FriendSelectionDialog::selectFriends_SSL(QWidget *parent,con
|
|||
|
||||
return sids ;
|
||||
}
|
||||
std::list<RsGxsId> FriendSelectionDialog::selectFriends_GXS(QWidget *parent,const QString& caption,const QString& header_text,
|
||||
FriendSelectionWidget::Modus modus,
|
||||
FriendSelectionWidget::ShowTypes show_type,
|
||||
const std::list<RsGxsId>& pre_selected_ids)
|
||||
{
|
||||
std::list<std::string> psids ;
|
||||
for(std::list<RsGxsId>::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<RsGxsId>() ;
|
||||
|
||||
std::list<RsGxsId> sids ;
|
||||
dialog.friends_widget->selectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(sids,false) ;
|
||||
|
||||
return sids ;
|
||||
}
|
||||
FriendSelectionDialog::FriendSelectionDialog(QWidget *parent,const QString& header_text,
|
||||
FriendSelectionWidget::Modus modus,
|
||||
FriendSelectionWidget::ShowTypes show_type,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include <retroshare/rstypes.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include <gui/common/FriendSelectionWidget.h>
|
||||
|
||||
class FriendSelectionDialog : public QDialog
|
||||
|
@ -9,13 +10,19 @@ class FriendSelectionDialog : public QDialog
|
|||
public:
|
||||
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::ShowTypes = FriendSelectionWidget::SHOW_GROUP,
|
||||
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>()) ;
|
||||
|
||||
static std::list<RsGxsId> selectFriends_GXS(QWidget *parent,const QString& caption,const QString& header_string,
|
||||
FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI,
|
||||
FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_GXS,
|
||||
const std::list<RsGxsId>& pre_selected_ids = std::list<RsGxsId>()) ;
|
||||
|
||||
private:
|
||||
virtual ~FriendSelectionDialog() ;
|
||||
FriendSelectionDialog(QWidget *parent,const QString& header_string,FriendSelectionWidget::Modus modus,FriendSelectionWidget::ShowTypes show_type,
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#define COLUMN_DATA 0
|
||||
#define COLUMN_COUNT 1
|
||||
|
||||
#define IDDIALOG_IDLIST 1
|
||||
|
||||
#define ROLE_ID Qt::UserRole
|
||||
#define ROLE_SORT Qt::UserRole + 1
|
||||
|
||||
|
@ -73,9 +75,8 @@ static void setSelected(FriendSelectionWidget::Modus modus, QTreeWidgetItem *ite
|
|||
}
|
||||
}
|
||||
|
||||
FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::FriendSelectionWidget)
|
||||
FriendSelectionWidget::FriendSelectionWidget(QWidget *parent)
|
||||
: RsGxsUpdateBroadcastPage(rsIdentity,parent), ui(new Ui::FriendSelectionWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
@ -87,6 +88,8 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) :
|
|||
mInSslItemChanged = false;
|
||||
mInFillList = false;
|
||||
|
||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||
|
||||
connect(ui->friendList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
|
||||
connect(ui->friendList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int)));
|
||||
connect(ui->friendList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*,int)));
|
||||
|
@ -228,6 +231,34 @@ void FriendSelectionWidget::fillList()
|
|||
secured_fillList() ;
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::loadRequest(const TokenQueue */*queue*/, const TokenRequest &req)
|
||||
{
|
||||
// store all IDs locally, and call fillList() ;
|
||||
|
||||
uint32_t token = req.mToken ;
|
||||
|
||||
RsGxsIdGroup data;
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
std::vector<RsGxsIdGroup>::iterator vit;
|
||||
|
||||
if (!rsIdentity->getGroupData(token, datavector))
|
||||
{
|
||||
std::cerr << "FriendSelectionWidget::loadRequest() ERROR. Cannot load data from rsIdentity." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
gxsIds.clear() ;
|
||||
|
||||
for(uint32_t i=0;i<datavector.size();++i)
|
||||
{
|
||||
gxsIds.push_back(datavector[i].mMeta.mGroupId) ;
|
||||
std::cerr << " got ID = " << datavector[i].mMeta.mGroupId << std::endl;
|
||||
}
|
||||
|
||||
std::cerr << "Got all " << datavector.size() << " ids from rsIdentity. Calling update of list." << std::endl;
|
||||
fillList() ;
|
||||
}
|
||||
|
||||
void FriendSelectionWidget::secured_fillList()
|
||||
{
|
||||
mInFillList = true;
|
||||
|
@ -248,6 +279,10 @@ void FriendSelectionWidget::secured_fillList()
|
|||
selectedIds<RsPgpId,IDTYPE_GPG>(gpgIdsSelected,true);
|
||||
}
|
||||
|
||||
std::list<RsGxsId> gxsIdsSelected;
|
||||
if (mShowTypes & SHOW_GXS)
|
||||
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true);
|
||||
|
||||
// remove old items
|
||||
ui->friendList->clear();
|
||||
|
||||
|
@ -282,9 +317,11 @@ void FriendSelectionWidget::secured_fillList()
|
|||
while (true) {
|
||||
QTreeWidgetItem *groupItem = NULL;
|
||||
QTreeWidgetItem *gpgItem = NULL;
|
||||
RsGroupInfo *groupInfo = NULL;
|
||||
QTreeWidgetItem *gxsItem = NULL;
|
||||
RsGroupInfo *groupInfo = NULL;
|
||||
|
||||
if ((mShowTypes & SHOW_GROUP) && groupIt != groupInfoList.end()) {
|
||||
if ((mShowTypes & SHOW_GROUP) && groupIt != groupInfoList.end())
|
||||
{
|
||||
groupInfo = &(*groupIt);
|
||||
|
||||
if (groupInfo->peerIds.size() == 0) {
|
||||
|
@ -323,7 +360,8 @@ void FriendSelectionWidget::secured_fillList()
|
|||
}
|
||||
}
|
||||
|
||||
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) {
|
||||
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG))
|
||||
{
|
||||
// iterate through gpg ids
|
||||
for (gpgIt = gpgIds.begin(); gpgIt != gpgIds.end(); gpgIt++) {
|
||||
if (groupInfo) {
|
||||
|
@ -422,7 +460,9 @@ void FriendSelectionWidget::secured_fillList()
|
|||
setSelected(mListModus, gpgItem, true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// iterate through ssl ids
|
||||
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
|
||||
RsPeerDetails detail;
|
||||
|
@ -470,6 +510,47 @@ void FriendSelectionWidget::secured_fillList()
|
|||
}
|
||||
}
|
||||
|
||||
if(mShowTypes & SHOW_GXS)
|
||||
{
|
||||
// iterate through gpg ids
|
||||
for (std::vector<RsGxsGroupId>::const_iterator gxsIt = gxsIds.begin(); gxsIt != gxsIds.end(); gxsIt++)
|
||||
{
|
||||
// we fill the not assigned gpg ids
|
||||
if (std::find(filledIds.begin(), filledIds.end(), (*gxsIt).toStdString()) != filledIds.end())
|
||||
continue;
|
||||
|
||||
// add equal too, its no problem
|
||||
filledIds.push_back((*gxsIt).toStdString());
|
||||
|
||||
RsIdentityDetails detail;
|
||||
if (!rsIdentity->getIdDetails(RsGxsId(*gxsIt), detail))
|
||||
continue; /* BAD */
|
||||
|
||||
// make a widget per friend
|
||||
gxsItem = new RSTreeWidgetItem(mCompareRole, IDTYPE_GXS);
|
||||
|
||||
QString name = QString::fromUtf8(detail.mNickname.c_str());
|
||||
gxsItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString( (*gxsIt).toStdString() )+")");
|
||||
|
||||
gxsItem->setTextColor(COLUMN_NAME, textColorOnline());
|
||||
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
|
||||
gxsItem->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(RS_STATUS_ONLINE)));
|
||||
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
|
||||
gxsItem->setData(COLUMN_DATA, ROLE_SORT, "2 " + name);
|
||||
|
||||
if (mListModus == MODUS_CHECK)
|
||||
gxsItem->setCheckState(0, Qt::Unchecked);
|
||||
|
||||
ui->friendList->addTopLevelItem(gxsItem);
|
||||
|
||||
gxsItem->setExpanded(true);
|
||||
|
||||
emit itemAdded(IDTYPE_GXS, QString::fromStdString(detail.mId.toStdString()), gxsItem);
|
||||
|
||||
if (std::find(gxsIdsSelected.begin(), gxsIdsSelected.end(), detail.mId) != gxsIdsSelected.end())
|
||||
setSelected(mListModus, gxsItem, true);
|
||||
}
|
||||
}
|
||||
if (groupIt != groupInfoList.end()) {
|
||||
groupIt++;
|
||||
} else {
|
||||
|
@ -488,6 +569,29 @@ void FriendSelectionWidget::secured_fillList()
|
|||
|
||||
emit contentChanged();
|
||||
}
|
||||
void FriendSelectionWidget::updateDisplay(bool)
|
||||
{
|
||||
requestGXSIdList() ;
|
||||
}
|
||||
void FriendSelectionWidget::requestGXSIdList()
|
||||
{
|
||||
if (!mIdQueue)
|
||||
return;
|
||||
|
||||
//mStateHelper->setLoading(IDDIALOG_IDLIST, true);
|
||||
//mStateHelper->setLoading(IDDIALOG_IDDETAILS, true);
|
||||
//mStateHelper->setLoading(IDDIALOG_REPLIST, true);
|
||||
|
||||
mIdQueue->cancelActiveRequestTokens(IDDIALOG_IDLIST);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
uint32_t token;
|
||||
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, IDDIALOG_IDLIST);
|
||||
}
|
||||
|
||||
|
||||
void FriendSelectionWidget::groupsChanged(int /*type*/)
|
||||
{
|
||||
|
@ -657,7 +761,8 @@ void FriendSelectionWidget::itemChanged(QTreeWidgetItem *item, int column)
|
|||
}
|
||||
break;
|
||||
case IDTYPE_GPG:
|
||||
{
|
||||
case IDTYPE_GXS:
|
||||
{
|
||||
if (mInGpgItemChanged) {
|
||||
break;
|
||||
}
|
||||
|
@ -790,7 +895,9 @@ void FriendSelectionWidget::selectedIds(IdType idType, std::list<std::string> &i
|
|||
}
|
||||
break;
|
||||
case IDTYPE_GPG:
|
||||
if (idType == IDTYPE_GPG) {
|
||||
case IDTYPE_GXS:
|
||||
if (idType == IDTYPE_GPG || idType == IDTYPE_GXS)
|
||||
{
|
||||
if (isSelected(mListModus, item)) {
|
||||
id = idFromItem(item);
|
||||
} else {
|
||||
|
@ -858,7 +965,8 @@ void FriendSelectionWidget::setSelectedIds(IdType idType, const std::list<std::s
|
|||
case IDTYPE_GROUP:
|
||||
case IDTYPE_GPG:
|
||||
case IDTYPE_SSL:
|
||||
if (idType == itemType) {
|
||||
case IDTYPE_GXS:
|
||||
if (idType == itemType) {
|
||||
if (std::find(ids.begin(), ids.end(), id) != ids.end()) {
|
||||
setSelected(mListModus, item, true);
|
||||
break;
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
#include <QWidget>
|
||||
#include <QDialog>
|
||||
|
||||
#include <gui/gxs/RsGxsUpdateBroadcastPage.h>
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
namespace Ui {
|
||||
class FriendSelectionWidget;
|
||||
}
|
||||
|
@ -33,7 +36,7 @@ class FriendSelectionWidget;
|
|||
class QTreeWidgetItem;
|
||||
class RSTreeWidgetItemCompareRole;
|
||||
|
||||
class FriendSelectionWidget : public QWidget
|
||||
class FriendSelectionWidget : public RsGxsUpdateBroadcastPage, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -45,7 +48,8 @@ public:
|
|||
IDTYPE_NONE,
|
||||
IDTYPE_GROUP,
|
||||
IDTYPE_SSL,
|
||||
IDTYPE_GPG
|
||||
IDTYPE_GPG,
|
||||
IDTYPE_GXS
|
||||
};
|
||||
|
||||
enum Modus
|
||||
|
@ -61,6 +65,7 @@ public:
|
|||
SHOW_GPG = 2,
|
||||
SHOW_SSL = 4,
|
||||
SHOW_NON_FRIEND_GPG = 8,
|
||||
SHOW_GXS =16
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(ShowTypes, ShowType)
|
||||
|
@ -107,6 +112,9 @@ public:
|
|||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
virtual void loadRequest(const TokenQueue *queue,const TokenRequest& req);
|
||||
virtual void updateDisplay(bool complete);
|
||||
|
||||
signals:
|
||||
void itemAdded(int idType, const QString &id, QTreeWidgetItem *item);
|
||||
void contentChanged();
|
||||
|
@ -132,6 +140,8 @@ private:
|
|||
void selectedIds(IdType idType, std::list<std::string> &ids, bool onlyDirectSelected);
|
||||
void setSelectedIds(IdType idType, const std::list<std::string> &ids, bool add);
|
||||
|
||||
void requestGXSIdList() ;
|
||||
|
||||
bool mStarted;
|
||||
RSTreeWidgetItemCompareRole *mCompareRole;
|
||||
Modus mListModus;
|
||||
|
@ -147,6 +157,9 @@ private:
|
|||
Ui::FriendSelectionWidget *ui;
|
||||
|
||||
friend class FriendSelectionDialog ;
|
||||
|
||||
std::vector<RsGxsGroupId> gxsIds ;
|
||||
TokenQueue *mIdQueue ;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(FriendSelectionWidget::ShowTypes)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QCoreApplication>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
#include "PeerDefs.h"
|
||||
|
||||
|
@ -42,6 +43,14 @@ const QString PeerDefs::rsid(const std::string &name, const RsPgpId &id)
|
|||
|
||||
return QString::fromUtf8(name.c_str()) + "@" + QString::fromStdString(id.toStdString());
|
||||
}
|
||||
const QString PeerDefs::rsid(const std::string &name, const RsGxsId &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 std::string &name, const RsPeerId &id)
|
||||
{
|
||||
if (name.empty()) {
|
||||
|
@ -60,32 +69,42 @@ const QString PeerDefs::rsidFromId(const RsPeerId &id, QString *name /* = NULL*/
|
|||
QString rsid;
|
||||
|
||||
std::string peerName = rsPeers->getPeerName(id);
|
||||
DistantMsgPeerId pid ;
|
||||
DistantMsgPeerId pid ;
|
||||
|
||||
if(!peerName.empty())
|
||||
{
|
||||
if(!peerName.empty())
|
||||
{
|
||||
rsid = PeerDefs::rsid(peerName, id);
|
||||
|
||||
if (name) {
|
||||
if (name)
|
||||
*name = QString::fromUtf8(peerName.c_str());
|
||||
}
|
||||
}
|
||||
else if(rsMsgs->getDistantMessagePeerId(rsPeers->getGPGOwnId(),pid) && pid == id)
|
||||
{
|
||||
// not a real peer. Try from hash for distant messages
|
||||
|
||||
peerName = rsPeers->getGPGName(rsPeers->getGPGOwnId()) ;
|
||||
rsid = PeerDefs::rsid(peerName, rsPeers->getGPGOwnId());
|
||||
if(name)
|
||||
*name = QString::fromUtf8(peerName.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
rsid = PeerDefs::rsid("", id);
|
||||
|
||||
if (name)
|
||||
*name = qApp->translate("PeerDefs", "Unknown");
|
||||
}
|
||||
return rsid ;
|
||||
|
||||
}
|
||||
|
||||
std::list<RsGxsId> gxs_ids ;
|
||||
rsIdentity->getOwnIds(gxs_ids) ;
|
||||
|
||||
for(std::list<RsGxsId>::const_iterator it(gxs_ids.begin());it!=gxs_ids.end();++it)
|
||||
if(RsPeerId(*it) == id)
|
||||
{
|
||||
// not a real peer. Try from hash for distant messages
|
||||
|
||||
RsIdentityDetails details ;
|
||||
if(!rsIdentity->getIdDetails(*it,details))
|
||||
continue ;
|
||||
|
||||
peerName = details.mNickname ;
|
||||
|
||||
rsid = PeerDefs::rsid(peerName, *it);
|
||||
if(name)
|
||||
*name = QString::fromUtf8(peerName.c_str());
|
||||
}
|
||||
|
||||
rsid = PeerDefs::rsid("", id);
|
||||
|
||||
if (name)
|
||||
*name = qApp->translate("PeerDefs", "Unknown");
|
||||
|
||||
return rsid;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#define _PEERDEFS_H
|
||||
|
||||
#include <QString>
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
class RsPeerDetails;
|
||||
|
||||
|
@ -35,6 +36,7 @@ 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 rsid(const std::string &name, const RsGxsId &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);
|
||||
|
|
|
@ -197,7 +197,7 @@ void ChatMsgItem::sendMsg()
|
|||
return;
|
||||
}
|
||||
|
||||
nMsgDialog->addRecipient(MessageComposer::TO, mPeerId, false);
|
||||
nMsgDialog->addRecipient(MessageComposer::TO, mPeerId);
|
||||
nMsgDialog->show();
|
||||
nMsgDialog->activateWindow();
|
||||
|
||||
|
@ -245,7 +245,7 @@ void ChatMsgItem::sendMessage()
|
|||
|
||||
mi.title = tr("Quick Message").toUtf8().constData();
|
||||
mi.msg = quickmsgText->toHtml().toUtf8().constData();
|
||||
mi.msgto.push_back(mPeerId);
|
||||
mi.rspeerid_msgto.push_back(mPeerId);
|
||||
|
||||
rsMsgs->MessageSend(mi);
|
||||
|
||||
|
|
|
@ -81,16 +81,16 @@ void MsgItem::updateItemStatic()
|
|||
return;
|
||||
|
||||
/* get peer Id */
|
||||
mPeerId = mi.srcId;
|
||||
mPeerId = mi.rspeerid_srcId;
|
||||
|
||||
avatar->setId(mPeerId);
|
||||
|
||||
QString title;
|
||||
QString srcName;
|
||||
if ((mi.msgflags & RS_MSG_SYSTEM) && mi.srcId == rsPeers->getOwnId()) {
|
||||
if ((mi.msgflags & RS_MSG_SYSTEM) && mi.rspeerid_srcId == rsPeers->getOwnId()) {
|
||||
srcName = "RetroShare";
|
||||
} else {
|
||||
srcName = QString::fromUtf8(rsPeers->getPeerName(mi.srcId).c_str());
|
||||
srcName = QString::fromUtf8(rsPeers->getPeerName(mi.rspeerid_srcId).c_str());
|
||||
}
|
||||
|
||||
timestampLabel->setText(DateTime::formatLongDateTime(mi.ts));
|
||||
|
@ -138,7 +138,7 @@ void MsgItem::updateItemStatic()
|
|||
for(it = mi.files.begin(); it != mi.files.end(); it++)
|
||||
{
|
||||
/* add file */
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size, SFI_STATE_REMOTE, mi.srcId);
|
||||
SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size, SFI_STATE_REMOTE, mi.rspeerid_srcId);
|
||||
mFileItems.push_back(fi);
|
||||
|
||||
QLayout *layout = expandFrame->layout();
|
||||
|
|
|
@ -275,7 +275,7 @@ void PeerItem::sendMsg()
|
|||
return;
|
||||
}
|
||||
|
||||
nMsgDialog->addRecipient(MessageComposer::TO, mPeerId, false);
|
||||
nMsgDialog->addRecipient(MessageComposer::TO, mPeerId);
|
||||
nMsgDialog->show();
|
||||
nMsgDialog->activateWindow();
|
||||
|
||||
|
@ -314,7 +314,7 @@ void PeerItem::sendMessage()
|
|||
|
||||
mi.title = tr("Quick Message").toUtf8().constData();
|
||||
mi.msg = quickmsgText->toHtml().toUtf8().constData();
|
||||
mi.msgto.push_back(mPeerId);
|
||||
mi.rspeerid_msgto.push_back(mPeerId);
|
||||
|
||||
rsMsgs->MessageSend(mi);
|
||||
|
||||
|
|
|
@ -375,6 +375,8 @@ void SecurityItem::sendMsg()
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": suspended for now." << std::endl;
|
||||
#ifdef SUSPENDED
|
||||
MessageComposer *nMsgDialog = MessageComposer::newMsg();
|
||||
if (nMsgDialog == NULL) {
|
||||
return;
|
||||
|
@ -389,7 +391,8 @@ void SecurityItem::sendMsg()
|
|||
nMsgDialog->activateWindow();
|
||||
}
|
||||
|
||||
/* window will destroy itself! */
|
||||
/* window will destroy itself! */
|
||||
#endif
|
||||
}
|
||||
|
||||
void SecurityItem::openChat()
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rsstatus.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/common/RSTreeWidgetItem.h"
|
||||
|
@ -73,9 +74,6 @@
|
|||
|
||||
#define COLOR_CONNECT Qt::blue
|
||||
|
||||
#define TYPE_GROUP 0
|
||||
#define TYPE_SSL 1
|
||||
|
||||
#define COLUMN_RECIPIENT_TYPE 0
|
||||
#define COLUMN_RECIPIENT_ICON 1
|
||||
#define COLUMN_RECIPIENT_NAME 2
|
||||
|
@ -83,7 +81,7 @@
|
|||
#define COLUMN_RECIPIENT_DATA COLUMN_RECIPIENT_ICON // the column with a QTableWidgetItem
|
||||
|
||||
#define ROLE_RECIPIENT_ID Qt::UserRole
|
||||
#define ROLE_RECIPIENT_GROUP Qt::UserRole + 1
|
||||
#define ROLE_RECIPIENT_TYPE Qt::UserRole + 1
|
||||
|
||||
#define COLUMN_FILE_CHECKED 0
|
||||
#define COLUMN_FILE_NAME 0
|
||||
|
@ -215,7 +213,8 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
|
|||
ui.friendSelectionWidget->setModus(FriendSelectionWidget::MODUS_MULTI);
|
||||
ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP
|
||||
| FriendSelectionWidget::SHOW_SSL
|
||||
| (ui.onlyTrustedKeys->isChecked()? FriendSelectionWidget::SHOW_NONE : FriendSelectionWidget::SHOW_NON_FRIEND_GPG));
|
||||
| FriendSelectionWidget::SHOW_GXS);
|
||||
//| (ui.onlyTrustedKeys->isChecked()? FriendSelectionWidget::SHOW_NONE : FriendSelectionWidget::SHOW_NON_FRIEND_GPG));
|
||||
//ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL );
|
||||
ui.friendSelectionWidget->start();
|
||||
|
||||
|
@ -359,29 +358,27 @@ void MessageComposer::processSettings(bool bLoad)
|
|||
|
||||
Settings->endGroup();
|
||||
}
|
||||
/*static*/ void MessageComposer::msgDistantPeer(const RsPgpId& pgp_id)
|
||||
|
||||
/*static*/ void MessageComposer::msgGxsIdentity(const RsGxsId &id)
|
||||
{
|
||||
// std::cerr << "MessageComposer::msgfriend()" << std::endl;
|
||||
|
||||
/* create a message */
|
||||
|
||||
DistantMsgPeerId pid ;
|
||||
rsMsgs->getDistantMessagePeerId(pgp_id,pid) ;
|
||||
|
||||
MessageComposer *pMsgDialog = MessageComposer::newMsg();
|
||||
if (pMsgDialog == NULL)
|
||||
|
||||
if (pMsgDialog == NULL)
|
||||
return;
|
||||
|
||||
pMsgDialog->addRecipient(TO,pid,pgp_id) ;
|
||||
pMsgDialog->addRecipient(TO, id);
|
||||
pMsgDialog->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
|
||||
/*static*/ void MessageComposer::msgFriend(const RsPeerId &id, bool group)
|
||||
/*static*/ void MessageComposer::msgFriend(const RsPeerId &id)
|
||||
{
|
||||
// std::cerr << "MessageComposer::msgfriend()" << std::endl;
|
||||
// std::cerr << "MessageComposer::msgfriend()" << std::endl;
|
||||
|
||||
/* create a message */
|
||||
|
||||
|
@ -390,25 +387,10 @@ void MessageComposer::processSettings(bool bLoad)
|
|||
return;
|
||||
}
|
||||
|
||||
if (group) {
|
||||
pMsgDialog->addRecipient(TO, id, true);
|
||||
} else {
|
||||
RsPeerDetails detail;
|
||||
if (rsPeers->getPeerDetails(id, detail) && detail.accept_connection)
|
||||
RsPeerDetails detail;
|
||||
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);
|
||||
// }
|
||||
}
|
||||
pMsgDialog->addRecipient(TO, id);
|
||||
}
|
||||
|
||||
pMsgDialog->show();
|
||||
|
@ -460,7 +442,7 @@ void MessageComposer::recommendFriend(const std::list <RsPeerId> &sslIds, const
|
|||
composer->msgFlags |= RS_MSG_FRIEND_RECOMMENDATION;
|
||||
|
||||
if (!to.isNull()) {
|
||||
composer->addRecipient(TO, to, false);
|
||||
composer->addRecipient(TO, to);
|
||||
}
|
||||
RsPgpId ownPgpId = rsPeers->getGPGOwnId();
|
||||
RetroShareLink link;
|
||||
|
@ -479,7 +461,7 @@ void MessageComposer::recommendFriend(const std::list <RsPeerId> &sslIds, const
|
|||
if (*peerIt == to) {
|
||||
continue;
|
||||
}
|
||||
composer->addRecipient(CC, *peerIt, false);
|
||||
composer->addRecipient(CC, *peerIt);
|
||||
}
|
||||
|
||||
if (autoSend) {
|
||||
|
@ -683,15 +665,16 @@ void MessageComposer::peerStatusChanged(const QString& peer_id, int status)
|
|||
|
||||
for (row = 0; row < rowCount; row++) {
|
||||
enumType type;
|
||||
destinationType dtype ;
|
||||
std::string id;
|
||||
bool group;
|
||||
|
||||
if (getRecipientFromRow(row, type, id, group) && !id.empty() ) {
|
||||
if (group == false && QString::fromStdString(id) == peer_id) {
|
||||
if (getRecipientFromRow(row, type,dtype, id) && !id.empty() ) {
|
||||
if (dtype == PEER_TYPE_SSL && QString::fromStdString(id) == peer_id)
|
||||
{
|
||||
QTableWidgetItem *item = ui.recipientWidget->item(row, COLUMN_RECIPIENT_ICON);
|
||||
if (item) {
|
||||
if (item)
|
||||
item->setIcon(QIcon(StatusDefs::imageUser(status)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -892,38 +875,34 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
|
|||
|
||||
std::list<std::string> groupIds;
|
||||
std::list<std::string>::iterator groupIt;
|
||||
std::list<RsPeerId>::iterator it;
|
||||
|
||||
// calculateGroupsOfSslIds(groupInfoList, msgInfo.msgto, groupIds);
|
||||
// for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) {
|
||||
// msgComposer->addRecipient(MessageComposer::TO, *groupIt, true) ;
|
||||
// }
|
||||
for (it = msgInfo.msgto.begin(); it != msgInfo.msgto.end(); it++ ) {
|
||||
msgComposer->addRecipient(MessageComposer::TO, *it, false) ;
|
||||
}
|
||||
// calculateGroupsOfSslIds(groupInfoList, msgInfo.msgto, groupIds);
|
||||
// for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) {
|
||||
// msgComposer->addRecipient(MessageComposer::TO, *groupIt, true) ;
|
||||
// }
|
||||
|
||||
// calculateGroupsOfSslIds(groupInfoList, msgInfo.msgcc, groupIds);
|
||||
// for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) {
|
||||
// msgComposer->addRecipient(MessageComposer::CC, *groupIt, true) ;
|
||||
// }
|
||||
for (it = msgInfo.msgcc.begin(); it != msgInfo.msgcc.end(); it++ ) {
|
||||
msgComposer->addRecipient(MessageComposer::CC, *it, false) ;
|
||||
}
|
||||
// calculateGroupsOfSslIds(groupInfoList, msgInfo.msgcc, groupIds);
|
||||
// for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) {
|
||||
// msgComposer->addRecipient(MessageComposer::CC, *groupIt, true) ;
|
||||
// }
|
||||
|
||||
// calculateGroupsOfSslIds(groupInfoList, msgInfo.msgbcc, groupIds);
|
||||
// for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) {
|
||||
// msgComposer->addRecipient(MessageComposer::BCC, *groupIt, true) ;
|
||||
// }
|
||||
for (it = msgInfo.msgbcc.begin(); it != msgInfo.msgbcc.end(); it++ ) {
|
||||
msgComposer->addRecipient(MessageComposer::BCC, *it, false) ;
|
||||
}
|
||||
// calculateGroupsOfSslIds(groupInfoList, msgInfo.msgbcc, groupIds);
|
||||
// for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) {
|
||||
// msgComposer->addRecipient(MessageComposer::BCC, *groupIt, true) ;
|
||||
// }
|
||||
|
||||
for (std::list<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); it++ ) msgComposer->addRecipient(MessageComposer::TO, *it) ;
|
||||
for (std::list<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); it++ ) msgComposer->addRecipient(MessageComposer::CC, *it) ;
|
||||
for (std::list<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgbcc.begin(); it != msgInfo.rspeerid_msgbcc.end(); it++ ) msgComposer->addRecipient(MessageComposer::BCC, *it) ;
|
||||
for (std::list<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); it++ ) msgComposer->addRecipient(MessageComposer::TO, *it) ;
|
||||
for (std::list<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); it++ ) msgComposer->addRecipient(MessageComposer::CC, *it) ;
|
||||
for (std::list<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgbcc.begin(); it != msgInfo.rsgxsid_msgbcc.end(); it++ ) msgComposer->addRecipient(MessageComposer::BCC, *it) ;
|
||||
|
||||
MsgTagInfo tagInfo;
|
||||
rsMsgs->getMessageTag(msgId, tagInfo);
|
||||
|
||||
msgComposer->m_tagIds = tagInfo.tagIds;
|
||||
|
||||
msgComposer->showTagLabels();
|
||||
|
||||
msgComposer->ui.msgText->document()->setModified(false);
|
||||
}
|
||||
|
||||
|
@ -935,29 +914,44 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
|
|||
QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo)
|
||||
{
|
||||
RetroShareLink link;
|
||||
link.createMessage(msgInfo.srcId, "");
|
||||
link.createMessage(msgInfo.rspeerid_srcId, "");
|
||||
QString from = link.toHtml();
|
||||
|
||||
QString to;
|
||||
std::list<RsPeerId>::const_iterator it;
|
||||
for (it = msgInfo.msgto.begin(); it != msgInfo.msgto.end(); it++) {
|
||||
if (link.createMessage(*it, "")) {
|
||||
if (!to.isEmpty()) {
|
||||
for ( std::list<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); it++)
|
||||
if (link.createMessage(*it, ""))
|
||||
{
|
||||
if (!to.isEmpty())
|
||||
to += ", ";
|
||||
}
|
||||
|
||||
to += link.toHtml();
|
||||
}
|
||||
}
|
||||
for ( std::list<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); it++)
|
||||
if (link.createMessage(*it, ""))
|
||||
{
|
||||
if (!to.isEmpty())
|
||||
to += ", ";
|
||||
|
||||
to += link.toHtml();
|
||||
}
|
||||
|
||||
|
||||
QString cc;
|
||||
for (it = msgInfo.msgcc.begin(); it != msgInfo.msgcc.end(); it++) {
|
||||
for (std::list<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); it++)
|
||||
if (link.createMessage(*it, "")) {
|
||||
if (!cc.isEmpty()) {
|
||||
cc += ", ";
|
||||
}
|
||||
cc += link.toHtml();
|
||||
}
|
||||
}
|
||||
for (std::list<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); it++)
|
||||
if (link.createMessage(*it, "")) {
|
||||
if (!cc.isEmpty()) {
|
||||
cc += ", ";
|
||||
}
|
||||
cc += link.toHtml();
|
||||
}
|
||||
|
||||
|
||||
QString header = QString("<span>-----%1-----").arg(tr("Original Message"));
|
||||
header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").arg(tr("From"), from);
|
||||
|
@ -1030,22 +1024,28 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all)
|
|||
msgComposer->setTitleText(QString::fromUtf8(msgInfo.title.c_str()), REPLY);
|
||||
msgComposer->setQuotedMsg(QString::fromUtf8(msgInfo.msg.c_str()), buildReplyHeader(msgInfo));
|
||||
|
||||
msgComposer->addRecipient(MessageComposer::TO, msgInfo.srcId, false);
|
||||
if(!msgInfo.rspeerid_srcId.isNull()) msgComposer->addRecipient(MessageComposer::TO, msgInfo.rspeerid_srcId);
|
||||
if(!msgInfo.rsgxsid_srcId.isNull()) msgComposer->addRecipient(MessageComposer::TO, msgInfo.rsgxsid_srcId);
|
||||
|
||||
if (all) {
|
||||
if (all)
|
||||
{
|
||||
RsPeerId ownId = rsPeers->getOwnId();
|
||||
|
||||
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<RsPeerId>::iterator tli = msgInfo.rspeerid_msgto.begin(); tli != msgInfo.rspeerid_msgto.end(); tli++)
|
||||
if (ownId != *tli)
|
||||
msgComposer->addRecipient(MessageComposer::TO, *tli) ;
|
||||
|
||||
for (std::list<RsPeerId>::iterator tli = msgInfo.msgcc.begin(); tli != msgInfo.msgcc.end(); tli++) {
|
||||
if (ownId != *tli) {
|
||||
msgComposer->addRecipient(MessageComposer::TO, *tli, false) ;
|
||||
}
|
||||
}
|
||||
for (std::list<RsPeerId>::iterator tli = msgInfo.rspeerid_msgcc.begin(); tli != msgInfo.rspeerid_msgcc.end(); tli++)
|
||||
if (ownId != *tli)
|
||||
msgComposer->addRecipient(MessageComposer::TO, *tli) ;
|
||||
|
||||
for (std::list<RsGxsId>::iterator tli = msgInfo.rsgxsid_msgto.begin(); tli != msgInfo.rsgxsid_msgto.end(); tli++)
|
||||
//if (ownId != *tli)
|
||||
msgComposer->addRecipient(MessageComposer::TO, *tli) ;
|
||||
|
||||
for (std::list<RsGxsId>::iterator tli = msgInfo.rsgxsid_msgcc.begin(); tli != msgInfo.rsgxsid_msgcc.end(); tli++)
|
||||
//if (ownId != *tli)
|
||||
msgComposer->addRecipient(MessageComposer::TO, *tli) ;
|
||||
}
|
||||
|
||||
// needed to send system flags with reply
|
||||
|
@ -1139,9 +1139,10 @@ void MessageComposer::sendMessage()
|
|||
}
|
||||
}
|
||||
|
||||
template<class T> void addUnique(std::list<T>& lst,const T& t) { if(std::find(lst.begin(),lst.end(),t) == lst.end()) lst.push_back(t) ; }
|
||||
|
||||
bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
||||
{
|
||||
#ifdef SUSPENDED
|
||||
/* construct a message */
|
||||
MessageInfo mi;
|
||||
|
||||
|
@ -1165,7 +1166,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
|||
for (int i = 0; i < filesCount; i++) {
|
||||
QTreeWidgetItem *item = ui.msgFileList->topLevelItem(i);
|
||||
if (item->checkState(COLUMN_FILE_CHECKED)) {
|
||||
std::string hash = item->text(COLUMN_FILE_HASH).toStdString();
|
||||
RsFileHash hash ( item->text(COLUMN_FILE_HASH).toStdString() );
|
||||
for(std::list<FileInfo>::iterator it = _recList.begin(); it != _recList.end(); it++) {
|
||||
if (it->hash == hash) {
|
||||
mi.files.push_back(*it);
|
||||
|
@ -1185,79 +1186,89 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
|||
int rowCount = ui.recipientWidget->rowCount();
|
||||
int row;
|
||||
|
||||
for (row = 0; row < rowCount; row++) {
|
||||
for (row = 0; row < rowCount; row++)
|
||||
{
|
||||
enumType type;
|
||||
destinationType dtype ;
|
||||
std::string id;
|
||||
bool group;
|
||||
|
||||
if (getRecipientFromRow(row, type, id, group) && !id.empty())
|
||||
{
|
||||
if (group) {
|
||||
RsGroupInfo groupInfo;
|
||||
if (rsPeers->getGroupInfo(id, groupInfo) == false) {
|
||||
// group not found
|
||||
continue;
|
||||
}
|
||||
if (!getRecipientFromRow(row, type,dtype, id) || id.empty())
|
||||
continue ;
|
||||
|
||||
std::list<std::string>::const_iterator groupIt;
|
||||
for (groupIt = groupInfo.peerIds.begin(); groupIt != groupInfo.peerIds.end(); groupIt++) {
|
||||
std::list<RsPeerId> sslIds;
|
||||
rsPeers->getAssociatedSSLIds(*groupIt, sslIds);
|
||||
switch(dtype)
|
||||
{
|
||||
case PEER_TYPE_GROUP: {
|
||||
RsGroupInfo groupInfo;
|
||||
if (rsPeers->getGroupInfo(id, groupInfo) == false) {
|
||||
// group not found
|
||||
continue;
|
||||
}
|
||||
|
||||
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
|
||||
continue;
|
||||
}
|
||||
std::list<RsPgpId>::const_iterator groupIt;
|
||||
for (groupIt = groupInfo.peerIds.begin(); groupIt != groupInfo.peerIds.end(); groupIt++) {
|
||||
std::list<RsPeerId> sslIds;
|
||||
rsPeers->getAssociatedSSLIds(*groupIt, sslIds);
|
||||
|
||||
switch (type) {
|
||||
case TO:
|
||||
if (std::find(mi.msgto.begin(), mi.msgto.end(), *sslIt) == mi.msgto.end()) {
|
||||
mi.msgto.push_back(*sslIt);
|
||||
}
|
||||
break;
|
||||
case CC:
|
||||
if (std::find(mi.msgcc.begin(), mi.msgcc.end(), *sslIt) == mi.msgcc.end()) {
|
||||
mi.msgcc.push_back(*sslIt);
|
||||
}
|
||||
break;
|
||||
case BCC:
|
||||
if (std::find(mi.msgbcc.begin(), mi.msgbcc.end(), *sslIt) == mi.msgbcc.end()) {
|
||||
mi.msgbcc.push_back(*sslIt);
|
||||
}
|
||||
break;
|
||||
}
|
||||
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
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (_distant_peers.find(id)==_distant_peers.end() && std::find(peers.begin(), peers.end(), id) == peers.end()) {
|
||||
// no friend
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case TO:
|
||||
if (std::find(mi.msgto.begin(), mi.msgto.end(), id) == mi.msgto.end()) {
|
||||
mi.msgto.push_back(id);
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case TO: addUnique(mi.rspeerid_msgto,*sslIt);
|
||||
break;
|
||||
case CC:
|
||||
if (std::find(mi.msgcc.begin(), mi.msgcc.end(), id) == mi.msgcc.end()) {
|
||||
mi.msgcc.push_back(id);
|
||||
}
|
||||
case CC: addUnique(mi.rspeerid_msgcc,*sslIt);
|
||||
break;
|
||||
case BCC:
|
||||
if (std::find(mi.msgbcc.begin(), mi.msgbcc.end(), id) == mi.msgbcc.end()) {
|
||||
mi.msgbcc.push_back(id);
|
||||
}
|
||||
case BCC:addUnique(mi.rspeerid_msgbcc,*sslIt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break ;
|
||||
case PEER_TYPE_SSL:
|
||||
{
|
||||
RsPeerId pid(id) ;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TO: addUnique(mi.rspeerid_msgto,pid);
|
||||
break ;
|
||||
case CC: addUnique(mi.rspeerid_msgcc,pid);
|
||||
break ;
|
||||
case BCC:addUnique(mi.rspeerid_msgbcc,pid);
|
||||
break ;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
case PEER_TYPE_GXS:
|
||||
{
|
||||
RsGxsId gid(id) ;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TO: addUnique(mi.rsgxsid_msgto,gid) ;
|
||||
break ;
|
||||
case CC: addUnique(mi.rsgxsid_msgcc,gid) ;
|
||||
break ;
|
||||
case BCC:addUnique(mi.rsgxsid_msgbcc,gid) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
|
||||
default:
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": Unhandled desitnation type " << dtype << std::endl;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
if (bDraftbox) {
|
||||
if (bDraftbox)
|
||||
{
|
||||
mi.msgId = m_sDraftMsgId;
|
||||
|
||||
rsMsgs->MessageToDraft(mi, m_msgParentId);
|
||||
|
@ -1275,16 +1286,18 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
|||
rsMsgs->MessageForwarded(m_sDraftMsgId, true);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* check for the recipient */
|
||||
if (mi.msgto.empty()) {
|
||||
if (mi.rspeerid_msgto.empty() && mi.rspeerid_msgcc.empty() && mi.rspeerid_msgbcc.empty()
|
||||
&& mi.rsgxsid_msgto.empty() && mi.rsgxsid_msgcc.empty() && mi.rsgxsid_msgbcc.empty())
|
||||
{
|
||||
QMessageBox::warning(this, tr("RetroShare"), tr("Please insert at least one recipient."), QMessageBox::Ok);
|
||||
return false; // Don't send with no recipient
|
||||
}
|
||||
mi.encryption_keys = _distant_peers ;
|
||||
|
||||
if(ui.signMessage_CB->isChecked())
|
||||
mi.msgflags |= RS_MSG_SIGNED ;
|
||||
if(ui.signMessage_CB->isChecked())
|
||||
mi.msgflags |= RS_MSG_SIGNED ;
|
||||
|
||||
if (rsMsgs->MessageSend(mi) == false) {
|
||||
return false;
|
||||
|
@ -1324,7 +1337,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
|||
}
|
||||
}
|
||||
ui.msgText->document()->setModified(false);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1350,10 +1363,10 @@ void MessageComposer::addEmptyRecipient()
|
|||
}
|
||||
}
|
||||
|
||||
setRecipientToRow(lastRow, TO,"", false);
|
||||
setRecipientToRow(lastRow, TO,PEER_TYPE_SSL,"");
|
||||
}
|
||||
|
||||
bool MessageComposer::getRecipientFromRow(int row, enumType &type, std::string &id, bool &group)
|
||||
bool MessageComposer::getRecipientFromRow(int row, enumType &type, destinationType& dest_type,std::string &id)
|
||||
{
|
||||
if (row >= ui.recipientWidget->rowCount()) {
|
||||
return false;
|
||||
|
@ -1366,12 +1379,12 @@ 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();
|
||||
group = ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->data(ROLE_RECIPIENT_GROUP).toBool();
|
||||
dest_type = (destinationType)ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->data(ROLE_RECIPIENT_TYPE).toInt();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MessageComposer::setRecipientToRow(int row, enumType type, const std::string& id, bool group)
|
||||
void MessageComposer::setRecipientToRow(int row, enumType type, destinationType dest_type, const std::string &id)
|
||||
{
|
||||
if (row + 1 > ui.recipientWidget->rowCount()) {
|
||||
ui.recipientWidget->setRowCount(row + 1);
|
||||
|
@ -1407,9 +1420,10 @@ void MessageComposer::setRecipientToRow(int row, enumType type, const std::strin
|
|||
QIcon icon;
|
||||
QString name;
|
||||
if (!id.empty())
|
||||
{
|
||||
if (group)
|
||||
{
|
||||
{
|
||||
switch(dest_type)
|
||||
{
|
||||
case PEER_TYPE_GROUP: {
|
||||
icon = QIcon(IMAGE_GROUP16);
|
||||
|
||||
RsGroupInfo groupInfo;
|
||||
|
@ -1418,54 +1432,61 @@ void MessageComposer::setRecipientToRow(int row, enumType type, const std::strin
|
|||
} else {
|
||||
name = tr("Unknown");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RsPeerDetails details;
|
||||
}
|
||||
break ;
|
||||
|
||||
if(_distant_peers.find(RsPeerId(id)) != _distant_peers.end())
|
||||
{
|
||||
if(!rsPeers->getGPGDetails(_distant_peers[RsPeerId(id)], details))
|
||||
{
|
||||
std::cerr << "Can't get peer details from " << _distant_peers[RsPeerId(id)] << std::endl;
|
||||
return ;
|
||||
}
|
||||
case PEER_TYPE_GXS: {
|
||||
|
||||
name = tr("Distant peer (name: %2, PGP key: %1)").arg(QString::fromStdString(_distant_peers[RsPeerId(id)].toStdString())).arg(QString::fromStdString(details.name)) ;
|
||||
icon = QIcon(StatusDefs::imageUser(RS_STATUS_ONLINE));
|
||||
}
|
||||
else if(rsPeers->getPeerDetails(RsPeerId(id), details) && (!details.isOnlyGPGdetail))
|
||||
{
|
||||
name = PeerDefs::nameWithLocation(details);
|
||||
RsIdentityDetails detail;
|
||||
RsGxsId gid(id) ;
|
||||
|
||||
StatusInfo peerStatusInfo;
|
||||
// No check of return value. Non existing status info is handled as offline.
|
||||
rsStatus->getStatus(RsPeerId(id), peerStatusInfo);
|
||||
if(!rsIdentity->getIdDetails(gid, detail))
|
||||
{
|
||||
std::cerr << "Can't get peer details from " << gid << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
icon = QIcon(StatusDefs::imageUser(peerStatusInfo.status));
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = QIcon(StatusDefs::imageUser(RS_STATUS_OFFLINE));
|
||||
name = tr("Unknown friend");
|
||||
}
|
||||
}
|
||||
name = tr("Distant peer (name: %2, PGP key: %1)").arg(QString::fromStdString(gid.toStdString())).arg(QString::fromStdString(detail.mNickname)) ;
|
||||
icon = QIcon(StatusDefs::imageUser(RS_STATUS_ONLINE));
|
||||
}
|
||||
break ;
|
||||
|
||||
case PEER_TYPE_SSL: {
|
||||
RsPeerDetails details ;
|
||||
|
||||
if(!rsPeers->getPeerDetails(RsPeerId(id), details))
|
||||
{
|
||||
std::cerr << "Can't get peer details from " << id << std::endl;
|
||||
return ;
|
||||
}
|
||||
name = PeerDefs::nameWithLocation(details);
|
||||
|
||||
StatusInfo peerStatusInfo;
|
||||
// No check of return value. Non existing status info is handled as offline.
|
||||
rsStatus->getStatus(RsPeerId(id), peerStatusInfo);
|
||||
|
||||
icon = QIcon(StatusDefs::imageUser(peerStatusInfo.status));
|
||||
}
|
||||
break ;
|
||||
default:
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": Unhandled type " << dest_type << std::endl;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
comboBox->setCurrentIndex(comboBox->findData(type, Qt::UserRole));
|
||||
|
||||
lineEdit->setText(name);
|
||||
if (id.empty()) {
|
||||
if (id.empty())
|
||||
lineEdit->setStyleSheet(QString(STYLE_FAIL).arg(lineEdit->objectName()));
|
||||
} else {
|
||||
else
|
||||
lineEdit->setStyleSheet(QString(STYLE_NORMAL).arg(lineEdit->objectName()));
|
||||
}
|
||||
|
||||
QTableWidgetItem *item = new QTableWidgetItem(icon, "", 0);
|
||||
item->setFlags(Qt::NoItemFlags);
|
||||
ui.recipientWidget->setItem(row, COLUMN_RECIPIENT_ICON, item);
|
||||
ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->setData(ROLE_RECIPIENT_ID, QString::fromStdString(id));
|
||||
ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->setData(ROLE_RECIPIENT_GROUP, group);
|
||||
ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->setData(ROLE_RECIPIENT_TYPE, dest_type);
|
||||
|
||||
addEmptyRecipient();
|
||||
}
|
||||
|
@ -1532,13 +1553,14 @@ void MessageComposer::editingRecipientFinished()
|
|||
|
||||
enumType type;
|
||||
std::string id; // dummy
|
||||
bool group; // dummy
|
||||
getRecipientFromRow(row, type, id, group);
|
||||
destinationType dtype ;
|
||||
|
||||
getRecipientFromRow(row, type, dtype, id);
|
||||
|
||||
QString text = lineEdit->text();
|
||||
|
||||
if (text.isEmpty()) {
|
||||
setRecipientToRow(row, type, "", false);
|
||||
setRecipientToRow(row, type,PEER_TYPE_SSL, "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1556,7 +1578,7 @@ void MessageComposer::editingRecipientFinished()
|
|||
QString name = PeerDefs::nameWithLocation(details);
|
||||
if (text.compare(name, Qt::CaseSensitive) == 0) {
|
||||
// found it
|
||||
setRecipientToRow(row, type, details.id.toStdString(), false);
|
||||
setRecipientToRow(row, type, PEER_TYPE_SSL, details.id.toStdString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1570,100 +1592,94 @@ void MessageComposer::editingRecipientFinished()
|
|||
QString groupName = GroupDefs::name(*groupIt);
|
||||
if (text.compare(groupName, Qt::CaseSensitive) == 0) {
|
||||
// found it
|
||||
setRecipientToRow(row, type, groupIt->id, true);
|
||||
setRecipientToRow(row, type, PEER_TYPE_GROUP, groupIt->id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setRecipientToRow(row, type, "", false);
|
||||
setRecipientToRow(row, type, PEER_TYPE_SSL, "");
|
||||
lineEdit->setStyleSheet(QString(STYLE_FAIL).arg(lineEdit->objectName()));
|
||||
lineEdit->setText(text);
|
||||
}
|
||||
|
||||
void MessageComposer::addRecipient(enumType type, const DistantMsgPeerId& pid,const RsPgpId& pgp_id)
|
||||
void MessageComposer::addRecipient(enumType type, const RsPeerId& pid)
|
||||
{
|
||||
_distant_peers[pid] = pgp_id ;
|
||||
int rowCount = ui.recipientWidget->rowCount();
|
||||
int row;
|
||||
for (row = 0; row < rowCount; row++)
|
||||
{
|
||||
enumType rowType;
|
||||
std::string rowId;
|
||||
destinationType dtype ;
|
||||
|
||||
int rowCount = ui.recipientWidget->rowCount();
|
||||
int row;
|
||||
for (row = 0; row < rowCount; row++)
|
||||
{
|
||||
enumType rowType;
|
||||
std::string rowId;
|
||||
bool rowGroup;
|
||||
if (getRecipientFromRow(row, rowType, dtype, rowId))
|
||||
{
|
||||
if (rowId.empty()) // use row
|
||||
break;
|
||||
|
||||
if (getRecipientFromRow(row, rowType, rowId, rowGroup) == true)
|
||||
{
|
||||
if (rowId.empty()) // use row
|
||||
break;
|
||||
|
||||
if (rowId == pid.toStdString() && rowType == type) // existing row
|
||||
break;
|
||||
}
|
||||
else // use row
|
||||
break;
|
||||
}
|
||||
|
||||
setRecipientToRow(row, type, pid.toStdString(), false);
|
||||
}
|
||||
void MessageComposer::addRecipient(enumType type, const RsPeerId &id, bool group)
|
||||
{
|
||||
std::list<RsPeerId> sslIds;
|
||||
if (group) {
|
||||
sslIds.push_back(id);
|
||||
} else {
|
||||
// check for gpg id or ssl id
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(id, detail)) {
|
||||
return;
|
||||
if (RsPeerId(rowId) == pid && rowType == type) // existing row
|
||||
break;
|
||||
}
|
||||
|
||||
// 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);
|
||||
// }
|
||||
else // use row
|
||||
break;
|
||||
}
|
||||
std::list<RsPeerId>::const_iterator sslIt;
|
||||
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
|
||||
// search existing or empty row
|
||||
int rowCount = ui.recipientWidget->rowCount();
|
||||
int row;
|
||||
for (row = 0; row < rowCount; row++) {
|
||||
enumType rowType;
|
||||
std::string rowId;
|
||||
bool rowGroup;
|
||||
|
||||
if (getRecipientFromRow(row, rowType, rowId, rowGroup) == true) {
|
||||
if (rowId.empty()) {
|
||||
// use row
|
||||
break;
|
||||
}
|
||||
setRecipientToRow(row, type, PEER_TYPE_SSL,pid.toStdString());
|
||||
}
|
||||
void MessageComposer::addRecipient(enumType type, const RsGxsId& gxs_id)
|
||||
{
|
||||
_distant_peers.insert(gxs_id) ;
|
||||
|
||||
if (rowId == (*sslIt).toStdString() && rowType == type && group == rowGroup) {
|
||||
// existing row
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
int rowCount = ui.recipientWidget->rowCount();
|
||||
int row;
|
||||
for (row = 0; row < rowCount; row++)
|
||||
{
|
||||
enumType rowType;
|
||||
std::string rowId;
|
||||
destinationType dtype ;
|
||||
|
||||
if (getRecipientFromRow(row, rowType, dtype, rowId))
|
||||
{
|
||||
if (rowId.empty()) // use row
|
||||
break;
|
||||
|
||||
if (RsGxsId(rowId) == gxs_id && rowType == type) // existing row
|
||||
break;
|
||||
}
|
||||
else // use row
|
||||
break;
|
||||
}
|
||||
|
||||
setRecipientToRow(row, type, PEER_TYPE_GXS,gxs_id.toStdString());
|
||||
}
|
||||
void MessageComposer::addRecipient(enumType type, const std::string& id)
|
||||
{
|
||||
// search existing or empty row
|
||||
int rowCount = ui.recipientWidget->rowCount();
|
||||
int row;
|
||||
for (row = 0; row < rowCount; row++) {
|
||||
enumType rowType;
|
||||
std::string rowId;
|
||||
destinationType dtype ;
|
||||
bool rowGroup;
|
||||
|
||||
if (getRecipientFromRow(row, rowType, dtype,rowId))
|
||||
{
|
||||
if (rowId.empty()) {
|
||||
// use row
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setRecipientToRow(row, type, (*sslIt).toStdString(), group);
|
||||
if (rowId == id && rowType == type && dtype == PEER_TYPE_GROUP) {
|
||||
// existing row
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// use row
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setRecipientToRow(row, type, PEER_TYPE_GROUP, id);
|
||||
}
|
||||
|
||||
void MessageComposer::setupFileActions()
|
||||
|
@ -2299,36 +2315,32 @@ void MessageComposer::fileHashingFinished(QList<HashedFile> hashedFiles)
|
|||
|
||||
void MessageComposer::addContact(enumType type)
|
||||
{
|
||||
// std::list<std::string> ids;
|
||||
// ui.friendSelectionWidget->selectedIds<std::string,FriendSelectionWidget::IDTYPE_GROUP>(ids,false);
|
||||
//
|
||||
// std::list<std::string>::iterator idIt;
|
||||
// for (idIt = ids.begin(); idIt != ids.end(); idIt++) {
|
||||
// addRecipient(type, *idIt, true);
|
||||
// }
|
||||
// std::list<std::string> ids;
|
||||
// ui.friendSelectionWidget->selectedIds<std::string,FriendSelectionWidget::IDTYPE_GROUP>(ids,false);
|
||||
//
|
||||
// std::list<std::string>::iterator idIt;
|
||||
// for (idIt = ids.begin(); idIt != ids.end(); idIt++) {
|
||||
// addRecipient(type, *idIt, true);
|
||||
// }
|
||||
|
||||
std::list<RsPeerId> ids ;
|
||||
ui.friendSelectionWidget->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(ids, true);
|
||||
for (std::list<RsPeerId>::const_iterator idIt = ids.begin(); idIt != ids.end(); idIt++) {
|
||||
addRecipient(type, *idIt, false);
|
||||
}
|
||||
std::list<RsPeerId> ids ;
|
||||
ui.friendSelectionWidget->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(ids, true);
|
||||
for (std::list<RsPeerId>::const_iterator idIt = ids.begin(); idIt != ids.end(); idIt++) {
|
||||
addRecipient(type, *idIt);
|
||||
}
|
||||
|
||||
std::list<RsPgpId> id2 ;
|
||||
ui.friendSelectionWidget->selectedIds<RsPgpId,FriendSelectionWidget::IDTYPE_GPG>(id2, true);
|
||||
for (std::list<RsPgpId>::const_iterator idIt = id2.begin(); idIt != id2.end(); idIt++)
|
||||
{
|
||||
DistantMsgPeerId pid ;
|
||||
|
||||
if(rsMsgs->getDistantMessagePeerId(*idIt,pid))
|
||||
addRecipient(type, pid, *idIt);
|
||||
}
|
||||
std::list<RsGxsId> id2 ;
|
||||
ui.friendSelectionWidget->selectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(id2, true);
|
||||
for (std::list<RsGxsId>::const_iterator idIt = id2.begin(); idIt != id2.end(); idIt++)
|
||||
addRecipient(type, *idIt);
|
||||
}
|
||||
|
||||
void MessageComposer::toggleShowNonFriend(bool bValue)
|
||||
{
|
||||
ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP
|
||||
| FriendSelectionWidget::SHOW_SSL
|
||||
| (bValue?FriendSelectionWidget::SHOW_NONE : FriendSelectionWidget::SHOW_NON_FRIEND_GPG));
|
||||
| (bValue?FriendSelectionWidget::SHOW_NONE : FriendSelectionWidget::SHOW_GXS));
|
||||
|
||||
Settings->setValueToGroup("MessageComposer", "ShowOnlyTrustedKeys", bValue);
|
||||
}
|
||||
|
||||
|
@ -2349,21 +2361,23 @@ void MessageComposer::addBcc()
|
|||
|
||||
void MessageComposer::addRecommend()
|
||||
{
|
||||
std::list<RsPeerId> sslIds;
|
||||
ui.friendSelectionWidget->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(sslIds, false);
|
||||
std::list<RsPeerId> sslIds;
|
||||
ui.friendSelectionWidget->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(sslIds, false);
|
||||
|
||||
if (sslIds.empty()) {
|
||||
return;
|
||||
}
|
||||
std::list<RsGxsId> gxsIds ;
|
||||
ui.friendSelectionWidget->selectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(gxsIds, true);
|
||||
|
||||
std::list <RsPeerId>::iterator it;
|
||||
for (it = sslIds.begin(); it != sslIds.end(); it++) {
|
||||
addRecipient(CC, *it, false);
|
||||
}
|
||||
if (sslIds.empty() && gxsIds.empty())
|
||||
return;
|
||||
|
||||
QString text = buildRecommendHtml(sslIds);
|
||||
ui.msgText->textCursor().insertHtml(text);
|
||||
ui.msgText->setFocus(Qt::OtherFocusReason);
|
||||
for(std::list <RsPeerId>::iterator it = sslIds.begin(); it != sslIds.end(); it++)
|
||||
addRecipient(CC, *it);
|
||||
for (std::list<RsGxsId>::const_iterator it = gxsIds.begin(); it != gxsIds.end(); it++)
|
||||
addRecipient(TO, *it);
|
||||
|
||||
QString text = buildRecommendHtml(sslIds);
|
||||
ui.msgText->textCursor().insertHtml(text);
|
||||
ui.msgText->setFocus(Qt::OtherFocusReason);
|
||||
}
|
||||
|
||||
void MessageComposer::friendDetails()
|
||||
|
|
|
@ -42,6 +42,7 @@ class MessageComposer : public QMainWindow
|
|||
public:
|
||||
enum enumType { TO, CC, BCC };
|
||||
enum enumMessageType { NORMAL, REPLY, FORWARD };
|
||||
enum destinationType { PEER_TYPE_SSL, PEER_TYPE_GROUP, PEER_TYPE_GXS };
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
|
@ -49,9 +50,9 @@ public:
|
|||
MessageComposer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
~MessageComposer();
|
||||
|
||||
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 void msgFriend(const RsPeerId &id);
|
||||
static void msgGxsIdentity(const RsGxsId& gxs_id) ;
|
||||
static void msgGroup(const std::string& group_id) ;
|
||||
|
||||
static QString recommendMessage();
|
||||
static void recommendFriend(const std::list <RsPeerId> &sslIds, const RsPeerId &to = RsPeerId(), const QString &msg = "", bool autoSend = false);
|
||||
|
@ -68,8 +69,9 @@ 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 RsPeerId &id, bool group);
|
||||
void addRecipient(enumType type, const DistantMsgPeerId &pid, const RsPgpId &pgp_id) ;
|
||||
void addRecipient(enumType type, const RsPeerId &id);
|
||||
void addRecipient(enumType type, const RsGxsId &gxs_id) ;
|
||||
void addRecipient(enumType type, const std::string& group_id) ;
|
||||
|
||||
public slots:
|
||||
/* actions to take.... */
|
||||
|
@ -174,8 +176,8 @@ private:
|
|||
void calculateTitle();
|
||||
void addEmptyRecipient();
|
||||
|
||||
bool getRecipientFromRow(int row, enumType &type, std::string &id, bool &group);
|
||||
void setRecipientToRow(int row, enumType type, const std::string &id, bool group);
|
||||
bool getRecipientFromRow(int row, enumType &type, destinationType& dest_type, std::string &id);
|
||||
void setRecipientToRow(int row, enumType type, destinationType dest_type,const std::string &id);
|
||||
|
||||
void clearTagLabels();
|
||||
void showTagLabels();
|
||||
|
@ -221,7 +223,7 @@ private:
|
|||
Ui::MessageComposer ui;
|
||||
|
||||
std::list<FileInfo> _recList ;
|
||||
std::map<DistantMsgPeerId,RsPgpId> _distant_peers ; // pairs (hash,pgp_id)
|
||||
std::set<RsGxsId> _distant_peers ; // we keep a list of them, in order to know which peer is a GXS id.
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -304,7 +304,7 @@ void MessageWidget::getcurrentrecommended()
|
|||
}
|
||||
|
||||
std::list<RsPeerId> srcIds;
|
||||
srcIds.push_back(msgInfo.srcId);
|
||||
srcIds.push_back(msgInfo.rspeerid_srcId);
|
||||
|
||||
QModelIndexList list = ui.msgList->selectionModel()->selectedIndexes();
|
||||
|
||||
|
@ -353,7 +353,7 @@ void MessageWidget::getallrecommended()
|
|||
for(it = recList.begin(); it != recList.end(); it++) {
|
||||
std::cerr << "MessageWidget::getallrecommended() Calling File Request" << std::endl;
|
||||
std::list<RsPeerId> srcIds;
|
||||
srcIds.push_back(msgInfo.srcId);
|
||||
srcIds.push_back(msgInfo.rspeerid_srcId);
|
||||
rsFiles->FileRequest(it->fname, it->hash, it->size, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
|
||||
}
|
||||
}
|
||||
|
@ -497,28 +497,23 @@ void MessageWidget::fill(const std::string &msgId)
|
|||
ui.msgList->insertTopLevelItems(0, items);
|
||||
|
||||
/* iterate through the sources */
|
||||
std::list<RsPeerId>::const_iterator pit;
|
||||
|
||||
RetroShareLink link;
|
||||
QString text;
|
||||
|
||||
for(pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++) {
|
||||
if (link.createMessage(*pit, "")) {
|
||||
text += link.toHtml() + " ";
|
||||
}
|
||||
}
|
||||
for(std::list<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " ";
|
||||
for(std::list<RsGxsId >::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " ";
|
||||
|
||||
ui.toText->setText(text);
|
||||
|
||||
if (msgInfo.msgcc.size() > 0) {
|
||||
if (!msgInfo.rspeerid_msgcc.empty() || !msgInfo.rsgxsid_msgcc.empty())
|
||||
{
|
||||
ui.cclabel->setVisible(true);
|
||||
ui.ccText->setVisible(true);
|
||||
|
||||
text.clear();
|
||||
for(pit = msgInfo.msgcc.begin(); pit != msgInfo.msgcc.end(); pit++) {
|
||||
if (link.createMessage(*pit, "")) {
|
||||
text += link.toHtml() + " ";
|
||||
}
|
||||
}
|
||||
for(std::list<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgcc.begin(); pit != msgInfo.rspeerid_msgcc.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " ";
|
||||
for(std::list<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgcc.begin(); pit != msgInfo.rsgxsid_msgcc.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " ";
|
||||
|
||||
ui.ccText->setText(text);
|
||||
} else {
|
||||
ui.cclabel->setVisible(false);
|
||||
|
@ -526,16 +521,15 @@ void MessageWidget::fill(const std::string &msgId)
|
|||
ui.ccText->clear();
|
||||
}
|
||||
|
||||
if (msgInfo.msgbcc.size() > 0) {
|
||||
ui.bcclabel->setVisible(true);
|
||||
ui.bccText->setVisible(true);
|
||||
if (!msgInfo.rspeerid_msgbcc.empty() || !msgInfo.rsgxsid_msgbcc.empty())
|
||||
{
|
||||
ui.bcclabel->setVisible(true);
|
||||
ui.bccText->setVisible(true);
|
||||
|
||||
text.clear();
|
||||
for(std::list<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgbcc.begin(); pit != msgInfo.rspeerid_msgbcc.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " ";
|
||||
for(std::list<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgbcc.begin(); pit != msgInfo.rsgxsid_msgbcc.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " ";
|
||||
|
||||
text.clear();
|
||||
for(pit = msgInfo.msgbcc.begin(); pit != msgInfo.msgbcc.end(); pit++) {
|
||||
if (link.createMessage(*pit, "")) {
|
||||
text += link.toHtml() + " ";
|
||||
}
|
||||
}
|
||||
ui.bccText->setText(text);
|
||||
} else {
|
||||
ui.bcclabel->setVisible(false);
|
||||
|
@ -552,11 +546,11 @@ void MessageWidget::fill(const std::string &msgId)
|
|||
// outgoing message are from me
|
||||
srcId = ownId;
|
||||
} else {
|
||||
srcId = msgInfo.srcId;
|
||||
srcId = msgInfo.rspeerid_srcId;
|
||||
}
|
||||
link.createMessage(srcId, "");
|
||||
|
||||
if ((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.srcId == ownId) {
|
||||
if ((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.rspeerid_srcId == ownId) {
|
||||
ui.fromText->setText("RetroShare");
|
||||
} else {
|
||||
ui.fromText->setText(link.toHtml());
|
||||
|
|
250
retroshare-gui/src/gui/settings/GlobalRouterStatistics.cpp
Normal file
250
retroshare-gui/src/gui/settings/GlobalRouterStatistics.cpp
Normal file
|
@ -0,0 +1,250 @@
|
|||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 20011, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include <QTimer>
|
||||
#include <QObject>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStylePainter>
|
||||
#include <QLayout>
|
||||
|
||||
#include <retroshare/rsgrouter.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include "GlobalRouterStatistics.h"
|
||||
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
static const int MAX_TUNNEL_REQUESTS_DISPLAY = 10 ;
|
||||
|
||||
static QColor colorScale(float f)
|
||||
{
|
||||
if(f == 0)
|
||||
return QColor::fromHsv(0,0,192) ;
|
||||
else
|
||||
return QColor::fromHsv((int)((1.0-f)*280),200,255) ;
|
||||
}
|
||||
|
||||
GlobalRouterStatistics::GlobalRouterStatistics(QWidget *parent)
|
||||
: RsAutoUpdatePage(2000,parent)
|
||||
{
|
||||
setupUi(this) ;
|
||||
|
||||
m_bProcessSettings = false;
|
||||
|
||||
_router_F->setWidget( _tst_CW = new GlobalRouterStatisticsWidget() ) ;
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
}
|
||||
|
||||
GlobalRouterStatistics::~GlobalRouterStatistics()
|
||||
{
|
||||
|
||||
// save settings
|
||||
processSettings(false);
|
||||
}
|
||||
|
||||
void GlobalRouterStatistics::processSettings(bool bLoad)
|
||||
{
|
||||
m_bProcessSettings = true;
|
||||
|
||||
Settings->beginGroup(QString("GlobalRouterStatistics"));
|
||||
|
||||
if (bLoad) {
|
||||
// load settings
|
||||
|
||||
// state of splitter
|
||||
//splitter->restoreState(Settings->value("Splitter").toByteArray());
|
||||
} else {
|
||||
// save settings
|
||||
|
||||
// state of splitter
|
||||
//Settings->setValue("Splitter", splitter->saveState());
|
||||
|
||||
}
|
||||
|
||||
Settings->endGroup();
|
||||
|
||||
m_bProcessSettings = false;
|
||||
}
|
||||
|
||||
void GlobalRouterStatistics::updateDisplay()
|
||||
{
|
||||
_tst_CW->updateContent() ;
|
||||
}
|
||||
|
||||
QString GlobalRouterStatistics::getPeerName(const RsPeerId &peer_id)
|
||||
{
|
||||
static std::map<RsPeerId, QString> names ;
|
||||
|
||||
std::map<RsPeerId,QString>::const_iterator it = names.find(peer_id) ;
|
||||
|
||||
if( it != names.end())
|
||||
return it->second ;
|
||||
else
|
||||
{
|
||||
RsPeerDetails detail ;
|
||||
if(!rsPeers->getPeerDetails(peer_id,detail))
|
||||
return tr("Unknown Peer");
|
||||
|
||||
return (names[peer_id] = QString::fromUtf8(detail.name.c_str())) ;
|
||||
}
|
||||
}
|
||||
|
||||
GlobalRouterStatisticsWidget::GlobalRouterStatisticsWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
maxWidth = 400 ;
|
||||
maxHeight = 0 ;
|
||||
}
|
||||
|
||||
void GlobalRouterStatisticsWidget::updateContent()
|
||||
{
|
||||
std::vector<RsGRouter::GRouterRoutingCacheInfo> cache_infos ;
|
||||
RsGRouter::GRouterRoutingMatrixInfo matrix_info ;
|
||||
|
||||
rsGRouter->getRoutingCacheInfo(cache_infos) ;
|
||||
rsGRouter->getRoutingMatrixInfo(matrix_info) ;
|
||||
|
||||
// What do we need to draw?
|
||||
//
|
||||
// Routing matrix
|
||||
// Key [][][][][][][][][][]
|
||||
//
|
||||
// -> each [] shows a square (one per friend location) that is the routing probabilities for all connected friends
|
||||
// computed using the "computeRoutingProbabilitites()" method.
|
||||
//
|
||||
// Own key ids
|
||||
// key service id description
|
||||
//
|
||||
// Data items
|
||||
// Msg id Local origin Destination Time Status
|
||||
//
|
||||
static const int cellx = 6 ;
|
||||
static const int celly = 10+4 ;
|
||||
|
||||
QPixmap tmppixmap(maxWidth, maxHeight);
|
||||
tmppixmap.fill(this, 0, 0);
|
||||
setFixedHeight(maxHeight);
|
||||
|
||||
QPainter painter(&tmppixmap);
|
||||
painter.initFrom(this);
|
||||
painter.setPen(QColor::fromRgb(0,0,0)) ;
|
||||
|
||||
maxHeight = 500 ;
|
||||
|
||||
// std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl;
|
||||
// draw...
|
||||
int ox=5,oy=5 ;
|
||||
|
||||
painter.drawText(ox,oy+celly,tr("Pending packets")+":" + QString::number(cache_infos.size())) ; oy += celly*2 ;
|
||||
|
||||
for(uint32_t i=0;i<cache_infos.size();++i)
|
||||
{
|
||||
QString packet_string ;
|
||||
packet_string += QString::number(cache_infos[i].mid,16) ;
|
||||
packet_string += tr(" by ")+QString::fromStdString(cache_infos[i].local_origin.toStdString()) ;
|
||||
packet_string += tr(" to ")+QString::fromStdString(cache_infos[i].destination.toStdString()) ;
|
||||
packet_string += tr(" Status ")+QString::number(cache_infos[i].status) ;
|
||||
|
||||
painter.drawText(ox+2*cellx,oy+celly,packet_string ) ; oy += celly ;
|
||||
}
|
||||
|
||||
oy += celly ;
|
||||
|
||||
painter.drawText(ox,oy+celly,tr("Managed keys")+":" + QString::number(matrix_info.published_keys.size())) ; oy += celly*2 ;
|
||||
|
||||
for(std::map<GRouterKeyId,RsGRouter::GRouterPublishedKeyInfo>::const_iterator it(matrix_info.published_keys.begin());it!=matrix_info.published_keys.end();++it)
|
||||
{
|
||||
QString packet_string ;
|
||||
packet_string += QString::fromStdString(it->first.toStdString()) ;
|
||||
packet_string += tr(" : Service ID = ")+QString::number(it->second.service_id,16) ;
|
||||
packet_string += " \""+QString::fromUtf8(it->second.description_string.c_str()) + "\"" ;
|
||||
|
||||
painter.drawText(ox+2*cellx,oy+celly,packet_string ) ; oy += celly ;
|
||||
}
|
||||
oy += celly ;
|
||||
|
||||
QString prob_string ;
|
||||
|
||||
painter.drawText(ox+0*cellx,oy+celly,tr("Routing matrix (")) ;
|
||||
|
||||
// draw scale
|
||||
|
||||
for(int i=0;i<100;++i)
|
||||
{
|
||||
painter.setPen(colorScale(i/100.0)) ;
|
||||
painter.drawLine(ox+120+i,oy+celly+2,ox+120+i,oy+2) ;
|
||||
}
|
||||
painter.setPen(QColor::fromRgb(0,0,0)) ;
|
||||
|
||||
painter.drawText(ox+230,oy+celly,")") ;
|
||||
|
||||
oy += celly ;
|
||||
oy += celly ;
|
||||
|
||||
static const int MaxKeySize = 20 ;
|
||||
|
||||
for(std::map<GRouterKeyId,std::vector<float> >::const_iterator it(matrix_info.per_friend_probabilities.begin());it!=matrix_info.per_friend_probabilities.end();++it)
|
||||
{
|
||||
painter.drawText(ox+2*cellx,oy+celly,QString::fromStdString(it->first.toStdString())+" : ") ;
|
||||
|
||||
for(uint32_t i=0;i<matrix_info.friend_ids.size();++i)
|
||||
painter.fillRect(ox+(MaxKeySize + i)*cellx+200,oy,cellx,celly,colorScale(it->second[i])) ;
|
||||
|
||||
oy += celly ;
|
||||
}
|
||||
|
||||
oy += celly ;
|
||||
oy += celly ;
|
||||
|
||||
// update the pixmap
|
||||
//
|
||||
pixmap = tmppixmap;
|
||||
maxHeight = oy ;
|
||||
}
|
||||
|
||||
QString GlobalRouterStatisticsWidget::speedString(float f)
|
||||
{
|
||||
if(f < 1.0f)
|
||||
return QString("0 B/s") ;
|
||||
if(f < 1024.0f)
|
||||
return QString::number((int)f)+" B/s" ;
|
||||
|
||||
return QString::number(f/1024.0,'f',2) + " KB/s";
|
||||
}
|
||||
|
||||
void GlobalRouterStatisticsWidget::paintEvent(QPaintEvent */*event*/)
|
||||
{
|
||||
QStylePainter(this).drawPixmap(0, 0, pixmap);
|
||||
}
|
||||
|
||||
void GlobalRouterStatisticsWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QRect TaskGraphRect = geometry();
|
||||
maxWidth = TaskGraphRect.width();
|
||||
maxHeight = TaskGraphRect.height() ;
|
||||
|
||||
QWidget::resizeEvent(event);
|
||||
updateContent();
|
||||
}
|
||||
|
71
retroshare-gui/src/gui/settings/GlobalRouterStatistics.h
Normal file
71
retroshare-gui/src/gui/settings/GlobalRouterStatistics.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 20011, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QPoint>
|
||||
#include <retroshare/rsgrouter.h>
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
#include "RsAutoUpdatePage.h"
|
||||
#include "ui_GlobalRouterStatistics.h"
|
||||
|
||||
class GlobalRouterStatisticsWidget ;
|
||||
|
||||
class GlobalRouterStatistics: public RsAutoUpdatePage, public Ui::GlobalRouterStatistics
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GlobalRouterStatistics(QWidget *parent = NULL) ;
|
||||
~GlobalRouterStatistics();
|
||||
|
||||
// Cache for peer names.
|
||||
static QString getPeerName(const RsPeerId& peer_id) ;
|
||||
|
||||
private:
|
||||
|
||||
void processSettings(bool bLoad);
|
||||
bool m_bProcessSettings;
|
||||
|
||||
virtual void updateDisplay() ;
|
||||
|
||||
GlobalRouterStatisticsWidget *_tst_CW ;
|
||||
} ;
|
||||
|
||||
class GlobalRouterStatisticsWidget: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GlobalRouterStatisticsWidget(QWidget *parent = NULL) ;
|
||||
|
||||
virtual void paintEvent(QPaintEvent *event) ;
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
|
||||
void updateContent() ;
|
||||
private:
|
||||
static QString speedString(float f) ;
|
||||
|
||||
QPixmap pixmap ;
|
||||
int maxWidth,maxHeight ;
|
||||
};
|
||||
|
55
retroshare-gui/src/gui/settings/GlobalRouterStatistics.ui
Normal file
55
retroshare-gui/src/gui/settings/GlobalRouterStatistics.ui
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GlobalRouterStatistics</class>
|
||||
<widget class="QWidget" name="GlobalRouterStatistics">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>611</width>
|
||||
<height>408</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Router Statistics</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QScrollArea" name="_router_F">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>593</width>
|
||||
<height>390</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -22,6 +22,7 @@
|
|||
#include "ServerPage.h"
|
||||
#include <gui/FileTransfer/TurtleRouterDialog.h>
|
||||
#include <gui/FileTransfer/TurtleRouterStatistics.h>
|
||||
#include <gui/settings/GlobalRouterStatistics.h>
|
||||
|
||||
#include "rshare.h"
|
||||
#include "rsharesettings.h"
|
||||
|
@ -78,12 +79,13 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
|
|||
trs->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding)) ;
|
||||
ui.tabWidget->widget(2)->layout()->addWidget(trs) ;
|
||||
ui.tabWidget->widget(2)->layout()->setContentsMargins(0,5,0,0) ;
|
||||
|
||||
QSpacerItem *verticalSpacer = new QSpacerItem(0,0,QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
|
||||
ui.tabWidget->widget(2)->layout()->addItem(verticalSpacer) ;
|
||||
ui.tabWidget->widget(2)->layout()->addItem( new QSpacerItem(0,0,QSizePolicy::Expanding, QSizePolicy::Minimum)) ;
|
||||
ui.tabWidget->widget(2)->layout()->update() ;
|
||||
|
||||
GlobalRouterStatistics *grs = new GlobalRouterStatistics ;
|
||||
grs->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding)) ;
|
||||
ui.tabWidget->addTab(grs,tr("Global routing")) ;
|
||||
|
||||
ui.torpage_incoming->setVisible(false);
|
||||
|
||||
/* Hide platform specific features */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue