summaryrefslogtreecommitdiffstats
path: root/kopete/plugins/smpppdcs
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbcb704366cb5e333a626c18c308c7e0448a8e69f (patch)
treef0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /kopete/plugins/smpppdcs
downloadtdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz
tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/plugins/smpppdcs')
-rw-r--r--kopete/plugins/smpppdcs/Changelog.smpppdcs67
-rw-r--r--kopete/plugins/smpppdcs/Makefile.am35
-rw-r--r--kopete/plugins/smpppdcs/detector.h59
-rw-r--r--kopete/plugins/smpppdcs/detectordcop.cpp77
-rw-r--r--kopete/plugins/smpppdcs/detectordcop.h51
-rw-r--r--kopete/plugins/smpppdcs/detectornetstat.cpp76
-rw-r--r--kopete/plugins/smpppdcs/detectornetstat.h56
-rw-r--r--kopete/plugins/smpppdcs/detectornetworkstatus.cpp68
-rw-r--r--kopete/plugins/smpppdcs/detectornetworkstatus.h50
-rw-r--r--kopete/plugins/smpppdcs/detectorsmpppd.cpp71
-rw-r--r--kopete/plugins/smpppdcs/detectorsmpppd.h46
-rw-r--r--kopete/plugins/smpppdcs/iconnector.h45
-rw-r--r--kopete/plugins/smpppdcs/icons/Makefile.am2
-rw-r--r--kopete/plugins/smpppdcs/icons/cr32-app-smpppdcs.pngbin0 -> 426 bytes
-rw-r--r--kopete/plugins/smpppdcs/kinternetiface.h47
-rw-r--r--kopete/plugins/smpppdcs/kopete_smpppdcs.desktop108
-rw-r--r--kopete/plugins/smpppdcs/kopete_smpppdcs_config.desktop108
-rw-r--r--kopete/plugins/smpppdcs/libsmpppdclient/Makefile.am10
-rw-r--r--kopete/plugins/smpppdcs/libsmpppdclient/smpppdclient.cpp104
-rw-r--r--kopete/plugins/smpppdcs/libsmpppdclient/smpppdclient.h80
-rw-r--r--kopete/plugins/smpppdcs/libsmpppdclient/smpppdready.cpp104
-rw-r--r--kopete/plugins/smpppdcs/libsmpppdclient/smpppdready.h49
-rw-r--r--kopete/plugins/smpppdcs/libsmpppdclient/smpppdstate.cpp76
-rw-r--r--kopete/plugins/smpppdcs/libsmpppdclient/smpppdstate.h58
-rw-r--r--kopete/plugins/smpppdcs/libsmpppdclient/smpppdunsettled.cpp153
-rw-r--r--kopete/plugins/smpppdcs/libsmpppdclient/smpppdunsettled.h49
-rw-r--r--kopete/plugins/smpppdcs/onlineinquiry.cpp45
-rw-r--r--kopete/plugins/smpppdcs/onlineinquiry.h45
-rw-r--r--kopete/plugins/smpppdcs/smpppdcs.kcfg29
-rw-r--r--kopete/plugins/smpppdcs/smpppdcsconfig.kcfgc6
-rw-r--r--kopete/plugins/smpppdcs/smpppdcsiface.h36
-rw-r--r--kopete/plugins/smpppdcs/smpppdcsplugin.cpp221
-rw-r--r--kopete/plugins/smpppdcs/smpppdcsplugin.h109
-rw-r--r--kopete/plugins/smpppdcs/smpppdcspreferences.cpp187
-rw-r--r--kopete/plugins/smpppdcs/smpppdcspreferences.h77
-rw-r--r--kopete/plugins/smpppdcs/smpppdcsprefs.ui284
-rw-r--r--kopete/plugins/smpppdcs/smpppdcsprefsimpl.cpp165
-rw-r--r--kopete/plugins/smpppdcs/smpppdcsprefsimpl.h76
-rw-r--r--kopete/plugins/smpppdcs/smpppdlocationui.ui149
-rw-r--r--kopete/plugins/smpppdcs/smpppdlocationwidget.cpp30
-rw-r--r--kopete/plugins/smpppdcs/smpppdlocationwidget.h39
-rw-r--r--kopete/plugins/smpppdcs/smpppdsearcher.cpp189
-rw-r--r--kopete/plugins/smpppdcs/smpppdsearcher.h102
-rw-r--r--kopete/plugins/smpppdcs/unittest/Makefile.am15
-rw-r--r--kopete/plugins/smpppdcs/unittest/clienttest.cpp121
-rw-r--r--kopete/plugins/smpppdcs/unittest/clienttest.h50
-rw-r--r--kopete/plugins/smpppdcs/unittest/main.cpp45
47 files changed, 3669 insertions, 0 deletions
diff --git a/kopete/plugins/smpppdcs/Changelog.smpppdcs b/kopete/plugins/smpppdcs/Changelog.smpppdcs
new file mode 100644
index 00000000..80854a86
--- /dev/null
+++ b/kopete/plugins/smpppdcs/Changelog.smpppdcs
@@ -0,0 +1,67 @@
+Changelog/README SMPPPDCS
+=========================
+
+The smpppdcs-plugin for Kopete provides a internet connection
+detection based on SuSE's kinternet/smpppd or on the netstat
+program.
+
+The smpppd is a controller to the internet interfaces. The plugin
+is inquiring this interface frequently and checks if it reports a
+connection to the internet and then activates all Kopete accounts.
+
+The netstat is checking if a default gateway is existing and then
+activates all Kopete accounts, too.
+
+Changelog
+=========
+
+0.79 (2006/01/25)
+* using KConfigXT for configuration
+* using dcopidl2cpp stub generated from kinternetiface.h (from kinternet package),
+ no more own implementation
+* experimental implementation of the the KDED-NetworkStatus (not active, yet)
+* significantly speeded up automatic detection of a SMPPPD
+* BUGFIX: reloading the plugin in a already running Kopete will no more
+ result in an inactive plugin
+* refactoring to allow easy implementation of new detection methods
+* even more speed improvements
+
+0.75 (2006/01/01)
+* use of KSocketStream instead of deprecated KExtendedSocket
+* progressbar while searching for an smpppd on the local network
+* automatically found smpppd server is resolved via DNS
+* Fixed Bug 111369: better detection of a SMPPPD and no more freeze of Kopete
+
+0.74 (2005/12/27)
+* minor bugfixes
+* disable netstat in config if the binary cannot be found
+
+0.72 (2005/09/07)
+* internal refactoring to provide online status
+
+0.7 (2004/11/20)
+
+* list to ignore accounts integrated.
+ Accounts can be excluded from the plugin connect/disconnect
+ mechanism
+* connection detection enhanced: first kinternet is asked via
+ DCOP for a running connection, if this fails the smpppd is asked
+* improved startup detection, compatible with recent CVS changes
+* some API chages in the config module
+
+0.6 (2004/10/18)
+
+* adapting to KDE 3.3.1
+
+0.4 (2004/10/05)
+
+* toggling between netstat and smpppdcs works without restart
+ of kopete
+
+0.3 (2004/10/03)
+
+* accounts get activated after they are loaded and initialized
+
+0.1 (2004/09/04)
+
+* first version of the plugin
diff --git a/kopete/plugins/smpppdcs/Makefile.am b/kopete/plugins/smpppdcs/Makefile.am
new file mode 100644
index 00000000..11173ac6
--- /dev/null
+++ b/kopete/plugins/smpppdcs/Makefile.am
@@ -0,0 +1,35 @@
+METASOURCES = AUTO
+
+SUBDIRS = icons libsmpppdclient unittest
+
+EXTRA_DIST = Changelog.smpppdcs
+
+AM_CPPFLAGS = $(KOPETE_INCLUDES) $(all_includes) -Ilibsmpppdclient
+
+kde_module_LTLIBRARIES = kopete_smpppdcs.la kcm_kopete_smpppdcs.la
+
+kopete_smpppdcs_la_SOURCES = kinternetiface.stub smpppdcsplugin.cpp \
+ onlineinquiry.cpp smpppdcsiface.skel detectordcop.cpp detectorsmpppd.cpp \
+ detectornetstat.cpp detectornetworkstatus.cpp smpppdcsconfig.kcfgc
+kopete_smpppdcs_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+kopete_smpppdcs_la_LIBADD = \
+ libsmpppdclient/libsmpppdclient.la ../../libkopete/libkopete.la
+
+kcm_kopete_smpppdcs_la_SOURCES = smpppdcsprefs.ui smpppdcspreferences.cpp \
+ smpppdsearcher.cpp smpppdcsprefsimpl.cpp smpppdlocationui.ui smpppdlocationwidget.cpp \
+ smpppdcsconfig.kcfgc
+kcm_kopete_smpppdcs_la_LDFLAGS = -module -no-undefined $(KDE_PLUGIN) $(all_libraries)
+kcm_kopete_smpppdcs_la_LIBADD = libsmpppdclient/libsmpppdclient.la \
+ ../../libkopete/libkopete.la $(LIB_KUTILS)
+
+service_DATA = kopete_smpppdcs.desktop
+servicedir = $(kde_servicesdir)
+
+kcm_DATA = kopete_smpppdcs_config.desktop
+kcmdir = $(kde_servicesdir)/kconfiguredialog
+
+kde_kcfg_DATA = smpppdcs.kcfg
+
+noinst_HEADERS = smpppdcsiface.h detectordcop.h detectorsmpppd.h \
+ detectornetstat.h kinternetiface.h detectornetworkstatus.h \
+ smpppdsearcher.h smpppdcsprefsimpl.h smpppdlocationwidget.h
diff --git a/kopete/plugins/smpppdcs/detector.h b/kopete/plugins/smpppdcs/detector.h
new file mode 100644
index 00000000..094de9e5
--- /dev/null
+++ b/kopete/plugins/smpppdcs/detector.h
@@ -0,0 +1,59 @@
+/*
+ detector.h
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef DETECTOR_H
+#define DETECTOR_H
+
+class IConnector;
+
+/**
+ * @brief Detector interface to find out if there is a connection to the internet.
+ *
+ * Subclasses should implement the specific ways to check for an internet
+ * connection
+ *
+ * @author Heiko Sch&auml;fer <heiko@rangun.de>
+ *
+ */
+
+class Detector {
+
+ Detector(const Detector&);
+ Detector& operator=(const Detector&);
+
+public:
+ /**
+ * @brief Creates an <code>Detector</code> instance.
+ *
+ * @param connector A connector to send feedback to the calling object
+ */
+ Detector(IConnector * connector) : m_connector(connector) {}
+
+ /**
+ * @brief Destroys an <code>Detector</code> instance.
+ *
+ */
+ virtual ~Detector() {}
+
+ virtual void checkStatus() const = 0;
+
+ virtual void smpppdServerChange() {}
+
+protected:
+ IConnector * m_connector;
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/detectordcop.cpp b/kopete/plugins/smpppdcs/detectordcop.cpp
new file mode 100644
index 00000000..2536674d
--- /dev/null
+++ b/kopete/plugins/smpppdcs/detectordcop.cpp
@@ -0,0 +1,77 @@
+/*
+ detectordcop.cpp
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <kapplication.h>
+#include <dcopclient.h>
+#include <kdebug.h>
+
+#include "kinternetiface_stub.h"
+
+#include "detectordcop.h"
+#include "iconnector.h"
+
+QCString DetectorDCOP::m_kinternetApp = "";
+
+DetectorDCOP::DetectorDCOP(IConnector * connector)
+ : Detector(connector) {}
+
+DetectorDCOP::~DetectorDCOP() {}
+
+/*!
+ \fn DetectorDCOP::getKInternetDCOP()
+ */
+QCString DetectorDCOP::getKInternetDCOP() const {
+ DCOPClient * client = kapp->dcopClient();
+ if(m_kinternetApp.isEmpty() && client && client->isAttached()) {
+ // get all registered dcop apps and search for kinternet
+ QCStringList apps = client->registeredApplications();
+ QCStringList::iterator iter;
+ for(iter = apps.begin(); iter != apps.end(); ++iter) {
+ if((*iter).left(9) == "kinternet") {
+ return *iter;
+ }
+ }
+ }
+
+ return m_kinternetApp;
+}
+
+/*!
+ \fn DetectorDCOP::getConnectionStatusDCOP()
+ */
+DetectorDCOP::KInternetDCOPState DetectorDCOP::getConnectionStatusDCOP() const {
+ kdDebug(14312) << k_funcinfo << "Start inquiring " << m_kinternetApp << " via DCOP" << endl;
+
+
+ KInternetIface_stub stub = KInternetIface_stub(kapp->dcopClient(), m_kinternetApp, "KInternetIface");
+
+ bool status = stub.isOnline();
+
+ if(stub.ok()) {
+ if(status) {
+ kdDebug(14312) << k_funcinfo << "isOnline() returned true" << endl;
+ return CONNECTED;
+ } else {
+ kdDebug(14312) << k_funcinfo << "isOnline() returned false" << endl;
+ return DISCONNECTED;
+ }
+ } else {
+ kdWarning(14312) << k_funcinfo << "DCOP call to " << m_kinternetApp << " failed!";
+ }
+
+ return ERROR;
+}
+
diff --git a/kopete/plugins/smpppdcs/detectordcop.h b/kopete/plugins/smpppdcs/detectordcop.h
new file mode 100644
index 00000000..5306998b
--- /dev/null
+++ b/kopete/plugins/smpppdcs/detectordcop.h
@@ -0,0 +1,51 @@
+/*
+ detectordcop.h
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef DETECTORDCOP_H
+#define DETECTORDCOP_H
+
+#include "detector.h"
+
+class IConnector;
+
+/**
+ @author Heiko Sch&auml;fer <heiko@rangun.de>
+*/
+class DetectorDCOP : public Detector {
+
+ DetectorDCOP(const DetectorDCOP&);
+ DetectorDCOP& operator=(const DetectorDCOP&);
+
+public:
+ DetectorDCOP(IConnector * connector);
+ virtual ~DetectorDCOP();
+
+protected:
+
+ enum KInternetDCOPState {
+ CONNECTED,
+ DISCONNECTED,
+ ERROR
+ };
+
+ QCString getKInternetDCOP() const;
+ KInternetDCOPState getConnectionStatusDCOP() const;
+
+protected:
+ static QCString m_kinternetApp;
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/detectornetstat.cpp b/kopete/plugins/smpppdcs/detectornetstat.cpp
new file mode 100644
index 00000000..60dff658
--- /dev/null
+++ b/kopete/plugins/smpppdcs/detectornetstat.cpp
@@ -0,0 +1,76 @@
+/*
+ detectornetstat.cpp
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <kdebug.h>
+#include <kprocess.h>
+
+#include "iconnector.h"
+#include "detectornetstat.h"
+
+DetectorNetstat::DetectorNetstat(IConnector* connector)
+ : Detector(connector), m_buffer(QString::null), m_process(NULL) {}
+
+DetectorNetstat::~DetectorNetstat() {
+ delete m_process;
+}
+
+void DetectorNetstat::checkStatus() const {
+ kdDebug(14312) << k_funcinfo << endl;
+
+ if(m_process) {
+ kdWarning(14312) << k_funcinfo << "Previous netstat process is still running!" << endl
+ << "Not starting new netstat. Perhaps your system is under heavy load?" << endl;
+
+ return;
+ }
+
+ m_buffer = QString::null;
+
+ // Use KProcess to run netstat -r. We'll then parse the output of
+ // netstat -r in slotProcessStdout() to see if it mentions the
+ // default gateway. If so, we're connected, if not, we're offline
+ m_process = new KProcess;
+ *m_process << "netstat" << "-r";
+
+ connect(m_process, SIGNAL(receivedStdout(KProcess *, char *, int)), this, SLOT(slotProcessStdout( KProcess *, char *, int)));
+ connect(m_process, SIGNAL(processExited(KProcess *)), this, SLOT(slotProcessExited(KProcess *)));
+
+ if(!m_process->start(KProcess::NotifyOnExit, KProcess::Stdout)) {
+ kdWarning(14312) << k_funcinfo << "Unable to start netstat process!" << endl;
+
+ delete m_process;
+ m_process = 0L;
+ }
+}
+
+void DetectorNetstat::slotProcessStdout(KProcess *, char *buffer, int buflen) {
+ // Look for a default gateway
+ kdDebug(14312) << k_funcinfo << endl;
+ m_buffer += QString::fromLatin1(buffer, buflen);
+ kdDebug(14312) << m_buffer << endl;
+}
+
+void DetectorNetstat::slotProcessExited(KProcess *process) {
+ kdDebug(14312) << k_funcinfo << m_buffer << endl;
+ if(process == m_process) {
+ m_connector->setConnectedStatus(m_buffer.contains("default"));
+ m_buffer = QString::null;
+ delete m_process;
+ m_process = 0L;
+ }
+}
+
+#include "detectornetstat.moc"
diff --git a/kopete/plugins/smpppdcs/detectornetstat.h b/kopete/plugins/smpppdcs/detectornetstat.h
new file mode 100644
index 00000000..d51a6d97
--- /dev/null
+++ b/kopete/plugins/smpppdcs/detectornetstat.h
@@ -0,0 +1,56 @@
+/*
+ detectornetstat.h
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef DETECTORNETSTAT_H
+#define DETECTORNETSTAT_H
+
+#include <qobject.h>
+
+#include "detector.h"
+
+class KProcess;
+class IConnector;
+
+/**
+ @author Heiko Sch&auml;fer <heiko@rangun.de>
+*/
+class DetectorNetstat : protected QObject, public Detector {
+ Q_OBJECT
+
+ DetectorNetstat(const DetectorNetstat&);
+ DetectorNetstat& operator=(const DetectorNetstat&);
+
+public:
+ DetectorNetstat(IConnector* connector);
+ virtual ~DetectorNetstat();
+
+ virtual void checkStatus() const;
+
+private slots:
+ // Original cs-plugin code
+ void slotProcessStdout(KProcess * process, char * buffer, int len);
+
+ /**
+ * Notify when the netstat process has exited
+ */
+ void slotProcessExited(KProcess *process);
+
+private:
+ mutable QString m_buffer;
+ mutable KProcess * m_process;
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/detectornetworkstatus.cpp b/kopete/plugins/smpppdcs/detectornetworkstatus.cpp
new file mode 100644
index 00000000..921718b7
--- /dev/null
+++ b/kopete/plugins/smpppdcs/detectornetworkstatus.cpp
@@ -0,0 +1,68 @@
+/*
+ detectornetworkstatus.cpp
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <kdebug.h>
+
+#include "kopeteuiglobal.h"
+#include "connectionmanager.h"
+
+#include "iconnector.h"
+#include "detectornetworkstatus.h"
+
+DetectorNetworkStatus::DetectorNetworkStatus(IConnector* connector)
+ : Detector(connector), m_connManager(NULL) {
+
+ m_connManager = ConnectionManager::self();
+ connect(m_connManager, SIGNAL(statusChanged(const QString&, NetworkStatus::EnumStatus)),
+ this, SLOT(statusChanged(const QString&, NetworkStatus::EnumStatus)));
+}
+
+DetectorNetworkStatus::~DetectorNetworkStatus() {}
+
+void DetectorNetworkStatus::checkStatus() const {
+ // needs to do nothing
+}
+
+void DetectorNetworkStatus::statusChanged(const QString& host, NetworkStatus::EnumStatus status) {
+ switch(status) {
+ case NetworkStatus::Offline:
+ kdDebug(14312) << k_funcinfo << host << ": NetworkStatus::Offline" << endl;
+ break;
+ case NetworkStatus::OfflineFailed:
+ kdDebug(14312) << k_funcinfo << host << ": NetworkStatus::OfflineFailed" << endl;
+ break;
+ case NetworkStatus::OfflineDisconnected:
+ kdDebug(14312) << k_funcinfo << host << ": NetworkStatus::OfflineDisconnected" << endl;
+ break;
+ case NetworkStatus::ShuttingDown:
+ kdDebug(14312) << k_funcinfo << host << ": NetworkStatus::ShuttingDown" << endl;
+ break;
+ case NetworkStatus::Establishing:
+ kdDebug(14312) << k_funcinfo << host << ": NetworkStatus::Establishing" << endl;
+ break;
+ case NetworkStatus::Online:
+ kdDebug(14312) << k_funcinfo << host << ": NetworkStatus::Online" << endl;
+ break;
+ case NetworkStatus::NoNetworks:
+ kdDebug(14312) << k_funcinfo << host << ": NetworkStatus::NoNetworks" << endl;
+ break;
+ case NetworkStatus::Unreachable:
+ kdDebug(14312) << k_funcinfo << host << ": NetworkStatus::Unreachable" << endl;
+ break;
+ }
+}
+
+#include "detectornetworkstatus.moc"
diff --git a/kopete/plugins/smpppdcs/detectornetworkstatus.h b/kopete/plugins/smpppdcs/detectornetworkstatus.h
new file mode 100644
index 00000000..20315902
--- /dev/null
+++ b/kopete/plugins/smpppdcs/detectornetworkstatus.h
@@ -0,0 +1,50 @@
+/*
+ detectornetworkstatus.h
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef DETECTORNETWORKSTATUS_H
+#define DETECTORNETWORKSTATUS_H
+
+#include <qobject.h>
+
+#include "detector.h"
+
+class IConnector;
+class ConnectionManager;
+
+/**
+ @author Heiko Sch&auml;fer <heiko@rangun.de>
+*/
+class DetectorNetworkStatus : protected QObject, public Detector
+{
+ Q_OBJECT
+
+ DetectorNetworkStatus(const DetectorNetworkStatus&);
+ DetectorNetworkStatus& operator=(const DetectorNetworkStatus&);
+
+public:
+ DetectorNetworkStatus(IConnector* connector);
+ virtual ~DetectorNetworkStatus();
+
+ virtual void checkStatus() const;
+
+protected slots:
+ void statusChanged(const QString& host, NetworkStatus::EnumStatus status);
+
+private:
+ ConnectionManager * m_connManager;
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/detectorsmpppd.cpp b/kopete/plugins/smpppdcs/detectorsmpppd.cpp
new file mode 100644
index 00000000..35ed1e05
--- /dev/null
+++ b/kopete/plugins/smpppdcs/detectorsmpppd.cpp
@@ -0,0 +1,71 @@
+/*
+ detectorsmpppd.cpp
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kconfig.h>
+#include <kapplication.h>
+
+#include "iconnector.h"
+#include "detectorsmpppd.h"
+#include "smpppdcsconfig.h"
+
+#include "smpppdclient.h"
+
+DetectorSMPPPD::DetectorSMPPPD(IConnector * connector)
+ : DetectorDCOP(connector) {}
+
+DetectorSMPPPD::~DetectorSMPPPD() {}
+
+/*!
+ \fn DetectorSMPPPD::checkStatus()
+ */
+void DetectorSMPPPD::checkStatus() const {
+ kdDebug(14312) << k_funcinfo << "Checking for online status..." << endl;
+
+#ifndef NOKINTERNETDCOP
+ m_kinternetApp = getKInternetDCOP();
+ if(kapp->dcopClient() && m_kinternetApp != "") {
+ switch(getConnectionStatusDCOP()) {
+ case CONNECTED:
+ m_connector->setConnectedStatus(true);
+ return;
+ case DISCONNECTED:
+ m_connector->setConnectedStatus(false);
+ return;
+ default:
+ break;
+ }
+ }
+#else
+#warning DCOP inquiry disabled
+ kdDebug(14312) << k_funcinfo << "DCOP inquiry disabled" << endl;
+#endif
+
+ SMPPPD::Client c;
+
+ unsigned int port = SMPPPDCSConfig::self()->port();
+ QString server = SMPPPDCSConfig::self()->server();
+
+ c.setPassword(SMPPPDCSConfig::self()->password().utf8());
+
+ if(c.connect(server, port)) {
+ m_connector->setConnectedStatus(c.isOnline());
+ } else {
+ kdDebug(14312) << k_funcinfo << "not connected to smpppd => I'll try again later" << endl;
+ m_connector->setConnectedStatus(false);
+ }
+}
diff --git a/kopete/plugins/smpppdcs/detectorsmpppd.h b/kopete/plugins/smpppdcs/detectorsmpppd.h
new file mode 100644
index 00000000..0f72d46d
--- /dev/null
+++ b/kopete/plugins/smpppdcs/detectorsmpppd.h
@@ -0,0 +1,46 @@
+/*
+ detectorsmpppd.h
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef DETECTORSMPPPD_H
+#define DETECTORSMPPPD_H
+
+#include <qstringlist.h>
+
+#include "detectordcop.h"
+
+namespace KNetwork {
+class KStreamSocket;
+};
+
+class IConnector;
+
+/**
+ @author Heiko Sch&auml;fer <heiko@rangun.de>
+*/
+class DetectorSMPPPD : public DetectorDCOP {
+
+ DetectorSMPPPD(const DetectorSMPPPD&);
+ DetectorSMPPPD& operator=(const DetectorSMPPPD&);
+
+public:
+ DetectorSMPPPD(IConnector* connector);
+ virtual ~DetectorSMPPPD();
+
+ virtual void checkStatus() const;
+
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/iconnector.h b/kopete/plugins/smpppdcs/iconnector.h
new file mode 100644
index 00000000..c4846862
--- /dev/null
+++ b/kopete/plugins/smpppdcs/iconnector.h
@@ -0,0 +1,45 @@
+/*
+ iconnector.h
+
+ Copyright (c) 2005-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef ICONNECTOR_H
+#define ICONNECTOR_H
+
+/**
+ * @brief Interface to an object setting a connection status.
+ *
+ * @author Heiko Sch&auml;fer <heiko@rangun.de>
+ */
+class IConnector {
+ IConnector(const IConnector&);
+ IConnector& operator=(const IConnector&);
+
+public:
+ IConnector() {}
+
+ virtual ~IConnector() {}
+
+ /**
+ * @brief Set the connection status.
+ *
+ * This method needs to get reimplemented at classes which implement
+ * this interface.
+ *
+ * @param newStatus the status of the internet connection, <code>TRUE</code> if there is a connection, otherwise <code>FALSE</code>
+ */
+ virtual void setConnectedStatus(bool newStatus) = 0;
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/icons/Makefile.am b/kopete/plugins/smpppdcs/icons/Makefile.am
new file mode 100644
index 00000000..9143c6b4
--- /dev/null
+++ b/kopete/plugins/smpppdcs/icons/Makefile.am
@@ -0,0 +1,2 @@
+kopeteicondir = $(kde_datadir)/kopete/icons
+kopeteicon_ICON = AUTO
diff --git a/kopete/plugins/smpppdcs/icons/cr32-app-smpppdcs.png b/kopete/plugins/smpppdcs/icons/cr32-app-smpppdcs.png
new file mode 100644
index 00000000..d895298b
--- /dev/null
+++ b/kopete/plugins/smpppdcs/icons/cr32-app-smpppdcs.png
Binary files differ
diff --git a/kopete/plugins/smpppdcs/kinternetiface.h b/kopete/plugins/smpppdcs/kinternetiface.h
new file mode 100644
index 00000000..b0ac8aa7
--- /dev/null
+++ b/kopete/plugins/smpppdcs/kinternetiface.h
@@ -0,0 +1,47 @@
+// -*- c++ -*-
+/***************************************************************************
+ * *
+ * Copyright: SuSE Linux AG, Nuernberg *
+ * *
+ * Author: Arvin Schnell <arvin@suse.de> *
+ * *
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef KINTERNETIFACE_H
+#define KINTERNETIFACE_H
+
+
+#include <dcopobject.h>
+
+class KInternetIface : public DCOPObject
+{
+ K_DCOP
+
+public:
+
+ KInternetIface (const QCString& name) : DCOPObject (name) { }
+
+k_dcop:
+
+ // query function for susewatcher
+ bool isOnline () {
+#ifndef NDEBUG
+ fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
+#endif
+ return kinternet && kinternet->get_status () == KInternet::CONNECTED;
+ }
+
+};
+
+
+#endif
diff --git a/kopete/plugins/smpppdcs/kopete_smpppdcs.desktop b/kopete/plugins/smpppdcs/kopete_smpppdcs.desktop
new file mode 100644
index 00000000..09653c75
--- /dev/null
+++ b/kopete/plugins/smpppdcs/kopete_smpppdcs.desktop
@@ -0,0 +1,108 @@
+[Desktop Entry]
+Type=Service
+Icon=smpppdcs
+X-Kopete-Version=1000900
+ServiceTypes=Kopete/Plugin
+X-KDE-Library=kopete_smpppdcs
+X-KDE-PluginInfo-Author=Heiko Schäfer
+X-KDE-PluginInfo-Email=heiko@rangun.de
+X-KDE-PluginInfo-Name=kopete_smpppdcs
+X-KDE-PluginInfo-Version=0.79
+X-KDE-PluginInfo-Website=http://www.rangun.de
+X-KDE-PluginInfo-Category=Plugins
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=true
+Name=SUSE smpppd-enabled Connection Status (SMPPPD)
+Name[bn]=SUSE smpppd-enabled সংযোগ অবস্থা (SMPPPD)
+Name[bs]=Status veze koji koristi SUSE-ov smpppd servis
+Name[ca]=Estat actiu de la connexió SUSE smpppd (SMPPPD)
+Name[cs]=Stav spojení SUSE smpppd-enabled (SMPPPD)
+Name[da]=SUSE smpppd-aktiveret Forbindelsesstatus (SMPPPD)
+Name[de]=Verbindungsstatus mit Unterstützung für SuSE SMPPPD
+Name[el]=SuSE smpppd-ενεργοποίηση κατάσταση σύνδεσης (SMPPPD)
+Name[es]=Estado de conexión con SUSE smpppd habilitado (SMPPPD)
+Name[et]=SUSE smpppd-võimalusega ühenduse staatus (SMPPPD)
+Name[eu]=SUSE smpppd-gaitutat konexioaren egoera (SMPPPD)
+Name[fa]=وضعیت اتصال فعال -SUSE smpppd (SMPPPD)
+Name[fi]=SUSE smpppd-enabled -yhteyden tila (SMPPPD)
+Name[fr]=État de la connexion pour « smpppd-enabled » de SUSE (SMPPPD)
+Name[he]=SUSE smpppd-מאפשר מצב חיבור (SMPPPD)
+Name[hu]=SUSE smpppd-alapú állapotjellemző (SMPPPD)
+Name[is]=SUSE smpppd-virkt staða tengingar (SMPPPD)
+Name[it]=Stato della connessione di SUSE smpppd
+Name[ja]=SUSE smpppd を使った接続状態 (SMPPPD)
+Name[ka]=SUSE smpppd-ჩართული კავშირის სტატუსი (SMPPPD)
+Name[kk]=SUSE smpppd (SMPPPD) қосылымының күйі
+Name[km]=ស្ថានភាព​តភ្ជាប់ SUSE ដែល​អនុញ្ញាត smpppd (SMPPPD)
+Name[lt]=SUSE smpppd ryšio būklė (SMPPPD)
+Name[nb]=Tilstand for SMPPPD – SUSE smpppd-forbindelse
+Name[nds]=Verbinnenstatus mit Ünnerstütten för SuSE-SMPPPD
+Name[ne]=SUSE smpppd ले जडान वस्तुस्थिति (SMPPPD) सक्षम पार्यो
+Name[nl]=SUSE smpppd-geactiveerde verbindingsstatus (SMPPPD)
+Name[nn]=Tilstand for SMPPPD – SUSE smpppd-forbindelse
+Name[pl]=Status połączenia SUSE SMPPPD
+Name[pt]=Estado da Ligação activado pelo 'smpppd' da SUSE (SMPPPD)
+Name[pt_BR]=Status da Conexão compatível com SUSE smpppd
+Name[ru]=Статус соединения с SUSE smpppd (SMPPPD)
+Name[sk]=Stav spojenia SUSE smpppd-enabled (SMPPPD)
+Name[sl]=Stanje povezave z uporabo SuSE SMPPPD
+Name[sr]=Статус SUSE-ове smpppd-везе (SMPPPD)
+Name[sr@Latn]=Status SUSE-ove smpppd-veze (SMPPPD)
+Name[sv]=SUSE SMPPPD-aktiverad anslutningsstatus (SMPPPD)
+Name[tr]=SUSE smpppd Bağlantı Durumu (SMPPPD)
+Name[uk]=SUSE smpppd-уможливлений Стан з'єднання (SMPPPD)
+Name[zh_CN]=SUSE smppp 连接状态(SMPPPD)
+Name[zh_HK]=連接 SUSE smpppd 的連線狀態 (SMPPPD)
+Name[zh_TW]=SUSE smpppd 連線狀態
+Comment=Connects/disconnects Kopete automatically depending on availability of Internet connection
+Comment[ar]=يقوم بوصل و فصل Kopete تلقائيا استنادا إلى وضع الاتصال بالشبكة
+Comment[be]=Злучае/адлучае Kopete ад сервісаў у залежнасці ад наяўнасці інтэрфэйсаў з Інтэрнэтам
+Comment[bg]=Автоматично установяване и прекъсване на връзката в зависимост от състоянието на връзката с Интернет
+Comment[bn]=ইন্টারনেট সংযোগের সুবিধা অনুযায়ী কপেট স্বয়ংক্রীয়ভাবে সংযোগ/সংযোগবিচ্ছিন্নকরে
+Comment[bs]=Automatski spaja Kopete i prekida vezu ovisno o dostupnosti Internet konekcije
+Comment[ca]=Connecta/desconnecta automàticament depenent de la disponibilitat de la connexió a Internet
+Comment[cs]=Automaticky připojí nebo odpojí vzhledem k dostupnosti připojení na Internet
+Comment[cy]=Cysylltu/datgyslltu Kopete yn ymysgogol, yn dibynnu ar argaeledd cysylltiad Rhyngrwyd
+Comment[da]=Forbinder/afbryder Kopete automatisk afhængig af om der er en internet-forbindelse
+Comment[de]=Verbindet/trennt Kopete automatisch abhängig von der Verfügbarkeit einer Internetverbindung
+Comment[el]=Συνδέει/αποσυνδέει το Kopete αυτόματα ανάλογα με την κατάσταση της σύνδεσης με το διαδίκτυο
+Comment[es]=Conecta/desconecta Kopete automáticamente según la disponibilidad de la conexión a internet
+Comment[et]=Kopete automaatne ühendamine/ühenduse katkestamine vastavalt internetiühenduse olemasolule
+Comment[eu]=Kopete automatikoki konektatu/deskonektatzen du internet-eko konexioaren eskuragarritasunaren arabera
+Comment[fa]=بسته به قابلیت دسترسی اتصال اینترنت، Kopete به طور خودکار وصل/قطع ارتباط می‌کند
+Comment[fi]=Yhdistää/katkaisee yhteyden automaattisesti riippuen onko Internet-yhteys päällä
+Comment[fr]=Connecte / déconnecte automatiquement Kopete en fonction de la disponibilité de la connexion Internet
+Comment[gl]=Conecta/desconecta a Kopete automáticamente dependendo da disponibilidade de conexión a Internet
+Comment[he]=חיבור\ניתוק Kopete באופן אוטומטי בתלות בזמינות של החיבור לאינטרנט
+Comment[hi]=इंटरनेट कनेक्शन की उपलब्धता की निर्भरता के आधार पर के-ऑप्टी को स्वचलित कनेक्ट/डिस्कनेक्ट करता है
+Comment[hu]=A Kopete automatikus csatlakoztatása és bontása az internetkapcsolat elérhetőségétől függően
+Comment[is]=(Af)tengir Kopete sjálfkrafa miðað við stöðu Internettengingar
+Comment[it]=Connetti/disconnetti automaticamente Kopete a seconda della disponibilità della connessione ad internet
+Comment[ja]=インターネット接続の有無により自動的に Kopete を接続/切断します
+Comment[ka]=ინტერნეტ კავშირის არსებობისას ავტომატურად აკავშირებს Kopete-ს
+Comment[kk]=Интернетке қосылымның бар=жоғына қарай Kopete-ті автоматты түрде қосады және ажыратады
+Comment[km]=ភ្ជាប់ ​ ​ផ្ដាច​ Kopeteដោយ​ស្វ័យប្រវត្តិ​ដោយ​ផ្អែក​លើ​ភាព​មាន​នៃការណត​ភ្ជាប់​អ៊ីនធឺណិត
+Comment[lt]=Automatiškai prijungia/atjungia Kopete, priklausomai nuo interneto ryšio buvimo
+Comment[mk]=Автоматски го поврзува/исклучува Kopete во зависност на достапноста на поврзувањето на Интернет
+Comment[nb]=Kobler Kopete automatisk til/fra avhengig av om internettforbindelse er tilgjengelig
+Comment[nds]=Koppelt Kopete automaatsch to- oder af, afhangen vun de Verföögborkeit vun de Internetverbinnen
+Comment[ne]=इन्टरनेट जडानको उपलब्धतामा आधारित कोपेट स्वचालित रूपमा जडान गर्दछ/विच्छेदन गर्दछ
+Comment[nl]=Bouwt automatisch verbindingen op voor Kopete of verbreekt ze, afhankelijk van de beschikbaarheid van de internetverbinding
+Comment[nn]=Koplar Kopete automatisk til eller frå avhengig av om Internett-sambandet er tilgjengeleg.
+Comment[pl]=Automatycznie podłącza/odłącza Kopete zależnie od stanu połączenia z Internetem
+Comment[pt]=Liga/desliga o Kopete automaticamente, dependendo da disponibilidade de uma ligação à Internet
+Comment[pt_BR]=Conecta/desconecta o Kopete automaticamente dependendo da disponibilidade da conexão com a Internet
+Comment[ru]=Автоматически входит в сеть или выходит из неё в зависимости от наличия соединения с Интернет
+Comment[sk]=Pripojí/odpojí Kopete v závislosti či existuje pripojenie na Internet
+Comment[sl]=Samodejno vzpostavi/prekine povezavo Kopete glede na dostopnost internetne povezave
+Comment[sr]=Аутоматски успоставља или прекида везу у Kopete-у у зависности од доступности интернет везе
+Comment[sr@Latn]=Automatski uspostavlja ili prekida vezu u Kopete-u u zavisnosti od dostupnosti internet veze
+Comment[sv]=Ansluter eller kopplar ner Kopete automatiskt beroende på Internetförbindelsens tillgänglighet
+Comment[ta]=இணைய இணைப்பை பொருத்து Kopete யுடன்தானாக இணையும்/நீக்கும்
+Comment[tg]=Вобаста ба имкониятҳои алоқаи Интернет Kopete-ро ба таври худкор пайваст/канда мекунад
+Comment[tr]=İnternet bağlantısının kullanılabilir olabilirliğine göre Kopete'yi otomatik bağlar/bağlamaz
+Comment[uk]=Автоматично входить в мережу чи виходить з неї в залежності від наявності з'єднання з Інтернет
+Comment[zh_CN]=根据 Internet 连接是否可用自动连接/断开 Kopete
+Comment[zh_HK]=自動根據互聯網連接情況連接或中斷 Kopete 連線
+Comment[zh_TW]=自動依據網路狀況來連線/中斷連線 Kopete
diff --git a/kopete/plugins/smpppdcs/kopete_smpppdcs_config.desktop b/kopete/plugins/smpppdcs/kopete_smpppdcs_config.desktop
new file mode 100644
index 00000000..3a2553cf
--- /dev/null
+++ b/kopete/plugins/smpppdcs/kopete_smpppdcs_config.desktop
@@ -0,0 +1,108 @@
+[Desktop Entry]
+Icon=smpppdcs
+Type=Service
+ServiceTypes=KCModule
+
+X-KDE-ModuleType=Library
+X-KDE-Library=kopete_smpppdcs
+X-KDE-FactoryName=SMPPPDCSConfigFactory
+X-KDE-ParentApp=kopete_smpppdcs
+X-KDE-ParentComponents=kopete_smpppdcs
+
+X-Kopete-Version=1000900
+
+Name=SUSE SMPPPD Connection Status
+Name[be]=Стан злучэння SUSE SMPPPD
+Name[bn]=SUSE SMPPPD সংযোগ অবস্থা
+Name[bs]=SUSE SMPPPD status veze
+Name[ca]=Estatus de la connexió SUSE SMPPPD
+Name[cs]=Stav spojení SUSE SMPPPD
+Name[da]=SUSE SMPPD Forbindelsesstatus
+Name[de]=SuSE SMPPPD-Verbindungsstatus
+Name[el]=Κατάσταση σύνδεσης του SuSE SMPPPD
+Name[es]=Estado de conexión de SUSE SMPPPD
+Name[et]=SUSE SMPPPD ühenduse staatus
+Name[eu]=SUSE SMPPPD konexioaren egoera
+Name[fa]=وضعیت اتصال SUSE SMPPPD
+Name[fi]=SUSE SMPPPD -yhteyden tila
+Name[fr]=État de la connexion SUSE SMPPPD
+Name[ga]=Stádas Ceangail SUSE SMPPPD
+Name[gl]=Estado da conexión de SUSE SMPPPD
+Name[he]=מצב החיבור של SUSE SMPPPD
+Name[hu]=SUSE SMPPPD kapcsolati állapot
+Name[is]=SUSE SMPPPD tengingarstaða
+Name[it]=Stato della connessione di SUSE SMPPPD
+Name[ja]=SUSE SMPPPD 接続状態
+Name[ka]=SUSE SMPPPD კავშირის სტატუსი
+Name[kk]=SUSE SMPPPD байланыс күйі
+Name[km]=ស្ថានភាព​ការ​តភ្ជាប់ SUSE SMPPPD
+Name[lt]=SUSE SMPPPD ryšio būklė
+Name[nb]=Tilstand for SUSE-SMPPPD-forbindelsen
+Name[nds]=SUSE SMPPPD-Verbinnenstatus
+Name[ne]=SUSE SMPPPD जडान वस्तुस्थिति
+Name[nl]=SUSE SMPPPD-verbindingsstatus
+Name[nn]=Tilstand for SUSE-SMPPPD-sambandet
+Name[pl]=Status połączenia SUSE SMPPPD
+Name[pt]=Estado da Ligação do SMPPPD para a SUSE
+Name[pt_BR]=Status da Conexão SUSE SMPPPD
+Name[ru]=Статус соединения SUSE SMPPPD
+Name[sk]=Stav spojenia SUSE SMPPPD
+Name[sl]=Stanje povezave z uporabo SuSE SMPPPD
+Name[sr]=Статус SUSE-ове SMPPPD везе
+Name[sr@Latn]=Status SUSE-ove SMPPPD veze
+Name[sv]=SUSE SMPPPD anslutningsstatus
+Name[tr]=SUSE SMPPPD bağlantı durumu
+Name[uk]=Стан з'єднання SUSE SMPPPD
+Name[zh_CN]=SUSE SMPPPD 连接状态
+Name[zh_HK]=SUSE SMPPPD 連線狀態
+Name[zh_TW]=SUSE SMPPPD 連線狀態
+Comment=SMPPPDCS Plugin
+Comment[be]=Модуль SMPPPDCS
+Comment[bn]=SMPPPDCS প্লাগিন
+Comment[br]=Lugant SMPPPDCS
+Comment[bs]=SMPPPDCS dodatak
+Comment[ca]=Connector SMPPPDCS
+Comment[cs]=SMPPPDCS modul
+Comment[da]=SMPPPDCS-Plugin
+Comment[de]=SMPPPDCS-Modul
+Comment[el]=Πρόσθετο SMPPPDCS
+Comment[eo]=SMPPPDCS-kromaĵo
+Comment[es]=Extensión SMPPPDCS
+Comment[et]=SMPPPDCS plugin
+Comment[eu]=SMPPPDCS plugin-a
+Comment[fa]=SUSE SMPPPD وصلۀ
+Comment[fi]=SMPPPDCS-liitännäinen
+Comment[fr]=Module SMPPPDCS
+Comment[ga]=Breiseán SMPPPDCS
+Comment[gl]=Plugin SMPPPDCS
+Comment[he]=תוסף SMPPPDCS
+Comment[hu]=SMPPPDCS bővítőmodul
+Comment[is]=SMPPPDCS íforrit
+Comment[it]=Plugin SMPPPDCS
+Comment[ja]=SMPPPDCS プラグイン
+Comment[ka]=SMPPPDCS მოდული
+Comment[kk]=SMPPPDCS плагин модулі
+Comment[km]=កម្មវិធី​ជំនួយ SMPPPDCS
+Comment[lt]=SMPPPDCS įskiepis
+Comment[nb]=Programtillegg for SMPPPDCS
+Comment[nds]=SMPPPDCS-Moduul
+Comment[ne]=SMPPPDCS प्लगइन
+Comment[nl]=SMPPPDCS-plugin
+Comment[nn]=Programtillegg for SMPPPDCS
+Comment[pl]=Wtyczka SMPPPDCS
+Comment[pt]='Plugin' do SMPPPDCS
+Comment[pt_BR]=Plugin SMPPPDCS
+Comment[ro]=Modul SMPPPDCS
+Comment[ru]=Модуль SMPPPDCS
+Comment[sk]=SMPPPDCS modul
+Comment[sl]=Vstavek SMPPPDCS
+Comment[sr]=Прикључак SMPPPDCS
+Comment[sr@Latn]=Priključak SMPPPDCS
+Comment[sv]=SMPPPDCS-insticksprogram
+Comment[tr]=SMPPPDCS Eklentisi
+Comment[uk]=Втулок SMPPPDCS
+Comment[uz]=SMPPPDCS plagini
+Comment[uz@cyrillic]=SMPPPDCS плагини
+Comment[zh_CN]=SMPPPDCS 插件
+Comment[zh_HK]=SMPPPDCS 插件
+Comment[zh_TW]=SMPPPDCS 外掛程式
diff --git a/kopete/plugins/smpppdcs/libsmpppdclient/Makefile.am b/kopete/plugins/smpppdcs/libsmpppdclient/Makefile.am
new file mode 100644
index 00000000..9fc9258c
--- /dev/null
+++ b/kopete/plugins/smpppdcs/libsmpppdclient/Makefile.am
@@ -0,0 +1,10 @@
+AM_CPPFLAGS = $(all_includes)
+
+noinst_LTLIBRARIES = libsmpppdclient.la
+libsmpppdclient_la_LDFLAGS = -avoid-version $(all_libraries)
+
+noinst_HEADERS = smpppdclient.h smpppdstate.h smpppdready.h smpppdunsettled.h
+libsmpppdclient_la_SOURCES = smpppdclient.cpp smpppdstate.cpp smpppdready.cpp \
+ smpppdunsettled.cpp
+
+libsmpppdclient_la_LIBADD = -lcrypto
diff --git a/kopete/plugins/smpppdcs/libsmpppdclient/smpppdclient.cpp b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdclient.cpp
new file mode 100644
index 00000000..d386b669
--- /dev/null
+++ b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdclient.cpp
@@ -0,0 +1,104 @@
+/*
+ smpppdclient.cpp
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <kstreamsocket.h>
+
+#include "smpppdunsettled.h"
+#include "smpppdclient.h"
+
+using namespace SMPPPD;
+
+Client::Client()
+ : m_state(NULL), m_sock(NULL), m_serverID(QString::null), m_serverVer(QString::null), m_password(QString::null) {
+ changeState(Unsettled::instance());
+}
+
+Client::~Client() {
+ disconnect();
+}
+
+bool Client::connect(const QString& server, uint port) {
+ return m_state->connect(this, server, port);
+}
+
+void Client::disconnect() {
+ m_state->disconnect(this);
+}
+
+QStringList Client::getInterfaceConfigurations() {
+ return m_state->getInterfaceConfigurations(this);
+}
+
+bool Client::statusInterface(const QString& ifcfg) {
+ return m_state->statusInterface(this, ifcfg);
+}
+
+QString Client::serverID() const {
+ return m_serverID;
+}
+
+QString Client::serverVersion() const {
+ return m_serverVer;
+}
+
+QStringList Client::read() const {
+ QStringList qsl;
+
+ if(isReady()) {
+ QDataStream stream(m_sock);
+ char s[1024];
+
+ stream.readRawBytes(s, 1023);
+ char *sp = s;
+
+ for(int i = 0; i < 1024; i++) {
+ if(s[i] == '\n') {
+ s[i] = 0;
+ qsl.push_back(sp);
+ sp = &(s[i+1]);
+ }
+ }
+ }
+
+ return qsl;
+}
+
+void Client::write(const char * cmd) {
+ if(isReady()) {
+ QDataStream stream(m_sock);
+ stream.writeRawBytes(cmd, strlen(cmd));
+ stream.writeRawBytes("\n", strlen("\n"));
+ m_sock->flush();
+ }
+}
+
+bool Client::isReady() const {
+ return m_sock && m_sock->state() == KNetwork::KStreamSocket::Connected;
+}
+
+bool Client::isOnline() {
+
+ if(isReady()) {
+ QStringList ifcfgs = getInterfaceConfigurations();
+ for(uint i = 0; i < ifcfgs.count(); i++) {
+ if(statusInterface(ifcfgs[i])) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
diff --git a/kopete/plugins/smpppdcs/libsmpppdclient/smpppdclient.h b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdclient.h
new file mode 100644
index 00000000..a123cd4c
--- /dev/null
+++ b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdclient.h
@@ -0,0 +1,80 @@
+/*
+ smpppdclient.h
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMPPPDCLIENT_H
+#define SMPPPDCLIENT_H
+
+#include <qstringlist.h>
+
+namespace KNetwork {
+class KStreamSocket;
+};
+
+namespace SMPPPD {
+
+class State;
+
+/**
+ @author Heiko Schaefer <heiko@rangun.de>
+*/
+class Client {
+ Client(const Client&);
+ Client& operator=(const Client&);
+
+public:
+ Client();
+ ~Client();
+
+ bool isReady() const;
+
+ bool connect(const QString& server, uint port = 3185);
+ void disconnect();
+
+ QStringList getInterfaceConfigurations();
+ bool statusInterface(const QString& ifcfg);
+
+ bool isOnline();
+ QString serverID() const;
+ QString serverVersion() const;
+
+ void setPassword(const QString& password);
+
+private:
+ friend class State;
+
+ void changeState(State * newState);
+ QStringList read() const;
+ void write(const char * cmd);
+
+private:
+ State * m_state;
+ KNetwork::KStreamSocket * m_sock;
+ QString m_serverID;
+ QString m_serverVer;
+ QString m_password;
+};
+
+inline void Client::changeState(State * newState) {
+ m_state = newState;
+}
+
+inline void Client::setPassword(const QString& password) {
+ m_password = password;
+}
+
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/libsmpppdclient/smpppdready.cpp b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdready.cpp
new file mode 100644
index 00000000..421914bb
--- /dev/null
+++ b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdready.cpp
@@ -0,0 +1,104 @@
+/*
+ smpppdready.cpp
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <qregexp.h>
+
+#include <kdebug.h>
+#include <kstreamsocket.h>
+
+#include "smpppdunsettled.h"
+#include "smpppdclient.h"
+#include "smpppdready.h"
+
+using namespace SMPPPD;
+
+Ready * Ready::m_instance = NULL;
+
+Ready::Ready() {}
+
+Ready::~Ready() {}
+
+Ready * Ready::instance() {
+ if(!m_instance) {
+ m_instance = new Ready;
+ }
+
+ return m_instance;
+}
+
+void Ready::disconnect(Client * client) {
+ kdDebug(14312) << k_funcinfo << endl;
+ if(socket(client)) {
+ socket(client)->flush();
+ socket(client)->close();
+
+ delete socket(client);
+ setSocket(client, NULL);
+
+ setServerID(client, QString::null);
+ setServerVersion(client, QString::null);
+ }
+
+ changeState(client, Unsettled::instance());
+}
+
+QStringList Ready::getInterfaceConfigurations(Client * client) {
+
+ QStringList ifcfgs;
+
+ // we want all ifcfgs
+ kdDebug(14312) << k_funcinfo << "smpppd req: list-ifcfgs" << endl;
+ write(client, "list-ifcfgs");
+ QStringList stream = read(client);
+ kdDebug(14312) << k_funcinfo << "smpppd ack: " << stream[0] << endl;
+ if(stream[0].startsWith("ok")) {
+ // we have now a QStringList with all ifcfgs
+ // we extract them and put them in the global ifcfgs-list
+ // stream[1] tells us how many ifcfgs are coming next
+ QRegExp numIfcfgsRex("^BEGIN IFCFGS ([0-9]+).*");
+ if(numIfcfgsRex.exactMatch(stream[1])) {
+ int count_ifcfgs = numIfcfgsRex.cap(1).toInt();
+ kdDebug(14312) << k_funcinfo << "ifcfgs: " << count_ifcfgs << endl;
+
+ for(int i = 0; i < count_ifcfgs; i++) {
+ QRegExp ifcfgRex("^i \"(ifcfg-[a-zA-Z]+[0-9]+)\".*");
+ if(ifcfgRex.exactMatch(stream[i+2])) {
+ ifcfgs.push_back(ifcfgRex.cap(1));
+ }
+ }
+ }
+ }
+
+ return ifcfgs;
+}
+
+bool Ready::statusInterface(Client * client, const QString& ifcfg) {
+
+ QString cmd = "list-status " + ifcfg;
+
+ write(client, cmd.latin1());
+ socket(client)->waitForMore(0);
+
+ QStringList stream = read(client);
+
+ if(stream[0].startsWith("ok")) {
+ if(stream[2].startsWith("status connected")) {
+ return true;
+ }
+ }
+
+ return false;
+}
diff --git a/kopete/plugins/smpppdcs/libsmpppdclient/smpppdready.h b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdready.h
new file mode 100644
index 00000000..9ec3ab93
--- /dev/null
+++ b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdready.h
@@ -0,0 +1,49 @@
+/*
+ smpppdready.h
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMPPPDREADY_H
+#define SMPPPDREADY_H
+
+#include "smpppdstate.h"
+
+namespace SMPPPD {
+
+/**
+ @author Heiko Schaefer <heiko@rangun.de>
+*/
+class Ready : public State
+{
+ Ready(const Ready&);
+ Ready& operator=(const Ready&);
+
+ Ready();
+
+public:
+ virtual ~Ready();
+
+ static Ready * instance();
+
+ virtual void disconnect(Client * client);
+ virtual QStringList getInterfaceConfigurations(Client * client);
+ virtual bool statusInterface(Client * client, const QString& ifcfg);
+
+private:
+ static Ready * m_instance;
+};
+
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/libsmpppdclient/smpppdstate.cpp b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdstate.cpp
new file mode 100644
index 00000000..9e4bd508
--- /dev/null
+++ b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdstate.cpp
@@ -0,0 +1,76 @@
+/*
+ smpppdstate.cpp
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <kstreamsocket.h>
+
+#include "smpppdclient.h"
+#include "smpppdstate.h"
+
+using namespace SMPPPD;
+
+State::State() {}
+
+State::~State() {}
+
+QStringList State::read(Client * client) const {
+ return client->read();
+}
+
+void State::write(Client * client, const char * cmd) {
+ client->write(cmd);
+}
+
+void State::changeState(Client * client, State * state) {
+ client->changeState(state);
+}
+
+KNetwork::KStreamSocket * State::socket(Client * client) const {
+ return client->m_sock;
+}
+
+QString State::password(Client * client) const {
+ return client->m_password;
+}
+
+void State::setPassword(Client * client, const QString& pass) {
+ client->m_password = pass;
+}
+
+void State::setServerID(Client * client, const QString& id) {
+ client->m_serverID = id;
+}
+
+void State::setServerVersion(Client * client, const QString& ver) {
+ client->m_serverVer = ver;
+}
+
+void State::setSocket(Client * client, KNetwork::KStreamSocket * sock) {
+ client->m_sock = sock;
+}
+
+bool State::connect(Client * /* client */, const QString& /* server */, uint /* port */) {
+ return false;
+}
+
+void State::disconnect(Client * /* client */) {}
+
+QStringList State::getInterfaceConfigurations(Client * /* client */) {
+ return QStringList();
+}
+
+bool State::statusInterface(Client * /* client */, const QString& /* ifcfg */) {
+ return false;
+}
diff --git a/kopete/plugins/smpppdcs/libsmpppdclient/smpppdstate.h b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdstate.h
new file mode 100644
index 00000000..0e7d393b
--- /dev/null
+++ b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdstate.h
@@ -0,0 +1,58 @@
+/*
+ smpppdstate.h
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMPPPDSTATE_H
+#define SMPPPDSTATE_H
+
+#include <qstringlist.h>
+
+namespace SMPPPD {
+
+class Client;
+
+/**
+ @author Heiko Schaefer <heiko@rangun.de>
+*/
+class State {
+ State(const State&);
+ State& operator=(const State&);
+
+public:
+ State();
+ virtual ~State();
+
+ virtual bool connect(Client * client, const QString& server, uint port = 3185);
+ virtual void disconnect(Client * client);
+
+ virtual QStringList getInterfaceConfigurations(Client * client);
+ virtual bool statusInterface(Client * client, const QString& ifcfg);
+
+protected:
+ QStringList read(Client * client) const;
+ void write(Client * client, const char * cmd);
+ void changeState(Client * client, State * state);
+ KNetwork::KStreamSocket * socket(Client * client) const;
+ void setSocket(Client * client, KNetwork::KStreamSocket * sock);
+ QString password(Client * client) const;
+ void setPassword(Client * client, const QString& pass);
+ void setServerID(Client * client, const QString& id);
+ void setServerVersion(Client * client, const QString& ver);
+
+};
+
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/libsmpppdclient/smpppdunsettled.cpp b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdunsettled.cpp
new file mode 100644
index 00000000..7ed5f516
--- /dev/null
+++ b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdunsettled.cpp
@@ -0,0 +1,153 @@
+/*
+ smpppdunsettled.cpp
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <cstdlib>
+#include <openssl/md5.h>
+
+#include <qregexp.h>
+
+#include <kdebug.h>
+#include <kstreamsocket.h>
+
+#include "smpppdready.h"
+#include "smpppdunsettled.h"
+
+using namespace SMPPPD;
+
+Unsettled * Unsettled::m_instance = NULL;
+
+Unsettled::Unsettled() {}
+
+Unsettled::~Unsettled() {}
+
+Unsettled * Unsettled::instance() {
+ if(!m_instance) {
+ m_instance = new Unsettled();
+ }
+
+ return m_instance;
+}
+
+bool Unsettled::connect(Client * client, const QString& server, uint port) {
+ if(!socket(client) ||
+ socket(client)->state() != KNetwork::KStreamSocket::Connected ||
+ socket(client)->state() != KNetwork::KStreamSocket::Connecting) {
+
+ QString resolvedServer = server;
+
+ changeState(client, Ready::instance());
+ disconnect(client);
+
+ // since a lookup on a non-existant host can take a lot of time we
+ // try to get the IP of server before and we do the lookup ourself
+ KNetwork::KResolver resolver(server);
+ resolver.start();
+ if(resolver.wait(500)) {
+ KNetwork::KResolverResults results = resolver.results();
+ if(!results.empty()) {
+ QString ip = results[0].address().asInet().ipAddress().toString();
+ kdDebug(14312) << k_funcinfo << "Found IP-Address for " << server << ": " << ip << endl;
+ resolvedServer = ip;
+ } else {
+ kdWarning(14312) << k_funcinfo << "No IP-Address found for " << server << endl;
+ return false;
+ }
+ } else {
+ kdWarning(14312) << k_funcinfo << "Looking up hostname timed out, consider to use IP or correct host" << endl;
+ return false;
+ }
+
+ setSocket(client, new KNetwork::KStreamSocket(resolvedServer, QString::number(port)));
+ socket(client)->setBlocking(TRUE);
+
+ if(!socket(client)->connect()) {
+ kdDebug(14312) << k_funcinfo << "Socket Error: " << KNetwork::KStreamSocket::errorString(socket(client)->error()) << endl;
+ } else {
+ kdDebug(14312) << k_funcinfo << "Successfully connected to smpppd \"" << server << ":" << port << "\"" << endl;
+
+ static QString verRex = "^SuSE Meta pppd \\(smpppd\\), Version (.*)$";
+ static QString clgRex = "^challenge = (.*)$";
+
+ QRegExp ver(verRex);
+ QRegExp clg(clgRex);
+
+ QString response = read(client)[0];
+
+ if(response != QString::null &&
+ ver.exactMatch(response)) {
+ setServerID(client, response);
+ setServerVersion(client, ver.cap(1));
+ changeState(client, Ready::instance());
+ return true;
+ } else if(response != QString::null &&
+ clg.exactMatch(response)) {
+ if(password(client) != QString::null) {
+ // we are challenged, ok, respond
+ write(client, QString("response = %1\n").arg(make_response(clg.cap(1).stripWhiteSpace(), password(client))).latin1());
+ response = read(client)[0];
+ if(ver.exactMatch(response)) {
+ setServerID(client, response);
+ setServerVersion(client, ver.cap(1));
+ return true;
+ } else {
+ kdWarning(14312) << k_funcinfo << "SMPPPD responded: " << response << endl;
+ changeState(client, Ready::instance());
+ disconnect(client);
+ }
+ } else {
+ kdWarning(14312) << k_funcinfo << "SMPPPD requested a challenge, but no password was supplied!" << endl;
+ changeState(client, Ready::instance());
+ disconnect(client);
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+QString Unsettled::make_response(const QString& chex, const QString& password) const {
+
+ int size = chex.length ();
+ if (size & 1)
+ return "error";
+ size >>= 1;
+
+ // convert challenge from hex to bin
+ QString cbin;
+ for (int i = 0; i < size; i++) {
+ QString tmp = chex.mid (2 * i, 2);
+ cbin.append ((char) strtol (tmp.ascii (), 0, 16));
+ }
+
+ // calculate response
+ unsigned char rbin[MD5_DIGEST_LENGTH];
+ MD5state_st md5;
+ MD5_Init (&md5);
+ MD5_Update (&md5, cbin.ascii (), size);
+ MD5_Update (&md5, password.ascii(), password.length ());
+ MD5_Final (rbin, &md5);
+
+ // convert response from bin to hex
+ QString rhex;
+ for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
+ char buffer[3];
+ snprintf (buffer, 3, "%02x", rbin[i]);
+ rhex.append (buffer);
+ }
+
+ return rhex;
+}
diff --git a/kopete/plugins/smpppdcs/libsmpppdclient/smpppdunsettled.h b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdunsettled.h
new file mode 100644
index 00000000..57a83752
--- /dev/null
+++ b/kopete/plugins/smpppdcs/libsmpppdclient/smpppdunsettled.h
@@ -0,0 +1,49 @@
+/*
+ smpppdunsettled.h
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMPPPDSMPPPDUNSETTLED_H
+#define SMPPPDSMPPPDUNSETTLED_H
+
+#include "smpppdstate.h"
+
+namespace SMPPPD {
+
+/**
+ @author Heiko Schaefer <heiko@rangun.de>
+*/
+class Unsettled : public State
+{
+ Unsettled(const Unsettled&);
+ Unsettled& operator=(const Unsettled&);
+
+ Unsettled();
+public:
+ virtual ~Unsettled();
+
+ static Unsettled * instance();
+
+ virtual bool connect(Client * client, const QString& server, uint port = 3185);
+
+private:
+ QString make_response(const QString& chex, const QString& password) const;
+
+private:
+ static Unsettled * m_instance;
+};
+
+}
+
+#endif
diff --git a/kopete/plugins/smpppdcs/onlineinquiry.cpp b/kopete/plugins/smpppdcs/onlineinquiry.cpp
new file mode 100644
index 00000000..4cab45d7
--- /dev/null
+++ b/kopete/plugins/smpppdcs/onlineinquiry.cpp
@@ -0,0 +1,45 @@
+/*
+ onlineinquiry.cpp
+
+ Copyright (c) 2005-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include "detectornetstat.h"
+#include "detectorsmpppd.h"
+#include "onlineinquiry.h"
+
+OnlineInquiry::OnlineInquiry()
+ : m_detector(NULL), m_online(FALSE) {}
+
+OnlineInquiry::~OnlineInquiry() {
+ delete m_detector;
+}
+
+bool OnlineInquiry::isOnline(bool useSMPPPD) {
+
+ delete m_detector;
+
+ if(useSMPPPD) {
+ m_detector = new DetectorSMPPPD(this);
+ } else {
+ m_detector = new DetectorNetstat(this);
+ }
+
+ m_detector->checkStatus();
+
+ return m_online;
+}
+
+void OnlineInquiry::setConnectedStatus(bool newStatus) {
+ m_online = newStatus;
+}
diff --git a/kopete/plugins/smpppdcs/onlineinquiry.h b/kopete/plugins/smpppdcs/onlineinquiry.h
new file mode 100644
index 00000000..c9b5221a
--- /dev/null
+++ b/kopete/plugins/smpppdcs/onlineinquiry.h
@@ -0,0 +1,45 @@
+/*
+ onlineinquiry.h
+
+ Copyright (c) 2005-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef ONLINEINQUIRY_H
+#define ONLINEINQUIRY_H
+
+#include "iconnector.h"
+
+class Detector;
+
+/**
+ * @author Heiko Sch&auml;fer <heiko@rangun.de>
+ */
+
+class OnlineInquiry : public IConnector {
+ OnlineInquiry(const OnlineInquiry&);
+ OnlineInquiry& operator=(const OnlineInquiry&);
+
+public:
+ OnlineInquiry();
+ virtual ~OnlineInquiry();
+
+ bool isOnline(bool useSMPPPD);
+
+ virtual void setConnectedStatus(bool newStatus);
+
+private:
+ Detector * m_detector;
+ bool m_online;
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/smpppdcs.kcfg b/kopete/plugins/smpppdcs/smpppdcs.kcfg
new file mode 100644
index 00000000..2ca65f54
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdcs.kcfg
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
+<kcfg>
+ <kcfgfile name="kopeterc"/>
+ <group name="SMPPPDCS Plugin">
+ <entry name="Password" type="String">
+ <label>Password to connect to the SMPPPD.</label>
+ </entry>
+ <entry name="ignoredAccounts" type="StringList">
+ <label>Accounts to ignore in the plugin.</label>
+ </entry>
+ <entry name="server" type="String">
+ <label>SMPPPD-Server to connect.</label>
+ <default>localhost</default>
+ </entry>
+ <entry name="port" type="UInt">
+ <label>SMPPPD-Server port to connect.</label>
+ <default>3185</default>
+ </entry>
+ <entry name="useNetstat" type="Bool">
+ <label>Use the netstat tool to determine the connection status.</label>
+ <default>true</default>
+ </entry>
+ <entry name="useSmpppd" type="Bool">
+ <label>Use the SMPPPD to determine the connection status.</label>
+ <default>false</default>
+ </entry>
+ </group>
+</kcfg> \ No newline at end of file
diff --git a/kopete/plugins/smpppdcs/smpppdcsconfig.kcfgc b/kopete/plugins/smpppdcs/smpppdcsconfig.kcfgc
new file mode 100644
index 00000000..2e955708
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdcsconfig.kcfgc
@@ -0,0 +1,6 @@
+File=smpppdcs.kcfg
+ClassName=SMPPPDCSConfig
+Singleton=true
+Mutators=true
+MemberVariables=private
+GlobalEnums=true \ No newline at end of file
diff --git a/kopete/plugins/smpppdcs/smpppdcsiface.h b/kopete/plugins/smpppdcs/smpppdcsiface.h
new file mode 100644
index 00000000..face60ad
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdcsiface.h
@@ -0,0 +1,36 @@
+/*
+ smpppdcsiface.h
+
+ Copyright (c) 2005-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMPPPDCSIFACE_H
+#define SMPPPDCSIFACE_H
+
+#include <dcopobject.h>
+
+/**
+ * @author Heiko Sch&auml;fer <heiko@rangun.de>
+ */
+
+class SMPPPDCSIFace : virtual public DCOPObject
+{
+ K_DCOP
+
+ k_dcop:
+
+ virtual QString detectionMethod() const = 0;
+ virtual bool isOnline() const = 0;
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/smpppdcsplugin.cpp b/kopete/plugins/smpppdcs/smpppdcsplugin.cpp
new file mode 100644
index 00000000..2ed8455c
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdcsplugin.cpp
@@ -0,0 +1,221 @@
+/*
+ smpppdcsplugin.cpp
+
+ Copyright (c) 2002-2003 by Chris Howells <howells@kde.org>
+ Copyright (c) 2003 by Martijn Klingens <klingens@kde.org>
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include "onlineinquiry.h"
+#include "smpppdcsplugin.h"
+
+#include <qtimer.h>
+
+#include <kdebug.h>
+#include <kgenericfactory.h>
+
+#include "kopeteprotocol.h"
+#include "networkstatuscommon.h"
+#include "kopetepluginmanager.h"
+#include "kopeteaccountmanager.h"
+
+#include "detectornetworkstatus.h"
+#include "detectornetstat.h"
+#include "detectorsmpppd.h"
+#include "smpppdcsconfig.h"
+
+typedef KGenericFactory<SMPPPDCSPlugin> SMPPPDCSPluginFactory;
+K_EXPORT_COMPONENT_FACTORY(kopete_smpppdcs, SMPPPDCSPluginFactory("kopete_smpppdcs"))
+
+SMPPPDCSPlugin::SMPPPDCSPlugin(QObject *parent, const char * name, const QStringList& /* args */)
+ : DCOPObject("SMPPPDCSIface"), Kopete::Plugin(SMPPPDCSPluginFactory::instance(), parent, name),
+ m_detectorSMPPPD(NULL), m_detectorNetstat(NULL), m_detectorNetworkStatus(NULL), m_timer(NULL),
+m_onlineInquiry(NULL) {
+
+ kdDebug(14312) << k_funcinfo << endl;
+
+ m_pluginConnected = false;
+
+ m_onlineInquiry = new OnlineInquiry();
+ m_detectorSMPPPD = new DetectorSMPPPD(this);
+ m_detectorNetstat = new DetectorNetstat(this);
+
+ // experimental, not used yet
+ m_detectorNetworkStatus = new DetectorNetworkStatus(this);
+
+ // we wait for the allPluginsLoaded signal, to connect
+ // as early as possible after startup, but not before
+ // all accounts are ready
+ connect(Kopete::PluginManager::self(), SIGNAL(allPluginsLoaded()),
+ this, SLOT(allPluginsLoaded()));
+
+ // if kopete was already running and the plugin
+ // was loaded later, we check once after 15 secs
+ // if all other plugins have been loaded
+ QTimer::singleShot(15000, this, SLOT(allPluginsLoaded()));
+}
+
+SMPPPDCSPlugin::~SMPPPDCSPlugin() {
+
+ kdDebug(14312) << k_funcinfo << endl;
+
+ delete m_timer;
+ delete m_detectorSMPPPD;
+ delete m_detectorNetstat;
+ delete m_detectorNetworkStatus;
+ delete m_onlineInquiry;
+}
+
+void SMPPPDCSPlugin::allPluginsLoaded() {
+
+ if(Kopete::PluginManager::self()->isAllPluginsLoaded()) {
+ m_timer = new QTimer();
+ connect(m_timer, SIGNAL(timeout()), this, SLOT(slotCheckStatus()));
+
+ if(SMPPPDCSConfig::self()->useSmpppd()) {
+ m_timer->start(30000);
+ } else {
+ // we use 1 min interval, because it reflects
+ // the old connectionstatus plugin behaviour
+ m_timer->start(60000);
+ }
+
+ slotCheckStatus();
+ }
+}
+
+bool SMPPPDCSPlugin::isOnline() const {
+ return m_onlineInquiry->isOnline(SMPPPDCSConfig::self()->useSmpppd());
+}
+
+void SMPPPDCSPlugin::slotCheckStatus() {
+
+ // reread config to get changes
+ SMPPPDCSConfig::self()->readConfig();
+
+ if(SMPPPDCSConfig::self()->useSmpppd()) {
+ m_detectorSMPPPD->checkStatus();
+ } else {
+ m_detectorNetstat->checkStatus();
+ }
+}
+
+void SMPPPDCSPlugin::setConnectedStatus( bool connected ) {
+ kdDebug(14312) << k_funcinfo << connected << endl;
+
+ // We have to handle a few cases here. First is the machine is connected, and the plugin thinks
+ // we're connected. Then we don't do anything. Next, we can have machine connected, but plugin thinks
+ // we're disconnected. Also, machine disconnected, plugin disconnected -- we
+ // don't do anything. Finally, we can have the machine disconnected, and the plugin thinks we're
+ // connected. This mechanism is required so that we don't keep calling the connect/disconnect functions
+ // constantly.
+
+ if ( connected && !m_pluginConnected ) {
+ // The machine is connected and plugin thinks we're disconnected
+ kdDebug(14312) << k_funcinfo << "Setting m_pluginConnected to true" << endl;
+ m_pluginConnected = true;
+ connectAllowed();
+ kdDebug(14312) << k_funcinfo << "We're connected" << endl;
+ } else if ( !connected && m_pluginConnected ) {
+ // The machine isn't connected and plugin thinks we're connected
+ kdDebug(14312) << k_funcinfo << "Setting m_pluginConnected to false" << endl;
+ m_pluginConnected = false;
+ disconnectAllowed();
+ kdDebug(14312) << k_funcinfo << "We're offline" << endl;
+ }
+}
+
+void SMPPPDCSPlugin::connectAllowed() {
+
+ QStringList list = SMPPPDCSConfig::self()->ignoredAccounts();
+
+ Kopete::AccountManager * m = Kopete::AccountManager::self();
+ for(QPtrListIterator<Kopete::Account> it(m->accounts())
+ ;
+ it.current();
+ ++it) {
+
+#ifndef NDEBUG
+ if(it.current()->inherits("Kopete::ManagedConnectionAccount")) {
+ kdDebug(14312) << k_funcinfo << "Account " << it.current()->protocol()->pluginId() + "_" + it.current()->accountId() << " is an managed account!" << endl;
+ } else {
+ kdDebug(14312) << k_funcinfo << "Account " << it.current()->protocol()->pluginId() + "_" + it.current()->accountId() << " is an unmanaged account!" << endl;
+ }
+#endif
+
+ if(!list.contains(it.current()->protocol()->pluginId() + "_" + it.current()->
+ accountId())) {
+ it.current()->connect();
+ }
+ }
+}
+
+void SMPPPDCSPlugin::disconnectAllowed() {
+
+ QStringList list = SMPPPDCSConfig::self()->ignoredAccounts();
+
+ Kopete::AccountManager * m = Kopete::AccountManager::self();
+ for(QPtrListIterator<Kopete::Account> it(m->accounts())
+ ;
+ it.current();
+ ++it) {
+
+#ifndef NDEBUG
+ if(it.current()->inherits("Kopete::ManagedConnectionAccount")) {
+ kdDebug(14312) << k_funcinfo << "Account " << it.current()->protocol()->pluginId() + "_" + it.current()->accountId() << " is an managed account!" << endl;
+ } else {
+ kdDebug(14312) << k_funcinfo << "Account " << it.current()->protocol()->pluginId() + "_" + it.current()->accountId() << " is an unmanaged account!" << endl;
+ }
+#endif
+
+ if(!list.contains(it.current()->protocol()->pluginId() + "_" + it.current()->accountId())) {
+ it.current()->disconnect();
+ }
+ }
+}
+
+QString SMPPPDCSPlugin::detectionMethod() const {
+ if(SMPPPDCSConfig::self()->useSmpppd()) {
+ return "smpppd";
+ } else {
+ return "netstat";
+ }
+}
+
+/*!
+ \fn SMPPPDCSPlugin::smpppdServerChanged(const QString& server)
+ */
+void SMPPPDCSPlugin::smpppdServerChanged(const QString& server) {
+
+ QString oldServer = SMPPPDCSConfig::self()->server().utf8();
+
+ if(oldServer != server) {
+ kdDebug(14312) << k_funcinfo << "Detected a server change" << endl;
+ m_detectorSMPPPD->smpppdServerChange();
+ }
+}
+
+void SMPPPDCSPlugin::aboutToUnload() {
+
+ kdDebug(14312) << k_funcinfo << endl;
+
+ if(m_timer) {
+ m_timer->stop();
+ }
+
+ emit readyForUnload();
+}
+
+#include "smpppdcsplugin.moc"
+
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/plugins/smpppdcs/smpppdcsplugin.h b/kopete/plugins/smpppdcs/smpppdcsplugin.h
new file mode 100644
index 00000000..789d9c41
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdcsplugin.h
@@ -0,0 +1,109 @@
+/*
+ smpppdcsplugin.h
+
+ Copyright (c) 2002-2003 by Chris Howells <howells@kde.org>
+ Copyright (c) 2003 by Martijn Klingens <klingens@kde.org>
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMPPPDCSPLUGIN_H
+#define SMPPPDCSPLUGIN_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "detector.h"
+#include "iconnector.h"
+#include "smpppdcsiface.h"
+
+#include "kopeteplugin.h"
+#include "kopeteaccount.h"
+
+class QTimer;
+class Detector;
+class OnlineInquiry;
+
+/**
+ * @brief Plugin for the detection of an internet connection
+ *
+ * This plugin inquires either the smpppd or netstat
+ * for an existing internet connection and depending
+ * on that connects or disconnects all accounts.
+ *
+ * Therefore it should be enabled on dial up network
+ * connections.
+ *
+ * @author Chris Howells <howells@kde.org>, Heiko Sch&auml;fer <heiko@rangun.de>
+ */
+class SMPPPDCSPlugin : public Kopete::Plugin, public IConnector, virtual public SMPPPDCSIFace {
+ Q_OBJECT
+ SMPPPDCSPlugin(const SMPPPDCSPlugin&);
+ SMPPPDCSPlugin& operator=(const SMPPPDCSPlugin&);
+
+public:
+ /**
+ * @brief Creates an <code>SMPPPDCSPlugin</code> instance
+ */
+ SMPPPDCSPlugin( QObject *parent, const char *name, const QStringList &args );
+
+ /**
+ * @brief Destroys an <code>SMPPPDCSPlugin</code> instance
+ */
+ virtual ~SMPPPDCSPlugin();
+
+ // Implementation of DCOP iface
+ /**
+ * @brief Checks if we are online.
+ * @note This method is reserved for future use. Do not use at the moment!
+ * @return <code>TRUE</code> if online, otherwise <code>FALSE</code>
+ */
+ virtual bool isOnline() const;
+
+ /**
+ * @brief Sets the status in all allowed accounts.
+ * Allowed accounts are set in the config dialog of the plugin.
+ *
+ * @see SMPPPDCSPrefs
+ */
+ virtual void setConnectedStatus( bool newStatus );
+
+ virtual QString detectionMethod() const;
+
+ virtual void aboutToUnload();
+
+public slots:
+ void smpppdServerChanged(const QString& server);
+
+private slots:
+ void slotCheckStatus();
+ void allPluginsLoaded();
+
+private:
+
+ void connectAllowed();
+ void disconnectAllowed();
+
+private:
+
+ Detector * m_detectorSMPPPD;
+ Detector * m_detectorNetstat;
+ Detector * m_detectorNetworkStatus;
+ bool m_pluginConnected;
+ QTimer * m_timer;
+ OnlineInquiry * m_onlineInquiry;
+};
+
+#endif /* SMPPPDCSPLUGIN_H */
+
+// vim: set noet ts=4 sts=4 sw=4:
diff --git a/kopete/plugins/smpppdcs/smpppdcspreferences.cpp b/kopete/plugins/smpppdcs/smpppdcspreferences.cpp
new file mode 100644
index 00000000..ddce3572
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdcspreferences.cpp
@@ -0,0 +1,187 @@
+/*
+ smpppdcspreferences.cpp
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <qlayout.h>
+#include <qregexp.h>
+#include <qradiobutton.h>
+
+#include <klistview.h>
+#include <klineedit.h>
+#include <knuminput.h>
+#include <kgenericfactory.h>
+
+#include "kopeteaccount.h"
+#include "kopeteprotocol.h"
+#include "kopeteaccountmanager.h"
+
+#include "smpppdlocationwidget.h"
+#include "smpppdcspreferences.h"
+#include "smpppdcsprefsimpl.h"
+#include "smpppdcsconfig.h"
+
+typedef KGenericFactory<SMPPPDCSPreferences> SMPPPDCSPreferencesFactory;
+K_EXPORT_COMPONENT_FACTORY(kcm_kopete_smpppdcs, SMPPPDCSPreferencesFactory("kcm_kopete_smpppdcs"))
+
+SMPPPDCSPreferences::SMPPPDCSPreferences(QWidget * parent, const char * /* name */, const QStringList& args)
+ : KCModule(SMPPPDCSPreferencesFactory::instance(), parent, args), m_ui(NULL) {
+
+ Kopete::AccountManager * manager = Kopete::AccountManager::self();
+ (new QVBoxLayout(this))->setAutoAdd(true);
+ m_ui = new SMPPPDCSPrefs(this);
+
+ for(QPtrListIterator<Kopete::Account> it(manager->accounts()); it.current(); ++it)
+ {
+ QString protoName;
+ QRegExp rex("(.*)Protocol");
+
+ if(rex.search((*it)->protocol()->pluginId()) > -1) {
+ protoName = rex.cap(1);
+ } else {
+ protoName = (*it)->protocol()->pluginId();
+ }
+
+ if(it.current()->inherits("Kopete::ManagedConnectionAccount")) {
+ protoName += QString(", %1").arg(i18n("connection status is managed by Kopete"));
+ }
+
+ QCheckListItem * cli = new QCheckListItem(m_ui->accountList,
+ (*it)->accountId() + " (" + protoName + ")", QCheckListItem::CheckBox);
+ cli->setPixmap(0, (*it)->accountIcon());
+
+ m_accountMapOld[cli->text(0)] = AccountPrivMap(FALSE, (*it)->protocol()->pluginId() + "_" + (*it)->accountId());
+ m_accountMapCur[cli->text(0)] = AccountPrivMap(FALSE, (*it)->protocol()->pluginId() + "_" + (*it)->accountId());;
+ m_ui->accountList->insertItem(cli);
+ }
+
+ connect(m_ui->accountList, SIGNAL(clicked(QListViewItem *)), this, SLOT(listClicked(QListViewItem *)));
+
+ // connect for modified
+ connect(m_ui->useNetstat, SIGNAL(clicked()), this, SLOT(slotModified()));
+ connect(m_ui->useSmpppd, SIGNAL(clicked()), this, SLOT(slotModified()));
+
+ connect(m_ui->SMPPPDLocation->server, SIGNAL(textChanged(const QString&)), this, SLOT(slotModified()));
+ connect(m_ui->SMPPPDLocation->port, SIGNAL(valueChanged(int)), this, SLOT(slotModified()));
+ connect(m_ui->SMPPPDLocation->Password, SIGNAL(textChanged(const QString&)), this, SLOT(slotModified()));
+
+ load();
+}
+
+SMPPPDCSPreferences::~SMPPPDCSPreferences() {
+ delete m_ui;
+}
+
+void SMPPPDCSPreferences::listClicked(QListViewItem * item)
+{
+ QCheckListItem * cli = dynamic_cast<QCheckListItem *>(item);
+
+ if(cli->isOn() != m_accountMapCur[cli->text(0)].m_on) {
+ AccountMap::iterator itOld = m_accountMapOld.begin();
+ AccountMap::iterator itCur;
+ bool change = FALSE;
+
+ for(itCur = m_accountMapCur.begin(); itCur != m_accountMapCur.end(); ++itCur, ++itOld) {
+ if((*itCur).m_on != (*itOld).m_on){
+ change = TRUE;
+ break;
+ }
+ }
+ emit KCModule::changed(change);
+ }
+ m_accountMapCur[cli->text(0)].m_on = cli->isOn();
+}
+
+void SMPPPDCSPreferences::defaults()
+{
+ QListViewItemIterator it(m_ui->accountList);
+ while(it.current()) {
+ QCheckListItem * cli = dynamic_cast<QCheckListItem *>(it.current());
+ cli->setOn(FALSE);
+ ++it;
+ }
+
+ SMPPPDCSConfig::self()->setDefaults();
+
+ m_ui->useNetstat->setChecked(SMPPPDCSConfig::self()->useNetstat());
+ m_ui->useSmpppd->setChecked(SMPPPDCSConfig::self()->useSmpppd());
+
+ m_ui->SMPPPDLocation->server->setText(SMPPPDCSConfig::self()->server());
+ m_ui->SMPPPDLocation->port->setValue(SMPPPDCSConfig::self()->port());
+ m_ui->SMPPPDLocation->Password->setText(SMPPPDCSConfig::self()->password());
+}
+
+void SMPPPDCSPreferences::load()
+{
+
+ SMPPPDCSConfig::self()->readConfig();
+
+ static QString rexStr = "^(.*) \\((.*)\\)";
+ QRegExp rex(rexStr);
+ QStringList list = SMPPPDCSConfig::self()->ignoredAccounts();
+ QListViewItemIterator it(m_ui->accountList);
+ while(it.current()) {
+ QCheckListItem * cli = dynamic_cast<QCheckListItem *>(it.current());
+ if(rex.search(cli->text(0)) > -1) {
+ bool isOn = list.contains(rex.cap(2) + "Protocol_" + rex.cap(1));
+ // m_accountMapOld[cli->text(0)].m_on = isOn;
+ m_accountMapCur[cli->text(0)].m_on = isOn;
+ cli->setOn(isOn);
+ }
+ ++it;
+ }
+
+ m_ui->useNetstat->setChecked(SMPPPDCSConfig::self()->useNetstat());
+ m_ui->useSmpppd->setChecked(SMPPPDCSConfig::self()->useSmpppd());
+
+ m_ui->SMPPPDLocation->server->setText(SMPPPDCSConfig::self()->server());
+ m_ui->SMPPPDLocation->port->setValue(SMPPPDCSConfig::self()->port());
+ m_ui->SMPPPDLocation->Password->setText(SMPPPDCSConfig::self()->password());
+
+ emit KCModule::changed(false);
+}
+
+void SMPPPDCSPreferences::save()
+{
+ QStringList list;
+ QListViewItemIterator it(m_ui->accountList);
+ while(it.current()) {
+
+ QCheckListItem * cli = dynamic_cast<QCheckListItem *>(it.current());
+ if(cli->isOn()) {
+ list.append(m_accountMapCur[cli->text(0)].m_id);
+ }
+
+ ++it;
+ }
+
+ SMPPPDCSConfig::self()->setIgnoredAccounts(list);
+
+ SMPPPDCSConfig::self()->setUseNetstat(m_ui->useNetstat->isChecked());
+ SMPPPDCSConfig::self()->setUseSmpppd(m_ui->useSmpppd->isChecked());
+
+ SMPPPDCSConfig::self()->setServer(m_ui->SMPPPDLocation->server->text());
+ SMPPPDCSConfig::self()->setPort(m_ui->SMPPPDLocation->port->value());
+ SMPPPDCSConfig::self()->setPassword(m_ui->SMPPPDLocation->Password->text());
+
+ SMPPPDCSConfig::self()->writeConfig();
+
+ emit KCModule::changed(false);
+}
+
+void SMPPPDCSPreferences::slotModified() {
+ emit KCModule::changed(true);
+}
+
+#include "smpppdcspreferences.moc"
diff --git a/kopete/plugins/smpppdcs/smpppdcspreferences.h b/kopete/plugins/smpppdcs/smpppdcspreferences.h
new file mode 100644
index 00000000..8bbeff69
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdcspreferences.h
@@ -0,0 +1,77 @@
+/*
+ smpppdcspreferences.h
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMPPPDCSPREFERENCES_H
+#define SMPPPDCSPREFERENCES_H
+
+#include <kcmodule.h>
+
+class QListViewItem;
+
+class SMPPPDCSPrefs;
+
+class AccountPrivMap {
+public:
+ AccountPrivMap(bool isOn = FALSE, const QString& id = QString::null)
+ : m_on(isOn), m_id(id) {}
+ bool m_on;
+ QString m_id;
+};
+
+/**
+ * @brief Module for the configuration of the smpppdcs-plugin
+ *
+ * @author Heiko Sch&auml;fer <heiko@rangun.de>
+ */
+class SMPPPDCSPreferences : public KCModule {
+ Q_OBJECT
+
+ SMPPPDCSPreferences(const SMPPPDCSPreferences&);
+ SMPPPDCSPreferences& operator=(const SMPPPDCSPreferences&);
+
+public:
+ typedef QMap<QString, AccountPrivMap> AccountMap;
+
+ /**
+ * @brief Creates an <code>SMPPPDCSPreferences</code> instance
+ */
+ SMPPPDCSPreferences(QWidget * parent = 0, const char * name = 0, const QStringList &args = QStringList());
+
+ /**
+ * @brief Destroys an <code>SMPPPDCSPreferences</code> instance
+ */
+ virtual ~SMPPPDCSPreferences();
+
+ virtual void load();
+ virtual void save();
+ virtual void defaults();
+
+protected slots:
+ void listClicked(QListViewItem * item);
+
+private slots:
+ void slotModified();
+
+protected:
+
+ /// The UI class generated by the QT-designer
+ SMPPPDCSPrefs * m_ui;
+
+ AccountMap m_accountMapOld;
+ AccountMap m_accountMapCur;
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/smpppdcsprefs.ui b/kopete/plugins/smpppdcs/smpppdcsprefs.ui
new file mode 100644
index 00000000..067c55a3
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdcsprefs.ui
@@ -0,0 +1,284 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SMPPPDCSPrefsBase</class>
+<author>Heiko Schaefer</author>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SMPPPDCSPrefsBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>476</width>
+ <height>225</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>SMPPPDCS Preferences</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QTabWidget">
+ <property name="name">
+ <cstring>tabWidget</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;Connection</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>6</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>csMethod</cstring>
+ </property>
+ <property name="title">
+ <string>Method of Connection Status Detection</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>6</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>useNetstat</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;netstat - Standard method of connection status detection</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Uses the netstat command to find a gateway; suitable on dial-up computers</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>useSmpppd</cstring>
+ </property>
+ <property name="text">
+ <string>smpppd - Ad&amp;vanced method of connection status detection</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Uses the smpppd on a gateway; suitable for a computer in a private network</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>autoCSLayout</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>autoCSTest</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Try to Detect Automatically</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Tries to find an appropriate connection method</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>341</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>smpppdPrefs</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string>Location of the SMPPPD</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>6</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="SMPPPDLocationWidget">
+ <property name="name">
+ <cstring>SMPPPDLocation</cstring>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer18</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Acco&amp;unts</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer4_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>6</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>toIgnoreLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Choose the accounts to ignore:</string>
+ </property>
+ </widget>
+ <widget class="KListView">
+ <column>
+ <property name="text">
+ <string>Account</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>false</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>accountList</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>SMPPPDLocationWidget</class>
+ <header location="local">smpppdlocationwidget.h</header>
+ <sizehint>
+ <width>16</width>
+ <height>16</height>
+ </sizehint>
+ <container>1</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="PNG" length="1125">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000042c49444154388db5954f6c14551cc73fefcd7476b65bdaae4bb78bb5502a14d404e4801c88182d1c4c2c693da847400f9c24c68b878684238660e2b1e01f12c19493012ef2478c814412d354a46017a8a564bb6da5bbedccee767776e63d0ffb073751d483bfe49799974c3eeffb7ebf37df9fd05a530b2184040cc0042420aaf9a4d0d554800f045a6b256ae0e1e1e1d6bebebe838ee31c48a7d39b5cd7fd075e251cc7617272f2ded8d8d819cff33e0316819259537aead4a9839d5dd6d1784f91f55b0a94830242088404d304292bef68a89f520802a598fecddaa04f1a876f5c250c7c0a64cdeac686e33807e23d45e6b297c8b877f1831542614550b6599835c83c2a81b6786a75134faf2f1169f12997350881d9021d0903e06de0745d3160a6d3e94dbd5b0a64dcbb94b5831d0e3375ab892b1772dcf9790528543f8dd0d367b36768153b5e31503a0f1aecb004580b44ffac58baae8b1714f0833c7638cc8dab303a320f4822ab4c7a37c69196203de3319d5ce1c4d13c733331dedc67a129a154fd128401ab0616d55a130ac3d42d93d1913940d13fd0c9ee0183685c60da01c5421bd72f7a8c8efccef9afd374267ad93d642365be0636a0d28ec7600941d9e6f23917f0e97f23ce5bef35d19ec863da0ed9059b2be70bec196c66dfa10ec0e49b338f7017258651bf95021035c595429bb0903248fe52a2b5b595dd7b4d945cc2340cdca536be389ee3f67886c5798f773fe8e0dac508c989659277a2180da4ca4ff07821058b8b251445d63d6b13ed1098a6417e39cac85197dbe31962ab9bd9f1f22a226d45366f6d0620fdb08c900d281af6110284b20085b414861d905d88f2e52739ee8cbb8022143259d3dd84691730aa2d52da441a8de0c6958068870022a41e9629ad3473fd3b8fdbe319dadb9b4924da994d2d716c7896fbe35152f78b48245d6b2da4507faf582be8eaf159b721cc837b05ae7debb1f79d08cb8b515edad942a22bc4b1c33eb3d34b1c797f06af90a72d16e2f96d9a74aa11dca8586b222d01af0fb60070f6c402d72f15d97f28c6f6d7027a5f5ce6c3233dc4e2ede496b278be4fff608cee8d3e1add806aeca51094cbb06397c1ecc328e746537c7e3ccdb5cb1136bf60635882d4d41c6ec6836ab37efa214f72208ed9f4d7cdd38ee310280542e38b1c43fb6de26b3672e1ec3cc99bcb246f66a938a3241ab3e91f7c861fbf77710b1e5e49915bae974203ba0e9e9c9cbc373d6d6d305a040a89c2a77f50b27d5782bbbf7acccf28349235dd16cf6dd374f7295e1de8a45c02d37499182b01cc0201a085d61a2144d8b2ac8fb6ed340e77240c4261890e04c250185262546d534a032154b59e0ad394e41c98182bf268ce6721ed9f064e0253356f6da2e24c1f030f783c15fe6da680af8021602bd051532ca9b8521488559f61aa86c29343578fbf0264a94c906c7d3409214c20043457a116ff6de6795578012889ff6b98fe016ea0ce1c6a2573410000000049454e44ae426082</data>
+ </image>
+</images>
+<tabstops>
+ <tabstop>tabWidget</tabstop>
+ <tabstop>useNetstat</tabstop>
+ <tabstop>autoCSTest</tabstop>
+ <tabstop>useSmpppd</tabstop>
+ <tabstop>accountList</tabstop>
+</tabstops>
+<layoutdefaults spacing="0" margin="0"/>
+<includehints>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>smpppdlocationwidget.h</includehint>
+ <includehint>klistview.h</includehint>
+</includehints>
+</UI>
diff --git a/kopete/plugins/smpppdcs/smpppdcsprefsimpl.cpp b/kopete/plugins/smpppdcs/smpppdcsprefsimpl.cpp
new file mode 100644
index 00000000..5a834c97
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdcsprefsimpl.cpp
@@ -0,0 +1,165 @@
+/*
+ smpppdcsprefsimpl.cpp
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <arpa/inet.h>
+#include <netdb.h>
+
+#include <qradiobutton.h>
+
+#include <kstandarddirs.h>
+#include <kapplication.h>
+#include <kpushbutton.h>
+#include <kresolver.h>
+#include <knuminput.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+#include "kopetepluginmanager.h"
+
+#include "../smpppdcsplugin.h"
+
+#include "smpppdlocationwidget.h"
+#include "smpppdcsprefsimpl.h"
+#include "smpppdsearcher.h"
+
+SMPPPDCSPrefs::SMPPPDCSPrefs(QWidget* parent, const char* name, WFlags fl)
+ : SMPPPDCSPrefsBase(parent, name, fl), m_plugin(NULL), m_scanProgressDlg(NULL), m_curSearcher(NULL) {
+
+ // search for our main-plugin instance
+ Kopete::Plugin * p = Kopete::PluginManager::self()->plugin("kopete_smpppdcs");
+ if(p) {
+ m_plugin = static_cast<SMPPPDCSPlugin *>(p);
+ }
+
+ // signals and slots connections
+ connect(useNetstat, SIGNAL(toggled(bool)), this, SLOT(disableSMPPPDSettings()));
+ connect(useSmpppd, SIGNAL(toggled(bool)), this, SLOT(enableSMPPPDSettings()));
+ connect(autoCSTest, SIGNAL(clicked()), this, SLOT(determineCSType()));
+
+ if(m_plugin) {
+ connect((QObject *)SMPPPDLocation->server, SIGNAL(textChanged(const QString&)),
+ m_plugin, SLOT(smpppdServerChanged(const QString&)));
+ }
+
+ // if netstat is NOT available, disable the option and set to SMPPPD
+ if(KStandardDirs::findExe("netstat") == QString::null) {
+ autoCSTest->setEnabled(FALSE);
+ useNetstat->setEnabled(FALSE);
+ useNetstat->setChecked(FALSE);
+ useSmpppd->setChecked(TRUE);
+ }
+}
+
+SMPPPDCSPrefs::~SMPPPDCSPrefs() {
+ delete m_scanProgressDlg;
+}
+
+void SMPPPDCSPrefs::determineCSType() {
+
+ // while we search, we'll disable the button
+ autoCSTest->setEnabled(false);
+ //kapp->processEvents();
+
+ /* broadcast network for a smpppd.
+ If one is available set to smpppd method */
+
+ SMPPPDSearcher searcher;
+ m_curSearcher = &searcher;
+
+ connect(&searcher, SIGNAL(smpppdFound(const QString&)), this, SLOT(smpppdFound(const QString&)));
+ connect(&searcher, SIGNAL(smpppdNotFound()), this, SLOT(smpppdNotFound()));
+ connect(&searcher, SIGNAL(scanStarted(uint)), this, SLOT(scanStarted(uint)));
+ connect(&searcher, SIGNAL(scanProgress(uint)), this, SLOT(scanProgress(uint)));
+ connect(&searcher, SIGNAL(scanFinished()), this, SLOT(scanFinished()));
+
+ searcher.searchNetwork();
+ m_curSearcher = NULL;
+}
+
+void SMPPPDCSPrefs::scanStarted(uint total) {
+ kdDebug(14312) << k_funcinfo << "Scanning for a SMPPPD started. Will scan " << total << " IPs" << endl;
+
+ // setup the scanProgress Dialog
+ if(!m_scanProgressDlg) {
+ m_scanProgressDlg = new KProgressDialog(this, 0, i18n("Searching"), i18n("Searching for a SMPPPD on the local network..."), TRUE);
+ m_scanProgressDlg->setAutoClose(TRUE);
+ m_scanProgressDlg->setAllowCancel(TRUE);
+ m_scanProgressDlg->setMinimumDuration(2000);
+
+ connect(m_scanProgressDlg, SIGNAL(cancelClicked()), this, SLOT(cancelScanning()));
+ }
+ m_scanProgressDlg->progressBar()->setTotalSteps(total);
+ m_scanProgressDlg->progressBar()->setProgress(0);
+ m_scanProgressDlg->show();
+}
+
+void SMPPPDCSPrefs::scanProgress(uint cur) {
+ m_scanProgressDlg->progressBar()->setProgress(cur);
+ kapp->processEvents();
+}
+
+void SMPPPDCSPrefs::cancelScanning() {
+ kdDebug(14312) << k_funcinfo << endl;
+ Q_ASSERT(m_curSearcher);
+ m_curSearcher->cancelSearch();
+}
+
+void SMPPPDCSPrefs::smpppdFound(const QString& host) {
+ kdDebug(14312) << k_funcinfo << endl;
+
+ QString myHost = host;
+
+ // try to get the domain name
+ struct in_addr addr;
+ if(inet_aton(host.ascii(), &addr)) {
+ struct hostent * hostEnt = gethostbyaddr(&addr.s_addr, sizeof(addr.s_addr), AF_INET);
+ if(hostEnt) {
+ myHost = hostEnt->h_name;
+ } else {
+#ifndef NDEBUG
+ switch(h_errno) {
+ case HOST_NOT_FOUND:
+ kdDebug(14312) << k_funcinfo << "No such host is known in the database." << endl;
+ break;
+ case TRY_AGAIN:
+ kdDebug(14312) << k_funcinfo << "Couldn't contact DNS server." << endl;
+ break;
+ case NO_RECOVERY:
+ kdDebug(14312) << k_funcinfo << "A non-recoverable error occurred." << endl;
+ break;
+ case NO_ADDRESS:
+ kdDebug(14312) << k_funcinfo << "The host database contains an entry for the name, but it doesn't have an associated Internet address." << endl;
+ break;
+ }
+#endif
+
+ }
+ }
+
+ SMPPPDLocation->setServer(myHost);
+ useNetstat->setChecked(false);
+ useSmpppd->setChecked(true);
+ autoCSTest->setEnabled(true);
+}
+
+void SMPPPDCSPrefs::smpppdNotFound() {
+ kdDebug(14312) << k_funcinfo << endl;
+ useNetstat->setChecked(true);
+ useSmpppd->setChecked(false);
+ autoCSTest->setEnabled(true);
+}
+
+#include "smpppdcsprefsimpl.moc"
diff --git a/kopete/plugins/smpppdcs/smpppdcsprefsimpl.h b/kopete/plugins/smpppdcs/smpppdcsprefsimpl.h
new file mode 100644
index 00000000..181ba9fa
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdcsprefsimpl.h
@@ -0,0 +1,76 @@
+/*
+ smpppdcsprefsimpl.h
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMPPPDCSPREFSIMPL_H
+#define SMPPPDCSPREFSIMPL_H
+
+#include <qgroupbox.h>
+
+#include <kprogress.h>
+
+#include "smpppdcsprefs.h"
+
+class SMPPPDCSPlugin;
+class SMPPPDSearcher;
+
+/**
+@author Heiko Sch&auml;fer <heiko@rangun.de>
+*/
+class SMPPPDCSPrefs : public SMPPPDCSPrefsBase
+{
+ Q_OBJECT
+
+ SMPPPDCSPrefs(const SMPPPDCSPrefs&);
+ SMPPPDCSPrefs& operator=(const SMPPPDCSPrefs&);
+
+public:
+
+ SMPPPDCSPrefs(QWidget* parent, const char* name = 0, WFlags fl = 0);
+ ~SMPPPDCSPrefs();
+
+signals:
+ void foundSMPPPD(bool found);
+
+protected slots:
+ void enableSMPPPDSettings();
+ void disableSMPPPDSettings();
+ void determineCSType();
+ void smpppdFound(const QString & host);
+ void smpppdNotFound();
+ void scanStarted(uint total);
+ void scanProgress(uint cur);
+ void scanFinished();
+ void cancelScanning();
+
+private:
+ SMPPPDCSPlugin * m_plugin;
+ KProgressDialog * m_scanProgressDlg;
+ SMPPPDSearcher * m_curSearcher;
+};
+
+inline void SMPPPDCSPrefs::enableSMPPPDSettings() {
+ smpppdPrefs->setEnabled(true);
+}
+
+inline void SMPPPDCSPrefs::disableSMPPPDSettings() {
+ smpppdPrefs->setEnabled(false);
+}
+
+inline void SMPPPDCSPrefs::scanFinished() {
+ m_scanProgressDlg->hide();
+}
+
+#endif
diff --git a/kopete/plugins/smpppdcs/smpppdlocationui.ui b/kopete/plugins/smpppdcs/smpppdlocationui.ui
new file mode 100644
index 00000000..0424f6f6
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdlocationui.ui
@@ -0,0 +1,149 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SMPPPDLocationWidgetBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SMPPPDLocationWidgetBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>365</width>
+ <height>167</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>SMPPPDLocation</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Ser&amp;ver:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>server</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>server</cstring>
+ </property>
+ <property name="cursor">
+ <cursor>4</cursor>
+ </property>
+ <property name="text">
+ <string>localhost</string>
+ </property>
+ <property name="maxLength">
+ <number>256</number>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The server on which the SMPPPD is running</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>P&amp;ort:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>port</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout14</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KIntNumInput">
+ <property name="name">
+ <cstring>port</cstring>
+ </property>
+ <property name="cursor">
+ <cursor>4</cursor>
+ </property>
+ <property name="value">
+ <number>3185</number>
+ </property>
+ <property name="minValue">
+ <number>0</number>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The port on which the SMPPPD is running on</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Default: 3185</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer15</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>130</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_passwordLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Pass&amp;word:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>Password</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>Password</cstring>
+ </property>
+ <property name="cursor">
+ <cursor>4</cursor>
+ </property>
+ <property name="echoMode">
+ <enum>Password</enum>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>The password to authenticate with the smpppd</string>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+</customwidgets>
+<layoutdefaults spacing="6" margin="0"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/kopete/plugins/smpppdcs/smpppdlocationwidget.cpp b/kopete/plugins/smpppdcs/smpppdlocationwidget.cpp
new file mode 100644
index 00000000..b20509d9
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdlocationwidget.cpp
@@ -0,0 +1,30 @@
+/*
+ smpppdlocationwidget.cpp
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <klineedit.h>
+
+#include "smpppdlocationwidget.h"
+
+SMPPPDLocationWidget::SMPPPDLocationWidget(QWidget* parent, const char* name, WFlags fl)
+ : SMPPPDLocationWidgetBase(parent, name, fl) {}
+
+SMPPPDLocationWidget::~SMPPPDLocationWidget() {}
+
+void SMPPPDLocationWidget::setServer(const QString& serv) {
+ server->setText(serv);
+}
+
+#include "smpppdlocationwidget.moc"
diff --git a/kopete/plugins/smpppdcs/smpppdlocationwidget.h b/kopete/plugins/smpppdcs/smpppdlocationwidget.h
new file mode 100644
index 00000000..00fa9157
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdlocationwidget.h
@@ -0,0 +1,39 @@
+/*
+ smpppdlocationwidget.h
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef SMPPPDLOCATIONWIDGET_H
+#define SMPPPDLOCATIONWIDGET_H
+
+#include "smpppdlocationui.h"
+
+/**
+ @author Heiko Sch&auml;fer <heiko@rangun.de>
+*/
+class SMPPPDLocationWidget : public SMPPPDLocationWidgetBase
+{
+ Q_OBJECT
+
+ SMPPPDLocationWidget(const SMPPPDLocationWidget&);
+ SMPPPDLocationWidget& operator=(const SMPPPDLocationWidget&);
+
+public:
+ SMPPPDLocationWidget(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
+ ~SMPPPDLocationWidget();
+
+ void setServer(const QString& serv);
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/smpppdsearcher.cpp b/kopete/plugins/smpppdcs/smpppdsearcher.cpp
new file mode 100644
index 00000000..6ee9c878
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdsearcher.cpp
@@ -0,0 +1,189 @@
+/*
+ smpppdsearcher.h
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <qregexp.h>
+#include <qfile.h>
+
+#include <kprocess.h>
+#include <kdebug.h>
+
+#include "smpppdclient.h"
+#include "smpppdsearcher.h"
+
+SMPPPDSearcher::SMPPPDSearcher()
+ : m_cancelSearchNow(FALSE),
+ m_procIfconfig(NULL),
+m_procNetstat(NULL) {}
+
+SMPPPDSearcher::~SMPPPDSearcher() {
+ delete m_procIfconfig;
+ delete m_procNetstat;
+}
+
+/*!
+ \fn SMPPPDSearcher::searchNetwork() const
+ */
+void SMPPPDSearcher::searchNetwork() {
+ kdDebug(14312) << k_funcinfo << endl;
+
+ // the first point to search is localhost
+ if(!scan("127.0.0.1", "255.0.0.0")) {
+
+ m_procNetstat = new KProcess;
+ m_procNetstat->setEnvironment("LANG", "C"); // we want to force english output
+
+ *m_procNetstat << "/bin/netstat" << "-rn";
+ connect(m_procNetstat, SIGNAL(receivedStdout(KProcess *,char *,int)), this, SLOT(slotStdoutReceivedNetstat(KProcess *,char *,int)));
+ if(!m_procNetstat->start(KProcess::Block, KProcess::Stdout)) {
+ kdDebug(14312) << k_funcinfo << "Couldn't execute /sbin/netstat -rn" << endl << "Perhaps the package net-tools isn't installed." << endl;
+
+ emit smpppdNotFound();
+ }
+
+ delete m_procNetstat;
+ m_procNetstat = NULL;
+ }
+}
+
+/*!
+ \fn SMPPPDSearcher::slotStdoutReceived(KProcess * proc, char * buf, int len)
+ */
+void SMPPPDSearcher::slotStdoutReceivedIfconfig(KProcess * /* proc */, char * buf, int len) {
+ kdDebug(14312) << k_funcinfo << endl;
+
+ QString myBuf = QString::fromLatin1(buf,len);
+ QRegExp rex("^[ ]{10}.*inet addr:([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}).*Mask:([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})");
+ // tokenize the string into lines
+ QStringList toks = QStringList::split("\n", myBuf);
+ for(QStringList::size_type i = 0; i < toks.count(); i++) {
+ if(rex.exactMatch(toks[i])) {
+ if(scan(rex.cap(1), rex.cap(2))) {
+ return;
+ }
+ }
+ }
+
+ emit smpppdNotFound();
+}
+void SMPPPDSearcher::slotStdoutReceivedNetstat(KProcess * /* proc */, char * buf, int len) {
+ kdDebug(14312) << k_funcinfo << endl;
+
+ QRegExp rexGW(".*\\n0.0.0.0[ ]*([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}).*");
+ QString myBuf = QString::fromLatin1(buf,len);
+
+ if(!(rexGW.exactMatch(myBuf) && scan(rexGW.cap(1), "255.255.255.255"))) {
+ // if netstat -r found no gateway we search the network
+ m_procIfconfig = new KProcess;
+ m_procIfconfig->setEnvironment("LANG", "C"); // we want to force english output
+
+ *m_procIfconfig << "/sbin/ifconfig";
+ connect(m_procIfconfig, SIGNAL(receivedStdout(KProcess *,char *,int)), this, SLOT(slotStdoutReceivedIfconfig(KProcess *,char *,int)));
+ if(!m_procIfconfig->start(KProcess::Block, KProcess::Stdout)) {
+ kdDebug(14312) << k_funcinfo << "Couldn't execute /sbin/ifconfig" << endl << "Perhaps the package net-tools isn't installed." << endl;
+
+ emit smpppdNotFound();
+ }
+
+ delete m_procIfconfig;
+ m_procIfconfig = NULL;
+ }
+}
+
+/*!
+ \fn SMPPPDSearcher::scan() const
+ */
+bool SMPPPDSearcher::scan(const QString& ip, const QString& mask) {
+ kdDebug(14312) << k_funcinfo << "Scanning " << ip << "/" << mask << "..." << endl;
+
+ SMPPPD::Client client;
+
+ if(ip == "127.0.0.1") { // if localhost, we only scan this one host
+ if(client.connect(ip, 3185)) {
+ client.disconnect();
+ emit smpppdFound(ip);
+ return true;
+ }
+
+ return false;
+ }
+
+ uint min_range = 0;
+ uint max_range = 255;
+
+ // calculate ip range (only last mask entry)
+ QRegExp lastRex("([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})");
+ if(lastRex.exactMatch(ip)) {
+
+ uint lastWordIP = lastRex.cap(4).toUInt();
+
+ QStringList ipToks;
+ for(int i = 1; i < 5; i++) {
+ ipToks.push_back(lastRex.cap(i));
+ }
+
+ if(lastRex.exactMatch(mask)) {
+ uint lastWordMask = lastRex.cap(4).toUInt();
+
+ if(lastWordMask == 0) {
+ kdDebug(14312) << k_funcinfo << "IP-Range: " << ipToks[0] << "." << ipToks[1] << "." << ipToks[2] << ".0 - " << ipToks[0] << "." << ipToks[1] << "." << ipToks[2] << ".255" << endl;
+ max_range = 255;
+ } else if(lastWordMask == 255) {
+ min_range = max_range = lastWordIP;
+ } else {
+ kdDebug(14312) << k_funcinfo << "IP-Range: " << ipToks[0] << "." << ipToks[1] << "." << ipToks[2] << ".0 - " << ipToks[0] << "." << ipToks[1] << "." << ipToks[2] << "." << lastWordMask << endl;
+ max_range = lastWordMask;
+ }
+ }
+
+ uint range = max_range - min_range;
+ m_cancelSearchNow = FALSE;
+ if(range > 1) {
+ emit scanStarted(max_range);
+ }
+ for(uint i = min_range; i <= max_range; i++) {
+ if(m_cancelSearchNow) {
+ if(range > 1) {
+ emit scanFinished();
+ }
+ break;
+ }
+ if(range > 1) {
+ emit scanProgress(i);
+ }
+
+ if(client.connect(QString(ipToks[0] + "." + ipToks[1] + "." + ipToks[2] + "." + QString::number(i)), 3185)) {
+ client.disconnect();
+ emit smpppdFound(ip);
+ if(range > 1) {
+ emit scanFinished();
+ }
+ return true;
+ }
+#ifndef NDEBUG
+ else {
+ kdDebug(14312) << k_funcinfo << "No smpppd found at " << QString(ipToks[0] + "." + ipToks[1] + "." + ipToks[2] + "." + QString::number(i)) << endl;
+ }
+#endif
+ }
+ if(range > 1) {
+ emit scanFinished();
+ }
+ }
+
+ return false;
+}
+
+#include "smpppdsearcher.moc"
diff --git a/kopete/plugins/smpppdcs/smpppdsearcher.h b/kopete/plugins/smpppdcs/smpppdsearcher.h
new file mode 100644
index 00000000..af36637d
--- /dev/null
+++ b/kopete/plugins/smpppdcs/smpppdsearcher.h
@@ -0,0 +1,102 @@
+/*
+ smpppdsearcher.h
+
+ Copyright (c) 2004-2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+
+#ifndef SMPPPDSEARCHER_H
+#define SMPPPDSEARCHER_H
+
+#include <kresolver.h>
+
+class KProcess;
+
+/**
+ * @brief Searches a network for a smpppd
+ *
+ * @todo Use of the SLP to find the smpppd
+ * @author Heiko Sch&auml;fer <heiko@rangun.de>
+ */
+class SMPPPDSearcher : public QObject {
+ Q_OBJECT
+
+ SMPPPDSearcher(const SMPPPDSearcher&);
+ SMPPPDSearcher& operator=(const SMPPPDSearcher&);
+
+public:
+ /**
+ * @brief Creates an <code>SMPPPDSearcher</code> instance
+ */
+ SMPPPDSearcher();
+
+ /**
+ * @brief Destroys an <code>SMPPPDSearcher</code> instance
+ */
+ ~SMPPPDSearcher();
+
+ /**
+ * @brief Triggers a network scan to find a smpppd
+ * @see smpppdFound
+ * @see smpppdNotFound
+ */
+ void searchNetwork();
+
+ void cancelSearch();
+
+protected:
+ /**
+ * @brief Scans a network for a smpppd
+ *
+ * Scans a network for a smpppd described by
+ * ip and mask.
+ *
+ * @param ip the ntwork ip
+ * @param mask the network mask
+ * @return <code>TRUE</code> if an smpppd was found
+ */
+ bool scan(const QString& ip, const QString& mask);
+
+signals:
+ /**
+ * @brief A smppd was found
+ *
+ * @param host the host there the smpppd was found
+ */
+ void smpppdFound(const QString& host);
+
+ /**
+ * @brief No smpppd was found
+ */
+ void smpppdNotFound();
+
+ void scanStarted(uint total);
+ void scanProgress(uint cur);
+ void scanFinished();
+
+protected slots:
+ void slotStdoutReceivedIfconfig(KProcess * proc, char * buf, int len);
+ void slotStdoutReceivedNetstat (KProcess * proc, char * buf, int len);
+
+private:
+ bool m_cancelSearchNow;
+ KProcess * m_procIfconfig;
+ KProcess * m_procNetstat;
+};
+
+inline void SMPPPDSearcher::cancelSearch() {
+ m_cancelSearchNow = TRUE;
+}
+
+#endif
+
diff --git a/kopete/plugins/smpppdcs/unittest/Makefile.am b/kopete/plugins/smpppdcs/unittest/Makefile.am
new file mode 100644
index 00000000..9694bff9
--- /dev/null
+++ b/kopete/plugins/smpppdcs/unittest/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes) -I../libsmpppdclient
+METASOURCES = AUTO
+
+
+check_PROGRAMS = smpppdcstests
+
+smpppdcstests_SOURCES = main.cpp clienttest.cpp
+smpppdcstests_LDFLAGS = $(KDE_RPATH) $(all_libraries)
+smpppdcstests_LDADD = ../libsmpppdclient/libsmpppdclient.la -lkunittestgui
+
+noinst_HEADERS = clienttest.h
+
+check:
+ kunittest ./smpppdcstests ClientTest
+
diff --git a/kopete/plugins/smpppdcs/unittest/clienttest.cpp b/kopete/plugins/smpppdcs/unittest/clienttest.cpp
new file mode 100644
index 00000000..5affd83c
--- /dev/null
+++ b/kopete/plugins/smpppdcs/unittest/clienttest.cpp
@@ -0,0 +1,121 @@
+/*
+ clienttest.cpp
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include "smpppdclient.h"
+
+#include "clienttest.h"
+
+ClientTest::ClientTest(const char * name)
+ : KUnitTest::SlotTester(name) {}
+
+ClientTest::~ClientTest() {}
+
+void ClientTest::testInitIsReady() {
+ SMPPPD::Client c;
+ CHECK(c.isReady(), false);
+}
+
+void ClientTest::testAfterConnectIsReady() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ CHECK(c.isReady(), true);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+void ClientTest::testConnect() {
+ SMPPPD::Client c;
+ CHECK(c.connect("warwar", 3185), true);
+ CHECK(c.connect("localhost", 3185), false);
+}
+
+void ClientTest::testCommunicationBeforeConnect() {
+ SMPPPD::Client c;
+ QStringList l = c.getInterfaceConfigurations();
+
+ CHECK(l.count() == 0, true);
+ CHECK(c.statusInterface("ifcfg0"), false);
+}
+
+void ClientTest::testServerIDBeforeConnect() {
+ SMPPPD::Client c;
+ CHECK(c.serverID(), QString::null);
+}
+
+void ClientTest::testServerVersionBeforeConnect() {
+ SMPPPD::Client c;
+ CHECK(c.serverVersion(), QString::null);
+}
+
+void ClientTest::testCommunicationAfterConnect() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ CHECK(c.getInterfaceConfigurations().count() > 0, true);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+void ClientTest::testServerIDAfterConnect() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ CHECK(c.serverID().isEmpty(), false);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+void ClientTest::testServerVersionAfterConnect() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ CHECK(c.serverVersion().isEmpty(), false);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+void ClientTest::testCommunicationAfterDisconnect() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ c.disconnect();
+ CHECK(c.getInterfaceConfigurations().count() == 0, true);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+void ClientTest::testServerIDAfterDisconnect() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ c.disconnect();
+ CHECK(c.serverID(), QString::null);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+void ClientTest::testServerVersionAfterDisconnect() {
+ SMPPPD::Client c;
+ if(c.connect("warwar", 3185)) {
+ c.disconnect();
+ CHECK(c.serverVersion(), QString::null);
+ } else {
+ SKIP("Test skipped because no smpppd at warwar:3185");
+ }
+}
+
+#include "clienttest.moc"
diff --git a/kopete/plugins/smpppdcs/unittest/clienttest.h b/kopete/plugins/smpppdcs/unittest/clienttest.h
new file mode 100644
index 00000000..5db7ef7b
--- /dev/null
+++ b/kopete/plugins/smpppdcs/unittest/clienttest.h
@@ -0,0 +1,50 @@
+/*
+ clienttest.h
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#ifndef CLIENTTEST_H
+#define CLIENTTEST_H
+
+#include <kunittest/tester.h>
+
+/**
+ @author Heiko Sch&auml;fer <heiko@rangun.de>
+*/
+class ClientTest : public KUnitTest::SlotTester {
+ Q_OBJECT
+
+ ClientTest(const ClientTest&);
+ ClientTest& operator=(const ClientTest&);
+
+public:
+ ClientTest(const char * name = 0);
+ virtual ~ClientTest();
+
+private slots:
+ void testInitIsReady();
+ void testAfterConnectIsReady();
+ void testConnect();
+ void testCommunicationBeforeConnect();
+ void testServerIDBeforeConnect();
+ void testServerVersionBeforeConnect();
+ void testCommunicationAfterConnect();
+ void testServerIDAfterConnect();
+ void testServerVersionAfterConnect();
+ void testCommunicationAfterDisconnect();
+ void testServerIDAfterDisconnect();
+ void testServerVersionAfterDisconnect();
+};
+
+#endif
diff --git a/kopete/plugins/smpppdcs/unittest/main.cpp b/kopete/plugins/smpppdcs/unittest/main.cpp
new file mode 100644
index 00000000..ec14489b
--- /dev/null
+++ b/kopete/plugins/smpppdcs/unittest/main.cpp
@@ -0,0 +1,45 @@
+/*
+ main.cpp
+
+ Copyright (c) 2006 by Heiko Schaefer <heiko@rangun.de>
+
+ Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * 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; version 2 of the License. *
+ * *
+ *************************************************************************
+*/
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+#include <kunittest/runnergui.h>
+
+#include "clienttest.h"
+
+static const char description[] = I18N_NOOP("SMPPPDClientTests");
+static const char version[] = "0.1";
+static KCmdLineOptions options[] = { KCmdLineLastOption };
+
+int main( int argc, char** argv ) {
+ KAboutData about("SMPPPDClientTests", I18N_NOOP("SMPPPDClientTests"), version, description,
+ KAboutData::License_BSD, "(C) 2006 Heiko Schäfer", 0, 0, "heiko@rangun.de");
+
+ KCmdLineArgs::init(argc, argv, &about);
+ KCmdLineArgs::addCmdLineOptions(options);
+ KApplication app;
+
+ KUnitTest::Runner::registerTester("ClientTest", new ClientTest);
+
+ KUnitTest::RunnerGUI runner(0);
+ runner.show();
+ app.setMainWidget(&runner);
+
+ return app.exec();
+}