# HG changeset patch # User John Reimer # Date 1217984450 25200 # Node ID 4ee8c4237614ef0ce2fa84452510b61cd66fdd92 # Parent 9cbe6285f7462ffdb9022a4ba2962e84d1c0485a old branches... commit by mistake diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/AppFileLocProvider.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/AppFileLocProvider.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,287 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + * Port to the D programming language: + * John Reimer + *******************************************************************************/ + +module dwt.browser.AppFileLocProvider; + +import dwt.dwthelper.utils; + +import dwt.internal.Compatibility; + +import dwt.internal.mozilla.nsEmbedString; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIDirectoryService; +import dwt.internal.mozilla.nsIFile; +import dwt.internal.mozilla.nsILocalFile; +import dwt.internal.mozilla.nsISupports; + +class AppFileLocProvider : nsISupports, nsIDirectoryServiceProvider2 +{ + // XPCOMObject supports; + // XPCOMObject directoryServiceProvider; + // XPCOMObject directoryServiceProvider2; + nsrefcnt _refCount = 0; + String mozillaPath, profilePath; + String[] pluginDirs; + bool isXULRunner; + + static String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$ + static String CHROME_DIR = "chrome"; //$NON-NLS-1$ + static String COMPONENTS_DIR = "components"; //$NON-NLS-1$ + static String HISTORY_FILE = "history.dat"; //$NON-NLS-1$ + static String LOCALSTORE_FILE = "localstore.rdf"; //$NON-NLS-1$ + static String MIMETYPES_FILE = "mimeTypes.rdf"; //$NON-NLS-1$ + static String PLUGINS_DIR = "plugins"; //$NON-NLS-1$ + static String USER_PLUGINS_DIR = ".mozilla" + SEPARATOR_OS + "plugins"; //$NON-NLS-1$ //$NON-NLS-2$ + static String PREFERENCES_FILE = "prefs.js"; //$NON-NLS-1$ + +AppFileLocProvider (String path) { + mozillaPath = path + SEPARATOR_OS; + createCOMInterfaces (); +} + + int AddRef () + { + refCount++; + return refCount; + } + + nsresult QueryInterface ( nsIID* riid, void** ppvObject) + { + if (riid is null || ppvObject is null) + return NS_ERROR_NO_INTERFACE; + + if (riid == nsISupports.IID) + { + *ppvObject =cast(void*)cast(nsISupports)this; + AddRef (); + return NS_OK; + } + + if (riid == nsIDirectoryServiceProvider.IID) + { + *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider)this; + AddRef (); + return NS_OK; + } + + if (riid == nsDirectoryServiceProvider2.IID) { + *ppvObject = cast(void*)cast(nsIDirectoryServiceProvider2)this; + AddRef (); + return NS_OK; + } + + *ppvObject = null; + return NS_ERROR_NO_INTERFACE; + } + + nsrefcnt Release () + { + _refCount--; + if (_refCount is 0) + return 0; + return _refCount; + } + +void setProfilePath (String path) { + profilePath = path; + if (!Compatibility.fileExists (path, "")) { //$NON-NLS-1$ + int /*long*/[] result = new int /*long*/[1]; + nsEmbedString pathString = new nsEmbedString (path); + int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); + pathString.dispose (); + + nsILocalFile file = new nsILocalFile (result [0]); + rc = file.Create (nsILocalFile.DIRECTORY_TYPE, 0700); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + file.Release (); + } +} + +/* nsIDirectoryServiceProvider2 */ + +int getFiles (int /*long*/ prop, int /*long*/ _retval) { + int size = XPCOM.strlen (prop); + byte[] bytes = new byte[size]; + XPCOM.memmove (bytes, prop, size); + String propertyName = new String (MozillaDelegate.mbcsToWcs (null, bytes)); + String[] propertyValues = null; + + if (propertyName.equals (XPCOM.NS_APP_PLUGINS_DIR_LIST)) { + if (pluginDirs is null) { + int index = 0; + /* set the first value(s) to the MOZ_PLUGIN_PATH environment variable value if it's defined */ + int /*long*/ ptr = C.getenv (MozillaDelegate.wcsToMbcs (null, XPCOM.MOZILLA_PLUGIN_PATH, true)); + if (ptr !is 0) { + int length = C.strlen (ptr); + byte[] buffer = new byte[length]; + C.memmove (buffer, ptr, length); + String value = new String (MozillaDelegate.mbcsToWcs (null, buffer)); + if (value.length () > 0) { + String separator = System.getProperty ("path.separator"); // $NON-NLS-1$ + Vector segments = new Vector (); + int start, end = -1; + do { + start = end + 1; + end = value.indexOf (separator, start); + String segment; + if (end is -1) { + segment = value.substring (start); + } else { + segment = value.substring (start, end); + } + if (segment.length () > 0) segments.addElement (segment); + } while (end !is -1); + int segmentsSize = segments.size (); + pluginDirs = new String [segmentsSize + 2]; + for (index = 0; index < segmentsSize; index++) { + pluginDirs[index] = (String)segments.elementAt (index); + } + } + } + if (pluginDirs is null) { + pluginDirs = new String[2]; + } + + /* set the next value to the GRE path + "plugins" */ + pluginDirs[index++] = mozillaPath + PLUGINS_DIR; + + /* set the next value to the home directory + "/.mozilla/plugins" */ + pluginDirs[index++] = System.getProperty("user.home") + SEPARATOR_OS + USER_PLUGINS_DIR; + } + propertyValues = pluginDirs; + } + + XPCOM.memmove(_retval, new int /*long*/[] {0}, C.PTR_SIZEOF); + if (propertyValues !is null) { + int /*long*/[] result = new int /*long*/[1]; + nsISupports[] files = new nsISupports [propertyValues.length]; + int index = 0; + for (int i = 0; i < propertyValues.length; i++) { + nsEmbedString pathString = new nsEmbedString (propertyValues[i]); + int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result); + if (rc !is XPCOM.NS_ERROR_FILE_UNRECOGNIZED_PATH) { + /* value appears to be a valid pathname */ + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); + + nsILocalFile localFile = new nsILocalFile (result[0]); + result[0] = 0; + rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); + localFile.Release (); + + nsIFile file = new nsIFile (result[0]); + files[index++] = file; + } + pathString.dispose (); + result[0] = 0; + } + + if (index < propertyValues.length) { + /* there were some invalid values so remove the trailing empty array slots */ + nsISupports[] temp = new nsISupports [index]; + System.arraycopy (files, 0, temp, 0, index); + files = temp; + } + + SimpleEnumerator enumerator = new SimpleEnumerator (files); + enumerator.AddRef (); + XPCOM.memmove (_retval, new int /*long*/[] {enumerator.getAddress ()}, C.PTR_SIZEOF); + return XPCOM.NS_OK; + } + + return XPCOM.NS_ERROR_FAILURE; +} + +/* nsIDirectoryServiceProvider implementation */ + +int getFile(int /*long*/ prop, int /*long*/ persistent, int /*long*/ _retval) { + int size = XPCOM.strlen (prop); + byte[] bytes = new byte[size]; + XPCOM.memmove (bytes, prop, size); + String propertyName = new String (MozillaDelegate.mbcsToWcs (null, bytes)); + String propertyValue = null; + + if (propertyName.equals (XPCOM.NS_APP_HISTORY_50_FILE)) { + propertyValue = profilePath + HISTORY_FILE; + } else if (propertyName.equals (XPCOM.NS_APP_USER_MIMETYPES_50_FILE)) { + propertyValue = profilePath + MIMETYPES_FILE; + } else if (propertyName.equals (XPCOM.NS_APP_PREFS_50_FILE)) { + propertyValue = profilePath + PREFERENCES_FILE; + } else if (propertyName.equals (XPCOM.NS_APP_PREFS_50_DIR)) { + propertyValue = profilePath; + } else if (propertyName.equals (XPCOM.NS_APP_USER_CHROME_DIR)) { + propertyValue = profilePath + CHROME_DIR; + } else if (propertyName.equals (XPCOM.NS_APP_USER_PROFILE_50_DIR)) { + propertyValue = profilePath; + } else if (propertyName.equals (XPCOM.NS_APP_LOCALSTORE_50_FILE)) { + propertyValue = profilePath + LOCALSTORE_FILE; + } else if (propertyName.equals (XPCOM.NS_APP_CACHE_PARENT_DIR)) { + propertyValue = profilePath; + } else if (propertyName.equals (XPCOM.NS_OS_HOME_DIR)) { + propertyValue = System.getProperty("user.home"); //$NON-NLS-1$ + } else if (propertyName.equals (XPCOM.NS_OS_TEMP_DIR)) { + propertyValue = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ + } else if (propertyName.equals (XPCOM.NS_GRE_DIR)) { + propertyValue = mozillaPath; + } else if (propertyName.equals (XPCOM.NS_GRE_COMPONENT_DIR)) { + propertyValue = mozillaPath + COMPONENTS_DIR; + } else if (propertyName.equals (XPCOM.NS_XPCOM_INIT_CURRENT_PROCESS_DIR)) { + propertyValue = mozillaPath; + } else if (propertyName.equals (XPCOM.NS_OS_CURRENT_PROCESS_DIR)) { + propertyValue = mozillaPath; + } else if (propertyName.equals (XPCOM.NS_XPCOM_COMPONENT_DIR)) { + propertyValue = mozillaPath + COMPONENTS_DIR; + } else if (propertyName.equals (XPCOM.NS_XPCOM_CURRENT_PROCESS_DIR)) { + propertyValue = mozillaPath; + } else if (propertyName.equals (XPCOM.NS_APP_PREF_DEFAULTS_50_DIR)) { + /* + * Answering a value for this property causes problems in Mozilla versions + * < 1.7. Unfortunately this property is queried early enough in the + * Browser creation process that the Mozilla version being used is not + * yet determined. However it is known if XULRunner is being used or not. + * + * For now answer a value for this property iff XULRunner is the GRE. + * If the range of Mozilla versions supported by the Browser is changed + * in the future to be >= 1.7 then this value can always be answered. + */ + if (isXULRunner) propertyValue = profilePath; + } + + XPCOM.memmove (persistent, new int[] {1}, 4); /* PRBool */ + XPCOM.memmove (_retval, new int /*long*/[] {0}, C.PTR_SIZEOF); + if (propertyValue !is null && propertyValue.length () > 0) { + int /*long*/[] result = new int /*long*/[1]; + nsEmbedString pathString = new nsEmbedString (propertyValue); + int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); + pathString.dispose (); + + nsILocalFile localFile = new nsILocalFile (result [0]); + result[0] = 0; + rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); + + XPCOM.memmove (_retval, new int /*long*/[] {result[0]}, C.PTR_SIZEOF); + localFile.Release (); + return XPCOM.NS_OK; + } + + return XPCOM.NS_ERROR_FAILURE; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/Browser.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/Browser.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,782 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.Browser; + +import dwt.dwthelper.utils; + +import dwt.DWT; +import dwt.DWTError; +import dwt.DWTException; +import dwt.widgets.Composite; +import dwt.widgets.Display; +import dwt.widgets.Widget; + +/** + * Instances of this class implement the browser user interface + * metaphor. It allows the user to visualize and navigate through + * HTML documents. + *

+ * Note that although this class is a subclass of Composite, + * it does not make sense to set a layout on it. + *

+ *
+ *
Styles:
+ *
MOZILLA
+ *
Events:
+ *
CloseWindowListener, LocationListener, OpenWindowListener, ProgressListener, StatusTextListener, TitleListener, VisibilityWindowListener
+ *
+ *

+ * IMPORTANT: This class is not intended to be subclassed. + *

+ * + * @since 3.0 + */ + +public class Browser extends Composite { + WebBrowser webBrowser; + int userStyle; + + static final String PACKAGE_PREFIX = "dwt.browser."; //$NON-NLS-1$ + static final String NO_INPUT_METHOD = "dwt.internal.gtk.noInputMethod"; //$NON-NLS-1$ + +/** + * Constructs a new instance of this class given its parent + * and a style value describing its behavior and appearance. + *

+ * The style value is either one of the style constants defined in + * class DWT which is applicable to instances of this + * class, or must be built by bitwise OR'ing together + * (that is, using the int "|" operator) two or more + * of those DWT style constants. The class description + * lists the style constants that are applicable to the class. + * Style bits are also inherited from superclasses. + *

+ * + * @param parent a widget which will be the parent of the new instance (cannot be null) + * @param style the style of widget to construct + * + * @exception IllegalArgumentException + * @exception DWTException + * @exception DWTError + * + * @see Widget#getStyle + * + * @since 3.0 + */ +public Browser (Composite parent, int style) { + super (checkParent (parent), checkStyle (style)); + userStyle = style; + + String platform = DWT.getPlatform (); + Display display = parent.getDisplay (); + if ("gtk".equals (platform)) display.setData (NO_INPUT_METHOD, null); //$NON-NLS-1$ + String className = null; + if ((style & DWT.MOZILLA) !is 0) { + className = "dwt.browser.Mozilla"; //$NON-NLS-1$ + } else { + if ("win32".equals (platform) || "wpf".equals (platform)) { //$NON-NLS-1$ $NON-NLS-2$ + className = "dwt.browser.IE"; //$NON-NLS-1$ + } else if ("motif".equals (platform)) { //$NON-NLS-1$ + className = "dwt.browser.Mozilla"; //$NON-NLS-1$ + } else if ("gtk".equals (platform)) { //$NON-NLS-1$ + className = "dwt.browser.Mozilla"; //$NON-NLS-1$ + } else if ("carbon".equals (platform) || "cocoa".equals (platform)) { //$NON-NLS-1$ + className = "dwt.browser.Safari"; //$NON-NLS-1$ + } else if ("photon".equals (platform)) { //$NON-NLS-1$ + className = "dwt.browser.Voyager"; //$NON-NLS-1$ + } else { + dispose (); + DWT.error (DWT.ERROR_NO_HANDLES); + } + } + + try { + Class clazz = Class.forName (className); + webBrowser = (WebBrowser)clazz.newInstance (); + } catch (ClassNotFoundException e) { + } catch (IllegalAccessException e) { + } catch (InstantiationException e) { + } + if (webBrowser is null) { + dispose (); + DWT.error (DWT.ERROR_NO_HANDLES); + } + + webBrowser.setBrowser (this); + webBrowser.create (parent, style); +} + +static Composite checkParent (Composite parent) { + String platform = DWT.getPlatform (); + if (!"gtk".equals (platform)) return parent; //$NON-NLS-1$ + + /* + * Note. Mozilla provides all IM support needed for text input in web pages. + * If DWT creates another input method context for the widget it will cause + * indeterminate results to happen (hangs and crashes). The fix is to prevent + * DWT from creating an input method context for the Browser widget. + */ + if (parent !is null && !parent.isDisposed ()) { + Display display = parent.getDisplay (); + if (display !is null) { + if (display.getThread () is Thread.currentThread ()) { + display.setData (NO_INPUT_METHOD, "true"); //$NON-NLS-1$ + } + } + } + return parent; +} + +static int checkStyle(int style) { + String platform = DWT.getPlatform (); + if ((style & DWT.MOZILLA) !is 0) { + if ("carbon".equals (platform)) return style | DWT.EMBEDDED; //$NON-NLS-1$ + if ("motif".equals (platform)) return style | DWT.EMBEDDED; //$NON-NLS-1$ + return style; + } + + if ("win32".equals (platform)) { //$NON-NLS-1$ + /* + * For IE on win32 the border is supplied by the embedded browser, so remove + * the style so that the parent Composite will not draw a second border. + */ + return style & ~DWT.BORDER; + } else if ("motif".equals (platform)) { //$NON-NLS-1$ + return style | DWT.EMBEDDED; + } + return style; +} + +/** + * Clears all session cookies from all current Browser instances. + * + * @since 3.2 + */ +public static void clearSessions () { + WebBrowser.clearSessions (); +} + +/** + * Adds the listener to the collection of listeners who will be + * notified when the window hosting the receiver should be closed. + *

+ * This notification occurs when a javascript command such as + * window.close gets executed by a Browser. + *

+ * + * @param listener the listener which should be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void addCloseWindowListener (CloseWindowListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.addCloseWindowListener (listener); +} + +/** + * Adds the listener to the collection of listeners who will be + * notified when the current location has changed or is about to change. + *

+ * This notification typically occurs when the application navigates + * to a new location with {@link #setUrl(String)} or when the user + * activates a hyperlink. + *

+ * + * @param listener the listener which should be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void addLocationListener (LocationListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.addLocationListener (listener); +} + +/** + * Adds the listener to the collection of listeners who will be + * notified when a new window needs to be created. + *

+ * This notification occurs when a javascript command such as + * window.open gets executed by a Browser. + *

+ * + * @param listener the listener which should be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void addOpenWindowListener (OpenWindowListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.addOpenWindowListener (listener); +} + +/** + * Adds the listener to the collection of listeners who will be + * notified when a progress is made during the loading of the current + * URL or when the loading of the current URL has been completed. + * + * @param listener the listener which should be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void addProgressListener (ProgressListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.addProgressListener (listener); +} + +/** + * Adds the listener to the collection of listeners who will be + * notified when the status text is changed. + *

+ * The status text is typically displayed in the status bar of + * a browser application. + *

+ * + * @param listener the listener which should be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void addStatusTextListener (StatusTextListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.addStatusTextListener (listener); +} + +/** + * Adds the listener to the collection of listeners who will be + * notified when the title of the current document is available + * or has changed. + * + * @param listener the listener which should be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void addTitleListener (TitleListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.addTitleListener (listener); +} + +/** + * Adds the listener to the collection of listeners who will be + * notified when a window hosting the receiver needs to be displayed + * or hidden. + * + * @param listener the listener which should be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void addVisibilityWindowListener (VisibilityWindowListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.addVisibilityWindowListener (listener); +} + +/** + * Navigate to the previous session history item. + * + * @return true if the operation was successful and false otherwise + * + * @exception DWTException + * + * @see #forward + * + * @since 3.0 + */ +public bool back () { + checkWidget(); + return webBrowser.back (); +} + +protected void checkSubclass () { + String name = getClass ().getName (); + int index = name.lastIndexOf ('.'); + if (!name.substring (0, index + 1).equals (PACKAGE_PREFIX)) { + DWT.error (DWT.ERROR_INVALID_SUBCLASS); + } +} + +/** + * Execute the specified script. + * + *

+ * Execute a script containing javascript commands in the context of the current document. + * + * @param script the script with javascript commands + * + * @return true if the operation was successful and false otherwise + * + * @exception IllegalArgumentException

+ * + * @exception DWTException + * + * @since 3.1 + */ +public bool execute (String script) { + checkWidget(); + if (script is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + return webBrowser.execute (script); +} + +/** + * Navigate to the next session history item. + * + * @return true if the operation was successful and false otherwise + * + * @exception DWTException + * + * @see #back + * + * @since 3.0 + */ +public bool forward () { + checkWidget(); + return webBrowser.forward (); +} + +public int getStyle () { + /* + * If DWT.BORDER was specified at creation time then getStyle() should answer + * it even though it is removed for IE on win32 in checkStyle(). + */ + return super.getStyle () | (userStyle & DWT.BORDER); +} + +/** + * Returns a string with HTML that represents the content of the current page. + * + * @return HTML representing the current page or an empty String + * if this is empty + * + * @exception DWTException + * + * @since 3.4 + */ +public String getText () { + checkWidget(); + return webBrowser.getText (); +} + +/** + * Returns the current URL. + * + * @return the current URL or an empty String if there is no current URL + * + * @exception DWTException + * + * @see #setUrl + * + * @since 3.0 + */ +public String getUrl () { + checkWidget(); + return webBrowser.getUrl (); +} + +/** + * Returns the JavaXPCOM nsIWebBrowser for the receiver, or null + * if it is not available. In order for an nsIWebBrowser to be returned all + * of the following must be true: + * + * @return the receiver's JavaXPCOM nsIWebBrowser or null + * + * @since 3.3 + */ +public Object getWebBrowser () { + checkWidget(); + return webBrowser.getWebBrowser (); +} + +/** + * Returns true if the receiver can navigate to the + * previous session history item, and false otherwise. + * + * @return the receiver's back command enabled state + * + * @exception DWTException + * + * @see #back + */ +public bool isBackEnabled () { + checkWidget(); + return webBrowser.isBackEnabled (); +} + +public bool isFocusControl () { + checkWidget(); + if (webBrowser.isFocusControl ()) return true; + return super.isFocusControl (); +} + +/** + * Returns true if the receiver can navigate to the + * next session history item, and false otherwise. + * + * @return the receiver's forward command enabled state + * + * @exception DWTException + * + * @see #forward + */ +public bool isForwardEnabled () { + checkWidget(); + return webBrowser.isForwardEnabled (); +} + +/** + * Refresh the current page. + * + * @exception DWTException + * + * @since 3.0 + */ +public void refresh () { + checkWidget(); + webBrowser.refresh (); +} + +/** + * Removes the listener from the collection of listeners who will + * be notified when the window hosting the receiver should be closed. + * + * @param listener the listener which should no longer be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void removeCloseWindowListener (CloseWindowListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.removeCloseWindowListener (listener); +} + +/** + * Removes the listener from the collection of listeners who will + * be notified when the current location is changed or about to be changed. + * + * @param listener the listener which should no longer be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void removeLocationListener (LocationListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.removeLocationListener (listener); +} + +/** + * Removes the listener from the collection of listeners who will + * be notified when a new window needs to be created. + * + * @param listener the listener which should no longer be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void removeOpenWindowListener (OpenWindowListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.removeOpenWindowListener (listener); +} + +/** + * Removes the listener from the collection of listeners who will + * be notified when a progress is made during the loading of the current + * URL or when the loading of the current URL has been completed. + * + * @param listener the listener which should no longer be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void removeProgressListener (ProgressListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.removeProgressListener (listener); +} + +/** + * Removes the listener from the collection of listeners who will + * be notified when the status text is changed. + * + * @param listener the listener which should no longer be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void removeStatusTextListener (StatusTextListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.removeStatusTextListener (listener); +} + +/** + * Removes the listener from the collection of listeners who will + * be notified when the title of the current document is available + * or has changed. + * + * @param listener the listener which should no longer be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void removeTitleListener (TitleListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.removeTitleListener (listener); +} + +/** + * Removes the listener from the collection of listeners who will + * be notified when a window hosting the receiver needs to be displayed + * or hidden. + * + * @param listener the listener which should no longer be notified + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @since 3.0 + */ +public void removeVisibilityWindowListener (VisibilityWindowListener listener) { + checkWidget(); + if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + webBrowser.removeVisibilityWindowListener (listener); +} + +/** + * Renders HTML. + * + *

+ * The html parameter is Unicode encoded since it is a java String. + * As a result, the HTML meta tag charset should not be set. The charset is implied + * by the String itself. + * + * @param html the HTML content to be rendered + * + * @return true if the operation was successful and false otherwise. + * + * @exception IllegalArgumentException

+ * + * @exception DWTException + * + * @see #setUrl + * + * @since 3.0 + */ +public bool setText (String html) { + checkWidget(); + if (html is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + return webBrowser.setText (html); +} + +/** + * Loads a URL. + * + * @param url the URL to be loaded + * + * @return true if the operation was successful and false otherwise. + * + * @exception IllegalArgumentException + * + * @exception DWTException + * + * @see #getUrl + * + * @since 3.0 + */ +public bool setUrl (String url) { + checkWidget(); + if (url is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + return webBrowser.setUrl (url); +} + +/** + * Stop any loading and rendering activity. + * + * @exception DWTException + * + * @since 3.0 + */ +public void stop () { + checkWidget(); + webBrowser.stop (); +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/CloseWindowListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/CloseWindowListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 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 + *******************************************************************************/ +module dwt.browser.CloseWindowListener; + +import dwt.dwthelper.utils; + +import dwt.internal.DWTEventListener; + +/** + * This listener interface may be implemented in order to receive + * a {@link WindowEvent} notification when a {@link Browser} is + * about to be closed and when its host window should be closed + * by the application. + * + * @see Browser#addCloseWindowListener(CloseWindowListener) + * @see Browser#removeCloseWindowListener(CloseWindowListener) + * @see OpenWindowListener + * @see VisibilityWindowListener + * + * @since 3.0 + */ +public interface CloseWindowListener : DWTEventListener { + +/** + * This method is called when the window hosting a {@link Browser} should be closed. + * Application would typically close the {@link dwt.widgets.Shell} that + * hosts the Browser. The Browser is disposed after this + * notification. + * + *

The following fields in the WindowEvent apply: + *

+ * + * @param event the WindowEvent that specifies the Browser + * that is going to be disposed + * + * @see dwt.widgets.Shell#close() + * + * @since 3.0 + */ + public void close(WindowEvent event); +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/Download.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/Download.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,388 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + * Port to the D programming language: + * John Reimer + *******************************************************************************/ +module dwt.browser.Download; + +import dwt.dwthelper.utils; + +import dwt.DWT; +import dwt.internal.C; +import dwt.internal.Compatibility; +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIDownload; +import dwt.internal.mozilla.nsIHelperAppLauncher; +import dwt.internal.mozilla.nsILocalFile; +import dwt.internal.mozilla.nsIProgressDialog; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIWebProgressListener; +import dwt.layout.GridData; +import dwt.layout.GridLayout; +import dwt.widgets.Button; +import dwt.widgets.Event; +import dwt.widgets.Label; +import dwt.widgets.Listener; +import dwt.widgets.Shell; + +class Download { + XPCOMObject supports; + XPCOMObject download; + XPCOMObject progressDialog; + XPCOMObject webProgressListener; + nsIHelperAppLauncher helperAppLauncher; + int refCount = 0; + + Shell shell; + Label status; + Button cancel; + +Download () { + createCOMInterfaces (); +} + +int AddRef () { + refCount++; + return refCount; +} + +void createCOMInterfaces () { + /* Create each of the interfaces that this object implements */ + supports = new XPCOMObject (new int[] {2, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + }; + + download = new XPCOMObject (new int[] {2, 0, 0, 7, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);} + public int /*long*/ method4 (int /*long*/[] args) {return GetSource (args[0]);} + public int /*long*/ method5 (int /*long*/[] args) {return GetTarget (args[0]);} + public int /*long*/ method6 (int /*long*/[] args) {return GetPersist (args[0]);} + public int /*long*/ method7 (int /*long*/[] args) {return GetPercentComplete (args[0]);} + public int /*long*/ method8 (int /*long*/[] args) {return GetDisplayName (args[0]);} + public int /*long*/ method9 (int /*long*/[] args) {return SetDisplayName (args[0]);} + public int /*long*/ method10 (int /*long*/[] args) {return GetStartTime (args[0]);} + public int /*long*/ method11 (int /*long*/[] args) {return GetMIMEInfo (args[0]);} + public int /*long*/ method12 (int /*long*/[] args) {return GetListener (args[0]);} + public int /*long*/ method13 (int /*long*/[] args) {return SetListener (args[0]);} + public int /*long*/ method14 (int /*long*/[] args) {return GetObserver (args[0]);} + public int /*long*/ method15 (int /*long*/[] args) {return SetObserver (args[0]);} + }; + + progressDialog = new XPCOMObject (new int[] {2, 0, 0, 7, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);} + public int /*long*/ method4 (int /*long*/[] args) {return GetSource (args[0]);} + public int /*long*/ method5 (int /*long*/[] args) {return GetTarget (args[0]);} + public int /*long*/ method6 (int /*long*/[] args) {return GetPersist (args[0]);} + public int /*long*/ method7 (int /*long*/[] args) {return GetPercentComplete (args[0]);} + public int /*long*/ method8 (int /*long*/[] args) {return GetDisplayName (args[0]);} + public int /*long*/ method9 (int /*long*/[] args) {return SetDisplayName (args[0]);} + public int /*long*/ method10 (int /*long*/[] args) {return GetStartTime (args[0]);} + public int /*long*/ method11 (int /*long*/[] args) {return GetMIMEInfo (args[0]);} + public int /*long*/ method12 (int /*long*/[] args) {return GetListener (args[0]);} + public int /*long*/ method13 (int /*long*/[] args) {return SetListener (args[0]);} + public int /*long*/ method14 (int /*long*/[] args) {return GetObserver (args[0]);} + public int /*long*/ method15 (int /*long*/[] args) {return SetObserver (args[0]);} + public int /*long*/ method16 (int /*long*/[] args) {return Open (args[0]);} + public int /*long*/ method17 (int /*long*/[] args) {return GetCancelDownloadOnClose (args[0]);} + public int /*long*/ method18 (int /*long*/[] args) {return SetCancelDownloadOnClose ((int)/*64*/args[0]);} + public int /*long*/ method19 (int /*long*/[] args) {return GetDialog (args[0]);} + public int /*long*/ method20 (int /*long*/[] args) {return SetDialog (args[0]);} + }; + + webProgressListener = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);} + public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);} + public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);} + public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);} + public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);} + }; +} + +void disposeCOMInterfaces () { + if (supports !is null) { + supports.dispose (); + supports = null; + } + if (download !is null) { + download.dispose (); + download = null; + } + if (progressDialog !is null) { + progressDialog.dispose (); + progressDialog = null; + } + if (webProgressListener !is null) { + webProgressListener.dispose (); + webProgressListener = null; + } +} + +int /*long*/ getAddress () { + return progressDialog.getAddress (); +} + +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIDownload.NS_IDOWNLOAD_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIProgressDialog.NS_IPROGRESSDIALOG_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {progressDialog.getAddress ()}, C.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {webProgressListener.getAddress ()}, C.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int Release () { + refCount--; + if (refCount is 0) disposeCOMInterfaces (); + return refCount; +} + +/* nsIDownload */ + +/* Note. The argument startTime is defined as a PRInt64. This translates into two java ints. */ +int Init (int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, int /*long*/ startTime1, int /*long*/ startTime2, int /*long*/ aPersist) { + nsIURI source = new nsIURI (aSource); + int /*long*/ aSpec = XPCOM.nsEmbedCString_new (); + int rc = source.GetHost (aSpec); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + int length = XPCOM.nsEmbedCString_Length (aSpec); + int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec); + byte[] dest = new byte[length]; + XPCOM.memmove (dest, buffer, length); + XPCOM.nsEmbedCString_delete (aSpec); + String url = new String (dest); + + /* + * As of mozilla 1.7 the second argument of the nsIDownload interface's + * Init function changed from nsILocalFile to nsIURI. Detect which of + * these interfaces the second argument implements and act accordingly. + */ + String filename = null; + nsISupports supports = new nsISupports (aTarget); + int /*long*/[] result = new int /*long*/[1]; + rc = supports.QueryInterface (nsIURI.NS_IURI_IID, result); + if (rc is 0) { /* >= 1.7 */ + nsIURI target = new nsIURI (result[0]); + result[0] = 0; + int /*long*/ aPath = XPCOM.nsEmbedCString_new (); + rc = target.GetPath (aPath); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + length = XPCOM.nsEmbedCString_Length (aPath); + buffer = XPCOM.nsEmbedCString_get (aPath); + dest = new byte[length]; + XPCOM.memmove (dest, buffer, length); + XPCOM.nsEmbedCString_delete (aPath); + filename = new String (dest); + int separator = filename.lastIndexOf (System.getProperty ("file.separator")); //$NON-NLS-1$ + filename = filename.substring (separator + 1); + target.Release (); + } else { /* < 1.7 */ + nsILocalFile target = new nsILocalFile (aTarget); + int /*long*/ aNativeTarget = XPCOM.nsEmbedCString_new (); + rc = target.GetNativeLeafName (aNativeTarget); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + length = XPCOM.nsEmbedCString_Length (aNativeTarget); + buffer = XPCOM.nsEmbedCString_get (aNativeTarget); + dest = new byte[length]; + XPCOM.memmove (dest, buffer, length); + XPCOM.nsEmbedCString_delete (aNativeTarget); + filename = new String (dest); + } + + Listener listener = new Listener () { + public void handleEvent (Event event) { + if (event.widget is cancel) { + shell.close (); + } + if (helperAppLauncher !is null) { + helperAppLauncher.Cancel (); + helperAppLauncher.Release (); + } + shell = null; + helperAppLauncher = null; + } + }; + shell = new Shell (DWT.DIALOG_TRIM); + String msg = Compatibility.getMessage ("SWT_Download_File", new Object[] {filename}); //$NON-NLS-1$ + shell.setText (msg); + GridLayout gridLayout = new GridLayout (); + gridLayout.marginHeight = 15; + gridLayout.marginWidth = 15; + gridLayout.verticalSpacing = 20; + shell.setLayout(gridLayout); + msg = Compatibility.getMessage ("SWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$ + new Label (shell, DWT.SIMPLE).setText (msg); + status = new Label (shell, DWT.SIMPLE); + msg = Compatibility.getMessage ("SWT_Download_Started"); //$NON-NLS-1$ + status.setText (msg); + GridData data = new GridData (); + data.grabExcessHorizontalSpace = true; + data.grabExcessVerticalSpace = true; + status.setLayoutData (data); + + cancel = new Button (shell, DWT.PUSH); + cancel.setText (DWT.getMessage ("SWT_Cancel")); //$NON-NLS-1$ + data = new GridData (); + data.horizontalAlignment = GridData.CENTER; + cancel.setLayoutData (data); + cancel.addListener (DWT.Selection, listener); + shell.addListener (DWT.Close, listener); + shell.pack (); + shell.open (); + return XPCOM.NS_OK; +} + +int GetSource (int /*long*/ aSource) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetTarget (int /*long*/ aTarget) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetPersist (int /*long*/ aPersist) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetPercentComplete (int /*long*/ aPercentComplete) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetDisplayName (int /*long*/ aDisplayName) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int SetDisplayName (int /*long*/ aDisplayName) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetStartTime (int /*long*/ aStartTime) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetMIMEInfo (int /*long*/ aMIMEInfo) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetListener (int /*long*/ aListener) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int SetListener (int /*long*/ aListener) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetObserver (int /*long*/ aObserver) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int SetObserver (int /*long*/ aObserver) { + if (aObserver !is 0) { + nsISupports supports = new nsISupports (aObserver); + int /*long*/[] result = new int /*long*/[1]; + int rc = supports.QueryInterface (nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); + helperAppLauncher = new nsIHelperAppLauncher (result[0]); + } + return XPCOM.NS_OK; +} + +/* nsIProgressDialog */ +int Open (int /*long*/ aParent) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetCancelDownloadOnClose (int /*long*/ aCancelDownloadOnClose) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int SetCancelDownloadOnClose (int aCancelDownloadOnClose) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetDialog (int /*long*/ aDialog) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int SetDialog (int /*long*/ aDialog) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsIWebProgressListener */ + +int OnStateChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateFlags, int aStatus) { + if ((aStateFlags & nsIWebProgressListener.STATE_STOP) !is 0) { + if (helperAppLauncher !is null) helperAppLauncher.Release (); + helperAppLauncher = null; + if (shell !is null && !shell.isDisposed ()) shell.dispose (); + shell = null; + } + return XPCOM.NS_OK; +} + +int OnProgressChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aCurSelfProgress, int aMaxSelfProgress, int aCurTotalProgress, int aMaxTotalProgress) { + int currentKBytes = aCurTotalProgress / 1024; + int totalKBytes = aMaxTotalProgress / 1024; + if (shell !is null && !shell.isDisposed ()) { + Object[] arguments = {new Integer (currentKBytes), new Integer (totalKBytes)}; + String statusMsg = Compatibility.getMessage ("SWT_Download_Status", arguments); //$NON-NLS-1$ + status.setText (statusMsg); + shell.layout (true); + shell.getDisplay ().update (); + } + return XPCOM.NS_OK; +} + +int OnLocationChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) { + return XPCOM.NS_OK; +} + +int OnStatusChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStatus, int /*long*/ aMessage) { + return XPCOM.NS_OK; +} + +int OnSecurityChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int state) { + return XPCOM.NS_OK; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/DownloadFactory.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/DownloadFactory.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + * Port to the D programming language: + * John Reimer + *******************************************************************************/ +module dwt.browser.DownloadFactory; + +import dwt.dwthelper.utils; + +import dwt.browser.Download; + +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIFactory; +import dwt.internal.mozilla.nsISupports; + +class DownloadFactory : nsIFactory +{ + int _refCount = 0; + + nsrefcnt AddRef () + { + _refCount++; + return _refCount; + } + + int QueryInterface ( ref nsIID riid, void** ppvObject) + { + if (riid is null || ppvObject is null) + return NS_ERROR_NO_INTERFACE; + + if ( riid == nsISupports.IID) + { + *ppvObject = cast(void*)cast(nsISupports)this; + AddRef (); + return NS_OK; + } + + if ( riid == nsIFactory.IID) + { + *ppvObject = cast(void*)cast(nsIFactory)this; + AddRef (); + return NS_OK; + } + + *ppvObject = null; + return NS_ERROR_NO_INTERFACE; + } + + nsrefcnt Release () + { + _refCount--; + if (_refCount is 0) + _refCount = 0; + return _refCount; + } + +/* nsIFactory */ + + nsresult CreateInstance ( nsISupports aOuter, nsIID* iid, void** result) + { + Download download = new Download (); + download.AddRef (); + nsresult rv = download.QueryInterface( iid, result ); + return rv; + } + + nsresult LockFactory (int lock) + { + return NS_OK; + } +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/DownloadFactory_1_8.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/DownloadFactory_1_8.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.DownloadFactory_1_8; + +import dwt.dwthelper.utils; + +import dwt.internal.C; +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIFactory; +import dwt.internal.mozilla.nsISupports; + +class DownloadFactory_1_8 { + XPCOMObject supports; + XPCOMObject factory; + int refCount = 0; + +DownloadFactory_1_8 () { + createCOMInterfaces (); +} + +int AddRef () { + refCount++; + return refCount; +} + +void createCOMInterfaces () { + /* Create each of the interfaces that this object implements */ + supports = new XPCOMObject (new int[] {2, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + }; + + factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);} + public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);} + }; +} + +void disposeCOMInterfaces () { + if (supports !is null) { + supports.dispose (); + supports = null; + } + if (factory !is null) { + factory.dispose (); + factory = null; + } +} + +int /*long*/ getAddress () { + return factory.getAddress (); +} + +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int Release () { + refCount--; + if (refCount is 0) disposeCOMInterfaces (); + return refCount; +} + +/* nsIFactory */ + +int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) { + Download_1_8 download = new Download_1_8 (); + download.AddRef (); + XPCOM.memmove (result, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} + +int LockFactory (int lock) { + return XPCOM.NS_OK; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/Download_1_8.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/Download_1_8.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,407 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.Download_1_8; + +import dwt.dwthelper.utils; + +import dwt.DWT; +import dwt.internal.C; +import dwt.internal.Compatibility; +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; +import dwt.internal.mozilla.nsICancelable; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIDownload_1_8; +import dwt.internal.mozilla.nsIProgressDialog_1_8; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIWebProgressListener; +import dwt.layout.GridData; +import dwt.layout.GridLayout; +import dwt.widgets.Button; +import dwt.widgets.Event; +import dwt.widgets.Label; +import dwt.widgets.Listener; +import dwt.widgets.Shell; + +class Download_1_8 { + XPCOMObject supports; + XPCOMObject download; + XPCOMObject progressDialog; + XPCOMObject webProgressListener; + nsICancelable cancelable; + int refCount = 0; + + Shell shell; + Label status; + Button cancel; + + static final bool is32 = C.PTR_SIZEOF is 4; + +Download_1_8 () { + createCOMInterfaces (); +} + +int AddRef () { + refCount++; + return refCount; +} + +void createCOMInterfaces () { + /* Create each of the interfaces that this object implements */ + supports = new XPCOMObject (new int[] {2, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + }; + + download = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3, is32 ? 10 : 6, is32 ? 8 : 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);} + public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);} + public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);} + public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);} + public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);} + public int /*long*/ method8 (int /*long*/[] args) { + if (args.length is 10) { + return OnProgressChange64_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]); + } else { + return OnProgressChange64 (args[0], args[1], args[2], args[3], args[4], args[5]); + } + } + public int /*long*/ method9 (int /*long*/[] args) { + if (args.length is 8) { + return Init_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); + } else { + return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + } + public int /*long*/ method10 (int /*long*/[] args) {return GetTargetFile (args[0]);} + public int /*long*/ method11 (int /*long*/[] args) {return GetPercentComplete (args[0]);} + public int /*long*/ method12 (int /*long*/[] args) {return GetAmountTransferred (args[0]);} + public int /*long*/ method13 (int /*long*/[] args) {return GetSize (args[0]);} + public int /*long*/ method14 (int /*long*/[] args) {return GetSource (args[0]);} + public int /*long*/ method15 (int /*long*/[] args) {return GetTarget (args[0]);} + public int /*long*/ method16 (int /*long*/[] args) {return GetCancelable (args[0]);} + public int /*long*/ method17 (int /*long*/[] args) {return GetDisplayName (args[0]);} + public int /*long*/ method18 (int /*long*/[] args) {return GetStartTime (args[0]);} + public int /*long*/ method19 (int /*long*/[] args) {return GetMIMEInfo (args[0]);} + }; + + progressDialog = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3, is32 ? 10 : 6, is32 ? 8 : 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);} + public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);} + public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);} + public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);} + public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);} + public int /*long*/ method8 (int /*long*/[] args) { + if (args.length is 10) { + return OnProgressChange64_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]); + } else { + return OnProgressChange64 (args[0], args[1], args[2], args[3], args[4], args[5]); + } + } + public int /*long*/ method9 (int /*long*/[] args) { + if (args.length is 8) { + return Init_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); + } else { + return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + } + public int /*long*/ method10 (int /*long*/[] args) {return GetTargetFile (args[0]);} + public int /*long*/ method11 (int /*long*/[] args) {return GetPercentComplete (args[0]);} + public int /*long*/ method12 (int /*long*/[] args) {return GetAmountTransferred (args[0]);} + public int /*long*/ method13 (int /*long*/[] args) {return GetSize (args[0]);} + public int /*long*/ method14 (int /*long*/[] args) {return GetSource (args[0]);} + public int /*long*/ method15 (int /*long*/[] args) {return GetTarget (args[0]);} + public int /*long*/ method16 (int /*long*/[] args) {return GetCancelable (args[0]);} + public int /*long*/ method17 (int /*long*/[] args) {return GetDisplayName (args[0]);} + public int /*long*/ method18 (int /*long*/[] args) {return GetStartTime (args[0]);} + public int /*long*/ method19 (int /*long*/[] args) {return GetMIMEInfo (args[0]);} + public int /*long*/ method20 (int /*long*/[] args) {return Open (args[0]);} + public int /*long*/ method21 (int /*long*/[] args) {return GetCancelDownloadOnClose (args[0]);} + public int /*long*/ method22 (int /*long*/[] args) {return SetCancelDownloadOnClose ((int)/*64*/args[0]);} + public int /*long*/ method23 (int /*long*/[] args) {return GetObserver (args[0]);} + public int /*long*/ method24 (int /*long*/[] args) {return SetObserver (args[0]);} + public int /*long*/ method25 (int /*long*/[] args) {return GetDialog (args[0]);} + public int /*long*/ method26 (int /*long*/[] args) {return SetDialog (args[0]);} + }; + + webProgressListener = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);} + public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);} + public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);} + public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);} + public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);} + }; +} + +void disposeCOMInterfaces() { + if (supports !is null) { + supports.dispose (); + supports = null; + } + if (download !is null) { + download.dispose (); + download = null; + } + if (progressDialog !is null) { + progressDialog.dispose (); + progressDialog = null; + } + if (webProgressListener !is null) { + webProgressListener.dispose (); + webProgressListener = null; + } +} + +int /*long*/ getAddress () { + return progressDialog.getAddress (); +} + +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIDownload_1_8.NS_IDOWNLOAD_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIProgressDialog_1_8.NS_IPROGRESSDIALOG_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {progressDialog.getAddress ()}, C.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {webProgressListener.getAddress ()}, C.PTR_SIZEOF); + AddRef(); + return XPCOM.NS_OK; + } + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int Release () { + refCount--; + if (refCount is 0) disposeCOMInterfaces (); + return refCount; +} + +/* nsIDownload */ + +/* Note. The argument startTime is defined as a PRInt64. This translates into two java ints. */ +int Init_32 (int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, int /*long*/ startTime1, int /*long*/ startTime2, int /*long*/ aTempFile, int /*long*/ aCancelable) { + long startTime = (startTime2 << 32) + startTime1; + return Init (aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aTempFile, aCancelable); +} + +int Init (int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, long startTime, int /*long*/ aTempFile, int /*long*/ aCancelable) { + cancelable = new nsICancelable (aCancelable); + nsIURI source = new nsIURI (aSource); + int /*long*/ aSpec = XPCOM.nsEmbedCString_new (); + int rc = source.GetHost (aSpec); + if (rc !is XPCOM.NS_OK) Mozilla.error(rc); + int length = XPCOM.nsEmbedCString_Length (aSpec); + int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec); + byte[] dest = new byte[length]; + XPCOM.memmove (dest, buffer, length); + XPCOM.nsEmbedCString_delete (aSpec); + String url = new String (dest); + + nsIURI target = new nsIURI (aTarget); + int /*long*/ aPath = XPCOM.nsEmbedCString_new (); + rc = target.GetPath (aPath); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + length = XPCOM.nsEmbedCString_Length (aPath); + buffer = XPCOM.nsEmbedCString_get (aPath); + dest = new byte[length]; + XPCOM.memmove (dest, buffer, length); + XPCOM.nsEmbedCString_delete (aPath); + String filename = new String (dest); + int separator = filename.lastIndexOf (System.getProperty ("file.separator")); //$NON-NLS-1$ + filename = filename.substring (separator + 1); + + Listener listener = new Listener() { + public void handleEvent (Event event) { + if (event.widget is cancel) { + shell.close (); + } + if (cancelable !is null) { + int rc = cancelable.Cancel (XPCOM.NS_BINDING_ABORTED); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + } + shell = null; + cancelable = null; + } + }; + shell = new Shell (DWT.DIALOG_TRIM); + String msg = Compatibility.getMessage ("SWT_Download_File", new Object[] {filename}); //$NON-NLS-1$ + shell.setText (msg); + GridLayout gridLayout = new GridLayout (); + gridLayout.marginHeight = 15; + gridLayout.marginWidth = 15; + gridLayout.verticalSpacing = 20; + shell.setLayout (gridLayout); + msg = Compatibility.getMessage ("SWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$ + new Label (shell, DWT.SIMPLE).setText (msg); + status = new Label (shell, DWT.SIMPLE); + msg = Compatibility.getMessage ("SWT_Download_Started"); //$NON-NLS-1$ + status.setText (msg); + GridData data = new GridData (); + data.grabExcessHorizontalSpace = true; + data.grabExcessVerticalSpace = true; + status.setLayoutData (data); + + cancel = new Button (shell, DWT.PUSH); + cancel.setText (DWT.getMessage ("SWT_Cancel")); //$NON-NLS-1$ + data = new GridData (); + data.horizontalAlignment = GridData.CENTER; + cancel.setLayoutData (data); + cancel.addListener (DWT.Selection, listener); + shell.addListener (DWT.Close, listener); + shell.pack (); + shell.open (); + return XPCOM.NS_OK; +} + +int GetAmountTransferred (int /*long*/ arg0) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetCancelable (int /*long*/ arg0) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetDisplayName (int /*long*/ aDisplayName) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetMIMEInfo (int /*long*/ aMIMEInfo) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetPercentComplete (int /*long*/ aPercentComplete) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetSize (int /*long*/ arg0) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetSource (int /*long*/ aSource) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetStartTime (int /*long*/ aStartTime) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetTarget (int /*long*/ aTarget) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetTargetFile (int /*long*/ arg0) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsIProgressDialog */ +int GetCancelDownloadOnClose (int /*long*/ aCancelDownloadOnClose) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetDialog (int /*long*/ aDialog) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetObserver (int /*long*/ aObserver) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int Open (int /*long*/ aParent) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int SetCancelDownloadOnClose (int aCancelDownloadOnClose) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int SetDialog (int /*long*/ aDialog) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int SetObserver (int /*long*/ aObserver) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsIWebProgressListener */ + +int OnLocationChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) { + return XPCOM.NS_OK; +} + +int OnProgressChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aCurSelfProgress, int aMaxSelfProgress, int aCurTotalProgress, int aMaxTotalProgress) { + return OnProgressChange64 (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress); +} + +/* Note. The last 4 args in the original interface are defined as PRInt64. These each translate into two java ints. */ +int OnProgressChange64_32 (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aCurSelfProgress1, int /*long*/ aCurSelfProgress2, int /*long*/ aMaxSelfProgress1, int /*long*/ aMaxSelfProgress2, int /*long*/ aCurTotalProgress1, int /*long*/ aCurTotalProgress2, int /*long*/ aMaxTotalProgress1, int /*long*/ aMaxTotalProgress2) { + long aCurSelfProgress = (aCurSelfProgress2 << 32) + aCurSelfProgress1; + long aMaxSelfProgress = (aMaxSelfProgress2 << 32) + aMaxSelfProgress1; + long aCurTotalProgress = (aCurTotalProgress2 << 32) + aCurTotalProgress1; + long aMaxTotalProgress = (aMaxTotalProgress2 << 32) + aMaxTotalProgress1; + return OnProgressChange64 (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress); +} + +int OnProgressChange64 (int /*long*/ aWebProgress, int /*long*/ aRequest, long aCurSelfProgress, long aMaxSelfProgress, long aCurTotalProgress, long aMaxTotalProgress) { + long currentKBytes = aCurTotalProgress / 1024; + long totalKBytes = aMaxTotalProgress / 1024; + if (shell !is null && !shell.isDisposed ()) { + Object[] arguments = {new Long (currentKBytes), new Long (totalKBytes)}; + String statusMsg = Compatibility.getMessage ("SWT_Download_Status", arguments); //$NON-NLS-1$ + status.setText (statusMsg); + shell.layout (true); + shell.getDisplay ().update (); + } + return XPCOM.NS_OK; +} + +int OnSecurityChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int state) { + return XPCOM.NS_OK; +} + +int OnStateChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateFlags, int aStatus) { + if ((aStateFlags & nsIWebProgressListener.STATE_STOP) !is 0) { + cancelable = null; + if (shell !is null && !shell.isDisposed ()) shell.dispose (); + shell = null; + } + return XPCOM.NS_OK; +} + +int OnStatusChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStatus, int /*long*/ aMessage) { + return XPCOM.NS_OK; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/FilePicker.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/FilePicker.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,453 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + * Port to the D programming language: + * John Reimer + *******************************************************************************/ + +module dwt.browser.FilePicker; + +import tango.io.model.IFile; +import Utf = tango.text.convert.Utf; + +import dwt.dwthelper.utils; + +import dwt.DWT; + +import XPCOM = dwt.internal.mozilla.nsXPCOM; + +import dwt.browser.Mozilla; +import dwt.browser.MozillaDelegate; + +import dwt.internal.mozilla.nsEmbedString; +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIFilePicker; +import dwt.internal.mozilla.nsILocalFile; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsSimpleEnumerator; +import dwt.internal.mozilla.nsStringAPI; +import dwt.internal.mozilla.nsError; + +import dwt.widgets.DirectoryDialog; +import dwt.widgets.Display; +import dwt.widgets.FileDialog; +import dwt.widgets.Shell; + + +class FilePicker : nsISupports, nsIFilePicker +{ + /************************************************************************** + + **************************************************************************/ + + private + { + int _refCount = 0; + short _mode; + + nsIDOMWindow _parent; + + String[] _files; + String _masks; + String _defaultFilename, + _directory, + _title; + } + /************************************************************************** + + **************************************************************************/ + + static final String SEPARATOR = FileConst.FileSeparatorChar; + + /************************************************************************** + + **************************************************************************/ + + this () + { + } + + /************************************************************************** + + **************************************************************************/ + + nsrefcnt AddRef () + { + _refCount++; + return _refCount; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult QueryInterface ( inout nsID riid, void** ppvObject) + { + if (riid is null || ppvObject is null) + return NS_ERROR_NO_INTERFACE; + + if (riid == nsISupports.IID) + { + *ppvObject = cast(void*)cast(nsISupports) this; + AddRef (); + return NS_OK; + } + + if (riid == nsIFilePicker.IID)) + { + *ppvObject = cast(void*)cast(nsIFilePicker) this; + AddRef (); + return NS_OK; + } + + if (riid == nsIFilePicker_1_8.IID) + { + *ppvObject = cast(void*)cast(nsIFilePicker_1_8) this; + AddRef (); + return NS_OK; + } + + *ppvObject = null; + return NS_ERROR_NO_INTERFACE; + } + + /************************************************************************** + + **************************************************************************/ + + nsrefcnt Release () + { + _refCount--; + + if (_refCount is 0) + // No big deal here; just allow the GC to reap this object + // once all references are expired. -JJR + // delete this; + return 0; + + return _refCount; + } + + /************************************************************************** + + **************************************************************************/ + + /* SWT Comment: + * + * As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type. This method + * answers a java string based on the type of string that is appropriate for the Mozilla + * version being used. + */ + + override String parseAString (nsEmbedString str) + { + return null; + } + + /************************************************************************** + + **************************************************************************/ + + /* nsIFilePicker */ + + nsresult Init (nsIDOMWindow parent, nsAString* title, PRInt16 mode) + { + _parent = parent; + _mode = mode; + _title = parseAString (title); + return XPCOM; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult Show (PRUint32* retval) + { + if (_mode is nsIFilePicker.modeGetFolder) + { + /* picking a directory */ + int result = this.showDirectoryPicker (); + *retval = result; + return NS_OK; + } + + /* picking a file */ + int style = _mode is nsIFilePicker.modeSave ? DWT.SAVE : DWT.OPEN; + + if (_mode is nsIFilePicker.modeOpenMultiple) + style |= DWT.MULTI; + + Display display = Display.getCurrent (); + Shell parent = null; // TODO compute parent + + if (parent is null) + { + parent = new Shell (display); + } + + FileDialog dialog = new FileDialog (parent, style); + + if (_title !is null) + dialog.setText (_title); + + if (_directory !is null) + dialog.setFilterPath (_directory); + + if (_masks !is null) { + String[] str ~= _masks; + dialog.setFilterExtensions ( str ); + } + + if (_defaultFilename !is null) + dialog.setFileName (_defaultFilename); + + String filename = dialog.open (); + files = dialog.getFileNames (); + _directory = dialog.getFilterPath (); + _title = _defaultFilename = null; + _masks = null; + int result = filename is null ? nsIFilePicker.returnCancel : nsIFilePicker.returnOK; + *retval = result; + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + int showDirectoryPicker () + { + Display display = Display.getCurrent (); + Shell parent = null; // TODO compute parent + + if (parent is null) + { + parent = new Shell (display); + } + + DirectoryDialog dialog = new DirectoryDialog (parent, DWT.NONE); + + if (_title !is null) + dialog.setText (_title); + if (_directory !is null) + dialog.setFilterPath (_directory); + _directory = dialog.open (); + _title = _defaultFilename = null; + _files = _masks = null; + return _directory is null ? nsIFilePicker.returnCancel : nsIFilePicker.returnOK; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult GetFiles ( nsISimpleEnumerator* aFiles) + { + return NS_ERROR_NOT_IMPLEMENTED; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult GetFileURL (nsIFileURL aFileURL) + { + return NS_ERROR_NOT_IMPLEMENTED; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult GetFile (nsILocalFile* aFile) + { + String filename = ""; //$NON-NLS-1$ + + if (_directory !is null) + filename ~= _directory ~ SEPARATOR; + if (_files !is null && _files.length > 0) + filename ~= _files[0]; + + // Create a nsEmbedString which will be automatically disposed + // at the end of scope. + scope auto path = new nsEmbedString( filename ); + + nsresult rc = XPCOM.NS_NewLocalFile ( cast(nsAString*)path, 1, aFile); + + if (rc !is NS_OK) + Mozilla.error (rc); + if (aFile is null) + Mozilla.error (NS_ERROR_NULL_POINTER); + + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult SetDisplayDirectory (nsILocalFile aDisplayDirectory) + { + if (aDisplayDirectory is null) + return NS_OK; + + scope auto pathname = new nsEmbedCString; + aDisplayDirectory.GetNativePath ( cast(nsACString*)pathname ); + // TODO: CHECK IF THIS DOES CORRECT STRING CONVERSION -JJR + char[] buffer = pathname.toString(); + char[] chars = MozillaDelegate.mbcsToWcs (null, buffer); + // "buffer" contains a dup'ed string so we can safely reuse + // it's memory for the _directory member. -JJR + _directory = buffer; + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult GetDisplayDirectory (nsILocalFile* aDisplayDirectory) + { + String directoryName = _directory !is null ? _directory : ""; //$NON-NLS-1$ + scope auto path = new nsEmbedString (directoryName); + nsresult rc = XPCOM.NS_NewLocalFile ( cast(nsAString*)path, 1, aDisplayDirectory); + + if (rc !is NS_OK) + Mozilla.error (rc); + if (aDisplayDirectory is null) + Mozilla.error (NS_ERROR_NULL_POINTER); + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult SetFilterIndex (PRInt32 aFilterIndex) + { + return NS_ERROR_NOT_IMPLEMENTED; + } + + /************************************************************************** + + **************************************************************************/ + + nresult GetFilterIndex (PRInt32* aFilterIndex) + { + return NS_ERROR_NOT_IMPLEMENTED; + } + + /************************************************************************** + + **************************************************************************/ + + int SetDefaultExtension (nsAString* aDefaultExtension) + { + /* note that the type of argument 1 changed as of Mozilla 1.8 */ + return NS_ERROR_NOT_IMPLEMENTED; + } + + /************************************************************************** + + **************************************************************************/ + + int GetDefaultExtension (nsAString* aDefaultExtension) + { + /* note that the type of argument 1 changed as of Mozilla 1.8 */ + return NS_ERROR_NOT_IMPLEMENTED; + } + + /************************************************************************** + + **************************************************************************/ + + nresult SetDefaultString (nsAString* aDefaultString) + { + defaultFilename = parseAString (aDefaultString); + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + nresult GetDefaultString (nsAString* aDefaultString) + { + /* note that the type of argument 1 changed as of Mozilla 1.8 */ + return NS_ERROR_NOT_IMPLEMENTED; + } + + /************************************************************************** + + **************************************************************************/ + + nresult AppendFilter (nsAString* title, nsAString* filter) + { + /* note that the type of arguments 1 and 2 changed as of Mozilla 1.8 */ + return NS_ERROR_NOT_IMPLEMENTED; + } + + /************************************************************************** + + **************************************************************************/ + + nresult AppendFilters (PRInt32 filterMask) + { + String addFilters; + + switch (filterMask) + { + case nsIFilePicker.filterAll: + case nsIFilePicker.filterApps: + _masks = null; /* this is equivalent to no filter */ + break; + case nsIFilePicker.filterHTML: + addFilters = "*.htm;*.html" ; + break; + case nsIFilePicker.filterImages: + addFilters = "*.gif;*.jpeg;*.jpg;*.png"; + break; + case nsIFilePicker.filterText: + addFilters = "*.txt"; + break; + case nsIFilePicker.filterXML: + addFilters = "*.xml"; + break; + case nsIFilePicker.filterXUL: + addFilters = "*.xul"; + break; + } + + if (_masks is null) + { + _masks = addFilters; + } else { + if (addFilters !is null) + _masks ~= addFilters; + } + return NS_OK; + } + +/****************************************************************************** + + FilePicker for Mozilla Version 1.8 + +******************************************************************************/ + +class FilePicker_1_8 : FilePicker +{ + String parseAString (nsEmbedString str) + { + if (str is null) + return null; + return Utf.toString( str.toString16() ); + } +} \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/FilePickerFactory.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/FilePickerFactory.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + * Port to the D programming language: + * John Reimer + *******************************************************************************/ + +module dwt.browser.FilePickerFactory; + +import dwt.dwthelper.utils; + +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla. +import dwt.internal.mozilla.nsIFactory; +import dwt.internal.mozilla.nsISupports; + +class FilePickerFactory : nsISupports, nsIFactory +{ + + /************************************************************************** + + **************************************************************************/ + + int _refCount = 0; + + /************************************************************************** + + **************************************************************************/ + + this () + { + } + + /************************************************************************** + + **************************************************************************/ + + nsrefcnt AddRef () + { + _refCount++; + return _refCount; + } + + /************************************************************************** + + **************************************************************************/ + + int QueryInterface ( ref nsID riid, void** ppvObject) + { + if (riid is null || ppvObject is null) + return NS_ERROR_NO_INTERFACE; + + if (guid == nsISupports.IID)) + { + *ppvObject = cast(void*)cast(nsISupports) this; + AddRef (); + return NS_OK; + } + + if (guid == nsIFactory.IID) + { + *ppvObject = cast(void*)cast(nsIFactory) this; + AddRef (); + return NS_OK; + } + + *ppvObject = null; + return NS_ERROR_NO_INTERFACE; + } + + /************************************************************************** + + **************************************************************************/ + + nsrefcnt Release () + { + _refCount--; + if (_refCount is 0) + return 0; + return _refCount; + } + + /************************************************************************** + + **************************************************************************/ + + /* nsIFactory */ + + nsresult CreateInstance (nsISupports aOuter, nsIID* iid, void** result) + { + if (result is null) + return NS_ERROR_INVALID_ARG; + + FilePicker picker = new FilePicker (); + picker.AddRef (); + + nsresult rv = picker.QueryInterface( iid, result ); + + // TODO: If the query fails, the error should be checked and the + // newly created object deleted. In C++, this is done + // like so: + // + // if (NS_FAILED(rv)) { + // *result = nsnull; + // delete picker; + // } + // + // Deletion of the object really isn't critical here for D, but + // it may be considered "good habit" to do anyway for XPCOM objects. + // For now, just return the rv value. NS_FAILED needs to be + // ported first. -JJR + + return rv; + } + + nsresult LockFactory (int lock) + { + return NS_OK; + } + +} \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/FilePickerFactory_1_8.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/FilePickerFactory_1_8.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.FilePickerFactory_1_8; + +import dwt.dwthelper.utils; + +import dwt.internal.C; +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; + +class FilePickerFactory_1_8 extends FilePickerFactory { + +void createCOMInterfaces () { + /* Create each of the interfaces that this object implements */ + supports = new XPCOMObject (new int[] {2, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + }; + + factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);} + public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);} + }; +} + +/* nsIFactory */ + +int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) { + FilePicker_1_8 picker = new FilePicker_1_8 (); + picker.AddRef (); + XPCOM.memmove (result, new int /*long*/[] {picker.getAddress ()}, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} + +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/FilePicker_1_8.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/FilePicker_1_8.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.FilePicker_1_8; + +import dwt.dwthelper.utils; + +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; + +class FilePicker_1_8 extends FilePicker { + +void createCOMInterfaces () { + /* Create each of the interfaces that this object implements */ + supports = new XPCOMObject (new int[] {2, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + }; + + filePicker = new XPCOMObject (new int[] {2, 0, 0, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], (short)args[2]);} + public int /*long*/ method4 (int /*long*/[] args) {return AppendFilters ((int)/*64*/args[0]);} + public int /*long*/ method5 (int /*long*/[] args) {return AppendFilter (args[0], args[1]);} + public int /*long*/ method6 (int /*long*/[] args) {return GetDefaultString (args[0]);} + public int /*long*/ method7 (int /*long*/[] args) {return SetDefaultString (args[0]);} + public int /*long*/ method8 (int /*long*/[] args) {return GetDefaultExtension (args[0]);} + public int /*long*/ method9 (int /*long*/[] args) {return SetDefaultExtension (args[0]);} + public int /*long*/ method10 (int /*long*/[] args) {return GetFilterIndex (args[0]);} + public int /*long*/ method11 (int /*long*/[] args) {return SetFilterIndex ((int)/*64*/args[0]);} + public int /*long*/ method12 (int /*long*/[] args) {return GetDisplayDirectory (args[0]);} + public int /*long*/ method13 (int /*long*/[] args) {return SetDisplayDirectory (args[0]);} + public int /*long*/ method14 (int /*long*/[] args) {return GetFile (args[0]);} + public int /*long*/ method15 (int /*long*/[] args) {return GetFileURL (args[0]);} + public int /*long*/ method16 (int /*long*/[] args) {return GetFiles (args[0]);} + public int /*long*/ method17 (int /*long*/[] args) {return Show (args[0]);} + }; +} + +/* + * As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type. This method + * answers a java string based on the type of string that is appropriate for the Mozilla + * version being used. + */ +String parseAString (int /*long*/ string) { + if (string is 0) return null; + int length = XPCOM.nsEmbedString_Length (string); + int /*long*/ buffer = XPCOM.nsEmbedString_get (string); + char[] chars = new char[length]; + XPCOM.memmove (chars, buffer, length * 2); + return new String (chars); +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/HelperAppLauncherDialog.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/HelperAppLauncherDialog.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,233 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.HelperAppLauncherDialog; + +import dwt.dwthelper.utils; + +import dwt.DWT; +import dwt.internal.C; +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; +import dwt.internal.mozilla.nsEmbedString; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIHelperAppLauncher; +import dwt.internal.mozilla.nsIHelperAppLauncherDialog; +import dwt.internal.mozilla.nsIHelperAppLauncher_1_8; +import dwt.internal.mozilla.nsIHelperAppLauncher_1_9; +import dwt.internal.mozilla.nsISupports; +import dwt.widgets.FileDialog; +import dwt.widgets.Shell; + +class HelperAppLauncherDialog { + XPCOMObject supports; + XPCOMObject helperAppLauncherDialog; + int refCount = 0; + +HelperAppLauncherDialog () { + createCOMInterfaces (); +} + +int AddRef () { + refCount++; + return refCount; +} + +void createCOMInterfaces () { + /* Create each of the interfaces that this object implements */ + supports = new XPCOMObject (new int[] {2, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + }; + + helperAppLauncherDialog = new XPCOMObject (new int[] {2, 0, 0, 3, 5}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return Show (args[0], args[1], (int)/*64*/args[2]);} + public int /*long*/ method4 (int /*long*/[] args) {return PromptForSaveToFile (args[0], args[1], args[2], args[3], args[4]);} + }; +} + +void disposeCOMInterfaces () { + if (supports !is null) { + supports.dispose (); + supports = null; + } + if (helperAppLauncherDialog !is null) { + helperAppLauncherDialog.dispose (); + helperAppLauncherDialog = null; + } +} + +int /*long*/ getAddress () { + return helperAppLauncherDialog.getAddress (); +} + +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIHelperAppLauncherDialog.NS_IHELPERAPPLAUNCHERDIALOG_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int Release () { + refCount--; + /* + * Note. This instance lives as long as the download it is binded to. + * Its reference count is expected to go down to 0 when the download + * has completed or when it has been cancelled. E.g. when the user + * cancels the File Dialog, cancels or closes the Download Dialog + * and when the Download Dialog goes away after the download is completed. + */ + if (refCount is 0) disposeCOMInterfaces (); + return refCount; +} + +/* nsIHelperAppLauncherDialog */ + +int Show (int /*long*/ aLauncher, int /*long*/ aContext, int aReason) { + /* + * The interface for nsIHelperAppLauncher changed in GRE versions 1.8 and 1.9. Query for + * each of these interfaces in turn until one is found. + */ + nsISupports supports = new nsISupports (aLauncher); + int /*long*/[] result = new int /*long*/[1]; + int rc = supports.QueryInterface (nsIHelperAppLauncher_1_9.NS_IHELPERAPPLAUNCHER_IID, result); + if (rc is 0) { + nsIHelperAppLauncher_1_9 helperAppLauncher = new nsIHelperAppLauncher_1_9 (aLauncher); + rc = helperAppLauncher.SaveToDisk (0, 0); + helperAppLauncher.Release (); + return rc; + } + + result[0] = 0; + rc = supports.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result); + if (rc is 0) { + nsIHelperAppLauncher_1_8 helperAppLauncher = new nsIHelperAppLauncher_1_8 (aLauncher); + rc = helperAppLauncher.SaveToDisk (0, 0); + helperAppLauncher.Release (); + return rc; + } + + nsIHelperAppLauncher helperAppLauncher = new nsIHelperAppLauncher (aLauncher); /* < 1.8 */ + return helperAppLauncher.SaveToDisk (0, 0); +} + +int PromptForSaveToFile (int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ arg4) { + int /*long*/ aDefaultFile, aSuggestedFileExtension, _retval; + bool hasLauncher = false; + + /* + * The interface for nsIHelperAppLauncherDialog changed as of mozilla 1.5 when an + * extra argument was added to the PromptForSaveToFile method (this resulted in all + * subsequent arguments shifting right). The workaround is to provide an XPCOMObject + * that fits the newer API, and to use the first argument's type to infer whether + * the old or new nsIHelperAppLauncherDialog interface is being used (and by extension + * the ordering of the arguments). In mozilla >= 1.5 the first argument is an + * nsIHelperAppLauncher. + */ + /* + * The interface for nsIHelperAppLauncher changed as of mozilla 1.8, so the first + * argument must be queried for both the old and new nsIHelperAppLauncher interfaces. + */ + bool using_1_8 = false, using_1_9 = false; + nsISupports support = new nsISupports (arg0); + int /*long*/[] result = new int /*long*/[1]; + int rc = support.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result); + if (rc is 0) { + using_1_8 = true; + hasLauncher = true; + new nsISupports (result[0]).Release (); + } else { + result[0] = 0; + rc = support.QueryInterface (nsIHelperAppLauncher_1_9.NS_IHELPERAPPLAUNCHER_IID, result); + if (rc is 0) { + using_1_9 = true; + hasLauncher = true; + new nsISupports (result[0]).Release (); + } else { + result[0] = 0; + rc = support.QueryInterface (nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result); + if (rc is 0) { + hasLauncher = true; + new nsISupports (result[0]).Release (); + } + } + } + result[0] = 0; + + if (hasLauncher) { /* >= 1.5 */ + aDefaultFile = arg2; + aSuggestedFileExtension = arg3; + _retval = arg4; + } else { /* 1.4 */ + aDefaultFile = arg1; + aSuggestedFileExtension = arg2; + _retval = arg3; + } + + int length = XPCOM.strlen_PRUnichar (aDefaultFile); + char[] dest = new char[length]; + XPCOM.memmove (dest, aDefaultFile, length * 2); + String defaultFile = new String (dest); + + length = XPCOM.strlen_PRUnichar (aSuggestedFileExtension); + dest = new char[length]; + XPCOM.memmove (dest, aSuggestedFileExtension, length * 2); + String suggestedFileExtension = new String (dest); + + Shell shell = new Shell (); + FileDialog fileDialog = new FileDialog (shell, DWT.SAVE); + fileDialog.setFileName (defaultFile); + fileDialog.setFilterExtensions (new String[] {suggestedFileExtension}); + String name = fileDialog.open (); + shell.close (); + if (name is null) { + if (hasLauncher) { + if (using_1_8) { + nsIHelperAppLauncher_1_8 launcher = new nsIHelperAppLauncher_1_8 (arg0); + rc = launcher.Cancel (XPCOM.NS_BINDING_ABORTED); + } else if (using_1_9) { + nsIHelperAppLauncher_1_9 launcher = new nsIHelperAppLauncher_1_9 (arg0); + rc = launcher.Cancel (XPCOM.NS_BINDING_ABORTED); + } else { + nsIHelperAppLauncher launcher = new nsIHelperAppLauncher (arg0); + rc = launcher.Cancel (); + } + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + return XPCOM.NS_OK; + } + return XPCOM.NS_ERROR_FAILURE; + } + nsEmbedString path = new nsEmbedString (name); + rc = XPCOM.NS_NewLocalFile (path.getAddress (), 1, result); + path.dispose (); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); + /* Our own nsIDownload has been registered during the Browser initialization. It will be invoked by Mozilla. */ + XPCOM.memmove (_retval, result, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/HelperAppLauncherDialogFactory.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/HelperAppLauncherDialogFactory.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.HelperAppLauncherDialogFactory; + +import dwt.dwthelper.utils; + +import dwt.internal.C; +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIFactory; +import dwt.internal.mozilla.nsISupports; + +class HelperAppLauncherDialogFactory { + XPCOMObject supports; + XPCOMObject factory; + int refCount = 0; + +HelperAppLauncherDialogFactory () { + createCOMInterfaces (); +} + +int AddRef () { + refCount++; + return refCount; +} + +void createCOMInterfaces () { + /* Create each of the interfaces that this object implements */ + supports = new XPCOMObject (new int[] {2, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + }; + + factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);} + public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);} + }; +} + +void disposeCOMInterfaces () { + if (supports !is null) { + supports.dispose (); + supports = null; + } + if (factory !is null) { + factory.dispose (); + factory = null; + } +} + +int /*long*/ getAddress () { + return factory.getAddress (); +} + +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int Release () { + refCount--; + if (refCount is 0) disposeCOMInterfaces (); + return refCount; +} + +/* nsIFactory */ + +int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) { + HelperAppLauncherDialog helperAppLauncherDialog = new HelperAppLauncherDialog (); + helperAppLauncherDialog.AddRef (); + XPCOM.memmove (result, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} + +int LockFactory (int lock) { + return XPCOM.NS_OK; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/InputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/InputStream.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,177 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + * Port to the D programming language: + * John Reimer + *******************************************************************************/ + +module dwt.browser.InputStream; + +import dwt.dwthelper.utils; + +import dwt.internal.mozilla.nsError; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIInputStream; +import dwt.internal.mozilla.nsISupports; + +import Math = tango.math.Math; + +/****************************************************************************** + + COMMENTS: SWT implements this class as a replacement for the XPCOM + implementation; it may be possible to use the XPCOM one instead + (which also may be safer for D), but for now we'll follow SWT's example + and use this reimplementation of InputStream. It should be trivial to + move over to strict XPCOM implementation should the need arise. It appears + that the Java SWT source uses many workarounds in order to use the XPCOM + interface. For D, I remove much of the Java layered callback + approach since it is no longer necessary. -JJR + +******************************************************************************/ + +class InputStream : nsIInputStream +{ + int _refCount = 0; + int _index = 0; + byte[] _buffer; + + /************************************************************************** + + **************************************************************************/ + + this (byte[] buffer) + { + this._buffer = buffer; + index = 0; + } + + /************************************************************************** + + **************************************************************************/ + + nsrefcnt AddRef () + { + _refCount++; + return _refCount; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult QueryInterface ( inout nsID riid, void** ppvObject) + { + if (riid is null || ppvObject is null) + return NS_ERROR_NO_INTERFACE; + + nsID guid = riid; + + if (guid == nsISupports.NS_ISUPPORTS_IID) + { + *ppvObject = cast(void*)cast(nsISupports) this; + this.AddRef (); + return NS_OK; + } + + if (guid == nsIInputStream.NS_IINPUTSTREAM_IID) + { + *ppvObject = cast(void*)cast(nsIInputStream) this; + this.AddRef (); + return NS_OK; + } + + *ppvObject = null; + return NS_ERROR_NO_INTERFACE; + } + + /************************************************************************** + + **************************************************************************/ + + nsrefcnt Release () + { + _refCount--; + if (_refCount is 0) + return 0 + // delete this; + return _refCount; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult Close () + { + _buffer = null; + _index = 0; + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult Available ( PRUint32* retval) + { + PRUint32 available = buffer is null ? 0 : buffer.length - _index; + *retval = available; + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult Read(byte* aBuf, PRUint32 aCount, PRUint32* retval) + { + int max = Math.min (aCount, _buffer is null ? 0 : _buffer.length - _index); + + if (max > 0) + { + aBuf[0..max] = _buffer[_index..$]; + _index += max; + } + + *retval = max; + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult ReadSegments (nsWriteSegmentFun aWriter, void* aClosure, PRUint32 aCount, PRUint32* retval) + { + int max = Math.min (aCount, buffer is null ? 0 : buffer.length - _index); + PRUint32 cnt = max; + + while (cnt > 0) + { + PRUint32 aWriteCount; + nsresult rc = aWriter ( cast(nsIInputStream)this, aClosure, buffer.ptr, _index, cnt, &aWriteCount); + if (rc !is NS_OK) break; + _index += aWriteCount; + cnt -= aWriteCount; + } + + *retval = (max - cnt); + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult IsNonBlocking ( PRUint32* retval) + { + *retval = 0; + return NS_OK; + } +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/LocationAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/LocationAdapter.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 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 + * Port to the D programming language: + * John Reimer + *******************************************************************************/ +module dwt.browser.LocationAdapter; + +import dwt.browser.LocationListener; +import dwt.browser.LocationEvent; +import dwt.dwthelper.utils; + +/** + * This adapter class provides default implementations for the + * methods described by the {@link LocationListener} interface. + *

+ * Classes that wish to deal with {@link LocationEvent}'s can + * extend this class and override only the methods which they are + * interested in. + *

+ * + * @since 3.0 + */ +public abstract class LocationAdapter : LocationListener { + + public void changing(LocationEvent event) { + } + + public void changed(LocationEvent event) { + } +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/LocationEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/LocationEvent.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 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 + * Port to the D programming language: + * John Reimer + *******************************************************************************/ +module dwt.browser.LocationEvent; + +import dwt.dwthelper.utils; + +import dwt.events.TypedEvent; +import dwt.widgets.Widget; + +/** + * A LocationEvent is sent by a {@link Browser} to + * {@link LocationListener}'s when the Browser + * navigates to a different URL. This notification typically + * occurs when the application navigates to a new location with + * {@link Browser#setUrl(String)} or when the user activates a + * hyperlink. + * + * @since 3.0 + */ +public class LocationEvent : TypedEvent { + /** current location */ + public String location; + + /** + * A flag indicating whether the location opens in the top frame + * or not. + */ + public bool top; + + /** + * A flag indicating whether the location loading should be allowed. + * Setting this field to false will cancel the operation. + */ + public bool doit; + + static final long serialVersionUID = 3906644198244299574L; + +LocationEvent(Widget w) { + super(w); +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public String toString() { + String string = super.toString (); + return string.substring (0, string.length() - 1) // remove trailing '}' + + " location=" + location + + " top=" + top + + " doit=" + doit + + "}"; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/LocationListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/LocationListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 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 + *******************************************************************************/ +module dwt.browser.LocationListener; + +import dwt.dwthelper.utils; + +import dwt.internal.DWTEventListener; + +/** + * This listener interface may be implemented in order to receive + * a {@link LocationEvent} notification when a {@link Browser} + * navigates to a different URL. + * + * @see Browser#addLocationListener(LocationListener) + * @see Browser#removeLocationListener(LocationListener) + * + * @since 3.0 + */ +public interface LocationListener extends DWTEventListener { + +/** + * This method is called when the current location is about to be changed. + *

+ * + *

The following fields in the LocationEvent apply: + *

    + *
  • (in) location the location to be loaded + *
  • (in) widget the Browser whose location is changing + *
  • (in/out) doit can be set to false to prevent the location + * from being loaded + *
+ * + * @param event the LocationEvent that specifies the location + * to be loaded by a Browser + * + * @since 3.0 + */ +public void changing(LocationEvent event); + +/** + * This method is called when the current location is changed. + *

+ * + *

The following fields in the LocationEvent apply: + *

    + *
  • (in) location the current location + *
  • (in) top true if the location opens in the top frame or + * false otherwise + *
  • (in) widget the Browser whose location has changed + *
+ * + * @param event the LocationEvent that specifies the new + * location of a Browser + * + * @since 3.0 + */ +public void changed(LocationEvent event); + +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/Mozilla.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/Mozilla.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,3222 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + * Port to the D programming language: + * John Reimer + *******************************************************************************/ +module dwt.browser.Mozilla; + +import dwt.dwthelper.utils; + +import dwt.DWT; +import dwt.DWTError; +import dwt.graphics.Device; +import dwt.graphics.Point; +import dwt.graphics.Rectangle; + +import dwt.internal.Compatibility; +import dwt.internal.LONG; +import dwt.internal.Library; + +import dwt.internal.mozilla.nsEmbedString; +import dwt.internal.mozilla.nsError; + +import dwt.internal.mozilla.nsIAppShell; +import dwt.internal.mozilla.nsIBaseWindow; +import dwt.internal.mozilla.nsICategoryManager; +import dwt.internal.mozilla.nsIComponentManager; +import dwt.internal.mozilla.nsIComponentRegistrar; +import dwt.internal.mozilla.nsIContextMenuListener; +import dwt.internal.mozilla.nsICookie; +import dwt.internal.mozilla.nsICookieManager; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIDOMEvent; +import dwt.internal.mozilla.nsIDOMEventTarget; +import dwt.internal.mozilla.nsIDOMKeyEvent; +import dwt.internal.mozilla.nsIDOMMouseEvent; +import dwt.internal.mozilla.nsIDOMSerializer; +import dwt.internal.mozilla.nsIDOMSerializer_1_7; +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsIDOMWindowCollection; +import dwt.internal.mozilla.nsIDirectoryService; +import dwt.internal.mozilla.nsIDocShell; +import dwt.internal.mozilla.nsIDocShell_1_8; +import dwt.internal.mozilla.nsIDocShell_1_9; +import dwt.internal.mozilla.nsIEmbeddingSiteWindow; +import dwt.internal.mozilla.nsIFile; +import dwt.internal.mozilla.nsIIOService; +import dwt.internal.mozilla.nsIInterfaceRequestor; +import dwt.internal.mozilla.nsIJSContextStack; +import dwt.internal.mozilla.nsILocalFile; +import dwt.internal.mozilla.nsIObserverService; +import dwt.internal.mozilla.nsIPrefBranch; +import dwt.internal.mozilla.nsIPrefLocalizedString; +import dwt.internal.mozilla.nsIPrefService; +import dwt.internal.mozilla.nsIProperties; +import dwt.internal.mozilla.nsIServiceManager; +import dwt.internal.mozilla.nsISimpleEnumerator; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsISupportsWeakReference; +import dwt.internal.mozilla.nsITooltipListener; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIURIContentListener; +import dwt.internal.mozilla.nsIWeakReference; +import dwt.internal.mozilla.nsIWebBrowser; +import dwt.internal.mozilla.nsIWebBrowserChrome; +import dwt.internal.mozilla.nsIWebBrowserChromeFocus; +import dwt.internal.mozilla.nsIWebBrowserFocus; +import dwt.internal.mozilla.nsIWebNavigation; +import dwt.internal.mozilla.nsIWebNavigationInfo; +import dwt.internal.mozilla.nsIWebProgress; +import dwt.internal.mozilla.nsIWebProgressListener; +import dwt.internal.mozilla.nsIWindowWatcher; + +import dwt.layout.FillLayout; +import dwt.widgets.Composite; +import dwt.widgets.Display; +import dwt.widgets.Event; +import dwt.widgets.Label; +import dwt.widgets.Listener; +import dwt.widgets.Menu; +import dwt.widgets.Shell; + +class Mozilla : nsIWebBrowser, nsIWeakReference, + nsIWebProgressListener, nsIWebBrowserChrome, + nsIWebBrowserChromeFocus, nsIEmbeddingSiteWindow, + nsIInterfaceRequestor, nsISupportsWeakReference, + nsIContextMenuListener, nsIUriContentListener, + nsIToolTipListener, nsIDOMEventListener +{ + int /*long*/ embedHandle; + nsIWebBrowser webBrowser; + Object webBrowserObject; + MozillaDelegate mozDelegate; + + int chromeFlags = nsIWebBrowserChrome.CHROME_DEFAULT; + int refCount, lastKeyCode, lastCharCode; + int /*long*/ request; + Point location, size; + bool visible, isChild, ignoreDispose, awaitingNavigate; + Shell tip = null; + Listener listener; + + // replace with appropriate D/Tango data structure + Vector unhookedDOMWindows = new Vector (); + + static nsIAppShell AppShell; + static AppFileLocProvider LocationProvider; + static WindowCreator2 WindowCreator; + static int BrowserCount; + static bool Initialized, IsPre_1_8, PerformedVersionCheck, XPCOMWasGlued, XPCOMInitWasGlued; + + /* XULRunner detect constants */ + static final String GRERANGE_LOWER = "1.8.1.2"; //$NON-NLS-1$ + static final String GRERANGE_LOWER_FALLBACK = "1.8"; //$NON-NLS-1$ + static final bool LowerRangeInclusive = true; + static final String GRERANGE_UPPER = "1.9.*"; //$NON-NLS-1$ + static final bool UpperRangeInclusive = true; + + static final int MAX_PORT = 65535; + 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 = "dwt.browser.Mozilla.disposeListenerHooked"; //$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$ + static final String PREFERENCE_DISABLEWINDOWSTATUSCHANGE = "dom.disable_window_status_change"; //$NON-NLS-1$ + static final String PREFERENCE_LANGUAGES = "intl.accept_languages"; //$NON-NLS-1$ + static final String PREFERENCE_PROXYHOST_FTP = "network.proxy.ftp"; //$NON-NLS-1$ + static final String PREFERENCE_PROXYPORT_FTP = "network.proxy.ftp_port"; //$NON-NLS-1$ + static final String PREFERENCE_PROXYHOST_HTTP = "network.proxy.http"; //$NON-NLS-1$ + static final String PREFERENCE_PROXYPORT_HTTP = "network.proxy.http_port"; //$NON-NLS-1$ + static final String PREFERENCE_PROXYHOST_SSL = "network.proxy.ssl"; //$NON-NLS-1$ + static final String PREFERENCE_PROXYPORT_SSL = "network.proxy.ssl_port"; //$NON-NLS-1$ + static final String PREFERENCE_PROXYTYPE = "network.proxy.type"; //$NON-NLS-1$ + static final String PROFILE_AFTER_CHANGE = "profile-after-change"; //$NON-NLS-1$ + static final String PROFILE_BEFORE_CHANGE = "profile-before-change"; //$NON-NLS-1$ + static final String PROFILE_DIR = SEPARATOR_OS + "eclipse" + SEPARATOR_OS; //$NON-NLS-1$ + static final String PROFILE_DO_CHANGE = "profile-do-change"; //$NON-NLS-1$ + static final String PROPERTY_PROXYPORT = "network.proxy_port"; //$NON-NLS-1$ + static final String PROPERTY_PROXYHOST = "network.proxy_host"; //$NON-NLS-1$ + static final String SEPARATOR_LOCALE = "-"; //$NON-NLS-1$ + static final String SHUTDOWN_PERSIST = "shutdown-persist"; //$NON-NLS-1$ + static final String STARTUP = "startup"; //$NON-NLS-1$ + static final String TOKENIZER_LOCALE = ","; //$NON-NLS-1$ + static final String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$ + static final String XULRUNNER_PATH = "dwt.browser.XULRunnerPath"; //$NON-NLS-1$ + + // TEMPORARY CODE + static final String GRE_INITIALIZED = "dwt.browser.XULRunnerInitialized"; //$NON-NLS-1$ + + static { + MozillaClearSessions = new Runnable () { + public void run () { + if (!Initialized) return; + int /*long*/[] result = new int /*long*/[1]; + int rc = XPCOM.NS_GetServiceManager (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + nsIServiceManager serviceManager = new nsIServiceManager (result[0]); + result[0] = 0; + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_COOKIEMANAGER_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsICookieManager.NS_ICOOKIEMANAGER_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + serviceManager.Release (); + + nsICookieManager manager = new nsICookieManager (result[0]); + result[0] = 0; + rc = manager.GetEnumerator (result); + if (rc !is XPCOM.NS_OK) error (rc); + manager.Release (); + + nsISimpleEnumerator enumerator = new nsISimpleEnumerator (result[0]); + int[] moreElements = new int[1]; /* PRBool */ + rc = enumerator.HasMoreElements (moreElements); + if (rc !is XPCOM.NS_OK) error (rc); + while (moreElements[0] !is 0) { + result[0] = 0; + rc = enumerator.GetNext (result); + if (rc !is XPCOM.NS_OK) error (rc); + nsICookie cookie = new nsICookie (result[0]); + long[] expires = new long[1]; + rc = cookie.GetExpires (expires); + if (expires[0] is 0) { + /* indicates a session cookie */ + int /*long*/ domain = XPCOM.nsEmbedCString_new (); + int /*long*/ name = XPCOM.nsEmbedCString_new (); + int /*long*/ path = XPCOM.nsEmbedCString_new (); + cookie.GetHost (domain); + cookie.GetName (name); + cookie.GetPath (path); + rc = manager.Remove (domain, name, path, 0); + XPCOM.nsEmbedCString_delete (domain); + XPCOM.nsEmbedCString_delete (name); + XPCOM.nsEmbedCString_delete (path); + if (rc !is XPCOM.NS_OK) error (rc); + } + cookie.Release (); + rc = enumerator.HasMoreElements (moreElements); + if (rc !is XPCOM.NS_OK) error (rc); + } + enumerator.Release (); + } + }; + } + +public void create (Composite parent, int style) { + mozDelegate = new MozillaDelegate (browser); + Display display = parent.getDisplay (); + + int /*long*/[] result = new int /*long*/[1]; + if (!Initialized) { + bool initLoaded = false; + bool IsXULRunner = false; + + String greInitialized = System.getProperty (GRE_INITIALIZED); + if ("true".equals (greInitialized)) { //$NON-NLS-1$ + /* + * Another browser has already initialized xulrunner in this process, + * so just bind to it instead of trying to initialize a new one. + */ + Initialized = true; + } + String mozillaPath = System.getProperty (XULRUNNER_PATH); + if (mozillaPath is null) { + try { + String libName = mozDelegate.getSWTInitLibraryName (); + Library.loadLibrary (libName); + initLoaded = true; + } catch (UnsatisfiedLinkError e) { + /* + * If this library failed to load then do not attempt to detect a + * xulrunner to use. The Browser may still be usable if MOZILLA_FIVE_HOME + * points at a GRE. + */ + } + } else { + mozillaPath += SEPARATOR_OS + mozDelegate.getLibraryName (); + IsXULRunner = true; + } + + if (initLoaded) { + /* attempt to discover a XULRunner to use as the GRE */ + GREVersionRange range = new GREVersionRange (); + byte[] bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER, true); + int /*long*/ lower = C.malloc (bytes.length); + C.memmove (lower, bytes, bytes.length); + range.lower = lower; + range.lowerInclusive = LowerRangeInclusive; + + bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_UPPER, true); + int /*long*/ upper = C.malloc (bytes.length); + C.memmove (upper, bytes, bytes.length); + range.upper = upper; + range.upperInclusive = UpperRangeInclusive; + + int length = XPCOMInit.PATH_MAX; + int /*long*/ greBuffer = C.malloc (length); + int /*long*/ propertiesPtr = C.malloc (2 * C.PTR_SIZEOF); + int rc = XPCOMInit.GRE_GetGREPathWithProperties (range, 1, propertiesPtr, 0, greBuffer, length); + + /* + * A XULRunner was not found that supports wrapping of XPCOM handles as JavaXPCOM objects. + * Drop the lower version bound and try to detect an earlier XULRunner installation. + */ + if (rc !is XPCOM.NS_OK) { + C.free (lower); + bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER_FALLBACK, true); + lower = C.malloc (bytes.length); + C.memmove (lower, bytes, bytes.length); + range.lower = lower; + rc = XPCOMInit.GRE_GetGREPathWithProperties (range, 1, propertiesPtr, 0, greBuffer, length); + } + + C.free (lower); + C.free (upper); + C.free (propertiesPtr); + if (rc is XPCOM.NS_OK) { + /* indicates that a XULRunner was found */ + length = C.strlen (greBuffer); + bytes = new byte[length]; + C.memmove (bytes, greBuffer, length); + mozillaPath = new String (MozillaDelegate.mbcsToWcs (null, bytes)); + IsXULRunner = mozillaPath.length () > 0; + + /* + * Test whether the detected XULRunner can be used as the GRE before loading swt's + * XULRunner library. If it cannot be used then fall back to attempting to use + * the GRE pointed to by MOZILLA_FIVE_HOME. + * + * One case where this will fail is attempting to use a 64-bit xulrunner while swt + * is running in 32-bit mode, or vice versa. + */ + if (IsXULRunner) { + byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true); + rc = XPCOMInit.XPCOMGlueStartup (path); + if (rc !is XPCOM.NS_OK) { + IsXULRunner = false; /* failed */ + mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS)); + if (Device.DEBUG) System.out.println ("cannot use detected XULRunner: " + mozillaPath); //$NON-NLS-1$ + } else { + XPCOMInitWasGlued = true; + } + } + } + C.free (greBuffer); + } + + if (IsXULRunner) { + if (Device.DEBUG) System.out.println ("XULRunner path: " + mozillaPath); //$NON-NLS-1$ + try { + Library.loadLibrary ("swt-xulrunner"); //$NON-NLS-1$ + } catch (UnsatisfiedLinkError e) { + DWT.error (DWT.ERROR_NO_HANDLES, e); + } + byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true); + int rc = XPCOM.XPCOMGlueStartup (path); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + XPCOMWasGlued = true; + + /* + * Remove the trailing xpcom lib name from mozillaPath because the + * Mozilla.initialize and NS_InitXPCOM2 invocations require a directory name only. + */ + mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS)); + } else { + if ((style & DWT.MOZILLA) !is 0) { + browser.dispose (); + String errorString = (mozillaPath !is null && mozillaPath.length () > 0) ? + " [Failed to use detected XULRunner: " + mozillaPath + "]" : + " [Could not detect registered XULRunner to use]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + DWT.error (DWT.ERROR_NO_HANDLES, null, errorString); + } + + /* attempt to use the GRE pointed at by MOZILLA_FIVE_HOME */ + int /*long*/ ptr = C.getenv (MozillaDelegate.wcsToMbcs (null, XPCOM.MOZILLA_FIVE_HOME, true)); + if (ptr !is 0) { + int length = C.strlen (ptr); + byte[] buffer = new byte[length]; + C.memmove (buffer, ptr, length); + mozillaPath = new String (MozillaDelegate.mbcsToWcs (null, buffer)); + } else { + browser.dispose (); + DWT.error (DWT.ERROR_NO_HANDLES, null, " [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]"); //$NON-NLS-1$ + } + if (Device.DEBUG) System.out.println ("Mozilla path: " + mozillaPath); //$NON-NLS-1$ + + /* + * Note. Embedding a Mozilla GTK1.2 causes a crash. The workaround + * is to check the version of GTK used by Mozilla by looking for + * the libwidget_gtk.so library used by Mozilla GTK1.2. Mozilla GTK2 + * uses the libwidget_gtk2.so library. + */ + if (Compatibility.fileExists (mozillaPath, "components/libwidget_gtk.so")) { //$NON-NLS-1$ + browser.dispose (); + DWT.error (DWT.ERROR_NO_HANDLES, null, " [Mozilla GTK2 required (GTK1.2 detected)]"); //$NON-NLS-1$ + } + + try { + Library.loadLibrary ("swt-mozilla"); //$NON-NLS-1$ + } catch (UnsatisfiedLinkError e) { + try { + /* + * The initial loadLibrary attempt may have failed as a result of the user's + * system not having libstdc++.so.6 installed, so try to load the alternate + * swt mozilla library that depends on libswtc++.so.5 instead. + */ + Library.loadLibrary ("swt-mozilla-gcc3"); //$NON-NLS-1$ + } catch (UnsatisfiedLinkError ex) { + browser.dispose (); + /* + * Print the error from the first failed attempt since at this point it's + * known that the failure was not due to the libstdc++.so.6 dependency. + */ + DWT.error (DWT.ERROR_NO_HANDLES, e, " [MOZILLA_FIVE_HOME='" + mozillaPath + "']"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + } + + if (!Initialized) { + int /*long*/[] retVal = new int /*long*/[1]; + nsEmbedString pathString = new nsEmbedString (mozillaPath); + int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, retVal); + pathString.dispose (); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (retVal[0] is 0) { + browser.dispose (); + error (XPCOM.NS_ERROR_NULL_POINTER); + } + + LocationProvider = new AppFileLocProvider (mozillaPath); + LocationProvider.AddRef (); + + nsIFile localFile = new nsILocalFile (retVal[0]); + rc = XPCOM.NS_InitXPCOM2 (0, localFile.getAddress(), LocationProvider.getAddress ()); + localFile.Release (); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + DWT.error (DWT.ERROR_NO_HANDLES, null, " [MOZILLA_FIVE_HOME may not point at an embeddable GRE] [NS_InitEmbedding " + mozillaPath + " error " + rc + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + System.setProperty (GRE_INITIALIZED, "true"); //$NON-NLS-1$ + if (IsXULRunner) { + System.setProperty (XULRUNNER_PATH, mozillaPath); + } + } + + /* If JavaXPCOM is detected then attempt to initialize it with the XULRunner being used */ + if (IsXULRunner) { + try { + Class clazz = Class.forName ("org.mozilla.xpcom.Mozilla"); //$NON-NLS-1$ + Method method = clazz.getMethod ("getInstance", new Class[0]); //$NON-NLS-1$ + Object mozilla = method.invoke (null, new Object[0]); + method = clazz.getMethod ("getComponentManager", new Class[0]); //$NON-NLS-1$ + try { + method.invoke (mozilla, new Object[0]); + } catch (InvocationTargetException e) { + /* indicates that JavaXPCOM has not been initialized yet */ + Class fileClass = Class.forName ("java.io.File"); //$NON-NLS-1$ + method = clazz.getMethod ("initialize", new Class[] {fileClass}); //$NON-NLS-1$ + Constructor constructor = fileClass.getDeclaredConstructor (new Class[] {String.class}); + Object argument = constructor.newInstance (new Object[] {mozillaPath}); + method.invoke (mozilla, new Object[] {argument}); + } + } catch (ClassNotFoundException e) { + /* JavaXPCOM is not on the classpath */ + } catch (NoSuchMethodException e) { + /* the JavaXPCOM on the classpath does not implement initialize() */ + } catch (IllegalArgumentException e) { + } catch (IllegalAccessException e) { + } catch (InvocationTargetException e) { + } catch (InstantiationException e) { + } + } + + int rc = XPCOM.NS_GetComponentManager (result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + + nsIComponentManager componentManager = new nsIComponentManager (result[0]); + result[0] = 0; + if (mozDelegate.needsSpinup ()) { + /* nsIAppShell is discontinued as of xulrunner 1.9, so do not fail if it is not found */ + rc = componentManager.CreateInstance (XPCOM.NS_APPSHELL_CID, 0, nsIAppShell.NS_IAPPSHELL_IID, result); + if (rc !is XPCOM.NS_ERROR_NO_INTERFACE) { + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + + AppShell = new nsIAppShell (result[0]); + rc = AppShell.Create (0, null); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + rc = AppShell.Spinup (); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + } + result[0] = 0; + } + + WindowCreator = new WindowCreator2 (); + WindowCreator.AddRef (); + + rc = XPCOM.NS_GetServiceManager (result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + + nsIServiceManager serviceManager = new nsIServiceManager (result[0]); + result[0] = 0; + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsIWindowWatcher.NS_IWINDOWWATCHER_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + + nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]); + result[0] = 0; + rc = windowWatcher.SetWindowCreator (WindowCreator.getAddress()); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + windowWatcher.Release (); + + /* compute the profile directory and set it on the AppFileLocProvider */ + if (LocationProvider !is null) { + byte[] buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DIRECTORYSERVICE_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (buffer, nsIDirectoryService.NS_IDIRECTORYSERVICE_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + + nsIDirectoryService directoryService = new nsIDirectoryService (result[0]); + result[0] = 0; + rc = directoryService.QueryInterface (nsIProperties.NS_IPROPERTIES_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + directoryService.Release (); + + nsIProperties properties = new nsIProperties (result[0]); + result[0] = 0; + buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_APP_APPLICATION_REGISTRY_DIR, true); + rc = properties.Get (buffer, nsIFile.NS_IFILE_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + properties.Release (); + + nsIFile profileDir = new nsIFile (result[0]); + result[0] = 0; + int /*long*/ path = XPCOM.nsEmbedCString_new (); + rc = profileDir.GetNativePath (path); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + int length = XPCOM.nsEmbedCString_Length (path); + int /*long*/ ptr = XPCOM.nsEmbedCString_get (path); + buffer = new byte [length]; + XPCOM.memmove (buffer, ptr, length); + String profilePath = new String (MozillaDelegate.mbcsToWcs (null, buffer)) + PROFILE_DIR; + LocationProvider.setProfilePath (profilePath); + LocationProvider.isXULRunner = IsXULRunner; + XPCOM.nsEmbedCString_delete (path); + profileDir.Release (); + + /* notify observers of a new profile directory being used */ + buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_OBSERVER_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (buffer, nsIObserverService.NS_IOBSERVERSERVICE_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + + nsIObserverService observerService = new nsIObserverService (result[0]); + result[0] = 0; + buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_DO_CHANGE, true); + length = STARTUP.length (); + char[] chars = new char [length + 1]; + STARTUP.getChars (0, length, chars, 0); + rc = observerService.NotifyObservers (0, buffer, chars); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_AFTER_CHANGE, true); + rc = observerService.NotifyObservers (0, buffer, chars); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + observerService.Release (); + } + + /* + * As a result of using a common profile the user cannot change their locale + * and charset. The fix for this is to set mozilla's locale and charset + * preference values according to the user's current locale and charset. + */ + aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFSERVICE_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsIPrefService.NS_IPREFSERVICE_IID, result); + serviceManager.Release (); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + + nsIPrefService prefService = new nsIPrefService (result[0]); + result[0] = 0; + byte[] buffer = new byte[1]; + rc = prefService.GetBranch (buffer, result); /* empty buffer denotes root preference level */ + prefService.Release (); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + + nsIPrefBranch prefBranch = new nsIPrefBranch (result[0]); + result[0] = 0; + + /* get Mozilla's current locale preference value */ + String prefLocales = null; + nsIPrefLocalizedString localizedString = null; + buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_LANGUAGES, true); + rc = prefBranch.GetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result); + /* + * Feature of Debian. For some reason attempting to query for the current locale + * preference fails on Debian. The workaround for this is to assume a value of + * "en-us,en" since this is typically the default value when mozilla is used without + * a profile. + */ + if (rc !is XPCOM.NS_OK) { + prefLocales = "en-us,en" + TOKENIZER_LOCALE; //$NON-NLS-1$ + } else { + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + localizedString = new nsIPrefLocalizedString (result[0]); + result[0] = 0; + rc = localizedString.ToString (result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + int length = XPCOM.strlen_PRUnichar (result[0]); + char[] dest = new char[length]; + XPCOM.memmove (dest, result[0], length * 2); + prefLocales = new String (dest) + TOKENIZER_LOCALE; + } + result[0] = 0; + + /* + * construct the new locale preference value by prepending the + * user's current locale and language to the original value + */ + Locale locale = Locale.getDefault (); + String language = locale.getLanguage (); + String country = locale.getCountry (); + StringBuffer stringBuffer = new StringBuffer (language); + stringBuffer.append (SEPARATOR_LOCALE); + stringBuffer.append (country.toLowerCase ()); + stringBuffer.append (TOKENIZER_LOCALE); + stringBuffer.append (language); + stringBuffer.append (TOKENIZER_LOCALE); + String newLocales = stringBuffer.toString (); + + int start, end = -1; + do { + start = end + 1; + end = prefLocales.indexOf (TOKENIZER_LOCALE, start); + String token; + if (end is -1) { + token = prefLocales.substring (start); + } else { + token = prefLocales.substring (start, end); + } + if (token.length () > 0) { + token = (token + TOKENIZER_LOCALE).trim (); + /* ensure that duplicate locale values are not added */ + if (newLocales.indexOf (token) is -1) { + stringBuffer.append (token); + } + } + } while (end !is -1); + newLocales = stringBuffer.toString (); + if (!newLocales.equals (prefLocales)) { + /* write the new locale value */ + newLocales = newLocales.substring (0, newLocales.length () - TOKENIZER_LOCALE.length ()); /* remove trailing tokenizer */ + int length = newLocales.length (); + char[] charBuffer = new char[length + 1]; + newLocales.getChars (0, length, charBuffer, 0); + if (localizedString is null) { + byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true); + rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + localizedString = new nsIPrefLocalizedString (result[0]); + result[0] = 0; + } + localizedString.SetDataWithLength (length, charBuffer); + rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress()); + } + if (localizedString !is null) { + localizedString.Release (); + localizedString = null; + } + + /* get Mozilla's current charset preference value */ + String prefCharset = null; + buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_CHARSET, true); + rc = prefBranch.GetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result); + /* + * Feature of Debian. For some reason attempting to query for the current charset + * preference fails on Debian. The workaround for this is to assume a value of + * "ISO-8859-1" since this is typically the default value when mozilla is used + * without a profile. + */ + if (rc !is XPCOM.NS_OK) { + prefCharset = "ISO-8859-1"; //$NON_NLS-1$ + } else { + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + localizedString = new nsIPrefLocalizedString (result[0]); + result[0] = 0; + rc = localizedString.ToString (result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + int length = XPCOM.strlen_PRUnichar (result[0]); + char[] dest = new char[length]; + XPCOM.memmove (dest, result[0], length * 2); + prefCharset = new String (dest); + } + result[0] = 0; + + String newCharset = System.getProperty ("file.encoding"); // $NON-NLS-1$ + if (!newCharset.equals (prefCharset)) { + /* write the new charset value */ + int length = newCharset.length (); + char[] charBuffer = new char[length + 1]; + newCharset.getChars (0, length, charBuffer, 0); + if (localizedString is null) { + byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true); + rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + localizedString = new nsIPrefLocalizedString (result[0]); + result[0] = 0; + } + localizedString.SetDataWithLength (length, charBuffer); + rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress ()); + } + if (localizedString !is null) localizedString.Release (); + + /* + * Check for proxy values set as documented java properties and update mozilla's + * preferences with these values if needed. + */ + String proxyHost = System.getProperty (PROPERTY_PROXYHOST); + String proxyPortString = System.getProperty (PROPERTY_PROXYPORT); + + int port = -1; + if (proxyPortString !is null) { + try { + int value = Integer.valueOf (proxyPortString).intValue (); + if (0 <= value && value <= MAX_PORT) port = value; + } catch (NumberFormatException e) { + /* do nothing, java property has non-integer value */ + } + } + + if (proxyHost !is null) { + byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true); + rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + localizedString = new nsIPrefLocalizedString (result[0]); + result[0] = 0; + int length = proxyHost.length (); + char[] charBuffer = new char[length + 1]; + proxyHost.getChars (0, length, charBuffer, 0); + rc = localizedString.SetDataWithLength (length, charBuffer); + if (rc !is XPCOM.NS_OK) error (rc); + buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_FTP, true); + rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress ()); + if (rc !is XPCOM.NS_OK) error (rc); + buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_HTTP, true); + rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress ()); + if (rc !is XPCOM.NS_OK) error (rc); + buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_SSL, true); + rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress ()); + if (rc !is XPCOM.NS_OK) error (rc); + localizedString.Release (); + } + + if (port !is -1) { + buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYPORT_FTP, true); + rc = prefBranch.SetIntPref (buffer, port); + if (rc !is XPCOM.NS_OK) error (rc); + buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYPORT_HTTP, true); + rc = prefBranch.SetIntPref (buffer, port); + if (rc !is XPCOM.NS_OK) error (rc); + buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYPORT_SSL, true); + rc = prefBranch.SetIntPref (buffer, port); + if (rc !is XPCOM.NS_OK) error (rc); + } + + if (proxyHost !is null || port !is -1) { + buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYTYPE, true); + rc = prefBranch.SetIntPref (buffer, 1); + if (rc !is XPCOM.NS_OK) error (rc); + } + + /* + * Ensure that windows that are shown during page loads are not blocked. Firefox may + * try to block these by default since such windows are often unwelcome, but this + * assumption should not be made in the Browser's context. Since the Browser client + * is responsible for creating the new Browser and Shell in an OpenWindowListener, + * they should decide whether the new window is unwelcome or not and act accordingly. + */ + buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_DISABLEOPENDURINGLOAD, true); + rc = prefBranch.SetBoolPref (buffer, 0); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + + /* Ensure that the status text can be set through means like javascript */ + buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_DISABLEWINDOWSTATUSCHANGE, true); + rc = prefBranch.SetBoolPref (buffer, 0); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + + prefBranch.Release (); + + PromptService2Factory factory = new PromptService2Factory (); + factory.AddRef (); + + rc = componentManager.QueryInterface (nsIComponentRegistrar.NS_ICOMPONENTREGISTRAR_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + + nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]); + result[0] = 0; + aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PROMPTSERVICE_CONTRACTID, true); + byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Prompt Service", true); //$NON-NLS-1$ + rc = componentRegistrar.RegisterFactory (XPCOM.NS_PROMPTSERVICE_CID, aClassName, aContractID, factory.getAddress ()); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + factory.Release (); + + HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory (); + dialogFactory.AddRef (); + aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true); + aClassName = MozillaDelegate.wcsToMbcs (null, "Helper App Launcher Dialog", true); //$NON-NLS-1$ + rc = componentRegistrar.RegisterFactory (XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName, aContractID, dialogFactory.getAddress ()); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + dialogFactory.Release (); + + /* + * This Download factory will be used if the GRE version is < 1.8. + * If the GRE version is 1.8.x then the Download factory that is registered later for + * contract "Transfer" will be used. + * If the GRE version is >= 1.9 then no Download factory is registered because this + * functionality is provided by the GRE. + */ + DownloadFactory downloadFactory = new DownloadFactory (); + downloadFactory.AddRef (); + aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOWNLOAD_CONTRACTID, true); + aClassName = MozillaDelegate.wcsToMbcs (null, "Download", true); //$NON-NLS-1$ + rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName, aContractID, downloadFactory.getAddress ()); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + downloadFactory.Release (); + + FilePickerFactory pickerFactory = IsXULRunner ? new FilePickerFactory_1_8 () : new FilePickerFactory (); + pickerFactory.AddRef (); + aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_FILEPICKER_CONTRACTID, true); + aClassName = MozillaDelegate.wcsToMbcs (null, "FilePicker", true); //$NON-NLS-1$ + rc = componentRegistrar.RegisterFactory (XPCOM.NS_FILEPICKER_CID, aClassName, aContractID, pickerFactory.getAddress ()); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + pickerFactory.Release (); + + componentRegistrar.Release (); + componentManager.Release (); + + Initialized = true; + } + + if (display.getData (DISPOSE_LISTENER_HOOKED) is null) { + display.setData (DISPOSE_LISTENER_HOOKED, DISPOSE_LISTENER_HOOKED); + display.addListener (DWT.Dispose, new Listener () { + public void handleEvent (Event event) { + if (BrowserCount > 0) return; /* another display is still active */ + + int /*long*/[] result = new int /*long*/[1]; + int rc = XPCOM.NS_GetServiceManager (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + nsIServiceManager serviceManager = new nsIServiceManager (result[0]); + result[0] = 0; + byte[] buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_OBSERVER_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (buffer, nsIObserverService.NS_IOBSERVERSERVICE_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + nsIObserverService observerService = new nsIObserverService (result[0]); + result[0] = 0; + buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_BEFORE_CHANGE, true); + int length = SHUTDOWN_PERSIST.length (); + char[] chars = new char [length + 1]; + SHUTDOWN_PERSIST.getChars (0, length, chars, 0); + rc = observerService.NotifyObservers (0, buffer, chars); + if (rc !is XPCOM.NS_OK) error (rc); + observerService.Release (); + + if (LocationProvider !is null) { + String prefsLocation = LocationProvider.profilePath + AppFileLocProvider.PREFERENCES_FILE; + nsEmbedString pathString = new nsEmbedString (prefsLocation); + rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); + pathString.dispose (); + + nsILocalFile localFile = new nsILocalFile (result [0]); + result[0] = 0; + rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); + localFile.Release (); + + nsIFile prefFile = new nsIFile (result[0]); + result[0] = 0; + + buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFSERVICE_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (buffer, nsIPrefService.NS_IPREFSERVICE_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + nsIPrefService prefService = new nsIPrefService (result[0]); + result[0] = 0; + rc = prefService.SavePrefFile(prefFile.getAddress ()); + prefService.Release (); + prefFile.Release (); + } + serviceManager.Release (); + + if (XPCOMWasGlued) { + XPCOM.XPCOMGlueShutdown (); + XPCOMWasGlued = false; + } + if (XPCOMInitWasGlued) { + XPCOMInit.XPCOMGlueShutdown (); + XPCOMInitWasGlued = false; + } + Initialized = false; + } + }); + } + + BrowserCount++; + int rc = XPCOM.NS_GetComponentManager (result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + + nsIComponentManager componentManager = new nsIComponentManager (result[0]); + result[0] = 0; + nsID NS_IWEBBROWSER_CID = new nsID ("F1EAC761-87E9-11d3-AF80-00A024FFC08C"); //$NON-NLS-1$ + rc = componentManager.CreateInstance (NS_IWEBBROWSER_CID, 0, nsIWebBrowser.NS_IWEBBROWSER_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + + webBrowser = new nsIWebBrowser (result[0]); + result[0] = 0; + + createCOMInterfaces (); + AddRef (); + + rc = webBrowser.SetContainerWindow (webBrowserChrome.getAddress()); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + + rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_ERROR_NO_INTERFACE); + } + + nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]); + result[0] = 0; + Rectangle rect = browser.getClientArea (); + if (rect.isEmpty ()) { + rect.width = 1; + rect.height = 1; + } + + embedHandle = mozDelegate.getHandle (); + + rc = baseWindow.InitWindow (embedHandle, 0, 0, 0, rect.width, rect.height); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (XPCOM.NS_ERROR_FAILURE); + } + rc = baseWindow.Create (); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (XPCOM.NS_ERROR_FAILURE); + } + rc = baseWindow.SetVisibility (1); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (XPCOM.NS_ERROR_FAILURE); + } + baseWindow.Release (); + + if (!PerformedVersionCheck) { + PerformedVersionCheck = true; + + /* + * Check for the availability of the pre-1.8 implementation of nsIDocShell + * to determine if the GRE's version is < 1.8. + */ + rc = webBrowser.QueryInterface (nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (XPCOM.NS_ERROR_FAILURE); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_ERROR_NO_INTERFACE); + } + nsIInterfaceRequestor interfaceRequestor = new nsIInterfaceRequestor (result[0]); + result[0] = 0; + + rc = interfaceRequestor.GetInterface (nsIDocShell.NS_IDOCSHELL_IID, result); + if (rc is XPCOM.NS_OK && result[0] !is 0) { + IsPre_1_8 = true; + new nsISupports (result[0]).Release (); + } + result[0] = 0; + + /* + * A Download factory for contract "Transfer" must be registered iff the GRE's version is 1.8.x. + * Check for the availability of the 1.8 implementation of nsIDocShell to determine if the + * GRE's version is 1.8.x. + * If the GRE version is < 1.8 then the previously-registered Download factory for contract + * "Download" will be used. + * If the GRE version is >= 1.9 then no Download factory is registered because this + * functionality is provided by the GRE. + */ + if (!IsPre_1_8) { + rc = interfaceRequestor.GetInterface (nsIDocShell_1_8.NS_IDOCSHELL_IID, result); + if (rc is XPCOM.NS_OK && result[0] !is 0) { /* 1.8 */ + new nsISupports (result[0]).Release (); + result[0] = 0; + rc = componentManager.QueryInterface (nsIComponentRegistrar.NS_ICOMPONENTREGISTRAR_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_NOINTERFACE); + } + + nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]); + DownloadFactory_1_8 downloadFactory_1_8 = new DownloadFactory_1_8 (); + downloadFactory_1_8.AddRef (); + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_TRANSFER_CONTRACTID, true); + byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Transfer", true); //$NON-NLS-1$ + rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName, aContractID, downloadFactory_1_8.getAddress ()); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + downloadFactory_1_8.Release (); + componentRegistrar.Release (); + } else { /* >= 1.9 */ + /* + * Bug in XULRunner 1.9. Mozilla no longer clears its background before initial content has + * been set. As a result embedders appear broken if they do not immediately navigate to a url. + * The workaround for this is to navigate to about:blank immediately so that the background is + * cleared, but do not fire any corresponding events or allow Browser API calls to reveal this. + * Once the client does a proper navigate with either setUrl() or setText() then resume as + * normal. The Mozilla bug for this is https://bugzilla.mozilla.org/show_bug.cgi?id=415789. + */ + awaitingNavigate = true; + rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + if (result[0] is 0) { + browser.dispose (); + error (XPCOM.NS_ERROR_NO_INTERFACE); + } + nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + char[] uri = new char[ABOUT_BLANK.length () + 1]; + ABOUT_BLANK.getChars (0, ABOUT_BLANK.length (), uri, 0); + rc = webNavigation.LoadURI (uri, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0); + webNavigation.Release (); + } + } + result[0] = 0; + interfaceRequestor.Release (); + } + componentManager.Release (); + + rc = webBrowser.AddWebBrowserListener (weakReference.getAddress (), nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + + rc = webBrowser.SetParentURIContentListener (uriContentListener.getAddress ()); + if (rc !is XPCOM.NS_OK) { + browser.dispose (); + error (rc); + } + + mozDelegate.init (); + + listener = new Listener () { + public void handleEvent (Event event) { + switch (event.type) { + case DWT.Dispose: { + /* make this handler run after other dispose listeners */ + if (ignoreDispose) { + ignoreDispose = false; + break; + } + ignoreDispose = true; + browser.notifyListeners (event.type, event); + event.type = DWT.NONE; + onDispose (event.display); + break; + } + case DWT.Resize: onResize (); break; + case DWT.FocusIn: Activate (); break; + case DWT.Activate: Activate (); break; + case DWT.Deactivate: { + Display display = event.display; + if (Mozilla.this.browser is display.getFocusControl ()) Deactivate (); + break; + } + case DWT.Show: { + /* + * Feature in GTK Mozilla. Mozilla does not show up when + * its container (a GTK fixed handle) is made visible + * after having been hidden. The workaround is to reset + * its size after the container has been made visible. + */ + Display display = event.display; + display.asyncExec(new Runnable () { + public void run() { + if (browser.isDisposed ()) return; + onResize (); + } + }); + break; + } + } + } + }; + int[] folderEvents = new int[] { + DWT.Dispose, + DWT.Resize, + DWT.FocusIn, + DWT.Activate, + DWT.Deactivate, + DWT.Show, + DWT.KeyDown // needed to make browser traversable + }; + for (int i = 0; i < folderEvents.length; i++) { + browser.addListener (folderEvents[i], listener); + } +} + +public bool back () { + if (awaitingNavigate) return false; + + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + rc = webNavigation.GoBack (); + webNavigation.Release (); + return rc is XPCOM.NS_OK; +} + +void createCOMInterfaces () { + // Create each of the interfaces that this object implements + supports = new XPCOMObject (new int[] {2, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + }; + + weakReference = new XPCOMObject (new int[] {2, 0, 0, 2}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return QueryReferent (args[0], args[1]);} + }; + + webProgressListener = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);} + public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);} + public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);} + public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);} + public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);} + }; + + webBrowserChrome = new XPCOMObject (new int[] {2, 0, 0, 2, 1, 1, 1, 1, 0, 2, 0, 1, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return SetStatus ((int)/*64*/args[0], args[1]);} + public int /*long*/ method4 (int /*long*/[] args) {return GetWebBrowser (args[0]);} + public int /*long*/ method5 (int /*long*/[] args) {return SetWebBrowser (args[0]);} + public int /*long*/ method6 (int /*long*/[] args) {return GetChromeFlags (args[0]);} + public int /*long*/ method7 (int /*long*/[] args) {return SetChromeFlags ((int)/*64*/args[0]);} + public int /*long*/ method8 (int /*long*/[] args) {return DestroyBrowserWindow ();} + public int /*long*/ method9 (int /*long*/[] args) {return SizeBrowserTo ((int)/*64*/args[0], (int)/*64*/args[1]);} + public int /*long*/ method10 (int /*long*/[] args) {return ShowAsModal ();} + public int /*long*/ method11 (int /*long*/[] args) {return IsWindowModal (args[0]);} + public int /*long*/ method12 (int /*long*/[] args) {return ExitModalEventLoop ((int)/*64*/args[0]);} + }; + + webBrowserChromeFocus = new XPCOMObject (new int[] {2, 0, 0, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return FocusNextElement ();} + public int /*long*/ method4 (int /*long*/[] args) {return FocusPrevElement ();} + }; + + embeddingSiteWindow = new XPCOMObject (new int[] {2, 0, 0, 5, 5, 0, 1, 1, 1, 1, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return SetDimensions ((int)/*64*/args[0], (int)/*64*/args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4]);} + public int /*long*/ method4 (int /*long*/[] args) {return GetDimensions ((int)/*64*/args[0], args[1], args[2], args[3], args[4]);} + public int /*long*/ method5 (int /*long*/[] args) {return SetFocus ();} + public int /*long*/ method6 (int /*long*/[] args) {return GetVisibility (args[0]);} + public int /*long*/ method7 (int /*long*/[] args) {return SetVisibility ((int)/*64*/args[0]);} + public int /*long*/ method8 (int /*long*/[] args) {return GetTitle (args[0]);} + public int /*long*/ method9 (int /*long*/[] args) {return SetTitle (args[0]);} + public int /*long*/ method10 (int /*long*/[] args) {return GetSiteWindow (args[0]);} + }; + + interfaceRequestor = new XPCOMObject (new int[] {2, 0, 0, 2} ){ + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return GetInterface (args[0], args[1]);} + }; + + supportsWeakReference = new XPCOMObject (new int[] {2, 0, 0, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return GetWeakReference (args[0]);} + }; + + contextMenuListener = new XPCOMObject (new int[] {2, 0, 0, 3}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return OnShowContextMenu ((int)/*64*/args[0], args[1], args[2]);} + }; + + uriContentListener = new XPCOMObject (new int[] {2, 0, 0, 2, 5, 3, 4, 1, 1, 1, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return OnStartURIOpen (args[0], args[1]);} + public int /*long*/ method4 (int /*long*/[] args) {return DoContent (args[0], (int)/*64*/args[1], args[2], args[3], args[4]);} + public int /*long*/ method5 (int /*long*/[] args) {return IsPreferred (args[0], args[1], args[2]);} + public int /*long*/ method6 (int /*long*/[] args) {return CanHandleContent (args[0], (int)/*64*/args[1], args[2], args[3]);} + public int /*long*/ method7 (int /*long*/[] args) {return GetLoadCookie (args[0]);} + public int /*long*/ method8 (int /*long*/[] args) {return SetLoadCookie (args[0]);} + public int /*long*/ method9 (int /*long*/[] args) {return GetParentContentListener (args[0]);} + public int /*long*/ method10 (int /*long*/[] args) {return SetParentContentListener (args[0]);} + }; + + tooltipListener = new XPCOMObject (new int[] {2, 0, 0, 3, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return OnShowTooltip ((int)/*64*/args[0], (int)/*64*/args[1], args[2]);} + public int /*long*/ method4 (int /*long*/[] args) {return OnHideTooltip ();} + }; + + domEventListener = new XPCOMObject (new int[] {2, 0, 0, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return HandleEvent (args[0]);} + }; +} + +void disposeCOMInterfaces () { + if (supports !is null) { + supports.dispose (); + supports = null; + } + if (weakReference !is null) { + weakReference.dispose (); + weakReference = null; + } + if (webProgressListener !is null) { + webProgressListener.dispose (); + webProgressListener = null; + } + if (webBrowserChrome !is null) { + webBrowserChrome.dispose (); + webBrowserChrome = null; + } + if (webBrowserChromeFocus !is null) { + webBrowserChromeFocus.dispose (); + webBrowserChromeFocus = null; + } + if (embeddingSiteWindow !is null) { + embeddingSiteWindow.dispose (); + embeddingSiteWindow = null; + } + if (interfaceRequestor !is null) { + interfaceRequestor.dispose (); + interfaceRequestor = null; + } + if (supportsWeakReference !is null) { + supportsWeakReference.dispose (); + supportsWeakReference = null; + } + if (contextMenuListener !is null) { + contextMenuListener.dispose (); + contextMenuListener = null; + } + if (uriContentListener !is null) { + uriContentListener.dispose (); + uriContentListener = null; + } + if (tooltipListener !is null) { + tooltipListener.dispose (); + tooltipListener = null; + } + if (domEventListener !is null) { + domEventListener.dispose (); + domEventListener = null; + } +} + +public bool execute (String script) { + if (awaitingNavigate) return false; + + String url = PREFIX_JAVASCRIPT + script + ";void(0);"; //$NON-NLS-1$ + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + char[] arg = url.toCharArray (); + char[] c = new char[arg.length+1]; + System.arraycopy (arg, 0, c, 0, arg.length); + rc = webNavigation.LoadURI (c, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0); + webNavigation.Release (); + return rc is XPCOM.NS_OK; +} + +static Browser findBrowser (int /*long*/ handle) { + return MozillaDelegate.findBrowser (handle); +} + +public bool forward () { + if (awaitingNavigate) return false; + + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + rc = webNavigation.GoForward (); + webNavigation.Release (); + + return rc is XPCOM.NS_OK; +} + +public String getText () { + if (awaitingNavigate) return ""; //$NON-NLS-1$ + + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.GetContentDOMWindow (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + nsIDOMWindow window = new nsIDOMWindow (result[0]); + result[0] = 0; + rc = window.GetDocument (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + window.Release (); + + int /*long*/ document = result[0]; + result[0] = 0; + rc = XPCOM.NS_GetComponentManager (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + nsIComponentManager componentManager = new nsIComponentManager (result[0]); + result[0] = 0; + byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOMSERIALIZER_CONTRACTID, true); + char[] chars = null; + + rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIDOMSerializer_1_7.NS_IDOMSERIALIZER_IID, result); + if (rc is XPCOM.NS_OK) { /* mozilla >= 1.7 */ + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + nsIDOMSerializer_1_7 serializer = new nsIDOMSerializer_1_7 (result[0]); + result[0] = 0; + int /*long*/ string = XPCOM.nsEmbedString_new (); + rc = serializer.SerializeToString (document, string); + serializer.Release (); + + int length = XPCOM.nsEmbedString_Length (string); + int /*long*/ buffer = XPCOM.nsEmbedString_get (string); + chars = new char[length]; + XPCOM.memmove (chars, buffer, length * 2); + XPCOM.nsEmbedString_delete (string); + } else { /* mozilla < 1.7 */ + rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIDOMSerializer.NS_IDOMSERIALIZER_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + nsIDOMSerializer serializer = new nsIDOMSerializer (result[0]); + result[0] = 0; + rc = serializer.SerializeToString (document, result); + serializer.Release (); + + int length = XPCOM.strlen_PRUnichar (result[0]); + chars = new char[length]; + XPCOM.memmove (chars, result[0], length * 2); + } + + componentManager.Release (); + new nsISupports (document).Release (); + return new String (chars); +} + +public String getUrl () { + if (awaitingNavigate) return ""; //$NON-NLS-1$ + + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + int /*long*/[] aCurrentURI = new int /*long*/[1]; + rc = webNavigation.GetCurrentURI (aCurrentURI); + if (rc !is XPCOM.NS_OK) error (rc); + webNavigation.Release (); + + byte[] dest = null; + if (aCurrentURI[0] !is 0) { + nsIURI uri = new nsIURI (aCurrentURI[0]); + int /*long*/ aSpec = XPCOM.nsEmbedCString_new (); + rc = uri.GetSpec (aSpec); + if (rc !is XPCOM.NS_OK) error (rc); + int length = XPCOM.nsEmbedCString_Length (aSpec); + int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec); + dest = new byte[length]; + XPCOM.memmove (dest, buffer, length); + XPCOM.nsEmbedCString_delete (aSpec); + uri.Release (); + } + if (dest is null) return ""; //$NON-NLS-1$ + + String location = new String (dest); + /* + * If the URI indicates that the page is being rendered from memory + * (via setText()) then set it to about:blank to be consistent with IE. + */ + if (location.equals (URI_FROMMEMORY)) location = ABOUT_BLANK; + return location; +} + +public Object getWebBrowser () { + if ((browser.getStyle () & DWT.MOZILLA) is 0) return null; + if (webBrowserObject !is null) return webBrowserObject; + + try { + Class clazz = Class.forName ("org.mozilla.xpcom.Mozilla"); //$NON-NLS-1$ + Method method = clazz.getMethod ("getInstance", new Class[0]); //$NON-NLS-1$ + Object mozilla = method.invoke (null, new Object[0]); + method = clazz.getMethod ("wrapXPCOMObject", new Class[] {Long.TYPE, String.class}); //$NON-NLS-1$ + webBrowserObject = method.invoke (mozilla, new Object[] {new Long (webBrowser.getAddress ()), nsIWebBrowser.NS_IWEBBROWSER_IID_STR}); + /* + * The following AddRef() is needed to offset the automatic Release() that + * will be performed by JavaXPCOM when webBrowserObject is finalized. + */ + webBrowser.AddRef (); + return webBrowserObject; + } catch (ClassNotFoundException e) { + } catch (NoSuchMethodException e) { + } catch (IllegalArgumentException e) { + } catch (IllegalAccessException e) { + } catch (InvocationTargetException e) { + } + return null; +} + +public bool isBackEnabled () { + if (awaitingNavigate) return false; + + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + int[] aCanGoBack = new int[1]; /* PRBool */ + rc = webNavigation.GetCanGoBack (aCanGoBack); + webNavigation.Release (); + return aCanGoBack[0] !is 0; +} + +public bool isForwardEnabled () { + if (awaitingNavigate) return false; + + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + int[] aCanGoForward = new int[1]; /* PRBool */ + rc = webNavigation.GetCanGoForward (aCanGoForward); + webNavigation.Release (); + return aCanGoForward[0] !is 0; +} + +static String error (int code) { + throw new DWTError ("XPCOM error " + code); //$NON-NLS-1$ +} + +void onDispose (Display display) { + int rc = webBrowser.RemoveWebBrowserListener (weakReference.getAddress (), nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID); + if (rc !is XPCOM.NS_OK) error (rc); + + rc = webBrowser.SetParentURIContentListener (0); + if (rc !is XPCOM.NS_OK) error (rc); + + unhookDOMListeners (); + if (listener !is null) { + int[] folderEvents = new int[] { + DWT.Dispose, + DWT.Resize, + DWT.FocusIn, + DWT.Activate, + DWT.Deactivate, + DWT.Show, + DWT.KeyDown, + }; + for (int i = 0; i < folderEvents.length; i++) { + browser.removeListener (folderEvents[i], listener); + } + listener = null; + } + + int /*long*/[] result = new int /*long*/[1]; + rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]); + rc = baseWindow.Destroy (); + if (rc !is XPCOM.NS_OK) error (rc); + baseWindow.Release (); + + Release (); + webBrowser.Release (); + webBrowser = null; + webBrowserObject = null; + + if (tip !is null && !tip.isDisposed ()) tip.dispose (); + tip = null; + location = size = null; + + Enumeration elements = unhookedDOMWindows.elements (); + while (elements.hasMoreElements ()) { + LONG ptrObject = (LONG)elements.nextElement (); + new nsISupports (ptrObject.value).Release (); + } + unhookedDOMWindows = null; + + mozDelegate.onDispose (embedHandle); + mozDelegate = null; + + embedHandle = 0; + BrowserCount--; +} + +void Activate () { + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIWebBrowserFocus.NS_IWEBBROWSERFOCUS_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIWebBrowserFocus webBrowserFocus = new nsIWebBrowserFocus (result[0]); + rc = webBrowserFocus.Activate (); + if (rc !is XPCOM.NS_OK) error (rc); + webBrowserFocus.Release (); +} + +void Deactivate () { + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIWebBrowserFocus.NS_IWEBBROWSERFOCUS_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIWebBrowserFocus webBrowserFocus = new nsIWebBrowserFocus (result[0]); + rc = webBrowserFocus.Deactivate (); + if (rc !is XPCOM.NS_OK) error (rc); + webBrowserFocus.Release (); +} + +void onResize () { + Rectangle rect = browser.getClientArea (); + int width = Math.max (1, rect.width); + int height = Math.max (1, rect.height); + + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + mozDelegate.setSize (embedHandle, width, height); + nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]); + rc = baseWindow.SetPositionAndSize (0, 0, width, height, 1); + if (rc !is XPCOM.NS_OK) error (rc); + baseWindow.Release (); +} + +public void refresh () { + if (awaitingNavigate) return; + + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + if (rc !is XPCOM.NS_OK) error(rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + rc = webNavigation.Reload (nsIWebNavigation.LOAD_FLAGS_NONE); + webNavigation.Release (); + if (rc is XPCOM.NS_OK) return; + /* + * Feature in Mozilla. Reload returns an error code NS_ERROR_INVALID_POINTER + * when it is called immediately after a request to load a new document using + * LoadURI. The workaround is to ignore this error code. + * + * Feature in Mozilla. Attempting to reload a file that no longer exists + * returns an error code of NS_ERROR_FILE_NOT_FOUND. This is equivalent to + * attempting to load a non-existent local url, which is not a Browser error, + * so this error code should be ignored. + */ + if (rc !is XPCOM.NS_ERROR_INVALID_POINTER && rc !is XPCOM.NS_ERROR_FILE_NOT_FOUND) error (rc); +} + +public bool setText (String html) { + /* + * Feature in Mozilla. The focus memory of Mozilla must be + * properly managed through the nsIWebBrowserFocus interface. + * In particular, nsIWebBrowserFocus.deactivate must be called + * when the focus moves from the browser (or one of its children + * managed by Mozilla to another widget. We currently do not + * get notified when a widget takes focus away from the Browser. + * As a result, deactivate is not properly called. This causes + * Mozilla to retake focus the next time a document is loaded. + * This breaks the case where the HTML loaded in the Browser + * varies while the user enters characters in a text widget. The text + * widget loses focus every time new content is loaded. + * The current workaround is to call deactivate everytime if + * the browser currently does not have focus. A better workaround + * would be to have a way to call deactivate when the Browser + * or one of its children loses focus. + */ + if (browser !is browser.getDisplay ().getFocusControl ()) Deactivate (); + + /* convert the String containing HTML to an array of bytes with UTF-8 data */ + byte[] data = null; + try { + data = html.getBytes ("UTF-8"); //$NON-NLS-1$ + } catch (UnsupportedEncodingException e) { + return false; + } + + awaitingNavigate = false; + + byte[] contentTypeBuffer = MozillaDelegate.wcsToMbcs (null, "text/html", true); // $NON-NLS-1$ + int /*long*/ aContentType = XPCOM.nsEmbedCString_new (contentTypeBuffer, contentTypeBuffer.length); + byte[] contentCharsetBuffer = MozillaDelegate.wcsToMbcs (null, "UTF-8", true); //$NON-NLS-1$ + int /*long*/ aContentCharset = XPCOM.nsEmbedCString_new (contentCharsetBuffer, contentCharsetBuffer.length); + + int /*long*/[] result = new int /*long*/[1]; + int rc = XPCOM.NS_GetServiceManager (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + nsIServiceManager serviceManager = new nsIServiceManager (result[0]); + result[0] = 0; + rc = serviceManager.GetService (XPCOM.NS_IOSERVICE_CID, nsIIOService.NS_IIOSERVICE_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + serviceManager.Release (); + + nsIIOService ioService = new nsIIOService (result[0]); + result[0] = 0; + /* + * Note. Mozilla ignores LINK tags used to load CSS stylesheets + * when the URI protocol for the nsInputStreamChannel + * is about:blank. The fix is to specify the file protocol. + */ + byte[] aString = MozillaDelegate.wcsToMbcs (null, URI_FROMMEMORY, false); + int /*long*/ aSpec = XPCOM.nsEmbedCString_new (aString, aString.length); + rc = ioService.NewURI (aSpec, null, 0, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + XPCOM.nsEmbedCString_delete (aSpec); + ioService.Release (); + + nsIURI uri = new nsIURI (result[0]); + result[0] = 0; + + rc = webBrowser.QueryInterface (nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + nsIInterfaceRequestor interfaceRequestor = new nsIInterfaceRequestor (result[0]); + result[0] = 0; + + /* + * Feature in Mozilla. LoadStream invokes the nsIInputStream argument + * through a different thread. The callback mechanism must attach + * a non java thread to the JVM otherwise the nsIInputStream Read and + * Close methods never get called. + */ + InputStream inputStream = new InputStream (data); + inputStream.AddRef (); + + rc = interfaceRequestor.GetInterface (nsIDocShell_1_9.NS_IDOCSHELL_IID, result); + if (rc is XPCOM.NS_OK) { + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + nsIDocShell_1_9 docShell = new nsIDocShell_1_9 (result[0]); + rc = docShell.LoadStream (inputStream.getAddress (), uri.getAddress (), aContentType, aContentCharset, 0); + docShell.Release (); + } else { + result[0] = 0; + rc = interfaceRequestor.GetInterface (nsIDocShell_1_8.NS_IDOCSHELL_IID, result); + if (rc is XPCOM.NS_OK) { + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + nsIDocShell_1_8 docShell = new nsIDocShell_1_8 (result[0]); + rc = docShell.LoadStream (inputStream.getAddress (), uri.getAddress (), aContentType, aContentCharset, 0); + docShell.Release (); + } else { + result[0] = 0; + rc = interfaceRequestor.GetInterface (nsIDocShell.NS_IDOCSHELL_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + nsIDocShell docShell = new nsIDocShell (result[0]); + rc = docShell.LoadStream (inputStream.getAddress (), uri.getAddress (), aContentType, aContentCharset, 0); + docShell.Release (); + } + } + if (rc !is XPCOM.NS_OK) error (rc); + result[0] = 0; + + inputStream.Release (); + interfaceRequestor.Release (); + uri.Release (); + XPCOM.nsEmbedCString_delete (aContentCharset); + XPCOM.nsEmbedCString_delete (aContentType); + return true; +} + +public bool setUrl (String url) { + awaitingNavigate = false; + + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIWebNavigation webNavigation = new nsIWebNavigation (result[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); + webNavigation.Release (); + return rc is XPCOM.NS_OK; +} + +public void stop () { + if (awaitingNavigate) return; + + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + rc = webNavigation.Stop (nsIWebNavigation.STOP_ALL); + if (rc !is XPCOM.NS_OK) error (rc); + webNavigation.Release (); +} + +void hookDOMListeners (nsIDOMEventTarget target, bool isTop) { + nsEmbedString string = new nsEmbedString (XPCOM.DOMEVENT_FOCUS); + target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_UNLOAD); + target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEDOWN); + target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEUP); + target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEMOVE); + target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEWHEEL); + target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEDRAG); + target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + + /* + * Only hook mouseover and mouseout if the target is a top-level frame, so that mouse moves + * between frames will not generate events. + */ + if (isTop && mozDelegate.hookEnterExit ()) { + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEOVER); + target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEOUT); + target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + } + + string = new nsEmbedString (XPCOM.DOMEVENT_KEYDOWN); + target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_KEYPRESS); + target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_KEYUP); + target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); +} + +void unhookDOMListeners () { + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.GetContentDOMWindow (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIDOMWindow window = new nsIDOMWindow (result[0]); + result[0] = 0; + rc = window.QueryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIDOMEventTarget target = new nsIDOMEventTarget (result[0]); + result[0] = 0; + unhookDOMListeners (target); + target.Release (); + + /* Listeners must be unhooked in pages contained in frames */ + rc = window.GetFrames (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + nsIDOMWindowCollection frames = new nsIDOMWindowCollection (result[0]); + result[0] = 0; + int[] frameCount = new int[1]; + rc = frames.GetLength (frameCount); /* PRUint32 */ + if (rc !is XPCOM.NS_OK) error (rc); + int count = frameCount[0]; + + if (count > 0) { + for (int i = 0; i < count; i++) { + rc = frames.Item (i, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIDOMWindow frame = new nsIDOMWindow (result[0]); + result[0] = 0; + rc = frame.QueryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + target = new nsIDOMEventTarget (result[0]); + result[0] = 0; + unhookDOMListeners (target); + target.Release (); + frame.Release (); + } + } + frames.Release (); + window.Release (); +} + +void unhookDOMListeners (nsIDOMEventTarget target) { + nsEmbedString string = new nsEmbedString (XPCOM.DOMEVENT_FOCUS); + target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_UNLOAD); + target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEDOWN); + target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEUP); + target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEMOVE); + target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEWHEEL); + target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEDRAG); + target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEOVER); + target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEOUT); + target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_KEYDOWN); + target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_KEYPRESS); + target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); + string = new nsEmbedString (XPCOM.DOMEVENT_KEYUP); + target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0); + string.dispose (); +} + +/* nsISupports */ + +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIWeakReference.NS_IWEAKREFERENCE_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {weakReference.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {webProgressListener.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIWebBrowserChrome.NS_IWEBBROWSERCHROME_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {webBrowserChrome.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIWebBrowserChromeFocus.NS_IWEBBROWSERCHROMEFOCUS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {webBrowserChromeFocus.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIEmbeddingSiteWindow.NS_IEMBEDDINGSITEWINDOW_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {embeddingSiteWindow.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {interfaceRequestor.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsISupportsWeakReference.NS_ISUPPORTSWEAKREFERENCE_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supportsWeakReference.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIContextMenuListener.NS_ICONTEXTMENULISTENER_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {contextMenuListener.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIURIContentListener.NS_IURICONTENTLISTENER_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {uriContentListener.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsITooltipListener.NS_ITOOLTIPLISTENER_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {tooltipListener.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int AddRef () { + refCount++; + return refCount; +} + +int Release () { + refCount--; + if (refCount is 0) disposeCOMInterfaces (); + return refCount; +} + +/* nsIWeakReference */ + +int QueryReferent (int /*long*/ riid, int /*long*/ ppvObject) { + return QueryInterface (riid, ppvObject); +} + +/* nsIInterfaceRequestor */ + +int GetInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + if (guid.Equals (nsIDOMWindow.NS_IDOMWINDOW_IID)) { + int /*long*/[] aContentDOMWindow = new int /*long*/[1]; + int rc = webBrowser.GetContentDOMWindow (aContentDOMWindow); + if (rc !is XPCOM.NS_OK) error (rc); + if (aContentDOMWindow[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + XPCOM.memmove (ppvObject, aContentDOMWindow, C.PTR_SIZEOF); + return rc; + } + return QueryInterface (riid, ppvObject); +} + +int GetWeakReference (int /*long*/ ppvObject) { + XPCOM.memmove (ppvObject, new int /*long*/[] {weakReference.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; +} + +/* nsIWebProgressListener */ + +int OnStateChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateFlags, int aStatus) { + if ((aStateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT) is 0) return XPCOM.NS_OK; + if ((aStateFlags & nsIWebProgressListener.STATE_START) !is 0) { + if (request is 0) request = aRequest; + + if (!awaitingNavigate) { + /* + * Add the page's nsIDOMWindow to the collection of windows that will + * have DOM listeners added to them later on in the page loading + * process. These listeners cannot be added yet because the + * nsIDOMWindow is not ready to take them at this stage. + */ + int /*long*/[] result = new int /*long*/[1]; + nsIWebProgress progress = new nsIWebProgress (aWebProgress); + int rc = progress.GetDOMWindow (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + unhookedDOMWindows.addElement (new LONG (result[0])); + } + } else if ((aStateFlags & nsIWebProgressListener.STATE_REDIRECTING) !is 0) { + if (request is aRequest) request = 0; + } else if ((aStateFlags & nsIWebProgressListener.STATE_STOP) !is 0) { + /* + * If this page's nsIDOMWindow handle is still in unhookedDOMWindows then + * add its DOM listeners now. It's possible for this to happen since + * there is no guarantee that a STATE_TRANSFERRING state change will be + * received for every window in a page, which is when these listeners + * are typically added. + */ + int /*long*/[] result = new int /*long*/[1]; + nsIWebProgress progress = new nsIWebProgress (aWebProgress); + int rc = progress.GetDOMWindow (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + nsIDOMWindow domWindow = new nsIDOMWindow (result[0]); + + LONG ptrObject = new LONG (result[0]); + result[0] = 0; + int index = unhookedDOMWindows.indexOf (ptrObject); + if (index !is -1) { + rc = webBrowser.GetContentDOMWindow (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + bool isTop = result[0] is domWindow.getAddress (); + new nsISupports (result[0]).Release (); + result[0] = 0; + + rc = domWindow.QueryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIDOMEventTarget target = new nsIDOMEventTarget (result[0]); + result[0] = 0; + hookDOMListeners (target, isTop); + target.Release (); + + /* + * Remove and unreference the nsIDOMWindow from the collection of windows + * that are waiting to have DOM listeners hooked on them. + */ + unhookedDOMWindows.remove (ptrObject); + new nsISupports (ptrObject.value).Release (); + } + domWindow.Release (); + + /* + * Feature in Mozilla. When a request is redirected (STATE_REDIRECTING), + * it never reaches the state STATE_STOP and it is replaced with a new request. + * The new request is received when it is in the state STATE_STOP. + * To handle this case, the variable request is set to 0 when the corresponding + * request is redirected. The following request received with the state STATE_STOP + * - the new request resulting from the redirection - is used to send + * the ProgressListener.completed event. + */ + if (request is aRequest || request is 0) { + request = 0; + if (!awaitingNavigate) { + StatusTextEvent event = new StatusTextEvent (browser); + event.display = browser.getDisplay (); + event.widget = browser; + event.text = ""; //$NON-NLS-1$ + for (int i = 0; i < statusTextListeners.length; i++) { + statusTextListeners[i].changed (event); + } + ProgressEvent event2 = new ProgressEvent (browser); + event2.display = browser.getDisplay (); + event2.widget = browser; + for (int i = 0; i < progressListeners.length; i++) { + progressListeners[i].completed (event2); + } + } + } + } else if ((aStateFlags & nsIWebProgressListener.STATE_TRANSFERRING) !is 0) { + /* + * Hook DOM listeners to the page's nsIDOMWindow here because this is + * the earliest opportunity to do so. + */ + int /*long*/[] result = new int /*long*/[1]; + nsIWebProgress progress = new nsIWebProgress (aWebProgress); + int rc = progress.GetDOMWindow (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + nsIDOMWindow domWindow = new nsIDOMWindow (result[0]); + + LONG ptrObject = new LONG (result[0]); + result[0] = 0; + int index = unhookedDOMWindows.indexOf (ptrObject); + if (index !is -1) { + rc = webBrowser.GetContentDOMWindow (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + bool isTop = result[0] is domWindow.getAddress (); + new nsISupports (result[0]).Release (); + result[0] = 0; + + rc = domWindow.QueryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIDOMEventTarget target = new nsIDOMEventTarget (result[0]); + result[0] = 0; + hookDOMListeners (target, isTop); + target.Release (); + + /* + * Remove and unreference the nsIDOMWindow from the collection of windows + * that are waiting to have DOM listeners hooked on them. + */ + unhookedDOMWindows.remove (ptrObject); + new nsISupports (ptrObject.value).Release (); + } + domWindow.Release (); + } + return XPCOM.NS_OK; +} + +int OnProgressChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aCurSelfProgress, int aMaxSelfProgress, int aCurTotalProgress, int aMaxTotalProgress) { + if (awaitingNavigate || progressListeners.length is 0) return XPCOM.NS_OK; + ProgressEvent event = new ProgressEvent (browser); + event.display = browser.getDisplay (); + event.widget = browser; + event.current = aCurTotalProgress; + event.total = aMaxTotalProgress; + for (int i = 0; i < progressListeners.length; i++) { + progressListeners[i].changed (event); + } + return XPCOM.NS_OK; +} + +int OnLocationChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) { + /* + * Feature in Mozilla. When a page is loaded via setText before a previous + * setText page load has completed, the expected OnStateChange STATE_STOP for the + * original setText never arrives because it gets replaced by the OnStateChange + * STATE_STOP for the new request. This results in the request field never being + * cleared because the original request's OnStateChange STATE_STOP is still expected + * (but never arrives). To handle this case, the request field is updated to the new + * overriding request since its OnStateChange STATE_STOP will be received next. + */ + if (request !is 0 && request !is aRequest) request = aRequest; + + if (awaitingNavigate || locationListeners.length is 0) return XPCOM.NS_OK; + + nsIWebProgress webProgress = new nsIWebProgress (aWebProgress); + int /*long*/[] aDOMWindow = new int /*long*/[1]; + int rc = webProgress.GetDOMWindow (aDOMWindow); + if (rc !is XPCOM.NS_OK) error (rc); + if (aDOMWindow[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIDOMWindow domWindow = new nsIDOMWindow (aDOMWindow[0]); + int /*long*/[] aTop = new int /*long*/[1]; + rc = domWindow.GetTop (aTop); + if (rc !is XPCOM.NS_OK) error (rc); + if (aTop[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + domWindow.Release (); + + nsIDOMWindow topWindow = new nsIDOMWindow (aTop[0]); + topWindow.Release (); + + nsIURI location = new nsIURI (aLocation); + int /*long*/ aSpec = XPCOM.nsEmbedCString_new (); + location.GetSpec (aSpec); + int length = XPCOM.nsEmbedCString_Length (aSpec); + int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec); + byte[] dest = new byte[length]; + XPCOM.memmove (dest, buffer, length); + XPCOM.nsEmbedCString_delete (aSpec); + String url = new String (dest); + + /* + * As of Mozilla 1.8, the first time that a page is displayed, regardless of + * whether it's via Browser.setURL() or Browser.setText(), the GRE navigates + * to about:blank and fires the corresponding navigation events. Do not send + * this event on to the user since it is not expected. + */ + if (!IsPre_1_8 && aRequest is 0 && url.startsWith (ABOUT_BLANK)) return XPCOM.NS_OK; + + LocationEvent event = new LocationEvent (browser); + event.display = browser.getDisplay (); + event.widget = browser; + event.location = url; + /* + * If the URI indicates that the page is being rendered from memory + * (via setText()) then set it to about:blank to be consistent with IE. + */ + if (event.location.equals (URI_FROMMEMORY)) event.location = ABOUT_BLANK; + event.top = aTop[0] is aDOMWindow[0]; + for (int i = 0; i < locationListeners.length; i++) { + locationListeners[i].changed (event); + } + return XPCOM.NS_OK; +} + +int OnStatusChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStatus, int /*long*/ aMessage) { + if (awaitingNavigate || statusTextListeners.length is 0) return XPCOM.NS_OK; + StatusTextEvent event = new StatusTextEvent (browser); + event.display = browser.getDisplay (); + event.widget = browser; + int length = XPCOM.strlen_PRUnichar (aMessage); + char[] dest = new char[length]; + XPCOM.memmove (dest, aMessage, length * 2); + event.text = new String (dest); + for (int i = 0; i < statusTextListeners.length; i++) { + statusTextListeners[i].changed (event); + } + return XPCOM.NS_OK; +} + +int OnSecurityChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int state) { + return XPCOM.NS_OK; +} + +/* nsIWebBrowserChrome */ + +int SetStatus (int statusType, int /*long*/ status) { + if (awaitingNavigate || statusTextListeners.length is 0) return XPCOM.NS_OK; + StatusTextEvent event = new StatusTextEvent (browser); + event.display = browser.getDisplay (); + event.widget = browser; + int length = XPCOM.strlen_PRUnichar (status); + char[] dest = new char[length]; + XPCOM.memmove (dest, status, length * 2); + String string = new String (dest); + event.text = string; + for (int i = 0; i < statusTextListeners.length; i++) { + statusTextListeners[i].changed (event); + } + return XPCOM.NS_OK; +} + +int GetWebBrowser (int /*long*/ aWebBrowser) { + int /*long*/[] ret = new int /*long*/[1]; + if (webBrowser !is null) { + webBrowser.AddRef (); + ret[0] = webBrowser.getAddress (); + } + XPCOM.memmove (aWebBrowser, ret, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} + +int SetWebBrowser (int /*long*/ aWebBrowser) { + if (webBrowser !is null) webBrowser.Release (); + webBrowser = aWebBrowser !is 0 ? new nsIWebBrowser (aWebBrowser) : null; + return XPCOM.NS_OK; +} + +int GetChromeFlags (int /*long*/ aChromeFlags) { + int[] ret = new int[1]; + ret[0] = chromeFlags; + XPCOM.memmove (aChromeFlags, ret, 4); /* PRUint32 */ + return XPCOM.NS_OK; +} + +int SetChromeFlags (int aChromeFlags) { + chromeFlags = aChromeFlags; + return XPCOM.NS_OK; +} + +int DestroyBrowserWindow () { + WindowEvent newEvent = new WindowEvent (browser); + newEvent.display = browser.getDisplay (); + newEvent.widget = browser; + for (int i = 0; i < closeWindowListeners.length; i++) { + closeWindowListeners[i].close (newEvent); + } + /* + * Note on Mozilla. The DestroyBrowserWindow notification cannot be cancelled. + * The browser widget cannot be used after this notification has been received. + * The application is advised to close the window hosting the browser widget. + * The browser widget must be disposed in all cases. + */ + browser.dispose (); + return XPCOM.NS_OK; +} + +int SizeBrowserTo (int aCX, int aCY) { + size = new Point (aCX, aCY); + bool isChrome = (chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) !is 0; + if (isChrome) { + Shell shell = browser.getShell (); + shell.setSize (shell.computeSize (size.x, size.y)); + } + return XPCOM.NS_OK; +} + +int ShowAsModal () { + int /*long*/[] result = new int /*long*/[1]; + int rc = XPCOM.NS_GetServiceManager (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + nsIServiceManager serviceManager = new nsIServiceManager (result[0]); + result[0] = 0; + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_CONTEXTSTACK_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsIJSContextStack.NS_IJSCONTEXTSTACK_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + serviceManager.Release (); + + nsIJSContextStack stack = new nsIJSContextStack (result[0]); + result[0] = 0; + rc = stack.Push (0); + if (rc !is XPCOM.NS_OK) error (rc); + + Shell shell = browser.getShell (); + Display display = browser.getDisplay (); + while (!shell.isDisposed ()) { + if (!display.readAndDispatch ()) display.sleep (); + } + + rc = stack.Pop (result); + if (rc !is XPCOM.NS_OK) error (rc); + stack.Release (); + return XPCOM.NS_OK; +} + +int IsWindowModal (int /*long*/ retval) { + int result = (chromeFlags & nsIWebBrowserChrome.CHROME_MODAL) !is 0 ? 1 : 0; + XPCOM.memmove (retval, new int[] {result}, 4); /* PRBool */ + return XPCOM.NS_OK; +} + +int ExitModalEventLoop (int aStatus) { + return XPCOM.NS_OK; +} + +/* nsIEmbeddingSiteWindow */ + +int SetDimensions (int flags, int x, int y, int cx, int cy) { + if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_POSITION) !is 0) { + location = new Point (x, y); + browser.getShell ().setLocation (x, y); + } + if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_SIZE_INNER) !is 0) { + browser.setSize (cx, cy); + } + if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_SIZE_OUTER) !is 0) { + browser.getShell ().setSize (cx, cy); + } + return XPCOM.NS_OK; +} + +int GetDimensions (int flags, int /*long*/ x, int /*long*/ y, int /*long*/ cx, int /*long*/ cy) { + if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_POSITION) !is 0) { + Point location = browser.getShell ().getLocation (); + if (x !is 0) C.memmove (x, new int[] {location.x}, 4); /* PRInt32 */ + if (y !is 0) C.memmove (y, new int[] {location.y}, 4); /* PRInt32 */ + } + if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_SIZE_INNER) !is 0) { + Point size = browser.getSize (); + if (cx !is 0) C.memmove (cx, new int[] {size.x}, 4); /* PRInt32 */ + if (cy !is 0) C.memmove (cy, new int[] {size.y}, 4); /* PRInt32 */ + } + if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_SIZE_OUTER) !is 0) { + Point size = browser.getShell().getSize (); + if (cx !is 0) C.memmove (cx, new int[] {size.x}, 4); /* PRInt32 */ + if (cy !is 0) C.memmove (cy, new int[] {size.y}, 4); /* PRInt32 */ + } + return XPCOM.NS_OK; +} + +int SetFocus () { + int /*long*/[] result = new int /*long*/[1]; + int rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]); + rc = baseWindow.SetFocus (); + if (rc !is XPCOM.NS_OK) error (rc); + baseWindow.Release (); + + /* + * Note. Mozilla notifies here that one of the children took + * focus. This could or should be used to fire an DWT.FOCUS_IN + * event on Browser focus listeners. + */ + return XPCOM.NS_OK; +} + +int GetVisibility (int /*long*/ aVisibility) { + bool visible = browser.isVisible () && !browser.getShell ().getMinimized (); + XPCOM.memmove (aVisibility, new int[] {visible ? 1 : 0}, 4); /* PRBool */ + return XPCOM.NS_OK; +} + +int SetVisibility (int aVisibility) { + if (isChild) { + WindowEvent event = new WindowEvent (browser); + event.display = browser.getDisplay (); + event.widget = browser; + if (aVisibility !is 0) { + /* + * Bug in Mozilla. When the JavaScript window.open is executed, Mozilla + * fires multiple SetVisibility 1 notifications. The workaround is + * to ignore subsequent notifications. + */ + if (!visible) { + visible = true; + event.location = location; + event.size = size; + event.addressBar = (chromeFlags & nsIWebBrowserChrome.CHROME_LOCATIONBAR) !is 0; + event.menuBar = (chromeFlags & nsIWebBrowserChrome.CHROME_MENUBAR) !is 0; + event.statusBar = (chromeFlags & nsIWebBrowserChrome.CHROME_STATUSBAR) !is 0; + event.toolBar = (chromeFlags & nsIWebBrowserChrome.CHROME_TOOLBAR) !is 0; + for (int i = 0; i < visibilityWindowListeners.length; i++) { + visibilityWindowListeners[i].show (event); + } + location = null; + size = null; + } + } else { + visible = false; + for (int i = 0; i < visibilityWindowListeners.length; i++) { + visibilityWindowListeners[i].hide (event); + } + } + } else { + visible = aVisibility !is 0; + } + return XPCOM.NS_OK; +} + +int GetTitle (int /*long*/ aTitle) { + return XPCOM.NS_OK; +} + +int SetTitle (int /*long*/ aTitle) { + if (awaitingNavigate || titleListeners.length is 0) return XPCOM.NS_OK; + TitleEvent event = new TitleEvent (browser); + event.display = browser.getDisplay (); + event.widget = browser; + /* + * To be consistent with other platforms the title event should + * contain the page's url if the page does not contain a + * tag. + */ + int length = XPCOM.strlen_PRUnichar (aTitle); + if (length > 0) { + char[] dest = new char[length]; + XPCOM.memmove (dest, aTitle, length * 2); + event.title = new String (dest); + } else { + event.title = getUrl (); + } + for (int i = 0; i < titleListeners.length; i++) { + titleListeners[i].changed (event); + } + return XPCOM.NS_OK; +} + +int GetSiteWindow (int /*long*/ aSiteWindow) { + /* + * Note. The handle is expected to be an HWND on Windows and + * a GtkWidget* on GTK. This callback is invoked on Windows + * when the javascript window.print is invoked and the print + * dialog comes up. If no handle is returned, the print dialog + * does not come up on this platform. + */ + XPCOM.memmove (aSiteWindow, new int /*long*/[] {embedHandle}, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} + +/* nsIWebBrowserChromeFocus */ + +int FocusNextElement () { + /* + * Bug in Mozilla embedding API. Mozilla takes back the focus after sending + * this event. This prevents tabbing out of Mozilla. This behaviour can be reproduced + * with the Mozilla application TestGtkEmbed. The workaround is to + * send the traversal notification after this callback returns. + */ + browser.getDisplay ().asyncExec (new Runnable () { + public void run () { + if (browser.isDisposed ()) return; + browser.traverse (DWT.TRAVERSE_TAB_NEXT); + } + }); + return XPCOM.NS_OK; +} + +int FocusPrevElement () { + /* + * Bug in Mozilla embedding API. Mozilla takes back the focus after sending + * this event. This prevents tabbing out of Mozilla. This behaviour can be reproduced + * with the Mozilla application TestGtkEmbed. The workaround is to + * send the traversal notification after this callback returns. + */ + browser.getDisplay ().asyncExec (new Runnable () { + public void run () { + if (browser.isDisposed ()) return; + browser.traverse (DWT.TRAVERSE_TAB_PREVIOUS); + } + }); + return XPCOM.NS_OK; +} + +/* nsIContextMenuListener */ + +int OnShowContextMenu (int aContextFlags, int /*long*/ aEvent, int /*long*/ aNode) { + if (awaitingNavigate) return XPCOM.NS_OK; + + nsIDOMEvent domEvent = new nsIDOMEvent (aEvent); + int /*long*/[] result = new int /*long*/[1]; + int rc = domEvent.QueryInterface (nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + nsIDOMMouseEvent domMouseEvent = new nsIDOMMouseEvent (result[0]); + int[] aScreenX = new int[1], aScreenY = new int[1]; + rc = domMouseEvent.GetScreenX (aScreenX); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domMouseEvent.GetScreenY (aScreenY); + if (rc !is XPCOM.NS_OK) error (rc); + domMouseEvent.Release (); + + Event event = new Event (); + event.x = aScreenX[0]; + event.y = aScreenY[0]; + browser.notifyListeners (DWT.MenuDetect, event); + if (!event.doit) return XPCOM.NS_OK; + Menu menu = browser.getMenu (); + if (menu !is null && !menu.isDisposed ()) { + if (aScreenX[0] !is event.x || aScreenY[0] !is event.y) { + menu.setLocation (event.x, event.y); + } + menu.setVisible (true); + } + return XPCOM.NS_OK; +} + +/* nsIURIContentListener */ + +int OnStartURIOpen (int /*long*/ aURI, int /*long*/ retval) { + if (awaitingNavigate || locationListeners.length is 0) { + XPCOM.memmove (retval, new int[] {0}, 4); /* PRBool */ + return XPCOM.NS_OK; + } + nsIURI location = new nsIURI (aURI); + int /*long*/ aSpec = XPCOM.nsEmbedCString_new (); + location.GetSpec (aSpec); + int length = XPCOM.nsEmbedCString_Length (aSpec); + int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec); + buffer = XPCOM.nsEmbedCString_get (aSpec); + byte[] dest = new byte[length]; + XPCOM.memmove (dest, buffer, length); + XPCOM.nsEmbedCString_delete (aSpec); + String value = new String (dest); + bool doit = true; + if (request is 0) { + /* + * listeners should not be notified of internal transitions like "javascipt:..." + * because this is an implementation side-effect, not a true navigate + */ + if (!value.startsWith (PREFIX_JAVASCRIPT)) { + LocationEvent event = new LocationEvent (browser); + event.display = browser.getDisplay(); + event.widget = browser; + event.location = value; + /* + * If the URI indicates that the page is being rendered from memory + * (via setText()) then set it to about:blank to be consistent with IE. + */ + if (event.location.equals (URI_FROMMEMORY)) event.location = ABOUT_BLANK; + event.doit = doit; + for (int i = 0; i < locationListeners.length; i++) { + locationListeners[i].changing (event); + } + doit = event.doit && !browser.isDisposed(); + } + } + XPCOM.memmove (retval, new int[] {doit ? 0 : 1}, 4); /* PRBool */ + return XPCOM.NS_OK; +} + +int DoContent (int /*long*/ aContentType, int aIsContentPreferred, int /*long*/ aRequest, int /*long*/ aContentHandler, int /*long*/ retval) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int IsPreferred (int /*long*/ aContentType, int /*long*/ aDesiredContentType, int /*long*/ retval) { + bool preferred = false; + int size = XPCOM.strlen (aContentType); + if (size > 0) { + byte[] typeBytes = new byte[size + 1]; + XPCOM.memmove (typeBytes, aContentType, size); + String contentType = new String (typeBytes, 0, size); + + /* do not attempt to handle known problematic content types */ + if (!contentType.equals (XPCOM.CONTENT_MAYBETEXT) && !contentType.equals (XPCOM.CONTENT_MULTIPART)) { + /* determine whether browser can handle the content type */ + int /*long*/[] result = new int /*long*/[1]; + int rc = XPCOM.NS_GetServiceManager (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + nsIServiceManager serviceManager = new nsIServiceManager (result[0]); + result[0] = 0; + + /* First try to use the nsIWebNavigationInfo if it's available (>= mozilla 1.8) */ + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WEBNAVIGATIONINFO_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsIWebNavigationInfo.NS_IWEBNAVIGATIONINFO_IID, result); + if (rc is 0) { + byte[] bytes = MozillaDelegate.wcsToMbcs (null, contentType, true); + int /*long*/ typePtr = XPCOM.nsEmbedCString_new (bytes, bytes.length); + nsIWebNavigationInfo info = new nsIWebNavigationInfo (result[0]); + result[0] = 0; + int[] isSupportedResult = new int[1]; /* PRUint32 */ + rc = info.IsTypeSupported (typePtr, 0, isSupportedResult); + if (rc !is XPCOM.NS_OK) error (rc); + info.Release (); + XPCOM.nsEmbedCString_delete (typePtr); + preferred = isSupportedResult[0] !is 0; + } else { + /* nsIWebNavigationInfo is not available, so do the type lookup */ + result[0] = 0; + rc = serviceManager.GetService (XPCOM.NS_CATEGORYMANAGER_CID, nsICategoryManager.NS_ICATEGORYMANAGER_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + nsICategoryManager categoryManager = new nsICategoryManager (result[0]); + result[0] = 0; + byte[] categoryBytes = MozillaDelegate.wcsToMbcs (null, "Gecko-Content-Viewers", true); //$NON-NLS-1$ + rc = categoryManager.GetCategoryEntry (categoryBytes, typeBytes, result); + categoryManager.Release (); + /* if no viewer for the content type is registered then rc is XPCOM.NS_ERROR_NOT_AVAILABLE */ + preferred = rc is XPCOM.NS_OK; + } + serviceManager.Release (); + } + } + + XPCOM.memmove(retval, new int[] {preferred ? 1 : 0}, 4); /* PRBool */ + if (preferred) { + XPCOM.memmove (aDesiredContentType, new int /*long*/[] {0}, C.PTR_SIZEOF); + } + return XPCOM.NS_OK; +} + +int CanHandleContent (int /*long*/ aContentType, int aIsContentPreferred, int /*long*/ aDesiredContentType, int /*long*/ retval) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetLoadCookie (int /*long*/ aLoadCookie) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int SetLoadCookie (int /*long*/ aLoadCookie) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int GetParentContentListener (int /*long*/ aParentContentListener) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +int SetParentContentListener (int /*long*/ aParentContentListener) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + +/* nsITooltipListener */ + +int OnShowTooltip (int aXCoords, int aYCoords, int /*long*/ aTipText) { + if (awaitingNavigate) return XPCOM.NS_OK; + + int length = XPCOM.strlen_PRUnichar (aTipText); + char[] dest = new char[length]; + XPCOM.memmove (dest, aTipText, length * 2); + String text = new String (dest); + if (tip !is null && !tip.isDisposed ()) tip.dispose (); + Display display = browser.getDisplay (); + Shell parent = browser.getShell (); + tip = new Shell (parent, DWT.ON_TOP); + tip.setLayout (new FillLayout()); + Label label = new Label (tip, DWT.CENTER); + label.setForeground (display.getSystemColor (DWT.COLOR_INFO_FOREGROUND)); + label.setBackground (display.getSystemColor (DWT.COLOR_INFO_BACKGROUND)); + label.setText (text); + /* + * Bug in Mozilla embedded API. Tooltip coordinates are wrong for + * elements inside an inline frame (IFrame tag). The workaround is + * to position the tooltip based on the mouse cursor location. + */ + Point point = display.getCursorLocation (); + /* Assuming cursor is 21x21 because this is the size of + * the arrow cursor on Windows + */ + point.y += 21; + tip.setLocation (point); + tip.pack (); + tip.setVisible (true); + return XPCOM.NS_OK; +} + +int OnHideTooltip () { + if (tip !is null && !tip.isDisposed ()) tip.dispose (); + tip = null; + return XPCOM.NS_OK; +} + +/* nsIDOMEventListener */ + +int HandleEvent (int /*long*/ event) { + nsIDOMEvent domEvent = new nsIDOMEvent (event); + + int /*long*/ type = XPCOM.nsEmbedString_new (); + int rc = domEvent.GetType (type); + if (rc !is XPCOM.NS_OK) error (rc); + int length = XPCOM.nsEmbedString_Length (type); + int /*long*/ buffer = XPCOM.nsEmbedString_get (type); + char[] chars = new char[length]; + XPCOM.memmove (chars, buffer, length * 2); + String typeString = new String (chars); + XPCOM.nsEmbedString_delete (type); + + if (XPCOM.DOMEVENT_UNLOAD.equals (typeString)) { + int /*long*/[] result = new int /*long*/[1]; + rc = domEvent.GetCurrentTarget (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + + nsIDOMEventTarget target = new nsIDOMEventTarget (result[0]); + unhookDOMListeners (target); + target.Release (); + return XPCOM.NS_OK; + } + + if (XPCOM.DOMEVENT_FOCUS.equals (typeString)) { + mozDelegate.handleFocus (); + return XPCOM.NS_OK; + } + + if (XPCOM.DOMEVENT_KEYDOWN.equals (typeString)) { + int /*long*/[] result = new int /*long*/[1]; + rc = domEvent.QueryInterface (nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + nsIDOMKeyEvent domKeyEvent = new nsIDOMKeyEvent (result[0]); + result[0] = 0; + + int[] aKeyCode = new int[1]; /* PRUint32 */ + rc = domKeyEvent.GetKeyCode (aKeyCode); + if (rc !is XPCOM.NS_OK) error (rc); + int keyCode = translateKey (aKeyCode[0]); + + /* + * if keyCode is lastKeyCode then either a repeating key like Shift + * is being held or a key for which key events are not sent has been + * pressed. In both of these cases a KeyDown should not be sent. + */ + if (keyCode !is lastKeyCode) { + lastKeyCode = keyCode; + switch (keyCode) { + case DWT.SHIFT: + case DWT.CONTROL: + case DWT.ALT: + case DWT.CAPS_LOCK: + case DWT.NUM_LOCK: + case DWT.SCROLL_LOCK: + case DWT.COMMAND: { + /* keypress events will not be received for these keys, so send KeyDowns for them now */ + int[] aAltKey = new int[1], aCtrlKey = new int[1], aShiftKey = new int[1], aMetaKey = new int[1]; /* PRBool */ + rc = domKeyEvent.GetAltKey (aAltKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domKeyEvent.GetCtrlKey (aCtrlKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domKeyEvent.GetShiftKey (aShiftKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domKeyEvent.GetMetaKey (aMetaKey); + if (rc !is XPCOM.NS_OK) error (rc); + + Event keyEvent = new Event (); + keyEvent.widget = browser; + keyEvent.type = DWT.KeyDown; + keyEvent.keyCode = keyCode; + keyEvent.stateMask = (aAltKey[0] !is 0 ? DWT.ALT : 0) | (aCtrlKey[0] !is 0 ? DWT.CTRL : 0) | (aShiftKey[0] !is 0 ? DWT.SHIFT : 0) | (aMetaKey[0] !is 0 ? DWT.COMMAND : 0); + keyEvent.stateMask &= ~keyCode; /* remove current keydown if it's a state key */ + browser.notifyListeners (keyEvent.type, keyEvent); + if (!keyEvent.doit) { + domEvent.PreventDefault (); + } + break; + } + default: { + /* + * If the keydown has Meta (but not Meta+Ctrl) as a modifier then send a KeyDown event for it here + * because a corresponding keypress event will not be received for it from the DOM. If the keydown + * does not have Meta as a modifier, or has Meta+Ctrl as a modifier, then then do nothing here + * because its KeyDown event will be sent from the keypress listener. + */ + int[] aMetaKey = new int[1]; /* PRBool */ + rc = domKeyEvent.GetMetaKey (aMetaKey); + if (rc !is XPCOM.NS_OK) error (rc); + if (aMetaKey[0] !is 0) { + int[] aCtrlKey = new int[1]; /* PRBool */ + rc = domKeyEvent.GetCtrlKey (aCtrlKey); + if (rc !is XPCOM.NS_OK) error (rc); + if (aCtrlKey[0] is 0) { + int[] aAltKey = new int[1], aShiftKey = new int[1]; /* PRBool */ + rc = domKeyEvent.GetAltKey (aAltKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domKeyEvent.GetShiftKey (aShiftKey); + if (rc !is XPCOM.NS_OK) error (rc); + + Event keyEvent = new Event (); + keyEvent.widget = browser; + keyEvent.type = DWT.KeyDown; + keyEvent.keyCode = lastKeyCode; + keyEvent.stateMask = (aAltKey[0] !is 0 ? DWT.ALT : 0) | (aCtrlKey[0] !is 0? DWT.CTRL : 0) | (aShiftKey[0] !is 0? DWT.SHIFT : 0) | (aMetaKey[0] !is 0? DWT.COMMAND : 0); + browser.notifyListeners (keyEvent.type, keyEvent); + if (!keyEvent.doit) { + domEvent.PreventDefault (); + } + } + } + } + } + } + + domKeyEvent.Release (); + return XPCOM.NS_OK; + } + + if (XPCOM.DOMEVENT_KEYPRESS.equals (typeString)) { + /* + * if keydown could not determine a keycode for this key then it's a + * key for which key events are not sent (eg.- the Windows key) + */ + if (lastKeyCode is 0) return XPCOM.NS_OK; + + /* + * On linux only, unexpected keypress events are received for some + * modifier keys. The workaround is to ignore these events since + * KeyDown events are sent for these keys in the keydown listener. + */ + switch (lastKeyCode) { + case DWT.CAPS_LOCK: + case DWT.NUM_LOCK: + case DWT.SCROLL_LOCK: return XPCOM.NS_OK; + } + + int /*long*/[] result = new int /*long*/[1]; + rc = domEvent.QueryInterface (nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + nsIDOMKeyEvent domKeyEvent = new nsIDOMKeyEvent (result[0]); + result[0] = 0; + + int[] aAltKey = new int[1], aCtrlKey = new int[1], aShiftKey = new int[1], aMetaKey = new int[1]; /* PRBool */ + rc = domKeyEvent.GetAltKey (aAltKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domKeyEvent.GetCtrlKey (aCtrlKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domKeyEvent.GetShiftKey (aShiftKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domKeyEvent.GetMetaKey (aMetaKey); + if (rc !is XPCOM.NS_OK) error (rc); + domKeyEvent.Release (); + + int[] aCharCode = new int[1]; /* PRUint32 */ + rc = domKeyEvent.GetCharCode (aCharCode); + if (rc !is XPCOM.NS_OK) error (rc); + lastCharCode = aCharCode[0]; + if (lastCharCode is 0) { + switch (lastKeyCode) { + case DWT.TAB: lastCharCode = DWT.TAB; break; + case DWT.CR: lastCharCode = DWT.CR; break; + case DWT.BS: lastCharCode = DWT.BS; break; + case DWT.ESC: lastCharCode = DWT.ESC; break; + case DWT.DEL: lastCharCode = DWT.DEL; break; + } + } + if (aCtrlKey[0] !is 0 && (0 <= lastCharCode && lastCharCode <= 0x7F)) { + if ('a' <= lastCharCode && lastCharCode <= 'z') lastCharCode -= 'a' - 'A'; + if (64 <= lastCharCode && lastCharCode <= 95) lastCharCode -= 64; + } + + Event keyEvent = new Event (); + keyEvent.widget = browser; + keyEvent.type = DWT.KeyDown; + keyEvent.keyCode = lastKeyCode; + keyEvent.character = (char)lastCharCode; + keyEvent.stateMask = (aAltKey[0] !is 0 ? DWT.ALT : 0) | (aCtrlKey[0] !is 0 ? DWT.CTRL : 0) | (aShiftKey[0] !is 0 ? DWT.SHIFT : 0) | (aMetaKey[0] !is 0 ? DWT.COMMAND : 0); + browser.notifyListeners (keyEvent.type, keyEvent); + if (!keyEvent.doit) { + domEvent.PreventDefault (); + } + return XPCOM.NS_OK; + } + + if (XPCOM.DOMEVENT_KEYUP.equals (typeString)) { + int /*long*/[] result = new int /*long*/[1]; + rc = domEvent.QueryInterface (nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + nsIDOMKeyEvent domKeyEvent = new nsIDOMKeyEvent (result[0]); + result[0] = 0; + + int[] aKeyCode = new int[1]; /* PRUint32 */ + rc = domKeyEvent.GetKeyCode (aKeyCode); + if (rc !is XPCOM.NS_OK) error (rc); + int keyCode = translateKey (aKeyCode[0]); + if (keyCode is 0) { + /* indicates a key for which key events are not sent */ + domKeyEvent.Release (); + return XPCOM.NS_OK; + } + if (keyCode !is lastKeyCode) { + /* keyup does not correspond to the last keydown */ + lastKeyCode = keyCode; + lastCharCode = 0; + } + + int[] aAltKey = new int[1], aCtrlKey = new int[1], aShiftKey = new int[1], aMetaKey = new int[1]; /* PRBool */ + rc = domKeyEvent.GetAltKey (aAltKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domKeyEvent.GetCtrlKey (aCtrlKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domKeyEvent.GetShiftKey (aShiftKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domKeyEvent.GetMetaKey (aMetaKey); + if (rc !is XPCOM.NS_OK) error (rc); + domKeyEvent.Release (); + + Event keyEvent = new Event (); + keyEvent.widget = browser; + keyEvent.type = DWT.KeyUp; + keyEvent.keyCode = lastKeyCode; + keyEvent.character = (char)lastCharCode; + keyEvent.stateMask = (aAltKey[0] !is 0 ? DWT.ALT : 0) | (aCtrlKey[0] !is 0 ? DWT.CTRL : 0) | (aShiftKey[0] !is 0 ? DWT.SHIFT : 0) | (aMetaKey[0] !is 0 ? DWT.COMMAND : 0); + switch (lastKeyCode) { + case DWT.SHIFT: + case DWT.CONTROL: + case DWT.ALT: + case DWT.COMMAND: { + keyEvent.stateMask |= lastKeyCode; + } + } + browser.notifyListeners (keyEvent.type, keyEvent); + if (!keyEvent.doit) { + domEvent.PreventDefault (); + } + lastKeyCode = lastCharCode = 0; + return XPCOM.NS_OK; + } + + /* mouse event */ + + int /*long*/[] result = new int /*long*/[1]; + rc = domEvent.QueryInterface (nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID, result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + nsIDOMMouseEvent domMouseEvent = new nsIDOMMouseEvent (result[0]); + result[0] = 0; + + /* + * MouseOver and MouseOut events are fired any time the mouse enters or exits + * any element within the Browser. To ensure that DWT events are only + * fired for mouse movements into or out of the Browser, do not fire an + * event if the element being exited (on MouseOver) or entered (on MouseExit) + * is within the Browser. + */ + if (XPCOM.DOMEVENT_MOUSEOVER.equals (typeString) || XPCOM.DOMEVENT_MOUSEOUT.equals (typeString)) { + rc = domMouseEvent.GetRelatedTarget (result); + if (rc !is XPCOM.NS_OK) error (rc); + if (result[0] !is 0) { + domMouseEvent.Release (); + return XPCOM.NS_OK; + } + } + + int[] aClientX = new int[1], aClientY = new int[1], aDetail = new int[1]; /* PRInt32 */ + rc = domMouseEvent.GetClientX (aClientX); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domMouseEvent.GetClientY (aClientY); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domMouseEvent.GetDetail (aDetail); + if (rc !is XPCOM.NS_OK) error (rc); + short[] aButton = new short[1]; /* PRUint16 */ + rc = domMouseEvent.GetButton (aButton); + if (rc !is XPCOM.NS_OK) error (rc); + int[] aAltKey = new int[1], aCtrlKey = new int[1], aShiftKey = new int[1], aMetaKey = new int[1]; /* PRBool */ + rc = domMouseEvent.GetAltKey (aAltKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domMouseEvent.GetCtrlKey (aCtrlKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domMouseEvent.GetShiftKey (aShiftKey); + if (rc !is XPCOM.NS_OK) error (rc); + rc = domMouseEvent.GetMetaKey (aMetaKey); + if (rc !is XPCOM.NS_OK) error (rc); + domMouseEvent.Release (); + + Event mouseEvent = new Event (); + mouseEvent.widget = browser; + mouseEvent.x = aClientX[0]; mouseEvent.y = aClientY[0]; + mouseEvent.stateMask = (aAltKey[0] !is 0 ? DWT.ALT : 0) | (aCtrlKey[0] !is 0 ? DWT.CTRL : 0) | (aShiftKey[0] !is 0 ? DWT.SHIFT : 0) | (aMetaKey[0] !is 0 ? DWT.COMMAND : 0); + + if (XPCOM.DOMEVENT_MOUSEDOWN.equals (typeString)) { + mozDelegate.handleMouseDown (); + mouseEvent.type = DWT.MouseDown; + mouseEvent.button = aButton[0] + 1; + mouseEvent.count = aDetail[0]; + } else if (XPCOM.DOMEVENT_MOUSEUP.equals (typeString)) { + /* + * Bug on OSX. For some reason multiple mouseup events come from the DOM + * when button 3 is released on OSX. The first of these events has a count + * detail and the others do not. The workaround is to not fire received + * button 3 mouseup events that do not have a count since mouse events + * without a click count are not valid. + */ + int button = aButton[0] + 1; + int count = aDetail[0]; + if (count is 0 && button is 3) return XPCOM.NS_OK; + mouseEvent.type = DWT.MouseUp; + mouseEvent.button = button; + mouseEvent.count = count; + } else if (XPCOM.DOMEVENT_MOUSEMOVE.equals (typeString)) { + mouseEvent.type = DWT.MouseMove; + } else if (XPCOM.DOMEVENT_MOUSEWHEEL.equals (typeString)) { + mouseEvent.type = DWT.MouseWheel; + mouseEvent.count = -aDetail[0]; + } else if (XPCOM.DOMEVENT_MOUSEOVER.equals (typeString)) { + mouseEvent.type = DWT.MouseEnter; + } else if (XPCOM.DOMEVENT_MOUSEOUT.equals (typeString)) { + mouseEvent.type = DWT.MouseExit; + } else if (XPCOM.DOMEVENT_MOUSEDRAG.equals (typeString)) { + mouseEvent.type = DWT.DragDetect; + mouseEvent.button = aButton[0] + 1; + switch (mouseEvent.button) { + case 1: mouseEvent.stateMask |= DWT.BUTTON1; break; + case 2: mouseEvent.stateMask |= DWT.BUTTON2; break; + case 3: mouseEvent.stateMask |= DWT.BUTTON3; break; + case 4: mouseEvent.stateMask |= DWT.BUTTON4; break; + case 5: mouseEvent.stateMask |= DWT.BUTTON5; break; + } + } + + browser.notifyListeners (mouseEvent.type, mouseEvent); + if (aDetail[0] is 2 && XPCOM.DOMEVENT_MOUSEDOWN.equals (typeString)) { + mouseEvent = new Event (); + mouseEvent.widget = browser; + mouseEvent.x = aClientX[0]; mouseEvent.y = aClientY[0]; + mouseEvent.stateMask = (aAltKey[0] !is 0 ? DWT.ALT : 0) | (aCtrlKey[0] !is 0 ? DWT.CTRL : 0) | (aShiftKey[0] !is 0 ? DWT.SHIFT : 0) | (aMetaKey[0] !is 0 ? DWT.COMMAND : 0); + mouseEvent.type = DWT.MouseDoubleClick; + mouseEvent.button = aButton[0] + 1; + mouseEvent.count = aDetail[0]; + browser.notifyListeners (mouseEvent.type, mouseEvent); + } + return XPCOM.NS_OK; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/MozillaDelegate.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/MozillaDelegate.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,208 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.MozillaDelegate; + +import dwt.dwthelper.utils; + +import dwt.DWT; +import dwt.internal.Callback; +import dwt.internal.Converter; +import dwt.internal.gtk.GdkEvent; +import dwt.internal.gtk.OS; +import dwt.widgets.Display; +import dwt.widgets.Event; +import dwt.widgets.Listener; +import dwt.widgets.Widget; + +class MozillaDelegate { + Browser browser; + int /*long*/ mozillaHandle, embedHandle; + bool hasFocus; + Listener listener; + static Callback eventCallback; + static int /*long*/ eventProc; + static final int STOP_PROPOGATE = 1; + + static bool IsLinux; + static { + String osName = System.getProperty ("os.name").toLowerCase (); //$NON-NLS-1$ + IsLinux = osName.startsWith ("linux"); //$NON-NLS-1$ + } + +MozillaDelegate (Browser browser) { + super (); + if (!IsLinux) { + browser.dispose (); + DWT.error (DWT.ERROR_NO_HANDLES, null, " [Unsupported platform]"); //$NON-NLS-1$ + } + this.browser = browser; +} + +static int /*long*/ eventProc (int /*long*/ handle, int /*long*/ gdkEvent, int /*long*/ pointer) { + int /*long*/ parent = OS.gtk_widget_get_parent (handle); + parent = OS.gtk_widget_get_parent (parent); + if (parent is 0) return 0; + Widget widget = Display.getCurrent ().findWidget (parent); + if (widget !is null && widget instanceof Browser) { + return ((Mozilla)((Browser)widget).webBrowser).delegate.gtk_event (handle, gdkEvent, pointer); + } + return 0; +} + +static Browser findBrowser (int /*long*/ handle) { + /* + * Note. On GTK, Mozilla is embedded into a GtkHBox handle + * and not directly into the parent Composite handle. + */ + int /*long*/ parent = OS.gtk_widget_get_parent (handle); + Display display = Display.getCurrent (); + return (Browser)display.findWidget (parent); +} + +static char[] mbcsToWcs (String codePage, byte [] buffer) { + return Converter.mbcsToWcs (codePage, buffer); +} + +static byte[] wcsToMbcs (String codePage, String string, bool terminate) { + return Converter.wcsToMbcs (codePage, string, terminate); +} + +int /*long*/ getHandle () { + /* + * Bug in Mozilla Linux GTK. Embedding Mozilla into a GtkFixed + * handle causes problems with some Mozilla plug-ins. For some + * reason, the Flash plug-in causes the child of the GtkFixed + * handle to be resized to 1 when the Flash document is loaded. + * That could be due to gtk_container_resize_children being called + * by Mozilla - or one of its plug-ins - on the GtkFixed handle, + * causing the child of the GtkFixed handle to be resized to 1. + * The workaround is to embed Mozilla into a GtkHBox handle. + */ + embedHandle = OS.gtk_hbox_new (false, 0); + OS.gtk_container_add (browser.handle, embedHandle); + OS.gtk_widget_show (embedHandle); + return embedHandle; +} + +String getLibraryName () { + return "libxpcom.so"; //$NON-NLS-1$ +} + +String getSWTInitLibraryName () { + return "swt-xpcominit"; //$NON-NLS-1$ +} + +int /*long*/ gtk_event (int /*long*/ handle, int /*long*/ gdkEvent, int /*long*/ pointer) { + GdkEvent event = new GdkEvent (); + OS.memmove (event, gdkEvent, GdkEvent.sizeof); + if (event.type is OS.GDK_BUTTON_PRESS) { + if (!hasFocus) browser.setFocus (); + } + + /* + * Stop the propagation of events that are not consumed by Mozilla, before + * they reach the parent embedder. These event have already been received. + */ + if (pointer is STOP_PROPOGATE) return 1; + return 0; +} + +void handleFocus () { + if (hasFocus) return; + hasFocus = true; + listener = new Listener () { + public void handleEvent (Event event) { + if (event.widget is browser) return; + ((Mozilla)browser.webBrowser).Deactivate (); + hasFocus = false; + browser.getDisplay ().removeFilter (DWT.FocusIn, this); + browser.getShell ().removeListener (DWT.Deactivate, this); + listener = null; + } + }; + browser.getDisplay ().addFilter (DWT.FocusIn, listener); + browser.getShell ().addListener (DWT.Deactivate, listener); +} + +void handleMouseDown () { + int shellStyle = browser.getShell ().getStyle (); + if ((shellStyle & DWT.ON_TOP) !is 0 && (((shellStyle & DWT.NO_FOCUS) is 0) || ((browser.getStyle () & DWT.NO_FOCUS) is 0))) { + browser.getDisplay ().asyncExec (new Runnable () { + public void run () { + if (browser is null || browser.isDisposed ()) return; + ((Mozilla)browser.webBrowser).Activate (); + } + }); + } +} + +bool hookEnterExit () { + return false; +} + +void init () { + if (eventCallback is null) { + eventCallback = new Callback (getClass (), "eventProc", 3); //$NON-NLS-1$ + eventProc = eventCallback.getAddress (); + if (eventProc is 0) { + browser.dispose (); + Mozilla.error (DWT.ERROR_NO_MORE_CALLBACKS); + } + } + + /* + * Feature in Mozilla. GtkEvents such as key down, key pressed may be consumed + * by Mozilla and never be received by the parent embedder. The workaround + * is to find the top Mozilla gtk widget that receives all the Mozilla GtkEvents, + * i.e. the first child of the parent embedder. Then hook event callbacks and + * forward the event to the parent embedder before Mozilla received and consumed + * them. + */ + int /*long*/ list = OS.gtk_container_get_children (embedHandle); + if (list !is 0) { + mozillaHandle = OS.g_list_data (list); + OS.g_list_free (list); + + if (mozillaHandle !is 0) { + /* Note. Callback to get events before Mozilla receives and consumes them. */ + OS.g_signal_connect (mozillaHandle, OS.event, eventProc, 0); + + /* + * Note. Callback to get the events not consumed by Mozilla - and to block + * them so that they don't get propagated to the parent handle twice. + * This hook is set after Mozilla and is therefore called after Mozilla's + * handler because GTK dispatches events in their order of registration. + */ + OS.g_signal_connect (mozillaHandle, OS.key_press_event, eventProc, STOP_PROPOGATE); + OS.g_signal_connect (mozillaHandle, OS.key_release_event, eventProc, STOP_PROPOGATE); + OS.g_signal_connect (mozillaHandle, OS.button_press_event, eventProc, STOP_PROPOGATE); + } + } +} + +bool needsSpinup () { + return true; +} + +void onDispose (int /*long*/ embedHandle) { + if (listener !is null) { + browser.getDisplay ().removeFilter (DWT.FocusIn, listener); + browser.getShell ().removeListener (DWT.Deactivate, listener); + listener = null; + } + browser = null; +} + +void setSize (int /*long*/ embedHandle, int width, int height) { + OS.gtk_widget_set_size_request (embedHandle, width, height); +} + +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/OpenWindowListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/OpenWindowListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2003, 2005 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 + *******************************************************************************/ +module dwt.browser.OpenWindowListener; + +import dwt.dwthelper.utils; + +import dwt.internal.DWTEventListener; + +/** + * This listener interface may be implemented in order to receive + * a {@link WindowEvent} notification when a new {@link Browser} + * needs to be provided by the application. + * + * @see Browser#addOpenWindowListener(OpenWindowListener) + * @see Browser#removeOpenWindowListener(OpenWindowListener) + * @see CloseWindowListener + * @see VisibilityWindowListener + * + * @since 3.0 + */ +public interface OpenWindowListener extends DWTEventListener { + +/** + * This method is called when a new window needs to be created. + * <p> + * A particular <code>Browser</code> can be passed to the event.browser + * field to host the content of a new window. + * <p> + * A standalone system browser is used to host the new window + * if the event.required field value is false and if the event.browser + * field is left <code>null</code>. The event.required field + * is true on platforms that don't support a standalone system browser for + * new window requests. + * <p> + * The navigation is cancelled if the event.required field is set to + * true and the event.browser field is left <code>null</code>. + * <p> + * <p>The following fields in the <code>WindowEvent</code> apply: + * <ul> + * <li>(in/out) required true if the platform requires the user to provide a + * <code>Browser</code> to handle the new window or false otherwise. + * <li>(out) browser the new <code>Browser</code> that will host the + * content of the new window. + * <li>(in) widget the <code>Browser</code> that is requesting to open a + * new window + * </ul> + * + * @param event the <code>WindowEvent</code> that needs to be passed a new + * <code>Browser</code> to handle the new window request + * + * @since 3.0 + */ +public void open(WindowEvent event); +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/ProgressAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/ProgressAdapter.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 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 + *******************************************************************************/ +module dwt.browser.ProgressAdapter; + +import dwt.dwthelper.utils; + +/** + * This adapter class provides default implementations for the + * methods described by the {@link ProgressListener} interface. + * <p> + * Classes that wish to deal with {@link ProgressEvent}'s can + * extend this class and override only the methods which they are + * interested in. + * </p> + * + * @since 3.0 + */ +public abstract class ProgressAdapter implements ProgressListener { + +public void changed(ProgressEvent event) { +} + +public void completed(ProgressEvent event) { +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/ProgressEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/ProgressEvent.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 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 + * Port to the D programming language: + * John Reimer <terminal.node@gmail.com> + *******************************************************************************/ +module dwt.browser.ProgressEvent; + +import dwt.dwthelper.utils; + +import dwt.events.TypedEvent; +import dwt.widgets.Widget; + +/** + * A <code>ProgressEvent</code> is sent by a {@link Browser} to + * {@link ProgressListener}'s when a progress is made during the + * loading of the current URL or when the loading of the current + * URL has been completed. + * + * @since 3.0 + */ +public class ProgressEvent : TypedEvent { + /** current value */ + public int current; + /** total value */ + public int total; + + static final long serialVersionUID = 3977018427045393972L; + + this(Widget w) { + super(w); + } + + /** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ + + public override String toString () { + return Format( "ProgressEvent { current={} total={} }", + current, total ); + } +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/ProgressListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/ProgressListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 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 + *******************************************************************************/ +module dwt.browser.ProgressListener; + +import dwt.dwthelper.utils; + +import dwt.internal.DWTEventListener; + +/** + * This listener interface may be implemented in order to receive + * a {@link ProgressEvent} notification when a {@link Browser} + * makes a progress in loading the current URL or when the + * current URL has been loaded. + * + * @see Browser#addProgressListener(ProgressListener) + * @see Browser#removeProgressListener(ProgressListener) + * @see Browser#getUrl() + * + * @since 3.0 + */ +public interface ProgressListener extends DWTEventListener { + +/** + * This method is called when a progress is made during the loading of the + * current location. + * <p> + * + * <p>The following fields in the <code>ProgressEvent</code> apply: + * <ul> + * <li>(in) current the progress for the location currently being loaded + * <li>(in) total the maximum progress for the location currently being loaded + * <li>(in) widget the <code>Browser</code> whose current URL is being loaded + * </ul> + * + * @param event the <code>ProgressEvent</code> related to the loading of the + * current location of a <code>Browser</code> + * + * @since 3.0 + */ +public void changed(ProgressEvent event); + +/** + * This method is called when the current location has been completely loaded. + * <p> + * + * <p>The following fields in the <code>ProgressEvent</code> apply: + * <ul> + * <li>(in) widget the <code>Browser</code> whose current URL has been loaded + * </ul> + * + * @param event the <code>ProgressEvent</code> related to the <code>Browser</code> + * that has loaded its current URL. + * + * @since 3.0 + */ +public void completed(ProgressEvent event); +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/PromptDialog.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/PromptDialog.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,307 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.PromptDialog; + +import dwt.dwthelper.utils; + +import dwt.DWT; +import dwt.layout.GridData; +import dwt.layout.GridLayout; +import dwt.widgets.Button; +import dwt.widgets.Composite; +import dwt.widgets.Dialog; +import dwt.widgets.Display; +import dwt.widgets.Event; +import dwt.widgets.Label; +import dwt.widgets.Listener; +import dwt.widgets.Monitor; +import dwt.widgets.Shell; +import dwt.widgets.Text; +import dwt.widgets.Widget; + +class PromptDialog extends Dialog { + + PromptDialog(Shell parent, int style) { + super(parent, style); + } + + PromptDialog(Shell parent) { + this(parent, 0); + } + + void alertCheck(String title, String text, String check, ref int checkValue) { + Shell parent = getParent(); + final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); + if (title !is null) shell.setText(title); + GridLayout gridLayout = new GridLayout(); + shell.setLayout(gridLayout); + Label label = new Label(shell, DWT.WRAP); + label.setText(text); + GridData data = new GridData(); + Monitor monitor = parent.getMonitor(); + int maxWidth = monitor.getBounds().width * 2 / 3; + int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; + data.widthHint = Math.min(width, maxWidth); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + label.setLayoutData (data); + + final Button checkButton = check !is null ? new Button(shell, DWT.CHECK) : null; + if (checkButton !is null) { + checkButton.setText(check); + checkButton.setSelection(checkValue[0] !is 0); + data = new GridData (); + data.horizontalAlignment = GridData.BEGINNING; + checkButton.setLayoutData (data); + } + Button okButton = new Button(shell, DWT.PUSH); + okButton.setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$ + data = new GridData (); + data.horizontalAlignment = GridData.CENTER; + okButton.setLayoutData (data); + okButton.addListener(DWT.Selection, new Listener() { + public void handleEvent(Event event) { + if (checkButton !is null) checkValue[0] = checkButton.getSelection() ? 1 : 0; + shell.close(); + } + }); + + shell.pack(); + shell.open(); + Display display = parent.getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) display.sleep(); + } + } + + void confirmEx(String title, String text, String check, String button0, String button1, String button2, int defaultIndex, final int[] checkValue, final int[] result) { + Shell parent = getParent(); + final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); + shell.setText(title); + GridLayout gridLayout = new GridLayout(); + shell.setLayout(gridLayout); + Label label = new Label(shell, DWT.WRAP); + label.setText(text); + GridData data = new GridData(); + Monitor monitor = parent.getMonitor(); + int maxWidth = monitor.getBounds().width * 2 / 3; + int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; + data.widthHint = Math.min(width, maxWidth); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + label.setLayoutData (data); + + final Button[] buttons = new Button[4]; + Listener listener = new Listener() { + public void handleEvent(Event event) { + if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0; + Widget widget = event.widget; + for (int i = 1; i < buttons.length; i++) { + if (widget is buttons[i]) { + result[0] = i - 1; + break; + } + } + shell.close(); + } + }; + if (check !is null) { + buttons[0] = new Button(shell, DWT.CHECK); + buttons[0].setText(check); + buttons[0].setSelection(checkValue[0] !is 0); + data = new GridData (); + data.horizontalAlignment = GridData.BEGINNING; + buttons[0].setLayoutData (data); + } + Composite composite = new Composite(shell, DWT.NONE); + data = new GridData(); + data.horizontalAlignment = GridData.CENTER; + composite.setLayoutData (data); + GridLayout layout = new GridLayout(); + layout.makeColumnsEqualWidth = true; + composite.setLayout(layout); + int buttonCount = 0; + if (button0 !is null) { + buttons[1] = new Button(composite, DWT.PUSH); + buttons[1].setText(button0); + buttons[1].addListener(DWT.Selection, listener); + buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttonCount++; + } + if (button1 !is null) { + buttons[2] = new Button(composite, DWT.PUSH); + buttons[2].setText(button1); + buttons[2].addListener(DWT.Selection, listener); + buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttonCount++; + } + if (button2 !is null) { + buttons[3] = new Button(composite, DWT.PUSH); + buttons[3].setText(button2); + buttons[3].addListener(DWT.Selection, listener); + buttons[3].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttonCount++; + } + layout.numColumns = buttonCount; + Button defaultButton = buttons [defaultIndex + 1]; + if (defaultButton !is null) shell.setDefaultButton (defaultButton); + + shell.pack(); + shell.open(); + Display display = parent.getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) display.sleep(); + } + } + + void prompt(String title, String text, String check, final String[] value, final int[] checkValue, final int[] result) { + Shell parent = getParent(); + final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); + if (title !is null) shell.setText(title); + GridLayout gridLayout = new GridLayout(); + shell.setLayout(gridLayout); + Label label = new Label(shell, DWT.WRAP); + label.setText(text); + GridData data = new GridData(); + Monitor monitor = parent.getMonitor(); + int maxWidth = monitor.getBounds().width * 2 / 3; + int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; + data.widthHint = Math.min(width, maxWidth); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + label.setLayoutData (data); + + final Text valueText = new Text(shell, DWT.BORDER); + if (value[0] !is null) valueText.setText(value[0]); + data = new GridData(); + width = valueText.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; + if (width > maxWidth) data.widthHint = maxWidth; + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + valueText.setLayoutData(data); + + final Button[] buttons = new Button[3]; + Listener listener = new Listener() { + public void handleEvent(Event event) { + if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0; + value[0] = valueText.getText(); + result[0] = event.widget is buttons[1] ? 1 : 0; + shell.close(); + } + }; + if (check !is null) { + buttons[0] = new Button(shell, DWT.CHECK); + buttons[0].setText(check); + buttons[0].setSelection(checkValue[0] !is 0); + data = new GridData (); + data.horizontalAlignment = GridData.BEGINNING; + buttons[0].setLayoutData (data); + } + Composite composite = new Composite(shell, DWT.NONE); + data = new GridData(); + data.horizontalAlignment = GridData.CENTER; + composite.setLayoutData (data); + composite.setLayout(new GridLayout(2, true)); + buttons[1] = new Button(composite, DWT.PUSH); + buttons[1].setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$ + buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttons[1].addListener(DWT.Selection, listener); + buttons[2] = new Button(composite, DWT.PUSH); + buttons[2].setText(DWT.getMessage("SWT_Cancel")); //$NON-NLS-1$ + buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttons[2].addListener(DWT.Selection, listener); + + shell.pack(); + shell.open(); + Display display = parent.getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) display.sleep(); + } + } + + void promptUsernameAndPassword(String title, String text, String check, final String[] user, final String[] pass, final int[] checkValue, final int[] result) { + Shell parent = getParent(); + final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); + shell.setText(title); + GridLayout gridLayout = new GridLayout(); + shell.setLayout(gridLayout); + Label label = new Label(shell, DWT.WRAP); + label.setText(text); + GridData data = new GridData(); + Monitor monitor = parent.getMonitor(); + int maxWidth = monitor.getBounds().width * 2 / 3; + int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; + data.widthHint = Math.min(width, maxWidth); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + label.setLayoutData (data); + + Label userLabel = new Label(shell, DWT.NONE); + userLabel.setText(DWT.getMessage("SWT_Username")); //$NON-NLS-1$ + + final Text userText = new Text(shell, DWT.BORDER); + if (user[0] !is null) userText.setText(user[0]); + data = new GridData(); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + userText.setLayoutData(data); + + Label passwordLabel = new Label(shell, DWT.NONE); + passwordLabel.setText(DWT.getMessage("SWT_Password")); //$NON-NLS-1$ + + final Text passwordText = new Text(shell, DWT.PASSWORD | DWT.BORDER); + if (pass[0] !is null) passwordText.setText(pass[0]); + data = new GridData(); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + passwordText.setLayoutData(data); + + final Button[] buttons = new Button[3]; + Listener listener = new Listener() { + public void handleEvent(Event event) { + if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0; + user[0] = userText.getText(); + pass[0] = passwordText.getText(); + result[0] = event.widget is buttons[1] ? 1 : 0; + shell.close(); + } + }; + if (check !is null) { + buttons[0] = new Button(shell, DWT.CHECK); + buttons[0].setText(check); + buttons[0].setSelection(checkValue[0] !is 0); + data = new GridData (); + data.horizontalAlignment = GridData.BEGINNING; + buttons[0].setLayoutData (data); + } + Composite composite = new Composite(shell, DWT.NONE); + data = new GridData(); + data.horizontalAlignment = GridData.CENTER; + composite.setLayoutData (data); + composite.setLayout(new GridLayout(2, true)); + buttons[1] = new Button(composite, DWT.PUSH); + buttons[1].setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$ + buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttons[1].addListener(DWT.Selection, listener); + buttons[2] = new Button(composite, DWT.PUSH); + buttons[2].setText(DWT.getMessage("SWT_Cancel")); //$NON-NLS-1$ + buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttons[2].addListener(DWT.Selection, listener); + + shell.setDefaultButton(buttons[1]); + shell.pack(); + shell.open(); + Display display = parent.getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) display.sleep(); + } + } +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/PromptDialog.d~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/PromptDialog.d~ Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,307 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.PromptDialog; + +import dwt.dwthelper.utils; + +import dwt.DWT; +import dwt.layout.GridData; +import dwt.layout.GridLayout; +import dwt.widgets.Button; +import dwt.widgets.Composite; +import dwt.widgets.Dialog; +import dwt.widgets.Display; +import dwt.widgets.Event; +import dwt.widgets.Label; +import dwt.widgets.Listener; +import dwt.widgets.Monitor; +import dwt.widgets.Shell; +import dwt.widgets.Text; +import dwt.widgets.Widget; + +class PromptDialog extends Dialog { + + PromptDialog(Shell parent, int style) { + super(parent, style); + } + + PromptDialog(Shell parent) { + this(parent, 0); + } + + void alertCheck(String title, String text, String check, final int[] checkValue) { + Shell parent = getParent(); + final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); + if (title !is null) shell.setText(title); + GridLayout gridLayout = new GridLayout(); + shell.setLayout(gridLayout); + Label label = new Label(shell, DWT.WRAP); + label.setText(text); + GridData data = new GridData(); + Monitor monitor = parent.getMonitor(); + int maxWidth = monitor.getBounds().width * 2 / 3; + int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; + data.widthHint = Math.min(width, maxWidth); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + label.setLayoutData (data); + + final Button checkButton = check !is null ? new Button(shell, DWT.CHECK) : null; + if (checkButton !is null) { + checkButton.setText(check); + checkButton.setSelection(checkValue[0] !is 0); + data = new GridData (); + data.horizontalAlignment = GridData.BEGINNING; + checkButton.setLayoutData (data); + } + Button okButton = new Button(shell, DWT.PUSH); + okButton.setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$ + data = new GridData (); + data.horizontalAlignment = GridData.CENTER; + okButton.setLayoutData (data); + okButton.addListener(DWT.Selection, new Listener() { + public void handleEvent(Event event) { + if (checkButton !is null) checkValue[0] = checkButton.getSelection() ? 1 : 0; + shell.close(); + } + }); + + shell.pack(); + shell.open(); + Display display = parent.getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) display.sleep(); + } + } + + void confirmEx(String title, String text, String check, String button0, String button1, String button2, int defaultIndex, final int[] checkValue, final int[] result) { + Shell parent = getParent(); + final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); + shell.setText(title); + GridLayout gridLayout = new GridLayout(); + shell.setLayout(gridLayout); + Label label = new Label(shell, DWT.WRAP); + label.setText(text); + GridData data = new GridData(); + Monitor monitor = parent.getMonitor(); + int maxWidth = monitor.getBounds().width * 2 / 3; + int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; + data.widthHint = Math.min(width, maxWidth); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + label.setLayoutData (data); + + final Button[] buttons = new Button[4]; + Listener listener = new Listener() { + public void handleEvent(Event event) { + if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0; + Widget widget = event.widget; + for (int i = 1; i < buttons.length; i++) { + if (widget is buttons[i]) { + result[0] = i - 1; + break; + } + } + shell.close(); + } + }; + if (check !is null) { + buttons[0] = new Button(shell, DWT.CHECK); + buttons[0].setText(check); + buttons[0].setSelection(checkValue[0] !is 0); + data = new GridData (); + data.horizontalAlignment = GridData.BEGINNING; + buttons[0].setLayoutData (data); + } + Composite composite = new Composite(shell, DWT.NONE); + data = new GridData(); + data.horizontalAlignment = GridData.CENTER; + composite.setLayoutData (data); + GridLayout layout = new GridLayout(); + layout.makeColumnsEqualWidth = true; + composite.setLayout(layout); + int buttonCount = 0; + if (button0 !is null) { + buttons[1] = new Button(composite, DWT.PUSH); + buttons[1].setText(button0); + buttons[1].addListener(DWT.Selection, listener); + buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttonCount++; + } + if (button1 !is null) { + buttons[2] = new Button(composite, DWT.PUSH); + buttons[2].setText(button1); + buttons[2].addListener(DWT.Selection, listener); + buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttonCount++; + } + if (button2 !is null) { + buttons[3] = new Button(composite, DWT.PUSH); + buttons[3].setText(button2); + buttons[3].addListener(DWT.Selection, listener); + buttons[3].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttonCount++; + } + layout.numColumns = buttonCount; + Button defaultButton = buttons [defaultIndex + 1]; + if (defaultButton !is null) shell.setDefaultButton (defaultButton); + + shell.pack(); + shell.open(); + Display display = parent.getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) display.sleep(); + } + } + + void prompt(String title, String text, String check, final String[] value, final int[] checkValue, final int[] result) { + Shell parent = getParent(); + final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); + if (title !is null) shell.setText(title); + GridLayout gridLayout = new GridLayout(); + shell.setLayout(gridLayout); + Label label = new Label(shell, DWT.WRAP); + label.setText(text); + GridData data = new GridData(); + Monitor monitor = parent.getMonitor(); + int maxWidth = monitor.getBounds().width * 2 / 3; + int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; + data.widthHint = Math.min(width, maxWidth); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + label.setLayoutData (data); + + final Text valueText = new Text(shell, DWT.BORDER); + if (value[0] !is null) valueText.setText(value[0]); + data = new GridData(); + width = valueText.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; + if (width > maxWidth) data.widthHint = maxWidth; + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + valueText.setLayoutData(data); + + final Button[] buttons = new Button[3]; + Listener listener = new Listener() { + public void handleEvent(Event event) { + if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0; + value[0] = valueText.getText(); + result[0] = event.widget is buttons[1] ? 1 : 0; + shell.close(); + } + }; + if (check !is null) { + buttons[0] = new Button(shell, DWT.CHECK); + buttons[0].setText(check); + buttons[0].setSelection(checkValue[0] !is 0); + data = new GridData (); + data.horizontalAlignment = GridData.BEGINNING; + buttons[0].setLayoutData (data); + } + Composite composite = new Composite(shell, DWT.NONE); + data = new GridData(); + data.horizontalAlignment = GridData.CENTER; + composite.setLayoutData (data); + composite.setLayout(new GridLayout(2, true)); + buttons[1] = new Button(composite, DWT.PUSH); + buttons[1].setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$ + buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttons[1].addListener(DWT.Selection, listener); + buttons[2] = new Button(composite, DWT.PUSH); + buttons[2].setText(DWT.getMessage("SWT_Cancel")); //$NON-NLS-1$ + buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttons[2].addListener(DWT.Selection, listener); + + shell.pack(); + shell.open(); + Display display = parent.getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) display.sleep(); + } + } + + void promptUsernameAndPassword(String title, String text, String check, final String[] user, final String[] pass, final int[] checkValue, final int[] result) { + Shell parent = getParent(); + final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); + shell.setText(title); + GridLayout gridLayout = new GridLayout(); + shell.setLayout(gridLayout); + Label label = new Label(shell, DWT.WRAP); + label.setText(text); + GridData data = new GridData(); + Monitor monitor = parent.getMonitor(); + int maxWidth = monitor.getBounds().width * 2 / 3; + int width = label.computeSize(DWT.DEFAULT, DWT.DEFAULT).x; + data.widthHint = Math.min(width, maxWidth); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + label.setLayoutData (data); + + Label userLabel = new Label(shell, DWT.NONE); + userLabel.setText(DWT.getMessage("SWT_Username")); //$NON-NLS-1$ + + final Text userText = new Text(shell, DWT.BORDER); + if (user[0] !is null) userText.setText(user[0]); + data = new GridData(); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + userText.setLayoutData(data); + + Label passwordLabel = new Label(shell, DWT.NONE); + passwordLabel.setText(DWT.getMessage("SWT_Password")); //$NON-NLS-1$ + + final Text passwordText = new Text(shell, DWT.PASSWORD | DWT.BORDER); + if (pass[0] !is null) passwordText.setText(pass[0]); + data = new GridData(); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + passwordText.setLayoutData(data); + + final Button[] buttons = new Button[3]; + Listener listener = new Listener() { + public void handleEvent(Event event) { + if (buttons[0] !is null) checkValue[0] = buttons[0].getSelection() ? 1 : 0; + user[0] = userText.getText(); + pass[0] = passwordText.getText(); + result[0] = event.widget is buttons[1] ? 1 : 0; + shell.close(); + } + }; + if (check !is null) { + buttons[0] = new Button(shell, DWT.CHECK); + buttons[0].setText(check); + buttons[0].setSelection(checkValue[0] !is 0); + data = new GridData (); + data.horizontalAlignment = GridData.BEGINNING; + buttons[0].setLayoutData (data); + } + Composite composite = new Composite(shell, DWT.NONE); + data = new GridData(); + data.horizontalAlignment = GridData.CENTER; + composite.setLayoutData (data); + composite.setLayout(new GridLayout(2, true)); + buttons[1] = new Button(composite, DWT.PUSH); + buttons[1].setText(DWT.getMessage("SWT_OK")); //$NON-NLS-1$ + buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttons[1].addListener(DWT.Selection, listener); + buttons[2] = new Button(composite, DWT.PUSH); + buttons[2].setText(DWT.getMessage("SWT_Cancel")); //$NON-NLS-1$ + buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + buttons[2].addListener(DWT.Selection, listener); + + shell.setDefaultButton(buttons[1]); + shell.pack(); + shell.open(); + Display display = parent.getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) display.sleep(); + } + } +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/PromptService2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/PromptService2.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,701 @@ +/******************************************************************************* + * Copyright (c) 2003, 2008 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 + *******************************************************************************/ +module dwt.browser.PromptService2; + + +import Utf = tango.text.convert.Utf; + +import dwt.dwthelper.utils; + +import dwt.DWT; + +import dwt.internal.Compatibility; + +import dwt.internal.mozilla.nsEmbedString; +import dwt.internal.mozilla.nsIAuthInformation; +import dwt.internal.mozilla.nsIChannel; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsIEmbeddingSiteWindow; +import dwt.internal.mozilla.nsIMemory; +import dwt.internal.mozilla.nsIPromptService; +import dwt.internal.mozilla.nsIPromptService2; +import dwt.internal.mozilla.nsIServiceManager; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIWebBrowserChrome; +import dwt.internal.mozilla.nsIWindowWatcher; + +import nsStringAPI = dwt.internal.mozilla.nsStringAPI; + +import dwt.widgets.MessageBox; +import dwt.widgets.Shell; + +class PromptService2 +{ + private nsrefcnt _refCount = 0; + + /************************************************************************** + + **************************************************************************/ + + this () + { + } + + /************************************************************************** + + **************************************************************************/ + + nsrefcnt AddRef () + { + _refCount++; + return _refCount; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult QueryInterface ( ref nsIID riid, void** ppvObject ) + { + if (riid is null || ppvObject is null) + return NS_ERROR_NO_INTERFACE; + + if (riid == nsISupports.IID)) + { + *ppvObject = cast(void*)cast(nsISupports)this; + AddRef (); + return NS_OK; + } + + if ( riid == nsIPromptService.IID ) + { + *ppvObject = cast(void*)cast(nsIPromptService)this; + AddRef (); + return NS_OK; + } + + if ( riid == nsIPromptService2.IID) + { + *ppvObject = cast(void*)cast(nsIPromptService2)this; + AddRef (); + return NS_OK; + } + + *ppvObject = null; + return NS_ERROR_NO_INTERFACE; + } + + /************************************************************************** + + **************************************************************************/ + + nsrefcnt Release () + { + _refCount--; + if (_refCount is 0) + return 0; + return refCount; + } + + /************************************************************************** + + **************************************************************************/ + + Browser getBrowser (nsIDOMWindow aDOMWindow) + { + if (aDOMWindow is null) + return null; + + nsIServiceManager serviceManager; + void* result; + + nsresult rc = XPCOM.NS_GetServiceManager (&serviceManager); + + if (rc !is NS_OK) + Mozilla.error (rc); + if (serviceManager is null) + Mozilla.error (NS_NOINTERFACE); + + nsIWindowWatcher windowWatcher; + rc = serviceManager.GetServiceByContractID (aContractID, nsIWindowWatcher.IID, &windowWatcher); + + if (rc !is NS_OK) + Mozilla.error(rc); + if (windowWatcher is null) + Mozilla.error (NS_NOINTERFACE); + + serviceManager.Release (); + + /* the chrome will only be answered for the top-level nsIDOMWindow */ + auto window = aDOMWindow; + + rc = window.GetTop (&result); + + if (rc !is NS_OK) + Mozilla.error (rc); + if (result is null) + Mozilla.error (NS_NOINTERFACE); + + aDOMWindow = result; + + rc = windowWatcher.GetChromeForWindow (aDOMWindow, &result); + + if (rc !is NS_OK) + Mozilla.error (rc); + if (result is null) + Mozilla.error (NS_NOINTERFACE); + + windowWatcher.Release (); + + // This assignment should work if "result" tested valid in prior tests + auto webBrowserChrome = cast(nsIWebBrowserChrome) result; + + rc = webBrowserChrome.QueryInterface (nsIEmbeddingSiteWindow.IID, &result); + + if (rc !is NS_OK) + Mozilla.error (rc); + if (result is null) + Mozilla.error (NS_NOINTERFACE); + + webBrowserChrome.Release (); + + auto embeddingSiteWindow = cast(nsIEmbeddingSiteWindow) result; + + rc = embeddingSiteWindow.GetSiteWindow (&result); + + if (rc !is NS_OK) + Mozilla.error (rc); + if (result is null) + Mozilla.error (NS_NOINTERFACE); + + embeddingSiteWindow.Release (); + + return Mozilla.findBrowser (result); + } + + /************************************************************************** + + **************************************************************************/ + + String getLabel (int buttonFlag, int index, PRUnichar* buttonTitle) + { + String label = null; + int flag = (buttonFlag & (0xff * index)) / index; + + switch (flag) + { + case nsIPromptService.BUTTON_TITLE_CANCEL : + label = DWT.getMessage ("SWT_Cancel"); + break; + case nsIPromptService.BUTTON_TITLE_NO : + label = DWT.getMessage ("SWT_No"); + break; + case nsIPromptService.BUTTON_TITLE_OK : + label = DWT.getMessage ("SWT_OK"); + break; + case nsIPromptService.BUTTON_TITLE_SAVE : + label = DWT.getMessage ("SWT_Save"); + break; + case nsIPromptService.BUTTON_TITLE_YES : + label = DWT.getMessage ("SWT_Yes"); + break; + case nsIPromptService.BUTTON_TITLE_IS_STRING : + { + int span = nsStringAPI.strlen_PRUnichar (buttonTitle); + label = Utf.toString( buttonTitle[0..span] ); + } + } + return label; + } + + /************************************************************************** + + nsIPromptService + + **************************************************************************/ + + nsresult Alert (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText) + { + Browser browser = getBrowser (aParent); + + int span = nsStringAPI.strlen_PRUnichar( aDialogTitle ); + String titleLabel = Utf.toString (aDialogTitle[0..span]); + + span = nsStringAPI.strlen_PRUnichar( aText ); + String textLabel = Utf.toString( aText[0..span] ); + + Shell shell = browser is null ? new Shell () : browser.getShell (); + + auto messageBox = new MessageBox (shell, DWT.OK | DWT.ICON_WARNING); + messageBox.setText (titleLabel); + messageBox.setMessage (textLabel); + messageBox.open (); + + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult AlertCheck ( nsIDOMWindow aParent, PRUnichar* aDialogTitle, + PRUnichar* aText, PRUnichar* aCheckMsg, PRBool* aCheckState ) + { + auto browser = getBrowser (aParent); + + int span = nsStringAPI.strlen_PRUnichar( aDialogTitle ); + String titleLabel = Utf.toString( aDialogTitle[0..span] ); + + span = nsStringAPI.strlen_PRUnichar( aText ); + String textLabel = Utf.toString( aText[0..span] ); + + span = nsStringAPI.strlen_PRUnichar( aCheckMsg ); + String checkLabel = Utf.toString( aCheckMsg[0..span] ); + + auto shell = browser is null ? new Shell () : browser.getShell (); + auto dialog = new PromptDialog( shell ); + PRBool check = *aCheckState; + dialog.alertCheck( titleLabel, textLabel, checkLabel, check ); + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + int AsyncPromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int /*long*/ aCallback, int /*long*/ aContext, int level, int /*long*/ authInfo, int /*long*/ checkboxLabel, int /*long*/ checkValue, int /*long*/ _retval) + { + return NS_ERROR_NOT_IMPLEMENTED; + } + + /************************************************************************** + + **************************************************************************/ + +int Confirm (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ _retval) { + Browser browser = getBrowser (aParent); + + int length = XPCOM.strlen_PRUnichar (aDialogTitle); + char[] dest = new char[length]; + XPCOM.memmove (dest, aDialogTitle, length * 2); + String titleLabel = new String (dest); + + length = XPCOM.strlen_PRUnichar (aText); + dest = new char[length]; + XPCOM.memmove (dest, aText, length * 2); + String textLabel = new String (dest); + + Shell shell = browser is null ? new Shell () : browser.getShell (); + MessageBox messageBox = new MessageBox (shell, DWT.OK | DWT.CANCEL | DWT.ICON_QUESTION); + messageBox.setText (titleLabel); + messageBox.setMessage (textLabel); + int id = messageBox.open (); + int[] result = {id is DWT.OK ? 1 : 0}; + XPCOM.memmove (_retval, result, 4); + return XPCOM.NS_OK; +} + + /************************************************************************** + + **************************************************************************/ + +int ConfirmCheck (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + + /************************************************************************** + + **************************************************************************/ + +int ConfirmEx (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int aButtonFlags, int /*long*/ aButton0Title, int /*long*/ aButton1Title, int /*long*/ aButton2Title, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) { + Browser browser = getBrowser (aParent); + + int length = XPCOM.strlen_PRUnichar (aDialogTitle); + char[] dest = new char[length]; + XPCOM.memmove (dest, aDialogTitle, length * 2); + String titleLabel = new String (dest); + + length = XPCOM.strlen_PRUnichar (aText); + dest = new char[length]; + XPCOM.memmove (dest, aText, length * 2); + String textLabel = new String (dest); + + String checkLabel = null; + if (aCheckMsg !is 0) { + length = XPCOM.strlen_PRUnichar (aCheckMsg); + dest = new char[length]; + XPCOM.memmove (dest, aCheckMsg, length * 2); + checkLabel = new String (dest); + } + + String button0Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_0, aButton0Title); + String button1Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_1, aButton1Title); + String button2Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_2, aButton2Title); + + int defaultIndex = 0; + if ((aButtonFlags & nsIPromptService.BUTTON_POS_1_DEFAULT) !is 0) { + defaultIndex = 1; + } else if ((aButtonFlags & nsIPromptService.BUTTON_POS_2_DEFAULT) !is 0) { + defaultIndex = 2; + } + + Shell shell = browser is null ? new Shell () : browser.getShell (); + PromptDialog dialog = new PromptDialog (shell); + int[] check = new int[1], result = new int[1]; + if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4); + dialog.confirmEx (titleLabel, textLabel, checkLabel, button0Label, button1Label, button2Label, defaultIndex, check, result); + if (aCheckState !is 0) XPCOM.memmove (aCheckState, check, 4); + XPCOM.memmove (_retval, result, 4); + return XPCOM.NS_OK; +} + + /************************************************************************** + + **************************************************************************/ + +int Prompt (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aValue, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) { + Browser browser = getBrowser (aParent); + String titleLabel = null, textLabel, checkLabel = null; + String[] valueLabel = new String[1]; + char[] dest; + int length; + if (aDialogTitle !is 0) { + length = XPCOM.strlen_PRUnichar (aDialogTitle); + dest = new char[length]; + XPCOM.memmove (dest, aDialogTitle, length * 2); + titleLabel = new String (dest); + } + + length = XPCOM.strlen_PRUnichar (aText); + dest = new char[length]; + XPCOM.memmove (dest, aText, length * 2); + textLabel = new String (dest); + + int /*long*/[] valueAddr = new int /*long*/[1]; + XPCOM.memmove (valueAddr, aValue, C.PTR_SIZEOF); + if (valueAddr[0] !is 0) { + length = XPCOM.strlen_PRUnichar (valueAddr[0]); + dest = new char[length]; + XPCOM.memmove (dest, valueAddr[0], length * 2); + valueLabel[0] = new String (dest); + } + + if (aCheckMsg !is 0) { + length = XPCOM.strlen_PRUnichar (aCheckMsg); + if (length > 0) { + dest = new char[length]; + XPCOM.memmove (dest, aCheckMsg, length * 2); + checkLabel = new String (dest); + } + } + + Shell shell = browser is null ? new Shell () : browser.getShell (); + PromptDialog dialog = new PromptDialog (shell); + int[] check = new int[1], result = new int[1]; + if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4); + dialog.prompt (titleLabel, textLabel, checkLabel, valueLabel, check, result); + + XPCOM.memmove (_retval, result, 4); + if (result[0] is 1) { + /* + * User selected OK. User name and password are returned as PRUnichar values. Any default + * value that we override must be freed using the nsIMemory service. + */ + int cnt, size; + int /*long*/ ptr; + char[] buffer; + int /*long*/[] result2 = new int /*long*/[1]; + if (valueLabel[0] !is null) { + cnt = valueLabel[0].length (); + buffer = new char[cnt + 1]; + valueLabel[0].getChars (0, cnt, buffer, 0); + size = buffer.length * 2; + ptr = C.malloc (size); + XPCOM.memmove (ptr, buffer, size); + XPCOM.memmove (aValue, new int /*long*/[] {ptr}, C.PTR_SIZEOF); + + if (valueAddr[0] !is 0) { + int rc = XPCOM.NS_GetServiceManager (result2); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE); + + nsIServiceManager serviceManager = new nsIServiceManager (result2[0]); + result2[0] = 0; + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE); + serviceManager.Release (); + + nsIMemory memory = new nsIMemory (result2[0]); + result2[0] = 0; + memory.Free (valueAddr[0]); + memory.Release (); + } + } + } + if (aCheckState !is 0) XPCOM.memmove (aCheckState, check, 4); + return XPCOM.NS_OK; +} + + /************************************************************************** + + **************************************************************************/ + +int PromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int level, int /*long*/ authInfo, int /*long*/ checkboxLabel, int /*long*/ checkboxValue, int /*long*/ _retval) { + Browser browser = getBrowser (aParent); + String checkLabel = null; + int[] checkValue = new int[1]; + String[] userLabel = new String[1], passLabel = new String[1]; + + String title = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$ + + if (checkboxLabel !is 0 && checkboxValue !is 0) { + int length = XPCOM.strlen_PRUnichar (checkboxLabel); + char[] dest = new char[length]; + XPCOM.memmove (dest, checkboxLabel, length * 2); + checkLabel = new String (dest); + XPCOM.memmove (checkValue, checkboxValue, 4); /* PRBool */ + } + + /* get initial username and password values */ + + nsIAuthInformation auth = new nsIAuthInformation (authInfo); + + int /*long*/ ptr = XPCOM.nsEmbedString_new (); + int rc = auth.GetUsername (ptr); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + int length = XPCOM.nsEmbedString_Length (ptr); + int /*long*/ buffer = XPCOM.nsEmbedString_get (ptr); + char[] chars = new char[length]; + XPCOM.memmove (chars, buffer, length * 2); + userLabel[0] = new String (chars); + XPCOM.nsEmbedString_delete (ptr); + + ptr = XPCOM.nsEmbedString_new (); + rc = auth.GetPassword (ptr); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + length = XPCOM.nsEmbedString_Length (ptr); + buffer = XPCOM.nsEmbedString_get (ptr); + chars = new char[length]; + XPCOM.memmove (chars, buffer, length * 2); + passLabel[0] = new String (chars); + XPCOM.nsEmbedString_delete (ptr); + + /* compute the message text */ + + ptr = XPCOM.nsEmbedString_new (); + rc = auth.GetRealm (ptr); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + length = XPCOM.nsEmbedString_Length (ptr); + buffer = XPCOM.nsEmbedString_get (ptr); + chars = new char[length]; + XPCOM.memmove (chars, buffer, length * 2); + String realm = new String (chars); + XPCOM.nsEmbedString_delete (ptr); + + nsIChannel channel = new nsIChannel (aChannel); + int /*long*/[] uri = new int /*long*/[1]; + rc = channel.GetURI (uri); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (uri[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE); + + nsIURI nsURI = new nsIURI (uri[0]); + int /*long*/ aSpec = XPCOM.nsEmbedCString_new (); + rc = nsURI.GetHost (aSpec); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + length = XPCOM.nsEmbedCString_Length (aSpec); + buffer = XPCOM.nsEmbedCString_get (aSpec); + byte[] bytes = new byte[length]; + XPCOM.memmove (bytes, buffer, length); + XPCOM.nsEmbedCString_delete (aSpec); + String host = new String (bytes); + nsURI.Release (); + + String message; + if (realm.length () > 0 && host.length () > 0) { + message = Compatibility.getMessage ("SWT_Enter_Username_and_Password", new String[] {realm, host}); //$NON-NLS-1$ + } else { + message = ""; //$NON-NLS-1$ + } + + /* open the prompter */ + Shell shell = browser is null ? new Shell () : browser.getShell (); + PromptDialog dialog = new PromptDialog (shell); + int[] result = new int[1]; + dialog.promptUsernameAndPassword (title, message, checkLabel, userLabel, passLabel, checkValue, result); + + XPCOM.memmove (_retval, result, 4); /* PRBool */ + if (result[0] is 1) { /* User selected OK */ + nsEmbedString string = new nsEmbedString (userLabel[0]); + rc = auth.SetUsername(string.getAddress ()); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + string.dispose (); + + string = new nsEmbedString (passLabel[0]); + rc = auth.SetPassword(string.getAddress ()); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + string.dispose (); + } + + if (checkboxValue !is 0) XPCOM.memmove (checkboxValue, checkValue, 4); /* PRBool */ + return XPCOM.NS_OK; +} + + /************************************************************************** + + **************************************************************************/ + +int PromptUsernameAndPassword (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aUsername, int /*long*/ aPassword, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) { + Browser browser = getBrowser (aParent); + String titleLabel, textLabel, checkLabel = null; + String[] userLabel = new String[1], passLabel = new String[1]; + char[] dest; + int length; + if (aDialogTitle !is 0) { + length = XPCOM.strlen_PRUnichar (aDialogTitle); + dest = new char[length]; + XPCOM.memmove (dest, aDialogTitle, length * 2); + titleLabel = new String (dest); + } else { + titleLabel = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$ + } + + length = XPCOM.strlen_PRUnichar (aText); + dest = new char[length]; + XPCOM.memmove (dest, aText, length * 2); + textLabel = new String (dest); + + int /*long*/[] userAddr = new int /*long*/[1]; + XPCOM.memmove (userAddr, aUsername, C.PTR_SIZEOF); + if (userAddr[0] !is 0) { + length = XPCOM.strlen_PRUnichar (userAddr[0]); + dest = new char[length]; + XPCOM.memmove (dest, userAddr[0], length * 2); + userLabel[0] = new String (dest); + } + + int /*long*/[] passAddr = new int /*long*/[1]; + XPCOM.memmove (passAddr, aPassword, C.PTR_SIZEOF); + if (passAddr[0] !is 0) { + length = XPCOM.strlen_PRUnichar (passAddr[0]); + dest = new char[length]; + XPCOM.memmove (dest, passAddr[0], length * 2); + passLabel[0] = new String (dest); + } + + if (aCheckMsg !is 0) { + length = XPCOM.strlen_PRUnichar (aCheckMsg); + if (length > 0) { + dest = new char[length]; + XPCOM.memmove (dest, aCheckMsg, length * 2); + checkLabel = new String (dest); + } + } + + Shell shell = browser is null ? new Shell () : browser.getShell (); + PromptDialog dialog = new PromptDialog (shell); + int[] check = new int[1], result = new int[1]; + if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4); /* PRBool */ + dialog.promptUsernameAndPassword (titleLabel, textLabel, checkLabel, userLabel, passLabel, check, result); + + XPCOM.memmove (_retval, result, 4); /* PRBool */ + if (result[0] is 1) { + /* + * User selected OK. User name and password are returned as PRUnichar values. Any default + * value that we override must be freed using the nsIMemory service. + */ + int cnt, size; + int /*long*/ ptr; + char[] buffer; + int /*long*/[] result2 = new int /*long*/[1]; + if (userLabel[0] !is null) { + cnt = userLabel[0].length (); + buffer = new char[cnt + 1]; + userLabel[0].getChars (0, cnt, buffer, 0); + size = buffer.length * 2; + ptr = C.malloc (size); + XPCOM.memmove (ptr, buffer, size); + XPCOM.memmove (aUsername, new int /*long*/[] {ptr}, C.PTR_SIZEOF); + + if (userAddr[0] !is 0) { + int rc = XPCOM.NS_GetServiceManager (result2); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE); + + nsIServiceManager serviceManager = new nsIServiceManager (result2[0]); + result2[0] = 0; + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (result[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE); + serviceManager.Release (); + + nsIMemory memory = new nsIMemory (result2[0]); + result2[0] = 0; + memory.Free (userAddr[0]); + memory.Release (); + } + } + if (passLabel[0] !is null) { + cnt = passLabel[0].length (); + buffer = new char[cnt + 1]; + passLabel[0].getChars (0, cnt, buffer, 0); + size = buffer.length * 2; + ptr = C.malloc (size); + XPCOM.memmove (ptr, buffer, size); + XPCOM.memmove (aPassword, new int /*long*/[] {ptr}, C.PTR_SIZEOF); + + if (passAddr[0] !is 0) { + int rc = XPCOM.NS_GetServiceManager (result2); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE); + + nsIServiceManager serviceManager = new nsIServiceManager (result2[0]); + result2[0] = 0; + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE); + serviceManager.Release (); + + nsIMemory memory = new nsIMemory (result2[0]); + result2[0] = 0; + memory.Free (passAddr[0]); + memory.Release (); + } + } + } + if (aCheckState !is 0) XPCOM.memmove (aCheckState, check, 4); /* PRBool */ + return XPCOM.NS_OK; +} + + /************************************************************************** + + **************************************************************************/ + + int PromptPassword (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aPassword, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) + { + return NS_ERROR_NOT_IMPLEMENTED; + } + + /************************************************************************** + + **************************************************************************/ + + int Select (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int aCount, int /*long*/ aSelectList, int /*long*/ aOutSelection, int /*long*/ _retval) + { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; + } + +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/PromptService2.d~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/PromptService2.d~ Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,701 @@ +/******************************************************************************* + * Copyright (c) 2003, 2008 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 + *******************************************************************************/ +module dwt.browser.PromptService2; + + +import Utf = tango.text.convert.Utf; + +import dwt.dwthelper.utils; + +import dwt.DWT; + +import dwt.internal.Compatibility; + +import dwt.internal.mozilla.nsEmbedString; +import dwt.internal.mozilla.nsIAuthInformation; +import dwt.internal.mozilla.nsIChannel; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsIEmbeddingSiteWindow; +import dwt.internal.mozilla.nsIMemory; +import dwt.internal.mozilla.nsIPromptService; +import dwt.internal.mozilla.nsIPromptService2; +import dwt.internal.mozilla.nsIServiceManager; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIWebBrowserChrome; +import dwt.internal.mozilla.nsIWindowWatcher; + +import nsStringAPI = dwt.internal.mozilla.nsStringAPI; + +import dwt.widgets.MessageBox; +import dwt.widgets.Shell; + +class PromptService2 +{ + private nsrefcnt _refCount = 0; + + /************************************************************************** + + **************************************************************************/ + + this () + { + } + + /************************************************************************** + + **************************************************************************/ + + nsrefcnt AddRef () + { + _refCount++; + return _refCount; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult QueryInterface ( ref nsIID riid, void** ppvObject ) + { + if (riid is null || ppvObject is null) + return NS_ERROR_NO_INTERFACE; + + if (riid == nsISupports.IID)) + { + *ppvObject = cast(void*)cast(nsISupports)this; + AddRef (); + return NS_OK; + } + + if ( riid == nsIPromptService.IID ) + { + *ppvObject = cast(void*)cast(nsIPromptService)this; + AddRef (); + return NS_OK; + } + + if ( riid == nsIPromptService2.IID) + { + *ppvObject = cast(void*)cast(nsIPromptService2)this; + AddRef (); + return NS_OK; + } + + *ppvObject = null; + return NS_ERROR_NO_INTERFACE; + } + + /************************************************************************** + + **************************************************************************/ + + nsrefcnt Release () + { + _refCount--; + if (_refCount is 0) + return 0; + return refCount; + } + + /************************************************************************** + + **************************************************************************/ + + Browser getBrowser (nsIDOMWindow aDOMWindow) + { + if (aDOMWindow is null) + return null; + + nsIServiceManager serviceManager; + void* result; + + nsresult rc = XPCOM.NS_GetServiceManager (&serviceManager); + + if (rc !is NS_OK) + Mozilla.error (rc); + if (serviceManager is null) + Mozilla.error (NS_NOINTERFACE); + + nsIWindowWatcher windowWatcher; + rc = serviceManager.GetServiceByContractID (aContractID, nsIWindowWatcher.IID, &windowWatcher); + + if (rc !is NS_OK) + Mozilla.error(rc); + if (windowWatcher is null) + Mozilla.error (NS_NOINTERFACE); + + serviceManager.Release (); + + /* the chrome will only be answered for the top-level nsIDOMWindow */ + auto window = aDOMWindow; + + rc = window.GetTop (&result); + + if (rc !is NS_OK) + Mozilla.error (rc); + if (result is null) + Mozilla.error (NS_NOINTERFACE); + + aDOMWindow = result; + + rc = windowWatcher.GetChromeForWindow (aDOMWindow, &result); + + if (rc !is NS_OK) + Mozilla.error (rc); + if (result is null) + Mozilla.error (NS_NOINTERFACE); + + windowWatcher.Release (); + + // This assignment should work if "result" tested valid in prior tests + auto webBrowserChrome = cast(nsIWebBrowserChrome) result; + + rc = webBrowserChrome.QueryInterface (nsIEmbeddingSiteWindow.IID, &result); + + if (rc !is NS_OK) + Mozilla.error (rc); + if (result is null) + Mozilla.error (NS_NOINTERFACE); + + webBrowserChrome.Release (); + + auto embeddingSiteWindow = cast(nsIEmbeddingSiteWindow) result; + + rc = embeddingSiteWindow.GetSiteWindow (&result); + + if (rc !is NS_OK) + Mozilla.error (rc); + if (result is null) + Mozilla.error (NS_NOINTERFACE); + + embeddingSiteWindow.Release (); + + return Mozilla.findBrowser (result); + } + + /************************************************************************** + + **************************************************************************/ + + String getLabel (int buttonFlag, int index, PRUnichar* buttonTitle) + { + String label = null; + int flag = (buttonFlag & (0xff * index)) / index; + + switch (flag) + { + case nsIPromptService.BUTTON_TITLE_CANCEL : + label = DWT.getMessage ("SWT_Cancel"); + break; + case nsIPromptService.BUTTON_TITLE_NO : + label = DWT.getMessage ("SWT_No"); + break; + case nsIPromptService.BUTTON_TITLE_OK : + label = DWT.getMessage ("SWT_OK"); + break; + case nsIPromptService.BUTTON_TITLE_SAVE : + label = DWT.getMessage ("SWT_Save"); + break; + case nsIPromptService.BUTTON_TITLE_YES : + label = DWT.getMessage ("SWT_Yes"); + break; + case nsIPromptService.BUTTON_TITLE_IS_STRING : + { + int span = nsStringAPI.strlen_PRUnichar (buttonTitle); + label = Utf.toString( buttonTitle[0..span] ); + } + } + return label; + } + + /************************************************************************** + + nsIPromptService + + **************************************************************************/ + + nsresult Alert (nsIDOMWindow aParent, PRUnichar* aDialogTitle, PRUnichar* aText) + { + Browser browser = getBrowser (aParent); + + int span = nsStringAPI.strlen_PRUnichar( aDialogTitle ); + String titleLabel = Utf.toString (aDialogTitle[0..span]); + + span = nsStringAPI.strlen_PRUnichar( aText ); + String textLabel = Utf.toString( aText[0..span] ); + + Shell shell = browser is null ? new Shell () : browser.getShell (); + + auto messageBox = new MessageBox (shell, DWT.OK | DWT.ICON_WARNING); + messageBox.setText (titleLabel); + messageBox.setMessage (textLabel); + messageBox.open (); + + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + nsresult AlertCheck ( nsIDOMWindow aParent, PRUnichar* aDialogTitle, + PRUnichar* aText, PRUnichar* aCheckMsg, PRBool* aCheckState ) + { + auto browser = getBrowser (aParent); + + int span = nsStringAPI.strlen_PRUnichar( aDialogTitle ); + String titleLabel = Utf.toString( aDialogTitle[0..span] ); + + span = nsStringAPI.strlen_PRUnichar( aText ); + String textLabel = Utf.toString( aText[0..span] ); + + span = nsStringAPI.strlen_PRUnichar( aCheckMsg ); + String checkLabel = Utf.toString( aCheckMsg[0..span] ); + + auto shell = browser is null ? new Shell () : browser.getShell (); + PromptDialog dialog = new PromptDialog( shell ); + PRBool check = *aCheckState; + dialog.alertCheck( titleLabel, textLabel, checkLabel, check ); + return NS_OK; + } + + /************************************************************************** + + **************************************************************************/ + + int AsyncPromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int /*long*/ aCallback, int /*long*/ aContext, int level, int /*long*/ authInfo, int /*long*/ checkboxLabel, int /*long*/ checkValue, int /*long*/ _retval) + { + return NS_ERROR_NOT_IMPLEMENTED; + } + + /************************************************************************** + + **************************************************************************/ + +int Confirm (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ _retval) { + Browser browser = getBrowser (aParent); + + int length = XPCOM.strlen_PRUnichar (aDialogTitle); + char[] dest = new char[length]; + XPCOM.memmove (dest, aDialogTitle, length * 2); + String titleLabel = new String (dest); + + length = XPCOM.strlen_PRUnichar (aText); + dest = new char[length]; + XPCOM.memmove (dest, aText, length * 2); + String textLabel = new String (dest); + + Shell shell = browser is null ? new Shell () : browser.getShell (); + MessageBox messageBox = new MessageBox (shell, DWT.OK | DWT.CANCEL | DWT.ICON_QUESTION); + messageBox.setText (titleLabel); + messageBox.setMessage (textLabel); + int id = messageBox.open (); + int[] result = {id is DWT.OK ? 1 : 0}; + XPCOM.memmove (_retval, result, 4); + return XPCOM.NS_OK; +} + + /************************************************************************** + + **************************************************************************/ + +int ConfirmCheck (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} + + /************************************************************************** + + **************************************************************************/ + +int ConfirmEx (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int aButtonFlags, int /*long*/ aButton0Title, int /*long*/ aButton1Title, int /*long*/ aButton2Title, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) { + Browser browser = getBrowser (aParent); + + int length = XPCOM.strlen_PRUnichar (aDialogTitle); + char[] dest = new char[length]; + XPCOM.memmove (dest, aDialogTitle, length * 2); + String titleLabel = new String (dest); + + length = XPCOM.strlen_PRUnichar (aText); + dest = new char[length]; + XPCOM.memmove (dest, aText, length * 2); + String textLabel = new String (dest); + + String checkLabel = null; + if (aCheckMsg !is 0) { + length = XPCOM.strlen_PRUnichar (aCheckMsg); + dest = new char[length]; + XPCOM.memmove (dest, aCheckMsg, length * 2); + checkLabel = new String (dest); + } + + String button0Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_0, aButton0Title); + String button1Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_1, aButton1Title); + String button2Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_2, aButton2Title); + + int defaultIndex = 0; + if ((aButtonFlags & nsIPromptService.BUTTON_POS_1_DEFAULT) !is 0) { + defaultIndex = 1; + } else if ((aButtonFlags & nsIPromptService.BUTTON_POS_2_DEFAULT) !is 0) { + defaultIndex = 2; + } + + Shell shell = browser is null ? new Shell () : browser.getShell (); + PromptDialog dialog = new PromptDialog (shell); + int[] check = new int[1], result = new int[1]; + if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4); + dialog.confirmEx (titleLabel, textLabel, checkLabel, button0Label, button1Label, button2Label, defaultIndex, check, result); + if (aCheckState !is 0) XPCOM.memmove (aCheckState, check, 4); + XPCOM.memmove (_retval, result, 4); + return XPCOM.NS_OK; +} + + /************************************************************************** + + **************************************************************************/ + +int Prompt (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aValue, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) { + Browser browser = getBrowser (aParent); + String titleLabel = null, textLabel, checkLabel = null; + String[] valueLabel = new String[1]; + char[] dest; + int length; + if (aDialogTitle !is 0) { + length = XPCOM.strlen_PRUnichar (aDialogTitle); + dest = new char[length]; + XPCOM.memmove (dest, aDialogTitle, length * 2); + titleLabel = new String (dest); + } + + length = XPCOM.strlen_PRUnichar (aText); + dest = new char[length]; + XPCOM.memmove (dest, aText, length * 2); + textLabel = new String (dest); + + int /*long*/[] valueAddr = new int /*long*/[1]; + XPCOM.memmove (valueAddr, aValue, C.PTR_SIZEOF); + if (valueAddr[0] !is 0) { + length = XPCOM.strlen_PRUnichar (valueAddr[0]); + dest = new char[length]; + XPCOM.memmove (dest, valueAddr[0], length * 2); + valueLabel[0] = new String (dest); + } + + if (aCheckMsg !is 0) { + length = XPCOM.strlen_PRUnichar (aCheckMsg); + if (length > 0) { + dest = new char[length]; + XPCOM.memmove (dest, aCheckMsg, length * 2); + checkLabel = new String (dest); + } + } + + Shell shell = browser is null ? new Shell () : browser.getShell (); + PromptDialog dialog = new PromptDialog (shell); + int[] check = new int[1], result = new int[1]; + if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4); + dialog.prompt (titleLabel, textLabel, checkLabel, valueLabel, check, result); + + XPCOM.memmove (_retval, result, 4); + if (result[0] is 1) { + /* + * User selected OK. User name and password are returned as PRUnichar values. Any default + * value that we override must be freed using the nsIMemory service. + */ + int cnt, size; + int /*long*/ ptr; + char[] buffer; + int /*long*/[] result2 = new int /*long*/[1]; + if (valueLabel[0] !is null) { + cnt = valueLabel[0].length (); + buffer = new char[cnt + 1]; + valueLabel[0].getChars (0, cnt, buffer, 0); + size = buffer.length * 2; + ptr = C.malloc (size); + XPCOM.memmove (ptr, buffer, size); + XPCOM.memmove (aValue, new int /*long*/[] {ptr}, C.PTR_SIZEOF); + + if (valueAddr[0] !is 0) { + int rc = XPCOM.NS_GetServiceManager (result2); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE); + + nsIServiceManager serviceManager = new nsIServiceManager (result2[0]); + result2[0] = 0; + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE); + serviceManager.Release (); + + nsIMemory memory = new nsIMemory (result2[0]); + result2[0] = 0; + memory.Free (valueAddr[0]); + memory.Release (); + } + } + } + if (aCheckState !is 0) XPCOM.memmove (aCheckState, check, 4); + return XPCOM.NS_OK; +} + + /************************************************************************** + + **************************************************************************/ + +int PromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int level, int /*long*/ authInfo, int /*long*/ checkboxLabel, int /*long*/ checkboxValue, int /*long*/ _retval) { + Browser browser = getBrowser (aParent); + String checkLabel = null; + int[] checkValue = new int[1]; + String[] userLabel = new String[1], passLabel = new String[1]; + + String title = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$ + + if (checkboxLabel !is 0 && checkboxValue !is 0) { + int length = XPCOM.strlen_PRUnichar (checkboxLabel); + char[] dest = new char[length]; + XPCOM.memmove (dest, checkboxLabel, length * 2); + checkLabel = new String (dest); + XPCOM.memmove (checkValue, checkboxValue, 4); /* PRBool */ + } + + /* get initial username and password values */ + + nsIAuthInformation auth = new nsIAuthInformation (authInfo); + + int /*long*/ ptr = XPCOM.nsEmbedString_new (); + int rc = auth.GetUsername (ptr); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + int length = XPCOM.nsEmbedString_Length (ptr); + int /*long*/ buffer = XPCOM.nsEmbedString_get (ptr); + char[] chars = new char[length]; + XPCOM.memmove (chars, buffer, length * 2); + userLabel[0] = new String (chars); + XPCOM.nsEmbedString_delete (ptr); + + ptr = XPCOM.nsEmbedString_new (); + rc = auth.GetPassword (ptr); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + length = XPCOM.nsEmbedString_Length (ptr); + buffer = XPCOM.nsEmbedString_get (ptr); + chars = new char[length]; + XPCOM.memmove (chars, buffer, length * 2); + passLabel[0] = new String (chars); + XPCOM.nsEmbedString_delete (ptr); + + /* compute the message text */ + + ptr = XPCOM.nsEmbedString_new (); + rc = auth.GetRealm (ptr); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + length = XPCOM.nsEmbedString_Length (ptr); + buffer = XPCOM.nsEmbedString_get (ptr); + chars = new char[length]; + XPCOM.memmove (chars, buffer, length * 2); + String realm = new String (chars); + XPCOM.nsEmbedString_delete (ptr); + + nsIChannel channel = new nsIChannel (aChannel); + int /*long*/[] uri = new int /*long*/[1]; + rc = channel.GetURI (uri); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (uri[0] is 0) Mozilla.error (XPCOM.NS_NOINTERFACE); + + nsIURI nsURI = new nsIURI (uri[0]); + int /*long*/ aSpec = XPCOM.nsEmbedCString_new (); + rc = nsURI.GetHost (aSpec); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + length = XPCOM.nsEmbedCString_Length (aSpec); + buffer = XPCOM.nsEmbedCString_get (aSpec); + byte[] bytes = new byte[length]; + XPCOM.memmove (bytes, buffer, length); + XPCOM.nsEmbedCString_delete (aSpec); + String host = new String (bytes); + nsURI.Release (); + + String message; + if (realm.length () > 0 && host.length () > 0) { + message = Compatibility.getMessage ("SWT_Enter_Username_and_Password", new String[] {realm, host}); //$NON-NLS-1$ + } else { + message = ""; //$NON-NLS-1$ + } + + /* open the prompter */ + Shell shell = browser is null ? new Shell () : browser.getShell (); + PromptDialog dialog = new PromptDialog (shell); + int[] result = new int[1]; + dialog.promptUsernameAndPassword (title, message, checkLabel, userLabel, passLabel, checkValue, result); + + XPCOM.memmove (_retval, result, 4); /* PRBool */ + if (result[0] is 1) { /* User selected OK */ + nsEmbedString string = new nsEmbedString (userLabel[0]); + rc = auth.SetUsername(string.getAddress ()); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + string.dispose (); + + string = new nsEmbedString (passLabel[0]); + rc = auth.SetPassword(string.getAddress ()); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + string.dispose (); + } + + if (checkboxValue !is 0) XPCOM.memmove (checkboxValue, checkValue, 4); /* PRBool */ + return XPCOM.NS_OK; +} + + /************************************************************************** + + **************************************************************************/ + +int PromptUsernameAndPassword (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aUsername, int /*long*/ aPassword, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) { + Browser browser = getBrowser (aParent); + String titleLabel, textLabel, checkLabel = null; + String[] userLabel = new String[1], passLabel = new String[1]; + char[] dest; + int length; + if (aDialogTitle !is 0) { + length = XPCOM.strlen_PRUnichar (aDialogTitle); + dest = new char[length]; + XPCOM.memmove (dest, aDialogTitle, length * 2); + titleLabel = new String (dest); + } else { + titleLabel = DWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$ + } + + length = XPCOM.strlen_PRUnichar (aText); + dest = new char[length]; + XPCOM.memmove (dest, aText, length * 2); + textLabel = new String (dest); + + int /*long*/[] userAddr = new int /*long*/[1]; + XPCOM.memmove (userAddr, aUsername, C.PTR_SIZEOF); + if (userAddr[0] !is 0) { + length = XPCOM.strlen_PRUnichar (userAddr[0]); + dest = new char[length]; + XPCOM.memmove (dest, userAddr[0], length * 2); + userLabel[0] = new String (dest); + } + + int /*long*/[] passAddr = new int /*long*/[1]; + XPCOM.memmove (passAddr, aPassword, C.PTR_SIZEOF); + if (passAddr[0] !is 0) { + length = XPCOM.strlen_PRUnichar (passAddr[0]); + dest = new char[length]; + XPCOM.memmove (dest, passAddr[0], length * 2); + passLabel[0] = new String (dest); + } + + if (aCheckMsg !is 0) { + length = XPCOM.strlen_PRUnichar (aCheckMsg); + if (length > 0) { + dest = new char[length]; + XPCOM.memmove (dest, aCheckMsg, length * 2); + checkLabel = new String (dest); + } + } + + Shell shell = browser is null ? new Shell () : browser.getShell (); + PromptDialog dialog = new PromptDialog (shell); + int[] check = new int[1], result = new int[1]; + if (aCheckState !is 0) XPCOM.memmove (check, aCheckState, 4); /* PRBool */ + dialog.promptUsernameAndPassword (titleLabel, textLabel, checkLabel, userLabel, passLabel, check, result); + + XPCOM.memmove (_retval, result, 4); /* PRBool */ + if (result[0] is 1) { + /* + * User selected OK. User name and password are returned as PRUnichar values. Any default + * value that we override must be freed using the nsIMemory service. + */ + int cnt, size; + int /*long*/ ptr; + char[] buffer; + int /*long*/[] result2 = new int /*long*/[1]; + if (userLabel[0] !is null) { + cnt = userLabel[0].length (); + buffer = new char[cnt + 1]; + userLabel[0].getChars (0, cnt, buffer, 0); + size = buffer.length * 2; + ptr = C.malloc (size); + XPCOM.memmove (ptr, buffer, size); + XPCOM.memmove (aUsername, new int /*long*/[] {ptr}, C.PTR_SIZEOF); + + if (userAddr[0] !is 0) { + int rc = XPCOM.NS_GetServiceManager (result2); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE); + + nsIServiceManager serviceManager = new nsIServiceManager (result2[0]); + result2[0] = 0; + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (result[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE); + serviceManager.Release (); + + nsIMemory memory = new nsIMemory (result2[0]); + result2[0] = 0; + memory.Free (userAddr[0]); + memory.Release (); + } + } + if (passLabel[0] !is null) { + cnt = passLabel[0].length (); + buffer = new char[cnt + 1]; + passLabel[0].getChars (0, cnt, buffer, 0); + size = buffer.length * 2; + ptr = C.malloc (size); + XPCOM.memmove (ptr, buffer, size); + XPCOM.memmove (aPassword, new int /*long*/[] {ptr}, C.PTR_SIZEOF); + + if (passAddr[0] !is 0) { + int rc = XPCOM.NS_GetServiceManager (result2); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE); + + nsIServiceManager serviceManager = new nsIServiceManager (result2[0]); + result2[0] = 0; + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2); + if (rc !is XPCOM.NS_OK) DWT.error (rc); + if (result2[0] is 0) DWT.error (XPCOM.NS_NOINTERFACE); + serviceManager.Release (); + + nsIMemory memory = new nsIMemory (result2[0]); + result2[0] = 0; + memory.Free (passAddr[0]); + memory.Release (); + } + } + } + if (aCheckState !is 0) XPCOM.memmove (aCheckState, check, 4); /* PRBool */ + return XPCOM.NS_OK; +} + + /************************************************************************** + + **************************************************************************/ + + int PromptPassword (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aPassword, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) + { + return NS_ERROR_NOT_IMPLEMENTED; + } + + /************************************************************************** + + **************************************************************************/ + + int Select (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int aCount, int /*long*/ aSelectList, int /*long*/ aOutSelection, int /*long*/ _retval) + { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; + } + +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/PromptService2Factory.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/PromptService2Factory.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright (c) 2003, 2008 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 + *******************************************************************************/ +module dwt.browser.PromptService2Factory; + +import dwt.dwthelper.utils; + +import dwt.internal.C; +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIFactory; +import dwt.internal.mozilla.nsISupports; + +class PromptService2Factory { + XPCOMObject supports; + XPCOMObject factory; + int refCount = 0; + +PromptService2Factory () { + createCOMInterfaces (); +} + +int AddRef () { + refCount++; + return refCount; +} + +void createCOMInterfaces () { + /* Create each of the interfaces that this object implements */ + supports = new XPCOMObject (new int[] {2, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + }; + + factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);} + public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);} + }; +} + +void disposeCOMInterfaces () { + if (supports !is null) { + supports.dispose (); + supports = null; + } + if (factory !is null) { + factory.dispose (); + factory = null; + } +} + +int /*long*/ getAddress () { + return factory.getAddress (); +} + +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int Release () { + refCount--; + if (refCount is 0) disposeCOMInterfaces (); + return refCount; +} + +/* nsIFactory */ + +int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) { + PromptService2 promptService = new PromptService2 (); + promptService.AddRef (); + XPCOM.memmove (result, new int /*long*/[] {promptService.getAddress ()}, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} + +int LockFactory (int lock) { + return XPCOM.NS_OK; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/SimpleEnumerator.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/SimpleEnumerator.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.SimpleEnumerator; + +import dwt.dwthelper.utils; + +import dwt.internal.C; +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.XPCOMObject; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISimpleEnumerator; +import dwt.internal.mozilla.nsISupports; + +class SimpleEnumerator { + XPCOMObject supports; + XPCOMObject simpleEnumerator; + int refCount = 0; + nsISupports[] values; + int index = 0; + +SimpleEnumerator (nsISupports[] values) { + this.values = values; + for (int i = 0; i < values.length; i++) { + values[i].AddRef (); + } + createCOMInterfaces (); +} + +int AddRef () { + refCount++; + return refCount; +} + +void createCOMInterfaces () { + /* Create each of the interfaces that this object implements */ + supports = new XPCOMObject (new int[] {2, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + }; + + simpleEnumerator = new XPCOMObject (new int[] {2, 0, 0, 1, 1}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return HasMoreElements (args[0]);} + public int /*long*/ method4 (int /*long*/[] args) {return GetNext (args[0]);} + }; +} + +void disposeCOMInterfaces () { + if (supports !is null) { + supports.dispose (); + supports = null; + } + if (simpleEnumerator !is null) { + simpleEnumerator.dispose (); + simpleEnumerator = null; + } + if (values !is null) { + for (int i = 0; i < values.length; i++) { + values[i].Release (); + } + values = null; + } +} + +int /*long*/ getAddress () { + return simpleEnumerator.getAddress (); +} + +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsISimpleEnumerator.NS_ISIMPLEENUMERATOR_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {simpleEnumerator.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int Release () { + refCount--; + if (refCount is 0) disposeCOMInterfaces (); + return refCount; +} + +int HasMoreElements (int /*long*/ _retval) { + bool more = values !is null && index < values.length; + XPCOM.memmove (_retval, new int[] {more ? 1 : 0}, 4); /*PRBool */ + return XPCOM.NS_OK; +} + +int GetNext (int /*long*/ _retval) { + if (values is null || index is values.length) return XPCOM.NS_ERROR_UNEXPECTED; + nsISupports value = values[index++]; + value.AddRef (); + XPCOM.memmove (_retval, new int /*long*/[] {value.getAddress ()}, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/StatusTextEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/StatusTextEvent.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 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 + *******************************************************************************/ +module dwt.browser.StatusTextEvent; + +import dwt.dwthelper.utils; + +import dwt.events.TypedEvent; +import dwt.widgets.Widget; + +/** + * A <code>StatusTextEvent</code> is sent by a {@link Browser} to + * {@link StatusTextListener}'s when the status text is changed. + * The status text is typically displayed in the status bar of + * a browser application. + * + * @since 3.0 + */ +public class StatusTextEvent extends TypedEvent { + /** status text */ + public String text; + + static final long serialVersionUID = 3258407348371600439L; + +StatusTextEvent(Widget w) { + super(w); +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public String toString() { + String string = super.toString (); + return string.substring (0, string.length() - 1) // remove trailing '}' + + " text=" + text + + "}"; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/StatusTextListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/StatusTextListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2003, 2005 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 + *******************************************************************************/ +module dwt.browser.StatusTextListener; + +import dwt.dwthelper.utils; + +import dwt.internal.DWTEventListener; + +/** + * This listener interface may be implemented in order to receive + * a {@link StatusTextEvent} notification when the status text for + * a {@link Browser} is changed. + * + * @see Browser#addStatusTextListener(StatusTextListener) + * @see Browser#removeStatusTextListener(StatusTextListener) + * + * @since 3.0 + */ +public interface StatusTextListener extends DWTEventListener { + +/** + * This method is called when the status text is changed. The + * status text is typically displayed in the status bar of a browser + * application. + * <p> + * + * <p>The following fields in the <code>StatusTextEvent</code> apply: + * <ul> + * <li>(in) text the modified status text + * <li>(in) widget the <code>Browser</code> whose status text is changed + * </ul> + * + * @param event the <code>StatusTextEvent</code> that contains the updated + * status description of a <code>Browser</code> + * + * @since 3.0 + */ +public void changed(StatusTextEvent event); +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/TitleEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/TitleEvent.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 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 + *******************************************************************************/ +module dwt.browser.TitleEvent; + +import dwt.dwthelper.utils; + +import dwt.events.TypedEvent; +import dwt.widgets.Widget; + +/** + * A <code>TitleEvent</code> is sent by a {@link Browser} to + * {@link TitleListener}'s when the title of the current document + * is available or when it is modified. + * + * @since 3.0 + */ +public class TitleEvent extends TypedEvent { + /** the title of the current document */ + public String title; + + static final long serialVersionUID = 4121132532906340919L; + +TitleEvent(Widget w) { + super(w); +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ +public String toString() { + String string = super.toString (); + return string.substring (0, string.length() - 1) // remove trailing '}' + + " title=" + title + + "}"; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/TitleListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/TitleListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 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 + *******************************************************************************/ +module dwt.browser.TitleListener; + +import dwt.dwthelper.utils; + +import dwt.internal.DWTEventListener; + +/** + * This listener interface may be implemented in order to receive + * a {@link TitleEvent} notification when the title of the document + * displayed in a {@link Browser} is known or has been changed. + * + * @see Browser#addTitleListener(TitleListener) + * @see Browser#removeTitleListener(TitleListener) + * + * @since 3.0 + */ +public interface TitleListener extends DWTEventListener { + +/** + * This method is called when the title of the current document + * is available or has changed. + * <p> + * + * <p>The following fields in the <code>TitleEvent</code> apply: + * <ul> + * <li>(in) title the title of the current document + * <li>(in) widget the <code>Browser</code> whose current document's + * title is known or modified + * </ul> + * + * @param event the <code>TitleEvent</code> that contains the title + * of the document currently displayed in a <code>Browser</code> + * + * @since 3.0 + */ +public void changed(TitleEvent event); +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/VisibilityWindowAdapter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/VisibilityWindowAdapter.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2003, 2004 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 + *******************************************************************************/ +module dwt.browser.VisibilityWindowAdapter; + +import dwt.dwthelper.utils; + +/** + * This adapter class provides default implementations for the + * methods described by the {@link VisibilityWindowListener} interface. + * <p> + * Classes that wish to deal with {@link WindowEvent}'s can + * extend this class and override only the methods which they are + * interested in. + * </p> + * + * @since 3.0 + */ +public abstract class VisibilityWindowAdapter implements VisibilityWindowListener { + +public void hide(WindowEvent event) { +} + +public void show(WindowEvent event) { +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/VisibilityWindowListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/VisibilityWindowListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.VisibilityWindowListener; + +import dwt.dwthelper.utils; + +import dwt.internal.DWTEventListener; + +/** + * This listener interface may be implemented in order to receive + * a {@link WindowEvent} notification when a window hosting a + * {@link Browser} needs to be displayed or hidden. + * + * @see Browser#addVisibilityWindowListener(VisibilityWindowListener) + * @see Browser#removeVisibilityWindowListener(VisibilityWindowListener) + * @see OpenWindowListener + * @see CloseWindowListener + * + * @since 3.0 + */ +public interface VisibilityWindowListener extends DWTEventListener { + +/** + * This method is called when the window hosting a <code>Browser</code> + * is requested to be hidden. Application would typically hide the + * {@link dwt.widgets.Shell} that hosts the <code>Browser</code>. + * <p> + * + * <p>The following fields in the <code>WindowEvent</code> apply: + * <ul> + * <li>(in) widget the <code>Browser</code> that needs to be hidden + * </ul> + * + * @param event the <code>WindowEvent</code> that specifies the + * <code>Browser</code> that needs to be hidden + * + * @see dwt.widgets.Shell#setVisible(bool) + * + * @since 3.0 + */ +public void hide(WindowEvent event); + +/** + * This method is called when the window hosting a <code>Browser</code> + * is requested to be displayed. Application would typically set the + * location and the size of the {@link dwt.widgets.Shell} + * that hosts the <code>Browser</code>, if a particular location and size + * are specified. The application would then open that <code>Shell</code>. + * <p> + * + * <p>The following fields in the <code>WindowEvent</code> apply: + * <ul> + * <li>(in) widget the <code>Browser</code> to display + * <li>(in) location the requested location for the <code>Shell</code> + * hosting the browser. It is <code>null</code> if no location is set. + * <li>(in) size the requested size for the <code>Browser</code>. + * The client area of the <code>Shell</code> hosting the + * <code>Browser</code> should be large enough to accommodate that size. + * It is <code>null</code> if no size is set. + * <li>(in) addressBar <code>true</code> if the <code>Shell</code> + * hosting the <code>Browser</code> should display an address bar or + * <code>false</code> otherwise + * <li>(in) menuBar <code>true</code> if the <code>Shell</code> + * hosting the <code>Browser</code> should display a menu bar or + * <code>false</code> otherwise + * <li>(in) statusBar <code>true</code> if the <code>Shell</code> + * hosting the <code>Browser</code> should display a status bar or + * <code>false</code> otherwise + * <li>(in) toolBar <code>true</code> if the <code>Shell</code> + * hosting the <code>Browser</code> should display a tool bar or + * <code>false</code> otherwise + * </ul> + * + * @param event the <code>WindowEvent</code> that specifies the + * <code>Browser</code> that needs to be displayed + * + * @see dwt.widgets.Control#setLocation(dwt.graphics.Point) + * @see dwt.widgets.Control#setSize(dwt.graphics.Point) + * @see dwt.widgets.Shell#open() + * + * @since 3.0 + */ +public void show(WindowEvent event); + +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/WebBrowser.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/WebBrowser.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,403 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + *******************************************************************************/ +module dwt.browser.WebBrowser; + +import dwt.dwthelper.utils; + +import dwt.DWT; +import dwt.widgets.Composite; + +abstract class WebBrowser { + Browser browser; + CloseWindowListener[] closeWindowListeners = new CloseWindowListener[0]; + LocationListener[] locationListeners = new LocationListener[0]; + OpenWindowListener[] openWindowListeners = new OpenWindowListener[0]; + ProgressListener[] progressListeners = new ProgressListener[0]; + StatusTextListener[] statusTextListeners = new StatusTextListener[0]; + TitleListener[] titleListeners = new TitleListener[0]; + VisibilityWindowListener[] visibilityWindowListeners = new VisibilityWindowListener[0]; + + static Runnable MozillaClearSessions; + static Runnable NativeClearSessions; + + /* Key Mappings */ + static final int [][] KeyTable = { + /* Keyboard and Mouse Masks */ + {18, DWT.ALT}, + {16, DWT.SHIFT}, + {17, DWT.CONTROL}, + {224, DWT.COMMAND}, + + /* Literal Keys */ + {65, 'a'}, + {66, 'b'}, + {67, 'c'}, + {68, 'd'}, + {69, 'e'}, + {70, 'f'}, + {71, 'g'}, + {72, 'h'}, + {73, 'i'}, + {74, 'j'}, + {75, 'k'}, + {76, 'l'}, + {77, 'm'}, + {78, 'n'}, + {79, 'o'}, + {80, 'p'}, + {81, 'q'}, + {82, 'r'}, + {83, 's'}, + {84, 't'}, + {85, 'u'}, + {86, 'v'}, + {87, 'w'}, + {88, 'x'}, + {89, 'y'}, + {90, 'z'}, + {48, '0'}, + {49, '1'}, + {50, '2'}, + {51, '3'}, + {52, '4'}, + {53, '5'}, + {54, '6'}, + {55, '7'}, + {56, '8'}, + {57, '9'}, + {32, ' '}, + {59, ';'}, + {61, '='}, + {188, ','}, + {190, '.'}, + {191, '/'}, + {219, '['}, + {221, ']'}, + {222, '\''}, + {192, '`'}, + {220, '\\'}, + {108, '|'}, + + /* Non-Numeric Keypad Keys */ + {37, DWT.ARROW_LEFT}, + {39, DWT.ARROW_RIGHT}, + {38, DWT.ARROW_UP}, + {40, DWT.ARROW_DOWN}, + {45, DWT.INSERT}, + {36, DWT.HOME}, + {35, DWT.END}, + {46, DWT.DEL}, + {33, DWT.PAGE_UP}, + {34, DWT.PAGE_DOWN}, + + /* Virtual and Ascii Keys */ + {8, DWT.BS}, + {13, DWT.CR}, + {9, DWT.TAB}, + {27, DWT.ESC}, + {12, DWT.DEL}, + + /* Functions Keys */ + {112, DWT.F1}, + {113, DWT.F2}, + {114, DWT.F3}, + {115, DWT.F4}, + {116, DWT.F5}, + {117, DWT.F6}, + {118, DWT.F7}, + {119, DWT.F8}, + {120, DWT.F9}, + {121, DWT.F10}, + {122, DWT.F11}, + {123, DWT.F12}, + {124, DWT.F13}, + {125, DWT.F14}, + {126, DWT.F15}, + {127, 0}, + {128, 0}, + {129, 0}, + {130, 0}, + {131, 0}, + {132, 0}, + {133, 0}, + {134, 0}, + {135, 0}, + + /* Numeric Keypad Keys */ + {96, DWT.KEYPAD_0}, + {97, DWT.KEYPAD_1}, + {98, DWT.KEYPAD_2}, + {99, DWT.KEYPAD_3}, + {100, DWT.KEYPAD_4}, + {101, DWT.KEYPAD_5}, + {102, DWT.KEYPAD_6}, + {103, DWT.KEYPAD_7}, + {104, DWT.KEYPAD_8}, + {105, DWT.KEYPAD_9}, + {14, DWT.KEYPAD_CR}, + {107, DWT.KEYPAD_ADD}, + {109, DWT.KEYPAD_SUBTRACT}, + {106, DWT.KEYPAD_MULTIPLY}, + {111, DWT.KEYPAD_DIVIDE}, + {110, DWT.KEYPAD_DECIMAL}, + + /* Other keys */ + {20, DWT.CAPS_LOCK}, + {144, DWT.NUM_LOCK}, + {145, DWT.SCROLL_LOCK}, + {44, DWT.PRINT_SCREEN}, + {6, DWT.HELP}, + {19, DWT.PAUSE}, + {3, DWT.BREAK}, + + /* Safari-specific */ + {186, ';'}, + {187, '='}, + {189, '-'}, + }; + +public void addCloseWindowListener (CloseWindowListener listener) { + CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length + 1]; + System.arraycopy(closeWindowListeners, 0, newCloseWindowListeners, 0, closeWindowListeners.length); + closeWindowListeners = newCloseWindowListeners; + closeWindowListeners[closeWindowListeners.length - 1] = listener; +} + +public void addLocationListener (LocationListener listener) { + LocationListener[] newLocationListeners = new LocationListener[locationListeners.length + 1]; + System.arraycopy(locationListeners, 0, newLocationListeners, 0, locationListeners.length); + locationListeners = newLocationListeners; + locationListeners[locationListeners.length - 1] = listener; +} + +public void addOpenWindowListener (OpenWindowListener listener) { + OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length + 1]; + System.arraycopy(openWindowListeners, 0, newOpenWindowListeners, 0, openWindowListeners.length); + openWindowListeners = newOpenWindowListeners; + openWindowListeners[openWindowListeners.length - 1] = listener; +} + +public void addProgressListener (ProgressListener listener) { + ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length + 1]; + System.arraycopy(progressListeners, 0, newProgressListeners, 0, progressListeners.length); + progressListeners = newProgressListeners; + progressListeners[progressListeners.length - 1] = listener; +} + +public void addStatusTextListener (StatusTextListener listener) { + StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length + 1]; + System.arraycopy(statusTextListeners, 0, newStatusTextListeners, 0, statusTextListeners.length); + statusTextListeners = newStatusTextListeners; + statusTextListeners[statusTextListeners.length - 1] = listener; +} + +public void addTitleListener (TitleListener listener) { + TitleListener[] newTitleListeners = new TitleListener[titleListeners.length + 1]; + System.arraycopy(titleListeners, 0, newTitleListeners, 0, titleListeners.length); + titleListeners = newTitleListeners; + titleListeners[titleListeners.length - 1] = listener; +} + +public void addVisibilityWindowListener (VisibilityWindowListener listener) { + VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length + 1]; + System.arraycopy(visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, visibilityWindowListeners.length); + visibilityWindowListeners = newVisibilityWindowListeners; + visibilityWindowListeners[visibilityWindowListeners.length - 1] = listener; +} + +public abstract bool back (); + +public static void clearSessions () { + if (NativeClearSessions !is null) NativeClearSessions.run (); + if (MozillaClearSessions !is null) MozillaClearSessions.run (); +} + +public abstract void create (Composite parent, int style); + +public abstract bool execute (String script); + +public abstract bool forward (); + +public abstract String getText (); + +public abstract String getUrl (); + +public Object getWebBrowser () { + return null; +} + +public abstract bool isBackEnabled (); + +public bool isFocusControl () { + return false; +} + +public abstract bool isForwardEnabled (); + +public abstract void refresh (); + +public void removeCloseWindowListener (CloseWindowListener listener) { + if (closeWindowListeners.length is 0) return; + int index = -1; + for (int i = 0; i < closeWindowListeners.length; i++) { + if (listener is closeWindowListeners[i]){ + index = i; + break; + } + } + if (index is -1) return; + if (closeWindowListeners.length is 1) { + closeWindowListeners = new CloseWindowListener[0]; + return; + } + CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length - 1]; + System.arraycopy (closeWindowListeners, 0, newCloseWindowListeners, 0, index); + System.arraycopy (closeWindowListeners, index + 1, newCloseWindowListeners, index, closeWindowListeners.length - index - 1); + closeWindowListeners = newCloseWindowListeners; +} + +public void removeLocationListener (LocationListener listener) { + if (locationListeners.length is 0) return; + int index = -1; + for (int i = 0; i < locationListeners.length; i++) { + if (listener is locationListeners[i]){ + index = i; + break; + } + } + if (index is -1) return; + if (locationListeners.length is 1) { + locationListeners = new LocationListener[0]; + return; + } + LocationListener[] newLocationListeners = new LocationListener[locationListeners.length - 1]; + System.arraycopy (locationListeners, 0, newLocationListeners, 0, index); + System.arraycopy (locationListeners, index + 1, newLocationListeners, index, locationListeners.length - index - 1); + locationListeners = newLocationListeners; +} + +public void removeOpenWindowListener (OpenWindowListener listener) { + if (openWindowListeners.length is 0) return; + int index = -1; + for (int i = 0; i < openWindowListeners.length; i++) { + if (listener is openWindowListeners[i]){ + index = i; + break; + } + } + if (index is -1) return; + if (openWindowListeners.length is 1) { + openWindowListeners = new OpenWindowListener[0]; + return; + } + OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length - 1]; + System.arraycopy (openWindowListeners, 0, newOpenWindowListeners, 0, index); + System.arraycopy (openWindowListeners, index + 1, newOpenWindowListeners, index, openWindowListeners.length - index - 1); + openWindowListeners = newOpenWindowListeners; +} + +public void removeProgressListener (ProgressListener listener) { + if (progressListeners.length is 0) return; + int index = -1; + for (int i = 0; i < progressListeners.length; i++) { + if (listener is progressListeners[i]){ + index = i; + break; + } + } + if (index is -1) return; + if (progressListeners.length is 1) { + progressListeners = new ProgressListener[0]; + return; + } + ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length - 1]; + System.arraycopy (progressListeners, 0, newProgressListeners, 0, index); + System.arraycopy (progressListeners, index + 1, newProgressListeners, index, progressListeners.length - index - 1); + progressListeners = newProgressListeners; +} + +public void removeStatusTextListener (StatusTextListener listener) { + if (statusTextListeners.length is 0) return; + int index = -1; + for (int i = 0; i < statusTextListeners.length; i++) { + if (listener is statusTextListeners[i]){ + index = i; + break; + } + } + if (index is -1) return; + if (statusTextListeners.length is 1) { + statusTextListeners = new StatusTextListener[0]; + return; + } + StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length - 1]; + System.arraycopy (statusTextListeners, 0, newStatusTextListeners, 0, index); + System.arraycopy (statusTextListeners, index + 1, newStatusTextListeners, index, statusTextListeners.length - index - 1); + statusTextListeners = newStatusTextListeners; +} + +public void removeTitleListener (TitleListener listener) { + if (titleListeners.length is 0) return; + int index = -1; + for (int i = 0; i < titleListeners.length; i++) { + if (listener is titleListeners[i]){ + index = i; + break; + } + } + if (index is -1) return; + if (titleListeners.length is 1) { + titleListeners = new TitleListener[0]; + return; + } + TitleListener[] newTitleListeners = new TitleListener[titleListeners.length - 1]; + System.arraycopy (titleListeners, 0, newTitleListeners, 0, index); + System.arraycopy (titleListeners, index + 1, newTitleListeners, index, titleListeners.length - index - 1); + titleListeners = newTitleListeners; +} + +public void removeVisibilityWindowListener (VisibilityWindowListener listener) { + if (visibilityWindowListeners.length is 0) return; + int index = -1; + for (int i = 0; i < visibilityWindowListeners.length; i++) { + if (listener is visibilityWindowListeners[i]){ + index = i; + break; + } + } + if (index is -1) return; + if (visibilityWindowListeners.length is 1) { + visibilityWindowListeners = new VisibilityWindowListener[0]; + return; + } + VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length - 1]; + System.arraycopy (visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, index); + System.arraycopy (visibilityWindowListeners, index + 1, newVisibilityWindowListeners, index, visibilityWindowListeners.length - index - 1); + visibilityWindowListeners = newVisibilityWindowListeners; +} + +public void setBrowser (Browser browser) { + this.browser = browser; +} + +public abstract bool setText (String html); + +public abstract bool setUrl (String url); + +public abstract void stop (); + +int translateKey (int key) { + for (int i = 0; i < KeyTable.length; i++) { + if (KeyTable[i][0] is key) return KeyTable[i][1]; + } + return 0; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/WindowCreator2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/WindowCreator2.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,239 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + * Port to the D programming language: + * John Reimer <terminal.node@gmail.com> + *******************************************************************************/ +module dwt.browser.WindowCreator2; + +import dwt.dwthelper.utils; + +import dwt.internal.Platform; + +import dwt.internal.mozilla.XPCOM; +import dwt.internal.mozilla.nsIBaseWindow; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIWebBrowser; +import dwt.internal.mozilla.nsIWebBrowserChrome; +import dwt.internal.mozilla.nsIWindowCreator; + +import dwt.DWT; +import dwt.graphics.Point; +import dwt.layout.FillLayout; +import dwt.widgets.Shell; + +class WindowCreator2 { + XPCOMObject supports; + XPCOMObject windowCreator; + XPCOMObject windowCreator2; + int refCount = 0; + +WindowCreator2 () { + createCOMInterfaces (); +} + +int AddRef () { + refCount++; + return refCount; +} + +void createCOMInterfaces () { + /* Create each of the interfaces that this object implements */ + supports = new XPCOMObject (new int[] {2, 0, 0}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + }; + + windowCreator = new XPCOMObject (new int[] {2, 0, 0, 3}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return CreateChromeWindow (args[0], (int)/*64*/args[1], args[2]);} + }; + + windowCreator2 = new XPCOMObject (new int[] {2, 0, 0, 3, 6}) { + public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} + public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} + public int /*long*/ method2 (int /*long*/[] args) {return Release ();} + public int /*long*/ method3 (int /*long*/[] args) {return CreateChromeWindow (args[0], (int)/*64*/args[1], args[2]);} + public int /*long*/ method4 (int /*long*/[] args) {return CreateChromeWindow2 (args[0], (int)/*64*/args[1], (int)/*64*/args[2], args[3], args[4], args[5]);} + }; +} + +void disposeCOMInterfaces () { + if (supports !is null) { + supports.dispose (); + supports = null; + } + if (windowCreator !is null) { + windowCreator.dispose (); + windowCreator = null; + } + + if (windowCreator2 !is null) { + windowCreator2.dispose (); + windowCreator2 = null; + } +} + +int /*long*/ getAddress () { + return windowCreator.getAddress (); +} + +int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { + if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE; + nsID guid = new nsID (); + XPCOM.memmove (guid, riid, nsID.sizeof); + + if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIWindowCreator.NS_IWINDOWCREATOR_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {windowCreator.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + if (guid.Equals (nsIWindowCreator2.NS_IWINDOWCREATOR2_IID)) { + XPCOM.memmove (ppvObject, new int /*long*/[] {windowCreator2.getAddress ()}, C.PTR_SIZEOF); + AddRef (); + return XPCOM.NS_OK; + } + + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); + return XPCOM.NS_ERROR_NO_INTERFACE; +} + +int Release () { + refCount--; + if (refCount is 0) disposeCOMInterfaces (); + return refCount; +} + +/* nsIWindowCreator */ + +int CreateChromeWindow (int /*long*/ parent, int chromeFlags, int /*long*/ _retval) { + return CreateChromeWindow2 (parent, chromeFlags, 0, 0, 0, _retval); +} + +/* nsIWindowCreator2 */ + +int CreateChromeWindow2 (int /*long*/ parent, int chromeFlags, int contextFlags, int /*long*/ uri, int /*long*/ cancel, int /*long*/ _retval) { + if (parent is 0 && (chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) is 0) { + return XPCOM.NS_ERROR_NOT_IMPLEMENTED; + } + Browser src = null; + if (parent !is 0) { + nsIWebBrowserChrome browserChromeParent = new nsIWebBrowserChrome (parent); + int /*long*/[] aWebBrowser = new int /*long*/[1]; + int rc = browserChromeParent.GetWebBrowser (aWebBrowser); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (aWebBrowser[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); + + nsIWebBrowser webBrowser = new nsIWebBrowser (aWebBrowser[0]); + int /*long*/[] result = new int /*long*/[1]; + rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); + webBrowser.Release (); + + nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]); + result[0] = 0; + int /*long*/[] aParentNativeWindow = new int /*long*/[1]; + rc = baseWindow.GetParentNativeWindow (aParentNativeWindow); + if (rc !is XPCOM.NS_OK) Mozilla.error (rc); + if (aParentNativeWindow[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); + baseWindow.Release (); + + src = Mozilla.findBrowser (aParentNativeWindow[0]); + } + final Browser browser; + bool doit = true; + if ((chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) !is 0) { + /* + * Mozilla will request a new Browser in a modal window in order to emulate a native + * dialog that is not available to it (eg.- a print dialog on Linux). For this + * reason modal requests are handled here so that the user is not exposed to them. + */ + int style = DWT.DIALOG_TRIM; + if ((chromeFlags & nsIWebBrowserChrome.CHROME_MODAL) !is 0) style |= DWT.APPLICATION_MODAL; + final Shell shell = src is null ? + new Shell (style) : + new Shell (src.getShell(), style); + shell.setLayout (new FillLayout ()); + browser = new Browser (shell, src is null ? DWT.MOZILLA : src.getStyle () & DWT.MOZILLA); + browser.addVisibilityWindowListener (new VisibilityWindowListener () { + public void hide (WindowEvent event) { + } + public void show (WindowEvent event) { + if (event.location !is null) shell.setLocation (event.location); + if (event.size !is null) { + Point size = event.size; + shell.setSize (shell.computeSize (size.x, size.y)); + } + shell.open (); + } + }); + browser.addCloseWindowListener (new CloseWindowListener () { + public void close (WindowEvent event) { + shell.close (); + } + }); + if (uri !is 0) { + nsIURI location = new nsIURI (uri); + int /*long*/ aSpec = XPCOM.nsEmbedCString_new (); + if (location.GetSpec (aSpec) is XPCOM.NS_OK) { + int length = XPCOM.nsEmbedCString_Length (aSpec); + if (length > 0) { + int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec); + byte[] dest = new byte[length]; + XPCOM.memmove (dest, buffer, length); + browser.setUrl (new String (dest)); + } + } + XPCOM.nsEmbedCString_delete (aSpec); + } + } else { + WindowEvent event = new WindowEvent (src); + event.display = src.getDisplay (); + event.widget = src; + event.required = true; + for (int i = 0; i < src.webBrowser.openWindowListeners.length; i++) { + src.webBrowser.openWindowListeners[i].open (event); + } + browser = event.browser; + + /* Ensure that the Browser provided by the client is valid for use */ + doit = browser !is null && !browser.isDisposed (); + if (doit) { + String platform = Platform.PLATFORM; + bool isMozillaNativePlatform = platform.equals ("gtk") || platform.equals ("motif"); //$NON-NLS-1$ //$NON-NLS-2$ + doit = isMozillaNativePlatform || (browser.getStyle () & DWT.MOZILLA) !is 0; + } + } + if (doit) { + Mozilla mozilla = (Mozilla)browser.webBrowser; + mozilla.isChild = true; + int /*long*/ chromePtr = mozilla.webBrowserChrome.getAddress (); + nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (chromePtr); + webBrowserChrome.SetChromeFlags (chromeFlags); + webBrowserChrome.AddRef (); + XPCOM.memmove (_retval, new int /*long*/[] {chromePtr}, C.PTR_SIZEOF); + } else { + if (cancel !is 0) { + C.memmove (cancel, new int[] {1}, 4); /* PRBool */ + } + } + return doit ? XPCOM.NS_OK : XPCOM.NS_ERROR_NOT_IMPLEMENTED; +} +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser.old/WindowEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser.old/WindowEvent.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,207 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + * Port to the D programming language: + * John Reimer <terminal.node@gmail.com> + *******************************************************************************/ +module dwt.browser.WindowEvent; + +import dwt.dwthelper.utils; + +import dwt.events.TypedEvent; +import dwt.graphics.Point; +import dwt.widgets.Widget; + +/** + * A <code>WindowEvent</code> is sent by a {@link Browser} when + * a new window needs to be created or when an existing window needs to be + * closed. This notification occurs when a javascript command such as + * <code>window.open</code> or <code>window.close</code> gets executed by + * a <code>Browser</code>. + * + * <p> + * The following example shows how <code>WindowEvent</code>'s are typically + * handled. + * + * <code><pre> + * public static void main(String[] args) { + * Display display = new Display(); + * Shell shell = new Shell(display); + * shell.setText("Main Window"); + * shell.setLayout(new FillLayout()); + * Browser browser = new Browser(shell, DWT.NONE); + * initialize(display, browser); + * shell.open(); + * browser.setUrl("http://www.eclipse.org"); + * while (!shell.isDisposed()) { + * if (!display.readAndDispatch()) + * display.sleep(); + * } + * display.dispose(); + * } + * + * static void initialize(final Display display, Browser browser) { + * browser.addOpenWindowListener(new OpenWindowListener() { + * public void open(WindowEvent event) { + * // Certain platforms can provide a default full browser. + * // simply return in that case if the application prefers + * // the default full browser to the embedded one set below. + * if (!event.required) return; + * + * // Embed the new window + * Shell shell = new Shell(display); + * shell.setText("New Window"); + * shell.setLayout(new FillLayout()); + * Browser browser = new Browser(shell, DWT.NONE); + * initialize(display, browser); + * event.browser = browser; + * } + * }); + * browser.addVisibilityWindowListener(new VisibilityWindowListener() { + * public void hide(WindowEvent event) { + * Browser browser = (Browser)event.widget; + * Shell shell = browser.getShell(); + * shell.setVisible(false); + * } + * public void show(WindowEvent event) { + * Browser browser = (Browser)event.widget; + * Shell shell = browser.getShell(); + * if (event.location !is null) shell.setLocation(event.location); + * if (event.size !is null) { + * Point size = event.size; + * shell.setSize(shell.computeSize(size.x, size.y)); + * } + * if (event.addressBar || event.menuBar || event.statusBar || event.toolBar) { + * // Create widgets for the address bar, menu bar, status bar and/or tool bar + * // leave enough space in the Shell to accommodate a Browser of the size + * // given by event.size + * } + * shell.open(); + * } + * }); + * browser.addCloseWindowListener(new CloseWindowListener() { + * public void close(WindowEvent event) { + * Browser browser = (Browser)event.widget; + * Shell shell = browser.getShell(); + * shell.close(); + * } + * }); + * } + * </pre></code> + * + * The following notifications are emitted when the user selects a hyperlink that targets a new window + * or as the result of a javascript that executes window.open. + * + * <p>Main Browser + * <ul> + * <li>User selects a link that opens in a new window or javascript requests a new window</li> + * <li>OpenWindowListener.open() notified</li> + * <ul> + * <li>Application creates a new Shell and a second Browser inside that Shell</li> + * <li>Application registers WindowListener's on that second Browser, such as VisibilityWindowListener</li> + * <li>Application returns the second Browser as the host for the new window content</li> + * </ul> + * </ul> + * + * <p>Second Browser + * <ul> + * <li>VisibilityWindowListener.show() notified</li> + * <ul> + * <li>Application sets navigation tool bar, status bar, menu bar and Shell size + * <li>Application makes the Shell hosting the second Browser visible + * <li>User now sees the new window + * </ul> + * </ul> + * + * @see CloseWindowListener + * @see OpenWindowListener + * @see VisibilityWindowListener + * + * @since 3.0 + */ + +public class WindowEvent : TypedEvent { + + /** + * Specifies whether the platform requires the user to provide a + * <code>Browser</code> to handle the new window. + * + * @since 3.1 + */ + public bool required; + + + /** + * <code>Browser</code> provided by the application. + */ + public Browser browser; + + /** + * Requested location for the <code>Shell</code> hosting the <code>Browser</code>. + * It is <code>null</code> if no location has been requested. + */ + public Point location; + + /** + * Requested <code>Browser</code> size. The client area of the <code>Shell</code> + * hosting the <code>Browser</code> should be large enough to accommodate that size. + * It is <code>null</code> if no size has been requested. + */ + public Point size; + + /** + * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should + * display an address bar. + * + * @since 3.1 + */ + public bool addressBar; + + /** + * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should + * display a menu bar. + * + * @since 3.1 + */ + public bool menuBar; + + /** + * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should + * display a status bar. + * + * @since 3.1 + */ + public bool statusBar; + + /** + * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should + * display a tool bar. + * + * @since 3.1 + */ + public bool toolBar; + + static final long serialVersionUID = 3617851997387174969L; + + this(Widget w) { + super(w); + } + + /** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the event + */ + + public override String toString () { + return Format( "WindowEvent {required={} browser={} location={} size={} addressBar={} menuBar={} statusBar={} toolBar={} }", + required, browser, location, size, addressBar, menuBar, statusBar, tooBar ); + } +} diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser/LocationEvent.d --- a/dwt/browser/LocationEvent.d Tue Aug 05 10:12:22 2008 -0700 +++ b/dwt/browser/LocationEvent.d Tue Aug 05 18:00:50 2008 -0700 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * John Reimer <terminal.node@gmail.com> *******************************************************************************/ module dwt.browser.LocationEvent; @@ -25,7 +27,7 @@ * * @since 3.0 */ -public class LocationEvent extends TypedEvent { +public class LocationEvent : TypedEvent { /** current location */ public String location; @@ -53,12 +55,8 @@ * * @return a string representation of the event */ -public String toString() { - String string = super.toString (); - return string.substring (0, string.length() - 1) // remove trailing '}' - + " location=" + location - + " top=" + top - + " doit=" + doit - + "}"; +public override String toString() { + return Format( "{} {location = {}, top = {}, doit = {}}", + super.toString[1 .. $-2], location, top, doit ); } } diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser/PromptDialog.d --- a/dwt/browser/PromptDialog.d Tue Aug 05 10:12:22 2008 -0700 +++ b/dwt/browser/PromptDialog.d Tue Aug 05 18:00:50 2008 -0700 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * John Reimer <terminal.node@gmail.com> *******************************************************************************/ module dwt.browser.PromptDialog; @@ -27,19 +29,19 @@ import dwt.widgets.Text; import dwt.widgets.Widget; -class PromptDialog extends Dialog { +class PromptDialog : Dialog { - PromptDialog(Shell parent, int style) { + this(Shell parent, int style) { super(parent, style); } - PromptDialog(Shell parent) { + this(Shell parent) { this(parent, 0); } - void alertCheck(String title, String text, String check, final int[] checkValue) { + void alertCheck(String title, String text, String check, /* final */ int[] checkValue) { Shell parent = getParent(); - final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); + /* final */ Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); if (title !is null) shell.setText(title); GridLayout gridLayout = new GridLayout(); shell.setLayout(gridLayout); @@ -82,9 +84,9 @@ } } - void confirmEx(String title, String text, String check, String button0, String button1, String button2, int defaultIndex, final int[] checkValue, final int[] result) { + void confirmEx(String title, String text, String check, String button0, String button1, String button2, int defaultIndex, /* final */ int[] checkValue, /* final */ int[] result) { Shell parent = getParent(); - final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); + /* final */ Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); shell.setText(title); GridLayout gridLayout = new GridLayout(); shell.setLayout(gridLayout); @@ -162,9 +164,9 @@ } } - void prompt(String title, String text, String check, final String[] value, final int[] checkValue, final int[] result) { + void prompt(String title, String text, String check, /* final */ String[] value, /* final */ int[] checkValue, /* final */ int[] result) { Shell parent = getParent(); - final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); + /* final */ Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); if (title !is null) shell.setText(title); GridLayout gridLayout = new GridLayout(); shell.setLayout(gridLayout); @@ -227,9 +229,9 @@ } } - void promptUsernameAndPassword(String title, String text, String check, final String[] user, final String[] pass, final int[] checkValue, final int[] result) { + void promptUsernameAndPassword(String title, String text, String check, /* final */ String[] user, /* final */ String[] pass, /* final */ int[] checkValue, /* final */ int[] result) { Shell parent = getParent(); - final Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); + /* final */ Shell shell = new Shell(parent, DWT.DIALOG_TRIM | DWT.APPLICATION_MODAL); shell.setText(title); GridLayout gridLayout = new GridLayout(); shell.setLayout(gridLayout); diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/browser/WindowEvent.d --- a/dwt/browser/WindowEvent.d Tue Aug 05 10:12:22 2008 -0700 +++ b/dwt/browser/WindowEvent.d Tue Aug 05 18:00:50 2008 -0700 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * John Reimer <terminal.node@gmail.com> *******************************************************************************/ module dwt.browser.WindowEvent; @@ -123,7 +125,7 @@ * * @since 3.0 */ -public class WindowEvent extends TypedEvent { +public class WindowEvent : TypedEvent { /** * Specifies whether the platform requires the user to provide a @@ -196,17 +198,12 @@ * * @return a string representation of the event */ + public String toString() { - String string = super.toString (); - return string.substring (0, string.length() - 1) // remove trailing '}' - + " required=" + required - + " browser=" + browser - + " location=" + location - + " size=" + size - + " addressBar=" + addressBar - + " menuBar=" + menuBar - + " statusBar=" + statusBar - + " toolBar=" + toolBar - + "}"; + return Format( "{} {required = {}, browser = {}, location = {}, size = {}, addressbar = {}, menubar = {}, statusbar = {}, toobar = {}}", + super.toString[1 .. $-2], + required, browser, + location, size, addressbar, + menubar, statusbar, toolbar ); } } diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/Common.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/Common.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,105 @@ +module dwt.internal.mozilla.Common; + +version(Windows) { + const NS_WIN32 = 1; +} +version(linux) { + const NS_UNIX = 1; +} + +alias uint nsresult; +alias uint nsrefcnt; + +const nsnull = 0; + +/****************************************************************************** + + prtypes + +******************************************************************************/ + +extern (System): + +alias ubyte PRUint8; +alias byte PRInt8; + +const PR_INT8_MAX = 127; +const PR_UINT8_MAX = 255U; + +alias ushort PRUint16; +alias short PRInt16; + +const PR_INT16_MAX = 32767; +const PR_UINT16_MAX = 65535U; + +alias uint PRUint32; +alias int PRInt32; + +alias long PRInt64; +alias ulong PRUint64; + +alias int PRIntn; +alias uint PRUintn; + +alias double PRFloat64; +alias size_t PRSize; + +alias PRInt32 PROffset32; +alias PRInt64 PROffset64; + +alias ptrdiff_t PRPtrdiff; +alias uint PRUptrdiff; + +alias PRIntn PRBool; + +const PR_TRUE = 1; +const PR_FALSE = 0; + +alias PRUint8 PRPackedBool; + +enum +{ + PR_FAILURE = -1, + PR_SUCCESS, +} + +alias int PRStatus; + +alias wchar PRUnichar; + +alias int PRWord; +alias uint PRUword; + +/****************************************************************************** + + nscommon + +******************************************************************************/ + +alias void* nsIWidget; +alias void* nsILayoutHistoryState; +alias void* nsIDeviceContext; +alias void* nsPresContext; +alias void* nsEvent; +alias void* nsEventStatus; +alias void* nsIPresShell; +alias void* JSContext; + +alias void* PRThread; +alias void* PLEvent; +alias void* PLEventQueue; +alias void* PLHandleEventProc; +alias void* PLDestroyEventProc; + +/****************************************************************************** + + gfxtypes + +******************************************************************************/ + +alias PRUint32 gfx_color; +alias PRUint16 gfx_depth; +alias PRInt32 gfx_format; + +alias void* nsIntRect; +alias void* nsRect; \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/gfxIImageFrame.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/gfxIImageFrame.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,51 @@ +module dwt.internal.mozilla.gfxIImageFrame; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] GFXIIMAGEFRAME_IID_STR = "f6d00ee7-defc-4101-b2dc-e72cf4c37c3c"; + +const nsIID GFXIIMAGEFRAME_IID= + {0xf6d00ee7, 0xdefc, 0x4101, + [ 0xb2, 0xdc, 0xe7, 0x2c, 0xf4, 0xc3, 0x7c, 0x3c ]}; + +extern(System) + +interface gfxIImageFrame : nsISupports { + + static const char[] IID_STR = GFXIIMAGEFRAME_IID_STR; + static const nsIID IID = GFXIIMAGEFRAME_IID; + + nsresult Init(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, gfx_format aFormat, gfx_depth aDepth); + nsresult GetMutable(PRBool *aMutable); + nsresult SetMutable(PRBool aMutable); + nsresult GetX(PRInt32 *aX); + nsresult GetY(PRInt32 *aY); + nsresult GetWidth(PRInt32 *aWidth); + nsresult GetHeight(PRInt32 *aHeight); + nsresult GetRect(nsIntRect * rect); + nsresult GetFormat(gfx_format *aFormat); + nsresult GetNeedsBackground(PRBool *aNeedsBackground); + nsresult GetImageBytesPerRow(PRUint32 *aImageBytesPerRow); + nsresult GetImageDataLength(PRUint32 *aImageDataLength); + nsresult GetImageData(PRUint8 **bits, PRUint32 *length); + nsresult SetImageData(PRUint8 *data, PRUint32 length, PRInt32 offset); + nsresult LockImageData(); + nsresult UnlockImageData(); + nsresult GetAlphaBytesPerRow(PRUint32 *aAlphaBytesPerRow); + nsresult GetAlphaDataLength(PRUint32 *aAlphaDataLength); + nsresult GetAlphaData(PRUint8 **bits, PRUint32 *length); + nsresult SetAlphaData(PRUint8 *data, PRUint32 length, PRInt32 offset); + nsresult LockAlphaData(); + nsresult UnlockAlphaData(); + nsresult DrawTo(gfxIImageFrame aDst, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight); + nsresult GetTimeout(PRInt32 *aTimeout); + nsresult SetTimeout(PRInt32 aTimeout); + nsresult GetFrameDisposalMethod(PRInt32 *aFrameDisposalMethod); + nsresult SetFrameDisposalMethod(PRInt32 aFrameDisposalMethod); + nsresult GetBackgroundColor(gfx_color *aBackgroundColor); + nsresult SetBackgroundColor(gfx_color aBackgroundColor); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/imgIContainer.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/imgIContainer.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,49 @@ +module dwt.internal.mozilla.imgIContainer; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.gfxIImageFrame; +import dwt.internal.mozilla.imgIContainerObserver; + +const char[] IMGICONTAINER_IID_STR = "1a6290e6-8285-4e10-963d-d001f8d327b8"; + +const nsIID IMGICONTAINER_IID= + {0x1a6290e6, 0x8285, 0x4e10, + [ 0x96, 0x3d, 0xd0, 0x01, 0xf8, 0xd3, 0x27, 0xb8 ]}; + +extern(System) + +interface imgIContainer : nsISupports { + + static const char[] IID_STR = IMGICONTAINER_IID_STR; + static const nsIID IID = IMGICONTAINER_IID; + + nsresult Init(PRInt32 aWidth, PRInt32 aHeight, imgIContainerObserver aObserver); + nsresult GetPreferredAlphaChannelFormat(gfx_format *aPreferredAlphaChannelFormat); + nsresult GetWidth(PRInt32 *aWidth); + nsresult GetHeight(PRInt32 *aHeight); + nsresult GetCurrentFrame(gfxIImageFrame *aCurrentFrame); + nsresult GetNumFrames(PRUint32 *aNumFrames); + + enum { kNormalAnimMode = 0 }; + enum { kDontAnimMode = 1 }; + enum { kLoopOnceAnimMode = 2 }; + + nsresult GetAnimationMode(PRUint16 *aAnimationMode); + nsresult SetAnimationMode(PRUint16 aAnimationMode); + nsresult GetFrameAt(PRUint32 index, gfxIImageFrame *_retval); + nsresult AppendFrame(gfxIImageFrame item); + nsresult RemoveFrame(gfxIImageFrame item); + nsresult EndFrameDecode(PRUint32 framenumber, PRUint32 timeout); + nsresult DecodingComplete(); + nsresult Clear(); + nsresult StartAnimation(); + nsresult StopAnimation(); + nsresult ResetAnimation(); + nsresult GetLoopCount(PRInt32 *aLoopCount); + nsresult SetLoopCount(PRInt32 aLoopCount); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/imgIContainerObserver.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/imgIContainerObserver.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,26 @@ +module dwt.internal.mozilla.imgIContainerObserver; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.imgIContainer; +import dwt.internal.mozilla.gfxIImageFrame; + +const char[] IMGICONTAINEROBSERVER_IID_STR = "53102f15-0f53-4939-957e-aea353ad2700"; + +const nsIID IMGICONTAINEROBSERVER_IID= + {0x53102f15, 0x0f53, 0x4939, + [ 0x95, 0x7e, 0xae, 0xa3, 0x53, 0xad, 0x27, 0x00 ]}; + +extern(System) + +interface imgIContainerObserver : nsISupports { + + static const char[] IID_STR = IMGICONTAINEROBSERVER_IID_STR; + static const nsIID IID = IMGICONTAINEROBSERVER_IID; + + nsresult FrameChanged(imgIContainer aContainer, gfxIImageFrame aFrame, nsIntRect * aDirtyRect); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsEmbedString.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsEmbedString.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,99 @@ +/* ***** 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 DWT + * - Copyright (C) 2004 IBM Corp. All Rights Reserved. + * + * Port to the D programming language: + * John Reimer <terminal.node@gmail.com> + * + * ***** END LICENSE BLOCK ***** */ + +module dwt.internal.mozilla.nsEmbedString; + +import dwt.dwthelper.utils; +import dwt.internal.mozilla.nsStringAPI; + +public class nsEmbedString +{ + int /*long*/ handle; + + /************************************************************************** + + **************************************************************************/ + + public this() + { + handle = XPCOM.nsEmbedString_new(); + } + + /************************************************************************** + + **************************************************************************/ + + public nsEmbedString(String string) + { + if (string !is null) + { + char[] aString = new char[string.length() + 1]; + string.getChars(0, string.length(), aString, 0); + handle = XPCOM.nsEmbedString_new(aString); + } + } + + /************************************************************************** + + **************************************************************************/ + + public int /*long*/ getAddress() + { + return handle; + } + + /************************************************************************** + + **************************************************************************/ + + public String toString() + { + if (handle is 0) + return null; + int length = XPCOM.nsEmbedString_Length(handle); + int /*long*/ buffer = XPCOM.nsEmbedString_get(handle); + char[] dest = new char[length]; + XPCOM.memmove(dest, buffer, length * 2); + return new String(dest); + } + + /************************************************************************** + + **************************************************************************/ + + public void dispose() + { + if (handle is 0) + return; + XPCOM.nsEmbedString_delete(handle); + handle = 0; + } +} \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsEmbedString2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsEmbedString2.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,86 @@ +module dwt.internal.mozilla.nsEmbedString; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsStringAPI; + +class nsEmbedString +{ + this(wchar[] s) + { + nsresult result; + result = NS_StringContainerInit2(&str, s.ptr, s.length, 0); + if (result != 0) // TODO: convert to XPCOM fail macro + throw new Exception("Init string container fail"); + } + + this() + { + nsresult result; + result = NS_StringContainerInit(&str); + if (result != 0) // TODO: convert to XPCOM fail macro + throw new Exception("Init string container fail"); + } + + nsAString* opCast() + { + return cast(nsAString*)&str; + } + + wchar[] toString16() + { + wchar* buffer = null; + PRBool terminated; + uint len = NS_StringGetData(cast(nsAString*)&str, &buffer, &terminated); + wchar[] result = buffer[0 .. len].dup; + return result; + } + + ~this() + { + NS_StringContainerFinish(&str); + } +private: + nsStringContainer str; +} + + +class nsEmbedCString +{ + this(char[] s) + { + nsresult result; + result = NS_CStringContainerInit2(&str, s.ptr, s.length, 0); + if (result != 0) // TODO: convert to XPCOM fail macro + throw new Exception("Init string container fail"); + } + + this() + { + nsresult result; + result = NS_CStringContainerInit(&str); + if (result != 0) // TODO: convert to XPCOM fail macro + throw new Exception("Init string container fail"); + } + + nsACString* opCast() + { + return cast(nsACString*)&str; + } + + char[] toString() + { + char* buffer = null; + PRBool terminated; + uint len = NS_CStringGetData(cast(nsACString*)&str, &buffer, &terminated); + char[] result = buffer[0 .. len].dup; + return result; + } + + ~this() + { + NS_CStringContainerFinish(&str); + } +private: + nsCStringContainer str; +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsError.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsError.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,67 @@ +module dwt.internal.mozilla.nsError; + +import dwt.internal.mozilla.Common; + +/** + * @name Standard Module Offset Code. Each Module should identify a unique number + * and then all errors associated with that module become offsets from the + * base associated with that module id. There are 16 bits of code bits for + * each module. + */ + +enum { + NS_ERROR_MODULE_XPCOM = 1, + NS_ERROR_MODULE_BASE = 2, + NS_ERROR_MODULE_GFX = 3, + NS_ERROR_MODULE_WIDGET = 4, + NS_ERROR_MODULE_CALENDAR = 5, + NS_ERROR_MODULE_NETWORK = 6, + NS_ERROR_MODULE_PLUGINS = 7, + NS_ERROR_MODULE_LAYOUT = 8, + NS_ERROR_MODULE_HTMLPARSER = 9, + NS_ERROR_MODULE_RDF = 10, + NS_ERROR_MODULE_UCONV = 11, + NS_ERROR_MODULE_REG = 12, + NS_ERROR_MODULE_FILES = 13, + NS_ERROR_MODULE_DOM = 14, + NS_ERROR_MODULE_IMGLIB = 15, + NS_ERROR_MODULE_MAILNEWS = 16, + NS_ERROR_MODULE_EDITOR = 17, + NS_ERROR_MODULE_XPCONNECT = 18, + NS_ERROR_MODULE_PROFILE = 19, + NS_ERROR_MODULE_LDAP = 20, + NS_ERROR_MODULE_SECURITY = 21, + NS_ERROR_MODULE_DOM_XPATH = 22, + NS_ERROR_MODULE_DOM_RANGE = 23, + NS_ERROR_MODULE_URILOADER = 24, + NS_ERROR_MODULE_CONTENT = 25, + NS_ERROR_MODULE_PYXPCOM = 26, + NS_ERROR_MODULE_XSLT = 27, + NS_ERROR_MODULE_IPC = 28, + NS_ERROR_MODULE_SVG = 29, + NS_ERROR_MODULE_STORAGE = 30, + NS_ERROR_MODULE_SCHEMA = 31, + NS_ERROR_MODULE_GENERAL = 51, + NS_ERROR_SEVERITY_ERROR = 1, + NS_ERROR_MODULE_BASE_OFFSET = 0x45, +} + +const nsresult NS_OK = cast(nsresult)0; +const nsresult NS_ERROR_BASE = cast(nsresult) 0xC1F30000; +const nsresult NS_ERROR_NOT_INITIALIZED = cast(nsresult)(NS_ERROR_BASE + 1); +const nsresult NS_ERROR_ALREADY_INITIALIZED = cast(nsresult)(NS_ERROR_BASE + 2); +const nsresult NS_NOINTERFACE = cast(nsresult)0x80004002L; + +alias NS_NOINTERFACE NS_ERROR_NO_INTERFACE; + +const nsresult NS_ERROR_INVALID_POINTER = cast(nsresult)0x80004003L; + +alias NS_ERROR_INVALID_POINTER NS_ERROR_NULL_POINTER; + +const nsresult NS_ERROR_ABORT = cast(nsresult)0x80004004L; +const nsresult NS_ERROR_FAILURE = cast(nsresult)0x80004005L; +const nsresult NS_ERROR_UNEXPECTED = cast(nsresult)0x8000ffffL; +const nsresult NS_ERROR_OUT_OF_MEMORY = cast(nsresult) 0x8007000eL; +const nsresult NS_ERROR_ILLEGAL_VALUE = cast(nsresult) 0x80070057L; + +alias NS_ERROR_ILLEGAL_VALUE NS_ERROR_INVALID_ARG; diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIAppShell.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIAppShell.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,29 @@ +module dwt.internal.mozilla.nsIAppShell; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIEventQueue; + +const char[] NS_IAPPSHELL_IID_STR = "a0757c31-eeac-11d1-9ec1-00aa002fb821"; + +const nsIID NS_IAPPSHELL_IID= + {0xa0757c31, 0xeeac, 0x11d1, + [ 0x9e, 0xc1, 0x00, 0xaa, 0x00, 0x2f, 0xb8, 0x21 ]}; + +extern(System) + +interface nsIAppShell : nsISupports { + static const char[] IID_STR = NS_IAPPSHELL_IID_STR; + static const nsIID IID = NS_IAPPSHELL_IID; + + nsresult Create(int *argc, char **argv); + nsresult Run(); + nsresult Spinup(); + nsresult Spindown(); + nsresult ListenToEventQueue(nsIEventQueue * aQueue, PRBool aListen); + nsresult GetNativeEvent(PRBool * aRealEvent, void * * aEvent); + nsresult DispatchNativeEvent(PRBool aRealEvent, void * aEvent); + nsresult Exit(); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIAtom.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIAtom.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,29 @@ +module dwt.internal.mozilla.nsIAtom; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IATOM_IID_STR = "3d1b15b0-93b4-11d1-895b-006008911b81"; + +const nsIID NS_IATOM_IID= + {0x3d1b15b0, 0x93b4, 0x11d1, + [ 0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81 ]}; + +extern(System) + +interface nsIAtom : nsISupports { + + static const char[] IID_STR = NS_IATOM_IID_STR; + static const nsIID IID = NS_IATOM_IID; + + nsresult ToString(nsAString * _retval); + nsresult ToUTF8String(nsACString * _retval); + nsresult GetUTF8String(char **aResult); + nsresult Equals(nsAString * aString, PRBool *_retval); + nsresult EqualsUTF8(nsACString * aString, PRBool *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIAuthInformation.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIAuthInformation.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,36 @@ +module dwt.internal.mozilla.nsAuthInformation; + +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IAUTHINFORMATION_IID_STR = "0d73639c-2a92-4518-9f92-28f71fea5f20"; + +const nsIID NS_IAUTHINFORMATION_IID = + {0x0d73639c, 0x2a92, 0x4518, + [ 0x9f, 0x92, 0x28, 0xf7, 0x1f, 0xea, 0x5f, 0x20 ] }; + +extern(System) + +interface nsIAuthInformation : nsISupports { + + static const char[] IID_STR = NS_IAUTHINFORMATION_IID_STR; + static const nsIID IID = NS_IAUTHINFORMATION_IID; + + enum { AUTH_HOST = 1U } + enum { AUTH_PROXY = 2U } + enum { NEED_DOMAIN = 4U } + enum { ONLY_PASSWORD = 8U } + + nsresult GetFlags(PRUint32 *aFlags); + nsresult GetRealm(nsAString * aRealm);; + nsresult GetAuthenticationScheme(nsACString * aAuthenticationScheme); + nsresult GetUsername(nsAString * aUsername); + nsresult SetUsername(nsAString * aUsername); + nsresult GetPassword(nsAString * aPassword); + nsresult SetPassword(nsAString * aPassword); + nsresult GetDomain(nsAString * aDomain); + nsresult SetDomain(nsAString * aDomain); + +}; diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIAuthPrompt.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIAuthPrompt.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,31 @@ +module dwt.internal.mozilla.nsIAuthPrompt; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +// import dwt.internal.mozilla.nsIPrompt; + +const char[] NS_IAUTHPROMPT_IID_STR = "2f977d45-5485-11d4-87e2-0010a4e75ef2"; + +const nsIID NS_IAUTHPROMPT_IID= + {0x2f977d45, 0x5485, 0x11d4, + [ 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 ]}; + +extern(System) + +interface nsIAuthPrompt : nsISupports { + + static const char[] IID_STR = NS_IAUTHPROMPT_IID_STR; + static const nsIID IID = NS_IAUTHPROMPT_IID; + + enum { SAVE_PASSWORD_NEVER = 0U }; + enum { SAVE_PASSWORD_FOR_SESSION = 1U }; + enum { SAVE_PASSWORD_PERMANENTLY = 2U }; + + nsresult Prompt(PRUnichar *dialogTitle, PRUnichar *text, PRUnichar *passwordRealm, PRUint32 savePassword, PRUnichar *defaultText, PRUnichar **result, PRBool *_retval); + nsresult PromptUsernameAndPassword(PRUnichar *dialogTitle, PRUnichar *text, PRUnichar *passwordRealm, PRUint32 savePassword, PRUnichar **user, PRUnichar **pwd, PRBool *_retval); + nsresult PromptPassword(PRUnichar *dialogTitle, PRUnichar *text, PRUnichar *passwordRealm, PRUint32 savePassword, PRUnichar **pwd, PRBool *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIBaseWindow.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIBaseWindow.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,48 @@ +module dwt.internal.mozilla.nsIBaseWindow; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +alias void * nativeWindow; + +const char[] NS_IBASEWINDOW_IID_STR = "046bc8a0-8015-11d3-af70-00a024ffc08c"; + +const nsIID NS_IBASEWINDOW_IID= + {0x046bc8a0, 0x8015, 0x11d3, + [ 0xaf, 0x70, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c ]}; + +extern(System) + +interface nsIBaseWindow : nsISupports { + + static const char[] IID_STR = NS_IBASEWINDOW_IID_STR; + static const nsIID IID = NS_IBASEWINDOW_IID; + + nsresult InitWindow(nativeWindow parentNativeWindow, nsIWidget * parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy); + nsresult Create(); + nsresult Destroy(); + nsresult SetPosition(PRInt32 x, PRInt32 y); + nsresult GetPosition(PRInt32 *x, PRInt32 *y); + nsresult SetSize(PRInt32 cx, PRInt32 cy, PRBool fRepaint); + nsresult GetSize(PRInt32 *cx, PRInt32 *cy); + nsresult SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy, PRBool fRepaint); + nsresult GetPositionAndSize(PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy); + nsresult Repaint(PRBool force); + nsresult GetParentWidget(nsIWidget * *aParentWidget); + nsresult SetParentWidget(nsIWidget * aParentWidget); + nsresult GetParentNativeWindow(nativeWindow *aParentNativeWindow); + nsresult SetParentNativeWindow(nativeWindow aParentNativeWindow); + nsresult GetVisibility(PRBool *aVisibility); + nsresult SetVisibility(PRBool aVisibility); + nsresult GetEnabled(PRBool *aEnabled); + nsresult SetEnabled(PRBool aEnabled); + nsresult GetBlurSuppression(PRBool *aBlurSuppression); + nsresult SetBlurSuppression(PRBool aBlurSuppression); + nsresult GetMainWidget(nsIWidget * *aMainWidget); + nsresult SetFocus(); + nsresult GetTitle(PRUnichar * *aTitle); + nsresult SetTitle(PRUnichar * aTitle); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIBinaryInputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIBinaryInputStream.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,37 @@ +module dwt.internal.mozilla.nsIBinaryInputStream; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIInputStream; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IBINARYINPUTSTREAM_IID_STR = "7b456cb0-8772-11d3-90cf-0040056a906e"; + +const nsIID NS_IBINARYINPUTSTREAM_IID= + {0x7b456cb0, 0x8772, 0x11d3, + [ 0x90, 0xcf, 0x00, 0x40, 0x05, 0x6a, 0x90, 0x6e ]}; + +extern(System) + +interface nsIBinaryInputStream : nsIInputStream { + + static const char[] IID_STR = NS_IBINARYINPUTSTREAM_IID_STR; + static const nsIID IID = NS_IBINARYINPUTSTREAM_IID; + + nsresult SetInputStream(nsIInputStream aInputStream); + nsresult ReadBoolean(PRBool *_retval); + nsresult Read8(PRUint8 *_retval); + nsresult Read16(PRUint16 *_retval); + nsresult Read32(PRUint32 *_retval); + nsresult Read64(PRUint64 *_retval); + nsresult ReadFloat(float *_retval); + nsresult ReadDouble(double *_retval); + nsresult ReadCString(nsACString * _retval); + nsresult ReadString(nsAString * _retval); + nsresult ReadBytes(PRUint32 aLength, char **aString); + nsresult ReadByteArray(PRUint32 aLength, PRUint8 **aBytes); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIBinaryOutputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIBinaryOutputStream.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,37 @@ +module dwt.internal.mozilla.nsIBinaryOutputStream; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIOutputStream; + +const char[] NS_IBINARYOUTPUTSTREAM_IID_STR = "204ee610-8765-11d3-90cf-0040056a906e"; + +const nsIID NS_IBINARYOUTPUTSTREAM_IID= + {0x204ee610, 0x8765, 0x11d3, + [ 0x90, 0xcf, 0x00, 0x40, 0x05, 0x6a, 0x90, 0x6e ]}; + +extern(System) + +interface nsIBinaryOutputStream : nsIOutputStream { + + static const char[] IID_STR = NS_IBINARYOUTPUTSTREAM_IID_STR; + static const nsIID IID = NS_IBINARYOUTPUTSTREAM_IID; + + nsresult SetOutputStream(nsIOutputStream aOutputStream); + nsresult WriteBoolean(PRBool aBoolean); + nsresult Write8(PRUint8 aByte); + nsresult Write16(PRUint16 a16); + nsresult Write32(PRUint32 a32); + nsresult Write64(PRUint64 a64); + nsresult WriteFloat(float aFloat); + nsresult WriteDouble(double aDouble); + nsresult WriteStringZ(char *aString); + nsresult WriteWStringZ(PRUnichar *aString); + nsresult WriteUtf8Z(PRUnichar *aString); + nsresult WriteBytes(char *aString, PRUint32 aLength); + nsresult WriteByteArray(PRUint8 *aBytes, PRUint32 aLength); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsICancelable.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsICancelable.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,22 @@ +module dwt.internal.mozilla.nsICancelable; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_ICANCELABLE_IID_STR = "d94ac0a0-bb18-46b8-844e-84159064b0bd"; + +const nsIID NS_ICANCELABLE_IID= + {0xd94ac0a0, 0xbb18, 0x46b8, + [ 0x84, 0x4e, 0x84, 0x15, 0x90, 0x64, 0xb0, 0xbd ]}; + +extern(System) + +interface nsICancelable : nsISupports { + + static const char[] IID_STR = NS_ICANCELABLE_IID_STR; + static const nsIID IID = NS_ICANCELABLE_IID; + + nsresult Cancel(nsresult aReason); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsICategoryManager.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsICategoryManager.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,28 @@ +module dwt.internal.mozilla.nsICategoryManager; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsISimpleEnumerator; + +const char[] NS_ICATEGORYMANAGER_IID_STR = "3275b2cd-af6d-429a-80d7-f0c5120342ac"; + +const nsIID NS_ICATEGORYMANAGER_IID= + {0x3275b2cd, 0xaf6d, 0x429a, + [ 0x80, 0xd7, 0xf0, 0xc5, 0x12, 0x03, 0x42, 0xac ]}; + +extern(System) + +interface nsICategoryManager : nsISupports { + + static const char[] IID_STR = NS_ICATEGORYMANAGER_IID_STR; + static const nsIID IID = NS_ICATEGORYMANAGER_IID; + + nsresult GetCategoryEntry(char *aCategory, char *aEntry, char **_retval); + nsresult AddCategoryEntry(char *aCategory, char *aEntry, char *aValue, PRBool aPersist, PRBool aReplace, char **_retval); + nsresult DeleteCategoryEntry(char *aCategory, char *aEntry, PRBool aPersist); + nsresult DeleteCategory(char *aCategory); + nsresult EnumerateCategory(char *aCategory, nsISimpleEnumerator *_retval); + nsresult EnumerateCategories(nsISimpleEnumerator *_retval); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIChannel.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIChannel.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,51 @@ +module dwt.internal.mozilla.nsIChannel; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIRequest; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIInterfaceRequestor; +import dwt.internal.mozilla.nsIInputStream; +import dwt.internal.mozilla.nsIStreamListener; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_ICHANNEL_IID_STR = "c63a055a-a676-4e71-bf3c-6cfa11082018"; +const nsIID NS_ICHANNEL_IID= + {0xc63a055a, 0xa676, 0x4e71, + [ 0xbf, 0x3c, 0x6c, 0xfa, 0x11, 0x08, 0x20, 0x18 ]}; + +extern(System) + +interface nsIChannel : nsIRequest { + + static const char[] IID_STR = NS_ICHANNEL_IID_STR; + static const nsIID IID = NS_ICHANNEL_IID; + + nsresult GetOriginalURI(nsIURI *aOriginalURI); + nsresult SetOriginalURI(nsIURI aOriginalURI); + nsresult GetURI(nsIURI *aURI); + nsresult GetOwner(nsISupports *aOwner); + nsresult SetOwner(nsISupports aOwner); + + nsresult GetNotificationCallbacks(nsIInterfaceRequestor *aNotificationCallbacks); + nsresult SetNotificationCallbacks(nsIInterfaceRequestor aNotificationCallbacks); + nsresult GetSecurityInfo(nsISupports *aSecurityInfo); + nsresult GetContentType(nsACString * aContentType); + nsresult SetContentType(nsACString * aContentType); + nsresult GetContentCharset(nsACString * aContentCharset); + nsresult SetContentCharset(nsACString * aContentCharset); + nsresult GetContentLength(PRInt32 *aContentLength); + nsresult SetContentLength(PRInt32 aContentLength); + nsresult Open(nsIInputStream *_retval); + nsresult AsyncOpen(nsIStreamListener aListener, nsISupports aContext); + + enum { LOAD_DOCUMENT_URI = 65536U }; + enum { LOAD_RETARGETED_DOCUMENT_URI = 131072U }; + enum { LOAD_REPLACE = 262144U }; + enum { LOAD_INITIAL_DOCUMENT_URI = 524288U }; + enum { LOAD_TARGETED = 1048576U }; + enum { LOAD_CALL_CONTENT_SNIFFERS = 2097152U }; +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIChromeEventHandler.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIChromeEventHandler.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,25 @@ +module dwt.internal.mozilla.nsIChromeEventHandler; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMEvent; + +const char[] NS_ICHROMEEVENTHANDLER_IID_STR = "7bc08970-9e6c-11d3-afb2-00a024ffc08c"; + +const nsIID NS_ICHROMEEVENTHANDLER_IID= + {0x7bc08970, 0x9e6c, 0x11d3, + [ 0xaf, 0xb2, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c ]}; + +extern(System) + +interface nsIChromeEventHandler : nsISupports { + + static const char[] IID_STR = NS_ICHROMEEVENTHANDLER_IID_STR; + static const nsIID IID = NS_ICHROMEEVENTHANDLER_IID; + + nsresult HandleChromeEvent(nsPresContext * aPresContext, nsEvent * aEvent, nsIDOMEvent *aDOMEvent, PRUint32 aFlags, nsEventStatus *aStatus); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsICollection.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsICollection.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,33 @@ +module dwt.internal.mozilla.nsICollection; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsISerializable; +import dwt.internal.mozilla.nsIEnumerator; + +const char[] NS_ICOLLECTION_IID_STR = "83b6019c-cbc4-11d2-8cca-0060b0fc14a3"; + +const nsIID NS_ICOLLECTION_IID= + {0x83b6019c, 0xcbc4, 0x11d2, + [ 0x8c, 0xca, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3 ]}; + +extern(System) + +interface nsICollection : nsISerializable { + + static const char[] IID_STR = NS_ICOLLECTION_IID_STR; + static const nsIID IID = NS_ICOLLECTION_IID; + + nsresult Count(PRUint32 *_retval); + nsresult GetElementAt(PRUint32 index, nsISupports *_retval); + nsresult QueryElementAt(PRUint32 index, nsIID * uuid, void * *result); + nsresult SetElementAt(PRUint32 index, nsISupports item); + nsresult AppendElement(nsISupports item); + nsresult RemoveElement(nsISupports item); + nsresult Enumerate(nsIEnumerator *_retval); + nsresult Clear(); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIComponentManager.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIComponentManager.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,25 @@ +module dwt.internal.mozilla.nsIComponentManager; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIFactory; + +const char[] NS_ICOMPONENTMANAGER_IID_STR = "a88e5a60-205a-4bb1-94e1-2628daf51eae"; + +const nsIID NS_ICOMPONENTMANAGER_IID= + {0xa88e5a60, 0x205a, 0x4bb1, + [ 0x94, 0xe1, 0x26, 0x28, 0xda, 0xf5, 0x1e, 0xae ]}; + +extern(System) + +interface nsIComponentManager : nsISupports { + static const char[] IID_STR = NS_ICOMPONENTMANAGER_IID_STR; + static const nsIID IID = NS_ICOMPONENTMANAGER_IID; + + nsresult GetClassObject(nsCID * aClass, nsIID * aIID, void * *result); + nsresult GetClassObjectByContractID(char *aContractID, nsIID * aIID, void * *result); + nsresult CreateInstance(nsCID * aClass, nsISupports aDelegate, nsIID * aIID, void * *result); + nsresult CreateInstanceByContractID(char *aContractID, nsISupports aDelegate, nsIID * aIID, void * *result); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIComponentRegistrar.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIComponentRegistrar.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,35 @@ +module dwt.internal.mozilla.nsIComponentRegistrar; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIFile; +import dwt.internal.mozilla.nsIFactory; +import dwt.internal.mozilla.nsISimpleEnumerator; + +const char[] NS_ICOMPONENTREGISTRAR_IID_STR = "2417cbfe-65ad-48a6-b4b6-eb84db174392"; + +const nsIID NS_ICOMPONENTREGISTRAR_IID= + {0x2417cbfe, 0x65ad, 0x48a6, + [ 0xb4, 0xb6, 0xeb, 0x84, 0xdb, 0x17, 0x43, 0x92 ]}; + +extern(System) + +interface nsIComponentRegistrar : nsISupports { + static const char[] IID_STR = NS_ICOMPONENTREGISTRAR_IID_STR; + static const nsIID IID = NS_ICOMPONENTREGISTRAR_IID; + + nsresult AutoRegister(nsIFile aSpec); + nsresult AutoUnregister(nsIFile aSpec); + nsresult RegisterFactory(nsCID * aClass, char *aClassName, char *aContractID, nsIFactory aFactory); + nsresult UnregisterFactory(nsCID * aClass, nsIFactory aFactory); + nsresult RegisterFactoryLocation(nsCID * aClass, char *aClassName, char *aContractID, nsIFile aFile, char *aLoaderStr, char *aType); + nsresult UnregisterFactoryLocation(nsCID * aClass, nsIFile aFile); + nsresult IsCIDRegistered(nsCID * aClass, PRBool *_retval); + nsresult IsContractIDRegistered(char *aContractID, PRBool *_retval); + nsresult EnumerateCIDs(nsISimpleEnumerator *_retval); + nsresult EnumerateContractIDs(nsISimpleEnumerator *_retval); + nsresult CIDToContractID(nsCID * aClass, char **_retval); + nsresult ContractIDToCID(char *aContractID, nsCID * *_retval); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIContentViewer.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIContentViewer.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,76 @@ +module dwt.internal.mozilla.nsIContentViewer; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMDocument; +import dwt.internal.mozilla.nsISHEntry; + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_ICONTENTVIEWER_IID_STR = "6a7ddb40-8a9e-4576-8ad1-71c5641d8780"; + +const nsIID NS_ICONTENTVIEWER_IID= + {0x6a7ddb40, 0x8a9e, 0x4576, + [ 0x8a, 0xd1, 0x71, 0xc5, 0x64, 0x1d, 0x87, 0x80 ]}; + +extern(System) + +interface nsIContentViewer : nsISupports { + + static const char[] IID_STR = NS_ICONTENTVIEWER_IID_STR; + static const nsIID IID = NS_ICONTENTVIEWER_IID; + + nsresult Init(nsIWidget * aParentWidget, nsIDeviceContext * aDeviceContext, nsRect * aBounds); + nsresult GetContainer(nsISupports *aContainer); + nsresult SetContainer(nsISupports aContainer); + nsresult LoadStart(nsISupports aDoc); + nsresult LoadComplete(PRUint32 aStatus); + nsresult PermitUnload(PRBool *_retval); + nsresult PageHide(PRBool isUnload); + nsresult Close(nsISHEntry historyEntry); + nsresult Destroy(); + nsresult Stop(); + nsresult GetDOMDocument(nsIDOMDocument *aDOMDocument); + nsresult SetDOMDocument(nsIDOMDocument aDOMDocument); + nsresult GetBounds(nsRect * aBounds); + nsresult SetBounds(nsRect * aBounds); + nsresult GetPreviousViewer(nsIContentViewer *aPreviousViewer); + nsresult SetPreviousViewer(nsIContentViewer aPreviousViewer); + nsresult Move(PRInt32 aX, PRInt32 aY); + nsresult Show(); + nsresult Hide(); + nsresult GetEnableRendering(PRBool *aEnableRendering); + nsresult SetEnableRendering(PRBool aEnableRendering); + nsresult GetSticky(PRBool *aSticky); + nsresult SetSticky(PRBool aSticky); + nsresult RequestWindowClose(PRBool *_retval); + nsresult Open(nsISupports aState); + nsresult ClearHistoryEntry(); + +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_ICONTENTVIEWER_MOZILLA_1_8_BRANCH_IID_STR = "51341ed4-a3bf-4fd5-ae17-5fd3ec59dcab"; + +const nsIID NS_ICONTENTVIEWER_MOZILLA_1_8_BRANCH_IID= + {0x51341ed4, 0xa3bf, 0x4fd5, + [ 0xae, 0x17, 0x5f, 0xd3, 0xec, 0x59, 0xdc, 0xab ]}; + +extern(System) + +interface nsIContentViewer_MOZILLA_1_8_BRANCH : nsISupports { + + static const char[] IID_STR = NS_ICONTENTVIEWER_MOZILLA_1_8_BRANCH_IID_STR; + static const nsIID IID = NS_ICONTENTVIEWER_MOZILLA_1_8_BRANCH_IID; + + nsresult OpenWithEntry(nsISupports aState, nsISHEntry aSHEntry); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIContextMenuListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIContextMenuListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,31 @@ +module dwt.internal.mozilla.nsIContextMenuListener; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIDOMEvent; +import dwt.internal.mozilla.nsIDOMNode; + +const char[] NS_ICONTEXTMENULISTENER_IID_STR = "3478b6b0-3875-11d4-94ef-0020183bf181"; + +const nsIID NS_ICONTEXTMENULISTENER_IID= + {0x3478b6b0, 0x3875, 0x11d4, + [ 0x94, 0xef, 0x00, 0x20, 0x18, 0x3b, 0xf1, 0x81 ]}; + +extern(System) + +interface nsIContextMenuListener : nsISupports { + + static const char[] IID_STR = NS_ICONTEXTMENULISTENER_IID_STR; + static const nsIID IID = NS_ICONTEXTMENULISTENER_IID; + + enum { CONTEXT_NONE = 0U }; + enum { CONTEXT_LINK = 1U }; + enum { CONTEXT_IMAGE = 2U }; + enum { CONTEXT_DOCUMENT = 4U }; + enum { CONTEXT_TEXT = 8U }; + enum { CONTEXT_INPUT = 16U }; + + nsresult OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent aEvent, nsIDOMNode aNode); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIContextMenuListener2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIContextMenuListener2.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,61 @@ +module dwt.internal.mozilla.nsIContextMenuListener2; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIDOMEvent; +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.imgIContainer; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_ICONTEXTMENULISTENER2_IID_STR = "7fb719b3-d804-4964-9596-77cf924ee314"; + +const nsIID NS_ICONTEXTMENULISTENER2_IID= + {0x7fb719b3, 0xd804, 0x4964, + [ 0x95, 0x96, 0x77, 0xcf, 0x92, 0x4e, 0xe3, 0x14 ]}; + +extern(System) + +interface nsIContextMenuListener2 : nsISupports { + + static const char[] IID_STR = NS_ICONTEXTMENULISTENER2_IID_STR; + static const nsIID IID = NS_ICONTEXTMENULISTENER2_IID; + + enum { CONTEXT_NONE = 0U }; + enum { CONTEXT_LINK = 1U }; + enum { CONTEXT_IMAGE = 2U }; + enum { CONTEXT_DOCUMENT = 4U }; + enum { CONTEXT_TEXT = 8U }; + enum { CONTEXT_INPUT = 16U }; + enum { CONTEXT_BACKGROUND_IMAGE = 32U }; + + nsresult OnShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo aUtils); +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_ICONTEXTMENUINFO_IID_STR = "2f977d56-5485-11d4-87e2-0010a4e75ef2"; + +const nsIID NS_ICONTEXTMENUINFO_IID= + {0x2f977d56, 0x5485, 0x11d4, + [ 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 ]}; + +extern(System) + +interface nsIContextMenuInfo : nsISupports { + + static const char[] IID_STR = NS_ICONTEXTMENUINFO_IID_STR; + static const nsIID IID = NS_ICONTEXTMENUINFO_IID; + + nsresult GetMouseEvent(nsIDOMEvent *aMouseEvent); + nsresult GetTargetNode(nsIDOMNode *aTargetNode); + nsresult GetAssociatedLink(nsAString * aAssociatedLink); + nsresult GetImageContainer(imgIContainer *aImageContainer); + nsresult GetImageSrc(nsIURI *aImageSrc); + nsresult GetBackgroundImageContainer(imgIContainer *aBackgroundImageContainer); + nsresult GetBackgroundImageSrc(nsIURI *aBackgroundImageSrc); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsICookie.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsICookie.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,49 @@ +module dwt.internal.mozilla.nsICookie; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsStringAPI; + +alias PRInt32 nsCookieStatus; +alias PRInt32 nsCookiePolicy; + +const char[] NS_ICOOKIE_IID_STR = "e9fcb9a4-d376-458f-b720-e65e7df593bc"; + +const nsIID NS_ICOOKIE_IID= + {0xe9fcb9a4, 0xd376, 0x458f, + [ 0xb7, 0x20, 0xe6, 0x5e, 0x7d, 0xf5, 0x93, 0xbc ]}; + +extern(System) + +interface nsICookie : nsISupports { + + static const char[] IID_STR = NS_ICOOKIE_IID_STR; + static const nsIID IID = NS_ICOOKIE_IID; + + nsresult GetName(nsACString * aName); + nsresult GetValue(nsACString * aValue); + nsresult GetIsDomain(PRBool *aIsDomain); + nsresult GetHost(nsACString * aHost); + nsresult GetPath(nsACString * aPath); + nsresult GetIsSecure(PRBool *aIsSecure); + nsresult GetExpires(PRUint64 *aExpires); + + enum { STATUS_UNKNOWN = 0 }; + enum { STATUS_ACCEPTED = 1 }; + enum { STATUS_DOWNGRADED = 2 }; + enum { STATUS_FLAGGED = 3 }; + enum { STATUS_REJECTED = 4 }; + + nsresult GetStatus(nsCookieStatus *aStatus); + + enum { POLICY_UNKNOWN = 0 }; + enum { POLICY_NONE = 1 }; + enum { POLICY_NO_CONSENT = 2 }; + enum { POLICY_IMPLICIT_CONSENT = 3 }; + enum { POLICY_EXPLICIT_CONSENT = 4 }; + enum { POLICY_NO_II = 5 }; + + nsresult GetPolicy(nsCookiePolicy *aPolicy); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsICookie2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsICookie2.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,25 @@ +module dwt.internal.mozilla.nsICookie2; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsICookie; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_ICOOKIE2_IID_STR = "d3493503-7854-46ed-8284-8af54a847efb"; + +const nsIID NS_ICOOKIE2_IID= + {0xd3493503, 0x7854, 0x46ed, + [ 0x82, 0x84, 0x8a, 0xf5, 0x4a, 0x84, 0x7e, 0xfb ]}; + +extern(System) + +interface nsICookie2 : nsICookie { + + static const char[] IID_STR = NS_ICOOKIE2_IID_STR; + static const nsIID IID = NS_ICOOKIE2_IID; + + nsresult GetRawHost(nsACString * aRawHost); + nsresult GetIsSession(PRBool *aIsSession); + nsresult GetExpiry(PRInt64 *aExpiry); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsICookieManager.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsICookieManager.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,27 @@ +module dwt.internal.mozilla.nsICookieManager; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsISimpleEnumerator; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_ICOOKIEMANAGER_IID_STR = "aaab6710-0f2c-11d5-a53b-0010a401eb10"; + +const nsIID NS_ICOOKIEMANAGER_IID= + {0xaaab6710, 0x0f2c, 0x11d5, + [ 0xa5, 0x3b, 0x00, 0x10, 0xa4, 0x01, 0xeb, 0x10 ]}; + +extern(System) + +interface nsICookieManager : nsISupports { + + static const char[] IID_STR = NS_ICOOKIEMANAGER_IID_STR; + static const nsIID IID = NS_ICOOKIEMANAGER_IID; + + nsresult RemoveAll(); + nsresult GetEnumerator(nsISimpleEnumerator *aEnumerator); + nsresult Remove(nsACString * aDomain, nsACString * aName, nsACString * aPath, PRBool aBlocked); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsICookieManager2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsICookieManager2.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,25 @@ +module dwt.internal.mozilla.nsICookieManager2; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsICookieManager; +import dwt.internal.mozilla.nsICookie2; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_ICOOKIEMANAGER2_IID_STR = "3e73ff5f-154e-494f-b640-3c654ba2cc2b"; + +const nsIID NS_ICOOKIEMANAGER2_IID= + {0x3e73ff5f, 0x154e, 0x494f, + [ 0xb6, 0x40, 0x3c, 0x65, 0x4b, 0xa2, 0xcc, 0x2b ]}; + +extern(System) + +interface nsICookieManager2 : nsICookieManager { + + static const char[] IID_STR = NS_ICOOKIEMANAGER2_IID_STR; + static const nsIID IID = NS_ICOOKIEMANAGER2_IID; + + nsresult Add(nsACString * aDomain, nsACString * aPath, nsACString * aName, nsACString * aValue, PRBool aSecure, PRBool aIsSession, PRInt64 aExpiry); + nsresult FindMatchingCookie(nsICookie2 aCookie, PRUint32 *aCountFromHost, PRBool *_retval); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsID.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsID.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,26 @@ +module dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.Common; + +align(1) +struct nsID +{ + PRUint32 m0; + PRUint16 m1; + PRUint16 m2; + PRUint8[8] m3; + + static nsID opCall(PRUint32 v0, PRUint16 v1, PRUint16 v2, PRUint8[8] v3) + { + nsID result; + result.m0 = v0; + result.m1 = v1; + result.m2 = v2; + for(int i=0; i<8; ++i) + result.m3[i] = v3[i]; + return result; + } +} + +alias nsID nsCID; +alias nsID nsIID; diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMAbstractView.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMAbstractView.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,27 @@ +module dwt.internal.mozilla.nsIDOMAbstractView; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMDocumentView; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMABSTRACTVIEW_IID_STR = "f51ebade-8b1a-11d3-aae7-0010830123b4"; + +const nsIID NS_IDOMABSTRACTVIEW_IID= + {0xf51ebade, 0x8b1a, 0x11d3, + [ 0xaa, 0xe7, 0x00, 0x10, 0x83, 0x01, 0x23, 0xb4 ]}; + +extern(System) + +interface nsIDOMAbstractView : nsISupports { + + static const char[] IID_STR = NS_IDOMABSTRACTVIEW_IID_STR; + static const nsIID IID = NS_IDOMABSTRACTVIEW_IID; + + nsresult GetDocument(nsIDOMDocumentView *aDocument); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMAttr.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMAttr.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,29 @@ +module dwt.internal.mozilla.nsIDOMAttr; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.nsIDOMElement; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IDOMATTR_IID_STR = "a6cf9070-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMATTR_IID= + {0xa6cf9070, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMAttr : nsIDOMNode { + + static const char[] IID_STR = NS_IDOMATTR_IID_STR; + static const nsIID IID = NS_IDOMATTR_IID; + + nsresult GetName(nsAString * aName); + nsresult GetSpecified(PRBool *aSpecified); + nsresult GetValue(nsAString * aValue); + nsresult SetValue(nsAString * aValue); + nsresult GetOwnerElement(nsIDOMElement *aOwnerElement); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMBarProp.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMBarProp.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,26 @@ +module dwt.internal.mozilla.nsIDOMBarProp; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMBARPROP_IID_STR = "9eb2c150-1d56-11d3-8221-0060083a0bcf"; + +const nsIID NS_IDOMBARPROP_IID= + {0x9eb2c150, 0x1d56, 0x11d3, + [ 0x82, 0x21, 0x00, 0x60, 0x08, 0x3a, 0x0b, 0xcf ]}; + +extern(System) + +interface nsIDOMBarProp : nsISupports { + + static const char[] IID_STR = NS_IDOMBARPROP_IID_STR; + static const nsIID IID = NS_IDOMBARPROP_IID; + + nsresult GetVisible(PRBool *aVisible); + nsresult SetVisible(PRBool aVisible); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMCDATASection.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMCDATASection.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,22 @@ +module dwt.internal.mozilla.nsIDOMCDATASection; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIDOMText; + +const char[] NS_IDOMCDATASECTION_IID_STR = "a6cf9071-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMCDATASECTION_IID= + {0xa6cf9071, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMCDATASection : nsIDOMText { + + static const char[] IID_STR = NS_IDOMCDATASECTION_IID_STR; + static const nsIID IID = NS_IDOMCDATASECTION_IID; + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMCharacterData.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMCharacterData.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,32 @@ +module dwt.internal.mozilla.nsIDOMCharacterData; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IDOMCHARACTERDATA_IID_STR = "a6cf9072-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMCHARACTERDATA_IID= + {0xa6cf9072, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMCharacterData : nsIDOMNode { + + static const char[] IID_STR = NS_IDOMCHARACTERDATA_IID_STR; + static const nsIID IID = NS_IDOMCHARACTERDATA_IID; + + nsresult GetData(nsAString * aData); + nsresult SetData(nsAString * aData); + nsresult GetLength(PRUint32 *aLength); + nsresult SubstringData(PRUint32 offset, PRUint32 count, nsAString * _retval); + nsresult AppendData(nsAString * arg); + nsresult InsertData(PRUint32 offset, nsAString * arg); + nsresult DeleteData(PRUint32 offset, PRUint32 count); + nsresult ReplaceData(PRUint32 offset, PRUint32 count, nsAString * arg); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMComment.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMComment.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,22 @@ +module dwt.internal.mozilla.nsIDOMComment; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIDOMCharacterData; + +const char[] NS_IDOMCOMMENT_IID_STR = "a6cf9073-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMCOMMENT_IID= + {0xa6cf9073, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMComment : nsIDOMCharacterData { + + static const char[] IID_STR = NS_IDOMCOMMENT_IID_STR; + static const nsIID IID = NS_IDOMCOMMENT_IID; + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMDOMImplementation.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMDOMImplementation.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,29 @@ +module dwt.internal.mozilla.nsIDOMDOMImplementation; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMDocumentType; +import dwt.internal.mozilla.nsIDOMDocument; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IDOMDOMIMPLEMENTATION_IID_STR = "a6cf9074-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMDOMIMPLEMENTATION_IID= + {0xa6cf9074, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMDOMImplementation : nsISupports { + + static const char[] IID_STR = NS_IDOMDOMIMPLEMENTATION_IID_STR; + static const nsIID IID = NS_IDOMDOMIMPLEMENTATION_IID; + + nsresult HasFeature(nsAString * feature, nsAString * version_, PRBool *_retval); + nsresult CreateDocumentType(nsAString * qualifiedName, nsAString * publicId, nsAString * systemId, nsIDOMDocumentType *_retval); + nsresult CreateDocument(nsAString * namespaceURI, nsAString * qualifiedName, nsIDOMDocumentType doctype, nsIDOMDocument *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMDocument.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMDocument.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,53 @@ +module dwt.internal.mozilla.nsIDOMDocument; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.nsStringAPI; + +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.nsIDOMNodeList; +import dwt.internal.mozilla.nsIDOMDocumentType; +import dwt.internal.mozilla.nsIDOMElement; +import dwt.internal.mozilla.nsIDOMDocumentFragment; +import dwt.internal.mozilla.nsIDOMText; +import dwt.internal.mozilla.nsIDOMComment; +import dwt.internal.mozilla.nsIDOMCDATASection; +import dwt.internal.mozilla.nsIDOMProcessingInstruction; +import dwt.internal.mozilla.nsIDOMDOMImplementation; +import dwt.internal.mozilla.nsIDOMAttr; +import dwt.internal.mozilla.nsIDOMEntityReference; + +const char[] NS_IDOMDOCUMENT_IID_STR = "a6cf9075-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMDOCUMENT_IID= + {0xa6cf9075, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMDocument : nsIDOMNode { + + static const char[] IID_STR = NS_IDOMDOCUMENT_IID_STR; + static const nsIID IID = NS_IDOMDOCUMENT_IID; + + nsresult GetDoctype(nsIDOMDocumentType *aDoctype); + nsresult GetImplementation(nsIDOMDOMImplementation *aImplementation); + nsresult GetDocumentElement(nsIDOMElement *aDocumentElement); + nsresult CreateElement(nsAString * tagName, nsIDOMElement *_retval); + nsresult CreateDocumentFragment(nsIDOMDocumentFragment *_retval); + nsresult CreateTextNode(nsAString * data, nsIDOMText *_retval); + nsresult CreateComment(nsAString * data, nsIDOMComment *_retval); + nsresult CreateCDATASection(nsAString * data, nsIDOMCDATASection *_retval); + nsresult CreateProcessingInstruction(nsAString * target, nsAString * data, nsIDOMProcessingInstruction *_retval); + nsresult CreateAttribute(nsAString * name, nsIDOMAttr *_retval); + nsresult CreateEntityReference(nsAString * name, nsIDOMEntityReference *_retval); + nsresult GetElementsByTagName(nsAString * tagname, nsIDOMNodeList *_retval); + nsresult ImportNode(nsIDOMNode importedNode, PRBool deep, nsIDOMNode *_retval); + nsresult CreateElementNS(nsAString * namespaceURI, nsAString * qualifiedName, nsIDOMElement *_retval); + nsresult CreateAttributeNS(nsAString * namespaceURI, nsAString * qualifiedName, nsIDOMAttr *_retval); + nsresult GetElementsByTagNameNS(nsAString * namespaceURI, nsAString * localName, nsIDOMNodeList *_retval); + nsresult GetElementById(nsAString * elementId, nsIDOMElement *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMDocumentFragment.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMDocumentFragment.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,20 @@ +module dwt.internal.mozilla.nsIDOMDocumentFragment; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIDOMNode; + +const char[] NS_IDOMDOCUMENTFRAGMENT_IID_STR = "a6cf9076-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMDOCUMENTFRAGMENT_IID= + {0xa6cf9076, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(Windows) +interface nsIDOMDocumentFragment : nsIDOMNode { + static const char[] IID_STR = NS_IDOMDOCUMENTFRAGMENT_IID_STR; + static const nsIID IID = NS_IDOMDOCUMENTFRAGMENT_IID; + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMDocumentType.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMDocumentType.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,31 @@ +module dwt.internal.mozilla.nsIDOMDocumentType; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.nsIDOMNamedNodeMap; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IDOMDOCUMENTTYPE_IID_STR = "a6cf9077-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMDOCUMENTTYPE_IID= + {0xa6cf9077, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMDocumentType : nsIDOMNode { + + static const char[] IID_STR = NS_IDOMDOCUMENTTYPE_IID_STR; + static const nsIID IID = NS_IDOMDOCUMENTTYPE_IID; + + nsresult GetName(nsAString * aName); + nsresult GetEntities(nsIDOMNamedNodeMap *aEntities); + nsresult GetNotations(nsIDOMNamedNodeMap *aNotations); + nsresult GetPublicId(nsAString * aPublicId); + nsresult GetSystemId(nsAString * aSystemId); + nsresult GetInternalSubset(nsAString * aInternalSubset); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMDocumentView.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMDocumentView.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,27 @@ +module dwt.internal.mozilla.nsIDOMDocumentView; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMAbstractView; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMDOCUMENTVIEW_IID_STR = "1acdb2ba-1dd2-11b2-95bc-9542495d2569"; + +const nsIID NS_IDOMDOCUMENTVIEW_IID= + {0x1acdb2ba, 0x1dd2, 0x11b2, + [ 0x95, 0xbc, 0x95, 0x42, 0x49, 0x5d, 0x25, 0x69 ]}; + +extern(System) + +interface nsIDOMDocumentView : nsISupports { + + static const char[] IID_STR = NS_IDOMDOCUMENTVIEW_IID_STR; + static const nsIID IID = NS_IDOMDOCUMENTVIEW_IID; + + nsresult GetDefaultView(nsIDOMAbstractView *aDefaultView); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMElement.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMElement.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,42 @@ +module dwt.internal.mozilla.nsIDOMElement; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.nsIDOMNodeList; +import dwt.internal.mozilla.nsIDOMAttr; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IDOMELEMENT_IID_STR = "a6cf9078-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMELEMENT_IID= + {0xa6cf9078, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMElement : nsIDOMNode { + + static const char[] IID_STR = NS_IDOMELEMENT_IID_STR; + static const nsIID IID = NS_IDOMELEMENT_IID; + + nsresult GetTagName(nsAString * aTagName); + nsresult GetAttribute(nsAString * name, nsAString * _retval); + nsresult SetAttribute(nsAString * name, nsAString * value); + nsresult RemoveAttribute(nsAString * name); + nsresult GetAttributeNode(nsAString * name, nsIDOMAttr *_retval); + nsresult SetAttributeNode(nsIDOMAttr newAttr, nsIDOMAttr *_retval); + nsresult RemoveAttributeNode(nsIDOMAttr oldAttr, nsIDOMAttr *_retval); + nsresult GetElementsByTagName(nsAString * name, nsIDOMNodeList *_retval); + nsresult GetAttributeNS(nsAString * namespaceURI, nsAString * localName, nsAString * _retval); + nsresult SetAttributeNS(nsAString * namespaceURI, nsAString * qualifiedName, nsAString * value); + nsresult RemoveAttributeNS(nsAString * namespaceURI, nsAString * localName); + nsresult GetAttributeNodeNS(nsAString * namespaceURI, nsAString * localName, nsIDOMAttr *_retval); + nsresult SetAttributeNodeNS(nsIDOMAttr newAttr, nsIDOMAttr *_retval); + nsresult GetElementsByTagNameNS(nsAString * namespaceURI, nsAString * localName, nsIDOMNodeList *_retval); + nsresult HasAttribute(nsAString * name, PRBool *_retval); + nsresult HasAttributeNS(nsAString * namespaceURI, nsAString * localName, PRBool *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMEntityReference.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMEntityReference.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,22 @@ +module dwt.internal.mozilla.nsIDOMEntityReference; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIDOMNode; + +const char[] NS_IDOMENTITYREFERENCE_IID_STR = "a6cf907a-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMENTITYREFERENCE_IID= + {0xa6cf907a, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMEntityReference : nsIDOMNode { + + static const char[] IID_STR = NS_IDOMENTITYREFERENCE_IID_STR; + static const nsIID IID = NS_IDOMENTITYREFERENCE_IID; + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMEvent.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,40 @@ +module dwt.internal.mozilla.nsIDOMEvent; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIDOMEventTarget; +import dwt.internal.mozilla.nsStringAPI; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMEVENT_IID_STR = "a66b7b80-ff46-bd97-0080-5f8ae38add32"; + +const nsIID NS_IDOMEVENT_IID= + {0xa66b7b80, 0xff46, 0xbd97, + [ 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMEvent : nsISupports { + + static const char[] IID_STR = NS_IDOMEVENT_IID_STR; + static const nsIID IID = NS_IDOMEVENT_IID; + + enum { CAPTURING_PHASE = 1U }; + enum { AT_TARGET = 2U }; + enum { BUBBLING_PHASE = 3U }; + + nsresult GetType(nsAString * aType); + nsresult GetTarget(nsIDOMEventTarget *aTarget); + nsresult GetCurrentTarget(nsIDOMEventTarget *aCurrentTarget); + nsresult GetEventPhase(PRUint16 *aEventPhase); + nsresult GetBubbles(PRBool *aBubbles); + nsresult GetCancelable(PRBool *aCancelable); + nsresult GetTimeStamp(DOMTimeStamp *aTimeStamp); + nsresult StopPropagation(); + nsresult PreventDefault(); + nsresult InitEvent(nsAString * eventTypeArg, PRBool canBubbleArg, PRBool cancelableArg); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMEventGroup.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMEventGroup.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,25 @@ +module dwt.internal.mozilla.nsIDOMEventGroup; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMEVENTGROUP_IID_STR = "33347bee-6620-4841-8152-36091ae80c7e"; + +const nsIID NS_IDOMEVENTGROUP_IID= + {0x33347bee, 0x6620, 0x4841, + [ 0x81, 0x52, 0x36, 0x09, 0x1a, 0xe8, 0x0c, 0x7e ]}; + +extern(System) + +interface nsIDOMEventGroup : nsISupports { + + static const char[] IID_STR = NS_IDOMEVENTGROUP_IID_STR; + static const nsIID IID = NS_IDOMEVENTGROUP_IID; + + nsresult IsSameEventGroup(nsIDOMEventGroup other, PRBool *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMEventListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMEventListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,24 @@ +module dwt.internal.mozilla.nsIDOMEventListener; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIDOMEvent; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMEVENTLISTENER_IID_STR = "df31c120-ded6-11d1-bd85-00805f8ae3f4"; +const nsIID NS_IDOMEVENTLISTENER_IID= + {0xdf31c120, 0xded6, 0x11d1, + [ 0xbd, 0x85, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4 ]}; + +extern(System) + +interface nsIDOMEventListener : nsISupports { + + static const char[] IID_STR = NS_IDOMEVENTLISTENER_IID_STR; + static const nsIID IID = NS_IDOMEVENTLISTENER_IID; + + nsresult HandleEvent(nsIDOMEvent event); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMEventTarget.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMEventTarget.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,30 @@ +module dwt.internal.mozilla.nsIDOMEventTarget; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIDOMEvent; +import dwt.internal.mozilla.nsIDOMEventListener; +import dwt.internal.mozilla.nsStringAPI; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMEVENTTARGET_IID_STR = "1c773b30-d1cf-11d2-bd95-00805f8ae3f4"; + +const nsIID NS_IDOMEVENTTARGET_IID= + {0x1c773b30, 0xd1cf, 0x11d2, + [ 0xbd, 0x95, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4 ]}; + +extern(System) + +interface nsIDOMEventTarget : nsISupports { + + static const char[] IID_STR = NS_IDOMEVENTTARGET_IID_STR; + static const nsIID IID = NS_IDOMEVENTTARGET_IID; + + nsresult AddEventListener(nsAString * type, nsIDOMEventListener listener, PRBool useCapture); + nsresult RemoveEventListener(nsAString * type, nsIDOMEventListener listener, PRBool useCapture); + nsresult DispatchEvent(nsIDOMEvent evt, PRBool *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMKeyEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMKeyEvent.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,149 @@ +module dwt.internal.mozilla.nsIDOMKeyEvent; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIDOMUIEvent; +import dwt.internal.mozilla.nsIDOMAbstractView; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IDOMKEYEVENT_IID_STR = "028e0e6e-8b01-11d3-aae7-0010838a3123"; + +const nsIID NS_IDOMKEYEVENT_IID= + {0x028e0e6e, 0x8b01, 0x11d3, + [ 0xaa, 0xe7, 0x00, 0x10, 0x83, 0x8a, 0x31, 0x23 ]}; + +extern(System) + +interface nsIDOMKeyEvent : nsIDOMUIEvent { + + static const char[] IID_STR = NS_IDOMKEYEVENT_IID_STR; + static const nsIID IID = NS_IDOMKEYEVENT_IID; + + enum { DOM_VK_CANCEL = 3U }; + enum { DOM_VK_HELP = 6U }; + enum { DOM_VK_BACK_SPACE = 8U }; + enum { DOM_VK_TAB = 9U }; + enum { DOM_VK_CLEAR = 12U }; + enum { DOM_VK_RETURN = 13U }; + enum { DOM_VK_ENTER = 14U }; + enum { DOM_VK_SHIFT = 16U }; + enum { DOM_VK_CONTROL = 17U }; + enum { DOM_VK_ALT = 18U }; + enum { DOM_VK_PAUSE = 19U }; + enum { DOM_VK_CAPS_LOCK = 20U }; + enum { DOM_VK_ESCAPE = 27U }; + enum { DOM_VK_SPACE = 32U }; + enum { DOM_VK_PAGE_UP = 33U }; + enum { DOM_VK_PAGE_DOWN = 34U }; + enum { DOM_VK_END = 35U }; + enum { DOM_VK_HOME = 36U }; + enum { DOM_VK_LEFT = 37U }; + enum { DOM_VK_UP = 38U }; + enum { DOM_VK_RIGHT = 39U }; + enum { DOM_VK_DOWN = 40U }; + enum { DOM_VK_PRINTSCREEN = 44U }; + enum { DOM_VK_INSERT = 45U }; + enum { DOM_VK_DELETE = 46U }; + enum { DOM_VK_0 = 48U }; + enum { DOM_VK_1 = 49U }; + enum { DOM_VK_2 = 50U }; + enum { DOM_VK_3 = 51U }; + enum { DOM_VK_4 = 52U }; + enum { DOM_VK_5 = 53U }; + enum { DOM_VK_6 = 54U }; + enum { DOM_VK_7 = 55U }; + enum { DOM_VK_8 = 56U }; + enum { DOM_VK_9 = 57U }; + enum { DOM_VK_SEMICOLON = 59U }; + enum { DOM_VK_EQUALS = 61U }; + enum { DOM_VK_A = 65U }; + enum { DOM_VK_B = 66U }; + enum { DOM_VK_C = 67U }; + enum { DOM_VK_D = 68U }; + enum { DOM_VK_E = 69U }; + enum { DOM_VK_F = 70U }; + enum { DOM_VK_G = 71U }; + enum { DOM_VK_H = 72U }; + enum { DOM_VK_I = 73U }; + enum { DOM_VK_J = 74U }; + enum { DOM_VK_K = 75U }; + enum { DOM_VK_L = 76U }; + enum { DOM_VK_M = 77U }; + enum { DOM_VK_N = 78U }; + enum { DOM_VK_O = 79U }; + enum { DOM_VK_P = 80U }; + enum { DOM_VK_Q = 81U }; + enum { DOM_VK_R = 82U }; + enum { DOM_VK_S = 83U }; + enum { DOM_VK_T = 84U }; + enum { DOM_VK_U = 85U }; + enum { DOM_VK_V = 86U }; + enum { DOM_VK_W = 87U }; + enum { DOM_VK_X = 88U }; + enum { DOM_VK_Y = 89U }; + enum { DOM_VK_Z = 90U }; + enum { DOM_VK_CONTEXT_MENU = 93U }; + enum { DOM_VK_NUMPAD0 = 96U }; + enum { DOM_VK_NUMPAD1 = 97U }; + enum { DOM_VK_NUMPAD2 = 98U }; + enum { DOM_VK_NUMPAD3 = 99U }; + enum { DOM_VK_NUMPAD4 = 100U }; + enum { DOM_VK_NUMPAD5 = 101U }; + enum { DOM_VK_NUMPAD6 = 102U }; + enum { DOM_VK_NUMPAD7 = 103U }; + enum { DOM_VK_NUMPAD8 = 104U }; + enum { DOM_VK_NUMPAD9 = 105U }; + enum { DOM_VK_MULTIPLY = 106U }; + enum { DOM_VK_ADD = 107U }; + enum { DOM_VK_SEPARATOR = 108U }; + enum { DOM_VK_SUBTRACT = 109U }; + enum { DOM_VK_DECIMAL = 110U }; + enum { DOM_VK_DIVIDE = 111U }; + enum { DOM_VK_F1 = 112U }; + enum { DOM_VK_F2 = 113U }; + enum { DOM_VK_F3 = 114U }; + enum { DOM_VK_F4 = 115U }; + enum { DOM_VK_F5 = 116U }; + enum { DOM_VK_F6 = 117U }; + enum { DOM_VK_F7 = 118U }; + enum { DOM_VK_F8 = 119U }; + enum { DOM_VK_F9 = 120U }; + enum { DOM_VK_F10 = 121U }; + enum { DOM_VK_F11 = 122U }; + enum { DOM_VK_F12 = 123U }; + enum { DOM_VK_F13 = 124U }; + enum { DOM_VK_F14 = 125U }; + enum { DOM_VK_F15 = 126U }; + enum { DOM_VK_F16 = 127U }; + enum { DOM_VK_F17 = 128U }; + enum { DOM_VK_F18 = 129U }; + enum { DOM_VK_F19 = 130U }; + enum { DOM_VK_F20 = 131U }; + enum { DOM_VK_F21 = 132U }; + enum { DOM_VK_F22 = 133U }; + enum { DOM_VK_F23 = 134U }; + enum { DOM_VK_F24 = 135U }; + enum { DOM_VK_NUM_LOCK = 144U }; + enum { DOM_VK_SCROLL_LOCK = 145U }; + enum { DOM_VK_COMMA = 188U }; + enum { DOM_VK_PERIOD = 190U }; + enum { DOM_VK_SLASH = 191U }; + enum { DOM_VK_BACK_QUOTE = 192U }; + enum { DOM_VK_OPEN_BRACKET = 219U }; + enum { DOM_VK_BACK_SLASH = 220U }; + enum { DOM_VK_CLOSE_BRACKET = 221U }; + enum { DOM_VK_QUOTE = 222U }; + enum { DOM_VK_META = 224U }; + + nsresult GetCharCode(PRUint32 *aCharCode); + nsresult GetKeyCode(PRUint32 *aKeyCode); + nsresult GetAltKey(PRBool *aAltKey); + nsresult GetCtrlKey(PRBool *aCtrlKey); + nsresult GetShiftKey(PRBool *aShiftKey); + nsresult GetMetaKey(PRBool *aMetaKey); + + nsresult InitKeyEvent(nsAString * typeArg, PRBool canBubbleArg, PRBool cancelableArg, nsIDOMAbstractView viewArg, PRBool ctrlKeyArg, PRBool altKeyArg, PRBool shiftKeyArg, PRBool metaKeyArg, PRUint32 keyCodeArg, PRUint32 charCodeArg); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMMouseEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMMouseEvent.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,37 @@ +module dwt.internal.mozilla.nsIDOMMouseEvent; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIDOMUIEvent; +import dwt.internal.mozilla.nsIDOMEventTarget; +import dwt.internal.mozilla.nsIDOMAbstractView; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IDOMMOUSEEVENT_IID_STR = "ff751edc-8b02-aae7-0010-8301838a3123"; + +const nsIID NS_IDOMMOUSEEVENT_IID= + {0xff751edc, 0x8b02, 0xaae7, + [ 0x00, 0x10, 0x83, 0x01, 0x83, 0x8a, 0x31, 0x23 ]}; + +extern(System) + +interface nsIDOMMouseEvent : nsIDOMUIEvent { + + static const char[] IID_STR = NS_IDOMMOUSEEVENT_IID_STR; + static const nsIID IID = NS_IDOMMOUSEEVENT_IID; + + nsresult GetScreenX(PRInt32 *aScreenX); + nsresult GetScreenY(PRInt32 *aScreenY); + nsresult GetClientX(PRInt32 *aClientX); + nsresult GetClientY(PRInt32 *aClientY); + nsresult GetCtrlKey(PRBool *aCtrlKey); + nsresult GetShiftKey(PRBool *aShiftKey); + nsresult GetAltKey(PRBool *aAltKey); + nsresult GetMetaKey(PRBool *aMetaKey); + nsresult GetButton(PRUint16 *aButton); + nsresult GetRelatedTarget(nsIDOMEventTarget *aRelatedTarget); + + nsresult InitMouseEvent(nsAString * typeArg, PRBool canBubbleArg, PRBool cancelableArg, nsIDOMAbstractView viewArg, PRInt32 detailArg, PRInt32 screenXArg, PRInt32 screenYArg, PRInt32 clientXArg, PRInt32 clientYArg, PRBool ctrlKeyArg, PRBool altKeyArg, PRBool shiftKeyArg, PRBool metaKeyArg, PRUint16 buttonArg, nsIDOMEventTarget relatedTargetArg); + +} \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMNamedNodeMap.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMNamedNodeMap.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,35 @@ +module dwt.internal.mozilla.nsIDOMNamedNodeMap; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.nsStringAPI; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMNAMEDNODEMAP_IID_STR = "a6cf907b-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMNAMEDNODEMAP_IID= + {0xa6cf907b, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMNamedNodeMap : nsISupports { + + static const char[] IID_STR = NS_IDOMNAMEDNODEMAP_IID_STR; + static const nsIID IID = NS_IDOMNAMEDNODEMAP_IID; + + nsresult GetNamedItem(nsAString * name, nsIDOMNode *_retval); + nsresult SetNamedItem(nsIDOMNode arg, nsIDOMNode *_retval); + nsresult RemoveNamedItem(nsAString * name, nsIDOMNode *_retval); + nsresult Item(PRUint32 index, nsIDOMNode *_retval); + nsresult GetLength(PRUint32 *aLength); + nsresult GetNamedItemNS(nsAString * namespaceURI, nsAString * localName, nsIDOMNode *_retval); + nsresult SetNamedItemNS(nsIDOMNode arg, nsIDOMNode *_retval); + nsresult RemoveNamedItemNS(nsAString * namespaceURI, nsAString * localName, nsIDOMNode *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMNode.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMNode.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,67 @@ +module dwt.internal.mozilla.nsIDOMNode; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMNodeList; +import dwt.internal.mozilla.nsIDOMNamedNodeMap; +import dwt.internal.mozilla.nsIDOMDocument; +import dwt.internal.mozilla.nsStringAPI; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMNODE_IID_STR = "a6cf907c-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMNODE_IID= + {0xa6cf907c, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMNode : nsISupports { + + static const char[] IID_STR = NS_IDOMNODE_IID_STR; + static const nsIID IID = NS_IDOMNODE_IID; + + enum { ELEMENT_NODE = 1U }; + enum { ATTRIBUTE_NODE = 2U }; + enum { TEXT_NODE = 3U }; + enum { CDATA_SECTION_NODE = 4U }; + enum { ENTITY_REFERENCE_NODE = 5U }; + enum { ENTITY_NODE = 6U }; + enum { PROCESSING_INSTRUCTION_NODE = 7U }; + enum { COMMENT_NODE = 8U }; + enum { DOCUMENT_NODE = 9U }; + enum { DOCUMENT_TYPE_NODE = 10U }; + enum { DOCUMENT_FRAGMENT_NODE = 11U }; + enum { NOTATION_NODE = 12U }; + + nsresult GetNodeName(nsAString * aNodeName); + nsresult GetNodeValue(nsAString * aNodeValue); + nsresult SetNodeValue(nsAString * aNodeValue); + nsresult GetNodeType(PRUint16 *aNodeType); + nsresult GetParentNode(nsIDOMNode *aParentNode); + nsresult GetChildNodes(nsIDOMNodeList *aChildNodes); + nsresult GetFirstChild(nsIDOMNode *aFirstChild); + nsresult GetLastChild(nsIDOMNode *aLastChild); + nsresult GetPreviousSibling(nsIDOMNode *aPreviousSibling); + nsresult GetNextSibling(nsIDOMNode *aNextSibling); + nsresult GetAttributes(nsIDOMNamedNodeMap *aAttributes); + nsresult GetOwnerDocument(nsIDOMDocument *aOwnerDocument); + nsresult InsertBefore(nsIDOMNode newChild, nsIDOMNode refChild, nsIDOMNode *_retval); + nsresult ReplaceChild(nsIDOMNode newChild, nsIDOMNode oldChild, nsIDOMNode *_retval); + nsresult RemoveChild(nsIDOMNode oldChild, nsIDOMNode *_retval); + nsresult AppendChild(nsIDOMNode newChild, nsIDOMNode *_retval); + nsresult HasChildNodes(PRBool *_retval); + nsresult CloneNode(PRBool deep, nsIDOMNode *_retval); + nsresult Normalize(); + nsresult IsSupported(nsAString * feature, nsAString * version_, PRBool *_retval); + nsresult GetNamespaceURI(nsAString * aNamespaceURI); + nsresult GetPrefix(nsAString * aPrefix); + nsresult SetPrefix(nsAString * aPrefix); + nsresult GetLocalName(nsAString * aLocalName); + nsresult HasAttributes(PRBool *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMNodeList.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMNodeList.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,28 @@ +module dwt.internal.mozilla.nsIDOMNodeList; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMNode; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMNODELIST_IID_STR = "a6cf907d-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMNODELIST_IID= + {0xa6cf907d, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMNodeList : nsISupports { + + static const char[] IID_STR = NS_IDOMNODELIST_IID_STR; + static const nsIID IID = NS_IDOMNODELIST_IID; + + nsresult Item(PRUint32 index, nsIDOMNode *_retval); + nsresult GetLength(PRUint32 *aLength); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMProcessingInstruction.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMProcessingInstruction.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,26 @@ +module dwt.internal.mozilla.nsIDOMProcessingInstruction; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IDOMPROCESSINGINSTRUCTION_IID_STR = "a6cf907f-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMPROCESSINGINSTRUCTION_IID= + {0xa6cf907f, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMProcessingInstruction : nsIDOMNode { + + static const char[] IID_STR = NS_IDOMPROCESSINGINSTRUCTION_IID_STR; + static const nsIID IID = NS_IDOMPROCESSINGINSTRUCTION_IID; + + nsresult GetTarget(nsAString * aTarget); + nsresult GetData(nsAString * aData); + nsresult SetData(nsAString * aData); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMRange.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMRange.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,56 @@ +module dwt.internal.mozilla.nsIDOMRange; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.nsIDOMDocumentFragment; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IDOMRANGE_IID_STR = "a6cf90ce-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMRANGE_IID= + {0xa6cf90ce, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMRange : nsISupports { + + static const char[] IID_STR = NS_IDOMRANGE_IID_STR; + static const nsIID IID = NS_IDOMRANGE_IID; + + nsresult GetStartContainer(nsIDOMNode *aStartContainer); + nsresult GetStartOffset(PRInt32 *aStartOffset); + nsresult GetEndContainer(nsIDOMNode *aEndContainer); + nsresult GetEndOffset(PRInt32 *aEndOffset); + nsresult GetCollapsed(PRBool *aCollapsed); + nsresult GetCommonAncestorContainer(nsIDOMNode *aCommonAncestorContainer); + nsresult SetStart(nsIDOMNode refNode, PRInt32 offset); + nsresult SetEnd(nsIDOMNode refNode, PRInt32 offset); + nsresult SetStartBefore(nsIDOMNode refNode); + nsresult SetStartAfter(nsIDOMNode refNode); + nsresult SetEndBefore(nsIDOMNode refNode); + nsresult SetEndAfter(nsIDOMNode refNode); + nsresult Collapse(PRBool toStart); + nsresult SelectNode(nsIDOMNode refNode); + nsresult SelectNodeContents(nsIDOMNode refNode); + + enum { START_TO_START = 0U }; + enum { START_TO_END = 1U }; + enum { END_TO_END = 2U }; + enum { END_TO_START = 3U }; + + nsresult CompareBoundaryPoints(PRUint16 how, nsIDOMRange sourceRange, PRInt16 *_retval); + nsresult DeleteContents(); + nsresult ExtractContents(nsIDOMDocumentFragment *_retval); + nsresult CloneContents(nsIDOMDocumentFragment *_retval); + nsresult InsertNode(nsIDOMNode newNode); + nsresult SurroundContents(nsIDOMNode newParent); + nsresult CloneRange(nsIDOMRange *_retval); + nsresult ToString(nsAString * _retval); + nsresult Detach(); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMSerializer.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMSerializer.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,27 @@ +module dwt.internal.mozilla.nsIDOMSerializer; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIOutputStream; +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IDOMSERIALIZER_IID_STR = "9fd4ba15-e67c-4c98-b52c-7715f62c9196"; + +const nsIID NS_IDOMSERIALIZER_IID= + {0x9fd4ba15, 0xe67c, 0x4c98, + [ 0xb5, 0x2c, 0x77, 0x15, 0xf6, 0x2c, 0x91, 0x96 ]}; + +extern(System) + +interface nsIDOMSerializer : nsISupports { + + static const char[] IID_STR = NS_IDOMSERIALIZER_IID_STR; + static const nsIID IID = NS_IDOMSERIALIZER_IID; + + nsresult SerializeToString(nsIDOMNode root, nsAString * _retval); + nsresult SerializeToStream(nsIDOMNode root, nsIOutputStream stream, nsACString * charset); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMStorage.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMStorage.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,32 @@ +module dwt.internal.mozilla.nsIDOMStorage; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsStringAPI; +import dwt.internal.mozilla.nsIDOMStorageItem; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMSTORAGE_IID_STR = "95cc1383-3b62-4b89-aaef-1004a513ef47"; + +const nsIID NS_IDOMSTORAGE_IID= + {0x95cc1383, 0x3b62, 0x4b89, + [ 0xaa, 0xef, 0x10, 0x04, 0xa5, 0x13, 0xef, 0x47 ]}; + +extern(System) + +interface nsIDOMStorage : nsISupports { + + static const char[] IID_STR = NS_IDOMSTORAGE_IID_STR; + static const nsIID IID = NS_IDOMSTORAGE_IID; + + nsresult GetLength(PRUint32 *aLength); + nsresult Key(PRUint32 index, nsAString * _retval); + nsresult GetItem(nsAString * key, nsIDOMStorageItem *_retval); + nsresult SetItem(nsAString * key, nsAString * data); + nsresult RemoveItem(nsAString * key); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMStorageItem.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMStorageItem.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,30 @@ +module dwt.internal.mozilla.nsIDOMStorageItem; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsStringAPI; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMSTORAGEITEM_IID_STR = "0cc37c78-4c5f-48e1-adfc-7480b8fe9dc4"; + +const nsIID NS_IDOMSTORAGEITEM_IID= + {0x0cc37c78, 0x4c5f, 0x48e1, + [ 0xad, 0xfc, 0x74, 0x80, 0xb8, 0xfe, 0x9d, 0xc4 ]}; + +extern(System) + +interface nsIDOMStorageItem : nsISupports { + + static const char[] IID_STR = NS_IDOMSTORAGEITEM_IID_STR; + static const nsIID IID = NS_IDOMSTORAGEITEM_IID; + + nsresult GetSecure(PRBool *aSecure); + nsresult SetSecure(PRBool aSecure); + nsresult GetValue(nsAString * aValue); + nsresult SetValue(nsAString * aValue); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMText.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMText.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,24 @@ +module dwt.internal.mozilla.nsIDOMText; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIDOMCharacterData; + +const char[] NS_IDOMTEXT_IID_STR = "a6cf9082-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMTEXT_IID= + {0xa6cf9082, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMText : nsIDOMCharacterData { + + static const char[] IID_STR = NS_IDOMTEXT_IID_STR; + static const nsIID IID = NS_IDOMTEXT_IID; + + nsresult SplitText(PRUint32 offset, nsIDOMText *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMUIEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMUIEvent.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,28 @@ +module dwt.internal.mozilla.nsIDOMUIEvent; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIDOMEvent; +import dwt.internal.mozilla.nsStringAPI; +import dwt.internal.mozilla.nsIDOMAbstractView; + +const char[] NS_IDOMUIEVENT_IID_STR = "a6cf90c3-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMUIEVENT_IID= + {0xa6cf90c3, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMUIEvent : nsIDOMEvent { + + static const char[] IID_STR = NS_IDOMUIEVENT_IID_STR; + static const nsIID IID = NS_IDOMUIEVENT_IID; + + nsresult GetView(nsIDOMAbstractView *aView); + nsresult GetDetail(PRInt32 *aDetail); + nsresult InitUIEvent(nsAString * typeArg, PRBool canBubbleArg, PRBool cancelableArg, nsIDOMAbstractView viewArg, PRInt32 detailArg); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMWindow.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMWindow.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,47 @@ +module dwt.internal.mozilla.nsIDOMWindow; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMWindowCollection; +import dwt.internal.mozilla.nsIDOMDocument; +import dwt.internal.mozilla.nsIDOMBarProp; +import dwt.internal.mozilla.nsISelection; +import dwt.internal.mozilla.nsStringAPI; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMWINDOW_IID_STR = "a6cf906b-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMWINDOW_IID= + {0xa6cf906b, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMWindow : nsISupports { + + static const char[] IID_STR = NS_IDOMWINDOW_IID_STR; + static const nsIID IID = NS_IDOMWINDOW_IID; + + nsresult GetDocument(nsIDOMDocument *aDocument); + nsresult GetParent(nsIDOMWindow *aParent); + nsresult GetTop(nsIDOMWindow *aTop); + nsresult GetScrollbars(nsIDOMBarProp *aScrollbars); + nsresult GetFrames(nsIDOMWindowCollection *aFrames); + nsresult GetName(nsAString * aName); + nsresult SetName(nsAString * aName); + nsresult GetTextZoom(float *aTextZoom); + nsresult SetTextZoom(float aTextZoom); + nsresult GetScrollX(PRInt32 *aScrollX); + nsresult GetScrollY(PRInt32 *aScrollY); + nsresult ScrollTo(PRInt32 xScroll, PRInt32 yScroll); + nsresult ScrollBy(PRInt32 xScrollDif, PRInt32 yScrollDif); + nsresult GetSelection(nsISelection *_retval); + nsresult ScrollByLines(PRInt32 numLines); + nsresult ScrollByPages(PRInt32 numPages); + nsresult SizeToContent(); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMWindow2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMWindow2.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,24 @@ +module dwt.internal.mozilla.nsIDOMWindow2; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsIDOMEventTarget; + +const char[] NS_IDOMWINDOW2_IID_STR = "65455132-b96a-40ec-adea-52fa22b1028c"; + +const nsIID NS_IDOMWINDOW2_IID= + {0x65455132, 0xb96a, 0x40ec, + [ 0xad, 0xea, 0x52, 0xfa, 0x22, 0xb1, 0x02, 0x8c ]}; + +extern(System) + +interface nsIDOMWindow2 : nsIDOMWindow { + + static const char[] IID_STR = NS_IDOMWINDOW2_IID_STR; + static const nsIID IID = NS_IDOMWINDOW2_IID; + + nsresult GetWindowRoot(nsIDOMEventTarget *aWindowRoot); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDOMWindowCollection.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDOMWindowCollection.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,29 @@ +module dwt.internal.mozilla.nsIDOMWindowCollection; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsStringAPI; + +alias PRUint64 DOMTimeStamp; + +const char[] NS_IDOMWINDOWCOLLECTION_IID_STR = "a6cf906f-15b3-11d2-932e-00805f8add32"; + +const nsIID NS_IDOMWINDOWCOLLECTION_IID= + {0xa6cf906f, 0x15b3, 0x11d2, + [ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 ]}; + +extern(System) + +interface nsIDOMWindowCollection : nsISupports { + + static const char[] IID_STR = NS_IDOMWINDOWCOLLECTION_IID_STR; + static const nsIID IID = NS_IDOMWINDOWCOLLECTION_IID; + + nsresult GetLength(PRUint32 *aLength); + nsresult Item(PRUint32 index, nsIDOMWindow *_retval); + nsresult NamedItem(nsAString * name, nsIDOMWindow *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDebug.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDebug.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,23 @@ +module dwt.internal.mozilla.nsIDebug; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_IDEBUG_IID_STR = "3bf0c3d7-3bd9-4cf2-a971-33572c503e1e"; + +const nsIID NS_IDEBUG_IID= + {0x3bf0c3d7, 0x3bd9, 0x4cf2, + [ 0xa9, 0x71, 0x33, 0x57, 0x2c, 0x50, 0x3e, 0x1e ]}; + +extern(System) +interface nsIDebug : nsISupports { + static const char[] IID_STR = NS_IDEBUG_IID_STR; + static const nsIID IID = NS_IDEBUG_IID; + + nsresult Assertion(char *aStr, char *aExpr, char *aFile, PRInt32 aLine); + nsresult Warning(char *aStr, char *aFile, PRInt32 aLine); + nsresult Break(char *aFile, PRInt32 aLine); + nsresult Abort(char *aFile, PRInt32 aLine); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDirectoryService.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDirectoryService.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,72 @@ +module dwt.internal.mozilla.nsIDirectoryService; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISimpleEnumerator; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIFile; + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IDIRECTORYSERVICEPROVIDER_IID_STR = "bbf8cab0-d43a-11d3-8cc2-00609792278c"; + +const nsIID NS_IDIRECTORYSERVICEPROVIDER_IID= + {0xbbf8cab0, 0xd43a, 0x11d3, + [ 0x8c, 0xc2, 0x00, 0x60, 0x97, 0x92, 0x27, 0x8c ]}; + +extern(System) + +interface nsIDirectoryServiceProvider : nsISupports { + + static const char[] IID_STR = NS_IDIRECTORYSERVICEPROVIDER_IID_STR; + static const nsIID IID = NS_IDIRECTORYSERVICEPROVIDER_IID; + + nsresult GetFile(char *prop, PRBool *persistent, nsIFile *_retval); + +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IDIRECTORYSERVICEPROVIDER2_IID_STR = "2f977d4b-5485-11d4-87e2-0010a4e75ef2"; + +const nsIID NS_IDIRECTORYSERVICEPROVIDER2_IID= + {0x2f977d4b, 0x5485, 0x11d4, + [ 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 ]}; + +extern(System) + +interface nsIDirectoryServiceProvider2 : nsIDirectoryServiceProvider { + + static const char[] IID_STR = NS_IDIRECTORYSERVICEPROVIDER2_IID_STR; + static const nsIID IID = NS_IDIRECTORYSERVICEPROVIDER2_IID; + + nsresult GetFiles(char *prop, nsISimpleEnumerator *_retval); + +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IDIRECTORYSERVICE_IID_STR = "57a66a60-d43a-11d3-8cc2-00609792278c"; + +const nsIID NS_IDIRECTORYSERVICE_IID= + {0x57a66a60, 0xd43a, 0x11d3, + [ 0x8c, 0xc2, 0x00, 0x60, 0x97, 0x92, 0x27, 0x8c ]}; + +extern(System) + +interface nsIDirectoryService : nsISupports { + + static const char[] IID_STR = NS_IDIRECTORYSERVICE_IID_STR; + static const nsIID IID = NS_IDIRECTORYSERVICE_IID; + + nsresult Init(); + nsresult RegisterProvider(nsIDirectoryServiceProvider prov); + nsresult UnregisterProvider(nsIDirectoryServiceProvider prov); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDocShell.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDocShell.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,173 @@ +// FIXME; IID's are not consistant with SWT version + +module dwt.internal.mozilla.nsIDocShell; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIChannel; +import dwt.internal.mozilla.nsIContentViewer; +import dwt.internal.mozilla.nsIURIContentListener; +import dwt.internal.mozilla.nsIChromeEventHandler; +import dwt.internal.mozilla.nsIDocShellLoadInfo; +import dwt.internal.mozilla.nsIDocumentCharsetInfo; +import dwt.internal.mozilla.nsIWebNavigation; +import dwt.internal.mozilla.nsISimpleEnumerator; +import dwt.internal.mozilla.nsIInputStream; +import dwt.internal.mozilla.nsIRequest; +import dwt.internal.mozilla.nsISHEntry; +import dwt.internal.mozilla.nsISecureBrowserUI; +import dwt.internal.mozilla.nsIDOMStorage; +import dwt.internal.mozilla.nsStringAPI; + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IDOCSHELL_IID_STR = "9f0c7461-b9a4-47f6-b88c-421dce1bce66"; + +const nsIID NS_IDOCSHELL_IID= + {0x9f0c7461, 0xb9a4, 0x47f6, + [ 0xb8, 0x8c, 0x42, 0x1d, 0xce, 0x1b, 0xce, 0x66 ]}; + +extern(System) + +interface nsIDocShell : nsISupports { + + static const char[] IID_STR = NS_IDOCSHELL_IID_STR; + static const nsIID IID = NS_IDOCSHELL_IID; + + nsresult LoadURI(nsIURI uri, nsIDocShellLoadInfo loadInfo, PRUint32 aLoadFlags, PRBool firstParty); + nsresult LoadStream(nsIInputStream aStream, nsIURI aURI, nsACString * aContentType, nsACString * aContentCharset, nsIDocShellLoadInfo aLoadInfo); + + enum { INTERNAL_LOAD_FLAGS_NONE = 0 }; + enum { INTERNAL_LOAD_FLAGS_INHERIT_OWNER = 1 }; + enum { INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 2 }; + enum { INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 4 }; + enum { INTERNAL_LOAD_FLAGS_FIRST_LOAD = 8 }; + + nsresult InternalLoad(nsIURI aURI, nsIURI aReferrer, nsISupports aOwner, PRUint32 aFlags, PRUnichar *aWindowTarget, char *aTypeHint, nsIInputStream aPostDataStream, nsIInputStream aHeadersStream, PRUint32 aLoadFlags, nsISHEntry aSHEntry, PRBool firstParty, nsIDocShell *aDocShell, nsIRequest *aRequest); + + nsresult CreateLoadInfo(nsIDocShellLoadInfo *loadInfo); + nsresult PrepareForNewContentModel(); + nsresult SetCurrentURI(nsIURI aURI); + nsresult FirePageHideNotification(PRBool isUnload); + nsresult GetPresContext(nsPresContext * *aPresContext); + nsresult GetPresShell(nsIPresShell * *aPresShell); + nsresult GetEldestPresShell(nsIPresShell * *aEldestPresShell); + nsresult GetContentViewer(nsIContentViewer *aContentViewer); + nsresult GetChromeEventHandler(nsIChromeEventHandler *aChromeEventHandler); + nsresult SetChromeEventHandler(nsIChromeEventHandler aChromeEventHandler); + nsresult GetDocumentCharsetInfo(nsIDocumentCharsetInfo *aDocumentCharsetInfo); + nsresult SetDocumentCharsetInfo(nsIDocumentCharsetInfo aDocumentCharsetInfo); + nsresult GetAllowPlugins(PRBool *aAllowPlugins); + nsresult SetAllowPlugins(PRBool aAllowPlugins); + nsresult GetAllowJavascript(PRBool *aAllowJavascript); + nsresult SetAllowJavascript(PRBool aAllowJavascript); + nsresult GetAllowMetaRedirects(PRBool *aAllowMetaRedirects); + nsresult SetAllowMetaRedirects(PRBool aAllowMetaRedirects); + nsresult GetAllowSubframes(PRBool *aAllowSubframes); + nsresult SetAllowSubframes(PRBool aAllowSubframes); + nsresult GetAllowImages(PRBool *aAllowImages); + nsresult SetAllowImages(PRBool aAllowImages); + + enum { ENUMERATE_FORWARDS = 0 }; + enum { ENUMERATE_BACKWARDS = 1 }; + + nsresult GetDocShellEnumerator(PRInt32 aItemType, PRInt32 aDirection, nsISimpleEnumerator *_retval); + + enum { APP_TYPE_UNKNOWN = 0U }; + enum { APP_TYPE_MAIL = 1U }; + enum { APP_TYPE_EDITOR = 2U }; + + nsresult GetAppType(PRUint32 *aAppType); + nsresult SetAppType(PRUint32 aAppType); + nsresult GetAllowAuth(PRBool *aAllowAuth); + nsresult SetAllowAuth(PRBool aAllowAuth); + nsresult GetZoom(float *aZoom); + nsresult SetZoom(float aZoom); + nsresult GetMarginWidth(PRInt32 *aMarginWidth); + nsresult SetMarginWidth(PRInt32 aMarginWidth); + nsresult GetMarginHeight(PRInt32 *aMarginHeight); + nsresult SetMarginHeight(PRInt32 aMarginHeight); + nsresult GetHasFocus(PRBool *aHasFocus); + nsresult SetHasFocus(PRBool aHasFocus); + nsresult GetCanvasHasFocus(PRBool *aCanvasHasFocus); + nsresult SetCanvasHasFocus(PRBool aCanvasHasFocus); + nsresult TabToTreeOwner(PRBool forward, PRBool *tookFocus); + + enum { BUSY_FLAGS_NONE = 0U }; + enum { BUSY_FLAGS_BUSY = 1U }; + enum { BUSY_FLAGS_BEFORE_PAGE_LOAD = 2U }; + enum { BUSY_FLAGS_PAGE_LOADING = 4U }; + enum { LOAD_CMD_NORMAL = 1U }; + enum { LOAD_CMD_RELOAD = 2U }; + enum { LOAD_CMD_HISTORY = 4U }; + + nsresult GetBusyFlags(PRUint32 *aBusyFlags); + nsresult GetLoadType(PRUint32 *aLoadType); + nsresult SetLoadType(PRUint32 aLoadType); + nsresult IsBeingDestroyed(PRBool *_retval); + nsresult GetIsExecutingOnLoadHandler(PRBool *aIsExecutingOnLoadHandler); + nsresult GetLayoutHistoryState(nsILayoutHistoryState *aLayoutHistoryState); + nsresult SetLayoutHistoryState(nsILayoutHistoryState aLayoutHistoryState); + nsresult GetShouldSaveLayoutState(PRBool *aShouldSaveLayoutState); + nsresult GetSecurityUI(nsISecureBrowserUI *aSecurityUI); + nsresult SetSecurityUI(nsISecureBrowserUI aSecurityUI); + nsresult SuspendRefreshURIs(); + nsresult ResumeRefreshURIs(); + nsresult BeginRestore(nsIContentViewer viewer, PRBool top); + nsresult FinishRestore(); + nsresult GetRestoringDocument(PRBool *aRestoringDocument); + nsresult GetUseErrorPages(PRBool *aUseErrorPages); + nsresult SetUseErrorPages(PRBool aUseErrorPages); + nsresult GetPreviousTransIndex(PRInt32 *aPreviousTransIndex); + nsresult GetLoadedTransIndex(PRInt32 *aLoadedTransIndex); + nsresult HistoryPurged(PRInt32 numEntries); +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IDOCSHELL_MOZILLA_1_8_BRANCH_IID_STR = "45988a14-b240-4d07-ae64-50ecca26e6d8"; + +const nsIID NS_IDOCSHELL_MOZILLA_1_8_BRANCH_IID= + {0x45988a14, 0xb240, 0x4d07, + [ 0xae, 0x64, 0x50, 0xec, 0xca, 0x26, 0xe6, 0xd8 ]}; + +extern(System) + +interface nsIDocShell_MOZILLA_1_8_BRANCH : nsISupports { + + static const char[] IID_STR = NS_IDOCSHELL_MOZILLA_1_8_BRANCH_IID_STR; + static const nsIID IID = NS_IDOCSHELL_MOZILLA_1_8_BRANCH_IID; + + nsresult GetSessionStorageForURI(nsIURI uri, nsIDOMStorage *_retval); + nsresult AddSessionStorage(nsACString * aDomain, nsIDOMStorage storage); + nsresult GetCurrentDocumentChannel(nsIChannel *aCurrentDocumentChannel); +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IDOCSHELL_MOZILLA_1_9_BRANCH_IID_STR = "45988a14-b240-4d07-ae64-50ecca26e6d8"; + +const nsIID NS_IDOCSHELL_MOZILLA_1_9_BRANCH_IID = + {0x45988a14, 0xb240, 0x4d07, + [ 0xae, 0x64, 0x50, 0xec, 0xca, 0x26, 0xe6, 0xd8 ]}; + +extern(System) + +interface nsIDocShell_MOZILLA_1_9_BRANCH : nsISupports { + + static const char[] IID_STR = NS_IDOCSHELL_MOZILLA_1_9_BRANCH_IID_STR; + static const nsIID IID = NS_IDOCSHELL_MOZILLA_1_9_BRANCH_IID; + + nsresult GetSessionStorageForURI(nsIURI uri, nsIDOMStorage *_retval); + nsresult AddSessionStorage(nsACString * aDomain, nsIDOMStorage storage); + nsresult GetCurrentDocumentChannel(nsIChannel *aCurrentDocumentChannel); +} \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDocShellLoadInfo.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDocShellLoadInfo.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,62 @@ +module dwt.internal.mozilla.nsIDocShellLoadInfo; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIInputStream; +import dwt.internal.mozilla.nsISHEntry; + +alias PRInt32 nsDocShellInfoLoadType; + +const char[] NS_IDOCSHELLLOADINFO_IID_STR = "4f813a88-7aca-4607-9896-d97270cdf15e"; + +const nsIID NS_IDOCSHELLLOADINFO_IID= + {0x4f813a88, 0x7aca, 0x4607, + [ 0x98, 0x96, 0xd9, 0x72, 0x70, 0xcd, 0xf1, 0x5e ]}; + +extern(System) + +interface nsIDocShellLoadInfo : nsISupports { + + static const char[] IID_STR = NS_IDOCSHELLLOADINFO_IID_STR; + static const nsIID IID = NS_IDOCSHELLLOADINFO_IID; + + nsresult GetReferrer(nsIURI *aReferrer); + nsresult SetReferrer(nsIURI aReferrer); + nsresult GetOwner(nsISupports *aOwner); + nsresult SetOwner(nsISupports aOwner); + nsresult GetInheritOwner(PRBool *aInheritOwner); + nsresult SetInheritOwner(PRBool aInheritOwner); + + enum { loadNormal = 0 }; + enum { loadNormalReplace = 1 }; + enum { loadHistory = 2 }; + enum { loadReloadNormal = 3 }; + enum { loadReloadBypassCache = 4 }; + enum { loadReloadBypassProxy = 5 }; + enum { loadReloadBypassProxyAndCache = 6 }; + enum { loadLink = 7 }; + enum { loadRefresh = 8 }; + enum { loadReloadCharsetChange = 9 }; + enum { loadBypassHistory = 10 }; + enum { loadStopContent = 11 }; + enum { loadStopContentAndReplace = 12 }; + enum { loadNormalExternal = 13 }; + + nsresult GetLoadType(nsDocShellInfoLoadType *aLoadType); + nsresult SetLoadType(nsDocShellInfoLoadType aLoadType); + nsresult GetSHEntry(nsISHEntry *aSHEntry); + nsresult SetSHEntry(nsISHEntry aSHEntry); + nsresult GetTarget(PRUnichar * *aTarget); + nsresult SetTarget(PRUnichar * aTarget); + nsresult GetPostDataStream(nsIInputStream *aPostDataStream); + nsresult SetPostDataStream(nsIInputStream aPostDataStream); + nsresult GetHeadersStream(nsIInputStream *aHeadersStream); + nsresult SetHeadersStream(nsIInputStream aHeadersStream); + nsresult GetSendReferrer(PRBool *aSendReferrer); + nsresult SetSendReferrer(PRBool aSendReferrer); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDocShellTreeItem.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDocShellTreeItem.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,45 @@ +module dwt.internal.mozilla.nsIDocShellTreeItem; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDocShellTreeOwner; + +const char[] NS_IDOCSHELLTREEITEM_IID_STR = "7d935d63-6d2a-4600-afb5-9a4f7d68b825"; + +const nsIID NS_IDOCSHELLTREEITEM_IID= + {0x7d935d63, 0x6d2a, 0x4600, + [ 0xaf, 0xb5, 0x9a, 0x4f, 0x7d, 0x68, 0xb8, 0x25 ]}; + +extern(System) + +interface nsIDocShellTreeItem : nsISupports { + + static const char[] IID_STR = NS_IDOCSHELLTREEITEM_IID_STR; + static const nsIID IID = NS_IDOCSHELLTREEITEM_IID; + + nsresult GetName(PRUnichar * *aName); + nsresult SetName(PRUnichar * aName); + nsresult NameEquals(PRUnichar *name, PRBool *_retval); + + enum { typeChrome = 0 }; + enum { typeContent = 1 }; + enum { typeContentWrapper = 2 }; + enum { typeChromeWrapper = 3 }; + enum { typeAll = 2147483647 }; + + nsresult GetItemType(PRInt32 *aItemType); + nsresult SetItemType(PRInt32 aItemType); + nsresult GetParent(nsIDocShellTreeItem *aParent); + nsresult GetSameTypeParent(nsIDocShellTreeItem *aSameTypeParent); + nsresult GetRootTreeItem(nsIDocShellTreeItem *aRootTreeItem); + nsresult GetSameTypeRootTreeItem(nsIDocShellTreeItem *aSameTypeRootTreeItem); + nsresult FindItemWithName(PRUnichar *name, nsISupports aRequestor, nsIDocShellTreeItem aOriginalRequestor, nsIDocShellTreeItem *_retval); + nsresult GetTreeOwner(nsIDocShellTreeOwner *aTreeOwner); + nsresult SetTreeOwner(nsIDocShellTreeOwner treeOwner); + nsresult GetChildOffset(PRInt32 *aChildOffset); + nsresult SetChildOffset(PRInt32 aChildOffset); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDocShellTreeOwner.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDocShellTreeOwner.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,57 @@ +module dwt.internal.mozilla.nsIDocShellTreeOwner; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDocShellTreeItem; +import dwt.internal.mozilla.nsStringAPI; + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IDOCSHELLTREEOWNER_IID_STR = "9e508466-5ebb-4618-abfa-9ad47bed0b2e"; + +const nsIID NS_IDOCSHELLTREEOWNER_IID= + {0x9e508466, 0x5ebb, 0x4618, + [ 0xab, 0xfa, 0x9a, 0xd4, 0x7b, 0xed, 0x0b, 0x2e ]}; + +extern(System) + +interface nsIDocShellTreeOwner : nsISupports { + + static const char[] IID_STR = NS_IDOCSHELLTREEOWNER_IID_STR; + static const nsIID IID = NS_IDOCSHELLTREEOWNER_IID; + + nsresult FindItemWithName(PRUnichar *name, nsIDocShellTreeItem aRequestor, nsIDocShellTreeItem aOriginalRequestor, nsIDocShellTreeItem *_retval); + nsresult ContentShellAdded(nsIDocShellTreeItem aContentShell, PRBool aPrimary, PRUnichar *aID); + nsresult GetPrimaryContentShell(nsIDocShellTreeItem *aPrimaryContentShell); + nsresult SizeShellTo(nsIDocShellTreeItem shell, PRInt32 cx, PRInt32 cy); + nsresult SetPersistence(PRBool aPersistPosition, PRBool aPersistSize, PRBool aPersistSizeMode); + nsresult GetPersistence(PRBool *aPersistPosition, PRBool *aPersistSize, PRBool *aPersistSizeMode); + +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IDOCSHELLTREEOWNER_MOZILLA_1_8_BRANCH_IID_STR = "3c2a6927-e923-4ea8-bbda-a335c768ce4e"; + +const nsIID NS_IDOCSHELLTREEOWNER_MOZILLA_1_8_BRANCH_IID= + {0x3c2a6927, 0xe923, 0x4ea8, + [ 0xbb, 0xda, 0xa3, 0x35, 0xc7, 0x68, 0xce, 0x4e ]}; + +extern(System) + +interface nsIDocShellTreeOwner_MOZILLA_1_8_BRANCH : nsIDocShellTreeOwner { + + static const char[] IID_STR = NS_IDOCSHELLTREEOWNER_MOZILLA_1_8_BRANCH_IID_STR; + static const nsIID IID = NS_IDOCSHELLTREEOWNER_MOZILLA_1_8_BRANCH_IID; + + nsresult ContentShellAdded2(nsIDocShellTreeItem aContentShell, PRBool aPrimary, PRBool aTargetable, nsAString * aID); + nsresult ContentShellRemoved(nsIDocShellTreeItem aContentShell); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDocumentCharsetInfo.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDocumentCharsetInfo.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,32 @@ +module dwt.internal.mozilla.nsIDocumentCharsetInfo; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIAtom; + +const char[] NS_IDOCUMENTCHARSETINFO_IID_STR = "2d40b291-01e1-11d4-9d0e-0050040007b2"; + +const nsIID NS_IDOCUMENTCHARSETINFO_IID= + {0x2d40b291, 0x01e1, 0x11d4, + [ 0x9d, 0x0e, 0x00, 0x50, 0x04, 0x00, 0x07, 0xb2 ]}; + +extern(System) + +interface nsIDocumentCharsetInfo : nsISupports { + + static const char[] IID_STR = NS_IDOCUMENTCHARSETINFO_IID_STR; + static const nsIID IID = NS_IDOCUMENTCHARSETINFO_IID; + + nsresult GetForcedCharset(nsIAtom *aForcedCharset); + nsresult SetForcedCharset(nsIAtom aForcedCharset); + nsresult GetForcedDetector(PRBool *aForcedDetector); + nsresult SetForcedDetector(PRBool aForcedDetector); + nsresult GetParentCharset(nsIAtom *aParentCharset); + nsresult SetParentCharset(nsIAtom aParentCharset); + nsresult GetParentCharsetSource(PRInt32 *aParentCharsetSource); + nsresult SetParentCharsetSource(PRInt32 aParentCharsetSource); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIDownload.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIDownload.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,54 @@ +module dwt.internal.mozilla.nsIDownload; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsITransfer; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsILocalFile; +import dwt.internal.mozilla.nsIObserver; +import dwt.internal.mozilla.nsICancelable; +import dwt.internal.mozilla.nsIMIMEInfo; + +const char[] NS_IDOWNLOAD_IID_STR = "9e1fd9f2-9727-4926-85cd-f16c375bba6d"; + +const nsIID NS_IDOWNLOAD_IID= + {0x9e1fd9f2, 0x9727, 0x4926, + [ 0x85, 0xcd, 0xf1, 0x6c, 0x37, 0x5b, 0xba, 0x6d ]}; + +extern(System) + +interface nsIDownload : nsITransfer { + + static const char[] IID_STR = NS_IDOWNLOAD_IID_STR; + static const nsIID IID = NS_IDOWNLOAD_IID; + + nsresult GetTargetFile(nsILocalFile *aTargetFile); + nsresult GetPercentComplete(PRInt32 *aPercentComplete); + nsresult GetAmountTransferred(PRUint64 *aAmountTransferred); + nsresult GetSize(PRUint64 *aSize); + nsresult GetSource(nsIURI *aSource); + nsresult GetTarget(nsIURI *aTarget); + nsresult GetCancelable(nsICancelable *aCancelable); + nsresult GetDisplayName(PRUnichar * *aDisplayName); + nsresult GetStartTime(PRInt64 *aStartTime); + nsresult GetMIMEInfo(nsIMIMEInfo *aMIMEInfo); + +} + +const char[] NS_IDOWNLOAD_MOZILLA_1_8_BRANCH_IID_STR = "ff76f0c7-caaf-4e64-8896-154348322696"; + +const nsIID NS_IDOWNLOAD_MOZILLA_1_8_BRANCH_IID= + {0xff76f0c7, 0xcaaf, 0x4e64, + [ 0x88, 0x96, 0x15, 0x43, 0x48, 0x32, 0x26, 0x96 ]}; + +extern(System) + +interface nsIDownload_MOZILLA_1_8_BRANCH : nsIDownload { + + static const char[] IID_STR = NS_IDOWNLOAD_MOZILLA_1_8_BRANCH_IID_STR; + static const nsIID IID = NS_IDOWNLOAD_MOZILLA_1_8_BRANCH_IID; + + nsresult GetSpeed(double *aSpeed); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIEmbeddingSiteWindow.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIEmbeddingSiteWindow.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,34 @@ +module dwt.internal.mozilla.nsIEmbeddingSiteWindow; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_IEMBEDDINGSITEWINDOW_IID_STR = "3e5432cd-9568-4bd1-8cbe-d50aba110743"; + +const nsIID NS_IEMBEDDINGSITEWINDOW_IID= + {0x3e5432cd, 0x9568, 0x4bd1, + [ 0x8c, 0xbe, 0xd5, 0x0a, 0xba, 0x11, 0x07, 0x43 ]}; + +extern(System) + +interface nsIEmbeddingSiteWindow : nsISupports { + + static const char[] IID_STR = NS_IEMBEDDINGSITEWINDOW_IID_STR; + static const nsIID IID = NS_IEMBEDDINGSITEWINDOW_IID; + + enum { DIM_FLAGS_POSITION = 1U }; + enum { DIM_FLAGS_SIZE_INNER = 2U }; + enum { DIM_FLAGS_SIZE_OUTER = 4U }; + + nsresult SetDimensions(PRUint32 flags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy); + nsresult GetDimensions(PRUint32 flags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy); + nsresult SetFocus(); + nsresult GetVisibility(PRBool *aVisibility); + nsresult SetVisibility(PRBool aVisibility); + nsresult GetTitle(PRUnichar * *aTitle); + nsresult SetTitle(PRUnichar * aTitle); + nsresult GetSiteWindow(void * *aSiteWindow); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIEmbeddingSiteWindow2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIEmbeddingSiteWindow2.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,23 @@ +module dwt.internal.mozilla.nsIEmbeddingSiteWindow2; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIEmbeddingSiteWindow; + +const char[] NS_IEMBEDDINGSITEWINDOW2_IID_STR = "e932bf55-0a64-4beb-923a-1f32d3661044"; + +const nsIID NS_IEMBEDDINGSITEWINDOW2_IID= + {0xe932bf55, 0x0a64, 0x4beb, + [ 0x92, 0x3a, 0x1f, 0x32, 0xd3, 0x66, 0x10, 0x44 ]}; + +extern(System) + +interface nsIEmbeddingSiteWindow2 : nsIEmbeddingSiteWindow { + + static const char[] IID_STR = NS_IEMBEDDINGSITEWINDOW2_IID_STR; + static const nsIID IID = NS_IEMBEDDINGSITEWINDOW2_IID; + + nsresult Blur(); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIEnumerator.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIEnumerator.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,52 @@ +module dwt.internal.mozilla.nsIEnumerator; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IENUMERATOR_IID_STR = "ad385286-cbc4-11d2-8cca-0060b0fc14a3"; + +const nsIID NS_IENUMERATOR_IID= + {0xad385286, 0xcbc4, 0x11d2, + [ 0x8c, 0xca, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3 ]}; + +extern(System) + +interface nsIEnumerator : nsISupports { + + static const char[] IID_STR = NS_IENUMERATOR_IID_STR; + static const nsIID IID = NS_IENUMERATOR_IID; + + nsresult First(); + nsresult Next(); + nsresult CurrentItem(nsISupports *_retval); + nsresult IsDone(); + +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IBIDIRECTIONALENUMERATOR_IID_STR = "75f158a0-cadd-11d2-8cca-0060b0fc14a3"; + +const nsIID NS_IBIDIRECTIONALENUMERATOR_IID= + {0x75f158a0, 0xcadd, 0x11d2, + [ 0x8c, 0xca, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3 ]}; + +extern(System) + +interface nsIBidirectionalEnumerator : nsIEnumerator { + + static const char[] IID_STR = NS_IBIDIRECTIONALENUMERATOR_IID_STR; + static const nsIID IID = NS_IBIDIRECTIONALENUMERATOR_IID; + + nsresult Last(); + nsresult Prev(); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIEventQueue.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIEventQueue.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,39 @@ +module dwt.internal.mozilla.nsIEventQueue; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIEventTarget; + +const char[] NS_IEVENTQUEUE_IID_STR = "176afb41-00a4-11d3-9f2a-00400553eef0"; +const nsIID NS_IEVENTQUEUE_IID= + {0x176afb41, 0x00a4, 0x11d3, + [ 0x9f, 0x2a, 0x00, 0x40, 0x05, 0x53, 0xee, 0xf0 ]}; + +extern(System) + +interface nsIEventQueue : nsIEventTarget { + static const char[] IID_STR = NS_IEVENTQUEUE_IID_STR; + static const nsIID IID = NS_IEVENTQUEUE_IID; + + nsresult InitEvent(PLEvent * aEvent, void * owner, PLHandleEventProc handler, PLDestroyEventProc destructor); + nsresult PostSynchronousEvent(PLEvent * aEvent, void * *aResult); + nsresult PendingEvents(PRBool *_retval); + nsresult ProcessPendingEvents(); + nsresult EventLoop(); + nsresult EventAvailable(PRBool * aResult); + nsresult GetEvent(PLEvent * *_retval); + nsresult HandleEvent(PLEvent * aEvent); + nsresult WaitForEvent(PLEvent * *_retval); + PRInt32 GetEventQueueSelectFD(); + nsresult Init(PRBool aNative); + nsresult InitFromPRThread(PRThread * thread, PRBool aNative); + nsresult InitFromPLQueue(PLEventQueue * aQueue); + nsresult EnterMonitor(); + nsresult ExitMonitor(); + nsresult RevokeEvents(void * owner); + nsresult GetPLEventQueue(PLEventQueue * *_retval); + nsresult IsQueueNative(PRBool *_retval); + nsresult StopAcceptingEvents(); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIEventTarget.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIEventTarget.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,23 @@ +module dwt.internal.mozilla.nsIEventTarget; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsID; + +const char[] NS_IEVENTTARGET_IID_STR = "ea99ad5b-cc67-4efb-97c9-2ef620a59f2a"; + +const nsIID NS_IEVENTTARGET_IID= + {0xea99ad5b, 0xcc67, 0x4efb, + [ 0x97, 0xc9, 0x2e, 0xf6, 0x20, 0xa5, 0x9f, 0x2a ]}; + +extern(System) + +interface nsIEventTarget : nsISupports { + + static const char[] IID_STR = NS_IEVENTTARGET_IID_STR; + static const nsIID IID = NS_IEVENTTARGET_IID; + + nsresult PostEvent(PLEvent * aEvent); + nsresult IsOnCurrentThread(PRBool *_retval); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIExternalHelperAppService.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIExternalHelperAppService.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,89 @@ +module dwt.internal.mozilla.nsIExternalHelperAppService; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsICancelable; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIRequest; +import dwt.internal.mozilla.nsIStreamListener; +import dwt.internal.mozilla.nsIFile; +import dwt.internal.mozilla.nsIMIMEInfo; +import dwt.internal.mozilla.nsIWebProgressListener2; +import dwt.internal.mozilla.nsIInterfaceRequestor; +import dwt.internal.mozilla.nsStringAPI; + +import dwt.internal.mozilla.prtime; + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IEXTERNALHELPERAPPSERVICE_IID_STR = "0ea90cf3-2dd9-470f-8f76-f141743c5678"; + +const nsIID NS_IEXTERNALHELPERAPPSERVICE_IID= + {0x0ea90cf3, 0x2dd9, 0x470f, + [ 0x8f, 0x76, 0xf1, 0x41, 0x74, 0x3c, 0x56, 0x78 ]}; + +extern(System) + +interface nsIExternalHelperAppService : nsISupports { + + static const char[] IID_STR = NS_IEXTERNALHELPERAPPSERVICE_IID_STR; + static const nsIID IID = NS_IEXTERNALHELPERAPPSERVICE_IID; + + nsresult DoContent(nsACString * aMimeContentType, nsIRequest aRequest, nsIInterfaceRequestor aWindowContext, nsIStreamListener *_retval); + nsresult ApplyDecodingForExtension(nsACString * aExtension, nsACString * aEncodingType, PRBool *_retval); + +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_PIEXTERNALAPPLAUNCHER_IID_STR = "d0b5d7d3-9565-403d-9fb5-e5089c4567c6"; + +const nsIID NS_PIEXTERNALAPPLAUNCHER_IID= + {0xd0b5d7d3, 0x9565, 0x403d, + [ 0x9f, 0xb5, 0xe5, 0x08, 0x9c, 0x45, 0x67, 0xc6 ]}; + +extern(System) + +interface nsPIExternalAppLauncher : nsISupports { + + static const char[] IID_STR = NS_PIEXTERNALAPPLAUNCHER_IID_STR; + static const nsIID IID = NS_PIEXTERNALAPPLAUNCHER_IID; + + nsresult DeleteTemporaryFileOnExit(nsIFile aTemporaryFile); + +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IHELPERAPPLAUNCHER_IID_STR = "99a0882d-2ff9-4659-9952-9ac531ba5592"; + +const nsIID NS_IHELPERAPPLAUNCHER_IID= + {0x99a0882d, 0x2ff9, 0x4659, + [ 0x99, 0x52, 0x9a, 0xc5, 0x31, 0xba, 0x55, 0x92 ]}; + +extern(System) + +interface nsIHelperAppLauncher : nsICancelable { + + static const char[] IID_STR = NS_IHELPERAPPLAUNCHER_IID_STR; + static const nsIID IID = NS_IHELPERAPPLAUNCHER_IID; + + nsresult GetMIMEInfo(nsIMIMEInfo *aMIMEInfo); + nsresult GetSource(nsIURI *aSource); + nsresult GetSuggestedFileName(nsAString * aSuggestedFileName); + nsresult SaveToDisk(nsIFile aNewFileLocation, PRBool aRememberThisPreference); + nsresult LaunchWithApplication(nsIFile aApplication, PRBool aRememberThisPreference); + nsresult SetWebProgressListener(nsIWebProgressListener2 aWebProgressListener); + nsresult CloseProgressWindow(); + nsresult GetTargetFile(nsIFile *aTargetFile); + nsresult GetTimeDownloadStarted(PRTime *aTimeDownloadStarted); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIFactory.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIFactory.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,23 @@ + +module dwt.internal.mozilla.nsIFactory; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_IFACTORY_IID_STR = "00000001-0000-0000-c000-000000000046"; + +const nsIID NS_IFACTORY_IID= + {0x00000001, 0x0000, 0x0000, + [ 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 ]}; + +extern(System) + +interface nsIFactory : nsISupports { + + static const char[] IID_STR = NS_IFACTORY_IID_STR; + static const nsIID IID = NS_IFACTORY_IID; + + nsresult CreateInstance(nsISupports aOuter, nsIID * iid, void * *result); + nsresult LockFactory(PRBool lock); +} \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIFile.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIFile.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,70 @@ +module dwt.internal.mozilla.nsIFile; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsISimpleEnumerator; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IFILE_IID_STR = "c8c0a080-0868-11d3-915f-d9d889d48e3c"; + +const nsIID NS_IFILE_IID= + {0xc8c0a080, 0x0868, 0x11d3, + [ 0x91, 0x5f, 0xd9, 0xd8, 0x89, 0xd4, 0x8e, 0x3c ]}; + +extern(System) + +interface nsIFile : nsISupports { + static const char[] IID_STR = NS_IFILE_IID_STR; + static const nsIID IID = NS_IFILE_IID; + + enum { NORMAL_FILE_TYPE = 0U }; + enum { DIRECTORY_TYPE = 1U }; + + nsresult Append(nsAString * node); + nsresult AppendNative(nsACString * node); + nsresult Normalize(); + nsresult Create(PRUint32 type, PRUint32 permissions); + nsresult GetLeafName(nsAString * aLeafName); + nsresult SetLeafName(nsAString * aLeafName); + nsresult GetNativeLeafName(nsACString * aNativeLeafName); + nsresult SetNativeLeafName(nsACString * aNativeLeafName); + nsresult CopyTo(nsIFile newParentDir, nsAString * newName); + nsresult CopyToNative(nsIFile newParentDir, nsACString * newName); + nsresult CopyToFollowingLinks(nsIFile newParentDir, nsAString * newName); + nsresult CopyToFollowingLinksNative(nsIFile newParentDir, nsACString * newName); + nsresult MoveTo(nsIFile newParentDir, nsAString * newName); + nsresult MoveToNative(nsIFile newParentDir, nsACString * newName); + nsresult Remove(PRBool recursive); + nsresult GetPermissions(PRUint32 *aPermissions); + nsresult SetPermissions(PRUint32 aPermissions); + nsresult GetPermissionsOfLink(PRUint32 *aPermissionsOfLink); + nsresult SetPermissionsOfLink(PRUint32 aPermissionsOfLink); + nsresult GetLastModifiedTime(PRInt64 *aLastModifiedTime); + nsresult SetLastModifiedTime(PRInt64 aLastModifiedTime); + nsresult GetLastModifiedTimeOfLink(PRInt64 *aLastModifiedTimeOfLink); + nsresult SetLastModifiedTimeOfLink(PRInt64 aLastModifiedTimeOfLink); + nsresult GetFileSize(PRInt64 *aFileSize); + nsresult SetFileSize(PRInt64 aFileSize); + nsresult GetFileSizeOfLink(PRInt64 *aFileSizeOfLink); + nsresult GetTarget(nsAString * aTarget); + nsresult GetNativeTarget(nsACString * aNativeTarget); + nsresult GetPath(nsAString * aPath); + nsresult GetNativePath(nsACString * aNativePath); + nsresult Exists(PRBool *_retval); + nsresult IsWritable(PRBool *_retval); + nsresult IsReadable(PRBool *_retval); + nsresult IsExecutable(PRBool *_retval); + nsresult IsHidden(PRBool *_retval); + nsresult IsDirectory(PRBool *_retval); + nsresult IsFile(PRBool *_retval); + nsresult IsSymlink(PRBool *_retval); + nsresult IsSpecial(PRBool *_retval); + nsresult CreateUnique(PRUint32 type, PRUint32 permissions); + nsresult Clone(nsIFile *_retval); + nsresult Equals(nsIFile inFile, PRBool *_retval); + nsresult Contains(nsIFile inFile, PRBool recur, PRBool *_retval); + nsresult GetParent(nsIFile *aParent); + nsresult GetDirectoryEntries(nsISimpleEnumerator *aDirectoryEntries); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIFilePicker.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIFilePicker.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,57 @@ +module dwt.internal.mozilla.nsIFilePicker; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsILocalFile; +import dwt.internal.mozilla.nsIFileURL; +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsISimpleEnumerator; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IFILEPICKER_IID_STR = "80faf095-c807-4558-a2cc-185ed70754ea"; + +const nsIID NS_IFILEPICKER_IID= + {0x80faf095, 0xc807, 0x4558, + [ 0xa2, 0xcc, 0x18, 0x5e, 0xd7, 0x07, 0x54, 0xea ]}; + +extern(System) + +interface nsIFilePicker : nsISupports { + + static const char[] IID_STR = NS_IFILEPICKER_IID_STR; + static const nsIID IID = NS_IFILEPICKER_IID; + + enum { modeOpen = 0 }; + enum { modeSave = 1 }; + enum { modeGetFolder = 2 }; + enum { modeOpenMultiple = 3 }; + enum { returnOK = 0 }; + enum { returnCancel = 1 }; + enum { returnReplace = 2 }; + enum { filterAll = 1 }; + enum { filterHTML = 2 }; + enum { filterText = 4 }; + enum { filterImages = 8 }; + enum { filterXML = 16 }; + enum { filterXUL = 32 }; + enum { filterApps = 64 }; + + nsresult Init(nsIDOMWindow parent, nsAString * title, PRInt16 mode); + nsresult AppendFilters(PRInt32 filterMask); + nsresult AppendFilter(nsAString * title, nsAString * filter); + nsresult GetDefaultString(nsAString * aDefaultString); + nsresult SetDefaultString(nsAString * aDefaultString); + nsresult GetDefaultExtension(nsAString * aDefaultExtension); + nsresult SetDefaultExtension(nsAString * aDefaultExtension); + nsresult GetFilterIndex(PRInt32 *aFilterIndex); + nsresult SetFilterIndex(PRInt32 aFilterIndex); + nsresult GetDisplayDirectory(nsILocalFile *aDisplayDirectory); + nsresult SetDisplayDirectory(nsILocalFile aDisplayDirectory); + nsresult GetFile(nsILocalFile *aFile); + nsresult GetFileURL(nsIFileURL *aFileURL); + nsresult GetFiles(nsISimpleEnumerator *aFiles); + nsresult Show(PRInt16 *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIFileURL.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIFileURL.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,25 @@ +module dwt.internal.mozilla.nsIFileURL; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIURL; +import dwt.internal.mozilla.nsIFile; + +const char[] NS_IFILEURL_IID_STR = "d26b2e2e-1dd1-11b2-88f3-8545a7ba7949"; + +const nsIID NS_IFILEURL_IID= + {0xd26b2e2e, 0x1dd1, 0x11b2, + [ 0x88, 0xf3, 0x85, 0x45, 0xa7, 0xba, 0x79, 0x49 ]}; + +extern(System) + +interface nsIFileURL : nsIURL { + + static const char[] IID_STR = NS_IFILEURL_IID_STR; + static const nsIID IID = NS_IFILEURL_IID; + + nsresult GetFile(nsIFile *aFile); + nsresult SetFile(nsIFile aFile); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIHelperAppLauncherDialog.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIHelperAppLauncherDialog.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,29 @@ +module dwt.internal.mozilla.nsIHelperAppLauncherDialog; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIExternalHelperAppService; +import dwt.internal.mozilla.nsILocalFile; + +const char[] NS_IHELPERAPPLAUNCHERDIALOG_IID_STR = "64355793-988d-40a5-ba8e-fcde78cac631"; + +const nsIID NS_IHELPERAPPLAUNCHERDIALOG_IID= + {0x64355793, 0x988d, 0x40a5, + [ 0xba, 0x8e, 0xfc, 0xde, 0x78, 0xca, 0xc6, 0x31 ]}; + +extern(System) + +interface nsIHelperAppLauncherDialog : nsISupports { + + static const char[] IID_STR = NS_IHELPERAPPLAUNCHERDIALOG_IID_STR; + static const nsIID IID = NS_IHELPERAPPLAUNCHERDIALOG_IID; + + enum { REASON_CANTHANDLE = 0U }; + enum { REASON_SERVERREQUEST = 1U }; + enum { REASON_TYPESNIFFED = 2U }; + nsresult Show(nsIHelperAppLauncher aLauncher, nsISupports aContext, PRUint32 aReason); + nsresult PromptForSaveToFile(nsIHelperAppLauncher aLauncher, nsISupports aWindowContext, PRUnichar *aDefaultFile, PRUnichar *aSuggestedFileExtension, nsILocalFile *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIHistoryEntry.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIHistoryEntry.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,27 @@ +module dwt.internal.mozilla.nsIHistoryEntry; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIURI; + +const char[] NS_IHISTORYENTRY_IID_STR = "a41661d4-1417-11d5-9882-00c04fa02f40"; + +const nsIID NS_IHISTORYENTRY_IID= + {0xa41661d4, 0x1417, 0x11d5, + [ 0x98, 0x82, 0x00, 0xc0, 0x4f, 0xa0, 0x2f, 0x40 ]}; + +extern(System) + +interface nsIHistoryEntry : nsISupports { + + static const char[] IID_STR = NS_IHISTORYENTRY_IID_STR; + static const nsIID IID = NS_IHISTORYENTRY_IID; + + nsresult GetURI(nsIURI *aURI); + nsresult GetTitle(PRUnichar * *aTitle); + nsresult GetIsSubFrame(PRBool *aIsSubFrame); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIIOService.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIIOService.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,37 @@ +module dwt.internal.mozilla.nsIIOService; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIProtocolHandler; +import dwt.internal.mozilla.nsIChannel; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIFile; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IIOSERVICE_IID_STR = "bddeda3f-9020-4d12-8c70-984ee9f7935e"; + +const nsIID NS_IIOSERVICE_IID= + {0xbddeda3f, 0x9020, 0x4d12, + [ 0x8c, 0x70, 0x98, 0x4e, 0xe9, 0xf7, 0x93, 0x5e ]}; + +extern(System) + +interface nsIIOService : nsISupports { + + static const char[] IID_STR = NS_IIOSERVICE_IID_STR; + static const nsIID IID = NS_IIOSERVICE_IID; + + nsresult GetProtocolHandler(char *aScheme, nsIProtocolHandler *_retval); + nsresult GetProtocolFlags(char *aScheme, PRUint32 *_retval); + nsresult NewURI(nsACString * aSpec, char *aOriginCharset, nsIURI aBaseURI, nsIURI *_retval); + nsresult NewFileURI(nsIFile aFile, nsIURI *_retval); + nsresult NewChannelFromURI(nsIURI aURI, nsIChannel *_retval); + nsresult NewChannel(nsACString * aSpec, char *aOriginCharset, nsIURI aBaseURI, nsIChannel *_retval); + nsresult GetOffline(PRBool *aOffline); + nsresult SetOffline(PRBool aOffline); + nsresult AllowPort(PRInt32 aPort, char *aScheme, PRBool *_retval); + nsresult ExtractScheme(nsACString * urlString, nsACString * _retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIIOService2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIIOService2.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,24 @@ +module dwt.internal.mozilla.nsIIOService2; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIIOService; + +const char[] NS_IIOSERVICE2_IID_STR = "d44fe6d4-ee35-4789-886a-eb8f0554d04e"; + +const nsIID NS_IIOSERVICE2_IID= + {0xd44fe6d4, 0xee35, 0x4789, + [ 0x88, 0x6a, 0xeb, 0x8f, 0x05, 0x54, 0xd0, 0x4e ]}; + +extern(System) + +interface nsIIOService2 : nsIIOService { + + static const char[] IID_STR = NS_IIOSERVICE2_IID_STR; + static const nsIID IID = NS_IIOSERVICE2_IID; + + nsresult GetManageOfflineStatus(PRBool *aManageOfflineStatus); + nsresult SetManageOfflineStatus(PRBool aManageOfflineStatus); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIInputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIInputStream.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,34 @@ +module dwt.internal.mozilla.nsIInputStream; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +typedef nsresult function(nsIInputStream aInStream, + void *aClosure, + byte *aFromSegment, + PRUint32 aToOffset, + PRUint32 aCount, + PRUint32 *aWriteCount) nsWriteSegmentFun; + +const char[] NS_IINPUTSTREAM_IID_STR = "fa9c7f6c-61b3-11d4-9877-00c04fa0cf4a"; + +const nsIID NS_IINPUTSTREAM_IID= + {0xfa9c7f6c, 0x61b3, 0x11d4, + [ 0x98, 0x77, 0x00, 0xc0, 0x4f, 0xa0, 0xcf, 0x4a ]}; + +extern(System) + +interface nsIInputStream : nsISupports { + + static const char[] IID_STR = NS_IINPUTSTREAM_IID_STR; + static const nsIID IID = NS_IINPUTSTREAM_IID; + + nsresult Close(); + nsresult Available(PRUint32 *_retval); + nsresult Read(byte * aBuf, PRUint32 aCount, PRUint32 *_retval); + nsresult ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval); + nsresult IsNonBlocking(PRBool *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIInterfaceRequestor.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIInterfaceRequestor.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,23 @@ +module dwt.internal.mozilla.nsIInterfaceRequestor; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_IINTERFACEREQUESTOR_IID_STR = "033a1470-8b2a-11d3-af88-00a024ffc08c"; + +const nsIID NS_IINTERFACEREQUESTOR_IID= + {0x033a1470, 0x8b2a, 0x11d3, + [ 0xaf, 0x88, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c ]}; + +extern(System) + +interface nsIInterfaceRequestor : nsISupports { + + static const char[] IID_STR = NS_IINTERFACEREQUESTOR_IID_STR; + static const nsIID IID = NS_IINTERFACEREQUESTOR_IID; + + nsresult GetInterface(nsIID * uuid, void * *result); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIJSContextStack.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIJSContextStack.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,75 @@ +module dwt.internal.mozilla.nsIJSContextStack; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IJSCONTEXTSTACK_IID_STR = "c67d8270-3189-11d3-9885-006008962422"; + +const nsIID NS_IJSCONTEXTSTACK_IID= + {0xc67d8270, 0x3189, 0x11d3, + [ 0x98, 0x85, 0x00, 0x60, 0x08, 0x96, 0x24, 0x22 ]}; + +extern(System) + +interface nsIJSContextStack : nsISupports { + + static const char[] IID_STR = NS_IJSCONTEXTSTACK_IID_STR; + static const nsIID IID = NS_IJSCONTEXTSTACK_IID; + + nsresult GetCount(PRInt32 *aCount); + nsresult Peek(JSContext * *_retval); + nsresult Pop(JSContext * *_retval); + nsresult Push(JSContext * cx); + +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IJSCONTEXTSTACKITERATOR_IID_STR = "c7e6b7aa-fc12-4ca7-b140-98c38b698961"; + +const nsIID NS_IJSCONTEXTSTACKITERATOR_IID= + {0xc7e6b7aa, 0xfc12, 0x4ca7, + [ 0xb1, 0x40, 0x98, 0xc3, 0x8b, 0x69, 0x89, 0x61 ]}; + +extern(System) + +interface nsIJSContextStackIterator : nsISupports { + + static const char[] IID_STR = NS_IJSCONTEXTSTACKITERATOR_IID_STR; + static const nsIID IID = NS_IJSCONTEXTSTACKITERATOR_IID; + + nsresult Reset(nsIJSContextStack stack); + nsresult Done(PRBool *_retval); + nsresult Prev(JSContext * *_retval); + +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_ITHREADJSCONTEXTSTACK_IID_STR = "a1339ae0-05c1-11d4-8f92-0010a4e73d9a"; + +const nsIID NS_ITHREADJSCONTEXTSTACK_IID= + {0xa1339ae0, 0x05c1, 0x11d4, + [ 0x8f, 0x92, 0x00, 0x10, 0xa4, 0xe7, 0x3d, 0x9a ]}; + +extern(System) + +interface nsIThreadJSContextStack : nsIJSContextStack { + + static const char[] IID_STR = NS_ITHREADJSCONTEXTSTACK_IID_STR; + static const nsIID IID = NS_ITHREADJSCONTEXTSTACK_IID; + + nsresult GetSafeJSContext(JSContext * *aSafeJSContext); + nsresult SetSafeJSContext(JSContext * aSafeJSContext); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsILoadGroup.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsILoadGroup.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,37 @@ +module dwt.internal.mozilla.nsILoadGroup; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIRequest; +import dwt.internal.mozilla.nsISimpleEnumerator; +import dwt.internal.mozilla.nsIRequestObserver; +import dwt.internal.mozilla.nsIInterfaceRequestor; + +const char[] NS_ILOADGROUP_IID_STR = "3de0a31c-feaf-400f-9f1e-4ef71f8b20cc"; + +const nsIID NS_ILOADGROUP_IID= + {0x3de0a31c, 0xfeaf, 0x400f, + [ 0x9f, 0x1e, 0x4e, 0xf7, 0x1f, 0x8b, 0x20, 0xcc ]}; + +extern(System) + +interface nsILoadGroup : nsIRequest { + + static const char[] IID_STR = NS_ILOADGROUP_IID_STR; + static const nsIID IID = NS_ILOADGROUP_IID; + + nsresult GetGroupObserver(nsIRequestObserver *aGroupObserver); + nsresult SetGroupObserver(nsIRequestObserver aGroupObserver); + nsresult GetDefaultLoadRequest(nsIRequest *aDefaultLoadRequest); + nsresult SetDefaultLoadRequest(nsIRequest aDefaultLoadRequest); + nsresult AddRequest(nsIRequest aRequest, nsISupports aContext); + nsresult RemoveRequest(nsIRequest aRequest, nsISupports aContext, nsresult aStatus); + nsresult GetRequests(nsISimpleEnumerator *aRequests); + nsresult GetActiveCount(PRUint32 *aActiveCount); + nsresult GetNotificationCallbacks(nsIInterfaceRequestor *aNotificationCallbacks); + nsresult SetNotificationCallbacks(nsIInterfaceRequestor aNotificationCallbacks); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsILocalFile.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsILocalFile.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,44 @@ +module dwt.internal.mozilla.nsILocalFile; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.prlink; +import dwt.internal.mozilla.prio; +import dwt.internal.mozilla.prtime; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIFile; +import dwt.internal.mozilla.nsStringAPI; + +import tango.stdc.stdio : FILE; + +const char[] NS_ILOCALFILE_IID_STR = "aa610f20-a889-11d3-8c81-000064657374"; + +const nsIID NS_ILOCALFILE_IID= + {0xaa610f20, 0xa889, 0x11d3, + [ 0x8c, 0x81, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74 ]}; + +extern(System) + +interface nsILocalFile : nsIFile { + + static const char[] IID_STR = NS_ILOCALFILE_IID_STR; + static const nsIID IID = NS_ILOCALFILE_IID; + + nsresult InitWithPath(nsAString * filePath); + nsresult InitWithNativePath(nsACString * filePath); + nsresult InitWithFile(nsILocalFile aFile); + nsresult GetFollowLinks(PRBool *aFollowLinks); + nsresult SetFollowLinks(PRBool aFollowLinks); + nsresult OpenNSPRFileDesc(PRInt32 flags, PRInt32 mode, PRFileDesc * *_retval); + nsresult OpenANSIFileDesc(char *mode, FILE * *_retval); + nsresult Load(PRLibrary * *_retval); + nsresult GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable); + nsresult AppendRelativePath(nsAString * relativeFilePath); + nsresult AppendRelativeNativePath(nsACString * relativeFilePath); + nsresult GetPersistentDescriptor(nsACString * aPersistentDescriptor); + nsresult SetPersistentDescriptor(nsACString * aPersistentDescriptor); + nsresult Reveal(); + nsresult Launch(); + nsresult GetRelativeDescriptor(nsILocalFile fromFile, nsACString * _retval); + nsresult SetRelativeDescriptor(nsILocalFile fromFile, nsACString * relativeDesc); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIMIMEInfo.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIMIMEInfo.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,60 @@ +module dwt.internal.mozilla.nsIMIMEInfo; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIFile; +import dwt.internal.mozilla.nsIStringEnumerator; +import dwt.internal.mozilla.nsStringAPI; + +alias PRInt32 nsMIMEInfoHandleAction; + +const char[] NS_IMIMEINFO_IID_STR = "1448b42f-cf0d-466e-9a15-64e876ebe857"; + +const nsIID NS_IMIMEINFO_IID= + {0x1448b42f, 0xcf0d, 0x466e, + [ 0x9a, 0x15, 0x64, 0xe8, 0x76, 0xeb, 0xe8, 0x57 ]}; + +extern(System) + +interface nsIMIMEInfo : nsISupports { + + static const char[] IID_STR = NS_IMIMEINFO_IID_STR; + static const nsIID IID = NS_IMIMEINFO_IID; + + nsresult GetFileExtensions(nsIUTF8StringEnumerator *_retval); + nsresult SetFileExtensions(nsACString * aExtensions); + nsresult ExtensionExists(nsACString * aExtension, PRBool *_retval); + nsresult AppendExtension(nsACString * aExtension); + nsresult GetPrimaryExtension(nsACString * aPrimaryExtension); + nsresult SetPrimaryExtension(nsACString * aPrimaryExtension); + nsresult GetMIMEType(nsACString * aMIMEType); + nsresult SetDescription(nsAString * aDescription); + nsresult GetMacType(PRUint32 *aMacType); + nsresult SetMacType(PRUint32 aMacType); + nsresult GetMacCreator(PRUint32 *aMacCreator); + nsresult SetMacCreator(PRUint32 aMacCreator); + nsresult Equals(nsIMIMEInfo aMIMEInfo, PRBool *_retval); + nsresult GetPreferredApplicationHandler(nsIFile *aPreferredApplicationHandler); + nsresult SetPreferredApplicationHandler(nsIFile aPreferredApplicationHandler); + nsresult GetApplicationDescription(nsAString * aApplicationDescription); + nsresult SetApplicationDescription(nsAString * aApplicationDescription); + nsresult GetHasDefaultHandler(PRBool *aHasDefaultHandler); + nsresult GetDefaultDescription(nsAString * aDefaultDescription); + nsresult LaunchWithFile(nsIFile aFile); + + enum { saveToDisk = 0 }; + enum { alwaysAsk = 1 }; + enum { useHelperApp = 2 }; + enum { handleInternally = 3 }; + enum { useSystemDefault = 4 }; + + nsresult GetPreferredAction(nsMIMEInfoHandleAction *aPreferredAction); + nsresult SetPreferredAction(nsMIMEInfoHandleAction aPreferredAction); + nsresult GetAlwaysAskBeforeHandling(PRBool *aAlwaysAskBeforeHandling); + nsresult SetAlwaysAskBeforeHandling(PRBool aAlwaysAskBeforeHandling); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIMemory.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIMemory.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,24 @@ +module dwt.internal.mozilla.nsIMemory; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_IMEMORY_IID_STR = "59e7e77a-38e4-11d4-8cf5-0060b0fc14a3"; + +const nsIID NS_IMEMORY_IID= + {0x59e7e77a, 0x38e4, 0x11d4, + [ 0x8c, 0xf5, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3 ]}; + +extern(System) +interface nsIMemory : nsISupports { + static const char[] IID_STR = NS_IMEMORY_IID_STR; + static const nsIID IID = NS_IMEMORY_IID; + + void * Alloc(size_t size); + void * Realloc(void * ptr, size_t newSize); + void Free(void * ptr); + nsresult HeapMinimize(PRBool immediate); + nsresult IsLowMemory(PRBool *_retval); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIModule.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIModule.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,25 @@ +module dwt.internal.mozilla.nsIModule; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIFile; +import dwt.internal.mozilla.nsIComponentManager; + +const char[] NS_IMODULE_IID_STR = "7392d032-5371-11d3-994e-00805fd26fee"; + +const nsIID NS_IMODULE_IID= + {0x7392d032, 0x5371, 0x11d3, + [ 0x99, 0x4e, 0x00, 0x80, 0x5f, 0xd2, 0x6f, 0xee ]}; + +extern(System) +interface nsIModule : nsISupports { + static const char[] IID_STR = NS_IMODULE_IID_STR; + static const nsIID IID = NS_IMODULE_IID; + + nsresult GetClassObject(nsIComponentManager aCompMgr, nsCID * aClass, nsIID * aIID, void * *aResult); + nsresult RegisterSelf(nsIComponentManager aCompMgr, nsIFile aLocation, char *aLoaderStr, char *aType); + nsresult UnregisterSelf(nsIComponentManager aCompMgr, nsIFile aLocation, char *aLoaderStr); + nsresult CanUnload(nsIComponentManager aCompMgr, PRBool *_retval); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIObjectInputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIObjectInputStream.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,28 @@ +module dwt.internal.mozilla.nsIObjectInputStream; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIBinaryInputStream; + +const char[] NS_IOBJECTINPUTSTREAM_IID_STR = "6c248606-4eae-46fa-9df0-ba58502368eb"; + +const nsIID NS_IOBJECTINPUTSTREAM_IID= + {0x6c248606, 0x4eae, 0x46fa, + [ 0x9d, 0xf0, 0xba, 0x58, 0x50, 0x23, 0x68, 0xeb ]}; + +extern(System) + +interface nsIObjectInputStream : nsIBinaryInputStream { + + static const char[] IID_STR = NS_IOBJECTINPUTSTREAM_IID_STR; + static const nsIID IID = NS_IOBJECTINPUTSTREAM_IID; + + nsresult ReadObject(PRBool aIsStrongRef, nsISupports *_retval); + nsresult ReadID(nsID *aID); + char * GetBuffer(PRUint32 aLength, PRUint32 aAlignMask); + void PutBuffer(char * aBuffer, PRUint32 aLength); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIObjectOutputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIObjectOutputStream.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,30 @@ +module dwt.internal.mozilla.nsIObjectOutputStream; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIBinaryOutputStream; + +const char[] NS_IOBJECTOUTPUTSTREAM_IID_STR = "92c898ac-5fde-4b99-87b3-5d486422094b"; + +const nsIID NS_IOBJECTOUTPUTSTREAM_IID= + {0x92c898ac, 0x5fde, 0x4b99, + [ 0x87, 0xb3, 0x5d, 0x48, 0x64, 0x22, 0x09, 0x4b ]}; + +extern(System) + +interface nsIObjectOutputStream : nsIBinaryOutputStream { + + static const char[] IID_STR = NS_IOBJECTOUTPUTSTREAM_IID_STR; + static const nsIID IID = NS_IOBJECTOUTPUTSTREAM_IID; + + nsresult WriteObject(nsISupports aObject, PRBool aIsStrongRef); + nsresult WriteSingleRefObject(nsISupports aObject); + nsresult WriteCompoundObject(nsISupports aObject, nsIID * aIID, PRBool aIsStrongRef); + nsresult WriteID(nsID * aID); + char * GetBuffer(PRUint32 aLength, PRUint32 aAlignMask); + void PutBuffer(char * aBuffer, PRUint32 aLength); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIObserver.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIObserver.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,23 @@ +module dwt.internal.mozilla.nsIObserver; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_IOBSERVER_IID_STR = "db242e01-e4d9-11d2-9dde-000064657374"; + +const nsIID NS_IOBSERVER_IID= + {0xdb242e01, 0xe4d9, 0x11d2, + [ 0x9d, 0xde, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74 ]}; + +extern(System) + +interface nsIObserver : nsISupports { + + static const char[] IID_STR = NS_IOBSERVER_IID_STR; + static const nsIID IID = NS_IOBSERVER_IID; + + nsresult Observe(nsISupports aSubject, char *aTopic, PRUnichar *aData); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIObserverService.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIObserverService.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,28 @@ +module dwt.internal.mozilla.nsIObserverService; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIObserver; +import dwt.internal.mozilla.nsISimpleEnumerator; + +const char[] NS_IOBSERVERSERVICE_IID_STR = "d07f5192-e3d1-11d2-8acd-00105a1b8860"; + +const nsIID NS_IOBSERVERSERVICE_IID= + {0xd07f5192, 0xe3d1, 0x11d2, + [ 0x8a, 0xcd, 0x00, 0x10, 0x5a, 0x1b, 0x88, 0x60 ]}; + +extern(System) + +interface nsIObserverService : nsISupports { + + static const char[] IID_STR = NS_IOBSERVERSERVICE_IID_STR; + static const nsIID IID = NS_IOBSERVERSERVICE_IID; + + nsresult AddObserver(nsIObserver anObserver, char *aTopic, PRBool ownsWeak); + nsresult RemoveObserver(nsIObserver anObserver, char *aTopic); + nsresult NotifyObservers(nsISupports aSubject, char *aTopic, PRUnichar *someData); + nsresult EnumerateObservers(char *aTopic, nsISimpleEnumerator *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIOutputStream.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIOutputStream.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,37 @@ +module dwt.internal.mozilla.nsIOutputStream; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIInputStream; + +typedef nsresult function(nsIOutputStream aOutStream, + void *aClosure, + char *aToSegment, + PRUint32 aFromOffset, + PRUint32 aCount, + PRUint32 *aReadCount) nsReadSegmentFun; + +const char[] NS_IOUTPUTSTREAM_IID_STR = "0d0acd2a-61b4-11d4-9877-00c04fa0cf4a"; + +const nsIID NS_IOUTPUTSTREAM_IID= + {0x0d0acd2a, 0x61b4, 0x11d4, + [ 0x98, 0x77, 0x00, 0xc0, 0x4f, 0xa0, 0xcf, 0x4a ]}; + +extern(System) + +interface nsIOutputStream : nsISupports { + + static const char[] IID_STR = NS_IOUTPUTSTREAM_IID_STR; + static const nsIID IID = NS_IOUTPUTSTREAM_IID; + + nsresult Close(); + nsresult Flush(); + nsresult Write(char *aBuf, PRUint32 aCount, PRUint32 *_retval); + nsresult WriteFrom(nsIInputStream aFromStream, PRUint32 aCount, PRUint32 *_retval); + nsresult WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval); + nsresult IsNonBlocking(PRBool *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIPrefBranch.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIPrefBranch.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,45 @@ +module dwt.internal.mozilla.nsIPrefBranch; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_IPREFBRANCH_IID_STR = "56c35506-f14b-11d3-99d3-ddbfac2ccf65"; + +const nsIID NS_IPREFBRANCH_IID= + {0x56c35506, 0xf14b, 0x11d3, + [ 0x99, 0xd3, 0xdd, 0xbf, 0xac, 0x2c, 0xcf, 0x65 ]}; + +extern(System) + +interface nsIPrefBranch : nsISupports { + + static const char[] IID_STR = NS_IPREFBRANCH_IID_STR; + static const nsIID IID = NS_IPREFBRANCH_IID; + + enum { PREF_INVALID = 0 }; + enum { PREF_STRING = 32 }; + enum { PREF_INT = 64 }; + enum { PREF_BOOL = 128 }; + + nsresult GetRoot(char * *aRoot); + nsresult GetPrefType(char *aPrefName, PRInt32 *_retval); + nsresult GetBoolPref(char *aPrefName, PRBool *_retval); + nsresult SetBoolPref(char *aPrefName, PRInt32 aValue); + nsresult GetCharPref(char *aPrefName, char **_retval); + nsresult SetCharPref(char *aPrefName, char *aValue); + nsresult GetIntPref(char *aPrefName, PRInt32 *_retval); + nsresult SetIntPref(char *aPrefName, PRInt32 aValue); + nsresult GetComplexValue(char *aPrefName, nsIID * aType, void * *aValue); + nsresult SetComplexValue(char *aPrefName, nsIID * aType, nsISupports aValue); + nsresult ClearUserPref(char *aPrefName); + nsresult LockPref(char *aPrefName); + nsresult PrefHasUserValue(char *aPrefName, PRBool *_retval); + nsresult PrefIsLocked(char *aPrefName, PRBool *_retval); + nsresult UnlockPref(char *aPrefName); + nsresult DeleteBranch(char *aStartingAt); + nsresult GetChildList(char *aStartingAt, PRUint32 *aCount, char ***aChildArray); + nsresult ResetBranch(char *aStartingAt); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIPrefBranch2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIPrefBranch2.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,26 @@ +module dwt.internal.mozilla.nsIPrefBranch2; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIPrefBranch; +import dwt.internal.mozilla.nsIObserver; + +const char[] NS_IPREFBRANCH2_IID_STR = "74567534-eb94-4b1c-8f45-389643bfc555"; + +const nsIID NS_IPREFBRANCH2_IID= + {0x74567534, 0xeb94, 0x4b1c, + [ 0x8f, 0x45, 0x38, 0x96, 0x43, 0xbf, 0xc5, 0x55 ]}; + +extern(System) + +interface nsIPrefBranch2 : nsIPrefBranch { + + static const char[] IID_STR = NS_IPREFBRANCH2_IID_STR; + static const nsIID IID = NS_IPREFBRANCH2_IID; + + nsresult AddObserver(char *aDomain, nsIObserver aObserver, PRBool aHoldWeak); + nsresult RemoveObserver(char *aDomain, nsIObserver aObserver); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIPrefLocalizedString.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIPrefLocalizedString.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,26 @@ +module dwt.internal.mozilla.nsIPrefLocalizedString; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_IPREFLOCALIZEDSTRING_IID_STR = "ae419e24-1dd1-11b2-b39a-d3e5e7073802"; + +const nsIID NS_IPREFLOCALIZEDSTRING_IID= + {0xae419e24, 0x1dd1, 0x11b2, + [ 0xb3, 0x9a, 0xd3, 0xe5, 0xe7, 0x07, 0x38, 0x02 ]}; + +extern(System) + +interface nsIPrefLocalizedString : nsISupports { + + static const char[] IID_STR = NS_IPREFLOCALIZEDSTRING_IID_STR; + static const nsIID IID = NS_IPREFLOCALIZEDSTRING_IID; + + nsresult GetData(PRUnichar * *aData); + nsresult SetData(PRUnichar * aData); + nsresult ToString(PRUnichar **_retval); + nsresult SetDataWithLength(PRUint32 length, PRUnichar *data); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIPrefService.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIPrefService.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,30 @@ +module dwt.internal.mozilla.nsIPrefService; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIPrefBranch; +import dwt.internal.mozilla.nsIFile; + +const char[] NS_IPREFSERVICE_IID_STR = "decb9cc7-c08f-4ea5-be91-a8fc637ce2d2"; + +const nsIID NS_IPREFSERVICE_IID= + {0xdecb9cc7, 0xc08f, 0x4ea5, + [ 0xbe, 0x91, 0xa8, 0xfc, 0x63, 0x7c, 0xe2, 0xd2 ]}; + +extern(System) + +interface nsIPrefService : nsISupports { + + static const char[] IID_STR = NS_IPREFSERVICE_IID_STR; + static const nsIID IID = NS_IPREFSERVICE_IID; + + nsresult ReadUserPrefs(nsIFile aFile); + nsresult ResetPrefs(); + nsresult ResetUserPrefs(); + nsresult SavePrefFile(nsIFile aFile); + nsresult GetBranch(char *aPrefRoot, nsIPrefBranch *_retval); + nsresult GetDefaultBranch(char *aPrefRoot, nsIPrefBranch *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIProgressDialog.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIProgressDialog.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,32 @@ +module dwt.internal.mozilla.nsIProgressDialog; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIDownload; +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsIObserver; + +const char[] NS_IPROGRESSDIALOG_IID_STR = "20e790a2-76c6-462d-851a-22ab6cbbe48b"; + +const nsIID NS_IPROGRESSDIALOG_IID= + {0x20e790a2, 0x76c6, 0x462d, + [ 0x85, 0x1a, 0x22, 0xab, 0x6c, 0xbb, 0xe4, 0x8b ]}; + +extern(System) + +interface nsIProgressDialog : nsIDownload { + + static const char[] IID_STR = NS_IPROGRESSDIALOG_IID_STR; + static const nsIID IID = NS_IPROGRESSDIALOG_IID; + + nsresult Open(nsIDOMWindow aParent); + nsresult GetCancelDownloadOnClose(PRBool *aCancelDownloadOnClose); + nsresult SetCancelDownloadOnClose(PRBool aCancelDownloadOnClose); + nsresult GetObserver(nsIObserver *aObserver); + nsresult SetObserver(nsIObserver aObserver); + nsresult GetDialog(nsIDOMWindow *aDialog); + nsresult SetDialog(nsIDOMWindow aDialog); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIPrompt.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIPrompt.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,49 @@ +module dwt.internal.mozilla.nsIPrompt; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_IPROMPT_IID_STR = "a63f70c0-148b-11d3-9333-00104ba0fd40"; + +const nsIID NS_IPROMPT_IID= + {0xa63f70c0, 0x148b, 0x11d3, + [ 0x93, 0x33, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40 ]}; + +extern(System) + +interface nsIPrompt : nsISupports { + + static const char[] IID_STR = NS_IPROMPT_IID_STR; + static const nsIID IID = NS_IPROMPT_IID; + + nsresult Alert(PRUnichar *dialogTitle, PRUnichar *text); + nsresult AlertCheck(PRUnichar *dialogTitle, PRUnichar *text, PRUnichar *checkMsg, PRBool *checkValue); + nsresult Confirm(PRUnichar *dialogTitle, PRUnichar *text, PRBool *_retval); + nsresult ConfirmCheck(PRUnichar *dialogTitle, PRUnichar *text, PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval); + + enum { BUTTON_POS_0 = 1U }; + enum { BUTTON_POS_1 = 256U }; + enum { BUTTON_POS_2 = 65536U }; + enum { BUTTON_TITLE_OK = 1U }; + enum { BUTTON_TITLE_CANCEL = 2U }; + enum { BUTTON_TITLE_YES = 3U }; + enum { BUTTON_TITLE_NO = 4U }; + enum { BUTTON_TITLE_SAVE = 5U }; + enum { BUTTON_TITLE_DONT_SAVE = 6U }; + enum { BUTTON_TITLE_REVERT = 7U }; + enum { BUTTON_TITLE_IS_STRING = 127U }; + enum { BUTTON_POS_0_DEFAULT = 0U }; + enum { BUTTON_POS_1_DEFAULT = 16777216U }; + enum { BUTTON_POS_2_DEFAULT = 33554432U }; + enum { BUTTON_DELAY_ENABLE = 67108864U }; + enum { STD_OK_CANCEL_BUTTONS = 513U }; + + nsresult ConfirmEx(PRUnichar *dialogTitle, PRUnichar *text, PRUint32 buttonFlags, PRUnichar *button0Title, PRUnichar *button1Title, PRUnichar *button2Title, PRUnichar *checkMsg, PRBool *checkValue, PRInt32 *_retval); + nsresult Prompt(PRUnichar *dialogTitle, PRUnichar *text, PRUnichar **value, PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval); + nsresult PromptPassword(PRUnichar *dialogTitle, PRUnichar *text, PRUnichar **password, PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval); + nsresult PromptUsernameAndPassword(PRUnichar *dialogTitle, PRUnichar *text, PRUnichar **username, PRUnichar **password, PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval); + nsresult Select(PRUnichar *dialogTitle, PRUnichar *text, PRUint32 count, PRUnichar **selectList, PRInt32 *outSelection, PRBool *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIPromptService.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIPromptService.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,52 @@ +module dwt.internal.mozilla.nsIPromptService; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMWindow; + +const char[] NS_IPROMPTSERVICE_IID_STR = "1630c61a-325e-49ca-8759-a31b16c47aa5"; + +const nsIID NS_IPROMPTSERVICE_IID= + {0x1630c61a, 0x325e, 0x49ca, + [ 0x87, 0x59, 0xa3, 0x1b, 0x16, 0xc4, 0x7a, 0xa5 ]}; + +extern(System) + +interface nsIPromptService : nsISupports { + + static const char[] IID_STR = NS_IPROMPTSERVICE_IID_STR; + static const nsIID IID = NS_IPROMPTSERVICE_IID; + + nsresult Alert(nsIDOMWindow aParent, PRUnichar *aDialogTitle, PRUnichar *aText); + nsresult AlertCheck(nsIDOMWindow aParent, PRUnichar *aDialogTitle, PRUnichar *aText, PRUnichar *aCheckMsg, PRBool *aCheckState); + nsresult Confirm(nsIDOMWindow aParent, PRUnichar *aDialogTitle, PRUnichar *aText, PRBool *_retval); + nsresult ConfirmCheck(nsIDOMWindow aParent, PRUnichar *aDialogTitle, PRUnichar *aText, PRUnichar *aCheckMsg, PRBool *aCheckState, PRBool *_retval); + + enum { BUTTON_POS_0 = 1U }; + enum { BUTTON_POS_1 = 256U }; + enum { BUTTON_POS_2 = 65536U }; + enum { BUTTON_TITLE_OK = 1U }; + enum { BUTTON_TITLE_CANCEL = 2U }; + enum { BUTTON_TITLE_YES = 3U }; + enum { BUTTON_TITLE_NO = 4U }; + enum { BUTTON_TITLE_SAVE = 5U }; + enum { BUTTON_TITLE_DONT_SAVE = 6U }; + enum { BUTTON_TITLE_REVERT = 7U }; + enum { BUTTON_TITLE_IS_STRING = 127U }; + enum { BUTTON_POS_0_DEFAULT = 0U }; + enum { BUTTON_POS_1_DEFAULT = 16777216U }; + enum { BUTTON_POS_2_DEFAULT = 33554432U }; + enum { BUTTON_DELAY_ENABLE = 67108864U }; + enum { STD_OK_CANCEL_BUTTONS = 513U }; + enum { STD_YES_NO_BUTTONS = 1027U }; + + nsresult ConfirmEx(nsIDOMWindow aParent, PRUnichar *aDialogTitle, PRUnichar *aText, PRUint32 aButtonFlags, PRUnichar *aButton0Title, PRUnichar *aButton1Title, PRUnichar *aButton2Title, PRUnichar *aCheckMsg, PRBool *aCheckState, PRInt32 *_retval); + nsresult Prompt(nsIDOMWindow aParent, PRUnichar *aDialogTitle, PRUnichar *aText, PRUnichar **aValue, PRUnichar *aCheckMsg, PRBool *aCheckState, PRBool *_retval); + nsresult PromptUsernameAndPassword(nsIDOMWindow aParent, PRUnichar *aDialogTitle, PRUnichar *aText, PRUnichar **aUsername, PRUnichar **aPassword, PRUnichar *aCheckMsg, PRBool *aCheckState, PRBool *_retval); + nsresult PromptPassword(nsIDOMWindow aParent, PRUnichar *aDialogTitle, PRUnichar *aText, PRUnichar **aPassword, PRUnichar *aCheckMsg, PRBool *aCheckState, PRBool *_retval); + nsresult Select(nsIDOMWindow aParent, PRUnichar *aDialogTitle, PRUnichar *aText, PRUint32 aCount, PRUnichar **aSelectList, PRInt32 *aOutSelection, PRBool *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIProperties.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIProperties.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,27 @@ +module mozilla.xpcom.nsIProperties; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_IPROPERTIES_IID_STR = "78650582-4e93-4b60-8e85-26ebd3eb14ca"; + +const nsIID NS_IPROPERTIES_IID= + {0x78650582, 0x4e93, 0x4b60, + [ 0x8e, 0x85, 0x26, 0xeb, 0xd3, 0xeb, 0x14, 0xca ]}; + +extern(System) + +interface nsIProperties : nsISupports { + + static const char[] IID_STR = NS_IPROPERTIES_IID_STR; + static const nsIID IID = NS_IPROPERTIES_IID; + + nsresult Get(char *prop, nsIID * iid, void * *result); + nsresult Set(char *prop, nsISupports value); + nsresult Has(char *prop, PRBool *_retval); + nsresult Undefine(char *prop); + nsresult GetKeys(PRUint32 *count, char ***keys); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIProtocolHandler.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIProtocolHandler.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,37 @@ +module dwt.internal.mozilla.nsIProtocolHandler; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIChannel; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IPROTOCOLHANDLER_IID_STR = "15fd6940-8ea7-11d3-93ad-00104ba0fd40"; + +const nsIID NS_IPROTOCOLHANDLER_IID= + {0x15fd6940, 0x8ea7, 0x11d3, + [ 0x93, 0xad, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40 ]}; + +extern(System) + +interface nsIProtocolHandler : nsISupports { + + static const char[] IID_STR = NS_IPROTOCOLHANDLER_IID_STR; + static const nsIID IID = NS_IPROTOCOLHANDLER_IID; + + nsresult GetScheme(nsACString * aScheme); + nsresult GetDefaultPort(PRInt32 *aDefaultPort); + nsresult GetProtocolFlags(PRUint32 *aProtocolFlags); + nsresult NewURI(nsACString * aSpec, char *aOriginCharset, nsIURI aBaseURI, nsIURI *_retval); + nsresult NewChannel(nsIURI aURI, nsIChannel *_retval); + nsresult AllowPort(PRInt32 port, char *scheme, PRBool *_retval); + + enum { URI_STD = 0U }; + enum { URI_NORELATIVE = 1U }; + enum { URI_NOAUTH = 2U }; + enum { ALLOWS_PROXY = 4U }; + enum { ALLOWS_PROXY_HTTP = 8U }; + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIRequest.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIRequest.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,46 @@ +module dwt.internal.mozilla.nsIRequest; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsILoadGroup; +import dwt.internal.mozilla.nsStringAPI; + +alias PRUint32 nsLoadFlags; + +const char[] NS_IREQUEST_IID_STR = "ef6bfbd2-fd46-48d8-96b7-9f8f0fd387fe"; + +const nsIID NS_IREQUEST_IID= + {0xef6bfbd2, 0xfd46, 0x48d8, + [ 0x96, 0xb7, 0x9f, 0x8f, 0x0f, 0xd3, 0x87, 0xfe ]}; + +extern(System) + +interface nsIRequest : nsISupports { + + static const char[] IID_STR = NS_IREQUEST_IID_STR; + static const nsIID IID = NS_IREQUEST_IID; + + nsresult GetName(nsACString * aName); + nsresult IsPending(PRBool *_retval); + nsresult GetStatus(nsresult *aStatus); + nsresult Cancel(nsresult aStatus); + nsresult Suspend(); + nsresult Resume(); + nsresult GetLoadGroup(nsILoadGroup *aLoadGroup); + nsresult SetLoadGroup(nsILoadGroup aLoadGroup); + nsresult GetLoadFlags(nsLoadFlags *aLoadFlags); + nsresult SetLoadFlags(nsLoadFlags aLoadFlags); + + enum { LOAD_NORMAL = 0U }; + enum { LOAD_BACKGROUND = 1U }; + enum { INHIBIT_CACHING = 128U }; + enum { INHIBIT_PERSISTENT_CACHING = 256U }; + enum { LOAD_BYPASS_CACHE = 512U }; + enum { LOAD_FROM_CACHE = 1024U }; + enum { VALIDATE_ALWAYS = 2048U }; + enum { VALIDATE_NEVER = 4096U }; + enum { VALIDATE_ONCE_PER_SESSION = 8192U }; + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIRequestObserver.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIRequestObserver.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,26 @@ +module dwt.internal.mozilla.nsIRequestObserver; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIRequest; + +const char[] NS_IREQUESTOBSERVER_IID_STR = "fd91e2e0-1481-11d3-9333-00104ba0fd40"; + +const nsIID NS_IREQUESTOBSERVER_IID= + {0xfd91e2e0, 0x1481, 0x11d3, + [ 0x93, 0x33, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40 ]}; + +extern(System) + +interface nsIRequestObserver : nsISupports { + + static const char[] IID_STR = NS_IREQUESTOBSERVER_IID_STR; + static const nsIID IID = NS_IREQUESTOBSERVER_IID; + + nsresult OnStartRequest(nsIRequest aRequest, nsISupports aContext); + nsresult OnStopRequest(nsIRequest aRequest, nsISupports aContext, nsresult aStatusCode); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsISHEntry.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsISHEntry.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,74 @@ +module dwt.internal.mozilla.nsISHEntry; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIHistoryEntry; +import dwt.internal.mozilla.nsIContentViewer; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIInputStream; +import dwt.internal.mozilla.nsIDocShellTreeItem; +import dwt.internal.mozilla.nsISupportsArray; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_ISHENTRY_IID_STR = "542a98b9-2889-4922-aaf4-02b6056f4136"; + +const nsIID NS_ISHENTRY_IID= + {0x542a98b9, 0x2889, 0x4922, + [ 0xaa, 0xf4, 0x02, 0xb6, 0x05, 0x6f, 0x41, 0x36 ]}; + +extern(System) + +interface nsISHEntry : nsIHistoryEntry { + + static const char[] IID_STR = NS_ISHENTRY_IID_STR; + static const nsIID IID = NS_ISHENTRY_IID; + + nsresult SetURI(nsIURI aURI); + nsresult GetReferrerURI(nsIURI *aReferrerURI); + nsresult SetReferrerURI(nsIURI aReferrerURI); + nsresult GetContentViewer(nsIContentViewer *aContentViewer); + nsresult SetContentViewer(nsIContentViewer aContentViewer); + nsresult GetSticky(PRBool *aSticky); + nsresult SetSticky(PRBool aSticky); + nsresult GetWindowState(nsISupports *aWindowState); + nsresult SetWindowState(nsISupports aWindowState); + nsresult GetViewerBounds(nsRect * bounds); + nsresult SetViewerBounds(nsRect * bounds); + nsresult AddChildShell(nsIDocShellTreeItem shell); + nsresult ChildShellAt(PRInt32 index, nsIDocShellTreeItem *_retval); + nsresult ClearChildShells(); + nsresult GetRefreshURIList(nsISupportsArray *aRefreshURIList); + nsresult SetRefreshURIList(nsISupportsArray aRefreshURIList); + nsresult SyncPresentationState(); + nsresult SetTitle(nsAString * aTitle); + nsresult GetPostData(nsIInputStream *aPostData); + nsresult SetPostData(nsIInputStream aPostData); + nsresult GetLayoutHistoryState(nsILayoutHistoryState *aLayoutHistoryState); + nsresult SetLayoutHistoryState(nsILayoutHistoryState aLayoutHistoryState); + nsresult GetParent(nsISHEntry *aParent); + nsresult SetParent(nsISHEntry aParent); + nsresult GetLoadType(PRUint32 *aLoadType); + nsresult SetLoadType(PRUint32 aLoadType); + nsresult GetID(PRUint32 *aID); + nsresult SetID(PRUint32 aID); + nsresult GetPageIdentifier(PRUint32 *aPageIdentifier); + nsresult SetPageIdentifier(PRUint32 aPageIdentifier); + nsresult GetCacheKey(nsISupports *aCacheKey); + nsresult SetCacheKey(nsISupports aCacheKey); + nsresult GetSaveLayoutStateFlag(PRBool *aSaveLayoutStateFlag); + nsresult SetSaveLayoutStateFlag(PRBool aSaveLayoutStateFlag); + nsresult GetExpirationStatus(PRBool *aExpirationStatus); + nsresult SetExpirationStatus(PRBool aExpirationStatus); + nsresult GetContentType(nsACString * aContentType); + nsresult SetContentType(nsACString * aContentType); + nsresult SetScrollPosition(PRInt32 x, PRInt32 y); + nsresult GetScrollPosition(PRInt32 *x, PRInt32 *y); + nsresult Create(nsIURI URI, nsAString * title, nsIInputStream inputStream, nsILayoutHistoryState layoutHistoryState, nsISupports cacheKey, nsACString * contentType); + nsresult Clone(nsISHEntry *_retval); + nsresult SetIsSubFrame(PRBool aFlag); + nsresult GetAnyContentViewer(nsISHEntry *ownerEntry, nsIContentViewer *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsISHistory.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsISHistory.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,35 @@ +module dwt.internal.mozilla.nsISHistory; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIHistoryEntry; +import dwt.internal.mozilla.nsISHistoryListener; +import dwt.internal.mozilla.nsISimpleEnumerator; + +const char[] NS_ISHISTORY_IID_STR = "7294fe9b-14d8-11d5-9882-00c04fa02f40"; + +const nsIID NS_ISHISTORY_IID= + {0x7294fe9b, 0x14d8, 0x11d5, + [ 0x98, 0x82, 0x00, 0xc0, 0x4f, 0xa0, 0x2f, 0x40 ]}; + +extern(System) + +interface nsISHistory : nsISupports { + + static const char[] IID_STR = NS_ISHISTORY_IID_STR; + static const nsIID IID = NS_ISHISTORY_IID; + + nsresult GetCount(PRInt32 *aCount); + nsresult GetIndex(PRInt32 *aIndex); + nsresult GetMaxLength(PRInt32 *aMaxLength); + nsresult SetMaxLength(PRInt32 aMaxLength); + nsresult GetEntryAtIndex(PRInt32 index, PRBool modifyIndex, nsIHistoryEntry *_retval); + nsresult PurgeHistory(PRInt32 numEntries); + nsresult AddSHistoryListener(nsISHistoryListener aListener); + nsresult RemoveSHistoryListener(nsISHistoryListener aListener); + nsresult GetSHistoryEnumerator(nsISimpleEnumerator *aSHistoryEnumerator); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsISHistoryListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsISHistoryListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,30 @@ +module dwt.internal.mozilla.nsISHistoryListener; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIURI; + +const char[] NS_ISHISTORYLISTENER_IID_STR = "3b07f591-e8e1-11d4-9882-00c04fa02f40"; + +const nsIID NS_ISHISTORYLISTENER_IID= + {0x3b07f591, 0xe8e1, 0x11d4, + [ 0x98, 0x82, 0x00, 0xc0, 0x4f, 0xa0, 0x2f, 0x40 ]}; + +extern(System) + +interface nsISHistoryListener : nsISupports { + + static const char[] IID_STR = NS_ISHISTORYLISTENER_IID_STR; + static const nsIID IID = NS_ISHISTORYLISTENER_IID; + + nsresult OnHistoryNewEntry(nsIURI aNewURI); + nsresult OnHistoryGoBack(nsIURI aBackURI, PRBool *_retval); + nsresult OnHistoryGoForward(nsIURI aForwardURI, PRBool *_retval); + nsresult OnHistoryReload(nsIURI aReloadURI, PRUint32 aReloadFlags, PRBool *_retval); + nsresult OnHistoryGotoIndex(PRInt32 aIndex, nsIURI aGotoURI, PRBool *_retval); + nsresult OnHistoryPurge(PRInt32 aNumEntries, PRBool *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsISecureBrowserUI.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsISecureBrowserUI.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,28 @@ +module dwt.internal.mozilla.nsISecureBrowserUI; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_ISECUREBROWSERUI_IID_STR = "081e31e0-a144-11d3-8c7c-00609792278c"; + +const nsIID NS_ISECUREBROWSERUI_IID= + {0x081e31e0, 0xa144, 0x11d3, + [ 0x8c, 0x7c, 0x00, 0x60, 0x97, 0x92, 0x27, 0x8c ]}; + +extern(System) + +interface nsISecureBrowserUI : nsISupports { + + static const char[] IID_STR = NS_ISECUREBROWSERUI_IID_STR; + static const nsIID IID = NS_ISECUREBROWSERUI_IID; + + nsresult Init(nsIDOMWindow window); + nsresult GetState(PRUint32 *aState); + nsresult GetTooltipText(nsAString * aTooltipText); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsISelection.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsISelection.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,44 @@ +module dwt.internal.mozilla.nsISelection; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMNode; +import dwt.internal.mozilla.nsIDOMRange; + +const char[] NS_ISELECTION_IID_STR = "b2c7ed59-8634-4352-9e37-5484c8b6e4e1"; + +const nsIID NS_ISELECTION_IID= + {0xb2c7ed59, 0x8634, 0x4352, + [ 0x9e, 0x37, 0x54, 0x84, 0xc8, 0xb6, 0xe4, 0xe1 ]}; + +extern(System) + +interface nsISelection : nsISupports { + + static const char[] IID_STR = NS_ISELECTION_IID_STR; + static const nsIID IID = NS_ISELECTION_IID; + + nsresult GetAnchorNode(nsIDOMNode *aAnchorNode); + nsresult GetAnchorOffset(PRInt32 *aAnchorOffset); + nsresult GetFocusNode(nsIDOMNode *aFocusNode); + nsresult GetFocusOffset(PRInt32 *aFocusOffset); + nsresult GetIsCollapsed(PRBool *aIsCollapsed); + nsresult GetRangeCount(PRInt32 *aRangeCount); + nsresult GetRangeAt(PRInt32 index, nsIDOMRange *_retval); + nsresult Collapse(nsIDOMNode parentNode, PRInt32 offset); + nsresult Extend(nsIDOMNode parentNode, PRInt32 offset); + nsresult CollapseToStart(); + nsresult CollapseToEnd(); + nsresult ContainsNode(nsIDOMNode node, PRBool entirelyContained, PRBool *_retval); + nsresult SelectAllChildren(nsIDOMNode parentNode); + nsresult AddRange(nsIDOMRange range); + nsresult RemoveRange(nsIDOMRange range); + nsresult RemoveAllRanges(); + nsresult DeleteFromDocument(); + nsresult SelectionLanguageChange(PRBool langRTL); + nsresult ToString(PRUnichar **_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsISerializable.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsISerializable.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,27 @@ +module dwt.internal.mozilla.nsISerializable; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIObjectInputStream; +import dwt.internal.mozilla.nsIObjectOutputStream; + +const char[] NS_ISERIALIZABLE_IID_STR = "91cca981-c26d-44a8-bebe-d9ed4891503a"; + +const nsIID NS_ISERIALIZABLE_IID= + {0x91cca981, 0xc26d, 0x44a8, + [ 0xbe, 0xbe, 0xd9, 0xed, 0x48, 0x91, 0x50, 0x3a ]}; + +extern(System) + +interface nsISerializable : nsISupports { + + static const char[] IID_STR = NS_ISERIALIZABLE_IID_STR; + static const nsIID IID = NS_ISERIALIZABLE_IID; + + nsresult Read(nsIObjectInputStream aInputStream); + nsresult Write(nsIObjectOutputStream aOutputStream); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIServiceManager.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIServiceManager.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,25 @@ +module dwt.internal.mozilla.nsIServiceManager; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_ISERVICEMANAGER_IID_STR = "8bb35ed9-e332-462d-9155-4a002ab5c958"; +const nsIID NS_ISERVICEMANAGER_IID= + {0x8bb35ed9, 0xe332, 0x462d, + [ 0x91, 0x55, 0x4a, 0x00, 0x2a, 0xb5, 0xc9, 0x58 ]}; + +extern(System) + +interface nsIServiceManager : nsISupports { + + static const char[] IID_STR = NS_ISERVICEMANAGER_IID_STR; + static const nsIID IID = NS_ISERVICEMANAGER_IID; + + nsresult GetService(nsCID * aClass, nsIID * aIID, void * *result); + nsresult GetServiceByContractID(char *aContractID, nsIID * aIID, void * *result); + nsresult IsServiceInstantiated(nsCID * aClass, nsIID * aIID, PRBool *_retval); + nsresult IsServiceInstantiatedByContractID(char *aContractID, nsIID * aIID, PRBool *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsISimpleEnumerator.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsISimpleEnumerator.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,24 @@ +module dwt.internal.mozilla.nsISimpleEnumerator; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_ISIMPLEENUMERATOR_IID_STR = "d1899240-f9d2-11d2-bdd6-000064657374"; + +const nsIID NS_ISIMPLEENUMERATOR_IID= + {0xd1899240, 0xf9d2, 0x11d2, + [ 0xbd, 0xd6, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74 ]}; + +extern(System) + +interface nsISimpleEnumerator : nsISupports { + + static const char[] IID_STR = NS_ISIMPLEENUMERATOR_IID_STR; + static const nsIID IID = NS_ISIMPLEENUMERATOR_IID; + + nsresult HasMoreElements(PRBool *_retval); + nsresult GetNext(nsISupports *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIStreamListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIStreamListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,27 @@ +module dwt.internal.mozilla.nsIStreamListener; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIRequestObserver; +import dwt.internal.mozilla.nsIRequest; +import dwt.internal.mozilla.nsIInputStream; + +const char[] NS_ISTREAMLISTENER_IID_STR = "1a637020-1482-11d3-9333-00104ba0fd40"; + +const nsIID NS_ISTREAMLISTENER_IID= + {0x1a637020, 0x1482, 0x11d3, + [ 0x93, 0x33, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40 ]}; + +extern(System) + +interface nsIStreamListener : nsIRequestObserver { + + static const char[] IID_STR = NS_ISTREAMLISTENER_IID_STR; + static const nsIID IID = NS_ISTREAMLISTENER_IID; + + nsresult OnDataAvailable(nsIRequest aRequest, nsISupports aContext, nsIInputStream aInputStream, PRUint32 aOffset, PRUint32 aCount); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIStringEnumerator.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIStringEnumerator.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,52 @@ +module dwt.internal.mozilla.nsIStringEnumerator; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsStringAPI; + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_ISTRINGENUMERATOR_IID_STR = "50d3ef6c-9380-4f06-9fb2-95488f7d141c"; + +const nsIID NS_ISTRINGENUMERATOR_IID= + {0x50d3ef6c, 0x9380, 0x4f06, + [ 0x9f, 0xb2, 0x95, 0x48, 0x8f, 0x7d, 0x14, 0x1c ]}; + +extern(System) + +interface nsIStringEnumerator : nsISupports { + + static const char[] IID_STR = NS_ISTRINGENUMERATOR_IID_STR; + static const nsIID IID = NS_ISTRINGENUMERATOR_IID; + + nsresult HasMore(PRBool *_retval); + nsresult GetNext(nsAString * _retval); + +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IUTF8STRINGENUMERATOR_IID_STR = "9bdf1010-3695-4907-95ed-83d0410ec307"; + +const nsIID NS_IUTF8STRINGENUMERATOR_IID= + {0x9bdf1010, 0x3695, 0x4907, + [ 0x95, 0xed, 0x83, 0xd0, 0x41, 0x0e, 0xc3, 0x07 ]}; + +extern(System) + +interface nsIUTF8StringEnumerator : nsISupports { + + static const char[] IID_STR = NS_IUTF8STRINGENUMERATOR_IID_STR; + static const nsIID IID = NS_IUTF8STRINGENUMERATOR_IID; + + nsresult HasMore(PRBool *_retval); + nsresult GetNext(nsACString * _retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsISupports.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsISupports.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,31 @@ +module dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +const char[] NS_ISUPPORTS_IID_STR = "00000000-0000-0000-c000-000000000046"; + +const nsIID NS_ISUPPORTS_IID= + { 0x00000000, 0x0000, 0x0000, + [ 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 ] }; + +extern(System) + +interface IUnknown +{ + static const char[] IID_STR = NS_ISUPPORTS_IID_STR; + static const nsIID IID = NS_ISUPPORTS_IID; + + nsresult QueryInterface(ref nsIID uuid, void **result); + + nsrefcnt AddRef(); + nsrefcnt Release(); +} + +// WHY WE USE COM's IUnknown for XPCOM: +// +// The IUnknown interface is special-cased in D and is specifically designed to be +// compatible with MS COM. XPCOM's nsISupports interface is the exact equivalent +// of IUnknown so we alias it here to take advantage of D's COM support. -JJR + +alias IUnknown nsISupports; \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsISupports.d~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsISupports.d~ Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,31 @@ +module dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +const char[] NS_ISUPPORTS_IID_STR = "00000000-0000-0000-c000-000000000046"; + +const nsIID NS_ISUPPORTS_IID= + { 0x00000000, 0x0000, 0x0000, + [ 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 ] }; + +extern(System) + +interface IUnknown +{ + static const char[] IID_STR = NS_ISUPPORTS_IID_STR; + static const nsIID IID = NS_ISUPPORTS_IID; + + nsresult QueryInterface(nsIID * uuid, void **result); + + nsrefcnt AddRef(); + nsrefcnt Release(); +} + +// WHY WE USE COM's IUnknown for XPCOM: +// +// The IUnknown interface is special-cased in D and is specifically designed to be +// compatible with MS COM. XPCOM's nsISupports interface is the exact equivalent +// of IUnknown so we alias it here to take advantage of D's COM support. -JJR + +alias IUnknown nsISupports; \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsISupportsArray.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsISupportsArray.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,49 @@ +module dwt.internal.mozilla.nsISupportsArray; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsICollection; + +typedef PRBool function(nsISupports, void*) nsISupportsArrayEnumFunc; + +const char[] NS_ISUPPORTSARRAY_IID_STR = "791eafa0-b9e6-11d1-8031-006008159b5a"; + +const nsIID NS_ISUPPORTSARRAY_IID= + {0x791eafa0, 0xb9e6, 0x11d1, + [ 0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a ]}; + +extern(System) + +interface nsISupportsArray : nsICollection { + + static const char[] IID_STR = NS_ISUPPORTSARRAY_IID_STR; + static const nsIID IID = NS_ISUPPORTSARRAY_IID; + + PRBool Equals(nsISupportsArray other); + nsISupports ElementAt(PRUint32 aIndex); + PRInt32 IndexOf(nsISupports aPossibleElement); + PRInt32 IndexOfStartingAt(nsISupports aPossibleElement, PRUint32 aStartIndex); + PRInt32 LastIndexOf(nsISupports aPossibleElement); + nsresult GetIndexOf(nsISupports aPossibleElement, PRInt32 *_retval); + nsresult GetIndexOfStartingAt(nsISupports aPossibleElement, PRUint32 aStartIndex, PRInt32 *_retval); + nsresult GetLastIndexOf(nsISupports aPossibleElement, PRInt32 *_retval); + PRBool InsertElementAt(nsISupports aElement, PRUint32 aIndex); + PRBool ReplaceElementAt(nsISupports aElement, PRUint32 aIndex); + PRBool RemoveElementAt(PRUint32 aIndex); + PRBool RemoveLastElement(nsISupports aElement); + nsresult DeleteLastElement(nsISupports aElement); + nsresult DeleteElementAt(PRUint32 aIndex); + PRBool AppendElements(nsISupportsArray aElements); + nsresult Compact(); + PRBool EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void * aData); + PRBool EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void * aData); + nsresult Clone(nsISupportsArray *_retval); + PRBool MoveElement(PRInt32 aFrom, PRInt32 aTo); + PRBool InsertElementsAt(nsISupportsArray aOther, PRUint32 aIndex); + PRBool RemoveElementsAt(PRUint32 aIndex, PRUint32 aCount); + PRBool SizeTo(PRInt32 aSize); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsITooltipListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsITooltipListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,24 @@ +module dwt.internal.mozilla.nsITooltipListener; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_ITOOLTIPLISTENER_IID_STR = "44b78386-1dd2-11b2-9ad2-e4eee2ca1916"; + +const nsIID NS_ITOOLTIPLISTENER_IID= + {0x44b78386, 0x1dd2, 0x11b2, + [ 0x9a, 0xd2, 0xe4, 0xee, 0xe2, 0xca, 0x19, 0x16 ]}; + +extern(System) + +interface nsITooltipListener : nsISupports { + + static const char[] IID_STR = NS_ITOOLTIPLISTENER_IID_STR; + static const nsIID IID = NS_ITOOLTIPLISTENER_IID; + + nsresult OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, PRUnichar *aTipText); + nsresult OnHideTooltip(); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsITraceRefcnt.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsITraceRefcnt.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,25 @@ +module dwt.internal.mozilla.nsITraceRefcnt; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_ITRACEREFCNT_IID_STR = "273dc92f-0fe6-4545-96a9-21be77828039"; + +const nsIID NS_ITRACEREFCNT_IID= + {0x273dc92f, 0x0fe6, 0x4545, + [ 0x96, 0xa9, 0x21, 0xbe, 0x77, 0x82, 0x80, 0x39 ]}; + +extern(System) +interface nsITraceRefcnt : nsISupports { + static const char[] IID_STR = NS_ITRACEREFCNT_IID_STR; + static const nsIID IID = NS_ITRACEREFCNT_IID; + + nsresult LogAddRef(void * aPtr, nsrefcnt aNewRefcnt, char *aTypeName, PRUint32 aInstanceSize); + nsresult LogRelease(void * aPtr, nsrefcnt aNewRefcnt, char *aTypeName); + nsresult LogCtor(void * aPtr, char *aTypeName, PRUint32 aInstanceSize); + nsresult LogDtor(void * aPtr, char *aTypeName, PRUint32 aInstanceSize); + nsresult LogAddCOMPtr(void * aPtr, nsISupports aObject); + nsresult LogReleaseCOMPtr(void * aPtr, nsISupports aObject); +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsITransfer.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsITransfer.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,32 @@ +module dwt.internal.mozilla.nsITransfer; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.prtime; + +import dwt.internal.mozilla.nsIWebProgressListener2; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsICancelable; +import dwt.internal.mozilla.nsIMIMEInfo; +import dwt.internal.mozilla.nsILocalFile; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_ITRANSFER_IID_STR = "23c51569-e9a1-4a92-adeb-3723db82ef7c"; + +const nsIID NS_ITRANSFER_IID= + {0x23c51569, 0xe9a1, 0x4a92, + [ 0xad, 0xeb, 0x37, 0x23, 0xdb, 0x82, 0xef, 0x7c ]}; + +extern(System) + +interface nsITransfer : nsIWebProgressListener2 { + + static const char[] IID_STR = NS_ITRANSFER_IID_STR; + static const nsIID IID = NS_ITRANSFER_IID; + + nsresult Init(nsIURI aSource, nsIURI aTarget, nsAString * aDisplayName, nsIMIMEInfo aMIMEInfo, PRTime startTime, nsILocalFile aTempFile, nsICancelable aCancelable); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIURI.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIURI.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,49 @@ +module dwt.internal.mozilla.nsIURI; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IURI_IID_STR = "07a22cc0-0ce5-11d3-9331-00104ba0fd40"; + +const nsIID NS_IURI_IID= + {0x07a22cc0, 0x0ce5, 0x11d3, + [ 0x93, 0x31, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40 ]}; + +extern(System) + +interface nsIURI : nsISupports { + + static const char[] IID_STR = NS_IURI_IID_STR; + static const nsIID IID = NS_IURI_IID; + + nsresult GetSpec(nsACString * aSpec); + nsresult SetSpec(nsACString * aSpec); + nsresult GetPrePath(nsACString * aPrePath); + nsresult GetScheme(nsACString * aScheme); + nsresult SetScheme(nsACString * aScheme); + nsresult GetUserPass(nsACString * aUserPass); + nsresult SetUserPass(nsACString * aUserPass); + nsresult GetUsername(nsACString * aUsername); + nsresult SetUsername(nsACString * aUsername); + nsresult GetPassword(nsACString * aPassword); + nsresult SetPassword(nsACString * aPassword); + nsresult GetHostPort(nsACString * aHostPort); + nsresult SetHostPort(nsACString * aHostPort); + nsresult GetHost(nsACString * aHost); + nsresult SetHost(nsACString * aHost); + nsresult GetPort(PRInt32 *aPort); + nsresult SetPort(PRInt32 aPort); + nsresult GetPath(nsACString * aPath); + nsresult SetPath(nsACString * aPath); + nsresult Equals(nsIURI other, PRBool *_retval); + nsresult SchemeIs(char *scheme, PRBool *_retval); + nsresult Clone(nsIURI *_retval); + nsresult Resolve(nsACString * relativePath, nsACString * _retval); + nsresult GetAsciiSpec(nsACString * aAsciiSpec); + nsresult GetAsciiHost(nsACString * aAsciiHost); + nsresult GetOriginCharset(nsACString * aOriginCharset); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIURIContentListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIURIContentListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,34 @@ +module dwt.internal.mozilla.nsIURIContentListener; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIRequest; +import dwt.internal.mozilla.nsIStreamListener; +import dwt.internal.mozilla.nsIURI; + +const char[] NS_IURICONTENTLISTENER_IID_STR = "94928ab3-8b63-11d3-989d-001083010e9b"; + +const nsIID NS_IURICONTENTLISTENER_IID= + {0x94928ab3, 0x8b63, 0x11d3, + [ 0x98, 0x9d, 0x00, 0x10, 0x83, 0x01, 0x0e, 0x9b ]}; + +extern(System) + +interface nsIURIContentListener : nsISupports { + + static const char[] IID_STR = NS_IURICONTENTLISTENER_IID_STR; + static const nsIID IID = NS_IURICONTENTLISTENER_IID; + + nsresult OnStartURIOpen(nsIURI aURI, PRBool *_retval); + nsresult DoContent(char *aContentType, PRBool aIsContentPreferred, nsIRequest aRequest, nsIStreamListener *aContentHandler, PRBool *_retval); + nsresult IsPreferred(char *aContentType, char **aDesiredContentType, PRBool *_retval); + nsresult CanHandleContent(char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType, PRBool *_retval); + nsresult GetLoadCookie(nsISupports *aLoadCookie); + nsresult SetLoadCookie(nsISupports aLoadCookie); + nsresult GetParentContentListener(nsIURIContentListener *aParentContentListener); + nsresult SetParentContentListener(nsIURIContentListener aParentContentListener); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIURL.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIURL.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,41 @@ +module dwt.internal.mozilla.nsIURL; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IURL_IID_STR = "d6116970-8034-11d3-9399-00104ba0fd40"; + +const nsIID NS_IURL_IID= + {0xd6116970, 0x8034, 0x11d3, + [ 0x93, 0x99, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40 ]}; + +extern(System) + +interface nsIURL : nsIURI { + + static const char[] IID_STR = NS_IURL_IID_STR; + static const nsIID IID = NS_IURL_IID; + + nsresult GetFilePath(nsACString * aFilePath); + nsresult SetFilePath(nsACString * aFilePath); + nsresult GetParam(nsACString * aParam); + nsresult SetParam(nsACString * aParam); + nsresult GetQuery(nsACString * aQuery); + nsresult SetQuery(nsACString * aQuery); + nsresult GetRef(nsACString * aRef); + nsresult SetRef(nsACString * aRef); + nsresult GetDirectory(nsACString * aDirectory); + nsresult SetDirectory(nsACString * aDirectory); + nsresult GetFileName(nsACString * aFileName); + nsresult SetFileName(nsACString * aFileName); + nsresult GetFileBaseName(nsACString * aFileBaseName); + nsresult SetFileBaseName(nsACString * aFileBaseName); + nsresult GetFileExtension(nsACString * aFileExtension); + nsresult SetFileExtension(nsACString * aFileExtension); + nsresult GetCommonBaseSpec(nsIURI aURIToCompare, nsACString * _retval); + nsresult GetRelativeSpec(nsIURI aURIToCompare, nsACString * _retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWeakReference.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWeakReference.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,48 @@ +module dwt.internal.mozilla.nsIWeakReference; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_IWEAKREFERENCE_IID_STR = "9188bc85-f92e-11d2-81ef-0060083a0bcf"; + +const nsIID NS_IWEAKREFERENCE_IID= + {0x9188bc85, 0xf92e, 0x11d2, + [ 0x81, 0xef, 0x00, 0x60, 0x08, 0x3a, 0x0b, 0xcf ]}; + +extern(System) + +interface nsIWeakReference : nsISupports { + + static const char[] IID_STR = NS_IWEAKREFERENCE_IID_STR; + static const nsIID IID = NS_IWEAKREFERENCE_IID; + + nsresult QueryReferent(nsIID * uuid, void * *result); + +} + +/****************************************************************************** + +******************************************************************************/ + +const char[] NS_ISUPPORTSWEAKREFERENCE_IID_STR = "9188bc86-f92e-11d2-81ef-0060083a0bcf"; + +const nsIID NS_ISUPPORTSWEAKREFERENCE_IID= + {0x9188bc86, 0xf92e, 0x11d2, + [ 0x81, 0xef, 0x00, 0x60, 0x08, 0x3a, 0x0b, 0xcf ]}; + +extern(System) + +interface nsISupportsWeakReference : nsISupports { + + static const char[] IID_STR = NS_ISUPPORTSWEAKREFERENCE_IID_STR; + static const nsIID IID = NS_ISUPPORTSWEAKREFERENCE_IID; + + nsresult GetWeakReference(nsIWeakReference *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWebBrowser.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWebBrowser.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,34 @@ +module dwt.internal.mozilla.nsIWebBrowser; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIWebBrowserChrome; +import dwt.internal.mozilla.nsIURIContentListener; +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsIWeakReference; + +const char[] NS_IWEBBROWSER_IID_STR = "69e5df00-7b8b-11d3-af61-00a024ffc08c"; + +const nsIID NS_IWEBBROWSER_IID= + {0x69e5df00, 0x7b8b, 0x11d3, + [ 0xaf, 0x61, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c ]}; + +extern(System) + +interface nsIWebBrowser : nsISupports { + + static const char[] IID_STR = NS_IWEBBROWSER_IID_STR; + static const nsIID IID = NS_IWEBBROWSER_IID; + + nsresult AddWebBrowserListener(nsIWeakReference aListener, nsIID * aIID); + nsresult RemoveWebBrowserListener(nsIWeakReference aListener, nsIID * aIID); + nsresult GetContainerWindow(nsIWebBrowserChrome *aContainerWindow); + nsresult SetContainerWindow(nsIWebBrowserChrome aContainerWindow); + nsresult GetParentURIContentListener(nsIURIContentListener *aParentURIContentListener); + nsresult SetParentURIContentListener(nsIURIContentListener aParentURIContentListener); + nsresult GetContentDOMWindow(nsIDOMWindow *aContentDOMWindow); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWebBrowserChrome.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWebBrowserChrome.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,64 @@ +module dwt.internal.mozilla.nsIWebBrowserChrome; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIWebBrowser; + +const char[] NS_IWEBBROWSERCHROME_IID_STR = "ba434c60-9d52-11d3-afb0-00a024ffc08c"; + +const nsIID NS_IWEBBROWSERCHROME_IID= + {0xba434c60, 0x9d52, 0x11d3, + [ 0xaf, 0xb0, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c ]}; + +extern(System) + +interface nsIWebBrowserChrome : nsISupports { + + static const char[] IID_STR = NS_IWEBBROWSERCHROME_IID_STR; + static const nsIID IID = NS_IWEBBROWSERCHROME_IID; + + enum { STATUS_SCRIPT = 1U }; + enum { STATUS_SCRIPT_DEFAULT = 2U }; + enum { STATUS_LINK = 3U }; + + nsresult SetStatus(PRUint32 statusType, PRUnichar *status); + nsresult GetWebBrowser(nsIWebBrowser *aWebBrowser); + nsresult SetWebBrowser(nsIWebBrowser aWebBrowser); + + enum { CHROME_DEFAULT = 1U }; + enum { CHROME_WINDOW_BORDERS = 2U }; + enum { CHROME_WINDOW_CLOSE = 4U }; + enum { CHROME_WINDOW_RESIZE = 8U }; + enum { CHROME_MENUBAR = 16U }; + enum { CHROME_TOOLBAR = 32U }; + enum { CHROME_LOCATIONBAR = 64U }; + enum { CHROME_STATUSBAR = 128U }; + enum { CHROME_PERSONAL_TOOLBAR = 256U }; + enum { CHROME_SCROLLBARS = 512U }; + enum { CHROME_TITLEBAR = 1024U }; + enum { CHROME_EXTRA = 2048U }; + enum { CHROME_WITH_SIZE = 4096U }; + enum { CHROME_WITH_POSITION = 8192U }; + enum { CHROME_WINDOW_MIN = 16384U }; + enum { CHROME_WINDOW_POPUP = 32768U }; + enum { CHROME_WINDOW_RAISED = 33554432U }; + enum { CHROME_WINDOW_LOWERED = 67108864U }; + enum { CHROME_CENTER_SCREEN = 134217728U }; + enum { CHROME_DEPENDENT = 268435456U }; + enum { CHROME_MODAL = 536870912U }; + enum { CHROME_OPENAS_DIALOG = 1073741824U }; + enum { CHROME_OPENAS_CHROME = 2147483648U }; + enum { CHROME_ALL = 4094U }; + + nsresult GetChromeFlags(PRUint32 *aChromeFlags); + nsresult SetChromeFlags(PRUint32 aChromeFlags); + nsresult DestroyBrowserWindow(); + nsresult SizeBrowserTo(PRInt32 aCX, PRInt32 aCY); + nsresult ShowAsModal(); + nsresult IsWindowModal(PRBool *_retval); + nsresult ExitModalEventLoop(nsresult aStatus); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWebBrowserChromeFocus.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWebBrowserChromeFocus.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,24 @@ +module dwt.internal.mozilla.nsIWebBrowserChromeFocus; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +const char[] NS_IWEBBROWSERCHROMEFOCUS_IID_STR = "d2206418-1dd1-11b2-8e55-acddcd2bcfb8"; + +const nsIID NS_IWEBBROWSERCHROMEFOCUS_IID= + {0xd2206418, 0x1dd1, 0x11b2, + [ 0x8e, 0x55, 0xac, 0xdd, 0xcd, 0x2b, 0xcf, 0xb8 ]}; + +extern(System) + +interface nsIWebBrowserChromeFocus : nsISupports { + + static const char[] IID_STR = NS_IWEBBROWSERCHROMEFOCUS_IID_STR; + static const nsIID IID = NS_IWEBBROWSERCHROMEFOCUS_IID; + + nsresult FocusNextElement(); + nsresult FocusPrevElement(); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWebBrowserFocus.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWebBrowserFocus.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,32 @@ +module dwt.internal.mozilla.nsIWebBrowserFocus; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsIDOMElement; + +const char[] NS_IWEBBROWSERFOCUS_IID_STR = "9c5d3c58-1dd1-11b2-a1c9-f3699284657a"; + +const nsIID NS_IWEBBROWSERFOCUS_IID= + {0x9c5d3c58, 0x1dd1, 0x11b2, + [ 0xa1, 0xc9, 0xf3, 0x69, 0x92, 0x84, 0x65, 0x7a ]}; + +extern(System) + +interface nsIWebBrowserFocus : nsISupports { + + static const char[] IID_STR = NS_IWEBBROWSERFOCUS_IID_STR; + static const nsIID IID = NS_IWEBBROWSERFOCUS_IID; + + nsresult Activate(); + nsresult Deactivate(); + nsresult SetFocusAtFirstElement(); + nsresult SetFocusAtLastElement(); + nsresult GetFocusedWindow(nsIDOMWindow *aFocusedWindow); + nsresult SetFocusedWindow(nsIDOMWindow aFocusedWindow); + nsresult GetFocusedElement(nsIDOMElement *aFocusedElement); + nsresult SetFocusedElement(nsIDOMElement aFocusedElement); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWebNavigation.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWebNavigation.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,60 @@ +module dwt.internal.mozilla.nsIWebNavigation; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMDocument; +import dwt.internal.mozilla.nsIInputStream; +import dwt.internal.mozilla.nsISHistory; +import dwt.internal.mozilla.nsIURI; + +const char[] NS_IWEBNAVIGATION_IID_STR = "f5d9e7b0-d930-11d3-b057-00a024ffc08c"; + +const nsIID NS_IWEBNAVIGATION_IID= + {0xf5d9e7b0, 0xd930, 0x11d3, + [ 0xb0, 0x57, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c ]}; + +extern(System) + +interface nsIWebNavigation : nsISupports { + + static const char[] IID_STR = NS_IWEBNAVIGATION_IID_STR; + static const nsIID IID = NS_IWEBNAVIGATION_IID; + + nsresult GetCanGoBack(PRBool *aCanGoBack); + nsresult GetCanGoForward(PRBool *aCanGoForward); + nsresult GoBack(); + nsresult GoForward(); + nsresult GotoIndex(PRInt32 index); + + enum { LOAD_FLAGS_MASK = 65535U }; + enum { LOAD_FLAGS_NONE = 0U }; + enum { LOAD_FLAGS_IS_REFRESH = 16U }; + enum { LOAD_FLAGS_IS_LINK = 32U }; + enum { LOAD_FLAGS_BYPASS_HISTORY = 64U }; + enum { LOAD_FLAGS_REPLACE_HISTORY = 128U }; + enum { LOAD_FLAGS_BYPASS_CACHE = 256U }; + enum { LOAD_FLAGS_BYPASS_PROXY = 512U }; + enum { LOAD_FLAGS_CHARSET_CHANGE = 1024U }; + enum { LOAD_FLAGS_STOP_CONTENT = 2048U }; + enum { LOAD_FLAGS_FROM_EXTERNAL = 4096U }; + enum { LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 8192U }; + enum { LOAD_FLAGS_FIRST_LOAD = 16384U }; + + nsresult LoadURI(PRUnichar *aURI, PRUint32 aLoadFlags, nsIURI aReferrer, nsIInputStream aPostData, nsIInputStream aHeaders); + nsresult Reload(PRUint32 aReloadFlags); + + enum { STOP_NETWORK = 1U }; + enum { STOP_CONTENT = 2U }; + enum { STOP_ALL = 3U }; + + nsresult Stop(PRUint32 aStopFlags); + nsresult GetDocument(nsIDOMDocument *aDocument); + nsresult GetCurrentURI(nsIURI *aCurrentURI); + nsresult GetReferringURI(nsIURI *aReferringURI); + nsresult GetSessionHistory(nsISHistory *aSessionHistory); + nsresult SetSessionHistory(nsISHistory aSessionHistory); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWebNavigationInfo.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWebNavigationInfo.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,30 @@ +module dwt.internal.mozilla.nsIWebNavigationInfo; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; +import dwt.internal.mozilla.nsIWebNavigation; +import dwt.internal.mozilla.nsStringAPI; + +const char[] NS_IWEBNAVIGATIONINFO_IID_STR = "62a93afb-93a1-465c-84c8-0432264229de"; + +const nsIID NS_IWEBNAVIGATIONINFO_IID= + {0x62a93afb, 0x93a1, 0x465c, + [ 0x84, 0xc8, 0x04, 0x32, 0x26, 0x42, 0x29, 0xde ]}; + +extern(System) + +interface nsIWebNavigationInfo : nsISupports { + + static const char[] IID_STR = NS_IWEBNAVIGATIONINFO_IID_STR; + static const nsIID IID = NS_IWEBNAVIGATIONINFO_IID; + + enum { UNSUPPORTED = 0U }; + enum { IMAGE = 1U }; + enum { PLUGIN = 2U }; + enum { OTHER = 32768U }; + + nsresult IsTypeSupported(nsACString * aType, nsIWebNavigation aWebNav, PRUint32 *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWebProgress.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWebProgress.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,40 @@ +module dwt.internal.mozilla.nsIWebProgress; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsIWebProgressListener; + +const char[] NS_IWEBPROGRESS_IID_STR = "570f39d0-efd0-11d3-b093-00a024ffc08c"; + +const nsIID NS_IWEBPROGRESS_IID= + {0x570f39d0, 0xefd0, 0x11d3, + [ 0xb0, 0x93, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c ]}; + +extern(System) + +interface nsIWebProgress : nsISupports { + + static const char[] IID_STR = NS_IWEBPROGRESS_IID_STR; + static const nsIID IID = NS_IWEBPROGRESS_IID; + + enum { NOTIFY_STATE_REQUEST = 1U }; + enum { NOTIFY_STATE_DOCUMENT = 2U }; + enum { NOTIFY_STATE_NETWORK = 4U }; + enum { NOTIFY_STATE_WINDOW = 8U }; + enum { NOTIFY_STATE_ALL = 15U }; + enum { NOTIFY_PROGRESS = 16U }; + enum { NOTIFY_STATUS = 32U }; + enum { NOTIFY_SECURITY = 64U }; + enum { NOTIFY_LOCATION = 128U }; + enum { NOTIFY_ALL = 255U }; + + nsresult AddProgressListener(nsIWebProgressListener aListener, PRUint32 aNotifyMask); + nsresult RemoveProgressListener(nsIWebProgressListener aListener); + nsresult GetDOMWindow(nsIDOMWindow *aDOMWindow); + nsresult GetIsLoadingDocument(PRBool *aIsLoadingDocument); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWebProgressListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWebProgressListener.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,48 @@ +module dwt.internal.mozilla.nsIWebProgressListener; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIWebProgress; +import dwt.internal.mozilla.nsIRequest; +import dwt.internal.mozilla.nsIURI; + +const char[] NS_IWEBPROGRESSLISTENER_IID_STR = "570f39d1-efd0-11d3-b093-00a024ffc08c"; + +const nsIID NS_IWEBPROGRESSLISTENER_IID= + {0x570f39d1, 0xefd0, 0x11d3, + [ 0xb0, 0x93, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c ]}; + +extern(System) + +interface nsIWebProgressListener : nsISupports { + + static const char[] IID_STR = NS_IWEBPROGRESSLISTENER_IID_STR; + static const nsIID IID = NS_IWEBPROGRESSLISTENER_IID; + + enum { STATE_START = 1U }; + enum { STATE_REDIRECTING = 2U }; + enum { STATE_TRANSFERRING = 4U }; + enum { STATE_NEGOTIATING = 8U }; + enum { STATE_STOP = 16U }; + enum { STATE_IS_REQUEST = 65536U }; + enum { STATE_IS_DOCUMENT = 131072U }; + enum { STATE_IS_NETWORK = 262144U }; + enum { STATE_IS_WINDOW = 524288U }; + enum { STATE_RESTORING = 16777216U }; + enum { STATE_IS_INSECURE = 4U }; + enum { STATE_IS_BROKEN = 1U }; + enum { STATE_IS_SECURE = 2U }; + enum { STATE_SECURE_HIGH = 262144U }; + enum { STATE_SECURE_MED = 65536U }; + enum { STATE_SECURE_LOW = 131072U }; + + nsresult OnStateChange(nsIWebProgress aWebProgress, nsIRequest aRequest, PRUint32 aStateFlags, nsresult aStatus); + nsresult OnProgressChange(nsIWebProgress aWebProgress, nsIRequest aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress); + nsresult OnLocationChange(nsIWebProgress aWebProgress, nsIRequest aRequest, nsIURI aLocation); + nsresult OnStatusChange(nsIWebProgress aWebProgress, nsIRequest aRequest, nsresult aStatus, PRUnichar *aMessage); + nsresult OnSecurityChange(nsIWebProgress aWebProgress, nsIRequest aRequest, PRUint32 aState); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWebProgressListener2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWebProgressListener2.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,26 @@ +module dwt.internal.mozilla.nsIWebProgressListener2; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIWebProgressListener; +import dwt.internal.mozilla.nsIWebProgress; +import dwt.internal.mozilla.nsIRequest; + +const char[] NS_IWEBPROGRESSLISTENER2_IID_STR = "3f24610d-1e1f-4151-9d2e-239884742324"; + +const nsIID NS_IWEBPROGRESSLISTENER2_IID= + {0x3f24610d, 0x1e1f, 0x4151, + [ 0x9d, 0x2e, 0x23, 0x98, 0x84, 0x74, 0x23, 0x24 ]}; + +extern(System) + +interface nsIWebProgressListener2 : nsIWebProgressListener { + + static const char[] IID_STR = NS_IWEBPROGRESSLISTENER2_IID_STR; + static const nsIID IID = NS_IWEBPROGRESSLISTENER2_IID; + + nsresult OnProgressChange64(nsIWebProgress aWebProgress, nsIRequest aRequest, PRInt64 aCurSelfProgress, PRInt64 aMaxSelfProgress, PRInt64 aCurTotalProgress, PRInt64 aMaxTotalProgress); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWindowCreator.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWindowCreator.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,25 @@ +module dwt.internal.mozilla.nsIWindowCreator; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIWebBrowserChrome; + +const char[] NS_IWINDOWCREATOR_IID_STR = "30465632-a777-44cc-90f9-8145475ef999"; + +const nsIID NS_IWINDOWCREATOR_IID= + {0x30465632, 0xa777, 0x44cc, + [ 0x90, 0xf9, 0x81, 0x45, 0x47, 0x5e, 0xf9, 0x99 ]}; + +extern(System) + +interface nsIWindowCreator : nsISupports { + + static const char[] IID_STR = NS_IWINDOWCREATOR_IID_STR; + static const nsIID IID = NS_IWINDOWCREATOR_IID; + + nsresult CreateChromeWindow(nsIWebBrowserChrome parent, PRUint32 chromeFlags, nsIWebBrowserChrome *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWindowCreator2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWindowCreator2.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,27 @@ +module dwt.internal.mozilla.nsIWindowCreator2; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; + +import dwt.internal.mozilla.nsIWindowCreator; +import dwt.internal.mozilla.nsIURI; +import dwt.internal.mozilla.nsIWebBrowserChrome; + +const char[] NS_IWINDOWCREATOR2_IID_STR = "f673ec81-a4b0-11d6-964b-eb5a2bf216fc"; + +const nsIID NS_IWINDOWCREATOR2_IID= + {0xf673ec81, 0xa4b0, 0x11d6, + [ 0x96, 0x4b, 0xeb, 0x5a, 0x2b, 0xf2, 0x16, 0xfc ]}; + +extern(System) + +interface nsIWindowCreator2 : nsIWindowCreator { + + static const char[] IID_STR = NS_IWINDOWCREATOR2_IID_STR; + static const nsIID IID = NS_IWINDOWCREATOR2_IID; + + enum { PARENT_IS_LOADING_OR_RUNNING_TIMEOUT = 1U }; + nsresult CreateChromeWindow2(nsIWebBrowserChrome parent, PRUint32 chromeFlags, PRUint32 contextFlags, nsIURI uri, PRBool *cancel, nsIWebBrowserChrome *_retval); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsIWindowWatcher.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsIWindowWatcher.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,41 @@ +module dwt.internal.mozilla.nsIWindowWatcher; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsID; +import dwt.internal.mozilla.nsISupports; + +import dwt.internal.mozilla.nsIDOMWindow; +import dwt.internal.mozilla.nsIObserver; +import dwt.internal.mozilla.nsIPrompt; +import dwt.internal.mozilla.nsIAuthPrompt; +import dwt.internal.mozilla.nsISimpleEnumerator; +import dwt.internal.mozilla.nsIWebBrowserChrome; +import dwt.internal.mozilla.nsIWindowCreator; + +const char[] NS_IWINDOWWATCHER_IID_STR = "002286a8-494b-43b3-8ddd-49e3fc50622b"; + +const nsIID NS_IWINDOWWATCHER_IID= + {0x002286a8, 0x494b, 0x43b3, + [ 0x8d, 0xdd, 0x49, 0xe3, 0xfc, 0x50, 0x62, 0x2b ]}; + +extern(System) + +interface nsIWindowWatcher : nsISupports { + + static const char[] IID_STR = NS_IWINDOWWATCHER_IID_STR; + static const nsIID IID = NS_IWINDOWWATCHER_IID; + + nsresult OpenWindow(nsIDOMWindow aParent, char *aUrl, char *aName, char *aFeatures, nsISupports aArguments, nsIDOMWindow *_retval); + nsresult RegisterNotification(nsIObserver aObserver); + nsresult UnregisterNotification(nsIObserver aObserver); + nsresult GetWindowEnumerator(nsISimpleEnumerator *_retval); + nsresult GetNewPrompter(nsIDOMWindow aParent, nsIPrompt *_retval); + nsresult GetNewAuthPrompter(nsIDOMWindow aParent, nsIAuthPrompt *_retval); + nsresult SetWindowCreator(nsIWindowCreator creator); + nsresult GetChromeForWindow(nsIDOMWindow aWindow, nsIWebBrowserChrome *_retval); + nsresult GetWindowByName(PRUnichar *aTargetName, nsIDOMWindow aCurrentWindow, nsIDOMWindow *_retval); + nsresult GetActiveWindow(nsIDOMWindow *aActiveWindow); + nsresult SetActiveWindow(nsIDOMWindow aActiveWindow); + +} + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsStringAPI.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsStringAPI.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,187 @@ +module dwt.internal.mozilla.nsStringAPI; + +import dwt.internal.mozilla.Common; + +extern (System): + +/****************************************************************************** + +******************************************************************************/ + +enum +{ + NS_STRING_CONTAINER_INIT_DEPEND = 2, + NS_STRING_CONTAINER_INIT_ADOPT = 4, + NS_STRING_CONTAINER_INIT_SUBSTRING = 8, +} + +nsresult NS_StringContainerInit ( nsStringContainer *aContainer ); +nsresult NS_StringContainerInit2( nsStringContainer *aContainer, PRUnichar *aData, PRUint32 aDataLength, PRUint32 aFlags ); +void NS_StringContainerFinish(nsStringContainer *aContainer); +PRUint32 NS_StringGetData(nsAString *aStr, PRUnichar **aData, PRBool *aTerminated); +PRUint32 NS_StringGetMutableData(nsAString *aStr, PRUint32 aDataLength, PRUnichar **aData); +PRUnichar * NS_StringCloneData(nsAString *aStr); +nsresult NS_StringSetData(nsAString *aStr, PRUnichar *aData, PRUint32 aDataLength); +nsresult NS_StringSetDataRange( nsAString *aStr, PRUint32 aCutOffset, PRUint32 aCutLength, PRUnichar *aData, PRUint32 aDataLength ); +nsresult NS_StringCopy(nsAString *aDestStr, nsAString *aSrcStr); + +/****************************************************************************** + +******************************************************************************/ + +enum +{ + NS_CSTRING_CONTAINER_INIT_DEPEND = 2, + NS_CSTRING_CONTAINER_INIT_ADOPT = 4, + NS_CSTRING_CONTAINER_INIT_SUBSTRING = 8, +} + +nsresult NS_CStringContainerInit( nsCStringContainer *aContainer ); +nsresult NS_CStringContainerInit2( nsCStringContainer *aContainer, char *aData, PRUint32 aDataLength, PRUint32 aFlags ); +void NS_CStringContainerFinish( nsCStringContainer *aContainer ); +PRUint32 NS_CStringGetData( nsACString *aStr, char **aData, PRBool *aTerminated ); +PRUint32 NS_CStringGetMutableData( nsACString *aStr, PRUint32 aDataLength, char **aData ); +char * NS_CStringCloneData( nsACString *aStr); +nsresult NS_CStringSetData( nsACString *aStr, char *aData, PRUint32 aDataLength ); +nsresult NS_CStringSetDataRange( nsACString *aStr, PRUint32 aCutOffset, + PRUint32 aCutLength, char *aData, PRUint32 aDataLength ); +nsresult NS_CStringCopy( nsACString *aDestStr, nsACString *aSrcStr ); + +/****************************************************************************** + +******************************************************************************/ + +enum nsCStringEncoding +{ + NS_CSTRING_ENCODING_ASCII, + NS_CSTRING_ENCODING_UTF8, + NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, +} + +nsresult NS_CStringToUTF16( nsACString *aSource, int aSrcEncoding, nsAString *aDest ); +nsresult NS_UTF16ToCString( nsAString *aSource, int aDestEncoding, nsACString *aDest ); + +/****************************************************************************** + +******************************************************************************/ + +alias nsAString nsAString_external; +alias nsACString nsACString_external; + +alias nsAString nsEmbedString; +alias nsACString nsEmbedCString; + +struct nsAString +{ + static nsAString opCall(wchar[] s) + { + nsAString result; + NS_StringSetData(&result, cast(PRUnichar*)s, uint.max); + return result; + } + + private: + void *v; +} + +struct nsACString +{ + static nsACString opCall(char[] s) + { + nsACString result; + NS_CStringSetData(&result, cast(char*)s, uint.max); + return result; + } + + private: + void *v; +} + +/****************************************************************************** + +******************************************************************************/ + +struct nsStringContainer// : public nsAString +{ +private: + void* v; + void* d1; + uint d2; + void* d3; +} + +struct nsCStringContainer// : public nsACString +{ +private: + void* v; + void* d1; + uint d2; + void* d3; +} + +/****************************************************************************** + +******************************************************************************/ + +// import mozilla.xpcom.nsDebug; + +alias nsString_external nsString; +alias nsCString_external nsCString; +alias nsDependentString_external nsDependentString; +alias nsDependentCString_external nsDependentCString; +alias NS_ConvertASCIItoUTF16_external NS_ConvertASCIItoUTF16; +alias NS_ConvertUTF8toUTF16_external NS_ConvertUTF8toUTF16; +alias NS_ConvertUTF16toUTF8_external NS_ConvertUTF16toUTF8; +alias NS_LossyConvertUTF16toASCII_external NS_LossyConvertUTF16toASCII; +alias nsGetterCopies_external nsGetterCopies; +alias nsCGetterCopies_external nsCGetterCopies; +alias nsDependentSubstring_external nsDependentSubstring; +alias nsDependentCSubstring_external nsDependentCSubstring; + +struct nsString_external{} +struct nsCString_external{} +struct nsDependentString_external{} +struct nsDependentCString_external{} +struct NS_ConvertASCIItoUTF16_external{} +struct NS_ConvertUTF8toUTF16_external{} +struct NS_ConvertUTF16toUTF8_external{} +struct NS_LossyConvertUTF16toASCII_external{} + +/****************************************************************************** + +******************************************************************************/ + +struct nsGetterCopies_external +{ + private: + alias PRUnichar char_type; + nsString_external *mString; + char_type *mData; +} + +struct nsCGetterCopies_external +{ + private: + alias char char_type; + nsCString_external *mString; + char_type *mData; +} + +/****************************************************************************** + +******************************************************************************/ + +struct nsDependentSubstring_external{} +struct nsDependentCSubstring_external{} + +/****************************************************************************** + +******************************************************************************/ + +PRUint32 strlen_PRUnichar ( PRUnichar* str ) +{ + PRUint32 len = 0; + if (str !is null) + while (*(lparg0++) != 0) len++; + ret len; +} \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsStringAPI.d~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsStringAPI.d~ Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,187 @@ +module dwt.internal.mozilla.nsStringAPI; + +import dwt.internal.mozilla.Common; + +extern (System): + +/****************************************************************************** + +******************************************************************************/ + +enum +{ + NS_STRING_CONTAINER_INIT_DEPEND = 2, + NS_STRING_CONTAINER_INIT_ADOPT = 4, + NS_STRING_CONTAINER_INIT_SUBSTRING = 8, +} + +nsresult NS_StringContainerInit ( nsStringContainer *aContainer ); +nsresult NS_StringContainerInit2( nsStringContainer *aContainer, PRUnichar *aData, PRUint32 aDataLength, PRUint32 aFlags ); +void NS_StringContainerFinish(nsStringContainer *aContainer); +PRUint32 NS_StringGetData(nsAString *aStr, PRUnichar **aData, PRBool *aTerminated); +PRUint32 NS_StringGetMutableData(nsAString *aStr, PRUint32 aDataLength, PRUnichar **aData); +PRUnichar * NS_StringCloneData(nsAString *aStr); +nsresult NS_StringSetData(nsAString *aStr, PRUnichar *aData, PRUint32 aDataLength); +nsresult NS_StringSetDataRange( nsAString *aStr, PRUint32 aCutOffset, PRUint32 aCutLength, PRUnichar *aData, PRUint32 aDataLength ); +nsresult NS_StringCopy(nsAString *aDestStr, nsAString *aSrcStr); + +/****************************************************************************** + +******************************************************************************/ + +enum +{ + NS_CSTRING_CONTAINER_INIT_DEPEND = 2, + NS_CSTRING_CONTAINER_INIT_ADOPT = 4, + NS_CSTRING_CONTAINER_INIT_SUBSTRING = 8, +} + +nsresult NS_CStringContainerInit( nsCStringContainer *aContainer ); +nsresult NS_CStringContainerInit2( nsCStringContainer *aContainer, char *aData, PRUint32 aDataLength, PRUint32 aFlags ); +void NS_CStringContainerFinish( nsCStringContainer *aContainer ); +PRUint32 NS_CStringGetData( nsACString *aStr, char **aData, PRBool *aTerminated ); +PRUint32 NS_CStringGetMutableData( nsACString *aStr, PRUint32 aDataLength, char **aData ); +char * NS_CStringCloneData( nsACString *aStr); +nsresult NS_CStringSetData( nsACString *aStr, char *aData, PRUint32 aDataLength ); +nsresult NS_CStringSetDataRange( nsACString *aStr, PRUint32 aCutOffset, + PRUint32 aCutLength, char *aData, PRUint32 aDataLength ); +nsresult NS_CStringCopy( nsACString *aDestStr, nsACString *aSrcStr ); + +/****************************************************************************** + +******************************************************************************/ + +enum nsCStringEncoding +{ + NS_CSTRING_ENCODING_ASCII, + NS_CSTRING_ENCODING_UTF8, + NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, +} + +nsresult NS_CStringToUTF16( nsACString *aSource, int aSrcEncoding, nsAString *aDest ); +nsresult NS_UTF16ToCString( nsAString *aSource, int aDestEncoding, nsACString *aDest ); + +/****************************************************************************** + +******************************************************************************/ + +alias nsAString nsAString_external; +alias nsACString nsACString_external; + +alias nsAString nsEmbedString; +alias nsACString nsEmbedCString; + +struct nsAString +{ + static nsAString opCall(wchar[] s) + { + nsAString result; + NS_StringSetData(&result, cast(PRUnichar*)s, uint.max); + return result; + } + + private: + void *v; +} + +struct nsACString +{ + static nsACString opCall(char[] s) + { + nsACString result; + NS_CStringSetData(&result, cast(char*)s, uint.max); + return result; + } + + private: + void *v; +} + +/****************************************************************************** + +******************************************************************************/ + +struct nsStringContainer// : public nsAString +{ +private: + void* v; + void* d1; + uint d2; + void* d3; +} + +struct nsCStringContainer// : public nsACString +{ +private: + void* v; + void* d1; + uint d2; + void* d3; +} + +/****************************************************************************** + +******************************************************************************/ + +// import mozilla.xpcom.nsDebug; + +alias nsString_external nsString; +alias nsCString_external nsCString; +alias nsDependentString_external nsDependentString; +alias nsDependentCString_external nsDependentCString; +alias NS_ConvertASCIItoUTF16_external NS_ConvertASCIItoUTF16; +alias NS_ConvertUTF8toUTF16_external NS_ConvertUTF8toUTF16; +alias NS_ConvertUTF16toUTF8_external NS_ConvertUTF16toUTF8; +alias NS_LossyConvertUTF16toASCII_external NS_LossyConvertUTF16toASCII; +alias nsGetterCopies_external nsGetterCopies; +alias nsCGetterCopies_external nsCGetterCopies; +alias nsDependentSubstring_external nsDependentSubstring; +alias nsDependentCSubstring_external nsDependentCSubstring; + +struct nsString_external{} +struct nsCString_external{} +struct nsDependentString_external{} +struct nsDependentCString_external{} +struct NS_ConvertASCIItoUTF16_external{} +struct NS_ConvertUTF8toUTF16_external{} +struct NS_ConvertUTF16toUTF8_external{} +struct NS_LossyConvertUTF16toASCII_external{} + +/****************************************************************************** + +******************************************************************************/ + +struct nsGetterCopies_external +{ + private: + alias PRUnichar char_type; + nsString_external *mString; + char_type *mData; +} + +struct nsCGetterCopies_external +{ + private: + alias char char_type; + nsCString_external *mString; + char_type *mData; +} + +/****************************************************************************** + +******************************************************************************/ + +struct nsDependentSubstring_external{} +struct nsDependentCSubstring_external{} + +/****************************************************************************** + +******************************************************************************/ + +PRUint32 strlen_PRUnichar ( PRUnichar* str ) +{ + PRUint32 len = 0; + if (str !is null) + while (*lparg0++ != 0) len++; + ret len; +} \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsXPCOM.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsXPCOM.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,53 @@ + +module dwt.internal.mozilla.nsXPCOM; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsStringAPI; +import dwt.internal.mozilla.nsIModule; +import dwt.internal.mozilla.nsIComponentManager; +import dwt.internal.mozilla.nsIComponentRegistrar; +import dwt.internal.mozilla.nsIServiceManager; +import dwt.internal.mozilla.nsIFile; +import dwt.internal.mozilla.nsILocalFile; +import dwt.internal.mozilla.nsIDirectoryService; +import dwt.internal.mozilla.nsIMemory; +import dwt.internal.mozilla.nsIDebug; +import dwt.internal.mozilla.nsITraceRefcnt; + +/****************************************************************************** + +******************************************************************************/ + +extern (System): + +struct nsStaticModuleInfo +{ + char *name; + nsGetModuleProc getModule; +} + +alias nsresult function (nsIComponentManager, nsIFile, nsIModule*) nsGetModuleProc; + +/****************************************************************************** + +******************************************************************************/ + +nsresult NS_InitXPCOM2( nsIServiceManager *result, nsIFile binDirectory, + nsIDirectoryServiceProvider appFileLocationProvider ); +nsresult NS_InitXPCOM3( nsIServiceManager *result, nsIFile binDirectory, + nsIDirectoryServiceProvider appFileLocationProvider, + nsStaticModuleInfo* staticComponents, + PRUint32 componentCount ); + +nsresult NS_ShutdownXPCOM(nsIServiceManager servMgr); +nsresult NS_GetServiceManager(nsIServiceManager *result); +nsresult NS_GetComponentManager(nsIComponentManager *result); +nsresult NS_GetComponentRegistrar(nsIComponentRegistrar *result); +nsresult NS_GetMemoryManager(nsIMemory *result); +nsresult NS_NewLocalFile(inout nsAString path, PRBool followLinks, nsILocalFile** result); +nsresult NS_NewNativeLocalFile(inout nsACString path, PRBool followLinks, nsILocalFile** result); +void * NS_Alloc(PRSize size); +void * NS_Realloc(void *ptr, PRSize size); +void NS_Free(void *ptr); +nsresult NS_GetDebug(nsIDebug **result); +nsresult NS_GetTraceRefcnt(nsITraceRefcnt *result); diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsXPCOM.d~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsXPCOM.d~ Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,54 @@ +/****************************************************************************** + +module dwt.internal.mozilla.nsXPCOM; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.nsStringAPI; +import dwt.internal.mozilla.nsIModule; +import dwt.internal.mozilla.nsIComponentManager; +import dwt.internal.mozilla.nsIComponentRegistrar; +import dwt.internal.mozilla.nsIServiceManager; +import dwt.internal.mozilla.nsIFile; +import dwt.internal.mozilla.nsILocalFile; +import dwt.internal.mozilla.nsIDirectoryService; +import dwt.internal.mozilla.nsIMemory; +import dwt.internal.mozilla.nsIDebug; +import dwt.internal.mozilla.nsITraceRefcnt; + +/****************************************************************************** + +******************************************************************************/ + +extern (System): + +struct nsStaticModuleInfo +{ + char *name; + nsGetModuleProc getModule; +} + +alias nsresult function (nsIComponentManager, nsIFile, nsIModule*) nsGetModuleProc; + +/****************************************************************************** + +******************************************************************************/ + +nsresult NS_InitXPCOM2( nsIServiceManager *result, nsIFile binDirectory, + nsIDirectoryServiceProvider appFileLocationProvider ); +nsresult NS_InitXPCOM3( nsIServiceManager *result, nsIFile binDirectory, + nsIDirectoryServiceProvider appFileLocationProvider, + nsStaticModuleInfo* staticComponents, + PRUint32 componentCount ); + +nsresult NS_ShutdownXPCOM(nsIServiceManager servMgr); +nsresult NS_GetServiceManager(nsIServiceManager *result); +nsresult NS_GetComponentManager(nsIComponentManager *result); +nsresult NS_GetComponentRegistrar(nsIComponentRegistrar *result); +nsresult NS_GetMemoryManager(nsIMemory *result); +nsresult NS_NewLocalFile(inout nsAString path, PRBool followLinks, nsILocalFile** result); +nsresult NS_NewNativeLocalFile(inout nsACString path, PRBool followLinks, nsILocalFile** result); +void * NS_Alloc(PRSize size); +void * NS_Realloc(void *ptr, PRSize size); +void NS_Free(void *ptr); +nsresult NS_GetDebug(nsIDebug **result); +nsresult NS_GetTraceRefcnt(nsITraceRefcnt *result); diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/nsXPCOMGlue.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/nsXPCOMGlue.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,37 @@ +module dwt.internal.mozilla.nsXPCOMGlue; + +extern(C): + +align(4): + +struct GREVersionRange { + char *lower; + int lowerInclusive; + char *upper; + int upperInclusive; +} + +struct GREProperty { + char *property; + char *value; +} + +uint GRE_GetGREPathWithProperties(GREVersionRange *versions, + int versionsLength, + GREProperty *properties, + uint propertiesLength, + char *buffer, uint buflen); + +uint XPCOMGlueStartup(char* xpcomFile); + +alias void function() NSFuncPtr; + +struct nsDynamicFunctionLoad +{ + char *functionName; + NSFuncPtr *func; +} + +uint XPCOMGlueLoadXULFunctions(nsDynamicFunctionLoad *symbols); +uint XPCOMGlueShutdown(); + diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/prinrval.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/prinrval.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,60 @@ +module dwt.internal.mozilla.prinrval; + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.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 the Netscape Portable Runtime (NSPR). + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +import dwt.internal.mozilla.Common; + +extern (System): + +alias PRUint32 PRIntervalTime; + +const PR_INTERVAL_MIN = 1000U; +const PR_INTERVAL_MAX = 100000U; +const PR_INTERVAL_NO_WAIT = 0U; +const PR_INTERVAL_NO_TIMEOUT = 0xffffffffU; + +version(NON_XPCOM_GLUE) +{ + PRIntervalTime PR_IntervalNow(); + PRUint32 PR_TicksPerSecond(); + PRIntervalTime PR_SecondsToInterval(PRUint32 seconds); + PRIntervalTime PR_MillisecondsToInterval(PRUint32 milli); + PRIntervalTime PR_MicrosecondsToInterval(PRUint32 micro); + PRUint32 PR_IntervalToSeconds(PRIntervalTime ticks); + PRUint32 PR_IntervalToMilliseconds(PRIntervalTime ticks); + PRUint32 PR_IntervalToMicroseconds(PRIntervalTime ticks); +} \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/prio.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/prio.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,517 @@ +module dwt.internal.mozilla.prio; + +import dwt.internal.mozilla.Common; +import dwt.internal.mozilla.prtime; +import dwt.internal.mozilla.prinrval; + +extern (System): + +alias PRIntn PRDescIdentity; +alias void PRFilePrivate; + +struct PRFileDesc +{ + PRIOMethods *methods; + PRFilePrivate *secret; + PRFileDesc *lower; + PRFileDesc *higher; + void function(PRFileDesc *fd)dtor; + PRDescIdentity identity; +} + +enum PRTransmitFileFlags +{ + PR_TRANSMITFILE_KEEP_OPEN, + PR_TRANSMITFILE_CLOSE_SOCKET, +} + +const PR_AF_INET = 2; +const PR_AF_LOCAL = 1; +const PR_INADDR_LOOPBACK = 0x7f000001; +const PR_AF_UNSPEC = 0; + +union _N2 +{ + PRUint8 [16]_S6_u8; + PRUint16 [8]_S6_u16; + PRUint32 [4]_S6_u32; + PRUint64 [2]_S6_u64; +} + +struct PRIPv6Addr +{ + struct _N2{ + union + { + PRUint8 [16]_S6_u8; + PRUint16 [8]_S6_u16; + PRUint32 [4]_S6_u32; + PRUint64 [2]_S6_u64; + } + } + _N2 _S6_un; +} + +struct _N3 +{ + PRUint16 family; + char [14]data; +} + +struct _N4 +{ + PRUint16 family; + PRUint16 port; + PRUint32 ip; + char [8]pad; +} + +struct _N5 +{ + PRUint16 family; + PRUint16 port; + PRUint32 flowinfo; + PRIPv6Addr ip; + PRUint32 scope_id; +} + +union PRNetAddr +{ + struct _N3 + { + PRUint16 family; + char [14]data; + } + _N3 raw; + struct _N4 + { + PRUint16 family; + PRUint16 port; + PRUint32 ip; + char [8]pad; + } + _N4 inet; + struct _N5 + { + PRUint16 family; + PRUint16 port; + PRUint32 flowinfo; + PRIPv6Addr ip; + PRUint32 scope_id; + } + _N5 ipv6; +} + +enum PRSockOption +{ + PR_SockOpt_Nonblocking, + PR_SockOpt_Linger, + PR_SockOpt_Reuseaddr, + PR_SockOpt_Keepalive, + PR_SockOpt_RecvBufferSize, + PR_SockOpt_SendBufferSize, + PR_SockOpt_IpTimeToLive, + PR_SockOpt_IpTypeOfService, + PR_SockOpt_AddMember, + PR_SockOpt_DropMember, + PR_SockOpt_McastInterface, + PR_SockOpt_McastTimeToLive, + PR_SockOpt_McastLoopback, + PR_SockOpt_NoDelay, + PR_SockOpt_MaxSegment, + PR_SockOpt_Broadcast, + PR_SockOpt_Last, +} + +struct PRLinger +{ + PRBool polarity; + PRIntervalTime linger; +} + +struct PRMcastRequest +{ + PRNetAddr mcaddr; + PRNetAddr ifaddr; +} + +union _N6 +{ + PRUintn ip_ttl; + PRUintn mcast_ttl; + PRUintn tos; + PRBool non_blocking; + PRBool reuse_addr; + PRBool keep_alive; + PRBool mcast_loopback; + PRBool no_delay; + PRBool broadcast; + PRSize max_segment; + PRSize recv_buffer_size; + PRSize send_buffer_size; + PRLinger linger; + PRMcastRequest add_member; + PRMcastRequest drop_member; + PRNetAddr mcast_if; +} + +struct PRSocketOptionData +{ + int option; + union _N6 + { + PRUintn ip_ttl; + PRUintn mcast_ttl; + PRUintn tos; + PRBool non_blocking; + PRBool reuse_addr; + PRBool keep_alive; + PRBool mcast_loopback; + PRBool no_delay; + PRBool broadcast; + PRSize max_segment; + PRSize recv_buffer_size; + PRSize send_buffer_size; + PRLinger linger; + PRMcastRequest add_member; + PRMcastRequest drop_member; + PRNetAddr mcast_if; + } + _N6 value; +} + +struct PRIOVec +{ + char *iov_base; + int iov_len; +} + +enum PRDescType +{ + PR_DESC_FILE = 1, + PR_DESC_SOCKET_TCP, + PR_DESC_SOCKET_UDP, + PR_DESC_LAYERED, + PR_DESC_PIPE, +} + +enum PRSeekWhence +{ + PR_SEEK_SET, + PR_SEEK_CUR, + PR_SEEK_END, +} + +version(NON_XPCOM_GLUE){ + int PR_GetDescType(PRFileDesc *file); +} + +alias PRStatus function(PRFileDesc *fd)PRCloseFN; +alias PRInt32 function(PRFileDesc *fd, void *buf, PRInt32 amount)PRReadFN; +alias PRInt32 function(PRFileDesc *fd, void *buf, PRInt32 amount)PRWriteFN; +alias PRInt32 function(PRFileDesc *fd)PRAvailableFN; +alias PRInt64 function(PRFileDesc *fd)PRAvailable64FN; +alias PRStatus function(PRFileDesc *fd)PRFsyncFN; +alias PROffset32 function(PRFileDesc *fd, PROffset32 offset, int how)PRSeekFN; +alias PROffset64 function(PRFileDesc *fd, PROffset64 offset, int how)PRSeek64FN; +alias PRStatus function(PRFileDesc *fd, PRFileInfo *info)PRFileInfoFN; +alias PRStatus function(PRFileDesc *fd, PRFileInfo64 *info)PRFileInfo64FN; +alias PRInt32 function(PRFileDesc *fd, PRIOVec *iov, PRInt32 iov_size, PRIntervalTime timeout)PRWritevFN; +alias PRStatus function(PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout)PRConnectFN; +alias PRFileDesc * function(PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout)PRAcceptFN; +alias PRStatus function(PRFileDesc *fd, PRNetAddr *addr)PRBindFN; +alias PRStatus function(PRFileDesc *fd, PRIntn backlog)PRListenFN; +alias PRStatus function(PRFileDesc *fd, PRIntn how)PRShutdownFN; +alias PRInt32 function(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout)PRRecvFN; +alias PRInt32 function(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout)PRSendFN; +alias PRInt32 function(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout)PRRecvfromFN; +alias PRInt32 function(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout)PRSendtoFN; +alias PRInt16 function(PRFileDesc *fd, PRInt16 in_flags, PRInt16 *out_flags)PRPollFN; +alias PRInt32 function(PRFileDesc *sd, PRFileDesc **nd, PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime t)PRAcceptreadFN; +alias PRInt32 function(PRFileDesc *sd, PRFileDesc *fd, void *headers, PRInt32 hlen, int flags, PRIntervalTime t)PRTransmitfileFN; +alias PRStatus function(PRFileDesc *fd, PRNetAddr *addr)PRGetsocknameFN; +alias PRStatus function(PRFileDesc *fd, PRNetAddr *addr)PRGetpeernameFN; +alias PRStatus function(PRFileDesc *fd, PRSocketOptionData *data)PRGetsocketoptionFN; +alias PRStatus function(PRFileDesc *fd, PRSocketOptionData *data)PRSetsocketoptionFN; +alias PRInt32 function(PRFileDesc *networkSocket, PRSendFileData *sendData, int flags, PRIntervalTime timeout)PRSendfileFN; +alias PRStatus function(PRFileDesc *fd, PRInt16 out_flags)PRConnectcontinueFN; +alias PRIntn function(PRFileDesc *fd)PRReservedFN; + +struct PRIOMethods +{ + int file_type; + PRCloseFN close; + PRReadFN read; + PRWriteFN write; + PRAvailableFN available; + PRAvailable64FN available64; + PRFsyncFN fsync; + PRSeekFN seek; + PRSeek64FN seek64; + PRFileInfoFN fileInfo; + PRFileInfo64FN fileInfo64; + PRWritevFN writev; + PRConnectFN connect; + PRAcceptFN accept; + PRBindFN bind; + PRListenFN listen; + PRShutdownFN shutdown; + PRRecvFN recv; + PRSendFN send; + PRRecvfromFN recvfrom; + PRSendtoFN sendto; + PRPollFN poll; + PRAcceptreadFN acceptread; + PRTransmitfileFN transmitfile; + PRGetsocknameFN getsockname; + PRGetpeernameFN getpeername; + PRReservedFN reserved_fn_6; + PRReservedFN reserved_fn_5; + PRGetsocketoptionFN getsocketoption; + PRSetsocketoptionFN setsocketoption; + PRSendfileFN sendfile; + PRConnectcontinueFN connectcontinue; + PRReservedFN reserved_fn_3; + PRReservedFN reserved_fn_2; + PRReservedFN reserved_fn_1; + PRReservedFN reserved_fn_0; +} + +enum PRSpecialFD +{ + PR_StandardInput, + PR_StandardOutput, + PR_StandardError, +} + +version(NON_XPCOM_GLUE) +{ + PRFileDesc * PR_GetSpecialFD(int id); + PRDescIdentity PR_GetUniqueIdentity(char *layer_name); + char * PR_GetNameForIdentity(PRDescIdentity ident); + PRDescIdentity PR_GetLayersIdentity(PRFileDesc *fd); + PRFileDesc * PR_GetIdentitiesLayer(PRFileDesc *fd_stack, PRDescIdentity id); + PRIOMethods * PR_GetDefaultIOMethods(); + PRFileDesc * PR_CreateIOLayerStub(PRDescIdentity ident, PRIOMethods *methods); + PRFileDesc * PR_CreateIOLayer(PRFileDesc *fd); + PRStatus PR_PushIOLayer(PRFileDesc *fd_stack, PRDescIdentity id, PRFileDesc *layer); + PRFileDesc * PR_PopIOLayer(PRFileDesc *fd_stack, PRDescIdentity id); +} + +const PR_RDONLY = 0x01; +const PR_WRONLY = 0x02; +const PR_RDWR = 0x04; +const PR_CREATE_FILE = 0x08; +const PR_APPEND = 0x10; +const PR_TRUNCATE = 0x20; +const PR_SYNC = 0x40; +const PR_EXCL = 0x80; + +version(NON_XPCOM_GLUE) { + PRFileDesc * PR_Open(char *name, PRIntn flags, PRIntn mode); +} + +const PR_IRWXU = 00700; +const PR_IRUSR = 00400; +const PR_IWUSR = 00200; +const PR_IXUSR = 00100; +const PR_IRWXG = 00070; +const PR_IRGRP = 00040; +const PR_IWGRP = 00020; +const PR_IXGRP = 00010; +const PR_IRWXO = 00007; +const PR_IROTH = 00004; +const PR_IWOTH = 00002; +const PR_IXOTH = 00001; + +version(NON_XPCOM_GLUE) +{ + PRFileDesc * PR_OpenFile(char *name, PRIntn flags, PRIntn mode); + PRStatus PR_Close(PRFileDesc *fd); + PRInt32 PR_Read(PRFileDesc *fd, void *buf, PRInt32 amount); + PRInt32 PR_Write(PRFileDesc *fd, void *buf, PRInt32 amount); +} + +const PR_MAX_IOVECTOR_SIZE = 16; + +version(NON_XPCOM_GLUE) +{ + PRInt32 PR_Writev(PRFileDesc *fd, PRIOVec *iov, PRInt32 iov_size, PRIntervalTime timeout); + PRStatus PR_Delete(char *name); +} + +enum PRFileType +{ + PR_FILE_FILE = 1, + PR_FILE_DIRECTORY, + PR_FILE_OTHER, +} + +struct PRFileInfo +{ + int type; + PROffset32 size; + PRTime creationTime; + PRTime modifyTime; +} + +struct PRFileInfo64 +{ + int type; + PROffset64 size; + PRTime creationTime; + PRTime modifyTime; +} + +version (NON_XPCOM_GLUE) +{ + PRStatus PR_GetFileInfo(char *fn, PRFileInfo *info); + PRStatus PR_GetFileInfo64(char *fn, PRFileInfo64 *info); + PRStatus PR_GetOpenFileInfo(PRFileDesc *fd, PRFileInfo *info); + PRStatus PR_GetOpenFileInfo64(PRFileDesc *fd, PRFileInfo64 *info); + PRStatus PR_Rename(char *from, char *to); +} + +enum PRAccessHow +{ + PR_ACCESS_EXISTS = 1, + PR_ACCESS_WRITE_OK, + PR_ACCESS_READ_OK, +} + +version(NON_XPCOM_GLUE) +{ + PRStatus PR_Access(char *name, int how); + PROffset32 PR_Seek(PRFileDesc *fd, PROffset32 offset, int whence); + PROffset64 PR_Seek64(PRFileDesc *fd, PROffset64 offset, int whence); + PRInt32 PR_Available(PRFileDesc *fd); + PRInt64 PR_Available64(PRFileDesc *fd); + PRStatus PR_Sync(PRFileDesc *fd); +} + +struct PRDirEntry +{ + char *name; +} + +alias void PRDir; + +version(NON_XPCOM_GLUE) { + PRDir * PR_OpenDir(char *name); +} + +enum PRDirFlags +{ + PR_SKIP_NONE, + PR_SKIP_DOT, + PR_SKIP_DOT_DOT, + PR_SKIP_BOTH, + PR_SKIP_HIDDEN, +} + +version(NON_XPCOM_GLUE) +{ + PRDirEntry * PR_ReadDir(PRDir *dir, int flags); + PRStatus PR_CloseDir(PRDir *dir); + PRStatus PR_MkDir(char *name, PRIntn mode); + PRStatus PR_MakeDir(char *name, PRIntn mode); + PRStatus PR_RmDir(char *name); + PRFileDesc * PR_NewUDPSocket(); + PRFileDesc * PR_NewTCPSocket(); + PRFileDesc * PR_OpenUDPSocket(PRIntn af); + PRFileDesc * PR_OpenTCPSocket(PRIntn af); + PRStatus PR_Connect(PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout); + PRStatus PR_ConnectContinue(PRFileDesc *fd, PRInt16 out_flags); + PRStatus PR_GetConnectStatus(PRPollDesc *pd); + PRFileDesc * PR_Accept(PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout); + PRStatus PR_Bind(PRFileDesc *fd, PRNetAddr *addr); + PRStatus PR_Listen(PRFileDesc *fd, PRIntn backlog); +} + +enum PRShutdownHow +{ + PR_SHUTDOWN_RCV, + PR_SHUTDOWN_SEND, + PR_SHUTDOWN_BOTH, +} + +version(NON_XPCOM_GLUE) { + PRStatus PR_Shutdown(PRFileDesc *fd, int how); +} + +const PR_MSG_PEEK = 0x2; + +version(NON_XPCOM_GLUE) +{ + PRInt32 PR_Recv(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout); + PRInt32 PR_Send(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout); + PRInt32 PR_RecvFrom(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout); + PRInt32 PR_SendTo(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout); + PRInt32 PR_TransmitFile(PRFileDesc *networkSocket, PRFileDesc *sourceFile, void *headers, PRInt32 hlen, int flags, PRIntervalTime timeout); +} + +struct PRSendFileData +{ + PRFileDesc *fd; + PRUint32 file_offset; + PRSize file_nbytes; + void *header; + PRInt32 hlen; + void *trailer; + PRInt32 tlen; +} + +version(NON_XPCOM_GLUE) +{ + PRInt32 PR_SendFile(PRFileDesc *networkSocket, PRSendFileData *sendData, int flags, PRIntervalTime timeout); + PRInt32 PR_AcceptRead(PRFileDesc *listenSock, PRFileDesc **acceptedSock, PRNetAddr **peerAddr, void *buf, PRInt32 amount, PRIntervalTime timeout); + PRStatus PR_NewTCPSocketPair(PRFileDesc **fds); + PRStatus PR_GetSockName(PRFileDesc *fd, PRNetAddr *addr); + PRStatus PR_GetPeerName(PRFileDesc *fd, PRNetAddr *addr); + PRStatus PR_GetSocketOption(PRFileDesc *fd, PRSocketOptionData *data); + PRStatus PR_SetSocketOption(PRFileDesc *fd, PRSocketOptionData *data); + PRStatus PR_SetFDInheritable(PRFileDesc *fd, PRBool inheritable); + PRFileDesc * PR_GetInheritedFD(char *name); +} + +enum PRFileMapProtect +{ + PR_PROT_READONLY, + PR_PROT_READWRITE, + PR_PROT_WRITECOPY, +} + +alias void PRFileMap; + +version(NON_XPCOM_GLUE) +{ + PRFileMap * PR_CreateFileMap(PRFileDesc *fd, PRInt64 size, int prot); + PRInt32 PR_GetMemMapAlignment(); + void * PR_MemMap(PRFileMap *fmap, PROffset64 offset, PRUint32 len); + PRStatus PR_MemUnmap(void *addr, PRUint32 len); + PRStatus PR_CloseFileMap(PRFileMap *fmap); + PRStatus PR_CreatePipe(PRFileDesc **readPipe, PRFileDesc **writePipe); +} + +struct PRPollDesc +{ + PRFileDesc *fd; + PRInt16 in_flags; + PRInt16 out_flags; +} + +const PR_POLL_READ = 0x1; +const PR_POLL_WRITE = 0x2; +const PR_POLL_EXCEPT = 0x4; +const PR_POLL_ERR = 0x8; +const PR_POLL_NVAL = 0x10; +const PR_POLL_HUP = 0x20; + +version(NON_XPCOM_GLUE) +{ + PRInt32 PR_Poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout); + PRFileDesc * PR_NewPollableEvent(); + PRStatus PR_DestroyPollableEvent(PRFileDesc *event); + PRStatus PR_SetPollableEvent(PRFileDesc *event); + PRStatus PR_WaitForPollableEvent(PRFileDesc *event); +} \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/prlink.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/prlink.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,134 @@ +module dwt.internal.mozilla.prlink; +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.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 the Netscape Portable Runtime (NSPR). + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +import dwt.internal.mozilla.Common; + +struct PRStaticLinkTable +{ + char *name; + void function()fp; +} + +extern (System): + +PRStatus PR_SetLibraryPath(char *path); + +char * PR_GetLibraryPath(); +char * PR_GetLibraryName(char *dir, char *lib); +void PR_FreeLibraryName(char *mem); + +alias void PRLibrary; + +PRLibrary * PR_LoadLibrary(char *name); + +enum PRLibSpecType +{ + PR_LibSpec_Pathname, + PR_LibSpec_MacNamedFragment, + PR_LibSpec_MacIndexedFragment, +} + +alias void FSSpec; + +struct _N3 +{ + FSSpec *fsspec; + char *name; +} + +struct _N4 +{ + FSSpec *fsspec; + PRUint32 index; +} + +union _N2 +{ + char *pathname; + struct _N3 + { + FSSpec *fsspec; + char *name; + } + _N3 mac_named_fragment; + struct _N4 + { + FSSpec *fsspec; + PRUint32 index; + } + _N4 mac_indexed_fragment; +} + +struct PRLibSpec +{ + int type; + union _N2 + { + char *pathname; + struct _N3 + { + FSSpec *fsspec; + char *name; + } + _N3 mac_named_fragment; + struct _N4 + { + FSSpec *fsspec; + PRUint32 index; + } + _N4 mac_indexed_fragment; + } + _N2 value; +} + +const PR_LD_LAZY = 0x1; +const PR_LD_NOW = 0x2; +const PR_LD_GLOBAL = 0x4; +const PR_LD_LOCAL = 0x8; + +PRLibrary * PR_LoadLibraryWithFlags(PRLibSpec libSpec, PRIntn flags); +PRStatus PR_UnloadLibrary(PRLibrary *lib); +void * PR_FindSymbol(PRLibrary *lib, char *name); + +alias void function()PRFuncPtr; + +PRFuncPtr PR_FindFunctionSymbol(PRLibrary *lib, char *name); +void * PR_FindSymbolAndLibrary(char *name, PRLibrary **lib); +PRFuncPtr PR_FindFunctionSymbolAndLibrary(char *name, PRLibrary **lib); +PRLibrary * PR_LoadStaticLibrary(char *name, PRStaticLinkTable *table); +char * PR_GetLibraryFilePathname(char *name, PRFuncPtr addr); diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/internal/mozilla.old/prtime.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/mozilla.old/prtime.d Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,87 @@ +module dwt.internal.mozilla.prtime; + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.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 the Netscape Portable Runtime (NSPR). + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +import dwt.internal.mozilla.Common; + +const PR_MSEC_PER_SEC = 1000U; +const PR_USEC_PER_SEC = 1000000U; +const PR_NSEC_PER_SEC = 1000000000U; +const PR_USEC_PER_MSEC = 1000U; +const PR_NSEC_PER_MSEC = 1000000U; + +extern (System): + +alias PRInt64 PRTime; + +struct PRTimeParameters +{ + PRInt32 tp_gmt_offset; + PRInt32 tp_dst_offset; +} + +struct PRExplodedTime +{ + PRInt32 tm_usec; + PRInt32 tm_sec; + PRInt32 tm_min; + PRInt32 tm_hour; + PRInt32 tm_mday; + PRInt32 tm_month; + PRInt16 tm_year; + PRInt8 tm_wday; + PRInt16 tm_yday; + PRTimeParameters tm_params; +} + +alias PRTimeParameters function(PRExplodedTime *gmt)PRTimeParamFn; + +version(NON_XPCOM_GLUE) +{ + PRTime PR_Now(); + void PR_ExplodeTime(PRTime usecs, PRTimeParamFn params, PRExplodedTime *exploded); + PRTime PR_ImplodeTime(PRExplodedTime *exploded); + void PR_NormalizeTime(PRExplodedTime *exploded, PRTimeParamFn params); + + PRTimeParameters PR_LocalTimeParameters(PRExplodedTime *gmt); + PRTimeParameters PR_GMTParameters(PRExplodedTime *gmt); + PRTimeParameters PR_USPacificTimeParameters(PRExplodedTime *gmt); + + PRStatus PR_ParseTimeString(char *string, PRBool default_to_gmt, PRTime *result); + PRUint32 PR_FormatTime(char *buf, int buflen, char *fmt, PRExplodedTime *tm); + PRUint32 PR_FormatTimeUSEnglish(char *buf, PRUint32 bufSize, char *format, PRExplodedTime *tm); +} \ No newline at end of file diff -r 9cbe6285f746 -r 4ee8c4237614 dwt/widgets/DirectoryDialog.d~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/widgets/DirectoryDialog.d~ Tue Aug 05 18:00:50 2008 -0700 @@ -0,0 +1,343 @@ +/******************************************************************************* + * Copyright (c) 2000, 2008 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 + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwt.widgets.DirectoryDialog; + +import dwt.dwthelper.utils; + + + +import dwt.DWT; +import dwt.DWTException; +import dwt.internal.gtk.OS; +import dwt.widgets.Dialog; +import dwt.widgets.Shell; +import dwt.widgets.Display; + +version(TANGOSVN) { + static import tango.io.model.IFile; +} +else{ + static import tango.io.FileConst; +} +static import tango.text.Util; + +/** + * Instances of this class allow the user to navigate + * the file system and select a directory. + * <dl> + * <dt><b>Styles:</b></dt> + * <dd>(none)</dd> + * <dt><b>Events:</b></dt> + * <dd>(none)</dd> + * </dl> + * <p> + * IMPORTANT: This class is intended to be subclassed <em>only</em> + * within the DWT implementation. + * </p> + * + * @see <a href="http://www.eclipse.org/swt/snippets/#directorydialog">DirectoryDialog snippets</a> + * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample, Dialog tab</a> + * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> + */ +public class DirectoryDialog : Dialog { + String message = "", filterPath = ""; +version(TANGOSVN) { + static const String SEPARATOR = tango.io.model.IFile.FileConst.PathSeparatorString; +} +else{ + static const String SEPARATOR = tango.io.FileConst.FileConst.PathSeparatorString; +} + +/** + * Constructs a new instance of this class given only its parent. + * + * @param parent a shell which will be the parent of the new instance + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> + * </ul> + * @exception DWTException <ul> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> + * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> + * </ul> + */ +public this (Shell parent) { + this (parent, DWT.APPLICATION_MODAL); +} +/** + * Constructs a new instance of this class given its parent + * and a style value describing its behavior and appearance. + * <p> + * The style value is either one of the style constants defined in + * class <code>DWT</code> which is applicable to instances of this + * class, or must be built by <em>bitwise OR</em>'ing together + * (that is, using the <code>int</code> "|" operator) two or more + * of those <code>DWT</code> style constants. The class description + * lists the style constants that are applicable to the class. + * Style bits are also inherited from superclasses. + * </p> + * + * @param parent a shell which will be the parent of the new instance + * @param style the style of dialog to construct + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> + * </ul> + * @exception DWTException <ul> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> + * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> + * </ul> + */ +public this (Shell parent, int style) { + super (parent, checkStyle (parent, style)); + checkSubclass (); +} +/** + * Returns the path which the dialog will use to filter + * the directories it shows. + * + * @return the filter path + * + * @see #setFilterPath + */ +public String getFilterPath () { + return filterPath; +} +/** + * Returns the dialog's message, which is a description of + * the purpose for which it was opened. This message will be + * visible on the dialog while it is open. + * + * @return the message + */ +public String getMessage () { + return message; +} +/** + * Makes the dialog visible and brings it to the front + * of the display. + * + * @return a string describing the absolute path of the selected directory, + * or null if the dialog was cancelled or an error occurred + * + * @exception DWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li> + * </ul> + */ +public String open () { + bool useChooserDialog = OS.GTK_VERSION >= OS.buildVERSION (2, 4, 10); + if (useChooserDialog) { + return openChooserDialog (); + } else { + return openClassicDialog (); + } +} +String openChooserDialog () { + char* titleBytes = toStringz(title); + auto shellHandle = parent.topHandle (); + auto handle = OS.gtk_file_chooser_dialog_new2 ( + titleBytes, + shellHandle, + OS.GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, + OS.GTK_STOCK_CANCEL (), OS.GTK_RESPONSE_CANCEL, + OS.GTK_STOCK_OK (), OS.GTK_RESPONSE_OK ); + auto pixbufs = OS.gtk_window_get_icon_list (shellHandle); + if (pixbufs !is null) { + OS.gtk_window_set_icon_list (handle, pixbufs); + OS.g_list_free (pixbufs); + } + if (filterPath !is null && filterPath.length > 0) { + String p; + /* filename must be a full path */ + if ( filterPath[ 0 .. SEPARATOR.length ] != SEPARATOR ) { + p ~= SEPARATOR; + p ~= filterPath; + } + else{ + p = filterPath; + } + char* buffer = toStringz(p); + /* + * Bug in GTK. GtkFileChooser may crash on GTK versions 2.4.10 to 2.6 + * when setting a file name that is not a true canonical path. + * The fix is to use the canonical path. + */ + char* ptr = OS.realpath (buffer, null); + if (ptr !is null) { + OS.gtk_file_chooser_set_current_folder (handle, ptr); + OS.g_free (ptr); + } + } + if (message.length > 0) { + char* buffer = toStringz(message); + auto box = OS.gtk_hbox_new (false, 0); + if (box is null) error (DWT.ERROR_NO_HANDLES); + auto label = OS.gtk_label_new (buffer); + if (label is null) error (DWT.ERROR_NO_HANDLES); + OS.gtk_container_add (box, label); + OS.gtk_widget_show (label); + OS.gtk_label_set_line_wrap (label, true); + OS.gtk_label_set_justify (label, OS.GTK_JUSTIFY_CENTER); + OS.gtk_file_chooser_set_extra_widget (handle, box); + } + String answer = null; + Display display = parent !is null ? parent.getDisplay (): Display.getCurrent (); + display.addIdleProc (); + Dialog oldModal = null; + if (OS.gtk_window_get_modal (handle)) { + oldModal = display.getModalDialog (); + display.setModalDialog (this); + } + int signalId = 0; + int /*long*/ hookId = 0; + CallbackData emissionData; + emissionData.display = display; + emissionData.data = handle; + if ((style & DWT.RIGHT_TO_LEFT) !is 0) { + signalId = OS.g_signal_lookup (OS.map.ptr, OS.GTK_TYPE_WIDGET()); + hookId = OS.g_signal_add_emission_hook (signalId, 0, &Display.emissionFunc, &emissionData, null); + } + int response = OS.gtk_dialog_run (handle); + if ((style & DWT.RIGHT_TO_LEFT) !is 0) { + OS.g_signal_remove_emission_hook (signalId, hookId); + } + if (OS.gtk_window_get_modal (handle)) { + display.setModalDialog (oldModal); + } + if (response is OS.GTK_RESPONSE_OK) { + auto path = OS.gtk_file_chooser_get_filename (handle); + if (path !is null) { + uint items_written; + auto utf8Ptr = OS.g_filename_to_utf8 (path, -1, null, &items_written, null); + OS.g_free (path); + if (utf8Ptr !is null) { + answer = utf8Ptr[ 0 .. items_written ].dup; + filterPath = answer; + OS.g_free (utf8Ptr); + } + } + } + display.removeIdleProc (); + OS.gtk_widget_destroy (handle); + return answer; +} +String openClassicDialog () { + char* titleBytes = toStringz(title); + auto handle = OS.gtk_file_selection_new (titleBytes); + if (parent !is null) { + auto shellHandle = parent.topHandle (); + OS.gtk_window_set_transient_for (handle, shellHandle); + auto pixbufs = OS.gtk_window_get_icon_list (shellHandle); + if (pixbufs !is null) { + OS.gtk_window_set_icon_list (handle, pixbufs); + OS.g_list_free (pixbufs); + } + } + String answer = null; + if (filterPath !is null) { + String path = filterPath; + if (path.length > 0 && path[ $-1 .. $ ] != SEPARATOR ) { + path ~= SEPARATOR; + } + char* fileNamePtr = OS.g_filename_from_utf8 (toStringz(path), -1, null, null, null); + OS.gtk_file_selection_set_filename (handle, fileNamePtr); + OS.g_free (fileNamePtr); + } + GtkFileSelection* selection = cast(GtkFileSelection*)handle; + OS.gtk_file_selection_hide_fileop_buttons (handle); + auto fileListParent = OS.gtk_widget_get_parent (selection.file_list); + OS.gtk_widget_hide (selection.file_list); + OS.gtk_widget_hide (fileListParent); + if (message.length > 0) { + auto labelHandle = OS.gtk_label_new (toStringz(message)); + OS.gtk_label_set_line_wrap (labelHandle, true); + OS.gtk_misc_set_alignment (labelHandle, 0.0f, 0.0f); + OS.gtk_container_add (selection.main_vbox, labelHandle); + OS.gtk_box_set_child_packing ( + selection.main_vbox, labelHandle, false, false, 0, OS.GTK_PACK_START); + OS.gtk_widget_show (labelHandle); + } + Display display = parent !is null ? parent.getDisplay (): Display.getCurrent (); + display.addIdleProc (); + Dialog oldModal = null; + if (OS.gtk_window_get_modal (handle)) { + oldModal = display.getModalDialog (); + display.setModalDialog (this); + } + int signalId = 0; + int /*long*/ hookId = 0; + CallbackData emissionData; + emissionData.display = display; + emissionData.data = handle; + if ((style & DWT.RIGHT_TO_LEFT) !is 0) { + signalId = OS.g_signal_lookup (OS.map.ptr, OS.GTK_TYPE_WIDGET()); + hookId = OS.g_signal_add_emission_hook (signalId, 0, &Display.emissionFunc, &emissionData, null); + } + int response = OS.gtk_dialog_run (handle); + if ((style & DWT.RIGHT_TO_LEFT) !is 0) { + OS.g_signal_remove_emission_hook (signalId, hookId); + } + if (OS.gtk_window_get_modal (handle)) { + display.setModalDialog (oldModal); + } + if (response is OS.GTK_RESPONSE_OK) { + char* fileNamePtr = OS.gtk_file_selection_get_filename (handle); + uint items_written; + char* utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, &items_written, null); + if (utf8Ptr !is null) { + String osAnswer = utf8Ptr[ 0 .. items_written ]; + if (osAnswer.length !is 0) { + /* remove trailing separator, unless root directory */ + if ( osAnswer != SEPARATOR && osAnswer[ $-1 .. $ ] == SEPARATOR ) { + osAnswer = osAnswer[ 0 .. $ - 1 ]; + } + answer = filterPath = osAnswer.dup; + } + OS.g_free (utf8Ptr); + } + } + display.removeIdleProc (); + OS.gtk_widget_destroy (handle); + return answer; +} +/** + * Sets the path that the dialog will use to filter + * the directories it shows to the argument, which may + * be null. If the string is null, then the operating + * system's default filter path will be used. + * <p> + * Note that the path string is platform dependent. + * For convenience, either '/' or '\' can be used + * as a path separator. + * </p> + * + * @param string the filter path + */ +public void setFilterPath (String string) { + filterPath = string.dup; +} +/** + * Sets the dialog's message, which is a description of + * the purpose for which it was opened. This message will be + * visible on the dialog while it is open. + * + * @param string the message + * + */ +public void setMessage (String string) { + // DWT extension: allow null for zero length string + //if (string is null) error (DWT.ERROR_NULL_ARGUMENT); + message = string.dup; +} +}