plugin.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <qobjectlist.h>
00024
00025 #include <dcopclient.h>
00026 #include <kaboutdata.h>
00027 #include <kglobal.h>
00028 #include <kparts/componentfactory.h>
00029 #include <kdebug.h>
00030 #include <kinstance.h>
00031 #include <krun.h>
00032
00033 #include "core.h"
00034 #include "plugin.h"
00035
00036 using namespace Kontact;
00037
00038 class Plugin::Private
00039 {
00040 public:
00041 Kontact::Core *core;
00042 DCOPClient *dcopClient;
00043 QPtrList<KAction> *newActions;
00044 QString identifier;
00045 QString title;
00046 QString icon;
00047 QString executableName;
00048 QCString partLibraryName;
00049 KParts::Part *part;
00050 };
00051
00052
00053 Plugin::Plugin( Kontact::Core *core, QObject *parent, const char *name )
00054 : QObject( parent, name ), d( new Private )
00055 {
00056 KGlobal::locale()->insertCatalogue(name);
00057
00058 d->core = core;
00059 d->dcopClient = 0;
00060 d->newActions = new QPtrList<KAction>;
00061 d->part = 0;
00062 }
00063
00064
00065 Plugin::~Plugin()
00066 {
00067 delete d->part;
00068 delete d->dcopClient;
00069 delete d;
00070 }
00071
00072 void Plugin::setIdentifier( const QString &identifier )
00073 {
00074 d->identifier = identifier;
00075 }
00076
00077 QString Plugin::identifier() const
00078 {
00079 return d->identifier;
00080 }
00081
00082 void Plugin::setTitle( const QString &title )
00083 {
00084 d->title = title;
00085 }
00086
00087 QString Plugin::title() const
00088 {
00089 return d->title;
00090 }
00091
00092 void Plugin::setIcon( const QString &icon )
00093 {
00094 d->icon = icon;
00095 }
00096
00097 QString Plugin::icon() const
00098 {
00099 return d->icon;
00100 }
00101
00102 void Plugin::setExecutableName( const QString& bin )
00103 {
00104 d->executableName = bin;
00105 }
00106
00107 QString Plugin::executableName() const
00108 {
00109 return d->executableName;
00110 }
00111
00112 void Plugin::setPartLibraryName( const QCString &libName )
00113 {
00114 d->partLibraryName = libName;
00115 }
00116
00117 KParts::Part *Plugin::loadPart()
00118 {
00119 return core()->createPart( d->partLibraryName );
00120 }
00121
00122 const KAboutData *Plugin::aboutData()
00123 {
00124 kdDebug() << "Plugin::aboutData(): libname: " << d->partLibraryName << endl;
00125
00126 const KInstance *instance =
00127 KParts::Factory::partInstanceFromLibrary( d->partLibraryName );
00128
00129 if ( instance ) {
00130 return instance->aboutData();
00131 } else {
00132 kdError() << "Plugin::aboutData(): Can't load instance for "
00133 << title() << endl;
00134 return 0;
00135 }
00136 }
00137
00138 KParts::Part *Plugin::part()
00139 {
00140 if ( !d->part ) {
00141 d->part = createPart();
00142 if( d->part ) {
00143 connect( d->part, SIGNAL( destroyed() ), SLOT( partDestroyed() ) );
00144 core()->partLoaded( this, d->part );
00145 }
00146 }
00147 return d->part;
00148 }
00149
00150 QString Plugin::tipFile() const
00151 {
00152 return QString::null;
00153 }
00154
00155
00156 DCOPClient* Plugin::dcopClient() const
00157 {
00158 if ( !d->dcopClient ) {
00159 d->dcopClient = new DCOPClient();
00160
00161
00162
00163 d->dcopClient->registerAs( name(), false );
00164 }
00165
00166 return d->dcopClient;
00167 }
00168
00169 void Plugin::insertNewAction( KAction *action )
00170 {
00171 d->newActions->append( action );
00172 }
00173
00174 QPtrList<KAction> *Plugin::newActions() const
00175 {
00176 return d->newActions;
00177 }
00178
00179 Kontact::Core *Plugin::core() const
00180 {
00181 return d->core;
00182 }
00183
00184 void Plugin::select()
00185 {
00186 }
00187
00188 void Plugin::configUpdated()
00189 {
00190 }
00191
00192 void Plugin::partDestroyed()
00193 {
00194 d->part = 0;
00195 }
00196
00197 void Plugin::bringToForeground()
00198 {
00199 if (!d->executableName.isEmpty())
00200 KRun::runCommand(d->executableName);
00201 }
00202
00203 #include "plugin.moc"
00204
00205
This file is part of the documentation for kontact Library Version 3.2.2.