diff --git a/examples/osgvnc/osgvnc.cpp b/examples/osgvnc/osgvnc.cpp index c02794338..a286b59b0 100644 --- a/examples/osgvnc/osgvnc.cpp +++ b/examples/osgvnc/osgvnc.cpp @@ -1,5 +1,6 @@ #include +#include #include #include @@ -46,10 +47,23 @@ int main(int argc,char** argv) osg::ref_ptr group = new osg::Group; + std::string password; + while(arguments.read("--password",password)) + { + } + for(int i=1; igetAuthenticationMap()) osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap); + osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(hostname, new osgDB::AuthenticationDetails("", password)); + } + osg::ref_ptr vncClient = new osgWidget::VncClient; if (vncClient->connect(arguments[i], hints)) { diff --git a/src/osgPlugins/vnc/ReaderWriterVNC.cpp b/src/osgPlugins/vnc/ReaderWriterVNC.cpp index 55cf4eabd..581d20bd1 100644 --- a/src/osgPlugins/vnc/ReaderWriterVNC.cpp +++ b/src/osgPlugins/vnc/ReaderWriterVNC.cpp @@ -49,6 +49,11 @@ class LibVncImage : public osgWidget::VncImage static void updateImage(rfbClient* client,int x,int y,int w,int h); + static void passwordCheck(rfbClient* client,const char* encryptedPassWord,int len); + static char* getPassword(rfbClient* client); + + std::string _username; + std::string _password; double _timeOfLastUpdate; double _timeOfLastRender; @@ -137,7 +142,6 @@ LibVncImage::LibVncImage(): // setPixelBufferObject(new osg::PixelBufferObject(this); _inactiveBlock = new osg::RefBlock; - } LibVncImage::~LibVncImage() @@ -197,6 +201,18 @@ static rfbBool rfbInitConnection(rfbClient* client) return TRUE; } +void LibVncImage::passwordCheck(rfbClient* client,const char* encryptedPassWord,int len) +{ + OSG_NOTICE<<"LibVncImage::passwordCheck"<_password<_password.c_str()); +} + bool LibVncImage::connect(const std::string& hostname) { @@ -211,6 +227,9 @@ bool LibVncImage::connect(const std::string& hostname) _client->HandleKeyboardLedState = 0; _client->HandleTextChat = 0; + // provide the password if we have one assigned + if (!_password.empty()) _client->GetPassword = getPassword; + rfbClientSetClientData(_client, 0, this); _client->serverHost = strdup(hostname.c_str()); @@ -267,7 +286,13 @@ rfbBool LibVncImage::resizeImage(rfbClient* client) OSG_NOTICE<<"resize "<