From 9590786254430ddeec21c3dc3bfccce636f38ae2 Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Tue, 8 Feb 2000 01:11:13 +0000 Subject: [PATCH] more changes to get everyone using my arbitrary command line handling. removing "calendar" from the appearance pref panel, there is no calendar in 5.0. r=mscott git-svn-id: svn://10.0.0.236/trunk@60015 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/nsEditorRegistration.cpp | 4 +- mozilla/editor/base/nsHTMLEditor.cpp | 1 + mozilla/editor/base/nsHTMLEditor.h | 4 +- mozilla/editor/base/nsHTMLEditorLog.cpp | 8 + mozilla/editor/base/nsHTMLEditorLog.h | 7 +- .../libeditor/build/nsEditorRegistration.cpp | 4 +- .../editor/libeditor/html/nsHTMLEditor.cpp | 1 + mozilla/editor/libeditor/html/nsHTMLEditor.h | 4 +- .../editor/libeditor/html/nsHTMLEditorLog.cpp | 8 + .../editor/libeditor/html/nsHTMLEditorLog.h | 7 +- .../mailnews/addrbook/src/nsAddressBook.cpp | 2 +- mozilla/mailnews/base/src/nsMessenger.cpp | 2 +- .../mailnews/base/src/nsMsgAccountManager.cpp | 2 +- .../compose/build/nsMsgCompFactory.cpp | 4 +- .../compose/src/nsMsgComposeService.cpp | 8 +- .../compose/src/nsMsgComposeService.h | 9 +- mozilla/mailnews/news/src/nsNntpService.cpp | 2 +- .../appshell/public/nsICmdLineHandler.idl | 23 +- mozilla/xpfe/bootstrap/nsAppRunner.cpp | 272 +++++------------- .../xpfe/browser/src/nsBrowserInstance.cpp | 8 +- mozilla/xpfe/browser/src/nsBrowserInstance.h | 5 + .../resources/content/pref-appearance.xul | 7 - .../locale/en-US/pref-appearance.dtd | 2 - .../startup/public/nsICmdLineHandler.idl | 23 +- 24 files changed, 181 insertions(+), 236 deletions(-) diff --git a/mozilla/editor/base/nsEditorRegistration.cpp b/mozilla/editor/base/nsEditorRegistration.cpp index 66d27717057..d78553fb492 100644 --- a/mozilla/editor/base/nsEditorRegistration.cpp +++ b/mozilla/editor/base/nsEditorRegistration.cpp @@ -52,7 +52,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLEditor) static nsModuleComponentInfo components[] = { #ifdef ENABLE_EDITOR_API_LOG { "HTML Editor", NS_HTMLEDITOR_CID, - "component://netscape/editor/htmleditor", nsHTMLEditorLogConstructor, }, + "component://netscape/editor/htmleditor", nsHTMLEditorLogConstructor, + nsHTMLEditorLog::RegisterProc, + nsHTMLEditorLog::UnregisterProc, }, #else { "HTML Editor", NS_HTMLEDITOR_CID, "component://netscape/editor/htmleditor", nsHTMLEditorConstructor, }, diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index 92b98e4a682..038c2749e67 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -7375,3 +7375,4 @@ nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement, return res; } + diff --git a/mozilla/editor/base/nsHTMLEditor.h b/mozilla/editor/base/nsHTMLEditor.h index dd6b98b4d18..b6fefbb29aa 100644 --- a/mozilla/editor/base/nsHTMLEditor.h +++ b/mozilla/editor/base/nsHTMLEditor.h @@ -39,7 +39,7 @@ #include "TypeInState.h" #include "nsEditRules.h" - + class nsIDOMKeyEvent; /** @@ -52,6 +52,7 @@ class nsHTMLEditor : public nsEditor, public nsITableEditor, public nsIEditorStyleSheets, public nsICSSLoaderObserver + { typedef enum {eNoOp, eReplaceParent=1, eInsertParent=2} BlockTransformationType; @@ -78,6 +79,7 @@ public: // another class. Only the base class should use NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS_INHERITED + nsHTMLEditor(); virtual ~nsHTMLEditor(); diff --git a/mozilla/editor/base/nsHTMLEditorLog.cpp b/mozilla/editor/base/nsHTMLEditorLog.cpp index 86b624a5b53..031438fbb47 100644 --- a/mozilla/editor/base/nsHTMLEditorLog.cpp +++ b/mozilla/editor/base/nsHTMLEditorLog.cpp @@ -33,6 +33,7 @@ #include "nsIDOMRange.h" #include "nsHTMLEditorLog.h" #include "nsCOMPtr.h" +#include "nsICmdLineHandler.h" #include "nsEditorTxnLog.h" @@ -67,6 +68,11 @@ nsHTMLEditorLog::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } + if (aIID.Equals(NS_GET_IID(nsICmdLineHandler))) { + *aInstancePtr = (void*)(nsICmdLineHandler*)this; + NS_ADDREF_THIS(); + return NS_OK; + } return nsHTMLEditor::QueryInterface(aIID, aInstancePtr); } @@ -1239,3 +1245,5 @@ function EditorSetSelectionFromOffsets(selRanges) } #endif + +CMDLINEHANDLER_IMPL(nsHTMLEditorLog,"-edit","general.startup.editor","chrome://editor/content/","Start with editor","component://netscape/editor/htmleditor","Editor Cmd Line Handler", PR_TRUE,"about:blank") diff --git a/mozilla/editor/base/nsHTMLEditorLog.h b/mozilla/editor/base/nsHTMLEditorLog.h index 4d12dade703..260bce6211c 100644 --- a/mozilla/editor/base/nsHTMLEditorLog.h +++ b/mozilla/editor/base/nsHTMLEditorLog.h @@ -27,6 +27,7 @@ #include "nsIEditorLogging.h" #include "nsIFileSpec.h" #include "nsCOMPtr.h" +#include "nsICmdLineHandler.h" class nsEditorTxnLog; @@ -34,7 +35,8 @@ class nsEditorTxnLog; * */ class nsHTMLEditorLog : public nsHTMLEditor, - public nsIEditorLogging + public nsIEditorLogging, + public nsICmdLineHandler { private: @@ -48,6 +50,9 @@ public: // Interfaces for AddRef, Release, and QueryInterface. NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSICMDLINEHANDLER + CMDLINEHANDLER_REGISTERPROC_DECLS + nsHTMLEditorLog(); virtual ~nsHTMLEditorLog(); diff --git a/mozilla/editor/libeditor/build/nsEditorRegistration.cpp b/mozilla/editor/libeditor/build/nsEditorRegistration.cpp index 66d27717057..d78553fb492 100644 --- a/mozilla/editor/libeditor/build/nsEditorRegistration.cpp +++ b/mozilla/editor/libeditor/build/nsEditorRegistration.cpp @@ -52,7 +52,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLEditor) static nsModuleComponentInfo components[] = { #ifdef ENABLE_EDITOR_API_LOG { "HTML Editor", NS_HTMLEDITOR_CID, - "component://netscape/editor/htmleditor", nsHTMLEditorLogConstructor, }, + "component://netscape/editor/htmleditor", nsHTMLEditorLogConstructor, + nsHTMLEditorLog::RegisterProc, + nsHTMLEditorLog::UnregisterProc, }, #else { "HTML Editor", NS_HTMLEDITOR_CID, "component://netscape/editor/htmleditor", nsHTMLEditorConstructor, }, diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 92b98e4a682..038c2749e67 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -7375,3 +7375,4 @@ nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement, return res; } + diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.h b/mozilla/editor/libeditor/html/nsHTMLEditor.h index dd6b98b4d18..b6fefbb29aa 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.h +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.h @@ -39,7 +39,7 @@ #include "TypeInState.h" #include "nsEditRules.h" - + class nsIDOMKeyEvent; /** @@ -52,6 +52,7 @@ class nsHTMLEditor : public nsEditor, public nsITableEditor, public nsIEditorStyleSheets, public nsICSSLoaderObserver + { typedef enum {eNoOp, eReplaceParent=1, eInsertParent=2} BlockTransformationType; @@ -78,6 +79,7 @@ public: // another class. Only the base class should use NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS_INHERITED + nsHTMLEditor(); virtual ~nsHTMLEditor(); diff --git a/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp b/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp index 86b624a5b53..031438fbb47 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp @@ -33,6 +33,7 @@ #include "nsIDOMRange.h" #include "nsHTMLEditorLog.h" #include "nsCOMPtr.h" +#include "nsICmdLineHandler.h" #include "nsEditorTxnLog.h" @@ -67,6 +68,11 @@ nsHTMLEditorLog::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } + if (aIID.Equals(NS_GET_IID(nsICmdLineHandler))) { + *aInstancePtr = (void*)(nsICmdLineHandler*)this; + NS_ADDREF_THIS(); + return NS_OK; + } return nsHTMLEditor::QueryInterface(aIID, aInstancePtr); } @@ -1239,3 +1245,5 @@ function EditorSetSelectionFromOffsets(selRanges) } #endif + +CMDLINEHANDLER_IMPL(nsHTMLEditorLog,"-edit","general.startup.editor","chrome://editor/content/","Start with editor","component://netscape/editor/htmleditor","Editor Cmd Line Handler", PR_TRUE,"about:blank") diff --git a/mozilla/editor/libeditor/html/nsHTMLEditorLog.h b/mozilla/editor/libeditor/html/nsHTMLEditorLog.h index 4d12dade703..260bce6211c 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditorLog.h +++ b/mozilla/editor/libeditor/html/nsHTMLEditorLog.h @@ -27,6 +27,7 @@ #include "nsIEditorLogging.h" #include "nsIFileSpec.h" #include "nsCOMPtr.h" +#include "nsICmdLineHandler.h" class nsEditorTxnLog; @@ -34,7 +35,8 @@ class nsEditorTxnLog; * */ class nsHTMLEditorLog : public nsHTMLEditor, - public nsIEditorLogging + public nsIEditorLogging, + public nsICmdLineHandler { private: @@ -48,6 +50,9 @@ public: // Interfaces for AddRef, Release, and QueryInterface. NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSICMDLINEHANDLER + CMDLINEHANDLER_REGISTERPROC_DECLS + nsHTMLEditorLog(); virtual ~nsHTMLEditorLog(); diff --git a/mozilla/mailnews/addrbook/src/nsAddressBook.cpp b/mozilla/mailnews/addrbook/src/nsAddressBook.cpp index 97c8f10be15..30562d91751 100644 --- a/mozilla/mailnews/addrbook/src/nsAddressBook.cpp +++ b/mozilla/mailnews/addrbook/src/nsAddressBook.cpp @@ -1270,4 +1270,4 @@ NS_IMETHODIMP nsAddressBook::ImportAddressBook() return rv; } -CMDLINEHANDLER_IMPL(nsAddressBook,"-addressbook","general.startup.addressbook","chrome://addressbook/content/","Start with the addressbook.",NS_ADDRESSBOOK_PROGID,"Addressbook Cmd Line Handler") +CMDLINEHANDLER_IMPL(nsAddressBook,"-addressbook","general.startup.addressbook","chrome://addressbook/content/","Start with the addressbook.",NS_ADDRESSBOOK_PROGID,"Addressbook Cmd Line Handler",PR_FALSE,"") diff --git a/mozilla/mailnews/base/src/nsMessenger.cpp b/mozilla/mailnews/base/src/nsMessenger.cpp index 07768099625..8a16c0633f9 100644 --- a/mozilla/mailnews/base/src/nsMessenger.cpp +++ b/mozilla/mailnews/base/src/nsMessenger.cpp @@ -1374,4 +1374,4 @@ nsSaveAsListener::OnDataAvailable(nsIChannel* aChannel, return rv; } -CMDLINEHANDLER_IMPL(nsMessenger,"-mail","general.startup.mail","chrome://messenger/content/","Start with mail.",NS_MESSENGER_PROGID,"Mail Cmd Line Handler") +CMDLINEHANDLER_IMPL(nsMessenger,"-mail","general.startup.mail","chrome://messenger/content/","Start with mail.",NS_MESSENGER_PROGID,"Mail Cmd Line Handler",PR_FALSE,"") diff --git a/mozilla/mailnews/base/src/nsMsgAccountManager.cpp b/mozilla/mailnews/base/src/nsMsgAccountManager.cpp index 6a0dc566706..c9297b3fd68 100644 --- a/mozilla/mailnews/base/src/nsMsgAccountManager.cpp +++ b/mozilla/mailnews/base/src/nsMsgAccountManager.cpp @@ -415,7 +415,7 @@ nsMsgAccountManager::createKeyedServer(const char* key, serverProgID += type; // finally, create the server -#ifdef DEBUG_sspitzer +#ifdef DEBUG_sspitzer_ printf("serverProgID = %s\n", (const char *)serverProgID); #endif rv = nsComponentManager::CreateInstance(serverProgID, diff --git a/mozilla/mailnews/compose/build/nsMsgCompFactory.cpp b/mozilla/mailnews/compose/build/nsMsgCompFactory.cpp index 20c6c220b76..3278b2f06f7 100644 --- a/mozilla/mailnews/compose/build/nsMsgCompFactory.cpp +++ b/mozilla/mailnews/compose/build/nsMsgCompFactory.cpp @@ -82,7 +82,9 @@ static nsModuleComponentInfo components[] = { "Msg Compose Service", NS_MSGCOMPOSESERVICE_CID, NS_MSGCOMPOSESERVICE_PROGID, - nsMsgComposeServiceConstructor }, + nsMsgComposeServiceConstructor, + nsMsgComposeService::RegisterProc, + nsMsgComposeService::UnregisterProc }, { "mailto content handler", NS_MSGCOMPOSESERVICE_CID, NS_CONTENT_HANDLER_PROGID_PREFIX"x-application-mailto", diff --git a/mozilla/mailnews/compose/src/nsMsgComposeService.cpp b/mozilla/mailnews/compose/src/nsMsgComposeService.cpp index dedfee8740b..8488f98a7eb 100644 --- a/mozilla/mailnews/compose/src/nsMsgComposeService.cpp +++ b/mozilla/mailnews/compose/src/nsMsgComposeService.cpp @@ -49,6 +49,8 @@ nsMsgComposeService::nsMsgComposeService() rv = NS_NewISupportsArray(getter_AddRefs(m_msgQueue)); } +/* the following macro actually implement addref, release and query interface for our component. */ +NS_IMPL_ISUPPORTS3(nsMsgComposeService, nsIMsgComposeService, nsIContentHandler,nsICmdLineHandler); nsMsgComposeService::~nsMsgComposeService() { @@ -86,9 +88,6 @@ static nsresult openWindow( const PRUnichar *chrome, const PRUnichar *args ) { return rv; } -/* the following macro actually implement addref, release and query interface for our component. */ -NS_IMPL_ISUPPORTS2(nsMsgComposeService, nsIMsgComposeService, nsIContentHandler); - nsresult nsMsgComposeService::OpenComposeWindow(const PRUnichar *msgComposeWindowURL, const PRUnichar *originalMsgURI, MSG_ComposeType type, MSG_ComposeFormat format, nsIMsgIdentity * identity) { @@ -370,3 +369,6 @@ NS_IMETHODIMP nsMsgComposeService::HandleContent(const char * aContentType, cons return rv; } + +CMDLINEHANDLER_IMPL(nsMsgComposeService,"-compose","general.startup.messengercompose","chrome://messengercompose/content/","Start with messenger compose",NS_MSGCOMPOSESERVICE_PROGID,"Messenger Compose Cmd Line Handler", PR_TRUE, "about:blank") + diff --git a/mozilla/mailnews/compose/src/nsMsgComposeService.h b/mozilla/mailnews/compose/src/nsMsgComposeService.h index cfa6ce9868e..00bcb18c685 100644 --- a/mozilla/mailnews/compose/src/nsMsgComposeService.h +++ b/mozilla/mailnews/compose/src/nsMsgComposeService.h @@ -24,18 +24,21 @@ #include "nsISupportsArray.h" #include "nsIContentHandler.h" #include "nsCOMPtr.h" +#include "nsICmdLineHandler.h" -class nsMsgComposeService : public nsIMsgComposeService, public nsIContentHandler +class nsMsgComposeService : public nsIMsgComposeService, public nsIContentHandler, public nsICmdLineHandler { public: nsMsgComposeService(); virtual ~nsMsgComposeService(); - /* this macro defines QueryInterface, AddRef and Release for this class */ NS_DECL_ISUPPORTS NS_DECL_NSIMSGCOMPOSESERVICE NS_DECL_NSICONTENTHANDLER - + + NS_DECL_NSICMDLINEHANDLER + CMDLINEHANDLER_REGISTERPROC_DECLS + private: nsCOMPtr m_msgQueue; }; diff --git a/mozilla/mailnews/news/src/nsNntpService.cpp b/mozilla/mailnews/news/src/nsNntpService.cpp index 6dc1cbda506..f0775f71cdd 100644 --- a/mozilla/mailnews/news/src/nsNntpService.cpp +++ b/mozilla/mailnews/news/src/nsNntpService.cpp @@ -1147,4 +1147,4 @@ nsNntpService::GetDefaultCopiesAndFoldersPrefsToServer(PRBool *aDefaultCopiesAnd return NS_OK; } -CMDLINEHANDLER_IMPL(nsNntpService,"-news","general.startup.news","chrome://messenger/content/","Start with news window.",NS_NNTPSERVICE_PROGID,"News Cmd Line Handler") +CMDLINEHANDLER_IMPL(nsNntpService,"-news","general.startup.news","chrome://messenger/content/","Start with news window.",NS_NNTPSERVICE_PROGID,"News Cmd Line Handler", PR_FALSE,"") diff --git a/mozilla/xpfe/appshell/public/nsICmdLineHandler.idl b/mozilla/xpfe/appshell/public/nsICmdLineHandler.idl index 7d78b766203..d909acdbe21 100644 --- a/mozilla/xpfe/appshell/public/nsICmdLineHandler.idl +++ b/mozilla/xpfe/appshell/public/nsICmdLineHandler.idl @@ -33,12 +33,13 @@ #include "nsICategoryManager.h" #include "nsIFileSpec.h" #include "nsXPIDLString.h" +#include "nsIServiceManager.h" #define CMDLINEHANDLER_REGISTERPROC_DECLS \ static NS_METHOD RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType); \ static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation); -#define CMDLINEHANDLER_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_chrome_url,macro_help_text, macro_progid, macro_pretty_name) \ +#define CMDLINEHANDLER_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_chrome_url,macro_help_text, macro_progid, macro_pretty_name, macro_handles_args, macro_default_args) \ NS_IMETHODIMP macro_class::GetCommandLineArgument(char **aCommandLineArgument) \ { \ if (!aCommandLineArgument) return NS_ERROR_FAILURE; \ @@ -63,9 +64,23 @@ NS_IMETHODIMP macro_class::GetHelpText(char **aHelpText) \ *aHelpText = PL_strdup(macro_help_text); \ return NS_OK; \ } \ +NS_IMETHODIMP macro_class::GetHandlesArgs(PRBool *aHandlesArgs) \ +{ \ + if (!aHandlesArgs) return NS_ERROR_FAILURE; \ + *aHandlesArgs = macro_handles_args; \ + return NS_OK; \ +} \ +NS_IMETHODIMP macro_class::GetDefaultArgs(PRUnichar **aDefaultArgs) \ +{ \ + if (!aDefaultArgs) return NS_ERROR_FAILURE; \ + nsString args(macro_default_args); \ + *aDefaultArgs = args.ToNewUnicode(); \ + return NS_OK; \ +} \ NS_METHOD macro_class::RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType) \ { \ nsresult rv; \ + printf("registering %s under %s\n",macro_progid,COMMAND_LINE_ARGUMENT_HANDLERS); \ nsCOMPtr catman = do_GetService("mozilla.categorymanager.1", &rv); \ if (NS_FAILED(rv)) return rv; \ nsXPIDLCString prevEntry; \ @@ -75,6 +90,7 @@ NS_METHOD macro_class::RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPat NS_METHOD macro_class::UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation) \ { \ nsresult rv; \ + nsCOMPtr catman = do_GetService("mozilla.categorymanager.1", &rv); \ if (NS_FAILED(rv)) return rv; \ nsXPIDLCString prevEntry; \ @@ -90,8 +106,9 @@ interface nsICmdLineHandler : nsISupports readonly attribute string commandLineArgument; readonly attribute string prefNameForStartup; readonly attribute string chromeUrlForTask; - - /* should this be a wstring? */ readonly attribute string helpText; + + readonly attribute boolean handlesArgs; + readonly attribute wstring defaultArgs; }; diff --git a/mozilla/xpfe/bootstrap/nsAppRunner.cpp b/mozilla/xpfe/bootstrap/nsAppRunner.cpp index f5edbec4ef3..f3d4b91c832 100644 --- a/mozilla/xpfe/bootstrap/nsAppRunner.cpp +++ b/mozilla/xpfe/bootstrap/nsAppRunner.cpp @@ -59,16 +59,15 @@ #include "nsICategoryManager.h" #include "nsXPIDLString.h" +#if defined(DEBUG_sspitzer) || defined(DEBUG_seth) +#define DEBUG_CMD_LINE +#endif + static NS_DEFINE_CID(kSoftUpdateCID, NS_SoftwareUpdate_CID); static NS_DEFINE_IID(kIWindowMediatorIID,NS_IWINDOWMEDIATOR_IID); static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID); static NS_DEFINE_CID(kWalletServiceCID, NS_WALLETSERVICE_CID); -#define PREF_GENERAL_STARTUP_BROWSER "general.startup.browser" -#define PREF_GENERAL_STARTUP_MAIL "general.startup.mail" -#define PREF_GENERAL_STARTUP_EDITOR "general.startup.editor" -#define PREF_GENERAL_STARTUP_CALENDAR "general.startup.calendar" - #define HELP_SPACER_1 "\t" #define HELP_SPACER_2 "\t\t" @@ -196,39 +195,6 @@ static nsresult OpenWindow( const char*urlstr, const PRUnichar *args ) { return rv; } -static nsresult HandleEditorStartup( nsICmdLineService* cmdLineArgs, nsIPref *prefs, PRBool heedGeneralStartupPrefs) -{ - char* cmdResult = nsnull; - char * urlstr=nsnull; - nsString withArgs; - nsresult rv; - PRBool forceLaunchEditor = PR_FALSE; - - if (heedGeneralStartupPrefs) { - prefs->GetBoolPref(PREF_GENERAL_STARTUP_EDITOR,&forceLaunchEditor); - } - - rv = cmdLineArgs->GetCmdLineValue("-edit", &cmdResult); - if (NS_SUCCEEDED(rv)) - { - if (forceLaunchEditor || cmdResult) { - urlstr = "chrome://editor/content/"; - if (cmdResult) { - if (PL_strcmp("1",cmdResult)==0) { - // this signals no URL after "-edit"? - withArgs = "about:blank"; - } else { - // We have a URL -- Should we do some URL validating here? - withArgs = cmdResult; - } - } - OpenWindow( urlstr, withArgs.GetUnicode() ); - } - } - - return NS_OK; -} - static nsresult OpenChromURL( const char * urlstr, PRInt32 height = NS_SIZETOCONTENT, PRInt32 width = NS_SIZETOCONTENT ) { nsIURI* url = nsnull; @@ -246,114 +212,27 @@ static nsresult OpenChromURL( const char * urlstr, PRInt32 height = NS_SIZETOCON return rv; } -static nsresult HandleMailStartup( nsICmdLineService* cmdLineArgs, nsIPref *prefs, PRBool heedGeneralStartupPrefs) -{ - char* cmdResult = nsnull; - char * urlstr=nsnull; - nsString withArgs; - nsresult rv; - - PRInt32 height = NS_SIZETOCONTENT; - PRInt32 width = NS_SIZETOCONTENT; - // Get the value of -width option - char* tempString = NULL; - rv = cmdLineArgs->GetCmdLineValue("-width", &tempString); - if (NS_FAILED(rv)) - return rv; - - if (tempString) - PR_sscanf(tempString, "%d", &width); - - // Get the value of -height option - rv = cmdLineArgs->GetCmdLineValue("-height", &tempString); - if (NS_FAILED(rv)) - return rv; - - if (tempString) - PR_sscanf(tempString, "%d", &height); - - - rv = cmdLineArgs->GetCmdLineValue("-compose", &cmdResult); - if (NS_SUCCEEDED(rv)) - { - if (cmdResult && (PL_strcmp("1",cmdResult)==0)) - { - urlstr = "chrome://messengercompose/content/"; - withArgs = "about:blank"; - - OpenWindow( urlstr, withArgs.GetUnicode() ); - } - } - - return rv; -} - -static nsresult HandleBrowserStartup( nsICmdLineService* cmdLineArgs, nsIPref *prefs, PRBool heedGeneralStartupPrefs) -{ - char* cmdResult = nsnull; - - nsString withArgs; - nsresult rv; - PRBool forceLaunchBrowser = PR_FALSE; - - PRInt32 height = NS_SIZETOCONTENT; - PRInt32 width = NS_SIZETOCONTENT; - // Get the value of -width option - char* tempString = NULL; - rv = cmdLineArgs->GetCmdLineValue("-width", &tempString); - if (NS_FAILED(rv)) - return rv; - - if (tempString) - PR_sscanf(tempString, "%d", &width); - - - // Get the value of -height option - rv = cmdLineArgs->GetCmdLineValue("-height", &tempString); - if (NS_FAILED(rv)) - return rv; - - - if (tempString) - PR_sscanf(tempString, "%d", &height); - - if (heedGeneralStartupPrefs) { - prefs->GetBoolPref(PREF_GENERAL_STARTUP_BROWSER,&forceLaunchBrowser); - } - rv = cmdLineArgs->GetCmdLineValue("-chrome", &cmdResult); - if (forceLaunchBrowser) { - rv = OpenChromURL("chrome://navigator/content/", height, width ); - } - else if (NS_SUCCEEDED(rv) && cmdResult) { - rv = OpenChromURL(cmdResult, height, width); - } - - return rv; -} - static void DumpArbitraryHelp() { nsresult rv; NS_WITH_SERVICE(nsICategoryManager, catman, "mozilla.categorymanager.1", &rv); if(NS_SUCCEEDED(rv) && catman) { -#ifdef DEBUG_sspitzer - printf("got the category manager\n"); -#endif /* DEBUG_sspitzer */ nsCOMPtr e; rv = catman->EnumerateCategory(COMMAND_LINE_ARGUMENT_HANDLERS, getter_AddRefs(e)); if(NS_SUCCEEDED(rv) && e) { -#ifdef DEBUG_sspitzer - printf("got the enumerator for all %s\n",COMMAND_LINE_ARGUMENT_HANDLERS); -#endif /* DEBUG_sspitzer */ - nsCOMPtr el; - rv = e->GetNext(getter_AddRefs(el)); - while (NS_SUCCEEDED(rv) && el) { - nsCOMPtr handler = do_QueryInterface(el); + nsCOMPtr progid; + rv = e->GetNext(getter_AddRefs(progid)); + while (NS_SUCCEEDED(rv) && progid) { + nsXPIDLCString progidString; + progid->ToString (getter_Copies(progidString)); + +#ifdef DEBUG_CMD_LINE + printf("cmd line hander progid = %s\n", (const char *)progidString); +#endif /* DEBUG_CMD_LINE */ + + nsCOMPtr handler = do_CreateInstance((const char *)progidString, &rv); if (handler) { -#ifdef DEBUG_sspitzer - printf("got a nsICmdLineHandler\n"); -#endif /* DEBUG_sspitzer */ nsXPIDLCString commandLineArg; rv = handler->GetCommandLineArgument(getter_Copies(commandLineArg)); if (NS_FAILED(rv)) continue; @@ -361,7 +240,7 @@ static void DumpArbitraryHelp() nsXPIDLCString helpText; rv = handler->GetHelpText(getter_Copies(helpText)); if (NS_FAILED(rv)) continue; - + if ((const char *)commandLineArg) { printf("%s%s", HELP_SPACER_1,(const char *)commandLineArg); if ((const char *)helpText) { @@ -369,77 +248,57 @@ static void DumpArbitraryHelp() } } } - else { -#ifdef DEBUG_sspitzer - printf("failed to QI from nsISupports to nsICmdLineHandler\n"); -#endif - } - rv = e->GetNext(getter_AddRefs(el)); + rv = e->GetNext(getter_AddRefs(progid)); } } } - -#ifdef DEBUG_sspitzer - printf("all done dumping arbitrary help\n"); -#endif /* DEBUG_sspitzer */ return; } static nsresult HandleArbitraryStartup( nsICmdLineService* cmdLineArgs, nsIPref *prefs, PRBool heedGeneralStartupPrefs) { char* cmdResult = nsnull; - nsString withArgs; nsresult rv; PRBool forceLaunchTask = PR_FALSE; PRInt32 height = NS_SIZETOCONTENT; PRInt32 width = NS_SIZETOCONTENT; char* tempString = NULL; -#ifdef DEBUG_sspitzer - printf("start handling arbitrary command line arguments\n"); -#endif /* DEBUG_sspitzer */ - // Get the value of -width option rv = cmdLineArgs->GetCmdLineValue("-width", &tempString); if (NS_FAILED(rv)) return rv; - if (tempString) - PR_sscanf(tempString, "%d", &width); + if (tempString) PR_sscanf(tempString, "%d", &width); // Get the value of -height option rv = cmdLineArgs->GetCmdLineValue("-height", &tempString); if (NS_FAILED(rv)) return rv; - - if (tempString) - PR_sscanf(tempString, "%d", &height); - + if (tempString) PR_sscanf(tempString, "%d", &height); + NS_WITH_SERVICE(nsICategoryManager, catman, "mozilla.categorymanager.1", &rv); if(NS_SUCCEEDED(rv) && catman) { -#ifdef DEBUG_sspitzer - printf("got the category manager\n"); -#endif /* DEBUG_sspitzer */ + nsCOMPtr e; rv = catman->EnumerateCategory(COMMAND_LINE_ARGUMENT_HANDLERS, getter_AddRefs(e)); if(NS_SUCCEEDED(rv) && e) { -#ifdef DEBUG_sspitzer - printf("got the enumerator for all %s\n",COMMAND_LINE_ARGUMENT_HANDLERS); -#endif /* DEBUG_sspitzer */ + nsCOMPtr progid; rv = e->GetNext(getter_AddRefs(progid)); while (NS_SUCCEEDED(rv) && progid) { nsXPIDLCString progidString; - progid->ToString (getter_Copies(progidString)); - - // should this be a NS_WITH_SERVICE? - nsCOMPtr handler = do_CreateInstance((const char *)progidString, &rv); - if (NS_FAILED(rv)) continue; - + progid->ToString (getter_Copies(progidString)); + +#ifdef DEBUG_CMD_LINE + printf("cmd line hander progid = %s\n", (const char *)progidString); +#endif /* DEBUG_CMD_LINE */ + + nsCOMPtr handler = do_CreateInstance((const char *)progidString, &rv); + if (NS_FAILED(rv)) continue; + if (handler) { -#ifdef DEBUG_sspitzer - printf("got a nsICmdLineHandler\n"); -#endif /* DEBUG_sspitzer */ + nsXPIDLCString commandLineArg; rv = handler->GetCommandLineArgument(getter_Copies(commandLineArg)); if (NS_FAILED(rv)) continue; @@ -452,10 +311,10 @@ static nsresult HandleArbitraryStartup( nsICmdLineService* cmdLineArgs, nsIPref rv = handler->GetPrefNameForStartup(getter_Copies(prefNameForStartup)); if (NS_FAILED(rv)) continue; -#ifdef DEBUG_sspitzer - printf("got this one: %s\t%s\t%s\n",(const char *)commandLineArg,(const char *)chromeUrlForTask,(const char *)prefNameForStartup); -#endif /* DEBUG_sspitzer */ - +#ifdef DEBUG_CMD_LINE + printf("got this one:\t%s\n\t%s\n\t%s\n\n",(const char *)commandLineArg,(const char *)chromeUrlForTask,(const char *)prefNameForStartup); +#endif /* DEBUG_CMD_LINE */ + if (heedGeneralStartupPrefs) { rv = prefs->GetBoolPref((const char *)prefNameForStartup,&forceLaunchTask); if (NS_FAILED(rv)) { @@ -464,14 +323,35 @@ static nsresult HandleArbitraryStartup( nsICmdLineService* cmdLineArgs, nsIPref } rv = cmdLineArgs->GetCmdLineValue((const char *)commandLineArg, &cmdResult); - if (forceLaunchTask || (NS_SUCCEEDED(rv) && cmdResult && (PL_strcmp("1",cmdResult)==0))) { - OpenChromURL((const char *)chromeUrlForTask,height, width); + PRBool handlesArgs = PR_FALSE; + rv = handler->GetHandlesArgs(&handlesArgs); + if (handlesArgs) { + if (forceLaunchTask || cmdResult) { + if (cmdResult && PL_strcmp("1",cmdResult)) { + nsString cmdArgs(cmdResult); + OpenWindow((const char *)chromeUrlForTask, cmdArgs.GetUnicode()); + } + else { + PRUnichar *defaultArgs; + rv = handler->GetDefaultArgs(&defaultArgs); + OpenWindow((const char *)chromeUrlForTask, defaultArgs); + Recycle(defaultArgs); + } + } + } + else { + if (forceLaunchTask) { + OpenChromURL((const char *)chromeUrlForTask,height, width); + } + else if (NS_SUCCEEDED(rv) && cmdResult) { + if (PL_strcmp("1",cmdResult)) { + OpenChromURL((const char *)chromeUrlForTask,height, width); + } + else { + OpenChromURL(cmdResult, height, width); + } + } } - } - else { -#ifdef DEBUG_sspitzer - printf("failed to QI from nsISupports to nsICmdLineHandler\n"); -#endif } rv = e->GetNext(getter_AddRefs(progid)); @@ -479,9 +359,6 @@ static nsresult HandleArbitraryStartup( nsICmdLineService* cmdLineArgs, nsIPref } } -#ifdef DEBUG_sspitzer - printf("all done handling arbitrary command line arguments\n"); -#endif /* DEBUG_sspitzer */ return NS_OK; } @@ -493,15 +370,6 @@ static nsresult DoCommandLines( nsICmdLineService* cmdLine, PRBool heedGeneralSt NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv); if (NS_FAILED(rv)) return rv; - rv = HandleEditorStartup( cmdLine, prefs, heedGeneralStartupPrefs); - if ( NS_FAILED( rv ) ) return rv; - - rv = HandleMailStartup( cmdLine, prefs, heedGeneralStartupPrefs); - if ( NS_FAILED( rv ) ) return rv; - - rv = HandleBrowserStartup( cmdLine, prefs, heedGeneralStartupPrefs); - if ( NS_FAILED( rv ) ) return rv; - rv = HandleArbitraryStartup( cmdLine, prefs, heedGeneralStartupPrefs); return rv; } @@ -640,12 +508,11 @@ static nsresult main1(int argc, char* argv[], nsISplashScreen *splashScreen ) // if we get here, and we don't have a current profile, return a failure so we will exit // this can happen, if the user hits Cancel or Exit in the profile manager dialogs - char *currentProfileStr = nsnull; - rv = profileMgr->GetCurrentProfile(¤tProfileStr); - if (NS_FAILED(rv) || !currentProfileStr || (PL_strlen(currentProfileStr) == 0)) { + nsXPIDLCString currentProfileStr; + rv = profileMgr->GetCurrentProfile(getter_Copies(currentProfileStr)); + if (NS_FAILED(rv) || !((const char *)currentProfileStr) || (PL_strlen((const char *)currentProfileStr) == 0)) { return NS_ERROR_FAILURE; } - PR_FREEIF(currentProfileStr); // rjc: now must explicitly call appshell's CreateHiddenWindow() function AFTER profile manager. // if the profile manager ever switches to using nsIDOMWindow stuff, this might have to change @@ -706,9 +573,6 @@ void DumpHelp(char *appname) printf("Usage: %s [ options ... ] [URL]\n", appname); printf(" where options include:\n"); printf("\n"); - printf("%s-chrome %sOpen chrome url..\n",HELP_SPACER_1,HELP_SPACER_2); - printf("%s-compose%sStart with mail compose window.\n",HELP_SPACER_1,HELP_SPACER_2); - printf("%s-edit%sStart with editor.\n",HELP_SPACER_1,HELP_SPACER_2); printf("%s-height %sSet height of startup window to .\n",HELP_SPACER_1,HELP_SPACER_2); printf("%s-h or -help%sPrint this message.\n",HELP_SPACER_1,HELP_SPACER_2); printf("%s-installer%sStart with 4.x migration window.\n",HELP_SPACER_1,HELP_SPACER_2); @@ -721,6 +585,8 @@ void DumpHelp(char *appname) printf("%s-ProfileManager%sStart with profile manager.\n",HELP_SPACER_1,HELP_SPACER_2); printf("%s-SelectProfile%sStart with profile selection dialog.\n",HELP_SPACER_1,HELP_SPACER_2); + // not working yet, because we handle -h too early, and components + // havent registered yet DumpArbitraryHelp(); } diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp index f436aeb3c2c..d42184eb8a1 100644 --- a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp +++ b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp @@ -86,6 +86,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #include "nsCURILoader.h" #include "nsIContentHandler.h" #include "nsNetUtil.h" +#include "nsICmdLineHandler.h" static NS_DEFINE_IID(kIWalletServiceIID, NS_IWALLETSERVICE_IID); static NS_DEFINE_IID(kWalletServiceCID, NS_WALLETSERVICE_CID); @@ -182,6 +183,7 @@ NS_INTERFACE_MAP_BEGIN(nsBrowserInstance) NS_INTERFACE_MAP_ENTRY(nsIDocumentLoaderObserver) NS_INTERFACE_MAP_ENTRY(nsIObserver) NS_INTERFACE_MAP_ENTRY(nsIURIContentListener) + NS_INTERFACE_MAP_ENTRY(nsICmdLineHandler) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener) NS_INTERFACE_MAP_END @@ -2410,8 +2412,12 @@ static nsModuleComponentInfo components[] = { { "nsBrowserInstance", NS_BROWSERINSTANCE_CID, NS_IBROWSERINSTANCE_PROGID, - nsBrowserInstanceConstructor } + nsBrowserInstanceConstructor, + nsBrowserInstance::RegisterProc, + nsBrowserInstance::UnregisterProc, + } }; NS_IMPL_NSGETMODULE("nsBrowserModule", components) +CMDLINEHANDLER_IMPL(nsBrowserInstance,"-chrome","general.startup.browser","chrome://navigator/content/","Start with browser",NS_IBROWSERINSTANCE_PROGID,"Browser Cmd Line Handler", PR_FALSE, "") diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.h b/mozilla/xpfe/browser/src/nsBrowserInstance.h index 095f0504cfc..3e6bdf0ec44 100644 --- a/mozilla/xpfe/browser/src/nsBrowserInstance.h +++ b/mozilla/xpfe/browser/src/nsBrowserInstance.h @@ -37,6 +37,7 @@ #include "nsIObserver.h" #include "nsISessionHistory.h" #include "nsIURIContentListener.h" +#include "nsICmdLineHandler.h" #ifdef DEBUG_radha #include "nsISHistory.h" @@ -66,6 +67,7 @@ class nsBrowserInstance : public nsIBrowserInstance, public nsIObserver, public nsISessionHistory, public nsIURIContentListener, + public nsICmdLineHandler, public nsSupportsWeakReference { public: @@ -76,6 +78,9 @@ class nsBrowserInstance : public nsIBrowserInstance, NS_DECL_NSIBROWSERINSTANCE + NS_DECL_NSICMDLINEHANDLER + CMDLINEHANDLER_REGISTERPROC_DECLS + NS_DEFINE_STATIC_CID_ACCESSOR( NS_BROWSERINSTANCE_CID ) // nsIDocumentLoaderObserver diff --git a/mozilla/xpfe/components/prefwindow/resources/content/pref-appearance.xul b/mozilla/xpfe/components/prefwindow/resources/content/pref-appearance.xul index 345ce83168f..8263abe5e10 100644 --- a/mozilla/xpfe/components/prefwindow/resources/content/pref-appearance.xul +++ b/mozilla/xpfe/components/prefwindow/resources/content/pref-appearance.xul @@ -60,13 +60,6 @@ &compCheck.label; - - - - &calCheck.label; - - diff --git a/mozilla/xpfe/components/prefwindow/resources/locale/en-US/pref-appearance.dtd b/mozilla/xpfe/components/prefwindow/resources/locale/en-US/pref-appearance.dtd index 3f8c88be062..55f366f1e9b 100644 --- a/mozilla/xpfe/components/prefwindow/resources/locale/en-US/pref-appearance.dtd +++ b/mozilla/xpfe/components/prefwindow/resources/locale/en-US/pref-appearance.dtd @@ -12,8 +12,6 @@ - - diff --git a/mozilla/xpfe/components/startup/public/nsICmdLineHandler.idl b/mozilla/xpfe/components/startup/public/nsICmdLineHandler.idl index 7d78b766203..d909acdbe21 100644 --- a/mozilla/xpfe/components/startup/public/nsICmdLineHandler.idl +++ b/mozilla/xpfe/components/startup/public/nsICmdLineHandler.idl @@ -33,12 +33,13 @@ #include "nsICategoryManager.h" #include "nsIFileSpec.h" #include "nsXPIDLString.h" +#include "nsIServiceManager.h" #define CMDLINEHANDLER_REGISTERPROC_DECLS \ static NS_METHOD RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType); \ static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation); -#define CMDLINEHANDLER_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_chrome_url,macro_help_text, macro_progid, macro_pretty_name) \ +#define CMDLINEHANDLER_IMPL(macro_class,macro_cmd_line_arg,macro_pref_name,macro_chrome_url,macro_help_text, macro_progid, macro_pretty_name, macro_handles_args, macro_default_args) \ NS_IMETHODIMP macro_class::GetCommandLineArgument(char **aCommandLineArgument) \ { \ if (!aCommandLineArgument) return NS_ERROR_FAILURE; \ @@ -63,9 +64,23 @@ NS_IMETHODIMP macro_class::GetHelpText(char **aHelpText) \ *aHelpText = PL_strdup(macro_help_text); \ return NS_OK; \ } \ +NS_IMETHODIMP macro_class::GetHandlesArgs(PRBool *aHandlesArgs) \ +{ \ + if (!aHandlesArgs) return NS_ERROR_FAILURE; \ + *aHandlesArgs = macro_handles_args; \ + return NS_OK; \ +} \ +NS_IMETHODIMP macro_class::GetDefaultArgs(PRUnichar **aDefaultArgs) \ +{ \ + if (!aDefaultArgs) return NS_ERROR_FAILURE; \ + nsString args(macro_default_args); \ + *aDefaultArgs = args.ToNewUnicode(); \ + return NS_OK; \ +} \ NS_METHOD macro_class::RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, const char *componentType) \ { \ nsresult rv; \ + printf("registering %s under %s\n",macro_progid,COMMAND_LINE_ARGUMENT_HANDLERS); \ nsCOMPtr catman = do_GetService("mozilla.categorymanager.1", &rv); \ if (NS_FAILED(rv)) return rv; \ nsXPIDLCString prevEntry; \ @@ -75,6 +90,7 @@ NS_METHOD macro_class::RegisterProc(nsIComponentManager *aCompMgr, nsIFile *aPat NS_METHOD macro_class::UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation) \ { \ nsresult rv; \ + nsCOMPtr catman = do_GetService("mozilla.categorymanager.1", &rv); \ if (NS_FAILED(rv)) return rv; \ nsXPIDLCString prevEntry; \ @@ -90,8 +106,9 @@ interface nsICmdLineHandler : nsISupports readonly attribute string commandLineArgument; readonly attribute string prefNameForStartup; readonly attribute string chromeUrlForTask; - - /* should this be a wstring? */ readonly attribute string helpText; + + readonly attribute boolean handlesArgs; + readonly attribute wstring defaultArgs; };