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

List:       kde-commits
Subject:    branches/kdepim/enterprise/kdepim
From:       Allen Winter <winter () kde ! org>
Date:       2010-04-30 22:18:31
Message-ID: 20100430221831.C3EC6AC8AB () svn ! kde ! org
[Download RAW message or body]

SVN commit 1121244 by winterz:

Pass the sender email address back to the incidenceformatter when
constructing the bodypart invitation.

Now, use the sender address to determine if the sender is also
the invitation organizer and if not, then we tell folks that the
invitation was sent by a representative of the organizer.

kolab/issue4348
MERGE: trunk


 M  +1 -1      kmail/app_octetstream.cpp  
 M  +2 -1      kmail/bodypartformatter.cpp  
 M  +2 -2      kmail/interfaces/bodypartformatter.h  
 M  +3 -1      kmail/objecttreeparser.cpp  
 M  +71 -10    libkcal/incidenceformatter.cpp  
 M  +9 -2      libkcal/incidenceformatter.h  
 M  +3 -2      plugins/kmail/bodypartformatter/text_calendar.cpp  
 M  +1 -1      plugins/kmail/bodypartformatter/text_vcard.cpp  
 M  +1 -1      plugins/kmail/bodypartformatter/text_xdiff.cpp  


--- branches/kdepim/enterprise/kdepim/kmail/app_octetstream.cpp #1121243:1121244
@@ -38,7 +38,7 @@
 
   class Formatter : public KMail::Interface::BodyPartFormatter {
   public:
-    Result format( KMail::Interface::BodyPart *, KMail::HtmlWriter * ) const { \
return AsIcon; } +    Result format( KMail::Interface::BodyPart *, KMail::HtmlWriter \
*, KMail::Callback & ) const { return AsIcon; }  };
 
   class Plugin : public KMail::Interface::BodyPartFormatterPlugin {
--- branches/kdepim/enterprise/kdepim/kmail/bodypartformatter.cpp #1121243:1121244
@@ -39,6 +39,7 @@
 
 #include "objecttreeparser.h"
 #include "partNode.h"
+#include "callback.h"
 
 #include <mimelib/enum.h>
 #include <mimelib/string.h>
@@ -53,7 +54,7 @@
       public KMail::Interface::BodyPartFormatter {
     static const AnyTypeBodyPartFormatter * self;
   public:
-    Result format( KMail::Interface::BodyPart *, KMail::HtmlWriter * ) const {
+    Result format( KMail::Interface::BodyPart *, KMail::HtmlWriter *, \
                KMail::Callback & ) const {
       kdDebug(5006) << "AnyTypeBodyPartFormatter::format() acting as a \
KMail::Interface::BodyPartFormatter!" << endl;  return AsIcon;
     }
--- branches/kdepim/enterprise/kdepim/kmail/interfaces/bodypartformatter.h \
#1121243:1121244 @@ -35,7 +35,7 @@
 #define __KMAIL_INTERFACE_BODYPARTFORMATTER_H__
 
 namespace KMail {
-
+  class Callback;
   class HtmlWriter;
 
   namespace Interface {
@@ -61,7 +61,7 @@
 
 	 @return the result code (see above)
       */
-      virtual Result format( BodyPart * part, KMail::HtmlWriter * writer ) const = \
0; +      virtual Result format( BodyPart * part, KMail::HtmlWriter * writer,  \
Callback &c ) const = 0;  };
 
     /**
--- branches/kdepim/enterprise/kdepim/kmail/objecttreeparser.cpp #1121243:1121244
@@ -53,6 +53,7 @@
 #include "interfaces/bodypartformatter.h"
 #include "globalsettings.h"
 #include "util.h"
+#include "callback.h"
 
 // other module headers
 #include <mimelib/enum.h>
@@ -281,7 +282,8 @@
 
         writeAttachmentMarkHeader( node );
         node->setDisplayedEmbedded( true );
-        const Interface::BodyPartFormatter::Result result = formatter->format( \
&part, htmlWriter() ); +        Callback callback( mReader->message(), mReader );
+        const Interface::BodyPartFormatter::Result result = formatter->format( \
&part, htmlWriter(), callback );  writeAttachmentMarkFooter();
 #if 0
         // done in KMReaderWin::setBodyPartMemento() now
--- branches/kdepim/enterprise/kdepim/libkcal/incidenceformatter.cpp #1121243:1121244
@@ -134,6 +134,26 @@
   return iam;
 }
 
+static bool senderIsOrganizer( Incidence *incidence, const QString &sender )
+{
+  // Check if the specified sender is the organizer
+
+  if ( !incidence || sender.isEmpty() ) {
+    return true;
+  }
+
+  bool isorg = true;
+  QString senderName, senderEmail;
+  if ( KPIM::getNameAndMail( sender, senderName, senderEmail ) ) {
+    // for this heuristic, we say the sender is the organizer if either the name or \
the email match. +    if ( incidence->organizer().email() != senderEmail &&
+         incidence->organizer().name() != senderName ) {
+      isorg = false;
+    }
+  }
+  return isorg;
+}
+
 static QString firstAttendeeName( Incidence *incidence, const QString &defName )
 {
   QString name;
@@ -1499,7 +1519,7 @@
 */
 }
 
-static QString invitationHeaderEvent( Event *event, ScheduleMessage *msg )
+static QString invitationHeaderEvent( Event *event, ScheduleMessage *msg, const \
QString &sender )  {
   if ( !msg || !event )
     return QString::null;
@@ -1514,13 +1534,23 @@
     if ( iamOrganizer( event ) ) {
       return i18n( "I sent this invitation" );
     } else {
+      if ( senderIsOrganizer( event, sender ) ) {
       if ( !event->organizer().fullName().isEmpty() ) {
         return i18n( "You received an invitation from %1" ).
           arg( event->organizer().fullName() );
       } else {
         return i18n( "You received an invitation" );
       }
+      } else {
+        if ( !event->organizer().fullName().isEmpty() ) {
+          return i18n( "You received an invitation from %1 as a representative of \
%2" ). +            arg( sender, event->organizer().fullName() );
+        } else {
+          return i18n( "You received an invitation from %1 as the organizer's \
representative" ). +            arg( sender );
     }
+      }
+    }
   case Scheduler::Refresh:
     return i18n( "This invitation was refreshed" );
   case Scheduler::Cancel:
@@ -1616,7 +1646,7 @@
   return QString::null;
 }
 
-static QString invitationHeaderTodo( Todo *todo, ScheduleMessage *msg )
+static QString invitationHeaderTodo( Todo *todo, ScheduleMessage *msg, const QString \
&sender )  {
   if ( !msg || !todo ) {
     return QString::null;
@@ -1629,8 +1659,27 @@
     if ( todo->revision() > 0 ) {
       return i18n( "This task has been updated" );
     } else {
+      if ( iamOrganizer( todo ) ) {
+        return i18n( "This is a task I created" );
+      } else {
+        if ( senderIsOrganizer( todo, sender ) ) {
+          if ( !todo->organizer().fullName().isEmpty() ) {
+            return i18n( "You have been assigned this task by %1" ).
+              arg( todo->organizer().fullName() );
+          } else {
       return i18n( "You have been assigned this task" );
     }
+        } else {
+          if ( !todo->organizer().fullName().isEmpty() ) {
+            return i18n( "You have been assigned this task by %1 as a representative \
of %2" ). +              arg( sender, todo->organizer().fullName() );
+          } else {
+            return i18n( "You have been assigned this task by %1 as the organizer's \
representative" ). +              arg( sender );
+          }
+        }
+      }
+    }
   case Scheduler::Refresh:
     return i18n( "This task was refreshed" );
   case Scheduler::Cancel:
@@ -1898,9 +1947,10 @@
 {
   public:
     ScheduleMessageVisitor() : mMessage(0) { mResult = ""; }
-    bool act( IncidenceBase *incidence, ScheduleMessage *msg )
+    bool act( IncidenceBase *incidence, ScheduleMessage *msg, const QString &sender \
)  {
       mMessage = msg;
+      mSender = sender;
       return incidence->accept( *this );
     }
     QString result() const { return mResult; }
@@ -1908,6 +1958,7 @@
   protected:
     QString mResult;
     ScheduleMessage *mMessage;
+    QString mSender;
 };
 
 class IncidenceFormatter::InvitationHeaderVisitor
@@ -1916,12 +1967,12 @@
   protected:
     bool visit( Event *event )
     {
-      mResult = invitationHeaderEvent( event, mMessage );
+      mResult = invitationHeaderEvent( event, mMessage, mSender );
       return !mResult.isEmpty();
     }
     bool visit( Todo *todo )
     {
-      mResult = invitationHeaderTodo( todo, mMessage );
+      mResult = invitationHeaderTodo( todo, mMessage, mSender );
       return !mResult.isEmpty();
     }
     bool visit( Journal *journal )
@@ -2198,7 +2249,8 @@
 QString IncidenceFormatter::formatICalInvitationHelper( QString invitation,
                                                         Calendar *mCalendar,
                                                         InvitationFormatterHelper \
                *helper,
-                                                        bool noHtmlMode )
+                                                        bool noHtmlMode,
+                                                        const QString &sender )
 {
   if ( invitation.isEmpty() ) {
     return QString::null;
@@ -2249,12 +2301,12 @@
   html += tableHead;
   InvitationHeaderVisitor headerVisitor;
   // The InvitationHeaderVisitor returns false if the incidence is somehow invalid, \
                or not handled
-  if ( !headerVisitor.act( incBase, msg ) )
+  if ( !headerVisitor.act( incBase, msg, sender ) )
     return QString::null;
   html += "<b>" + headerVisitor.result() + "</b>";
 
   InvitationBodyVisitor bodyVisitor( noHtmlMode );
-  if ( !bodyVisitor.act( incBase, msg ) )
+  if ( !bodyVisitor.act( incBase, msg, sender ) )
     return QString::null;
   html += bodyVisitor.result();
 
@@ -2471,16 +2523,25 @@
                                                   Calendar *mCalendar,
                                                   InvitationFormatterHelper *helper \
)  {
-  return formatICalInvitationHelper( invitation, mCalendar, helper, false );
+  return formatICalInvitationHelper( invitation, mCalendar, helper, false, QString() \
);  }
 
 QString IncidenceFormatter::formatICalInvitationNoHtml( QString invitation,
                                                         Calendar *mCalendar,
                                                         InvitationFormatterHelper \
*helper )  {
-  return formatICalInvitationHelper( invitation, mCalendar, helper, true );
+  return formatICalInvitationHelper( invitation, mCalendar, helper, true, QString() \
);  }
 
+QString IncidenceFormatter::formatICalInvitationNoHtml( QString invitation,
+                                                        Calendar *mCalendar,
+                                                        InvitationFormatterHelper \
*helper, +                                                        const QString \
&sender ) +{
+  return formatICalInvitationHelper( invitation, mCalendar, helper, true, sender );
+}
+
+
 /*******************************************************************
  *  Helper functions for the msTNEF -> VPart converter
  *******************************************************************/
--- branches/kdepim/enterprise/kdepim/libkcal/incidenceformatter.h #1121243:1121244
@@ -65,8 +65,14 @@
 
     static QString formatICalInvitation( QString invitation, Calendar *mCalendar,
                                          InvitationFormatterHelper *helper );
-    static QString formatICalInvitationNoHtml( QString invitation, Calendar \
*mCalendar, +    static QString KDE_DEPRECATED formatICalInvitationNoHtml( QString \
invitation, +                                                              Calendar \
                *mCalendar,
                                                InvitationFormatterHelper *helper );
+    static QString formatICalInvitationNoHtml( QString invitation,
+                                               Calendar *mCalendar,
+                                               InvitationFormatterHelper *helper,
+                                               const QString &sender );
+
     // Format a TNEF attachment to an HTML mail
     static QString formatTNEFInvitation( const QByteArray& tnef,
                                          Calendar *mCalendar,
@@ -111,7 +117,8 @@
     static QString formatICalInvitationHelper( QString invitation,
                                                Calendar *mCalendar,
                                                InvitationFormatterHelper *helper,
-                                               bool noHtmlMode );
+                                               bool noHtmlMode,
+                                               const QString &sender );
     class EventViewerVisitor;
     class ScheduleMessageVisitor;
     class InvitationHeaderVisitor;
--- branches/kdepim/enterprise/kdepim/plugins/kmail/bodypartformatter/text_calendar.cpp \
#1121243:1121244 @@ -162,7 +162,7 @@
 {
   public:
     Result format( KMail::Interface::BodyPart *bodyPart,
-                   KMail::HtmlWriter *writer ) const
+                   KMail::HtmlWriter *writer, KMail::Callback &callback ) const
     {
       if ( !writer )
         // Guard against crashes in createReply()
@@ -179,7 +179,8 @@
       } else {
         source = bodyPart->asText();
       }
-      QString html = IncidenceFormatter::formatICalInvitationNoHtml( source, &cl, \
&helper ); +      QString html =
+        IncidenceFormatter::formatICalInvitationNoHtml( source, &cl, &helper, \
callback.sender() );  
       if ( html.isEmpty() ) return AsIcon;
       writer->queue( html );
--- branches/kdepim/enterprise/kdepim/plugins/kmail/bodypartformatter/text_vcard.cpp \
#1121243:1121244 @@ -67,7 +67,7 @@
       //mKIMProxy = ::KIMProxy::instance( kapp->dcopClient() );
     }
 
-    Result format( BodyPart *bodyPart, KMail::HtmlWriter *writer ) const {
+    Result format( BodyPart *bodyPart, KMail::HtmlWriter *writer, KMail::Callback & \
) const {  
        if ( !writer ) return AsIcon;
 
--- branches/kdepim/enterprise/kdepim/plugins/kmail/bodypartformatter/text_xdiff.cpp \
#1121243:1121244 @@ -59,7 +59,7 @@
 
   class Formatter : public KMail::Interface::BodyPartFormatter {
   public:
-    Result format( KMail::Interface::BodyPart *bodyPart, KMail::HtmlWriter *writer ) \
const { +    Result format( KMail::Interface::BodyPart *bodyPart, KMail::HtmlWriter \
*writer, KMail::Callback & ) const {  
       if ( !writer ) return Ok;
 


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

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