author | ulf69 <ulf69> | 2004-08-04 22:45:22 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-04 22:45:22 (UTC) |
commit | c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852 (patch) (side-by-side diff) | |
tree | dc59744a6d59ba241e793ce051da485d0bf16d06 /kabc/plugins/file | |
parent | b83866e08ddcc5cb2734801977927f48b53a2e1c (diff) | |
download | kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.zip kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.tar.gz kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.tar.bz2 |
final changes for addressbook sync config dialog
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index d98efc8..da2e4d7 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp @@ -21,154 +21,144 @@ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <sys/types.h> #include <sys/stat.h> #ifndef _WIN32_ #include <unistd.h> #endif #include <qfile.h> #include <qfileinfo.h> #include <qregexp.h> #include <qtimer.h> #include <kapplication.h> #include <kconfig.h> #include <kdebug.h> #include <klocale.h> //US #include <ksavefile.h> #include <kstandarddirs.h> #include <kmessagebox.h> #include "formatfactory.h" #include "resource.h" #include "resourcefileconfig.h" #include "stdaddressbook.h" #include "resourcefile.h" #include "syncprefwidget.h" using namespace KABC; extern "C" #ifdef _WIN32_ __declspec(dllexport) #else { #endif //US void *init_kabc_file() void *init_microkabc_file() { - return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidget>(); + return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidgetContainer>(); } #ifndef _WIN32_ } #endif ResourceFile::ResourceFile( const KConfig *config, bool syncable ) : Resource( config, syncable ) , mFormat( 0 ) { - QString fileName, formatName; + QString fileName, formatName, default_fileName; + + if (syncable == true) + default_fileName = "/home/polo/kdepim/apps/kabc/localfile.vcf"; + else + default_fileName = StdAddressBook::fileName(); KConfig *cfg = (KConfig *)config; if ( cfg ) { - fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() ); + fileName = cfg->readEntry( "FileName", default_fileName ); formatName = cfg->readEntry( "FileFormat", "vcard" ); -// qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() ); } else { - fileName = StdAddressBook::fileName(); + fileName = default_fileName; formatName = "vcard"; -// qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() ); } init( fileName, formatName ); } ResourceFile::ResourceFile( const QString &fileName, bool syncable , const QString &formatName ) : Resource( 0, syncable ) { // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); 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 ); } -/*US -//US qDebug("ResourceFile::init initialized with format %s ", formatName.latin1()); - if (mFormatName == "vcard") { - mFormat = new VCardFormatPlugin2(); -// qDebug("ResourceFile::init format VCardFormatPlugin2"); - } - else if (mFormatName == "binary") { - mFormat = new BinaryFormat(); -// qDebug("ResourceFile::init format BinaryFormat"); - } - else - qDebug("ResourceFile::init format unknown !!! %s ", formatName.latin1()); -*/ 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 ); } ResourceFile::~ResourceFile() { delete mFormat; mFormat = 0; } void ResourceFile::writeConfig( KConfig *config ) { config->setGroup( "Resource_" + identifier() ); Resource::writeConfig( config ); config->writeEntry( "FileName", mFileName ); config->writeEntry( "FileFormat", mFormatName ); // qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); } Ticket *ResourceFile::requestSaveTicket() { kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; if ( !addressBook() ) return 0; if ( !lock( mFileName ) ) { kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock file '" << mFileName << "'" << endl; return 0; } return createTicket( this ); } bool ResourceFile::doOpen() { QFile file( mFileName ); if ( !file.exists() ) { // try to create the file |