14 #include "registration.h"
16 #include "clientbase.h"
28 m_del( false ), m_reg( false )
40 m_oob( 0 ), m_del( false ), m_reg( false )
52 TagList::const_iterator it = l.begin();
53 for( ; it != l.end(); ++it )
55 const std::string& name = (*it)->name();
56 if( name ==
"instructions" )
57 m_instructions = (*it)->cdata();
58 else if( name ==
"remove" )
60 else if( name ==
"registered" )
62 else if( name ==
"username" )
67 else if( name ==
"nick" )
70 m_values.
nick = (*it)->cdata();
72 else if( name ==
"password" )
77 else if( name ==
"name" )
80 m_values.
name = (*it)->cdata();
82 else if( name ==
"first" )
85 m_values.
first = (*it)->cdata();
87 else if( name ==
"last" )
90 m_values.
last = (*it)->cdata();
92 else if( name ==
"email" )
95 m_values.
email = (*it)->cdata();
97 else if( name ==
"address" )
100 m_values.
address = (*it)->cdata();
102 else if( name ==
"city" )
105 m_values.
city = (*it)->cdata();
107 else if( name ==
"state" )
110 m_values.
state = (*it)->cdata();
112 else if( name ==
"zip" )
115 m_values.
zip = (*it)->cdata();
117 else if( name ==
"phone" )
120 m_values.
phone = (*it)->cdata();
122 else if( name ==
"url" )
125 m_values.
url = (*it)->cdata();
127 else if( name ==
"date" )
130 m_values.
date = (*it)->cdata();
132 else if( name ==
"misc" )
135 m_values.
misc = (*it)->cdata();
137 else if( name ==
"text" )
140 m_values.
text = (*it)->cdata();
142 else if( !m_form && name ==
"x" && (*it)->xmlns() ==
XMLNS_X_DATA )
144 else if( !m_oob && name ==
"x" && (*it)->xmlns() ==
XMLNS_X_OOB )
145 m_oob =
new OOB( (*it) );
157 static const std::string filter =
"/iq/query[@xmlns='" +
XMLNS_REGISTER +
"']";
163 Tag* t =
new Tag(
"query" );
166 if( !m_instructions.empty() )
167 new Tag( t,
"instructions", m_instructions );
170 new Tag( t,
"registered" );
177 new Tag( t,
"remove" );
181 new Tag( t,
"username", m_values.username );
183 new Tag( t,
"nick", m_values.nick );
185 new Tag( t,
"password", m_values.password );
187 new Tag( t,
"name", m_values.
name );
189 new Tag( t,
"first", m_values.first );
191 new Tag( t,
"last", m_values.last );
193 new Tag( t,
"email", m_values.email );
195 new Tag( t,
"address", m_values.address );
197 new Tag( t,
"city", m_values.city );
199 new Tag( t,
"state", m_values.state );
201 new Tag( t,
"zip", m_values.zip );
203 new Tag( t,
"phone", m_values.phone );
205 new Tag( t,
"url", m_values.url );
207 new Tag( t,
"date", m_values.date );
209 new Tag( t,
"misc", m_values.misc );
211 new Tag( t,
"text", m_values.text );
220 : m_parent( parent ), m_to( to ), m_registrationHandler( 0 )
226 : m_parent( parent ), m_registrationHandler( 0 )
231 void Registration::init()
257 m_parent->
send( iq,
this, FetchRegistrationFields );
262 std::string username;
268 m_parent->
send( iq,
this, CreateAccount );
275 if( !m_parent || !form )
280 m_parent->
send( iq,
this, CreateAccount );
285 if( !m_parent || !m_parent->
authed() )
290 m_parent->
send( iq,
this, RemoveAccount );
295 if( !m_parent || !m_parent->
authed() || username.empty() )
307 m_registrationHandler = rh;
312 m_registrationHandler = 0;
317 if( !m_registrationHandler )
324 case FetchRegistrationFields:
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
ConnectionState state() const
void removeIqHandler(IqHandler *ih, int exttype)
void removeIDHandler(IqHandler *ih)
bool removeStanzaExtension(int ext)
void registerIqHandler(IqHandler *ih, int exttype)
void registerStanzaExtension(StanzaExtension *ext)
A stanza error abstraction implemented as a StanzaExtension.
StanzaError error() const
An abstraction of an IQ stanza.
This is an abstraction of a jabber:x:oob namespace element or a jabber:iq:oob namespace element as sp...
A virtual interface that receives events from an Registration object.
virtual void handleDataForm(const JID &from, const DataForm &form)=0
virtual void handleAlreadyRegistered(const JID &from)=0
virtual void handleOOB(const JID &from, const OOB &oob)=0
virtual void handleRegistrationResult(const JID &from, RegistrationResult regResult)=0
virtual void handleRegistrationFields(const JID &from, int fields, std::string instructions)=0
A wrapping class for the XEP-0077 <query> element.
const std::string & instructions() const
const DataForm * form() const
virtual const std::string & filterString() const
virtual Tag * tag() const
void changePassword(const std::string &username, const std::string &password)
virtual void handleIqID(const IQ &iq, int context)
void removeRegistrationHandler()
void registerRegistrationHandler(RegistrationHandler *rh)
void fetchRegistrationFields()
bool createAccount(int fields, const RegistrationFields &values)
Registration(ClientBase *parent, const JID &to)
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
void addExtension(const StanzaExtension *se)
const Error * error() const
const StanzaExtension * findExtension(int type) const
This is an abstraction of an XML element.
const std::string xmlns() const
void addChild(Tag *child)
const std::string & name() const
const TagList & children() const
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
bool nodeprep(const std::string &node, std::string &out)
The namespace for the gloox library.
std::list< Tag * > TagList
@ RegistrationUnknownError
@ RegistrationUnexpectedRequest
@ RegistrationNotAuthorized
@ RegistrationNotAcceptable
const std::string XMLNS_X_OOB
const std::string XMLNS_REGISTER
const std::string XMLNS_X_DATA
@ StanzaErrorResourceConstraint
@ StanzaErrorRegistrationRequired
@ StanzaErrorNotAuthorized
@ StanzaErrorUnexpectedRequest
@ StanzaErrorNotAcceptable