Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
ShortcutResolver Class Reference
Collaboration diagram for ShortcutResolver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ShortcutResolver ()
 ~ShortcutResolver ()
nsresult Init ()
nsresult Resolve (const WCHAR *in, WCHAR *out)

Private Attributes

PRLockmLock
IPersistFile * mPersistFile
union {
IShellLinkW * W
IShellLinkA * A
mShellLink

Detailed Description

Definition at line 111 of file nsLocalFileWin.cpp.


Constructor & Destructor Documentation

Definition at line 132 of file nsLocalFileWin.cpp.

Definition at line 139 of file nsLocalFileWin.cpp.

{
    if (mLock)
        PR_DestroyLock(mLock);

    // Release the pointer to the IPersistFile interface.
    if (mPersistFile)
        mPersistFile->Release();

    // Release the pointer to the IShellLink interface.
    if (NS_UseUnicode())
    {
        if (mShellLink.W)
            mShellLink.W->Release();
    }
    else
    {
        if (mShellLink.A)
            mShellLink.A->Release();
    }

    CoUninitialize();
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 164 of file nsLocalFileWin.cpp.

{
    CoInitialize(NULL);  // FIX: we should probably move somewhere higher up during startup

    mLock = PR_NewLock();
    if (!mLock)
        return NS_ERROR_FAILURE;

    HRESULT hres; 
    if (NS_UseUnicode())
    {
        hres = CoCreateInstance(CLSID_ShellLink,
                                NULL,
                                CLSCTX_INPROC_SERVER,
                                IID_IShellLinkW,
                                (void**)&(mShellLink.W));
        if (SUCCEEDED(hres))
        {
            // Get a pointer to the IPersistFile interface.
            hres = mShellLink.W->QueryInterface(IID_IPersistFile,
                                                (void**)&mPersistFile);
        }
    }
    else 
    {
        hres = CoCreateInstance(CLSID_ShellLink,
                                NULL,
                                CLSCTX_INPROC_SERVER,
                                IID_IShellLinkA,
                                (void**)&(mShellLink.A));
        if (SUCCEEDED(hres))
        {
            // Get a pointer to the IPersistFile interface.
            hres = mShellLink.A->QueryInterface(IID_IPersistFile,
                                                (void**)&mPersistFile);
        }
    }

    if (mPersistFile == nsnull || mShellLink.W == nsnull)
        return NS_ERROR_FAILURE;

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 210 of file nsLocalFileWin.cpp.

{
    nsAutoLock lock(mLock);

    // see if we can Load the path.
    HRESULT hres = mPersistFile->Load(in, STGM_READ);

    if (FAILED(hres))
        return NS_ERROR_FAILURE;

    // Resolve the link.
    hres = mShellLink.W->Resolve(nsnull, SLR_NO_UI );

    if (FAILED(hres))
        return NS_ERROR_FAILURE;

    // Get the path to the link target.
    if (NS_UseUnicode()) 
        hres = mShellLink.W->GetPath( out, MAX_PATH, NULL, SLGP_UNCPRIORITY );
    else {
        char tmp[MAX_PATH];
        hres = mShellLink.A->GetPath( tmp, MAX_PATH, NULL, SLGP_UNCPRIORITY );
        if (SUCCEEDED(hres))
            NS_ConvertAtoW(tmp, MAX_PATH, out);
    }
    if (FAILED(hres))
        return NS_ERROR_FAILURE;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 122 of file nsLocalFileWin.cpp.

IPersistFile* ShortcutResolver::mPersistFile [private]

Definition at line 123 of file nsLocalFileWin.cpp.

union { ... } ShortcutResolver::mShellLink [private]

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