NAME

Net::Jabber::Message - Jabber Message Module

SYNOPSIS

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

DESCRIPTION

To initialize the Message with a Jabber <message/> you must pass it 
the XML::Parser Tree array from the Net::Jabber::Client module.  In the
callback function for the message:

  use Net::Jabber;

  sub message {
    my $message = new Net::Jabber::Message(@_);
    .
    .
    .
  }

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

To create a new message to send to the server:

  use Net::Jabber;

  $Mess = new Net::Jabber::Message();

Now 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

$from     = $Mess->GetFrom();
$resource = $Mess->GetResource();
$id       = $Mess->GetID();
$type     = $Mess->GetType();
$subject  = $Mess->GetSubject();
$body     = $Mess->GetBody();
@body     = $Mess->GetBody("full");
$thread   = $Mess->GetThread();
$priority = $Mess->GetPriority();
$error    = $Mess->GetError();
$errType  = $Mess->GetErrorType();
@xTags    = $Mess->GetX();
@xTags    = $Mess->GetX("my:namespace");
@xTrees   = $Mess->GetXTrees();
@xTrees   = $Mess->GetXTrees("my:namespace");

$str      = $Mess->GetXML();
@message  = $Mess->GetTree();

Creation functions

    $Mess->SetMessage(-TO=>"bob\@jabber.org/Working Bob",
		      -Subject=>"Lunch",
		      -BoDy=>"Let's go grab some lunch!",
		      -priority=>100);
    $Mess->SetTo("Test User");
    $Mess->SetSubject("This is a test");
    $Mess->SetBody("This is a test of the emergency broadcast system...");
    $Mess->SetThread("AE912B3");
    $Mess->SetPriority(1);

    $Mess->SetMessage(-to=>"bob\@jabber.org",
                      -errortype=>"denied",
                      -error=>"Permission Denied");
    $Mess->SetErrorType("denied");
    $Mess->SetError("Permission Denied");

    $X = $Mess->NewX("jabber:x:delay");
    $X = $Mess->NewX("my:namespace");

METHODS

Retrieval functions

GetTo() - returns a string with the Jabber Identifier of the 
          person who is going to receive the <message/>.

GetFrom() - returns a string with the Jabber Identifier of the 
            person who sent the <message/>.

GetResource() - returns a string with the Jabber Resource of the 
                person who sent the <message/>.

GetID() - returns an integer with the id of the <message/>.

GetType() - returns a string with the type <message/> this is.

GetSubject() - returns a string with the subject of the <message/>.

GetBody(string) - returns the data in the <body/> tag depending on the
                  value of the string passed to it.  The string
                  represents the mark up level to return.

                  none   returns a string with just the text of 
                         the <body/> (default)
                  full   returns an XML::Paser::Tree with everything
                         in the <body/>

GetThread() - returns a string that represents the thread this
              <message/> belongs to.

GetPriority() - returns an integer with the priority of the <message/>.

GetError() - returns a string with the data of the <error/> tag.

GetErrorType() - returns a string with the type of the <error/> tag.

GetX(string) - returns an array of Net::Jabber::X objects.  The string can 
               either be empty or the XML Namespace you are looking for.  
               If empty then GetX returns every <x/> tag in the 
               <message/>.  If an XML Namespace is sent then GetX 
               returns every <x/> tag with that Namespace.

GetXTrees(string) - returns an array of XML::Parser::Tree objects.  The 
                    string can either be empty or the XML Namespace you 
                    are looking for.  If empty then GetXTrees returns every 
                    <x/> tag in the <message/>.  If an XML Namespace is 
                    sent then GetXTrees returns every <x/> tag with that 
                    Namespace.

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

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

Creation functions

SetMessage(to=>string,         - set multiple fields in the <message/>
           type=>string,         at one time.  This is a cumulative
           subject=>string,      and over writing action.  If you set
           body=>string,         the "to" attribute twice, the second
           thread=>string,       setting is what is used.  If you set
           priority=>integer,    the subject, and then set the body
           errortype=>string,    then both will be in the <message/>
           error=>string)        tag.  For valid settings read the
                                 specific Set functions below.

SetTo(string) - sets the to attribute.  Must be a valid Jabber Identifier 
                or the server will return an error message.
                (ie.  jabber:bob@jabber.org/Silent Bob, etc...)

SetType(string) - sets the type attribute.  Valid settings are:

                  normal         defines a normal message
                  chat           defines a chat style message
                  groupchat      defines a chatroom message

SetSubject(string) - sets the subject of the <message/>.

SetBody(string) - sets the body of the <message/>.

SetThread(string) - sets the thread of the <message/>.  You should
                    copy this out of the message being replied to so
                    that the thread is maintained.

SetPriority(integer) - sets the priority of this <message/>.  The 
                       higher the priority the more likely the client
                       will deliver the message, even if the user has
                       specified no messages.

SetErrorType(string) - sets the error type of the <message/>.

SetError(string) - sets the error string of the <message/>.

NewX(string) - creates a new Net::Jabber::X object with the namespace
               in the string.  In order for this function to work with
               a custom namespace, you must define and register that  
               namespace with the X module.  For more information
               please read the documentation for Net::Jabber::X.

AUTHOR

By Ryan Eatmon in December of 1999 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.