Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsNativeAppSupport.h File Reference
#include "nsINativeAppSupport.h"
#include "nsISplashScreen.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

nsresult NS_CreateSplashScreen (nsISplashScreen **aResult)
PRBool NS_CanRun ()
nsresult NS_CreateNativeAppSupport (nsINativeAppSupport **aResult)
 Create the nativeappsupport implementation.
nsresult DoCommandLines (nsICmdLineService *cmdLine, PRBool *windowOpened)

Function Documentation

nsresult DoCommandLines ( nsICmdLineService cmdLine,
PRBool windowOpened 
)

Definition at line 668 of file nsAppRunner.cpp.

{
  NS_ENSURE_ARG(windowOpened);
  *windowOpened = PR_FALSE;

  nsresult rv;

       PRInt32 height = nsIAppShellService::SIZE_TO_CONTENT;
       PRInt32 width  = nsIAppShellService::SIZE_TO_CONTENT;
       nsXPIDLCString tempString;

       // Get the value of -width option
       rv = cmdLineArgs->GetCmdLineValue("-width", getter_Copies(tempString));
       if (NS_SUCCEEDED(rv) && !tempString.IsEmpty())
    PR_sscanf(tempString.get(), "%d", &width);

       // Get the value of -height option
       rv = cmdLineArgs->GetCmdLineValue("-height", getter_Copies(tempString));
       if (NS_SUCCEEDED(rv) && !tempString.IsEmpty())
    PR_sscanf(tempString.get(), "%d", &height);
  
    PRInt32 argc = 0;
    rv = cmdLineArgs->GetArgc(&argc);
  if (NS_FAILED(rv)) 
    return rv;

    char **argv = nsnull;
    rv = cmdLineArgs->GetArgv(&argv);
  if (NS_FAILED(rv)) 
    return rv;

  // first apply command line args
  // if there is any window opened, startup preferences are ignored
    PRInt32 i = 0;
    for (i=1;i<argc;i++) {
#ifdef DEBUG_CMD_LINE
      printf("XXX argv[%d] = %s\n",i,argv[i]);
#endif /* DEBUG_CMD_LINE */
      if (IsStartupCommand(argv[i])) {

        // skip over the - (or / on windows)
        char *command = argv[i] + 1;
#ifdef XP_UNIX
        // unix allows -mail and --mail
        if ((argv[i][0] == '-') && (argv[i][1] == '-')) {
          command = argv[i] + 2;
        }
#endif /* XP_UNIX */

        // this can fail, as someone could do -foo, where -foo is not handled
        rv = LaunchApplicationWithArgs((const char *)(argv[i]),
                                       cmdLineArgs, command,
                                       height, width, windowOpened);
        if (rv == NS_ERROR_NOT_AVAILABLE || rv == NS_ERROR_ABORT)
          return rv;
      }
    }
   // second if an URL is given in the command line
   // then open a browser window with the URL
  nsXPIDLCString urlToLoad;
  rv = cmdLineArgs->GetURLToLoad(getter_Copies(urlToLoad));
  if (NS_SUCCEEDED(rv) && !urlToLoad.IsEmpty()) {
    nsCOMPtr<nsICmdLineHandler> handler(
      do_GetService("@mozilla.org/commandlinehandler/general-startup;1?type=browser"));

    nsXPIDLCString chromeUrlForTask;
    rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));

    if (NS_SUCCEEDED(rv)) {
      // convert the cmdLine URL to Unicode
      nsAutoString url;
      NS_CopyNativeToUnicode(urlToLoad, url);
      rv = OpenWindow(chromeUrlForTask, url, width, height);
    }

    if (NS_SUCCEEDED(rv)) {
      *windowOpened = PR_TRUE;
    }
  }

  // third if no window is opened then apply the startup preferences
  if (!*windowOpened) {
    nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
    if (NS_FAILED(rv))
      return rv;
    rv = appStartup->CreateStartupState(width, height, windowOpened);
    if (NS_FAILED(rv))
      return rv;
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 324 of file nsAppRunner.cpp.

{
       return PR_TRUE;
}

Here is the caller graph for this function:

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 call graph for this function:

Definition at line 313 of file nsAppRunner.cpp.

{
    nsresult rv = NS_OK;
    if (aResult) {
        *aResult = 0;
    } else {
        rv = NS_ERROR_NULL_POINTER;
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function: