mirror of
https://github.com/dborth/fceugx.git
synced 2025-01-07 14:28:18 +01:00
network cleanup
This commit is contained in:
parent
7ffa0c17db
commit
3893c3fb51
@ -9,26 +9,16 @@
|
|||||||
* SMB support routines
|
* SMB support routines
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <gccore.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ogcsys.h>
|
|
||||||
#include <network.h>
|
#include <network.h>
|
||||||
#include <smb.h>
|
#include <smb.h>
|
||||||
#include <zlib.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "fceugx.h"
|
#include "fceugx.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "gcunzip.h"
|
|
||||||
#include "menudraw.h"
|
#include "menudraw.h"
|
||||||
#include "filesel.h"
|
|
||||||
|
|
||||||
bool networkInit = false;
|
bool networkInit = false;
|
||||||
|
bool autoNetworkInit = true;
|
||||||
bool networkShareInit = false;
|
bool networkShareInit = false;
|
||||||
bool networkInitHalt = false;
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* InitializeNetwork
|
* InitializeNetwork
|
||||||
@ -37,36 +27,32 @@ bool networkInitHalt = false;
|
|||||||
|
|
||||||
void InitializeNetwork(bool silent)
|
void InitializeNetwork(bool silent)
|
||||||
{
|
{
|
||||||
if(networkInit || networkInitHalt)
|
// stop if we're already initialized, or if auto-init has failed before
|
||||||
|
// in which case, manual initialization is required
|
||||||
|
if(networkInit || !autoNetworkInit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!silent)
|
if(!silent)
|
||||||
ShowAction ("Initializing network...");
|
ShowAction ("Initializing network...");
|
||||||
|
|
||||||
s32 result;
|
char ip[16];
|
||||||
|
s32 initResult = if_config(ip, NULL, NULL, true);
|
||||||
|
|
||||||
while ((result = net_init()) == -EAGAIN);
|
if(initResult == 0)
|
||||||
|
|
||||||
if (result >= 0)
|
|
||||||
{
|
{
|
||||||
char myIP[16];
|
networkInit = true;
|
||||||
|
|
||||||
if (if_config(myIP, NULL, NULL, true) < 0)
|
|
||||||
{
|
|
||||||
networkInitHalt = true; // do not attempt a reconnection again
|
|
||||||
|
|
||||||
if(!silent)
|
|
||||||
WaitPrompt("Error reading IP address.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
networkInit = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// do not automatically attempt a reconnection
|
||||||
|
autoNetworkInit = false;
|
||||||
|
|
||||||
if(!silent)
|
if(!silent)
|
||||||
WaitPrompt("Unable to initialize network.");
|
{
|
||||||
|
char msg[150];
|
||||||
|
sprintf(msg, "Unable to initialize network (Error #: %i)", initResult);
|
||||||
|
WaitPrompt(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,14 +75,32 @@ ConnectShare (bool silent)
|
|||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// check that all parameter have been set
|
int chkU = (strlen(GCSettings.smbuser) > 0) ? 0:1;
|
||||||
if(strlen(GCSettings.smbuser) == 0 ||
|
int chkP = (strlen(GCSettings.smbpwd) > 0) ? 0:1;
|
||||||
strlen(GCSettings.smbpwd) == 0 ||
|
int chkS = (strlen(GCSettings.smbshare) > 0) ? 0:1;
|
||||||
strlen(GCSettings.smbshare) == 0 ||
|
int chkI = (strlen(GCSettings.smbip) > 0) ? 0:1;
|
||||||
strlen(GCSettings.smbip) == 0)
|
|
||||||
|
// check that all parameters have been set
|
||||||
|
if(chkU + chkP + chkS + chkI > 0)
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
WaitPrompt("Invalid network settings. Check settings.xml.");
|
{
|
||||||
|
char msg[50];
|
||||||
|
char msg2[100];
|
||||||
|
if(chkU + chkP + chkS + chkI > 1) // more than one thing is wrong
|
||||||
|
sprintf(msg, "Check settings.xml.");
|
||||||
|
else if(chkU)
|
||||||
|
sprintf(msg, "Username is blank.");
|
||||||
|
else if(chkP)
|
||||||
|
sprintf(msg, "Password is blank.");
|
||||||
|
else if(chkS)
|
||||||
|
sprintf(msg, "Share name is blank.");
|
||||||
|
else if(chkI)
|
||||||
|
sprintf(msg, "Share IP is blank.");
|
||||||
|
|
||||||
|
sprintf(msg2, "Invalid network settings - %s", msg);
|
||||||
|
WaitPrompt(msg2);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user