Use qtpaths directly
[kdepim.git] / sieveeditor / sieveserversettings.cpp
blob3f18c5053f4802954ae96d9e6dc080effc16eba1
1 /*
2 Copyright (c) 2014-2015 Montel Laurent <montel@kde.org>
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
21 #include "sieveserversettings.h"
23 #include <kwallet.h>
25 class SieveServerSettingsPrivate
27 public:
28 SieveServerSettingsPrivate()
29 : sieveServerSettings(new SieveServerSettings)
33 ~SieveServerSettingsPrivate()
35 delete sieveServerSettings;
38 SieveServerSettings *sieveServerSettings;
41 Q_GLOBAL_STATIC(SieveServerSettingsPrivate, sInstance)
43 SieveServerSettings::SieveServerSettings(QObject *parent)
44 : QObject(parent),
45 mWallet(Q_NULLPTR)
49 SieveServerSettings::~SieveServerSettings()
51 delete mWallet;
54 SieveServerSettings *SieveServerSettings::self()
56 return sInstance->sieveServerSettings; //will create it
59 KWallet::Wallet *SieveServerSettings::wallet()
61 if (!mWallet) {
62 mWallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), 0);
63 if (mWallet) {
64 connect(mWallet, &KWallet::Wallet::walletClosed, this, &SieveServerSettings::slotWalletClosed);
67 return mWallet;
70 void SieveServerSettings::closeWallet()
72 KWallet::Wallet::closeWallet(KWallet::Wallet::LocalWallet(), true);
75 void SieveServerSettings::slotWalletClosed()
77 delete mWallet;
78 mWallet = Q_NULLPTR;