-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
ku_global.cpp
105 lines (93 loc) · 2.83 KB
/
ku_global.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Copyright (c) 1998 Denis Perchine <[email protected]>
* Copyright (c) 2004 Szombathelyi GyĂśrgy <[email protected]>
* Former maintainer: Adriaan de Groot <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU 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 <kglobal.h>
#include <kmessagebox.h>
#include "ku_global.h"
#include "ku_userfiles.h"
#include "ku_groupfiles.h"
#include "ku_userldap.h"
#include "ku_groupldap.h"
#include "ku_usersystem.h"
#include "ku_groupsystem.h"
void KU_Global::initCfg( const QString &connection )
{
if ( mCfg ) {
mCfg->writeConfig();
delete mCfg;
}
KSharedConfig::Ptr config( KGlobal::config() );
mCfg = new KU_PrefsBase( config, connection );
mCfg->readConfig();
}
void KU_Global::displayUsersError()
{
if ( mUsers->errorDetails().isEmpty() )
KMessageBox::error( 0, mUsers->errorString() );
else
KMessageBox::detailedError( 0, mUsers->errorString(), mUsers->errorDetails() );
}
void KU_Global::displayGroupsError()
{
if ( mGroups->errorDetails().isEmpty() )
KMessageBox::error( 0, mGroups->errorString() );
else
KMessageBox::detailedError( 0, mGroups->errorString(), mGroups->errorDetails() );
}
void KU_Global::init()
{
delete mUsers;
delete mGroups;
SID::setAlgRidBase( mCfg->samridbase() );
kDebug() << "Algorithmic RID base: " << SID::getAlgRidBase();
switch ( mCfg->source() ) {
case KU_PrefsBase::EnumSource::Files:
mUsers = new KU_UserFiles( mCfg );
mGroups = new KU_GroupFiles( mCfg );
break;
case KU_PrefsBase::EnumSource::LDAP:
mUsers = new KU_UserLDAP( mCfg );
mGroups = new KU_GroupLDAP( mCfg );
break;
case KU_PrefsBase::EnumSource::System:
mUsers = new KU_UserSystem( mCfg );
mGroups = new KU_GroupSystem( mCfg );
break;
default:
Q_ASSERT(0);
}
if ( !mUsers->reload() ) displayUsersError();
if ( !mGroups->reload() ) displayGroupsError();
}
KU_Users *KU_Global::users()
{
return mUsers;
}
KU_Groups *KU_Global::groups()
{
return mGroups;
}
KU_PrefsBase *KU_Global::kcfg()
{
return mCfg;
}
KU_Users *KU_Global::mUsers;
KU_Groups *KU_Global::mGroups;
KU_PrefsBase *KU_Global::mCfg;