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

registration.h

00001 /*
00002   Copyright (c) 2005-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 #ifndef REGISTRATION_H__
00015 #define REGISTRATION_H__
00016 
00017 #include "iqhandler.h"
00018 #include "registrationhandler.h"
00019 #include "dataform.h"
00020 #include "jid.h"
00021 
00022 #include <string>
00023 #include <map>
00024 
00025 namespace gloox
00026 {
00027 
00028   class ClientBase;
00029   class Stanza;
00030   class OOB;
00031 
00036   struct RegistrationFields
00037   {
00038     std::string username;           
00039     std::string nick;               
00040     std::string password;           
00041     std::string name;               
00042     std::string first;              
00043     std::string last;               
00044     std::string email;              
00045     std::string address;            
00046     std::string city;               
00047     std::string state;              
00048     std::string zip;                
00049     std::string phone;              
00050     std::string url;                
00051     std::string date;               
00052     std::string misc;               
00053     std::string text;               
00054   };
00055 
00092   class GLOOX_API Registration : public IqHandler
00093   {
00094     public:
00095 
00099       enum fieldEnum
00100       {
00101         FieldUsername  =     1,
00102         FieldNick      =     2,
00103         FieldPassword  =     4,
00104         FieldName      =     8,
00105         FieldFirst     =    16,
00106         FieldLast      =    32,
00107         FieldEmail     =    64,
00108         FieldAddress   =   128,
00109         FieldCity      =   256,
00110         FieldState     =   512,
00111         FieldZip       =  1024,
00112         FieldPhone     =  2048,
00113         FieldUrl       =  4096,
00114         FieldDate      =  8192,
00115         FieldMisc      = 16384,
00116         FieldText      = 32768
00117       };
00118 
00125       Registration( ClientBase* parent, const JID& to );
00126 
00131       Registration( ClientBase* parent );
00132 
00136       virtual ~Registration();
00137 
00143       void fetchRegistrationFields();
00144 
00157       bool createAccount( int fields, const RegistrationFields& values );
00158 
00166       void createAccount( DataForm* form );
00167 
00171       void removeAccount();
00172 
00179       void changePassword( const std::string& username, const std::string& password );
00180 
00185       void registerRegistrationHandler( RegistrationHandler* rh );
00186 
00190       void removeRegistrationHandler();
00191 
00192       // reimplemented from IqHandler.
00193       virtual bool handleIq( const IQ& iq ) { (void)iq; return false; }
00194 
00195       // reimplemented from IqHandler.
00196       virtual void handleIqID( const IQ& iq, int context );
00197 
00198 #ifdef REGISTRATION_TEST
00199     public:
00200 #endif
00201 
00207       class Query : public StanzaExtension
00208       {
00209         public:
00214           Query( DataForm* form );
00215 
00220           Query( bool del = false );
00221 
00228           Query( int fields, const RegistrationFields& values );
00229 
00235           Query( const Tag* tag );
00236 
00240           virtual ~Query();
00241 
00246           const DataForm* form() const { return m_form; }
00247 
00252           const std::string& instructions() const { return m_instructions; }
00253 
00258           int fields() const { return m_fields; }
00259 
00263           const RegistrationFields& values() const { return m_values; }
00264 
00268           bool registered() const { return m_reg; }
00269 
00273           const OOB* oob() const { return m_oob; }
00274 
00275           // reimplemented from StanzaExtension
00276           virtual const std::string& filterString() const;
00277 
00278           // reimplemented from StanzaExtension
00279           virtual StanzaExtension* newInstance( const Tag* tag ) const
00280           {
00281             return new Query( tag );
00282           }
00283 
00284           // reimplemented from StanzaExtension
00285           virtual Tag* tag() const;
00286 
00287         private:
00288           DataForm* m_form;
00289           int m_fields;
00290           RegistrationFields m_values;
00291           std::string m_instructions;
00292           OOB* m_oob;
00293           bool m_del;
00294           bool m_reg;
00295       };
00296 
00297       enum IdType
00298       {
00299         FetchRegistrationFields,
00300         CreateAccount,
00301         RemoveAccount,
00302         ChangePassword
00303       };
00304 
00305       void init();
00306 
00307       ClientBase* m_parent;
00308       const JID m_to;
00309       RegistrationHandler* m_registrationHandler;
00310   };
00311 
00312 }
00313 
00314 #endif // REGISTRATION_H__

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