Forgot MumbleChannelJoiner component
This commit is contained in:
parent
94932e3159
commit
fc917fca7d
25
MumbleChannelJoiner.cpp
Normal file
25
MumbleChannelJoiner.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include "MumbleChannelJoiner.hpp"
|
||||||
|
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
mumble::MumbleChannelJoiner::MumbleChannelJoiner(std::string channelNameRegex) : channelNameRegex(boost::regex(channelNameRegex)),
|
||||||
|
logger(log4cpp::Category::getInstance("MumbleChannelJoiner")){
|
||||||
|
}
|
||||||
|
|
||||||
|
void mumble::MumbleChannelJoiner::checkChannel(std::string channel_name, int channel_id) {
|
||||||
|
boost::smatch s;
|
||||||
|
logger.debug("Channel %s available (%d)", channel_name.c_str(), channel_id);
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
23
MumbleChannelJoiner.hpp
Normal file
23
MumbleChannelJoiner.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <boost/noncopyable.hpp>
|
||||||
|
#include <log4cpp/Category.hh>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <boost/regex.hpp>
|
||||||
|
#include "MumbleCommunicator.hpp"
|
||||||
|
|
||||||
|
namespace mumble {
|
||||||
|
class MumbleChannelJoiner : boost::noncopyable {
|
||||||
|
public:
|
||||||
|
MumbleChannelJoiner(std::string channelNameRegex);
|
||||||
|
|
||||||
|
void checkChannel(std::string channel_name, int channel_id);
|
||||||
|
void maybeJoinChannel(mumble::MumbleCommunicator *mc);
|
||||||
|
|
||||||
|
private:
|
||||||
|
log4cpp::Category &logger;
|
||||||
|
boost::regex channelNameRegex;
|
||||||
|
int channel_id;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user