LibreOffice Module sw (master)  1
maildispatcher.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_MAILDISPATCHER_HXX
21 #define INCLUDED_SW_SOURCE_UIBASE_INC_MAILDISPATCHER_HXX
22 
23 #include <com/sun/star/mail/XSmtpService.hpp>
24 #include <com/sun/star/mail/XMailMessage.hpp>
25 #include <osl/thread.hxx>
26 #include <osl/conditn.hxx>
27 #include <rtl/ref.hxx>
29 
30 #include <list>
31 #include <vector>
32 
33 #include <swdllapi.h>
34 
36 
46  , private ::osl::Thread
47 {
48 public:
49  // bringing operator new/delete into scope
50  using osl::Thread::operator new;
51  using osl::Thread::operator delete;
52  using osl::Thread::join;
53 
63  MailDispatcher(css::uno::Reference< css::mail::XSmtpService> const & xMailService);
64 
69  virtual ~MailDispatcher() override;
70 
79  void enqueueMailMessage(css::uno::Reference< css::mail::XMailMessage> const & xMailMessage);
84  css::uno::Reference< css::mail::XMailMessage> dequeueMailMessage();
85 
96  void start();
97 
103  void stop();
104 
111  void shutdown();
112 
119  bool isStarted() const { return m_bActive; }
120 
123  using osl::Thread::isRunning;
124 
128  bool isShutdownRequested() const { return m_bShutdownRequested; }
129 
133  void addListener(::rtl::Reference<IMailDispatcherListener> const & listener);
134 
135 protected:
136  virtual void SAL_CALL run() override;
137  virtual void SAL_CALL onTerminated() override;
138 
139 private:
140  std::vector< ::rtl::Reference<IMailDispatcherListener> > cloneListener();
141  void sendMailMessageNotifyListener(css::uno::Reference< css::mail::XMailMessage> const & message);
142 
143 private:
144  css::uno::Reference< css::mail::XSmtpService> m_xMailserver;
145  std::list< css::uno::Reference< css::mail::XMailMessage > > m_aXMessageList;
146  std::vector< ::rtl::Reference<IMailDispatcherListener> > m_aListenerVector;
149  ::osl::Mutex m_aThreadStatusMutex;
150  ::osl::Condition m_aRunCondition;
151  ::osl::Condition m_aWakeupCondition;
153  bool m_bActive;
155 };
156 
157 #endif // INCLUDED_SW_SOURCE_UIBASE_INC_MAILDISPATCHER_HXX
158 
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::osl::Mutex m_aListenerContainerMutex
std::vector< ::rtl::Reference< IMailDispatcherListener > > m_aListenerVector
bool isShutdownRequested() const
returns if shutdown has already been called
MailDispatcher listener interface.
void addListener(const InterfaceRef &xObject, const css::uno::Reference< css::lang::XEventListener > &xListener)
::osl::Condition m_aWakeupCondition
std::list< css::uno::Reference< css::mail::XMailMessage > > m_aXMessageList
def run
::osl::Mutex m_aThreadStatusMutex
def stop
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
::osl::Condition m_aRunCondition
::osl::Mutex m_aMessageContainerMutex
bool isStarted() const
Check whether the mail dispatcher is started or not.
::rtl::Reference< MailDispatcher > m_xSelfReference
css::uno::Reference< css::mail::XSmtpService > m_xMailserver
A MailDispatcher should be used for sending a bunch a mail messages asynchronously.