diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch) | |
tree | 67208f7c145782a7e90b123b982ca78d88cc2c87 /kioslaves/opengroupware | |
download | tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.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/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kioslaves/opengroupware')
-rw-r--r-- | kioslaves/opengroupware/Makefile.am | 17 | ||||
-rw-r--r-- | kioslaves/opengroupware/opengroupware.cpp | 250 | ||||
-rw-r--r-- | kioslaves/opengroupware/opengroupware.h | 56 | ||||
-rw-r--r-- | kioslaves/opengroupware/opengroupware.protocol | 7 | ||||
-rw-r--r-- | kioslaves/opengroupware/opengroupwares.protocol | 7 | ||||
-rw-r--r-- | kioslaves/opengroupware/webdavhandler.cpp | 81 | ||||
-rw-r--r-- | kioslaves/opengroupware/webdavhandler.h | 44 |
7 files changed, 462 insertions, 0 deletions
diff --git a/kioslaves/opengroupware/Makefile.am b/kioslaves/opengroupware/Makefile.am new file mode 100644 index 000000000..bd4104904 --- /dev/null +++ b/kioslaves/opengroupware/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/kresources/opengroupware/soap \ + $(all_includes) + +noinst_HEADERS = opengroupware.h + +METASOURCES = AUTO + +kdelnkdir = $(kde_servicesdir) +kdelnk_DATA = opengroupware.protocol opengroupwares.protocol + +kde_module_LTLIBRARIES = kio_opengroupware.la + +kio_opengroupware_la_SOURCES = opengroupware.cpp webdavhandler.cpp +kio_opengroupware_la_LIBADD = $(top_builddir)/libkcal/libkcal.la \ + $(top_builddir)/libkdepim/libkdepim.la $(LIB_KIO) +kio_opengroupware_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + diff --git a/kioslaves/opengroupware/opengroupware.cpp b/kioslaves/opengroupware/opengroupware.cpp new file mode 100644 index 000000000..76abeb10e --- /dev/null +++ b/kioslaves/opengroupware/opengroupware.cpp @@ -0,0 +1,250 @@ +/* + This file is part of KDE. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@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. + + 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 "opengroupware.h" +#include "webdavhandler.h" + +#include <kdebug.h> +#include <kurl.h> +#include <kio/job.h> +#include <kio/davjob.h> +#include <klocale.h> + +#include <libkdepim/kabcresourcecached.h> + +#include <libkcal/freebusy.h> +#include <libkcal/icalformat.h> +#include <libkcal/scheduler.h> +#include <libkcal/calendarlocal.h> + +#include <kabc/vcardconverter.h> + +#include <kinstance.h> +#include <kdebug.h> +#include <klocale.h> +#include <ktempfile.h> + +#include <sys/types.h> +#include <unistd.h> +#include <stdlib.h> + +#include <kdepimmacros.h> + +namespace KABC { + +class ResourceMemory : public ResourceCached +{ + public: + ResourceMemory() : ResourceCached( 0 ) {} + + Ticket *requestSaveTicket() { return 0; } + bool load() { return true; } + bool save( Ticket * ) { return true; } + void releaseSaveTicket( Ticket * ) {} +}; + +} + + +extern "C" { +KDE_EXPORT int kdemain( int argc, char **argv ); +} + +int kdemain( int argc, char **argv ) +{ + KInstance instance( "kio_OpenGroupware" ); + + kdDebug(7000) << "Starting kio_OpenGroupware(pid: " << getpid() << ")" << endl; + + if (argc != 4) { + fprintf( stderr, "Usage: kio_OpenGroupware protocol domain-socket1 domain-socket2\n"); + exit( -1 ); + } + + OpenGroupware slave( argv[1], argv[2], argv[3] ); + slave.dispatchLoop(); + + return 0; +} + +OpenGroupware::OpenGroupware( const QCString &protocol, const QCString &pool, + const QCString &app ) + : SlaveBase( protocol, pool, app ) +{ +} + +void OpenGroupware::get( const KURL &url ) +{ + kdDebug(7000) << "OpenGroupware::get()" << endl; + kdDebug(7000) << " URL: " << url.url() << endl; + #if 1 + kdDebug(7000) << " Path: " << url.path() << endl; + kdDebug(7000) << " Query: " << url.query() << endl; + kdDebug(7000) << " Protocol: " << url.protocol() << endl; + kdDebug(7000) << " Filename: " << url.filename() << endl; + #endif + + mimeType( "text/plain" ); + + QString path = url.path(); + debugMessage( "Path: " + path ); + + if ( path.startsWith( "/freebusy/" ) ) { + getFreeBusy( url ); + } else if ( path.startsWith( "/calendar/" ) ) { + getCalendar( url ); + } else if ( path.startsWith( "/addressbook/" ) ) { + getAddressbook( url ); + } else { + QString error = i18n("Unknown path. Known paths are '/freebusy/', " + "'/calendar/' and '/addressbook/'."); + errorMessage( error ); + } + + kdDebug(7000) << "OpenGroupwareCgiProtocol::get() done" << endl; +} + +void OpenGroupware::getFreeBusy( const KURL &url ) +{ + QString file = url.filename(); + if ( file.right( 4 ) != ".ifb" ) { + QString error = i18n("Illegal filename. File has to have '.ifb' suffix."); + errorMessage( error ); + } else { + QString email = file.left( file.length() - 4 ); + debugMessage( "Email: " + email ); + + QString user = url.user(); + QString pass = url.pass(); + + debugMessage( "URL: " ); + debugMessage( "User: " + user ); + debugMessage( "Password: " + pass ); + + KCal::FreeBusy *fb = new KCal::FreeBusy; + + if ( user.isEmpty() || pass.isEmpty() ) { + errorMessage( i18n("Need username and password.") ); + } else { + // FIXME get from server + + // FIXME: Read range from configuration or URL parameters. + QDate start = QDate::currentDate().addDays( -3 ); + QDate end = QDate::currentDate().addDays( 60 ); + + fb->setDtStart( start ); + fb->setDtEnd( end ); + + kdDebug() << "Login" << endl; + + } + +#if 0 + QDateTime s = QDateTime( QDate( 2004, 9, 27 ), QTime( 10, 0 ) ); + QDateTime e = QDateTime( QDate( 2004, 9, 27 ), QTime( 11, 0 ) ); + + fb->addPeriod( s, e ); +#endif + + KCal::ICalFormat format; + + QString ical = format.createScheduleMessage( fb, KCal::Scheduler::Publish ); + + data( ical.utf8() ); + + finished(); + } +} + + +void OpenGroupware::getCalendar( const KURL &_url ) +{ + + KURL url( _url ); // we'll be changing it + QString user = url.user(); + QString pass = url.pass(); + + QDomDocument props = WebdavHandler::createAllPropsRequest(); + + debugMessage( "URL: " ); + debugMessage( "User: " + user ); + debugMessage( "Password: " + pass ); + + url.setProtocol( "webdav" ); + url.setPath ( "/zidestore/dav/till/" ); + + kdDebug(7000) << "getCalendar: " << url.prettyURL() << endl; + + // FIXME do progress handling + mListEventsJob = KIO::davPropFind( url, props, "0", false ); + connect( mListEventsJob, SIGNAL( result( KIO::Job * ) ), + SLOT( slotGetCalendarListingResult( KIO::Job * ) ) ); +} + +void OpenGroupware::getAddressbook( const KURL &url ) +{ + +} + +void OpenGroupware::errorMessage( const QString &msg ) +{ + error( KIO::ERR_SLAVE_DEFINED, msg ); +} + +void OpenGroupware::debugMessage( const QString &msg ) +{ +#if 0 + data( ( msg + "\n" ).utf8() ); +#else + Q_UNUSED( msg ); +#endif +} + + +void OpenGroupware::slotGetCalendarListingResult( KIO::Job *job ) +{ + + kdDebug(7000) << k_funcinfo << endl; + + if ( job->error() ) { + job->showErrorDialog( 0 ); + } else { + kdDebug() << "ResourceSlox::slotResult() success" << endl; + + QDomDocument doc = mListEventsJob->response(); + + } + KCal::ICalFormat format; + KCal::CalendarLocal calendar; + + QString ical = format.toString( &calendar ); + + data( ical.utf8() ); + + finished(); +} + + +void OpenGroupware::slotGetCalendarResult( KIO::Job *job ) +{ + Q_UNUSED( job ); +} +#include "opengroupware.moc" + diff --git a/kioslaves/opengroupware/opengroupware.h b/kioslaves/opengroupware/opengroupware.h new file mode 100644 index 000000000..04eadf456 --- /dev/null +++ b/kioslaves/opengroupware/opengroupware.h @@ -0,0 +1,56 @@ +/* + This file is part of KDE. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@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. + + 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 GROUPWISE_H +#define GROUPWISE_H + +#include <kio/slavebase.h> + +#include <qobject.h> + +namespace KIO { + class Job; + class DavJob; +} + + +class OpenGroupware : public QObject, public KIO::SlaveBase +{ + Q_OBJECT + public: + OpenGroupware( const QCString &protocol, const QCString &pool, + const QCString &app ); + + void get( const KURL &url ); + + protected: + void debugMessage( const QString & ); + void errorMessage( const QString & ); + + void getFreeBusy( const KURL &url ); + void getCalendar( const KURL &url ); + void getAddressbook( const KURL &url ); + protected slots: + void slotGetCalendarListingResult( KIO::Job* ); + void slotGetCalendarResult( KIO::Job* ); + private: + KIO::DavJob *mListEventsJob; +}; + +#endif diff --git a/kioslaves/opengroupware/opengroupware.protocol b/kioslaves/opengroupware/opengroupware.protocol new file mode 100644 index 000000000..89c0b9ea2 --- /dev/null +++ b/kioslaves/opengroupware/opengroupware.protocol @@ -0,0 +1,7 @@ +[Protocol] +DocPath=kioslave/opengroupware.html +exec=kio_opengroupware +input=none +output=filesystem +protocol=opengroupware +reading=true diff --git a/kioslaves/opengroupware/opengroupwares.protocol b/kioslaves/opengroupware/opengroupwares.protocol new file mode 100644 index 000000000..595057b27 --- /dev/null +++ b/kioslaves/opengroupware/opengroupwares.protocol @@ -0,0 +1,7 @@ +[Protocol] +DocPath=kioslave/opengroupware.html +exec=kio_opengroupware +input=none +output=filesystem +protocol=opengroupwares +reading=true diff --git a/kioslaves/opengroupware/webdavhandler.cpp b/kioslaves/opengroupware/webdavhandler.cpp new file mode 100644 index 000000000..683302003 --- /dev/null +++ b/kioslaves/opengroupware/webdavhandler.cpp @@ -0,0 +1,81 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@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. + + 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 <config.h> + +#include "webdavhandler.h" + +#include <limits.h> + +#include <libkdepim/kpimprefs.h> + +#include <kdebug.h> +#include <kconfig.h> + +#include <qfile.h> + + +WebdavHandler::WebdavHandler() +{ +} + + +QDomElement WebdavHandler::addElement( QDomDocument &doc, QDomNode &node, + const QString &tag ) +{ + QDomElement el = doc.createElement( tag ); + node.appendChild( el ); + return el; +} + +QDomElement WebdavHandler::addDavElement( QDomDocument &doc, QDomNode &node, + const QString &tag ) +{ + QDomElement el = doc.createElementNS( "DAV", tag ); + node.appendChild( el ); + return el; +} + +QDomElement WebdavHandler::addSloxElement( QDomDocument &doc, QDomNode &node, + const QString &tag, + const QString &text ) +{ + QDomElement el = doc.createElementNS( "SLOX", tag ); + if ( !text.isEmpty() ) { + QDomText textnode = doc.createTextNode( text ); + el.appendChild( textnode ); + } + node.appendChild( el ); + return el; +} + +QDomDocument WebdavHandler::createAllPropsRequest() +{ + QDomDocument doc; + + QDomElement root = WebdavHandler::addDavElement( doc, doc, "propfind" ); + QDomElement prop = WebdavHandler::addDavElement( doc, root, "prop" ); + WebdavHandler::addDavElement( doc, prop, "getcontentlength"); + WebdavHandler::addDavElement( doc, prop, "getlastmodified" ); + WebdavHandler::addDavElement( doc, prop, "displayname" ); + WebdavHandler::addDavElement( doc, prop, "resourcetype" ); + prop.appendChild( doc.createElementNS( "http://apache.org/dav/props/", "executable" ) ); + return doc; +} diff --git a/kioslaves/opengroupware/webdavhandler.h b/kioslaves/opengroupware/webdavhandler.h new file mode 100644 index 000000000..3c1320812 --- /dev/null +++ b/kioslaves/opengroupware/webdavhandler.h @@ -0,0 +1,44 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Cornelius Schumacher <schumacher@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. + + 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 WEBDAVHANDLER_H +#define WEBDAVHANDLER_H + +#include <qvaluelist.h> +#include <qstring.h> +#include <qdatetime.h> +#include <qdom.h> + +class WebdavHandler +{ + public: + WebdavHandler(); + + + static QDomElement addElement( QDomDocument &, QDomNode &, + const QString &tag ); + static QDomElement addDavElement( QDomDocument &, QDomNode &, + const QString &tag ); + static QDomElement addSloxElement( QDomDocument &, QDomNode &, + const QString &tag, + const QString &text = QString::null ); + static QDomDocument createAllPropsRequest(); +}; + +#endif |