RetroShare/libresapi/src/api/PeersHandler.h

67 lines
2.0 KiB
C
Raw Normal View History

#pragma once
#include "ResourceRouter.h"
#include "StateTokenServer.h"
2015-07-29 15:02:10 +02:00
#include "ChatHandler.h"
#include <retroshare/rsnotify.h>
#include <util/rsthreads.h>
class RsPeers;
class RsMsgs;
namespace resource_api
{
2015-07-29 15:02:10 +02:00
class PeersHandler: public ResourceRouter, NotifyClient, Tickable, public UnreadMsgNotify
{
public:
PeersHandler(StateTokenServer* sts, RsNotify* notify, RsPeers* peers, RsMsgs* msgs);
virtual ~PeersHandler();
// from NotifyClient
// note: this may get called from foreign threads
virtual void notifyListChange(int list, int type); // friends list change
virtual void notifyPeerHasNewAvatar(std::string /*peer_id*/);
// from Tickable
virtual void tick();
2015-07-29 15:02:10 +02:00
// from UnreadMsgNotify
// ChatHandler calls this to tell us about unreadmsgs
// this allows to merge unread msgs info with the peers list
virtual void notifyUnreadMsgCountChanged(const RsPeerId& peer, uint32_t count);
private:
void handleWildcard(Request& req, Response& resp);
void handleExamineCert(Request& req, Response& resp);
2017-03-25 18:28:31 +01:00
void handleGetStateString(Request& req, Response& resp);
void handleSetStateString(Request& req, Response& resp);
void handleGetCustomStateString(Request& req, Response& resp);
void handleSetCustomStateString(Request& req, Response& resp);
void handleGetPGPOptions(Request& req, Response& resp);
void handleSetPGPOptions(Request& req, Response& resp);
// a helper which ensures proper mutex locking
StateToken getCurrentStateToken();
StateTokenServer* mStateTokenServer;
RsNotify* mNotify;
RsPeers* mRsPeers;
RsMsgs* mRsMsgs; // required for avatar data
std::list<RsPeerId> mOnlinePeers;
2017-03-28 11:20:51 +02:00
uint32_t status;
std::string custom_state_string;
RsMutex mMtx;
StateToken mStateToken; // mutex protected
2017-03-28 11:20:51 +02:00
StateToken mStringStateToken; // mutex protected
StateToken mCustomStateToken; // mutex protected
2015-07-29 15:02:10 +02:00
std::map<RsPeerId, uint32_t> mUnreadMsgsCounts;
};
} // namespace resource_api