1 /******************************************************************************* 2 * Copyright (c) 2003, 2007 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 * Port to the D programming language: 11 * John Reimer <terminal.node@gmail.com> 12 *******************************************************************************/ 13 module org.eclipse.swt.browser.FilePickerFactory; 14 15 import java.lang.all; 16 17 //import org.eclipse.swt.internal.C; 18 import XPCOM = org.eclipse.swt.internal.mozilla.XPCOM; 19 //import org.eclipse.swt.internal.mozilla.XPCOMObject; 20 import org.eclipse.swt.internal.mozilla.Common; 21 import org.eclipse.swt.internal.mozilla.nsID; 22 import org.eclipse.swt.internal.mozilla.nsIFactory; 23 import org.eclipse.swt.internal.mozilla.nsISupports; 24 25 import org.eclipse.swt.browser.FilePicker; 26 27 class FilePickerFactory : nsIFactory { 28 //XPCOMObject supports; 29 //XPCOMObject factory; 30 int refCount = 0; 31 32 this () { } 33 34 extern(System) 35 nsrefcnt AddRef () { 36 refCount++; 37 return refCount; 38 } 39 40 extern(System) 41 nsresult QueryInterface (in nsID* riid, void** ppvObject) { 42 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; 43 //nsID guid = new nsID (); 44 //XPCOM.memmove (guid, riid, nsID.sizeof); 45 46 if (*riid == nsISupports.IID) { 47 *ppvObject = cast(void*)cast(nsISupports)this; 48 AddRef (); 49 return XPCOM.NS_OK; 50 } 51 if (*riid == nsIFactory.IID) { 52 *ppvObject = cast(void*)cast(nsIFactory)this; 53 AddRef (); 54 return XPCOM.NS_OK; 55 } 56 57 *ppvObject = null; 58 return XPCOM.NS_ERROR_NO_INTERFACE; 59 } 60 61 extern(System) 62 nsrefcnt Release () { 63 refCount--; 64 //if (refCount is 0) disposeCOMInterfaces (); 65 return refCount; 66 } 67 68 /* nsIFactory */ 69 70 extern(System) 71 nsresult CreateInstance (nsISupports aOuter, nsID* iid, void** result) { 72 if (result is null) 73 return XPCOM.NS_ERROR_INVALID_ARG; 74 auto picker = new FilePicker; 75 nsresult rv = picker.QueryInterface( iid, result ); 76 if (XPCOM.NS_FAILED(rv)) { 77 *result = null; 78 delete picker; 79 } 80 return rv; 81 } 82 83 extern(System) 84 nsresult LockFactory (PRBool lock) { 85 return XPCOM.NS_OK; 86 } 87 }