Back to index

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

#include <nsWinProfile.h>

Collaboration diagram for nsWinProfile:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsWinProfile (nsInstall *suObj, const nsString &folder, const nsString &file)
 ~nsWinProfile ()
PRInt32 WriteString (nsString section, nsString key, nsString value, PRInt32 *aReturn)
 Schedules a write into a windows "ini" file.
PRInt32 GetString (nsString section, nsString key, nsString *aReturn)
 Reads a value from a windows "ini" file.
nsStringGetFilename ()
nsInstallInstallObject ()
PRInt32 FinalWriteString (nsString section, nsString key, nsString value)

Private Member Functions

PRInt32 NativeWriteString (nsString section, nsString key, nsString value)
PRInt32 NativeGetString (nsString section, nsString key, nsString *aReturn)

Private Attributes

nsString mFilename
nsInstallmInstallObject

Detailed Description

Definition at line 45 of file nsWinProfile.h.


Constructor & Destructor Documentation

nsWinProfile::nsWinProfile ( nsInstall suObj,
const nsString folder,
const nsString file 
)

Definition at line 49 of file nsWinProfile.cpp.

  : mFilename(folder)
{
  MOZ_COUNT_CTOR(nsWinProfile);

  if(mFilename.Last() != '\\')
  {
      mFilename.AppendLiteral("\\");
  }
  mFilename.Append(file);

       mInstallObject = suObj;
}

Definition at line 63 of file nsWinProfile.cpp.


Member Function Documentation

Definition at line 113 of file nsWinProfile.cpp.

{
       /* do we need another security check here? */
       return NativeWriteString(section, key, value);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 102 of file nsWinProfile.cpp.

{
       return mFilename;
}

Here is the caller graph for this function:

PRInt32 nsWinProfile::GetString ( nsString  section,
nsString  key,
nsString aReturn 
)

Reads a value from a windows "ini" file.

We don't support using a null "key" to return a list of keys--you have to know what you want

Returns:
String value from INI, "" if not found, null if error

Definition at line 69 of file nsWinProfile.cpp.

{
  return NativeGetString(section, key, aReturn);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 107 of file nsWinProfile.cpp.

{
       return mInstallObject;
}
PRInt32 nsWinProfile::NativeGetString ( nsString  section,
nsString  key,
nsString aReturn 
) [private]

Definition at line 124 of file nsWinProfile.cpp.

{
  int       numChars = 0;
  char      valbuf[STRBUFLEN];

  /* make sure conversions worked */
  if(aSection.First() != '\0' && aKey.First() != '\0' && mFilename.First() != '\0')
  {
    nsCAutoString section;
    nsCAutoString key;
    nsCAutoString filename;

    if(NS_FAILED(NS_CopyUnicodeToNative(aSection, section)) ||
       NS_FAILED(NS_CopyUnicodeToNative(aKey, key)) ||
       NS_FAILED(NS_CopyUnicodeToNative(mFilename, filename)))
      return 0;

    valbuf[0] = 0;
    numChars = GetPrivateProfileString( section.get(), key.get(), "", valbuf,
                                        STRBUFLEN, filename.get());

    nsCAutoString cStrValue(valbuf);
    nsAutoString value;
    if(NS_SUCCEEDED(NS_CopyNativeToUnicode(cStrValue, value)))
      aReturn->Assign(value);
  }

  return numChars;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinProfile::NativeWriteString ( nsString  section,
nsString  key,
nsString  value 
) [private]

Definition at line 155 of file nsWinProfile.cpp.

{
  int   success = 0;

       /* make sure conversions worked */
  if(aSection.First() != '\0' && aKey.First() != '\0' && mFilename.First() != '\0')
  {
    nsCAutoString section;
    nsCAutoString key;
    nsCAutoString value;
    nsCAutoString filename;

    if(NS_FAILED(NS_CopyUnicodeToNative(aSection, section)) ||
       NS_FAILED(NS_CopyUnicodeToNative(aKey, key)) ||
       NS_FAILED(NS_CopyUnicodeToNative(aValue, value)) ||
       NS_FAILED(NS_CopyUnicodeToNative(mFilename, filename)))
      return 0;

    success = WritePrivateProfileString( section.get(), key.get(), value.get(), filename.get() );
  }

  return success;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsWinProfile::WriteString ( nsString  section,
nsString  key,
nsString  value,
PRInt32 aReturn 
)

Schedules a write into a windows "ini" file.

"Value" can be null to delete the value, but we don't support deleting an entire section via a null "key". The actual write takes place during SoftwareUpdate.FinalizeInstall();

Returns:
false for failure, true for success

Definition at line 75 of file nsWinProfile.cpp.

{
  *aReturn = NS_OK;
  
  nsWinProfileItem* wi = new nsWinProfileItem(this, section, key, value, aReturn);

  if(wi == nsnull)
  {
    *aReturn = nsInstall::OUT_OF_MEMORY;
    return NS_OK;
  }

  if(*aReturn != nsInstall::SUCCESS)
  {
    if(wi)
    {
      delete wi;
      return NS_OK;
    }
  }

  if (mInstallObject)
    mInstallObject->ScheduleForInstall(wi);
  
  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 83 of file nsWinProfile.h.

Definition at line 84 of file nsWinProfile.h.


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