File indexing completed on 2025-01-05 04:55:02
0001 /* 0002 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> 0003 0004 This library is free software; you can redistribute it and/or modify it 0005 under the terms of the GNU Library General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or (at your 0007 option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, but WITHOUT 0010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 0012 License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to the 0016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0017 02110-1301, USA. 0018 */ 0019 #pragma once 0020 0021 #include "kube_export.h" 0022 #include <QObject> 0023 #include <QByteArray> 0024 #include <QSettings> 0025 #include <QSharedPointer> 0026 0027 namespace Kube { 0028 0029 class KUBE_EXPORT Settings : public QObject { 0030 Q_OBJECT 0031 Q_PROPERTY(QByteArray identifier READ identifier WRITE setIdentifier) 0032 public: 0033 Settings(QObject *parent = 0); 0034 Settings(const QByteArray &id, QObject *parent = 0); 0035 virtual ~Settings(); 0036 Settings(const Settings&); 0037 0038 void setIdentifier(const QByteArray &id); 0039 QByteArray identifier() const; 0040 0041 Q_INVOKABLE void save(); 0042 Q_INVOKABLE void remove(); 0043 private: 0044 void load(); 0045 QSharedPointer<QSettings> getSettings(); 0046 QByteArray mIdentifier; 0047 bool mLoaded; 0048 }; 0049 0050 class Account; 0051 class Identity; 0052 class Transport; 0053 0054 class ApplicationContext : public Settings 0055 { 0056 Q_OBJECT 0057 public: 0058 ApplicationContext(); 0059 Account currentAccount() const; 0060 0061 }; 0062 0063 class Account : public Settings 0064 { 0065 Q_OBJECT 0066 public: 0067 Account(const QByteArray &identifier); 0068 Identity primaryIdentity() const; 0069 QByteArray type() const; 0070 }; 0071 0072 class Identity : public Settings 0073 { 0074 Q_OBJECT 0075 public: 0076 Identity(const QByteArray &identifier); 0077 Transport transport() const; 0078 }; 0079 0080 class Transport : public Settings 0081 { 0082 Q_OBJECT 0083 public: 0084 Transport(const QByteArray &identifier); 0085 QByteArray username() const; 0086 QByteArray password() const; 0087 QByteArray server() const; 0088 }; 0089 0090 } 0091 0092 Q_DECLARE_METATYPE(Kube::Settings*); 0093