ncurses: refactor window structures and functions

This commit is contained in:
Kaian 2018-11-19 12:58:42 +01:00
parent 8ecc666652
commit a03d0d67c2
14 changed files with 167 additions and 166 deletions

View File

@ -34,15 +34,15 @@ set(SOURCES
src/capture/capture_pcap.c
src/capture/capture_txt.c
src/ncurses/manager.c
src/ncurses/call_flow.c
src/ncurses/call_list.c
src/ncurses/call_raw.c
src/ncurses/column_select.c
src/ncurses/call_flow_win.c
src/ncurses/call_list_win.c
src/ncurses/call_raw_win.c
src/ncurses/column_select_win.c
src/ncurses/ui_filter.c
src/ncurses/ui_msg_diff.c
src/ncurses/ui_save.c
src/ncurses/ui_settings.c
src/ncurses/stats.c
src/ncurses/stats_win.c
src/ncurses/window.c
src/ncurses/keybinding.c
src/ncurses/scrollbar.c

View File

@ -32,7 +32,7 @@
#include <string.h>
#include "glib-utils.h"
#include "storage.h"
#include "ncurses/call_list.h"
#include "ncurses/call_list_win.h"
#include "filter.h"
//! Storage of filter information
@ -120,7 +120,7 @@ filter_check_call(gconstpointer item, G_GNUC_UNUSED gconstpointer user_data)
break;
case FILTER_CALL_LIST:
// FIXME Maybe call should know hot to calculate this line
call_list_line_text(ncurses_find_by_type(WINDOW_CALL_LIST), call, data);
call_list_win_line_text(ncurses_find_by_type(WINDOW_CALL_LIST), call, data);
break;
default:
// Unknown filter id

View File

@ -33,8 +33,8 @@
#include <packet/dissectors/packet_sip.h>
#include "capture/capture_pcap.h"
#include "ncurses/manager.h"
#include "ncurses/call_flow.h"
#include "ncurses/call_raw.h"
#include "ncurses/call_flow_win.h"
#include "ncurses/call_raw_win.h"
#include "ncurses/ui_msg_diff.h"
#include "ncurses/ui_save.h"
#include "timeval.h"
@ -76,10 +76,10 @@
* @param window UI structure pointer
* @return a pointer to info structure of given panel
*/
static CallFlowInfo *
call_flow_info(Window *window)
static CallFlowWinInfo *
call_flow_win_info(Window *window)
{
return (CallFlowInfo*) panel_userptr(window->panel);
return (CallFlowWinInfo*) panel_userptr(window->panel);
}
/*
@ -95,7 +95,7 @@ static CallFlowArrow *
call_flow_arrow_selected(Window *window)
{
// Get panel info
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_val_if_fail(info != NULL, NULL);
// No selected call
@ -205,7 +205,7 @@ call_flow_arrow_find_item_cb(CallFlowArrow *arrow, gpointer item)
static CallFlowArrow *
call_flow_arrow_find(Window *window, const void *data)
{
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_val_if_fail(info != NULL, NULL);
g_return_val_if_fail(data != NULL, NULL);
@ -323,7 +323,7 @@ call_flow_arrow_message(const CallFlowArrow *arrow)
static CallFlowColumn *
call_flow_column_get(Window *window, const char *callid, Address addr)
{
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_val_if_fail(info != NULL, NULL);
// Look for address or address:port ?
@ -374,7 +374,7 @@ call_flow_column_get(Window *window, const char *callid, Address addr)
static void
call_flow_column_add(Window *window, const char *callid, Address addr)
{
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_if_fail(info != NULL);
if (call_flow_column_get(window, callid, addr))
@ -442,7 +442,7 @@ call_flow_draw_columns(Window *window)
Address addr;
// Get panel information
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_if_fail(info != NULL);
// In extended call flow, columns can have multiple call-ids
@ -547,7 +547,7 @@ call_flow_draw_message(Window *window, CallFlowArrow *arrow, int cline)
int aline = cline + 1;
// Get panel information
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_val_if_fail(info != NULL, 0);
// Get the messages window
@ -790,7 +790,7 @@ call_flow_draw_rtp_stream(Window *window, CallFlowArrow *arrow, int cline)
Address addr;
// Get panel information
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_val_if_fail(info != NULL, 0);
// Get the messages window
@ -1017,7 +1017,7 @@ call_flow_draw_arrows(Window *window)
int cline = 0;
// Get panel information
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_if_fail(info != NULL);
// Create pending SIP arrows
@ -1077,7 +1077,7 @@ call_flow_draw_raw(Window *window, Message *msg)
int min_raw_width, fixed_raw_width;
// Get panel information
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_if_fail(info != NULL);
// Get min raw width
@ -1145,13 +1145,13 @@ call_flow_draw_raw_rtcp(Window *window, G_GNUC_UNUSED RtpStream *stream)
*/
return 0;
CallFlowInfo *info;
CallFlowWinInfo *info;
WINDOW *raw_win;
int raw_width, raw_height;
int min_raw_width, fixed_raw_width;
// Get panel information
if (!(info = call_flow_info(window)))
if (!(info = call_flow_win_info(window)))
return 1;
// Get min raw width
@ -1218,7 +1218,7 @@ call_flow_draw_preview(Window *window)
return;
// Get panel information
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_if_fail(info != NULL);
// Draw current arrow preview
@ -1246,7 +1246,7 @@ call_flow_move(Window *window, guint idx)
int curh = 0;
// Get panel info
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_if_fail(info != NULL);
// Already in this position?
@ -1325,7 +1325,7 @@ call_flow_move(Window *window, guint idx)
static void
call_flow_move_up(Window *window, guint times)
{
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_if_fail(info != NULL);
gint newpos = info->cur_idx - times;
@ -1343,7 +1343,7 @@ call_flow_move_up(Window *window, guint times)
static void
call_flow_move_down(Window *window, guint times)
{
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_if_fail(info != NULL);
guint newpos = info->cur_idx + times;
@ -1373,7 +1373,7 @@ call_flow_handle_key(Window *window, int key)
int action = -1;
// Sanity check, this should not happen
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_val_if_fail(info != NULL, KEY_NOT_HANDLED);
// Check actions for this key
@ -1416,12 +1416,12 @@ call_flow_handle_key(Window *window, int key)
call_group_add(info->group, call);
info->group->callid = 0;
}
call_flow_set_group(window, info->group);
call_flow_win_set_group(window, info->group);
break;
case ACTION_SHOW_RAW:
// KEY_R, display current call in raw mode
next_window = ncurses_create_window(WINDOW_CALL_RAW);
call_raw_set_group(next_window, info->group);
call_raw_win_set_group(next_window, info->group);
break;
case ACTION_DECREASE_RAW:
raw_width = getmaxx(info->raw_win);
@ -1445,19 +1445,19 @@ call_flow_handle_key(Window *window, int key)
if (call_group_msg_count(info->group) == 0)
info->group->sdp_only = 0;
// Reset screen
call_flow_set_group(window, info->group);
call_flow_win_set_group(window, info->group);
break;
case ACTION_SDP_INFO:
setting_toggle(SETTING_CF_SDP_INFO);
break;
case ACTION_ONLY_MEDIA:
setting_toggle(SETTING_CF_ONLYMEDIA);
call_flow_set_group(window, info->group);
call_flow_win_set_group(window, info->group);
break;
case ACTION_TOGGLE_MEDIA:
setting_toggle(SETTING_CF_MEDIA);
// Force reload arrows
call_flow_set_group(window, info->group);
call_flow_win_set_group(window, info->group);
break;
case ACTION_TOGGLE_RAW:
setting_toggle(SETTING_CF_FORCERAW);
@ -1465,7 +1465,7 @@ call_flow_handle_key(Window *window, int key)
case ACTION_COMPRESS:
setting_toggle(SETTING_CF_SPLITCALLID);
// Force columns reload
call_flow_set_group(window, info->group);
call_flow_win_set_group(window, info->group);
break;
case ACTION_SAVE:
if (capture_sources_count(capture_manager()) > 1) {
@ -1501,8 +1501,9 @@ call_flow_handle_key(Window *window, int key)
case ACTION_CONFIRM:
// KEY_ENTER, display current message in raw mode
next_window = ncurses_create_window(WINDOW_CALL_RAW);
call_raw_set_group(next_window, info->group);
call_raw_set_msg(next_window, call_flow_arrow_message(g_ptr_array_index(info->darrows, info->cur_idx)));
call_raw_win_set_group(next_window, info->group);
call_raw_win_set_msg(next_window,
call_flow_arrow_message(g_ptr_array_index(info->darrows, info->cur_idx)));
break;
case ACTION_CLEAR_CALLS:
case ACTION_CLEAR_CALLS_SOFT:
@ -1595,9 +1596,9 @@ call_flow_help(G_GNUC_UNUSED Window *window)
}
void
call_flow_set_group(Window *window, CallGroup *group)
call_flow_win_set_group(Window *window, CallGroup *group)
{
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_if_fail(info != NULL);
g_ptr_array_remove_all(info->columns);
@ -1623,7 +1624,7 @@ call_flow_draw(Window *window)
char title[256];
// Get panel information
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_val_if_fail(info != NULL, -1);
// Get window of main panel
@ -1694,7 +1695,7 @@ call_flow_redraw(Window *window)
int maxx, maxy;
// Get panel information
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
// Get current screen dimensions
getmaxyx(stdscr, maxy, maxx);
@ -1717,9 +1718,9 @@ call_flow_redraw(Window *window)
}
void
call_flow_free(Window *window)
call_flow_win_free(Window *window)
{
CallFlowInfo *info = call_flow_info(window);
CallFlowWinInfo *info = call_flow_win_info(window);
g_return_if_fail(info != NULL);
// Free the panel information
@ -1739,11 +1740,11 @@ call_flow_free(Window *window)
}
Window *
call_flow_new()
call_flow_win_new()
{
Window *window = g_malloc0(sizeof(Window));
window->type = WINDOW_CALL_FLOW;
window->destroy = call_flow_free;
window->destroy = call_flow_win_free;
window->redraw = call_flow_redraw;
window->draw = call_flow_draw;
window->handle_key = call_flow_handle_key;
@ -1753,7 +1754,7 @@ call_flow_new()
window_init(window, getmaxy(stdscr), getmaxx(stdscr));
// Initialize Call List specific data
CallFlowInfo *info = g_malloc0(sizeof(CallFlowInfo));
CallFlowWinInfo *info = g_malloc0(sizeof(CallFlowWinInfo));
// Display timestamp next to each arrow
info->arrowtime = TRUE;

View File

@ -52,8 +52,8 @@
* +--------------------------------------------------------+
*
*/
#ifndef __SNGREP_CALL_FLOW_H
#define __SNGREP_CALL_FLOW_H
#ifndef __SNGREP_CALL_FLOW_WIN_H
#define __SNGREP_CALL_FLOW_WIN_H
#include <glib.h>
#include "ncurses/manager.h"
@ -61,7 +61,7 @@
#include "group.h"
//! Sorter declaration of struct _CallFlowInfo
typedef struct _CallFlowInfo CallFlowInfo;
typedef struct _CallFlowWinInfo CallFlowWinInfo;
//! Sorter declaration of struct _CallFlowColumn
typedef struct _CallFlowColumn CallFlowColumn;
//! Sorter declaration of struct _CallFlowArrow
@ -135,7 +135,7 @@ struct _CallFlowColumn {
* This data stores the actual status of the panel. It's stored in the
* PANEL user pointer.
*/
struct _CallFlowInfo {
struct _CallFlowWinInfo {
//! Window to display SIP payload
WINDOW *raw_win;
//! Window to diplay arrows
@ -173,7 +173,7 @@ struct _CallFlowInfo {
* @param ui UI structure pointer
*/
Window *
call_flow_new();
call_flow_win_new();
/**
* @brief Destroy panel
@ -183,7 +183,7 @@ call_flow_new();
* @param ui UI structure pointer
*/
void
call_flow_free(Window *window);
call_flow_win_free(Window *window);
/**
* @brief Set the group call of the panel
@ -194,6 +194,6 @@ call_flow_free(Window *window);
* @param group Call group pointer to be set in the internal info struct
*/
void
call_flow_set_group(Window *window, CallGroup *group);
call_flow_win_set_group(Window *window, CallGroup *group);
#endif /* __SNGREP_CALL_FLOW_H */
#endif /* __SNGREP_CALL_FLOW_WIN_H */

View File

@ -41,14 +41,14 @@
#include "capture/capture_hep.h"
#endif
#include "ncurses/manager.h"
#include "ncurses/call_list.h"
#include "ncurses/call_flow.h"
#include "ncurses/call_raw.h"
#include "ncurses/stats.h"
#include "ncurses/call_list_win.h"
#include "ncurses/call_flow_win.h"
#include "ncurses/call_raw_win.h"
#include "ncurses/stats_win.h"
#include "ncurses/ui_filter.h"
#include "ncurses/ui_save.h"
#include "storage.h"
#include "column_select.h"
#include "column_select_win.h"
/**
* @brief Get custom information of given panel
@ -59,10 +59,10 @@
* @param window UI structure pointer
* @return a pointer to info structure of given panel
*/
static CallListInfo *
static CallListWinInfo *
call_list_info(Window *window)
{
return (CallListInfo*) panel_userptr(window->panel);
return (CallListWinInfo*) panel_userptr(window->panel);
}
/**
@ -77,7 +77,7 @@ call_list_info(Window *window)
static void
call_list_move(Window *window, guint line)
{
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_if_fail(info != NULL);
// Already in this position?
@ -128,7 +128,7 @@ call_list_move(Window *window, guint line)
static void
call_list_move_up(Window *window, guint times)
{
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_if_fail(info != NULL);
gint newpos = info->cur_idx - times;
@ -146,7 +146,7 @@ call_list_move_up(Window *window, guint times)
static void
call_list_move_down(Window *window, guint times)
{
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_if_fail(info != NULL);
guint newpos = info->cur_idx + times;
@ -184,7 +184,7 @@ call_list_resize(Window *window)
int maxx, maxy;
// Get panel info
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_val_if_fail(info != NULL, -1);
// Get current screen dimensions
@ -201,7 +201,7 @@ call_list_resize(Window *window)
wresize(info->list_win, maxy - 6, maxx); //-4
// Force list redraw
call_list_clear(window);
call_list_win_clear(window);
return 0;
}
@ -222,7 +222,7 @@ call_list_draw_header(Window *window)
const char *device, *filterbpf;
// Get panel info
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_if_fail(info != NULL);
// Draw panel title
@ -388,7 +388,7 @@ call_list_draw_list(Window *window)
int color;
// Get panel info
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_if_fail(info != NULL);
// Get window of call list panel
@ -532,7 +532,7 @@ call_list_draw(Window *window)
static void
call_list_form_activate(Window *window, gboolean active)
{
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_if_fail(info != NULL);
// Store form state
@ -567,13 +567,13 @@ call_list_form_activate(Window *window, gboolean active)
* @return A pointer to text
*/
const char *
call_list_line_text(Window *window, Call *call, char *text)
call_list_win_line_text(Window *window, Call *call, char *text)
{
char call_attr[ATTR_MAXLEN];
char coltext[ATTR_MAXLEN];
// Get panel info
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_val_if_fail(info != NULL, text);
// Print requested columns
@ -617,7 +617,7 @@ call_list_line_text(Window *window, Call *call, char *text)
static void
call_list_select_sort_attribute(Window *window)
{
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_if_fail(info != NULL);
// Activete sorting menu
@ -662,7 +662,7 @@ call_list_handle_form_key(Window *window, int key)
int action = -1;
// Get panel information
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_val_if_fail(info != NULL, -1);
// Check actions for this key
@ -717,7 +717,7 @@ call_list_handle_form_key(Window *window, int key)
if (action == ACTION_PRINTABLE || action == ACTION_BACKSPACE ||
action == ACTION_DELETE || action == ACTION_CLEAR) {
// Updated displayed results
call_list_clear(window);
call_list_win_clear(window);
// Reset filters on each key stroke
filter_reset_calls();
}
@ -758,7 +758,7 @@ call_list_handle_menu_key(Window *window, int key)
enum AttributeId id;
// Get panel information
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_val_if_fail(info != NULL, -1);
menu = info->menu;
@ -843,7 +843,7 @@ call_list_handle_key(Window *window, int key)
Call *call;
StorageSortOpts sort;
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_val_if_fail(info != NULL, -1);
// Handle form key
@ -911,17 +911,17 @@ call_list_handle_key(Window *window, int key)
if (action == ACTION_SHOW_RAW) {
// Create a Call raw panel
call_raw_set_group(ncurses_create_window(WINDOW_CALL_RAW), group);
call_raw_win_set_group(ncurses_create_window(WINDOW_CALL_RAW), group);
} else {
// Display current call flow (normal or extended)
call_flow_set_group(ncurses_create_window(WINDOW_CALL_FLOW), group);
call_flow_win_set_group(ncurses_create_window(WINDOW_CALL_FLOW), group);
}
break;
case ACTION_SHOW_FILTERS:
ncurses_create_window(PANEL_FILTER);
break;
case ACTION_SHOW_COLUMNS:
column_select_set_columns(ncurses_create_window(WINDOW_COLUMN_SELECT), info->columns);
column_select_win_set_columns(ncurses_create_window(WINDOW_COLUMN_SELECT), info->columns);
break;
case ACTION_SHOW_STATS:
ncurses_create_window(WINDOW_STATS);
@ -941,13 +941,13 @@ call_list_handle_key(Window *window, int key)
// Remove all stored calls
storage_calls_clear();
// Clear List
call_list_clear(window);
call_list_win_clear(window);
break;
case ACTION_CLEAR_CALLS_SOFT:
// Remove stored calls, keeping the currently displayed calls
storage_calls_clear_soft();
// Clear List
call_list_clear(window);
call_list_win_clear(window);
break;
case ACTION_AUTOSCROLL:
info->autoscroll = (info->autoscroll) ? 0 : 1;
@ -1101,7 +1101,7 @@ static void
call_list_add_column(Window *window, enum AttributeId id, const char* attr,
const char *title, int width)
{
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_if_fail(info != NULL);
CallListColumn *column = g_malloc0(sizeof(CallListColumn));
@ -1113,9 +1113,9 @@ call_list_add_column(Window *window, enum AttributeId id, const char* attr,
}
void
call_list_clear(Window *window)
call_list_win_clear(Window *window)
{
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_if_fail(info != NULL);
// Initialize structures
@ -1137,7 +1137,7 @@ call_list_clear(Window *window)
static void
call_list_free(Window *window)
{
CallListInfo *info = call_list_info(window);
CallListWinInfo *info = call_list_info(window);
g_return_if_fail(info != NULL);
// Deallocate forms data
@ -1160,7 +1160,7 @@ call_list_free(Window *window)
}
Window *
call_list_new()
call_list_win_new()
{
Window *window = g_malloc0(sizeof(Window));
window->type = WINDOW_CALL_LIST;
@ -1175,7 +1175,7 @@ call_list_new()
window_init(window, getmaxy(stdscr), getmaxx(stdscr));
// Initialize Call List specific data
CallListInfo *info = g_malloc0(sizeof(CallListInfo));
CallListWinInfo *info = g_malloc0(sizeof(CallListWinInfo));
set_panel_userptr(window->panel, (void*) info);
// Add configured columns

View File

@ -29,8 +29,8 @@
* screen.
*
*/
#ifndef __UI_CALL_LIST_H
#define __UI_CALL_LIST_H
#ifndef __UI_CALL_LIST_WIN_H
#define __UI_CALL_LIST_WIN_H
#include <menu.h>
#include <glib.h>
@ -50,7 +50,7 @@ enum CallListFieldList {
//! Sorter declaration of column struct
typedef struct _CallListColumn CallListColumn;
//! Sorter declaration of info struct
typedef struct _CallListInfo CallListInfo;
typedef struct _CallListWinInfo CallListWinInfo;
/**
* @brief Call List column information
@ -76,7 +76,7 @@ struct _CallListColumn {
* This data stores the actual status of the panel. It's stored in the
* panel pointer.
*/
struct _CallListInfo {
struct _CallListWinInfo {
//! Displayed calls vector
GPtrArray *dcalls;
//! Selected call in the list
@ -117,7 +117,7 @@ struct _CallListInfo {
* @return the allocated window structure
*/
Window *
call_list_new();
call_list_win_new();
/**
* @brief Get List line from the given call
@ -131,7 +131,7 @@ call_list_new();
* @return A pointer to text
*/
const char*
call_list_line_text(Window *window, Call *call, char *text);
call_list_win_line_text(Window *window, Call *call, char *text);
/**
* @brief Remove all calls from the list and calls storage
@ -140,6 +140,6 @@ call_list_line_text(Window *window, Call *call, char *text);
* @param window UI structure pointer
*/
void
call_list_clear(Window *window);
call_list_win_clear(Window *window);
#endif

View File

@ -33,7 +33,7 @@
#include <string.h>
#include <stdlib.h>
#include "ncurses/manager.h"
#include "ncurses/call_raw.h"
#include "ncurses/call_raw_win.h"
#include "ncurses/ui_save.h"
#include "capture/capture_pcap.h"
#include "packet/dissectors/packet_sip.h"
@ -47,10 +47,10 @@
* @param panel Ncurses panel pointer
* @return a pointer to info structure of given panel
*/
static CallRawInfo *
static CallRawWinInfo *
call_raw_info(Window *window)
{
return (CallRawInfo*) panel_userptr(window->panel);
return (CallRawWinInfo*) panel_userptr(window->panel);
}
/**
@ -65,7 +65,7 @@ static gboolean
call_raw_redraw(Window *window)
{
// Get panel information
CallRawInfo *info = call_raw_info(window);
CallRawWinInfo *info = call_raw_info(window);
g_return_val_if_fail(info != NULL, FALSE);
// Check if any of the group has changed
@ -91,7 +91,7 @@ call_raw_print_msg(Window *window, Message *msg)
int color = 0;
// Get panel information
CallRawInfo *info = call_raw_info(window);
CallRawWinInfo *info = call_raw_info(window);
g_return_if_fail(info != NULL);
// Get the pad window
@ -175,7 +175,7 @@ call_raw_draw(Window *window)
Message *msg = NULL;
// Get panel information
CallRawInfo *info = call_raw_info(window);
CallRawWinInfo *info = call_raw_info(window);
g_return_val_if_fail(info != NULL, -1);
if (info->group) {
@ -184,7 +184,7 @@ call_raw_draw(Window *window)
call_raw_print_msg(window, msg);
}
} else {
call_raw_set_msg(window, info->msg);
call_raw_win_set_msg(window, info->msg);
}
// Copy the visible part of the pad into the panel window
@ -203,7 +203,7 @@ static void
call_raw_move_up(Window *window, guint times)
{
// Get panel information
CallRawInfo *info = call_raw_info(window);
CallRawWinInfo *info = call_raw_info(window);
g_return_if_fail(info != NULL);
if (info->scroll < times) {
@ -224,7 +224,7 @@ static void
call_raw_move_down(Window *window, guint times)
{
// Get panel information
CallRawInfo *info = call_raw_info(window);
CallRawWinInfo *info = call_raw_info(window);
g_return_if_fail(info != NULL);
info->scroll += times;
@ -250,7 +250,7 @@ call_raw_handle_key(Window *window, int key)
guint rnpag_steps = (guint) setting_get_intvalue(SETTING_CR_SCROLLSTEP);
int action = -1;
CallRawInfo *info = call_raw_info(window);
CallRawWinInfo *info = call_raw_info(window);
g_return_val_if_fail(info != NULL, KEY_NOT_HANDLED);
// Check actions for this key
@ -296,9 +296,9 @@ call_raw_handle_key(Window *window, int key)
info->last = NULL;
// Force refresh panel
if (info->group) {
call_raw_set_group(window, info->group);
call_raw_win_set_group(window, info->group);
} else {
call_raw_set_msg(window, info->msg);
call_raw_win_set_msg(window, info->msg);
}
break;
case ACTION_CLEAR_CALLS:
@ -320,9 +320,9 @@ call_raw_handle_key(Window *window, int key)
}
void
call_raw_set_group(Window *window, CallGroup *group)
call_raw_win_set_group(Window *window, CallGroup *group)
{
CallRawInfo *info = call_raw_info(window);
CallRawWinInfo *info = call_raw_info(window);
g_return_if_fail(info != NULL);
g_return_if_fail(group != NULL);
@ -336,9 +336,9 @@ call_raw_set_group(Window *window, CallGroup *group)
}
void
call_raw_set_msg(Window *window, Message *msg)
call_raw_win_set_msg(Window *window, Message *msg)
{
CallRawInfo *info = call_raw_info(window);
CallRawWinInfo *info = call_raw_info(window);
g_return_if_fail(info != NULL);
g_return_if_fail(msg != NULL);
@ -355,9 +355,9 @@ call_raw_set_msg(Window *window, Message *msg)
}
void
call_raw_free(Window *window)
call_raw_win_free(Window *window)
{
CallRawInfo *info = call_raw_info(window);
CallRawWinInfo *info = call_raw_info(window);
g_return_if_fail(info != NULL);
// Delete panel windows
@ -368,11 +368,11 @@ call_raw_free(Window *window)
}
Window *
call_raw_new()
call_raw_win_new()
{
Window *window = g_malloc0(sizeof(Window));
window->type = WINDOW_CALL_RAW;
window->destroy = call_raw_free;
window->destroy = call_raw_win_free;
window->redraw = call_raw_redraw;
window->draw = call_raw_draw;
window->handle_key = call_raw_handle_key;
@ -381,7 +381,7 @@ call_raw_new()
window_init(window, getmaxy(stdscr), getmaxx(stdscr));
// Initialize Call Raw specific data
CallRawInfo *info = g_malloc0(sizeof(CallRawInfo));
CallRawWinInfo *info = g_malloc0(sizeof(CallRawWinInfo));
set_panel_userptr(window->panel, (void*) info);
// Create a initial pad of 1000 lines

View File

@ -29,8 +29,8 @@
* output screen.
*
*/
#ifndef __SNGREP_CALL_RAW_H
#define __SNGREP_CALL_RAW_H
#ifndef __SNGREP_CALL_RAW_WIN_H
#define __SNGREP_CALL_RAW_WIN_H
#include "config.h"
#include "group.h"
@ -38,7 +38,7 @@
#include "ncurses/manager.h"
//! Sorter declaration of struct call_raw_info
typedef struct _CallRawInfo CallRawInfo;
typedef struct _CallRawWinInfo CallRawWinInfo;
/**
* @brief Call raw status information
@ -46,7 +46,7 @@ typedef struct _CallRawInfo CallRawInfo;
* This data stores the actual status of the panel. It's stored in the
* PANEL user pointer.
*/
struct _CallRawInfo {
struct _CallRawWinInfo {
//! Group of calls displayed on the panel (Call raw display)
CallGroup *group;
//! Message to display on the panel (Single message raw display)
@ -70,7 +70,7 @@ struct _CallRawInfo {
* store it in the panel's userpointer
*/
Window *
call_raw_new();
call_raw_win_new();
/**
* @brief Destroy panel
@ -80,7 +80,7 @@ call_raw_new();
* @param panel Ncurses panel pointer
*/
void
call_raw_free(Window *window);
call_raw_win_free(Window *window);
/**
* @brief Set the active call group of the panel
@ -92,7 +92,7 @@ call_raw_free(Window *window);
* @param group Call Group pointer to be set in the internal info struct
*/
void
call_raw_set_group(Window *window, CallGroup *group);
call_raw_win_set_group(Window *window, CallGroup *group);
/**
* @brief Set the active msg of the panel
@ -103,6 +103,6 @@ call_raw_set_group(Window *window, CallGroup *group);
* @param msg Message pointer to be set in the internal info struct
*/
void
call_raw_set_msg(Window *window, Message *msg);
call_raw_win_set_msg(Window *window, Message *msg);
#endif
#endif /* __SNGREP_CALL_RAW_WIN_H */

View File

@ -36,8 +36,8 @@
#include <glib/gstdio.h>
#include "glib-utils.h"
#include "ncurses/manager.h"
#include "ncurses/call_list.h"
#include "ncurses/column_select.h"
#include "ncurses/call_list_win.h"
#include "ncurses/column_select_win.h"
/**
* @brief Get custom information of given panel
@ -48,10 +48,10 @@
* @param ui UI structure pointer
* @return a pointer to info structure of given panel
*/
static ColumnSelectInfo *
static ColumnSelectWinInfo *
column_select_info(Window *ui)
{
return (ColumnSelectInfo*) panel_userptr(ui->panel);
return (ColumnSelectWinInfo*) panel_userptr(ui->panel);
}
/**
@ -67,7 +67,7 @@ static void
column_select_move_item(Window *ui, ITEM *item, int pos)
{
// Get panel information
ColumnSelectInfo *info = column_select_info(ui);
ColumnSelectWinInfo *info = column_select_info(ui);
// Check we have a valid position
if (pos == item_count(info->menu) || pos < 0)
@ -93,7 +93,7 @@ static void
column_select_toggle_item(Window *ui, ITEM *item)
{
// Get panel information
ColumnSelectInfo *info = column_select_info(ui);
ColumnSelectWinInfo *info = column_select_info(ui);
int pos = item_index(item);
@ -124,7 +124,7 @@ static void
column_select_update_menu(Window *ui)
{
// Get panel information
ColumnSelectInfo *info = column_select_info(ui);
ColumnSelectWinInfo *info = column_select_info(ui);
ITEM *current = current_item(info->menu);
int top_idx = top_row(info->menu);
@ -157,7 +157,7 @@ column_select_update_columns(Window *ui)
int column, attr_id;
// Get panel information
ColumnSelectInfo *info = column_select_info(ui);
ColumnSelectWinInfo *info = column_select_info(ui);
g_return_if_fail(info != NULL);
// Reset column count
@ -250,7 +250,7 @@ column_select_save_columns(Window *ui)
}
// Get panel information
ColumnSelectInfo *info = column_select_info(ui);
ColumnSelectWinInfo *info = column_select_info(ui);
// Add all selected columns
for (gint i = 0; i < item_count(info->menu); i++) {
@ -287,7 +287,7 @@ column_select_handle_key_menu(Window *ui, int key)
int action = -1;
// Get panel information
ColumnSelectInfo *info = column_select_info(ui);
ColumnSelectWinInfo *info = column_select_info(ui);
g_return_val_if_fail(info != NULL, KEY_DESTROY);
current = current_item(info->menu);
@ -368,7 +368,7 @@ column_select_handle_key_form(Window *ui, int key)
int action = -1;
// Get panel information
ColumnSelectInfo *info = column_select_info(ui);
ColumnSelectWinInfo *info = column_select_info(ui);
g_return_val_if_fail(info != NULL, KEY_DESTROY);
// Get current field id
@ -454,7 +454,7 @@ static int
column_select_handle_key(Window *window, int key)
{
// Get panel information
ColumnSelectInfo *info = column_select_info(window);
ColumnSelectWinInfo *info = column_select_info(window);
g_return_val_if_fail(info != NULL, KEY_DESTROY);
if (info->form_active) {
@ -465,10 +465,10 @@ column_select_handle_key(Window *window, int key)
}
void
column_select_set_columns(Window *window, GPtrArray *columns)
column_select_win_set_columns(Window *window, GPtrArray *columns)
{
// Get panel information
ColumnSelectInfo *info = column_select_info(window);
ColumnSelectWinInfo *info = column_select_info(window);
g_return_if_fail(info != NULL);
// Set selected column array
@ -503,7 +503,7 @@ void
column_select_free(Window *ui)
{
int i;
ColumnSelectInfo *info = column_select_info(ui);
ColumnSelectWinInfo *info = column_select_info(ui);
// Remove menu and items
unpost_menu(info->menu);
@ -524,7 +524,7 @@ column_select_free(Window *ui)
}
Window *
column_select_new()
column_select_win_new()
{
Window *window = g_malloc0(sizeof(Window));
window->type = WINDOW_COLUMN_SELECT;
@ -535,7 +535,7 @@ column_select_new()
window_init(window, 20, 60);
// Initialize Filter panel specific data
ColumnSelectInfo *info = g_malloc0(sizeof(ColumnSelectInfo));
ColumnSelectWinInfo *info = g_malloc0(sizeof(ColumnSelectWinInfo));
set_panel_userptr(window->panel, (void*) info);
// Initialize attributes

View File

@ -20,14 +20,14 @@
**
****************************************************************************/
/**
* @file ui_column_select.h
* @file column_select.h
* @author Ivan Alonso [aka Kaian] <kaian@irontec.com>
*
* @brief Functions to manage columns select panel
*/
#ifndef __UI_COLUMN_SELECT_H
#define __UI_COLUMN_SELECT_H
#ifndef __COLUMN_SELECT_WIN_H
#define __COLUMN_SELECT_WIN_H
#include "config.h"
#include <menu.h>
@ -49,14 +49,14 @@ enum ColumnSelectFields {
//! Sorter declaration of struct columns_select_info
typedef struct _ColumnSelectInfo ColumnSelectInfo;
typedef struct _ColumnSelectWinInfo ColumnSelectWinInfo;
/**
* @brief Column selector panel private information
*
* This structure contains the durable data of column selection panel.
*/
struct _ColumnSelectInfo {
struct _ColumnSelectWinInfo {
//! Section of panel where menu is being displayed
WINDOW *menu_win;
//! Columns menu
@ -86,13 +86,13 @@ struct _ColumnSelectInfo {
* @return Window UI structure pointer
*/
Window *
column_select_new();
column_select_win_new();
/**
* @brief Set Column array to be updated
* @param columns Array of currect active columns
*/
void
column_select_set_columns(Window *window, GPtrArray *columns);
column_select_win_set_columns(Window *window, GPtrArray *columns);
#endif /* __UI_COLUMN_SELECT_H */
#endif /* __COLUMN_SELECT_WIN_H */

View File

@ -36,13 +36,13 @@
#include "manager.h"
#include "packet/dissectors/packet_sip.h"
#include "capture/capture.h"
#include "ncurses/call_list.h"
#include "ncurses/call_flow.h"
#include "ncurses/call_raw.h"
#include "ncurses/call_list_win.h"
#include "ncurses/call_flow_win.h"
#include "ncurses/call_raw_win.h"
#include "ncurses/ui_filter.h"
#include "ncurses/ui_msg_diff.h"
#include "ncurses/column_select.h"
#include "ncurses/stats.h"
#include "ncurses/column_select_win.h"
#include "ncurses/stats_win.h"
#include "ncurses/ui_save.h"
#include "ncurses/ui_settings.h"
@ -204,19 +204,19 @@ ncurses_find_by_type(enum WindowTypes type)
switch (type) {
case WINDOW_CALL_LIST:
window = call_list_new();
window = call_list_win_new();
break;
case WINDOW_COLUMN_SELECT:
window = column_select_new();
window = column_select_win_new();
break;
case WINDOW_STATS:
window = stats_new();
window = stats_win_new();
break;
case WINDOW_CALL_FLOW:
window = call_flow_new();
window = call_flow_win_new();
break;
case WINDOW_CALL_RAW:
window = call_raw_new();
window = call_raw_win_new();
break;
default: break;
}

View File

@ -58,10 +58,10 @@
#include "glib-utils.h"
#include "storage.h"
#include "packet/dissectors/packet_sip.h"
#include "stats.h"
#include "stats_win.h"
Window *
stats_new()
stats_win_new()
{
Window *window = g_malloc0(sizeof(Window));
window->type = WINDOW_STATS;

View File

@ -25,8 +25,8 @@
*
* @brief Functions to manage ui window for capture stats display
*/
#ifndef __SNGREP_STATS_H
#define __SNGREP_STATS_H
#ifndef __SNGREP_STATS_WIN_H
#define __SNGREP_STATS_WIN_H
#include "ncurses/manager.h"
@ -40,6 +40,6 @@
*
*/
Window *
stats_new();
stats_win_new();
#endif /* __SNGREP_STATS_H */
#endif /* __SNGREP_STATS_WIN_H */

View File

@ -33,7 +33,7 @@
#include "packet/dissectors/packet_sip.h"
#include "ncurses/manager.h"
#include "ncurses/ui_filter.h"
#include "ncurses/call_list.h"
#include "ncurses/call_list_win.h"
#include "storage.h"
#include "filter.h"
#include "setting.h"
@ -394,7 +394,7 @@ filter_save_options(Window *ui)
// Force filter evaluation
filter_reset_calls();
// TODO FIXME Refresh call list FIXME
call_list_clear(ncurses_find_by_type(WINDOW_CALL_LIST));
call_list_win_clear(ncurses_find_by_type(WINDOW_CALL_LIST));
}