/*! * Получение канала из URL адреса. */ ClientChannel ChatUrls::channel(const QUrl &url) { ClientChannel channel; if (url.scheme() != LS("chat") && url.host() != LS("channel")) return channel; QStringList path = ChatUrls::path(url); if (path.isEmpty()) return channel; QByteArray id = SimpleID::decode(path.at(0).toLatin1()); if (!Channel::isCompatibleId(id)) return channel; channel = ChatClient::channels()->get(id); if (channel) return channel; channel = ClientChannel(new Channel(id, ChatId::fromBase32(QUrlQuery(url).queryItemValue(LS("name")).toLatin1()))); channel->gender().setRaw(QUrlQuery(url).queryItemValue(LS("gender")).toInt()); if (!channel->isValid()) return ClientChannel(); return channel; }
ClientChannel TabWidget::channel(const QByteArray &id) const { if (m_channels.contains(id) && m_channels.value(id)->channel()->id() == id) return m_channels.value(id)->channel(); return ClientChannel(); }