Back to index

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

#include <nsXPITriggerInfo.h>

Collaboration diagram for nsXPITriggerItem:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsXPITriggerItem (const PRUnichar *name, const PRUnichar *URL, const PRUnichar *iconURL, const char *hash=nsnull, PRInt32 flags=0)
 ~nsXPITriggerItem ()
void SetPrincipal (nsIPrincipal *aPrincipal)
PRBool IsFileURL ()
PRBool IsRelativeURL ()
const PRUnicharGetSafeURLString ()

Public Attributes

nsString mName
nsString mURL
nsString mIconURL
nsString mArguments
nsString mCertName
PRBool mHashFound
nsCString mHash
nsCOMPtr< nsICryptoHashmHasher
PRInt32 mFlags
nsCOMPtr< nsILocalFilemFile
nsCOMPtr< nsIOutputStreammOutStream
nsCOMPtr< nsIPrincipalmPrincipal

Private Member Functions

nsXPITriggerItemoperator= (const nsXPITriggerItem &rhs)
 nsXPITriggerItem (const nsXPITriggerItem &rhs)

Private Attributes

nsString mSafeURL

Detailed Description

Definition at line 70 of file nsXPITriggerInfo.h.


Constructor & Destructor Documentation

nsXPITriggerItem::nsXPITriggerItem ( const PRUnichar name,
const PRUnichar URL,
const PRUnichar iconURL,
const char *  hash = nsnull,
PRInt32  flags = 0 
)

Definition at line 57 of file nsXPITriggerInfo.cpp.

    : mName(aName), mURL(aURL), mIconURL(aIconURL), mFlags(aFlags), mHashFound(PR_FALSE)
{
    MOZ_COUNT_CTOR(nsXPITriggerItem);

    // check for arguments
    PRInt32 qmark = mURL.FindChar('?');
    if ( qmark != kNotFound )
    {
        mArguments = Substring( mURL, qmark+1, mURL.Length() );
    }

    // construct name if not passed in
    if ( mName.IsEmpty() )
    {
        // Use the filename as the display name by starting after the last
        // slash in the URL, looking backwards from the arguments delimiter if
        // we found one. By good fortune using kNotFound as the offset for
        // RFindChar() starts at the end, so we can use qmark in all cases.

        PRInt32 namestart = mURL.RFindChar( '/', qmark );

        // the real start is after the slash (or 0 if not found)
        namestart = ( namestart==kNotFound ) ? 0 : namestart + 1;

        PRInt32 length;
        if (qmark == kNotFound)
            length =  mURL.Length();      // no '?', slurp up rest of URL
        else
            length = (qmark - namestart); // filename stops at the '?'

        mName = Substring( mURL, namestart, length );
    }

    // parse optional hash into its parts
    if (aHash)
    {
        mHashFound = PR_TRUE;

        PRUint32 htype = 1;
        char * colon = PL_strchr(aHash, ':');
        if (colon)
        {
            mHasher = do_CreateInstance("@mozilla.org/security/hash;1");
            if (!mHasher) return;
            
            *colon = '\0'; // null the colon so that aHash is just the type.
            nsresult rv = mHasher->InitWithString(nsDependentCString(aHash));
            *colon = ':';  // restore the colon

            if (NS_SUCCEEDED(rv))
                mHash = colon+1;
        }
    }
}

Here is the call graph for this function:

Definition at line 117 of file nsXPITriggerInfo.cpp.


Member Function Documentation

Definition at line 133 of file nsXPITriggerInfo.cpp.

{
    // create the safe url string the first time
    if (mSafeURL.IsEmpty() && !mURL.IsEmpty())
    {
        nsCOMPtr<nsIURI> uri;
        NS_NewURI(getter_AddRefs(uri), mURL);
        if (uri)
        {
            nsCAutoString spec;
            uri->SetUserPass(EmptyCString());
            uri->GetSpec(spec);
            mSafeURL = NS_ConvertUTF8toUTF16(spec);
        }
    }

    return mSafeURL.get();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 97 of file nsXPITriggerInfo.h.

{ return StringBeginsWith(mURL, NS_LITERAL_STRING("file:/")); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 122 of file nsXPITriggerInfo.cpp.

{
    PRInt32 cpos = mURL.FindChar(':');
    if (cpos == kNotFound)
        return PR_TRUE;

    PRInt32 spos = mURL.FindChar('/');
    return (cpos > spos);
}
nsXPITriggerItem& nsXPITriggerItem::operator= ( const nsXPITriggerItem rhs) [private]

Definition at line 153 of file nsXPITriggerInfo.cpp.

{
    mPrincipal = aPrincipal;

    // aPrincipal can be null for various failure cases.
    // see bug 213894 for an example.
    // nsXPInstallManager::OnCertAvailable can be called with a null principal
    // and it can also force a null principal.
    if (!aPrincipal)
        return;

    PRBool hasCert;
    aPrincipal->GetHasCertificate(&hasCert);
    if (hasCert) {
        nsCAutoString prettyName;
        // XXXbz should this really be using the prettyName?  Perhaps
        // it wants to get the subjectName or nsIX509Cert and display
        // it sanely?
        aPrincipal->GetPrettyName(prettyName);
        CopyUTF8toUTF16(prettyName, mCertName);
    }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 83 of file nsXPITriggerInfo.h.

Definition at line 84 of file nsXPITriggerInfo.h.

Definition at line 91 of file nsXPITriggerInfo.h.

Definition at line 89 of file nsXPITriggerInfo.h.

Definition at line 87 of file nsXPITriggerInfo.h.

Definition at line 88 of file nsXPITriggerInfo.h.

Definition at line 86 of file nsXPITriggerInfo.h.

Definition at line 82 of file nsXPITriggerInfo.h.

Definition at line 80 of file nsXPITriggerInfo.h.

Definition at line 92 of file nsXPITriggerInfo.h.

Definition at line 93 of file nsXPITriggerInfo.h.

Definition at line 107 of file nsXPITriggerInfo.h.

Definition at line 81 of file nsXPITriggerInfo.h.


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