From b929a3c6effc268d4cf4fff1ca3c626cf799debb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jorge=20Rodr=C3=ADguez?= Date: Mon, 15 Oct 2007 15:20:07 +0200 Subject: [PATCH] 'Populate rosters with chatrooms' support added. --- Makefile.16 | 4 ++++ tools/Vcard2Ldap.pm | 28 +++++++++++++++++++++++----- tools/jabber2db.pl | 12 ++++++------ 3 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 Makefile.16 diff --git a/Makefile.16 b/Makefile.16 new file mode 100644 index 0000000..636f29c --- /dev/null +++ b/Makefile.16 @@ -0,0 +1,4 @@ +all: + cd src/ && $(MAKE) -f Makefile.16 $@ +clean: + cd src/ && $(MAKE) -f Makefile.16 $@ diff --git a/tools/Vcard2Ldap.pm b/tools/Vcard2Ldap.pm index 51d0bd0..b0ea01f 100644 --- a/tools/Vcard2Ldap.pm +++ b/tools/Vcard2Ldap.pm @@ -11,8 +11,9 @@ my $ldapserver = "localhost"; my $disname="cn=admin,dc=nodomain"; my $ldappass= "secret"; my $ldapperson = "irisPerson"; -my $ldapgroup = "ou"; +my $ldapchatroom = ""; +my $ldapgroup = "ou"; my $ldapjidattr = "irisUserPresenceID"; my $ldapjidmatch = qr/urn:mace:rediris.es:presence:xmpp:([\w\-_\.]+@.+)/; @@ -125,7 +126,10 @@ sub ldap_get_users { ); die $us->error if $us->code; - set_users ($us) if ($#users == -1); + if ($#users == -1) { + add_users ($us); + add_chatrooms ($ldap) if (length ($ldapchatrooms) > 0); + } return $us->entries; } @@ -191,7 +195,7 @@ sub vcard_get_map { ### private -sub set_users { +sub add_users { my $us = shift; foreach ($us->entries) { @@ -205,6 +209,20 @@ sub set_users { } } +sub add_chatrooms { + my $ldap = shift; + + my $us = $ldap->search( + base => "$basedn", + scope => "one", + filter => "(&(objectClass=$ldapchatroom)($ldapgroup=*))" + ); + + die $us->error if $us->code; + + add_users ($us); +} + sub parse_vcard { my $key = shift; my $value = shift; @@ -217,14 +235,14 @@ sub parse_vcard { if ($_ eq "v2ln") { next; } elsif ($_ eq "content") { - $ret .= "$key". parse_vcard ('', $value->{$_}); + $ret .= "$key". parse_vcard ("", $value->{$_}); } else { $ret .= "$key/". parse_vcard ($_, $value->{$_}); } } } elsif (ref ($value) eq "ARRAY") { for (@$value) { - $ret .= "$key" . parse_vcard ('', $_); + $ret .= "$key" . parse_vcard ("", $_); } } diff --git a/tools/jabber2db.pl b/tools/jabber2db.pl index d5bc46c..56576b7 100755 --- a/tools/jabber2db.pl +++ b/tools/jabber2db.pl @@ -180,9 +180,9 @@ sub db_delete_rosters { sub db_insert_vcard { my $pers = shift; - my $squery = ''; - my $ssquery = ''; - my $query = ''; + my $squery = ""; + my $ssquery = ""; + my $query = ""; $query = "INSERT INTO vcard (\"collection-owner\""; @@ -206,9 +206,9 @@ sub db_insert_vcard { sub db_update_vcard { my $pers = shift; - my $squery = ''; - my $ssquery = ''; - my $query = ''; + my $squery = ""; + my $ssquery = ""; + my $query = ""; $query = "UPDATE vcard SET "; -- 2.11.4.GIT