<commit_before>/***************************************************************************
                          jabberprotocol.cpp  -  Jabber Plugin
                             -------------------
    begin                : Fri Apr 12 2002
    copyright            : (C) 2002 by <NAME>, <NAME>,
                           Kopete Development team
    email                : <EMAIL>, <EMAIL>
 ***************************************************************************

 ***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#include <kdebug.h>
#include <kgenericfactory.h>
#include <kconfig.h>
#include <kmessagebox.h>
#include <kstatusbar.h>
#include <kiconloader.h>
#include <kpopupmenu.h>
#include <kstandarddirs.h>

#include <qstringlist.h>
#include <qmap.h>
#include <qpixmap.h>
#include <qmovie.h>
#include <qcursor.h>

#include <psi/client.h>
#include <psi/stream.h>
#include <psi/tasks.h>
#include <psi/types.h>
#include <psi/vcard.h>

#include "kopete.h"
#include "systemtray.h"   // I believe that this belongs into kopete.h
#include "kopetewindow.h"
#include "kopetecontact.h"
#include "kopetecontactlist.h"
#include "kopetemetacontact.h"
#include "kopeteaway.h"
#include "kopeteprotocol.h"
#include "kopeteplugin.h"
#include "addcontactpage.h"
#include "statusbaricon.h"
#include "jabbercontact.h"
#include "jabberprefs.h"
#include "dlgjabberstatus.h"
#include "dlgjabbersendraw.h"
#include "jabberaddcontactpage.h"
#include "jabbermap.h"
#include "jabberprotocol.h"

JabberProtocol *JabberProtocol::protocolInstance = 0;

K_EXPORT_COMPONENT_FACTORY(kopete_jabber, KGenericFactory<JabberProtocol>);

JabberProtocol::JabberProtocol(QObject *parent, QString name, QStringList) : KopeteProtocol(parent, name)
{
	kdDebug() << "[JabberProtocol] Loading ..." << endl;

	// this is meant to be a singleton, so we will check if we have been loaded before
	if (protocolInstance)
	{
		kdDebug() << "[JabberProtocol] Warning: Protocol already loaded, not initializing again." << endl;
		return;
	}

	protocolInstance = this;

	jabberClient = 0L;
	registerFlag = 0;

	// these dialogs will be re-instantiated when needed and deleted after
	// they have served their purpose
	reasonDialog = 0L;
	sendRawDialog = 0L;
	
	myContact = 0L;

	initialPresence = STATUS_ONLINE;

	preferences = new JabberPreferences("jabber_protocol_32", this);
	connect (preferences, SIGNAL(saved()), this, SLOT(slotSettingsChanged()));

	// read the Jabber ID from Kopete's configuration
	KGlobal::config()->setGroup("Jabber");

	// setup icons and actions
	initIcons();
	initActions();

	// read remaining settings from configuration file
	slotSettingsChanged();
	
}

JabberProtocol::~JabberProtocol()
{

}

void JabberProtocol::errorConnectFirst()
{

	KMessageBox::error(kopeteapp->mainWindow(), i18n("Please connect first"), i18n("Error"));

}

void JabberProtocol::init()
{

	// initialize icon that sits in Kopete's status bar
	statusBarIcon = new StatusBarIcon();
	QObject::connect(statusBarIcon, SIGNAL(rightClicked(const QPoint&)), this, SLOT(slotIconRightClicked(const QPoint&)));
	statusBarIcon->setPixmap(offlineIcon);

	KGlobal::config()->setGroup("Jabber");

	// make sure we load the SSL library if required
	if(KGlobal::config()->readBoolEntry("UseSSL", "0"))
	{
		// try to load QSSL library needed by libpsi
		// FIXME: this is ugly because it uses fixed dirs! should check ldconfig or something
		QStringList dirs;

		dirs += "/usr/lib";
		dirs += "/usr/local/lib";

		Jabber::Stream::loadSSL(dirs);
	}

	// if we need to connect on startup, do it now
	if (KGlobal::config()->readBoolEntry( "AutoConnect", false ) )
		Connect();

}

bool JabberProtocol::unload()
{
	
	kdDebug() << "[JabberProtocol] Unload..." << endl;
	
	Disconnect();

	// kick the SSL library
	Jabber::Stream::unloadSSL();
	
	// remove the statusbar indicator
	if (kopeteapp->statusBar())
	{
		kopeteapp->statusBar()->removeWidget(statusBarIcon);
		delete statusBarIcon;<commit_msg>Added LD_LIBRARY_PATH to qssl load code<commit_after>/***************************************************************************
                          jabberprotocol.cpp  -  Jabber Plugin
                             -------------------
    begin                : Fri Apr 12 2002
    copyright            : (C) 2002 by <NAME>, <NAME>,
                           Kopete Development team
    email                : <EMAIL>, <EMAIL>
 ***************************************************************************

 ***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#include <kdebug.h>
#include <kgenericfactory.h>
#include <kconfig.h>
#include <kmessagebox.h>
#include <kstatusbar.h>
#include <kiconloader.h>
#include <kpopupmenu.h>
#include <kstandarddirs.h>

#include <qstringlist.h>
#include <qmap.h>
#include <qpixmap.h>
#include <qmovie.h>
#include <qcursor.h>

#include <psi/client.h>
#include <psi/stream.h>
#include <psi/tasks.h>
#include <psi/types.h>
#include <psi/vcard.h>

#include "kopete.h"
#include "systemtray.h"   // I believe that this belongs into kopete.h
#include "kopetewindow.h"
#include "kopetecontact.h"
#include "kopetecontactlist.h"
#include "kopetemetacontact.h"
#include "kopeteaway.h"
#include "kopeteprotocol.h"
#include "kopeteplugin.h"
#include "addcontactpage.h"
#include "statusbaricon.h"
#include "jabbercontact.h"
#include "jabberprefs.h"
#include "dlgjabberstatus.h"
#include "dlgjabbersendraw.h"
#include "jabberaddcontactpage.h"
#include "jabbermap.h"
#include "jabberprotocol.h"

JabberProtocol *JabberProtocol::protocolInstance = 0;

K_EXPORT_COMPONENT_FACTORY(kopete_jabber, KGenericFactory<JabberProtocol>);

JabberProtocol::JabberProtocol(QObject *parent, QString name, QStringList) : KopeteProtocol(parent, name)
{
	kdDebug() << "[JabberProtocol] Loading ..." << endl;

	// this is meant to be a singleton, so we will check if we have been loaded before
	if (protocolInstance)
	{
		kdDebug() << "[JabberProtocol] Warning: Protocol already loaded, not initializing again." << endl;
		return;
	}

	protocolInstance = this;

	jabberClient = 0L;
	registerFlag = 0;

	// these dialogs will be re-instantiated when needed and deleted after
	// they have served their purpose
	reasonDialog = 0L;
	sendRawDialog = 0L;
	
	myContact = 0L;

	initialPresence = STATUS_ONLINE;

	preferences = new JabberPreferences("jabber_protocol_32", this);
	connect (preferences, SIGNAL(saved()), this, SLOT(slotSettingsChanged()));

	// read the Jabber ID from Kopete's configuration
	KGlobal::config()->setGroup("Jabber");

	// setup icons and actions
	initIcons();
	initActions();

	// read remaining settings from configuration file
	slotSettingsChanged();
	
}

JabberProtocol::~JabberProtocol()
{

}

void JabberProtocol::errorConnectFirst()
{

	KMessageBox::error(kopeteapp->mainWindow(), i18n("Please connect first"), i18n("Error"));

}

void JabberProtocol::init()
{

	// initialize icon that sits in Kopete's status bar
	statusBarIcon = new StatusBarIcon();
	QObject::connect(statusBarIcon, SIGNAL(rightClicked(const QPoint&)), this, SLOT(slotIconRightClicked(const QPoint&)));
	statusBarIcon->setPixmap(offlineIcon);

	KGlobal::config()->setGroup("Jabber");

	// make sure we load the SSL library if required
	if(KGlobal::config()->readBoolEntry("UseSSL", "0"))
	{
		// try to load QSSL library needed by libpsi
		// FIXME: this is ugly because it uses fixed dirs! should check ldconfig or something
		QStringList dirs;

		dirs += "/usr/lib";
		dirs += "/usr/local/lib";
		dirs += QStringList::split(":", QString(getenv("LD_LIBRARY_PATH")));

		Jabber::Stream::loadSSL(dirs);
	}

	// if we need to connect on startup, do it now
	if (KGlobal::config()->readBoolEntry( "AutoConnect", false ) )
		Connect();

}

bool JabberProtocol::unload()
{
	
	kdDebug() << "[JabberProtocol] Unload..." << endl;
	
	Disconnect();

	// kick the SSL library
	Jabber::Stream::unloadSSL();
	
	// remove the statusbar indicator
	if (kopeteapp->statusBar())
	{
		kopeteapp->statusBar()->removeWidget(statusBarIcon);
		delete statusBarIcon;
{'fraction_non_alphanumeric': 0.1850958904109589, 'fraction_numerical': 0.00526027397260274, 'mean_word_length': 3.613751263902932, 'pattern_counts': {'":': 1, '<': 73, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4873906', 'n_tokens_mistral': 2935, 'n_tokens_neox': 2729, 'n_words': 709}