* fixed, transfer start when subscribing to channel.

* cleaned up p3distrib callbacks.
 * added holdQueue for transfer startup in controller. 
 * fixed partial resume.
 * updated Mac script to only build library.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@828 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-11-21 00:10:59 +00:00
parent 71797d6f70
commit c46b823261
12 changed files with 222 additions and 141 deletions

View file

@ -294,58 +294,16 @@ bool p3Channels::channelSubscribe(std::string cId, bool subscribe)
/***************************************************************************************/
/****************** Event Feedback (Overloaded form p3distrib) *************************/
/***************************************************************************************/
#include "pqi/pqinotify.h"
bool p3Channels::locked_eventUpdateGroup(GroupInfo *info, bool isNew)
{
std::string grpId = info->grpId;
std::string msgId;
std::string nullId;
std::cerr << "p3Channels::locked_eventUpdateGroup() ";
std::cerr << grpId;
std::cerr << " flags:" << info->flags;
std::cerr << std::endl;
if (isNew)
{
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_CHAN_NEW, grpId, msgId, nullId);
}
else
{
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_CHAN_UPDATE, grpId, msgId, nullId);
}
if (info->flags & RS_DISTRIB_SUBSCRIBED)
// || (info->flags & RS_DISTRIB_SUBSCRIBED))
{
std::string channeldir = mChannelsDir + "/" + grpId;
std::cerr << "p3Channels::locked_eventUpdateGroup() ";
std::cerr << " creating directory: " << channeldir;
std::cerr << std::endl;
/* create chanDir */
if (!RsDirUtil::checkCreateDirectory(channeldir))
{
std::cerr << "p3Channels::locked_eventUpdateGroup() ";
std::cerr << "Failed to create Channels Directory: ";
std::cerr << channeldir;
std::cerr << std::endl;
}
}
return true;
}
/* only download in the first week of channel
* older stuff can be manually downloaded.
*/
const uint32_t DOWNLOAD_PERIOD = 7 * 24 * 3600;
/* This is called when we receive a msg, and also recalled
* on a subscription to a channel..
*/
bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std::string id)
{
std::string grpId = msg->grpId;
@ -368,9 +326,6 @@ bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std
/* request the files
* NB: This will result in duplicates.
* it is upto ftserver/ftcontroller/ftextralist
*
* download, then add to
*
* */
//bool download = (grp->flags & (RS_DISTRIB_ADMIN |
@ -408,6 +363,8 @@ bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std
/* download it ... and flag for ExtraList
* don't do pre-search check as FileRequest does it better
*
* FileRequest will ignore request if file is already indexed.
*/
std::cerr << "p3Channels::locked_eventDuplicateMsg() ";
@ -424,6 +381,7 @@ bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std
return true;
}
#include "pqi/pqinotify.h"
bool p3Channels::locked_eventNewMsg(GroupInfo *grp, RsDistribMsg *msg, std::string id)
{
@ -449,31 +407,62 @@ bool p3Channels::locked_eventNewMsg(GroupInfo *grp, RsDistribMsg *msg, std::stri
}
void p3Channels::locked_notifyGroupChanged(GroupInfo &grp)
void p3Channels::locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags)
{
/* create directory if needed */
if (grp.flags & RS_DISTRIB_SUBSCRIBED)
std::string grpId = grp.grpId;
std::string msgId;
std::string nullId;
std::cerr << "p3Channels::locked_eventUpdateGroup() ";
std::cerr << grpId;
std::cerr << " flags:" << grp.flags;
std::cerr << std::endl;
switch(flags)
{
std::string channeldir = mChannelsDir + "/" + grp.grpId;
case GRP_NEW_UPDATE:
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_CHAN_NEW, grpId, msgId, nullId);
break;
case GRP_UPDATE:
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_CHAN_UPDATE, grpId, msgId, nullId);
break;
case GRP_LOAD_KEY:
break;
case GRP_NEW_MSG:
break;
case GRP_SUBSCRIBED:
break;
{
std::string channeldir = mChannelsDir + "/" + grpId;
std::cerr << "p3Channels::locked_notifyGroupChanged() ";
std::cerr << " creating directory: " << channeldir;
std::cerr << std::endl;
/* create chanDir */
if (!RsDirUtil::checkCreateDirectory(channeldir))
{
std::cerr << "p3Channels::channelSubscribe()";
std::cerr << " Failed to create Channels Directory: ";
std::cerr << channeldir;
std::cerr << std::endl;
}
else
{
std::cerr << "p3Channels::channelSubscribe()";
std::cerr << " Created: ";
std::cerr << "p3Channels::locked_notifyGroupChanged() ";
std::cerr << "Failed to create Channels Directory: ";
std::cerr << channeldir;
std::cerr << std::endl;
}
/* check if downloads need to be started? */
}
return p3GroupDistrib::locked_notifyGroupChanged(grp);
break;
case GRP_UNSUBSCRIBED:
/* won't stop downloads... */
break;
}
return p3GroupDistrib::locked_notifyGroupChanged(grp, flags);
}

View file

@ -63,7 +63,7 @@ virtual bool channelSubscribe(std::string cId, bool subscribe);
/***************************************************************************************/
protected:
virtual bool locked_eventUpdateGroup(GroupInfo *, bool isNew);
virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags);
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string);
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string);
@ -77,7 +77,6 @@ virtual bool locked_checkDistribMsg(RsDistribMsg *msg);
virtual RsDistribGrp *locked_createPublicDistribGrp(GroupInfo &info);
virtual RsDistribGrp *locked_createPrivateDistribGrp(GroupInfo &info);
virtual void locked_notifyGroupChanged(GroupInfo &info);
/****************************************/

View file

@ -434,9 +434,11 @@ void p3GroupDistrib::loadGroup(RsDistribGrp *newGrp)
else
{
/* Callback for any derived classes */
locked_eventUpdateGroup(&(it->second), isNew);
locked_notifyGroupChanged(it->second);
if (isNew)
locked_notifyGroupChanged(it->second, GRP_NEW_UPDATE);
else
locked_notifyGroupChanged(it->second, GRP_UPDATE);
}
#ifdef DISTRIB_DEBUG
@ -511,7 +513,7 @@ void p3GroupDistrib::loadGroupKey(RsDistribGrpKey *newKey)
if (updateOk)
{
locked_notifyGroupChanged(it->second);
locked_notifyGroupChanged(it->second, GRP_LOAD_KEY);
}
#ifdef DISTRIB_DEBUG
@ -638,14 +640,18 @@ void p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, std::string src, bool l
}
else
{
/* Note it makes it very difficult to republish msg - if we have
* deleted the signed version... The load of old messages will occur
* at next startup. And publication will happen then too.
*/
#ifdef DISTRIB_DEBUG
std::cerr << "p3GroupDistrib::loadMsg() Deleted Original Msg (No Publish)";
std::cerr << std::endl;
#endif
delete newMsg;
}
locked_notifyGroupChanged(git->second);
locked_notifyGroupChanged(git->second, GRP_NEW_MSG);
}
@ -1112,8 +1118,28 @@ bool p3GroupDistrib::subscribeToGroup(std::string grpId, bool subscribe)
{
git->second.flags |= RS_DISTRIB_SUBSCRIBED;
locked_notifyGroupChanged(git->second);
locked_notifyGroupChanged(git->second, GRP_SUBSCRIBED);
mGroupsRepublish = true;
/* reprocess groups messages .... so actions can be taken (by inherited)
* This could be an very expensive operation! .... but they asked for it.
*
* Hopefully a LoadList call will have on existing messages!
*/
std::map<std::string, RsDistribMsg *>::iterator mit;
std::list<std::string>::iterator pit;
/* assume that each peer can provide all of them */
for(mit = git->second.msgs.begin();
mit != git->second.msgs.end(); mit++)
{
for(pit = git->second.sources.begin();
pit != git->second.sources.end(); pit++)
{
locked_eventDuplicateMsg(&(git->second), mit->second, *pit);
}
}
}
}
else
@ -1122,7 +1148,7 @@ bool p3GroupDistrib::subscribeToGroup(std::string grpId, bool subscribe)
{
git->second.flags &= (~RS_DISTRIB_SUBSCRIBED);
locked_notifyGroupChanged(git->second);
locked_notifyGroupChanged(git->second, GRP_UNSUBSCRIBED);
mGroupsRepublish = true;
}
}
@ -2562,7 +2588,7 @@ std::ostream &operator<<(std::ostream &out, const GroupInfo &info)
return out;
}
void p3GroupDistrib::locked_notifyGroupChanged(GroupInfo &info)
void p3GroupDistrib::locked_notifyGroupChanged(GroupInfo &info, uint32_t flags)
{
mGroupsChanged = true;
info.grpChanged = true;

View file

@ -194,6 +194,14 @@ class GroupCache
uint16_t cacheSubId;
};
/* Flags for locked_notifyGroupChanged() ***/
const uint32_t GRP_NEW_UPDATE = 0x0001;
const uint32_t GRP_UPDATE = 0x0002;
const uint32_t GRP_LOAD_KEY = 0x0003;
const uint32_t GRP_NEW_MSG = 0x0004;
const uint32_t GRP_SUBSCRIBED = 0x0005;
const uint32_t GRP_UNSUBSCRIBED = 0x0006;
class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, public nullService
{
@ -279,7 +287,9 @@ RsDistribMsg *locked_getGroupMsg(std::string grpId, std::string msgId);
/***************************** Event Feedback ******************************************/
/***************************************************************************************/
virtual bool locked_eventUpdateGroup(GroupInfo *, bool isNew) = 0;
protected:
/* root version of this function must be called */
virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags);
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string id) = 0;
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string id) = 0;
@ -347,9 +357,6 @@ virtual bool locked_choosePublishKey(GroupInfo &info);
//virtual RsDistribGrp *locked_createPublicDistribGrp(GroupInfo &info);
//virtual RsDistribGrp *locked_createPrivateDistribGrp(GroupInfo &info);
protected:
/* root version of this function must be called */
virtual void locked_notifyGroupChanged(GroupInfo &info);
/***************************************************************************************/
/***************************** Utility Functions ***************************************/

View file

@ -362,23 +362,30 @@ bool p3Forums::forumSubscribe(std::string fId, bool subscribe)
#include "pqi/pqinotify.h"
bool p3Forums::locked_eventUpdateGroup(GroupInfo *info, bool isNew)
void p3Forums::locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags)
{
std::string grpId = info->grpId;
std::string grpId = grp.grpId;
std::string msgId;
std::string nullId;
if (isNew)
{
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_FORUM_NEW, grpId, msgId, nullId);
}
else
{
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_FORUM_UPDATE, grpId, msgId, nullId);
}
return true;
switch(flags)
{
case GRP_NEW_UPDATE:
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_FORUM_NEW, grpId, msgId, nullId);
break;
case GRP_UPDATE:
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_FORUM_UPDATE, grpId, msgId, nullId);
break;
case GRP_LOAD_KEY:
break;
case GRP_NEW_MSG:
break;
case GRP_SUBSCRIBED:
break;
}
return p3GroupDistrib::locked_notifyGroupChanged(grp, flags);
}
bool p3Forums::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, std::string id)
{
return true;

View file

@ -99,7 +99,7 @@ virtual bool forumSubscribe(std::string fId, bool subscribe);
/****************** Event Feedback (Overloaded form p3distrib) *************************/
/***************************************************************************************/
virtual bool locked_eventUpdateGroup(GroupInfo *, bool isNew);
virtual void locked_notifyGroupChanged(GroupInfo &grp, uint32_t flags);
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string);
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string);