void IdDetailsDialog::insertIdDetails(uint32_t token) { mStateHelper->setLoading(IDDETAILSDIALOG_IDDETAILS, false); /* get details from libretroshare */ std::vector<RsGxsIdGroup> datavector; if (!rsIdentity->getGroupData(token, datavector)) { mStateHelper->setActive(IDDETAILSDIALOG_IDDETAILS, false); mStateHelper->clear(IDDETAILSDIALOG_REPLIST); ui->lineEdit_KeyId->setText("ERROR GETTING KEY!"); return; } if (datavector.size() != 1) { #ifdef ID_DEBUG std::cerr << "IdDetailsDialog::insertIdDetails() Invalid datavector size"; #endif mStateHelper->setActive(IDDETAILSDIALOG_IDDETAILS, false); mStateHelper->clear(IDDETAILSDIALOG_IDDETAILS); ui->lineEdit_KeyId->setText("INVALID DV SIZE"); return; } mStateHelper->setActive(IDDETAILSDIALOG_IDDETAILS, true); RsGxsIdGroup &data = datavector[0]; /* get GPG Details from rsPeers */ RsPgpId ownPgpId = rsPeers->getGPGOwnId(); ui->lineEdit_Nickname->setText(QString::fromUtf8(data.mMeta.mGroupName.c_str())); ui->lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId.toStdString())); //ui->lineEdit_GpgHash->setText(QString::fromStdString(data.mPgpIdHash.toStdString())); ui->lineEdit_GpgId->setText(QString::fromStdString(data.mPgpId.toStdString())); time_t now = time(NULL) ; ui->lineEdit_LastUsed->setText(getHumanReadableDuration(now - data.mLastUsageTS)) ; QPixmap pixmap; if(data.mImage.mSize > 0 && pixmap.loadFromData(data.mImage.mData, data.mImage.mSize, "PNG")) ui->avatarLabel->setPixmap(pixmap); else pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId))) ; ui->avatarLabel->setPixmap(pixmap); // we need to use the default pixmap here, generated from the ID #ifdef ID_DEBUG std::cerr << "Setting header frame image : " << pix.width() << " x " << pix.height() << std::endl; #endif if (data.mPgpKnown) { RsPeerDetails details; rsPeers->getGPGDetails(data.mPgpId, details); ui->lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str())); } else { if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) { ui->lineEdit_GpgName->setText(tr("Unknown real name")); } else { ui->lineEdit_GpgName->setText(tr("Anonymous Id")); } } if(data.mPgpId.isNull()) { ui->lineEdit_GpgId->hide() ; ui->lineEdit_GpgName->hide() ; ui->PgpId_LB->hide() ; ui->PgpName_LB->hide() ; } else { ui->lineEdit_GpgId->show() ; ui->lineEdit_GpgName->show() ; ui->PgpId_LB->show() ; ui->PgpName_LB->show() ; } bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) || (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); if (isOwnId) if (data.mPgpKnown) ui->lineEdit_Type->setText(tr("Identity owned by you, linked to your Retroshare node")) ; else ui->lineEdit_Type->setText(tr("Anonymous identity, owned by you")) ; else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) { if (data.mPgpKnown) if (rsPeers->isGPGAccepted(data.mPgpId)) ui->lineEdit_Type->setText(tr("Owned by a friend Retroshare node")) ; else ui->lineEdit_Type->setText(tr("Owned by 2-hops Retroshare node")) ; else ui->lineEdit_Type->setText(tr("Owned by unknown Retroshare node")) ; } else ui->lineEdit_Type->setText(tr("Anonymous identity")) ; if (isOwnId) { mStateHelper->setWidgetEnabled(ui->ownOpinion_CB, false); } else { // No Reputation yet! mStateHelper->setWidgetEnabled(ui->ownOpinion_CB, true); } /* now fill in the reputation information */ #ifdef SUSPENDED if (data.mPgpKnown) { ui->line_RatingImplicit->setText(tr("+50 Known PGP")); } else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) { ui->line_RatingImplicit->setText(tr("+10 UnKnown PGP")); } else { ui->line_RatingImplicit->setText(tr("+5 Anon Id")); } { QString rating = QString::number(data.mReputation.mIdScore); ui->line_RatingImplicit->setText(rating); } #endif RsReputations::ReputationInfo info ; rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId),data.mPgpId,info) ; ui->neighborNodesOpinion_TF->setText(QString::number(info.mOverallReputationScore-1.0f)); ui->overallOpinion_TF->setText(QString::number(info.mOverallReputationScore-1.0f) +" ("+ ((info.mAssessment == RsReputations::ASSESSMENT_OK)? tr("OK") : tr("Banned")) +")" ) ; switch(info.mOwnOpinion) { case RsReputations::OPINION_NEGATIVE: ui->ownOpinion_CB->setCurrentIndex(0); break ; case RsReputations::OPINION_NEUTRAL : ui->ownOpinion_CB->setCurrentIndex(1); break ; case RsReputations::OPINION_POSITIVE: ui->ownOpinion_CB->setCurrentIndex(2); break ; default: std::cerr << "Unexpected value in own opinion: " << info.mOwnOpinion << std::endl; } }
void IdDialog::insertIdDetails(uint32_t token) { mStateHelper->setLoading(IDDIALOG_IDDETAILS, false); /* get details from libretroshare */ RsGxsIdGroup data; std::vector<RsGxsIdGroup> datavector; if (!rsIdentity->getGroupData(token, datavector)) { mStateHelper->setActive(IDDIALOG_IDDETAILS, false); mStateHelper->clear(IDDIALOG_REPLIST); ui->lineEdit_KeyId->setText("ERROR GETTING KEY!"); return; } if (datavector.size() != 1) { #ifdef ID_DEBUG std::cerr << "IdDialog::insertIdDetails() Invalid datavector size"; #endif mStateHelper->setActive(IDDIALOG_IDDETAILS, false); mStateHelper->clear(IDDIALOG_IDDETAILS); ui->lineEdit_KeyId->setText("INVALID DV SIZE"); return; } mStateHelper->setActive(IDDIALOG_IDDETAILS, true); data = datavector[0]; /* get GPG Details from rsPeers */ RsPgpId ownPgpId = rsPeers->getGPGOwnId(); ui->lineEdit_Nickname->setText(QString::fromUtf8(data.mMeta.mGroupName.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE)); ui->lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId.toStdString())); //ui->lineEdit_GpgHash->setText(QString::fromStdString(data.mPgpIdHash.toStdString())); ui->lineEdit_GpgId->setText(QString::fromStdString(data.mPgpId.toStdString())); time_t now = time(NULL) ; ui->lineEdit_LastUsed->setText(getHumanReadableDuration(now - data.mLastUsageTS)) ; ui->headerTextLabel->setText(QString::fromUtf8(data.mMeta.mGroupName.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE)); QPixmap pixmap ; if(data.mImage.mSize == 0 || !pixmap.loadFromData(data.mImage.mData, data.mImage.mSize, "PNG")) pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId))) ; #ifdef ID_DEBUG std::cerr << "Setting header frame image : " << pix.width() << " x " << pix.height() << std::endl; #endif ui->avlabel->setPixmap(pixmap); ui->avatarLabel->setPixmap(pixmap); if (data.mPgpKnown) { RsPeerDetails details; rsPeers->getGPGDetails(data.mPgpId, details); ui->lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str())); } else { if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) { ui->lineEdit_GpgName->setText(tr("Unknown real name")); } else { ui->lineEdit_GpgName->setText(tr("Anonymous Id")); } } if(data.mPgpId.isNull()) { ui->lineEdit_GpgId->hide() ; ui->lineEdit_GpgName->hide() ; ui->PgpId_LB->hide() ; ui->PgpName_LB->hide() ; } else { ui->lineEdit_GpgId->show() ; ui->lineEdit_GpgName->show() ; ui->PgpId_LB->show() ; ui->PgpName_LB->show() ; } bool isLinkedToOwnPgpId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) ; bool isOwnId = (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); if(isOwnId) if (isLinkedToOwnPgpId) ui->lineEdit_Type->setText(tr("Identity owned by you, linked to your Retroshare node")) ; else ui->lineEdit_Type->setText(tr("Anonymous identity, owned by you")) ; else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) { if (data.mPgpKnown) if (rsPeers->isGPGAccepted(data.mPgpId)) ui->lineEdit_Type->setText(tr("Linked to a friend Retroshare node")) ; else ui->lineEdit_Type->setText(tr("Linked to a known Retroshare node")) ; else ui->lineEdit_Type->setText(tr("Linked to unknown Retroshare node")) ; } else ui->lineEdit_Type->setText(tr("Anonymous identity")) ; // if (isOwnId) // { // ui->radioButton_IdYourself->setChecked(true); // } // else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) // { // if (data.mPgpKnown) // { // if (rsPeers->isGPGAccepted(data.mPgpId)) // { // ui->radioButton_IdFriend->setChecked(true); // } // else // { // ui->radioButton_IdFOF->setChecked(true); // } // } // else // { // ui->radioButton_IdOther->setChecked(true); // } // } // else // { // ui->radioButton_IdPseudo->setChecked(true); // } if (isOwnId) { mStateHelper->setWidgetEnabled(ui->toolButton_Reputation, false); ui->editIdentity->setEnabled(true); ui->removeIdentity->setEnabled(true); ui->chatIdentity->setEnabled(false); ui->messageButton->setEnabled(false); } else { // No Reputation yet! mStateHelper->setWidgetEnabled(ui->toolButton_Reputation, /*true*/ false); ui->editIdentity->setEnabled(false); ui->removeIdentity->setEnabled(false); ui->chatIdentity->setEnabled(true); ui->messageButton->setEnabled(true); } /* now fill in the reputation information */ ui->line_RatingOverall->setText("Overall Rating TODO"); ui->line_RatingOwn->setText("Own Rating TODO"); if (data.mPgpKnown) { ui->line_RatingImplicit->setText(tr("+50 Known PGP")); } else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) { ui->line_RatingImplicit->setText(tr("+10 UnKnown PGP")); } else { ui->line_RatingImplicit->setText(tr("+5 Anon Id")); } { QString rating = QString::number(data.mReputation.mOverallScore); ui->line_RatingOverall->setText(rating); } { QString rating = QString::number(data.mReputation.mIdScore); ui->line_RatingImplicit->setText(rating); } { QString rating = QString::number(data.mReputation.mOwnOpinion); ui->line_RatingOwn->setText(rating); } { QString rating = QString::number(data.mReputation.mPeerOpinion); ui->line_RatingPeers->setText(rating); } }
void IdDetailsDialog::insertIdDetails(uint32_t token) { mStateHelper->setLoading(IDDETAILSDIALOG_IDDETAILS, false); /* get details from libretroshare */ std::vector<RsGxsIdGroup> datavector; if (!rsIdentity->getGroupData(token, datavector)) { mStateHelper->setActive(IDDETAILSDIALOG_IDDETAILS, false); mStateHelper->clear(IDDETAILSDIALOG_REPLIST); ui->lineEdit_KeyId->setText("ERROR GETTING KEY!"); return; } if (datavector.size() != 1) { #ifdef ID_DEBUG std::cerr << "IdDetailsDialog::insertIdDetails() Invalid datavector size"; #endif mStateHelper->setActive(IDDETAILSDIALOG_IDDETAILS, false); mStateHelper->clear(IDDETAILSDIALOG_IDDETAILS); ui->lineEdit_KeyId->setText("INVALID DV SIZE"); return; } mStateHelper->setActive(IDDETAILSDIALOG_IDDETAILS, true); RsGxsIdGroup &data = datavector[0]; /* get GPG Details from rsPeers */ RsPgpId ownPgpId = rsPeers->getGPGOwnId(); ui->lineEdit_Nickname->setText(QString::fromUtf8(data.mMeta.mGroupName.c_str())); ui->lineEdit_KeyId->setText(QString::fromStdString(data.mMeta.mGroupId.toStdString())); if(data.mPgpKnown) ui->lineEdit_GpgId->setText(QString::fromStdString(data.mPgpId.toStdString())); else ui->lineEdit_GpgId->setText(QString::fromStdString(data.mPgpId.toStdString()) + tr(" [unverified]")); ui->autoBanIdentities_CB->setVisible(!data.mPgpId.isNull()) ; ui->banoption_label->setVisible(!data.mPgpId.isNull()) ; time_t now = time(NULL) ; ui->lineEdit_LastUsed->setText(getHumanReadableDuration(now - data.mLastUsageTS)) ; QPixmap pixmap; if(data.mImage.mSize > 0 && pixmap.loadFromData(data.mImage.mData, data.mImage.mSize, "PNG")) ui->avatarLabel->setPixmap(pixmap) ; else { pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId)) ) ; ui->avatarLabel->setPixmap(pixmap) ; // we need to use the default pixmap here, generated from the ID } #ifdef ID_DEBUG std::cerr << "Setting header frame image : " << pix.width() << " x " << pix.height() << std::endl; #endif if (data.mPgpKnown) { RsPeerDetails details; rsPeers->getGPGDetails(data.mPgpId, details); ui->lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str())); } else { if(data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) { ui->lineEdit_GpgName->setText(tr("Unknown real name")); } else { ui->lineEdit_GpgName->setText(tr("Anonymous Id")); } } if(data.mPgpId.isNull()) { ui->lineEdit_GpgId->hide() ; ui->lineEdit_GpgName->hide() ; ui->PgpId_LB->hide() ; ui->PgpName_LB->hide() ; } else { ui->lineEdit_GpgId->show() ; ui->lineEdit_GpgName->show() ; ui->PgpId_LB->show() ; ui->PgpName_LB->show() ; } bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) || (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); if (isOwnId) { if (data.mPgpKnown) ui->lineEdit_Type->setText(tr("Identity owned by you, linked to your Retroshare node")) ; else ui->lineEdit_Type->setText(tr("Anonymous identity, owned by you")) ; } else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility) { if(data.mPgpKnown) if (rsPeers->isGPGAccepted(data.mPgpId)) ui->lineEdit_Type->setText(tr("Owned by a friend Retroshare node")) ; else ui->lineEdit_Type->setText(tr("Owned by 2-hops Retroshare node")) ; else ui->lineEdit_Type->setText(tr("Owned by unknown Retroshare node")) ; } else ui->lineEdit_Type->setText(tr("Anonymous identity")) ; if (isOwnId) { mStateHelper->setWidgetEnabled(ui->ownOpinion_CB, false); } else { // No Reputation yet! mStateHelper->setWidgetEnabled(ui->ownOpinion_CB, true); } ui->autoBanIdentities_CB->setChecked(rsReputations->isNodeBanned(data.mPgpId)); /* now fill in the reputation information */ #ifdef SUSPENDED if (data.mPgpKnown) { ui->line_RatingImplicit->setText(tr("+50 Known PGP")); } else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) { ui->line_RatingImplicit->setText(tr("+10 UnKnown PGP")); } else { ui->line_RatingImplicit->setText(tr("+5 Anon Id")); } { QString rating = QString::number(data.mReputation.mIdScore); ui->line_RatingImplicit->setText(rating); } #endif RsReputations::ReputationInfo info ; rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId),data.mPgpId,info) ; #warning (csoler) Do we need to do this? This code is apparently not used. QString frep_string ; if(info.mFriendsPositiveVotes > 0) frep_string += QString::number(info.mFriendsPositiveVotes) + tr(" positive ") ; if(info.mFriendsNegativeVotes > 0) frep_string += QString::number(info.mFriendsNegativeVotes) + tr(" negative ") ; if(info.mFriendsPositiveVotes==0 && info.mFriendsNegativeVotes==0) frep_string = tr("No votes from friends") ; ui->neighborNodesOpinion_TF->setText(frep_string) ; ui->label_positive->setText(QString::number(info.mFriendsPositiveVotes)); ui->label_negative->setText(QString::number(info.mFriendsNegativeVotes)); switch(info.mOverallReputationLevel) { case RsReputations::REPUTATION_LOCALLY_POSITIVE: ui->overallOpinion_TF->setText(tr("Positive")) ; break ; case RsReputations::REPUTATION_LOCALLY_NEGATIVE: ui->overallOpinion_TF->setText(tr("Negative (Banned by you)")) ; break ; case RsReputations::REPUTATION_REMOTELY_POSITIVE: ui->overallOpinion_TF->setText(tr("Positive (according to your friends)")) ; break ; case RsReputations::REPUTATION_REMOTELY_NEGATIVE: ui->overallOpinion_TF->setText(tr("Negative (according to your friends)")) ; break ; default: case RsReputations::REPUTATION_NEUTRAL: ui->overallOpinion_TF->setText(tr("Neutral")) ; break ; } switch(info.mOwnOpinion) { case RsReputations::OPINION_NEGATIVE: ui->ownOpinion_CB->setCurrentIndex(0); break ; case RsReputations::OPINION_NEUTRAL : ui->ownOpinion_CB->setCurrentIndex(1); break ; case RsReputations::OPINION_POSITIVE: ui->ownOpinion_CB->setCurrentIndex(2); break ; default: std::cerr << "Unexpected value in own opinion: " << info.mOwnOpinion << std::endl; } }