Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Functions | Variables
nsTridentPreferencesWin.cpp File Reference
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include "nsAppDirectoryServiceDefs.h"
#include "nsCOMPtr.h"
#include "nsNetCID.h"
#include "nsDebug.h"
#include "nsDependentString.h"
#include "nsDirectoryServiceDefs.h"
#include "nsString.h"
#include "nsTridentPreferencesWin.h"
#include "plstr.h"
#include "prio.h"
#include "prmem.h"
#include "prlong.h"
#include "nsICookieManager2.h"
#include "nsIFile.h"
#include "nsILocalFile.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsServiceManagerUtils.h"
#include "nsISimpleEnumerator.h"
#include "nsITridentProfileMigrator.h"

Go to the source code of this file.

Classes

struct  regEntry

Typedefs

typedef void(* regEntryHandler )(unsigned char *, DWORD, DWORD, nsIPrefBranch *, char *)

Functions

void TranslateYNtoTF (unsigned char *aRegValue, DWORD aRegValueLength, DWORD aRegValueType, nsIPrefBranch *prefs, char *aPrefKeyName)
void TranslateYNtoFT (unsigned char *aRegValue, DWORD aRegValueLength, DWORD aRegValueType, nsIPrefBranch *prefs, char *aPrefKeyName)
void TranslateDRGBtoHRGB (unsigned char *aRegValue, DWORD aRegValueLength, DWORD aRegValueType, nsIPrefBranch *prefs, char *aPrefKeyName)
void TranslateDWORDtoPRInt32 (unsigned char *aRegValue, DWORD aRegValueLength, DWORD aRegValueType, nsIPrefBranch *prefs, char *aPrefKeyName)
void TranslateString (unsigned char *aRegValue, DWORD aRegValueLength, DWORD aRegValueType, nsIPrefBranch *prefs, char *aPrefKeyName)
void TranslateHomepage (unsigned char *aRegValue, DWORD aRegValueLength, DWORD aRegValueType, nsIPrefBranch *prefs, char *aPrefKeyName)
void TranslateLanglist (unsigned char *aRegValue, DWORD aRegValueLength, DWORD aRegValueType, nsIPrefBranch *prefs, char *aPrefKeyName)
static int CALLBACK fontEnumProc (const LOGFONT *aLogFont, const TEXTMETRIC *aMetric, DWORD aFontType, LPARAM aClosure)
void TranslatePropFont (unsigned char *aRegValue, DWORD aRegValueLength, DWORD aRegValueType, nsIPrefBranch *prefs, char *aPrefKeyName)
nsTridentPreferencesMakeTridentPreferences ()

Variables

const int sInitialCookieBufferSize = 1024
const int sUsernameLengthLimit = 80
const int sHostnameLengthLimit = 255

Class Documentation

struct regEntry

Definition at line 268 of file nsTridentPreferencesWin.cpp.

Collaboration diagram for regEntry:
Class Members
regEntryHandler entryHandler
char * prefKeyName
char * regKeyName
char * regValueName

Typedef Documentation

typedef void(* regEntryHandler)(unsigned char *, DWORD, DWORD, nsIPrefBranch *, char *)

Definition at line 70 of file nsTridentPreferencesWin.cpp.


Function Documentation

static int CALLBACK fontEnumProc ( const LOGFONT *  aLogFont,
const TEXTMETRIC *  aMetric,
DWORD  aFontType,
LPARAM  aClosure 
) [static]

Definition at line 231 of file nsTridentPreferencesWin.cpp.

                                               {
  *((int *) aClosure) = aLogFont->lfPitchAndFamily & FF_ROMAN;
  return 0;
}

Here is the caller graph for this function:

Definition at line 347 of file nsTridentPreferencesWin.cpp.

                         {
  return new nsTridentPreferencesWin();
}
void TranslateDRGBtoHRGB ( unsigned char *  aRegValue,
DWORD  aRegValueLength,
DWORD  aRegValueType,
nsIPrefBranch prefs,
char *  aPrefKeyName 
)

Definition at line 113 of file nsTridentPreferencesWin.cpp.

                                                              {

  // clear previous settings with defaults
  char prefStringValue[10];

  // input type is a string
  if (aRegValueType != REG_SZ)
    NS_WARNING("unexpected RGB data type");

  if (aRegValueType == REG_SZ && aRegValue[0] != 0) {
    int red, green, blue;
    ::sscanf(NS_REINTERPRET_CAST(char *, aRegValue), "%d,%d,%d",
             &red, &green, &blue);
    ::sprintf(prefStringValue, "#%02X%02X%02X", red, green, blue);
    prefs->SetCharPref(aPrefKeyName, prefStringValue);
  }
}

Here is the call graph for this function:

void TranslateDWORDtoPRInt32 ( unsigned char *  aRegValue,
DWORD  aRegValueLength,
DWORD  aRegValueType,
nsIPrefBranch prefs,
char *  aPrefKeyName 
)

Definition at line 135 of file nsTridentPreferencesWin.cpp.

                                                                  {

  // clear previous settings with defaults
  PRInt32 prefIntValue = 0;

  if (aRegValueType != REG_DWORD)
    NS_WARNING("unexpected signed int data type");

  if (aRegValueType == REG_DWORD) {
    prefIntValue = *(NS_REINTERPRET_CAST(DWORD *, aRegValue));
    prefs->SetIntPref(aPrefKeyName, prefIntValue);
  }
}
void TranslateHomepage ( unsigned char *  aRegValue,
DWORD  aRegValueLength,
DWORD  aRegValueType,
nsIPrefBranch prefs,
char *  aPrefKeyName 
)

Definition at line 168 of file nsTridentPreferencesWin.cpp.

                                                            {

  if (aRegValueType != REG_SZ)
    NS_WARNING("unexpected string data type");

  if (aRegValueType == REG_SZ) {
    // strcmp is safe; it's bounded by its second parameter
    if (strcmp(NS_REINTERPRET_CAST(char *, aRegValue), "about:blank") == 0)
      prefs->SetIntPref("browser.startup.page", 0);
    else {
      prefs->SetIntPref("browser.startup.page", 1);
      prefs->SetCharPref(aPrefKeyName,
                        NS_REINTERPRET_CAST(char *, aRegValue));
    }
  }
}
void TranslateLanglist ( unsigned char *  aRegValue,
DWORD  aRegValueLength,
DWORD  aRegValueType,
nsIPrefBranch prefs,
char *  aPrefKeyName 
)

Definition at line 190 of file nsTridentPreferencesWin.cpp.

                                                            {

  char prefStringValue[MAX_PATH]; // a convenient size, one hopes

  if (aRegValueType != REG_SZ)
    NS_WARNING("unexpected string data type");

  if (aRegValueType != REG_SZ)
    return;

  // copy source format like "en-us,ar-kw;q=0.7,ar-om;q=0.3" into
  // destination format like "en-us, ar-kw, ar-om"

  char   *source = NS_REINTERPRET_CAST(char *, aRegValue),
         *dest = prefStringValue,
         *sourceEnd = source + aRegValueLength,
         *destEnd = dest + (MAX_PATH-2); // room for " \0"
  PRBool  skip = PR_FALSE,
          comma = PR_FALSE;

  while (source < sourceEnd && *source && dest < destEnd) {
    if (*source == ',')
      skip = PR_FALSE;
    else if (*source == ';')
      skip = PR_TRUE;
    if (!skip) {
      if (comma && *source != ' ')
        *dest++ = ' ';
      *dest = *source;
    }
    comma = *source == ',';
    ++source;
  }
  *dest = 0;

  prefs->SetCharPref(aPrefKeyName, prefStringValue);
}
void TranslatePropFont ( unsigned char *  aRegValue,
DWORD  aRegValueLength,
DWORD  aRegValueType,
nsIPrefBranch prefs,
char *  aPrefKeyName 
)

Definition at line 237 of file nsTridentPreferencesWin.cpp.

                                                            {

  HDC     dc = ::GetDC(0);
  LOGFONT lf;
  int     isSerif = 1;

  // serif or sans-serif font?
  lf.lfCharSet = DEFAULT_CHARSET;
  lf.lfPitchAndFamily = 0;
  PL_strncpyz(lf.lfFaceName, NS_REINTERPRET_CAST(char *, aRegValue),
              LF_FACESIZE);
  ::EnumFontFamiliesEx(dc, &lf, fontEnumProc, (LPARAM) &isSerif, 0);
  ::ReleaseDC(0, dc);

  if (isSerif) {
    prefs->SetCharPref("font.name.serif.x-western",
                       NS_REINTERPRET_CAST(char *, aRegValue));
    prefs->SetCharPref("font.default.x-western", "serif");
  } else {
    prefs->SetCharPref("font.name.sans-serif.x-western",
                       NS_REINTERPRET_CAST(char *, aRegValue));
    prefs->SetCharPref("font.default.x-western", "sans-serif");
  }
}

Here is the call graph for this function:

void TranslateString ( unsigned char *  aRegValue,
DWORD  aRegValueLength,
DWORD  aRegValueType,
nsIPrefBranch prefs,
char *  aPrefKeyName 
)

Definition at line 153 of file nsTridentPreferencesWin.cpp.

                                                          {

  if (aRegValueType != REG_SZ)
    NS_WARNING("unexpected string data type");

  if (aRegValueType == REG_SZ)
    prefs->SetCharPref(aPrefKeyName,
                       NS_REINTERPRET_CAST(char *, aRegValue));
}
void TranslateYNtoFT ( unsigned char *  aRegValue,
DWORD  aRegValueLength,
DWORD  aRegValueType,
nsIPrefBranch prefs,
char *  aPrefKeyName 
)

Definition at line 94 of file nsTridentPreferencesWin.cpp.

                                                          {

  PRInt32 prefIntValue = 0;

  // input type is a string, lowercase "yes" or "no"
  if (aRegValueType != REG_SZ)
    NS_WARNING("unexpected yes/no data type");

  if (aRegValueType == REG_SZ && aRegValue[0] != 0) {
    // strcmp is safe; it's bounded by its second parameter
    prefIntValue = strcmp(NS_REINTERPRET_CAST(char *, aRegValue), "yes") != 0;
    prefs->SetBoolPref(aPrefKeyName, prefIntValue);
  }
}
void TranslateYNtoTF ( unsigned char *  aRegValue,
DWORD  aRegValueLength,
DWORD  aRegValueType,
nsIPrefBranch prefs,
char *  aPrefKeyName 
)

Definition at line 75 of file nsTridentPreferencesWin.cpp.

                                                          {

  PRInt32 prefIntValue = 0;

  // input type is a string, lowercase "yes" or "no"
  if (aRegValueType != REG_SZ)
    NS_WARNING("unexpected yes/no data type");

  if (aRegValueType == REG_SZ && aRegValue[0] != 0) {
    // strcmp is safe; it's bounded by its second parameter
    prefIntValue = strcmp(NS_REINTERPRET_CAST(char *, aRegValue), "yes") == 0;
    prefs->SetBoolPref(aPrefKeyName, prefIntValue);
  }
}

Variable Documentation

Definition at line 64 of file nsTridentPreferencesWin.cpp.

Definition at line 62 of file nsTridentPreferencesWin.cpp.

Definition at line 63 of file nsTridentPreferencesWin.cpp.