Changeset - 5efb6707da4f
[Not reviewed]
0 1 0
HanzZ - 14 years ago 2011-12-22 21:47:47
hanzz.k@gmail.com
setUser
1 file changed with 23 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/pqxxbackend.cpp
Show inline comments
 
@@ -160,22 +160,30 @@ void PQXXBackend::setUser(const UserInfo &user) {
 
}
 

	
 
bool PQXXBackend::getUser(const std::string &barejid, UserInfo &user) {
 
//	*m_getUser << barejid;
 
//	EXEC(m_getUser, getUser(barejid, user));
 
//	if (!exec_ok)
 
//		return false;
 

	
 
	int ret = false;
 
//	while (m_getUser->fetch() == 0) {
 
//		ret = true;
 
//		*m_getUser >> user.id >> user.jid >> user.uin >> user.password >> user.encoding >> user.language >> user.vip;
 

	
 
//		if (!CONFIG_STRING(m_config, "database.encryption_key").empty()) {
 
//			user.password = Util::decryptPassword(user.password, CONFIG_STRING(m_config, "database.encryption_key"));
 
//		}
 
//	}
 
	try {
 
		pqxx::work txn(*m_conn);
 

	
 
		pqxx::result r = txn.exec("SELECT id, jid, uin, password, encoding, language, vip FROM " + m_prefix + "users WHERE jid="
 
			+ txn.quote(barejid));
 

	
 
		if (r.size() == 0) {
 
			return false;
 
		}
 

	
 
		user.id = r[0][0].as<int>();
 
		user.jid = r[0][1].as<std::string>();
 
		user.uin = r[0][2].as<std::string>();
 
		user.password = r[0][3].as<std::string>();
 
		user.encoding = r[0][4].as<std::string>();
 
		user.language = r[0][5].as<std::string>();
 
		// user.vip = r[0][6].as<int>();
 
	}
 
	catch (std::exception& e) {
 
		LOG4CXX_ERROR(logger, e.what());
 
		return false;
 
	}
 

	
 
	return ret;
 
	return true;
 
}
 

	
 
void PQXXBackend::setUserOnline(long id, bool online) {
0 comments (0 inline, 0 general)