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" )
64 m_fields |= FieldUsername;
67 else if( name ==
"nick" )
69 m_fields |= FieldNick;
70 m_values.
nick = (*it)->cdata();
72 else if( name ==
"password" )
74 m_fields |= FieldPassword;
77 else if( name ==
"name" )
79 m_fields |= FieldName;
80 m_values.
name = (*it)->cdata();
82 else if( name ==
"first" )
84 m_fields |= FieldFirst;
85 m_values.
first = (*it)->cdata();
87 else if( name ==
"last" )
89 m_fields |= FieldLast;
90 m_values.
last = (*it)->cdata();
92 else if( name ==
"email" )
94 m_fields |= FieldEmail;
95 m_values.
email = (*it)->cdata();
97 else if( name ==
"address" )
99 m_fields |= FieldAddress;
100 m_values.
address = (*it)->cdata();
102 else if( name ==
"city" )
104 m_fields |= FieldCity;
105 m_values.
city = (*it)->cdata();
107 else if( name ==
"state" )
109 m_fields |= FieldState;
110 m_values.
state = (*it)->cdata();
112 else if( name ==
"zip" )
114 m_fields |= FieldZip;
115 m_values.
zip = (*it)->cdata();
117 else if( name ==
"phone" )
119 m_fields |= FieldPhone;
120 m_values.
phone = (*it)->cdata();
122 else if( name ==
"url" )
124 m_fields |= FieldUrl;
125 m_values.
url = (*it)->cdata();
127 else if( name ==
"date" )
129 m_fields |= FieldDate;
130 m_values.
date = (*it)->cdata();
132 else if( name ==
"misc" )
134 m_fields |= FieldMisc;
135 m_values.
misc = (*it)->cdata();
137 else if( name ==
"text" )
139 m_fields |= FieldText;
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" );
180 if( m_fields & FieldUsername )
181 new Tag( t,
"username", m_values.username );
182 if( m_fields & FieldNick )
183 new Tag( t,
"nick", m_values.nick );
184 if( m_fields & FieldPassword )
185 new Tag( t,
"password", m_values.password );
186 if( m_fields & FieldName )
187 new Tag( t,
"name", m_values.
name );
188 if( m_fields & FieldFirst )
189 new Tag( t,
"first", m_values.first );
190 if( m_fields & FieldLast )
191 new Tag( t,
"last", m_values.last );
192 if( m_fields & FieldEmail )
193 new Tag( t,
"email", m_values.email );
194 if( m_fields & FieldAddress )
195 new Tag( t,
"address", m_values.address );
196 if( m_fields & FieldCity )
197 new Tag( t,
"city", m_values.city );
198 if( m_fields & FieldState )
199 new Tag( t,
"state", m_values.state );
200 if( m_fields & FieldZip )
201 new Tag( t,
"zip", m_values.zip );
202 if( m_fields & FieldPhone )
203 new Tag( t,
"phone", m_values.phone );
204 if( m_fields & FieldUrl )
205 new Tag( t,
"url", m_values.url );
206 if( m_fields & FieldDate )
207 new Tag( t,
"date", m_values.date );
208 if( m_fields & FieldMisc )
209 new Tag( t,
"misc", m_values.misc );
210 if( m_fields & FieldText )
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() )
298 int fields = FieldUsername | FieldPassword;
307 m_registrationHandler = rh;
312 m_registrationHandler = 0;
317 if( !m_registrationHandler )
324 case FetchRegistrationFields: