From b256cf5695919293daa7a6fe392a55a6f450307e Mon Sep 17 00:00:00 2001 From: Brian West Date: Sat, 14 Jul 2012 14:05:26 -0500 Subject: [PATCH 1/8] fix auth_only voicemail usage --- src/mod/applications/mod_voicemail/mod_voicemail.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index de44945e8e..611243bb2e 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -3535,12 +3535,12 @@ SWITCH_STANDARD_APP(voicemail_function) if (argv[x] && !strcasecmp(argv[x], "check")) { check++; x++; - } else if (argv[x] && !strcasecmp(argv[x], "auth")) { - auth++; - x++; } else if (argv[x] && !strcasecmp(argv[x], "auth_only")) { auth = 2; x++; + } else if (argv[x] && !strcasecmp(argv[x], "auth")) { + auth++; + x++; } else { break; } @@ -3584,7 +3584,7 @@ SWITCH_STANDARD_APP(voicemail_function) return; } - if (check) { + if (check || auth == 2) { if (argv[x]) { uuid = argv[x++]; } From addcddc1ae617e6a8aa69b4038fc4669a957b9b4 Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Sun, 15 Jul 2012 00:31:08 +0200 Subject: [PATCH 2/8] mod_http_cache: Fix last remaining C99-style for loop. Signed-off-by: Stefan Knoblich --- src/mod/applications/mod_http_cache/mod_http_cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_http_cache/mod_http_cache.c b/src/mod/applications/mod_http_cache/mod_http_cache.c index aec7be684d..856f2be0a1 100644 --- a/src/mod/applications/mod_http_cache/mod_http_cache.c +++ b/src/mod/applications/mod_http_cache/mod_http_cache.c @@ -698,6 +698,7 @@ static cached_url_t *cached_url_create(url_cache_t *cache, const char *url) char *dirname = NULL; cached_url_t *u = NULL; const char *file_extension = ""; + const char *ext = NULL; if (zstr(url)) { return NULL; @@ -716,7 +717,7 @@ static cached_url_t *cached_url_create(url_cache_t *cache, const char *url) switch_dir_make_recursive(dirname, SWITCH_DEFAULT_DIR_PERMS, cache->pool); /* find extension on the end of URL */ - for(const char *ext = &url[strlen(url) - 1]; ext != url; ext--) { + for (ext = &url[strlen(url) - 1]; ext != url; ext--) { if (*ext == '/' || *ext == '\\') { break; } From fa03e4e0caf01a776b9114c94789474af14ebee0 Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Sun, 15 Jul 2012 00:43:00 +0200 Subject: [PATCH 3/8] mod_http_cache: Remove DOS line-endings in http_put(). Signed-off-by: Stefan Knoblich --- .../mod_http_cache/mod_http_cache.c | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/mod/applications/mod_http_cache/mod_http_cache.c b/src/mod/applications/mod_http_cache/mod_http_cache.c index 856f2be0a1..d4117d0a69 100644 --- a/src/mod/applications/mod_http_cache/mod_http_cache.c +++ b/src/mod/applications/mod_http_cache/mod_http_cache.c @@ -191,29 +191,29 @@ static void url_cache_clear(url_cache_t *cache, switch_core_session_t *session); static switch_status_t http_put(url_cache_t *cache, switch_core_session_t *session, const char *url, const char *filename) { switch_status_t status = SWITCH_STATUS_SUCCESS; - - switch_curl_slist_t *headers = NULL; /* optional linked-list of HTTP headers */ - char *ext; /* file extension, used for MIME type identification */ - const char *mime_type = "application/octet-stream"; - char *buf; - + + switch_curl_slist_t *headers = NULL; /* optional linked-list of HTTP headers */ + char *ext; /* file extension, used for MIME type identification */ + const char *mime_type = "application/octet-stream"; + char *buf; + CURL *curl_handle = NULL; long httpRes = 0; struct stat file_info = {0}; FILE *file_to_put = NULL; int fd; - - /* guess what type of mime content this is going to be */ - if ((ext = strrchr(filename, '.'))) { - ext++; - if (!(mime_type = switch_core_mime_ext2type(ext))) { - mime_type = "application/octet-stream"; - } - } - - buf = switch_mprintf("Content-Type: %s", mime_type); - headers = switch_curl_slist_append(headers, buf); - + + /* guess what type of mime content this is going to be */ + if ((ext = strrchr(filename, '.'))) { + ext++; + if (!(mime_type = switch_core_mime_ext2type(ext))) { + mime_type = "application/octet-stream"; + } + } + + buf = switch_mprintf("Content-Type: %s", mime_type); + headers = switch_curl_slist_append(headers, buf); + /* open file and get the file size */ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "opening %s for upload to %s\n", filename, url); fd = open(filename, O_RDONLY); @@ -244,7 +244,7 @@ static switch_status_t http_put(url_cache_t *cache, switch_core_session_t *sessi switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1); switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1); switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); - switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers); + switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers); switch_curl_easy_setopt(curl_handle, CURLOPT_URL, url); switch_curl_easy_setopt(curl_handle, CURLOPT_READDATA, file_to_put); switch_curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); @@ -279,12 +279,12 @@ done: fclose(file_to_put); } - if (headers) { - switch_curl_slist_free_all(headers); - } - - switch_safe_free(buf); - + if (headers) { + switch_curl_slist_free_all(headers); + } + + switch_safe_free(buf); + return status; } From 545c387938ad70ad7c204d7107519778c71d931b Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 14 Jul 2012 20:23:13 -0500 Subject: [PATCH 4/8] frick --- libs/libscgi/src/scgi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libscgi/src/scgi.c b/libs/libscgi/src/scgi.c index df05b5980b..d0eeab5203 100644 --- a/libs/libscgi/src/scgi.c +++ b/libs/libscgi/src/scgi.c @@ -606,7 +606,7 @@ SCGI_DECLARE(scgi_status_t) scgi_accept(scgi_socket_t server_sock, scgi_socket_t clntLen = sizeof(*echoClntAddr); if ((client_sock = accept(server_sock, (struct sockaddr *) echoClntAddr, &clntLen)) == SCGI_SOCK_INVALID) { - printf("FRICK %s\n", strerror(errno)); + //printf("FRICK %s\n", strerror(errno)); status = SCGI_FAIL; } else { *client_sock_p = client_sock; From 8d6b64e0ca85f2463de518a91876b8cb1ad258ee Mon Sep 17 00:00:00 2001 From: Seven Du Date: Sun, 15 Jul 2012 11:22:18 +0800 Subject: [PATCH 5/8] add flags to conference xml_list and show also on conference list --- .../mod_conference/mod_conference.c | 97 ++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index fa5f02e8b9..7c9146b1b1 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -4903,13 +4903,96 @@ static switch_status_t conf_api_sub_list(conference_obj_t *conference, switch_st if (conference == NULL) { switch_mutex_lock(globals.hash_mutex); for (hi = switch_hash_first(NULL, globals.conference_hash); hi; hi = switch_hash_next(hi)) { + int fcount = 0; switch_hash_this(hi, NULL, NULL, &val); conference = (conference_obj_t *) val; - stream->write_function(stream, "Conference %s (%u member%s rate: %u%s)\n", + stream->write_function(stream, "Conference %s (%u member%s rate: %u%s flags: ", conference->name, conference->count, conference->count == 1 ? "" : "s", conference->rate, switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : ""); + + if (switch_test_flag(conference, CFLAG_LOCKED)) { + stream->write_function(stream, "%slocked", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_DESTRUCT)) { + stream->write_function(stream, "%sdestruct", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_WAIT_MOD)) { + stream->write_function(stream, "%swait_mod", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_AUDIO_ALWAYS)) { + stream->write_function(stream, "%saudio_always", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_RUNNING)) { + stream->write_function(stream, "%srunning", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_ANSWERED)) { + stream->write_function(stream, "%sanswered", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_ENFORCE_MIN)) { + stream->write_function(stream, "%senforce_min", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_BRIDGE_TO)) { + stream->write_function(stream, "%sbridge_to", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_DYNAMIC)) { + stream->write_function(stream, "%sdynamic", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_EXIT_SOUND)) { + stream->write_function(stream, "%sexit_sound", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_ENTER_SOUND)) { + stream->write_function(stream, "%senter_sound", fcount ? "|" : ""); + fcount++; + } + + if (conference->record_count > 0) { + stream->write_function(stream, "%srecording", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_VIDEO_BRIDGE)) { + stream->write_function(stream, "%svideo_bridge", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_VID_FLOOR)) { + stream->write_function(stream, "%svideo_floor_only", fcount ? "|" : ""); + fcount++; + } + + if (switch_test_flag(conference, CFLAG_RFC4579)) { + stream->write_function(stream, "%svideo_rfc4579", fcount ? "|" : ""); + fcount++; + } + + if (!fcount) { + stream->write_function(stream, "none"); + } + + stream->write_function(stream, ")\n"); + count++; if (!summary) { if (pretty) { @@ -5074,6 +5157,18 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer switch_xml_set_attr_d(x_conference, "endconf_grace_time", ival); } + if (switch_test_flag(conference, CFLAG_VIDEO_BRIDGE)) { + switch_xml_set_attr_d(x_conference, "video_bridge", "true"); + } + + if (switch_test_flag(conference, CFLAG_VID_FLOOR)) { + switch_xml_set_attr_d(x_conference, "video_floor_only", "true"); + } + + if (switch_test_flag(conference, CFLAG_RFC4579)) { + switch_xml_set_attr_d(x_conference, "video_rfc4579", "true"); + } + switch_snprintf(i, sizeof(i), "%d", switch_epoch_time_now(NULL) - conference->run_time); switch_xml_set_attr_d(x_conference, "run_time", ival); From 253e74d69b1b005a66f1131339467ae99a861f41 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Sun, 15 Jul 2012 12:37:54 +0800 Subject: [PATCH 6/8] add video_bridge flag to xml members --- src/mod/applications/mod_conference/mod_conference.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 7c9146b1b1..8a2dd2dc02 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -5267,6 +5267,9 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer x_tag = switch_xml_add_child_d(x_flags, "has_video", count++); switch_xml_set_txt_d(x_tag, switch_channel_test_flag(switch_core_session_get_channel(member->session), CF_VIDEO) ? "true" : "false"); + x_tag = switch_xml_add_child_d(x_flags, "video_bridge", count++); + switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_VIDEO_BRIDGE) ? "true" : "false"); + x_tag = switch_xml_add_child_d(x_flags, "has_floor", count++); switch_xml_set_txt_d(x_tag, (member == member->conference->floor_holder) ? "true" : "false"); From f55f15c888aa5f7531516311b8b321198bd6993d Mon Sep 17 00:00:00 2001 From: Seven Du Date: Sun, 15 Jul 2012 12:44:26 +0800 Subject: [PATCH 7/8] accept binary in api and bgapi --- src/mod/event_handlers/mod_erlang_event/handle_msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod/event_handlers/mod_erlang_event/handle_msg.c b/src/mod/event_handlers/mod_erlang_event/handle_msg.c index e6d0d7a5f9..618b7eb829 100644 --- a/src/mod/event_handlers/mod_erlang_event/handle_msg.c +++ b/src/mod/event_handlers/mod_erlang_event/handle_msg.c @@ -634,7 +634,7 @@ static switch_status_t handle_msg_api(listener_t *listener, erlang_msg * msg, in ei_get_type(buf->buff, &buf->index, &type, &size); arg = malloc(size + 1); - if (ei_decode_string(buf->buff, &buf->index, arg)) { + if (ei_decode_string_or_binary(buf->buff, &buf->index, size, arg)) { fail = SWITCH_TRUE; } @@ -664,7 +664,7 @@ static switch_status_t handle_msg_bgapi(listener_t *listener, erlang_msg * msg, { char api_cmd[MAXATOMLEN]; char arg[1024]; - if (arity < 3 || ei_decode_atom(buf->buff, &buf->index, api_cmd) || ei_decode_string(buf->buff, &buf->index, arg)) { + if (arity < 3 || ei_decode_atom(buf->buff, &buf->index, api_cmd) || ei_decode_string_or_binary(buf->buff, &buf->index, 1023, arg)) { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "badarg"); From b2f0e9079585858f7d2e07197b063d856ba55213 Mon Sep 17 00:00:00 2001 From: Brian West Date: Sun, 15 Jul 2012 00:05:28 -0500 Subject: [PATCH 8/8] fix set user call to include domain --- src/mod/applications/mod_voicemail/mod_voicemail.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 611243bb2e..699bc96311 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -2548,7 +2548,10 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p if (authed) { switch_channel_set_variable(channel, "user_pin_authenticated", "true"); switch_channel_set_variable(channel, "user_pin_authenticated_user", myid); - if (!zstr(myid)) switch_ivr_set_user(session, myid); + if (!zstr(myid) && !zstr(domain_name)) { + char *account = switch_core_session_sprintf(session, "%s@%s", myid, domain_name); + switch_ivr_set_user(session, account); + } } else { switch_channel_hangup(channel, SWITCH_CAUSE_USER_CHALLENGE); }