diff --git a/direct/src/p3d/AppRunner.py b/direct/src/p3d/AppRunner.py index d09fef72ae..25fd97a8f8 100644 --- a/direct/src/p3d/AppRunner.py +++ b/direct/src/p3d/AppRunner.py @@ -111,6 +111,8 @@ class AppRunner(DirectObject): self.packedAppEnvironmentInitialized = False self.gotWindow = False self.gotP3DFilename = False + self.p3dFilename = None + self.p3dUrl = None self.started = False self.windowOpened = False self.windowPrc = None @@ -872,7 +874,7 @@ class AppRunner(DirectObject): initAppForGui() def setP3DFilename(self, p3dFilename, tokens, argv, instanceId, - interactiveConsole, p3dOffset = 0): + interactiveConsole, p3dOffset, p3dUrl): """ Called by the browser to specify the p3d file that contains the application itself, along with the web tokens and/or command-line arguments. Once this method has been @@ -913,6 +915,7 @@ class AppRunner(DirectObject): raise ArgumentError, "No such file: %s" % (p3dFilename) fname.makeAbsolute() + fname.setBinary() mf = Multifile() if p3dOffset == 0: if not mf.openRead(fname): @@ -976,6 +979,13 @@ class AppRunner(DirectObject): self.loadMultifilePrcFiles(mf, self.multifileRoot) self.gotP3DFilename = True + self.p3dFilename = fname + if p3dUrl: + # The url from which the p3d file was downloaded is + # provided if available. It is only for documentation + # purposes; the actual p3d file has already been + # downloaded to p3dFilename. + self.p3dUrl = PandaModules.URLSpec(p3dUrl) # Send this call to the main thread; don't call it directly. messenger.send('AppRunner_startIfReady', taskChain = 'default') diff --git a/direct/src/plugin/p3dFileParams.I b/direct/src/plugin/p3dFileParams.I index 30177fd7eb..d3c9a41858 100644 --- a/direct/src/plugin/p3dFileParams.I +++ b/direct/src/plugin/p3dFileParams.I @@ -16,8 +16,8 @@ //////////////////////////////////////////////////////////////////// // Function: P3DFileParams::get_p3d_filename // Access: Public -// Description: Returns the p3d filename that was passed to the -// constructor. +// Description: Returns the filename that was passed to +// set_p3d_filename(). //////////////////////////////////////////////////////////////////// inline const string &P3DFileParams:: get_p3d_filename() const { @@ -35,6 +35,16 @@ get_p3d_offset() const { return _p3d_offset; } +//////////////////////////////////////////////////////////////////// +// Function: P3DFileParams::get_p3d_url +// Access: Public +// Description: Returns the string that was passed to set_p3d_url(). +//////////////////////////////////////////////////////////////////// +inline const string &P3DFileParams:: +get_p3d_url() const { + return _p3d_url; +} + //////////////////////////////////////////////////////////////////// // Function: P3DFileParams::get_num_tokens // Access: Public diff --git a/direct/src/plugin/p3dFileParams.cxx b/direct/src/plugin/p3dFileParams.cxx index decb00b280..3507463dc6 100644 --- a/direct/src/plugin/p3dFileParams.cxx +++ b/direct/src/plugin/p3dFileParams.cxx @@ -33,6 +33,7 @@ P3DFileParams:: P3DFileParams(const P3DFileParams ©) : _p3d_filename(copy._p3d_filename), _p3d_offset(copy._p3d_offset), + _p3d_url(copy._p3d_url), _tokens(copy._tokens), _args(copy._args) { @@ -47,6 +48,7 @@ void P3DFileParams:: operator = (const P3DFileParams &other) { _p3d_filename = other._p3d_filename; _p3d_offset = other._p3d_offset; + _p3d_url = other._p3d_url; _tokens = other._tokens; _args = other._args; } @@ -62,7 +64,7 @@ set_p3d_filename(const string &p3d_filename) { } //////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::set_p3d_filename +// Function: P3DFileParams::set_p3d_offset // Access: Public // Description: Specifies the location in the file where // the p3d file data starts. @@ -72,6 +74,18 @@ set_p3d_offset(const int &p3d_offset) { _p3d_offset = p3d_offset; } +//////////////////////////////////////////////////////////////////// +// Function: P3DFileParams::set_p3d_url +// Access: Public +// Description: Specifies the original URL that hosted the p3d file, +// if any. This is for documentation purposes only; it +// is communicated to the child Panda3D process. +//////////////////////////////////////////////////////////////////// +void P3DFileParams:: +set_p3d_url(const string &p3d_url) { + _p3d_url = p3d_url; +} + //////////////////////////////////////////////////////////////////// // Function: P3DFileParams::set_tokens // Access: Public @@ -179,6 +193,7 @@ make_xml() { xfparams->SetAttribute("p3d_filename", _p3d_filename); xfparams->SetAttribute("p3d_offset", _p3d_offset); + xfparams->SetAttribute("p3d_url", _p3d_url); Tokens::const_iterator ti; for (ti = _tokens.begin(); ti != _tokens.end(); ++ti) { diff --git a/direct/src/plugin/p3dFileParams.h b/direct/src/plugin/p3dFileParams.h index f1cf5a2475..2c486d33b4 100644 --- a/direct/src/plugin/p3dFileParams.h +++ b/direct/src/plugin/p3dFileParams.h @@ -32,11 +32,13 @@ public: void set_p3d_filename(const string &p3d_filename); void set_p3d_offset(const int &p3d_offset); + void set_p3d_url(const string &p3d_url); void set_tokens(const P3D_token tokens[], size_t num_tokens); void set_args(int argc, const char *argv[]); inline const string &get_p3d_filename() const; inline int get_p3d_offset() const; + inline const string &get_p3d_url() const; string lookup_token(const string &keyword) const; int lookup_token_int(const string &keyword) const; bool has_token(const string &keyword) const; @@ -58,6 +60,7 @@ private: string _p3d_filename; int _p3d_offset; + string _p3d_url; Tokens _tokens; Args _args; }; diff --git a/direct/src/plugin/p3dInstance.cxx b/direct/src/plugin/p3dInstance.cxx index 912dc12278..d5adf324c2 100644 --- a/direct/src/plugin/p3dInstance.cxx +++ b/direct/src/plugin/p3dInstance.cxx @@ -228,6 +228,8 @@ P3DInstance(P3D_request_ready_func *func, _main_object->set_string_property("coreapiTimestampString", timestamp_string); _main_object->set_string_property("coreapiVersionString", inst_mgr->get_coreapi_set_ver()); + _main_object->set_bool_property("trustedEnvironment", (int)inst_mgr->get_trusted_environment()); + _main_object->set_bool_property("consoleEnvironment", (int)inst_mgr->get_console_environment()); // We'll start off with the "download" image displayed in the splash // window (when it opens), until we get stuff downloaded. @@ -409,6 +411,7 @@ set_p3d_url(const string &p3d_url) { set_failed(); return; } + _fparams.set_p3d_url(p3d_url); // Save the last part of the URL as the p3d_basename, for reporting // purposes or whatever. @@ -452,6 +455,8 @@ set_p3d_url(const string &p3d_url) { //////////////////////////////////////////////////////////////////// int P3DInstance:: make_p3d_stream(const string &p3d_url) { + _fparams.set_p3d_url(p3d_url); + // Save the last part of the URL as the p3d_basename, for reporting // purposes or whatever. determine_p3d_basename(p3d_url); diff --git a/direct/src/plugin/p3dPythonRun.cxx b/direct/src/plugin/p3dPythonRun.cxx index 6443aa7ba1..5bd3c7508a 100755 --- a/direct/src/plugin/p3dPythonRun.cxx +++ b/direct/src/plugin/p3dPythonRun.cxx @@ -1324,6 +1324,12 @@ set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) { int p3d_offset = 0; xfparams->Attribute("p3d_offset", &p3d_offset); + string p3d_url; + const char *p3d_url_c = xfparams->Attribute("p3d_url"); + if (p3d_url_c != NULL) { + p3d_url = p3d_url_c; + } + PyObject *token_list = PyList_New(0); TiXmlElement *xtoken = xfparams->FirstChildElement("token"); while (xtoken != NULL) { @@ -1363,8 +1369,9 @@ set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) { } PyObject *result = PyObject_CallMethod - (_runner, (char *)"setP3DFilename", (char *)"sOOiii", p3d_filename.c_str(), - token_list, arg_list, inst->get_instance_id(), _interactive_console, p3d_offset); + (_runner, (char *)"setP3DFilename", (char *)"sOOiiis", p3d_filename.c_str(), + token_list, arg_list, inst->get_instance_id(), _interactive_console, p3d_offset, + p3d_url.c_str()); Py_DECREF(token_list); Py_DECREF(arg_list);