/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #pragma once #include #include #include #include #include #include #include namespace jsdialog { enum MessageType { FullUpdate, WidgetUpdate, Close, Action, Popup, PopupClose, Menu, }; } /// Class with the message description for storing in the queue class JSDialogMessageInfo { public: jsdialog::MessageType m_eType; VclPtr m_pWindow; VclPtr m_pMenu; std::unique_ptr m_pData; private: void copy(const JSDialogMessageInfo& rInfo) { this->m_eType = rInfo.m_eType; this->m_pWindow = rInfo.m_pWindow; this->m_pMenu = rInfo.m_pMenu; if (rInfo.m_pData) { std::unique_ptr pData( new jsdialog::ActionDataMap(*rInfo.m_pData)); this->m_pData = std::move(pData); } } public: JSDialogMessageInfo(jsdialog::MessageType eType, VclPtr pWindow, std::unique_ptr pData) : m_eType(eType) , m_pWindow(std::move(pWindow)) , m_pData(std::move(pData)) { } JSDialogMessageInfo(jsdialog::MessageType eType, VclPtr pMenu, std::unique_ptr pData) : m_eType(eType) , m_pMenu(std::move(pMenu)) , m_pData(std::move(pData)) { } JSDialogMessageInfo(const JSDialogMessageInfo& rInfo) { copy(rInfo); } JSDialogMessageInfo& operator=(JSDialogMessageInfo aInfo) { if (this == &aInfo) return *this; copy(aInfo); return *this; } }; class JSDialogNotifyIdle final : public Idle { // used to send message VclPtr m_aNotifierWindow; // used to generate JSON VclPtr m_aContentWindow; OUString m_sTypeOfJSON; OString m_LastNotificationMessage; bool m_bForce; std::deque m_aMessageQueue; std::mutex m_aQueueMutex; public: JSDialogNotifyIdle(VclPtr aNotifierWindow, VclPtr aContentWindow, const rtl::OUString& sTypeOfJSON); void Invoke() override; void clearQueue(); void forceUpdate(); template void sendMessage(const jsdialog::MessageType eType, const VclPtr& pTarget, std::unique_ptr pData = nullptr); private: void send(const OString& sMsg); OString generateFullUpdate() const; OString generateWidgetUpdate(const VclPtr& pWindow) const; OString generateCloseMessage() const; OString generateActionMessage(const VclPtr& pWindow, std::unique_ptr pData) const; OString generatePopupMessage(const VclPtr& pWindow, const rtl::OUString& sParentId, const OUString& sCloseId) const; OString generateClosePopupMessage(const rtl::OUString& sWindowId) const; OString generateMenuMessage(const VclPtr& pMenu) const; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */