void column_select_update_columns(ui_t *ui) { int column, attr_id; // Get panel information column_select_info_t *info = column_select_info(ui); // Set enabled fields ui_t *ui_list = ui_find_by_type(PANEL_CALL_LIST); call_list_info_t *list_info = call_list_info(ui_list); // Reset column count list_info->columncnt = 0; // Add all selected columns for (column = 0; column < item_count(info->menu); column++) { // If column is active if (!strncmp(item_name(info->items[column]), "[ ]", 3)) continue; // Get column attribute attr_id = sip_attr_from_name(item_userptr(info->items[column])); // Add a new column to the list call_list_add_column(ui_list, attr_id, sip_attr_get_name(attr_id), sip_attr_get_title(attr_id), sip_attr_get_width(attr_id)); } }
PANEL * call_list_create() { PANEL *panel; WINDOW *win; int height, width, i, attrid, collen; call_list_info_t *info; char option[80]; const char *field, *title; // Create a new panel that fill all the screen panel = new_panel(newwin(LINES, COLS, 0, 0)); // Initialize Call List specific data info = sng_malloc(sizeof(call_list_info_t)); // Store it into panel userptr set_panel_userptr(panel, (void*) info); // Add configured columns for (i = 0; i < SIP_ATTR_COUNT; i++) { // Get column attribute name from options sprintf(option, "cl.column%d", i); if ((field = get_option_value(option))) { if ((attrid = sip_attr_from_name(field)) == -1) continue; // Get column width from options sprintf(option, "cl.column%d.width", i); if ((collen = get_option_int_value(option)) == -1) collen = sip_attr_get_width(attrid); // Get column title title = sip_attr_get_title(attrid); // Add column to the list call_list_add_column(panel, attrid, field, title, collen); } } // Let's draw the fixed elements of the screen win = panel_window(panel); getmaxyx(win, height, width); // Initialize the fields info->fields[FLD_LIST_FILTER] = new_field(1, width - 19, 2, 18, 0, 0); info->fields[FLD_LIST_COUNT] = NULL; // Create the form and post it info->form = new_form(info->fields); set_form_sub(info->form, win); // Form starts inactive call_list_form_activate(panel, 0); // Calculate available printable area info->list_win = subwin(win, height - 5, width, 4, 0); info->group = call_group_create(); // Get current call list info->calls = sip_calls_iterator(); vector_iterator_set_filter(&info->calls, filter_check_call); info->cur_call = info->first_call = -1; // Set autoscroll default status info->autoscroll = setting_enabled(SETTING_CL_AUTOSCROLL); // Apply initial configured method filters filter_method_from_setting(setting_get_value(SETTING_FILTER_METHODS)); // Return the created panel return panel; }
void sip_init(int limit, int only_calls, int no_incomplete) { int match_flags, reg_rule_len, reg_rule_err; char reg_rule[SIP_ATTR_MAXLEN]; const char *setting = NULL; // Store capture limit calls.limit = limit; calls.only_calls = only_calls; calls.ignore_incomplete = no_incomplete; calls.last_index = 0; // Create a vector to store calls calls.list = vector_create(200, 50); vector_set_destroyer(calls.list, call_destroyer); vector_set_sorter(calls.list, sip_list_sorter); calls.active = vector_create(10, 10); // Create hash table for callid search calls.callids = htable_create(calls.limit); // Set default sorting field if (sip_attr_from_name(setting_get_value(SETTING_CL_SORTFIELD)) >= 0) { calls.sort.by = sip_attr_from_name(setting_get_value(SETTING_CL_SORTFIELD)); calls.sort.asc = (!strcmp(setting_get_value(SETTING_CL_SORTORDER), "asc")); } else { // Fallback to default sorting field calls.sort.by = SIP_ATTR_CALLINDEX; calls.sort.asc = true; } // Initialize payload parsing regexp match_flags = REG_EXTENDED | REG_ICASE | REG_NEWLINE; regcomp(&calls.reg_method, "^([a-zA-Z]+) [a-zA-Z]+:.+ SIP/2.0[ ]*\r", match_flags & ~REG_NEWLINE); regcomp(&calls.reg_callid, "^(Call-ID|i):[ ]*([^ ]+)[ ]*\r$", match_flags); setting = setting_get_value(SETTING_SIP_HEADER_X_CID); reg_rule_len = strlen(setting) + 22; if (reg_rule_len >= SIP_ATTR_MAXLEN) { setting = "X-Call-ID|X-CID"; reg_rule_len = strlen(setting) + 22; fprintf(stderr, "%s setting too long, using default.\n", setting_name(SETTING_SIP_HEADER_X_CID)); } snprintf(reg_rule, reg_rule_len, "^(%s):[ ]*([^ ]+)[ ]*\r$", setting); reg_rule_err = regcomp(&calls.reg_xcallid, reg_rule, match_flags); if(reg_rule_err != 0) { regerror(reg_rule_err, &calls.reg_xcallid, reg_rule, SIP_ATTR_MAXLEN); regfree(&calls.reg_xcallid); fprintf(stderr, "%s setting produces regex compilation error: %s" "using default value instead\n", setting_name(SETTING_SIP_HEADER_X_CID), reg_rule); regcomp(&calls.reg_xcallid, "^(X-Call-ID|X-CID):[ ]*([^ ]+)[ ]*\r$", match_flags); } regcomp(&calls.reg_response, "^SIP/2.0[ ]*(([0-9]{3}) [^\r]*)[ ]*\r", match_flags & ~REG_NEWLINE); regcomp(&calls.reg_cseq, "^CSeq:[ ]*([0-9]{1,10}) .+\r$", match_flags); regcomp(&calls.reg_from, "^(From|f):[ ]*[^:]*:(([^@>]+)@?[^\r>;]+)", match_flags); regcomp(&calls.reg_to, "^(To|t):[ ]*[^:]*:(([^@>]+)@?[^\r>;]+)", match_flags); regcomp(&calls.reg_valid, "^([A-Z]+ [a-zA-Z]+:|SIP/2.0 [0-9]{3})", match_flags & ~REG_NEWLINE); regcomp(&calls.reg_cl, "^(Content-Length|l):[ ]*([0-9]+)[ ]*\r$", match_flags); regcomp(&calls.reg_body, "\r\n\r\n(.*)", match_flags & ~REG_NEWLINE); regcomp(&calls.reg_reason, "Reason:[ ]*[^\r]*;text=\"([^\r]+)\"", match_flags); regcomp(&calls.reg_warning, "Warning:[ ]*([0-9]*)", match_flags); }