コード例 #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();
	}
}
コード例 #2
0
ファイル: mumbleclient.cpp プロジェクト: guyt101z/qradiolink
void MumbleClient::processChannelState(quint8 *message, quint64 size)
{

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

    qDebug() << " Channel id: " << ch.channel_id() << QString::fromStdString(ch.name());
}
コード例 #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);
		}

	}
コード例 #4
0
void MumbleClient::SetChannel(const std::string& channelName)
{
	if (!m_connectionInfo.isConnected)
	{
		return;
	}

	if (channelName == m_curManualChannel)
	{
		return;
	}

	m_curManualChannel = channelName;

	// check if the channel already exists
	std::wstring wname = ToWide(channelName);

	for (const auto& channel : m_state.GetChannels())
	{
		if (channel.second.GetName() == wname)
		{
			// join the channel
			MumbleProto::UserState state;
			state.set_session(m_state.GetSession());
			state.set_channel_id(channel.first);

			Send(MumbleMessageType::UserState, state);
			return;
		}
	}

	// it does not, create the channel
	{
		MumbleProto::ChannelState chan;
		chan.set_parent(0);
		chan.set_name(channelName);
		chan.set_temporary(true);

		Send(MumbleMessageType::ChannelState, chan);
	}
}
コード例 #5
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);
		}
	}
}
コード例 #6
0
ファイル: mumbleclient.cpp プロジェクト: guyt101z/qradiolink
QString MumbleClient::createChannel(QString channel_name)
{
    QString name;
    if(channel_name == "")
    {
        int rand_len = 8;
        char rand[9];
        genRandomStr(rand,rand_len);
        name = QString::fromLocal8Bit(rand);
    }
    else
    {
        name = channel_name;
    }
    _temp_channel_name = name;
    MumbleProto::ChannelState channel;
    channel.set_parent(0);
    channel.set_name(name.toStdString());
    channel.set_temporary(true);
    int size = channel.ByteSize();
    quint8 data[size];
    channel.SerializeToArray(data,size);
    quint16 type = 7;
    this->sendMessage(data,type,size);
    emit channelName(_temp_channel_name);
    MumbleProto::UserState us;
    us.set_self_deaf(false);
    us.set_self_mute(false);
    us.set_session(_session_id);
    us.set_actor(_session_id);
    int msize = us.ByteSize();
    quint8 mdata[msize];
    us.SerializeToArray(mdata,msize);
    this->sendMessage(mdata,9,msize);
    return name;
}
コード例 #7
0
ファイル: Messages.cpp プロジェクト: Keridos/mumble
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);
	}
}
コード例 #8
0
ファイル: Messages.cpp プロジェクト: Hrym/mumble
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);
	}
}