Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

search.h

00001 /*
00002   Copyright (c) 2006-2008 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
00011 */
00012 
00013 
00014 
00015 #ifndef SEARCH_H__
00016 #define SEARCH_H__
00017 
00018 #include "gloox.h"
00019 #include "searchhandler.h"
00020 #include "discohandler.h"
00021 #include "iqhandler.h"
00022 #include "stanzaextension.h"
00023 #include "dataform.h"
00024 
00025 #include <string>
00026 
00027 namespace gloox
00028 {
00029 
00030   class ClientBase;
00031   class IQ;
00032   class Disco;
00033 //   class DataForm;
00034 
00050   class GLOOX_API Search : public IqHandler
00051   {
00052 
00053     public:
00058       Search( ClientBase* parent );
00059 
00063       ~Search();
00064 
00070       void fetchSearchFields( const JID& directory, SearchHandler* sh );
00071 
00080       void search( const JID& directory, DataForm* form, SearchHandler* sh );
00081 
00091       void search( const JID& directory, int fields, const SearchFieldStruct& values, SearchHandler* sh );
00092 
00093       // reimplemented from IqHandler.
00094       virtual bool handleIq( const IQ& iq ) { (void)iq; return false; }
00095 
00096       // reimplemented from IqHandler.
00097       virtual void handleIqID( const IQ& iq, int context );
00098 
00099     protected:
00100       enum IdType
00101       {
00102         FetchSearchFields,
00103         DoSearch
00104       };
00105 
00106       typedef std::map<std::string, SearchHandler*> TrackMap;
00107       TrackMap m_track;
00108 
00109       ClientBase* m_parent;
00110       Disco* m_disco;
00111 
00112     private:
00113 #ifdef SEARCH_TEST
00114     public:
00115 #endif
00116 
00122       class Query : public StanzaExtension
00123       {
00124         public:
00129           Query( DataForm* form );
00130 
00137           Query( int fields, const SearchFieldStruct& values );
00138 
00144           Query( const Tag* tag = 0 );
00145 
00149           virtual ~Query();
00150 
00155           const DataForm* form() const { return m_form; }
00156 
00161           const std::string& instructions() const { return m_instructions; }
00162 
00167           int fields() const { return m_fields; }
00168 
00173           const SearchResultList& result() const { return m_srl; }
00174 
00175           // reimplemented from StanzaExtension
00176           virtual const std::string& filterString() const;
00177 
00178           // reimplemented from StanzaExtension
00179           virtual StanzaExtension* newInstance( const Tag* tag ) const
00180           {
00181             return new Query( tag );
00182           }
00183 
00184           // reimplemented from StanzaExtension
00185           virtual Tag* tag() const;
00186 
00187         private:
00188 #ifdef SEARCH_TEST
00189         public:
00190 #endif
00191           DataForm* m_form;
00192           int m_fields;
00193           SearchFieldStruct m_values;
00194           std::string m_instructions;
00195           SearchResultList m_srl;
00196       };
00197 
00198   };
00199 
00200 }
00201 
00202 #endif // SEARCH_H__

Generated on Mon Jun 23 10:50:19 2008 for gloox by  doxygen 1.4.1