mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added setFlags method in Id combo box. Removed possibility to send anonymous distant messages (too risky). Improved the logic in message composer GUI. Fixed bug when key not available in message encryption/signing routine.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7705 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2f547e4014
commit
30d9671ca6
@ -1728,7 +1728,7 @@ bool p3MsgService::createDistantMessage(const RsGxsId& destination_gxs_id,const
|
||||
|
||||
// 2 - now sign the data, if necessary, and put the signature up front
|
||||
|
||||
if(item->msgFlags & RS_MSG_FLAGS_SIGNED)
|
||||
if(item->msgFlags & RS_MSG_FLAGS_SIGNED && !source_gxs_id.isNull())
|
||||
{
|
||||
#ifdef DEBUG_DISTANT_MSG
|
||||
std::cerr << " Signing the message with key id " << source_gxs_id << std::endl;
|
||||
@ -1739,7 +1739,7 @@ bool p3MsgService::createDistantMessage(const RsGxsId& destination_gxs_id,const
|
||||
#ifdef DEBUG_DISTANT_MSG
|
||||
std::cerr << " Getting key material..." << std::endl;
|
||||
#endif
|
||||
if(!mIdService->getPrivateKey(source_gxs_id,signature_key))
|
||||
if(mIdService->getPrivateKey(source_gxs_id,signature_key) < 0)
|
||||
throw std::runtime_error("Cannot get signature key for id " + source_gxs_id.toStdString()) ;
|
||||
|
||||
#ifdef DEBUG_DISTANT_MSG
|
||||
|
@ -49,6 +49,7 @@ RSFeedWidget::RSFeedWidget(QWidget *parent)
|
||||
mCountChangedDisabled = 0;
|
||||
|
||||
ui->treeWidget->installEventFilter(this);
|
||||
ui->treeWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
}
|
||||
|
||||
RSFeedWidget::~RSFeedWidget()
|
||||
|
@ -71,6 +71,11 @@ GxsIdChooser::GxsIdChooser(QWidget *parent)
|
||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||
}
|
||||
|
||||
void GxsIdChooser::setFlags(uint32_t flags)
|
||||
{
|
||||
mFlags = flags ;
|
||||
updateDisplay(true);
|
||||
}
|
||||
GxsIdChooser::~GxsIdChooser()
|
||||
{
|
||||
if (mIdQueue) {
|
||||
@ -124,9 +129,9 @@ bool GxsIdChooser::makeIdDesc(const RsGxsId &gxsId, QString &desc)
|
||||
desc = QString("%1 ... [").arg(tr("Not found"));
|
||||
desc += QString::fromStdString(gxsId.toStdString().substr(0,5));
|
||||
desc += "...]";
|
||||
}//if (mTimerCount > MAX_TRY)
|
||||
}
|
||||
return false;
|
||||
}//if (!GxsIdDetails::MakeIdDesc(gxsId, false, desc, icons))
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -140,8 +145,8 @@ void GxsIdChooser::addPrivateId(const RsGxsId &gxsId, bool replace)
|
||||
if (replace && mTimerCount <= MAX_TRY) {
|
||||
/* Retry */
|
||||
return;
|
||||
}//if (replace && mTimerCount <= MAX_TRY)
|
||||
}//if (!found)
|
||||
}
|
||||
}
|
||||
|
||||
QString id = QString::fromStdString(gxsId.toStdString());
|
||||
|
||||
@ -154,9 +159,9 @@ void GxsIdChooser::addPrivateId(const RsGxsId &gxsId, bool replace)
|
||||
setItemData(index, found ? TYPE_FOUND_ID : TYPE_UNKNOWN_ID, ROLE_TYPE);
|
||||
model()->sort(0);
|
||||
return;
|
||||
}//if (index >= 0)
|
||||
}
|
||||
//If not found create a new item.
|
||||
}//if (replace)
|
||||
}
|
||||
|
||||
/* Add new item */
|
||||
addItem(str, id);
|
||||
@ -172,7 +177,7 @@ void GxsIdChooser::loadPrivateIds(uint32_t token)
|
||||
mTimerCount = 0;
|
||||
if (mTimer) {
|
||||
delete(mTimer);
|
||||
}//if (mTimer)
|
||||
}
|
||||
|
||||
std::list<RsGxsId> ids;
|
||||
//rsIdentity->getOwnIds(ids);
|
||||
@ -181,19 +186,19 @@ void GxsIdChooser::loadPrivateIds(uint32_t token)
|
||||
std::cerr << "GxsIdChooser::loadPrivateIds() Error getting GroupData";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}//if (!rsIdentity->getGroupData(token, datavector))
|
||||
}
|
||||
|
||||
for (std::vector<RsGxsIdGroup>::iterator vit = datavector.begin();
|
||||
vit != datavector.end(); ++vit) {
|
||||
RsGxsIdGroup data = (*vit);
|
||||
if (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) {
|
||||
ids.push_back((RsGxsId) data.mMeta.mGroupId);
|
||||
}//if (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN)
|
||||
}
|
||||
|
||||
if (mDefaultIdName == data.mMeta.mGroupName) {
|
||||
mDefaultId=(RsGxsId) data.mMeta.mGroupId;
|
||||
}//if (mDefaultIdName == data.mMeta.mGroupName)
|
||||
}//for (std::vector<RsGxsIdGroup>::iterator vit
|
||||
}
|
||||
}
|
||||
|
||||
//rsIdentity->getDefaultId(defId);
|
||||
// Prefer to use an application specific default???
|
||||
@ -207,8 +212,8 @@ void GxsIdChooser::loadPrivateIds(uint32_t token)
|
||||
addItem(str, id);
|
||||
setItemData(count() - 1, QString("0_%2").arg(str), ROLE_SORT);
|
||||
setItemData(count() - 1, TYPE_NO_ID, ROLE_TYPE);
|
||||
}//if (!(mFlags & IDCHOOSER_ID_REQUIRED)
|
||||
}//if (mFirstLoad)
|
||||
}
|
||||
}
|
||||
|
||||
if (!mFirstLoad) {
|
||||
for (int idx=0; idx < count(); ++idx) {
|
||||
@ -225,23 +230,23 @@ void GxsIdChooser::loadPrivateIds(uint32_t token)
|
||||
if (lit == ids.end()) {
|
||||
removeItem(idx);
|
||||
idx--;
|
||||
}//if (lit == ids.end())
|
||||
}//default:
|
||||
}//switch (type.toInt())
|
||||
}//for (int idx=0; idx < count(); ++idx)
|
||||
}//if (!mFirstLoad)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ids.empty()) {
|
||||
std::cerr << "GxsIdChooser::loadPrivateIds() ERROR no ids";
|
||||
std::cerr << std::endl;
|
||||
mFirstLoad = false;
|
||||
return;
|
||||
}//if (ids.empty())
|
||||
}
|
||||
|
||||
for(std::list<RsGxsId>::iterator it = ids.begin(); it != ids.end(); ++it) {
|
||||
/* add to Chooser */
|
||||
addPrivateId(*it, !mFirstLoad);
|
||||
}//for(std::list<RsGxsId>::iterator it
|
||||
}
|
||||
|
||||
if (!mPendingId.empty()) {
|
||||
/* Create and start timer to load pending id's */
|
||||
@ -251,7 +256,7 @@ void GxsIdChooser::loadPrivateIds(uint32_t token)
|
||||
mTimer->setInterval(500);
|
||||
connect(mTimer, SIGNAL(timeout()), this, SLOT(timer()));
|
||||
mTimer->start();
|
||||
}//if (!mPendingId.empty())
|
||||
}
|
||||
|
||||
setDefaultItem();
|
||||
|
||||
@ -267,11 +272,11 @@ void GxsIdChooser::setDefaultItem()
|
||||
} else {
|
||||
QString id = QString::fromStdString(mDefaultId.toStdString());
|
||||
def = findData(id);
|
||||
}//if ((mFlags & IDCHOOSER_ANON_DEFAULT)
|
||||
}
|
||||
|
||||
if (def >= 0) {
|
||||
setCurrentIndex(def);
|
||||
}//if (def >= 0)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -284,7 +289,7 @@ bool GxsIdChooser::setChosenId(RsGxsId &gxsId)
|
||||
if (index >= 0) {
|
||||
setCurrentIndex(index);
|
||||
return true;
|
||||
}//if (index >= 0)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -292,7 +297,7 @@ GxsIdChooser::ChosenId_Ret GxsIdChooser::getChosenId(RsGxsId &gxsId)
|
||||
{
|
||||
if (count() < 1) {
|
||||
return None;
|
||||
}//if (count() < 1)
|
||||
}
|
||||
|
||||
int idx = currentIndex();
|
||||
|
||||
@ -306,7 +311,7 @@ GxsIdChooser::ChosenId_Ret GxsIdChooser::getChosenId(RsGxsId &gxsId)
|
||||
return KnowId;
|
||||
case TYPE_UNKNOWN_ID:
|
||||
return UnKnowId;
|
||||
}//switch (type.toInt())
|
||||
}
|
||||
|
||||
return None;
|
||||
}
|
||||
@ -320,7 +325,7 @@ void GxsIdChooser::myCurrentIndexChanged(int index)
|
||||
setToolTip(text);
|
||||
} else {
|
||||
setToolTip("");
|
||||
}//if (width()<fm.boundingRect(text).width())
|
||||
}
|
||||
}
|
||||
|
||||
void GxsIdChooser::timer()
|
||||
@ -336,7 +341,7 @@ void GxsIdChooser::timer()
|
||||
pendingId.pop_front();
|
||||
|
||||
addPrivateId(id, true);
|
||||
}//while (!pendingId.empty())
|
||||
}
|
||||
|
||||
setDefaultItem();
|
||||
|
||||
@ -354,8 +359,8 @@ void GxsIdChooser::timer()
|
||||
mTimer = NULL;
|
||||
mTimerCount = 0;
|
||||
mPendingId.clear();
|
||||
}//if (mTimerCount <= MAX_TRY)
|
||||
}//if (mPendingId.empty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GxsIdChooser::updateDisplay(bool complete)
|
||||
@ -393,7 +398,7 @@ void GxsIdChooser::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
std::cerr << "IdDialog::loadRequest() ERROR";
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}//switch(req.mUserType)
|
||||
}
|
||||
}
|
||||
|
||||
void GxsIdChooser::insertIdList(uint32_t token)
|
||||
|
@ -50,6 +50,8 @@ public:
|
||||
GxsIdChooser(QWidget *parent = NULL);
|
||||
virtual ~GxsIdChooser();
|
||||
|
||||
void setFlags(uint32_t flags) ;
|
||||
|
||||
void setUpdateWhenInvisible(bool update);
|
||||
const std::list<RsGxsGroupId> &getGrpIds();
|
||||
const std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &getMsgIds();
|
||||
|
@ -136,6 +136,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
|
||||
|
||||
ui.hashBox->hide();
|
||||
ui.signMessage_CB->setChecked(true) ;
|
||||
ui.signMessage_CB->setEnabled(false) ;
|
||||
|
||||
// connect up the buttons.
|
||||
connect( ui.actionSend, SIGNAL( triggered (bool)), this, SLOT( sendMessage( ) ) );
|
||||
@ -235,28 +236,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
|
||||
|
||||
setupFormatActions();
|
||||
|
||||
// std::list<RsGxsId> own_ids ;
|
||||
// rsIdentity->getOwnIds(own_ids) ;
|
||||
//
|
||||
// ui.respond_to_CB->addItem(tr("[no identity]"), QVariant(QString::fromStdString(RsGxsId().toStdString()))) ;
|
||||
//
|
||||
// for(std::list<RsGxsId>::const_iterator it(own_ids.begin());it!=own_ids.end();++it)
|
||||
// {
|
||||
// RsIdentityDetails details ;
|
||||
// rsIdentity->getIdDetails(*it,details) ;
|
||||
//
|
||||
// std::cerr << "Adding identity: id=" << (*it) << ", name=" << details.mNickname << std::endl;
|
||||
//
|
||||
// if(details.mNickname.empty()) // I don't know why, but that happens
|
||||
// ui.respond_to_CB->addItem(QString::fromStdString((*it).toStdString()), QString::fromStdString((*it).toStdString())) ;
|
||||
// else
|
||||
// ui.respond_to_CB->addItem(QString::fromUtf8(details.mNickname.c_str()), QString::fromStdString((*it).toStdString())) ;
|
||||
// }
|
||||
|
||||
QObject::connect(ui.respond_to_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSigningButton(int))) ;
|
||||
|
||||
// if(!own_ids.empty())
|
||||
// ui.respond_to_CB->setCurrentIndex(1) ;
|
||||
ui.respond_to_CB->setFlags(IDCHOOSER_ID_REQUIRED) ;
|
||||
|
||||
/*ui.comboStyle->addItem("Standard");
|
||||
ui.comboStyle->addItem("Bullet List (Disc)");
|
||||
@ -266,8 +246,8 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
|
||||
ui.comboStyle->addItem("Ordered List (Alpha lower)");
|
||||
ui.comboStyle->addItem("Ordered List (Alpha upper)");*/
|
||||
//connect(ui.comboStyle, SIGNAL(activated(int)),this, SLOT(textStyle(int)));
|
||||
connect(ui.comboStyle, SIGNAL(activated(int)),this, SLOT(changeFormatType(int)));
|
||||
|
||||
connect(ui.comboStyle, SIGNAL(activated(int)),this, SLOT(changeFormatType(int)));
|
||||
connect(ui.comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &)));
|
||||
|
||||
ui.comboSize->setEditable(true);
|
||||
@ -353,13 +333,6 @@ MessageComposer::~MessageComposer()
|
||||
{
|
||||
delete(m_compareRole);
|
||||
}
|
||||
void MessageComposer::updateSigningButton(int n)
|
||||
{
|
||||
if(n == 0)
|
||||
ui.signMessage_CB->setEnabled(false) ;
|
||||
else
|
||||
ui.signMessage_CB->setEnabled(true) ;
|
||||
}
|
||||
|
||||
void MessageComposer::processSettings(bool bLoad)
|
||||
{
|
||||
@ -2356,6 +2329,12 @@ 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)
|
||||
{
|
||||
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 ;
|
||||
}
|
||||
for (std::list<RsGxsId>::const_iterator idIt = gxsIds.begin(); idIt != gxsIds.end(); ++idIt)
|
||||
addRecipient(type, *idIt);
|
||||
}
|
||||
|
@ -80,7 +80,6 @@ public slots:
|
||||
void addImage();
|
||||
|
||||
void changeFormatType(int styleIndex );
|
||||
void updateSigningButton(int) ;
|
||||
|
||||
protected:
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
Loading…
Reference in New Issue
Block a user