separated "owned by you" and "linked to your node" which are two different things; fixed bug showing chat menu for own identity

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7919 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-02-05 20:37:24 +00:00
parent 6620269f31
commit e6d92bf44e
2 changed files with 104 additions and 96 deletions

View File

@ -33,11 +33,11 @@ List of fixes/improvements before 0.6
Chat Chat
[ ] Distant chat window should show GXS avatars [ ] Distant chat window should show GXS avatars
[ ] Distant chat should work with shared identities [ ] Distant chat should work with shared identities
[ ] You should not be enabled to distant-chat yourself! [X] You should not be enabled to distant-chat yourself!
Identities: Identities:
[ ] "Owned by you" => "Owned by node [nodename]" [X] "Owned by you" => "Owned by node [nodename]"
[ ] Bold face should only be used for keys with admin credentials [X] Bold face should only be used for keys with admin credentials
[ ] reputations are not used yet. We should hide them. [ ] reputations are not used yet. We should hide them.
[ ] Add timeout to Identities that are unused. Need to keep a time stamp list, updated [ ] Add timeout to Identities that are unused. Need to keep a time stamp list, updated
whenever the identity is used for checking signatures. whenever the identity is used for checking signatures.
@ -49,6 +49,9 @@ List of fixes/improvements before 0.6
[X] remove the Ghost news feed items [X] remove the Ghost news feed items
[ ] remove the double feed publication [ ] remove the double feed publication
libretroshare
[ ] fix the data race in pqissl
[ ] make a valgrind pass for
Post v0.6 release changes Post v0.6 release changes
========================= =========================

View File

@ -62,10 +62,11 @@
#define RSIDREP_COL_COMMENT 2 #define RSIDREP_COL_COMMENT 2
#define RSIDREP_COL_REPUTATION 3 #define RSIDREP_COL_REPUTATION 3
#define RSID_FILTER_YOURSELF 0x0001 #define RSID_FILTER_OWNED_BY_YOU 0x0001
#define RSID_FILTER_FRIENDS 0x0002 #define RSID_FILTER_FRIENDS 0x0002
#define RSID_FILTER_OTHERS 0x0004 #define RSID_FILTER_OTHERS 0x0004
#define RSID_FILTER_PSEUDONYMS 0x0008 #define RSID_FILTER_PSEUDONYMS 0x0008
#define RSID_FILTER_YOURSELF 0x0010
#define RSID_FILTER_ALL 0xffff #define RSID_FILTER_ALL 0xffff
#define IMAGE_EDIT ":/images/edit_16.png" #define IMAGE_EDIT ":/images/edit_16.png"
@ -154,11 +155,12 @@ IdDialog::IdDialog(QWidget *parent) :
ui->splitter->setStretchFactor(1, 0); ui->splitter->setStretchFactor(1, 0);
/* Add filter types */ /* Add filter types */
ui->filterComboBox->addItem(tr("All"), RSID_FILTER_ALL); ui->filterComboBox->addItem(tr("All"), RSID_FILTER_ALL);
ui->filterComboBox->addItem(tr("Owned by you"), RSID_FILTER_YOURSELF); ui->filterComboBox->addItem(tr("Owned by you"), RSID_FILTER_OWNED_BY_YOU);
ui->filterComboBox->addItem(tr("Owned by neighbor nodes"), RSID_FILTER_FRIENDS); ui->filterComboBox->addItem(tr("Linked to your node"), RSID_FILTER_YOURSELF);
ui->filterComboBox->addItem(tr("Owned by distant nodes"), RSID_FILTER_OTHERS); ui->filterComboBox->addItem(tr("Linked to neighbor nodes"), RSID_FILTER_FRIENDS);
ui->filterComboBox->addItem(tr("Anonymous"), RSID_FILTER_PSEUDONYMS); ui->filterComboBox->addItem(tr("Linked to distant nodes"), RSID_FILTER_OTHERS);
ui->filterComboBox->addItem(tr("Anonymous"), RSID_FILTER_PSEUDONYMS);
ui->filterComboBox->setCurrentIndex(0); ui->filterComboBox->setCurrentIndex(0);
/* Add filter actions */ /* Add filter actions */
@ -310,62 +312,58 @@ void IdDialog::requestIdList()
bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept) bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept)
{ {
bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) || (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); bool isLinkedToOwnNode = (data.mPgpKnown && (data.mPgpId == ownPgpId)) ;
bool isOwnId = (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
uint32_t item_flags = 0 ;
/* do filtering */ /* do filtering */
bool ok = false; bool ok = false;
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
{ {
if (isOwnId && (accept & RSID_FILTER_YOURSELF)) if (isLinkedToOwnNode && (accept & RSID_FILTER_YOURSELF))
{ {
ok = true; ok = true;
} item_flags |= RSID_FILTER_YOURSELF ;
else }
{
if (data.mPgpKnown)
{
if (accept & RSID_FILTER_FRIENDS)
{
ok = true;
}
}
else
{
if (accept & RSID_FILTER_OTHERS)
{
ok = true;
}
}
}
}
else
{
if (accept & RSID_FILTER_PSEUDONYMS)
{
ok = true;
}
if (isOwnId && (accept & RSID_FILTER_YOURSELF)) if (data.mPgpKnown && (accept & RSID_FILTER_FRIENDS))
{ {
ok = true; ok = true;
} item_flags |= RSID_FILTER_FRIENDS ;
} }
if (accept & RSID_FILTER_OTHERS)
{
ok = true;
item_flags |= RSID_FILTER_OTHERS ;
}
}
else if (accept & RSID_FILTER_PSEUDONYMS)
{
ok = true;
item_flags |= RSID_FILTER_PSEUDONYMS ;
}
if (isOwnId && (accept & RSID_FILTER_OWNED_BY_YOU))
{
ok = true;
item_flags |= RSID_FILTER_OWNED_BY_YOU ;
}
if (!ok) if (!ok)
{
return false; return false;
}
if (!item) if (!item)
{ item = new QTreeWidgetItem();
item = new QTreeWidgetItem();
}
item->setText(RSID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str())); item->setText(RSID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str()));
item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId.toStdString())); item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId.toStdString()));
item->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ;
if(isOwnId) if(isOwnId)
{ {
QFont font = item->font(RSID_COL_NICKNAME) ; QFont font = item->font(RSID_COL_NICKNAME) ;
font.setBold(true) ; font.setBold(true) ;
item->setFont(RSID_COL_NICKNAME,font) ; item->setFont(RSID_COL_NICKNAME,font) ;
item->setFont(RSID_COL_IDTYPE,font) ; item->setFont(RSID_COL_IDTYPE,font) ;
@ -593,27 +591,28 @@ void IdDialog::insertIdDetails(uint32_t token)
ui->PgpName_LB->show() ; ui->PgpName_LB->show() ;
} }
bool isOwnId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) || (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); bool isLinkedToOwnPgpId = (data.mPgpKnown && (data.mPgpId == ownPgpId)) ;
bool isOwnId = (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
if(isOwnId) if(isOwnId)
if (data.mPgpKnown) if (isLinkedToOwnPgpId)
ui->lineEdit_Type->setText(tr("Identity owned by you, linked to your Retroshare node")) ; ui->lineEdit_Type->setText(tr("Identity owned by you, linked to your Retroshare node")) ;
else else
ui->lineEdit_Type->setText(tr("Anonymous identity, owned by you")) ; ui->lineEdit_Type->setText(tr("Anonymous identity, owned by you")) ;
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
{ {
if (data.mPgpKnown) if (data.mPgpKnown)
if (rsPeers->isGPGAccepted(data.mPgpId)) if (rsPeers->isGPGAccepted(data.mPgpId))
ui->lineEdit_Type->setText(tr("Owned by a friend Retroshare node")) ; ui->lineEdit_Type->setText(tr("Linked to a friend Retroshare node")) ;
else else
ui->lineEdit_Type->setText(tr("Owned by 2-hops Retroshare node")) ; ui->lineEdit_Type->setText(tr("Linked to a known Retroshare node")) ;
else else
ui->lineEdit_Type->setText(tr("Owned by unknown Retroshare node")) ; ui->lineEdit_Type->setText(tr("Linked to unknown Retroshare node")) ;
} }
else else
ui->lineEdit_Type->setText(tr("Anonymous identity")) ; ui->lineEdit_Type->setText(tr("Anonymous identity")) ;
// if (isOwnId) // if (isOwnId)
// { // {
// ui->radioButton_IdYourself->setChecked(true); // ui->radioButton_IdYourself->setChecked(true);
// } // }
@ -941,38 +940,44 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
QMenu contextMnu( this ); QMenu contextMnu( this );
std::list<RsGxsId> own_identities ; std::list<RsGxsId> own_identities ;
rsIdentity->getOwnIds(own_identities) ; rsIdentity->getOwnIds(own_identities) ;
if(own_identities.size() <= 1) QTreeWidgetItem *item = ui->treeWidget_IdList->currentItem();
{ uint32_t item_flags = item->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
QAction *action = contextMnu.addAction(QIcon(":/images/chat_24.png"), tr("Chat with this person"), this, SLOT(chatIdentity()));
if(!(item_flags & RSID_FILTER_OWNED_BY_YOU))
{
if(own_identities.size() <= 1)
{
QAction *action = contextMnu.addAction(QIcon(":/images/chat_24.png"), tr("Chat with this person"), this, SLOT(chatIdentity()));
if(own_identities.empty()) if(own_identities.empty())
action->setEnabled(false) ; action->setEnabled(false) ;
else else
action->setData(QString::fromStdString((own_identities.front()).toStdString())) ; action->setData(QString::fromStdString((own_identities.front()).toStdString())) ;
} }
else else
{ {
QMenu *mnu = contextMnu.addMenu(QIcon(":/images/chat_24.png"),tr("Chat with this person as...")) ; QMenu *mnu = contextMnu.addMenu(QIcon(":/images/chat_24.png"),tr("Chat with this person as...")) ;
for(std::list<RsGxsId>::const_iterator it=own_identities.begin();it!=own_identities.end();++it) for(std::list<RsGxsId>::const_iterator it=own_identities.begin();it!=own_identities.end();++it)
{ {
RsIdentityDetails idd ; RsIdentityDetails idd ;
rsIdentity->getIdDetails(*it,idd) ; rsIdentity->getIdDetails(*it,idd) ;
QPixmap pixmap ; QPixmap pixmap ;
if(idd.mAvatar.mSize == 0 || !pixmap.loadFromData(idd.mAvatar.mData, idd.mAvatar.mSize, "PNG")) if(idd.mAvatar.mSize == 0 || !pixmap.loadFromData(idd.mAvatar.mData, idd.mAvatar.mSize, "PNG"))
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ; pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ;
QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity())); QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity()));
action->setData(QString::fromStdString((*it).toStdString())) ; action->setData(QString::fromStdString((*it).toStdString())) ;
} }
} }
contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message to this person"), this, SLOT(sendMsg())); contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message to this person"), this, SLOT(sendMsg()));
}
contextMnu.addSeparator(); contextMnu.addSeparator();
@ -1018,7 +1023,7 @@ void IdDialog::sendMsg()
return; return;
} }
std::string keyId = item->text(RSID_COL_KEYID).toStdString(); std::string keyId = item->text(RSID_COL_KEYID).toStdString();
nMsgDialog->addRecipient(MessageComposer::TO, RsGxsId(keyId)); nMsgDialog->addRecipient(MessageComposer::TO, RsGxsId(keyId));
nMsgDialog->show(); nMsgDialog->show();