mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-06 00:55:37 +00:00
a new test harness for send unsent messages (send later) interfaces
This commit is contained in:
parent
51592ac23a
commit
106f845dea
34
mailnews/compose/tests/sendlater/Makefile.in
Normal file
34
mailnews/compose/tests/sendlater/Makefile.in
Normal file
@ -0,0 +1,34 @@
|
||||
#!gmake
|
||||
#
|
||||
# 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.
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
MODULE =sendlatertest
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
CPPSRCS = \
|
||||
test.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
88
mailnews/compose/tests/sendlater/makefile.win
Normal file
88
mailnews/compose/tests/sendlater/makefile.win
Normal file
@ -0,0 +1,88 @@
|
||||
# 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.
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
# New build system where zip dll is build indepenant of java stubs.
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
MODULE =sendlatertest
|
||||
#EXPORTS = \
|
||||
# $(NULL)
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH= ..\..\..\..
|
||||
|
||||
MAKE_OBJ_TYPE=EXE
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
EXENAME=TestMSGSendLater
|
||||
PDBFILE=TestMSGSendLater.pdb
|
||||
MAPFILE=TestMSGSendLater.map
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define the files necessary to build the target (ie. OBJS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\test.obj \
|
||||
$(NULL)
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
|
||||
#// (these must be defined before the common makefiles are included)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
PROGRAM=.\$(OBJDIR)\$(EXENAME).EXE
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any local options for the make tools
|
||||
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
LCFLAGS=-DNETSCAPE
|
||||
LLIBS= $(LLIBS) ole32.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(LIBNSPR) \
|
||||
|
||||
# clobber and clobber_all will remove the following garbage:
|
||||
GARBAGE = $(GARBAGE) _gen
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
install:: $(PROGRAM)
|
||||
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin\
|
||||
|
||||
clobber::
|
||||
rm -f $(EXENAME).exe
|
199
mailnews/compose/tests/sendlater/test.cpp
Normal file
199
mailnews/compose/tests/sendlater/test.cpp
Normal file
@ -0,0 +1,199 @@
|
||||
#include "msgCore.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsMsgLocalCID.h"
|
||||
#include "nsMsgCompCID.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef XP_PC
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsMsgCompCID.h"
|
||||
#include "nsIMsgCompose.h"
|
||||
#include "nsIMsgCompFields.h"
|
||||
#include "nsIMsgSend.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIMsgMailSession.h"
|
||||
#include "nsINetSupportDialogService.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
|
||||
|
||||
#include "nsINetService.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsISmtpService.h"
|
||||
#include "nsISmtpUrl.h"
|
||||
#include "nsIUrlListener.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIFileLocator.h"
|
||||
|
||||
#include "MsgCompGlue.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsIMimeURLUtils.h"
|
||||
#include "nsMsgSendLater.h"
|
||||
|
||||
|
||||
#ifdef XP_PC
|
||||
#define NETLIB_DLL "netlib.dll"
|
||||
#define XPCOM_DLL "xpcom32.dll"
|
||||
#define PREF_DLL "xppref32.dll"
|
||||
#define APPSHELL_DLL "nsappshell.dll"
|
||||
#define MIME_DLL "mime.dll"
|
||||
#else
|
||||
#ifdef XP_MAC
|
||||
#include "nsMacRepository.h"
|
||||
#else
|
||||
#define NETLIB_DLL "libnetlib"MOZ_DLL_SUFFIX
|
||||
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
|
||||
#define PREF_DLL "libpref"MOZ_DLL_SUFFIX
|
||||
#define APPCORES_DLL "libappcores"MOZ_DLL_SUFFIX
|
||||
#define APPSHELL_DLL "libnsappshell"MOZ_DLL_SUFFIX
|
||||
#define MIME_DLL "libmime"MOZ_DLL_SUFFIX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Define keys for all of the interfaces we are going to require for this test
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
|
||||
static NS_DEFINE_CID(kEventQueueCID, NS_EVENTQUEUE_CID);
|
||||
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kMimeURLUtilsCID, NS_IMIME_URLUTILS_CID);
|
||||
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID);
|
||||
static NS_DEFINE_IID(kIMsgSendLaterIID, NS_IMSGSENDLATER_IID);
|
||||
static NS_DEFINE_CID(kMsgSendLaterCID, NS_MSGSENDLATER_CID);
|
||||
|
||||
nsresult OnIdentityCheck()
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kCMsgMailSessionCID, &result);
|
||||
if (NS_SUCCEEDED(result) && mailSession)
|
||||
{
|
||||
// mscott: we really don't check an identity, we check
|
||||
// for an outgoing
|
||||
nsIMsgIncomingServer * incomingServer = nsnull;
|
||||
result = mailSession->GetCurrentServer(&incomingServer);
|
||||
if (NS_SUCCEEDED(result) && incomingServer)
|
||||
{
|
||||
char * value = nsnull;
|
||||
incomingServer->GetPrettyName(&value);
|
||||
printf("Server pretty name: %s\n", value ? value : "");
|
||||
incomingServer->GetUsername(&value);
|
||||
printf("User Name: %s\n", value ? value : "");
|
||||
incomingServer->GetHostName(&value);
|
||||
printf("Pop Server: %s\n", value ? value : "");
|
||||
incomingServer->GetPassword(&value);
|
||||
printf("Pop Password: %s\n", value ? value : "");
|
||||
|
||||
NS_RELEASE(incomingServer);
|
||||
}
|
||||
else
|
||||
printf("Unable to retrieve the outgoing server interface....\n");
|
||||
}
|
||||
else
|
||||
printf("Unable to retrieve the mail session service....\n");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a test stub for mail composition. This will be enhanced as the
|
||||
* development continues for message send functions.
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsIAppShellService* appShell = nsnull;
|
||||
|
||||
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kPrefCID, nsnull, nsnull, PREF_DLL, PR_TRUE, PR_TRUE);
|
||||
nsComponentManager::RegisterComponent(kFileLocatorCID, NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kMimeURLUtilsCID, NULL, NULL, MIME_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kNetSupportDialogCID, NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kAppShellServiceCID, NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
/*
|
||||
* Create the Application Shell instance...
|
||||
*/
|
||||
nsIWebShellWindow* newWindow;
|
||||
rv = nsServiceManager::GetService(kAppShellServiceCID,
|
||||
kIAppShellServiceIID,
|
||||
(nsISupports**)&appShell);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
appShell->CreateTopLevelWindow(nsnull, nsnull, PR_TRUE, newWindow,
|
||||
nsnull, nsnull, 200, 200);
|
||||
|
||||
// Create the Event Queue for this thread...
|
||||
NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
printf("Failed to get event queue\n");
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = pEventQService->CreateThreadEventQueue();
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
printf("Failed to create event queue\n");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// make sure prefs get initialized and loaded..
|
||||
// mscott - this is just a bad bad bad hack right now until prefs
|
||||
// has the ability to take nsnull as a parameter. Once that happens,
|
||||
// prefs will do the work of figuring out which prefs file to load...
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
|
||||
if (NS_FAILED(rv) || (prefs == nsnull)) {
|
||||
exit(rv);
|
||||
}
|
||||
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kCMsgMailSessionCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
printf("Failure on Mail Session Init!\n");
|
||||
return rv;
|
||||
}
|
||||
|
||||
OnIdentityCheck();
|
||||
|
||||
nsIMsgSendLater *pMsgSendLater;
|
||||
rv = nsComponentManager::CreateInstance(kMsgSendLaterCID, NULL, kIMsgSendLaterIID, (void **) &pMsgSendLater);
|
||||
if (rv == NS_OK && pMsgSendLater)
|
||||
{
|
||||
printf("We succesfully obtained a nsIMsgSendLater interface....\n");
|
||||
nsIMsgIdentity *identity = nsnull;
|
||||
pMsgSendLater->SendUnsentMessages(identity, "Outbox", "nsmail-2");
|
||||
}
|
||||
|
||||
#ifdef XP_PC
|
||||
printf("Sitting in an event processing loop ...Hit Cntl-C to exit...");
|
||||
while (1)
|
||||
{
|
||||
MSG msg;
|
||||
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user