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 | ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch) | |
tree | 5ac38a06f3dde268dc7927dc155896926aaf7012 /kabc/plugins/file | |
download | tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.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/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kabc/plugins/file')
-rw-r--r-- | kabc/plugins/file/Makefile.am | 28 | ||||
-rw-r--r-- | kabc/plugins/file/file.desktop | 82 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 395 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.h | 162 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefileconfig.cpp | 118 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefileconfig.h | 57 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefileplugin.cpp | 32 |
7 files changed, 874 insertions, 0 deletions
diff --git a/kabc/plugins/file/Makefile.am b/kabc/plugins/file/Makefile.am new file mode 100644 index 000000000..9e3fc8360 --- /dev/null +++ b/kabc/plugins/file/Makefile.am @@ -0,0 +1,28 @@ +INCLUDES = -I$(top_builddir)/kabc -I$(top_srcdir)/kabc $(all_includes) + +# these are the headers for your project +noinst_HEADERS = resourcefileconfig.h + +lib_LTLIBRARIES = libkabc_file.la +libkabc_file_la_SOURCES = resourcefile.cpp resourcefileconfig.cpp +libkabc_file_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -version-info 1:0:0 -no-undefined +libkabc_file_la_LIBADD = $(LIB_KABC) +libkabc_file_la_COMPILE_FIRST = $(top_builddir)/kabc/addressee.h + + +kde_module_LTLIBRARIES = kabc_file.la +kabc_file_la_SOURCES = resourcefileplugin.cpp +kabc_file_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined +kabc_file_la_LIBADD = libkabc_file.la +kabc_file_la_COMPILE_FIRST = $(top_builddir)/kabc/addressee.h + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kabc_file.pot + +kabcincludedir = $(includedir)/kabc +kabcinclude_HEADERS = resourcefile.h + +servicedir = $(kde_servicesdir)/kresources/kabc +service_DATA = file.desktop diff --git a/kabc/plugins/file/file.desktop b/kabc/plugins/file/file.desktop new file mode 100644 index 000000000..559cfcf21 --- /dev/null +++ b/kabc/plugins/file/file.desktop @@ -0,0 +1,82 @@ +[Desktop Entry] +Name=File +Name[af]=Lêer +Name[ar]=ملفّ +Name[az]=Fayl +Name[be]=Файл +Name[bn]=ফাইল +Name[br]=Restr +Name[bs]=Datoteka +Name[ca]=Fitxer +Name[cs]=Soubor +Name[csb]=Lopk +Name[cy]=Ffeil +Name[da]=Fil +Name[de]=Datei +Name[el]=Αρχείο +Name[eo]=Dosiero +Name[es]=Archivo +Name[et]=Fail +Name[eu]=Fitxategia +Name[fa]=پرونده +Name[fi]=Tiedosto +Name[fr]=Fichier +Name[fy]=Triem +Name[ga]=Comhad +Name[gl]=Ficheiro +Name[he]=קובץ +Name[hi]=फ़ाइल +Name[hr]=Datoteka +Name[hsb]=Dataja +Name[hu]=Fájl +Name[id]=Berkas +Name[is]=Skrá +Name[ja]=ファイル +Name[ka]=ფაილი +Name[kk]=Файл +Name[km]=ឯកសារ +Name[ko]=파일 +Name[lb]=Datei +Name[lt]=Byla +Name[lv]=Fails +Name[mk]=Датотека +Name[mn]=Файл +Name[ms]=Fail +Name[nb]=Fil +Name[nds]=Datei +Name[ne]=फाइल +Name[nl]=Bestand +Name[nn]=Fil +Name[pa]=ਫਾਇਲ +Name[pl]=Plik +Name[pt]=Ficheiro +Name[pt_BR]=Arquivo +Name[ro]=Fişier +Name[ru]=Файл +Name[rw]=Idosiye +Name[se]=Fiila +Name[sk]=Súbor +Name[sl]=Datoteka +Name[sq]=Skedë +Name[sr]=Фајл +Name[sr@Latn]=Fajl +Name[sv]=Fil +Name[ta]=கோப்பு +Name[te]=దస్త్రం +Name[tg]=Файл +Name[th]=แฟ้ม +Name[tr]=Dosya +Name[tt]=Birem +Name[uk]=Файл +Name[uz]=Fayl +Name[uz@cyrillic]=Файл +Name[vi]=Tập tin +Name[wa]=Fitchî +Name[zh_CN]=文件 +Name[zh_HK]=檔案 +Name[zh_TW]=檔案 +X-KDE-Library=kabc_file +Type=Service +ServiceTypes=KResources/Plugin +X-KDE-ResourceFamily=contact +X-KDE-ResourceType=file diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp new file mode 100644 index 000000000..9c0f85fb8 --- /dev/null +++ b/kabc/plugins/file/resourcefile.cpp @@ -0,0 +1,395 @@ +/* + This file is part of libkabc. + + Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2006 Tom Abers <tomalbers@kde.nl> + + 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 <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#include <qfile.h> +#include <qfileinfo.h> +#include <qtimer.h> + +#include <kapplication.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kio/scheduler.h> +#include <klocale.h> +#include <ksavefile.h> +#include <kstandarddirs.h> + +#include "formatfactory.h" +#include "resourcefileconfig.h" +#include "stdaddressbook.h" +#include "lock.h" + +#include "resourcefile.h" + +using namespace KABC; + +ResourceFile::ResourceFile( const KConfig *config ) + : Resource( config ), mFormat( 0 ), + mAsynchronous( false ) +{ + QString fileName, formatName; + + if ( config ) { + fileName = config->readPathEntry( "FileName", StdAddressBook::fileName() ); + formatName = config->readEntry( "FileFormat", "vcard" ); + } else { + fileName = StdAddressBook::fileName(); + formatName = "vcard"; + } + + init( fileName, formatName ); +} + +ResourceFile::ResourceFile( const QString &fileName, + const QString &formatName ) + : Resource( 0 ), mFormat( 0 ), + mAsynchronous( false ) +{ + init( fileName, formatName ); +} + +void ResourceFile::init( const QString &fileName, const QString &formatName ) +{ + mFormatName = formatName; + + FormatFactory *factory = FormatFactory::self(); + mFormat = factory->format( mFormatName ); + + if ( !mFormat ) { + mFormatName = "vcard"; + mFormat = factory->format( mFormatName ); + } + + connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); + connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); + connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); + + setFileName( fileName ); + + mLock = 0; +} + +ResourceFile::~ResourceFile() +{ + delete mFormat; + mFormat = 0; +} + +void ResourceFile::writeConfig( KConfig *config ) +{ + Resource::writeConfig( config ); + + if ( mFileName == StdAddressBook::fileName() ) + config->deleteEntry( "FileName" ); + else + config->writePathEntry( "FileName", mFileName ); + + config->writeEntry( "FileFormat", mFormatName ); +} + +Ticket *ResourceFile::requestSaveTicket() +{ + kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; + + if ( !addressBook() ) return 0; + + delete mLock; + mLock = new Lock( mFileName ); + + if ( mLock->lock() ) { + addressBook()->emitAddressBookLocked(); + } else { + addressBook()->error( mLock->error() ); + kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock file '" + << mFileName << "': " << mLock->error() << endl; + return 0; + } + + return createTicket( this ); +} + +void ResourceFile::releaseSaveTicket( Ticket *ticket ) +{ + delete ticket; + + delete mLock; + mLock = 0; + + addressBook()->emitAddressBookUnlocked(); +} + +bool ResourceFile::doOpen() +{ + QFile file( mFileName ); + + if ( !file.exists() ) { + // try to create the file + bool ok = file.open( IO_WriteOnly ); + if ( ok ) + file.close(); + + return ok; + } else { + QFileInfo fileInfo( mFileName ); + if ( readOnly() || !fileInfo.isWritable() ) { + if ( !file.open( IO_ReadOnly ) ) + return false; + } else { + if ( !file.open( IO_ReadWrite ) ) + return false; + } + + if ( file.size() == 0 ) { + file.close(); + kdDebug() << "File size is zero. Evaluating backups" << endl; + for (int i=0; i!=20; i++) + { + QFile backup( mFileName + "__" + QString::number(i) ); + kdDebug() << "Evaluating" << backup.name() << " size: " << backup.size() << endl; + if ( backup.size() != 0 ) + { + kdDebug() << "Restoring backup " << i << endl; + const QString src = mFileName + "__" + QString::number(i); + const QString dest = mFileName; + + // remove dest + QFile::remove( dest ); + + // copy src to dest + if ( backup.open( IO_ReadOnly ) ) { + const QByteArray data = backup.readAll(); + + QFile out( dest ); + if ( out.open( IO_WriteOnly ) ) { + out.writeBlock( data ); + out.close(); + } + + backup.close(); + } + return true; + } + } + return true; + } + + bool ok = mFormat->checkFormat( &file ); + file.close(); + + return ok; + } +} + +void ResourceFile::doClose() +{ +} + +bool ResourceFile::load() +{ + kdDebug(5700) << "ResourceFile::load(): '" << mFileName << "'" << endl; + + mAsynchronous = false; + + QFile file( mFileName ); + if ( !file.open( IO_ReadOnly ) ) { + addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); + return false; + } + + clear(); + + return mFormat->loadAll( addressBook(), this, &file ); +} + +bool ResourceFile::asyncLoad() +{ + kdDebug(5700) << "ResourceFile::asyncLoad()" << endl; + + mAsynchronous = true; + + bool ok = load(); + + if ( !ok ) + emitLoadingError(); + else + emitLoadingFinished(); + + return true; +} + +bool ResourceFile::save( Ticket * ) +{ + kdDebug(5700) << "ResourceFile::save()" << endl; + + // Only do the logrotate dance when the __0 file is not 0 bytes. + QFile file( mFileName + "__0" ); + if ( file.size() != 0 ) { + const QString last = mFileName + "__20"; + kdDebug() << "deleting " << last << endl; + + QFile::remove( last ); + + for (int i=19; i>=0; i--) + { + const QString src = mFileName + "__" + QString::number(i); + const QString dest = mFileName + "__" + QString::number(i+1); + kdDebug() << "moving " << src << " -> " << dest << endl; + + // copy src to dest + QFile in( src ); + if ( in.open( IO_ReadOnly ) ) { + const QByteArray data = in.readAll(); + + QFile out( dest ); + if ( out.open( IO_WriteOnly ) ) { + out.writeBlock( data ); + out.close(); + } + + in.close(); + } + + // remove src + QFile::remove( src ); + } + } else + kdDebug() << "Not starting logrotate __0 is 0 bytes." << endl; + + QString extension = "__0"; + (void) KSaveFile::backupFile( mFileName, QString::null /*directory*/, + extension ); + + mDirWatch.stopScan(); + + KSaveFile saveFile( mFileName ); + bool ok = false; + + if ( saveFile.status() == 0 && saveFile.file() ) { + mFormat->saveAll( addressBook(), this, saveFile.file() ); + ok = saveFile.close(); + } + + if ( !ok ) { + saveFile.abort(); + addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); + } + + mDirWatch.startScan(); + + return ok; +} + +bool ResourceFile::asyncSave( Ticket *ticket ) +{ + kdDebug(5700) << "ResourceFile::asyncSave()" << endl; + + bool ok = save( ticket ); + + if ( !ok ) + QTimer::singleShot( 0, this, SLOT( emitSavingError() ) ); + else + QTimer::singleShot( 0, this, SLOT( emitSavingFinished() ) ); + + return ok; +} + +void ResourceFile::setFileName( const QString &fileName ) +{ + mDirWatch.stopScan(); + if ( mDirWatch.contains( mFileName ) ) + mDirWatch.removeFile( mFileName ); + + mFileName = fileName; + + mDirWatch.addFile( mFileName ); + mDirWatch.startScan(); +} + +QString ResourceFile::fileName() const +{ + return mFileName; +} + +void ResourceFile::setFormat( const QString &format ) +{ + mFormatName = format; + delete mFormat; + + FormatFactory *factory = FormatFactory::self(); + mFormat = factory->format( mFormatName ); +} + +QString ResourceFile::format() const +{ + return mFormatName; +} + +void ResourceFile::fileChanged() +{ + kdDebug(5700) << "ResourceFile::fileChanged(): " << mFileName << endl; + + if ( !addressBook() ) + return; + + if ( mAsynchronous ) + asyncLoad(); + else { + load(); + kdDebug() << "addressBookChanged() " << endl; + addressBook()->emitAddressBookChanged(); + } +} + +void ResourceFile::removeAddressee( const Addressee &addr ) +{ + QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) ); + QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) ); + QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) ); + + mAddrMap.erase( addr.uid() ); +} + +void ResourceFile::emitSavingFinished() +{ + emit savingFinished( this ); +} + +void ResourceFile::emitSavingError() +{ + emit savingError( this, i18n( "Unable to save file '%1'." ).arg( mFileName ) ); +} + +void ResourceFile::emitLoadingFinished() +{ + emit loadingFinished( this ); +} + +void ResourceFile::emitLoadingError() +{ + emit loadingError( this, i18n( "Problems during parsing file '%1'." ).arg( mFileName ) ); +} + +#include "resourcefile.moc" diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h new file mode 100644 index 000000000..84dfc7cda --- /dev/null +++ b/kabc/plugins/file/resourcefile.h @@ -0,0 +1,162 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 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 KABC_RESOURCEFILE_H +#define KABC_RESOURCEFILE_H + +#include <kconfig.h> +#include <kdirwatch.h> + +#include <sys/types.h> + +#include <kabc/resource.h> + +namespace KABC { + +class FormatPlugin; +class ResourceConfigWidget; +class Lock; + +/** + This resource allows access to a local file. +*/ +class KABC_EXPORT ResourceFile : public Resource +{ + Q_OBJECT + + public: + /** + Constructor. + + @param cfg The config object where custom resource settings are stored. + */ + ResourceFile( const KConfig *cfg ); + + /** + Construct file resource on file @arg fileName using format @arg formatName. + */ + ResourceFile( const QString &fileName, const QString &formatName = "vcard" ); + + /** + Destructor. + */ + ~ResourceFile(); + + /** + Writes the config back. + */ + virtual void writeConfig( KConfig *cfg ); + + /** + Tries to open the file and checks for the proper format. + This method should be called before load(). + */ + virtual bool doOpen(); + + /** + Closes the file again. + */ + virtual void doClose(); + + /** + Requests a save ticket, that is used by save() + */ + virtual Ticket *requestSaveTicket(); + + virtual void releaseSaveTicket( Ticket* ); + + /** + Loads all addressees from file to the address book. + Returns true if all addressees could be loaded otherwise false. + */ + virtual bool load(); + + virtual bool asyncLoad(); + + /** + Saves all addresses from address book to file. + Returns true if all addressees could be saved otherwise false. + + @param ticket The ticket returned by requestSaveTicket() + */ + virtual bool save( Ticket *ticket ); + + virtual bool asyncSave( Ticket *ticket ); + + /** + Set name of file to be used for saving. + */ + void setFileName( const QString & ); + + /** + Return name of file used for loading and saving the address book. + */ + QString fileName() const; + + /** + Sets a new format by name. + */ + void setFormat( const QString &name ); + + /** + Returns the format name. + */ + QString format() const; + + /** + Remove a addressee from its source. + This method is mainly called by KABC::AddressBook. + */ + virtual void removeAddressee( const Addressee& addr ); + + private slots: + void emitLoadingFinished(); + void emitLoadingError(); + void emitSavingFinished(); + void emitSavingError(); + + protected slots: + void fileChanged(); + + protected: + void init( const QString &fileName, const QString &format ); + + bool lock( const QString &fileName ); + void unlock( const QString &fileName ); + + private: + QString mFileName; + QString mFormatName; + + FormatPlugin *mFormat; + + Lock *mLock; + + KDirWatch mDirWatch; + + bool mAsynchronous; + + class ResourceFilePrivate; + ResourceFilePrivate *d; +}; + +} + +#endif diff --git a/kabc/plugins/file/resourcefileconfig.cpp b/kabc/plugins/file/resourcefileconfig.cpp new file mode 100644 index 000000000..a6d8ab4f9 --- /dev/null +++ b/kabc/plugins/file/resourcefileconfig.cpp @@ -0,0 +1,118 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <tokoe@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 <qlabel.h> +#include <qlayout.h> + +#include <kdebug.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kdialog.h> + +#include <unistd.h> + +#include "formatfactory.h" +#include "resourcefile.h" +#include "stdaddressbook.h" + +#include "resourcefileconfig.h" + +using namespace KABC; + +ResourceFileConfig::ResourceFileConfig( QWidget* parent, const char* name ) + : ConfigWidget( parent, name ) +{ + QGridLayout *mainLayout = new QGridLayout( this, 2, 2, 0, + KDialog::spacingHint() ); + + QLabel *label = new QLabel( i18n( "Format:" ), this ); + mFormatBox = new KComboBox( this ); + + mainLayout->addWidget( label, 0, 0 ); + mainLayout->addWidget( mFormatBox, 0, 1 ); + + label = new QLabel( i18n( "Location:" ), this ); + mFileNameEdit = new KURLRequester( this ); + + connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), + SLOT( checkFilePermissions( const QString & ) ) ); + + mainLayout->addWidget( label, 1, 0 ); + mainLayout->addWidget( mFileNameEdit, 1, 1 ); + + FormatFactory *factory = FormatFactory::self(); + QStringList formats = factory->formats(); + QStringList::Iterator it; + for ( it = formats.begin(); it != formats.end(); ++it ) { + FormatInfo *info = factory->info( *it ); + if ( info ) { + mFormatTypes << (*it); + mFormatBox->insertItem( info->nameLabel ); + } + } + + mInEditMode = false; +} + +void ResourceFileConfig::setEditMode( bool value ) +{ + mFormatBox->setEnabled( !value ); + mInEditMode = value; +} + +void ResourceFileConfig::loadSettings( KRES::Resource *res ) +{ + ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceFileConfig::loadSettings(): cast failed" << endl; + return; + } + + mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->format() ) ); + + mFileNameEdit->setURL( resource->fileName() ); + if ( mFileNameEdit->url().isEmpty() ) + mFileNameEdit->setURL( KABC::StdAddressBook::fileName() ); +} + +void ResourceFileConfig::saveSettings( KRES::Resource *res ) +{ + ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); + + if ( !resource ) { + kdDebug(5700) << "ResourceFileConfig::saveSettings(): cast failed" << endl; + return; + } + + if ( !mInEditMode ) + resource->setFormat( mFormatTypes[ mFormatBox->currentItem() ] ); + + resource->setFileName( mFileNameEdit->url() ); +} + +void ResourceFileConfig::checkFilePermissions( const QString& fileName ) +{ + // If file exist but is not writeable... + if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) + emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); +} + +#include "resourcefileconfig.moc" diff --git a/kabc/plugins/file/resourcefileconfig.h b/kabc/plugins/file/resourcefileconfig.h new file mode 100644 index 000000000..3e92f0728 --- /dev/null +++ b/kabc/plugins/file/resourcefileconfig.h @@ -0,0 +1,57 @@ +/* + This file is part of libkabc. + Copyright (c) 2002 Tobias Koenig <tokoe@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 RESOURCEFILECONFIG_H +#define RESOURCEFILECONFIG_H + +#include <kcombobox.h> +#include <kurlrequester.h> + +#include <kresources/configwidget.h> + +namespace KABC { + +class KABC_EXPORT ResourceFileConfig : public KRES::ConfigWidget +{ + Q_OBJECT + +public: + ResourceFileConfig( QWidget* parent = 0, const char* name = 0 ); + + void setEditMode( bool value ); + +public slots: + void loadSettings( KRES::Resource *resource ); + void saveSettings( KRES::Resource *resource ); + +protected slots: + void checkFilePermissions( const QString& fileName ); + +private: + KComboBox* mFormatBox; + KURLRequester* mFileNameEdit; + bool mInEditMode; + + QStringList mFormatTypes; +}; + +} + +#endif diff --git a/kabc/plugins/file/resourcefileplugin.cpp b/kabc/plugins/file/resourcefileplugin.cpp new file mode 100644 index 000000000..4dce19bc0 --- /dev/null +++ b/kabc/plugins/file/resourcefileplugin.cpp @@ -0,0 +1,32 @@ +/* + This file is part of libkabc. + Copyright (c) 2001 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 "resourcefile.h" +#include "resourcefileconfig.h" + +using namespace KABC; + +extern "C" +{ + KDE_EXPORT void *init_kabc_file() + { + return new KRES::PluginFactory<ResourceFile, ResourceFileConfig>(); + } +} |