OSDN Git Service

generic: port to KPasswdStore
authorIvailo Monev <xakepa10@gmail.com>
Mon, 4 Apr 2022 22:40:28 +0000 (01:40 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Mon, 4 Apr 2022 22:40:28 +0000 (01:40 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
22 files changed:
kget/CMakeLists.txt
kget/conf/dlgwebinterface.cpp
kget/conf/dlgwebinterface.h
kget/extensions/webinterface/httpserver.cpp
kget/extensions/webinterface/httpserver.h
krdc/config/general.ui
krdc/core/CMakeLists.txt
krdc/core/hostpreferences.cpp
krdc/core/remoteview.cpp
krdc/core/remoteview.h
krfb/krfb/CMakeLists.txt
krfb/krfb/invitationsrfbserver.cpp
krfb/krfb/invitationsrfbserver.h
okular/CMakeLists.txt
okular/TODO
okular/core/document.cpp
okular/core/document.h
okular/core/generator.cpp
okular/core/generator.h
okular/generators/ooo/generator_ooo.cpp
okular/generators/ooo/generator_ooo.h
okular/part.cpp

index 0dfc7fe..26c657e 100644 (file)
@@ -232,6 +232,7 @@ target_link_libraries(kget
     ${KDE4_KIO_LIBS}
     ${KDE4_KCMUTILS_LIBS}
     ${KDE4_KNOTIFYCONFIG_LIBS}
+    ${KDE4_KPASSWDSTORE_LIBS}
     kgetcore
 )
 
index cdf11b6..9d36868 100644 (file)
 
 #include <KMessageBox>
 #include <KLocale>
-#include <kwallet.h>
 
 DlgWebinterface::DlgWebinterface(KDialog *parent)
     : QWidget(parent),
-      m_wallet(0)
+      m_passwdstore(nullptr)
 {
     setupUi(this);
 
@@ -30,41 +29,28 @@ DlgWebinterface::DlgWebinterface(KDialog *parent)
 
 DlgWebinterface::~DlgWebinterface()
 {
-    delete m_wallet;
 }
 
 void DlgWebinterface::readConfig()
 {
     if (Settings::webinterfaceEnabled()) {
-        m_wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(),
-                                               winId(),///Use MainWindow?
-                                               KWallet::Wallet::Asynchronous);
-        if (m_wallet) {
-            connect(m_wallet, SIGNAL(walletOpened(bool)), SLOT(walletOpened(bool)));
-        } else {
-            KMessageBox::error(0, i18n("Could not open KWallet"));
+        if (!m_passwdstore) {
+            m_passwdstore = new KPasswdStore(this);
+            m_passwdstore->setStoreID("KGet");
         }
-    }
-}
 
-void DlgWebinterface::walletOpened(bool opened)
-{
-    if (opened &&
-        (m_wallet->hasFolder("KGet") ||
-         m_wallet->createFolder("KGet")) &&
-         m_wallet->setFolder("KGet")) {
-        QString pwd;
-        m_wallet->readPassword("Webinterface", pwd);
-        webinterfacePwd->setText(pwd);
-    } else {
-        KMessageBox::error(0, i18n("Could not open KWallet"));
+        if (m_passwdstore->openStore(winId())) {
+            webinterfacePwd->setText(m_passwdstore->getPasswd("Webinterface", winId()));
+        } else {
+            KMessageBox::error(nullptr, i18n("Could not open KPasswdStore"));
+        }
     }
 }
 
 void DlgWebinterface::saveSettings()
 {
-    if (m_wallet) {
-        m_wallet->writePassword("Webinterface", webinterfacePwd->text());
+    if (m_passwdstore && m_passwdstore->openStore(winId())) {
+        m_passwdstore->storePasswd("Webinterface", webinterfacePwd->text(), winId());
     }
     emit saved();
 }
index 969f47d..f1b54f6 100644 (file)
 
 #include <QWidget>
 #include <KDialog>
+#include <kpasswdstore.h>
 
 #include "ui_dlgwebinterface.h"
 
-namespace KWallet {
-    class Wallet;
-}
-
 class DlgWebinterface : public QWidget, public Ui::DlgWebinterface
 {
     Q_OBJECT
@@ -35,10 +32,9 @@ signals:
 private Q_SLOTS:
     void readConfig();
     void saveSettings();
-    void walletOpened(bool);
     
 private:
-    KWallet::Wallet *m_wallet;
+    KPasswdStore *m_passwdstore;
 };
 
 #endif
index ed43217..eed350a 100644 (file)
@@ -21,7 +21,6 @@
 #include <KDebug>
 #include <KGlobalSettings>
 #include <KStandardDirs>
-#include <kwallet.h>
 
 #include <QTcpServer>
 #include <QTcpSocket>
@@ -68,46 +67,34 @@ void HttpHeaderParser::parseHeader(const QByteArray &header)
 
 HttpServer::HttpServer(QWidget *parent)
     : QObject(parent),
-      m_wallet(0)
+      m_passwdstore(nullptr)
 {
-    m_wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(),
-                                           parent->winId(),///Use MainWindow?
-                                           KWallet::Wallet::Asynchronous);
-    if (m_wallet) {
-        connect(m_wallet, SIGNAL(walletOpened(bool)), SLOT(init(bool)));
+    m_passwdstore = new KPasswdStore(this);
+    m_passwdstore->setStoreID("KGet");
+
+    if (m_passwdstore && m_passwdstore->openStore(parent->winId())) {
+        m_pwd = m_passwdstore->getPasswd("Webinterface", parent->winId());
+
+        m_tcpServer = new QTcpServer(this);
+        if (!m_tcpServer->listen(QHostAddress::Any, Settings::webinterfacePort())) {
+            KGet::showNotification(parent, "error", i18nc("@info", "Unable to start WebInterface: %1", m_tcpServer->errorString()));
+            return;
+        }
+
+        connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(handleRequest()));
     } else {
-        KGet::showNotification(parent, "error", i18n("Unable to start WebInterface: Could not open KWallet"));
+        KGet::showNotification(parent, "error", i18n("Unable to start WebInterface: Could not open KPasswdStore"));
     }
 }
 
 HttpServer::~HttpServer()
 {
-    delete m_wallet;
-}
-
-void HttpServer::init(bool opened)
-{
-    if (opened &&
-        m_wallet->hasFolder("KGet") &&
-        m_wallet->setFolder("KGet")) {
-        m_wallet->readPassword("Webinterface", m_pwd);
-    } else {
-        KGet::showNotification(static_cast<QWidget*>(parent()), "error", i18n("Unable to start WebInterface: Could not open KWallet"));
-        return;
-    }
-    m_tcpServer = new QTcpServer(this);
-    if (!m_tcpServer->listen(QHostAddress::Any, Settings::webinterfacePort())) {
-        KGet::showNotification(static_cast<QWidget*>(parent()), "error", i18nc("@info", "Unable to start WebInterface: %1", m_tcpServer->errorString()));
-        return;
-    }
-
-    connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(handleRequest()));
 }
 
 void HttpServer::settingsChanged()
 {
-    if (m_wallet) {
-        m_wallet->readPassword("Webinterface", m_pwd);
+    if (m_passwdstore && m_passwdstore->openStore(static_cast<QWidget*>(parent())->winId())) {
+        m_pwd = m_passwdstore->getPasswd("Webinterface");
     }
 }
 
index dd294e0..ab922db 100644 (file)
 #define HTTPSERVER_H
 
 #include <QWidget>
-
 #include <QTcpServer>
 
-namespace KWallet {
-    class Wallet;
-}
+#include <kpasswdstore.h>
 
 class HttpServer : public QObject
 {
@@ -30,11 +27,10 @@ public:
     void settingsChanged();
 
 private slots:
-    void init(bool);
     void handleRequest();
 
 private:
-    KWallet::Wallet *m_wallet;
+    KPasswdStore *m_passwdstore;
     QTcpServer *m_tcpServer;
     QString m_pwd;
 };
index 4a1f0e0..8899fa1 100644 (file)
@@ -28,7 +28,7 @@
    <item>
     <widget class="QCheckBox" name="kcfg_WalletSupport">
      <property name="text">
-      <string>Remember passwords (KWallet)</string>
+      <string>Remember passwords (KPasswdStore)</string>
      </property>
     </widget>
    </item>
index 35efb1d..d59517d 100644 (file)
@@ -10,7 +10,11 @@ kde4_add_kcfg_files(krdccore_SRCS settings.kcfgc)
 
 add_library(krdccore SHARED ${krdccore_SRCS})
 
-target_link_libraries(krdccore ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS})
+target_link_libraries(krdccore
+    ${KDE4_KDECORE_LIBS}
+    ${KDE4_KDEUI_LIBS}
+    ${KDE4_KPASSWDSTORE_LIBS}
+)
 
 set_target_properties(krdccore PROPERTIES
     VERSION ${GENERIC_LIB_VERSION}
index 83bd567..aaecb3e 100644 (file)
@@ -206,7 +206,7 @@ bool HostPreferences::showDialog(QWidget *parent)
     showAgainCheckBox->setChecked(showConfigAgain());
 
     walletSupportCheckBox = new QCheckBox(mainWidget);
-    walletSupportCheckBox->setText(i18n("Remember password (KWallet)"));
+    walletSupportCheckBox->setText(i18n("Remember password (KPasswdStore)"));
     walletSupportCheckBox->setChecked(walletSupport());
 
     layout->addWidget(showAgainCheckBox);
index e45a1a1..bf8e215 100644 (file)
@@ -41,7 +41,7 @@ RemoteView::RemoteView(QWidget *parent)
         m_scale(false),
         m_keyboardIsGrabbed(false),
 #ifndef QTONLY
-        m_wallet(0),
+        m_passwdStore(0),
 #endif
         m_dotCursorState(CursorOff)
 {
@@ -50,7 +50,7 @@ RemoteView::RemoteView(QWidget *parent)
 RemoteView::~RemoteView()
 {
 #ifndef QTONLY
-    delete m_wallet;
+    delete m_passwdStore;
 #endif
 }
 
@@ -198,31 +198,25 @@ KUrl RemoteView::url()
 #ifndef QTONLY
 QString RemoteView::readWalletPassword(bool fromUserNameOnly)
 {
-    const QString KRDCFOLDER = "KRDC";
-
     window()->setDisabled(true); // WORKAROUND: disable inputs so users cannot close the current tab (see #181230)
-    m_wallet = KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), window()->winId());
+    m_passwdStore = new KPasswdStore(this);
+    m_passwdStore->setStoreID("KRDC");
     window()->setDisabled(false);
 
-    if (m_wallet) {
-        bool walletOK = m_wallet->hasFolder(KRDCFOLDER);
-        if (!walletOK) {
-            walletOK = m_wallet->createFolder(KRDCFOLDER);
-            kDebug(5010) << "Wallet folder created";
-        }
+    if (m_passwdStore) {
+        const qlonglong windowId = window()->winId();
+        bool walletOK = m_passwdStore->openStore(windowId);
         if (walletOK) {
             kDebug(5010) << "Wallet OK";
-            m_wallet->setFolder(KRDCFOLDER);
-            QString password;
-            
+
             QString key;
             if (fromUserNameOnly)
                 key = m_url.userName();
             else
                 key = m_url.prettyUrl(KUrl::RemoveTrailingSlash);
 
-            if (m_wallet->hasEntry(key) &&
-                    !m_wallet->readPassword(key, password)) {
+            QString password = m_passwdStore->getPasswd(key.toUtf8(), windowId);
+            if (!password.isEmpty()) {
                 kDebug(5010) << "Password read OK";
 
                 return password;
@@ -240,9 +234,10 @@ void RemoteView::saveWalletPassword(const QString &password, bool fromUserNameOn
     else
         key = m_url.prettyUrl(KUrl::RemoveTrailingSlash);
 
-    if (m_wallet && m_wallet->isOpen()) {
+    const qlonglong windowId = window()->winId();
+    if (m_passwdStore && m_passwdStore->openStore(windowId)) {
         kDebug(5010) << "Write wallet password";
-        m_wallet->writePassword(key, password);
+        m_passwdStore->storePasswd(key.toUtf8(), password, windowId);
     }
 }
 #endif
index f91fcba..b90061c 100644 (file)
@@ -31,7 +31,7 @@
     #define KRDCCORE_EXPORT
 #else
     #include <KUrl>
-    #include <KWallet/Wallet>
+    #include <kpasswdstore.h>
     #include "krdccore_export.h"
 #endif
 
@@ -406,7 +406,7 @@ protected:
 #ifndef QTONLY
     QString readWalletPassword(bool fromUserNameOnly = false);
     void saveWalletPassword(const QString &password, bool fromUserNameOnly = false);
-    KWallet::Wallet *m_wallet;
+    KPasswdStore *m_passwdStore;
 #endif
 
     DotCursorState m_dotCursorState;
index 8c2ca69..754edee 100644 (file)
@@ -74,6 +74,7 @@ target_link_libraries(krfb
     ${QT_QTNETWORK_LIBRARY}
     ${KDE4_KDNSSD_LIBS}
     ${KDE4_KDEUI_LIBS}
+    ${KDE4_KPASSWDSTORE_LIBS}
     ${LIBVNCSERVER_LIBRARIES}
 )
 
index e5f22a6..acfa082 100644 (file)
@@ -22,6 +22,7 @@
 #include "invitationsrfbclient.h"
 #include "krfbconfig.h"
 #include "rfbservermanager.h"
+
 #include <QtCore/QTimer>
 #include <QtGui/QApplication>
 #include <QtNetwork/QHostInfo>
@@ -31,9 +32,7 @@
 #include <KUser>
 #include <KRandom>
 #include <KStringHandler>
-#include <KWallet/Wallet>
 #include <DNSSD/PublicService>
-using KWallet::Wallet;
 
 //static
 InvitationsRfbServer *InvitationsRfbServer::instance;
@@ -52,11 +51,38 @@ void InvitationsRfbServer::init()
     instance->setListeningPort(KrfbConfig::port());
     instance->setPasswordRequired(true);
 
-    instance->m_wallet = Wallet::openWallet(
-            Wallet::NetworkWallet(), 0, Wallet::Asynchronous);
-    if(instance->m_wallet) {
-        connect(instance->m_wallet, SIGNAL(walletOpened(bool)),
-                instance, SLOT(walletOpened(bool)));
+    instance->m_passwdStore = new KPasswdStore(instance);
+    instance->m_passwdStore->setStoreID("krfb");
+    QString desktopPassword;
+    QString unattendedPassword;
+    if ( !instance->m_passwdStore->openStore() ) {
+        desktopPassword = instance->m_passwdStore->getPasswd("desktopSharingPassword");
+        if (!desktopPassword.isEmpty()) {
+            instance->m_desktopPassword = desktopPassword;
+            emit instance->passwordChanged(instance->m_desktopPassword);
+        }
+
+        unattendedPassword = instance->m_passwdStore->getPasswd("unattendedAccessPassword");
+        if (!unattendedPassword.isEmpty()) {
+            instance->m_unattendedPassword = unattendedPassword;
+        }
+    } else {
+        kDebug() << "KPasswdStore is disabled, falling back to config file";
+        KSharedConfigPtr config = KGlobal::config();
+        KConfigGroup krfbConfig(config,"Security");
+
+        desktopPassword = KStringHandler::obscure(krfbConfig.readEntry(
+                "desktopPassword", QString()));
+        if(!desktopPassword.isEmpty()) {
+            instance->m_desktopPassword = desktopPassword;
+            emit instance->passwordChanged(instance->m_desktopPassword);
+        }
+
+        unattendedPassword = KStringHandler::obscure(krfbConfig.readEntry(
+                "unattendedPassword", QString()));
+        if(!unattendedPassword.isEmpty()) {
+            instance->m_unattendedPassword = unattendedPassword;
+        }
     }
 }
 
@@ -123,16 +149,9 @@ InvitationsRfbServer::~InvitationsRfbServer()
     KSharedConfigPtr config = KGlobal::config();
     KConfigGroup krfbConfig(config,"Security");
     krfbConfig.writeEntry("allowUnattendedAccess",m_allowUnattendedAccess);
-    if(m_wallet && m_wallet->isOpen()) {
-
-         if( (m_wallet->currentFolder()=="krfb") ||
-                 ((m_wallet->hasFolder("krfb") || m_wallet->createFolder("krfb")) &&
-                    m_wallet->setFolder("krfb")) ) {
-
-             m_wallet->writePassword("desktopSharingPassword",m_desktopPassword);
-             m_wallet->writePassword("unattendedAccessPassword",m_unattendedPassword);
-         }
-
+    if (m_passwdStore && m_passwdStore->openStore()) {
+            m_passwdStore->storePasswd("desktopSharingPassword", m_desktopPassword);
+            m_passwdStore->storePasswd("unattendedAccessPassword", m_unattendedPassword);
     } else {
         krfbConfig.writeEntry("desktopPassword",
                 KStringHandler::obscure(m_desktopPassword));
@@ -148,48 +167,6 @@ PendingRfbClient* InvitationsRfbServer::newClient(rfbClientPtr client)
     return new PendingInvitationsRfbClient(client, this);
 }
 
-void InvitationsRfbServer::walletOpened(bool opened)
-{
-    QString desktopPassword;
-    QString unattendedPassword;
-    Q_ASSERT(m_wallet);
-    if( opened &&
-            ( m_wallet->hasFolder("krfb") || m_wallet->createFolder("krfb") ) &&
-            m_wallet->setFolder("krfb") ) {
-
-        if(m_wallet->readPassword("desktopSharingPassword", desktopPassword)==0 &&
-                !desktopPassword.isEmpty()) {
-            m_desktopPassword = desktopPassword;
-            emit passwordChanged(m_desktopPassword);
-        }
-
-        if(m_wallet->readPassword("unattendedAccessPassword", unattendedPassword)==0 &&
-                !unattendedPassword.isEmpty()) {
-            m_unattendedPassword = unattendedPassword;
-        }
-
-    } else {
-
-        kDebug() << "Could not open KWallet, Falling back to config file";
-        KSharedConfigPtr config = KGlobal::config();
-        KConfigGroup krfbConfig(config,"Security");
-
-        desktopPassword = KStringHandler::obscure(krfbConfig.readEntry(
-                "desktopPassword", QString()));
-        if(!desktopPassword.isEmpty()) {
-            m_desktopPassword = desktopPassword;
-            emit passwordChanged(m_desktopPassword);
-        }
-
-        unattendedPassword = KStringHandler::obscure(krfbConfig.readEntry(
-                "unattendedPassword", QString()));
-        if(!unattendedPassword.isEmpty()) {
-            m_unattendedPassword = unattendedPassword;
-        }
-
-    }
-}
-
 // a random string that doesn't contain i, I, o, O, 1, l, 0
 // based on KRandom::randomString()
 QString InvitationsRfbServer::readableRandomString(int length)
index bba830a..9ba074f 100644 (file)
@@ -22,9 +22,7 @@
 
 #include "rfbserver.h"
 
-namespace KWallet {
-    class Wallet;
-}
+#include <kpasswdstore.h>
 
 namespace DNSSD {
     class PublicService;
@@ -56,15 +54,12 @@ protected:
     virtual ~InvitationsRfbServer();
     virtual PendingRfbClient* newClient(rfbClientPtr client);
 
-private Q_SLOTS:
-    void walletOpened(bool);
-
 private:
     DNSSD::PublicService *m_publicService;
     bool m_allowUnattendedAccess;
     QString m_desktopPassword;
     QString m_unattendedPassword;
-    KWallet::Wallet *m_wallet;
+    KPasswdStore *m_passwdStore;
 
     QString readableRandomString(int);
     Q_DISABLE_COPY(InvitationsRfbServer)
index a4f037a..37525c8 100644 (file)
@@ -248,6 +248,7 @@ kde4_add_plugin(okularpart ${okularpart_SRCS})
 target_link_libraries(okularpart
     ${KDE4_KPARTS_LIBS}
     ${KDE4_SOLID_LIBS}
+    ${KDE4_KPASSWDSTORE_LIBS}
     ${QT_QTGUI_LIBRARY}
     ${MATH_LIB}
     okularcore
index 49925f1..d54428a 100644 (file)
@@ -48,7 +48,7 @@ In progress [working on]:
 -> various backends: fill about data information
 -> gui: add config for gfx (yes/no) and text (yes/no/kde) antialias
 -> core: provide a binary compatible okularcore library to extend the format capabilities
--> KPDF -> okular conversion of configuration & datafiles {configuration(done), document data(in progress), kwallet passwords(missing)}
+-> KPDF -> okular conversion of configuration & datafiles {configuration(done), document data(in progress), kpasswdstore passwords(missing)}
 -> inverse search (BR113191)
    find with an usability expert the "best" way to activate such a link
    provide a configuration widget to choose the editor and configure a custom one
index abe0e40..3d449a5 100644 (file)
@@ -4240,12 +4240,12 @@ void Document::setAnnotationEditingEnabled( bool enable )
     foreachObserver( notifySetup( d->m_pagesVector, 0 ) );
 }
 
-void Document::walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const
+void Document::walletDataForFile( const QString &fileName, QString *walletName, QString *walletKey ) const
 {
     if (d->m_generator) {
-        d->m_generator->walletDataForFile( fileName, walletName, walletFolder, walletKey );
+        d->m_generator->walletDataForFile( fileName, walletName, walletKey );
     } else if (d->m_walletGenerator) {
-        d->m_walletGenerator->walletDataForFile( fileName, walletName, walletFolder, walletKey );
+        d->m_walletGenerator->walletDataForFile( fileName, walletName, walletKey );
     }
 }
 
index 85952d5..9a4f889 100644 (file)
@@ -725,7 +725,7 @@ class OKULAR_EXPORT Document : public QObject
          *
          * @since 0.20 (KDE 4.14)
         */
-        void walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const;
+        void walletDataForFile( const QString &fileName, QString *walletName, QString *walletKey ) const;
 
     public Q_SLOTS:
         /**
index a3e000b..c635c17 100644 (file)
@@ -18,7 +18,6 @@
 #include <kdebug.h>
 #include <kicon.h>
 #include <klocale.h>
-#include <kwallet.h>
 
 #include "document.h"
 #include "document_p.h"
@@ -359,11 +358,10 @@ bool Generator::exportTo( const QString&, const ExportFormat& )
     return false;
 }
 
-void Generator::walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const
+void Generator::walletDataForFile( const QString &fileName, QString *walletName, QString *walletKey ) const
 {
     *walletKey = fileName.section('/', -1, -1);
-    *walletName = KWallet::Wallet::NetworkWallet();
-    *walletFolder = "KPdf";
+    *walletName = "KPdf";
 }
 
 bool Generator::hasFeature( GeneratorFeature feature ) const
index 3990f8e..512822e 100644 (file)
@@ -415,7 +415,7 @@ class OKULAR_EXPORT Generator : public QObject
          * Unless you have very special requirements to where wallet data should be stored you
          * don't need to reimplement this method.
          */
-        virtual void walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const;
+        virtual void walletDataForFile( const QString &fileName, QString *walletName, QString *walletKey ) const;
 
         /**
          * Query for the specified @p feature.
index 0781730..33c2359 100644 (file)
@@ -14,7 +14,6 @@
 #include <kaboutdata.h>
 #include <klocale.h>
 #include <kconfigdialog.h>
-#include <kwallet.h>
 
 static KAboutData createAboutData()
 {
@@ -46,9 +45,8 @@ void KOOOGenerator::addPages( KConfigDialog* dlg )
     dlg->addPage( widget, generalSettings(), i18n("OpenDocument Text"), "application-vnd.oasis.opendocument.text", i18n("OpenDocument Text Backend Configuration") );
 }
 
-void KOOOGenerator::walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const
+void KOOOGenerator::walletDataForFile( const QString &fileName, QString *walletName, QString *walletKey ) const
 {
     *walletKey = fileName + "/opendocument";
-    *walletName = KWallet::Wallet::LocalWallet();
-    *walletFolder = KWallet::Wallet::PasswordFolder();
+    *walletName = "okular_ooo_generator";
 }
index 2bfa81c..478e54d 100644 (file)
@@ -20,7 +20,7 @@ class KOOOGenerator : public Okular::TextDocumentGenerator
     // [INHERITED] reparse configuration
     void addPages( KConfigDialog* dlg );
 
-    virtual void walletDataForFile( const QString &fileName, QString *walletName, QString *walletFolder, QString *walletKey ) const;
+    virtual void walletDataForFile( const QString &fileName, QString *walletName, QString *walletKey ) const;
 };
 
 #endif
index 7005764..0381427 100644 (file)
@@ -62,7 +62,7 @@
 #include <kdeprintdialog.h>
 #include <kbookmarkmenu.h>
 #include <kpassworddialog.h>
-#include <kwallet.h>
+#include <kpasswdstore.h>
 
 // local includes
 #include "aboutdata.h"
@@ -1237,31 +1237,28 @@ Document::OpenResult Part::doOpenFile( const KMimeType::Ptr &mimeA, const QStrin
         }
 
         // if the file didn't open correctly it might be encrypted, so ask for a pass
-        QString walletName, walletFolder, walletKey;
-        m_document->walletDataForFile(fileNameToOpen, &walletName, &walletFolder, &walletKey);
+        QString walletName, walletKey;
+        m_document->walletDataForFile(fileNameToOpen, &walletName, &walletKey);
         bool firstInput = true;
         bool triedWallet = false;
-        KWallet::Wallet * wallet = 0;
         bool keep = true;
         while ( openResult == Document::OpenNeedsPassword )
         {
+            KPasswdStore store;
+            bool storeopened = false;
+            const WId parentwid = widget()->effectiveWinId();
             QString password;
 
-            // 1.A. try to retrieve the first password from the kde wallet system
+            // 1.A. try to retrieve the first password from the kde store system
             if ( !triedWallet && !walletKey.isNull() )
             {
-                const WId parentwid = widget()->effectiveWinId();
-                wallet = KWallet::Wallet::openWallet( walletName, parentwid );
-                if ( wallet )
+                storeopened = store.openStore( parentwid );
+                store.setStoreID(walletName);
+                if ( storeopened )
                 {
-                    // use the KPdf folder (and create if missing)
-                    if ( !wallet->hasFolder( walletFolder ) )
-                        wallet->createFolder( walletFolder );
-                    wallet->setFolder( walletFolder );
-
                     // look for the pass in that folder
-                    QString retrievedPass;
-                    if ( wallet->readPassword( walletKey, retrievedPass ) == 0)
+                    QString retrievedPass = store.getPasswd( walletKey.toUtf8(), parentwid );
+                    if (!retrievedPass.isEmpty())
                         password = retrievedPass;
                 }
                 triedWallet = true;
@@ -1278,13 +1275,13 @@ Document::OpenResult Part::doOpenFile( const KMimeType::Ptr &mimeA, const QStrin
                 firstInput = false;
 
                 // if the user presses cancel, abort opening
-                KPasswordDialog dlg( widget(), wallet ? KPasswordDialog::ShowKeepPassword : KPasswordDialog::KPasswordDialogFlags() );
+                KPasswordDialog dlg( widget(), storeopened ? KPasswordDialog::ShowKeepPassword : KPasswordDialog::KPasswordDialogFlags() );
                 dlg.setCaption( i18n( "Document Password" ) );
                 dlg.setPrompt( prompt );
                 if( !dlg.exec() )
                     break;
                 password = dlg.password();
-                if ( wallet )
+                if ( storeopened )
                     keep = dlg.keepPassword();
             }
 
@@ -1300,9 +1297,9 @@ Document::OpenResult Part::doOpenFile( const KMimeType::Ptr &mimeA, const QStrin
             }
 
             // 3. if the password is correct and the user chose to remember it, store it to the wallet
-            if ( openResult == Document::OpenSuccess && wallet && /*safety check*/ wallet->isOpen() && keep )
+            if ( openResult == Document::OpenSuccess && storeopened && keep )
             {
-                wallet->writePassword( walletKey, password );
+                store.storePasswd( walletKey.toUtf8(), password, parentwid );
             }
         }
     }