view dwt/browser/DownloadFactory.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 source

/*******************************************************************************
 * 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.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;
    }
}