diff --git a/libretroshare/src/server/Makefile b/libretroshare/src/server/Makefile index 6cede1e9c..21b6f3dc7 100644 --- a/libretroshare/src/server/Makefile +++ b/libretroshare/src/server/Makefile @@ -2,8 +2,8 @@ RS_TOP_DIR = .. include ../make.opt -OBJ = filedexserver.o pqifiler.o \ - ft.o ftfiler.o hashsearch.o +OBJ = ft.o ftfiler.o hashsearch.o \ + filedexserver.o EXEC = ftcachetest diff --git a/libretroshare/src/server/filedexserver.cc b/libretroshare/src/server/filedexserver.cc index 86b5db40f..3677fde8d 100644 --- a/libretroshare/src/server/filedexserver.cc +++ b/libretroshare/src/server/filedexserver.cc @@ -58,47 +58,19 @@ #include "dbase/fimonitor.h" #include "dbase/fistore.h" +#include "serialiser/rsserviceids.h" + #include const int fldxsrvrzone = 47659; - -/* Another little hack ..... unique message Ids - * will be handled in this class..... - * These are unique within this run of the server, - * and are not stored long term.... - * - * Only 3 entry points: - * (1) from network.... - * (2) from local send - * (3) from storage... - */ - -static unsigned int msgUniqueId = 1; -unsigned int getNewUniqueMsgId() -{ - return msgUniqueId++; -} - - - filedexserver::filedexserver() :pqisi(NULL), sslr(NULL), - - ftFiler(NULL), - - save_dir("."), - msgChanged(1), msgMajorChanged(1), chatChanged(1) -#ifdef PQI_USE_CHANNELS - ,channelsChanged(1) -#endif + save_dir("."), + ftFiler(NULL) { -#ifdef PQI_USE_CHANNELS - p3chan = NULL; -#endif initialiseFileStore(); - } int filedexserver::setSearchInterface(P3Interface *si, sslroot *sr) @@ -108,17 +80,12 @@ int filedexserver::setSearchInterface(P3Interface *si, sslroot *sr) return 1; } - -std::list filedexserver::getTransfers() +std::list filedexserver::getTransfers() { return ftFiler->getStatus(); } - - - - int filedexserver::tick() { pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, @@ -152,13 +119,6 @@ int filedexserver::tick() { moreToTick = 1; } - - if (0 < getChat()) - { - moreToTick = 1; - } - checkOutgoingMessages(); /* don't worry about increasing tick rate! */ - return moreToTick; } @@ -202,313 +162,6 @@ void filedexserver::setSaveIncSearch(bool v) save_inc = v; } - -/***************** Chat Stuff **********************/ - -int filedexserver::sendChat(std::string msg) -{ - // make chat item.... - ChatItem *ci = new ChatItem(); - ci -> sid = getPQIsearchId(); - ci -> p = sslr -> getOwnCert(); - ci -> flags = 0; - - pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, - "filedexserver::sendChat()"); - - ci -> msg = msg; - - /* will come back to us anyway (for now) */ - //ichat.push_back(ci -> clone()); - //chatChanged.IndicateChanged(); - - { - std::ostringstream out; - out << "Chat Item we are sending:" << std::endl; - ci -> print(out); - pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, out.str()); - } - - /* to global .... */ - pqisi -> SendGlobalMsg(ci); - return 1; -} - -int filedexserver::sendPrivateChat(ChatItem *ci) -{ - // make chat item.... - pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, - "filedexserver::sendPrivateChat()"); - - { - std::ostringstream out; - out << "Private Chat Item we are sending:" << std::endl; - ci -> print(out); - pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, out.str()); - } - - /* to global .... */ - pqisi -> SendMsg(ci); - return 1; -} - - -int filedexserver::getChat() -{ - ChatItem *ci; - int i = 0; - while((ci = pqisi -> GetMsg()) != NULL) - { - ++i; - ci -> epoch = time(NULL); - std::string mesg; - - if (ci -> subtype == PQI_MI_SUBTYPE_MSG) - { - // then a message..... push_back. - MsgItem *mi = (MsgItem *) ci; - if (mi -> p == sslr->getOwnCert()) - { - /* from the loopback device */ - mi -> msgflags = PQI_MI_FLAGS_OUTGOING; - } - else - { - /* from a peer */ - mi -> msgflags = 0; - } - - /* new as well! */ - mi -> msgflags |= PQI_MI_FLAGS_NEW; - /* STORE MsgID */ - mi -> sid = getNewUniqueMsgId(); - - imsg.push_back(mi); - //nmsg.push_back(mi); - msgChanged.IndicateChanged(); - } - else - { - // push out the chat instead. - ichat.push_back(ci); - chatChanged.IndicateChanged(); - } - } - - if (i > 0) - { - return 1; - } - return 0; -} - - -std::list filedexserver::getChatQueue() -{ - std::list ilist = ichat; - ichat.clear(); - return ilist; -} - - -std::list &filedexserver::getMsgList() -{ - return imsg; -} - -std::list &filedexserver::getMsgOutList() -{ - return msgOutgoing; -} - - - -std::list filedexserver::getNewMsgs() -{ - std::list tmplist = nmsg; - nmsg.clear(); - return tmplist; -} - -/* remove based on the unique mid (stored in sid) */ -int filedexserver::removeMsgId(unsigned long mid) -{ - std::list::iterator it; - - for(it = imsg.begin(); it != imsg.end(); it++) - { - if ((*it)->sid == mid) - { - MsgItem *mi = (*it); - imsg.erase(it); - delete mi; - msgChanged.IndicateChanged(); - msgMajorChanged.IndicateChanged(); - return 1; - } - } - - /* try with outgoing messages otherwise */ - for(it = msgOutgoing.begin(); it != msgOutgoing.end(); it++) - { - if ((*it)->sid == mid) - { - MsgItem *mi = (*it); - msgOutgoing.erase(it); - delete mi; - msgChanged.IndicateChanged(); - msgMajorChanged.IndicateChanged(); - return 1; - } - } - - return 0; -} - -int filedexserver::markMsgIdRead(unsigned long mid) -{ - std::list::iterator it; - - for(it = imsg.begin(); it != imsg.end(); it++) - { - if ((*it)->sid == mid) - { - MsgItem *mi = (*it); - mi -> msgflags &= ~(PQI_MI_FLAGS_NEW); - msgChanged.IndicateChanged(); - return 1; - } - } - return 0; -} - -int filedexserver::removeMsgItem(int itemnum) -{ - std::list::iterator it; - int i; - - for(i = 1, it = imsg.begin(); (i != itemnum) && (it != imsg.end()); it++, i++); - if (it != imsg.end()) - { - MsgItem *mi = (*it); - imsg.erase(it); - delete mi; - msgChanged.IndicateChanged(); - msgMajorChanged.IndicateChanged(); - return 1; - } - return 0; -} - - -int filedexserver::removeMsgItem(MsgItem *mi) -{ - std::list::iterator it; - for(it = imsg.begin(); (mi != *it) && (it != imsg.end()); it++); - if (it != imsg.end()) - { - imsg.erase(it); - delete mi; - msgChanged.IndicateChanged(); - msgMajorChanged.IndicateChanged(); - return 1; - } - return 0; -} - -/* This is the old fltkgui send recommend.... - * can only handle one single file.... - * will maintain this fn.... but it is deprecated. - */ - -int filedexserver::sendRecommend(PQFileItem *fi, std::string msg) -{ - // make chat item.... - MsgItem *mi = new MsgItem(); - mi -> sid = getPQIsearchId(); - - pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, - "filedexserver::sendRecommend()"); - - mi -> msg = msg; - - if (fi != NULL) - { - MsgFileItem mfi; - mfi.name = fi -> name; - mfi.hash = fi -> hash; - mfi.size = fi -> size; - - mi -> files.push_back(mfi); - } - else - { - /* nuffink */ - } - - pqisi -> SendMsg(mi); - return 1; -} - - -int filedexserver::sendMessage(MsgItem *item) -{ - item -> sid = getPQIsearchId(); - - pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, - "filedexserver::sendMessage()"); - - if (item -> p) - { - /* add pending flag */ - item->msgflags |= - (PQI_MI_FLAGS_OUTGOING | - PQI_MI_FLAGS_PENDING); - /* STORE MsgID */ - item -> sid = getNewUniqueMsgId(); - msgOutgoing.push_back(item); - } - else - { - delete item; - } - return 1; -} - -int filedexserver::checkOutgoingMessages() -{ - /* iterate through the outgoing queue - * - * if online, send - */ - - std::list::iterator it; - for(it = msgOutgoing.begin(); it != msgOutgoing.end();) - { - /* if online, send it */ - if (((*it) -> p -> Status() & PERSON_STATUS_CONNECTED) - || ((*it) -> p == sslr->getOwnCert())) - { - /* send msg */ - pqioutput(PQL_ALERT, fldxsrvrzone, - "filedexserver::checkOutGoingMessages() Sending out message"); - /* remove the pending flag */ - (*it)->msgflags &= ~PQI_MI_FLAGS_PENDING; - - pqisi -> SendMsg(*it); - it = msgOutgoing.erase(it); - } - else - { - pqioutput(PQL_ALERT, fldxsrvrzone, - "filedexserver::checkOutGoingMessages() Delaying until available..."); - it++; - } - } - return 0; -} - - int filedexserver::addSearchDirectory(std::string dir) { dbase_dirs.push_back(dir); @@ -629,45 +282,33 @@ int filedexserver::save_config() std::string statelog = config_dir + "/state.rst"; + /* what can be saved?? */ + RsSerialiser *rss = new RsSerialiser(); + rss->addSerialType(new RsFileTransferSerialiser()); + BinFileInterface *out = new BinFileInterface((char *) statelog.c_str(), BIN_FLAGS_WRITEABLE); - pqiarchive *pa_out = new pqiarchive(out, BIN_FLAGS_WRITEABLE, sslr); + pqiarchive *pa_out = new pqiarchive(rss, out, BIN_FLAGS_WRITEABLE); bool written = false; - std::list::iterator mit; - for(mit = imsg.begin(); mit != imsg.end(); mit++) - { - MsgItem *mi = (*mit)->clone(); - if (pa_out -> SendItem(mi)) - { - written = true; - } - - } - - for(mit = msgOutgoing.begin(); mit != msgOutgoing.end(); mit++) - { - MsgItem *mi = (*mit)->clone(); - mi -> msgflags |= PQI_MI_FLAGS_PENDING; - if (pa_out -> SendItem(mi)) - { - written = true; - } - - } - - std::list::iterator fit; - std::list ftlist = ftFiler -> getStatus(); + std::list::iterator fit; + std::list ftlist = ftFiler -> getStatus(); for(fit = ftlist.begin(); fit != ftlist.end(); fit++) { /* only write out the okay/uncompleted (with hash) files */ - if (((*fit)->state != FT_STATE_OKAY) || ((*fit)->hash == "")) + if (((*fit)->state == FT_STATE_FAILED) || + ((*fit)->state == FT_STATE_COMPLETE) || + ((*fit)->in == false) || + ((*fit)->file.hash == "")) { - delete(*fit); + /* ignore */ } else if (pa_out -> SendItem(*fit)) { written = true; } + + /* cleanup */ + delete(*fit); } if (!written) @@ -750,59 +391,30 @@ int filedexserver::load_config() std::string statelog = config_dir + "/state.rst"; // XXX Fix Interface! + /* what can be saved?? */ + RsSerialiser *rss = new RsSerialiser(); + rss->addSerialType(new RsFileTransferSerialiser()); + BinFileInterface *in = new BinFileInterface((char *) statelog.c_str(), BIN_FLAGS_READABLE); - pqiarchive *pa_in = new pqiarchive(in, BIN_FLAGS_READABLE, sslr); - PQItem *item; - MsgItem *mitem; - PQFileItem *fitem; + pqiarchive *pa_in = new pqiarchive(rss, in, BIN_FLAGS_READABLE); + RsItem *item; + RsFileTransfer *rft; while((item = pa_in -> GetItem())) { - switch(item->type) + /* add to ft queue */ + if (NULL != (rft = dynamic_cast(item))) { - case PQI_ITEM_TYPE_FILEITEM: - /* add to ft queue */ - if (NULL != (fitem = dynamic_cast(item))) - { - /* only add in ones which have a hash (filters old versions) */ - if (fitem->hash != "") - { - ftFiler -> getFile(fitem->name, fitem->hash, - fitem->size, ""); - } - } - delete item; - break; - case PQI_ITEM_TYPE_CHATITEM: - if (NULL != (mitem = dynamic_cast(item))) - { - /* switch depending on the PENDING - * flags - */ - /* STORE MsgID */ - mitem->sid = getNewUniqueMsgId(); - if (mitem -> msgflags & PQI_MI_FLAGS_PENDING) - { - std::cerr << "MSG_PENDING"; - std::cerr << std::endl; - mitem->print(std::cerr); - msgOutgoing.push_back(mitem); - } - else - { - imsg.push_back(mitem); - } - } - else - { - delete item; - } - /* add to chat queue */ - break; - default: - /* unexpected */ - break; + /* only add in ones which have a hash (filters old versions) */ + if (rft->file.hash != "") + { + ftFiler -> getFile( + rft->file.name, + rft->file.hash, + rft->file.filesize, ""); + } } + delete item; } delete pa_in; @@ -810,102 +422,6 @@ int filedexserver::load_config() return 1; } - -#ifdef PQI_USE_CHANNELS - - // Channel stuff. -void filedexserver::setP3Channel(p3channel *p3c) -{ - p3chan = p3c; - return; -} - -int filedexserver::getAvailableChannels(std::list &chans) -{ - if (!p3chan) - { - pqioutput(PQL_ALERT, fldxsrvrzone, - "fildexserver::getAvailableChannels() p3chan == NULL"); - return 0; - } - return p3chan->getChannelList(chans); -} - - -int filedexserver::getChannelMsgList(channelSign s, std::list &summary) -{ - if (!p3chan) - { - pqioutput(PQL_ALERT, fldxsrvrzone, - "fildexserver::getChannelMsgList() p3chan == NULL"); - return 0; - } - pqichannel *chan = p3chan -> findChannel(s); - if (!chan) - { - pqioutput(PQL_ALERT, fldxsrvrzone, - "fildexserver::getChannelMsgList() Channel don't exist!"); - return 0; - } - return chan -> getMsgSummary(summary); -} - - -channelMsg *filedexserver::getChannelMsg(channelSign s, MsgHash mh) -{ - if (!p3chan) - { - pqioutput(PQL_ALERT, fldxsrvrzone, - "fildexserver::getChannelMsg() p3chan == NULL"); - return NULL; - } - pqichannel *chan = p3chan -> findChannel(s); - if (!chan) - { - pqioutput(PQL_ALERT, fldxsrvrzone, - "fildexserver::getChannelMsg() Channel don't exist!"); - return NULL; - } - channelMsg *msg = chan -> findMsg(mh); - if (!msg) - { - pqioutput(PQL_ALERT, fldxsrvrzone, - "fildexserver::getChannelMsg() Msg don't exist!"); - return NULL; - } - return msg; -} - - - -#endif - - -void filedexserver::loadWelcomeMsg() -{ - /* Load Welcome Message */ - MsgItem *msg = new MsgItem(); - - msg -> p = getSSLRoot() -> getOwnCert(); - - msg -> title = "Welcome to Retroshare"; - msg -> header = "Basic Instructions"; - msg -> sendTime = 0; - - msg -> msg = "Send and receive messages\n"; - msg -> msg += "with your friends...\n\n"; - - msg -> msg += "These can hold recommendations\n"; - msg -> msg += "from your local shared files\n\n"; - - msg -> msg += "Add recommendations through\n"; - msg -> msg += "the Local Files Dialog\n\n"; - - msg -> msg += "Enjoy.\n"; - - imsg.push_back(msg); -} - /*************************************** NEW File Cache Stuff ****************************/ void filedexserver::initialiseFileStore() @@ -951,7 +467,7 @@ void filedexserver::setFileCallback(NotifyBase *cb) /* now add the set to the cachestrapper */ - CachePair cp(fimon, fiStore, CacheId(CACHE_TYPE_FILE_INDEX, 0)); + CachePair cp(fimon, fiStore, CacheId(RS_SERVICE_TYPE_FILE_INDEX, 0)); cacheStrapper -> addCachePair(cp); /* add to peermonitor */ @@ -979,7 +495,7 @@ void filedexserver::setFileCallback(NotifyBase *cb) std::string loadCacheFile = localcachedir + "/" + localCacheFile; CacheData cd; cd.pid = ownId; - cd.cid = CacheId(CACHE_TYPE_FILE_INDEX, 0); + cd.cid = CacheId(RS_SERVICE_TYPE_FILE_INDEX, 0); cd.name = localCacheFile; cd.path = localcachedir; cd.hash = localCacheHash; @@ -1095,15 +611,17 @@ int filedexserver::FileStoreTick() int filedexserver::handleInputQueues() { // get all the incoming results.. and print to the screen. - SearchItem *si; - PQFileItem *fi; - PQFileItem *pfi; + RsCacheRequest *cr; + RsCacheItem *ci; + RsFileRequest *fr; + RsFileData *fd; + // Loop through Search Results. int i = 0; int i_init = 0; //std::cerr << "filedexserver::handleInputQueues()" << std::endl; - while((fi = pqisi -> GetSearchResult()) != NULL) + while((ci = pqisi -> GetSearchResult()) != NULL) { //std::cerr << "filedexserver::handleInputQueues() Recvd SearchResult (CacheResponse!)" << std::endl; std::ostringstream out; @@ -1111,37 +629,46 @@ int filedexserver::handleInputQueues() { out << "Recieved Search Results:" << std::endl; } - fi -> print(out); + ci -> print(out); pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, out.str()); /* these go to the CacheStrapper! */ CacheData data; - data.cid = CacheId(fi->fileoffset, fi->chunksize); - data.hash = fi->hash; - data.size = fi->size; - data.name = fi->name; - data.path = fi->path; + data.cid = CacheId(ci->cacheType, ci->cacheSubId); + data.hash = ci->file.hash; + data.size = ci->file.filesize; + data.name = ci->file.name; + data.path = ci->file.path; certsign sign; + convert_to_certsign(ci->PeerId(), sign); + cert *peer = getSSLRoot() -> findcertsign(sign); - if (getSSLRoot() -> getcertsign((cert *) fi->p, sign)) + data.pid = ci->PeerId(); + + if (peer) { - data.pid = convert_to_str(sign); - data.pname = fi->p->Name(); + data.pname = peer->Name(); cacheStrapper->recvCacheResponse(data, time(NULL)); } else { + std::ostringstream out2; + out2 << "Failed to Find Peer for Search Result:"; + out2 << std::endl; + ci -> print(out2); + + pqioutput(PQL_ALERT, fldxsrvrzone, out2.str()); std::cerr << "ERROR"; exit(1); } - delete fi; + delete ci; } // now requested Searches. i_init = i; - while((si = pqisi -> RequestedSearch()) != NULL) + while((cr = pqisi -> RequestedSearch()) != NULL) { //std::cerr << "filedexserver::handleInputQueues() Recvd RequestedSearch (CacheQuery!)" << std::endl; std::ostringstream out; @@ -1149,7 +676,7 @@ int filedexserver::handleInputQueues() { out << "Requested Search:" << std::endl; } - si -> print(out); + cr -> print(out); pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, out.str()); /* these go to the CacheStrapper (handled immediately) */ @@ -1162,82 +689,114 @@ int filedexserver::handleInputQueues() { //std::cerr << "filedexserver::handleInputQueues() Sending (CacheAnswer!)" << std::endl; /* construct reply */ - PQFileItem *fi = new PQFileItem(); + RsCacheItem *ci = new RsCacheItem(); - /* PQItem ones (from incoming) */ - fi -> p = si -> p; - fi -> cid = si -> cid; - /* type/subtype already done, flags/search id ignored */ + /* id from incoming */ + ci -> PeerId(cr->PeerId()); - fi -> hash = (it->second).hash; - fi -> name = (it->second).name; - fi -> path = ""; // (it->second).path; - fi -> size = (it->second).size; - fi -> fileoffset = (it->second).cid.type; - fi -> chunksize = (it->second).cid.subid; + ci -> file.hash = (it->second).hash; + ci -> file.name = (it->second).name; + ci -> file.path = ""; // (it->second).path; + ci -> file.filesize = (it->second).size; + ci -> cacheType = (it->second).cid.type; + ci -> cacheSubId = (it->second).cid.subid; std::ostringstream out2; - out2 << "Outgoing CacheStrapper reply -> PQFileItem:" << std::endl; - fi -> print(out2); + out2 << "Outgoing CacheStrapper reply -> RsCacheItem:" << std::endl; + ci -> print(out2); pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, out2.str()); - pqisi -> SendFileItem(fi); + pqisi -> SendSearchResult(ci); } - delete si; - } - - // now Cancelled Searches. - i_init = i; - while((si = pqisi -> CancelledSearch()) != NULL) - { - std::ostringstream out; - if (i++ == i_init) - { - out << "Deleting Cancelled Search:" << std::endl; - } - si -> print(out); - pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, out.str()); - delete si; + delete cr; } // now File Input. i_init = i; - while((pfi = pqisi -> GetFileItem()) != NULL ) + while((fr = pqisi -> GetFileRequest()) != NULL ) { - //std::cerr << "filedexserver::handleInputQueues() Recvd ftFiler Data" << std::endl; + //std::cerr << "filedexserver::handleInputQueues() Recvd ftFiler Request" << std::endl; std::ostringstream out; if (i++ == i_init) { out << "Incoming(Net) File Item:" << std::endl; } - pfi -> print(out); + fr -> print(out); pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, out.str()); - certsign sign; - if (!getSSLRoot() -> getcertsign((cert *) pfi->p, sign)) - { - std::cerr << "ERROR FFR"; - exit(1); - } - std::string id = convert_to_str(sign); - PQFileData *pfd = dynamic_cast(pfi); - if (pfd) + /* This bit is for debugging only! (not really needed) */ + + certsign sign; + convert_to_certsign(fr->PeerId(), sign); + cert *peer = getSSLRoot() -> findcertsign(sign); + if (peer) { - /* incoming data */ - ftFileData *ffd = new ftFileData(id, pfd->hash, pfd->size, - pfd->fileoffset, pfd->chunksize, pfd->data); - pfd -> data = NULL; - ftFiler->recvFileInfo(ffd); + /* ok! */ } else { - /* request */ - - ftFileRequest *ffr = new ftFileRequest(id, pfi->hash, - pfi->size, pfi->fileoffset, pfi->chunksize); - ftFiler->recvFileInfo(ffr); + std::ostringstream out2; + out2 << "Failed to Find Peer for File Request:"; + out2 << std::endl; + fr -> print(out2); + + pqioutput(PQL_ALERT, fldxsrvrzone, out2.str()); + std::cerr << "ERROR FFR"; + exit(1); } - delete pfi; + + + /* request */ + ftFileRequest *ffr = new ftFileRequest(fr->PeerId(), + fr->file.hash, fr->file.filesize, + fr->fileoffset, fr->chunksize); + ftFiler->recvFileInfo(ffr); + + delete fr; + } + + // now File Data. + i_init = i; + while((fd = pqisi -> GetFileData()) != NULL ) + { + //std::cerr << "filedexserver::handleInputQueues() Recvd ftFiler Data" << std::endl; + std::ostringstream out; + if (i++ == i_init) + { + out << "Incoming(Net) File Data:" << std::endl; + } + fd -> print(out); + pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, out.str()); + + /* This bit is for debugging only! (not really needed) */ + certsign sign; + convert_to_certsign(fd->PeerId(), sign); + cert *peer = getSSLRoot() -> findcertsign(sign); + if (peer) + { + /* ok! */ + } + else + { + std::ostringstream out2; + out2 << "Failed to Find Peer for File Request:"; + out2 << std::endl; + fd -> print(out2); + + pqioutput(PQL_ALERT, fldxsrvrzone, out2.str()); + std::cerr << "ERROR FFRD"; + exit(1); + } + + /* incoming data */ + ftFileData *ffd = new ftFileData(fd->PeerId(), + fd->fd.file.hash, fd->fd.file.filesize, + fd->fd.file_offset, + fd->fd.binData.bin_len, + fd->fd.binData.bin_data); + + ftFiler->recvFileInfo(ffd); + delete fd; } if (i > 0) @@ -1265,37 +824,19 @@ int filedexserver::handleOutputQueues() //std::cerr << "filedexserver::handleOutputQueues() Cache Query for: " << (*pit) << std::endl; /* now create one! */ - SearchItem *si = new SearchItem(); - - /* set it up */ - certsign sign; - if (!convert_to_certsign(*pit, sign)) - { - std::cerr << "CERTSIGN error!" << std::endl; - exit(1); - } - - /* look it up */ - cert *c = getSSLRoot() -> findcertsign(sign); - if (c == NULL) - { - std::cerr << "CERTSIGN error! 2" << std::endl; - exit(1); - } - - si->p = c; - si->cid = c->cid; + RsCacheRequest *cr = new RsCacheRequest(); + cr->PeerId(*pit); std::ostringstream out; if (i++ == 0) { out << "Outgoing CacheStrapper -> SearchItem:" << std::endl; } - si -> print(out); + cr -> print(out); pqioutput(PQL_DEBUG_BASIC, fldxsrvrzone, out.str()); /* send it off */ - pqisi -> SearchSpecific(si); + pqisi -> SearchSpecific(cr); } /* now see if the filer has any data */ @@ -1353,21 +894,20 @@ int filedexserver::handleOutputQueues() void filedexserver::SendFileRequest(ftFileRequest *ftr, cert *peer) { - /* send request */ - PQFileItem *fi = new PQFileItem(); - fi -> subtype = PQI_FI_SUBTYPE_REQUEST; + RsFileRequest *rfi = new RsFileRequest(); - fi -> p = peer; - fi -> cid = peer->cid; - /* type/subtype already done, flags/search id ignored */ + /* id */ + rfi->PeerId(peer->PeerId()); - fi -> hash = ftr -> hash; - /* name, path, ext are ignored */ - fi -> size = ftr -> size; - fi -> fileoffset = ftr->offset; - fi -> chunksize = ftr->chunk; + /* file info */ + rfi->file.filesize = ftr->size; + rfi->file.hash = ftr->hash; - pqisi -> SendFileItem(fi); + /* offsets */ + rfi->fileoffset = ftr->offset; + rfi->chunksize = ftr->chunk; + + pqisi -> SendFileRequest(rfi); } #define MAX_FT_CHUNK 4096 @@ -1389,21 +929,28 @@ void filedexserver::SendFileData(ftFileData *ftd, cert *peer) chunk = tosend; } - /* send data! */ - PQFileData *fid = new PQFileData(); + /******** New Serialiser Type *******/ - fid -> p = peer; - fid -> cid = peer->cid; - fid -> hash = ftd -> hash; - fid -> size = ftd -> size; + RsFileData *rfd = new RsFileData(); - fid -> data = malloc(chunk); - memcpy(fid->data, &(((uint8_t *) ftd->data)[offset]), chunk); - fid -> datalen = chunk; - fid -> chunksize = chunk; - fid -> fileoffset = baseoffset + offset; + /* set id */ + rfd->PeerId(peer->PeerId()); - pqisi -> SendFileItem(fid); + /* file info */ + rfd->fd.file.filesize = ftd->size; + rfd->fd.file.hash = ftd->hash; + rfd->fd.file.name = ""; /* blank other data */ + rfd->fd.file.path = ""; + rfd->fd.file.pop = 0; + rfd->fd.file.age = 0; + + rfd->fd.file_offset = baseoffset + offset; + + /* file data */ + rfd->fd.binData.setBinData( + &(((uint8_t *) ftd->data)[offset]), chunk); + + pqisi -> SendFileData(rfd); offset += chunk; tosend -= chunk; diff --git a/libretroshare/src/server/filedexserver.h b/libretroshare/src/server/filedexserver.h index 8be24beee..b47bbb51f 100644 --- a/libretroshare/src/server/filedexserver.h +++ b/libretroshare/src/server/filedexserver.h @@ -49,6 +49,7 @@ #include "pqi/pqi.h" #include "pqi/pqiindic.h" +#include "serialiser/rsconfigitems.h" #include #include #include @@ -82,23 +83,25 @@ class filedexserver void loadWelcomeMsg(); /* startup message */ int setSearchInterface(P3Interface *si, sslroot *sr); -int additem(SearchItem *item, char *fname); +//int additem(SearchItem *item, char *fname); -int sendChat(std::string msg); -int sendPrivateChat(ChatItem *ci); +//int sendChat(std::string msg); +//int sendPrivateChat(ChatItem *ci); -int sendRecommend(PQFileItem *fi, std::string msg); -int sendMessage(MsgItem *item); -int checkOutgoingMessages(); +//int sendRecommend(PQFileItem *fi, std::string msg); +//int sendMessage(MsgItem *item); +//int checkOutgoingMessages(); -int getChat(); +//int getChat(); /* std::deque &getChatQueue(); */ -std::list getChatQueue(); +//std::list getChatQueue(); -std::list &getMsgList(); -std::list &getMsgOutList(); -std::list getNewMsgs(); -std::list getTransfers(); +//std::list &getMsgList(); +//std::list &getMsgOutList(); +//std::list getNewMsgs(); + + +std::list getTransfers(); // get files (obsolete?) int getFile(std::string fname, std::string hash, @@ -107,12 +110,12 @@ void clear_old_transfers(); void cancelTransfer(std::string fname, std::string hash, uint32_t size); // cleaning up.... -int removeMsgItem(int itemnum); +//int removeMsgItem(int itemnum); // alternative versions. -int removeMsgItem(MsgItem *mi); +//int removeMsgItem(MsgItem *mi); // third versions. -int removeMsgId(unsigned long mid); /* id stored in sid */ -int markMsgIdRead(unsigned long mid); +//int removeMsgId(unsigned long mid); /* id stored in sid */ +//int markMsgIdRead(unsigned long mid); // access to search info is also required. @@ -134,20 +137,17 @@ void setSaveIncSearch(bool v); int tick(); int status(); + private: int handleInputQueues(); int handleOutputQueues(); -std::list ichat; -std::list imsg; -std::list nmsg; -std::list msgOutgoing; /* ones that haven't made it out yet! */ - std::list dbase_dirs; -P3Interface *pqisi; -sslroot *sslr; + sslroot *sslr; + + P3Interface *pqisi; std::string config_dir; std::string save_dir; @@ -155,23 +155,23 @@ bool save_inc; // is savedir include in share list. // bool state flags. public: - Indicator msgChanged; - Indicator msgMajorChanged; - Indicator chatChanged; +// Indicator msgChanged; +// Indicator msgMajorChanged; +// Indicator chatChanged; #ifdef PQI_USE_CHANNELS public: // Channel stuff. -void setP3Channel(p3channel *p3c); -int getAvailableChannels(std::list &chans); -int getChannelMsgList(channelSign s, std::list &summary); -channelMsg *getChannelMsg(channelSign s, MsgHash mh); +//void setP3Channel(p3channel *p3c); +//int getAvailableChannels(std::list &chans); +//int getChannelMsgList(channelSign s, std::list &summary); +//channelMsg *getChannelMsg(channelSign s, MsgHash mh); - Indicator channelsChanged; // everything! +// Indicator channelsChanged; // everything! private: -p3channel *p3chan; +//p3channel *p3chan; #endif diff --git a/libretroshare/src/server/ft.cc b/libretroshare/src/server/ft.cc index 2266a4397..bdc257f9a 100644 --- a/libretroshare/src/server/ft.cc +++ b/libretroshare/src/server/ft.cc @@ -26,7 +26,7 @@ #include "server/ft.h" -bool ftManager::lookupLocalHash(std::string hash, std::string &path, uint32_t &size) +bool ftManager::lookupLocalHash(std::string hash, std::string &path, uint64_t &size) { std::list details; diff --git a/libretroshare/src/server/ft.h b/libretroshare/src/server/ft.h index 4f5f4b617..98a9327dd 100644 --- a/libretroshare/src/server/ft.h +++ b/libretroshare/src/server/ft.h @@ -29,13 +29,14 @@ /* * ftManager - virtual base class for FileTransfer */ - -#include "pqi/pqi.h" #include #include #include +#include "pqi/pqi.h" +#include "serialiser/rsconfigitems.h" + #include "dbase/cachestrapper.h" #include "server/hashsearch.h" @@ -46,7 +47,7 @@ class ftFileRequest { public: ftFileRequest(std::string id_in, std::string hash_in, - uint32_t size_in, uint32_t offset_in, + uint64_t size_in, uint64_t offset_in, uint32_t chunk_in) :id(id_in), hash(hash_in), size(size_in), offset(offset_in), chunk(chunk_in) @@ -58,8 +59,8 @@ virtual ~ftFileRequest() { return; } std::string id; std::string hash; - uint32_t size; - uint32_t offset; + uint64_t size; + uint64_t offset; uint32_t chunk; }; @@ -68,7 +69,7 @@ class ftFileData: public ftFileRequest { public: ftFileData(std::string id_in, std::string hash_in, - uint32_t size_in, uint32_t offset_in, + uint64_t size_in, uint64_t offset_in, uint32_t chunk_in, void *data_in) :ftFileRequest(id_in, hash_in, size_in, offset_in, chunk_in), data(data_in) @@ -103,16 +104,16 @@ void setFileHashSearch(FileHashSearch *hs) { fhs = hs; } /*********** overloaded from CacheTransfer ***************/ /* Must callback after this fn - using utility functions */ //virtual bool RequestCacheFile(RsPeerId id, std::string path, -// std::string hash, uint32_t size); +// std::string hash, uint64_t size); /******************* GUI Interface ************************/ virtual int getFile(std::string name, std::string hash, - uint32_t size, std::string destpath) = 0; + uint64_t size, std::string destpath) = 0; virtual int cancelFile(std::string hash) = 0; virtual int clearFailedTransfers() = 0; virtual int tick() = 0; -virtual std::list getStatus() = 0; +virtual std::list getStatus() = 0; /************* Network Interface****************************/ @@ -126,7 +127,7 @@ virtual ftFileRequest * sendFileInfo() = 0; /****************** UTILITY FUNCTIONS ********************/ /* combines two lookup functions */ -bool lookupLocalHash(std::string hash, std::string &path, uint32_t &size); +bool lookupLocalHash(std::string hash, std::string &path, uint64_t &size); bool lookupRemoteHash(std::string hash, std::list &ids); /*********** callback from CacheTransfer ***************/ @@ -142,3 +143,12 @@ bool lookupRemoteHash(std::string hash, std::list &ids); }; #endif + + + + + + + + + diff --git a/libretroshare/src/server/ftfiler.cc b/libretroshare/src/server/ftfiler.cc index 1ee4f75a9..7b8c62f74 100644 --- a/libretroshare/src/server/ftfiler.cc +++ b/libretroshare/src/server/ftfiler.cc @@ -61,19 +61,19 @@ const int ftfilerzone = 86539; * */ -const int PQIFILE_OFFLINE_CHECK = 120; /* check every 2 minutes */ -const int PQIFILE_DOWNLOAD_TIMEOUT = 60; /* time it out, -> offline after 60 secs */ -const int PQIFILE_DOWNLOAD_CHECK = 10; /* desired delta = 10 secs */ -const int PQIFILE_DOWNLOAD_TOO_FAST = 8; /* 8 secs */ -const int PQIFILE_DOWNLOAD_TOO_SLOW = 12; /* 12 secs */ -const int PQIFILE_DOWNLOAD_MIN_DELTA = 5; /* 5 secs */ +const uint32_t PQIFILE_OFFLINE_CHECK = 120; /* check every 2 minutes */ +const uint32_t PQIFILE_DOWNLOAD_TIMEOUT = 60; /* time it out, -> offline after 60 secs */ +const uint32_t PQIFILE_DOWNLOAD_CHECK = 10; /* desired delta = 10 secs */ +const uint32_t PQIFILE_DOWNLOAD_TOO_FAST = 8; /* 8 secs */ +const uint32_t PQIFILE_DOWNLOAD_TOO_SLOW = 12; /* 12 secs */ +const uint32_t PQIFILE_DOWNLOAD_MIN_DELTA = 5; /* 5 secs */ const float TRANSFER_MODE_TRICKLE_RATE = 1000; /* 1 kbyte limit */ const float TRANSFER_MODE_NORMAL_RATE = 500000; /* 500 kbyte limit - everyone uses this one for now */ const float TRANSFER_MODE_FAST_RATE = 500000; /* 500 kbyte limit */ -const int TRANSFER_START_MIN = 500; /* 500 byte min limit */ -const int TRANSFER_START_MAX = 10000; /* 10000 byte max limit */ +const uint32_t TRANSFER_START_MIN = 500; /* 500 byte min limit */ +const uint32_t TRANSFER_START_MAX = 10000; /* 10000 byte max limit */ void printFtFileStatus(ftFileStatus *s, std::ostream &out); @@ -93,7 +93,7 @@ void printFtFileStatus(ftFileStatus *s, std::ostream &out); int ftfiler::getFile(std::string name, std::string hash, - uint32_t size, std::string destpath) + uint64_t size, std::string destpath) { /* add to local queue */ { @@ -141,7 +141,7 @@ int ftfiler::getFile(std::string name, std::string hash, return 1; } -bool ftfiler::RequestCacheFile(std::string id, std::string destpath, std::string hash, uint32_t size) +bool ftfiler::RequestCacheFile(std::string id, std::string destpath, std::string hash, uint64_t size) { /* add to local queue */ { @@ -307,72 +307,147 @@ int ftfiler::clearFailedTransfers() return 1; } -std::list ftfiler::getStatus() +std::list ftfiler::getStatus() { pqioutput(PQL_DEBUG_BASIC, ftfilerzone, "ftfiler::getTransferStatus()"); - std::list stateList; + std::list stateList; /* iterate through all files to recv */ std::list::iterator it; for(it = recvFiles.begin(); it != recvFiles.end(); it++) { - FileTransferItem *fti = new FileTransferItem(); + RsFileTransfer *rft = new RsFileTransfer(); + rft -> in = true; - /* fill in the basics - * HACK - note - current system cannot save without a cert! - * - so use ours! - */ - fti -> p = getSSLRoot()->getOwnCert(); - - fti -> name = (*it)->name; - - /* hack to only store 'Real' Transfers (Cache have blank hash value)*/ - if ((*it)->ftMode != FT_MODE_CACHE) + /* Ids: current and all */ + std::list::iterator pit; + for(pit = (*it)->sources.begin(); + pit != (*it)->sources.end(); pit++) { - fti -> hash = (*it)->hash; + rft->allPeerIds.ids.push_back(*pit); } - fti -> size = (*it)->size; + rft -> cPeerId = (*it)->id; + + /* file details */ + rft -> file.name = (*it)->name; + rft -> file.filesize = (*it)->size; + rft -> file.path = ""; + rft -> file.pop = 0; + rft -> file.age = 0; + + /* hack to store 'Real' Transfers (Cache have blank hash)*/ + if ((*it)->ftMode != FT_MODE_CACHE) + rft -> file.hash = (*it)->hash; + else + rft -> file.hash = ""; /* Fill in rate and State */ - fti -> transferred = (*it)->recv_size; - fti -> crate = (*it)->rate / 1000.0; // kbytes. - fti -> trate = (*it)->rate / 1000.0; // kbytes. - fti -> lrate = (*it)->rate / 1000.0; // kbytes. - fti -> ltransfer = (*it)->req_size; - fti -> in = true; + rft -> transferred = (*it)->recv_size; + rft -> crate = (*it)->rate; // bytes. + rft -> trate = (*it)->rate; // bytes. + rft -> lrate = (*it)->rate; // bytes. + rft -> ltransfer = (*it)->req_size; /* get inactive period */ if ((*it) -> status == PQIFILE_NOT_ONLINE) { - fti -> crate = 0; - fti -> trate = 0; - fti -> lrate = 0; - fti -> ltransfer = 0; - fti -> state = FT_STATE_OKAY; + rft -> crate = 0; + rft -> trate = 0; + rft -> lrate = 0; + rft -> ltransfer = 0; + rft -> state = FT_STATE_WAITING; } else if ((*it) -> status & PQIFILE_FAIL) { - fti -> crate = 0; - fti -> trate = 0; - fti -> lrate = 0; - fti -> ltransfer = 0; - fti -> state = FT_STATE_FAILED; + rft -> crate = 0; + rft -> trate = 0; + rft -> lrate = 0; + rft -> ltransfer = 0; + rft -> state = FT_STATE_FAILED; } else if ((*it) -> status == PQIFILE_COMPLETE) { - fti -> state = FT_STATE_COMPLETE; + rft -> state = FT_STATE_COMPLETE; } else if ((*it) -> status == PQIFILE_DOWNLOADING) { - fti -> state = FT_STATE_OKAY; + rft -> state = FT_STATE_DOWNLOADING; } else { - fti -> state = FT_STATE_FAILED; + rft -> state = FT_STATE_FAILED; } - stateList.push_back(fti); + stateList.push_back(rft); + } + + /* outgoing files */ + for(it = fileCache.begin(); it != fileCache.end(); it++) + { + RsFileTransfer *rft = new RsFileTransfer(); + rft -> in = false; + + /* Ids: current and all */ + std::list::iterator pit; + for(pit = (*it)->sources.begin(); + pit != (*it)->sources.end(); pit++) + { + rft->allPeerIds.ids.push_back(*pit); + } + rft -> cPeerId = (*it)->id; + + /* file details */ + rft -> file.name = (*it)->name; + rft -> file.filesize = (*it)->size; + rft -> file.path = ""; + rft -> file.pop = 0; + rft -> file.age = 0; + + /* hack to store 'Real' Transfers (Cache have blank hash)*/ + if ((*it)->ftMode != FT_MODE_CACHE) + rft -> file.hash = (*it)->hash; + else + rft -> file.hash = ""; + + /* Fill in rate and State */ + rft -> transferred = (*it)->recv_size; + rft -> crate = (*it)->rate; // bytes. + rft -> trate = (*it)->rate; // bytes. + rft -> lrate = (*it)->rate; // bytes. + rft -> ltransfer = (*it)->req_size; + + /* get inactive period */ + if ((*it) -> status == PQIFILE_NOT_ONLINE) + { + rft -> crate = 0; + rft -> trate = 0; + rft -> lrate = 0; + rft -> ltransfer = 0; + rft -> state = FT_STATE_WAITING; + } + else if ((*it) -> status & PQIFILE_FAIL) + { + rft -> crate = 0; + rft -> trate = 0; + rft -> lrate = 0; + rft -> ltransfer = 0; + rft -> state = FT_STATE_FAILED; + + } + else if ((*it) -> status == PQIFILE_COMPLETE) + { + rft -> state = FT_STATE_COMPLETE; + } + else if ((*it) -> status == PQIFILE_DOWNLOADING) + { + rft -> state = FT_STATE_DOWNLOADING; + } + else + { + rft -> state = FT_STATE_FAILED; + } + stateList.push_back(rft); } return stateList; } @@ -473,7 +548,7 @@ int ftfiler::handleFileNotAvailable(std::string hash) } -int ftfiler::handleFileData(std::string hash, uint32_t offset, +int ftfiler::handleFileData(std::string hash, uint64_t offset, void *data, uint32_t datalen) { pqioutput(PQL_DEBUG_BASIC, ftfilerzone, @@ -512,7 +587,7 @@ int ftfiler::handleFileData(std::string hash, uint32_t offset, return 1; } -int ftfiler::handleFileRequest(std::string id, std::string hash, uint32_t offset, uint32_t chunk) +int ftfiler::handleFileRequest(std::string id, std::string hash, uint64_t offset, uint32_t chunk) { pqioutput(PQL_DEBUG_BASIC, ftfilerzone, "ftfiler::handleFileRequest()"); @@ -539,7 +614,7 @@ int ftfiler::handleFileRequest(std::string id, std::string hash, uint32_t offset return handleFileCacheRequest(id, hash, offset, chunk); } -int ftfiler::handleFileCacheRequest(std::string id, std::string hash, uint32_t offset, uint32_t chunk) +int ftfiler::handleFileCacheRequest(std::string id, std::string hash, uint64_t offset, uint32_t chunk) { pqioutput(PQL_DEBUG_BASIC, ftfilerzone, "ftfiler::handleFileCacheRequest()"); @@ -828,7 +903,7 @@ int ftfiler::requestData(ftFileStatus *item) */ -int ftfiler::generateFileData(ftFileStatus *s, std::string id, uint32_t offset, uint32_t chunk) +int ftfiler::generateFileData(ftFileStatus *s, std::string id, uint64_t offset, uint32_t chunk) { pqioutput(PQL_DEBUG_BASIC, ftfilerzone, "ftfiler::generateFileData()"); @@ -1128,7 +1203,7 @@ int ftfiler::resetFileTransfer(ftFileStatus *state) -int ftfiler::addFileData(ftFileStatus *s, long idx, void *data, int size) +int ftfiler::addFileData(ftFileStatus *s, uint64_t idx, void *data, uint32_t size) { pqioutput(PQL_DEBUG_BASIC, ftfilerzone, "ftfiler::addFileData()"); @@ -1265,7 +1340,7 @@ ftFileStatus *ftfiler::createFileCache(std::string hash) /* so look it up! */ std::string srcpath; - uint32_t size; + uint64_t size; if (lookupLocalHash(s->hash, srcpath, size)) { found = true; diff --git a/libretroshare/src/server/ftfiler.h b/libretroshare/src/server/ftfiler.h index d259d7753..e492d5b36 100644 --- a/libretroshare/src/server/ftfiler.h +++ b/libretroshare/src/server/ftfiler.h @@ -78,7 +78,7 @@ public: } ****/ - ftFileStatus(std::string name_in, std::string hash_in, uint32_t size_in, + ftFileStatus(std::string name_in, std::string hash_in, uint64_t size_in, std::string destpath_in, uint32_t mode_in) :name(name_in), hash(hash_in), destpath(destpath_in), size(size_in), ftMode(mode_in), status(PQIFILE_INIT), mode(0), rate(0), fd(NULL), total_size(0), recv_size(0), @@ -92,7 +92,7 @@ public: return; } - ftFileStatus(std::string id_in, std::string name_in, std::string hash_in, uint32_t size_in, + ftFileStatus(std::string id_in, std::string name_in, std::string hash_in, uint64_t size_in, std::string destpath_in, uint32_t mode_in) :id(id_in), name(name_in), hash(hash_in), destpath(destpath_in), size(size_in), ftMode(mode_in), status(PQIFILE_INIT), mode(0), rate(0), fd(NULL), total_size(0), recv_size(0), @@ -119,7 +119,7 @@ public: std::string name; std::string hash; std::string destpath; - uint32_t size; + uint64_t size; /* new stuff */ uint32_t ftMode; @@ -133,18 +133,18 @@ public: std::string file_name; FILE *fd; - long total_size; + uint64_t total_size; /* this is the simplistic case where only inorder data * otherwise - need much more status info */ - long recv_size; + uint64_t recv_size; /* current file data request */ - long req_loc; - int req_size; + uint64_t req_loc; + uint32_t req_size; /* timestamp */ - long lastTS; - int lastDelta; /* send til all recved */ + time_t lastTS; + uint32_t lastDelta; /* send til all recved */ }; @@ -158,15 +158,15 @@ public: virtual ~ftfiler() { return; } virtual bool RequestCacheFile(std::string id, std::string path, - std::string hash, uint32_t size); + std::string hash, uint64_t size); virtual int getFile(std::string name, std::string hash, - uint32_t size, std::string destpath); + uint64_t size, std::string destpath); virtual int cancelFile(std::string hash); virtual int clearFailedTransfers(); int tick(); -std::list getStatus(); +std::list getStatus(); virtual void setSaveBasePath(std::string s); @@ -179,13 +179,13 @@ private: virtual int handleFileError(std::string hash, uint32_t err); virtual int handleFileNotOnline(std::string hash); virtual int handleFileNotAvailable(std::string hash); -virtual int handleFileData(std::string hash, uint32_t offset, +virtual int handleFileData(std::string hash, uint64_t offset, void *data, uint32_t size); virtual int handleFileRequest( std::string id, std::string hash, - uint32_t offset, uint32_t chunk); + uint64_t offset, uint32_t chunk); virtual int handleFileCacheRequest(std::string id, std::string hash, - uint32_t offset, uint32_t chunk); + uint64_t offset, uint32_t chunk); ftFileStatus *findRecvFileItem(std::string hash); void queryInactive(); @@ -199,7 +199,7 @@ int requestData(ftFileStatus *item); ftFileStatus * createFileCache(std::string hash); ftFileRequest * generateFileRequest(ftFileStatus *); -int generateFileData(ftFileStatus *s, std::string id, uint32_t offset, uint32_t size); +int generateFileData(ftFileStatus *s, std::string id, uint64_t offset, uint32_t size); //int sendFileNotAvail(PQFileItem *req); /************* FILE DATA HANDLING ****************************** @@ -210,7 +210,7 @@ std::string determineDestFilePath(ftFileStatus *s); int initiateFileTransfer(ftFileStatus *s); int resetFileTransfer(ftFileStatus *s); -int addFileData(ftFileStatus *s, long idx, void *data, int size); +int addFileData(ftFileStatus *s, uint64_t idx, void *data, uint32_t size); int completeFileTransfer(ftFileStatus *s); diff --git a/libretroshare/src/server/hashsearch.cc b/libretroshare/src/server/hashsearch.cc index e8f68e83c..8656615ac 100644 --- a/libretroshare/src/server/hashsearch.cc +++ b/libretroshare/src/server/hashsearch.cc @@ -32,7 +32,7 @@ #include "dbase/fimonitor.h" /* Search Interface - For FileTransfer Lookup */ -int FileHashSearch::searchLocalHash(std::string hash, std::string &path, uint32_t &size) +int FileHashSearch::searchLocalHash(std::string hash, std::string &path, uint64_t &size) { if (monitor) { diff --git a/libretroshare/src/server/hashsearch.h b/libretroshare/src/server/hashsearch.h index 13992be12..d7da0213b 100644 --- a/libretroshare/src/server/hashsearch.h +++ b/libretroshare/src/server/hashsearch.h @@ -48,7 +48,7 @@ class FileHashSearch ~FileHashSearch() { return; } /* Search Interface - For FileTransfer Lookup */ - int searchLocalHash(std::string hash, std::string &path, uint32_t &size); + int searchLocalHash(std::string hash, std::string &path, uint64_t &size); int searchRemoteHash(std::string hash, std::list &results);