interface to allow more specific error messages

This commit is contained in:
Glenn Maynard
2005-04-22 05:48:52 +00:00
parent 0d9b7c943a
commit 30c3578cdc
6 changed files with 27 additions and 15 deletions
+6 -3
View File
@@ -413,6 +413,7 @@ void MemoryCardManager::CheckStateChanges()
UsbStorageDevice &new_device = m_Device[p]; UsbStorageDevice &new_device = m_Device[p];
MemoryCardState state = MEMORY_CARD_STATE_INVALID; MemoryCardState state = MEMORY_CARD_STATE_INVALID;
CString sError;
if( m_bCardsLocked ) if( m_bCardsLocked )
{ {
@@ -434,9 +435,9 @@ void MemoryCardManager::CheckStateChanges()
{ {
if( m_FinalDevice[p].sSerial != new_device.sSerial ) if( m_FinalDevice[p].sSerial != new_device.sSerial )
{ {
/* A different card is inserted than we had when we finalized; /* A different card is inserted than we had when we finalized. */
* ignore it. */ state = MEMORY_CARD_STATE_ERROR;
state = MEMORY_CARD_STATE_REMOVED; sError = "Changed";
} }
} }
@@ -458,6 +459,7 @@ void MemoryCardManager::CheckStateChanges()
case UsbStorageDevice::STATE_ERROR: case UsbStorageDevice::STATE_ERROR:
state = MEMORY_CARD_STATE_ERROR; state = MEMORY_CARD_STATE_ERROR;
sError = new_device.m_sError;
break; break;
case UsbStorageDevice::STATE_READY: case UsbStorageDevice::STATE_READY:
@@ -489,6 +491,7 @@ void MemoryCardManager::CheckStateChanges()
} }
m_State[p] = state; m_State[p] = state;
m_sError[p] = sError;
} }
} }
+1 -2
View File
@@ -21,7 +21,6 @@ ScreenSystemLayer::ScreenSystemLayer( const CString &sName ) : Screen(sName)
CREDITS_PRESS_START.Load("ScreenSystemLayer","CreditsPressStart"); CREDITS_PRESS_START.Load("ScreenSystemLayer","CreditsPressStart");
CREDITS_INSERT_CARD.Load("ScreenSystemLayer","CreditsInsertCard"); CREDITS_INSERT_CARD.Load("ScreenSystemLayer","CreditsInsertCard");
CREDITS_CARD_ERROR.Load("ScreenSystemLayer","CreditsCardError");
CREDITS_CARD_TOO_LATE.Load("ScreenSystemLayer","CreditsCardTooLate"); CREDITS_CARD_TOO_LATE.Load("ScreenSystemLayer","CreditsCardTooLate");
CREDITS_CARD_NO_NAME.Load("ScreenSystemLayer","CreditsCardNoName"); CREDITS_CARD_NO_NAME.Load("ScreenSystemLayer","CreditsCardNoName");
CREDITS_CARD_READY.Load("ScreenSystemLayer","CreditsCardReady"); CREDITS_CARD_READY.Load("ScreenSystemLayer","CreditsCardReady");
@@ -145,7 +144,7 @@ CString ScreenSystemLayer::GetCreditsMessage( PlayerNumber pn ) const
else else
return ""; return "";
case MEMORY_CARD_STATE_ERROR: return CREDITS_CARD_ERROR.GetValue(); case MEMORY_CARD_STATE_ERROR: return THEME->GetMetric( m_sName, "CreditsCard" + MEMCARDMAN->GetCardError(pn) );
case MEMORY_CARD_STATE_TOO_LATE: return CREDITS_CARD_TOO_LATE.GetValue(); case MEMORY_CARD_STATE_TOO_LATE: return CREDITS_CARD_TOO_LATE.GetValue();
case MEMORY_CARD_STATE_CHECKING: return CREDITS_CARD_CHECKING.GetValue(); case MEMORY_CARD_STATE_CHECKING: return CREDITS_CARD_CHECKING.GetValue();
case MEMORY_CARD_STATE_REMOVED: return CREDITS_CARD_REMOVED.GetValue(); case MEMORY_CARD_STATE_REMOVED: return CREDITS_CARD_REMOVED.GetValue();
-1
View File
@@ -37,7 +37,6 @@ private:
ThemeMetric<CString> CREDITS_PRESS_START; ThemeMetric<CString> CREDITS_PRESS_START;
ThemeMetric<CString> CREDITS_INSERT_CARD; ThemeMetric<CString> CREDITS_INSERT_CARD;
ThemeMetric<CString> CREDITS_CARD_ERROR;
ThemeMetric<CString> CREDITS_CARD_TOO_LATE; ThemeMetric<CString> CREDITS_CARD_TOO_LATE;
ThemeMetric<CString> CREDITS_CARD_NO_NAME; ThemeMetric<CString> CREDITS_CARD_NO_NAME;
ThemeMetric<CString> CREDITS_CARD_READY; ThemeMetric<CString> CREDITS_CARD_READY;
@@ -47,6 +47,9 @@ struct UsbStorageDevice
STATE_READY, STATE_READY,
}; };
State m_State; State m_State;
CString m_sError;
void SetError( const CString &sError ) { m_State = STATE_ERROR; m_sError = sError; }
bool bIsNameAvailable; // Name in the profile on the memory card. bool bIsNameAvailable; // Name in the profile on the memory card.
CString sName; // Name in the profile on the memory card. CString sName; // Name in the profile on the memory card.
@@ -220,10 +220,17 @@ bool MemoryCardDriverThreaded_Linux::DoOneUpdate( bool bMount, vector<UsbStorage
continue; continue;
} }
CString sCommand = "mount " + d.sDevice; if( !ExecuteCommand("mount " + d.sDevice) )
bool bMountedSuccessfully = ExecuteCommand( sCommand ); {
d.SetError( "MountFailed" );
continue;
}
if( bMountedSuccessfully && TestWrite( d.sOsMountDir ) ) if( !TestWrite(d.sOsMountDir) )
{
d.SetError( "TestFailed" );
}
else
{ {
/* We've successfully mounted and tested the device. Read the /* We've successfully mounted and tested the device. Read the
* profile name (by mounting a temporary, private mountpoint), * profile name (by mounting a temporary, private mountpoint),
@@ -239,11 +246,9 @@ bool MemoryCardDriverThreaded_Linux::DoOneUpdate( bool bMount, vector<UsbStorage
FILEMAN->Unmount( "dir", d.sOsMountDir, TEMP_MOUNT_POINT ); FILEMAN->Unmount( "dir", d.sOsMountDir, TEMP_MOUNT_POINT );
CString sCommand = "umount " + d.sOsMountDir;
ExecuteCommand( sCommand );
} }
else
d.m_State = UsbStorageDevice::STATE_ERROR; ExecuteCommand( "umount " + d.sOsMountDir );
LOG->Trace( "WriteTest: %s, Name: %s", d.m_State == UsbStorageDevice::STATE_ERROR? "failed":"succeeded", d.sName.c_str() ); LOG->Trace( "WriteTest: %s, Name: %s", d.m_State == UsbStorageDevice::STATE_ERROR? "failed":"succeeded", d.sName.c_str() );
} }
@@ -89,7 +89,10 @@ bool MemoryCardDriverThreaded_Windows::DoOneUpdate( bool bMount, vector<UsbStora
UsbStorageDevice usbd; UsbStorageDevice usbd;
usbd.SetOsMountDir( sDrive ); usbd.SetOsMountDir( sDrive );
usbd.m_State = TestWrite( sDrive )? UsbStorageDevice::STATE_READY:UsbStorageDevice::STATE_ERROR; if( TestWrite(sDrive) )
usbd.m_State = UsbStorageDevice::STATE_READY;
else
usbd.SetError( "MountFailed" );
// read name // read name
this->Mount( &usbd ); this->Mount( &usbd );