/* * Copyright (C) 2006 Registro.br. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * 1. Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY REGISTRO.BR ``AS IS AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIE OF FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL REGISTRO.BR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. */ /* $Id: CommonData.H 878 2007-03-05 20:14:13Z eduardo $ */ /** @file CommonData.H * @brief EPP CommonData Class */ #ifndef __COMMON_DATA_H__ #define __COMMON_DATA_H__ #include #include #include #include "libepp_nicbr.H" using std::string; using std::vector; using std::set; LIBEPP_NICBR_NS_BEGIN /// Action Types enum ActionType { UNSET_ACTION = -1, LOGIN = 0, LOGOUT, HELLO, POLL, GREETING, CONTACT_CHECK = 10, CONTACT_CREATE, CONTACT_INFO, CONTACT_TRANSFER, CONTACT_UPDATE, CONTACT_PANDATA, DOMAIN_CHECK = 20, DOMAIN_CREATE, DOMAIN_INFO, DOMAIN_RENEW, DOMAIN_UPDATE, DOMAIN_PANDATA, BR_ORG_CHECK = 30, BR_ORG_INFO, BR_ORG_CREATE, BR_ORG_UPDATE, BR_ORG_PANDATA, BR_DOMAIN_CHECK = 40, BR_DOMAIN_INFO, BR_DOMAIN_CREATE, BR_DOMAIN_RENEW, BR_DOMAIN_UPDATE, BR_DOMAIN_PANDATA }; /// AuthInfo Class class AuthInfo { public: AuthInfo& operator=(const AuthInfo &authInfo) { _roid = authInfo._roid; _roid_f = authInfo._roid_f; _pw = authInfo._pw; _pw_f = authInfo._pw_f; return *this; } /// Default constructor AuthInfo() { this->reset(); } /// Sets repository object ID /** @param roid repository object id */ void set_roid(string roid) { _roid = roid; if (roid != "") { _roid_f = true; } } /// Returns repository object ID /** @return repository object ID */ string get_roid() { return _roid; } /// Returns the roid change flag /** @return roid change flag */ bool get_roid_f() { return _roid_f; } /// Sets password /** @param pw password */ void set_pw(string pw) { _pw = pw; _pw_f = true; } /// Returns the password /** @return password */ string get_pw() { return _pw; } /// Returns the password change flag /** @return password change flag */ bool get_pw_f() { return _pw_f; } /// Reset all object attributes void reset() { _roid = ""; _roid_f = false; _pw = ""; _pw_f = false; } protected: /// repository object ID string _roid; /// roid change flag bool _roid_f; /// password string _pw; /// password change flag bool _pw_f; }; struct NSIPAddr { string version; string addr; bool operator<(const NSIPAddr &ip) const { return addr < ip.addr; } }; struct NameServer { string name; set ips; bool operator<(const NameServer &n) const { return name < n.name; } }; /// PostalInfo class class PostalInfo { public: PostalInfo() { this->reset(); } void reset() { _type_f = false; _name_f = false; _org_f = false; _str1_f = false; _str2_f = false; _str3_f = false; _city_f = false; _sp_f = false; _pc_f = false; _cc_f = false; } string get_type() { return _type; } void set_type(string type) { _type = type; _type_f = true; } string get_name() { return _name; } void set_name(string name) { _name = name; _name_f = true; } string get_org() { return _org; } void set_org(string org) { _org = org; _org_f = true; } string get_str1() { return _str1; } void set_str1(string str1) { _str1 = str1; _str1_f = true; } string get_str2() { return _str2; } void set_str2(string str2) { _str2 = str2; _str2_f = true; } string get_str3() { return _str3; } void set_str3(string str3) { _str3 = str3; _str3_f = true; } string get_city() { return _city; } void set_city(string city) { _city = city; _city_f = true; } string get_sp() { return _sp; } void set_sp(string sp) { _sp = sp; _sp_f = true; } string get_pc() { return _pc; } void set_pc(string pc) { _pc = pc; _pc_f = true; } string get_cc() { return _cc; } void set_cc(string cc) { _cc = cc; _cc_f = true; } bool get_type_f() { return _type_f; } bool get_name_f() { return _name_f; } bool get_org_f() { return _org_f; } bool get_str1_f() { return _str1_f; } bool get_str2_f() { return _str2_f; } bool get_str3_f() { return _str3_f; } bool get_city_f() { return _city_f; } bool get_sp_f() { return _sp_f; } bool get_pc_f() { return _pc_f; } bool get_cc_f() { return _cc_f; } private: //Flags for PostalInfo attributes bool _type_f; bool _name_f; bool _org_f; bool _str1_f; bool _str2_f; bool _str3_f; bool _city_f; bool _sp_f; bool _pc_f; bool _cc_f; //PostalInfo attributes string _type; string _name; string _org; string _str1; string _str2; string _str3; string _city; string _sp; string _pc; string _cc; }; /// EPP CommonData Class class CommonData { public: struct Disclose { int flag; bool name_int; bool name_loc; bool org_int; bool org_loc; bool addr_int; bool addr_loc; bool voice; bool fax; bool email; Disclose() { flag = -1; name_int = false; name_loc = false; org_int = false; org_loc = false; addr_int = false; addr_loc = false; voice = false; fax = false; email = false; } bool is_set() { return ((flag == 0 || flag == 1) && (name_int || name_loc || org_int || org_loc || addr_int || addr_loc || voice || fax || email)); } }; struct Phone { string ext; string number; }; /// Constructor CommonData() { this->reset(); } /// Sets the object's id /** @param id contact id */ void set_id(const string &id); /// Inserts postal information into the object /** @param postal_info postal information */ void insert_postal_info(const PostalInfo& postal_info); /// Sets the object's voice telephone number /** @param voice contact voice telephone */ void set_voice(const Phone& voice); /// Sets the object's fax number /** @param fax contact fax */ void set_fax(const Phone& fax); /// Sets the object's email /** @param email contact email */ void set_email(const string &email); /// Sets the object's disclosure policy /** @param disclose disclose information */ void set_disclose(const Disclose &disclose); /// Returns the object's id /** @return Contact id */ string get_id(); /// Returns the object's postal information /** @return Postal info list */ vector get_postal_info(); /// Returns the object's voice telephone number /** @return voice contact voice telephone number */ Phone get_voice(); /// Returns the object's voice change flag /** @return contact voice change flag */ bool get_voice_f() { return _voice_f; } /// Returns the object's fax number /** @return fax contact fax number */ Phone get_fax(); /// Returns the object's fax change flag /** @return contact fax change flag */ bool get_fax_f() { return _fax_f; } /// Returns the object's email /** @return contact email */ string get_email(); /// Returns the object's email change flag /** @return contact email change flag */ bool get_email_f() { return _email_f; } /// Returns the object's disclosure policy /** @return disclose disclose information */ Disclose get_disclose(); /// reset attributes void reset(); protected: /// Contact id string _id; /// Postal Info list (just 1 or 2 elements) vector _postal_info; /// Contact's voice telephone number (optional) Phone _voice; /// Voice change flag bool _voice_f; /// Contact's fax (optional) Phone _fax; /// Fax change flag bool _fax_f; /// Contact's email string _email; /// E-mail change flag bool _email_f; /// Disclose information (optional) Disclose _disclose; }; LIBEPP_NICBR_NS_END #endif //__COMMON_DATA_H__