NAME

Net::Jabber::Query::Roster::Item - Jabber IQ Roster Item Module

SYNOPSIS

Net::Jabber::Query::Roster::Item is a companion to the 
Net::Jabber::Query::Roster module.  It provides the user a simple 
interface to set and retrieve all parts of a Jabber Roster Item.

DESCRIPTION

To initialize the Item with a Jabber <iq/> and then access the auth
query you must pass it the XML::Parser Tree array from the 
Net::Jabber::Client module.  In the callback function for the iq:

  use Net::Jabber;

  sub iq {
    my $iq = new Net::Jabber::IQ(@_);
    my $roster = $iq->GetQuery();
    my @items = $roster->GetItems();
    foreach $item (@items) {
      ...
    }
    .
    .
    .
  }

You now have access to all of the retrieval functions available below.

To create a new IQ Roster Item to send to the server:

  use Net::Jabber;

  $Client = new Net::Jabber::Client();
  ...

  $iq = new Net::Jabber::IQ();
  $roster = $iq->NewQuery("jabber:iq:roster");
  $item = $roster->AddItem();
  ...

  $client->Send($iq);

Using $Item you can call the creation functions below to populate the 
tag before sending it.

For more information about the array format being passed to the CallBack
please read the Net::Jabber::Client documentation.

Retrieval functions

$jid          = $item->GetJID();
$jidJID       = $item->GetJID("jid");
$name         = $item->GetName();
$subscription = $item->GetSubscription();
$ask          = $item->GetAsk();
@groups       = $item->GetGroups();

@item         = $item->GetTree();
$str          = $item->GetXML();

Creation functions

    $item->SetItem(jid=>'bob@jabber.org',
		   name=>'Bob',
		   subscription=>'both',
		   groups=>[ 'friends','school' ]);

    $item->SetJID('bob@jabber.org');
    $item->SetName('Bob');
    $item->SetSubscription('both');
    $item->SetAsk('both');
    $item->SetGroups(['friends','school']);

METHODS

Retrieval functions

GetJID()      - returns either a string with the Jabber Identifier,
GetJID("jid")   or a Net::Jabber::JID object for the person who is 
                listed in this <item/>.  To get the JID object set the 
                string to "jid", otherwise leave blank for the text
                string.

GetName() - returns a string with the name of the jabber ID.

GetSubscription() - returns a string with the current subscription 
                    of this <item/>.

                    none    means no one is getting <presence/> tags
                    to      means we are getting their <presence/>
                            but they are not getting ours
                    from    means we are not getting their <presence/>
                            but they are getting ours
                    both    means we are getting their <presence/>
                            and they are getting ours
                    remove  remove this jid from the roster

GetAsk() - returns a string with the current ask of this <item/>.
           This is the pending request by you to this JID, usually
           handled by the server.

GetGroups() - returns an array of strings with the names of the groups
             that this <item/> belongs to.

GetXML() - returns the XML string that represents the <presence/>.
           This is used by the Send() function in Client.pm to send
           this object as a Jabber Presence.

GetTree() - returns an array that contains the <presence/> tag
            in XML::Parser Tree format.

Creation functions

SetItem(jid=>string|JID,      - set multiple fields in the <item/>
        name=>string,           at one time.  This is a cumulative
        subscription=>string,   and overwriting action.  If you
        ask=>string,            set the "ask" twice, the second
        groups=>array)          setting is what is used.  If you set
                                the password, and then set the
                                resource then both will be in the
                                <item/> tag.  For valid settings
                                read the specific Set functions below.
                                Note: group does not behave in this
                                manner.  For each group setting a
                                new <group/> tag will be created.

SetJID(string) - sets the Jabber Identifier.  You can either pass a
SetJID(JID)      string or a JID object.  They must be valid Jabber 
                 Identifiers or the server will return an error message.
                 (ie.  jabber:bob@jabber.org/Silent Bob, etc...)

SetName(string) - sets the name this roster item should show in the
                  roster.

SetSubscription(string) - sets the subscription that this roster item
                          has.

SetAsk(string) - sets the ask for the <item/>.

SetGroups(array) - sets the group for each group in the array.

AUTHOR

By Ryan Eatmon in May of 2000 for http://jabber.org..

COPYRIGHT

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.