DEV-43948 viewer2 is writing session data into the 'read-only' installation tree (mostly media stuff)

propagate the parent app's OSUserAppDir (i.e. ~/.secondlife/) all the way down to plugins, if they need persistant user data/settings (like the webkit plugin needs a place to put its cache).
master
Tofu Linden 2009-12-09 12:57:10 -08:00
parent 15fbfa5ae1
commit 197de032e1
8 changed files with 29 additions and 14 deletions

View File

@ -63,14 +63,15 @@ LLPluginClassMedia::~LLPluginClassMedia()
reset();
}
bool LLPluginClassMedia::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug)
bool LLPluginClassMedia::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug, const std::string &user_data_path)
{
LL_DEBUGS("Plugin") << "launcher: " << launcher_filename << LL_ENDL;
LL_DEBUGS("Plugin") << "plugin: " << plugin_filename << LL_ENDL;
LL_DEBUGS("Plugin") << "user_data_path: " << user_data_path << LL_ENDL;
mPlugin = new LLPluginProcessParent(this);
mPlugin->setSleepTime(mSleepTime);
mPlugin->init(launcher_filename, plugin_filename, debug);
mPlugin->init(launcher_filename, plugin_filename, debug, user_data_path);
return true;
}

View File

@ -49,7 +49,7 @@ public:
virtual ~LLPluginClassMedia();
// local initialization, called by the media manager when creating a source
virtual bool init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug = false);
virtual bool init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug, const std::string &user_data_path);
// undoes everything init() didm called by the media manager when destroying a source
virtual void reset();

View File

@ -145,8 +145,12 @@ void LLPluginProcessChild::idle(void)
break;
case STATE_PLUGIN_LOADED:
setState(STATE_PLUGIN_INITIALIZING);
sendMessageToPlugin(LLPluginMessage("base", "init"));
{
setState(STATE_PLUGIN_INITIALIZING);
LLPluginMessage message("base", "init");
message.setValue("user_data_path", mUserDataPath);
sendMessageToPlugin(message);
}
break;
case STATE_PLUGIN_INITIALIZING:
@ -310,6 +314,7 @@ void LLPluginProcessChild::receiveMessageRaw(const std::string &message)
if(message_name == "load_plugin")
{
mPluginFile = parsed.getValue("file");
mUserDataPath = parsed.getValue("user_data_path");
}
else if(message_name == "shm_add")
{

View File

@ -96,6 +96,8 @@ private:
LLSocket::ptr_t mSocket;
std::string mPluginFile;
std::string mUserDataPath;
LLPluginInstance *mInstance;

View File

@ -99,12 +99,13 @@ void LLPluginProcessParent::errorState(void)
setState(STATE_ERROR);
}
void LLPluginProcessParent::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug)
void LLPluginProcessParent::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug, const std::string &user_data_path)
{
mProcess.setExecutable(launcher_filename);
mPluginFile = plugin_filename;
mCPUUsage = 0.0f;
mDebug = debug;
mUserDataPath = user_data_path;
setState(STATE_INITIALIZED);
}
@ -362,6 +363,7 @@ void LLPluginProcessParent::idle(void)
{
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "load_plugin");
message.setValue("file", mPluginFile);
message.setValue("user_data_path", mUserDataPath);
sendMessage(message);
}

View File

@ -58,7 +58,7 @@ public:
LLPluginProcessParent(LLPluginProcessParentOwner *owner);
~LLPluginProcessParent();
void init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug = false);
void init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug, const std::string &user_data_path);
void idle(void);
// returns true if the plugin is on its way to steady state
@ -139,6 +139,8 @@ private:
std::string mPluginFile;
std::string mUserDataPath;
LLPluginProcessParentOwner *mOwner;
typedef std::map<std::string, LLPluginSharedMemory*> sharedMemoryRegionsType;

View File

@ -76,6 +76,8 @@ public:
private:
std::string mProfileDir;
enum
{
INIT_STATE_UNINITIALIZED, // Browser instance hasn't been set up yet
@ -187,7 +189,6 @@ private:
#else
std::string component_dir = application_dir;
#endif
std::string profileDir = application_dir + "/" + "browser_profile"; // cross platform?
// window handle - needed on Windows and must be app window.
#if LL_WINDOWS
@ -199,7 +200,7 @@ private:
#endif
// main browser initialization
bool result = LLQtWebKit::getInstance()->init( application_dir, component_dir, profileDir, native_window_handle );
bool result = LLQtWebKit::getInstance()->init( application_dir, component_dir, mProfileDir, native_window_handle );
if ( result )
{
// create single browser window
@ -576,7 +577,7 @@ MediaPluginWebKit::~MediaPluginWebKit()
void MediaPluginWebKit::receiveMessage(const char *message_string)
{
// std::cerr << "MediaPluginWebKit::receiveMessage: received message: \"" << message_string << "\"" << std::endl;
std::cerr << "MediaPluginWebKit::receiveMessage: received message: \"" << message_string << "\"" << std::endl;
LLPluginMessage message_in;
if(message_in.parse(message_string) >= 0)
@ -587,6 +588,9 @@ void MediaPluginWebKit::receiveMessage(const char *message_string)
{
if(message_name == "init")
{
std::string user_data_path = message_in.getValue("user_data_path"); // n.b. always has trailing platform-specific dir-delimiter
mProfileDir = user_data_path + "browser_profile";
LLPluginMessage message("base", "init_response");
LLSD versions = LLSD::emptyMap();
versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION;

View File

@ -988,11 +988,10 @@ LLPluginClassMedia* LLViewerMediaImpl::newSourceFromMediaType(std::string media_
}
else
{
std::string plugins_path = gDirUtilp->getLLPluginDir();
plugins_path += gDirUtilp->getDirDelimiter();
std::string launcher_name = gDirUtilp->getLLPluginLauncher();
std::string plugin_name = gDirUtilp->getLLPluginFilename(plugin_basename);
std::string user_data_path = gDirUtilp->getOSUserAppDir();
user_data_path += gDirUtilp->getDirDelimiter();
// See if the plugin executable exists
llstat s;
@ -1008,7 +1007,7 @@ LLPluginClassMedia* LLViewerMediaImpl::newSourceFromMediaType(std::string media_
{
LLPluginClassMedia* media_source = new LLPluginClassMedia(owner);
media_source->setSize(default_width, default_height);
if (media_source->init(launcher_name, plugin_name, gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins")))
if (media_source->init(launcher_name, plugin_name, gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins"), user_data_path))
{
return media_source;
}