summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp2
-rw-r--r--kabc/plugins/file/resourcefile.cpp41
-rw-r--r--kabc/plugins/file/resourcefile.h2
3 files changed, 31 insertions, 14 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index aa96210..9118c3d 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -292,13 +292,13 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
292 } 292 }
293 picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">"; 293 picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">";
294 294
295 } else { 295 } else {
296 static bool setDefaultImage = false; 296 static bool setDefaultImage = false;
297 if ( !setDefaultImage ) { 297 if ( !setDefaultImage ) {
298 qDebug("Setting default pixmap "); 298 //qDebug("Setting default pixmap ");
299 QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) ); 299 QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) );
300 setDefaultImage = true; 300 setDefaultImage = true;
301 } 301 }
302 picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">"; 302 picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">";
303 } 303 }
304 } 304 }
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index dc5932f..4ab7f02 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -52,13 +52,12 @@ $Id$
52#define NO_DIRWATCH 52#define NO_DIRWATCH
53#include "resourcefile.h" 53#include "resourcefile.h"
54 54
55//#define ALLOW_LOCKING 55//#define ALLOW_LOCKING
56 56
57 57
58
59using namespace KABC; 58using namespace KABC;
60 59
61extern "C" 60extern "C"
62#ifdef _WIN32_ 61#ifdef _WIN32_
63__declspec(dllexport) 62__declspec(dllexport)
64#else 63#else
@@ -95,12 +94,15 @@ ResourceFile::ResourceFile( const KConfig *config )
95 94
96ResourceFile::ResourceFile( const QString &fileName , 95ResourceFile::ResourceFile( const QString &fileName ,
97 const QString &formatName ) 96 const QString &formatName )
98 : Resource( 0 ) 97 : Resource( 0 )
99{ 98{
100// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); 99// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
100
101
102
101 init( fileName, formatName ); 103 init( fileName, formatName );
102} 104}
103 105
104void ResourceFile::init( const QString &fileName, const QString &formatName ) 106void ResourceFile::init( const QString &fileName, const QString &formatName )
105{ 107{
106 mFormatName = formatName; 108 mFormatName = formatName;
@@ -115,12 +117,27 @@ void ResourceFile::init( const QString &fileName, const QString &formatName )
115 117
116#ifndef NO_DIRWATCH 118#ifndef NO_DIRWATCH
117 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 119 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
118 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 120 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
119 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 121 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
120#endif 122#endif
123
124
125 QString localKdeDir;
126 localKdeDir = readEnvPath("LOCALMICROKDEHOME");
127 if ( ! localKdeDir.isEmpty() ) {
128 qDebug("LOCALMICROKDEHOME is set to: %s",localKdeDir.latin1() );
129
130
131
132
133 }
134 qDebug("RESOURCE: %s ", fileName.latin1());
135
136
137
121 setFileName( fileName ); 138 setFileName( fileName );
122} 139}
123 140
124ResourceFile::~ResourceFile() 141ResourceFile::~ResourceFile()
125{ 142{
126 delete mFormat; 143 delete mFormat;
@@ -130,13 +147,13 @@ ResourceFile::~ResourceFile()
130void ResourceFile::writeConfig( KConfig *config ) 147void ResourceFile::writeConfig( KConfig *config )
131{ 148{
132 149
133 config->setGroup( "Resource_" + identifier() ); 150 config->setGroup( "Resource_" + identifier() );
134 Resource::writeConfig( config ); 151 Resource::writeConfig( config );
135 152
136 config->writeEntry( "FileName", mFileName ); 153 config->writeEntry( "FileName", fileName() );
137 config->writeEntry( "FileFormat", mFormatName ); 154 config->writeEntry( "FileFormat", mFormatName );
138 155
139// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); 156// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
140 157
141} 158}
142 159
@@ -155,14 +172,14 @@ Ticket *ResourceFile::requestSaveTicket()
155 return createTicket( this ); 172 return createTicket( this );
156} 173}
157 174
158 175
159bool ResourceFile::doOpen() 176bool ResourceFile::doOpen()
160{ 177{
161 QFile file( mFileName ); 178 QFile file( fileName() );
162 qDebug("ResourceFile::openfile %s ", mFileName.latin1()); 179 qDebug("ResourceFile::openfile %s ", fileName().latin1());
163 180
164 if ( !file.exists() ) { 181 if ( !file.exists() ) {
165 // try to create the file 182 // try to create the file
166 bool ok = file.open( IO_WriteOnly ); 183 bool ok = file.open( IO_WriteOnly );
167 if ( ok ) 184 if ( ok )
168 file.close(); 185 file.close();
@@ -188,15 +205,15 @@ void ResourceFile::doClose()
188{ 205{
189} 206}
190 207
191bool ResourceFile::load() 208bool ResourceFile::load()
192{ 209{
193 210
194 QFile file( mFileName ); 211 QFile file( fileName() );
195 if ( !file.open( IO_ReadOnly ) ) { 212 if ( !file.open( IO_ReadOnly ) ) {
196 addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); 213 addressBook()->error( i18n( "Unable to open file '%1'." ).arg( fileName() ) );
197 return false; 214 return false;
198 } 215 }
199 216
200// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); 217// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1());
201 218
202 return mFormat->loadAll( addressBook(), this, &file ); 219 return mFormat->loadAll( addressBook(), this, &file );
@@ -226,26 +243,26 @@ bool ResourceFile::save( Ticket *ticket )
226 243
227//US ToDo: write backupfile 244//US ToDo: write backupfile
228#ifndef NO_DIRWATCH 245#ifndef NO_DIRWATCH
229 mDirWatch.stopScan(); 246 mDirWatch.stopScan();
230#endif 247#endif
231 QFile info; 248 QFile info;
232 info.setName( mFileName ); 249 info.setName( fileName() );
233 bool ok = info.open( IO_WriteOnly ); 250 bool ok = info.open( IO_WriteOnly );
234 if ( ok ) { 251 if ( ok ) {
235 mFormat->saveAll( addressBook(), this, &info ); 252 mFormat->saveAll( addressBook(), this, &info );
236 253
237 info.close(); 254 info.close();
238 ok = true; 255 ok = true;
239 } 256 }
240 else { 257 else {
241 258
242 } 259 }
243 260
244 if ( !ok ) 261 if ( !ok )
245 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); 262 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( fileName() ) );
246#ifndef NO_DIRWATCH 263#ifndef NO_DIRWATCH
247 mDirWatch.startScan(); 264 mDirWatch.startScan();
248#endif 265#endif
249 delete ticket; 266 delete ticket;
250#ifdef ALLOW_LOCKING 267#ifdef ALLOW_LOCKING
251 unlock( mFileName ); 268 unlock( mFileName );
@@ -331,22 +348,22 @@ void ResourceFile::setFileName( const QString &fileName )
331 mFileName = fileName; 348 mFileName = fileName;
332 349
333 350
334 mDirWatch.addFile( mFileName ); 351 mDirWatch.addFile( mFileName );
335 mDirWatch.startScan(); 352 mDirWatch.startScan();
336#else 353#else
337 mFileName = fileName; 354 mFileName2 = fileName;
338#endif 355#endif
339 356
340//US simulate KDirWatch event 357//US simulate KDirWatch event
341//US fileChanged(); 358//US fileChanged();
342} 359}
343 360
344QString ResourceFile::fileName() const 361QString ResourceFile::fileName() const
345{ 362{
346 return mFileName; 363 return mFileName2;
347} 364}
348 365
349void ResourceFile::setFormat( const QString &format ) 366void ResourceFile::setFormat( const QString &format )
350{ 367{
351 mFormatName = format; 368 mFormatName = format;
352 delete mFormat; 369 delete mFormat;
@@ -379,13 +396,13 @@ void ResourceFile::fileChanged()
379 // There is a small theoretical chance that KDirWatch calls us before 396 // There is a small theoretical chance that KDirWatch calls us before
380 // we are fully constructed 397 // we are fully constructed
381 if (!addressBook()) 398 if (!addressBook())
382 return; 399 return;
383 400
384 401
385 QString text( i18n( "File resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) ); 402 QString text( i18n( "File resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) );
386 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { 403 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
387 load(); 404 load();
388 addressBook()->emitAddressBookChanged(); 405 addressBook()->emitAddressBookChanged();
389 } 406 }
390} 407}
391 408
@@ -395,10 +412,10 @@ void ResourceFile::removeAddressee( const Addressee &addr )
395 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) ); 412 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) );
396 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) ); 413 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) );
397} 414}
398 415
399void ResourceFile::cleanUp() 416void ResourceFile::cleanUp()
400{ 417{
401 unlock( mFileName ); 418 unlock( fileName() );
402} 419}
403 420
404//US #include "resourcefile.moc" 421//US #include "resourcefile.moc"
diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h
index b4421b2..dd38a9d 100644
--- a/kabc/plugins/file/resourcefile.h
+++ b/kabc/plugins/file/resourcefile.h
@@ -144,13 +144,13 @@ protected:
144 void init( const QString &fileName, const QString &format ); 144 void init( const QString &fileName, const QString &format );
145 145
146 bool lock( const QString &fileName ); 146 bool lock( const QString &fileName );
147 void unlock( const QString &fileName ); 147 void unlock( const QString &fileName );
148 148
149private: 149private:
150 QString mFileName; 150 QString mFileName2;
151 QString mFormatName; 151 QString mFormatName;
152 152
153 FormatPlugin *mFormat; 153 FormatPlugin *mFormat;
154 154
155 QString mLockUniqueName; 155 QString mLockUniqueName;
156#ifndef NO_DIRWATCH 156#ifndef NO_DIRWATCH