|
Lines 23-32
Link Here
|
| 23 |
|
23 |
|
| 24 |
import java.io.IOException; |
24 |
import java.io.IOException; |
| 25 |
import java.io.InputStreamReader; |
25 |
import java.io.InputStreamReader; |
|
|
26 |
import java.net.URL; |
| 26 |
import java.util.StringTokenizer; |
27 |
import java.util.StringTokenizer; |
| 27 |
|
28 |
|
|
|
29 |
import org.eclipse.core.runtime.FileLocator; |
| 28 |
import org.eclipse.core.runtime.IPath; |
30 |
import org.eclipse.core.runtime.IPath; |
| 29 |
import org.eclipse.core.runtime.Platform; |
31 |
import org.eclipse.core.runtime.Platform; |
|
|
32 |
import org.eclipse.hyades.execution.recorder.local.appadapters.JNIWrapper; |
| 33 |
import org.osgi.framework.Bundle; |
| 30 |
|
34 |
|
| 31 |
/** |
35 |
/** |
| 32 |
* @author mdunn |
36 |
* @author mdunn |
|
Lines 57-62
Link Here
|
| 57 |
// below is for bugzilla 177396 mdd |
61 |
// below is for bugzilla 177396 mdd |
| 58 |
public final int VISTA_ADMIN_ERROR = -8; |
62 |
public final int VISTA_ADMIN_ERROR = -8; |
| 59 |
public final int WINDOWS_ADMIN_ERROR = -8; |
63 |
public final int WINDOWS_ADMIN_ERROR = -8; |
|
|
64 |
public final int BROWSER_IN_USE_ERROR = -9; |
| 65 |
public final int RECORDING_TPTPRECUTIL_DLL_MISSING = -10; |
| 60 |
// bugzilla 79219 mdd |
66 |
// bugzilla 79219 mdd |
| 61 |
private String sslProxyAddr = ""; |
67 |
private String sslProxyAddr = ""; |
| 62 |
private String sslProxyPort = ""; |
68 |
private String sslProxyPort = ""; |
|
Lines 66-73
Link Here
|
| 66 |
private String proxyOverrideString = ""; |
72 |
private String proxyOverrideString = ""; |
| 67 |
private String autoConfigURLString = ""; |
73 |
private String autoConfigURLString = ""; |
| 68 |
|
74 |
|
|
|
75 |
private boolean bUseNativeRegistryInterface = false; |
| 76 |
private JNIWrapper jniWrapper = null; |
| 77 |
|
| 69 |
public RecorderRegistryInfo() { |
78 |
public RecorderRegistryInfo() { |
| 70 |
StringBuffer inputFileContents = getRegistryInfo(); |
79 |
StringBuffer inputFileContents = new StringBuffer(); |
|
|
80 |
// return of false indicates fatal error |
| 81 |
checkOSVersion(inputFileContents); |
| 82 |
if (bUseNativeRegistryInterface) |
| 83 |
getRegistryInfoUsingNativeAPI(inputFileContents); |
| 84 |
else |
| 85 |
getRegistryInfo(inputFileContents); |
| 86 |
|
| 71 |
// below is for bugzilla 177396 mdd |
87 |
// below is for bugzilla 177396 mdd |
| 72 |
String checkVistaError=inputFileContents.toString(); |
88 |
String checkVistaError=inputFileContents.toString(); |
| 73 |
if (checkVistaError.equalsIgnoreCase("VISTA_ADMIN_ERROR")) { |
89 |
if (checkVistaError.equalsIgnoreCase("VISTA_ADMIN_ERROR")) { |
|
Lines 78-83
Link Here
|
| 78 |
setBadProxySettings(true); |
94 |
setBadProxySettings(true); |
| 79 |
setProxyError(WINDOWS_ADMIN_ERROR); |
95 |
setProxyError(WINDOWS_ADMIN_ERROR); |
| 80 |
} |
96 |
} |
|
|
97 |
else if (checkVistaError.equalsIgnoreCase("BROWSER_IN_USE_ERROR")) { |
| 98 |
setBadProxySettings(true); |
| 99 |
setProxyError(BROWSER_IN_USE_ERROR); |
| 100 |
} |
| 101 |
if (checkVistaError.equalsIgnoreCase("RECORDING_TPTPRECUTIL_DLL_MISSING")) { |
| 102 |
setBadProxySettings(true); |
| 103 |
setProxyError(RECORDING_TPTPRECUTIL_DLL_MISSING); |
| 104 |
} |
| 81 |
else { |
105 |
else { |
| 82 |
boolean isEnabled = checkProxyEnabled(inputFileContents); |
106 |
boolean isEnabled = checkProxyEnabled(inputFileContents); |
| 83 |
setProxyEnabled(isEnabled); |
107 |
setProxyEnabled(isEnabled); |
|
Lines 115-122
Link Here
|
| 115 |
} |
139 |
} |
| 116 |
} |
140 |
} |
| 117 |
} |
141 |
} |
| 118 |
|
142 |
|
| 119 |
private StringBuffer getRegistryInfo() |
143 |
private boolean checkOSVersion(StringBuffer inputFileContents){ |
|
|
144 |
String currentOS = Platform.getOS(); |
| 145 |
if (currentOS.equals("win32")) { |
| 146 |
String myVersion = System.getProperty("os.version"); |
| 147 |
if (myVersion.startsWith("6")) { |
| 148 |
try{ |
| 149 |
// Bugilla 168597, use native registry calls |
| 150 |
// instead of displaying an error message |
| 151 |
Bundle b = Platform.getBundle("org.eclipse.hyades.test.core"); |
| 152 |
URL u = FileLocator.resolve(b.getEntry("/")); |
| 153 |
String path = u.getPath(); |
| 154 |
path = path.substring(1); |
| 155 |
String finalPath = path + "TPTPRecUtil.dll"; |
| 156 |
File dllFile = new File(finalPath); |
| 157 |
if (dllFile.exists() == false){ |
| 158 |
return false; |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
jniWrapper = new JNIWrapper(); |
| 163 |
if (jniWrapper.isProcessRunningElevated() == false){ |
| 164 |
bUseNativeRegistryInterface = true; |
| 165 |
if (jniWrapper.isBrowserRunning() == true){ |
| 166 |
inputFileContents.append("BROWSER_IN_USE_ERROR"); |
| 167 |
return false; |
| 168 |
} |
| 169 |
} |
| 170 |
} |
| 171 |
catch (IOException ioe){ |
| 172 |
|
| 173 |
} |
| 174 |
|
| 175 |
// so, if we can't load our DLL, we will throw the old |
| 176 |
// error message out so the user can perform a recording by |
| 177 |
// running eclipse using "Run as Adminstrator |
| 178 |
// this should never happen |
| 179 |
catch (UnsatisfiedLinkError e2){ |
| 180 |
inputFileContents.append("VISTA_ADMIN_ERROR"); |
| 181 |
return false; |
| 182 |
} |
| 183 |
} |
| 184 |
} |
| 185 |
return true; |
| 186 |
} |
| 187 |
|
| 188 |
private void getRegistryInfo(StringBuffer inputFileContents) |
| 120 |
{ |
189 |
{ |
| 121 |
String originalSettingsFileName = "newSettingsFile.tmp"; |
190 |
String originalSettingsFileName = "newSettingsFile.tmp"; |
| 122 |
String originalSettingsFilePath = ""; |
191 |
String originalSettingsFilePath = ""; |
|
Lines 127-133
Link Here
|
| 127 |
String getOriginalInfoCommandLine = "regedit /e "+"\"" + originalSettingsFilePath+"\"" + " \"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\"";//$NON-NLS-1$//$NON-NLS-2$ |
196 |
String getOriginalInfoCommandLine = "regedit /e "+"\"" + originalSettingsFilePath+"\"" + " \"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\"";//$NON-NLS-1$//$NON-NLS-2$ |
| 128 |
InputStreamReader inputReader=null; |
197 |
InputStreamReader inputReader=null; |
| 129 |
File file = null; |
198 |
File file = null; |
| 130 |
StringBuffer inputFileContents = new StringBuffer(); |
|
|
| 131 |
try |
199 |
try |
| 132 |
{ |
200 |
{ |
| 133 |
try { |
201 |
try { |
|
Lines 154-166
Link Here
|
| 154 |
if (currentOS.equals("win32")) { |
222 |
if (currentOS.equals("win32")) { |
| 155 |
String myVersion = System.getProperty("os.version"); |
223 |
String myVersion = System.getProperty("os.version"); |
| 156 |
if (myVersion.startsWith("6")) { |
224 |
if (myVersion.startsWith("6")) { |
| 157 |
inputFileContents.append("VISTA_ADMIN_ERROR"); |
225 |
inputFileContents.append("RECORDING_TPTPRECUTIL_DLL_MISSING"); |
| 158 |
} |
226 |
}else { |
| 159 |
else { |
|
|
| 160 |
inputFileContents.append("WINDOWS_ADMIN_ERROR"); |
227 |
inputFileContents.append("WINDOWS_ADMIN_ERROR"); |
|
|
228 |
e.printStackTrace(); |
| 161 |
} |
229 |
} |
| 162 |
} |
230 |
} |
| 163 |
e.printStackTrace(); |
|
|
| 164 |
|
231 |
|
| 165 |
} |
232 |
} |
| 166 |
|
233 |
|
|
Lines 181-188
Link Here
|
| 181 |
if (file.exists()) |
248 |
if (file.exists()) |
| 182 |
file.delete(); |
249 |
file.delete(); |
| 183 |
} |
250 |
} |
| 184 |
return inputFileContents; |
251 |
return; |
| 185 |
} |
252 |
} |
|
|
253 |
|
| 254 |
// added for Bugilla 168597 |
| 255 |
private void getRegistryInfoUsingNativeAPI(StringBuffer inputFileContents){ |
| 256 |
// fire up an instance of the JNI layer to start using native code |
| 257 |
AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyEnable"); |
| 258 |
AddSettingToBuffer(jniWrapper, inputFileContents, "AutoConfigURL"); |
| 259 |
AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyServer"); |
| 260 |
AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyOverride"); |
| 261 |
|
| 262 |
return; |
| 263 |
} |
| 264 |
|
| 265 |
private void AddSettingToBuffer(JNIWrapper jniWrapper, StringBuffer inputFileContents, String name){ |
| 266 |
String setting = jniWrapper.getInternetSetting(name); |
| 267 |
if (setting != null && setting.length() > 0){ |
| 268 |
inputFileContents.append("\"" + name + "\"=" + setting + "\r\n"); |
| 269 |
} |
| 270 |
return; |
| 271 |
} |
| 272 |
|
| 273 |
|
| 186 |
private boolean checkProxyEnabled(StringBuffer inputBuffer) |
274 |
private boolean checkProxyEnabled(StringBuffer inputBuffer) |
| 187 |
{ |
275 |
{ |
| 188 |
boolean comparesOK = false; |
276 |
boolean comparesOK = false; |