mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 07:59:29 -05:00
Added status service: p3status
Added status service to core: p3face-startup git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@524 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
02c6d70e30
commit
26d2def720
@ -4,7 +4,7 @@
|
|||||||
/*
|
/*
|
||||||
* libretroshare/src/rsiface: rsstatus.h
|
* libretroshare/src/rsiface: rsstatus.h
|
||||||
*
|
*
|
||||||
* RetroShare C++ Interface.
|
* RetroShare C++ .
|
||||||
*
|
*
|
||||||
* Copyright 2007-2008 by Vinny Do.
|
* Copyright 2007-2008 by Vinny Do.
|
||||||
*
|
*
|
||||||
@ -26,10 +26,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class RsStatusInterface;
|
class RsStatus;
|
||||||
|
|
||||||
extern RsStatusInterface *rsStatusInterface;
|
extern RsStatus *rsStatus;
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ class StatusInfo
|
|||||||
uint32_t status;
|
uint32_t status;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsStatusInterface
|
class RsStatus
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool getStatus(std::string id, StatusInfo& statusInfo) = 0;
|
virtual bool getStatus(std::string id, StatusInfo& statusInfo) = 0;
|
||||||
@ -53,4 +54,6 @@ virtual bool setStatus(StatusInfo& statusInfo) = 0;
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& out, const StatusInfo& statusInfo);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include "services/p3ranking.h"
|
#include "services/p3ranking.h"
|
||||||
#include "services/p3photoservice.h"
|
#include "services/p3photoservice.h"
|
||||||
#include "services/p3forums.h"
|
#include "services/p3forums.h"
|
||||||
|
#include "services/p3status.h"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -738,11 +739,13 @@ int RsServer::StartupRetroShare(RsInit *config)
|
|||||||
rsPhoto = new p3Photo(photoService);
|
rsPhoto = new p3Photo(photoService);
|
||||||
rsRanks = new p3Rank(mRanking);
|
rsRanks = new p3Rank(mRanking);
|
||||||
rsForums = new p3Forums();
|
rsForums = new p3Forums();
|
||||||
|
rsStatus = new p3Status();
|
||||||
#else
|
#else
|
||||||
rsGameLauncher = NULL;
|
rsGameLauncher = NULL;
|
||||||
rsPhoto = NULL;
|
rsPhoto = NULL;
|
||||||
rsRanks = NULL;
|
rsRanks = NULL;
|
||||||
rsForums = NULL;
|
rsForums = NULL;
|
||||||
|
rsStatus = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@ include $(RS_TOP_DIR)/scripts/config.mk
|
|||||||
RSOBJ = p3service.o p3chatservice.o p3msgservice.o \
|
RSOBJ = p3service.o p3chatservice.o p3msgservice.o \
|
||||||
p3gamelauncher.o p3ranking.o p3disc.o \
|
p3gamelauncher.o p3ranking.o p3disc.o \
|
||||||
p3photoservice.o \
|
p3photoservice.o \
|
||||||
p3forums.o
|
p3forums.o \
|
||||||
|
p3status.o
|
||||||
|
|
||||||
# p3distrib.o
|
# p3distrib.o
|
||||||
|
|
||||||
|
96
libretroshare/src/services/p3status.cc
Normal file
96
libretroshare/src/services/p3status.cc
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* libretroshare/src/services: p3status.cc
|
||||||
|
*
|
||||||
|
* RetroShare C++ .
|
||||||
|
*
|
||||||
|
* Copyright 2008 by Vinny Do.
|
||||||
|
*
|
||||||
|
* 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 "services/p3status.h"
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& out, const StatusInfo& si)
|
||||||
|
{
|
||||||
|
out << "StatusInfo: " << std::endl;
|
||||||
|
out << "id: " << si.id << std::endl;
|
||||||
|
out << "status: " << si.status << std::endl;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsStatus *rsStatus = NULL;
|
||||||
|
|
||||||
|
p3Status::p3Status()
|
||||||
|
{
|
||||||
|
loadDummyData();
|
||||||
|
}
|
||||||
|
|
||||||
|
p3Status::~p3Status()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/********* RsStatus ***********/
|
||||||
|
|
||||||
|
bool p3Status::getStatus(std::string id, StatusInfo& statusInfo)
|
||||||
|
{
|
||||||
|
std::map<std::string, StatusInfo>::iterator it;
|
||||||
|
it = mStatusInfoMap.find(id);
|
||||||
|
if (it == mStatusInfoMap.end())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
statusInfo.id = (it->second).id;
|
||||||
|
statusInfo.status = (it->second).status;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool p3Status::setStatus(StatusInfo& statusInfo)
|
||||||
|
{
|
||||||
|
mStatusInfoMap[statusInfo.id] = statusInfo;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************/
|
||||||
|
|
||||||
|
void p3Status::loadDummyData()
|
||||||
|
{
|
||||||
|
StatusInfo si;
|
||||||
|
|
||||||
|
si.id = "id01";
|
||||||
|
si.status = RS_STATUS_OFFLINE;
|
||||||
|
|
||||||
|
setStatus(si);
|
||||||
|
|
||||||
|
si.id = "id02";
|
||||||
|
si.status = RS_STATUS_AWAY;
|
||||||
|
|
||||||
|
setStatus(si);
|
||||||
|
|
||||||
|
si.id = "id03";
|
||||||
|
si.status = RS_STATUS_BUSY;
|
||||||
|
|
||||||
|
setStatus(si);
|
||||||
|
|
||||||
|
si.id = "id04";
|
||||||
|
si.status = RS_STATUS_ONLINE;
|
||||||
|
|
||||||
|
setStatus(si);
|
||||||
|
}
|
54
libretroshare/src/services/p3status.h
Normal file
54
libretroshare/src/services/p3status.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#ifndef RS_P3_STATUS_INTERFACE_H
|
||||||
|
#define RS_P3_STATUS_INTERFACE_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* libretroshare/src/services: p3status.h
|
||||||
|
*
|
||||||
|
* RetroShare C++ .
|
||||||
|
*
|
||||||
|
* Copyright 2008 by Vinny Do.
|
||||||
|
*
|
||||||
|
* 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 "rsiface/rsstatus.h"
|
||||||
|
|
||||||
|
class p3Status: public RsStatus
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
p3Status();
|
||||||
|
virtual ~p3Status();
|
||||||
|
|
||||||
|
/********* RsStatus ***********/
|
||||||
|
|
||||||
|
virtual bool getStatus(std::string id, StatusInfo& statusInfo);
|
||||||
|
virtual bool setStatus(StatusInfo& statusInfo);
|
||||||
|
|
||||||
|
/******************************/
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void loadDummyData();
|
||||||
|
std::map<std::string, StatusInfo> mStatusInfoMap;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user