options: set default savepath to current directory

This commit is contained in:
Kaian 2016-08-05 11:50:13 +02:00
parent a140032554
commit 14bcdb42b7
4 changed files with 22 additions and 8 deletions

View File

@ -54,7 +54,7 @@ void
save_create(ui_t *ui)
{
save_info_t *info;
char savepath[128];
char savepath[MAX_SETTING_LEN];
// Pause the capture while saving
capture_set_paused(1);
@ -84,13 +84,19 @@ save_create(ui_t *ui)
info->fields[FLD_SAVE_COUNT] = NULL;
// Set fields options
field_opts_off(info->fields[FLD_SAVE_PATH], O_STATIC);
field_opts_off(info->fields[FLD_SAVE_PATH], O_AUTOSKIP);
field_opts_off(info->fields[FLD_SAVE_FILE], O_STATIC);
field_opts_off(info->fields[FLD_SAVE_FILE], O_AUTOSKIP);
field_opts_off(info->fields[FLD_SAVE_ALL], O_AUTOSKIP);
field_opts_off(info->fields[FLD_SAVE_SELECTED], O_AUTOSKIP);
field_opts_off(info->fields[FLD_SAVE_DISPLAYED], O_AUTOSKIP);
field_opts_off(info->fields[FLD_SAVE_MESSAGE], O_VISIBLE);
// Limit max save path and file length
set_max_field(info->fields[FLD_SAVE_PATH], MAX_SETTING_LEN);
set_max_field(info->fields[FLD_SAVE_FILE], MAX_SETTING_LEN);
// Change background of input fields
set_field_back(info->fields[FLD_SAVE_PATH], A_UNDERLINE);
set_field_back(info->fields[FLD_SAVE_FILE], A_UNDERLINE);
@ -204,7 +210,7 @@ save_info(ui_t *ui)
int
save_draw(ui_t *ui)
{
char field_value[80];
char field_value[MAX_SETTING_LEN];
// Get panel information
save_info_t *info = save_info(ui);
@ -402,9 +408,9 @@ save_set_msg(ui_t *ui, sip_msg_t *msg)
int
save_to_file(ui_t *ui)
{
char savepath[256];
char savefile[256];
char fullfile[512];
char savepath[MAX_SETTING_LEN];
char savefile[MAX_SETTING_LEN];
char fullfile[MAX_SETTING_LEN*2];
sip_call_t *call = NULL;
sip_msg_t *msg = NULL;
pcap_dumper_t *pd = NULL;

View File

@ -26,9 +26,11 @@
* @brief Source code of functions defined in option.h
*
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "keybinding.h"
#include "option.h"
@ -50,9 +52,15 @@ init_options()
// Custom user conf file
char userconf[128];
char *home = getenv("HOME");
char *pwd = get_current_dir_name();
// Defualt savepath is current directory
if (pwd) {
setting_set_value(SETTING_SAVEPATH, pwd);
free(pwd);
}
// Initialize settings
setting_set_value(SETTING_SAVEPATH, home);
setting_set_value(SETTING_FILTER_METHODS, "REGISTER,INVITE,SUBSCRIBE,NOTIFY,OPTIONS,PUBLISH,MESSAGE");
// Add Call list column options

View File

@ -158,7 +158,7 @@ setting_set_value(int id, const char *value)
if (strlen(value) < MAX_SETTING_LEN) {
strcpy(sett->value, value);
} else {
fprintf(stderr, "Setting value %s for %s is to long\n", sett->value, sett->name);
fprintf(stderr, "Setting value %s for %s is too long\n", sett->value, sett->name);
exit(1);
}
}

View File

@ -42,7 +42,7 @@
#define __SNGREP_SETTING_H
//! Max setting value
#define MAX_SETTING_LEN 80
#define MAX_SETTING_LEN 1024
//! Shorter declarartion of setting_option struct
typedef struct setting_option setting_t;