Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsProfileDirServiceProvider.cpp File Reference
#include "nsProfileDirServiceProvider.h"
#include "nsProfileStringTypes.h"
#include "nsProfileLock.h"
#include "nsILocalFile.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsISupportsUtils.h"
#include "nsISimpleEnumerator.h"
#include "nsIObserverService.h"

Go to the source code of this file.

Defines

#define PREFS_FILE_50_NAME   NS_LITERAL_CSTRING("prefs.js")
#define USER_CHROME_DIR_50_NAME   NS_LITERAL_CSTRING("chrome")
#define LOCAL_STORE_FILE_50_NAME   NS_LITERAL_CSTRING("localstore.rdf")
#define HISTORY_FILE_50_NAME   NS_LITERAL_CSTRING("history.dat")
#define PANELS_FILE_50_NAME   NS_LITERAL_CSTRING("panels.rdf")
#define MIME_TYPES_FILE_50_NAME   NS_LITERAL_CSTRING("mimeTypes.rdf")
#define BOOKMARKS_FILE_50_NAME   NS_LITERAL_CSTRING("bookmarks.html")
#define DOWNLOADS_FILE_50_NAME   NS_LITERAL_CSTRING("downloads.rdf")
#define SEARCH_FILE_50_NAME   NS_LITERAL_CSTRING("search.rdf" )
#define MAIL_DIR_50_NAME   NS_LITERAL_CSTRING("Mail")
#define IMAP_MAIL_DIR_50_NAME   NS_LITERAL_CSTRING("ImapMail")
#define NEWS_DIR_50_NAME   NS_LITERAL_CSTRING("News")
#define MSG_FOLDER_CACHE_DIR_50_NAME   NS_LITERAL_CSTRING("panacea.dat")
#define STORAGE_FILE_50_NAME   NS_LITERAL_CSTRING("storage.sdb")

Functions

 NS_IMPL_THREADSAFE_ISUPPORTS1 (nsProfileDirServiceProvider, nsIDirectoryServiceProvider) NS_IMETHODIMP nsProfileDirServiceProvider
nsresult NS_NewProfileDirServiceProvider (PRBool aNotifyObservers, nsProfileDirServiceProvider **aProvider)
 Global method to create an instance of nsProfileDirServiceProvider.

Define Documentation

Definition at line 62 of file nsProfileDirServiceProvider.cpp.

Definition at line 63 of file nsProfileDirServiceProvider.cpp.

Definition at line 59 of file nsProfileDirServiceProvider.cpp.

Definition at line 66 of file nsProfileDirServiceProvider.cpp.

Definition at line 58 of file nsProfileDirServiceProvider.cpp.

Definition at line 65 of file nsProfileDirServiceProvider.cpp.

Definition at line 61 of file nsProfileDirServiceProvider.cpp.

Definition at line 68 of file nsProfileDirServiceProvider.cpp.

Definition at line 67 of file nsProfileDirServiceProvider.cpp.

Definition at line 60 of file nsProfileDirServiceProvider.cpp.

Definition at line 56 of file nsProfileDirServiceProvider.cpp.

Definition at line 64 of file nsProfileDirServiceProvider.cpp.

Definition at line 69 of file nsProfileDirServiceProvider.cpp.

Definition at line 57 of file nsProfileDirServiceProvider.cpp.


Function Documentation

Definition at line 199 of file nsProfileDirServiceProvider.cpp.

{
  NS_ENSURE_ARG(prop);
  NS_ENSURE_ARG_POINTER(persistant);
  NS_ENSURE_ARG_POINTER(_retval);

  // Don't assert - we can be called many times before SetProfileDir() has been called.
  if (!mProfileDir)
    return NS_ERROR_FAILURE;

  *persistant = PR_TRUE;
  nsIFile* domainDir = mProfileDir;

#ifdef MOZ_PROFILESHARING
  // If the prop is prefixed with NS_SHARED,
  // the location is in the shared domain.
  PRBool bUseShared = PR_FALSE;
  if (strncmp(prop, NS_SHARED, sizeof(NS_SHARED)-1) == 0) {
    prop += (sizeof(NS_SHARED)-1);
    bUseShared = PR_TRUE;
  }
  if (!bUseShared && mNonSharedProfileDir)
    domainDir = mNonSharedProfileDir;
#endif

  nsCOMPtr<nsIFile>  localFile;
  nsresult rv = NS_ERROR_FAILURE;

  if (strcmp(prop, NS_APP_PREFS_50_DIR) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
  }
  else if (strcmp(prop, NS_APP_PREFS_50_FILE) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv))
      rv = localFile->AppendNative(PREFS_FILE_50_NAME);
  }
  else if (strcmp(prop, NS_APP_USER_PROFILE_50_DIR) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
  }
  else if (strcmp(prop, NS_APP_USER_PROFILE_LOCAL_50_DIR) == 0) {
    rv = mLocalProfileDir->Clone(getter_AddRefs(localFile));
  }
  else if (strcmp(prop, NS_APP_USER_CHROME_DIR) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv))
      rv = localFile->AppendNative(USER_CHROME_DIR_50_NAME);
  }
  else if (strcmp(prop, NS_APP_LOCALSTORE_50_FILE) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv)) {
      rv = localFile->AppendNative(LOCAL_STORE_FILE_50_NAME);
      if (NS_SUCCEEDED(rv)) {
        // it's OK if we can't copy the file... it will be created
        // by client code.
        (void) EnsureProfileFileExists(localFile, domainDir);
      }
    }
  }
  else if (strcmp(prop, NS_APP_HISTORY_50_FILE) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv))
      rv = localFile->AppendNative(HISTORY_FILE_50_NAME);
  }
  else if (strcmp(prop, NS_APP_USER_PANELS_50_FILE) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv)) {
      rv = localFile->AppendNative(PANELS_FILE_50_NAME);
      if (NS_SUCCEEDED(rv))
        rv = EnsureProfileFileExists(localFile, domainDir);
    }
  }
  else if (strcmp(prop, NS_APP_USER_MIMETYPES_50_FILE) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv)) {
      rv = localFile->AppendNative(MIME_TYPES_FILE_50_NAME);
      if (NS_SUCCEEDED(rv))
        rv = EnsureProfileFileExists(localFile, domainDir);
    }
  }
  else if (strcmp(prop, NS_APP_BOOKMARKS_50_FILE) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv))
      rv = localFile->AppendNative(BOOKMARKS_FILE_50_NAME);
  }
  else if (strcmp(prop, NS_APP_DOWNLOADS_50_FILE) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv))
      rv = localFile->AppendNative(DOWNLOADS_FILE_50_NAME);
  }
  else if (strcmp(prop, NS_APP_SEARCH_50_FILE) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv)) {
      rv = localFile->AppendNative(SEARCH_FILE_50_NAME);
      if (NS_SUCCEEDED(rv))
        rv = EnsureProfileFileExists(localFile, domainDir);
    }
  }
  else if (strcmp(prop, NS_APP_MAIL_50_DIR) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv))
      rv = localFile->AppendNative(MAIL_DIR_50_NAME);
  }
  else if (strcmp(prop, NS_APP_IMAP_MAIL_50_DIR) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv))
      rv = localFile->AppendNative(IMAP_MAIL_DIR_50_NAME);
  }
  else if (strcmp(prop, NS_APP_NEWS_50_DIR) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv))
      rv = localFile->AppendNative(NEWS_DIR_50_NAME);
  }
  else if (strcmp(prop, NS_APP_MESSENGER_FOLDER_CACHE_50_DIR) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv))
      rv = localFile->AppendNative(MSG_FOLDER_CACHE_DIR_50_NAME);
  }
  else if (strcmp(prop, NS_APP_STORAGE_50_FILE) == 0) {
    rv = domainDir->Clone(getter_AddRefs(localFile));
    if (NS_SUCCEEDED(rv))
      rv = localFile->AppendNative(STORAGE_FILE_50_NAME);
  }

  
  if (localFile && NS_SUCCEEDED(rv))
    return CallQueryInterface(localFile, _retval);

  return rv;
}

Here is the call graph for this function:

Global method to create an instance of nsProfileDirServiceProvider.

Parameters:
aNotifyObserversIf true, will send out profile startup notifications when the profile directory is set. See nsIProfileChangeStatus.

Definition at line 528 of file nsProfileDirServiceProvider.cpp.

{
  NS_ENSURE_ARG_POINTER(aProvider);
  *aProvider = nsnull;

  nsProfileDirServiceProvider *prov = new nsProfileDirServiceProvider(aNotifyObservers);
  if (!prov)
    return NS_ERROR_OUT_OF_MEMORY;
  nsresult rv = prov->Initialize();
  if (NS_FAILED(rv)) {
    delete prov;
    return rv;
  }
  NS_ADDREF(*aProvider = prov);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function: