diff options
author | Darrell Anderson <humanreadable@yahoo.com> | 2014-02-06 17:54:49 -0600 |
---|---|---|
committer | Darrell Anderson <humanreadable@yahoo.com> | 2014-02-06 17:54:49 -0600 |
commit | ca705978d11b2e0bdcaf8186b0addff48d851483 (patch) | |
tree | da2d37c0fc29b1746cc24594e948bc7c9f1241eb /tdeioslave/opengroupware | |
parent | eaa1b143397fadcb31d69944ed69d6cf215be77d (diff) | |
download | tdepim-ca705978d11b2e0bdcaf8186b0addff48d851483.tar.gz tdepim-ca705978d11b2e0bdcaf8186b0addff48d851483.zip |
Reorganize tdeioslave help handbooks, fix related protocol files and issues, update and add handbooks.
Diffstat (limited to 'tdeioslave/opengroupware')
-rw-r--r-- | tdeioslave/opengroupware/Makefile.am | 17 | ||||
-rw-r--r-- | tdeioslave/opengroupware/opengroupware.cpp | 250 | ||||
-rw-r--r-- | tdeioslave/opengroupware/opengroupware.h | 57 | ||||
-rw-r--r-- | tdeioslave/opengroupware/opengroupware.protocol | 8 | ||||
-rw-r--r-- | tdeioslave/opengroupware/opengroupwares.protocol | 8 | ||||
-rw-r--r-- | tdeioslave/opengroupware/webdavhandler.cpp | 81 | ||||
-rw-r--r-- | tdeioslave/opengroupware/webdavhandler.h | 44 |
7 files changed, 465 insertions, 0 deletions
diff --git a/tdeioslave/opengroupware/Makefile.am b/tdeioslave/opengroupware/Makefile.am new file mode 100644 index 000000000..fbe8cee15 --- /dev/null +++ b/tdeioslave/opengroupware/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/tderesources/opengroupware/soap \ + $(all_includes) + +noinst_HEADERS = opengroupware.h + +METASOURCES = AUTO + +kdelnkdir = $(kde_servicesdir) +kdelnk_DATA = opengroupware.protocol opengroupwares.protocol + +kde_module_LTLIBRARIES = tdeio_opengroupware.la + +tdeio_opengroupware_la_SOURCES = opengroupware.cpp webdavhandler.cpp +tdeio_opengroupware_la_LIBADD = $(top_builddir)/libkcal/libkcal.la \ + $(top_builddir)/libtdepim/libtdepim.la $(LIB_TDEIO) +tdeio_opengroupware_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + diff --git a/tdeioslave/opengroupware/opengroupware.cpp b/tdeioslave/opengroupware/opengroupware.cpp new file mode 100644 index 000000000..304ff225f --- /dev/null +++ b/tdeioslave/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 <tdeio/job.h> +#include <tdeio/davjob.h> +#include <tdelocale.h> + +#include <libtdepim/tdeabcresourcecached.h> + +#include <libkcal/freebusy.h> +#include <libkcal/icalformat.h> +#include <libkcal/scheduler.h> +#include <libkcal/calendarlocal.h> + +#include <tdeabc/vcardconverter.h> + +#include <kinstance.h> +#include <kdebug.h> +#include <tdelocale.h> +#include <tdetempfile.h> + +#include <sys/types.h> +#include <unistd.h> +#include <stdlib.h> + +#include <tdepimmacros.h> + +namespace TDEABC { + +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 ) +{ + TDEInstance instance( "tdeio_OpenGroupware" ); + + kdDebug(7000) << "Starting tdeio_OpenGroupware(pid: " << getpid() << ")" << endl; + + if (argc != 4) { + fprintf( stderr, "Usage: tdeio_OpenGroupware protocol domain-socket1 domain-socket2\n"); + exit( -1 ); + } + + OpenGroupware slave( argv[1], argv[2], argv[3] ); + slave.dispatchLoop(); + + return 0; +} + +OpenGroupware::OpenGroupware( const TQCString &protocol, const TQCString &pool, + const TQCString &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" ); + + TQString 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 { + TQString 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 ) +{ + TQString file = url.filename(); + if ( file.right( 4 ) != ".ifb" ) { + TQString error = i18n("Illegal filename. File has to have '.ifb' suffix."); + errorMessage( error ); + } else { + TQString email = file.left( file.length() - 4 ); + debugMessage( "Email: " + email ); + + TQString user = url.user(); + TQString 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. + TQDate start = TQDate::currentDate().addDays( -3 ); + TQDate end = TQDate::currentDate().addDays( 60 ); + + fb->setDtStart( start ); + fb->setDtEnd( end ); + + kdDebug() << "Login" << endl; + + } + +#if 0 + TQDateTime s = TQDateTime( TQDate( 2004, 9, 27 ), TQTime( 10, 0 ) ); + TQDateTime e = TQDateTime( TQDate( 2004, 9, 27 ), TQTime( 11, 0 ) ); + + fb->addPeriod( s, e ); +#endif + + KCal::ICalFormat format; + + TQString 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 + TQString user = url.user(); + TQString pass = url.pass(); + + TQDomDocument 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 = TDEIO::davPropFind( url, props, "0", false ); + connect( mListEventsJob, TQT_SIGNAL( result( TDEIO::Job * ) ), + TQT_SLOT( slotGetCalendarListingResult( TDEIO::Job * ) ) ); +} + +void OpenGroupware::getAddressbook( const KURL &url ) +{ + +} + +void OpenGroupware::errorMessage( const TQString &msg ) +{ + error( TDEIO::ERR_SLAVE_DEFINED, msg ); +} + +void OpenGroupware::debugMessage( const TQString &msg ) +{ +#if 0 + data( ( msg + "\n" ).utf8() ); +#else + Q_UNUSED( msg ); +#endif +} + + +void OpenGroupware::slotGetCalendarListingResult( TDEIO::Job *job ) +{ + + kdDebug(7000) << k_funcinfo << endl; + + if ( job->error() ) { + job->showErrorDialog( 0 ); + } else { + kdDebug() << "ResourceSlox::slotResult() success" << endl; + + TQDomDocument doc = mListEventsJob->response(); + + } + KCal::ICalFormat format; + KCal::CalendarLocal calendar; + + TQString ical = format.toString( &calendar ); + + data( ical.utf8() ); + + finished(); +} + + +void OpenGroupware::slotGetCalendarResult( TDEIO::Job *job ) +{ + Q_UNUSED( job ); +} +#include "opengroupware.moc" + diff --git a/tdeioslave/opengroupware/opengroupware.h b/tdeioslave/opengroupware/opengroupware.h new file mode 100644 index 000000000..151187dbe --- /dev/null +++ b/tdeioslave/opengroupware/opengroupware.h @@ -0,0 +1,57 @@ +/* + 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 <tdeio/slavebase.h> + +#include <tqobject.h> + +namespace TDEIO { + class Job; + class DavJob; +} + + +class OpenGroupware : public TQObject, public TDEIO::SlaveBase +{ + Q_OBJECT + + public: + OpenGroupware( const TQCString &protocol, const TQCString &pool, + const TQCString &app ); + + void get( const KURL &url ); + + protected: + void debugMessage( const TQString & ); + void errorMessage( const TQString & ); + + void getFreeBusy( const KURL &url ); + void getCalendar( const KURL &url ); + void getAddressbook( const KURL &url ); + protected slots: + void slotGetCalendarListingResult( TDEIO::Job* ); + void slotGetCalendarResult( TDEIO::Job* ); + private: + TDEIO::DavJob *mListEventsJob; +}; + +#endif diff --git a/tdeioslave/opengroupware/opengroupware.protocol b/tdeioslave/opengroupware/opengroupware.protocol new file mode 100644 index 000000000..5531f3106 --- /dev/null +++ b/tdeioslave/opengroupware/opengroupware.protocol @@ -0,0 +1,8 @@ +[Protocol] +DocPath=tdeioslave/opengroupware/index.html +exec=tdeio_opengroupware +input=none +output=filesystem +protocol=opengroupware +reading=true +Icon=kontact diff --git a/tdeioslave/opengroupware/opengroupwares.protocol b/tdeioslave/opengroupware/opengroupwares.protocol new file mode 100644 index 000000000..03bb4b1db --- /dev/null +++ b/tdeioslave/opengroupware/opengroupwares.protocol @@ -0,0 +1,8 @@ +[Protocol] +DocPath=tdeioslave/opengroupware/index.html +exec=tdeio_opengroupware +input=none +output=filesystem +protocol=opengroupwares +reading=true +Icon=kontact diff --git a/tdeioslave/opengroupware/webdavhandler.cpp b/tdeioslave/opengroupware/webdavhandler.cpp new file mode 100644 index 000000000..9c89174ae --- /dev/null +++ b/tdeioslave/opengroupware/webdavhandler.cpp @@ -0,0 +1,81 @@ +/* + This file is part of tdepim. + + 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 <libtdepim/kpimprefs.h> + +#include <kdebug.h> +#include <tdeconfig.h> + +#include <tqfile.h> + + +WebdavHandler::WebdavHandler() +{ +} + + +TQDomElement WebdavHandler::addElement( TQDomDocument &doc, TQDomNode &node, + const TQString &tag ) +{ + TQDomElement el = doc.createElement( tag ); + node.appendChild( el ); + return el; +} + +TQDomElement WebdavHandler::addDavElement( TQDomDocument &doc, TQDomNode &node, + const TQString &tag ) +{ + TQDomElement el = doc.createElementNS( "DAV", tag ); + node.appendChild( el ); + return el; +} + +TQDomElement WebdavHandler::addSloxElement( TQDomDocument &doc, TQDomNode &node, + const TQString &tag, + const TQString &text ) +{ + TQDomElement el = doc.createElementNS( "SLOX", tag ); + if ( !text.isEmpty() ) { + TQDomText textnode = doc.createTextNode( text ); + el.appendChild( textnode ); + } + node.appendChild( el ); + return el; +} + +TQDomDocument WebdavHandler::createAllPropsRequest() +{ + TQDomDocument doc; + + TQDomElement root = WebdavHandler::addDavElement( doc, doc, "propfind" ); + TQDomElement 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/tdeioslave/opengroupware/webdavhandler.h b/tdeioslave/opengroupware/webdavhandler.h new file mode 100644 index 000000000..a86332a32 --- /dev/null +++ b/tdeioslave/opengroupware/webdavhandler.h @@ -0,0 +1,44 @@ +/* + This file is part of tdepim. + + 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 <tqvaluelist.h> +#include <tqstring.h> +#include <tqdatetime.h> +#include <tqdom.h> + +class WebdavHandler +{ + public: + WebdavHandler(); + + + static TQDomElement addElement( TQDomDocument &, TQDomNode &, + const TQString &tag ); + static TQDomElement addDavElement( TQDomDocument &, TQDomNode &, + const TQString &tag ); + static TQDomElement addSloxElement( TQDomDocument &, TQDomNode &, + const TQString &tag, + const TQString &text = TQString() ); + static TQDomDocument createAllPropsRequest(); +}; + +#endif |