<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1126" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Rebbaj,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I found a segment of code in my files listed
in following, and </FONT></DIV>
<DIV><FONT face=Arial size=2>you can see that I am using "$iq->GetXML()" and
"$iq_result->GetXML()"</FONT></DIV>
<DIV><FONT face=Arial size=2>to check the IQ packet to be sent and the IQ packet
result. </FONT></DIV>
<DIV><FONT face=Arial size=2>As long as the format </FONT><FONT face=Arial
size=2>of XML is right, it should work. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>So, please check your XML before sending.
</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Good luck.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>-Yanming</DIV>
<DIV></FONT><FONT face=Arial size=2></FONT> </DIV><FONT face=Arial size=2>
<DIV> </DIV>
<DIV>...</DIV>
<DIV> </DIV>
<DIV> print "Connecting:
$username\@$server:$port/$resource\n";</DIV>
<DIV> </DIV>
<DIV> # initialize the Jabber client
object<BR># $Connection = new
Net::Jabber::Client(debuglevel=>2, debugfile=>"debug",
debugtime=>1);<BR> $Connection = new
Net::Jabber::Client;</DIV>
<DIV> </DIV>
<DIV> print ".\n";<BR> # try the connection
and get the status of it<BR> $status =
$Connection->Connect("hostname" =>
$server,<BR> "port" =>
$port);<BR> print ".\n";<BR> # If
something's wrong with the connection<BR> if
(!(defined($status))) <BR> {<BR> print "<br
/>ERROR: Jabber server is down or connection was not
allowed.\n";<BR> print "<br
/>($!)\n";<BR> <BR> &print_file("./jru-bottom.inc");<BR> exit(0);<BR>
}</DIV>
<DIV> </DIV>
<DIV> print ".\n";</DIV>
<DIV> </DIV>
<DIV> # Set callbacks for incoming info<BR>
$Connection->SetCallBacks("message" =>
\&InMessage,<BR> "presence" =>
\&InPresence,<BR> "iq" => \&InIQ);</DIV>
<DIV> </DIV>
<DIV> # Connect!<BR>
$Connection->Connect();<BR> print
".\n";<BR> # Try authorization<BR> @result =
$Connection->AuthSend("username" =>
$username,<BR> "password" =>
$password,<BR> "resource" =>
$resource);<BR> print ".\n";<BR> # If the
auth went awry<BR> if ($result[0] ne "ok")
<BR> {<BR> print "<br />ERROR: Authorization
failed: $result[0] - $result[1]\n<br
/>";<BR> exit(0);<BR> }<BR> print
".\n";<BR> print "<br />Logged in successfully to
$server:$port as $username...\n";</DIV>
<DIV> </DIV>
<DIV># print "<br />Getting your
roster...\n";<BR>#<BR># this step is important --- to behavior as a
regualr Jabber client. <BR>#<BR> %roster =
$Connection->RosterGet();</DIV>
<DIV> </DIV>
<DIV>### Start of Subscription ####</DIV>
<DIV> </DIV>
<DIV>print "<br />Sending
presence...\n";<BR>$Connection->PresenceSend();<BR>#$Connection->Process(1);</DIV>
<DIV> </DIV>
<DIV>my ($iq, $iq_query, $iq_result, my $from);<BR>#<BR>#<iq id="jcl_44"
to="<A href="mailto:1st@mla.lvj1">1st@mla.lvj1</A>"
type="set"><BR># <query
xmlns="jabber:iq:register"><BR># <nick>reminder</nick><BR># </query><BR>#</iq><BR>#</DIV>
<DIV> </DIV>
<DIV>$from = "$username\@$server/$resource";</DIV>
<DIV> </DIV>
<DIV>print "<br />from= $from\n";</DIV>
<DIV> </DIV>
<DIV>$iq = Net::Jabber::IQ->new();<BR>$iq->SetIQ(<BR> from
=> $from,<BR> type => 'set',<BR> to
=> $service_jid,<BR> id => 'jru_02',<BR> query
=> 'info'<BR>);</DIV>
<DIV> </DIV>
<DIV>$iq_query =
$iq->NewQuery("jabber:iq:register");<BR>$iq_query->SetNick($nick);</DIV>
<DIV> </DIV>
<DIV>print "<br />Sending iq...\n".$iq->GetXML()."\n";</DIV>
<DIV> </DIV>
<DIV>$iq_result = $Connection->SendAndReceiveWithID($iq, 1);<BR>#
Success<BR>if ($iq_result->GetType() eq
'result')<BR>{<BR> print "<br
/>";<BR> print
$iq_result->GetXML();<BR> print
"<br />\n";<BR>}<BR># Failure<BR>else<BR>{<BR> print "<br
/>Error: ", $iq_result->GetErrorCode(), " (", $iq_result->GetError(),
")\n";<BR># <BR># print
"<br />ERROR: IQ failed: $result[0] - $result[1]\n<br
/>";<BR># print "<br /><TEXTAREA NAME=RECV ROWS=10
COLS=70>\n";<BR># print
$result->toStr;<BR>#
print "</TEXTAREA><br />\n";<BR>#<BR> exit(0);<BR>}</DIV>
<DIV> </DIV>
<DIV>#$Connection->Process(1);</DIV>
<DIV> </DIV>
<DIV>##########################<BR>my $presence =
Net::Jabber::Presence->new();<BR>$presence->SetTo($service_jid);<BR>#$presence->SetFrom($from);<BR>$presence->SetType('subscribed');
</DIV>
<DIV> </DIV>
<DIV><BR>#while( $first_run &&
defined($Connection->Process()))<BR>print "<br />Sending
presence...\n".$presence->GetXML()."\n";<BR>$iq_result =
$Connection->SendAndReceiveWithID($presence, 1);</DIV>
<DIV> </DIV>
<DIV><BR>### End of Subscription ####</DIV>
<DIV> </DIV>
<DIV> # Should be all done, so why don't we disconnect?
Sounds like fun to me.. but fun to you? Could be. Give it a shot,
anyway...<BR> print "<br
/>Disconnecting...\n";<BR>#<BR> #$do_subscribe =
'';<BR> #$query->delete_all();<BR> #print
$query->start_multipart_form();<BR> #print
$query->end_form();<BR>#<BR>
$Connection->Disconnect();<BR> print "<br
/>Disconnected.\n";</DIV>
<DIV> </DIV>
<DIV># print "\n<script
type=\"text/javascript\">\n<!--\nfunction popUpLog() {\n newWindow =
window.open('', 'newWin',
'toolbar=no,location=no,scrollbars=yes,resizable=yes,width=300,height=300')\n\n
newWindow.document.write(\"<html><head><title>Jabber roster
utility Log</title></head><body bgcolor=ffffff
text=000000><b><font face=sans-serif><div align=left><br
/>", $log,
"</div></font></b></body></html>\")\n}\n -->\n
</script>";<BR># print "<br /><a href=\"\#\"
onmousedown=\"popUpLog(); return true;\">Click here</a> to view a log
of all users updated and all errors.\n<br /><br
/>";<BR>#<BR># print "<hr width=\"75%\"
noshade=\"noshade\" />";</DIV>
<DIV></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV style="FONT: 10pt arial">----- Original Message -----
<DIV style="BACKGROUND: #e4e4e4; font-color: black"><B>From:</B> <A
title=rebbaj2000@yahoo.co.uk href="mailto:rebbaj2000@yahoo.co.uk">rebbaj
rebbaj</A> </DIV>
<DIV><B>To:</B> <A title=jdev@jabber.org
href="mailto:jdev@jabber.org">jdev@jabber.org</A> </DIV>
<DIV><B>Sent:</B> Tuesday, January 07, 2003 5:39 PM</DIV>
<DIV><B>Subject:</B> Re: [JDEV] Proper use of Perl Net::Jabber calls</DIV></DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT
face=Arial size=2></FONT><BR></DIV>
<P>Thanks Yanming. I took a good long look at the code found at <A
href="http://www.jabberstudio.org/cgi-bin/viewcvs.cgi/*checkout*/netjabber/examples/client.pl?rev=1.4&content-type=text/plain">http://www.jabberstudio.org/cgi-bin/viewcvs.cgi/*checkout*/netjabber/examples/client.pl?rev=1.4&content-type=text/plain</A>
<P>What I still do not understand is why the $Connection->RosterGet(); call
does not result in all of the roster entries being sent back from the
server and hence triggering the sub InIQ routine. If I manually
enter the following XML "<iq type="get"><query
xmlns="jabber:iq:roster"/></iq>, I get all the entries back.
<P>The docs state "RosterGet() - sends an empty Net::Jabber::IQ::Roster tag to
the server so the server will send the Roster to the client."
<P>Any other ideas?
<P>Regards,
<P>Rebbaj
<P> <B><I>Yanming Xiao <xiao@legatovideo.com></I></B> wrote:
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">
<META content="MSHTML 6.00.2800.1126" name=GENERATOR>
<STYLE></STYLE>
<DIV><FONT face=Arial size=2>Rabbaj,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>It seems to me that you are using 2 different
packages. </FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>There is a function called "RosterGet()" in
Net::Jabber::Client. </FONT></DIV>
<DIV><FONT face=Arial size=2>find the sample code in:</FONT></DIV>
<DIV><FONT face=Arial size=2><A
href="http://jru.jabberstudio.org/">http://jru.jabberstudio.org/</A></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>-Yanming</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=rebbaj2000@yahoo.co.uk href="mailto:rebbaj2000@yahoo.co.uk">rebbaj
rebbaj</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=jdev@jabber.org
href="mailto:jdev@jabber.org">jdev@jabber.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, January 07, 2003 9:40
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [JDEV] Proper use of Perl
Net::Jabber calls</DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial
size=2></FONT><BR></DIV>
<P>Hello jabber people.</P>
<P>I am hoping that someone can help me out with how the Perl Net::Jabber
library should be used. Note that I am also somewhat new to perl so if
I get confused by some of the syntax, you will have to excuse me. The
examples in the Oreily book were rather helpful but I seem to be having
problems in calling and receiving IQ information.</P>
<P>Here is what I am trying to send and receive in XML:</P>
<P>SENT:<BR><iq id="jcl_9" type="get"><BR> <query
xmlns="jabber:iq:roster"/><BR></iq><BR><BR>RECV:<BR><iq <A
href="mailto:from='rebbaj@jabber.org/Perl'">from='rebbaj@jabber.org/Perl'</A>
id='jcl_9' type='result'><BR> <query
xmlns='jabber:iq:roster'><BR> <item <A
href="mailto:jid='rebbaj@jabber.com'">jid='rebbaj@jabber.com'</A>
name='rebbaj' subscription='both'/><BR> <item <A
href="mailto:jid='rebbaj2@jabber.com'">jid='rebbaj2@jabber.com'</A>
name='rebbaj2' subscription='both'/><BR>
</query><BR></iq></P>
<P>The code stub that I have written to do this is as follows. I
suspect that I have the flow a bit wrong and I am not using the optimal
calls to parse the resulting returned roster data... Any help would be
appreciated....</P>
<P>rebbaj</P>
<P>------------------------------------------------<BR>#!/usr/bin/perl<BR>use
Net::Jabber qw(Client);<BR>use strict;<BR>my
$c=Net::Jabber::Client->new();<BR>$c->Connect('hostname'=>
'jabber.org', 'port'=>5222);</P>
<P>$c->AuthSend('username'=>
'rebbaj',<BR> 'password'=>
'secret',<BR> 'resource'=> 'Perl');</P>
<P>$c->SetCallBacks('presence'=>
\&handle_presence);<BR>$c->SetCallBacks('iq'=>
\&handle_iq);<BR>$c->PresenceSend();<BR><BR>My $IQ = new
Net::Jabber::IQ();<BR>$IQ->NewQuery("jabber:iq:roster"); # Does
this actually make the IQ get request?$c->Send($IQ); # is this call
necessary?</P>
<P>print "involking process\n";<BR>$c->Process();</P>
<P><FONT face=Arial size=2></FONT> </P>
<P> </P>
<P><BR>$c->Disconnect;<BR>exit(0);</P>
<P>sub handle_presence {<BR> my ($sid, $presence) = @_;</P>
<P> my $show = $presence->GetShow() ||
'online';<BR> <BR> print "presence packet received
$show\n";<BR>}</P>
<P>sub handle_iq {<BR> my ($sid, $iq) = @_;</P>
<P> my $querytag = $iq->GetQuery();</P>
<P><BR> print "iq packet received $querytag\n";<BR>}</P>
<P>
<P><BR>
<HR SIZE=1>
<A
href="http://uk.yahoo.com/mail/tagline_xtra/?http://uk.docs.yahoo.com/mail_storage.html"><B><FONT
face=Arial size=2>With Yahoo! Mail you can get a bigger mailbox -- choose a
size that fits your needs</FONT></B></A><BR></BLOCKQUOTE></BLOCKQUOTE>
<P>
<P><BR>
<HR SIZE=1>
<A
href="http://uk.yahoo.com/mail/tagline_xtra/?http://uk.docs.yahoo.com/mail_storage.html"><B><FONT
face=Arial size=2>With Yahoo! Mail you can get a bigger mailbox -- choose a size
that fits your needs</FONT></B></A><BR></BODY></HTML>