Commit 3d6f267f authored by Gabriel Margiani's avatar Gabriel Margiani
Browse files

Implemented dtmf send functionality

parent b46d6ca0
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ std::map<std::string, std::string> p3::client::command_shorthands {
	{"j", "conference"},
	{"t", "transfer"},
	{"join", "conference"},
	{"d", "dtmf"},
	{"q", "quit"},
	{"x", "exit"}
};
@@ -112,6 +113,9 @@ void p3::client::run() {
		p3::mQueueMessage m = connection->receive(-1);
		bool print_list = true;
		switch (m.get_command()) {
			case p3::protocol::ASK:
				connection->send(p3::protocol::ANSWER, get_input(m.get_value(), WORD));
				continue;
			case p3::protocol::ASK_NUMBER:
				connection->send(p3::protocol::ANSWER, get_input(m.get_value(), NUMBER));
				continue;
+2 −1
Original line number Diff line number Diff line
@@ -49,7 +49,8 @@ namespace p3 {
		enum inputType {
			COMMAND,
			NUMBER,
			ID
			ID,
			WORD
		};

		bool interactive;
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ void print_usage() {
		<< "p3 ma muteall         - mute microphone for all calls." << std::endl
		<< "p3 j oin              - conference current calls" << std::endl
		<< "p3 t ransfer [id] [nr] - forward call" << std::endl
		<< "p3 d tmf [dgts] [id]  - dial dtfm digits" << std::endl
		<< "p3 r ecord [file]     - record" << std::endl
		<< "-I for an interactive shell" << std::endl;
}
+12 −0
Original line number Diff line number Diff line
@@ -170,6 +170,8 @@ void p3::clientHandler::parse_command(const std::string& c) {
			handle_list();
		} else if ("reload" == c) {
			handle_reload();
		} else if ("dtmf" == c) {
			handle_dtmf();
		} else {
			std::cout << "Unknown command received: " << c << std::endl;
			connection.send(p3::protocol::ERROR, "Invalid Command '" + c + "'");
@@ -247,6 +249,16 @@ void p3::clientHandler::handle_reload() {
	connection.send(p3::protocol::OK, "reload OK");
}

void p3::clientHandler::handle_dtmf() {
	connection.send(p3::protocol::ASK, "Digits to send");
	p3::mQueueMessage n = connection.receive(listenTimeout);
	phone.dial_dtmf(
			get_call_id("Call do dial on (id)", p3::callState::RUNNING),
			n.get_value()
	);
	connection.send(p3::protocol::OK, "dtmf OK");
}

int p3::clientHandler::get_call_id(const std::string& q, p3::callState filter) {
	int nr = phone.get_call_count(filter);
	if (nr == 1) {
+1 −0
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ namespace p3 {
		void handle_reload();
		void handle_conference();
		void handle_transfer();
		void handle_dtmf();

		void send_calls_list(
				callState filter = callState::NONE,
Loading