[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/akonadi/agents
From: Volker Krause <vkrause () kde ! org>
Date: 2009-10-01 10:01:39
Message-ID: 1254391299.824755.17397.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1029982 by vkrause:
- Move attachment indexing to the base class, we'll need that for KCal
attachments as well.
- Test for the availability of the Soprano backend for Strigi in the
self test in case the agent needs that.
- Keep the Strigi::IndexManager around for the entire agent lifetime
instead of reloading all Strigi plugins for every indexed item.
M +12 -1 CMakeLists.txt
M +2 -8 nepomuk_calendar_feeder/CMakeLists.txt
M +2 -8 nepomuk_contact_feeder/CMakeLists.txt
M +1 -10 nepomuk_email_feeder/CMakeLists.txt
M +3 -28 nepomuk_email_feeder/messageanalyzer.cpp
M +5 -6 nepomuk_email_feeder/messageanalyzer.h
M +2 -0 nepomuk_email_feeder/nepomukemailfeeder.cpp
M +37 -2 nepomukfeeder/nepomukfeederagentbase.cpp
M +20 -2 nepomukfeeder/nepomukfeederagentbase.h
--- trunk/KDE/kdepim/akonadi/agents/CMakeLists.txt #1029981:1029982
@@ -7,7 +7,18 @@
${CMAKE_CURRENT_SOURCE_DIR}/nepomukfeeder/nepomukfeederagentbase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nepomukfeeder/sparqlbuilder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nepomukfeeder/selectsparqlbuilder.cpp
- )
+ )
+ set( NEPOMUKFEEDER_SHARED_LIBS
+ niefast
+ ${SOPRANO_LIBRARIES}
+ ${KDE4_KDEUI_LIBRARY}
+ ${KDE4_KDECORE_LIBS}
+ ${KDEPIMLIBS_AKONADI_LIBS}
+ ${QT_QTCORE_LIBRARY}
+ ${QT_QTDBUS_LIBRARY}
+ ${NEPOMUK_LIBRARIES}
+ ${STRIGI_STREAMANALYZER_LIBRARY}
+ )
include( SopranoAddOntology )
add_subdirectory( nie_fast )
add_subdirectory( nepomukfeeder )
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_calendar_feeder/CMakeLists.txt \
#1029981:1029982 @@ -15,16 +15,10 @@
kde4_add_executable(akonadi_nepomuk_calendar_feeder RUN_UNINSTALLED \
nepomukcalendarfeeder.cpp ${NEPOMUKFEEDER_SHARED_SRCS} ${vocabulary_srcs})
target_link_libraries(akonadi_nepomuk_calendar_feeder
- niefast
- ${KDEPIMLIBS_AKONADI_LIBS}
- ${QT_QTCORE_LIBRARY}
- ${QT_QTDBUS_LIBRARY}
+ ${NEPOMUKFEEDER_SHARED_LIBS}
${KDEPIMLIBS_KCAL_LIBS}
- ${NEPOMUK_LIBRARIES}
- ${SOPRANO_LIBRARIES}
- ${KDE4_KDECORE_LIBS}
akonadi-kcal
- )
+)
install(TARGETS akonadi_nepomuk_calendar_feeder ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES nepomukcalendarfeeder.desktop DESTINATION \
"${CMAKE_INSTALL_PREFIX}/share/akonadi/agents")
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_contact_feeder/CMakeLists.txt \
#1029981:1029982 @@ -11,15 +11,9 @@
kde4_add_executable(akonadi_nepomuk_contact_feeder RUN_UNINSTALLED \
nepomukcontactfeeder.cpp ${NEPOMUKFEEDER_SHARED_SRCS} )
target_link_libraries(akonadi_nepomuk_contact_feeder
- niefast
- ${KDEPIMLIBS_AKONADI_LIBS}
- ${QT_QTCORE_LIBRARY}
- ${QT_QTDBUS_LIBRARY}
${KDEPIMLIBS_KABC_LIBS}
- ${NEPOMUK_LIBRARIES}
- ${SOPRANO_LIBRARIES}
- ${KDE4_KDECORE_LIBS}
- )
+ ${NEPOMUKFEEDER_SHARED_LIBS}
+)
install(TARGETS akonadi_nepomuk_contact_feeder ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES nepomukcontactfeeder.desktop DESTINATION \
"${CMAKE_INSTALL_PREFIX}/share/akonadi/agents")
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_email_feeder/CMakeLists.txt \
#1029981:1029982 @@ -20,17 +20,8 @@
kde4_add_executable(akonadi_nepomuk_email_feeder RUN_UNINSTALLED \
${akonadi_nepomuk_email_feeder_SRCS})
target_link_libraries(akonadi_nepomuk_email_feeder
- niefast
- ${SOPRANO_LIBRARIES}
- ${KDE4_KDEUI_LIBRARY}
- ${KDEPIMLIBS_AKONADI_LIBS}
- akonadi-kmime
- ${QT_QTCORE_LIBRARY}
- ${QT_QTDBUS_LIBRARY}
+ ${NEPOMUKFEEDER_SHARED_LIBS}
${KDEPIMLIBS_KMIME_LIBS}
- ${NEPOMUK_LIBRARIES}
- ${STRIGIQTDBUSCLIENT_LIBRARY}
- ${STRIGI_STREAMANALYZER_LIBRARY}
)
install(TARGETS akonadi_nepomuk_email_feeder ${INSTALL_TARGETS_DEFAULT_ARGS})
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_email_feeder/messageanalyzer.cpp \
#1029981:1029982 @@ -36,18 +36,11 @@
#include <Soprano/Model>
#include <Soprano/QueryResultIterator>
-#include <strigi/analyzerconfiguration.h>
-#include <strigi/analysisresult.h>
-#include <strigi/indexpluginloader.h>
-#include <strigi/indexmanager.h>
-#include <strigi/indexwriter.h>
-#include <strigi/streamanalyzer.h>
-#include <strigi/stringstream.h>
-
#include <boost/shared_ptr.hpp>
-MessageAnalyzer::MessageAnalyzer(const Akonadi::Item& item, const QUrl& graphUri, \
QObject* parent) : +MessageAnalyzer::MessageAnalyzer(const Akonadi::Item& item, const \
QUrl& graphUri, NepomukFeederAgentBase* parent) : QObject( parent ),
+ m_item( item ),
m_email( item.url(), graphUri ),
m_graphUri( graphUri )
{
@@ -134,28 +127,10 @@
if ( content->contentDescription( false ) && \
!content->contentDescription()->asUnicodeString().isEmpty() )
attachment.addProperty( Vocabulary::NIE::description(), Soprano::LiteralValue( \
content->contentDescription()->asUnicodeString() ) ); m_email.addAttachment( \
attachment );
- processAttachmentBody( attachmentUrl, content );
+ m_parent->indexData( attachmentUrl, content->decodedContent(), \
m_item.modificationTime() ); }
}
-void MessageAnalyzer::processAttachmentBody(const KUrl& url, KMime::Content* \
content)
-{
- const QByteArray decodedContent = content->decodedContent();
-
- Strigi::IndexManager* indexManager = \
Strigi::IndexPluginLoader::createIndexManager( "sopranobackend", 0 );
- Q_ASSERT( indexManager );
-
- Strigi::IndexWriter* writer = indexManager->indexWriter();
- Strigi::AnalyzerConfiguration ic;
- Strigi::StreamAnalyzer streamindexer( ic );
- streamindexer.setIndexWriter( *writer );
- Strigi::StringInputStream sr( decodedContent.constData(), decodedContent.size(), \
false );
- Strigi::AnalysisResult idx( url.url().toLatin1().constData(), \
QDateTime::currentDateTime().toTime_t(), *writer, streamindexer );
- idx.index( &sr );
-
- Strigi::IndexPluginLoader::deleteIndexManager( indexManager );
-}
-
QList< NepomukFast::Contact > MessageAnalyzer::extractContactsFromMailboxes(const \
KMime::Types::Mailbox::List& mbs, const QUrl&graphUri ) {
QList<NepomukFast::Contact> contacts;
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_email_feeder/messageanalyzer.h \
#1029981:1029982 @@ -24,6 +24,8 @@
#include <contact.h>
#include <email.h>
+#include <akonadi/item.h>
+
#include <kmime/kmime_headers.h>
#include <kmime/kmime_message.h>
@@ -32,10 +34,6 @@
class NepomukFeederAgentBase;
-namespace Akonadi {
- class Item;
-}
-
/**
Does the actual analysis of the email, split out from the feeder agent due to \
possibly asynchronous operations in the OTP, so we need to isolate state in case \
multiple items are processed at the same time. @@ -45,7 +43,7 @@
{
Q_OBJECT
public:
- MessageAnalyzer( const Akonadi::Item &item, const QUrl &graphUri, QObject* \
parent = 0 ); + MessageAnalyzer( const Akonadi::Item &item, const QUrl &graphUri, \
NepomukFeederAgentBase* parent = 0 );
inline QUrl graphUri() const { return m_graphUri; }
@@ -53,9 +51,10 @@
QList<NepomukFast::Contact> extractContactsFromMailboxes( const \
KMime::Types::Mailbox::List& mbs, const QUrl&graphUri ); void processHeaders( const \
KMime::Message::Ptr &msg ); void processPart( KMime::Content *content );
- void processAttachmentBody( const KUrl &url, KMime::Content *content );
private:
+ NepomukFeederAgentBase *m_parent;
+ Akonadi::Item m_item;
NepomukFast::Email m_email;
QUrl m_graphUri;
};
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_email_feeder/nepomukemailfeeder.cpp \
#1029981:1029982 @@ -35,6 +35,8 @@
addSupportedMimeType( "message/rfc822" );
addSupportedMimeType( "message/news" );
+ setNeedsStrigi( true );
+
changeRecorder()->itemFetchScope().fetchFullPayload();
}
--- trunk/KDE/kdepim/akonadi/agents/nepomukfeeder/nepomukfeederagentbase.cpp \
#1029981:1029982 @@ -44,6 +44,14 @@
#include <Soprano/Vocabulary/NAO>
+#include <strigi/analyzerconfiguration.h>
+#include <strigi/analysisresult.h>
+#include <strigi/indexpluginloader.h>
+#include <strigi/indexmanager.h>
+#include <strigi/indexwriter.h>
+#include <strigi/streamanalyzer.h>
+#include <strigi/stringstream.h>
+
#include <QtCore/QTimer>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusReply>
@@ -58,8 +66,10 @@
mProcessedAmount( 0 ),
mPendingJobs( 0 ),
mNrlModel( 0 ),
+ mStrigiIndexManager( 0 ),
mNepomukStartupAttempted( false ),
- mInitialUpdateDone( false )
+ mInitialUpdateDone( false ),
+ mNeedsStrigi( false )
{
// initialize Nepomuk
Nepomuk::ResourceManager::instance()->init();
@@ -74,12 +84,14 @@
connect( QDBusConnection::sessionBus().interface(), \
SIGNAL(serviceOwnerChanged(QString,QString,QString)), \
SLOT(serviceOwnerChanged(QString,QString,QString)) );
setOnline( false );
- selfTest();
+ QTimer::singleShot( 0, this, SLOT(selfTest()) );
}
NepomukFeederAgentBase::~NepomukFeederAgentBase()
{
delete mNrlModel;
+ if ( mStrigiIndexManager )
+ Strigi::IndexPluginLoader::deleteIndexManager( mStrigiIndexManager );
}
void NepomukFeederAgentBase::itemAdded(const Akonadi::Item& item, const \
Akonadi::Collection& collection) @@ -262,6 +274,13 @@
errorMessages.append( i18n( "Nepomuk is not running." ) );
}
+ // try to obtain a Strigi index manager with a Soprano backend
+ if ( !mStrigiIndexManager && mNeedsStrigi ) {
+ Strigi::IndexManager* indexManager = \
Strigi::IndexPluginLoader::createIndexManager( "sopranobackend", 0 ); + if ( \
!indexManager ) + errorMessages.append( i18n( "Soprano backend for Strigi is not \
available." ) ); + }
+
if ( errorMessages.isEmpty() ) {
setOnline( true );
mNepomukStartupAttempted = false; // everything worked, we can try again if the \
server goes down later @@ -341,4 +360,20 @@
return contact;
}
+void NepomukFeederAgentBase::setNeedsStrigi(bool enableStrigi)
+{
+ mNeedsStrigi = enableStrigi;
+}
+
+void NepomukFeederAgentBase::indexData(const KUrl& url, const QByteArray& data, \
const QDateTime& mtime) +{
+ Strigi::IndexWriter* writer = mStrigiIndexManager->indexWriter();
+ Strigi::AnalyzerConfiguration ic;
+ Strigi::StreamAnalyzer streamindexer( ic );
+ streamindexer.setIndexWriter( *writer );
+ Strigi::StringInputStream sr( data.constData(), data.size(), false );
+ Strigi::AnalysisResult idx( url.url().toLatin1().constData(), mtime.toTime_t(), \
*writer, streamindexer ); + idx.index( &sr );
+}
+
#include "nepomukfeederagentbase.moc"
--- trunk/KDE/kdepim/akonadi/agents/nepomukfeeder/nepomukfeederagentbase.h \
#1029981:1029982 @@ -43,7 +43,13 @@
#include <QStringList>
#include <QtCore/QTimer>
+#include <QtCore/QDateTime>
+namespace NepomukFast
+{
+ class PersonContact;
+}
+
namespace Akonadi
{
class Item;
@@ -54,9 +60,9 @@
class NRLModel;
}
-namespace NepomukFast
+namespace Strigi
{
- class PersonContact;
+ class IndexManager;
}
class KJob;
@@ -127,6 +133,16 @@
res.addProperty( Vocabulary::NIE::isPartOf(), \
entity.parentCollection().url() ); }
+ /**
+ Enables Strigi support for indexing attachments.
+ */
+ void setNeedsStrigi( bool enableStrigi );
+
+ /**
+ Index the given data with Strigi. Use for e.g. attachments.
+ */
+ void indexData( const KUrl &url, const QByteArray &data, const QDateTime &mtime \
= QDateTime::currentDateTime() ); +
public slots:
/** Trigger a complete update of all items. */
void updateAll();
@@ -160,8 +176,10 @@
int mTotalAmount, mProcessedAmount, mPendingJobs;
QTimer mNepomukStartupTimeout;
Soprano::NRLModel *mNrlModel;
+ Strigi::IndexManager *mStrigiIndexManager;
bool mNepomukStartupAttempted;
bool mInitialUpdateDone;
+ bool mNeedsStrigi;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic