From 10251f9a2a51f37c2a42833c1d05cd5a8fdf6bb5 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 17 Feb 2013 02:06:43 -0600 Subject: Fix FTBFS --- tderesources/lib/kabc_resourcegroupwarebase.cpp | 262 --------------------- tderesources/lib/kabc_resourcegroupwarebase.h | 99 -------- .../lib/kabc_resourcegroupwarebaseconfig.cpp | 117 --------- .../lib/kabc_resourcegroupwarebaseconfig.h | 65 ----- tderesources/lib/tdeabc_resourcegroupwarebase.cpp | 262 +++++++++++++++++++++ tderesources/lib/tdeabc_resourcegroupwarebase.h | 99 ++++++++ .../lib/tdeabc_resourcegroupwarebaseconfig.cpp | 117 +++++++++ .../lib/tdeabc_resourcegroupwarebaseconfig.h | 65 +++++ 8 files changed, 543 insertions(+), 543 deletions(-) delete mode 100644 tderesources/lib/kabc_resourcegroupwarebase.cpp delete mode 100644 tderesources/lib/kabc_resourcegroupwarebase.h delete mode 100644 tderesources/lib/kabc_resourcegroupwarebaseconfig.cpp delete mode 100644 tderesources/lib/kabc_resourcegroupwarebaseconfig.h create mode 100644 tderesources/lib/tdeabc_resourcegroupwarebase.cpp create mode 100644 tderesources/lib/tdeabc_resourcegroupwarebase.h create mode 100644 tderesources/lib/tdeabc_resourcegroupwarebaseconfig.cpp create mode 100644 tderesources/lib/tdeabc_resourcegroupwarebaseconfig.h (limited to 'tderesources/lib') diff --git a/tderesources/lib/kabc_resourcegroupwarebase.cpp b/tderesources/lib/kabc_resourcegroupwarebase.cpp deleted file mode 100644 index 3ebd175eb..000000000 --- a/tderesources/lib/kabc_resourcegroupwarebase.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - Copyright (c) 2004 Till Adam - Copyright (C) 2005 Reinhold Kainhofer - - 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 "kabc_resourcegroupwarebase.h" -#include "tderesources_groupwareprefs.h" - -#include "folderlister.h" -#include "addressbookadaptor.h" -#include "groupwaredownloadjob.h" -#include "groupwareuploadjob.h" - -#include -#include -#include - -using namespace KABC; - -ResourceGroupwareBase::ResourceGroupwareBase( const TDEConfig *config ) - : ResourceCached( config ), - mPrefs(0), mFolderLister(0), mAdaptor(0), mDownloadJob(0), mUploadJob(0) -{ - if ( config ) readConfig( config ); -} - -ResourceGroupwareBase::~ResourceGroupwareBase() -{ - delete mPrefs; - mPrefs = 0; -} - -KPIM::GroupwareDownloadJob *ResourceGroupwareBase::createDownloadJob( - AddressBookAdaptor *adaptor ) -{ - return new KPIM::GroupwareDownloadJob( adaptor ); -} - -KPIM::GroupwareUploadJob *ResourceGroupwareBase::createUploadJob( - AddressBookAdaptor *adaptor ) -{ - return new KPIM::GroupwareUploadJob( adaptor ); -} - -void ResourceGroupwareBase::setPrefs( KPIM::GroupwarePrefsBase *newprefs ) -{ - if ( !newprefs ) return; - if ( mPrefs ) delete mPrefs; - mPrefs = newprefs; - mPrefs->addGroupPrefix( identifier() ); - - mPrefs->readConfig(); - if ( mFolderLister ) mFolderLister->readConfig( mPrefs ); -} - -void ResourceGroupwareBase::setFolderLister( KPIM::FolderLister *folderLister ) -{ - if ( !folderLister ) return; - if ( mFolderLister ) delete mFolderLister; - mFolderLister = folderLister; - if ( mPrefs ) mFolderLister->readConfig( mPrefs ); - if ( mAdaptor ) { - mAdaptor->setFolderLister( mFolderLister ); - mFolderLister->setAdaptor( mAdaptor ); - } -} - -void ResourceGroupwareBase::setAdaptor( AddressBookAdaptor *adaptor ) -{ - if ( !adaptor ) return; - if ( mAdaptor ) delete mAdaptor; - mAdaptor = adaptor; - mAdaptor->setFolderLister( mFolderLister ); - if ( mFolderLister ) mFolderLister->setAdaptor( mAdaptor ); - mAdaptor->setDownloadProgressMessage( i18n("Downloading addressbook") ); - mAdaptor->setUploadProgressMessage( i18n("Uploading addressbook") ); - if ( prefs() ) { - mAdaptor->setBaseURL( prefs()->url() ); - mAdaptor->setUser( prefs()->user() ); - mAdaptor->setPassword( prefs()->password() ); - } - mAdaptor->setIdMapper( &idMapper() ); - mAdaptor->setResource( this ); -} - -void ResourceGroupwareBase::init() -{ - mDownloadJob = 0; -} - -KPIM::GroupwarePrefsBase *ResourceGroupwareBase::createPrefs() -{ - return new KPIM::GroupwarePrefsBase(); -} - - - -void ResourceGroupwareBase::readConfig( const TDEConfig */*config*/ ) -{ - kdDebug(5700) << "KABC::ResourceGroupwareBase::readConfig()" << endl; -// ResourceCached::readConfig( config ); - if ( mPrefs ) { - mPrefs->readConfig(); - if ( mFolderLister ) - mFolderLister->readConfig( mPrefs ); - } -} - -void ResourceGroupwareBase::writeConfig( TDEConfig *config ) -{ - Resource::writeConfig( config ); - - if ( mPrefs ) { - if ( mFolderLister ) - mFolderLister->writeConfig( mPrefs ); - mPrefs->writeConfig(); - } -} - -Ticket *ResourceGroupwareBase::requestSaveTicket() -{ - if ( !addressBook() ) { - kdDebug(5700) << "no addressbook" << endl; - return 0; - } - - return createTicket( this ); -} - -void ResourceGroupwareBase::releaseSaveTicket( Ticket *ticket ) -{ - delete ticket; -} - -bool ResourceGroupwareBase::doOpen() -{ - return true; -} - -void ResourceGroupwareBase::doClose() -{ - kdDebug(5800) << "ResourceGroupwareBase::doClose()" << endl; - - if ( mDownloadJob ) mDownloadJob->kill(); -} - -bool ResourceGroupwareBase::load() -{ - return asyncLoad(); -} - -bool ResourceGroupwareBase::asyncLoad() -{ - if ( mDownloadJob ) { - kdWarning() << "Download still in progress" << endl; - return false; - } - - mAddrMap.clear(); - loadCache(); - - mDownloadJob = createDownloadJob( mAdaptor ); - connect( mDownloadJob, TQT_SIGNAL( result( KPIM::GroupwareJob * ) ), - TQT_SLOT( slotDownloadJobResult( KPIM::GroupwareJob * ) ) ); - - return true; -} - -void ResourceGroupwareBase::slotDownloadJobResult( KPIM::GroupwareJob *job ) -{ - kdDebug(5800) << "ResourceGroupwareBase::slotJobResult(): " << endl; - - if ( job->error() ) { - kdError() << "job failed: " << job->errorString() << endl; - } else { - emit loadingFinished( this ); - if ( addressBook() ) - addressBook()->emitAddressBookChanged(); - } - - mDownloadJob = 0; -} - -bool ResourceGroupwareBase::save( Ticket *ticket ) -{ - return asyncSave( ticket ); -} - -bool ResourceGroupwareBase::asyncSave( Ticket* ) -{ - if ( mUploadJob ) { - // FIXME: If the user cancels, need to reset the mUploadJob variable to 0. - kdWarning() << "Upload still in progress." << endl; - return false; - } - - mUploadJob = createUploadJob( mAdaptor ); - connect( mUploadJob, TQT_SIGNAL( result( KPIM::GroupwareJob * ) ), - TQT_SLOT( slotUploadJobResult( KPIM::GroupwareJob * ) ) ); - - KABC::Addressee::List addr; - KABC::Addressee::List::Iterator it; - KPIM::GroupwareUploadItem::List addedItems, changedItems, deletedItems; - - addr = addedAddressees(); - for( it = addr.begin(); it != addr.end(); ++it ) { - addedItems.append( adaptor()->newUploadItem( *it, - KPIM::GroupwareUploadItem::Added ) ); - } - // TODO: Check if the item has changed on the server... - // In particular, check if the version we based our change on is still current - // on the server - addr = changedAddressees(); - for( it = addr.begin(); it != addr.end(); ++it ) { - changedItems.append( adaptor()->newUploadItem( *it, - KPIM::GroupwareUploadItem::Changed ) ); - } - addr = deletedAddressees(); - for( it = addr.begin(); it != addr.end(); ++it ) { - deletedItems.append( adaptor()->newUploadItem( *it, - KPIM::GroupwareUploadItem::Deleted ) ); - } - - mUploadJob->setAddedItems( addedItems ); - mUploadJob->setChangedItems( changedItems ); - mUploadJob->setDeletedItems( deletedItems ); - - return true; -} - -void ResourceGroupwareBase::slotUploadJobResult( KPIM::GroupwareJob *job ) -{ - kdDebug(5800) << "ResourceGroupwareBase::slotJobResult(): " << endl; - - if ( job->error() ) { - kdError() << "job failed: " << job->errorString() << endl; - } else { - // FIXME - } - - mUploadJob = 0; -} - - -#include "kabc_resourcegroupwarebase.moc" diff --git a/tderesources/lib/kabc_resourcegroupwarebase.h b/tderesources/lib/kabc_resourcegroupwarebase.h deleted file mode 100644 index 28ce5199e..000000000 --- a/tderesources/lib/kabc_resourcegroupwarebase.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - Copyright (c) 2004 Till Adam - Copyright (C) 2005 Reinhold Kainhofer - - 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 KABC_RESOURCEGROUPWARE_H -#define KABC_RESOURCEGROUPWARE_H - -#include -#include -#include - -class TDEConfig; - -namespace KPIM { -class GroupwareJob; -class GroupwareDownloadJob; -class GroupwareUploadJob; -class FolderLister; -class GroupwarePrefsBase; -} - -namespace KABC { - -class AddressBookAdaptor; - -class KDE_EXPORT ResourceGroupwareBase : public ResourceCached -{ - Q_OBJECT - - - public: - ResourceGroupwareBase( const TDEConfig * ); - ~ResourceGroupwareBase(); - - void readConfig( const TDEConfig * ); - void writeConfig( TDEConfig * ); - - KPIM::GroupwarePrefsBase *prefs() const { return mPrefs; } - void setPrefs( KPIM::GroupwarePrefsBase *prefs ); - - KPIM::FolderLister *folderLister() const { return mFolderLister; } - void setFolderLister( KPIM::FolderLister *folderLister ); - - AddressBookAdaptor *adaptor() const { return mAdaptor; } - void setAdaptor( AddressBookAdaptor *adaptor ); - - bool doOpen(); - void doClose(); - - Ticket *requestSaveTicket(); - void releaseSaveTicket( Ticket* ); - - bool load(); - bool asyncLoad(); - bool save( Ticket * ); - bool asyncSave( Ticket * ); - - protected: - void init(); - - KPIM::GroupwarePrefsBase *createPrefs(); - virtual KPIM::GroupwareDownloadJob *createDownloadJob( - AddressBookAdaptor *adaptor ); - virtual KPIM::GroupwareUploadJob *createUploadJob( - AddressBookAdaptor *adaptor ); - - private slots: - void slotDownloadJobResult( KPIM::GroupwareJob * ); - void slotUploadJobResult( KPIM::GroupwareJob * ); - - private: - KPIM::GroupwarePrefsBase *mPrefs; - KPIM::FolderLister *mFolderLister; - AddressBookAdaptor *mAdaptor; - - KPIM::GroupwareDownloadJob *mDownloadJob; - KPIM::GroupwareUploadJob *mUploadJob; -}; - -} - -#endif diff --git a/tderesources/lib/kabc_resourcegroupwarebaseconfig.cpp b/tderesources/lib/kabc_resourcegroupwarebaseconfig.cpp deleted file mode 100644 index 918dfc52b..000000000 --- a/tderesources/lib/kabc_resourcegroupwarebaseconfig.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - Copyright (c) 2004 Till Adam - Copyright (c) 2005 Reinhold Kainhofer - - 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 "kabc_resourcegroupwarebaseconfig.h" - -#include "kabc_resourcegroupwarebase.h" -#include "tderesources_groupwareprefs.h" -#include "folderconfig.h" - -#include -#include -#include -#include -#include - -#include -#include - -using namespace KABC; - -ResourceGroupwareBaseConfig::ResourceGroupwareBaseConfig( TQWidget* parent, const char* name ) - : KRES::ConfigWidget( parent, name ) -{ - TQGridLayout *mainLayout = new TQGridLayout( this, 7, 2, 0, KDialog::spacingHint() ); - - TQLabel *label = new TQLabel( i18n( "URL:" ), this ); - mURL = new KURLRequester( this ); - - mainLayout->addWidget( label, 0, 0 ); - mainLayout->addWidget( mURL, 0, 1 ); - - label = new TQLabel( i18n( "User:" ), this ); - mUser = new KLineEdit( this ); - - mainLayout->addWidget( label, 1, 0 ); - mainLayout->addWidget( mUser, 1, 1 ); - - label = new TQLabel( i18n( "Password:" ), this ); - mPassword = new KLineEdit( this ); - mPassword->setEchoMode( TQLineEdit::Password ); - - mainLayout->addWidget( label, 2, 0 ); - mainLayout->addWidget( mPassword, 2, 1 ); - - TQFrame *hline = new TQFrame( this ); - hline->setFrameStyle( TQFrame::HLine | TQFrame::Sunken ); - - mainLayout->addMultiCellWidget( hline, 3, 3, 0, 1 ); - - mFolderConfig = new KPIM::FolderConfig( this ); - connect( mFolderConfig, TQT_SIGNAL( updateFoldersClicked() ), - TQT_SLOT( updateFolders() ) ); - mainLayout->addMultiCellWidget( mFolderConfig, 4, 4, 0, 1 ); -} - -void ResourceGroupwareBaseConfig::loadSettings( KRES::Resource *res ) -{ - mResource = dynamic_cast( res ); - - if ( !mResource ) { - kdDebug(5700) << "ResourceGroupwareBaseConfig::loadSettings(): cast failed" << endl; - return; - } - - mURL->setURL( mResource->prefs()->url() ); - mUser->setText( mResource->prefs()->user() ); - mPassword->setText( mResource->prefs()->password() ); - - mFolderConfig->setFolderLister( mResource->folderLister() ); - mFolderConfig->updateFolderList(); -} - -void ResourceGroupwareBaseConfig::saveSettings( KRES::Resource *res ) -{ - ResourceGroupwareBase *resource = dynamic_cast( res ); - - if ( !resource ) { - kdDebug(5700) << "ResourceGroupwareBaseConfig::saveSettings(): cast failed" << endl; - return; - } - - resource->prefs()->setUrl( mURL->url() ); - resource->prefs()->setUser( mUser->text() ); - resource->prefs()->setPassword( mPassword->text() ); - - mFolderConfig->saveSettings(); -} - -void ResourceGroupwareBaseConfig::updateFolders() -{ - KURL url = mURL->url(); - url.setUser( mUser->text() ); - url.setPass( mPassword->text() ); - - mFolderConfig->retrieveFolderList( url ); -} - -#include "kabc_resourcegroupwarebaseconfig.moc" diff --git a/tderesources/lib/kabc_resourcegroupwarebaseconfig.h b/tderesources/lib/kabc_resourcegroupwarebaseconfig.h deleted file mode 100644 index f505d9ceb..000000000 --- a/tderesources/lib/kabc_resourcegroupwarebaseconfig.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - This file is part of tdepim. - - Copyright (c) 2004 Cornelius Schumacher - Copyright (c) 2004 Till Adam - Copyright (c) 2005 Reinhold Kainhofer - - 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 KABC_RESOURCEGROUPWAREBASECONFIG_H -#define KABC_RESOURCEGROUPWAREBASECONFIG_H - -#include -#include - -class KLineEdit; -class KURLRequester; - -namespace KPIM { -class FolderConfig; -} - -namespace KABC { - -class ResourceGroupwareBase; - -class KDE_EXPORT ResourceGroupwareBaseConfig : public KRES::ConfigWidget -{ - Q_OBJECT - - - public: - ResourceGroupwareBaseConfig( TQWidget* parent = 0, const char* name = 0 ); - - public slots: - void loadSettings( KRES::Resource* ); - void saveSettings( KRES::Resource* ); - - protected slots: - void updateFolders(); - - private: - KURLRequester *mURL; - KLineEdit *mUser; - KLineEdit *mPassword; - KPIM::FolderConfig *mFolderConfig; - - ResourceGroupwareBase *mResource; -}; - -} - -#endif diff --git a/tderesources/lib/tdeabc_resourcegroupwarebase.cpp b/tderesources/lib/tdeabc_resourcegroupwarebase.cpp new file mode 100644 index 000000000..3ebd175eb --- /dev/null +++ b/tderesources/lib/tdeabc_resourcegroupwarebase.cpp @@ -0,0 +1,262 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + Copyright (c) 2004 Till Adam + Copyright (C) 2005 Reinhold Kainhofer + + 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 "kabc_resourcegroupwarebase.h" +#include "tderesources_groupwareprefs.h" + +#include "folderlister.h" +#include "addressbookadaptor.h" +#include "groupwaredownloadjob.h" +#include "groupwareuploadjob.h" + +#include +#include +#include + +using namespace KABC; + +ResourceGroupwareBase::ResourceGroupwareBase( const TDEConfig *config ) + : ResourceCached( config ), + mPrefs(0), mFolderLister(0), mAdaptor(0), mDownloadJob(0), mUploadJob(0) +{ + if ( config ) readConfig( config ); +} + +ResourceGroupwareBase::~ResourceGroupwareBase() +{ + delete mPrefs; + mPrefs = 0; +} + +KPIM::GroupwareDownloadJob *ResourceGroupwareBase::createDownloadJob( + AddressBookAdaptor *adaptor ) +{ + return new KPIM::GroupwareDownloadJob( adaptor ); +} + +KPIM::GroupwareUploadJob *ResourceGroupwareBase::createUploadJob( + AddressBookAdaptor *adaptor ) +{ + return new KPIM::GroupwareUploadJob( adaptor ); +} + +void ResourceGroupwareBase::setPrefs( KPIM::GroupwarePrefsBase *newprefs ) +{ + if ( !newprefs ) return; + if ( mPrefs ) delete mPrefs; + mPrefs = newprefs; + mPrefs->addGroupPrefix( identifier() ); + + mPrefs->readConfig(); + if ( mFolderLister ) mFolderLister->readConfig( mPrefs ); +} + +void ResourceGroupwareBase::setFolderLister( KPIM::FolderLister *folderLister ) +{ + if ( !folderLister ) return; + if ( mFolderLister ) delete mFolderLister; + mFolderLister = folderLister; + if ( mPrefs ) mFolderLister->readConfig( mPrefs ); + if ( mAdaptor ) { + mAdaptor->setFolderLister( mFolderLister ); + mFolderLister->setAdaptor( mAdaptor ); + } +} + +void ResourceGroupwareBase::setAdaptor( AddressBookAdaptor *adaptor ) +{ + if ( !adaptor ) return; + if ( mAdaptor ) delete mAdaptor; + mAdaptor = adaptor; + mAdaptor->setFolderLister( mFolderLister ); + if ( mFolderLister ) mFolderLister->setAdaptor( mAdaptor ); + mAdaptor->setDownloadProgressMessage( i18n("Downloading addressbook") ); + mAdaptor->setUploadProgressMessage( i18n("Uploading addressbook") ); + if ( prefs() ) { + mAdaptor->setBaseURL( prefs()->url() ); + mAdaptor->setUser( prefs()->user() ); + mAdaptor->setPassword( prefs()->password() ); + } + mAdaptor->setIdMapper( &idMapper() ); + mAdaptor->setResource( this ); +} + +void ResourceGroupwareBase::init() +{ + mDownloadJob = 0; +} + +KPIM::GroupwarePrefsBase *ResourceGroupwareBase::createPrefs() +{ + return new KPIM::GroupwarePrefsBase(); +} + + + +void ResourceGroupwareBase::readConfig( const TDEConfig */*config*/ ) +{ + kdDebug(5700) << "KABC::ResourceGroupwareBase::readConfig()" << endl; +// ResourceCached::readConfig( config ); + if ( mPrefs ) { + mPrefs->readConfig(); + if ( mFolderLister ) + mFolderLister->readConfig( mPrefs ); + } +} + +void ResourceGroupwareBase::writeConfig( TDEConfig *config ) +{ + Resource::writeConfig( config ); + + if ( mPrefs ) { + if ( mFolderLister ) + mFolderLister->writeConfig( mPrefs ); + mPrefs->writeConfig(); + } +} + +Ticket *ResourceGroupwareBase::requestSaveTicket() +{ + if ( !addressBook() ) { + kdDebug(5700) << "no addressbook" << endl; + return 0; + } + + return createTicket( this ); +} + +void ResourceGroupwareBase::releaseSaveTicket( Ticket *ticket ) +{ + delete ticket; +} + +bool ResourceGroupwareBase::doOpen() +{ + return true; +} + +void ResourceGroupwareBase::doClose() +{ + kdDebug(5800) << "ResourceGroupwareBase::doClose()" << endl; + + if ( mDownloadJob ) mDownloadJob->kill(); +} + +bool ResourceGroupwareBase::load() +{ + return asyncLoad(); +} + +bool ResourceGroupwareBase::asyncLoad() +{ + if ( mDownloadJob ) { + kdWarning() << "Download still in progress" << endl; + return false; + } + + mAddrMap.clear(); + loadCache(); + + mDownloadJob = createDownloadJob( mAdaptor ); + connect( mDownloadJob, TQT_SIGNAL( result( KPIM::GroupwareJob * ) ), + TQT_SLOT( slotDownloadJobResult( KPIM::GroupwareJob * ) ) ); + + return true; +} + +void ResourceGroupwareBase::slotDownloadJobResult( KPIM::GroupwareJob *job ) +{ + kdDebug(5800) << "ResourceGroupwareBase::slotJobResult(): " << endl; + + if ( job->error() ) { + kdError() << "job failed: " << job->errorString() << endl; + } else { + emit loadingFinished( this ); + if ( addressBook() ) + addressBook()->emitAddressBookChanged(); + } + + mDownloadJob = 0; +} + +bool ResourceGroupwareBase::save( Ticket *ticket ) +{ + return asyncSave( ticket ); +} + +bool ResourceGroupwareBase::asyncSave( Ticket* ) +{ + if ( mUploadJob ) { + // FIXME: If the user cancels, need to reset the mUploadJob variable to 0. + kdWarning() << "Upload still in progress." << endl; + return false; + } + + mUploadJob = createUploadJob( mAdaptor ); + connect( mUploadJob, TQT_SIGNAL( result( KPIM::GroupwareJob * ) ), + TQT_SLOT( slotUploadJobResult( KPIM::GroupwareJob * ) ) ); + + KABC::Addressee::List addr; + KABC::Addressee::List::Iterator it; + KPIM::GroupwareUploadItem::List addedItems, changedItems, deletedItems; + + addr = addedAddressees(); + for( it = addr.begin(); it != addr.end(); ++it ) { + addedItems.append( adaptor()->newUploadItem( *it, + KPIM::GroupwareUploadItem::Added ) ); + } + // TODO: Check if the item has changed on the server... + // In particular, check if the version we based our change on is still current + // on the server + addr = changedAddressees(); + for( it = addr.begin(); it != addr.end(); ++it ) { + changedItems.append( adaptor()->newUploadItem( *it, + KPIM::GroupwareUploadItem::Changed ) ); + } + addr = deletedAddressees(); + for( it = addr.begin(); it != addr.end(); ++it ) { + deletedItems.append( adaptor()->newUploadItem( *it, + KPIM::GroupwareUploadItem::Deleted ) ); + } + + mUploadJob->setAddedItems( addedItems ); + mUploadJob->setChangedItems( changedItems ); + mUploadJob->setDeletedItems( deletedItems ); + + return true; +} + +void ResourceGroupwareBase::slotUploadJobResult( KPIM::GroupwareJob *job ) +{ + kdDebug(5800) << "ResourceGroupwareBase::slotJobResult(): " << endl; + + if ( job->error() ) { + kdError() << "job failed: " << job->errorString() << endl; + } else { + // FIXME + } + + mUploadJob = 0; +} + + +#include "kabc_resourcegroupwarebase.moc" diff --git a/tderesources/lib/tdeabc_resourcegroupwarebase.h b/tderesources/lib/tdeabc_resourcegroupwarebase.h new file mode 100644 index 000000000..28ce5199e --- /dev/null +++ b/tderesources/lib/tdeabc_resourcegroupwarebase.h @@ -0,0 +1,99 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + Copyright (c) 2004 Till Adam + Copyright (C) 2005 Reinhold Kainhofer + + 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 KABC_RESOURCEGROUPWARE_H +#define KABC_RESOURCEGROUPWARE_H + +#include +#include +#include + +class TDEConfig; + +namespace KPIM { +class GroupwareJob; +class GroupwareDownloadJob; +class GroupwareUploadJob; +class FolderLister; +class GroupwarePrefsBase; +} + +namespace KABC { + +class AddressBookAdaptor; + +class KDE_EXPORT ResourceGroupwareBase : public ResourceCached +{ + Q_OBJECT + + + public: + ResourceGroupwareBase( const TDEConfig * ); + ~ResourceGroupwareBase(); + + void readConfig( const TDEConfig * ); + void writeConfig( TDEConfig * ); + + KPIM::GroupwarePrefsBase *prefs() const { return mPrefs; } + void setPrefs( KPIM::GroupwarePrefsBase *prefs ); + + KPIM::FolderLister *folderLister() const { return mFolderLister; } + void setFolderLister( KPIM::FolderLister *folderLister ); + + AddressBookAdaptor *adaptor() const { return mAdaptor; } + void setAdaptor( AddressBookAdaptor *adaptor ); + + bool doOpen(); + void doClose(); + + Ticket *requestSaveTicket(); + void releaseSaveTicket( Ticket* ); + + bool load(); + bool asyncLoad(); + bool save( Ticket * ); + bool asyncSave( Ticket * ); + + protected: + void init(); + + KPIM::GroupwarePrefsBase *createPrefs(); + virtual KPIM::GroupwareDownloadJob *createDownloadJob( + AddressBookAdaptor *adaptor ); + virtual KPIM::GroupwareUploadJob *createUploadJob( + AddressBookAdaptor *adaptor ); + + private slots: + void slotDownloadJobResult( KPIM::GroupwareJob * ); + void slotUploadJobResult( KPIM::GroupwareJob * ); + + private: + KPIM::GroupwarePrefsBase *mPrefs; + KPIM::FolderLister *mFolderLister; + AddressBookAdaptor *mAdaptor; + + KPIM::GroupwareDownloadJob *mDownloadJob; + KPIM::GroupwareUploadJob *mUploadJob; +}; + +} + +#endif diff --git a/tderesources/lib/tdeabc_resourcegroupwarebaseconfig.cpp b/tderesources/lib/tdeabc_resourcegroupwarebaseconfig.cpp new file mode 100644 index 000000000..918dfc52b --- /dev/null +++ b/tderesources/lib/tdeabc_resourcegroupwarebaseconfig.cpp @@ -0,0 +1,117 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + Copyright (c) 2004 Till Adam + Copyright (c) 2005 Reinhold Kainhofer + + 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 "kabc_resourcegroupwarebaseconfig.h" + +#include "kabc_resourcegroupwarebase.h" +#include "tderesources_groupwareprefs.h" +#include "folderconfig.h" + +#include +#include +#include +#include +#include + +#include +#include + +using namespace KABC; + +ResourceGroupwareBaseConfig::ResourceGroupwareBaseConfig( TQWidget* parent, const char* name ) + : KRES::ConfigWidget( parent, name ) +{ + TQGridLayout *mainLayout = new TQGridLayout( this, 7, 2, 0, KDialog::spacingHint() ); + + TQLabel *label = new TQLabel( i18n( "URL:" ), this ); + mURL = new KURLRequester( this ); + + mainLayout->addWidget( label, 0, 0 ); + mainLayout->addWidget( mURL, 0, 1 ); + + label = new TQLabel( i18n( "User:" ), this ); + mUser = new KLineEdit( this ); + + mainLayout->addWidget( label, 1, 0 ); + mainLayout->addWidget( mUser, 1, 1 ); + + label = new TQLabel( i18n( "Password:" ), this ); + mPassword = new KLineEdit( this ); + mPassword->setEchoMode( TQLineEdit::Password ); + + mainLayout->addWidget( label, 2, 0 ); + mainLayout->addWidget( mPassword, 2, 1 ); + + TQFrame *hline = new TQFrame( this ); + hline->setFrameStyle( TQFrame::HLine | TQFrame::Sunken ); + + mainLayout->addMultiCellWidget( hline, 3, 3, 0, 1 ); + + mFolderConfig = new KPIM::FolderConfig( this ); + connect( mFolderConfig, TQT_SIGNAL( updateFoldersClicked() ), + TQT_SLOT( updateFolders() ) ); + mainLayout->addMultiCellWidget( mFolderConfig, 4, 4, 0, 1 ); +} + +void ResourceGroupwareBaseConfig::loadSettings( KRES::Resource *res ) +{ + mResource = dynamic_cast( res ); + + if ( !mResource ) { + kdDebug(5700) << "ResourceGroupwareBaseConfig::loadSettings(): cast failed" << endl; + return; + } + + mURL->setURL( mResource->prefs()->url() ); + mUser->setText( mResource->prefs()->user() ); + mPassword->setText( mResource->prefs()->password() ); + + mFolderConfig->setFolderLister( mResource->folderLister() ); + mFolderConfig->updateFolderList(); +} + +void ResourceGroupwareBaseConfig::saveSettings( KRES::Resource *res ) +{ + ResourceGroupwareBase *resource = dynamic_cast( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceGroupwareBaseConfig::saveSettings(): cast failed" << endl; + return; + } + + resource->prefs()->setUrl( mURL->url() ); + resource->prefs()->setUser( mUser->text() ); + resource->prefs()->setPassword( mPassword->text() ); + + mFolderConfig->saveSettings(); +} + +void ResourceGroupwareBaseConfig::updateFolders() +{ + KURL url = mURL->url(); + url.setUser( mUser->text() ); + url.setPass( mPassword->text() ); + + mFolderConfig->retrieveFolderList( url ); +} + +#include "kabc_resourcegroupwarebaseconfig.moc" diff --git a/tderesources/lib/tdeabc_resourcegroupwarebaseconfig.h b/tderesources/lib/tdeabc_resourcegroupwarebaseconfig.h new file mode 100644 index 000000000..f505d9ceb --- /dev/null +++ b/tderesources/lib/tdeabc_resourcegroupwarebaseconfig.h @@ -0,0 +1,65 @@ +/* + This file is part of tdepim. + + Copyright (c) 2004 Cornelius Schumacher + Copyright (c) 2004 Till Adam + Copyright (c) 2005 Reinhold Kainhofer + + 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 KABC_RESOURCEGROUPWAREBASECONFIG_H +#define KABC_RESOURCEGROUPWAREBASECONFIG_H + +#include +#include + +class KLineEdit; +class KURLRequester; + +namespace KPIM { +class FolderConfig; +} + +namespace KABC { + +class ResourceGroupwareBase; + +class KDE_EXPORT ResourceGroupwareBaseConfig : public KRES::ConfigWidget +{ + Q_OBJECT + + + public: + ResourceGroupwareBaseConfig( TQWidget* parent = 0, const char* name = 0 ); + + public slots: + void loadSettings( KRES::Resource* ); + void saveSettings( KRES::Resource* ); + + protected slots: + void updateFolders(); + + private: + KURLRequester *mURL; + KLineEdit *mUser; + KLineEdit *mPassword; + KPIM::FolderConfig *mFolderConfig; + + ResourceGroupwareBase *mResource; +}; + +} + +#endif -- cgit v1.2.1