- Turbo mode should run Mozilla from registry (88844). r=ccarlen sr=ben
- Systray menu for turbo should include components (89532). r=syd sr=ben
- Installer checkbox needs to turn turbo on properly (96936, 97338). r=ccarlen sr=ben
- Add 'Disable Quick Launch' menuitem to turbo systray icon (98770). r=syd sr=ben
- Need confirmation dialog when 'Disable Quick Launch' is selected (98805). r=syd sr=ben
- Show dialog when last window is closed in turbo mode (89166). r=ccarlen sr=ben

and some cleanup.
This commit is contained in:
blakeross%telocity.com 2001-09-10 23:48:09 +00:00
Родитель 0b9548abdc
Коммит 58210fe390
24 изменённых файлов: 620 добавлений и 548 удалений

Просмотреть файл

Просмотреть файл

@ -196,6 +196,7 @@ en-US.jar:
locale/en-US/messenger/msgFolderPickerOverlay.dtd (base/resources/locale/en-US/msgFolderPickerOverlay.dtd)
locale/en-US/messenger/msgHdrViewOverlay.dtd (base/resources/locale/en-US/msgHdrViewOverlay.dtd)
locale/en-US/messenger/mailTasksOverlay.dtd (base/resources/locale/en-US/mailTasksOverlay.dtd)
locale/en-US/messenger/mailTurboMenu.properties (base/resources/locale/en-US/mailTurboMenu.properties)
locale/en-US/messenger/mailNavigatorOverlay.dtd (base/resources/locale/en-US/mailNavigatorOverlay.dtd)
locale/en-US/messenger/mailEditorOverlay.dtd (base/resources/locale/en-US/mailEditorOverlay.dtd)
locale/en-US/messenger/mailOverlay.dtd (base/resources/locale/en-US/mailOverlay.dtd)

Просмотреть файл

@ -1,4 +0,0 @@
classic.jar:
skin/classic/navigator/navigator.css
skin/classic/navigator/resources.xml

Просмотреть файл

Просмотреть файл

@ -0,0 +1,4 @@
#turboTrayImage {
list-style-image: url("chrome://navigator/skin/turbo-systray.gif");
border: 2px inset ThreeDHighlight !important;
}

Просмотреть файл

@ -272,12 +272,15 @@ menulist[editable="true"] {
.menulist-editable-box {
border: 1px solid #5D616E;
padding: 1px 0px 1px 2px;
}
html|*.menulist-editable-text {
border: none !important;
margin: 0px !important;
border: none !important;
padding: 0px !important;
background-color: inherit;
font: inherit;
}
menulist[editable="true"]> .menulist-editable-box > .menu-dropmarker-box > .menu-dropmarker {

Просмотреть файл

@ -752,6 +752,8 @@ modern.jar:
skin/modern/navigator/navigatorBindings.xml (navigator/navigatorBindings.xml)
skin/modern/navigator/personalToolbar.css (navigator/personalToolbar.css)
skin/modern/navigator/resources.xml (navigator/resources.xml)
skin/modern/navigator/turbo-systray.gif (navigator/turbo-systray.gif)
skin/modern/navigator/turbo.css (navigator/turbo.css)
skin/modern/navigator/btn1/back-act.gif (navigator/btn1/back-act.gif)
skin/modern/navigator/btn1/back-dis.gif (navigator/btn1/back-dis.gif)
skin/modern/navigator/btn1/back-hov.gif (navigator/btn1/back-hov.gif)

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -149,14 +149,8 @@
* Windows startup folder at system initialization.
*
*
* needsProfileUI - Boolean attribute used when running in "server mode."
* If the "server mode" caused profile dialogs to be
* suppressed, this should be set to true. When the server
* starts a real session, it will call on the profile mgr
* to do what it needed to do when this attribute is true.
*/
interface nsIDOMWindow;
interface nsIXULWindow;
[scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)]
@ -172,8 +166,8 @@ interface nsINativeAppSupport : nsISupports {
// Server mode.
attribute boolean isServerMode;
attribute boolean shouldShowUI;
void startServerMode();
attribute boolean needsProfileUI;
void onLastWindowClosing(in nsIXULWindow aWindow);
};

Просмотреть файл

@ -222,14 +222,11 @@ nsAppShellService::DoProfileStartup(nsICmdLineService *aCmdLineService, PRBool c
PRBool saveQuitOnLastWindowClosing = mQuitOnLastWindowClosing;
mQuitOnLastWindowClosing = PR_FALSE;
// If we are in server mode, profile mgr cannot show UI
// If we being launched in turbo mode, profile mgr cannot show UI
rv = profileMgr->StartupWithArgs(aCmdLineService, canInteract);
NS_ASSERTION(NS_SUCCEEDED(rv), "StartupWithArgs failed\n");
if (!canInteract && rv == NS_ERROR_PROFILE_REQUIRES_INTERACTION) {
if (mNativeAppSupport) {
mNativeAppSupport->SetNeedsProfileUI(PR_TRUE);
rv = NS_OK;
}
NS_WARNING("nsIProfileInternal::StartupWithArgs returned NS_ERROR_PROFILE_REQUIRES_INTERACTION");
rv = NS_OK;
}
mQuitOnLastWindowClosing = saveQuitOnLastWindowClosing;

Просмотреть файл

@ -56,8 +56,8 @@
#include "nsIContentHandler.h"
#include "nsIBrowserInstance.h"
#include "nsIEventQueueService.h"
#include "nsMPFileLocProvider.h"
#include "nsDirectoryServiceDefs.h"
#include "nsMPFileLocProvider.h"
#include "nsDirectoryServiceDefs.h"
#include "nsIHttpProtocolHandler.h"
#include "nsBuildID.h"
#include "nsWindowCreator.h"
@ -79,7 +79,6 @@
#include "nsIXRemoteClient.h"
#include "nsIXRemoteService.h"
#endif
#define TURBO_PREF "browser.turbo.enabled"
#ifdef NS_TRACE_MALLOC
#include "nsTraceMalloc.h"
@ -91,12 +90,8 @@
#define DEBUG_CMD_LINE
#endif
// Standalone App defines
#define STANDALONE_APP_PREF "profile.standalone_app.enable"
#define STANDALONE_APP_DIR_PREF "profile.standalone_app.directory"
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
static NS_DEFINE_CID(kIProcessCID, NS_PROCESS_CID);
static NS_DEFINE_CID(kIProcessCID, NS_PROCESS_CID);
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
#define UILOCALE_CMD_LINE_ARG "-UILocale"
@ -227,10 +222,10 @@ public:
{
// TSM is initialized in InitializeMacToolbox
};
~stTSMCloser()
{
#if !TARGET_CARBON
#if !TARGET_CARBON
(void)CloseTSMAwareApplication();
#endif
}
@ -255,7 +250,7 @@ static char *sWatcherServiceContractID = "@mozilla.org/embedcomp/window-watcher;
#if !defined (XP_MAC ) && !defined(NTO) && !defined( XP_PC ) && !defined( XP_BEOS )
nsresult NS_CreateSplashScreen( nsISplashScreen **aResult )
{
{
nsresult rv = NS_OK;
if ( aResult ) {
*aResult = 0;
@ -305,11 +300,11 @@ static nsresult GetNativeAppSupport(nsINativeAppSupport** aNativeApp)
{
NS_ENSURE_ARG_POINTER(aNativeApp);
*aNativeApp = nsnull;
nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID));
if (appShellService)
appShellService->GetNativeAppSupport(aNativeApp);
return *aNativeApp ? NS_OK : NS_ERROR_FAILURE;
}
@ -494,7 +489,7 @@ LaunchApplicationWithArgs(const char *commandLineArg,
NS_ENSURE_ARG(aParam);
nsresult rv;
nsCOMPtr<nsICmdLineService> cmdLine =
do_GetService("@mozilla.org/appshell/commandLineService;1",&rv);
if (NS_FAILED(rv)) return rv;
@ -643,13 +638,13 @@ static nsresult HandleArbitraryStartup( nsICmdLineService* cmdLineArgs, nsIPref
// Get the value of -width option
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);
if (heedGeneralStartupPrefs) {
@ -707,7 +702,7 @@ static nsresult HandleArbitraryStartup( nsICmdLineService* cmdLineArgs, nsIPref
static nsresult DoCommandLines(nsICmdLineService* cmdLine, PRBool heedGeneralStartupPrefs)
{
nsresult rv;
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
@ -801,19 +796,24 @@ static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs)
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<nsINativeAppSupport> nativeApp;
PRBool serverMode = PR_FALSE;
rv = GetNativeAppSupport(getter_AddRefs(nativeApp));
// Create special Nav window.
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(nativeApp->GetIsServerMode(&serverMode)) && serverMode) {
nativeApp->StartServerMode();
return NS_OK;
}
#ifdef XP_WIN32
// If starting up in server mode, then we do things differently.
nsCOMPtr<nsINativeAppSupport> nativeApp;
rv = GetNativeAppSupport(getter_AddRefs(nativeApp));
// Create special Nav window.
if (NS_SUCCEEDED(rv)) {
PRBool shouldShowUI = PR_TRUE;
nativeApp->GetShouldShowUI(&shouldShowUI);
if (!shouldShowUI) {
nativeApp->StartServerMode();
return NS_OK;
}
}
#endif
// No window exists so lets create a browser one
PRInt32 height = nsIAppShellService::SIZE_TO_CONTENT;
@ -826,8 +826,8 @@ static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs)
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))
@ -835,7 +835,7 @@ static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs)
if ((const char*)tempString)
PR_sscanf(tempString, "%d", &height);
rv = OpenBrowserWindow(height, width);
}
}
@ -871,76 +871,18 @@ static nsresult InstallGlobalLocale(nsICmdLineService *cmdLineArgs)
return NS_OK;
}
// Do the righe thing to provide locations depending on whether an
// application is standalone or not
static nsresult InitializeProfileService(nsICmdLineService *cmdLineArgs)
{
// If we are being launched in -turbo mode, we cannot show UI
PRBool shouldShowUI = PR_TRUE;
nsCOMPtr<nsINativeAppSupport> nativeApp;
if (NS_SUCCEEDED(GetNativeAppSupport(getter_AddRefs(nativeApp))))
nativeApp->GetShouldShowUI(&shouldShowUI);
nsresult rv;
nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID, &rv));
if (NS_FAILED(rv)) return rv;
rv = appShellService->DoProfileStartup(cmdLineArgs, shouldShowUI);
PRBool standaloneApp = PR_FALSE;
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
rv = prefs->GetBoolPref(STANDALONE_APP_PREF, &standaloneApp);
if (NS_SUCCEEDED(rv) && standaloneApp)
{
nsMPFileLocProvider *fileLocProvider = new nsMPFileLocProvider;
NS_ENSURE_TRUE(fileLocProvider, NS_ERROR_OUT_OF_MEMORY);
// Specify the dir that standalone app will use for its "profile" dir
nsCOMPtr<nsIFile> parentDir;
PRBool exists = PR_FALSE;
#ifdef XP_OS2
rv = NS_GetSpecialDirectory(NS_OS2_HOME_DIR, getter_AddRefs(parentDir));
if (NS_SUCCEEDED(rv))
rv = parentDir->Exists(&exists);
if (NS_FAILED(rv) || !exists)
return rv;
#elif defined(XP_PC)
rv = NS_GetSpecialDirectory(NS_WIN_APPDATA_DIR, getter_AddRefs(parentDir));
if (NS_SUCCEEDED(rv))
rv = parentDir->Exists(&exists);
if (NS_FAILED(rv) || !exists)
{
parentDir = nsnull;
rv = NS_GetSpecialDirectory(NS_WIN_WINDOWS_DIR, getter_AddRefs(parentDir));
}
if (NS_FAILED(rv))
return rv;
#else
rv = NS_GetSpecialDirectory(NS_OS_HOME_DIR, getter_AddRefs(parentDir));
if (NS_SUCCEEDED(rv))
rv = parentDir->Exists(&exists);
if (NS_FAILED(rv) || !exists)
return rv;
#endif
// Get standalone app dir name from prefs and initialize mpfilelocprovider
nsXPIDLCString appDir;
rv = prefs->CopyCharPref(STANDALONE_APP_DIR_PREF, getter_Copies(appDir));
if (NS_FAILED(rv) || (nsCRT::strlen(appDir) == 0))
return NS_ERROR_FAILURE;
rv = fileLocProvider->Initialize(parentDir, appDir);
if (NS_FAILED(rv)) return rv;
rv = prefs->ResetPrefs();
if (NS_FAILED(rv)) return rv;
rv = prefs->ReadUserPrefs(nsnull);
if (NS_FAILED(rv)) return rv;
}
else
{
nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID, &rv));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsINativeAppSupport> nativeAppSupport;
PRBool serverMode = PR_FALSE;
::GetNativeAppSupport(getter_AddRefs(nativeAppSupport));
if (nativeAppSupport)
nativeAppSupport->GetIsServerMode(&serverMode);
rv = appShellService->DoProfileStartup(cmdLineArgs, !serverMode);
}
return rv;
}
@ -976,8 +918,8 @@ static void ShowOSAlertFromFile(int argc, char **argv, const char *alert_filenam
directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = directoryService->Get(NS_APP_RES_DIR,
NS_GET_IID(nsIFile),
rv = directoryService->Get(NS_APP_RES_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(fileName));
if (NS_SUCCEEDED(rv) && fileName) {
fileName->Append(alert_filename);
@ -1005,12 +947,12 @@ static nsresult VerifyInstallation(int argc, char **argv)
nsresult rv;
nsCOMPtr<nsILocalFile> registryFile;
nsCOMPtr<nsIProperties> directoryService =
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return NS_OK;
rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR,
NS_GET_IID(nsIFile),
rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(registryFile));
if (NS_FAILED(rv) || !registryFile)
return NS_OK;
@ -1028,7 +970,7 @@ static nsresult VerifyInstallation(int argc, char **argv)
char* lastResortMessage = "A previous install did not complete correctly. Finishing install.";
ShowOSAlertFromFile(argc, argv, CLEANUP_MESSAGE_FILENAME, lastResortMessage);
nsCOMPtr<nsIFile> cleanupUtility;
registryFile->Clone(getter_AddRefs(cleanupUtility));
cleanupUtility->SetLeafName(CLEANUP_UTIL);
@ -1038,7 +980,7 @@ static nsresult VerifyInstallation(int argc, char **argv)
rv = cleanupProcess->Init(cleanupUtility);
if (NS_SUCCEEDED(rv))
rv = cleanupProcess->Run(PR_FALSE,nsnull, 0, nsnull);
//We must exit because all open files must be released by the system
return NS_ERROR_FAILURE;
}
@ -1051,11 +993,11 @@ static nsresult VerifyPsmAbsentOrSane(int argc, char **argv)
nsCOMPtr<nsIEntropyCollector> enCol =
do_GetService(NS_ENTROPYCOLLECTOR_CONTRACTID, &rv);
if (rv == NS_ERROR_ABORT) {
// In case the security component can not do its internal initialization,
// In case the security component can not do its internal initialization,
// we must warn the user and exit.
char *panicMsg = "Could not initialize the browser's security component. "
"The most likely cause is problems with files in your "
"browser's profile directory. Please check that this "
@ -1063,9 +1005,9 @@ static nsresult VerifyPsmAbsentOrSane(int argc, char **argv)
"hard disk is not full or close to full.";
char *panicMessageFilename = "nssifail.txt";
ShowOSAlertFromFile(argc, argv, panicMessageFilename, panicMsg);
return rv;
}
@ -1260,7 +1202,7 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize appshell");
if (NS_FAILED(rv)) return rv;
rv = InitializeWindowCreator();
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize window creator");
if (NS_FAILED(rv)) return rv;
@ -1288,20 +1230,6 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
appShell->CreateHiddenWindow();
NS_TIMELINE_LEAVE("appShell->CreateHiddenWindow");
nsCOMPtr<nsINativeAppSupport> nativeApps;
rv = GetNativeAppSupport(getter_AddRefs(nativeApps));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
if (NS_SUCCEEDED(rv) && prefs) {
PRBool serverMode = PR_FALSE;
nativeApps->GetIsServerMode(&serverMode);
if (!serverMode) { // okay, so it's not -turbo
prefs->GetBoolPref(TURBO_PREF, &serverMode);
nativeApps->SetIsServerMode(serverMode);
}
}
}
// This will go away once Components are handling there own commandlines
// if we have no command line arguments, we need to heed the
// "general.startup.*" prefs
@ -1447,7 +1375,7 @@ static nsresult DumpVersion(char *appname)
nsXPIDLCString agent;
httpHandler->GetUserAgent(getter_Copies(agent));
printf("%s", agent.get());
if(buildID) {
@ -1455,7 +1383,7 @@ static nsresult DumpVersion(char *appname)
} else {
printf(" <developer build>\n");
}
return rv;
}
@ -1593,7 +1521,7 @@ int main(int argc, char* argv[])
// They should% return quick, so we deal with them here.
if (HandleDumpArguments(argc, argv))
return 0;
#ifdef NS_TRACE_MALLOC
argc = NS_TraceMallocStartupArgs(argc, argv);
#endif

Просмотреть файл

@ -26,7 +26,8 @@ nsNativeAppSupportBase::nsNativeAppSupportBase()
: mRefCnt( 0 ),
mSplash( 0 ),
mServerMode( PR_FALSE ),
mNeedsProfileUI( PR_FALSE ) {
mShouldShowUI( PR_TRUE ),
mShownTurboDialog( PR_FALSE ) {
}
nsNativeAppSupportBase::~nsNativeAppSupportBase() {
@ -94,15 +95,15 @@ nsNativeAppSupportBase::GetIsServerMode(PRBool *aIsServerMode) {
}
NS_IMETHODIMP
nsNativeAppSupportBase::GetNeedsProfileUI(PRBool *aNeedsProfileUI) {
NS_ENSURE_ARG_POINTER(aNeedsProfileUI);
*aNeedsProfileUI = mNeedsProfileUI;
nsNativeAppSupportBase::SetShouldShowUI(PRBool aShouldShowUI) {
mShouldShowUI = aShouldShowUI;
return NS_OK;
}
NS_IMETHODIMP
nsNativeAppSupportBase::SetNeedsProfileUI(PRBool aNeedsProfileUI) {
mNeedsProfileUI = aNeedsProfileUI;
nsNativeAppSupportBase::GetShouldShowUI(PRBool *aShouldShowUI) {
NS_ENSURE_ARG( aShouldShowUI );
*aShouldShowUI = mShouldShowUI;
return NS_OK;
}

Просмотреть файл

@ -53,6 +53,7 @@ public:
nsrefcnt mRefCnt;
nsCOMPtr<nsISplashScreen> mSplash;
PRBool mServerMode;
PRBool mNeedsProfileUI;
PRBool mShouldShowUI;
PRBool mShownTurboDialog;
}; // class nsSplashScreenWin

Просмотреть файл

@ -346,6 +346,7 @@ public:
NS_IMETHOD Quit();
NS_IMETHOD StartServerMode();
NS_IMETHOD SetIsServerMode( PRBool isServerMode );
NS_IMETHOD OnLastWindowClosing( nsIXULWindow *aWindow );
// The "old" Start method (renamed).
NS_IMETHOD StartDDE();
@ -1766,41 +1767,33 @@ nsNativeAppSupportOS2::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
return rv;
}
// Check the needsProfileUI attribute of the native app and,
// if so, do it. Once this suceeds, set the attribute to false
// so we can only do this once.
// Check to see if we have a profile. We will not have a profile
// at this point if we were launched invisibly in -turbo mode, and
// the profile mgr needed to show UI (to pick from multiple profiles).
// At this point, we can show UI, so call DoProfileStartUp().
nsresult
nsNativeAppSupportOS2::EnsureProfile(nsICmdLineService* args)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIAppShellService> appShell = do_GetService( "@mozilla.org/appshell/appShellService;1", &rv );
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsINativeAppSupport> nativeApp;
rv = appShell->GetNativeAppSupport(getter_AddRefs(nativeApp));
if (NS_FAILED(rv)) return rv;
PRBool needsProfileUI;
rv = nativeApp->GetNeedsProfileUI(&needsProfileUI);
if (NS_FAILED(rv)) return rv;
nsresult rv;
nsCOMPtr<nsIProfileInternal> profileMgr(do_GetService(NS_PROFILE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIAppShellService> appShell(do_GetService("@mozilla.org/appshell/appShellService;1", &rv));
if (NS_FAILED(rv)) return rv;
// If we have a profile, everything is fine.
PRBool haveProfile;
rv = profileMgr->IsCurrentProfileAvailable(&haveProfile);
if (NS_SUCCEEDED(rv) && haveProfile)
return NS_OK;
if (needsProfileUI) {
// We need profile UI because we started in
// server mode and could not show it then.
rv = profileMgr->StartupWithArgs(args, PR_TRUE);
if (NS_FAILED(rv)) return rv;
nativeApp->SetNeedsProfileUI(PR_FALSE);
}
else {
// Even if not started in server mode, ensure
// that we have a profile. We can hit this case
// if somebody double-clicks the app twice.
PRBool haveProfile = PR_FALSE;
(void)profileMgr->IsCurrentProfileAvailable(&haveProfile);
if (!haveProfile) return NS_ERROR_FAILURE;
}
return NS_OK;
// If the profile selection is happening, fail.
PRBool doingProfileStartup;
rv = profileMgr->GetIsStartingUp(&doingProfileStartup);
if (NS_FAILED(rv) || doingProfileStartup) return NS_ERROR_FAILURE;
rv = appShell->DoProfileStartup(args, PR_TRUE);
return rv;
}
nsresult
@ -2142,6 +2135,33 @@ nsNativeAppSupportOS2::SetIsServerMode( PRBool isServerMode ) {
return nsNativeAppSupportBase::SetIsServerMode( isServerMode );
}
NS_IMETHODIMP
nsNativeAppSupportOS2::OnLastWindowClosing( nsIXULWindow *aWindow ) {
nsresult rv;
if (!mServerMode)
return NS_OK;
// If the last window closed is our special "turbo" window made
// in StartServerMode(), don't do anything.
nsCOMPtr<nsIDocShell> docShell;
(void)aWindow->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(docShell));
if (domWindow == mInitialWindow) {
mInitialWindow = nsnull;
return NS_OK;
}
nsCOMPtr<nsIProfileInternal> profileMgr(do_GetService(NS_PROFILE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
rv = profileMgr->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
// go through the command line arguments, and try to load a handler
// for one, and when we do, get the chrome URL for its task

Просмотреть файл

@ -17,7 +17,7 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Contributor(s):
* Bill Law law@netscape.com
*/
@ -38,8 +38,8 @@
#include "nsIWindowWatcher.h"
#include "nsIDOMWindowInternal.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocShell.h"
#include "nsIBaseWindow.h"
#include "nsIDocShell.h"
#include "nsIBaseWindow.h"
#include "nsIWidget.h"
#include "nsIAppShellService.h"
#include "nsIProfileInternal.h"
@ -47,6 +47,11 @@
#include "nsIXULWindow.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIPref.h"
#include "nsIWindowsHooks.h"
#include "nsIPromptService.h"
#include "nsNetCID.h"
#include "nsIHttpProtocolHandler.h"
// These are needed to load a URL in a browser window.
#include "nsIDOMLocation.h"
@ -61,9 +66,15 @@
#include <io.h>
#include <fcntl.h>
#define TURBO_QUIT 1
#define TURBO_NAVIGATOR 1
#define TURBO_MAIL 2
#define TURBO_EDITOR 3
#define TURBO_ADDRESSBOOK 4
#define TURBO_DISABLE 5
#define TURBO_EXIT 6
static HWND hwndForDOMWindow( nsISupports * );
static NS_DEFINE_CID(kHttpHandlerCID, NS_HTTPPROTOCOLHANDLER_CID);
static
nsresult
@ -255,13 +266,13 @@ private:
* code consists of initializing DDE and doing a DdeConnect to Mozilla's
* application/topic. If that connection succeeds, then a server process
* must be running already.
*
*
* Otherwise, no server has started. In that case, the current process
* calls DdeNameService to register that application/topic. Only at that
* point does the mutex get released.
*
* There are a couple of subtleties that one should be aware of:
*
*
* 1. It is imperative that DdeInitialize be called only after the mutex
* lock has been obtained. The reason is that at shutdown, DDE
* notifications go out to all initialized DDE processes. Thus, if
@ -274,7 +285,7 @@ private:
*
* 2. All mutex requests are made with a reasonably long timeout value and
* are designed to "fail safe" (i.e., a timeout is treated as failure).
*
*
* 3. An attempt has been made to minimize the degree to which the main
* Mozilla application logic needs to be aware of the DDE mechanisms
* implemented herein. As a result, this module surfaces a very
@ -367,7 +378,6 @@ private:
static DWORD mInstance;
static char *mAppName;
static nsIDOMWindow *mInitialWindow;
static nsXPIDLString mLastProfileName;
friend struct MessageWindow;
}; // nsNativeAppSupportWin
@ -467,10 +477,10 @@ nsSplashScreenWin::DialogProc( HWND dlg, UINT msg, WPARAM wp, LPARAM lp ) {
splashScreen->LoadBitmap();
}
/* Size and center the splash screen correctly. The flags in the
* dialog template do not do the right thing if the user's
/* Size and center the splash screen correctly. The flags in the
* dialog template do not do the right thing if the user's
* machine is using large fonts.
*/
*/
HWND bitmapControl = GetDlgItem( dlg, IDB_SPLASH );
if ( bitmapControl ) {
HBITMAP hbitmap = (HBITMAP)SendMessage( bitmapControl,
@ -587,14 +597,15 @@ nsNativeAppSupportWin::CheckConsole() {
||
strcmp( "/turbo", __argv[i] ) == 0
||
strcmp( "-server", __argv[i] ) == 0
strcmp( "-server", __argv[i] ) == 0
||
strcmp( "/server", __argv[i] ) == 0 ) {
// Start in server mode (and suppress splash screen).
strcmp( "/server", __argv[i] ) == 0 ) {
// Start in server mode (and suppress splash screen).
mServerMode = PR_TRUE;
mShouldShowUI = PR_FALSE;
__argv[i] = "-nosplash"; // Bit of a hack, but it works!
// Ignore other args.
break;
// Ignore other args.
break;
}
}
return;
@ -606,11 +617,11 @@ nsresult
NS_CreateNativeAppSupport( nsINativeAppSupport **aResult ) {
if ( aResult ) {
nsNativeAppSupportWin *pNative = new nsNativeAppSupportWin;
if ( pNative ) {
*aResult = pNative;
NS_ADDREF( *aResult );
// Check for dynamic console creation request.
pNative->CheckConsole();
if ( pNative ) {
*aResult = pNative;
NS_ADDREF( *aResult );
// Check for dynamic console creation request.
pNative->CheckConsole();
} else {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -668,11 +679,10 @@ HSZ nsNativeAppSupportWin::mApplication = 0;
HSZ nsNativeAppSupportWin::mTopics[nsNativeAppSupportWin::topicCount] = { 0 };
DWORD nsNativeAppSupportWin::mInstance = 0;
nsIDOMWindow* nsNativeAppSupportWin::mInitialWindow = nsnull;
nsXPIDLString nsNativeAppSupportWin::mLastProfileName;
NOTIFYICONDATA nsNativeAppSupportWin::mIconData = { sizeof(NOTIFYICONDATA),
0,
1,
1,
NIF_ICON | NIF_MESSAGE | NIF_TIP,
WM_USER,
0,
@ -685,7 +695,7 @@ struct MessageWindow {
// ctor/dtor are simplistic
MessageWindow() {
// Try to find window.
mHandle = ::FindWindow( className(), 0 );
mHandle = ::FindWindow( className(), 0 );
}
// Act like an HWND.
@ -697,7 +707,7 @@ struct MessageWindow {
static const char *className() {
static char classNameBuffer[128];
static char *mClassName = 0;
if ( !mClassName ) {
if ( !mClassName ) {
::_snprintf( classNameBuffer,
sizeof classNameBuffer,
"%s%s",
@ -763,7 +773,7 @@ struct MessageWindow {
// Show menu with Exit disabled/enabled appropriately.
nsCOMPtr<nsIDOMWindowInternal> win;
GetMostRecentWindow( 0, getter_AddRefs( win ) );
::EnableMenuItem( nsNativeAppSupportWin::mTrayIconMenu, 1, win ? MF_GRAYED : MF_ENABLED );
::EnableMenuItem( nsNativeAppSupportWin::mTrayIconMenu, TURBO_EXIT, win ? MF_GRAYED : MF_ENABLED );
POINT pt;
GetCursorPos( &pt );
@ -778,9 +788,61 @@ struct MessageWindow {
0 );
switch (selectedItem) {
case TURBO_QUIT:
case TURBO_NAVIGATOR:
(void)nsNativeAppSupportWin::HandleRequest( (LPBYTE)"mozilla" );
break;
case TURBO_MAIL:
(void)nsNativeAppSupportWin::HandleRequest( (LPBYTE)"mozilla -mail" );
break;
case TURBO_EDITOR:
(void)nsNativeAppSupportWin::HandleRequest( (LPBYTE)"mozilla -editor" );
break;
case TURBO_ADDRESSBOOK:
(void)nsNativeAppSupportWin::HandleRequest( (LPBYTE)"mozilla -addressbook" );
break;
case TURBO_EXIT:
(void)nsNativeAppSupportWin::HandleRequest( (LPBYTE)"mozilla -kill" );
break;
case TURBO_DISABLE:
nsresult rv;
nsCOMPtr<nsIWindowsHooks> winHooksService ( do_GetService( NS_IWINDOWSHOOKS_CONTRACTID, &rv ) );
if ( NS_SUCCEEDED( rv ) )
winHooksService->StartupTurboDisable();
nsCOMPtr<nsIStringBundleService> stringBundleService( do_GetService( NS_STRINGBUNDLE_CONTRACTID ) );
nsCOMPtr<nsIStringBundle> turboMenuBundle;
nsCOMPtr<nsIStringBundle> brandBundle;
if ( stringBundleService ) {
stringBundleService->CreateBundle( "chrome://global/locale/brand.properties", getter_AddRefs( brandBundle ) );
stringBundleService->CreateBundle( "chrome://navigator/locale/turboMenu.properties",
getter_AddRefs( turboMenuBundle ) );
}
nsXPIDLString dialogMsg;
nsXPIDLString dialogTitle;
nsXPIDLString brandName;
if ( brandBundle && turboMenuBundle ) {
brandBundle->GetStringFromName( NS_LITERAL_STRING( "brandShortName" ).get(),
getter_Copies( brandName ) );
const PRUnichar *formatStrings[] = { brandName.get() };
turboMenuBundle->GetStringFromName( NS_LITERAL_STRING( "DisableDlgMsg" ).get(),
getter_Copies( dialogMsg ) );
turboMenuBundle->FormatStringFromName( NS_LITERAL_STRING( "DisableDlgTitle" ).get(), formatStrings,
1, getter_Copies( dialogTitle ) );
}
if ( dialogMsg.get() && dialogTitle.get() && brandName.get() ) {
nsCOMPtr<nsIPromptService> dialog( do_GetService( "@mozilla.org/embedcomp/prompt-service;1" ) );
if ( dialog )
dialog->Alert( nsnull, dialogTitle.get(), dialogMsg.get() );
}
nsCOMPtr<nsIAppShellService> appShell = do_GetService( "@mozilla.org/appshell/appShellService;1", &rv );
if ( NS_SUCCEEDED( rv ) ) {
nsCOMPtr<nsINativeAppSupport> native;
rv = appShell->GetNativeAppSupport( getter_AddRefs( native ) );
if ( NS_SUCCEEDED( rv ) )
native->SetIsServerMode( PR_FALSE );
if ( !win )
appShell->Quit();
}
break;
}
PostMessage(msgWindow, WM_NULL, 0, 0);
} else if ( lp == WM_LBUTTONDBLCLK ) {
@ -810,7 +872,7 @@ char *nsNativeAppSupportWin::mAppName = nameBuffer;
* case, we use the handle to the "message" window and send
* a request corresponding to this process's command line
* options.
*
*
* If not, then this is the first instance of Mozilla. In
* that case, we create and set up the message window.
*
@ -861,6 +923,26 @@ nsNativeAppSupportWin::Start( PRBool *aResult ) {
startupLock.Unlock();
PRBool serverMode = PR_FALSE;
GetIsServerMode( &serverMode );
if ( !serverMode ) { // okay, so it's not -turbo
HKEY key;
LONG result = ::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_QUERY_VALUE, &key );
if ( result == ERROR_SUCCESS ) {
nsresult res;
nsCOMPtr<nsIHttpProtocolHandler> http ( do_GetService( kHttpHandlerCID, &res ) );
if ( NS_FAILED( res ) ) return rv;
nsXPIDLCString appName;
http->GetAppName( getter_Copies( appName ) );
nsCString fullValue; fullValue.Assign( appName );
fullValue.Append( " Quick Launch" );
result = ::RegQueryValueEx( key, fullValue, NULL, NULL, NULL, NULL );
::RegCloseKey( key );
if ( result == ERROR_SUCCESS )
SetIsServerMode( PR_TRUE );
}
}
return rv;
}
@ -903,8 +985,8 @@ nsNativeAppSupportWin::StartDDE() {
nsNativeAppSupportWin::HandleDDENotification,
APPCLASS_STANDARD,
0 ),
NS_ERROR_FAILURE );
NS_ERROR_FAILURE );
// Allocate DDE strings.
NS_ENSURE_TRUE( ( mApplication = DdeCreateStringHandle( mInstance, mAppName, CP_WINANSI ) ) && InitTopicStrings(),
NS_ERROR_FAILURE );
@ -1169,7 +1251,7 @@ nsCString nsNativeAppSupportWin::ParseDDEArg( HSZ args, int index ) {
end = temp.Length();
}
// Extract result.
result.Assign( temp.get() + offset, end - offset );
result.Assign( temp.get() + offset, end - offset );
}
}
@ -1207,7 +1289,7 @@ HDDEDATA nsNativeAppSupportWin::CreateDDEData( DWORD value ) {
void
nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) {
// Parse command line.
nsCOMPtr<nsICmdLineService> args;
nsresult rv;
@ -1255,7 +1337,7 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) {
nsCOMPtr<nsIAppShellService> appShell =
do_GetService( "@mozilla.org/appshell/appShellService;1", &rv);
if (NS_FAILED(rv)) return;
nsCOMPtr<nsINativeAppSupport> native;
rv = appShell->GetNativeAppSupport( getter_AddRefs( native ));
if (NS_SUCCEEDED(rv)) {
@ -1276,7 +1358,7 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) {
}
// ok, no idea what the param is.
// ok, no idea what the param is.
#if MOZ_DEBUG_DDE
printf( "Unknown request [%s]\n", (char*) request );
#endif
@ -1285,14 +1367,14 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) {
"@mozilla.org/commandlinehandler/general-startup;1?type=browser";
nsCOMPtr<nsICmdLineHandler> handler = do_GetService(contractID, &rv);
if (NS_FAILED(rv)) return;
rv = EnsureProfile(args);
if (NS_FAILED(rv)) return;
nsXPIDLString defaultArgs;
rv = handler->GetDefaultArgs(getter_Copies(defaultArgs));
if (NS_FAILED(rv) || !defaultArgs) return;
if (defaultArgs) {
nsCAutoString url;
url.AssignWithConversion( defaultArgs );
@ -1355,7 +1437,7 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
// We are processing the contents of an argument.
// Check for whitespace or end.
if ( *p == 0 || ( !quoted && isspace( *p ) ) ) {
// Process pending backslashes (interpret them
// Process pending backslashes (interpret them
// literally since they're not followed by a ").
while( bSlashCount ) {
arg += '\\';
@ -1364,7 +1446,7 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
// End current arg.
if ( !justCounting ) {
argv[argc] = new char[ arg.Length() + 1 ];
strcpy( argv[argc], arg.get() );
strcpy( argv[argc], arg.get() );
}
argc++;
// We're now between args.
@ -1426,7 +1508,7 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
if ( justCounting ) {
// Allocate argv array.
argv = new char*[ argc ];
// Start second pass
justCounting = 0;
init = 1;
@ -1458,13 +1540,14 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu
return rv;
}
// Check the needsProfileUI attribute of the native app and,
// if so, do it. Once this suceeds, set the attribute to false
// so we can only do this once.
// Check to see if we have a profile. We will not have a profile
// at this point if we were launched invisibly in -turbo mode, and
// the profile mgr needed to show UI (to pick from multiple profiles).
// At this point, we can show UI, so call DoProfileStartUp().
nsresult
nsNativeAppSupportWin::EnsureProfile(nsICmdLineService* args)
{
nsresult rv;
nsresult rv;
nsCOMPtr<nsIProfileInternal> profileMgr(do_GetService(NS_PROFILE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
@ -1476,23 +1559,13 @@ nsNativeAppSupportWin::EnsureProfile(nsICmdLineService* args)
rv = profileMgr->IsCurrentProfileAvailable(&haveProfile);
if (NS_SUCCEEDED(rv) && haveProfile)
return NS_OK;
// If the profile selection is happening, fail.
PRBool doingProfileStartup;
rv = profileMgr->GetIsStartingUp(&doingProfileStartup);
if (NS_FAILED(rv) || doingProfileStartup) return NS_ERROR_FAILURE;
nsCOMPtr<nsINativeAppSupport> nativeApp;
rv = appShell->GetNativeAppSupport(getter_AddRefs(nativeApp));
if (NS_FAILED(rv)) return rv;
PRBool needsProfileUI;
rv = nativeApp->GetNeedsProfileUI(&needsProfileUI);
if (NS_FAILED(rv)) return rv;
if (needsProfileUI)
rv = appShell->DoProfileStartup(args, PR_TRUE);
else
rv = profileMgr->SetCurrentProfile(mLastProfileName.get());
rv = appShell->DoProfileStartup(args, PR_TRUE);
return rv;
}
@ -1566,7 +1639,7 @@ nsNativeAppSupportWin::ReParent( nsISupports *window, HWND newParent ) {
return NS_ERROR_FAILURE;
}
// Filter out WM_SETFOCUS messages while reparenting to
// Filter out WM_SETFOCUS messages while reparenting to
// other than the desktop.
//
// For some reason, Windows generates one and it causes
@ -1638,7 +1711,7 @@ nsresult SafeJSContext::Push() {
mContext = 0;
}
}
return mContext ? NS_OK : NS_ERROR_FAILURE;
return mContext ? NS_OK : NS_ERROR_FAILURE;
}
@ -1647,7 +1720,7 @@ nsNativeAppSupportWin::OpenBrowserWindow( const char *args, PRBool newWindow ) {
nsresult rv = NS_OK;
// Open the argument URL in the most recently used Navigator window.
// If there is no Nav window, open a new one.
// Get most recently used Nav window.
nsCOMPtr<nsIDOMWindowInternal> navWin;
GetMostRecentWindow( NS_LITERAL_STRING( "navigator:browser" ).get(), getter_AddRefs( navWin ) );
@ -1698,7 +1771,16 @@ nsNativeAppSupportWin::OpenBrowserWindow( const char *args, PRBool newWindow ) {
return OpenWindow( "chrome://navigator/content", args );
}
void AppendMenuItem( HMENU& menu, PRInt32 aIdentifier, const nsString& aText ) {
char* ACPText = GetACPString( aText );
if ( ACPText ) {
::AppendMenu( menu, MF_STRING, aIdentifier, ACPText );
delete [] ACPText;
}
}
// Utility function that sets up system tray icon.
void
nsNativeAppSupportWin::SetupSysTrayIcon() {
// Messages go to the hidden window.
@ -1711,46 +1793,102 @@ nsNativeAppSupportWin::SetupSysTrayIcon() {
mIconData.szTip[0] = 0;
nsCOMPtr<nsIStringBundleService> svc( do_GetService( NS_STRINGBUNDLE_CONTRACTID ) );
if ( svc ) {
nsCOMPtr<nsIStringBundle> bundle1;
svc->CreateBundle( "chrome://global/locale/brand.properties", getter_AddRefs( bundle1 ) );
if ( bundle1 ) {
nsXPIDLString tooltip;
bundle1->GetStringFromName( NS_LITERAL_STRING( "brandShortName" ).get(),
getter_Copies( tooltip ) );
nsCOMPtr<nsIStringBundle> brandBundle;
nsXPIDLString tooltip;
svc->CreateBundle( "chrome://global/locale/brand.properties", getter_AddRefs( brandBundle ) );
if ( brandBundle ) {
brandBundle->GetStringFromName( NS_LITERAL_STRING( "brandShortName" ).get(),
getter_Copies( tooltip ) );
// (damned strings...)
nsAutoString autoTip( tooltip );
nsAutoCString tip( autoTip );
nsAutoCString tip( autoTip );
::strncpy( mIconData.szTip, (const char*)tip, sizeof mIconData.szTip - 1 );
}
// Build menu.
nsCOMPtr<nsIStringBundle> bundle2;
svc->CreateBundle( "chrome://communicator/locale/profile/profileManager.properties",
getter_AddRefs( bundle2 ) );
nsCOMPtr<nsIStringBundle> turboBundle;
nsCOMPtr<nsIStringBundle> mailBundle;
svc->CreateBundle( "chrome://navigator/locale/turboMenu.properties",
getter_AddRefs( turboBundle ) );
nsresult rv = svc->CreateBundle( "chrome://messenger/locale/mailTurboMenu.properties",
getter_AddRefs( mailBundle ) );
PRBool isMail = NS_SUCCEEDED(rv) && mailBundle;
nsAutoString exitText;
if ( bundle2 ) {
nsXPIDLString text;
bundle2->GetStringFromName( NS_LITERAL_STRING( "exitButton" ).get(),
getter_Copies( text ) );
exitText = (const PRUnichar*)text;
nsAutoString disableText;
nsAutoString navigatorText;
nsAutoString editorText;
nsAutoString mailText;
nsAutoString addressbookText;
nsXPIDLString text;
if ( turboBundle ) {
if ( brandBundle ) {
const PRUnichar* formatStrings[] = { tooltip.get() };
turboBundle->FormatStringFromName( NS_LITERAL_STRING( "Exit" ).get(), formatStrings, 1,
getter_Copies( text ) );
exitText = (const PRUnichar*)text;
}
turboBundle->GetStringFromName( NS_LITERAL_STRING( "Disable" ).get(),
getter_Copies( text ) );
disableText = (const PRUnichar*)text;
turboBundle->GetStringFromName( NS_LITERAL_STRING( "Navigator" ).get(),
getter_Copies( text ) );
navigatorText = (const PRUnichar*)text;
turboBundle->GetStringFromName( NS_LITERAL_STRING( "Editor" ).get(),
getter_Copies( text ) );
editorText = (const PRUnichar*)text;
}
if ( exitText.IsEmpty() ) {
// Fall back to this.
exitText = NS_LITERAL_STRING( "Exit" );
if (isMail) {
mailBundle->GetStringFromName( NS_LITERAL_STRING( "MailNews" ).get(),
getter_Copies( text ) );
mailText = (const PRUnichar*)text;
mailBundle->GetStringFromName( NS_LITERAL_STRING( "Addressbook" ).get(),
getter_Copies( text ) );
addressbookText = (const PRUnichar*)text;
}
if ( exitText.IsEmpty() )
exitText = NS_LITERAL_STRING( "&Exit Mozilla" );
if ( disableText.IsEmpty() )
disableText = NS_LITERAL_STRING( "&Disable Quick Launch" );
if ( navigatorText.IsEmpty() )
navigatorText = NS_LITERAL_STRING( "&Navigator" );
if ( editorText.IsEmpty() )
editorText = NS_LITERAL_STRING( "&Composer" );
if ( isMail ) {
if ( mailText.IsEmpty() )
mailText = NS_LITERAL_STRING( "&Mail && Newsgroups" );
if ( addressbookText.IsEmpty() )
addressbookText = NS_LITERAL_STRING( "&Address Book" );
}
// Create menu and add item.
mTrayIconMenu = ::CreatePopupMenu();
::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_QUIT, exitText.get() );
::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_NAVIGATOR, navigatorText.get() );
if ( ::GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) {
char* exitACPText = GetACPString( exitText );
if ( exitACPText ) {
::AppendMenu( mTrayIconMenu, MF_STRING, TURBO_QUIT, exitACPText );
delete [] exitACPText ;
}
AppendMenuItem( mTrayIconMenu, TURBO_NAVIGATOR, navigatorText );
if ( isMail )
AppendMenuItem( mTrayIconMenu, TURBO_MAIL, mailText );
AppendMenuItem( mTrayIconMenu, TURBO_EDITOR, editorText );
if ( isMail )
AppendMenuItem( mTrayIconMenu, TURBO_ADDRESSBOOK, addressbookText );
::AppendMenu( mTrayIconMenu, MF_SEPARATOR, NULL, NULL );
AppendMenuItem( mTrayIconMenu, TURBO_DISABLE, disableText );
AppendMenuItem( mTrayIconMenu, TURBO_EXIT, exitText );
}
else {
if (isMail)
::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_MAIL, mailText.get() );
::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_EDITOR, editorText.get() );
if (isMail)
::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_ADDRESSBOOK, addressbookText.get() );
::AppendMenuW( mTrayIconMenu, MF_SEPARATOR, NULL, NULL );
::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_DISABLE, disableText.get() );
::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_EXIT, exitText.get() );
}
}
// Add the tray icon.
::Shell_NotifyIcon( NIM_ADD, &mIconData );
}
@ -1838,26 +1976,38 @@ nsNativeAppSupportWin::SetIsServerMode( PRBool isServerMode ) {
NS_IMETHODIMP
nsNativeAppSupportWin::OnLastWindowClosing( nsIXULWindow *aWindow ) {
nsresult rv;
if (!mServerMode)
if ( !mServerMode )
return NS_OK;
// If the last window closed is our special "turbo" window made
// in StartServerMode(), don't do anything.
nsCOMPtr<nsIDocShell> docShell;
(void)aWindow->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(docShell));
if (domWindow == mInitialWindow) {
( void )aWindow->GetDocShell( getter_AddRefs( docShell ) );
nsCOMPtr<nsIDOMWindow> domWindow( do_GetInterface( docShell ) );
if ( domWindow == mInitialWindow ) {
mInitialWindow = nsnull;
return NS_OK;
}
nsresult rv;
if ( !mShownTurboDialog ) {
PRBool showDialog = PR_TRUE;
nsCOMPtr<nsIPref> prefService ( do_GetService( NS_PREF_CONTRACTID, &rv ) );
if ( NS_SUCCEEDED( rv ) )
prefService->GetBoolPref( "browser.turbo.showDialog", &showDialog );
nsCOMPtr<nsIDOMWindowInternal> domWindowInt ( do_GetInterface( docShell ) );
if ( showDialog && domWindowInt ) {
nsCOMPtr<nsIDOMWindow> newWindow;
mShownTurboDialog = PR_TRUE;
domWindowInt->OpenDialog( NS_LITERAL_STRING( "chrome://navigator/content/turboDialog.xul" ),
NS_LITERAL_STRING( "_blank" ),
NS_LITERAL_STRING( "chrome,modal,titlebar,centerscreen,dialog" ),
nsnull, getter_AddRefs( newWindow ) );
}
}
nsCOMPtr<nsIProfileInternal> profileMgr(do_GetService(NS_PROFILE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
rv = profileMgr->GetCurrentProfile(getter_Copies(mLastProfileName));
if (NS_FAILED(rv)) return rv;
rv = profileMgr->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST);
if (NS_FAILED(rv)) return rv;
@ -1870,13 +2020,13 @@ nsresult
nsNativeAppSupportWin::GetStartupURL(nsICmdLineService *args, nsCString& taskURL)
{
nsresult rv;
nsCOMPtr<nsICmdLineHandler> handler;
// see if there is a handler
rv = args->GetHandlerForParam(nsnull, getter_AddRefs(handler));
if (NS_FAILED(rv)) return rv;
// ok, from here on out, failures really are fatal
nsXPIDLCString url;
rv = handler->GetChromeUrlForTask(getter_Copies(url));

Просмотреть файл

@ -19,6 +19,7 @@ comm.jar:
content/navigator/metadata.xul (resources/content/metadata.xul)
content/navigator/metadata.js (resources/content/metadata.js)
content/navigator/personalToolbar.js (resources/content/personalToolbar.js)
content/navigator/turboDialog.xul (resources/content/turboDialog.xul)
en-US.jar:
locale/en-US/navigator/contents.rdf (resources/locale/en-US/contents.rdf)
locale/en-US/navigator/viewSource.dtd (resources/locale/en-US/viewSource.dtd)
@ -28,6 +29,8 @@ en-US.jar:
locale/en-US/navigator/metadata.dtd (resources/locale/en-US/metadata.dtd)
locale/en-US/navigator/metadata.properties (resources/locale/en-US/metadata.properties)
locale/en-US/navigator/pageInfo.properties (resources/locale/en-US/pageInfo.properties)
locale/en-US/navigator/turboDialog.dtd (resources/locale/en-US/turboDialog.dtd)
locale/en-US/navigator/turboMenu.properties (resources/locale/en-US/turboMenu.properties)
US.jar:
locale/US/navigator-region/contents.rdf (resources/locale/en-US/contents-region.rdf)

Просмотреть файл

@ -0,0 +1,94 @@
<?xml version="1.0"?>
<!-- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2
-
- The contents of this file are subject to the Netscape Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/NPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The Original Code is Mozilla Communicator client code.
-
- The Initial Developer of the Original Code is Netscape Communications
- Corporation. Portions created by Netscape are
- Copyright (C) 1998 Netscape Communications Corporation. All
- Rights Reserved.
-
- Contributor(s):
- Blake Ross <blake@netscape.com> (Original Author)
-->
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xml-stylesheet href="chrome://navigator/skin/turbo.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window [
<!ENTITY % turboDialogDTD SYSTEM "chrome://navigator/locale/turboDialog.dtd" >
%turboDialogDTD;
<!ENTITY % dialogOverlayDTD SYSTEM "chrome://global-platform/locale/platformDialogOverlay.dtd" >
%dialogOverlayDTD;
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
%brandDTD;
]>
<window id="turboDialog"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&exitWarningTitle.label;"
class="dialog"
orient="vertical"
onload="document.getElementById('okButton').focus();"
onunload="SetTurboPref();">
<script type="application/x-javascript">
<![CDATA[
function SetTurboPref() {
var showDialog = document.getElementById("showAgain").checked;
try {
var prefs = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefBranch);
if (prefs)
prefs.setBoolPref("browser.turbo.showDialog", !showDialog);
}
catch(e) {
}
}
]]>
</script>
<keyset id="dialogKeys"/>
<hbox flex="1">
<hbox align="start" valign="top">
<image class="message-icon"/>
</hbox>
<separator orient="vertical" class="thin"/>
<vbox flex="1">
<!-- text -->
<html flex="1">&exitWarningMsg.label;</html>
<vbox flex="1" style="max-width: 36em;"/>
<separator/>
<hbox>
<spring flex="45%"/>
<image id="turboTrayImage"/>
<spring flex="55%"/>
</hbox>
<separator class="thin"/>
<separator class="thin"/>
<!-- checkbox -->
<hbox align="start">
<checkbox id="showAgain" label="&exitWarningCheckbox.label;"
accesskey="&exitWarningCheckbox.accesskey;" checked="true"/>
</hbox>
</vbox>
</hbox>
<separator class="thin"/>
<separator class="thin"/>
<hbox>
<spring flex="1"/>
<button id="okButton" label="&okButton.label;" oncommand="window.close();" default="true"/>
<spring flex="1"/>
</hbox>
</window>

Просмотреть файл

@ -0,0 +1,4 @@
<!ENTITY exitWarningMsg.label "Quick Launch is active, so &brandShortName; remains in memory and can be started again quickly. To completely exit, right click on the &brandShortName; icon in the bottom right of the taskbar and select Exit.">
<!ENTITY exitWarningTitle.label "Quick Launch">
<!ENTITY exitWarningCheckbox.label "Don't show me this message again">
<!ENTITY exitWarningCheckbox.accesskey "D">

Просмотреть файл

@ -0,0 +1,6 @@
Exit=&Exit %S
Disable=Disable Quick Launch
DisableDlgMsg=Quick Launch is now disabled. To enable it again, open the Edit menu and choose Preferences. Choose the "Advanced" category and check "Enable Quick Launch."
DisableDlgTitle=%S Quick Launch
Navigator=&Navigator
Editor=&Composer

Просмотреть файл

@ -33,17 +33,14 @@
<script type="application/x-javascript">
<![CDATA[
var panel = "chrome://communicator/content/pref/pref-advanced.xul";
var _elementIDs = ["advancedJavaAllow", "javascriptEnabled", "advancedMailFTP", "advancedMailFTPAddress",
"enableTurbo"];
var _elementIDs = ["advancedJavaAllow", "javascriptEnabled", "advancedMailFTP", "advancedMailFTPAddress"];
function Startup()
{
function Startup() {
ftpCheck();
turboCheck();
turboCheck();
}
function ftpCheck()
{
function ftpCheck() {
var checked = document.getElementById("advancedMailFTP").checked;
var field = document.getElementById("advancedMailFTPAddress");
field.disabled = !checked;
@ -51,27 +48,27 @@
field.focus();
}
/*
* Name: turboCheck()
*
* Arguments: none
*
* Description: This function is called when the root advanced prefs panel
* is loaded. The turbo mode setting is not exactly a preference -- setting
* the checkbox should (on leaving the prefs with an "Ok") result in a call
* to the backend to do the necessary win32 registry twiddling needed for
* turbo mode to go into affect. Clearing it should undo this work. We need
* to call the backend to determine if turbo mode is enabled (since we are
* required to check for it in a non-trivial way) and then explicitly set the
* checkbox here based on what we find. Finally, we have to hide the checkbox
* (and the group box that frames it) if we are not executing on a Win32
* platform.
*
* Return Value: void
*
* Original Code: syd@netscape.com 6/8/2001
*
*/
/*
* Name: turboCheck()
*
* Arguments: none
*
* Description: This function is called when the root advanced prefs panel
* is loaded. The turbo mode setting is not exactly a preference -- setting
* the checkbox should (on leaving the prefs with an "Ok") result in a call
* to the backend to do the necessary win32 registry twiddling needed for
* turbo mode to go into effect. Clearing it should undo this work. We need
* to call the backend to determine if turbo mode is enabled (since we are
* required to check for it in a non-trivial way) and then explicitly set the
* checkbox here based on what we find. Finally, we have to hide the checkbox
* (and the group box that frames it) if we are not executing on a Win32
* platform.
*
* Return Value: void
*
* Original Code: syd@netscape.com 6/8/2001
*
*/
function turboCheck()
{
@ -80,55 +77,53 @@
frame.setAttribute("hidden", "true");
return;
}
var winhooksService = Components.classes["@mozilla.org/winhooks;1"].getService(Components.interfaces.nsIWindowsHooks);
if (winhooksService)
document.getElementById("enableTurbo").checked = winhooksService.isStartupTurboEnabled();
parent.hPrefWindow.registerOKCallbackFunc( saveTurboSetting );
}
/*
* Name: saveTurboSetting()
*
* Arguments: none
*
* Description: This function is called when the user hits the OK button in
* the preferences panel. The function determines what the turbo "preference"
* setting is and performs the appropriate action to enable or disable turbo mode.
*
* Return Value: void
*
* Original Code: syd@netscape.com 6/9/2001
*
*/
/*
* Name: saveTurboSetting()
*
* Arguments: none
*
* Description: This function is called when the user hits the OK button in
* the preferences panel. The function determines what the turbo "preference"
* setting is and performs the appropriate action to enable or disable turbo mode.
*
* Return Value: void
*
* Original Code: syd@netscape.com 6/9/2001
*
*/
function saveTurboSetting()
{
if ( navigator.platform != "Win32" )
return;
function saveTurboSetting() {
if (navigator.platform != "Win32")
return;
var acheckbox = document.getElementById("enableTurbo");
try {
hooks = Components.classes["@mozilla.org/winhooks;1"];
if ( hooks )
hooks = hooks.getService(Components.interfaces.nsIWindowsHooks);
if ( hooks ) {
var isEnabled = acheckbox.checked;
if ( isEnabled == true )
hooks.startupTurboEnable();
else
hooks.startupTurboDisable();
var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService );
var nativeAppSupport = null;
try {
nativeAppSupport = appShell.nativeAppSupport;
}
catch ( ex ) {
}
if (nativeAppSupport)
nativeAppSupport.isServerMode = isEnabled;
}
} catch( ex ) {
}
}
var turboCheckbox = document.getElementById("enableTurbo");
var winhooksService = Components.classes["@mozilla.org/winhooks;1"].getService(Components.interfaces.nsIWindowsHooks);
if (winhooksService) {
var isEnabled = turboCheckbox.checked;
if (isEnabled)
winhooksService.startupTurboEnable();
else
winhooksService.startupTurboDisable();
var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService );
var nativeAppSupport = null;
try {
nativeAppSupport = appShell.nativeAppSupport;
}
catch ( ex ) {
}
if (nativeAppSupport)
nativeAppSupport.isServerMode = isEnabled;
}
}
]]>
</script>
@ -166,8 +161,7 @@
<groupbox orient="vertical" id="perfSettings">
<caption id="perfLabel" label="&perfTitle.label;"/>
<vbox id="perfBox" align="start">
<checkbox id="enableTurbo" label="&enableTurbo.label;" accesskey="&enableTurboCheck.accesskey;"
pref="true" preftype="bool" prefstring="browser.turbo.enabled" prefattribute="checked"/>
<checkbox id="enableTurbo" label="&enableTurbo.label;" accesskey="&enableTurboCheck.accesskey;"/>
</vbox>
</groupbox>

Просмотреть файл

@ -149,14 +149,8 @@
* Windows startup folder at system initialization.
*
*
* needsProfileUI - Boolean attribute used when running in "server mode."
* If the "server mode" caused profile dialogs to be
* suppressed, this should be set to true. When the server
* starts a real session, it will call on the profile mgr
* to do what it needed to do when this attribute is true.
*/
interface nsIDOMWindow;
interface nsIXULWindow;
[scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)]
@ -172,8 +166,8 @@ interface nsINativeAppSupport : nsISupports {
// Server mode.
attribute boolean isServerMode;
attribute boolean shouldShowUI;
void startServerMode();
attribute boolean needsProfileUI;
void onLastWindowClosing(in nsIXULWindow aWindow);
};

Просмотреть файл

@ -150,25 +150,25 @@ interface nsIWindowsHooks : nsISupports {
// aParent - parent window for any dialogs that
// will appear
void checkSettings( in nsIDOMWindowInternal aParent );
// turbo mode
// ----------
// the following interfaces support turbo mode preferences.
//
// IsStartupTurboEnabled() returns true if the shortcut for
// turbo mode is in the Windows startup folder, else it
// returns false. The function is called in the onload
// handler of the prefs panel that contains the "use turbo
// mode" checkbox to determine if the checkbox should be set
// (shortcut is present) or not (shortcut is missing). The
// installer is used to initialize state (e.g., it will put
// the shortcut in the startup folder initially).
boolean isStartupTurboEnabled();
// the following function is called by the preferences panel
// code if the user checks the "use turbo mode" checkbox.
void startupTurboEnable();
// the following function is called by the preferences panel
// code if the user unchecks the "use turbo mode" checkbox.
void startupTurboDisable();
/**
* Returns true if the "(appname) QuickLaunch" value is in the
* HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run
* key (indicating that the app will preload when Windows starts).
*/
boolean isStartupTurboEnabled();
/**
* Adds the "(appname) QuickLaunch" value to the key mentioned above,
* with data "(path\to\app.exe) -turbo", if not done already.
*/
void startupTurboEnable();
/**
* Removes the "(appname) QuickLaunch" value from the key mentioned above,
* if not done already.
*/
void startupTurboDisable();
};
%{C++

Просмотреть файл

@ -36,7 +36,8 @@
#include "nsXPIDLString.h"
#include "nsString.h"
#include "nsMemory.h"
#include "nsIHttpProtocolHandler.h"
#include "nsNetCID.h"
// The order of these headers is important on Win2K because CreateDirectory
// is |#undef|-ed in nsFileSpec.h, so we need to pull in windows.h for the
// first time after nsFileSpec.h.
@ -53,7 +54,7 @@ static ProtocolRegistryEntry
ftp( "ftp" ),
chrome( "chrome" ),
gopher( "gopher" );
static NS_DEFINE_CID(kHttpHandlerCID, NS_HTTPPROTOCOLHANDLER_CID);
const char *jpgExts[] = { ".jpg", ".jpeg", 0 };
const char *gifExts[] = { ".gif", 0 };
const char *pngExts[] = { ".png", 0 };
@ -75,11 +76,6 @@ static EditableFileTypeRegistryEntry
// Use standard implementation of nsISupports stuff.
NS_IMPL_ISUPPORTS1( nsWindowsHooksSettings, nsIWindowsHooksSettings );
static PRBool IsWindowsNT(void);
static PRBool GetStartupFolder( char *buf );
static HRESULT CreateALink(LPCSTR lpszPathObj, LPCSTR lpszPathLink, LPCSTR lpszDesc, LPCSTR lpszWorkingPath, LPCSTR lpszArgs, LPCSTR lpszIconFullPath, int iIcon);
nsWindowsHooksSettings::nsWindowsHooksSettings() {
NS_INIT_ISUPPORTS();
}
@ -528,52 +524,21 @@ nsWindowsHooks::SetRegistry() {
NS_IMETHODIMP nsWindowsHooks::IsStartupTurboEnabled(PRBool *_retval)
{
DWORD dwErr;
BOOL bNameExists = FALSE;
HANDLE hnd;
char szBuf[MAX_BUF];
char szName[MAX_BUF];
*_retval = PR_FALSE;
// read the windows registry to get the location of the startup folder
bNameExists = GetStartupFolder( szName );
// then see if the file mozilla.exe.lnk exists
if ( bNameExists ) {
dwErr = GetModuleFileName( NULL, szBuf, sizeof( szBuf ) );
if ( dwErr != 0 ) {
nsAutoString baseName;
baseName.AssignWithConversion( szBuf );
PRInt32 slashOffset = baseName.RFindChar(PRUnichar('\\'));
if ( slashOffset >= 0 ) {
baseName.Cut(0, slashOffset + 1 );
}
strcpy( mShortcutName, szName ); // remember for creation
char *baseNameC = baseName.ToNewCString();
strcpy( mShortcutBase, baseNameC ); // remember for creation
baseName.AssignWithConversion( szBuf );
baseName.Cut(slashOffset, -1);
char *progNameC = baseName.ToNewCString();
strcpy( mShortcutProg, progNameC ); // remember for creation
strcat( szName, "\\" );
strcat( szName, baseNameC );
strcat( szName, ".lnk" );
strcpy( mShortcutPath, szName ); // remember the path for later deletion
// open the file, if successful, it exists
hnd = CreateFile( szName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if ( hnd != INVALID_HANDLE_VALUE ) {
*_retval = PR_TRUE;
CloseHandle( hnd );
}
nsMemory::Free( baseNameC );
nsMemory::Free( progNameC );
}
*_retval = PR_FALSE;
HKEY key;
LONG result = ::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_QUERY_VALUE, &key );
if ( result == ERROR_SUCCESS ) {
nsresult rv;
nsCOMPtr<nsIHttpProtocolHandler> http ( do_GetService( kHttpHandlerCID, &rv ) );
if ( NS_FAILED( rv ) ) return rv;
nsXPIDLCString appName;
http->GetAppName( getter_Copies( appName ) );
nsCString fullValue; fullValue.Assign( appName );
fullValue.Append( " Quick Launch" );
result = ::RegQueryValueEx( key, fullValue, NULL, NULL, NULL, NULL );
::RegCloseKey( key );
if ( result == ERROR_SUCCESS )
*_retval = PR_TRUE;
}
return NS_OK;
}
@ -581,142 +546,57 @@ NS_IMETHODIMP nsWindowsHooks::IsStartupTurboEnabled(PRBool *_retval)
NS_IMETHODIMP nsWindowsHooks::StartupTurboEnable()
{
PRBool startupFound;
char buf[ MAX_BUF ];
DWORD dwErr, bytesWritten;
HANDLE hnd;
IsStartupTurboEnabled(&startupFound);
IsStartupTurboEnabled( &startupFound );
if ( startupFound == PR_TRUE )
return NS_OK; // already enabled, no need to do this
// create the file
dwErr = GetModuleFileName( NULL, buf, sizeof( buf ) );
if ( dwErr != 0 )
CreateALink( buf, mShortcutName, mShortcutBase, mShortcutProg, "-turbo", NULL, 0 );
HKEY hKey;
LONG res = ::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_SET_VALUE, &hKey );
if ( res != ERROR_SUCCESS )
return NS_OK;
char fileName[_MAX_PATH];
int rv = ::GetModuleFileName( NULL, fileName, sizeof fileName );
if ( rv ) {
strcat( fileName, " -turbo" );
nsresult rv;
nsCOMPtr<nsIHttpProtocolHandler> http ( do_GetService( kHttpHandlerCID, &rv ) );
if ( NS_FAILED( rv ) ) return rv;
nsXPIDLCString appName;
http->GetAppName( getter_Copies( appName ) );
nsCString fullValue; fullValue.Assign( appName );
fullValue.Append( " Quick Launch" );
::RegSetValueEx( hKey, fullValue, 0, REG_SZ, ( LPBYTE )fileName, strlen( fileName ) );
}
::RegCloseKey( hKey );
return NS_OK;
}
NS_IMETHODIMP nsWindowsHooks::StartupTurboDisable()
{
PRBool startupFound;
IsStartupTurboEnabled( &startupFound );
if ( !startupFound )
return NS_OK; // already disabled, no need to do this
IsStartupTurboEnabled(&startupFound);
if ( startupFound == PR_FALSE )
return NS_OK; // already disabled
DeleteFile( mShortcutPath );
HKEY hKey;
LONG res = ::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_SET_VALUE, &hKey );
if ( res != ERROR_SUCCESS )
return NS_OK;
nsresult rv;
nsCOMPtr<nsIHttpProtocolHandler> http ( do_GetService( kHttpHandlerCID, &rv ) );
if ( NS_FAILED( rv ) ) return rv;
nsXPIDLCString appName;
http->GetAppName( getter_Copies( appName ) );
nsCString fullValue; fullValue.Assign( appName );
fullValue.Append( " Quick Launch" );
res = ::RegDeleteValue( hKey, fullValue );
::RegCloseKey( hKey );
return NS_OK;
}
static PRBool
IsWindowsNT( void )
{
PRBool retval = PR_FALSE;
OSVERSIONINFO osVersionInfo;
osVersionInfo.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
if (GetVersionEx(&osVersionInfo)) {
retval = (osVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT ? PR_TRUE : PR_FALSE);
}
return retval;
}
static PRBool
GetStartupFolder( char *buf )
{
HKEY hkResult;
HKEY hkRootKey;
DWORD dwErr;
DWORD dwSize;
char szKey[MAX_BUF];
char szBuf[MAX_BUF];
char szName[MAX_BUF];
BOOL bNameExists = FALSE;
// read the windows registry to get the location of the startup folder
if ( IsWindowsNT() == PR_TRUE ) {
hkRootKey = HKEY_LOCAL_MACHINE;
strcpy( szKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders" );
strcpy( szName, "Common Startup" );
} else {
hkRootKey = HKEY_CURRENT_USER;
strcpy( szKey,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders" );
strcpy( szName, "Startup" );
}
if((dwErr = RegOpenKeyEx(hkRootKey, szKey, 0, KEY_READ, &hkResult)) == ERROR_SUCCESS) {
dwSize = sizeof(szBuf);
dwErr = RegQueryValueEx(hkResult, (const char *) szName, NULL, NULL, (LPBYTE) szBuf, &dwSize);
if((*szBuf != '\0') && (dwErr == ERROR_SUCCESS)) {
strcpy( buf, szBuf );
bNameExists = TRUE;
}
RegCloseKey(hkResult);
}
return bNameExists;
}
#if (_MSC_VER == 1100)
#define INITGUID
#include "objbase.h"
DEFINE_OLEGUID(IID_IPersistFile, 0x0000010BL, 0, 0);
#endif
static HRESULT CreateALink(LPCSTR lpszPathObj, LPCSTR lpszPathLink, LPCSTR lpszDesc, LPCSTR lpszWorkingPath, LPCSTR lpszArgs, LPCSTR lpszIconFullPath, int iIcon)
{
HRESULT hres;
IShellLink *psl;
char lpszFullPath[MAX_BUF];
lstrcpy(lpszFullPath, lpszPathLink);
lstrcat(lpszFullPath, "\\");
lstrcat(lpszFullPath, lpszDesc);
lstrcat(lpszFullPath, ".lnk");
CreateDirectory(lpszPathLink, NULL);
CoInitialize(NULL);
// Get a pointer to the IShellLink interface.
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl);
if(SUCCEEDED(hres))
{
IPersistFile* ppf;
// Set the path to the shortcut target, and add the
// description.
psl->SetPath(lpszPathObj);
psl->SetDescription(lpszDesc);
if(lpszWorkingPath)
psl->SetWorkingDirectory(lpszWorkingPath);
if(lpszArgs)
psl->SetArguments(lpszArgs);
if(lpszIconFullPath)
psl->SetIconLocation(lpszIconFullPath, iIcon);
// Query IShellLink for the IPersistFile interface for saving the
// shortcut in persistent storage.
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID FAR *)&ppf);
if(SUCCEEDED(hres))
{
WORD wsz[MAX_BUF];
// Ensure that the string is ANSI.
MultiByteToWideChar(CP_ACP, 0, lpszFullPath, -1, (wchar_t *)wsz, MAX_BUF);
// Save the link by calling IPersistFile::Save.
hres = ppf->Save((wchar_t *)wsz, TRUE);
ppf->Release();
}
psl->Release();
}
CoUninitialize();
return hres;
}