LibreOffice Module sw (master) 1
|
A MailDispatcher should be used for sending a bunch a mail messages asynchronously. More...
#include <maildispatcher.hxx>
Public Member Functions | |
MailDispatcher (css::uno::Reference< css::mail::XSmtpService > xMailService) | |
virtual | ~MailDispatcher () override |
Shutdown the mail dispatcher. More... | |
void | enqueueMailMessage (css::uno::Reference< css::mail::XMailMessage > const &xMailMessage) |
Enqueue a mail message for delivery. More... | |
css::uno::Reference< css::mail::XMailMessage > | dequeueMailMessage () |
Dequeues a mail message. More... | |
void | start () |
Start sending mail messages asynchronously. More... | |
void | stop () |
Stop sending mail messages. More... | |
void | shutdown () |
Request shutdown of the mail dispatcher thread. More... | |
bool | isStarted () const |
Check whether the mail dispatcher is started or not. More... | |
bool | isShutdownRequested () const |
returns if shutdown has already been called More... | |
void | addListener (::rtl::Reference< IMailDispatcherListener > const &listener) |
Register a listener for mail dispatcher events. More... | |
Public Member Functions inherited from salhelper::SimpleReferenceObject | |
SimpleReferenceObject () | |
void | acquire () |
void | release () |
Private Member Functions | |
virtual void SAL_CALL | run () override |
virtual void SAL_CALL | onTerminated () override |
std::vector<::rtl::Reference< IMailDispatcherListener > > | cloneListener () |
void | sendMailMessageNotifyListener (css::uno::Reference< css::mail::XMailMessage > const &message) |
Private Attributes | |
css::uno::Reference< css::mail::XSmtpService > | m_xMailserver |
std::list< css::uno::Reference< css::mail::XMailMessage > > | m_aXMessageList |
std::vector<::rtl::Reference< IMailDispatcherListener > > | m_aListenerVector |
::osl::Mutex | m_aMessageContainerMutex |
::osl::Mutex | m_aListenerContainerMutex |
::osl::Mutex | m_aThreadStatusMutex |
::osl::Condition | m_aRunCondition |
::osl::Condition | m_aWakeupCondition |
::rtl::Reference< MailDispatcher > | m_xSelfReference |
bool | m_bActive |
bool | m_bShutdownRequested |
Additional Inherited Members | |
Static Public Member Functions inherited from salhelper::SimpleReferenceObject | |
static void * | operator new (std::size_t nSize) |
static void * | operator new (std::size_t nSize, std::nothrow_t const &rNothrow) |
static void | operator delete (void *pPtr) |
static void | operator delete (void *pPtr, std::nothrow_t const &rNothrow) |
Protected Member Functions inherited from salhelper::SimpleReferenceObject | |
virtual | ~SimpleReferenceObject () COVERITY_NOEXCEPT_FALSE |
Protected Attributes inherited from salhelper::SimpleReferenceObject | |
oslInterlockedCount | m_nCount |
A MailDispatcher should be used for sending a bunch a mail messages asynchronously.
Usually a client enqueues a number of mail messages and then calls start to begin sending them. An instance of this class must not be shared among different client threads. Instead each client thread should create an own instance of this class.
Definition at line 44 of file maildispatcher.hxx.
MailDispatcher::MailDispatcher | ( | css::uno::Reference< css::mail::XSmtpService > | xMailService | ) |
xSmtpService | [in] a reference to a mail server. A user must be connected to the mail server otherwise errors occur during the delivery of mail messages. |
css::uno::RuntimeException | on errors during construction of an instance of this class. |
Definition at line 72 of file maildispatcher.cxx.
References create(), m_aRunCondition, and m_aWakeupCondition.
|
overridevirtual |
Shutdown the mail dispatcher.
Every mail messages not yet sent will be discarded.
Definition at line 89 of file maildispatcher.cxx.
void MailDispatcher::addListener | ( | ::rtl::Reference< IMailDispatcherListener > const & | listener | ) |
Register a listener for mail dispatcher events.
Definition at line 160 of file maildispatcher.cxx.
References m_aListenerContainerMutex, m_aListenerVector, and m_bShutdownRequested.
|
private |
Definition at line 168 of file maildispatcher.cxx.
References m_aListenerContainerMutex, and m_aListenerVector.
Referenced by run(), and sendMailMessageNotifyListener().
uno::Reference< mail::XMailMessage > MailDispatcher::dequeueMailMessage | ( | ) |
Dequeues a mail message.
This enables the caller to remove attachments when sending mails is to be cancelled.
Definition at line 105 of file maildispatcher.cxx.
References m_aMessageContainerMutex, and m_aXMessageList.
void MailDispatcher::enqueueMailMessage | ( | css::uno::Reference< css::mail::XMailMessage > const & | xMailMessage | ) |
Enqueue a mail message for delivery.
A client must start the mail dispatcher in order to send the enqueued mail messages.
xMailMessage | [in] a mail message that should be send. |
Definition at line 93 of file maildispatcher.cxx.
References m_aMessageContainerMutex, m_aThreadStatusMutex, m_aWakeupCondition, m_aXMessageList, m_bActive, and m_bShutdownRequested.
|
inline |
returns if shutdown has already been called
Definition at line 127 of file maildispatcher.hxx.
|
inline |
Check whether the mail dispatcher is started or not.
Definition at line 118 of file maildispatcher.hxx.
|
overrideprivatevirtual |
Definition at line 242 of file maildispatcher.cxx.
References m_xSelfReference.
|
overrideprivatevirtual |
Definition at line 197 of file maildispatcher.cxx.
References cloneListener(), m_aMessageContainerMutex, m_aRunCondition, m_aThreadStatusMutex, m_aWakeupCondition, m_aXMessageList, m_bShutdownRequested, m_xSelfReference, and sendMailMessageNotifyListener().
|
private |
Definition at line 174 of file maildispatcher.cxx.
References cloneListener(), ex, and m_xMailserver.
Referenced by run().
void MailDispatcher::shutdown | ( | ) |
Request shutdown of the mail dispatcher thread.
NOTE: You must call this method before you release your last reference to this class otherwise the mail dispatcher thread will never end.
Definition at line 149 of file maildispatcher.cxx.
References m_aThreadStatusMutex, m_aWakeupCondition, and m_bShutdownRequested.
void MailDispatcher::start | ( | ) |
Start sending mail messages asynchronously.
A client may register a listener for mail dispatcher events. For every mail message sent the notification will be sent. While handling such notification a client may enqueue new mail messages. If there are no more mail messages to send a respective notification is sent and the mail dispatcher waits for more mail messages.
@precond not isStarted()
Definition at line 117 of file maildispatcher.cxx.
References isStarted(), m_aThreadStatusMutex, m_aWakeupCondition, m_bActive, and m_bShutdownRequested.
void MailDispatcher::stop | ( | ) |
Stop sending mail messages.
@precond isStarted()
Definition at line 133 of file maildispatcher.cxx.
References isStarted(), m_aThreadStatusMutex, m_aWakeupCondition, m_bActive, and m_bShutdownRequested.
|
private |
Definition at line 145 of file maildispatcher.hxx.
Referenced by addListener(), and cloneListener().
|
private |
Definition at line 143 of file maildispatcher.hxx.
Referenced by addListener(), and cloneListener().
|
private |
Definition at line 144 of file maildispatcher.hxx.
Referenced by dequeueMailMessage(), enqueueMailMessage(), and run().
|
private |
Definition at line 147 of file maildispatcher.hxx.
Referenced by MailDispatcher(), and run().
|
private |
Definition at line 146 of file maildispatcher.hxx.
Referenced by enqueueMailMessage(), run(), shutdown(), start(), and stop().
|
private |
Definition at line 148 of file maildispatcher.hxx.
Referenced by enqueueMailMessage(), MailDispatcher(), run(), shutdown(), start(), and stop().
|
private |
Definition at line 142 of file maildispatcher.hxx.
Referenced by dequeueMailMessage(), enqueueMailMessage(), and run().
|
private |
Definition at line 150 of file maildispatcher.hxx.
Referenced by enqueueMailMessage(), start(), and stop().
|
private |
Definition at line 151 of file maildispatcher.hxx.
Referenced by addListener(), enqueueMailMessage(), run(), shutdown(), start(), and stop().
|
private |
Definition at line 141 of file maildispatcher.hxx.
Referenced by sendMailMessageNotifyListener().
|
private |
Definition at line 149 of file maildispatcher.hxx.
Referenced by onTerminated(), and run().