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 #include "rajcesession.h"
0017 
0018 // Local includes
0019 
0020 #include "digikam_debug.h"
0021 
0022 namespace DigikamGenericRajcePlugin
0023 {
0024 
0025 class Q_DECL_HIDDEN RajceSession::Private
0026 {
0027 public:
0028 
0029     explicit Private()
0030     {
0031         maxWidth      = 0;
0032         maxHeight     = 0;
0033         imageQuality  = 0;
0034         lastErrorCode = 0;
0035         lastCommand   = Logout;
0036     }
0037 
0038     unsigned            maxWidth;
0039     unsigned            maxHeight;
0040     unsigned            imageQuality;
0041     unsigned            lastErrorCode;
0042 
0043     QString             sessionToken;
0044     QString             nickname;
0045     QString             username;
0046     QString             albumToken;
0047     QString             lastErrorMessage;
0048 
0049     QVector<RajceAlbum> albums;
0050 
0051     RajceCommandType    lastCommand;
0052 };
0053 
0054 RajceSession::RajceSession()
0055     : d(new Private)
0056 {
0057 }
0058 
0059 RajceSession::~RajceSession()
0060 {
0061     delete d;
0062 }
0063 
0064 RajceSession::RajceSession(const RajceSession& other)
0065     : d(other.d)
0066 {
0067 }
0068 
0069 RajceSession& RajceSession::operator=(const RajceSession& other)
0070 {
0071     *d = *other.d;
0072 
0073     return *this;
0074 }
0075 
0076 QString& RajceSession::sessionToken()
0077 {
0078     return d->sessionToken;
0079 }
0080 
0081 QString const& RajceSession::sessionToken() const
0082 {
0083     return d->sessionToken;
0084 }
0085 
0086 QString& RajceSession::nickname()
0087 {
0088     return d->nickname;
0089 }
0090 
0091 QString const& RajceSession::nickname() const
0092 {
0093     return d->nickname;
0094 }
0095 
0096 QString& RajceSession::username()
0097 {
0098     return d->username;
0099 }
0100 
0101 QString const& RajceSession::username() const
0102 {
0103     return d->username;
0104 }
0105 
0106 QString& RajceSession::openAlbumToken()
0107 {
0108     return d->albumToken;
0109 }
0110 
0111 QString const& RajceSession::openAlbumToken() const
0112 {
0113     return d->albumToken;
0114 }
0115 
0116 QString& RajceSession::lastErrorMessage()
0117 {
0118     return d->lastErrorMessage;
0119 }
0120 
0121 QString const& RajceSession::lastErrorMessage() const
0122 {
0123     return d->lastErrorMessage;
0124 }
0125 
0126 unsigned& RajceSession::maxWidth()
0127 {
0128     return d->maxWidth;
0129 }
0130 
0131 unsigned RajceSession::maxWidth() const
0132 {
0133     return d->maxWidth;
0134 }
0135 
0136 unsigned& RajceSession::maxHeight()
0137 {
0138     return d->maxHeight;
0139 }
0140 
0141 unsigned RajceSession::maxHeight() const
0142 {
0143     return d->maxHeight;
0144 }
0145 
0146 unsigned& RajceSession::imageQuality()
0147 {
0148     return d->imageQuality;
0149 }
0150 
0151 unsigned RajceSession::imageQuality() const
0152 {
0153     return d->imageQuality;
0154 }
0155 
0156 unsigned& RajceSession::lastErrorCode()
0157 {
0158     return d->lastErrorCode;
0159 }
0160 
0161 unsigned RajceSession::lastErrorCode() const
0162 {
0163     return d->lastErrorCode;
0164 }
0165 
0166 QVector<RajceAlbum>& RajceSession::albums()
0167 {
0168     return d->albums;
0169 }
0170 
0171 const QVector<RajceAlbum>& RajceSession::albums() const
0172 {
0173     return d->albums;
0174 }
0175 
0176 RajceCommandType RajceSession::lastCommand() const
0177 {
0178     return d->lastCommand;
0179 }
0180 
0181 RajceCommandType& RajceSession::lastCommand()
0182 {
0183     return d->lastCommand;
0184 }
0185 
0186 } // namespace DigikamGenericRajcePlugin
0187 
0188 QDebug operator<<(QDebug d, const DigikamGenericRajcePlugin::RajceSession& s)
0189 {
0190     QString     ss;
0191     QTextStream str(&ss);
0192 
0193     str << "SessionState[";
0194     str << "sessionToken='"       << s.sessionToken()     << "'";
0195     str << ", nickname='"         << s.nickname()         << "'";
0196     str << ", username='"         << s.username()         << "'";
0197     str << ", albumToken='"       << s.openAlbumToken()   << "'";
0198     str << ", lastErrorMessage='" << s.lastErrorMessage() << "'";
0199     str << ", lastErrorCode="     << s.lastErrorCode();
0200     str << ", maxWidth="          << s.maxWidth();
0201     str << ", maxHeight="         << s.maxHeight();
0202     str << ", imageQuality="      << s.imageQuality();
0203     str << ", albums=[";
0204 
0205     DigikamGenericRajcePlugin::RajceAlbum a;
0206 
0207     Q_FOREACH (a, s.albums())
0208     {
0209         str << a << ", ";
0210     }
0211 
0212     str << "]";
0213 
0214     d << *str.string();
0215 
0216     return d;
0217 }