registration.h

00001 /*
00002   Copyright (c) 2005-2007 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 
00035   struct RegistrationFields
00036   {
00037     std::string username;           
00038     std::string nick;               
00039     std::string password;           
00040     std::string name;               
00041     std::string first;              
00042     std::string last;               
00043     std::string email;              
00044     std::string address;            
00045     std::string city;               
00046     std::string state;              
00047     std::string zip;                
00048     std::string phone;              
00049     std::string url;                
00050     std::string date;               
00051     std::string misc;               
00052     std::string text;               
00053   };
00054 
00091   class GLOOX_API Registration : public IqHandler
00092   {
00093     public:
00094 
00098       enum fieldEnum
00099       {
00100         FieldUsername  =     1,
00101         FieldNick      =     2,
00102         FieldPassword  =     4,
00103         FieldName      =     8,
00104         FieldFirst     =    16,
00105         FieldLast      =    32,
00106         FieldEmail     =    64,
00107         FieldAddress   =   128,
00108         FieldCity      =   256,
00109         FieldState     =   512,
00110         FieldZip       =  1024,
00111         FieldPhone     =  2048,
00112         FieldUrl       =  4096,
00113         FieldDate      =  8192,
00114         FieldMisc      = 16384,
00115         FieldText      = 32768
00116       };
00117 
00124       Registration( ClientBase *parent, const JID& to );
00125 
00130       Registration( ClientBase *parent );
00131 
00135       virtual ~Registration();
00136 
00142       void fetchRegistrationFields();
00143 
00153       void createAccount( int fields, const RegistrationFields& values );
00154 
00162       void createAccount( const DataForm& form );
00163 
00167       void removeAccount();
00168 
00175       void changePassword( const std::string& username, const std::string& password );
00176 
00181       void registerRegistrationHandler( RegistrationHandler *rh );
00182 
00186       void removeRegistrationHandler();
00187 
00188       // reimplemented from IqHandler
00189       virtual bool handleIq( Stanza* /*stanza*/ ) { return false; }
00190 
00191       // reimplemented from IqHandler
00192       virtual bool handleIqID( Stanza* stanza, int context );
00193 
00194     private:
00195       enum IdType
00196       {
00197         FetchRegistrationFields,
00198         CreateAccount,
00199         RemoveAccount,
00200         ChangePassword
00201       };
00202 
00203       void init();
00204 
00205       ClientBase *m_parent;
00206       const JID m_to;
00207       RegistrationHandler *m_registrationHandler;
00208   };
00209 
00210 }
00211 
00212 #endif // REGISTRATION_H__

Generated on Sat Nov 10 08:50:27 2007 for gloox by  doxygen 1.5.3-20071008