File indexing completed on 2025-01-05 03:53:31
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2012-02-02 0007 * Description : a tool to export items to ImageShackSession web service 0008 * 0009 * SPDX-FileCopyrightText: 2012 by Dodon Victor <dodonvictor at gmail dot com> 0010 * SPDX-FileCopyrightText: 2013-2018 by Caulier Gilles <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "imageshacksession.h" 0017 0018 // Qt includes 0019 0020 #include <QApplication> 0021 0022 // KDE includes 0023 0024 #include <ksharedconfig.h> 0025 #include <kconfiggroup.h> 0026 0027 // Locla includes 0028 0029 #include "digikam_debug.h" 0030 0031 namespace DigikamGenericImageShackPlugin 0032 { 0033 0034 class Q_DECL_HIDDEN ImageShackSession::Private 0035 { 0036 0037 public: 0038 0039 explicit Private() 0040 { 0041 loggedIn = false; 0042 } 0043 0044 bool loggedIn; 0045 0046 QString authToken; 0047 QString username; 0048 QString email; 0049 QString password; 0050 QString credits; 0051 }; 0052 0053 ImageShackSession::ImageShackSession() 0054 : d(new Private) 0055 { 0056 readSettings(); 0057 } 0058 0059 ImageShackSession::~ImageShackSession() 0060 { 0061 delete d; 0062 } 0063 0064 bool ImageShackSession::loggedIn() const 0065 { 0066 return d->loggedIn; 0067 } 0068 0069 QString ImageShackSession::username() const 0070 { 0071 return d->username; 0072 } 0073 0074 QString ImageShackSession::email() const 0075 { 0076 return d->email; 0077 } 0078 0079 QString ImageShackSession::password() const 0080 { 0081 return d->password; 0082 } 0083 0084 QString ImageShackSession::authToken() const 0085 { 0086 return d->authToken; 0087 } 0088 0089 QString ImageShackSession::credits() const 0090 { 0091 return d->credits; 0092 } 0093 0094 void ImageShackSession::setLoggedIn(bool b) 0095 { 0096 d->loggedIn = b; 0097 } 0098 0099 void ImageShackSession::setUsername(const QString& username) 0100 { 0101 d->username = username; 0102 } 0103 0104 void ImageShackSession::setEmail(const QString& email) 0105 { 0106 d->email = email; 0107 } 0108 0109 void ImageShackSession::setAuthToken(const QString& token) 0110 { 0111 d->authToken = token; 0112 } 0113 0114 void ImageShackSession::setPassword(const QString& pass) 0115 { 0116 d->password = pass; 0117 } 0118 0119 void ImageShackSession::setCredits(const QString& credits) 0120 { 0121 d->credits = credits; 0122 } 0123 0124 void ImageShackSession::logOut() 0125 { 0126 d->loggedIn = false; 0127 d->username.clear(); 0128 d->email.clear(); 0129 d->credits.clear(); 0130 saveSettings(); 0131 } 0132 0133 void ImageShackSession::readSettings() 0134 { 0135 static bool bLoaded = false; 0136 0137 if (bLoaded) 0138 return; 0139 0140 bLoaded = true; 0141 0142 KSharedConfigPtr config = KSharedConfig::openConfig(); 0143 KConfigGroup group = config->group(QLatin1String("ImageShack Settings")); 0144 } 0145 0146 void ImageShackSession::saveSettings() 0147 { 0148 KSharedConfigPtr config = KSharedConfig::openConfig(); 0149 KConfigGroup group = config->group(QLatin1String("ImageShack Settings")); 0150 0151 config->sync(); 0152 } 0153 0154 } // namespace DigikamGenericImageShackPlugin