Proof-reading - fixed one usage of the i18n plural form (it wasn't doing before,...
[kdeadmin.git] / kuser / ku_global.cpp
blob2cad6bb5fef6d9a7e7a77d06774621010aa4756f
1 /*
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.
20 **/
22 #include <kglobal.h>
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 )
35 if ( mCfg ) {
36 mCfg->writeConfig();
37 delete mCfg;
39 KSharedConfig::Ptr config( KGlobal::config() );
40 mCfg = new KU_PrefsBase( config, connection );
41 mCfg->readConfig();
44 void KU_Global::displayUsersError()
46 if ( mUsers->errorDetails().isEmpty() )
47 KMessageBox::error( 0, mUsers->errorString() );
48 else
49 KMessageBox::detailedError( 0, mUsers->errorString(), mUsers->errorDetails() );
52 void KU_Global::displayGroupsError()
54 if ( mGroups->errorDetails().isEmpty() )
55 KMessageBox::error( 0, mGroups->errorString() );
56 else
57 KMessageBox::detailedError( 0, mGroups->errorString(), mGroups->errorDetails() );
60 void KU_Global::init()
62 delete mUsers;
63 delete mGroups;
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 );
71 break;
72 case KU_PrefsBase::EnumSource::LDAP:
73 mUsers = new KU_UserLDAP( mCfg );
74 mGroups = new KU_GroupLDAP( mCfg );
75 break;
76 case KU_PrefsBase::EnumSource::System:
77 mUsers = new KU_UserSystem( mCfg );
78 mGroups = new KU_GroupSystem( mCfg );
79 break;
80 default:
81 Q_ASSERT(0);
83 if ( !mUsers->reload() ) displayUsersError();
84 if ( !mGroups->reload() ) displayGroupsError();
87 KU_Users *KU_Global::users()
89 return mUsers;
92 KU_Groups *KU_Global::groups()
94 return mGroups;
97 KU_PrefsBase *KU_Global::kcfg()
99 return mCfg;
102 KU_Users *KU_Global::mUsers;
103 KU_Groups *KU_Global::mGroups;
105 KU_PrefsBase *KU_Global::mCfg;