2018-05-28 16:28:51 -04:00
|
|
|
/*******************************************************************************
|
|
|
|
* libretroshare/src/retroshare: rsservicecontrol.h *
|
|
|
|
* *
|
|
|
|
* libretroshare: retroshare core library *
|
|
|
|
* *
|
|
|
|
* Copyright 2014-2014 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/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2014-03-21 23:53:44 -04:00
|
|
|
#ifndef RETROSHARE_SERVICE_CONTROL_GUI_INTERFACE_H
|
|
|
|
#define RETROSHARE_SERVICE_CONTROL_GUI_INTERFACE_H
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <retroshare/rstypes.h>
|
|
|
|
|
|
|
|
/* The Main Interface Class - for information about your Peers */
|
|
|
|
class RsServiceControl;
|
|
|
|
extern RsServiceControl *rsServiceControl;
|
|
|
|
|
|
|
|
class RsServiceInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsServiceInfo();
|
|
|
|
RsServiceInfo(
|
|
|
|
const uint16_t service_type,
|
2017-07-27 10:54:56 -04:00
|
|
|
const std::string& service_name,
|
2014-03-21 23:53:44 -04:00
|
|
|
const uint16_t version_major,
|
|
|
|
const uint16_t version_minor,
|
|
|
|
const uint16_t min_version_major,
|
|
|
|
const uint16_t min_version_minor);
|
|
|
|
|
|
|
|
std::string mServiceName;
|
|
|
|
uint32_t mServiceType;
|
|
|
|
// current version, we running.
|
|
|
|
uint16_t mVersionMajor;
|
|
|
|
uint16_t mVersionMinor;
|
|
|
|
// minimum version can communicate with.
|
|
|
|
uint16_t mMinVersionMajor;
|
|
|
|
uint16_t mMinVersionMinor;
|
2018-08-01 14:30:28 -04:00
|
|
|
|
|
|
|
static unsigned int RsServiceInfoUIn16ToFullServiceId(uint16_t serviceType);
|
2014-03-21 23:53:44 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-03-22 02:28:59 -04:00
|
|
|
bool ServiceInfoCompatible(const RsServiceInfo &info1, const RsServiceInfo &info2);
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-21 23:53:44 -04:00
|
|
|
/* this is what is transmitted to peers */
|
|
|
|
class RsPeerServiceInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsPeerServiceInfo()
|
|
|
|
:mPeerId(), mServiceList() { return; }
|
|
|
|
|
|
|
|
RsPeerId mPeerId;
|
|
|
|
std::map<uint32_t, RsServiceInfo> mServiceList;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::ostream &operator<<(std::ostream &out, const RsPeerServiceInfo &info);
|
|
|
|
std::ostream &operator<<(std::ostream &out, const RsServiceInfo &info);
|
|
|
|
|
|
|
|
|
|
|
|
class RsServicePermissions
|
|
|
|
{
|
2015-02-03 16:28:32 -05:00
|
|
|
public:
|
|
|
|
RsServicePermissions();
|
2014-03-21 23:53:44 -04:00
|
|
|
|
2015-02-01 09:38:19 -05:00
|
|
|
bool peerHasPermission(const RsPeerId &peerId) const;
|
|
|
|
|
|
|
|
void setPermission(const RsPeerId& peerId) ;
|
|
|
|
void resetPermission(const RsPeerId& peerId) ;
|
2014-03-21 23:53:44 -04:00
|
|
|
|
2015-02-03 16:28:32 -05:00
|
|
|
uint32_t mServiceId;
|
|
|
|
std::string mServiceName;
|
2014-03-21 23:53:44 -04:00
|
|
|
|
2015-02-03 16:28:32 -05:00
|
|
|
bool mDefaultAllowed;
|
|
|
|
// note only one of these is checked.
|
|
|
|
// if DefaultAllowed = true, then only PeersDenied is checked.
|
|
|
|
// if DefaultAllowed = false, then only PeersAllowed is checked.
|
|
|
|
std::set<RsPeerId> mPeersAllowed;
|
|
|
|
std::set<RsPeerId> mPeersDenied;
|
2014-03-21 23:53:44 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class RsServiceControl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RsServiceControl() { return; }
|
|
|
|
virtual ~RsServiceControl() { return; }
|
|
|
|
|
2014-03-22 02:28:59 -04:00
|
|
|
virtual bool getOwnServices(RsPeerServiceInfo &info) = 0;
|
2016-12-20 18:34:07 -05:00
|
|
|
virtual std::string getServiceName(uint32_t service_id) = 0;
|
2017-04-20 14:54:51 -04:00
|
|
|
virtual bool getServiceItemNames(uint32_t service_id,std::map<uint8_t,std::string>& names) = 0;
|
2014-03-22 02:28:59 -04:00
|
|
|
|
2014-03-21 23:53:44 -04:00
|
|
|
virtual bool getServicesAllowed(const RsPeerId &peerId, RsPeerServiceInfo &info) = 0;
|
|
|
|
virtual bool getServicesProvided(const RsPeerId &peerId, RsPeerServiceInfo &info) = 0;
|
|
|
|
virtual bool getServicePermissions(uint32_t serviceId, RsServicePermissions &permissions) = 0;
|
|
|
|
virtual bool updateServicePermissions(uint32_t serviceId, const RsServicePermissions &permissions) = 0;
|
|
|
|
|
2014-03-26 03:45:03 -04:00
|
|
|
virtual void getPeersConnected(const uint32_t serviceId, std::set<RsPeerId> &peerSet) = 0;
|
|
|
|
|
2014-03-21 23:53:44 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|