[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/pim/krss/resource
From: Dmitry Ivanov <vonami () gmail ! com>
Date: 2008-08-20 14:05:50
Message-ID: 1219241150.157874.22920.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 849946 by divanov:
- redirect errors from the parser in ImportOpmlJob
- add a test for broken OPML
M +19 -5 importopmljob.cpp
M +1 -0 importopmljob.h
M +13 -0 tests/importopmljobtest.cpp
M +1 -0 tests/importopmljobtest.h
M +2 -2 tests/testdata/broken.opml
--- trunk/playground/pim/krss/resource/importopmljob.cpp #849945:849946
@@ -57,6 +57,7 @@
QString m_defaultTag;
QXmlStreamReader m_reader;
int m_pendingJobs;
+ QList<FeedCollection> m_pendingFeeds;
QHash<FeedCollection::Id, FeedCollection> m_feeds;
};
@@ -95,6 +96,7 @@
switch ( error() ) {
case RootCollectionImportFailed:
case OpmlReadFailed:
+ case OpmlParsingFailed:
case FeedImportFailed:
return errorText();
default:
@@ -172,6 +174,22 @@
}
static_cast<KIO::FileJob *>( job )->close();
+
+ // commit the feeds or return the error from the parser
+ if ( !d->m_reader.hasError() ) {
+ Q_FOREACH( const FeedCollection &feed, d->m_pendingFeeds ) {
+ kDebug() << "Importing new feed:" << feed.title();
+ d->m_pendingJobs++;
+ Akonadi::CollectionCreateJob *job = new Akonadi::CollectionCreateJob( \
feed ); + connect( job, SIGNAL( result( KJob* ) ), this, SLOT( \
slotFeedImportDone( KJob* ) ) ); + }
+ d->m_pendingFeeds.clear();
+ }
+ else {
+ setError( OpmlParsingFailed );
+ setErrorText( d->m_reader.errorString() );
+ emitResult();
+ }
}
void ImportOpmlJob::slotFileResult( KJob *job )
@@ -334,11 +352,7 @@
kDebug() << "Setting tags:" << tags;
feed.setTags( tags );
- // push the feed to Akonadi
- kDebug() << "Importing new feed:" << feed.title();
- d->m_pendingJobs++;
- Akonadi::CollectionCreateJob *job = new Akonadi::CollectionCreateJob( feed \
);
- connect( job, SIGNAL( result( KJob* ) ), this, SLOT( slotFeedImportDone( \
KJob* ) ) ); + d->m_pendingFeeds.append( feed );
}
while ( !d->m_reader.atEnd() ) {
--- trunk/playground/pim/krss/resource/importopmljob.h #849945:849946
@@ -37,6 +37,7 @@
enum Error {
RootCollectionImportFailed = KJob::UserDefinedError,
OpmlReadFailed,
+ OpmlParsingFailed,
FeedImportFailed
};
--- trunk/playground/pim/krss/resource/tests/importopmljobtest.cpp #849945:849946
@@ -122,6 +122,19 @@
}
}
+void ImportOpmlJobTest::testBrokenOpml()
+{
+ Akonadi::Collection root( 2 );
+ const QString defaultTag = "Imported";
+
+ qDebug() << "Test data:" << TESTDATAPATH;
+ ImportOpmlJob *import = new ImportOpmlJob( QString( "%1/broken.opml" ).arg( \
TESTDATAPATH ), root, this ); + import->setDefaultTag( defaultTag );
+ QVERIFY( !import->exec() );
+ QVERIFY( import->error() == ImportOpmlJob::OpmlParsingFailed );
+ qDebug() << "The error is:" << import->errorString();
+}
+
void ImportOpmlJobTest::cleanupTestCase()
{
Akonadi::CollectionFetchJob *fetch = new Akonadi::CollectionFetchJob( \
Akonadi::Collection( 2 ),
--- trunk/playground/pim/krss/resource/tests/importopmljobtest.h #849945:849946
@@ -28,6 +28,7 @@
void initTestCase();
void testGoodOpml();
+ void testBrokenOpml();
void cleanupTestCase();
};
--- trunk/playground/pim/krss/resource/tests/testdata/broken.opml #849945:849946
@@ -4,12 +4,12 @@
<body>
<outline isOpen="true" id="86934463" text="Linux" >
- outline isOpen="true" id="1369658234" text="Planets" >
+ <outline isOpen="true" id="1369658234" text="Planets" >
<outline text="Planet KDE" title="Planet KDE" description="Planet KDE - \
http://planetKDE.org/" htmlUrl="http://planetKDE.org/" \
xmlUrl="http://planetkde.org/rss20.xml" />
-<outline id="2PLptx4quo" text="Planet Ubuntu" title="Planet Ubuntu" \
description="Planet Ubuntu - http://planet.ubuntu.com/" \
htmlUrl="http://planet.ubuntu.com/" xmlUrl="http://planet.ubuntu.com/rss20.xml" \
category="Linux,Ubuntu" /> +<outline id="2PLptx4quo" text="Planet Ubuntu" \
title="Planet Ubuntu" description="Planet Ubuntu - http://planet.ubuntu.com/" \
htmlUrl="http://planet.ubuntu.com/" xmlUrl="http://planet.ubuntu.com/rss20.xml" \
category="Linux,Ubuntu"
</outline>
</outline>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic