summaryrefslogtreecommitdiffstats
path: root/tderesources/remote
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:50 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:50 -0600
commitb363d2579af0a11b77e698aed2e1021c2233b644 (patch)
treef4a47b87354b7a6a3b266c8121bd8ddaeb7accaa /tderesources/remote
parent61bddfe3a7226b18c68a76124b727c736f431688 (diff)
downloadtdepim-b363d2579af0a11b77e698aed2e1021c2233b644.tar.gz
tdepim-b363d2579af0a11b77e698aed2e1021c2233b644.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tderesources/remote')
-rw-r--r--tderesources/remote/CMakeLists.txt56
-rw-r--r--tderesources/remote/Makefile.am26
-rw-r--r--tderesources/remote/remote.desktop57
-rw-r--r--tderesources/remote/resourceremote.cpp352
-rw-r--r--tderesources/remote/resourceremote.h132
-rw-r--r--tderesources/remote/resourceremote_plugin.cpp41
-rw-r--r--tderesources/remote/resourceremoteconfig.cpp101
-rw-r--r--tderesources/remote/resourceremoteconfig.h69
8 files changed, 834 insertions, 0 deletions
diff --git a/tderesources/remote/CMakeLists.txt b/tderesources/remote/CMakeLists.txt
new file mode 100644
index 000000000..33b10fc39
--- /dev/null
+++ b/tderesources/remote/CMakeLists.txt
@@ -0,0 +1,56 @@
+#################################################
+#
+# (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}
+ ${CMAKE_SOURCE_DIR}/libtdepim
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### headers ###################################
+
+install( FILES
+ resourceremoteconfig.h resourceremote.h
+ DESTINATION ${INCLUDE_INSTALL_DIR}/libkcal )
+
+
+##### other data ################################
+
+install( FILES
+ remote.desktop
+ DESTINATION ${SERVICES_INSTALL_DIR}/tderesources/kcal )
+
+
+##### kcal_remote (module) ######################
+
+tde_add_kpart( kcal_remote AUTOMOC
+ SOURCES resourceremote_plugin.cpp
+ LINK kcal_resourceremote-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
+
+
+##### kcal_resourceremote (shared) ##############
+
+tde_add_library( kcal_resourceremote SHARED AUTOMOC
+ SOURCES
+ resourceremote.cpp resourceremoteconfig.cpp
+ VERSION 1.0.0
+ LINK tdepim-shared
+ DESTINATION ${LIB_INSTALL_DIR}
+)
diff --git a/tderesources/remote/Makefile.am b/tderesources/remote/Makefile.am
new file mode 100644
index 000000000..78e1cc7d8
--- /dev/null
+++ b/tderesources/remote/Makefile.am
@@ -0,0 +1,26 @@
+INCLUDES = -I$(top_srcdir) $(all_includes)
+
+lib_LTLIBRARIES = libkcal_resourceremote.la
+libkcal_resourceremote_la_LDFLAGS = $(all_libraries) -no-undefined \
+ -version-info 1:0:0
+libkcal_resourceremote_la_LIBADD = $(top_builddir)/libkcal/libkcal.la \
+ $(top_builddir)/libtdepim/libtdepim.la
+libkcal_resourceremote_la_SOURCES = resourceremote.cpp resourceremoteconfig.cpp
+
+kde_module_LTLIBRARIES = kcal_remote.la
+
+kcal_remote_la_SOURCES = resourceremote_plugin.cpp
+kcal_remote_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+kcal_remote_la_LIBADD = libkcal_resourceremote.la \
+ $(top_builddir)/libtdepim/libtdepim.la
+
+libkcalincludedir = $(includedir)/libkcal
+libkcalinclude_HEADERS = resourceremoteconfig.h resourceremote.h
+
+servicedir = $(kde_servicesdir)/tderesources/kcal
+service_DATA = remote.desktop
+
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kres_remote.pot
diff --git a/tderesources/remote/remote.desktop b/tderesources/remote/remote.desktop
new file mode 100644
index 000000000..4b003173c
--- /dev/null
+++ b/tderesources/remote/remote.desktop
@@ -0,0 +1,57 @@
+[Desktop Entry]
+Name=Calendar in Remote File
+Name[af]=Kalender in 'n afgeleë lêer
+Name[bg]=Календар в отдалечен файл
+Name[br]=Deiziadur e restr a-bell
+Name[bs]=Kalendar u udaljenoj datoteci
+Name[ca]=Calendari a un fitxer remot
+Name[cs]=Kalendář ve vzdáleném souboru
+Name[cy]=Calendr mewn Ffeil Pell
+Name[da]=Kalender i ekstern fil
+Name[de]=Kalender in Datei auf Fremdrechner
+Name[el]=Ημερολόγιο σε απομακρυσμένο αρχείο
+Name[es]=Calendario en un archivo remoto
+Name[et]=Kalender võrgufailis
+Name[eu]=Egutegia urruneko fitxategi batean
+Name[fa]=تقویم در پروندۀ دور
+Name[fi]=Kalenteri etätiedostossa
+Name[fr]=Calendrier dans un fichier distant
+Name[fy]=Aginda yn ekstern triem
+Name[ga]=Féilire i gCianchomhad
+Name[gl]=Calendario en ficheiro remoto
+Name[hi]=रिमोट फ़ाइल में कैलेन्डर
+Name[hu]=Távoli fájlban tárolt naptár
+Name[is]=Dagatal í fjarlægri skrá
+Name[it]=Calendario in file remoto
+Name[ja]=リモートファイルのカレンダー
+Name[kk]=Қашықтағы файлдағы күнтізбе
+Name[km]=ប្រតិទិន​នៅ​ក្នុង​ឯកសារ​នៅ​ឆ្ងាយ
+Name[lt]=Kalendorius nutolusioje byloje
+Name[mk]=Календар во оддалечена датотека
+Name[ms]=Kalendar dalam Fail Jauh
+Name[nb]=Kalender i fil på nettverk
+Name[nds]=Kalenner as Datei op en anner Reekner
+Name[ne]=टाढाको फाइलको क्यालेन्डर
+Name[nl]=Agenda in extern bestand
+Name[nn]=Kalender i ekstern fil
+Name[pl]=Kalendarz w pliku zdalnym
+Name[pt]=Calendário num Ficheiro Remoto
+Name[pt_BR]=Calendário em Arquivo Remoto
+Name[ro]=Calendar în fişier distant
+Name[ru]=Календарь во внешнем файле
+Name[sk]=Kalendár vo vzdialenom súbore
+Name[sl]=Koledar v oddaljeni datoteki
+Name[sr]=Календар у удаљеном фајлу
+Name[sr@Latn]=Kalendar u udaljenom fajlu
+Name[sv]=Kalender i fjärrfil
+Name[ta]=தொலைதூர கோப்பில் உள்ள நாள்காட்டி
+Name[tg]=Тақвимот дар файли хурӯҷӣ
+Name[tr]=Uzak Dosyadaki Takvim
+Name[uk]=Календар у віддаленому файлі
+Name[zh_CN]=远程文件中的日历
+Name[zh_TW]=遠端檔案的行事曆
+X-TDE-Library=kcal_remote
+Type=Service
+ServiceTypes=KResources/Plugin
+X-TDE-ResourceFamily=calendar
+X-TDE-ResourceType=remote
diff --git a/tderesources/remote/resourceremote.cpp b/tderesources/remote/resourceremote.cpp
new file mode 100644
index 000000000..ed05f8405
--- /dev/null
+++ b/tderesources/remote/resourceremote.cpp
@@ -0,0 +1,352 @@
+/*
+ This file is part of libkcal.
+
+ Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <typeinfo>
+#include <stdlib.h>
+
+#include <tqdatetime.h>
+#include <tqstring.h>
+#include <tqptrlist.h>
+
+#include <kdebug.h>
+#include <kurl.h>
+#include <kio/job.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kstandarddirs.h>
+
+#include <libkcal/icalformat.h>
+#include <libkcal/exceptions.h>
+#include <libkcal/incidence.h>
+#include <libkcal/event.h>
+#include <libkcal/todo.h>
+#include <libkcal/journal.h>
+#include <libkcal/filestorage.h>
+
+#include <kabc/lock.h>
+
+#include <tderesources/configwidget.h>
+
+#include "resourceremoteconfig.h"
+
+#include "resourceremote.h"
+
+using namespace KCal;
+
+ResourceRemote::ResourceRemote( const TDEConfig *config )
+ : ResourceCached( config ), mUseProgressManager( true ), mUseCacheFile( true )
+{
+ if ( config ) {
+ readConfig( config );
+ } else {
+ setResourceName( i18n( "Remote Calendar" ) );
+ }
+
+ init();
+}
+
+ResourceRemote::ResourceRemote( const KURL &downloadUrl, const KURL &uploadUrl )
+ : ResourceCached( 0 ), mUseProgressManager( false ), mUseCacheFile( false )
+{
+ mDownloadUrl = downloadUrl;
+
+ if ( uploadUrl.isEmpty() ) {
+ mUploadUrl = mDownloadUrl;
+ } else {
+ mUploadUrl = uploadUrl;
+ }
+
+ init();
+}
+
+ResourceRemote::~ResourceRemote()
+{
+ close();
+
+ if ( mDownloadJob ) mDownloadJob->kill();
+ if ( mUploadJob ) mUploadJob->kill();
+
+ delete mLock;
+}
+
+void ResourceRemote::init()
+{
+ mDownloadJob = 0;
+ mUploadJob = 0;
+
+ mProgress = 0;
+
+ setType( "remote" );
+
+ mLock = new KABC::Lock( cacheFile() );
+
+ enableChangeNotification();
+}
+
+void ResourceRemote::readConfig( const TDEConfig *config )
+{
+ TQString url = config->readEntry( "DownloadUrl" );
+ mDownloadUrl = KURL( url );
+
+ url = config->readEntry( "UploadUrl" );
+ mUploadUrl = KURL( url );
+
+ ResourceCached::readConfig( config );
+}
+
+void ResourceRemote::writeConfig( TDEConfig *config )
+{
+ kdDebug(5800) << "ResourceRemote::writeConfig()" << endl;
+
+ ResourceCalendar::writeConfig( config );
+
+ config->writeEntry( "DownloadUrl", mDownloadUrl.url() );
+ config->writeEntry( "UploadUrl", mUploadUrl.url() );
+
+ ResourceCached::writeConfig( config );
+}
+
+void ResourceRemote::setDownloadUrl( const KURL &url )
+{
+ mDownloadUrl = url;
+}
+
+KURL ResourceRemote::downloadUrl() const
+{
+ return mDownloadUrl;
+}
+
+void ResourceRemote::setUploadUrl( const KURL &url )
+{
+ mUploadUrl = url;
+}
+
+KURL ResourceRemote::uploadUrl() const
+{
+ return mUploadUrl;
+}
+
+void ResourceRemote::setUseProgressManager( bool useProgressManager )
+{
+ mUseProgressManager = useProgressManager;
+}
+
+bool ResourceRemote::useProgressManager() const
+{
+ return mUseProgressManager;
+}
+
+void ResourceRemote::setUseCacheFile( bool useCacheFile )
+{
+ mUseCacheFile = useCacheFile;
+}
+
+bool ResourceRemote::useCacheFile() const
+{
+ return mUseCacheFile;
+}
+
+bool ResourceRemote::doLoad()
+{
+ kdDebug(5800) << "ResourceRemote::load()" << endl;
+
+ if ( mDownloadJob ) {
+ kdWarning() << "ResourceRemote::load(): download still in progress."
+ << endl;
+ return true;
+ }
+ if ( mUploadJob ) {
+ kdWarning() << "ResourceRemote::load(): upload still in progress."
+ << endl;
+ return false;
+ }
+
+ mCalendar.close();
+
+ if ( mUseCacheFile ) {
+ disableChangeNotification();
+ loadCache();
+ enableChangeNotification();
+ }
+
+ clearChanges();
+
+ emit resourceChanged( this );
+
+ if ( mLock->lock() )
+ {
+ kdDebug() << "Download from: " << mDownloadUrl << endl;
+
+ mDownloadJob = TDEIO::file_copy( mDownloadUrl, KURL( cacheFile() ), -1, true,
+ false, !mUseProgressManager );
+ connect( mDownloadJob, TQT_SIGNAL( result( TDEIO::Job * ) ),
+ TQT_SLOT( slotLoadJobResult( TDEIO::Job * ) ) );
+ if ( mUseProgressManager ) {
+ connect( mDownloadJob, TQT_SIGNAL( percent( TDEIO::Job *, unsigned long ) ),
+ TQT_SLOT( slotPercent( TDEIO::Job *, unsigned long ) ) );
+ mProgress = KPIM::ProgressManager::createProgressItem(
+ KPIM::ProgressManager::getUniqueID(), i18n("Downloading Calendar") );
+
+ mProgress->setProgress( 0 );
+ }
+ }
+ else
+ kdDebug() << "ResourceRemote::load(): cache file is locked - something else must be loading the file" << endl;
+ return true;
+}
+
+void ResourceRemote::slotPercent( TDEIO::Job *, unsigned long percent )
+{
+ kdDebug() << "ResourceRemote::slotPercent(): " << percent << endl;
+
+ mProgress->setProgress( percent );
+}
+
+void ResourceRemote::slotLoadJobResult( TDEIO::Job *job )
+{
+ if ( job->error() ) {
+ // TODO: Should detect 404, 401 etc. vs host not found and prompt to create new resource only when 404 is returned
+ TQString warningString = TQString("<b>") + i18n("Remote data access failure") + TQString("</b><p>") + i18n("Detailed information") \
+ + TQString(":<br>") + job->errorString() + TQString("<p>") + i18n("What would you like to do?");
+ int rc = KMessageBox::warningContinueCancel(0,
+ warningString, i18n("Remote Data Access Failure"), i18n("&Continue with cached resource"));
+ if ( rc == KMessageBox::Continue ) {
+ mCalendar.close();
+ disableChangeNotification();
+ loadCache();
+ enableChangeNotification();
+
+ emit resourceChanged( this );
+ }
+ //job->showErrorDialog( 0 );
+ } else {
+ kdDebug(5800) << "ResourceRemote::slotLoadJobResult() success" << endl;
+
+ mCalendar.close();
+ disableChangeNotification();
+ loadCache();
+ enableChangeNotification();
+
+ emit resourceChanged( this );
+ }
+
+ mDownloadJob = 0;
+ if ( mProgress ) {
+ mProgress->setComplete();
+ mProgress = 0;
+ }
+
+ mLock->unlock();
+ emit resourceLoaded( this );
+}
+
+bool ResourceRemote::doSave()
+{
+ kdDebug(5800) << "ResourceRemote::save()" << endl;
+
+ if ( readOnly() || !hasChanges() ) {
+ emit resourceSaved( this );
+ return true;
+ }
+
+ if ( mDownloadJob ) {
+ kdWarning() << "ResourceRemote::save(): download still in progress."
+ << endl;
+ return false;
+ }
+ if ( mUploadJob ) {
+ kdWarning() << "ResourceRemote::save(): upload still in progress."
+ << endl;
+ return false;
+ }
+
+ mChangedIncidences = allChanges();
+
+ saveCache();
+
+ mUploadJob = TDEIO::file_copy( KURL( cacheFile() ), mUploadUrl, -1, true );
+ connect( mUploadJob, TQT_SIGNAL( result( TDEIO::Job * ) ),
+ TQT_SLOT( slotSaveJobResult( TDEIO::Job * ) ) );
+
+ return true;
+}
+
+bool ResourceRemote::isSaving()
+{
+ return mUploadJob;
+}
+
+void ResourceRemote::slotSaveJobResult( TDEIO::Job *job )
+{
+ if ( job->error() ) {
+ job->showErrorDialog( 0 );
+ } else {
+ kdDebug(5800) << "ResourceRemote::slotSaveJobResult() success" << endl;
+
+ Incidence::List::ConstIterator it;
+ for( it = mChangedIncidences.begin(); it != mChangedIncidences.end();
+ ++it ) {
+ clearChange( *it );
+ }
+ mChangedIncidences.clear();
+ }
+
+ mUploadJob = 0;
+
+ emit resourceSaved( this );
+}
+
+KABC::Lock *ResourceRemote::lock()
+{
+ return mLock;
+}
+
+void ResourceRemote::dump() const
+{
+ ResourceCalendar::dump();
+ kdDebug(5800) << " DownloadUrl: " << mDownloadUrl.url() << endl;
+ kdDebug(5800) << " UploadUrl: " << mUploadUrl.url() << endl;
+ kdDebug(5800) << " ReloadPolicy: " << reloadPolicy() << endl;
+}
+
+void ResourceRemote::addInfoText( TQString &txt ) const
+{
+ txt += "<br>";
+ txt += i18n("URL: %1").arg( mDownloadUrl.prettyURL() );
+}
+
+bool ResourceRemote::setValue( const TQString &key, const TQString &value )
+{
+ if ( key == "URL" ) {
+ setUploadUrl( KURL( value ) );
+ setDownloadUrl( KURL( value ) );
+ return true;
+ } else if ( key == "DownloadURL" ) {
+ setDownloadUrl( KURL( value ) );
+ return true;
+ } else if ( key == "UploadURL" ) {
+ setUploadUrl( KURL( value ) );
+ return true;
+ } else
+ return ResourceCached::setValue( key, value );
+}
+
+#include "resourceremote.moc"
diff --git a/tderesources/remote/resourceremote.h b/tderesources/remote/resourceremote.h
new file mode 100644
index 000000000..2c3fd5fad
--- /dev/null
+++ b/tderesources/remote/resourceremote.h
@@ -0,0 +1,132 @@
+ /*
+ This file is part of libkcal.
+
+ Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef KCAL_RESOURCEREMOTEDIR_H
+#define KCAL_RESOURCEREMOTEDIR_H
+
+#include <tqptrlist.h>
+#include <tqstring.h>
+#include <tqdatetime.h>
+
+#include <kurl.h>
+#include <kconfig.h>
+#include <kdirwatch.h>
+#include <tdepimmacros.h>
+
+#include <libtdepim/progressmanager.h>
+
+#include <libkcal/incidence.h>
+#include <libkcal/calendarlocal.h>
+#include <libkcal/icalformat.h>
+
+#include <libkcal/resourcecached.h>
+
+namespace TDEIO {
+class FileCopyJob;
+class Job;
+}
+
+namespace KCal {
+
+/**
+ This class provides a calendar stored as a remote file.
+*/
+class KDE_EXPORT ResourceRemote : public ResourceCached
+{
+ Q_OBJECT
+
+
+ friend class ResourceRemoteConfig;
+
+ public:
+ /**
+ Create resource from configuration information stored in TDEConfig object.
+ */
+ ResourceRemote( const TDEConfig * );
+ /**
+ Create remote resource.
+
+ @param downloadUrl URL used to download iCalendar file
+ @param uploadUrl URL used to upload iCalendar file
+ */
+ ResourceRemote( const KURL &downloadUrl, const KURL &uploadUrl = KURL() );
+ virtual ~ResourceRemote();
+
+ void readConfig( const TDEConfig *config );
+ void writeConfig( TDEConfig *config );
+
+ void setDownloadUrl( const KURL & );
+ KURL downloadUrl() const;
+
+ void setUploadUrl( const KURL & );
+ KURL uploadUrl() const;
+
+ void setUseProgressManager( bool useProgressManager );
+ bool useProgressManager() const;
+
+ void setUseCacheFile( bool useCacheFile );
+ bool useCacheFile() const;
+
+ KABC::Lock *lock();
+
+ bool isSaving();
+
+ void dump() const;
+
+ bool setValue( const TQString &key, const TQString &value );
+
+
+ protected slots:
+ void slotLoadJobResult( TDEIO::Job * );
+ void slotSaveJobResult( TDEIO::Job * );
+
+ void slotPercent( TDEIO::Job *, unsigned long percent );
+
+ protected:
+ bool doLoad();
+ bool doSave();
+
+ void addInfoText( TQString & ) const;
+
+ private:
+ void init();
+
+ KURL mDownloadUrl;
+ KURL mUploadUrl;
+
+ bool mUseProgressManager;
+ bool mUseCacheFile;
+
+ TDEIO::FileCopyJob *mDownloadJob;
+ TDEIO::FileCopyJob *mUploadJob;
+
+ KPIM::ProgressItem *mProgress;
+
+ Incidence::List mChangedIncidences;
+
+ KABC::Lock *mLock;
+
+ class Private;
+ Private *d;
+};
+
+}
+
+#endif
diff --git a/tderesources/remote/resourceremote_plugin.cpp b/tderesources/remote/resourceremote_plugin.cpp
new file mode 100644
index 000000000..67eaa92fe
--- /dev/null
+++ b/tderesources/remote/resourceremote_plugin.cpp
@@ -0,0 +1,41 @@
+/*
+ This file is part of libkcal.
+
+ Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "resourceremoteconfig.h"
+#include "resourceremote.h"
+
+#include <kglobal.h>
+#include <klocale.h>
+
+using namespace KCal;
+
+typedef KRES::PluginFactory<ResourceRemote,ResourceRemoteConfig> RemoteFactory;
+// FIXME: Use K_EXPORT_COMPONENT_FACTORY( kcal_remote, RemoteFactory ); here
+// Problem: How do I insert the catalogue???
+extern "C"
+{
+ void *init_kcal_remote()
+ {
+ TDEGlobal::locale()->insertCatalogue( "libkcal" );
+ TDEGlobal::locale()->insertCatalogue( "kres_remote" );
+ return new RemoteFactory;
+ }
+}
diff --git a/tderesources/remote/resourceremoteconfig.cpp b/tderesources/remote/resourceremoteconfig.cpp
new file mode 100644
index 000000000..67d7f4b94
--- /dev/null
+++ b/tderesources/remote/resourceremoteconfig.cpp
@@ -0,0 +1,101 @@
+/*
+ This file is part of libkcal.
+
+ Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <typeinfo>
+
+#include <tqlabel.h>
+#include <tqlayout.h>
+
+#include <klocale.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <kstandarddirs.h>
+#include <kdialog.h>
+
+#include <libkcal/resourcecachedconfig.h>
+
+#include "resourceremote.h"
+
+#include "resourceremoteconfig.h"
+
+using namespace KCal;
+
+ResourceRemoteConfig::ResourceRemoteConfig( TQWidget* parent, const char* name )
+ : KRES::ConfigWidget( parent, name )
+{
+ resize( 245, 115 );
+ TQGridLayout *mainLayout = new TQGridLayout( this, 2, 2 );
+ mainLayout->setSpacing( KDialog::spacingHint() );
+
+ TQLabel *label = new TQLabel( i18n( "Download from:" ), this );
+
+ mDownloadUrl = new KURLRequester( this );
+ mDownloadUrl->setMode( KFile::File );
+ mainLayout->addWidget( label, 1, 0 );
+ mainLayout->addWidget( mDownloadUrl, 1, 1 );
+
+ label = new TQLabel( i18n( "Upload to:" ), this );
+ mUploadUrl = new KURLRequester( this );
+ mUploadUrl->setMode( KFile::File );
+ mainLayout->addWidget( label, 2, 0 );
+ mainLayout->addWidget( mUploadUrl, 2, 1 );
+
+ mReloadConfig = new ResourceCachedReloadConfig( this );
+ mainLayout->addMultiCellWidget( mReloadConfig, 3, 3, 0, 1 );
+
+ mSaveConfig = new ResourceCachedSaveConfig( this );
+ mainLayout->addMultiCellWidget( mSaveConfig, 4, 4, 0, 1 );
+}
+
+void ResourceRemoteConfig::loadSettings( KRES::Resource *resource )
+{
+ ResourceRemote *res = static_cast<ResourceRemote *>( resource );
+ if ( res ) {
+ mDownloadUrl->setURL( res->downloadUrl().url() );
+ mUploadUrl->setURL( res->uploadUrl().url() );
+ mReloadConfig->loadSettings( res );
+ mSaveConfig->loadSettings( res );
+ } else {
+ kdError(5700) << "ResourceRemoteConfig::loadSettings(): no ResourceRemote, cast failed" << endl;
+ }
+}
+
+void ResourceRemoteConfig::saveSettings( KRES::Resource *resource )
+{
+ ResourceRemote* res = static_cast<ResourceRemote*>( resource );
+ if ( res ) {
+ res->setDownloadUrl( KURL( mDownloadUrl->url() ) );
+ res->setUploadUrl( KURL( mUploadUrl->url() ) );
+ mReloadConfig->saveSettings( res );
+ mSaveConfig->saveSettings( res );
+
+
+ if ( mUploadUrl->url().isEmpty() && !resource->readOnly() ) {
+ KMessageBox::information( this, i18n( "You have specified no upload URL, "
+ "the calendar will be read-only." ), "RemoteResourseNoUploadURL" );
+ resource->setReadOnly( true );
+ }
+ } else {
+ kdError(5700) << "ResourceRemoteConfig::saveSettings(): no ResourceRemote, cast failed" << endl;
+ }
+}
+
+#include "resourceremoteconfig.moc"
diff --git a/tderesources/remote/resourceremoteconfig.h b/tderesources/remote/resourceremoteconfig.h
new file mode 100644
index 000000000..a05171eed
--- /dev/null
+++ b/tderesources/remote/resourceremoteconfig.h
@@ -0,0 +1,69 @@
+/*
+ This file is part of libkcal.
+
+ Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
+ Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
+ Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef KCAL_RESOURCEREMOTECONFIG_H
+#define KCAL_RESOURCEREMOTECONFIG_H
+
+#include <tqradiobutton.h>
+#include <tqbuttongroup.h>
+#include <kurlrequester.h>
+
+#include <tderesources/resource.h>
+#include <tderesources/configwidget.h>
+
+#include <tdepimmacros.h>
+
+namespace KCal {
+
+class ResourceCachedReloadConfig;
+class ResourceCachedSaveConfig;
+
+/**
+ Configuration widget for remote resource.
+
+ @see ResourceRemote
+*/
+class KDE_EXPORT ResourceRemoteConfig : public KRES::ConfigWidget
+{
+ Q_OBJECT
+
+ public:
+ ResourceRemoteConfig( TQWidget *parent = 0, const char *name = 0 );
+
+ public slots:
+ virtual void loadSettings( KRES::Resource *resource );
+ virtual void saveSettings( KRES::Resource *resource );
+
+ private:
+ KURLRequester *mDownloadUrl;
+ KURLRequester *mUploadUrl;
+
+ ResourceCachedReloadConfig *mReloadConfig;
+ ResourceCachedSaveConfig *mSaveConfig;
+
+ class Private;
+ Private *d;
+};
+
+}
+
+#endif