NAME
Net::XMPP2::IM::Contact - Instant messaging roster contact
SYNOPSIS
my $con = Net::XMPP2::IM::Connection->new (...);
...
my $ro = $con->roster;
if (my $c = $ro->get_contact ('test@example.com')) {
$c->make_message ()->add_body ("Hello there!")->send;
}
DESCRIPTION
This module represents a class for contact objects which populate a roster (Net::XMPP2::IM::Roster.
You can get an instance of this class only by calling the get_contact
function on a roster object.
METHODS
- send_update ($cb, %upd)
-
This method updates a contact. If the request is finished it will call
$cb
. If it resulted in an error the first argument of that callback will be a Net::XMPP2::Error::IQ object.The
%upd
hash should have one of the following keys and defines what parts of the contact to update:- name => $name
-
Updates the name of the contact.
$name
= '' erases the contact. - add_group => $groups
-
Addes the contact to the groups in the arrayreference
$groups
. - remove_group => $groups
-
Removes the contact from the groups in the arrayreference
$groups
. - groups => $groups
-
This sets the groups of the contact.
$groups
should be an array reference of the groups.
- send_subscribe ()
-
This method sends this contact a subscription request.
- send_subscribed ()
-
This method accepts a contact's subscription request.
- send_unsubscribe ()
-
This method sends this contact a unsubscription request.
- send_unsubscribed ()
-
This method sends this contact a unsubscription request which unsubscribes ones own presence from him (he wont get any further presence from us).
- update ($item)
-
This method wants a Net::XMPP2::Node in
$item
which should be a roster item received from the server. The method will update the contact accordingly and return it self. - update_presence ($presence)
-
This method updates the presence of contacts on the roster.
$presence
must be a Net::XMPP2::Node object and should be a presence packet. - get_presence ($jid)
-
This method returns a presence of this contact if it is available. The return value is an instance of Net::XMPP2::IM::Presence or undef if no such presence exists.
- get_presences
-
Returns all presences of this contact in form of Net::XMPP2::IM::Presence objects.
- get_priority_presence
-
Returns the presence with the highest priority.
- groups
-
Returns the list of groups (strings) this contact is in.
- jid
-
Returns the bare JID of this contact.
- name
-
Returns the (nick)name of this contact.
- is_on_roster ()
-
Returns 1 if this is a contact that is officially on the roster and not just a contact we've received presence information for.
- subscription
-
Returns the subscription state of this contact, which can be one of:
'none', 'to', 'from', 'both'
If the contact isn't on the roster anymore this method returns:
'remove'
- ask
-
Returns 'subscribe' if we asked this contact for subscription.
- subscription_pending
-
Returns true if this contact has a pending subscription. That means: the contact has to aknowledge the subscription.
- nickname
-
Returns the nickname of this contact.
- make_message (%args)
-
This method returns a Net::XMPP2::IM::Message object with the to field set to this contacts JID.
%args
are further arguments for the message constructor.
AUTHOR
Robin Redeker, <elmex at ta-sa.org>
, JID: <elmex at jabber.org>
COPYRIGHT & LICENSE
Copyright 2007 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.