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

List:       kde-commits
Subject:    KDE/kdepim/nepomuk_email_feeder
From:       Volker Krause <vkrause () kde ! org>
Date:       2009-10-15 8:52:38
Message-ID: 1255596758.939427.26293.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1035495 by vkrause:

Tag messages accordingly if they have the important, todo or watched
flag set.


 M  +1 -0      CMakeLists.txt  
 M  +35 -5     messageanalyzer.cpp  
 M  +2 -0      messageanalyzer.h  


--- trunk/KDE/kdepim/nepomuk_email_feeder/CMakeLists.txt #1035494:1035495
@@ -27,6 +27,7 @@
 
 target_link_libraries(akonadi_nepomuk_email_feeder
   niefast_apps
+  messagecore
   ${SOPRANO_LIBRARIES}
   ${KDE4_KDEUI_LIBRARY}
   ${KDE4_KDECORE_LIBS}
--- trunk/KDE/kdepim/nepomuk_email_feeder/messageanalyzer.cpp #1035494:1035495
@@ -28,18 +28,24 @@
 #include <nmo.h>
 #include <mailboxdataobject.h>
 
+#include <messagecore/messagestatus.h>
+
 #include <akonadi/item.h>
 
 #include <kmime/kmime_message.h>
 
+#include <klocalizedstring.h>
+
 #include <Nepomuk/Resource>
 #include <Nepomuk/ResourceManager>
 #include <Nepomuk/Variant>
+#include <Nepomuk/Tag>
 
 #include <Soprano/Model>
 #include <Soprano/QueryResultIterator>
+#include <Soprano/Vocabulary/NAO>
 
-#include <boost/shared_ptr.hpp>
+// #include <boost/shared_ptr.hpp>
 
 MessageAnalyzer::MessageAnalyzer(const Akonadi::Item& item, const QUrl& graphUri, \
NepomukFeederAgentBase* parent) :  QObject( parent ),
@@ -51,10 +57,7 @@
 {
   NepomukFeederAgentBase::setParent( m_email, item );
 
-  // the \Seen flag is in MailboxDataObject instead of Email...
-  NepomukFast::MailboxDataObject mdb( item.url(), graphUri );
-  mdb.setIsReads( QList<bool>() << item.flags().contains( "\\Seen" ) );
-
+  processFlags( item.flags() );
   const KMime::Message::Ptr msg = item.payload<KMime::Message::Ptr>();
   processHeaders( msg );
 
@@ -168,4 +171,31 @@
   return contacts;
 }
 
+void MessageAnalyzer::processFlags(const Akonadi::Item::Flags& flags)
+{
+  KPIM::MessageStatus status;
+  status.setStatusFromFlags( flags );
+
+  // the \Seen flag is in MailboxDataObject instead of Email...
+  NepomukFast::MailboxDataObject mdb( m_item.url(), graphUri() );
+  mdb.setIsReads( QList<bool>() << status.isRead() );
+
+  if ( status.isImportant() )
+    addTranslatedTag( "important", i18n("Important") );
+  if ( status.isToAct() )
+    addTranslatedTag( "todo", i18n("To Do") );
+  if ( status.isWatched() )
+    addTranslatedTag( "watched", i18n("Watched") );
+}
+
+
+void MessageAnalyzer::addTranslatedTag(const char* tagName, const QString& tagLabel)
+{
+ Nepomuk::Tag tag( QString::fromLatin1( tagName ) );
+ if ( tag.label().isEmpty() )
+    tag.setLabel( tagLabel );
+  m_email.addProperty( Soprano::Vocabulary::NAO::hasTag(), tag.resourceUri() );
+}
+
+
 #include "messageanalyzer.moc"
--- trunk/KDE/kdepim/nepomuk_email_feeder/messageanalyzer.h #1035494:1035495
@@ -49,6 +49,8 @@
 
   private:
     QList<NepomukFast::Contact> extractContactsFromMailboxes( const \
KMime::Types::Mailbox::List& mbs, const QUrl&graphUri ); +    void addTranslatedTag( \
const char* tagName, const QString &tagLabel ); +    void processFlags( const \
Akonadi::Item::Flags &flags );  void processHeaders( const KMime::Message::Ptr &msg \
);  void processPart( KMime::Content *content );
 


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

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