summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/file/resourcefile.cpp
Side-by-side diff
Diffstat (limited to 'kabc/plugins/file/resourcefile.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kabc/plugins/file/resourcefile.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index c89939d..dad4571 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -38,96 +38,103 @@ $Id$
#include <kapplication.h>
#include <kconfig.h>
#include <kdebug.h>
#include <klocale.h>
//US #include <ksavefile.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <kglobalsettings.h>
#include "formatfactory.h"
#include "resource.h"
#include "resourcefileconfig.h"
#include "stdaddressbook.h"
#define NO_DIRWATCH
#include "resourcefile.h"
//#define ALLOW_LOCKING
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, default_fileName;
default_fileName = StdAddressBook::fileName();
mLastBackupDate = -1;
KConfig *cfg = (KConfig *)config;
if ( cfg ) {
+#ifdef _WIN32_
+ // we use plugins on win32. the group is stored in a static variable
+ // such that group info not available on win32 plugins
+ // to fix that, it would be a looooot of work
+ if ( !cfg->tempGroup().isEmpty() )
+ cfg->setGroup( cfg->tempGroup() );
+#endif
fileName = cfg->readEntry( "FileName", default_fileName );
formatName = cfg->readEntry( "FileFormat", "vcard" );
mFamily = cfg->readEntry( "ResourceName", "std" );
mLastBackupDate = cfg->readNumEntry( "LastBackupDate", 0 );
} 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());
mLastBackupDate = -1;
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 );