summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-13 21:27:10 (UTC)
committer ulf69 <ulf69>2004-10-13 21:27:10 (UTC)
commit737183a5abd7d7b02048e8a939bafd0a8e803918 (patch) (unidiff)
treeddacf864a06a6669911b1d48862e564399eeb33b
parent7bb6c5f55d29ad4632b1f5c7361eee4c0d8b7cb0 (diff)
downloadkdepimpi-737183a5abd7d7b02048e8a939bafd0a8e803918.zip
kdepimpi-737183a5abd7d7b02048e8a939bafd0a8e803918.tar.gz
kdepimpi-737183a5abd7d7b02048e8a939bafd0a8e803918.tar.bz2
removal of syncresources
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp2
-rw-r--r--kabc/kabcE.pro2
-rw-r--r--kabc/plugins/dir/resourcedir.cpp7
-rw-r--r--kabc/plugins/dir/resourcedir.h2
-rw-r--r--kabc/plugins/file/resourcefile.cpp16
-rw-r--r--kabc/plugins/file/resourcefile.h4
-rw-r--r--kabc/plugins/ldap/resourceldap.cpp7
-rw-r--r--kabc/plugins/ldap/resourceldap.h2
-rw-r--r--kabc/plugins/opie/resourceopie.cpp11
-rw-r--r--kabc/plugins/opie/resourceopie.h4
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp11
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.h4
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp8
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.h4
-rw-r--r--kabc/resource.cpp32
-rw-r--r--kabc/resource.h16
-rw-r--r--kaddressbook/xxportobject.cpp4
-rw-r--r--microkde/kresources/configdialog.cpp125
-rw-r--r--microkde/kresources/configdialog.h5
-rw-r--r--microkde/kresources/configpage.cpp29
-rw-r--r--microkde/kresources/factory.cpp38
-rw-r--r--microkde/kresources/factory.h15
-rw-r--r--microkde/kresources/manager.h12
-rw-r--r--microkde/kresources/managerimpl.cpp13
-rw-r--r--microkde/kresources/managerimpl.h8
-rw-r--r--microkde/kresources/resource.cpp1
-rw-r--r--microkde/kresources/resource.h24
-rw-r--r--microkde/microkdeE.pro2
28 files changed, 91 insertions, 317 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 592d78d..c584c35 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -248,65 +248,65 @@ void AddressBook::init(const QString &config, const QString &family )
248 if ( family == "syncContact" ) { 248 if ( family == "syncContact" ) {
249 qDebug("creating sync config "); 249 qDebug("creating sync config ");
250 fami = "contact"; 250 fami = "contact";
251 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 251 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
252 con->setGroup( "General" ); 252 con->setGroup( "General" );
253 con->writeEntry( "ResourceKeys", QString("sync") ); 253 con->writeEntry( "ResourceKeys", QString("sync") );
254 con->writeEntry( "Standard", QString("sync") ); 254 con->writeEntry( "Standard", QString("sync") );
255 con->setGroup( "Resource_sync" ); 255 con->setGroup( "Resource_sync" );
256 con->writeEntry( "FileName", config ); 256 con->writeEntry( "FileName", config );
257 con->writeEntry( "FileFormat", QString("vcard") ); 257 con->writeEntry( "FileFormat", QString("vcard") );
258 con->writeEntry( "ResourceIdentifier", QString("sync") ); 258 con->writeEntry( "ResourceIdentifier", QString("sync") );
259 con->writeEntry( "ResourceName", QString("sync_res") ); 259 con->writeEntry( "ResourceName", QString("sync_res") );
260 if ( config.right(4) == ".xml" ) 260 if ( config.right(4) == ".xml" )
261 con->writeEntry( "ResourceType", QString("qtopia") ); 261 con->writeEntry( "ResourceType", QString("qtopia") );
262 else if ( config == "sharp" ) { 262 else if ( config == "sharp" ) {
263 con->writeEntry( "ResourceType", QString("sharp") ); 263 con->writeEntry( "ResourceType", QString("sharp") );
264 } else { 264 } else {
265 con->writeEntry( "ResourceType", QString("file") ); 265 con->writeEntry( "ResourceType", QString("file") );
266 } 266 }
267 //con->sync(); 267 //con->sync();
268 d->mConfig = con; 268 d->mConfig = con;
269 } 269 }
270 else 270 else
271 d->mConfig = new KConfig( locateLocal("config", config) ); 271 d->mConfig = new KConfig( locateLocal("config", config) );
272// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 272// qDebug("AddressBook::init 1 config=%s",config.latin1() );
273 } 273 }
274 else { 274 else {
275 d->mConfig = 0; 275 d->mConfig = 0;
276// qDebug("AddressBook::init 1 config=0"); 276// qDebug("AddressBook::init 1 config=0");
277 } 277 }
278 278
279//US d->mErrorHandler = 0; 279//US d->mErrorHandler = 0;
280 d->mManager = new KRES::Manager<Resource>( fami, false ); 280 d->mManager = new KRES::Manager<Resource>( fami );
281 d->mManager->readConfig( d->mConfig ); 281 d->mManager->readConfig( d->mConfig );
282 if ( family == "syncContact" ) { 282 if ( family == "syncContact" ) {
283 KRES::Manager<Resource> *manager = d->mManager; 283 KRES::Manager<Resource> *manager = d->mManager;
284 KRES::Manager<Resource>::ActiveIterator it; 284 KRES::Manager<Resource>::ActiveIterator it;
285 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 285 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
286 (*it)->setAddressBook( this ); 286 (*it)->setAddressBook( this );
287 if ( !(*it)->open() ) 287 if ( !(*it)->open() )
288 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 288 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
289 } 289 }
290 Resource *res = standardResource(); 290 Resource *res = standardResource();
291 if ( !res ) { 291 if ( !res ) {
292 qDebug("ERROR: no standard resource"); 292 qDebug("ERROR: no standard resource");
293 res = manager->createResource( "file" ); 293 res = manager->createResource( "file" );
294 if ( res ) 294 if ( res )
295 { 295 {
296 addResource( res ); 296 addResource( res );
297 } 297 }
298 else 298 else
299 qDebug(" No resource available!!!"); 299 qDebug(" No resource available!!!");
300 } 300 }
301 setStandardResource( res ); 301 setStandardResource( res );
302 manager->writeConfig(); 302 manager->writeConfig();
303 } 303 }
304 addCustomField( i18n( "Department" ), KABC::Field::Organization, 304 addCustomField( i18n( "Department" ), KABC::Field::Organization,
305 "X-Department", "KADDRESSBOOK" ); 305 "X-Department", "KADDRESSBOOK" );
306 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 306 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
307 "X-Profession", "KADDRESSBOOK" ); 307 "X-Profession", "KADDRESSBOOK" );
308 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 308 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
309 "X-AssistantsName", "KADDRESSBOOK" ); 309 "X-AssistantsName", "KADDRESSBOOK" );
310 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 310 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
311 "X-ManagersName", "KADDRESSBOOK" ); 311 "X-ManagersName", "KADDRESSBOOK" );
312 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 312 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
diff --git a/kabc/kabcE.pro b/kabc/kabcE.pro
index 061909b..96fe39e 100644
--- a/kabc/kabcE.pro
+++ b/kabc/kabcE.pro
@@ -12,65 +12,64 @@ LIBS += -lmicrokdepim
12#LIBS += -lldap 12#LIBS += -lldap
13LIBS += -L$(QPEDIR)/lib 13LIBS += -L$(QPEDIR)/lib
14DEFINES += KAB_EMBEDDED 14DEFINES += KAB_EMBEDDED
15 15
16#enable the following line if you want to get debugoutput while loading adresses 16#enable the following line if you want to get debugoutput while loading adresses
17#DEFINES += VCARD_DEBUG 17#DEFINES += VCARD_DEBUG
18 18
19INTERFACES = \ 19INTERFACES = \
20 20
21HEADERS = \ 21HEADERS = \
22 address.h \ 22 address.h \
23 addressbook.h \ 23 addressbook.h \
24 addressee.h \ 24 addressee.h \
25 addresseedialog.h \ 25 addresseedialog.h \
26 addresseelist.h \ 26 addresseelist.h \
27 addresseeview.h \ 27 addresseeview.h \
28 agent.h \ 28 agent.h \
29 distributionlist.h \ 29 distributionlist.h \
30 distributionlistdialog.h \ 30 distributionlistdialog.h \
31 distributionlisteditor.h \ 31 distributionlisteditor.h \
32 field.h \ 32 field.h \
33 formatfactory.h \ 33 formatfactory.h \
34 formatplugin.h \ 34 formatplugin.h \
35 geo.h \ 35 geo.h \
36 key.h \ 36 key.h \
37 phonenumber.h \ 37 phonenumber.h \
38 picture.h \ 38 picture.h \
39 plugin.h \ 39 plugin.h \
40 resource.h \ 40 resource.h \
41 secrecy.h \ 41 secrecy.h \
42 sound.h \ 42 sound.h \
43 stdaddressbook.h \ 43 stdaddressbook.h \
44 syncprefwidget.h \
45 timezone.h \ 44 timezone.h \
46 tmpaddressbook.h \ 45 tmpaddressbook.h \
47 vcardconverter.h \ 46 vcardconverter.h \
48 vcard21parser.h \ 47 vcard21parser.h \
49 vcardformatimpl.h \ 48 vcardformatimpl.h \
50 vcardformatplugin.h \ 49 vcardformatplugin.h \
51 vcardparser/vcardline.h \ 50 vcardparser/vcardline.h \
52 vcardparser/vcard.h \ 51 vcardparser/vcard.h \
53 vcardparser/vcardtool.h \ 52 vcardparser/vcardtool.h \
54 vcardparser/vcardparser.h \ 53 vcardparser/vcardparser.h \
55 vcard/include/VCardAdrParam.h \ 54 vcard/include/VCardAdrParam.h \
56 vcard/include/VCardAdrValue.h \ 55 vcard/include/VCardAdrValue.h \
57 vcard/include/VCardAgentParam.h \ 56 vcard/include/VCardAgentParam.h \
58 vcard/include/VCardContentLine.h \ 57 vcard/include/VCardContentLine.h \
59 vcard/include/VCardDateParam.h \ 58 vcard/include/VCardDateParam.h \
60 vcard/include/VCardDateValue.h \ 59 vcard/include/VCardDateValue.h \
61 vcard/include/VCardEmailParam.h \ 60 vcard/include/VCardEmailParam.h \
62 vcard/include/VCardGeoValue.h \ 61 vcard/include/VCardGeoValue.h \
63 vcard/include/VCardGroup.h \ 62 vcard/include/VCardGroup.h \
64 vcard/include/VCardImageParam.h \ 63 vcard/include/VCardImageParam.h \
65 vcard/include/VCardImageValue.h \ 64 vcard/include/VCardImageValue.h \
66 vcard/include/VCardLangValue.h \ 65 vcard/include/VCardLangValue.h \
67 vcard/include/VCardNValue.h \ 66 vcard/include/VCardNValue.h \
68 vcard/include/VCardParam.h \ 67 vcard/include/VCardParam.h \
69 vcard/include/VCardPhoneNumberValue.h \ 68 vcard/include/VCardPhoneNumberValue.h \
70 vcard/include/VCardSourceParam.h \ 69 vcard/include/VCardSourceParam.h \
71 vcard/include/VCardTelParam.h \ 70 vcard/include/VCardTelParam.h \
72 vcard/include/VCardTextParam.h \ 71 vcard/include/VCardTextParam.h \
73 vcard/include/VCardTextNSParam.h \ 72 vcard/include/VCardTextNSParam.h \
74 vcard/include/VCardTextValue.h \ 73 vcard/include/VCardTextValue.h \
75 vcard/include/VCardTextBinParam.h \ 74 vcard/include/VCardTextBinParam.h \
76 vcard/include/VCardURIValue.h \ 75 vcard/include/VCardURIValue.h \
@@ -117,65 +116,64 @@ HEADERS = \
117 vcard/include/generated/TextBinValue-generated.h \ 116 vcard/include/generated/TextBinValue-generated.h \
118 vcard/include/generated/OrgValue-generated.h \ 117 vcard/include/generated/OrgValue-generated.h \
119 vcard/include/generated/UTCValue-generated.h \ 118 vcard/include/generated/UTCValue-generated.h \
120 vcard/include/generated/ClassValue-generated.h \ 119 vcard/include/generated/ClassValue-generated.h \
121 vcard/include/generated/FloatValue-generated.h \ 120 vcard/include/generated/FloatValue-generated.h \
122 vcard/include/generated/TextListValue-generated.h 121 vcard/include/generated/TextListValue-generated.h
123 122
124 123
125 124
126 125
127SOURCES = \ 126SOURCES = \
128 address.cpp \ 127 address.cpp \
129 addressbook.cpp \ 128 addressbook.cpp \
130 addressee.cpp \ 129 addressee.cpp \
131 addresseedialog.cpp \ 130 addresseedialog.cpp \
132 addresseelist.cpp \ 131 addresseelist.cpp \
133 addresseeview.cpp \ 132 addresseeview.cpp \
134 agent.cpp \ 133 agent.cpp \
135 distributionlist.cpp \ 134 distributionlist.cpp \
136 distributionlistdialog.cpp \ 135 distributionlistdialog.cpp \
137 distributionlisteditor.cpp \ 136 distributionlisteditor.cpp \
138 field.cpp \ 137 field.cpp \
139 formatfactory.cpp \ 138 formatfactory.cpp \
140 geo.cpp \ 139 geo.cpp \
141 key.cpp \ 140 key.cpp \
142 phonenumber.cpp \ 141 phonenumber.cpp \
143 picture.cpp \ 142 picture.cpp \
144 plugin.cpp \ 143 plugin.cpp \
145 resource.cpp \ 144 resource.cpp \
146 secrecy.cpp \ 145 secrecy.cpp \
147 sound.cpp \ 146 sound.cpp \
148 stdaddressbook.cpp \ 147 stdaddressbook.cpp \
149 syncprefwidget.cpp \
150 timezone.cpp \ 148 timezone.cpp \
151 tmpaddressbook.cpp \ 149 tmpaddressbook.cpp \
152 vcardconverter.cpp \ 150 vcardconverter.cpp \
153 vcard21parser.cpp \ 151 vcard21parser.cpp \
154 vcardformatimpl.cpp \ 152 vcardformatimpl.cpp \
155 vcardformatplugin.cpp \ 153 vcardformatplugin.cpp \
156 vcardparser/vcardline.cpp \ 154 vcardparser/vcardline.cpp \
157 vcardparser/vcard.cpp \ 155 vcardparser/vcard.cpp \
158 vcardparser/vcardtool.cpp \ 156 vcardparser/vcardtool.cpp \
159 vcardparser/vcardparser.cpp \ 157 vcardparser/vcardparser.cpp \
160vcard/AdrParam.cpp \ 158vcard/AdrParam.cpp \
161vcard/AdrValue.cpp \ 159vcard/AdrValue.cpp \
162vcard/AgentParam.cpp \ 160vcard/AgentParam.cpp \
163vcard/ContentLine.cpp \ 161vcard/ContentLine.cpp \
164vcard/DateParam.cpp \ 162vcard/DateParam.cpp \
165vcard/DateValue.cpp \ 163vcard/DateValue.cpp \
166vcard/EmailParam.cpp \ 164vcard/EmailParam.cpp \
167vcard/Entity.cpp \ 165vcard/Entity.cpp \
168vcard/Enum.cpp \ 166vcard/Enum.cpp \
169vcard/GeoValue.cpp \ 167vcard/GeoValue.cpp \
170vcard/ImageParam.cpp \ 168vcard/ImageParam.cpp \
171vcard/ImageValue.cpp \ 169vcard/ImageValue.cpp \
172vcard/LangValue.cpp \ 170vcard/LangValue.cpp \
173vcard/NValue.cpp \ 171vcard/NValue.cpp \
174vcard/Param.cpp \ 172vcard/Param.cpp \
175vcard/PhoneNumberValue.cpp \ 173vcard/PhoneNumberValue.cpp \
176vcard/RToken.cpp \ 174vcard/RToken.cpp \
177vcard/SourceParam.cpp \ 175vcard/SourceParam.cpp \
178vcard/TelParam.cpp \ 176vcard/TelParam.cpp \
179vcard/TextParam.cpp \ 177vcard/TextParam.cpp \
180vcard/TextValue.cpp \ 178vcard/TextValue.cpp \
181vcard/TextBinParam.cpp \ 179vcard/TextBinParam.cpp \
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp
index e58e4f7..e2b7b08 100644
--- a/kabc/plugins/dir/resourcedir.cpp
+++ b/kabc/plugins/dir/resourcedir.cpp
@@ -29,88 +29,87 @@ $Id$
29#include <sys/types.h> 29#include <sys/types.h>
30#include <sys/stat.h> 30#include <sys/stat.h>
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#include <kmessagebox.h>
48 48
49#include "addressbook.h" 49#include "addressbook.h"
50 50
51#include "formatfactory.h" 51#include "formatfactory.h"
52 52
53#include "resourcedirconfig.h" 53#include "resourcedirconfig.h"
54#include "stdaddressbook.h" 54#include "stdaddressbook.h"
55 55
56//US 56//US
57#include <qdir.h> 57#include <qdir.h>
58 58
59#define NO_DIRWATCH 59#define NO_DIRWATCH
60#include "resourcedir.h" 60#include "resourcedir.h"
61#include "syncprefwidget.h"
62 61
63//#define ALLOW_LOCKING 62//#define ALLOW_LOCKING
64 63
65using namespace KABC; 64using namespace KABC;
66 65
67extern "C" 66extern "C"
68#ifdef _WIN32_ 67#ifdef _WIN32_
69__declspec(dllexport) 68__declspec(dllexport)
70#else 69#else
71{ 70{
72#endif 71#endif
73 72
74//US void *init_kabc_dir() 73//US void *init_kabc_dir()
75 void *init_microkabc_dir() 74 void *init_microkabc_dir()
76 { 75 {
77 return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, SyncPrefWidgetContainer>(); 76 return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>();
78 } 77 }
79#ifndef _WIN32_ 78#ifndef _WIN32_
80} 79}
81#endif 80#endif
82 81
83ResourceDir::ResourceDir( const KConfig *config, bool syncable ) 82ResourceDir::ResourceDir( const KConfig *config )
84 : Resource( config, syncable ) 83 : Resource( config )
85{ 84{
86 QString path; 85 QString path;
87 86
88 KConfig *cfg = (KConfig *)config; 87 KConfig *cfg = (KConfig *)config;
89 if ( cfg ) { 88 if ( cfg ) {
90//US path = config->readEntry( "FilePath" ); 89//US path = config->readEntry( "FilePath" );
91 path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() ); 90 path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() );
92//US mFormatName = config->readEntry( "FileFormat" ); 91//US mFormatName = config->readEntry( "FileFormat" );
93 mFormatName = cfg->readEntry( "FileFormat", "vcard" ); 92 mFormatName = cfg->readEntry( "FileFormat", "vcard" );
94 } else { 93 } else {
95 path = StdAddressBook::directoryName(); 94 path = StdAddressBook::directoryName();
96 mFormatName = "vcard"; 95 mFormatName = "vcard";
97 } 96 }
98 97
99 98
100 FormatFactory *factory = FormatFactory::self(); 99 FormatFactory *factory = FormatFactory::self();
101 mFormat = factory->format( mFormatName ); 100 mFormat = factory->format( mFormatName );
102 101
103 if ( !mFormat ) { 102 if ( !mFormat ) {
104 mFormatName = "vcard"; 103 mFormatName = "vcard";
105 mFormat = factory->format( mFormatName ); 104 mFormat = factory->format( mFormatName );
106 } 105 }
107 106
108/*US 107/*US
109//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); 108//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1());
110 if (mFormatName == "vcard") 109 if (mFormatName == "vcard")
111 mFormat = new VCardFormatPlugin2(); 110 mFormat = new VCardFormatPlugin2();
112 else if (mFormatName == "binary") 111 else if (mFormatName == "binary")
113 mFormat = new BinaryFormat(); 112 mFormat = new BinaryFormat();
114 else 113 else
115 qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1()); 114 qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1());
116*/ 115*/
diff --git a/kabc/plugins/dir/resourcedir.h b/kabc/plugins/dir/resourcedir.h
index 77cd18c..6c1e922 100644
--- a/kabc/plugins/dir/resourcedir.h
+++ b/kabc/plugins/dir/resourcedir.h
@@ -20,65 +20,65 @@
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_RESOURCEDIR_H 28#ifndef KABC_RESOURCEDIR_H
29#define KABC_RESOURCEDIR_H 29#define KABC_RESOURCEDIR_H
30 30
31#include <kconfig.h> 31#include <kconfig.h>
32#include <kdirwatch.h> 32#include <kdirwatch.h>
33 33
34#include <sys/types.h> 34#include <sys/types.h>
35 35
36#include "resource.h" 36#include "resource.h"
37 37
38class QTimer; 38class QTimer;
39 39
40namespace KABC { 40namespace KABC {
41 41
42class FormatPlugin; 42class FormatPlugin;
43 43
44/** 44/**
45 @internal 45 @internal
46*/ 46*/
47class ResourceDir : public Resource 47class ResourceDir : public Resource
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 50
51public: 51public:
52 ResourceDir( const KConfig*, bool syncable ); 52 ResourceDir( const KConfig* );
53 ~ResourceDir(); 53 ~ResourceDir();
54 54
55 virtual void writeConfig( KConfig* ); 55 virtual void writeConfig( KConfig* );
56 56
57 virtual bool doOpen(); 57 virtual bool doOpen();
58 virtual void doClose(); 58 virtual void doClose();
59 59
60 virtual Ticket *requestSaveTicket(); 60 virtual Ticket *requestSaveTicket();
61 61
62 virtual bool load(); 62 virtual bool load();
63 virtual bool save( Ticket * ); 63 virtual bool save( Ticket * );
64 64
65 /** 65 /**
66 * Set path to be used for saving. 66 * Set path to be used for saving.
67 */ 67 */
68 void setPath( const QString & ); 68 void setPath( const QString & );
69 69
70 /** 70 /**
71 * Return path used for loading and saving the address book. 71 * Return path used for loading and saving the address book.
72 */ 72 */
73 QString path() const; 73 QString path() const;
74 74
75 /** 75 /**
76 * Set the format by name. 76 * Set the format by name.
77 */ 77 */
78 void setFormat( const QString &format ); 78 void setFormat( const QString &format );
79 79
80 /** 80 /**
81 * Returns the format name. 81 * Returns the format name.
82 */ 82 */
83 QString format() const; 83 QString format() const;
84 84
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index 163f2b4..dc5932f 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -22,113 +22,109 @@
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <sys/types.h> 28#include <sys/types.h>
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#include <kmessagebox.h>
46 46
47#include "formatfactory.h" 47#include "formatfactory.h"
48 48
49#include "resource.h" 49#include "resource.h"
50#include "resourcefileconfig.h" 50#include "resourcefileconfig.h"
51#include "stdaddressbook.h" 51#include "stdaddressbook.h"
52#define NO_DIRWATCH 52#define NO_DIRWATCH
53#include "resourcefile.h" 53#include "resourcefile.h"
54#include "syncprefwidget.h"
55 54
56//#define ALLOW_LOCKING 55//#define ALLOW_LOCKING
57 56
58 57
59 58
60using namespace KABC; 59using namespace KABC;
61 60
62extern "C" 61extern "C"
63#ifdef _WIN32_ 62#ifdef _WIN32_
64__declspec(dllexport) 63__declspec(dllexport)
65#else 64#else
66{ 65{
67#endif 66#endif
68 67
69//US void *init_kabc_file() 68//US void *init_kabc_file()
70 void *init_microkabc_file() 69 void *init_microkabc_file()
71 { 70 {
72 return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, SyncPrefWidgetContainer>(); 71 return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>();
73 } 72 }
74#ifndef _WIN32_ 73#ifndef _WIN32_
75} 74}
76#endif 75#endif
77 76
78ResourceFile::ResourceFile( const KConfig *config, bool syncable ) 77ResourceFile::ResourceFile( const KConfig *config )
79 : Resource( config, syncable ) , mFormat( 0 ) 78 : Resource( config ) , mFormat( 0 )
80{ 79{
81 QString fileName, formatName, default_fileName; 80 QString fileName, formatName, default_fileName;
82 81
83 if (syncable == true) 82 default_fileName = StdAddressBook::fileName();
84 default_fileName = "/home/polo/kdepim/apps/kabc/localfile.vcf";
85 else
86 default_fileName = StdAddressBook::fileName();
87 83
88 KConfig *cfg = (KConfig *)config; 84 KConfig *cfg = (KConfig *)config;
89 if ( cfg ) { 85 if ( cfg ) {
90 fileName = cfg->readEntry( "FileName", default_fileName ); 86 fileName = cfg->readEntry( "FileName", default_fileName );
91 formatName = cfg->readEntry( "FileFormat", "vcard" ); 87 formatName = cfg->readEntry( "FileFormat", "vcard" );
92 } else { 88 } else {
93 fileName = default_fileName; 89 fileName = default_fileName;
94 formatName = "vcard"; 90 formatName = "vcard";
95 } 91 }
96 92
97 init( fileName, formatName ); 93 init( fileName, formatName );
98} 94}
99 95
100ResourceFile::ResourceFile( const QString &fileName, bool syncable , 96ResourceFile::ResourceFile( const QString &fileName ,
101 const QString &formatName ) 97 const QString &formatName )
102 : Resource( 0, syncable ) 98 : Resource( 0 )
103{ 99{
104// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); 100// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
105 init( fileName, formatName ); 101 init( fileName, formatName );
106} 102}
107 103
108void ResourceFile::init( const QString &fileName, const QString &formatName ) 104void ResourceFile::init( const QString &fileName, const QString &formatName )
109{ 105{
110 mFormatName = formatName; 106 mFormatName = formatName;
111 107
112 FormatFactory *factory = FormatFactory::self(); 108 FormatFactory *factory = FormatFactory::self();
113 mFormat = factory->format( mFormatName ); 109 mFormat = factory->format( mFormatName );
114 110
115 if ( !mFormat ) { 111 if ( !mFormat ) {
116 mFormatName = "vcard"; 112 mFormatName = "vcard";
117 mFormat = factory->format( mFormatName ); 113 mFormat = factory->format( mFormatName );
118 } 114 }
119 115
120#ifndef NO_DIRWATCH 116#ifndef NO_DIRWATCH
121 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 117 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
122 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 118 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
123 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 119 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
124#endif 120#endif
125 setFileName( fileName ); 121 setFileName( fileName );
126} 122}
127 123
128ResourceFile::~ResourceFile() 124ResourceFile::~ResourceFile()
129{ 125{
130 delete mFormat; 126 delete mFormat;
131 mFormat = 0; 127 mFormat = 0;
132} 128}
133 129
134void ResourceFile::writeConfig( KConfig *config ) 130void ResourceFile::writeConfig( KConfig *config )
diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h
index 8339340..b4421b2 100644
--- a/kabc/plugins/file/resourcefile.h
+++ b/kabc/plugins/file/resourcefile.h
@@ -29,70 +29,70 @@ $Id$
29#ifndef KABC_RESOURCEFILE_H 29#ifndef KABC_RESOURCEFILE_H
30#define KABC_RESOURCEFILE_H 30#define KABC_RESOURCEFILE_H
31 31
32#include <kconfig.h> 32#include <kconfig.h>
33#include <kdirwatch.h> 33#include <kdirwatch.h>
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36 36
37#include <resource.h> 37#include <resource.h>
38 38
39class QTimer; 39class QTimer;
40class FormatPlugin; 40class FormatPlugin;
41 41
42namespace KABC { 42namespace KABC {
43 43
44//US class FormatPlugin; 44//US class FormatPlugin;
45class ResourceConfigWidget; 45class ResourceConfigWidget;
46 46
47/** 47/**
48 @internal 48 @internal
49*/ 49*/
50class ResourceFile : public Resource 50class ResourceFile : public Resource
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54public: 54public:
55 55
56 /** 56 /**
57 Constructor. 57 Constructor.
58 58
59 @param cfg The config object where custom resource settings are stored. 59 @param cfg The config object where custom resource settings are stored.
60 */ 60 */
61 ResourceFile( const KConfig *cfg, bool syncable ); 61 ResourceFile( const KConfig *cfg );
62 62
63 /** 63 /**
64 Construct file resource on file @arg fileName using format @arg formatName. 64 Construct file resource on file @arg fileName using format @arg formatName.
65 */ 65 */
66 ResourceFile( const QString &fileName, bool syncable , const QString &formatName = "vcard" ); 66 ResourceFile( const QString &fileName , const QString &formatName = "vcard" );
67 67
68 /** 68 /**
69 * Destructor. 69 * Destructor.
70 */ 70 */
71 ~ResourceFile(); 71 ~ResourceFile();
72 72
73 /** 73 /**
74 Writes the config back. 74 Writes the config back.
75 */ 75 */
76 virtual void writeConfig( KConfig *cfg ); 76 virtual void writeConfig( KConfig *cfg );
77 77
78 /** 78 /**
79 * Tries to open the file and checks for the proper format. 79 * Tries to open the file and checks for the proper format.
80 * This method should be called before @ref load(). 80 * This method should be called before @ref load().
81 */ 81 */
82 virtual bool doOpen(); 82 virtual bool doOpen();
83 83
84 /** 84 /**
85 * Closes the file again. 85 * Closes the file again.
86 */ 86 */
87 virtual void doClose(); 87 virtual void doClose();
88 88
89 /** 89 /**
90 * Requests a save ticket, that is used by @ref save() 90 * Requests a save ticket, that is used by @ref save()
91 */ 91 */
92 virtual Ticket *requestSaveTicket(); 92 virtual Ticket *requestSaveTicket();
93 93
94 /** 94 /**
95 * Loads all addressees from file to the address book. 95 * Loads all addressees from file to the address book.
96 * Returns true if all addressees could be loaded otherwise false. 96 * Returns true if all addressees could be loaded otherwise false.
97 */ 97 */
98 virtual bool load(); 98 virtual bool load();
diff --git a/kabc/plugins/ldap/resourceldap.cpp b/kabc/plugins/ldap/resourceldap.cpp
index 17f115d..55c43af 100644
--- a/kabc/plugins/ldap/resourceldap.cpp
+++ b/kabc/plugins/ldap/resourceldap.cpp
@@ -7,82 +7,81 @@
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <kdebug.h> 28#include <kdebug.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#include <klineedit.h> 30#include <klineedit.h>
31#include <klocale.h> 31#include <klocale.h>
32#include <kconfig.h> 32#include <kconfig.h>
33#include <kstringhandler.h> 33#include <kstringhandler.h>
34 34
35#include <stdlib.h> 35#include <stdlib.h>
36 36
37#include "resourceldap.h" 37#include "resourceldap.h"
38#include "resourceldapconfig.h" 38#include "resourceldapconfig.h"
39#include "syncprefwidget.h"
40 39
41using namespace KABC; 40using namespace KABC;
42 41
43extern "C" 42extern "C"
44{ 43{
45//US void *init_kabc_ldap() 44//US void *init_kabc_ldap()
46 void *init_microkabc_ldap() 45 void *init_microkabc_ldap()
47 { 46 {
48 return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig, SyncPrefWidgetContainer>(); 47 return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig>();
49 } 48 }
50} 49}
51 50
52void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value ); 51void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value );
53 52
54 53
55ResourceLDAP::ResourceLDAP( const KConfig *config, bool syncable ) 54ResourceLDAP::ResourceLDAP( const KConfig *config )
56 : Resource( config, syncable ), mPort( 389 ), mLdap( 0 ) 55 : Resource( config ), mPort( 389 ), mLdap( 0 )
57{ 56{
58 KConfig *cfg = (KConfig *)config; 57 KConfig *cfg = (KConfig *)config;
59 if ( cfg ) { 58 if ( cfg ) {
60 mUser = cfg->readEntry( "LdapUser" ); 59 mUser = cfg->readEntry( "LdapUser" );
61 mPassword = KStringHandler::obscure( cfg->readEntry( "LdapPassword" ) ); 60 mPassword = KStringHandler::obscure( cfg->readEntry( "LdapPassword" ) );
62 mDn = cfg->readEntry( "LdapDn" ); 61 mDn = cfg->readEntry( "LdapDn" );
63 mHost = cfg->readEntry( "LdapHost" ); 62 mHost = cfg->readEntry( "LdapHost" );
64 mPort = cfg->readNumEntry( "LdapPort", 389 ); 63 mPort = cfg->readNumEntry( "LdapPort", 389 );
65 mFilter = cfg->readEntry( "LdapFilter" ); 64 mFilter = cfg->readEntry( "LdapFilter" );
66 mAnonymous = cfg->readBoolEntry( "LdapAnonymous" ); 65 mAnonymous = cfg->readBoolEntry( "LdapAnonymous" );
67 66
68 QStringList attributes = cfg->readListEntry( "LdapAttributes" ); 67 QStringList attributes = cfg->readListEntry( "LdapAttributes" );
69 for ( uint pos = 0; pos < attributes.count(); pos += 2 ) 68 for ( uint pos = 0; pos < attributes.count(); pos += 2 )
70 mAttributes.insert( attributes[ pos ], attributes[ pos + 1 ] ); 69 mAttributes.insert( attributes[ pos ], attributes[ pos + 1 ] );
71 } 70 }
72 71
73 /** 72 /**
74 If you want to add new attributes, append them here, add a 73 If you want to add new attributes, append them here, add a
75 translation string in the ctor of AttributesDialog and 74 translation string in the ctor of AttributesDialog and
76 handle them in the load() method below. 75 handle them in the load() method below.
77 These are the default values from 76 These are the default values from
78 */ 77 */
79 if ( mAttributes.count() == 0 ) { 78 if ( mAttributes.count() == 0 ) {
80 mAttributes.insert( "commonName", "cn" ); 79 mAttributes.insert( "commonName", "cn" );
81 mAttributes.insert( "formattedName", "displayName" ); 80 mAttributes.insert( "formattedName", "displayName" );
82 mAttributes.insert( "familyName", "sn" ); 81 mAttributes.insert( "familyName", "sn" );
83 mAttributes.insert( "givenName", "givenName" ); 82 mAttributes.insert( "givenName", "givenName" );
84 mAttributes.insert( "mail", "mail" ); 83 mAttributes.insert( "mail", "mail" );
85 mAttributes.insert( "mailAlias", "" ); 84 mAttributes.insert( "mailAlias", "" );
86 mAttributes.insert( "phoneNumber", "telephoneNumber" ); 85 mAttributes.insert( "phoneNumber", "telephoneNumber" );
87 mAttributes.insert( "uid", "uid" ); 86 mAttributes.insert( "uid", "uid" );
88 } 87 }
diff --git a/kabc/plugins/ldap/resourceldap.h b/kabc/plugins/ldap/resourceldap.h
index 0aad3c1..0625f30 100644
--- a/kabc/plugins/ldap/resourceldap.h
+++ b/kabc/plugins/ldap/resourceldap.h
@@ -14,65 +14,65 @@
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_RESOURCELDAP_H 28#ifndef KABC_RESOURCELDAP_H
29#define KABC_RESOURCELDAP_H 29#define KABC_RESOURCELDAP_H
30 30
31 31
32#include <lber.h> 32#include <lber.h>
33#include <ldap.h> 33#include <ldap.h>
34 34
35#include "addressbook.h" 35#include "addressbook.h"
36#include "resource.h" 36#include "resource.h"
37 37
38class KConfig; 38class KConfig;
39 39
40namespace KABC { 40namespace KABC {
41 41
42class ResourceLDAP : public Resource 42class ResourceLDAP : public Resource
43{ 43{
44public: 44public:
45 45
46 ResourceLDAP( const KConfig*, bool syncable ); 46 ResourceLDAP( const KConfig* );
47 47
48 virtual void writeConfig( KConfig* ); 48 virtual void writeConfig( KConfig* );
49 49
50 virtual bool doOpen(); 50 virtual bool doOpen();
51 virtual void doClose(); 51 virtual void doClose();
52 52
53 virtual Ticket *requestSaveTicket(); 53 virtual Ticket *requestSaveTicket();
54 54
55 virtual bool load(); 55 virtual bool load();
56 virtual bool save( Ticket * ); 56 virtual bool save( Ticket * );
57 57
58 virtual void removeAddressee( const Addressee& addr ); 58 virtual void removeAddressee( const Addressee& addr );
59 59
60 void setUser( const QString &user ); 60 void setUser( const QString &user );
61 QString user() const; 61 QString user() const;
62 62
63 void setPassword( const QString &password ); 63 void setPassword( const QString &password );
64 QString password() const; 64 QString password() const;
65 65
66 void setDn( const QString &dn ); 66 void setDn( const QString &dn );
67 QString dn() const; 67 QString dn() const;
68 68
69 void setHost( const QString &host ); 69 void setHost( const QString &host );
70 QString host() const; 70 QString host() const;
71 71
72 void setPort( int port ); 72 void setPort( int port );
73 int port() const; 73 int port() const;
74 74
75 void setFilter( const QString &filter ); 75 void setFilter( const QString &filter );
76 QString filter() const; 76 QString filter() const;
77 77
78 void setIsAnonymous( bool value ); 78 void setIsAnonymous( bool value );
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index 22237dc..f610b38 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -21,95 +21,94 @@
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
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#include <kmessagebox.h>
44 44
45//US #include "formatfactory.h" 45//US #include "formatfactory.h"
46//US #include <qpe/qpeapplication.h> 46//US #include <qpe/qpeapplication.h>
47 47
48#include <opie/ocontactaccess.h> 48#include <opie/ocontactaccess.h>
49#include <opie/ocontactaccessbackend_xml.h> 49#include <opie/ocontactaccessbackend_xml.h>
50 50
51#include "resourceopieconfig.h" 51#include "resourceopieconfig.h"
52#include "stdaddressbook.h" 52#include "stdaddressbook.h"
53#include "syncprefwidget.h"
54 53
55#include "opieconverter.h" 54#include "opieconverter.h"
56 55
57#include "resourceopie.h" 56#include "resourceopie.h"
58 57
59using namespace KABC; 58using namespace KABC;
60extern "C" 59extern "C"
61{ 60{
62 void *init_microkabc_opie() 61 void *init_microkabc_opie()
63 { 62 {
64 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, SyncPrefWidgetContainer>(); 63 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>();
65 } 64 }
66} 65}
67 66
68ResourceOpie::ResourceOpie( const KConfig *config, bool syncable ) 67ResourceOpie::ResourceOpie( const KConfig *config )
69 : Resource( config, syncable ), mAccess(0), mConverter (0) 68 : Resource( config ), mAccess(0), mConverter (0)
70{ 69{
71 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 70 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
72 71
73 KConfig *cfg = (KConfig *)config; 72 KConfig *cfg = (KConfig *)config;
74 if ( cfg ) { 73 if ( cfg ) {
75 fileName = cfg->readEntry( "FileName", fileName ); 74 fileName = cfg->readEntry( "FileName", fileName );
76 75
77 } 76 }
78 77
79 init( fileName ); 78 init( fileName );
80} 79}
81 80
82ResourceOpie::ResourceOpie( const QString &fileName, bool syncable ) 81ResourceOpie::ResourceOpie( const QString &fileName )
83 : Resource( 0, syncable ) 82 : Resource( 0 )
84{ 83{
85 init( fileName ); 84 init( fileName );
86} 85}
87 86
88void ResourceOpie::init( const QString &fileName ) 87void ResourceOpie::init( const QString &fileName )
89{ 88{
90 qDebug("ResourceOpie::init()"); 89 qDebug("ResourceOpie::init()");
91 90
92 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 91 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
93 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 92 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
94 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 93 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
95 94
96 setFileName( fileName ); 95 setFileName( fileName );
97} 96}
98 97
99ResourceOpie::~ResourceOpie() 98ResourceOpie::~ResourceOpie()
100{ 99{
101 if (mConverter != 0) 100 if (mConverter != 0)
102 delete mConverter; 101 delete mConverter;
103 102
104 if(mAccess != 0) 103 if(mAccess != 0)
105 delete mAccess; 104 delete mAccess;
106} 105}
107 106
108void ResourceOpie::writeConfig( KConfig *config ) 107void ResourceOpie::writeConfig( KConfig *config )
109{ 108{
110 Resource::writeConfig( config ); 109 Resource::writeConfig( config );
111 110
112 config->writeEntry( "FileName", fileName() ); 111 config->writeEntry( "FileName", fileName() );
113} 112}
114 113
115Ticket *ResourceOpie::requestSaveTicket() 114Ticket *ResourceOpie::requestSaveTicket()
diff --git a/kabc/plugins/opie/resourceopie.h b/kabc/plugins/opie/resourceopie.h
index d5b4ebd..9d05c70 100644
--- a/kabc/plugins/opie/resourceopie.h
+++ b/kabc/plugins/opie/resourceopie.h
@@ -28,70 +28,70 @@ $Id$
28 28
29#ifndef KABC_RESOURCEOPIE_H 29#ifndef KABC_RESOURCEOPIE_H
30#define KABC_RESOURCEOPIE_H 30#define KABC_RESOURCEOPIE_H
31 31
32#include <kconfig.h> 32#include <kconfig.h>
33#include <kdirwatch.h> 33#include <kdirwatch.h>
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36 36
37#include "resource.h" 37#include "resource.h"
38 38
39 39
40class OContactAccess; 40class OContactAccess;
41 41
42namespace KABC { 42namespace KABC {
43 43
44class ResourceConfigWidget; 44class ResourceConfigWidget;
45class OpieConverter; 45class OpieConverter;
46/** 46/**
47 @internal 47 @internal
48*/ 48*/
49class ResourceOpie : public Resource 49class ResourceOpie : public Resource
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 52
53public: 53public:
54 54
55 /** 55 /**
56 Constructor. 56 Constructor.
57 57
58 @param cfg The config object where custom resource settings are stored. 58 @param cfg The config object where custom resource settings are stored.
59 */ 59 */
60 ResourceOpie( const KConfig *cfg, bool syncable ); 60 ResourceOpie( const KConfig *cfg );
61 61
62 /** 62 /**
63 Construct file resource on file @arg fileName using format @arg formatName. 63 Construct file resource on file @arg fileName using format @arg formatName.
64 */ 64 */
65 ResourceOpie( const QString &fileName, bool syncable ); 65 ResourceOpie( const QString &fileName );
66 66
67 /** 67 /**
68 * Destructor. 68 * Destructor.
69 */ 69 */
70 ~ResourceOpie(); 70 ~ResourceOpie();
71 71
72 /** 72 /**
73 Writes the config back. 73 Writes the config back.
74 */ 74 */
75 virtual void writeConfig( KConfig *cfg ); 75 virtual void writeConfig( KConfig *cfg );
76 76
77 /** 77 /**
78 * Tries to open the file and checks for the proper format. 78 * Tries to open the file and checks for the proper format.
79 * This method should be called before @ref load(). 79 * This method should be called before @ref load().
80 */ 80 */
81 virtual bool doOpen(); 81 virtual bool doOpen();
82 82
83 /** 83 /**
84 * Closes the file again. 84 * Closes the file again.
85 */ 85 */
86 virtual void doClose(); 86 virtual void doClose();
87 87
88 /** 88 /**
89 * Requests a save ticket, that is used by @ref save() 89 * Requests a save ticket, that is used by @ref save()
90 */ 90 */
91 virtual Ticket *requestSaveTicket(); 91 virtual Ticket *requestSaveTicket();
92 92
93 /** 93 /**
94 * Loads all addressees from file to the address book. 94 * Loads all addressees from file to the address book.
95 * Returns true if all addressees could be loaded otherwise false. 95 * Returns true if all addressees could be loaded otherwise false.
96 */ 96 */
97 virtual bool load(); 97 virtual bool load();
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index f9cabcb..deb218b 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -20,87 +20,86 @@
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
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#include <kmessagebox.h>
44 44
45#include <qpe/pim/addressbookaccess.h> 45#include <qpe/pim/addressbookaccess.h>
46 46
47 47
48#include "resourceqtopiaconfig.h" 48#include "resourceqtopiaconfig.h"
49#include "stdaddressbook.h" 49#include "stdaddressbook.h"
50 50
51#include "qtopiaconverter.h" 51#include "qtopiaconverter.h"
52#include "syncprefwidget.h"
53 52
54#include "resourceqtopia.h" 53#include "resourceqtopia.h"
55 54
56using namespace KABC; 55using namespace KABC;
57extern "C" 56extern "C"
58{ 57{
59 void *init_microkabc_qtopia() 58 void *init_microkabc_qtopia()
60 { 59 {
61 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidgetContainer>(); 60 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>();
62 } 61 }
63} 62}
64 63
65ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable ) 64ResourceQtopia::ResourceQtopia( const KConfig *config )
66 : Resource( config, syncable ), mConverter (0) 65 : Resource( config ), mConverter (0)
67{ 66{
68 // we can not choose the filename. Therefore use the default to display 67 // we can not choose the filename. Therefore use the default to display
69 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 68 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
70 init( fileName ); 69 init( fileName );
71} 70}
72 71
73ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable ) 72ResourceQtopia::ResourceQtopia( const QString &fileName )
74 : Resource( 0, syncable ) 73 : Resource( 0 )
75{ 74{
76 init( fileName ); 75 init( fileName );
77} 76}
78 77
79void ResourceQtopia::init( const QString &fileName ) 78void ResourceQtopia::init( const QString &fileName )
80{ 79{
81 80
82 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 81 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
83 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 82 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
84 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 83 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
85 84
86 setFileName( fileName ); 85 setFileName( fileName );
87} 86}
88 87
89ResourceQtopia::~ResourceQtopia() 88ResourceQtopia::~ResourceQtopia()
90{ 89{
91 if (mConverter != 0) 90 if (mConverter != 0)
92 delete mConverter; 91 delete mConverter;
93 92
94 if(mAccess != 0) 93 if(mAccess != 0)
95 delete mAccess; 94 delete mAccess;
96} 95}
97 96
98void ResourceQtopia::writeConfig( KConfig *config ) 97void ResourceQtopia::writeConfig( KConfig *config )
99{ 98{
100 Resource::writeConfig( config ); 99 Resource::writeConfig( config );
101} 100}
102 101
103Ticket *ResourceQtopia::requestSaveTicket() 102Ticket *ResourceQtopia::requestSaveTicket()
104{ 103{
105 kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl; 104 kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl;
106 105
diff --git a/kabc/plugins/qtopia/resourceqtopia.h b/kabc/plugins/qtopia/resourceqtopia.h
index eace280..ff6350d 100644
--- a/kabc/plugins/qtopia/resourceqtopia.h
+++ b/kabc/plugins/qtopia/resourceqtopia.h
@@ -29,70 +29,70 @@ $Id$
29#ifndef KABC_RESOURCEOPIE_H 29#ifndef KABC_RESOURCEOPIE_H
30#define KABC_RESOURCEOPIE_H 30#define KABC_RESOURCEOPIE_H
31 31
32#include <kconfig.h> 32#include <kconfig.h>
33#include <kdirwatch.h> 33#include <kdirwatch.h>
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36 36
37#include "resource.h" 37#include "resource.h"
38 38
39class AddressBookAccess; 39class AddressBookAccess;
40 40
41namespace KABC { 41namespace KABC {
42 42
43//US class FormatPlugin; 43//US class FormatPlugin;
44class ResourceConfigWidget; 44class ResourceConfigWidget;
45class QtopiaConverter; 45class QtopiaConverter;
46 46
47/** 47/**
48 @internal 48 @internal
49*/ 49*/
50class ResourceQtopia : public Resource 50class ResourceQtopia : public Resource
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54public: 54public:
55 55
56 /** 56 /**
57 Constructor. 57 Constructor.
58 58
59 @param cfg The config object where custom resource settings are stored. 59 @param cfg The config object where custom resource settings are stored.
60 */ 60 */
61 ResourceQtopia( const KConfig *cfg, bool syncable ); 61 ResourceQtopia( const KConfig *cfg );
62 62
63 /** 63 /**
64 Construct file resource on file @arg fileName using format @arg formatName. 64 Construct file resource on file @arg fileName using format @arg formatName.
65 */ 65 */
66 ResourceQtopia( const QString &fileName, bool syncable ); 66 ResourceQtopia( const QString &fileName );
67 67
68 /** 68 /**
69 * Destructor. 69 * Destructor.
70 */ 70 */
71 ~ResourceQtopia(); 71 ~ResourceQtopia();
72 72
73 /** 73 /**
74 Writes the config back. 74 Writes the config back.
75 */ 75 */
76 virtual void writeConfig( KConfig *cfg ); 76 virtual void writeConfig( KConfig *cfg );
77 77
78 /** 78 /**
79 * Tries to open the file and checks for the proper format. 79 * Tries to open the file and checks for the proper format.
80 * This method should be called before @ref load(). 80 * This method should be called before @ref load().
81 */ 81 */
82 virtual bool doOpen(); 82 virtual bool doOpen();
83 83
84 /** 84 /**
85 * Closes the file again. 85 * Closes the file again.
86 */ 86 */
87 virtual void doClose(); 87 virtual void doClose();
88 88
89 /** 89 /**
90 * Requests a save ticket, that is used by @ref save() 90 * Requests a save ticket, that is used by @ref save()
91 */ 91 */
92 virtual Ticket *requestSaveTicket(); 92 virtual Ticket *requestSaveTicket();
93 93
94 /** 94 /**
95 * Loads all addressees from file to the address book. 95 * Loads all addressees from file to the address book.
96 * Returns true if all addressees could be loaded otherwise false. 96 * Returns true if all addressees could be loaded otherwise false.
97 */ 97 */
98 virtual bool load(); 98 virtual bool load();
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
index c013f52..2cdf4bf 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
@@ -21,81 +21,79 @@
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
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//US #include <qtimer.h> 36//US #include <qtimer.h>
37 37
38#include <kapplication.h> 38#include <kapplication.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kdebug.h> 40#include <kdebug.h>
41#include <klocale.h> 41#include <klocale.h>
42//US #include <ksavefile.h> 42//US #include <ksavefile.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kmessagebox.h> 44#include <kmessagebox.h>
45 45
46#include <sl/slzdb.h> 46#include <sl/slzdb.h>
47 47
48#include <libkdepim/ksyncprofile.h> 48#include <libkdepim/ksyncprofile.h>
49 49
50#include "resourcesharpdtmconfig.h" 50#include "resourcesharpdtmconfig.h"
51#include "resourcesharpdtm.h" 51#include "resourcesharpdtm.h"
52 52
53#include "syncprefwidget.h"
54
55#include "stdaddressbook.h" 53#include "stdaddressbook.h"
56 54
57#include "sharpdtmconverter.h" 55#include "sharpdtmconverter.h"
58//#define ALLOW_LOCKING 56//#define ALLOW_LOCKING
59using namespace KABC; 57using namespace KABC;
60extern "C" 58extern "C"
61{ 59{
62 void *init_microkabc_sharpdtm() 60 void *init_microkabc_sharpdtm()
63 { 61 {
64 return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidgetContainer>(); 62 return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>();
65 } 63 }
66} 64}
67 65
68ResourceSharpDTM::ResourceSharpDTM( const KConfig *config, bool syncable ) 66ResourceSharpDTM::ResourceSharpDTM( const KConfig *config )
69 : Resource( config, syncable ), mConverter (0) 67 : Resource( config ), mConverter (0)
70{ 68{
71 // we can not choose the filename. Therefore use the default to display 69 // we can not choose the filename. Therefore use the default to display
72 70
73 QString fileName = SlZDataBase::addressbookFileName(); 71 QString fileName = SlZDataBase::addressbookFileName();
74 init( fileName ); 72 init( fileName );
75} 73}
76 74
77ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable ) 75ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable )
78 : Resource( 0, syncable ) 76 : Resource( 0, syncable )
79{ 77{
80 init( fileName ); 78 init( fileName );
81} 79}
82 80
83void ResourceSharpDTM::init( const QString &fileName ) 81void ResourceSharpDTM::init( const QString &fileName )
84{ 82{
85 83
86 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 84 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
87 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 85 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
88 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 86 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
89 87
90 setFileName( fileName ); 88 setFileName( fileName );
91} 89}
92 90
93ResourceSharpDTM::~ResourceSharpDTM() 91ResourceSharpDTM::~ResourceSharpDTM()
94{ 92{
95 if (mConverter != 0) 93 if (mConverter != 0)
96 delete mConverter; 94 delete mConverter;
97 95
98 if(mAccess != 0) 96 if(mAccess != 0)
99 delete mAccess; 97 delete mAccess;
100} 98}
101 99
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.h b/kabc/plugins/sharpdtm/resourcesharpdtm.h
index f386e69..64d06f9 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.h
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.h
@@ -29,70 +29,70 @@ $Id$
29#ifndef KABC_RESOURCESHARPDTM_H 29#ifndef KABC_RESOURCESHARPDTM_H
30#define KABC_RESOURCESHARPDTM_H 30#define KABC_RESOURCESHARPDTM_H
31 31
32#include <kconfig.h> 32#include <kconfig.h>
33#include <kdirwatch.h> 33#include <kdirwatch.h>
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36 36
37#include "resource.h" 37#include "resource.h"
38 38
39 39
40class SlZDataBase; 40class SlZDataBase;
41 41
42namespace KABC { 42namespace KABC {
43 43
44class ResourceConfigWidget; 44class ResourceConfigWidget;
45class SharpDTMConverter; 45class SharpDTMConverter;
46 46
47/** 47/**
48 @internal 48 @internal
49*/ 49*/
50class ResourceSharpDTM : public Resource 50class ResourceSharpDTM : public Resource
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54public: 54public:
55 55
56 /** 56 /**
57 Constructor. 57 Constructor.
58 58
59 @param cfg The config object where custom resource settings are stored. 59 @param cfg The config object where custom resource settings are stored.
60 */ 60 */
61 ResourceSharpDTM( const KConfig *cfg, bool syncable ); 61 ResourceSharpDTM( const KConfig *cfg );
62 62
63 /** 63 /**
64 Construct file resource on file @arg fileName using format @arg formatName. 64 Construct file resource on file @arg fileName using format @arg formatName.
65 */ 65 */
66 ResourceSharpDTM( const QString &fileName, bool syncable ); 66 ResourceSharpDTM( const QString &fileName );
67 67
68 /** 68 /**
69 * Destructor. 69 * Destructor.
70 */ 70 */
71 ~ResourceSharpDTM(); 71 ~ResourceSharpDTM();
72 72
73 /** 73 /**
74 Writes the config back. 74 Writes the config back.
75 */ 75 */
76 virtual void writeConfig( KConfig *cfg ); 76 virtual void writeConfig( KConfig *cfg );
77 77
78 /** 78 /**
79 * Tries to open the file and checks for the proper format. 79 * Tries to open the file and checks for the proper format.
80 * This method should be called before @ref load(). 80 * This method should be called before @ref load().
81 */ 81 */
82 virtual bool doOpen(); 82 virtual bool doOpen();
83 83
84 /** 84 /**
85 * Closes the file again. 85 * Closes the file again.
86 */ 86 */
87 virtual void doClose(); 87 virtual void doClose();
88 88
89 /** 89 /**
90 * Requests a save ticket, that is used by @ref save() 90 * Requests a save ticket, that is used by @ref save()
91 */ 91 */
92 virtual Ticket *requestSaveTicket(); 92 virtual Ticket *requestSaveTicket();
93 93
94 /** 94 /**
95 * Loads all addressees from file to the address book. 95 * Loads all addressees from file to the address book.
96 * Returns true if all addressees could be loaded otherwise false. 96 * Returns true if all addressees could be loaded otherwise false.
97 */ 97 */
98 virtual bool load(); 98 virtual bool load();
diff --git a/kabc/resource.cpp b/kabc/resource.cpp
index 7b91239..267cdaf 100644
--- a/kabc/resource.cpp
+++ b/kabc/resource.cpp
@@ -1,144 +1,116 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <kdebug.h> 28#include <kdebug.h>
29 29
30#include <ksyncprofile.h>
31
32#include "resource.h" 30#include "resource.h"
33 31
34using namespace KABC; 32using namespace KABC;
35 33
36Resource::Resource( const KConfig *config, bool syncable ) 34Resource::Resource( const KConfig *config )
37 : KRES::Resource( config ), mAddressBook( 0 ), mSyncProfile( 0 ) 35 : KRES::Resource( config ), mAddressBook( 0 )
38{ 36{
39 if(syncable == true) {
40 mSyncProfile = new KSyncProfile( );
41 mSyncProfile->setName("pending" /*resourceName()*/);
42 mSyncProfile->readConfig( (KConfig *)config );
43 }
44} 37}
45 38
46Resource::~Resource() 39Resource::~Resource()
47{ 40{
48 if (mSyncProfile != 0) {
49 delete mSyncProfile;
50 }
51} 41}
52 42
53void Resource::writeConfig( KConfig *config ) 43void Resource::writeConfig( KConfig *config )
54{ 44{
55 KRES::Resource::writeConfig( config ); 45 KRES::Resource::writeConfig( config );
56
57 if(mSyncProfile != 0)
58 mSyncProfile->writeConfig( config );
59} 46}
60 47
61 48
62void Resource::setAddressBook( AddressBook *ab ) 49void Resource::setAddressBook( AddressBook *ab )
63{ 50{
64 mAddressBook = ab; 51 mAddressBook = ab;
65} 52}
66 53
67AddressBook *Resource::addressBook() 54AddressBook *Resource::addressBook()
68{ 55{
69 return mAddressBook; 56 return mAddressBook;
70} 57}
71 58
72bool Resource::doOpen() 59bool Resource::doOpen()
73{ 60{
74 return true; 61 return true;
75} 62}
76 63
77void Resource::doClose() 64void Resource::doClose()
78{ 65{
79} 66}
80 67
81Ticket *Resource::requestSaveTicket() 68Ticket *Resource::requestSaveTicket()
82{ 69{
83 return 0; 70 return 0;
84} 71}
85 72
86bool Resource::load() 73bool Resource::load()
87{ 74{
88 return true; 75 return true;
89} 76}
90 77
91bool Resource::save( Ticket * ) 78bool Resource::save( Ticket * )
92{ 79{
93 return false; 80 return false;
94} 81}
95 82
96Ticket *Resource::createTicket( Resource *resource ) 83Ticket *Resource::createTicket( Resource *resource )
97{ 84{
98 return new Ticket( resource ); 85 return new Ticket( resource );
99} 86}
100 87
101void Resource::removeAddressee( const Addressee& ) 88void Resource::removeAddressee( const Addressee& )
102{ 89{
103 // do nothing 90 // do nothing
104} 91}
105 92
106void Resource::cleanUp() 93void Resource::cleanUp()
107{ 94{
108 // do nothing 95 // do nothing
109} 96}
110 97
111bool Resource::isSyncable() const
112{
113 return (mSyncProfile != 0);
114}
115
116KSyncProfile* Resource::getSyncProfile()
117{
118 return mSyncProfile;
119}
120
121
122QString Resource::fileName() const 98QString Resource::fileName() const
123{ 99{
124 return mFileName; 100 return mFileName;
125} 101}
126 102
127void Resource::setFileName( const QString &fileName ) 103void Resource::setFileName( const QString &fileName )
128{ 104{
129 mFileName = fileName; 105 mFileName = fileName;
130} 106}
131 107
132/** 108/**
133 * Set the name of resource.You can override this method, 109 * Set the name of resource.You can override this method,
134 * but also remember to call Resource::setResourceName(). 110 * but also remember to call Resource::setResourceName().
135 */ 111 */
136void Resource::setResourceName( const QString &name ) 112void Resource::setResourceName( const QString &name )
137{ 113{
138 KRES::Resource::setResourceName(name); 114 KRES::Resource::setResourceName(name);
139 if(mSyncProfile != 0) {
140 mSyncProfile->setName( name );
141 }
142
143} 115}
144 116
diff --git a/kabc/resource.h b/kabc/resource.h
index 2024d2d..e5f0d5d 100644
--- a/kabc/resource.h
+++ b/kabc/resource.h
@@ -4,102 +4,94 @@
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_RESOURCE_H 28#ifndef KABC_RESOURCE_H
29#define KABC_RESOURCE_H 29#define KABC_RESOURCE_H
30 30
31#include <kresources/resource.h> 31#include <kresources/resource.h>
32 32
33 33
34#include "addressbook.h" 34#include "addressbook.h"
35 35
36class KSyncProfile;
37
38namespace KABC { 36namespace KABC {
39 37
40/** 38/**
41 * @short Helper class for handling coordinated save of address books. 39 * @short Helper class for handling coordinated save of address books.
42 * 40 *
43 * This class is used as helper class for saving address book. 41 * This class is used as helper class for saving address book.
44 * @see requestSaveTicket(), save(). 42 * @see requestSaveTicket(), save().
45 */ 43 */
46class Ticket 44class Ticket
47{ 45{
48 friend class Resource; 46 friend class Resource;
49 public: 47 public:
50 Resource *resource() { return mResource; } 48 Resource *resource() { return mResource; }
51 49
52 private: 50 private:
53 Ticket( Resource *resource ) : mResource( resource ) {} 51 Ticket( Resource *resource ) : mResource( resource ) {}
54 52
55 Resource *mResource; 53 Resource *mResource;
56}; 54};
57 55
58/** 56/**
59 * @internal 57 * @internal
60 */ 58 */
61class Resource : public KRES::Resource 59class Resource : public KRES::Resource
62{ 60{
63private:
64 /**
65 * make this constructor private to force everybody to use the other one
66 */
67 Resource( const KConfig *config);
68
69public: 61public:
70 /** 62 /**
71 * Constructor 63 * Constructor
72 */ 64 */
73 Resource( const KConfig *config, bool syncable ); 65 Resource( const KConfig *config );
74 66
75 /** 67 /**
76 * Destructor. 68 * Destructor.
77 */ 69 */
78 virtual ~Resource(); 70 virtual ~Resource();
79 71
80 /** 72 /**
81 * Sets the address book of the resource. 73 * Sets the address book of the resource.
82 */ 74 */
83 void setAddressBook( AddressBook* ); 75 void setAddressBook( AddressBook* );
84 76
85 /** 77 /**
86 * Returns a pointer to the addressbook. 78 * Returns a pointer to the addressbook.
87 */ 79 */
88 AddressBook *addressBook(); 80 AddressBook *addressBook();
89 81
90 /** 82 /**
91 * Writes the resource specific config to file. 83 * Writes the resource specific config to file.
92 */ 84 */
93 virtual void writeConfig( KConfig *config ); 85 virtual void writeConfig( KConfig *config );
94 86
95 /** 87 /**
96 * Open the resource and returns if it was successfully 88 * Open the resource and returns if it was successfully
97 */ 89 */
98 virtual bool doOpen(); 90 virtual bool doOpen();
99 91
100 92
101 /** 93 /**
102 * Request a ticket, you have to pass through @ref save() to 94 * Request a ticket, you have to pass through @ref save() to
103 * allow locking. 95 * allow locking.
104 */ 96 */
105 virtual Ticket *requestSaveTicket(); 97 virtual Ticket *requestSaveTicket();
@@ -110,62 +102,56 @@ public:
110 virtual bool load(); 102 virtual bool load();
111 103
112 /** 104 /**
113 * Save all addressees to the addressbook. 105 * Save all addressees to the addressbook.
114 * 106 *
115 * @param ticket The ticket you get by @ref requestSaveTicket() 107 * @param ticket The ticket you get by @ref requestSaveTicket()
116 */ 108 */
117 virtual bool save( Ticket *ticket ); 109 virtual bool save( Ticket *ticket );
118 110
119 /** 111 /**
120 * Removes a addressee from resource. This method is mainly 112 * Removes a addressee from resource. This method is mainly
121 * used by record-based resources like LDAP or SQL. 113 * used by record-based resources like LDAP or SQL.
122 */ 114 */
123 virtual void removeAddressee( const Addressee& addr ); 115 virtual void removeAddressee( const Addressee& addr );
124 116
125 117
126 /** 118 /**
127 * This method is called by an error handler if the application 119 * This method is called by an error handler if the application
128 * crashed 120 * crashed
129 */ 121 */
130 virtual void cleanUp(); 122 virtual void cleanUp();
131 123
132 /** 124 /**
133 * Set name of file to be used for saving. 125 * Set name of file to be used for saving.
134 */ 126 */
135 virtual void setFileName( const QString & ); 127 virtual void setFileName( const QString & );
136 128
137 /** 129 /**
138 * Return name of file used for loading and saving the address book. 130 * Return name of file used for loading and saving the address book.
139 */ 131 */
140 virtual QString fileName() const; 132 virtual QString fileName() const;
141 133
142
143 virtual bool isSyncable() const;
144
145 virtual KSyncProfile* getSyncProfile();
146
147 /** 134 /**
148 * Set the name of resource.You can override this method, 135 * Set the name of resource.You can override this method,
149 * but also remember to call Resource::setResourceName(). 136 * but also remember to call Resource::setResourceName().
150 */ 137 */
151 virtual void setResourceName( const QString &name ); 138 virtual void setResourceName( const QString &name );
152 139
153 140
154 141
155protected: 142protected:
156 Ticket *createTicket( Resource * ); 143 Ticket *createTicket( Resource * );
157 virtual void doClose(); 144 virtual void doClose();
158 145
159private: 146private:
160 AddressBook *mAddressBook; 147 AddressBook *mAddressBook;
161 KSyncProfile *mSyncProfile;
162 QString mFileName; 148 QString mFileName;
163 149
164}; 150};
165 151
166 152
167} 153}
168 154
169 155
170 156
171#endif 157#endif
diff --git a/kaddressbook/xxportobject.cpp b/kaddressbook/xxportobject.cpp
index 4351753..67e8406 100644
--- a/kaddressbook/xxportobject.cpp
+++ b/kaddressbook/xxportobject.cpp
@@ -147,125 +147,125 @@ void XXPortObject::slotExportActivated( const QString &data )
147 147
148void XXPortObject::slotImportActivated( const QString &data ) 148void XXPortObject::slotImportActivated( const QString &data )
149{ 149{
150 emit importActivated( identifier(), ( data == "<empty>" ? QString::null : data ) ); 150 emit importActivated( identifier(), ( data == "<empty>" ? QString::null : data ) );
151} 151}
152 152
153/******************************************************************** 153/********************************************************************
154 * 154 *
155 *******************************************************************/ 155 *******************************************************************/
156 156
157 157
158XXPortResourceObject::XXPortResourceObject( KABC::AddressBook *ab, QWidget *parent, 158XXPortResourceObject::XXPortResourceObject( KABC::AddressBook *ab, QWidget *parent,
159 const char *name ) 159 const char *name )
160 : XXPortObject( ab, parent, name ), mFactory(0) 160 : XXPortObject( ab, parent, name ), mFactory(0)
161{ 161{
162 mFactory = KRES::Factory::self( "tmpcontact" ); 162 mFactory = KRES::Factory::self( "tmpcontact" );
163} 163}
164 164
165XXPortResourceObject::~XXPortResourceObject() 165XXPortResourceObject::~XXPortResourceObject()
166{ 166{
167 //do not delete the factory. It is a singleton, and selfcontained 167 //do not delete the factory. It is a singleton, and selfcontained
168} 168}
169 169
170bool XXPortResourceObject::isAvailable() 170bool XXPortResourceObject::isAvailable()
171{ 171{
172 return (mFactory != 0); 172 return (mFactory != 0);
173} 173}
174 174
175 175
176bool XXPortResourceObject::_exportContacts( const KABC::AddresseeList &list, const QString& identifier, const QString& fileName ) 176bool XXPortResourceObject::_exportContacts( const KABC::AddresseeList &list, const QString& identifier, const QString& fileName )
177{ 177{
178 //create new resource 178 //create new resource
179 KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0, false )); 179 KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0 ));
180 180
181 if (mResource == 0) 181 if (mResource == 0)
182 return false; 182 return false;
183 183
184 if (fileName != QString::null) 184 if (fileName != QString::null)
185 mResource->setFileName( fileName ); 185 mResource->setFileName( fileName );
186 186
187 187
188 KABC::TmpAddressBook tmpAB; 188 KABC::TmpAddressBook tmpAB;
189 189
190 bool res = tmpAB.addResource( mResource ); 190 bool res = tmpAB.addResource( mResource );
191 if (res == false) 191 if (res == false)
192 { 192 {
193 delete mResource; 193 delete mResource;
194 return false; 194 return false;
195 } 195 }
196 196
197 res = tmpAB.load(); 197 res = tmpAB.load();
198 if (res == false) 198 if (res == false)
199 { 199 {
200 //removeResource deletes also the resource object, if the linkcount is 0 200 //removeResource deletes also the resource object, if the linkcount is 0
201 tmpAB.removeResource( mResource ); 201 tmpAB.removeResource( mResource );
202 return false; 202 return false;
203 } 203 }
204 204
205 205
206 //Now check if the file has already entries, and ask the user if he wants to delete them first. 206 //Now check if the file has already entries, and ask the user if he wants to delete them first.
207 if (tmpAB.begin() != tmpAB.end()) 207 if (tmpAB.begin() != tmpAB.end())
208 { 208 {
209 QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); 209 QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) );
210 if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { 210 if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) {
211 // Clean the database.. 211 // Clean the database..
212 tmpAB.clear(); 212 tmpAB.clear();
213 } 213 }
214 } 214 }
215 215
216 216
217 KABC::Addressee::List::ConstIterator it; 217 KABC::Addressee::List::ConstIterator it;
218 for ( it = list.begin(); it != list.end(); ++it ) { 218 for ( it = list.begin(); it != list.end(); ++it ) {
219 tmpAB.insertAddressee(*it); 219 tmpAB.insertAddressee(*it);
220 } 220 }
221 221
222 KABC::Ticket * ticket = tmpAB.requestSaveTicket(mResource); 222 KABC::Ticket * ticket = tmpAB.requestSaveTicket(mResource);
223 223
224 res = false; 224 res = false;
225 if (ticket != 0) 225 if (ticket != 0)
226 res = tmpAB.save( ticket ); 226 res = tmpAB.save( ticket );
227 227
228 //removeResource deletes also the resource object, if the linkcount is 0 228 //removeResource deletes also the resource object, if the linkcount is 0
229 tmpAB.removeResource( mResource ); 229 tmpAB.removeResource( mResource );
230 230
231 return res; 231 return res;
232} 232}
233 233
234 234
235KABC::AddresseeList XXPortResourceObject::_importContacts( const QString& identifier, const QString& fileName ) const 235KABC::AddresseeList XXPortResourceObject::_importContacts( const QString& identifier, const QString& fileName ) const
236{ 236{
237 237
238 238
239 KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0, false )); 239 KABC::Resource* mResource = (KABC::Resource*)(mFactory->resource( this->identifier(), 0 ));
240 240
241 if (mResource == 0) 241 if (mResource == 0)
242 return KABC::AddresseeList(); 242 return KABC::AddresseeList();
243 243
244 KABC::AddresseeList adrlst; 244 KABC::AddresseeList adrlst;
245 245
246 if (fileName != QString::null) 246 if (fileName != QString::null)
247 mResource->setFileName( fileName ); 247 mResource->setFileName( fileName );
248 248
249 249
250 KABC::TmpAddressBook tmpAB; 250 KABC::TmpAddressBook tmpAB;
251 251
252 bool res = tmpAB.addResource( mResource ); 252 bool res = tmpAB.addResource( mResource );
253 if (res == false) 253 if (res == false)
254 { 254 {
255 delete mResource; 255 delete mResource;
256 return KABC::AddresseeList(); 256 return KABC::AddresseeList();
257 } 257 }
258 258
259 res = tmpAB.load(); 259 res = tmpAB.load();
260 260
261 adrlst = tmpAB.allAddressees(); 261 adrlst = tmpAB.allAddressees();
262 262
263 //remove resource deletes also the Resourceobject, if the linkcount is 0 263 //remove resource deletes also the Resourceobject, if the linkcount is 0
264 tmpAB.removeResource( mResource ); 264 tmpAB.removeResource( mResource );
265 265
266 return adrlst; 266 return adrlst;
267} 267}
268 268
269 269
270 270
271#ifndef KAB_EMBEDDED 271#ifndef KAB_EMBEDDED
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp
index 030b547..24e82bc 100644
--- a/microkde/kresources/configdialog.cpp
+++ b/microkde/kresources/configdialog.cpp
@@ -12,235 +12,168 @@
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#include <klocale.h> 24#include <klocale.h>
25#include <kglobal.h> 25#include <kglobal.h>
26#include <kmessagebox.h> 26#include <kmessagebox.h>
27 27
28#include <qgroupbox.h> 28#include <qgroupbox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qvbox.h> 32#include <qvbox.h>
33 33
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qscrollview.h> 35#include <qscrollview.h>
36 36
37#include <kbuttonbox.h> 37#include <kbuttonbox.h>
38#include <kdialog.h> 38#include <kdialog.h>
39#include <klineedit.h> 39#include <klineedit.h>
40 40
41#include "factory.h" 41#include "factory.h"
42#include "configwidget.h" 42#include "configwidget.h"
43#include "configdialog.h" 43#include "configdialog.h"
44#include "syncwidget.h"
45 44
46using namespace KRES; 45using namespace KRES;
47 46
48ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, 47ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
49 Resource* resource, const char *name ) 48 Resource* resource, const char *name )
50 : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ), 49 : KDialogBase( parent, name, true, i18n( "Resource Configuration" ),
51 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget_Settings(0), mSyncWidget_Conflicts(0),mSyncWidget_Remote(0), mResource( resource ), mPersistentReadOnly(false) 50 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false)
52{ 51{
53 52
54 Factory *factory = Factory::self( resourceFamily ); 53 Factory *factory = Factory::self( resourceFamily );
55 54
56//US resize( 250, 240 ); 55//US resize( 250, 240 );
57 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); 56 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240));
58 57
59 QFrame *main; 58 QFrame *main;
60 59
61 if (!mResource->isSyncable()) 60 main = plainPage();
62 main = plainPage();
63 else
64 main = addPage("Profile");
65 61
66 QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); 62 QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() );
67 63
68 64
69 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 65 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
70 generalGroupBox->layout()->setSpacing( spacingHint() ); 66 generalGroupBox->layout()->setSpacing( spacingHint() );
71 generalGroupBox->setTitle( i18n( "General Settings" ) ); 67 generalGroupBox->setTitle( i18n( "General Settings" ) );
72 68
73 new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox ); 69 new QLabel( i18n( "Name:" ), generalGroupBox );
74 70
75 mName = new KLineEdit( generalGroupBox ); 71 mName = new KLineEdit( generalGroupBox );
76 72
77 if (!mResource->isSyncable()) { 73 new QLabel("", generalGroupBox );
78 new QLabel("", generalGroupBox ); 74 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
79 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); 75 mReadOnly->setChecked( mResource->readOnly() );
80 mReadOnly->setChecked( mResource->readOnly() ); 76
81 new QLabel("", generalGroupBox ); 77 new QLabel("", generalGroupBox );
82 mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox ); 78 mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox );
83 mIncludeInSync->setChecked( mResource->includeInSync() ); 79 mIncludeInSync->setChecked( mResource->includeInSync() );
84 }
85 80
86 mName->setText( mResource->resourceName() ); 81 mName->setText( mResource->resourceName() );
87 82
88 mainLayout->addWidget( generalGroupBox ); 83 mainLayout->addWidget( generalGroupBox );
89 84
90 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 85 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main );
91 resourceGroupBox->layout()->setSpacing( spacingHint()); 86 resourceGroupBox->layout()->setSpacing( spacingHint());
92 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) 87 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" )
93 .arg( factory->typeName( resource->type() ) ) ); 88 .arg( factory->typeName( resource->type() ) ) );
94 mainLayout->addWidget( resourceGroupBox ); 89 mainLayout->addWidget( resourceGroupBox );
95 90
96 mainLayout->addStretch(); 91 mainLayout->addStretch();
97 92
98 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); 93 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
99 if ( mConfigWidget ) { 94 if ( mConfigWidget ) {
100 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), 95 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
101 SLOT( setReadOnly( bool ) ) ); 96 SLOT( setReadOnly( bool ) ) );
97 connect( mConfigWidget, SIGNAL( setIncludeInSync( bool ) ),
98 SLOT( setIncludeInSync( bool ) ) );
102 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), 99 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ),
103 SLOT( setPersistentReadOnly( bool ) ) ); 100 SLOT( setPersistentReadOnly( bool ) ) );
104 mConfigWidget->setInEditMode( false ); 101 mConfigWidget->setInEditMode( false );
105 mConfigWidget->loadSettings( mResource ); 102 mConfigWidget->loadSettings( mResource );
106 mConfigWidget->show(); 103 mConfigWidget->show();
107 104
108 } 105 }
109 106
110 if (mResource->isSyncable())
111 {
112 SyncWidgetContainer* c = factory->syncWidgetContainer( resource->type() );
113
114 QFrame* syncPage = addPage("Settings");
115 QVBoxLayout *syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() );
116 mSyncWidget_Settings = c->generateSettingsTab(syncPage);
117 syncLayout->addWidget( mSyncWidget_Settings );
118
119 syncPage = addPage("Conflicts");
120 syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() );
121 mSyncWidget_Conflicts = c->generateConflictsTab(syncPage);
122 syncLayout->addWidget( mSyncWidget_Conflicts );
123
124 syncPage = addPage("Remote");
125 syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() );
126 mSyncWidget_Remote = c->generateRemoteTab(syncPage);
127 syncLayout->addWidget( mSyncWidget_Remote );
128
129
130 mSyncWidget_Settings->setInEditMode( false );
131 mSyncWidget_Settings->loadSettings( mResource );
132 mSyncWidget_Settings->show();
133
134 mSyncWidget_Conflicts->setInEditMode( false );
135 mSyncWidget_Conflicts->loadSettings( mResource );
136 mSyncWidget_Conflicts->show();
137
138 mSyncWidget_Remote->setInEditMode( false );
139 mSyncWidget_Remote->loadSettings( mResource );
140 mSyncWidget_Remote->show();
141
142 delete c;
143
144// QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, syncPage );
145// syncGroupBox->layout()->setSpacing( spacingHint());
146// syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) );
147// syncLayout->addWidget( syncGroupBox );
148
149// syncLayout->addStretch();
150/*US
151 mSyncWidget = factory->syncWidget( resource->type(), syncPage );
152 syncLayout->addWidget( mSyncWidget );
153 if ( mSyncWidget ) {
154 mSyncWidget->setInEditMode( false );
155 mSyncWidget->loadSettings( mResource );
156 mSyncWidget->show();
157 }
158 */
159 }
160
161
162
163 107
164 connect( mName, SIGNAL( textChanged(const QString &)), 108 connect( mName, SIGNAL( textChanged(const QString &)),
165 SLOT( slotNameChanged(const QString &))); 109 SLOT( slotNameChanged(const QString &)));
166 110
167 slotNameChanged( mName->text() ); 111 slotNameChanged( mName->text() );
168 112
169//US setMinimumSize( 400, 250 ); 113//US setMinimumSize( 400, 250 );
170 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); 114 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250));
171 115
172} 116}
173 117
174void ConfigDialog::setInEditMode( bool value ) 118void ConfigDialog::setInEditMode( bool value )
175{ 119{
176 if ( mConfigWidget ) 120 if ( mConfigWidget )
177 mConfigWidget->setInEditMode( value ); 121 mConfigWidget->setInEditMode( value );
178
179 if ( mSyncWidget_Settings )
180 mSyncWidget_Settings->setInEditMode( value );
181 if ( mSyncWidget_Conflicts )
182 mSyncWidget_Conflicts->setInEditMode( value );
183 if ( mSyncWidget_Remote )
184 mSyncWidget_Remote->setInEditMode( value );
185
186} 122}
187 123
188void ConfigDialog::slotNameChanged( const QString &text) 124void ConfigDialog::slotNameChanged( const QString &text)
189{ 125{
190 enableButtonOK( !text.isEmpty() ); 126 enableButtonOK( !text.isEmpty() );
191} 127}
192 128
193void ConfigDialog::setReadOnly( bool value ) 129void ConfigDialog::setReadOnly( bool value )
194{ 130{
195 if (!mResource->isSyncable()) {
196
197 if (mPersistentReadOnly == false) 131 if (mPersistentReadOnly == false)
198 mReadOnly->setChecked( value ); 132 mReadOnly->setChecked( value );
199 else 133 else
200 mReadOnly->setChecked( true ); 134 mReadOnly->setChecked( true );
201 }
202} 135}
203 136
204void ConfigDialog::setPersistentReadOnly( bool value ) 137void ConfigDialog::setIncludeInSync( bool value )
205{ 138{
206 if (!mResource->isSyncable()) { 139 if (mPersistentReadOnly == false)
140 mIncludeInSync->setChecked( value );
141 else
142 mIncludeInSync->setChecked( true );
143}
207 144
145void ConfigDialog::setPersistentReadOnly( bool value )
146{
208 mPersistentReadOnly = value; 147 mPersistentReadOnly = value;
209 148
210 if (value == true) 149 if (value == true) {
211 setReadOnly( true ); 150 setReadOnly( true );
151 setIncludeInSync( true );
152 }
212 153
213 mReadOnly->setEnabled( !value ); 154 mReadOnly->setEnabled( !value );
214 } 155 mIncludeInSync->setEnabled (!value );
215} 156}
216 157
158
217void ConfigDialog::accept() 159void ConfigDialog::accept()
218{ 160{
219 if ( mName->text().isEmpty() ) { 161 if ( mName->text().isEmpty() ) {
220 KMessageBox::sorry( this, mResource->isSyncable()?i18n( "Please enter a profile name" ):i18n( "Please enter a resource name" ) ); 162 KMessageBox::sorry( this, i18n( "Please enter a resource name" ) );
221 return; 163 return;
222 } 164 }
223 165
224 mResource->setResourceName( mName->text() ); 166 mResource->setResourceName( mName->text() );
225 if (!mResource->isSyncable()) 167 mResource->setReadOnly( mReadOnly->isChecked() );
226 mResource->setReadOnly( mReadOnly->isChecked() ); 168 mResource->setIncludeInSync( mIncludeInSync->isChecked() );
227 mResource->setIncludeInSync( mIncludeInSync->isChecked() );
228 169
229 if ( mConfigWidget ) { 170 if ( mConfigWidget ) {
230 // First save generic information 171 // First save generic information
231 // Also save setting of specific resource type 172 // Also save setting of specific resource type
232 mConfigWidget->saveSettings( mResource ); 173 mConfigWidget->saveSettings( mResource );
233 } 174 }
234 175
235 if ( mSyncWidget_Settings )
236 mSyncWidget_Settings->saveSettings( mResource );
237 if ( mSyncWidget_Conflicts )
238 mSyncWidget_Conflicts->saveSettings( mResource );
239 if ( mSyncWidget_Remote )
240 mSyncWidget_Remote->saveSettings( mResource );
241
242
243 KDialog::accept(); 176 KDialog::accept();
244} 177}
245 178
246//US #include "configdialog.moc" 179//US #include "configdialog.moc"
diff --git a/microkde/kresources/configdialog.h b/microkde/kresources/configdialog.h
index ed3ecab..b205975 100644
--- a/microkde/kresources/configdialog.h
+++ b/microkde/kresources/configdialog.h
@@ -2,67 +2,64 @@
2 This file is part of libkresources. 2 This file is part of libkresources.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 4 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef KRESOURCES_CONFIGDIALOG_H 22#ifndef KRESOURCES_CONFIGDIALOG_H
23#define KRESOURCES_CONFIGDIALOG_H 23#define KRESOURCES_CONFIGDIALOG_H
24 24
25#include <kdialogbase.h> 25#include <kdialogbase.h>
26 26
27class KLineEdit; 27class KLineEdit;
28class QCheckBox; 28class QCheckBox;
29class KButtonBox; 29class KButtonBox;
30 30
31namespace KRES { 31namespace KRES {
32 class Resource; 32 class Resource;
33 class ConfigWidget; 33 class ConfigWidget;
34 class SyncWidget;
35 34
36class ConfigDialog : public KDialogBase 35class ConfigDialog : public KDialogBase
37{ 36{
38 Q_OBJECT 37 Q_OBJECT
39 public: 38 public:
40 // Resource=0: create new resource 39 // Resource=0: create new resource
41 ConfigDialog( QWidget *parent, const QString& resourceFamily, 40 ConfigDialog( QWidget *parent, const QString& resourceFamily,
42 Resource* resource, const char *name = 0); 41 Resource* resource, const char *name = 0);
43 42
44 void setInEditMode( bool value ); 43 void setInEditMode( bool value );
45 44
46 protected slots: 45 protected slots:
47 void accept(); 46 void accept();
48 void setReadOnly( bool value ); 47 void setReadOnly( bool value );
48 void setIncludeInSync( bool value );
49 void setPersistentReadOnly( bool value ); 49 void setPersistentReadOnly( bool value );
50 void slotNameChanged( const QString &text); 50 void slotNameChanged( const QString &text);
51 51
52 private: 52 private:
53 ConfigWidget *mConfigWidget; 53 ConfigWidget *mConfigWidget;
54 SyncWidget *mSyncWidget_Settings;
55 SyncWidget *mSyncWidget_Conflicts;
56 SyncWidget *mSyncWidget_Remote;
57 Resource* mResource; 54 Resource* mResource;
58 55
59 KLineEdit *mName; 56 KLineEdit *mName;
60 QCheckBox *mReadOnly; 57 QCheckBox *mReadOnly;
61 QCheckBox *mIncludeInSync; 58 QCheckBox *mIncludeInSync;
62//US add a persistent readonly flag. We need that for opie and qtopia addressbooks. 59//US add a persistent readonly flag. We need that for opie and qtopia addressbooks.
63 bool mPersistentReadOnly; 60 bool mPersistentReadOnly;
64}; 61};
65 62
66} 63}
67 64
68#endif 65#endif
diff --git a/microkde/kresources/configpage.cpp b/microkde/kresources/configpage.cpp
index 02c5fb1..533be51 100644
--- a/microkde/kresources/configpage.cpp
+++ b/microkde/kresources/configpage.cpp
@@ -28,67 +28,64 @@ Copyright (c) 2004 Ulf Schenk
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qgroupbox.h> 31#include <qgroupbox.h>
32#include <qinputdialog.h> 32#include <qinputdialog.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qlayout.h> 34#include <qlayout.h>
35 35
36#include <kapplication.h> 36#include <kapplication.h>
37#include <kcombobox.h> 37#include <kcombobox.h>
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kmessagebox.h> 40#include <kmessagebox.h>
41#include <ksimpleconfig.h> 41#include <ksimpleconfig.h>
42#include <kstandarddirs.h> 42#include <kstandarddirs.h>
43#include <kurlrequester.h> 43#include <kurlrequester.h>
44#include <klistview.h> 44#include <klistview.h>
45#include <kbuttonbox.h> 45#include <kbuttonbox.h>
46//US #include <ktrader.h> 46//US #include <ktrader.h>
47 47
48#include "resource.h" 48#include "resource.h"
49#include "configdialog.h" 49#include "configdialog.h"
50 50
51#include "configpage.h" 51#include "configpage.h"
52 52
53//US 53//US
54#include <qpushbutton.h> 54#include <qpushbutton.h>
55#include <qfile.h> 55#include <qfile.h>
56#include <kglobal.h> 56#include <kglobal.h>
57 57
58using namespace KRES; 58using namespace KRES;
59 59
60const QString ConfigPage::syncfamily = "syncprofiles";
61
62
63class ConfigViewItem : public QCheckListItem 60class ConfigViewItem : public QCheckListItem
64{ 61{
65 public: 62 public:
66 ConfigViewItem( QListView *parent, Resource* resource ) : 63 ConfigViewItem( QListView *parent, Resource* resource ) :
67 QCheckListItem( parent, resource->resourceName(), CheckBox ), 64 QCheckListItem( parent, resource->resourceName(), CheckBox ),
68 mResource( resource ), 65 mResource( resource ),
69 mIsStandard( false ) 66 mIsStandard( false )
70 { 67 {
71 setText( 1, mResource->type() ); 68 setText( 1, mResource->type() );
72 setOn( mResource->isActive() ); 69 setOn( mResource->isActive() );
73 } 70 }
74 71
75 void setStandard( bool value ) 72 void setStandard( bool value )
76 { 73 {
77 setText( 2, ( value ? i18n( "Yes" ) : QString::null ) ); 74 setText( 2, ( value ? i18n( "Yes" ) : QString::null ) );
78 mIsStandard = value; 75 mIsStandard = value;
79 } 76 }
80 77
81 bool standard() const { return mIsStandard; } 78 bool standard() const { return mIsStandard; }
82 bool readOnly() const { return mResource->readOnly(); } 79 bool readOnly() const { return mResource->readOnly(); }
83 80
84 Resource *resource() { return mResource; } 81 Resource *resource() { return mResource; }
85 82
86 private: 83 private:
87 Resource* mResource; 84 Resource* mResource;
88 85
89 bool mIsStandard; 86 bool mIsStandard;
90}; 87};
91 88
92ConfigPage::ConfigPage( QWidget *parent, const char *name ) 89ConfigPage::ConfigPage( QWidget *parent, const char *name )
93 : QWidget( parent, name ), 90 : QWidget( parent, name ),
94 mCurrentManager( 0 ), 91 mCurrentManager( 0 ),
@@ -155,87 +152,85 @@ ConfigPage::ConfigPage( QWidget *parent, const char *name )
155 152
156 load(); 153 load();
157} 154}
158 155
159ConfigPage::~ConfigPage() 156ConfigPage::~ConfigPage()
160{ 157{
161 QValueList<ResourcePageInfo>::Iterator it; 158 QValueList<ResourcePageInfo>::Iterator it;
162 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) { 159 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) {
163 (*it).mManager->removeListener( this ); 160 (*it).mManager->removeListener( this );
164 delete (*it).mManager; 161 delete (*it).mManager;
165 delete (*it).mConfig; 162 delete (*it).mConfig;
166 } 163 }
167 164
168 mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() ); 165 mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() );
169 delete mConfig; 166 delete mConfig;
170 mConfig = 0; 167 mConfig = 0;
171} 168}
172 169
173void ConfigPage::load() 170void ConfigPage::load()
174{ 171{
175 kdDebug(5650) << "ConfigPage::load()" << endl; 172 kdDebug(5650) << "ConfigPage::load()" << endl;
176 173
177 mListView->clear(); 174 mListView->clear();
178 175
179//US we remove the dynamic pluginloader, and set the one family we need (contact) manually. 176//US we remove the dynamic pluginloader, and set the one family we need (contact) manually.
180 177
181//US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" ); 178//US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" );
182//US KTrader::OfferList::ConstIterator it; 179//US KTrader::OfferList::ConstIterator it;
183//US for ( it = plugins.begin(); it != plugins.end(); ++it ) { 180//US for ( it = plugins.begin(); it != plugins.end(); ++it ) {
184//US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" ); 181//US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" );
185//US QString family = tmp.toString(); 182//US QString family = tmp.toString();
186 QStringList families; 183 QStringList families;
187 families << "contact" << syncfamily; 184 families << "contact";
188 185
189 186
190 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) 187 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it )
191 { 188 {
192 QString family = (*it); 189 QString family = (*it);
193 if ( !family.isEmpty() ) { 190 if ( !family.isEmpty() ) {
194 if ( !mFamilyMap.contains( family ) ) { 191 if ( !mFamilyMap.contains( family ) ) {
195 mCurrentManager = new Manager<Resource>( family, (family == syncfamily) ); 192 mCurrentManager = new Manager<Resource>( family );
196 if ( mCurrentManager ) { 193 if ( mCurrentManager ) {
197 mFamilyMap.append( family ); 194 mFamilyMap.append( family );
198 mCurrentManager->addListener( this ); 195 mCurrentManager->addListener( this );
199 196
200 ResourcePageInfo info; 197 ResourcePageInfo info;
201 info.mManager = mCurrentManager; 198 info.mManager = mCurrentManager;
202 QString configDir = KGlobal::dirs()->saveLocation( "config" ); 199 QString configDir = KGlobal::dirs()->saveLocation( "config" );
203 //QString configDir = KStandardDirs::appDir() + "/config"; 200 //QString configDir = KStandardDirs::appDir() + "/config";
204 if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) { 201 if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) {
205 info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) ); 202 info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) );
206 } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) { 203 } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) {
207 info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) ); 204 info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) );
208 } else if ( family == syncfamily && QFile::exists( configDir + "/kabcsyncrc" ) ) {
209 info.mConfig = new KConfig( locateLocal( "config", "kabcsyncrc" ) );
210 } else { 205 } else {
211 QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) ); 206 QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) );
212 info.mConfig = new KConfig( configFile ); 207 info.mConfig = new KConfig( configFile );
213 } 208 }
214 info.mManager->readConfig( info.mConfig ); 209 info.mManager->readConfig( info.mConfig );
215 210
216 mInfoMap.append( info ); 211 mInfoMap.append( info );
217 } 212 }
218 } 213 }
219 } 214 }
220 } 215 }
221 mCurrentManager = 0; 216 mCurrentManager = 0;
222 217
223 mFamilyCombo->insertStringList( mFamilyMap ); 218 mFamilyCombo->insertStringList( mFamilyMap );
224 219
225 int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 ); 220 int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 );
226 mFamilyCombo->setCurrentItem( currentFamily ); 221 mFamilyCombo->setCurrentItem( currentFamily );
227 slotFamilyChanged( currentFamily ); 222 slotFamilyChanged( currentFamily );
228} 223}
229 224
230void ConfigPage::save() 225void ConfigPage::save()
231{ 226{
232 saveResourceSettings(); 227 saveResourceSettings();
233 228
234 QValueList<ResourcePageInfo>::Iterator it; 229 QValueList<ResourcePageInfo>::Iterator it;
235 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) 230 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it )
236 (*it).mManager->writeConfig( (*it).mConfig ); 231 (*it).mManager->writeConfig( (*it).mConfig );
237 232
238 emit changed( false ); 233 emit changed( false );
239} 234}
240 235
241void ConfigPage::defaults() 236void ConfigPage::defaults()
@@ -281,98 +276,82 @@ void ConfigPage::slotFamilyChanged( int pos )
281 276
282 if ( mListView->childCount() == 0 ) { 277 if ( mListView->childCount() == 0 ) {
283//US qDebug("ConfigPage::slotFamilyChanged 4.5 "); 278//US qDebug("ConfigPage::slotFamilyChanged 4.5 ");
284 279
285 defaults(); 280 defaults();
286 emit changed( true ); 281 emit changed( true );
287 mCurrentManager->writeConfig( mCurrentConfig ); 282 mCurrentManager->writeConfig( mCurrentConfig );
288 } else { 283 } else {
289//US qDebug("ConfigPage::slotFamilyChanged 4.6 "); 284//US qDebug("ConfigPage::slotFamilyChanged 4.6 ");
290 285
291 if ( !standardResource ) { 286 if ( !standardResource ) {
292 KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) ); 287 KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) );
293 288
294//US qDebug("ConfigPage::slotFamilyChanged 4.7" ); 289//US qDebug("ConfigPage::slotFamilyChanged 4.7" );
295 290
296 } 291 }
297 292
298 emit changed( false ); 293 emit changed( false );
299 } 294 }
300} 295}
301 296
302void ConfigPage::slotAdd() 297void ConfigPage::slotAdd()
303{ 298{
304 if ( !mCurrentManager ) 299 if ( !mCurrentManager )
305 return; 300 return;
306 301
307 QStringList types = mCurrentManager->resourceTypeNames(); 302 QStringList types = mCurrentManager->resourceTypeNames();
308 QStringList descs = mCurrentManager->resourceTypeDescriptions(); 303 QStringList descs = mCurrentManager->resourceTypeDescriptions();
309 bool ok = false; 304 bool ok = false;
310 305
311 QString desc; 306 QString desc;
312 307
313 if (mFamily == syncfamily) 308 desc = QInputDialog::getItem( i18n( "Resource Configuration" ),
314 {
315 desc = QInputDialog::getItem( i18n( "Sync Configuration" ),
316 i18n( "Select resource type for the new sync profile:" ), descs, 0,
317 false, &ok, this );
318 }
319 else
320 {
321 desc = QInputDialog::getItem( i18n( "Resource Configuration" ),
322 i18n( "Select type of the new resource:" ), descs, 0, 309 i18n( "Select type of the new resource:" ), descs, 0,
323 false, &ok, this ); 310 false, &ok, this );
324 }
325 311
326 if ( !ok ) 312 if ( !ok )
327 return; 313 return;
328 314
329 QString type = types[ descs.findIndex( desc ) ]; 315 QString type = types[ descs.findIndex( desc ) ];
330 316
331 // Create new resource 317 // Create new resource
332 Resource *resource = mCurrentManager->createResource( type ); 318 Resource *resource = mCurrentManager->createResource( type );
333 if ( !resource ) { 319 if ( !resource ) {
334 KMessageBox::error( this, i18n("Unable to create resource of type '%1'.") 320 KMessageBox::error( this, i18n("Unable to create resource of type '%1'.")
335 .arg( type ) ); 321 .arg( type ) );
336 return; 322 return;
337 } 323 }
338 324
339 if (mFamily == syncfamily) 325 resource->setResourceName( type + "-resource" );
340 {
341 resource->setResourceName( type + "-syncprofile" );
342 }
343 else
344 {
345 resource->setResourceName( type + "-resource" );
346 }
347 326
348 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" ); 327 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" );
349 328
350 if ( dlg.exec() ) { 329 if ( dlg.exec() ) {
351 mCurrentManager->add( resource ); 330 mCurrentManager->add( resource );
352 331
353 ConfigViewItem *item = new ConfigViewItem( mListView, resource ); 332 ConfigViewItem *item = new ConfigViewItem( mListView, resource );
354 333
355 mLastItem = item; 334 mLastItem = item;
356 335
357 // if there are only read-only resources we'll set this resource 336 // if there are only read-only resources we'll set this resource
358 // as standard resource 337 // as standard resource
359 if ( !resource->readOnly() ) { 338 if ( !resource->readOnly() ) {
360 bool onlyReadOnly = true; 339 bool onlyReadOnly = true;
361 QListViewItem *it = mListView->firstChild(); 340 QListViewItem *it = mListView->firstChild();
362 while ( it != 0 ) { 341 while ( it != 0 ) {
363 ConfigViewItem *confIt = static_cast<ConfigViewItem*>( it ); 342 ConfigViewItem *confIt = static_cast<ConfigViewItem*>( it );
364 if ( !confIt->readOnly() && confIt != item ) 343 if ( !confIt->readOnly() && confIt != item )
365 onlyReadOnly = false; 344 onlyReadOnly = false;
366 345
367 it = it->itemBelow(); 346 it = it->itemBelow();
368 } 347 }
369 348
370 if ( onlyReadOnly ) 349 if ( onlyReadOnly )
371 item->setStandard( true ); 350 item->setStandard( true );
372 } 351 }
373 352
374 emit changed( true ); 353 emit changed( true );
375 } else { 354 } else {
376 delete resource; 355 delete resource;
377 resource = 0; 356 resource = 0;
378 } 357 }
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index e44fce3..4e4456d 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -158,132 +158,98 @@ ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
158{ 158{
159 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 159 if ( type.isEmpty() || !mTypeMap.contains( type ) )
160 return 0; 160 return 0;
161 161
162//US KService::Ptr ptr = mTypeMap[ type ]; 162//US KService::Ptr ptr = mTypeMap[ type ];
163//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 163//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
164 PluginInfo* pi = mTypeMap[ type ]; 164 PluginInfo* pi = mTypeMap[ type ];
165 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 165 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
166 if ( !factory ) { 166 if ( !factory ) {
167 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); 167 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1());
168 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; 168 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl;
169 return 0; 169 return 0;
170 } 170 }
171 171
172 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 172 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
173 173
174 if ( !pluginFactory ) { 174 if ( !pluginFactory ) {
175 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); 175 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1());
176 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; 176 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl;
177 return 0; 177 return 0;
178 } 178 }
179 179
180 ConfigWidget *wdg = pluginFactory->configWidget( parent ); 180 ConfigWidget *wdg = pluginFactory->configWidget( parent );
181 if ( !wdg ) { 181 if ( !wdg ) {
182//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 182//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
183 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 183 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
184 return 0; 184 return 0;
185 } 185 }
186 return wdg; 186 return wdg;
187 187
188} 188}
189 189
190SyncWidgetContainer *Factory::syncWidgetContainer( const QString& type )
191{
192 if ( type.isEmpty() || !mTypeMap.contains( type ) )
193 return 0;
194
195//US KService::Ptr ptr = mTypeMap[ type ];
196//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
197 PluginInfo* pi = mTypeMap[ type ];
198 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
199 if ( !factory ) {
200 qDebug("KRES::Factory::syncWidget(): Factory creation failed for library %s", pi->library.latin1());
201 kdDebug() << "KRES::Factory::syncWidget(): Factory creation failed" << endl;
202 return 0;
203 }
204
205 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
206
207 if ( !pluginFactory ) {
208 qDebug("KRES::Factory::syncWidget(): no plugin factory for library %s", pi->library.latin1());
209 kdDebug() << "KRES::Factory::syncWidget(): no plugin factory." << endl;
210 return 0;
211 }
212
213 SyncWidgetContainer *wdg = pluginFactory->syncWidgetContainer( );
214 if ( !wdg ) {
215//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
216 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
217 return 0;
218 }
219 return wdg;
220
221}
222
223
224QString Factory::typeName( const QString &type ) const 190QString Factory::typeName( const QString &type ) const
225{ 191{
226 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 192 if ( type.isEmpty() || !mTypeMap.contains( type ) )
227 return QString(); 193 return QString();
228 194
229 195
230//US KService::Ptr ptr = mTypeMap[ type ]; 196//US KService::Ptr ptr = mTypeMap[ type ];
231//US return ptr->name(); 197//US return ptr->name();
232 PluginInfo* pi = mTypeMap[ type ]; 198 PluginInfo* pi = mTypeMap[ type ];
233 return pi->nameLabel; 199 return pi->nameLabel;
234 200
235} 201}
236 202
237QString Factory::typeDescription( const QString &type ) const 203QString Factory::typeDescription( const QString &type ) const
238{ 204{
239 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 205 if ( type.isEmpty() || !mTypeMap.contains( type ) )
240 return QString(); 206 return QString();
241 207
242//US KService::Ptr ptr = mTypeMap[ type ]; 208//US KService::Ptr ptr = mTypeMap[ type ];
243//US return ptr->comment(); 209//US return ptr->comment();
244 PluginInfo* pi = mTypeMap[ type ]; 210 PluginInfo* pi = mTypeMap[ type ];
245 return pi->descriptionLabel; 211 return pi->descriptionLabel;
246} 212}
247 213
248Resource *Factory::resource( const QString& type, const KConfig *config, bool syncable ) 214Resource *Factory::resource( const QString& type, const KConfig *config )
249{ 215{
250 216
251 217
252 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 218 if ( type.isEmpty() || !mTypeMap.contains( type ) )
253 return 0; 219 return 0;
254 220
255/*US load the lib not dynamicly. !! 221/*US load the lib not dynamicly. !!
256 KService::Ptr ptr = mTypeMap[ type ]; 222 KService::Ptr ptr = mTypeMap[ type ];
257 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 223 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
258 if ( !factory ) { 224 if ( !factory ) {
259 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 225 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
260 return 0; 226 return 0;
261 } 227 }
262*/ 228*/
263 PluginInfo* pi = mTypeMap[ type ]; 229 PluginInfo* pi = mTypeMap[ type ];
264 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 230 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
265 if ( !factory ) { 231 if ( !factory ) {
266 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1()); 232 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1());
267 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 233 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
268 return 0; 234 return 0;
269 } 235 }
270 236
271 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 237 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
272 238
273 if ( !pluginFactory ) { 239 if ( !pluginFactory ) {
274 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); 240 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1());
275 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; 241 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl;
276 return 0; 242 return 0;
277 } 243 }
278 244
279 Resource *resource = pluginFactory->resource( config, syncable ); 245 Resource *resource = pluginFactory->resource( config );
280 if ( !resource ) { 246 if ( !resource ) {
281//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 247//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
282 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 248 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
283 return 0; 249 return 0;
284 } 250 }
285 251
286 resource->setType( type ); 252 resource->setType( type );
287 253
288 return resource; 254 return resource;
289} 255}
diff --git a/microkde/kresources/factory.h b/microkde/kresources/factory.h
index 0e4231b..ea01b23 100644
--- a/microkde/kresources/factory.h
+++ b/microkde/kresources/factory.h
@@ -5,135 +5,122 @@
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#ifndef KRESOURCES_FACTORY_H 24#ifndef KRESOURCES_FACTORY_H
25#define KRESOURCES_FACTORY_H 25#define KRESOURCES_FACTORY_H
26 26
27#include <qdict.h> 27#include <qdict.h>
28#include <qstring.h> 28#include <qstring.h>
29 29
30#include <kconfig.h> 30#include <kconfig.h>
31 31
32 32
33#include "resource.h" 33#include "resource.h"
34 34
35namespace KRES { 35namespace KRES {
36 36
37class SyncWidgetContainer;
38class ConfigWidget; 37class ConfigWidget;
39 38
40//US 39//US
41struct PluginInfo 40struct PluginInfo
42{ 41{
43 QString library; 42 QString library;
44 QString nameLabel; 43 QString nameLabel;
45 QString descriptionLabel; 44 QString descriptionLabel;
46}; 45};
47 46
48 47
49/** 48/**
50 * Class for loading resource plugins. 49 * Class for loading resource plugins.
51 * Do not use this class directly. Use ResourceManager instead 50 * Do not use this class directly. Use ResourceManager instead
52 * 51 *
53 * Example: 52 * Example:
54 * 53 *
55 * <pre> 54 * <pre>
56 * KABC::Factory<Calendar> *factory = KABC::Factory<Calendar>::self(); 55 * KABC::Factory<Calendar> *factory = KABC::Factory<Calendar>::self();
57 * 56 *
58 * QStringList list = factory->resources(); 57 * QStringList list = factory->resources();
59 * QStringList::Iterator it; 58 * QStringList::Iterator it;
60 * for ( it = list.begin(); it != list.end(); ++it ) { 59 * for ( it = list.begin(); it != list.end(); ++it ) {
61 * Resource<Calendar> *resource = factory->resource( (*it), 60 * Resource<Calendar> *resource = factory->resource( (*it),
62 * KABC::StdAddressBook::self(), 0 ); 61 * KABC::StdAddressBook::self(), 0 );
63 * // do something with resource 62 * // do something with resource
64 * } 63 * }
65 * </pre> 64 * </pre>
66 */ 65 */
67class Factory 66class Factory
68{ 67{
69 public: 68 public:
70 69
71 70
72 /** 71 /**
73 * Returns the global resource factory. 72 * Returns the global resource factory.
74 */ 73 */
75 static Factory *self( const QString& resourceFamily ); 74 static Factory *self( const QString& resourceFamily );
76 75
77 ~Factory(); 76 ~Factory();
78 77
79 /** 78 /**
80 * Returns the config widget for the given resource type, 79 * Returns the config widget for the given resource type,
81 * or a null pointer if resource type doesn't exist. 80 * or a null pointer if resource type doesn't exist.
82 * 81 *
83 * @param type The type of the resource, returned by @ref resources() 82 * @param type The type of the resource, returned by @ref resources()
84 * @param resource The resource to be editted. 83 * @param resource The resource to be editted.
85 * @param parent The parent widget 84 * @param parent The parent widget
86 */ 85 */
87 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 ); 86 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 );
88 87
89 /** 88 /**
90 * Returns the sync widget for the given resource type,
91 * or a null pointer if resource type doesn't exist,
92 * or a null pointer if resource does not support syncing.
93 *
94 * @param type The type of the resource, returned by @ref resources()
95 * @param resource The resource to be editted.
96 * @param parent The parent widget
97 */
98 SyncWidgetContainer *syncWidgetContainer( const QString& type );
99
100 /**
101 * Returns a pointer to a resource object or a null pointer 89 * Returns a pointer to a resource object or a null pointer
102 * if resource type doesn't exist. 90 * if resource type doesn't exist.
103 * 91 *
104 * @param type The type of the resource, returned by @ref resources() 92 * @param type The type of the resource, returned by @ref resources()
105 * @param ab The address book, the resource should belong to 93 * @param ab The address book, the resource should belong to
106 * @param config The config object where the resource get it settings from, or 0 if a new resource should be created. 94 * @param config The config object where the resource get it settings from, or 0 if a new resource should be created.
107 * @param syncable If the resource should support syncing capabilities.
108 */ 95 */
109 Resource *resource( const QString& type, const KConfig *config, bool syncable ); 96 Resource *resource( const QString& type, const KConfig *config);
110 97
111 /** 98 /**
112 * Returns a list of all available resource types. 99 * Returns a list of all available resource types.
113 */ 100 */
114 QStringList typeNames() const; 101 QStringList typeNames() const;
115 102
116 /** 103 /**
117 * Returns the name for a special type. 104 * Returns the name for a special type.
118 */ 105 */
119 QString typeName( const QString &type ) const; 106 QString typeName( const QString &type ) const;
120 107
121 /** 108 /**
122 * Returns the description for a special type. 109 * Returns the description for a special type.
123 */ 110 */
124 QString typeDescription( const QString &type ) const; 111 QString typeDescription( const QString &type ) const;
125 112
126 protected: 113 protected:
127 Factory( const QString& resourceFamily); 114 Factory( const QString& resourceFamily);
128 115
129 private: 116 private:
130 static QDict<Factory> *mSelves; 117 static QDict<Factory> *mSelves;
131 118
132 QString mResourceFamily; 119 QString mResourceFamily;
133//US QMap<QString, KService::Ptr> mTypeMap; 120//US QMap<QString, KService::Ptr> mTypeMap;
134//US lets store the pluginfo struct as value instead of a KService 121//US lets store the pluginfo struct as value instead of a KService
135 QMap<QString, PluginInfo*> mTypeMap; 122 QMap<QString, PluginInfo*> mTypeMap;
136}; 123};
137 124
138} 125}
139#endif 126#endif
diff --git a/microkde/kresources/manager.h b/microkde/kresources/manager.h
index 7e9e19a..0e6f838 100644
--- a/microkde/kresources/manager.h
+++ b/microkde/kresources/manager.h
@@ -138,75 +138,70 @@ class Manager : private ManagerImplListener
138 */ 138 */
139 bool checkActive() 139 bool checkActive()
140 { 140 {
141 if ( !mList || mIt == mList->end() ) return false; 141 if ( !mList || mIt == mList->end() ) return false;
142 return !(*mIt)->isActive(); 142 return !(*mIt)->isActive();
143 } 143 }
144 144
145 Resource::List::Iterator mIt; 145 Resource::List::Iterator mIt;
146 Resource::List *mList; 146 Resource::List *mList;
147 }; 147 };
148 148
149 ActiveIterator activeBegin() 149 ActiveIterator activeBegin()
150 { 150 {
151 ActiveIterator it; 151 ActiveIterator it;
152 it.mIt = mImpl->resourceList()->begin(); 152 it.mIt = mImpl->resourceList()->begin();
153 it.mList = mImpl->resourceList(); 153 it.mList = mImpl->resourceList();
154 if ( it.mIt != mImpl->resourceList()->end() ) { 154 if ( it.mIt != mImpl->resourceList()->end() ) {
155 if ( !(*it)->isActive() ) it++; 155 if ( !(*it)->isActive() ) it++;
156 } 156 }
157 return it; 157 return it;
158 } 158 }
159 159
160 ActiveIterator activeEnd() 160 ActiveIterator activeEnd()
161 { 161 {
162 ActiveIterator it; 162 ActiveIterator it;
163 it.mIt = mImpl->resourceList()->end(); 163 it.mIt = mImpl->resourceList()->end();
164 it.mList = mImpl->resourceList(); 164 it.mList = mImpl->resourceList();
165 return it; 165 return it;
166 } 166 }
167 167
168 bool isEmpty() const { return mImpl->resourceList()->isEmpty(); } 168 bool isEmpty() const { return mImpl->resourceList()->isEmpty(); }
169 169
170 /** 170 Manager( const QString &family )
171 Return true, if the manager manages syncable resources.
172 */
173 bool manageSyncable() { return mImpl->manageSyncable(); }
174
175 Manager( const QString &family, bool syncable )
176 { 171 {
177 mFactory = Factory::self( family ); 172 mFactory = Factory::self( family );
178 // The managerimpl will use the same Factory object as the manager 173 // The managerimpl will use the same Factory object as the manager
179 // because of the Factory::self() pattern 174 // because of the Factory::self() pattern
180 mImpl = new ManagerImpl( family, syncable ); 175 mImpl = new ManagerImpl( family );
181 mImpl->setListener( this ); 176 mImpl->setListener( this );
182 177
183 mListeners = new QPtrList<ManagerListener<T> >; 178 mListeners = new QPtrList<ManagerListener<T> >;
184 } 179 }
185 180
186 virtual ~Manager() 181 virtual ~Manager()
187 { 182 {
188 mImpl->setListener( 0 ); 183 mImpl->setListener( 0 );
189 delete mListeners; 184 delete mListeners;
190 delete mImpl; 185 delete mImpl;
191 } 186 }
192 187
193 /** 188 /**
194 Recreate Resource objects from configuration file. If cfg is 0, read standard 189 Recreate Resource objects from configuration file. If cfg is 0, read standard
195 configuration file. 190 configuration file.
196 */ 191 */
197 void readConfig( KConfig *cfg = 0 ) 192 void readConfig( KConfig *cfg = 0 )
198 { 193 {
199 mImpl->readConfig( cfg ); 194 mImpl->readConfig( cfg );
200 } 195 }
201 196
202 /** 197 /**
203 Write configuration of Resource objects to configuration file. If cfg is 0, write 198 Write configuration of Resource objects to configuration file. If cfg is 0, write
204 to standard configuration file. 199 to standard configuration file.
205 */ 200 */
206 void writeConfig( KConfig *cfg = 0 ) 201 void writeConfig( KConfig *cfg = 0 )
207 { 202 {
208 mImpl->writeConfig( cfg ); 203 mImpl->writeConfig( cfg );
209 } 204 }
210 205
211 /** 206 /**
212 Add resource to manager. This passes ownership of the Resource object 207 Add resource to manager. This passes ownership of the Resource object
@@ -231,69 +226,68 @@ class Manager : private ManagerImplListener
231 { 226 {
232 if ( resource ) mImpl->setStandardResource( resource ); 227 if ( resource ) mImpl->setStandardResource( resource );
233 } 228 }
234 229
235 void setActive( Resource *resource, bool active ) 230 void setActive( Resource *resource, bool active )
236 { 231 {
237 if ( resource ) mImpl->setActive( resource, active ); 232 if ( resource ) mImpl->setActive( resource, active );
238 } 233 }
239 234
240 /** 235 /**
241 Returns a list of the names of the reources managed by the 236 Returns a list of the names of the reources managed by the
242 Manager for this family. 237 Manager for this family.
243 */ 238 */
244 QStringList resourceNames() const 239 QStringList resourceNames() const
245 { 240 {
246 return mImpl->resourceNames(); 241 return mImpl->resourceNames();
247 } 242 }
248 243
249 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 ) 244 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 )
250 { 245 {
251 return mFactory->resourceConfigWidget( type, parent ); 246 return mFactory->resourceConfigWidget( type, parent );
252 } 247 }
253 248
254 /** 249 /**
255 Creates a new resource of type @param type, with default 250 Creates a new resource of type @param type, with default
256 settings. The resource is 251 settings. The resource is
257 not added to the manager, the application has to do that. 252 not added to the manager, the application has to do that.
258 Returns a pointer to a resource object or a null pointer 253 Returns a pointer to a resource object or a null pointer
259 if resource type doesn't exist. 254 if resource type doesn't exist.
260 255
261 @param type The type of the resource, one of those returned 256 @param type The type of the resource, one of those returned
262 by @ref resourceTypeNames() 257 by @ref resourceTypeNames()
263 * @param syncable If the resource should support syncing capabilities.
264 */ 258 */
265 T *createResource( const QString& type ) 259 T *createResource( const QString& type )
266 { 260 {
267 return (T *)( mFactory->resource( type, 0, mImpl->manageSyncable() ) ); 261 return (T *)( mFactory->resource( type, 0 ) );
268 } 262 }
269 263
270 /** 264 /**
271 Returns a list of the names of all available resource types. 265 Returns a list of the names of all available resource types.
272 */ 266 */
273 QStringList resourceTypeNames() const 267 QStringList resourceTypeNames() const
274 { 268 {
275 return mFactory->typeNames(); 269 return mFactory->typeNames();
276 } 270 }
277 271
278 QStringList resourceTypeDescriptions() const 272 QStringList resourceTypeDescriptions() const
279 { 273 {
280 QStringList typeDescs; 274 QStringList typeDescs;
281 QStringList types = mFactory->typeNames(); 275 QStringList types = mFactory->typeNames();
282 276
283 for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) { 277 for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) {
284 QString desc = mFactory->typeName( *it ); 278 QString desc = mFactory->typeName( *it );
285 if ( !mFactory->typeDescription( *it ).isEmpty() ) 279 if ( !mFactory->typeDescription( *it ).isEmpty() )
286 desc += " (" + mFactory->typeDescription( *it ) + ")"; 280 desc += " (" + mFactory->typeDescription( *it ) + ")";
287 281
288 typeDescs.append( desc ); 282 typeDescs.append( desc );
289 } 283 }
290 284
291 return typeDescs; 285 return typeDescs;
292 } 286 }
293 287
294 void resourceChanged( T *resource ) 288 void resourceChanged( T *resource )
295 { 289 {
296 mImpl->resourceChanged( resource ); 290 mImpl->resourceChanged( resource );
297 } 291 }
298 292
299 void addListener( ManagerListener<T> *listener ) 293 void addListener( ManagerListener<T> *listener )
diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp
index 3655f50..81bbbec 100644
--- a/microkde/kresources/managerimpl.cpp
+++ b/microkde/kresources/managerimpl.cpp
@@ -12,66 +12,66 @@
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32 32
33#include <kapplication.h> 33#include <kapplication.h>
34#include <kdebug.h> 34#include <kdebug.h>
35#include <kconfig.h> 35#include <kconfig.h>
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37 37
38#include "resource.h" 38#include "resource.h"
39#include "factory.h" 39#include "factory.h"
40#include "managerimpl.h" 40#include "managerimpl.h"
41 41
42using namespace KRES; 42using namespace KRES;
43 43
44ManagerImpl::ManagerImpl( const QString &family, bool syncable ) 44ManagerImpl::ManagerImpl( const QString &family )
45 : mFamily( family ), mSyncable(syncable), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ), 45 : mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ),
46 mFactory( 0 ) 46 mFactory( 0 )
47 47
48{ 48{
49 kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl; 49 kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl;
50 50
51 51
52} 52}
53 53
54ManagerImpl::~ManagerImpl() 54ManagerImpl::~ManagerImpl()
55{ 55{
56 kdDebug(5650) << "ManagerImpl::~ManagerImpl()" << endl; 56 kdDebug(5650) << "ManagerImpl::~ManagerImpl()" << endl;
57 57
58 Resource::List::ConstIterator it; 58 Resource::List::ConstIterator it;
59 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 59 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
60 delete *it; 60 delete *it;
61 } 61 }
62 62
63 delete mStdConfig; 63 delete mStdConfig;
64} 64}
65 65
66void ManagerImpl::createStandardConfig() 66void ManagerImpl::createStandardConfig()
67{ 67{
68 if ( !mStdConfig ) { 68 if ( !mStdConfig ) {
69 QString file = locateLocal( "data", KGlobal::getAppName() 69 QString file = locateLocal( "data", KGlobal::getAppName()
70 + "/kresources/" + mFamily + "rc" ); 70 + "/kresources/" + mFamily + "rc" );
71 mStdConfig = new KConfig( file ); 71 mStdConfig = new KConfig( file );
72 } 72 }
73 73
74 mConfig = mStdConfig; 74 mConfig = mStdConfig;
75} 75}
76 76
77void ManagerImpl::readConfig( KConfig *cfg ) 77void ManagerImpl::readConfig( KConfig *cfg )
@@ -239,65 +239,65 @@ QPtrList<Resource> ManagerImpl::resources( bool active )
239 QPtrList<Resource> result; 239 QPtrList<Resource> result;
240 240
241 Resource::List::ConstIterator it; 241 Resource::List::ConstIterator it;
242 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 242 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
243 if ( (*it)->isActive() == active ) { 243 if ( (*it)->isActive() == active ) {
244 result.append( *it ); 244 result.append( *it );
245 } 245 }
246 } 246 }
247 return result; 247 return result;
248} 248}
249 249
250void ManagerImpl::setListener( ManagerImplListener *listener ) 250void ManagerImpl::setListener( ManagerImplListener *listener )
251{ 251{
252 mListener = listener; 252 mListener = listener;
253} 253}
254 254
255Resource* ManagerImpl::readResourceConfig( const QString& identifier, 255Resource* ManagerImpl::readResourceConfig( const QString& identifier,
256 bool checkActive ) 256 bool checkActive )
257{ 257{
258 kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; 258 kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl;
259 259
260// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); 260// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1());
261 261
262 mConfig->setGroup( "Resource_" + identifier ); 262 mConfig->setGroup( "Resource_" + identifier );
263#ifdef _WIN32_ 263#ifdef _WIN32_
264 // we use plugins on win32. the group is stored in a static variable 264 // we use plugins on win32. the group is stored in a static variable
265 // such that gourp info not avail on win32 plugins 265 // such that gourp info not avail on win32 plugins
266 // to fix that, it would be a looooot of work 266 // to fix that, it would be a looooot of work
267 mConfig->setTempGroup( "Resource_" + identifier ); 267 mConfig->setTempGroup( "Resource_" + identifier );
268#endif 268#endif
269 QString type = mConfig->readEntry( "ResourceType" ); 269 QString type = mConfig->readEntry( "ResourceType" );
270 QString name = mConfig->readEntry( "ResourceName" ); 270 QString name = mConfig->readEntry( "ResourceName" );
271 Resource *resource = mFactory->resource( type, mConfig, mSyncable ); 271 Resource *resource = mFactory->resource( type, mConfig );
272 if ( !resource ) { 272 if ( !resource ) {
273 qDebug("Failed to create resource with id %s ",identifier.latin1() ); 273 qDebug("Failed to create resource with id %s ",identifier.latin1() );
274 return 0; 274 return 0;
275 } 275 }
276 276
277 if ( resource->identifier().isEmpty() ) 277 if ( resource->identifier().isEmpty() )
278 resource->setIdentifier( identifier ); 278 resource->setIdentifier( identifier );
279 279
280 mConfig->setGroup( "General" ); 280 mConfig->setGroup( "General" );
281 281
282 QString standardKey = mConfig->readEntry( "Standard" ); 282 QString standardKey = mConfig->readEntry( "Standard" );
283 if ( standardKey == identifier ) { 283 if ( standardKey == identifier ) {
284 mStandard = resource; 284 mStandard = resource;
285 } 285 }
286 286
287 if ( checkActive ) { 287 if ( checkActive ) {
288 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 288 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
289 resource->setActive( activeKeys.contains( identifier ) ); 289 resource->setActive( activeKeys.contains( identifier ) );
290 } 290 }
291 mResources.append( resource ); 291 mResources.append( resource );
292 292
293 return resource; 293 return resource;
294} 294}
295 295
296void ManagerImpl::writeResourceConfig( Resource *resource, 296void ManagerImpl::writeResourceConfig( Resource *resource,
297 bool checkActive ) 297 bool checkActive )
298{ 298{
299 QString key = resource->identifier(); 299 QString key = resource->identifier();
300 300
301 kdDebug(5650) << "Saving resource " << key << endl; 301 kdDebug(5650) << "Saving resource " << key << endl;
302 302
303 if ( !mConfig ) createStandardConfig(); 303 if ( !mConfig ) createStandardConfig();
@@ -335,40 +335,33 @@ void ManagerImpl::removeResource( Resource *resource )
335 335
336 mConfig->setGroup( "General" ); 336 mConfig->setGroup( "General" );
337 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 337 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
338 if ( activeKeys.contains( key ) ) { 338 if ( activeKeys.contains( key ) ) {
339 activeKeys.remove( key ); 339 activeKeys.remove( key );
340 mConfig->writeEntry( "ResourceKeys", activeKeys ); 340 mConfig->writeEntry( "ResourceKeys", activeKeys );
341 } else { 341 } else {
342 QStringList passiveKeys = mConfig->readListEntry( "PassiveResourceKeys" ); 342 QStringList passiveKeys = mConfig->readListEntry( "PassiveResourceKeys" );
343 passiveKeys.remove( key ); 343 passiveKeys.remove( key );
344 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); 344 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys );
345 } 345 }
346 346
347 QString standardKey = mConfig->readEntry( "Standard" ); 347 QString standardKey = mConfig->readEntry( "Standard" );
348 if ( standardKey == key ) { 348 if ( standardKey == key ) {
349 mConfig->writeEntry( "Standard", "" ); 349 mConfig->writeEntry( "Standard", "" );
350 } 350 }
351 351
352 mConfig->deleteGroup( "Resource_" + resource->identifier() ); 352 mConfig->deleteGroup( "Resource_" + resource->identifier() );
353 353
354 mConfig->sync(); 354 mConfig->sync();
355} 355}
356 356
357Resource* ManagerImpl::getResource( const QString& identifier ) 357Resource* ManagerImpl::getResource( const QString& identifier )
358{ 358{
359 Resource::List::ConstIterator it; 359 Resource::List::ConstIterator it;
360 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 360 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
361 if ( (*it)->identifier() == identifier ) 361 if ( (*it)->identifier() == identifier )
362 return *it; 362 return *it;
363 } 363 }
364 return 0; 364 return 0;
365} 365}
366 366
367/**
368 Return true, if the manager manages syncable resources.
369*/
370bool ManagerImpl::manageSyncable() const
371{
372 return mSyncable;
373}
374 367
diff --git a/microkde/kresources/managerimpl.h b/microkde/kresources/managerimpl.h
index 0425279..56a2db6 100644
--- a/microkde/kresources/managerimpl.h
+++ b/microkde/kresources/managerimpl.h
@@ -36,91 +36,85 @@ $Id$
36#include <qdict.h> 36#include <qdict.h>
37//US 37//US
38#include <qobject.h> 38#include <qobject.h>
39 39
40#include "resource.h" 40#include "resource.h"
41 41
42 42
43class KConfig; 43class KConfig;
44 44
45namespace KRES { 45namespace KRES {
46 46
47class Resource; 47class Resource;
48class Factory; 48class Factory;
49 49
50class ManagerImplListener 50class ManagerImplListener
51{ 51{
52 public: 52 public:
53 virtual void resourceAdded( Resource *resource ) = 0; 53 virtual void resourceAdded( Resource *resource ) = 0;
54 virtual void resourceModified( Resource *resource ) = 0; 54 virtual void resourceModified( Resource *resource ) = 0;
55 virtual void resourceDeleted( Resource *resource ) = 0; 55 virtual void resourceDeleted( Resource *resource ) = 0;
56}; 56};
57 57
58 58
59/** 59/**
60 @internal 60 @internal
61 61
62 Do not use this class directly. Use ResourceManager instead 62 Do not use this class directly. Use ResourceManager instead
63*/ 63*/
64class ManagerImpl : public QObject 64class ManagerImpl : public QObject
65{ 65{
66 Q_OBJECT 66 Q_OBJECT
67 public: 67 public:
68 ManagerImpl( const QString &family, bool syncable); 68 ManagerImpl( const QString &family);
69 ~ManagerImpl(); 69 ~ManagerImpl();
70 70
71 void readConfig( KConfig * ); 71 void readConfig( KConfig * );
72 void writeConfig( KConfig * ); 72 void writeConfig( KConfig * );
73 73
74 void add( Resource *resource, bool useDCOP = true ); 74 void add( Resource *resource, bool useDCOP = true );
75 void remove( Resource *resource, bool useDCOP = true ); 75 void remove( Resource *resource, bool useDCOP = true );
76 76
77 Resource *standardResource(); 77 Resource *standardResource();
78 void setStandardResource( Resource *resource ); 78 void setStandardResource( Resource *resource );
79 79
80 void setActive( Resource *resource, bool active ); 80 void setActive( Resource *resource, bool active );
81 81
82 Resource::List *resourceList(); 82 Resource::List *resourceList();
83 83
84 QPtrList<Resource> resources(); 84 QPtrList<Resource> resources();
85 85
86 // Get only active or passive resources 86 // Get only active or passive resources
87 QPtrList<Resource> resources( bool active ); 87 QPtrList<Resource> resources( bool active );
88 88
89 QStringList resourceNames(); 89 QStringList resourceNames();
90 90
91 void setListener( ManagerImplListener *listener ); 91 void setListener( ManagerImplListener *listener );
92 92
93 /**
94 Return true, if the manager manages syncable resources.
95 */
96 bool manageSyncable() const;
97
98 public slots: 93 public slots:
99 void resourceChanged( Resource *resource ); 94 void resourceChanged( Resource *resource );
100 95
101 private: 96 private:
102 // dcop calls 97 // dcop calls
103 98
104 private: 99 private:
105 void createStandardConfig(); 100 void createStandardConfig();
106 101
107 Resource *readResourceConfig( const QString& identifier, bool checkActive ); 102 Resource *readResourceConfig( const QString& identifier, bool checkActive );
108 void writeResourceConfig( Resource *resource, bool checkActive ); 103 void writeResourceConfig( Resource *resource, bool checkActive );
109 104
110 void removeResource( Resource *resource ); 105 void removeResource( Resource *resource );
111 Resource *getResource( Resource *resource ); 106 Resource *getResource( Resource *resource );
112 Resource *getResource( const QString& identifier ); 107 Resource *getResource( const QString& identifier );
113 108
114 QString mFamily; 109 QString mFamily;
115 bool mSyncable;
116 KConfig *mConfig; 110 KConfig *mConfig;
117 KConfig *mStdConfig; 111 KConfig *mStdConfig;
118 Resource *mStandard; 112 Resource *mStandard;
119 Factory *mFactory; 113 Factory *mFactory;
120 Resource::List mResources; 114 Resource::List mResources;
121 ManagerImplListener *mListener; 115 ManagerImplListener *mListener;
122}; 116};
123 117
124} 118}
125 119
126#endif 120#endif
diff --git a/microkde/kresources/resource.cpp b/microkde/kresources/resource.cpp
index f79bcd0..cccd485 100644
--- a/microkde/kresources/resource.cpp
+++ b/microkde/kresources/resource.cpp
@@ -169,36 +169,37 @@ bool Resource::readOnly() const
169 return d->mReadOnly; 169 return d->mReadOnly;
170} 170}
171 171
172void Resource::setResourceName( const QString &name ) 172void Resource::setResourceName( const QString &name )
173{ 173{
174 d->mName = name; 174 d->mName = name;
175} 175}
176 176
177QString Resource::resourceName() const 177QString Resource::resourceName() const
178{ 178{
179 return d->mName; 179 return d->mName;
180} 180}
181 181
182void Resource::setActive( bool value ) 182void Resource::setActive( bool value )
183{ 183{
184 d->mActive = value; 184 d->mActive = value;
185} 185}
186 186
187bool Resource::isActive() const 187bool Resource::isActive() const
188{ 188{
189 return d->mActive; 189 return d->mActive;
190} 190}
191 191
192void Resource::dump() const 192void Resource::dump() const
193{ 193{
194 qDebug("Resource::dump() "); 194 qDebug("Resource::dump() ");
195 kdDebug(5650) << "Resource:" << endl; 195 kdDebug(5650) << "Resource:" << endl;
196 kdDebug(5650) << " Name: " << d->mName << endl; 196 kdDebug(5650) << " Name: " << d->mName << endl;
197 kdDebug(5650) << " Identifier: " << d->mIdentifier << endl; 197 kdDebug(5650) << " Identifier: " << d->mIdentifier << endl;
198 kdDebug(5650) << " Type: " << d->mType << endl; 198 kdDebug(5650) << " Type: " << d->mType << endl;
199 kdDebug(5650) << " OpenCount: " << d->mOpenCount << endl; 199 kdDebug(5650) << " OpenCount: " << d->mOpenCount << endl;
200 kdDebug(5650) << " ReadOnly: " << ( d->mReadOnly ? "yes" : "no" ) << endl; 200 kdDebug(5650) << " ReadOnly: " << ( d->mReadOnly ? "yes" : "no" ) << endl;
201 kdDebug(5650) << " IncludeInSync: " << ( d->mIncludeInSync ? "yes" : "no" ) << endl;
201 kdDebug(5650) << " Active: " << ( d->mActive ? "yes" : "no" ) << endl; 202 kdDebug(5650) << " Active: " << ( d->mActive ? "yes" : "no" ) << endl;
202 kdDebug(5650) << " IsOpen: " << ( d->mIsOpen ? "yes" : "no" ) << endl; 203 kdDebug(5650) << " IsOpen: " << ( d->mIsOpen ? "yes" : "no" ) << endl;
203} 204}
204 205
diff --git a/microkde/kresources/resource.h b/microkde/kresources/resource.h
index 70b5613..ed5af96 100644
--- a/microkde/kresources/resource.h
+++ b/microkde/kresources/resource.h
@@ -11,65 +11,64 @@
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#ifndef KRESOURCES_RESOURCE_H 23#ifndef KRESOURCES_RESOURCE_H
24#define KRESOURCES_RESOURCE_H 24#define KRESOURCES_RESOURCE_H
25 25
26//US 26//US
27#ifdef QT_THREAD_SUPPORT 27#ifdef QT_THREAD_SUPPORT
28#include <qmutex.h> 28#include <qmutex.h>
29#endif //QT_THREAD_SUPPORT 29#endif //QT_THREAD_SUPPORT
30 30
31#include <qvaluelist.h> 31#include <qvaluelist.h>
32#include <qwidget.h> 32#include <qwidget.h>
33 33
34#include <qobject.h> 34#include <qobject.h>
35 35
36#include <klibloader.h> 36#include <klibloader.h>
37 37
38class KConfig; 38class KConfig;
39 39
40namespace KRES { 40namespace KRES {
41 41
42class ConfigWidget; 42class ConfigWidget;
43class SyncWidgetContainer;
44 43
45/** 44/**
46 * @internal 45 * @internal
47 * @libdoc The KDE Resource library 46 * @libdoc The KDE Resource library
48 * 47 *
49 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this 48 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this
50 * interface, it is in constant flux. 49 * interface, it is in constant flux.
51 * 50 *
52 * The KDE Resource framework can be used to manage resources of 51 * The KDE Resource framework can be used to manage resources of
53 * different types, organized in families. The Resource framework 52 * different types, organized in families. The Resource framework
54 * is currently used for addressbook resources in libkabc and for 53 * is currently used for addressbook resources in libkabc and for
55 * calendar resources in libkcal. 54 * calendar resources in libkcal.
56 * 55 *
57 * When you want to use the framework for a new family, you need to 56 * When you want to use the framework for a new family, you need to
58 * <ul><li>Define a name for your resource family</li> 57 * <ul><li>Define a name for your resource family</li>
59 * <li>subclass Resource and add the fields and method that are needed 58 * <li>subclass Resource and add the fields and method that are needed
60 * in your application</li> 59 * in your application</li>
61 * <li>If needed, override the doOpen() and doClose() methods. 60 * <li>If needed, override the doOpen() and doClose() methods.
62 * <li> Provide a configuration possibility for resources in your 61 * <li> Provide a configuration possibility for resources in your
63 * new family. You can use @ref ResourcesConfigPage to easily create a 62 * new family. You can use @ref ResourcesConfigPage to easily create a
64 * KControl applet</li> 63 * KControl applet</li>
65 * <li>In your application, you can use @ref ResourceManager to keep track 64 * <li>In your application, you can use @ref ResourceManager to keep track
66 * of the resources in your family, and you can use @ref ResourceSelectDialog 65 * of the resources in your family, and you can use @ref ResourceSelectDialog
67 * to let the user select a single resource.</li> 66 * to let the user select a single resource.</li>
68 * </ul> 67 * </ul>
69 * 68 *
70 * When you want to add a new resource type to an existing resource family, 69 * When you want to add a new resource type to an existing resource family,
71 * you need to 70 * you need to
72 * <ul><li>Further subclass the family-specific Resource to implement 71 * <ul><li>Further subclass the family-specific Resource to implement
73 * resource type-specific operation</li> 72 * resource type-specific operation</li>
74 * <li>Subclass ResourceConfigWidget to provide a configuration widget 73 * <li>Subclass ResourceConfigWidget to provide a configuration widget
75 * for your new resource type</li> 74 * for your new resource type</li>
@@ -203,65 +202,65 @@ void ResourceExampleConfig::saveSettings( KRES::Resource *resource )
203* <B>resourceexample.desktop</B>: 202* <B>resourceexample.desktop</B>:
204<pre> 203<pre>
205[Desktop Entry] 204[Desktop Entry]
206Type=Service 205Type=Service
207 206
208[Misc] 207[Misc]
209Encoding=UTF-8 208Encoding=UTF-8
210Name=Example Resource 209Name=Example Resource
211 210
212[Plugin] 211[Plugin]
213Type=exchange 212Type=exchange
214X-KDE-Library=resourceexample 213X-KDE-Library=resourceexample
215</pre> 214</pre>
216* <B>Makefile.am</B> 215* <B>Makefile.am</B>
217<pre> 216<pre>
218kde_module_LTLIBRARIES = resourceexample.la 217kde_module_LTLIBRARIES = resourceexample.la
219 218
220resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp 219resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp
221resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN) 220resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN)
222resourceexample_la_LIBADD= -lkderesources 221resourceexample_la_LIBADD= -lkderesources
223 222
224linkdir= $(kde_datadir)/resources/family 223linkdir= $(kde_datadir)/resources/family
225link_DATA= resourceexample.desktop 224link_DATA= resourceexample.desktop
226</pre> 225</pre>
227 * 226 *
228 * 227 *
229 */ 228 */
230 229
231/** 230/**
232 * A @ref Resource is a ... 231 * A @ref Resource is a ...
233 * 232 *
234 * A subclass should reimplement at least the constructor and the 233 * A subclass should reimplement at least the constructor and the
235 * @ref writeConfig method. 234k * @ref writeConfig method.
236 * 235 *
237 */ 236 */
238class Resource : public QObject 237class Resource : public QObject
239{ 238{
240 Q_OBJECT 239 Q_OBJECT
241 240
242 public: 241 public:
243 typedef QValueList<Resource *> List; 242 typedef QValueList<Resource *> List;
244 243
245 /** 244 /**
246 * Constructor. Construct resource from config. 245 * Constructor. Construct resource from config.
247 * @param config Configuration to read persistence information from. 246 * @param config Configuration to read persistence information from.
248 * If config==0, create object using default settings. 247 * If config==0, create object using default settings.
249 */ 248 */
250 Resource( const KConfig* config ); 249 Resource( const KConfig* config );
251 250
252 /** 251 /**
253 * Destructor. 252 * Destructor.
254 */ 253 */
255 virtual ~Resource(); 254 virtual ~Resource();
256 255
257 /** 256 /**
258 * Write configuration information for this resource to a configuration 257 * Write configuration information for this resource to a configuration
259 * file. If you override this method, remember to call Resource::writeConfig 258 * file. If you override this method, remember to call Resource::writeConfig
260 * or Terrible Things(TM) will happen. 259 * or Terrible Things(TM) will happen.
261 * @param config Configuration to write persistence information to. 260 * @param config Configuration to write persistence information to.
262 */ 261 */
263 virtual void writeConfig( KConfig* config ); 262 virtual void writeConfig( KConfig* config );
264 263
265 /** 264 /**
266 * Open this resource, if it not already open. Increase the open 265 * Open this resource, if it not already open. Increase the open
267 * count of this object, and open the resource by calling @ref doOpen(). 266 * count of this object, and open the resource by calling @ref doOpen().
@@ -294,125 +293,112 @@ class Resource : public QObject
294 */ 293 */
295 QString identifier() const; 294 QString identifier() const;
296 295
297 /** 296 /**
298 * Returns the type of this resource. 297 * Returns the type of this resource.
299 */ 298 */
300 QString type() const; 299 QString type() const;
301 300
302 /** 301 /**
303 * Mark the resource as read-only. You can override this method, 302 * Mark the resource as read-only. You can override this method,
304 * but also remember to call Resource::setReadOnly(). 303 * but also remember to call Resource::setReadOnly().
305 */ 304 */
306 virtual void setReadOnly( bool value ); 305 virtual void setReadOnly( bool value );
307 306
308 /** 307 /**
309 * Returns, if the resource is read-only. 308 * Returns, if the resource is read-only.
310 */ 309 */
311 virtual bool readOnly() const; 310 virtual bool readOnly() const;
312 311
313 void setIncludeInSync( bool value ); 312 void setIncludeInSync( bool value );
314 bool includeInSync() const; 313 bool includeInSync() const;
315 /** 314 /**
316 * Set the name of resource.You can override this method, 315 * Set the name of resource.You can override this method,
317 * but also remember to call Resource::setResourceName(). 316 * but also remember to call Resource::setResourceName().
318 */ 317 */
319 virtual void setResourceName( const QString &name ); 318 virtual void setResourceName( const QString &name );
320 319
321 /** 320 /**
322 * Returns the name of resource. 321 * Returns the name of resource.
323 */ 322 */
324 virtual QString resourceName() const; 323 virtual QString resourceName() const;
325 324
326
327
328 virtual bool isSyncable() const = 0;
329
330
331 /** 325 /**
332 Sets, if the resource is active. 326 Sets, if the resource is active.
333 */ 327 */
334 void setActive( bool active ); 328 void setActive( bool active );
335 329
336 /** 330 /**
337 Return true, if the resource is active. 331 Return true, if the resource is active.
338 */ 332 */
339 bool isActive() const; 333 bool isActive() const;
340 334
341 friend class Factory; 335 friend class Factory;
342 friend class ManagerImpl; 336 friend class ManagerImpl;
343 337
344 /** 338 /**
345 Print resource information as debug output. 339 Print resource information as debug output.
346 */ 340 */
347 virtual void dump() const; 341 virtual void dump() const;
348 342
349 343
350 protected: 344 protected:
351 /** 345 /**
352 * Open this resource. When called, the resource must be in 346 * Open this resource. When called, the resource must be in
353 * a closed state. 347 * a closed state.
354 * 348 *
355 * Returns true if the resource was opened successfully; 349 * Returns true if the resource was opened successfully;
356 * returns false if the resource was not opened successfully. 350 * returns false if the resource was not opened successfully.
357 * 351 *
358 * The result of this call can be accessed later by @ref isOpen() 352 * The result of this call can be accessed later by @ref isOpen()
359 */ 353 */
360 virtual bool doOpen() { return true; } 354 virtual bool doOpen() { return true; }
361 355
362 /** 356 /**
363 * Close this resource. Pre-condition: resource is open. 357 * Close this resource. Pre-condition: resource is open.
364 * Post-condition: resource is closed. 358 * Post-condition: resource is closed.
365 */ 359 */
366 virtual void doClose() {} 360 virtual void doClose() {}
367 361
368 void setIdentifier( const QString& identifier ); 362 void setIdentifier( const QString& identifier );
369 void setType( const QString& type ); 363 void setType( const QString& type );
370 364
371 private: 365 private:
372 class ResourcePrivate; 366 class ResourcePrivate;
373 ResourcePrivate *d; 367 ResourcePrivate *d;
374}; 368};
375 369
376class PluginFactoryBase : public KLibFactory 370class PluginFactoryBase : public KLibFactory
377{ 371{
378 public: 372 public:
379 virtual Resource *resource( const KConfig *config, bool syncable ) = 0; 373 virtual Resource *resource( const KConfig *config) = 0;
380 374
381 virtual ConfigWidget *configWidget( QWidget *parent ) = 0; 375 virtual ConfigWidget *configWidget( QWidget *parent ) = 0;
382 376
383 virtual SyncWidgetContainer *syncWidgetContainer() = 0;
384
385 protected: 377 protected:
386 virtual QObject* createObject( QObject*, const char*, const char*, 378 virtual QObject* createObject( QObject*, const char*, const char*,
387 const QStringList & ) 379 const QStringList & )
388 { 380 {
389 return 0; 381 return 0;
390 } 382 }
391}; 383};
392 384
393template<class TR,class TC, class TS> 385template<class TR,class TC>
394class PluginFactory : public PluginFactoryBase 386class PluginFactory : public PluginFactoryBase
395{ 387{
396 public: 388 public:
397 Resource *resource( const KConfig *config, bool syncable ) 389 Resource *resource( const KConfig *config)
398 { 390 {
399 return new TR( config, syncable ); 391 return new TR( config );
400 } 392 }
401 393
402 ConfigWidget *configWidget( QWidget *parent ) 394 ConfigWidget *configWidget( QWidget *parent )
403 { 395 {
404 return new TC( parent ); 396 return new TC( parent );
405 } 397 }
406
407 SyncWidgetContainer *syncWidgetContainer()
408 {
409 return new TS();
410 }
411
412}; 398};
413 399
414 400
415 401
416} 402}
417 403
418#endif 404#endif
diff --git a/microkde/microkdeE.pro b/microkde/microkdeE.pro
index df914ce..071ceb3 100644
--- a/microkde/microkdeE.pro
+++ b/microkde/microkdeE.pro
@@ -60,65 +60,64 @@ osmartpointer.h \
60 kdeui/kguiitem.h \ 60 kdeui/kguiitem.h \
61 kdeui/kaction.h \ 61 kdeui/kaction.h \
62 kdeui/kactionclasses.h \ 62 kdeui/kactionclasses.h \
63 kdeui/kactioncollection.h \ 63 kdeui/kactioncollection.h \
64 kdeui/kcmodule.h \ 64 kdeui/kcmodule.h \
65 kdeui/kstdaction.h \ 65 kdeui/kstdaction.h \
66 kdeui/kbuttonbox.h \ 66 kdeui/kbuttonbox.h \
67 kdeui/klistbox.h \ 67 kdeui/klistbox.h \
68 kdeui/klistview.h \ 68 kdeui/klistview.h \
69 kdeui/kjanuswidget.h \ 69 kdeui/kjanuswidget.h \
70 kdeui/kseparator.h \ 70 kdeui/kseparator.h \
71 kdeui/kmainwindow.h \ 71 kdeui/kmainwindow.h \
72 kdeui/knuminput.h \ 72 kdeui/knuminput.h \
73 kdeui/knumvalidator.h \ 73 kdeui/knumvalidator.h \
74 kdeui/ksqueezedtextlabel.h \ 74 kdeui/ksqueezedtextlabel.h \
75 kdeui/ktoolbar.h \ 75 kdeui/ktoolbar.h \
76 kdeui/ktoolbarbutton.h \ 76 kdeui/ktoolbarbutton.h \
77 kdeui/ktoolbarhandler.h \ 77 kdeui/ktoolbarhandler.h \
78 kdeui/kxmlguiclient.h \ 78 kdeui/kxmlguiclient.h \
79 kio/job.h \ 79 kio/job.h \
80 kio/kio/kdirwatch.h \ 80 kio/kio/kdirwatch.h \
81 kio/kio/kdirwatch_p.h \ 81 kio/kio/kdirwatch_p.h \
82 kio/kfile/kurlrequester.h \ 82 kio/kfile/kurlrequester.h \
83 kresources/resource.h \ 83 kresources/resource.h \
84 kresources/factory.h \ 84 kresources/factory.h \
85 kresources/managerimpl.h \ 85 kresources/managerimpl.h \
86 kresources/manager.h \ 86 kresources/manager.h \
87 kresources/selectdialog.h \ 87 kresources/selectdialog.h \
88 kresources/configpage.h \ 88 kresources/configpage.h \
89 kresources/configwidget.h \ 89 kresources/configwidget.h \
90 kresources/configdialog.h \ 90 kresources/configdialog.h \
91 kresources/kcmkresources.h \ 91 kresources/kcmkresources.h \
92 kresources/syncwidget.h \
93 kdecore/kmdcodec.h \ 92 kdecore/kmdcodec.h \
94 kdecore/kconfigbase.h \ 93 kdecore/kconfigbase.h \
95 kdecore/klocale.h \ 94 kdecore/klocale.h \
96 kdecore/klibloader.h \ 95 kdecore/klibloader.h \
97 kdecore/kcatalogue.h \ 96 kdecore/kcatalogue.h \
98 kdecore/kprefs.h \ 97 kdecore/kprefs.h \
99 kdecore/ksharedptr.h \ 98 kdecore/ksharedptr.h \
100 kdecore/kshell.h \ 99 kdecore/kshell.h \
101 kdecore/kstandarddirs.h \ 100 kdecore/kstandarddirs.h \
102 kdecore/kstringhandler.h \ 101 kdecore/kstringhandler.h \
103 kdecore/kshortcut.h \ 102 kdecore/kshortcut.h \
104 kutils/kcmultidialog.h \ 103 kutils/kcmultidialog.h \
105 kidmanager.h 104 kidmanager.h
106 105
107 106
108 107
109 108
110SOURCES = \ 109SOURCES = \
111KDGanttMinimizeSplitter.cpp \ 110KDGanttMinimizeSplitter.cpp \
112 kapplication.cpp \ 111 kapplication.cpp \
113 kcalendarsystem.cpp \ 112 kcalendarsystem.cpp \
114 kcalendarsystemgregorian.cpp \ 113 kcalendarsystemgregorian.cpp \
115 kcolorbutton.cpp \ 114 kcolorbutton.cpp \
116 kcolordialog.cpp \ 115 kcolordialog.cpp \
117 kconfig.cpp \ 116 kconfig.cpp \
118 kdatetbl.cpp \ 117 kdatetbl.cpp \
119 kdialog.cpp \ 118 kdialog.cpp \
120 kdialogbase.cpp \ 119 kdialogbase.cpp \
121 keditlistbox.cpp \ 120 keditlistbox.cpp \
122 kemailsettings.cpp \ 121 kemailsettings.cpp \
123 kfontdialog.cpp \ 122 kfontdialog.cpp \
124 kfiledialog.cpp \ 123 kfiledialog.cpp \
@@ -144,36 +143,35 @@ oprocess.cpp \
144 kdecore/kshell.cpp \ 143 kdecore/kshell.cpp \
145 kdecore/kstandarddirs.cpp \ 144 kdecore/kstandarddirs.cpp \
146 kdecore/kstringhandler.cpp \ 145 kdecore/kstringhandler.cpp \
147 kdeui/kaction.cpp \ 146 kdeui/kaction.cpp \
148 kdeui/kactionclasses.cpp \ 147 kdeui/kactionclasses.cpp \
149 kdeui/kactioncollection.cpp \ 148 kdeui/kactioncollection.cpp \
150 kdeui/kbuttonbox.cpp \ 149 kdeui/kbuttonbox.cpp \
151 kdeui/kcmodule.cpp \ 150 kdeui/kcmodule.cpp \
152 kdeui/kguiitem.cpp \ 151 kdeui/kguiitem.cpp \
153 kdeui/kjanuswidget.cpp \ 152 kdeui/kjanuswidget.cpp \
154 kdeui/klistbox.cpp \ 153 kdeui/klistbox.cpp \
155 kdeui/klistview.cpp \ 154 kdeui/klistview.cpp \
156 kdeui/kmainwindow.cpp \ 155 kdeui/kmainwindow.cpp \
157 kdeui/knuminput.cpp \ 156 kdeui/knuminput.cpp \
158 kdeui/knumvalidator.cpp \ 157 kdeui/knumvalidator.cpp \
159 kdeui/kseparator.cpp \ 158 kdeui/kseparator.cpp \
160 kdeui/kstdaction.cpp \ 159 kdeui/kstdaction.cpp \
161 kdeui/ksqueezedtextlabel.cpp \ 160 kdeui/ksqueezedtextlabel.cpp \
162 kdeui/ktoolbar.cpp \ 161 kdeui/ktoolbar.cpp \
163 kdeui/ktoolbarbutton.cpp \ 162 kdeui/ktoolbarbutton.cpp \
164 kdeui/ktoolbarhandler.cpp \ 163 kdeui/ktoolbarhandler.cpp \
165 kdeui/kxmlguiclient.cpp \ 164 kdeui/kxmlguiclient.cpp \
166 kio/kfile/kurlrequester.cpp \ 165 kio/kfile/kurlrequester.cpp \
167 kio/kio/kdirwatch.cpp \ 166 kio/kio/kdirwatch.cpp \
168 kresources/configpage.cpp \ 167 kresources/configpage.cpp \
169 kresources/configdialog.cpp \ 168 kresources/configdialog.cpp \
170 kresources/configwidget.cpp \ 169 kresources/configwidget.cpp \
171 kresources/factory.cpp \ 170 kresources/factory.cpp \
172 kresources/kcmkresources.cpp \ 171 kresources/kcmkresources.cpp \
173 kresources/managerimpl.cpp \ 172 kresources/managerimpl.cpp \
174 kresources/resource.cpp \ 173 kresources/resource.cpp \
175 kresources/selectdialog.cpp \ 174 kresources/selectdialog.cpp \
176 kresources/syncwidget.cpp \
177 kutils/kcmultidialog.cpp \ 175 kutils/kcmultidialog.cpp \
178 kidmanager.cpp 176 kidmanager.cpp
179 177