nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID)); if (appShellService) { nsCOMPtr<nsINativeAppSupport> nativeApp; appShellService->GetNativeAppSupport(getter_AddRefs(nativeApp)); if (nativeApp) { PRBool serverMode = PR_FALSE; nativeApp->GetIsServerMode(&serverMode); if (serverMode) {  nativeApp->StartServerMode(); return NS_OK; } }
nsCOMPtr<nsINativeAppSupport> nativeApp; PRBool serverMode; rv = GetNativeAppSupport(getter_AddRefs(nativeApp)); if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(nativeApp->GetIsServerMode(&serverMode)) && serverMode) {  nativeApp->StartServerMode(); return NS_OK;
static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs){  nsresult rv;  nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID, &rv));  if (NS_FAILED(rv))    return rv;  nsCOMPtr<nsISimpleEnumerator> windowEnumerator;  if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator))))  {    PRBool more;	    windowEnumerator->HasMoreElements(&more);    if ( !more )    {      // If starting up in server mode, then we do things differently.      nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID));      if (appShellService) {        nsCOMPtr<nsINativeAppSupport> nativeApp;        appShellService->GetNativeAppSupport(getter_AddRefs(nativeApp));        if (nativeApp) {          PRBool serverMode = PR_FALSE;          nativeApp->GetIsServerMode(&serverMode);          if (serverMode) {            // Create special Nav window.            nativeApp->StartServerMode();            return NS_OK;          }        }      }      // No window exists so lets create a browser one      PRInt32 height  = NS_SIZETOCONTENT;      PRInt32 width  = NS_SIZETOCONTENT;				      // Get the value of -width option      nsXPIDLCString tempString;      rv = cmdLineArgs->GetCmdLineValue("-width", getter_Copies(tempString));      if (NS_FAILED(rv))        return rv;      if ((const char*)tempString)        PR_sscanf(tempString, "%d", &width);								      // Get the value of -height option      rv = cmdLineArgs->GetCmdLineValue("-height", getter_Copies(tempString));      if (NS_FAILED(rv))        return rv;      if ((const char*)tempString)        PR_sscanf(tempString, "%d", &height);				      rv = OpenBrowserWindow(height, width);    }  }  return rv;}