rem: QString host = KolabConfig::self()->server(); QString basedn = host; 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"); }
add: KCal::CalendarResourceManager m( "calendar" ); m.readConfig(); QString server = KolabConfig::self()->server(); KCal::ResourceIMAP *r = new KCal::ResourceIMAP( server ); r->setResourceName( i18n("Kolab Server") ); m.add( r ); m.writeConfig();
context:     void apply()    {      QString host = KolabConfig::self()->server();      QString basedn = host;      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");      }    }