IBR-DTNSuite  0.8
daemon/src/net/HTTPConvergenceLayer.h
Go to the documentation of this file.
00001 
00014 #ifndef HTTPCONVERGENCELAYER_H_
00015 #define HTTPCONVERGENCELAYER_H_
00016 
00017 #include "Component.h"
00018 
00019 #include "core/BundleCore.h"
00020 #include "core/BundleEvent.h"
00021 
00022 #include <ibrdtn/data/Serializer.h>
00023 
00024 #include "net/ConvergenceLayer.h"
00025 #include "net/TransferCompletedEvent.h"
00026 #include "net/TransferAbortedEvent.h"
00027 #include "net/BundleReceivedEvent.h"
00028 
00029 #include <ibrcommon/data/BLOB.h>
00030 #include <ibrcommon/data/iobuffer.h>
00031 
00032 #include <ibrcommon/net/vinterface.h>
00033 #include <ibrcommon/net/vaddress.h>
00034 #include <ibrcommon/thread/MutexLock.h>
00035 #include <ibrcommon/thread/Mutex.h>
00036 #include <ibrcommon/thread/Thread.h>
00037 #include <ibrcommon/Exceptions.h>
00038 #include <ibrcommon/Logger.h>
00039 
00040 #include <curl/curl.h>
00041 #include <curl/easy.h>
00042 
00043 
00044 #include <iostream>
00045 
00046 namespace dtn
00047 {
00048         namespace net
00049         {
00050                 class HTTPConvergenceLayer : public ConvergenceLayer, public dtn::daemon::IndependentComponent
00051                 {
00052                 public:
00053                         HTTPConvergenceLayer(const std::string &server);
00054                         virtual ~HTTPConvergenceLayer();
00055 
00056                         dtn::core::Node::Protocol getDiscoveryProtocol() const;
00057 
00061                         void queue(const dtn::core::Node &n, const ConvergenceLayer::Job &job);
00062 
00066                         virtual const std::string getName() const;
00067 
00068 
00069                 protected:
00070                         virtual void componentUp();
00071                         virtual void componentRun();
00072                         virtual void componentDown();
00073                         void __cancellation();
00074 
00075                 private:
00079                         const std::string _server;
00080 
00082                         ibrcommon::Mutex _push_iob_mutex;
00084                         ibrcommon::iobuffer *_push_iob;
00086                         bool _running;
00087                 };
00088 
00089                 class DownloadThread : public ibrcommon::JoinableThread
00090                 {
00091                 public:
00092 
00093                         DownloadThread(ibrcommon::iobuffer &buf);
00094                         virtual ~DownloadThread();
00095 
00096                 protected:
00097                         void run();
00098                         void __cancellation();
00099 
00100                 private:
00102                         std::istream _stream;
00103                 };
00104 
00105         }
00106 }
00107 
00108 #endif /* HTTPCONVERGENCELAYER_H_ */