#include "MumbleChannelJoiner.hpp" #include using namespace std; mumble::MumbleChannelJoiner::MumbleChannelJoiner(std::string channelNameRegex) : channelNameRegex(boost::regex(channelNameRegex)), logger(log4cpp::Category::getInstance("MumbleChannelJoiner")){ //std::vector *channels = new std::vector(); } std::vector mumble::MumbleChannelJoiner::channels; void mumble::MumbleChannelJoiner::checkChannel(std::string channel_name, int channel_id) { boost::smatch s; ChannelEntry ent; logger.debug("Channel %s available (%d)", channel_name.c_str(), channel_id); ent.name = channel_name; ent.id = channel_id; channels.push_back(ent); if(boost::regex_match(channel_name, s, channelNameRegex)) { this->channel_id = channel_id; } } void mumble::MumbleChannelJoiner::maybeJoinChannel(mumble::MumbleCommunicator *mc) { if(channel_id > -1) { mc->joinChannel(channel_id); } } /* This is a secondary channel-switching object that relys on updates to the * class variable 'channels' for the channel list from the server. */ void mumble::MumbleChannelJoiner::findJoinChannel(mumble::MumbleCommunicator *mc) { boost::smatch s; int found = -1; for(std::vector::iterator it = channels.begin(); it != channels.end(); ++it) { if(boost::regex_match(it->name, s, channelNameRegex)) { found = it->id; } } if(found > -1) { mc->joinChannel(found); } }