• Main Page
  • Classes
  • Files
  • File List

Swiften/Elements/JingleS5BTransportPayload.h

00001 /*
00002  * Copyright (c) 2011 Remko Tronçon
00003  * Licensed under the GNU General Public License v3.
00004  * See Documentation/Licenses/GPLv3.txt for more information.
00005  */
00006 
00007 #pragma once
00008 
00009 #include <vector>
00010 
00011 #include <boost/shared_ptr.hpp>
00012 
00013 #include <Swiften/Elements/JingleTransportPayload.h>
00014 #include <Swiften/Elements/Bytestreams.h>
00015 #include <Swiften/Network/HostAddressPort.h>
00016 
00017 
00018 namespace Swift {
00019   class JingleS5BTransportPayload : public JingleTransportPayload {
00020     public:
00021       enum Mode {
00022         TCPMode, // default case
00023         UDPMode,
00024       };
00025 
00026       struct Candidate {
00027         enum Type {
00028           DirectType, // default case
00029           AssistedType,
00030           TunnelType,
00031           ProxyType,
00032         };
00033 
00034         Candidate() : priority(0), type(DirectType) {}
00035 
00036         std::string cid;
00037         JID jid;
00038         HostAddressPort hostPort;
00039         int priority;
00040         Type type;
00041       };
00042 
00043       struct CompareCandidate {
00044         bool operator() (const JingleS5BTransportPayload::Candidate& c1, const JingleS5BTransportPayload::Candidate& c2) const {
00045           if (c1.priority < c2.priority) return true;
00046           return false;
00047         }
00048       };
00049 
00050     public:
00051       JingleS5BTransportPayload() : mode(TCPMode), candidateError(false), proxyError(false) {}
00052 
00053       Mode getMode() const {
00054         return mode;
00055       }
00056 
00057       void setMode(Mode mode) {
00058         this->mode = mode;
00059       }
00060 
00061       const std::vector<Candidate>& getCandidates() const {
00062         return candidates;
00063       }
00064 
00065       void addCandidate(const Candidate& candidate) {
00066         candidates.push_back(candidate);
00067       }
00068 
00069       void setCandidateUsed(const std::string& cid) {
00070         candidateUsedCID = cid;
00071       }
00072 
00073       const std::string& getCandidateUsed() const {
00074         return candidateUsedCID;
00075       }
00076 
00077       void setActivated(const std::string& cid) {
00078         activatedCID = cid;
00079       }
00080 
00081       const std::string& getActivated() const {
00082         return activatedCID;
00083       }
00084 
00085       void setCandidateError(bool hasError) {
00086         candidateError = hasError;
00087       }
00088       
00089       bool hasCandidateError() const {
00090         return candidateError;
00091       }
00092       
00093       void setProxyError(bool hasError) {
00094         proxyError = hasError;
00095       }
00096 
00097       bool hasProxyError() const {
00098         return proxyError;
00099       }
00100     public:
00101       typedef boost::shared_ptr<JingleS5BTransportPayload> ref;
00102 
00103     private:
00104       Mode mode;
00105       std::vector<Candidate> candidates;
00106       
00107       std::string candidateUsedCID;
00108       std::string activatedCID;
00109       bool candidateError;
00110       bool proxyError;
00111   };
00112 }

Generated on Fri Oct 12 2012 21:00:19 for Swiften by  doxygen 1.7.1