/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 */

function nsJSAimFileXferRendezvous() {
    // dump("creating new nsJSAimFileXferRendezvous\n");
}

nsJSAimFileXferRendezvous.prototype = {
    // we just implement one function!
    OnProposalReceived : function (screenname, proposal)
    {

     inviteArgsObj = {
     	inviteProposalScreenName: screenname, 
     	inviteProposalObj: proposal,
     	inviteMode: 'incomingfile'
     }
    
     var windowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();

     var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);

     var topWindow = windowManagerInterface.getMostRecentWindow(null);

	 
     //topWindow.focus();
     topWindow.openDialog('chrome://aim/content/incomingFile.xul','_blank','chrome,all,dialog=no',inviteArgsObj); 
    
    }
}

var module = {
    registerSelf: function (compMgr, fileSpec, location, type) {
        compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
        compMgr.registerComponentWithType(this.myCID,
        	"nsJSAimFileXferRendezvous",
                "@netscape.com/js/aim/filexferrendezvous;1",
                fileSpec, location, true, true, type);
    },

    getClassObject: function (compMgr, cid, iid) {
        if (!cid.equals(this.myCID))
            throw Components.results.NS_ERROR_NO_INTERFACE;
        
        if (!iid.equals(Components.interfaces.nsIFactory))
            throw Components.results.NS_ERROR_NOT_IMPLEMENTED;

        return this.myFactory;
    },

    canUnload: function () {
    },
    
    myCID: Components.ID("{98763432-2DC7-11d4-BA1A-0010833594E9}"),
    
    myFactory: {
        createInstance: function (outer, iid) {
            if (outer != null)
                throw Components.results.NS_ERROR_NO_AGGREGATION;
            
            if (!(iid.equals(Components.interfaces.nsIAimFileXferRendezvousCallback) || iid.equals(Components.interfaces.nsISupports))) {
                throw Components.results.NS_ERROR_INVALID_ARG;
            }

            return new nsJSAimFileXferRendezvous();
        }
    }
};

function NSGetModule(compMgr, fileSpec) { return module; }
