Create a custom OTRPluginFactory object instead of using the KGenericFactory

template. This prevents an unwanted creation of a hidden second instance
if the library is built with enabled hidden visibility.

This resolves issue #3.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/2/head
Slávek Banko 3 years ago
parent d4af338ad1
commit 186deab80c
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -83,6 +83,7 @@ tde_add_kpart( ${PROJECT_NAME} AUTOMOC
SOURCES
otrplugin-factory.cpp
LINK
kotr-shared
tdecore-shared

@ -18,6 +18,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include <tdeaction.h>
#include <tdelocale.h>

@ -45,13 +45,10 @@ namespace Kopete { class ChatSession; }
*/
class OtrGUIClient : public TQObject , public KXMLGUIClient
class OtrGUIClient : public TQObject, public KXMLGUIClient
{
Q_OBJECT
public:
OtrGUIClient( Kopete::ChatSession *parent, const char *name=0L );

@ -24,6 +24,10 @@
* @author Michael Zanetti
*/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include <sys/types.h>
#include <sys/stat.h>
@ -60,8 +64,6 @@
#include "privkeypopup.h"
#include "smppopup.h"
#include "config.h"
OtrlChatInterface *OtrlChatInterface::mSelf = 0;
static OtrlUserState userstate;
static OtrlPolicy confPolicy;

@ -23,6 +23,10 @@
* @author Michael Zanetti
*/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include <tqapplication.h>
#include <tqeventloop.h>

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2007 by Michael Zanetti *
* Copyright (C) 2021 by Slávek Banko *
* *
* *
* This program is free software; you can redistribute it and/or modify *
@ -15,18 +15,44 @@
* 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. *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include <kgenericfactory.h>
#include <tdeaboutdata.h>
#include "otrplugin-factory.h"
#include "otrplugin.h"
/**
* @author Michael Zanetti
*/
typedef KGenericFactory<OTRPlugin> OTRPluginFactory;
// typedef KGenericFactory<OTRPlugin> OTRPluginFactory;
static const TDEAboutData aboutdata("kopete_otr", I18N_NOOP("OTR") , "0.7" );
K_EXPORT_COMPONENT_FACTORY( kopete_otr, OTRPluginFactory( &aboutdata ) )
TDEInstance *OTRPluginFactory::s_instance = 0;
OTRPluginFactory::OTRPluginFactory( const TDEAboutData *aboutdata )
{
s_instance = new TDEInstance( aboutdata );
}
OTRPluginFactory::~OTRPluginFactory()
{
delete s_instance;
}
KParts::Part *OTRPluginFactory::createPartObject( TQWidget * /*parentWidget*/,
const char * /*widgetName*/,
TQObject *parent,
const char *name,
const char * /*className*/,
const TQStringList & args )
{
return (KParts::Part*) new OTRPlugin( instance(), parent, name, args);
}
#include "otrplugin-factory.moc"

@ -0,0 +1,45 @@
/***************************************************************************
* Copyright (C) 2021 by Slávek Banko *
* *
* *
* 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. *
***************************************************************************/
#if !defined(OTRPLUGIN_FACTORY_H)
#define OTRPLUGIN_FACTORY_H
#include <tdeparts/factory.h>
class OTRPluginFactory : public KParts::Factory
{
Q_OBJECT
public:
OTRPluginFactory( const TDEAboutData* );
virtual ~OTRPluginFactory();
virtual KParts::Part *createPartObject( TQWidget *parentWidget, const char *widgetName,
TQObject *parent, const char *name,
const char *className, const TQStringList &args );
static TDEInstance *instance() { return s_instance; }
private:
static TDEInstance *s_instance;
};
#endif /* OTRPLUGIN_FACTORY_H */

@ -18,6 +18,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include <tqstylesheet.h>
#include <tqtimer.h>
#include <tqregexp.h>
@ -56,11 +60,8 @@
*/
typedef KGenericFactory<OTRPlugin> OTRPluginFactory;
OTRPlugin::OTRPlugin( TQObject *parent, const char *name, const TQStringList & /* args */ )
: Kopete::Plugin( OTRPluginFactory::instance(), parent, name )
OTRPlugin::OTRPlugin( TDEInstance *instance, TQObject *parent, const char *name, const TQStringList & /* args */ )
: Kopete::Plugin( instance, parent, name )
{
if( !pluginStatic_ )
pluginStatic_=this;

@ -19,7 +19,7 @@
#define OTRPLUGIN_H
#include "kdebug.h"
#include <kdebug.h>
#include <kopeteplugin.h>
#include <kopetemessagehandler.h>
@ -69,12 +69,11 @@ class KDE_EXPORT OTRPlugin : public Kopete::Plugin
{
Q_OBJECT
public:
static OTRPlugin *plugin();
OTRPlugin( TQObject *parent, const char *name, const TQStringList &args );
OTRPlugin( TDEInstance *instance, TQObject *parent, const char *name, const TQStringList &args );
~OTRPlugin();
void emitGoneSecure( Kopete::ChatSession *session, int status );
@ -113,7 +112,6 @@ private:
signals:
void goneSecure( Kopete::ChatSession *session, int state );
};
#endif

@ -18,6 +18,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include <tqlayout.h>
#include <tqlabel.h>
#include <tqmap.h>

@ -32,7 +32,6 @@
class OTRPreferences : public TDECModule {
Q_OBJECT
public:
OTRPreferences(TQWidget *parent = 0, const char *name = 0, const TQStringList &args = TQStringList());
~OTRPreferences();

@ -22,6 +22,11 @@
* @author Michael Zanetti
*/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include <kdemacros.h>
#include "privkeypopup.h"

@ -31,7 +31,6 @@ class PrivKeyPopup : public PrivKeyPopupUI
{
Q_OBJECT
public:
PrivKeyPopup(TQWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~PrivKeyPopup();
@ -53,4 +52,3 @@ protected slots:
};
#endif

@ -18,13 +18,17 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "tqlabel.h"
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include "kdebug.h"
#include "tdelocale.h"
#include "klineedit.h"
#include "kurl.h"
#include "krun.h"
#include <tqlabel.h>
#include <kdebug.h>
#include <tdelocale.h>
#include <klineedit.h>
#include <kurl.h>
#include <krun.h>
#include "smppopup.h"
#include "verifypopup.h"

@ -34,7 +34,6 @@ class SMPPopup : public SMPPopupUI
{
Q_OBJECT
public:
SMPPopup(TQWidget* parent = 0, const char* name = 0, TQString title = TQString::null, WFlags fl = 0, ConnContext *context = 0, Kopete::ChatSession *session = 0, bool initiate = true );
~SMPPopup();
@ -61,4 +60,3 @@ protected slots:
};
#endif

@ -18,6 +18,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include "verifypopup.h"
#include "otrlchatinterface.h"

@ -28,7 +28,6 @@ class VerifyPopup : public VerifyPopupUI
{
Q_OBJECT
public:
VerifyPopup(TQWidget* parent = 0, const char* name = 0, Kopete::ChatSession *session = NULL, bool modal = FALSE, WFlags fl = 0 );
~VerifyPopup();
@ -48,4 +47,3 @@ protected slots:
};
#endif

Loading…
Cancel
Save