Gnash  0.8.10
rc.h
Go to the documentation of this file.
00001 // rc.h:  "Run Command" configuration file declarations, for Gnash.
00002 // 
00003 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00004 //   Free Software Foundation, Inc
00005 // 
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 3 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 #ifndef GNASH_RC_H
00021 #define GNASH_RC_H
00022 
00023 #include "dsodefs.h"
00024 #include <string>
00025 #include <vector>
00026 #include <iosfwd>
00027 #include <sstream>
00028 #include <boost/cstdint.hpp>
00029 #include <boost/tokenizer.hpp>
00030 
00031 #include "StringPredicates.h"
00032 
00033 #if !defined(_WIN32) && !defined(__HAIKU__) && !defined(ANDROID)
00034 #include <sys/shm.h>
00035 #else
00036 #ifdef _WIN32
00037   typedef boost::uint32_t key_t;
00038 #endif // _WIN32
00039 #endif // _WIN32 and __HAIKU__
00040 
00041 namespace gnash {
00042   
00043 class DSOEXPORT RcInitFile 
00044 {
00045 public:
00046 
00048     static RcInitFile& getDefaultInstance();
00049 
00051     //
00052     void loadFiles();
00053 
00054     bool parseFile(const std::string& filespec);
00055 
00059     //
00062     bool updateFile(const std::string& filespec);
00063     
00067     //
00069     bool updateFile();
00070     
00071     bool useSplashScreen() const { return _splashScreen; }
00072     void useSplashScreen(bool value);
00073 
00074     bool useActionDump() const { return _actionDump; }
00075     void useActionDump(bool value);
00076 
00077     bool useParserDump() const { return _parserDump; }
00078     void useParserDump(bool value);
00079 
00080     bool useWriteLog() const { return _writeLog; }
00081     void useWriteLog(bool value);
00082 
00083     int getTimerDelay() const { return _delay; }
00084     void setTimerDelay(int x) { _delay = x; }
00085 
00086     bool showASCodingErrors() const { return _verboseASCodingErrors; }
00087     void showASCodingErrors(bool value);
00088 
00089     bool showMalformedSWFErrors() const { return _verboseMalformedSWF; }
00090     void showMalformedSWFErrors(bool value);
00091 
00092     bool showMalformedAMFErrors() const { return _verboseMalformedAMF; }
00093     void showMalformedAMFErrors(bool value);
00094 
00095     int getMovieLibraryLimit() const { return _movieLibraryLimit; }
00096     void setMovieLibraryLimit(int value) { _movieLibraryLimit = value; }
00097 
00098     bool enableExtensions() const { return _extensionsEnabled; }
00099 
00101     //
00103     bool startStopped() const { return _startStopped; }
00104     void startStopped(bool value) { _startStopped = value; }
00105 
00106     bool insecureSSL() const { return _insecureSSL; }
00107     void insecureSSL(bool value) { _insecureSSL = value; }
00108     
00109     int qualityLevel() const { return _quality; }
00110     void qualityLevel(int value) { _quality = value; }
00111     
00112     int verbosityLevel() const { return _verbosity; }
00113     void verbosityLevel(int value) { _verbosity = value; }
00114     
00115     void setDebugLog(const std::string &x) { _log = x; }
00116     const std::string& getDebugLog() const { return _log; }
00117 
00118     void setDocumentRoot(const std::string &x) { _wwwroot = x; }
00119     std::string getDocumentRoot() { return _wwwroot; }
00120     
00121     bool useDebugger() const { return _debugger; }
00122     void useDebugger(bool value) { _debugger = value; }
00123 
00124     bool useSound() const { return _sound; }
00125     void useSound(bool value) { _sound = value; }
00126 
00127     // strk: I'd drop this, and allow an -f switch to select
00128     //       the gnashrc file to use instead
00129     bool usePluginSound() const { return _pluginSound; }
00130     void usePluginSound(bool value) { _pluginSound = value; }
00131 
00132     bool popupMessages() const { return _popups; }
00133     void interfacePopups(bool value) { _popups = value; }
00134 
00135     bool useLocalDomain() const { return _localdomainOnly; }
00136     void useLocalDomain(bool value);
00137 
00139     bool useLocalHost() const { return _localhostOnly; }
00140 
00142     void useLocalHost(bool value);
00143 
00144     typedef std::vector<std::string> PathList;
00145 
00147     //
00149     const PathList& getWhiteList() const { return _whitelist; }
00150 
00152     //
00154     void setWhitelist (const std::vector<std::string>& list) { _whitelist = list; }
00155 
00157     //
00159     const PathList& getBlackList() const { return _blacklist; }
00160 
00164     bool showMouse() const { return _showMouse; }
00165     
00167     //
00169     void setBlacklist (const std::vector<std::string>& list) { 
00170         _blacklist = list;
00171     }
00172 
00174     //
00178     const PathList& getLocalSandboxPath() const { return _localSandboxPath; }
00179 
00181     void addLocalSandboxPath(const std::string& dir)
00182     {
00183         _localSandboxPath.push_back(dir);
00184     }
00185 
00189     //
00191     void setLocalSandboxPath(const PathList& path)
00192     {
00193         _localSandboxPath = path;
00194     }
00195 
00196     const std::string& getFlashVersionString() const {
00197         return _flashVersionString;
00198     }
00199     
00200     void setFlashVersionString(const std::string& value) {
00201         _flashVersionString = value;
00202     }
00203 
00204     const std::string& getFlashSystemOS() const {
00205         return _flashSystemOS;
00206     }
00207     
00208     void setFlashSystemOS(const std::string& value) {
00209         _flashSystemOS = value;
00210     }
00211 
00212     const std::string& getFlashSystemManufacturer() const {
00213         return _flashSystemManufacturer;
00214     }
00215     
00216     void setFlashSystemManufacturer(const std::string& value) {
00217         _flashSystemManufacturer = value;
00218     }
00219     
00220     const std::string& getGstAudioSink() const { return _gstaudiosink; }
00221     
00222     void setGstAudioSink(const std::string& value) { _gstaudiosink = value; }
00223 
00224     int getRetries() const { return _retries; }
00225     
00226     void setRetries(int x) { _retries = x; }
00227 
00229     double getStreamsTimeout() const { return _streamsTimeout; }
00230 
00232     void setStreamsTimeout(const double &x) { _streamsTimeout = x; }
00233 
00235     //
00239     const std::string &getURLOpenerFormat() const
00240     {
00241         return _urlOpenerFormat;
00242     }
00243     
00244     void setURLOpenerFormat(const std::string& value)
00245     {
00246         _urlOpenerFormat = value;
00247     }
00248  
00249     // Get the name of the hardware acclerator to use for video
00250     const std::string &getHWAccel() const { return _hwaccel; }
00251 
00252     // Set the name of the hardware acclerator to use for video
00253     void setHWAccel(const std::string &x) { _hwaccel = x; }
00254 
00255     // Get the name of the renderer to draw the display
00256     const std::string& getRenderer() const { return _renderer; }
00257 
00258     // Set the name of the renderer to draw the display
00259     void setRenderer(const std::string& x) { _renderer = x; }
00260 
00261     // Get the name of the media handler to use for video/audio
00262     const std::string& getMediaHandler() const { return _mediahandler; }
00263 
00264     // Set the name of the media handler to use for video/audio
00265     void setMediaHandler(const std::string& x) { _mediahandler = x; }
00266 
00267     // Get the location of the sandbox for .sol files
00268     const std::string &getSOLSafeDir() const { return _solsandbox; }
00269 
00270     // Set the location of the sandbox for .sol files
00271     void setSOLSafeDir(const std::string &x) { _solsandbox = x; }
00272 
00273     bool getSOLLocalDomain() const { return _sollocaldomain; }
00274     
00275     void setSOLLocalDomain(bool x) { _sollocaldomain = x; }
00276     
00277     bool getSOLReadOnly() const { return _solreadonly; }
00278     
00279     void setSOLReadOnly(bool x) { _solreadonly = x; }
00280     
00281     bool getLocalConnection() const { return _lcdisabled; }
00282     
00283     void setLocalConnection(bool x) { _lcdisabled = x; }
00284     
00286     bool getLCTrace() const { return _lctrace; }
00287     
00288     void setLCTrace(bool x) { _lctrace = x; }
00289 
00290     key_t getLCShmKey() const { return static_cast<key_t>(_lcshmkey); }
00291     
00292     void setLCShmKey(bool x) { _lcshmkey = x; }
00293 
00294     bool ignoreFSCommand() const { return _ignoreFSCommand; }
00295     
00296     void ignoreFSCommand(bool value) { _ignoreFSCommand = value; }
00297     
00298     void saveStreamingMedia(bool value) { _saveStreamingMedia = value; }
00299 
00300     bool saveStreamingMedia() const { return _saveStreamingMedia; }
00301 
00302     void saveLoadedMedia(bool value) { _saveLoadedMedia = value; }
00303 
00304     bool saveLoadedMedia() const { return _saveLoadedMedia; }
00305 
00306     void setMediaDir(const std::string& value) { _mediaCacheDir = value; }
00307 
00308     const std::string& getMediaDir() const { return _mediaCacheDir; }
00309         
00310     void setWebcamDevice(int value) {_webcamDevice = value;}
00311     
00312     int getWebcamDevice() const {return _webcamDevice;}
00313     
00314     void setAudioInputDevice(int value) {_microphoneDevice = value;}
00315     
00316     int getAudioInputDevice() {return _microphoneDevice;}
00317 
00319     const std::string& getRootCert() const {
00320         return _rootcert;
00321     }
00323     void setRootCert(const std::string& value) {
00324         _rootcert = value;
00325     }
00326 
00328     const std::string& getCertFile() const {
00329         return _certfile;
00330     }
00332     void setCertFile(const std::string& value) {
00333         _certfile = value;
00334     }
00335 
00337     const std::string& getCertDir() const {
00338         return _certdir;
00339     }
00341     void setCertDir(const std::string& value) {
00342         _certdir = value;
00343     }
00344 
00345     void ignoreShowMenu(bool value) { _ignoreShowMenu=value; }
00346 
00347     bool ignoreShowMenu() const { return _ignoreShowMenu; }
00348 
00349     int getScriptsTimeout() const { return _scriptsTimeout; }
00350 
00351     void setScriptsTimeout(int x) { _scriptsTimeout = x; }
00352 
00353     int getScriptsRecursionLimit() const { return _scriptsRecursionLimit; }
00354 
00355     void setScriptsRecursionLimit(int x) { _scriptsRecursionLimit = x; }
00356 
00357     void lockScriptLimits(bool x) { _lockScriptLimits = x; }
00358 
00359     bool lockScriptLimits() const { return _lockScriptLimits; }
00360 
00361     void dump();    
00362 
00363 protected:
00364     
00365     // A function only for writing path lists to an outstream.
00366     void writeList(const PathList& list, std::ostream& o);
00367 
00369     RcInitFile();
00370 
00372     ~RcInitFile();
00373 
00378     static void expandPath(std::string& path);
00379 
00383     //
00389     static bool extractSetting(bool &var, const std::string& pattern,
00390                         const std::string &variable, const std::string &value);
00391 
00395     //
00401     template<typename T>
00402     static bool extractNumber(T& num, const std::string& pattern,
00403                         const std::string &variable, const std::string &value)
00404     {
00405 
00406         StringNoCaseEqual noCaseCompare;
00407 
00408         if (noCaseCompare(variable, pattern)) {
00409             std::istringstream in(value);
00410             if (in >> num) return true;
00411             
00412             num = 0;
00413             return true;
00414         }
00415         
00416         return false;
00417     }
00418 
00422     //
00428     static bool extractDouble(double &out, const std::string& pattern,
00429                         const std::string &variable, const std::string &value);
00430 
00431 
00433     //
00438     void parseList(std::vector<std::string>& list, const std::string &action,
00439                                 const std::string &items);
00440 
00441     typedef boost::char_separator<char> Sep;
00442     typedef boost::tokenizer< Sep > Tok;
00443 
00445     boost::uint32_t  _delay;
00446 
00448     boost::uint32_t  _movieLibraryLimit;   
00449 
00451     bool _debug;
00452 
00454     bool _debugger;
00455 
00457     boost::uint32_t  _verbosity;
00458 
00460     //
00464     std::string  _urlOpenerFormat;
00465 
00467     std::string  _flashVersionString;
00468     
00470     std::string _gstaudiosink;
00471 
00475     std::string  _flashSystemOS;       
00476 
00480     std::string  _flashSystemManufacturer;
00481 
00483     bool _actionDump;
00484 
00486     bool _parserDump;
00487 
00489     bool _verboseASCodingErrors;
00490 
00492     bool _verboseMalformedSWF;
00493 
00495     bool _verboseMalformedAMF;
00496 
00498     bool _splashScreen;
00499 
00501     bool _localdomainOnly;
00502     
00504     bool _localhostOnly;
00505 
00507     bool _showMouse;
00508 
00510     PathList _whitelist;
00511     
00513     PathList _blacklist;
00514     
00516     std::string _log;
00517     
00519     bool _writeLog;
00520     
00522     std::string _wwwroot;
00523     
00525     int _retries;
00526     
00528     bool _sound;
00529     
00531     bool _pluginSound;          
00532 
00534     bool _extensionsEnabled;    
00535 
00537     bool _startStopped;         
00538 
00540     bool _insecureSSL;          
00541 
00543     double _streamsTimeout;
00544 
00547     PathList _localSandboxPath;
00548 
00551     std::string _solsandbox;
00552 
00554     bool _solreadonly;
00555     bool _sollocaldomain;
00556     
00557     // Disable local connection
00558     bool _lcdisabled;
00559     
00561     bool _lctrace;
00562     
00565     boost::uint32_t _lcshmkey;
00566     
00569     bool _ignoreFSCommand;
00570 
00572     int _quality;
00573 
00574     bool _saveStreamingMedia;
00575     
00576     bool _saveLoadedMedia;
00577 
00578     std::string _mediaCacheDir;
00579 
00580     bool _popups;
00581 
00582     bool _useXv;
00583         
00586     int _webcamDevice;
00587     
00588     int _microphoneDevice;
00589 
00592     std::string _certfile;
00593 
00596     std::string _certdir;
00597 
00600     std::string _rootcert;
00601 
00604     bool _ignoreShowMenu;
00605 
00609     std::string _hwaccel;
00610 
00614     std::string _renderer;
00615 
00618     std::string _mediahandler;
00619 
00622     int _scriptsTimeout;
00623 
00625     int _scriptsRecursionLimit;
00626 
00628     bool _lockScriptLimits;
00629 };
00630 
00631 // End of gnash namespace 
00632 }
00633 
00634 #endif
00635 
00636 
00637 // local Variables:
00638 // mode: C++
00639 // indent-tabs-mode: t
00640 // End: