summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Gayed <ggayed>2009-10-02 20:58:07 +0000
committerGrant Gayed <ggayed>2009-10-02 20:58:07 +0000
commit056762a1d7c74e75bfac132d1e756819b6f3b39e (patch)
treee645e7459407ba289c710b04410e048d0425c17a
parent2c8a13d0df1694740c0af6220e23682b3ddd10de (diff)
downloadeclipse.platform.swt-056762a1d7c74e75bfac132d1e756819b6f3b39e.tar.gz
eclipse.platform.swt-056762a1d7c74e75bfac132d1e756819b6f3b39e.tar.xz
eclipse.platform.swt-056762a1d7c74e75bfac132d1e756819b6f3b39e.zip
60387 and 283223: Browser.setUrl() with header values and post args
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java215
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java35
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/forms/org/eclipse/swt/browser/IE.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Browser/photon/org/eclipse/swt/browser/Voyager.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java116
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/wpf/org/eclipse/swt/browser/IE.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/InputStream.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java68
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIMIMEInputStream.java59
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa.c16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa_stats.c5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa_stats.h1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSMutableURLRequest.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/WebKitFull.bridgesupport.extras4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/WebView.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c48
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.c86
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.h24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SAFEARRAY.java24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SAFEARRAYBOUND.java17
29 files changed, 631 insertions, 178 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java
index abb242ebc3..12cd254102 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java
@@ -57,6 +57,8 @@ class Safari extends WebBrowser {
static final String URI_APPLEWEBDATA = "applewebdata://"; //$NON-NLS-1$
static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
static final String HEADER_SETCOOKIE = "Set-Cookie"; //$NON-NLS-1$
+ static final String POST = "POST"; //$NON-NLS-1$
+ static final String USER_AGENT = "user-agent"; //$NON-NLS-1$
static final String ADD_WIDGET_KEY = "org.eclipse.swt.internal.addWidget"; //$NON-NLS-1$
static final String BROWSER_WINDOW = "org.eclipse.swt.browser.Browser.Window"; //$NON-NLS-1$
static final String SAFARI_EVENTS_FIX_KEY = "org.eclipse.swt.internal.safariEventsFix"; //$NON-NLS-1$
@@ -90,27 +92,21 @@ class Safari extends WebBrowser {
NativeGetCookie = new Runnable () {
public void run () {
int storage = Cocoa.objc_msgSend (Cocoa.C_NSHTTPCookieStorage, Cocoa.S_sharedHTTPCookieStorage);
- int length = CookieUrl.length ();
- char[] buffer = new char[length];
- CookieUrl.getChars (0, length, buffer, 0);
- int urlString = OS.CFStringCreateWithCharacters (0, buffer, length);
+ int urlString = createNSString (CookieUrl);
int url = Cocoa.objc_msgSend (Cocoa.C_NSURL, Cocoa.S_URLWithString, urlString);
OS.CFRelease (urlString);
int cookies = Cocoa.objc_msgSend (storage, Cocoa.S_cookiesForURL, url);
int count = Cocoa.objc_msgSend (cookies, Cocoa.S_count);
if (count == 0) return;
- length = CookieName.length ();
- buffer = new char[length];
- CookieName.getChars (0, length, buffer, 0);
- int name = OS.CFStringCreateWithCharacters (0, buffer, length);
+ int name = createNSString (CookieName);
for (int i = 0; i < count; i++) {
int current = Cocoa.objc_msgSend (cookies, Cocoa.S_objectAtIndex, i);
int currentName = Cocoa.objc_msgSend (current, Cocoa.S_name);
if (Cocoa.objc_msgSend (currentName, Cocoa.S_compare, name) == Cocoa.NSOrderedSame) {
int value = Cocoa.objc_msgSend (current, Cocoa.S_value);
- length = OS.CFStringGetLength (value);
- buffer = new char[length];
+ int length = OS.CFStringGetLength (value);
+ char[] buffer = new char[length];
CFRange range = new CFRange ();
range.length = length;
OS.CFStringGetCharacters (value, range, buffer);
@@ -125,21 +121,12 @@ class Safari extends WebBrowser {
NativeSetCookie = new Runnable () {
public void run () {
- int length = CookieUrl.length ();
- char[] buffer = new char[length];
- CookieUrl.getChars (0, length, buffer, 0);
- int urlString = OS.CFStringCreateWithCharacters (0, buffer, length);
+ int urlString = createNSString(CookieUrl);
int url = Cocoa.objc_msgSend (Cocoa.C_NSURL, Cocoa.S_URLWithString, urlString);
OS.CFRelease (urlString);
- length = CookieValue.length ();
- buffer = new char[length];
- CookieValue.getChars (0, length, buffer, 0);
- int value = OS.CFStringCreateWithCharacters (0, buffer, length);
- length = HEADER_SETCOOKIE.length ();
- buffer = new char[length];
- HEADER_SETCOOKIE.getChars (0, length, buffer, 0);
- int key = OS.CFStringCreateWithCharacters (0, buffer, length);
+ int value = createNSString (CookieValue);
+ int key = createNSString (HEADER_SETCOOKIE);
int headers = Cocoa.objc_msgSend (Cocoa.C_NSMutableDictionary, Cocoa.S_dictionaryWithCapacity, 1);
Cocoa.objc_msgSend (headers, Cocoa.S_setValue, value, key);
OS.CFRelease (key);
@@ -394,10 +381,7 @@ public void create (Composite parent, int style) {
Cocoa.objc_msgSend(webView, Cocoa.S_setDownloadDelegate, delegate);
// [webView setApplicationNameForUserAgent:applicationName];
- int length = AGENT_STRING.length();
- char[] chars = new char[length];
- AGENT_STRING.getChars(0, length, chars, 0);
- int sHandle = OS.CFStringCreateWithCharacters(0, chars, length);
+ int sHandle = createNSString(AGENT_STRING);
Cocoa.objc_msgSend(webView, Cocoa.S_setApplicationNameForUserAgent, sHandle);
OS.CFRelease(sHandle);
@@ -429,6 +413,13 @@ static int eventProc7(int webview, int userData, int selector, int arg0, int arg
return 0;
}
+static int createNSString(String string) {
+ int length = string.length ();
+ char[] buffer = new char[length];
+ string.getChars (0, length, buffer, 0);
+ return OS.CFStringCreateWithCharacters (0, buffer, length);
+}
+
static String getString (int ptr) {
int length = OS.CFStringGetLength (ptr);
char[] buffer = new char[length];
@@ -463,11 +454,7 @@ public boolean close () {
}
public boolean execute(String script) {
- int length = script.length();
- char[] buffer = new char[length];
- script.getChars(0, length, buffer, 0);
- int string = OS.CFStringCreateWithCharacters(0, buffer, length);
-
+ int string = createNSString(script);
int value = Cocoa.objc_msgSend(webView, Cocoa.S_stringByEvaluatingJavaScriptFromString, string);
OS.CFRelease(string);
return value != 0;
@@ -776,16 +763,9 @@ public boolean setText(String html) {
return true;
}
-void _setText(String html) {
- int length = html.length();
- char[] buffer = new char[length];
- html.getChars(0, length, buffer, 0);
- int string = OS.CFStringCreateWithCharacters(0, buffer, length);
-
- length = URI_FROMMEMORY.length();
- buffer = new char[length];
- URI_FROMMEMORY.getChars(0, length, buffer, 0);
- int URLString = OS.CFStringCreateWithCharacters(0, buffer, length);
+void _setText(String html) {
+ int string = createNSString(html);
+ int URLString = createNSString(URI_FROMMEMORY);
/*
* Note. URLWithString uses autorelease. The resulting URL
@@ -803,7 +783,7 @@ void _setText(String html) {
OS.CFRelease(string);
}
-public boolean setUrl(String url) {
+public boolean setUrl(String url, String postData, String[] headers) {
html = null;
if (url.indexOf('/') == 0) {
@@ -813,9 +793,7 @@ public boolean setUrl(String url) {
}
int inURL = 0;
- char[] chars = new char[url.length()];
- url.getChars(0, chars.length, chars, 0);
- int str = OS.CFStringCreateWithCharacters(0, chars, chars.length);
+ int str = createNSString(url);
if (str != 0) {
char[] unescapedChars = new char[] {'%', '#'};
int unescapedStr = OS.CFStringCreateWithCharacters(0, unescapedChars, unescapedChars.length);
@@ -829,16 +807,49 @@ public boolean setUrl(String url) {
}
if (inURL == 0) return false;
- //request = [NSURLRequest requestWithURL:(NSURL*)inURL];
- int request = Cocoa.objc_msgSend(Cocoa.C_NSURLRequest, Cocoa.S_requestWithURL, inURL);
+ int request = Cocoa.objc_msgSend(Cocoa.C_NSMutableURLRequest, Cocoa.S_requestWithURL, inURL);
OS.CFRelease(inURL);
- //mainFrame = [webView mainFrame];
- int mainFrame = Cocoa.objc_msgSend(webView, Cocoa.S_mainFrame);
+ if (postData != null) {
+ int post = createNSString(POST);
+ Cocoa.objc_msgSend(request, Cocoa.S_setHTTPMethod, post);
+ OS.CFRelease (post);
+ byte[] bytes = postData.getBytes();
+ int data = Cocoa.objc_msgSend(Cocoa.C_NSData, Cocoa.S_dataWithBytes, bytes, bytes.length);
+ Cocoa.objc_msgSend(request, Cocoa.S_setHTTPBody, data);
+ }
+ if (headers != null) {
+ for (int i = 0; i < headers.length; i++) {
+ String current = headers[i];
+ int index = current.indexOf(':');
+ if (index != -1) {
+ String key = current.substring(0, index).trim();
+ String value = current.substring(index + 1).trim();
+ if (key.length() > 0 && value.length() > 0) {
+ if (key.equals(USER_AGENT)) {
+ /*
+ * Feature of Safari. The user-agent header value cannot be overridden
+ * here. The workaround is to temporarily set the value on the WebView
+ * and then remove it after the loading of the request has begun.
+ */
+ int string = createNSString(value);
+ Cocoa.objc_msgSend(webView, Cocoa.S_setCustomUserAgent, string);
+ OS.CFRelease (string);
+ } else {
+ int keyString = createNSString(key);
+ int valueString = createNSString(value);
+ Cocoa.objc_msgSend(request, Cocoa.S_setValueForHTTPHeaderField, keyString, valueString);
+ OS.CFRelease (valueString);
+ OS.CFRelease (keyString);
+ }
+ }
+ }
+ }
+ }
- //[mainFrame loadRequest:request];
+ int mainFrame = Cocoa.objc_msgSend(webView, Cocoa.S_mainFrame);
Cocoa.objc_msgSend(mainFrame, Cocoa.S_loadRequest, request);
-
+ Cocoa.objc_msgSend(webView, Cocoa.S_setCustomUserAgent, 0);
return true;
}
@@ -989,19 +1000,11 @@ void hookDOMFocusListeners(int frame) {
int document = Cocoa.objc_msgSend(frame, Cocoa.S_DOMDocument);
if (document == 0) return;
- String string = DOMEVENT_FOCUSIN;
- int length = string.length();
- char[] chars = new char[length];
- string.getChars(0, length, chars, 0);
- int ptr = OS.CFStringCreateWithCharacters(0, chars, length);
+ int ptr = createNSString(DOMEVENT_FOCUSIN);
Cocoa.objc_msgSend(document, Cocoa.S_addEventListener, ptr, delegate, 0);
OS.CFRelease(ptr);
- string = DOMEVENT_FOCUSOUT;
- length = string.length();
- chars = new char[length];
- string.getChars(0, length, chars, 0);
- ptr = OS.CFStringCreateWithCharacters(0, chars, length);
+ ptr = createNSString(DOMEVENT_FOCUSOUT);
Cocoa.objc_msgSend(document, Cocoa.S_addEventListener, ptr, delegate, 0);
OS.CFRelease(ptr);
}
@@ -1016,19 +1019,11 @@ void hookDOMKeyListeners(int frame) {
int document = Cocoa.objc_msgSend(frame, Cocoa.S_DOMDocument);
if (document == 0) return;
- String string = DOMEVENT_KEYDOWN;
- int length = string.length();
- char[] chars = new char[length];
- string.getChars(0, length, chars, 0);
- int ptr = OS.CFStringCreateWithCharacters(0, chars, length);
+ int ptr = createNSString(DOMEVENT_KEYDOWN);
Cocoa.objc_msgSend(document, Cocoa.S_addEventListener, ptr, delegate, 0);
OS.CFRelease(ptr);
- string = DOMEVENT_KEYUP;
- length = string.length();
- chars = new char[length];
- string.getChars(0, length, chars, 0);
- ptr = OS.CFStringCreateWithCharacters(0, chars, length);
+ ptr = createNSString(DOMEVENT_KEYUP);
Cocoa.objc_msgSend(document, Cocoa.S_addEventListener, ptr, delegate, 0);
OS.CFRelease(ptr);
}
@@ -1043,35 +1038,19 @@ void hookDOMMouseListeners(int frame) {
int document = Cocoa.objc_msgSend(frame, Cocoa.S_DOMDocument);
if (document == 0) return;
- String string = DOMEVENT_MOUSEDOWN;
- int length = string.length();
- char[] chars = new char[length];
- string.getChars(0, length, chars, 0);
- int ptr = OS.CFStringCreateWithCharacters(0, chars, length);
+ int ptr = createNSString(DOMEVENT_MOUSEDOWN);
Cocoa.objc_msgSend(document, Cocoa.S_addEventListener, ptr, delegate, 0);
OS.CFRelease(ptr);
- string = DOMEVENT_MOUSEUP;
- length = string.length();
- chars = new char[length];
- string.getChars(0, length, chars, 0);
- ptr = OS.CFStringCreateWithCharacters(0, chars, length);
+ ptr = createNSString(DOMEVENT_MOUSEUP);
Cocoa.objc_msgSend(document, Cocoa.S_addEventListener, ptr, delegate, 0);
OS.CFRelease(ptr);
- string = DOMEVENT_MOUSEMOVE;
- length = string.length();
- chars = new char[length];
- string.getChars(0, length, chars, 0);
- ptr = OS.CFStringCreateWithCharacters(0, chars, length);
+ ptr = createNSString(DOMEVENT_MOUSEMOVE);
Cocoa.objc_msgSend(document, Cocoa.S_addEventListener, ptr, delegate, 0);
OS.CFRelease(ptr);
- string = DOMEVENT_MOUSEWHEEL;
- length = string.length();
- chars = new char[length];
- string.getChars(0, length, chars, 0);
- ptr = OS.CFStringCreateWithCharacters(0, chars, length);
+ ptr = createNSString(DOMEVENT_MOUSEWHEEL);
Cocoa.objc_msgSend(document, Cocoa.S_addEventListener, ptr, delegate, 0);
OS.CFRelease(ptr);
}
@@ -1171,10 +1150,7 @@ void didCommitLoadForFrame(int frame) {
}
void windowScriptObjectAvailable (int windowScriptObject) {
- String objectName = "external"; //$NON-NLS-1$
- char[] chars = new char[objectName.length ()];
- objectName.getChars (0, chars.length, chars, 0);
- int str = OS.CFStringCreateWithCharacters (0, chars, chars.length);
+ int str = createNSString("external"); //$NON-NLS-1$
if (str != 0) {
Cocoa.objc_msgSend (windowScriptObject, Cocoa.S_setValue, delegate, str);
OS.CFRelease (str);
@@ -1238,14 +1214,8 @@ void didReceiveAuthenticationChallengefromDataSource (int identifier, int challe
}
if (event.user != null && event.password != null) {
int challengeSender = Cocoa.objc_msgSend (challenge, Cocoa.S_sender);
- int length = event.user.length ();
- char[] buffer = new char[length];
- event.user.getChars (0, length, buffer, 0);
- int user = OS.CFStringCreateWithCharacters (0, buffer, length);
- length = event.password.length ();
- buffer = new char[length];
- event.password.getChars (0, length, buffer, 0);
- int password = OS.CFStringCreateWithCharacters (0, buffer, length);
+ int user = createNSString(event.user);
+ int password = createNSString(event.password);
int credential = Cocoa.objc_msgSend (Cocoa.C_NSURLCredential, Cocoa.S_credentialWithUser, user, password, Cocoa.NSURLCredentialPersistenceForSession);
Cocoa.objc_msgSend (challengeSender, Cocoa.S_useCredential, credential, challenge);
OS.CFRelease (password);
@@ -1296,14 +1266,8 @@ void didReceiveAuthenticationChallengefromDataSource (int identifier, int challe
return;
}
- int length = userReturn[0].length ();
- char[] buffer = new char[length];
- userReturn[0].getChars (0, length, buffer, 0);
- int user = OS.CFStringCreateWithCharacters (0, buffer, length);
- length = passwordReturn[0].length ();
- buffer = new char[length];
- passwordReturn[0].getChars (0, length, buffer, 0);
- int password = OS.CFStringCreateWithCharacters (0, buffer, length);
+ int user = createNSString(userReturn[0]);
+ int password = createNSString(passwordReturn[0]);
int credential = Cocoa.objc_msgSend (Cocoa.C_NSURLCredential, Cocoa.S_credentialWithUser, user, password, Cocoa.NSURLCredentialPersistenceForSession);
Cocoa.objc_msgSend (challengeSender, Cocoa.S_useCredential, credential, challenge);
OS.CFRelease (password);
@@ -1569,10 +1533,7 @@ void runOpenPanelForFileButtonWithResultListener(int resultListener) {
Cocoa.objc_msgSend(resultListener, Cocoa.S_cancel);
return;
}
- int length = result.length();
- char[] buffer = new char[length];
- result.getChars(0, length, buffer, 0);
- int filename = OS.CFStringCreateWithCharacters(0, buffer, length);
+ int filename = createNSString(result);
Cocoa.objc_msgSend(resultListener, Cocoa.S_chooseFilename, filename);
OS.CFRelease(filename);
}
@@ -1655,10 +1616,7 @@ void mouseDidMoveOverElement (int elementInformation, int modifierFlags) {
if (elementInformation == 0) return;
if (!browser.isEnabled ()) return;
- int length = WebElementLinkURLKey.length();
- char[] chars = new char[length];
- WebElementLinkURLKey.getChars(0, length, chars, 0);
- int key = OS.CFStringCreateWithCharacters(0, chars, length);
+ int key = createNSString(WebElementLinkURLKey);
int value = Cocoa.objc_msgSend(elementInformation, Cocoa.S_valueForKey, key);
OS.CFRelease(key);
if (value == 0) {
@@ -1676,12 +1634,12 @@ void mouseDidMoveOverElement (int elementInformation, int modifierFlags) {
}
int stringPtr = Cocoa.objc_msgSend(value, Cocoa.S_absoluteString);
- length = OS.CFStringGetLength(stringPtr);
+ int length = OS.CFStringGetLength(stringPtr);
String urlString;
if (length == 0) {
urlString = ""; //$NON-NLS-1$
} else {
- chars = new char[length];
+ char[] chars = new char[length];
CFRange range = new CFRange();
range.length = length;
OS.CFStringGetCharacters(stringPtr, range, chars);
@@ -1829,10 +1787,7 @@ void decideDestinationWithSuggestedFilename (int download, int filename) {
Cocoa.objc_msgSend(download, Cocoa.S_cancel);
return;
}
- length = path.length();
- char[] chars = new char[length];
- path.getChars(0, length, chars, 0);
- int result = OS.CFStringCreateWithCharacters(0, chars, length);
+ int result = createNSString(path);
Cocoa.objc_msgSend(download, Cocoa.S_setDestinationAllowOverwrite, result, 1);
OS.CFRelease(result);
}
@@ -1995,10 +1950,7 @@ Object convertToJava (int value) {
}
}
if (Cocoa.objc_msgSend (value, Cocoa.S_isKindOfClass, Cocoa.C_WebScriptObject) != 0) {
- String string = "length"; //$NON-NLS-1$
- char[] chars = new char[string.length ()];
- string.getChars (0, chars.length, chars, 0);
- int str = OS.CFStringCreateWithCharacters (0, chars, chars.length);
+ int str = createNSString ("length"); //$NON-NLS-1$
int numberValue = Cocoa.objc_msgSend (value, Cocoa.S_valueForKey, str);
OS.CFRelease (str);
int length = Cocoa.objc_msgSend (numberValue, Cocoa.S_intValue);
@@ -2024,10 +1976,7 @@ int convertToJS (Object value) {
return Cocoa.objc_msgSend (Cocoa.C_WebUndefined, Cocoa.S_undefined);
}
if (value instanceof String) {
- String result = (String)value;
- char[] chars = new char[result.length ()];
- result.getChars (0, chars.length, chars, 0);
- return OS.CFStringCreateWithCharacters (0, chars, chars.length);
+ return createNSString((String)value);
}
if (value instanceof Boolean) {
int booleanValue = ((Boolean)value).booleanValue () ? 1 : 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java
index 9840ba4552..98348e136f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa/org/eclipse/swt/browser/Safari.java
@@ -50,6 +50,8 @@ class Safari extends WebBrowser {
static final String PROTOCOL_HTTP = "http://"; //$NON-NLS-1$
static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
static final String HEADER_SETCOOKIE = "Set-Cookie"; //$NON-NLS-1$
+ static final String POST = "POST"; //$NON-NLS-1$
+ static final String USER_AGENT = "user-agent"; //$NON-NLS-1$
static final String ADD_WIDGET_KEY = "org.eclipse.swt.internal.addWidget"; //$NON-NLS-1$
static final String SAFARI_EVENTS_FIX_KEY = "org.eclipse.swt.internal.safariEventsFix"; //$NON-NLS-1$
static final byte[] SWT_OBJECT = {'S', 'W', 'T', '_', 'O', 'B', 'J', 'E', 'C', 'T', '\0'};
@@ -501,7 +503,7 @@ void _setText(String html) {
mainFrame.loadHTMLString(string, URL);
}
-public boolean setUrl(String url) {
+public boolean setUrl(String url, String postData, String[] headers) {
html = null;
if (url.indexOf('/') == 0) {
@@ -516,9 +518,38 @@ public boolean setUrl(String url) {
NSString escapedString = new NSString(ptr);
NSURL inURL = NSURL.URLWithString(escapedString);
OS.CFRelease(ptr);
- NSURLRequest request = NSURLRequest.requestWithURL(inURL);
+ NSMutableURLRequest request = (NSMutableURLRequest)NSMutableURLRequest.requestWithURL(inURL);
+ if (postData != null) {
+ request.setHTTPMethod(NSString.stringWith(POST));
+ byte[] bytes = postData.getBytes();
+ NSData data = NSData.dataWithBytes(bytes, bytes.length);
+ request.setHTTPBody(data);
+ }
+ if (headers != null) {
+ for (int i = 0; i < headers.length; i++) {
+ String current = headers[i];
+ int index = current.indexOf(':');
+ if (index != -1) {
+ String key = current.substring(0, index).trim();
+ String value = current.substring(index + 1).trim();
+ if (key.length() > 0 && value.length() > 0) {
+ if (key.equals(USER_AGENT)) {
+ /*
+ * Feature of Safari. The user-agent header value cannot be overridden
+ * here. The workaround is to temporarily set the value on the WebView
+ * and then remove it after the loading of the request has begun.
+ */
+ webView.setCustomUserAgent(NSString.stringWith(value));
+ } else {
+ request.setValue(NSString.stringWith(value), NSString.stringWith(key));
+ }
+ }
+ }
+ }
+ }
WebFrame mainFrame = webView.mainFrame();
mainFrame.loadRequest(request);
+ webView.setCustomUserAgent(null);
return true;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java
index ae2b1e7415..bd96efab5f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java
@@ -999,8 +999,13 @@ public boolean setText (String html) {
*/
public boolean setUrl (String url) {
checkWidget();
+ return setUrl (url, null, null);
+}
+
+public boolean setUrl (String url, String postData, String[] headers) {
+ checkWidget();
if (url == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- return webBrowser.setUrl (url);
+ return webBrowser.setUrl (url, postData, headers);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java
index d3ef6d863c..01018ff050 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java
@@ -589,7 +589,7 @@ public void setBrowser (Browser browser) {
public abstract boolean setText (String html);
-public abstract boolean setUrl (String url);
+public abstract boolean setUrl (String url, String postData, String[] headers);
public abstract void stop ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/forms/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/forms/org/eclipse/swt/browser/IE.java
index 4a52398af0..03c61fd09e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/forms/org/eclipse/swt/browser/IE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/forms/org/eclipse/swt/browser/IE.java
@@ -260,7 +260,7 @@ public boolean setText(String html) {
return true;
}
-public boolean setUrl(String url) {
+public boolean setUrl(String url, String postData, String[] headers) {
int state = OS.WebBrowser_ReadyState(webBrowser);
if (!(state == OS.WebBrowserReadyState_Uninitialized || state == OS.WebBrowserReadyState_Complete)) {
OS.WebBrowser_Stop(webBrowser);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/photon/org/eclipse/swt/browser/Voyager.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/photon/org/eclipse/swt/browser/Voyager.java
index 075ac65fe5..2354716706 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/photon/org/eclipse/swt/browser/Voyager.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/photon/org/eclipse/swt/browser/Voyager.java
@@ -454,7 +454,7 @@ public boolean setText(String html) {
return true;
}
-public boolean setUrl(String url) {
+public boolean setUrl(String url, String postData, String[] headers) {
byte[] buffer = Converter.wcsToMbcs(null, url, true);
int ptr = OS.malloc(buffer.length);
OS.memmove(ptr, buffer, buffer.length);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
index 8c9b44528e..ae1d79705b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
@@ -14,6 +14,7 @@ import java.util.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.C;
import org.eclipse.swt.internal.ole.win32.*;
import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.ole.win32.*;
@@ -517,7 +518,7 @@ public void create(Composite parent, int style) {
* UNC first segment has been successfully navigated,
* now redirect to the full UNC path.
*/
- navigate(uncRedirect, true);
+ navigate(uncRedirect, null, null, true);
break;
}
uncRedirect = null;
@@ -580,7 +581,7 @@ public void create(Composite parent, int style) {
} else {
uncRedirect = url;
}
- navigate(host, true);
+ navigate(host, null, null, true);
}
});
}
@@ -884,6 +885,34 @@ public boolean close() {
return result;
}
+static Variant createSafeArray(String string) {
+ /* Create a pointer and copy the data into it */
+ byte[] bytes = string.getBytes();
+ int length = bytes.length;
+ int /*long*/ pvData = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, length);
+ C.memmove(pvData, bytes, length);
+ int cElements1 = length;
+
+ /* Create a SAFEARRAY in memory */
+ int /*long*/ pSafeArray = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, SAFEARRAY.sizeof);
+ SAFEARRAY safeArray = new SAFEARRAY();
+ safeArray.cDims = 1;
+ safeArray.fFeatures = OS.FADF_FIXEDSIZE | OS.FADF_HAVEVARTYPE;
+ safeArray.cbElements = 1;
+ safeArray.pvData = pvData;
+ SAFEARRAYBOUND safeArrayBound = new SAFEARRAYBOUND();
+ safeArray.rgsabound = safeArrayBound;
+ safeArrayBound.cElements = cElements1;
+ OS.MoveMemory (pSafeArray, safeArray, SAFEARRAY.sizeof);
+
+ /* Return a Variant that holds the SAFEARRAY */
+ int /*long*/ pVariant = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
+ short vt = (short)(OLE.VT_ARRAY | OLE.VT_UI1);
+ OS.MoveMemory(pVariant, new short[] {vt}, 2);
+ OS.MoveMemory(pVariant + 8, new int /*long*/[] {pSafeArray}, C.PTR_SIZEOF);
+ return new Variant(pVariant, (short)(OLE.VT_BYREF | OLE.VT_VARIANT));
+}
+
public boolean execute(String script) {
/* get IHTMLDocument2 */
int[] rgdispid = auto.getIDsOfNames(new String[]{"Document"}); //$NON-NLS-1$
@@ -999,6 +1028,59 @@ public boolean isFocusControl () {
return site.isFocusControl() || frame.isFocusControl();
}
+boolean navigate(String url, String postData, String headers[], boolean silent) {
+ navigate = true;
+ int count = 1;
+ if (postData != null) count++;
+ if (headers != null) count++;
+ Variant[] rgvarg = new Variant[count];
+ int[] rgdispidNamedArgs = new int[count];
+ int[] rgdispid = auto.getIDsOfNames(new String[] { "Navigate", "URL", "PostData", "Headers" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ int index = 0;
+ rgvarg[index] = new Variant(url);
+ rgdispidNamedArgs[index++] = rgdispid[1];
+ if (postData != null) {
+ rgvarg[index] = createSafeArray(postData);
+ rgdispidNamedArgs[index++] = rgdispid[2];
+ }
+ if (headers != null) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < headers.length; i++) {
+ String current = headers[i];
+ int sep = current.indexOf(':');
+ if (sep != -1) {
+ String key = current.substring(0, sep).trim();
+ String value = current.substring(sep + 1).trim();
+ if (key.length() > 0 && value.length() > 0) {
+ buffer.append(key);
+ buffer.append(':');
+ buffer.append(value);
+ buffer.append("\r\n");
+ }
+ }
+ }
+ rgvarg[index] = new Variant(buffer.toString());
+ rgdispidNamedArgs[index++] = rgdispid[3];
+ }
+ boolean oldValue = false;
+ if (silent && !OS.IsWinCE && IsIE7) {
+ int hResult = OS.CoInternetIsFeatureEnabled(OS.FEATURE_DISABLE_NAVIGATION_SOUNDS, OS.GET_FEATURE_FROM_PROCESS);
+ oldValue = hResult == COM.S_OK;
+ OS.CoInternetSetFeatureEnabled(OS.FEATURE_DISABLE_NAVIGATION_SOUNDS, OS.SET_FEATURE_ON_PROCESS, true);
+ }
+ Variant pVarResult = auto.invoke(rgdispid[0], rgvarg, rgdispidNamedArgs);
+ if (silent && !OS.IsWinCE && IsIE7) {
+ OS.CoInternetSetFeatureEnabled(OS.FEATURE_DISABLE_NAVIGATION_SOUNDS, OS.SET_FEATURE_ON_PROCESS, oldValue);
+ }
+ for (int i = 0; i < count; i++) {
+ rgvarg[i].dispose();
+ }
+ if (pVarResult == null) return false;
+ boolean result = pVarResult.getType() == OLE.VT_EMPTY;
+ pVarResult.dispose();
+ return result;
+}
+
public void refresh() {
uncRedirect = null;
int[] rgdispid = auto.getIDsOfNames(new String[] { "Refresh" }); //$NON-NLS-1$
@@ -1156,31 +1238,7 @@ public boolean setText(final String html) {
return result;
}
-boolean navigate(String url, boolean silent) {
- navigate = true;
- int[] rgdispid = auto.getIDsOfNames(new String[] { "Navigate", "URL" }); //$NON-NLS-1$ //$NON-NLS-2$
- Variant[] rgvarg = new Variant[1];
- rgvarg[0] = new Variant(url);
- int[] rgdispidNamedArgs = new int[1];
- rgdispidNamedArgs[0] = rgdispid[1];
- boolean oldValue = false;
- if (silent && !OS.IsWinCE && IsIE7) {
- int hResult = OS.CoInternetIsFeatureEnabled(OS.FEATURE_DISABLE_NAVIGATION_SOUNDS, OS.GET_FEATURE_FROM_PROCESS);
- oldValue = hResult == COM.S_OK;
- OS.CoInternetSetFeatureEnabled(OS.FEATURE_DISABLE_NAVIGATION_SOUNDS, OS.SET_FEATURE_ON_PROCESS, true);
- }
- Variant pVarResult = auto.invoke(rgdispid[0], rgvarg, rgdispidNamedArgs);
- if (silent && !OS.IsWinCE && IsIE7) {
- OS.CoInternetSetFeatureEnabled(OS.FEATURE_DISABLE_NAVIGATION_SOUNDS, OS.SET_FEATURE_ON_PROCESS, oldValue);
- }
- rgvarg[0].dispose();
- if (pVarResult == null) return false;
- boolean result = pVarResult.getType() == OLE.VT_EMPTY;
- pVarResult.dispose();
- return result;
-}
-
-public boolean setUrl(String url) {
+public boolean setUrl(String url, String postData, String headers[]) {
html = uncRedirect = null;
/*
@@ -1198,12 +1256,12 @@ public boolean setUrl(String url) {
* issuing Stop so that the 'Action cancelled' page is not displayed.
*/
if (!navigate) {
- navigate (ABOUT_BLANK, true);
+ navigate (ABOUT_BLANK, null, null, true);
}
int[] rgdispid = auto.getIDsOfNames(new String[] { "Stop" }); //$NON-NLS-1$
auto.invoke(rgdispid[0]);
}
- return navigate(url, false);
+ return navigate(url, postData, headers, false);
}
public void stop() {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/wpf/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/wpf/org/eclipse/swt/browser/IE.java
index babe61d6af..7d4708b294 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/wpf/org/eclipse/swt/browser/IE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/wpf/org/eclipse/swt/browser/IE.java
@@ -201,7 +201,7 @@ public boolean setText(String html) {
// return result;
}
-public boolean setUrl(String url) {
+public boolean setUrl(String url, String postData, String[] headers) {
if (url.indexOf(':') == -1) url = "http://" + url;
int length = url.length ();
char [] buffer = new char [length + 1];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/InputStream.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/InputStream.java
index 3440fbbd0f..3a5e3add6e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/InputStream.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/InputStream.java
@@ -108,7 +108,10 @@ int Read(int /*long*/ aBuf, int aCount, int /*long*/ _retval) {
}
int ReadSegments (int /*long*/ aWriter, int /*long*/ aClosure, int aCount, int /*long*/ _retval) {
- int max = Math.min (aCount, buffer == null ? 0 : buffer.length - index);
+ int max = buffer == null ? 0 : buffer.length - index;
+ if (aCount != -1) {
+ max = Math.min (max, aCount);
+ }
int cnt = max;
while (cnt > 0) {
int[] aWriteCount = new int[1];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
index db4aff4613..0c671997c1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
@@ -72,6 +72,8 @@ class Mozilla extends WebBrowser {
static final String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$
static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
static final String DISPOSE_LISTENER_HOOKED = "org.eclipse.swt.browser.Mozilla.disposeListenerHooked"; //$NON-NLS-1$
+ static final String HEADER_CONTENTTYPE = "Content-Type"; //$NON-NLS-1
+ static final String MIMETYPE_FORMURLENCODED = "application/x-www-form-urlencoded"; //$NON-NLS-1$
static final String PREFIX_JAVASCRIPT = "javascript:"; //$NON-NLS-1$
static final String PREFERENCE_CHARSET = "intl.charset.default"; //$NON-NLS-1$
static final String PREFERENCE_DISABLEOPENDURINGLOAD = "dom.disable_open_during_load"; //$NON-NLS-1$
@@ -2373,7 +2375,7 @@ public boolean setText (String html) {
return true;
}
-public boolean setUrl (String url) {
+public boolean setUrl (String url, String postData, String[] headers) {
htmlBytes = null;
int /*long*/[] result = new int /*long*/[1];
@@ -2389,9 +2391,69 @@ public boolean setUrl (String url) {
delegate.removeWindowSubclass ();
nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+ result[0] = 0;
char[] uri = new char[url.length () + 1];
url.getChars (0, url.length (), uri, 0);
- rc = webNavigation.LoadURI (uri, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0);
+
+ nsIMIMEInputStream postDataStream = null;
+ InputStream dataStream = null;
+ if (postData != null) {
+ rc = XPCOM.NS_GetComponentManager (result);
+ if (rc != XPCOM.NS_OK) error (rc);
+ if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+ nsIComponentManager componentManager = new nsIComponentManager (result[0]);
+ result[0] = 0;
+ byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MIMEINPUTSTREAM_CONTRACTID, true);
+ rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIMIMEInputStream.NS_IMIMEINPUTSTREAM_IID, result);
+ componentManager.Release();
+
+ if (rc == XPCOM.NS_OK && result[0] != 0) { /* nsIMIMEInputStream is not in mozilla 1.4 */
+ byte[] bytes = MozillaDelegate.wcsToMbcs (null, postData, false);
+ dataStream = new InputStream (bytes);
+ dataStream.AddRef ();
+ postDataStream = new nsIMIMEInputStream (result[0]);
+ rc = postDataStream.SetData (dataStream.getAddress ());
+ if (rc != XPCOM.NS_OK) error (rc);
+ rc = postDataStream.SetAddContentLength (1);
+ if (rc != XPCOM.NS_OK) error (rc);
+ byte[] name = MozillaDelegate.wcsToMbcs (null, HEADER_CONTENTTYPE, true);
+ byte[] value = MozillaDelegate.wcsToMbcs (null, MIMETYPE_FORMURLENCODED, true);
+ rc = postDataStream.AddHeader (name, value);
+ if (rc != XPCOM.NS_OK) error (rc);
+ }
+ result[0] = 0;
+ }
+
+ InputStream headersStream = null;
+ if (headers != null) {
+ StringBuffer buffer = new StringBuffer ();
+ for (int i = 0; i < headers.length; i++) {
+ String current = headers[i];
+ int sep = current.indexOf (':');
+ if (sep != -1) {
+ String key = current.substring (0, sep).trim ();
+ String value = current.substring (sep + 1).trim ();
+ if (key.length () > 0 && value.length () > 0) {
+ buffer.append (key);
+ buffer.append (':');
+ buffer.append (value);
+ buffer.append ("\r\n");
+ }
+ }
+ }
+ byte[] bytes = MozillaDelegate.wcsToMbcs (null, buffer.toString (), true);
+ headersStream = new InputStream (bytes);
+ headersStream.AddRef ();
+ }
+
+ rc = webNavigation.LoadURI (
+ uri,
+ nsIWebNavigation.LOAD_FLAGS_NONE,
+ 0,
+ postDataStream == null ? 0 : postDataStream.getAddress (),
+ headersStream == null ? 0 : headersStream.getAddress ());
+ if (dataStream != null) dataStream.Release ();
+ if (headersStream != null) headersStream.Release ();
webNavigation.Release ();
return rc == XPCOM.NS_OK;
}
@@ -3408,7 +3470,7 @@ int OnStartURIOpen (int /*long*/ aURI, int /*long*/ retval) {
if (value.indexOf ("aboutCertError.xhtml") != -1 || (isViewingErrorPage && value.indexOf ("javascript:showSecuritySection") != -1)) { //$NON-NLS-1$ //$NON-NLS-2$
XPCOM.memmove (retval, new int[] {1}, 4); /* PRBool */
isRetrievingBadCert = true;
- setUrl (lastNavigateURL);
+ setUrl (lastNavigateURL, null, null);
return XPCOM.NS_OK;
}
isViewingErrorPage = value.indexOf ("netError.xhtml") != -1; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java
index f474386816..4e6c714f7c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java
@@ -72,6 +72,7 @@ public class XPCOM extends C {
public static final String NS_FILEPICKER_CONTRACTID = "@mozilla.org/filepicker;1"; //$NON-NLS-1$
public static final String NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID = "@mozilla.org/helperapplauncherdialog;1"; //$NON-NLS-1$
public static final String NS_MEMORY_CONTRACTID = "@mozilla.org/xpcom/memory-service;1"; //$NON-NLS-1$
+ public static final String NS_MIMEINPUTSTREAM_CONTRACTID = "@mozilla.org/network/mime-input-stream;1"; //$NON-NLS-1$
public static final String NS_SCRIPTSECURITYMANAGER_CONTRACTID = "@mozilla.org/scriptsecuritymanager;1"; //$NON-NLS-1$
public static final String NS_OBSERVER_CONTRACTID = "@mozilla.org/observer-service;1"; //$NON-NLS-1$
public static final String NS_PREFLOCALIZEDSTRING_CONTRACTID = "@mozilla.org/pref-localizedstring;1"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIMIMEInputStream.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIMIMEInputStream.java
new file mode 100644
index 0000000000..2d1d44e25f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIMIMEInputStream.java
@@ -0,0 +1,59 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * - Binding to permit interfacing between Mozilla and SWT
+ * - Copyright (C) 2003, 2009 IBM Corp. All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIMIMEInputStream extends nsIInputStream {
+
+ static final int LAST_METHOD_ID = nsIInputStream.LAST_METHOD_ID + 4;
+
+ public static final String NS_IMIMEINPUTSTREAM_IID_STR =
+ "dcbce63c-1dd1-11b2-b94d-91f6d49a3161";
+
+ public static final nsID NS_IMIMEINPUTSTREAM_IID =
+ new nsID(NS_IMIMEINPUTSTREAM_IID_STR);
+
+ public nsIMIMEInputStream(int /*long*/ address) {
+ super(address);
+ }
+
+ public int GetAddContentLength(int[] aAddContentLength) {
+ return XPCOM.VtblCall(nsIInputStream.LAST_METHOD_ID + 1, getAddress(), aAddContentLength);
+ }
+
+ public int SetAddContentLength(int aAddContentLength) {
+ return XPCOM.VtblCall(nsIInputStream.LAST_METHOD_ID + 2, getAddress(), aAddContentLength);
+ }
+
+ public int AddHeader(byte[] name, byte[] value) {
+ return XPCOM.VtblCall(nsIInputStream.LAST_METHOD_ID + 3, getAddress(), name, value);
+ }
+
+ public int SetData(int /*long*/ stream) {
+ return XPCOM.VtblCall(nsIInputStream.LAST_METHOD_ID + 4, getAddress(), stream);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa.c b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa.c
index 0609152d1f..d870730deb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa.c
@@ -419,6 +419,22 @@ fail:
}
#endif
+#ifndef NO_objc_1msgSend__II_3BI
+JNIEXPORT jint JNICALL Cocoa_NATIVE(objc_1msgSend__II_3BI)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3)
+{
+ jbyte *lparg2=NULL;
+ jint rc = 0;
+ Cocoa_NATIVE_ENTER(env, that, objc_1msgSend__II_3BI_FUNC);
+ if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ rc = (jint)((jint (*)(jint, jint, jbyte *, jint))objc_msgSend)(arg0, arg1, lparg2, arg3);
+fail:
+ if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ Cocoa_NATIVE_EXIT(env, that, objc_1msgSend__II_3BI_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_objc_1msgSend__II_3C
JNIEXPORT jint JNICALL Cocoa_NATIVE(objc_1msgSend__II_3C)
(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa_stats.c
index 71c8ec334c..d967f7dff9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa_stats.c
@@ -14,8 +14,8 @@
#ifdef NATIVE_STATS
-int Cocoa_nativeFunctionCount = 35;
-int Cocoa_nativeFunctionCallCount[35];
+int Cocoa_nativeFunctionCount = 36;
+int Cocoa_nativeFunctionCallCount[36];
char * Cocoa_nativeFunctionNames[] = {
"HICocoaViewCreate",
"HIJavaViewCreateWithCocoaView",
@@ -46,6 +46,7 @@ char * Cocoa_nativeFunctionNames[] = {
"objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2I",
"objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2II",
"objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSSize_2",
+ "objc_1msgSend__II_3BI",
"objc_1msgSend__II_3C",
"objc_1msgSend__II_3IIIIIIIIIII",
"objc_1msgSend_1fpret",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa_stats.h
index 18345a3cb8..6d8ba07b33 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/cocoa_stats.h
@@ -54,6 +54,7 @@ typedef enum {
objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2I_FUNC,
objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSRect_2II_FUNC,
objc_1msgSend__IILorg_eclipse_swt_internal_cocoa_NSSize_2_FUNC,
+ objc_1msgSend__II_3BI_FUNC,
objc_1msgSend__II_3C_FUNC,
objc_1msgSend__II_3IIIIIIIIIII_FUNC,
objc_1msgSend_1fpret_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java
index 6db28d1634..9e3fa3eaac 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java
@@ -25,7 +25,7 @@ public static final int C_NSHTTPCookieStorage = Cocoa.objc_getClass("NSHTTPCooki
public static final int C_NSNotificationCenter = Cocoa.objc_getClass("NSNotificationCenter"); //$NON-NLS-1$
public static final int C_NSNumber = Cocoa.objc_getClass("NSNumber"); //$NON-NLS-1$
public static final int C_NSURL = Cocoa.objc_getClass("NSURL"); //$NON-NLS-1$
-public static final int C_NSURLRequest = Cocoa.objc_getClass("NSURLRequest"); //$NON-NLS-1$
+public static final int C_NSMutableURLRequest = Cocoa.objc_getClass("NSMutableURLRequest"); //$NON-NLS-1$
public static final int C_NSURLCredential = Cocoa.objc_getClass("NSURLCredential"); //$NON-NLS-1$
public static final int C_WebKitDelegate = Cocoa.objc_getClass("WebKitDelegate"); //$NON-NLS-1$
public static final int C_WebDownload = Cocoa.objc_getClass("WebDownload"); //$NON-NLS-1$
@@ -49,6 +49,7 @@ public static final int C_NSMutableDictionary = Cocoa.objc_getClass("NSMutableDi
public static final int C_WebPanelAuthenticationHandler = Cocoa.objc_getClass("WebPanelAuthenticationHandler"); //$NON-NLS-1$
public static final int C_WebScriptObject = Cocoa.objc_getClass("WebScriptObject"); //$NON-NLS-1$
public static final int C_WebUndefined = Cocoa.objc_getClass("WebUndefined"); //$NON-NLS-1$
+public static final int C_NSData = Cocoa.objc_getClass("NSData"); //$NON-NLS-1$
/* Objective-C method selectors */
public static final int S_absoluteString = Cocoa.sel_registerName("absoluteString"); //$NON-NLS-1$
@@ -72,6 +73,7 @@ public static final int S_copy = Cocoa.sel_registerName("copy:"); //$NON-NLS-1$
public static final int S_count = Cocoa.sel_registerName("count"); //$NON-NLS-1$
public static final int S_credentialWithUser = Cocoa.sel_registerName("credentialWithUser:password:persistence:"); //$NON-NLS-1$
public static final int S_cut = Cocoa.sel_registerName("cut:"); //$NON-NLS-1$
+public static final int S_dataWithBytes = Cocoa.sel_registerName("dataWithBytes:length:"); //$NON-NLS-1$
public static final int S_dataSource = Cocoa.sel_registerName("dataSource"); //$NON-NLS-1$
public static final int S_defaultCenter = Cocoa.sel_registerName("defaultCenter"); //$NON-NLS-1$
public static final int S_deleteCookie = Cocoa.sel_registerName("deleteCookie:"); //$NON-NLS-1$
@@ -217,6 +219,10 @@ public static final int S_getCharacters_ = Cocoa.sel_registerName("getCharacters
public static final int S_objCType = Cocoa.sel_registerName("objCType"); //$NON-NLS-1$
public static final int S_setPreferences = Cocoa.sel_registerName("setPreferences:"); //$NON-NLS-1$
public static final int S_value = Cocoa.sel_registerName("value"); //$NON-NLS-1$
+public static final int S_setHTTPBody = Cocoa.sel_registerName("setHTTPBody:"); //$NON-NLS-1$
+public static final int S_setHTTPMethod = Cocoa.sel_registerName("setHTTPMethod:"); //$NON-NLS-1$
+public static final int S_setCustomUserAgent = Cocoa.sel_registerName("setCustomUserAgent:"); //$NON-NLS-1$
+public static final int S_setValueForHTTPHeaderField = Cocoa.sel_registerName("setValue:forHTTPHeaderField:"); //$NON-NLS-1$
public static final int NSAlphaFirstBitmapFormat = 1 << 0;
public static final int NSAlphaNonpremultipliedBitmapFormat = 1 << 1;
@@ -287,6 +293,8 @@ public static final native int objc_msgSend(int object, int selector, float arg0
public static final native int objc_msgSend(int object, int selector, double arg0);
/** @method flags=cast */
public static final native int objc_msgSend(int object, int selector, char[] arg0);
+/** @method flags=cast */
+public static final native int objc_msgSend(int object, int selector, byte[] arg0, int arg1);
/**
* @method flags=cast
* @param object cast=(id)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
index 5edb6b7d9d..f924634400 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
@@ -548,10 +548,23 @@
<arg name="policy" swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
+ <method selector="setHTTPBody:" swt_gen="true">
+ <arg name="data" swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
+ <method selector="setHTTPMethod:" swt_gen="true">
+ <arg name="method" swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="setURL:" swt_gen="true">
<arg name="URL" swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
+ <method selector="setValue:forHTTPHeaderField:" swt_gen="true">
+ <arg name="value" swt_gen="true"></arg>
+ <arg name="field" swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
</class>
<class name="NSNameSpecifier" swt_superclass="NSScriptObjectSpecifier">
</class>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSMutableURLRequest.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSMutableURLRequest.java
index 36ca289d66..4a895806c3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSMutableURLRequest.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSMutableURLRequest.java
@@ -28,10 +28,22 @@ public void setCachePolicy(int /*long*/ policy) {
OS.objc_msgSend(this.id, OS.sel_setCachePolicy_, policy);
}
+public void setHTTPBody(NSData data) {
+ OS.objc_msgSend(this.id, OS.sel_setHTTPBody_, data != null ? data.id : 0);
+}
+
+public void setHTTPMethod(NSString method) {
+ OS.objc_msgSend(this.id, OS.sel_setHTTPMethod_, method != null ? method.id : 0);
+}
+
public void setURL(NSURL URL) {
OS.objc_msgSend(this.id, OS.sel_setURL_, URL != null ? URL.id : 0);
}
+public void setValue(NSString value, NSString field) {
+ OS.objc_msgSend(this.id, OS.sel_setValue_forHTTPHeaderField_, value != null ? value.id : 0, field != null ? field.id : 0);
+}
+
public static NSURLRequest requestWithURL(NSURL URL) {
int /*long*/ result = OS.objc_msgSend(OS.class_NSMutableURLRequest, OS.sel_requestWithURL_, URL != null ? URL.id : 0);
return result != 0 ? new NSMutableURLRequest(result) : null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index e3905e5215..57976c50d3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -1481,6 +1481,7 @@ public static final int /*long*/ sel_setCookie_ = sel_registerName("setCookie:")
public static final int /*long*/ sel_setCopiesOnScroll_ = sel_registerName("setCopiesOnScroll:");
public static final int /*long*/ sel_setCurrentContext_ = sel_registerName("setCurrentContext:");
public static final int /*long*/ sel_setCurrentOperation_ = sel_registerName("setCurrentOperation:");
+public static final int /*long*/ sel_setCustomUserAgent_ = sel_registerName("setCustomUserAgent:");
public static final int /*long*/ sel_setData_forType_ = sel_registerName("setData:forType:");
public static final int /*long*/ sel_setDataCell_ = sel_registerName("setDataCell:");
public static final int /*long*/ sel_setDataSource_ = sel_registerName("setDataSource:");
@@ -1523,6 +1524,8 @@ public static final int /*long*/ sel_setFrame_display_animate_ = sel_registerNam
public static final int /*long*/ sel_setFrameLoadDelegate_ = sel_registerName("setFrameLoadDelegate:");
public static final int /*long*/ sel_setFrameOrigin_ = sel_registerName("setFrameOrigin:");
public static final int /*long*/ sel_setFrameSize_ = sel_registerName("setFrameSize:");
+public static final int /*long*/ sel_setHTTPBody_ = sel_registerName("setHTTPBody:");
+public static final int /*long*/ sel_setHTTPMethod_ = sel_registerName("setHTTPMethod:");
public static final int /*long*/ sel_setHasHorizontalScroller_ = sel_registerName("setHasHorizontalScroller:");
public static final int /*long*/ sel_setHasShadow_ = sel_registerName("setHasShadow:");
public static final int /*long*/ sel_setHasVerticalScroller_ = sel_registerName("setHasVerticalScroller:");
@@ -1652,6 +1655,7 @@ public static final int /*long*/ sel_setURL_ = sel_registerName("setURL:");
public static final int /*long*/ sel_setUpPrintOperationDefaultValues = sel_registerName("setUpPrintOperationDefaultValues");
public static final int /*long*/ sel_setUsesAlternatingRowBackgroundColors_ = sel_registerName("setUsesAlternatingRowBackgroundColors:");
public static final int /*long*/ sel_setUsesThreadedAnimation_ = sel_registerName("setUsesThreadedAnimation:");
+public static final int /*long*/ sel_setValue_forHTTPHeaderField_ = sel_registerName("setValue:forHTTPHeaderField:");
public static final int /*long*/ sel_setValue_forKey_ = sel_registerName("setValue:forKey:");
public static final int /*long*/ sel_setValueWraps_ = sel_registerName("setValueWraps:");
public static final int /*long*/ sel_setVerticalScroller_ = sel_registerName("setVerticalScroller:");
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/WebKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/WebKitFull.bridgesupport.extras
index a5edadde01..06a4c09e6c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/WebKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/WebKitFull.bridgesupport.extras
@@ -206,6 +206,10 @@
<arg name="applicationName" swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
+ <method selector="setCustomUserAgent:" swt_gen="true">
+ <arg name="userAgentString" swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="setDownloadDelegate:" swt_gen="true">
<arg name="delegate" swt_gen="true"></arg>
<retval swt_gen="true"></retval>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/WebView.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/WebView.java
index 34df6e3a5e..671ff0985b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/WebView.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/WebView.java
@@ -74,6 +74,10 @@ public void setApplicationNameForUserAgent(NSString applicationName) {
OS.objc_msgSend(this.id, OS.sel_setApplicationNameForUserAgent_, applicationName != null ? applicationName.id : 0);
}
+public void setCustomUserAgent(NSString userAgentString) {
+ OS.objc_msgSend(this.id, OS.sel_setCustomUserAgent_, userAgentString != null ? userAgentString.id : 0);
+}
+
public void setDownloadDelegate(id delegate) {
OS.objc_msgSend(this.id, OS.sel_setDownloadDelegate_, delegate != null ? delegate.id : 0);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
index 9a6972e9da..94b60f2934 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
@@ -8881,6 +8881,30 @@ fail:
}
#endif
+#if (!defined(NO_MoveMemory__ILorg_eclipse_swt_internal_win32_SAFEARRAY_2I) && !defined(JNI64)) || (!defined(NO_MoveMemory__JLorg_eclipse_swt_internal_win32_SAFEARRAY_2I) && defined(JNI64))
+#ifndef JNI64
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_SAFEARRAY_2I)(JNIEnv *env, jclass that, jintLong arg0, jobject arg1, jint arg2)
+#else
+JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__JLorg_eclipse_swt_internal_win32_SAFEARRAY_2I)(JNIEnv *env, jclass that, jintLong arg0, jobject arg1, jint arg2)
+#endif
+{
+ SAFEARRAY _arg1, *lparg1=NULL;
+#ifndef JNI64
+ OS_NATIVE_ENTER(env, that, MoveMemory__ILorg_eclipse_swt_internal_win32_SAFEARRAY_2I_FUNC);
+#else
+ OS_NATIVE_ENTER(env, that, MoveMemory__JLorg_eclipse_swt_internal_win32_SAFEARRAY_2I_FUNC);
+#endif
+ if (arg1) if ((lparg1 = getSAFEARRAYFields(env, arg1, &_arg1)) == NULL) goto fail;
+ MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2);
+fail:
+#ifndef JNI64
+ OS_NATIVE_EXIT(env, that, MoveMemory__ILorg_eclipse_swt_internal_win32_SAFEARRAY_2I_FUNC);
+#else
+ OS_NATIVE_EXIT(env, that, MoveMemory__JLorg_eclipse_swt_internal_win32_SAFEARRAY_2I_FUNC);
+#endif
+}
+#endif
+
#if (!defined(NO_MoveMemory__ILorg_eclipse_swt_internal_win32_SHDRAGIMAGE_2I) && !defined(JNI64)) || (!defined(NO_MoveMemory__JLorg_eclipse_swt_internal_win32_SHDRAGIMAGE_2I) && defined(JNI64))
#ifndef JNI64
JNIEXPORT void JNICALL OS_NATIVE(MoveMemory__ILorg_eclipse_swt_internal_win32_SHDRAGIMAGE_2I)(JNIEnv *env, jclass that, jintLong arg0, jobject arg1, jint arg2)
@@ -12442,6 +12466,30 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(RoundRect)
}
#endif
+#ifndef NO_SAFEARRAYBOUND_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(SAFEARRAYBOUND_1sizeof)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, SAFEARRAYBOUND_1sizeof_FUNC);
+ rc = (jint)SAFEARRAYBOUND_sizeof();
+ OS_NATIVE_EXIT(env, that, SAFEARRAYBOUND_1sizeof_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO_SAFEARRAY_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(SAFEARRAY_1sizeof)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, SAFEARRAY_1sizeof_FUNC);
+ rc = (jint)SAFEARRAY_sizeof();
+ OS_NATIVE_EXIT(env, that, SAFEARRAY_1sizeof_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_SCRIPT_1ANALYSIS_1sizeof
JNIEXPORT jint JNICALL OS_NATIVE(SCRIPT_1ANALYSIS_1sizeof)
(JNIEnv *env, jclass that)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
index 8c1c3b6295..cb0f7dc931 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
@@ -14,8 +14,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 974;
-int OS_nativeFunctionCallCount[974];
+int OS_nativeFunctionCount = 977;
+int OS_nativeFunctionCallCount[977];
char * OS_nativeFunctionNames[] = {
"ACCEL_1sizeof",
"ACTCTX_1sizeof",
@@ -758,6 +758,11 @@ char * OS_nativeFunctionNames[] = {
"MoveMemory__JLorg_eclipse_swt_internal_win32_RECT_2I",
#endif
#ifndef JNI64
+ "MoveMemory__ILorg_eclipse_swt_internal_win32_SAFEARRAY_2I",
+#else
+ "MoveMemory__JLorg_eclipse_swt_internal_win32_SAFEARRAY_2I",
+#endif
+#ifndef JNI64
"MoveMemory__ILorg_eclipse_swt_internal_win32_SHDRAGIMAGE_2I",
#else
"MoveMemory__JLorg_eclipse_swt_internal_win32_SHDRAGIMAGE_2I",
@@ -1219,6 +1224,8 @@ char * OS_nativeFunctionNames[] = {
"ReplyMessage",
"RestoreDC",
"RoundRect",
+ "SAFEARRAYBOUND_1sizeof",
+ "SAFEARRAY_1sizeof",
"SCRIPT_1ANALYSIS_1sizeof",
"SCRIPT_1CONTROL_1sizeof",
"SCRIPT_1DIGITSUBSTITUTE_1sizeof",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
index 2a6ffcba3d..dfe9ed907d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
@@ -766,6 +766,11 @@ typedef enum {
MoveMemory__JLorg_eclipse_swt_internal_win32_RECT_2I_FUNC,
#endif
#ifndef JNI64
+ MoveMemory__ILorg_eclipse_swt_internal_win32_SAFEARRAY_2I_FUNC,
+#else
+ MoveMemory__JLorg_eclipse_swt_internal_win32_SAFEARRAY_2I_FUNC,
+#endif
+#ifndef JNI64
MoveMemory__ILorg_eclipse_swt_internal_win32_SHDRAGIMAGE_2I_FUNC,
#else
MoveMemory__JLorg_eclipse_swt_internal_win32_SHDRAGIMAGE_2I_FUNC,
@@ -1227,6 +1232,8 @@ typedef enum {
ReplyMessage_FUNC,
RestoreDC_FUNC,
RoundRect_FUNC,
+ SAFEARRAYBOUND_1sizeof_FUNC,
+ SAFEARRAY_1sizeof_FUNC,
SCRIPT_1ANALYSIS_1sizeof_FUNC,
SCRIPT_1CONTROL_1sizeof_FUNC,
SCRIPT_1DIGITSUBSTITUTE_1sizeof_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.c
index 426ada6623..eb4851fb66 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.c
@@ -6409,6 +6409,92 @@ void setRECTFields(JNIEnv *env, jobject lpObject, RECT *lpStruct)
}
#endif
+#ifndef NO_SAFEARRAY
+typedef struct SAFEARRAY_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cDims, fFeatures, cbElements, cLocks, pvData, rgsabound;
+} SAFEARRAY_FID_CACHE;
+
+SAFEARRAY_FID_CACHE SAFEARRAYFc;
+
+void cacheSAFEARRAYFields(JNIEnv *env, jobject lpObject)
+{
+ if (SAFEARRAYFc.cached) return;
+ SAFEARRAYFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ SAFEARRAYFc.cDims = (*env)->GetFieldID(env, SAFEARRAYFc.clazz, "cDims", "S");
+ SAFEARRAYFc.fFeatures = (*env)->GetFieldID(env, SAFEARRAYFc.clazz, "fFeatures", "S");
+ SAFEARRAYFc.cbElements = (*env)->GetFieldID(env, SAFEARRAYFc.clazz, "cbElements", "I");
+ SAFEARRAYFc.cLocks = (*env)->GetFieldID(env, SAFEARRAYFc.clazz, "cLocks", "I");
+ SAFEARRAYFc.pvData = (*env)->GetFieldID(env, SAFEARRAYFc.clazz, "pvData", I_J);
+ SAFEARRAYFc.rgsabound = (*env)->GetFieldID(env, SAFEARRAYFc.clazz, "rgsabound", "Lorg/eclipse/swt/internal/win32/SAFEARRAYBOUND;");
+ SAFEARRAYFc.cached = 1;
+}
+
+SAFEARRAY *getSAFEARRAYFields(JNIEnv *env, jobject lpObject, SAFEARRAY *lpStruct)
+{
+ if (!SAFEARRAYFc.cached) cacheSAFEARRAYFields(env, lpObject);
+ lpStruct->cDims = (*env)->GetShortField(env, lpObject, SAFEARRAYFc.cDims);
+ lpStruct->fFeatures = (*env)->GetShortField(env, lpObject, SAFEARRAYFc.fFeatures);
+ lpStruct->cbElements = (*env)->GetIntField(env, lpObject, SAFEARRAYFc.cbElements);
+ lpStruct->cLocks = (*env)->GetIntField(env, lpObject, SAFEARRAYFc.cLocks);
+ lpStruct->pvData = (PVOID)(*env)->GetIntLongField(env, lpObject, SAFEARRAYFc.pvData);
+ {
+ jobject lpObject1 = (*env)->GetObjectField(env, lpObject, SAFEARRAYFc.rgsabound);
+ if (lpObject1 != NULL) getSAFEARRAYBOUNDFields(env, lpObject1, &lpStruct->rgsabound[0]);
+ }
+ return lpStruct;
+}
+
+void setSAFEARRAYFields(JNIEnv *env, jobject lpObject, SAFEARRAY *lpStruct)
+{
+ if (!SAFEARRAYFc.cached) cacheSAFEARRAYFields(env, lpObject);
+ (*env)->SetShortField(env, lpObject, SAFEARRAYFc.cDims, (jshort)lpStruct->cDims);
+ (*env)->SetShortField(env, lpObject, SAFEARRAYFc.fFeatures, (jshort)lpStruct->fFeatures);
+ (*env)->SetIntField(env, lpObject, SAFEARRAYFc.cbElements, (jint)lpStruct->cbElements);
+ (*env)->SetIntField(env, lpObject, SAFEARRAYFc.cLocks, (jint)lpStruct->cLocks);
+ (*env)->SetIntLongField(env, lpObject, SAFEARRAYFc.pvData, (jintLong)lpStruct->pvData);
+ {
+ jobject lpObject1 = (*env)->GetObjectField(env, lpObject, SAFEARRAYFc.rgsabound);
+ if (lpObject1 != NULL) setSAFEARRAYBOUNDFields(env, lpObject1, &lpStruct->rgsabound[0]);
+ }
+}
+#endif
+
+#ifndef NO_SAFEARRAYBOUND
+typedef struct SAFEARRAYBOUND_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID cElements, lLbound;
+} SAFEARRAYBOUND_FID_CACHE;
+
+SAFEARRAYBOUND_FID_CACHE SAFEARRAYBOUNDFc;
+
+void cacheSAFEARRAYBOUNDFields(JNIEnv *env, jobject lpObject)
+{
+ if (SAFEARRAYBOUNDFc.cached) return;
+ SAFEARRAYBOUNDFc.clazz = (*env)->GetObjectClass(env, lpObject);
+ SAFEARRAYBOUNDFc.cElements = (*env)->GetFieldID(env, SAFEARRAYBOUNDFc.clazz, "cElements", "I");
+ SAFEARRAYBOUNDFc.lLbound = (*env)->GetFieldID(env, SAFEARRAYBOUNDFc.clazz, "lLbound", "I");
+ SAFEARRAYBOUNDFc.cached = 1;
+}
+
+SAFEARRAYBOUND *getSAFEARRAYBOUNDFields(JNIEnv *env, jobject lpObject, SAFEARRAYBOUND *lpStruct)
+{
+ if (!SAFEARRAYBOUNDFc.cached) cacheSAFEARRAYBOUNDFields(env, lpObject);
+ lpStruct->cElements = (*env)->GetIntField(env, lpObject, SAFEARRAYBOUNDFc.cElements);
+ lpStruct->lLbound = (*env)->GetIntField(env, lpObject, SAFEARRAYBOUNDFc.lLbound);
+ return lpStruct;
+}
+
+void setSAFEARRAYBOUNDFields(JNIEnv *env, jobject lpObject, SAFEARRAYBOUND *lpStruct)
+{
+ if (!SAFEARRAYBOUNDFc.cached) cacheSAFEARRAYBOUNDFields(env, lpObject);
+ (*env)->SetIntField(env, lpObject, SAFEARRAYBOUNDFc.cElements, (jint)lpStruct->cElements);
+ (*env)->SetIntField(env, lpObject, SAFEARRAYBOUNDFc.lLbound, (jint)lpStruct->lLbound);
+}
+#endif
+
#ifndef NO_SCRIPT_ANALYSIS
typedef struct SCRIPT_ANALYSIS_FID_CACHE {
int cached;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.h
index ad112156b7..8099eda64c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_structs.h
@@ -1307,6 +1307,30 @@ void setRECTFields(JNIEnv *env, jobject lpObject, RECT *lpStruct);
#define RECT_sizeof() 0
#endif
+#ifndef NO_SAFEARRAY
+void cacheSAFEARRAYFields(JNIEnv *env, jobject lpObject);
+SAFEARRAY *getSAFEARRAYFields(JNIEnv *env, jobject lpObject, SAFEARRAY *lpStruct);
+void setSAFEARRAYFields(JNIEnv *env, jobject lpObject, SAFEARRAY *lpStruct);
+#define SAFEARRAY_sizeof() sizeof(SAFEARRAY)
+#else
+#define cacheSAFEARRAYFields(a,b)
+#define getSAFEARRAYFields(a,b,c) NULL
+#define setSAFEARRAYFields(a,b,c)
+#define SAFEARRAY_sizeof() 0
+#endif
+
+#ifndef NO_SAFEARRAYBOUND
+void cacheSAFEARRAYBOUNDFields(JNIEnv *env, jobject lpObject);
+SAFEARRAYBOUND *getSAFEARRAYBOUNDFields(JNIEnv *env, jobject lpObject, SAFEARRAYBOUND *lpStruct);
+void setSAFEARRAYBOUNDFields(JNIEnv *env, jobject lpObject, SAFEARRAYBOUND *lpStruct);
+#define SAFEARRAYBOUND_sizeof() sizeof(SAFEARRAYBOUND)
+#else
+#define cacheSAFEARRAYBOUNDFields(a,b)
+#define getSAFEARRAYBOUNDFields(a,b,c) NULL
+#define setSAFEARRAYBOUNDFields(a,b,c)
+#define SAFEARRAYBOUND_sizeof() 0
+#endif
+
#ifndef NO_SCRIPT_ANALYSIS
void cacheSCRIPT_ANALYSISFields(JNIEnv *env, jobject lpObject);
SCRIPT_ANALYSIS *getSCRIPT_ANALYSISFields(JNIEnv *env, jobject lpObject, SCRIPT_ANALYSIS *lpStruct);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
index a8b11dc61d..e628ee5311 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
@@ -663,6 +663,8 @@ public class OS extends C {
public static final int EVENT_OBJECT_SELECTIONWITHIN = 0x8009;
// public static final int EVENT_OBJECT_STATECHANGE = 0x800A;
public static final int EVENT_OBJECT_VALUECHANGE = 0x800E;
+ public static final short FADF_FIXEDSIZE = 0x10;
+ public static final short FADF_HAVEVARTYPE = 0x80;
public static final int FALT = 0x10;
public static final int FCONTROL = 0x8;
public static final int FE_FONTSMOOTHINGCLEARTYPE = 0x0002;
@@ -2262,6 +2264,8 @@ public static final native int PRINTDLG_sizeof ();
public static final native int PROCESS_INFORMATION_sizeof ();
public static final native int REBARBANDINFO_sizeof ();
public static final native int RECT_sizeof ();
+public static final native int SAFEARRAY_sizeof ();
+public static final native int SAFEARRAYBOUND_sizeof ();
public static final native int SCRIPT_ANALYSIS_sizeof ();
public static final native int SCRIPT_CONTROL_sizeof ();
public static final native int SCRIPT_DIGITSUBSTITUTE_sizeof ();
@@ -5051,6 +5055,11 @@ public static final native void MoveMemory (int /*long*/ Destination, RECT Sourc
* @param Destination cast=(PVOID)
* @param Source cast=(CONST VOID *),flags=no_out
*/
+public static final native void MoveMemory (int /*long*/ Destination, SAFEARRAY Source, int Length);
+/**
+ * @param Destination cast=(PVOID)
+ * @param Source cast=(CONST VOID *),flags=no_out
+ */
public static final native void MoveMemory (int /*long*/ Destination, TRIVERTEX Source, int Length);
/**
* @param Destination cast=(PVOID)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SAFEARRAY.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SAFEARRAY.java
new file mode 100644
index 0000000000..020c1a6dd2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SAFEARRAY.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.win32;
+
+public class SAFEARRAY {
+ public short cDims;
+ public short fFeatures;
+ public int cbElements;
+ public int cLocks;
+ /** @field cast=(PVOID) */
+ public int /*long*/ pvData;
+ /** @field accessor=rgsabound[0] */
+ public SAFEARRAYBOUND rgsabound;
+
+ public static final int sizeof = OS.SAFEARRAY_sizeof ();
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SAFEARRAYBOUND.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SAFEARRAYBOUND.java
new file mode 100644
index 0000000000..5c236bc2e5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/SAFEARRAYBOUND.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.win32;
+
+public class SAFEARRAYBOUND {
+ public int cElements;
+ public int lLbound;
+ public static final int sizeof = OS.SAFEARRAYBOUND_sizeof ();
+}