1 /* 2 * Copyright (C) 2001-2008 Jacek Sieka, arnetheduck on gmail point com 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 */ 18 19 #ifndef DCPLUSPLUS_DCPP_HUBENTRY_H_ 20 #define DCPLUSPLUS_DCPP_HUBENTRY_H_ 21 22 namespace dcpp { 23 24 class HubEntry { 25 public: HubEntry(const string & aName,const string & aServer,const string & aDescription,const string & aUsers)26 HubEntry(const string& aName, const string& aServer, const string& aDescription, const string& aUsers) throw() : 27 name(aName), server(aServer), description(aDescription), country(Util::emptyString), 28 rating(Util::emptyString), reliability(0.0), shared(0), minShare(0), users(Util::toInt(aUsers)), minSlots(0), maxHubs(0), maxUsers(0) { } 29 HubEntry(const string & aName,const string & aServer,const string & aDescription,const string & aUsers,const string & aCountry,const string & aShared,const string & aMinShare,const string & aMinSlots,const string & aMaxHubs,const string & aMaxUsers,const string & aReliability,const string & aRating)30 HubEntry(const string& aName, const string& aServer, const string& aDescription, const string& aUsers, const string& aCountry, 31 const string& aShared, const string& aMinShare, const string& aMinSlots, const string& aMaxHubs, const string& aMaxUsers, 32 const string& aReliability, const string& aRating) : name(aName), server(aServer), description(aDescription), country(aCountry), 33 rating(aRating), reliability((float)(Util::toFloat(aReliability) / 100.0)), shared(Util::toInt64(aShared)), minShare(Util::toInt64(aMinShare)), 34 users(Util::toInt(aUsers)), minSlots(Util::toInt(aMinSlots)), maxHubs(Util::toInt(aMaxHubs)), maxUsers(Util::toInt(aMaxUsers)) 35 { 36 37 } 38 throw()39 HubEntry() throw() { } throw()40 HubEntry(const HubEntry& rhs) throw() : name(rhs.name), server(rhs.server), description(rhs.description), country(rhs.country), 41 rating(rhs.rating), reliability(rhs.reliability), shared(rhs.shared), minShare(rhs.minShare), users(rhs.users), minSlots(rhs.minSlots), 42 maxHubs(rhs.maxHubs), maxUsers(rhs.maxUsers) { } 43 throw()44 ~HubEntry() throw() { } 45 46 GETSET(string, name, Name); 47 GETSET(string, server, Server); 48 GETSET(string, description, Description); 49 GETSET(string, country, Country); 50 GETSET(string, rating, Rating); 51 GETSET(float, reliability, Reliability); 52 GETSET(int64_t, shared, Shared); 53 GETSET(int64_t, minShare, MinShare); 54 GETSET(int, users, Users); 55 GETSET(int, minSlots, MinSlots); 56 GETSET(int, maxHubs, MaxHubs); 57 GETSET(int, maxUsers, MaxUsers); 58 }; 59 60 class FavoriteHubEntry { 61 public: FavoriteHubEntry()62 FavoriteHubEntry() throw() : connect(false), encoding(Text::systemCharset) { } throw()63 FavoriteHubEntry(const HubEntry& rhs) throw() : name(rhs.getName()), server(rhs.getServer()), description(rhs.getDescription()), connect(false), encoding(Text::systemCharset) { } throw()64 FavoriteHubEntry(const FavoriteHubEntry& rhs) throw() : userdescription(rhs.userdescription), name(rhs.getName()), server(rhs.getServer()), description(rhs.getDescription()), 65 password(rhs.getPassword()), connect(rhs.getConnect()), encoding(rhs.getEncoding()), nick(rhs.nick){ } throw()66 ~FavoriteHubEntry() throw() { } 67 68 const string& getNick(bool useDefault = true) const { 69 return (!nick.empty() || !useDefault) ? nick : SETTING(NICK); 70 } 71 setNick(const string & aNick)72 void setNick(const string& aNick) { nick = aNick; } 73 74 GETSET(string, userdescription, UserDescription); 75 GETSET(string, name, Name); 76 GETSET(string, server, Server); 77 GETSET(string, description, Description); 78 GETSET(string, password, Password); 79 GETSET(bool, connect, Connect); 80 GETSET(string, encoding, Encoding); 81 82 private: 83 string nick; 84 }; 85 86 } 87 88 #endif /*HUBENTRY_H_*/ 89