mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 06:02:41 -04:00
Merge pull request #1440 from csoler/v0.6-Identity
added button (enabled by default) to automatically add IDs signed by …
This commit is contained in:
commit
bcea548d83
6 changed files with 60 additions and 10 deletions
|
@ -378,6 +378,8 @@ struct RsIdentity : RsGxsIfaceHelper
|
||||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
||||||
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
|
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
|
||||||
virtual uint32_t nbRegularContacts() =0;
|
virtual uint32_t nbRegularContacts() =0;
|
||||||
|
virtual void setAutoAddFriendIdsAsContact(bool b) =0;
|
||||||
|
virtual bool autoAddFriendIdsAsContact() =0;
|
||||||
|
|
||||||
virtual bool serialiseIdentityToMemory( const RsGxsId& id,
|
virtual bool serialiseIdentityToMemory( const RsGxsId& id,
|
||||||
std::string& radix_string ) = 0;
|
std::string& radix_string ) = 0;
|
||||||
|
|
|
@ -166,6 +166,7 @@ p3IdService::p3IdService(
|
||||||
mLastKeyCleaningTime = time(NULL) - int(MAX_DELAY_BEFORE_CLEANING * 0.9) ;
|
mLastKeyCleaningTime = time(NULL) - int(MAX_DELAY_BEFORE_CLEANING * 0.9) ;
|
||||||
mLastConfigUpdate = 0 ;
|
mLastConfigUpdate = 0 ;
|
||||||
mOwnIdsLoaded = false ;
|
mOwnIdsLoaded = false ;
|
||||||
|
mAutoAddFriendsIdentitiesAsContacts = true; // default
|
||||||
mMaxKeepKeysBanned = MAX_KEEP_KEYS_BANNED_DEFAULT;
|
mMaxKeepKeysBanned = MAX_KEEP_KEYS_BANNED_DEFAULT;
|
||||||
|
|
||||||
// Kick off Cache Testing, + Others.
|
// Kick off Cache Testing, + Others.
|
||||||
|
@ -238,6 +239,7 @@ bool p3IdService::isARegularContact(const RsGxsId& id)
|
||||||
|
|
||||||
bool p3IdService::setAsRegularContact(const RsGxsId& id,bool b)
|
bool p3IdService::setAsRegularContact(const RsGxsId& id,bool b)
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(mIdMtx);
|
||||||
std::set<RsGxsId>::iterator it = mContacts.find(id) ;
|
std::set<RsGxsId>::iterator it = mContacts.find(id) ;
|
||||||
|
|
||||||
if(b && (it == mContacts.end()))
|
if(b && (it == mContacts.end()))
|
||||||
|
@ -343,6 +345,8 @@ bool p3IdService::loadList(std::list<RsItem*>& items)
|
||||||
std::cerr << "Setting mMaxKeepKeysBanned threshold to " << val << std::endl ;
|
std::cerr << "Setting mMaxKeepKeysBanned threshold to " << val << std::endl ;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if(kit->key == "AUTO_SET_FRIEND_IDENTITIES_AS_CONTACT")
|
||||||
|
mAutoAddFriendsIdentitiesAsContacts = (kit->value == "YES") ;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete *it ;
|
delete *it ;
|
||||||
|
@ -368,6 +372,20 @@ uint32_t p3IdService::deleteBannedNodesThreshold()
|
||||||
return mMaxKeepKeysBanned/86400;
|
return mMaxKeepKeysBanned/86400;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void p3IdService::setAutoAddFriendIdsAsContact(bool b)
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mIdMtx) ;
|
||||||
|
if(b != mAutoAddFriendsIdentitiesAsContacts)
|
||||||
|
{
|
||||||
|
IndicateConfigChanged();
|
||||||
|
mAutoAddFriendsIdentitiesAsContacts=b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool p3IdService::autoAddFriendIdsAsContact()
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mIdMtx) ;
|
||||||
|
return mAutoAddFriendsIdentitiesAsContacts;
|
||||||
|
}
|
||||||
|
|
||||||
bool p3IdService::saveList(bool& cleanup,std::list<RsItem*>& items)
|
bool p3IdService::saveList(bool& cleanup,std::list<RsItem*>& items)
|
||||||
{
|
{
|
||||||
|
@ -393,6 +411,10 @@ bool p3IdService::saveList(bool& cleanup,std::list<RsItem*>& items)
|
||||||
rs_sprintf(kv.value, "%d", mMaxKeepKeysBanned);
|
rs_sprintf(kv.value, "%d", mMaxKeepKeysBanned);
|
||||||
vitem->tlvkvs.pairs.push_back(kv) ;
|
vitem->tlvkvs.pairs.push_back(kv) ;
|
||||||
|
|
||||||
|
kv.key = "AUTO_SET_FRIEND_IDENTITIES_AS_CONTACT" ;
|
||||||
|
kv.value = mAutoAddFriendsIdentitiesAsContacts?"YES":"NO";
|
||||||
|
vitem->tlvkvs.pairs.push_back(kv) ;
|
||||||
|
|
||||||
items.push_back(vitem) ;
|
items.push_back(vitem) ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
|
@ -650,13 +672,23 @@ bool p3IdService::getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
|
||||||
|
|
||||||
if (mKeyCache.fetch(id, data))
|
if (mKeyCache.fetch(id, data))
|
||||||
{
|
{
|
||||||
|
bool is_a_contact = (mContacts.find(id) != mContacts.end());
|
||||||
|
|
||||||
|
details = data.details;
|
||||||
|
|
||||||
|
if(mAutoAddFriendsIdentitiesAsContacts && (!is_a_contact) && (details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN))
|
||||||
|
{
|
||||||
|
mContacts.insert(id) ;
|
||||||
|
slowIndicateConfigChanged() ;
|
||||||
|
|
||||||
|
is_a_contact = true;
|
||||||
|
}
|
||||||
|
|
||||||
// This step is needed, because p3GxsReputation does not know all identities, and might not have any data for
|
// This step is needed, because p3GxsReputation does not know all identities, and might not have any data for
|
||||||
// the ones in the contact list. So we change them on demand.
|
// the ones in the contact list. So we change them on demand.
|
||||||
|
|
||||||
if(mContacts.find(id) != mContacts.end() && rsReputations->nodeAutoPositiveOpinionForContacts())
|
if(is_a_contact && rsReputations->nodeAutoPositiveOpinionForContacts())
|
||||||
rsReputations->setOwnOpinion(id,RsReputations::OPINION_POSITIVE) ;
|
rsReputations->setOwnOpinion(id,RsReputations::OPINION_POSITIVE) ;
|
||||||
|
|
||||||
details = data.details;
|
|
||||||
|
|
||||||
std::map<RsGxsId,keyTSInfo>::const_iterator it = mKeysTS.find(id) ;
|
std::map<RsGxsId,keyTSInfo>::const_iterator it = mKeysTS.find(id) ;
|
||||||
|
|
||||||
|
|
|
@ -279,8 +279,11 @@ public:
|
||||||
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
||||||
uint16_t tag_class, uint16_t tag_type, std::string &tag);
|
uint16_t tag_class, uint16_t tag_type, std::string &tag);
|
||||||
|
|
||||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) ;
|
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) override;
|
||||||
virtual bool isARegularContact(const RsGxsId& id) ;
|
virtual bool isARegularContact(const RsGxsId& id) override;
|
||||||
|
virtual void setAutoAddFriendIdsAsContact(bool b) override;
|
||||||
|
virtual bool autoAddFriendIdsAsContact() override;
|
||||||
|
|
||||||
virtual uint32_t nbRegularContacts() ;
|
virtual uint32_t nbRegularContacts() ;
|
||||||
virtual rstime_t getLastUsageTS(const RsGxsId &id) ;
|
virtual rstime_t getLastUsageTS(const RsGxsId &id) ;
|
||||||
|
|
||||||
|
@ -597,6 +600,7 @@ private:
|
||||||
rstime_t mLastConfigUpdate ;
|
rstime_t mLastConfigUpdate ;
|
||||||
|
|
||||||
bool mOwnIdsLoaded ;
|
bool mOwnIdsLoaded ;
|
||||||
|
bool mAutoAddFriendsIdentitiesAsContacts;
|
||||||
uint32_t mMaxKeepKeysBanned ;
|
uint32_t mMaxKeepKeysBanned ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ PeoplePage::PeoplePage(QWidget * parent, Qt::WindowFlags flags)
|
||||||
connect(ui.thresholdForNegative_SB,SIGNAL(valueChanged(int)),this,SLOT(updateThresholdForRemotelyNegativeReputation()));
|
connect(ui.thresholdForNegative_SB,SIGNAL(valueChanged(int)),this,SLOT(updateThresholdForRemotelyNegativeReputation()));
|
||||||
connect(ui.preventReloadingBannedIdentitiesFor_SB,SIGNAL(valueChanged(int)),this,SLOT(updateRememberDeletedNodes()));
|
connect(ui.preventReloadingBannedIdentitiesFor_SB,SIGNAL(valueChanged(int)),this,SLOT(updateRememberDeletedNodes()));
|
||||||
connect(ui.deleteBannedIdentitiesAfter_SB,SIGNAL(valueChanged(int)),this,SLOT(updateDeleteBannedNodesThreshold()));
|
connect(ui.deleteBannedIdentitiesAfter_SB,SIGNAL(valueChanged(int)),this,SLOT(updateDeleteBannedNodesThreshold()));
|
||||||
|
connect(ui.autoAddFriendIdsAsContact_CB,SIGNAL(toggled(bool)),this,SLOT(updateAutoAddFriendIdsAsContact()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeoplePage::updateAutoPositiveOpinion() { rsReputations->setNodeAutoPositiveOpinionForContacts(ui.autoPositiveOpinion_CB->isChecked()) ; }
|
void PeoplePage::updateAutoPositiveOpinion() { rsReputations->setNodeAutoPositiveOpinionForContacts(ui.autoPositiveOpinion_CB->isChecked()) ; }
|
||||||
|
@ -45,6 +46,7 @@ void PeoplePage::updateThresholdForRemotelyNegativeReputation() { rsReputations
|
||||||
|
|
||||||
void PeoplePage::updateRememberDeletedNodes() { rsReputations->setRememberDeletedNodesThreshold(ui.preventReloadingBannedIdentitiesFor_SB->value()); }
|
void PeoplePage::updateRememberDeletedNodes() { rsReputations->setRememberDeletedNodesThreshold(ui.preventReloadingBannedIdentitiesFor_SB->value()); }
|
||||||
void PeoplePage::updateDeleteBannedNodesThreshold() { rsIdentity->setDeleteBannedNodesThreshold(ui.deleteBannedIdentitiesAfter_SB->value());}
|
void PeoplePage::updateDeleteBannedNodesThreshold() { rsIdentity->setDeleteBannedNodesThreshold(ui.deleteBannedIdentitiesAfter_SB->value());}
|
||||||
|
void PeoplePage::updateAutoAddFriendIdsAsContact() { rsIdentity->setAutoAddFriendIdsAsContact(ui.autoAddFriendIdsAsContact_CB->isChecked()) ; }
|
||||||
|
|
||||||
PeoplePage::~PeoplePage()
|
PeoplePage::~PeoplePage()
|
||||||
{
|
{
|
||||||
|
@ -56,10 +58,12 @@ void PeoplePage::load()
|
||||||
bool auto_positive_contacts = rsReputations->nodeAutoPositiveOpinionForContacts() ;
|
bool auto_positive_contacts = rsReputations->nodeAutoPositiveOpinionForContacts() ;
|
||||||
uint32_t threshold_for_positive = rsReputations->thresholdForRemotelyPositiveReputation();
|
uint32_t threshold_for_positive = rsReputations->thresholdForRemotelyPositiveReputation();
|
||||||
uint32_t threshold_for_negative = rsReputations->thresholdForRemotelyNegativeReputation();
|
uint32_t threshold_for_negative = rsReputations->thresholdForRemotelyNegativeReputation();
|
||||||
|
bool auto_add_friend_ids_as_contact = rsIdentity->autoAddFriendIdsAsContact();
|
||||||
|
|
||||||
whileBlocking(ui.autoPositiveOpinion_CB)->setChecked(auto_positive_contacts);
|
whileBlocking(ui.autoAddFriendIdsAsContact_CB )->setChecked(auto_add_friend_ids_as_contact);
|
||||||
whileBlocking(ui.thresholdForPositive_SB)->setValue(threshold_for_positive);
|
whileBlocking(ui.autoPositiveOpinion_CB )->setChecked(auto_positive_contacts);
|
||||||
whileBlocking(ui.thresholdForNegative_SB)->setValue(threshold_for_negative);
|
whileBlocking(ui.thresholdForPositive_SB )->setValue(threshold_for_positive);
|
||||||
whileBlocking(ui.deleteBannedIdentitiesAfter_SB)->setValue(rsIdentity->deleteBannedNodesThreshold());
|
whileBlocking(ui.thresholdForNegative_SB )->setValue(threshold_for_negative);
|
||||||
|
whileBlocking(ui.deleteBannedIdentitiesAfter_SB )->setValue(rsIdentity->deleteBannedNodesThreshold());
|
||||||
whileBlocking(ui.preventReloadingBannedIdentitiesFor_SB)->setValue(rsReputations->rememberDeletedNodesThreshold());
|
whileBlocking(ui.preventReloadingBannedIdentitiesFor_SB)->setValue(rsReputations->rememberDeletedNodesThreshold());
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ protected slots:
|
||||||
|
|
||||||
void updateRememberDeletedNodes();
|
void updateRememberDeletedNodes();
|
||||||
void updateDeleteBannedNodesThreshold() ;
|
void updateDeleteBannedNodesThreshold() ;
|
||||||
|
void updateAutoAddFriendIdsAsContact() ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PeoplePage ui;
|
Ui::PeoplePage ui;
|
||||||
|
|
|
@ -30,6 +30,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="autoAddFriendIdsAsContact_CB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Automatically add identities owned by friend nodes to my contacts</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue