Loading .gitignore +1 −0 Original line number Diff line number Diff line *.swp *.o *.P 3phone src/account.h +8 −6 Original line number Diff line number Diff line Loading @@ -22,13 +22,15 @@ #include <pjsua2.hpp> class p3Account : public pj::Account { namespace p3 { class account : public pj::Account { public: p3Account() {}; ~p3Account() {}; account() {}; ~account() {}; virtual void onRegState(OnRegStateParam &prm); virtual void onIncomingCall(OnIncomingCallParam &iprm); virtual void onRegState(pj::OnRegStateParam &prm); virtual void onIncomingCall(pj::OnIncomingCallParam &iprm); }; } #endif src/call.cpp 0 → 100644 +31 −0 Original line number Diff line number Diff line /** * This file is part of 3phone * Copyright (C) 2015 Gabriel Margiani * * 3phone is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 3phone is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with 3phone. If not, see <http://www.gnu.org/licenses/>. **/ #include "call.h" p3::call::call(p3::account &acc, int call_id) : Call(acc, call_id) { } p3::call::~call() { } void p3::call::onCallState(pj::OnCallStateParam& prm) { } void p3::call::onCallMediaState(pj::OnCallMediaStateParam& prm) { } src/call.h 0 → 100644 +39 −0 Original line number Diff line number Diff line /** * This file is part of 3phone * Copyright (C) 2015 Gabriel Margiani * * 3phone is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 3phone is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with 3phone. If not, see <http://www.gnu.org/licenses/>. **/ #ifndef __P3_CALL_H__ #define __P3_CALL_H__ #include <pjsua2.hpp> #include "account.h" namespace p3 { class call : public pj::Call { public: call(p3::account& acc, int call_id = PJSUA_INVALID_ID); ~call(); void onCallState(pj::OnCallStateParam &prm); void onCallMediaState(pj::OnCallMediaStateParam &prm); }; } #endif src/client.cpp +17 −4 Original line number Diff line number Diff line Loading @@ -26,11 +26,18 @@ #include "error.h" std::map<std::string, std::string> p3::client::command_shorthands { {"c", "call"} {"c", "call"}, {"q", "quit"}, {"x", "exit"} }; p3::client::client(int ac, char *av[]) : argv(av, av+ac) { p3::client::client(int ac, char *av[]) : argv(av, av+ac), interactive(false) { argv.pop_front(); auto i = std::find(argv.begin(), argv.end(), "-I"); if (i != argv.end()) { interactive = true; argv.erase(i); } std::random_device rd; std::default_random_engine e(rd()); Loading @@ -39,11 +46,12 @@ p3::client::client(int ac, char *av[]) : argv(av, av+ac) { connection = nullptr; try { std::cout << "connecting..." << std::endl; p3::mQueue ma(p3::mQueue::DefaultId, false); connection = new mQueue(id, true); ma.send(p3::protocol::HELLO, id); p3::mQueueMessage m = ma.receive(30); p3::mQueueMessage m = connection->receive(30); if (m.get_command() != p3::protocol::OK) { throw new p3::perror("client.connection", "cannot connect to server " + m.get_value()); Loading @@ -66,12 +74,17 @@ std::string p3::client::get_input(std::string q, p3::client::inputType type) { if (!argv.empty()) { in = argv.front(); argv.pop_front(); } else if (!interactive && type == COMMAND) { return "quit"; // We have parsed all arguments... } else { do { std::cout << q << " > " << std::flush; std::cin >> in; boost::trim(in); } while (in == ""); } while (std::cin && in == ""); if (in == "") { return "quit"; } } boost::to_lower(in); Loading Loading
src/account.h +8 −6 Original line number Diff line number Diff line Loading @@ -22,13 +22,15 @@ #include <pjsua2.hpp> class p3Account : public pj::Account { namespace p3 { class account : public pj::Account { public: p3Account() {}; ~p3Account() {}; account() {}; ~account() {}; virtual void onRegState(OnRegStateParam &prm); virtual void onIncomingCall(OnIncomingCallParam &iprm); virtual void onRegState(pj::OnRegStateParam &prm); virtual void onIncomingCall(pj::OnIncomingCallParam &iprm); }; } #endif
src/call.cpp 0 → 100644 +31 −0 Original line number Diff line number Diff line /** * This file is part of 3phone * Copyright (C) 2015 Gabriel Margiani * * 3phone is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 3phone is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with 3phone. If not, see <http://www.gnu.org/licenses/>. **/ #include "call.h" p3::call::call(p3::account &acc, int call_id) : Call(acc, call_id) { } p3::call::~call() { } void p3::call::onCallState(pj::OnCallStateParam& prm) { } void p3::call::onCallMediaState(pj::OnCallMediaStateParam& prm) { }
src/call.h 0 → 100644 +39 −0 Original line number Diff line number Diff line /** * This file is part of 3phone * Copyright (C) 2015 Gabriel Margiani * * 3phone is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 3phone is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with 3phone. If not, see <http://www.gnu.org/licenses/>. **/ #ifndef __P3_CALL_H__ #define __P3_CALL_H__ #include <pjsua2.hpp> #include "account.h" namespace p3 { class call : public pj::Call { public: call(p3::account& acc, int call_id = PJSUA_INVALID_ID); ~call(); void onCallState(pj::OnCallStateParam &prm); void onCallMediaState(pj::OnCallMediaStateParam &prm); }; } #endif
src/client.cpp +17 −4 Original line number Diff line number Diff line Loading @@ -26,11 +26,18 @@ #include "error.h" std::map<std::string, std::string> p3::client::command_shorthands { {"c", "call"} {"c", "call"}, {"q", "quit"}, {"x", "exit"} }; p3::client::client(int ac, char *av[]) : argv(av, av+ac) { p3::client::client(int ac, char *av[]) : argv(av, av+ac), interactive(false) { argv.pop_front(); auto i = std::find(argv.begin(), argv.end(), "-I"); if (i != argv.end()) { interactive = true; argv.erase(i); } std::random_device rd; std::default_random_engine e(rd()); Loading @@ -39,11 +46,12 @@ p3::client::client(int ac, char *av[]) : argv(av, av+ac) { connection = nullptr; try { std::cout << "connecting..." << std::endl; p3::mQueue ma(p3::mQueue::DefaultId, false); connection = new mQueue(id, true); ma.send(p3::protocol::HELLO, id); p3::mQueueMessage m = ma.receive(30); p3::mQueueMessage m = connection->receive(30); if (m.get_command() != p3::protocol::OK) { throw new p3::perror("client.connection", "cannot connect to server " + m.get_value()); Loading @@ -66,12 +74,17 @@ std::string p3::client::get_input(std::string q, p3::client::inputType type) { if (!argv.empty()) { in = argv.front(); argv.pop_front(); } else if (!interactive && type == COMMAND) { return "quit"; // We have parsed all arguments... } else { do { std::cout << q << " > " << std::flush; std::cin >> in; boost::trim(in); } while (in == ""); } while (std::cin && in == ""); if (in == "") { return "quit"; } } boost::to_lower(in); Loading