void Quest::setProperty(const CeGuiString& key, const Property& value) { if (key == PROPERTY_KNOWN) { setKnown(value.toBool()); } else if (key == PROPERTY_ID) { mId = value.toString(); } else if (key == PROPERTY_NAME) { mName = value.toString(); } else if (key == PROPERTY_DESCRIPTION) { mDescription = value.toString(); } else if (key == PROPERTY_STATE) { mState = getStateFromName(value.toString()); } else if (key == PROPERTY_PARTSTODO) { setPartsToDo(value.isInt()); } else if (key == PROPERTY_PARTSDONE) { setPartsDone(value.toInt()); } else { mAdditionalProperties.setProperty(key, value); } }
/** * method to receive new events from the EventSwitch */ void BaseRouter::raiseEvent(const dtn::core::Event *evt) throw () { // If a new neighbor comes available, send him a request for the summary vector // If a neighbor went away we can free the stored database try { const dtn::core::NodeEvent &event = dynamic_cast<const dtn::core::NodeEvent&>(*evt); if (event.getAction() == NODE_AVAILABLE) { ibrcommon::MutexLock l(_neighbor_database); _neighbor_database.create( event.getNode().getEID() ); } else if (event.getAction() == NODE_UNAVAILABLE) { ibrcommon::MutexLock l(_neighbor_database); _neighbor_database.create( event.getNode().getEID() ).reset(); } // pass event to all extensions ibrcommon::RWLock l(_extensions_mutex, ibrcommon::RWMutex::LOCK_READONLY); __forward_event(evt); return; } catch (const std::bad_cast&) { }; try { const dtn::net::TransferCompletedEvent &event = dynamic_cast<const dtn::net::TransferCompletedEvent&>(*evt); // if a transfer is completed, then release the transfer resource of the peer try { // add this bundle to the purge vector if it is delivered to its destination if ((event.getBundle().procflags & dtn::data::Bundle::DESTINATION_IS_SINGLETON) && ( event.getPeer().getNode() == event.getBundle().destination.getNode() )) { IBRCOMMON_LOGGER_DEBUG_TAG(BaseRouter::TAG, 20) << "singleton bundle added to purge vector: " << event.getBundle().toString() << IBRCOMMON_LOGGER_ENDL; // add it to the purge vector ibrcommon::MutexLock l(_purged_bundles_lock); _purged_bundles.add(event.getBundle()); } // lock the list of neighbors ibrcommon::MutexLock l(_neighbor_database); NeighborDatabase::NeighborEntry &entry = _neighbor_database.get(event.getPeer()); entry.releaseTransfer(event.getBundle()); // add the bundle to the summary vector of the neighbor entry.add(event.getBundle()); } catch (const NeighborDatabase::NeighborNotAvailableException&) { }; // pass event to all extensions ibrcommon::RWLock l(_extensions_mutex, ibrcommon::RWMutex::LOCK_READONLY); __forward_event(evt); return; } catch (const std::bad_cast&) { }; try { const dtn::net::TransferAbortedEvent &event = dynamic_cast<const dtn::net::TransferAbortedEvent&>(*evt); // if a transfer is aborted, then release the transfer resource of the peer try { // lock the list of neighbors ibrcommon::MutexLock l(_neighbor_database); NeighborDatabase::NeighborEntry &entry = _neighbor_database.create(event.getPeer()); entry.releaseTransfer(event.getBundleID()); if (event.reason == dtn::net::TransferAbortedEvent::REASON_REFUSED) { const dtn::data::MetaBundle meta = getStorage().get(event.getBundleID()); // add the transferred bundle to the bloomfilter of the receiver entry.add(meta); } } catch (const dtn::storage::NoBundleFoundException&) { }; // pass event to all extensions ibrcommon::RWLock l(_extensions_mutex, ibrcommon::RWMutex::LOCK_READONLY); __forward_event(evt); return; } catch (const std::bad_cast&) { }; try { const dtn::net::BundleReceivedEvent &received = dynamic_cast<const dtn::net::BundleReceivedEvent&>(*evt); // Store incoming bundles into the storage try { if (received.fromlocal) { // store the bundle into a storage module getStorage().store(received.bundle); // set the bundle as known setKnown(received.bundle); // raise the queued event to notify all receivers about the new bundle QueueBundleEvent::raise(received.bundle, received.peer); } // if the bundle is not known else if (!filterKnown(received.bundle)) { // security methods modifies the bundle, thus we need a copy of it dtn::data::Bundle bundle = received.bundle; #ifdef WITH_BUNDLE_SECURITY // lets see if signatures and hashes are correct and remove them if possible dtn::security::SecurityManager::getInstance().verify(bundle); #endif // increment value in the scope control hop limit block try { dtn::data::ScopeControlHopLimitBlock &schl = bundle.find<dtn::data::ScopeControlHopLimitBlock>(); schl.increment(); } catch (const dtn::data::Bundle::NoSuchBlockFoundException&) { }; // modify TrackingBlock try { dtn::data::TrackingBlock &track = bundle.find<dtn::data::TrackingBlock>(); track.append(dtn::core::BundleCore::local); } catch (const dtn::data::Bundle::NoSuchBlockFoundException&) { }; // prevent loops try { ibrcommon::MutexLock l(_neighbor_database); // add the bundle to the summary vector of the neighbor _neighbor_database.get(received.peer).add(received.bundle); } catch (const NeighborDatabase::NeighborNotAvailableException&) { }; // store the bundle into a storage module getStorage().store(bundle); // raise the queued event to notify all receivers about the new bundle QueueBundleEvent::raise(received.bundle, received.peer); } else { IBRCOMMON_LOGGER_DEBUG_TAG(BaseRouter::TAG, 5) << "Duplicate bundle " << received.bundle.toString() << " from " << received.peer.getString() << " ignored." << IBRCOMMON_LOGGER_ENDL; } // finally create a bundle received event dtn::core::BundleEvent::raise(received.bundle, dtn::core::BUNDLE_RECEIVED); #ifdef WITH_BUNDLE_SECURITY } catch (const dtn::security::SecurityManager::VerificationFailedException &ex) { IBRCOMMON_LOGGER_TAG(BaseRouter::TAG, notice) << "Security checks failed (" << ex.what() << "), bundle will be dropped: " << received.bundle.toString() << IBRCOMMON_LOGGER_ENDL; #endif } catch (const ibrcommon::IOException &ex) { IBRCOMMON_LOGGER_TAG(BaseRouter::TAG, notice) << "Unable to store bundle " << received.bundle.toString() << IBRCOMMON_LOGGER_ENDL; // raise BundleEvent because we have to drop the bundle dtn::core::BundleEvent::raise(received.bundle, dtn::core::BUNDLE_DELETED, dtn::data::StatusReportBlock::DEPLETED_STORAGE); } catch (const dtn::storage::BundleStorage::StorageSizeExeededException &ex) { IBRCOMMON_LOGGER_TAG(BaseRouter::TAG, notice) << "No space left for bundle " << received.bundle.toString() << IBRCOMMON_LOGGER_ENDL; // raise BundleEvent because we have to drop the bundle dtn::core::BundleEvent::raise(received.bundle, dtn::core::BUNDLE_DELETED, dtn::data::StatusReportBlock::DEPLETED_STORAGE); } catch (const ibrcommon::Exception &ex) { IBRCOMMON_LOGGER_TAG(BaseRouter::TAG, error) << "Bundle " << received.bundle.toString() << " dropped: " << ex.what() << IBRCOMMON_LOGGER_ENDL; // raise BundleEvent because we have to drop the bundle dtn::core::BundleEvent::raise(received.bundle, dtn::core::BUNDLE_DELETED, dtn::data::StatusReportBlock::DEPLETED_STORAGE); } // no routing extension should be interested in this event // everybody should listen to QueueBundleEvent instead return; } catch (const std::bad_cast&) { }; try { const dtn::core::BundleGeneratedEvent &generated = dynamic_cast<const dtn::core::BundleGeneratedEvent&>(*evt); // set the bundle as known setKnown(generated.bundle); // Store incoming bundles into the storage try { // store the bundle into a storage module getStorage().store(generated.bundle); // raise the queued event to notify all receivers about the new bundle QueueBundleEvent::raise(generated.bundle, dtn::core::BundleCore::local); } catch (const ibrcommon::IOException &ex) { IBRCOMMON_LOGGER_TAG(BaseRouter::TAG, notice) << "Unable to store bundle " << generated.bundle.toString() << IBRCOMMON_LOGGER_ENDL; } catch (const dtn::storage::BundleStorage::StorageSizeExeededException &ex) { IBRCOMMON_LOGGER_TAG(BaseRouter::TAG, notice) << "No space left for bundle " << generated.bundle.toString() << IBRCOMMON_LOGGER_ENDL; } // do not pass this event to any extension return; } catch (const std::bad_cast&) { }; try { const dtn::core::TimeEvent &time = dynamic_cast<const dtn::core::TimeEvent&>(*evt); dtn::data::Timestamp expire_time = time.getTimestamp(); if (expire_time <= 60) expire_time = 0; else expire_time -= 60; { ibrcommon::MutexLock l(_known_bundles_lock); _known_bundles.expire(expire_time); } { ibrcommon::MutexLock l(_purged_bundles_lock); _purged_bundles.expire(expire_time); } { ibrcommon::MutexLock l(_neighbor_database); _neighbor_database.expire(time.getTimestamp()); } // pass event to all extensions ibrcommon::RWLock l(_extensions_mutex, ibrcommon::RWMutex::LOCK_READONLY); __forward_event(evt); return; } catch (const std::bad_cast&) { }; // pass event to all extensions ibrcommon::RWLock l(_extensions_mutex, ibrcommon::RWMutex::LOCK_READONLY); __forward_event(evt); }