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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2011-04-12
0007  * Description : A tool to export items to Rajce web service
0008  *
0009  * SPDX-FileCopyrightText: 2011      by Lukas Krejci <krejci.l at centrum dot cz>
0010  * SPDX-FileCopyrightText: 2011-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_RAJCE_SESSION_H
0017 #define DIGIKAM_RAJCE_SESSION_H
0018 
0019 // Qt includes
0020 
0021 #include <QString>
0022 #include <QVector>
0023 
0024 // Local includes
0025 
0026 #include "rajcealbum.h"
0027 
0028 namespace DigikamGenericRajcePlugin
0029 {
0030 
0031 enum RajceCommandType
0032 {
0033     Login = 0,
0034     Logout,
0035     ListAlbums,
0036     CreateAlbum,
0037     OpenAlbum,
0038     CloseAlbum,
0039     AddPhoto
0040 };
0041 
0042 enum RajceErrorCode
0043 {
0044 /**
0045  * Taken from the semi-official documentation:
0046  * https://docs.google.com/View?id=ajkd99k8zcw6_120ctqvnjd5#Chybov_k_dy
0047  */
0048     UnknownError = 1,               ///<  1 Unknown error.
0049     InvalidCommand,                 ///<  2 Invalid command.
0050     InvalidCredentials,             ///<  3 Invalid credentials.
0051     InvalidSessionToken,            ///<  4 Invalid session token.
0052     InvalidOrRepeatedColumnName,    ///<  5 Unknown or repeated column name {colName}.
0053     InvalidAlbumId,                 ///<  6 Invalid album ID.
0054     AlbumDoesntExistOrNoPrivileges, ///<  7 The album doesn't exist or is not owned by the logged in user.
0055     InvalidAlbumToken,              ///<  8 Invalid album token.
0056     AlbumNameEmpty,                 ///<  9 Album can't have an empty name.
0057     FailedToCreateAlbum,            ///< 10 Failed to create an album (probably a serverside error).
0058     AlbumDoesntExist,               ///< 11 Album doesn't exist.
0059     UnknownApplication,             ///< 12 Nonexistent application.
0060     InvalidApplicationKey,          ///< 13 Invalid application key.
0061     FileNotAttached,                ///< 14 A file is not attached.
0062     NewerVersionExists,             ///< 15 A newer version already exists {version}.
0063     SavingFileFailed,               ///< 16 Failed to save the file.
0064     UnsupportedFileExtension,       ///< 17 Unsupported file extension {extension}.
0065     UnknownClientVersion,           ///< 18 Unknown client version.
0066     NonexistentTarget               ///< 19 Unknown target.
0067 };
0068 
0069 class RajceSession
0070 {
0071 public:
0072 
0073     explicit RajceSession();
0074     ~RajceSession();
0075 
0076     /** Copy constructor.
0077      */
0078     RajceSession(const RajceSession& other);
0079 
0080     /** Create a copy of container
0081      */
0082     RajceSession& operator=(const RajceSession& other);
0083 
0084 public:
0085 
0086     QString& sessionToken();
0087     QString  const& sessionToken()      const;
0088     QString& nickname();
0089     QString  const& nickname()          const;
0090     QString& username();
0091     QString  const& username()          const;
0092     QString& openAlbumToken();
0093     QString  const& openAlbumToken()    const;
0094     QString& lastErrorMessage();
0095     QString  const& lastErrorMessage()  const;
0096 
0097     unsigned& maxWidth();
0098     unsigned  maxWidth()                const;
0099     unsigned& maxHeight();
0100     unsigned  maxHeight()               const;
0101     unsigned& imageQuality();
0102     unsigned  imageQuality()            const;
0103     unsigned& lastErrorCode();
0104     unsigned  lastErrorCode()           const;
0105 
0106     QVector<RajceAlbum>& albums();
0107     const QVector<RajceAlbum>& albums() const;
0108 
0109     RajceCommandType& lastCommand();
0110     RajceCommandType  lastCommand()     const;
0111 
0112 private:
0113 
0114     class Private;
0115     Private* const d;
0116 };
0117 
0118 } // namespace DigikamGenericRajcePlugin
0119 
0120 QDebug operator<<(QDebug d, const DigikamGenericRajcePlugin::RajceSession& s);
0121 
0122 #endif // DIGIKAM_RAJCE_SESSION_H