Salome HOME
Copyright update 2022
[modules/gui.git] / src / SUIT / SUIT_LicenseDlg.cxx
old mode 100755 (executable)
new mode 100644 (file)
index e2c15f5..9b8a92a
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -25,6 +25,7 @@
 #include <QPushButton>
 #include <QTextStream> 
 #include <QFile>
+#include <QDir>
 #include <QPrinter>
 //#include <QSimpleRichText>
 #include <QTextDocument>
@@ -32,6 +33,8 @@
 
 #include <math.h>
 
+#include <Qtx.h>
+
 #ifdef WIN32
 #include <UserEnv.h>
 #endif
@@ -47,10 +50,7 @@ SUIT_LicenseDlg::SUIT_LicenseDlg( bool firstShow, QWidget* parent, const char* n
 {
   setObjectName( name );
   setModal( modal );
-  QString env;
-  if ( ::getenv( "SALOME_LICENSE_FILE" ) )
-    env = ::getenv( "SALOME_LICENSE_FILE" );
+  QString env = Qtx::getenv( "SALOME_LICENSE_FILE" ); 
   QFile file( env ); // Read the text from a file
   
   if ( !file.exists() || !file.open( QIODevice::ReadOnly ) )
@@ -116,17 +116,21 @@ SUIT_LicenseDlg::~SUIT_LicenseDlg()
 
 void SUIT_LicenseDlg::onAgree()
 {
+  /*
   QString env;
 #ifdef WIN32
-    DWORD aLen=1024;
-  char aStr[1024];
+  DWORD aLen=1024;
+  TCHAR aStr[1024];
   HANDLE aToken=0;
   HANDLE hProcess = GetCurrentProcess();
   OpenProcessToken(hProcess,TOKEN_QUERY,&aToken);
   if( ! GetUserProfileDirectory( aToken, aStr, &aLen ) )
     reject();
-
+#ifdef UNICODE
+  env = QString::fromWCharArray(aStr);
+#else 
   env = aStr;
+#endif
 #else
   if( ! ::getenv( "HOME" ) )
     reject();
@@ -136,6 +140,11 @@ void SUIT_LicenseDlg::onAgree()
   QFile file( env + "/ReadLicense.log" ); // Read the text from a file
 
   file.open( QIODevice::WriteOnly );
+  */
+  QString env = QDir::homePath();
+  QFile file( env + "/ReadLicense.log" );
+  if (!file.open( QIODevice::WriteOnly ))
+    reject();
 
   QTextStream ts( &file );
   ts << "OK" << endl;