mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-11-27 19:10:41 -05:00
implement dummy friend for a gpg key, improve PersDialog ui
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2018 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9976b80566
commit
e50dc4e3b9
9 changed files with 212 additions and 83 deletions
|
|
@ -275,7 +275,7 @@ void PeersDialog::insertPeers()
|
|||
rsPeers->getGPGAcceptedList(gpgFriends);
|
||||
|
||||
/* get a link to the table */
|
||||
QTreeWidget *peerWidget = ui.peertreeWidget;
|
||||
QTreeWidget *peertreeWidget = ui.peertreeWidget;
|
||||
|
||||
// add self nick and Avatar to Friends.
|
||||
RsPeerDetails pd ;
|
||||
|
|
@ -285,6 +285,18 @@ void PeersDialog::insertPeers()
|
|||
ui.nicklabel->setText(titleStr.arg(QString::fromStdString(pd.name) + tr(" (me)"))) ;
|
||||
}
|
||||
|
||||
//remove items that are not fiends anymore
|
||||
int index = 0;
|
||||
while (index < peertreeWidget->topLevelItemCount()) {
|
||||
std::string gpg_id = (peertreeWidget->topLevelItem(index))->text(3).toStdString();
|
||||
if (!rsPeers->isGPGAccepted(gpg_id)) {
|
||||
peertreeWidget->takeTopLevelItem(index);
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//add the gpg friends
|
||||
for(it = gpgFriends.begin(); it != gpgFriends.end(); it++) {
|
||||
std::cerr << "" << *it << std::endl;
|
||||
|
|
@ -292,54 +304,72 @@ void PeersDialog::insertPeers()
|
|||
continue;
|
||||
}
|
||||
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(*it, detail)) {
|
||||
continue; /* BAD */
|
||||
}
|
||||
|
||||
/* make a widget per friend */
|
||||
QTreeWidgetItem *item;
|
||||
QList<QTreeWidgetItem *> list = peerWidget->findItems (QString::fromStdString(detail.gpg_id), Qt::MatchExactly, 3);
|
||||
QTreeWidgetItem *gpg_item;
|
||||
QList<QTreeWidgetItem *> list = peertreeWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 3);
|
||||
if (list.size() == 1) {
|
||||
item = list.front();
|
||||
gpg_item = list.front();
|
||||
} else {
|
||||
item = new QTreeWidgetItem(0);
|
||||
item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||
gpg_item = new QTreeWidgetItem(0);
|
||||
gpg_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||
}
|
||||
|
||||
item -> setText(0, QString::fromStdString(detail.name));
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(*it, detail) || !detail.accept_connection) {
|
||||
//don't accept anymore connection, remove from the view
|
||||
peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpg_item));
|
||||
continue;
|
||||
}
|
||||
|
||||
item -> setTextAlignment(0, Qt::AlignLeft | Qt::AlignVCenter );
|
||||
//use to mark item as updated
|
||||
gpg_item->setData(0, Qt::UserRole, true);
|
||||
gpg_item -> setText(0, QString::fromStdString(detail.name));
|
||||
|
||||
//item -> setText( 1, QString::fromStdString(detail.name));
|
||||
gpg_item -> setTextAlignment(0, Qt::AlignLeft | Qt::AlignVCenter );
|
||||
|
||||
//gpg_item -> setText( 1, QString::fromStdString(detail.name));
|
||||
|
||||
/* not displayed, used to find back the item */
|
||||
item -> setText(3, QString::fromStdString(detail.id));
|
||||
gpg_item -> setText(3, QString::fromStdString(detail.id));
|
||||
|
||||
/* add to the list. If item is already in the list, it won't be duplicated thanks to Qt */
|
||||
peerWidget->addTopLevelItem(item);
|
||||
|
||||
//add the childs (ssl certs)
|
||||
//item->takeChildren();
|
||||
//remove items that are not friends anymore
|
||||
int childIndex = 0;
|
||||
while (childIndex < gpg_item->childCount()) {
|
||||
std::string ssl_id = (gpg_item->child(childIndex))->text(3).toStdString();
|
||||
if (!rsPeers->isFriend(ssl_id)) {
|
||||
gpg_item->takeChild(childIndex);
|
||||
} else {
|
||||
childIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
//update the childs (ssl certs)
|
||||
std::list<std::string> sslContacts;
|
||||
rsPeers->getSSLChildListOfGPGId(detail.gpg_id, sslContacts);
|
||||
for(std::list<std::string>::iterator sslIt = sslContacts.begin(); sslIt != sslContacts.end(); sslIt++) {
|
||||
RsPeerDetails sslDetail;
|
||||
if (!rsPeers->getPeerDetails(*sslIt, sslDetail)) {
|
||||
continue; /* BAD */
|
||||
}
|
||||
|
||||
/* find the sslItem */
|
||||
QTreeWidgetItem *sslItem = new QTreeWidgetItem(1);
|
||||
bool gotToExpandBecauseNewChild = true;
|
||||
for (int childIndex = 0; childIndex < item->childCount(); childIndex++) {
|
||||
if (item->child(childIndex)->text(3).toStdString() == sslDetail.id) {
|
||||
sslItem = item->child(childIndex);
|
||||
gotToExpandBecauseNewChild = false;
|
||||
QTreeWidgetItem *sslItem;
|
||||
|
||||
//find the corresponding sslItem child item of the gpg item
|
||||
bool newChild = true;
|
||||
for (int childIndex = 0; childIndex < gpg_item->childCount(); childIndex++) {
|
||||
if (gpg_item->child(childIndex)->text(3).toStdString() == *sslIt) {
|
||||
sslItem = gpg_item->child(childIndex);
|
||||
newChild = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newChild) {
|
||||
sslItem = new QTreeWidgetItem(1);
|
||||
}
|
||||
|
||||
RsPeerDetails sslDetail;
|
||||
if (!rsPeers->getPeerDetails(*sslIt, sslDetail) || !rsPeers->isFriend(*sslIt)) {
|
||||
std::cerr << "Removing widget from the view : id : " << *sslIt << std::endl;
|
||||
//child has disappeared, remove it from the gpg_item
|
||||
gpg_item->removeChild(sslItem);
|
||||
}
|
||||
|
||||
/* not displayed, used to find back the item */
|
||||
sslItem -> setText(3, QString::fromStdString(sslDetail.id));
|
||||
|
||||
|
|
@ -399,11 +429,15 @@ void PeersDialog::insertPeers()
|
|||
std::cerr << "PeersDialog::insertPeers() inserting sslItem." << std::endl;
|
||||
#endif
|
||||
/* add to the list. If item is already in the list, it won't be duplicated thanks to Qt */
|
||||
item->addChild(sslItem);
|
||||
if (gotToExpandBecauseNewChild) {
|
||||
item->setExpanded(true);
|
||||
gpg_item->addChild(sslItem);
|
||||
if (newChild) {
|
||||
gpg_item->setExpanded(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* add to the list. If item is already in the list, it won't be duplicated thanks to Qt */
|
||||
peertreeWidget->addTopLevelItem(gpg_item);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ signals:
|
|||
QAction* exportfriendAct;
|
||||
QAction* removefriendAct;
|
||||
|
||||
QTreeWidget *peertreeWidget;
|
||||
//QTreeWidget *peertreeWidget;
|
||||
|
||||
IMHistoryKeeper historyKeeper;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ ConfCertDialog::ConfCertDialog(QWidget *parent, Qt::WFlags flags)
|
|||
|
||||
connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog()));
|
||||
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg()));
|
||||
connect(ui.sign_button, SIGNAL(clicked()), this, SLOT(makeFriend()));
|
||||
connect(ui.make_friend_button, SIGNAL(clicked()), this, SLOT(makeFriend()));
|
||||
|
||||
|
||||
ui.applyButton->setToolTip(tr("Apply and Close"));
|
||||
|
|
@ -151,11 +151,29 @@ void ConfCertDialog::loadDialog()
|
|||
ui.groupBox->hide();
|
||||
}
|
||||
|
||||
if (detail.ownsign) {
|
||||
ui.sign_button->hide();
|
||||
ui.signed_already_label->show();
|
||||
if (detail.accept_connection) {
|
||||
//connection already accepted, propose to sign gpg key
|
||||
if (!detail.ownsign) {
|
||||
ui.signGPGKeyCheckBox->setChecked(true);
|
||||
ui.signGPGKeyCheckBox->hide();
|
||||
ui.signed_already_label->setText(tr("Peer is already a friend"));
|
||||
ui.make_friend_button->setText(tr("Sign GPG key"));
|
||||
ui.make_friend_button->show();
|
||||
} else {
|
||||
ui.signGPGKeyCheckBox->hide();
|
||||
ui.signed_already_label->setText(tr("Peer is a friend and GPG key is signed"));
|
||||
ui.signed_already_label->show();
|
||||
ui.make_friend_button->hide();
|
||||
}
|
||||
} else {
|
||||
ui.sign_button->show();
|
||||
ui.make_friend_button->show();
|
||||
ui.make_friend_button->setText(tr("Make Friend"));
|
||||
if (!detail.ownsign) {
|
||||
ui.signGPGKeyCheckBox->show();
|
||||
ui.signGPGKeyCheckBox->setChecked(true);
|
||||
} else {
|
||||
ui.signGPGKeyCheckBox->hide();
|
||||
}
|
||||
ui.signed_already_label->hide();
|
||||
}
|
||||
|
||||
|
|
@ -177,13 +195,13 @@ void ConfCertDialog::loadDialog()
|
|||
ui.radioButton_trust_marginnaly->show();
|
||||
ui.radioButton_trust_never->show();
|
||||
if (detail.trustLvl == 4) {
|
||||
ui.web_of_trust_label->setText(tr("Your trust in this peer is full, it means he has an excellent understanding of key signing, and his signature on a key would be as good as your own."));
|
||||
ui.web_of_trust_label->setText(tr("Your trust in this peer is full."));
|
||||
ui.radioButton_trust_fully->setChecked(true);
|
||||
} else if (detail.trustLvl == 3) {
|
||||
ui.web_of_trust_label->setText(tr("Your trust in this peer is marginal, it means he understands the implications of key signing and properly check keys before signing them."));
|
||||
ui.web_of_trust_label->setText(tr("Your trust in this peer is marginal."));
|
||||
ui.radioButton_trust_marginnaly->setChecked(true);
|
||||
} else if (detail.trustLvl == 2) {
|
||||
ui.web_of_trust_label->setText(tr("Your trust in this peer is none, it means he is known to improperly sign other keys."));
|
||||
ui.web_of_trust_label->setText(tr("Your trust in this peer is none."));
|
||||
ui.radioButton_trust_never->setChecked(true);
|
||||
} else {
|
||||
ui.web_of_trust_label->setText(tr("Your trust in this peer is not set."));
|
||||
|
|
@ -256,6 +274,12 @@ void ConfCertDialog::applyDialog()
|
|||
|
||||
void ConfCertDialog::makeFriend()
|
||||
{
|
||||
rsPeers->signGPGCertificate(mId);
|
||||
loadDialog();
|
||||
std::string gpg_id = rsPeers->getGPGId(mId);
|
||||
if (ui.signGPGKeyCheckBox->isChecked()) {
|
||||
rsPeers->signGPGCertificate(gpg_id);
|
||||
} else {
|
||||
rsPeers->setAcceptToConnectGPGCertificate(gpg_id, true);
|
||||
}
|
||||
rsPeers->addFriend(mId, gpg_id);
|
||||
loadDialog();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>506</width>
|
||||
<width>459</width>
|
||||
<height>529</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="stabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="icon">
|
||||
|
|
@ -286,15 +286,37 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="signed_already_label">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>450</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Peer is already a friend of me (his GPG key is signed by me)</string>
|
||||
<string>Not filled</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="sign_button">
|
||||
<widget class="QCheckBox" name="signGPGKeyCheckBox">
|
||||
<property name="text">
|
||||
<string>Make friend (Sign his GPG key)</string>
|
||||
<string>Sign GPG key (Default)</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="make_friend_button">
|
||||
<property name="text">
|
||||
<string>Make Friends</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -332,6 +354,9 @@
|
|||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_trust_never">
|
||||
<property name="toolTip">
|
||||
<string>Your trust in this peer is none, it means he is known to improperly sign other keys.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
|
|
@ -339,6 +364,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_trust_marginnaly">
|
||||
<property name="toolTip">
|
||||
<string>Your trust in this peer is marginal, it means he understands the implications of key signing and properly check keys before signing them.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Marginnaly</string>
|
||||
</property>
|
||||
|
|
@ -346,6 +374,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_trust_fully">
|
||||
<property name="toolTip">
|
||||
<string>Your trust in this peer is full, it means he has an excellent understanding of key signing, and his signature on a key would be as good as your own.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fully</string>
|
||||
</property>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue