forked from Mirrors/sngrep
Added Multiaddress extended call flow
This can be handy if there are more than 3 addresses involved in the dialog. In the future, it could be implemented a way to show multiple unrelated dialogs in the same flow. * Fixed raw panel for extended call flow. * Added color per dialog (capital C keybind)
This commit is contained in:
parent
0a4ed2b5e6
commit
2428d71f53
|
@ -91,7 +91,10 @@ static sip_attr_hdr_t attrs[] = {
|
|||
.id = SIP_ATTR_METHOD,
|
||||
.name = "method",
|
||||
.desc = "Method" },
|
||||
|
||||
{
|
||||
.id = SIP_ATTR_REQUEST,
|
||||
.name = "request",
|
||||
.desc = "Request" },
|
||||
{
|
||||
.id = SIP_ATTR_STARTING,
|
||||
.name = "starting",
|
||||
|
@ -585,6 +588,9 @@ msg_parse_payload(sip_msg_t *msg, const char *payload)
|
|||
}
|
||||
if (sscanf(pch, "CSeq: %d %[^\t\n\r]", &irest, value)) {
|
||||
if (!msg_get_attribute(msg, SIP_ATTR_METHOD)) {
|
||||
// ACK Messages are not considered request, but responses
|
||||
if (strcasecmp(value, "ACK"))
|
||||
msg_set_attribute(msg, SIP_ATTR_REQUEST, "1");
|
||||
msg_set_attribute(msg, SIP_ATTR_METHOD, value);
|
||||
}
|
||||
continue;
|
||||
|
|
|
@ -68,6 +68,8 @@ enum sip_attr_id
|
|||
SIP_ATTR_TIME,
|
||||
//! SIP Message Method or Response code
|
||||
SIP_ATTR_METHOD,
|
||||
//! SIP Message
|
||||
SIP_ATTR_REQUEST,
|
||||
//! SIP Call first message method
|
||||
SIP_ATTR_STARTING,
|
||||
//! SIP Call message counter
|
||||
|
|
|
@ -170,15 +170,20 @@ call_flow_draw(PANEL *panel)
|
|||
// Print timestamp
|
||||
mvwprintw(win, cline, 2, "%s", msg_get_attribute(msg, SIP_ATTR_TIME));
|
||||
|
||||
if (msg == info->cur_msg) wattron(win, A_REVERSE);
|
||||
if (msg == info->cur_msg) wattron(win, A_BOLD);
|
||||
|
||||
// Determine arrow color
|
||||
if (msg_get_attribute(msg, SIP_ATTR_REQUEST)) {
|
||||
wattron(win, COLOR_PAIR(OUTGOING_COLOR));
|
||||
} else {
|
||||
wattron(win, COLOR_PAIR(INCOMING_COLOR));
|
||||
}
|
||||
|
||||
// Determine the message direction
|
||||
if (!strcmp(msg_get_attribute(msg, SIP_ATTR_SRC), from)) {
|
||||
wattron(win, COLOR_PAIR(OUTGOING_COLOR));
|
||||
mvwhline(win, cline + 1, 22, ACS_HLINE, 26);
|
||||
mvwaddch(win, cline + 1, 47, ACS_RARROW);
|
||||
} else {
|
||||
wattron(win, COLOR_PAIR(INCOMING_COLOR));
|
||||
mvwhline(win, cline + 1, 22, ACS_HLINE, 26);
|
||||
mvwaddch(win, cline + 1, 22, ACS_LARROW);
|
||||
}
|
||||
|
@ -192,7 +197,7 @@ call_flow_draw(PANEL *panel)
|
|||
// Turn off colors
|
||||
wattroff(win, COLOR_PAIR(OUTGOING_COLOR));
|
||||
wattroff(win, COLOR_PAIR(INCOMING_COLOR));
|
||||
wattroff(win, A_REVERSE);
|
||||
wattroff(win, A_BOLD);
|
||||
|
||||
// One message fills 2 lines
|
||||
cline += 2;
|
||||
|
|
|
@ -61,28 +61,8 @@ call_flow_ex_create()
|
|||
// Window borders
|
||||
wattron(win, COLOR_PAIR(DETAIL_BORDER_COLOR));
|
||||
title_foot_box(win);
|
||||
mvwaddch(win, 2, 91, ACS_TTEE);
|
||||
mvwvline(win, 3, 91, ACS_VLINE, height - 6);
|
||||
mvwaddch(win, 4, 0, ACS_LTEE);
|
||||
mvwhline(win, 4, 1, ACS_HLINE, 91);
|
||||
mvwaddch(win, 4, 91, ACS_RTEE);
|
||||
mvwaddch(win, height - 3, 91, ACS_BTEE);
|
||||
wattroff(win, COLOR_PAIR(DETAIL_BORDER_COLOR));
|
||||
|
||||
// Callflow box title
|
||||
mvwprintw(win, 3, 40, "Call Flow Extended");
|
||||
mvwhline(win, 6, 11, ACS_HLINE, 20);
|
||||
mvwhline(win, 6, 40, ACS_HLINE, 20);
|
||||
mvwhline(win, 6, 70, ACS_HLINE, 20);
|
||||
mvwaddch(win, 6, 20, ACS_TTEE);
|
||||
mvwaddch(win, 6, 50, ACS_TTEE);
|
||||
mvwaddch(win, 6, 80, ACS_TTEE);
|
||||
|
||||
// Make the vertical lines for messages (2 lines per message + extra space)
|
||||
mvwvline(win, 7, 20, ACS_VLINE, info->linescnt);
|
||||
mvwvline(win, 7, 50, ACS_VLINE, info->linescnt);
|
||||
mvwvline(win, 7, 80, ACS_VLINE, info->linescnt);
|
||||
|
||||
mvwprintw(win, height - 2, 2, "Q/Esc: Quit");
|
||||
mvwprintw(win, height - 2, 16, "F1: Help");
|
||||
mvwprintw(win, height - 2, 27, "x: Call-Flow");
|
||||
|
@ -152,42 +132,41 @@ call_flow_ex_draw(PANEL *panel)
|
|||
const char *msg_time, *msg_callid, *msg_method, *msg_from, *msg_to, *msg_src, *msg_dst;
|
||||
|
||||
const struct sip_msg *first = call_get_next_msg_ex(call, NULL);
|
||||
if (!strcmp(call_get_attribute(call, SIP_ATTR_CALLID), call_get_attribute(first->call,
|
||||
SIP_ATTR_CALLID))) {
|
||||
from = call_get_attribute(call, SIP_ATTR_SRC);
|
||||
via = call_get_attribute(call, SIP_ATTR_DST);
|
||||
to = call_get_attribute(call2, SIP_ATTR_DST);
|
||||
callid1 = call_get_attribute(call, SIP_ATTR_CALLID);
|
||||
callid2 = call_get_attribute(call2, SIP_ATTR_CALLID);
|
||||
} else {
|
||||
from = call_get_attribute(call2, SIP_ATTR_SRC);
|
||||
via = call_get_attribute(call2, SIP_ATTR_DST);
|
||||
to = call_get_attribute(call, SIP_ATTR_DST);
|
||||
callid1 = call_get_attribute(call2, SIP_ATTR_CALLID);
|
||||
callid2 = call_get_attribute(call, SIP_ATTR_CALLID);
|
||||
|
||||
// Get window of main panel
|
||||
call_flow_ex_column_t *columns;
|
||||
columns = info->columns;
|
||||
while (columns) {
|
||||
// Make the vertical lines for messages (2 lines per message + extra space)
|
||||
mvwvline(win, 7, 20 + 30 * columns->colpos, ACS_VLINE, info->linescnt);
|
||||
mvwhline(win, 6, 10 + 30 * columns->colpos, ACS_HLINE, 20);
|
||||
mvwaddch(win, 6, 20 + 30 * columns->colpos, ACS_TTEE);
|
||||
mvwprintw(win, 5, 7 + 30 * columns->colpos, "%22s", columns->addr);
|
||||
columns = columns->next;
|
||||
}
|
||||
|
||||
// Get window size
|
||||
getmaxyx(win, height, width);
|
||||
|
||||
// Window title
|
||||
mvwprintw(win, 1, (width - 45) / 2, "Call Details for %s -> %s", callid1, callid2);
|
||||
|
||||
// Hosts and lines in callflow
|
||||
mvwprintw(win, 5, 7, "%22s", from);
|
||||
mvwprintw(win, 5, 37, "%22s", via);
|
||||
mvwprintw(win, 5, 67, "%22s", to);
|
||||
mvwprintw(win, 1, (width - 45) / 2, "Call Details for %s -> %s", call_get_attribute(call,
|
||||
SIP_ATTR_CALLID), call_get_attribute(call2, SIP_ATTR_CALLID));
|
||||
|
||||
for (cline = startpos, msg = info->first_msg; msg; msg = call_get_next_msg_ex(info->call, msg)) {
|
||||
// Check if there are still 2 spaces for this message in the list
|
||||
if (cline >= info->linescnt + startpos - 1) {
|
||||
// Draw 2 arrow to show there are more messages
|
||||
mvwaddch(win, info->linescnt + startpos - 1, 20, ACS_DARROW);
|
||||
mvwaddch(win, info->linescnt + startpos - 1, 50, ACS_DARROW);
|
||||
mvwaddch(win, info->linescnt + startpos - 1, 80, ACS_DARROW);
|
||||
break;
|
||||
}
|
||||
|
||||
columns = info->columns;
|
||||
while (columns) {
|
||||
mvwprintw(win, cline, 21 + 30 * columns->colpos, "%29s", "");
|
||||
mvwprintw(win, cline+1, 21 + 30 * columns->colpos, "%29s", "");
|
||||
columns = columns->next;
|
||||
}
|
||||
|
||||
// Get message attributes
|
||||
msg_time = msg_get_attribute(msg, SIP_ATTR_TIME);
|
||||
msg_callid = msg_get_attribute(msg, SIP_ATTR_CALLID);
|
||||
|
@ -200,68 +179,81 @@ call_flow_ex_draw(PANEL *panel)
|
|||
// Print timestamp
|
||||
mvwprintw(win, cline, 2, "%s", msg_time);
|
||||
|
||||
if (msg == info->cur_msg) wattron(win, A_REVERSE);
|
||||
if (msg == info->cur_msg) wattron(win, A_BOLD);
|
||||
|
||||
// Draw message type or status and line
|
||||
int msglen = strlen(msg_method);
|
||||
if (msglen > 24) msglen = 24;
|
||||
|
||||
// Determine the message direction
|
||||
if (!strcmp(msg_callid, callid1) && !strcmp(msg_src, from)) {
|
||||
wattron(win, COLOR_PAIR(OUTGOING_COLOR));
|
||||
mvwprintw(win, cline, 22, "%26s", "");
|
||||
mvwprintw(win, cline, 22 + (24 - msglen) / 2, "%.24s", msg_method);
|
||||
mvwhline(win, cline + 1, 22, ACS_HLINE, 26);
|
||||
mvwaddch(win, cline + 1, 47, ACS_RARROW);
|
||||
wattroff(win, A_REVERSE);
|
||||
mvwprintw(win, cline, 52, "%26s", "");
|
||||
mvwprintw(win, cline + 1, 52, "%26s", "");
|
||||
} else if (!strcmp(msg_callid, callid1) && !strcmp(msg_dst, from)) {
|
||||
wattron(win, COLOR_PAIR(INCOMING_COLOR));
|
||||
mvwprintw(win, cline, 22, "%26s", "");
|
||||
mvwprintw(win, cline, 22 + (24 - msglen) / 2, "%.24s", msg_method);
|
||||
mvwhline(win, cline + 1, 22, ACS_HLINE, 26);
|
||||
mvwaddch(win, cline + 1, 22, ACS_LARROW);
|
||||
wattroff(win, A_REVERSE);
|
||||
mvwprintw(win, cline, 52, "%26s", "");
|
||||
mvwprintw(win, cline + 1, 52, "%26s", "");
|
||||
} else if (!strcmp(msg_callid, callid2) && !strcmp(msg_src, via)) {
|
||||
wattron(win, COLOR_PAIR(OUTGOING_COLOR));
|
||||
mvwprintw(win, cline, 52, "%26s", "");
|
||||
mvwprintw(win, cline, 54 + (24 - msglen) / 2, "%.24s", msg_method);
|
||||
mvwhline(win, cline + 1, 52, ACS_HLINE, 26);
|
||||
mvwaddch(win, cline + 1, 77, ACS_RARROW);
|
||||
wattroff(win, A_REVERSE);
|
||||
mvwprintw(win, cline, 22, "%26s", "");
|
||||
mvwprintw(win, cline + 1, 22, "%26s", "");
|
||||
call_flow_ex_column_t *column1 = call_flow_ex_column(panel, msg_callid, msg_src);
|
||||
call_flow_ex_column_t *column2 = call_flow_ex_column(panel, msg_callid, msg_dst);
|
||||
|
||||
call_flow_ex_column_t *tmp;
|
||||
if (column1->colpos > column2->colpos) {
|
||||
tmp = column1;
|
||||
column1 = column2;
|
||||
column2 = tmp;
|
||||
}
|
||||
|
||||
int startpos = 20 + 30 * column1->colpos;
|
||||
int endpos = 20 + 30 * column2->colpos;
|
||||
int distance = abs(endpos - startpos) - 3;
|
||||
|
||||
if (is_option_enabled("callid_color")) {
|
||||
if (!strcasecmp(msg_callid, call_get_attribute(call, SIP_ATTR_CALLID))) {
|
||||
wattron(win, COLOR_PAIR(CALLID1_COLOR));
|
||||
} else {
|
||||
wattron(win, COLOR_PAIR(CALLID2_COLOR));
|
||||
}
|
||||
} else {
|
||||
wattron(win, COLOR_PAIR(INCOMING_COLOR));
|
||||
mvwprintw(win, cline, 52, "%26s", "");
|
||||
mvwprintw(win, cline, 54 + (24 - msglen) / 2, "%.24s", msg_method);
|
||||
mvwhline(win, cline + 1, 52, ACS_HLINE, 26);
|
||||
mvwaddch(win, cline + 1, 52, ACS_LARROW);
|
||||
wattroff(win, A_REVERSE);
|
||||
mvwprintw(win, cline, 22, "%26s", "");
|
||||
mvwprintw(win, cline + 1, 22, "%26s", "");
|
||||
// Determine arrow color
|
||||
if (msg_get_attribute(msg, SIP_ATTR_REQUEST)) {
|
||||
wattron(win, COLOR_PAIR(OUTGOING_COLOR));
|
||||
} else {
|
||||
wattron(win, COLOR_PAIR(INCOMING_COLOR));
|
||||
}
|
||||
}
|
||||
|
||||
mvwprintw(win, cline, startpos + 2, "%.*s", distance, "");
|
||||
mvwprintw(win, cline, startpos + distance / 2 - msglen / 2 + 2, "%.26s", msg_method);
|
||||
mvwhline(win, cline + 1, startpos + 2, ACS_HLINE, distance);
|
||||
if (!strcasecmp(msg_src, column1->addr)) {
|
||||
mvwaddch(win, cline + 1, endpos - 2, ACS_RARROW);
|
||||
} else {
|
||||
mvwaddch(win, cline + 1, startpos + 2, ACS_LARROW);
|
||||
}
|
||||
|
||||
// Turn off colors
|
||||
wattroff(win, COLOR_PAIR(OUTGOING_COLOR));
|
||||
wattroff(win, COLOR_PAIR(INCOMING_COLOR));
|
||||
wattroff(win, A_REVERSE);
|
||||
wattroff(win, COLOR_PAIR(CALLID1_COLOR));
|
||||
wattroff(win, COLOR_PAIR(CALLID2_COLOR));
|
||||
wattroff(win, A_BOLD);
|
||||
|
||||
// One message fills 2 lines
|
||||
cline += 2;
|
||||
}
|
||||
|
||||
// Clean the message area
|
||||
for (cline = 3, i = 0; i < info->linescnt + 4; i++)
|
||||
mvwprintw(win, cline++, 92, "%*s", width - 93, "");
|
||||
// If there are only three columns, then draw the raw message on this panel
|
||||
if (info->columns->colpos == 2) {
|
||||
wattron(win, COLOR_PAIR(DETAIL_BORDER_COLOR));
|
||||
// Draw raw box lines
|
||||
mvwaddch(win, 2, 91, ACS_TTEE);
|
||||
mvwvline(win, 3, 91, ACS_VLINE, height - 6);
|
||||
mvwaddch(win, 4, 0, ACS_LTEE);
|
||||
mvwhline(win, 4, 1, ACS_HLINE, 91);
|
||||
mvwaddch(win, 4, 91, ACS_RTEE);
|
||||
mvwaddch(win, height - 3, 91, ACS_BTEE);
|
||||
wattroff(win, COLOR_PAIR(DETAIL_BORDER_COLOR));
|
||||
|
||||
// Print the message payload in the right side of the screen
|
||||
for (cline = 3, i = 0; i < info->cur_msg->plines && i < info->linescnt + 4; i++)
|
||||
mvwprintw(win, cline++, 92, "%.*s", width - 93, info->cur_msg->payload[i]);
|
||||
// Clean the message area
|
||||
for (cline = 3, i = 0; i < info->linescnt + 4; i++)
|
||||
mvwprintw(win, cline++, 92, "%*s", width - 93, "");
|
||||
|
||||
// Print the message payload in the right side of the screen
|
||||
for (cline = 3, i = 0; i < info->cur_msg->plines && i < info->linescnt + 4; i++)
|
||||
mvwprintw(win, cline++, 92, "%.*s", width - 93, info->cur_msg->payload[i]);
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
@ -307,7 +299,7 @@ call_flow_ex_handle_key(PANEL *panel, int key)
|
|||
}
|
||||
break;
|
||||
case KEY_NPAGE:
|
||||
// Next page => N key down strokes
|
||||
// Next page => N key down strokes
|
||||
for (i = 0; i < rnpag_steps; i++)
|
||||
call_flow_ex_handle_key(panel, KEY_DOWN);
|
||||
break;
|
||||
|
@ -318,7 +310,7 @@ call_flow_ex_handle_key(PANEL *panel, int key)
|
|||
break;
|
||||
case 'x':
|
||||
if (!info->call) return -1;
|
||||
// KEY_ENTER , Display current call flow
|
||||
// KEY_X , Display current call flow
|
||||
next_panel = ui_create(ui_find_by_type(DETAILS_PANEL));
|
||||
call_flow_set_call(info->call);
|
||||
ui_set_replace(ui_find_by_panel(panel), next_panel);
|
||||
|
@ -326,8 +318,16 @@ call_flow_ex_handle_key(PANEL *panel, int key)
|
|||
case 'r':
|
||||
// KEY_R, display current call in raw mode
|
||||
next_panel = ui_create(ui_find_by_type(RAW_PANEL));
|
||||
call_raw_set_call(info->call);
|
||||
call_raw_set_call_ex(info->call);
|
||||
wait_for_input(next_panel);
|
||||
break;
|
||||
case 10:
|
||||
// KEY_ENTER, display current message in raw mode
|
||||
next_panel = ui_create(ui_find_by_type(RAW_PANEL));
|
||||
call_raw_set_call(info->call);
|
||||
call_raw_set_msg(info->cur_msg);
|
||||
wait_for_input(next_panel);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ call_flow_ex_help(PANEL *panel)
|
|||
wattroff(help_win, COLOR_PAIR(HELP_COLOR));
|
||||
|
||||
// A list of available keys in this window
|
||||
mvwprintw(help_win, 8, 2, "Available keys:");
|
||||
mvwprintw(help_win, 8, 2, "Available keys:");
|
||||
mvwprintw(help_win, 10, 2, "F1 Show this screen.");
|
||||
mvwprintw(help_win, 11, 2, "q/Esc Go back to Call list window.");
|
||||
mvwprintw(help_win, 12, 2, "c Turn on/off window colours.");
|
||||
|
@ -394,6 +394,9 @@ call_flow_ex_set_call(sip_call_t *call)
|
|||
{
|
||||
PANEL *panel;
|
||||
call_flow_ex_info_t *info;
|
||||
sip_msg_t *msg;
|
||||
call_flow_ex_column_t *column;
|
||||
int colpos = 0;
|
||||
|
||||
if (!call) return -1;
|
||||
|
||||
|
@ -405,5 +408,39 @@ call_flow_ex_set_call(sip_call_t *call)
|
|||
info->call2 = call_get_xcall(call);
|
||||
info->cur_msg = info->first_msg = call_get_next_msg_ex(call, NULL);
|
||||
info->cur_line = 1;
|
||||
info->columns = NULL;
|
||||
|
||||
for (msg = info->first_msg; msg; msg = call_get_next_msg_ex(info->call, msg)) {
|
||||
const char *callid = msg_get_attribute(msg, SIP_ATTR_CALLID);
|
||||
const char *src = msg_get_attribute(msg, SIP_ATTR_SRC);
|
||||
if (!call_flow_ex_column(panel, callid, src)) {
|
||||
call_flow_ex_column_t *column = malloc(sizeof(call_flow_ex_column_t));
|
||||
column->callid = callid;
|
||||
column->addr = src;
|
||||
column->colpos = colpos++;
|
||||
column->next = info->columns;
|
||||
info->columns = column;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
call_flow_ex_column_t *
|
||||
call_flow_ex_column(PANEL *panel, const char *callid, const char *addr)
|
||||
{
|
||||
call_flow_ex_info_t *info;
|
||||
call_flow_ex_column_t *columns;
|
||||
|
||||
if (!(panel = ui_get_panel(ui_find_by_type(DETAILS_EX_PANEL)))) return NULL;
|
||||
|
||||
if (!(info = (call_flow_ex_info_t*) panel_userptr(panel))) return NULL;
|
||||
|
||||
columns = info->columns;
|
||||
while (columns) {
|
||||
if (!strcasecmp(addr, columns->addr) && (!strcasecmp(callid, columns->callid)
|
||||
|| columns->colpos == 1)) return columns;
|
||||
columns = columns->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,17 @@
|
|||
|
||||
//! Sorter declaration of struct call_flow_ex_info
|
||||
typedef struct call_flow_ex_info call_flow_ex_info_t;
|
||||
//! Sorter declaration of struct call_flow_ex_column
|
||||
typedef struct call_flow_ex_column call_flow_ex_column_t;
|
||||
|
||||
|
||||
struct call_flow_ex_column
|
||||
{
|
||||
const char *addr;
|
||||
const char *callid;
|
||||
int colpos;
|
||||
call_flow_ex_column_t *next;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Call flow Extended status information
|
||||
|
@ -50,6 +61,7 @@ struct call_flow_ex_info
|
|||
sip_msg_t *cur_msg;
|
||||
int linescnt;
|
||||
int cur_line;
|
||||
call_flow_ex_column_t *columns;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -137,4 +149,7 @@ call_flow_ex_help(PANEL *panel);
|
|||
extern int
|
||||
call_flow_ex_set_call(sip_call_t *call);
|
||||
|
||||
extern call_flow_ex_column_t *
|
||||
call_flow_ex_column(PANEL *panel, const char *callid, const char *addr);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -273,7 +273,7 @@ call_list_handle_key(PANEL *panel, int key)
|
|||
break;
|
||||
case 'x':
|
||||
if (!info->cur_call) return -1;
|
||||
// KEY_ENTER , Display current call flow
|
||||
// KEY_X , Display current call flow (extended)
|
||||
next_panel = ui_create(ui_find_by_type(DETAILS_EX_PANEL));
|
||||
call_flow_ex_set_call(info->cur_call);
|
||||
wait_for_input(next_panel);
|
||||
|
|
|
@ -55,6 +55,7 @@ call_raw_create()
|
|||
|
||||
// Calculate available printable area
|
||||
info->linescnt = height;
|
||||
info->totlines = 0;
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
@ -69,41 +70,71 @@ int
|
|||
call_raw_draw(PANEL *panel)
|
||||
{
|
||||
struct sip_msg *msg = NULL;
|
||||
int pline = 0, raw_line;
|
||||
const char *all_lines[1024];
|
||||
int all_linescnt = 0;
|
||||
wclear(panel_window(panel));
|
||||
|
||||
// Get panel information
|
||||
call_raw_info_t *info = (call_raw_info_t*) panel_userptr(panel);
|
||||
info->totlines = info->scrline = 0;
|
||||
|
||||
if (info->msg) {
|
||||
call_raw_print_msg(panel, info->msg);
|
||||
} else {
|
||||
if (info->call2) {
|
||||
while ((msg = call_get_next_msg_ex(info->call, msg)))
|
||||
call_raw_print_msg(panel, msg);
|
||||
} else {
|
||||
while ((msg = call_get_next_msg(info->call, msg)))
|
||||
call_raw_print_msg(panel, msg);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
call_raw_print_msg(PANEL *panel, sip_msg_t *msg)
|
||||
{
|
||||
// Get panel information
|
||||
call_raw_info_t *info = (call_raw_info_t*) panel_userptr(panel);
|
||||
|
||||
// Get window of main panel
|
||||
WINDOW *win = panel_window(panel);
|
||||
wclear(win);
|
||||
|
||||
/*
|
||||
FIXME This part could be coded decently.
|
||||
A better aproach is creating a pad window and copy the visible area
|
||||
into the panel window, taking into account the scroll position.
|
||||
This is dirty but easier to manage by now
|
||||
*/
|
||||
memset(all_lines, 0, 1024);
|
||||
while ((msg = call_get_next_msg(info->call, msg))) {
|
||||
for (raw_line = 0; raw_line < msg->plines; raw_line++) {
|
||||
all_lines[all_linescnt++] = msg->payload[raw_line];
|
||||
// Get current line
|
||||
int raw_line;
|
||||
|
||||
// Determine arrow color
|
||||
if (is_option_enabled("callid_color")) {
|
||||
if (!strcasecmp(msg_get_attribute(msg, SIP_ATTR_CALLID), call_get_attribute(info->call,
|
||||
SIP_ATTR_CALLID))) {
|
||||
wattron(win, COLOR_PAIR(CALLID1_COLOR));
|
||||
} else {
|
||||
wattron(win, COLOR_PAIR(CALLID2_COLOR));
|
||||
}
|
||||
} else {
|
||||
// Determine arrow color
|
||||
if (msg_get_attribute(msg, SIP_ATTR_REQUEST)) {
|
||||
wattron(win, COLOR_PAIR(OUTGOING_COLOR));
|
||||
} else {
|
||||
wattron(win, COLOR_PAIR(INCOMING_COLOR));
|
||||
}
|
||||
all_lines[all_linescnt++] = NULL;
|
||||
all_lines[all_linescnt++] = NULL;
|
||||
}
|
||||
info->all_lines = all_linescnt;
|
||||
|
||||
for (raw_line = info->scrollpos; raw_line <= all_linescnt; raw_line++) {
|
||||
for (raw_line = 0; raw_line < msg->plines; raw_line++) {
|
||||
info->totlines++;
|
||||
// Check if we must start drawing
|
||||
if (info->totlines < info->scrollpos) continue;
|
||||
// Until we have reached the end of the screen
|
||||
if (pline >= info->linescnt) break;
|
||||
if (info->scrline >= info->linescnt) break;
|
||||
|
||||
// If printable line, otherwise let this line empty
|
||||
if (all_lines[raw_line]) mvwprintw(win, pline, 0, "%s", all_lines[raw_line]);
|
||||
// but increase line counter
|
||||
pline++;
|
||||
mvwprintw(win, info->scrline++, 0, "%s", msg->payload[raw_line]);
|
||||
if (raw_line == msg->plines - 1) {
|
||||
info->scrline++;
|
||||
info->totlines++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -119,7 +150,7 @@ call_raw_handle_key(PANEL *panel, int key)
|
|||
|
||||
switch (key) {
|
||||
case KEY_DOWN:
|
||||
if (info->scrollpos + info->linescnt < info->all_lines) info->scrollpos++;
|
||||
if (info->scrollpos + info->linescnt - 10 < info->totlines) info->scrollpos++;
|
||||
break;
|
||||
case KEY_UP:
|
||||
if (info->scrollpos > 0) info->scrollpos--;
|
||||
|
@ -159,3 +190,45 @@ call_raw_set_call(sip_call_t *call)
|
|||
info->scrollpos = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
call_raw_set_call_ex(sip_call_t *call)
|
||||
{
|
||||
ui_t *raw_panel;
|
||||
PANEL *panel;
|
||||
call_raw_info_t *info;
|
||||
|
||||
if (!call) return -1;
|
||||
|
||||
if (!(raw_panel = ui_find_by_type(RAW_PANEL))) return -1;
|
||||
|
||||
if (!(panel = raw_panel->panel)) return -1;
|
||||
|
||||
if (!(info = (call_raw_info_t*) panel_userptr(panel))) return -1;
|
||||
|
||||
info->call = call;
|
||||
info->call2 = call_get_xcall(call);
|
||||
info->scrollpos = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
call_raw_set_msg(sip_msg_t *msg)
|
||||
{
|
||||
ui_t *raw_panel;
|
||||
PANEL *panel;
|
||||
call_raw_info_t *info;
|
||||
|
||||
if (!msg) return -1;
|
||||
|
||||
if (!(raw_panel = ui_find_by_type(RAW_PANEL))) return -1;
|
||||
|
||||
if (!(panel = raw_panel->panel)) return -1;
|
||||
|
||||
if (!(info = (call_raw_info_t*) panel_userptr(panel))) return -1;
|
||||
|
||||
info->msg = msg;
|
||||
info->scrollpos = 0;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
|
@ -45,9 +45,12 @@ typedef struct call_raw_info call_raw_info_t;
|
|||
struct call_raw_info
|
||||
{
|
||||
sip_call_t *call;
|
||||
sip_call_t *call2;
|
||||
sip_msg_t *msg;
|
||||
int totlines;
|
||||
int scrline;
|
||||
int scrollpos;
|
||||
int linescnt;
|
||||
int all_lines;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -113,4 +116,18 @@ call_raw_handle_key(PANEL *panel, int key);
|
|||
extern int
|
||||
call_raw_set_call(sip_call_t *call);
|
||||
|
||||
extern int
|
||||
call_raw_set_call_ex(sip_call_t *call);
|
||||
|
||||
/**
|
||||
* @brief Set the active msg of the panel
|
||||
*
|
||||
* This function will access the panel information and will set the
|
||||
* msg pointer to the processed message.
|
||||
*
|
||||
* @param msg Message pointer to be set in the internal info struct
|
||||
*/
|
||||
extern int
|
||||
call_raw_set_msg(sip_msg_t *msg);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -262,6 +262,9 @@ wait_for_input(ui_t *ui)
|
|||
set_option_value("color", is_option_enabled("color") ? "off" : "on");
|
||||
toggle_color(is_option_enabled("color"));
|
||||
break;
|
||||
case 'C':
|
||||
set_option_value("callid_color", is_option_enabled("callid_color") ? "off" : "on");
|
||||
break;
|
||||
case 'h':
|
||||
case 265: /* KEY_F1 */
|
||||
ui_help(ui);
|
||||
|
@ -287,12 +290,16 @@ toggle_color(int on)
|
|||
init_pair(OUTGOING_COLOR, COLOR_RED, COLOR_BLACK);
|
||||
init_pair(INCOMING_COLOR, COLOR_GREEN, COLOR_BLACK);
|
||||
init_pair(DETAIL_BORDER_COLOR, COLOR_BLUE, COLOR_BLACK);
|
||||
init_pair(CALLID1_COLOR, COLOR_CYAN, COLOR_BLACK);
|
||||
init_pair(CALLID2_COLOR, COLOR_YELLOW, COLOR_BLACK);
|
||||
} else {
|
||||
init_pair(HIGHLIGHT_COLOR, COLOR_BLACK, COLOR_WHITE);
|
||||
init_pair(HELP_COLOR, COLOR_WHITE, COLOR_BLACK);
|
||||
init_pair(OUTGOING_COLOR, COLOR_WHITE, COLOR_BLACK);
|
||||
init_pair(INCOMING_COLOR, COLOR_WHITE, COLOR_BLACK);
|
||||
init_pair(DETAIL_BORDER_COLOR, COLOR_WHITE, COLOR_BLACK);
|
||||
init_pair(CALLID1_COLOR, COLOR_WHITE, COLOR_BLACK);
|
||||
init_pair(CALLID2_COLOR, COLOR_WHITE, COLOR_BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,8 @@ enum sngrep_colors
|
|||
INCOMING_COLOR,
|
||||
//! Call-Flow border color
|
||||
DETAIL_BORDER_COLOR,
|
||||
CALLID1_COLOR,
|
||||
CALLID2_COLOR,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue