[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-09-29 15:04:49
Message-ID: 1254236689.770070.12437.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1029335 by vkrause:

Factor out the actual message analysis code into its own class. This is
necessary to encapsulate the state once the analysis becomes
asynchronous and multiple of them might end up running in parallel 
(asynchronous operations will be introduced by the OTP when decrypting
messages). Long term this might even allow us to distribute the analysis
to multiple threads.


 M  +1 -1      nepomuk_email_feeder/CMakeLists.txt  
 A             nepomuk_email_feeder/messageanalyzer.cpp   [License: LGPL (v2+)]
 A             nepomuk_email_feeder/messageanalyzer.h   [License: LGPL (v2+)]
 M  +4 -86     nepomuk_email_feeder/nepomukemailfeeder.cpp  
 M  +0 -4      nepomuk_email_feeder/nepomukemailfeeder.h  
 M  +1 -7      nepomukfeeder/nepomukfeederagent.h  
 M  +9 -1      nepomukfeeder/nepomukfeederagentbase.h  


--- trunk/KDE/kdepim/akonadi/agents/nepomuk_email_feeder/CMakeLists.txt \
#1029334:1029335 @@ -7,7 +7,7 @@
 set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}" )
 add_definitions(-DNEPOMUK_RESOURCE_STATIC)
 
-set(akonadi_nepomuk_email_feeder_SRCS nepomukemailfeeder.cpp \
${NEPOMUKFEEDER_SHARED_SRCS}) +set(akonadi_nepomuk_email_feeder_SRCS \
nepomukemailfeeder.cpp messageanalyzer.cpp ${NEPOMUKFEEDER_SHARED_SRCS})  
 kde4_add_app_icon(akonadi_nepomuk_email_feeder_SRCS \
"${KDE4_ICON_DIR}/oxygen/*/apps/nepomuk.png")  
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_email_feeder/nepomukemailfeeder.cpp \
#1029334:1029335 @@ -19,29 +19,14 @@
 */
 
 #include "nepomukemailfeeder.h"
-#include "email.h"
-#include "personcontact.h"
-#include "selectsqarqlbuilder.h"
+#include "messageanalyzer.h"
 
+#include <kmime/kmime_message.h>
+
 #include <akonadi/changerecorder.h>
 #include <akonadi/item.h>
 #include <akonadi/itemfetchscope.h>
-#include <akonadi/kmime/messageparts.h>
 
-#include <kmime/kmime_message.h>
-#include <kmime/kmime_content.h>
-#include <boost/shared_ptr.hpp>
-
-#include <Nepomuk/Resource>
-#include <Nepomuk/ResourceManager>
-#include <Nepomuk/Variant>
-#include <kurl.h>
-
-#include <Soprano/Model>
-#include <Soprano/QueryResultIterator>
-#include <Soprano/Vocabulary/NAO>
-#include <Soprano/Vocabulary/XMLSchema>
-
 using namespace Akonadi;
 
 Akonadi::NepomukEMailFeeder::NepomukEMailFeeder( const QString &id ) :
@@ -53,80 +38,13 @@
   changeRecorder()->itemFetchScope().fetchFullPayload();
 }
 
-NepomukEMailFeeder::~NepomukEMailFeeder()
-{
-}
-
 void NepomukEMailFeeder::updateItem(const Akonadi::Item & item, const QUrl \
&graphUri)  {
   if ( !item.hasPayload<KMime::Message::Ptr>() )
     return;
-  const KMime::Message::Ptr msg = item.payload<KMime::Message::Ptr>();
-
-  // FIXME: make a distinction between email and news
-  NepomukFast::Email r( item.url(), graphUri );
-  setParent( r, item );
-
-  if ( msg->subject( false ) ) {
-    r.setMessageSubject( msg->subject()->asUnicodeString() );
-    r.setLabel( msg->subject()->asUnicodeString() );
-  }
-
-  if ( msg->date( false ) ) {
-    r.setReceivedDate( msg->date()->dateTime().dateTime() );
-  }
-
-  if ( msg->from( false ) ) {
-    r.setFroms( extractContactsFromMailboxes( msg->from()->mailboxes(), graphUri ) \
                );
-  }
-
-  if ( msg->sender( false ) )
-    r.setSenders( extractContactsFromMailboxes( msg->sender()->mailboxes(), graphUri \
                ) );
-
-  if ( msg->to( false ) ) {
-    r.setTos( extractContactsFromMailboxes( msg->to()->mailboxes(), graphUri ) );
-  }
-
-  if ( msg->cc( false ) ) {
-    r.setCcs( extractContactsFromMailboxes( msg->cc()->mailboxes(), graphUri ) );
-  }
-
-  if ( msg->bcc( false ) ) {
-    r.setBccs( extractContactsFromMailboxes( msg->bcc()->mailboxes(), graphUri ) );
-  }
-
-  KMime::Content* content = msg->mainBodyPart( "text/plain" );
-
-  // FIXME: simplyfy this text as in: remove all html tags. Is there a quick way to \
                do this?
-  if ( content ) {
-    const QString text = content->decodedText( true, true );
-    if ( !text.isEmpty() ) {
-      r.setPlainTextMessageContents( QStringList( text ) );
-    }
-  }
-
-  if ( msg->messageID( false ) ) {
-    r.setMessageIds( QStringList( msg->messageID()->asUnicodeString() ) );
-  }
-
-  // IDEA: use Strigi to index the attachments
+  new MessageAnalyzer( item, graphUri, this );
 }
 
-QList<NepomukFast::Contact> NepomukEMailFeeder::extractContactsFromMailboxes( const \
                KMime::Types::Mailbox::List& mbs,
-                                                                              const \
                QUrl &graphUri )
-{
-  QList<NepomukFast::Contact> contacts;
-
-  foreach( const KMime::Types::Mailbox& mbox, mbs ) {
-    if ( mbox.hasAddress() ) {
-      const NepomukFast::Contact c = findOrCreateContact( QString::fromLatin1( \
                mbox.address() ), mbox.name(), graphUri );
-      contacts << c;
-    }
-  }
-
-  return contacts;
-}
-
 AKONADI_AGENT_MAIN( NepomukEMailFeeder )
 
 #include "nepomukemailfeeder.moc"
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_email_feeder/nepomukemailfeeder.h \
#1029334:1029335 @@ -37,12 +37,8 @@
   Q_OBJECT
   public:
     NepomukEMailFeeder( const QString &id );
-    ~NepomukEMailFeeder();
 
     void updateItem( const Akonadi::Item &item, const QUrl &graphUri );
-
-  private:
-    QList<NepomukFast::Contact> extractContactsFromMailboxes( const \
KMime::Types::Mailbox::List& mbs, const QUrl& );  };
 
 }
--- trunk/KDE/kdepim/akonadi/agents/nepomukfeeder/nepomukfeederagent.h \
#1029334:1029335 @@ -25,6 +25,7 @@
 #include "nie.h"
 #include <akonadi/collection.h>
 #include <akonadi/entitydisplayattribute.h>
+#include <KDE/KUrl>
 #include <Soprano/Vocabulary/NAO>
 
 /** Template part of the shared base class, split out of NepomukFeederAgentBase \
since moc can't handle templates. */ @@ -47,13 +48,6 @@
       setParent( r, collection );
     }
 
-    template <typename R, typename E>
-    void setParent( R& res, const E &entity )
-    {
-      if ( entity.parentCollection().isValid() && entity.parentCollection() != \
                Akonadi::Collection::root() )
-        res.addProperty( Vocabulary::NIE::isPartOf(), \
                entity.parentCollection().url() );
-    }
-
     void itemMoved(const Akonadi::Item& item, const Akonadi::Collection& \
collectionSource, const Akonadi::Collection& collectionDestination)  {
       entityMoved( item, collectionSource, collectionDestination );
--- trunk/KDE/kdepim/akonadi/agents/nepomukfeeder/nepomukfeederagentbase.h \
#1029334:1029335 @@ -24,6 +24,7 @@
 
 #include "selectsqarqlbuilder.h"
 #include "resource.h"
+#include <nie.h>
 
 #include <akonadi/agentbase.h>
 #include <akonadi/collection.h>
@@ -117,8 +118,15 @@
         @param found Used to indicate if the contact is already there are was just \
newly created. In the latter case you might  want to add additional information you \
                have available for it.
     */
-    NepomukFast::PersonContact findOrCreateContact( const QString &email, const \
QString &name, const QUrl &graphUri, bool *found = 0 ); +    static \
NepomukFast::PersonContact findOrCreateContact( const QString &email, const QString \
&name, const QUrl &graphUri, bool *found = 0 );  
+    template <typename R, typename E>
+    static void setParent( R& res, const E &entity )
+    {
+      if ( entity.parentCollection().isValid() && entity.parentCollection() != \
Akonadi::Collection::root() ) +        res.addProperty( Vocabulary::NIE::isPartOf(), \
entity.parentCollection().url() ); +    }
+
   public slots:
     /** Trigger a complete update of all items. */
     void updateAll();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic