registration.h

00001 /*
00002   Copyright (c) 2005-2006 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 
00068   class GLOOX_API Registration : public IqHandler
00069   {
00070     public:
00071 
00076       struct fieldStruct
00077       {
00078         std::string username;
00079         std::string nick;
00080         std::string password;
00081         std::string name;
00082         std::string first;
00083         std::string last;
00084         std::string email;
00085         std::string address;
00086         std::string city;
00087         std::string state;
00088         std::string zip;
00089         std::string phone;
00090         std::string url;
00091         std::string date;
00092         std::string misc;
00093         std::string text;
00094       };
00095 
00099       enum fieldEnum
00100       {
00101         FIELD_USERNAME =     1,
00102         FIELD_NICK     =     2,
00103         FIELD_PASSWORD =     4,
00104         FIELD_NAME     =     8,
00105         FIELD_FIRST    =    16,
00106         FIELD_LAST     =    32,
00107         FIELD_EMAIL    =    64,
00108         FIELD_ADDRESS  =   128,
00109         FIELD_CITY     =   256,
00110         FIELD_STATE    =   512,
00111         FIELD_ZIP      =  1024,
00112         FIELD_PHONE    =  2048,
00113         FIELD_URL      =  4096,
00114         FIELD_DATE     =  8192,
00115         FIELD_MISC     = 16384,
00116         FIELD_TEXT     = 32768
00117       };
00118 
00125       Registration( ClientBase *parent, const JID& to );
00126 
00131       Registration( ClientBase *parent );
00132 
00136       virtual ~Registration();
00137 
00143       void fetchRegistrationFields();
00144 
00154       void createAccount( int fields, const fieldStruct& values );
00155 
00163       void createAccount( const DataForm& form );
00164 
00168       void removeAccount();
00169 
00176       void changePassword( const std::string& username, const std::string& password );
00177 
00182       void registerRegistrationHandler( RegistrationHandler *rh );
00183 
00187       void removeRegistrationHandler();
00188 
00189       // reimplemented from IqHandler
00190       virtual bool handleIq( Stanza *stanza );
00191 
00192       // reimplemented from IqHandler
00193       virtual bool handleIqID( Stanza *stanza, int context );
00194 
00195     private:
00196       enum IdType
00197       {
00198         FETCH_REGISTRATION_FIELDS,
00199         CREATE_ACCOUNT,
00200         REMOVE_ACCOUNT,
00201         CHANGE_PASSWORD
00202       };
00203 
00204       ClientBase *m_parent;
00205       const JID m_to;
00206       RegistrationHandler *m_registrationHandler;
00207   };
00208 
00209 }
00210 
00211 #endif // REGISTRATION_H__

Generated on Tue May 1 14:20:20 2007 for gloox by  doxygen 1.5.1