| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Gtk2::Net::LDAP::Widgets::LdapEntrySelector; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#---[ pod head ]---{{{ |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Gtk2::Net::LDAP::Widgets::LdapEntrySelector - LDAP entry selection window |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Gtk2::Net::LDAP::Widgets; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $entryPopup = Gtk2::Net::LDAP::Widgets::LdapEntrySelector->new ($parent_window, |
|
14
|
|
|
|
|
|
|
$ldap_source, |
|
15
|
|
|
|
|
|
|
'dc=example,dc=com', |
|
16
|
|
|
|
|
|
|
'objectClass=inetorgperson', |
|
17
|
|
|
|
|
|
|
'init_interactive_filter' => 'smith', |
|
18
|
|
|
|
|
|
|
'single_selection' => 1, |
|
19
|
|
|
|
|
|
|
'interactive_filter_type' => 'simple' |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
$entryPopup->signal_connect (response => sub { |
|
22
|
|
|
|
|
|
|
my ($popup, $response) = @_; |
|
23
|
|
|
|
|
|
|
if($response =~ 'accept') { |
|
24
|
|
|
|
|
|
|
print "Selected entry DN: ".$entryPopup->get_dn; |
|
25
|
|
|
|
|
|
|
} else { |
|
26
|
|
|
|
|
|
|
print "No existing entry selected.\n"; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
$_[0]->destroy; |
|
29
|
|
|
|
|
|
|
}); |
|
30
|
|
|
|
|
|
|
$entryPopup->show_all; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 ABSTRACT |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Gtk2::Net::LDAP::Widgets::LdapEntrySelector is a child class to L |
|
36
|
|
|
|
|
|
|
and is used to create a Gtk2 dialog which lets the user search for a LDAP entry |
|
37
|
|
|
|
|
|
|
and select it. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
The dialog is equipped with a search/filter box. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#---}}} |
|
44
|
2
|
|
|
2
|
|
26409
|
use utf8; |
|
|
2
|
|
|
|
|
20
|
|
|
|
2
|
|
|
|
|
9
|
|
|
45
|
2
|
|
|
2
|
|
64
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
299
|
|
|
46
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
69
|
|
|
47
|
2
|
|
|
2
|
|
9
|
use vars qw(@ISA $VERSION); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
144
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
2
|
|
|
2
|
|
11
|
use Carp qw(cluck); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
146
|
|
|
50
|
2
|
|
|
2
|
|
2150
|
use Net::LDAP; |
|
|
2
|
|
|
|
|
466811
|
|
|
|
2
|
|
|
|
|
17
|
|
|
51
|
2
|
|
|
2
|
|
8161
|
use Net::LDAP::Util; |
|
|
2
|
|
|
|
|
140
|
|
|
|
2
|
|
|
|
|
126
|
|
|
52
|
2
|
|
|
2
|
|
1015
|
use Gtk2 -init; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
use Data::Dumper; |
|
54
|
|
|
|
|
|
|
use Gtk2::Net::LDAP::Widgets::LdapEntryView; |
|
55
|
|
|
|
|
|
|
use Gtk2::Net::LDAP::Widgets::Util; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
@ISA = qw(Gtk2::Dialog); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
our $VERSION = "2.0.1"; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
use overload |
|
63
|
|
|
|
|
|
|
q{""} => 'to_string'; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# determine the filter (internal utility method) |
|
66
|
|
|
|
|
|
|
sub _get_filter { |
|
67
|
|
|
|
|
|
|
my $self = shift; |
|
68
|
|
|
|
|
|
|
if ($self->{interactive_filter_type} eq 'ldap') { |
|
69
|
|
|
|
|
|
|
return($self->{entryInteractiveFilter}->get_text); |
|
70
|
|
|
|
|
|
|
} elsif ($self->{interactive_filter_type} eq 'none') { |
|
71
|
|
|
|
|
|
|
return(''); |
|
72
|
|
|
|
|
|
|
} elsif ($self->{interactive_filter_type} eq 'simple') { |
|
73
|
|
|
|
|
|
|
return('cn=*'.$self->{entryInteractiveFilter}->get_text.'*'); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
return(''); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#---[ sub new ]---{{{ |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over 4 |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item new ( parent, ldap_source, base_dn, static_filter, named parameters ) |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Creates a new Gtk2::Net::LDAP::Widgets::LdapEntrySelector object. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
C the L which will be parent of this L |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
C the L object which is an active connection to an LDAP server |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
C the base DN of LDAP search operations |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
C the static filter that will be logically AND-ed with all filters executed by this selector |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 named parameters |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=over 4 |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item init_interactive_filter =E 'some ldap filter' |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
The string to be initially put in the filter box |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item single_selection =E 0 | 1 |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Whether to use single selection mode (otherwise multiple selection is posible) |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item interactive_filter_type =E 'ldap' | 'simple' | 'none' |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The type of filter box: 'ldap' supports full LDAP filter syntax, 'simple' does a substring search against the "cn" attribute, 'none' disables the search/filter box. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=back |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
|
118
|
|
|
|
|
|
|
sub new { |
|
119
|
|
|
|
|
|
|
my $class = shift; |
|
120
|
|
|
|
|
|
|
my $self = $class->SUPER::new('Choose LDAP entry/entries', shift, 'destroy-with-parent', |
|
121
|
|
|
|
|
|
|
'gtk-ok' => 'accept', 'gtk-cancel' => 'reject'); |
|
122
|
|
|
|
|
|
|
$self->set_modal(1); |
|
123
|
|
|
|
|
|
|
$self->{ldap_source} = shift; |
|
124
|
|
|
|
|
|
|
$self->{base_dn} = shift; |
|
125
|
|
|
|
|
|
|
$self->{static_filter} = shift; |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
my %named_params = @_; |
|
128
|
|
|
|
|
|
|
$self->{init_interactive_filter} = $named_params{'init_interactive_filter'}; |
|
129
|
|
|
|
|
|
|
$self->{single_selection} = $named_params{'single_selection'}; |
|
130
|
|
|
|
|
|
|
$self->{interactive_filter_type} = $named_params{'interactive_filter_type'}; |
|
131
|
|
|
|
|
|
|
# possible values: 'ldap', 'simple', 'none': |
|
132
|
|
|
|
|
|
|
if (! $self->{interactive_filter_type}) { |
|
133
|
|
|
|
|
|
|
$self->{interactive_filter_type} = 'ldap'; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $btnFiltruj = Gtk2::Button->new_with_mnemonic ('_Filter'); |
|
138
|
|
|
|
|
|
|
if ($self->{interactive_filter_type} ne 'none') { |
|
139
|
|
|
|
|
|
|
# The filter horizontal box: |
|
140
|
|
|
|
|
|
|
my $hboxFilter = Gtk2::HBox->new; |
|
141
|
|
|
|
|
|
|
my $labelFilter = Gtk2::Label->new; |
|
142
|
|
|
|
|
|
|
if ($self->{interactive_filter_type} eq 'ldap') { |
|
143
|
|
|
|
|
|
|
$labelFilter->set_markup("LDAP filter:"); |
|
144
|
|
|
|
|
|
|
} elsif ($self->{interactive_filter_type} eq 'simple') { |
|
145
|
|
|
|
|
|
|
$labelFilter->set_markup("Search:"); |
|
146
|
|
|
|
|
|
|
} else { |
|
147
|
|
|
|
|
|
|
$labelFilter->set_markup("filter:"); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
$hboxFilter->pack_start ($labelFilter, 0, 0, 5); |
|
150
|
|
|
|
|
|
|
my $entryInteractiveFilter = Gtk2::Entry->new; |
|
151
|
|
|
|
|
|
|
$entryInteractiveFilter->set_text($self->{init_interactive_filter}); |
|
152
|
|
|
|
|
|
|
$hboxFilter->pack_start ($entryInteractiveFilter, 1, 1, 5); |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
$hboxFilter->pack_start ($btnFiltruj, 1, 1, 5); |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
$self->{entryInteractiveFilter} = $entryInteractiveFilter; |
|
157
|
|
|
|
|
|
|
$self->vbox->pack_start ($hboxFilter, 0, 0, 5); |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Results list component: |
|
162
|
|
|
|
|
|
|
bless $self, $class; |
|
163
|
|
|
|
|
|
|
$self->{listEntriesView} = Gtk2::Net::LDAP::Widgets::LdapEntryView->new($self->{ldap_source}, $self->{base_dn}, $self->{static_filter}, |
|
164
|
|
|
|
|
|
|
$self->_get_filter, $self->{single_selection}); |
|
165
|
|
|
|
|
|
|
my $scrollwin = Gtk2::ScrolledWindow->new; |
|
166
|
|
|
|
|
|
|
$scrollwin->set_policy ('never', 'automatic'); |
|
167
|
|
|
|
|
|
|
$scrollwin->set_shadow_type ('in'); |
|
168
|
|
|
|
|
|
|
$scrollwin->add($self->{listEntriesView}); |
|
169
|
|
|
|
|
|
|
$self->vbox->pack_start ($scrollwin, 1, 1, 5); |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
$self->set_default_size(640, 480); |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$btnFiltruj->signal_connect (clicked => sub { |
|
174
|
|
|
|
|
|
|
$self->refresh_list; |
|
175
|
|
|
|
|
|
|
}); |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
bless $self, $class; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
#---}}} |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
# by OLO |
|
182
|
|
|
|
|
|
|
# czw mar 17 17:51:20 CET 2005 |
|
183
|
|
|
|
|
|
|
# Conversion of self to string: |
|
184
|
|
|
|
|
|
|
sub to_string { |
|
185
|
|
|
|
|
|
|
my $self = shift; |
|
186
|
|
|
|
|
|
|
return $self->{class}.' "'.\$self.'"'; |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
#---[ sub refresh_list ]---{{{ |
|
191
|
|
|
|
|
|
|
=head2 refresh_list |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Refresh the entries list - re-execute the search with the filter determined by |
|
194
|
|
|
|
|
|
|
the search/filter box. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
|
197
|
|
|
|
|
|
|
sub refresh_list { |
|
198
|
|
|
|
|
|
|
my $self = shift; |
|
199
|
|
|
|
|
|
|
my $newfilter = $self->_get_filter; |
|
200
|
|
|
|
|
|
|
$self->{listEntriesView}->set_interactive_filter($newfilter); |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
#---}}} |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
#---[ sub get_dn ]---{{{ |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head2 get_dn |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Return the list of selected entries' Distinguished Names. |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
The list has at most one entry if single_selection is set to 1. |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut |
|
213
|
|
|
|
|
|
|
sub get_dn { |
|
214
|
|
|
|
|
|
|
my $self = shift; |
|
215
|
|
|
|
|
|
|
return $self->{listEntriesView}->get_dn; |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
#---}}} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
1; |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
__END__ |