mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-14 17:15:47 -04:00
Addition of new channels service.
* Addition of channels serialiser. * New channels interface. * Added Channels to startup code. * New CFG Id for serialiser. * Cleanup of old channels stuff from interfaces. * Cleanup of messages as well. * Changed file size to uint64_t git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@620 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d8def217fa
commit
b9ccbd54e8
18 changed files with 964 additions and 310 deletions
|
@ -37,221 +37,6 @@ const int p3facemsgzone = 11453;
|
|||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
/****************************************/
|
||||
/****************************************/
|
||||
int RsServer::ChannelCreateNew(ChannelInfo &info)
|
||||
{
|
||||
UpdateAllChannels();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/****************************************/
|
||||
int RsServer::ChannelSendMsg(ChannelInfo &info)
|
||||
{
|
||||
UpdateAllChannels();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/****************************************/
|
||||
int RsServer::UpdateAllChannels()
|
||||
{
|
||||
|
||||
#ifdef PQI_USE_CHANNELS
|
||||
|
||||
std::list<pqichannel *> chanlist;
|
||||
std::list<pqichannel *>::iterator cit;
|
||||
|
||||
NotifyBase &cb = getNotify();
|
||||
cb.notifyListPreChange(NOTIFY_LIST_CHANNELLIST, NOTIFY_TYPE_MOD);
|
||||
|
||||
RsIface &iface = getIface();
|
||||
|
||||
/* lock Mutexes */
|
||||
lockRsCore(); /* LOCK */
|
||||
iface.lockData(); /* LOCK */
|
||||
|
||||
std::map<RsChanId, ChannelInfo> &chs = iface.mChannelMap;
|
||||
|
||||
server->getAvailableChannels(chanlist);
|
||||
|
||||
/* empty the old list */
|
||||
chs.clear();
|
||||
|
||||
for(cit = chanlist.begin(); cit != chanlist.end(); ++cit)
|
||||
{
|
||||
ChannelInfo ci;
|
||||
initRsCI(*cit, ci);
|
||||
intAddChannel(ci);
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "fltkserver::UpdateAllChannels() Added: ";
|
||||
out << ci;
|
||||
pqioutput(PQL_DEBUG_BASIC, p3facemsgzone, out.str());
|
||||
}
|
||||
|
||||
/* then add msgs */
|
||||
std::list<chanMsgSummary> summarylist;
|
||||
std::list<chanMsgSummary>::iterator mit;
|
||||
|
||||
channelSign sign = (*cit)->getSign();
|
||||
server->getChannelMsgList(sign, summarylist);
|
||||
|
||||
for(mit = summarylist.begin(); mit != summarylist.end(); mit++)
|
||||
{
|
||||
channelMsg *cm = NULL;
|
||||
cm = server->getChannelMsg(sign, mit->mh);
|
||||
|
||||
MessageInfo msg;
|
||||
|
||||
initRsCMI(*cit, cm, msg);
|
||||
// the files....
|
||||
PQChanItem::FileList::const_iterator it;
|
||||
for(it = cm->msg->files.begin(); it != cm->msg->files.end(); ++it)
|
||||
{
|
||||
FileInfo file;
|
||||
|
||||
/* add to the message */
|
||||
//ChanFileDisItem *cfdi = new ChanFileDisItem(it->name, it->size);
|
||||
initRsCMFI(*cit, &(*mit), &(*it), file);
|
||||
msg.files.push_back(file);
|
||||
|
||||
msg.size += file.size;
|
||||
msg.count++;
|
||||
} // files loop.
|
||||
|
||||
ci.size += msg.size;
|
||||
ci.count += ci.count;
|
||||
|
||||
/* add the Msg? */
|
||||
intAddChannelMsg(ci.chanId, msg);
|
||||
|
||||
} // msg loop
|
||||
|
||||
} // channel loop.
|
||||
|
||||
/* Notify of Changes */
|
||||
iface.setChanged(RsIface::Channel);
|
||||
|
||||
/* release Mutexes */
|
||||
iface.unlockData(); /* UNLOCK */
|
||||
unlockRsCore(); /* UNLOCK */
|
||||
|
||||
cb.notifyListChange(NOTIFY_LIST_CHANNELLIST, NOTIFY_TYPE_MOD);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**** HELPER FNS For Chat/Msg/Channel Lists ************
|
||||
*
|
||||
* The iface->Mutex is required to be locked
|
||||
* for intAddChannel / intAddChannelMsg.
|
||||
*/
|
||||
|
||||
#ifdef PQI_USE_CHANNELS
|
||||
|
||||
int RsServer::intAddChannel(ChannelInfo &info)
|
||||
{
|
||||
RsIface &iface = getIface();
|
||||
|
||||
std::map<RsChanId, ChannelInfo> &chs = iface.mChannelMap;
|
||||
chs[info.chanId] = info;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int RsServer::intAddChannelMsg(RsChanId id, MessageInfo &msg)
|
||||
{
|
||||
RsIface &iface = getIface();
|
||||
|
||||
std::map<RsChanId, ChannelInfo> &chs = iface.mChannelMap;
|
||||
std::map<RsChanId, ChannelInfo>::iterator it = chs.find(id);
|
||||
if (it != chs.end())
|
||||
{
|
||||
/* add the message */
|
||||
/*
|
||||
std::map<MsgId, MessageInfo> &msgs =
|
||||
it -> second.msglist;
|
||||
msgs[MsgId] = msg;
|
||||
*/
|
||||
std::list<MessageInfo> &msgs =
|
||||
it -> second.msglist;
|
||||
msgs.push_back(msg);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
RsChanId RsServer::signToChanId(const channelSign &cs) const
|
||||
{
|
||||
/* hackish here */
|
||||
RsChanId id;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < CHAN_SIGN_SIZE; i++) /* 16 Bytes XXX Must be equal! */
|
||||
id.data[i] = cs.sign[i];
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void RsServer::initRsCI(pqichannel *in, ChannelInfo &out)
|
||||
{
|
||||
out.chanId = signToChanId(in -> getSign());
|
||||
out.mode = in -> getMode();
|
||||
out.rank = in -> getRanking();
|
||||
out.chanName = in -> getName();
|
||||
out.count = in -> getMsgCount();
|
||||
/*
|
||||
out.size = in -> getMsgSize();
|
||||
*/
|
||||
}
|
||||
|
||||
void RsServer::initRsCMI(pqichannel *chan, channelMsg *cm, MessageInfo &msg)
|
||||
{
|
||||
msg.title = cm->msg->title;
|
||||
msg.msg = cm->msg->msg;
|
||||
|
||||
int i;
|
||||
MsgHash h = getMsgHash(cm->msg); /* call from p3channel.h */
|
||||
/* Copy MsgId over */
|
||||
for(i = 0; i < CHAN_SIGN_SIZE; i++) /* 16 Bytes XXX Must be equal! */
|
||||
msg.msgId.data[i] = h.sign[i];
|
||||
|
||||
/* init size to zero */
|
||||
msg.size = 0;
|
||||
msg.count = 0;
|
||||
}
|
||||
|
||||
void RsServer::initRsCMFI(pqichannel *chan, chanMsgSummary *msg,
|
||||
const PQChanItem::FileItem *cfdi,
|
||||
FileInfo &file)
|
||||
{
|
||||
file.searchId = 0;
|
||||
file.path = "";
|
||||
file.fname = cfdi -> name;
|
||||
file.hash = cfdi -> hash;
|
||||
file.ext = "";
|
||||
file.size = cfdi -> size;
|
||||
file.inRecommend = false;
|
||||
|
||||
/* check the status */
|
||||
file.status = FileInfo::kRsFiStatusNone;
|
||||
/* cfdi -> status; */
|
||||
if (file.status > FileInfo::kRsFiStatusNone)
|
||||
{
|
||||
intCheckFileStatus(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
file.avail = 0;
|
||||
file.rank = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void RsServer::intCheckFileStatus(FileInfo &file)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue