• Main Page
  • Classes
  • Files
  • File List

Swiften/Queries/IQRouter.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 <boost/shared_ptr.hpp>
00010 #include <vector>
00011 #include <string>
00012 
00013 #include <Swiften/Base/API.h>
00014 #include <Swiften/Elements/IQ.h>
00015 
00016 namespace Swift {
00017   class IQChannel;
00018   class IQHandler;
00019 
00020   class SWIFTEN_API IQRouter {
00021     public:
00022       IQRouter(IQChannel* channel);
00023       ~IQRouter();
00024 
00031       void setJID(const JID& jid) {
00032         jid_ = jid;
00033       }
00034 
00035       const JID& getJID() const {
00036         return jid_;
00037       }
00038 
00046       void setFrom(const JID& from) {
00047         from_ = from;
00048       }
00049 
00050       void addHandler(IQHandler* handler);
00051       void removeHandler(IQHandler* handler);
00052       void addHandler(boost::shared_ptr<IQHandler> handler);
00053       void removeHandler(boost::shared_ptr<IQHandler> handler);
00054 
00062       void sendIQ(boost::shared_ptr<IQ> iq);
00063       std::string getNewIQID();
00064       
00065       bool isAvailable();
00066 
00073       bool isAccountJID(const JID& jid) {
00074         return jid.isValid() ? jid_.toBare().equals(jid, JID::WithResource) : true;
00075       }
00076 
00077     private:
00078       void handleIQ(boost::shared_ptr<IQ> iq);
00079       void processPendingRemoves();
00080 
00081     private:
00082       IQChannel* channel_;
00083       JID jid_;
00084       JID from_;
00085       std::vector< boost::shared_ptr<IQHandler> > handlers_;
00086       std::vector< boost::shared_ptr<IQHandler> > queuedRemoves_;
00087       bool queueRemoves_;
00088   };
00089 }

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