AnyEvent-XMPP
view release on metacpan or search on metacpan
lib/AnyEvent/XMPP/IM/Account.pm view on Meta::CPAN
=cut
sub bare_jid {
my ($self) = @_;
prep_bare_jid $self->jid
}
=item B<nickname ()>
Your nickname for this account.
=cut
sub nickname {
my ($self) = @_;
# FIXME: fetch real nickname from server somehow? Does that exist?
# eg. from the roster?
my ($user, $host, $res) = split_jid ($self->bare_jid);
$user
}
=item B<nickname_for_jid ($jid)>
This method transforms the C<$jid> to a nickname. It looks the C<$jid>
up in the roster and looks for a nickname. If no nickname could be found
in the roster it returns the node part for the C<$jid>.
=cut
sub nickname_for_jid {
my ($self, $jid) = @_;
if ($self->is_connected) {
my $c = $self->connection->get_roster->get_contact ($jid);
return $c ? $c->nickname : node_jid ($jid);
} else {
return node_jid ($jid);
}
}
=item B<send_tracked_message ($msg)>
This method sends the L<AnyEvent::XMPP::IM::Message> object in C<$msg>.
The C<to> attribute of the message is adjusted by the conversation tracking
mechanism.
=cut
sub send_tracked_message {
my ($self, $msg) = @_;
my $bjid = prep_bare_jid $msg->to;
$msg->to ($self->{track}->{$bjid} || $bjid);
$msg->send ($self->connection)
}
=back
=head1 EVENTS
For these events callbacks can be registered (with the L<Object::Event> interface):
=over 4
=item tracked_message_destination => $bare_jid, $full_jid
This event is emitted whenever the message tracking mechanism changes (or sets)
it's destination resource for the C<$bare_jid> to C<$full_jid>.
=item removed
Whenever the account is removed from the L<AnyEvent::XMPP::Client>
(eg. when disconnected) this event is emitted before it is destroyed.
=back
=head1 AUTHOR
Robin Redeker, C<< <elmex at ta-sa.org> >>, JID: C<< <elmex at jabber.org> >>
=head1 COPYRIGHT & LICENSE
Copyright 2007, 2008 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
1;
( run in 0.503 second using v1.01-cache-2.11-cpan-39bf76dae61 )