44 FileConvergenceLayer::Task::Task(FileConvergenceLayer::Task::Action a,
const dtn::core::Node &n)
49 FileConvergenceLayer::Task::~Task()
58 FileConvergenceLayer::StoreBundleTask::~StoreBundleTask()
106 case Task::TASK_STORE:
109 StoreBundleTask &sbt =
dynamic_cast<StoreBundleTask&
>(*t);
116 std::list<dtn::data::MetaBundle> bundles = scan(path);
130 if (_blacklist.
find(bundle) != _blacklist.
end())
136 _blacklist.
add(bundle);
140 replyHandshake(bundle, bundles);
149 for (std::list<dtn::data::MetaBundle>::const_iterator iter = bundles.begin(); iter != bundles.end(); ++iter)
151 if ((*iter) == sbt.job.getBundle())
165 std::fstream fs(filename.
getPath().c_str(), std::fstream::out);
187 }
catch (
const std::bad_cast&) { }
191 }
catch (
const std::exception &ex) {
209 _tasks.push(
new Task(Task::TASK_LOAD, n));
212 }
catch (
const std::bad_cast&) { };
222 }
catch (
const std::bad_cast&) { };
227 return "FileConvergenceLayer";
241 std::list<dtn::data::MetaBundle> ret;
242 std::list<ibrcommon::File> files;
250 for (std::list<ibrcommon::File>::const_iterator iter = files.begin(); iter != files.end(); ++iter)
259 std::fstream fs(f.
getPath().c_str(), std::fstream::in);
270 if ( ( bundle.destination ==
EID() ) || ( bundle.source ==
EID() ) )
277 if ( router.
isKnown(bundle) )
continue;
278 }
catch (
const std::exception&) {
285 std::fstream fs(f.
getPath().c_str(), std::fstream::in);
318 const std::string &uri = uris.front().value;
325 std::list<dtn::data::MetaBundle> FileConvergenceLayer::scan(
const ibrcommon::File &path)
327 std::list<dtn::data::MetaBundle> ret;
328 std::list<ibrcommon::File> files;
333 for (std::list<ibrcommon::File>::const_iterator iter = files.begin(); iter != files.end(); ++iter)
342 std::fstream fs(f.
getPath().c_str(), std::fstream::in);
360 }
catch (
const std::exception&) {
373 _tasks.
push(
new StoreBundleTask(n, job));
376 void FileConvergenceLayer::replyHandshake(
const dtn::data::Bundle &bundle, std::list<dtn::data::MetaBundle> &bl)
401 for (std::list<dtn::data::MetaBundle>::const_iterator iter = bl.begin(); iter != bl.end(); ++iter)
409 for (std::set<dtn::data::MetaBundle>::const_iterator iter = _blacklist.
begin(); iter != _blacklist.
end(); ++iter)
419 response.addItem(item);