<commit_before>/***************************************************************************
                          wppreferences.cpp  -  description
                             -------------------
    begin                : Fri Apr 26 2002
    copyright            : (C) 2002 by <NAME>
    email                : <EMAIL>

    Based on code from   : (C) 2002 by <NAME>
    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.                                   *
 *                                                                         *
 ***************************************************************************/
// QT Includes
#include <qlayout.h>

// KDE Includes
#include <kcombobox.h>
#include <kdebug.h>
#include <kiconloader.h>
#include <kurlrequester.h>
#include <kmessagebox.h>
#include <klocale.h>

// Kopete Includes
#include <addcontactpage.h>

// Local Includes
#include "wpaddcontactbase.h"
#include "wpaccount.h"
#include "wpaddcontact.h"

WPAddContact::WPAddContact(QWidget *parent, WPAccount *newAccount, const char *name) : AddContactPage(parent, name)
{
//	kdDebug(14170) << "WPAddContact::WPAddContact(<owner>, " << newAccount << ", <parent>, " << name << ")" << endl;

	(new QVBoxLayout(this))->setAutoAdd(true);
	theDialog = new WPAddContactBase(this);
	connect(theDialog->mHostGroup, SIGNAL(activated(const QString &)), this, SLOT(slotSelected(const QString &)));
	connect(theDialog->mRefresh, SIGNAL(clicked()), this, SLOT(slotUpdateGroups()));
	theDialog->show();
	theAccount = newAccount;

	slotUpdateGroups();
	slotSelected(theDialog->mHostGroup->currentText());
}

WPAddContact::~WPAddContact()
{
}

void WPAddContact::slotUpdateGroups()
{
	kdDebug(14170) << "WPAddContact::slotUpdateGroups()" << endl;

	theDialog->mHostGroup->clear();
	QStringList Groups = theAccount->getGroups();
	QStringList::ConstIterator end = Groups.end();
	for (QStringList::ConstIterator i = Groups.begin(); i != end; i++)
		theDialog->mHostGroup->insertItem(SmallIcon("network"), *i);
	slotSelected(theDialog->mHostGroup->currentText());
}

void WPAddContact::slotSelected(const QString &Group)
{
	kdDebug(14170) << "WPAddContact::slotSelected(" << Group << ")" << endl;

	theDialog->mHostName->clear();
	QStringList Hosts = theAccount->getHosts(Group);
	QStringList::ConstIterator end = Hosts.end();
	for (QStringList::ConstIterator i = Hosts.begin(); i != end; i++)
		theDialog->mHostName->insertItem(SmallIcon("personal"), *i);
}

bool WPAddContact::validateData()
{
	kdDebug(14170) << "WPAddContact::validateData()" << endl;

	QString tmpHostName = theDialog->mHostName->currentText();

	if (tmpHostName.isEmpty()) {
		KMessageBox::sorry(this, i18n("<qt>You must enter a valid hostname.</qt>"), i18n("WinPopup"));
		return false;
	}

	// If our own host is not allowed as contact localhost should be forbidden as well,
	// additionally somehow localhost as contact crashes when receiving a message from it?? GF
	if (tmpHostName.upper() == "LOCALHOST") {
		KMessageBox::sorry(this, i18n("<qt>LOCALHOST is not allowed as contact.</qt>"), i18n("WinPopup"));
		return false;
	}

	return true;
}

bool WPAddContact::apply(Kopete::Account *theAccount, Kopete::MetaContact *theMetaContact)
{
	kdDebug(14170) << "WPAddContact::apply(" << theAccount << ", " << theMetaContact << ")" << endl;

	// TODO: make the nickname an option
	theAccount->addContact(theDialog->mHostName->currentText(), theMetaContact, Kopete::Account::ChangeKABC );
	return true;
}

#include "wpaddcontact.moc"

// vim: set noet ts=4 sts=4 sw=4:
// kate: tab-width 4; indent-width 4; replace-trailing-space-save on;
<commit_msg>proper return value for apply()<commit_after>/***************************************************************************
                          wppreferences.cpp  -  description
                             -------------------
    begin                : Fri Apr 26 2002
    copyright            : (C) 2002 by <NAME>
    email                : <EMAIL>

    Based on code from   : (C) 2002 by <NAME>
    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.                                   *
 *                                                                         *
 ***************************************************************************/
// QT Includes
#include <qlayout.h>

// KDE Includes
#include <kcombobox.h>
#include <kdebug.h>
#include <kiconloader.h>
#include <kurlrequester.h>
#include <kmessagebox.h>
#include <klocale.h>

// Kopete Includes
#include <addcontactpage.h>

// Local Includes
#include "wpaddcontactbase.h"
#include "wpaccount.h"
#include "wpaddcontact.h"

WPAddContact::WPAddContact(QWidget *parent, WPAccount *newAccount, const char *name) : AddContactPage(parent, name)
{
//	kdDebug(14170) << "WPAddContact::WPAddContact(<owner>, " << newAccount << ", <parent>, " << name << ")" << endl;

	(new QVBoxLayout(this))->setAutoAdd(true);
	theDialog = new WPAddContactBase(this);
	connect(theDialog->mHostGroup, SIGNAL(activated(const QString &)), this, SLOT(slotSelected(const QString &)));
	connect(theDialog->mRefresh, SIGNAL(clicked()), this, SLOT(slotUpdateGroups()));
	theDialog->show();
	theAccount = newAccount;

	slotUpdateGroups();
	slotSelected(theDialog->mHostGroup->currentText());
}

WPAddContact::~WPAddContact()
{
}

void WPAddContact::slotUpdateGroups()
{
	kdDebug(14170) << "WPAddContact::slotUpdateGroups()" << endl;

	theDialog->mHostGroup->clear();
	QStringList Groups = theAccount->getGroups();
	QStringList::ConstIterator end = Groups.end();
	for (QStringList::ConstIterator i = Groups.begin(); i != end; i++)
		theDialog->mHostGroup->insertItem(SmallIcon("network"), *i);
	slotSelected(theDialog->mHostGroup->currentText());
}

void WPAddContact::slotSelected(const QString &Group)
{
	kdDebug(14170) << "WPAddContact::slotSelected(" << Group << ")" << endl;

	theDialog->mHostName->clear();
	QStringList Hosts = theAccount->getHosts(Group);
	QStringList::ConstIterator end = Hosts.end();
	for (QStringList::ConstIterator i = Hosts.begin(); i != end; i++)
		theDialog->mHostName->insertItem(SmallIcon("personal"), *i);
}

bool WPAddContact::validateData()
{
	kdDebug(14170) << "WPAddContact::validateData()" << endl;

	QString tmpHostName = theDialog->mHostName->currentText();

	if (tmpHostName.isEmpty()) {
		KMessageBox::sorry(this, i18n("<qt>You must enter a valid hostname.</qt>"), i18n("WinPopup"));
		return false;
	}

	// If our own host is not allowed as contact localhost should be forbidden as well,
	// additionally somehow localhost as contact crashes when receiving a message from it?? GF
	if (tmpHostName.upper() == "LOCALHOST") {
		KMessageBox::sorry(this, i18n("<qt>LOCALHOST is not allowed as contact.</qt>"), i18n("WinPopup"));
		return false;
	}

	return true;
}

bool WPAddContact::apply(Kopete::Account *theAccount, Kopete::MetaContact *theMetaContact)
{
	kdDebug(14170) << "WPAddContact::apply(" << theAccount << ", " << theMetaContact << ")" << endl;

	// TODO: make the nickname an option
	return theAccount->addContact(theDialog->mHostName->currentText(), theMetaContact, Kopete::Account::ChangeKABC );
}

#include "wpaddcontact.moc"

// vim: set noet ts=4 sts=4 sw=4:
// kate: tab-width 4; indent-width 4; replace-trailing-space-save on;

{'fraction_non_alphanumeric': 0.2112779201757598, 'fraction_numerical': 0.012937873794702796, 'mean_word_length': 3.717328727691422, 'pattern_counts': {'":': 0, '<': 119, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4422327', 'n_tokens_mistral': 2515, 'n_tokens_neox': 2343, 'n_words': 557}