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

List:       kde-pim
Subject:    [Kde-pim] email address patch
From:       Mark Zealey <mspam () zealey ! org>
Date:       2005-03-30 22:07:17
Message-ID: 200503302307.18009.mspam () zealey ! org
[Download RAW message or body]

Hi guys,

Would someone be able to apply this patch? I've been using it for a month or 
two and its working fine - it colours an email address the colour of a 
visited link if it's in the address book, which I find very useful and I'm 
sure others would too.

Mark

["kmail_known_emails.patch" (text/x-diff)]

diff -urN kdepim_old/kmail/configuredialog.cpp kdepim/kmail/configuredialog.cpp
--- kdepim_old/kmail/configuredialog.cpp	2005-01-06 12:25:57.000000000 +0000
+++ kdepim/kmail/configuredialog.cpp	2005-01-06 11:36:28.000000000 +0000
@@ -1651,6 +1651,8 @@
   { "QuotedText1", I18N_NOOP("Quoted Text - First Level") },
   { "QuotedText2", I18N_NOOP("Quoted Text - Second Level") },
   { "QuotedText3", I18N_NOOP("Quoted Text - Third Level") },
+  { "KnownEmailColor", I18N_NOOP("Known Email address") },
+  { "UnknownEmailColor", I18N_NOOP("Unknown Email address") },
   { "LinkColor", I18N_NOOP("Link") },
   { "FollowedColor", I18N_NOOP("Followed Link") },
   { "MisspelledColor", I18N_NOOP("Misspelled Words") },
@@ -1721,6 +1723,8 @@
     QColor( 0x00, 0x80, 0x00 ), // quoted l1
     QColor( 0x00, 0x70, 0x00 ), // quoted l2
     QColor( 0x00, 0x60, 0x00 ), // quoted l3
+    KGlobalSettings::visitedLinkColor(), // known email address
+    KGlobalSettings::linkColor(), // unkwnown email address
     KGlobalSettings::linkColor(), // link
     KGlobalSettings::visitedLinkColor(), // visited link
     Qt::red, // misspelled words
diff -urN kdepim_old/kmail/csshelper.cpp kdepim/kmail/csshelper.cpp
--- kdepim_old/kmail/csshelper.cpp	2005-01-06 12:25:57.000000000 +0000
+++ kdepim/kmail/csshelper.cpp	2005-01-06 11:42:26.000000000 +0000
@@ -87,7 +87,7 @@
     bool mRecycleQuoteColors;
     bool mBackingPixmapOn;
     QString mBackingPixmapStr;
-    QColor c1, c2, c3, c4;
+    QColor c1, c2, c3, c4, c5, c6;
     // colors for PGP (Frame, Header, Body)
     QColor cPgpOk1F, cPgpOk1H, cPgpOk1B,
       cPgpOk0F, cPgpOk0H, cPgpOk0B,
@@ -111,6 +111,7 @@
       mBackingPixmapOn == other.mBackingPixmapOn &&
       mBackingPixmapStr == other.mBackingPixmapStr &&
       c1 == other.c1 && c2 == other.c2 && c3 == other.c3 && c4 == other.c4 &&
+      c5 == other.c5 && c6 == other.c6 &&
       cHtmlWarning == other.cHtmlWarning &&
       cPgpOk1F == other.cPgpOk1F && cPgpOk1H == other.cPgpOk1H && cPgpOk1B == other.cPgpOk1B &&
       cPgpOk0F == other.cPgpOk0F && cPgpOk0H == other.cPgpOk0H && cPgpOk0B == other.cPgpOk0B &&
@@ -157,6 +158,8 @@
     c2 = KGlobalSettings::linkColor();
     c3 = KGlobalSettings::visitedLinkColor();
     c4 = QApplication::palette().active().base();
+    c5 = KGlobalSettings::visitedLinkColor();
+    c6 = KGlobalSettings::linkColor();
     cHtmlWarning = QColor( 0xFF, 0x40, 0x40 ); // warning frame color: light red
 
     // The default colors are also defined in configuredialog.cpp
@@ -175,6 +178,8 @@
       c2 = reader.readColorEntry("LinkColor",&c2);
       c3 = reader.readColorEntry("FollowedColor",&c3);
       c4 = reader.readColorEntry("BackgroundColor",&c4);
+      c5 = reader.readColorEntry("KnownEmailColor",&c5);
+      c6 = reader.readColorEntry("UnknownEmailColor",&c6);
       cPgpEncrH = reader.readColorEntry( "PGPMessageEncr", &cPgpEncrH );
       cPgpOk1H  = reader.readColorEntry( "PGPMessageOkKeyOk", &cPgpOk1H );
       cPgpOk0H  = reader.readColorEntry( "PGPMessageOkKeyBad", &cPgpOk0H );
@@ -418,6 +423,8 @@
     const QString fgColor = c1.name();
     const QString bgColor = c4.name();
     const QString linkColor = c2.name();
+    const QString knownEmailColor = c5.name();
+    const QString unknownEmailColor = c6.name();
     const QString headerFont = QString("  font-family: \"%1\" ! important;\n"
 				       "  font-size: %2px ! important;\n")
       .arg( mBodyFont.family() )
@@ -486,6 +493,15 @@
 	       "}\n\n" )
       .arg( linkColor, fgColor, bgColor, headerFont )
       +
+      QString( "a.knownEmail {\n"
+	       "  color: %5 ! important;\n"
+	       "}\n\n"
+
+	       "a.unknownEmail {\n"
+	       "  color: %6 ! important;\n"
+	       "}\n\n" )
+      .arg( knownEmailColor, unknownEmailColor )
+      +
       QString( "table.encr {\n"
 	       "  background-color: %1 ! important;\n"
 	       "}\n\n"
diff -urN kdepim_old/kmail/kmmainwidget.cpp kdepim/kmail/kmmainwidget.cpp
--- kdepim_old/kmail/kmmainwidget.cpp	2005-01-06 12:25:57.000000000 +0000
+++ kdepim/kmail/kmmainwidget.cpp	2005-01-06 12:06:33.000000000 +0000
@@ -2052,6 +2052,10 @@
       mMsgView->mailToForwardAction()->plug( menu );
       menu->insertSeparator();
       mMsgView->addAddrBookAction()->plug( menu );
+      if( KAddrBookExternal::isInAddressBook(aUrl.path()) )
+        mMsgView->addAddrBookAction()->setEnabled( false );
+      else
+        mMsgView->addAddrBookAction()->setEnabled( true );
       mMsgView->openAddrBookAction()->plug( menu );
       mMsgView->copyURLAction()->plug( menu );
       mMsgView->startImChatAction()->plug( menu );
diff -urN kdepim_old/kmail/kmmessage.cpp kdepim/kmail/kmmessage.cpp
--- kdepim_old/kmail/kmmessage.cpp	2005-01-06 12:25:58.000000000 +0000
+++ kdepim/kmail/kmmessage.cpp	2005-01-06 11:38:24.000000000 +0000
@@ -3893,12 +3893,19 @@
 
   QString result;
 
+  // Make sure we've got the latest address book loaded
+  KAddrBookExternal::reloadAddressBook();
+
   for( QStringList::ConstIterator it = addressList.begin();
        ( it != addressList.end() );
        ++it ) {
     if( !(*it).isEmpty() ) {
       QString address = *it;
-      result += "<a href=\"mailto:"
+      QString type = "unknownEmail";
+      if( KAddrBookExternal::isInAddressBook(address) )
+	      type = "knownEmail";
+
+      result += "<a class=\"" + type + "\" href=\"mailto:"
               + KMMessage::encodeMailtoUrl( address )
               + "\">";
       if( stripped )
diff -urN kdepim_old/libkdepim/kaddrbook.cpp kdepim/libkdepim/kaddrbook.cpp
--- kdepim_old/libkdepim/kaddrbook.cpp	2005-01-06 12:26:01.000000000 +0000
+++ kdepim/libkdepim/kaddrbook.cpp	2005-01-06 11:03:27.000000000 +0000
@@ -81,6 +81,23 @@
   }
 }
 
+// force a reload of the address book file so that changes that were made
+// by other programs are loaded
+void KAddrBookExternal::reloadAddressBook( ) {
+  KABC::AddressBook *ab = KABC::StdAddressBook::self();
+  ab->load();
+}
+
+bool KAddrBookExternal::isInAddressBook( const QString &addr ) {
+  QString email;
+  QString name;
+  KABC::Addressee::parseEmailAddress( addr, name, email );
+  KABC::AddressBook *ab = KABC::StdAddressBook::self();
+
+  KABC::Addressee::List addressees = ab->findByEmail( email );
+  return !addressees.isEmpty();
+}
+
 void KAddrBookExternal::openAddressBook(QWidget *) {
   kapp->startServiceByDesktopName( "kaddressbook" );
 }
diff -urN kdepim_old/libkdepim/kaddrbook.h kdepim/libkdepim/kaddrbook.h
--- kdepim_old/libkdepim/kaddrbook.h	2005-01-06 12:26:01.000000000 +0000
+++ kdepim/libkdepim/kaddrbook.h	2005-01-06 11:30:06.000000000 +0000
@@ -16,6 +16,8 @@
 public:
   static void addEmail( const QString &addr, QWidget *parent );
   static void addNewAddressee( QWidget* );
+  static void reloadAddressBook( );
+  static bool isInAddressBook( const QString &addr );
   static void openEmail( const QString &email, const QString &addr, QWidget *parent );
   static void openAddressBook( QWidget *parent );


_______________________________________________
kde-pim mailing list
kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/

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

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