summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-07-15 05:06:06 (UTC)
committer ulf69 <ulf69>2004-07-15 05:06:06 (UTC)
commit59f727076930aada485db6531d4084f2bfe0b928 (patch) (unidiff)
treed68ab61d9f78759d36d8ccb2cdd3312987bf7917
parent2ada2bfd67b5488115268e6667e55a9b4b297fa2 (diff)
downloadkdepimpi-59f727076930aada485db6531d4084f2bfe0b928.zip
kdepimpi-59f727076930aada485db6531d4084f2bfe0b928.tar.gz
kdepimpi-59f727076930aada485db6531d4084f2bfe0b928.tar.bz2
ask for readwrite resources if the user wants them to reload in the case of an
external change.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/dir/resourcedir.cpp10
-rw-r--r--kabc/plugins/file/resourcefile.cpp10
-rw-r--r--kabc/plugins/opie/resourceopie.cpp12
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp9
-rw-r--r--kaddressbook/details/detailsviewcontainer.cpp3
-rw-r--r--kaddressbook/kabcore.cpp1
6 files changed, 33 insertions, 12 deletions
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp
index 7825c6f..52863d5 100644
--- a/kabc/plugins/dir/resourcedir.cpp
+++ b/kabc/plugins/dir/resourcedir.cpp
@@ -31,44 +31,43 @@ $Id$
31#ifndef _WIN32_ 31#ifndef _WIN32_
32#include <unistd.h> 32#include <unistd.h>
33#endif 33#endif
34 34
35#include <qregexp.h> 35#include <qregexp.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qwidget.h> 37#include <qwidget.h>
38 38
39#include <kapplication.h> 39#include <kapplication.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <kdebug.h> 41#include <kdebug.h>
42//US #include <kgenericfactory.h> 42//US #include <kgenericfactory.h>
43#include <kglobal.h> 43#include <kglobal.h>
44#include <klocale.h> 44#include <klocale.h>
45#include <kstandarddirs.h> 45#include <kstandarddirs.h>
46#include <kurlrequester.h> 46#include <kurlrequester.h>
47#include <kmessagebox.h>
47 48
48#include "addressbook.h" 49#include "addressbook.h"
49 50
50#include "formatfactory.h" 51#include "formatfactory.h"
51 52
52#include "resourcedirconfig.h" 53#include "resourcedirconfig.h"
53#include "stdaddressbook.h" 54#include "stdaddressbook.h"
54 55
55//US 56//US
56#include <qdir.h> 57#include <qdir.h>
57//US #include "../../formats/vcardformatplugin2.h"
58//US #include "../../formats/binaryformat.h"
59 58
60#include "resourcedir.h" 59#include "resourcedir.h"
61 60
62using namespace KABC; 61using namespace KABC;
63 62
64extern "C" 63extern "C"
65#ifdef _WIN32_ 64#ifdef _WIN32_
66__declspec(dllexport) 65__declspec(dllexport)
67#else 66#else
68{ 67{
69#endif 68#endif
70 69
71//US void *init_kabc_dir() 70//US void *init_kabc_dir()
72 void *init_microkabc_dir() 71 void *init_microkabc_dir()
73 { 72 {
74 return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>(); 73 return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>();
@@ -332,31 +331,34 @@ qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1());
332 else 331 else
333 qDebug("ResourceDir::setFormat format unknown !!! %s ", format.latin1()); 332 qDebug("ResourceDir::setFormat format unknown !!! %s ", format.latin1());
334*/ 333*/
335 334
336} 335}
337 336
338QString ResourceDir::format() const 337QString ResourceDir::format() const
339{ 338{
340 return mFormatName; 339 return mFormatName;
341} 340}
342 341
343void ResourceDir::pathChanged() 342void ResourceDir::pathChanged()
344{ 343{
345 if ( !addressBook() ) 344 if ( !addressBook() )
346 return; 345 return;
347 346
348 load(); 347 QString text( i18n( "Dir resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mPath ) );
349 addressBook()->emitAddressBookChanged(); 348 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
349 load();
350 addressBook()->emitAddressBookChanged();
351 }
350} 352}
351 353
352void ResourceDir::removeAddressee( const Addressee& addr ) 354void ResourceDir::removeAddressee( const Addressee& addr )
353{ 355{
354 QFile::remove( mPath + "/" + addr.uid() ); 356 QFile::remove( mPath + "/" + addr.uid() );
355} 357}
356 358
357void ResourceDir::cleanUp() 359void ResourceDir::cleanUp()
358{ 360{
359 unlock( mPath ); 361 unlock( mPath );
360} 362}
361 363
362//US #include "resourcedir.moc" 364//US #include "resourcedir.moc"
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index 9f9b00f..1d3acec 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -29,32 +29,33 @@ $Id$
29#include <sys/stat.h> 29#include <sys/stat.h>
30#ifndef _WIN32_ 30#ifndef _WIN32_
31#include <unistd.h> 31#include <unistd.h>
32#endif 32#endif
33 33
34#include <qfile.h> 34#include <qfile.h>
35#include <qfileinfo.h> 35#include <qfileinfo.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qtimer.h> 37#include <qtimer.h>
38 38
39#include <kapplication.h> 39#include <kapplication.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <klocale.h> 42#include <klocale.h>
43//US #include <ksavefile.h> 43//US #include <ksavefile.h>
44#include <kstandarddirs.h> 44#include <kstandarddirs.h>
45#include <kmessagebox.h>
45 46
46#include "formatfactory.h" 47#include "formatfactory.h"
47 48
48#include "resource.h" 49#include "resource.h"
49#include "resourcefileconfig.h" 50#include "resourcefileconfig.h"
50#include "stdaddressbook.h" 51#include "stdaddressbook.h"
51 52
52#include "resourcefile.h" 53#include "resourcefile.h"
53 54
54using namespace KABC; 55using namespace KABC;
55 56
56extern "C" 57extern "C"
57#ifdef _WIN32_ 58#ifdef _WIN32_
58__declspec(dllexport) 59__declspec(dllexport)
59#else 60#else
60{ 61{
@@ -359,33 +360,38 @@ void ResourceFile::setFormat( const QString &format )
359 qDebug("ResourceFile::setFormat format unknown !!! %s ", format.latin1()); 360 qDebug("ResourceFile::setFormat format unknown !!! %s ", format.latin1());
360*/ 361*/
361 362
362} 363}
363 364
364QString ResourceFile::format() const 365QString ResourceFile::format() const
365{ 366{
366 return mFormatName; 367 return mFormatName;
367} 368}
368 369
369void ResourceFile::fileChanged() 370void ResourceFile::fileChanged()
370{ 371{
371 // There is a small theoretical chance that KDirWatch calls us before 372 // There is a small theoretical chance that KDirWatch calls us before
372 // we are fully constructed 373 // we are fully constructed
373 if (!addressBook()) 374 if (!addressBook())
374 return; 375 return;
375 load(); 376
376 addressBook()->emitAddressBookChanged(); 377
378 QString text( i18n( "File resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) );
379 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
380 load();
381 addressBook()->emitAddressBookChanged();
382 }
377} 383}
378 384
379void ResourceFile::removeAddressee( const Addressee &addr ) 385void ResourceFile::removeAddressee( const Addressee &addr )
380{ 386{
381 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) ); 387 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) );
382 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) ); 388 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) );
383 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) ); 389 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) );
384} 390}
385 391
386void ResourceFile::cleanUp() 392void ResourceFile::cleanUp()
387{ 393{
388 unlock( mFileName ); 394 unlock( mFileName );
389} 395}
390 396
391//US #include "resourcefile.moc" 397//US #include "resourcefile.moc"
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index 1436508..aaee801 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -27,32 +27,33 @@ $Id$
27 27
28#include <sys/types.h> 28#include <sys/types.h>
29#include <sys/stat.h> 29#include <sys/stat.h>
30#include <unistd.h> 30#include <unistd.h>
31 31
32#include <qdir.h> 32#include <qdir.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qfileinfo.h> 34#include <qfileinfo.h>
35#include <qregexp.h> 35#include <qregexp.h>
36 36
37#include <kapplication.h> 37#include <kapplication.h>
38#include <kconfig.h> 38#include <kconfig.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41//US #include <ksavefile.h> 41//US #include <ksavefile.h>
42#include <kstandarddirs.h> 42#include <kstandarddirs.h>
43#include <kmessagebox.h>
43 44
44//US #include "formatfactory.h" 45//US #include "formatfactory.h"
45//US #include <qpe/qpeapplication.h> 46//US #include <qpe/qpeapplication.h>
46 47
47#include <opie/ocontactaccess.h> 48#include <opie/ocontactaccess.h>
48#include <opie/ocontactaccessbackend_xml.h> 49#include <opie/ocontactaccessbackend_xml.h>
49 50
50#include "resourceopieconfig.h" 51#include "resourceopieconfig.h"
51#include "stdaddressbook.h" 52#include "stdaddressbook.h"
52 53
53#include "opieconverter.h" 54#include "opieconverter.h"
54 55
55#include "resourceopie.h" 56#include "resourceopie.h"
56 57
57using namespace KABC; 58using namespace KABC;
58extern "C" 59extern "C"
@@ -79,35 +80,33 @@ ResourceOpie::ResourceOpie( const KConfig *config )
79 init( fileName ); 80 init( fileName );
80} 81}
81 82
82ResourceOpie::ResourceOpie( const QString &fileName ) 83ResourceOpie::ResourceOpie( const QString &fileName )
83 : Resource( 0 ) 84 : Resource( 0 )
84{ 85{
85// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1()); 86// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1());
86 init( fileName ); 87 init( fileName );
87} 88}
88 89
89void ResourceOpie::init( const QString &fileName ) 90void ResourceOpie::init( const QString &fileName )
90{ 91{
91 92
92 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 93 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
93 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 94 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
94 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 95 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
95 96
96 //US opie addressbook is always readonly
97//US setReadOnly( true );
98 97
99 setFileName( fileName ); 98 setFileName( fileName );
100 99
101} 100}
102 101
103ResourceOpie::~ResourceOpie() 102ResourceOpie::~ResourceOpie()
104{ 103{
105 if (mConverter != 0) 104 if (mConverter != 0)
106 delete mConverter; 105 delete mConverter;
107} 106}
108 107
109void ResourceOpie::writeConfig( KConfig *config ) 108void ResourceOpie::writeConfig( KConfig *config )
110{ 109{
111 Resource::writeConfig( config ); 110 Resource::writeConfig( config );
112 111
113 config->writeEntry( "FileName", mFileName ); 112 config->writeEntry( "FileName", mFileName );
@@ -358,32 +357,39 @@ void ResourceOpie::setFileName( const QString &fileName )
358 357
359//US simulate KDirWatch event 358//US simulate KDirWatch event
360//US fileChanged(); 359//US fileChanged();
361} 360}
362 361
363QString ResourceOpie::fileName() const 362QString ResourceOpie::fileName() const
364{ 363{
365 return mFileName; 364 return mFileName;
366} 365}
367 366
368void ResourceOpie::fileChanged() 367void ResourceOpie::fileChanged()
369{ 368{
370 // There is a small theoretical chance that KDirWatch calls us before 369 // There is a small theoretical chance that KDirWatch calls us before
371 // we are fully constructed 370 // we are fully constructed
372 if (!addressBook()) 371 if (!addressBook())
373 return; 372 return;
373
374 QString text( i18n( "Opie resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) );
375 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
376 load();
377 addressBook()->emitAddressBookChanged();
378 }
379
374 load(); 380 load();
375 addressBook()->emitAddressBookChanged(); 381 addressBook()->emitAddressBookChanged();
376} 382}
377 383
378void ResourceOpie::removeAddressee( const Addressee &addr ) 384void ResourceOpie::removeAddressee( const Addressee &addr )
379{ 385{
380} 386}
381 387
382void ResourceOpie::cleanUp() 388void ResourceOpie::cleanUp()
383{ 389{
384// qDebug("ResourceOpie::cleanup() %s", mFileName.latin1()); 390// qDebug("ResourceOpie::cleanup() %s", mFileName.latin1());
385 391
386 unlock( mFileName ); 392 unlock( mFileName );
387} 393}
388 394
389//US #include "resourceopie.moc" 395//US #include "resourceopie.moc"
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 4854197..7475685 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -27,32 +27,33 @@ $Id$
27#include <sys/types.h> 27#include <sys/types.h>
28#include <sys/stat.h> 28#include <sys/stat.h>
29#include <unistd.h> 29#include <unistd.h>
30 30
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qfileinfo.h> 33#include <qfileinfo.h>
34#include <qregexp.h> 34#include <qregexp.h>
35//US #include <qtimer.h> 35//US #include <qtimer.h>
36 36
37#include <kapplication.h> 37#include <kapplication.h>
38#include <kconfig.h> 38#include <kconfig.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41//US #include <ksavefile.h> 41//US #include <ksavefile.h>
42#include <kstandarddirs.h> 42#include <kstandarddirs.h>
43#include <kmessagebox.h>
43 44
44#include <qpe/pim/addressbookaccess.h> 45#include <qpe/pim/addressbookaccess.h>
45 46
46 47
47#include "resourceqtopiaconfig.h" 48#include "resourceqtopiaconfig.h"
48#include "stdaddressbook.h" 49#include "stdaddressbook.h"
49 50
50#include "qtopiaconverter.h" 51#include "qtopiaconverter.h"
51 52
52#include "resourceqtopia.h" 53#include "resourceqtopia.h"
53 54
54using namespace KABC; 55using namespace KABC;
55extern "C" 56extern "C"
56{ 57{
57 void *init_microkabc_qtopia() 58 void *init_microkabc_qtopia()
58 { 59 {
@@ -322,30 +323,34 @@ void ResourceQtopia::setFileName( const QString &fileName )
322 323
323//US simulate KDirWatch event 324//US simulate KDirWatch event
324//US fileChanged(); 325//US fileChanged();
325} 326}
326 327
327QString ResourceQtopia::fileName() const 328QString ResourceQtopia::fileName() const
328{ 329{
329 return mFileName; 330 return mFileName;
330} 331}
331 332
332void ResourceQtopia::fileChanged() 333void ResourceQtopia::fileChanged()
333{ 334{
334 // There is a small theoretical chance that KDirWatch calls us before 335 // There is a small theoretical chance that KDirWatch calls us before
335 // we are fully constructed 336 // we are fully constructed
336 if (!addressBook()) 337 if (!addressBook())
337 return; 338 return;
338 load(); 339
339 addressBook()->emitAddressBookChanged(); 340 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) );
341 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
342 load();
343 addressBook()->emitAddressBookChanged();
344 }
340} 345}
341 346
342void ResourceQtopia::removeAddressee( const Addressee &addr ) 347void ResourceQtopia::removeAddressee( const Addressee &addr )
343{ 348{
344} 349}
345 350
346void ResourceQtopia::cleanUp() 351void ResourceQtopia::cleanUp()
347{ 352{
348 unlock( mFileName ); 353 unlock( mFileName );
349} 354}
350 355
351//US #include "resourceqtopia.moc" 356//US #include "resourceqtopia.moc"
diff --git a/kaddressbook/details/detailsviewcontainer.cpp b/kaddressbook/details/detailsviewcontainer.cpp
index 8f566cf..a42499f 100644
--- a/kaddressbook/details/detailsviewcontainer.cpp
+++ b/kaddressbook/details/detailsviewcontainer.cpp
@@ -121,34 +121,35 @@ void ViewContainer::slotStyleSelected( int index )
121 << factory->description() << endl; 121 << factory->description() << endl;
122 122
123 mCurrentLook = factory->create(); 123 mCurrentLook = factory->create();
124 mDetailsStack->raiseWidget( mCurrentLook ); 124 mDetailsStack->raiseWidget( mCurrentLook );
125 125
126 connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this, 126 connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this,
127 SIGNAL( sendEmail( const QString& ) ) ); 127 SIGNAL( sendEmail( const QString& ) ) );
128 connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this, 128 connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this,
129 SIGNAL( browse( const QString& ) ) ); 129 SIGNAL( browse( const QString& ) ) );
130 } 130 }
131 131
132 mCurrentLook->restoreSettings( config ); 132 mCurrentLook->restoreSettings( config );
133 mCurrentLook->setAddressee( addr ); 133 mCurrentLook->setAddressee( addr );
134} 134}
135void ViewContainer::refreshView() 135void ViewContainer::refreshView()
136{ 136{
137 if ( mCurrentLook ) 137 if ( mCurrentLook ) {
138 mCurrentLook->setAddressee( mCurrentAddressee ); 138 mCurrentLook->setAddressee( mCurrentAddressee );
139 }
139} 140}
140 141
141void ViewContainer::setAddressee( const KABC::Addressee& addressee ) 142void ViewContainer::setAddressee( const KABC::Addressee& addressee )
142{ 143{
143 if ( mCurrentLook != 0 ) { 144 if ( mCurrentLook != 0 ) {
144 if ( addressee == mCurrentAddressee ) 145 if ( addressee == mCurrentAddressee )
145 return; 146 return;
146 else { 147 else {
147 mCurrentAddressee = addressee; 148 mCurrentAddressee = addressee;
148 mCurrentLook->setAddressee( mCurrentAddressee ); 149 mCurrentLook->setAddressee( mCurrentAddressee );
149 } 150 }
150 } 151 }
151} 152}
152 153
153KABC::Addressee ViewContainer::addressee() 154KABC::Addressee ViewContainer::addressee()
154{ 155{
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 2b07541..a7ca0ce 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1111,32 +1111,33 @@ void KABCore::addressBookChanged()
1111 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1111 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1112 ++it; 1112 ++it;
1113 } 1113 }
1114*/ 1114*/
1115 if (mEditorDialog) 1115 if (mEditorDialog)
1116 { 1116 {
1117 if (mEditorDialog->dirty()) 1117 if (mEditorDialog->dirty())
1118 { 1118 {
1119 QString text = i18n( "Data has been changed externally. Unsaved " 1119 QString text = i18n( "Data has been changed externally. Unsaved "
1120 "changes will be lost." ); 1120 "changes will be lost." );
1121 KMessageBox::information( this, text ); 1121 KMessageBox::information( this, text );
1122 } 1122 }
1123 QString currentuid = mEditorDialog->addressee().uid(); 1123 QString currentuid = mEditorDialog->addressee().uid();
1124 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1124 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1125 } 1125 }
1126 mViewManager->refreshView(); 1126 mViewManager->refreshView();
1127// mDetails->refreshView();
1127 1128
1128 1129
1129} 1130}
1130 1131
1131AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1132AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1132 const char *name ) 1133 const char *name )
1133{ 1134{
1134 1135
1135 if ( mEditorDialog == 0 ) { 1136 if ( mEditorDialog == 0 ) {
1136 mEditorDialog = new AddresseeEditorDialog( this, parent, 1137 mEditorDialog = new AddresseeEditorDialog( this, parent,
1137 name ? name : "editorDialog" ); 1138 name ? name : "editorDialog" );
1138 1139
1139 1140
1140 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1141 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1141 SLOT( contactModified( const KABC::Addressee& ) ) ); 1142 SLOT( contactModified( const KABC::Addressee& ) ) );
1142 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1143 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),