[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnash-dev] [PATCH] User-specific tmp directory and auto-removal of
From: |
Takashi Iwai |
Subject: |
Re: [Gnash-dev] [PATCH] User-specific tmp directory and auto-removal of swf files |
Date: |
Thu, 24 Aug 2006 16:48:25 +0200 |
User-agent: |
Wanderlust/2.12.0 (Your Wildest Dreams) SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (Sanjō) APEL/10.6 MULE XEmacs/21.5 (beta25) (eggplant) (+CVS-20060326) (i386-suse-linux) |
At Wed, 23 Aug 2006 20:00:08 +0200,
I wrote:
>
> At Wed, 23 Aug 2006 09:53:02 -0600,
> Rob Savoye wrote:
> >
> > Takashi Iwai wrote:
> >
> >
> > Btw, there is already support for a ~/.gnashrc file, you'd just have
> > to add the support for the additional config setting, since it has to
> > get parsed out of the file.
>
> OK, will check it.
The below is a newer version. ~/.gnashtmp is used as default for the
temporary directory, and files are removed automatically.
Can be tuned via gnashrc now.
Takashi
--- libbase/rc.cpp-dist 2006-08-24 13:31:43.000000000 +0200
+++ libbase/rc.cpp 2006-08-24 16:36:30.000000000 +0200
@@ -71,7 +71,10 @@
_parserdump(false),
_splash_screen(true),
_localdomain_only(false),
- _localhost_only(false)
+ _localhost_only(false),
+ _auto_delete_swf(true),
+ _tmp_swf_dir("~/.gnashtmp"),
+ _loaded(false)
{
// GNASH_REPORT_FUNCTION;
// loadFiles();
@@ -84,12 +87,16 @@
// Look for a config file in the likely places.
bool
-RcInitFile::loadFiles()
+RcInitFile::loadFiles(bool force)
{
// GNASH_REPORT_FUNCTION;
char *home;
string loadfile;
+ if (_loaded && ! force)
+ return false;
+
+ _loaded = true;
// Check the default system location
loadfile = "/etc/gnashrc";
parseFile(loadfile);
@@ -197,6 +204,11 @@
_wwwroot = value;
}
+ extractSetting(&_auto_delete_swf, "auto_delete_swf", variable,
value);
+ if (variable == "tmp_swf_dir") {
+ _tmp_swf_dir = value;
+ }
+
if (variable == "blacklist") {
string::size_type pos;
while ((pos = value.find(':', 0)) != string::npos) {
--- libbase/rc.h-dist 2006-08-24 13:32:05.000000000 +0200
+++ libbase/rc.h 2006-08-24 16:35:34.000000000 +0200
@@ -53,7 +53,7 @@ public:
RcInitFile();
~RcInitFile();
- bool loadFiles();
+ bool loadFiles(bool force = false);
bool parseFile(std::string filespec);
bool updateFile(std::string filespec);
@@ -96,9 +96,13 @@ public:
std::vector<std::string> getWhiteList() { return _whitelist; };
std::vector<std::string> getBlackList() { return _blacklist; };
+ bool autoDeleteSwf() { return _auto_delete_swf; }
+ std::string tmpSwfDir() { return _tmp_swf_dir; }
+
void dump();
private:
+ bool _loaded; // already loaded?
int _delay; // the timer delay
bool _debug; // enable debugging of this class
bool _debugger; // enable the Flash movie debugger
@@ -118,6 +122,10 @@ private:
std::string _log; // the name of the debug log
bool _writelog; // enable writing the debug log to disk
std::string _wwwroot; // the root path for the streaming server
+
+ // Plugin Behavior
+ bool _auto_delete_swf; // delete downloaded swf files at closing
+ std::string _tmp_swf_dir; // temporary directory to download swf files
};
extern RcInitFile rcfile;
--- plugin/plugin.cpp-dist 2006-08-16 14:40:30.000000000 +0200
+++ plugin/plugin.cpp 2006-08-24 16:34:25.000000000 +0200
@@ -40,6 +40,7 @@
#endif
#include "plugin.h"
+#include "rc.h"
#define MIME_TYPES_HANDLED "application/x-shockwave-flash"
// The name must be this value to get flash movies that check the
@@ -357,6 +358,9 @@
}
_childpid = 0;
+
+ if (rcfile.autoDeleteSwf())
+ unlink(_swf_file.c_str());
}
/// \brief Set the window to be used to render in
@@ -416,6 +420,20 @@
return WriteStatus( const_cast<char*>(msg.c_str()) );
}
+static void replace_marks(std::string& fname, const std::string& mark,
+ const std::string& val)
+{
+ size_t pos = 0;
+ size_t mark_len = mark.length();
+ size_t val_len = val.length();
+ while ((pos = fname.find(mark, pos)) != std::string::npos) {
+ fname.erase(pos, mark_len);
+ fname.insert(pos, val);
+ pos += val_len;
+ }
+}
+
+
/// \brief Open a new data stream
///
/// Opens a new incoming data stream, which is the flash movie we want
@@ -442,7 +460,26 @@
end = url.find(".swf", 0) + 4;
start = url.rfind("/", end) + 1;
- fname = "/tmp/";
+
+ rcfile.loadFiles();
+
+ fname = rcfile.tmpSwfDir();
+ if ((fname[0] == '~' && fname[1] == '/') && getenv("HOME")) {
+ fname.erase(0, 1);
+ fname.insert(0, getenv("HOME"));
+ }
+ if (getlogin())
+ replace_marks(fname, "%U", getlogin());
+ replace_marks(fname, "%%", "%");
+
+ if (access(fname.c_str(), R_OK|W_OK|X_OK)) {
+ if (mkdir(fname.c_str(), S_IRWXU)) {
+ WriteStatus(string("Can't create a temporary directory: ") + fname);
+ dbglogfile << "ERROR: Can't create a temporary directory: " <<
fname << endl;
+ return NPERR_INVALID_PARAM;
+ }
+ }
+ fname += "/";
fname += url.substr(start, end - start);
// extract the parameters from the URL
Re: [Gnash-dev] [PATCH] User-specific tmp directory and auto-removal of swf files, strk, 2006/08/23