Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 168597 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/hyades/execution/recorder/local/appadapters/InternetExplorerAdapter.java (-30 / +233 lines)
Lines 27-32 Link Here
27
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle;
27
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle;
28
28
29
29
30
31
30
/**
32
/**
31
 * This object is the client object for a RecorderApplication extension point (point org.eclipse.hyades.execution.recorder.RecorderApplication)
33
 * This object is the client object for a RecorderApplication extension point (point org.eclipse.hyades.execution.recorder.RecorderApplication)
32
 * it contains logic for initializing, starting, and stopping Internet Explorer.  In particular, this object is able
34
 * it contains logic for initializing, starting, and stopping Internet Explorer.  In particular, this object is able
Lines 78-90 Link Here
78
	// bugzilla 165310 mdd
80
	// bugzilla 165310 mdd
79
	final String mylocalhost = "127.0.0.1:";
81
	final String mylocalhost = "127.0.0.1:";
80
	
82
	
83
	// bugzilla 168597
84
	/* Later we may want to change this to always use native code
85
	 * to get and set Internet Explorer registry settings.
86
	 * 
87
	 * For this defect fix, we will determine that our attempt to run regedit.exe
88
	 * has failed running on Vista without using "Run as Administrator" elevated privileges
89
	 * 
90
	 * When this happens, we will set the boolean below true and create an instance of JNIWrapper class.
91
	 * The JNIWrapper class will load the native DLL and make the calls into native code.
92
	 * 
93
	 */
94
	private boolean bUseNativeRegistryInterface = false;
95
	private boolean bRunningVista = false;
96
	private JNIWrapper jniWrapper = null;
97
	
81
	public void init(String initInfo) throws RecorderApplicationAdapterException
98
	public void init(String initInfo) throws RecorderApplicationAdapterException
82
	{
99
	{
100
		StringBuffer inputFileContents;
101
				
83
		// bugzilla 114253 set the path of temp files to the workspace path
102
		// bugzilla 114253 set the path of temp files to the workspace path
84
		setTempFilePaths();
103
		setTempFilePaths();
85
				
104
				
86
		parseInitInfo(initInfo);	
105
		parseInitInfo(initInfo);
87
		StringBuffer inputFileContents = getRegistryInfo();
106
		checkOSVersion();
107
		
108
		// Bugilla 168597		
109
		if (bUseNativeRegistryInterface)
110
			inputFileContents = getRegistryInfoUsingNativeAPI();
111
		else
112
			inputFileContents = getRegistryInfo();
113
		
114
		createOriginalRegSettingsFile(inputFileContents);
88
		
115
		
89
		StringBuffer outputFileContents = new StringBuffer();
116
		StringBuffer outputFileContents = new StringBuffer();
90
		// new mdd hyades 1.3 check for http
117
		// new mdd hyades 1.3 check for http
Lines 101-116 Link Here
101
				StringTokenizer lineTokenizer = new StringTokenizer(line,":");//$NON-NLS-1$
128
				StringTokenizer lineTokenizer = new StringTokenizer(line,":");//$NON-NLS-1$
102
				newLine=lineTokenizer.nextToken();
129
				newLine=lineTokenizer.nextToken();
103
				newLine+=":00000001";//$NON-NLS-1$
130
				newLine+=":00000001";//$NON-NLS-1$
131
				setNativeRegistryValue(newLine);
132
				outputFileContents.append(newLine+"\r\n");//$NON-NLS-1$				
104
				if (isProxyEnabled){
133
				if (isProxyEnabled){
105
					// newLine+="\r\n\"ProxyServer\"=\"http=localhost:" + portnum;//$NON-NLS-1$
134
					// newLine+="\r\n\"ProxyServer\"=\"http=localhost:" + portnum;//$NON-NLS-1$
106
					newLine+="\r\n\"ProxyServer\"=\"http=" + mylocalhost+  portnum;//$NON-NLS-1$
135
					newLine="\"ProxyServer\"=\"http=" + mylocalhost+  portnum;//$NON-NLS-1$
107
					newLine += ";https=" + mylocalhost + portnum + "\"";
136
					newLine += ";https=" + mylocalhost + portnum + "\"";
108
				}
137
				}
109
				else {
138
				else {
110
					// newLine+="\r\n\"ProxyServer\"=\"socks=localhost:";//$NON-NLS-1$
139
					// newLine+="\r\n\"ProxyServer\"=\"socks=localhost:";//$NON-NLS-1$
111
					newLine+="\r\n\"ProxyServer\"=\"socks=" + mylocalhost;//$NON-NLS-1$
140
					newLine="\"ProxyServer\"=\"socks=" + mylocalhost;//$NON-NLS-1$
112
					newLine+=portnum+"\"";//$NON-NLS-1$
141
					newLine+=portnum+"\"";//$NON-NLS-1$
113
				}				
142
				}								
143
				
114
			}
144
			}
115
			else if(line.startsWith("\"ProxyHttp1.1"))//$NON-NLS-1$
145
			else if(line.startsWith("\"ProxyHttp1.1"))//$NON-NLS-1$
116
			{
146
			{
Lines 121-126 Link Here
121
			}
151
			}
122
			else if(line.startsWith("\"ProxyServer"))//$NON-NLS-1$
152
			else if(line.startsWith("\"ProxyServer"))//$NON-NLS-1$
123
			{
153
			{
154
				
124
				//it has been found that if the target computer has never been pointed to a proxy.  This 
155
				//it has been found that if the target computer has never been pointed to a proxy.  This 
125
				//entry may not be present.  Therefore, we will ignore it if it is there and always create it from scratch.
156
				//entry may not be present.  Therefore, we will ignore it if it is there and always create it from scratch.
126
				newLine=null;				
157
				newLine=null;				
Lines 176-211 Link Here
176
				}
207
				}
177
				newLine = null; //don't update this
208
				newLine = null; //don't update this
178
			}
209
			}
179
			if(newLine!=null)
210
			if(newLine!=null){
180
				outputFileContents.append(newLine+"\r\n");//$NON-NLS-1$
211
				if (bUseNativeRegistryInterface)
212
					setNativeRegistryValue(newLine);
213
				else
214
					outputFileContents.append(newLine+"\r\n");//$NON-NLS-1$
215
			}
181
		}
216
		}
182
217
183
			
218
			
184
		
219
		
185
		createRegSettingsFile(outputFileContents);
220
		if (bUseNativeRegistryInterface){
221
			launchPath = launchPath.replaceAll("%1", "");
222
			int n = launchPath.indexOf("\\\\");  //replaceAll doesn't work for these cases
223
			int m = launchPath.indexOf("\\\"");
224
			while (n > -1 || m > -1)
225
			{						
226
				if (n > -1)
227
				{
228
					launchPath = launchPath.substring(0, n) + launchPath.substring(n+1, launchPath.length());
229
					
230
				}
231
				else if (m > -1) //wait until next loop (have to reassign indeces) 
232
				{ 
233
					launchPath = launchPath.substring(0, m) + launchPath.substring(m+1, launchPath.length());
234
					
235
				}	
236
				n = launchPath.indexOf("\\\\");
237
				m = launchPath.indexOf("\\\"");
238
			}
239
			System.out.println(launchPath);
240
		}
241
	
186
		
242
		
187
		try
243
		try
188
		{
244
		{
189
			pushRegFile(tempSettingsFilePath);
245
			if (!bUseNativeRegistryInterface){
246
				createRegSettingsFile(outputFileContents);
247
				pushRegFile(tempSettingsFilePath);
248
			}
190
		}
249
		}
191
		catch (Exception e)
250
		catch (Exception e)
192
		{
251
		{
193
			// below is for bugzilla 177396 mdd
252
				String myError = TestCorePluginResourceBundle.RecorderClientApp_WINDOWS_ADMIN_ERROR;
194
			String currentOS = Platform.getOS();
195
			if (currentOS.equals("win32")) {
196
				String myVersion = System.getProperty("os.version");
197
				String myError = "";
198
				if (myVersion.startsWith("6")) {
199
					myError = TestCorePluginResourceBundle.RecorderClientApp_VISTA_ADMIN_ERROR;
200
				}
201
				else {
202
					myError = TestCorePluginResourceBundle.RecorderClientApp_WINDOWS_ADMIN_ERROR;
203
				}
204
				throw new RecorderApplicationAdapterException(myError + "\n" + e.getMessage());
253
				throw new RecorderApplicationAdapterException(myError + "\n" + e.getMessage());
254
		}
255
		
256
	}
257
	
258
	private void checkOSVersion(){
259
		String currentOS = Platform.getOS();
260
		if (currentOS.equals("win32")) {
261
			String myVersion = System.getProperty("os.version");
262
			if (myVersion.startsWith("6")) {
263
				try{
264
					// Bugilla 168597, use native registry calls 
265
					// instead of displaying an error message
266
					bRunningVista = true;
267
					jniWrapper = new JNIWrapper();
268
					if ((jniWrapper.isProcessRunningElevated()) == false)
269
						bUseNativeRegistryInterface = true;
270
				}
271
				// so, if we can't load our DLL, we will throw the old
272
				// error message out so the user can perform a recording by
273
				// running eclipse using "Run as Administrator
274
				// this should never happen 
275
				catch (UnsatisfiedLinkError e2){
276
					StringBuffer inputFileContents = new StringBuffer();					
277
					inputFileContents.append("VISTA_ADMIN_ERROR");
278
				}
205
			}
279
			}
206
			throw new RecorderApplicationAdapterException(e.getMessage());
207
		}
280
		}
208
		
281
		
282
	}	
283
	
284
	private void setNativeRegistryValue(String newLine){
285
		if (bUseNativeRegistryInterface){
286
			int index1 = 1;  // next character after beginning quote
287
			int index2 = newLine.indexOf("=");
288
			String keyname = newLine.substring(index1, index2 - 1);
289
			String value = newLine.substring(index2 + 1);
290
			if (value.charAt(0) == '\"')
291
				value = value.substring(1);
292
			if (value.endsWith("\""))
293
				value = value.substring(0, value.length() - 1);
294
			jniWrapper.setInternetSetting(keyname, value);
295
		}
209
	}
296
	}
210
297
211
	/*
298
	/*
Lines 291-296 Link Here
291
		
378
		
292
	}
379
	}
293
380
381
	/**
382
	 * method which creates a registry settings file (*.reg)
383
	 * @param StringBuffer ouputFileContents
384
	 */
385
	private void createOriginalRegSettingsFile(StringBuffer inputFileContents)
386
	{
387
		// Bugzilla 114253 - use new path for temp files to put them in workspace
388
		File newFile = new File(originalSettingsFilePath);
389
				
390
		try
391
		{
392
			OutputStreamWriter outputWriter = new OutputStreamWriter(new FileOutputStream(newFile),"UnicodeLittle");//$NON-NLS-1$
393
			outputWriter.write(inputFileContents.toString());
394
			outputWriter.close();
395
		}
396
		catch (UnsupportedEncodingException e1)
397
		{
398
			e1.printStackTrace();
399
		}
400
		catch (FileNotFoundException e1)
401
		{
402
			e1.printStackTrace();
403
		} 
404
		catch (IOException e)
405
		{
406
			e.printStackTrace();
407
		}
408
		
409
	}
410
	
294
411
295
	/**
412
	/**
296
	 * method which exports the registry keys of interested into a file using regedit and then reads the file
413
	 * method which exports the registry keys of interested into a file using regedit and then reads the file
Lines 299-304 Link Here
299
	private StringBuffer getRegistryInfo()
416
	private StringBuffer getRegistryInfo()
300
	{	
417
	{	
301
		
418
		
419
302
		String[] regInfo = {"\"HKEY_CLASSES_ROOT\\Applications\\iexplore.exe\\shell\\open\\command\"",
420
		String[] regInfo = {"\"HKEY_CLASSES_ROOT\\Applications\\iexplore.exe\\shell\\open\\command\"",
303
				"\"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\"",
421
				"\"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\"",
304
				"\"HKEY_CURRENT_USER\\Software\\Microsoft\\Java VM\""};
422
				"\"HKEY_CURRENT_USER\\Software\\Microsoft\\Java VM\""};
Lines 307-318 Link Here
307
		//	 bugzilla 127536 mark d dunn put quotes around file name due to spaces in workspace path
425
		//	 bugzilla 127536 mark d dunn put quotes around file name due to spaces in workspace path
308
		String cmdLine = "regedit /e "+"\"" + originalSettingsFilePath+ "\" ";//$NON-NLS-1$//$NON-NLS-2$
426
		String cmdLine = "regedit /e "+"\"" + originalSettingsFilePath+ "\" ";//$NON-NLS-1$//$NON-NLS-2$
309
		String consolecmdLine = "regedit /e "+"\""+consoleSettingsFilePath+ "\" ";
427
		String consolecmdLine = "regedit /e "+"\""+consoleSettingsFilePath+ "\" ";
310
428
		
311
		InputStreamReader inputReader=null;
429
		InputStreamReader inputReader=null;
312
		File file = null;
430
		File file = null;
313
		File consoleFile = null;
431
		File consoleFile = null;
314
		Process registryChange = null;
432
		Process registryChange = null;
315
		StringBuffer inputFileContents = new StringBuffer();
433
		StringBuffer inputFileContents = new StringBuffer();
434
		
316
		try
435
		try
317
		{
436
		{
318
			// bugzilla 114253 - write temp files in workspace instead of eclipse instance location
437
			// bugzilla 114253 - write temp files in workspace instead of eclipse instance location
Lines 326-339 Link Here
326
445
327
			for (int i = 0; i < regInfo.length; i++)
446
			for (int i = 0; i < regInfo.length; i++)
328
			{
447
			{
329
				if (i == 2){
448
				if (i == 2  && bRunningVista == false){  // the Java command console registry setting is not available on Vista
330
					registryChange = Runtime.getRuntime().exec(consolecmdLine + regInfo[i],null);	
449
					registryChange = Runtime.getRuntime().exec(consolecmdLine + regInfo[i],null);	
450
					
331
				} 
451
				} 
332
				else {
452
				else {
333
					registryChange = Runtime.getRuntime().exec(cmdLine + regInfo[i],null);
453
					registryChange = Runtime.getRuntime().exec(cmdLine + regInfo[i],null);
334
				}
454
				}
455
					
335
				registryChange.waitFor();
456
				registryChange.waitFor();
336
				if (i == 2){
457
				if (i == 2  && bRunningVista == false){
458
					// the Java command console registry setting is not available on Vista
459
					// so this was throwing a File I/O exception
337
					inputReader= new InputStreamReader(new FileInputStream(consoleFile),"UTF-16");//$NON-NLS-1$
460
					inputReader= new InputStreamReader(new FileInputStream(consoleFile),"UTF-16");//$NON-NLS-1$
338
				} else 
461
				} else 
339
				{
462
				{
Lines 373-379 Link Here
373
		}
496
		}
374
		return inputFileContents;
497
		return inputFileContents;
375
	}
498
	}
376
499
	//Bugilla 168597
500
	StringBuffer getRegistryInfoUsingNativeAPI(){
501
		bUseNativeRegistryInterface = true;
502
		
503
		StringBuffer inputFileContents = new StringBuffer();		
504
		// fire up an instance of the JNI layer to start using native code
505
		launchPath = jniWrapper.getIEPath();
506
		String str = jniWrapper.getErrorMessage();
507
		AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyEnable");
508
		AddSettingToBuffer(jniWrapper, inputFileContents, "AutoConfigURL");
509
		AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyServer");
510
		AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyOverride");
511
		AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyHttp1.1");
512
		AddSettingToBuffer(jniWrapper, inputFileContents, "WarnOnBadCertRecving");
513
		AddSettingToBuffer(jniWrapper, inputFileContents, "WarnOnZoneCrossing");
514
		
515
		// left out ZonesMixedContent for now, that would require reading many more keys
516
		// to set all that
517
		
518
		return inputFileContents;
519
	}
520
	
521
	private void AddSettingToBuffer(JNIWrapper jniWrapper, StringBuffer inputFileContents, String name){
522
		String setting = jniWrapper.getInternetSetting(name);
523
		if (setting != null  && setting.length() > 0){
524
			inputFileContents.append("\"" + name + "\"=" + setting + "\r\n");
525
		}
526
		return;
527
	}
528
			
377
	
529
	
378
	/**
530
	/**
379
	 * method called by the recorder to start the target application (Internet Explorer)
531
	 * method called by the recorder to start the target application (Internet Explorer)
Lines 384-391 Link Here
384
		ieProcess = null;
536
		ieProcess = null;
385
		try
537
		try
386
		{
538
		{
539
			String strStart = launchPath + " " + startupURL;//$NON-NLS-1$
387
			//TODO derive path to iexplore.exe using registry.
540
			//TODO derive path to iexplore.exe using registry.
388
			ieProcess = Runtime.getRuntime().exec(launchPath + " " +  startupURL);//$NON-NLS-1$
541
			if (bUseNativeRegistryInterface == true)
542
				jniWrapper.startIE(startupURL);
543
			else
544
				ieProcess = Runtime.getRuntime().exec(strStart);
389
		}
545
		}
390
		catch (IOException e)
546
		catch (IOException e)
391
		{
547
		{
Lines 404-412 Link Here
404
		{
560
		{
405
			// bugzilla 114253 - write temp files in workspace instead of eclipse instance location
561
			// bugzilla 114253 - write temp files in workspace instead of eclipse instance location
406
			// use the new path for the temp files
562
			// use the new path for the temp files
407
			pushRegFile(originalSettingsFilePath);
563
			if (bUseNativeRegistryInterface){
408
			
564
				try {
409
			pushRegFile(consoleSettingsFilePath);
565
				StringBuffer inputFileContents = new StringBuffer();
566
				String str;
567
				byte [] buffer = new byte[4096];
568
				int bytes_read;
569
				File newFile = new File(originalSettingsFilePath);				
570
				FileInputStream inputStream = new FileInputStream(newFile);//$NON-NLS-1$
571
				while ((bytes_read = inputStream.read(buffer)) != -1){
572
					str = new String(buffer, 0, bytes_read, "UnicodeLittle");
573
					inputFileContents.append(str);
574
				}
575
				inputStream.close();				
576
				StringTokenizer fileTokenizer = new StringTokenizer(inputFileContents.toString(),"\r\n");//$NON-NLS-1$
577
				while(fileTokenizer.hasMoreTokens())
578
				{
579
					String line=fileTokenizer.nextToken();
580
					// check to see if it is a real setting or a blank line
581
					int index = line.indexOf('=');
582
					if (index > 0)
583
						setNativeRegistryValue(line);
584
				}
585
				}
586
				catch (IOException eio){
587
					// file not found is ok because cleanup gets called twice if stopping from the GUI
588
					// rather than by closing IE.
589
				}
590
								
591
			}
592
			else{
593
				pushRegFile(originalSettingsFilePath);
594
				
595
				pushRegFile(consoleSettingsFilePath);
596
			}
410
		}
597
		}
411
		catch (Exception e)
598
		catch (Exception e)
412
		{
599
		{
Lines 430-436 Link Here
430
	 */
617
	 */
431
	public void stop() throws RecorderApplicationAdapterException
618
	public void stop() throws RecorderApplicationAdapterException
432
	{
619
	{
433
		ieProcess.destroy();
620
		if (ieProcess == null){
621
			if (jniWrapper != null)
622
				jniWrapper.terminateIE();
623
			
624
		}else{
625
			ieProcess.destroy();
626
		}
434
	}
627
	}
435
	
628
	
436
	//init format:
629
	//init format:
Lines 589-593 Link Here
589
	public void setApplicationPath(String str) {
782
	public void setApplicationPath(String str) {
590
		TestCorePlugin.getDefault().getPluginPreferences().setValue("RECORDER_IE_PATH", str);
783
		TestCorePlugin.getDefault().getPluginPreferences().setValue("RECORDER_IE_PATH", str);
591
	}
784
	}
785
	// added this method to be called by the RecorderDataProcessorHelper class
786
	// when the client connects, we will look for a new instance of IE if
787
	// we are using the Native DLL code to control the recording
788
	public void clientConnectNotification(){
789
		
790
		if (bUseNativeRegistryInterface  && jniWrapper != null){
791
			jniWrapper.clientConnectNotification();
792
		}
793
		
794
	}
592
795
593
}
796
}
(-)src/org/eclipse/hyades/internal/execution/recorder/local/RecorderStopper.java (-1 / +12 lines)
Lines 11-16 Link Here
11
 **********************************************************************/
11
 **********************************************************************/
12
package org.eclipse.hyades.internal.execution.recorder.local;
12
package org.eclipse.hyades.internal.execution.recorder.local;
13
13
14
import org.eclipse.hyades.execution.recorder.local.appadapters.JNIWrapper;
15
14
/**
16
/**
15
 * Thread which monitors the application being recorded
17
 * Thread which monitors the application being recorded
16
 * when the application being recorded terminates, this threads shuts down the 
18
 * when the application being recorded terminates, this threads shuts down the 
Lines 38-44 Link Here
38
			{
40
			{
39
				bActive = true;
41
				bActive = true;
40
				System.err.println("about to wait for process"); //$NON-NLS-1$
42
				System.err.println("about to wait for process"); //$NON-NLS-1$
41
				process.waitFor();
43
				if (process == null){
44
					JNIWrapper jniWrapper = new JNIWrapper();
45
					jniWrapper.waitForIE();
46
				}else{
47
					process.waitFor();
48
				}
49
				
42
				bActive = false;
50
				bActive = false;
43
				System.err.println("process terminated"); //$NON-NLS-1$
51
				System.err.println("process terminated"); //$NON-NLS-1$
44
				client.stopRecording();
52
				client.stopRecording();
Lines 48-53 Link Here
48
				//this is an expected occurance when the user selects the stop button.
56
				//this is an expected occurance when the user selects the stop button.
49
				
57
				
50
			} 
58
			} 
59
			catch (NullPointerException e){
60
				
61
			}
51
			 			
62
			 			
52
		}
63
		}
53
		
64
		
(-)src/org/eclipse/hyades/internal/execution/recorder/local/RecorderDataProcessorHelper.java (-2 / +20 lines)
Lines 17-26 Link Here
17
17
18
import org.eclipse.hyades.execution.recorder.IRecorderDataProcessor;
18
import org.eclipse.hyades.execution.recorder.IRecorderDataProcessor;
19
import org.eclipse.hyades.execution.recorder.IRecorderListenerFullFeedback;
19
import org.eclipse.hyades.execution.recorder.IRecorderListenerFullFeedback;
20
import org.eclipse.hyades.execution.recorder.Recorder;
20
import org.eclipse.hyades.execution.recorder.RecorderFactory;
21
import org.eclipse.hyades.execution.recorder.RecorderFactory;
21
import org.eclipse.hyades.internal.execution.local.common.DataProcessor;
22
import org.eclipse.hyades.internal.execution.local.common.DataProcessor;
22
import org.eclipse.hyades.internal.execution.recorder.remote.IRecorderMessageTypes;
23
import org.eclipse.hyades.internal.execution.recorder.remote.IRecorderMessageTypes;
23
24
import org.eclipse.hyades.execution.recorder.local.appadapters.InternetExplorerAdapter;
24
/**
25
/**
25
 * Object which contains data management and direction functionality.  It receives incoming messages from the Agent Controller and sends them to the
26
 * Object which contains data management and direction functionality.  It receives incoming messages from the Agent Controller and sends them to the
26
 * appropriate API in the contained IRecorderDataProcessor
27
 * appropriate API in the contained IRecorderDataProcessor
Lines 52-57 Link Here
52
	 */
53
	 */
53
	private Date lastReceivedReportTime = null;
54
	private Date lastReceivedReportTime = null;
54
	
55
	
56
	/**
57
	 * Adding this boolean to identify when the incomming data indicates a client
58
	 * connection has taken place
59
	 */
60
	private boolean clientConnected = false;
61
	
55
	
62
	
56
	/**
63
	/**
57
	 * constructor
64
	 * constructor
Lines 80-86 Link Here
80
		switch(controlByte)
87
		switch(controlByte)
81
		{
88
		{
82
			case MESSAGE_TYPE_DATA:
89
			case MESSAGE_TYPE_DATA:
83
				loadTestDataProcessor.processData(buffer);				
90
				loadTestDataProcessor.processData(buffer);	
91
				if (!clientConnected){
92
					String tStr = new String(buffer);
93
					if (tStr.contains("Client Connected") == true){
94
						clientConnected = true;
95
						Object recorder = RecorderFactory.getInstance().getActiveRecorder().getRecorderClient().appAdapter;
96
						if (recorder instanceof InternetExplorerAdapter){
97
							InternetExplorerAdapter rec = (InternetExplorerAdapter)recorder;
98
							rec.clientConnectNotification();
99
						}
100
					}
101
				}
84
				updateBytesRecievedControl(bufferLength, false);
102
				updateBytesRecievedControl(bufferLength, false);
85
				break;			
103
				break;			
86
			case MESSAGE_TYPE_CONTROL_STRING:
104
			case MESSAGE_TYPE_CONTROL_STRING:
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.hyades.test.core; singleton:=true
4
Bundle-SymbolicName: org.eclipse.hyades.test.core; singleton:=true
5
Bundle-Version: 4.2.200.qualifier
5
Bundle-Version: 4.2.202.qualifier
6
Bundle-ClassPath: hexteh.jar,
6
Bundle-ClassPath: hexteh.jar,
7
 hexrecr.jar,
7
 hexrecr.jar,
8
 test-core.jar
8
 test-core.jar
(-)src/org/eclipse/hyades/execution/recorder/Recorder.java (+8 lines)
Lines 178-183 Link Here
178
	{
178
	{
179
		return id;
179
		return id;
180
	}
180
	}
181
	/**
182
	 * 
183
	 * @return returns the active recorder client application adapter
184
	 * @provisional Provisional API:  This API is subject to change in the next release.
185
	 * 	 */
186
	public RecorderClient getRecorderClient(){
187
		return client;
188
	}
181
	
189
	
182
	/**
190
	/**
183
	 * called to initiate a recording with this recording.  Before this method is called, all valid information for this 
191
	 * called to initiate a recording with this recording.  Before this method is called, all valid information for this 
(-)src/org/eclipse/hyades/execution/recorder/local/appadapters/JNIWrapper.java (+205 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: JNIWrapper.java,v 1 2007/08/24 1:03:39 dmorris Exp $
8
 * 
9
 * Contributors: 
10
 * IBM Corporation - initial API and implementation
11
 **********************************************************************/
12
13
package org.eclipse.hyades.execution.recorder.local.appadapters;
14
15
16
import java.net.URL;
17
18
import org.eclipse.core.runtime.FileLocator;
19
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.Platform;
21
import org.osgi.framework.Bundle;
22
23
import java.io.FileInputStream;
24
import java.io.FileOutputStream;
25
import java.io.IOException;
26
import java.io.File;
27
import java.io.OutputStreamWriter;
28
29
30
// added this file for bugzilla 168597
31
32
public class JNIWrapper {
33
	
34
	private static final native String getLastError();
35
	private static final native String getIEAppPath();
36
	private static final native String getEnableJavaConsole();
37
	private static final native String getIESetting(String name);
38
	private static final native int setIESetting(String name, String value, int type);
39
	private static final native int launchIE(String url);
40
	private static final native int waitForIEProcess();
41
	private static final native int killIEProcess();
42
	private static final native int isProcessElevated();
43
	private static final native int lookForNewBrowser();
44
	private static final native int isIERunning();
45
	
46
	public static final int REG_SZ = 1;
47
	public static final int REG_DWORD = 4;
48
	
49
	public static String pluginPath;
50
	public static String blankURL = null;
51
	
52
	public synchronized String getIEPath(){
53
		
54
		String path = getIEAppPath();
55
		return path;
56
	}
57
	
58
	public synchronized String getEnableJava(){
59
		
60
		String path = getEnableJavaConsole();
61
		return path;
62
	}
63
	
64
	
65
	public synchronized String getInternetSetting(String name){
66
		String setting = getIESetting(name);
67
		//if (setting == null || setting.length() == 0)
68
			//getErrorMessage();
69
		
70
		
71
		return setting;
72
	}
73
	
74
	public synchronized boolean setInternetSetting(String name, String value){
75
		int i = 0;
76
	
77
		if (value.startsWith("dword:", 0)){
78
			int index = value.indexOf(":");
79
			index++;
80
			value = value.substring(index);
81
			value = value.trim();
82
			Integer intVal = new Integer(value);
83
			value = intVal.toString();
84
			i = setIESetting(name, value, REG_DWORD);
85
			
86
			
87
		}else{
88
			i = setIESetting(name, value, REG_SZ);
89
		}
90
		if (i > 0)
91
			return true;
92
		else
93
			return false;
94
	}
95
	
96
	public synchronized String getErrorMessage(){
97
		String errorMsg = getLastError();
98
		System.out.println(errorMsg);
99
		return errorMsg;
100
		
101
	}
102
103
	public boolean startIE(String url){
104
		int retCode = 0;
105
		// we create a temporary blank.html file on the fly
106
		// using IELaunchURL with about:blank fails and we generally 
107
		// want a blank page to come up so the users default URL page won't end up
108
		// being a part of every recording
109
		if (url.compareTo("about:blank") == 0){
110
			blankURL = null;
111
			try {
112
				File tfile = File.createTempFile("blank", ".html");
113
				blankURL = tfile.getPath();
114
				if (!tfile.exists()){
115
						tfile.createNewFile();
116
					OutputStreamWriter outputWriter = 
117
						new OutputStreamWriter(new FileOutputStream(tfile),"UnicodeLittle");//$NON-NLS-1$
118
					outputWriter.write("<HTML></HTML>");//$NON-NLS-1$
119
					outputWriter.close();
120
				}
121
			}
122
			catch (IOException e){
123
				// we will just launch IE with the user default page if there is an exception creating
124
				// the temp file. 
125
			}
126
			
127
			//blankURL = pluginPath + "blank.htm";
128
			retCode = launchIE(blankURL);
129
		}else{
130
			retCode = launchIE(url);
131
		}
132
133
		if (retCode == 0)
134
			return false;
135
		else
136
			return true;
137
	}
138
	
139
	public boolean waitForIE(){
140
		int retCode = 0;
141
142
		retCode = waitForIEProcess();
143
		if (blankURL != null){
144
			File tfile = new File(blankURL);
145
			if (tfile.exists())
146
				tfile.delete();
147
		}
148
		if (retCode == 0)
149
			return false;
150
		else
151
			return true;
152
		
153
	}
154
	
155
	public boolean terminateIE(){
156
		int retCode = 0;
157
158
		retCode = killIEProcess();
159
		if (retCode == 0)
160
			return false;
161
		else
162
			return true;
163
		
164
	}
165
	
166
	public boolean isProcessRunningElevated(){
167
		int i = isProcessElevated();
168
		if (i == 0)
169
			return false;
170
		else
171
			return true;
172
	}
173
	
174
	public void clientConnectNotification(){
175
		lookForNewBrowser();
176
	}
177
	
178
	public boolean isBrowserRunning(){
179
		int i = isIERunning();
180
		if (i == 0)
181
			return false;
182
		else
183
			return true;
184
	}
185
	
186
	
187
	static {
188
		// load our utility dll, it should be in the org.eclipse.hyades.test.core plugin directory
189
		try{
190
			Bundle b = Platform.getBundle("org.eclipse.hyades.test.core");
191
			URL u = FileLocator.resolve(b.getEntry("/"));
192
			String path = u.getPath();
193
			path = path.substring(1);
194
			pluginPath = path;
195
			String finalPath = path + "TPTPRecUtil.dll";
196
			System.load(finalPath);
197
		}
198
		catch (IOException e){
199
		
200
		}
201
	}
202
	
203
}
204
205

Return to bug 168597