removed offline status msg

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2729 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2010-04-18 20:01:31 +00:00
parent 9fb3770066
commit a5bc5d7aa2
4 changed files with 61 additions and 24 deletions

View File

@ -35,12 +35,14 @@ extern RsStatus *rsStatus;
#include <inttypes.h>
#include <list>
const uint32_t RS_STATUS_OFFLINE = 0x0001;
const uint32_t RS_STATUS_AWAY = 0x0002;
const uint32_t RS_STATUS_BUSY = 0x0003;
const uint32_t RS_STATUS_ONLINE = 0x0004;
const uint32_t RS_STATUS_AWAY = 0x0001;
const uint32_t RS_STATUS_BUSY = 0x0002;
const uint32_t RS_STATUS_ONLINE = 0x0003;
//! data object for peer status information
/*!
* data object used for peer status information
*/
class StatusInfo
{
public:
@ -49,14 +51,39 @@ class StatusInfo
time_t time_stamp; /// for owner time set, and for their peers time sent
};
//! Interface to retroshare for Rs status
/*!
* Provides an interface for retroshare's status functionality
*/
class RsStatus
{
public:
virtual bool getStatus(std::list<StatusInfo>& statusInfo) = 0;
virtual bool sendStatus(StatusInfo& statusInfo) = 0;
virtual bool statusAvailable() = 0;
virtual void getStatusString(uint32_t status, std::string& statusString) = 0;
/**
* This retrieves the status info on the client's peers
* @param statusInfo is populated with client's peer's status
*/
virtual bool getStatus(std::list<StatusInfo>& statusInfo) = 0;
/**
* send the client's status to his/her peers
* @param statusInfo the status of the peers
* @return will return false if status info does not belong to client
*/
virtual bool sendStatus(StatusInfo& statusInfo) = 0;
/**
* checks to see if any status items have been received
*/
virtual bool statusAvailable() = 0;
/**
* translates the status field of a peer to a string
* @status the status id that needs to be translated
* @statusString the string translation is passed here
*/
virtual void getStatusString(uint32_t status, std::string& statusString) = 0;
};

View File

@ -55,11 +55,7 @@ bool p3Status::statusAvailable(){
void p3Status::getStatusString(uint32_t status, std::string& statusString){
if (status == RS_STATUS_OFFLINE){
statusString = "Offline";
}else if (status == RS_STATUS_AWAY){
if (status == RS_STATUS_AWAY){
statusString = "Away";

View File

@ -127,6 +127,7 @@ bool p3StatusService::getStatus(std::list<StatusInfo>& statusInfo)
for(mit = mStatusInfoMap.begin(); mit != mStatusInfoMap.end(); mit++){
statusInfo.push_back(mit->second);
}
}
return true;
@ -142,18 +143,25 @@ bool p3StatusService::sendStatus(StatusInfo& statusInfo)
if(statusInfo.id != mConnMgr->getOwnId())
return false;
mStatusInfoMap[statusInfo.id] = statusInfo;
// If your id is not set, set it
if(mStatusInfoMap.find(statusInfo.id) == mStatusInfoMap.end()){
std::pair<std::string, StatusInfo> pr(statusInfo.id, statusInfo);
mStatusInfoMap.insert(pr);
IndicateConfigChanged();
}else
if(mStatusInfoMap[statusInfo.id].status != statusInfo.status){
IndicateConfigChanged();
mStatusInfoMap[statusInfo.id] = statusInfo;
}
mConnMgr->getOnlineList(onlineList);
}
//statusItem->PeerId(statusInfo.id);
std::list<std::string>::iterator it;
#ifdef STATUS_DEBUG
std::cerr << "p3StatusService::sendStatus() " << std::endl;
std::cerr << statusInfo;
@ -252,25 +260,27 @@ bool p3StatusService::loadList(std::list<RsItem*> load){
// load your status from last rs session
StatusInfo own_info;
std::list<RsItem*>::iterator it = load.begin();
std::list<RsItem*>::const_iterator it = load.begin();
if(it == load.end()){
std::cerr << "p3StatusService::loadList(): Failed to load " << std::endl;
return false;
}
for(; it != load.end(); it++){
RsStatusItem* own_status = dynamic_cast<RsStatusItem* >(*it);
if(own_status != NULL){
own_info.id = own_status->PeerId();
own_info.id = mConnMgr->getOwnId();
own_info.status = own_status->status;
own_info.time_stamp = own_status->sendTime;
delete own_status;
{
RsStackMutex stack(mStatusMtx);
std::pair<std::string, StatusInfo> pr(own_info.id, own_info);
std::pair<std::string, StatusInfo> pr(mConnMgr->getOwnId(), own_info);
mStatusInfoMap.insert(pr);
}
@ -280,6 +290,7 @@ bool p3StatusService::loadList(std::list<RsItem*> load){
<< std::endl;
}
}
return false;
}

View File

@ -54,6 +54,9 @@ virtual int status();
/********* RsStatus ***********/
/**
* Status is set to offline as default if no info received from relevant peer
*/
virtual bool getStatus(std::list<StatusInfo>& statusInfo);
virtual bool sendStatus(StatusInfo& statusInfo);
virtual bool statusAvailable();