File indexing completed on 2025-01-05 03:53:06

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2021-07-24
0007  * Description : a plugin to share items with MJPEG Stream server.
0008  *
0009  * SPDX-FileCopyrightText: 2021-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2021      by Quoc Hưng Tran <quochungtran1999 at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "mjpegstreamplugin.h"
0017 
0018 // Qt includes
0019 
0020 #include <QPointer>
0021 
0022 // KDE includes
0023 
0024 #include <klocalizedstring.h>
0025 
0026 // Local includes
0027 
0028 #include "mjpegstreamdlg.h"
0029 #include "mjpegservermngr.h"
0030 
0031 namespace DigikamGenericMjpegStreamPlugin
0032 {
0033 
0034 MjpegStreamPlugin::MjpegStreamPlugin(QObject* const parent)
0035     : DPluginGeneric(parent)
0036 {
0037     // Start the MJPEG Server if necessary
0038 
0039     MjpegServerMngr::instance()->loadAtStartup();
0040 }
0041 
0042 MjpegStreamPlugin::~MjpegStreamPlugin()
0043 {
0044 }
0045 
0046 void MjpegStreamPlugin::cleanUp()
0047 {
0048     // Stop the MJPEG Server if necessary
0049 
0050     MjpegServerMngr::instance()->saveAtShutdown();
0051 }
0052 
0053 QString MjpegStreamPlugin::name() const
0054 {
0055     return i18n("MJPEG Stream Server");
0056 }
0057 
0058 QString MjpegStreamPlugin::iid() const
0059 {
0060     return QLatin1String(DPLUGIN_IID);
0061 }
0062 
0063 QIcon MjpegStreamPlugin::icon() const
0064 {
0065     return QIcon::fromTheme(QLatin1String("video-x-generic"));
0066 }
0067 
0068 QString MjpegStreamPlugin::description() const
0069 {
0070     return i18n("A tool to export items as MJPEG Stream");
0071 }
0072 
0073 QString MjpegStreamPlugin::handbookSection() const
0074 {
0075     return QLatin1String("post_processing");
0076 }
0077 
0078 QString MjpegStreamPlugin::handbookChapter() const
0079 {
0080     return QLatin1String("mjpeg_stream");
0081 }
0082 
0083 QString MjpegStreamPlugin::details() const
0084 {
0085     return i18n(
0086         "<p>This tool allows users to share items on the local network through a MJPEG Stream server.</p>"
0087         "<p>Items to share can be selected one by one or by group through a selection of albums.</p>"
0088         "<p>Motion JPEG is a video compression format in which each video frame or interlaced field of "
0089         "a digital video sequence is compressed separately as a JPEG image. MJPEG streams is a standard "
0090         "which allows network clients to be connected without additional module. Most major web browsers "
0091         "and players support MJPEG stream.</p>"
0092         "<p>To access to stream from your browser, use http://address:port as url, with address the MJPEG address, "   // krazy:exclude=insecurenet
0093         "and port the MJPEG port set in config dialog. More than one computer can be connected to the MJPEG server "
0094         "at the same time.</p>");
0095 }
0096 
0097 QList<DPluginAuthor> MjpegStreamPlugin::authors() const
0098 {
0099     return QList<DPluginAuthor>()
0100             << DPluginAuthor(QString::fromUtf8("Quoc Hưng Tran"),
0101                              QString::fromUtf8("quochungtran1999 at gmail dot com"),
0102                              QString::fromUtf8("(C) 2021"),
0103                              i18n("Developer"))
0104             << DPluginAuthor(QString::fromUtf8("Gilles Caulier"),
0105                              QString::fromUtf8("caulier dot gilles at gmail dot com"),
0106                              QString::fromUtf8("(C) 2021-2024"),
0107                              i18n("Developer and Maintainer"))
0108             ;
0109 }
0110 
0111 void MjpegStreamPlugin::setup(QObject* const parent)
0112 {
0113     DPluginAction* const ac = new DPluginAction(parent);
0114     ac->setIcon(icon());
0115     ac->setText(i18nc("@action", "Share as MJPEG Stream..."));
0116     ac->setObjectName(QLatin1String("mjpegstream"));
0117     ac->setActionCategory(DPluginAction::GenericTool);
0118 
0119     connect(ac, SIGNAL(triggered(bool)),
0120             this, SLOT(slotMjpegStream()));
0121 
0122     addAction(ac);
0123 }
0124 
0125 void MjpegStreamPlugin::slotMjpegStream()
0126 {
0127     QPointer<MjpegStreamDlg> w = new MjpegStreamDlg(this, infoIface(sender()));
0128     w->setPlugin(this);
0129     w->exec();
0130     delete w;
0131 }
0132 
0133 } // namespace DigikamGenericMjpegStreamPlugin
0134 
0135 #include "moc_mjpegstreamplugin.cpp"