mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-15 01:25:56 -04:00
ID cleaning. Saving progress
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7103 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c56e1627f4
commit
55e35975e9
18 changed files with 346 additions and 287 deletions
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <retroshare/rsids.h>
|
#include <retroshare/rstypes.h>
|
||||||
|
|
||||||
class RsPeerDetails ;
|
class RsPeerDetails ;
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ p3HistoryMgr::~p3HistoryMgr()
|
||||||
|
|
||||||
/***** p3HistoryMgr *****/
|
/***** p3HistoryMgr *****/
|
||||||
|
|
||||||
void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, const std::string &peerId, const RsChatMsgItem *chatItem)
|
void p3HistoryMgr::addMessage(bool incoming, const RsPeerId &chatPeerId, const RsPeerId &peerId, const RsChatMsgItem *chatItem)
|
||||||
{
|
{
|
||||||
uint32_t addMsgId = 0;
|
uint32_t addMsgId = 0;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
if (mPublicEnable == false && chatPeerId.empty()) {
|
if (mPublicEnable == false && chatPeerId.isNull()) {
|
||||||
// public chat not enabled
|
// public chat not enabled
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -87,12 +87,12 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons
|
||||||
|
|
||||||
if (cli)
|
if (cli)
|
||||||
{
|
{
|
||||||
if (mLobbyEnable == false && !chatPeerId.empty()) // lobby chat not enabled
|
if (mLobbyEnable == false && !chatPeerId.isNull()) // lobby chat not enabled
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mPrivateEnable == false && !chatPeerId.empty()) // private chat not enabled
|
if (mPrivateEnable == false && !chatPeerId.isNull()) // private chat not enabled
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons
|
||||||
item->message = chatItem->message ;
|
item->message = chatItem->message ;
|
||||||
//librs::util::ConvertUtf16ToUtf8(chatItem->message, item->message);
|
//librs::util::ConvertUtf16ToUtf8(chatItem->message, item->message);
|
||||||
|
|
||||||
std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(item->chatPeerId);
|
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(item->chatPeerId);
|
||||||
if (mit != mMessages.end()) {
|
if (mit != mMessages.end()) {
|
||||||
item->msgId = nextMsgId++;
|
item->msgId = nextMsgId++;
|
||||||
mit->second.insert(std::make_pair(item->msgId, item));
|
mit->second.insert(std::make_pair(item->msgId, item));
|
||||||
|
@ -120,7 +120,7 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons
|
||||||
|
|
||||||
// check the limit
|
// check the limit
|
||||||
uint32_t limit;
|
uint32_t limit;
|
||||||
if (chatPeerId.empty())
|
if (chatPeerId.isNull())
|
||||||
limit = mPublicSaveCount;
|
limit = mPublicSaveCount;
|
||||||
else if (cli)
|
else if (cli)
|
||||||
limit = mLobbySaveCount;
|
limit = mLobbySaveCount;
|
||||||
|
@ -159,7 +159,7 @@ void p3HistoryMgr::cleanOldMessages()
|
||||||
time_t now = time(NULL) ;
|
time_t now = time(NULL) ;
|
||||||
bool changed = false ;
|
bool changed = false ;
|
||||||
|
|
||||||
for(std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.begin(); mit != mMessages.end();)
|
for(std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.begin(); mit != mMessages.end();)
|
||||||
{
|
{
|
||||||
if (mMaxStorageDurationSeconds > 0)
|
if (mMaxStorageDurationSeconds > 0)
|
||||||
{
|
{
|
||||||
|
@ -183,7 +183,7 @@ void p3HistoryMgr::cleanOldMessages()
|
||||||
|
|
||||||
if(mit->second.empty())
|
if(mit->second.empty())
|
||||||
{
|
{
|
||||||
std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit2 = mit ;
|
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit2 = mit ;
|
||||||
++mit2 ;
|
++mit2 ;
|
||||||
std::cerr << " removing peer id " << mit->first << ", since it has no messages" << std::endl;
|
std::cerr << " removing peer id " << mit->first << ", since it has no messages" << std::endl;
|
||||||
mMessages.erase(mit) ;
|
mMessages.erase(mit) ;
|
||||||
|
@ -216,7 +216,7 @@ bool p3HistoryMgr::saveList(bool& cleanup, std::list<RsItem*>& saveData)
|
||||||
|
|
||||||
mHistoryMtx.lock(); /********** STACK LOCKED MTX ******/
|
mHistoryMtx.lock(); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit;
|
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit;
|
||||||
std::map<uint32_t, RsHistoryMsgItem*>::iterator lit;
|
std::map<uint32_t, RsHistoryMsgItem*>::iterator lit;
|
||||||
for (mit = mMessages.begin(); mit != mMessages.end(); mit++) {
|
for (mit = mMessages.begin(); mit != mMessages.end(); mit++) {
|
||||||
for (lit = mit->second.begin(); lit != mit->second.end(); lit++) {
|
for (lit = mit->second.begin(); lit != mit->second.end(); lit++) {
|
||||||
|
@ -287,7 +287,7 @@ bool p3HistoryMgr::loadList(std::list<RsItem*>& load)
|
||||||
for (it = load.begin(); it != load.end(); it++) {
|
for (it = load.begin(); it != load.end(); it++) {
|
||||||
if (NULL != (msgItem = dynamic_cast<RsHistoryMsgItem*>(*it))) {
|
if (NULL != (msgItem = dynamic_cast<RsHistoryMsgItem*>(*it))) {
|
||||||
|
|
||||||
std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(msgItem->chatPeerId);
|
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(msgItem->chatPeerId);
|
||||||
msgItem->msgId = nextMsgId++;
|
msgItem->msgId = nextMsgId++;
|
||||||
|
|
||||||
std::cerr << "Loading msg history item: peer id=" << msgItem->chatPeerId << "), msg id =" << msgItem->msgId << std::endl;
|
std::cerr << "Loading msg history item: peer id=" << msgItem->chatPeerId << "), msg id =" << msgItem->msgId << std::endl;
|
||||||
|
@ -371,7 +371,7 @@ static void convertMsg(const RsHistoryMsgItem* item, HistoryMsg &msg)
|
||||||
msg.message = item->message;
|
msg.message = item->message;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3HistoryMgr::getMessages(const std::string &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount)
|
bool p3HistoryMgr::getMessages(const RsPeerId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount)
|
||||||
{
|
{
|
||||||
msgs.clear();
|
msgs.clear();
|
||||||
|
|
||||||
|
@ -379,20 +379,20 @@ bool p3HistoryMgr::getMessages(const std::string &chatPeerId, std::list<HistoryM
|
||||||
|
|
||||||
std::cerr << "Getting history for peer " << chatPeerId << std::endl;
|
std::cerr << "Getting history for peer " << chatPeerId << std::endl;
|
||||||
|
|
||||||
if (mPublicEnable == false && chatPeerId.empty()) { // chatPeerId.empty() means it's public chat
|
if (mPublicEnable == false && chatPeerId.isNull()) { // chatPeerId.empty() means it's public chat
|
||||||
// public chat not enabled
|
// public chat not enabled
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPrivateEnable == false && chatPeerId.empty() == false) // private chat not enabled
|
if (mPrivateEnable == false && chatPeerId.isNull() == false) // private chat not enabled
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (mLobbyEnable == false && chatPeerId.empty() == false) // private chat not enabled
|
if (mLobbyEnable == false && chatPeerId.isNull() == false) // private chat not enabled
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32_t foundCount = 0;
|
uint32_t foundCount = 0;
|
||||||
|
|
||||||
std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(chatPeerId);
|
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(chatPeerId);
|
||||||
|
|
||||||
if (mit != mMessages.end())
|
if (mit != mMessages.end())
|
||||||
{
|
{
|
||||||
|
@ -418,7 +418,7 @@ bool p3HistoryMgr::getMessage(uint32_t msgId, HistoryMsg &msg)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit;
|
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit;
|
||||||
for (mit = mMessages.begin(); mit != mMessages.end(); mit++) {
|
for (mit = mMessages.begin(); mit != mMessages.end(); mit++) {
|
||||||
std::map<uint32_t, RsHistoryMsgItem*>::iterator lit = mit->second.find(msgId);
|
std::map<uint32_t, RsHistoryMsgItem*>::iterator lit = mit->second.find(msgId);
|
||||||
if (lit != mit->second.end()) {
|
if (lit != mit->second.end()) {
|
||||||
|
@ -430,14 +430,14 @@ bool p3HistoryMgr::getMessage(uint32_t msgId, HistoryMsg &msg)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3HistoryMgr::clear(const std::string &chatPeerId)
|
void p3HistoryMgr::clear(const RsPeerId &chatPeerId)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::cerr << "********** p3History::clear()called for peer id " << chatPeerId << std::endl;
|
std::cerr << "********** p3History::clear()called for peer id " << chatPeerId << std::endl;
|
||||||
|
|
||||||
std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(chatPeerId);
|
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit = mMessages.find(chatPeerId);
|
||||||
if (mit == mMessages.end()) {
|
if (mit == mMessages.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -465,7 +465,7 @@ void p3HistoryMgr::removeMessages(const std::list<uint32_t> &msgIds)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit;
|
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> >::iterator mit;
|
||||||
for (mit = mMessages.begin(); mit != mMessages.end(); ++mit) {
|
for (mit = mMessages.begin(); mit != mMessages.end(); ++mit) {
|
||||||
iit = ids.begin();
|
iit = ids.begin();
|
||||||
while (iit != ids.end()) {
|
while (iit != ids.end()) {
|
||||||
|
|
|
@ -48,13 +48,13 @@ public:
|
||||||
|
|
||||||
/******** p3HistoryMgr *********/
|
/******** p3HistoryMgr *********/
|
||||||
|
|
||||||
void addMessage(bool incoming, const std::string &chatPeerId, const std::string &peerId, const RsChatMsgItem *chatItem);
|
void addMessage(bool incoming, const RsPeerId &chatPeerId, const RsPeerId &peerId, const RsChatMsgItem *chatItem);
|
||||||
|
|
||||||
/********* RsHistory ***********/
|
/********* RsHistory ***********/
|
||||||
|
|
||||||
bool getMessages(const std::string &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount);
|
bool getMessages(const RsPeerId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount);
|
||||||
bool getMessage(uint32_t msgId, HistoryMsg &msg);
|
bool getMessage(uint32_t msgId, HistoryMsg &msg);
|
||||||
void clear(const std::string &chatPeerId);
|
void clear(const RsPeerId &chatPeerId);
|
||||||
void removeMessages(const std::list<uint32_t> &msgIds);
|
void removeMessages(const std::list<uint32_t> &msgIds);
|
||||||
|
|
||||||
virtual bool getEnable(uint32_t chat_type);
|
virtual bool getEnable(uint32_t chat_type);
|
||||||
|
@ -73,7 +73,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t nextMsgId;
|
uint32_t nextMsgId;
|
||||||
std::map<std::string, std::map<uint32_t, RsHistoryMsgItem*> > mMessages;
|
std::map<RsPeerId, std::map<uint32_t, RsHistoryMsgItem*> > mMessages;
|
||||||
|
|
||||||
// Removes messages stored for more than mMaxMsgStorageDurationSeconds seconds.
|
// Removes messages stored for more than mMaxMsgStorageDurationSeconds seconds.
|
||||||
// This avoids the stored list to grow crazy with time.
|
// This avoids the stored list to grow crazy with time.
|
||||||
|
|
|
@ -33,6 +33,7 @@ extern RsHistory *rsHistory;
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include "retroshare/rstypes.h"
|
||||||
|
|
||||||
//! data object for message history
|
//! data object for message history
|
||||||
/*!
|
/*!
|
||||||
|
@ -55,9 +56,9 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint32_t msgId;
|
uint32_t msgId;
|
||||||
std::string chatPeerId;
|
RsPeerId chatPeerId;
|
||||||
bool incoming;
|
bool incoming;
|
||||||
std::string peerId;
|
RsPeerId peerId;
|
||||||
std::string peerName;
|
std::string peerName;
|
||||||
uint32_t sendTime;
|
uint32_t sendTime;
|
||||||
uint32_t recvTime;
|
uint32_t recvTime;
|
||||||
|
@ -71,10 +72,10 @@ public:
|
||||||
class RsHistory
|
class RsHistory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool getMessages(const std::string &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
|
virtual bool getMessages(const RsPeerId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
|
||||||
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0;
|
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0;
|
||||||
virtual void removeMessages(const std::list<uint32_t> &msgIds) = 0;
|
virtual void removeMessages(const std::list<uint32_t> &msgIds) = 0;
|
||||||
virtual void clear(const std::string &chatPeerId) = 0;
|
virtual void clear(const RsPeerId &chatPeerId) = 0;
|
||||||
|
|
||||||
virtual bool getEnable(uint32_t chat_type) = 0;
|
virtual bool getEnable(uint32_t chat_type) = 0;
|
||||||
virtual void setEnable(uint32_t chat_type, bool enable) = 0;
|
virtual void setEnable(uint32_t chat_type, bool enable) = 0;
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <util/rsrandom.h>
|
#include <util/rsrandom.h>
|
||||||
|
|
||||||
template<uint32_t ID_SIZE_IN_BYTES,uint32_t UNIQUE_IDENTIFIER> class t_RsGenericIdType
|
template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> class t_RsGenericIdType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
t_RsGenericIdType()
|
t_RsGenericIdType()
|
||||||
|
@ -55,9 +55,9 @@ template<uint32_t ID_SIZE_IN_BYTES,uint32_t UNIQUE_IDENTIFIER> class t_RsGeneric
|
||||||
|
|
||||||
// Random initialization. Can be useful for testing.
|
// Random initialization. Can be useful for testing.
|
||||||
//
|
//
|
||||||
static t_RsGenericIdType<ID_SIZE_IN_BYTES,UNIQUE_IDENTIFIER> random()
|
static t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER> random()
|
||||||
{
|
{
|
||||||
t_RsGenericIdType<ID_SIZE_IN_BYTES,UNIQUE_IDENTIFIER> id ;
|
t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER> id ;
|
||||||
|
|
||||||
for(uint32_t i=0;i<ID_SIZE_IN_BYTES;++i)
|
for(uint32_t i=0;i<ID_SIZE_IN_BYTES;++i)
|
||||||
id.bytes[i] = RSRandom::random_u32() & 0xff ;
|
id.bytes[i] = RSRandom::random_u32() & 0xff ;
|
||||||
|
@ -69,13 +69,12 @@ template<uint32_t ID_SIZE_IN_BYTES,uint32_t UNIQUE_IDENTIFIER> class t_RsGeneric
|
||||||
|
|
||||||
// Converts to a std::string using cached value.
|
// Converts to a std::string using cached value.
|
||||||
//
|
//
|
||||||
std::string toStdString(bool upper_case = true) const ;
|
|
||||||
const unsigned char *toByteArray() const { return &bytes[0] ; }
|
const unsigned char *toByteArray() const { return &bytes[0] ; }
|
||||||
static const uint32_t SIZE_IN_BYTES = ID_SIZE_IN_BYTES ;
|
static const uint32_t SIZE_IN_BYTES = ID_SIZE_IN_BYTES ;
|
||||||
|
|
||||||
inline bool operator==(const t_RsGenericIdType<ID_SIZE_IN_BYTES,UNIQUE_IDENTIFIER>& fp) const { return !memcmp(bytes,fp.bytes,ID_SIZE_IN_BYTES) ; }
|
inline bool operator==(const t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>& fp) const { return !memcmp(bytes,fp.bytes,ID_SIZE_IN_BYTES) ; }
|
||||||
inline bool operator!=(const t_RsGenericIdType<ID_SIZE_IN_BYTES,UNIQUE_IDENTIFIER>& fp) const { return !!memcmp(bytes,fp.bytes,ID_SIZE_IN_BYTES); }
|
inline bool operator!=(const t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>& fp) const { return !!memcmp(bytes,fp.bytes,ID_SIZE_IN_BYTES); }
|
||||||
inline bool operator< (const t_RsGenericIdType<ID_SIZE_IN_BYTES,UNIQUE_IDENTIFIER>& fp) const { return (memcmp(bytes,fp.bytes,ID_SIZE_IN_BYTES) < 0) ; }
|
inline bool operator< (const t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>& fp) const { return (memcmp(bytes,fp.bytes,ID_SIZE_IN_BYTES) < 0) ; }
|
||||||
|
|
||||||
inline bool isNull() const
|
inline bool isNull() const
|
||||||
{
|
{
|
||||||
|
@ -85,15 +84,39 @@ template<uint32_t ID_SIZE_IN_BYTES,uint32_t UNIQUE_IDENTIFIER> class t_RsGeneric
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& out,const t_RsGenericIdType<ID_SIZE_IN_BYTES,UNIQUE_IDENTIFIER>& id)
|
friend std::ostream& operator<<(std::ostream& out,const t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>& id)
|
||||||
{
|
{
|
||||||
return out << id.toStdString() ;
|
return out << id.toStdString(UPPER_CASE) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string toStdString() const { return toStdString(UPPER_CASE) ; }
|
||||||
|
|
||||||
|
inline uint32_t serial_size() const { return SIZE_IN_BYTES ; }
|
||||||
|
bool serialise(void *data,uint32_t pktsize,uint32_t& offset)
|
||||||
|
{
|
||||||
|
if(offset + SIZE_IN_BYTES >= pktsize)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
memcpy(&((uint8_t*)data)[offset],bytes,SIZE_IN_BYTES) ;
|
||||||
|
offset += SIZE_IN_BYTES ;
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
bool deserialise(void *data,uint32_t pktsize,uint32_t& offset)
|
||||||
|
{
|
||||||
|
if(offset + SIZE_IN_BYTES >= pktsize)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
memcpy(bytes,&((uint8_t*)data)[offset],SIZE_IN_BYTES) ;
|
||||||
|
offset += SIZE_IN_BYTES ;
|
||||||
|
return true ;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
std::string toStdString(bool upper_case) const ;
|
||||||
|
|
||||||
unsigned char bytes[ID_SIZE_IN_BYTES] ;
|
unsigned char bytes[ID_SIZE_IN_BYTES] ;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<uint32_t ID_SIZE_IN_BYTES,uint32_t UNIQUE_IDENTIFIER> std::string t_RsGenericIdType<ID_SIZE_IN_BYTES,UNIQUE_IDENTIFIER>::toStdString(bool upper_case) const
|
template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> std::string t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>::toStdString(bool upper_case) const
|
||||||
{
|
{
|
||||||
static const char outh[16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' } ;
|
static const char outh[16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' } ;
|
||||||
static const char outl[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' } ;
|
static const char outl[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' } ;
|
||||||
|
@ -115,7 +138,7 @@ template<uint32_t ID_SIZE_IN_BYTES,uint32_t UNIQUE_IDENTIFIER> std::string t_RsG
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<uint32_t ID_SIZE_IN_BYTES,uint32_t UNIQUE_IDENTIFIER> t_RsGenericIdType<ID_SIZE_IN_BYTES,UNIQUE_IDENTIFIER>::t_RsGenericIdType(const std::string& s)
|
template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>::t_RsGenericIdType(const std::string& s)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -149,7 +172,7 @@ template<uint32_t ID_SIZE_IN_BYTES,uint32_t UNIQUE_IDENTIFIER> t_RsGenericIdType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<uint32_t ID_SIZE_IN_BYTES,uint32_t UNIQUE_IDENTIFIER> t_RsGenericIdType<ID_SIZE_IN_BYTES,UNIQUE_IDENTIFIER>::t_RsGenericIdType(const unsigned char *mem)
|
template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>::t_RsGenericIdType(const unsigned char *mem)
|
||||||
{
|
{
|
||||||
if(mem == NULL)
|
if(mem == NULL)
|
||||||
memset(bytes,0,ID_SIZE_IN_BYTES) ;
|
memset(bytes,0,ID_SIZE_IN_BYTES) ;
|
||||||
|
@ -169,8 +192,8 @@ static const uint32_t RS_GENERIC_ID_PGP_ID_TYPE = 0x80339f4f ;
|
||||||
static const uint32_t RS_GENERIC_ID_SHA1_ID_TYPE = 0x9540284e ;
|
static const uint32_t RS_GENERIC_ID_SHA1_ID_TYPE = 0x9540284e ;
|
||||||
static const uint32_t RS_GENERIC_ID_PGP_FINGERPRINT_TYPE = 0x102943e3 ;
|
static const uint32_t RS_GENERIC_ID_PGP_FINGERPRINT_TYPE = 0x102943e3 ;
|
||||||
|
|
||||||
typedef t_RsGenericIdType< SSL_ID_SIZE , RS_GENERIC_ID_SSL_ID_TYPE> SSLIdType ;
|
typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_SSL_ID_TYPE> SSLIdType ;
|
||||||
typedef t_RsGenericIdType< PGP_KEY_ID_SIZE , RS_GENERIC_ID_PGP_ID_TYPE> PGPIdType;
|
typedef t_RsGenericIdType< PGP_KEY_ID_SIZE , true, RS_GENERIC_ID_PGP_ID_TYPE> PGPIdType;
|
||||||
typedef t_RsGenericIdType< SHA1_SIZE , RS_GENERIC_ID_SHA1_ID_TYPE> Sha1CheckSum ;
|
typedef t_RsGenericIdType< SHA1_SIZE , false, RS_GENERIC_ID_SHA1_ID_TYPE> Sha1CheckSum ;
|
||||||
typedef t_RsGenericIdType< PGP_KEY_FINGERPRINT_SIZE, RS_GENERIC_ID_PGP_FINGERPRINT_TYPE> PGPFingerprintType ;
|
typedef t_RsGenericIdType< PGP_KEY_FINGERPRINT_SIZE, true, RS_GENERIC_ID_PGP_FINGERPRINT_TYPE> PGPFingerprintType ;
|
||||||
|
|
||||||
|
|
|
@ -92,13 +92,13 @@ class MessageInfo
|
||||||
public:
|
public:
|
||||||
MessageInfo() {}
|
MessageInfo() {}
|
||||||
std::string msgId;
|
std::string msgId;
|
||||||
std::string srcId;
|
RsPeerId srcId;
|
||||||
|
|
||||||
unsigned int msgflags;
|
unsigned int msgflags;
|
||||||
|
|
||||||
std::list<std::string> msgto;
|
std::list<RsPeerId> msgto;
|
||||||
std::list<std::string> msgcc;
|
std::list<RsPeerId> msgcc;
|
||||||
std::list<std::string> msgbcc;
|
std::list<RsPeerId> msgbcc;
|
||||||
|
|
||||||
std::string title;
|
std::string title;
|
||||||
std::string msg;
|
std::string msg;
|
||||||
|
@ -119,7 +119,7 @@ class MsgInfoSummary
|
||||||
MsgInfoSummary() {}
|
MsgInfoSummary() {}
|
||||||
|
|
||||||
std::string msgId;
|
std::string msgId;
|
||||||
std::string srcId;
|
RsPeerId srcId;
|
||||||
|
|
||||||
uint32_t msgflags;
|
uint32_t msgflags;
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ public:
|
||||||
class ChatInfo
|
class ChatInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string rsid;
|
RsPeerId rsid;
|
||||||
std::string peer_nickname;
|
std::string peer_nickname;
|
||||||
unsigned int chatflags;
|
unsigned int chatflags;
|
||||||
uint32_t sendTime;
|
uint32_t sendTime;
|
||||||
|
@ -182,7 +182,7 @@ class ChatLobbyInvite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ChatLobbyId lobby_id ;
|
ChatLobbyId lobby_id ;
|
||||||
std::string peer_id ;
|
RsPeerId peer_id ;
|
||||||
std::string lobby_name ;
|
std::string lobby_name ;
|
||||||
std::string lobby_topic ;
|
std::string lobby_topic ;
|
||||||
uint32_t lobby_privacy_level ;
|
uint32_t lobby_privacy_level ;
|
||||||
|
@ -196,7 +196,7 @@ class VisibleChatLobbyRecord
|
||||||
ChatLobbyId lobby_id ; // unique id of the lobby
|
ChatLobbyId lobby_id ; // unique id of the lobby
|
||||||
std::string lobby_name ; // name to use for this lobby
|
std::string lobby_name ; // name to use for this lobby
|
||||||
std::string lobby_topic ; // topic to use for this lobby
|
std::string lobby_topic ; // topic to use for this lobby
|
||||||
std::set<std::string> participating_friends ; // list of direct friend who participate.
|
std::set<RsPeerId> participating_friends ; // list of direct friend who participate.
|
||||||
|
|
||||||
uint32_t total_number_of_peers ; // total number of particpating peers. Might not be
|
uint32_t total_number_of_peers ; // total number of particpating peers. Might not be
|
||||||
time_t last_report_time ; // last time the lobby was reported.
|
time_t last_report_time ; // last time the lobby was reported.
|
||||||
|
@ -210,7 +210,7 @@ class ChatLobbyInfo
|
||||||
ChatLobbyId lobby_id ; // unique id of the lobby
|
ChatLobbyId lobby_id ; // unique id of the lobby
|
||||||
std::string lobby_name ; // name to use for this lobby
|
std::string lobby_name ; // name to use for this lobby
|
||||||
std::string lobby_topic ; // topic to use for this lobby
|
std::string lobby_topic ; // topic to use for this lobby
|
||||||
std::set<std::string> participating_friends ; // list of direct friend who participate. Used to broadcast sent messages.
|
std::set<RsPeerId> participating_friends ; // list of direct friend who participate. Used to broadcast sent messages.
|
||||||
std::string nick_name ; // nickname to use for this lobby
|
std::string nick_name ; // nickname to use for this lobby
|
||||||
|
|
||||||
uint32_t lobby_privacy_level ; // see RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC / RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE
|
uint32_t lobby_privacy_level ; // see RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC / RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE
|
||||||
|
@ -222,7 +222,7 @@ struct DistantChatInviteInfo
|
||||||
{
|
{
|
||||||
std::string hash ; // hash to contact the invite and refer to it.
|
std::string hash ; // hash to contact the invite and refer to it.
|
||||||
std::string encrypted_radix64_string ; // encrypted radix string used to for the chat link
|
std::string encrypted_radix64_string ; // encrypted radix string used to for the chat link
|
||||||
std::string destination_pgp_id ; // pgp is of the destination of the chat link
|
PGPIdType destination_pgp_id ; // pgp is of the destination of the chat link
|
||||||
time_t time_of_validity ; // time when te invite becomes unusable
|
time_t time_of_validity ; // time when te invite becomes unusable
|
||||||
uint32_t invite_flags ; // used to keep track of wether signature was ok or not.
|
uint32_t invite_flags ; // used to keep track of wether signature was ok or not.
|
||||||
};
|
};
|
||||||
|
@ -237,7 +237,7 @@ extern RsMsgs *rsMsgs;
|
||||||
|
|
||||||
struct DistantOfflineMessengingInvite
|
struct DistantOfflineMessengingInvite
|
||||||
{
|
{
|
||||||
std::string issuer_pgp_id ;
|
PGPIdType issuer_pgp_id ;
|
||||||
std::string hash ;
|
std::string hash ;
|
||||||
time_t time_of_validity ;
|
time_t time_of_validity ;
|
||||||
};
|
};
|
||||||
|
@ -290,29 +290,29 @@ virtual bool createDistantOfflineMessengingInvite(time_t validity_time_stamp, st
|
||||||
virtual bool getDistantOfflineMessengingInvites(std::vector<DistantOfflineMessengingInvite>& invites) = 0 ;
|
virtual bool getDistantOfflineMessengingInvites(std::vector<DistantOfflineMessengingInvite>& invites) = 0 ;
|
||||||
virtual void enableDistantMessaging(bool b) = 0;
|
virtual void enableDistantMessaging(bool b) = 0;
|
||||||
virtual bool distantMessagingEnabled() = 0;
|
virtual bool distantMessagingEnabled() = 0;
|
||||||
virtual bool getDistantMessageHash(const std::string& pgp_id, std::string& hash) = 0;
|
virtual bool getDistantMessageHash(const PGPIdType& pgp_id, std::string& hash) = 0;
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Chat */
|
/* Chat */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
virtual bool sendPublicChat(const std::string& msg) = 0;
|
virtual bool sendPublicChat(const std::string& msg) = 0;
|
||||||
virtual bool sendPrivateChat(const std::string& id, const std::string& msg) = 0;
|
virtual bool sendPrivateChat(const RsPeerId& id, const std::string& msg) = 0;
|
||||||
virtual int getPublicChatQueueCount() = 0;
|
virtual int getPublicChatQueueCount() = 0;
|
||||||
virtual bool getPublicChatQueue(std::list<ChatInfo> &chats) = 0;
|
virtual bool getPublicChatQueue(std::list<ChatInfo> &chats) = 0;
|
||||||
virtual int getPrivateChatQueueCount(bool incoming) = 0;
|
virtual int getPrivateChatQueueCount(bool incoming) = 0;
|
||||||
virtual bool getPrivateChatQueueIds(bool incoming, std::list<std::string> &ids) = 0;
|
virtual bool getPrivateChatQueueIds(bool incoming, std::list<RsPeerId> &ids) = 0;
|
||||||
virtual bool getPrivateChatQueue(bool incoming, const std::string& id, std::list<ChatInfo> &chats) = 0;
|
virtual bool getPrivateChatQueue(bool incoming, const RsPeerId& id, std::list<ChatInfo> &chats) = 0;
|
||||||
virtual bool clearPrivateChatQueue(bool incoming, const std::string& id) = 0;
|
virtual bool clearPrivateChatQueue(bool incoming, const RsPeerId& id) = 0;
|
||||||
|
|
||||||
virtual void sendStatusString(const std::string& id,const std::string& status_string) = 0 ;
|
virtual void sendStatusString(const RsPeerId& id,const std::string& status_string) = 0 ;
|
||||||
virtual void sendGroupChatStatusString(const std::string& status_string) = 0 ;
|
virtual void sendGroupChatStatusString(const std::string& status_string) = 0 ;
|
||||||
|
|
||||||
virtual void setCustomStateString(const std::string& status_string) = 0 ;
|
virtual void setCustomStateString(const std::string& status_string) = 0 ;
|
||||||
virtual std::string getCustomStateString() = 0 ;
|
virtual std::string getCustomStateString() = 0 ;
|
||||||
virtual std::string getCustomStateString(const std::string& peer_id) = 0 ;
|
virtual std::string getCustomStateString(const RsPeerId& peer_id) = 0 ;
|
||||||
|
|
||||||
// get avatar data for peer pid
|
// get avatar data for peer pid
|
||||||
virtual void getAvatarData(const std::string& pid,unsigned char *& data,int& size) = 0 ;
|
virtual void getAvatarData(const RsPeerId& pid,unsigned char *& data,int& size) = 0 ;
|
||||||
// set own avatar data
|
// set own avatar data
|
||||||
virtual void setOwnAvatarData(const unsigned char *data,int size) = 0 ;
|
virtual void setOwnAvatarData(const unsigned char *data,int size) = 0 ;
|
||||||
virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;
|
virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;
|
||||||
|
@ -322,11 +322,11 @@ virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
|
||||||
virtual bool joinVisibleChatLobby(const ChatLobbyId& lobby_id) = 0 ;
|
virtual bool joinVisibleChatLobby(const ChatLobbyId& lobby_id) = 0 ;
|
||||||
virtual bool isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lobby_id) = 0;
|
virtual bool isLobbyId(const RsPeerId& virtual_peer_id,ChatLobbyId& lobby_id) = 0;
|
||||||
virtual bool getVirtualPeerId(const ChatLobbyId& lobby_id,std::string& vpid) = 0;
|
virtual bool getVirtualPeerId(const ChatLobbyId& lobby_id,RsPeerId& vpid) = 0;
|
||||||
virtual void getChatLobbyList(std::list<ChatLobbyInfo>& cl_info) = 0;
|
virtual void getChatLobbyList(std::list<ChatLobbyInfo>& cl_info) = 0;
|
||||||
virtual void getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& public_lobbies) = 0 ;
|
virtual void getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& public_lobbies) = 0 ;
|
||||||
virtual void invitePeerToLobby(const ChatLobbyId& lobby_id,const std::string& peer_id) = 0;
|
virtual void invitePeerToLobby(const ChatLobbyId& lobby_id,const RsPeerId& peer_id) = 0;
|
||||||
virtual bool acceptLobbyInvite(const ChatLobbyId& id) = 0 ;
|
virtual bool acceptLobbyInvite(const ChatLobbyId& id) = 0 ;
|
||||||
virtual void denyLobbyInvite(const ChatLobbyId& id) = 0 ;
|
virtual void denyLobbyInvite(const ChatLobbyId& id) = 0 ;
|
||||||
virtual void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) = 0;
|
virtual void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) = 0;
|
||||||
|
@ -337,17 +337,17 @@ virtual bool setDefaultNickNameForChatLobby(const std::string& nick) = 0;
|
||||||
virtual bool getDefaultNickNameForChatLobby(std::string& nick) = 0 ;
|
virtual bool getDefaultNickNameForChatLobby(std::string& nick) = 0 ;
|
||||||
virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe) = 0 ;
|
virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe) = 0 ;
|
||||||
virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id) = 0 ;
|
virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id) = 0 ;
|
||||||
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<std::string>& invited_friends,uint32_t lobby_privacy_type) = 0 ;
|
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,uint32_t lobby_privacy_type) = 0 ;
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* Distant chat */
|
/* Distant chat */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
|
||||||
virtual bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string) = 0 ;
|
virtual bool createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& encrypted_string) = 0 ;
|
||||||
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
|
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
|
||||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,std::string& hash,uint32_t& error_code) = 0;
|
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,std::string& hash,uint32_t& error_code) = 0;
|
||||||
virtual bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) = 0;
|
virtual bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) = 0;
|
||||||
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) = 0;
|
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,PGPIdType& pgp_id) = 0;
|
||||||
virtual bool closeDistantChatConnexion(const std::string& hash) = 0;
|
virtual bool closeDistantChatConnexion(const std::string& hash) = 0;
|
||||||
virtual bool removeDistantChatInvite(const std::string& hash) = 0 ;
|
virtual bool removeDistantChatInvite(const std::string& hash) = 0 ;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ uint32_t p3History::getMaxStorageDuration()
|
||||||
{
|
{
|
||||||
return mHistoryMgr->getMaxStorageDuration() ;
|
return mHistoryMgr->getMaxStorageDuration() ;
|
||||||
}
|
}
|
||||||
bool p3History::getMessages(const std::string &chatPeerId, std::list<HistoryMsg> &msgs, const uint32_t loadCount)
|
bool p3History::getMessages(const RsPeerId &chatPeerId, std::list<HistoryMsg> &msgs, const uint32_t loadCount)
|
||||||
{
|
{
|
||||||
return mHistoryMgr->getMessages(chatPeerId, msgs, loadCount);
|
return mHistoryMgr->getMessages(chatPeerId, msgs, loadCount);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ void p3History::removeMessages(const std::list<uint32_t> &msgIds)
|
||||||
mHistoryMgr->removeMessages(msgIds);
|
mHistoryMgr->removeMessages(msgIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3History::clear(const std::string &chatPeerId)
|
void p3History::clear(const RsPeerId &chatPeerId)
|
||||||
{
|
{
|
||||||
mHistoryMgr->clear(chatPeerId);
|
mHistoryMgr->clear(chatPeerId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,10 @@ public:
|
||||||
p3History(p3HistoryMgr* historyMgr);
|
p3History(p3HistoryMgr* historyMgr);
|
||||||
virtual ~p3History();
|
virtual ~p3History();
|
||||||
|
|
||||||
virtual bool getMessages(const std::string &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount);
|
virtual bool getMessages(const RsPeerId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount);
|
||||||
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg);
|
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg);
|
||||||
virtual void removeMessages(const std::list<uint32_t> &msgIds);
|
virtual void removeMessages(const std::list<uint32_t> &msgIds);
|
||||||
virtual void clear(const std::string &chatPeerId);
|
virtual void clear(const RsPeerId &chatPeerId);
|
||||||
virtual bool getEnable(uint32_t chat_type);
|
virtual bool getEnable(uint32_t chat_type);
|
||||||
virtual void setEnable(uint32_t chat_type, bool enable);
|
virtual void setEnable(uint32_t chat_type, bool enable);
|
||||||
virtual uint32_t getSaveCount(uint32_t chat_type);
|
virtual uint32_t getSaveCount(uint32_t chat_type);
|
||||||
|
|
|
@ -116,7 +116,7 @@ bool p3Msgs::distantMessagingEnabled()
|
||||||
{
|
{
|
||||||
return mMsgSrv->distantMessagingEnabled();
|
return mMsgSrv->distantMessagingEnabled();
|
||||||
}
|
}
|
||||||
bool p3Msgs::getDistantMessageHash(const std::string& pgp_id,std::string& hash)
|
bool p3Msgs::getDistantMessageHash(const PGPIdType& pgp_id,std::string& hash)
|
||||||
{
|
{
|
||||||
return mMsgSrv->getDistantMessageHash(pgp_id,hash);
|
return mMsgSrv->getDistantMessageHash(pgp_id,hash);
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ bool p3Msgs::sendPublicChat(const std::string& msg)
|
||||||
return mChatSrv -> sendPublicChat(msg);
|
return mChatSrv -> sendPublicChat(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Msgs::sendPrivateChat(const std::string& id, const std::string& msg)
|
bool p3Msgs::sendPrivateChat(const RsPeerId& id, const std::string& msg)
|
||||||
{
|
{
|
||||||
/* send a message to peer */
|
/* send a message to peer */
|
||||||
return mChatSrv -> sendPrivateChat(id, msg);
|
return mChatSrv -> sendPrivateChat(id, msg);
|
||||||
|
@ -229,7 +229,7 @@ void p3Msgs::sendGroupChatStatusString(const std::string& status_string)
|
||||||
mChatSrv->sendGroupChatStatusString(status_string);
|
mChatSrv->sendGroupChatStatusString(status_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3Msgs::sendStatusString(const std::string& peer_id, const std::string& status_string)
|
void p3Msgs::sendStatusString(const RsPeerId& peer_id, const std::string& status_string)
|
||||||
{
|
{
|
||||||
mChatSrv->sendStatusString(peer_id, status_string);
|
mChatSrv->sendStatusString(peer_id, status_string);
|
||||||
}
|
}
|
||||||
|
@ -249,17 +249,17 @@ int p3Msgs::getPrivateChatQueueCount(bool incoming)
|
||||||
return mChatSrv->getPrivateChatQueueCount(incoming);
|
return mChatSrv->getPrivateChatQueueCount(incoming);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Msgs::getPrivateChatQueueIds(bool incoming, std::list<std::string> &ids)
|
bool p3Msgs::getPrivateChatQueueIds(bool incoming, std::list<RsPeerId> &ids)
|
||||||
{
|
{
|
||||||
return mChatSrv->getPrivateChatQueueIds(incoming, ids);
|
return mChatSrv->getPrivateChatQueueIds(incoming, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Msgs::getPrivateChatQueue(bool incoming, const std::string& id, std::list<ChatInfo> &chats)
|
bool p3Msgs::getPrivateChatQueue(bool incoming, const RsPeerId& id, std::list<ChatInfo> &chats)
|
||||||
{
|
{
|
||||||
return mChatSrv->getPrivateChatQueue(incoming, id, chats);
|
return mChatSrv->getPrivateChatQueue(incoming, id, chats);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Msgs::clearPrivateChatQueue(bool incoming, const std::string& id)
|
bool p3Msgs::clearPrivateChatQueue(bool incoming, const RsPeerId& id)
|
||||||
{
|
{
|
||||||
return mChatSrv->clearPrivateChatQueue(incoming, id);
|
return mChatSrv->clearPrivateChatQueue(incoming, id);
|
||||||
}
|
}
|
||||||
|
@ -274,12 +274,12 @@ void p3Msgs::setOwnAvatarData(const unsigned char *data,int size)
|
||||||
mChatSrv->setOwnAvatarJpegData(data,size) ;
|
mChatSrv->setOwnAvatarJpegData(data,size) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3Msgs::getAvatarData(const std::string& pid,unsigned char *& data,int& size)
|
void p3Msgs::getAvatarData(const RsPeerId& pid,unsigned char *& data,int& size)
|
||||||
{
|
{
|
||||||
mChatSrv->getAvatarJpegData(pid,data,size) ;
|
mChatSrv->getAvatarJpegData(pid,data,size) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string p3Msgs::getCustomStateString(const std::string& peer_id)
|
std::string p3Msgs::getCustomStateString(const RsPeerId& peer_id)
|
||||||
{
|
{
|
||||||
return mChatSrv->getCustomStateString(peer_id) ;
|
return mChatSrv->getCustomStateString(peer_id) ;
|
||||||
}
|
}
|
||||||
|
@ -294,11 +294,11 @@ void p3Msgs::setCustomStateString(const std::string& state_string)
|
||||||
mChatSrv->setOwnCustomStateString(state_string) ;
|
mChatSrv->setOwnCustomStateString(state_string) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Msgs::getVirtualPeerId(const ChatLobbyId& id,std::string& peer_id)
|
bool p3Msgs::getVirtualPeerId(const ChatLobbyId& id,RsPeerId& peer_id)
|
||||||
{
|
{
|
||||||
return mChatSrv->getVirtualPeerId(id,peer_id) ;
|
return mChatSrv->getVirtualPeerId(id,peer_id) ;
|
||||||
}
|
}
|
||||||
bool p3Msgs::isLobbyId(const std::string& peer_id,ChatLobbyId& id)
|
bool p3Msgs::isLobbyId(const RsPeerId& peer_id,ChatLobbyId& id)
|
||||||
{
|
{
|
||||||
return mChatSrv->isLobbyId(peer_id,id) ;
|
return mChatSrv->isLobbyId(peer_id,id) ;
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ void p3Msgs::getChatLobbyList(std::list<ChatLobbyInfo>& linfos)
|
||||||
{
|
{
|
||||||
mChatSrv->getChatLobbyList(linfos) ;
|
mChatSrv->getChatLobbyList(linfos) ;
|
||||||
}
|
}
|
||||||
void p3Msgs::invitePeerToLobby(const ChatLobbyId& lobby_id, const std::string& peer_id)
|
void p3Msgs::invitePeerToLobby(const ChatLobbyId& lobby_id, const RsPeerId& peer_id)
|
||||||
{
|
{
|
||||||
mChatSrv->invitePeerToLobby(lobby_id,peer_id) ;
|
mChatSrv->invitePeerToLobby(lobby_id,peer_id) ;
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ void p3Msgs::getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& pub
|
||||||
mChatSrv->getListOfNearbyChatLobbies(public_lobbies) ;
|
mChatSrv->getListOfNearbyChatLobbies(public_lobbies) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatLobbyId p3Msgs::createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<std::string>& invited_friends,uint32_t privacy_type)
|
ChatLobbyId p3Msgs::createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,uint32_t privacy_type)
|
||||||
{
|
{
|
||||||
return mChatSrv->createChatLobby(lobby_name,lobby_topic,invited_friends,privacy_type) ;
|
return mChatSrv->createChatLobby(lobby_name,lobby_topic,invited_friends,privacy_type) ;
|
||||||
}
|
}
|
||||||
|
@ -371,7 +371,7 @@ void p3Msgs::getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites)
|
||||||
{
|
{
|
||||||
mChatSrv->getPendingChatLobbyInvites(invites) ;
|
mChatSrv->getPendingChatLobbyInvites(invites) ;
|
||||||
}
|
}
|
||||||
bool p3Msgs::createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string)
|
bool p3Msgs::createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& encrypted_string)
|
||||||
{
|
{
|
||||||
return mChatSrv->createDistantChatInvite(pgp_id,time_of_validity,encrypted_string) ;
|
return mChatSrv->createDistantChatInvite(pgp_id,time_of_validity,encrypted_string) ;
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,7 @@ bool p3Msgs::initiateDistantChatConnexion(const std::string& hash,uint32_t& erro
|
||||||
{
|
{
|
||||||
return mChatSrv->initiateDistantChatConnexion(hash,error_code) ;
|
return mChatSrv->initiateDistantChatConnexion(hash,error_code) ;
|
||||||
}
|
}
|
||||||
bool p3Msgs::getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id)
|
bool p3Msgs::getDistantChatStatus(const std::string& hash,uint32_t& status,PGPIdType& pgp_id)
|
||||||
{
|
{
|
||||||
return mChatSrv->getDistantChatStatus(hash,status,pgp_id) ;
|
return mChatSrv->getDistantChatStatus(hash,status,pgp_id) ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,12 +85,12 @@ class p3Msgs: public RsMsgs
|
||||||
|
|
||||||
virtual void enableDistantMessaging(bool b) ;
|
virtual void enableDistantMessaging(bool b) ;
|
||||||
virtual bool distantMessagingEnabled() ;
|
virtual bool distantMessagingEnabled() ;
|
||||||
virtual bool getDistantMessageHash(const std::string& pgp_id,std::string& hash) ;
|
virtual bool getDistantMessageHash(const PGPIdType& pgp_id,std::string& hash) ;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* gets avatar from peer, image data in jpeg format
|
* gets avatar from peer, image data in jpeg format
|
||||||
*/
|
*/
|
||||||
virtual void getAvatarData(const std::string& pid,unsigned char *& data,int& size);
|
virtual void getAvatarData(const RsPeerId& pid,unsigned char *& data,int& size);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* sets clients avatar, image data should be in jpeg format
|
* sets clients avatar, image data should be in jpeg format
|
||||||
|
@ -115,7 +115,7 @@ class p3Msgs: public RsMsgs
|
||||||
/*!
|
/*!
|
||||||
* retrieves peer's custom status
|
* retrieves peer's custom status
|
||||||
*/
|
*/
|
||||||
virtual std::string getCustomStateString(const std::string& peer_id) ;
|
virtual std::string getCustomStateString(const RsPeerId& peer_id) ;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -127,7 +127,7 @@ class p3Msgs: public RsMsgs
|
||||||
* chat is sent to specifc peer
|
* chat is sent to specifc peer
|
||||||
* @param id peer to send chat msg to
|
* @param id peer to send chat msg to
|
||||||
*/
|
*/
|
||||||
virtual bool sendPrivateChat(const std::string& id, const std::string& msg);
|
virtual bool sendPrivateChat(const RsPeerId& id, const std::string& msg);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* returns the count of messages in public or private queue
|
* returns the count of messages in public or private queue
|
||||||
|
@ -149,24 +149,24 @@ class p3Msgs: public RsMsgs
|
||||||
/*!
|
/*!
|
||||||
* @param id's of available private chat messages
|
* @param id's of available private chat messages
|
||||||
*/
|
*/
|
||||||
virtual bool getPrivateChatQueueIds(bool incoming, std::list<std::string> &ids);
|
virtual bool getPrivateChatQueueIds(bool incoming, std::list<RsPeerId> &ids);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @param chats ref to list of received private chats is stored here
|
* @param chats ref to list of received private chats is stored here
|
||||||
*/
|
*/
|
||||||
virtual bool getPrivateChatQueue(bool incoming, const std::string& id, std::list<ChatInfo> &chats);
|
virtual bool getPrivateChatQueue(bool incoming, const RsPeerId& id, std::list<ChatInfo> &chats);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @param clear private chat queue
|
* @param clear private chat queue
|
||||||
*/
|
*/
|
||||||
virtual bool clearPrivateChatQueue(bool incoming, const std::string& id);
|
virtual bool clearPrivateChatQueue(bool incoming, const RsPeerId& id);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* sends immediate status string to a specific peer, e.g. in a private chat
|
* sends immediate status string to a specific peer, e.g. in a private chat
|
||||||
* @param peer_id peer to send status string to
|
* @param peer_id peer to send status string to
|
||||||
* @param status_string immediate status to send
|
* @param status_string immediate status to send
|
||||||
*/
|
*/
|
||||||
virtual void sendStatusString(const std::string& peer_id, const std::string& status_string) ;
|
virtual void sendStatusString(const RsPeerId& peer_id, const std::string& status_string) ;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* sends immediate status to all peers
|
* sends immediate status to all peers
|
||||||
|
@ -178,10 +178,10 @@ class p3Msgs: public RsMsgs
|
||||||
|
|
||||||
virtual bool joinVisibleChatLobby(const ChatLobbyId& id) ;
|
virtual bool joinVisibleChatLobby(const ChatLobbyId& id) ;
|
||||||
virtual void getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& public_lobbies) ;
|
virtual void getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& public_lobbies) ;
|
||||||
virtual bool getVirtualPeerId(const ChatLobbyId& id,std::string& vpid) ;
|
virtual bool getVirtualPeerId(const ChatLobbyId& id,RsPeerId& vpid) ;
|
||||||
virtual bool isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lobby_id) ;
|
virtual bool isLobbyId(const RsPeerId& virtual_peer_id,ChatLobbyId& lobby_id) ;
|
||||||
virtual void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >&) ;
|
virtual void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >&) ;
|
||||||
virtual void invitePeerToLobby(const ChatLobbyId&, const std::string&) ;
|
virtual void invitePeerToLobby(const ChatLobbyId&, const RsPeerId&) ;
|
||||||
virtual bool acceptLobbyInvite(const ChatLobbyId& id) ;
|
virtual bool acceptLobbyInvite(const ChatLobbyId& id) ;
|
||||||
virtual void denyLobbyInvite(const ChatLobbyId& id) ;
|
virtual void denyLobbyInvite(const ChatLobbyId& id) ;
|
||||||
virtual void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;
|
virtual void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;
|
||||||
|
@ -192,13 +192,13 @@ class p3Msgs: public RsMsgs
|
||||||
virtual bool getDefaultNickNameForChatLobby(std::string& nick) ;
|
virtual bool getDefaultNickNameForChatLobby(std::string& nick) ;
|
||||||
virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe);
|
virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe);
|
||||||
virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id);
|
virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id);
|
||||||
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<std::string>& invited_friends,uint32_t privacy_type) ;
|
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,uint32_t privacy_type) ;
|
||||||
|
|
||||||
virtual bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string) ;
|
virtual bool createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& encrypted_string) ;
|
||||||
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
|
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
|
||||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,std::string& hash,uint32_t& error_code) ;
|
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,std::string& hash,uint32_t& error_code) ;
|
||||||
virtual bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) ;
|
virtual bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) ;
|
||||||
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) ;
|
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,PGPIdType& pgp_id) ;
|
||||||
virtual bool closeDistantChatConnexion(const std::string& hash) ;
|
virtual bool closeDistantChatConnexion(const std::string& hash) ;
|
||||||
virtual bool removeDistantChatInvite(const std::string& hash) ;
|
virtual bool removeDistantChatInvite(const std::string& hash) ;
|
||||||
|
|
||||||
|
|
|
@ -1184,7 +1184,7 @@ std::ostream &RsPeerGroupItem::print(std::ostream &out, uint16_t indent)
|
||||||
printIndent(out, int_Indent);
|
printIndent(out, int_Indent);
|
||||||
out << "groupFlag: " << flag << std::endl;
|
out << "groupFlag: " << flag << std::endl;
|
||||||
|
|
||||||
std::list<std::string>::iterator it;
|
std::list<PGPIdType>::iterator it;
|
||||||
for (it = peerIds.begin(); it != peerIds.end(); it++) {
|
for (it = peerIds.begin(); it != peerIds.end(); it++) {
|
||||||
printIndent(out, int_Indent);
|
printIndent(out, int_Indent);
|
||||||
out << "peerId: " << *it << std::endl;
|
out << "peerId: " << *it << std::endl;
|
||||||
|
@ -1222,9 +1222,9 @@ uint32_t RsPeerConfigSerialiser::sizeGroup(RsPeerGroupItem *i)
|
||||||
s += GetTlvStringSize(i->name);
|
s += GetTlvStringSize(i->name);
|
||||||
s += 4; /* flag */
|
s += 4; /* flag */
|
||||||
|
|
||||||
std::list<std::string>::iterator it;
|
std::list<PGPIdType>::iterator it;
|
||||||
for (it = i->peerIds.begin(); it != i->peerIds.end(); it++) {
|
for (it = i->peerIds.begin(); it != i->peerIds.end(); it++) {
|
||||||
s += GetTlvStringSize(*it);
|
s += PGPIdType::SIZE_IN_BYTES ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
@ -1260,9 +1260,9 @@ bool RsPeerConfigSerialiser::serialiseGroup(RsPeerGroupItem *item, void *data, u
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->flag);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->flag);
|
||||||
|
|
||||||
std::list<std::string>::iterator it;
|
std::list<PGPIdType>::iterator it;
|
||||||
for (it = item->peerIds.begin(); it != item->peerIds.end(); it++) {
|
for (it = item->peerIds.begin(); it != item->peerIds.end(); it++) {
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, *it);
|
ok &= setRawPGPId(data, tlvsize, &offset, *it);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(offset != tlvsize)
|
if(offset != tlvsize)
|
||||||
|
@ -1313,11 +1313,10 @@ RsPeerGroupItem *RsPeerConfigSerialiser::deserialiseGroup(void *data, uint32_t *
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
|
||||||
|
|
||||||
std::string peerId;
|
PGPIdType peerId;
|
||||||
while (offset != rssize) {
|
while (offset != rssize)
|
||||||
peerId.erase();
|
{
|
||||||
|
ok &= getRawPGPId(data, rssize, &offset, peerId);
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, peerId);
|
|
||||||
|
|
||||||
item->peerIds.push_back(peerId);
|
item->peerIds.push_back(peerId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,9 +104,9 @@ uint32_t RsHistorySerialiser::sizeHistoryMsgItem(RsHistoryMsgItem* item)
|
||||||
{
|
{
|
||||||
uint32_t s = 8; /* header */
|
uint32_t s = 8; /* header */
|
||||||
s += 2; /* version */
|
s += 2; /* version */
|
||||||
s += GetTlvStringSize(item->chatPeerId);
|
s += item->chatPeerId.serial_size();
|
||||||
s += 1; /* incoming */
|
s += 1; /* incoming */
|
||||||
s += GetTlvStringSize(item->peerId);
|
s += item->peerId.serial_size();
|
||||||
s += GetTlvStringSize(item->peerName);
|
s += GetTlvStringSize(item->peerName);
|
||||||
s += 4; /* sendTime */
|
s += 4; /* sendTime */
|
||||||
s += 4; /* recvTime */
|
s += 4; /* recvTime */
|
||||||
|
@ -140,10 +140,10 @@ bool RsHistorySerialiser::serialiseHistoryMsgItem(RsHistoryMsgItem* item, void*
|
||||||
|
|
||||||
/* add mandatory parts first */
|
/* add mandatory parts first */
|
||||||
ok &= setRawUInt16(data, tlvsize, &offset, 0); // version
|
ok &= setRawUInt16(data, tlvsize, &offset, 0); // version
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LOCATION, item->chatPeerId);
|
ok &= item->chatPeerId.serialise(data, tlvsize, offset) ;
|
||||||
uint8_t dummy = item->incoming ? 1 : 0;
|
uint8_t dummy = item->incoming ? 1 : 0;
|
||||||
ok &= setRawUInt8(data, tlvsize, &offset, dummy);
|
ok &= setRawUInt8(data, tlvsize, &offset, dummy);
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, item->peerId);
|
ok &= item->peerId.serialise(data, tlvsize, offset) ;
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->peerName);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->peerName);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->sendTime);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->sendTime);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, item->recvTime);
|
ok &= setRawUInt32(data, tlvsize, &offset, item->recvTime);
|
||||||
|
@ -194,11 +194,11 @@ RsHistoryMsgItem *RsHistorySerialiser::deserialiseHistoryMsgItem(void *data, uin
|
||||||
/* get mandatory parts first */
|
/* get mandatory parts first */
|
||||||
uint16_t version = 0;
|
uint16_t version = 0;
|
||||||
ok &= getRawUInt16(data, rssize, &offset, &version);
|
ok &= getRawUInt16(data, rssize, &offset, &version);
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LOCATION, item->chatPeerId);
|
ok &= item->chatPeerId.deserialise(data, rssize, offset) ;
|
||||||
uint8_t dummy;
|
uint8_t dummy;
|
||||||
ok &= getRawUInt8(data, rssize, &offset, &dummy);
|
ok &= getRawUInt8(data, rssize, &offset, &dummy);
|
||||||
item->incoming = (dummy == 1);
|
item->incoming = (dummy == 1);
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, item->peerId);
|
ok &= item->peerId.deserialise(data, rssize, offset) ;
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->peerName);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->peerName);
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->sendTime));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->sendTime));
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->recvTime));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->recvTime));
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "serialiser/rsserviceids.h"
|
#include "serialiser/rsserviceids.h"
|
||||||
#include "serialiser/rsserial.h"
|
#include "serialiser/rsserial.h"
|
||||||
|
#include "retroshare/rstypes.h"
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
|
@ -40,9 +41,9 @@ public:
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||||
|
|
||||||
std::string chatPeerId; // empty for global chat
|
RsPeerId chatPeerId; // empty for global chat
|
||||||
bool incoming;
|
bool incoming;
|
||||||
std::string peerId;
|
RsPeerId peerId;
|
||||||
std::string peerName;
|
std::string peerName;
|
||||||
uint32_t sendTime;
|
uint32_t sendTime;
|
||||||
uint32_t recvTime;
|
uint32_t recvTime;
|
||||||
|
|
|
@ -418,7 +418,7 @@ uint32_t RsPrivateChatMsgConfigItem::serial_size()
|
||||||
{
|
{
|
||||||
uint32_t s = 8; /* header */
|
uint32_t s = 8; /* header */
|
||||||
s += 4; /* version */
|
s += 4; /* version */
|
||||||
s += GetTlvStringSize(configPeerId);
|
s += configPeerId.serial_size();
|
||||||
s += 4; /* chatFlags */
|
s += 4; /* chatFlags */
|
||||||
s += 4; /* configFlags */
|
s += 4; /* configFlags */
|
||||||
s += 4; /* sendTime */
|
s += 4; /* sendTime */
|
||||||
|
@ -432,7 +432,7 @@ uint32_t RsPrivateChatDistantInviteConfigItem::serial_size()
|
||||||
uint32_t s = 8; /* header */
|
uint32_t s = 8; /* header */
|
||||||
s += GetTlvStringSize(hash);
|
s += GetTlvStringSize(hash);
|
||||||
s += GetTlvStringSize(encrypted_radix64_string);
|
s += GetTlvStringSize(encrypted_radix64_string);
|
||||||
s += GetTlvStringSize(destination_pgp_id);
|
s += destination_pgp_id.serial_size();
|
||||||
s += 16; /* aes_key */
|
s += 16; /* aes_key */
|
||||||
s += 4; /* time_of_validity */
|
s += 4; /* time_of_validity */
|
||||||
s += 4; /* last_hit_time */
|
s += 4; /* last_hit_time */
|
||||||
|
@ -807,7 +807,7 @@ bool RsPrivateChatMsgConfigItem::serialise(void *data, uint32_t& pktsize)
|
||||||
|
|
||||||
/* add mandatory parts first */
|
/* add mandatory parts first */
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, 0);
|
ok &= setRawUInt32(data, tlvsize, &offset, 0);
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, configPeerId);
|
ok &= configPeerId.serialise(data, tlvsize, offset) ;
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, chatFlags);
|
ok &= setRawUInt32(data, tlvsize, &offset, chatFlags);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, configFlags);
|
ok &= setRawUInt32(data, tlvsize, &offset, configFlags);
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, sendTime);
|
ok &= setRawUInt32(data, tlvsize, &offset, sendTime);
|
||||||
|
@ -847,7 +847,7 @@ bool RsPrivateChatDistantInviteConfigItem::serialise(void *data, uint32_t& pktsi
|
||||||
/* add mandatory parts first */
|
/* add mandatory parts first */
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_KEY, hash);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_KEY, hash);
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, encrypted_radix64_string);
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, encrypted_radix64_string);
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GPGID, destination_pgp_id);
|
ok &= destination_pgp_id.serialise(data, tlvsize, offset);
|
||||||
|
|
||||||
memcpy(&((unsigned char *)data)[offset],aes_key,16) ;
|
memcpy(&((unsigned char *)data)[offset],aes_key,16) ;
|
||||||
offset += 16 ;
|
offset += 16 ;
|
||||||
|
@ -1229,7 +1229,7 @@ RsPrivateChatMsgConfigItem::RsPrivateChatMsgConfigItem(void *data,uint32_t /*siz
|
||||||
/* get mandatory parts first */
|
/* get mandatory parts first */
|
||||||
uint32_t version = 0;
|
uint32_t version = 0;
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &version);
|
ok &= getRawUInt32(data, rssize, &offset, &version);
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, configPeerId);
|
ok &= configPeerId.deserialise(data, rssize, offset);
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &chatFlags);
|
ok &= getRawUInt32(data, rssize, &offset, &chatFlags);
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &configFlags);
|
ok &= getRawUInt32(data, rssize, &offset, &configFlags);
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &sendTime);
|
ok &= getRawUInt32(data, rssize, &offset, &sendTime);
|
||||||
|
@ -1254,7 +1254,7 @@ RsPrivateChatDistantInviteConfigItem::RsPrivateChatDistantInviteConfigItem(void
|
||||||
/* get mandatory parts first */
|
/* get mandatory parts first */
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_KEY, hash);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_KEY, hash);
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, encrypted_radix64_string);
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, encrypted_radix64_string);
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GPGID, destination_pgp_id);
|
ok &= destination_pgp_id.serialise(data, rssize, offset);
|
||||||
|
|
||||||
memcpy(aes_key,&((unsigned char*)data)[offset],16) ;
|
memcpy(aes_key,&((unsigned char*)data)[offset],16) ;
|
||||||
offset += 16 ;
|
offset += 16 ;
|
||||||
|
@ -1296,7 +1296,7 @@ RsChatLobbyConfigItem::RsChatLobbyConfigItem(void *data,uint32_t /*size*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set data from RsChatMsgItem to RsPrivateChatMsgConfigItem */
|
/* set data from RsChatMsgItem to RsPrivateChatMsgConfigItem */
|
||||||
void RsPrivateChatMsgConfigItem::set(RsChatMsgItem *ci, const std::string &/*peerId*/, uint32_t confFlags)
|
void RsPrivateChatMsgConfigItem::set(RsChatMsgItem *ci, const RsPeerId& /*peerId*/, uint32_t confFlags)
|
||||||
{
|
{
|
||||||
PeerId(ci->PeerId());
|
PeerId(ci->PeerId());
|
||||||
configPeerId = ci->PeerId();
|
configPeerId = ci->PeerId();
|
||||||
|
@ -1982,7 +1982,7 @@ uint32_t RsMsgSrcId::serial_size(bool)
|
||||||
uint32_t s = 8; /* header */
|
uint32_t s = 8; /* header */
|
||||||
|
|
||||||
s += 4;
|
s += 4;
|
||||||
s += GetTlvStringSize(srcId);
|
s += srcId.serial_size() ;
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -2011,7 +2011,7 @@ bool RsMsgSrcId::serialise(void *data, uint32_t& pktsize,bool config)
|
||||||
offset += 8;
|
offset += 8;
|
||||||
|
|
||||||
ok &= setRawUInt32(data, tlvsize, &offset, msgId);
|
ok &= setRawUInt32(data, tlvsize, &offset, msgId);
|
||||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, srcId);
|
ok &= srcId.serialise(data, tlvsize, offset) ;
|
||||||
|
|
||||||
if (offset != tlvsize)
|
if (offset != tlvsize)
|
||||||
{
|
{
|
||||||
|
@ -2056,7 +2056,7 @@ RsMsgSrcId* RsMsgSerialiser::deserialiseMsgSrcIdItem(void* data, uint32_t* pktsi
|
||||||
|
|
||||||
/* get mandatory parts first */
|
/* get mandatory parts first */
|
||||||
ok &= getRawUInt32(data, rssize, &offset, &(item->msgId));
|
ok &= getRawUInt32(data, rssize, &offset, &(item->msgId));
|
||||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, item->srcId);
|
ok &= item->srcId.deserialise(data, rssize, offset);
|
||||||
|
|
||||||
if (offset != rssize)
|
if (offset != rssize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include "retroshare/rstypes.h"
|
||||||
#include "serialiser/rsserviceids.h"
|
#include "serialiser/rsserviceids.h"
|
||||||
#include "serialiser/rsserial.h"
|
#include "serialiser/rsserial.h"
|
||||||
#include "serialiser/rstlvtypes.h"
|
#include "serialiser/rstlvtypes.h"
|
||||||
|
@ -308,11 +309,11 @@ class RsPrivateChatMsgConfigItem: public RsChatItem
|
||||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||||
|
|
||||||
/* set data from RsChatMsgItem to RsPrivateChatMsgConfigItem */
|
/* set data from RsChatMsgItem to RsPrivateChatMsgConfigItem */
|
||||||
void set(RsChatMsgItem *ci, const std::string &peerId, uint32_t confFlags);
|
void set(RsChatMsgItem *ci, const RsPeerId &peerId, uint32_t confFlags);
|
||||||
/* get data from RsPrivateChatMsgConfigItem to RsChatMsgItem */
|
/* get data from RsPrivateChatMsgConfigItem to RsChatMsgItem */
|
||||||
void get(RsChatMsgItem *ci);
|
void get(RsChatMsgItem *ci);
|
||||||
|
|
||||||
std::string configPeerId;
|
RsPeerId configPeerId;
|
||||||
uint32_t chatFlags;
|
uint32_t chatFlags;
|
||||||
uint32_t configFlags;
|
uint32_t configFlags;
|
||||||
uint32_t sendTime;
|
uint32_t sendTime;
|
||||||
|
@ -335,7 +336,7 @@ class RsPrivateChatDistantInviteConfigItem: public RsChatItem
|
||||||
unsigned char aes_key[16] ;
|
unsigned char aes_key[16] ;
|
||||||
std::string hash ;
|
std::string hash ;
|
||||||
std::string encrypted_radix64_string ;
|
std::string encrypted_radix64_string ;
|
||||||
std::string destination_pgp_id ;
|
PGPIdType destination_pgp_id ;
|
||||||
uint32_t time_of_validity ;
|
uint32_t time_of_validity ;
|
||||||
uint32_t last_hit_time ;
|
uint32_t last_hit_time ;
|
||||||
uint32_t flags ;
|
uint32_t flags ;
|
||||||
|
@ -545,7 +546,7 @@ class RsMsgSrcId : public RsMessageItem
|
||||||
//
|
//
|
||||||
|
|
||||||
uint32_t msgId;
|
uint32_t msgId;
|
||||||
std::string srcId;
|
RsPeerId srcId;
|
||||||
};
|
};
|
||||||
class RsPublicMsgInviteConfigItem : public RsMessageItem
|
class RsPublicMsgInviteConfigItem : public RsMessageItem
|
||||||
{
|
{
|
||||||
|
|
|
@ -153,12 +153,12 @@ int p3ChatService::sendPublicChat(const std::string &msg)
|
||||||
{
|
{
|
||||||
/* go through all the peers */
|
/* go through all the peers */
|
||||||
|
|
||||||
std::list<std::string> ids;
|
std::list<RsPeerId> ids;
|
||||||
std::list<std::string>::iterator it;
|
std::list<RsPeerId>::iterator it;
|
||||||
mLinkMgr->getOnlineList(ids);
|
mLinkMgr->getOnlineList(ids);
|
||||||
|
|
||||||
/* add in own id -> so get reflection */
|
/* add in own id -> so get reflection */
|
||||||
std::string ownId = mLinkMgr->getOwnId();
|
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||||
ids.push_back(ownId);
|
ids.push_back(ownId);
|
||||||
|
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
|
@ -184,7 +184,7 @@ int p3ChatService::sendPublicChat(const std::string &msg)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (*it == ownId) {
|
if (*it == ownId) {
|
||||||
mHistoryMgr->addMessage(false, "", ownId, ci);
|
mHistoryMgr->addMessage(false, RsPeerId(), ownId, ci);
|
||||||
}
|
}
|
||||||
sendItem(ci);
|
sendItem(ci);
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ class p3ChatService::AvatarInfo
|
||||||
|
|
||||||
void p3ChatService::sendGroupChatStatusString(const std::string& status_string)
|
void p3ChatService::sendGroupChatStatusString(const std::string& status_string)
|
||||||
{
|
{
|
||||||
std::list<std::string> ids;
|
std::list<RsPeerId> ids;
|
||||||
mLinkMgr->getOnlineList(ids);
|
mLinkMgr->getOnlineList(ids);
|
||||||
|
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
|
@ -250,7 +250,7 @@ void p3ChatService::sendGroupChatStatusString(const std::string& status_string)
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(std::list<std::string>::iterator it = ids.begin(); it != ids.end(); ++it)
|
for(std::list<RsPeerId>::iterator it = ids.begin(); it != ids.end(); ++it)
|
||||||
{
|
{
|
||||||
RsChatStatusItem *cs = new RsChatStatusItem ;
|
RsChatStatusItem *cs = new RsChatStatusItem ;
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ void p3ChatService::sendGroupChatStatusString(const std::string& status_string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::sendStatusString( const std::string& id , const std::string& status_string)
|
void p3ChatService::sendStatusString( const RsPeerId& id , const std::string& status_string)
|
||||||
{
|
{
|
||||||
ChatLobbyId lobby_id ;
|
ChatLobbyId lobby_id ;
|
||||||
if(isLobbyId(id,lobby_id))
|
if(isLobbyId(id,lobby_id))
|
||||||
|
@ -291,8 +291,12 @@ void p3ChatService::sendPrivateChatItem(RsChatItem *item)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
if(_distant_chat_peers.find(item->PeerId()) != _distant_chat_peers.end())
|
for(std::map<TurtleFileHash,DistantChatPeerInfo>::const_iterator it=_distant_chat_peers.begin();it!=_distant_chat_peers.end();++it)
|
||||||
found = true ;
|
if( it->second.virtual_peer_id == item->PeerId()) // _distant_chat_peers.find(item->PeerId()) !=_distant_chat_peers.end())
|
||||||
|
{
|
||||||
|
found = true ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(found)
|
if(found)
|
||||||
|
@ -363,7 +367,7 @@ void p3ChatService::checkSizeAndSendMessage(RsChatLobbyMsgItem *msg)
|
||||||
sendItem(msg) ;
|
sendItem(msg) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::getVirtualPeerId(const ChatLobbyId& id,std::string& vpid)
|
bool p3ChatService::getVirtualPeerId(const ChatLobbyId& id,ChatLobbyVirtualPeerId& vpid)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
@ -409,7 +413,7 @@ void p3ChatService::locked_printDebugInfo() const
|
||||||
|
|
||||||
std::cerr << " Participating friends: " << std::endl;
|
std::cerr << " Participating friends: " << std::endl;
|
||||||
|
|
||||||
for(std::set<std::string>::const_iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
for(std::set<RsPeerId>::const_iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
||||||
std::cerr << " " << *it2 << std::endl;
|
std::cerr << " " << *it2 << std::endl;
|
||||||
|
|
||||||
std::cerr << " Participating nick names: " << std::endl;
|
std::cerr << " Participating nick names: " << std::endl;
|
||||||
|
@ -421,7 +425,7 @@ void p3ChatService::locked_printDebugInfo() const
|
||||||
|
|
||||||
std::cerr << "Recorded lobby names: " << std::endl;
|
std::cerr << "Recorded lobby names: " << std::endl;
|
||||||
|
|
||||||
for( std::map<std::string,ChatLobbyId>::const_iterator it(_lobby_ids.begin()) ;it!=_lobby_ids.end();++it)
|
for( std::map<RsPeerId,ChatLobbyId>::const_iterator it(_lobby_ids.begin()) ;it!=_lobby_ids.end();++it)
|
||||||
std::cerr << " \"" << it->first << "\" id = " << std::hex << it->second << std::dec << std::endl;
|
std::cerr << " \"" << it->first << "\" id = " << std::hex << it->second << std::dec << std::endl;
|
||||||
|
|
||||||
std::cerr << "Visible public lobbies: " << std::endl;
|
std::cerr << "Visible public lobbies: " << std::endl;
|
||||||
|
@ -429,7 +433,7 @@ void p3ChatService::locked_printDebugInfo() const
|
||||||
for( std::map<ChatLobbyId,VisibleChatLobbyRecord>::const_iterator it(_visible_lobbies.begin()) ;it!=_visible_lobbies.end();++it)
|
for( std::map<ChatLobbyId,VisibleChatLobbyRecord>::const_iterator it(_visible_lobbies.begin()) ;it!=_visible_lobbies.end();++it)
|
||||||
{
|
{
|
||||||
std::cerr << " " << std::hex << it->first << " name = " << std::dec << it->second.lobby_name << it->second.lobby_topic << std::endl;
|
std::cerr << " " << std::hex << it->first << " name = " << std::dec << it->second.lobby_name << it->second.lobby_topic << std::endl;
|
||||||
for(std::set<std::string>::const_iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
for(std::set<RsPeerId>::const_iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
||||||
std::cerr << " With friend: " << *it2 << std::endl;
|
std::cerr << " With friend: " << *it2 << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,11 +443,11 @@ void p3ChatService::locked_printDebugInfo() const
|
||||||
std::cerr << " \"" << std::hex << it->first << "\" flags = " << it->second << std::dec << std::endl;
|
std::cerr << " \"" << std::hex << it->first << "\" flags = " << it->second << std::dec << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lobby_id)
|
bool p3ChatService::isLobbyId(const RsPeerId& virtual_peer_id,ChatLobbyId& lobby_id)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<std::string,ChatLobbyId>::const_iterator it(_lobby_ids.find(virtual_peer_id)) ;
|
std::map<ChatLobbyVirtualPeerId,ChatLobbyId>::const_iterator it(_lobby_ids.find(virtual_peer_id)) ;
|
||||||
|
|
||||||
if(it != _lobby_ids.end())
|
if(it != _lobby_ids.end())
|
||||||
{
|
{
|
||||||
|
@ -455,20 +459,21 @@ bool p3ChatService::isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lo
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::isOnline(const std::string& id)
|
bool p3ChatService::isOnline(const RsPeerId& id)
|
||||||
{
|
{
|
||||||
// check if the id is a tunnel id or a peer id.
|
// check if the id is a tunnel id or a peer id.
|
||||||
|
|
||||||
uint32_t status ;
|
uint32_t status ;
|
||||||
std::string pgp_id ;
|
PGPIdType pgp_id ;
|
||||||
|
|
||||||
if(!getDistantChatStatus(id,status,pgp_id))
|
std::string hash ;
|
||||||
|
if(findHashForVirtualPeerId(id,hash) && getDistantChatStatus(hash,status,pgp_id))
|
||||||
|
return true ;
|
||||||
|
else
|
||||||
return mLinkMgr->isOnline(id) ;
|
return mLinkMgr->isOnline(id) ;
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::sendPrivateChat(const std::string &id, const std::string &msg)
|
bool p3ChatService::sendPrivateChat(const RsPeerId &id, const std::string &msg)
|
||||||
{
|
{
|
||||||
// look into ID. Is it a peer, or a chat lobby?
|
// look into ID. Is it a peer, or a chat lobby?
|
||||||
|
|
||||||
|
@ -508,7 +513,7 @@ bool p3ChatService::sendPrivateChat(const std::string &id, const std::string
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
std::map<std::string,AvatarInfo*>::iterator it = _avatars.find(id) ;
|
std::map<RsPeerId,AvatarInfo*>::iterator it = _avatars.find(id) ;
|
||||||
|
|
||||||
if(it == _avatars.end())
|
if(it == _avatars.end())
|
||||||
{
|
{
|
||||||
|
@ -543,7 +548,7 @@ bool p3ChatService::sendPrivateChat(const std::string &id, const std::string
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<std::string,StateStringInfo>::iterator it = _state_strings.find(id) ;
|
std::map<RsPeerId,StateStringInfo>::iterator it = _state_strings.find(id) ;
|
||||||
|
|
||||||
if(it == _state_strings.end())
|
if(it == _state_strings.end())
|
||||||
{
|
{
|
||||||
|
@ -575,7 +580,7 @@ bool p3ChatService::locked_checkAndRebuildPartialMessage_deprecated(RsChatMsgIte
|
||||||
{
|
{
|
||||||
// Check is the item is ending an incomplete item.
|
// Check is the item is ending an incomplete item.
|
||||||
//
|
//
|
||||||
std::map<std::string,RsChatMsgItem*>::iterator it = _pendingPartialMessages.find(ci->PeerId()) ;
|
std::map<RsPeerId,RsChatMsgItem*>::iterator it = _pendingPartialMessages.find(ci->PeerId()) ;
|
||||||
|
|
||||||
bool ci_is_incomplete = ci->chatFlags & RS_CHAT_FLAG_PARTIAL_MESSAGE ;
|
bool ci_is_incomplete = ci->chatFlags & RS_CHAT_FLAG_PARTIAL_MESSAGE ;
|
||||||
|
|
||||||
|
@ -720,14 +725,14 @@ class MsgCounter
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool p3ChatService::locked_bouncingObjectCheck(RsChatLobbyBouncingObject *obj,const std::string& peer_id,uint32_t lobby_count)
|
bool p3ChatService::locked_bouncingObjectCheck(RsChatLobbyBouncingObject *obj,const RsPeerId& peer_id,uint32_t lobby_count)
|
||||||
{
|
{
|
||||||
static std::map<std::string, std::list<time_t> > message_counts ;
|
static std::map<std::string, std::list<time_t> > message_counts ;
|
||||||
|
|
||||||
std::ostringstream os ;
|
std::ostringstream os ;
|
||||||
os << obj->lobby_id ;
|
os << obj->lobby_id ;
|
||||||
|
|
||||||
std::string pid = peer_id + "_" + os.str() ;
|
std::string pid = peer_id.toStdString() + "_" + os.str() ;
|
||||||
|
|
||||||
// Check for the number of peers in the lobby. First look into visible lobbies, because the number
|
// Check for the number of peers in the lobby. First look into visible lobbies, because the number
|
||||||
// of peers there is more accurate. If non existant (because it's a private lobby), take the count from
|
// of peers there is more accurate. If non existant (because it's a private lobby), take the count from
|
||||||
|
@ -1079,7 +1084,7 @@ void p3ChatService::handleRecvChatAvatarItem(RsChatAvatarItem *ca)
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "Received avatar data for peer " << ca->PeerId() << ". Notifying." << std::endl ;
|
std::cerr << "Received avatar data for peer " << ca->PeerId() << ". Notifying." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
RsServer::notify()->notifyPeerHasNewAvatar(ca->PeerId()) ;
|
RsServer::notify()->notifyPeerHasNewAvatar(ca->PeerId().toStdString()) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::checkForMessageSecurity(RsChatMsgItem *ci)
|
bool p3ChatService::checkForMessageSecurity(RsChatMsgItem *ci)
|
||||||
|
@ -1131,7 +1136,7 @@ bool p3ChatService::checkForMessageSecurity(RsChatMsgItem *ci)
|
||||||
//
|
//
|
||||||
std::cout << "handleRecvChatMsgItem: " << ci->message << std::endl;
|
std::cout << "handleRecvChatMsgItem: " << ci->message << std::endl;
|
||||||
std::cout << "**********" << std::endl;
|
std::cout << "**********" << std::endl;
|
||||||
std::cout << "********** entity attack by " << ci->PeerId().c_str() << std::endl;
|
std::cout << "********** entity attack by " << ci->PeerId().toStdString().c_str() << std::endl;
|
||||||
std::cout << "**********" << std::endl;
|
std::cout << "**********" << std::endl;
|
||||||
|
|
||||||
ci->message = "**** This message (from peer id " + rsPeers->getPeerName(ci->PeerId()) + ") has been removed because it contains the string \"<!\".****" ;
|
ci->message = "**** This message (from peer id " + rsPeers->getPeerName(ci->PeerId()) + ") has been removed because it contains the string \"<!\".****" ;
|
||||||
|
@ -1215,7 +1220,7 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *ci)
|
||||||
|
|
||||||
// setup the peer id to the virtual peer id of the lobby.
|
// setup the peer id to the virtual peer id of the lobby.
|
||||||
//
|
//
|
||||||
std::string virtual_peer_id ;
|
RsPeerId virtual_peer_id ;
|
||||||
getVirtualPeerId(cli->lobby_id,virtual_peer_id) ;
|
getVirtualPeerId(cli->lobby_id,virtual_peer_id) ;
|
||||||
cli->PeerId(virtual_peer_id) ;
|
cli->PeerId(virtual_peer_id) ;
|
||||||
name = cli->nick;
|
name = cli->nick;
|
||||||
|
@ -1256,7 +1261,7 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *ci)
|
||||||
ci->chatFlags &= ~RS_CHAT_FLAG_AVATAR_AVAILABLE ;
|
ci->chatFlags &= ~RS_CHAT_FLAG_AVATAR_AVAILABLE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string,AvatarInfo *>::const_iterator it = _avatars.find(ci->PeerId()) ;
|
std::map<RsPeerId,AvatarInfo *>::const_iterator it = _avatars.find(ci->PeerId()) ;
|
||||||
|
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "p3chatservice:: avatar requested from above. " << std::endl ;
|
std::cerr << "p3chatservice:: avatar requested from above. " << std::endl ;
|
||||||
|
@ -1276,11 +1281,11 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *ci)
|
||||||
|
|
||||||
if (ci->chatFlags & RS_CHAT_FLAG_PRIVATE) {
|
if (ci->chatFlags & RS_CHAT_FLAG_PRIVATE) {
|
||||||
/* notify private chat message */
|
/* notify private chat message */
|
||||||
RsServer::notify()->AddPopupMessage(popupChatFlag, ci->PeerId(), name, message);
|
RsServer::notify()->AddPopupMessage(popupChatFlag, ci->PeerId().toStdString(), name, message);
|
||||||
} else {
|
} else {
|
||||||
/* notify public chat message */
|
/* notify public chat message */
|
||||||
RsServer::notify()->AddPopupMessage(RS_POPUP_GROUPCHAT, ci->PeerId(), "", message);
|
RsServer::notify()->AddPopupMessage(RS_POPUP_GROUPCHAT, ci->PeerId().toStdString(), "", message);
|
||||||
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_CHAT_NEW, ci->PeerId(), message, "");
|
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_CHAT_NEW, ci->PeerId().toStdString(), message, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1303,7 +1308,7 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *ci)
|
||||||
|
|
||||||
if (ci->PeerId() != mLinkMgr->getOwnId()) {
|
if (ci->PeerId() != mLinkMgr->getOwnId()) {
|
||||||
/* not from loop back */
|
/* not from loop back */
|
||||||
mHistoryMgr->addMessage(true, "", ci->PeerId(), ci);
|
mHistoryMgr->addMessage(true, RsPeerId(), ci->PeerId(), ci);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* UNLOCK */
|
} /* UNLOCK */
|
||||||
|
@ -1331,7 +1336,7 @@ void p3ChatService::handleRecvChatStatusItem(RsChatStatusItem *cs)
|
||||||
else if(cs->flags & RS_CHAT_FLAG_CUSTOM_STATE) // Check if new custom string is available at peer's.
|
else if(cs->flags & RS_CHAT_FLAG_CUSTOM_STATE) // Check if new custom string is available at peer's.
|
||||||
{ // If so, send a request to get the custom string.
|
{ // If so, send a request to get the custom string.
|
||||||
receiveStateString(cs->PeerId(),cs->status_string) ; // store it
|
receiveStateString(cs->PeerId(),cs->status_string) ; // store it
|
||||||
RsServer::notify()->notifyCustomState(cs->PeerId(), cs->status_string) ;
|
RsServer::notify()->notifyCustomState(cs->PeerId().toStdString(), cs->status_string) ;
|
||||||
}
|
}
|
||||||
else if(cs->flags & RS_CHAT_FLAG_CUSTOM_STATE_AVAILABLE)
|
else if(cs->flags & RS_CHAT_FLAG_CUSTOM_STATE_AVAILABLE)
|
||||||
{
|
{
|
||||||
|
@ -1342,13 +1347,13 @@ void p3ChatService::handleRecvChatStatusItem(RsChatStatusItem *cs)
|
||||||
}
|
}
|
||||||
else if(cs->flags & RS_CHAT_FLAG_PRIVATE)
|
else if(cs->flags & RS_CHAT_FLAG_PRIVATE)
|
||||||
{
|
{
|
||||||
RsServer::notify()->notifyChatStatus(cs->PeerId(),cs->status_string,true) ;
|
RsServer::notify()->notifyChatStatus(cs->PeerId().toStdString(),cs->status_string,true) ;
|
||||||
|
|
||||||
if(cs->flags & RS_CHAT_FLAG_CLOSING_DISTANT_CONNECTION)
|
if(cs->flags & RS_CHAT_FLAG_CLOSING_DISTANT_CONNECTION)
|
||||||
markDistantChatAsClosed(cs->PeerId()) ;
|
markDistantChatAsClosed(cs->PeerId()) ;
|
||||||
}
|
}
|
||||||
else if(cs->flags & RS_CHAT_FLAG_PUBLIC)
|
else if(cs->flags & RS_CHAT_FLAG_PUBLIC)
|
||||||
RsServer::notify()->notifyChatStatus(cs->PeerId(),cs->status_string,false) ;
|
RsServer::notify()->notifyChatStatus(cs->PeerId().toStdString(),cs->status_string,false) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& visible_lobbies)
|
void p3ChatService::getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& visible_lobbies)
|
||||||
|
@ -1366,10 +1371,10 @@ void p3ChatService::getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecor
|
||||||
|
|
||||||
if(now > MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ + last_visible_lobby_info_request_time)
|
if(now > MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ + last_visible_lobby_info_request_time)
|
||||||
{
|
{
|
||||||
std::list<std::string> ids ;
|
std::list<RsPeerId> ids ;
|
||||||
mLinkMgr->getOnlineList(ids);
|
mLinkMgr->getOnlineList(ids);
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator it(ids.begin());it!=ids.end();++it)
|
for(std::list<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||||
{
|
{
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << " asking list of public lobbies to " << *it << std::endl;
|
std::cerr << " asking list of public lobbies to " << *it << std::endl;
|
||||||
|
@ -1436,7 +1441,7 @@ int p3ChatService::getPrivateChatQueueCount(bool incoming)
|
||||||
return privateOutgoingList.size();
|
return privateOutgoingList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::getPrivateChatQueueIds(bool incoming, std::list<std::string> &ids)
|
bool p3ChatService::getPrivateChatQueueIds(bool incoming, std::list<RsPeerId> &ids)
|
||||||
{
|
{
|
||||||
ids.clear();
|
ids.clear();
|
||||||
|
|
||||||
|
@ -1467,7 +1472,7 @@ bool p3ChatService::getPrivateChatQueueIds(bool incoming, std::list<std::string>
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::getPrivateChatQueue(bool incoming, const std::string &id, std::list<ChatInfo> &chats)
|
bool p3ChatService::getPrivateChatQueue(bool incoming, const RsPeerId &id, std::list<ChatInfo> &chats)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
@ -1498,7 +1503,7 @@ bool p3ChatService::getPrivateChatQueue(bool incoming, const std::string &id, st
|
||||||
return (chats.size() > 0);
|
return (chats.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::clearPrivateChatQueue(bool incoming, const std::string &id)
|
bool p3ChatService::clearPrivateChatQueue(bool incoming, const RsPeerId &id)
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
|
@ -1569,7 +1574,7 @@ void p3ChatService::initRsChatInfo(RsChatMsgItem *c, ChatInfo &i)
|
||||||
|
|
||||||
void p3ChatService::setOwnCustomStateString(const std::string& s)
|
void p3ChatService::setOwnCustomStateString(const std::string& s)
|
||||||
{
|
{
|
||||||
std::list<std::string> onlineList;
|
std::list<RsPeerId> onlineList;
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
@ -1578,7 +1583,7 @@ void p3ChatService::setOwnCustomStateString(const std::string& s)
|
||||||
#endif
|
#endif
|
||||||
_custom_status_string = s ;
|
_custom_status_string = s ;
|
||||||
|
|
||||||
for(std::map<std::string,StateStringInfo>::iterator it(_state_strings.begin());it!=_state_strings.end();++it)
|
for(std::map<RsPeerId,StateStringInfo>::iterator it(_state_strings.begin());it!=_state_strings.end();++it)
|
||||||
it->second._own_is_new = true ;
|
it->second._own_is_new = true ;
|
||||||
|
|
||||||
mLinkMgr->getOnlineList(onlineList);
|
mLinkMgr->getOnlineList(onlineList);
|
||||||
|
@ -1587,7 +1592,7 @@ void p3ChatService::setOwnCustomStateString(const std::string& s)
|
||||||
RsServer::notify()->notifyOwnStatusMessageChanged() ;
|
RsServer::notify()->notifyOwnStatusMessageChanged() ;
|
||||||
|
|
||||||
// alert your online peers to your newly set status
|
// alert your online peers to your newly set status
|
||||||
std::list<std::string>::iterator it(onlineList.begin());
|
std::list<RsPeerId>::iterator it(onlineList.begin());
|
||||||
for(; it != onlineList.end(); it++){
|
for(; it != onlineList.end(); it++){
|
||||||
|
|
||||||
RsChatStatusItem *cs = new RsChatStatusItem();
|
RsChatStatusItem *cs = new RsChatStatusItem();
|
||||||
|
@ -1619,7 +1624,7 @@ void p3ChatService::setOwnAvatarJpegData(const unsigned char *data,int size)
|
||||||
_own_avatar = new AvatarInfo(data,size) ;
|
_own_avatar = new AvatarInfo(data,size) ;
|
||||||
|
|
||||||
// set the info that our avatar is new, for all peers
|
// set the info that our avatar is new, for all peers
|
||||||
for(std::map<std::string,AvatarInfo *>::iterator it(_avatars.begin());it!=_avatars.end();++it)
|
for(std::map<RsPeerId,AvatarInfo *>::iterator it(_avatars.begin());it!=_avatars.end();++it)
|
||||||
it->second->_own_is_new = true ;
|
it->second->_own_is_new = true ;
|
||||||
}
|
}
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
|
@ -1632,7 +1637,7 @@ void p3ChatService::setOwnAvatarJpegData(const unsigned char *data,int size)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::receiveStateString(const std::string& id,const std::string& s)
|
void p3ChatService::receiveStateString(const RsPeerId& id,const std::string& s)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
|
@ -1696,13 +1701,13 @@ void p3ChatService::getOwnAvatarJpegData(unsigned char *& data,int& size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string p3ChatService::getCustomStateString(const std::string& peer_id)
|
std::string p3ChatService::getCustomStateString(const RsPeerId& peer_id)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
// should be a Mutex here.
|
// should be a Mutex here.
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<std::string,StateStringInfo>::iterator it = _state_strings.find(peer_id) ;
|
std::map<RsPeerId,StateStringInfo>::iterator it = _state_strings.find(peer_id) ;
|
||||||
|
|
||||||
// has it. Return it strait away.
|
// has it. Return it strait away.
|
||||||
//
|
//
|
||||||
|
@ -1717,13 +1722,13 @@ std::string p3ChatService::getCustomStateString(const std::string& peer_id)
|
||||||
return std::string() ;
|
return std::string() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::getAvatarJpegData(const std::string& peer_id,unsigned char *& data,int& size)
|
void p3ChatService::getAvatarJpegData(const RsPeerId& peer_id,unsigned char *& data,int& size)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
// should be a Mutex here.
|
// should be a Mutex here.
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<std::string,AvatarInfo *>::const_iterator it = _avatars.find(peer_id) ;
|
std::map<RsPeerId,AvatarInfo *>::const_iterator it = _avatars.find(peer_id) ;
|
||||||
|
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "p3chatservice:: avatar for peer " << peer_id << " requested from above. " << std::endl ;
|
std::cerr << "p3chatservice:: avatar for peer " << peer_id << " requested from above. " << std::endl ;
|
||||||
|
@ -1750,7 +1755,7 @@ void p3ChatService::getAvatarJpegData(const std::string& peer_id,unsigned char *
|
||||||
sendAvatarRequest(peer_id);
|
sendAvatarRequest(peer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::sendAvatarRequest(const std::string& peer_id)
|
void p3ChatService::sendAvatarRequest(const RsPeerId& peer_id)
|
||||||
{
|
{
|
||||||
// Doesn't have avatar. Request it.
|
// Doesn't have avatar. Request it.
|
||||||
//
|
//
|
||||||
|
@ -1769,7 +1774,7 @@ void p3ChatService::sendAvatarRequest(const std::string& peer_id)
|
||||||
sendPrivateChatItem(ci);
|
sendPrivateChatItem(ci);
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::sendCustomStateRequest(const std::string& peer_id){
|
void p3ChatService::sendCustomStateRequest(const RsPeerId& peer_id){
|
||||||
|
|
||||||
RsChatStatusItem* cs = new RsChatStatusItem;
|
RsChatStatusItem* cs = new RsChatStatusItem;
|
||||||
|
|
||||||
|
@ -1806,7 +1811,7 @@ RsChatAvatarItem *p3ChatService::makeOwnAvatarItem()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void p3ChatService::sendAvatarJpegData(const std::string& peer_id)
|
void p3ChatService::sendAvatarJpegData(const RsPeerId& peer_id)
|
||||||
{
|
{
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "p3chatservice: sending requested for peer " << peer_id << ", data=" << (void*)_own_avatar << std::endl ;
|
std::cerr << "p3chatservice: sending requested for peer " << peer_id << ", data=" << (void*)_own_avatar << std::endl ;
|
||||||
|
@ -1833,7 +1838,7 @@ void p3ChatService::sendAvatarJpegData(const std::string& peer_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::sendCustomState(const std::string& peer_id){
|
void p3ChatService::sendCustomState(const RsPeerId& peer_id){
|
||||||
|
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "p3chatservice: sending requested status string for peer " << peer_id << std::endl ;
|
std::cerr << "p3chatservice: sending requested status string for peer " << peer_id << std::endl ;
|
||||||
|
@ -1847,7 +1852,7 @@ std::cerr << "p3chatservice: sending requested status string for peer " << peer_
|
||||||
|
|
||||||
bool p3ChatService::loadList(std::list<RsItem*>& load)
|
bool p3ChatService::loadList(std::list<RsItem*>& load)
|
||||||
{
|
{
|
||||||
std::list<std::string> ssl_peers;
|
std::list<RsPeerId> ssl_peers;
|
||||||
mLinkMgr->getFriendList(ssl_peers);
|
mLinkMgr->getFriendList(ssl_peers);
|
||||||
|
|
||||||
for(std::list<RsItem*>::const_iterator it(load.begin());it!=load.end();++it)
|
for(std::list<RsItem*>::const_iterator it(load.begin());it!=load.end();++it)
|
||||||
|
@ -2069,7 +2074,7 @@ void p3ChatService::statusChange(const std::list<pqipeer> &plist)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::string ownId = mLinkMgr->getOwnId();
|
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||||
|
|
||||||
std::list<RsChatMsgItem *>::iterator cit = privateOutgoingList.begin();
|
std::list<RsChatMsgItem *>::iterator cit = privateOutgoingList.begin();
|
||||||
while (cit != privateOutgoingList.end()) {
|
while (cit != privateOutgoingList.end()) {
|
||||||
|
@ -2115,7 +2120,7 @@ void p3ChatService::statusChange(const std::list<pqipeer> &plist)
|
||||||
// true: the object is not a duplicate and should be used
|
// true: the object is not a duplicate and should be used
|
||||||
// false: the object is a duplicate or there is an error, and it should be destroyed.
|
// false: the object is a duplicate or there is an error, and it should be destroyed.
|
||||||
//
|
//
|
||||||
bool p3ChatService::bounceLobbyObject(RsChatLobbyBouncingObject *item,const std::string& peer_id)
|
bool p3ChatService::bounceLobbyObject(RsChatLobbyBouncingObject *item,const RsPeerId& peer_id)
|
||||||
{
|
{
|
||||||
time_t now = time(NULL) ;
|
time_t now = time(NULL) ;
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
@ -2173,7 +2178,7 @@ bool p3ChatService::bounceLobbyObject(RsChatLobbyBouncingObject *item,const std:
|
||||||
|
|
||||||
// Forward to allparticipating friends, except this peer.
|
// Forward to allparticipating friends, except this peer.
|
||||||
|
|
||||||
for(std::set<std::string>::const_iterator it(lobby.participating_friends.begin());it!=lobby.participating_friends.end();++it)
|
for(std::set<RsPeerId>::const_iterator it(lobby.participating_friends.begin());it!=lobby.participating_friends.end();++it)
|
||||||
if((*it)!=peer_id && mLinkMgr->isOnline(*it))
|
if((*it)!=peer_id && mLinkMgr->isOnline(*it))
|
||||||
{
|
{
|
||||||
RsChatLobbyBouncingObject *obj2 = item->duplicate() ; // makes a copy
|
RsChatLobbyBouncingObject *obj2 = item->duplicate() ; // makes a copy
|
||||||
|
@ -2248,7 +2253,7 @@ void p3ChatService::sendLobbyStatusItem(const ChatLobbyId& lobby_id,int type,con
|
||||||
item.string1 = status_string ;
|
item.string1 = status_string ;
|
||||||
item.sendTime = time(NULL) ;
|
item.sendTime = time(NULL) ;
|
||||||
}
|
}
|
||||||
std::string ownId = mLinkMgr->getOwnId();
|
RsPeerId ownId = mLinkMgr->getOwnId();
|
||||||
bounceLobbyObject(&item,ownId) ;
|
bounceLobbyObject(&item,ownId) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2281,7 +2286,7 @@ bool p3ChatService::locked_initLobbyBouncableObject(const ChatLobbyId& lobby_id,
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::sendLobbyChat(const std::string &id, const std::string& msg, const ChatLobbyId& lobby_id)
|
bool p3ChatService::sendLobbyChat(const RsPeerId &id, const std::string& msg, const ChatLobbyId& lobby_id)
|
||||||
{
|
{
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "Sending chat lobby message to lobby " << std::hex << lobby_id << std::dec << std::endl;
|
std::cerr << "Sending chat lobby message to lobby " << std::hex << lobby_id << std::dec << std::endl;
|
||||||
|
@ -2306,7 +2311,7 @@ bool p3ChatService::sendLobbyChat(const std::string &id, const std::string& msg,
|
||||||
item.message = msg;
|
item.message = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ownId = rsPeers->getOwnId();
|
RsPeerId ownId = rsPeers->getOwnId();
|
||||||
|
|
||||||
mHistoryMgr->addMessage(false, id, ownId, &item);
|
mHistoryMgr->addMessage(false, id, ownId, &item);
|
||||||
|
|
||||||
|
@ -2327,7 +2332,8 @@ void p3ChatService::handleConnectionChallenge(RsChatLobbyConnectChallengeItem *i
|
||||||
|
|
||||||
time_t now = time(NULL) ;
|
time_t now = time(NULL) ;
|
||||||
ChatLobbyId lobby_id ;
|
ChatLobbyId lobby_id ;
|
||||||
std::string ownId = rsPeers->getOwnId();
|
const RsPeerId& ownId = rsPeers->getOwnId();
|
||||||
|
|
||||||
bool found = false ;
|
bool found = false ;
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
@ -2406,10 +2412,10 @@ void p3ChatService::sendConnectionChallenge(ChatLobbyId lobby_id)
|
||||||
|
|
||||||
// Broadcast to all direct friends
|
// Broadcast to all direct friends
|
||||||
|
|
||||||
std::list<std::string> ids ;
|
std::list<RsPeerId> ids ;
|
||||||
mLinkMgr->getOnlineList(ids);
|
mLinkMgr->getOnlineList(ids);
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator it(ids.begin());it!=ids.end();++it)
|
for(std::list<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||||
{
|
{
|
||||||
RsChatLobbyConnectChallengeItem *item = new RsChatLobbyConnectChallengeItem ;
|
RsChatLobbyConnectChallengeItem *item = new RsChatLobbyConnectChallengeItem ;
|
||||||
|
|
||||||
|
@ -2425,16 +2431,16 @@ void p3ChatService::sendConnectionChallenge(ChatLobbyId lobby_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t p3ChatService::makeConnexionChallengeCode(const std::string& peer_id,ChatLobbyId lobby_id,ChatLobbyMsgId msg_id)
|
uint64_t p3ChatService::makeConnexionChallengeCode(const RsPeerId& peer_id,ChatLobbyId lobby_id,ChatLobbyMsgId msg_id)
|
||||||
{
|
{
|
||||||
uint64_t result = 0 ;
|
uint64_t result = 0 ;
|
||||||
|
|
||||||
for(uint32_t i=0;i<peer_id.size();++i)
|
for(uint32_t i=0;i<RsPeerId::SIZE_IN_BYTES;++i)
|
||||||
{
|
{
|
||||||
result += msg_id ;
|
result += msg_id ;
|
||||||
result ^= result >> 35 ;
|
result ^= result >> 35 ;
|
||||||
result += result << 6 ;
|
result += result << 6 ;
|
||||||
result ^= peer_id[i] * lobby_id ;
|
result ^= peer_id.toByteArray()[i] * lobby_id ;
|
||||||
result += result << 26 ;
|
result += result << 26 ;
|
||||||
result ^= result >> 13 ;
|
result ^= result >> 13 ;
|
||||||
}
|
}
|
||||||
|
@ -2452,7 +2458,7 @@ void p3ChatService::getChatLobbyList(std::list<ChatLobbyInfo>& cl_infos)
|
||||||
for(std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it(_chat_lobbys.begin());it!=_chat_lobbys.end();++it)
|
for(std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it(_chat_lobbys.begin());it!=_chat_lobbys.end();++it)
|
||||||
cl_infos.push_back(it->second) ;
|
cl_infos.push_back(it->second) ;
|
||||||
}
|
}
|
||||||
void p3ChatService::invitePeerToLobby(const ChatLobbyId& lobby_id, const std::string& peer_id,bool connexion_challenge)
|
void p3ChatService::invitePeerToLobby(const ChatLobbyId& lobby_id, const RsPeerId& peer_id,bool connexion_challenge)
|
||||||
{
|
{
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
if(connexion_challenge)
|
if(connexion_challenge)
|
||||||
|
@ -2623,12 +2629,13 @@ bool p3ChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id)
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string p3ChatService::makeVirtualPeerId(ChatLobbyId lobby_id)
|
ChatLobbyVirtualPeerId p3ChatService::makeVirtualPeerId(ChatLobbyId lobby_id)
|
||||||
{
|
{
|
||||||
std::string s;
|
uint8_t bytes[RsPeerId::SIZE_IN_BYTES] ;
|
||||||
rs_sprintf(s, "Chat Lobby 0x%llx", lobby_id);
|
memset(bytes,0,RsPeerId::SIZE_IN_BYTES) ;
|
||||||
|
memcpy(bytes,&lobby_id,sizeof(lobby_id)) ;
|
||||||
|
|
||||||
return s ;
|
return ChatLobbyVirtualPeerId(bytes) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2655,7 +2662,7 @@ bool p3ChatService::joinVisibleChatLobby(const ChatLobbyId& lobby_id)
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "Joining public chat lobby " << std::hex << lobby_id << std::dec << std::endl;
|
std::cerr << "Joining public chat lobby " << std::hex << lobby_id << std::dec << std::endl;
|
||||||
#endif
|
#endif
|
||||||
std::list<std::string> invited_friends ;
|
std::list<RsPeerId> invited_friends ;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
@ -2702,7 +2709,7 @@ bool p3ChatService::joinVisibleChatLobby(const ChatLobbyId& lobby_id)
|
||||||
|
|
||||||
_lobby_ids[entry.virtual_peer_id] = lobby_id ;
|
_lobby_ids[entry.virtual_peer_id] = lobby_id ;
|
||||||
|
|
||||||
for(std::set<std::string>::const_iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
for(std::set<RsPeerId>::const_iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
||||||
{
|
{
|
||||||
invited_friends.push_back(*it2) ;
|
invited_friends.push_back(*it2) ;
|
||||||
entry.participating_friends.insert(*it2) ;
|
entry.participating_friends.insert(*it2) ;
|
||||||
|
@ -2710,7 +2717,7 @@ bool p3ChatService::joinVisibleChatLobby(const ChatLobbyId& lobby_id)
|
||||||
_chat_lobbys[lobby_id] = entry ;
|
_chat_lobbys[lobby_id] = entry ;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it)
|
for(std::list<RsPeerId>::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it)
|
||||||
invitePeerToLobby(lobby_id,*it) ;
|
invitePeerToLobby(lobby_id,*it) ;
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD) ;
|
RsServer::notify()->notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD) ;
|
||||||
|
@ -2719,7 +2726,7 @@ bool p3ChatService::joinVisibleChatLobby(const ChatLobbyId& lobby_id)
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatLobbyId p3ChatService::createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<std::string>& invited_friends,uint32_t privacy_level)
|
ChatLobbyId p3ChatService::createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,uint32_t privacy_level)
|
||||||
{
|
{
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "Creating a new Chat lobby !!" << std::endl;
|
std::cerr << "Creating a new Chat lobby !!" << std::endl;
|
||||||
|
@ -2754,7 +2761,7 @@ ChatLobbyId p3ChatService::createChatLobby(const std::string& lobby_name,const s
|
||||||
_chat_lobbys[lobby_id] = entry ;
|
_chat_lobbys[lobby_id] = entry ;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it)
|
for(std::list<RsPeerId>::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it)
|
||||||
invitePeerToLobby(lobby_id,*it) ;
|
invitePeerToLobby(lobby_id,*it) ;
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD) ;
|
RsServer::notify()->notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD) ;
|
||||||
|
@ -2778,7 +2785,7 @@ void p3ChatService::handleFriendUnsubscribeLobby(RsChatLobbyUnsubscribeItem *ite
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::set<std::string>::iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
for(std::set<RsPeerId>::iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
||||||
if(*it2 == item->PeerId())
|
if(*it2 == item->PeerId())
|
||||||
{
|
{
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
|
@ -2811,7 +2818,7 @@ void p3ChatService::unsubscribeChatLobby(const ChatLobbyId& id)
|
||||||
|
|
||||||
// send a lobby leaving packet to all friends
|
// send a lobby leaving packet to all friends
|
||||||
|
|
||||||
for(std::set<std::string>::const_iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
for(std::set<RsPeerId>::const_iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
||||||
{
|
{
|
||||||
RsChatLobbyUnsubscribeItem *item = new RsChatLobbyUnsubscribeItem ;
|
RsChatLobbyUnsubscribeItem *item = new RsChatLobbyUnsubscribeItem ;
|
||||||
|
|
||||||
|
@ -2833,7 +2840,7 @@ void p3ChatService::unsubscribeChatLobby(const ChatLobbyId& id)
|
||||||
|
|
||||||
_chat_lobbys.erase(it) ;
|
_chat_lobbys.erase(it) ;
|
||||||
|
|
||||||
for(std::map<std::string,ChatLobbyId>::iterator it2(_lobby_ids.begin());it2!=_lobby_ids.end();++it2)
|
for(std::map<ChatLobbyVirtualPeerId,ChatLobbyId>::iterator it2(_lobby_ids.begin());it2!=_lobby_ids.end();++it2)
|
||||||
if(it2->second == id)
|
if(it2->second == id)
|
||||||
{
|
{
|
||||||
_lobby_ids.erase(it2) ;
|
_lobby_ids.erase(it2) ;
|
||||||
|
@ -3065,7 +3072,7 @@ void p3ChatService::cleanLobbyCaches()
|
||||||
sendConnectionChallenge(*it) ;
|
sendConnectionChallenge(*it) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::handleTunnelRequest(const std::string& hash,const std::string& /*peer_id*/)
|
bool p3ChatService::handleTunnelRequest(const std::string& hash,const RsPeerId& /*peer_id*/)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
@ -3156,7 +3163,7 @@ void p3ChatService::addVirtualPeer(const TurtleFileHash& hash,const TurtleVirtua
|
||||||
|
|
||||||
cs->status_string = "Tunnel is working. You can talk!" ;
|
cs->status_string = "Tunnel is working. You can talk!" ;
|
||||||
cs->flags = RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_ACK_DISTANT_CONNECTION;
|
cs->flags = RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_ACK_DISTANT_CONNECTION;
|
||||||
cs->PeerId(hash);
|
cs->PeerId(virtual_peer_id);
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
@ -3201,7 +3208,7 @@ static void printBinaryData(void *data,uint32_t size)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void p3ChatService::receiveTurtleData( RsTurtleGenericTunnelItem *gitem,const std::string& hash,
|
void p3ChatService::receiveTurtleData( RsTurtleGenericTunnelItem *gitem,const std::string& hash,
|
||||||
const std::string& virtual_peer_id,RsTurtleGenericTunnelItem::Direction /*direction*/)
|
const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction /*direction*/)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DISTANT_CHAT
|
#ifdef DEBUG_DISTANT_CHAT
|
||||||
std::cerr << "p3ChatService::receiveTurtleData(): Received turtle data. " << std::endl;
|
std::cerr << "p3ChatService::receiveTurtleData(): Received turtle data. " << std::endl;
|
||||||
|
@ -3285,12 +3292,25 @@ void p3ChatService::receiveTurtleData( RsTurtleGenericTunnelItem *gitem,const st
|
||||||
|
|
||||||
// Setup the virtual peer to be the origin, and pass it on.
|
// Setup the virtual peer to be the origin, and pass it on.
|
||||||
//
|
//
|
||||||
citem->PeerId(hash) ;
|
citem->PeerId(virtual_peer_id) ;
|
||||||
//RsServer::notify()->notifyPeerStatusChanged(hash,RS_STATUS_ONLINE) ;
|
//RsServer::notify()->notifyPeerStatusChanged(hash,RS_STATUS_ONLINE) ;
|
||||||
|
|
||||||
handleIncomingItem(citem) ; // Treats the item, and deletes it
|
handleIncomingItem(citem) ; // Treats the item, and deletes it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3ChatService::findHashForVirtualPeerId(const TurtleVirtualPeerId& vpid,std::string& hash)
|
||||||
|
{
|
||||||
|
// Looks costly, but there's very few distant chat peers at a time, so this is not.
|
||||||
|
//
|
||||||
|
for(std::map<TurtleFileHash,DistantChatPeerInfo>::const_iterator it = _distant_chat_peers.begin();it!=_distant_chat_peers.end();++it)
|
||||||
|
if(it->second.virtual_peer_id == vpid)
|
||||||
|
{
|
||||||
|
hash = it->first ;
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
void p3ChatService::sendTurtleData(RsChatItem *item)
|
void p3ChatService::sendTurtleData(RsChatItem *item)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DISTANT_CHAT
|
#ifdef DEBUG_DISTANT_CHAT
|
||||||
|
@ -3311,11 +3331,13 @@ void p3ChatService::sendTurtleData(RsChatItem *item)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
uint8_t aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
||||||
std::string virtual_peer_id ;
|
RsPeerId virtual_peer_id = item->PeerId();
|
||||||
|
|
||||||
|
TurtleFileHash hash ;
|
||||||
|
if(findHashForVirtualPeerId(virtual_peer_id,hash))
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
std::map<std::string,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(item->PeerId()) ;
|
std::map<TurtleFileHash,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||||
|
|
||||||
if(it == _distant_chat_peers.end())
|
if(it == _distant_chat_peers.end())
|
||||||
{
|
{
|
||||||
|
@ -3324,9 +3346,14 @@ void p3ChatService::sendTurtleData(RsChatItem *item)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
it->second.last_contact = time(NULL) ;
|
it->second.last_contact = time(NULL) ;
|
||||||
virtual_peer_id = it->second.virtual_peer_id ;
|
|
||||||
memcpy(aes_key,it->second.aes_key,DISTANT_CHAT_AES_KEY_SIZE) ;
|
memcpy(aes_key,it->second.aes_key,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "(EE) p3ChatService::sendTurtleData(): virtual peer id " << virtual_peer_id << " is unknown!!" << std::endl;
|
||||||
|
delete[] buff ;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
#ifdef DEBUG_DISTANT_CHAT
|
#ifdef DEBUG_DISTANT_CHAT
|
||||||
std::cerr << "p3ChatService::sendTurtleData(): tunnel found. Encrypting data." << std::endl;
|
std::cerr << "p3ChatService::sendTurtleData(): tunnel found. Encrypting data." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -3377,7 +3404,7 @@ void p3ChatService::sendTurtleData(RsChatItem *item)
|
||||||
mTurtle->sendTurtleData(virtual_peer_id,gitem) ;
|
mTurtle->sendTurtleData(virtual_peer_id,gitem) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_radix64_string)
|
bool p3ChatService::createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,std::string& encrypted_radix64_string)
|
||||||
{
|
{
|
||||||
// create the invite
|
// create the invite
|
||||||
|
|
||||||
|
@ -3391,19 +3418,13 @@ bool p3ChatService::createDistantChatInvite(const std::string& pgp_id,time_t tim
|
||||||
|
|
||||||
// Create a random hash for that invite.
|
// Create a random hash for that invite.
|
||||||
//
|
//
|
||||||
unsigned char hash_bytes[DISTANT_CHAT_HASH_SIZE] ;
|
std::string hash = Sha1CheckSum::random().toStdString() ;
|
||||||
RAND_bytes( hash_bytes, DISTANT_CHAT_HASH_SIZE) ;
|
|
||||||
|
|
||||||
std::string hash = Sha1CheckSum(hash_bytes).toStdString(false) ;
|
|
||||||
|
|
||||||
#ifdef DEBUG_DISTANT_CHAT
|
#ifdef DEBUG_DISTANT_CHAT
|
||||||
std::cerr << "Created new distant chat invite: " << std::endl;
|
std::cerr << "Created new distant chat invite: " << std::endl;
|
||||||
std::cerr << " validity time stamp = " << invite.time_of_validity << std::endl;
|
std::cerr << " validity time stamp = " << invite.time_of_validity << std::endl;
|
||||||
std::cerr << " hash = " << hash << std::endl;
|
std::cerr << " hash = " << hash << std::endl;
|
||||||
std::cerr << " encryption key = " ;
|
std::cerr << " encryption key = " << t_GenericIdType<DISTANT_CHAT_AES_KEY_SIZE,true,0x0001>(invite.aes_key) << std::endl;
|
||||||
static const char outl[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' } ;
|
|
||||||
for(uint32_t j = 0; j < 16; j++) { std::cerr << outl[ (invite.aes_key[j]>>4) ] ; std::cerr << outl[ invite.aes_key[j] & 0xf ] ; }
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Now encrypt the data to create the link info. We need
|
// Now encrypt the data to create the link info. We need
|
||||||
|
@ -3423,7 +3444,7 @@ bool p3ChatService::createDistantChatInvite(const std::string& pgp_id,time_t tim
|
||||||
|
|
||||||
PGPIdType OwnId(AuthGPG::getAuthGPG()->getGPGOwnId());
|
PGPIdType OwnId(AuthGPG::getAuthGPG()->getGPGOwnId());
|
||||||
|
|
||||||
memcpy(data ,hash_bytes ,DISTANT_CHAT_HASH_SIZE) ;
|
memcpy(data ,Sha1CheckSum(hash).toByteArray(),DISTANT_CHAT_HASH_SIZE) ;
|
||||||
memcpy(data+DISTANT_CHAT_HASH_SIZE ,invite.aes_key ,DISTANT_CHAT_AES_KEY_SIZE) ;
|
memcpy(data+DISTANT_CHAT_HASH_SIZE ,invite.aes_key ,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||||
memcpy(data+DISTANT_CHAT_HASH_SIZE+DISTANT_CHAT_AES_KEY_SIZE,OwnId.toByteArray(),PGP_KEY_ID_SIZE) ;
|
memcpy(data+DISTANT_CHAT_HASH_SIZE+DISTANT_CHAT_AES_KEY_SIZE,OwnId.toByteArray(),PGP_KEY_ID_SIZE) ;
|
||||||
|
|
||||||
|
@ -3508,21 +3529,21 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool signature_checked = AuthGPG::getAuthGPG()->VerifySignBin(data,header_size,data+header_size,data_size-header_size,fingerprint.toStdString()) ;
|
bool signature_checked = AuthGPG::getAuthGPG()->VerifySignBin(data,header_size,data+header_size,data_size-header_size,fingerprint) ;
|
||||||
|
|
||||||
#ifdef DEBUG_DISTANT_CHAT
|
#ifdef DEBUG_DISTANT_CHAT
|
||||||
std::cerr << "Signature successfuly verified!" << std::endl;
|
std::cerr << "Signature successfuly verified!" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
hash = Sha1CheckSum(data).toStdString(false) ;
|
hash = Sha1CheckSum(data).toStdString() ;
|
||||||
|
|
||||||
startClientDistantChatConnection(hash,pgp_id.toStdString(),data+DISTANT_CHAT_HASH_SIZE) ;
|
startClientDistantChatConnection(hash,pgp_id,data+DISTANT_CHAT_HASH_SIZE) ;
|
||||||
|
|
||||||
// Finally, save the decrypted chat info, so that we can display some info in the GUI in case we want to re-use the link
|
// Finally, save the decrypted chat info, so that we can display some info in the GUI in case we want to re-use the link
|
||||||
//
|
//
|
||||||
DistantChatInvite dinvite ;
|
DistantChatInvite dinvite ;
|
||||||
|
|
||||||
dinvite.encrypted_radix64_string = "" ; // means that it's not issued by us
|
dinvite.encrypted_radix64_string = "" ; // means that it's not issued by us
|
||||||
dinvite.destination_pgp_id = pgp_id.toStdString() ;
|
dinvite.destination_pgp_id = pgp_id;
|
||||||
dinvite.time_of_validity = time_of_validity ;
|
dinvite.time_of_validity = time_of_validity ;
|
||||||
dinvite.last_hit_time = time(NULL) ;
|
dinvite.last_hit_time = time(NULL) ;
|
||||||
dinvite.flags = RS_DISTANT_CHAT_FLAG_SIGNED | (signature_checked ? RS_DISTANT_CHAT_FLAG_SIGNATURE_OK : 0) ;
|
dinvite.flags = RS_DISTANT_CHAT_FLAG_SIGNED | (signature_checked ? RS_DISTANT_CHAT_FLAG_SIGNATURE_OK : 0) ;
|
||||||
|
@ -3555,7 +3576,7 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
||||||
|
|
||||||
bool p3ChatService::initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code)
|
bool p3ChatService::initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code)
|
||||||
{
|
{
|
||||||
std::string pgp_id ;
|
PGPIdType pgp_id ;
|
||||||
unsigned char aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
unsigned char aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -3582,7 +3603,7 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& hash,uint32_
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::startClientDistantChatConnection(const std::string& hash,const std::string& pgp_id,const unsigned char *aes_key_buf)
|
void p3ChatService::startClientDistantChatConnection(const std::string& hash,const PGPIdType& pgp_id,const unsigned char *aes_key_buf)
|
||||||
{
|
{
|
||||||
DistantChatPeerInfo info ;
|
DistantChatPeerInfo info ;
|
||||||
|
|
||||||
|
@ -3654,7 +3675,7 @@ bool p3ChatService::getDistantChatInviteList(std::vector<DistantChatInviteInfo>&
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id)
|
bool p3ChatService::getDistantChatStatus(const std::string& hash,uint32_t& status,PGPIdType& pgp_id)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
@ -3679,6 +3700,7 @@ bool p3ChatService::closeDistantChatConnexion(const std::string& hash)
|
||||||
// - server needs to only close the window and let the tunnel die. But the window should only open if a message arrives.
|
// - server needs to only close the window and let the tunnel die. But the window should only open if a message arrives.
|
||||||
|
|
||||||
bool is_client = false ;
|
bool is_client = false ;
|
||||||
|
RsPeerId virtual_peer_id ;
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
@ -3691,6 +3713,8 @@ bool p3ChatService::closeDistantChatConnexion(const std::string& hash)
|
||||||
}
|
}
|
||||||
if(it->second.direction == RsTurtleGenericTunnelItem::DIRECTION_SERVER)
|
if(it->second.direction == RsTurtleGenericTunnelItem::DIRECTION_SERVER)
|
||||||
is_client = true ;
|
is_client = true ;
|
||||||
|
|
||||||
|
virtual_peer_id = it->second.virtual_peer_id ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_client)
|
if(is_client)
|
||||||
|
@ -3701,7 +3725,7 @@ bool p3ChatService::closeDistantChatConnexion(const std::string& hash)
|
||||||
|
|
||||||
cs->status_string = "" ;
|
cs->status_string = "" ;
|
||||||
cs->flags = RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_CLOSING_DISTANT_CONNECTION;
|
cs->flags = RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_CLOSING_DISTANT_CONNECTION;
|
||||||
cs->PeerId(hash);
|
cs->PeerId(virtual_peer_id);
|
||||||
|
|
||||||
sendTurtleData(cs) ; // that needs to be done off-mutex!
|
sendTurtleData(cs) ; // that needs to be done off-mutex!
|
||||||
|
|
||||||
|
@ -3725,10 +3749,17 @@ bool p3ChatService::closeDistantChatConnexion(const std::string& hash)
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::markDistantChatAsClosed(const std::string& hash)
|
void p3ChatService::markDistantChatAsClosed(const RsPeerId& vpid)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
std::map<std::string,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
|
||||||
|
std::string hash ;
|
||||||
|
if(!findHashForVirtualPeerId(vpid,hash))
|
||||||
|
{
|
||||||
|
std::cerr << "Cannot mark distant chat as closed for vpid " << vpid << ": not found." << std::endl;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
std::map<TurtleFileHash,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||||
|
|
||||||
if(it == _distant_chat_peers.end()) // server side. Nothing to do.
|
if(it == _distant_chat_peers.end()) // server side. Nothing to do.
|
||||||
{
|
{
|
||||||
|
@ -3742,7 +3773,7 @@ void p3ChatService::markDistantChatAsClosed(const std::string& hash)
|
||||||
bool p3ChatService::removeDistantChatInvite(const std::string& hash)
|
bool p3ChatService::removeDistantChatInvite(const std::string& hash)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
std::map<std::string,DistantChatInvite>::iterator it = _distant_chat_invites.find(hash) ;
|
std::map<TurtleFileHash,DistantChatInvite>::iterator it = _distant_chat_invites.find(hash) ;
|
||||||
|
|
||||||
if(it == _distant_chat_invites.end()) // server side. Nothing to do.
|
if(it == _distant_chat_invites.end()) // server side. Nothing to do.
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,8 @@ class p3LinkMgr;
|
||||||
class p3HistoryMgr;
|
class p3HistoryMgr;
|
||||||
class p3turtle ;
|
class p3turtle ;
|
||||||
|
|
||||||
|
typedef RsPeerId ChatLobbyVirtualPeerId ;
|
||||||
|
|
||||||
//!The basic Chat service.
|
//!The basic Chat service.
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -77,13 +79,13 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
* chat is sent to specifc peer
|
* chat is sent to specifc peer
|
||||||
* @param id peer to send chat msg to
|
* @param id peer to send chat msg to
|
||||||
*/
|
*/
|
||||||
bool sendPrivateChat(const std::string &id, const std::string &msg);
|
bool sendPrivateChat(const RsPeerId &id, const std::string &msg);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* can be used to send 'immediate' status msgs, these status updates are meant for immediate use by peer (not saved by rs)
|
* can be used to send 'immediate' status msgs, these status updates are meant for immediate use by peer (not saved by rs)
|
||||||
* e.g currently used to update user when a peer 'is typing' during a chat
|
* e.g currently used to update user when a peer 'is typing' during a chat
|
||||||
*/
|
*/
|
||||||
void sendStatusString(const std::string& peer_id,const std::string& status_str) ;
|
void sendStatusString(const RsPeerId& peer_id,const std::string& status_str) ;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* send to all peers online
|
* send to all peers online
|
||||||
|
@ -95,7 +97,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
* this retrieves custom status for a peers, generate a requests to the peer
|
* this retrieves custom status for a peers, generate a requests to the peer
|
||||||
* @param peer_id the id of the peer you want status string for
|
* @param peer_id the id of the peer you want status string for
|
||||||
*/
|
*/
|
||||||
std::string getCustomStateString(const std::string& peer_id) ;
|
std::string getCustomStateString(const RsPeerId& peer_id) ;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* sets the client's custom status, generates 'status available' item sent to all online peers
|
* sets the client's custom status, generates 'status available' item sent to all online peers
|
||||||
|
@ -111,7 +113,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
* its avatar, if not already available. Creates a new unsigned char array. It's the caller's
|
* its avatar, if not already available. Creates a new unsigned char array. It's the caller's
|
||||||
* responsibility to delete this ones used.
|
* responsibility to delete this ones used.
|
||||||
*/
|
*/
|
||||||
void getAvatarJpegData(const std::string& peer_id,unsigned char *& data,int& size) ;
|
void getAvatarJpegData(const RsPeerId& peer_id,unsigned char *& data,int& size) ;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the avatar data and size for client's account
|
* Sets the avatar data and size for client's account
|
||||||
|
@ -145,12 +147,12 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
/*!
|
/*!
|
||||||
* @param id's of available private chat messages
|
* @param id's of available private chat messages
|
||||||
*/
|
*/
|
||||||
bool getPrivateChatQueueIds(bool incoming, std::list<std::string> &ids);
|
bool getPrivateChatQueueIds(bool incoming, std::list<RsPeerId> &ids);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This retrieves all private chat msg items for peer
|
* This retrieves all private chat msg items for peer
|
||||||
*/
|
*/
|
||||||
bool getPrivateChatQueue(bool incoming, const std::string &id, std::list<ChatInfo> &chats);
|
bool getPrivateChatQueue(bool incoming, const RsPeerId &id, std::list<ChatInfo> &chats);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Checks message security, especially remove billion laughs attacks
|
* Checks message security, especially remove billion laughs attacks
|
||||||
|
@ -161,15 +163,15 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
/*!
|
/*!
|
||||||
* @param clear private chat queue
|
* @param clear private chat queue
|
||||||
*/
|
*/
|
||||||
bool clearPrivateChatQueue(bool incoming, const std::string &id);
|
bool clearPrivateChatQueue(bool incoming, const RsPeerId &id);
|
||||||
|
|
||||||
bool getVirtualPeerId(const ChatLobbyId& lobby_id, std::string& virtual_peer_id) ;
|
bool getVirtualPeerId(const ChatLobbyId& lobby_id, RsPeerId& virtual_peer_id) ;
|
||||||
bool isLobbyId(const std::string& virtual_peer_id, ChatLobbyId& lobby_id) ;
|
bool isLobbyId(const RsPeerId& virtual_peer_id, ChatLobbyId& lobby_id) ;
|
||||||
void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >& cl_infos) ;
|
void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >& cl_infos) ;
|
||||||
bool acceptLobbyInvite(const ChatLobbyId& id) ;
|
bool acceptLobbyInvite(const ChatLobbyId& id) ;
|
||||||
void denyLobbyInvite(const ChatLobbyId& id) ;
|
void denyLobbyInvite(const ChatLobbyId& id) ;
|
||||||
void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;
|
void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;
|
||||||
void invitePeerToLobby(const ChatLobbyId&, const std::string& peer_id,bool connexion_challenge = false) ;
|
void invitePeerToLobby(const ChatLobbyId&, const RsPeerId& peer_id,bool connexion_challenge = false) ;
|
||||||
void unsubscribeChatLobby(const ChatLobbyId& lobby_id) ;
|
void unsubscribeChatLobby(const ChatLobbyId& lobby_id) ;
|
||||||
bool setNickNameForChatLobby(const ChatLobbyId& lobby_id,const std::string& nick) ;
|
bool setNickNameForChatLobby(const ChatLobbyId& lobby_id,const std::string& nick) ;
|
||||||
bool getNickNameForChatLobby(const ChatLobbyId& lobby_id,std::string& nick) ;
|
bool getNickNameForChatLobby(const ChatLobbyId& lobby_id,std::string& nick) ;
|
||||||
|
@ -178,7 +180,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe);
|
void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe);
|
||||||
bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id);
|
bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id);
|
||||||
void sendLobbyStatusString(const ChatLobbyId& id,const std::string& status_string) ;
|
void sendLobbyStatusString(const ChatLobbyId& id,const std::string& status_string) ;
|
||||||
ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic, const std::list<std::string>& invited_friends,uint32_t privacy_type) ;
|
ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic, const std::list<RsPeerId>& invited_friends,uint32_t privacy_type) ;
|
||||||
|
|
||||||
void getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& public_lobbies) ;
|
void getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& public_lobbies) ;
|
||||||
bool joinVisibleChatLobby(const ChatLobbyId& id) ;
|
bool joinVisibleChatLobby(const ChatLobbyId& id) ;
|
||||||
|
@ -194,7 +196,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
virtual void saveDone();
|
virtual void saveDone();
|
||||||
virtual bool loadList(std::list<RsItem*>& load) ;
|
virtual bool loadList(std::list<RsItem*>& load) ;
|
||||||
|
|
||||||
bool isOnline(const std::string& id) ;
|
bool isOnline(const RsPeerId& id) ;
|
||||||
private:
|
private:
|
||||||
RsMutex mChatMtx;
|
RsMutex mChatMtx;
|
||||||
|
|
||||||
|
@ -211,14 +213,14 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
void addTimeShiftStatistics(int shift) ;
|
void addTimeShiftStatistics(int shift) ;
|
||||||
|
|
||||||
/// Send avatar info to peer in jpeg format.
|
/// Send avatar info to peer in jpeg format.
|
||||||
void sendAvatarJpegData(const std::string& peer_id) ;
|
void sendAvatarJpegData(const RsPeerId& peer_id) ;
|
||||||
|
|
||||||
/// Send custom state info to peer
|
/// Send custom state info to peer
|
||||||
void sendCustomState(const std::string& peer_id);
|
void sendCustomState(const RsPeerId& peer_id);
|
||||||
|
|
||||||
/// Receive the avatar in a chat item, with RS_CHAT_RECEIVE_AVATAR flag.
|
/// Receive the avatar in a chat item, with RS_CHAT_RECEIVE_AVATAR flag.
|
||||||
void receiveAvatarJpegData(RsChatAvatarItem *ci) ; // new method
|
void receiveAvatarJpegData(RsChatAvatarItem *ci) ; // new method
|
||||||
void receiveStateString(const std::string& id,const std::string& s) ;
|
void receiveStateString(const RsPeerId& id,const std::string& s) ;
|
||||||
|
|
||||||
/// methods for handling various Chat items.
|
/// methods for handling various Chat items.
|
||||||
bool handleRecvChatMsgItem(RsChatMsgItem *item) ; // returns false if the item should be deleted.
|
bool handleRecvChatMsgItem(RsChatMsgItem *item) ; // returns false if the item should be deleted.
|
||||||
|
@ -229,13 +231,13 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
void handleRecvChatLobbyEventItem(RsChatLobbyEventItem *item) ;
|
void handleRecvChatLobbyEventItem(RsChatLobbyEventItem *item) ;
|
||||||
|
|
||||||
/// Checks that the lobby object is not flooding a lobby.
|
/// Checks that the lobby object is not flooding a lobby.
|
||||||
bool locked_bouncingObjectCheck(RsChatLobbyBouncingObject *obj,const std::string& peer_id,uint32_t lobby_count) ;
|
bool locked_bouncingObjectCheck(RsChatLobbyBouncingObject *obj,const RsPeerId& peer_id,uint32_t lobby_count) ;
|
||||||
|
|
||||||
/// Sends a request for an avatar to the peer of given id
|
/// Sends a request for an avatar to the peer of given id
|
||||||
void sendAvatarRequest(const std::string& peer_id) ;
|
void sendAvatarRequest(const RsPeerId& peer_id) ;
|
||||||
|
|
||||||
/// Send a request for custom status string
|
/// Send a request for custom status string
|
||||||
void sendCustomStateRequest(const std::string& peer_id);
|
void sendCustomStateRequest(const RsPeerId& peer_id);
|
||||||
|
|
||||||
/// called as a proxy to sendItem(). Possibly splits item into multiple items of size lower than the maximum item size.
|
/// called as a proxy to sendItem(). Possibly splits item into multiple items of size lower than the maximum item size.
|
||||||
void checkSizeAndSendMessage(RsChatLobbyMsgItem *item) ;
|
void checkSizeAndSendMessage(RsChatLobbyMsgItem *item) ;
|
||||||
|
@ -246,15 +248,15 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
bool locked_checkAndRebuildPartialMessage_deprecated(RsChatMsgItem*) ;
|
bool locked_checkAndRebuildPartialMessage_deprecated(RsChatMsgItem*) ;
|
||||||
|
|
||||||
/// receive and handle chat lobby item
|
/// receive and handle chat lobby item
|
||||||
bool recvLobbyChat(RsChatLobbyMsgItem*,const std::string& src_peer_id) ;
|
bool recvLobbyChat(RsChatLobbyMsgItem*,const RsPeerId& src_peer_id) ;
|
||||||
bool sendLobbyChat(const std::string &id, const std::string&, const ChatLobbyId&) ;
|
bool sendLobbyChat(const RsPeerId &id, const std::string&, const ChatLobbyId&) ;
|
||||||
void handleRecvLobbyInvite(RsChatLobbyInviteItem*) ;
|
void handleRecvLobbyInvite(RsChatLobbyInviteItem*) ;
|
||||||
void checkAndRedirectMsgToLobby(RsChatMsgItem*) ;
|
void checkAndRedirectMsgToLobby(RsChatMsgItem*) ;
|
||||||
void handleConnectionChallenge(RsChatLobbyConnectChallengeItem *item) ;
|
void handleConnectionChallenge(RsChatLobbyConnectChallengeItem *item) ;
|
||||||
void sendConnectionChallenge(ChatLobbyId id) ;
|
void sendConnectionChallenge(ChatLobbyId id) ;
|
||||||
void handleFriendUnsubscribeLobby(RsChatLobbyUnsubscribeItem*) ;
|
void handleFriendUnsubscribeLobby(RsChatLobbyUnsubscribeItem*) ;
|
||||||
void cleanLobbyCaches() ;
|
void cleanLobbyCaches() ;
|
||||||
bool bounceLobbyObject(RsChatLobbyBouncingObject *obj, const std::string& peer_id) ;
|
bool bounceLobbyObject(RsChatLobbyBouncingObject *obj, const RsPeerId& peer_id) ;
|
||||||
|
|
||||||
void sendLobbyStatusItem(const ChatLobbyId&, int type, const std::string& status_string) ;
|
void sendLobbyStatusItem(const ChatLobbyId&, int type, const std::string& status_string) ;
|
||||||
void sendLobbyStatusPeerLiving(const ChatLobbyId& lobby_id) ;
|
void sendLobbyStatusPeerLiving(const ChatLobbyId& lobby_id) ;
|
||||||
|
@ -265,8 +267,8 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
|
|
||||||
bool locked_initLobbyBouncableObject(const ChatLobbyId& id,RsChatLobbyBouncingObject&) ;
|
bool locked_initLobbyBouncableObject(const ChatLobbyId& id,RsChatLobbyBouncingObject&) ;
|
||||||
|
|
||||||
static std::string makeVirtualPeerId(ChatLobbyId) ;
|
static ChatLobbyVirtualPeerId makeVirtualPeerId(ChatLobbyId) ;
|
||||||
static uint64_t makeConnexionChallengeCode(const std::string& peer_id,ChatLobbyId lobby_id,ChatLobbyMsgId msg_id) ;
|
static uint64_t makeConnexionChallengeCode(const RsPeerId& peer_id,ChatLobbyId lobby_id,ChatLobbyMsgId msg_id) ;
|
||||||
|
|
||||||
void locked_printDebugInfo() const ;
|
void locked_printDebugInfo() const ;
|
||||||
RsChatAvatarItem *makeOwnAvatarItem() ;
|
RsChatAvatarItem *makeOwnAvatarItem() ;
|
||||||
|
@ -280,28 +282,28 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
std::list<RsChatMsgItem *> privateOutgoingList;
|
std::list<RsChatMsgItem *> privateOutgoingList;
|
||||||
|
|
||||||
AvatarInfo *_own_avatar ;
|
AvatarInfo *_own_avatar ;
|
||||||
std::map<std::string,AvatarInfo *> _avatars ;
|
std::map<RsPeerId,AvatarInfo *> _avatars ;
|
||||||
std::map<std::string,RsChatMsgItem *> _pendingPartialMessages ;
|
std::map<RsPeerId,RsChatMsgItem *> _pendingPartialMessages ;
|
||||||
std::map<ChatLobbyMsgId,std::vector<RsChatLobbyMsgItem*> > _pendingPartialLobbyMessages ; // should be used for all chat msgs after version updgrade
|
std::map<ChatLobbyMsgId,std::vector<RsChatLobbyMsgItem*> > _pendingPartialLobbyMessages ; // should be used for all chat msgs after version updgrade
|
||||||
std::string _custom_status_string ;
|
std::string _custom_status_string ;
|
||||||
std::map<std::string,StateStringInfo> _state_strings ;
|
std::map<RsPeerId,StateStringInfo> _state_strings ;
|
||||||
|
|
||||||
class ChatLobbyEntry: public ChatLobbyInfo
|
class ChatLobbyEntry: public ChatLobbyInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::map<ChatLobbyMsgId,time_t> msg_cache ;
|
std::map<ChatLobbyMsgId,time_t> msg_cache ;
|
||||||
std::string virtual_peer_id ;
|
RsPeerId virtual_peer_id ;
|
||||||
int connexion_challenge_count ;
|
int connexion_challenge_count ;
|
||||||
time_t last_connexion_challenge_time ;
|
time_t last_connexion_challenge_time ;
|
||||||
time_t last_keep_alive_packet_time ;
|
time_t last_keep_alive_packet_time ;
|
||||||
std::set<std::string> previously_known_peers ;
|
std::set<RsPeerId> previously_known_peers ;
|
||||||
uint32_t flags ;
|
uint32_t flags ;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<ChatLobbyId,ChatLobbyEntry> _chat_lobbys ;
|
std::map<ChatLobbyId,ChatLobbyEntry> _chat_lobbys ;
|
||||||
std::map<ChatLobbyId,ChatLobbyInvite> _lobby_invites_queue ;
|
std::map<ChatLobbyId,ChatLobbyInvite> _lobby_invites_queue ;
|
||||||
std::map<ChatLobbyId,VisibleChatLobbyRecord> _visible_lobbies ;
|
std::map<ChatLobbyId,VisibleChatLobbyRecord> _visible_lobbies ;
|
||||||
std::map<std::string,ChatLobbyId> _lobby_ids ;
|
std::map<ChatLobbyVirtualPeerId,ChatLobbyId> _lobby_ids ;
|
||||||
std::map<ChatLobbyId,ChatLobbyFlags> _known_lobbies_flags ; // flags for all lobbies, including the ones that are not known. So we can't
|
std::map<ChatLobbyId,ChatLobbyFlags> _known_lobbies_flags ; // flags for all lobbies, including the ones that are not known. So we can't
|
||||||
// store them in _chat_lobbies (subscribed lobbies) nor _visible_lobbies.
|
// store them in _chat_lobbies (subscribed lobbies) nor _visible_lobbies.
|
||||||
// Known flags:
|
// Known flags:
|
||||||
|
@ -325,21 +327,21 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
// Creates the invite if the public key of the distant peer is available.
|
// Creates the invite if the public key of the distant peer is available.
|
||||||
// Om success, stores the invite in the map above, so that we can respond to tunnel requests.
|
// Om success, stores the invite in the map above, so that we can respond to tunnel requests.
|
||||||
//
|
//
|
||||||
bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,TurtleFileHash& hash) ;
|
bool createDistantChatInvite(const PGPIdType& pgp_id,time_t time_of_validity,TurtleFileHash& hash) ;
|
||||||
bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) ;
|
bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) ;
|
||||||
bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t time_of_validity,std::string& hash,uint32_t& error_code) ; // from encrypted data
|
bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t time_of_validity,std::string& hash,uint32_t& error_code) ; // from encrypted data
|
||||||
bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) ; // from known hash of a decrypted link
|
bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) ; // from known hash of a decrypted link
|
||||||
bool closeDistantChatConnexion(const std::string& hash) ;
|
bool closeDistantChatConnexion(const std::string& hash) ;
|
||||||
bool removeDistantChatInvite(const std::string& hash) ;
|
bool removeDistantChatInvite(const std::string& hash) ;
|
||||||
|
|
||||||
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) ;
|
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,PGPIdType& pgp_id) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct DistantChatInvite
|
struct DistantChatInvite
|
||||||
{
|
{
|
||||||
unsigned char aes_key[16] ;
|
unsigned char aes_key[16] ;
|
||||||
std::string encrypted_radix64_string ;
|
std::string encrypted_radix64_string ;
|
||||||
std::string destination_pgp_id ;
|
PGPIdType destination_pgp_id ;
|
||||||
time_t time_of_validity ;
|
time_t time_of_validity ;
|
||||||
time_t last_hit_time ;
|
time_t last_hit_time ;
|
||||||
uint32_t flags ;
|
uint32_t flags ;
|
||||||
|
@ -349,8 +351,8 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
time_t last_contact ; // used to send keep alive packets
|
time_t last_contact ; // used to send keep alive packets
|
||||||
unsigned char aes_key[16] ; // key to encrypt packets
|
unsigned char aes_key[16] ; // key to encrypt packets
|
||||||
uint32_t status ; // info: do we have a tunnel ?
|
uint32_t status ; // info: do we have a tunnel ?
|
||||||
std::string virtual_peer_id; // given by the turtle router. Identifies the tunnel.
|
RsPeerId virtual_peer_id; // given by the turtle router. Identifies the tunnel.
|
||||||
std::string pgp_id ; // pgp id of the peer we're talking to.
|
PGPIdType pgp_id ; // pgp id of the peer we're talking to.
|
||||||
RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server.
|
RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -361,7 +363,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
|
|
||||||
// This maps contains the current peers to talk to with distant chat.
|
// This maps contains the current peers to talk to with distant chat.
|
||||||
//
|
//
|
||||||
std::map<std::string,DistantChatPeerInfo> _distant_chat_peers ;
|
std::map<TurtleFileHash,DistantChatPeerInfo> _distant_chat_peers ;
|
||||||
|
|
||||||
// List of items to be sent asap. Used to store items that we cannot pass directly to
|
// List of items to be sent asap. Used to store items that we cannot pass directly to
|
||||||
// sendTurtleData(), because of Mutex protection.
|
// sendTurtleData(), because of Mutex protection.
|
||||||
|
@ -370,12 +372,13 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||||
|
|
||||||
// Overloaded from RsTurtleClientService
|
// Overloaded from RsTurtleClientService
|
||||||
|
|
||||||
virtual bool handleTunnelRequest(const std::string& hash,const std::string& peer_id) ;
|
virtual bool handleTunnelRequest(const std::string& hash,const RsPeerId& peer_id) ;
|
||||||
virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const std::string& hash,const std::string& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const std::string& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
||||||
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
||||||
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ;
|
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ;
|
||||||
void markDistantChatAsClosed(const TurtleFileHash& hash) ;
|
void markDistantChatAsClosed(const TurtleVirtualPeerId& vpid) ;
|
||||||
void startClientDistantChatConnection(const std::string& hash,const std::string& pgp_id,const unsigned char *aes_key_buf) ;
|
void startClientDistantChatConnection(const std::string& hash,const PGPIdType& pgp_id,const unsigned char *aes_key_buf) ;
|
||||||
|
bool findHashForVirtualPeerId(const TurtleVirtualPeerId& pid,std::string& hash) ;
|
||||||
|
|
||||||
// Utility functions
|
// Utility functions
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ int checkOutgoingMessages();
|
||||||
struct DistantMessengingContact
|
struct DistantMessengingContact
|
||||||
{
|
{
|
||||||
time_t last_hit_time ;
|
time_t last_hit_time ;
|
||||||
std::string virtual_peer_id ;
|
RsPeerId virtual_peer_id ;
|
||||||
uint32_t status ;
|
uint32_t status ;
|
||||||
bool pending_messages ;
|
bool pending_messages ;
|
||||||
};
|
};
|
||||||
|
@ -132,7 +132,7 @@ int checkOutgoingMessages();
|
||||||
|
|
||||||
void enableDistantMessaging(bool b) ;
|
void enableDistantMessaging(bool b) ;
|
||||||
bool distantMessagingEnabled() ;
|
bool distantMessagingEnabled() ;
|
||||||
bool getDistantMessageHash(const std::string& pgp_id,std::string& hash) ;
|
bool getDistantMessageHash(const PGPIdType& pgp_id,std::string& hash) ;
|
||||||
|
|
||||||
void sendPrivateMsgItem(RsMsgItem *) ;
|
void sendPrivateMsgItem(RsMsgItem *) ;
|
||||||
|
|
||||||
|
@ -150,14 +150,14 @@ int checkOutgoingMessages();
|
||||||
#ifdef GROUTER
|
#ifdef GROUTER
|
||||||
virtual void receiveGRouterData(RsGRouterGenericDataItem *item, const GRouterKeyId& key) ;
|
virtual void receiveGRouterData(RsGRouterGenericDataItem *item, const GRouterKeyId& key) ;
|
||||||
#endif
|
#endif
|
||||||
virtual bool handleTunnelRequest(const std::string& hash,const std::string& peer_id) ;
|
virtual bool handleTunnelRequest(const std::string& hash,const RsPeerId& peer_id) ;
|
||||||
virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const std::string& hash,const std::string& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const std::string& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
||||||
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
||||||
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ;
|
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ;
|
||||||
|
|
||||||
// Utility functions
|
// Utility functions
|
||||||
|
|
||||||
bool encryptMessage(const std::string& pgp_id,RsMsgItem *msg) ;
|
bool encryptMessage(const PGPIdType& pgp_id,RsMsgItem *msg) ;
|
||||||
|
|
||||||
void manageDistantPeers() ;
|
void manageDistantPeers() ;
|
||||||
void sendTurtleData(const std::string& hash,RsMsgItem *) ;
|
void sendTurtleData(const std::string& hash,RsMsgItem *) ;
|
||||||
|
@ -181,7 +181,7 @@ bool checkAndRebuildPartialMessage(RsMsgItem*) ;
|
||||||
|
|
||||||
void initRsMI(RsMsgItem *msg, MessageInfo &mi);
|
void initRsMI(RsMsgItem *msg, MessageInfo &mi);
|
||||||
void initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis);
|
void initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis);
|
||||||
RsMsgItem *initMIRsMsg(MessageInfo &info, const std::string &to);
|
RsMsgItem *initMIRsMsg(MessageInfo &info, const RsPeerId &to);
|
||||||
|
|
||||||
void initStandardTagTypes();
|
void initStandardTagTypes();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue