File:  [mozdev] / abimoz / plugin / TestWPPlugin.cpp
Revision 1.4: download - view: text, annotated - select for diffs - revision graph
Fri Oct 25 14:42:28 2002 UTC (14 years, 11 months ago) by mikep
Branches: MAIN
CVS tags: HEAD
Upgraded to Mozilla 1.2b and abiword 1.0.3.

This file is part of AbiMoz.

TestWPPlugin.cpp - DESCRIPTION
Copyright (C) 2001 OEone Corporation

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

The author of this program can be contacted in writing at
OEone Corporation, 290 St-Joseph Blvd., Hull, QC J8Y 3Y3, CANADA.

#include <unistd.h>
#include <nsWPPlugin.h>
#include <nsIServiceManager.h>
#include "nsIComponentRegistrar.h"


    nsresult rv;
    char buf[80];

    // Initialize XPCOM
    nsCOMPtr<nsIServiceManager> servMan;
    rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
    if (NS_FAILED(rv))
        printf("ERROR: XPCOM intialization error [%x].\n", rv);
        return -1;

    nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
    NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
    // Do Autoreg to make sure our component is registered. The real way of
    // doing this is running the xpcom registraion tool, regxpcom, at install
    // time to get components registered and not make this call everytime.
    // Ignore return value.
    // Here we use the global component manager. Note that this will cause
    // linkage dependency to XPCOM library. We feel that linkage dependency
    // to XPCOM is inevitable and this is simpler to code.
    // To break free from such dependencies, we can GetService() the component
    // manager from the service manager that is returned from NS_InitXPCOM().
    // We feel that linkage dependency to XPCOM library is inevitable.

    // Create an instance of our component
    nsCOMPtr<nsIWPPluginInstance> mysample = do_CreateInstance(NS_WPPLUGIN_CONTRACTID, &rv);
    if (NS_FAILED(rv))
        printf("ERROR: Cannot create instance of component " NS_WPPLUGIN_CONTRACTID " [%x].\n"
               "Debugging hint:\n"
               "\tsetenv NSPR_LOG_MODULES nsComponentManager:5\n"
               "\tsetenv NSPR_LOG_FILE xpcom.log\n"
               "\t<check the contents for xpcom.log for possible cause of error>.\n",
        return -2;

    printf("Test finished\n");

    // Shutdown XPCOM
    return 0;

FreeBSD-CVSweb <>