Commit ab18a48d authored by Gabriel Margiani's avatar Gabriel Margiani

Phonebook logging and fix

parent 4c9833ad
......@@ -48,7 +48,7 @@ void p3::phonebook::load() {
id_count = 0;
std::ifstream f(conf->get_string("phonebook:filename"));
std::string l;
std::string l;
while(std::getline(f, l)) {
std::istringstream il(l);
std::string nr("");
......@@ -106,12 +106,12 @@ void p3::phonebook::add_number(const std::string& nr) {
if (com.empty() || com == "none") return;
com += " " + nr;
std::cout << "Looking up name for '" << nr << "' using '"
std::cout << "PHONEBOOK: Looking up name for '" << nr << "' using '"
<< com << "'" << std::endl;
FILE* pipe = popen(com.c_str(), "r");
if (!pipe) {
std::cout << "Failed to run '" << com
std::cout << "PHONEBOOK: Failed to run '" << com
<< "' to reverse lookup '" << nr << "'" << std::endl;
return;
}
......@@ -132,7 +132,7 @@ void p3::phonebook::add_number(const std::string& nr) {
name = std::regex_replace(name,std::regex("\\s+"), " ");
boost::trim(name);
std::cout << "Got name for '" << nr << "': '" << name << "'" << std::endl;
std::cout << "PHONEBOOK: Got name for '" << nr << "': '" << name << "'" << std::endl;
g.lock();
......@@ -170,7 +170,7 @@ void p3::phonebook::add(const std::string& nr) {
std::string name("");
std::string num(nr);
bool non_voip = false;
bool non_voip = true;
if (std::regex_search(nr, match, rnm) && match.size() > 1) {
name = match.str(1);
......@@ -180,9 +180,9 @@ void p3::phonebook::add(const std::string& nr) {
if (match.str(2) == conf->get_string("phonebook:default_uri") ||
match.str(2) == conf->get_string("phonebook:default_uri_alias")) {
num = match.str(1);
non_voip = true;
} else {
num = "<sip:" + match.str(1) + "@" + match.str(2) + ">";
non_voip = false;
}
normalize(num);
}
......@@ -191,10 +191,13 @@ void p3::phonebook::add(const std::string& nr) {
if (non_voip && name.empty() &&
conf->get_string("phonebook:reverse_lookup_command") != "none") {
std::cout << "PHONEBOOK: Scheduling reverse lookup of " << num << std::endl;
shedule_add(num);
return;
}
std::cout << "PHONEBOOK: adding " << name << "<" << num << ">" << std::endl;
data[id_count] = {num, name, ""};
index[num] = id_count;
if (!name.empty()) index[name] = id_count;
......
......@@ -209,6 +209,11 @@ void p3::sipphone::handle_incoming_call(int pjid) {
pj::CallOpParam o;
if (always_busy || (get_call_count() > 1 && conf.get_bool("phone:busy_on_busy"))) {
eventhook.run_hook(
"auto_busy",
book.address_by_nr(c->get_nr()),
always_busy ? "busyall" : "busy on busy"
);
o.statusCode = PJSIP_SC_BUSY_HERE;
c->hangup(o);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment