Exemple #1
0
uint8_t UserInfoBase::getImage(const Identity& identity, bool aIsClientTcpActive) {

	bool bot = identity.isBot() && !identity.getUser()->isSet(User::NMDC);
	uint8_t image = bot ? USER_ICON_BOT : identity.isAway() ? USER_ICON_AWAY : USER_ICON;
	image *= (USER_ICON_LAST - USER_ICON_MOD_START) * (USER_ICON_LAST - USER_ICON_MOD_START);

	if (identity.getUser()->isNMDC()) {
		if(!bot && !aIsClientTcpActive)
		{
			image += 1 << (USER_ICON_PASSIVE - USER_ICON_MOD_START);
		}
	} else {
		const auto cm = identity.getConnectMode();
		if(!bot && (cm == Identity::MODE_PASSIVE_V6 || cm == Identity::MODE_PASSIVE_V4))
		{
			image += 1 << (USER_ICON_PASSIVE - USER_ICON_MOD_START);
		}

		if(!bot && (cm == Identity::MODE_NOCONNECT_PASSIVE || cm == Identity::MODE_NOCONNECT_IP || cm == Identity::MODE_UNDEFINED))
		{
			image += 1 << (USER_ICON_NOCONNECT - USER_ICON_MOD_START);
		}

		//TODO: add icon for unknown (passive) connectivity
		if(!bot && (cm == Identity::MODE_PASSIVE_V4_UNKNOWN || cm == Identity::MODE_PASSIVE_V6_UNKNOWN))
		{
			image += 1 << (USER_ICON_PASSIVE - USER_ICON_MOD_START);
		}
	}

	if(identity.isOp()) {
		image += 1 << (USER_ICON_OP - USER_ICON_MOD_START);
	}
	return image;
}
Exemple #2
0
Identity::Identity(const Identity& rhs) : Flags(), sid(0), connectMode(rhs.getConnectMode()) { 
	*this = rhs;  // Use operator= since we have to lock before reading...
}