2 * Copyright (c) 1998 Denis Perchine <dyp@perchine.com>
3 * Copyright (c) 2004 Szombathelyi GyĂśrgy <gyurco@freemail.hu>
4 * Former maintainer: Adriaan de Groot <groot@kde.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU 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.
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.
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.
23 #include <kmessagebox.h>
25 #include "ku_global.h"
26 #include "ku_userfiles.h"
27 #include "ku_groupfiles.h"
28 #include "ku_userldap.h"
29 #include "ku_groupldap.h"
30 #include "ku_usersystem.h"
31 #include "ku_groupsystem.h"
33 void KU_Global::initCfg( const QString
&connection
)
39 KSharedConfig::Ptr
config( KGlobal::config() );
40 mCfg
= new KU_PrefsBase( config
, connection
);
44 void KU_Global::displayUsersError()
46 if ( mUsers
->errorDetails().isEmpty() )
47 KMessageBox::error( 0, mUsers
->errorString() );
49 KMessageBox::detailedError( 0, mUsers
->errorString(), mUsers
->errorDetails() );
52 void KU_Global::displayGroupsError()
54 if ( mGroups
->errorDetails().isEmpty() )
55 KMessageBox::error( 0, mGroups
->errorString() );
57 KMessageBox::detailedError( 0, mGroups
->errorString(), mGroups
->errorDetails() );
60 void KU_Global::init()
65 SID::setAlgRidBase( mCfg
->samridbase() );
66 kDebug() << "Algorithmic RID base: " << SID::getAlgRidBase();
67 switch ( mCfg
->source() ) {
68 case KU_PrefsBase::EnumSource::Files
:
69 mUsers
= new KU_UserFiles( mCfg
);
70 mGroups
= new KU_GroupFiles( mCfg
);
72 case KU_PrefsBase::EnumSource::LDAP
:
73 mUsers
= new KU_UserLDAP( mCfg
);
74 mGroups
= new KU_GroupLDAP( mCfg
);
76 case KU_PrefsBase::EnumSource::System
:
77 mUsers
= new KU_UserSystem( mCfg
);
78 mGroups
= new KU_GroupSystem( mCfg
);
83 if ( !mUsers
->reload() ) displayUsersError();
84 if ( !mGroups
->reload() ) displayGroupsError();
87 KU_Users
*KU_Global::users()
92 KU_Groups
*KU_Global::groups()
97 KU_PrefsBase
*KU_Global::kcfg()
102 KU_Users
*KU_Global::mUsers
;
103 KU_Groups
*KU_Global::mGroups
;
105 KU_PrefsBase
*KU_Global::mCfg
;