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:
vinnyx 2008-04-26 09:39:02 +00:00
parent 02c6d70e30
commit 26d2def720
5 changed files with 162 additions and 5 deletions

View file

@ -10,7 +10,8 @@ include $(RS_TOP_DIR)/scripts/config.mk
RSOBJ = p3service.o p3chatservice.o p3msgservice.o \
p3gamelauncher.o p3ranking.o p3disc.o \
p3photoservice.o \
p3forums.o
p3forums.o \
p3status.o
# p3distrib.o

View 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);
}

View 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