From kde-commits Fri Dec 31 18:49:58 2004 From: Matt Douhan Date: Fri, 31 Dec 2004 18:49:58 +0000 To: kde-commits Subject: kdepim/kmail Message-Id: <20041231184958.E75521A14E () office ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=110451900629549 CVS commit by mdouhan: Refactor the validation code to utilise the isValidEmailAddress Approved by: Till M +7 -17 identitydialog.cpp 1.49 --- kdepim/kmail/identitydialog.cpp #1.48:1.49 @@ -80,4 +80,6 @@ using KMail::FolderRequester; #include +using namespace KPIM; + namespace KMail { @@ -436,22 +438,10 @@ namespace KMail { } - void IdentityDialog::slotOk() { +void IdentityDialog::slotOk() { const QString email = mEmailEdit->text().stripWhiteSpace(); - int atCount = email.contains('@'); - if ( KPIM::getEmailAddr( email ).isEmpty() || atCount == 0 ) { - KMessageBox::sorry( this, ""+ - i18n("Your email address is not valid because it " - "does not contain a @: " - "you will not create valid messages if you do not " - "change your address.") + "", - i18n("Invalid Email Address") ); - return; - } else if ( atCount > 1 ) { - KMessageBox::sorry( this, "" + - i18n("Your email address is not valid because it " - "contains more than one @: " - "you will not create valid messages if you do not " - "change your address.") + "", - i18n("Invalid Email Address") ); + emailParseResult errorCode = isValidEmailAddress( email ); + if ( errorCode != AddressOk ) { + QString errorMsg( emailParseResultToString( errorCode )); + KMessageBox::sorry( this, errorMsg, i18n("Invalid Email Address") ); return; }