• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

rc.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00003 //   Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef GNASH_RC_H
00020 #define GNASH_RC_H
00021 
00022 #include "dsodefs.h"
00023 #include "StringPredicates.h"
00024 
00025 #include <string>
00026 #include <vector>
00027 #include <iostream>
00028 #include <sstream>
00029 #include <boost/cstdint.hpp>
00030 #include <boost/tokenizer.hpp>
00031 
00032 #if !defined(_WIN32) && !defined(__HAIKU__) && !defined(_ANDROID)
00033 #include <sys/shm.h>
00034 #else
00035 #ifdef _WIN32
00036   typedef boost::uint32_t key_t;
00037 #endif // _WIN32
00038 #endif // _WIN32 and __HAIKU__
00039 
00040 namespace gnash {
00041   
00042 class DSOEXPORT RcInitFile 
00043 {
00044 public:
00045 
00047     static RcInitFile& getDefaultInstance();
00048 
00050     //
00051     void loadFiles();
00052 
00053     bool parseFile(const std::string& filespec);
00054 
00058     //
00061     bool updateFile(const std::string& filespec);
00062     
00066     //
00068     bool updateFile();
00069     
00070     bool useSplashScreen() const { return _splashScreen; }
00071     void useSplashScreen(bool value);
00072 
00073     bool useActionDump() const { return _actionDump; }
00074     void useActionDump(bool value);
00075 
00076     bool useParserDump() const { return _parserDump; }
00077     void useParserDump(bool value);
00078 
00079     bool useWriteLog() const { return _writeLog; }
00080     void useWriteLog(bool value);
00081 
00082     int getTimerDelay() const { return _delay; }
00083     void setTimerDelay(int x) { _delay = x; }
00084 
00085     bool showASCodingErrors() const { return _verboseASCodingErrors; }
00086     void showASCodingErrors(bool value);
00087 
00088     bool showMalformedSWFErrors() const { return _verboseMalformedSWF; }
00089     void showMalformedSWFErrors(bool value);
00090 
00091     bool showMalformedAMFErrors() const { return _verboseMalformedAMF; }
00092     void showMalformedAMFErrors(bool value);
00093 
00094     int getMovieLibraryLimit() const { return _movieLibraryLimit; }
00095     void setMovieLibraryLimit(int value) { _movieLibraryLimit = value; }
00096 
00097     bool enableExtensions() const { return _extensionsEnabled; }
00098 
00100     //
00102     bool startStopped() const { return _startStopped; }
00103     void startStopped(bool value) { _startStopped = value; }
00104 
00105     bool insecureSSL() const { return _insecureSSL; }
00106     void insecureSSL(bool value) { _insecureSSL = value; }
00107     
00108     int qualityLevel() const { return _quality; }
00109     void qualityLevel(int value) { _quality = value; }
00110     
00111     int verbosityLevel() const { return _verbosity; }
00112     void verbosityLevel(int value) { _verbosity = value; }
00113     
00114     void setDebugLog(const std::string &x) { _log = x; }
00115     const std::string& getDebugLog() const { return _log; }
00116 
00117     void setDocumentRoot(const std::string &x) { _wwwroot = x; }
00118     std::string getDocumentRoot() { return _wwwroot; }
00119     
00120     bool useDebugger() const { return _debugger; }
00121     void useDebugger(bool value) { _debugger = value; }
00122 
00123     bool useSound() const { return _sound; }
00124     void useSound(bool value) { _sound = value; }
00125 
00126     // strk: I'd drop this, and allow an -f switch to select
00127     //       the gnashrc file to use instead
00128     bool usePluginSound() const { return _pluginSound; }
00129     void usePluginSound(bool value) { _pluginSound = value; }
00130 
00131     bool popupMessages() const { return _popups; }
00132     void interfacePopups(bool value) { _popups = value; }
00133 
00134     bool useLocalDomain() const { return _localdomainOnly; }
00135     void useLocalDomain(bool value);
00136 
00138     bool useLocalHost() const { return _localhostOnly; }
00139 
00141     void useLocalHost(bool value);
00142 
00143     typedef std::vector<std::string> PathList;
00144 
00146     //
00148     const PathList& getWhiteList() const { return _whitelist; }
00149 
00151     //
00153     void setWhitelist (const std::vector<std::string>& list) { _whitelist = list; }
00154 
00156     //
00158     const PathList& getBlackList() const { return _blacklist; }
00159     
00161     //
00163     void setBlacklist (const std::vector<std::string>& list) { 
00164         _blacklist = list;
00165     }
00166 
00168     //
00172     const PathList& getLocalSandboxPath() const { return _localSandboxPath; }
00173 
00175     void addLocalSandboxPath(const std::string& dir)
00176     {
00177         _localSandboxPath.push_back(dir);
00178     }
00179 
00183     //
00185     void setLocalSandboxPath(const PathList& path)
00186     {
00187         _localSandboxPath = path;
00188     }
00189 
00190     const std::string& getFlashVersionString() const {
00191         return _flashVersionString;
00192     }
00193     
00194     void setFlashVersionString(const std::string& value) {
00195         _flashVersionString = value;
00196     }
00197 
00198     const std::string& getFlashSystemOS() const {
00199         return _flashSystemOS;
00200     }
00201     
00202     void setFlashSystemOS(const std::string& value) {
00203         _flashSystemOS = value;
00204     }
00205 
00206     const std::string& getFlashSystemManufacturer() const {
00207         return _flashSystemManufacturer;
00208     }
00209     
00210     void setFlashSystemManufacturer(const std::string& value) {
00211         _flashSystemManufacturer = value;
00212     }
00213     
00214     const std::string& getGstAudioSink() const { return _gstaudiosink; }
00215     
00216     void setGstAudioSink(const std::string& value) { _gstaudiosink = value; }
00217 
00218     int getRetries() const { return _retries; }
00219     
00220     void setRetries(int x) { _retries = x; }
00221 
00223     double getStreamsTimeout() const { return _streamsTimeout; }
00224 
00226     void setStreamsTimeout(const double &x) { _streamsTimeout = x; }
00227 
00229     //
00233     const std::string &getURLOpenerFormat() const
00234     {
00235         return _urlOpenerFormat;
00236     }
00237     
00238     void setURLOpenerFormat(const std::string& value)
00239     {
00240         _urlOpenerFormat = value;
00241     }
00242  
00243     // Get the name of the hardware acclerator to use for video
00244     const std::string &getHWAccel() const { return _hwaccel; }
00245 
00246     // Set the name of the hardware acclerator to use for video
00247     void setHWAccel(const std::string &x) { _hwaccel = x; }
00248 
00249     // Get the name of the hardware acclerator to use for video
00250     const std::string& getRenderer() const { return _renderer; }
00251 
00252     // Set the name of the hardware acclerator to use for video
00253     void setRenderer(const std::string& x) { _renderer = x; }
00254 
00255     // Get the location of the sandbox for .sol files
00256     const std::string &getSOLSafeDir() const { return _solsandbox; }
00257 
00258     // Set the location of the sandbox for .sol files
00259     void setSOLSafeDir(const std::string &x) { _solsandbox = x; }
00260 
00261     bool getSOLLocalDomain() const { return _sollocaldomain; }
00262     
00263     void setSOLLocalDomain(bool x) { _sollocaldomain = x; }
00264     
00265     bool getSOLReadOnly() const { return _solreadonly; }
00266     
00267     void setSOLReadOnly(bool x) { _solreadonly = x; }
00268     
00269     bool getLocalConnection() const { return _lcdisabled; }
00270     
00271     void setLocalConnection(bool x) { _lcdisabled = x; }
00272     
00274     bool getLCTrace() const { return _lctrace; }
00275     
00276     void setLCTrace(bool x) { _lctrace = x; }
00277 
00278     key_t getLCShmKey() const { return static_cast<key_t>(_lcshmkey); }
00279     
00280     void setLCShmKey(bool x) { _lcshmkey = x; }
00281 
00282     bool ignoreFSCommand() const { return _ignoreFSCommand; }
00283     
00284     void ignoreFSCommand(bool value) { _ignoreFSCommand = value; }
00285     
00286     void saveStreamingMedia(bool value) { _saveStreamingMedia = value; }
00287 
00288     bool saveStreamingMedia() const { return _saveStreamingMedia; }
00289 
00290     void saveLoadedMedia(bool value) { _saveLoadedMedia = value; }
00291 
00292     bool saveLoadedMedia() const { return _saveLoadedMedia; }
00293 
00294     void setMediaDir(const std::string& value) { _mediaCacheDir = value; }
00295 
00296     const std::string& getMediaDir() const { return _mediaCacheDir; }
00297         
00298     void setWebcamDevice(int value) {_webcamDevice = value;}
00299     
00300     int getWebcamDevice() const {return _webcamDevice;}
00301     
00302     void setAudioInputDevice(int value) {_microphoneDevice = value;}
00303     
00304     int getAudioInputDevice() {return _microphoneDevice;}
00305 
00307     const std::string& getRootCert() const {
00308         return _rootcert;
00309     }
00311     void setRootCert(const std::string& value) {
00312         _rootcert = value;
00313     }
00314 
00316     const std::string& getCertFile() const {
00317         return _certfile;
00318     }
00320     void setCertFile(const std::string& value) {
00321         _certfile = value;
00322     }
00323 
00325     const std::string& getCertDir() const {
00326         return _certdir;
00327     }
00329     void setCertDir(const std::string& value) {
00330         _certdir = value;
00331     }
00332 
00333     void ignoreShowMenu(bool value) { _ignoreShowMenu= value; }
00334 
00335     bool ignoreShowMenu() const { return _ignoreShowMenu; }
00336 
00337     void dump();    
00338 
00339 protected:
00340     
00341     // A function only for writing path lists to an outstream.
00342     void writeList(const PathList& list, std::ostream& o);
00343 
00345     RcInitFile();
00346 
00348     ~RcInitFile();
00349 
00354     static void expandPath(std::string& path);
00355 
00359     //
00365     static bool extractSetting(bool &var, const std::string& pattern,
00366                         const std::string &variable, const std::string &value);
00367 
00371     //
00377     template<typename T>
00378     static bool extractNumber(T& num, const std::string& pattern,
00379                         const std::string &variable, const std::string &value)
00380     {
00381 
00382         StringNoCaseEqual noCaseCompare;
00383 
00384         if (noCaseCompare(variable, pattern)) {
00385             std::istringstream in(value);
00386             if (in >> num) return true;
00387             
00388             // If conversion fails, set value to 0 rather than leaving
00389             // it as the default.
00390             std::cerr << "Conversion overflow in extractNumber: " << 
00391                 value << std::endl;
00392             num = 0;
00393             return true;
00394         }
00395         
00396         return false;
00397     }
00398 
00402     //
00408     static bool extractDouble(double &out, const std::string& pattern,
00409                         const std::string &variable, const std::string &value);
00410 
00411 
00413     //
00418     void parseList(std::vector<std::string>& list, const std::string &action,
00419                                 const std::string &items);
00420 
00421     typedef boost::char_separator<char> Sep;
00422     typedef boost::tokenizer< Sep > Tok;
00423 
00425     boost::uint32_t  _delay;
00426 
00428     boost::uint32_t  _movieLibraryLimit;   
00429 
00431     bool _debug;
00432 
00434     bool _debugger;
00435 
00437     boost::uint32_t  _verbosity;
00438 
00440     //
00444     std::string  _urlOpenerFormat;
00445 
00447     std::string  _flashVersionString;
00448     
00450     std::string _gstaudiosink;
00451 
00455     std::string  _flashSystemOS;       
00456 
00460     std::string  _flashSystemManufacturer;
00461 
00463     bool _actionDump;
00464 
00466     bool _parserDump;
00467 
00469     bool _verboseASCodingErrors;
00470 
00472     bool _verboseMalformedSWF;
00473 
00475     bool _verboseMalformedAMF;
00476 
00478     bool _splashScreen;
00479 
00481     bool _localdomainOnly;
00482     
00484     bool _localhostOnly;
00485     
00487     PathList _whitelist;
00488     
00490     PathList _blacklist;
00491     
00493     std::string _log;
00494     
00496     bool _writeLog;
00497     
00499     std::string _wwwroot;
00500     
00502     int _retries;
00503     
00505     bool _sound;
00506     
00508     bool _pluginSound;          
00509 
00511     bool _extensionsEnabled;    
00512 
00514     bool _startStopped;         
00515 
00517     bool _insecureSSL;          
00518 
00520     double _streamsTimeout;
00521 
00524     PathList _localSandboxPath;
00525 
00528     std::string _solsandbox;
00529 
00531     bool _solreadonly;
00532     bool _sollocaldomain;
00533     
00534     // Disable local connection
00535     bool _lcdisabled;
00536     
00538     bool _lctrace;
00539     
00542     boost::uint32_t _lcshmkey;
00543     
00546     bool _ignoreFSCommand;
00547 
00549     int _quality;
00550 
00551     bool _saveStreamingMedia;
00552     
00553     bool _saveLoadedMedia;
00554 
00555     std::string _mediaCacheDir;
00556 
00557     bool _popups;
00558 
00559     bool _useXv;
00560         
00563     int _webcamDevice;
00564     
00565     int _microphoneDevice;
00566 
00569     std::string _certfile;
00570 
00573     std::string _certdir;
00574 
00577     std::string _rootcert;
00578 
00581     bool _ignoreShowMenu;
00582 
00586     std::string _hwaccel;
00587 
00591     std::string _renderer;
00592 };
00593 
00594 // End of gnash namespace 
00595 }
00596 
00597 #endif
00598 
00599 
00600 // local Variables:
00601 // mode: C++
00602 // indent-tabs-mode: t
00603 // End:

Generated on Fri Mar 16 2012 15:46:11 for Gnash by  doxygen 1.7.1