From kfm-devel Tue Dec 09 00:25:27 2003 From: Zack Rusin Date: Tue, 09 Dec 2003 00:25:27 +0000 To: kfm-devel Subject: Re: Patch for 67179 X-MARC-Message: https://marc.info/?l=kfm-devel&m=107092963503218 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_3ZR1/8JHTE3OoLE" --Boundary-00=_3ZR1/8JHTE3OoLE Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Monday 08 December 2003 16:22, Dirk Mueller wrote: > I wouldn't name it "cacheable" though, since caching has a different > meaning for me imho. But otherwise okay. Great. Well, then this is the final version. Zack -- He who laughs last thinks slowest! --Boundary-00=_3ZR1/8JHTE3OoLE Content-Type: text/x-diff; charset="iso-8859-1"; name="savform.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="savform.diff" ? cur.diff ? debug ? result ? results ? results1 ? results2 ? resultx ? resultx2 ? rendering/render_obj.cpp.diff Index: khtmlview.cpp =================================================================== RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v retrieving revision 1.596 diff -u -3 -p -b -B -r1.596 khtmlview.cpp --- khtmlview.cpp 5 Dec 2003 18:43:45 -0000 1.596 +++ khtmlview.cpp 9 Dec 2003 00:24:03 -0000 @@ -1850,6 +1850,32 @@ void KHTMLView::addFormCompletionItem(co d->formCompletions->writeEntry(name, items); } +void KHTMLView::addNonPasswordStorableSite(const QString& host) +{ + if (!d->formCompletions) { + d->formCompletions = new KSimpleConfig(locateLocal("data", "khtml/formcompletions")); + } + + d->formCompletions->setGroup("NonPasswordStorableSites"); + QStringList sites = d->formCompletions->readListEntry("Sites"); + sites.append(host); + d->formCompletions->writeEntry("Sites", sites); + d->formCompletions->sync(); + d->formCompletions->setGroup(QString::null);//reset +} + +bool KHTMLView::nonPasswordStorableSite(const QString& host) const +{ + if (!d->formCompletions) { + d->formCompletions = new KSimpleConfig(locateLocal("data", "khtml/formcompletions")); + } + d->formCompletions->setGroup("NonPasswordStorableSites"); + QStringList sites = d->formCompletions->readListEntry("Sites"); + d->formCompletions->setGroup(QString::null);//reset + + return (sites.find(host) != sites.end()); +} + // returns true if event should be swallowed bool KHTMLView::dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, bool cancelable, int detail,QMouseEvent *_mouse, bool setUnder, Index: khtmlview.h =================================================================== RCS file: /home/kde/kdelibs/khtml/khtmlview.h,v retrieving revision 1.199 diff -u -3 -p -b -B -r1.199 khtmlview.h --- khtmlview.h 27 Nov 2003 14:48:52 -0000 1.199 +++ khtmlview.h 9 Dec 2003 00:24:03 -0000 @@ -254,6 +254,9 @@ private: void clearCompletionHistory(const QString& name); void addFormCompletionItem(const QString &name, const QString &value); + void addNonPasswordStorableSite( const QString& host ); + bool nonPasswordStorableSite( const QString& host ) const; + bool dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, bool cancelable, int detail,QMouseEvent *_mouse, bool setUnder, int mouseEventType); Index: html/html_formimpl.cpp =================================================================== RCS file: /home/kde/kdelibs/khtml/html/html_formimpl.cpp,v retrieving revision 1.354 diff -u -3 -p -b -B -r1.354 html_formimpl.cpp --- html/html_formimpl.cpp 5 Dec 2003 14:35:28 -0000 1.354 +++ html/html_formimpl.cpp 9 Dec 2003 00:24:04 -0000 @@ -460,6 +460,8 @@ void HTMLFormElementImpl::submit( ) QMap walletMap; bool havePassword = false; bool haveTextarea = false; + KURL formUrl(getDocument()->URL()); + if (!view->nonPasswordStorableSite(formUrl.host())) { for (QPtrListIterator it(formElements); it.current(); ++it) if (it.current()->id() == ID_INPUT) { HTMLInputElementImpl* c = static_cast (it.current()); @@ -473,10 +475,21 @@ void HTMLFormElementImpl::submit( ) } else if (it.current()->id() == ID_TEXTAREA) haveTextarea = true; + } - if (havePassword && !haveTextarea) { - // ### ask the user if he wants to cache the form data, per domain etc + int savePassword = KMessageBox::Yes; + if (havePassword && !haveTextarea && + (savePassword=KMessageBox::questionYesNoCancel( + 0, + i18n("Konqueror has the ability to store the password " + "in an encrypted wallet. When the wallet is unlocked, it " + "can then automatically restore the login information " + "next time you visit this site. Do you want to store " + "the information now?"), + i18n("Save passwords"), + KStdGuiItem::yes(), + KGuiItem(i18n("Never for this site")))) == KMessageBox::Yes) { KWallet::Wallet* w = view->part()->wallet(); if (w) { QString key = calculateAutoFillKey(*this); @@ -487,6 +500,8 @@ void HTMLFormElementImpl::submit( ) w->setFolder(KWallet::Wallet::FormDataFolder()); w->writeMap(key, walletMap); } + } else if (savePassword == KMessageBox::No) { + view->addNonPasswordStorableSite(formUrl.host()); } DOMString url(khtml::parseURL(getAttribute(ATTR_ACTION))); --Boundary-00=_3ZR1/8JHTE3OoLE--