Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
nsAppRunner.h File Reference
#include "nscore.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MAXPATHLEN   1024
#define NS_APP_PROFILE_DIR_STARTUP   "ProfDS"
#define NS_LOCALSTORE_UNSAFE_FILE   "LStoreS"
#define NS_APP_PROFILE_LOCAL_DIR_STARTUP   "ProfLDS"
#define XRE_UPDATE_ROOT_DIR   "UpdRootD"
 A directory service key which provides the update directory.
#define NS_NATIVEAPPSUPPORT_CONTRACTID   "@mozilla.org/toolkit/native-app-support;1"

Functions

nsresult NS_CreateNativeAppSupport (nsINativeAppSupport **aResult)
 Create the nativeappsupport implementation.
 NS_NewToolkitProfileService (nsIToolkitProfileService **aResult)
 NS_LockProfilePath (nsILocalFile *aPath, nsILocalFile *aTempPath, nsIProfileUnlocker **aUnlocker, nsIProfileLock **aResult)
 Try to acquire exclusive access to the specified profile directory.
 WriteConsoleLog ()

Variables

nsXREDirProvidergDirServiceProvider
const nsXREAppDatagAppData
PRBool gSafeMode
int gArgc
char ** gArgv
PRBool gLogConsoleErrors

Define Documentation

#define MAXPATHLEN   1024

Definition at line 51 of file nsAppRunner.h.

Definition at line 61 of file nsAppRunner.h.

Definition at line 72 of file nsAppRunner.h.

Definition at line 66 of file nsAppRunner.h.

#define NS_NATIVEAPPSUPPORT_CONTRACTID   "@mozilla.org/toolkit/native-app-support;1"

Definition at line 143 of file nsAppRunner.h.

#define XRE_UPDATE_ROOT_DIR   "UpdRootD"

A directory service key which provides the update directory.

At present this is supported only on Windows. Windows: Documents and Settings<User> Settings Data\ <Vendor><Application><relative path to app dir from Program Files> If appDir is not under the Program Files, directory service will fail. Callers should fallback to appDir.

Definition at line 82 of file nsAppRunner.h.


Function Documentation

Create the nativeappsupport implementation.

Note:
XPCOMInit has not happened yet.

Definition at line 240 of file nsNativeAppSupportBeOS.cpp.

{
    if (!aResult)
        return NS_ERROR_NULL_POINTER;

    nsNativeAppSupportBeOS *pNative = new nsNativeAppSupportBeOS;
    if (!pNative)
        return NS_ERROR_OUT_OF_MEMORY;

    *aResult = pNative;
    NS_ADDREF(*aResult);
    return NS_OK;
}

Here is the caller graph for this function:

NS_LockProfilePath ( nsILocalFile aPath,
nsILocalFile aTempPath,
nsIProfileUnlocker **  aUnlocker,
nsIProfileLock **  aResult 
)

Try to acquire exclusive access to the specified profile directory.

Parameters:
aPathThe profile directory to lock.
aTempPathThe corresponding profile temporary directory.
aUnlockerA callback interface used to attempt to unlock a profile that appears to be locked.
aResultThe resulting profile lock object (or null if the profile could not be locked).
Returns:
NS_ERROR_FILE_ACCESS_DENIED to indicate that the profile directory cannot be unlocked.

Definition at line 589 of file nsToolkitProfileService.cpp.

{
    nsCOMPtr<nsToolkitProfileLock> lock = new nsToolkitProfileLock();
    if (!lock) return NS_ERROR_OUT_OF_MEMORY;

    nsresult rv = lock->Init(aPath, aTempPath, aUnlocker);
    if (NS_FAILED(rv)) return rv;

    NS_ADDREF(*aResult = lock);
    return NS_OK;
}

Here is the call graph for this function:

Definition at line 847 of file nsToolkitProfileService.cpp.

{
    nsToolkitProfileService* aThis = new nsToolkitProfileService();
    nsresult rv = aThis->Init();
    if (NS_FAILED(rv)) {
        NS_ERROR("nsToolkitProfileService::Init failed!");
        delete aThis;
        return rv;
    }

    NS_ADDREF(*aResult = aThis);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 54 of file nsConsoleWriter.cpp.

{
  nsresult rv;

  nsCOMPtr<nsILocalFile> lfile;

  char* logFileEnv = PR_GetEnv("XRE_CONSOLE_LOG");
  if (logFileEnv && *logFileEnv) {
    rv = XRE_GetFileFromPath(logFileEnv, getter_AddRefs(lfile));
    if (NS_FAILED(rv))
      return;
  }
  else {
    if (!gLogConsoleErrors)
      return;

    rv = gDirServiceProvider->GetUserAppDataDirectory(getter_AddRefs(lfile));
    if (NS_FAILED(rv))
      return;

    lfile->AppendNative(NS_LITERAL_CSTRING("console.log"));
  }

  PRFileDesc *file;
  rv = lfile->OpenNSPRFileDesc(PR_WRONLY | PR_APPEND | PR_CREATE_FILE,
                               0660, &file);
  if (NS_FAILED(rv))
    return;

  nsCOMPtr<nsIConsoleService> csrv
    (do_GetService(NS_CONSOLESERVICE_CONTRACTID));
  if (!csrv) {
    PR_Close(file);
    return;
  }

  nsIConsoleMessage** messages;
  PRUint32 mcount;

  rv = csrv->GetMessageArray(&messages, &mcount);
  if (NS_FAILED(rv)) {
    PR_Close(file);
    return;
  }

  if (mcount) {
    PRExplodedTime etime;
    PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &etime);
    char datetime[512];
    PR_FormatTimeUSEnglish(datetime, sizeof(datetime),
                           "%Y-%m-%d %H:%M:%S", &etime);

    PR_fprintf(file, NS_LINEBREAK
                     "*** Console log: %s ***" NS_LINEBREAK,
               datetime);
  }

  // From this point on, we have to release all the messages, and free
  // the memory allocated for the messages array. XPCOM arrays suck.

  nsXPIDLString msg;
  nsCAutoString nativemsg;

  for (PRUint32 i = 0; i < mcount; ++i) {
    rv = messages[i]->GetMessage(getter_Copies(msg));
    if (NS_SUCCEEDED(rv)) {
      NS_CopyUnicodeToNative(msg, nativemsg);
      PR_fprintf(file, "%s" NS_LINEBREAK, nativemsg.get());
    }
    NS_IF_RELEASE(messages[i]);
  }

  PR_Close(file);
  NS_Free(messages);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 2184 of file nsAppRunner.cpp.

Definition at line 260 of file nsAppRunner.cpp.

char** gArgv

Definition at line 261 of file nsAppRunner.cpp.

Definition at line 100 of file nsXREDirProvider.cpp.

Definition at line 720 of file nsAppRunner.cpp.

Definition at line 480 of file nsAppRunner.cpp.