2018-11-04 15:17:22 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* unittests/libretroshare/gxs/nxs_test/nxsdummyservice.cpp *
|
|
|
|
* *
|
|
|
|
* Copyright (C) 2014, Crispy <retroshare.team@gmailcom> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
******************************************************************************/
|
2014-04-13 17:52:53 -04:00
|
|
|
|
|
|
|
#include "nxsdummyservices.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-05-27 17:14:05 -04:00
|
|
|
rs_nxs_test::RsNxsSimpleDummyCircles::RsNxsSimpleDummyCircles() {
|
2014-04-13 17:52:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool rs_nxs_test::RsNxsSimpleDummyCircles::isLoaded(
|
2017-01-21 10:31:22 -05:00
|
|
|
const RsGxsCircleId& /*circleId*/) {
|
2014-04-13 17:52:53 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rs_nxs_test::RsNxsSimpleDummyCircles::loadCircle(
|
2017-01-21 10:31:22 -05:00
|
|
|
const RsGxsCircleId& /*circleId*/) {
|
2014-04-13 17:52:53 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-21 10:31:22 -05:00
|
|
|
int rs_nxs_test::RsNxsSimpleDummyCircles::canSend(const RsGxsCircleId& /*circleId*/,
|
|
|
|
const RsPgpId& /*id*/, bool &/*should_encrypt*/) {
|
2014-04-13 17:52:53 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rs_nxs_test::RsNxsSimpleDummyCircles::canReceive(
|
2017-01-21 10:31:22 -05:00
|
|
|
const RsGxsCircleId& /*circleId*/, const RsPgpId& /*id*/) {
|
2014-04-13 17:52:53 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-21 10:31:22 -05:00
|
|
|
bool rs_nxs_test::RsNxsSimpleDummyCircles::isRecipient(const RsGxsCircleId &/*circleId*/, const RsGxsGroupId &/*destination_group*/, const RsGxsId& /*id*/)
|
2016-03-26 17:25:15 -04:00
|
|
|
{
|
|
|
|
return true ;
|
|
|
|
}
|
|
|
|
|
2014-04-13 17:52:53 -04:00
|
|
|
bool rs_nxs_test::RsNxsSimpleDummyCircles::recipients(
|
2017-01-21 10:31:22 -05:00
|
|
|
const RsGxsCircleId& /*circleId*/, std::list<RsPgpId>& /*friendlist*/) {
|
2014-04-13 17:52:53 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-21 10:31:22 -05:00
|
|
|
bool rs_nxs_test::RsNxsSimpleDummyCircles::recipients(const RsGxsCircleId& /*circleId*/, const RsGxsGroupId &/*destination_group*/, std::list<RsGxsId>& /*friendlist*/) {
|
2016-03-26 17:25:15 -04:00
|
|
|
return true;
|
|
|
|
}
|
2017-01-21 10:31:22 -05:00
|
|
|
|
2014-04-13 17:52:53 -04:00
|
|
|
rs_nxs_test::RsNxsSimpleDummyReputation::RsNxsSimpleDummyReputation(
|
2017-01-21 10:31:22 -05:00
|
|
|
RepMap& /*repMap*/, bool /*cached*/) {
|
2014-04-13 17:52:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool rs_nxs_test::RsNxsSimpleDummyReputation::haveReputation(
|
2017-01-21 10:31:22 -05:00
|
|
|
const RsGxsId& /*id*/) {
|
2014-04-13 17:52:53 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-21 10:31:22 -05:00
|
|
|
bool rs_nxs_test::RsNxsSimpleDummyReputation::loadReputation(const RsGxsId& /*id*/,
|
|
|
|
const std::list<RsPeerId>& /*peers*/) {
|
2014-04-13 17:52:53 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-21 10:31:22 -05:00
|
|
|
bool rs_nxs_test::RsNxsSimpleDummyReputation::getReputation(const RsGxsId& /*id*/,
|
2014-04-13 17:52:53 -04:00
|
|
|
GixsReputation& rep) {
|
2017-01-13 16:41:54 -05:00
|
|
|
rep.reputation_level = 5;
|
2014-04-13 17:52:53 -04:00
|
|
|
return true;
|
|
|
|
}
|
2014-05-18 13:24:21 -04:00
|
|
|
|
|
|
|
rs_nxs_test::RsNxsDelayedDummyCircles::RsNxsDelayedDummyCircles(
|
|
|
|
int countBeforePresent) : mCountBeforePresent(countBeforePresent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
rs_nxs_test::RsNxsDelayedDummyCircles::~RsNxsDelayedDummyCircles() {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rs_nxs_test::RsNxsDelayedDummyCircles::isLoaded(
|
|
|
|
const RsGxsCircleId& circleId) {
|
|
|
|
return allowed(circleId);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rs_nxs_test::RsNxsDelayedDummyCircles::loadCircle(
|
|
|
|
const RsGxsCircleId& circleId) {
|
|
|
|
return allowed(circleId);
|
|
|
|
}
|
|
|
|
|
2017-01-21 10:31:22 -05:00
|
|
|
int rs_nxs_test::RsNxsDelayedDummyCircles::canSend(const RsGxsCircleId& circleId, const RsPgpId& /*id*/, bool &/*should_encrypt*/) {
|
2014-05-18 13:24:21 -04:00
|
|
|
return allowed(circleId);
|
|
|
|
}
|
|
|
|
|
|
|
|
int rs_nxs_test::RsNxsDelayedDummyCircles::canReceive(
|
2017-01-21 10:31:22 -05:00
|
|
|
const RsGxsCircleId& circleId, const RsPgpId& /*id*/) {
|
2014-05-18 13:24:21 -04:00
|
|
|
return allowed(circleId);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rs_nxs_test::RsNxsDelayedDummyCircles::recipients(
|
2017-01-21 10:31:22 -05:00
|
|
|
const RsGxsCircleId& circleId, std::list<RsPgpId>& /*friendlist*/) {
|
2014-05-18 13:24:21 -04:00
|
|
|
return allowed(circleId);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rs_nxs_test::RsNxsDelayedDummyCircles::allowed(
|
|
|
|
const RsGxsCircleId& circleId) {
|
|
|
|
|
|
|
|
if(mMembershipCallCount.find(circleId) == mMembershipCallCount.end())
|
|
|
|
mMembershipCallCount[circleId] = 0;
|
|
|
|
|
|
|
|
if(mMembershipCallCount[circleId] >= mCountBeforePresent)
|
|
|
|
{
|
|
|
|
mMembershipCallCount[circleId]++;
|
2014-05-27 17:14:05 -04:00
|
|
|
return true;
|
2014-05-18 13:24:21 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mMembershipCallCount[circleId]++;
|
2014-05-27 17:14:05 -04:00
|
|
|
return false;
|
2014-05-18 13:24:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-27 17:14:05 -04:00
|
|
|
const RsPgpId& rs_nxs_test::RsDummyPgpUtils::getPGPOwnId() {
|
|
|
|
return mOwnId;
|
|
|
|
}
|
|
|
|
|
2021-10-29 14:29:18 -04:00
|
|
|
RsPgpId rs_nxs_test::RsDummyPgpUtils::getPgpId(const RsPeerId& /*sslid*/) {
|
2014-05-27 17:14:05 -04:00
|
|
|
return RsPgpId().random();
|
|
|
|
}
|
|
|
|
|
2021-10-29 14:29:18 -04:00
|
|
|
bool rs_nxs_test::RsDummyPgpUtils::getPgpAllList(std::list<RsPgpId>& /*ids*/) {
|
2014-05-27 17:14:05 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-04 11:18:42 -04:00
|
|
|
bool rs_nxs_test::RsDummyPgpUtils::getKeyFingerprint(const RsPgpId& /*id*/,
|
|
|
|
PGPFingerprintType& /*fp*/
|
|
|
|
) const {
|
2014-05-27 17:14:05 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-04 11:18:42 -04:00
|
|
|
bool rs_nxs_test::RsDummyPgpUtils::parseSignature(unsigned char* /*sign*/,
|
|
|
|
unsigned int /*signlen*/,
|
|
|
|
RsPgpId& /*issuer*/
|
|
|
|
) const {
|
2014-05-27 17:14:05 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-04 11:18:42 -04:00
|
|
|
bool rs_nxs_test::RsDummyPgpUtils::VerifySignBin(const void* /*data*/,
|
|
|
|
uint32_t /*len*/,
|
|
|
|
unsigned char* /*sign*/,
|
|
|
|
unsigned int /*signlen*/,
|
|
|
|
const PGPFingerprintType& /*withfingerprint*/
|
|
|
|
) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-27 17:14:05 -04:00
|
|
|
|
|
|
|
|
2014-05-18 13:24:21 -04:00
|
|
|
|