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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2018-07-30
0007  * Description : a plugin to share items with DLNA server.
0008  *
0009  * SPDX-FileCopyrightText: 2018-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "mediaserverplugin.h"
0016 
0017 // Qt includes
0018 
0019 #include <QPointer>
0020 
0021 // KDE includes
0022 
0023 #include <klocalizedstring.h>
0024 
0025 // Local includes
0026 
0027 #include "dmediaserverdlg.h"
0028 #include "dmediaservermngr.h"
0029 
0030 namespace DigikamGenericMediaServerPlugin
0031 {
0032 
0033 MediaServerPlugin::MediaServerPlugin(QObject* const parent)
0034     : DPluginGeneric(parent)
0035 {
0036     // Start the Media Server if necessary
0037 
0038     DMediaServerMngr::instance()->loadAtStartup();
0039 }
0040 
0041 MediaServerPlugin::~MediaServerPlugin()
0042 {
0043 }
0044 
0045 void MediaServerPlugin::cleanUp()
0046 {
0047     // Stop the Media Server if necessary
0048 
0049     DMediaServerMngr::instance()->saveAtShutdown();
0050 }
0051 
0052 QString MediaServerPlugin::name() const
0053 {
0054     return i18n("DLNA Export");
0055 }
0056 
0057 QString MediaServerPlugin::iid() const
0058 {
0059     return QLatin1String(DPLUGIN_IID);
0060 }
0061 
0062 QIcon MediaServerPlugin::icon() const
0063 {
0064     return QIcon::fromTheme(QLatin1String("go-next-skip"));
0065 }
0066 
0067 QString MediaServerPlugin::description() const
0068 {
0069     return i18n("A tool to export items to a DLNA compatible device");
0070 }
0071 
0072 QString MediaServerPlugin::details() const
0073 {
0074     return i18n("<p>This tool allows users to share items on the local network through a DLNA server.</p>"
0075                 "<p>Items to share can be selected one by one or by group through a selection of albums.</p>"
0076                 "<p>Many kind of electronic devices can support DLNA, as tablets, cellulars, TV, etc.</p>");
0077 }
0078 
0079 QString MediaServerPlugin::handbookSection() const
0080 {
0081     return QLatin1String("post_processing");
0082 }
0083 
0084 QString MediaServerPlugin::handbookChapter() const
0085 {
0086     return QLatin1String("media_server");
0087 }
0088 
0089 QList<DPluginAuthor> MediaServerPlugin::authors() const
0090 {
0091     return QList<DPluginAuthor>()
0092             << DPluginAuthor(QString::fromUtf8("Ahmed Fathi"),
0093                              QString::fromUtf8("ahmed dot fathi dot abdelmageed at gmail dot com"),
0094                              QString::fromUtf8("(C) 2015"))
0095             << DPluginAuthor(QString::fromUtf8("Smit Mehta"),
0096                              QString::fromUtf8("smit dot meh at gmail dot com"),
0097                              QString::fromUtf8("(C) 2012-2013"))
0098             << DPluginAuthor(QString::fromUtf8("Marcel Wiesweg"),
0099                              QString::fromUtf8("marcel dot wiesweg at gmx dot de"),
0100                              QString::fromUtf8("(C) 2012-2013"))
0101             << DPluginAuthor(QString::fromUtf8("Gilles Caulier"),
0102                              QString::fromUtf8("caulier dot gilles at gmail dot com"),
0103                              QString::fromUtf8("(C) 2012-2020"),
0104                              i18n("Developer and Maintainer"))
0105             ;
0106 }
0107 
0108 void MediaServerPlugin::setup(QObject* const parent)
0109 {
0110     DPluginAction* const ac = new DPluginAction(parent);
0111     ac->setIcon(icon());
0112     ac->setText(i18nc("@action", "Share with DLNA..."));
0113     ac->setObjectName(QLatin1String("mediaserver"));
0114     ac->setActionCategory(DPluginAction::GenericTool);
0115 
0116     connect(ac, SIGNAL(triggered(bool)),
0117             this, SLOT(slotMediaServer()));
0118 
0119     addAction(ac);
0120 }
0121 
0122 void MediaServerPlugin::slotMediaServer()
0123 {
0124     QPointer<DMediaServerDlg> w = new DMediaServerDlg(this, infoIface(sender()));
0125     w->setPlugin(this);
0126     w->exec();
0127     delete w;
0128 }
0129 
0130 } // namespace DigikamGenericMediaServerPlugin
0131 
0132 #include "moc_mediaserverplugin.cpp"