Changeset 892568b


Ignore:
Timestamp:
Sep 12, 2007, 10:46:17 PM (17 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
6711361
Parents:
86840c5
Message:
Show full JIDs for users in non-anonymous JIDs in :jmuc presence. closes #24
Location:
perl/modules/Jabber/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r86840c5 r892568b  
    601601    die("Usage: jmuc part MUC [-a account]") unless $muc;
    602602
    603     $conn->getConnectionFromJID($jid)->MUCLeave(JID => $muc);
    604     queue_admin_msg("$jid has left $muc.");
     603    if($conn->getConnectionFromJID($jid)->MUCLeave(JID => $muc)) {
     604        queue_admin_msg("$jid has left $muc.");
     605    } else {
     606        die("Error: Not joined to $muc");
     607    }
    605608}
    606609
     
    641644    my $m = shift;
    642645    my @jids = $m->Presence();
    643     return "JIDs present in " . $m->BaseJID . "\n\t"
    644       . join("\n\t", map {$_->GetResource}@jids) . "\n";
     646
     647    my $presence = "JIDs present in " . $m->BaseJID;
     648    if($m->Anonymous) {
     649        $presence .= " [anonymous MUC]";
     650    }
     651    $presence .= "\n\t";
     652    $presence .= join("\n\t", map {pp_jid($m, $_);} @jids) . "\n";
     653    return $presence;
     654}
     655
     656sub pp_jid {
     657    my ($m, $jid) = @_;
     658    my $nick = $jid->GetResource;
     659    my $full = $m->GetFullJID($jid);
     660    if($full && $full ne $nick) {
     661        return "$nick ($full)";
     662    } else {
     663        return "$nick";
     664    }
    645665}
    646666
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/Connection.pm

    r3c455b4 r892568b  
    5252Leave a MUC. The MUC is specified in the same form as L</FindMUC>
    5353
     54Returns true if successful, false if this connection was not in the
     55named MUC.
     56
    5457=cut
    5558
     
    6164    $muc->Leave();
    6265    $self->{_BARNOWL_MUCS} = [grep {$_->BaseJID ne $muc->BaseJID} $self->MUCs];
     66    return 1;
    6367}
    6468
  • perl/modules/Jabber/lib/Net/Jabber/MUC.pm

    rc2bed55 r892568b  
    6464    $self->{JID} = $args{jid};
    6565    $self->{PRESENCE} = { };
     66    $self->{ANONYMOUS} = 1;
    6667
    6768    bless($self, $class);
     
    188189        delete $self->{PRESENCE}->{$from->GetJID('full')};
    189190    } elsif($type eq 'available') {
    190         $self->{PRESENCE}->{$from->GetJID('full')} = $from;
     191        $self->{PRESENCE}->{$from->GetJID('full')} = {ROOMNICK => $from};
     192        my $x = $presence->GetX('http://jabber.org/protocol/muc#user');
     193        if($x && $x->DefinedItem()) {
     194            my $item = $x->GetItem();
     195            if($item->DefinedJID()) {
     196                $self->{PRESENCE}->{$from->GetJID('full')}->{FULLJID} = $item->GetJID();
     197                $self->{ANONYMOUS} = 0;
     198            }
     199        }
    191200    }
    192201}
     
    207216}
    208217
     218=head2 GetFullJID roomjid
     219
     220Given the roomnick of a user in the MUC, return their full NIC if the
     221MUC makes it available. If the MUC is anonymous or the user does not
     222exist in the MUC, return undef.
     223
     224=cut
     225
     226sub GetFullJID {
     227    my $self = shift;
     228    my $jid = shift;
     229
     230    $jid = $jid->GetJID('full') if UNIVERSAL::isa($jid, 'Net::Jabber::JID');
     231    my $pres = $self->{PRESENCE}->{$jid};
     232    return unless $pres;
     233    return $pres->{FULLJID};
     234}
     235
    209236=head2 Presence
    210237
     
    215242sub Presence {
    216243    my $self = shift;
    217     return values %{$self->{PRESENCE}};
     244    return map {$_->{ROOMNICK}} values %{$self->{PRESENCE}};
     245}
     246
     247=head2 Anonymous
     248
     249Returns true if the MUC is anonymous (hides participants real JIDs)
     250
     251=cut
     252
     253sub Anonymous {
     254    my $self = shift;
     255    return $self->{ANONYMOUS};
    218256}
    219257
Note: See TracChangeset for help on using the changeset viewer.