gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog libbase/rc.cpp libbase/rc.h


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog libbase/rc.cpp libbase/rc.h
Date: Thu, 17 Jan 2008 15:25:37 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/01/17 15:25:36

Modified files:
        .              : ChangeLog 
        libbase        : rc.cpp rc.h 

Log message:
        * libbase/rc.{h,cpp}: enable writing of rcfiles (updateFile). Add 
function to set malformedSWF verbosity (already declared in rc.h). Add 
convenience function for writing path lists to a stream. Make sure strings 
consisting entirely of spaces are emptied when reading from the rcfile.
        
        This isn't used yet from any GUI. If you use it to overwrite an 
existing rcfile, it won't preserve anything that isn't stored in RcInitFile 
(especially commented-out lines) and will add things it found in other rcfiles.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5424&r2=1.5425
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.cpp?cvsroot=gnash&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.h?cvsroot=gnash&r1=1.39&r2=1.40

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5424
retrieving revision 1.5425
diff -u -b -r1.5424 -r1.5425
--- ChangeLog   17 Jan 2008 12:42:16 -0000      1.5424
+++ ChangeLog   17 Jan 2008 15:25:35 -0000      1.5425
@@ -1,3 +1,10 @@
+2008-01-17 Benjamin Wolsey <address@hidden>
+
+       * libbase/rc.{h,cpp}: enable writing of rcfiles (updateFile). Add 
function
+         to set malformedSWF verbosity (already declared in rc.h). Add 
convenience
+         function for writing path lists to a stream. Make sure strings 
consisting
+         entirely of spaces are emptied when reading from the rcfile.
+
 2008-01-17 Sandro Santilli <address@hidden>
 
        * server/button_character_instance.cpp (get_topmost_mouse_entity):

Index: libbase/rc.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/rc.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- libbase/rc.cpp      16 Jan 2008 17:19:55 -0000      1.52
+++ libbase/rc.cpp      17 Jan 2008 15:25:36 -0000      1.53
@@ -67,14 +67,15 @@
                            _debug(false),
                            _debugger(false),
                            _verbosity(-1),
-                           // will be reset to something else if __OS2__x is 
defined
+                           // will be reset to something else if __OS2__x is 
defined:
                            _urlOpenerFormat("firefox -remote 'openurl(%u)'"),
                            _flashVersionString(
                                DEFAULT_FLASH_PLATFORM_ID" "\
                                DEFAULT_FLASH_MAJOR_VERSION","\
                                DEFAULT_FLASH_MINOR_VERSION","\
                                DEFAULT_FLASH_REV_NUMBER ",0"),
-                           _flashSystemOS(), 
+                          // An empty string leaves detection to VM.cpp:
+                           _flashSystemOS(""),
                            _flashSystemManufacturer("Gnash 
"DEFAULT_FLASH_SYSTEM_OS),
                            _actionDump(false),
                            _parserDump(false),
@@ -326,6 +327,16 @@
 
 }
 
+void
+RcInitFile::writeList (std::vector<std::string>& list, std::ostream& o)
+{
+    for (std::vector<std::string>::const_iterator it = list.begin();
+       it != list.end(); ++it) {
+           o << *it << " ";
+       }
+    o << endl;
+}
+
 // Parse the config file and set the variables.
 bool
 RcInitFile::parseFile(const std::string& filespec)
@@ -381,8 +392,10 @@
             getline(in, value);
 
            // Erase leading spaces.
-            string::size_type position = value.find_first_not_of(' ');
-            if(position != string::npos) value.erase(0, position);
+            // If there are nothing but spaces in the value,
+            // e.g. "set writelog ", value should be an empty string,
+            // so value.erase(0, string::npos) is correct.
+            value.erase(0, value.find_first_not_of(' '));
 
             if (noCaseCompare(action, "set") || noCaseCompare(action, 
"append") ) {
 
@@ -495,10 +508,116 @@
 
 // Write the changed settings to the config file
 bool
-RcInitFile::updateFile(const std::string& /* filespec */)
+RcInitFile::updateFile(const std::string& filespec)
 {
-    cerr << __PRETTY_FUNCTION__ << "ERROR: unimplemented!" << endl;
+
+    if (filespec == "") {
+        return false;
+    }
+
+    ofstream out;
+    
+    out.open(filespec.c_str());
+        
+    if (!out) {
+        log_error(_("Couldn't open file %s for writing"), filespec.c_str());
     return false;
+    }
+
+    std::string cmd = "set ";
+
+    // Bools and numbers. We want boolean values written as words.
+    out << boolalpha <<
+    cmd << "splash_screen " << _splashScreen << endl <<
+    cmd << "localHost " << _localhostOnly << endl <<
+    cmd << "localDomain " << _localdomainOnly << endl <<
+    cmd << "insecureSSL " << _insecureSSL << endl <<
+    cmd << "debugger " << _debugger << endl <<
+    cmd << "actionDump " << _actionDump << endl <<
+    cmd << "parserDump " << _parserDump << endl <<
+    cmd << "writeLog " << _writeLog << endl <<
+    cmd << "sound " << _sound << endl <<
+    cmd << "pluginSound " << _pluginSound << endl <<
+    cmd << "ASCodingErrorsVerbosity " << _verboseASCodingErrors << endl <<
+    cmd << "malformedSWFVerbosity " << _verboseMalformedSWF << endl <<
+    cmd << "enableExtensions " << _extensionsEnabled << endl <<
+    cmd << "startStopped " << _startStopped << endl <<
+    cmd << "streamsTimeout " << _streamsTimeout << endl <<
+    cmd << "movieLibraryLimit " << _movieLibraryLimit << endl <<
+    cmd << "delay " << _delay << endl <<
+    cmd << "verbosity " << _verbosity << endl <<
+    cmd << "solReadOnly " << _solreadonly << endl <<
+    cmd << "localConnection " << _lcdisabled << endl <<
+    cmd << "LCTrace " << _lctrace << endl <<
+    cmd << "LCShmkey " << _lcshmkey << endl;
+   
+    // Strings.
+    // VM.cpp checks whether flashSystemOS is set in order to decide
+    // whether to send the detected value, so it's best not to write
+    // them at all if they are set to "". Gnash then defaults to the
+    // values set in the constructor.
+    
+    // This might be irritating for users who, for instance, set
+    // debuglog to nothing, only to find it returns to "gnash-debug.log"
+    // at the next run (even though that's not the way to use it...)
+    
+    if (_log != "") {
+        out << cmd << "debuglog " << _log << endl;
+    }
+
+    if (_wwwroot != "") {
+        out << cmd << "documentroot " << _wwwroot << endl;
+    }
+    
+    if (_flashSystemOS != "") {
+        out << cmd << "flashSystemOS " << _flashSystemOS << endl;
+    }
+
+    if (_flashVersionString != "") {
+        out << cmd << "flashVersionString " << _flashVersionString << endl;
+    }
+
+    if (_urlOpenerFormat != "") {
+        out << cmd << "urlOpenerFormat " << _urlOpenerFormat << endl;
+    }
+
+    if (_solsandbox != "") {
+        out << cmd << "SOLSafeDir " << _solsandbox << endl;
+    }
+
+    // Lists. These can't be handled very well at the moment. The main
+    // inconvenience would be that disabling a list makes it an empty
+    // array in the rc class, and writing that to a file would lose that
+    // blacklist you'd spent ages collecting.
+    //
+    // For now we'll just make sure lists that gnashrc finds are written.
+    // Commented out lists in gnashrc will be deleted!
+    //
+    // The difference between append and set also can't be used without
+    // a bit of trickery. It would be possible, for instance, to pass a
+    // special character (e.g. '+') as the first element of an array from
+    // the gui. However, this is possibly not all that useful anyway,
+    // as lists in other parsed rcfiles would be taken over and written
+    // as part of the new file.
+    //
+    // It might be necessary to have a 'useWhitelist' flag as well
+    // as a whitelist. This would allow rcfile to keep a whitelist and write
+    // it to disk, but not have to use it.
+    
+    out << cmd << "whitelist ";
+    writeList (_whitelist, out);
+
+    out << cmd << "blacklist ";
+    writeList (_blacklist, out);
+    
+    // This also adds the base URL of the current SWF, as that gets
+    // added to the path automatically...
+    //out << cmd << "localSandboxPath ";
+    //writeList (_localSandboxPath, out);
+
+    out.close();
+    
+    return true;
 }
 
 void
@@ -542,6 +661,18 @@
 }
 
 void
+RcInitFile::showMalformedSWFErrors(bool value)
+{
+//    GNASH_REPORT_FUNCTION;
+    
+    _verboseMalformedSWF = value;
+    
+    if (value) {
+        _verbosity++;
+    }
+}
+
+void
 RcInitFile::useParserDump(bool value)
 {
 //    GNASH_REPORT_FUNCTION;
@@ -598,9 +729,14 @@
     if (_flashVersionString.size()) {
         cerr << "\tFlash Version String is: " << _flashVersionString << endl;
     }
+    cerr << "\tWhitelist: ";
+    writeList (_whitelist, cerr);
+    
+    cerr << "\tBlacklist: ";
+    writeList (_blacklist, cerr);
     
-//     std::vector<std::string> _whitelist;
-//     std::vector<std::string> _blacklist;
+    cerr << "\tSandbox: ";
+    writeList (_localSandboxPath, cerr);
 }
 
 

Index: libbase/rc.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/rc.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- libbase/rc.h        26 Dec 2007 18:03:47 -0000      1.39
+++ libbase/rc.h        17 Jan 2008 15:25:36 -0000      1.40
@@ -27,6 +27,7 @@
 
 #include <string>
 #include <vector>
+#include <iostream>
 #include <sys/shm.h>           // for key_t
 
 namespace gnash {
@@ -81,6 +82,7 @@
     
     void setDebugLog(std::string &x) { _log = x; }
     const std::string& getDebugLog() const { return _log; }
+
     void setDocumentRoot(std::string &x) { _wwwroot = x; }
     std::string getDocumentRoot() { return _wwwroot; }
     
@@ -140,9 +142,6 @@
         _localSandboxPath = path;
     }
 
-    // Get the location of the sandbox for .sol files
-    const std::string &getSOLSafeDir() const { return _solsandbox; }
-
     /// Get the URL opener command format
     //
     /// The %u label will need to be substituted by the actual url
@@ -153,6 +152,9 @@
         return _urlOpenerFormat;
     }
 
+    // Get the location of the sandbox for .sol files
+    const std::string &getSOLSafeDir() const { return _solsandbox; }
+
     // Set the location of the sandbox for .sol files
     void setSOLSafeDir(std::string &x) { _solsandbox = x; }
 
@@ -251,6 +253,10 @@
     bool _lcdisabled;
     bool _lctrace;
     key_t _lcshmkey;
+
+    // A function only for writing lists to an outstream.
+    void writeList(std::vector<std::string>& list, std::ostream& o);
+
 protected:
     
     /// Construct only by getDefaultInstance()




reply via email to

[Prev in Thread] Current Thread [Next in Thread]