//This program is free software: you can redistribute it and/or modify //it under the terms of the GNU Lesser General Public License as published by //the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU Lesser General Public License for more details. // Copyright (c) Petr Bena 2015 - 2019 #include "user.h" using namespace libircclient; User::User() { this->Hops = 0; this->IsAway = false; } User::User(const QHash &hash) { this->Hops = 0; this->IsAway = false; this->LoadHash(hash); } User::User(const QString &user) : libirc::User(user) { this->Hops = 0; this->IsAway = false; } User::User(User *user) : libirc::User(user) { this->IsAway = user->IsAway; this->Hops = user->Hops; this->ChannelPrefixes = user->ChannelPrefixes; this->CUModes = user->CUModes; } QString User::GetPrefixedNick() { QString nick = this->GetNick(); if (!this->ChannelPrefixes.isEmpty()) nick = QChar(this->ChannelPrefixes[0]) + nick; return nick; } char User::GetHighestCUMode() { if (this->CUModes.isEmpty()) return 0; // Get a mode with index 0 as that is meant to be highest return this->CUModes[0]; } void User::LoadHash(const QHash &hash) { libirc::User::LoadHash(hash); UNSERIALIZE_CHARLIST(ChannelPrefixes); UNSERIALIZE_STRING(AwayMs); //UNSERIALIZE_INT(Hops); UNSERIALIZE_BOOL(IsAway); UNSERIALIZE_STRING(ServerName); UNSERIALIZE_CHARLIST(CUModes); } QHash User::ToHash() { QHash hash = libirc::User::ToHash(); SERIALIZE_CHARLIST(ChannelPrefixes); SERIALIZE_CHARLIST(CUModes); SERIALIZE(ServerName); SERIALIZE(IsAway); SERIALIZE(AwayMs); return hash; }