summaryrefslogtreecommitdiffstats
path: root/tderesources/scalix/tdeioslave
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:05:15 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:05:15 -0600
commit64df902cf71a8ee258fb85f6be26248f399aa01f (patch)
treedba58f705042c22cea26b678d5b0e4e9a34bf202 /tderesources/scalix/tdeioslave
parentde53c98cab07e9c4b0f5e25dab82830fb6fc67ec (diff)
downloadtdepim-64df902cf71a8ee258fb85f6be26248f399aa01f.tar.gz
tdepim-64df902cf71a8ee258fb85f6be26248f399aa01f.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tderesources/scalix/tdeioslave')
-rw-r--r--tderesources/scalix/tdeioslave/CMakeLists.txt37
-rw-r--r--tderesources/scalix/tdeioslave/Makefile.am17
-rw-r--r--tderesources/scalix/tdeioslave/scalix.cpp225
-rw-r--r--tderesources/scalix/tdeioslave/scalix.h52
-rw-r--r--tderesources/scalix/tdeioslave/scalix.protocol8
-rw-r--r--tderesources/scalix/tdeioslave/scalixs.protocol8
6 files changed, 347 insertions, 0 deletions
diff --git a/tderesources/scalix/tdeioslave/CMakeLists.txt b/tderesources/scalix/tdeioslave/CMakeLists.txt
new file mode 100644
index 000000000..7ba76f672
--- /dev/null
+++ b/tderesources/scalix/tdeioslave/CMakeLists.txt
@@ -0,0 +1,37 @@
+#################################################
+#
+# (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_SOURCE_DIR}/libtdepim
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### other data ################################
+
+install(
+ FILES scalix.protocol scalixs.protocol
+ DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+##### kio_scalix (module) #######################
+
+tde_add_kpart( kio_scalix AUTOMOC
+ SOURCES scalix.cpp
+ LINK tdepim-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tderesources/scalix/tdeioslave/Makefile.am b/tderesources/scalix/tdeioslave/Makefile.am
new file mode 100644
index 000000000..1e66f7091
--- /dev/null
+++ b/tderesources/scalix/tdeioslave/Makefile.am
@@ -0,0 +1,17 @@
+INCLUDES = -I$(top_srcdir) -I$(top_builddir)/libtdepim $(all_includes)
+
+noinst_HEADERS = scalix.h
+
+METASOURCES = AUTO
+
+kdelnkdir = $(kde_servicesdir)
+kdelnk_DATA = scalix.protocol scalixs.protocol
+
+kde_module_LTLIBRARIES = kio_scalix.la
+
+kio_scalix_la_SOURCES = scalix.cpp
+kio_scalix_la_LIBADD = $(top_builddir)/libkcal/libkcal.la $(top_builddir)/libtdepim/libtdepim.la $(LIB_KIO)
+kio_scalix_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/tdeio_scalix.pot
diff --git a/tderesources/scalix/tdeioslave/scalix.cpp b/tderesources/scalix/tdeioslave/scalix.cpp
new file mode 100644
index 000000000..40084669d
--- /dev/null
+++ b/tderesources/scalix/tdeioslave/scalix.cpp
@@ -0,0 +1,225 @@
+/*
+ This file is part of KDE.
+
+ Copyright (C) 2007 Trolltech ASA. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include <tqapplication.h>
+#include <tqeventloop.h>
+
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+#include <tdeversion.h>
+#include <tdeio/global.h>
+#include <klocale.h>
+
+#include <tdepimmacros.h>
+
+#include <stdlib.h>
+
+#include "scalix.h"
+
+extern "C" {
+ KDE_EXPORT int kdemain( int argc, char **argv );
+}
+
+static const KCmdLineOptions options[] =
+{
+ { "+protocol", I18N_NOOP( "Protocol name" ), 0 },
+ { "+pool", I18N_NOOP( "Socket name" ), 0 },
+ { "+app", I18N_NOOP( "Socket name" ), 0 },
+ KCmdLineLastOption
+};
+
+int kdemain( int argc, char **argv )
+{
+ putenv( strdup( "SESSION_MANAGER=" ) );
+ TDEApplication::disableAutoDcopRegistration();
+
+ TDECmdLineArgs::init( argc, argv, "kio_scalix", 0, 0, 0, 0 );
+ TDECmdLineArgs::addCmdLineOptions( options );
+ TDEApplication app( false, false );
+
+ TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
+ Scalix slave( args->arg( 0 ), args->arg( 1 ), args->arg( 2 ) );
+ slave.dispatchLoop();
+
+ return 0;
+}
+
+Scalix::Scalix( const TQCString &protocol, const TQCString &pool, const TQCString &app )
+ : SlaveBase( protocol, pool, app )
+{
+}
+
+void Scalix::get( const KURL &url )
+{
+ mimeType( "text/plain" );
+
+ TQString path = url.path();
+
+ if ( path.contains( "/freebusy/" ) ) {
+ retrieveFreeBusy( url );
+ } else {
+ error( TDEIO::ERR_SLAVE_DEFINED, i18n( "Unknown path. Known path is '/freebusy/'" ) );
+ }
+}
+
+void Scalix::put( const KURL& url, int, bool, bool )
+{
+ TQString path = url.path();
+
+ if ( path.contains( "/freebusy/" ) ) {
+ publishFreeBusy( url );
+ } else {
+ error( TDEIO::ERR_SLAVE_DEFINED, i18n( "Unknown path. Known path is '/freebusy/'" ) );
+ }
+}
+
+void Scalix::retrieveFreeBusy( const KURL &url )
+{
+ /**
+ * The url is of the following form:
+ * scalix://user:password@host/freebusy/user@domain.ifb
+ */
+
+ // Extract user@domain (e.g. everything between '/freebusy/' and '.ifb')
+ const TQString requestUser = url.path().mid( 10, url.path().length() - 14 );
+
+ TQByteArray packedArgs;
+ TQDataStream stream( packedArgs, IO_WriteOnly );
+
+ const TQString argument = TQString( "BEGIN:VFREEBUSY\nATTENDEE:MAILTO:%1\nEND:VFREEBUSY" ).arg( requestUser );
+ const TQString command = TQString( "X-GET-ICAL-FREEBUSY {%1}" ).arg( argument.length() );
+
+ stream << (int) 'X' << 'E' << command << argument;
+
+ TQString imapUrl = TQString( "imap://%1@%3/" ).arg( url.pass().isEmpty() ?
+ url.user() : url.user() + ":" + url.pass() )
+ .arg( url.host() );
+
+ mFreeBusyData = TQString();
+
+ TDEIO::SimpleJob *job = TDEIO::special( imapUrl, packedArgs, false );
+ connect( job, TQT_SIGNAL( infoMessage( TDEIO::Job*, const TQString& ) ),
+ this, TQT_SLOT( slotInfoMessage( TDEIO::Job*, const TQString& ) ) );
+ connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ),
+ this, TQT_SLOT( slotRetrieveResult( TDEIO::Job* ) ) );
+
+ tqApp->eventLoop()->enterLoop();
+}
+
+void Scalix::publishFreeBusy( const KURL &url )
+{
+ /**
+ * The url is of the following form:
+ * scalix://user:password@host/freebusy/path/to/calendar/user@domain
+ */
+ TQString requestUser, calendar;
+ TQString path = url.path();
+
+ // extract user name
+ int lastSlash = path.findRev( '/' );
+ if ( lastSlash != -1 )
+ requestUser = path.mid( lastSlash + 1 );
+
+ // extract calendar name
+ int secondSlash = path.find( '/', 1 );
+ if ( secondSlash != -1 )
+ calendar = path.mid( secondSlash + 1, lastSlash - secondSlash - 1 );
+
+ if ( requestUser.isEmpty() || calendar.isEmpty() ) {
+ error( TDEIO::ERR_SLAVE_DEFINED, i18n( "No user or calendar given!" ) );
+ return;
+ };
+
+ // read freebusy information
+ TQByteArray data;
+ while ( true ) {
+ dataReq();
+
+ TQByteArray buffer;
+ const int newSize = readData(buffer);
+ if ( newSize < 0 ) {
+ // read error: network in unknown state so disconnect
+ error( TDEIO::ERR_COULD_NOT_READ, i18n("KIO data supply error.") );
+ return;
+ }
+
+ if ( newSize == 0 )
+ break;
+
+ unsigned int oldSize = data.size();
+ data.resize( oldSize + buffer.size() );
+ memcpy( data.data() + oldSize, buffer.data(), buffer.size() );
+ }
+
+ TQByteArray packedArgs;
+ TQDataStream stream( packedArgs, IO_WriteOnly );
+
+ const TQString argument = TQString::fromUtf8( data );
+ const TQString command = TQString( "X-PUT-ICAL-FREEBUSY Calendar {%1}" ).arg( argument.length() );
+
+ stream << (int) 'X' << 'E' << command << argument;
+
+ TQString imapUrl = TQString( "imap://%1@%3/" ).arg( url.pass().isEmpty() ?
+ url.user() : url.user() + ":" + url.pass() )
+ .arg( url.host() );
+
+ TDEIO::SimpleJob *job = TDEIO::special( imapUrl, packedArgs, false );
+ connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ),
+ this, TQT_SLOT( slotPublishResult( TDEIO::Job* ) ) );
+
+ tqApp->eventLoop()->enterLoop();
+}
+
+void Scalix::slotInfoMessage( TDEIO::Job *job, const TQString &data )
+{
+ if ( job->error() ) {
+ // error is handled in slotResult
+ return;
+ }
+
+ mFreeBusyData = data;
+}
+
+
+void Scalix::slotRetrieveResult( TDEIO::Job *job )
+{
+ if ( job->error() ) {
+ error( TDEIO::ERR_SLAVE_DEFINED, job->errorString() );
+ } else {
+ data( mFreeBusyData.utf8() );
+ finished();
+ }
+
+ tqApp->eventLoop()->exitLoop();
+}
+
+void Scalix::slotPublishResult( TDEIO::Job *job )
+{
+ if ( job->error() ) {
+ error( TDEIO::ERR_SLAVE_DEFINED, job->errorString() );
+ } else {
+ finished();
+ }
+
+ tqApp->eventLoop()->exitLoop();
+}
+
+#include "scalix.moc"
diff --git a/tderesources/scalix/tdeioslave/scalix.h b/tderesources/scalix/tdeioslave/scalix.h
new file mode 100644
index 000000000..f4dbdeadd
--- /dev/null
+++ b/tderesources/scalix/tdeioslave/scalix.h
@@ -0,0 +1,52 @@
+/*
+ This file is part of KDE.
+
+ Copyright (C) 2007 Trolltech ASA. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SCALIX_H
+#define SCALIX_H
+
+#include <tdeio/job.h>
+#include <tdeio/slavebase.h>
+
+#include <tqobject.h>
+
+class Scalix : public TQObject, public TDEIO::SlaveBase
+{
+ Q_OBJECT
+
+
+ public:
+ Scalix( const TQCString &protocol, const TQCString &pool, const TQCString &app );
+
+ void get( const KURL &url );
+ void put( const KURL &url, int permissions, bool overwrite, bool resume );
+
+ private slots:
+ void slotRetrieveResult( TDEIO::Job* );
+ void slotPublishResult( TDEIO::Job* );
+ void slotInfoMessage( TDEIO::Job*, const TQString& );
+
+ private:
+ void retrieveFreeBusy( const KURL& );
+ void publishFreeBusy( const KURL& );
+
+ TQString mFreeBusyData;
+};
+
+#endif
diff --git a/tderesources/scalix/tdeioslave/scalix.protocol b/tderesources/scalix/tdeioslave/scalix.protocol
new file mode 100644
index 000000000..91a213e87
--- /dev/null
+++ b/tderesources/scalix/tdeioslave/scalix.protocol
@@ -0,0 +1,8 @@
+[Protocol]
+DocPath=tdeioslave/scalix.html
+exec=kio_scalix
+input=none
+output=filesystem
+protocol=scalix
+reading=true
+writing=true
diff --git a/tderesources/scalix/tdeioslave/scalixs.protocol b/tderesources/scalix/tdeioslave/scalixs.protocol
new file mode 100644
index 000000000..19defac56
--- /dev/null
+++ b/tderesources/scalix/tdeioslave/scalixs.protocol
@@ -0,0 +1,8 @@
+[Protocol]
+DocPath=tdeioslave/scalix.html
+exec=kio_scalix
+input=none
+output=filesystem
+protocol=scalixs
+reading=true
+writing=true