CVSROOT: /sources/gnash Module name: gnash Changes by: Benjamin Wolsey <bwy> 07/12/12 18:19:28
Modified files: . : ChangeLog configure.ac libbase : rc.cpp rc.h server/asobj : System.cpp server/vm : VM.cpp VM.h Log message: * server/asobj/System.cpp: implement language, hasAudio; find os at runtime. * libbase/rc.{h,cpp}: do not set _flashSystemOS by default; doing so overrides runtime OS detection. * server/vm/VM.{h,cpp}: add methods to retrieve current OS and current language for System.capabilities. * configure.ac: test for sys/utsname.h (for system information). CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5145&r2=1.5146 http://cvs.savannah.gnu.org/viewcvs/gnash/configure.ac?cvsroot=gnash&r1=1.457&r2=1.458 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.cpp?cvsroot=gnash&r1=1.45&r2=1.46 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.h?cvsroot=gnash&r1=1.33&r2=1.34 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/System.cpp?cvsroot=gnash&r1=1.17&r2=1.18 http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/VM.cpp?cvsroot=gnash&r1=1.27&r2=1.28 http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/VM.h?cvsroot=gnash&r1=1.22&r2=1.23 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.5145 retrieving revision 1.5146 diff -u -b -r1.5145 -r1.5146 --- ChangeLog 12 Dec 2007 16:35:19 -0000 1.5145 +++ ChangeLog 12 Dec 2007 18:19:26 -0000 1.5146 @@ -1,3 +1,13 @@ +2007-12-12 Benjamin Wolsey <[EMAIL PROTECTED]> + + * server/asobj/System.cpp: implement language, hasAudio; find os + at runtime. + * libbase/rc.{h,cpp}: do not set _flashSystemOS by default; doing + so overrides runtime OS detection. + * server/vm/VM.{h,cpp}: add methods to retrieve current OS and + current language for System.capabilities. + * configure.ac: test for sys/utsname.h (for system information). + 2007-12-12 Sandro Santilli <[EMAIL PROTECTED]> * server/swf/tag_loaders.cpp: add support for limiting reads from Index: configure.ac =================================================================== RCS file: /sources/gnash/gnash/configure.ac,v retrieving revision 1.457 retrieving revision 1.458 diff -u -b -r1.457 -r1.458 --- configure.ac 12 Dec 2007 12:19:55 -0000 1.457 +++ configure.ac 12 Dec 2007 18:19:27 -0000 1.458 @@ -1,4 +1,4 @@ -dnl +hednl dnl Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. dnl dnl This program is free software; you can redistribute it and/or modify @@ -15,7 +15,7 @@ dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA dnl -dnl $Id: configure.ac,v 1.457 2007/12/12 12:19:55 strk Exp $ +dnl $Id: configure.ac,v 1.458 2007/12/12 18:19:27 bwy Exp $ AC_PREREQ(2.50) AC_INIT(gnash, cvs) @@ -933,6 +933,7 @@ AC_CHECK_HEADERS(getopt.h) AC_CHECK_HEADERS(libgen.h) AC_CHECK_HEADERS(pwd.h) +AC_CHECK_HEADERS(sys/utsname.h) AC_CHECK_LIB(m, sqrt) AC_CHECK_LIB(c, getpwnam,AC_DEFINE(HAVE_GETPWNAM, 1, [Has getpwnam] )) Index: libbase/rc.cpp =================================================================== RCS file: /sources/gnash/gnash/libbase/rc.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -u -b -r1.45 -r1.46 --- libbase/rc.cpp 12 Dec 2007 12:09:02 -0000 1.45 +++ libbase/rc.cpp 12 Dec 2007 18:19:27 -0000 1.46 @@ -68,7 +68,7 @@ DEFAULT_FLASH_MAJOR_VERSION","\ DEFAULT_FLASH_MINOR_VERSION","\ DEFAULT_FLASH_REV_NUMBER ",0"), - _flashSystemOS(DEFAULT_FLASH_SYSTEM_OS), + _flashSystemOS(), _flashSystemManufacturer("Gnash "DEFAULT_FLASH_SYSTEM_OS), _actiondump(false), _parserdump(false), Index: libbase/rc.h =================================================================== RCS file: /sources/gnash/gnash/libbase/rc.h,v retrieving revision 1.33 retrieving revision 1.34 diff -u -b -r1.33 -r1.34 --- libbase/rc.h 12 Dec 2007 12:09:02 -0000 1.33 +++ libbase/rc.h 12 Dec 2007 18:19:27 -0000 1.34 @@ -151,9 +151,13 @@ bool _debug; // enable debugging of this class bool _debugger; // enable the Flash movie debugger int _verbosity; - std::string _flashVersionString; //String to pass as $version in Actionscript - std::string _flashSystemOS; //String to pass as System.capabilities.os in Actionscript - std::string _flashSystemManufacturer; //String to pass as System.capabilities.manufacturer in Actionscript + std::string _flashVersionString; // String to pass as $version in Actionscript + std::string _flashSystemOS; // String to pass as System.capabilities.os + // in Actionscript. If empty, leaves detection + // to System.cpp (default). + std::string _flashSystemManufacturer; // String to pass as + // System.capabilities.manufacturer + // in Actionscript bool _actiondump; // enable dumping actionscript classes bool _parserdump; // enable dumping parser data Index: server/asobj/System.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/System.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -b -r1.17 -r1.18 --- server/asobj/System.cpp 12 Dec 2007 12:09:02 -0000 1.17 +++ server/asobj/System.cpp 12 Dec 2007 18:19:27 -0000 1.18 @@ -74,13 +74,22 @@ // "stand-alone", "external", "plug-in", or "ActiveX". proto->init_member("playerType", "stand-alone", flags); - // TODO: // "Windows XP", "Windows 2000", "Windows NT", "Windows 98/ME", "Windows 95", "Windows CE", "Linux", "MacOS" - proto->init_member("os", rcfile.getFlashSystemOS(), flags); + proto->init_member("os", VM::get().getOSName(), flags); - // TODO: should be manufacturer and platform // "Macromedia Windows", "Macromedia Linux", "Macromedia MacOS" proto->init_member("manufacturer", rcfile.getFlashSystemManufacturer(), flags); + + /* Human Interface */ + + // Two-letter language code ('en', 'de') + proto->init_member("language", VM::get().getSystemLanguage(), flags); + + /* Media */ + + // Is audio available? + proto->init_member("hasAudio", (get_sound_handler() != NULL), flags); + } return proto.get(); } Index: server/vm/VM.cpp =================================================================== RCS file: /sources/gnash/gnash/server/vm/VM.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -u -b -r1.27 -r1.28 --- server/vm/VM.cpp 10 Dec 2007 10:54:34 -0000 1.27 +++ server/vm/VM.cpp 12 Dec 2007 18:19:27 -0000 1.28 @@ -16,7 +16,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -/* $Id: VM.cpp,v 1.27 2007/12/10 10:54:34 bwy Exp $ */ +/* $Id: VM.cpp,v 1.28 2007/12/12 18:19:27 bwy Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -33,6 +33,10 @@ #include "ClassHierarchy.h" #include "VirtualClock.h" // for getTime() +#ifdef HAVE_SYS_UTSNAME_H +# include <sys/utsname.h> // For system information +#endif + #include <memory> #include <boost/random.hpp> // for random generator @@ -128,6 +132,74 @@ return version; } +const std::string +VM::getOSName() +{ + + // The directive in gnashrc must override OS detection. + if (rcfile.getFlashSystemOS() != "") + { + return rcfile.getFlashSystemOS(); + } + else + { +#ifdef HAVE_SYS_UTSNAME_H +// For Linux- or UNIX-based systems (POSIX 4.4 conformant) + + utsname osname; + std::string tmp; + + uname (&osname); + + tmp = osname.sysname; + tmp += " "; + tmp += osname.release; + + return tmp; +#else +// Last resort, hard-coded from compile-time options + + return DEFAULT_FLASH_SYSTEM_OS; +#endif + } +} + +const std::string +VM::getSystemLanguage() +{ + std::string lang; + char *loc; + + // Try various environment variables. These should + // be in the standard form "de", "de_DE" or "de_DE.utf8" + // We'll return the first two characters anyway. + // This should work on most UNIX-like systems. + // TODO: Other OSs. + if ((loc = getenv("LANG"))) + { + lang = loc; + } + else if ((loc = getenv("LANGUAGE"))) + { + lang = loc; + } + else if ((loc = getenv("LC_MESSAGES"))) + { + lang = loc; + } + + if (lang.length() >= 2) + { + return lang.substr(0,2); + } + else + { + // TODO: what should be returned if we fail to + // find a language string? + return ""; + } +} + movie_root& VM::getRoot() const { Index: server/vm/VM.h =================================================================== RCS file: /sources/gnash/gnash/server/vm/VM.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -b -r1.22 -r1.23 --- server/vm/VM.h 10 Dec 2007 10:54:34 -0000 1.22 +++ server/vm/VM.h 12 Dec 2007 18:19:28 -0000 1.23 @@ -209,6 +209,17 @@ /// const std::string& getPlayerVersion() const; + /// Get current OS name. This is used for System.capabilites.os. If + /// defined in gnashrc, that takes precedence. For Linux, the string + /// includes the kernel version (unname -sr). Only works for systems + /// with sys/utsname.h (POSIX 4.4). + const std::string getOSName(); + + /// Return the current language of the system. This is used for + /// System.capabilities.language. Only works for systems with + /// a language environment variable. + const std::string getSystemLanguage(); + // The boost Random Number Generator to use. // // http://www.boost.org/libs/random/random-generators.html _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit