зеркало из https://github.com/mozilla/pjs.git
Killing the messenger appcore once and for all.
Don't be frightened by the size of this checkin, most of the appcore conversion to XPConnect was fairly simple. Some of this is just fixing code that depended on the old appcore
This commit is contained in:
Родитель
c6829970ad
Коммит
1f5093e97a
|
@ -46,10 +46,7 @@ EXTRA_DSO_LDOPTS = \
|
|||
$(NSPR_LIBS) \
|
||||
-lxpcom \
|
||||
-lreg \
|
||||
-lmozjs \
|
||||
-lmsgbaseutil \
|
||||
-lappcores \
|
||||
-ljsdom \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -82,10 +82,8 @@ LLIBS= \
|
|||
$(MSGLIBS) \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(DIST)\lib\js32$(VERSION_NUMBER).lib \
|
||||
$(DIST)\lib\msgcoreutil.lib \
|
||||
$(DIST)\lib\msgcore.lib \
|
||||
$(DIST)\lib\appcores.lib \
|
||||
$(DIST)\lib\netlib.lib \
|
||||
$(DIST)\lib\raptorgfxwin.lib \
|
||||
$(LIBNSPR) \
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
#include "nsCRT.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsMessengerBootstrap.h"
|
||||
#include "nsMessenger.h"
|
||||
#include "nsMsgGroupRecord.h"
|
||||
|
||||
#include "nsMsgAppCore.h"
|
||||
|
||||
/* Include all of the interfaces our factory can generate components for */
|
||||
|
||||
|
@ -64,7 +64,7 @@ static NS_DEFINE_CID(kCMessengerBootstrapCID, NS_MESSENGERBOOTSTRAP_CID);
|
|||
|
||||
static NS_DEFINE_CID(kCMsgFolderEventCID, NS_MSGFOLDEREVENT_CID);
|
||||
|
||||
static NS_DEFINE_CID(kCMsgAppCoreCID, NS_MSGAPPCORE_CID);
|
||||
static NS_DEFINE_CID(kCMessengerCID, NS_MESSENGER_CID);
|
||||
static NS_DEFINE_CID(kCMsgGroupRecordCID, NS_MSGGROUPRECORD_CID);
|
||||
|
||||
static NS_DEFINE_CID(kMailNewsFolderDataSourceCID, NS_MAILNEWSFOLDERDATASOURCE_CID);
|
||||
|
@ -209,9 +209,9 @@ nsMsgFactory::CreateInstance(nsISupports * /* aOuter */,
|
|||
delete session;
|
||||
}
|
||||
}
|
||||
else if (mClassID.Equals(kCMsgAppCoreCID))
|
||||
else if (mClassID.Equals(kCMessengerCID))
|
||||
{
|
||||
rv = NS_NewMsgAppCore(aIID, aResult);
|
||||
rv = NS_NewMessenger(aIID, aResult);
|
||||
}
|
||||
|
||||
else if (mClassID.Equals(kMsgAccountManagerCID))
|
||||
|
@ -366,9 +366,9 @@ NSRegisterSelf(nsISupports* aServMgr, const char* path)
|
|||
PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = compMgr->RegisterComponent(kCMsgAppCoreCID,
|
||||
"Messenger AppCore",
|
||||
"component://netscape/appcores/messenger",
|
||||
rv = compMgr->RegisterComponent(kCMessengerCID,
|
||||
"Messenger DOM interaction object",
|
||||
"component://netscape/messenger",
|
||||
path,
|
||||
PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
|
||||
nsIUrlListener.idl
|
||||
nsIMsgGroupRecord.idl
|
||||
nsIDOMMsgAppCore.idl
|
||||
nsIMessenger.idl
|
||||
#nsIMsgMailNewsUrl.idl
|
||||
|
|
|
@ -24,7 +24,7 @@ MODULE = mailnews
|
|||
include $(DEPTH)/config/autoconf.mk
|
||||
XPIDLSRCS = \
|
||||
nsICopyMessageListener.idl \
|
||||
nsIDOMMsgAppCore.idl \
|
||||
nsIMessenger.idl \
|
||||
nsIFolder.idl \
|
||||
nsIFolderListener.idl \
|
||||
nsIMessage.idl \
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
DEPTH=..\..\..
|
||||
XPIDLSRCS = \
|
||||
.\nsIMessenger.idl \
|
||||
.\nsICopyMessageListener.idl \
|
||||
.\nsIFolder.idl \
|
||||
.\nsIFolderListener.idl \
|
||||
|
@ -53,7 +54,6 @@ EXPORTS = \
|
|||
nsIFolderListener.h \
|
||||
nsIMsgMailSession.h \
|
||||
nsIMsgIdentity.h \
|
||||
nsIDOMMsgAppCore.h \
|
||||
nsIMsgGroupRecord.h \
|
||||
nsICopyMessageListener.h \
|
||||
nsIMessageView.h \
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
var msgAppCore;
|
||||
var messenger = Components.classes['component://netscape/messenger'].createInstance();
|
||||
messenger = messenger.QueryInterface(Components.interfaces.nsIMessenger);
|
||||
|
||||
var composeAppCore;
|
||||
|
||||
var RDF = Components.classes['component://netscape/rdf/rdf-service'].getService();
|
||||
|
@ -11,29 +13,22 @@ function GetFolderTree()
|
|||
return folderTree;
|
||||
}
|
||||
|
||||
function FindMsgAppCore()
|
||||
function FindMessenger()
|
||||
{
|
||||
msgAppCore = XPAppCoresManager.Find("MsgAppCore");
|
||||
if (msgAppCore == null) {
|
||||
dump("FindMsgAppCore: Creating AppCore\n");
|
||||
msgAppCore = new MsgAppCore();
|
||||
dump("Initializing MsgAppCore and setting Window\n");
|
||||
msgAppCore.Init("MsgAppCore");
|
||||
}
|
||||
return msgAppCore;
|
||||
return messenger;
|
||||
}
|
||||
|
||||
function OpenURL(url)
|
||||
{
|
||||
dump("\n\nOpenURL from XUL\n\n\n");
|
||||
var appCore = FindMsgAppCore();
|
||||
var appCore = FindMessenger();
|
||||
if (appCore != null) {
|
||||
appCore.SetWindow(window);
|
||||
appCore.OpenURL(url);
|
||||
}
|
||||
}
|
||||
|
||||
function ComposeMessage(tree, nodeList, msgAppCore, type)
|
||||
function ComposeMessage(tree, nodeList, messenger, type)
|
||||
{
|
||||
dump("\nComposeMessage from XUL\n");
|
||||
|
||||
|
@ -53,7 +48,7 @@ function ComposeMessage(tree, nodeList, msgAppCore, type)
|
|||
// name=<name of the appcore>
|
||||
// editorType=[default | html | text] ; default means use the prefs value send_html
|
||||
var args = "name=" + composeAppCoreName + ",editorType=default";
|
||||
composeAppCore.NewMessage("chrome://messengercompose/content/", args, tree, nodeList, msgAppCore, type);
|
||||
composeAppCore.NewMessage("chrome://messengercompose/content/", args, tree, nodeList, type);
|
||||
dump("Created a compose appcore from Messenger, " + args);
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +69,7 @@ function GetNewMessages()
|
|||
{
|
||||
var selectedFolder = selectedFolderList[0];
|
||||
|
||||
var appCore = FindMsgAppCore();
|
||||
var appCore = FindMessenger();
|
||||
if (appCore != null) {
|
||||
appCore.SetWindow(window);
|
||||
appCore.GetNewMessages(folderTree.database, selectedFolder);
|
||||
|
@ -87,7 +82,7 @@ function GetNewMessages()
|
|||
|
||||
function MsgAccountManager()
|
||||
{
|
||||
var appCore = FindMsgAppCore();
|
||||
var appCore = FindMessenger();
|
||||
if (appCore != null) {
|
||||
dump('Opening account manager..\n');
|
||||
appCore.AccountManager(window);
|
||||
|
@ -126,7 +121,7 @@ function ComposeMessageWithType(type)
|
|||
if(tree) {
|
||||
dump("tree is valid\n");
|
||||
var nodeList = tree.getElementsByAttribute("selected", "true");
|
||||
var appCore = FindMsgAppCore();
|
||||
var appCore = FindMessenger();
|
||||
dump("message type ");
|
||||
dump(type);
|
||||
dump("\n");
|
||||
|
|
|
@ -27,10 +27,10 @@ LIBRARY_NAME=mailnewsbase_s
|
|||
|
||||
EXPORTS = \
|
||||
nsMessenger.h \
|
||||
nsMessengerBootstrap.h \
|
||||
nsMsgKeyArray.h \
|
||||
nsUrlListenerManager.h \
|
||||
nsMsgMailSession.h \
|
||||
nsMsgAppCore.h \
|
||||
nsMsgAccountManager.h \
|
||||
nsMsgAccount.h \
|
||||
nsMsgFolderDataSource.h \
|
||||
|
@ -46,12 +46,10 @@ EXPORTS = \
|
|||
|
||||
CPPSRCS = \
|
||||
nsMessenger.cpp \
|
||||
nsMessengerNameSet.cpp \
|
||||
nsMessengerBootstrap.cpp \
|
||||
nsMsgKeyArray.cpp \
|
||||
nsUrlListenerManager.cpp \
|
||||
nsMsgMailSession.cpp \
|
||||
nsMsgAppCore.cpp \
|
||||
nsJSMsgAppCore.cpp \
|
||||
nsMsgMD5.cpp \
|
||||
nsMsgAccountManager.cpp \
|
||||
nsMsgAccount.cpp \
|
||||
|
|
|
@ -28,12 +28,10 @@ DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
|||
|
||||
CPPSRCS= \
|
||||
nsMessenger.cpp \
|
||||
nsMessengerNameSet.cpp \
|
||||
nsMessengerBootstrap.cpp \
|
||||
nsMsgKeyArray.cpp \
|
||||
nsUrlListenerManager.cpp \
|
||||
nsMsgMailSession.cpp \
|
||||
nsJSMsgAppCore.cpp \
|
||||
nsMsgAppCore.cpp \
|
||||
nsCopyMessageStreamListener.cpp \
|
||||
nsMessageViewDataSource.cpp \
|
||||
nsMsgAccountManager.cpp \
|
||||
|
@ -53,12 +51,10 @@ CPPSRCS= \
|
|||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsMessenger.obj \
|
||||
.\$(OBJDIR)\nsMessengerNameSet.obj \
|
||||
.\$(OBJDIR)\nsMessengerBootstrap.obj \
|
||||
.\$(OBJDIR)\nsMsgKeyArray.obj \
|
||||
.\$(OBJDIR)\nsUrlListenerManager.obj \
|
||||
.\$(OBJDIR)\nsMsgMailSession.obj \
|
||||
.\$(OBJDIR)\nsMsgAppCore.obj \
|
||||
.\$(OBJDIR)\nsJSMsgAppCore.obj \
|
||||
.\$(OBJDIR)\nsCopyMessageStreamListener.obj \
|
||||
.\$(OBJDIR)\nsMessageViewDataSource.obj \
|
||||
.\$(OBJDIR)\nsMsgAccountManager.obj \
|
||||
|
@ -77,10 +73,10 @@ CPP_OBJS= \
|
|||
|
||||
EXPORTS= \
|
||||
nsMessenger.h \
|
||||
nsMessengerBootstrap.h \
|
||||
nsMsgKeyArray.h \
|
||||
nsUrlListenerManager.h \
|
||||
nsMsgMailSession.h \
|
||||
nsMsgAppCore.h \
|
||||
nsMsgFolderDataSource.h \
|
||||
nsMsgMessageDataSource.h \
|
||||
nsMessageViewDataSource.h \
|
||||
|
|
|
@ -16,78 +16,761 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "prsystem.h"
|
||||
|
||||
#include "nsIMessenger.h"
|
||||
#include "nsMessenger.h"
|
||||
#include "nsIAppShellComponent.h"
|
||||
|
||||
/* rhp - for access to webshell */
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsMessengerNameSet.h"
|
||||
#include "nsIScriptNameSetRegistry.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDocumentViewer.h"
|
||||
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsIMsgMailSession.h"
|
||||
#include "nsIMsgIncomingServer.h"
|
||||
#include "nsIPop3IncomingServer.h"
|
||||
#include "nsIMsgMessageService.h"
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
static NS_DEFINE_IID(kCScriptNameSetRegistryCID, NS_SCRIPT_NAMESET_REGISTRY_CID);
|
||||
#include "nsIMessage.h"
|
||||
#include "nsIMsgFolder.h"
|
||||
#include "nsIPop3Service.h"
|
||||
|
||||
class nsMessengerBootstrap : public nsIAppShellComponent {
|
||||
#include "nsIDOMXULTreeElement.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsMsgRDFUtils.h"
|
||||
|
||||
#include "nsINetService.h"
|
||||
#include "nsCopyMessageStreamListener.h"
|
||||
#include "nsICopyMessageListener.h"
|
||||
|
||||
#include "nsIMessageView.h"
|
||||
|
||||
#include "nsMsgUtils.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsMsgLocalCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
static NS_DEFINE_CID(kCPop3ServiceCID, NS_POP3SERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
|
||||
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
|
||||
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
|
||||
// we need this because of an egcs 1.0 (and possibly gcc) compiler bug
|
||||
// that doesn't allow you to call ::nsISupports::GetIID() inside of a class
|
||||
// that multiply inherits from nsISupports
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
class nsMessenger : public nsIMessenger
|
||||
{
|
||||
|
||||
public:
|
||||
nsMessengerBootstrap();
|
||||
virtual ~nsMessengerBootstrap();
|
||||
|
||||
nsMessenger();
|
||||
virtual ~nsMessenger();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_IAPPSHELLCOMPONENT
|
||||
// nsIMessenger
|
||||
NS_IMETHOD Open3PaneWindow();
|
||||
NS_IMETHOD GetNewMessages(nsIRDFCompositeDataSource *db, nsIDOMXULElement *folderElement);
|
||||
NS_IMETHOD SetWindow(nsIDOMWindow* aWin);
|
||||
NS_IMETHOD OpenURL(const char * url);
|
||||
NS_IMETHOD DeleteMessages(nsIDOMXULTreeElement *tree, nsIDOMXULElement *srcFolderElement, nsIDOMNodeList *nodeList);
|
||||
NS_IMETHOD DeleteFolders(nsIRDFCompositeDataSource *db, nsIDOMXULElement *parentFolder, nsIDOMXULElement *folder);
|
||||
|
||||
NS_IMETHOD CopyMessages(nsIDOMXULElement *srcFolderElement, nsIDOMXULElement *folderElement, nsIDOMNodeList *nodeList,
|
||||
PRBool isMove);
|
||||
NS_IMETHOD GetRDFResourceForMessage(nsIDOMXULTreeElement *tree,
|
||||
nsIDOMNodeList *nodeList, nsISupports
|
||||
**aSupport);
|
||||
NS_IMETHOD Exit();
|
||||
NS_IMETHOD ViewAllMessages(nsIRDFCompositeDataSource *databsae);
|
||||
NS_IMETHOD ViewUnreadMessages(nsIRDFCompositeDataSource *databsae);
|
||||
NS_IMETHOD ViewAllThreadMessages(nsIRDFCompositeDataSource *database);
|
||||
NS_IMETHOD MarkMessagesRead(nsIRDFCompositeDataSource *database, nsIDOMNodeList *messages, PRBool markRead);
|
||||
|
||||
NS_IMETHOD NewFolder(nsIRDFCompositeDataSource *database, nsIDOMXULElement *parentFolderElement,
|
||||
const char *name);
|
||||
NS_IMETHOD AccountManager(nsIDOMWindow *parent);
|
||||
|
||||
protected:
|
||||
nsresult DoDelete(nsIRDFCompositeDataSource* db, nsISupportsArray *srcArray, nsISupportsArray *deletedArray);
|
||||
nsresult DoCommand(nsIRDFCompositeDataSource *db, char * command, nsISupportsArray *srcArray,
|
||||
nsISupportsArray *arguments);
|
||||
private:
|
||||
|
||||
nsString mId;
|
||||
void *mScriptObject;
|
||||
|
||||
/* rhp - need this to drive message display */
|
||||
nsIDOMWindow *mWindow;
|
||||
nsIWebShell *mWebShell;
|
||||
|
||||
// mscott: temporary variable used to support running urls through the 'Demo' menu....
|
||||
nsFileSpec m_folderPath;
|
||||
void InitializeFolderRoot();
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsMessengerBootstrap, nsIAppShellComponent::GetIID())
|
||||
|
||||
nsMessengerBootstrap::nsMessengerBootstrap()
|
||||
static nsresult ConvertDOMListToResourceArray(nsIDOMNodeList *nodeList, nsISupportsArray **resourceArray)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 listLength;
|
||||
nsIDOMNode *node;
|
||||
nsIDOMXULTreeElement *xulElement;
|
||||
nsIRDFResource *resource;
|
||||
|
||||
if(!resourceArray)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if(NS_FAILED(rv = nodeList->GetLength(&listLength)))
|
||||
return rv;
|
||||
|
||||
if(NS_FAILED(NS_NewISupportsArray(resourceArray)))
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for(PRUint32 i = 0; i < listLength; i++)
|
||||
{
|
||||
if(NS_FAILED(nodeList->Item(i, &node)))
|
||||
return rv;
|
||||
|
||||
if(NS_SUCCEEDED(rv = node->QueryInterface(nsIDOMXULElement::GetIID(), (void**)&xulElement)))
|
||||
{
|
||||
if(NS_SUCCEEDED(rv = xulElement->GetResource(&resource)))
|
||||
{
|
||||
(*resourceArray)->AppendElement(resource);
|
||||
NS_RELEASE(resource);
|
||||
}
|
||||
NS_RELEASE(xulElement);
|
||||
}
|
||||
NS_RELEASE(node);
|
||||
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsMessengerBootstrap::~nsMessengerBootstrap()
|
||||
static nsresult AddView(nsIRDFCompositeDataSource *database, nsIMessageView **messageView)
|
||||
{
|
||||
if(!messageView || !database)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIRDFService* gRDFService = nsnull;
|
||||
nsIRDFDataSource *view, *datasource;
|
||||
nsresult rv;
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &gRDFService);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = gRDFService->GetDataSource("rdf:mail-messageview", &view);
|
||||
rv = NS_SUCCEEDED(rv) && gRDFService->GetDataSource("rdf:mailnewsfolders", &datasource);
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
|
||||
}
|
||||
|
||||
if(!NS_SUCCEEDED(rv))
|
||||
return rv;
|
||||
|
||||
database->RemoveDataSource(datasource);
|
||||
//This is a hack until I have the ability to save off my current view some place.
|
||||
//In case it's already been added, remove it. We'll need to do the same for the
|
||||
//thread view.
|
||||
database->RemoveDataSource(view);
|
||||
database->AddDataSource(view);
|
||||
|
||||
//add the datasource
|
||||
//return the view as an nsIMessageView
|
||||
nsIRDFCompositeDataSource *viewCompositeDataSource;
|
||||
if(NS_SUCCEEDED(view->QueryInterface(nsIRDFCompositeDataSource::GetIID(), (void**)&viewCompositeDataSource)))
|
||||
{
|
||||
viewCompositeDataSource->AddDataSource(datasource);
|
||||
NS_IF_RELEASE(viewCompositeDataSource);
|
||||
}
|
||||
rv = view->QueryInterface(nsIMessageView::GetIID(), (void**)messageView);
|
||||
|
||||
NS_IF_RELEASE(view);
|
||||
NS_IF_RELEASE(datasource);
|
||||
|
||||
return rv;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// nsMessenger
|
||||
//
|
||||
nsMessenger::nsMessenger() : m_folderPath("")
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mScriptObject = nsnull;
|
||||
mWebShell = nsnull;
|
||||
mWindow = nsnull;
|
||||
|
||||
InitializeFolderRoot();
|
||||
}
|
||||
|
||||
nsMessenger::~nsMessenger()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// nsISupports
|
||||
//
|
||||
NS_IMPL_ISUPPORTS(nsMessenger, nsIMessenger::GetIID())
|
||||
|
||||
//
|
||||
// nsIMsgAppCore
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::Open3PaneWindow()
|
||||
{
|
||||
nsIAppShellService* appShell;
|
||||
char * urlstr=nsnull;
|
||||
nsresult rv;
|
||||
|
||||
urlstr = "resource:/res/samples/messenger.html";
|
||||
rv = nsServiceManager::GetService(kAppShellServiceCID,
|
||||
nsIAppShellService::GetIID(),
|
||||
(nsISupports**)&appShell);
|
||||
|
||||
nsIURL* url = nsnull;
|
||||
nsINetService * pNetService;
|
||||
rv = nsServiceManager::GetService(kNetServiceCID, nsINetService::GetIID(), (nsISupports **)&pNetService);
|
||||
if (NS_SUCCEEDED(rv) && pNetService) {
|
||||
rv = pNetService->CreateURL(&url, urlstr);
|
||||
NS_RELEASE(pNetService);
|
||||
if (NS_FAILED(rv))
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
goto done;
|
||||
|
||||
|
||||
nsIWebShellWindow* newWindow;
|
||||
appShell->CreateTopLevelWindow(nsnull, // parent
|
||||
url,
|
||||
PR_TRUE,
|
||||
newWindow, // result widget
|
||||
nsnull, // observer
|
||||
nsnull, // callbacks
|
||||
200, // width
|
||||
200); // height
|
||||
done:
|
||||
NS_RELEASE(url);
|
||||
if (nsnull != appShell) {
|
||||
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMessengerBootstrap::Initialize(nsIAppShellService*,
|
||||
nsICmdLineService*)
|
||||
nsMessenger::GetNewMessages(nsIRDFCompositeDataSource *db, nsIDOMXULElement *folderElement)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> folderResource;
|
||||
nsCOMPtr<nsISupportsArray> folderArray;
|
||||
|
||||
printf("Messenger has been bootstrapped!\n");
|
||||
NS_WITH_SERVICE(nsIScriptNameSetRegistry, registry, kCScriptNameSetRegistryCID, &rv);
|
||||
if(!folderElement || !db)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsMessengerNameSet* nameSet = new nsMessengerNameSet();
|
||||
|
||||
if (nameSet == nsnull)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = folderElement->GetResource(getter_AddRefs(folderResource));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if(NS_FAILED(NS_NewISupportsArray(getter_AddRefs(folderArray))))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
folderArray->AppendElement(folderResource);
|
||||
|
||||
DoCommand(db, NC_RDF_GETNEWMESSAGES, folderArray, nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
nsresult
|
||||
NS_NewMessenger(const nsIID &aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsMessenger *appcore = new nsMessenger();
|
||||
if (appcore)
|
||||
return appcore->QueryInterface(aIID, (void **)aResult);
|
||||
else
|
||||
rv = registry->AddExternalNameSet(nameSet);
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::SetWindow(nsIDOMWindow* aWin)
|
||||
{
|
||||
if(!aWin)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsAutoString webShellName("browser.webwindow");
|
||||
mWindow = aWin;
|
||||
NS_ADDREF(aWin);
|
||||
|
||||
/* rhp - Needed to access the webshell to drive message display */
|
||||
printf("nsMessenger::SetWindow(): Getting the webShell of interest...\n");
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj( do_QueryInterface(aWin) );
|
||||
if (!globalObj)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsIWebShell *webShell = nsnull;
|
||||
nsIWebShell *rootWebShell = nsnull;
|
||||
|
||||
globalObj->GetWebShell(&webShell);
|
||||
if (nsnull == webShell)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
webShell->GetRootWebShell(rootWebShell);
|
||||
if (nsnull != rootWebShell)
|
||||
{
|
||||
rootWebShell->FindChildWithName(webShellName.GetUnicode(), mWebShell);
|
||||
#ifdef NS_DEBUG
|
||||
if (nsnull != mWebShell)
|
||||
printf("nsMessenger::SetWindow(): Got the webShell %s.\n", (const char *) nsAutoCString(webShellName));
|
||||
else
|
||||
printf("nsMessenger::SetWindow(): Failed to find webshell %s.\n", (const char *) nsAutoCString(webShellName));
|
||||
#endif
|
||||
NS_RELEASE(rootWebShell);
|
||||
}
|
||||
|
||||
NS_RELEASE(webShell);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// this should really go through all the pop servers and initialize all
|
||||
// folder roots
|
||||
void nsMessenger::InitializeFolderRoot()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// get the current identity from the mail session....
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kCMsgMailSessionCID, &rv);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
rv = mailSession->GetCurrentServer(getter_AddRefs(server));
|
||||
|
||||
char * folderRoot;
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = server->GetLocalPath(&folderRoot);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// everyone should have a inbox so let's
|
||||
// tack that folder name on to the root path...
|
||||
m_folderPath = folderRoot;
|
||||
m_folderPath += "Inbox";
|
||||
} // if we have a folder root for the current server
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::OpenURL(const char * url)
|
||||
{
|
||||
if (url)
|
||||
{
|
||||
#ifdef DEBUG_sspitzer
|
||||
printf("nsMessenger::OpenURL(%s)\n",url);
|
||||
#endif
|
||||
nsIMsgMessageService * messageService = nsnull;
|
||||
nsresult rv = GetMessageServiceFromURI(url, &messageService);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && messageService)
|
||||
{
|
||||
messageService->DisplayMessage(url, mWebShell, nsnull, nsnull);
|
||||
ReleaseMessageServiceFromURI(url, messageService);
|
||||
}
|
||||
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMessengerBootstrap::Shutdown()
|
||||
nsMessenger::DoCommand(nsIRDFCompositeDataSource* db, char *command,
|
||||
nsISupportsArray *srcArray, nsISupportsArray *argumentArray)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIRDFService, rdfService, kRDFServiceCID, &rv);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> commandResource;
|
||||
rv = rdfService->GetResource(command, getter_AddRefs(commandResource));
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = db->DoCommand(srcArray, commandResource, argumentArray);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::DeleteMessages(nsIDOMXULTreeElement *tree, nsIDOMXULElement *srcFolderElement, nsIDOMNodeList *nodeList)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if(!tree || !srcFolderElement || !nodeList)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIRDFCompositeDataSource> database;
|
||||
nsCOMPtr<nsISupportsArray> resourceArray, folderArray;
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
|
||||
rv = srcFolderElement->GetResource(getter_AddRefs(resource));
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = tree->GetDatabase(getter_AddRefs(database));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv =ConvertDOMListToResourceArray(nodeList, getter_AddRefs(resourceArray));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(folderArray));
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
folderArray->AppendElement(resource);
|
||||
|
||||
rv = DoCommand(database, NC_RDF_DELETE, folderArray, resourceArray);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessenger::DeleteFolders(nsIRDFCompositeDataSource *db, nsIDOMXULElement *parentFolderElement,
|
||||
nsIDOMXULElement *folderElement)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if(!db || !parentFolderElement || !folderElement)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> parentArray, deletedArray;
|
||||
nsCOMPtr<nsIRDFResource> parentResource, deletedFolderResource;
|
||||
|
||||
rv = parentFolderElement->GetResource(getter_AddRefs(parentResource));
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = folderElement->GetResource(getter_AddRefs(deletedFolderResource));
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(parentArray));
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(deletedArray));
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
parentArray->AppendElement(parentResource);
|
||||
deletedArray->AppendElement(deletedFolderResource);
|
||||
|
||||
rv = DoCommand(db, NC_RDF_DELETE, parentArray, deletedArray);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::CopyMessages(nsIDOMXULElement *srcFolderElement, nsIDOMXULElement *dstFolderElement,
|
||||
nsIDOMNodeList *nodeList, PRBool isMove)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if(!srcFolderElement || !dstFolderElement || !nodeList)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIRDFResource *srcResource, *dstResource;
|
||||
nsICopyMessageListener *dstFolder;
|
||||
nsIMsgFolder *srcFolder;
|
||||
nsISupportsArray *resourceArray;
|
||||
|
||||
if(NS_FAILED(rv = dstFolderElement->GetResource(&dstResource)))
|
||||
return rv;
|
||||
|
||||
if(NS_FAILED(rv = dstResource->QueryInterface(nsICopyMessageListener::GetIID(), (void**)&dstFolder)))
|
||||
return rv;
|
||||
|
||||
if(NS_FAILED(rv = srcFolderElement->GetResource(&srcResource)))
|
||||
return rv;
|
||||
|
||||
if(NS_FAILED(rv = srcResource->QueryInterface(nsIMsgFolder::GetIID(), (void**)&srcFolder)))
|
||||
return rv;
|
||||
|
||||
if(NS_FAILED(rv =ConvertDOMListToResourceArray(nodeList, &resourceArray)))
|
||||
return rv;
|
||||
|
||||
//Call the mailbox service to copy first message. In the future we should call CopyMessages.
|
||||
//And even more in the future we need to distinguish between the different types of URI's, i.e.
|
||||
//local, imap, and news, and call the appropriate copy function.
|
||||
|
||||
PRUint32 cnt;
|
||||
rv = resourceArray->Count(&cnt);
|
||||
if (NS_SUCCEEDED(rv) && cnt > 0)
|
||||
{
|
||||
nsIRDFResource * firstMessage = (nsIRDFResource*)resourceArray->ElementAt(0);
|
||||
char *uri;
|
||||
firstMessage->GetValue(&uri);
|
||||
nsCopyMessageStreamListener* copyStreamListener = new nsCopyMessageStreamListener(srcFolder, dstFolder, nsnull);
|
||||
|
||||
nsIMsgMessageService * messageService = nsnull;
|
||||
rv = GetMessageServiceFromURI(uri, &messageService);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && messageService)
|
||||
{
|
||||
nsIURL * url = nsnull;
|
||||
messageService->CopyMessage(uri, copyStreamListener, isMove, nsnull, &url);
|
||||
ReleaseMessageServiceFromURI(uri, messageService);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_RELEASE(srcResource);
|
||||
NS_RELEASE(srcFolder);
|
||||
NS_RELEASE(dstResource);
|
||||
NS_RELEASE(dstFolder);
|
||||
NS_RELEASE(resourceArray);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::GetRDFResourceForMessage(nsIDOMXULTreeElement *tree,
|
||||
nsIDOMNodeList *nodeList, nsISupports
|
||||
**aSupport)
|
||||
{
|
||||
nsresult rv;
|
||||
if(!tree || !nodeList)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsISupportsArray *resourceArray;
|
||||
nsIBidirectionalEnumerator *aEnumerator = nsnull;
|
||||
*aSupport = nsnull;
|
||||
nsISupports *aItem = nsnull;
|
||||
|
||||
if(NS_FAILED(rv =ConvertDOMListToResourceArray(nodeList, &resourceArray)))
|
||||
return rv;
|
||||
|
||||
rv = NS_NewISupportsArrayEnumerator(resourceArray, &aEnumerator);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = aEnumerator->First();
|
||||
while (rv == NS_OK)
|
||||
{
|
||||
rv = aEnumerator->CurrentItem(&aItem);
|
||||
if (rv != NS_OK) break;
|
||||
rv = aItem->QueryInterface(nsIMessage::GetIID(), (void**)aSupport);
|
||||
aItem->Release();
|
||||
if (rv == NS_OK && *aSupport) break;
|
||||
rv = aEnumerator->Next();
|
||||
}
|
||||
|
||||
aEnumerator->Release();
|
||||
NS_RELEASE(resourceArray);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::Exit()
|
||||
{
|
||||
nsIAppShellService* appShell = nsnull;
|
||||
|
||||
/*
|
||||
* Create the Application Shell instance...
|
||||
*/
|
||||
nsresult rv = nsServiceManager::GetService(kAppShellServiceCID,
|
||||
nsIAppShellService::GetIID(),
|
||||
(nsISupports**)&appShell);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
appShell->Shutdown();
|
||||
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewMessengerBootstrap(const nsIID &aIID, void ** msgboot)
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::ViewAllMessages(nsIRDFCompositeDataSource *database)
|
||||
{
|
||||
if (!msgboot) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsMessengerBootstrap *bootstrap =
|
||||
new nsMessengerBootstrap();
|
||||
nsIMessageView *messageView;
|
||||
if(NS_SUCCEEDED(AddView(database, &messageView)))
|
||||
{
|
||||
messageView->SetShowAll();
|
||||
messageView->SetShowThreads(PR_FALSE);
|
||||
NS_IF_RELEASE(messageView);
|
||||
}
|
||||
|
||||
if (!bootstrap) return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
|
||||
|
||||
return bootstrap->QueryInterface(aIID, msgboot);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::ViewUnreadMessages(nsIRDFCompositeDataSource *database)
|
||||
{
|
||||
nsIMessageView *messageView;
|
||||
if(NS_SUCCEEDED(AddView(database, &messageView)))
|
||||
{
|
||||
messageView->SetShowUnread();
|
||||
messageView->SetShowThreads(PR_FALSE);
|
||||
NS_IF_RELEASE(messageView);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::ViewAllThreadMessages(nsIRDFCompositeDataSource *database)
|
||||
{
|
||||
nsIMessageView *messageView;
|
||||
if(NS_SUCCEEDED(AddView(database, &messageView)))
|
||||
{
|
||||
messageView->SetShowAll();
|
||||
messageView->SetShowThreads(PR_TRUE);
|
||||
NS_IF_RELEASE(messageView);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::MarkMessagesRead(nsIRDFCompositeDataSource *database, nsIDOMNodeList *messages, PRBool markRead)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if(!database || !messages)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> resourceArray, argumentArray;
|
||||
|
||||
|
||||
rv =ConvertDOMListToResourceArray(messages, getter_AddRefs(resourceArray));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(argumentArray));
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if(markRead)
|
||||
rv = DoCommand(database, NC_RDF_MARKREAD, resourceArray, argumentArray);
|
||||
else
|
||||
rv = DoCommand(database, NC_RDF_MARKUNREAD, resourceArray, argumentArray);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::NewFolder(nsIRDFCompositeDataSource *database, nsIDOMXULElement *parentFolderElement,
|
||||
const char *name)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> folderResource;
|
||||
nsCOMPtr<nsISupportsArray> nameArray, folderArray;
|
||||
|
||||
if(!parentFolderElement || !name)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
rv = parentFolderElement->GetResource(getter_AddRefs(folderResource));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(nameArray));
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(folderArray));
|
||||
if(NS_FAILED(rv))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
folderArray->AppendElement(folderResource);
|
||||
|
||||
NS_WITH_SERVICE(nsIRDFService, rdfService, kRDFServiceCID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsString nameStr = name;
|
||||
nsCOMPtr<nsIRDFLiteral> nameLiteral;
|
||||
|
||||
rdfService->GetLiteral(nameStr.GetUnicode(), getter_AddRefs(nameLiteral));
|
||||
nameArray->AppendElement(nameLiteral);
|
||||
rv = DoCommand(database, NC_RDF_NEWFOLDER, folderArray, nameArray);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMessenger::AccountManager(nsIDOMWindow *parent)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIURL> url;
|
||||
rv = NS_NewURL(getter_AddRefs(url),
|
||||
"chrome://messenger/content/AccountManager.xul");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIXULWindowCallbacks *cb = nsnull;
|
||||
nsIWebShellWindow* newWindow;
|
||||
rv = appShell->CreateDialogWindow(nsnull, // parent
|
||||
url, // UI url
|
||||
PR_TRUE,
|
||||
newWindow,
|
||||
nsnull, // stream observer
|
||||
cb, // callbacks
|
||||
504, 436 ); // width, height
|
||||
|
||||
if (NS_SUCCEEDED(rv) && newWindow)
|
||||
rv = newWindow->ShowModal();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// to load the webshell!
|
||||
// mWebShell->LoadURL(nsAutoString("http://www.netscape.com"),
|
||||
// nsnull, PR_TRUE, nsURLReload, 0);
|
||||
|
|
|
@ -16,28 +16,21 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef __nsMsgAppCore_h
|
||||
#define __nsMsgAppCore_h
|
||||
|
||||
#ifndef __nsMessenger_h
|
||||
#define __nsMessenger_h
|
||||
|
||||
#include "nsCom.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIAppShellService.h"
|
||||
|
||||
#define NS_MESSENGER_CID \
|
||||
{ /* 241471d0-cdda-11d2-b7f6-00805f05ffa5 */ \
|
||||
0x241471d0, 0xcdda, 0x11d2, \
|
||||
{0xb7, 0xf6, 0x00, 0x80, 0x5f, 0x05, 0xff, 0xa5}}
|
||||
|
||||
#define NS_MESSENGERBOOTSTRAP_CID \
|
||||
{ /* 4a85a5d0-cddd-11d2-b7f6-00805f05ffa5 */ \
|
||||
0x4a85a5d0, 0xcddd, 0x11d2, \
|
||||
{0xb7, 0xf6, 0x00, 0x80, 0x5f, 0x05, 0xff, 0xa5}}
|
||||
|
||||
#define NS_MESSENGER_CID \
|
||||
{ /* 3f181950-c14d-11d2-b7f2-00805f05ffa5 */ \
|
||||
0x3f181950, 0xc14d, 0x11d2, \
|
||||
{0xb7, 0xf2, 0x0, 0x80, 0x5f, 0x05, 0xff, 0xa5}}
|
||||
|
||||
NS_BEGIN_EXTERN_C
|
||||
|
||||
nsresult NS_NewMessengerBootstrap(const nsIID &aIID, void ** inst);
|
||||
nsresult
|
||||
NS_NewMessenger(const nsIID &aIID, void **);
|
||||
|
||||
NS_END_EXTERN_C
|
||||
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsMessengerBootstrap.h"
|
||||
#include "nsIAppShellComponent.h"
|
||||
|
||||
#include "nsDOMCID.h"
|
||||
|
||||
class nsMessengerBootstrap : public nsIAppShellComponent {
|
||||
|
||||
public:
|
||||
nsMessengerBootstrap();
|
||||
virtual ~nsMessengerBootstrap();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_IAPPSHELLCOMPONENT
|
||||
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsMessengerBootstrap, nsIAppShellComponent::GetIID())
|
||||
|
||||
nsMessengerBootstrap::nsMessengerBootstrap()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
}
|
||||
|
||||
nsMessengerBootstrap::~nsMessengerBootstrap()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMessengerBootstrap::Initialize(nsIAppShellService*,
|
||||
nsICmdLineService*)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMessengerBootstrap::Shutdown()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewMessengerBootstrap(const nsIID &aIID, void ** msgboot)
|
||||
{
|
||||
if (!msgboot) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsMessengerBootstrap *bootstrap =
|
||||
new nsMessengerBootstrap();
|
||||
|
||||
if (!bootstrap) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
return bootstrap->QueryInterface(aIID, msgboot);
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __nsMessenger_h
|
||||
#define __nsMessenger_h
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIAppShellService.h"
|
||||
|
||||
#define NS_MESSENGERBOOTSTRAP_CID \
|
||||
{ /* 4a85a5d0-cddd-11d2-b7f6-00805f05ffa5 */ \
|
||||
0x4a85a5d0, 0xcddd, 0x11d2, \
|
||||
{0xb7, 0xf6, 0x00, 0x80, 0x5f, 0x05, 0xff, 0xa5}}
|
||||
|
||||
|
||||
NS_BEGIN_EXTERN_C
|
||||
|
||||
nsresult NS_NewMessengerBootstrap(const nsIID &aIID, void ** inst);
|
||||
|
||||
NS_END_EXTERN_C
|
||||
|
||||
#endif
|
|
@ -21,6 +21,7 @@ VPATH = @srcdir@
|
|||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
MODULE=msgcompose
|
||||
|
||||
IDLSRCS = \
|
||||
nsIMsgCompose.idl \
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "nsID.h" /* interface nsID */
|
||||
#include "nsIDOMXULTreeElement.h" /* interface nsIDOMXULTreeElement */
|
||||
#include "nsIDOMBaseAppCore.h" /* interface nsIDOMBaseAppCore */
|
||||
#include "nsIDOMMsgAppCore.h" /* interface nsIDOMMsgAppCore */
|
||||
#include "nsIDOMNodeList.h" /* interface nsIDOMNodeList */
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
|
@ -44,8 +43,8 @@ class nsIDOMComposeAppCore : public nsIDOMBaseAppCore {
|
|||
/* void CompleteCallback (in nsAutoString script); */
|
||||
NS_IMETHOD CompleteCallback(nsAutoString& script) = 0;
|
||||
|
||||
/* void NewMessage (in nsAutoString url, in nsAutoString args, in nsIDOMXULTreeElement tree, in nsIDOMNodeList node, in nsIDOMMsgAppCore msgAppCore, in long messageType); */
|
||||
NS_IMETHOD NewMessage(nsAutoString& url, nsAutoString& args, nsIDOMXULTreeElement *tree, nsIDOMNodeList *node, nsIDOMMsgAppCore *msgAppCore, PRInt32 messageType) = 0;
|
||||
/* void NewMessage (in nsAutoString url, in nsAutoString args, in nsIDOMXULTreeElement tree, in nsIDOMNodeList node, in long messageType); */
|
||||
NS_IMETHOD NewMessage(nsAutoString& url, nsAutoString& args, nsIDOMXULTreeElement *tree, nsIDOMNodeList *node, PRInt32 messageType) = 0;
|
||||
|
||||
/* void SendMsg (in nsAutoString addrTo, in nsAutoString addrCc, in nsAutoString addrBcc, in nsAutoString newsgroup, in nsAutoString subject, in nsAutoString msg); */
|
||||
NS_IMETHOD SendMsg(nsAutoString& addrTo, nsAutoString& addrCc, nsAutoString& addrBcc, nsAutoString& newsgroup, nsAutoString& subject, nsAutoString& msg) = 0;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "nsIDOMBaseAppCore.idl"
|
||||
#include "nsIDOMWindow.idl"
|
||||
#include "nsIDOMEditorAppCore.idl"
|
||||
#include "nsIDOMMsgAppCore.idl"
|
||||
|
||||
native nsAutoString(nsAutoString&);
|
||||
|
||||
|
@ -37,7 +36,6 @@ interface nsIDOMComposeAppCore : nsIDOMBaseAppCore {
|
|||
in nsAutoString args,
|
||||
in nsIDOMXULTreeElement tree,
|
||||
in nsIDOMNodeList node,
|
||||
in nsIDOMMsgAppCore msgAppCore,
|
||||
in long messageType);
|
||||
void SendMsg(in nsAutoString addrTo,
|
||||
in nsAutoString addrCc,
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* DO NOT EDIT. THIS FILE IS GENERATED FROM nsIMsgCompose.idl
|
||||
*/
|
||||
|
||||
#ifndef __gen_nsIMsgCompose_h__
|
||||
#define __gen_nsIMsgCompose_h__
|
||||
|
||||
#include "nsISupports.h" /* interface nsISupports */
|
||||
#include "nsIMsgCompFields.h" /* interface nsIMsgCompFields */
|
||||
#include "nsID.h" /* interface nsID */
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
#include "jsapi.h"
|
||||
#endif
|
||||
|
||||
/* starting interface: nsIMsgCompose */
|
||||
|
||||
/* {4E606270-B588-11D2-8289-00805F2A0107} */
|
||||
#define NS_IMSGCOMPOSE_IID_STR "4E606270-B588-11D2-8289-00805F2A0107"
|
||||
#define NS_IMSGCOMPOSE_IID \
|
||||
{0x4E606270, 0xB588, 0x11D2, \
|
||||
{ 0x82, 0x89, 0x00, 0x80, 0x5F, 0x2A, 0x01, 0x07 }}
|
||||
|
||||
class nsIMsgCompose : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMSGCOMPOSE_IID)
|
||||
|
||||
/* void CreateAndInitialize (in long a_context, in long old_context, in long prefs, in nsIMsgCompFields initfields, in long master); */
|
||||
NS_IMETHOD CreateAndInitialize(PRInt32 a_context, PRInt32 old_context, PRInt32 prefs, nsIMsgCompFields *initfields, PRInt32 master) = 0;
|
||||
|
||||
/* void Create (in long a_context, in long prefs, in long master); */
|
||||
NS_IMETHOD Create(PRInt32 a_context, PRInt32 prefs, PRInt32 master) = 0;
|
||||
|
||||
/* void Initialize (in long old_context, in nsIMsgCompFields initfields); */
|
||||
NS_IMETHOD Initialize(PRInt32 old_context, nsIMsgCompFields *initfields) = 0;
|
||||
|
||||
/* void Dispose (); */
|
||||
NS_IMETHOD Dispose() = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIMsgCompose *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* __gen_nsIMsgCompose_h__ */
|
|
@ -47,7 +47,7 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsMsgCompPrefs.h"
|
||||
#include "nsIDOMMsgAppCore.h"
|
||||
#include "nsIMessenger.h"
|
||||
#include "nsIMessage.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
|
@ -153,7 +153,6 @@ public:
|
|||
nsAutoString& args,
|
||||
nsIDOMXULTreeElement *tree,
|
||||
nsIDOMNodeList *nodeList,
|
||||
nsIDOMMsgAppCore * msgAppCore,
|
||||
PRInt32 messageType);
|
||||
NS_IMETHOD SendMsg(nsAutoString& aAddrTo, nsAutoString& aAddrCc,
|
||||
nsAutoString& aAddrBcc,
|
||||
|
@ -718,7 +717,6 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl,
|
|||
nsAutoString& args,
|
||||
nsIDOMXULTreeElement *tree,
|
||||
nsIDOMNodeList *nodeList,
|
||||
nsIDOMMsgAppCore * msgAppCore,
|
||||
PRInt32 messageType)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -755,9 +753,15 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl,
|
|||
PR_Free(default_mail_charset);
|
||||
}
|
||||
|
||||
if (tree && nodeList && msgAppCore) {
|
||||
if (tree && nodeList) {
|
||||
nsCOMPtr<nsIMessenger> messenger;
|
||||
rv = nsComponentManager::CreateInstance("component://netscape/messenger",
|
||||
nsnull,
|
||||
nsIMessenger::GetIID(),
|
||||
(void **)getter_AddRefs(messenger));
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
nsCOMPtr<nsISupports> object;
|
||||
rv = msgAppCore->GetRDFResourceForMessage(tree, nodeList,
|
||||
rv = messenger->GetRDFResourceForMessage(tree, nodeList,
|
||||
getter_AddRefs(object));
|
||||
if ((NS_SUCCEEDED(rv)) && object) {
|
||||
nsCOMPtr<nsIMessage> message;
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMEditorAppCore.h"
|
||||
#include "nsIDOMMsgAppCore.h"
|
||||
#include "nsIDOMComposeAppCore.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIScriptNameSpaceManager.h"
|
||||
|
@ -303,8 +302,7 @@ ComposeAppCoreNewMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
nsAutoString b1;
|
||||
nsIDOMXULTreeElement * b2;
|
||||
nsIDOMNodeList * b3;
|
||||
nsIDOMMsgAppCore * b4;
|
||||
PRInt32 b5;
|
||||
PRInt32 b4;
|
||||
int32 i;
|
||||
const nsString typeName;
|
||||
|
||||
|
@ -331,15 +329,10 @@ ComposeAppCoreNewMessage(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
cx,
|
||||
argv[3]);
|
||||
|
||||
rBool &= nsJSUtils::nsConvertJSValToObject((nsISupports**)&b4, nsIDOMMsgAppCore::GetIID(),
|
||||
typeName,
|
||||
cx,
|
||||
argv[4]);
|
||||
JS_ValueToInt32(cx, argv[4], &i);
|
||||
b4 = i;
|
||||
|
||||
JS_ValueToInt32(cx, argv[5], &i);
|
||||
b5 = i;
|
||||
|
||||
if (!rBool || NS_OK != nativeThis->NewMessage(b0, b1, b2, b3, b4, b5)) {
|
||||
if (!rBool || NS_OK != nativeThis->NewMessage(b0, b1, b2, b3, b4)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче