2015-03-18 18:48:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ResourceRouter.h"
|
|
|
|
#include "StateTokenServer.h"
|
2015-07-29 15:02:10 +02:00
|
|
|
#include "ChatHandler.h"
|
2015-03-18 18:48:43 +00:00
|
|
|
#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
|
2015-03-18 18:48:43 +00:00
|
|
|
{
|
|
|
|
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
|
2015-06-24 11:13:53 +00:00
|
|
|
virtual void notifyPeerHasNewAvatar(std::string /*peer_id*/);
|
2015-03-18 18:48:43 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
2015-03-18 18:48:43 +00:00
|
|
|
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);
|
|
|
|
|
2017-04-12 20:24:18 +02:00
|
|
|
void handleGetPGPOptions(Request& req, Response& resp);
|
|
|
|
void handleSetPGPOptions(Request& req, Response& resp);
|
|
|
|
|
2015-03-18 18:48:43 +00:00
|
|
|
// 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;
|
2015-03-18 18:48:43 +00:00
|
|
|
|
|
|
|
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;
|
2015-03-18 18:48:43 +00:00
|
|
|
};
|
|
|
|
} // namespace resource_api
|