2010-04-15 06:47:48 -04:00
|
|
|
#ifndef RS_P3_STATUS_INTERFACE_H
|
|
|
|
#define RS_P3_STATUS_INTERFACE_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* libretroshare/src/services: p3statusService.h
|
|
|
|
*
|
|
|
|
* RetroShare C++
|
|
|
|
*
|
|
|
|
* Copyright 2008 by Vinny Do, Chris Evi-Parker.
|
|
|
|
*
|
|
|
|
* 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 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 <map>
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
#include "serialiser/rsstatusitems.h"
|
2010-08-06 05:40:23 -04:00
|
|
|
#include "retroshare/rsstatus.h"
|
2010-04-15 06:47:48 -04:00
|
|
|
#include "services/p3service.h"
|
2011-07-09 14:39:34 -04:00
|
|
|
#include "pqi/p3cfgmgr.h"
|
|
|
|
#include "pqi/pqimonitor.h"
|
|
|
|
|
|
|
|
class p3LinkMgr;
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
//! handles standard status messages (busy, away, online, offline) set by user
|
|
|
|
/*!
|
|
|
|
* The is a retroshare service which allows peers
|
|
|
|
* to inform each other about their status in a standard way, as opposed to
|
|
|
|
* custom string.
|
|
|
|
* @see rsiface/rsstatus.h for status constants
|
|
|
|
*/
|
2010-07-20 15:45:07 -04:00
|
|
|
class p3StatusService: public p3Service, public p3Config, public pqiMonitor
|
2010-04-15 06:47:48 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2011-07-09 14:39:34 -04:00
|
|
|
p3StatusService(p3LinkMgr *lm);
|
2010-04-15 06:47:48 -04:00
|
|
|
virtual ~p3StatusService();
|
|
|
|
|
|
|
|
/***** overloaded from p3Service *****/
|
|
|
|
virtual int tick();
|
|
|
|
virtual int status();
|
|
|
|
|
2010-07-20 15:45:07 -04:00
|
|
|
/*************** pqiMonitor callback ***********************/
|
|
|
|
virtual void statusChange(const std::list<pqipeer> &plist);
|
|
|
|
|
2010-04-15 06:47:48 -04:00
|
|
|
/********* RsStatus ***********/
|
|
|
|
|
2010-04-18 16:01:31 -04:00
|
|
|
/**
|
|
|
|
* Status is set to offline as default if no info received from relevant peer
|
|
|
|
*/
|
2010-07-20 15:45:07 -04:00
|
|
|
virtual bool getOwnStatus(StatusInfo& statusInfo);
|
2010-08-20 14:45:44 -04:00
|
|
|
virtual bool getStatusList(std::list<StatusInfo>& statusInfo);
|
2012-01-17 15:36:36 -05:00
|
|
|
virtual bool getStatus(const std::string &id, StatusInfo &statusInfo);
|
2010-07-20 15:45:07 -04:00
|
|
|
/* id = "", status is sent to all online peers */
|
|
|
|
virtual bool sendStatus(const std::string &id, uint32_t status);
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
/******************************/
|
|
|
|
|
|
|
|
|
|
|
|
/** implemented from p3Config **/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @return The serialiser the enables storage of save info
|
|
|
|
*/
|
|
|
|
virtual RsSerialiser *setupSerialiser();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* This stores information on what your status was before you exited rs
|
|
|
|
*/
|
2010-12-18 14:35:07 -05:00
|
|
|
virtual bool saveList(bool& cleanup, std::list<RsItem*>&);
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @param load Should contain a single item which is clients status from last rs session
|
|
|
|
*/
|
2010-12-18 14:35:07 -05:00
|
|
|
virtual bool loadList(std::list<RsItem*>& load);
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2010-08-20 14:45:44 -04:00
|
|
|
virtual void receiveStatusQueue();
|
2010-04-15 06:47:48 -04:00
|
|
|
|
2011-07-09 14:39:34 -04:00
|
|
|
p3LinkMgr *mLinkMgr;
|
2010-04-15 06:47:48 -04:00
|
|
|
|
|
|
|
std::map<std::string, StatusInfo> mStatusInfoMap;
|
|
|
|
|
|
|
|
RsMutex mStatusMtx;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|