Browse Source

respect passed-in hostUrl

David Rose 16 years ago
parent
commit
217580661d

+ 4 - 9
direct/src/plugin/p3dInstance.cxx

@@ -96,8 +96,8 @@ P3DInstance(P3D_request_ready_func *func,
   _has_log_basename = false;
   _has_log_basename = false;
   _hidden = (_fparams.lookup_token_int("hidden") != 0);
   _hidden = (_fparams.lookup_token_int("hidden") != 0);
   _allow_python_dev = false;
   _allow_python_dev = false;
-  _keep_user_env = false;
-  _auto_start = false;
+  _keep_user_env = (_fparams.lookup_token_int("keep_user_env") != 0);
+  _auto_start = (_fparams.lookup_token_int("auto_start") != 0);
   _auth_button_approved = false;
   _auth_button_approved = false;
   _failed = false;
   _failed = false;
   _session = NULL;
   _session = NULL;
@@ -174,7 +174,7 @@ P3DInstance(P3D_request_ready_func *func,
   // it eventually, and it's good to have it loaded early, so we can
   // it eventually, and it's good to have it loaded early, so we can
   // put up a splash image (for instance, the above IT_download image)
   // put up a splash image (for instance, the above IT_download image)
   // while we download the real contents.
   // while we download the real contents.
-  P3DHost *host = inst_mgr->get_host(PANDA_PACKAGE_HOST_URL);
+  P3DHost *host = inst_mgr->get_host(inst_mgr->get_host_url());
   _image_package = host->get_package("images", "");
   _image_package = host->get_package("images", "");
   if (_image_package != NULL) {
   if (_image_package != NULL) {
     _image_package->add_instance(this);
     _image_package->add_instance(this);
@@ -1261,7 +1261,7 @@ mark_p3d_untrusted() {
   if (_p3dcert_package == NULL) {
   if (_p3dcert_package == NULL) {
     // We have to go download this package.
     // We have to go download this package.
     P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
     P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
-    P3DHost *host = inst_mgr->get_host(PANDA_PACKAGE_HOST_URL);
+    P3DHost *host = inst_mgr->get_host(inst_mgr->get_host_url());
     _p3dcert_package = host->get_package("p3dcert", "");
     _p3dcert_package = host->get_package("p3dcert", "");
     if (_p3dcert_package != NULL) {
     if (_p3dcert_package != NULL) {
       _p3dcert_package->add_instance(this);
       _p3dcert_package->add_instance(this);
@@ -1395,11 +1395,6 @@ scan_app_desc_file(TiXmlDocument *doc) {
     }
     }
   }
   }
 
 
-  // auto_start is true if it is set in the application itself, or in
-  // the web tokens.
-  if (_fparams.lookup_token_int("auto_start") != 0) {
-    _auto_start = true;
-  }
   if (_auth_button_approved) {
   if (_auth_button_approved) {
     // But finally, if the user has already clicked through the red
     // But finally, if the user has already clicked through the red
     // "auth" button, no need to present him/her with another green
     // "auth" button, no need to present him/her with another green

+ 19 - 1
direct/src/plugin/p3dInstanceManager.I

@@ -51,6 +51,22 @@ reset_verify_contents() {
 }
 }
 
 
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: P3DInstanceManager::get_host_url
+//       Access: Public
+//  Description: Returns the standard host_url which the instances
+//               should attempt to contact to download auxiliary
+//               packages associated with the core API, such as the
+//               p3dcert and images packages.  This is normally the
+//               compiled-in PANDA_PACKAGE_HOST_URL, but it might be
+//               set to something different by the -u parameter on the
+//               panda3d executable.
+////////////////////////////////////////////////////////////////////
+inline const string &P3DInstanceManager::
+get_host_url() const {
+  return _host_url;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: P3DInstanceManager::get_root_dir
 //     Function: P3DInstanceManager::get_root_dir
 //       Access: Public
 //       Access: Public
@@ -212,7 +228,9 @@ get_plugin_distributor() const {
 //     Function: P3DInstanceManager::get_coreapi_host_url
 //     Function: P3DInstanceManager::get_coreapi_host_url
 //       Access: Public
 //       Access: Public
 //  Description: Returns the host URL from which this Core API was
 //  Description: Returns the host URL from which this Core API was
-//               downloaded (according to the plugin).
+//               downloaded (according to the plugin).  This is for
+//               reporting purposes only; see get_host_url() for the
+//               URL to contact to actually download content.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 inline const string &P3DInstanceManager::
 inline const string &P3DInstanceManager::
 get_coreapi_host_url() const {
 get_coreapi_host_url() const {

+ 5 - 0
direct/src/plugin/p3dInstanceManager.cxx

@@ -189,6 +189,11 @@ initialize(const string &contents_filename, const string &host_url,
     _platform = DTOOL_PLATFORM;
     _platform = DTOOL_PLATFORM;
   }
   }
 
 
+  _host_url = host_url;
+  if (_host_url.empty()) {
+    _host_url = PANDA_PACKAGE_HOST_URL;
+  }
+
   _root_dir = find_root_dir();
   _root_dir = find_root_dir();
 
 
   // Allow the caller (e.g. panda3d.exe) to specify a log directory.
   // Allow the caller (e.g. panda3d.exe) to specify a log directory.

+ 2 - 0
direct/src/plugin/p3dInstanceManager.h

@@ -62,6 +62,7 @@ public:
   inline bool get_verify_contents() const;
   inline bool get_verify_contents() const;
   inline void reset_verify_contents();
   inline void reset_verify_contents();
 
 
+  inline const string &get_host_url() const;
   inline const string &get_root_dir() const;
   inline const string &get_root_dir() const;
   inline const string &get_platform() const;
   inline const string &get_platform() const;
   inline const string &get_temp_directory() const;
   inline const string &get_temp_directory() const;
@@ -139,6 +140,7 @@ private:
 
 
 private:
 private:
   bool _is_initialized;
   bool _is_initialized;
+  string _host_url;
   string _root_dir;
   string _root_dir;
   string _certs_dir;
   string _certs_dir;
   bool _verify_contents;
   bool _verify_contents;