00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#include <qwidget.h>
00025
00026
#include <kaction.h>
00027
#include <kapplication.h>
00028
#include <kdebug.h>
00029
#include <kgenericfactory.h>
00030
#include <kiconloader.h>
00031
#include <kmessagebox.h>
00032
#include <kparts/componentfactory.h>
00033
00034
#include <dcopclient.h>
00035
00036
#include "core.h"
00037
#include "kabsummarywidget.h"
00038
#include "plugin.h"
00039
00040
#include "kaddressbook_plugin.h"
00041
00042
typedef KGenericFactory< KAddressbookPlugin, Kontact::Core > KAddressbookPluginFactory;
00043 K_EXPORT_COMPONENT_FACTORY( libkontact_kaddressbookplugin,
00044 KAddressbookPluginFactory(
"kontact_kaddressbookplugin" ) )
00045
00046 KAddressbookPlugin::KAddressbookPlugin( Kontact::
Core *core, const
char *, const QStringList& )
00047 : Kontact::Plugin( core, core, "kaddressbook" ),
00048 mStub( 0 )
00049 {
00050 setInstance( KAddressbookPluginFactory::instance() );
00051
00052 insertNewAction(
new KAction( i18n(
"New Contact" ), BarIcon(
"identity" ),
00053 0,
this, SLOT( slotNewContact() ), actionCollection(),
00054
"new_contact" ) );
00055 mUniqueAppWatcher =
new Kontact::UniqueAppWatcher(
00056
new Kontact::UniqueAppHandlerFactory<KABUniqueAppHandler>(),
this );
00057 }
00058
00059 KAddressbookPlugin::~KAddressbookPlugin()
00060 {
00061 }
00062
00063 KParts::Part* KAddressbookPlugin::createPart()
00064 {
00065 KParts::Part * part = loadPart();
00066
if ( !part )
return 0;
00067
00068
00069 mStub =
new KAddressBookIface_stub( dcopClient(),
"kaddressbook",
00070
"KAddressBookIface" );
00071
return part;
00072 }
00073
00074 QStringList KAddressbookPlugin::configModules()
const
00075
{
00076 QStringList modules;
00077 modules <<
"PIM/kabconfig.desktop" <<
"PIM/kabldapconfig.desktop";
00078
return modules;
00079 }
00080
00081 QStringList KAddressbookPlugin::invisibleToolbarActions()
const
00082
{
00083
return QStringList(
"file_new_contact" );
00084 }
00085
00086
void KAddressbookPlugin::slotNewContact()
00087 {
00088 (
void) part();
00089 Q_ASSERT( mStub );
00090
if ( mStub )
00091 mStub->newContact();
00092 }
00093
00094
bool KAddressbookPlugin::createDCOPInterface(
const QString& serviceType )
00095 {
00096
if ( serviceType ==
"DCOP/AddressBook" ) {
00097 Q_ASSERT( mStub );
00098
return true;
00099 }
00100
00101
return false;
00102 }
00103
00104
bool KAddressbookPlugin::isRunningStandalone()
00105 {
00106
return mUniqueAppWatcher->isRunningStandalone();
00107 }
00108
00109
Kontact::Summary *KAddressbookPlugin::createSummaryWidget( QWidget *parentWidget )
00110 {
00111
return new KABSummaryWidget(
this, parentWidget );
00112 }
00113
00115
00116
#include "../../../kaddressbook/kaddressbook_options.h"
00117
#include <dcopref.h>
00118
00119
void KABUniqueAppHandler::loadCommandLineOptions()
00120 {
00121 KCmdLineArgs::addCmdLineOptions( kaddressbook_options );
00122 }
00123
00124
int KABUniqueAppHandler::newInstance()
00125 {
00126
00127
00128 (
void)plugin()->part();
00129 DCOPRef kAB(
"kaddressbook",
"KAddressBookIface" );
00130 DCOPReply reply = kAB.call(
"handleCommandLine" );
00131
if ( reply.isValid() ) {
00132
bool handled = reply;
00133
00134
if ( !handled )
00135
return Kontact::UniqueAppHandler::newInstance();
00136 }
00137
return 0;
00138 }
00139
00140
#include "kaddressbook_plugin.moc"
00141
00142