void MumbleClient::disconnectAllStations() { for(int i =0; i<_stations.size(); i++) { Station *s = _stations.at(i); if((s->_called_by == _session_id) && (s->_in_call == 1) && (s->_conference_id == _channel_id)) { s->_called_by = 0; s->_in_call = 0; s->_conference_id = -1; MumbleProto::UserState us; us.set_channel_id(1); us.set_session(s->_id); us.set_actor(_session_id); us.set_self_mute(true); us.set_self_deaf(true); int size = us.ByteSize(); quint8 data[size]; us.SerializeToArray(data,size); this->sendMessage(data,9,size); } } }
int MumbleClient::disconnectStation(QString radio_id) { int sessid = 0; for(int i =0; i<_stations.size(); i++) { Station *s = _stations.at(i); if(s->_radio_id == radio_id) { sessid = s->_id; if(s->_conference_id != _channel_id) return -2; if(s->_called_by != _session_id) return -3; s->_called_by = 0; s->_in_call = 0; s->_conference_id = -1; } } if(sessid ==0) return -1; MumbleProto::UserState us; us.set_channel_id(1); us.set_session(sessid); us.set_actor(_session_id); us.set_self_mute(true); us.set_self_deaf(true); int size = us.ByteSize(); quint8 data[size]; us.SerializeToArray(data,size); this->sendMessage(data,9,size); return 0; }
void MumbleClient::processServerSync(quint8 *message, quint64 size) { MumbleProto::ServerSync sync; sync.ParseFromArray(message,size); _session_id = sync.session(); _max_bandwidth = sync.max_bandwidth(); std::string welcome = sync.welcome_text(); _synchronized = true; qDebug() << QString::fromStdString(welcome) << " max bandwidth: " << _max_bandwidth << " session: " << QString::number(_session_id); #ifndef NO_CRYPT createChannel(); #endif MumbleProto::UserState us; us.set_session(_session_id); us.set_actor(_session_id); us.set_self_deaf(true); us.set_self_mute(true); us.set_comment(_settings->_callsign.toStdString().c_str()); int msize = us.ByteSize(); quint8 data[msize]; us.SerializeToArray(data,msize); this->sendMessage(data,9,msize); }
void MumbleClient::joinChannel(int id) { MumbleProto::UserState us; us.set_session(_session_id); us.set_self_deaf(false); us.set_self_mute(false); us.set_channel_id(id); int size = us.ByteSize(); quint8 data[size]; us.SerializeToArray(data,size); this->sendMessage(data,9,size); _channel_id = id; }
void MumbleClient::setMute(bool mute) { while(!_synchronized) { usleep(10000); QCoreApplication::processEvents(); } MumbleProto::UserState us; us.set_self_deaf(mute); us.set_self_mute(mute); 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); }
void MumbleClient::disconnectFromCall() { if(_channel_id < 2) { qDebug() << "something went wrong"; return; } _temp_channel_name = ""; MumbleProto::UserState us; us.set_channel_id(1); us.set_session(_session_id); us.set_self_mute(true); us.set_self_deaf(true); int size = us.ByteSize(); quint8 data[size]; us.SerializeToArray(data,size); this->sendMessage(data,9,size); }
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); } }
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; }