Author: helio
Date: Thu Nov 23 17:10:35 2006
New Revision: 86673

Added:
   packages/cooker/kdelibs/current/SOURCES/kdelibs-3.5.5-ldap-kconfig.patch
   packages/cooker/kdelibs/current/SOURCES/kdelibs-3.5.5.20061120.tar.bz2   
(contents, props changed)
Removed:
   packages/cooker/kdelibs/current/SOURCES/kdelibs-3.5.5.tar.bz2
Modified:
   packages/cooker/kdelibs/current/SPECS/kdelibs.spec

Log:
- Introducing ldap patch for kconfig. All work is done based on future kde
  3.5.6, so for now on we are basing our releases on KDE 3.5 branch snaphots. 
The cost of
  develop patches for old codebase and after redone again same work is more 
than the
  time we have available for complete work and test.
- the current patch is strongly based on Willem Verschuur work provided for
  Mandriva and is the server read part. The operations are done sync, not async.
- TODO: Make a env var switch to turn on/off ldap on the fly ( current just on
  configure to enable/disable feature )
- TODO: Verify immutable conditions for global and single items. Group immutable
  properties are available already


Added: packages/cooker/kdelibs/current/SOURCES/kdelibs-3.5.5-ldap-kconfig.patch
==============================================================================
--- (empty file)
+++ packages/cooker/kdelibs/current/SOURCES/kdelibs-3.5.5-ldap-kconfig.patch    
Thu Nov 23 17:10:35 2006
@@ -0,0 +1,1187 @@
+diff -u -N -r kdelibs.orig/kdecore/configure.in.in 
kdelibs-3.5.5/kdecore/configure.in.in
+--- kdelibs.orig/kdecore/configure.in.in       2005-11-29 16:01:07.000000000 
-0200
++++ kdelibs-3.5.5/kdecore/configure.in.in      2006-11-23 13:16:44.000000000 
-0200
+@@ -231,3 +231,116 @@
+       ],
+       AC_MSG_RESULT(no)
+ )
++
++AC_MSG_CHECKING(for LDAP support)
++AC_ARG_WITH(ldap,
++AC_HELP_STRING([--with-ldap=PATH],[Set path for LDAP files [default=check]]),
++[ case "$withval" in
++  yes)
++    with_ldap=CHECK
++    ;;
++  esac ],
++[ with_ldap=CHECK ]
++)dnl
++
++if test "x$with_ldap" = "xCHECK" ; then
++  with_ldap=NOTFOUND
++  search_incs="$kde_includes /usr/include /usr/local/include"
++  AC_FIND_FILE(ldap.h, $search_incs, ldap_incdir)
++  if test -r $ldap_incdir/ldap.h ; then
++    test "x$ldap_incdir" != "x/usr/include" && LDAP_INCS="-I$ldap_incdir"
++    with_ldap=FOUND
++  fi
++  if test $with_ldap = FOUND ; then
++    with_ldap=NOTFOUND
++    for ext in la so sl a dylib ; do
++      AC_FIND_FILE(libldap.$ext, $kde_libraries /usr/lib /usr/local/lib 
/usr/lib64,
++        ldap_libdir)
++      if test -r $ldap_libdir/libldap.$ext ; then
++        if test "x$ldap_libdir" != "x/usr/lib" ; then
++          LDAP_LIBS="-L$ldap_libdir "
++          test "$USE_RPATH" = yes && LDAP_RPATH="-R $ldap_libdir"
++        fi
++        LDAP_LIBS="${LDAP_LIBS}-lldap"
++        with_ldap=FOUND
++        break
++      fi
++    done
++  fi
++fi
++
++case "$with_ldap" in
++no) AC_MSG_RESULT(no) ;;
++framework)
++  LDAP_LIBS="-Xlinker -framework -Xlinker LDAP"
++  AC_DEFINE_UNQUOTED(HAVE_LIBLDAP, 1, [Define if you have LDAP libraries])
++  LDAP_SUBDIR="ldap"
++  AC_MSG_RESULT(Apple framework)
++  ;;
++FOUND)
++  AC_MSG_RESULT(incs=$ldap_incdir libs=$ldap_libdir)
++  ;;
++NOTFOUND) AC_MSG_RESULT(searched but not found) ;;
++*)
++  AC_MSG_RESULT($with_ldap)
++  ;;
++esac
++
++AC_MSG_CHECKING(whether LDAP support can be compiled)
++
++  if test "x$with_ldap" != "xFOUND" ; then
++    LDAP_ROOT="$with_ldap"
++    if test "x$LDAP_ROOT" != "x/usr" ; then
++      LDAP_INCS="-I${LDAP_ROOT}/include"
++      LDAP_LIBS="-L${LDAP_ROOT}/lib "
++      if test "$USE_RPATH" = "yes" ; then
++        LDAP_RPATH="-R ${LDAP_ROOT}/lib"
++      fi
++    fi
++    LDAP_LIBS="${LDAP_LIBS}-lldap"
++  fi
++  LDAP_LIBS="${LDAP_LIBS} ${LIB_LBER} ${LIBRESOLV}"
++
++  kde_safe_LIBS="$LIBS"
++  kde_safe_CFLAGS="$CFLAGS"
++  kde_safe_CXXFLAGS="$CXXFLAGS"
++  LIBS="$LIBS $all_libraries $LDAP_LIBS $KRB4_LIBS $X_EXTRA_LIBS"
++  CFLAGS="$CFLAGS $all_includes $LDAP_INCS -DLDAP_DEPRECATED"
++  CXXFLAGS="$CXXFLAGS $all_includes $LDAP_INCS -DLDAP_DEPRECATED"
++
++  AC_LANG_SAVE
++  AC_LANG_C
++  AC_TRY_LINK(dnl
++  [
++  #include <ldap.h>
++  #if LDAP_API_VERSION < 2004
++  #error LDAP version too old, please upgrade to a library supporting API 
2004 or higher
++  #endif
++  ],
++  [
++  LDAP *ldap;
++  ],
++  , with_ldap=no
++  )
++  AC_LANG_RESTORE
++  if test "$with_ldap" = "no" ; then
++    LDAP_INCS=
++    LDAP_LIBS=
++    LDAP_RPATH=
++    LDAP_SUBDIR=
++    CFLAGS=$kde_safe_CFLAGS
++    CXXFLAGS=$kde_safe_CXXFLAGS
++    LIBS=$kde_safe_LIBS
++    AC_MSG_RESULT(no (but first try gave $msg))
++  else
++    AC_DEFINE_UNQUOTED(HAVE_LIBLDAP, 1, [Define if you have LDAP libraries])
++    LDAP_SUBDIR="ldap"
++    AC_MSG_RESULT(yes)
++  fi
++
++AC_SUBST(LDAP_INCS)
++AC_SUBST(LDAP_LIBS)
++AC_SUBST(LDAP_RPATH)
++
++
++
+diff -u -N -r kdelibs.orig/kdecore/kconfigbase.cpp 
kdelibs-3.5.5/kdecore/kconfigbase.cpp
+--- kdelibs.orig/kdecore/kconfigbase.cpp       2005-10-22 04:42:27.000000000 
-0200
++++ kdelibs-3.5.5/kdecore/kconfigbase.cpp      2006-11-23 10:52:26.000000000 
-0200
+@@ -38,25 +38,18 @@
+ #include "kstandarddirs.h"
+ #include "kstringhandler.h"
+ 
+-class KConfigBase::KConfigBasePrivate
+-{
+-public:
+-     KConfigBasePrivate() : readDefaults(false) { };
+-
+-public:
+-     bool readDefaults;
+-};
+-
+ KConfigBase::KConfigBase()
+   : backEnd(0L), bDirty(false), bLocaleInitialized(false),
+-    bReadOnly(false), bExpand(false), d(0)
++    bReadOnly(false), bExpand(false), m_Private(0)
+ {
++    m_Private = m_Private = new KConfigBasePrivate();
++    m_Private->backEnds.setAutoDelete(true);
+     setGroup(QString::null);
+ }
+ 
+ KConfigBase::~KConfigBase()
+ {
+-    delete d;
++    delete m_Private;
+ }
+ 
+ void KConfigBase::setLocale()
+@@ -1665,14 +1658,23 @@
+ 
+ void KConfigBase::parseConfigFiles()
+ {
++
+   if (!bLocaleInitialized && KGlobal::_locale) {
+     setLocale();
+   }
++
++  for ( KConfigBackEnd* backend = m_Private->backEnds.first();
++        backend;
++        backend = m_Private->backEnds.next() )
++  {
++      backend->parseConfigFiles();
++  }
++
+   if (backEnd)
+   {
+-     backEnd->parseConfigFiles();
+-     bReadOnly = (backEnd->getConfigState() == ReadOnly);
++      bReadOnly = (backEnd->getConfigState() == ReadOnly);
+   }
++
+ }
+ 
+ void KConfigBase::sync()
+@@ -1700,18 +1702,12 @@
+ 
+ void KConfigBase::setReadDefaults(bool b)
+ {
+-  if (!d)
+-  {
+-     if (!b) return;
+-     d = new KConfigBasePrivate();
+-  }
+-
+-  d->readDefaults = b;
++  m_Private->readDefaults = b;
+ }
+ 
+ bool KConfigBase::readDefaults() const
+ {
+-  return (d && d->readDefaults);
++  return (m_Private && m_Private->readDefaults);
+ }
+ 
+ void KConfigBase::revertToDefault(const QString &key)
+diff -u -N -r kdelibs.orig/kdecore/kconfigbase.h 
kdelibs-3.5.5/kdecore/kconfigbase.h
+--- kdelibs.orig/kdecore/kconfigbase.h 2006-10-02 18:38:52.000000000 -0300
++++ kdelibs-3.5.5/kdecore/kconfigbase.h        2006-11-23 13:35:45.000000000 
-0200
+@@ -23,6 +23,7 @@
+ #ifndef _KCONFIGBASE_H
+ #define _KCONFIGBASE_H
+ 
++#include <config.h>
+ #include <qobject.h>
+ #include <qcolor.h>
+ #include <qfont.h>
+@@ -73,6 +74,7 @@
+ 
+   friend class KConfigBackEnd;
+   friend class KConfigINIBackEnd;
++  friend class KConfigLDAPBackEnd;
+   friend class KConfigGroup;
+ 
+ public:
+@@ -2005,9 +2007,19 @@
+ 
+ protected:
+   virtual void virtual_hook( int id, void* data );
+-private:
+-  class KConfigBasePrivate;
+-  KConfigBasePrivate *d;
++  
++protected:
++  class KConfigBasePrivate
++  {
++  public:
++     KConfigBasePrivate() : readDefaults(false) { };
++
++  public:
++     bool                       readDefaults;
++     QPtrList<KConfigBackEnd>   backEnds;
++  };
++
++  KConfigBasePrivate *m_Private;
+ };
+ 
+ class KConfigGroupSaverPrivate;
+diff -u -N -r kdelibs.orig/kdecore/kconfig.cpp 
kdelibs-3.5.5/kdecore/kconfig.cpp
+--- kdelibs.orig/kdecore/kconfig.cpp   2006-09-01 13:26:04.000000000 -0300
++++ kdelibs-3.5.5/kdecore/kconfig.cpp  2006-11-23 10:52:26.000000000 -0200
+@@ -34,6 +34,7 @@
+ 
+ #include <kapplication.h>
+ #include "kconfigbackend.h"
++#include "kconfigldapbackend.h"
+ 
+ #include "kconfig.h"
+ #include "kglobal.h"
+@@ -49,17 +50,26 @@
+   // set the object's read-only status.
+   setReadOnly(bReadOnly);
+ 
+-  // for right now we will hardcode that we are using the INI
++  // for right now we will hardcode that we are using the INI & LDAP
+   // back end driver.  In the future this should be converted over to
+   // a object factory of some sorts.
+-  KConfigINIBackEnd *aBackEnd = new KConfigINIBackEnd(this,
++  // and to configure precedence and exclusion
++  KConfigLDAPBackEnd *ldapBackEnd = new KConfigLDAPBackEnd(this,
++                              fileName,
++                              resType,
++                              bUseKderc);
++                              
++  KConfigINIBackEnd *iniBackEnd = new KConfigINIBackEnd(this,
+                                                     fileName,
+-                                                      resType,
++                              resType,
+                                                     bUseKderc);
+ 
++  m_Private->backEnds.append(ldapBackEnd);
++  m_Private->backEnds.append(iniBackEnd);
++          
+   // set the object's back end pointer to this new backend
+-  backEnd = aBackEnd;
+-
++  backEnd = iniBackEnd;
++  
+   // read initial information off disk
+   reparseConfiguration();
+ 
+@@ -88,7 +98,8 @@
+ {
+   sync();
+ 
+-  delete backEnd;
++  // delete taken care of by destruction of kconfibase's private class
++  //delete backEnd;
+ }
+ 
+ void KConfig::rollback(bool bDeep)
+diff -u -N -r kdelibs.orig/kdecore/kconfigldapbackend.cpp 
kdelibs-3.5.5/kdecore/kconfigldapbackend.cpp
+--- kdelibs.orig/kdecore/kconfigldapbackend.cpp        1969-12-31 
21:00:00.000000000 -0300
++++ kdelibs-3.5.5/kdecore/kconfigldapbackend.cpp       2006-11-23 
13:54:44.000000000 -0200
+@@ -0,0 +1,173 @@
++/*
++  This file is part of the KDE libraries
++  Copyright (c) 2005 Willem Verschuur <[EMAIL PROTECTED]>
++  Copyright (c) 2006 Helio Chissini de Castro <[EMAIL PROTECTED]>
++
++  This library is free software; you can redistribute it and/or
++  modify it under the terms of the GNU Library General Public
++  License as published by the Free Software Foundation; either
++  version 2 of the License, or (at your option) any later version.
++
++  This library is distributed in the hope that it will be useful,
++  but WITHOUT ANY WARRANTY; without even the implied warranty of
++  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++  Library General Public License for more details.
++
++  You should have received a copy of the GNU Library General Public License
++  along with this library; see the file COPYING.LIB.  If not, write to
++  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
++  Boston, MA 02110-1301, USA.
++*/
++
++#include "kconfigldapbackend.h"
++#include "kconfigdata.h"
++#include "kuser.h"
++#include "xldaplite.h"
++
++KConfigLDAPBackEnd::KConfigLDAPBackEnd( KConfigBase *config, 
++                                        const QString &fileName,
++                                        const char * resType, 
++                                        bool useKDEGlobals )
++
++    :   KConfigBackEnd(config, fileName, resType, useKDEGlobals)
++
++{
++}
++
++
++
++
++KConfigLDAPBackEnd::~KConfigLDAPBackEnd()
++{
++}
++
++
++
++bool KConfigLDAPBackEnd::parseConfigFiles()
++{
++    // will result in an invalid search anyway..
++    if (mfileName.isEmpty()) 
++       return false;
++
++    // blacklists some entries to avoid uselless queries
++    if (  mfileName == "kdebugrc" 
++          || mfileName == "kconf_updaterc" 
++          || mfileName == "kdedrc"
++          || mfileName == "kdeinitrc"
++          || mfileName == "kbuildsycocarc"
++          || mfileName.startsWith( "/" ) )
++       return false;
++
++    // connect to ldap server
++    xLDAPconnection ldap;
++    if (!ldap.connect()) return false;
++
++    // User and profilelist
++    KUser user;
++    QString basedn = QString( "cn=%1,ou=default,ou=KDEConfig,%2" ).arg( 
mfileName ).arg( ldap.base() );
++    QStringList profiles( basedn );
++
++    // Query group profile
++    basedn = 
QString("uid=%1,ou=People,%2").arg(user.loginName()).arg(ldap.base());
++    char *attrs[] = { "seealso", 0 };
++    xLDAPquery query( ldap, "(objectClass=posixAccount)", basedn, attrs );
++
++    for ( xLDAPiterator section(query); section; ++section )
++    {
++               for ( xLDAPattribute gattr(section); gattr; ++gattr )
++               {
++          basedn = QString( "cn=%1,%2" ).arg( mfileName ).arg( 
gattr.firstValue() );
++          profiles.push_front( basedn );
++               }
++    }
++
++ for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); 
++it ) 
++ {
++       xLDAPquery query( ldap, "(objectClass=appConfigSection)", *it );
++
++       // write results to application settings 
++       // iterate through sections/groups
++       for ( xLDAPiterator section(query); section; ++section )
++       {
++               QCString aCurrentGroup = "<default>";
++               bool groupimmutable = false;
++               // find out group name and flags
++               for ( xLDAPattribute gattr(section); gattr; ++gattr )
++               {
++                       // section name
++                       if (!strcmp(gattr.attribute(), "cn"))
++                               aCurrentGroup = gattr.firstValue();
++                       else if (!strcmp(gattr.attribute(), "immuteable")) // 
immutable
++        groupimmutable = (0 == strcmp(gattr.firstValue(), "TRUE"));
++               }
++
++               // backwards compatibility
++               if (aCurrentGroup == "KDE Desktop Entry")
++                       aCurrentGroup = "Desktop Entry";
++
++               KEntryKey groupKey(aCurrentGroup, 0);
++               KEntry entry = pConfig->lookupData(groupKey);
++               bool groupSkip = entry.bImmutable;
++               
++               if (groupSkip)
++                       continue;
++      
++               entry.bImmutable |= groupimmutable;
++               pConfig->putData(groupKey, entry, false);
++  
++               // set attribute values
++               for ( xLDAPattribute attr(section);  attr; ++attr )
++               {
++                       if (strcmp(attr.attribute(), "appconfigentry")) 
continue;
++                       for ( char* cattr = (char*) attr.firstValue();
++                                       cattr;
++                                       cattr = (char*) attr.nextValue() )
++                       {
++                               QCString cattribute((const char*) cattr); 
++                               cattr = cattribute.data();
++                               char* ceq = (char*) strchr(cattr, '=');
++                               if (!ceq) continue;
++        
++        *ceq = 0;
++        char* cvalue = ++ceq;
++        
++        // insert the key/value line
++        KEntryKey aEntryKey(aCurrentGroup, cattr);
++        aEntryKey.bLocal = false; //(locale != 0);
++        aEntryKey.bDefault = false; //bDefault; meep?
++
++        KEntry aEntry;
++        aEntry.mValue = cvalue;
++        aEntry.bGlobal = true; //bGlobal;
++        aEntry.bImmutable = false; //optionImmutable;
++        aEntry.bDeleted = false; // optionDeleted;
++        aEntry.bExpand = false; // optionExpand;
++        aEntry.bNLS = false; //(locale != 0);
++
++        pConfig->putData( aEntryKey, // group
++                          aEntry,    // entry
++                          false );   
++                       }
++               }
++       }
++ }
++
++    // return successful
++    return true;
++
++}
++
++
++
++void KConfigLDAPBackEnd::sync(bool bMerge)
++{
++    // write back to ldap server..
++}
++
++
++
++void KConfigLDAPBackEnd::virtual_hook(int id, void* data)
++{
++    KConfigBackEnd::virtual_hook( id, data );
++}
++
+diff -u -N -r kdelibs.orig/kdecore/kconfigldapbackend.h 
kdelibs-3.5.5/kdecore/kconfigldapbackend.h
+--- kdelibs.orig/kdecore/kconfigldapbackend.h  1969-12-31 21:00:00.000000000 
-0300
++++ kdelibs-3.5.5/kdecore/kconfigldapbackend.h 2006-11-23 13:55:32.000000000 
-0200
+@@ -0,0 +1,50 @@
++/*
++  This file is part of the KDE libraries
++  Copyright (c) 2005 Willem Verschuur <[EMAIL PROTECTED]>
++  Copyright (c) 2006 Helio Chissini de Castro <[EMAIL PROTECTED]>
++
++  This library is free software; you can redistribute it and/or
++  modify it under the terms of the GNU Library General Public
++  License as published by the Free Software Foundation; either
++  version 2 of the License, or (at your option) any later version.
++
++  This library is distributed in the hope that it will be useful,
++  but WITHOUT ANY WARRANTY; without even the implied warranty of
++  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++  Library General Public License for more details.
++
++  You should have received a copy of the GNU Library General Public License
++  along with this library; see the file COPYING.LIB.  If not, write to
++  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
++  Boston, MA 02110-1301, USA.
++*/
++
++#ifndef KCONFIGLDAPBACKEND_H
++#define KCONFIGLDAPBACKEND_H
++
++#include "kconfigbackend.h"
++
++/**
++ * Class for KDE INI-style configuration file loading/saving from LDAP
++ *
++ * @author Willem Verschuur <[EMAIL PROTECTED]>
++ * @author Helio Chissini de Castro <[EMAIL PROTECTED]>
++ */
++
++class KDECORE_EXPORT KConfigLDAPBackEnd : public KConfigBackEnd
++{
++   public:
++      KConfigLDAPBackEnd( KConfigBase *_config, const QString &_fileName, 
const char * _resType, bool _useKDEGlobals = true );
++      virtual ~KConfigLDAPBackEnd();
++      bool parseConfigFiles();
++      virtual void sync(bool bMerge = true);
++      void setEnabled( bool enb ) { enabled = enb; }
++      bool getEnabled( ) { return enabled; }
++
++   protected:
++      virtual void virtual_hook(int id, void* data);
++      bool enabled;
++};
++
++#endif
++
+diff -u -N -r kdelibs.orig/kdecore/Makefile.am 
kdelibs-3.5.5/kdecore/Makefile.am
+--- kdelibs.orig/kdecore/Makefile.am   2006-09-11 11:47:04.000000000 -0300
++++ kdelibs-3.5.5/kdecore/Makefile.am  2006-11-23 11:35:58.000000000 -0200
+@@ -39,7 +39,8 @@
+ include_HEADERS = kconfig.h kconfigskeleton.h \
+       kconfigdata.h ksimpleconfig.h kconfigdialogmanager.h \
+       kconfigbase.h kdesktopfile.h kurl.h ksock.h kaboutdata.h \
+-      kcmdlineargs.h kconfigbackend.h kapp.h kapplication.h kuniqueapp.h \
++      kcmdlineargs.h kconfigbackend.h kconfigldapbackend.h \
++      xldaplite.h kapp.h kapplication.h kuniqueapp.h \
+       kuniqueapplication.h kcharsets.h kdeversion.h kpty.h kprocess.h \
+       kprocctrl.h klocale.h kicontheme.h kiconloader.h kdebug.h \
+       kwinmodule.h kwin.h krootprop.h kshortcut.h kkeynative.h kaccel.h \
+@@ -85,7 +86,8 @@
+ 
+ libkdecore_la_SOURCES = libintl.cpp kapplication.cpp \
+       kdebug.cpp netwm.cpp kconfigbase.cpp kconfig.cpp  ksimpleconfig.cpp \
+-      kconfigbackend.cpp kmanagerselection.cpp kdesktopfile.cpp \
++      kconfigbackend.cpp kconfigldapbackend.cpp xldaplite.cpp \
++      kmanagerselection.cpp kdesktopfile.cpp \
+       kstandarddirs.cpp ksock.cpp kpty.cpp kprocess.cpp kprocctrl.cpp \
+       klocale.cpp krfcdate.cpp kiconeffect.cpp kicontheme.cpp \
+       kiconloader.cpp kwin.cpp kwinmodule.cpp krootprop.cpp kcharsets.cpp \
+@@ -116,7 +118,7 @@
+       kqiodevicegzip_p.cpp ktimezones.cpp
+ 
+ libkdecore_la_LDFLAGS = $(QT_LDFLAGS) $(KDE_RPATH) $(KDE_MT_LDFLAGS) 
$(X_LDFLAGS) $(USER_LDFLAGS) -version-info 6:0:2 -no-undefined
+-libkdecore_la_LIBADD = malloc/libklmalloc.la network/libkdecorenetwork.la 
$(SVGICON_LIB) ../dcop/libDCOP.la ../libltdl/libltdlc.la $(LIB_XEXT) 
$(LIBRESOLV) $(LIBUTIL) $(LIBART_LIBS) $(LIB_IDN) ../kdefx/libkdefx.la
++libkdecore_la_LIBADD = malloc/libklmalloc.la network/libkdecorenetwork.la 
$(SVGICON_LIB) ../dcop/libDCOP.la ../libltdl/libltdlc.la $(LIB_XEXT) 
$(LIBRESOLV) $(LIBUTIL) $(LIBART_LIBS) $(LIB_IDN) ../kdefx/libkdefx.la 
$(LDAP_LIBS)
+ libkdecore_la_NMCHECK = $(srcdir)/libkdecore.nmcheck
+ libkdecore_la_NMCHECKWEAK = $(srcdir)/libkdecore_weak.nmcheck 
$(srcdir)/libqt-mt_weak.nmcheck \
+       $(top_srcdir)/dcop/libDCOP_weak.nmcheck 
$(top_srcdir)/kdecore/standard_weak.nmcheck
+diff -u -N -r kdelibs.orig/kdecore/xldaplite.cpp 
kdelibs-3.5.5/kdecore/xldaplite.cpp
+--- kdelibs.orig/kdecore/xldaplite.cpp 1969-12-31 21:00:00.000000000 -0300
++++ kdelibs-3.5.5/kdecore/xldaplite.cpp        2006-11-23 13:55:15.000000000 
-0200
+@@ -0,0 +1,404 @@
++/*
++  This file is part of the KDE libraries
++  Copyright (c) 2005 Willem Verschuur <[EMAIL PROTECTED]>
++  Copyright (c) 2006 Helio Chissini de Castro <[EMAIL PROTECTED]>
++
++  This library is free software; you can redistribute it and/or
++  modify it under the terms of the GNU Library General Public
++  License as published by the Free Software Foundation; either
++  version 2 of the License, or (at your option) any later version.
++
++  This library is distributed in the hope that it will be useful,
++  but WITHOUT ANY WARRANTY; without even the implied warranty of
++  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++  Library General Public License for more details.
++
++  You should have received a copy of the GNU Library General Public License
++  along with this library; see the file COPYING.LIB.  If not, write to
++  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
++  Boston, MA 02110-1301, USA.
++*/
++
++#include <qfile.h>
++#include <qmap.h>
++#include <qregexp.h>
++#include <unistd.h>
++#include <iostream>
++
++#include "xldaplite.h"
++
++#ifndef LDAP_CONF
++#define LDAP_CONF "/etc/ldap.conf"
++#endif
++
++#ifndef LDAP_SECRET
++#define LDAP_SECRET "/etc/ldap.secret"
++#endif
++
++xLDAPconnection::xLDAPconnection()
++{
++    
++    m_Connection = 0;
++    
++}
++
++
++
++xLDAPconnection::~xLDAPconnection()
++{
++    if (m_Connection)
++    {
++        disconnect();
++    }
++}
++
++
++
++bool xLDAPconnection::connect()
++{
++
++    // close existing connection
++    if (m_Connection)
++    {
++        disconnect();
++    }
++
++    QFile conf(LDAP_CONF);
++    QMap<QString,QString> config;
++  
++    if (!conf.open(IO_ReadOnly)) 
++    {
++        std::cerr << "Cannot open " << LDAP_CONF << std::endl;
++        return false;
++    }
++
++    QTextStream confs(&conf);
++    
++    while (!confs.atEnd()) 
++    {
++        QString line = confs.readLine();
++        if (line.contains(QRegExp("^\\s*[a-z]+\\s+.+"))) 
++        {
++            QStringList strs=QStringList::split(QRegExp("\\s+"),line);
++            config[strs[0]] = strs[1];
++        }
++    }
++    
++    if (geteuid()==0) 
++    {
++        
++        QFile secretFile( LDAP_SECRET );
++        
++        if (!secretFile.open(IO_ReadOnly)) 
++        {
++            std::cerr << "Cannot find " << LDAP_SECRET << std::endl; 
++            return false;
++        }
++        
++        QTextStream secretStream(&secretFile);
++        m_RootPassword = secretStream.readLine();
++        
++    }
++
++    // configure parameters 
++    QString host = config["host"];
++    int port = 389;
++    
++    if (config.contains("port")) 
++    {
++        port = config["port"].toInt();
++    }
++    
++    // create ldap connection
++    m_Connection = ldap_init(host.latin1(), port);
++
++    if (!m_Connection) return false;
++
++    int version = LDAP_VERSION3;
++    
++    if (config.contains("ldap_version"))
++        version = config["ldap_version"].toInt();
++   
++    // configure connection
++    int ret;
++    if ((ret = ldap_set_option(m_Connection, LDAP_OPT_PROTOCOL_VERSION, 
&version)) != LDAP_SUCCESS) 
++    {
++        std::cerr << "ldap_set_option" << ldap_err2string(ret) << std::endl;
++        return false;
++    } 
++
++    // root binding
++    if (getuid==0 && config.contains("rootbinddn")) 
++    {
++        if ( LDAP_SUCCESS != ldap_bind_s( m_Connection,
++                                          config["rootbinddn"].latin1(),
++                                          m_RootPassword.latin1(), 
++                                          LDAP_AUTH_SIMPLE ) )
++        {
++            std::cerr << "Root bind failed" << std::endl;
++            return false;
++        }
++        // should be utf8....
++    } 
++    else 
++    {
++        if (LDAP_SUCCESS != (ret = 
ldap_simple_bind_s(m_Connection,NULL,NULL)))
++        {
++            std::cerr << "Anonymous bind failed" << std::endl;
++            return false;
++        }
++        // there are also SASL, and kerberos
++    }
++    
++    // configure scope
++    m_Scope = LDAP_SCOPE_SUBTREE;
++    
++    if (config.contains("scope")) 
++    {
++        if (config["scope"] == "sub");
++        else if (config["scope"] == "one")
++            m_Scope = LDAP_SCOPE_ONELEVEL;
++        else if (config["scope"] == "base")
++            m_Scope = LDAP_SCOPE_BASE;
++        else 
++        {
++            std::cerr << "bad value for scope in ldap.conf: " << 
config["scope"].latin1() << std::endl;
++            return false;
++        }
++    }
++    
++    // configure base
++    if (!config.contains("base")) 
++    {
++        std::cerr << "base is not defined in ldap.conf" << std::endl;
++        return false;
++    }
++    
++    m_Base = config["base"];
++
++    // return successful
++    return true;
++
++}
++
++
++
++void xLDAPconnection::disconnect()
++{
++
++    // the connection doesnt exist
++    if (!m_Connection) return;
++
++    // drop connection
++    ldap_unbind(m_Connection);
++    m_Connection = 0;
++
++    return;
++
++}
++
++
++
++xLDAPquery::xLDAPquery( xLDAPconnection& connection,
++                        const QString& filter,
++                        const QString& pbasedn,
++                        char** attributes )
++{
++
++    // initialize vars
++    QString basedn;
++    
++    if (pbasedn.isNull())
++    {
++        basedn = connection.m_Base;
++    }
++    else
++    {
++        basedn = pbasedn;
++    }
++    
++    m_Connection = &connection;
++
++    // execute search
++    m_Result = ldap_search_s(   m_Connection->m_Connection,
++                                basedn.latin1(),
++                                m_Connection->m_Scope,
++                                filter.latin1(),   
++                                attributes,
++                                0, // return attrs & values
++                                &m_Query   );
++
++    // output an error if query failed
++    //if (m_Result != LDAP_SUCCESS) 
++          //std::cerr << "ldap_search: " << ldap_err2string(m_Result) << 
std::endl;
++
++}
++
++
++
++xLDAPquery::~xLDAPquery()
++{
++    if (m_Query)
++    {
++        ldap_msgfree(m_Query);
++        m_Query = 0;
++    }
++}
++
++
++
++xLDAPiterator::xLDAPiterator(xLDAPquery& query)
++{
++    
++    // initialize vars
++    m_Query = &query;
++    m_Entry = 0;   // used by element iterator (this)
++    m_Element = 0; // used by attribute iterator
++
++    // fix error handling 
++    // if (!m_Connection) return false;
++    // if (!m_Message) return false;
++    
++    // point to first element in query result
++    m_Entry = ldap_first_entry(m_Query->m_Connection->m_Connection, 
m_Query->m_Query);
++    
++}
++
++
++
++xLDAPiterator::~xLDAPiterator()
++{
++
++    clearElement();
++}
++
++
++
++void xLDAPiterator::clearElement()
++{
++
++    if (m_Element)
++    {
++        ber_free(m_Element, 0);
++        m_Element = 0;
++    }
++
++}
++
++
++
++xLDAPiterator::operator bool ()
++{
++    return (m_Entry != 0);
++}
++
++
++
++void xLDAPiterator::operator ++ ()
++{
++    m_Entry = ldap_next_entry(m_Query->m_Connection->m_Connection, m_Entry);
++}
++
++
++
++xLDAPattribute::xLDAPattribute(xLDAPiterator& iter)
++{
++
++    // initialize class vars
++    m_Iterator = &iter;
++    m_Attribute = 0;
++    m_Values = 0;
++    m_CurrentValue = 0;
++
++    // free previous element's attribute data 
++    if (m_Iterator->m_Element)
++    {
++        m_Iterator->clearElement();
++    }
++
++    // get first attribute
++    m_Attribute = ldap_first_attribute( 
m_Iterator->m_Query->m_Connection->m_Connection, 
++                                        m_Iterator->m_Entry, 
++                                        &m_Iterator->m_Element);
++
++}
++
++
++
++xLDAPattribute::~xLDAPattribute()
++{
++    clearAttribute();
++}
++
++
++
++void xLDAPattribute::clearAttribute()
++{
++
++    if (m_Attribute)
++    {
++        ldap_memfree(m_Attribute);
++        m_Attribute = 0;
++    }
++    
++    if (m_Values)
++    {
++        clearValues();
++    }
++
++}
++
++
++
++xLDAPattribute::operator bool ()
++{
++    return (m_Attribute != 0);
++}
++
++
++
++void xLDAPattribute::operator ++ ()
++{
++
++    clearAttribute();
++    m_Attribute = ldap_next_attribute( 
m_Iterator->m_Query->m_Connection->m_Connection, 
++                                       m_Iterator->m_Entry, 
++                                       m_Iterator->m_Element );
++
++}
++
++
++
++const char* xLDAPattribute::firstValue()
++{
++    if (m_Values)
++    {
++        clearValues();
++    }
++
++    m_Values = ldap_get_values (  
m_Iterator->m_Query->m_Connection->m_Connection, 
++                                  m_Iterator->m_Entry, 
++                                  m_Attribute );
++
++    m_CurrentValue = m_Values;
++    return *m_CurrentValue;
++}
++
++
++const char* xLDAPattribute::nextValue()
++{
++    m_CurrentValue++;
++    return *m_CurrentValue;
++}
++
++
++
++void xLDAPattribute::clearValues()
++{
++    if (m_Values)
++    {
++        ldap_value_free(m_Values);
++        m_Values = 0;
++    }
++}
++
+diff -u -N -r kdelibs.orig/kdecore/xldaplite.h 
kdelibs-3.5.5/kdecore/xldaplite.h
+--- kdelibs.orig/kdecore/xldaplite.h   1969-12-31 21:00:00.000000000 -0300
++++ kdelibs-3.5.5/kdecore/xldaplite.h  2006-11-23 13:55:31.000000000 -0200
+@@ -0,0 +1,217 @@
++/*
++  This file is part of the KDE libraries
++  Copyright (c) 2005 Willem Verschuur <[EMAIL PROTECTED]>
++  Copyright (c) 2006 Helio Chissini de Castro <[EMAIL PROTECTED]>
++
++  This library is free software; you can redistribute it and/or
++  modify it under the terms of the GNU Library General Public
++  License as published by the Free Software Foundation; either
++  version 2 of the License, or (at your option) any later version.
++
++  This library is distributed in the hope that it will be useful,
++  but WITHOUT ANY WARRANTY; without even the implied warranty of
++  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++  Library General Public License for more details.
++
++  You should have received a copy of the GNU Library General Public License
++  along with this library; see the file COPYING.LIB.  If not, write to
++  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
++  Boston, MA 02110-1301, USA.
++*/
++
++/*
++ * Lightweight openldap api wrappers, just makes the
++ * whole memory management schlep so much easier
++ *
++ * test: exception handling.. try to break it
++ *
++ * note: dont pass these classes as results for functions..
++ * for that you need to pull the variables into a counter
++ * referenced core structure.
++ *
++ * todo: ldapnode class for a truer in-memory representation
++ * of LDAP tree.. and easier query coding
++ */
++
++#ifndef _XLDAPLITE_H
++#define _XLDAPLITE_H
++
++
++
++#include <ldap.h>
++#include <qstring.h>
++#include <qstringlist.h>
++#include <qptrlist.h>
++
++
++
++class xLDAPquery;
++class xLDAPiterator;
++class xLDAPattribute;
++
++
++
++class xLDAPconnection
++{
++
++    
++    friend class xLDAPquery;
++    friend class xLDAPiterator;
++    friend class xLDAPattribute;
++
++    
++    public:
++
++
++        // read /etc/ldap.conf 
++        xLDAPconnection();
++
++
++        // free resources on object destruction
++        ~xLDAPconnection();
++
++
++        // connect to ldap server
++        bool connect();
++
++
++        // free resources
++        void disconnect();
++
++
++        // accessor
++        const LDAP* connection()  { return m_Connection; }
++        const QString& base() { return m_Base; }
++        const QString& password() { return m_RootPassword; }
++
++
++    protected:
++
++
++        LDAP*           m_Connection;
++        QString         m_RootPassword;
++        ber_int_t       m_Scope;
++        QString         m_Base;
++       
++
++};
++
++
++
++class xLDAPquery
++{
++
++
++    // iterator should have access to members
++    friend class xLDAPiterator;
++    friend class xLDAPattribute;
++
++    
++    public:
++
++
++        // execute a query
++        xLDAPquery( xLDAPconnection&, 
++                    const QString& filter, 
++                    const QString& base = 0, 
++                    char** attrs = 0 );
++
++
++        // free resources on object destruction
++        ~xLDAPquery();
++
++        
++    protected:
++
++
++        xLDAPconnection*    m_Connection;
++        LDAPMessage*        m_Query;
++        int                 m_Result;
++
++        
++};
++
++
++
++class xLDAPiterator
++{
++
++
++    friend class xLDAPattribute;
++
++    
++    public:
++
++
++        xLDAPiterator(xLDAPquery&);
++
++
++        ~xLDAPiterator();
++
++
++        operator bool(void);
++
++
++        void operator ++ (void);
++
++
++    protected:
++
++
++        void clearElement();
++
++        
++        xLDAPquery*     m_Query;
++        LDAPMessage*    m_Entry;
++        BerElement*     m_Element; // used by attribute functions
++
++
++};
++
++
++
++class xLDAPattribute
++{
++
++    
++    public:
++
++
++        xLDAPattribute(xLDAPiterator&);
++
++
++        ~xLDAPattribute();
++
++
++        operator bool(void);
++
++
++        void operator ++ (void);
++
++
++        const char* attribute() { return m_Attribute; }
++
++
++        const char* firstValue();
++        const char* nextValue();
++
++        
++    protected:
++
++
++        void clearAttribute();
++        void clearValues();
++
++
++        xLDAPiterator*          m_Iterator;
++        char*                   m_Attribute;    // attribute
++        char**                  m_Values;
++        char**                  m_CurrentValue;
++
++       
++};
++
++
++
++#endif
++

Added: packages/cooker/kdelibs/current/SOURCES/kdelibs-3.5.5.20061120.tar.bz2
==============================================================================
Binary file. No diff available.

Modified: packages/cooker/kdelibs/current/SPECS/kdelibs.spec
==============================================================================
--- packages/cooker/kdelibs/current/SPECS/kdelibs.spec  (original)
+++ packages/cooker/kdelibs/current/SPECS/kdelibs.spec  Thu Nov 23 17:10:35 2006
@@ -1,6 +1,6 @@
 %define _requires_exceptions 
perl\(.*\)\\|devel\(linux-gate\)\\|devel\(libdns_sd\(.*\)\\|devel\(libdns_sd\)
 
-%define branch_date 20061011
+%define branch_date 20061120
 %define __libtoolize    /bin/true
 
 %define use_hspell_plugins 1
@@ -8,13 +8,16 @@
 %define use_enable_final 1
 %{?_no_enable_final: %{expand: %%global use_enable_final 0}}
 
+%define with_ldap 1
+%{?_without_ldap: %{expand: %%global with_ldap 0}}
+
 %define compile_apidox 1
 %{?_no_apidox: %{expand: %%global compile_apidox 0}}
 
 %define unstable 0
 %{?_unstable: %{expand: %%global unstable 1}}
 
-%define branch 0
+%define branch 1
 %{?_branch: %{expand: %%global branch 1}}
 
 %if %unstable
@@ -44,7 +47,7 @@
 Name: kdelibs
 Summary: K Desktop Environment - Libraries
 Version: 3.5.5
-Release: %mkrel 2
+Release: %mkrel 3
 Epoch: %epoch_kdelibs
 Group: Graphical desktop/KDE
 License: ARTISTIC BSD GPL_V2 LGPL_V2 QPL_V1.0
@@ -103,6 +106,7 @@
 Patch60:       kdelibs-3.4.2-add-default-startup-sound.patch
 Patch61:       kdelibs-3.5.4-fix-translate-desktopfile.patch
 Patch62: kdelibs-3.5.4-dcop_wrong_reply.patch
+Patch63: kdelibs-3.5.5-ldap-kconfig.patch
 
 # to remove
 Obsoletes: kdelibs-static-devel
@@ -175,6 +179,9 @@
 BuildRequires:  graphviz
 BuildRequires: qt3-doc
 %endif
+%if %with_ldap
+BuildRequires: openldap-devel >= 2.3
+%endif
 
 %description 
 Libraries for the K Desktop Environment.
@@ -683,6 +690,9 @@
 %patch60 -p1 -b .default_startup_sound
 %patch61 -p1 -b .fix_translate_desktopfile
 %patch62 -p1 -b .dcop_wrong_reply
+%if %with_ldap
+%patch63 -p1 -b .ldap
+%endif
 
 %build
 # This step is needed mostly because avahi patch
@@ -722,6 +732,9 @@
        --with-xinerama \
        --with-alsa \
        --with-ipv6-lookup=auto \
+%if ! %with_ldap
+   --without-ldap \
+%endif
 %if "%{_lib}" != "lib"
        --enable-libsuffix="%(A=%{_lib}; echo ${A/lib/})" \
 %endif

Reply via email to