[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/base/konq-plugins/clearhttpauth
From:       Tom Albers <tomalbers () kde ! nl>
Date:       2009-01-31 23:40:39
Message-ID: 1233445239.721435.7240.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 919431 by toma:

Clear the password from the KWallet and reload the page.


 M  +45 -1     plugin_clearhttpauth.cpp  


--- trunk/playground/base/konq-plugins/clearhttpauth/plugin_clearhttpauth.cpp #919430:919431
@@ -23,6 +23,7 @@
 // KDE
 #include <KActionCollection>
 #include <KGenericFactory>
+#include <kwallet.h>
 
 // Qt
 #include <QDBusInterface>
@@ -54,8 +55,51 @@
 void PluginClearHttpAuth::slotClearHttpAuth()
 {
     kDebug() << "Clear it!" << m_part->url();
-    QDBusInterface dbus( "org.kde.kded", "/modules/kpasswdserver","org.kde.KPasswdServer");
+    QDBusInterface dbus( "org.kde.kded", "/modules/kpasswdserver","org.kde.KPasswdServer" );
     dbus.call( "removeAuthInfo", m_part->url().host(), m_part->url().protocol(), QString() );
+
+    // remove it from the wallet too
+    KWallet::Wallet* wallet = KWallet::Wallet::openWallet(
+                                  KWallet::Wallet::NetworkWallet(), m_part->widget()->winId() );
+
+    // no wallet?
+    if ( !wallet )
+        return;
+
+    // set folder or if no password folder exit.
+    if ( !wallet->hasFolder( KWallet::Wallet::PasswordFolder() ) ) {
+        delete wallet;
+        return;
+    }
+    wallet->setFolder( KWallet::Wallet::PasswordFolder() );
+
+    // get all entries and find the one that applies...
+    const QStringList list = wallet->entryList();
+    QString key;
+    foreach( const QString& item, list ) {
+        kDebug() << "Considering: " << item;
+        if ( item.startsWith( m_part->url().protocol()+"-"+m_part->url().host() ) ) {
+            key = item;
+            break;
+        }
+    }
+
+    // did we find the correct entry?
+    if ( key.isEmpty() ) {
+        kDebug() << "No entry found";
+        delete wallet;
+        return;
+    }
+
+    kDebug() << "Deleting:" << key;
+    wallet->removeEntry( key );
+    delete wallet;
+
+    // Reload the page.
+    KParts::OpenUrlArguments args;
+    args.setReload( true );
+    m_part->setArguments( args );
+    m_part->openUrl( m_part->url() );
 }
 
 #include "plugin_clearhttpauth.moc"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic