summaryrefslogtreecommitdiffabout
path: root/kabc/stdaddressbook.cpp
Side-by-side diff
Diffstat (limited to 'kabc/stdaddressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/stdaddressbook.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp
index a14ae20..43d9fde 100644
--- a/kabc/stdaddressbook.cpp
+++ b/kabc/stdaddressbook.cpp
@@ -35,48 +35,65 @@ $Id$
#include "stdaddressbook.h"
using namespace KABC;
StdAddressBook *StdAddressBook::mSelf = 0;
bool StdAddressBook::mAutomaticSave = false;
static KStaticDeleter<StdAddressBook> addressBookDeleter;
QString StdAddressBook::fileName()
{
return locateLocal( "data", "kabc/std.vcf" );
}
QString StdAddressBook::directoryName()
{
return locateLocal( "data", "kabc/stdvcf" );
}
void StdAddressBook::handleCrash()
{
StdAddressBook::self()->cleanUp();
}
+StdAddressBook *StdAddressBook::selfNoLoad()
+{
+
+ if ( !mSelf )
+ {
+ QString appdir = StdAddressBook::setTempAppDir();
+// US im am not sure why I have to use the other format here??
+#ifdef KAB_EMBEDDED
+ mSelf = addressBookDeleter.setObject( new StdAddressBook ( QString() ) );
+#else //KAB_EMBEDDED
+ addressBookDeleter.setObject( mSelf, new StdAddressBook( QString() ) );
+#endif //KAB_EMBEDDED
+ KStandardDirs::setAppDir( appdir );
+ }
+
+ return mSelf;
+}
StdAddressBook *StdAddressBook::self()
{
if ( !mSelf )
{
QString appdir = StdAddressBook::setTempAppDir();
// US im am not sure why I have to use the other format here??
#ifdef KAB_EMBEDDED
mSelf = addressBookDeleter.setObject( new StdAddressBook );
#else //KAB_EMBEDDED
addressBookDeleter.setObject( mSelf, new StdAddressBook );
#endif //KAB_EMBEDDED
KStandardDirs::setAppDir( appdir );
}
return mSelf;
}
QString StdAddressBook::setTempAppDir()
{
QString appDIR = KStandardDirs::appDir();
#ifdef DESKTOP_VERSION
QString appdir = QDir::homeDirPath();
@@ -87,62 +104,66 @@ QString StdAddressBook::setTempAppDir()
KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
#else
QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook";
KStandardDirs::setAppDir( appdir );
#endif
return appDIR;
}
StdAddressBook *StdAddressBook::self( bool onlyFastResources )
{
if ( !mSelf )
{
QString appdir =StdAddressBook::setTempAppDir();
#ifdef KAB_EMBEDDED
mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) );
#else //KAB_EMBEDDED
addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) );
#endif //KAB_EMBEDDED
KStandardDirs::setAppDir( appdir );
}
return mSelf;
}
+StdAddressBook::StdAddressBook( QString )
+ : AddressBook( "kabcrc" )
+{
+
+}
StdAddressBook::StdAddressBook()
: AddressBook( "kabcrc" )
{
- //init( false );
+ init( false );
}
StdAddressBook::StdAddressBook( bool onlyFastResources )
: AddressBook( "kabcrc" )
{
- if ( onlyFastResources )
- init( onlyFastResources );
+ init( onlyFastResources );
}
StdAddressBook::~StdAddressBook()
{
if ( mAutomaticSave )
save();
}
void StdAddressBook::init( bool )
{
KRES::Manager<Resource> *manager = resourceManager();
KRES::Manager<Resource>::ActiveIterator it;
for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
(*it)->setAddressBook( this );
if ( !(*it)->open() )
error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
}
Resource *res = standardResource();
if ( !res ) {
res = manager->createResource( "file" );
if ( res )
{