File indexing completed on 2024-04-28 08:09:24

0001 /*
0002     SPDX-FileCopyrightText: 2001 The Kompany
0003     SPDX-FileCopyrightText: 2001-2003 Ilya Konstantinov <kde-devel@future.shiny.co.il>
0004     SPDX-FileCopyrightText: 2001-2008 Marcus Meissner <marcus@jet.franken.de>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef __kamera_h__
0010 #define __kamera_h__
0011 
0012 #include <KIO/WorkerBase>
0013 #include <gphoto2.h>
0014 class KConfig;
0015 
0016 class KConfig;
0017 
0018 class KameraProtocol : public KIO::WorkerBase
0019 {
0020 public:
0021     KameraProtocol(const QByteArray &pool, const QByteArray &app);
0022     ~KameraProtocol() override;
0023 
0024     KIO::WorkerResult get(const QUrl &url) override;
0025     KIO::WorkerResult stat(const QUrl &url) override;
0026     KIO::WorkerResult del(const QUrl &url, bool isFile) override;
0027     KIO::WorkerResult listDir(const QUrl &url) override;
0028     KIO::WorkerResult special(const QByteArray &data) override;
0029 
0030     CameraFile *getFile()
0031     {
0032         return m_file;
0033     }
0034     KIO::filesize_t getFileSize()
0035     {
0036         return m_fileSize;
0037     }
0038     void setFileSize(KIO::filesize_t newfs)
0039     {
0040         m_fileSize = newfs;
0041     }
0042 
0043 private:
0044     Camera *m_camera;
0045     QString current_camera, current_port;
0046     CameraAbilities m_abilities;
0047     KConfig *m_config;
0048 
0049     GPContext *m_context;
0050 
0051     [[nodiscard]] KIO::WorkerResult split_url2camerapath(const QString &url, QString &directory, QString &file);
0052     [[nodiscard]] KIO::WorkerResult setCamera(const QString &cam, const QString &port);
0053     void reparseConfiguration() override;
0054     bool openCamera(QString &str);
0055     bool openCamera()
0056     {
0057         QString errstr;
0058         return openCamera(errstr);
0059     }
0060     void closeCamera();
0061 
0062     [[nodiscard]] KIO::WorkerResult statRoot();
0063     [[nodiscard]] KIO::WorkerResult statRegular(const QUrl &url);
0064     void translateTextToUDS(KIO::UDSEntry &udsEntry, const QString &info, const char *txt);
0065     void translateFileToUDS(KIO::UDSEntry &udsEntry, const CameraFileInfo &info, const QString &name);
0066     void translateDirectoryToUDS(KIO::UDSEntry &udsEntry, const QString &dirname);
0067     bool cameraSupportsPreview();
0068     bool cameraSupportsDel();
0069     bool cameraSupportsPut();
0070     int readCameraFolder(const QString &folder, CameraList *dirList, CameraList *fileList);
0071 
0072     QString m_lockfile;
0073     int idletime;
0074 
0075     KIO::filesize_t m_fileSize;
0076     CameraFile *m_file = nullptr;
0077     bool actiondone, cameraopen;
0078 };
0079 #endif