gloox  0.9.9.12
registration.h
1 /*
2  Copyright (c) 2005-2008 by Jakob Schroeter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef REGISTRATION_H__
15 #define REGISTRATION_H__
16 
17 #include "iqhandler.h"
18 #include "registrationhandler.h"
19 #include "dataform.h"
20 #include "jid.h"
21 
22 #include <string>
23 #include <map>
24 
25 namespace gloox
26 {
27 
28  class ClientBase;
29  class Stanza;
30 
36  {
37  std::string username;
38  std::string nick;
39  std::string password;
40  std::string name;
41  std::string first;
42  std::string last;
43  std::string email;
44  std::string address;
45  std::string city;
46  std::string state;
47  std::string zip;
48  std::string phone;
49  std::string url;
50  std::string date;
51  std::string misc;
52  std::string text;
53  };
54 
91  class GLOOX_API Registration : public IqHandler
92  {
93  public:
94 
98  enum fieldEnum
99  {
100  FieldUsername = 1,
101  FieldNick = 2,
102  FieldPassword = 4,
103  FieldName = 8,
104  FieldFirst = 16,
105  FieldLast = 32,
106  FieldEmail = 64,
107  FieldAddress = 128,
108  FieldCity = 256,
109  FieldState = 512,
110  FieldZip = 1024,
111  FieldPhone = 2048,
112  FieldUrl = 4096,
113  FieldDate = 8192,
114  FieldMisc = 16384,
115  FieldText = 32768
116  };
117 
124  Registration( ClientBase *parent, const JID& to );
125 
130  Registration( ClientBase *parent );
131 
135  virtual ~Registration();
136 
142  void fetchRegistrationFields();
143 
153  void createAccount( int fields, const RegistrationFields& values );
154 
162  void createAccount( const DataForm& form );
163 
167  void removeAccount();
168 
175  void changePassword( const std::string& username, const std::string& password );
176 
181  void registerRegistrationHandler( RegistrationHandler *rh );
182 
186  void removeRegistrationHandler();
187 
188  // reimplemented from IqHandler
189  virtual bool handleIq( Stanza* /*stanza*/ ) { return false; }
190 
191  // reimplemented from IqHandler
192  virtual bool handleIqID( Stanza* stanza, int context );
193 
194  private:
195  enum IdType
196  {
197  FetchRegistrationFields,
198  CreateAccount,
199  RemoveAccount,
200  ChangePassword
201  };
202 
203  void init();
204 
205  ClientBase *m_parent;
206  const JID m_to;
207  RegistrationHandler *m_registrationHandler;
208  };
209 
210 }
211 
212 #endif // REGISTRATION_H__