summaryrefslogtreecommitdiffabout
path: root/kabc
authorulf69 <ulf69>2004-07-14 14:52:15 (UTC)
committer ulf69 <ulf69>2004-07-14 14:52:15 (UTC)
commitcf7175c9a6b96cd11fb7f3cba459f5223aa4aacb (patch) (side-by-side diff)
treee14057a10fba52a7b2881f5bacb0d266e415bd83 /kabc
parent80b35ebb50cac5007c074a4900f518f48f704eac (diff)
downloadkdepimpi-cf7175c9a6b96cd11fb7f3cba459f5223aa4aacb.zip
kdepimpi-cf7175c9a6b96cd11fb7f3cba459f5223aa4aacb.tar.gz
kdepimpi-cf7175c9a6b96cd11fb7f3cba459f5223aa4aacb.tar.bz2
added changes to support the kdirwatch implementation
Diffstat (limited to 'kabc') (more/less context) (show whitespace changes)
-rw-r--r--kabc/distributionlist.cpp5
-rw-r--r--kabc/distributionlist.h2
-rw-r--r--kabc/kabc.pro2
-rw-r--r--kabc/kabcE.pro2
-rw-r--r--kabc/plugins/dir/dir.pro2
-rw-r--r--kabc/plugins/dir/dirE.pro2
-rw-r--r--kabc/plugins/dir/resourcedir.cpp9
-rw-r--r--kabc/plugins/file/file.pro2
-rw-r--r--kabc/plugins/file/fileE.pro2
-rw-r--r--kabc/plugins/file/resourcefile.cpp14
-rw-r--r--kabc/plugins/opie/opieE.pro2
11 files changed, 14 insertions, 30 deletions
diff --git a/kabc/distributionlist.cpp b/kabc/distributionlist.cpp
index 0735aba..1fb186e 100644
--- a/kabc/distributionlist.cpp
+++ b/kabc/distributionlist.cpp
@@ -221,75 +221,72 @@ bool DistributionListManager::save()
{
KSimpleConfig cfg( locateLocal( "data", "kabc/distlists" ) );
cfg.deleteGroup( mAddressBook->identifier() );
cfg.setGroup( mAddressBook->identifier() );
DistributionList *list;
for( list = mLists.first(); list; list = mLists.next() ) {
kdDebug(5700) << " Saving '" << list->name() << "'" << endl;
QStringList value;
DistributionList::Entry::List entries = list->entries();
DistributionList::Entry::List::ConstIterator it;
for( it = entries.begin(); it != entries.end(); ++it ) {
value.append( (*it).addressee.uid() );
if (( *it).email.isEmpty())
value.append( " " );
else
value.append( (*it).email );
// qDebug("uid *%s* email *%s* ", (*it).addressee.uid().latin1(),(*it).email.latin1() );
}
cfg.writeEntry( list->name(), value );
}
//US for microKDE we have not yet sophisticated methods to load maps.
// Because of that we store also a list of all distributionlists.
QStringList namelist;
for( list = mLists.first(); list; list = mLists.next() ) {
namelist.append( list->name() );
}
cfg.writeEntry( "__Lists__List__", namelist );
cfg.sync();
return true;
}
DistributionListWatcher* DistributionListWatcher::mSelf = 0;
DistributionListWatcher::DistributionListWatcher()
: QObject( 0, "DistributionListWatcher" )
{
-/*US
+
mDirWatch = new KDirWatch;
mDirWatch->addFile( locateLocal( "data", "kabc/distlists" ) );
connect( mDirWatch, SIGNAL( dirty( const QString& ) ), SIGNAL( changed() ) );
mDirWatch->startScan();
-*/
}
DistributionListWatcher::~DistributionListWatcher()
{
-/*US
delete mDirWatch;
mDirWatch = 0;
-*/
}
DistributionListWatcher *DistributionListWatcher::self()
{
if ( !mSelf )
mSelf = new DistributionListWatcher();
return mSelf;
}
//US #include "distributionlist.moc"
diff --git a/kabc/distributionlist.h b/kabc/distributionlist.h
index 5f091b1..584f287 100644
--- a/kabc/distributionlist.h
+++ b/kabc/distributionlist.h
@@ -165,53 +165,53 @@ class DistributionListManager
bool save();
private:
AddressBook *mAddressBook;
QPtrList<DistributionList> mLists;
};
/**
@short Watchdog for distribution lists
This class provides a @ref changed() signal that i emitted when the
distribution lists has changed in some way.
Exapmle:
<pre>
KABC::DistributionListWatcher *watchdog = KABC::DistributionListWatcher::self()
connect( watchdog, SIGNAL( changed() ), SLOT( doSomething() ) );
</pre>
*/
class DistributionListWatcher : public QObject
{
Q_OBJECT
public:
/**
* Returns the watcher object.
*/
static DistributionListWatcher *self();
signals:
/**
* This signal is emmitted whenever the distribution lists has
* changed (if a list was added or removed, when a list was
* renamed or the entries of the list changed).
*/
void changed();
protected:
DistributionListWatcher();
~DistributionListWatcher();
private:
static DistributionListWatcher* mSelf;
-//US KDirWatch *mDirWatch;
+ KDirWatch *mDirWatch;
};
}
#endif
diff --git a/kabc/kabc.pro b/kabc/kabc.pro
index 4a8d73a..a8cd695 100644
--- a/kabc/kabc.pro
+++ b/kabc/kabc.pro
@@ -1,58 +1,58 @@
TEMPLATE = lib
CONFIG += qt warn_on
#release debug
DESTDIR=../bin
TARGET = microkabc
include( ../variables.pri )
-INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../qtcompat ../microkde/kdeui
+INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../qtcompat ../microkde/kdeui
#LIBS += -lmicrokde -lldap
LIBS += -L$(QPEDIR)/lib
DEFINES += KAB_EMBEDDED DESKTOP_VERSION
unix : {
OBJECTS_DIR = obj/unix
MOC_DIR = moc/unix
}
win32: {
DEFINES += _WIN32_
OBJECTS_DIR = obj/win
MOC_DIR = moc/win
}
INTERFACES = \
HEADERS = \
resource.h \
stdaddressbook.h \
agent.h \
geo.h \
key.h \
field.h \
plugin.h \
address.h \
addresseelist.h \
formatfactory.h \
formatplugin.h \
phonenumber.h \
distributionlist.h \
distributionlistdialog.h \
distributionlisteditor.h \
vcardformatplugin.h \
formats/vcardformatplugin2.h \
picture.h \
secrecy.h \
sound.h \
addressbook.h \
timezone.h \
addressee.h \
addresseedialog.h \
vcardconverter.h \
vcard21parser.h \
vcardformatimpl.h \
plugins/file/resourcefile.h \
plugins/file/resourcefileconfig.h \
plugins/dir/resourcedir.h \
diff --git a/kabc/kabcE.pro b/kabc/kabcE.pro
index 840afb9..bc1c0ed 100644
--- a/kabc/kabcE.pro
+++ b/kabc/kabcE.pro
@@ -1,54 +1,54 @@
TEMPLATE = lib
CONFIG += qt warn_on
TARGET = microkabc
-INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../qtcompat $(QPEDIR)/include
+INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../qtcompat $(QPEDIR)/include
OBJECTS_DIR = obj/$(PLATFORM)
MOC_DIR = moc/$(PLATFORM)
DESTDIR = $(QPEDIR)/lib
LIBS += -lmicrokde
#LIBS += -lldap
LIBS += -L$(QPEDIR)/lib
DEFINES += KAB_EMBEDDED
INTERFACES = \
HEADERS = \
address.h \
addressbook.h \
addressee.h \
addresseedialog.h \
addresseelist.h \
agent.h \
distributionlist.h \
distributionlistdialog.h \
distributionlisteditor.h \
field.h \
formatfactory.h \
formatplugin.h \
geo.h \
key.h \
phonenumber.h \
picture.h \
plugin.h \
resource.h \
secrecy.h \
sound.h \
stdaddressbook.h \
timezone.h \
vcardconverter.h \
vcard21parser.h \
vcardformatimpl.h \
vcardformatplugin.h \
vcardparser/vcardline.h \
vcardparser/vcard.h \
vcardparser/vcardtool.h \
vcardparser/vcardparser.h \
vcard/include/VCardAdrParam.h \
vcard/include/VCardAdrValue.h \
vcard/include/VCardAgentParam.h \
vcard/include/VCardContentLine.h \
vcard/include/VCardDateParam.h \
vcard/include/VCardDateValue.h \
vcard/include/VCardEmailParam.h \
diff --git a/kabc/plugins/dir/dir.pro b/kabc/plugins/dir/dir.pro
index 0023029..0555484 100644
--- a/kabc/plugins/dir/dir.pro
+++ b/kabc/plugins/dir/dir.pro
@@ -1,34 +1,34 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#release debug
TARGET = microkabc_dir
-INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat
+INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat
DESTDIR = ../../../bin
#LIBS += -lmicrokde -lmicrokabc
#LIBS += -L$(QPEDIR)/lib
INTERFACES = \
HEADERS = \
resourcedir.h \
resourcedirconfig.h
SOURCES = \
resourcedir.cpp \
resourcedirconfig.cpp
unix : {
OBJECTS_DIR = obj/unix
MOC_DIR = moc/unix
}
win32: {
CONFIG += dll
DEFINES += _WIN32_
OBJECTS_DIR = obj/win
MOC_DIR = moc/win
LIBS += ../../../bin/microkdepim.lib
LIBS += ../../../bin/microkcal.lib
LIBS += ../../../bin/microkde.lib
LIBS += ../../../bin/microkabc.lib
} \ No newline at end of file
diff --git a/kabc/plugins/dir/dirE.pro b/kabc/plugins/dir/dirE.pro
index aceb28a..729f4ce 100644
--- a/kabc/plugins/dir/dirE.pro
+++ b/kabc/plugins/dir/dirE.pro
@@ -1,21 +1,21 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#release debug
TARGET = microkabc_dir
-INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat
+INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat
OBJECTS_DIR = obj/$(PLATFORM)
MOC_DIR = moc/$(PLATFORM)
DESTDIR = $(QPEDIR)/lib
LIBS += -lmicrokde -lmicrokabc
LIBS += -L$(QPEDIR)/lib
INTERFACES = \
HEADERS = \
resourcedir.h \
resourcedirconfig.h
SOURCES = \
resourcedir.cpp \
resourcedirconfig.cpp
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp
index 3cb5179..7825c6f 100644
--- a/kabc/plugins/dir/resourcedir.cpp
+++ b/kabc/plugins/dir/resourcedir.cpp
@@ -67,101 +67,99 @@ __declspec(dllexport)
#else
{
#endif
//US void *init_kabc_dir()
void *init_microkabc_dir()
{
return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>();
}
#ifndef _WIN32_
}
#endif
ResourceDir::ResourceDir( const KConfig *config )
: Resource( config )
{
QString path;
KConfig *cfg = (KConfig *)config;
if ( cfg ) {
//US path = config->readEntry( "FilePath" );
path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() );
//US mFormatName = config->readEntry( "FileFormat" );
mFormatName = cfg->readEntry( "FileFormat", "vcard" );
} else {
path = StdAddressBook::directoryName();
mFormatName = "vcard";
}
FormatFactory *factory = FormatFactory::self();
mFormat = factory->format( mFormatName );
if ( !mFormat ) {
mFormatName = "vcard";
mFormat = factory->format( mFormatName );
}
/*US
//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1());
if (mFormatName == "vcard")
mFormat = new VCardFormatPlugin2();
else if (mFormatName == "binary")
mFormat = new BinaryFormat();
else
qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1());
*/
-/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods
connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) );
connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) );
connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) );
-*/
setPath( path );
}
ResourceDir::~ResourceDir()
{
delete mFormat;
mFormat = 0;
}
void ResourceDir::writeConfig( KConfig *config )
{
config->setGroup( "Resource_" + identifier() );
Resource::writeConfig( config );
config->writeEntry( "FilePath", mPath );
config->writeEntry( "FileFormat", mFormatName );
}
Ticket *ResourceDir::requestSaveTicket()
{
kdDebug(5700) << "ResourceDir::requestSaveTicket()" << endl;
if ( !addressBook() ) return 0;
if ( !lock( mPath ) ) {
kdDebug(5700) << "ResourceDir::requestSaveTicket(): Unable to lock path '"
<< mPath << "'" << endl;
return 0;
}
return createTicket( this );
}
bool ResourceDir::doOpen()
{
QDir dir( mPath );
if ( !dir.exists() ) { // no directory available
return dir.mkdir( dir.path() );
} else {
QString testName = dir.entryList( QDir::Files )[0];
if ( testName.isNull() || testName.isEmpty() ) // no file in directory
return true;
QFile file( mPath + "/" + testName );
if ( file.open( IO_ReadOnly ) )
return true;
@@ -253,109 +251,106 @@ bool ResourceDir::lock( const QString &path )
if ( QFile::exists( lockName ) ) return false;
QString lockUniqueName;
lockUniqueName = p + KApplication::randomString( 8 );
url = lockUniqueName;
//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
// Create unique file
QFile file( mLockUniqueName );
file.open( IO_WriteOnly );
file.close();
// Create lock file
int result = 0;
#ifndef _WIN32_
result = ::link( QFile::encodeName( mLockUniqueName ),
QFile::encodeName( lockName ) );
#endif
if ( result == 0 ) {
addressBook()->emitAddressBookLocked();
return true;
}
// TODO: check stat
return false;
}
void ResourceDir::unlock( const QString &path )
{
QString p = path;
//US change the implementation how the lockfilename is getting created
//US p.replace( QRegExp( "/" ), "_" );
//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" );
KURL url(p);
QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" );
::unlink( QFile::encodeName( lockName ) );
QFile::remove( mLockUniqueName );
addressBook()->emitAddressBookUnlocked();
}
void ResourceDir::setPath( const QString &path )
{
-/*US ToDo: no synchronization so far. Has to be changed in the future
mDirWatch.stopScan();
mDirWatch.removeDir( mPath );
-*/
+
mPath = path;
-/*US ToDo: no synchronization so far. Has to be changed in the future
mDirWatch.addDir( mPath, true );
mDirWatch.startScan();
-*/
//US simulate KDirWatch event
- pathChanged();
+//US pathChanged();
}
QString ResourceDir::path() const
{
return mPath;
}
void ResourceDir::setFormat( const QString &format )
{
mFormatName = format;
if ( mFormat )
delete mFormat;
FormatFactory *factory = FormatFactory::self();
mFormat = factory->format( mFormatName );
/*US
qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1());
if (mFormatName == "vcard")
mFormat = new VCardFormatPlugin2();
else if (mFormatName == "binary")
mFormat = new BinaryFormat();
else
qDebug("ResourceDir::setFormat format unknown !!! %s ", format.latin1());
*/
}
QString ResourceDir::format() const
{
return mFormatName;
}
void ResourceDir::pathChanged()
{
if ( !addressBook() )
return;
load();
addressBook()->emitAddressBookChanged();
}
void ResourceDir::removeAddressee( const Addressee& addr )
{
QFile::remove( mPath + "/" + addr.uid() );
}
diff --git a/kabc/plugins/file/file.pro b/kabc/plugins/file/file.pro
index 7cf7c58..32555a2 100644
--- a/kabc/plugins/file/file.pro
+++ b/kabc/plugins/file/file.pro
@@ -1,35 +1,35 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#release debug
TARGET = microkabc_file
-INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat
+INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat
DESTDIR = ../../../bin
#LIBS += -lmicrokde -lmicrokabc
#LIBS += -L$(QPEDIR)/lib
INTERFACES = \
HEADERS = \
resourcefile.h \
resourcefileconfig.h
SOURCES = \
resourcefile.cpp \
resourcefileconfig.cpp
unix : {
OBJECTS_DIR = obj/unix
MOC_DIR = moc/unix
}
win32: {
CONFIG += dll
DEFINES += _WIN32_
OBJECTS_DIR = obj/win
MOC_DIR = moc/win
LIBS += ../../../bin/microkdepim.lib
LIBS += ../../../bin/microkcal.lib
LIBS += ../../../bin/microkde.lib
LIBS += ../../../bin/microkabc.lib
} \ No newline at end of file
diff --git a/kabc/plugins/file/fileE.pro b/kabc/plugins/file/fileE.pro
index 2d17a8f..d19a26d 100644
--- a/kabc/plugins/file/fileE.pro
+++ b/kabc/plugins/file/fileE.pro
@@ -1,21 +1,21 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#release debug
TARGET = microkabc_file
-INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat
+INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat
OBJECTS_DIR = obj/$(PLATFORM)
MOC_DIR = moc/$(PLATFORM)
DESTDIR = $(QPEDIR)/lib
LIBS += -lmicrokde -lmicrokabc
LIBS += -L$(QPEDIR)/lib
INTERFACES = \
HEADERS = \
resourcefile.h \
resourcefileconfig.h
SOURCES = \
resourcefile.cpp \
resourcefileconfig.cpp
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
@@ -4,178 +4,172 @@
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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
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 "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;
KConfig *cfg = (KConfig *)config;
if ( cfg ) {
fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() );
formatName = cfg->readEntry( "FileFormat", "vcard" );
// qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() );
} else {
fileName = StdAddressBook::fileName();
formatName = "vcard";
// qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() );
}
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 );
}
/*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()
{
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
bool ok = file.open( IO_WriteOnly );
if ( ok )
file.close();
@@ -281,109 +275,107 @@ bool ResourceFile::lock( const QString &fileName )
if (QFile::exists( lockName )) return false;
QString lockUniqueName;
lockUniqueName = fn + KApplication::randomString( 8 );
url = lockUniqueName;
//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
// Create unique file
QFile file( mLockUniqueName );
file.open( IO_WriteOnly );
file.close();
// Create lock file
int result = 0;
#ifndef _WIN32_
result = ::link( QFile::encodeName( mLockUniqueName ),
QFile::encodeName( lockName ) );
#endif
if ( result == 0 ) {
addressBook()->emitAddressBookLocked();
return true;
}
// 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());
}
else
qDebug("ResourceFile::setFormat format unknown !!! %s ", format.latin1());
*/
}
QString ResourceFile::format() const
{
return mFormatName;
}
void ResourceFile::fileChanged()
{
// There is a small theoretical chance that KDirWatch calls us before
// we are fully constructed
if (!addressBook())
return;
load();
addressBook()->emitAddressBookChanged();
}
void ResourceFile::removeAddressee( const Addressee &addr )
{
QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) );
diff --git a/kabc/plugins/opie/opieE.pro b/kabc/plugins/opie/opieE.pro
index 75a5dab..4048cc0 100644
--- a/kabc/plugins/opie/opieE.pro
+++ b/kabc/plugins/opie/opieE.pro
@@ -1,32 +1,32 @@
TEMPLATE = lib
CONFIG += qt warn_on
#release debug
TARGET = microkabc_opie
-INCLUDEPATH += ../.. ../../converter/opie ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include $(OPIEDIR)/include
+INCLUDEPATH += ../.. ../../converter/opie ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat $(QPEDIR)/include $(OPIEDIR)/include
OBJECTS_DIR = obj/$(PLATFORM)
MOC_DIR = moc/$(PLATFORM)
DESTDIR = $(QPEDIR)/lib
LIBS += -lmicrokde
LIBS += -lmicrokabc
LIBS += -L$(QPEDIR)/lib
LIBS += -L$(OPIEDIR)/lib
LIBS += -lopie
LIBS += -lqpe
LIBS += -lqte
LIBS += -lmicrokabc_opieconverter
#LIBS += -L../../lib/$(PLATFORM)
INTERFACES = \
HEADERS = \
resourceopie.h \
resourceopieconfig.h \
SOURCES = \
resourceopie.cpp \
resourceopieconfig.cpp \