mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-10 10:05:19 -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)
|
||||
{
|
||||
|
|
|
@ -192,9 +192,6 @@ void RsServer::run()
|
|||
//std::cerr << "RsServer::run() UpdateAllTransfers()" << std::endl;
|
||||
UpdateAllTransfers();
|
||||
|
||||
//std::cerr << "RsServer::run() UpdateAllChannels()" << std::endl;
|
||||
UpdateAllChannels();
|
||||
|
||||
//std::cerr << "RsServer::run() ";
|
||||
//std::cerr << "UpdateRemotePeople()"<<std::endl;
|
||||
//UpdateRemotePeople();
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "services/p3ranking.h"
|
||||
#include "services/p3photoservice.h"
|
||||
#include "services/p3forums.h"
|
||||
#include "services/p3channels.h"
|
||||
#include "services/p3status.h"
|
||||
#include "services/p3Qblog.h"
|
||||
|
||||
|
@ -613,6 +614,14 @@ int RsServer::StartupRetroShare(RsInit *config)
|
|||
mCacheStrapper -> addCachePair(cp4);
|
||||
pqih -> addService(mForums); /* This must be also ticked as a service */
|
||||
|
||||
p3Channels *mChannels = new p3Channels(RS_SERVICE_TYPE_CHANNEL,
|
||||
mCacheStrapper, mCacheTransfer,
|
||||
localcachedir, remotecachedir, localcachedir);
|
||||
|
||||
CachePair cp5(mChannels, mChannels, CacheId(RS_SERVICE_TYPE_CHANNEL, 0));
|
||||
mCacheStrapper -> addCachePair(cp5);
|
||||
pqih -> addService(mChannels); /* This must be also ticked as a service */
|
||||
|
||||
#else
|
||||
mQblog = NULL;
|
||||
//mForums = NULL;
|
||||
|
@ -641,6 +650,7 @@ int RsServer::StartupRetroShare(RsInit *config)
|
|||
mConfigMgr->addConfiguration("ranklink.cfg", mRanking);
|
||||
#ifndef RS_RELEASE
|
||||
mConfigMgr->addConfiguration("forums.cfg", mForums);
|
||||
mConfigMgr->addConfiguration("channels.cfg", mChannels);
|
||||
#endif
|
||||
|
||||
/**************************************************************************/
|
||||
|
@ -770,6 +780,7 @@ int RsServer::StartupRetroShare(RsInit *config)
|
|||
rsGameLauncher = gameLauncher;
|
||||
rsPhoto = new p3Photo(photoService);
|
||||
rsForums = mForums;
|
||||
rsChannels = mChannels;
|
||||
rsStatus = new p3Status();
|
||||
rsQblog = new p3Blog(mQblog);
|
||||
|
||||
|
@ -777,6 +788,7 @@ int RsServer::StartupRetroShare(RsInit *config)
|
|||
rsGameLauncher = NULL;
|
||||
rsPhoto = NULL;
|
||||
rsForums = NULL;
|
||||
rsChannels = NULL;
|
||||
rsStatus = NULL;
|
||||
rsQblog = NULL;
|
||||
#endif
|
||||
|
|
|
@ -162,10 +162,6 @@ int UpdateRemotePeople();
|
|||
/* p3face-msg Operations */
|
||||
|
||||
public:
|
||||
/* Channel Items */
|
||||
virtual int ChannelCreateNew(ChannelInfo &info);
|
||||
virtual int ChannelSendMsg(ChannelInfo &info);
|
||||
|
||||
/* Flagging Persons / Channels / Files in or out of a set (CheckLists) */
|
||||
virtual int SetInChat(std::string id, bool in); /* friend : chat msgs */
|
||||
virtual int SetInMsg(std::string id, bool in); /* friend : msg receipients */
|
||||
|
@ -186,26 +182,6 @@ virtual bool IsInMsg(std::string id); /* friend : msg recpts*/
|
|||
|
||||
std::list<std::string> mInChatList, mInMsgList;
|
||||
|
||||
/* Internal Update Iface Fns */
|
||||
int UpdateAllChannels();
|
||||
|
||||
|
||||
#ifdef PQI_USE_CHANNELS
|
||||
/* Internal Helper Fns */
|
||||
RsChanId signToChanId(const channelSign &cs) const;
|
||||
|
||||
|
||||
int intAddChannel(ChannelInfo &info);
|
||||
int intAddChannelMsg(RsChanId id, MessageInfo &msg);
|
||||
|
||||
|
||||
void initRsCI(pqichannel *in, ChannelInfo &out);
|
||||
void initRsCMI(pqichannel *chan, channelMsg *cm, MessageInfo &msg);
|
||||
void initRsCMFI(pqichannel *chan, chanMsgSummary *msg,
|
||||
const PQChanItem::FileItem *cfdi, FileInfo &file);
|
||||
|
||||
#endif
|
||||
|
||||
void intCheckFileStatus(FileInfo &file);
|
||||
|
||||
void initRsMI(RsMsgItem *msg, MessageInfo &mi);
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "rsserver/p3face.h"
|
||||
#include "util/rsdir.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
@ -37,8 +35,13 @@ const int p3facemsgzone = 11453;
|
|||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "rsiface/rstypes.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "rsserver/p3msgs.h"
|
||||
|
||||
#include "services/p3msgservice.h"
|
||||
#include "services/p3chatservice.h"
|
||||
|
||||
/* external reference point */
|
||||
RsMsgs *rsMsgs = NULL;
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ class p3AuthMgr;
|
|||
class p3MsgService;
|
||||
class p3ChatService;
|
||||
|
||||
class RsChatItem;
|
||||
|
||||
class p3Msgs: public RsMsgs
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -107,15 +107,6 @@ std::ostream &operator<<(std::ostream &out, const ChatInfo &info)
|
|||
|
||||
#endif
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const ChannelInfo &info)
|
||||
{
|
||||
out << "ChannelInfo(TODO)";
|
||||
out << std::endl;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int DirInfo::merge(const DirInfo &udir)
|
||||
{
|
||||
/* add in the data from the udir */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue