merged new GRouter model (branch v0.6-NewGRouterModel 7837-7863). Provides a fully functional distant messaging system. The asynchronous part will be implemented shortly

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7867 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-01-23 19:28:10 +00:00
commit 34f968a112
44 changed files with 2447 additions and 1854 deletions

View file

@ -1521,19 +1521,6 @@ void MessagesDialog::insertMsgTxtAndFiles(QTreeWidgetItem *item, bool bSetToRead
updateInterface();
}
void MessagesDialog::decryptSelectedMsg()
{
if (!MessageWidget::decryptMsg(mCurrMsgId)) {
return;
}
// Force refill
mCurrMsgId.clear();
msgWidget->fill("");
insertMsgTxtAndFiles(ui.messageTreeWidget->currentItem());
}
bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid)
{
QTreeWidgetItem *item = ui.messageTreeWidget->currentItem();

View file

@ -69,7 +69,6 @@ private slots:
/** Create the context popup menu and it's submenus */
void messageTreeWidgetCustomPopupMenu(QPoint point);
void folderlistWidgetCustomPopupMenu(QPoint);
void decryptSelectedMsg() ;
void changeBox(int newrow);
void changeQuickView(int newrow);

View file

@ -1279,7 +1279,6 @@ static void processList(const QStringList &list, const QString &textSingular, co
std::cerr << " RetroShareLink::process MessageRequest : id : " << link.hash().toStdString() << ", subject : " << link.name().toStdString() << std::endl;
#endif
RsPeerDetails detail;
DistantMsgPeerId dm_pid ;
// This is awful, but apparently the hash can be multiple different types. Let's check!

View file

@ -125,7 +125,6 @@ const QString PeerDefs::rsidFromId(const RsPeerId &id, QString *name /* = NULL*/
QString rsid;
std::string peerName = rsPeers->getPeerName(id);
DistantMsgPeerId pid ;
if(!peerName.empty())
{

View file

@ -57,7 +57,9 @@ public:
enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ;
void loadIds(uint32_t chooserFlags, RsGxsId defId);
void setDefaultId(RsGxsId defId) {mDefaultId=defId;}
void setDefaultId(std::string defIdName) {mDefaultIdName=defIdName;}
void setDefaultId(std::string defIdName) {mDefaultIdName=defIdName;}
bool hasAvailableIds() const { return !mDefaultId.isNull() ; }
bool setChosenId(RsGxsId &gxsId);
ChosenId_Ret getChosenId(RsGxsId &gxsId);

View file

@ -2370,7 +2370,7 @@ void MessageComposer::addContact(enumType type)
std::list<RsGxsId> gxsIds ;
ui.friendSelectionWidget->selectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(gxsIds, false);
if(!gxsIds.empty() && ui.respond_to_CB->count() == 0)
if(!gxsIds.empty() && ui.respond_to_CB->hasAvailableIds())
{
QMessageBox::warning(NULL,tr("Cannot send distant messages"),tr("In order to send distant messages, you need an identity to sign with. Please go to the Identities tab and create one first."));
return ;

View file

@ -133,14 +133,12 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WindowFlags f
connect(ui.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview()));
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getallrecommended()));
connect(ui.msgText, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl)));
connect(ui.decryptButton, SIGNAL(clicked()), this, SLOT(decrypt()));
connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged()));
connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), this, SLOT(messagesChanged()));
ui.imageBlockWidget->addButtonAction(tr("Load images always for this message"), this, SLOT(loadImagesAlways()), true);
ui.msgText->setImageBlockWidget(ui.imageBlockWidget);
ui.decryptFrame->hide();
/* hide the Tree +/- */
ui.msgList->setRootIsDecorated( false );
@ -445,8 +443,6 @@ void MessageWidget::fill(const std::string &msgId)
// return;
// }
ui.decryptFrame->hide();
currMsgId = msgId;
if (currMsgId.empty()) {
@ -573,12 +569,7 @@ void MessageWidget::fill(const std::string &msgId)
ui.fromText->setToolTip(tooltip_string) ;
}
if (msgInfo.msgflags & RS_MSG_ENCRYPTED) {
ui.subjectText->setText(tr("Encrypted message"));
ui.fromText->setText(tr("Unknown (needs decryption)")) ;
} else {
ui.subjectText->setText(QString::fromUtf8(msgInfo.title.c_str()));
}
text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromUtf8(msgInfo.msg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_REPLACE_LINKS);
ui.msgText->resetImagesStatus(Settings->getMsgLoadEmbeddedImages() || (msgInfo.msgflags & RS_MSG_LOAD_EMBEDDED_IMAGES));
@ -587,10 +578,6 @@ void MessageWidget::fill(const std::string &msgId)
ui.filesText->setText(QString("%1").arg(msgInfo.count));
ui.filesSize->setText(QString(misc::friendlyUnit(msgInfo.size)));
if (msgInfo.msgflags & RS_MSG_ENCRYPTED) {
ui.decryptFrame->show();
}
showTagLabels();
currMsgFlags = msgInfo.msgflags;
@ -748,40 +735,3 @@ void MessageWidget::loadImagesAlways()
rsMsgs->MessageLoadEmbeddedImages(currMsgId, true);
}
void MessageWidget::decrypt()
{
if (!decryptMsg(currMsgId)) {
return;
}
// Force refill
std::string msgId = currMsgId;
currMsgId.clear();
fill(msgId);
}
bool MessageWidget::decryptMsg(const std::string &msgId)
{
if (msgId.empty()) {
return false;
}
MessageInfo msgInfo;
if (!rsMsgs->getMessage(msgId, msgInfo)) {
return false;
}
if (!(msgInfo.msgflags & RS_MSG_ENCRYPTED)) {
QMessageBox::warning(NULL, tr("Decryption failed!"), tr("This message is not encrypted. Cannot decrypt!"));
return false;
}
if (!rsMsgs->decryptMessage(msgId)) {
QMessageBox::warning(NULL, tr("Decryption failed!"), tr("This message could not be decrypted."));
return false;
}
return true;
}

View file

@ -59,7 +59,6 @@ public:
QString subject(bool noEmpty);
static bool decryptMsg(const std::string &msgId);
private slots:
void reply();
@ -82,7 +81,6 @@ private slots:
void anchorClicked(const QUrl &url);
void loadImagesAlways();
void decrypt();
private:
void clearTagLabels();

View file

@ -23,7 +23,7 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0">
<item row="0" column="0">
<widget class="QSplitter" name="msgSplitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -414,125 +414,6 @@
</widget>
</widget>
</item>
<item row="0" column="0">
<widget class="QFrame" name="decryptFrame">
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>255</green>
<blue>204</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>255</green>
<blue>204</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>255</green>
<blue>204</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>255</green>
<blue>204</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="decryptImage">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/mail-encrypted-full.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="decryptLabel">
<property name="text">
<string>This messages is encrypted. Click the right button to decrypt it.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>280</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="decryptButton">
<property name="text">
<string>Decrypt</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
<action name="actionPrint">
<property name="text">

View file

@ -46,7 +46,7 @@ static QColor colorScale(float f)
}
GlobalRouterStatistics::GlobalRouterStatistics(QWidget *parent)
: RsAutoUpdatePage(2000,parent)
: RsAutoUpdatePage(2000,parent)
{
setupUi(this) ;
@ -170,10 +170,10 @@ void GlobalRouterStatisticsWidget::updateContent()
painter.drawText(ox,oy+celly,tr("Managed keys")+":" + QString::number(matrix_info.published_keys.size())) ; oy += celly*2 ;
painter.setFont(monospace_f) ;
for(std::map<GRouterKeyId,RsGRouter::GRouterPublishedKeyInfo>::const_iterator it(matrix_info.published_keys.begin());it!=matrix_info.published_keys.end();++it)
for(std::map<Sha1CheckSum,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 += QString::fromStdString(it->second.authentication_key.toStdString()) ;
packet_string += tr(" : Service ID = ")+QString::number(it->second.service_id,16) ;
packet_string += " \""+QString::fromUtf8(it->second.description_string.c_str()) + "\"" ;
@ -181,59 +181,29 @@ void GlobalRouterStatisticsWidget::updateContent()
}
oy += celly ;
QString prob_string ;
painter.setFont(times_f) ;
QString Q = tr("Routing matrix (") ;
painter.drawText(ox+0*cellx,oy+fm_times.height(),Q) ;
// draw scale
for(int i=0;i<100;++i)
{
painter.setPen(colorScale(i/100.0)) ;
painter.drawLine(fm_times.width(Q)+i,oy+celly+2,fm_times.width(Q)+i,oy+2) ;
}
painter.setPen(QColor::fromRgb(0,0,0)) ;
painter.drawText(ox+fm_times.width(Q) + 100,oy+celly,")") ;
oy += celly ;
oy += celly ;
static const int MaxKeySize = 20 ;
painter.setFont(monospace_f) ;
for(std::map<GRouterKeyId,std::vector<float> >::const_iterator it(matrix_info.per_friend_probabilities.begin());it!=matrix_info.per_friend_probabilities.end();++it)
{
QString ids = QString::fromStdString(it->first.toStdString())+" : " ;
painter.drawText(ox+2*cellx,oy+celly,ids) ;
for(uint32_t i=0;i<matrix_info.friend_ids.size();++i)
painter.fillRect(ox+i*cellx+fm_monospace.width(ids),oy,cellx,celly,colorScale(it->second[i])) ;
oy += celly ;
}
oy += celly ;
painter.setFont(times_f) ;
painter.drawText(ox,oy+celly,tr("Pending packets")+":" + QString::number(cache_infos.size())) ; oy += celly*2 ;
painter.setFont(monospace_f) ;
static const QString status_string[5] = { "UNKN", "PEND","SENT","ACKN","DEAD" } ;
time_t now = time(NULL) ;
static const QString data_status_string[4] = { "UNKOWN","PENDING","SENT","RECEIVED" } ;
static const QString tunnel_status_string[3] = { "UNMANAGED", "REQUESTED","ACTIVE" } ;
time_t now = time(NULL) ;
std::map<QString, std::vector<QString> > tos ;
for(uint32_t i=0;i<cache_infos.size();++i)
{
QString packet_string ;
packet_string += QString("Id=")+QString::number(cache_infos[i].mid,16) ;
packet_string += tr(" by ")+QString::fromStdString(cache_infos[i].local_origin.toStdString()) ;
packet_string += tr(" size=")+QString::number(cache_infos[i].data_size) ;
packet_string += tr(" Status ")+status_string[cache_infos[i].status % 6] ;
packet_string += " " + tr("%1 secs ago").arg(now - cache_infos[i].time_stamp);
//packet_string += tr(" By ")+QString::fromStdString(cache_infos[i].local_origin.toStdString()) ;
packet_string += tr(" Size: ")+QString::number(cache_infos[i].data_size) ;
packet_string += tr(" Data status: ")+data_status_string[cache_infos[i].data_status % 4] ;
packet_string += tr(" Tunnel status: ")+tunnel_status_string[cache_infos[i].tunnel_status % 3] ;
packet_string += " " + tr("Received: %1 secs ago, Send: %2 secs ago, Tried: %3 secs ago")
.arg(now - cache_infos[i].routing_time)
.arg(now - cache_infos[i].last_sent_time)
.arg(now - cache_infos[i].last_tunnel_attempt_time);
tos[ QString::fromStdString(cache_infos[i].destination.toStdString()) ].push_back(packet_string) ;
}
@ -248,6 +218,42 @@ void GlobalRouterStatisticsWidget::updateContent()
oy += celly ;
}
}
oy += celly ;
QString prob_string ;
painter.setFont(times_f) ;
QString Q = tr("Routing matrix (") ;
painter.drawText(ox+0*cellx,oy+fm_times.height(),Q) ;
// draw scale
for(int i=0;i<100;++i)
{
painter.setPen(colorScale(i/100.0)) ;
painter.drawLine(fm_times.width(Q)+i,oy+celly+2,fm_times.width(Q)+i,oy+2) ;
}
painter.setPen(QColor::fromRgb(0,0,0)) ;
painter.drawText(ox+fm_times.width(Q) + 100,oy+celly,")") ;
oy += celly ;
oy += celly ;
static const int MaxKeySize = 20 ;
painter.setFont(monospace_f) ;
for(std::map<GRouterKeyId,std::vector<float> >::const_iterator it(matrix_info.per_friend_probabilities.begin());it!=matrix_info.per_friend_probabilities.end();++it)
{
QString ids = QString::fromStdString(it->first.toStdString())+" : " ;
painter.drawText(ox+2*cellx,oy+celly,ids) ;
for(uint32_t i=0;i<matrix_info.friend_ids.size();++i)
painter.fillRect(ox+i*cellx+fm_monospace.width(ids),oy,cellx,celly,colorScale(it->second[i])) ;
oy += celly ;
}
oy += celly ;