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:
const TagList & children() const
A virtual interface that receives events from an Registration object.
StanzaError error() const
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
virtual void handleDataForm(const JID &from, const DataForm &form)=0
void fetchRegistrationFields()
void removeIDHandler(IqHandler *ih)
Registration(ClientBase *parent, const JID &to)
An abstraction of an IQ stanza.
void removeIqHandler(IqHandler *ih, int exttype)
void registerIqHandler(IqHandler *ih, int exttype)
void addExtension(const StanzaExtension *se)
void registerStanzaExtension(StanzaExtension *ext)
std::list< Tag * > TagList
void registerRegistrationHandler(RegistrationHandler *rh)
A stanza error abstraction implemented as a StanzaExtension.
bool removeStanzaExtension(int ext)
ConnectionState state() const
void addChild(Tag *child)
const std::string XMLNS_X_DATA
virtual void handleAlreadyRegistered(const JID &from)=0
virtual void handleRegistrationFields(const JID &from, int fields, std::string instructions)=0
The namespace for the gloox library.
const std::string & instructions() const
This class abstracts a stanza extension, which is usually an element in a specific namespace...
const DataForm * form() const
const std::string & xmlns() const
void removeRegistrationHandler()
bool nodeprep(const std::string &node, std::string &out)
bool createAccount(int fields, const RegistrationFields &values)
virtual void handleRegistrationResult(const JID &from, RegistrationResult regResult)=0
This is an abstraction of a jabber:x:oob namespace element or a jabber:iq:oob namespace element as sp...
A wrapping class for the XEP-0077 element.
const std::string & name() const
const Error * error() const
virtual void handleIqID(const IQ &iq, int context)
const std::string XMLNS_REGISTER
virtual Tag * tag() const
void changePassword(const std::string &username, const std::string &password)
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
virtual void handleOOB(const JID &from, const OOB &oob)=0
const StanzaExtension * findExtension(int type) const
This is an abstraction of an XML element.
const std::string XMLNS_X_OOB
virtual const std::string & filterString() const