[JDEV] Perl code sample needed...

Curtis Hawthorne cghawthorne at yahoo.com
Sun Jan 26 14:55:39 CST 2003


Rebbaj,

I think what you want is the RosterParse method in
Net::Jabber.  It returns a hash with all the information
you need.  For instance:

sub InIQ {
 my $sid = shift;
 my $iq = shift;

 my %rosterupdate = $iq->RosterParse($iq);

 foreach (keys %rosterupdate) {
  print "Name: ", $_->{name}, "\n";
  print "Subscription: ", $_->{subscription}, "\n";
  print "Ask: ", $_->{ask}, "\n";
  print "Groups: ", $_->{groups}, "\n";
 }
}

>From there you could turn it into an array if you wanted,
but I would think a hash would be easier to work with.

Curtis H.

--- rebbaj rebbaj <rebbaj2000 at yahoo.co.uk> wrote:
> 
> After some more testing, I got the impression that the
> following callback logic would work.  Getting the <item>s
> does not seem to work.  Has anybody ever made this work
> before?? 
> sub InIQ
> {
>  my $sid = shift;
>  my $iq = shift; 
>  my $id = $iq->GetID();
>  print "id = $id\n"; # works 
>  my $type = $iq->GetType();
>  print "type = $type\n"; #works 
>  my $xmlns = $iq->GetQueryXMLNS();
>  print "xmlns = $xmlns\n"; #works 
>  foreach my $query ($iq->GetQuery->GetItems) {
>   print ("JID = $query->GetItem()->GetJID\n"); # prints a
> hash
>   print ("Name = $query->GetItem()->GetName\n");  #
> prints a hash
>   print ("Subscription =
> $query->GetItem()->GetSubscription\n"); # prints a hash
>   print ("Group = $query->GetItem()->GetGroup[0]\n"); #
> prints a hash
>  }
> } 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the JDev mailing list