Exemplo n.º 1
0
void MumbleChannel::UpdateChannel(MumbleProto::ChannelState& state)
{
	if (state.has_channel_id())
	{
		m_id = state.channel_id();
	}

	if (state.has_name())
	{
		m_channelName = ConvertFromUTF8(state.name());
	}

	if (state.has_description())
	{
		m_channelDescription = ConvertFromUTF8(state.description());
		m_hasDescription = true;
	}

	if (state.has_description_hash())
	{
		m_descriptionHash = state.description_hash();
		m_hasDescription = false;
	}

	if (state.has_temporary())
	{
		m_temporary = state.temporary();
	}
}
Exemplo n.º 2
0
void MumbleClient::processChannelState(quint8 *message, quint64 size)
{

    MumbleProto::ChannelState ch;
    ch.ParseFromArray(message,size);

    qDebug() << " Channel id: " << ch.channel_id() << QString::fromStdString(ch.name());
}
Exemplo n.º 3
0
	void MumBotState::updateChannelState(MumbleProto::ChannelState msg, bool del) {
        std::lock_guard<std::mutex> lock(channelStateMutex_);
		uint32_t id = msg.channel_id();

		if (channelStates_.count(id) == 0) { //new user state
			channelStates_[id] = msg;
		}
		else if (!del) { //user state update
			MumbleProto::ChannelState cstate = channelStates_[id];
			cstate.MergeFrom(msg);
			channelStates_[id] = cstate;

		}
		else {
			channelStates_.erase(id);
		}

	}
Exemplo n.º 4
0
void MumbleClientState::ProcessChannelState(MumbleProto::ChannelState& channelState)
{
	if (channelState.has_channel_id())
	{
		// is this an update to a channel we know?
		auto id = channelState.channel_id();
		auto& channelIt = m_channels.find(id);

		if (channelIt == m_channels.end())
		{
			auto channel = MumbleChannel(m_client, channelState);

			m_channels.insert(std::make_pair(id, channel));

			auto name = channel.GetName();

			trace("New channel: %s\n", std::string(name.begin(), name.end()).c_str());
		}
		else
		{
			channelIt->second.UpdateChannel(channelState);
		}
	}
}
Exemplo n.º 5
0
void MainWindow::msgChannelState(const MumbleProto::ChannelState &msg) {
	if (! msg.has_channel_id())
		return;

	Channel *c = Channel::get(msg.channel_id());
	Channel *p = msg.has_parent() ? Channel::get(msg.parent()) : NULL;

	if (!c) {
		// Addresses channel does not exist so create it
		if (p && msg.has_name()) {
			c = pmModel->addChannel(msg.channel_id(), p, u8(msg.name()));
			c->bTemporary = msg.temporary();
			p = NULL; // No need to move it later

			ServerHandlerPtr sh = g.sh;
			if (sh)
				c->bFiltered = Database::isChannelFiltered(sh->qbaDigest, c->iId);

		} else {
			qWarning("Server attempted state change on nonexistent channel");
			return;
		}
	}

	if (p) {
		// Channel move
		Channel *pp = p;
		while (pp) {
			if (pp == c) {
				qWarning("Server asked to move a channel into itself or one of its children");
				return;
			}

			pp = pp->cParent;
		}
		pmModel->moveChannel(c, p);
	}

	if (msg.has_name())
		pmModel->renameChannel(c, u8(msg.name()));

	if (msg.has_description_hash())
		pmModel->setCommentHash(c, blob(msg.description_hash()));
	if (msg.has_description())
		pmModel->setComment(c, u8(msg.description()));
	if (msg.icons_size()) {
		QList<QByteArray> ql;
		for (int i=0;i<msg.icons_size();++i) {
			ql << blob(msg.icons(i));
		}
		pmModel->setIcons(c, ql);
	}

	if (msg.has_position()) {
		pmModel->repositionChannel(c, msg.position());
	}

	if (msg.links_size()) {
		QList<Channel *> ql;
		pmModel->unlinkAll(c);
		for (int i=0;i<msg.links_size();++i) {
			Channel *l = Channel::get(msg.links(i));
			if (l)
				ql << l;
		}
		if (! ql.isEmpty())
			pmModel->linkChannels(c, ql);
	}
	if (msg.links_remove_size()) {
		QList<Channel *> ql;
		for (int i=0;i<msg.links_remove_size();++i) {
			Channel *l = Channel::get(msg.links_remove(i));
			if (l)
				ql << l;
		}
		if (! ql.isEmpty())
			pmModel->unlinkChannels(c, ql);
	}
	if (msg.links_add_size()) {
		QList<Channel *> ql;
		for (int i=0;i<msg.links_add_size();++i) {
			Channel *l = Channel::get(msg.links_add(i));
			if (l)
				ql << l;
		}
		if (! ql.isEmpty())
			pmModel->linkChannels(c, ql);
	}
}
Exemplo n.º 6
0
void MainWindow::msgChannelState(const MumbleProto::ChannelState &msg) {
	if (! msg.has_channel_id())
		return;

	Channel *c = Channel::get(msg.channel_id());
	Channel *p = msg.has_parent() ? Channel::get(msg.parent()) : NULL;

	if (!c) {
		if (msg.has_parent() && p && msg.has_name()) {
			c = pmModel->addChannel(msg.channel_id(), p, u8(msg.name()));
			c->bTemporary = msg.temporary();
			p = NULL;
		} else {
			return;
		}
	}

	if (p) {
		Channel *pp = p;
		while (pp) {
			if (pp == c)
				return;
			pp = pp->cParent;
		}
		pmModel->moveChannel(c, p);
	}

	if (msg.has_name())
		pmModel->renameChannel(c, u8(msg.name()));

	if (msg.has_description_hash())
		pmModel->setCommentHash(c, blob(msg.description_hash()));
	if (msg.has_description())
		pmModel->setComment(c, u8(msg.description()));

	if (msg.has_position()) {
		pmModel->repositionChannel(c, msg.position());
	}

	if (msg.links_size()) {
		QList<Channel *> ql;
		pmModel->unlinkAll(c);
		for (int i=0;i<msg.links_size();++i) {
			Channel *l = Channel::get(msg.links(i));
			if (l)
				ql << l;
		}
		if (! ql.isEmpty())
			pmModel->linkChannels(c, ql);
	}
	if (msg.links_remove_size()) {
		QList<Channel *> ql;
		for (int i=0;i<msg.links_remove_size();++i) {
			Channel *l = Channel::get(msg.links_remove(i));
			if (l)
				ql << l;
		}
		if (! ql.isEmpty())
			pmModel->unlinkChannels(c, ql);
	}
	if (msg.links_add_size()) {
		QList<Channel *> ql;
		for (int i=0;i<msg.links_add_size();++i) {
			Channel *l = Channel::get(msg.links_add(i));
			if (l)
				ql << l;
		}
		if (! ql.isEmpty())
			pmModel->linkChannels(c, ql);
	}
}