modified present3D to allow multiple --login arguments like osgViewer, added --login option to osgvnc example

This commit is contained in:
Laurens Voerman 2017-10-12 17:21:10 +02:00
parent adb6ae849d
commit 99491e46ec
2 changed files with 22 additions and 11 deletions

View File

@ -336,14 +336,10 @@ int main( int argc, char **argv )
std::string url, username, password;
while(arguments.read("--login",url, username, password))
{
if (!osgDB::Registry::instance()->getAuthenticationMap())
{
osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(
url,
new osgDB::AuthenticationDetails(username, password)
);
}
osgDB::Registry::instance()->getOrCreateAuthenticationMap()->addAuthenticationDetails(
url,
new osgDB::AuthenticationDetails(username, password)
);
}

View File

@ -37,7 +37,9 @@ class EscapeHandler : public osgGA::GUIEventHandler
int main(int argc,char** argv)
{
osg::ArgumentParser arguments(&argc, argv);
osgViewer::Viewer viewer(arguments);
arguments.getApplicationUsage()->addCommandLineOption("--login <url> <username> <password>", "Provide authentication information for http file access.");
arguments.getApplicationUsage()->addCommandLineOption("--password <password>", "Provide password for any vnc url on command line not mentioned in --login.");
osgViewer::Viewer viewer(arguments);
osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
osg::Vec3(1.0f,0.0f,0.0f),
@ -52,6 +54,15 @@ int main(int argc,char** argv)
{
}
std::string url, username, password;
while (arguments.read("--login", url, username, password))
{
osgDB::Registry::instance()->getOrCreateAuthenticationMap()->addAuthenticationDetails(
url,
new osgDB::AuthenticationDetails(username, password)
);
}
for(int i=1; i<arguments.argc(); ++i)
{
if (!arguments.isOption(i))
@ -60,8 +71,12 @@ int main(int argc,char** argv)
if (!password.empty())
{
if (!osgDB::Registry::instance()->getAuthenticationMap()) osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(hostname, new osgDB::AuthenticationDetails("", password));
const osgDB::AuthenticationMap* authenticationMap = osgDB::Registry::instance()->getOrCreateAuthenticationMap();
const osgDB::AuthenticationDetails* details = authenticationMap->getAuthenticationDetails(hostname);
if (details == NULL)
{
authenticationMap->addAuthenticationDetails(hostname, new osgDB::AuthenticationDetails("", password));
}
}
osg::ref_ptr<osgWidget::VncClient> vncClient = new osgWidget::VncClient;