summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/jabber/tdeioslave
diff options
context:
space:
mode:
Diffstat (limited to 'kopete/protocols/jabber/tdeioslave')
-rw-r--r--kopete/protocols/jabber/tdeioslave/CMakeLists.txt42
-rw-r--r--kopete/protocols/jabber/tdeioslave/Makefile.am25
-rw-r--r--kopete/protocols/jabber/tdeioslave/jabberdisco.cpp399
-rw-r--r--kopete/protocols/jabber/tdeioslave/jabberdisco.h83
-rw-r--r--kopete/protocols/jabber/tdeioslave/jabberdisco.protocol53
5 files changed, 602 insertions, 0 deletions
diff --git a/kopete/protocols/jabber/tdeioslave/CMakeLists.txt b/kopete/protocols/jabber/tdeioslave/CMakeLists.txt
new file mode 100644
index 00000000..aaf788bd
--- /dev/null
+++ b/kopete/protocols/jabber/tdeioslave/CMakeLists.txt
@@ -0,0 +1,42 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/..
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libiris/iris/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libiris/iris/jabber
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libiris/iris/xmpp-im
+ ${CMAKE_CURRENT_SOURCE_DIR}/../libiris/cutestuff/util
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### other data ################################
+
+install( FILES jabberdisco.protocol DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+##### kio_jabberdisco (module) ##################
+
+tde_add_kpart( kio_jabberdisco AUTOMOC
+ SOURCES jabberdisco.cpp
+ LINK
+ jabberclient-static
+ iris_xmpp_core-static iris_xmpp_im-static iris_jabber-static iris-static
+ qca-static cutestuff_network-static cutestuff_util-static tdeio-shared idn
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/kopete/protocols/jabber/tdeioslave/Makefile.am b/kopete/protocols/jabber/tdeioslave/Makefile.am
new file mode 100644
index 00000000..f8b9c651
--- /dev/null
+++ b/kopete/protocols/jabber/tdeioslave/Makefile.am
@@ -0,0 +1,25 @@
+METASOURCES = AUTO
+
+INCLUDES = \
+ -I$(srcdir)/.. \
+ -I$(srcdir)/../libiris/iris/include \
+ -I$(srcdir)/../libiris/iris/xmpp-im \
+ -I$(srcdir)/../libiris/iris/jabber \
+ -I$(srcdir)/../libiris/qca/src \
+ -I$(srcdir)/../libiris/cutestuff/util \
+ -I$(srcdir)/../libiris/cutestuff/network \
+ $(all_includes)
+
+kde_module_LTLIBRARIES = kio_jabberdisco.la
+
+kio_jabberdisco_la_SOURCES = jabberdisco.cpp
+kio_jabberdisco_la_LIBADD = ../libjabberclient.la ../libiris/qca/src/libqca.la ../libiris/iris/include/libiris.la ../libiris/iris/xmpp-im/libiris_xmpp_im.la ../libiris/iris/xmpp-core/libiris_xmpp_core.la ../libiris/iris/jabber/libiris_jabber.la ../libiris/cutestuff/util/libcutestuff_util.la ../libiris/cutestuff/network/libcutestuff_network.la $(LIB_KIO)
+kio_jabberdisco_la_LDFLAGS = -no-undefined -module $(KDE_PLUGIN) $(all_libraries) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+
+noinst_HEADERS = jabberdisco.h
+
+protocol_DATA = jabberdisco.protocol
+protocoldir = $(kde_servicesdir)
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/tdeio_jabberdisco.pot
diff --git a/kopete/protocols/jabber/tdeioslave/jabberdisco.cpp b/kopete/protocols/jabber/tdeioslave/jabberdisco.cpp
new file mode 100644
index 00000000..311cfafd
--- /dev/null
+++ b/kopete/protocols/jabber/tdeioslave/jabberdisco.cpp
@@ -0,0 +1,399 @@
+
+/***************************************************************************
+ Jabber Service Discovery KIO Slave
+ -------------------
+ begin : Wed June 1 2005
+ copyright : (C) 2005 by Till Gerken <till@tantalo.net>
+
+ Kopete (C) 2001-2005 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; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <kdebug.h>
+
+#include "jabberdisco.h"
+
+#include <stdlib.h>
+#include <tqcstring.h>
+#include <tqthread.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kapplication.h>
+#include <kmessagebox.h>
+
+#include <xmpp_tasks.h>
+#include "jabberclient.h"
+
+JabberDiscoProtocol::JabberDiscoProtocol ( const TQCString &pool_socket, const TQCString &app_socket )
+ : TDEIO::SlaveBase ( "kio_jabberdisco", pool_socket, app_socket )
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << "Slave launched." << endl;
+
+ m_jabberClient = 0l;
+ m_connected = false;
+
+}
+
+
+JabberDiscoProtocol::~JabberDiscoProtocol ()
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << "Slave is shutting down." << endl;
+
+ delete m_jabberClient;
+
+}
+
+void JabberDiscoProtocol::setHost ( const TQString &host, int port, const TQString &user, const TQString &pass )
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << " Host " << host << ", port " << port << ", user " << user << endl;
+
+ m_host = host;
+ m_port = !port ? 5222 : port;
+ m_user = TQString(user).replace ( "%", "@" );
+ m_password = pass;
+
+}
+
+void JabberDiscoProtocol::openConnection ()
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << endl;
+
+ if ( m_connected )
+ {
+ return;
+ }
+
+ // instantiate new client backend or clean up old one
+ if ( !m_jabberClient )
+ {
+ m_jabberClient = new JabberClient;
+
+ TQObject::connect ( m_jabberClient, TQT_SIGNAL ( csDisconnected () ), this, TQT_SLOT ( slotCSDisconnected () ) );
+ TQObject::connect ( m_jabberClient, TQT_SIGNAL ( csError ( int ) ), this, TQT_SLOT ( slotCSError ( int ) ) );
+ TQObject::connect ( m_jabberClient, TQT_SIGNAL ( tlsWarning ( int ) ), this, TQT_SLOT ( slotHandleTLSWarning ( int ) ) );
+ TQObject::connect ( m_jabberClient, TQT_SIGNAL ( connected () ), this, TQT_SLOT ( slotConnected () ) );
+ TQObject::connect ( m_jabberClient, TQT_SIGNAL ( error ( JabberClient::ErrorCode ) ), this, TQT_SLOT ( slotClientError ( JabberClient::ErrorCode ) ) );
+
+ TQObject::connect ( m_jabberClient, TQT_SIGNAL ( debugMessage ( const TQString & ) ),
+ this, TQT_SLOT ( slotClientDebugMessage ( const TQString & ) ) );
+ }
+ else
+ {
+ m_jabberClient->disconnect ();
+ }
+
+ // we need to use the old protocol for now
+ m_jabberClient->setUseXMPP09 ( true );
+
+ // set SSL flag (this should be converted to forceTLS when using the new protocol)
+ m_jabberClient->setUseSSL ( false );
+
+ // override server and port (this should be dropped when using the new protocol and no direct SSL)
+ m_jabberClient->setOverrideHost ( true, m_host, m_port );
+
+ // allow plaintext password authentication or not?
+ m_jabberClient->setAllowPlainTextPassword ( false );
+
+ switch ( m_jabberClient->connect ( XMPP::Jid ( m_user + TQString("/") + "JabberBrowser" ), m_password ) )
+ {
+ case JabberClient::NoTLS:
+ // no SSL support, at the connecting stage this means the problem is client-side
+ error ( TDEIO::ERR_UPGRADE_REQUIRED, i18n ( "TLS" ) );
+ break;
+
+ case JabberClient::Ok:
+ default:
+ // everything alright!
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << "Waiting for socket to open..." << endl;
+ break;
+ }
+
+ connected ();
+
+}
+
+void JabberDiscoProtocol::closeConnection ()
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << endl;
+
+ if ( m_jabberClient )
+ {
+ m_jabberClient->disconnect ();
+ }
+
+}
+
+void JabberDiscoProtocol::slave_status ()
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << endl;
+
+ slaveStatus ( m_host, m_connected );
+
+}
+
+void JabberDiscoProtocol::get ( const KURL &url )
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << endl;
+
+ m_command = Get;
+ m_url = url;
+
+ mimeType ( "inode/directory" );
+
+ finished ();
+
+}
+
+void JabberDiscoProtocol::listDir ( const KURL &url )
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << endl;
+
+ m_command = ListDir;
+ m_url = url;
+
+ openConnection ();
+
+}
+
+void JabberDiscoProtocol::mimetype ( const KURL &/*url*/ )
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << endl;
+
+ mimeType("inode/directory");
+
+ finished ();
+
+}
+
+void JabberDiscoProtocol::slotClientDebugMessage ( const TQString &msg )
+{
+
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << msg << endl;
+
+}
+
+void JabberDiscoProtocol::slotHandleTLSWarning ( int validityResult )
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << "Handling TLS warning..." << endl;
+
+ if ( messageBox ( TDEIO::SlaveBase::WarningContinueCancel,
+ i18n ( "The server certificate is invalid. Do you want to continue? " ),
+ i18n ( "Certificate Warning" ) ) == KMessageBox::Continue )
+ {
+ // resume stream
+ m_jabberClient->continueAfterTLSWarning ();
+ }
+ else
+ {
+ // disconnect stream
+ closeConnection ();
+ }
+
+}
+
+void JabberDiscoProtocol::slotClientError ( JabberClient::ErrorCode errorCode )
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << "Handling client error..." << endl;
+
+ switch ( errorCode )
+ {
+ case JabberClient::NoTLS:
+ default:
+ error ( TDEIO::ERR_UPGRADE_REQUIRED, i18n ( "TLS" ) );
+ closeConnection ();
+ break;
+ }
+
+}
+
+void JabberDiscoProtocol::slotConnected ()
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << "Connected to Jabber server." << endl;
+
+ XMPP::JT_DiscoItems *discoTask;
+
+ m_connected = true;
+
+ // now execute command
+ switch ( m_command )
+ {
+ case ListDir: // list a directory
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << "Listing directory..." << endl;
+ discoTask = new XMPP::JT_DiscoItems ( m_jabberClient->rootTask () );
+ connect ( discoTask, TQT_SIGNAL ( finished () ), this, TQT_SLOT ( slotQueryFinished () ) );
+ discoTask->get ( m_host );
+ discoTask->go ( true );
+ break;
+
+ case Get: // retrieve an item
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << "Retrieving item..." << endl;
+ break;
+
+ default: // do nothing by default
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << "Unknown command " << m_command << endl;
+ break;
+ }
+
+}
+
+void JabberDiscoProtocol::slotQueryFinished ()
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << "Query task finished" << endl;
+
+ XMPP::JT_DiscoItems * task = (XMPP::JT_DiscoItems *) sender ();
+
+ if (!task->success ())
+ {
+ error ( TDEIO::ERR_COULD_NOT_READ, "" );
+ return;
+ }
+
+ XMPP::DiscoList::const_iterator itemsEnd = task->items().end ();
+ for (XMPP::DiscoList::const_iterator it = task->items().begin (); it != itemsEnd; ++it)
+ {
+ TDEIO::UDSAtom atom;
+ TDEIO::UDSEntry entry;
+
+ atom.m_uds = TDEIO::UDS_NAME;
+ atom.m_str = (*it).jid().userHost ();
+ entry.prepend ( atom );
+
+ atom.m_uds = TDEIO::UDS_SIZE;
+ atom.m_long = 0;
+ entry.prepend ( atom );
+
+ atom.m_uds = TDEIO::UDS_LINK_DEST;
+ atom.m_str = (*it).name ();
+ entry.prepend ( atom );
+
+ atom.m_uds = TDEIO::UDS_MIME_TYPE;
+ atom.m_str = "inode/directory";
+ entry.prepend ( atom );
+
+ atom.m_uds = TDEIO::UDS_SIZE;
+ atom.m_long = 0;
+ entry.prepend ( atom );
+
+ listEntry ( entry, false );
+
+ }
+
+ listEntry ( TDEIO::UDSEntry(), true );
+
+ finished ();
+
+}
+
+void JabberDiscoProtocol::slotCSDisconnected ()
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << "Disconnected from Jabber server." << endl;
+
+ /*
+ * We should delete the JabberClient instance here,
+ * but timers etc prevent us from doing so. Iris does
+ * not like to be deleted from a slot.
+ */
+ m_connected = false;
+
+}
+
+void JabberDiscoProtocol::slotCSError ( int errorCode )
+{
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << "Error in stream signalled." << endl;
+
+ if ( ( errorCode == XMPP::ClientStream::ErrAuth )
+ && ( m_jabberClient->clientStream()->errorCondition () == XMPP::ClientStream::NotAuthorized ) )
+ {
+ kdDebug ( JABBER_DISCO_DEBUG ) << k_funcinfo << "Incorrect password, retrying." << endl;
+
+ TDEIO::AuthInfo authInfo;
+ authInfo.username = m_user;
+ authInfo.password = m_password;
+ if ( openPassDlg ( authInfo, i18n ( "The login details are incorrect. Do you want to try again?" ) ) )
+ {
+ m_user = authInfo.username;
+ m_password = authInfo.password;
+ closeConnection ();
+ openConnection ();
+ }
+ else
+ {
+ closeConnection ();
+ error ( TDEIO::ERR_COULD_NOT_AUTHENTICATE, "" );
+ }
+ }
+ else
+ {
+ closeConnection ();
+ error ( TDEIO::ERR_CONNECTION_BROKEN, "" );
+ }
+
+}
+
+bool breakEventLoop = false;
+
+class EventLoopThread : public TQThread
+{
+public:
+ void run ();
+};
+
+void EventLoopThread::run ()
+{
+
+ while ( true )
+ {
+ tqApp->processEvents ();
+ msleep ( 100 );
+
+ if ( breakEventLoop )
+ break;
+ }
+
+}
+
+void JabberDiscoProtocol::dispatchLoop ()
+{
+
+ EventLoopThread eventLoopThread;
+
+ eventLoopThread.start ();
+ SlaveBase::dispatchLoop ();
+ breakEventLoop = true;
+ eventLoopThread.wait ();
+
+}
+
+extern "C"
+{
+ KDE_EXPORT int kdemain(int argc, char **argv);
+}
+
+
+int kdemain ( int argc, char **argv )
+{
+ TDEApplication app(argc, argv, "kio_jabberdisco", false, true);
+
+ kdDebug(JABBER_DISCO_DEBUG) << k_funcinfo << endl;
+
+ if ( argc != 4 )
+ {
+ kdDebug(JABBER_DISCO_DEBUG) << "Usage: kio_jabberdisco protocol domain-socket1 domain-socket2" << endl;
+ exit(-1);
+ }
+
+ JabberDiscoProtocol slave ( argv[2], argv[3] );
+ slave.dispatchLoop ();
+
+ return 0;
+}
+
+#include "jabberdisco.moc"
diff --git a/kopete/protocols/jabber/tdeioslave/jabberdisco.h b/kopete/protocols/jabber/tdeioslave/jabberdisco.h
new file mode 100644
index 00000000..a2bc92a4
--- /dev/null
+++ b/kopete/protocols/jabber/tdeioslave/jabberdisco.h
@@ -0,0 +1,83 @@
+
+/***************************************************************************
+ Jabber Service Discovery KIO Slave
+ -------------------
+ begin : Wed June 1 2005
+ copyright : (C) 2005 by Till Gerken <till@tantalo.net>
+
+ Kopete (C) 2001-2005 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; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _JABBERDISCO_H_
+#define _JABBERDISCO_H_
+
+#include <tqobject.h>
+#include <tqstring.h>
+#include <tqcstring.h>
+
+#include <kurl.h>
+#include <tdeio/global.h>
+#include <tdeio/slavebase.h>
+#include <jabberclient.h>
+
+#define JABBER_DISCO_DEBUG 0
+
+class JabberClient;
+
+class JabberDiscoProtocol : public TQObject, public TDEIO::SlaveBase
+{
+
+Q_OBJECT
+
+
+public:
+ JabberDiscoProtocol ( const TQCString &pool_socket, const TQCString &app_socket );
+ virtual ~JabberDiscoProtocol ();
+
+ void setHost ( const TQString &host, int port, const TQString &user, const TQString &pass );
+
+ void openConnection ();
+ void closeConnection ();
+
+ void slave_status ();
+
+ void get ( const KURL &url );
+ void listDir ( const KURL &url );
+ void mimetype ( const KURL &url );
+
+ void dispatchLoop ();
+
+private slots:
+ void slotClientDebugMessage ( const TQString &msg );
+ void slotHandleTLSWarning ( int validityResult );
+ void slotClientError ( JabberClient::ErrorCode errorCode );
+ void slotConnected ();
+ void slotCSDisconnected ();
+ void slotCSError ( int error );
+
+ void slotQueryFinished ();
+
+private:
+ enum CommandType { Get, ListDir };
+
+ TQString m_host, m_user, m_password;
+ int m_port;
+ KURL m_url;
+ bool m_connected;
+
+ CommandType m_command;
+
+ JabberClient *m_jabberClient;
+
+};
+
+#endif
diff --git a/kopete/protocols/jabber/tdeioslave/jabberdisco.protocol b/kopete/protocols/jabber/tdeioslave/jabberdisco.protocol
new file mode 100644
index 00000000..fcc0161b
--- /dev/null
+++ b/kopete/protocols/jabber/tdeioslave/jabberdisco.protocol
@@ -0,0 +1,53 @@
+[Protocol]
+exec=kio_jabberdisco
+protocol=jabber
+input=none
+output=filesystem
+reading=true
+writing=false
+makedir=false
+linking=false
+moving=false
+Icon=remote
+Description=A KIO slave for Jabber Service Discovery
+Description[be]=Модуль tdeioslave для пошуку сервісаў Jabber
+Description[bn]=Jabber সার্ভিস ডিসকভারির জন্য একটি কে-আই-ও স্লেভ
+Description[bs]=KIO slave za otkrivanje Jabber servisa
+Description[ca]=Un esclau KIO pel servei de de descoberta del Jabber
+Description[cs]=Pomocný protokol pro zjišťování služeb Jabber
+Description[da]=En tdeioslave til at opdage jabber service
+Description[de]=Ein Ein-/Ausgabemodul zum Auffinden von Jabber-Diensten
+Description[el]=Ένα tdeioslave για την ανίχνευση υπηρεσίας Jabber
+Description[es]=Un «tdeioslave» para el servicio de descubrimiento jabber
+Description[et]=Jabberi teenuste tuvastamise KIO-moodul
+Description[eu]=Jabber aurkikuntza zerbitzureako KIO morroi bat
+Description[fa]=یک پیرو KIO برای خدمت اکتشافی Jabber
+Description[fr]=Un module d'entrée / sortie pour la recherche de service Jabber
+Description[gl]=Un KIO slave para Jabber Service Discovery
+Description[hu]=KDE-protokoll a Jabber szolgáltatáskereső használatához
+Description[is]=tdeioslave fyrir Jabber þjónustu uppgötvun
+Description[it]=Un KIO slave per il servizio di discovery per Jabber
+Description[ja]=Jabber Service Discovery の KIO スレーブ
+Description[ka]=KIO slave Jabber სერვისის დირექტორიისთვის
+Description[kk]=Jabber қызметін байқау KIO slave қызметі
+Description[km]=KIO slave មួយ​សម្រាប់​របក​គំហើញ​សេវា Jabber
+Description[lt]=Priedas (tdeioslave) FISH protokolui
+Description[nb]=En tdeioslave for Jabber tjenestesøk
+Description[nds]=En In-/Utgaavmoduul för't Finnen vun Jabber-Deensten
+Description[ne]=ज्याबर सेवा खोजीका लागि कियो स्लाभ
+Description[nl]=Een tdeioslave voor Jabber Service Discovery
+Description[nn]=Ein KIO-slave for Jabber-tenesteoppdaging
+Description[pl]=Wtyczka protokołu KIO dla usługi odkrywania usług Jabbera (Jabber Service Discovery)
+Description[pt]=Um 'tdeioslave' para a Descoberta de Serviços do Jabber
+Description[pt_BR]=Um KIO-Slave para a descoberta de serviço do Jabber
+Description[ru]=Обработчик KIO для обнаружения служб Jabber
+Description[sk]=KIO otrok pre Jabber Service Discovery
+Description[sl]=KIO slave za odkrivanje storitev za Jabber
+Description[sr]=KIO слуга за Jabber Service Discovery
+Description[sr@Latn]=KIO sluga za Jabber Service Discovery
+Description[sv]=En I/O-slav för Jabber tjänstupptäckt
+Description[tr]=Jabber Servis Bulucu için KIOSlave
+Description[uk]=Підлеглий В/В для виявлення служби Jabber
+Description[zh_CN]=Jabber 服务发现的 KIO slave
+Description[zh_HK]=用於發現 Jabber 服務的 KIO slave
+Description[zh_TW]=Jabber 服務的 tdeioslave