mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-02 11:26:31 -05: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
@ -378,6 +378,8 @@ struct RsIdentity : RsGxsIfaceHelper
|
||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
||||
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
|
||||
virtual uint32_t nbRegularContacts() =0;
|
||||
virtual void setAutoAddFriendIdsAsContact(bool b) =0;
|
||||
virtual bool autoAddFriendIdsAsContact() =0;
|
||||
|
||||
virtual bool serialiseIdentityToMemory( const RsGxsId& id,
|
||||
std::string& radix_string ) = 0;
|
||||
|
@ -166,6 +166,7 @@ p3IdService::p3IdService(
|
||||
mLastKeyCleaningTime = time(NULL) - int(MAX_DELAY_BEFORE_CLEANING * 0.9) ;
|
||||
mLastConfigUpdate = 0 ;
|
||||
mOwnIdsLoaded = false ;
|
||||
mAutoAddFriendsIdentitiesAsContacts = true; // default
|
||||
mMaxKeepKeysBanned = MAX_KEEP_KEYS_BANNED_DEFAULT;
|
||||
|
||||
// Kick off Cache Testing, + Others.
|
||||
@ -238,6 +239,7 @@ bool p3IdService::isARegularContact(const RsGxsId& id)
|
||||
|
||||
bool p3IdService::setAsRegularContact(const RsGxsId& id,bool b)
|
||||
{
|
||||
RsStackMutex stack(mIdMtx);
|
||||
std::set<RsGxsId>::iterator it = mContacts.find(id) ;
|
||||
|
||||
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 ;
|
||||
}
|
||||
};
|
||||
if(kit->key == "AUTO_SET_FRIEND_IDENTITIES_AS_CONTACT")
|
||||
mAutoAddFriendsIdentitiesAsContacts = (kit->value == "YES") ;
|
||||
}
|
||||
|
||||
delete *it ;
|
||||
@ -368,6 +372,20 @@ uint32_t p3IdService::deleteBannedNodesThreshold()
|
||||
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)
|
||||
{
|
||||
@ -393,6 +411,10 @@ bool p3IdService::saveList(bool& cleanup,std::list<RsItem*>& items)
|
||||
rs_sprintf(kv.value, "%d", mMaxKeepKeysBanned);
|
||||
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) ;
|
||||
|
||||
return true ;
|
||||
@ -650,13 +672,23 @@ bool p3IdService::getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
|
||||
|
||||
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
|
||||
// the ones in the contact list. So we change them on demand.
|
||||
|
||||
if(mContacts.find(id) != mContacts.end() && rsReputations->nodeAutoPositiveOpinionForContacts())
|
||||
rsReputations->setOwnOpinion(id,RsReputations::OPINION_POSITIVE) ;
|
||||
|
||||
details = data.details;
|
||||
if(is_a_contact && rsReputations->nodeAutoPositiveOpinionForContacts())
|
||||
rsReputations->setOwnOpinion(id,RsReputations::OPINION_POSITIVE) ;
|
||||
|
||||
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,
|
||||
uint16_t tag_class, uint16_t tag_type, std::string &tag);
|
||||
|
||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) ;
|
||||
virtual bool isARegularContact(const RsGxsId& id) ;
|
||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) override;
|
||||
virtual bool isARegularContact(const RsGxsId& id) override;
|
||||
virtual void setAutoAddFriendIdsAsContact(bool b) override;
|
||||
virtual bool autoAddFriendIdsAsContact() override;
|
||||
|
||||
virtual uint32_t nbRegularContacts() ;
|
||||
virtual rstime_t getLastUsageTS(const RsGxsId &id) ;
|
||||
|
||||
@ -597,6 +600,7 @@ private:
|
||||
rstime_t mLastConfigUpdate ;
|
||||
|
||||
bool mOwnIdsLoaded ;
|
||||
bool mAutoAddFriendsIdentitiesAsContacts;
|
||||
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.preventReloadingBannedIdentitiesFor_SB,SIGNAL(valueChanged(int)),this,SLOT(updateRememberDeletedNodes()));
|
||||
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()) ; }
|
||||
@ -45,6 +46,7 @@ void PeoplePage::updateThresholdForRemotelyNegativeReputation() { rsReputations
|
||||
|
||||
void PeoplePage::updateRememberDeletedNodes() { rsReputations->setRememberDeletedNodesThreshold(ui.preventReloadingBannedIdentitiesFor_SB->value()); }
|
||||
void PeoplePage::updateDeleteBannedNodesThreshold() { rsIdentity->setDeleteBannedNodesThreshold(ui.deleteBannedIdentitiesAfter_SB->value());}
|
||||
void PeoplePage::updateAutoAddFriendIdsAsContact() { rsIdentity->setAutoAddFriendIdsAsContact(ui.autoAddFriendIdsAsContact_CB->isChecked()) ; }
|
||||
|
||||
PeoplePage::~PeoplePage()
|
||||
{
|
||||
@ -56,10 +58,12 @@ void PeoplePage::load()
|
||||
bool auto_positive_contacts = rsReputations->nodeAutoPositiveOpinionForContacts() ;
|
||||
uint32_t threshold_for_positive = rsReputations->thresholdForRemotelyPositiveReputation();
|
||||
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.thresholdForPositive_SB)->setValue(threshold_for_positive);
|
||||
whileBlocking(ui.thresholdForNegative_SB)->setValue(threshold_for_negative);
|
||||
whileBlocking(ui.deleteBannedIdentitiesAfter_SB)->setValue(rsIdentity->deleteBannedNodesThreshold());
|
||||
whileBlocking(ui.autoAddFriendIdsAsContact_CB )->setChecked(auto_add_friend_ids_as_contact);
|
||||
whileBlocking(ui.autoPositiveOpinion_CB )->setChecked(auto_positive_contacts);
|
||||
whileBlocking(ui.thresholdForPositive_SB )->setValue(threshold_for_positive);
|
||||
whileBlocking(ui.thresholdForNegative_SB )->setValue(threshold_for_negative);
|
||||
whileBlocking(ui.deleteBannedIdentitiesAfter_SB )->setValue(rsIdentity->deleteBannedNodesThreshold());
|
||||
whileBlocking(ui.preventReloadingBannedIdentitiesFor_SB)->setValue(rsReputations->rememberDeletedNodesThreshold());
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ protected slots:
|
||||
|
||||
void updateRememberDeletedNodes();
|
||||
void updateDeleteBannedNodesThreshold() ;
|
||||
void updateAutoAddFriendIdsAsContact() ;
|
||||
|
||||
private:
|
||||
Ui::PeoplePage ui;
|
||||
|
@ -30,6 +30,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
|
Loading…
Reference in New Issue
Block a user