Back to index

lightning-sunbird  0.9+nobinonly
Defines | Typedefs | Functions
nsOSHelperAppService.cpp File Reference
#include "nsOSHelperAppService.h"
#include "nsISupports.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsIURL.h"
#include "nsIMIMEInfo.h"
#include "nsMIMEInfoWin.h"
#include "nsMimeTypes.h"
#include "nsILocalFileWin.h"
#include "nsIProcess.h"
#include "plstr.h"
#include "nsAutoPtr.h"
#include "nsNativeCharsetUtils.h"
#include "nsIWindowsRegKey.h"
#include <windows.h>
#include <shellapi.h>
#include <shlobj.h>

Go to the source code of this file.

Defines

#define LOG(args)   PR_LOG(mLog, PR_LOG_DEBUG, args)

Typedefs

typedef ULONG SFGAOF
typedef IBindCtx * pbc
typedef IBindCtx LPITEMIDLISTppidl
typedef IBindCtx LPITEMIDLIST
SFGAOF 
sfgaoIn
typedef IBindCtx LPITEMIDLIST
SFGAOF SFGAOF
psfgaoOut

Functions

static nsresult GetExtensionFrom4xRegistryInfo (const nsACString &aMimeType, nsString &aFileExtension)
static nsresult GetExtensionFromWindowsMimeDatabase (const nsACString &aMimeType, nsString &aFileExtension)
typedef HRESULT (STDMETHODCALLTYPE *MySHParseDisplayName)(PCWSTR pszName
static void RemoveParameters (nsString &aPath)

Define Documentation

#define LOG (   args)    PR_LOG(mLog, PR_LOG_DEBUG, args)

Definition at line 63 of file nsOSHelperAppService.cpp.


Typedef Documentation

typedef IBindCtx* pbc

Definition at line 183 of file nsOSHelperAppService.cpp.

typedef IBindCtx LPITEMIDLIST* ppidl

Definition at line 183 of file nsOSHelperAppService.cpp.

typedef IBindCtx LPITEMIDLIST SFGAOF SFGAOF* psfgaoOut

Definition at line 183 of file nsOSHelperAppService.cpp.

typedef ULONG SFGAOF

Definition at line 180 of file nsOSHelperAppService.cpp.

typedef IBindCtx LPITEMIDLIST SFGAOF sfgaoIn

Definition at line 183 of file nsOSHelperAppService.cpp.


Function Documentation

static nsresult GetExtensionFrom4xRegistryInfo ( const nsACString &  aMimeType,
nsString aFileExtension 
) [static]

Definition at line 124 of file nsOSHelperAppService.cpp.

{
  nsCOMPtr<nsIWindowsRegKey> regKey = 
    do_CreateInstance("@mozilla.org/windows-registry-key;1");
  if (!regKey) 
    return NS_ERROR_NOT_AVAILABLE;

  nsresult rv = regKey->
    Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
         NS_LITERAL_STRING("Software\\Netscape\\Netscape Navigator\\Suffixes"),
         nsIWindowsRegKey::ACCESS_QUERY_VALUE);
  if (NS_FAILED(rv))
    return NS_ERROR_NOT_AVAILABLE;
   
  rv = regKey->ReadStringValue(NS_ConvertASCIItoUTF16(aMimeType),
                               aFileExtension);
  if (NS_FAILED(rv))
    return NS_OK;

  aFileExtension.Insert(PRUnichar('.'), 0);
      
  // this may be a comma separated list of extensions...just take the 
  // first one for now...

  PRInt32 pos = aFileExtension.FindChar(PRUnichar(','));
  if (pos > 0) {
    // we have a comma separated list of types...
    // truncate everything after the first comma (including the comma)
    aFileExtension.Truncate(pos); 
  }
   
  return NS_OK;
}

Here is the call graph for this function:

static nsresult GetExtensionFromWindowsMimeDatabase ( const nsACString &  aMimeType,
nsString aFileExtension 
) [static]

Definition at line 97 of file nsOSHelperAppService.cpp.

{
  nsAutoString mimeDatabaseKey;
  mimeDatabaseKey.AssignLiteral("MIME\\Database\\Content Type\\");

  AppendASCIItoUTF16(aMimeType, mimeDatabaseKey);

  nsCOMPtr<nsIWindowsRegKey> regKey = 
    do_CreateInstance("@mozilla.org/windows-registry-key;1");
  if (!regKey) 
    return NS_ERROR_NOT_AVAILABLE;

  nsresult rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
                             mimeDatabaseKey,
                             nsIWindowsRegKey::ACCESS_QUERY_VALUE);
  
  if (NS_SUCCEEDED(rv))
     regKey->ReadStringValue(NS_LITERAL_STRING("Extension"), aFileExtension);

  return NS_OK;
}

Here is the call graph for this function:

typedef HRESULT ( STDMETHODCALLTYPE *  MySHParseDisplayName)
static void RemoveParameters ( nsString aPath) [static]

Definition at line 351 of file nsOSHelperAppService.cpp.

{
  // Command Strings stored in the Windows registry with parameters look like 
  // this:
  //
  // 1) "C:\Program Files\Company Name\product.exe" -foo -bar  (long version)
  //                      -- OR --
  // 2) C:\PROGRA~1\COMPAN~2\product.exe -foo -bar             (short version)
  //
  // For 1), the path is the first "" quoted string. (quotes are used to 
  //         prevent parameter parsers from choking)
  // For 2), the path is the string up until the first space (spaces are 
  //         illegal in short DOS-style paths)
  //
  if (aPath.First() == PRUnichar('"')) {
    aPath = Substring(aPath, 1, aPath.Length() - 1);
    PRInt32 nextQuote = aPath.FindChar(PRUnichar('"'));
    if (nextQuote != kNotFound)
      aPath.Truncate(nextQuote);
  }
  else {
    PRInt32 firstSpace = aPath.FindChar(PRUnichar(' '));
    if (firstSpace != kNotFound) 
      aPath.Truncate(firstSpace);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function: