44 FileConvergenceLayer::Task::Task(FileConvergenceLayer::Task::Action a,
const dtn::core::Node &n)
49 FileConvergenceLayer::Task::~Task()
58 FileConvergenceLayer::StoreBundleTask::~StoreBundleTask()
94 Task *t = _tasks.getnpop(
true);
106 case Task::TASK_STORE:
109 StoreBundleTask &sbt =
dynamic_cast<StoreBundleTask&
>(*t);
116 std::list<dtn::data::MetaBundle> bundles = scan(path);
133 if (_blacklist.find(meta) != _blacklist.end())
139 _blacklist.add(meta);
143 replyHandshake(bundle, bundles);
152 for (std::list<dtn::data::MetaBundle>::const_iterator iter = bundles.begin(); iter != bundles.end(); ++iter)
154 if ((*iter) == sbt.job.getBundle())
168 std::fstream fs(filename.
getPath().c_str(), std::fstream::out);
190 }
catch (
const std::bad_cast&) { }
194 }
catch (
const std::exception &ex) {
212 _tasks.push(
new Task(Task::TASK_LOAD, n));
215 }
catch (
const std::bad_cast&) { };
225 }
catch (
const std::bad_cast&) { };
230 return "FileConvergenceLayer";
244 std::list<dtn::data::MetaBundle> ret;
245 std::list<ibrcommon::File> files;
248 getPath(n).getFiles(files);
253 for (std::list<ibrcommon::File>::const_iterator iter = files.begin(); iter != files.end(); ++iter)
262 std::fstream fs(f.
getPath().c_str(), std::fstream::in);
273 if ( ( bundle.destination ==
EID() ) || ( bundle.source ==
EID() ) )
280 if ( router.
isKnown(bundle) )
continue;
281 }
catch (
const std::exception&) {
288 std::fstream fs(f.
getPath().c_str(), std::fstream::in);
321 const std::string &uri = uris.front().value;
328 std::list<dtn::data::MetaBundle> FileConvergenceLayer::scan(
const ibrcommon::File &path)
330 std::list<dtn::data::MetaBundle> ret;
331 std::list<ibrcommon::File> files;
336 for (std::list<ibrcommon::File>::const_iterator iter = files.begin(); iter != files.end(); ++iter)
345 std::fstream fs(f.
getPath().c_str(), std::fstream::in);
363 }
catch (
const std::exception&) {
376 _tasks.push(
new StoreBundleTask(n, job));
379 void FileConvergenceLayer::replyHandshake(
const dtn::data::Bundle &bundle, std::list<dtn::data::MetaBundle> &bl)
404 for (std::list<dtn::data::MetaBundle>::const_iterator iter = bl.begin(); iter != bl.end(); ++iter)
412 for (std::set<dtn::data::MetaBundle>::const_iterator iter = _blacklist.begin(); iter != _blacklist.end(); ++iter)
422 response.addItem(item);