mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-01 23:43:35 +00:00
Finally DTRT with tcpOpenDialog(); it should have never diddled
mediaDevice directly.
This commit is contained in:
parent
4cca17ae59
commit
70f8c15560
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=22842
@ -499,12 +499,12 @@ installNovice(dialogMenuItem *self)
|
||||
}
|
||||
if (mediaDevice->type != DEVICE_TYPE_FTP && mediaDevice->type != DEVICE_TYPE_NFS) {
|
||||
if (!msgYesNo("Would you like to configure any SLIP/PPP or network interface devices?")) {
|
||||
Device *save = mediaDevice;
|
||||
Device *tmp;
|
||||
|
||||
/* This will also set the media device, which we don't want */
|
||||
tcpDeviceSelect();
|
||||
/* so we restore our saved value below */
|
||||
mediaDevice = save;
|
||||
tmp = tcpDeviceSelect();
|
||||
if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (!tmp->init(tmp))
|
||||
msgConfirm("Initialization of %s device failed.", tmp->name);
|
||||
dialog_clear_norefresh();
|
||||
}
|
||||
}
|
||||
|
@ -335,18 +335,16 @@ mediaSetFTP(dialogMenuItem *self)
|
||||
"would you like to skip over it now?") != 0) {
|
||||
if (networkDev)
|
||||
networkDev->shutdown(networkDev);
|
||||
networkDev = NULL;
|
||||
if (!tcpDeviceSelect()) {
|
||||
if (!(networkDev = tcpDeviceSelect())) {
|
||||
variable_unset(VAR_FTP_PATH);
|
||||
return DITEM_FAILURE | what;
|
||||
}
|
||||
if (!mediaDevice || !mediaDevice->init(mediaDevice)) {
|
||||
if (isDebug())
|
||||
msgDebug("mediaSetFTP: Net device init failed.\n");
|
||||
variable_unset(VAR_FTP_PATH);
|
||||
return DITEM_FAILURE | what;
|
||||
}
|
||||
networkDev = mediaDevice;
|
||||
}
|
||||
if (!networkDev->init(networkDev)) {
|
||||
if (isDebug())
|
||||
msgDebug("mediaSetFTP: Net device init failed.\n");
|
||||
variable_unset(VAR_FTP_PATH);
|
||||
return DITEM_FAILURE | what;
|
||||
}
|
||||
hostname = cp + 6;
|
||||
if ((cp = index(hostname, ':')) != NULL) {
|
||||
@ -448,15 +446,12 @@ mediaSetNFS(dialogMenuItem *self)
|
||||
"would you like to skip over it now?") != 0) {
|
||||
if (networkDev)
|
||||
networkDev->shutdown(networkDev);
|
||||
networkDev = NULL;
|
||||
if (!tcpDeviceSelect())
|
||||
if (!(networkDev = tcpDeviceSelect()))
|
||||
return DITEM_FAILURE;
|
||||
if (!mediaDevice || !mediaDevice->init(mediaDevice)) {
|
||||
if (isDebug())
|
||||
msgDebug("mediaSetNFS: Net device init failed\n");
|
||||
return DITEM_FAILURE;
|
||||
}
|
||||
networkDev = mediaDevice;
|
||||
}
|
||||
if (!networkDev->init(networkDev)) {
|
||||
if (isDebug())
|
||||
msgDebug("mediaSetNFS: Net device init failed\n");
|
||||
}
|
||||
if (variable_get(VAR_NAMESERVER)) {
|
||||
if ((gethostbyname(cp) == NULL) && (inet_addr(cp) == INADDR_NONE)) {
|
||||
|
@ -666,7 +666,7 @@ extern void mediaShutdownTape(Device *dev);
|
||||
/* tcpip.c */
|
||||
extern int tcpOpenDialog(Device *dev);
|
||||
extern int tcpMenuSelect(dialogMenuItem *self);
|
||||
extern Boolean tcpDeviceSelect(void);
|
||||
extern Device *tcpDeviceSelect(void);
|
||||
|
||||
/* termcap.c */
|
||||
extern int set_termcap(void);
|
||||
|
@ -309,6 +309,8 @@ reenter:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Device *NetDev;
|
||||
|
||||
static int
|
||||
netHook(dialogMenuItem *self)
|
||||
{
|
||||
@ -317,33 +319,31 @@ netHook(dialogMenuItem *self)
|
||||
devs = deviceFindDescr(self->prompt, self->title, DEVICE_TYPE_NETWORK);
|
||||
if (devs) {
|
||||
if (DITEM_STATUS(tcpOpenDialog(devs[0])) != DITEM_FAILURE)
|
||||
mediaDevice = devs[0];
|
||||
NetDev = devs[0];
|
||||
else
|
||||
devs = NULL;
|
||||
NetDev = NULL;
|
||||
}
|
||||
return devs ? DITEM_LEAVE_MENU : DITEM_FAILURE;
|
||||
}
|
||||
|
||||
/* Get a network device */
|
||||
Boolean
|
||||
Device *
|
||||
tcpDeviceSelect(void)
|
||||
{
|
||||
DMenu *menu;
|
||||
Device **devs;
|
||||
Device **devs, *rval;
|
||||
int cnt;
|
||||
int status;
|
||||
|
||||
devs = deviceFind(NULL, DEVICE_TYPE_NETWORK);
|
||||
cnt = deviceCount(devs);
|
||||
if (!cnt) {
|
||||
msgConfirm("No network devices available!");
|
||||
status = FALSE;
|
||||
rval = NULL;
|
||||
}
|
||||
else if (cnt == 1) {
|
||||
if (DITEM_STATUS(tcpOpenDialog(devs[0]) == DITEM_FAILURE))
|
||||
return FALSE;
|
||||
mediaDevice = devs[0];
|
||||
status = TRUE;
|
||||
return NULL;
|
||||
rval = devs[0];
|
||||
}
|
||||
else {
|
||||
menu = deviceCreateMenu(&MenuNetworkDevice, DEVICE_TYPE_NETWORK, netHook, NULL);
|
||||
@ -351,14 +351,20 @@ tcpDeviceSelect(void)
|
||||
msgFatal("Unable to create network device menu! Argh!");
|
||||
status = dmenuOpenSimple(menu, FALSE);
|
||||
free(menu);
|
||||
rval = NetDev;
|
||||
}
|
||||
return status;
|
||||
return rval;
|
||||
}
|
||||
|
||||
/* Do it from a menu that doesn't care about status */
|
||||
int
|
||||
tcpMenuSelect(dialogMenuItem *self)
|
||||
{
|
||||
(void)tcpDeviceSelect();
|
||||
Device *tmp;
|
||||
|
||||
tmp = tcpDeviceSelect();
|
||||
if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (!tmp->init(tmp))
|
||||
msgConfirm("Initialization of %s device failed.", tmp->name);
|
||||
return DITEM_SUCCESS | DITEM_RESTORE;
|
||||
}
|
||||
|
@ -499,12 +499,12 @@ installNovice(dialogMenuItem *self)
|
||||
}
|
||||
if (mediaDevice->type != DEVICE_TYPE_FTP && mediaDevice->type != DEVICE_TYPE_NFS) {
|
||||
if (!msgYesNo("Would you like to configure any SLIP/PPP or network interface devices?")) {
|
||||
Device *save = mediaDevice;
|
||||
Device *tmp;
|
||||
|
||||
/* This will also set the media device, which we don't want */
|
||||
tcpDeviceSelect();
|
||||
/* so we restore our saved value below */
|
||||
mediaDevice = save;
|
||||
tmp = tcpDeviceSelect();
|
||||
if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (!tmp->init(tmp))
|
||||
msgConfirm("Initialization of %s device failed.", tmp->name);
|
||||
dialog_clear_norefresh();
|
||||
}
|
||||
}
|
||||
|
@ -666,7 +666,7 @@ extern void mediaShutdownTape(Device *dev);
|
||||
/* tcpip.c */
|
||||
extern int tcpOpenDialog(Device *dev);
|
||||
extern int tcpMenuSelect(dialogMenuItem *self);
|
||||
extern Boolean tcpDeviceSelect(void);
|
||||
extern Device *tcpDeviceSelect(void);
|
||||
|
||||
/* termcap.c */
|
||||
extern int set_termcap(void);
|
||||
|
@ -499,12 +499,12 @@ installNovice(dialogMenuItem *self)
|
||||
}
|
||||
if (mediaDevice->type != DEVICE_TYPE_FTP && mediaDevice->type != DEVICE_TYPE_NFS) {
|
||||
if (!msgYesNo("Would you like to configure any SLIP/PPP or network interface devices?")) {
|
||||
Device *save = mediaDevice;
|
||||
Device *tmp;
|
||||
|
||||
/* This will also set the media device, which we don't want */
|
||||
tcpDeviceSelect();
|
||||
/* so we restore our saved value below */
|
||||
mediaDevice = save;
|
||||
tmp = tcpDeviceSelect();
|
||||
if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (!tmp->init(tmp))
|
||||
msgConfirm("Initialization of %s device failed.", tmp->name);
|
||||
dialog_clear_norefresh();
|
||||
}
|
||||
}
|
||||
|
@ -335,18 +335,16 @@ mediaSetFTP(dialogMenuItem *self)
|
||||
"would you like to skip over it now?") != 0) {
|
||||
if (networkDev)
|
||||
networkDev->shutdown(networkDev);
|
||||
networkDev = NULL;
|
||||
if (!tcpDeviceSelect()) {
|
||||
if (!(networkDev = tcpDeviceSelect())) {
|
||||
variable_unset(VAR_FTP_PATH);
|
||||
return DITEM_FAILURE | what;
|
||||
}
|
||||
if (!mediaDevice || !mediaDevice->init(mediaDevice)) {
|
||||
if (isDebug())
|
||||
msgDebug("mediaSetFTP: Net device init failed.\n");
|
||||
variable_unset(VAR_FTP_PATH);
|
||||
return DITEM_FAILURE | what;
|
||||
}
|
||||
networkDev = mediaDevice;
|
||||
}
|
||||
if (!networkDev->init(networkDev)) {
|
||||
if (isDebug())
|
||||
msgDebug("mediaSetFTP: Net device init failed.\n");
|
||||
variable_unset(VAR_FTP_PATH);
|
||||
return DITEM_FAILURE | what;
|
||||
}
|
||||
hostname = cp + 6;
|
||||
if ((cp = index(hostname, ':')) != NULL) {
|
||||
@ -448,15 +446,12 @@ mediaSetNFS(dialogMenuItem *self)
|
||||
"would you like to skip over it now?") != 0) {
|
||||
if (networkDev)
|
||||
networkDev->shutdown(networkDev);
|
||||
networkDev = NULL;
|
||||
if (!tcpDeviceSelect())
|
||||
if (!(networkDev = tcpDeviceSelect()))
|
||||
return DITEM_FAILURE;
|
||||
if (!mediaDevice || !mediaDevice->init(mediaDevice)) {
|
||||
if (isDebug())
|
||||
msgDebug("mediaSetNFS: Net device init failed\n");
|
||||
return DITEM_FAILURE;
|
||||
}
|
||||
networkDev = mediaDevice;
|
||||
}
|
||||
if (!networkDev->init(networkDev)) {
|
||||
if (isDebug())
|
||||
msgDebug("mediaSetNFS: Net device init failed\n");
|
||||
}
|
||||
if (variable_get(VAR_NAMESERVER)) {
|
||||
if ((gethostbyname(cp) == NULL) && (inet_addr(cp) == INADDR_NONE)) {
|
||||
|
@ -666,7 +666,7 @@ extern void mediaShutdownTape(Device *dev);
|
||||
/* tcpip.c */
|
||||
extern int tcpOpenDialog(Device *dev);
|
||||
extern int tcpMenuSelect(dialogMenuItem *self);
|
||||
extern Boolean tcpDeviceSelect(void);
|
||||
extern Device *tcpDeviceSelect(void);
|
||||
|
||||
/* termcap.c */
|
||||
extern int set_termcap(void);
|
||||
|
@ -309,6 +309,8 @@ reenter:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Device *NetDev;
|
||||
|
||||
static int
|
||||
netHook(dialogMenuItem *self)
|
||||
{
|
||||
@ -317,33 +319,31 @@ netHook(dialogMenuItem *self)
|
||||
devs = deviceFindDescr(self->prompt, self->title, DEVICE_TYPE_NETWORK);
|
||||
if (devs) {
|
||||
if (DITEM_STATUS(tcpOpenDialog(devs[0])) != DITEM_FAILURE)
|
||||
mediaDevice = devs[0];
|
||||
NetDev = devs[0];
|
||||
else
|
||||
devs = NULL;
|
||||
NetDev = NULL;
|
||||
}
|
||||
return devs ? DITEM_LEAVE_MENU : DITEM_FAILURE;
|
||||
}
|
||||
|
||||
/* Get a network device */
|
||||
Boolean
|
||||
Device *
|
||||
tcpDeviceSelect(void)
|
||||
{
|
||||
DMenu *menu;
|
||||
Device **devs;
|
||||
Device **devs, *rval;
|
||||
int cnt;
|
||||
int status;
|
||||
|
||||
devs = deviceFind(NULL, DEVICE_TYPE_NETWORK);
|
||||
cnt = deviceCount(devs);
|
||||
if (!cnt) {
|
||||
msgConfirm("No network devices available!");
|
||||
status = FALSE;
|
||||
rval = NULL;
|
||||
}
|
||||
else if (cnt == 1) {
|
||||
if (DITEM_STATUS(tcpOpenDialog(devs[0]) == DITEM_FAILURE))
|
||||
return FALSE;
|
||||
mediaDevice = devs[0];
|
||||
status = TRUE;
|
||||
return NULL;
|
||||
rval = devs[0];
|
||||
}
|
||||
else {
|
||||
menu = deviceCreateMenu(&MenuNetworkDevice, DEVICE_TYPE_NETWORK, netHook, NULL);
|
||||
@ -351,14 +351,20 @@ tcpDeviceSelect(void)
|
||||
msgFatal("Unable to create network device menu! Argh!");
|
||||
status = dmenuOpenSimple(menu, FALSE);
|
||||
free(menu);
|
||||
rval = NetDev;
|
||||
}
|
||||
return status;
|
||||
return rval;
|
||||
}
|
||||
|
||||
/* Do it from a menu that doesn't care about status */
|
||||
int
|
||||
tcpMenuSelect(dialogMenuItem *self)
|
||||
{
|
||||
(void)tcpDeviceSelect();
|
||||
Device *tmp;
|
||||
|
||||
tmp = tcpDeviceSelect();
|
||||
if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (!tmp->init(tmp))
|
||||
msgConfirm("Initialization of %s device failed.", tmp->name);
|
||||
return DITEM_SUCCESS | DITEM_RESTORE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user