summaryrefslogtreecommitdiffstats
path: root/kontact/plugins/kmail
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kontact/plugins/kmail
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kontact/plugins/kmail')
-rw-r--r--kontact/plugins/kmail/Makefile.am29
-rw-r--r--kontact/plugins/kmail/kcmkmailsummary.cpp192
-rw-r--r--kontact/plugins/kmail/kcmkmailsummary.desktop107
-rw-r--r--kontact/plugins/kmail/kcmkmailsummary.h61
-rw-r--r--kontact/plugins/kmail/kmail_plugin.cpp221
-rw-r--r--kontact/plugins/kmail/kmail_plugin.h86
-rw-r--r--kontact/plugins/kmail/kmailplugin.desktop67
-rw-r--r--kontact/plugins/kmail/summarywidget.cpp182
-rw-r--r--kontact/plugins/kmail/summarywidget.h73
9 files changed, 1018 insertions, 0 deletions
diff --git a/kontact/plugins/kmail/Makefile.am b/kontact/plugins/kmail/Makefile.am
new file mode 100644
index 00000000..d176693a
--- /dev/null
+++ b/kontact/plugins/kmail/Makefile.am
@@ -0,0 +1,29 @@
+INCLUDES = -I$(top_srcdir)/kontact/interfaces -I$(top_srcdir)/kmail -I$(top_builddir)/kmail \
+ -I$(top_srcdir)/libkdepim \
+ -I$(top_srcdir) $(all_includes)
+
+kde_module_LTLIBRARIES = libkontact_kmailplugin.la kcm_kmailsummary.la
+
+libkontact_kmailplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
+libkontact_kmailplugin_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(top_builddir)/libkcal/libkcal.la $(LIB_KPARTS)
+
+libkontact_kmailplugin_la_SOURCES = kmail_plugin.cpp kmailIface.stub \
+ summarywidget.cpp summarywidget.skel
+
+kcm_kmailsummary_la_SOURCES = kcmkmailsummary.cpp
+kcm_kmailsummary_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) \
+ -avoid-version -no-undefined
+kcm_kmailsummary_la_LIBADD = $(LIB_KDEUI)
+
+kmailIface_DCOPIDLNG = true
+
+summarywidget_DCOPIDLNG = true
+
+METASOURCES = AUTO
+
+servicedir = $(kde_servicesdir)/kontact
+service_DATA = kmailplugin.desktop
+
+kde_services_DATA = kcmkmailsummary.desktop
+
+kmailIface_DIR = $(top_srcdir)/kmail
diff --git a/kontact/plugins/kmail/kcmkmailsummary.cpp b/kontact/plugins/kmail/kcmkmailsummary.cpp
new file mode 100644
index 00000000..02627c0f
--- /dev/null
+++ b/kontact/plugins/kmail/kcmkmailsummary.cpp
@@ -0,0 +1,192 @@
+/*
+ This file is part of Kontact.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qcheckbox.h>
+#include <qlayout.h>
+
+#include <dcopref.h>
+
+#include <kaboutdata.h>
+#include <kaccelmanager.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <klistview.h>
+#include <klocale.h>
+
+#include "kcmkmailsummary.h"
+
+#include <kdepimmacros.h>
+
+extern "C"
+{
+ KDE_EXPORT KCModule *create_kmailsummary( QWidget *parent, const char * )
+ {
+ return new KCMKMailSummary( parent, "kcmkmailsummary" );
+ }
+}
+
+KCMKMailSummary::KCMKMailSummary( QWidget *parent, const char *name )
+ : KCModule( parent, name )
+{
+ initGUI();
+
+ connect( mFolderView, SIGNAL( clicked( QListViewItem* ) ), SLOT( modified() ) );
+ connect( mFullPath, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
+
+ KAcceleratorManager::manage( this );
+
+ load();
+
+ KAboutData *about = new KAboutData( I18N_NOOP( "kcmkmailsummary" ),
+ I18N_NOOP( "Mail Summary Configuration Dialog" ),
+ 0, 0, KAboutData::License_GPL,
+ I18N_NOOP( "(c) 2004 Tobias Koenig" ) );
+
+ about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" );
+ setAboutData( about );
+}
+
+void KCMKMailSummary::modified()
+{
+ emit changed( true );
+}
+
+void KCMKMailSummary::initGUI()
+{
+ QVBoxLayout *layout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
+
+ mFolderView = new KListView( this );
+ mFolderView->setRootIsDecorated( true );
+ mFolderView->setFullWidth( true );
+
+ mFolderView->addColumn( i18n( "Summary" ) );
+
+ mFullPath = new QCheckBox( i18n( "Show full path for folders" ), this );
+
+ layout->addWidget( mFolderView );
+ layout->addWidget( mFullPath );
+}
+
+void KCMKMailSummary::initFolders()
+{
+ DCOPRef kmail( "kmail", "KMailIface" );
+
+ QStringList folderList;
+ kmail.call( "folderList" ).get( folderList );
+
+ mFolderView->clear();
+ mFolderMap.clear();
+
+ QStringList::Iterator it;
+ for ( it = folderList.begin(); it != folderList.end(); ++it ) {
+ QString displayName;
+ if ( (*it) == "/Local" )
+ displayName = i18n( "prefix for local folders", "Local" );
+ else {
+ DCOPRef folderRef = kmail.call( "getFolder(QString)", *it );
+ folderRef.call( "displayName()" ).get( displayName );
+ }
+ if ( (*it).contains( '/' ) == 1 ) {
+ if ( mFolderMap.find( *it ) == mFolderMap.end() )
+ mFolderMap.insert( *it, new QListViewItem( mFolderView,
+ displayName ) );
+ } else {
+ const int pos = (*it).findRev( '/' );
+ const QString parentFolder = (*it).left( pos );
+ mFolderMap.insert( *it,
+ new QCheckListItem( mFolderMap[ parentFolder ],
+ displayName,
+ QCheckListItem::CheckBox ) );
+ }
+ }
+}
+
+void KCMKMailSummary::loadFolders()
+{
+ KConfig config( "kcmkmailsummaryrc" );
+ config.setGroup( "General" );
+
+ QStringList folders;
+ if ( !config.hasKey( "ActiveFolders" ) )
+ folders << "/Local/inbox";
+ else
+ folders = config.readListEntry( "ActiveFolders" );
+
+ QMap<QString, QListViewItem*>::Iterator it;
+ for ( it = mFolderMap.begin(); it != mFolderMap.end(); ++it ) {
+ if ( QCheckListItem *qli = dynamic_cast<QCheckListItem*>( it.data() ) ) {
+ if ( folders.contains( it.key() ) ) {
+ qli->setOn( true );
+ mFolderView->ensureItemVisible( it.data() );
+ } else {
+ qli->setOn( false );
+ }
+ }
+ }
+ mFullPath->setChecked( config.readBoolEntry( "ShowFullPath", true ) );
+}
+
+void KCMKMailSummary::storeFolders()
+{
+ KConfig config( "kcmkmailsummaryrc" );
+ config.setGroup( "General" );
+
+ QStringList folders;
+
+ QMap<QString, QListViewItem*>::Iterator it;
+ for ( it = mFolderMap.begin(); it != mFolderMap.end(); ++it )
+ if ( QCheckListItem *qli = dynamic_cast<QCheckListItem*>( it.data() ) )
+ if ( qli->isOn() )
+ folders.append( it.key() );
+
+ config.writeEntry( "ActiveFolders", folders );
+ config.writeEntry( "ShowFullPath", mFullPath->isChecked() );
+
+ config.sync();
+}
+
+void KCMKMailSummary::load()
+{
+ initFolders();
+ loadFolders();
+
+ emit changed( false );
+}
+
+void KCMKMailSummary::save()
+{
+ storeFolders();
+
+ emit changed( false );
+}
+
+void KCMKMailSummary::defaults()
+{
+ mFullPath->setChecked( true );
+
+ emit changed( true );
+}
+
+#include "kcmkmailsummary.moc"
diff --git a/kontact/plugins/kmail/kcmkmailsummary.desktop b/kontact/plugins/kmail/kcmkmailsummary.desktop
new file mode 100644
index 00000000..2b8c7d99
--- /dev/null
+++ b/kontact/plugins/kmail/kcmkmailsummary.desktop
@@ -0,0 +1,107 @@
+[Desktop Entry]
+Icon=kontact_mail
+Type=Service
+ServiceTypes=KCModule
+
+X-KDE-ModuleType=Library
+X-KDE-Library=kmailsummary
+X-KDE-FactoryName=kmailsummary
+X-KDE-ParentApp=kontact_kmailplugin
+X-KDE-ParentComponents=kontact_kmailplugin
+X-KDE-CfgDlgHierarchy=KontactSummary
+
+Name=E-Mail Overview
+Name[bg]=Преглед на пощата
+Name[ca]=Resum de correu
+Name[da]=Oversigt over e-mail
+Name[de]=E-Mail-Übersicht
+Name[el]=Επισκόπηση αλληλογραφίας
+Name[es]=Resumen de correo electrónico
+Name[et]=E-posti ülevaade
+Name[fr]=Aperçu du courriel
+Name[is]=Yfirsýn á tölvupóst
+Name[it]=Panoramica posta elettronica
+Name[ja]=メールの要約
+Name[km]=ទិដ្ឋភាព​ទូទៅ​របស់​អ៊ីមែល
+Name[nds]=Nettpost-Översicht
+Name[nl]=E-mailoverzicht
+Name[pl]=Poczta
+Name[ru]=Сведения о почте
+Name[sk]=Prehľad pošty
+Name[sr]=Преглед е-поште
+Name[sr@Latn]=Pregled e-pošte
+Name[sv]=E-postöversikt
+Name[tr]=E-Postalara Genel Bakış
+Name[zh_CN]=邮件概览
+Name[zh_TW]=郵件概要
+Comment=E-Mail Summary Setup
+Comment[bg]=Настройки на обобщението на писмата
+Comment[ca]=Configuració del resum de correu
+Comment[da]=Opsætning af post-opsummering
+Comment[de]=Einstellungen für E-Mail-Übersicht
+Comment[el]=Ρύθμιση σύνοψης αλληλογραφίας
+Comment[es]=Configuración del resumen de correo electrónico
+Comment[et]=E-posti kokkuvõtte seadistus
+Comment[fr]=Configuration du résumé des courriels
+Comment[is]=Uppsetning póstyfirlits
+Comment[it]=Impostazioni sommario posta elettronica
+Comment[ja]=メール要約の設定
+Comment[km]=រៀបចំ​សេចក្ដី​សង្ខេប​អ៊ីមែល
+Comment[nds]=Instellen för Nettpost-Översicht
+Comment[nl]=Instellingen voor e-mailoverzicht
+Comment[pl]=Ustawienia podsumowania e-maili
+Comment[ru]=Настройка сводки почты
+Comment[sk]=Nastavenie súhrnu pošty
+Comment[sr]=Подешавање сажетка е-поште
+Comment[sr@Latn]=Podešavanje sažetka e-pošte
+Comment[sv]=Inställning av e-postöversikt
+Comment[tr]=E-Posta Özet Yapılandırması
+Comment[zh_CN]=邮件摘要设置
+Comment[zh_TW]=郵件摘要設定
+Keywords=email, summary, configure, settings
+Keywords[af]=email,summary,configure,settings
+Keywords[bg]=резюме, общо, обобщение, пощенски, клиент, е-поща, email, summary, configure, settings
+Keywords[bs]=email, summary, configure, settings, sažetak, postavke
+Keywords[ca]=correu-e, resum, configuració, arranjament
+Keywords[cs]=email,souhrn,nastavení,nastavit
+Keywords[da]=e-mail, opsummering, indstil, opsætning
+Keywords[de]=E-Mail,email,Übersicht,einstellen,Einstellungen,Einrichten
+Keywords[el]=αλληλογραφία, σύνοψη, ρύθμιση, ρυθμίσεις
+Keywords[es]=correo, resumen, configurar, opciones
+Keywords[et]=e-post, meil, seadistamine, seadistused
+Keywords[eu]=eposta, laburpena, konfiguratu, ezarpenak
+Keywords[fa]=email، خلاصه، پیکربندی، تنظیمات
+Keywords[fi]=sähköposti, yhteenveto, asetukset
+Keywords[fr]=message,messagerie,courriel,résumé,vue,configurer,paramètres,paramètre
+Keywords[fy]=email,e-mail,e-post,oersicht,gearfetting,ynstellings, konfiguraasje
+Keywords[ga]=ríomhphost, achoimre, cumraigh, socruithe
+Keywords[gl]=email, resumo, configurar, opcións
+Keywords[he]=email, summary, configure, settings, דוא"ל, תקציר, תצורה, הגדרת, דואל, דואר, דואר אלקטרוני
+Keywords[hu]=e-mail,áttekintés,konfigurálás,beállítások
+Keywords[is]=tölvupóstur, yfirlit, stillingar, stilla
+Keywords[it]=posta elettronica, email, sommario, configura, impostazioni
+Keywords[ja]=メール,要約,設定,設定
+Keywords[ka]=ელფოსტა,დაიჯესტი,კონფიგურაცია,პარამეტრები
+Keywords[km]=អ៊ីមែល,សង្ខេប,កំណត់​រចនាសម្ព័ន្ធ,ការ​កំណត់
+Keywords[lt]=email, summary, configure, settings, e. paštas, santrauka, konfigūruoti, nustatymai
+Keywords[mk]=email, summary, configure, settings, е-пошта, преглед, конфигурација, поставувања
+Keywords[ms]=e-mel, ringkasan, konfigur, seting
+Keywords[nb]=e-post, sammendrag, oppsett, innstillinger
+Keywords[nds]=Nettpost,Nettbreef,Översicht,instellen
+Keywords[ne]=इमेल, सारांश, कन्फिगर, सेटिङ
+Keywords[nl]=email,e-mail,overzicht,samenvatting,instellingen,configuratie
+Keywords[nn]=e-post,samandrag,oppsett,innstillingar
+Keywords[pl]=e-mail,list,podsumowanie,konfiguracja,ustawienia
+Keywords[pt]=e-mail, sumário, configurar, configuração
+Keywords[pt_BR]=e-mail, resumo, configurar, configurações
+Keywords[ru]=email,summary,configure,settings,настройки,сводка,почта
+Keywords[sk]=email,súhrn,nastavenie
+Keywords[sl]=e-pošta,pošta,povzetek,nastavi,nastavitve
+Keywords[sr]=емаил, сажетак, подеси, поставке
+Keywords[sr@Latn]=email, sažetak, podesi, postavke
+Keywords[sv]=e-post, översikt, anpassa, inställningar
+Keywords[ta]=மின்னஞ்சல்,சுருக்கம்,கட்டமைப்பு,அமைவுகள்
+Keywords[tg]=email, summary, configure, settings,танзимот, дайджест,почта
+Keywords[tr]=e-posta, özet, yapılandır, yapılandırma
+Keywords[uk]=пошта, підсумок, налаштування, параметри
+Keywords[zh_CN]=email, summary, configure, settings, 电子邮件, 摘要, 配置, 设置
diff --git a/kontact/plugins/kmail/kcmkmailsummary.h b/kontact/plugins/kmail/kcmkmailsummary.h
new file mode 100644
index 00000000..e2959dea
--- /dev/null
+++ b/kontact/plugins/kmail/kcmkmailsummary.h
@@ -0,0 +1,61 @@
+/*
+ This file is part of Kontact.
+ Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KCMKMAILSUMMARY_H
+#define KCMKMAILSUMMARY_H
+
+#include <qvaluelist.h>
+
+#include <kcmodule.h>
+
+class KListView;
+
+class QCheckBox;
+class QCheckListItem;
+
+class KCMKMailSummary : public KCModule
+{
+ Q_OBJECT
+
+ public:
+ KCMKMailSummary( QWidget *parent = 0, const char *name = 0 );
+
+ virtual void load();
+ virtual void save();
+ virtual void defaults();
+
+ private slots:
+ void modified();
+
+ private:
+ void initGUI();
+ void initFolders();
+ void loadFolders();
+ void storeFolders();
+
+ KListView *mFolderView;
+ QCheckBox *mFullPath;
+ QMap<QString, QListViewItem*> mFolderMap;
+};
+
+#endif
diff --git a/kontact/plugins/kmail/kmail_plugin.cpp b/kontact/plugins/kmail/kmail_plugin.cpp
new file mode 100644
index 00000000..3d9f45be
--- /dev/null
+++ b/kontact/plugins/kmail/kmail_plugin.cpp
@@ -0,0 +1,221 @@
+/*
+ This file is part of Kontact.
+ Copyright (c) 2003 Kontact Developer
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qwidget.h>
+
+#include <kaction.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kgenericfactory.h>
+#include <kiconloader.h>
+#include <kparts/componentfactory.h>
+#include <kstandarddirs.h>
+#include <dcopclient.h>
+#include <ktempfile.h>
+
+#include <kabc/addressee.h>
+
+#include <libkcal/vcaldrag.h>
+#include <libkcal/icaldrag.h>
+#include <libkcal/calendarlocal.h>
+
+#include <libkdepim/kvcarddrag.h>
+
+#include <kmail/kmail_part.h>
+#include <kmail/kmkernel.h>
+
+#include "core.h"
+#include "summarywidget.h"
+
+#include "kmail_plugin.h"
+
+using namespace KCal;
+
+typedef KGenericFactory<KMailPlugin, Kontact::Core> KMailPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( libkontact_kmailplugin,
+ KMailPluginFactory( "kontact_kmailplugin" ) )
+
+KMailPlugin::KMailPlugin(Kontact::Core *core, const char *, const QStringList& )
+ : Kontact::Plugin( core, core, "kmail" ),
+ mStub( 0 )
+{
+ setInstance( KMailPluginFactory::instance() );
+
+ insertNewAction( new KAction( i18n( "New Message..." ), "mail_new",
+ CTRL+SHIFT+Key_M, this, SLOT( slotNewMail() ), actionCollection(),
+ "new_mail" ) );
+
+ insertSyncAction( new KAction( i18n( "Synchronize Mail" ), "reload",
+ 0, this, SLOT( slotSyncFolders() ), actionCollection(),
+ "sync_mail" ) );
+
+ mUniqueAppWatcher = new Kontact::UniqueAppWatcher(
+ new Kontact::UniqueAppHandlerFactory<KMailUniqueAppHandler>(), this );
+}
+
+bool KMailPlugin::canDecodeDrag( QMimeSource *qms )
+{
+ return ( ICalDrag::canDecode( qms ) ||
+ VCalDrag::canDecode( qms ) ||
+ KVCardDrag::canDecode( qms ) );
+}
+
+void KMailPlugin::processDropEvent( QDropEvent * de )
+{
+ kdDebug() << k_funcinfo << endl;
+ CalendarLocal cal( QString::fromLatin1("UTC") );
+ KABC::Addressee::List list;
+
+ if ( VCalDrag::decode( de, &cal ) || ICalDrag::decode( de, &cal ) ) {
+ KTempFile tmp( locateLocal( "tmp", "incidences-" ), ".ics" );
+ cal.save( tmp.name() );
+ openComposer( KURL::fromPathOrURL( tmp.name() ) );
+ }
+ else if ( KVCardDrag::decode( de, list ) ) {
+ KABC::Addressee::List::Iterator it;
+ QStringList to;
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ to.append( ( *it ).fullEmail() );
+ }
+ openComposer( to.join(", ") );
+ }
+
+}
+
+void KMailPlugin::openComposer( const KURL& attach )
+{
+ (void) part(); // ensure part is loaded
+ Q_ASSERT( mStub );
+ if ( mStub ) {
+ if ( attach.isValid() )
+ mStub->newMessage( "", "", "", false, true, KURL(), attach );
+ else
+ mStub->newMessage( "", "", "", false, true, KURL(), KURL() );
+ }
+}
+
+void KMailPlugin::openComposer( const QString& to )
+{
+ (void) part(); // ensure part is loaded
+ Q_ASSERT( mStub );
+ if ( mStub ) {
+ mStub->newMessage( to, "", "", false, true, KURL(), KURL() );
+ }
+}
+
+void KMailPlugin::slotNewMail()
+{
+ openComposer( QString::null );
+}
+
+void KMailPlugin::slotSyncFolders()
+{
+ DCOPRef ref( "kmail", "KMailIface" );
+ ref.send( "checkMail" );
+}
+
+KMailPlugin::~KMailPlugin()
+{
+}
+
+bool KMailPlugin::createDCOPInterface( const QString& serviceType )
+{
+ if ( serviceType == "DCOP/ResourceBackend/IMAP" ) {
+ if ( part() )
+ return true;
+ }
+
+ return false;
+}
+
+QString KMailPlugin::tipFile() const
+{
+ QString file = ::locate("data", "kmail/tips");
+ return file;
+}
+
+KParts::ReadOnlyPart* KMailPlugin::createPart()
+{
+ KParts::ReadOnlyPart *part = loadPart();
+ if ( !part ) return 0;
+
+ mStub = new KMailIface_stub( dcopClient(), "kmail", "KMailIface" );
+
+ return part;
+}
+
+QStringList KMailPlugin::invisibleToolbarActions() const
+{
+ return QStringList( "new_message" );
+}
+
+bool KMailPlugin::isRunningStandalone()
+{
+ return mUniqueAppWatcher->isRunningStandalone();
+}
+
+Kontact::Summary *KMailPlugin::createSummaryWidget( QWidget *parent )
+{
+ return new SummaryWidget( this, parent );
+}
+
+////
+
+#include "../../../kmail/kmail_options.h"
+void KMailUniqueAppHandler::loadCommandLineOptions()
+{
+ KCmdLineArgs::addCmdLineOptions( kmail_options );
+}
+
+int KMailUniqueAppHandler::newInstance()
+{
+ // Ensure part is loaded
+ (void)plugin()->part();
+ DCOPRef kmail( "kmail", "KMailIface" );
+ DCOPReply reply = kmail.call( "handleCommandLine", false );
+ if ( reply.isValid() ) {
+ bool handled = reply;
+ //kdDebug(5602) << k_funcinfo << "handled=" << handled << endl;
+ if ( !handled ) // no args -> simply bring kmail plugin to front
+ return Kontact::UniqueAppHandler::newInstance();
+ }
+ return 0;
+}
+
+bool KMailPlugin::queryClose() const {
+ KMailIface_stub stub( kapp->dcopClient(), "kmail", "KMailIface" );
+ bool canClose=stub.canQueryClose();
+ return canClose;
+}
+
+void KMailPlugin::loadProfile( const QString& profileDirectory ) {
+ DCOPRef ref( "kmail", "KMailIface" );
+ ref.send( "loadProfile", profileDirectory );
+}
+
+void KMailPlugin::saveToProfile( const QString& profileDirectory ) {
+ DCOPRef ref( "kmail", "KMailIface" );
+ ref.send( "saveToProfile", profileDirectory );
+}
+
+#include "kmail_plugin.moc"
diff --git a/kontact/plugins/kmail/kmail_plugin.h b/kontact/plugins/kmail/kmail_plugin.h
new file mode 100644
index 00000000..0d601386
--- /dev/null
+++ b/kontact/plugins/kmail/kmail_plugin.h
@@ -0,0 +1,86 @@
+/*
+ This file is part of Kontact.
+ Copyright (c) 2003 Kontact Developer
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef KMAIL_PLUGIN_H
+#define KMAIL_PLUGIN_H
+
+#include <klocale.h>
+#include <kparts/part.h>
+
+#include "kmailIface_stub.h"
+#include <plugin.h>
+#include <summary.h>
+#include <uniqueapphandler.h>
+
+class QMimeSource;
+class QDropEvent;
+
+class KMailUniqueAppHandler : public Kontact::UniqueAppHandler
+{
+public:
+ KMailUniqueAppHandler( Kontact::Plugin* plugin ) : Kontact::UniqueAppHandler( plugin ) {}
+ virtual void loadCommandLineOptions();
+ virtual int newInstance();
+};
+
+class KMailPlugin : public Kontact::Plugin
+{
+ Q_OBJECT
+
+ public:
+ KMailPlugin( Kontact::Core *core, const char *name, const QStringList& );
+ ~KMailPlugin();
+
+ virtual bool isRunningStandalone();
+ virtual bool createDCOPInterface( const QString& serviceType );
+ virtual Kontact::Summary *createSummaryWidget( QWidget *parent );
+ virtual QString tipFile() const;
+ int weight() const { return 200; }
+
+ virtual QStringList invisibleToolbarActions() const;
+ virtual bool queryClose() const;
+
+ //override
+ void loadProfile( const QString& profileDirectory );
+
+ //override
+ void saveToProfile( const QString& profileDirectory );
+
+ protected:
+ virtual KParts::ReadOnlyPart* createPart();
+ void openComposer( const KURL& = KURL() );
+ void openComposer( const QString& to );
+ bool canDecodeDrag( QMimeSource * );
+ void processDropEvent( QDropEvent * );
+
+
+ protected slots:
+ void slotNewMail();
+ void slotSyncFolders();
+
+ private:
+ KMailIface_stub *mStub;
+ Kontact::UniqueAppWatcher *mUniqueAppWatcher;
+};
+
+#endif
diff --git a/kontact/plugins/kmail/kmailplugin.desktop b/kontact/plugins/kmail/kmailplugin.desktop
new file mode 100644
index 00000000..55ba5e97
--- /dev/null
+++ b/kontact/plugins/kmail/kmailplugin.desktop
@@ -0,0 +1,67 @@
+[Desktop Entry]
+Type=Service
+Icon=kontact_mail
+ServiceTypes=Kontact/Plugin,KPluginInfo
+
+X-KDE-Library=libkontact_kmailplugin
+X-KDE-KontactPluginVersion=6
+X-KDE-KontactPartLibraryName=libkmailpart
+X-KDE-KontactPartExecutableName=kmail
+X-KDE-KontactPartLoadOnStart=true
+X-KDE-KontactPluginHasSummary=true
+
+X-KDE-PluginInfo-Website=http://kmail.kde.org/
+X-KDE-PluginInfo-Name=kontact_kmailplugin
+X-KDE-PluginInfo-Version=0.1
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=true
+
+Comment=E-Mail Component (KMail Plugin)
+Comment[bg]=Модул за е-поща
+Comment[ca]=Component de correu (endollable del KMail)
+Comment[da]=Post-komponent (KMail-plugin)
+Comment[de]=E-Mail-Komponente (KMail-Modul)
+Comment[el]=Συστατικό αλληλογραφίας (Πρόσθετο του KMail)
+Comment[es]=Componente de correo electrónico (complemento de KMail)
+Comment[et]=E-posti plugin (KMail)
+Comment[fr]=Composant de courriel (Module pour KMail)
+Comment[is]=Pósteining (KMail íforrit)
+Comment[it]=Componente posta elettronica (plugin KMail)
+Comment[ja]=メールコンポーネント (KMail プラグイン)
+Comment[km]=សមាសភាគ​អ៊ីមែល (កម្មវិធី​ជំនួយ KMail)
+Comment[nds]=Nettpost-Komponent (KMail-Moduul)
+Comment[nl]=E-mailcomponent (KMail-plugin)
+Comment[pl]=Składnik poczty (wtyczka KMail)
+Comment[pt_BR]=Componente de e-mail (plug-in do KMail)
+Comment[ru]=Электронная почта (модуль KMail)
+Comment[sk]=Poštový komponent (Model pre KMail)
+Comment[sr]=Компонента е-поште (прикључак KMail-а)
+Comment[sr@Latn]=Komponenta e-pošte (priključak KMail-a)
+Comment[sv]=E-postkomponent (Kmail-insticksprogram)
+Comment[tr]=E-Posta Bileşeni (KMail Eklentisi)
+Comment[zh_CN]=邮件组件(KMail 插件)
+Comment[zh_TW]=電子郵件組件(KMail 外掛程式)
+Name=E-Mail
+Name[bg]=Е-поща
+Name[ca]=Correu
+Name[da]=E-mail
+Name[el]=Αλληλογραφία
+Name[es]=Correo electrónico
+Name[et]=E-post
+Name[fr]=Courriel
+Name[is]=Tölvupóstur
+Name[it]=Posta elettronica
+Name[ja]=メール
+Name[km]=អ៊ីមែល
+Name[nds]=Nettpost
+Name[nl]=E-mail
+Name[pl]=E-mail
+Name[pt_BR]=E-mail
+Name[ru]=Электронная почта
+Name[sk]=Pošta
+Name[sr]=Е-пошта
+Name[sr@Latn]=E-pošta
+Name[sv]=E-post
+Name[tr]=E-Posta
+Name[zh_CN]=邮件
+Name[zh_TW]=電子郵件
diff --git a/kontact/plugins/kmail/summarywidget.cpp b/kontact/plugins/kmail/summarywidget.cpp
new file mode 100644
index 00000000..79f2f465
--- /dev/null
+++ b/kontact/plugins/kmail/summarywidget.cpp
@@ -0,0 +1,182 @@
+/* -*- mode: C++; c-file-style: "gnu" -*-
+
+ This file is part of Kontact.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qlabel.h>
+#include <qlayout.h>
+
+#include <dcopref.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kparts/part.h>
+
+#include "core.h"
+#include "summary.h"
+#include "summarywidget.h"
+
+#include <time.h>
+
+SummaryWidget::SummaryWidget( Kontact::Plugin *plugin, QWidget *parent, const char *name )
+ : Kontact::Summary( parent, name ),
+ DCOPObject( QCString("MailSummary") ),
+ mPlugin( plugin )
+{
+ QVBoxLayout *mainLayout = new QVBoxLayout( this, 3, 3 );
+
+ QPixmap icon = KGlobal::iconLoader()->loadIcon( "kontact_mail", KIcon::Desktop,
+ KIcon::SizeMedium );
+ QWidget *header = createHeader(this, icon, i18n("E-Mail"));
+ mLayout = new QGridLayout( 1, 3, 3 );
+
+ mainLayout->addWidget(header);
+ mainLayout->addLayout(mLayout);
+
+ slotUnreadCountChanged();
+ connectDCOPSignal( 0, 0, "unreadCountChanged()", "slotUnreadCountChanged()",
+ false );
+}
+
+void SummaryWidget::selectFolder( const QString& folder )
+{
+ if ( mPlugin->isRunningStandalone() )
+ mPlugin->bringToForeground();
+ else
+ mPlugin->core()->selectPlugin( mPlugin );
+ QByteArray data;
+ QDataStream arg( data, IO_WriteOnly );
+ arg << folder;
+ emitDCOPSignal( "kmailSelectFolder(QString)", data );
+}
+
+void SummaryWidget::updateSummary( bool )
+{
+ // check whether we need to update the message counts
+ DCOPRef kmail( "kmail", "KMailIface" );
+ const int timeOfLastMessageCountChange =
+ kmail.call( "timeOfLastMessageCountChange()" );
+ if ( timeOfLastMessageCountChange > mTimeOfLastMessageCountUpdate )
+ slotUnreadCountChanged();
+}
+
+void SummaryWidget::slotUnreadCountChanged()
+{
+ DCOPRef kmail( "kmail", "KMailIface" );
+ DCOPReply reply = kmail.call( "folderList" );
+ if ( reply.isValid() ) {
+ QStringList folderList = reply;
+ updateFolderList( folderList );
+ }
+ else {
+ kdDebug(5602) << "Calling kmail->KMailIface->folderList() via DCOP failed."
+ << endl;
+ }
+ mTimeOfLastMessageCountUpdate = ::time( 0 );
+}
+
+void SummaryWidget::updateFolderList( const QStringList& folders )
+{
+ mLabels.setAutoDelete( true );
+ mLabels.clear();
+ mLabels.setAutoDelete( false );
+
+ KConfig config( "kcmkmailsummaryrc" );
+ config.setGroup( "General" );
+
+ QStringList activeFolders;
+ if ( !config.hasKey( "ActiveFolders" ) )
+ activeFolders << "/Local/inbox";
+ else
+ activeFolders = config.readListEntry( "ActiveFolders" );
+
+ int counter = 0;
+ QStringList::ConstIterator it;
+ DCOPRef kmail( "kmail", "KMailIface" );
+ for ( it = folders.begin(); it != folders.end(); ++it ) {
+ if ( activeFolders.contains( *it ) ) {
+ DCOPRef folderRef = kmail.call( "getFolder(QString)", *it );
+ const int numMsg = folderRef.call( "messages()" );
+ const int numUnreadMsg = folderRef.call( "unreadMessages()" );
+
+ if ( numUnreadMsg == 0 ) continue;
+
+ QString folderPath;
+ if ( config.readBoolEntry( "ShowFullPath", true ) )
+ folderRef.call( "displayPath()" ).get( folderPath );
+ else
+ folderRef.call( "displayName()" ).get( folderPath );
+
+ KURLLabel *urlLabel = new KURLLabel( *it, folderPath, this );
+ urlLabel->installEventFilter( this );
+ urlLabel->setAlignment( AlignLeft );
+ urlLabel->show();
+ connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ),
+ SLOT( selectFolder( const QString& ) ) );
+ mLayout->addWidget( urlLabel, counter, 0 );
+ mLabels.append( urlLabel );
+
+ QLabel *label =
+ new QLabel( QString( i18n("%1: number of unread messages "
+ "%2: total number of messages", "%1 / %2") )
+ .arg( numUnreadMsg ).arg( numMsg ), this );
+ label->setAlignment( AlignLeft );
+ label->show();
+ mLayout->addWidget( label, counter, 2 );
+ mLabels.append( label );
+
+ counter++;
+ }
+ }
+
+ if ( counter == 0 ) {
+ QLabel *label = new QLabel( i18n( "No unread messages in your monitored folders" ), this );
+ label->setAlignment( AlignHCenter | AlignVCenter );
+ mLayout->addMultiCellWidget( label, 0, 0, 0, 2 );
+ label->show();
+ mLabels.append( label );
+ }
+}
+
+bool SummaryWidget::eventFilter( QObject *obj, QEvent* e )
+{
+ if ( obj->inherits( "KURLLabel" ) ) {
+ KURLLabel* label = static_cast<KURLLabel*>( obj );
+ if ( e->type() == QEvent::Enter )
+ emit message( i18n( "Open Folder: \"%1\"" ).arg( label->text() ) );
+ if ( e->type() == QEvent::Leave )
+ emit message( QString::null );
+ }
+
+ return Kontact::Summary::eventFilter( obj, e );
+}
+
+QStringList SummaryWidget::configModules() const
+{
+ return QStringList( "kcmkmailsummary.desktop" );
+}
+
+#include "summarywidget.moc"
diff --git a/kontact/plugins/kmail/summarywidget.h b/kontact/plugins/kmail/summarywidget.h
new file mode 100644
index 00000000..563a021e
--- /dev/null
+++ b/kontact/plugins/kmail/summarywidget.h
@@ -0,0 +1,73 @@
+/*
+ This file is part of Kontact.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#ifndef SUMMARYWIDGET_H
+#define SUMMARYWIDGET_H
+
+#include <qmap.h>
+#include <qtimer.h>
+#include <qwidget.h>
+
+#include <dcopobject.h>
+#include <kurllabel.h>
+#include <kparts/part.h>
+
+#include "plugin.h"
+#include "summary.h"
+
+class QGridLayout;
+class QString;
+
+class SummaryWidget : public Kontact::Summary, public DCOPObject
+{
+ Q_OBJECT
+ K_DCOP
+
+ public:
+ SummaryWidget( Kontact::Plugin *plugin, QWidget *parent, const char *name = 0 );
+
+ int summaryHeight() const { return 1; }
+ QStringList configModules() const;
+
+ k_dcop_hidden:
+ void slotUnreadCountChanged();
+
+ protected:
+ virtual bool eventFilter( QObject *obj, QEvent* e );
+
+ public slots:
+ virtual void updateSummary( bool force );
+
+ private slots:
+ void selectFolder( const QString& );
+
+ private:
+ void updateFolderList( const QStringList& folders );
+
+ QPtrList<QLabel> mLabels;
+ QGridLayout *mLayout;
+ Kontact::Plugin *mPlugin;
+ int mTimeOfLastMessageCountUpdate;
+};
+
+#endif