kontact Library API Documentation

kaddressbook_plugin.cpp

00001 /* 00002 This file is part of Kontact. 00003 Copyright (c) 2003 Kontact Developer 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of Qt, and distribute the resulting executable, 00021 without including the source code for Qt in the source distribution. 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 // Create the stub that allows us to talk to the part 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(); // ensure part is loaded 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 //kdDebug() << k_funcinfo << endl; 00127 // Ensure part is loaded 00128 (void)plugin()->part(); 00129 DCOPRef kAB( "kaddressbook", "KAddressBookIface" ); 00130 DCOPReply reply = kAB.call( "handleCommandLine" ); 00131 if ( reply.isValid() ) { 00132 bool handled = reply; 00133 //kdDebug() << k_funcinfo << "handled=" << handled << endl; 00134 if ( !handled ) // no args -> simply bring kaddressbook plugin to front 00135 return Kontact::UniqueAppHandler::newInstance(); 00136 } 00137 return 0; 00138 } 00139 00140 #include "kaddressbook_plugin.moc" 00141 00142 // vim: sw=2 sts=2 tw=80 et
KDE Logo
This file is part of the documentation for kontact Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:15 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003