Back to index

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

#include <nsSoftwareUpdate.h>

Inheritance diagram for nsSoftwareUpdate:
Inheritance graph
[legend]
Collaboration diagram for nsSoftwareUpdate:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 NS_DEFINE_STATIC_CID_ACCESSOR (NS_SoftwareUpdate_CID)
NS_DECL_ISUPPORTS
NS_DECL_NSPIXPISTUBHOOK
NS_DECL_NSIOBSERVER NS_IMETHOD 
InstallJar (nsIFile *localFile, const PRUnichar *URL, const PRUnichar *arguments, nsIPrincipal *principal=nsnull, PRUint32 flags=0, nsIXPIListener *aListener=0)
NS_IMETHOD InstallChrome (PRUint32 aType, nsIFile *aFile, const PRUnichar *URL, const PRUnichar *aName, PRBool aSelect, nsIXPIListener *aListener=0)
NS_IMETHOD RegisterListener (nsIXPIListener *aListener)
NS_IMETHOD InstallJarCallBack ()
NS_IMETHOD GetMasterListener (nsIXPIListener **aListener)
NS_IMETHOD SetActiveListener (nsIXPIListener *aListener)
 nsSoftwareUpdate ()
virtual ~nsSoftwareUpdate ()
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Static Public Member Functions

static nsSoftwareUpdateGetInstance ()
static nsIFileGetProgramDirectory ()
 GetProgramDirectory Information used within the XPI module -- not available through any interface.
static char * GetLogName ()
 GetLogName Optional log name used privately in the XPI module.
static void NeedCleanup ()

Static Public Attributes

static PRBool mNeedCleanup = PR_FALSE

Private Member Functions

nsresult RunNextInstall ()
nsresult RegisterNameset ()
void CreateMasterListener ()
void Shutdown ()

Private Attributes

PRLockmLock
PRBool mInstalling
nsVoidArray mJarInstallQueue
nsTopProgressListenermMasterListener
HREG mReg

Static Private Attributes

static nsSoftwareUpdatemInstance = nsnull
static nsCOMPtr< nsIFilemProgramDir = nsnull
static char * mLogName = nsnull

Detailed Description

Definition at line 26 of file nsSoftwareUpdate.h.


Constructor & Destructor Documentation

Definition at line 116 of file nsSoftwareUpdate.cpp.

: mInstalling(PR_FALSE),
  mMasterListener(0),
  mReg(0)
{
    mLock = PR_NewLock();

    /***************************************/
    /* Startup the Version Registry        */
    /***************************************/

    NR_StartupRegistry();   /* startup the registry; if already started, this will essentially be a noop */


    nsresult rv;
    nsCOMPtr<nsIProperties> directoryService =
             do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);

    if(!directoryService) return;

    nsCOMPtr<nsILocalFile> dir;
    directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(dir));
    if (dir)
    {
        nsCAutoString nativePath;
        dir->GetNativePath(nativePath);
        // EVIL version registry does not take a nsIFile.;
        VR_SetRegDirectory( nativePath.get() );

    }
    /***************************************/
    /* Add this as a shutdown observer     */
    /***************************************/
    nsCOMPtr<nsIObserverService> observerService =
             do_GetService("@mozilla.org/observer-service;1", &rv);

    if (NS_SUCCEEDED(rv))
        observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 157 of file nsSoftwareUpdate.cpp.

{
    PR_Lock(mLock);

    nsInstallInfo* element;
    for (PRInt32 i=0; i < mJarInstallQueue.Count(); i++)
    {
        element = (nsInstallInfo*)mJarInstallQueue.ElementAt(i);
        //FIX:  need to add to registry....
        delete element;
    }

    mJarInstallQueue.Clear();

    PR_Unlock(mLock);
    PR_DestroyLock(mLock);

    NR_ShutdownRegistry();

    NS_IF_RELEASE (mMasterListener);
    mInstance = nsnull;

    PR_FREEIF(mLogName);
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 293 of file nsSoftwareUpdate.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 105 of file nsSoftwareUpdate.cpp.

Here is the call graph for this function:

static char* nsSoftwareUpdate::GetLogName ( ) [inline, static]

GetLogName Optional log name used privately in the XPI module.

Definition at line 45 of file nsSoftwareUpdate.h.

{ return mLogName; }

Definition at line 262 of file nsSoftwareUpdate.cpp.

{
    NS_ASSERTION(aListener, "getter has invalid return pointer");
    if (!aListener)
        return NS_ERROR_NULL_POINTER;

    if (!mMasterListener)
        CreateMasterListener();

    if (!mMasterListener)
        return NS_ERROR_FAILURE;

    NS_ADDREF (mMasterListener);
    *aListener = mMasterListener;
    return NS_OK;
}

Here is the call graph for this function:

static nsIFile* nsSoftwareUpdate::GetProgramDirectory ( ) [inline, static]

GetProgramDirectory Information used within the XPI module -- not available through any interface.

Definition at line 40 of file nsSoftwareUpdate.h.

{ return mProgramDir; }

Here is the caller graph for this function:

NS_IMETHODIMP nsSoftwareUpdate::InstallChrome ( PRUint32  aType,
nsIFile aFile,
const PRUnichar URL,
const PRUnichar aName,
PRBool  aSelect,
nsIXPIListener aListener = 0 
)

Definition at line 333 of file nsSoftwareUpdate.cpp.

{
    nsInstallInfo *info = new nsInstallInfo( aType,
                                             aFile,
                                             URL,
                                             aName,
                                             nsnull,
                                             (PRUint32)aSelect,
                                             aListener);
    if (!info)
        return NS_ERROR_OUT_OF_MEMORY;

    if (!info->GetChromeRegistry() ||
#ifdef MOZ_XUL_APP
        !info->GetExtensionManager() ||
        !info->GetFileJARURL() ||
        !info->GetManifestURL()
#else
        info->GetFileJARSpec().IsEmpty()
#endif
        ) {
      delete info;
      return NS_ERROR_FAILURE;
    }

    PR_CreateThread(PR_USER_THREAD,
                    RunChromeInstallOnThread,
                    (void*)info,
                    PR_PRIORITY_NORMAL,
                    PR_GLOBAL_THREAD,
                    PR_UNJOINABLE_THREAD,
                    0);

    return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsSoftwareUpdate::InstallJar ( nsIFile localFile,
const PRUnichar URL,
const PRUnichar arguments,
nsIPrincipal principal = nsnull,
PRUint32  flags = 0,
nsIXPIListener aListener = 0 
)

Definition at line 306 of file nsSoftwareUpdate.cpp.

{
    if ( !aLocalFile )
        return NS_ERROR_NULL_POINTER;

    // we want to call this with or without a chrome registry
    nsInstallInfo *info = new nsInstallInfo( 0, aLocalFile, aURL, aArguments, aPrincipal,
                                             flags, aListener);

    if (!info)
        return NS_ERROR_OUT_OF_MEMORY;

    PR_Lock(mLock);
    mJarInstallQueue.AppendElement( info );
    PR_Unlock(mLock);
    RunNextInstall();

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 376 of file nsSoftwareUpdate.cpp.

{
    PR_Lock(mLock);

    if (mJarInstallQueue.Count() != 0) // paranoia
    {
        nsInstallInfo *nextInstall = (nsInstallInfo*)mJarInstallQueue.ElementAt(0);
        if (nextInstall != nsnull)
            delete nextInstall;

        mJarInstallQueue.RemoveElementAt(0);
    }
    mInstalling = PR_FALSE;

    PR_Unlock(mLock);

    return RunNextInstall();
}

Here is the call graph for this function:

static void nsSoftwareUpdate::NeedCleanup ( ) [inline, static]

Definition at line 47 of file nsSoftwareUpdate.h.

Here is the caller graph for this function:

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.

Definition at line 246 of file nsSoftwareUpdate.cpp.

{
    // once you register a Listener, you can not remove it.
    // This should get changed at some point.

    if (!mMasterListener)
        CreateMasterListener();

    if (!mMasterListener)
        return NS_ERROR_FAILURE;

    mMasterListener->RegisterListener(aListener);
    return NS_OK;
}

Here is the call graph for this function:

Definition at line 397 of file nsSoftwareUpdate.cpp.

{
    nsresult        rv = NS_OK;
    nsInstallInfo*  info = nsnull;

    PR_Lock(mLock);

    // make sure master master listener exists
    if (!mMasterListener)
        CreateMasterListener();

    if (!mInstalling)
    {
        if ( mJarInstallQueue.Count() > 0 )
        {
            info = (nsInstallInfo*)mJarInstallQueue.ElementAt(0);

            if ( info )
                mInstalling = PR_TRUE;
            else
            {
                // bogus elements got into the queue
                NS_ERROR("leaks remaining nsInstallInfos, please file bug!");
                rv = NS_ERROR_NULL_POINTER;
                VR_Close();
            }
        }
        else
        {
            // nothing more to do
            VR_Close();
        }
    }
    PR_Unlock(mLock);

    // make sure to RunInstall() outside of locked section due to callbacks
    if (info)
        RunInstall( info );

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 281 of file nsSoftwareUpdate.cpp.

Here is the call graph for this function:


Member Data Documentation

Definition at line 89 of file nsSoftwareUpdate.h.

Definition at line 79 of file nsSoftwareUpdate.h.

Definition at line 90 of file nsSoftwareUpdate.h.

Definition at line 88 of file nsSoftwareUpdate.h.

char * nsSoftwareUpdate::mLogName = nsnull [static, private]

Definition at line 81 of file nsSoftwareUpdate.h.

Definition at line 91 of file nsSoftwareUpdate.h.

Definition at line 76 of file nsSoftwareUpdate.h.

Definition at line 80 of file nsSoftwareUpdate.h.

Definition at line 93 of file nsSoftwareUpdate.h.


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