Mercurial > projects > dwt-linux
diff dwt/browser/FilePickerFactory.d @ 278:93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
author | John Reimer<terminal.node@gmail.com> |
---|---|
date | Thu, 31 Jul 2008 19:17:51 -0700 |
parents | |
children | 44258e0b6687 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/browser/FilePickerFactory.d Thu Jul 31 19:17:51 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 <terminal.node@gmail.com> + *******************************************************************************/ + +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