Compare commits

...

4 Commits

Author SHA1 Message Date
timando 008db7f8ed
Merge 30aa4c51c6 into 3b58ebc5f3 2025-01-21 00:17:21 +00:00
junction1153b 3b58ebc5f3
[mod_sofia] Update Polycom UA to recognize new Poly phones
We observed that the new Poly phones (formerly known as Polycom) were not getting sent a SIP UPDATE in certain circumstances (example: retrieving a parked call, and therefore, Caller ID would not show the parked caller). I renamed Polycom to Poly which will catch all Poly AND Polycom UA's. I also added Acrobits, and Ringotel to extend such functionality to those UA's. There were also other minor compatibility issues with the new Poly phones which have been resolved with tweaking the UA recognition on the code.

Co-authored-by: Joseph <junction1153@gmail.com>
2025-01-21 00:57:25 +03:00
timando 30aa4c51c6
Update mod_voicemail.c 2023-08-31 12:44:24 +10:00
Tim Anderson (on dev server) eca1985ba9 [mod_voicemail] allow mod_voicemail to work with mod_http_cache as storage location
This commit makes mod_voicemail assume file system operations succeed if the
filename is a url. This means that you can set the `storage-dir` parameter
to a mod_http_cache url and it should just work.

Note: this does not work for deleting voicemail recordings from the http
server. Doing so would require adding delete support to mod_http_cache and
the generic file handling code.
2023-08-30 04:01:53 +00:00
5 changed files with 40 additions and 24 deletions

View File

@ -206,6 +206,20 @@ const char * mwi_reason2str(mwi_reason_t state)
return str;
}
switch_status_t vm_file_exists(const char *filename, switch_memory_pool_t *pool)
{
//If filename is a URL, assume it exists
if(filename && strstr(filename, "://")) return SWITCH_STATUS_SUCCESS;
return switch_file_exists(filename, pool);
}
switch_status_t vm_dir_make_recursive(const char *path, switch_fileperms_t perm, switch_memory_pool_t *pool)
{
//If path is a url e.g. mod_http_cache, assume success
if(path && strstr(path, "://")) return SWITCH_STATUS_SUCCESS;
return switch_dir_make_recursive(path, perm, pool);
}
switch_cache_db_handle_t *vm_get_db_handle(vm_profile_t *profile)
{
@ -1231,7 +1245,7 @@ static switch_status_t create_file(switch_core_session_t *session, vm_profile_t
switch_ivr_record_file(session, &fh, file_path, &args, profile->max_record_len);
if (switch_file_exists(file_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
if (vm_file_exists(file_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
got_file = 1;
}
@ -1635,7 +1649,7 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t
memset(&fh, 0, sizeof(fh));
cc.fh = &fh;
cc.playback_controls_active = 1;
if (switch_file_exists(cbt->file_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
if (vm_file_exists(cbt->file_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
TRY_CODE(switch_ivr_play_file(session, &fh, cbt->file_path, &args));
}
cc.playback_controls_active = 0;
@ -2644,7 +2658,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
profile->name, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, myid);
}
if (switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
if (vm_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error creating %s\n", dir_path);
goto end;
}
@ -2853,7 +2867,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
SWITCH_PATH_SEPARATOR, profile->name, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, myid);
}
if (switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, pool) != SWITCH_STATUS_SUCCESS) {
if (vm_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", dir_path);
ret = SWITCH_STATUS_FALSE;
goto failed;
@ -2889,7 +2903,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
}
}
if (insert_db && switch_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) {
if (insert_db && vm_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) {
char *usql;
switch_event_t *message_event;
@ -2923,7 +2937,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
update_mwi(profile, myid, domain_name, myfolder, MWI_REASON_NEW);
}
if (send_mail && (!zstr(vm_email) || !zstr(vm_notify_email)) && switch_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) {
if (send_mail && (!zstr(vm_email) || !zstr(vm_notify_email)) && vm_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) {
switch_event_t *event;
char *from;
char *body;
@ -3141,7 +3155,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
failed:
if (!insert_db && file_path && switch_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) {
if (!insert_db && file_path && vm_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) {
if (unlink(file_path) != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to delete file [%s]\n", file_path);
}
@ -3490,7 +3504,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
SWITCH_PATH_SEPARATOR, profile->name, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, id);
}
if (switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
if (vm_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error creating %s\n", dir_path);
goto end;
}
@ -3528,11 +3542,11 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
switch_ivr_sleep(session, 100, SWITCH_TRUE, NULL);
if (switch_file_exists(greet_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
if (vm_file_exists(greet_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
memset(buf, 0, sizeof(buf));
TRY_CODE(switch_ivr_play_file(session, NULL, greet_path, &args));
} else {
if (switch_file_exists(cbt.name_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
if (vm_file_exists(cbt.name_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
memset(buf, 0, sizeof(buf));
TRY_CODE(switch_ivr_play_file(session, NULL, cbt.name_path, &args));
}
@ -5123,10 +5137,10 @@ SWITCH_STANDARD_API(vm_fsdb_pref_greeting_set_function)
profile->name, SWITCH_PATH_SEPARATOR, domain, SWITCH_PATH_SEPARATOR, id);
char *final_file_path = switch_core_sprintf(pool, "%s%sgreeting_%d.%s", dir_path, SWITCH_PATH_SEPARATOR, slot, profile->file_ext);
switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, pool);
vm_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, pool);
if (file_path) {
if (switch_file_exists(file_path, pool) != SWITCH_STATUS_SUCCESS) {
if (vm_file_exists(file_path, pool) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "-ERR Filename doesn't exist\n");
profile_rwunlock(profile);
goto done;
@ -5135,7 +5149,7 @@ SWITCH_STANDARD_API(vm_fsdb_pref_greeting_set_function)
switch_file_rename(file_path, final_file_path, pool);
}
if (switch_file_exists(final_file_path, pool) == SWITCH_STATUS_SUCCESS) {
if (vm_file_exists(final_file_path, pool) == SWITCH_STATUS_SUCCESS) {
sql = switch_mprintf("SELECT count(*) FROM voicemail_prefs WHERE username = '%q' AND domain = '%q'", id, domain);
vm_execute_sql2str(profile, profile->mutex, sql, res, sizeof(res));
@ -5278,7 +5292,7 @@ SWITCH_STANDARD_API(vm_fsdb_pref_recname_set_function)
goto done;
}
if (switch_file_exists(file_path, pool) != SWITCH_STATUS_SUCCESS) {
if (vm_file_exists(file_path, pool) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "-ERR Filename doesn't exist\n");
profile_rwunlock(profile);
goto done;
@ -5295,9 +5309,9 @@ SWITCH_STANDARD_API(vm_fsdb_pref_recname_set_function)
profile->name, SWITCH_PATH_SEPARATOR, domain, SWITCH_PATH_SEPARATOR, id);
char *final_file_path = switch_core_sprintf(pool, "%s%srecorded_name.%s", dir_path, SWITCH_PATH_SEPARATOR, profile->file_ext);
switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, pool);
vm_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, pool);
if (switch_file_exists(file_path, pool) != SWITCH_STATUS_SUCCESS) {
if (vm_file_exists(file_path, pool) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "-ERR Filename doesn't exist\n");
profile_rwunlock(profile);
goto done;
@ -5827,12 +5841,12 @@ SWITCH_STANDARD_API(vm_fsdb_msg_forward_function)
vm_execute_sql_callback(profile, profile->mutex, sql, message_get_callback, &cbt);
switch_safe_free(sql);
file_path = switch_event_get_header(cbt.my_params, "VM-Message-File-Path");
if (file_path && switch_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) {
if (file_path && vm_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) {
const char *new_file_path = file_path;
const char *command = NULL;
if (prepend_file_path && switch_file_exists(prepend_file_path, pool) == SWITCH_STATUS_SUCCESS) {
if (prepend_file_path && vm_file_exists(prepend_file_path, pool) == SWITCH_STATUS_SUCCESS) {
switch_uuid_t tmp_uuid;
char tmp_uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
const char *test[3] = { NULL };

View File

@ -254,7 +254,7 @@ char *generate_pai_str(private_object_t *tech_pvt)
callee_number = switch_sanitize_number(switch_core_session_strdup(session, callee_number));
callee_name = switch_sanitize_number(switch_core_session_strdup(session, callee_name));
if (!zstr(callee_number) && (zstr(ua) || !switch_stristr("polycom", ua))) {
if (!zstr(callee_number) && (zstr(ua) || !switch_stristr("poly", ua))) {
callee_number = switch_core_session_sprintf(session, "sip:%s@%s", callee_number, host);
}
@ -2075,13 +2075,15 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), SIPTAG_PAYLOAD_STR(message), TAG_END());
} else if (update_allowed && ua && (switch_channel_var_true(tech_pvt->channel, "update_ignore_ua") ||
switch_stristr("polycom", ua) ||
switch_stristr("poly", ua) ||
(switch_stristr("aastra", ua) && !switch_stristr("Intelligate", ua)) ||
(switch_stristr("cisco/spa50", ua) ||
switch_stristr("cisco/spa525", ua)) ||
switch_stristr("cisco/spa30", ua) ||
switch_stristr("Fanvil", ua) ||
switch_stristr("Grandstream", ua) ||
switch_stristr("Ringotel", ua) ||
switch_stristr("Groundwire", ua) ||
switch_stristr("Yealink", ua) ||
switch_stristr("Mitel", ua) ||
switch_stristr("Panasonic", ua))) {
@ -2152,7 +2154,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
SIPTAG_PAYLOAD_STR(message),
TAG_IF(!zstr(session_id_header), SIPTAG_HEADER_STR(session_id_header)),
TAG_END());
} else if (ua && switch_stristr("polycom", ua)) {
} else if (ua && switch_stristr("poly", ua)) {
snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", msg->string_arg, tech_pvt->caller_profile->destination_number);
nua_update(tech_pvt->nh,
NUTAG_SESSION_TIMER(tech_pvt->session_timeout),

View File

@ -10476,7 +10476,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
(!is_tcp && !is_tls && (zstr(network_ip) || !switch_check_network_list_ip(network_ip, profile->local_network)) &&
profile->server_rport_level >= 2 && sip->sip_user_agent &&
sip->sip_user_agent->g_string &&
(!strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) || !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20)))
(!strncasecmp(sip->sip_user_agent->g_string, "Poly", 4) || !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20)))
) {
if (sip->sip_via) {
const char *port = sip->sip_via->v_port;

View File

@ -2501,7 +2501,7 @@ static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *r
{
char *ret = NULL;
if (switch_stristr("polycom", user_agent)) {
if (switch_stristr("poly", user_agent)) {
*ct = "application/xpidf+xml";
/* If unknown/none prpid is provided, just show the user as online. */

View File

@ -1661,7 +1661,7 @@ uint8_t sofia_reg_handle_register_token(nua_t *nua, sofia_profile_t *profile, nu
if (!is_tcp && !is_tls && (zstr(network_ip) || !switch_check_network_list_ip(network_ip, profile->local_network)) &&
profile->server_rport_level >= 2 && sip->sip_user_agent &&
sip->sip_user_agent->g_string &&
( !strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) ||
( !strncasecmp(sip->sip_user_agent->g_string, "Poly", 4) ||
!strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20) ||
!strncasecmp(sip->sip_user_agent->g_string, "ADTRAN_Total_Access", 19) )) {
if (sip->sip_via) {