mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-21 23:40:26 -04:00
Added ServiceControl + ServiceInfo. Basics are working, but still a lot to do!
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7196 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a4b54e1021
commit
83a78bcaee
71 changed files with 3168 additions and 209 deletions
110
libretroshare/src/retroshare/rsservicecontrol.h
Normal file
110
libretroshare/src/retroshare/rsservicecontrol.h
Normal file
|
@ -0,0 +1,110 @@
|
|||
#ifndef RETROSHARE_SERVICE_CONTROL_GUI_INTERFACE_H
|
||||
#define RETROSHARE_SERVICE_CONTROL_GUI_INTERFACE_H
|
||||
|
||||
/*
|
||||
* libretroshare/src/rsiface: rsservicecontrol.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2014 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#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,
|
||||
const std::string service_name,
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
/* 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
|
||||
{
|
||||
public:
|
||||
RsServicePermissions();
|
||||
|
||||
bool peerHasPermission(const RsPeerId &peerId) const;
|
||||
|
||||
uint32_t mServiceId;
|
||||
std::string mServiceName;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class RsServiceControl
|
||||
{
|
||||
public:
|
||||
|
||||
RsServiceControl() { return; }
|
||||
virtual ~RsServiceControl() { return; }
|
||||
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue