File indexing completed on 2025-01-05 03:53:40
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2014-09-30 0007 * Description : a tool to export items to Piwigo web service 0008 * 0009 * SPDX-FileCopyrightText: 2003-2005 by Renchi Raju <renchi dot raju at gmail dot com> 0010 * SPDX-FileCopyrightText: 2006 by Colin Guthrie <kde at colin dot guthr dot ie> 0011 * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0012 * SPDX-FileCopyrightText: 2008 by Andrea Diamantini <adjam7 at gmail dot com> 0013 * SPDX-FileCopyrightText: 2010-2014 by Frederic Coiffier <frederic dot coiffier at free dot com> 0014 * 0015 * SPDX-License-Identifier: GPL-2.0-or-later 0016 * 0017 * ============================================================ */ 0018 0019 #include "piwigosession.h" 0020 0021 // Qt includes 0022 0023 #include <QApplication> 0024 0025 // KDE includes 0026 0027 #include <ksharedconfig.h> 0028 #include <kconfiggroup.h> 0029 0030 // Local includes 0031 0032 #include "digikam_debug.h" 0033 0034 namespace DigikamGenericPiwigoPlugin 0035 { 0036 0037 class Q_DECL_HIDDEN PiwigoSession::Private 0038 { 0039 public: 0040 0041 explicit Private() 0042 { 0043 } 0044 0045 QString url; 0046 QString username; 0047 QString password; 0048 }; 0049 0050 PiwigoSession::PiwigoSession() 0051 : d(new Private) 0052 { 0053 load(); 0054 } 0055 0056 PiwigoSession::~PiwigoSession() 0057 { 0058 delete d; 0059 } 0060 0061 QString PiwigoSession::url() const 0062 { 0063 return d->url; 0064 } 0065 0066 QString PiwigoSession::username() const 0067 { 0068 return d->username; 0069 } 0070 0071 QString PiwigoSession::password() const 0072 { 0073 return d->password; 0074 } 0075 0076 void PiwigoSession::setUrl(const QString& url) 0077 { 0078 d->url = url; 0079 } 0080 0081 void PiwigoSession::setUsername(const QString& username) 0082 { 0083 d->username = username; 0084 } 0085 0086 void PiwigoSession::setPassword(const QString& password) 0087 { 0088 d->password = password; 0089 } 0090 0091 void PiwigoSession::load() 0092 { 0093 KSharedConfigPtr config = KSharedConfig::openConfig(); 0094 KConfigGroup group = config->group(QLatin1String("Piwigo Settings")); 0095 0096 d->url = group.readEntry("URL", QString()); 0097 d->username = group.readEntry("Username", QString()); 0098 d->password = group.readEntry("Password", QString()); 0099 } 0100 0101 void PiwigoSession::save() 0102 { 0103 KSharedConfigPtr config = KSharedConfig::openConfig(); 0104 KConfigGroup group = config->group(QLatin1String("Piwigo Settings")); 0105 0106 group.writeEntry(QString::fromUtf8("URL"), url()); 0107 group.writeEntry(QString::fromUtf8("Username"), username()); 0108 group.writeEntry(QString::fromUtf8("Password"), password()); 0109 0110 config->sync(); 0111 } 0112 0113 } // namespace DigikamGenericPiwigoPlugin