summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/opie/resourceopie.cpp
Side-by-side diff
Diffstat (limited to 'kabc/plugins/opie/resourceopie.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/opie/resourceopie.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index 3b2a6b7..a7d271f 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -76,64 +76,64 @@ ResourceOpie::ResourceOpie( const KConfig *config )
}
// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() );
init( fileName );
}
ResourceOpie::ResourceOpie( const QString &fileName )
: Resource( 0 )
{
// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1());
init( fileName );
}
void ResourceOpie::init( const QString &fileName )
{
/*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() ) );
*/
//US opie addressbook is always readonly
- setReadOnly( true );
+//US setReadOnly( true );
setFileName( fileName );
}
ResourceOpie::~ResourceOpie()
{
if (mConverter != 0)
delete mConverter;
}
void ResourceOpie::writeConfig( KConfig *config )
{
//US opie addressbook is always readonly
- setReadOnly( true );
+//US setReadOnly( true );
Resource::writeConfig( config );
config->writeEntry( "FileName", mFileName );
// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
}
Ticket *ResourceOpie::requestSaveTicket()
{
kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl;
if ( !addressBook() ) return 0;
if ( !lock( mFileName ) ) {
kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '"
<< mFileName << "'" << endl;
return 0;
}
return createTicket( this );
}
@@ -173,55 +173,65 @@ bool ResourceOpie::doOpen()
void ResourceOpie::doClose()
{
// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
}
bool ResourceOpie::load()
{
// qDebug("ResourceOpie::load() %s", mFileName.latin1());
kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl;
qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1());
OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName );
OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false);
if ( !access ) {
qDebug("Unable to load file() %s", mFileName.latin1());
addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
return false;
}
access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
+ bool res = false;
if (mConverter == 0)
+ {
mConverter = new OpieConverter();
+ res = mConverter->init();
+ if ( !res )
+ {
+ qDebug("Unable to initialize opie converter. Most likely a problem with the category file");
+ addressBook()->error( i18n( "Unable to initialize opie converter. Most likely a problem with the category file" ) );
+ delete access;
+ return false;
+ }
+ }
OContactAccess::List::Iterator it;
OContactAccess::List allList = access->allRecords();
- bool res = false;
for ( it = allList.begin(); it != allList.end(); ++it )
{
OContact c = (*it);
KABC::Addressee addressee;
res = mConverter->opieToAddressee( c, addressee );
if ( !addressee.isEmpty() && res )
{
addressee.setResource( this );
addressBook()->insertAddressee( addressee );
}
// qDebug("found %s", c.fullName().latin1());
}
delete access;
// it seems so, that deletion of access deletes backend as well
//delete backend;
return true;
}