mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
jsonfy RsServiceControl
This commit is contained in:
parent
9306d8ccc8
commit
31b0f67e94
@ -31,11 +31,15 @@
|
||||
|
||||
/* The Main Interface Class - for information about your Peers */
|
||||
class RsServiceControl;
|
||||
|
||||
/**
|
||||
* Pointer to global instance of RsServiceControl service implementation
|
||||
* @jsonapi{development}
|
||||
*/
|
||||
extern RsServiceControl *rsServiceControl;
|
||||
|
||||
class RsServiceInfo
|
||||
struct RsServiceInfo : RsSerializable
|
||||
{
|
||||
public:
|
||||
RsServiceInfo();
|
||||
RsServiceInfo(
|
||||
const uint16_t service_type,
|
||||
@ -45,6 +49,8 @@ class RsServiceInfo
|
||||
const uint16_t min_version_major,
|
||||
const uint16_t min_version_minor);
|
||||
|
||||
static unsigned int RsServiceInfoUIn16ToFullServiceId(uint16_t serviceType);
|
||||
|
||||
std::string mServiceName;
|
||||
uint32_t mServiceType;
|
||||
// current version, we running.
|
||||
@ -54,32 +60,42 @@ class RsServiceInfo
|
||||
uint16_t mMinVersionMajor;
|
||||
uint16_t mMinVersionMinor;
|
||||
|
||||
static unsigned int RsServiceInfoUIn16ToFullServiceId(uint16_t serviceType);
|
||||
// RsSerializable interface
|
||||
public:
|
||||
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
|
||||
RS_SERIAL_PROCESS(mServiceName);
|
||||
RS_SERIAL_PROCESS(mServiceType);
|
||||
RS_SERIAL_PROCESS(mVersionMajor);
|
||||
RS_SERIAL_PROCESS(mVersionMinor);
|
||||
RS_SERIAL_PROCESS(mMinVersionMajor);
|
||||
RS_SERIAL_PROCESS(mMinVersionMinor);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
bool ServiceInfoCompatible(const RsServiceInfo &info1, const RsServiceInfo &info2);
|
||||
|
||||
|
||||
|
||||
/* this is what is transmitted to peers */
|
||||
class RsPeerServiceInfo
|
||||
struct RsPeerServiceInfo : RsSerializable
|
||||
{
|
||||
public:
|
||||
RsPeerServiceInfo()
|
||||
:mPeerId(), mServiceList() { return; }
|
||||
RsPeerServiceInfo() : mPeerId(), mServiceList() {}
|
||||
|
||||
RsPeerId mPeerId;
|
||||
std::map<uint32_t, RsServiceInfo> mServiceList;
|
||||
|
||||
// RsSerializable interface
|
||||
public:
|
||||
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
|
||||
RS_SERIAL_PROCESS(mPeerId);
|
||||
RS_SERIAL_PROCESS(mServiceList);
|
||||
}
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsPeerServiceInfo &info);
|
||||
std::ostream &operator<<(std::ostream &out, const RsServiceInfo &info);
|
||||
|
||||
|
||||
class RsServicePermissions
|
||||
struct RsServicePermissions : RsSerializable
|
||||
{
|
||||
public:
|
||||
RsServicePermissions();
|
||||
|
||||
bool peerHasPermission(const RsPeerId &peerId) const;
|
||||
@ -96,6 +112,18 @@ public:
|
||||
// if DefaultAllowed = false, then only PeersAllowed is checked.
|
||||
std::set<RsPeerId> mPeersAllowed;
|
||||
std::set<RsPeerId> mPeersDenied;
|
||||
|
||||
// RsSerializable interface
|
||||
public:
|
||||
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
|
||||
RS_SERIAL_PROCESS(mServiceId);
|
||||
RS_SERIAL_PROCESS(mServiceName);
|
||||
|
||||
RS_SERIAL_PROCESS(mDefaultAllowed);
|
||||
|
||||
RS_SERIAL_PROCESS(mPeersAllowed);
|
||||
RS_SERIAL_PROCESS(mPeersDenied);
|
||||
}
|
||||
};
|
||||
|
||||
class RsServiceControl
|
||||
@ -105,17 +133,74 @@ class RsServiceControl
|
||||
RsServiceControl() { return; }
|
||||
virtual ~RsServiceControl() { return; }
|
||||
|
||||
/**
|
||||
* @brief getOwnServices return a map off all services.
|
||||
* @jsonapi{development}
|
||||
* @param[out] info
|
||||
* @return always true
|
||||
*/
|
||||
virtual bool getOwnServices(RsPeerServiceInfo &info) = 0;
|
||||
|
||||
/**
|
||||
* @brief getServiceName lookup the name of a service.
|
||||
* @jsonapi{development}
|
||||
* @param[in] service_id service to look up
|
||||
* @return name of service
|
||||
*/
|
||||
virtual std::string getServiceName(uint32_t service_id) = 0;
|
||||
|
||||
/**
|
||||
* @brief getServiceItemNames return a map of service item names.
|
||||
* @jsonapi{development}
|
||||
* @param[in] service_id service to look up
|
||||
* @param[out] names names of items
|
||||
* @return true on success false otherwise
|
||||
*/
|
||||
virtual bool getServiceItemNames(uint32_t service_id,std::map<uint8_t,std::string>& names) = 0;
|
||||
|
||||
/**
|
||||
* @brief getServicesAllowed return a mpa with allowed service information.
|
||||
* @jsonapi{development}
|
||||
* @param[in] peerId peer to look up
|
||||
* @param[out] info map with infomration
|
||||
* @return always true
|
||||
*/
|
||||
virtual bool getServicesAllowed(const RsPeerId &peerId, RsPeerServiceInfo &info) = 0;
|
||||
|
||||
/**
|
||||
* @brief getServicesProvided return services provided by a peer.
|
||||
* @jsonapi{development}
|
||||
* @param[in] peerId peer to look up
|
||||
* @param[out] info
|
||||
* @return true on success false otherwise.
|
||||
*/
|
||||
virtual bool getServicesProvided(const RsPeerId &peerId, RsPeerServiceInfo &info) = 0;
|
||||
|
||||
/**
|
||||
* @brief getServicePermissions return permissions of one service.
|
||||
* @jsonapi{development}
|
||||
* @param[in] serviceId service id to look up
|
||||
* @param[out] permissions
|
||||
* @return true on success false otherwise.
|
||||
*/
|
||||
virtual bool getServicePermissions(uint32_t serviceId, RsServicePermissions &permissions) = 0;
|
||||
|
||||
/**
|
||||
* @brief updateServicePermissions update service permissions of one service.
|
||||
* @jsonapi{development}
|
||||
* @param[in] serviceId service to update
|
||||
* @param[in] permissions new permissions
|
||||
* @return true on success false otherwise.
|
||||
*/
|
||||
virtual bool updateServicePermissions(uint32_t serviceId, const RsServicePermissions &permissions) = 0;
|
||||
|
||||
/**
|
||||
* @brief getPeersConnected return peers using a service.
|
||||
* @jsonapi{development}
|
||||
* @param[in] serviceId service to look up.
|
||||
* @param[out] peerSet set of peers using this service.
|
||||
*/
|
||||
virtual void getPeersConnected(const uint32_t serviceId, std::set<RsPeerId> &peerSet) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user