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
45 private ::osl::Thread
46{
47public:
48 // bringing operator new/delete into scope
49 using osl::Thread::operator new;
50 using osl::Thread::operator delete;
51 using osl::Thread::join;
52
62 MailDispatcher(css::uno::Reference<css::mail::XSmtpService> xMailService);
63
68 virtual ~MailDispatcher() override;
69
78 void enqueueMailMessage(css::uno::Reference<css::mail::XMailMessage> const& xMailMessage);
83 css::uno::Reference<css::mail::XMailMessage> dequeueMailMessage();
84
95 void start();
96
102 void stop();
103
110 void shutdown();
111
118 bool isStarted() const { return m_bActive; }
119
122 using osl::Thread::isRunning;
123
127 bool isShutdownRequested() const { return m_bShutdownRequested; }
128
133
134private:
135 virtual void SAL_CALL run() override;
136 virtual void SAL_CALL onTerminated() override;
137
138 std::vector<::rtl::Reference<IMailDispatcherListener>> cloneListener();
139 void sendMailMessageNotifyListener(css::uno::Reference<css::mail::XMailMessage> const& message);
140
141 css::uno::Reference<css::mail::XSmtpService> m_xMailserver;
142 std::list<css::uno::Reference<css::mail::XMailMessage>> m_aXMessageList;
143 std::vector<::rtl::Reference<IMailDispatcherListener>> m_aListenerVector;
147 ::osl::Condition m_aRunCondition;
148 ::osl::Condition m_aWakeupCondition;
152};
153
154#endif // INCLUDED_SW_SOURCE_UIBASE_INC_MAILDISPATCHER_HXX
155
156/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
MailDispatcher listener interface.
A MailDispatcher should be used for sending a bunch a mail messages asynchronously.
std::vector<::rtl::Reference< IMailDispatcherListener > > m_aListenerVector
css::uno::Reference< css::mail::XSmtpService > m_xMailserver
::osl::Mutex m_aThreadStatusMutex
::osl::Condition m_aRunCondition
bool isShutdownRequested() const
returns if shutdown has already been called
::osl::Condition m_aWakeupCondition
std::list< css::uno::Reference< css::mail::XMailMessage > > m_aXMessageList
bool isStarted() const
Check whether the mail dispatcher is started or not.
::osl::Mutex m_aListenerContainerMutex
::osl::Mutex m_aMessageContainerMutex
::rtl::Reference< MailDispatcher > m_xSelfReference
def stop(arg=None)
def run(arg=None, arg2=-1)
void addListener(const InterfaceRef &xObject, const css::uno::Reference< css::lang::XEventListener > &xListener)
#define SW_DLLPUBLIC
Definition: swdllapi.h:28