summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/file/resourcefile.cpp
Side-by-side diff
Diffstat (limited to 'kabc/plugins/file/resourcefile.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/file/resourcefile.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index 2d20706..9f9b00f 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -28,52 +28,48 @@ $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 "formatfactory.h"
#include "resource.h"
#include "resourcefileconfig.h"
#include "stdaddressbook.h"
-//US #include "../../formats/vcardformatplugin2.h"
-//US #include "../../formats/binaryformat.h"
-
-
#include "resourcefile.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>();
}
#ifndef _WIN32_
}
#endif
ResourceFile::ResourceFile( const KConfig *config )
: Resource( config ) , mFormat( 0 )
{
QString fileName, formatName;
@@ -105,53 +101,51 @@ 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());
*/
-/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods
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()
@@ -305,61 +299,59 @@ bool ResourceFile::lock( const QString &fileName )
}
// TODO: check stat
return false;
}
void ResourceFile::unlock( const QString &fileName )
{
QString fn = fileName;
//US change the implementation how the lockfilename is getting created
//US fn.replace( QRegExp( "/" ), "_" );
//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
//US QString lockName = fn + ".lock";
KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
QFile::remove( lockName );
QFile::remove( mLockUniqueName );
addressBook()->emitAddressBookUnlocked();
}
void ResourceFile::setFileName( const QString &fileName )
{
-/*US ToDo: no synchronization so far. Has to be changed in the future
mDirWatch.stopScan();
mDirWatch.removeFile( mFileName );
-*/
+
mFileName = fileName;
-/*US ToDo: no synchronization so far. Has to be changed in the future
mDirWatch.addFile( mFileName );
mDirWatch.startScan();
-*/
+
//US simulate KDirWatch event
- fileChanged();
+//US fileChanged();
}
QString ResourceFile::fileName() const
{
return mFileName;
}
void ResourceFile::setFormat( const QString &format )
{
mFormatName = format;
delete mFormat;
FormatFactory *factory = FormatFactory::self();
mFormat = factory->format( mFormatName );
/*US
//qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1());
if (mFormatName == "vcard") {
mFormat = new VCardFormatPlugin2();
// qDebug("ResourceFile::setFormat format %s", mFormatName.latin1());
}
else if (mFormatName == "binary") {
mFormat = new BinaryFormat();
// qDebug("ResourceFile::setFormat format %s", mFormatName.latin1());
}