1 /* This file is part of the KDE project
2 Copyright (C) 2000 David Faure <faure@kde.org>
3 Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License version 2 or at your option version 3 as published by
8 the Free Software Foundation.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
25 #include <QtCore/QTimer>
26 #include <QtGui/QPainter>
31 #include <kdatetime.h>
32 #include <kcharsets.h>
33 #include <kbookmarkmanager.h>
41 #include "bookmarkiterator.h"
42 #include "bookmarkmodel.h"
44 TestLinkItrHolder
*TestLinkItrHolder::s_self
= 0;
46 TestLinkItrHolder::TestLinkItrHolder()
47 : BookmarkIteratorHolder() {
51 void TestLinkItrHolder::doItrListChanged() {
52 KEBApp::self()->setCancelTestsEnabled(count() > 0);
55 kDebug()<<"Notifing managers "<<m_affectedBookmark
;
56 CurrentMgr::self()->notifyManagers(CurrentMgr::bookmarkAt(m_affectedBookmark
).toGroup());
57 m_affectedBookmark
.clear();
61 void TestLinkItrHolder::addAffectedBookmark( const QString
& address
)
63 kDebug()<<"addAffectedBookmark "<<address
;
64 if(m_affectedBookmark
.isNull())
65 m_affectedBookmark
= address
;
67 m_affectedBookmark
= KBookmark::commonParent(m_affectedBookmark
, address
);
68 kDebug()<<" m_affectedBookmark is now "<<m_affectedBookmark
;
71 /* -------------------------- */
73 TestLinkItr::TestLinkItr(QList
<KBookmark
> bks
)
74 : BookmarkIterator(bks
) {
78 TestLinkItr::~TestLinkItr() {
79 //FIXME setStatus(m_oldStatus); if we didn't finish
81 // kDebug() << "JOB kill\n";
87 void TestLinkItr::setStatus(const QString
& text
)
89 EditCommand::setNodeText(curBk(), QStringList()<< "info" << "metadata" << "linkstate", text
);
90 CurrentMgr::self()->model()->emitDataChanged(curBk());
93 bool TestLinkItr::isApplicable(const KBookmark
&bk
) const {
94 return (!bk
.isGroup() && !bk
.isSeparator());
97 void TestLinkItr::doAction() {
98 kDebug()<<"TestLinkItr::doAction() "<<endl
;
99 m_job
= KIO::get(curBk().url(), KIO::Reload
, KIO::HideProgressInfo
);
100 m_job
->addMetaData( QString("cookies"), QString("none") );
101 m_job
->addMetaData( QString("errorPage"), QString("false") );
103 connect(m_job
, SIGNAL( result( KJob
*)),
104 this, SLOT( slotJobResult(KJob
*)));
106 m_oldStatus
= EditCommand::getNodeText(curBk(), QStringList()<< "info" << "metadata" << "linkstate");
107 setStatus(i18n("Checking..."));
110 void TestLinkItr::slotJobResult(KJob
*job
) {
111 kDebug()<<"TestLinkItr::slotJobResult()"<<endl
;
114 KIO::TransferJob
*transfer
= (KIO::TransferJob
*)job
;
115 QString modDate
= transfer
->queryMetaData("modified");
117 if (transfer
->error() || transfer
->isErrorPage())
119 kDebug()<<"***********"<<transfer
->error()<<" "<<transfer
->isErrorPage()<<endl
;
120 // can we assume that errorString will contain no entities?
121 QString err
= transfer
->errorString();
122 err
.replace("\n", " ");
127 if (!modDate
.isEmpty())
130 setStatus(i18n("OK"));
133 holder()->addAffectedBookmark(KBookmark::parentAddress(curBk().address()));
134 delayedEmitNextOne();
135 //FIXME check that we don't need to call kill()
137 #include "testlink.moc"