File indexing completed on 2025-01-05 03:59:45

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2004-09-17
0007  * Description : digital camera controller
0008  *
0009  * SPDX-FileCopyrightText: 2004-2005 by Renchi Raju <renchi dot raju at gmail dot com>
0010  * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  * SPDX-FileCopyrightText: 2006-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0012  *
0013  * SPDX-License-Identifier: GPL-2.0-or-later
0014  *
0015  * ============================================================ */
0016 
0017 #ifndef DIGIKAM_CAMERA_CONTROLLER_H
0018 #define DIGIKAM_CAMERA_CONTROLLER_H
0019 
0020 // Qt includes
0021 
0022 #include <QThread>
0023 #include <QString>
0024 #include <QFileInfo>
0025 
0026 // Local includes
0027 
0028 #include "downloadsettings.h"
0029 #include "camiteminfo.h"
0030 #include "dmetadata.h"
0031 #include "dkcamera.h"
0032 #include "dhistoryview.h"
0033 #include "digikam_export.h"
0034 
0035 namespace Digikam
0036 {
0037 
0038 class CameraCommand;
0039 
0040 class DIGIKAM_GUI_EXPORT CameraController : public QThread
0041 {
0042     Q_OBJECT
0043 
0044 public:
0045 
0046     explicit CameraController(QWidget* const parent,
0047                               const QString& title,
0048                               const QString& model,
0049                               const QString& port,
0050                               const QString& path);
0051     ~CameraController()                                       override;
0052 
0053     bool cameraThumbnailSupport()                       const;
0054     bool cameraDeleteSupport()                          const;
0055     bool cameraUploadSupport()                          const;
0056     bool cameraMkDirSupport()                           const;
0057     bool cameraDelDirSupport()                          const;
0058     bool cameraCaptureImageSupport()                    const;
0059     bool cameraCaptureImagePreviewSupport()             const;
0060 
0061     QString cameraPath()                                const;
0062     QString cameraTitle()                               const;
0063 
0064     DKCamera::CameraDriverType cameraDriverType()       const;
0065 
0066     QByteArray cameraMD5ID()                            const;
0067 
0068     void capture();
0069     void listRootFolder(bool useMetadata);
0070     void listFolders(const QString& folder = QString());
0071     void listFiles(const QString& folder, bool useMetadata);
0072     void getFreeSpace();
0073     void getMetadata(const QString& folder, const QString& file);
0074     void getCameraInformation();
0075     void getPreview();
0076 
0077     /**
0078      * Get thumbnails for a list of camera items plus advanced information from metadata.
0079      */
0080     CameraCommand* getThumbsInfo(const CamItemInfoList& infoList, int thumbSize);
0081     void moveThumbsInfo(CameraCommand* const cmd);
0082 
0083     void download(const DownloadSettings& downloadSettings);
0084     void download(const DownloadSettingsList& list);
0085     void upload(const QFileInfo& srcFileInfo,
0086                 const QString& destFile,
0087                 const QString& destFolder);
0088     void deleteFile(const QString& folder, const QString& file);
0089     void lockFile(const QString& folder, const QString& file, bool lock);
0090     void openFile(const QString& folder, const QString& file);
0091 
0092     QIcon mimeTypeThumbnail(const QString& itemName)    const;
0093 
0094 Q_SIGNALS:
0095 
0096     void signalBusy(bool val);
0097     void signalLogMsg(const QString& msg,
0098                       DHistoryView::EntryType type,
0099                       const QString& folder,
0100                       const QString& file);
0101     void signalCameraInformation(const QString& summary,
0102                                  const QString& manual,
0103                                  const QString& about);
0104     void signalFreeSpace(qint64 bytesSize,
0105                          qint64 bytesAvail);
0106     void signalPreview(const QImage& preview);
0107 
0108     void signalConnected(bool val);
0109     void signalFolderList(const QStringList& folderList);
0110     void signalFileList(const CamItemInfoList& infoList);
0111     void signalUploaded(const CamItemInfo& itemInfo);
0112     void signalDownloaded(const QString& folder,
0113                           const QString& file,
0114                           const QString& temp,
0115                           int status);
0116     void signalDeleted(const QString& folder,
0117                        const QString& file,
0118                        bool status);
0119     void signalLocked(const QString& folder,
0120                       const QString& file,
0121                       bool status);
0122     void signalThumbInfo(const QString& folder,
0123                          const QString& file,
0124                          const CamItemInfo& itemInfo,
0125                          const QImage& thumb);
0126     void signalThumbInfoFailed(const QString& folder,
0127                                const QString& file,
0128                                const CamItemInfo& itemInfo);
0129     void signalMetadata(const QString& folder,
0130                         const QString& file,
0131                         const MetaEngineData& exifData);
0132 
0133     void signalInternalDownloadFailed(const QString& folder,
0134                                       const QString& file);
0135     void signalInternalUploadFailed(const QString& folder,
0136                                     const QString& file,
0137                                     const QString& src);
0138     void signalInternalDeleteFailed(const QString& folder,
0139                                     const QString& file);
0140     void signalInternalLockFailed(const QString& folder,
0141                                   const QString& file);
0142 
0143 public Q_SLOTS:
0144 
0145     void slotCancel();
0146     void slotConnect();
0147 
0148 protected:
0149 
0150     void run() override;
0151     void executeCommand(CameraCommand* const cmd);
0152 
0153 private Q_SLOTS:
0154 
0155     void slotDownloadFailed(const QString& folder,
0156                             const QString& file);
0157     void slotUploadFailed(const QString& folder,
0158                           const QString& file,
0159                           const QString& src);
0160     void slotDeleteFailed(const QString& folder,
0161                           const QString& file);
0162     void slotLockFailed(const QString& folder,
0163                         const QString& file);
0164 
0165 private:
0166 
0167     void sendLogMsg(const QString& msg,
0168                     DHistoryView::EntryType type = DHistoryView::StartingEntry,
0169                     const QString& folder = QString(),
0170                     const QString& file = QString());
0171 
0172     void addCommand(CameraCommand* const cmd);
0173     bool queueIsEmpty()                                 const;
0174 
0175 private:
0176 
0177     class Private;
0178     Private* const d;
0179 };
0180 
0181 } // namespace Digikam
0182 
0183 #endif // DIGIKAM_CAMERA_CONTROLLER_H