Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
nsWindowsHooks.cpp File Reference
#include "nsIDOMWindowInternal.h"
#include "nsIServiceManager.h"
#include "nsIPromptService.h"
#include "nsIStringBundle.h"
#include "nsIAllocator.h"
#include "nsXPIDLString.h"
#include "nsString.h"
#include "nsMemory.h"
#include "nsNetUtil.h"
#include "nsWindowsHooksUtil.cpp"
#include "nsWindowsHooks.h"
#include <windows.h>
#include <shlobj.h>
#include <shlguid.h>
#include "nsIDocument.h"
#include "nsIContent.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsIFrame.h"
#include "nsIPresShell.h"
#include "nsIImageLoadingContent.h"
#include "imgIRequest.h"
#include "imgIContainer.h"
#include "gfxIImageFrame.h"
#include "nsDirectoryServiceUtils.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsICmdLineService.h"
#include "nsXPFEComponentsCID.h"
#include "nsEmbedCID.h"

Go to the source code of this file.

Defines

#define MAX_BUF   4096
#define RUNKEY   "Software\\Microsoft\\Windows\\CurrentVersion\\Run"
#define DEFINE_GETTER_AND_SETTER(attr, member)

Functions

static PRBool misMatch (const PRBool &flag, const ProtocolRegistryEntry &entry)
static PRBool isAccessRestricted ()
nsresult putPRBoolIntoRegistry (const char *valueName, nsIWindowsHooksSettings *prefs, nsWindowsHooksSettings::getter memFun)
void grabArgs (char *optionline, char **args)
nsresult WriteBitmap (nsIFile *aFile, gfxIImageFrame *aImage)

Variables

static ProtocolRegistryEntry http ("http")
static ProtocolRegistryEntry https ("https")
static ProtocolRegistryEntry ftp ("ftp")
static ProtocolRegistryEntry chrome ("chrome")
static ProtocolRegistryEntry gopher ("gopher")
const char * jpgExts [] = { ".jpg", ".jpe", ".jpeg", ".jfif", ".pjpeg", ".pjp", 0 }
const char * gifExts [] = { ".gif", 0 }
const char * pngExts [] = { ".png", 0 }
const char * mngExts [] = { ".mng", 0 }
const char * xbmExts [] = { ".xbm", 0 }
const char * bmpExts [] = { ".bmp", ".rle", ".dib", 0 }
const char * icoExts [] = { ".ico", 0 }
const char * xmlExts [] = { ".xml", 0 }
const char * xhtmExts [] = { ".xht", ".xhtml", 0 }
const char * xulExts [] = { ".xul", 0 }
const char * htmExts [] = { ".htm", ".html", ".shtml", 0 }
static FileTypeRegistryEntry jpg (jpgExts,"MozillaJPEG","JPEG Image","jpegfile","jpeg-file.ico")
static FileTypeRegistryEntry gif (gifExts,"MozillaGIF","GIF Image","giffile","gif-file.ico")
static FileTypeRegistryEntry png (pngExts,"MozillaPNG","PNG Image","pngfile","image-file.ico")
static FileTypeRegistryEntry mng (mngExts,"MozillaMNG","MNG Image","","image-file.ico")
static FileTypeRegistryEntry xbm (xbmExts,"MozillaXBM","XBM Image","xbmfile","image-file.ico")
static FileTypeRegistryEntry bmp (bmpExts,"MozillaBMP","BMP Image","","image-file.ico")
static FileTypeRegistryEntry ico (icoExts,"MozillaICO","Icon","icofile","%1")
static FileTypeRegistryEntry xml (xmlExts,"MozillaXML","XML Document","xmlfile","xml-file.ico")
static FileTypeRegistryEntry xhtml (xhtmExts,"MozillaXHTML","XHTML Document","","misc-file.ico")
static FileTypeRegistryEntry xul (xulExts,"MozillaXUL","Mozilla XUL Document","","xul-file.ico")
static
EditableFileTypeRegistryEntry 
mozillaMarkup (htmExts,"MozillaHTML","HTML Document","htmlfile","html-file.ico")

Define Documentation

#define DEFINE_GETTER_AND_SETTER (   attr,
  member 
)
Value:
NS_IMETHODIMP \
nsWindowsHooksSettings::Get##attr ( PRBool *result ) { \
    return this->Get( result, &nsWindowsHooksSettings::member ); \
} \
NS_IMETHODIMP \
nsWindowsHooksSettings::Set##attr ( PRBool value ) { \
    return this->Set( value, &nsWindowsHooksSettings::member ); \
}

Definition at line 149 of file nsWindowsHooks.cpp.

#define MAX_BUF   4096

Definition at line 45 of file nsWindowsHooks.cpp.

#define RUNKEY   "Software\\Microsoft\\Windows\\CurrentVersion\\Run"

Definition at line 85 of file nsWindowsHooks.cpp.


Function Documentation

void grabArgs ( char *  optionline,
char **  args 
)

Definition at line 730 of file nsWindowsHooks.cpp.

                                             {
    nsCRT::strtok(optionline, "\"", &optionline);
    if (optionline != NULL)
        *args = nsCRT::strtok(optionline, "\"", &optionline);
}
static PRBool isAccessRestricted ( ) [static]

Definition at line 264 of file nsWindowsHooks.cpp.

                                   {
    char   subKey[] = "Software\\Mozilla - Test Key";
    PRBool result = PR_FALSE;
    DWORD  dwDisp = 0;
    HKEY   key;
    // Try to create/open a subkey under HKLM.
    DWORD rc = ::RegCreateKeyEx( HKEY_LOCAL_MACHINE,
                                 subKey,
                                 0,
                                 NULL,
                                 REG_OPTION_NON_VOLATILE,
                                 KEY_WRITE,
                                 NULL,
                                 &key,
                                 &dwDisp );

    if ( rc == ERROR_SUCCESS ) {
        // Key was opened; first close it.
        ::RegCloseKey( key );
        // Delete it if we just created it.
        switch( dwDisp ) {
            case REG_CREATED_NEW_KEY:
                ::RegDeleteKey( HKEY_LOCAL_MACHINE, subKey );
                break;
            case REG_OPENED_EXISTING_KEY:
                break;
        }
    } else {
        // Can't create/open it; we don't have access.
        result = PR_TRUE;
    }

    return result;
}
static PRBool misMatch ( const PRBool flag,
const ProtocolRegistryEntry entry 
) [static]

Definition at line 249 of file nsWindowsHooks.cpp.

                                                                                 {
    PRBool result = PR_FALSE;
    // Check if we care.
    if ( flag ) { 
        // Compare registry entry setting to what it *should* be.
        if ( entry.currentSetting() != entry.setting ) {
            result = PR_TRUE;
        }
    }

    return result;
}

Here is the call graph for this function:

Definition at line 542 of file nsWindowsHooks.cpp.

                                                                      {
    // Use getter method to extract attribute from prefs.
    PRBool boolValue;
    (void)(prefs->*memFun)( &boolValue );
    // Convert to DWORD.
    DWORD  dwordValue = boolValue;
    // Store into registry.
    BoolRegistryEntry pref( valueName );
    nsresult rv = boolValue ? pref.set() : pref.reset();

    return rv;
}

Here is the call graph for this function:

nsresult WriteBitmap ( nsIFile aFile,
gfxIImageFrame aImage 
)

Definition at line 842 of file nsWindowsHooks.cpp.

{
  PRInt32 width, height;
  aImage->GetWidth(&width);
  aImage->GetHeight(&height);
  
  PRUint8* bits;
  PRUint32 length;
  aImage->GetImageData(&bits, &length);
  if (!bits) return NS_ERROR_FAILURE;
  
  PRUint32 bpr;
  aImage->GetImageBytesPerRow(&bpr);
  PRInt32 bitCount = bpr/width;
  
  // initialize these bitmap structs which we will later
  // serialize directly to the head of the bitmap file
  LPBITMAPINFOHEADER bmi = (LPBITMAPINFOHEADER)new BITMAPINFO;
  bmi->biSize = sizeof(BITMAPINFOHEADER);
  bmi->biWidth = width;
  bmi->biHeight = height;
  bmi->biPlanes = 1;
  bmi->biBitCount = (WORD)bitCount*8;
  bmi->biCompression = BI_RGB;
  bmi->biSizeImage = 0; // don't need to set this if bmp is uncompressed
  bmi->biXPelsPerMeter = 0;
  bmi->biYPelsPerMeter = 0;
  bmi->biClrUsed = 0;
  bmi->biClrImportant = 0;
  
  BITMAPFILEHEADER bf;
  bf.bfType = 0x4D42; // 'BM'
  bf.bfReserved1 = 0;
  bf.bfReserved2 = 0;
  bf.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
  bf.bfSize = bf.bfOffBits + bmi->biSizeImage;

  // get a file output stream
  nsresult rv;
  nsCOMPtr<nsIOutputStream> stream;
  rv = NS_NewLocalFileOutputStream(getter_AddRefs(stream), aFile);
  NS_ENSURE_SUCCESS(rv, rv);

  // write the bitmap headers and rgb pixel data to the file
  rv = NS_ERROR_FAILURE;
  if (stream) {
    PRUint32 written;
    stream->Write((const char*)&bf, sizeof(BITMAPFILEHEADER), &written);
    if (written == sizeof(BITMAPFILEHEADER)) {
      stream->Write((const char*)bmi, sizeof(BITMAPINFOHEADER), &written);
      if (written == sizeof(BITMAPINFOHEADER)) {
        stream->Write((const char*)bits, length, &written);
        if (written == length)
          rv = NS_OK;
      }
    }
  
    stream->Close();
  }
  
  return rv;
}

Here is the call graph for this function:


Variable Documentation

FileTypeRegistryEntry bmp(bmpExts,"MozillaBMP","BMP Image","","image-file.ico")
const char* bmpExts[] = { ".bmp", ".rle", ".dib", 0 }

Definition at line 99 of file nsWindowsHooks.cpp.

FileTypeRegistryEntry gif(gifExts,"MozillaGIF","GIF Image","giffile","gif-file.ico")
const char* gifExts[] = { ".gif", 0 }

Definition at line 95 of file nsWindowsHooks.cpp.

const char* htmExts[] = { ".htm", ".html", ".shtml", 0 }

Definition at line 104 of file nsWindowsHooks.cpp.

ProtocolRegistryEntry http("http") [static]
FileTypeRegistryEntry ico(icoExts,"MozillaICO","Icon","icofile","%1")
const char* icoExts[] = { ".ico", 0 }

Definition at line 100 of file nsWindowsHooks.cpp.

FileTypeRegistryEntry jpg(jpgExts,"MozillaJPEG","JPEG Image","jpegfile","jpeg-file.ico") [static]
const char* jpgExts[] = { ".jpg", ".jpe", ".jpeg", ".jfif", ".pjpeg", ".pjp", 0 }

Definition at line 94 of file nsWindowsHooks.cpp.

FileTypeRegistryEntry mng(mngExts,"MozillaMNG","MNG Image","","image-file.ico")
const char* mngExts[] = { ".mng", 0 }

Definition at line 97 of file nsWindowsHooks.cpp.

EditableFileTypeRegistryEntry mozillaMarkup(htmExts,"MozillaHTML","HTML Document","htmlfile","html-file.ico") [static]
FileTypeRegistryEntry png(pngExts,"MozillaPNG","PNG Image","pngfile","image-file.ico")
const char* pngExts[] = { ".png", 0 }

Definition at line 96 of file nsWindowsHooks.cpp.

FileTypeRegistryEntry xbm(xbmExts,"MozillaXBM","XBM Image","xbmfile","image-file.ico")
const char* xbmExts[] = { ".xbm", 0 }

Definition at line 98 of file nsWindowsHooks.cpp.

const char* xhtmExts[] = { ".xht", ".xhtml", 0 }

Definition at line 102 of file nsWindowsHooks.cpp.

FileTypeRegistryEntry xhtml(xhtmExts,"MozillaXHTML","XHTML Document","","misc-file.ico")
FileTypeRegistryEntry xml(xmlExts,"MozillaXML","XML Document","xmlfile","xml-file.ico")
const char* xmlExts[] = { ".xml", 0 }

Definition at line 101 of file nsWindowsHooks.cpp.

FileTypeRegistryEntry xul(xulExts,"MozillaXUL","Mozilla XUL Document","","xul-file.ico")
const char* xulExts[] = { ".xul", 0 }

Definition at line 103 of file nsWindowsHooks.cpp.