[JDEV] Perl code sample needed...

rebbaj rebbaj rebbaj2000 at yahoo.co.uk
Mon Jan 27 18:44:22 CST 2003


Hmmmm

I seem to be making progress but I do not understand why:)  Perhaps someone can explain what is going on.  In the IQ callback, I can get the first item in the roster by referencing it as follows with the Net::Jabber 1.0028 pm release.  

my @query = $iq->GetQuery();
print ("name = ", $query[0]->GetItems->GetName(), "\n");
print ("JID = ", $query[0]->GetItems->GetJID(), "\n"); 
print ("Subscription = ", $query[0]->GetItems->GetSubscription(), "\n");
print ("Group = ", $query[0]->GetItems->GetGroup(), "\n");

How do I get the second item?  Using $query[1] does not do not as the array appears to have only one element although there are 10 items in the roster..  

What does the GetItem object do?  It is typed as a Master but I am not sure I understand what that means..

Any help is greatly appreciated as I get (slowly) through this learning curve.

Regards
 

 rebbaj rebbaj <rebbaj2000 at yahoo.co.uk> wrote:
Thanks Curtis, 
I have not seen any referenced to the RosterParse in Jabber::Net 1.0028.  It only seems to show up in the 1.0024 documentation.  Is there a way to do this using 1.0028? 
 Curtis Hawthorne <cghawthorne at yahoo.com> wrote: 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 wrote:
> 
> After some more testing, I got the impression that the
> following callback logic would work. Getting the 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
_______________________________________________
jdev mailing list
jdev at jabber.org
http://mailman.jabber.org/listinfo/jdev



---------------------------------
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs




---------------------------------
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.jabber.org/pipermail/jdev/attachments/20030128/2a5a95d4/attachment-0002.htm>


More information about the JDev mailing list