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 SOURCES
otrplugin-factory.cpp otrplugin-factory.cpp
LINK LINK
kotr-shared kotr-shared
tdecore-shared tdecore-shared

@ -18,6 +18,9 @@
* 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 <tdeaction.h> #include <tdeaction.h>
#include <tdelocale.h> #include <tdelocale.h>

@ -45,12 +45,9 @@ namespace Kopete { class ChatSession; }
*/ */
class OtrGUIClient : public TQObject, public KXMLGUIClient
class OtrGUIClient : public TQObject , public KXMLGUIClient
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -70,7 +67,7 @@ private slots:
void slotDisableOtr(); void slotDisableOtr();
void encryptionEnabled( Kopete::ChatSession* session, int state ); void encryptionEnabled( Kopete::ChatSession* session, int state );
void slotVerifyFingerprint(); void slotVerifyFingerprint();
signals: signals:
void signalOtrChatsession( Kopete::ChatSession* session, bool enable ); void signalOtrChatsession( Kopete::ChatSession* session, bool enable );
void signalVerifyFingerprint( Kopete::ChatSession *session ); void signalVerifyFingerprint( Kopete::ChatSession *session );

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

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

@ -60,7 +60,7 @@ private:
OtrlUserState userstate; OtrlUserState userstate;
TQWidget *preferencesDialog; TQWidget *preferencesDialog;
Fingerprint *findFingerprint( TQString strFingerprint ); Fingerprint *findFingerprint( TQString strFingerprint );
}; };
#endif #endif

@ -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 * * 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 * * You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the * * along with this program; if not, write to the *
* Free Software Foundation, Inc., * * 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 <kgenericfactory.h>
#include <tdeaboutdata.h> #include <tdeaboutdata.h>
#include "otrplugin-factory.h"
#include "otrplugin.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" ); static const TDEAboutData aboutdata("kopete_otr", I18N_NOOP("OTR") , "0.7" );
K_EXPORT_COMPONENT_FACTORY( kopete_otr, OTRPluginFactory( &aboutdata ) ) 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. * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/ ***************************************************************************/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
#include <tqstylesheet.h> #include <tqstylesheet.h>
#include <tqtimer.h> #include <tqtimer.h>
#include <tqregexp.h> #include <tqregexp.h>
@ -56,11 +60,8 @@
*/ */
OTRPlugin::OTRPlugin( TDEInstance *instance, TQObject *parent, const char *name, const TQStringList & /* args */ )
typedef KGenericFactory<OTRPlugin> OTRPluginFactory; : Kopete::Plugin( instance, parent, name )
OTRPlugin::OTRPlugin( TQObject *parent, const char *name, const TQStringList & /* args */ )
: Kopete::Plugin( OTRPluginFactory::instance(), parent, name )
{ {
if( !pluginStatic_ ) if( !pluginStatic_ )
pluginStatic_=this; pluginStatic_=this;

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

@ -18,6 +18,10 @@
* 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 <tqlayout.h> #include <tqlayout.h>
#include <tqlabel.h> #include <tqlabel.h>
#include <tqmap.h> #include <tqmap.h>

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

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

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

@ -18,13 +18,17 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * 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 <tqlabel.h>
#include "tdelocale.h"
#include "klineedit.h" #include <kdebug.h>
#include "kurl.h" #include <tdelocale.h>
#include "krun.h" #include <klineedit.h>
#include <kurl.h>
#include <krun.h>
#include "smppopup.h" #include "smppopup.h"
#include "verifypopup.h" #include "verifypopup.h"

@ -33,7 +33,6 @@ extern "C"{
class SMPPopup : public SMPPopupUI class SMPPopup : public SMPPopupUI
{ {
Q_OBJECT Q_OBJECT
public: 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(TQWidget* parent = 0, const char* name = 0, TQString title = TQString::null, WFlags fl = 0, ConnContext *context = 0, Kopete::ChatSession *session = 0, bool initiate = true );
@ -61,4 +60,3 @@ protected slots:
}; };
#endif #endif

@ -18,6 +18,9 @@
* 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 "verifypopup.h" #include "verifypopup.h"
#include "otrlchatinterface.h" #include "otrlchatinterface.h"

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

Loading…
Cancel
Save