rem: KCal::CalendarResourceManager m( "calendar" ); m.readConfig(); KCal::ResourceKolab *r = new KCal::ResourceKolab( 0 ); r->setResourceName( i18n("Kolab Server") ); m.add( r ); m.setStandardResource( r ); m.writeConfig();
add: const QString host = KolabConfig::self()->server();   QString basedn = host;   const QString user = KolabConfig::self()->user(); int pos = user.find( "@" ); if ( pos > 0 ) { const QString h = user.mid( pos+1 ); if ( !h.isEmpty() )  basedn = h; } { KConfig c( "kmailrc" ); c.setGroup( "General" ); c.writeEntry( "Default domain", basedn ); }  basedn.replace(".",",dc="); basedn.prepend("dc=");   KConfig c( "kabldaprc" ); c.setGroup( "LDAP" ); bool hasMyServer = false; uint selHosts = c.readNumEntry("NumSelectedHosts", 0); for ( uint i = 0 ; i < selHosts && !hasMyServer; ++i ) if ( c.readEntry( QString("SelectedHost%1").arg(i) ) == host ) hasMyServer = true; if ( !hasMyServer ) { c.writeEntry( "NumSelectedHosts", selHosts + 1 ); c.writeEntry( QString("SelectedHost%1").arg(selHosts), host); c.writeEntry( QString("SelectedBase%1").arg(selHosts), basedn); c.writeEntry( QString("SelectedPort%1").arg(selHosts), "389"); }
context:     void apply()    {      KCal::CalendarResourceManager m( "calendar" );      m.readConfig();      KCal::ResourceKolab *r = new KCal::ResourceKolab( 0 );      r->setResourceName( i18n("Kolab Server") );      m.add( r );      m.setStandardResource( r );      m.writeConfig();    }