Kaydet (Commit) 5d83153b authored tarafından Jens-Heiner Rechtien's avatar Jens-Heiner Rechtien

INTEGRATION: CWS jl13 (1.3.2); FILE MERGED

2004/11/04 15:51:32 jl 1.3.2.4: #i36674#
2004/10/26 12:54:02 jl 1.3.2.3: #i29390#
2004/09/20 10:08:52 jl 1.3.2.2: #i34388# an JRE whith an unknown version, such as 1.4.2_06-ea, caused that no JREs were displayed in the options dialog
2004/09/17 06:53:46 jl 1.3.2.1: #32973# win registry is now accessed using Unicode API
üst 5bcb4eb4
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: util.cxx,v $ * $RCSfile: util.cxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: rt $ $Date: 2004-08-20 12:32:55 $ * last change: $Author: hr $ $Date: 2004-11-09 13:59:18 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -85,8 +85,8 @@ using namespace std; ...@@ -85,8 +85,8 @@ using namespace std;
; ;
#ifdef WNT #ifdef WNT
#define HKEY_SUN_JRE "Software\\JavaSoft\\Java Runtime Environment" #define HKEY_SUN_JRE L"Software\\JavaSoft\\Java Runtime Environment"
#define HKEY_SUN_SDK "Software\\JavaSoft\\Java Development Kit" #define HKEY_SUN_SDK L"Software\\JavaSoft\\Java Development Kit"
#endif #endif
#ifdef UNX #ifdef UNX
...@@ -404,7 +404,7 @@ bool getJavaProps(const OUString & exePath, ...@@ -404,7 +404,7 @@ bool getJavaProps(const OUString & exePath,
stderrReader.join(); stderrReader.join();
#if OSL_DEBUG_LEVEL >=2 #if OSL_DEBUG_LEVEL >=2
OString data = stderrReader.getData(); OString data = stderrReader.getData();
fprintf(stdout,"%s\n", data.getStr()); fprintf(stderr,"%s\n", data.getStr());
#endif #endif
...@@ -466,38 +466,40 @@ void createJavaInfoFromWinReg(std::vector<rtl::Reference<VendorBase> > & vecInfo ...@@ -466,38 +466,40 @@ void createJavaInfoFromWinReg(std::vector<rtl::Reference<VendorBase> > & vecInfo
} }
bool getJavaInfoFromRegistry(const bool bSdk, const char* szRegKey, bool getJavaInfoFromRegistry(const bool bSdk, const wchar_t* szRegKey,
vector<OUString>& vecJavaHome) vector<OUString>& vecJavaHome)
{ {
HKEY hRoot; HKEY hRoot;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szRegKey, 0, KEY_ENUMERATE_SUB_KEYS, &hRoot) if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, szRegKey, 0, KEY_ENUMERATE_SUB_KEYS, &hRoot)
== ERROR_SUCCESS) == ERROR_SUCCESS)
{ {
DWORD dwIndex = 0; DWORD dwIndex = 0;
DWORD nNameLen; const DWORD BUFFSIZE = 1024;
char bufVersion[1024]; wchar_t bufVersion[BUFFSIZE];
// char bufVersion[BUFFSIZE];
DWORD nNameLen = BUFFSIZE;
FILETIME fileTime; FILETIME fileTime;
nNameLen = sizeof(bufVersion); nNameLen = sizeof(bufVersion);
// Iterate over all subkeys of HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment // Iterate over all subkeys of HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment
while (RegEnumKeyEx(hRoot, dwIndex, bufVersion, &nNameLen, NULL, NULL, NULL, &fileTime) != ERROR_NO_MORE_ITEMS) while (RegEnumKeyExW(hRoot, dwIndex, bufVersion, &nNameLen, NULL, NULL, NULL, &fileTime) != ERROR_NO_MORE_ITEMS)
{ {
HKEY hKey; HKEY hKey;
// Open a Java Runtime Environment sub key, e.g. "1.4.0" // Open a Java Runtime Environment sub key, e.g. "1.4.0"
if (RegOpenKeyEx(hRoot, bufVersion, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) if (RegOpenKeyExW(hRoot, bufVersion, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
{ {
DWORD dwType; DWORD dwType;
DWORD dwTmpPathLen= 0; DWORD dwTmpPathLen= 0;
// Get the path to the JavaHome every JRE entry // Get the path to the JavaHome every JRE entry
// Find out how long the string for JavaHome is and allocate memory to hold the path // Find out how long the string for JavaHome is and allocate memory to hold the path
if( RegQueryValueExA(hKey, "JavaHome", 0, &dwType, NULL, &dwTmpPathLen)== ERROR_SUCCESS) if( RegQueryValueExW(hKey, L"JavaHome", 0, &dwType, NULL, &dwTmpPathLen)== ERROR_SUCCESS)
{ {
char* szTmpPath= (char *) malloc( dwTmpPathLen); char* szTmpPath= (char *) malloc( dwTmpPathLen);
// Get the path for the runtime lib // Get the path for the runtime lib
if(RegQueryValueExA(hKey, "JavaHome", 0, &dwType, (unsigned char*) szTmpPath, &dwTmpPathLen) == ERROR_SUCCESS) if(RegQueryValueExW(hKey, L"JavaHome", 0, &dwType, (unsigned char*) szTmpPath, &dwTmpPathLen) == ERROR_SUCCESS)
{ {
// There can be several version entries refering with the same JavaHome,e.g 1.4 and 1.4.1 // There can be several version entries refering with the same JavaHome,e.g 1.4 and 1.4.1
OUString usHome= OUString::createFromAscii(szTmpPath); OUString usHome((sal_Unicode*) szTmpPath);
// check if there is already an entry with the same JavaHomeruntime lib // check if there is already an entry with the same JavaHomeruntime lib
// if so, we use the one with the more accurate version // if so, we use the one with the more accurate version
bool bAppend= true; bool bAppend= true;
...@@ -528,7 +530,7 @@ bool getJavaInfoFromRegistry(const bool bSdk, const char* szRegKey, ...@@ -528,7 +530,7 @@ bool getJavaInfoFromRegistry(const bool bSdk, const char* szRegKey,
} }
} }
dwIndex ++; dwIndex ++;
nNameLen = sizeof(bufVersion); nNameLen = BUFFSIZE;
} }
RegCloseKey(hRoot); RegCloseKey(hRoot);
} }
...@@ -563,9 +565,32 @@ void bubbleSortVersion(vector<rtl::Reference<VendorBase> >& vec) ...@@ -563,9 +565,32 @@ void bubbleSortVersion(vector<rtl::Reference<VendorBase> >& vec)
rtl::Reference<VendorBase>& cur= vec.at(j); rtl::Reference<VendorBase>& cur= vec.at(j);
rtl::Reference<VendorBase>& next= vec.at(j-1); rtl::Reference<VendorBase>& next= vec.at(j-1);
// comparing invalid SunVersion s is possible, they will be less than a int nCmp = 0;
// valid version // comparing invalid SunVersion s is possible, they will be less than a
int nCmp = cur->compareVersions(next->getVersion()); // valid version
//check if version of current is recognized, by comparing it with itself
try
{
cur->compareVersions(cur->getVersion());
}
catch (MalformedVersionException &)
{
nCmp = -1; // current < next
}
//The version of cur is valid, now compare with the second version
if (nCmp == 0)
{
try
{
nCmp = cur->compareVersions(next->getVersion());
}
catch (MalformedVersionException & )
{
//The second version is invalid, therefor it is regardes less.
nCmp = 1;
}
}
if(nCmp == 1) // cur > next if(nCmp == 1) // cur > next
{ {
rtl::Reference<VendorBase> less = next; rtl::Reference<VendorBase> less = next;
...@@ -688,14 +713,40 @@ std::vector<rtl::Reference<VendorBase> > getAllJREInfos( ...@@ -688,14 +713,40 @@ std::vector<rtl::Reference<VendorBase> > getAllJREInfos(
} }
if (bMinVersion) if (bMinVersion)
{ {
if (cur->compareVersions(sMinVersion) == -1) try
{
if (cur->compareVersions(sMinVersion) == -1)
continue;
}
catch (MalformedVersionException&)
{
#if OSL_DEBUG_LEVEL >= 1
OString _ver = OUStringToOString(
cur->getVersion(), osl_getThreadTextEncoding());
fprintf(stderr, "sunjavaplugin: A JRE was detected which version "
"has an unknown format: %s",_ver.getStr());
#endif
continue; continue;
}
} }
if (bMaxVersion) if (bMaxVersion)
{ {
if (cur->compareVersions(sMaxVersion) == 1) try
{
if (cur->compareVersions(sMaxVersion) == 1)
continue;
}
catch (MalformedVersionException&)
{
#if OSL_DEBUG_LEVEL >= 1
OString _ver = OUStringToOString(
cur->getVersion(), osl_getThreadTextEncoding());
fprintf(stderr, "sunjavaplugin: A JRE was detected which version "
"has an unknown format: %s",_ver.getStr());
#endif
continue; continue;
}
} }
if (bExcludeList) if (bExcludeList)
...@@ -705,8 +756,22 @@ std::vector<rtl::Reference<VendorBase> > getAllJREInfos( ...@@ -705,8 +756,22 @@ std::vector<rtl::Reference<VendorBase> > getAllJREInfos(
for (it_s ii = vecExcludeVersions.begin(); for (it_s ii = vecExcludeVersions.begin();
ii != vecExcludeVersions.end(); ii++) ii != vecExcludeVersions.end(); ii++)
{ {
if (cur->compareVersions(*ii) == 0) try
{ {
if (cur->compareVersions(*ii) == 0)
{
bExclude = true;
break;
}
}
catch (MalformedVersionException&)
{
#if OSL_DEBUG_LEVEL >= 1
OString _ver = OUStringToOString(
cur->getVersion(), osl_getThreadTextEncoding());
fprintf(stderr, "sunjavaplugin: A JRE was detected which version "
"has an unknown format: %s",_ver.getStr());
#endif
bExclude = true; bExclude = true;
break; break;
} }
...@@ -860,7 +925,7 @@ rtl::Reference<VendorBase> getJREInfoByPath( ...@@ -860,7 +925,7 @@ rtl::Reference<VendorBase> getJREInfoByPath(
{ {
#if OSL_DEBUG_LEVEL >= 2 #if OSL_DEBUG_LEVEL >= 2
OString _s = OUStringToOString(sResolvedDir, osl_getThreadTextEncoding()); OString _s = OUStringToOString(sResolvedDir, osl_getThreadTextEncoding());
fprintf(stdout,"###JRE found again (detected before): %s\n", _s.getStr()); fprintf(stderr,"###JRE found again (detected before): %s\n", _s.getStr());
#endif #endif
return entry2->second; return entry2->second;
} }
...@@ -915,7 +980,7 @@ rtl::Reference<VendorBase> getJREInfoByPath( ...@@ -915,7 +980,7 @@ rtl::Reference<VendorBase> getJREInfoByPath(
{ {
#if OSL_DEBUG_LEVEL >= 2 #if OSL_DEBUG_LEVEL >= 2
OString _s = OUStringToOString(sFilePath, osl_getThreadTextEncoding()); OString _s = OUStringToOString(sFilePath, osl_getThreadTextEncoding());
fprintf(stdout,"###JRE found again (detected before): %s\n", _s.getStr()); fprintf(stderr,"###JRE found again (detected before): %s\n", _s.getStr());
#endif #endif
return entry->second; return entry->second;
...@@ -985,7 +1050,7 @@ rtl::Reference<VendorBase> getJREInfoByPath( ...@@ -985,7 +1050,7 @@ rtl::Reference<VendorBase> getJREInfoByPath(
#if OSL_DEBUG_LEVEL >= 2 #if OSL_DEBUG_LEVEL >= 2
OString _s = OUStringToOString(sResolvedDir, osl_getThreadTextEncoding()); OString _s = OUStringToOString(sResolvedDir, osl_getThreadTextEncoding());
OString _s2 = OUStringToOString(path, osl_getThreadTextEncoding()); OString _s2 = OUStringToOString(path, osl_getThreadTextEncoding());
fprintf(stdout,"###Detected another JRE: %s\n at: %s\n" , fprintf(stderr,"###Detected another JRE: %s\n at: %s\n" ,
_s.getStr(), _s2.getStr()); _s.getStr(), _s2.getStr());
#endif #endif
mapJREs.insert(MAPJRE::value_type(sResolvedDir, ret)); mapJREs.insert(MAPJRE::value_type(sResolvedDir, ret));
...@@ -1139,7 +1204,7 @@ void createJavaInfoDirScan(vector<rtl::Reference<VendorBase> >& vecInfos) ...@@ -1139,7 +1204,7 @@ void createJavaInfoDirScan(vector<rtl::Reference<VendorBase> >& vecInfos)
OUString usDir3(usDir2 + arNames[k]); OUString usDir3(usDir2 + arNames[k]);
// OString _s = OUStringToOString(usDir3, osl_getThreadTextEncoding()); // OString _s = OUStringToOString(usDir3, osl_getThreadTextEncoding());
// fprintf(stdout,"###directory: %s\n", _s.getStr()); // fprintf(stderr,"###directory: %s\n", _s.getStr());
DirectoryItem item3; DirectoryItem item3;
if(DirectoryItem::get(usDir3, item) == File::E_None) if(DirectoryItem::get(usDir3, item) == File::E_None)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment