registration.h
/*
Copyright (c) 2005-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef REGISTRATION_H__
#define REGISTRATION_H__
#include "iqhandler.h"
#include "registrationhandler.h"
#include "dataform.h"
#include "jid.h"
#include "oob.h"
#include <string>
#include <map>
namespace gloox
{
class ClientBase;
class Stanza;
struct RegistrationFields
{
std::string username;
std::string nick;
std::string password;
std::string name;
std::string first;
std::string last;
std::string email;
std::string address;
std::string city;
std::string state;
std::string zip;
std::string phone;
std::string url;
std::string date;
std::string misc;
std::string text;
};
class GLOOX_API Registration : public IqHandler
{
public:
enum fieldEnum
{
FieldUsername = 1,
FieldNick = 2,
FieldPassword = 4,
FieldName = 8,
FieldFirst = 16,
FieldLast = 32,
FieldEmail = 64,
FieldAddress = 128,
FieldCity = 256,
FieldState = 512,
FieldZip = 1024,
FieldPhone = 2048,
FieldUrl = 4096,
FieldDate = 8192,
FieldMisc = 16384,
FieldText = 32768
};
class Query : public StanzaExtension
{
public:
Query( DataForm* form );
Query( bool del = false );
Query( int fields, const RegistrationFields& values );
Query( const Tag* tag );
virtual ~Query();
const DataForm* form() const { return m_form; }
const std::string& instructions() const { return m_instructions; }
int fields() const { return m_fields; }
const RegistrationFields& values() const { return m_values; }
bool registered() const { return m_reg; }
bool remove() const { return m_del; }
const OOB* oob() const { return m_oob; }
// reimplemented from StanzaExtension
virtual const std::string& filterString() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* newInstance( const Tag* tag ) const
{
return new Query( tag );
}
// reimplemented from StanzaExtension
virtual Tag* tag() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* clone() const
{
Query* q = new Query();
q->m_form = m_form ? new DataForm( *m_form ) : 0;
q->m_fields = m_fields;
q->m_values = m_values;
q->m_instructions = m_instructions;
q->m_oob = new OOB( *m_oob );
q->m_del = m_del;
q->m_reg = m_reg;
return q;
}
private:
DataForm* m_form;
int m_fields;
RegistrationFields m_values;
std::string m_instructions;
OOB* m_oob;
bool m_del;
bool m_reg;
};
Registration( ClientBase* parent, const JID& to );
Registration( ClientBase* parent );
virtual ~Registration();
void fetchRegistrationFields();
bool createAccount( int fields, const RegistrationFields& values );
void createAccount( DataForm* form );
void removeAccount();
void changePassword( const std::string& username, const std::string& password );
void registerRegistrationHandler( RegistrationHandler* rh );
void removeRegistrationHandler();
// reimplemented from IqHandler.
virtual bool handleIq( const IQ& iq ) { (void)iq; return false; }
// reimplemented from IqHandler.
virtual void handleIqID( const IQ& iq, int context );
private:
#ifdef REGISTRATION_TEST
public:
#endif
enum IdType
{
FetchRegistrationFields,
CreateAccount,
RemoveAccount,
ChangePassword
};
Registration operator=( const Registration& );
void init();
ClientBase* m_parent;
const JID m_to;
RegistrationHandler* m_registrationHandler;
};
}
#endif // REGISTRATION_H__
gloox::ClientBase
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition clientbase.h:79
gloox::DataForm
An abstraction of a XEP-0004 Data Form.
Definition dataform.h:57
gloox::IQ
An abstraction of an IQ stanza.
Definition iq.h:34
gloox::IqHandler
A virtual interface which can be reimplemented to receive IQ stanzas.
Definition iqhandler.h:32
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::OOB
This is an abstraction of a jabber:x:oob namespace element or a jabber:iq:oob namespace element as sp...
Definition oob.h:36
gloox::RegistrationHandler
A virtual interface that receives events from an Registration object.
Definition registrationhandler.h:81
gloox::Registration::Query::registered
bool registered() const
Definition registration.h:186
gloox::Registration::Query::clone
virtual StanzaExtension * clone() const
Definition registration.h:213
gloox::Registration::Query::form
const DataForm * form() const
Definition registration.h:163
gloox::Registration::Query::Query
Query(DataForm *form)
Definition registration.cpp:26
gloox::Registration::Query::oob
const OOB * oob() const
Definition registration.h:198
gloox::Registration::Query::newInstance
virtual StanzaExtension * newInstance(const Tag *tag) const
Definition registration.h:204
gloox::Registration::Query::instructions
const std::string & instructions() const
Definition registration.h:169
gloox::Registration::Query::remove
bool remove() const
Definition registration.h:192
gloox::Registration::Query::fields
int fields() const
Definition registration.h:175
gloox::Registration::Query::tag
virtual Tag * tag() const
Definition registration.cpp:161
gloox::Registration
This class is an implementation of XEP-0077 (In-Band Registration).
Definition registration.h:93
gloox::Registration::handleIq
virtual bool handleIq(const IQ &iq)
Definition registration.h:310
gloox::Registration::fieldEnum
fieldEnum
Definition registration.h:100
gloox::Registration::FieldNick
@ FieldNick
Definition registration.h:102
gloox::Registration::FieldLast
@ FieldLast
Definition registration.h:106
gloox::Registration::FieldAddress
@ FieldAddress
Definition registration.h:108
gloox::Registration::FieldCity
@ FieldCity
Definition registration.h:109
gloox::Registration::FieldState
@ FieldState
Definition registration.h:110
gloox::Registration::FieldZip
@ FieldZip
Definition registration.h:111
gloox::Registration::FieldName
@ FieldName
Definition registration.h:104
gloox::Registration::FieldUrl
@ FieldUrl
Definition registration.h:113
gloox::Registration::FieldFirst
@ FieldFirst
Definition registration.h:105
gloox::Registration::FieldEmail
@ FieldEmail
Definition registration.h:107
gloox::Registration::FieldMisc
@ FieldMisc
Definition registration.h:115
gloox::Registration::FieldPassword
@ FieldPassword
Definition registration.h:103
gloox::Registration::FieldText
@ FieldText
Definition registration.h:116
gloox::Registration::FieldPhone
@ FieldPhone
Definition registration.h:112
gloox::Registration::FieldUsername
@ FieldUsername
Definition registration.h:101
gloox::Registration::FieldDate
@ FieldDate
Definition registration.h:114
gloox::Registration::Registration
Registration(ClientBase *parent, const JID &to)
Definition registration.cpp:219
gloox::StanzaExtension::StanzaExtension
StanzaExtension(int type)
Definition stanzaextension.h:211
gloox::Stanza
This is the base class for XMPP stanza abstractions.
Definition stanza.h:34
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::RegistrationFields
Definition registration.h:37
gloox::RegistrationFields::state
std::string state
Definition registration.h:47
gloox::RegistrationFields::phone
std::string phone
Definition registration.h:49
gloox::RegistrationFields::text
std::string text
Definition registration.h:53
gloox::RegistrationFields::password
std::string password
Definition registration.h:40
gloox::RegistrationFields::email
std::string email
Definition registration.h:44
gloox::RegistrationFields::misc
std::string misc
Definition registration.h:52
gloox::RegistrationFields::last
std::string last
Definition registration.h:43
gloox::RegistrationFields::username
std::string username
Definition registration.h:38
gloox::RegistrationFields::address
std::string address
Definition registration.h:45
gloox::RegistrationFields::date
std::string date
Definition registration.h:51
gloox::RegistrationFields::city
std::string city
Definition registration.h:46
gloox::RegistrationFields::name
std::string name
Definition registration.h:41
gloox::RegistrationFields::nick
std::string nick
Definition registration.h:39
gloox::RegistrationFields::first
std::string first
Definition registration.h:42
gloox::RegistrationFields::url
std::string url
Definition registration.h:50
gloox::RegistrationFields::zip
std::string zip
Definition registration.h:48