summaryrefslogtreecommitdiffstats
path: root/kontact/plugins/kaddressbook
diff options
context:
space:
mode:
Diffstat (limited to 'kontact/plugins/kaddressbook')
-rw-r--r--kontact/plugins/kaddressbook/Makefile.am18
-rw-r--r--kontact/plugins/kaddressbook/kaddressbook_plugin.cpp218
-rw-r--r--kontact/plugins/kaddressbook/kaddressbook_plugin.h86
-rw-r--r--kontact/plugins/kaddressbook/kaddressbookplugin.desktop100
4 files changed, 422 insertions, 0 deletions
diff --git a/kontact/plugins/kaddressbook/Makefile.am b/kontact/plugins/kaddressbook/Makefile.am
new file mode 100644
index 00000000..a769f29d
--- /dev/null
+++ b/kontact/plugins/kaddressbook/Makefile.am
@@ -0,0 +1,18 @@
+INCLUDES = -I$(top_srcdir)/kontact/interfaces -I$(top_srcdir) $(all_includes)
+
+kde_module_LTLIBRARIES = libkontact_kaddressbookplugin.la
+libkontact_kaddressbookplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -lkabc
+libkontact_kaddressbookplugin_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(top_builddir)/libkdepim/libkdepim.la
+
+libkontact_kaddressbookplugin_la_SOURCES = kaddressbook_plugin.cpp \
+ kaddressbookiface.stub \
+ kmailIface.stub
+
+METASOURCES = AUTO
+
+servicedir = $(kde_servicesdir)/kontact
+service_DATA = kaddressbookplugin.desktop
+
+kaddressbookiface_DIR = $(top_srcdir)/kaddressbook
+kmailIface_DIR = $(top_srcdir)/kmail
+kmailIface_DCOPIDLNG = true
diff --git a/kontact/plugins/kaddressbook/kaddressbook_plugin.cpp b/kontact/plugins/kaddressbook/kaddressbook_plugin.cpp
new file mode 100644
index 00000000..e2f5a706
--- /dev/null
+++ b/kontact/plugins/kaddressbook/kaddressbook_plugin.cpp
@@ -0,0 +1,218 @@
+/*
+ This file is part of Kontact.
+
+ Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@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 <qwidget.h>
+#include <qdragobject.h>
+
+#include <kaction.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kgenericfactory.h>
+#include <kiconloader.h>
+#include <kmessagebox.h>
+#include <kparts/componentfactory.h>
+
+#include <kaddrbook.h>
+#include <kabc/addressbook.h>
+#include <kabc/stdaddressbook.h>
+
+#include <dcopclient.h>
+#include "kmailIface_stub.h"
+
+#include <libkdepim/maillistdrag.h>
+
+#include "core.h"
+#include "plugin.h"
+
+#include "kaddressbook_plugin.h"
+
+typedef KGenericFactory< KAddressbookPlugin, Kontact::Core > KAddressbookPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( libkontact_kaddressbookplugin,
+ KAddressbookPluginFactory( "kontact_kaddressbookplugin" ) )
+
+KAddressbookPlugin::KAddressbookPlugin( Kontact::Core *core, const char *, const QStringList& )
+ : Kontact::Plugin( core, core, "kaddressbook" ),
+ mStub( 0 )
+{
+ setInstance( KAddressbookPluginFactory::instance() );
+
+ insertNewAction( new KAction( i18n( "New Contact..." ), "identity",
+ CTRL+SHIFT+Key_C, this, SLOT( slotNewContact() ), actionCollection(),
+ "new_contact" ) );
+
+ insertNewAction( new KAction( i18n( "&New Distribution List..." ), "kontact_contacts", 0, this,
+ SLOT( slotNewDistributionList() ), actionCollection(), "new_distributionlist" ) );
+
+ insertSyncAction( new KAction( i18n( "Synchronize Contacts" ), "reload",
+ 0, this, SLOT( slotSyncContacts() ), actionCollection(),
+ "kaddressbook_sync" ) );
+ mUniqueAppWatcher = new Kontact::UniqueAppWatcher(
+ new Kontact::UniqueAppHandlerFactory<KABUniqueAppHandler>(), this );
+}
+
+KAddressbookPlugin::~KAddressbookPlugin()
+{
+}
+
+KParts::ReadOnlyPart* KAddressbookPlugin::createPart()
+{
+ KParts::ReadOnlyPart * part = loadPart();
+ if ( !part ) return 0;
+
+ // Create the stub that allows us to talk to the part
+ mStub = new KAddressBookIface_stub( dcopClient(), "kaddressbook",
+ "KAddressBookIface" );
+ return part;
+}
+
+QStringList KAddressbookPlugin::configModules() const
+{
+ QStringList modules;
+ modules << "PIM/kabconfig.desktop" << "PIM/kabldapconfig.desktop";
+ return modules;
+}
+
+QStringList KAddressbookPlugin::invisibleToolbarActions() const
+{
+ return QStringList( "file_new_contact" );
+}
+
+KAddressBookIface_stub *KAddressbookPlugin::interface()
+{
+ if ( !mStub ) {
+ part();
+ }
+ Q_ASSERT( mStub );
+ return mStub;
+}
+
+void KAddressbookPlugin::slotNewContact()
+{
+ interface()->newContact();
+}
+
+
+void KAddressbookPlugin::slotNewDistributionList()
+{
+ interface()->newDistributionList();
+}
+
+void KAddressbookPlugin::slotSyncContacts()
+{
+ DCOPRef ref( "kmail", "KMailICalIface" );
+ ref.send( "triggerSync", QString("Contact") );
+}
+
+bool KAddressbookPlugin::createDCOPInterface( const QString& serviceType )
+{
+ if ( serviceType == "DCOP/AddressBook" ) {
+ Q_ASSERT( mStub );
+ return true;
+ }
+
+ return false;
+}
+
+void KAddressbookPlugin::configUpdated()
+{
+}
+
+bool KAddressbookPlugin::isRunningStandalone()
+{
+ return mUniqueAppWatcher->isRunningStandalone();
+}
+
+bool KAddressbookPlugin::canDecodeDrag( QMimeSource *mimeSource )
+{
+ return QTextDrag::canDecode( mimeSource ) ||
+ KPIM::MailListDrag::canDecode( mimeSource );
+}
+
+#include <dcopref.h>
+
+void KAddressbookPlugin::processDropEvent( QDropEvent *event )
+{
+ KPIM::MailList mails;
+ if ( KPIM::MailListDrag::decode( event, mails ) ) {
+ if ( mails.count() != 1 ) {
+ KMessageBox::sorry( core(),
+ i18n( "Drops of multiple mails are not supported." ) );
+ } else {
+ KPIM::MailSummary mail = mails.first();
+
+ KMailIface_stub kmailIface( "kmail", "KMailIface" );
+ QString sFrom = kmailIface.getFrom( mail.serialNumber() );
+
+ if ( !sFrom.isEmpty() ) {
+ KAddrBookExternal::addEmail( sFrom, core() );
+ }
+ }
+ return;
+ }
+
+ KMessageBox::sorry( core(), i18n( "Cannot handle drop events of type '%1'." )
+ .arg( event->format() ) );
+}
+
+
+void KAddressbookPlugin::loadProfile( const QString& directory )
+{
+ DCOPRef ref( "kaddressbook", "KAddressBookIface" );
+ ref.send( "loadProfile", directory );
+}
+
+void KAddressbookPlugin::saveToProfile( const QString& directory ) const
+{
+ DCOPRef ref( "kaddressbook", "KAddressBookIface" );
+ ref.send( "saveToProfile", directory );
+}
+
+////
+
+#include "../../../kaddressbook/kaddressbook_options.h"
+
+void KABUniqueAppHandler::loadCommandLineOptions()
+{
+ KCmdLineArgs::addCmdLineOptions( kaddressbook_options );
+}
+
+int KABUniqueAppHandler::newInstance()
+{
+ kdDebug(5602) << k_funcinfo << endl;
+ // Ensure part is loaded
+ (void)plugin()->part();
+ DCOPRef kAB( "kaddressbook", "KAddressBookIface" );
+ DCOPReply reply = kAB.call( "handleCommandLine" );
+ if ( reply.isValid() ) {
+ bool handled = reply;
+ kdDebug(5602) << k_funcinfo << "handled=" << handled << endl;
+ if ( !handled ) // no args -> simply bring kaddressbook plugin to front
+ return Kontact::UniqueAppHandler::newInstance();
+ }
+ return 0;
+}
+
+#include "kaddressbook_plugin.moc"
+
+// vim: sw=2 sts=2 tw=80 et
diff --git a/kontact/plugins/kaddressbook/kaddressbook_plugin.h b/kontact/plugins/kaddressbook/kaddressbook_plugin.h
new file mode 100644
index 00000000..f66d44aa
--- /dev/null
+++ b/kontact/plugins/kaddressbook/kaddressbook_plugin.h
@@ -0,0 +1,86 @@
+/*
+ This file is part of Kontact.
+
+ Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@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 KADDRESSBOOK_PLUGIN_H
+#define KADDRESSBOOK_PLUGIN_H
+
+#include <klocale.h>
+#include <kparts/part.h>
+
+#include "kaddressbookiface_stub.h"
+#include "plugin.h"
+#include <uniqueapphandler.h>
+
+class KAboutData;
+
+class KABUniqueAppHandler : public Kontact::UniqueAppHandler
+{
+public:
+ KABUniqueAppHandler( Kontact::Plugin* plugin ) : Kontact::UniqueAppHandler( plugin ) {}
+ virtual void loadCommandLineOptions();
+ virtual int newInstance();
+};
+
+class KAddressbookPlugin : public Kontact::Plugin
+{
+ Q_OBJECT
+
+ public:
+ KAddressbookPlugin( Kontact::Core *core, const char *name, const QStringList& );
+ ~KAddressbookPlugin();
+
+ virtual bool createDCOPInterface( const QString &serviceType );
+ virtual bool isRunningStandalone();
+ int weight() const { return 300; }
+
+ bool canDecodeDrag( QMimeSource * );
+ void processDropEvent( QDropEvent * );
+
+ virtual QStringList configModules() const;
+
+ virtual QStringList invisibleToolbarActions() const;
+
+ virtual void configUpdated();
+
+ KAddressBookIface_stub *interface();
+
+ //override
+ void loadProfile( const QString& directory );
+
+ //override
+ void saveToProfile( const QString& directory ) const;
+
+ protected:
+ KParts::ReadOnlyPart *createPart();
+ private slots:
+ void slotNewContact();
+ void slotNewDistributionList();
+ void slotSyncContacts();
+
+ private:
+ KAddressBookIface_stub *mStub;
+ Kontact::UniqueAppWatcher *mUniqueAppWatcher;
+};
+
+#endif
diff --git a/kontact/plugins/kaddressbook/kaddressbookplugin.desktop b/kontact/plugins/kaddressbook/kaddressbookplugin.desktop
new file mode 100644
index 00000000..f5208ea5
--- /dev/null
+++ b/kontact/plugins/kaddressbook/kaddressbookplugin.desktop
@@ -0,0 +1,100 @@
+[Desktop Entry]
+Type=Service
+Icon=kontact_contacts
+ServiceTypes=Kontact/Plugin,KPluginInfo
+
+X-KDE-Library=libkontact_kaddressbookplugin
+X-KDE-KontactPluginVersion=6
+X-KDE-KontactPartLibraryName=libkaddressbookpart
+X-KDE-KontactPartExecutableName=kaddressbook
+X-KDE-KontactPluginHasSummary=false
+
+X-KDE-PluginInfo-Website=http://www.kaddressbook.org/
+X-KDE-PluginInfo-Name=kontact_kaddressbookplugin
+X-KDE-PluginInfo-Version=0.1
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=true
+
+Comment=Contacts Component (KAdressbook Plugin)
+Comment[bg]=Приставка за адресника
+Comment[ca]=Component de contactes (endollable del KAdressbook)
+Comment[da]=Kontaktkomponent (KAddressbook-plugin)
+Comment[de]=Kontakte-Komponente (Adressbuch-Modul)
+Comment[el]=Συστατικό επαφών (Πρόσθετο του KAdressbook)
+Comment[es]=Componente de contactos (complemento de KAddressbook)
+Comment[et]=Kontaktide plugin (KDE aadressiraamat)
+Comment[fr]=Composant des contacts (module externe KAdressBook)
+Comment[is]=Vistfangaskráreining (KAddressBook íforrit)
+Comment[it]=Componente contatti (plugin KAddressbook)
+Comment[ja]=アドレス帳コンポーネント (KAddressbook プラグイン)
+Comment[km]=សមាសភាគ​ទំនាក់ទំន​ង (កម្មវិធី​ជំនួយ KAdressbook​)
+Comment[nds]=Kontakten-Komponent (KAddressbook-Moduul)
+Comment[nl]=Adresboekcomponent (KAddressbook-plugin)
+Comment[pl]=Składnik wizytówek (wtyczka KAddressBook)
+Comment[ru]=Контакты (модуль KAddressBook)
+Comment[sr]=Компонента контаката (прикључак KAddressBook-а)
+Comment[sr@Latn]=Komponenta kontakata (priključak KAddressBook-a)
+Comment[sv]=Kontaktkomponent (adressboksinsticksprogram)
+Comment[tr]=Kişiler Bileşeni (KAdresDefteri Eklentisi)
+Comment[zh_CN]=联系人组件(KAddressbook 插件)
+Comment[zh_TW]=聯絡人組件(KAddressBook 外掛程式)
+Name=Contacts
+Name[af]=Kontakte
+Name[ar]=المراسلون
+Name[be]=Кантакты
+Name[bg]=Контакти
+Name[br]=Darempredoù
+Name[bs]=Kontakti
+Name[ca]=Contactes
+Name[cs]=Kontakty
+Name[cy]=Cysylltau
+Name[da]=Kontakter
+Name[de]=Kontakte
+Name[el]=Επαφές
+Name[eo]=Kontaktoj
+Name[es]=Contactos
+Name[et]=Kontaktid
+Name[eu]=Kontaktuak
+Name[fa]=تماسها
+Name[fi]=Yhteystiedot
+Name[fy]=Adressen
+Name[ga]=Teagmhálacha
+Name[gl]=Contactos
+Name[he]=אנשי קשר
+Name[hi]=सम्पर्कों
+Name[hu]=Névjegyek
+Name[is]=Tengiliðir
+Name[it]=Contatti
+Name[ja]=コンタクト
+Name[ka]=კონტაქტები
+Name[kk]=Контакттар
+Name[km]=ទំនាក់ទំនង
+Name[lt]=Kontaktai
+Name[mk]=Контакти
+Name[ms]=Orang hubungan
+Name[nds]=Kontakten
+Name[ne]=सम्पर्क
+Name[nl]=Adressen
+Name[nn]=Kontaktar
+Name[pa]=ਸੰਪਰਕ
+Name[pl]=Wizytówki
+Name[pt]=Contactos
+Name[pt_BR]=Contatos
+Name[ro]=Contacte
+Name[ru]=Контакты
+Name[rw]=Amaderesi
+Name[se]=Oktavuođat
+Name[sk]=Kontakty
+Name[sl]=Stiki
+Name[sr]=Контакти
+Name[sr@Latn]=Kontakti
+Name[sv]=Kontakter
+Name[ta]=தொடர்புகள்
+Name[tg]=Алоқот
+Name[th]=ที่อยู่ติดต่อ
+Name[tr]=Kişiler
+Name[uk]=Контакти
+Name[uz]=Aloqalar
+Name[uz@cyrillic]=Алоқалар
+Name[zh_CN]=联系人
+Name[zh_TW]=聯絡人