2018-05-28 22:03:39 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* libretroshare/src/pqi: pqiloopback.cc *
|
|
|
|
* *
|
|
|
|
* libretroshare: retroshare core library *
|
|
|
|
* *
|
|
|
|
* Copyright 2004-2008 by Robert Fernie <retroshare@lunamutt.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Lesser 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/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2007-11-15 03:18:48 +00:00
|
|
|
#include "pqi/pqiloopback.h"
|
|
|
|
|
2016-08-25 11:33:11 +02:00
|
|
|
#include <stddef.h> // for NULL
|
|
|
|
|
2018-01-22 15:02:33 +01:00
|
|
|
struct RsItem;
|
2016-08-25 11:33:11 +02:00
|
|
|
|
2008-04-04 12:19:50 +00:00
|
|
|
/***
|
|
|
|
#define LOOPBACK_DEBUG 1
|
|
|
|
***/
|
|
|
|
|
2014-03-17 20:56:06 +00:00
|
|
|
pqiloopback::pqiloopback(const RsPeerId& id)
|
2007-12-12 01:29:14 +00:00
|
|
|
:PQInterface(id)
|
2007-11-15 03:18:48 +00:00
|
|
|
{
|
|
|
|
setMaxRate(true, 0);
|
|
|
|
setMaxRate(false, 0);
|
|
|
|
setRate(true, 0);
|
|
|
|
setRate(false, 0);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pqiloopback::~pqiloopback()
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-12 01:29:14 +00:00
|
|
|
int pqiloopback::SendItem(RsItem *i)
|
2007-11-15 03:18:48 +00:00
|
|
|
{
|
2008-04-04 12:19:50 +00:00
|
|
|
|
|
|
|
#ifdef LOOPBACK_DEBUG
|
|
|
|
std::cerr << "pqiloopback::SendItem()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
i->print(std::cerr);
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
2007-11-15 03:18:48 +00:00
|
|
|
objs.push_back(i);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-12-12 01:29:14 +00:00
|
|
|
RsItem * pqiloopback::GetItem()
|
2007-11-15 03:18:48 +00:00
|
|
|
{
|
|
|
|
if (objs.size() > 0)
|
|
|
|
{
|
2007-12-12 01:29:14 +00:00
|
|
|
RsItem *pqi = objs.front();
|
2007-11-15 03:18:48 +00:00
|
|
|
objs.pop_front();
|
2008-04-04 12:19:50 +00:00
|
|
|
#ifdef LOOPBACK_DEBUG
|
|
|
|
std::cerr << "pqiloopback::GetItem()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
pqi->print(std::cerr);
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
2007-11-15 03:18:48 +00:00
|
|
|
return pqi;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-01-25 06:36:40 +00:00
|
|
|
// PQI interface.
|
2007-11-15 03:18:48 +00:00
|
|
|
int pqiloopback::tick()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pqiloopback::status()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|