find_host

This commit is contained in:
David Rose 2009-10-07 22:43:24 +00:00
parent 6c6f498ebb
commit 10f5d804be
3 changed files with 46 additions and 22 deletions

View File

@ -19,6 +19,13 @@ from pandac.PandaModules import getModelPath, Filename, ConfigVariableFilename
# Also see panda3d.pdef.
packager.setHost('file:///c:/cygwin/home/drose/p3dstage',
downloadUrl = 'file:///c:/cygwin/home/drose/p3dstage_1',
mirrors = ['file:///c:/cygwin/home/drose/mirror1',
'file:///c:/cygwin/home/drose/mirror2',
'http://www.ddrose.com/~drose/mirror3',
'http://www.ddrose.com/~drose/mirror4'])
class coreapi(solo):
# The special "coreapi" package. As a "solo", this is just a
# single .dll (or dylib, or whatever).

View File

@ -162,28 +162,7 @@ read_contents_file(const string &contents_filename) {
if (xcontents != NULL) {
// Look for the <host> entry; it might point us at a different
// download URL, and it might mention some mirrors.
string host_url = PANDA_PACKAGE_HOST_URL;
TiXmlElement *xhost = xcontents->FirstChildElement("host");
if (xhost != NULL) {
const char *url = xhost->Attribute("url");
if (url != NULL && host_url == string(url)) {
// We're the primary host. This is the normal case.
read_xhost(xhost);
} else {
// We're not the primary host; perhaps we're an alternate host.
TiXmlElement *xalthost = xhost->FirstChildElement("alt_host");
while (xalthost != NULL) {
const char *url = xalthost->Attribute("url");
if (url != NULL && host_url == string(url)) {
// Yep, we're this alternate host.
read_xhost(xhost);
break;
}
xalthost = xalthost->NextSiblingElement("alt_host");
}
}
}
find_host(xcontents);
// Now look for the core API package.
TiXmlElement *xpackage = xcontents->FirstChildElement("package");
@ -207,6 +186,43 @@ read_contents_file(const string &contents_filename) {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: PPInstance::find_host
// Access: Private
// Description: Scans the <contents> element for the matching <host>
// element.
////////////////////////////////////////////////////////////////////
void PPInstance::
find_host(TiXmlElement *xcontents) {
string host_url = PANDA_PACKAGE_HOST_URL;
TiXmlElement *xhost = xcontents->FirstChildElement("host");
if (xhost != NULL) {
const char *url = xhost->Attribute("url");
if (url != NULL && host_url == string(url)) {
// We're the primary host. This is the normal case.
read_xhost(xhost);
return;
} else {
// We're not the primary host; perhaps we're an alternate host.
TiXmlElement *xalthost = xhost->FirstChildElement("alt_host");
while (xalthost != NULL) {
const char *url = xalthost->Attribute("url");
if (url != NULL && host_url == string(url)) {
// Yep, we're this alternate host.
read_xhost(xhost);
return;
}
xalthost = xalthost->NextSiblingElement("alt_host");
}
}
// Hmm, didn't find the URL we used mentioned. Assume we're the
// primary host.
read_xhost(xhost);
}
}
////////////////////////////////////////////////////////////////////
// Function: PPInstance::read_xhost
// Access: Private

View File

@ -72,6 +72,7 @@ protected:
int CopyFile( const std::string& from, const std::string& to );
bool read_contents_file(const std::string &contents_filename);
void find_host(TiXmlElement *xcontents);
void read_xhost(TiXmlElement *xhost);
void add_mirror(std::string mirror_url);
void choose_random_mirrors(std::vector<std::string> &result, int num_mirrors);