summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Unidiff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 17b9ba2..adb451f 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -209,98 +209,101 @@ bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
209 return ( d->mIt == it.d->mIt ); 209 return ( d->mIt == it.d->mIt );
210} 210}
211 211
212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
213{ 213{
214 return ( d->mIt != it.d->mIt ); 214 return ( d->mIt != it.d->mIt );
215} 215}
216 216
217 217
218AddressBook::AddressBook() 218AddressBook::AddressBook()
219{ 219{
220 init(0, "contact"); 220 init(0, "contact");
221} 221}
222 222
223AddressBook::AddressBook( const QString &config ) 223AddressBook::AddressBook( const QString &config )
224{ 224{
225 init(config, "contact"); 225 init(config, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config, const QString &family ) 228AddressBook::AddressBook( const QString &config, const QString &family )
229{ 229{
230 init(config, family); 230 init(config, family);
231 231
232} 232}
233 233
234// the default family is "contact" 234// the default family is "contact"
235void AddressBook::init(const QString &config, const QString &family ) 235void AddressBook::init(const QString &config, const QString &family )
236{ 236{
237 blockLSEchange = false; 237 blockLSEchange = false;
238 d = new AddressBookData; 238 d = new AddressBookData;
239 QString fami = family; 239 QString fami = family;
240 qDebug("new ab "); 240 qDebug("new ab ");
241 if (config != 0) { 241 if (config != 0) {
242 qDebug("config != 0 "); 242 qDebug("config != 0 ");
243 if ( family == "syncContact" ) { 243 if ( family == "syncContact" ) {
244 qDebug("creating sync config "); 244 qDebug("creating sync config ");
245 fami = "contact"; 245 fami = "contact";
246 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 246 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
247 con->setGroup( "General" ); 247 con->setGroup( "General" );
248 con->writeEntry( "ResourceKeys", QString("sync") ); 248 con->writeEntry( "ResourceKeys", QString("sync") );
249 con->writeEntry( "Standard", QString("sync") ); 249 con->writeEntry( "Standard", QString("sync") );
250 con->setGroup( "Resource_sync" ); 250 con->setGroup( "Resource_sync" );
251 con->writeEntry( "FileName", config ); 251 con->writeEntry( "FileName", config );
252 con->writeEntry( "FileFormat", QString("vcard") ); 252 con->writeEntry( "FileFormat", QString("vcard") );
253 con->writeEntry( "ResourceIdentifier", QString("sync") ); 253 con->writeEntry( "ResourceIdentifier", QString("sync") );
254 con->writeEntry( "ResourceName", QString("sync_res") ); 254 con->writeEntry( "ResourceName", QString("sync_res") );
255 if ( config.right(4) == ".xml" ) 255 if ( config.right(4) == ".xml" )
256 con->writeEntry( "ResourceType", QString("qtopia") ); 256 con->writeEntry( "ResourceType", QString("qtopia") );
257 else 257 else if ( config == "sharp" ) {
258 con->writeEntry( "ResourceType", QString("sharp") );
259 } else {
258 con->writeEntry( "ResourceType", QString("file") ); 260 con->writeEntry( "ResourceType", QString("file") );
261 }
259 //con->sync(); 262 //con->sync();
260 d->mConfig = con; 263 d->mConfig = con;
261 } 264 }
262 else 265 else
263 d->mConfig = new KConfig( locateLocal("config", config) ); 266 d->mConfig = new KConfig( locateLocal("config", config) );
264// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 267// qDebug("AddressBook::init 1 config=%s",config.latin1() );
265 } 268 }
266 else { 269 else {
267 d->mConfig = 0; 270 d->mConfig = 0;
268// qDebug("AddressBook::init 1 config=0"); 271// qDebug("AddressBook::init 1 config=0");
269 } 272 }
270 273
271//US d->mErrorHandler = 0; 274//US d->mErrorHandler = 0;
272 d->mManager = new KRES::Manager<Resource>( fami, false ); 275 d->mManager = new KRES::Manager<Resource>( fami, false );
273 d->mManager->readConfig( d->mConfig ); 276 d->mManager->readConfig( d->mConfig );
274 if ( family == "syncContact" ) { 277 if ( family == "syncContact" ) {
275 KRES::Manager<Resource> *manager = d->mManager; 278 KRES::Manager<Resource> *manager = d->mManager;
276 KRES::Manager<Resource>::ActiveIterator it; 279 KRES::Manager<Resource>::ActiveIterator it;
277 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 280 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
278 (*it)->setAddressBook( this ); 281 (*it)->setAddressBook( this );
279 if ( !(*it)->open() ) 282 if ( !(*it)->open() )
280 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 283 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
281 } 284 }
282 Resource *res = standardResource(); 285 Resource *res = standardResource();
283 if ( !res ) { 286 if ( !res ) {
284 qDebug("ERROR: no standard resource"); 287 qDebug("ERROR: no standard resource");
285 res = manager->createResource( "file" ); 288 res = manager->createResource( "file" );
286 if ( res ) 289 if ( res )
287 { 290 {
288 addResource( res ); 291 addResource( res );
289 } 292 }
290 else 293 else
291 qDebug(" No resource available!!!"); 294 qDebug(" No resource available!!!");
292 } 295 }
293 setStandardResource( res ); 296 setStandardResource( res );
294 manager->writeConfig(); 297 manager->writeConfig();
295 } 298 }
296 addCustomField( i18n( "Department" ), KABC::Field::Organization, 299 addCustomField( i18n( "Department" ), KABC::Field::Organization,
297 "X-Department", "KADDRESSBOOK" ); 300 "X-Department", "KADDRESSBOOK" );
298 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 301 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
299 "X-Profession", "KADDRESSBOOK" ); 302 "X-Profession", "KADDRESSBOOK" );
300 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 303 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
301 "X-AssistantsName", "KADDRESSBOOK" ); 304 "X-AssistantsName", "KADDRESSBOOK" );
302 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 305 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
303 "X-ManagersName", "KADDRESSBOOK" ); 306 "X-ManagersName", "KADDRESSBOOK" );
304 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 307 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
305 "X-SpousesName", "KADDRESSBOOK" ); 308 "X-SpousesName", "KADDRESSBOOK" );
306 addCustomField( i18n( "Office" ), KABC::Field::Personal, 309 addCustomField( i18n( "Office" ), KABC::Field::Personal,