soc.2009.transport: 0e6d1147: Return references to objects intead of t...

hanzz at soc.pidgin.im hanzz at soc.pidgin.im
Fri Jun 19 08:51:03 EDT 2009


-----------------------------------------------------------------
Revision: 0e6d1147767b69b373d1c90821a10110b0aab95c
Ancestor: 6d9aa9c60970ec5f26b9ba4caae37b6fc496de97
Author: hanzz at soc.pidgin.im
Date: 2009-06-19T12:45:20
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/0e6d1147767b69b373d1c90821a10110b0aab95c

Modified files:
        main.cpp main.h registerhandler.cpp user.h

ChangeLog: 

Return references to objects intead of their copies

-------------- next part --------------
============================================================
--- main.cpp	f635734d9c5f0ff1e25f5726624c25b62687be23
+++ main.cpp	b3af74a24b9c7f2802d4eaf8b0a5d5885756aa3d
@@ -1146,7 +1146,8 @@ void GlooxMessageHandler::handlePresence
 			}
 			else {
 				bool isVip = sql()->isVIP(stanza.from().bare());
-				if (configuration().onlyForVIP && !isVip && std::find(configuration().allowedServers.begin(), configuration().allowedServers.end(), stanza.from().server()) == configuration().allowedServers.end()){
+				std::list<std::string> const &x = configuration().allowedServers;
+				if (configuration().onlyForVIP && !isVip && std::find(x.begin(), x.end(), stanza.from().server()) == x.end()){
 					Log().Get(stanza.from().full()) << "This user is not VIP, can't login...";
 					return;
 				}
============================================================
--- main.h	06703d8d35afa8ea569f5a2f5211523ef531138b
+++ main.h	3a5d4b88ab334ddd8b6004179607b72b6e21770c
@@ -194,8 +194,8 @@ public:
 	
 	UserManager *userManager() { return m_userManager; }
 	GlooxStatsHandler *stats() { return m_stats; }
-	Configuration configuration() { return m_configuration; }
-	std::string jid() { return m_configuration.jid; } // just to create shortcut and because of historical reasons
+	Configuration & configuration() { return m_configuration; }
+	std::string & jid() { return m_configuration.jid; } // just to create shortcut and because of historical reasons
 	SQLClass *sql() { return m_sql; }
 	GlooxVCardHandler *vcard() { return m_vcard; }
 	AbstractProtocol *protocol() { return m_protocol; }
============================================================
--- registerhandler.cpp	bb486e25d42fb1e8c852e996592a6ebb366255a4
+++ registerhandler.cpp	fe4c2e088e394f1f05c15fb2adb733482ce8cebf
@@ -41,7 +41,8 @@ bool GlooxRegisterHandler::handleIq (con
 	User *user = p->userManager()->getUserByJID(iq.from().bare());
 	if (p->configuration().onlyForVIP){
 		bool isVIP = p->sql()->isVIP(iq.from().bare());
-		if (!isVIP)
+		std::list<std::string> const &x = p->configuration().allowedServers;
+		if (!isVIP && std::find(x.begin(), x.end(), iq.from().server()) == x.end())
 			return false;
 	}
 	
============================================================
--- user.h	e9afda5b48ca12b766cb6430a8d3de27f086b1b6
+++ user.h	3d792633ded3e60107cb97410a2816cc1bc924d7
@@ -114,7 +114,7 @@ class User {
 		void updateSetting(const std::string &key, PurpleValue *value);
 
 		// Entity Capabilities
-		std::string capsVersion() { return m_capsVersion; }
+		std::string & capsVersion() { return m_capsVersion; }
 		void setCapsVersion(const std::string &capsVersion) { m_capsVersion = capsVersion; }
 		
 		// Authorization requests
@@ -128,16 +128,16 @@ class User {
 		time_t connectionStart() { return m_connectionStart; }
 		
 		PurpleAccount *account() { return m_account; }
-		std::map<std::string,int> resources() { return m_resources; }
+		std::map<std::string,int> & resources() { return m_resources; }
 		int reconnectCount() { return m_reconnectCount; }
 		bool isVIP() { return m_vip; }
 		bool readyForConnect() { return m_readyForConnect; }
-		std::string username() { return m_username; }
-		std::string jid() { return m_jid; }
-		std::string resource() { return m_resource; }
-		AdhocData adhocData() { return m_adhocData; }
+		std::string & username() { return m_username; }
+		std::string & jid() { return m_jid; }
+		std::string & resource() { return m_resource; }
+		AdhocData & adhocData() { return m_adhocData; }
 		void setAdhocData(AdhocData data) { m_adhocData = data; }
-		std::map<std::string,RosterRow> roster() { return m_roster; }
+		std::map<std::string,RosterRow> & roster() { return m_roster; }
 		const char *getLang() { return m_lang; }
 		void setLang(const char *lang) { m_lang = lang; }
 		


More information about the Commits mailing list