File indexing completed on 2025-01-05 03:52:08

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2012-05-28
0007  * Description : Media server manager
0008  *
0009  * SPDX-FileCopyrightText: 2012      by Smit Mehta <smit dot meh at gmail dot com>
0010  * SPDX-FileCopyrightText: 2012-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_DMEDIA_SERVER_MNGR_H
0017 #define DIGIKAM_DMEDIA_SERVER_MNGR_H
0018 
0019 // Qt includes
0020 
0021 #include <QObject>
0022 #include <QMap>
0023 #include <QList>
0024 #include <QString>
0025 
0026 // Local includes
0027 
0028 #include "dmediaserver.h"
0029 
0030 namespace DigikamGenericMediaServerPlugin
0031 {
0032 
0033 class DMediaServerMngr : public QObject
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038 
0039     /// Setup the list of items to share with the DLNA server into a single album.
0040     void setItemsList(const QString& aname, const QList<QUrl>& urls);
0041 
0042     /// Return a flat list of items shared
0043     QList<QUrl> itemsList()                   const;
0044 
0045     /// Setup the list of albums to share with DLNA server.
0046     void setCollectionMap(const MediaServerMap&);
0047 
0048     /// Return the current album map shared.
0049     MediaServerMap collectionMap()            const;
0050 
0051     /// Start the DLNA server and share the contents. Return true is all is on-line.
0052     bool startMediaServer();
0053 
0054     /// Stop the DLNA server and clean-up.
0055     void cleanUp();
0056 
0057     /// Low level methods to save and load from xml data file.
0058     bool save();
0059     bool load();
0060 
0061     /// Wrapper to check if server configuration must be saved and restored between application sessions.
0062     bool loadAtStartup();
0063     void saveAtShutdown();
0064 
0065     /// Return true if server is running in background.
0066     bool isRunning()                          const;
0067 
0068     /// Return some stats about total albums and total items shared on the network.
0069     int  albumsShared()                       const;
0070     int  itemsShared()                        const;
0071 
0072     /// Config properties methods.
0073 
0074     QString configGroupName()                 const;
0075     QString configStartServerOnStartupEntry() const;
0076 
0077     /// Send a notification message if MediaServer have been started or not.
0078     void mediaServerNotification(bool started);
0079 
0080 public:
0081 
0082     /// This manager is a singleton. Use this method to control the DLNA server instance.
0083     static DMediaServerMngr* instance();
0084 
0085 private:
0086 
0087     // Disable
0088     DMediaServerMngr();
0089     explicit DMediaServerMngr(QObject*) = delete;
0090     ~DMediaServerMngr() override;
0091 
0092 private:
0093 
0094     friend class DMediaServerMngrCreator;
0095 
0096     class Private;
0097     Private* const d;
0098 };
0099 
0100 } // namespace DigikamGenericMediaServerPlugin
0101 
0102 #endif // DIGIKAM_DMEDIA_SERVER_MNGR_H