1 /******************************************************************************* 2 * Copyright (c) 2003, 2008 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.PromptService2Factory; 14 15 //import java.lang.all; 16 import org.eclipse.swt.internal.mozilla.Common; 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.nsID; 21 import org.eclipse.swt.internal.mozilla.nsIFactory; 22 import org.eclipse.swt.internal.mozilla.nsISupports; 23 import org.eclipse.swt.browser.PromptService2; 24 25 class PromptService2Factory : nsIFactory { 26 // XPCOMObject supports; 27 // XPCOMObject factory; 28 int refCount = 0; 29 30 this () { 31 // createCOMInterfaces (); 32 } 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 null) disposeCOMInterfaces (); 65 return refCount; 66 } 67 68 /* nsIFactory */ 69 70 extern(System) 71 nsresult CreateInstance (nsISupports aOuter, nsIID* iid, void** result) { 72 if (result is null) 73 return XPCOM.NS_ERROR_INVALID_ARG; 74 auto promptService = new PromptService2; 75 nsresult rv = promptService.QueryInterface( iid, result ); 76 if (XPCOM.NS_FAILED(rv)) { 77 *result = null; 78 delete promptService; 79 } 80 return rv; 81 } 82 83 extern(System) 84 nsresult LockFactory (PRBool lock) { 85 return XPCOM.NS_OK; 86 } 87 }