зеркало из https://github.com/mozilla/pjs.git
fix for #36663. make it so when you run a news://host/group url to autosubscribe, a new messenger window opens up. eventually I'll heed the 4.x pref for
this, so that it will open in an existing messenger window.
This commit is contained in:
Родитель
bb5271913c
Коммит
9cc3b222b0
|
@ -53,6 +53,7 @@ EXTRA_DSO_LDOPTS = \
|
|||
$(MOZ_TIMER_LIBS) \
|
||||
-L$(DIST)/bin \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ CPP_OBJS= \
|
|||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\js32$(VERSION_NUMBER).lib \
|
||||
$(DIST)\lib\msgbsutl.lib \
|
||||
$(DIST)\lib\msgbase_s.lib \
|
||||
$(DIST)\lib\msgsearch_s.lib \
|
||||
|
|
|
@ -240,6 +240,11 @@
|
|||
"component://netscape/appshell/component/messenger"
|
||||
#define NS_MAILSTARTUPHANDLER_PROGID \
|
||||
"component://netscape/commandlinehandler/general-startup-mail"
|
||||
#define NS_MESSENGERWINDOWSERVICE_PROGID \
|
||||
"component://netscape/messenger/windowservice"
|
||||
#define NS_MESSENGERWINDOWSERVICE_CID \
|
||||
{ 0xa01b6724, 0x1dd1, 0x11b2, \
|
||||
{0xaa, 0xb9, 0x82,0xf2, 0x4c,0x59, 0x5f, 0x41} }
|
||||
|
||||
//
|
||||
// nsMessenger
|
||||
|
|
|
@ -117,6 +117,10 @@ static nsModuleComponentInfo gComponents[] = {
|
|||
NS_MESSENGERBOOTSTRAP_PROGID,
|
||||
nsMessengerBootstrapConstructor,
|
||||
},
|
||||
{ "Netscape Messenger Window Service", NS_MESSENGERWINDOWSERVICE_CID,
|
||||
NS_MESSENGERWINDOWSERVICE_PROGID,
|
||||
nsMessengerBootstrapConstructor,
|
||||
},
|
||||
{ "Mail Startup Handler", NS_MESSENGERBOOTSTRAP_CID,
|
||||
NS_MAILSTARTUPHANDLER_PROGID,
|
||||
nsMessengerBootstrapConstructor,
|
||||
|
|
|
@ -72,6 +72,7 @@ XPIDLSRCS = \
|
|||
nsIIncomingServerListener.idl \
|
||||
nsIMsgHdr.idl \
|
||||
nsIMessengerMigrator.idl \
|
||||
nsIMessengerWindowService.idl \
|
||||
nsIMsgStringService.idl \
|
||||
nsIMsgViewNavigationService.idl \
|
||||
nsIMsgPrintEngine.idl \
|
||||
|
|
|
@ -33,6 +33,7 @@ XPIDLSRCS = \
|
|||
.\nsIMsgAccount.idl \
|
||||
.\nsIMsgAccountManager.idl \
|
||||
.\nsIMessengerMigrator.idl \
|
||||
.\nsIMessengerWindowService.idl \
|
||||
.\nsIMsgFolder.idl \
|
||||
.\nsIMsgFolderCache.idl \
|
||||
.\nsIMsgFolderCacheElement.idl \
|
||||
|
|
|
@ -29,7 +29,12 @@
|
|||
#include "nsIMsgMailSession.h"
|
||||
#include "nsIMsgFolderCache.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
static NS_DEFINE_CID(kMsgAccountManagerCID, NS_MSGACCOUNTMANAGER_CID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
@ -37,7 +42,7 @@ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
|||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsMessengerBootstrap);
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsMessengerBootstrap);
|
||||
NS_IMPL_QUERY_INTERFACE2(nsMessengerBootstrap, nsIAppShellComponent, nsICmdLineHandler);
|
||||
NS_IMPL_QUERY_INTERFACE3(nsMessengerBootstrap, nsIAppShellComponent, nsICmdLineHandler, nsIMessengerWindowService);
|
||||
|
||||
nsMessengerBootstrap::nsMessengerBootstrap()
|
||||
{
|
||||
|
@ -101,3 +106,57 @@ NS_IMETHODIMP nsMessengerBootstrap::GetChromeUrlForTask(char **aChromeUrlForTask
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Utility function to open a messenger window and pass an argument string to it.
|
||||
static nsresult openWindow( const PRUnichar *chrome, const PRUnichar *args ) {
|
||||
nsCOMPtr<nsIDOMWindow> hiddenWindow;
|
||||
JSContext *jsContext;
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE( nsIAppShellService, appShell, kAppShellServiceCID, &rv )
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
rv = appShell->GetHiddenWindowAndJSContext( getter_AddRefs( hiddenWindow ),
|
||||
&jsContext );
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
// Set up arguments for "window.openDialog"
|
||||
void *stackPtr;
|
||||
jsval *argv = JS_PushArguments( jsContext,
|
||||
&stackPtr,
|
||||
"WssW",
|
||||
chrome,
|
||||
"_blank",
|
||||
"chrome,dialog=no,all",
|
||||
args );
|
||||
if ( argv ) {
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = hiddenWindow->OpenDialog( jsContext,
|
||||
argv,
|
||||
4,
|
||||
getter_AddRefs( newWindow ) );
|
||||
JS_PopArguments( jsContext, stackPtr );
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessengerBootstrap::OpenMessengerWindowWithUri(nsIURI *aURI)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsXPIDLCString args;
|
||||
nsXPIDLCString chromeurl;
|
||||
|
||||
if (!aURI) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = aURI->GetSpec(getter_Copies(args));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = GetChromeUrlForTask(getter_Copies(chromeurl));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// we need to use the "mailnews.reuse_thread_window2" pref
|
||||
// to determine if we should open a new window, or use an existing one.
|
||||
rv = openWindow(nsString(chromeurl).GetUnicode(),nsString(args).GetUnicode());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "nsIAppShellService.h"
|
||||
#include "nsIAppShellComponent.h"
|
||||
#include "nsICmdLineHandler.h"
|
||||
#include "nsIMessengerWindowService.h"
|
||||
|
||||
#define NS_MESSENGERBOOTSTRAP_CID \
|
||||
{ /* 4a85a5d0-cddd-11d2-b7f6-00805f05ffa5 */ \
|
||||
|
@ -36,7 +37,7 @@
|
|||
{0xb7, 0xf6, 0x00, 0x80, 0x5f, 0x05, 0xff, 0xa5}}
|
||||
|
||||
|
||||
class nsMessengerBootstrap : public nsIAppShellComponent, public nsICmdLineHandler {
|
||||
class nsMessengerBootstrap : public nsIAppShellComponent, public nsICmdLineHandler, public nsIMessengerWindowService {
|
||||
|
||||
public:
|
||||
nsMessengerBootstrap();
|
||||
|
@ -45,6 +46,7 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIAPPSHELLCOMPONENT
|
||||
NS_DECL_NSICMDLINEHANDLER
|
||||
NS_DECL_NSIMESSENGERWINDOWSERVICE
|
||||
CMDLINEHANDLER_REGISTERPROC_DECLS
|
||||
|
||||
};
|
||||
|
|
|
@ -353,19 +353,15 @@ NS_IMETHODIMP nsMsgComposeService::HandleContent(const char * aContentType, cons
|
|||
const char * aWindowTarget, nsISupports * aWindowContext, nsIChannel * aChannel)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (aChannel)
|
||||
{
|
||||
// First of all, get the content type and make sure it is a content type we know how to handle!
|
||||
if (nsCRT::strcasecmp(aContentType, "x-application-mailto") == 0)
|
||||
{
|
||||
if (!aChannel) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// First of all, get the content type and make sure it is a content type we know how to handle!
|
||||
if (nsCRT::strcasecmp(aContentType, "x-application-mailto") == 0) {
|
||||
nsCOMPtr<nsIURI> aUri;
|
||||
rv = aChannel->GetURI(getter_AddRefs(aUri));
|
||||
if (aUri)
|
||||
rv = OpenComposeWindowWithURI(nsnull, aUri);
|
||||
}
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
#include "nsNNTPNewsgroupList.h"
|
||||
#include "nsNNTPArticleList.h"
|
||||
#include "nsNNTPHost.h"
|
||||
#include "nsIContentHandler.h"
|
||||
#include "nsCURILoader.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNntpUrl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNntpService)
|
||||
|
@ -93,6 +95,10 @@ static nsModuleComponentInfo components[] =
|
|||
NS_NNTPSERVICE_CID,
|
||||
NS_SNEWSPROTOCOLHANDLER_PROGID,
|
||||
nsNntpServiceConstructor },
|
||||
{ "newsgroup content handler",
|
||||
NS_NNTPSERVICE_CID,
|
||||
NS_CONTENT_HANDLER_PROGID_PREFIX"x-application-newsgroup",
|
||||
nsNntpServiceConstructor },
|
||||
{ "News Folder Resource",
|
||||
NS_NEWSFOLDERRESOURCE_CID,
|
||||
NS_NEWSFOLDERRESOURCE_PROGID,
|
||||
|
|
|
@ -1062,20 +1062,18 @@ nsresult nsNNTPProtocol::ParseURL(nsIURI * aURL, PRBool * bValP, char ** aGroup,
|
|||
char ** aCommandSpecificData)
|
||||
{
|
||||
PRInt32 status = 0;
|
||||
char *fullPath = 0;
|
||||
nsXPIDLCString fullPath;
|
||||
char *group = 0;
|
||||
char *message_id = 0;
|
||||
char *command_specific_data = 0;
|
||||
char * s = 0;
|
||||
|
||||
// get the file path part and store it as the group...
|
||||
aURL->GetPath(&fullPath);
|
||||
if (fullPath && *fullPath == '/')
|
||||
group = PL_strdup(fullPath+1);
|
||||
aURL->GetPath(getter_Copies(fullPath));
|
||||
if ((const char *)fullPath && ((*(const char *)fullPath) == '/'))
|
||||
group = PL_strdup((const char *)fullPath+1);
|
||||
else
|
||||
group = PL_strdup(fullPath);
|
||||
|
||||
nsAllocator::Free(fullPath);
|
||||
group = PL_strdup((const char *)fullPath);
|
||||
|
||||
// more to do here, but for now, this works.
|
||||
// only escape if we are doing a search
|
||||
|
@ -5049,3 +5047,14 @@ nsNNTPProtocol::SetProgressStatus(char *message)
|
|||
}
|
||||
PR_FREEIF(progressMsg);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsNNTPProtocol::GetContentType(char * *aContentType)
|
||||
{
|
||||
if ((const char *)m_currentGroup && nsCRT::strlen((const char *)m_currentGroup)) {
|
||||
*aContentType = nsCRT::strdup("x-application-newsgroup");
|
||||
}
|
||||
else {
|
||||
*aContentType = nsCRT::strdup("message/rfc822");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -161,6 +161,7 @@ public:
|
|||
char * m_ProxyServer; /* proxy server hostname */
|
||||
|
||||
NS_IMETHOD Cancel(nsresult status); // handle stop button
|
||||
NS_IMETHOD GetContentType(char * *aContentType);
|
||||
|
||||
nsresult LoadUrl(nsIURI * aURL, nsISupports * aConsumer);
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "nsICmdLineHandler.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIMessengerWindowService.h"
|
||||
|
||||
#undef GetPort // XXX Windows!
|
||||
#undef SetPort // XXX Windows!
|
||||
|
@ -84,12 +85,13 @@ nsNntpService::~nsNntpService()
|
|||
NS_IMPL_THREADSAFE_ADDREF(nsNntpService);
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsNntpService);
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE5(nsNntpService,
|
||||
NS_IMPL_QUERY_INTERFACE6(nsNntpService,
|
||||
nsINntpService,
|
||||
nsIMsgMessageService,
|
||||
nsIProtocolHandler,
|
||||
nsIMsgProtocolInfo,
|
||||
nsICmdLineHandler)
|
||||
nsICmdLineHandler,
|
||||
nsIContentHandler)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIMsgMessageService support
|
||||
|
@ -1349,3 +1351,27 @@ NS_IMETHODIMP nsNntpService::GetChromeUrlForTask(char **aChromeUrlForTask)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::HandleContent(const char * aContentType, const char * aCommand, const char * aWindowTarget, nsISupports * aWindowContext, nsIChannel * aChannel)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (!aChannel) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (nsCRT::strcasecmp(aContentType, "x-application-newsgroup") == 0) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = aChannel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (uri) {
|
||||
nsCOMPtr <nsIMessengerWindowService> messengerWindowService = do_GetService(NS_MESSENGERWINDOWSERVICE_PROGID,&rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = messengerWindowService->OpenMessengerWindowWithUri(uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "nsINntpUrl.h"
|
||||
#include "nsICmdLineHandler.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContentHandler.h"
|
||||
|
||||
class nsIURI;
|
||||
class nsIUrlListener;
|
||||
|
@ -43,7 +44,8 @@ class nsNntpService : public nsINntpService,
|
|||
public nsIMsgMessageService,
|
||||
public nsIProtocolHandler,
|
||||
public nsIMsgProtocolInfo,
|
||||
public nsICmdLineHandler
|
||||
public nsICmdLineHandler,
|
||||
public nsIContentHandler
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -53,6 +55,7 @@ public:
|
|||
NS_DECL_NSIPROTOCOLHANDLER
|
||||
NS_DECL_NSIMSGPROTOCOLINFO
|
||||
NS_DECL_NSICMDLINEHANDLER
|
||||
NS_DECL_NSICONTENTHANDLER
|
||||
|
||||
// nsNntpService
|
||||
nsNntpService();
|
||||
|
|
Загрузка…
Ссылка в новой задаче