summaryrefslogtreecommitdiffstats
path: root/kio/tests
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kio/tests
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kio/tests')
-rw-r--r--kio/tests/Makefile.am91
-rw-r--r--kio/tests/dataprotocoltest.cpp287
-rw-r--r--kio/tests/dummymeta.cpp20
-rw-r--r--kio/tests/dummymeta.desktop54
-rw-r--r--kio/tests/dummymeta.h20
-rw-r--r--kio/tests/getalltest.cpp44
-rw-r--r--kio/tests/jobtest.cpp613
-rw-r--r--kio/tests/jobtest.h79
-rw-r--r--kio/tests/kacltest.cpp309
-rw-r--r--kio/tests/kacltest.h53
-rw-r--r--kio/tests/kdcopcheck.cpp132
-rw-r--r--kio/tests/kdcopcheck.h28
-rw-r--r--kio/tests/kdefaultprogresstest.cpp39
-rw-r--r--kio/tests/kdirlistertest.cpp162
-rw-r--r--kio/tests/kdirlistertest.h120
-rw-r--r--kio/tests/kdirwatchtest.cpp82
-rw-r--r--kio/tests/kdirwatchtest.h33
-rw-r--r--kio/tests/kdirwatchunittest.cpp180
-rw-r--r--kio/tests/kdirwatchunittest.h66
-rw-r--r--kio/tests/kfiltertest.cpp118
-rw-r--r--kio/tests/kionetrctest.cpp71
-rw-r--r--kio/tests/kiopassdlgtest.cpp32
-rw-r--r--kio/tests/kioslavetest.cpp555
-rw-r--r--kio/tests/kioslavetest.h108
-rw-r--r--kio/tests/kmfitest.cpp28
-rw-r--r--kio/tests/kmimefromext.cpp53
-rw-r--r--kio/tests/kmimemagictest.cpp54
-rw-r--r--kio/tests/kmimetypetest.cpp76
-rw-r--r--kio/tests/kpropsdlgtest.cpp35
-rw-r--r--kio/tests/kprotocolinfotest.cpp59
-rw-r--r--kio/tests/kruntest.cpp209
-rw-r--r--kio/tests/kruntest.h58
-rw-r--r--kio/tests/kscantest.cpp16
-rw-r--r--kio/tests/kshredtest.cpp74
-rw-r--r--kio/tests/ksycocatest.cpp360
-rw-r--r--kio/tests/ksycocaupdatetest.cpp11
-rw-r--r--kio/tests/ktartest.cpp178
-rw-r--r--kio/tests/ktradertest.cpp108
-rw-r--r--kio/tests/kurifiltertest.cpp361
-rw-r--r--kio/tests/kurlcompletiontest.cpp189
-rw-r--r--kio/tests/kziptest.cpp435
-rw-r--r--kio/tests/metatest.cpp321
-rw-r--r--kio/tests/netaccesstest.cpp48
-rw-r--r--kio/tests/previewtest.cpp64
-rw-r--r--kio/tests/previewtest.h25
-rw-r--r--kio/tests/speed.cpp139
-rw-r--r--kio/tests/speed.h24
-rw-r--r--kio/tests/wronglocalsizes.zipbin0 -> 325 bytes
48 files changed, 6221 insertions, 0 deletions
diff --git a/kio/tests/Makefile.am b/kio/tests/Makefile.am
new file mode 100644
index 000000000..4ec6be6f3
--- /dev/null
+++ b/kio/tests/Makefile.am
@@ -0,0 +1,91 @@
+# This file is part of the KDE libraries
+# Copyright (C) 1997 David Faure <faure@kde.org>
+
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+
+# You should have received a copy of the GNU Library General Public License
+# along with this library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/kio $(all_includes)
+LDADD = $(LIB_KIO)
+AM_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+check_PROGRAMS = ksycocatest getalltest kruntest ktartest kziptest\
+ kioslavetest kdirwatchtest kshredtest speed kurifiltertest \
+ kdefaultprogresstest kmimemagictest \
+ kfiltertest kiopassdlgtest kscantest kdirlistertest \
+ previewtest kionetrctest kdcopcheck metatest \
+ kmimefromext kpropsdlgtest kmfitest dataprotocoltest \
+ kprotocolinfotest ksycocaupdatetest netaccesstest jobtest \
+ kurlcompletiontest kmimetypetest kacltest
+
+# Unfortunately some tests depend on the network settings, it seems
+#check: kurifiltertest
+# ./kurifiltertest
+check-local: kziptest
+ ./kziptest list $(srcdir)/wronglocalsizes.zip
+
+TESTS = kmimetypetest
+
+bin_PROGRAMS = ktradertest
+
+METASOURCES = AUTO
+
+speed_SOURCES = speed.cpp
+kioslavetest_SOURCES = kioslavetest.cpp
+kshredtest_SOURCES = kshredtest.cpp
+kdefaultprogresstest_SOURCES = kdefaultprogresstest.cpp
+kionetrctest_SOURCES = kionetrctest.cpp
+kiopassdlgtest_SOURCES = kiopassdlgtest.cpp
+kurifiltertest_SOURCES = kurifiltertest.cpp
+ksycocatest_SOURCES = ksycocatest.cpp
+kdcopcheck_SOURCES = kdcopcheck.cpp
+getalltest_SOURCES = getalltest.cpp
+kruntest_SOURCES = kruntest.cpp
+kdirwatchtest_SOURCES = kdirwatchtest.cpp
+ktradertest_SOURCES = ktradertest.cpp
+kmimemagictest_SOURCES = kmimemagictest.cpp
+kfiltertest_SOURCES = kfiltertest.cpp
+kscantest_SOURCES = kscantest.cpp
+kdirlistertest_SOURCES = kdirlistertest.cpp
+previewtest_SOURCES = previewtest.cpp
+ktartest_SOURCES = ktartest.cpp
+kziptest_SOURCES = kziptest.cpp
+metatest_SOURCES = metatest.cpp
+kmimefromext_SOURCES = kmimefromext.cpp
+kpropsdlgtest_SOURCES = kpropsdlgtest.cpp
+kmfitest_SOURCES = kmfitest.cpp
+dataprotocoltest_SOURCES = dataprotocoltest.cpp
+kprotocolinfotest_SOURCES = kprotocolinfotest.cpp
+ksycocaupdatetest_SOURCES = ksycocaupdatetest.cpp
+netaccesstest_SOURCES = netaccesstest.cpp
+jobtest_SOURCES = jobtest.cpp
+kurlcompletiontest_SOURCES = kurlcompletiontest.cpp
+kmimetypetest_SOURCES = kmimetypetest.cpp
+kacltest_SOURCES = kacltest.cpp
+
+
+check_LTLIBRARIES = kunittest_kdirwatch.la
+kunittest_kdirwatch_la_SOURCES = kdirwatchunittest.cpp
+kunittest_kdirwatch_la_LIBADD = $(LIB_KUNITTEST) $(LIB_KIO)
+kunittest_kdirwatch_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN)
+
+# kfile meta stuff. Comment this in, if you want a small
+# metadata plugin test and "make install".
+#kde_module_LTLIBRARIES = dummymeta.la
+#dummymeta_la_SOURCES = dummymeta.cpp
+#dummymeta_la_LIBADD = $(LIB_KIO)
+#dummymeta_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+#services_DATA = dummymeta.desktop
+#servicesdir = $(kde_servicesdir)
diff --git a/kio/tests/dataprotocoltest.cpp b/kio/tests/dataprotocoltest.cpp
new file mode 100644
index 000000000..fa867291c
--- /dev/null
+++ b/kio/tests/dataprotocoltest.cpp
@@ -0,0 +1,287 @@
+// testing the data kioslave
+// (C) 2002, 2003 Leo Savernik
+//
+// invoke "make dataprotocoltest" to generate the binary inside KDE CVS
+// invoke "make test" to generate the binary outside KDE CVS
+
+// fix the symptoms, not the illness ;-)
+#ifdef QT_NO_ASCII_CAST
+# undef QT_NO_ASCII_CAST
+#endif
+
+#ifdef DATAKIOSLAVE
+# undef DATAKIOSLAVE
+#endif
+#ifndef TESTKIO
+# define TESTKIO
+#endif
+
+#include <kio/global.h>
+
+#include <qcstring.h>
+#include <qstring.h>
+
+#include <iostream.h>
+
+class KURL;
+
+class TestSlave {
+public:
+ TestSlave() {
+ }
+ virtual ~TestSlave() {
+ }
+
+ virtual void get(const KURL &) = 0;
+ virtual void mimetype(const KURL &) = 0;
+
+ void mimeType(const QString &type) {
+ testStrings("MIME Type: ",mime_type_expected,type);
+ }
+
+ void totalSize(KIO::filesize_t bytes) {
+// cout << "content size: " << bytes << " bytes" << endl;
+ }
+
+ void setMetaData(const QString &key, const QString &value) {
+// meta_data[key] = value;
+// cout << " " << key << " = " << value << endl;
+ QString prefix = "Metadata[\""+key+"\"]: ";
+ KIO::MetaData::Iterator it = attributes_expected.find(key);
+ if (it != attributes_expected.end()) {
+ testStrings(prefix,it.data(),value);
+ // remove key from map
+ attributes_expected.remove(it);
+ } else {
+ cout << endl << prefix << " no such key expected";
+ total++;
+ }
+ }
+
+ void sendMetaData() {
+ // check here if attributes_expected contains any excess keys
+ KIO::MetaData::ConstIterator it = attributes_expected.begin();
+ KIO::MetaData::ConstIterator end = attributes_expected.end();
+ for (; it != end; ++it) {
+ cout << endl << "Metadata[\"" << it.key()
+ << "\"] was expected but not defined";
+ total++;
+ }
+ }
+
+ void data(const QByteArray &a) {
+ if (a.isEmpty())
+/* cout << "<no more data>" << endl*/;
+ else {
+ testStrings("Content: ",content_expected,a);
+ }/*end if*/
+ }
+
+ void finished() {
+ }
+
+ void dispatchLoop() {
+ // dummy to make kde_main happy
+ }
+
+ // == stuff for regression testing
+private:
+ int testcaseno; // number of testcase
+ bool failure; // true if any testcase failed
+ QMap<int,bool> failed_testcases;
+
+ // -- testcase related members
+ QString mime_type_expected; // expected mime type
+ /** contains all attributes and values the testcase has to set */
+ KIO::MetaData attributes_expected;
+ /** contains the content as it is expected to be returned */
+ QByteArray content_expected;
+ int passed; // # of passed tests
+ int total; // # of total tests
+
+ /**
+ * compares two strings, printing an error message if they don't match.
+ * @param prefix prefix string for output in case of mismatch
+ * @param templat template string
+ * @param s string to compare to template
+ * @param casesensitive true if case sensitive compare (currently not used)
+ */
+ void testStrings(const QString &prefix, const QString &templat,
+ const QString &s, bool /*casesensitive*/ = true) {
+ if (templat == s)
+ passed++;
+ else {
+ cout << endl << prefix << "expected \"" << templat << "\", found \""
+ << s << "\"";
+ failure = true;
+ }/*end if*/
+ total++;
+ }
+
+public:
+ /** begins a testrun over all testcases */
+ void initTestrun() {
+ testcaseno = 0;
+ failure = false;
+ }
+
+ /** reuturns true if any testcase failed
+ */
+ bool hasFailedTestcases() const { return failure; }
+
+ /**
+ * sets up a new testcase
+ * @param name screen name for testcase
+ */
+ void beginTestcase(const char *name) {
+ passed = 0;
+ total = 0;
+ testcaseno++;
+ cout << "Testcase " << testcaseno << ": [" << name << "] ";
+ }
+
+ /**
+ * sets the mime type that this testcase is expected to return
+ */
+ void setExpectedMimeType(const QString &mime_type) {
+ mime_type_expected = mime_type;
+ }
+
+ /**
+ * sets all attribute-value pairs the testcase must deliver.
+ */
+ void setExpectedAttributes(const KIO::MetaData &attres) {
+ attributes_expected = attres;
+ }
+
+ /**
+ * sets content as expected to be delivered by the testcase.
+ */
+ void setExpectedContent(const QByteArray &content) {
+ content_expected = content;
+ }
+
+ /**
+ * closes testcase, printing out stats
+ */
+ void endTestcase() {
+ bool failed = passed < total;
+ if (failed) {
+ failure = true;
+ failed_testcases[testcaseno] = true;
+ cout << endl;
+ }
+ cout << "(" << passed << " of " << total << ") " << (failed ? "failed"
+ : "passed") << endl;
+ }
+
+ void endTestrun() {
+ if (failure) {
+ QMap<int,bool>::ConstIterator it = failed_testcases.begin();
+ for (; it != failed_testcases.end(); ++it) {
+ cout << "Testcase " << it.key() << " failed" << endl;
+ }
+ }
+ }
+};
+
+#include "dataprotocol.cpp" // we need access to static data & functions
+
+// == general functionality
+const struct {
+const char * const name;
+const char * const exp_mime_type; // 0 means "text/plain"
+const struct {
+ const char * const key;
+ const char * const value;
+} exp_attrs[10]; // ended with a key==0, value==0 pair
+const char * const exp_content;
+const char * const url;
+} testcases[] = {
+ // -----------------------------------------------------------------
+ { "escape resolving", 0, {}, "blah blah", "data:,blah%20blah" },
+ // --------------------
+ { "mime type, escape resolving", "text/html", {},
+ "<div style=\"border:thin orange solid;padding:1ex;background-color:"
+ "yellow;color:black\">Rich <b>text</b></div>",
+ "data:text/html,<div%20style=\"border:thin%20orange%20solid;"
+ "padding:1ex;background-color:yellow;color:black\">Rich%20<b>text</b>"
+ "</div>" },
+ // -------------------- whitespace test I
+ { "whitespace test I", "text/css", {
+ { "charset", "iso-8859-15" }, { 0,0 } },
+ " body { color: yellow; background:darkblue; font-weight:bold }",
+ "data:text/css ; charset = iso-8859-15 , body { color: yellow; "
+ "background:darkblue; font-weight:bold }" },
+ // -------------------- out of spec argument order, base64 decoding,
+ // whitespace test II
+ { "out of spec argument order, base64 decoding, whitespace test II",
+ 0, {
+ { "charset", "iso-8859-1" }, { 0,0 } },
+ "paaaaaaaasd!!\n",
+ "data: ; base64 ; charset = \"iso-8859-1\" ,cGFhYWFhYWFhc2QhIQo=" },
+ // -------------------- arbitrary keys, reserved names as keys,
+ // whitespace test III
+ { "arbitrary keys, reserved names as keys, whitespace test III", 0, {
+ { "base64", "nospace" }, { "key", "onespaceinner" },
+ { "key2", "onespaceouter" }, { "charset", "utf8" },
+ { "<<empty>>", "" }, { 0,0 } },
+ "Die, Allied Schweinehund (C) 1990 Wolfenstein 3D",
+ "data: ;base64=nospace;key = onespaceinner; key2=onespaceouter ;"
+ " charset = utf8 ; <<empty>>= ,Die, Allied Schweinehund "
+ "(C) 1990 Wolfenstein 3D" },
+ // -------------------- string literal with escaped chars, testing
+ // delimiters within string
+ { "string literal with escaped chars, testing delimiters within "
+ "string", 0, {
+ { "fortune-cookie", "Master Leep say: \"Rabbit is humble, "
+ "Rabbit is gentle; follow the Rabbit\"" }, { 0,0 } },
+ "(C) 1997 Shadow Warrior ;-)",
+ "data:;fortune-cookie=\"Master Leep say: \\\"Rabbit is humble, "
+ "Rabbit is gentle; follow the Rabbit\\\"\",(C) 1997 Shadow Warrior "
+ ";-)" },
+};
+
+#if 0
+// == charset tests
+ // -------------------- string
+const QChar
+const QChar * const charset_urls[] = {
+#endif
+
+int main(int /*argc*/,char* /*argv*/[]) {
+ DataProtocol kio_data;
+
+ kio_data.initTestrun();
+ for (uint i = 0; i < sizeof testcases/sizeof testcases[0]; i++) {
+ kio_data.beginTestcase(testcases[i].name);
+ kio_data.setExpectedMimeType(testcases[i].exp_mime_type != 0
+ ? testcases[i].exp_mime_type : "text/plain");
+
+ bool has_charset = false;
+ MetaData exp_attrs;
+ if (testcases[i].exp_attrs != 0) {
+ for (uint j = 0; testcases[i].exp_attrs[j].key != 0; j++) {
+ exp_attrs[testcases[i].exp_attrs[j].key] = testcases[i].exp_attrs[j].value;
+ if (strcmp(testcases[i].exp_attrs[j].key,"charset") == 0)
+ has_charset = true;
+ }/*next j*/
+ }
+ if (!has_charset) exp_attrs["charset"] = "us-ascii";
+ kio_data.setExpectedAttributes(exp_attrs);
+
+ QByteArray exp_content;
+ uint exp_content_len = strlen(testcases[i].exp_content);
+ exp_content.setRawData(testcases[i].exp_content,exp_content_len);
+ kio_data.setExpectedContent(exp_content);
+
+ kio_data.get(testcases[i].url);
+
+ kio_data.endTestcase();
+ exp_content.resetRawData(testcases[i].exp_content,exp_content_len);
+ }/*next i*/
+ kio_data.endTestrun();
+
+ return kio_data.hasFailedTestcases() ? 1 : 0;
+}
+
diff --git a/kio/tests/dummymeta.cpp b/kio/tests/dummymeta.cpp
new file mode 100644
index 000000000..be8bca2ad
--- /dev/null
+++ b/kio/tests/dummymeta.cpp
@@ -0,0 +1,20 @@
+#include <kgenericfactory.h>
+
+#include "dummymeta.h"
+
+K_EXPORT_COMPONENT_FACTORY( dummymeta, KGenericFactory<DummyMeta> )
+
+DummyMeta::DummyMeta( QObject *parent, const char *name,
+ const QStringList &preferredItems )
+ : KFilePlugin( parent, name, preferredItems )
+{
+ qDebug("---- DummyMeta::DummyMeta: got %i preferred items.", preferredItems.count());
+}
+
+bool DummyMeta::readInfo( KFileMetaInfo::Internal & info )
+{
+ qDebug("#### DummyMeta:: readInfo: %s", info.path().latin1() );
+ return 0L;
+}
+
+#include "dummymeta.moc"
diff --git a/kio/tests/dummymeta.desktop b/kio/tests/dummymeta.desktop
new file mode 100644
index 000000000..5f7373dc9
--- /dev/null
+++ b/kio/tests/dummymeta.desktop
@@ -0,0 +1,54 @@
+[Desktop Entry]
+Type=Service
+Name=Dummy Meta
+Name[af]=Fop Meta
+Name[az]=İşə Yaramayan Meta
+Name[be]=Парожнія звесткі
+Name[bn]=ডামি মেটা
+Name[cs]=Prázdné meta
+Name[csb]=Testowé pòdôwczi
+Name[cy]=Meta Dymi
+Name[da]=Dummy-meta
+Name[el]=Εικονικό Meta
+Name[eo]=Stulta Meto
+Name[et]=Dummy meta
+Name[fa]=فراساختگی
+Name[fi]=Tyhjä meta
+Name[fr]=Données factices
+Name[ga]=Meitea Caoch
+Name[hi]=डमी मेटा
+Name[hr]=Ogledni meta podatak
+Name[hu]=Üres (dummy) metaadat
+Name[it]=Informazioni aggiuntive posticce
+Name[ko]=가짜 메타
+Name[lb]=Dummy-Meta
+Name[lt]=Netikras Meta
+Name[ms]=Meta Olok-olok
+Name[mt]=Meta fittizju
+Name[ne]=डमी मेटा
+Name[nso]=Meta wa Dummy
+Name[pa]=ਫ਼ਰਜੀ ਮੈਟਾ
+Name[pl]=Dane testowe
+Name[ro]=Test Meta
+Name[rw]=Ikiragi Kidasanzwe
+Name[sk]=Prázdne meta
+Name[sl]=Slepi Meta
+Name[sr]=Лажни мета
+Name[sr@Latn]=Lažni meta
+Name[sv]=Testmeta
+Name[ta]=வெற்று மீட்டா
+Name[te]=డమ్మి మెటా
+Name[tg]=Meta-и Ғайрикорӣ
+Name[tr]=Kukla Meta
+Name[uk]=Макет метаданих
+Name[uz]=Maʼnosiz meta
+Name[uz@cyrillic]=Маъносиз мета
+Name[ven]=Meta isa tshili
+Name[vi]=Siêu giả
+Name[zh_CN]=哑元
+Name[zh_HK]=空的資料定義
+Name[zh_TW]=空的資料定義
+ServiceTypes=KFilePlugin
+X-KDE-Library=dummymeta
+MimeType=text/plain
+PreferredItems=Author,Title,Date
diff --git a/kio/tests/dummymeta.h b/kio/tests/dummymeta.h
new file mode 100644
index 000000000..5eb51402c
--- /dev/null
+++ b/kio/tests/dummymeta.h
@@ -0,0 +1,20 @@
+#ifndef DUMMYMETA_H
+#define DUMMYMETA_H
+
+#include <kfilemetainfo.h>
+
+class KFileMetaInfo;
+
+class DummyMeta : public KFilePlugin
+{
+ Q_OBJECT
+
+public:
+ DummyMeta( QObject *parent, const char *name, const QStringList &args );
+ ~DummyMeta() {}
+
+ virtual bool readInfo( KFileMetaInfo::Internal& info );
+
+};
+
+#endif
diff --git a/kio/tests/getalltest.cpp b/kio/tests/getalltest.cpp
new file mode 100644
index 000000000..eab0931fe
--- /dev/null
+++ b/kio/tests/getalltest.cpp
@@ -0,0 +1,44 @@
+#include <kservice.h>
+#include <kmimetype.h>
+#include <kservicetype.h>
+
+#include <kapplication.h>
+#include <kdebug.h>
+
+int main(int argc, char *argv[])
+{
+ KApplication k(argc,argv,"getalltest",false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
+
+//for (int i = 0 ; i < 2 ; ++i ) { // test twice to see if they got deleted
+ kdDebug() << "All services" << endl;
+ KService::List services = KService::allServices();
+ kdDebug() << "got " << services.count() << " services" << endl;
+ QValueListIterator<KService::Ptr> s = services.begin();
+ for ( ; s != services.end() ; ++s )
+ {
+ kdDebug() << (*s)->name() << " " << (*s)->desktopEntryPath() << endl;
+ }
+//}
+
+ kdDebug() << "All mimeTypes" << endl;
+ KMimeType::List mimeTypes = KMimeType::allMimeTypes();
+ kdDebug() << "got " << mimeTypes.count() << " mimeTypes" << endl;
+ QValueListIterator<KMimeType::Ptr> m = mimeTypes.begin();
+ for ( ; m != mimeTypes.end() ; ++m )
+ {
+ kdDebug() << (*m)->name() << endl;
+ }
+
+ kdDebug() << "All service types" << endl;
+ KServiceType::List list = KServiceType::allServiceTypes();
+ kdDebug() << "got " << list.count() << " service types" << endl;
+ QValueListIterator<KServiceType::Ptr> st = list.begin();
+ for ( ; st != list.end() ; ++st )
+ {
+ kdDebug() << (*st)->name() << endl;
+ }
+
+ kdDebug() << "done" << endl;
+
+ return 0;
+}
diff --git a/kio/tests/jobtest.cpp b/kio/tests/jobtest.cpp
new file mode 100644
index 000000000..0f6b426a5
--- /dev/null
+++ b/kio/tests/jobtest.cpp
@@ -0,0 +1,613 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004-2006 David Faure <faure@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "jobtest.h"
+
+#include <config.h>
+
+#include <kurl.h>
+#include <kapplication.h>
+#include <klargefile.h>
+#include <kio/netaccess.h>
+#include <kdebug.h>
+#include <kcmdlineargs.h>
+#include <kprotocolinfo.h>
+
+#include <qfileinfo.h>
+#include <qeventloop.h>
+#include <qdir.h>
+#include <qfileinfo.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <time.h>
+#include <utime.h>
+
+// The code comes partly from kdebase/kioslave/trash/testtrash.cpp
+
+static bool check(const QString& txt, QString a, QString b)
+{
+ if (a.isEmpty())
+ a = QString::null;
+ if (b.isEmpty())
+ b = QString::null;
+ if (a == b) {
+ kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl;
+ }
+ else {
+ kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl;
+ exit(1);
+ }
+ return true;
+}
+
+int main(int argc, char *argv[])
+{
+ KApplication::disableAutoDcopRegistration();
+ KCmdLineArgs::init(argc,argv,"jobtest", 0, 0, 0, 0);
+ KApplication app;
+
+ JobTest test;
+ test.setup();
+ test.runAll();
+ test.cleanup();
+ kdDebug() << "All tests OK." << endl;
+ return 0; // success. The exit(1) in check() is what happens in case of failure.
+}
+
+QString JobTest::homeTmpDir() const
+{
+ return QDir::homeDirPath() + "/.kde/jobtest/";
+}
+
+QString JobTest::otherTmpDir() const
+{
+ // This one needs to be on another partition
+ return "/tmp/jobtest/";
+}
+
+KURL JobTest::systemTmpDir() const
+{
+ return "system:/home/.kde/jobtest-system/";
+}
+
+QString JobTest::realSystemPath() const
+{
+ return QDir::homeDirPath() + "/.kde/jobtest-system/";
+}
+
+void JobTest::setup()
+{
+ // Start with a clean base dir
+ cleanup();
+ QDir dir; // TT: why not a static method?
+ bool ok = dir.mkdir( homeTmpDir() );
+ if ( !ok )
+ kdFatal() << "Couldn't create " << homeTmpDir() << endl;
+ ok = dir.mkdir( otherTmpDir() );
+ if ( !ok )
+ kdFatal() << "Couldn't create " << otherTmpDir() << endl;
+ ok = dir.mkdir( realSystemPath() );
+ if ( !ok )
+ kdFatal() << "Couldn't create " << realSystemPath() << endl;
+}
+
+void JobTest::runAll()
+{
+ get();
+ copyFileToSamePartition();
+ copyDirectoryToSamePartition();
+ copyDirectoryToExistingDirectory();
+ copyFileToOtherPartition();
+ copyDirectoryToOtherPartition();
+ listRecursive();
+ moveFileToSamePartition();
+ moveDirectoryToSamePartition();
+ moveFileToOtherPartition();
+ moveSymlinkToOtherPartition();
+ moveDirectoryToOtherPartition();
+ moveFileNoPermissions();
+ moveDirectoryNoPermissions();
+
+ copyFileToSystem();
+}
+
+void JobTest::cleanup()
+{
+ KIO::NetAccess::del( homeTmpDir(), 0 );
+ KIO::NetAccess::del( otherTmpDir(), 0 );
+ KIO::NetAccess::del( systemTmpDir(), 0 );
+}
+
+static void setTimeStamp( const QString& path )
+{
+#ifdef Q_OS_UNIX
+ // Put timestamp in the past so that we can check that the
+ // copy actually preserves it.
+ struct timeval tp;
+ gettimeofday( &tp, 0 );
+ struct utimbuf utbuf;
+ utbuf.actime = tp.tv_sec - 30; // 30 seconds ago
+ utbuf.modtime = tp.tv_sec - 60; // 60 second ago
+ utime( QFile::encodeName( path ), &utbuf );
+ qDebug( "Time changed for %s", path.latin1() );
+#endif
+}
+
+static void createTestFile( const QString& path )
+{
+ QFile f( path );
+ if ( !f.open( IO_WriteOnly ) )
+ kdFatal() << "Can't create " << path << endl;
+ f.writeBlock( "Hello world", 11 );
+ f.close();
+ setTimeStamp( path );
+}
+
+static void createTestSymlink( const QString& path )
+{
+ // Create symlink if it doesn't exist yet
+ KDE_struct_stat buf;
+ if ( KDE_lstat( QFile::encodeName( path ), &buf ) != 0 ) {
+ bool ok = symlink( "/IDontExist", QFile::encodeName( path ) ) == 0; // broken symlink
+ if ( !ok )
+ kdFatal() << "couldn't create symlink: " << strerror( errno ) << endl;
+ }
+}
+
+static void createTestDirectory( const QString& path )
+{
+ QDir dir;
+ bool ok = dir.mkdir( path );
+ if ( !ok && !dir.exists() )
+ kdFatal() << "couldn't create " << path << endl;
+ createTestFile( path + "/testfile" );
+ createTestSymlink( path + "/testlink" );
+ setTimeStamp( path );
+}
+
+void JobTest::get()
+{
+ kdDebug() << k_funcinfo << endl;
+ const QString filePath = homeTmpDir() + "fileFromHome";
+ createTestFile( filePath );
+ KURL u; u.setPath( filePath );
+ m_result = -1;
+ KIO::StoredTransferJob* job = KIO::storedGet( u );
+ connect( job, SIGNAL( result( KIO::Job* ) ),
+ this, SLOT( slotGetResult( KIO::Job* ) ) );
+ kapp->eventLoop()->enterLoop();
+ assert( m_result == 0 ); // no error
+ assert( m_data.size() == 11 );
+ assert( QCString( m_data ) == "Hello world" );
+}
+
+void JobTest::slotGetResult( KIO::Job* job )
+{
+ m_result = job->error();
+ m_data = static_cast<KIO::StoredTransferJob *>(job)->data();
+ kapp->eventLoop()->exitLoop();
+}
+
+////
+
+void JobTest::copyLocalFile( const QString& src, const QString& dest )
+{
+ KURL u;
+ u.setPath( src );
+ KURL d;
+ d.setPath( dest );
+
+ // copy the file with file_copy
+ bool ok = KIO::NetAccess::file_copy( u, d );
+ assert( ok );
+ assert( QFile::exists( dest ) );
+ assert( QFile::exists( src ) ); // still there
+
+ {
+ // check that the timestamp is the same (#24443)
+ // Note: this only works because of copy() in kio_file.
+ // The datapump solution ignores mtime, the app has to call FileCopyJob::setModificationTime()
+ QFileInfo srcInfo( src );
+ QFileInfo destInfo( dest );
+ assert( srcInfo.lastModified() == destInfo.lastModified() );
+ }
+
+ // cleanup and retry with KIO::copy()
+ QFile::remove( dest );
+ ok = KIO::NetAccess::dircopy( u, d, 0 );
+ assert( ok );
+ assert( QFile::exists( dest ) );
+ assert( QFile::exists( src ) ); // still there
+ {
+ // check that the timestamp is the same (#24443)
+ QFileInfo srcInfo( src );
+ QFileInfo destInfo( dest );
+ assert( srcInfo.lastModified() == destInfo.lastModified() );
+ }
+}
+
+void JobTest::copyLocalDirectory( const QString& src, const QString& _dest, int flags )
+{
+ assert( QFileInfo( src ).isDir() );
+ assert( QFileInfo( src + "/testfile" ).isFile() );
+ KURL u;
+ u.setPath( src );
+ QString dest( _dest );
+ KURL d;
+ d.setPath( dest );
+ if ( flags & AlreadyExists )
+ assert( QFile::exists( dest ) );
+ else
+ assert( !QFile::exists( dest ) );
+
+ bool ok = KIO::NetAccess::dircopy( u, d, 0 );
+ assert( ok );
+
+ if ( flags & AlreadyExists ) {
+ dest += "/" + u.fileName();
+ //kdDebug() << "Expecting dest=" << dest << endl;
+ }
+
+ assert( QFile::exists( dest ) );
+ assert( QFileInfo( dest ).isDir() );
+ assert( QFileInfo( dest + "/testfile" ).isFile() );
+ assert( QFile::exists( src ) ); // still there
+ {
+ // check that the timestamp is the same (#24443)
+ QFileInfo srcInfo( src );
+ QFileInfo destInfo( dest );
+ assert( srcInfo.lastModified() == destInfo.lastModified() );
+ }
+}
+
+void JobTest::copyFileToSamePartition()
+{
+ kdDebug() << k_funcinfo << endl;
+ const QString filePath = homeTmpDir() + "fileFromHome";
+ const QString dest = homeTmpDir() + "fileFromHome_copied";
+ createTestFile( filePath );
+ copyLocalFile( filePath, dest );
+}
+
+void JobTest::copyDirectoryToSamePartition()
+{
+ kdDebug() << k_funcinfo << endl;
+ const QString src = homeTmpDir() + "dirFromHome";
+ const QString dest = homeTmpDir() + "dirFromHome_copied";
+ createTestDirectory( src );
+ copyLocalDirectory( src, dest );
+}
+
+void JobTest::copyDirectoryToExistingDirectory()
+{
+ kdDebug() << k_funcinfo << endl;
+ // just the same as copyDirectoryToSamePartition, but it means that
+ // this time dest exists.
+ const QString src = homeTmpDir() + "dirFromHome";
+ const QString dest = homeTmpDir() + "dirFromHome_copied";
+ createTestDirectory( src );
+ copyLocalDirectory( src, dest, AlreadyExists );
+}
+
+void JobTest::copyFileToOtherPartition()
+{
+ kdDebug() << k_funcinfo << endl;
+ const QString filePath = homeTmpDir() + "fileFromHome";
+ const QString dest = otherTmpDir() + "fileFromHome_copied";
+ createTestFile( filePath );
+ copyLocalFile( filePath, dest );
+}
+
+void JobTest::copyDirectoryToOtherPartition()
+{
+ kdDebug() << k_funcinfo << endl;
+ const QString src = homeTmpDir() + "dirFromHome";
+ const QString dest = otherTmpDir() + "dirFromHome_copied";
+ // src is already created by copyDirectoryToSamePartition()
+ // so this is just in case someone calls this method only
+ if ( !QFile::exists( src ) )
+ createTestDirectory( src );
+ copyLocalDirectory( src, dest );
+}
+
+void JobTest::moveLocalFile( const QString& src, const QString& dest )
+{
+ assert( QFile::exists( src ) );
+ KURL u;
+ u.setPath( src );
+ KURL d;
+ d.setPath( dest );
+
+ // move the file with file_move
+ bool ok = KIO::NetAccess::file_move( u, d );
+ assert( ok );
+ assert( QFile::exists( dest ) );
+ assert( !QFile::exists( src ) ); // not there anymore
+
+ // move it back with KIO::move()
+ ok = KIO::NetAccess::move( d, u, 0 );
+ assert( ok );
+ assert( !QFile::exists( dest ) );
+ assert( QFile::exists( src ) ); // it's back
+}
+
+static void moveLocalSymlink( const QString& src, const QString& dest )
+{
+ KDE_struct_stat buf;
+ assert ( KDE_lstat( QFile::encodeName( src ), &buf ) == 0 );
+ KURL u;
+ u.setPath( src );
+ KURL d;
+ d.setPath( dest );
+
+ // move the symlink with move, NOT with file_move
+ bool ok = KIO::NetAccess::move( u, d );
+ if ( !ok )
+ kdWarning() << KIO::NetAccess::lastError() << endl;
+ assert( ok );
+ assert ( KDE_lstat( QFile::encodeName( dest ), &buf ) == 0 );
+ assert( !QFile::exists( src ) ); // not there anymore
+
+ // move it back with KIO::move()
+ ok = KIO::NetAccess::move( d, u, 0 );
+ assert( ok );
+ assert ( KDE_lstat( QFile::encodeName( dest ), &buf ) != 0 ); // doesn't exist anymore
+ assert ( KDE_lstat( QFile::encodeName( src ), &buf ) == 0 ); // it's back
+}
+
+void JobTest::moveLocalDirectory( const QString& src, const QString& dest )
+{
+ assert( QFile::exists( src ) );
+ assert( QFileInfo( src ).isDir() );
+ assert( QFileInfo( src + "/testfile" ).isFile() );
+ assert( QFileInfo( src + "/testlink" ).isSymLink() );
+ KURL u;
+ u.setPath( src );
+ KURL d;
+ d.setPath( dest );
+
+ bool ok = KIO::NetAccess::move( u, d, 0 );
+ assert( ok );
+ assert( QFile::exists( dest ) );
+ assert( QFileInfo( dest ).isDir() );
+ assert( QFileInfo( dest + "/testfile" ).isFile() );
+ assert( !QFile::exists( src ) ); // not there anymore
+
+ assert( QFileInfo( dest + "/testlink" ).isSymLink() );
+}
+
+void JobTest::moveFileToSamePartition()
+{
+ kdDebug() << k_funcinfo << endl;
+ const QString filePath = homeTmpDir() + "fileFromHome";
+ const QString dest = homeTmpDir() + "fileFromHome_moved";
+ createTestFile( filePath );
+ moveLocalFile( filePath, dest );
+}
+
+void JobTest::moveDirectoryToSamePartition()
+{
+ kdDebug() << k_funcinfo << endl;
+ const QString src = homeTmpDir() + "dirFromHome";
+ const QString dest = homeTmpDir() + "dirFromHome_moved";
+ createTestDirectory( src );
+ moveLocalDirectory( src, dest );
+}
+
+void JobTest::moveFileToOtherPartition()
+{
+ kdDebug() << k_funcinfo << endl;
+ const QString filePath = homeTmpDir() + "fileFromHome";
+ const QString dest = otherTmpDir() + "fileFromHome_moved";
+ createTestFile( filePath );
+ moveLocalFile( filePath, dest );
+}
+
+void JobTest::moveSymlinkToOtherPartition()
+{
+ kdDebug() << k_funcinfo << endl;
+ const QString filePath = homeTmpDir() + "testlink";
+ const QString dest = otherTmpDir() + "testlink_moved";
+ createTestSymlink( filePath );
+ moveLocalSymlink( filePath, dest );
+}
+
+void JobTest::moveDirectoryToOtherPartition()
+{
+ kdDebug() << k_funcinfo << endl;
+ const QString src = homeTmpDir() + "dirFromHome";
+ const QString dest = otherTmpDir() + "dirFromHome_moved";
+ createTestDirectory( src );
+ moveLocalDirectory( src, dest );
+}
+
+void JobTest::moveFileNoPermissions()
+{
+ kdDebug() << k_funcinfo << endl;
+ const QString src = "/etc/passwd";
+ const QString dest = homeTmpDir() + "passwd";
+ assert( QFile::exists( src ) );
+ assert( QFileInfo( src ).isFile() );
+ KURL u;
+ u.setPath( src );
+ KURL d;
+ d.setPath( dest );
+
+ KIO::CopyJob* job = KIO::move( u, d, 0 );
+ job->setInteractive( false ); // no skip dialog, thanks
+ QMap<QString, QString> metaData;
+ bool ok = KIO::NetAccess::synchronousRun( job, 0, 0, 0, &metaData );
+ assert( !ok );
+ assert( KIO::NetAccess::lastError() == KIO::ERR_ACCESS_DENIED );
+ // OK this is fishy. Just like mv(1), KIO's behavior depends on whether
+ // a direct rename(2) was used, or a full copy+del. In the first case
+ // there is no destination file created, but in the second case the
+ // destination file remains.
+ // In fact we assume /home is a separate partition, in this test, so:
+ assert( QFile::exists( dest ) );
+ assert( QFile::exists( src ) );
+}
+
+void JobTest::moveDirectoryNoPermissions()
+{
+ kdDebug() << k_funcinfo << endl;
+ const QString src = "/etc/init.d";
+ const QString dest = homeTmpDir() + "init.d";
+ assert( QFile::exists( src ) );
+ assert( QFileInfo( src ).isDir() );
+ KURL u;
+ u.setPath( src );
+ KURL d;
+ d.setPath( dest );
+
+ KIO::CopyJob* job = KIO::move( u, d, 0 );
+ job->setInteractive( false ); // no skip dialog, thanks
+ QMap<QString, QString> metaData;
+ bool ok = KIO::NetAccess::synchronousRun( job, 0, 0, 0, &metaData );
+ assert( !ok );
+ assert( KIO::NetAccess::lastError() == KIO::ERR_ACCESS_DENIED );
+ assert( QFile::exists( dest ) ); // see moveFileNoPermissions
+ assert( QFile::exists( src ) );
+}
+
+void JobTest::listRecursive()
+{
+ const QString src = homeTmpDir();
+ KURL u;
+ u.setPath( src );
+ KIO::ListJob* job = KIO::listRecursive( u );
+ connect( job, SIGNAL( entries( KIO::Job*, const KIO::UDSEntryList& ) ),
+ SLOT( slotEntries( KIO::Job*, const KIO::UDSEntryList& ) ) );
+ bool ok = KIO::NetAccess::synchronousRun( job, 0 );
+ assert( ok );
+ m_names.sort();
+ check( "listRecursive", m_names.join( "," ), ".,..,"
+ "dirFromHome,dirFromHome/testfile,dirFromHome/testlink,dirFromHome_copied,"
+ "dirFromHome_copied/dirFromHome,dirFromHome_copied/dirFromHome/testfile,dirFromHome_copied/dirFromHome/testlink,"
+ "dirFromHome_copied/testfile,dirFromHome_copied/testlink,"
+ "fileFromHome,fileFromHome_copied" );
+}
+
+void JobTest::slotEntries( KIO::Job*, const KIO::UDSEntryList& lst )
+{
+ for( KIO::UDSEntryList::ConstIterator it = lst.begin(); it != lst.end(); ++it ) {
+ KIO::UDSEntry::ConstIterator it2 = (*it).begin();
+ QString displayName;
+ KURL url;
+ for( ; it2 != (*it).end(); it2++ ) {
+ switch ((*it2).m_uds) {
+ case KIO::UDS_NAME:
+ displayName = (*it2).m_str;
+ break;
+ case KIO::UDS_URL:
+ url = (*it2).m_str;
+ break;
+ }
+ }
+ m_names.append( displayName );
+ }
+}
+
+void JobTest::copyFileToSystem()
+{
+ if ( !KProtocolInfo::isKnownProtocol( QString::fromLatin1( "system" ) ) ) {
+ kdDebug() << k_funcinfo << "no kio_system, skipping test" << endl;
+ return;
+ }
+
+ // First test with support for UDS_LOCAL_PATH
+ copyFileToSystem( true );
+
+ QString dest = realSystemPath() + "fileFromHome_copied";
+ QFile::remove( dest );
+
+ // Then disable support for UDS_LOCAL_PATH, i.e. test what would
+ // happen for ftp, smb, http etc.
+ copyFileToSystem( false );
+}
+
+void JobTest::copyFileToSystem( bool resolve_local_urls )
+{
+ kdDebug() << k_funcinfo << resolve_local_urls << endl;
+ extern KIO_EXPORT bool kio_resolve_local_urls;
+ kio_resolve_local_urls = resolve_local_urls;
+
+ const QString src = homeTmpDir() + "fileFromHome";
+ createTestFile( src );
+ KURL u;
+ u.setPath( src );
+ KURL d = systemTmpDir();
+ d.addPath( "fileFromHome_copied" );
+
+ kdDebug() << "copying " << u << " to " << d << endl;
+
+ // copy the file with file_copy
+ KIO::FileCopyJob* job = KIO::file_copy( u, d );
+ connect( job, SIGNAL(mimetype(KIO::Job*,const QString&)),
+ this, SLOT(slotMimetype(KIO::Job*,const QString&)) );
+ bool ok = KIO::NetAccess::synchronousRun( job, 0 );
+ assert( ok );
+
+ QString dest = realSystemPath() + "fileFromHome_copied";
+
+ assert( QFile::exists( dest ) );
+ assert( QFile::exists( src ) ); // still there
+
+ {
+ // do NOT check that the timestamp is the same.
+ // It can't work with file_copy when it uses the datapump,
+ // unless we use setModificationTime in the app code.
+ }
+
+ // Check mimetype
+ kdDebug() << m_mimetype << endl;
+ // There's no mimemagic determination in kio_file in kde3. Fixing this for kde4...
+ assert( m_mimetype == "application/octet-stream" );
+ //assert( m_mimetype == "text/plain" );
+
+ // cleanup and retry with KIO::copy()
+ QFile::remove( dest );
+ ok = KIO::NetAccess::dircopy( u, d, 0 );
+ assert( ok );
+ assert( QFile::exists( dest ) );
+ assert( QFile::exists( src ) ); // still there
+ {
+ // check that the timestamp is the same (#79937)
+ QFileInfo srcInfo( src );
+ QFileInfo destInfo( dest );
+ assert( srcInfo.lastModified() == destInfo.lastModified() );
+ }
+
+ // restore normal behavior
+ kio_resolve_local_urls = true;
+}
+
+void JobTest::slotMimetype(KIO::Job* job, const QString& type)
+{
+ assert( job );
+ m_mimetype = type;
+}
+
+#include "jobtest.moc"
diff --git a/kio/tests/jobtest.h b/kio/tests/jobtest.h
new file mode 100644
index 000000000..9d3d52894
--- /dev/null
+++ b/kio/tests/jobtest.h
@@ -0,0 +1,79 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 David Faure <faure@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef JOBTEST_H
+#define JOBTEST_H
+
+#include <qstring.h>
+#include <qobject.h>
+#include <kio/job.h>
+
+class JobTest : public QObject
+{
+ Q_OBJECT
+
+public:
+ JobTest() {}
+ void setup();
+ void runAll();
+ void cleanup();
+
+ // Local tests (kio_file only)
+ void get();
+ void copyFileToSamePartition();
+ void copyDirectoryToSamePartition();
+ void copyDirectoryToExistingDirectory();
+ void copyFileToOtherPartition();
+ void copyDirectoryToOtherPartition();
+ void listRecursive();
+ void moveFileToSamePartition();
+ void moveDirectoryToSamePartition();
+ void moveFileToOtherPartition();
+ void moveSymlinkToOtherPartition();
+ void moveDirectoryToOtherPartition();
+ void moveFileNoPermissions();
+ void moveDirectoryNoPermissions();
+
+ // Remote tests
+ void copyFileToSystem();
+
+private slots:
+ void slotEntries( KIO::Job*, const KIO::UDSEntryList& lst );
+ void slotGetResult( KIO::Job* );
+ void slotMimetype(KIO::Job*,const QString&);
+
+private:
+ QString homeTmpDir() const;
+ QString otherTmpDir() const;
+ QString realSystemPath() const;
+ KURL systemTmpDir() const;
+ enum { AlreadyExists = 1 };
+ void copyLocalFile( const QString& src, const QString& dest );
+ void copyLocalDirectory( const QString& src, const QString& dest, int flags = 0 );
+ void moveLocalFile( const QString& src, const QString& dest );
+ void moveLocalDirectory( const QString& src, const QString& dest );
+ void copyFileToSystem( bool resolve_local_urls );
+
+ int m_result;
+ QByteArray m_data;
+ QStringList m_names;
+ QString m_mimetype;
+};
+
+#endif
diff --git a/kio/tests/kacltest.cpp b/kio/tests/kacltest.cpp
new file mode 100644
index 000000000..7f75dfde6
--- /dev/null
+++ b/kio/tests/kacltest.cpp
@@ -0,0 +1,309 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Till Adam <adam@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kacltest.h"
+
+#include <config.h>
+
+#include <kacl.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kcmdlineargs.h>
+
+#include <qfileinfo.h>
+#include <qeventloop.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <qdir.h>
+
+// The code comes partly from kdebase/kioslave/trash/testtrash.cpp
+
+static bool check(const QString& txt, QString a, QString b)
+{
+ if (a.isEmpty())
+ a = QString::null;
+ if (b.isEmpty())
+ b = QString::null;
+ if (a == b) {
+ kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl;
+ }
+ else {
+ kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl;
+ exit(1);
+ }
+ return true;
+}
+
+template<typename T>
+static bool check(const QString& txt, T a, T b)
+{
+ if (a == b) {
+ kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl;
+ }
+ else {
+ kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl;
+ exit(1);
+ }
+ return true;
+}
+
+int main(int argc, char *argv[])
+{
+ KApplication::disableAutoDcopRegistration();
+ KCmdLineArgs::init(argc,argv,"kacltest", 0, 0, 0, 0);
+ KApplication app;
+
+ KACLTest test;
+ test.setup();
+ test.runAll();
+ test.cleanup();
+ kdDebug() << "All tests OK." << endl;
+ return 0; // success. The exit(1) in check() is what happens in case of failure.
+}
+
+#ifdef Q_OS_FREEBSD
+static const QString s_group1 = QString::fromLatin1("staff");
+static const QString s_group2 = QString::fromLatin1("guest");
+#else
+static const QString s_group1 = QString::fromLatin1("audio");
+static const QString s_group2 = QString::fromLatin1("users");
+#endif
+
+static const QString s_testACL = QString::fromLatin1( "user::rw-\nuser:bin:rwx\ngroup::rw-\nmask::rwx\nother::r--\n" );
+static const QString s_testACL2 = QString::fromLatin1( "user::rwx\nuser:bin:rwx\ngroup::rw-\n") +
+ QString::fromLatin1( "group:" ) + s_group1 + QString::fromLatin1( ":--x\n" ) +
+ QString::fromLatin1( "group:" ) + s_group2 + QString::fromLatin1( ":r--\n" ) +
+ QString::fromLatin1( "mask::r-x\nother::r--\n" );
+static const QString s_testACLEffective = QString::fromLatin1( "user::rwx\nuser:bin:rwx #effective:r-x\ngroup::rw- #effective:r--\n" ) +
+ QString::fromLatin1( "group:" ) + s_group1 + QString::fromLatin1( ":--x\n" ) +
+ QString::fromLatin1( "group:" ) + s_group2 + QString::fromLatin1( ":r--\n" ) +
+ QString::fromLatin1( "mask::r-x\nother::r--\n" );
+
+KACLTest::KACLTest()
+:m_acl( s_testACL )
+{
+}
+
+void KACLTest::setup()
+{
+}
+
+void KACLTest::runAll()
+{
+ testAsString();
+ testGetOwnerPermissions();
+ testGetOwningGroupPermissions();
+ testGetOthersPermissions();
+
+ testGetMaskPermissions();
+ testGetAllUserPermissions();
+
+ testIsExtended();
+
+ // from here on we operate with the second test string
+ testSetACL();
+ testGetAllGroupsPermissions();
+
+ testOperators();
+ testSettingBasic();
+ testSettingExtended();
+ testSettingErrorHandling();
+
+ testNewMask();
+}
+
+void KACLTest::cleanup()
+{
+}
+
+void KACLTest::testAsString()
+{
+ check( "asString: ", m_acl.asString(), s_testACL );
+}
+
+void KACLTest::testSetACL()
+{
+ m_acl.setACL( s_testACL2 );
+ check( "setACL: ", m_acl.asString().simplifyWhiteSpace().remove(" "), s_testACLEffective.simplifyWhiteSpace().remove(" ") );
+}
+
+void KACLTest::testGetOwnerPermissions()
+{
+ check( "Owner permissions: ", QString::number( m_acl.ownerPermissions() ), "6" );
+}
+
+void KACLTest::testGetOwningGroupPermissions()
+{
+ check( "Owning group permissions: ", QString::number( m_acl.owningGroupPermissions() ), "6" );
+}
+
+void KACLTest::testGetOthersPermissions()
+{
+ check( "Others permissions: ", QString::number( m_acl.othersPermissions() ), "4" );
+}
+
+void KACLTest::testGetMaskPermissions()
+{
+ bool exists = false;
+ unsigned short mask = m_acl.maskPermissions( exists );
+ check( "Mask permissions: ", QString::number( mask ), "7" );
+ check( "Mask permissions: ", exists, true );
+}
+
+void KACLTest::testGetAllUserPermissions()
+{
+ ACLUserPermissionsList list = m_acl.allUserPermissions();
+ ACLUserPermissionsConstIterator it = list.begin();
+ QString name;
+ unsigned short permissions;
+ int count = 0;
+ while ( it != list.end() ) {
+ name = ( *it ).first;
+ permissions = ( *it ).second;
+ ++it;
+ ++count;
+ }
+ check( "All users count: ", QString::number( count ), "1" );
+ check( "All users name: ", name, "bin" );
+ check( "All users permissions: ", QString::number( permissions ), "7" );
+}
+
+void KACLTest::testGetAllGroupsPermissions()
+{
+ ACLGroupPermissionsList list = m_acl.allGroupPermissions();
+ ACLGroupPermissionsConstIterator it = list.begin();
+ QString name;
+ unsigned short permissions;
+ int count = 0;
+ while ( it != list.end() ) {
+ name = ( *it ).first;
+ permissions = ( *it ).second;
+ // setACL sorts them alphabetically ...
+ if ( count == 0 ) {
+ check( "All groups name: ", name, s_group1 );
+ check( "All groups permissions: ", QString::number( permissions ), "1" );
+ } else if ( count == 1 ) {
+ check( "All groups name: ", name, s_group2 );
+ check( "All groups permissions: ", QString::number( permissions ), "4" );
+ }
+ ++it;
+ ++count;
+ }
+ check( "All users count: ", QString::number( count ), "2" );
+}
+
+void KACLTest::testIsExtended()
+{
+ KACL dukeOfMonmoth( s_testACL );
+ check( "isExtended on an extended one: ", dukeOfMonmoth.isExtended(), true );
+ KACL earlOfUpnor( "user::r--\ngroup::r--\nother::r--\n" );
+ check( "isExtended on a not extended one: ", earlOfUpnor.isExtended(), false );
+}
+
+void KACLTest::testOperators()
+{
+ KACL dukeOfMonmoth( s_testACL );
+ KACL JamesScott( s_testACL );
+ KACL earlOfUpnor( s_testACL2 );
+ check( "operator== on different ones: ", dukeOfMonmoth == earlOfUpnor, false );
+ check( "operator== on identical ones: ", dukeOfMonmoth == JamesScott, true );
+ check( "operator!= on diffenrent ones: ", dukeOfMonmoth != earlOfUpnor, true );
+ check( "operator!=: on identical ones: ", dukeOfMonmoth != JamesScott, false );
+}
+
+void KACLTest::testSettingBasic()
+{
+ KACL CharlesII( s_testACL );
+ CharlesII.setOwnerPermissions( 7 ); // clearly
+ CharlesII.setOwningGroupPermissions( 0 );
+ CharlesII.setOthersPermissions( 0 );
+ check( "setOwnerPermissions: ", QString::number( CharlesII.ownerPermissions() ),"7" );
+ check( "setOwningGroupPermissions: ", QString::number( CharlesII.owningGroupPermissions() ),"0" );
+ check( "setOthersPermissions: ", QString::number( CharlesII.othersPermissions() ),"0" );
+}
+
+void KACLTest::testSettingExtended()
+{
+ KACL CharlesII( s_testACL );
+ CharlesII.setMaskPermissions( 7 ); // clearly
+ bool dummy = false;
+ check( "setMaskPermissions: ", QString::number( CharlesII.maskPermissions( dummy ) ),"7" );
+
+ const QString expected( "user::rw-\nuser:root:rwx\nuser:bin:r--\ngroup::rw-\nmask::rwx\nother::r--\n" );
+
+ ACLUserPermissionsList users;
+ ACLUserPermissions user = qMakePair( QString( "root" ), ( unsigned short )7 );
+ users.append( user );
+ user = qMakePair( QString( "bin" ), ( unsigned short )4 );
+ users.append( user );
+ CharlesII.setAllUserPermissions( users );
+ check( "setAllUserPermissions: ", CharlesII.asString(), expected );
+
+ CharlesII.setACL( s_testACL ); // reset
+ // it already has an entry for bin, let's change it
+ CharlesII.setNamedUserPermissions( QString("bin"), 4 );
+ CharlesII.setNamedUserPermissions( QString( "root" ), 7 );
+ check( "setNamedUserPermissions: ", CharlesII.asString(), expected );
+
+ // groups, all and named
+
+ const QString expected2 = QString::fromLatin1( "user::rw-\nuser:bin:rwx\ngroup::rw-\ngroup:" ) + s_group1 +
+ QString::fromLatin1( ":-wx\ngroup:" ) + s_group2 + QString::fromLatin1(":r--\nmask::rwx\nother::r--\n" );
+ CharlesII.setACL( s_testACL ); // reset
+ ACLGroupPermissionsList groups;
+ ACLGroupPermissions group = qMakePair( s_group1, ( unsigned short )3 );
+ groups.append( group );
+ group = qMakePair( s_group2, ( unsigned short )4 );
+ groups.append( group );
+ CharlesII.setAllGroupPermissions( groups );
+ check( "setAllGroupPermissions: ", CharlesII.asString(), expected2 );
+
+ CharlesII.setACL( s_testACL ); // reset
+ CharlesII.setNamedGroupPermissions( s_group1, 3 );
+ CharlesII.setNamedGroupPermissions( s_group2, 4 );
+ check( "setNamedGroupPermissions: ", CharlesII.asString(), expected2 );
+}
+
+void KACLTest::testSettingErrorHandling()
+{
+ KACL foo( s_testACL );
+ bool v = foo.setNamedGroupPermissions( s_group1, 7 ); // existing group
+ check( "Existing group: ", v, true );
+ v = foo.setNamedGroupPermissions( "jongel", 7 ); // non-existing group
+ check( "Non-existing group: ", v, false );
+
+ v = foo.setNamedUserPermissions( "bin", 7 ); // existing user
+ check( "Existing user: ", v, true );
+ v = foo.setNamedUserPermissions( "jongel", 7 ); // non-existing user
+ check( "Non-existing user: ", v, false );
+}
+
+void KACLTest::testNewMask()
+{
+ KACL CharlesII( "user::rw-\ngroup::rw-\nother::rw\n" );
+ bool dummy = false;
+ CharlesII.maskPermissions( dummy );
+ check( "mask exists: ", dummy, false );
+
+ CharlesII.setMaskPermissions( 6 );
+ check( "new mask set: ", QString::number( CharlesII.maskPermissions( dummy ) ), "6" );
+ check( "mask exists now: ", dummy, true );
+}
diff --git a/kio/tests/kacltest.h b/kio/tests/kacltest.h
new file mode 100644
index 000000000..906a5a84f
--- /dev/null
+++ b/kio/tests/kacltest.h
@@ -0,0 +1,53 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Till Adam <adam@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KACLTEST_H
+#define KACLTEST_H
+
+#include <qobject.h>
+#include <kacl.h>
+
+class KACLTest
+{
+public:
+ KACLTest();
+ void setup();
+ void runAll();
+ void cleanup();
+
+ void testAsString();
+ void testSetACL();
+ void testGetOwnerPermissions();
+ void testGetOwningGroupPermissions();
+ void testGetOthersPermissions();
+ void testGetMaskPermissions();
+ void testGetAllUserPermissions();
+ void testGetAllGroupsPermissions();
+ void testIsExtended();
+ void testOperators();
+ void testSettingBasic();
+ void testSettingExtended();
+ void testSettingErrorHandling();
+ void testNewMask();
+
+private:
+ KACL m_acl;
+};
+
+#endif
diff --git a/kio/tests/kdcopcheck.cpp b/kio/tests/kdcopcheck.cpp
new file mode 100644
index 000000000..09cbf1310
--- /dev/null
+++ b/kio/tests/kdcopcheck.cpp
@@ -0,0 +1,132 @@
+#include <kuserprofile.h>
+#include <ktrader.h>
+#include <kservice.h>
+#include <kmimetype.h>
+#include <assert.h>
+#include <kstandarddirs.h>
+#include <kservicegroup.h>
+#include <kimageio.h>
+#include <kprotocolinfo.h>
+#include <kprocess.h>
+#include <qtimer.h>
+
+#include "kdcopcheck.h"
+#include <dcopclient.h>
+
+#include <kapplication.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void debug(QString txt)
+{
+ fprintf(stderr, "%s\n", txt.ascii());
+}
+
+void debug(const char *txt)
+{
+ fprintf(stderr, "%s\n", txt);
+}
+void debug(const char *format, const char *txt)
+{
+ fprintf(stderr, format, txt);
+ fprintf(stderr, "\n");
+}
+
+TestService::TestService(const QString &exec)
+{
+ m_exec = exec;
+ proc << exec;
+
+ proc.start();
+
+ connect(kapp->dcopClient(), SIGNAL( applicationRegistered(const QCString&)),
+ this, SLOT(newApp(const QCString&)));
+ connect(kapp->dcopClient(), SIGNAL( applicationRemoved(const QCString&)),
+ this, SLOT(endApp(const QCString&)));
+ connect(&proc, SIGNAL(processExited(KProcess *)),
+ this, SLOT(appExit()));
+
+ QTimer::singleShot(20*1000, this, SLOT(stop()));
+ result = KService::DCOP_None;
+}
+
+void TestService::newApp(const QCString &appId)
+{
+ QString id = appId;
+ if (id == m_exec)
+ {
+ result = KService::DCOP_Unique;
+ stop();
+ }
+ else if (id.startsWith(m_exec))
+ {
+ result = KService::DCOP_Multi;
+ stop();
+ }
+ qWarning("Register %s", appId.data());
+}
+
+void TestService::endApp(const QCString &appId)
+{
+ qWarning("Unegister %s", appId.data());
+}
+
+void TestService::appExit()
+{
+ qWarning("Exit");
+}
+
+void TestService::stop()
+{
+ kapp->exit_loop();
+}
+
+int TestService::exec()
+{
+ kapp->enter_loop();
+ return result;
+}
+
+int main(int argc, char *argv[])
+{
+ putenv("IGNORE_SYCOCA_VERSION=true");
+ KApplication k(argc,argv,"whatever",false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
+
+ k.dcopClient()->setNotifications(true);
+
+ KService::List list = KService::allServices();
+
+ qWarning("I found %d services.", list.count());
+ int i = 0;
+ for(KService::List::ConstIterator it = list.begin(); it != list.end(); ++it)
+ {
+ if (((*it)->DCOPServiceType() == KService::DCOP_None) &&
+ !(*it)->desktopEntryPath().startsWith("SuSE") &&
+ (*it)->hasServiceType("Application"))
+ {
+ if ((*it)->exec().startsWith((*it)->desktopEntryName()))
+ {
+ i++;
+
+ TestService *test = new TestService((*it)->desktopEntryName());
+ int n = test->exec();
+ delete test;
+
+ QString result;
+ if (n == KService::DCOP_None)
+ result = "None";
+ else if (n == KService::DCOP_Unique)
+ result = "Unique";
+ else if (n == KService::DCOP_Multi)
+ result = "Multi";
+
+ qWarning("%s %s", (*it)->desktopEntryPath().latin1(),
+ result.latin1());
+ }
+ }
+ }
+ qWarning("%d left after filtering.", i);
+}
+
+#include "kdcopcheck.moc"
diff --git a/kio/tests/kdcopcheck.h b/kio/tests/kdcopcheck.h
new file mode 100644
index 000000000..5410bbec2
--- /dev/null
+++ b/kio/tests/kdcopcheck.h
@@ -0,0 +1,28 @@
+#ifndef _BLA_H_
+#define _BLA_H_
+
+#include <kprocess.h>
+#include <qstring.h>
+#include <qobject.h>
+
+class TestService : public QObject
+{
+ Q_OBJECT
+public:
+ TestService(const QString &exec);
+
+ int exec();
+
+public slots:
+ void newApp(const QCString &appId);
+ void endApp(const QCString &appId);
+ void appExit();
+ void stop();
+
+protected:
+ int result;
+ QString m_exec;
+ KProcess proc;
+};
+
+#endif
diff --git a/kio/tests/kdefaultprogresstest.cpp b/kio/tests/kdefaultprogresstest.cpp
new file mode 100644
index 000000000..16d00d81d
--- /dev/null
+++ b/kio/tests/kdefaultprogresstest.cpp
@@ -0,0 +1,39 @@
+#include <kapplication.h>
+#include <kio/defaultprogress.h>
+#include <kurl.h>
+#include <kdebug.h>
+
+using namespace KIO;
+
+int main(int argc, char **argv)
+{
+ KApplication app(argc, argv, "kdefaultprogresstest");
+
+ DefaultProgress* dlg = new DefaultProgress();
+ KURL src("http://this.host.doesn't.exist/this/dir/neither/andthisfileneither");
+ KURL dest("file:/tmp/dest");
+ dlg->slotCopying( 0L, src, dest );
+ dlg->slotTotalSize( 0L, 12000 );
+ dlg->slotTotalFiles( 0L, 12 );
+ dlg->slotTotalDirs( 0L, 1 );
+
+ dlg->slotSpeed( 0L, 55 );
+ dlg->slotInfoMessage( 0L, QString::fromLatin1( "Starting..." ) );
+
+ int files = 0;
+ for ( int size = 0 ; size < 12000 ; size += 1 )
+ {
+ dlg->slotProcessedSize( 0L, size );
+ dlg->slotPercent( 0L, 100 * size / 12000 );
+ if ( size % 1000 == 0 )
+ {
+ dlg->slotProcessedFiles( 0L, ++files );
+ }
+ kapp->processEvents();
+ }
+ dlg->slotInfoMessage( 0L, QString::fromLatin1( "Done." ) );
+
+ delete dlg;
+ return 0;
+}
+
diff --git a/kio/tests/kdirlistertest.cpp b/kio/tests/kdirlistertest.cpp
new file mode 100644
index 000000000..d3ea5b888
--- /dev/null
+++ b/kio/tests/kdirlistertest.cpp
@@ -0,0 +1,162 @@
+/* This file is part of the KDE desktop environment
+
+ Copyright (C) 2001, 2002 Michael Brade <brade@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qlayout.h>
+#include <qpushbutton.h>
+
+#include <kapplication.h>
+#include <kdirlister.h>
+#include <kdebug.h>
+
+#include "kdirlistertest.h"
+
+#include <cstdlib>
+
+
+KDirListerTest::KDirListerTest( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+ lister = new KDirLister( false /* true */ );
+ debug = new PrintSignals;
+
+ QVBoxLayout* layout = new QVBoxLayout( this );
+
+ QPushButton* startH = new QPushButton( "Start listing $HOME", this );
+ QPushButton* startR= new QPushButton( "Start listing /", this );
+ QPushButton* test = new QPushButton( "Many", this );
+ QPushButton* startT = new QPushButton( "tarfile", this );
+
+ layout->addWidget( startH );
+ layout->addWidget( startR );
+ layout->addWidget( startT );
+ layout->addWidget( test );
+ resize( layout->sizeHint() );
+
+ connect( startR, SIGNAL( clicked() ), SLOT( startRoot() ) );
+ connect( startH, SIGNAL( clicked() ), SLOT( startHome() ) );
+ connect( startT, SIGNAL( clicked() ), SLOT( startTar() ) );
+ connect( test, SIGNAL( clicked() ), SLOT( test() ) );
+
+ connect( lister, SIGNAL( started( const KURL & ) ),
+ debug, SLOT( started( const KURL & ) ) );
+ connect( lister, SIGNAL( completed() ),
+ debug, SLOT( completed() ) );
+ connect( lister, SIGNAL( completed( const KURL & ) ),
+ debug, SLOT( completed( const KURL & ) ) );
+ connect( lister, SIGNAL( canceled() ),
+ debug, SLOT( canceled() ) );
+ connect( lister, SIGNAL( canceled( const KURL & ) ),
+ debug, SLOT( canceled( const KURL & ) ) );
+ connect( lister, SIGNAL( redirection( const KURL & ) ),
+ debug, SLOT( redirection( const KURL & ) ) );
+ connect( lister, SIGNAL( redirection( const KURL &, const KURL & ) ),
+ debug, SLOT( redirection( const KURL &, const KURL & ) ) );
+ connect( lister, SIGNAL( clear() ),
+ debug, SLOT( clear() ) );
+ connect( lister, SIGNAL( newItems( const KFileItemList & ) ),
+ debug, SLOT( newItems( const KFileItemList & ) ) );
+ connect( lister, SIGNAL( itemsFilteredByMime( const KFileItemList & ) ),
+ debug, SLOT( itemsFilteredByMime( const KFileItemList & ) ) );
+ connect( lister, SIGNAL( deleteItem( KFileItem * ) ),
+ debug, SLOT( deleteItem( KFileItem * ) ) );
+ connect( lister, SIGNAL( refreshItems( const KFileItemList & ) ),
+ debug, SLOT( refreshItems( const KFileItemList & ) ) );
+ connect( lister, SIGNAL( infoMessage( const QString& ) ),
+ debug, SLOT( infoMessage( const QString& ) ) );
+ connect( lister, SIGNAL( percent( int ) ),
+ debug, SLOT( percent( int ) ) );
+ connect( lister, SIGNAL( totalSize( KIO::filesize_t ) ),
+ debug, SLOT( totalSize( KIO::filesize_t ) ) );
+ connect( lister, SIGNAL( processedSize( KIO::filesize_t ) ),
+ debug, SLOT( processedSize( KIO::filesize_t ) ) );
+ connect( lister, SIGNAL( speed( int ) ),
+ debug, SLOT( speed( int ) ) );
+
+ connect( lister, SIGNAL( completed() ),
+ this, SLOT( completed() ) );
+}
+
+KDirListerTest::~KDirListerTest()
+{
+ delete lister;
+}
+
+void KDirListerTest::startHome()
+{
+ KURL home( getenv( "HOME" ) );
+ lister->openURL( home, false, false );
+// lister->stop();
+}
+
+void KDirListerTest::startRoot()
+{
+ KURL root( "file:/" );
+ lister->openURL( root, true, true );
+// lister->stop( root );
+}
+
+void KDirListerTest::startTar()
+{
+ KURL root( "file:/home/jowenn/aclocal_1.tgz" );
+ lister->openURL( root, true, true );
+// lister->stop( root );
+}
+
+void KDirListerTest::test()
+{
+ KURL home( getenv( "HOME" ) );
+ KURL root( "file:/" );
+/* lister->openURL( home, true, false );
+ lister->openURL( root, true, true );
+ lister->openURL( KURL("file:/etc"), true, true );
+ lister->openURL( root, true, true );
+ lister->openURL( KURL("file:/dev"), true, true );
+ lister->openURL( KURL("file:/tmp"), true, true );
+ lister->openURL( KURL("file:/usr/include"), true, true );
+ lister->updateDirectory( KURL("file:/usr/include") );
+ lister->updateDirectory( KURL("file:/usr/include") );
+ lister->openURL( KURL("file:/usr/"), true, true );
+*/
+ lister->openURL( KURL("file:/dev"), true, true );
+}
+
+void KDirListerTest::completed()
+{
+ if ( lister->url().path() == "/")
+ {
+ KFileItem* item = lister->findByURL( "/tmp" );
+ if ( item )
+ kdDebug() << "Found /tmp: " << item << endl;
+ else
+ kdWarning() << "/tmp not found! Bug in findByURL?" << endl;
+ }
+}
+
+int main ( int argc, char *argv[] )
+{
+ KApplication app( argc, argv, "kdirlistertest" );
+
+ KDirListerTest *test = new KDirListerTest( 0 );
+ test->show();
+ app.setMainWidget( test );
+ return app.exec();
+}
+
+#include "kdirlistertest.moc"
diff --git a/kio/tests/kdirlistertest.h b/kio/tests/kdirlistertest.h
new file mode 100644
index 000000000..5c0e751a4
--- /dev/null
+++ b/kio/tests/kdirlistertest.h
@@ -0,0 +1,120 @@
+/* This file is part of the KDE desktop environment
+
+ Copyright (C) 2001, 2002 Michael Brade <brade@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KDIRLISTERTEST_H_
+#define _KDIRLISTERTEST_H_
+
+#include <qwidget.h>
+#include <qstring.h>
+
+#include <kurl.h>
+#include <kfileitem.h>
+
+#include <iostream>
+
+using namespace std;
+
+class PrintSignals : public QObject
+{
+ Q_OBJECT
+public:
+ PrintSignals() : QObject() { }
+
+public slots:
+ void started( const KURL &url )
+ {
+ cout << "*** started( " << url.url().local8Bit() << " )" << endl;
+ }
+ void canceled() { cout << "canceled()" << endl; }
+ void canceled( const KURL& url )
+ {
+ cout << "*** canceled( " << url.prettyURL().local8Bit() << " )" << endl;
+ }
+ void completed() { cout << "*** completed()" << endl; }
+ void completed( const KURL& url )
+ {
+ cout << "*** completed( " << url.prettyURL().local8Bit() << " )" << endl;
+ }
+ void redirection( const KURL& url )
+ {
+ cout << "*** redirection( " << url.prettyURL().local8Bit() << " )" << endl;
+ }
+ void redirection( const KURL& src, const KURL& dest )
+ {
+ cout << "*** redirection( " << src.prettyURL().local8Bit() << ", "
+ << dest.prettyURL().local8Bit() << " )" << endl;
+ }
+ void clear() { cout << "*** clear()" << endl; }
+ void newItems( const KFileItemList& items )
+ {
+ cout << "*** newItems: " << endl;
+ for ( KFileItemListIterator it( items ) ; it.current() ; ++it )
+ cout << it.current() << " " << it.current()->name().local8Bit() << endl;
+ }
+ void deleteItem( KFileItem* item )
+ {
+ cout << "*** deleteItem: " << item->url().prettyURL().local8Bit() << endl;
+ }
+ void itemsFilteredByMime( const KFileItemList& )
+ {
+ cout << "*** itemsFilteredByMime: " << endl;
+ // TODO
+ }
+ void refreshItems( const KFileItemList& )
+ {
+ cout << "*** refreshItems: " << endl;
+ // TODO
+ }
+ void infoMessage( const QString& msg )
+ { cout << "*** infoMessage: " << msg.local8Bit() << endl; }
+
+ void percent( int percent )
+ { cout << "*** percent: " << percent << endl; }
+
+ void totalSize( KIO::filesize_t size )
+ { cout << "*** totalSize: " << (long)size << endl; }
+
+ void processedSize( KIO::filesize_t size )
+ { cout << "*** processedSize: " << (long)size << endl; }
+
+ void speed( int bytes_per_second )
+ { cout << "*** speed: " << bytes_per_second << endl; }
+};
+
+class KDirListerTest : public QWidget
+{
+ Q_OBJECT
+public:
+ KDirListerTest( QWidget *parent=0, const char *name=0 );
+ ~KDirListerTest();
+
+public slots:
+ void startRoot();
+ void startHome();
+ void startTar();
+ void test();
+ void completed();
+
+private:
+ KDirLister *lister;
+ PrintSignals *debug;
+};
+
+#endif
diff --git a/kio/tests/kdirwatchtest.cpp b/kio/tests/kdirwatchtest.cpp
new file mode 100644
index 000000000..41924078e
--- /dev/null
+++ b/kio/tests/kdirwatchtest.cpp
@@ -0,0 +1,82 @@
+ /*
+ This file is or will be part of KDE desktop environment
+
+ Copyright 1998 Sven Radej <sven@lisa.exp.univie.ac.at>
+
+ It is licensed under GPL version 2.
+
+ If it is part of KDE libraries than this file is licensed under
+ LGPL version 2.
+ */
+
+#include <qfile.h>
+
+#include <kdebug.h>
+#include <kcmdlineargs.h>
+
+#include "kdirwatchtest.h"
+
+static const KCmdLineOptions options[] =
+{
+ {"+[directory ...]", "Directory(ies) to watch", 0},
+ KCmdLineLastOption
+};
+
+
+int main (int argc, char **argv)
+{
+ KCmdLineArgs::init(argc, argv, "KDirWatchTest",
+ "Test for KDirWatch", "1.0");
+ KCmdLineArgs::addCmdLineOptions( options );
+ KApplication::addCmdLineOptions();
+
+ KApplication a;
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ myTest testObject;
+
+ KDirWatch *dirwatch1 = KDirWatch::self();
+ KDirWatch *dirwatch2 = new KDirWatch;
+
+ testObject.connect(dirwatch1, SIGNAL( dirty( const QString &)), SLOT( dirty( const QString &)) );
+ testObject.connect(dirwatch1, SIGNAL( created( const QString &)), SLOT( created( const QString &)) );
+ testObject.connect(dirwatch1, SIGNAL( deleted( const QString &)), SLOT( deleted( const QString &)) );
+
+ if (args->count() >0) {
+ for(int i = 0; i < args->count(); i++) {
+ kdDebug() << "Watching: " << args->arg(i) << endl;
+ dirwatch2->addDir( QFile::decodeName( args->arg(i)));
+ }
+ }
+
+ QString home = QString(getenv ("HOME")) + "/";
+ QString desk = home + "Desktop/";
+ kdDebug() << "Watching: " << home << endl;
+ dirwatch1->addDir(home);
+ kdDebug() << "Watching file: " << home << "foo " << endl;
+ dirwatch1->addFile(home+"foo");
+ kdDebug() << "Watching: " << desk << endl;
+ dirwatch1->addDir(desk);
+ QString test = home + "test/";
+ kdDebug() << "Watching: (but skipped) " << test << endl;
+ dirwatch1->addDir(test);
+
+ dirwatch1->startScan();
+ dirwatch2->startScan();
+
+ if(!dirwatch1->stopDirScan(home))
+ kdDebug() << "stopDirscan: " << home << " error!" << endl;
+ if(!dirwatch1->restartDirScan(home))
+ kdDebug() << "restartDirScan: " << home << "error!" << endl;
+ if (!dirwatch1->stopDirScan(test))
+ kdDebug() << "stopDirScan: error" << endl;
+
+ KDirWatch::statistics();
+
+ delete dirwatch2;
+
+ KDirWatch::statistics();
+
+ return a.exec();
+}
+#include "kdirwatchtest.moc"
diff --git a/kio/tests/kdirwatchtest.h b/kio/tests/kdirwatchtest.h
new file mode 100644
index 000000000..9330f941c
--- /dev/null
+++ b/kio/tests/kdirwatchtest.h
@@ -0,0 +1,33 @@
+ /*
+ This file is or will be part of KDE desktop environment
+
+ Copyright 1998 Sven Radej <sven@lisa.exp.univie.ac.at>
+
+ It is licensed under GPL version 2.
+
+ If it is part of KDE libraries than this file is licensed under
+ LGPL version 2.
+ */
+
+#ifndef _KDIRWATCHTEST_H_
+#define _KDIRWATCHTEST_H_
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <qobject.h>
+
+#include "kdirwatch.h"
+#include "kapplication.h"
+
+class myTest : public QObject
+{
+ Q_OBJECT
+public:
+ myTest() { };
+public slots:
+ void dirty(const QString &a) { printf("Dirty: %s\n", a.ascii()); };
+ void created(const QString& f) { printf("Created: %s\n", f.ascii()); }
+ void deleted(const QString& f) { printf("Deleted: %s\n", f.ascii()); }
+};
+
+#endif
diff --git a/kio/tests/kdirwatchunittest.cpp b/kio/tests/kdirwatchunittest.cpp
new file mode 100644
index 000000000..d523909ec
--- /dev/null
+++ b/kio/tests/kdirwatchunittest.cpp
@@ -0,0 +1,180 @@
+ /*
+ This file is or will be part of KDE desktop environment
+
+ (c) 2006 Dirk Mueller <mueller@kde.org>
+
+ It is licensed under GPL version 2.
+
+ If it is part of KDE libraries than this file is licensed under
+ LGPL version 2.
+ */
+
+#include <unistd.h>
+
+#include <qfile.h>
+#include <qdir.h>
+
+#include <kdebug.h>
+
+#include "kdirwatchunittest.h"
+
+void KDirWatchTest::VERIFY_NOTHING()
+{
+ unsigned m_s[3];
+ for(int i = 0; i < 3; ++i)
+ m_s[i] = m_signals[i];
+
+ for (int i = 0; i < 20; ++i) {
+ usleep(100*1000);
+ qApp->processEvents();
+ }
+
+ bool nothing_failed = true;
+ for (int i = 0; i < 3; ++i)
+ if (m_s[i] != m_signals[i])
+ nothing_failed = false;
+
+ KDirWatch::statistics();
+
+ VERIFY (nothing_failed);
+}
+
+void KDirWatchTest::VERIFY_DIRTY(const QString& alert)
+{
+ unsigned m_s[3];
+ for(int i = 0; i < 3; ++i)
+ m_s[i] = m_signals[i];
+
+ for (int i = 0; i < 20; ++i) {
+ usleep(100*1000);
+ qApp->processEvents();
+ }
+
+ VERIFY (m_s[sigCreated] == m_signals[sigCreated] &&
+ m_s[sigDeleted] == m_signals[sigDeleted] &&
+ m_s[sigDirty] + 1 == m_signals[sigDirty] &&
+ m_lastSignal == alert);
+}
+
+void KDirWatchTest::VERIFY_CREATED(const QString& alert)
+{
+ unsigned m_s[3];
+ for(int i = 0; i < 3; ++i)
+ m_s[i] = m_signals[i];
+
+ for (int i = 0; i < 20; ++i) {
+ usleep(100*1000);
+ qApp->processEvents();
+ }
+
+ VERIFY (m_s[sigDirty] == m_signals[sigDirty] &&
+ m_s[sigDeleted] == m_signals[sigDeleted] &&
+ m_s[sigCreated] + 1 == m_signals[sigCreated] &&
+ m_lastSignal == alert);
+}
+
+void KDirWatchTest::VERIFY_DELETED(const QString& alert)
+{
+ unsigned m_s[3];
+ for(int i = 0; i < 3; ++i)
+ m_s[i] = m_signals[i];
+
+ for (int i = 0; i < 20; ++i) {
+ usleep(100*1000);
+ qApp->processEvents();
+ }
+
+ VERIFY (m_s[sigDirty] == m_signals[sigDirty] &&
+ m_s[sigCreated] == m_signals[sigCreated] &&
+ m_s[sigDeleted] + 1 == m_signals[sigDeleted] &&
+ m_lastSignal == alert);
+}
+
+void KDirWatchTest::remove_file (const QString& file)
+{
+ ::unlink (QFile::encodeName(file));
+}
+
+void KDirWatchTest::touch_file (const QString& file)
+{
+ QFile f(file);
+ f.open(IO_WriteOnly);
+}
+
+void KDirWatchTest::rename_file(const QString& from, const QString& to)
+{
+ ::rename(QFile::encodeName(from), QFile::encodeName(to));
+}
+
+KUNITTEST_MODULE ( kunittest_kdirwatch, "KDirWatchTest" )
+KUNITTEST_MODULE_REGISTER_TESTER (KDirWatchTest)
+
+#define SLEEP() QApplication::processEvents();
+
+void KDirWatchTest::allTests()
+{
+ for(int loop=0; loop<3; ++loop) {
+ d = new KDirWatch;
+ VERIFY (d != 0);
+
+ QDir* dir = new QDir(m_workingDir);
+ VERIFY (dir != 0);
+
+ connect(d, SIGNAL (dirty( const QString &)), SLOT( slotDirty( const QString &)) );
+ connect(d, SIGNAL (created( const QString &)), SLOT( slotCreated( const QString &)) );
+ connect(d, SIGNAL (deleted( const QString &)), SLOT( slotDeleted( const QString &)) );
+
+ VERIFY (dir->mkdir (m_workingDir));
+
+ d->addDir (m_workingDir);
+ VERIFY_NOTHING();
+ dir->mkdir ("does");
+ VERIFY_DIRTY (m_workingDir);
+ touch_file (m_workingDir + "/file");
+ VERIFY_DIRTY (m_workingDir);
+ VERIFY_NOTHING ();
+ remove_file (m_workingDir + "/file");
+ d->addDir (m_workingDir + "/does/not/exist");
+ d->removeDir (m_workingDir);
+ VERIFY_NOTHING();
+
+ dir->mkdir ("does/not");
+ VERIFY_NOTHING();
+ dir->mkdir ("does/not/exist");
+ VERIFY_CREATED (m_workingDir + "/does/not/exist");
+
+ dir->rmdir ("does/not/exist");
+ VERIFY_DELETED (m_workingDir + "/does/not/exist");
+ dir->rmdir ("does/not");
+ VERIFY_NOTHING();
+ dir->rmdir ("does");
+ VERIFY_NOTHING();
+
+ d->addFile(m_workingDir + "/a");
+ touch_file(m_workingDir + "/a");
+ VERIFY_CREATED (m_workingDir + "/a");
+
+ rename_file (m_workingDir + "/a", m_workingDir + "/b");
+ VERIFY_DELETED (m_workingDir + "/a");
+ VERIFY_NOTHING();
+
+ touch_file (m_workingDir + "/a");
+ VERIFY_CREATED (m_workingDir + "/a");
+ VERIFY_NOTHING();
+
+ touch_file (m_workingDir + "/a");
+ VERIFY_DIRTY (m_workingDir + "/a");
+
+ remove_file (m_workingDir + "/b");
+ VERIFY_NOTHING();
+
+ d->removeFile(m_workingDir + "/a");
+
+ remove_file(m_workingDir + "/a");
+
+ VERIFY (dir->rmdir (m_workingDir));
+ delete d;
+ }
+}
+
+#include "kdirwatchunittest.moc"
diff --git a/kio/tests/kdirwatchunittest.h b/kio/tests/kdirwatchunittest.h
new file mode 100644
index 000000000..417cdf24e
--- /dev/null
+++ b/kio/tests/kdirwatchunittest.h
@@ -0,0 +1,66 @@
+ /*
+ This file is or will be part of KDE desktop environment
+
+ Copyright 1998 Sven Radej <sven@lisa.exp.univie.ac.at>
+
+ It is licensed under GPL version 2.
+
+ If it is part of KDE libraries than this file is licensed under
+ LGPL version 2.
+ */
+
+#ifndef _KDIRWATCHTEST_H_
+#define _KDIRWATCHTEST_H_
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <qobject.h>
+
+#include "kdirwatch.h"
+#include "kapplication.h"
+
+#include <kunittest/tester.h>
+#include <kunittest/module.h>
+
+class KDirWatchTest : public KUnitTest::Tester
+{
+ Q_OBJECT
+
+public:
+ enum { sigDirty, sigCreated, sigDeleted };
+
+ KDirWatchTest()
+ {
+ m_signals[sigDirty] = m_signals[sigCreated] = m_signals[sigDeleted] = 0;
+ m_workingDir = "/tmp/kdirwatchtest";
+ }
+
+ virtual void allTests();
+
+private slots:
+ void slotDirty (const QString& s) { m_signals[sigDirty]++; m_lastSignal = s; }
+ void slotCreated (const QString& s) { m_signals[sigCreated]++; m_lastSignal = s; }
+ void slotDeleted (const QString& s) { m_signals[sigDeleted]++; m_lastSignal = s; }
+
+private:
+ unsigned m_signals[3];
+
+ /* verify nothing happens */
+ void VERIFY_NOTHING();
+ /* verify that dirty got emitted */
+ void VERIFY_DIRTY (const QString&);
+ /* verify that created got emitted */
+ void VERIFY_CREATED (const QString&);
+ /* verify that deleted got emitted */
+ void VERIFY_DELETED (const QString&);
+
+ void touch_file (const QString& file);
+ void remove_file (const QString& file);
+ void rename_file (const QString& from, const QString& to);
+
+ QString m_lastSignal;
+ QString m_workingDir;
+ KDirWatch* d;
+};
+
+#endif
diff --git a/kio/tests/kfiltertest.cpp b/kio/tests/kfiltertest.cpp
new file mode 100644
index 000000000..a0dd8fe49
--- /dev/null
+++ b/kio/tests/kfiltertest.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2002, 2003 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "kfilterdev.h"
+#include "kfilterbase.h"
+#include <unistd.h>
+#include <limits.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <kdebug.h>
+#include <kinstance.h>
+
+void test_block( const QString & fileName )
+{
+ QIODevice * dev = KFilterDev::deviceForFile( fileName );
+ if (!dev) { kdWarning() << "dev=0" << endl; return; }
+ if ( !dev->open( IO_ReadOnly ) ) { kdWarning() << "open failed " << endl; return; }
+
+ // This is what KGzipDev::readAll could do, if QIODevice::readAll was virtual....
+
+ QByteArray array(1024);
+ int n;
+ while ( ( n = dev->readBlock( array.data(), array.size() ) ) )
+ {
+ kdDebug() << "readBlock returned " << n << endl << endl;
+ // QCString s(array,n+1); // Terminate with 0 before printing
+ // printf("%s", s.data());
+
+ kdDebug() << "dev.at = " << dev->at() << endl;
+ //kdDebug() << "f.at = " << f.at() << endl;
+ }
+ dev->close();
+ delete dev;
+}
+
+void test_block_write( const QString & fileName )
+{
+ QIODevice * dev = KFilterDev::deviceForFile( fileName );
+ if (!dev) { kdWarning() << "dev=0" << endl; return; }
+ if ( !dev->open( IO_WriteOnly ) ) { kdWarning() << "open failed " << endl; return; }
+
+ QCString s("hello\n");
+ int ret = dev->writeBlock( s, s.size()-1 );
+ kdDebug() << "writeBlock ret=" << ret << endl;
+ //ret = dev->writeBlock( s, s.size()-1 );
+ //kdDebug() << "writeBlock ret=" << ret << endl;
+ dev->close();
+ delete dev;
+}
+
+void test_getch( const QString & fileName )
+{
+ QIODevice * dev = KFilterDev::deviceForFile( fileName );
+ if (!dev) { kdWarning() << "dev=0" << endl; return; }
+ if ( !dev->open( IO_ReadOnly ) ) { kdWarning() << "open failed " << endl; return; }
+ int ch;
+ while ( ( ch = dev->getch() ) != -1 )
+ printf("%c",ch);
+ dev->close();
+ delete dev;
+}
+
+void test_textstream( const QString & fileName )
+{
+ QIODevice * dev = KFilterDev::deviceForFile( fileName );
+ if (!dev) { kdWarning() << "dev=0" << endl; return; }
+ if ( !dev->open( IO_ReadOnly ) ) { kdWarning() << "open failed " << endl; return; }
+ QTextStream ts( dev );
+ printf("%s\n", ts.read().latin1());
+ dev->close();
+ delete dev;
+}
+
+int main()
+{
+ KInstance instance("kfiltertest");
+
+ char currentdir[PATH_MAX+1];
+ getcwd( currentdir, PATH_MAX );
+ QString pathgz = QFile::decodeName(currentdir) + "/test.gz";
+ QString pathbz2 = QFile::decodeName(currentdir) + "/test.bz2";
+
+ kdDebug() << " -- test_block_write gzip -- " << endl;
+ test_block_write(pathgz);
+ kdDebug() << " -- test_block_write bzip2 -- " << endl;
+ test_block_write(pathbz2);
+
+ kdDebug() << " -- test_block gzip -- " << endl;
+ test_block(pathgz);
+ kdDebug() << " -- test_getch gzip -- " << endl;
+ test_getch(pathgz);
+ kdDebug() << " -- test_textstream gzip -- " << endl;
+ test_textstream(pathgz);
+
+ kdDebug() << " -- test_block bzip2 -- " << endl;
+ test_block(pathbz2);
+ kdDebug() << " -- test_getch bzip2 -- " << endl;
+ test_getch(pathbz2);
+ kdDebug() << " -- test_textstream bzip2 -- " << endl;
+ test_textstream(pathbz2);
+
+ return 0;
+}
diff --git a/kio/tests/kionetrctest.cpp b/kio/tests/kionetrctest.cpp
new file mode 100644
index 000000000..977603426
--- /dev/null
+++ b/kio/tests/kionetrctest.cpp
@@ -0,0 +1,71 @@
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
+
+#include "authinfo.h"
+
+void output( const KURL& u )
+{
+ kdDebug() << "Looking up auto login for: " << u.url() << endl;
+ KIO::NetRC::AutoLogin l;
+ bool result = KIO::NetRC::self()->lookup( u, l, true );
+ if ( !result )
+ {
+ kdDebug() << "Either no .netrc and/or .kionetrc file was "
+ "found or there was problem when attempting to "
+ "read from them! Please make sure either or both "
+ "of the above files exist and have the correct "
+ "permission, i.e. a regular file owned by you with "
+ "with a read/write permission (0600)" << endl;
+ return;
+ }
+
+ kdDebug() << "Type: " << l.type << endl
+ << "Machine: " << l.machine << endl
+ << "Login: " << l.login << endl
+ << "Password: " << l.password << endl;
+
+ QMap<QString,QStringList>::ConstIterator it = l.macdef.begin();
+ for ( ; it != l.macdef.end(); ++it )
+ {
+ kdDebug() << "Macro: " << it.key() << "= "
+ << it.data().join(" ") << endl;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ const char *version = "0.5";
+ const char *description = "Unit test for .netrc and kionetrc parser.";
+ KCmdLineOptions options[] =
+ {
+ { "+command", "[url1,url2 ,...]", 0 },
+ KCmdLineLastOption
+ };
+
+ KCmdLineArgs::init( argc, argv, "kionetrctest", description, version );
+ KCmdLineArgs::addCmdLineOptions( options );
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+ int count = args->count();
+ KApplication app;
+
+ if ( !count )
+ args->usage();
+ else
+ {
+ KURL u;
+ for( int i=0 ; i < count; i++ )
+ {
+ u = args->arg(i);
+ if ( !u.isValid() )
+ {
+ kdDebug() << u.url() << " is invalid! Ignoring..." << endl;
+ continue;
+ }
+ output( u );
+ }
+ }
+ args->clear();
+ return 0;
+}
diff --git a/kio/tests/kiopassdlgtest.cpp b/kio/tests/kiopassdlgtest.cpp
new file mode 100644
index 000000000..fc017476d
--- /dev/null
+++ b/kio/tests/kiopassdlgtest.cpp
@@ -0,0 +1,32 @@
+#include <kapplication.h>
+#include <klocale.h>
+#include <kaboutdata.h>
+#include <kmessagebox.h>
+#include <kcmdlineargs.h>
+
+#include "passdlg.h"
+
+int main ( int argc, char** argv )
+{
+ KAboutData aboutData("kiopassdlgtest", "KIO Password Dialog Test", "1.0");
+ KCmdLineArgs::init(argc, argv, &aboutData);
+ KApplication app;
+
+ QString usr, pass, comment, label;
+ label = "Site:";
+ comment = "<b>localhost</b>";
+ int res = KIO::PasswordDialog::getNameAndPassword( usr, pass, 0L,
+ QString::null, false,
+ QString::null, comment,
+ label );
+ if ( res == QDialog::Accepted )
+ KMessageBox::information( 0L, QString("You entered:\n"
+ " Username: %1\n"
+ " Password: %2").arg(usr).arg(pass),
+ "Test Result");
+ else
+ KMessageBox::information( 0L, "Password dialog was canceled!",
+ "Test Result");
+
+ return 0;
+}
diff --git a/kio/tests/kioslavetest.cpp b/kio/tests/kioslavetest.cpp
new file mode 100644
index 000000000..8594586df
--- /dev/null
+++ b/kio/tests/kioslavetest.cpp
@@ -0,0 +1,555 @@
+ /*
+ This file is or will be part of KDE desktop environment
+
+ Copyright 1999 Matt Koss <koss@miesto.sk>
+
+ It is licensed under GPL version 2.
+
+ If it is part of KDE libraries than this file is licensed under
+ LGPL version 2.
+ */
+
+#include <qlayout.h>
+#include <qmessagebox.h>
+#include <qdir.h>
+
+#include <kacl.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kurl.h>
+#include <kstatusbar.h>
+#include <kio/job.h>
+#include <kio/scheduler.h>
+#include <kprotocolinfo.h>
+
+#include "kioslavetest.h"
+
+using namespace KIO;
+
+KioslaveTest::KioslaveTest( QString src, QString dest, uint op, uint pr )
+ : KMainWindow(0, "")
+{
+
+ job = 0L;
+
+ main_widget = new QWidget( this, "");
+ QBoxLayout *topLayout = new QVBoxLayout( main_widget, 10, 5 );
+
+ QGridLayout *grid = new QGridLayout( 2, 2, 10 );
+ topLayout->addLayout( grid );
+
+ grid->setRowStretch(0,1);
+ grid->setRowStretch(1,1);
+
+ grid->setColStretch(0,1);
+ grid->setColStretch(1,100);
+
+ lb_from = new QLabel( "From:", main_widget );
+ grid->addWidget( lb_from, 0, 0 );
+
+ le_source = new QLineEdit( main_widget );
+ grid->addWidget( le_source, 0, 1 );
+ le_source->setText( src );
+
+ lb_to = new QLabel( "To:", main_widget );
+ grid->addWidget( lb_to, 1, 0 );
+
+ le_dest = new QLineEdit( main_widget );
+ grid->addWidget( le_dest, 1, 1 );
+ le_dest->setText( dest );
+
+ // Operation groupbox & buttons
+ opButtons = new QButtonGroup( "Operation", main_widget );
+ topLayout->addWidget( opButtons, 10 );
+ connect( opButtons, SIGNAL(clicked(int)), SLOT(changeOperation(int)) );
+
+ QBoxLayout *hbLayout = new QHBoxLayout( opButtons, 15 );
+
+ rbList = new QRadioButton( "List", opButtons );
+ opButtons->insert( rbList, List );
+ hbLayout->addWidget( rbList, 5 );
+
+ rbListRecursive = new QRadioButton( "ListRecursive", opButtons );
+ opButtons->insert( rbListRecursive, ListRecursive );
+ hbLayout->addWidget( rbListRecursive, 5 );
+
+ rbStat = new QRadioButton( "Stat", opButtons );
+ opButtons->insert( rbStat, Stat );
+ hbLayout->addWidget( rbStat, 5 );
+
+ rbGet = new QRadioButton( "Get", opButtons );
+ opButtons->insert( rbGet, Get );
+ hbLayout->addWidget( rbGet, 5 );
+
+ rbPut = new QRadioButton( "Put", opButtons );
+ opButtons->insert( rbPut, Put );
+ hbLayout->addWidget( rbPut, 5 );
+
+ rbCopy = new QRadioButton( "Copy", opButtons );
+ opButtons->insert( rbCopy, Copy );
+ hbLayout->addWidget( rbCopy, 5 );
+
+ rbMove = new QRadioButton( "Move", opButtons );
+ opButtons->insert( rbMove, Move );
+ hbLayout->addWidget( rbMove, 5 );
+
+ rbDelete = new QRadioButton( "Delete", opButtons );
+ opButtons->insert( rbDelete, Delete );
+ hbLayout->addWidget( rbDelete, 5 );
+
+ rbShred = new QRadioButton( "Shred", opButtons );
+ opButtons->insert( rbShred, Shred );
+ hbLayout->addWidget( rbShred, 5 );
+
+ rbMkdir = new QRadioButton( "Mkdir", opButtons );
+ opButtons->insert( rbMkdir, Mkdir );
+ hbLayout->addWidget( rbMkdir, 5 );
+
+ rbMimetype = new QRadioButton( "Mimetype", opButtons );
+ opButtons->insert( rbMimetype, Mimetype );
+ hbLayout->addWidget( rbMimetype, 5 );
+
+ opButtons->setButton( op );
+ changeOperation( op );
+
+ // Progress groupbox & buttons
+ progressButtons = new QButtonGroup( "Progress dialog mode", main_widget );
+ topLayout->addWidget( progressButtons, 10 );
+ connect( progressButtons, SIGNAL(clicked(int)), SLOT(changeProgressMode(int)) );
+
+ hbLayout = new QHBoxLayout( progressButtons, 15 );
+
+ rbProgressNone = new QRadioButton( "None", progressButtons );
+ progressButtons->insert( rbProgressNone, ProgressNone );
+ hbLayout->addWidget( rbProgressNone, 5 );
+
+ rbProgressDefault = new QRadioButton( "Default", progressButtons );
+ progressButtons->insert( rbProgressDefault, ProgressDefault );
+ hbLayout->addWidget( rbProgressDefault, 5 );
+
+ rbProgressStatus = new QRadioButton( "Status", progressButtons );
+ progressButtons->insert( rbProgressStatus, ProgressStatus );
+ hbLayout->addWidget( rbProgressStatus, 5 );
+
+ progressButtons->setButton( pr );
+ changeProgressMode( pr );
+
+ // statusbar progress widget
+ statusProgress = new StatusbarProgress( statusBar() );
+ statusBar()->addWidget( statusProgress, 0, true );
+
+ // run & stop butons
+ hbLayout = new QHBoxLayout( topLayout, 15 );
+
+ pbStart = new QPushButton( "&Start", main_widget );
+ pbStart->setFixedSize( pbStart->sizeHint() );
+ connect( pbStart, SIGNAL(clicked()), SLOT(startJob()) );
+ hbLayout->addWidget( pbStart, 5 );
+
+ pbStop = new QPushButton( "Sto&p", main_widget );
+ pbStop->setFixedSize( pbStop->sizeHint() );
+ pbStop->setEnabled( false );
+ connect( pbStop, SIGNAL(clicked()), SLOT(stopJob()) );
+ hbLayout->addWidget( pbStop, 5 );
+
+ // close button
+ close = new QPushButton( "&Close", main_widget );
+ close->setFixedSize( close->sizeHint() );
+ connect(close, SIGNAL(clicked()), this, SLOT(slotQuit()));
+
+ topLayout->addWidget( close, 5 );
+
+ main_widget->setMinimumSize( main_widget->sizeHint() );
+ setCentralWidget( main_widget );
+
+ slave = 0;
+// slave = KIO::Scheduler::getConnectedSlave(KURL("ftp://ftp.kde.org"));
+ KIO::Scheduler::connect(SIGNAL(slaveConnected(KIO::Slave*)),
+ this, SLOT(slotSlaveConnected()));
+ KIO::Scheduler::connect(SIGNAL(slaveError(KIO::Slave*,int,const QString&)),
+ this, SLOT(slotSlaveError()));
+}
+
+
+void KioslaveTest::closeEvent( QCloseEvent * ){
+ slotQuit();
+}
+
+
+void KioslaveTest::slotQuit(){
+ if ( job ) {
+ job->kill( true ); // kill the job quietly
+ }
+ if (slave)
+ KIO::Scheduler::disconnectSlave(slave);
+ kapp->quit();
+}
+
+
+void KioslaveTest::changeOperation( int id ) {
+ // only two urls for copy and move
+ bool enab = rbCopy->isChecked() || rbMove->isChecked();
+
+ le_dest->setEnabled( enab );
+
+ selectedOperation = id;
+}
+
+
+void KioslaveTest::changeProgressMode( int id ) {
+ progressMode = id;
+
+ if ( progressMode == ProgressStatus ) {
+ statusBar()->show();
+ } else {
+ statusBar()->hide();
+ }
+}
+
+
+void KioslaveTest::startJob() {
+ QString sCurrent = QDir::currentDirPath()+"/";
+ KURL::encode_string(sCurrent);
+ QString sSrc( le_source->text() );
+ KURL src( sCurrent, sSrc );
+
+ if ( !src.isValid() ) {
+ QMessageBox::critical(this, "Kioslave Error Message", "Source URL is malformed" );
+ return;
+ }
+
+ QString sDest( le_dest->text() );
+ KURL dest( sCurrent, sDest );
+
+ if ( !dest.isValid() &&
+ ( selectedOperation == Copy || selectedOperation == Move ) ) {
+ QMessageBox::critical(this, "Kioslave Error Message",
+ "Destination URL is malformed" );
+ return;
+ }
+
+ pbStart->setEnabled( false );
+
+ bool observe = true;
+ if (progressMode != ProgressDefault) {
+ observe = false;
+ }
+
+ SimpleJob *myJob = 0;
+
+ switch ( selectedOperation ) {
+ case List:
+ myJob = KIO::listDir( src );
+ connect(myJob, SIGNAL( entries( KIO::Job*, const KIO::UDSEntryList&)),
+ SLOT( slotEntries( KIO::Job*, const KIO::UDSEntryList&)));
+ break;
+
+ case ListRecursive:
+ myJob = KIO::listRecursive( src );
+ connect(myJob, SIGNAL( entries( KIO::Job*, const KIO::UDSEntryList&)),
+ SLOT( slotEntries( KIO::Job*, const KIO::UDSEntryList&)));
+ break;
+
+ case Stat:
+ myJob = KIO::stat( src, false, 2 );
+ break;
+
+ case Get:
+ myJob = KIO::get( src, true );
+ connect(myJob, SIGNAL( data( KIO::Job*, const QByteArray &)),
+ SLOT( slotData( KIO::Job*, const QByteArray &)));
+ break;
+
+ case Put:
+ putBuffer = 0;
+ myJob = KIO::put( src, -1, true, false);
+ connect(myJob, SIGNAL( dataReq( KIO::Job*, QByteArray &)),
+ SLOT( slotDataReq( KIO::Job*, QByteArray &)));
+ break;
+
+ case Copy:
+ job = KIO::copy( src, dest, observe );
+ break;
+
+ case Move:
+ job = KIO::move( src, dest, observe );
+ break;
+
+ case Delete:
+ job = KIO::del( src, false, observe );
+ break;
+
+ case Shred:
+ job = KIO::del(src, true, observe);
+ break;
+
+ case Mkdir:
+ myJob = KIO::mkdir( src );
+ break;
+
+ case Mimetype:
+ myJob = KIO::mimetype( src );
+ break;
+ }
+ if (myJob)
+ {
+ if (slave)
+ KIO::Scheduler::assignJobToSlave(slave, myJob);
+ job = myJob;
+ }
+
+ connect( job, SIGNAL( result( KIO::Job * ) ),
+ SLOT( slotResult( KIO::Job * ) ) );
+
+ connect( job, SIGNAL( canceled( KIO::Job * ) ),
+ SLOT( slotResult( KIO::Job * ) ) );
+
+ if (progressMode == ProgressStatus) {
+ statusProgress->setJob( job );
+ }
+
+ pbStop->setEnabled( true );
+}
+
+
+void KioslaveTest::slotResult( KIO::Job * _job )
+{
+ if ( _job->error() )
+ {
+ _job->showErrorDialog();
+ }
+ else if ( selectedOperation == Stat )
+ {
+ UDSEntry entry = ((KIO::StatJob*)_job)->statResult();
+ printUDSEntry( entry );
+ }
+ else if ( selectedOperation == Mimetype )
+ {
+ kdDebug() << "mimetype is " << ((KIO::MimetypeJob*)_job)->mimetype() << endl;
+ }
+
+ if (job == _job)
+ job = 0L;
+ pbStart->setEnabled( true );
+ pbStop->setEnabled( false );
+}
+
+void KioslaveTest::slotSlaveConnected()
+{
+ kdDebug() << "Slave connected." << endl;
+}
+
+void KioslaveTest::slotSlaveError()
+{
+ kdDebug() << "Error connected." << endl;
+ slave = 0;
+}
+
+static void printACL( const QString& acl )
+{
+ KACL kacl( acl );
+ kdDebug() << "According to KACL: " << endl << kacl.asString() << endl;
+ kdDebug() << "Owner: " << kacl.ownerPermissions() << endl;
+ kdDebug() << "Owning group: " << kacl.owningGroupPermissions() << endl;
+ kdDebug() << "Others: " << kacl.othersPermissions() << endl;
+}
+
+
+void KioslaveTest::printUDSEntry( const KIO::UDSEntry & entry )
+{
+ KIO::UDSEntry::ConstIterator it = entry.begin();
+ for( ; it != entry.end(); it++ ) {
+ switch ((*it).m_uds) {
+ case KIO::UDS_FILE_TYPE:
+ kdDebug() << "File Type : " << (mode_t)((*it).m_long) << endl;
+ if ( S_ISDIR( (mode_t)((*it).m_long) ) )
+ {
+ kdDebug() << "is a dir" << endl;
+ }
+ break;
+ case KIO::UDS_ACCESS:
+ kdDebug() << "Access permissions : " << (*it).m_long << endl;
+ break;
+ case KIO::UDS_EXTENDED_ACL:
+ if( (*it).m_long == 1 )
+ kdDebug() << "Has extended ACL information." << endl;
+ break;
+ case KIO::UDS_ACL_STRING:
+ kdDebug() << "ACL: " << ( (*it).m_str.ascii() ) << endl;
+ printACL( (*it).m_str );
+ break;
+ case KIO::UDS_DEFAULT_ACL_STRING:
+ kdDebug() << "Default ACL: " << ( (*it).m_str.ascii() ) << endl;
+ printACL( (*it).m_str );
+ break;
+ case KIO::UDS_USER:
+ kdDebug() << "User : " << ((*it).m_str.ascii() ) << endl;
+ break;
+ case KIO::UDS_GROUP:
+ kdDebug() << "Group : " << ((*it).m_str.ascii() ) << endl;
+ break;
+ case KIO::UDS_NAME:
+ kdDebug() << "Name : " << ((*it).m_str.ascii() ) << endl;
+ //m_strText = decodeFileName( (*it).m_str );
+ break;
+ case KIO::UDS_URL:
+ kdDebug() << "URL : " << ((*it).m_str.ascii() ) << endl;
+ break;
+ case KIO::UDS_MIME_TYPE:
+ kdDebug() << "MimeType : " << ((*it).m_str.ascii() ) << endl;
+ break;
+ case KIO::UDS_LINK_DEST:
+ kdDebug() << "LinkDest : " << ((*it).m_str.ascii() ) << endl;
+ break;
+ case KIO::UDS_SIZE:
+ kdDebug() << "Size: " << KIO::convertSize((*it).m_long) << endl;
+ break;
+ }
+ }
+}
+
+void KioslaveTest::slotEntries(KIO::Job* job, const KIO::UDSEntryList& list) {
+
+ KURL url = static_cast<KIO::ListJob*>( job )->url();
+ KProtocolInfo::ExtraFieldList extraFields = KProtocolInfo::extraFields(url);
+ UDSEntryListConstIterator it=list.begin();
+ for (; it != list.end(); ++it) {
+ // For each file...
+ KProtocolInfo::ExtraFieldList::Iterator extraFieldsIt = extraFields.begin();
+ UDSEntry::ConstIterator it2 = (*it).begin();
+ for( ; it2 != (*it).end(); it2++ ) {
+ if ((*it2).m_uds == UDS_NAME)
+ kdDebug() << "" << ( *it2 ).m_str << endl;
+ else if ( (*it2).m_uds == UDS_EXTRA) {
+ Q_ASSERT( extraFieldsIt != extraFields.end() );
+ QString column = (*extraFieldsIt).name;
+ //QString type = (*extraFieldsIt).type;
+ kdDebug() << " Extra data (" << column << ") :" << ( *it2 ).m_str << endl;
+ ++extraFieldsIt;
+ }
+ }
+ }
+}
+
+void KioslaveTest::slotData(KIO::Job*, const QByteArray &data)
+{
+ if (data.size() == 0)
+ {
+ kdDebug(0) << "Data: <End>" << endl;
+ }
+ else
+ {
+ kdDebug(0) << "Data: \"" << QCString(data, data.size()+1) << "\"" << endl;
+ }
+}
+
+void KioslaveTest::slotDataReq(KIO::Job*, QByteArray &data)
+{
+ const char *fileDataArray[] =
+ {
+ "Hello world\n",
+ "This is a test file\n",
+ "You can safely delete it.\n",
+ "BIG\n",
+ 0
+ };
+ const char *fileData = fileDataArray[putBuffer++];
+
+ if (!fileData)
+ {
+ kdDebug(0) << "DataReq: <End>" << endl;
+ return;
+ }
+ if (!strcmp(fileData, "BIG\n"))
+ data.fill(0, 29*1024*1024);
+ else
+ data.duplicate(fileData, strlen(fileData));
+ kdDebug(0) << "DataReq: \"" << fileData << "\"" << endl;
+}
+
+void KioslaveTest::stopJob() {
+ kdDebug() << "KioslaveTest::stopJob()" << endl;
+ job->kill();
+ job = 0L;
+
+ pbStop->setEnabled( false );
+ pbStart->setEnabled( true );
+}
+
+static const char version[] = "v0.0.0 0000"; // :-)
+static const char description[] = "Test for kioslaves";
+static KCmdLineOptions options[] =
+{
+ { "s", 0, 0 },
+ { "src <src>", "Source URL", "" },
+ { "d", 0, 0 },
+ { "dest <dest>", "Destination URL", "" },
+ { "o", 0, 0 },
+ { "operation <operation>", "Operation (list,listrecursive,stat,get,put,copy,move,del,shred,mkdir)", "copy" },
+ { "p", 0, 0 },
+ { "progress <progress>", "Progress Type (none,default,status)", "default" },
+ KCmdLineLastOption
+};
+
+int main(int argc, char **argv) {
+ KCmdLineArgs::init( argc, argv, "kioslavetest", description, version );
+ KCmdLineArgs::addCmdLineOptions( options );
+ KApplication app;
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ QString src = args->getOption("src");
+ QString dest = args->getOption("dest");
+
+ uint op = 0;
+ uint pr = 0;
+
+ QString tmps;
+
+ tmps = args->getOption("operation");
+ if ( tmps == "list") {
+ op = KioslaveTest::List;
+ } else if ( tmps == "listrecursive") {
+ op = KioslaveTest::ListRecursive;
+ } else if ( tmps == "stat") {
+ op = KioslaveTest::Stat;
+ } else if ( tmps == "get") {
+ op = KioslaveTest::Get;
+ } else if ( tmps == "put") {
+ op = KioslaveTest::Put;
+ } else if ( tmps == "copy") {
+ op = KioslaveTest::Copy;
+ } else if ( tmps == "move") {
+ op = KioslaveTest::Move;
+ } else if ( tmps == "del") {
+ op = KioslaveTest::Delete;
+ } else if ( tmps == "shred") {
+ op = KioslaveTest::Shred;
+ } else if ( tmps == "mkdir") {
+ op = KioslaveTest::Mkdir;
+ } else KCmdLineArgs::usage("unknown operation");
+
+ tmps = args->getOption("progress");
+ if ( tmps == "none") {
+ pr = KioslaveTest::ProgressNone;
+ } else if ( tmps == "default") {
+ pr = KioslaveTest::ProgressDefault;
+ } else if ( tmps == "status") {
+ pr = KioslaveTest::ProgressStatus;
+ } else KCmdLineArgs::usage("unknown progress mode");
+
+ args->clear(); // Free up memory
+
+ KioslaveTest test( src, dest, op, pr );
+ test.show();
+ // Bug in KTMW / Qt / layouts ?
+ test.resize( test.sizeHint() );
+
+ app.setMainWidget(&test);
+ app.exec();
+}
+
+
+#include "kioslavetest.moc"
diff --git a/kio/tests/kioslavetest.h b/kio/tests/kioslavetest.h
new file mode 100644
index 000000000..34cb00c15
--- /dev/null
+++ b/kio/tests/kioslavetest.h
@@ -0,0 +1,108 @@
+ /*
+ This file is or will be part of KDE desktop environment
+
+ Copyright 1999 Matt Koss <koss@miesto.sk>
+
+ It is licensed under GPL version 2.
+
+ If it is part of KDE libraries than this file is licensed under
+ LGPL version 2.
+ */
+
+#ifndef _KIOSLAVETEST_H
+#define _KIOSLAVETEST_H
+
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qradiobutton.h>
+#include <qpushbutton.h>
+#include <qbuttongroup.h>
+#include <qwidget.h>
+
+#include <kmainwindow.h>
+
+#include "kio/job.h"
+#include "kio/global.h"
+#include "kio/statusbarprogress.h"
+#include "kio/slave.h"
+
+class KioslaveTest : public KMainWindow {
+ Q_OBJECT
+
+public:
+ KioslaveTest( QString src, QString dest, uint op, uint pr );
+ ~KioslaveTest() {}
+
+ enum Operations { List, ListRecursive, Stat, Get, Put, Copy, Move, Delete, Shred, Mkdir, Mimetype };
+
+ enum ProgressModes { ProgressNone, ProgressDefault, ProgressStatus };
+
+protected:
+
+ void closeEvent( QCloseEvent * );
+
+ void printUDSEntry( const KIO::UDSEntry & entry );
+
+ // info stuff
+ QLabel *lb_from;
+ QLineEdit *le_source;
+
+ QLabel *lb_to;
+ QLineEdit *le_dest;
+
+ // operation stuff
+ QButtonGroup *opButtons;
+
+ QRadioButton *rbList;
+ QRadioButton *rbListRecursive;
+ QRadioButton *rbStat;
+ QRadioButton *rbGet;
+ QRadioButton *rbPut;
+ QRadioButton *rbCopy;
+ QRadioButton *rbMove;
+ QRadioButton *rbDelete;
+ QRadioButton *rbShred;
+ QRadioButton *rbMkdir;
+ QRadioButton *rbMimetype;
+
+ // progress stuff
+ QButtonGroup *progressButtons;
+
+ QRadioButton *rbProgressNone;
+ QRadioButton *rbProgressDefault;
+ QRadioButton *rbProgressStatus;
+
+ QPushButton *pbStart;
+ QPushButton *pbStop;
+
+ QPushButton *close;
+
+protected slots:
+ void changeOperation( int id );
+ void changeProgressMode( int id );
+
+ void startJob();
+ void stopJob();
+
+ void slotResult( KIO::Job * );
+ void slotEntries( KIO::Job *, const KIO::UDSEntryList& );
+ void slotData( KIO::Job *, const QByteArray &data );
+ void slotDataReq( KIO::Job *, QByteArray &data );
+
+ void slotQuit();
+ void slotSlaveConnected();
+ void slotSlaveError();
+
+private:
+ KIO::Job *job;
+ QWidget *main_widget;
+
+ KIO::StatusbarProgress *statusProgress;
+
+ int selectedOperation;
+ int progressMode;
+ int putBuffer;
+ KIO::Slave *slave;
+};
+
+#endif // _KIOSLAVETEST_H
diff --git a/kio/tests/kmfitest.cpp b/kio/tests/kmfitest.cpp
new file mode 100644
index 000000000..c50b83b34
--- /dev/null
+++ b/kio/tests/kmfitest.cpp
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <qdir.h>
+#include <qfile.h>
+#include <kinstance.h>
+#include <kurl.h>
+#include <kfilemetainfo.h>
+#include <kmimetype.h>
+
+int main (int argc, char **argv)
+{
+ KInstance ins("kmfitest");
+
+ if (argc < 2) {
+ printf("usage: %s <file>\n", argv[0]);
+ return 1;
+ }
+
+ for (int i = 1; i < argc; i++) {
+ QString file = QFile::decodeName(argv[i]);
+ qWarning("File: %s", file.local8Bit().data());
+ KMimeType::Ptr p;
+ p = KMimeType::findByPath(file);
+ qWarning("Mime type (findByPath): %s", p->name().latin1());
+ KFileMetaInfo meta(file, QString::null, KFileMetaInfo::TechnicalInfo | KFileMetaInfo::ContentInfo);
+ }
+
+ return 0;
+}
diff --git a/kio/tests/kmimefromext.cpp b/kio/tests/kmimefromext.cpp
new file mode 100644
index 000000000..e867d4822
--- /dev/null
+++ b/kio/tests/kmimefromext.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2002 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <ktrader.h>
+#include <kmimetype.h>
+#include <kcmdlineargs.h>
+#include <kapplication.h>
+
+#include <stdio.h>
+
+static KCmdLineOptions options[] =
+{
+ { "+filename", "the filename to test", 0 },
+ KCmdLineLastOption
+};
+
+int main(int argc, char *argv[])
+{
+ KCmdLineArgs::init( argc, argv, "kmimefromext", "A mimetype testing tool, gives the mimetype for a given filename", "0.0" );
+
+ KCmdLineArgs::addCmdLineOptions( options );
+
+ KApplication app;
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+ QString fileName = args->arg( 0 );
+
+ // The "true" here means only the filename will be looked at.
+ // "Mime-magic" will not interfer. The file doesn't exist.
+ // TODO: a cmd line parameter for controlling this bool ;)
+ KMimeType::Ptr mime = KMimeType::findByPath( fileName, 0, true );
+ if ( mime && mime->name() != KMimeType::defaultMimeType() )
+ printf( "%s\n", mime->name().latin1());
+ else
+ return 1; // error
+
+ return 0;
+}
diff --git a/kio/tests/kmimemagictest.cpp b/kio/tests/kmimemagictest.cpp
new file mode 100644
index 000000000..9f3f5bb2b
--- /dev/null
+++ b/kio/tests/kmimemagictest.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2002 David Faure <faure@kde.org>
+ * Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kmimetype.h>
+#include <kmimemagic.h>
+#include <kinstance.h>
+#include <stdio.h>
+
+int main( int argc, char** argv )
+{
+ if (argc != 2)
+ {
+ printf("\n"
+ "Usage : ./kmimemagictest file\n");
+ return 1;
+ }
+ KInstance blah("kmimemagictest");
+
+ QString file = QString::fromLocal8Bit( argv[1] );
+
+ KMimeMagicResult * result = KMimeMagic::self()->findFileType( file );
+
+ if ( result->isValid() )
+ printf( "Found %s, accuracy %d\n", result->mimeType().latin1(), result->accuracy() );
+ else
+ printf( "Invalid result\n");
+
+ KMimeType::Format f = KMimeType::findFormatByFileContent( file );
+ if (f.text)
+ printf("Text\n");
+ else
+ printf("Binary\n");
+
+ if (f.compression == KMimeType::Format::GZipCompression)
+ printf("GZipped\n");
+
+ return 0;
+}
diff --git a/kio/tests/kmimetypetest.cpp b/kio/tests/kmimetypetest.cpp
new file mode 100644
index 000000000..b95f1ceea
--- /dev/null
+++ b/kio/tests/kmimetypetest.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2005 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kmimetype.h>
+#include <kinstance.h>
+#include <ktempdir.h>
+#include <kprotocolinfo.h>
+#include <qdir.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static void checkIcon( const KURL& url, const QString& expectedIcon )
+{
+ QString icon = KMimeType::iconForURL( url );
+ if ( icon == expectedIcon )
+ qDebug( "icon for %s is %s, OK", url.prettyURL().latin1(), icon.latin1() );
+ else {
+ qDebug( "ERROR: icon for %s is %s, expected %s!", url.prettyURL().latin1(), icon.latin1(), expectedIcon.latin1() );
+ exit(1);
+ }
+}
+
+int main( int argc, char** argv )
+{
+ KInstance blah("kmimetypetest");
+
+ // Obviously those tests will need to be fixed if we ever change the name of the icons
+ // but at least they unit-test KMimeType::iconForURL.
+ KURL url;
+
+ // safely check a "regular" folder
+ url.setPath( QDir::homeDirPath() );
+ checkIcon( url, "folder" );
+
+ // safely check a non-readable folder
+ if (0 != geteuid()) { // can't do this test if we're root
+ KTempDir tmp( QString::null, 0 );
+ tmp.setAutoDelete( true );
+ url.setPath( tmp.name() );
+ checkIcon( url, "folder_locked" );
+ chmod( QFile::encodeName( tmp.name() ), 0500 ); // so we can 'rm -rf' it
+ }
+
+ // safely check the trash folder
+ if ( KProtocolInfo::isKnownProtocol( QString("trash") ) ) {
+ checkIcon( "trash:/", "trashcan_full" ); // #100321
+ checkIcon( "trash:/foo/", "folder" );
+ }
+
+ QString pdf;
+ KMimeType::diagnoseFileName("foo.pdf", pdf);
+ qDebug("extension: '%s'", pdf.latin1());
+ assert(pdf == QString("*.pdf"));
+ QString ps;
+ KMimeType::diagnoseFileName("foo.ps", ps);
+ qDebug("extension: '%s'", ps.latin1());
+ assert(ps == QString("*.ps"));
+
+ return 0;
+}
diff --git a/kio/tests/kpropsdlgtest.cpp b/kio/tests/kpropsdlgtest.cpp
new file mode 100644
index 000000000..5f9e6ae3b
--- /dev/null
+++ b/kio/tests/kpropsdlgtest.cpp
@@ -0,0 +1,35 @@
+#include <kapplication.h>
+#include <klocale.h>
+#include <kaboutdata.h>
+#include <kpropertiesdialog.h>
+#include <kcmdlineargs.h>
+
+
+static KCmdLineOptions options[] =
+{
+ { "+url", "the path or url to the file/dir for which to show properties", 0 },
+ KCmdLineLastOption
+};
+
+int main ( int argc, char** argv )
+{
+ KAboutData aboutData("kpropertiesdialogtest", "KIO Properties Dialog Test", "1.0");
+ KCmdLineArgs::init(argc, argv, &aboutData);
+ KCmdLineArgs::addCmdLineOptions( options );
+
+ KApplication app;
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+ if ( args->count() < 1 )
+ KCmdLineArgs::usage();
+ KURL u = args->url( 0 );
+
+ // This is the test for the KPropertiesDialog constructor that is now
+ // documented to NOT work. Passing only a URL means a KIO::stat will happen,
+ // and asking for the dialog to be modal too creates problems.
+ // (A non-modal, URL-only dialog is the one kicker uses for app buttons, no problem there)
+ KPropertiesDialog* dlg = new KPropertiesDialog( u, 0, 0, true /*modal*/, false /*we do exec ourselves*/ );
+ dlg->exec();
+
+ return 0;
+}
diff --git a/kio/tests/kprotocolinfotest.cpp b/kio/tests/kprotocolinfotest.cpp
new file mode 100644
index 000000000..64ec617f6
--- /dev/null
+++ b/kio/tests/kprotocolinfotest.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2002 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kprotocolinfo.h>
+#include <kprotocolmanager.h>
+#include <kapplication.h>
+#include <kglobalsettings.h>
+#include <kcmdlineargs.h>
+#include <kaboutdata.h>
+#include <kdebug.h>
+#include <assert.h>
+
+int main(int argc, char **argv) {
+ KAboutData aboutData("kprotocolinfotest", "KProtocolinfo Test",
+ "1.0");
+
+ KCmdLineArgs::init(argc, argv, &aboutData);
+ KApplication app;
+
+ KURL url;
+ url.setPath("/tmp");
+ assert( KProtocolInfo::supportsListing( KURL( "ftp://10.1.1.10") ) );
+ assert( KProtocolInfo::inputType(url) == KProtocolInfo::T_NONE );
+ assert( KProtocolInfo::outputType(url) == KProtocolInfo::T_FILESYSTEM );
+ assert( KProtocolInfo::supportsReading(url) == true );
+ KProtocolInfo::ExtraFieldList extraFields = KProtocolInfo::extraFields(url);
+ KProtocolInfo::ExtraFieldList::Iterator extraFieldsIt = extraFields.begin();
+ for ( ; extraFieldsIt != extraFields.end() ; ++extraFieldsIt )
+ kdDebug() << (*extraFieldsIt).name << " " << (*extraFieldsIt).type << endl;
+
+ assert( KProtocolInfo::showFilePreview( "file" ) == true );
+ assert( KProtocolInfo::showFilePreview( "audiocd" ) == false );
+ assert( KGlobalSettings::showFilePreview( "audiocd:/" ) == false );
+
+ QString proxy;
+ QString protocol = KProtocolManager::slaveProtocol( "http://bugs.kde.org", proxy );
+ assert( protocol == "http" );
+
+ QStringList capabilities = KProtocolInfo::capabilities( "imap" );
+ kdDebug() << "kio_imap capabilities: " << capabilities << endl;
+ //assert(capabilities.contains("ACL"));
+
+ return 0;
+}
diff --git a/kio/tests/kruntest.cpp b/kio/tests/kruntest.cpp
new file mode 100644
index 000000000..92c0a3af3
--- /dev/null
+++ b/kio/tests/kruntest.cpp
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2002 David Faure <faure@kde.org>
+ * Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// ------ this test works only if your terminal application is set to "x-term" ------
+
+#include "kruntest.h"
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kshell.h>
+#include <kservice.h>
+#include <kde_file.h>
+
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qdir.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+const int MAXKRUNS = 100;
+
+testKRun * myArray[MAXKRUNS];
+
+void testKRun::foundMimeType( const QString& _type )
+{
+ kdDebug() << "testKRun::foundMimeType " << _type << endl;
+ kdDebug() << "testKRun::foundMimeType URL=" << m_strURL.url() << endl;
+ m_bFinished = true;
+ m_timer.start( 0, true );
+ return;
+}
+
+Receiver::Receiver()
+{
+ QVBoxLayout *lay = new QVBoxLayout(this);
+ lay->setAutoAdd(true);
+ QPushButton * h = new QPushButton( "Press here to terminate", this );
+ start = new QPushButton( "Launch KRuns", this );
+ stop = new QPushButton( "Stop those KRuns", this );
+ stop->setEnabled(false);
+ QObject::connect( h, SIGNAL(clicked()), kapp, SLOT(quit()) );
+ QObject::connect( start, SIGNAL(clicked()), this, SLOT(slotStart()) );
+ QObject::connect( stop, SIGNAL(clicked()), this, SLOT(slotStop()) );
+
+ adjustSize();
+ show();
+}
+
+void Receiver::slotStop()
+{
+ for (int i = 0 ; i < MAXKRUNS ; i++ )
+ {
+ kdDebug() << " deleting krun " << i << endl;
+ delete myArray[i];
+ }
+ start->setEnabled(true);
+ stop->setEnabled(false);
+}
+
+
+void Receiver::slotStart()
+{
+ for (int i = 0 ; i < MAXKRUNS ; i++ )
+ {
+ kdDebug() << "creating testKRun " << i << endl;
+ myArray[i] = new testKRun( KURL("file:/tmp"), 0, true, false /* no autodelete */ );
+ }
+ start->setEnabled(false);
+ stop->setEnabled(true);
+}
+
+void check(QString txt, QString a, QString b)
+{
+ if (a.isEmpty())
+ a = QString::null;
+ if (b.isEmpty())
+ b = QString::null;
+ if (a == b)
+ kdDebug() << txt << " : '" << a << "' - ok" << endl;
+ else {
+ kdDebug() << txt << " : '" << a << "' but expected '" << b << "' - KO!" << endl;
+ exit(1);
+ }
+}
+
+const char *bt(bool tr) { return tr?"true":"false"; }
+
+void checkBN(QString a, bool tr, QString b)
+{
+ check( QString().sprintf("binaryName('%s', %s)", a.latin1(), bt(tr)), KRun::binaryName(a, tr), b);
+}
+
+void checkPDE(const KService &service, const KURL::List &urls, bool hs, bool tf, QString b)
+{
+ check(
+ QString().sprintf("processDesktopExec( "
+ "service = {\nexec = %s\nterminal = %s, terminalOptions = %s\nsubstituteUid = %s, user = %s },"
+ "\nURLs = { %s },\nhas_shell = %s, temp_files = %s )",
+ service.exec().latin1(), bt(service.terminal()), service.terminalOptions().latin1(), bt(service.substituteUid()), service.username().latin1(),
+ KShell::joinArgs(urls.toStringList()).latin1(), bt(hs), bt(tf)),
+ KShell::joinArgs(KRun::processDesktopExec(service,urls,hs,tf)), b);
+}
+
+int main(int argc, char **argv)
+{
+ KApplication app( argc, argv, "kruntest", true /* it _has_ a GUI ! */);
+
+ // First some non-interactive tests
+ checkBN( "/usr/bin/ls", true, "ls");
+ checkBN( "/usr/bin/ls", false, "/usr/bin/ls");
+ checkBN( "/path/to/wine \"long argument with path\"", true, "wine" );
+ checkBN( "/path/with/a/sp\\ ace/exe arg1 arg2", true, "exe" );
+ checkBN( "\"progname\" \"arg1\"", true, "progname" );
+ checkBN( "'quoted' \"arg1\"", true, "quoted" );
+ checkBN( " 'leading space' arg1", true, "leading space" );
+
+ KURL::List l0;
+ KURL::List l1; l1 << "file:/tmp";
+ KURL::List l2; l2 << "http://localhost/foo";
+ KURL::List l3; l3 << "file:/local/file" << "http://remotehost.org/bar";
+
+ static const char
+ *execs[] = { "Exec=date -u", "Exec=echo $$PWD" },
+ *terms[] = { "Terminal=false", "Terminal=true\nTerminalOptions=-T \"%f - %c\"" },
+ *sus[] = { "X-KDE-SubstituteUID=false", "X-KDE-SubstituteUID=true\nX-KDE-Username=sprallo" },
+ *rslts[] = {
+"'date' '-u'", // 0
+"'/bin/sh' '-c' 'echo $PWD '", // 1
+"'x-term' '-T' ' - just_a_test' '-e' 'date' '-u'", // 2
+"'x-term' '-T' ' - just_a_test' '-e' '/bin/sh' '-c' 'echo $PWD '", // 3
+"'kdesu' '-u' 'sprallo' '-c' 'date -u '", // 4
+"'kdesu' '-u' 'sprallo' '-c' '/bin/sh -c '\\''echo $PWD '\\'''", // 5
+"'x-term' '-T' ' - just_a_test' '-e' 'su' 'sprallo' '-c' 'date -u '", // 6
+"'x-term' '-T' ' - just_a_test' '-e' 'su' 'sprallo' '-c' '/bin/sh -c '\\''echo $PWD '\\'''", // 7
+"'date -u '", // 8
+"'echo $PWD '", // 9
+"'x-term -T \" - just_a_test\"' '-e' 'date -u '", // a
+"'x-term -T \" - just_a_test\"' '-e' '/bin/sh -c '\\''echo $PWD '\\'''", // b
+"'kdesu' '-u' 'sprallo' '-c' ''\\''date -u '\\'''", // c
+"'kdesu' '-u' 'sprallo' '-c' ''\\''/bin/sh -c '\\''\\'\\'''\\''echo $PWD '\\''\\'\\'''\\'''\\'''", // d
+"'x-term -T \" - just_a_test\"' '-e' 'su' 'sprallo' '-c' ''\\''date -u '\\'''", // e
+"'x-term -T \" - just_a_test\"' '-e' 'su' 'sprallo' '-c' ''\\''/bin/sh -c '\\''\\'\\'''\\''echo $PWD '\\''\\'\\'''\\'''\\'''", // f
+ };
+ for (int hs = 0; hs < 2; hs++)
+ for (int su = 0; su < 2; su++)
+ for (int te = 0; te < 2; te++)
+ for (int ex = 0; ex < 2; ex++) {
+ int fd = creat("kruntest.desktop", 0666);
+ FILE *f;
+ if (fd < 0) abort();
+ f = KDE_fdopen(fd, "w");
+ fprintf(f, "[Desktop Entry]\n"
+ "Type=Application\n"
+ "Name=just_a_test\n"
+ "Icon=~/icon.png\n"
+ "%s\n%s\n%s\n",execs[ex],terms[te],sus[su]);
+ close(fd);
+ fclose(f);
+ KService s(QDir::currentDirPath() + "/kruntest.desktop");
+ unlink("kruntest.desktop");
+ checkPDE( s, l0, hs, false, rslts[ex+te*2+su*4+hs*8]);
+ }
+
+ KService s1("dummy", "kate %U", "app");
+ checkPDE( s1, l0, false, false, "'kate'");
+ checkPDE( s1, l1, false, false, "'kate' '/tmp'");
+ checkPDE( s1, l2, false, false, "'kate' 'http://localhost/foo'");
+ checkPDE( s1, l3, false, false, "'kate' '/local/file' 'http://remotehost.org/bar'");
+ KService s2("dummy", "kate %u", "app");
+ checkPDE( s2, l0, false, false, "'kate'");
+ checkPDE( s2, l1, false, false, "'kate' '/tmp'");
+ checkPDE( s2, l2, false, false, "'kate' 'http://localhost/foo'");
+ checkPDE( s2, l3, false, false, "'kate'");
+ KService s3("dummy", "kate %F", "app");
+ checkPDE( s3, l0, false, false, "'kate'");
+ checkPDE( s3, l1, false, false, "'kate' '/tmp'");
+ checkPDE( s3, l2, false, false, "'kfmexec' 'kate %F' 'http://localhost/foo'");
+ checkPDE( s3, l3, false, false, "'kfmexec' 'kate %F' 'file:/local/file' 'http://remotehost.org/bar'");
+
+ checkPDE( s3, l1, false, true, "'kfmexec' '--tempfiles' 'kate %F' 'file:/tmp'");
+ checkPDE( s3, l1, true, true, "''\\''kfmexec'\\'' '\\''--tempfiles'\\'' '\\''kate %F'\\'' '\\''file:/tmp'\\'''");
+
+ KService s4("dummy", "sh -c \"kate \"'\\\"'\"%F\"'\\\"'", "app");
+ checkPDE( s4, l1, false, false, "'kate' '\"/tmp\"'");
+
+ Receiver receiver;
+ app.setMainWidget(&receiver);
+ return app.exec();
+}
+
+#include "kruntest.moc"
diff --git a/kio/tests/kruntest.h b/kio/tests/kruntest.h
new file mode 100644
index 000000000..e1bb92729
--- /dev/null
+++ b/kio/tests/kruntest.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2002 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _kruntest_h
+#define _kruntest_h
+
+#include <krun.h>
+
+#include <qwidget.h>
+
+class testKRun : public KRun
+{
+ Q_OBJECT
+public:
+
+ testKRun( const KURL& _url, mode_t _mode = 0,
+ bool _is_local_file = false, bool _auto_delete = true )
+ : KRun( _url, _mode, _is_local_file, _auto_delete ) {}
+
+ virtual ~testKRun() {}
+
+ virtual void foundMimeType( const QString& _type );
+
+};
+
+
+class QPushButton;
+class Receiver : public QWidget
+{
+ Q_OBJECT
+public:
+ Receiver();
+ ~Receiver() {}
+public slots:
+ void slotStart();
+ void slotStop();
+private:
+ QPushButton * start;
+ QPushButton * stop;
+
+};
+
+#endif
diff --git a/kio/tests/kscantest.cpp b/kio/tests/kscantest.cpp
new file mode 100644
index 000000000..9bc9d2ebc
--- /dev/null
+++ b/kio/tests/kscantest.cpp
@@ -0,0 +1,16 @@
+#include <kapplication.h>
+#include <kscan.h>
+
+int main( int argc, char **argv )
+{
+ KApplication app( argc, argv, "kscantest" );
+ KScanDialog *dlg = KScanDialog::getScanDialog();
+ if ( !dlg ) {
+ qDebug("*** EEK, no Scan-service available, aborting!");
+ return 0;
+ }
+
+ dlg->show();
+
+ return app.exec();
+}
diff --git a/kio/tests/kshredtest.cpp b/kio/tests/kshredtest.cpp
new file mode 100644
index 000000000..3bd7ae189
--- /dev/null
+++ b/kio/tests/kshredtest.cpp
@@ -0,0 +1,74 @@
+/*--------------------------------------------------------------------------*
+ KShred.h Copyright (c) 2000 MieTerra LLC.
+ Credits: Andreas F. Pour <bugs@mieterra.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include "kshred.h"
+#include <qstring.h>
+
+int main(int argc, char **argv)
+
+{
+ if (argc < 3)
+ {
+ fprintf(stderr, "Error, usage is '%s FILE MODE'\n", argv[0]);
+ exit(-1);
+ }
+
+ //if (!shred(argv[1]))
+ //printf("ERROR shredding %s\n", argv[1]);
+ //exit(1);
+
+ KShred::shred(argv[1]);
+ printf("Done\n");
+ exit(1);
+
+ KShred *shredder = new KShred(argv[1]);
+
+ switch (argv[2][0])
+ {
+ case '0':
+ if (!shredder->fill0s())
+ fprintf(stderr, "ERROR in filling 0s\n");
+ break;
+ case '1':
+ if (!shredder->fill1s())
+ fprintf(stderr, "ERROR in filling 1s\n");
+ break;
+ case 'r':
+ if (!shredder->fillrandom())
+ fprintf(stderr, "ERROR in filling random\n");
+ break;
+ case 'b':
+ if (!shredder->fillbyte((uint) argv[2][1]))
+ fprintf(stderr, "ERROR in filling byte '%c'\n", argv[2][1]);
+ break;
+ case 's':
+ if (!shredder->shred())
+ fprintf(stderr, "ERROR in shredding\n");
+ break;
+ default:
+ if (!shredder->fillpattern((unsigned char*)(argv[2]), strlen(argv[2])))
+ fprintf(stderr, "ERROR in filling with pattern '%s'\n", argv[2]);
+ break;
+ }
+ fprintf(stdout, "Done\n");
+ return 0;
+}
diff --git a/kio/tests/ksycocatest.cpp b/kio/tests/ksycocatest.cpp
new file mode 100644
index 000000000..fe2c22d94
--- /dev/null
+++ b/kio/tests/ksycocatest.cpp
@@ -0,0 +1,360 @@
+/*
+ * Copyright (C) 2002, 2003 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kdebug.h>
+#include <kuserprofile.h>
+#include <ktrader.h>
+#include <kservice.h>
+#include <kmimetype.h>
+#include <assert.h>
+#include <kstandarddirs.h>
+#include <kservicegroup.h>
+#include <kimageio.h>
+#include <kprotocolinfo.h>
+#include <kiconloader.h>
+
+#include <kapplication.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+bool check(QString txt, QString a, QString b)
+{
+ if (a.isEmpty())
+ a = QString::null;
+ if (b.isEmpty())
+ b = QString::null;
+ if (a == b) {
+ kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl;
+ }
+ else {
+ kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl
+;
+ exit(1);
+ }
+ return true;
+}
+
+void debug(QString txt)
+{
+ fprintf(stderr, "%s\n", txt.ascii());
+}
+
+void debug(const char *txt)
+{
+ fprintf(stderr, "%s\n", txt);
+}
+void debug(const char *format, const char *txt)
+{
+ fprintf(stderr, format, txt);
+ fprintf(stderr, "\n");
+}
+
+int main(int argc, char *argv[])
+{
+ KApplication k(argc,argv,"whatever",false/*noGUI*/); // KMessageBox needs KApp for makeStdCaption
+
+ QCString instname = "kword";
+ QString desktopPath = QString::fromLatin1( "Office/%1.desktop" ).arg( instname );
+ qDebug( "Looking for %s", desktopPath.latin1() );
+ KService::Ptr service = KService::serviceByDesktopPath( desktopPath );
+ if ( service )
+ qDebug( "found: %s", service->desktopEntryPath().latin1() );
+ else
+ qDebug( "not found" );
+
+ qDebug( "Looking for desktop name = %s", instname.data() );
+ service = KService::serviceByDesktopName( instname );
+ if ( service )
+ qDebug( "found: %s", service->desktopEntryPath().latin1() );
+ else
+ qDebug( "not found" );
+
+ debug("Trying to look for text/plain");
+ KMimeType::Ptr s1 = KMimeType::mimeType("text/plain");
+ if ( s1 )
+ {
+ debug("Found it !");
+ debug(QString("Comment is %1").arg(s1->comment(KURL(),false)));
+ }
+ else
+ {
+ debug("Not found !");
+ exit(1);
+ }
+
+ debug("Trying to look for application/x-zerosize");
+ KMimeType::Ptr s0 = KMimeType::mimeType("application/x-zerosize");
+ if ( s0 )
+ {
+ debug("Found it !");
+ debug(QString("Comment is %1").arg(s0->comment(KURL(),false)));
+ }
+ else
+ {
+ debug("Not found !");
+ exit(1);
+ }
+
+ debug("Trying to look for Desktop Pager");
+ KService::Ptr se = KService::serviceByName("Desktop Pager");
+ if ( se )
+ {
+ debug("Found it !");
+ debug(QString("Comment is %1").arg(se->comment()));
+ }
+ else
+ {
+ debug("Not found !");
+ }
+
+ debug("Trying to look for kpager");
+ se = KService::serviceByDesktopName("kpager");
+ if ( se )
+ {
+ debug("Found it !");
+ debug(QString("Comment is %1").arg(se->comment()));
+ QVariant qv = se->property("DocPath");
+ debug(QString("Property type is %1").arg(qv.typeName()));
+ debug(QString("Property value is %1").arg(qv.toString()));
+ }
+ else
+ {
+ debug("Not found !");
+ }
+
+ debug("Trying to look for System/kpager.desktop");
+ se = KService::serviceByDesktopPath("System/kpager.desktop");
+ if ( se )
+ {
+ debug("Found it !");
+ debug(QString("Comment is %1").arg(se->comment()));
+ }
+ else
+ {
+ debug("Not found !");
+ }
+
+ debug("Trying to look for System/fake-entry.desktop");
+ se = KService::serviceByDesktopPath("System/fake-entry.desktop");
+ if ( se )
+ {
+ debug("Found it !");
+ debug(QString("Comment is %1").arg(se->comment()));
+ }
+ else
+ {
+ debug("Not found !");
+ }
+
+#if 1
+ debug("Querying userprofile for services associated with text/plain");
+ KServiceTypeProfile::OfferList offers = KServiceTypeProfile::offers("text/plain");
+ debug(QString("got %1 offers").arg(offers.count()));
+ KServiceTypeProfile::OfferList::Iterator it = offers.begin();
+ for ( ; it != offers.end() ; it++ )
+ {
+ debug((*it).service()->name());
+ }
+
+ debug("Querying userprofile for services associated with KOfficeFilter");
+ offers = KServiceTypeProfile::offers("KOfficeFilter");
+ debug(QString("got %1 offers").arg(offers.count()));
+ it = offers.begin();
+ for ( ; it != offers.end() ; it++ )
+ {
+ debug((*it).service()->name());
+ }
+
+ debug("Querying trader for Konqueror/Plugin");
+ KTrader::OfferList traderoffers = KTrader::self()->query("Konqueror/Plugin");
+ debug(QString("got %1 offers").arg(traderoffers.count()));
+ KTrader::OfferList::Iterator trit = traderoffers.begin();
+ for ( ; trit != traderoffers.end() ; trit++ )
+ {
+ debug((*trit)->name());
+ }
+#endif
+
+
+ //
+ debug("\nTrying findByURL for $KDEDIR/bin/kdesktop");
+ KMimeType::Ptr mf = KMimeType::findByURL( KStandardDirs::findExe( "kdesktop" ), 0,
+ true, false );
+ assert( mf );
+ check( "A binary's mimetype", mf->name(), "application/x-executable" );
+
+ //
+ debug("\nTrying findByURL for folder_home.png");
+ QString fh;
+ (void)k.iconLoader()->loadIcon("folder_home.png",KIcon::Desktop,0,KIcon::DefaultState,&fh);
+ mf = KMimeType::findByURL( fh, 0, true, false );
+ assert( mf );
+ check( "A PNG's mimetype", mf->name(), "image/png" );
+
+ //
+ //debug("\nTrying findByURL for Makefile.am");
+ //mf = KMimeType::findByURL( KURL("/tmp/Makefile.am"), 0, true, false );
+ //assert( mf );
+ //debug(QString("Name is %1").arg(mf->name()));
+ //debug(QString("Comment is %1").arg(mf->comment(KURL(),false)));
+
+ debug("\nTrying findByURL for man:/ls");
+ mf = KMimeType::findByURL( KURL("man:/ls") );
+ assert( mf );
+ check( "man:/ls", mf->name(), "text/html" );
+ check( "man:/ls/", mf->name(), "text/html" );
+
+ mf = KMimeType::findByURL( KURL("http://foo/bar.png") );
+ check( "HTTP URL", mf->name(), "application/octet-stream" ); // HTTP can't know before downloading
+
+#if 1
+ KMimeType::List mtl;
+
+ mtl = KMimeType::allMimeTypes( );
+ assert( mtl.count() );
+ debug(QString("Found %1 mime types.").arg(mtl.count()));
+ for(int i = 0; i < (int)mtl.count(); i++)
+ {
+ debug(QString("Mime type %1: %2.").arg(i).arg(mtl[i]->name()));
+ }
+
+ KService::List sl;
+
+ sl = KService::allServices( );
+ assert( sl.count() );
+ debug(QString("Found %1 services.").arg(sl.count()));
+
+ KServiceGroup::Ptr root = KServiceGroup::root();
+ KServiceGroup::List list = root->entries();
+ //KServiceGroup::Ptr topGroup = KServiceGroup::childGroup( "kview" );
+ //Q_ASSERT( topGroup );
+ //KServiceGroup::List list = topGroup->entries();
+
+ KServiceGroup::Ptr first;
+
+ debug(QString("Found %1 entries").arg(list.count()));
+ for( KServiceGroup::List::ConstIterator it = list.begin();
+ it != list.end(); it++)
+ {
+ KSycocaEntry *p = (*it);
+ if (p->isType(KST_KService))
+ {
+ KService *service = static_cast<KService *>(p);
+ debug(service->name());
+ debug(service->desktopEntryPath());
+ }
+ else if (p->isType(KST_KServiceGroup))
+ {
+ KServiceGroup *serviceGroup = static_cast<KServiceGroup *>(p);
+ debug(QString(" %1 -->").arg(serviceGroup->caption()));
+ if (!first) first = serviceGroup;
+ }
+ else
+ {
+ debug("KServiceGroup: Unexpected object in list!");
+ }
+ }
+
+ if (first)
+ {
+ list = first->entries();
+ debug(QString("Found %1 entries").arg(list.count()));
+ for( KServiceGroup::List::ConstIterator it = list.begin();
+ it != list.end(); it++)
+ {
+ KSycocaEntry *p = (*it);
+ if (p->isType(KST_KService))
+ {
+ KService *service = static_cast<KService *>(p);
+ debug(QString(" %1").arg(service->name()));
+ }
+ else if (p->isType(KST_KServiceGroup))
+ {
+ KServiceGroup *serviceGroup = static_cast<KServiceGroup *>(p);
+ debug(QString(" %1 -->").arg(serviceGroup->caption()));
+ }
+ else
+ {
+ debug("KServiceGroup: Unexpected object in list!");
+ }
+ }
+ }
+
+ debug("--services that require initialisation--");
+ sl = KService::allInitServices();
+ for( KService::List::ConstIterator it = sl.begin();
+ it != sl.end(); it++)
+ {
+ KService *service = static_cast<KService *>(*it);
+ debug(service->name());
+ }
+ debug("--End of list--");
+
+ debug("--protocols--");
+ QStringList stringL = KProtocolInfo::protocols();
+ for( QStringList::ConstIterator it = stringL.begin();
+ it != stringL.end(); it++)
+ {
+ debug((*it).ascii());
+ }
+ debug("--End of list--");
+#endif
+
+#if 0
+ KImageIO::registerFormats();
+
+ QStringList types;
+ types = KImageIO::types(KImageIO::Reading);
+ debug("Can read:");
+ for(QStringList::ConstIterator it = types.begin();
+ it != types.end(); ++it)
+ debug(QString(" %1").arg((*it)));
+
+ types = KImageIO::types(KImageIO::Writing);
+ debug("Can write:");
+ for(QStringList::ConstIterator it = types.begin();
+ it != types.end(); ++it)
+ debug(QString(" %1").arg((*it)));
+
+
+ QString rPattern = KImageIO::pattern( KImageIO::Reading );
+ debug("Read pattern:\n%s", rPattern.ascii());
+
+ QString wPattern = KImageIO::pattern( KImageIO::Writing );
+ debug("Write pattern:\n%s", wPattern.ascii());
+
+ QString suffix = KImageIO::suffix("JPEG");
+ debug("Standard suffix for JPEG: %s", suffix.ascii());
+
+ types = KImageIO::mimeTypes(KImageIO::Reading);
+ debug("Can read (mimetypes):");
+ for(QStringList::ConstIterator it = types.begin();
+ it != types.end(); ++it)
+ debug(" %s", (*it).ascii());
+
+ types = KImageIO::mimeTypes(KImageIO::Writing);
+ debug("Can write (mimetypes):");
+ for(QStringList::ConstIterator it = types.begin();
+ it != types.end(); ++it)
+ debug(" %s", (*it).ascii());
+
+ debug("done");
+#endif
+ return 0;
+}
diff --git a/kio/tests/ksycocaupdatetest.cpp b/kio/tests/ksycocaupdatetest.cpp
new file mode 100644
index 000000000..1d9e3fcaa
--- /dev/null
+++ b/kio/tests/ksycocaupdatetest.cpp
@@ -0,0 +1,11 @@
+#include <kservice.h>
+
+#include <kapplication.h>
+
+int main(int argc, char *argv[])
+{
+ KApplication k(argc,argv,"whatever"); // KMessageBox needs KApp for makeStdCaption
+
+ KService::rebuildKSycoca(0);
+ return 0;
+}
diff --git a/kio/tests/ktartest.cpp b/kio/tests/ktartest.cpp
new file mode 100644
index 000000000..055d016a7
--- /dev/null
+++ b/kio/tests/ktartest.cpp
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2002, 2003 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "ktar.h"
+#include <stdio.h>
+#include <kinstance.h>
+#include <qfile.h>
+
+#include <assert.h>
+
+void recursive_print( const KTarDirectory * dir, const QString & path )
+{
+ QStringList l = dir->entries();
+ QStringList::Iterator it = l.begin();
+ for( ; it != l.end(); ++it )
+ {
+ const KTarEntry* entry = dir->entry( (*it) );
+ printf("mode=%07o %s %s %s%s %d isdir=%d\n", entry->permissions(), entry->user().latin1(), entry->group().latin1(), path.latin1(), (*it).latin1(),
+ entry->isFile() ? static_cast<const KArchiveFile *>(entry)->size() : 0,
+ entry->isDirectory());
+ if (entry->isDirectory())
+ recursive_print( (KTarDirectory *)entry, path+(*it)+"/" );
+ }
+}
+
+int main( int argc, char** argv )
+{
+ if (argc != 3)
+ {
+ printf("\n"
+ " Usage :\n"
+ " ./ktartest list /path/to/existing_file.tar.gz tests listing an existing tar.gz\n"
+ " ./ktartest readwrite newfile.tar.gz will create the tar.gz, then close and reopen it.\n"
+ " ./ktartest maxlength newfile.tar.gz tests the maximum filename length allowed.\n"
+ " ./ktartest iodevice /path/to/existing_file.tar.gz tests KArchiveFile::device()\n");
+ return 1;
+ }
+ KInstance instance("ktartest");
+ QString command = argv[1];
+ if ( command == "list" )
+ {
+ KTarGz tar( argv[2] );
+
+ if ( !tar.open( IO_ReadOnly ) )
+ {
+ printf("Could not open %s for reading\n", argv[2] );
+ return 1;
+ }
+
+ const KTarDirectory* dir = tar.directory();
+
+ //printf("calling recursive_print\n");
+ recursive_print( dir, "" );
+ //printf("recursive_print called\n");
+
+ tar.close();
+
+ return 0;
+ }
+ else if (command == "readwrite" )
+ {
+ KTarGz tar( argv[2] );
+
+ if ( !tar.open( IO_WriteOnly ) )
+ {
+ printf("Could not open %s for writing\n", argv[1]);
+ return 1;
+ }
+
+ tar.writeFile( "empty", "weis", "users", 0, "" );
+ tar.writeFile( "test1", "weis", "users", 5, "Hallo" );
+ tar.writeFile( "test2", "weis", "users", 8, "Hallo Du" );
+ tar.writeFile( "mydir/test3", "weis", "users", 13, "Noch so einer" );
+ tar.writeFile( "my/dir/test3", "dfaure", "hackers", 29, "I don't speak German (David)" );
+
+#define SIZE1 100
+ // Now a medium file : 100 null bytes
+ char medium[ SIZE1 ];
+ memset( medium, 0, SIZE1 );
+ tar.writeFile( "mediumfile", "user", "group", SIZE1, medium );
+ // Another one, with an absolute path
+ tar.writeFile( "/dir/subdir/mediumfile2", "user", "group", SIZE1, medium );
+
+ // Now a huge file : 20000 null bytes
+ int n = 20000;
+ char * huge = new char[ n ];
+ memset( huge, 0, n );
+ tar.writeFile( "hugefile", "user", "group", n, huge );
+ delete [] huge;
+
+ tar.close();
+
+ printf("-----------------------\n");
+
+ if ( !tar.open( IO_ReadOnly ) )
+ {
+ printf("Could not open %s for reading\n", argv[1] );
+ return 1;
+ }
+
+ const KTarDirectory* dir = tar.directory();
+ recursive_print(dir, "");
+
+ const KTarEntry* e = dir->entry( "mydir/test3" );
+ Q_ASSERT( e && e->isFile() );
+ const KTarFile* f = (KTarFile*)e;
+
+ QByteArray arr( f->data() );
+ printf("SIZE=%i\n",arr.size() );
+ QString str( arr );
+ printf("DATA=%s\n", str.latin1());
+
+ tar.close();
+
+ return 0;
+ }
+ else if ( command == "maxlength" )
+ {
+ KTarGz tar( argv[2] );
+
+ if ( !tar.open( IO_WriteOnly ) )
+ {
+ printf("Could not open %s for writing\n", argv[1]);
+ return 1;
+ }
+ // Generate long filenames of each possible length bigger than 98...
+ // Also exceed 512 byte block size limit to see how well the ././@LongLink
+ // implementation fares
+ for (int i = 98; i < 514 ; i++ )
+ {
+ QString str, num;
+ str.fill( 'a', i-10 );
+ num.setNum( i );
+ num = num.rightJustify( 10, '0' );
+ tar.writeFile( str+num, "testu", "testg", 3, "hum" );
+ }
+ // Result of this test : works perfectly now (failed at 482 formerly and
+ // before that at 154).
+ tar.close();
+ printf("Now run 'tar tvzf %s'\n", argv[2]);
+ return 0;
+ }
+ else if ( command == "iodevice" )
+ {
+ KTarGz tar( argv[2] );
+ if ( !tar.open( IO_ReadOnly ) )
+ return 1;
+ const KTarDirectory* dir = tar.directory();
+ assert(dir);
+ const KTarEntry* entry = dir->entry( "my/dir/test3" );
+ if ( entry && entry->isFile() )
+ {
+ QIODevice *dev = static_cast<const KTarFile *>(entry)->device();
+ QByteArray contents = dev->readAll();
+ printf("contents='%s'\n", QCString(contents, contents.size()+1 ).data());
+ } else
+ printf("entry=%p - not found if 0, otherwise not a file\n", (void*)entry);
+ return 0;
+ }
+ else
+ printf("Unknown command\n");
+}
+
diff --git a/kio/tests/ktradertest.cpp b/kio/tests/ktradertest.cpp
new file mode 100644
index 000000000..28d3730d6
--- /dev/null
+++ b/kio/tests/ktradertest.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2002, 2003 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kcmdlineargs.h>
+#include <ktrader.h>
+#include <kmimetype.h>
+#include <kapplication.h>
+#include <stdio.h>
+
+static KCmdLineOptions options[] =
+{
+ { "+query", "the query", 0 },
+ { "+[genericServiceType]", "Application (default), or KParts/ReadOnlyPart", 0 },
+ { "+[constraint]", "constraint", 0 },
+ { "+[preference]", "preference", 0 },
+ KCmdLineLastOption
+};
+
+int main( int argc, char **argv )
+{
+ KCmdLineArgs::init( argc, argv, "ktradertest", "KTradertest", "A KTrader testing tool", "0.0" );
+
+ KCmdLineArgs::addCmdLineOptions( options );
+
+ KApplication app( false, false ); // no GUI
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ if ( args->count() < 1 )
+ KCmdLineArgs::usage();
+
+ QString query = QString::fromLocal8Bit( args->arg( 0 ) );
+
+ QString genericServiceType, constraint, preference;
+
+ if ( args->count() >= 2 )
+ genericServiceType = QString::fromLocal8Bit( args->arg( 1 ) );
+
+ if ( args->count() >= 3 )
+ constraint = QString::fromLocal8Bit( args->arg( 2 ) );
+
+ if ( args->count() == 4 )
+ preference = QString::fromLocal8Bit( args->arg( 3 ) );
+
+ printf( "query is : %s\n", query.local8Bit().data() );
+ printf( "genericServiceType is : %s\n", genericServiceType.local8Bit().data() );
+ printf( "constraint is : %s\n", constraint.local8Bit().data() );
+ printf( "preference is : %s\n", preference.local8Bit().data() );
+
+ KTrader::OfferList offers = KTrader::self()->query( query, genericServiceType, constraint, preference );
+
+ printf("got %d offers.\n", offers.count());
+
+ int i = 0;
+ KTrader::OfferList::ConstIterator it = offers.begin();
+ KTrader::OfferList::ConstIterator end = offers.end();
+ for (; it != end; ++it, ++i )
+ {
+ printf("---- Offer %d ----\n", i);
+ QStringList props = (*it)->propertyNames();
+ QStringList::ConstIterator propIt = props.begin();
+ QStringList::ConstIterator propEnd = props.end();
+ for (; propIt != propEnd; ++propIt )
+ {
+ QVariant prop = (*it)->property( *propIt );
+
+ if ( !prop.isValid() )
+ {
+ printf("Invalid property %s\n", (*propIt).local8Bit().data());
+ continue;
+ }
+
+ QString outp = *propIt;
+ outp += " : '";
+
+ switch ( prop.type() )
+ {
+ case QVariant::StringList:
+ outp += prop.toStringList().join(" - ");
+ break;
+ case QVariant::Bool:
+ outp += prop.toBool() ? "TRUE" : "FALSE";
+ break;
+ default:
+ outp += prop.toString();
+ break;
+ }
+
+ if ( !outp.isEmpty() )
+ printf("%s'\n", outp.local8Bit().data());
+ }
+ }
+}
diff --git a/kio/tests/kurifiltertest.cpp b/kio/tests/kurifiltertest.cpp
new file mode 100644
index 000000000..9a041e28f
--- /dev/null
+++ b/kio/tests/kurifiltertest.cpp
@@ -0,0 +1,361 @@
+/*
+ * Copyright (C) 2002, 2003 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "kurifilter.h"
+
+#include <config.h>
+#include <iostream>
+#include <stdlib.h>
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kcmdlineargs.h>
+#include <kstandarddirs.h>
+#include <ksimpleconfig.h>
+
+#include <qdir.h>
+#include <qregexp.h>
+#include <kio/netaccess.h>
+
+static const char * const s_uritypes[] = { "NET_PROTOCOL", "LOCAL_FILE", "LOCAL_DIR", "EXECUTABLE", "HELP", "SHELL", "BLOCKED", "ERROR", "UNKNOWN" };
+#define NO_FILTERING -2
+
+void filter( const char* u, const char * expectedResult = 0, int expectedUriType = -1, QStringList list = QStringList(), const char * abs_path = 0, bool checkForExecutables = true )
+{
+ QString a = QString::fromUtf8( u );
+ KURIFilterData * m_filterData = new KURIFilterData;
+ m_filterData->setData( a );
+ m_filterData->setCheckForExecutables( checkForExecutables );
+
+ if( abs_path )
+ {
+ m_filterData->setAbsolutePath( QString::fromLatin1( abs_path ) );
+ kdDebug() << "Filtering: " << a << " with abs_path=" << abs_path << endl;
+ }
+ else
+ kdDebug() << "Filtering: " << a << endl;
+
+ if (KURIFilter::self()->filterURI(*m_filterData, list))
+ {
+ // Copied from minicli...
+ QString cmd;
+ KURL uri = m_filterData->uri();
+
+ if ( uri.isLocalFile() && !uri.hasRef() && uri.query().isEmpty() )
+ cmd = uri.path();
+ else
+ cmd = uri.url();
+
+ switch( m_filterData->uriType() )
+ {
+ case KURIFilterData::LOCAL_FILE:
+ case KURIFilterData::LOCAL_DIR:
+ case KURIFilterData::HELP:
+ kdDebug() << "*** Result: Local Resource => '"
+ << m_filterData->uri().url() << "'" << endl;
+ break;
+ case KURIFilterData::NET_PROTOCOL:
+ kdDebug() << "*** Result: Network Resource => '"
+ << m_filterData->uri().url() << "'" << endl;
+ break;
+ case KURIFilterData::SHELL:
+ case KURIFilterData::EXECUTABLE:
+ if( m_filterData->hasArgsAndOptions() )
+ cmd += m_filterData->argsAndOptions();
+ kdDebug() << "*** Result: Executable/Shell => '" << cmd << "'"<< endl;
+ break;
+ case KURIFilterData::ERROR:
+ kdDebug() << "*** Result: Encountered error. See reason below." << endl;
+ break;
+ default:
+ kdDebug() << "*** Result: Unknown or invalid resource." << endl;
+ }
+
+ if ( expectedUriType != -1 && expectedUriType != m_filterData->uriType() )
+ {
+ kdError() << " Got URI type " << s_uritypes[m_filterData->uriType()]
+ << " expected " << s_uritypes[expectedUriType] << endl;
+ ::exit(1);
+ }
+
+ if ( expectedResult )
+ {
+ // Hack for other locales than english, normalize google hosts to google.com
+ cmd = cmd.replace( QRegExp( "www\\.google\\.[^/]*/" ), "www.google.com/" );
+ if ( cmd != QString::fromLatin1( expectedResult ) )
+ {
+ kdError() << " Got " << cmd << " expected " << expectedResult << endl;
+ ::exit(1);
+ }
+ }
+ }
+ else
+ {
+ if ( expectedUriType == NO_FILTERING )
+ kdDebug() << "*** No filtering required." << endl;
+ else
+ {
+ kdDebug() << "*** Could not be filtered." << endl;
+ if( expectedUriType != m_filterData->uriType() )
+ {
+ kdError() << " Got URI type " << s_uritypes[m_filterData->uriType()]
+ << " expected " << s_uritypes[expectedUriType] << endl;
+ ::exit(1);
+ }
+ }
+ }
+
+ delete m_filterData;
+ kdDebug() << "-----" << endl;
+}
+
+void testLocalFile( const QString& filename )
+{
+ QFile tmpFile( filename ); // Yeah, I know, security risk blah blah. This is a test prog!
+
+ if ( tmpFile.open( IO_ReadWrite ) )
+ {
+ QCString fname = QFile::encodeName( tmpFile.name() );
+ filter(fname, fname, KURIFilterData::LOCAL_FILE);
+ tmpFile.close();
+ tmpFile.remove();
+ }
+ else
+ kdDebug() << "Couldn't create " << tmpFile.name() << ", skipping test" << endl;
+}
+
+static const char appName[] = "kurifiltertest";
+static const char programName[] = I18N_NOOP("kurifiltertest");
+static const char description[] = I18N_NOOP("Unit test for the URI filter plugin framework.");
+static const char version[] = "1.5";
+
+static const KCmdLineOptions options[] =
+{
+ { "s", I18N_NOOP("Use space as keyword delimeter for web shortcuts"), 0},
+ KCmdLineLastOption
+};
+
+int main(int argc, char **argv)
+{
+ // Ensure that user configuration doesn't change the results of those tests
+ // KDEHOME needs to be writable though, for a ksycoca database
+ setenv( "KDEHOME", QFile::encodeName( QDir::homeDirPath() + "/.kde-kurifiltertest" ), true );
+ setenv( "KDE_FORK_SLAVES", "yes", true ); // simpler, for the final cleanup
+
+ KAboutData aboutData(appName, programName, version, description);
+ KCmdLineArgs::init(argc, argv, &aboutData);
+ KCmdLineArgs::addCmdLineOptions( options );
+
+ KApplication app;
+ app.disableAutoDcopRegistration();
+
+ // Allow testing of the search engine using both delimiters...
+ char delimiter = KCmdLineArgs::parsedArgs()->isSet("s") ? ' ' : ':';
+
+ // Many tests check the "default search engine" feature.
+ // There is no default search engine by default (since it was annoying when making typos),
+ // so the user has to set it up, which we do here.
+ {
+ KSimpleConfig cfg( "kuriikwsfilterrc" );
+ cfg.setGroup( "General" );
+ cfg.writeEntry( "DefaultSearchEngine", "google" );
+ cfg.writeEntry( "Verbose", true );
+ cfg.writeEntry( "KeywordDelimiter", delimiter );
+ cfg.sync();
+ }
+
+ // Enable verbosity for debugging
+ {
+ KSimpleConfig cfg( "kshorturifilterrc" );
+ cfg.writeEntry( "Verbose", true );
+ cfg.sync();
+ }
+
+ QStringList minicliFilters;
+ minicliFilters << "kshorturifilter" << "kurisearchfilter" << "localdomainurifilter";
+
+ // URI that should require no filtering
+ filter( "http://www.kde.org", "http://www.kde.org", KURIFilterData::NET_PROTOCOL );
+ filter( "http://www.kde.org/developer//index.html", "http://www.kde.org/developer//index.html", KURIFilterData::NET_PROTOCOL );
+ // URL with reference
+ filter( "http://www.kde.org/index.html#q8", "http://www.kde.org/index.html#q8", KURIFilterData::NET_PROTOCOL );
+ // local file with reference
+ filter( "file:/etc/passwd#q8", "file:///etc/passwd#q8", KURIFilterData::LOCAL_FILE );
+ filter( "file:///etc/passwd#q8", "file:///etc/passwd#q8", KURIFilterData::LOCAL_FILE );
+ filter( "/etc/passwd#q8", "file:///etc/passwd#q8", KURIFilterData::LOCAL_FILE );
+ // local file with query (can be used by javascript)
+ filter( "file:/etc/passwd?foo=bar", "file:///etc/passwd?foo=bar", KURIFilterData::LOCAL_FILE );
+ testLocalFile( "/tmp/kurifiltertest?foo" ); // local file with ? in the name (#58990)
+ testLocalFile( "/tmp/kurlfiltertest#foo" ); // local file with '#' in the name
+ testLocalFile( "/tmp/kurlfiltertest#foo?bar" ); // local file with both
+ testLocalFile( "/tmp/kurlfiltertest?foo#bar" ); // local file with both, the other way round
+
+ // hostnames are lowercased by KURL
+ filter( "http://www.myDomain.commyPort/ViewObjectRes//Default:name=hello",
+ "http://www.mydomain.commyport/ViewObjectRes//Default:name=hello", KURIFilterData::NET_PROTOCOL);
+ filter( "ftp://ftp.kde.org", "ftp://ftp.kde.org", KURIFilterData::NET_PROTOCOL );
+ filter( "ftp://username@ftp.kde.org:500", "ftp://username@ftp.kde.org:500", KURIFilterData::NET_PROTOCOL );
+
+ // ShortURI/LocalDomain filter tests. NOTE: any of these tests can fail
+ // if you have specified your own patterns in kshorturifilterrc. For
+ // examples, see $KDEDIR/share/config/kshorturifilterrc .
+ filter( "linuxtoday.com", "http://linuxtoday.com", KURIFilterData::NET_PROTOCOL );
+ filter( "LINUXTODAY.COM", "http://linuxtoday.com", KURIFilterData::NET_PROTOCOL );
+ filter( "kde.org", "http://kde.org", KURIFilterData::NET_PROTOCOL );
+ filter( "ftp.kde.org", "ftp://ftp.kde.org", KURIFilterData::NET_PROTOCOL );
+ filter( "ftp.kde.org:21", "ftp://ftp.kde.org:21", KURIFilterData::NET_PROTOCOL );
+ filter( "cr.yp.to", "http://cr.yp.to", KURIFilterData::NET_PROTOCOL );
+ filter( "user@192.168.1.0:3128", "http://user@192.168.1.0:3128", KURIFilterData::NET_PROTOCOL );
+ filter( "127.0.0.1", "http://127.0.0.1", KURIFilterData::NET_PROTOCOL );
+ filter( "127.0.0.1:3128", "http://127.0.0.1:3128", KURIFilterData::NET_PROTOCOL );
+ filter( "foo@bar.com", "mailto:foo@bar.com", KURIFilterData::NET_PROTOCOL );
+ filter( "firstname.lastname@x.foo.bar", "mailto:firstname.lastname@x.foo.bar", KURIFilterData::NET_PROTOCOL );
+ filter( "www.123.foo", "http://www.123.foo", KURIFilterData::NET_PROTOCOL );
+ filter( "user@www.123.foo:3128", "http://user@www.123.foo:3128", KURIFilterData::NET_PROTOCOL );
+
+ // Exotic IPv4 address formats...
+ filter( "127.1", "http://127.1", KURIFilterData::NET_PROTOCOL );
+ filter( "127.0.1", "http://127.0.1", KURIFilterData::NET_PROTOCOL );
+
+ // Local domain filter - If you uncomment these test, make sure you
+ // you adjust it based on the localhost entry in your /etc/hosts file.
+ // filter( "localhost:3128", "http://localhost.localdomain:3128", KURIFilterData::NET_PROTOCOL );
+ // filter( "localhost", "http://localhost.localdomain", KURIFilterData::NET_PROTOCOL );
+ // filter( "localhost/~blah", "http://localhost.localdomain/~blah", KURIFilterData::NET_PROTOCOL );
+
+ filter( "/", "/", KURIFilterData::LOCAL_DIR );
+ filter( "/", "/", KURIFilterData::LOCAL_DIR, "kshorturifilter" );
+ filter( "~/.bashrc", QDir::homeDirPath().local8Bit()+"/.bashrc", KURIFilterData::LOCAL_FILE, "kshorturifilter" );
+ filter( "~", QDir::homeDirPath().local8Bit(), KURIFilterData::LOCAL_DIR, "kshorturifilter", "/tmp" );
+ filter( "~foobar", 0, KURIFilterData::ERROR, "kshorturifilter" );
+ filter( "user@host.domain", "mailto:user@host.domain", KURIFilterData::NET_PROTOCOL ); // new in KDE-3.2
+
+ // Windows style SMB (UNC) URL. Should be converted into the valid smb format...
+ filter( "\\\\mainserver\\share\\file", "smb://mainserver/share/file" , KURIFilterData::NET_PROTOCOL );
+
+ // Should not be filtered at all. All valid protocols of this form will be ignored.
+ filter( "ftp:" , "ftp:", KURIFilterData::UNKNOWN );
+ filter( "http:" , "http:", KURIFilterData::UNKNOWN );
+
+ /*
+ Automatic searching tests. NOTE: If the Default search engine is set to 'None',
+ this stuff will fail as the status returned will then be KURIFilterData::UNKNOWN.
+ */
+ filter( "gg:", 0 , KURIFilterData::NET_PROTOCOL );
+ filter( "KDE", 0 , KURIFilterData::NET_PROTOCOL );
+ filter( "FTP", 0 , KURIFilterData::NET_PROTOCOL );
+
+ // If your default search engine is set to 'Google', you can uncomment the test below.
+ filter( "gg:", "http://www.google.com/search?q=gg%3A&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL );
+ filter( "KDE", "http://www.google.com/search?q=KDE&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL );
+ filter( "FTP", "http://www.google.com/search?q=FTP&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL );
+
+ // Typing 'cp' or any other valid unix command in konq's location bar should result in
+ // a search using the default search engine
+ // 'ls' is a bit of a special case though, due to the toplevel domain called 'ls'
+ filter( "cp", "http://www.google.com/search?q=cp&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL,
+ QStringList(), 0, false /* don't check for executables, see konq_misc.cc */ );
+
+ // Executable tests - No IKWS in minicli
+ filter( "cp", "cp", KURIFilterData::EXECUTABLE, minicliFilters );
+ filter( "kfmclient", "kfmclient", KURIFilterData::EXECUTABLE, minicliFilters );
+ filter( "xwininfo", "xwininfo", KURIFilterData::EXECUTABLE, minicliFilters );
+ filter( "KDE", "KDE", NO_FILTERING, minicliFilters );
+ filter( "I/dont/exist", "I/dont/exist", NO_FILTERING, minicliFilters );
+ filter( "/I/dont/exist", 0, KURIFilterData::ERROR, minicliFilters );
+ filter( "/I/dont/exist#a", 0, KURIFilterData::ERROR, minicliFilters );
+ filter( "kfmclient --help", "kfmclient --help", KURIFilterData::EXECUTABLE, minicliFilters ); // the args are in argsAndOptions()
+ filter( "/usr/bin/gs", "/usr/bin/gs", KURIFilterData::EXECUTABLE, minicliFilters );
+ filter( "/usr/bin/gs -q -option arg1", "/usr/bin/gs -q -option arg1", KURIFilterData::EXECUTABLE, minicliFilters ); // the args are in argsAndOptions()
+
+ // ENVIRONMENT variable
+ setenv( "SOMEVAR", "/somevar", 0 );
+ setenv( "ETC", "/etc", 0 );
+
+ QCString qtdir=getenv("QTDIR");
+ QCString home = getenv("HOME");
+ QCString kdehome = getenv("KDEHOME");
+
+ filter( "$SOMEVAR/kdelibs/kio", 0, KURIFilterData::ERROR ); // note: this dir doesn't exist...
+ filter( "$ETC/passwd", "/etc/passwd", KURIFilterData::LOCAL_FILE );
+ filter( "$QTDIR/doc/html/functions.html#s", QCString("file://")+qtdir+"/doc/html/functions.html#s", KURIFilterData::LOCAL_FILE );
+ filter( "http://www.kde.org/$USER", "http://www.kde.org/$USER", KURIFilterData::NET_PROTOCOL ); // no expansion
+
+ // Assume the default (~/.kde) if
+ if (kdehome.isEmpty())
+ {
+ kdehome += "$HOME/.kde";
+ setenv("KDEHOME", kdehome.data(), 0);
+ }
+
+ filter( "$KDEHOME/share", kdehome+"/share", KURIFilterData::LOCAL_DIR );
+ KStandardDirs::makeDir( kdehome+"/a+plus" );
+ filter( "$KDEHOME/a+plus", kdehome+"/a+plus", KURIFilterData::LOCAL_DIR );
+
+ // BR 27788
+ KStandardDirs::makeDir( kdehome+"/share/Dir With Space" );
+ filter( "$KDEHOME/share/Dir With Space", kdehome+"/share/Dir With Space", KURIFilterData::LOCAL_DIR );
+
+ // support for name filters (BR 93825)
+ filter( "$KDEHOME/*.txt", kdehome+"/*.txt", KURIFilterData::LOCAL_DIR );
+ filter( "$KDEHOME/[a-b]*.txt", kdehome+"/[a-b]*.txt", KURIFilterData::LOCAL_DIR );
+ filter( "$KDEHOME/a?c.txt", kdehome+"/a?c.txt", KURIFilterData::LOCAL_DIR );
+ filter( "$KDEHOME/?c.txt", kdehome+"/?c.txt", KURIFilterData::LOCAL_DIR );
+ // but let's check that a directory with * in the name still works
+ KStandardDirs::makeDir( kdehome+"/share/Dir*With*Stars" );
+ filter( "$KDEHOME/share/Dir*With*Stars", kdehome+"/share/Dir*With*Stars", KURIFilterData::LOCAL_DIR );
+ KStandardDirs::makeDir( kdehome+"/share/Dir?QuestionMark" );
+ filter( "$KDEHOME/share/Dir?QuestionMark", kdehome+"/share/Dir?QuestionMark", KURIFilterData::LOCAL_DIR );
+ KStandardDirs::makeDir( kdehome+"/share/Dir[Bracket" );
+ filter( "$KDEHOME/share/Dir[Bracket", kdehome+"/share/Dir[Bracket", KURIFilterData::LOCAL_DIR );
+
+ filter( "$HOME/$KDEDIR/kdebase/kcontrol/ebrowsing", 0, KURIFilterData::ERROR );
+ filter( "$1/$2/$3", "http://www.google.com/search?q=$1/$2/$3&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL ); // can be used as bogus or valid test. Currently triggers default search, i.e. google
+ filter( "$$$$", "http://www.google.com/search?q=$$$$&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL ); // worst case scenarios.
+
+ // Replaced the match testing with a 0 since
+ // the shortURI filter will return the string
+ // itself if the requested environment variable
+ // is not already set.
+ filter( "$QTDIR", 0, KURIFilterData::LOCAL_DIR, "kshorturifilter" ); //use specific filter.
+ filter( "$HOME", home, KURIFilterData::LOCAL_DIR, "kshorturifilter" ); //use specific filter.
+
+
+ QCString sc;
+ filter( sc.sprintf("gg%cfoo bar",delimiter), "http://www.google.com/search?q=foo+bar&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL );
+ filter( sc.sprintf("bug%c55798", delimiter), "http://bugs.kde.org/show_bug.cgi?id=55798", KURIFilterData::NET_PROTOCOL );
+
+ filter( sc.sprintf("gg%cC++", delimiter), "http://www.google.com/search?q=C%2B%2B&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL );
+ filter( sc.sprintf("ya%cfoo bar was here", delimiter), 0, -1 ); // this triggers default search, i.e. google
+ filter( sc.sprintf("gg%cwww.kde.org", delimiter), "http://www.google.com/search?q=www.kde.org&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL );
+ filter( sc.sprintf("av%c+rock +sample", delimiter), "http://www.altavista.com/cgi-bin/query?pg=q&kl=XX&stype=stext&q=%2Brock+%2Bsample", KURIFilterData::NET_PROTOCOL );
+ filter( sc.sprintf("gg%cé", delimiter) /*eaccent in utf8*/, "http://www.google.com/search?q=%C3%A9&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL );
+ filter( sc.sprintf("gg%cпрйвет", delimiter) /* greetings in russian utf-8*/, "http://www.google.com/search?q=%D0%BF%D1%80%D0%B9%D0%B2%D0%B5%D1%82&ie=UTF-8&oe=UTF-8", KURIFilterData::NET_PROTOCOL );
+
+ // Absolute Path tests for kshorturifilter
+ filter( "./", kdehome+"/share", KURIFilterData::LOCAL_DIR, "kshorturifilter", kdehome+"/share/" ); // cleanDirPath removes the trailing slash
+ filter( "../", kdehome, KURIFilterData::LOCAL_DIR, "kshorturifilter", kdehome+"/share" );
+ filter( "config", kdehome+"/share/config", KURIFilterData::LOCAL_DIR, "kshorturifilter", kdehome+"/share" );
+
+ // Clean up
+ KIO::NetAccess::del( kdehome, 0 );
+
+ kdDebug() << "All tests done. Go home..." << endl;
+ return 0;
+}
diff --git a/kio/tests/kurlcompletiontest.cpp b/kio/tests/kurlcompletiontest.cpp
new file mode 100644
index 000000000..ac0108ead
--- /dev/null
+++ b/kio/tests/kurlcompletiontest.cpp
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2004 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kapplication.h>
+#include <kurlcompletion.h>
+#include <kdebug.h>
+#include <qdir.h>
+#include <assert.h>
+#include <qfile.h>
+#include <ktempdir.h>
+#include <kcmdlineargs.h>
+#include <unistd.h>
+
+class KURLCompletionTest
+{
+public:
+ KURLCompletionTest() {}
+ ~KURLCompletionTest() { teardown(); }
+ void setup( bool setDirAsURL );
+ void teardown();
+ void testLocalRelativePath();
+ void testLocalAbsolutePath();
+ void testLocalURL();
+
+private:
+ void waitForCompletion();
+ KURLCompletion* m_completion;
+ KTempDir* m_tempDir;
+ KURL m_dirURL;
+ QString m_dir;
+};
+
+void KURLCompletionTest::setup( bool setDirAsURL )
+{
+ kdDebug() << k_funcinfo << endl;
+ m_completion = new KURLCompletion;
+ m_tempDir = new KTempDir;
+ m_tempDir->setAutoDelete( true );
+ m_dir = m_tempDir->name();
+ kdDebug() << "m_dir=" << m_dir << endl;
+ Q_ASSERT( m_dir.endsWith( "/" ) );
+ if ( setDirAsURL ) {
+ KURL d; d.setPath( m_dir );
+ m_completion->setDir( d.url() );
+ } else {
+ m_completion->setDir( m_dir );
+ }
+ m_dirURL.setPath( m_dir );
+
+ QFile f1( m_dir + "/file1" );
+ bool ok = f1.open( IO_WriteOnly );
+ assert( ok );
+ f1.close();
+
+ QFile f2( m_dir + "/file#a" );
+ ok = f2.open( IO_WriteOnly );
+ assert( ok );
+ f2.close();
+}
+
+void KURLCompletionTest::teardown()
+{
+ delete m_completion;
+ m_completion = 0;
+ delete m_tempDir;
+ m_tempDir = 0;
+}
+void KURLCompletionTest::waitForCompletion()
+{
+ while ( m_completion->isRunning() ) {
+ kdDebug() << "waiting for thread..." << endl;
+ usleep( 10 );
+ }
+}
+
+void KURLCompletionTest::testLocalRelativePath()
+{
+ kdDebug() << k_funcinfo << endl;
+ // Completion from relative path, with two matches
+ m_completion->makeCompletion( "f" );
+ waitForCompletion();
+ QStringList comp1all = m_completion->allMatches();
+ assert( comp1all.count() == 2 );
+ assert( comp1all.find( "file1" ) != comp1all.end() );
+ assert( comp1all.find( "file#a" ) != comp1all.end() );
+ QString comp1 = m_completion->replacedPath( "file1" ); // like KURLRequester does
+ assert( comp1 == "file1" );
+
+ // Completion from relative path
+ kdDebug() << endl << k_funcinfo << "now completing on 'file#'" << endl;
+ m_completion->makeCompletion( "file#" );
+ waitForCompletion();
+ QStringList compall = m_completion->allMatches();
+ kdDebug() << compall << endl;
+ assert( compall.count() == 1 );
+ assert( compall.first() == "file#a" );
+ QString comp2 = m_completion->replacedPath( compall.first() ); // like KURLRequester does
+ assert( comp2 == "file#a" );
+}
+
+void KURLCompletionTest::testLocalAbsolutePath()
+{
+ // Completion from absolute path
+ kdDebug() << k_funcinfo << m_dir+"file#" << endl;
+ m_completion->makeCompletion( m_dir + "file#" );
+ waitForCompletion();
+ QStringList compall = m_completion->allMatches();
+ kdDebug() << compall << endl;
+ assert( compall.count() == 1 );
+ QString comp = compall.first();
+ assert( comp == m_dir + "file#a" );
+ comp = m_completion->replacedPath( comp ); // like KURLRequester does
+ assert( comp == m_dir + "file#a" );
+}
+
+void KURLCompletionTest::testLocalURL()
+{
+ // Completion from URL
+ kdDebug() << k_funcinfo << endl;
+ KURL url = KURL::fromPathOrURL( m_dirURL.path() + "file" );
+ m_completion->makeCompletion( url.prettyURL() );
+ waitForCompletion();
+ QStringList comp1all = m_completion->allMatches();
+ kdDebug() << comp1all << endl;
+ assert( comp1all.count() == 2 );
+ assert( comp1all.find( m_dirURL.url() + "file1" ) != comp1all.end() );
+ QString filehash = m_dirURL.url() + "file%23a";
+ assert( comp1all.find( filehash ) != comp1all.end() );
+ QString filehashPath = m_completion->replacedPath( filehash ); // note that it returns a path!!
+ kdDebug() << filehashPath << endl;
+ assert( filehashPath == m_dirURL.path() + "file#a" );
+
+ // Completion from URL with no match
+ url = KURL::fromPathOrURL( m_dirURL.path() + "foobar" );
+ kdDebug() << k_funcinfo << "makeCompletion(" << url << ")" << endl;
+ QString comp2 = m_completion->makeCompletion( url.prettyURL() );
+ assert( comp2.isEmpty() );
+ waitForCompletion();
+ assert( m_completion->allMatches().isEmpty() );
+
+ // Completion from URL with a ref -> no match
+ url = KURL::fromPathOrURL( m_dirURL.path() + "f" );
+ url.setRef( "ref" );
+ kdDebug() << k_funcinfo << "makeCompletion(" << url << ")" << endl;
+ m_completion->makeCompletion( url.prettyURL() );
+ waitForCompletion();
+ assert( m_completion->allMatches().isEmpty() );
+}
+
+int main( int argc, char **argv )
+{
+ KApplication::disableAutoDcopRegistration();
+ KCmdLineArgs::init(argc,argv,"kurlcompletiontest", 0, 0, 0, 0);
+ KApplication app;
+
+ {
+ KURLCompletionTest test;
+ test.setup( false );
+ test.testLocalRelativePath();
+ test.testLocalAbsolutePath();
+ test.testLocalURL();
+ test.teardown();
+
+ // Try again, with another KTempDir (to check that the caching doesn't give us wrong results)
+ test.setup( true );
+ test.testLocalRelativePath();
+ test.testLocalAbsolutePath();
+ test.testLocalURL();
+ test.teardown();
+ }
+ qDebug( "All tests OK." );
+
+ return 0;
+}
diff --git a/kio/tests/kziptest.cpp b/kio/tests/kziptest.cpp
new file mode 100644
index 000000000..11ad36b7d
--- /dev/null
+++ b/kio/tests/kziptest.cpp
@@ -0,0 +1,435 @@
+/*
+ * Copyright (C) 2002, 2003 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "kzip.h"
+#include <stdio.h>
+#include <kinstance.h>
+#include <kdebug.h>
+#include <qfile.h>
+
+#include <assert.h>
+
+void recursive_print( const KArchiveDirectory * dir, const QString & path )
+{
+ QStringList l = dir->entries();
+ QStringList::Iterator it = l.begin();
+ for( ; it != l.end(); ++it )
+ {
+ const KArchiveEntry* entry = dir->entry( (*it) );
+ printf("mode=%07o %s %s size: %d pos: %d %s%s isdir=%d%s", entry->permissions(),
+ entry->user().latin1(), entry->group().latin1(),
+ entry->isDirectory() ? 0 : ((KArchiveFile*)entry)->size(),
+ entry->isDirectory() ? 0 : ((KArchiveFile*)entry)->position(),
+ path.latin1(), (*it).latin1(), entry->isDirectory(),
+ !entry->symlink() ? "" : QString(" symlink: %1").arg(entry->symlink()).latin1() );
+
+// if (!entry->isDirectory()) printf("%d", ((KArchiveFile*)entry)->size());
+ printf("\n");
+ if (entry->isDirectory())
+ recursive_print( (KArchiveDirectory *)entry, path+(*it)+"/" );
+ }
+}
+
+
+void recursive_transfer(const KArchiveDirectory * dir,
+ const QString & path, KZip * zip)
+{
+ QStringList l = dir->entries();
+ QStringList::Iterator it = l.begin();
+ for( ; it != l.end(); ++it )
+ {
+ const KArchiveEntry* e = dir->entry( (*it) );
+ kdDebug() << "actual file: " << e->name() << endl;
+ if (e->isFile())
+ {
+ Q_ASSERT( e && e->isFile() );
+ const KArchiveFile* f = (KArchiveFile*)e;
+ printf("FILE=%s\n", e->name().latin1());
+
+ QByteArray arr( f->data() );
+ printf("SIZE=%i\n",arr.size() );
+ QString str( arr );
+ printf("DATA=%s\n", str.latin1());
+
+ if (e->symlink().isEmpty()) {
+ zip->writeFile( path+e->name().latin1(),
+ "holgi", "holgrp",
+ arr.size() , f->data() );
+ } else
+ zip->writeSymLink(path+e->name(), e->symlink(), "leo", "leo",
+ 0120777, 1000000000l, 1000000000l, 1000000000l);
+ }
+ else if (e->isDirectory())
+ {
+ recursive_transfer((KArchiveDirectory *)e ,
+ path+e->name()+"/", zip);
+ }
+ }
+}
+
+int main( int argc, char** argv )
+{
+ if (argc < 3)
+ {
+ printf("\n"
+ " Usage :\n"
+ " ./kziptest list /path/to/existing_file.zip tests listing an existing zip\n"
+ " ./kziptest readwrite newfile.zip will create the zip, then close and reopen it.\n"
+ " ./kziptest maxlength newfile.zip tests the maximum filename length allowed.\n"
+ " ./kziptest print file.zip prints contents of all files.\n"
+ " ./kziptest print2 file.zip filename prints contents of one file.\n"
+ " ./kziptest update file.zip filename updates contents of one file.\n"
+ " ./kziptest transfer file.zip newfile.zip complete transfer.\n"
+ " ./kziptest iodevice /path/to/existing_file.zip tests KArchiveFile::device()\n");
+ return 1;
+ }
+ KInstance instance("kziptest");
+ QString command = argv[1];
+ if ( command == "list" )
+ {
+ KZip zip( argv[2] );
+
+ if ( !zip.open( IO_ReadOnly ) )
+ {
+ printf("Could not open %s for reading\n", argv[2] );
+ return 1;
+ }
+
+ const KArchiveDirectory* dir = zip.directory();
+
+ //printf("calling recursive_print\n");
+ recursive_print( dir, "" );
+ //printf("recursive_print called\n");
+
+ zip.close();
+
+ return 0;
+ }
+ else if (command == "readwrite" )
+ {
+ KZip zip( argv[2] );
+
+ if ( !zip.open( IO_WriteOnly ) )
+ {
+ printf("Could not open %s for writing\n", argv[2]);
+ return 1;
+ }
+
+ zip.setCompression( KZip::NoCompression );
+ zip.writeFile( "typeid", "", "", 19, "application/x-kword" );
+ zip.setCompression( KZip::DeflateCompression );
+ zip.writeFile( "empty", "weis", "users", 0, "" );
+ zip.writeFile( "test1", "weis", "users", 5, "Hallo" );
+ zip.writeFile( "test2", "weis", "users", 8, "Hallo Du" );
+ zip.writeFile( "mydir/test3", "weis", "users", 13, "Noch so einer" );
+ zip.writeFile( "my/dir/test3", "dfaure", "hackers", 29, "I don't speak German (David)" );
+ zip.writeSymLink( "a_link", "mydir/test3", "leo", "leo", 0120777,
+ 1000000000l, 1000000000l, 1000000000l);
+
+#define SIZE1 100
+ // Now a medium file : 100 null bytes
+ char medium[ SIZE1 ];
+ memset( medium, 0, SIZE1 );
+ zip.writeFile( "mediumfile", "user", "group", SIZE1, medium );
+ // Another one, with an absolute path
+ zip.writeFile( "/dir/subdir/mediumfile2", "user", "group", SIZE1, medium );
+
+ // Now a huge file : 20000 null bytes
+ int n = 20000;
+ char * huge = new char[ n ];
+ memset( huge, 0, n );
+ zip.writeFile( "hugefile", "user", "group", n, huge );
+ delete [] huge;
+
+ // Now a file from the harddisk
+ zip.addLocalFile( ".libs/lt-kziptest", "lt-kziptest" );
+
+ printf( "calling close\n" );
+
+ zip.close();
+
+ printf("-----------------------\n");
+
+ if ( !zip.open( IO_ReadOnly ) )
+ {
+ printf("Could not open %s for reading\n", argv[2] );
+ return 1;
+ }
+
+ const KArchiveDirectory* dir = zip.directory();
+ recursive_print(dir, "");
+
+ const KArchiveEntry* e = dir->entry( "mydir/test3" );
+ Q_ASSERT( e && e->isFile() );
+ const KArchiveFile* f = (KArchiveFile*)e;
+
+ QByteArray arr( f->data() );
+ Q_ASSERT( arr.size() == 13 );
+ printf("SIZE=%i\n",arr.size() );
+ QString str( arr );
+ Q_ASSERT( str == "Noch so einer" );
+ printf("DATA=%s\n", str.latin1());
+
+ e = dir->entry( "mediumfile" );
+ Q_ASSERT( e && e->isFile() );
+ f = (KArchiveFile*)e;
+ Q_ASSERT( f->data().size() == SIZE1 );
+
+ e = dir->entry( "hugefile" );
+ Q_ASSERT( e && e->isFile() );
+ f = (KArchiveFile*)e;
+ Q_ASSERT( f->data().size() == 20000 );
+
+ zip.close();
+
+ return 0;
+ }
+ else if ( command == "maxlength" )
+ {
+ KZip zip( argv[2] );
+
+ if ( !zip.open( IO_WriteOnly ) )
+ {
+ printf("Could not open %s for writing\n", argv[2]);
+ return 1;
+ }
+ // Generate long filenames of each possible length bigger than 98...
+ for (int i = 98; i < 500 ; i++ )
+ {
+ QString str, num;
+ str.fill( 'a', i-10 );
+ num.setNum( i );
+ num = num.rightJustify( 10, '0' );
+ zip.writeFile( str+num, "testu", "testg", 3, "hum" );
+ }
+ // Result of this test : it fails at 482 (instead of 154 previously).
+ // Ok, I think we can do with that :)
+ zip.close();
+ printf("Now run 'unzip -l %s'\n", argv[2]);
+ return 0;
+ }
+ else if ( command == "iodevice" )
+ {
+ KZip zip( argv[2] );
+ if ( !zip.open( IO_ReadOnly ) )
+ return 1;
+ const KArchiveDirectory* dir = zip.directory();
+ assert(dir);
+ const KArchiveEntry* entry = dir->entry( "my/dir/test3" );
+ if ( entry && entry->isFile() )
+ {
+ QIODevice *dev = static_cast<const KZipFileEntry *>(entry)->device();
+ if ( dev ) {
+ QByteArray contents = dev->readAll();
+ printf("contents='%s'\n", QCString(contents, contents.size()+1).data());
+ }
+ } else
+ printf("entry=%p - not found if 0, otherwise not a file\n", (void*)entry);
+ return 0;
+ }
+ else if (command == "print" )
+ {
+ KZip zip( argv[2] );
+ kdDebug() << "Opening zip file" << endl;
+ if ( !zip.open( IO_ReadOnly ) )
+ {
+ printf("Could not open %s for reading\n", argv[2] );
+ return 1;
+ }
+ const KArchiveDirectory* dir = zip.directory();
+ kdDebug() << "Listing toplevel of zip file" << endl;
+ QStringList l = dir->entries();
+ QStringList::Iterator it = l.begin();
+ for( ; it != l.end(); ++it )
+ {
+ const KArchiveEntry* e = dir->entry( (*it) );
+ kdDebug() << "Printing " << (*it) << endl;
+ if (e->isFile())
+ {
+ Q_ASSERT( e && e->isFile() );
+ const KArchiveFile* f = (KArchiveFile*)e;
+
+ QByteArray arr( f->data() );
+ printf("SIZE=%i\n",arr.size() );
+ QString str( arr );
+ printf("DATA=%s\n", str.latin1());
+ }
+ }
+ zip.close();
+ return 0;
+ }
+ else if (command == "print2" )
+ {
+ if (argc != 4)
+ {
+ printf("usage: kziptest print2 archivename filename");
+ return 1;
+ }
+ KZip zip( argv[2] );
+ if ( !zip.open( IO_ReadOnly ) )
+ {
+ printf("Could not open %s for reading\n", argv[2] );
+ return 1;
+ }
+ const KArchiveDirectory* dir = zip.directory();
+ const KArchiveEntry* e = dir->entry( argv[3] );
+ Q_ASSERT( e && e->isFile() );
+ const KArchiveFile* f = (KArchiveFile*)e;
+
+ QByteArray arr( f->data() );
+ printf("SIZE=%i\n",arr.size() );
+ QString str( arr );
+// printf("DATA=%s\n", str.latin1());
+ printf("%s", str.latin1());
+ zip.close();
+
+ return 0;
+
+ }
+ else if (command == "update" )
+ {
+ if (argc != 4)
+ {
+ printf("usage: kziptest update archivename filename");
+ return 1;
+ }
+ KZip zip( argv[2] );
+ if ( !zip.open( IO_ReadWrite ) )
+ {
+ printf("Could not open %s for read/write\n", argv[2] );
+ return 1;
+ }
+ const KArchiveEntry* e = zip.directory()->entry( argv[3] );
+// Q_ASSERT( e && e->isFile() );
+// const KArchiveFile* f = (KArchiveFile*)e;
+
+// QCString data( "This is some new data that goes into " );
+ // data += argv[3];
+ QFile f ( argv[3] );
+ if (!f.open( IO_ReadOnly ))
+ {
+ printf("Could not open %s for reading\n", argv[2] );
+ return 1;
+ }
+
+ QDataStream s( &f );
+
+
+// zip.writeFile( argv[3], "", "", data.size(), data.data() );
+ zip.writeFile( argv[3], "", "", f.size(), f.readAll() );
+ zip.close();
+
+ return 0;
+
+ }
+ else if (command == "transfer" )
+ {
+ if (argc != 4)
+ {
+ printf("usage: kziptest transfer sourcefile destfile");
+ return 1;
+ }
+ KZip zip1( argv[2] );
+ KZip zip2( argv[3] );
+ if ( !zip1.open( IO_ReadOnly ) )
+ {
+ printf("Could not open %s for reading\n", argv[2] );
+ return 1;
+ }
+ if ( !zip2.open( IO_WriteOnly ) )
+ {
+ printf("Could not open %s for writing\n", argv[3] );
+ return 1;
+ }
+ const KArchiveDirectory* dir1 = zip1.directory();
+
+ recursive_transfer(dir1, "", &zip2 );
+
+ zip1.close();
+ zip2.close();
+
+/*
+ zip.writeFile( "empty", "weis", "users", 0, "" );
+ zip.writeFile( "test1", "weis", "users", 5, "Hallo" );
+ zip.writeFile( "test2", "weis", "users", 8, "Hallo Du" );
+ zip.writeFile( "mydir/test3", "weis", "users", 13, "Noch so einer" );
+ zip.writeFile( "my/dir/test3", "dfaure", "hackers", 29, "I don't speak German (David)" );
+
+#define SIZE1 100
+ // Now a medium file : 100 null bytes
+ char medium[ SIZE1 ];
+ memset( medium, 0, SIZE1 );
+ zip.writeFile( "mediumfile", "user", "group", SIZE1, medium );
+ // Another one, with an absolute path
+ zip.writeFile( "/dir/subdir/mediumfile2", "user", "group", SIZE1, medium );
+
+ // Now a huge file : 20000 null bytes
+ int n = 20000;
+ char * huge = new char[ n ];
+ memset( huge, 0, n );
+ zip.writeFile( "hugefile", "user", "group", n, huge );
+ delete [] huge;
+
+ zip.close();
+
+ printf("-----------------------\n");
+
+ if ( !zip.open( IO_ReadOnly ) )
+ {
+ printf("Could not open %s for reading\n", argv[2] );
+ return 1;
+ }
+
+ const KArchiveDirectory* dir = zip.directory();
+ recursive_print(dir, "");
+
+ const KArchiveEntry* e = dir->entry( "mydir/test3" );
+ Q_ASSERT( e && e->isFile() );
+ const KArchiveFile* f = (KArchiveFile*)e;
+
+ QByteArray arr( f->data() );
+ printf("SIZE=%i\n",arr.size() );
+ QString str( arr );
+ printf("DATA=%s\n", str.latin1());
+
+ zip.close();
+
+ return 0;
+
+
+
+
+
+ const KArchiveEntry* e = dir1->entry( argv[3] );
+ Q_ASSERT( e && e->isFile() );
+ const KArchiveFile* f = (KArchiveFile*)e;
+
+ QByteArray arr( f->data() );
+// printf("SIZE=%i\n",arr.size() );
+ QString str( arr );
+// printf("DATA=%s\n", str.latin1());
+ printf("%s", str.latin1());
+ zip.close();
+
+*/
+ return 0;
+
+ }
+ else
+ printf("Unknown command\n");
+}
diff --git a/kio/tests/metatest.cpp b/kio/tests/metatest.cpp
new file mode 100644
index 000000000..9a5824132
--- /dev/null
+++ b/kio/tests/metatest.cpp
@@ -0,0 +1,321 @@
+#include <kapplication.h>
+#include <kfilemetainfo.h>
+#include <kcmdlineargs.h>
+#include <qstringlist.h>
+#include <qimage.h>
+#include <kdebug.h>
+#include <qlabel.h>
+#include <qvalidator.h>
+
+#define I18N_NOOP
+
+ static KCmdLineOptions options[] =
+ {
+ { "+file", "File name", 0 },
+ { "addgroup ", "Add a group to a file", 0},
+ { "removegroup ", "Remove a group from a file", 0},
+ { "removeitem ", "Remove the item from --group from a file", 0},
+ { "group ", "Specify a group to work on", 0},
+ { "validator", "Create a validator for an item and show its class", 0},
+ { "item ", "Specify an item to work on", 0},
+ { "add ", "Add the --item to the --group and set the value", 0},
+ { "autogroupadd", "Automatically add a group if none is found", 0},
+ { "set ", "Set the value of --item in --group", 0},
+ { "groups", "list the groups of this file", 0 },
+ { "mimetypeinfo ", "the mimetype info for a mimetype", 0 },
+ KCmdLineLastOption
+ };
+
+void printKeyValues(KFileMetaInfo& info)
+{
+ QStringList l = info.preferredKeys();
+ kdDebug() << "found " << l.size() << " keys\n";
+
+ QString s;
+ QStringList::Iterator it;
+ for (it = l.begin(); it!=l.end(); ++it)
+ {
+ s +=" - " + *it;
+ }
+ kdDebug() << "keys: " << s << endl;
+
+ for (it = l.begin(); it!=l.end(); ++it)
+ {
+ KFileMetaInfoItem item = info.item(*it);
+ if ( item.isValid() && item.value().canCast(QVariant::String)) {
+ kdDebug() << item.key() << "(" << item.translatedKey() << ") -> "
+ << item.string() << endl;
+ }
+ }
+}
+
+void printMimeTypeInfo(QString mimetype)
+{
+ const KFileMimeTypeInfo* info = KFileMetaInfoProvider::self()->mimeTypeInfo(mimetype);
+
+ if (!info) return;
+ kdDebug() << "Preferred groups:\n";
+ kdDebug() << "=================\n";
+ QStringList groups = info->preferredGroups();
+
+ for (QStringList::Iterator it=groups.begin() ; it!=groups.end(); ++it)
+ {
+ kdDebug() << *it << endl;
+ }
+
+ kdDebug() << endl;
+ kdDebug() << "Supported groups:\n";
+ kdDebug() << "=================\n";
+ groups = info->supportedGroups();
+ for (QStringList::Iterator it=groups.begin() ; it!=groups.end(); ++it)
+ {
+ kdDebug() << *it << endl;
+ }
+
+ for (QStringList::Iterator it=groups.begin() ; it!=groups.end(); ++it)
+ {
+ const KFileMimeTypeInfo::GroupInfo* groupinfo = info->groupInfo(*it);
+
+ kdDebug() << endl;
+ kdDebug() << "Group \"" << *it << "\"\n";
+ kdDebug() << "==================\n";
+
+ if (!groupinfo) kdDebug() << "argh! no group info\n";
+
+ kdDebug() << endl;
+ kdDebug() << " Supported keys:\n";
+ QStringList keys = groupinfo->supportedKeys();
+ if (!keys.count()) kdDebug() << " none\n";
+ for (QStringList::Iterator kit=keys.begin(); kit!=keys.end(); ++kit)
+ {
+ kdDebug() << " " << *kit << endl;
+
+ const KFileMimeTypeInfo::ItemInfo* iti = groupinfo->itemInfo(*kit);
+ kdDebug() << " Key: " << iti->key() << endl;
+ kdDebug() << " Translated: " << iti->key() << endl;
+ kdDebug() << " Type: " << QVariant::typeToName(iti->type()) << endl;
+ kdDebug() << " Unit: " << iti->unit() << endl;
+ kdDebug() << " Hint: " << iti->hint() << endl;
+ kdDebug() << " Attributes: " << iti->attributes() << endl;
+ kdDebug() << " Prefix: " << iti->prefix() << endl;
+ kdDebug() << " Suffix: " << iti->suffix() << endl;
+ }
+
+ kdDebug() << " name: " << groupinfo->name() << endl;
+ kdDebug() << " translated: " << groupinfo->translatedName() << endl;
+ kdDebug() << " attributes: " << groupinfo->attributes() << endl;
+ kdDebug() << " variable keys: " << (groupinfo->supportsVariableKeys() ? "Yes" : "No") << endl;
+ if (groupinfo->supportsVariableKeys())
+ {
+ const KFileMimeTypeInfo::ItemInfo* iti = groupinfo->variableItemInfo();
+ kdDebug() << " variable key type/attr: " << QVariant::typeToName(iti->type()) << " / " << iti->attributes() << endl;
+ }
+ }
+
+ kdDebug() << endl;
+ kdDebug() << "Preferred keys:\n";
+ kdDebug() << "===============\n";
+ QStringList prefKeys = info->preferredKeys();
+ if (!prefKeys.count()) kdDebug() << " none\n";
+ for (QStringList::Iterator kit=prefKeys.begin(); kit!=prefKeys.end(); ++kit)
+ {
+ kdDebug() << *kit << endl;
+ }
+
+ kdDebug() << endl;
+ kdDebug() << "Supported keys:\n";
+ kdDebug() << "===============\n";
+ QStringList supKeys = info->supportedKeys();
+ if (!supKeys.count()) kdDebug() << " none\n";
+ for (QStringList::Iterator kit=supKeys.begin(); kit!=supKeys.end(); ++kit)
+ {
+ kdDebug() << *kit << endl;
+ }
+}
+
+void addGroup(KFileMetaInfo& info, QString group)
+{
+ kdDebug() << "trying to add group " << group << endl;
+
+ kdDebug() << "groups before: \n";
+ QStringList groups = info.groups();
+ for (QStringList::Iterator it=groups.begin() ; it!=groups.end(); ++it)
+ kdDebug() << " " << *it << endl;
+
+ if (info.addGroup(group))
+ kdDebug() << "addGroup succeeded\n";
+ else
+ kdDebug() << "addGroup failed\n";
+
+ kdDebug() << "trying another addGroup to see what happens\n";
+
+ if (info.addGroup(group))
+ kdDebug() << "addGroup succeeded\n";
+ else
+ kdDebug() << "addGroup failed\n";
+
+
+ kdDebug() << "and afterwards: \n";
+ groups = info.groups();
+ for (QStringList::Iterator it=groups.begin() ; it!=groups.end(); ++it)
+ kdDebug() << " " << *it << endl;
+}
+
+void removeGroup(KFileMetaInfo& info, QString group)
+{
+ kdDebug() << "trying to remove group " << group << endl;
+
+ kdDebug() << "groups before: \n";
+ QStringList groups = info.groups();
+ for (QStringList::Iterator it=groups.begin() ; it!=groups.end(); ++it)
+ kdDebug() << " " << *it << endl;
+
+ info.removeGroup(group);
+
+ kdDebug() << "and afterwards: \n";
+ groups = info.groups();
+ for (QStringList::Iterator it=groups.begin() ; it!=groups.end(); ++it)
+ kdDebug() << " " << *it << endl;
+}
+
+int main( int argc, char **argv )
+{
+ // Initialize command line args
+ KCmdLineArgs::init(argc, argv, "kfilemetatest", "testing kfilmetainfo", "X");
+
+ // Tell which options are supported
+ KCmdLineArgs::addCmdLineOptions( options );
+
+ // Add options from other components
+ KApplication::addCmdLineOptions();
+
+ KApplication app;
+
+ KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
+
+ QCString ov;
+ ov = args->getOption("mimetypeinfo");
+ if (ov)
+ {
+ printMimeTypeInfo(ov);
+ return 0;
+ }
+
+ if (!args->count()) return 1;
+
+ KFileMetaInfo info( args->url(0), QString::null, KFileMetaInfo::Everything);
+
+ if (args->isSet("groups"))
+ {
+ QStringList groups = info.groups();
+ for (QStringList::Iterator it=groups.begin() ; it!=groups.end(); ++it)
+ {
+ kdDebug() << "group " << *it << endl;
+ }
+ return 0;
+ }
+
+ QString group, item;
+
+ ov = args->getOption("addgroup");
+ if (ov) addGroup(info, ov);
+
+ ov = args->getOption("removegroup");
+ if (ov) removeGroup(info, ov);
+
+ ov = args->getOption("group");
+ if (ov) group = ov;
+
+ ov = args->getOption("item");
+ if (ov) item = ov;
+
+ ov = args->getOption("add");
+ if (ov && !group.isNull() && !item.isNull())
+ {
+ KFileMetaInfoGroup g = info[group];
+ if (!g.isValid() && args->isSet("autogroupadd"))
+ {
+ kdDebug() << "group is not there, adding it\n";
+ info.addGroup(group);
+ }
+ // add the item
+ KFileMetaInfoItem i = info[group].addItem(item);
+ if (i.isValid())
+ kdDebug() << "additem success\n";
+ else
+ kdDebug() << "additem failed\n";
+
+ if (i.setValue(ov))
+ kdDebug() << "setValue success\n";
+ else
+ kdDebug() << "setValue failed\n";
+ }
+
+ ov = args->getOption("set");
+ if (ov && !group.isNull() && !item.isNull())
+ {
+ if (info[group][item].setValue(QString(ov)))
+ kdDebug() << "setValue success\n";
+ else
+ kdDebug() << "setValue failed\n";
+ }
+
+ ov = args->getOption("removeitem");
+ if (ov && !group.isNull())
+ {
+ if (info[group].removeItem(ov))
+ kdDebug() << "removeitem success\n";
+ else
+ kdDebug() << "removeitem failed\n";
+ }
+
+ if (args->isSet("validator") && !group.isNull() && !item.isNull())
+ {
+ const KFileMimeTypeInfo* kfmti = KFileMetaInfoProvider::self()->mimeTypeInfo(info.mimeType());
+ QValidator* v = kfmti->createValidator(group, item);
+ if (!v)
+ kdDebug() << "got no validator\n";
+ else
+ {
+ kdDebug() << "validator is a " << v->className() << endl;
+ delete v;
+ }
+
+ }
+
+ kdDebug() << "is it valid?\n";
+
+ if (!info.isValid()) return 1;
+
+ kdDebug() << "it is!\n";
+
+ printKeyValues(info);
+
+
+ kdDebug() << "========= again after applyChanges() =========\n";
+
+ info.applyChanges();
+
+ printKeyValues(info);
+
+ KFileMetaInfoItem thumbitem = info.item(KFileMimeTypeInfo::Thumbnail);
+// KFileMetaInfoItem thumbitem = info.item("Thumbnail");
+
+ if (!thumbitem.isValid()) kdDebug() << "no thumbnail\n";
+ else
+ kdDebug() << "type of thumbnail is " << thumbitem.value().typeName() << endl;
+
+
+ if (thumbitem.isValid() && thumbitem.value().canCast(QVariant::Image))
+ {
+ QLabel* label = new QLabel(0);
+ app.setMainWidget(label);
+ QPixmap pix;
+ pix.convertFromImage(thumbitem.value().toImage());
+ label->setPixmap(pix);
+ label->show();
+ app.exec();
+ }
+
+ return 0;
+}
diff --git a/kio/tests/netaccesstest.cpp b/kio/tests/netaccesstest.cpp
new file mode 100644
index 000000000..6ac85fcfc
--- /dev/null
+++ b/kio/tests/netaccesstest.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2004 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kurl.h>
+#include <kio/netaccess.h>
+#include <qfile.h>
+
+int main(int argc, char **argv)
+{
+ KApplication app( argc, argv, "netaccesstest", true /* it _has_ a GUI ! */);
+
+ KURL srcURL( "ftp://ftp.kde.org/pub/kde/README" );
+ KURL tmpURL( "file:/tmp/netaccesstest_README" );
+
+ for ( uint i = 0; i < 4 ; ++i ) {
+ kdDebug() << "file_copy" << endl;
+ if ( !KIO::NetAccess::file_copy(srcURL, tmpURL, -1, true, false, 0) )
+ kdError() << "file_copy failed: " << KIO::NetAccess::lastErrorString() << endl;
+ else {
+ QFile f( tmpURL.path() );
+ if (!f.open(IO_ReadOnly))
+ kdFatal() << "Cannot open: " << f.name() << ". The error was: " << f.errorString() << endl;
+ else {
+ f.close();
+ }
+ }
+ }
+
+ return 0;
+}
+
diff --git a/kio/tests/previewtest.cpp b/kio/tests/previewtest.cpp
new file mode 100644
index 000000000..66fa9398e
--- /dev/null
+++ b/kio/tests/previewtest.cpp
@@ -0,0 +1,64 @@
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <klineedit.h>
+
+#include <kio/previewjob.h>
+
+#include "previewtest.moc"
+
+PreviewTest::PreviewTest()
+ :QWidget()
+{
+ QGridLayout *layout = new QGridLayout(this, 2, 2);
+ m_url = new KLineEdit(this);
+ m_url->setText("/home/malte/gore_bush.jpg");
+ layout->addWidget(m_url, 0, 0);
+ QPushButton *btn = new QPushButton("Generate", this);
+ connect(btn, SIGNAL(clicked()), SLOT(slotGenerate()));
+ layout->addWidget(btn, 0, 1);
+ m_preview = new QLabel(this);
+ m_preview->setMinimumSize(400, 300);
+ layout->addMultiCellWidget(m_preview, 1, 1, 0, 1);
+}
+
+void PreviewTest::slotGenerate()
+{
+ KURL::List urls;
+ urls.append(m_url->text());
+ KIO::PreviewJob *job = KIO::filePreview(urls, m_preview->width(), m_preview->height(), true, 48);
+ connect(job, SIGNAL(result(KIO::Job*)), SLOT(slotResult(KIO::Job*)));
+ connect(job, SIGNAL(gotPreview(const KFileItem *, const QPixmap &)), SLOT(slotPreview(const KFileItem *, const QPixmap &)));
+ connect(job, SIGNAL(failed(const KFileItem *)), SLOT(slotFailed()));
+}
+
+void PreviewTest::slotResult(KIO::Job*)
+{
+ kdDebug() << "PreviewTest::slotResult(...)" << endl;
+}
+
+void PreviewTest::slotPreview(const KFileItem *, const QPixmap &pix)
+{
+ kdDebug() << "PreviewTest::slotPreview()" << endl;
+ m_preview->setPixmap(pix);
+}
+
+void PreviewTest::slotFailed()
+{
+ kdDebug() << "PreviewTest::slotFailed()" << endl;
+ m_preview->setText("failed");
+}
+
+int main(int argc, char **argv)
+{
+ KApplication app(argc, argv, "previewtest");
+ PreviewTest *w = new PreviewTest;
+ w->show();
+ app.setMainWidget(w);
+ return app.exec();
+}
+
diff --git a/kio/tests/previewtest.h b/kio/tests/previewtest.h
new file mode 100644
index 000000000..52c10f240
--- /dev/null
+++ b/kio/tests/previewtest.h
@@ -0,0 +1,25 @@
+
+#include <qwidget.h>
+#include <kio/job.h>
+
+class KLineEdit;
+class QLabel;
+class KFileItem;
+
+class PreviewTest : public QWidget
+{
+ Q_OBJECT
+public:
+ PreviewTest();
+
+private slots:
+ void slotGenerate();
+ void slotResult(KIO::Job *);
+ void slotPreview( const KFileItem *, const QPixmap & );
+ void slotFailed();
+
+private:
+ KLineEdit *m_url;
+ QLabel *m_preview;
+};
+
diff --git a/kio/tests/speed.cpp b/kio/tests/speed.cpp
new file mode 100644
index 000000000..fc7128f35
--- /dev/null
+++ b/kio/tests/speed.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2002, 2003 Stephan Kulow <coolo@kde.org>
+ * Copyright (C) 2003 David Faure <faure@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#include <kdebug.h>
+#include <kapplication.h>
+#include <time.h>
+#include "speed.h"
+#include <kio/job.h>
+#include <kcmdlineargs.h>
+#include <qdir.h>
+#include <kio/global.h>
+
+using namespace KIO;
+
+SpeedTest::SpeedTest( const KURL & url )
+ : QObject(0, "speed")
+{
+ Job *job = listRecursive( url );
+ //Job *job = del( KURL("file:" + QDir::currentDirPath()) ); DANGEROUS !
+ connect(job, SIGNAL( result( KIO::Job*)),
+ SLOT( finished( KIO::Job* ) ));
+ /*connect(job, SIGNAL( entries( KIO::Job*, const KIO::UDSEntryList&)),
+ SLOT( entries( KIO::Job*, const KIO::UDSEntryList&)));
+ */
+}
+
+void SpeedTest::entries(KIO::Job*, const UDSEntryList& list) {
+
+ UDSEntryListConstIterator it=list.begin();
+ for (; it != list.end(); ++it) {
+ UDSEntry::ConstIterator it2 = (*it).begin();
+ for( ; it2 != (*it).end(); it2++ ) {
+ if ((*it2).m_uds == UDS_NAME)
+ kdDebug() << ( *it2 ).m_str << endl;
+ }
+ }
+}
+
+
+void SpeedTest::finished(Job*) {
+ kdDebug() << "job finished" << endl;
+ kapp->quit();
+}
+
+static KCmdLineOptions options[] =
+{
+ { "+[URL]", "the URL to list", 0 },
+ KCmdLineLastOption
+};
+
+int main(int argc, char **argv) {
+
+ KCmdLineArgs::init( argc, argv, "speedapp", "A KIO::listRecursive testing tool", "0.0" );
+
+ KCmdLineArgs::addCmdLineOptions( options );
+
+ KApplication app;
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ KURL url;
+ if ( args->count() == 1 )
+ url = args->url(0);
+ else
+ url = "file:" + QDir::currentDirPath();
+
+ kdDebug() << url.url() << " is probably " << (KIO::probably_slow_mounted(url.path()) ? "slow" : "normal") << " mounted\n";
+ kdDebug() << url.url() << " is " << (KIO::manually_mounted(url.path()) ? "manually" : "system") << " mounted\n";
+ QString mp = KIO::findDeviceMountPoint(url.path());
+ if (mp.isEmpty()) {
+ kdDebug() << "no mount point for device " << url.url() << " found\n";
+ } else
+ kdDebug() << mp << " is the mount point for device " << url.url() << endl;
+
+ mp = KIO::findPathMountPoint(url.path());
+ if (mp.isEmpty()) {
+ kdDebug() << "no mount point for path " << url.url() << " found\n";
+ } else
+ kdDebug() << mp << " is the mount point for path " << url.url() << endl;
+ // SpeedTest test( url );
+ // app.exec();
+
+ mp = KIO::findPathMountPoint(url.path());
+ if (mp.isEmpty()) {
+ kdDebug() << "no mount point for path " << url.url() << " found\n";
+ } else
+ kdDebug() << mp << " is the mount point for path " << url.url() << endl;
+ // SpeedTest test( url );
+ // app.exec();
+
+ url.setPath(QDir::homeDirPath());
+
+ mp = KIO::findPathMountPoint(url.path());
+ if (mp.isEmpty()) {
+ kdDebug() << "no mount point for path " << url.url() << " found\n";
+ } else
+ kdDebug() << mp << " is the mount point for path " << url.url() << endl;
+ // SpeedTest test( url );
+ // app.exec();
+
+ mp = KIO::findPathMountPoint(url.path());
+ if (mp.isEmpty()) {
+ kdDebug() << "no mount point for path " << url.url() << " found\n";
+ } else
+ kdDebug() << mp << " is the mount point for path " << url.url() << endl;
+ // SpeedTest test( url );
+ // app.exec();
+
+ if ( args->count() == 1 )
+ url = args->url(0);
+ else
+ url = "file:" + QDir::currentDirPath();
+
+ mp = KIO::findPathMountPoint(url.path());
+ if (mp.isEmpty()) {
+ kdDebug() << "no mount point for path " << url.url() << " found\n";
+ } else
+ kdDebug() << mp << " is the mount point for path " << url.url() << endl;
+ // SpeedTest test( url );
+ // app.exec();
+
+}
+
+#include "speed.moc"
diff --git a/kio/tests/speed.h b/kio/tests/speed.h
new file mode 100644
index 000000000..e66970f0f
--- /dev/null
+++ b/kio/tests/speed.h
@@ -0,0 +1,24 @@
+// -*- c++ -*-
+#ifndef _SPEED_H
+#define _SPEED_H
+
+#include <kio/global.h>
+#include <kurl.h>
+
+namespace KIO {
+ class Job;
+}
+
+class SpeedTest : public QObject {
+ Q_OBJECT
+
+public:
+ SpeedTest(const KURL & url);
+
+private slots:
+ void entries( KIO::Job *, const KIO::UDSEntryList& );
+ void finished( KIO::Job *job );
+
+};
+
+#endif
diff --git a/kio/tests/wronglocalsizes.zip b/kio/tests/wronglocalsizes.zip
new file mode 100644
index 000000000..3f76738ba
--- /dev/null
+++ b/kio/tests/wronglocalsizes.zip
Binary files differ