From cbb2ecff453755e249fa08671b7747ea2068a5a9 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 20 Aug 2008 08:25:30 +0000 Subject: [PATCH] Appends a License dialog in case of using "--useLicense" flag in application command line. --- src/SUITApp/SUITApp.cxx | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/SUITApp/SUITApp.cxx b/src/SUITApp/SUITApp.cxx index 3e0f483d6..28bda860d 100644 --- a/src/SUITApp/SUITApp.cxx +++ b/src/SUITApp/SUITApp.cxx @@ -32,6 +32,7 @@ #include #include +#include #ifdef SUIT_ENABLE_PYTHON #include #endif @@ -44,6 +45,10 @@ #include +#ifdef WIN32 +#include +#endif + static QString salomeVersion() { QString path( ::getenv( "GUI_ROOT_DIR" ) ); @@ -167,6 +172,7 @@ int main( int args, char* argv[] ) bool noExceptHandling = false; bool iniFormat = false; bool noSplash = false; + bool useLicense = false; for ( int i = 1; i < args /*&& !noExceptHandling*/; i++ ) { if ( !strcmp( argv[i], "--noexcepthandling" ) ) @@ -175,13 +181,41 @@ int main( int args, char* argv[] ) iniFormat = true; else if ( !strcmp( argv[i], "--nosplash") ) noSplash = true; - else + else if ( !strcmp( argv[i], "--uselicense" ) ) + useLicense = true; + else argList.append( QString( argv[i] ) ); } SUITApp_Application app( args, argv ); int result = -1; + + if ( useLicense ) { + QString env; + +#ifdef WIN32 + DWORD aLen=1024; + char aStr[1024]; + HANDLE aToken=0; + HANDLE hProcess = GetCurrentProcess(); + OpenProcessToken(hProcess,TOKEN_QUERY,&aToken); + if( GetUserProfileDirectory( aToken, aStr, &aLen ) ) + env = aStr; + +#else + if ( ::getenv( "HOME" ) ) + env = ::getenv( "HOME" ); +#endif + + QFile file( env + "/ReadLicense.log" ); // Read the text from a file + if( !file.exists() ) { + SUIT_LicenseDlg aLicense; + if ( aLicense.exec() != QDialog::Accepted ) + return result; + } + } + if ( !argList.isEmpty() ) { SUITApp_Session* aSession = new SUITApp_Session( iniFormat ); -- 2.39.2