author | zautrix <zautrix> | 2005-04-03 23:09:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-03 23:09:08 (UTC) |
commit | 06fbd5e92ff0cb2a5ef630f7f09ca3e1927f5cf5 (patch) (side-by-side diff) | |
tree | a9f01377dc21931e5d267edc3b196232f244d1fb /kabc | |
parent | 30359da3c126e67f6c75400323fcca4c159c3d93 (diff) | |
download | kdepimpi-06fbd5e92ff0cb2a5ef630f7f09ca3e1927f5cf5.zip kdepimpi-06fbd5e92ff0cb2a5ef630f7f09ca3e1927f5cf5.tar.gz kdepimpi-06fbd5e92ff0cb2a5ef630f7f09ca3e1927f5cf5.tar.bz2 |
sync fix
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 10 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.h | 1 |
2 files changed, 9 insertions, 2 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index 0e6c2a3..af76558 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp @@ -63,97 +63,103 @@ __declspec(dllexport) #else { #endif //US void *init_kabc_file() void *init_microkabc_file() { return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); } #ifndef _WIN32_ } #endif ResourceFile::ResourceFile( const KConfig *config ) : Resource( config ) , mFormat( 0 ) { QString fileName, formatName, default_fileName; default_fileName = StdAddressBook::fileName(); KConfig *cfg = (KConfig *)config; if ( cfg ) { fileName = cfg->readEntry( "FileName", default_fileName ); formatName = cfg->readEntry( "FileFormat", "vcard" ); + mFamily = cfg->readEntry( "ResourceName", "std" ); } else { fileName = default_fileName; formatName = "vcard"; } init( fileName, formatName ); } ResourceFile::ResourceFile( const QString &fileName , const QString &formatName ) : Resource( 0 ) { // 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 ); } #ifndef NO_DIRWATCH connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); #endif - QString localKdeDir; localKdeDir = readEnvPath("LOCALMICROKDEHOME"); if ( ! localKdeDir.isEmpty() ) { qDebug("LOCALMICROKDEHOME is set to: %s",localKdeDir.latin1() ); QFileInfo fi ( fileName ); QString localname = localKdeDir + "/apps/kabc/" + fi.fileName (); QFileInfo fi2 ( localname ); - if ( ! fi2.exists() ) { + if ( ! fi2.exists() || mFamily == "sync_res" ) { + if ( fi.exists() && mFamily == "sync_res") { + qDebug("LOCAL mode SYNC mode using absolute file path "); + setFileName( fileName ); + return; + } else { KMessageBox::error(0,i18n("Addressbook resource file not found:\n '%1'.\nIn LOCAL mode only resource files in\n'%2'\nare supported.\n(i.e. in the dir ./apps/kabc/ relative to the kapi(.exe) binary.)\n\nIf you are starting KA/Pi for the very first time\nyou will get this error message as well.\nIt will create the missing file automatically for you.").arg(localname).arg(localKdeDir+"/apps/kabc/") ); setFileName( localname ); return; + } } else { qDebug("Local resource file found. Changing filename to: %s",localname.latin1() ); setFileName( localname ); return; } } setFileName( fileName ); } ResourceFile::~ResourceFile() { delete mFormat; mFormat = 0; } void ResourceFile::writeConfig( KConfig *config ) { config->setGroup( "Resource_" + identifier() ); Resource::writeConfig( config ); config->writeEntry( "FileName", fileName() ); diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h index dd38a9d..3e9edfc 100644 --- a/kabc/plugins/file/resourcefile.h +++ b/kabc/plugins/file/resourcefile.h @@ -126,38 +126,39 @@ public: QString format() const; /** * Remove a addressee from its source. * This method is mainly called by KABC::AddressBook. */ virtual void removeAddressee( const Addressee& addr ); /** * This method is called by an error handler if the application * crashed */ virtual void cleanUp(); 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 mFamily; QString mFileName2; QString mFormatName; FormatPlugin *mFormat; QString mLockUniqueName; #ifndef NO_DIRWATCH KDirWatch mDirWatch; #endif }; } #endif |