Gnash 0.8.10dev
|
00001 // rc.h: "Run Command" configuration file declarations, for Gnash. 00002 // 00003 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 00004 // 2011 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 00162 // 00164 void setBlacklist (const std::vector<std::string>& list) { 00165 _blacklist = list; 00166 } 00167 00169 // 00173 const PathList& getLocalSandboxPath() const { return _localSandboxPath; } 00174 00176 void addLocalSandboxPath(const std::string& dir) 00177 { 00178 _localSandboxPath.push_back(dir); 00179 } 00180 00184 // 00186 void setLocalSandboxPath(const PathList& path) 00187 { 00188 _localSandboxPath = path; 00189 } 00190 00191 const std::string& getFlashVersionString() const { 00192 return _flashVersionString; 00193 } 00194 00195 void setFlashVersionString(const std::string& value) { 00196 _flashVersionString = value; 00197 } 00198 00199 const std::string& getFlashSystemOS() const { 00200 return _flashSystemOS; 00201 } 00202 00203 void setFlashSystemOS(const std::string& value) { 00204 _flashSystemOS = value; 00205 } 00206 00207 const std::string& getFlashSystemManufacturer() const { 00208 return _flashSystemManufacturer; 00209 } 00210 00211 void setFlashSystemManufacturer(const std::string& value) { 00212 _flashSystemManufacturer = value; 00213 } 00214 00215 const std::string& getGstAudioSink() const { return _gstaudiosink; } 00216 00217 void setGstAudioSink(const std::string& value) { _gstaudiosink = value; } 00218 00219 int getRetries() const { return _retries; } 00220 00221 void setRetries(int x) { _retries = x; } 00222 00224 double getStreamsTimeout() const { return _streamsTimeout; } 00225 00227 void setStreamsTimeout(const double &x) { _streamsTimeout = x; } 00228 00230 // 00234 const std::string &getURLOpenerFormat() const 00235 { 00236 return _urlOpenerFormat; 00237 } 00238 00239 void setURLOpenerFormat(const std::string& value) 00240 { 00241 _urlOpenerFormat = value; 00242 } 00243 00244 // Get the name of the hardware acclerator to use for video 00245 const std::string &getHWAccel() const { return _hwaccel; } 00246 00247 // Set the name of the hardware acclerator to use for video 00248 void setHWAccel(const std::string &x) { _hwaccel = x; } 00249 00250 // Get the name of the renderer to draw the display 00251 const std::string& getRenderer() const { return _renderer; } 00252 00253 // Set the name of the renderer to draw the display 00254 void setRenderer(const std::string& x) { _renderer = x; } 00255 00256 // Get the name of the media handler to use for video/audio 00257 const std::string& getMediaHandler() const { return _mediahandler; } 00258 00259 // Set the name of the media handler to use for video/audio 00260 void setMediaHandler(const std::string& x) { _mediahandler = x; } 00261 00262 // Get the location of the sandbox for .sol files 00263 const std::string &getSOLSafeDir() const { return _solsandbox; } 00264 00265 // Set the location of the sandbox for .sol files 00266 void setSOLSafeDir(const std::string &x) { _solsandbox = x; } 00267 00268 bool getSOLLocalDomain() const { return _sollocaldomain; } 00269 00270 void setSOLLocalDomain(bool x) { _sollocaldomain = x; } 00271 00272 bool getSOLReadOnly() const { return _solreadonly; } 00273 00274 void setSOLReadOnly(bool x) { _solreadonly = x; } 00275 00276 bool getLocalConnection() const { return _lcdisabled; } 00277 00278 void setLocalConnection(bool x) { _lcdisabled = x; } 00279 00281 bool getLCTrace() const { return _lctrace; } 00282 00283 void setLCTrace(bool x) { _lctrace = x; } 00284 00285 key_t getLCShmKey() const { return static_cast<key_t>(_lcshmkey); } 00286 00287 void setLCShmKey(bool x) { _lcshmkey = x; } 00288 00289 bool ignoreFSCommand() const { return _ignoreFSCommand; } 00290 00291 void ignoreFSCommand(bool value) { _ignoreFSCommand = value; } 00292 00293 void saveStreamingMedia(bool value) { _saveStreamingMedia = value; } 00294 00295 bool saveStreamingMedia() const { return _saveStreamingMedia; } 00296 00297 void saveLoadedMedia(bool value) { _saveLoadedMedia = value; } 00298 00299 bool saveLoadedMedia() const { return _saveLoadedMedia; } 00300 00301 void setMediaDir(const std::string& value) { _mediaCacheDir = value; } 00302 00303 const std::string& getMediaDir() const { return _mediaCacheDir; } 00304 00305 void setWebcamDevice(int value) {_webcamDevice = value;} 00306 00307 int getWebcamDevice() const {return _webcamDevice;} 00308 00309 void setAudioInputDevice(int value) {_microphoneDevice = value;} 00310 00311 int getAudioInputDevice() {return _microphoneDevice;} 00312 00314 const std::string& getRootCert() const { 00315 return _rootcert; 00316 } 00318 void setRootCert(const std::string& value) { 00319 _rootcert = value; 00320 } 00321 00323 const std::string& getCertFile() const { 00324 return _certfile; 00325 } 00327 void setCertFile(const std::string& value) { 00328 _certfile = value; 00329 } 00330 00332 const std::string& getCertDir() const { 00333 return _certdir; 00334 } 00336 void setCertDir(const std::string& value) { 00337 _certdir = value; 00338 } 00339 00340 void ignoreShowMenu(bool value) { _ignoreShowMenu=value; } 00341 00342 bool ignoreShowMenu() const { return _ignoreShowMenu; } 00343 00344 int getScriptsTimeout() const { return _scriptsTimeout; } 00345 00346 void setScriptsTimeout(int x) { _scriptsTimeout = x; } 00347 00348 int getScriptsRecursionLimit() const { return _scriptsRecursionLimit; } 00349 00350 void setScriptsRecursionLimit(int x) { _scriptsRecursionLimit = x; } 00351 00352 void lockScriptLimits(bool x) { _lockScriptLimits = x; } 00353 00354 bool lockScriptLimits() const { return _lockScriptLimits; } 00355 00356 void dump(); 00357 00358 protected: 00359 00360 // A function only for writing path lists to an outstream. 00361 void writeList(const PathList& list, std::ostream& o); 00362 00364 RcInitFile(); 00365 00367 ~RcInitFile(); 00368 00373 static void expandPath(std::string& path); 00374 00378 // 00384 static bool extractSetting(bool &var, const std::string& pattern, 00385 const std::string &variable, const std::string &value); 00386 00390 // 00396 template<typename T> 00397 static bool extractNumber(T& num, const std::string& pattern, 00398 const std::string &variable, const std::string &value) 00399 { 00400 00401 StringNoCaseEqual noCaseCompare; 00402 00403 if (noCaseCompare(variable, pattern)) { 00404 std::istringstream in(value); 00405 if (in >> num) return true; 00406 00407 num = 0; 00408 return true; 00409 } 00410 00411 return false; 00412 } 00413 00417 // 00423 static bool extractDouble(double &out, const std::string& pattern, 00424 const std::string &variable, const std::string &value); 00425 00426 00428 // 00433 void parseList(std::vector<std::string>& list, const std::string &action, 00434 const std::string &items); 00435 00436 typedef boost::char_separator<char> Sep; 00437 typedef boost::tokenizer< Sep > Tok; 00438 00440 boost::uint32_t _delay; 00441 00443 boost::uint32_t _movieLibraryLimit; 00444 00446 bool _debug; 00447 00449 bool _debugger; 00450 00452 boost::uint32_t _verbosity; 00453 00455 // 00459 std::string _urlOpenerFormat; 00460 00462 std::string _flashVersionString; 00463 00465 std::string _gstaudiosink; 00466 00470 std::string _flashSystemOS; 00471 00475 std::string _flashSystemManufacturer; 00476 00478 bool _actionDump; 00479 00481 bool _parserDump; 00482 00484 bool _verboseASCodingErrors; 00485 00487 bool _verboseMalformedSWF; 00488 00490 bool _verboseMalformedAMF; 00491 00493 bool _splashScreen; 00494 00496 bool _localdomainOnly; 00497 00499 bool _localhostOnly; 00500 00502 PathList _whitelist; 00503 00505 PathList _blacklist; 00506 00508 std::string _log; 00509 00511 bool _writeLog; 00512 00514 std::string _wwwroot; 00515 00517 int _retries; 00518 00520 bool _sound; 00521 00523 bool _pluginSound; 00524 00526 bool _extensionsEnabled; 00527 00529 bool _startStopped; 00530 00532 bool _insecureSSL; 00533 00535 double _streamsTimeout; 00536 00539 PathList _localSandboxPath; 00540 00543 std::string _solsandbox; 00544 00546 bool _solreadonly; 00547 bool _sollocaldomain; 00548 00549 // Disable local connection 00550 bool _lcdisabled; 00551 00553 bool _lctrace; 00554 00557 boost::uint32_t _lcshmkey; 00558 00561 bool _ignoreFSCommand; 00562 00564 int _quality; 00565 00566 bool _saveStreamingMedia; 00567 00568 bool _saveLoadedMedia; 00569 00570 std::string _mediaCacheDir; 00571 00572 bool _popups; 00573 00574 bool _useXv; 00575 00578 int _webcamDevice; 00579 00580 int _microphoneDevice; 00581 00584 std::string _certfile; 00585 00588 std::string _certdir; 00589 00592 std::string _rootcert; 00593 00596 bool _ignoreShowMenu; 00597 00601 std::string _hwaccel; 00602 00606 std::string _renderer; 00607 00610 std::string _mediahandler; 00611 00614 int _scriptsTimeout; 00615 00617 int _scriptsRecursionLimit; 00618 00620 bool _lockScriptLimits; 00621 }; 00622 00623 // End of gnash namespace 00624 } 00625 00626 #endif 00627 00628 00629 // local Variables: 00630 // mode: C++ 00631 // indent-tabs-mode: t 00632 // End: