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

List:       kde-commits
Subject:    branches/kdepim/enterprise4/kdepim
From:       Thomas McGuire <mcguire () kde ! org>
Date:       2009-07-17 9:11:54
Message-ID: 1247821914.982171.31558.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 998236 by tmcguire:

Revert the following commit, as Allen says it breaks things for him.

------------------------------------------------------------------------
r997532 | tmcguire | 2009-07-16 00:52:35 +0200 (Thu, 16 Jul 2009) | 9 lines

Crossport r997204 by mlaurent from trunk to the enterprise4 branch:

Fix kolab issue 3739
(Inform when we use a distribution list empty)

and fix duplication code.



------------------------------------------------------------------------


 M  +22 -3     kmail/identitydialog.cpp  
 M  +27 -9     kmail/kmcomposewin.cpp  
 M  +7 -0      kmail/kmcomposewin.h  
 M  +4 -9      kmail/kmmessage.cpp  
 M  +1 -1      kmail/kmmessage.h  
 M  +0 -1      kmail/tests/CMakeLists.txt  
 M  +1 -29     kmail/util.cpp  
 M  +0 -9      kmail/util.h  
 M  +3 -5      libkdepim/kaddrbookexternal.cpp  
 M  +1 -1      libkdepim/kaddrbookexternal.h  


--- branches/kdepim/enterprise4/kdepim/kmail/identitydialog.cpp #998235:998236
@@ -45,7 +45,7 @@
 #include "kmfolder.h"
 #include "templatesconfiguration.h"
 #include "templatesconfiguration_kfg.h"
-#include "util.h"
+
 // other kdepim headers:
 #include <kpimidentities/identity.h>
 #include <kpimidentities/signatureconfigurator.h>
@@ -525,6 +525,25 @@
     }
   }
 
+  bool IdentityDialog::validateAddresses( const QString &addresses )
+  {
+    QString brokenAddress;
+
+    KPIMUtils::EmailParseResult errorCode =
+      KPIMUtils::isValidAddressList( KMMessage::expandAliases( addresses ),
+                                     brokenAddress );
+    if ( !( errorCode == KPIMUtils::AddressOk ||
+            errorCode == KPIMUtils::AddressEmpty ) ) {
+      QString errorMsg( "<qt><p><b>" + brokenAddress +
+                        "</b></p><p>" +
+                        KPIMUtils::emailParseResultToString( errorCode ) +
+                        "</p></qt>" );
+      KMessageBox::sorry( this, errorMsg, i18n("Invalid Email Address") );
+      return false;
+    }
+    return true;
+  }
+
   void IdentityDialog::slotButtonClicked( int button )
   {
     if ( button != KDialog::Ok ) {
@@ -541,11 +560,11 @@
       return;
     }
 
-    if ( !Util::validateAddresses( this, mReplyToEdit->text().trimmed() ) ) {
+    if ( !validateAddresses( mReplyToEdit->text().trimmed() ) ) {
       return;
     }
 
-    if ( !Util::validateAddresses( this, mBccEdit->text().trimmed() ) ) {
+    if ( !validateAddresses( mBccEdit->text().trimmed() ) ) {
       return;
     }
 
--- branches/kdepim/enterprise4/kdepim/kmail/kmcomposewin.cpp #998235:998236
@@ -71,7 +71,6 @@
 #include "recipientseditor.h"
 #include "replyphrases.h"
 #include "stl_util.h"
-#include "util.h"
 
 using KMail::AttachmentListView;
 using KPIM::DictionaryComboBox;
@@ -3466,6 +3465,25 @@
 }
 
 //----------------------------------------------------------------------------
+bool KMComposeWin::validateAddresses( QWidget *parent, const QString &addresses )
+{
+  QString brokenAddress;
+  KPIMUtils::EmailParseResult errorCode =
+    KPIMUtils::isValidAddressList( KMMessage::expandAliases( addresses ),
+                                   brokenAddress );
+  if ( !( errorCode == KPIMUtils::AddressOk ||
+          errorCode == KPIMUtils::AddressEmpty ) ) {
+    QString errorMsg( "<qt><p><b>" + brokenAddress +
+                      "</b></p><p>" +
+                      KPIMUtils::emailParseResultToString( errorCode ) +
+                      "</p></qt>" );
+    KMessageBox::sorry( parent, errorMsg, i18n("Invalid Email Address") );
+    return false;
+  }
+  return true;
+}
+
+//----------------------------------------------------------------------------
 void KMComposeWin::doSend( KMail::MessageSender::SendMethod method,
                            KMComposeWin::SaveIn saveIn )
 {
@@ -3513,15 +3531,15 @@
     }
 
     // Validate the To:, CC: and BCC fields
-    if ( !KMail::Util::validateAddresses( this, to().trimmed() ) ) {
+    if ( !validateAddresses( this, to().trimmed() ) ) {
       return;
     }
 
-    if ( !KMail::Util::validateAddresses( this, cc().trimmed() ) ) {
+    if ( !validateAddresses( this, cc().trimmed() ) ) {
       return;
     }
 
-    if ( !KMail::Util::validateAddresses( this, bcc().trimmed() ) ) {
+    if ( !validateAddresses( this, bcc().trimmed() ) ) {
       return;
     }
 
@@ -3677,7 +3695,7 @@
     mDisableBreaking = false;
     return;
   }
-  bool listIsEmpty;
+
   for ( QVector<KMMessage*>::iterator it = mComposedMessages.begin() ; it != \
mComposedMessages.end() ; ++it ) {  
     // remove fields that contain no data (e.g. an empty Cc: or Bcc:)
@@ -3691,14 +3709,14 @@
     } else if ( mSaveIn == KMComposeWin::Templates ) {
       sentOk = saveDraftOrTemplate( (*it)->templates(), (*it) );
     } else {
-      (*it)->setTo( KMMessage::expandAliases( to(), listIsEmpty ));
-      (*it)->setCc( KMMessage::expandAliases( cc(), listIsEmpty ));
+      (*it)->setTo( KMMessage::expandAliases( to() ));
+      (*it)->setCc( KMMessage::expandAliases( cc() ));
       if ( !mComposer->originalBCC().isEmpty() ) {
-        (*it)->setBcc( KMMessage::expandAliases( \
mComposer->originalBCC(),listIsEmpty ) ); +        (*it)->setBcc( \
KMMessage::expandAliases( mComposer->originalBCC() ) );  }
       QString recips = (*it)->headerField( "X-KMail-Recipients" );
       if ( !recips.isEmpty() ) {
-        (*it)->setHeaderField( "X-KMail-Recipients", KMMessage::expandAliases( \
recips,listIsEmpty ), KMMessage::Address ); +        (*it)->setHeaderField( \
"X-KMail-Recipients", KMMessage::expandAliases( recips ), KMMessage::Address );  }
       (*it)->cleanupHeader();
       sentOk = kmkernel->msgSender()->send( (*it), mSendMethod );
--- branches/kdepim/enterprise4/kdepim/kmail/kmcomposewin.h #998235:998236
@@ -685,6 +685,13 @@
     void cleanupAutoSave();
 
     /**
+     * Validates a list of email addresses.
+     * @return true if all addresses are valid.
+     * @return false if one or several addresses are invalid.
+     */
+    static bool validateAddresses( QWidget *parent, const QString &addresses );
+
+    /**
      * Helper to insert the signature of the current identity arbitrarily
      * in the editor, connecting slot functions to KMeditor::insertSignature().
      * @param placement the position of the signature
--- branches/kdepim/enterprise4/kdepim/kmail/kmmessage.cpp #998235:998236
@@ -3855,7 +3855,7 @@
 
 //-----------------------------------------------------------------------------
 //static
-QString KMMessage::expandAliases( const QString& recipients, bool \
&distributionListIsEmpty ) +QString KMMessage::expandAliases( const QString& \
recipients )  {
   if ( recipients.isEmpty() )
     return QString();
@@ -3869,14 +3869,9 @@
       expandedRecipients += ", ";
     QString receiver = (*it).trimmed();
 
-     // try to expand distribution list
-    QString expandedList = KPIM::KAddrBookExternal::expandDistributionList( \
                receiver, distributionListIsEmpty );
-    if ( distributionListIsEmpty ) {
-      expandedRecipients += receiver;
-      continue;
-    }
-
-    if ( !expandedList.isEmpty()) {
+    // try to expand distribution list
+    QString expandedList = KPIM::KAddrBookExternal::expandDistributionList( receiver \
); +    if ( !expandedList.isEmpty() ) {
       expandedRecipients += expandedList;
       continue;
     }
--- branches/kdepim/enterprise4/kdepim/kmail/kmmessage.h #998235:998236
@@ -712,7 +712,7 @@
   /** Expands aliases (distribution lists and nick names) and appends a
       domain part to all email addresses which are missing the domain part.
   */
-  static QString expandAliases( const QString& recipients, bool \
&distributionListIsEmpty ); +  static QString expandAliases( const QString& \
recipients );  
   /** Uses the hostname as domain part and tries to determine the real name
       from the entries in the password file.
--- branches/kdepim/enterprise4/kdepim/kmail/tests/CMakeLists.txt #998235:998236
@@ -1,7 +1,6 @@
 set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
 # This can be used for finding data files in the source dir, without installing them
 add_definitions( -DKDESRCDIR=\\"${CMAKE_CURRENT_SOURCE_DIR}\\" )
-add_definitions(-DKMAIL_UNITTESTS=YES)
 
 include_directories( ${CMAKE_SOURCE_DIR}/mimelib ${CMAKE_SOURCE_DIR}/kmail  )
 
--- branches/kdepim/enterprise4/kdepim/kmail/util.cpp #998235:998236
@@ -38,10 +38,9 @@
 
 
 #include "util.h"
-#include "kmmessage.h"
+
 #include <stdlib.h>
 #include <mimelib/string.h>
-#include <kpimutils/email.h>
 
 size_t KMail::Util::crlf2lf( char* str, const size_t strLen )
 {
@@ -123,33 +122,6 @@
   return true;
 }
 
-#ifndef KMAIL_UNITTESTS
-bool KMail::Util::validateAddresses( QWidget *parent, const QString &addresses )
-{
-  QString brokenAddress;
-
-  bool distributionListIsEmpty;
-  KPIMUtils::EmailParseResult errorCode =
-    KPIMUtils::isValidAddressList( KMMessage::expandAliases( \
                addresses,distributionListIsEmpty ),
-                                   brokenAddress );
-  if ( distributionListIsEmpty ) {
-    QString errorMsg = i18n( "Distribution list \"addresses\" is empty. You can not \
                use it.",addresses );
-    KMessageBox::sorry( parent , errorMsg, i18n("Invalid Email Address") );
-    return false;
-  }
-  if ( !( errorCode == KPIMUtils::AddressOk ||
-          errorCode == KPIMUtils::AddressEmpty ) ) {
-    QString errorMsg( "<qt><p><b>" + brokenAddress +
-                      "</b></p><p>" +
-                      KPIMUtils::emailParseResultToString( errorCode ) +
-                      "</p></qt>" );
-    KMessageBox::sorry( parent , errorMsg, i18n("Invalid Email Address") );
-    return false;
-  }
-  return true;
-}
-#endif
-
 #ifdef Q_WS_MACX
 #include <QDesktopServices>
 #endif
--- branches/kdepim/enterprise4/kdepim/kmail/util.h #998235:998236
@@ -95,16 +95,7 @@
      */
     DwString dwString( const QByteArray& str );
 
-
     /**
-     * Validates a list of email addresses.
-     * @return true if all addresses are valid.
-     * @return false if one or several addresses are invalid.
-     */
-    bool validateAddresses( QWidget *parent, const QString &addresses );
-
-
-    /**
      * A LaterDeleter is intended to be used with the RAII ( Resource
      * Acquisiation is Initialization ) paradigm. When an instance of it
      * goes out of scope it deletes the associated object  It can be
--- branches/kdepim/enterprise4/kdepim/libkdepim/kaddrbookexternal.cpp #998235:998236
@@ -189,7 +189,7 @@
   return saved;
 }
 
-QString KAddrBookExternal::expandDistributionList( const QString &listName,bool \
&emptyList ) +QString KAddrBookExternal::expandDistributionList( const QString \
&listName )  {
   if ( listName.isEmpty() ) {
     return QString();
@@ -198,11 +198,9 @@
   const QString lowerListName = listName.toLower();
   KABC::AddressBook *addressBook = KABC::StdAddressBook::self( true );
   KABC::DistributionList* list = addressBook->findDistributionListByName( listName, \
Qt::CaseInsensitive ); +
   if ( list ) {
-    const QString listOfEmails = list->emails().join( ", " );
-    emptyList = listOfEmails.isEmpty();
-    return listOfEmails;
+    return list->emails().join( ", " );
   }
-  emptyList = false;
   return QString();
 }
--- branches/kdepim/enterprise4/kdepim/libkdepim/kaddrbookexternal.h #998235:998236
@@ -37,7 +37,7 @@
 
     static bool addVCard( const KABC::Addressee &addressee, QWidget *parent );
 
-    static QString expandDistributionList( const QString &listName,bool &emptyList \
); +    static QString expandDistributionList( const QString &listName );
 
   private:
     static bool addAddressee( const KABC::Addressee &addressee );


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

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