160 lines
4.8 KiB
C++
160 lines
4.8 KiB
C++
/***************************************************************************
|
|
menu_select_station_type.cpp - description
|
|
-------------------
|
|
begin : Tue Mar 2 2004
|
|
copyright : (C) 2004 by David Rokhvarg
|
|
email : davidr@sangoma.com
|
|
***************************************************************************/
|
|
|
|
/***************************************************************************
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
#include "menu_select_station_type.h"
|
|
#include "text_box.h"
|
|
|
|
#define DBG_SELECT_STATION_TYPE 1
|
|
|
|
menu_select_station_type::menu_select_station_type( IN char * lxdialog_path,
|
|
IN conf_file_reader* cfr)
|
|
{
|
|
snprintf(this->lxdialog_path, MAX_PATH_LENGTH, "%s", lxdialog_path);
|
|
this->cfr = cfr;
|
|
}
|
|
|
|
menu_select_station_type::~menu_select_station_type()
|
|
{
|
|
}
|
|
|
|
int menu_select_station_type::run(OUT int * selection_index)
|
|
{
|
|
string menu_str;
|
|
int rc;
|
|
char tmp_buff[MAX_PATH_LENGTH];
|
|
unsigned int option_selected;
|
|
char exit_dialog;
|
|
//help text box
|
|
text_box tb;
|
|
|
|
char backtitle[MAX_PATH_LENGTH];
|
|
|
|
snprintf(backtitle, MAX_PATH_LENGTH, "%s: ", WANCFG_PROGRAM_NAME);
|
|
snprintf(&backtitle[strlen(backtitle)], MAX_PATH_LENGTH,
|
|
"%s", get_protocol_string(NO_PROTOCOL_NEEDED));
|
|
|
|
Debug(DBG_SELECT_STATION_TYPE, ("menu_select_station_type::run()\n"));
|
|
|
|
again:
|
|
|
|
rc = YES;
|
|
option_selected = 0;
|
|
exit_dialog = NO;
|
|
menu_str = " ";
|
|
|
|
if(cfr->current_wanrouter_state == WANPIPE_RUNNING){
|
|
//if running don't let to change the protocol
|
|
tb.show_help_message(lxdialog_path, NO_PROTOCOL_NEEDED,
|
|
"Router Location can not be changed\nwhile WANPIPE is running.");
|
|
return YES;
|
|
}
|
|
|
|
/////////////////////////////////////////////////
|
|
snprintf(tmp_buff, MAX_PATH_LENGTH, " \"%d\" ", WANOPT_CPE);
|
|
menu_str += tmp_buff;
|
|
snprintf(tmp_buff, MAX_PATH_LENGTH, " \"Local (CPE)\" ");
|
|
menu_str += tmp_buff;
|
|
|
|
/////////////////////////////////////////////////
|
|
snprintf(tmp_buff, MAX_PATH_LENGTH, " \"%d\" ", WANOPT_NODE);
|
|
menu_str += tmp_buff;
|
|
snprintf(tmp_buff, MAX_PATH_LENGTH, " \"Telco (Switch)\" ");
|
|
menu_str += tmp_buff;
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
//create the explanation text for the menu
|
|
snprintf(tmp_buff, MAX_PATH_LENGTH,
|
|
"\n------------------------------------------\
|
|
\nSangoma Card Properties");
|
|
|
|
if(set_configuration( YES,//indicates to call V2 of the function
|
|
MENU_BOX_BACK,//MENU_BOX_SELECT,
|
|
lxdialog_path,
|
|
"ROUTER LOCATION",
|
|
WANCFG_PROGRAM_NAME,
|
|
tmp_buff,
|
|
MENU_HEIGTH, MENU_WIDTH,
|
|
2,//number of items in the menu, including the empty lines
|
|
(char*)menu_str.c_str()
|
|
) == NO){
|
|
rc = NO;
|
|
goto cleanup;
|
|
}
|
|
|
|
if(show(selection_index) == NO){
|
|
rc = NO;
|
|
goto cleanup;
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
exit_dialog = NO;
|
|
switch(*selection_index)
|
|
{
|
|
case MENU_BOX_BUTTON_SELECT:
|
|
Debug(DBG_SELECT_STATION_TYPE,
|
|
("menu_net_interface_ip_configuration: option selected for editing: %s\n",
|
|
get_lxdialog_output_string()));
|
|
|
|
switch(atoi(get_lxdialog_output_string()))
|
|
{
|
|
case WANOPT_CPE:
|
|
cfr->station_type = WANOPT_CPE;
|
|
exit_dialog = YES;
|
|
break;
|
|
|
|
case WANOPT_NODE:
|
|
cfr->station_type = WANOPT_NODE;
|
|
exit_dialog = YES;
|
|
break;
|
|
|
|
default:
|
|
ERR_DBG_OUT(("Invalid option selected for editing!! selection: %s\n",
|
|
get_lxdialog_output_string()));
|
|
rc = NO;
|
|
exit_dialog = YES;
|
|
}
|
|
break;
|
|
|
|
case MENU_BOX_BUTTON_HELP:
|
|
Debug(DBG_SELECT_STATION_TYPE, ("MENU_BOX_BUTTON_HELP: option selected for editing: %s\n",
|
|
get_lxdialog_output_string()));
|
|
|
|
switch(atoi(get_lxdialog_output_string()))
|
|
{
|
|
|
|
default:
|
|
ERR_DBG_OUT(("Invalid option selected for editing!! selection: %s\n",
|
|
get_lxdialog_output_string()));
|
|
rc = NO;
|
|
exit_dialog = YES;
|
|
}
|
|
break;
|
|
|
|
case MENU_BOX_BUTTON_EXIT:
|
|
exit_dialog = YES;
|
|
break;
|
|
}//switch(*selection_index)
|
|
|
|
if(exit_dialog == NO){
|
|
goto again;
|
|
}
|
|
|
|
cleanup:
|
|
return rc;
|
|
}
|
|
|