Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsMailProfileMigratorUtils.cpp File Reference
#include "nsMailProfileMigratorUtils.h"
#include "nsIFile.h"
#include "nsIProperties.h"
#include "nsIProfileMigrator.h"
#include "nsServiceManagerUtils.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsXPCOMCID.h"
#include "nsCRT.h"

Go to the source code of this file.

Functions

void SetProxyPref (const nsACString &aHostPort, const char *aPref, const char *aPortPref, nsIPrefBranch *aPrefs)
void ParseOverrideServers (const char *aServers, nsIPrefBranch *aBranch)
void GetMigrateDataFromArray (MigrationData *aDataArray, PRInt32 aDataArrayLength, PRBool aReplace, nsIFile *aSourceProfile, PRUint16 *aResult)
void GetProfilePath (nsIProfileStartup *aStartup, nsCOMPtr< nsIFile > &aProfileDir)

Function Documentation

void GetMigrateDataFromArray ( MigrationData aDataArray,
PRInt32  aDataArrayLength,
PRBool  aReplace,
nsIFile aSourceProfile,
PRUint16 aResult 
)

Definition at line 89 of file nsMailProfileMigratorUtils.cpp.

{
  nsCOMPtr<nsIFile> sourceFile; 
  PRBool exists;
  MigrationData* cursor;
  MigrationData* end = aDataArray + aDataArrayLength;
  for (cursor = aDataArray; cursor < end && cursor->fileName; ++cursor) {
    // When in replace mode, all items can be imported. 
    // When in non-replace mode, only items that do not require file replacement
    // can be imported.
    if (aReplace || !cursor->replaceOnly) {
      aSourceProfile->Clone(getter_AddRefs(sourceFile));
      sourceFile->Append(nsDependentString(cursor->fileName));
      sourceFile->Exists(&exists);
      if (exists)
        *aResult |= cursor->sourceFlag;
    }
    nsCRT::free(cursor->fileName);
    cursor->fileName = nsnull;
  }
}

Here is the call graph for this function:

void GetProfilePath ( nsIProfileStartup aStartup,
nsCOMPtr< nsIFile > &  aProfileDir 
)

Definition at line 114 of file nsMailProfileMigratorUtils.cpp.

{
  if (aStartup) {
    aStartup->GetDirectory(getter_AddRefs(aProfileDir));
  }
  else {
    nsCOMPtr<nsIProperties> dirSvc
      (do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
    if (dirSvc) {
      dirSvc->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile),
                  (void**) getter_AddRefs(aProfileDir));
    }
  }
}

Here is the call graph for this function:

void ParseOverrideServers ( const char *  aServers,
nsIPrefBranch aBranch 
)

Definition at line 67 of file nsMailProfileMigratorUtils.cpp.

{
  // Windows (and Opera) formats its proxy override list in the form:
  // server;server;server where server is a server name or ip address, 
  // or "<local>". Mozilla's format is server,server,server, and <local>
  // must be translated to "localhost,127.0.0.1"
  nsCAutoString override(aServers);
  PRInt32 left = 0, right = 0;
  for (;;) {
    right = override.FindChar(';', right);
    const nsACString& host = Substring(override, left, 
                                       (right < 0 ? override.Length() : right) - left);
    if (host.Equals("<local>"))
      override.Replace(left, 7, NS_LITERAL_CSTRING("localhost,127.0.0.1"));
    if (right < 0)
      break;
    left = right + 1;
    override.Replace(right, 1, NS_LITERAL_CSTRING(","));
  }
  aBranch->SetCharPref("network.proxy.no_proxies_on", override.get());
}

Here is the call graph for this function:

void SetProxyPref ( const nsACString &  aHostPort,
const char *  aPref,
const char *  aPortPref,
nsIPrefBranch aPrefs 
)

Definition at line 48 of file nsMailProfileMigratorUtils.cpp.

{
  nsCAutoString hostPort(aHostPort);  
  PRInt32 portDelimOffset = hostPort.RFindChar(':');
  if (portDelimOffset > 0) {
    nsCAutoString host(Substring(hostPort, 0, portDelimOffset));
    nsCAutoString port(Substring(hostPort, portDelimOffset + 1, 
                                 hostPort.Length() - (portDelimOffset + 1)));
    
    aPrefs->SetCharPref(aPref, host.get());
    PRInt32 stringErr;
    PRInt32 portValue = port.ToInteger(&stringErr);
    aPrefs->SetIntPref(aPortPref, portValue);
  }
  else
    aPrefs->SetCharPref(aPref, hostPort.get());
}

Here is the call graph for this function: