• Main Page
  • Classes
  • Files
  • File List

Swiften/Queries/Requests/GetPrivateStorageRequest.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 <Swiften/Base/boost_bsignals.h>
00010 #include <boost/shared_ptr.hpp>
00011 #include <boost/smart_ptr/make_shared.hpp>
00012 
00013 #include <Swiften/Queries/Request.h>
00014 #include <Swiften/Elements/PrivateStorage.h>
00015 #include <Swiften/Elements/ErrorPayload.h>
00016 
00017 namespace Swift {
00018   template<typename PAYLOAD_TYPE>
00019   class GetPrivateStorageRequest : public Request {
00020     public:
00021       typedef boost::shared_ptr<GetPrivateStorageRequest<PAYLOAD_TYPE> > ref;
00022 
00023       static ref create(IQRouter* router) {
00024         return ref(new GetPrivateStorageRequest(router));
00025       }
00026 
00027     private:
00028       GetPrivateStorageRequest(IQRouter* router) : Request(IQ::Get, JID(), boost::make_shared<PrivateStorage>(boost::shared_ptr<Payload>(new PAYLOAD_TYPE())), router) {
00029       }
00030 
00031       virtual void handleResponse(boost::shared_ptr<Payload> payload, ErrorPayload::ref error) {
00032         boost::shared_ptr<PrivateStorage> storage = boost::dynamic_pointer_cast<PrivateStorage>(payload);
00033         if (storage) {
00034           onResponse(boost::dynamic_pointer_cast<PAYLOAD_TYPE>(storage->getPayload()), error);
00035         }
00036         else {
00037           onResponse(boost::shared_ptr<PAYLOAD_TYPE>(), error);
00038         }
00039       }
00040 
00041     public:
00042       boost::signal<void (boost::shared_ptr<PAYLOAD_TYPE>, ErrorPayload::ref)> onResponse;
00043   };
00044 }

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