By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release. View | Details | Raw Unified | Return to bug 1499
Collapse All | Expand All

(-)kdelibs-orig/kdecore/configure.in.in (+113 lines)
Lines 231-233 Link Here
231
      ],
231
      ],
232
      AC_MSG_RESULT(no)
232
      AC_MSG_RESULT(no)
233
)
233
)
234
235
AC_MSG_CHECKING(for LDAP support)
236
AC_ARG_WITH(ldap,
237
AC_HELP_STRING([--with-ldap=PATH],[Set path for LDAP files [default=check]]),
238
[ case "$withval" in
239
  yes)
240
    with_ldap=CHECK
241
    ;;
242
  esac ],
243
[ with_ldap=CHECK ]
244
)dnl
245
246
if test "x$with_ldap" = "xCHECK" ; then
247
  with_ldap=NOTFOUND
248
  search_incs="$kde_includes /usr/include /usr/local/include"
249
  AC_FIND_FILE(ldap.h, $search_incs, ldap_incdir)
250
  if test -r $ldap_incdir/ldap.h ; then
251
    test "x$ldap_incdir" != "x/usr/include" && LDAP_INCS="-I$ldap_incdir"
252
    with_ldap=FOUND
253
  fi
254
  if test $with_ldap = FOUND ; then
255
    with_ldap=NOTFOUND
256
    for ext in la so sl a dylib ; do
257
      AC_FIND_FILE(libldap.$ext, $kde_libraries /usr/lib /usr/local/lib /usr/lib64,
258
        ldap_libdir)
259
      if test -r $ldap_libdir/libldap.$ext ; then
260
        if test "x$ldap_libdir" != "x/usr/lib" ; then
261
          LDAP_LIBS="-L$ldap_libdir "
262
          test "$USE_RPATH" = yes && LDAP_RPATH="-R $ldap_libdir"
263
        fi
264
        LDAP_LIBS="${LDAP_LIBS}-lldap"
265
        with_ldap=FOUND
266
        break
267
      fi
268
    done
269
  fi
270
fi
271
272
case "$with_ldap" in
273
no) AC_MSG_RESULT(no) ;;
274
framework)
275
  LDAP_LIBS="-Xlinker -framework -Xlinker LDAP"
276
  AC_DEFINE_UNQUOTED(HAVE_LIBLDAP, 1, [Define if you have LDAP libraries])
277
  LDAP_SUBDIR="ldap"
278
  AC_MSG_RESULT(Apple framework)
279
  ;;
280
FOUND)
281
  AC_MSG_RESULT(incs=$ldap_incdir libs=$ldap_libdir)
282
  ;;
283
NOTFOUND) AC_MSG_RESULT(searched but not found) ;;
284
*)
285
  AC_MSG_RESULT($with_ldap)
286
  ;;
287
esac
288
289
AC_MSG_CHECKING(whether LDAP support can be compiled)
290
291
  if test "x$with_ldap" != "xFOUND" ; then
292
    LDAP_ROOT="$with_ldap"
293
    if test "x$LDAP_ROOT" != "x/usr" ; then
294
      LDAP_INCS="-I${LDAP_ROOT}/include"
295
      LDAP_LIBS="-L${LDAP_ROOT}/lib "
296
      if test "$USE_RPATH" = "yes" ; then
297
        LDAP_RPATH="-R ${LDAP_ROOT}/lib"
298
      fi
299
    fi
300
    LDAP_LIBS="${LDAP_LIBS}-lldap"
301
  fi
302
  LDAP_LIBS="${LDAP_LIBS} ${LIB_LBER} ${LIBRESOLV}"
303
304
  kde_safe_LIBS="$LIBS"
305
  kde_safe_CFLAGS="$CFLAGS"
306
  kde_safe_CXXFLAGS="$CXXFLAGS"
307
  LIBS="$LIBS $all_libraries $LDAP_LIBS $KRB4_LIBS $X_EXTRA_LIBS"
308
  CFLAGS="$CFLAGS $all_includes $LDAP_INCS -DLDAP_DEPRECATED"
309
  CXXFLAGS="$CXXFLAGS $all_includes $LDAP_INCS -DLDAP_DEPRECATED"
310
311
  AC_LANG_SAVE
312
  AC_LANG_C
313
  AC_TRY_LINK(dnl
314
  [
315
  #include <ldap.h>
316
  #if LDAP_API_VERSION < 2004
317
  #error LDAP version too old, please upgrade to a library supporting API 2004 or higher
318
  #endif
319
  ],
320
  [
321
  LDAP *ldap;
322
  ],
323
  , with_ldap=no
324
  )
325
  AC_LANG_RESTORE
326
  if test "$with_ldap" = "no" ; then
327
    LDAP_INCS=
328
    LDAP_LIBS=
329
    LDAP_RPATH=
330
    LDAP_SUBDIR=
331
    CFLAGS=$kde_safe_CFLAGS
332
    CXXFLAGS=$kde_safe_CXXFLAGS
333
    LIBS=$kde_safe_LIBS
334
    AC_MSG_RESULT(no (but first try gave $msg))
335
  else
336
    AC_DEFINE_UNQUOTED(HAVE_LIBLDAP, 1, [Define if you have LDAP libraries])
337
    LDAP_SUBDIR="ldap"
338
    AC_MSG_RESULT(yes)
339
  fi
340
341
AC_SUBST(LDAP_INCS)
342
AC_SUBST(LDAP_LIBS)
343
AC_SUBST(LDAP_RPATH)
344
345
346
(-)kdelibs-orig/kdecore/kconfigbackend.cpp (-2 / +4 lines)
Lines 579-585 Link Here
579
         KEntry entry = pConfig->lookupData(groupKey);
579
         KEntry entry = pConfig->lookupData(groupKey);
580
         groupSkip = entry.bImmutable;
580
         groupSkip = entry.bImmutable;
581
581
582
         if (groupSkip && !bDefault)
582
         //if (groupSkip && !bDefault)
583
         if (groupSkip)
583
            continue;
584
            continue;
584
585
585
         entry.bImmutable |= groupOptionImmutable;
586
         entry.bImmutable |= groupOptionImmutable;
Lines 593-599 Link Here
593
594
594
         continue;
595
         continue;
595
      }
596
      }
596
      if (groupSkip && !bDefault)
597
      //if (groupSkip && !bDefault)
598
      if (groupSkip)
597
        goto sktoeol; // Skip entry
599
        goto sktoeol; // Skip entry
598
600
599
      bool optionImmutable = groupOptionImmutable;
601
      bool optionImmutable = groupOptionImmutable;
(-)kdelibs-3.5.6/kdecore/kconfigbase.cpp.ldap (-25 / +269 lines)
Lines 20-31 Link Here
20
   Boston, MA 02110-1301, USA.
20
   Boston, MA 02110-1301, USA.
21
*/
21
*/
22
22
23
#include <stdlib.h>
23
#include <cstdio>
24
#include <string.h>
24
#include <cstdlib>
25
25
26
#include <qfile.h>
26
#include <qfile.h>
27
#include <qdir.h>
27
#include <qdir.h>
28
#include <qtextstream.h>
28
#include <qtextstream.h>
29
#include <qtextcodec.h>
30
#include <qdom.h>
29
31
30
#include <kapplication.h>
32
#include <kapplication.h>
31
#include <kglobal.h>
33
#include <kglobal.h>
Lines 38-62 Link Here
38
#include "kstandarddirs.h"
40
#include "kstandarddirs.h"
39
#include "kstringhandler.h"
41
#include "kstringhandler.h"
40
42
41
class KConfigBase::KConfigBasePrivate
43
void KConfigBase::dumpConfig( const QString& ent, const QString& val, const QString& type ) const 
42
{
44
{
43
public:
45
   bool dumpEnabled = getenv( "DUMPCONFIG" ) ? true : false;
44
     KConfigBasePrivate() : readDefaults(false) { };
45
46
46
public:
47
   if( backEnd == 0 )
47
     bool readDefaults;
48
   {
48
};
49
      dumpEnabled = false;
50
      return;
51
   }
52
   else if( !dumpEnabled )
53
      return;
54
55
   QString filename;
56
   filename = backEnd->fileName();
57
58
   // blacklists some entries to avoid uselless queries
59
   if (  filename == "kdebugrc"
60
         || filename == "kconf_updaterc"
61
         || filename == "kdedrc"
62
         || filename == "klauncherrc"
63
         || filename == "kdeinitrc"
64
         || filename == "kbuildsycocarc"
65
         || filename == "drkonqirc"
66
         || filename.startsWith( "/" )
67
         || filename.endsWith( ".desktop" )
68
         )
69
      return;
70
   
71
   QDomDocument *xmldoc;
72
   QDomDocument *globalxmldoc;
73
  
74
   bool globalgroup = false;
75
   
76
   if ( mGroup == "KDE" || mGroup == "General" )
77
      globalgroup = true;
78
79
   QDomElement root;
80
   QDir bd( getenv( "KCONFIGXMLDIR" ) );
81
   
82
   QString data = bd.exists() ? bd.absPath() : "/tmp";
83
   QString localfile = data + '/' + filename + ".xml"; 
84
   QFile file( localfile );
85
   if ( !file.open( IO_ReadOnly ) )
86
   {
87
      xmldoc = new QDomDocument( filename );
88
      root = xmldoc->createElement( filename );
89
      xmldoc->appendChild( root );
90
   }
91
   else
92
   {
93
      xmldoc = new QDomDocument();
94
      if ( !xmldoc->setContent( &file ) ) 
95
      {
96
         file.close();
97
         return;
98
      }
99
      root = xmldoc->documentElement();
100
   }
101
   file.close();
102
   
103
   QDomElement globalroot;
104
   localfile = data + "/kdeglobals.xml"; 
105
   file.setName( localfile );
106
   if ( !file.open( IO_ReadOnly ) )
107
   {
108
      globalxmldoc = new QDomDocument( "kdeglobals" );
109
      globalroot = globalxmldoc->createElement( "kdeglobals" );
110
      globalxmldoc->appendChild( globalroot );
111
   }
112
   else
113
   {
114
      globalxmldoc = new QDomDocument();
115
      if ( !globalxmldoc->setContent( &file ) ) 
116
      {
117
         file.close();
118
         return;
119
      }
120
      globalroot = globalxmldoc->documentElement(); 
121
   }
122
   file.close();
123
   
124
125
   bool exists = false;
126
127
   QDomNode node;
128
   QDomElement grp;
129
130
   if( ! globalgroup )
131
   {
132
      node = xmldoc->documentElement().namedItem( "group" );
133
      while ( !node.isNull() )
134
      {
135
         QString current = node.attributes().item( 0 ).nodeValue();
136
         if ( node.attributes().item( 0 ).nodeValue() == QString( mGroup ) )
137
         {
138
            grp = node.toElement();
139
            exists = true;
140
            break;
141
         }
142
         node = node.nextSibling();
143
      }
144
      
145
      if ( ! exists )
146
      {
147
         grp = xmldoc->createElement( "group" );
148
         grp.setAttribute( "name", mGroup ); 
149
         root.appendChild( grp );
150
      }
151
   }
152
   else
153
   {
154
       node = globalxmldoc->documentElement().namedItem( "group" );
155
      while ( !node.isNull() )
156
      {
157
         QString current = node.attributes().item( 0 ).nodeValue();
158
         if ( node.attributes().item( 0 ).nodeValue() == QString( mGroup ) )
159
         {
160
            grp = node.toElement();
161
            exists = true;
162
            break;
163
         }
164
         node = node.nextSibling();
165
      }
166
      
167
      if ( ! exists )
168
      {
169
         grp = globalxmldoc->createElement( "group" );
170
         grp.setAttribute( "name", mGroup ); 
171
         globalroot.appendChild( grp );
172
      }
173
   }
174
175
     
176
   exists = false;
177
   QDomElement entry;
178
   QDomText t;
179
   if ( ! globalgroup )
180
      t = xmldoc->createTextNode( val );
181
   else
182
      t = globalxmldoc->createTextNode( val );
183
   node = grp.namedItem( "property" );
184
185
   while ( !node.isNull() )
186
   {
187
      QString current = node.attributes().item( 0 ).nodeValue();
188
      if ( node.attributes().namedItem( "name" ).nodeValue() == ent )
189
      {
190
         entry = node.toElement();
191
         exists = true;
192
         break;
193
      }
194
      node = node.nextSibling();
195
   }
196
   
197
   if ( ! exists )
198
   {
199
200
      if ( ! globalgroup )
201
         entry = xmldoc->createElement( "property" );
202
      else
203
         entry = globalxmldoc->createElement( "property" );
204
      entry.setAttribute( "name", ent );
205
      entry.setAttribute( "type", type );
206
      grp.appendChild( entry );
207
      entry.appendChild( t );
208
   }
209
210
   // Save every time to avoid duplicated root elements
211
   filename = data + '/' + backEnd->fileName() + ".xml"; 
212
   file.setName( filename );
213
   if ( file.open( IO_WriteOnly ) ) 
214
   {
215
      QTextStream qualquer( &file );
216
      qualquer <<  xmldoc->toString() << endl;
217
      file.close();
218
   }
219
   
220
   filename = data + "/kdeglobals.xml"; 
221
   file.setName( filename );
222
   if ( file.open( IO_WriteOnly ) ) 
223
   {
224
      QTextStream qualquer( &file );
225
      qualquer <<  globalxmldoc->toString() << endl;
226
      file.close();
227
   }
228
229
}
49
230
50
KConfigBase::KConfigBase()
231
KConfigBase::KConfigBase()
51
  : backEnd(0L), bDirty(false), bLocaleInitialized(false),
232
  : backEnd(0L), bDirty(false), bLocaleInitialized(false),
52
    bReadOnly(false), bExpand(false), d(0)
233
    bReadOnly(false), bExpand(false), m_Private(0)
53
{
234
{
235
    m_Private = m_Private = new KConfigBasePrivate();
236
    m_Private->backEnds.setAutoDelete(true);
54
    setGroup(QString::null);
237
    setGroup(QString::null);
55
}
238
}
56
239
57
KConfigBase::~KConfigBase()
240
KConfigBase::~KConfigBase()
58
{
241
{
59
    delete d;
242
243
   delete m_Private;
60
}
244
}
61
245
62
void KConfigBase::setLocale()
246
void KConfigBase::setLocale()
Lines 203-209 Link Here
203
QString KConfigBase::readEntry( const QString& pKey,
387
QString KConfigBase::readEntry( const QString& pKey,
204
                                const QString& aDefault ) const
388
                                const QString& aDefault ) const
205
{
389
{
206
   return KConfigBase::readEntry(pKey.utf8().data(), aDefault);
390
   QString aValue = KConfigBase::readEntry(pKey.utf8().data(), aDefault);
391
   if ( ! aValue.isNull() )
392
      dumpConfig( pKey, aValue, "String" );
393
   return aValue;
207
}
394
}
208
395
209
QString KConfigBase::readEntry( const char *pKey,
396
QString KConfigBase::readEntry( const char *pKey,
Lines 313-319 Link Here
313
        nDollarPos = aValue.find( '$', nDollarPos );
500
        nDollarPos = aValue.find( '$', nDollarPos );
314
      }
501
      }
315
    }
502
    }
316
503
 
317
  return aValue;
504
  return aValue;
318
}
505
}
319
506
Lines 442-448 Link Here
442
                                QStrList &list, char sep ) const
629
                                QStrList &list, char sep ) const
443
{
630
{
444
  if( !hasKey( pKey ) )
631
  if( !hasKey( pKey ) )
632
  {
445
    return 0;
633
    return 0;
634
  }
446
635
447
  QCString str_list = readEntryUtf8( pKey );
636
  QCString str_list = readEntryUtf8( pKey );
448
  if (str_list.isEmpty())
637
  if (str_list.isEmpty())
Lines 488-494 Link Here
488
677
489
  QStringList list;
678
  QStringList list;
490
  if( !hasKey( pKey ) )
679
  if( !hasKey( pKey ) )
680
  {
491
    return list;
681
    return list;
682
  }
492
  QString str_list = readEntry( pKey );
683
  QString str_list = readEntry( pKey );
493
  if( str_list.isEmpty() )
684
  if( str_list.isEmpty() )
494
    return list;
685
    return list;
Lines 520-525 Link Here
520
    value.squeeze();
711
    value.squeeze();
521
    list.append( value );
712
    list.append( value );
522
  }
713
  }
714
  dumpConfig( pKey, list.join( "," ), "List" );
523
  return list;
715
  return list;
524
}
716
}
525
717
Lines 527-533 Link Here
527
		char sep ) const
719
		char sep ) const
528
{
720
{
529
	if ( !hasKey( pKey ) )
721
	if ( !hasKey( pKey ) )
722
   {
530
		return aDefault;
723
		return aDefault;
724
   }
531
	else
725
	else
532
		return readListEntry( pKey, sep );
726
		return readListEntry( pKey, sep );
533
}
727
}
Lines 540-545 Link Here
540
QValueList<int> KConfigBase::readIntListEntry( const char *pKey ) const
734
QValueList<int> KConfigBase::readIntListEntry( const char *pKey ) const
541
{
735
{
542
  QStringList strlist = readListEntry(pKey);
736
  QStringList strlist = readListEntry(pKey);
737
  dumpConfig( pKey, strlist.join( "," ), "IntList" );
738
543
  QValueList<int> list;
739
  QValueList<int> list;
544
  QStringList::ConstIterator end(strlist.end());
740
  QStringList::ConstIterator end(strlist.end());
545
  for (QStringList::ConstIterator it = strlist.begin(); it != end; ++it)
741
  for (QStringList::ConstIterator it = strlist.begin(); it != end; ++it)
Lines 560-565 Link Here
560
  const bool bExpandSave = bExpand;
756
  const bool bExpandSave = bExpand;
561
  bExpand = true;
757
  bExpand = true;
562
  QString aValue = readEntry( pKey, pDefault );
758
  QString aValue = readEntry( pKey, pDefault );
759
  dumpConfig( pKey, aValue, "Path" );
563
  bExpand = bExpandSave;
760
  bExpand = bExpandSave;
564
  return aValue;
761
  return aValue;
565
}
762
}
Lines 574-579 Link Here
574
  const bool bExpandSave = bExpand;
771
  const bool bExpandSave = bExpand;
575
  bExpand = true;
772
  bExpand = true;
576
  QStringList aValue = readListEntry( pKey, sep );
773
  QStringList aValue = readListEntry( pKey, sep );
774
775
  dumpConfig( pKey, aValue.join( "," ), "PathList" );
577
  bExpand = bExpandSave;
776
  bExpand = bExpandSave;
578
  return aValue;
777
  return aValue;
579
}
778
}
Lines 585-590 Link Here
585
784
586
int KConfigBase::readNumEntry( const char *pKey, int nDefault) const
785
int KConfigBase::readNumEntry( const char *pKey, int nDefault) const
587
{
786
{
787
  dumpConfig( pKey, QString::number( nDefault ), "Num" );
588
  QCString aValue = readEntryUtf8( pKey );
788
  QCString aValue = readEntryUtf8( pKey );
589
  if( aValue.isNull() )
789
  if( aValue.isNull() )
590
    return nDefault;
790
    return nDefault;
Lines 606-611 Link Here
606
806
607
unsigned int KConfigBase::readUnsignedNumEntry( const char *pKey, unsigned int nDefault) const
807
unsigned int KConfigBase::readUnsignedNumEntry( const char *pKey, unsigned int nDefault) const
608
{
808
{
809
  dumpConfig( pKey, QString::number( nDefault ), "UnsignedNum" );
609
  QCString aValue = readEntryUtf8( pKey );
810
  QCString aValue = readEntryUtf8( pKey );
610
  if( aValue.isNull() )
811
  if( aValue.isNull() )
611
    return nDefault;
812
    return nDefault;
Lines 625-630 Link Here
625
826
626
long KConfigBase::readLongNumEntry( const char *pKey, long nDefault) const
827
long KConfigBase::readLongNumEntry( const char *pKey, long nDefault) const
627
{
828
{
829
  dumpConfig( pKey, QString::number( nDefault ), "LongNum" );
628
  QCString aValue = readEntryUtf8( pKey );
830
  QCString aValue = readEntryUtf8( pKey );
629
  if( aValue.isNull() )
831
  if( aValue.isNull() )
630
    return nDefault;
832
    return nDefault;
Lines 644-649 Link Here
644
846
645
unsigned long KConfigBase::readUnsignedLongNumEntry( const char *pKey, unsigned long nDefault) const
847
unsigned long KConfigBase::readUnsignedLongNumEntry( const char *pKey, unsigned long nDefault) const
646
{
848
{
849
  dumpConfig( pKey, QString::number( nDefault ), "UnsignedLongNum" );
647
  QCString aValue = readEntryUtf8( pKey );
850
  QCString aValue = readEntryUtf8( pKey );
648
  if( aValue.isNull() )
851
  if( aValue.isNull() )
649
    return nDefault;
852
    return nDefault;
Lines 662-667 Link Here
662
865
663
Q_INT64 KConfigBase::readNum64Entry( const char *pKey, Q_INT64 nDefault) const
866
Q_INT64 KConfigBase::readNum64Entry( const char *pKey, Q_INT64 nDefault) const
664
{
867
{
868
  dumpConfig( pKey, QString::number( nDefault ), "Num64" );
665
  // Note that QCString::toLongLong() is missing, we muse use a QString instead.
869
  // Note that QCString::toLongLong() is missing, we muse use a QString instead.
666
  QString aValue = readEntry( pKey );
870
  QString aValue = readEntry( pKey );
667
  if( aValue.isNull() )
871
  if( aValue.isNull() )
Lines 682-687 Link Here
682
886
683
Q_UINT64 KConfigBase::readUnsignedNum64Entry( const char *pKey, Q_UINT64 nDefault) const
887
Q_UINT64 KConfigBase::readUnsignedNum64Entry( const char *pKey, Q_UINT64 nDefault) const
684
{
888
{
889
  dumpConfig( pKey, QString::number( nDefault ), "UnsignedNum64" );
685
  // Note that QCString::toULongLong() is missing, we muse use a QString instead.
890
  // Note that QCString::toULongLong() is missing, we muse use a QString instead.
686
  QString aValue = readEntry( pKey );
891
  QString aValue = readEntry( pKey );
687
  if( aValue.isNull() )
892
  if( aValue.isNull() )
Lines 701-706 Link Here
701
906
702
double KConfigBase::readDoubleNumEntry( const char *pKey, double nDefault) const
907
double KConfigBase::readDoubleNumEntry( const char *pKey, double nDefault) const
703
{
908
{
909
  dumpConfig( pKey, QString::number( nDefault ), "Double" );
910
  
704
  QCString aValue = readEntryUtf8( pKey );
911
  QCString aValue = readEntryUtf8( pKey );
705
  if( aValue.isNull() )
912
  if( aValue.isNull() )
706
    return nDefault;
913
    return nDefault;
Lines 720-725 Link Here
720
927
721
bool KConfigBase::readBoolEntry( const char *pKey, bool bDefault ) const
928
bool KConfigBase::readBoolEntry( const char *pKey, bool bDefault ) const
722
{
929
{
930
  dumpConfig( pKey, QString::number( bDefault ), "Bool" );
931
723
  QCString aValue = readEntryUtf8( pKey );
932
  QCString aValue = readEntryUtf8( pKey );
724
933
725
  if( aValue.isNull() )
934
  if( aValue.isNull() )
Lines 747-752 Link Here
747
956
748
QFont KConfigBase::readFontEntry( const char *pKey, const QFont* pDefault ) const
957
QFont KConfigBase::readFontEntry( const char *pKey, const QFont* pDefault ) const
749
{
958
{
959
   if ( pDefault )
960
      dumpConfig( pKey, pDefault->toString(), "Font" );
961
   else
962
      dumpConfig( pKey, "", "Font" );
963
750
  QFont aRetFont;
964
  QFont aRetFont;
751
965
752
  QString aValue = readEntry( pKey );
966
  QString aValue = readEntry( pKey );
Lines 844-850 Link Here
844
1058
845
QRect KConfigBase::readRectEntry( const char *pKey, const QRect* pDefault ) const
1059
QRect KConfigBase::readRectEntry( const char *pKey, const QRect* pDefault ) const
846
{
1060
{
847
  QCString aValue = readEntryUtf8(pKey);
1061
   if ( pDefault )
1062
      dumpConfig( pKey, QString::number( pDefault->left() ) + "," + 
1063
            QString::number( pDefault->top() ) + "," + 
1064
            QString::number( pDefault->right() ) + "," +
1065
            QString::number( pDefault->bottom() ), 
1066
            "Rect" );
1067
   else
1068
      dumpConfig( pKey, "", "Rect" );
1069
1070
   QCString aValue = readEntryUtf8(pKey);
848
1071
849
  if (!aValue.isEmpty())
1072
  if (!aValue.isEmpty())
850
  {
1073
  {
Lines 870-875 Link Here
870
QPoint KConfigBase::readPointEntry( const char *pKey,
1093
QPoint KConfigBase::readPointEntry( const char *pKey,
871
                                    const QPoint* pDefault ) const
1094
                                    const QPoint* pDefault ) const
872
{
1095
{
1096
   if ( pDefault )
1097
      dumpConfig( pKey, QString::number( pDefault->x() ) + "," + QString::number( pDefault->y() ), "Point" );
1098
   else
1099
      dumpConfig( pKey, "", "Point" );
1100
  
873
  QCString aValue = readEntryUtf8(pKey);
1101
  QCString aValue = readEntryUtf8(pKey);
874
1102
875
  if (!aValue.isEmpty())
1103
  if (!aValue.isEmpty())
Lines 895-900 Link Here
895
QSize KConfigBase::readSizeEntry( const char *pKey,
1123
QSize KConfigBase::readSizeEntry( const char *pKey,
896
                                  const QSize* pDefault ) const
1124
                                  const QSize* pDefault ) const
897
{
1125
{
1126
   if ( pDefault )
1127
      dumpConfig( pKey, QString::number( pDefault->width() ) + "x" + QString::number( pDefault->height() ), "Size" );
1128
   else
1129
      dumpConfig( pKey, "", "Size" );
898
  QCString aValue = readEntryUtf8(pKey);
1130
  QCString aValue = readEntryUtf8(pKey);
899
1131
900
  if (!aValue.isEmpty())
1132
  if (!aValue.isEmpty())
Lines 914-926 Link Here
914
1146
915
QColor KConfigBase::readColorEntry( const QString& pKey,
1147
QColor KConfigBase::readColorEntry( const QString& pKey,
916
                                    const QColor* pDefault ) const
1148
                                    const QColor* pDefault ) const
917
{
1149
{ 
918
  return readColorEntry(pKey.utf8().data(), pDefault);
1150
   return readColorEntry(pKey.utf8().data(), pDefault);
919
}
1151
}
920
1152
921
QColor KConfigBase::readColorEntry( const char *pKey,
1153
QColor KConfigBase::readColorEntry( const char *pKey,
922
                                    const QColor* pDefault ) const
1154
                                    const QColor* pDefault ) const
923
{
1155
{
1156
   if ( pDefault )
1157
      dumpConfig( pKey, pDefault->name(), "Color" );
1158
   else
1159
      dumpConfig( pKey, "", "Color" );
924
  QColor aRetColor;
1160
  QColor aRetColor;
925
  int nRed = 0, nGreen = 0, nBlue = 0;
1161
  int nRed = 0, nGreen = 0, nBlue = 0;
926
1162
Lines 987-992 Link Here
987
QDateTime KConfigBase::readDateTimeEntry( const char *pKey,
1223
QDateTime KConfigBase::readDateTimeEntry( const char *pKey,
988
                                          const QDateTime* pDefault ) const
1224
                                          const QDateTime* pDefault ) const
989
{
1225
{
1226
   if ( pDefault )
1227
      dumpConfig( pKey, pDefault->toString(), "DateTime" );
1228
   else
1229
      dumpConfig( pKey, "", "DateTime" );
1230
990
  if( !hasKey( pKey ) )
1231
  if( !hasKey( pKey ) )
991
    {
1232
    {
992
      if( pDefault )
1233
      if( pDefault )
Lines 1665-1678 Link Here
1665
1906
1666
void KConfigBase::parseConfigFiles()
1907
void KConfigBase::parseConfigFiles()
1667
{
1908
{
1909
1668
  if (!bLocaleInitialized && KGlobal::_locale) {
1910
  if (!bLocaleInitialized && KGlobal::_locale) {
1669
    setLocale();
1911
    setLocale();
1670
  }
1912
  }
1913
1914
  for ( KConfigBackEnd* backend = m_Private->backEnds.first();
1915
        backend;
1916
        backend = m_Private->backEnds.next() )
1917
  {
1918
      backend->parseConfigFiles();
1919
  }
1920
1671
  if (backEnd)
1921
  if (backEnd)
1672
  {
1922
  {
1673
     backEnd->parseConfigFiles();
1923
      bReadOnly = (backEnd->getConfigState() == ReadOnly);
1674
     bReadOnly = (backEnd->getConfigState() == ReadOnly);
1675
  }
1924
  }
1925
1676
}
1926
}
1677
1927
1678
void KConfigBase::sync()
1928
void KConfigBase::sync()
Lines 1700-1717 Link Here
1700
1950
1701
void KConfigBase::setReadDefaults(bool b)
1951
void KConfigBase::setReadDefaults(bool b)
1702
{
1952
{
1703
  if (!d)
1953
  m_Private->readDefaults = b;
1704
  {
1705
     if (!b) return;
1706
     d = new KConfigBasePrivate();
1707
  }
1708
1709
  d->readDefaults = b;
1710
}
1954
}
1711
1955
1712
bool KConfigBase::readDefaults() const
1956
bool KConfigBase::readDefaults() const
1713
{
1957
{
1714
  return (d && d->readDefaults);
1958
  return (m_Private && m_Private->readDefaults);
1715
}
1959
}
1716
1960
1717
void KConfigBase::revertToDefault(const QString &key)
1961
void KConfigBase::revertToDefault(const QString &key)
(-)kdelibs-orig/kdecore/kconfigldapbackend.cpp (+196 lines)
Line 0 Link Here
1
/*
2
  This file is part of the KDE libraries
3
  Copyright (c) 2005 Willem Verschuur <willverschuur@yahoo.com>
4
  Copyright (c) 2006 Helio Chissini de Castro <helio@kde.org>
5
6
  This library is free software; you can redistribute it and/or
7
  modify it under the terms of the GNU Library General Public
8
  License as published by the Free Software Foundation; either
9
  version 2 of the License, or (at your option) any later version.
10
11
  This library is distributed in the hope that it will be useful,
12
  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
  Library General Public License for more details.
15
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
18
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
  Boston, MA 02110-1301, USA.
20
*/
21
22
#include <iostream>
23
24
#include "kconfigldapbackend.h"
25
#include "kconfigdata.h"
26
#include "kuser.h"
27
#include "xldaplite.h"
28
29
KConfigLDAPBackEnd::KConfigLDAPBackEnd( KConfigBase *config, 
30
                                        const QString &fileName,
31
                                        const char * resType, 
32
                                        bool useKDEGlobals )
33
34
    :   KConfigBackEnd(config, fileName, resType, useKDEGlobals)
35
36
{
37
   _fileImmutable = false;
38
}
39
40
41
42
43
KConfigLDAPBackEnd::~KConfigLDAPBackEnd()
44
{
45
}
46
47
48
49
bool KConfigLDAPBackEnd::parseConfigFiles()
50
{
51
    // will result in an invalid search anyway..
52
    if (mfileName.isEmpty()) 
53
       return false;
54
55
    // blacklists some entries to avoid uselless queries
56
    if (  mfileName == "kdebugrc" 
57
          || mfileName == "kconf_updaterc" 
58
          || mfileName == "kdedrc"
59
          || mfileName == "kdeinitrc"
60
          || mfileName == "kbuildsycocarc"
61
          || mfileName.startsWith( "/" ) )
62
       return false;
63
64
    // connect to ldap server
65
    xLDAPconnection ldap;
66
    if (!ldap.connect()) return false;
67
68
    // User and profilelist
69
    KUser user;
70
    QString basedn = QString( "cn=%1,ou=default,ou=KDEConfig,%2" ).arg( mfileName ).arg( ldap.base() );
71
    QStringList profiles( basedn );
72
73
    // Query group profile
74
    basedn = QString("uid=%1,ou=People,%2").arg(user.loginName()).arg(ldap.base());
75
    char *attrs[] = { "kdeConfigEntry", 0 };
76
    xLDAPquery query( ldap, "(objectClass=posixAccount)", basedn, attrs );
77
78
    for ( xLDAPiterator section(query); section; ++section )
79
    {
80
		 for ( xLDAPattribute gattr(section); gattr; ++gattr )
81
		 {
82
          basedn = QString( "cn=%1,%2" ).arg( mfileName ).arg( gattr.firstValue() );
83
          profiles.push_front( basedn );
84
		 }
85
    }
86
    
87
    for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) 
88
    {
89
       // File immutable
90
       xLDAPquery filequery( ldap, "(objectClass=appConfig)", *it );
91
       for ( xLDAPiterator section( filequery ); section; ++section )
92
       {
93
          for ( xLDAPattribute gattr(section); gattr; ++gattr )
94
          {
95
             if (!strcmp(gattr.attribute(), "immutable")) // immutable
96
                setFileImmutable(0 == strcmp(gattr.firstValue(), "TRUE"));
97
          }
98
       }
99
       
100
       xLDAPquery query( ldap, "(objectClass=appConfigSection)", *it );
101
       
102
       // write results to application settings 
103
       // iterate through sections/groups
104
       for ( xLDAPiterator section(query); section; ++section )
105
       {
106
          QCString aCurrentGroup = "<default>";
107
          bool groupimmutable = false;
108
          // find out group name and flags
109
          for ( xLDAPattribute gattr(section); gattr; ++gattr )
110
          {
111
             // section name
112
             if (!strcmp(gattr.attribute(), "cn"))
113
                aCurrentGroup = gattr.firstValue();
114
             else if (!strcmp(gattr.attribute(), "immutable"))
115
             {
116
                if ( getFileImmutable() )
117
                   groupimmutable = true;
118
                else
119
                   groupimmutable = (0 == strcmp(gattr.firstValue(), "TRUE"));
120
             }
121
             if ( groupimmutable )
122
                setGroupImmutable( aCurrentGroup, true );
123
          }
124
          
125
          // backwards compatibility
126
          if (aCurrentGroup == "KDE Desktop Entry")
127
             aCurrentGroup = "Desktop Entry";
128
          
129
          KEntryKey groupKey(aCurrentGroup, 0);
130
          KEntry entry = pConfig->lookupData(groupKey);
131
          bool groupSkip = entry.bImmutable;
132
          
133
          if (groupSkip)
134
             continue;
135
          
136
          entry.bImmutable |= groupimmutable;
137
          pConfig->putData(groupKey, entry, false);
138
  
139
          // set attribute values
140
          //std::cout << "LDAP: " << "[ " << aCurrentGroup << " ] " <<  std::endl;
141
          for ( xLDAPattribute attr(section);  attr; ++attr )
142
          {
143
             if (strcmp(attr.attribute(), "appconfigentry")) continue;
144
             for ( char* cattr = (char*) attr.firstValue();
145
                   cattr;
146
                   cattr = (char*) attr.nextValue() )
147
             {
148
                QCString cattribute((const char*) cattr); 
149
                cattr = cattribute.data();
150
                char* ceq = (char*) strchr(cattr, '=');
151
                if (!ceq) 
152
                   continue;
153
                
154
                *ceq = 0;
155
                char* cvalue = ++ceq;
156
                
157
                // insert the key/value line
158
                KEntryKey aEntryKey(aCurrentGroup, cattr);
159
                aEntryKey.bLocal = false; //(locale != 0);
160
                aEntryKey.bDefault = false; //bDefault; meep?
161
                
162
                //std::cout << "LDAP: " << cattr << " = " << cvalue <<  std::endl;
163
                
164
                KEntry aEntry;
165
                aEntry.mValue = cvalue;
166
                aEntry.bGlobal = true; //bGlobal;
167
                aEntry.bImmutable = false; //optionImmutable;
168
                aEntry.bDeleted = false; // optionDeleted;
169
                aEntry.bExpand = false; // optionExpand;
170
                aEntry.bNLS = false; //(locale != 0);
171
                
172
                pConfig->putData( aEntryKey, // group
173
                      aEntry,    // entry
174
                      false );   
175
             }
176
          }
177
       }
178
    }
179
    // return successful
180
    return true;
181
}
182
183
184
185
void KConfigLDAPBackEnd::sync(bool bMerge)
186
{
187
    // write back to ldap server..
188
}
189
190
191
192
void KConfigLDAPBackEnd::virtual_hook(int id, void* data)
193
{
194
    KConfigBackEnd::virtual_hook( id, data );
195
}
196
(-)kdelibs-orig/kdecore/kconfigldapbackend.h (+53 lines)
Line 0 Link Here
1
/*
2
  This file is part of the KDE libraries
3
  Copyright (c) 2005 Willem Verschuur <willverschuur@yahoo.com>
4
  Copyright (c) 2006 Helio Chissini de Castro <helio@kde.org>
5
6
  This library is free software; you can redistribute it and/or
7
  modify it under the terms of the GNU Library General Public
8
  License as published by the Free Software Foundation; either
9
  version 2 of the License, or (at your option) any later version.
10
11
  This library is distributed in the hope that it will be useful,
12
  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
  Library General Public License for more details.
15
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
18
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
  Boston, MA 02110-1301, USA.
20
*/
21
22
#ifndef KCONFIGLDAPBACKEND_H
23
#define KCONFIGLDAPBACKEND_H
24
25
#include "kconfigbackend.h"
26
27
/**
28
 * Class for KDE INI-style configuration file loading/saving from LDAP
29
 *
30
 * @author Willem Verschuur <willverschuur@yahoo.com>
31
 * @author Helio Chissini de Castro <helio@kde.org>
32
 */
33
34
class KDECORE_EXPORT KConfigLDAPBackEnd : public KConfigBackEnd
35
{
36
   public:
37
      KConfigLDAPBackEnd( KConfigBase *_config, const QString &_fileName, const char * _resType, bool _useKDEGlobals = true );
38
      virtual ~KConfigLDAPBackEnd();
39
      bool parseConfigFiles();
40
      virtual void sync(bool bMerge = true);
41
      inline void setFileImmutable( bool mt ) { _fileImmutable = mt; }
42
      inline bool getFileImmutable() { return _fileImmutable; }
43
      inline void setGroupImmutable( QString str, bool mt ) { _groupImmutable[ str ] = mt; }
44
      QMap< QString, bool > getGroupImmutable() { return _groupImmutable; }
45
46
   protected:
47
      virtual void virtual_hook(int id, void* data);
48
      bool _fileImmutable;
49
      QMap< QString, bool > _groupImmutable;
50
};
51
52
#endif
53
(-)kdelibs-orig/kdecore/Makefile.am (-3 / +5 lines)
Lines 39-45 Link Here
39
include_HEADERS = kconfig.h kconfigskeleton.h \
39
include_HEADERS = kconfig.h kconfigskeleton.h \
40
	kconfigdata.h ksimpleconfig.h kconfigdialogmanager.h \
40
	kconfigdata.h ksimpleconfig.h kconfigdialogmanager.h \
41
	kconfigbase.h kdesktopfile.h kurl.h ksock.h kaboutdata.h \
41
	kconfigbase.h kdesktopfile.h kurl.h ksock.h kaboutdata.h \
42
	kcmdlineargs.h kconfigbackend.h kapp.h kapplication.h kuniqueapp.h \
42
	kcmdlineargs.h kconfigbackend.h kconfigldapbackend.h \
43
	xldaplite.h kapp.h kapplication.h kuniqueapp.h \
43
	kuniqueapplication.h kcharsets.h kdeversion.h kpty.h kprocess.h \
44
	kuniqueapplication.h kcharsets.h kdeversion.h kpty.h kprocess.h \
44
	kprocctrl.h klocale.h kicontheme.h kiconloader.h kdebug.h \
45
	kprocctrl.h klocale.h kicontheme.h kiconloader.h kdebug.h \
45
	kwinmodule.h kwin.h krootprop.h kshortcut.h kkeynative.h kaccel.h \
46
	kwinmodule.h kwin.h krootprop.h kshortcut.h kkeynative.h kaccel.h \
Lines 85-91 Link Here
85
86
86
libkdecore_la_SOURCES = libintl.cpp kapplication.cpp \
87
libkdecore_la_SOURCES = libintl.cpp kapplication.cpp \
87
	kdebug.cpp netwm.cpp kconfigbase.cpp kconfig.cpp  ksimpleconfig.cpp \
88
	kdebug.cpp netwm.cpp kconfigbase.cpp kconfig.cpp  ksimpleconfig.cpp \
88
	kconfigbackend.cpp kmanagerselection.cpp kdesktopfile.cpp \
89
	kconfigbackend.cpp kconfigldapbackend.cpp xldaplite.cpp \
90
	kmanagerselection.cpp kdesktopfile.cpp \
89
	kstandarddirs.cpp ksock.cpp kpty.cpp kprocess.cpp kprocctrl.cpp \
91
	kstandarddirs.cpp ksock.cpp kpty.cpp kprocess.cpp kprocctrl.cpp \
90
	klocale.cpp krfcdate.cpp kiconeffect.cpp kicontheme.cpp \
92
	klocale.cpp krfcdate.cpp kiconeffect.cpp kicontheme.cpp \
91
	kiconloader.cpp kwin.cpp kwinmodule.cpp krootprop.cpp kcharsets.cpp \
93
	kiconloader.cpp kwin.cpp kwinmodule.cpp krootprop.cpp kcharsets.cpp \
Lines 116-122 Link Here
116
	kqiodevicegzip_p.cpp ktimezones.cpp
118
	kqiodevicegzip_p.cpp ktimezones.cpp
117
119
118
libkdecore_la_LDFLAGS = $(QT_LDFLAGS) $(KDE_RPATH) $(KDE_MT_LDFLAGS) $(X_LDFLAGS) $(USER_LDFLAGS) -version-info 6:0:2 -no-undefined
120
libkdecore_la_LDFLAGS = $(QT_LDFLAGS) $(KDE_RPATH) $(KDE_MT_LDFLAGS) $(X_LDFLAGS) $(USER_LDFLAGS) -version-info 6:0:2 -no-undefined
119
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
121
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)
120
libkdecore_la_NMCHECK = $(srcdir)/libkdecore.nmcheck
122
libkdecore_la_NMCHECK = $(srcdir)/libkdecore.nmcheck
121
libkdecore_la_NMCHECKWEAK = $(srcdir)/libkdecore_weak.nmcheck $(srcdir)/libqt-mt_weak.nmcheck \
123
libkdecore_la_NMCHECKWEAK = $(srcdir)/libkdecore_weak.nmcheck $(srcdir)/libqt-mt_weak.nmcheck \
122
	$(top_srcdir)/dcop/libDCOP_weak.nmcheck $(top_srcdir)/kdecore/standard_weak.nmcheck
124
	$(top_srcdir)/dcop/libDCOP_weak.nmcheck $(top_srcdir)/kdecore/standard_weak.nmcheck
(-)kdelibs-orig/kdecore/xldaplite.cpp (+404 lines)
Line 0 Link Here
1
/*
2
  This file is part of the KDE libraries
3
  Copyright (c) 2005 Willem Verschuur <willverschuur@yahoo.com>
4
  Copyright (c) 2006 Helio Chissini de Castro <helio@kde.org>
5
6
  This library is free software; you can redistribute it and/or
7
  modify it under the terms of the GNU Library General Public
8
  License as published by the Free Software Foundation; either
9
  version 2 of the License, or (at your option) any later version.
10
11
  This library is distributed in the hope that it will be useful,
12
  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
  Library General Public License for more details.
15
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
18
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
  Boston, MA 02110-1301, USA.
20
*/
21
22
#include <qfile.h>
23
#include <qmap.h>
24
#include <qregexp.h>
25
#include <unistd.h>
26
#include <iostream>
27
28
#include "xldaplite.h"
29
30
#ifndef LDAP_CONF
31
#define LDAP_CONF "/etc/ldap.conf"
32
#endif
33
34
#ifndef LDAP_SECRET
35
#define LDAP_SECRET "/etc/ldap.secret"
36
#endif
37
38
xLDAPconnection::xLDAPconnection()
39
{
40
    
41
    m_Connection = 0;
42
    
43
}
44
45
46
47
xLDAPconnection::~xLDAPconnection()
48
{
49
    if (m_Connection)
50
    {
51
        disconnect();
52
    }
53
}
54
55
56
57
bool xLDAPconnection::connect()
58
{
59
60
    // close existing connection
61
    if (m_Connection)
62
    {
63
        disconnect();
64
    }
65
66
    QFile conf(LDAP_CONF);
67
    QMap<QString,QString> config;
68
  
69
    if (!conf.open(IO_ReadOnly)) 
70
    {
71
        //std::cerr << "Cannot open " << LDAP_CONF << std::endl;
72
        return false;
73
    }
74
75
    QTextStream confs(&conf);
76
    
77
    while (!confs.atEnd()) 
78
    {
79
        QString line = confs.readLine();
80
        if (line.contains(QRegExp("^\\s*[a-z]+\\s+.+"))) 
81
        {
82
            QStringList strs=QStringList::split(QRegExp("\\s+"),line);
83
            config[strs[0]] = strs[1];
84
        }
85
    }
86
    
87
    if (geteuid()==0) 
88
    {
89
        
90
        QFile secretFile( LDAP_SECRET );
91
        
92
        if (!secretFile.open(IO_ReadOnly)) 
93
        {
94
            std::cerr << "Cannot find " << LDAP_SECRET << std::endl; 
95
            return false;
96
        }
97
        
98
        QTextStream secretStream(&secretFile);
99
        m_RootPassword = secretStream.readLine();
100
        
101
    }
102
103
    // configure parameters 
104
    QString host = config["host"];
105
    int port = 389;
106
    
107
    if (config.contains("port")) 
108
    {
109
        port = config["port"].toInt();
110
    }
111
    
112
    // create ldap connection
113
    m_Connection = ldap_init(host.latin1(), port);
114
115
    if (!m_Connection) return false;
116
117
    int version = LDAP_VERSION3;
118
    
119
    if (config.contains("ldap_version"))
120
        version = config["ldap_version"].toInt();
121
   
122
    // configure connection
123
    int ret;
124
    if ((ret = ldap_set_option(m_Connection, LDAP_OPT_PROTOCOL_VERSION, &version)) != LDAP_SUCCESS) 
125
    {
126
        std::cerr << "ldap_set_option" << ldap_err2string(ret) << std::endl;
127
        return false;
128
    } 
129
130
    // root binding
131
    if (getuid==0 && config.contains("rootbinddn")) 
132
    {
133
        if ( LDAP_SUCCESS != ldap_bind_s( m_Connection,
134
                                          config["rootbinddn"].latin1(),
135
                                          m_RootPassword.latin1(), 
136
                                          LDAP_AUTH_SIMPLE ) )
137
        {
138
            std::cerr << "Root bind failed" << std::endl;
139
            return false;
140
        }
141
        // should be utf8....
142
    } 
143
    else 
144
    {
145
        if (LDAP_SUCCESS != (ret = ldap_simple_bind_s(m_Connection,NULL,NULL)))
146
        {
147
            std::cerr << "Anonymous bind failed" << std::endl;
148
            return false;
149
        }
150
        // there are also SASL, and kerberos
151
    }
152
    
153
    // configure scope
154
    m_Scope = LDAP_SCOPE_SUBTREE;
155
    
156
    if (config.contains("scope")) 
157
    {
158
        if (config["scope"] == "sub");
159
        else if (config["scope"] == "one")
160
            m_Scope = LDAP_SCOPE_ONELEVEL;
161
        else if (config["scope"] == "base")
162
            m_Scope = LDAP_SCOPE_BASE;
163
        else 
164
        {
165
            std::cerr << "bad value for scope in ldap.conf: " << config["scope"].latin1() << std::endl;
166
            return false;
167
        }
168
    }
169
    
170
    // configure base
171
    if (!config.contains("base")) 
172
    {
173
        std::cerr << "base is not defined in ldap.conf" << std::endl;
174
        return false;
175
    }
176
    
177
    m_Base = config["base"];
178
179
    // return successful
180
    return true;
181
182
}
183
184
185
186
void xLDAPconnection::disconnect()
187
{
188
189
    // the connection doesnt exist
190
    if (!m_Connection) return;
191
192
    // drop connection
193
    ldap_unbind(m_Connection);
194
    m_Connection = 0;
195
196
    return;
197
198
}
199
200
201
202
xLDAPquery::xLDAPquery( xLDAPconnection& connection,
203
                        const QString& filter,
204
                        const QString& pbasedn,
205
                        char** attributes )
206
{
207
208
    // initialize vars
209
    QString basedn;
210
    
211
    if (pbasedn.isNull())
212
    {
213
        basedn = connection.m_Base;
214
    }
215
    else
216
    {
217
        basedn = pbasedn;
218
    }
219
    
220
    m_Connection = &connection;
221
222
    // execute search
223
    m_Result = ldap_search_s(   m_Connection->m_Connection,
224
                                basedn.latin1(),
225
                                m_Connection->m_Scope,
226
                                filter.latin1(),   
227
                                attributes,
228
                                0, // return attrs & values
229
                                &m_Query   );
230
231
    // output an error if query failed
232
    //if (m_Result != LDAP_SUCCESS) 
233
  	    //std::cerr << "ldap_search: " << ldap_err2string(m_Result) << std::endl;
234
235
}
236
237
238
239
xLDAPquery::~xLDAPquery()
240
{
241
    if (m_Query)
242
    {
243
        ldap_msgfree(m_Query);
244
        m_Query = 0;
245
    }
246
}
247
248
249
250
xLDAPiterator::xLDAPiterator(xLDAPquery& query)
251
{
252
    
253
    // initialize vars
254
    m_Query = &query;
255
    m_Entry = 0;   // used by element iterator (this)
256
    m_Element = 0; // used by attribute iterator
257
258
    // fix error handling 
259
    // if (!m_Connection) return false;
260
    // if (!m_Message) return false;
261
    
262
    // point to first element in query result
263
    m_Entry = ldap_first_entry(m_Query->m_Connection->m_Connection, m_Query->m_Query);
264
    
265
}
266
267
268
269
xLDAPiterator::~xLDAPiterator()
270
{
271
272
    clearElement();
273
}
274
275
276
277
void xLDAPiterator::clearElement()
278
{
279
280
    if (m_Element)
281
    {
282
        ber_free(m_Element, 0);
283
        m_Element = 0;
284
    }
285
286
}
287
288
289
290
xLDAPiterator::operator bool ()
291
{
292
    return (m_Entry != 0);
293
}
294
295
296
297
void xLDAPiterator::operator ++ ()
298
{
299
    m_Entry = ldap_next_entry(m_Query->m_Connection->m_Connection, m_Entry);
300
}
301
302
303
304
xLDAPattribute::xLDAPattribute(xLDAPiterator& iter)
305
{
306
307
    // initialize class vars
308
    m_Iterator = &iter;
309
    m_Attribute = 0;
310
    m_Values = 0;
311
    m_CurrentValue = 0;
312
313
    // free previous element's attribute data 
314
    if (m_Iterator->m_Element)
315
    {
316
        m_Iterator->clearElement();
317
    }
318
319
    // get first attribute
320
    m_Attribute = ldap_first_attribute( m_Iterator->m_Query->m_Connection->m_Connection, 
321
                                        m_Iterator->m_Entry, 
322
                                        &m_Iterator->m_Element);
323
324
}
325
326
327
328
xLDAPattribute::~xLDAPattribute()
329
{
330
    clearAttribute();
331
}
332
333
334
335
void xLDAPattribute::clearAttribute()
336
{
337
338
    if (m_Attribute)
339
    {
340
        ldap_memfree(m_Attribute);
341
        m_Attribute = 0;
342
    }
343
    
344
    if (m_Values)
345
    {
346
        clearValues();
347
    }
348
349
}
350
351
352
353
xLDAPattribute::operator bool ()
354
{
355
    return (m_Attribute != 0);
356
}
357
358
359
360
void xLDAPattribute::operator ++ ()
361
{
362
363
    clearAttribute();
364
    m_Attribute = ldap_next_attribute( m_Iterator->m_Query->m_Connection->m_Connection, 
365
                                       m_Iterator->m_Entry, 
366
                                       m_Iterator->m_Element );
367
368
}
369
370
371
372
const char* xLDAPattribute::firstValue()
373
{
374
    if (m_Values)
375
    {
376
        clearValues();
377
    }
378
379
    m_Values = ldap_get_values (  m_Iterator->m_Query->m_Connection->m_Connection, 
380
                                  m_Iterator->m_Entry, 
381
                                  m_Attribute );
382
383
    m_CurrentValue = m_Values;
384
    return *m_CurrentValue;
385
}
386
387
388
const char* xLDAPattribute::nextValue()
389
{
390
    m_CurrentValue++;
391
    return *m_CurrentValue;
392
}
393
394
395
396
void xLDAPattribute::clearValues()
397
{
398
    if (m_Values)
399
    {
400
        ldap_value_free(m_Values);
401
        m_Values = 0;
402
    }
403
}
404
(-)kdelibs-orig/kdecore/xldaplite.h (+217 lines)
Line 0 Link Here
1
/*
2
  This file is part of the KDE libraries
3
  Copyright (c) 2005 Willem Verschuur <willverschuur@yahoo.com>
4
  Copyright (c) 2006 Helio Chissini de Castro <helio@kde.org>
5
6
  This library is free software; you can redistribute it and/or
7
  modify it under the terms of the GNU Library General Public
8
  License as published by the Free Software Foundation; either
9
  version 2 of the License, or (at your option) any later version.
10
11
  This library is distributed in the hope that it will be useful,
12
  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
  Library General Public License for more details.
15
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
18
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
  Boston, MA 02110-1301, USA.
20
*/
21
22
/*
23
 * Lightweight openldap api wrappers, just makes the
24
 * whole memory management schlep so much easier
25
 *
26
 * test: exception handling.. try to break it
27
 *
28
 * note: dont pass these classes as results for functions..
29
 * for that you need to pull the variables into a counter
30
 * referenced core structure.
31
 *
32
 * todo: ldapnode class for a truer in-memory representation
33
 * of LDAP tree.. and easier query coding
34
 */
35
36
#ifndef _XLDAPLITE_H
37
#define _XLDAPLITE_H
38
39
40
41
#include <ldap.h>
42
#include <qstring.h>
43
#include <qstringlist.h>
44
#include <qptrlist.h>
45
46
47
48
class xLDAPquery;
49
class xLDAPiterator;
50
class xLDAPattribute;
51
52
53
54
class xLDAPconnection
55
{
56
57
    
58
    friend class xLDAPquery;
59
    friend class xLDAPiterator;
60
    friend class xLDAPattribute;
61
62
    
63
    public:
64
65
66
        // read /etc/ldap.conf 
67
        xLDAPconnection();
68
69
70
        // free resources on object destruction
71
        ~xLDAPconnection();
72
73
74
        // connect to ldap server
75
        bool connect();
76
77
78
        // free resources
79
        void disconnect();
80
81
82
        // accessor
83
        const LDAP* connection()  { return m_Connection; }
84
        const QString& base() { return m_Base; }
85
        const QString& password() { return m_RootPassword; }
86
87
88
    protected:
89
90
91
        LDAP*           m_Connection;
92
        QString         m_RootPassword;
93
        ber_int_t       m_Scope;
94
        QString         m_Base;
95
       
96
97
};
98
99
100
101
class xLDAPquery
102
{
103
104
105
    // iterator should have access to members
106
    friend class xLDAPiterator;
107
    friend class xLDAPattribute;
108
109
    
110
    public:
111
112
113
        // execute a query
114
        xLDAPquery( xLDAPconnection&, 
115
                    const QString& filter, 
116
                    const QString& base = 0, 
117
                    char** attrs = 0 );
118
119
120
        // free resources on object destruction
121
        ~xLDAPquery();
122
123
        
124
    protected:
125
126
127
        xLDAPconnection*    m_Connection;
128
        LDAPMessage*        m_Query;
129
        int                 m_Result;
130
131
        
132
};
133
134
135
136
class xLDAPiterator
137
{
138
139
140
    friend class xLDAPattribute;
141
142
    
143
    public:
144
145
146
        xLDAPiterator(xLDAPquery&);
147
148
149
        ~xLDAPiterator();
150
151
152
        operator bool(void);
153
154
155
        void operator ++ (void);
156
157
158
    protected:
159
160
161
        void clearElement();
162
163
        
164
        xLDAPquery*     m_Query;
165
        LDAPMessage*    m_Entry;
166
        BerElement*     m_Element; // used by attribute functions
167
168
169
};
170
171
172
173
class xLDAPattribute
174
{
175
176
    
177
    public:
178
179
180
        xLDAPattribute(xLDAPiterator&);
181
182
183
        ~xLDAPattribute();
184
185
186
        operator bool(void);
187
188
189
        void operator ++ (void);
190
191
192
        const char* attribute() { return m_Attribute; }
193
194
195
        const char* firstValue();
196
        const char* nextValue();
197
198
        
199
    protected:
200
201
202
        void clearAttribute();
203
        void clearValues();
204
205
206
        xLDAPiterator*          m_Iterator;
207
        char*                   m_Attribute;    // attribute
208
        char**                  m_Values;
209
        char**                  m_CurrentValue;
210
211
       
212
};
213
214
215
216
#endif
217
(-)kdelibs-3.5.6/kdecore/kconfig.cpp.ldap (-8 / +25 lines)
Lines 34-39 Link Here
34
34
35
#include <kapplication.h>
35
#include <kapplication.h>
36
#include "kconfigbackend.h"
36
#include "kconfigbackend.h"
37
#include "kconfigldapbackend.h"
37
38
38
#include "kconfig.h"
39
#include "kconfig.h"
39
#include "kglobal.h"
40
#include "kglobal.h"
Lines 49-65 Link Here
49
  // set the object's read-only status.
50
  // set the object's read-only status.
50
  setReadOnly(bReadOnly);
51
  setReadOnly(bReadOnly);
51
52
52
  // for right now we will hardcode that we are using the INI
53
  QString ldapenv( getenv( "KDELDAP" ) );
53
  // back end driver.  In the future this should be converted over to
54
54
  // a object factory of some sorts.
55
  if ( ! ldapenv.isEmpty() )
55
  KConfigINIBackEnd *aBackEnd = new KConfigINIBackEnd(this,
56
  {
57
      // for right now we will hardcode that we are using the INI & LDAP
58
      // back end driver.  In the future this should be converted over to
59
      // a object factory of some sorts.
60
      // and to configure precedence and exclusion
61
      KConfigLDAPBackEnd *ldapBackEnd = new KConfigLDAPBackEnd(this,
62
              fileName,
63
              resType,
64
              bUseKderc);
65
      
66
      m_Private->backEnds.append(ldapBackEnd);
67
  }
68
69
  KConfigINIBackEnd *iniBackEnd = new KConfigINIBackEnd(this,
56
						      fileName,
70
						      fileName,
57
                                                      resType,
71
                              resType,
58
						      bUseKderc);
72
						      bUseKderc);
59
73
74
  m_Private->backEnds.append(iniBackEnd);
75
          
60
  // set the object's back end pointer to this new backend
76
  // set the object's back end pointer to this new backend
61
  backEnd = aBackEnd;
77
  backEnd = iniBackEnd;
62
78
  
63
  // read initial information off disk
79
  // read initial information off disk
64
  reparseConfiguration();
80
  reparseConfiguration();
65
81
Lines 88-94 Link Here
88
{
104
{
89
  sync();
105
  sync();
90
106
91
  delete backEnd;
107
  // delete taken care of by destruction of kconfibase's private class
108
  //delete backEnd;
92
}
109
}
93
110
94
void KConfig::rollback(bool bDeep)
111
void KConfig::rollback(bool bDeep)
(-)kdelibs-3.5.8/kdecore/kconfigbase.h (-3 / +18 lines)
Lines 74-79 Link Here
74
  friend class KConfigBackEnd;
74
  friend class KConfigBackEnd;
75
  friend class KConfigINIBackEnd;
75
  friend class KConfigINIBackEnd;
76
  friend class KConfigGroup;
76
  friend class KConfigGroup;
77
  friend class KConfigLDAPBackEnd;
77
78
78
public:
79
public:
79
  /**
80
  /**
Lines 87-92 Link Here
87
  virtual ~KConfigBase();
88
  virtual ~KConfigBase();
88
89
89
  /**
90
  /**
91
  *    * Dump Config on an XML file
92
   *       */
93
  void dumpConfig(  const QString& ent, const QString& val, const QString& type ) const;
94
95
  /**
90
   * Specifies the group in which keys will be read and written.
96
   * Specifies the group in which keys will be read and written.
91
   *
97
   *
92
   *  Subsequent
98
   *  Subsequent
Lines 2005-2013 Link Here
2005
2011
2006
protected:
2012
protected:
2007
  virtual void virtual_hook( int id, void* data );
2013
  virtual void virtual_hook( int id, void* data );
2008
private:
2014
protected:
2009
  class KConfigBasePrivate;
2015
  class KConfigBasePrivate
2010
  KConfigBasePrivate *d;
2016
  {
2017
  public:
2018
     KConfigBasePrivate() : readDefaults(false) { };
2019
2020
  public:
2021
     bool                       readDefaults;
2022
     QPtrList<KConfigBackEnd>   backEnds;
2023
  };
2024
2025
  KConfigBasePrivate *m_Private;
2011
2026
2012
  void writeEntry( const char *pKey, const QString &rValue,
2027
  void writeEntry( const char *pKey, const QString &rValue,
2013
    bool bPersistent, bool bGlobal, bool bNLS, bool bExpand );
2028
    bool bPersistent, bool bGlobal, bool bNLS, bool bExpand );

Return to bug 1499