switch_time_t l_duration = 0;
switch_core_time_duration_t duration;
char duration_str[80];
-
+ char *formatted_cid_num = NULL;
if (!strcasecmp(cbt->read_flags, URGENT_FLAG_STRING)) {
priority = 1;
}
switch_time_exp_lt(&tm, switch_time_make(atol(cbt->created_epoch), 0));
switch_strftime(date, &retsize, sizeof(date), profile->date_fmt, &tm);
+ formatted_cid_num = switch_format_number(cbt->cid_number);
+
switch_snprintf(tmp, sizeof(tmp), "%d", total_new_messages);
switch_channel_set_variable(channel, "voicemail_total_new_messages", tmp);
switch_snprintf(tmp, sizeof(tmp), "%d", total_saved_messages);
switch_channel_set_variable(channel, "voicemail_account", cbt->user);
switch_channel_set_variable(channel, "voicemail_domain", cbt->domain);
switch_channel_set_variable(channel, "voicemail_caller_id_number", cbt->cid_number);
+ switch_channel_set_variable(channel, "voicemail_formatted_caller_id_number", formatted_cid_num);
switch_channel_set_variable(channel, "voicemail_caller_id_name", cbt->cid_name);
switch_channel_set_variable(channel, "voicemail_file_path", cbt->file_path);
switch_channel_set_variable(channel, "voicemail_read_flags", cbt->read_flags);
switch_snprintf(tmp, sizeof(tmp), "%d", priority);
switch_channel_set_variable(channel, "voicemail_priority", tmp);
message_len = atoi(cbt->message_len);
+ switch_safe_free(formatted_cid_num);
l_duration = switch_time_make(atol(cbt->message_len), 0);
switch_core_measure_time(l_duration, &duration);
switch_time_exp_t tm;
char date[80] = "";
switch_size_t retsize;
+ char *formatted_cid_num = NULL;
message_count(profile, myid, domain_name, myfolder, &total_new_messages, &total_saved_messages,
&total_new_urgent_messages, &total_saved_urgent_messages);
switch_strftime(date, &retsize, sizeof(date), profile->date_fmt, &tm);
}
+ formatted_cid_num = switch_format_number(caller_id_number);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_current_folder", myfolder);
switch_snprintf(tmpvar, sizeof(tmpvar), "%d", total_new_messages);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_total_new_messages", tmpvar);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_account", myid);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_domain", domain_name);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_caller_id_number", caller_id_number);
+ switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_formatted_caller_id_number", formatted_cid_num);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_caller_id_name", caller_id_name);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_file_path", file_path);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_read_flags", read_flags);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_time", date);
+ switch_safe_free(formatted_cid_num);
+
switch_snprintf(tmpvar, sizeof(tmpvar), "%d", priority);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_priority", tmpvar);
if (vm_email) {
}
+SWITCH_DECLARE(char *) switch_format_number(const char *num)
+{
+ char *r;
+ size_t len;
+ const char *p = num;
+
+ if(*p == '+') {
+ p++;
+ }
+
+ len = strlen(p);
+
+ /* region 1, TBD add more....*/
+ if (len == 11 && p[0] == '1') {
+ r = switch_mprintf("%c (%c%c%c) %c%c%c-%c%c%c%c", p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10]);
+ } else if (len == 10) {
+ r = switch_mprintf("1 (%c%c%c) %c%c%c-%c%c%c%c", p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9]);
+ } else {
+ r = strdup(num);
+ }
+
+
+ return r;
+}
+
+
/* For Emacs:
* Local Variables:
* mode:c