Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions | Static Private Attributes | Friends
QGeckoGlobals Class Reference

#include <qgeckoglobals.h>

Collaboration diagram for QGeckoGlobals:
Collaboration graph
[legend]

List of all members.

Static Public Member Functions

static void initializeGlobalObjects ()
static void pushStartup ()
static void popStartup ()
static void setCompPath (const char *aPath)
static void setAppComponents (const nsModuleComponentInfo *aComps, int aNumComponents)
static void setProfilePath (const char *aDir, const char *aName)
static void setDirectoryServiceProvider (nsIDirectoryServiceProvider *appFileLocProvider)
static int startupProfile (void)
static void shutdownProfile (void)
static int registerAppComponents ()
static void addEngine (QGeckoEmbed *embed)
static void removeEngine (QGeckoEmbed *embed)
static QGeckoEmbedfindPrivateForBrowser (nsIWebBrowserChrome *aBrowser)

Static Private Attributes

static PRUint32 sWidgetCount = 0
static char * sCompPath = nsnull
static const
nsModuleComponentInfo
sAppComps
static int sNumAppComps
static nsIAppShellsAppShell = nsnull
static char * sProfileDir = nsnull
static char * sProfileName = nsnull
static
nsProfileDirServiceProvider
sProfileDirServiceProvider = nsnull
static
nsIDirectoryServiceProvider
sAppFileLocProvider = nsnull
static nsVoidArraysWindowList = nsnull

Friends

class QGeckoEmbed

Detailed Description

Definition at line 53 of file qgeckoglobals.h.


Member Function Documentation

void QGeckoGlobals::addEngine ( QGeckoEmbed embed) [static]

Definition at line 292 of file qgeckoglobals.cpp.

{
    sWindowList->AppendElement(embed);
}

Here is the caller graph for this function:

Definition at line 302 of file qgeckoglobals.cpp.

{
    if (!sWindowList)
        return nsnull;

    // Get the number of browser windows.
    PRInt32 count = sWindowList->Count();
    // This function doesn't get called very often at all ( only when
    // creating a new window ) so it's OK to walk the list of open
    // windows.
    for (int i = 0; i < count; i++) {
        QGeckoEmbed *tmpPrivate = NS_STATIC_CAST(QGeckoEmbed *,
                                                sWindowList->ElementAt(i));
        // get the browser object for that window
        nsIWebBrowserChrome *chrome = NS_STATIC_CAST(nsIWebBrowserChrome *,
                                                     tmpPrivate->window());
        if (chrome == aBrowser)
            return tmpPrivate;
    }

    return nsnull;
}

Here is the call graph for this function:

Definition at line 285 of file qgeckoglobals.cpp.

{
    if (!sWindowList) {
        sWindowList = new nsVoidArray();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 146 of file qgeckoglobals.cpp.

{
    sWidgetCount--;
    if (sWidgetCount == 0) {
        // shut down the profiles
        shutdownProfile();

        if (sAppShell) {
            // Shutdown the appshell service.
            sAppShell->Spindown();
            NS_RELEASE(sAppShell);
            sAppShell = 0;
        }

        // shut down XPCOM/Embedding
        NS_TermEmbedding();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 98 of file qgeckoglobals.cpp.

{
    // increment the number of widgets
    sWidgetCount++;

    // if this is the first widget, fire up xpcom
    if (sWidgetCount == 1) {
        nsresult rv;
        nsCOMPtr<nsILocalFile> binDir;

        if (sCompPath) {
            rv = NS_NewNativeLocalFile(nsDependentCString(sCompPath), 1, getter_AddRefs(binDir));
            if (NS_FAILED(rv))
                return;
        }

        rv = NS_InitEmbedding(binDir, sAppFileLocProvider);
        if (NS_FAILED(rv))
            return;

        // we no longer need a reference to the DirectoryServiceProvider
        if (sAppFileLocProvider) {
            NS_RELEASE(sAppFileLocProvider);
            sAppFileLocProvider = nsnull;
        }

        rv = startupProfile();
        NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Warning: Failed to start up profiles.\n");

        rv = registerAppComponents();
        NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Warning: Failed to register app components.\n");

        // XXX startup appshell service?

        nsCOMPtr<nsIAppShell> appShell;
        appShell = do_CreateInstance(kAppShellCID);
        if (!appShell) {
            NS_WARNING("Failed to create appshell in QGeckoGlobals::pushStartup!\n");
            return;
        }
        sAppShell = appShell.get();
        NS_ADDREF(sAppShell);
        sAppShell->Create(0, nsnull);
        sAppShell->Spinup();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 261 of file qgeckoglobals.cpp.

{
  nsCOMPtr<nsIComponentRegistrar> cr;
  nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(cr));
  NS_ENSURE_SUCCESS(rv, rv);

  int numAppComps = sizeof(defaultAppComps) / sizeof(nsModuleComponentInfo);
  for (int i = 0; i < numAppComps; ++i) {
    nsCOMPtr<nsIGenericFactory> componentFactory;
    rv = NS_NewGenericFactory(getter_AddRefs(componentFactory),
                              &(defaultAppComps[i]));
    if (NS_FAILED(rv)) {
      NS_WARNING("Unable to create factory for component");
      continue;  // don't abort registering other components
    }

    rv = cr->RegisterFactory(defaultAppComps[i].mCID, defaultAppComps[i].mDescription,
                             defaultAppComps[i].mContractID, componentFactory);
    NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to register factory for component");
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 297 of file qgeckoglobals.cpp.

{
    sWindowList->RemoveElement(embed);
}

Here is the caller graph for this function:

void QGeckoGlobals::setAppComponents ( const nsModuleComponentInfo aComps,
int  aNumComponents 
) [static]

Definition at line 177 of file qgeckoglobals.cpp.

{
}
void QGeckoGlobals::setCompPath ( const char *  aPath) [static]

Definition at line 166 of file qgeckoglobals.cpp.

Definition at line 203 of file qgeckoglobals.cpp.

{
    if (sAppFileLocProvider)
        NS_RELEASE(sAppFileLocProvider);

    if (appFileLocProvider) {
        sAppFileLocProvider = appFileLocProvider;
        NS_ADDREF(sAppFileLocProvider);
    }
}

Here is the call graph for this function:

void QGeckoGlobals::setProfilePath ( const char *  aDir,
const char *  aName 
) [static]

Definition at line 183 of file qgeckoglobals.cpp.

{
    if (sProfileDir) {
        nsMemory::Free(sProfileDir);
        sProfileDir = nsnull;
    }

    if (sProfileName) {
        nsMemory::Free(sProfileName);
        sProfileName = nsnull;
    }

    if (aDir)
        sProfileDir = (char *)nsMemory::Clone(aDir, strlen(aDir) + 1);

    if (aName)
        sProfileName = (char *)nsMemory::Clone(aName, strlen(aName) + 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 250 of file qgeckoglobals.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 218 of file qgeckoglobals.cpp.

{
    // initialize profiles
    if (sProfileDir && sProfileName) {
        nsresult rv;
        nsCOMPtr<nsILocalFile> profileDir;
        NS_NewNativeLocalFile(nsDependentCString(sProfileDir), PR_TRUE,
                              getter_AddRefs(profileDir));
        if (!profileDir)
            return NS_ERROR_FAILURE;
        rv = profileDir->AppendNative(nsDependentCString(sProfileName));
        if (NS_FAILED(rv))
            return NS_ERROR_FAILURE;

        nsCOMPtr<nsProfileDirServiceProvider> locProvider;
        NS_NewProfileDirServiceProvider(PR_TRUE, getter_AddRefs(locProvider));
        if (!locProvider)
            return NS_ERROR_FAILURE;
        rv = locProvider->Register();
        if (NS_FAILED(rv))
            return rv;
        rv = locProvider->SetProfileDir(profileDir);
        if (NS_FAILED(rv))
            return rv;
        // Keep a ref so we can shut it down.
        NS_ADDREF(sProfileDirServiceProvider = locProvider);
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class QGeckoEmbed [friend]

Definition at line 55 of file qgeckoglobals.h.


Member Data Documentation

Definition at line 79 of file qgeckoglobals.h.

Definition at line 88 of file qgeckoglobals.h.

Definition at line 82 of file qgeckoglobals.h.

char * QGeckoGlobals::sCompPath = nsnull [static, private]

Definition at line 77 of file qgeckoglobals.h.

int QGeckoGlobals::sNumAppComps [static, private]

Definition at line 80 of file qgeckoglobals.h.

char * QGeckoGlobals::sProfileDir = nsnull [static, private]

Definition at line 84 of file qgeckoglobals.h.

Definition at line 87 of file qgeckoglobals.h.

char * QGeckoGlobals::sProfileName = nsnull [static, private]

Definition at line 85 of file qgeckoglobals.h.

PRUint32 QGeckoGlobals::sWidgetCount = 0 [static, private]

Definition at line 75 of file qgeckoglobals.h.

Definition at line 91 of file qgeckoglobals.h.


The documentation for this class was generated from the following files: