int save_raw_to_file(PANEL *panel) { char field_value[48]; FILE *f; sip_msg_t *msg = NULL; // Get panel information save_raw_info_t *info = (save_raw_info_t*) panel_userptr(panel); // Get current field value. // We trim spaces with sscanf because and empty field is stored as // space characters memset(field_value, 0, sizeof(field_value)); sscanf(field_buffer(info->fields[FLD_SAVE_RAW_FILE], 0), "%[^ ]", field_value); if (!(f = fopen(field_value, "w"))) { save_raw_error_message(panel, "Unable to open save file for writing"); return 0; } // Print the call group messages into the pad while ((msg = call_group_get_next_msg(info->group, msg))) { fprintf(f, "%s %s %s -> %s\n%s\n\n", msg_get_attribute(msg, SIP_ATTR_DATE), msg_get_attribute(msg, SIP_ATTR_TIME), msg_get_attribute(msg, SIP_ATTR_SRC), msg_get_attribute(msg, SIP_ATTR_DST), msg->payload); } fclose(f); return 27; }
sip_msg_t * call_group_get_prev_msg(sip_call_group_t *group, sip_msg_t *msg) { sip_msg_t *next = NULL; sip_msg_t *prev = NULL; // FIXME Horrible performance for huge dialogs while ((next = call_group_get_next_msg(group, next))) { if (next == msg) break; prev = next; } return prev; }
int call_group_msg_number(sip_call_group_t *group, sip_msg_t *msg) { int number = 0; sip_msg_t *cur = NULL; while ((cur = call_group_get_next_msg(group, cur))) { if (group->sdp_only && !msg_has_sdp(msg)) continue; if (cur == msg) return number; number++; } return 0; }
sip_call_t * call_group_get_next(sip_call_group_t *group, sip_call_t *call) { sip_msg_t *next, *first; sip_call_t *c; int i; if (!group) return NULL; // Get call of the first message in group if (!call) { if ((next = call_group_get_next_msg(group, NULL))) { return next->call; } return NULL; } // Initialize candidate next = NULL; // Get the call with the next chronological message for (i = 0; i < vector_count(group->calls); i++) { if ((c = vector_item(group->calls, i)) == call) continue; // Get first message first = vector_first(c->msgs); // Is first message of this call older? if (msg_is_older(first, vector_first(call->msgs)) && (!next || !msg_is_older(first, next))) { next = first; break; } } return (next) ? next->call : NULL; }
int call_raw_draw(PANEL *panel) { call_raw_info_t *info; sip_msg_t *msg = NULL; // Get panel information if(!(info = call_raw_info(panel))) return -1; if (info->group) { // Print the call group messages into the pad while ((msg = call_group_get_next_msg(info->group, info->last))) call_raw_print_msg(panel, msg); } else { call_raw_set_msg(info->msg); } // Copy the visible part of the pad into the panel window copywin(info->pad, panel_window(panel), info->scroll, 0, 0, 0, LINES - 1, COLS - 1, 0); touchwin(panel_window(panel)); return 0; }