зеркало из https://github.com/mozilla/gecko-dev.git
fix for #28911, r=alecf, a=jar. avoid loading in unnecessary dlls at startup.
This commit is contained in:
Родитель
9023bcebd7
Коммит
7cb570ad1b
|
@ -65,9 +65,15 @@ static nsModuleComponentInfo components[] = {
|
||||||
{ "Editor Shell Spell Checker", NS_EDITORSHELL_CID,
|
{ "Editor Shell Spell Checker", NS_EDITORSHELL_CID,
|
||||||
"component://netscape/editor/editorspellcheck", nsEditorShellConstructor, },
|
"component://netscape/editor/editorspellcheck", nsEditorShellConstructor, },
|
||||||
{ "Editor Service", NS_EDITORSERVICE_CID,
|
{ "Editor Service", NS_EDITORSERVICE_CID,
|
||||||
"component://netscape/editor/editorservice", nsEditorServiceConstructor,
|
"component://netscape/editor/editorservice", nsEditorServiceConstructor,},
|
||||||
|
{ "Editor Startup Handler", NS_EDITORSERVICE_CID,
|
||||||
|
"component://netscape/commandlinehander/general-startup-editor",
|
||||||
|
nsEditorServiceConstructor,
|
||||||
nsEditorService::RegisterProc,
|
nsEditorService::RegisterProc,
|
||||||
nsEditorService::UnregisterProc, },
|
nsEditorService::UnregisterProc, },
|
||||||
|
{ "Edit Startup Handler", NS_EDITORSERVICE_CID,
|
||||||
|
"component://netscape/commandlinehander/general-startup-edit",
|
||||||
|
nsEditorServiceConstructor, },
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -38,4 +38,4 @@ NS_IMPL_QUERY_INTERFACE2(nsEditorService,
|
||||||
nsIEditorService,
|
nsIEditorService,
|
||||||
nsICmdLineHandler)
|
nsICmdLineHandler)
|
||||||
|
|
||||||
CMDLINEHANDLER_IMPL(nsEditorService,"-edit","general.startup.editor","chrome://editor/content/","Start with editor.","component://netscape/editor/editorservice","Editor Cmd Line Handler", PR_TRUE,"about:blank", PR_TRUE)
|
CMDLINEHANDLER_IMPL(nsEditorService,"-edit","general.startup.editor","chrome://editor/content/","Start with editor.","component://netscape/commandlinehander/general-startup-editor","Editor Startup Handler", PR_TRUE,"about:blank", PR_TRUE)
|
||||||
|
|
|
@ -38,4 +38,4 @@ NS_IMPL_QUERY_INTERFACE2(nsEditorService,
|
||||||
nsIEditorService,
|
nsIEditorService,
|
||||||
nsICmdLineHandler)
|
nsICmdLineHandler)
|
||||||
|
|
||||||
CMDLINEHANDLER_IMPL(nsEditorService,"-edit","general.startup.editor","chrome://editor/content/","Start with editor.","component://netscape/editor/editorservice","Editor Cmd Line Handler", PR_TRUE,"about:blank", PR_TRUE)
|
CMDLINEHANDLER_IMPL(nsEditorService,"-edit","general.startup.editor","chrome://editor/content/","Start with editor.","component://netscape/commandlinehander/general-startup-editor","Editor Startup Handler", PR_TRUE,"about:blank", PR_TRUE)
|
||||||
|
|
|
@ -65,9 +65,15 @@ static nsModuleComponentInfo components[] = {
|
||||||
{ "Editor Shell Spell Checker", NS_EDITORSHELL_CID,
|
{ "Editor Shell Spell Checker", NS_EDITORSHELL_CID,
|
||||||
"component://netscape/editor/editorspellcheck", nsEditorShellConstructor, },
|
"component://netscape/editor/editorspellcheck", nsEditorShellConstructor, },
|
||||||
{ "Editor Service", NS_EDITORSERVICE_CID,
|
{ "Editor Service", NS_EDITORSERVICE_CID,
|
||||||
"component://netscape/editor/editorservice", nsEditorServiceConstructor,
|
"component://netscape/editor/editorservice", nsEditorServiceConstructor,},
|
||||||
|
{ "Editor Startup Handler", NS_EDITORSERVICE_CID,
|
||||||
|
"component://netscape/commandlinehander/general-startup-editor",
|
||||||
|
nsEditorServiceConstructor,
|
||||||
nsEditorService::RegisterProc,
|
nsEditorService::RegisterProc,
|
||||||
nsEditorService::UnregisterProc, },
|
nsEditorService::UnregisterProc, },
|
||||||
|
{ "Edit Startup Handler", NS_EDITORSERVICE_CID,
|
||||||
|
"component://netscape/commandlinehander/general-startup-edit",
|
||||||
|
nsEditorServiceConstructor, },
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
#define NS_ADDRESSBOOK_PROGID \
|
#define NS_ADDRESSBOOK_PROGID \
|
||||||
"component://netscape/addressbook"
|
"component://netscape/addressbook"
|
||||||
|
|
||||||
|
#define NS_ADDRESSBOOKSTARTUPHANDLER_PROGID \
|
||||||
|
"component://netscape/commandlinehander/general-startup-addressbook"
|
||||||
|
|
||||||
#define NS_ADDRESSBOOK_CID \
|
#define NS_ADDRESSBOOK_CID \
|
||||||
{ /* {D60B84F2-2A8C-11d3-9E07-00A0C92B5F0D} */ \
|
{ /* {D60B84F2-2A8C-11d3-9E07-00A0C92B5F0D} */ \
|
||||||
0xd60b84f2, 0x2a8c, 0x11d3, \
|
0xd60b84f2, 0x2a8c, 0x11d3, \
|
||||||
|
|
|
@ -64,9 +64,13 @@ static nsModuleComponentInfo components[] =
|
||||||
{ "Address Book",
|
{ "Address Book",
|
||||||
NS_ADDRESSBOOK_CID,
|
NS_ADDRESSBOOK_CID,
|
||||||
NS_ADDRESSBOOK_PROGID,
|
NS_ADDRESSBOOK_PROGID,
|
||||||
|
nsAddressBookConstructor },
|
||||||
|
{ "Address Book Startup Handler",
|
||||||
|
NS_ADDRESSBOOK_CID,
|
||||||
|
NS_ADDRESSBOOKSTARTUPHANDLER_PROGID,
|
||||||
nsAddressBookConstructor,
|
nsAddressBookConstructor,
|
||||||
nsAddressBook::RegisterProc,
|
nsAddressBook::RegisterProc,
|
||||||
nsAddressBook::UnregisterProc },
|
nsAddressBook::UnregisterProc },
|
||||||
{ "Address Book Directory Datasource",
|
{ "Address Book Directory Datasource",
|
||||||
NS_ABDIRECTORYDATASOURCE_CID,
|
NS_ABDIRECTORYDATASOURCE_CID,
|
||||||
NS_ABDIRECTORYDATASOURCE_PROGID,
|
NS_ABDIRECTORYDATASOURCE_PROGID,
|
||||||
|
|
|
@ -1272,4 +1272,4 @@ NS_IMETHODIMP nsAddressBook::ImportAddressBook()
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMDLINEHANDLER_IMPL(nsAddressBook,"-addressbook","general.startup.addressbook","chrome://addressbook/content/","Start with the addressbook.",NS_ADDRESSBOOK_PROGID,"Addressbook Cmd Line Handler",PR_FALSE,"", PR_TRUE)
|
CMDLINEHANDLER_IMPL(nsAddressBook,"-addressbook","general.startup.addressbook","chrome://addressbook/content/","Start with the addressbook.",NS_ADDRESSBOOKSTARTUPHANDLER_PROGID,"Addressbook Startup Handler",PR_FALSE,"", PR_TRUE)
|
||||||
|
|
|
@ -235,6 +235,8 @@
|
||||||
//
|
//
|
||||||
#define NS_MESSENGERBOOTSTRAP_PROGID \
|
#define NS_MESSENGERBOOTSTRAP_PROGID \
|
||||||
"component://netscape/appshell/component/messenger"
|
"component://netscape/appshell/component/messenger"
|
||||||
|
#define NS_MAILSTARTUPHANDLER_PROGID \
|
||||||
|
"component://netscape/commandlinehander/general-startup-mail"
|
||||||
|
|
||||||
//
|
//
|
||||||
// nsMessenger
|
// nsMessenger
|
||||||
|
|
|
@ -440,7 +440,9 @@ struct Components {
|
||||||
// The list of components we register
|
// The list of components we register
|
||||||
static Components gComponents[] = {
|
static Components gComponents[] = {
|
||||||
{ "Netscape Messenger Bootstrapper", &kCMessengerBootstrapCID,
|
{ "Netscape Messenger Bootstrapper", &kCMessengerBootstrapCID,
|
||||||
NS_MESSENGERBOOTSTRAP_PROGID,
|
NS_MESSENGERBOOTSTRAP_PROGID },
|
||||||
|
{ "Mail Startup Handler", &kCMessengerBootstrapCID,
|
||||||
|
NS_MAILSTARTUPHANDLER_PROGID,
|
||||||
nsMessengerBootstrap::RegisterProc,
|
nsMessengerBootstrap::RegisterProc,
|
||||||
nsMessengerBootstrap::UnregisterProc },
|
nsMessengerBootstrap::UnregisterProc },
|
||||||
{ "UrlListenerManager", &kCUrlListenerManagerCID,
|
{ "UrlListenerManager", &kCUrlListenerManagerCID,
|
||||||
|
|
|
@ -50,14 +50,19 @@ nsresult
|
||||||
nsMessengerBootstrap::Initialize(nsIAppShellService*,
|
nsMessengerBootstrap::Initialize(nsIAppShellService*,
|
||||||
nsICmdLineService*)
|
nsICmdLineService*)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
// not needed?
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> bootstrapper;
|
nsCOMPtr<nsISupports> bootstrapper;
|
||||||
rv = this->QueryInterface(kISupportsIID, getter_AddRefs(bootstrapper));
|
rv = this->QueryInterface(kISupportsIID, getter_AddRefs(bootstrapper));
|
||||||
if (NS_SUCCEEDED(rv) && bootstrapper) {
|
if (NS_SUCCEEDED(rv) && bootstrapper) {
|
||||||
rv = nsServiceManager::RegisterService( "component://netscape/appshell/component/messenger", bootstrapper);
|
rv = nsServiceManager::RegisterService(NS_MESSENGERBOOTSTRAP_PROGID, bootstrapper);
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
|
#else
|
||||||
|
return NS_OK;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -68,4 +73,4 @@ nsMessengerBootstrap::Shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CMDLINEHANDLER_IMPL(nsMessengerBootstrap,"-mail","general.startup.mail","chrome://messenger/content/","Start with mail.",NS_MESSENGERBOOTSTRAP_PROGID,"Mail Cmd Line Handler",PR_FALSE,"", PR_TRUE)
|
CMDLINEHANDLER_IMPL(nsMessengerBootstrap,"-mail","general.startup.mail","chrome://messenger/content/","Start with mail.",NS_MAILSTARTUPHANDLER_PROGID,"Mail Cmd Line Handler",PR_FALSE,"", PR_TRUE)
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
|
|
||||||
#define NS_MSGCOMPOSESERVICE_PROGID \
|
#define NS_MSGCOMPOSESERVICE_PROGID \
|
||||||
"component://netscape/messengercompose"
|
"component://netscape/messengercompose"
|
||||||
|
#define NS_MSGCOMPOSESTARTUPHANDLER_PROGID \
|
||||||
|
"component://netscape/commandlinehander/general-startup-compose"
|
||||||
|
|
||||||
//
|
//
|
||||||
// nsMsgCompose
|
// nsMsgCompose
|
||||||
|
|
|
@ -82,6 +82,10 @@ static nsModuleComponentInfo components[] =
|
||||||
{ "Msg Compose Service",
|
{ "Msg Compose Service",
|
||||||
NS_MSGCOMPOSESERVICE_CID,
|
NS_MSGCOMPOSESERVICE_CID,
|
||||||
NS_MSGCOMPOSESERVICE_PROGID,
|
NS_MSGCOMPOSESERVICE_PROGID,
|
||||||
|
nsMsgComposeServiceConstructor },
|
||||||
|
{ "Msg Compose Startup Handler",
|
||||||
|
NS_MSGCOMPOSESERVICE_CID,
|
||||||
|
NS_MSGCOMPOSESTARTUPHANDLER_PROGID,
|
||||||
nsMsgComposeServiceConstructor,
|
nsMsgComposeServiceConstructor,
|
||||||
nsMsgComposeService::RegisterProc,
|
nsMsgComposeService::RegisterProc,
|
||||||
nsMsgComposeService::UnregisterProc },
|
nsMsgComposeService::UnregisterProc },
|
||||||
|
|
|
@ -370,5 +370,5 @@ NS_IMETHODIMP nsMsgComposeService::HandleContent(const char * aContentType, cons
|
||||||
return rv;
|
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_FALSE, "", PR_TRUE)
|
CMDLINEHANDLER_IMPL(nsMsgComposeService,"-compose","general.startup.messengercompose","chrome://messengercompose/content/","Start with messenger compose.",NS_MSGCOMPOSESTARTUPHANDLER_PROGID,"Messenger Compose Startup Handler", PR_FALSE, "", PR_TRUE)
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,9 @@
|
||||||
"component://netscape/messenger/messageservice;type=news"
|
"component://netscape/messenger/messageservice;type=news"
|
||||||
#define NS_NNTPSERVICE_PROGID \
|
#define NS_NNTPSERVICE_PROGID \
|
||||||
"component://netscape/messenger/nntpservice"
|
"component://netscape/messenger/nntpservice"
|
||||||
|
#define NS_NEWSSTARTUPHANDLER_PROGID \
|
||||||
|
"component://netscape/commandlinehander/general-startup-news"
|
||||||
|
|
||||||
#define NS_NNTPSERVICE_CID \
|
#define NS_NNTPSERVICE_CID \
|
||||||
{ /* 4C9F90E1-E19B-11d2-806E-006008128C4E */ \
|
{ /* 4C9F90E1-E19B-11d2-806E-006008128C4E */ \
|
||||||
0x4c9f90e1, 0xe19b, 0x11d2, \
|
0x4c9f90e1, 0xe19b, 0x11d2, \
|
||||||
|
|
|
@ -66,6 +66,10 @@ static nsModuleComponentInfo components[] =
|
||||||
{ "NNTP Service",
|
{ "NNTP Service",
|
||||||
NS_NNTPSERVICE_CID,
|
NS_NNTPSERVICE_CID,
|
||||||
NS_NNTPSERVICE_PROGID,
|
NS_NNTPSERVICE_PROGID,
|
||||||
|
nsNntpServiceConstructor },
|
||||||
|
{ "News Startup Handler",
|
||||||
|
NS_NNTPSERVICE_CID,
|
||||||
|
NS_NEWSSTARTUPHANDLER_PROGID,
|
||||||
nsNntpServiceConstructor,
|
nsNntpServiceConstructor,
|
||||||
nsNntpService::RegisterProc,
|
nsNntpService::RegisterProc,
|
||||||
nsNntpService::UnregisterProc },
|
nsNntpService::UnregisterProc },
|
||||||
|
|
|
@ -1165,4 +1165,4 @@ nsresult nsNntpService::DisplayMessageForPrinting(const char* aMessageURI, nsISu
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMDLINEHANDLER_IMPL(nsNntpService,"-news","general.startup.news","chrome://messenger/content/","Start with news.",NS_NNTPSERVICE_PROGID,"News Cmd Line Handler", PR_FALSE,"", PR_TRUE)
|
CMDLINEHANDLER_IMPL(nsNntpService,"-news","general.startup.news","chrome://messenger/content/","Start with news.",NS_NEWSSTARTUPHANDLER_PROGID,"News Cmd Line Handler", PR_FALSE,"", PR_TRUE)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
%{C++
|
%{C++
|
||||||
|
|
||||||
#define COMMAND_LINE_ARGUMENT_HANDLERS "command-line-argument-handlers"
|
#define COMMAND_LINE_ARGUMENT_HANDLERS "command-line-argument-handlers"
|
||||||
|
#define PREF_STARTUP_PREFIX "general.startup."
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIComponentManager.h"
|
#include "nsIComponentManager.h"
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
#include "nsTimeBomb.h"
|
#include "nsTimeBomb.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DEBUG_sspitzer_) || defined(DEBUG_seth_)
|
#if defined(DEBUG_sspitzer) || defined(DEBUG_seth)
|
||||||
#define DEBUG_CMD_LINE
|
#define DEBUG_CMD_LINE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -278,11 +278,179 @@ static void DumpArbitraryHelp()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
nsresult LaunchApplication(const char *progID, PRInt32 height, PRInt32 width)
|
||||||
|
{
|
||||||
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
nsCOMPtr <nsICmdLineHandler> handler = do_GetService(progID, &rv);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
if (!handler) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
nsXPIDLCString chromeUrlForTask;
|
||||||
|
rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
PRBool handlesArgs = PR_FALSE;
|
||||||
|
rv = handler->GetHandlesArgs(&handlesArgs);
|
||||||
|
if (handlesArgs) {
|
||||||
|
PRUnichar *defaultArgs = nsnull;
|
||||||
|
rv = handler->GetDefaultArgs(&defaultArgs);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
rv = OpenWindow((const char *)chromeUrlForTask, defaultArgs);
|
||||||
|
Recycle(defaultArgs);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rv = OpenChromURL((const char *)chromeUrlForTask, height, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
static nsresult LaunchApplicationWithArgs(const char *commandLineArg, nsICmdLineService *cmdLineArgs, const char *progID, PRInt32 height, PRInt32 width)
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
if (!progID || !commandLineArg || !cmdLineArgs) return NS_ERROR_FAILURE;
|
||||||
|
nsXPIDLCString cmdResult;
|
||||||
|
|
||||||
|
nsCOMPtr <nsICmdLineHandler> handler = do_GetService(progID, &rv);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
if (!handler) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
nsXPIDLCString chromeUrlForTask;
|
||||||
|
rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
#ifdef DEBUG_CMD_LINE
|
||||||
|
printf("XXX got this one:\t%s\n\t%s\n\n",commandLineArg,(const char *)chromeUrlForTask);
|
||||||
|
#endif /* DEBUG_CMD_LINE */
|
||||||
|
|
||||||
|
rv = cmdLineArgs->GetCmdLineValue(commandLineArg, getter_Copies(cmdResult));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
#ifdef DEBUG_CMD_LINE
|
||||||
|
printf("%s, cmdResult = %s\n",commandLineArg,(const char *)cmdResult);
|
||||||
|
#endif /* DEBUG_CMD_LINE */
|
||||||
|
|
||||||
|
PRBool handlesArgs = PR_FALSE;
|
||||||
|
rv = handler->GetHandlesArgs(&handlesArgs);
|
||||||
|
if (handlesArgs) {
|
||||||
|
if ((const char *)cmdResult) {
|
||||||
|
if (PL_strcmp("1",(const char *)cmdResult)) {
|
||||||
|
PRBool openWindowWithArgs = PR_TRUE;
|
||||||
|
rv = handler->GetOpenWindowWithArgs(&openWindowWithArgs);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
if (openWindowWithArgs) {
|
||||||
|
nsString cmdArgs((const char *)cmdResult);
|
||||||
|
#ifdef DEBUG_CMD_LINE
|
||||||
|
printf("opening %s with %s\n",(const char *)chromeUrlForTask,"OpenWindow");
|
||||||
|
#endif /* DEBUG_CMD_LINE */
|
||||||
|
rv = OpenWindow((const char *)chromeUrlForTask, cmdArgs.GetUnicode());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#ifdef DEBUG_CMD_LINE
|
||||||
|
printf("opening %s with %s\n",(const char *)cmdResult,"OpenChromURL");
|
||||||
|
#endif /* DEBUG_CMD_LINE */
|
||||||
|
rv = OpenChromURL((const char *)cmdResult,height, width);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PRUnichar *defaultArgs;
|
||||||
|
rv = handler->GetDefaultArgs(&defaultArgs);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
rv = OpenWindow((const char *)chromeUrlForTask, defaultArgs);
|
||||||
|
Recycle(defaultArgs);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (NS_SUCCEEDED(rv) && (const char*)cmdResult) {
|
||||||
|
if (PL_strcmp("1",(const char *)cmdResult) == 0) {
|
||||||
|
rv = OpenChromURL((const char *)chromeUrlForTask,height, width);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rv = OpenChromURL((const char *)cmdResult, height, width);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
nsIPref *prefs;
|
||||||
|
PRInt32 height;
|
||||||
|
PRInt32 width;
|
||||||
|
} StartupClosure;
|
||||||
|
|
||||||
|
static
|
||||||
|
void startupPrefEnumerationFunction(const char *prefName, void *data)
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
PRBool prefValue = PR_FALSE;
|
||||||
|
|
||||||
|
if (!data || !prefName) return;
|
||||||
|
|
||||||
|
StartupClosure *closure = (StartupClosure *)data;
|
||||||
|
|
||||||
|
#ifdef DEBUG_CMD_LINE
|
||||||
|
printf("getting %s\n", prefName);
|
||||||
|
#endif /* DEBUG_CMD_LINE */
|
||||||
|
|
||||||
|
rv = closure->prefs->GetBoolPref(prefName, &prefValue);
|
||||||
|
if (NS_FAILED(rv)) return;
|
||||||
|
|
||||||
|
#ifdef DEBUG_CMD_LINE
|
||||||
|
printf("%s = %d\n", prefName, prefValue);
|
||||||
|
#endif /* DEBUG_CMD_LINE */
|
||||||
|
|
||||||
|
PRUint32 prefixLen = PL_strlen(PREF_STARTUP_PREFIX);
|
||||||
|
|
||||||
|
// if the pref is "general.startup.", ignore it.
|
||||||
|
if (PL_strlen(prefName) <= prefixLen) return;
|
||||||
|
|
||||||
|
if (prefValue) {
|
||||||
|
// this is the progid prefix that all the command line handers register
|
||||||
|
nsCAutoString progID = "component://netscape/commandlinehander/general-startup-";
|
||||||
|
progID += (prefName + prefixLen);
|
||||||
|
|
||||||
|
#ifdef DEBUG_CMD_LINE
|
||||||
|
printf("progid = %s\n", (const char *)progID);
|
||||||
|
#endif /* DEBUG_CMD_LINE */
|
||||||
|
rv = LaunchApplication((const char *)progID, closure->height, closure->width);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PRBool IsStartupCommand(const char *arg)
|
||||||
|
{
|
||||||
|
if (!arg) return PR_FALSE;
|
||||||
|
|
||||||
|
if (PL_strlen(arg) <= 1) return PR_FALSE;
|
||||||
|
|
||||||
|
// windows allows /mail or -mail
|
||||||
|
if ((arg[0] == '-')
|
||||||
|
#ifdef XP_PC
|
||||||
|
|| (arg[0] == '/')
|
||||||
|
#endif /* XP_PC */
|
||||||
|
) {
|
||||||
|
return PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PR_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static nsresult HandleArbitraryStartup( nsICmdLineService* cmdLineArgs, nsIPref *prefs, PRBool heedGeneralStartupPrefs)
|
static nsresult HandleArbitraryStartup( nsICmdLineService* cmdLineArgs, nsIPref *prefs, PRBool heedGeneralStartupPrefs)
|
||||||
{
|
{
|
||||||
char* cmdResult = nsnull;
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
PRBool forceLaunchTask = PR_FALSE;
|
|
||||||
PRInt32 height = NS_SIZETOCONTENT;
|
PRInt32 height = NS_SIZETOCONTENT;
|
||||||
PRInt32 width = NS_SIZETOCONTENT;
|
PRInt32 width = NS_SIZETOCONTENT;
|
||||||
char* tempString = NULL;
|
char* tempString = NULL;
|
||||||
|
@ -299,104 +467,53 @@ static nsresult HandleArbitraryStartup( nsICmdLineService* cmdLineArgs, nsIPref
|
||||||
|
|
||||||
if (tempString) PR_sscanf(tempString, "%d", &height);
|
if (tempString) PR_sscanf(tempString, "%d", &height);
|
||||||
|
|
||||||
NS_WITH_SERVICE(nsICategoryManager, catman, "mozilla.categorymanager.1", &rv);
|
if (heedGeneralStartupPrefs) {
|
||||||
if(NS_SUCCEEDED(rv) && catman) {
|
#ifdef DEBUG_CMD_LINE
|
||||||
|
printf("XXX iterate over all the general.startup.* prefs\n");
|
||||||
|
#endif /* DEBUG_CMD_LINE */
|
||||||
|
StartupClosure closure;
|
||||||
|
|
||||||
|
closure.prefs = prefs;
|
||||||
|
closure.height = height;
|
||||||
|
closure.width = width;
|
||||||
|
|
||||||
|
prefs->EnumerateChildren(PREF_STARTUP_PREFIX, startupPrefEnumerationFunction,(void *)(&closure));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PRInt32 argc = 0;
|
||||||
|
rv = cmdLineArgs->GetArgc(&argc);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
NS_ASSERTION(argc > 1, "we shouldn't be here if there were no command line arguments");
|
||||||
|
if (argc <= 1) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
char **argv = nsnull;
|
||||||
|
rv = cmdLineArgs->GetArgv(&argv);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
nsCOMPtr<nsISimpleEnumerator> e;
|
PRInt32 i = 0;
|
||||||
rv = catman->EnumerateCategory(COMMAND_LINE_ARGUMENT_HANDLERS, getter_AddRefs(e));
|
for (i=1;i<argc;i++) {
|
||||||
if(NS_SUCCEEDED(rv) && e) {
|
#ifdef DEBUG_CMD_LINE
|
||||||
while (PR_TRUE) {
|
printf("XXX argv[%d] = %s\n",i,argv[i]);
|
||||||
nsCOMPtr<nsISupportsString> progid;
|
#endif /* DEBUG_CMD_LINE */
|
||||||
rv = e->GetNext(getter_AddRefs(progid));
|
if (IsStartupCommand(argv[i])) {
|
||||||
if (NS_FAILED(rv) || !progid) break;
|
nsCAutoString progID = "component://netscape/commandlinehander/general-startup-";
|
||||||
|
|
||||||
nsXPIDLCString progidString;
|
|
||||||
progid->ToString(getter_Copies(progidString));
|
|
||||||
|
|
||||||
#ifdef DEBUG_CMD_LINE
|
// skip over the - (or / on windows)
|
||||||
printf("cmd line hander progid = %s\n", (const char *)progidString);
|
char *command = argv[i] + 1;
|
||||||
#endif /* DEBUG_CMD_LINE */
|
#ifdef XP_UNIX
|
||||||
|
// unix allows -mail and --mail
|
||||||
nsCOMPtr <nsICmdLineHandler> handler = do_GetService((const char *)progidString, &rv);
|
if ((argv[i][0] == '-') && (argv[i][1] == '-')) {
|
||||||
if (NS_FAILED(rv)) continue;
|
command = argv[i] + 2;
|
||||||
|
|
||||||
if (handler) {
|
|
||||||
|
|
||||||
nsXPIDLCString commandLineArg;
|
|
||||||
rv = handler->GetCommandLineArgument(getter_Copies(commandLineArg));
|
|
||||||
if (NS_FAILED(rv)) continue;
|
|
||||||
|
|
||||||
nsXPIDLCString chromeUrlForTask;
|
|
||||||
rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));
|
|
||||||
if (NS_FAILED(rv)) continue;
|
|
||||||
|
|
||||||
nsXPIDLCString prefNameForStartup;
|
|
||||||
rv = handler->GetPrefNameForStartup(getter_Copies(prefNameForStartup));
|
|
||||||
if (NS_FAILED(rv)) continue;
|
|
||||||
|
|
||||||
#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)) {
|
|
||||||
forceLaunchTask = PR_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = cmdLineArgs->GetCmdLineValue((const char *)commandLineArg, &cmdResult);
|
|
||||||
#ifdef DEBUG_CMD_LINE
|
|
||||||
printf("%s, cmdResult = %s\n",(const char *)commandLineArg,cmdResult);
|
|
||||||
#endif /* DEBUG_CMD_LINE */
|
|
||||||
|
|
||||||
PRBool handlesArgs = PR_FALSE;
|
|
||||||
rv = handler->GetHandlesArgs(&handlesArgs);
|
|
||||||
if (handlesArgs) {
|
|
||||||
if (forceLaunchTask || cmdResult) {
|
|
||||||
if (cmdResult && PL_strcmp("1",cmdResult)) {
|
|
||||||
PRBool openWindowWithArgs = PR_TRUE;
|
|
||||||
rv = handler->GetOpenWindowWithArgs(&openWindowWithArgs);
|
|
||||||
if (openWindowWithArgs) {
|
|
||||||
nsString cmdArgs(cmdResult);
|
|
||||||
#ifdef DEBUG_CMD_LINE
|
|
||||||
printf("opening %s with %s\n",(const char *)chromeUrlForTask,"OpenWindow");
|
|
||||||
#endif /* DEBUG_CMD_LINE */
|
|
||||||
OpenWindow((const char *)chromeUrlForTask, cmdArgs.GetUnicode());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
#ifdef DEBUG_CMD_LINE
|
|
||||||
printf("opening %s with %s\n",cmdResult,"OpenChromURL");
|
|
||||||
#endif /* DEBUG_CMD_LINE */
|
|
||||||
OpenChromURL(cmdResult,height, width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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) == 0) {
|
|
||||||
OpenChromURL((const char *)chromeUrlForTask,height, width);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
OpenChromURL(cmdResult, height, width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif /* XP_UNIX */
|
||||||
|
progID += (const char *)command;
|
||||||
|
// this can fail, as someone could do -foo, where -foo is not handled
|
||||||
|
rv = LaunchApplicationWithArgs((const char *)(argv[i]), cmdLineArgs, (const char *)progID, height, width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,23 +531,17 @@ static nsresult DoCommandLines( nsICmdLineService* cmdLine, PRBool heedGeneralSt
|
||||||
|
|
||||||
static nsresult OpenBrowserWindow(PRInt32 height, PRInt32 width)
|
static nsresult OpenBrowserWindow(PRInt32 height, PRInt32 width)
|
||||||
{
|
{
|
||||||
printf("XXX: OpenBrowserWindow()\n");
|
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
NS_WITH_SERVICE(nsICmdLineHandler, handler, NS_IBROWSERCMDLINEHANDLER_PROGID, &rv);
|
NS_WITH_SERVICE(nsICmdLineHandler, handler, NS_BROWSERSTARTUPHANDLER_PROGID, &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
nsXPIDLCString chromeUrlForTask;
|
nsXPIDLCString chromeUrlForTask;
|
||||||
rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));
|
rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
PRUnichar *defaultArgs;
|
rv = OpenChromURL((const char *)chromeUrlForTask, height, width );
|
||||||
rv = handler->GetDefaultArgs(&defaultArgs);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
rv = OpenWindow((const char *)chromeUrlForTask, defaultArgs);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
Recycle(defaultArgs);
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,11 +579,7 @@ static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs)
|
||||||
if (tempString)
|
if (tempString)
|
||||||
PR_sscanf(tempString, "%d", &height);
|
PR_sscanf(tempString, "%d", &height);
|
||||||
|
|
||||||
#if 0
|
|
||||||
rv = OpenBrowserWindow(height, width);
|
rv = OpenBrowserWindow(height, width);
|
||||||
#else
|
|
||||||
rv = OpenChromURL("chrome://navigator/content/", height, width );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -685,8 +792,9 @@ void DumpHelp(char *appname)
|
||||||
printf("%s-nosplash%sDisable splash screen.\n",HELP_SPACER_1,HELP_SPACER_2);
|
printf("%s-nosplash%sDisable splash screen.\n",HELP_SPACER_1,HELP_SPACER_2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// not working yet, because we handle -h too early, and components
|
// this works, but only after the components have registered. so if you drop in a new command line hander, -help
|
||||||
// havent registered yet
|
// won't not until the second run.
|
||||||
|
// out of the bug, because we ship a component.reg file, it works correctly.
|
||||||
DumpArbitraryHelp();
|
DumpArbitraryHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,8 @@ interface nsIBrowserInstance : nsISupports {
|
||||||
|
|
||||||
%{C++
|
%{C++
|
||||||
|
|
||||||
#define NS_IBROWSERINSTANCE_PROGID "component://netscape/appshell/component/browser/instance"
|
#define NS_BROWSERINSTANCE_PROGID "component://netscape/appshell/component/browser/instance"
|
||||||
#define NS_IBROWSERCMDLINEHANDLER_PROGID "component://netscape/appshell/component/browser/cmdhandler"
|
#define NS_BROWSERSTARTUPHANDLER_PROGID "component://netscape/commandlinehander/general-startup-browser"
|
||||||
|
|
||||||
// {c7bee75a-1dd1-11b2-9333-a38e085287cf}
|
// {c7bee75a-1dd1-11b2-9333-a38e085287cf}
|
||||||
#define NS_BROWSERCONTROLLER_CID { 0xc7bee75a, 0x1dd1, 0x11b2, { 0x93, 0x33, 0xa3, 0x8e, 0x08, 0x52, 0x87, 0xcf } }
|
#define NS_BROWSERCONTROLLER_CID { 0xc7bee75a, 0x1dd1, 0x11b2, { 0x93, 0x33, 0xa3, 0x8e, 0x08, 0x52, 0x87, 0xcf } }
|
||||||
|
|
|
@ -2525,7 +2525,7 @@ nsBrowserContentHandler::~nsBrowserContentHandler()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CMDLINEHANDLER2_IMPL(nsBrowserContentHandler,"-chrome","general.startup.browser","chrome://navigator/content/","Start with browser.",NS_IBROWSERCMDLINEHANDLER_PROGID,"Browser Cmd Line Handler", PR_TRUE, PR_FALSE)
|
CMDLINEHANDLER2_IMPL(nsBrowserContentHandler,"-chrome","general.startup.browser","chrome://navigator/content/","Start with browser.",NS_BROWSERSTARTUPHANDLER_PROGID,"Browser Startup Handler", PR_TRUE, PR_FALSE)
|
||||||
|
|
||||||
NS_IMETHODIMP nsBrowserContentHandler::GetDefaultArgs(PRUnichar **aDefaultArgs)
|
NS_IMETHODIMP nsBrowserContentHandler::GetDefaultArgs(PRUnichar **aDefaultArgs)
|
||||||
{
|
{
|
||||||
|
@ -2643,7 +2643,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserContentHandler)
|
||||||
static nsModuleComponentInfo components[] = {
|
static nsModuleComponentInfo components[] = {
|
||||||
{ "nsBrowserInstance",
|
{ "nsBrowserInstance",
|
||||||
NS_BROWSERINSTANCE_CID,
|
NS_BROWSERINSTANCE_CID,
|
||||||
NS_IBROWSERINSTANCE_PROGID,
|
NS_BROWSERINSTANCE_PROGID,
|
||||||
nsBrowserInstanceConstructor
|
nsBrowserInstanceConstructor
|
||||||
},
|
},
|
||||||
{ "Browser Content Handler",
|
{ "Browser Content Handler",
|
||||||
|
@ -2651,13 +2651,19 @@ static nsModuleComponentInfo components[] = {
|
||||||
NS_CONTENT_HANDLER_PROGID_PREFIX"text/html",
|
NS_CONTENT_HANDLER_PROGID_PREFIX"text/html",
|
||||||
nsBrowserContentHandlerConstructor
|
nsBrowserContentHandlerConstructor
|
||||||
},
|
},
|
||||||
{ "Browser Cmd Line Handler",
|
{ "Browser Startup Handler",
|
||||||
NS_BROWSERCONTENTHANDLER_CID,
|
NS_BROWSERCONTENTHANDLER_CID,
|
||||||
NS_IBROWSERCMDLINEHANDLER_PROGID,
|
NS_BROWSERSTARTUPHANDLER_PROGID,
|
||||||
nsBrowserContentHandlerConstructor,
|
nsBrowserContentHandlerConstructor,
|
||||||
nsBrowserContentHandler::RegisterProc,
|
nsBrowserContentHandler::RegisterProc,
|
||||||
nsBrowserContentHandler::UnregisterProc,
|
nsBrowserContentHandler::UnregisterProc,
|
||||||
}
|
},
|
||||||
|
{ "Chrome Startup Handler",
|
||||||
|
NS_BROWSERCONTENTHANDLER_CID,
|
||||||
|
"component://netscape/commandlinehander/general-startup-chrome",
|
||||||
|
nsBrowserContentHandlerConstructor,
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_IMPL_NSGETMODULE("nsBrowserModule", components)
|
NS_IMPL_NSGETMODULE("nsBrowserModule", components)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
%{C++
|
%{C++
|
||||||
|
|
||||||
#define COMMAND_LINE_ARGUMENT_HANDLERS "command-line-argument-handlers"
|
#define COMMAND_LINE_ARGUMENT_HANDLERS "command-line-argument-handlers"
|
||||||
|
#define PREF_STARTUP_PREFIX "general.startup."
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIComponentManager.h"
|
#include "nsIComponentManager.h"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче