Exemplo n.º 1
0
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));
    }
}
Exemplo n.º 2
0
void
call_list_draw_header(PANEL *panel)
{
    const char *infile, *coldesc;
    int height, width, colpos, collen, i;

    // Get panel info
    call_list_info_t *info = call_list_info(panel);

    // Let's draw the fixed elements of the screen
    WINDOW *win = panel_window(panel);
    getmaxyx(win, height, width);

    // Draw panel title
    draw_title(panel, "sngrep - SIP messages flow viewer");

    // Draw a Panel header lines
    clear_line(win, 1);
    if ((infile = capture_get_infile()))
        mvwprintw(win, 1, width - strlen(infile) - 11, "Filename: %s", infile);
    mvwprintw(win, 2, 2, "Display Filter: ");
    mvwprintw(win, 1, 2, "Current Mode: %s", capture_get_status_desc());

    // Reverse colors on monochrome terminals
    if (!has_colors())
        wattron(win, A_REVERSE);

    // Draw columns titles
    wattron(win, A_BOLD | COLOR_PAIR(CP_DEF_ON_CYAN));
    mvwprintw(win, 3, 0, "%*s", width, "");
    for (colpos = 6, i = 0; i < info->columncnt; i++) {
        // Get current column width
        collen = info->columns[i].width;
        // Get current column title
        coldesc = sip_attr_get_title(info->columns[i].id);

        // Check if the column will fit in the remaining space of the screen
        if (colpos + strlen(coldesc) >= width)
            break;
        mvwprintw(win, 3, colpos, "%.*s", collen, coldesc);
        colpos += collen + 1;
    }
    // Print Autoscroll indicator
    if (info->autoscroll)
        mvwprintw(win, 3, 0, "A");
    wattroff(win, A_BOLD | A_REVERSE | COLOR_PAIR(CP_DEF_ON_CYAN));

    // Get filter call counters
    sip_calls_stats(&info->callcnt, &info->dispcallcnt);

    // Print calls count (also filtered)
    mvwprintw(win, 1, 35, "%*s", 35, "");
    if (info->callcnt != info->dispcallcnt) {
        mvwprintw(win, 1, 35, "Dialogs: %d (%d displayed)", info->callcnt, info->dispcallcnt);
    } else {
        mvwprintw(win, 1, 35, "Dialogs: %d", info->callcnt);
    }

}
Exemplo n.º 3
0
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;
}