Adds support to PCSX2 for 'SetLogDir' being passed to the plugins; needed for proper UAC/user homedir mess (patch by gregory).

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3111 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-05-29 03:36:49 +00:00
parent 1cf685c8c6
commit 250b5da3ab
7 changed files with 57 additions and 0 deletions

View File

@ -245,6 +245,7 @@ s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread);
void CALLBACK GSclose(); void CALLBACK GSclose();
void CALLBACK GSshutdown(); void CALLBACK GSshutdown();
void CALLBACK GSsetSettingsDir( const char* dir ); void CALLBACK GSsetSettingsDir( const char* dir );
void CALLBACK GSsetLogDir( const char* dir );
void CALLBACK GSvsync(int field); void CALLBACK GSvsync(int field);
void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr); void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr);
@ -298,6 +299,7 @@ s32 CALLBACK PADopen(void *pDsp);
void CALLBACK PADclose(); void CALLBACK PADclose();
void CALLBACK PADshutdown(); void CALLBACK PADshutdown();
void CALLBACK PADsetSettingsDir( const char* dir ); void CALLBACK PADsetSettingsDir( const char* dir );
void CALLBACK PADsetLogDir( const char* dir );
// PADkeyEvent is called every vsync (return NULL if no event) // PADkeyEvent is called every vsync (return NULL if no event)
keyEvent* CALLBACK PADkeyEvent(); keyEvent* CALLBACK PADkeyEvent();
@ -339,6 +341,7 @@ s32 CALLBACK SPU2open(void *pDsp);
void CALLBACK SPU2close(); void CALLBACK SPU2close();
void CALLBACK SPU2shutdown(); void CALLBACK SPU2shutdown();
void CALLBACK SPU2setSettingsDir( const char* dir ); void CALLBACK SPU2setSettingsDir( const char* dir );
void CALLBACK SPU2setLogDir( const char* dir );
void CALLBACK SPU2write(u32 mem, u16 value); void CALLBACK SPU2write(u32 mem, u16 value);
u16 CALLBACK SPU2read(u32 mem); u16 CALLBACK SPU2read(u32 mem);
@ -399,6 +402,7 @@ s32 CALLBACK CDVDopen(const char* pTitleFilename);
void CALLBACK CDVDclose(); void CALLBACK CDVDclose();
void CALLBACK CDVDshutdown(); void CALLBACK CDVDshutdown();
void CALLBACK CDVDsetSettingsDir( const char* dir ); void CALLBACK CDVDsetSettingsDir( const char* dir );
void CALLBACK CDVDsetLogDir( const char* dir );
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode); s32 CALLBACK CDVDreadTrack(u32 lsn, int mode);
@ -449,6 +453,7 @@ s32 CALLBACK DEV9open(void *pDsp);
void CALLBACK DEV9close(); void CALLBACK DEV9close();
void CALLBACK DEV9shutdown(); void CALLBACK DEV9shutdown();
void CALLBACK DEV9setSettingsDir( const char* dir ); void CALLBACK DEV9setSettingsDir( const char* dir );
void CALLBACK DEV9setLogDir( const char* dir );
u8 CALLBACK DEV9read8(u32 addr); u8 CALLBACK DEV9read8(u32 addr);
u16 CALLBACK DEV9read16(u32 addr); u16 CALLBACK DEV9read16(u32 addr);
@ -491,6 +496,7 @@ s32 CALLBACK USBopen(void *pDsp);
void CALLBACK USBclose(); void CALLBACK USBclose();
void CALLBACK USBshutdown(); void CALLBACK USBshutdown();
void CALLBACK USBsetSettingsDir( const char* dir ); void CALLBACK USBsetSettingsDir( const char* dir );
void CALLBACK USBsetLogDir( const char* dir );
u8 CALLBACK USBread8(u32 addr); u8 CALLBACK USBread8(u32 addr);
u16 CALLBACK USBread16(u32 addr); u16 CALLBACK USBread16(u32 addr);
@ -529,6 +535,7 @@ s32 CALLBACK FWopen(void *pDsp);
void CALLBACK FWclose(); void CALLBACK FWclose();
void CALLBACK FWshutdown(); void CALLBACK FWshutdown();
void CALLBACK FWsetSettingsDir( const char* dir ); void CALLBACK FWsetSettingsDir( const char* dir );
void CALLBACK FWsetLogDir( const char* dir );
u32 CALLBACK FWread32(u32 addr); u32 CALLBACK FWread32(u32 addr);
void CALLBACK FWwrite32(u32 addr, u32 value); void CALLBACK FWwrite32(u32 addr, u32 value);

View File

@ -137,6 +137,7 @@ static s32 CALLBACK fallback_freeze(int mode, freezeData *data)
static void CALLBACK fallback_keyEvent(keyEvent *ev) {} static void CALLBACK fallback_keyEvent(keyEvent *ev) {}
static void CALLBACK fallback_setSettingsDir(const char* dir) {} static void CALLBACK fallback_setSettingsDir(const char* dir) {}
static void CALLBACK fallback_SetLogFolder(const char* dir) {}
static void CALLBACK fallback_configure() {} static void CALLBACK fallback_configure() {}
static void CALLBACK fallback_about() {} static void CALLBACK fallback_about() {}
static s32 CALLBACK fallback_test() { return 0; } static s32 CALLBACK fallback_test() { return 0; }
@ -291,6 +292,7 @@ static const LegacyApi_CommonMethod s_MethMessCommon[] =
{ "keyEvent", (vMeth*)fallback_keyEvent }, { "keyEvent", (vMeth*)fallback_keyEvent },
{ "setSettingsDir", (vMeth*)fallback_setSettingsDir }, { "setSettingsDir", (vMeth*)fallback_setSettingsDir },
{ "SetLogFolder", (vMeth*)fallback_SetLogFolder },
{ "freeze", (vMeth*)fallback_freeze }, { "freeze", (vMeth*)fallback_freeze },
{ "test", (vMeth*)fallback_test }, { "test", (vMeth*)fallback_test },
@ -931,6 +933,7 @@ void PluginManager::Load( const wxString (&folders)[PluginId_Count] )
throw Exception::PluginLoadError( PluginId_Mcd, wxEmptyString, "Internal Memorycard Plugin failed to load." ); throw Exception::PluginLoadError( PluginId_Mcd, wxEmptyString, "Internal Memorycard Plugin failed to load." );
} }
SendLogFolder();
SendSettingsFolder(); SendSettingsFolder();
} }
@ -1404,6 +1407,33 @@ void PluginManager::SetSettingsFolder( const wxString& folder )
SendSettingsFolder(); SendSettingsFolder();
} }
void PluginManager::SendLogFolder()
{
ScopedLock lock( m_mtx_PluginStatus );
if( m_LogFolder.IsEmpty() ) return;
wxCharBuffer utf8buffer( m_LogFolder.ToUTF8() );
const PluginInfo* pi = tbl_PluginInfo; do {
if( m_info[pi->id] ) m_info[pi->id]->CommonBindings.SetLogFolder( utf8buffer );
} while( ++pi, pi->shortname != NULL );
}
void PluginManager::SetLogFolder( const wxString& folder )
{
ScopedLock lock( m_mtx_PluginStatus );
wxString fixedfolder( folder );
if( !fixedfolder.IsEmpty() && (fixedfolder[fixedfolder.length()-1] != wxFileName::GetPathSeparator() ) )
{
fixedfolder += wxFileName::GetPathSeparator();
}
if( m_LogFolder == fixedfolder ) return;
m_LogFolder = fixedfolder;
SendLogFolder();
}
void PluginManager::Configure( PluginsEnum_t pid ) void PluginManager::Configure( PluginsEnum_t pid )
{ {
ScopedLock lock( m_mtx_PluginStatus ); ScopedLock lock( m_mtx_PluginStatus );

View File

@ -181,6 +181,8 @@ struct LegacyPluginAPI_Common
void (CALLBACK* KeyEvent)( keyEvent* evt ); void (CALLBACK* KeyEvent)( keyEvent* evt );
void (CALLBACK* SetSettingsDir)( const char* dir ); void (CALLBACK* SetSettingsDir)( const char* dir );
void (CALLBACK* SetLogFolder)( const char* dir );
s32 (CALLBACK* Freeze)(int mode, freezeData *data); s32 (CALLBACK* Freeze)(int mode, freezeData *data);
s32 (CALLBACK* Test)(); s32 (CALLBACK* Test)();
void (CALLBACK* Configure)(); void (CALLBACK* Configure)();
@ -267,6 +269,7 @@ protected:
const PS2E_LibraryAPI* m_mcdPlugin; const PS2E_LibraryAPI* m_mcdPlugin;
wxString m_SettingsFolder; wxString m_SettingsFolder;
wxString m_LogFolder;
Threading::MutexRecursive m_mtx_PluginStatus; Threading::MutexRecursive m_mtx_PluginStatus;
// Lovely hack until the new PS2E API is completed. // Lovely hack until the new PS2E API is completed.
@ -310,6 +313,9 @@ public:
virtual void Configure( PluginsEnum_t pid ); virtual void Configure( PluginsEnum_t pid );
virtual void SetSettingsFolder( const wxString& folder ); virtual void SetSettingsFolder( const wxString& folder );
virtual void SendSettingsFolder(); virtual void SendSettingsFolder();
virtual void SetLogFolder( const wxString& folder );
virtual void SendLogFolder();
const wxString GetName( PluginsEnum_t pid ) const; const wxString GetName( PluginsEnum_t pid ) const;
const wxString GetVersion( PluginsEnum_t pid ) const; const wxString GetVersion( PluginsEnum_t pid ) const;

View File

@ -326,6 +326,11 @@ bool AppConfig::FullpathMatchTest( PluginsEnum_t pluginId, const wxString& cmpto
return left == right; return left == right;
} }
wxDirName GetLogFolder()
{
return UseDefaultLogs ? PathDefs::GetLogs() : Logs;
}
wxDirName GetSettingsFolder() wxDirName GetSettingsFolder()
{ {
return UseDefaultSettingsFolder ? PathDefs::GetSettings() : SettingsFolder; return UseDefaultSettingsFolder ? PathDefs::GetSettings() : SettingsFolder;

View File

@ -45,9 +45,12 @@ extern DocsModeType DocsFolderMode; //
extern wxDirName SettingsFolder; // dictates where the settings folder comes from, *if* UseDefaultSettingsFolder is FALSE. extern wxDirName SettingsFolder; // dictates where the settings folder comes from, *if* UseDefaultSettingsFolder is FALSE.
extern wxDirName CustomDocumentsFolder; // allows the specification of a custom home folder for PCSX2 documents files. extern wxDirName CustomDocumentsFolder; // allows the specification of a custom home folder for PCSX2 documents files.
extern bool UseDefaultSettingsFolder; // when TRUE, pcsx2 derives the settings folder from the UseAdminMode extern bool UseDefaultSettingsFolder; // when TRUE, pcsx2 derives the settings folder from the UseAdminMode
extern wxDirName Logs;
extern bool UseDefaultLogs;
wxDirName GetSettingsFolder(); wxDirName GetSettingsFolder();
wxString GetSettingsFilename(); wxString GetSettingsFilename();
wxDirName GetLogFolder();
enum AspectRatioType enum AspectRatioType
{ {

View File

@ -232,7 +232,9 @@ void AppPluginManager::Load( const wxString (&folders)[PluginId_Count] )
{ {
if( !pxAssert(!AreLoaded()) ) return; if( !pxAssert(!AreLoaded()) ) return;
SetLogFolder( GetSettingsFolder().ToString() );
SetSettingsFolder( GetSettingsFolder().ToString() ); SetSettingsFolder( GetSettingsFolder().ToString() );
_parent::Load( folders ); _parent::Load( folders );
PostPluginStatus( CorePlugins_Loaded ); PostPluginStatus( CorePlugins_Loaded );
} }
@ -273,6 +275,7 @@ void AppPluginManager::Shutdown( PluginsEnum_t pid )
void AppPluginManager::Init() void AppPluginManager::Init()
{ {
SetLogFolder( GetLogFolder().ToString() );
SetSettingsFolder( GetSettingsFolder().ToString() ); SetSettingsFolder( GetSettingsFolder().ToString() );
_parent::Init(); _parent::Init();
PostPluginStatus( CorePlugins_Init ); PostPluginStatus( CorePlugins_Init );
@ -314,6 +317,7 @@ void AppPluginManager::Open()
return; return;
}*/ }*/
SetLogFolder( GetLogFolder().ToString() );
SetSettingsFolder( GetSettingsFolder().ToString() ); SetSettingsFolder( GetSettingsFolder().ToString() );
if( !NeedsOpen() ) return; if( !NeedsOpen() ) return;

View File

@ -43,6 +43,8 @@ DocsModeType DocsFolderMode = DocsFolder_User;
wxDirName SettingsFolder; wxDirName SettingsFolder;
wxDirName CustomDocumentsFolder; wxDirName CustomDocumentsFolder;
bool UseDefaultSettingsFolder = true; bool UseDefaultSettingsFolder = true;
wxDirName Logs;
bool UseDefaultLogs = true;
ScopedPtr<AppConfig> g_Conf; ScopedPtr<AppConfig> g_Conf;
ConfigOverrides OverrideOptions; ConfigOverrides OverrideOptions;