• Main Page
  • Classes
  • Files
  • File List

Swiften/Elements/IBB.h

00001 /*
00002  * Copyright (c) 2010 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 <string>
00010 #include <vector>
00011 #include <boost/shared_ptr.hpp>
00012 #include <boost/smart_ptr/make_shared.hpp>
00013 
00014 #include <Swiften/Elements/Payload.h>
00015 
00016 namespace Swift {
00017   class IBB : public Payload {
00018     public:
00019       typedef boost::shared_ptr<IBB> ref;
00020 
00021       enum Action {
00022         Open,
00023         Close,
00024         Data,
00025       };
00026       enum StanzaType {
00027         IQStanza,
00028         MessageStanza,
00029       };
00030 
00031       IBB(Action action = Open, const std::string& streamID = "") : action(action), streamID(streamID), stanzaType(IQStanza), blockSize(-1), sequenceNumber(-1) {
00032       }
00033 
00034       static IBB::ref createIBBOpen(const std::string& streamID, int blockSize) {
00035         IBB::ref result = boost::make_shared<IBB>(Open, streamID);
00036         result->setBlockSize(blockSize);
00037         return result;
00038       }
00039 
00040       static IBB::ref createIBBData(const std::string& streamID, int sequenceNumber, const std::vector<unsigned char>& data) {
00041         IBB::ref result = boost::make_shared<IBB>(Data, streamID);
00042         result->setSequenceNumber(sequenceNumber);
00043         result->setData(data);
00044         return result;
00045       }
00046 
00047       static IBB::ref createIBBClose(const std::string& streamID) {
00048         return boost::make_shared<IBB>(Close, streamID);
00049       }
00050 
00051       void setAction(Action action) {
00052         this->action = action;
00053       }
00054 
00055       Action getAction() const {
00056         return action;
00057       }
00058 
00059       void setStanzaType(StanzaType stanzaType) {
00060         this->stanzaType = stanzaType;
00061       }
00062 
00063       StanzaType getStanzaType() const {
00064         return stanzaType;
00065       }
00066 
00067       void setStreamID(const std::string& id) {
00068         streamID = id;
00069       }
00070 
00071       const std::string& getStreamID() const {
00072         return streamID;
00073       }
00074 
00075       const std::vector<unsigned char>& getData() const {
00076         return data;
00077       }
00078 
00079       void setData(const std::vector<unsigned char>& data) {
00080         this->data = data;
00081       }
00082 
00083       int getBlockSize() const {
00084         return blockSize;
00085       }
00086 
00087       void setBlockSize(int blockSize) {
00088         this->blockSize = blockSize;
00089       }
00090 
00091       int getSequenceNumber() const {
00092         return sequenceNumber;
00093       }
00094 
00095       void setSequenceNumber(int i) {
00096         sequenceNumber = i;
00097       }
00098 
00099     private:
00100       Action action;
00101       std::string streamID;
00102       std::vector<unsigned char> data;
00103       StanzaType stanzaType;
00104       int blockSize;
00105       int sequenceNumber;
00106   };
00107 }

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