[Scummvm-cvs-logs] scummvm master -> 8b3c36cfad99bc40742552b954df4751c3dbd149

fingolfin max at quendi.de
Fri Jun 3 13:37:37 CEST 2011


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
279a5b4f32 BACKENDS: Add OSystem::displayLogFile interface + OSX implementation
8b3c36cfad GUI: Add 'openlog' command to debugger


Commit: 279a5b4f32ebd9ed9df4390995e4bfc4da38f1df
    https://github.com/scummvm/scummvm/commit/279a5b4f32ebd9ed9df4390995e4bfc4da38f1df
Author: Max Horn (max at quendi.de)
Date: 2011-06-03T04:36:04-07:00

Commit Message:
BACKENDS: Add OSystem::displayLogFile interface + OSX implementation

Changed paths:
    backends/platform/sdl/macosx/macosx.cpp
    backends/platform/sdl/macosx/macosx.h
    backends/platform/sdl/posix/posix.cpp
    backends/platform/sdl/posix/posix.h
    common/system.h



diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp
index 0ef16d9..0624de2 100644
--- a/backends/platform/sdl/macosx/macosx.cpp
+++ b/backends/platform/sdl/macosx/macosx.cpp
@@ -34,6 +34,7 @@
 #include "common/fs.h"
 
 #include "CoreFoundation/CoreFoundation.h"
+#include "CoreServices/CoreServices.h"
 
 OSystem_MacOSX::OSystem_MacOSX()
 	:
@@ -75,4 +76,27 @@ void OSystem_MacOSX::setupIcon() {
 	// Don't set icon on OS X, as we use a nicer external icon there. 
 }
 
+bool OSystem_MacOSX::hasFeature(Feature f) {
+	if (f == kFeatureDisplayLogFile)
+		return true;
+	return OSystem_POSIX::hasFeature(f);
+}
+
+bool OSystem_MacOSX::displayLogFile() {
+	// Use LaunchServices to open the log file, if possible.
+
+	if (_logFilePath.empty())
+		return false;
+
+    FSRef ref;
+    OSStatus err;
+
+    err = FSPathMakeRef((const UInt8 *)_logFilePath.c_str(), &ref, NULL);
+    if (err == noErr) {
+        err = LSOpenFSRef(&ref, NULL);
+    }
+
+    return err != noErr;
+}
+
 #endif
diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h
index 6d78427..86c7029 100644
--- a/backends/platform/sdl/macosx/macosx.h
+++ b/backends/platform/sdl/macosx/macosx.h
@@ -29,6 +29,10 @@ class OSystem_MacOSX : public OSystem_POSIX {
 public:
 	OSystem_MacOSX();
 
+	virtual bool hasFeature(Feature f);
+
+	virtual bool displayLogFile();
+
 	virtual void initBackend();
 	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
 	virtual void setupIcon();
diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp
index 21ad7b9..f30b953 100644
--- a/backends/platform/sdl/posix/posix.cpp
+++ b/backends/platform/sdl/posix/posix.cpp
@@ -73,6 +73,10 @@ Common::String OSystem_POSIX::getDefaultConfigFileName() {
 }
 
 Common::WriteStream *OSystem_POSIX::createLogFile() {
+	// Start out by resetting _logFilePath, so that in case
+	// of a failure, we know that no log file is open.
+	_logFilePath.clear();
+
 	const char *home = getenv("HOME");
 	if (home == NULL)
 		return 0;
@@ -128,7 +132,10 @@ Common::WriteStream *OSystem_POSIX::createLogFile() {
 	logFile += "/scummvm.log";
 
 	Common::FSNode file(logFile);
-	return file.createWriteStream();
+	Common::WriteStream *stream = file.createWriteStream();
+	if (stream)
+		_logFilePath = logFile;
+	return stream;
 }
 
 #endif
diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h
index 0a4f38e..6246e6f 100644
--- a/backends/platform/sdl/posix/posix.h
+++ b/backends/platform/sdl/posix/posix.h
@@ -35,10 +35,23 @@ public:
 	virtual void initBackend();
 
 protected:
-	// Base string for creating the default path and filename
-	// for the configuration file
+	/**
+	 * Base string for creating the default path and filename for the
+	 * configuration file. This allows the Mac OS X subclass to override
+	 * the config file path and name.
+	 */
 	Common::String _baseConfigName;
 
+	/**
+	 * The path of the currently open log file, if any.
+	 *
+	 * @note This is currently a string and not an FSNode for simplicity;
+	 * e.g. we don't need to include fs.h here, and currently the
+	 * only use of this value is to use it to open the log file in an
+	 * editor; for that, we need it only as a string anyway.
+	 */
+	Common::String _logFilePath;
+
 	virtual Common::String getDefaultConfigFileName();
 
 	virtual Common::WriteStream *createLogFile();
diff --git a/common/system.h b/common/system.h
index b584739..ad706b5 100644
--- a/common/system.h
+++ b/common/system.h
@@ -195,7 +195,13 @@ public:
 		 * engine queries for to assign keys to actions ("Here's my default key
 		 * map for these actions, what do you want them set to?").
 		 */
-		kFeatureDisableKeyFiltering
+		kFeatureDisableKeyFiltering,
+
+		/**
+		 * This feature indicates whether the displayLogFile() call
+		 * is supported.
+		 */
+		kFeatureDisplayLogFile
 	};
 
 	/**
@@ -1010,6 +1016,29 @@ public:
 	virtual void logMessage(LogMessageType::Type type, const char *message);
 
 	/**
+	 * Open the log file in a way that allows the user to review it,
+	 * and possibly email it (or parts of it) to the ScummVM team,
+	 * e.g. as part of a bug report.
+	 *
+	 * On a desktop operating system, this would typically launch
+	 * some kind of (external) text editor / viewer.
+	 * On a phone, it might also cause a context switch to another
+	 * application. Finally, on some ports, it might not be supported.
+	 * at all, and so do nothing.
+	 *
+	 * The kFeatureDisplayLogFile feature flag can be used to
+	 * test whether this call has been implemented by the active
+	 * backend.
+	 *
+	 * @return true if all seems to have gone fine, false if an error occurred
+	 *
+	 * @note An error could mean that the log file did not exist,
+	 * or the editor could not launch. However, a return value of true does
+	 * not guarantee that the user actually will the log file.
+	 */
+	virtual bool displayLogFile() { return false; }
+
+	/**
 	 * Returns the locale of the system.
 	 *
 	 * This returns the currently set up locale of the system, on which


Commit: 8b3c36cfad99bc40742552b954df4751c3dbd149
    https://github.com/scummvm/scummvm/commit/8b3c36cfad99bc40742552b954df4751c3dbd149
Author: Max Horn (max at quendi.de)
Date: 2011-06-03T04:36:04-07:00

Commit Message:
GUI: Add 'openlog' command to debugger

Changed paths:
    gui/debugger.cpp
    gui/debugger.h



diff --git a/gui/debugger.cpp b/gui/debugger.cpp
index 2f49cb2..3973583 100644
--- a/gui/debugger.cpp
+++ b/gui/debugger.cpp
@@ -59,6 +59,7 @@ Debugger::Debugger() {
 	DCmd_Register("quit",				WRAP_METHOD(Debugger, Cmd_Exit));
 
 	DCmd_Register("help",				WRAP_METHOD(Debugger, Cmd_Help));
+	DCmd_Register("openlog",			WRAP_METHOD(Debugger, Cmd_OpenLog));
 
 	DCmd_Register("debugflag_list",		WRAP_METHOD(Debugger, Cmd_DebugFlagsList));
 	DCmd_Register("debugflag_enable",	WRAP_METHOD(Debugger, Cmd_DebugFlagEnable));
@@ -475,6 +476,15 @@ bool Debugger::Cmd_Help(int argc, const char **argv) {
 	return true;
 }
 
+bool Debugger::Cmd_OpenLog(int argc, const char **argv) {
+	if (g_system->hasFeature(OSystem::kFeatureDisplayLogFile))
+		g_system->displayLogFile();
+	else
+		DebugPrintf("Opening the log file not supported on this system\n");
+	return true;
+}
+
+
 bool Debugger::Cmd_DebugFlagsList(int argc, const char **argv) {
 	const Common::DebugManager::DebugChannelList &debugLevels = DebugMan.listDebugChannels();
 
diff --git a/gui/debugger.h b/gui/debugger.h
index 6da569e..031e297 100644
--- a/gui/debugger.h
+++ b/gui/debugger.h
@@ -190,6 +190,7 @@ private:
 protected:
 	bool Cmd_Exit(int argc, const char **argv);
 	bool Cmd_Help(int argc, const char **argv);
+	bool Cmd_OpenLog(int argc, const char **argv);
 	bool Cmd_DebugFlagsList(int argc, const char **argv);
 	bool Cmd_DebugFlagEnable(int argc, const char **argv);
 	bool Cmd_DebugFlagDisable(int argc, const char **argv);






More information about the Scummvm-git-logs mailing list