Changeset 7869e48 for perl/modules/Jabber/lib/Net/XMPP/Protocol.pm
- Timestamp:
- Jan 12, 2013, 1:43:13 PM (11 years ago)
- Children:
- e3a0d71, 4485285
- Parents:
- 4626016
- git-author:
- Jason Gross <jgross@mit.edu> (01/12/13 13:13:18)
- git-committer:
- Jason Gross <jgross@mit.edu> (01/12/13 13:43:13)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/modules/Jabber/lib/Net/XMPP/Protocol.pm
ra8c55b5 r7869e48 58 58 comes back. You can optionally specify a timeout so that 59 59 you do not block forever. 60 60 61 61 nonblock - send the packet with an ID, but then return that id and 62 62 control to the master program. Net::XMPP is still … … 69 69 combined with the XPath function because you can register 70 70 a one shot function tied to the id you get back. 71 71 72 72 73 73 =head2 Basic Functions … … 234 234 groups=>["foo"] 235 235 ); 236 236 237 237 $Con->RosterDBRemove("bob\@jabber.org"); 238 238 $Con->RosterDBRemove(Net::XMPP::JID); … … 244 244 245 245 @jids = $Con->RosterDBJIDs(); 246 246 247 247 if ($Con->RosterDBGroupExists("foo")) { ... 248 248 249 249 @groups = $Con->RosterDBGroups(); 250 250 251 251 @jids = $Con->RosterDBGroupJIDs("foo"); 252 252 253 253 @jids = $Con->RosterDBNonGroupJIDs(); 254 254 255 255 %hash = $Con->RosterDBQuery("bob\@jabber.org"); 256 256 %hash = $Con->RosterDBQuery(Net::XMPP::JID); … … 340 340 then you must *NOT* specify a callback for 341 341 presence in the SetCallBacks function. 342 342 343 343 Net::XMPP defines a few default 344 344 callbacks for various types: 345 345 346 346 "subscribe" - 347 347 replies with subscribed 348 348 349 349 "unsubscribe" - 350 350 replies with unsubscribed 351 351 352 352 "subscribed" - 353 353 replies with subscribed 354 354 355 355 "unsubscribed" - 356 356 replies with unsubscribed 357 357 358 358 359 359 SetMessageCallBacks(type=>function, - sets the callback functions for … … 441 441 0 - Status ok, no data received. 442 442 undef - Status not ok, stop processing. 443 443 444 444 IMPORTANT: You need to check the output of every 445 445 Process. If you get an undef then the connection … … 684 684 the has returned by RosterParse above, and 685 685 is the actual hash, not a reference. 686 686 687 687 RosterDBRemove(jid) - Remove a JID from the roster DB. The JID is 688 688 either a string, or a Net::XMPP::JID object. … … 696 696 RosterDBJIDs() - returns a list of Net::XMPP::JID objects that 697 697 represents all of the JIDs in the DB. 698 698 699 699 RosterDBGroups() - returns the complete list of roster groups in the 700 700 roster. 701 701 702 702 RosterDBGroupExists(group) - return 1 if the group is a group in the 703 703 roster DB, undef otherwise. … … 706 706 that represents all of the JIDs in the 707 707 specified roster group. 708 708 709 709 RosterDBNonGroupJIDs() - returns a list of Net::XMPP::JID objects 710 710 that represents all of the JIDs not in a … … 720 720 the given key. The available keys are: 721 721 name, ask, subsrcription and groups 722 The JID is either a string, or a 722 The JID is either a string, or a 723 723 Net::XMPP::JID object. 724 724 … … 827 827 my $id; 828 828 my $tree; 829 829 830 830 if (ref($object) !~ /^Net::XMPP/) 831 831 { … … 884 884 } 885 885 } 886 886 887 887 return if $direct_pass; 888 888 } … … 1093 1093 ############################################################################### 1094 1094 sub SetXPathCallBacks 1095 { 1095 { 1096 1096 my $self = shift; 1097 1097 my (%xpaths) = @_; … … 1133 1133 ############################################################################### 1134 1134 sub SetDirectXPathCallBacks 1135 { 1135 { 1136 1136 my $self = shift; 1137 1137 my (%xpaths) = @_; … … 1538 1538 1539 1539 $self->{DEBUG}->Log4("PresenceDBParse: pres(",$presence->GetXML(),")"); 1540 1540 1541 1541 my $type = $presence->GetType(); 1542 1542 $type = "" unless defined($type); … … 1942 1942 &{$self->{CB}->{update}}() if exists($self->{CB}->{update}); 1943 1943 } 1944 1944 1945 1945 #------------------------------------------------------------------------- 1946 1946 # The loop finished... but was it done? … … 1951 1951 return( "system","SASL timed out authenticating"); 1952 1952 } 1953 1953 1954 1954 #------------------------------------------------------------------------- 1955 1955 # Ok, it was done... but did we auth? … … 1960 1960 return ( "error", $self->{STREAM}->SASLClientError($sid)); 1961 1961 } 1962 1962 1963 1963 #------------------------------------------------------------------------- 1964 1964 # Phew... Restart the <stream:stream> per XMPP … … 1967 1967 $self->{SESSION} = $self->{STREAM}->OpenStream($sid); 1968 1968 $sid = $self->{SESSION}->{id}; 1969 1969 1970 1970 $self->{DEBUG}->Log1("AuthSASL: We got a new session. sid($sid)"); 1971 1971 … … 2012 2012 $iq->SetIQ(type=>"set"); 2013 2013 my $bind = $iq->NewChild(&ConstXMLNS("xmpp-bind")); 2014 2014 2015 2015 if (defined($resource) && ($resource ne "")) 2016 2016 { … … 2037 2037 $iq->SetIQ(type=>"set"); 2038 2038 my $session = $iq->NewChild(&ConstXMLNS("xmpp-session")); 2039 2039 2040 2040 my $result = $self->SendAndReceiveWithID($iq); 2041 2041 } … … 2096 2096 my %args; 2097 2097 while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); } 2098 2098 2099 2099 my $iq = $self->_iq(); 2100 2100 $iq->SetIQ(type=>"get"); … … 2122 2122 my %args; 2123 2123 while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); } 2124 2124 2125 2125 my $iq = $self->_iq(); 2126 2126 $iq->SetIQ(type=>"set"); … … 2181 2181 return $id; 2182 2182 } 2183 2183 2184 2184 return $self->SendWithID($iq) if ($args{mode} eq "nonblock"); 2185 2185 … … 2443 2443 $jid = $jid->GetJID(); 2444 2444 } 2445 2445 2446 2446 return unless exists($self->{ROSTERDB}); 2447 2447 return unless exists($self->{ROSTERDB}->{JIDS}); … … 2611 2611 $jid = $jid->GetJID(); 2612 2612 } 2613 2613 2614 2614 return unless $self->RosterDBExists($jid); 2615 2615 if (defined($key)) … … 2619 2619 } 2620 2620 return %{$self->{ROSTERDB}->{JIDS}->{$jid}}; 2621 } 2621 } 2622 2622 2623 2623 … … 2645 2645 } 2646 2646 } 2647 2647 2648 2648 delete($self->{ROSTERDB}->{JIDS}->{$jid}); 2649 2649 } … … 2692 2692 $self->TLSClientFailure($node); 2693 2693 } 2694 2694 2695 2695 if ($tag eq "proceed") 2696 2696 { … … 2711 2711 $timeout = 120 unless defined($timeout); 2712 2712 $timeout = 120 if ($timeout eq ""); 2713 2713 2714 2714 $self->TLSSendStartTLS(); 2715 2715 … … 2751 2751 $self->{TLS}->{error} = $message; 2752 2752 } 2753 2753 2754 2754 $self->RemoveDirectXPathCallBacks('/[@xmlns="'.&ConstXMLNS("xmpp-tls").'"]'=>$TLS_CALLBACK); 2755 2755 } … … 2764 2764 { 2765 2765 my $self = shift; 2766 2766 2767 2767 return $self->{TLS}->{secure}; 2768 2768 } … … 2777 2777 { 2778 2778 my $self = shift; 2779 2779 2780 2780 return $self->{TLS}->{done}; 2781 2781 } … … 2790 2790 { 2791 2791 my $self = shift; 2792 2792 2793 2793 return $self->{TLS}->{error}; 2794 2794 } … … 2804 2804 my $self = shift; 2805 2805 my $node = shift; 2806 2806 2807 2807 my $type = &XML::Stream::XPath($node,"*/name()"); 2808 2808 … … 2821 2821 my $self = shift; 2822 2822 my $type = shift; 2823 2823 2824 2824 $self->Send("<failure xmlns='".&ConstXMLNS('xmpp-tls')."'><${type}/></failure>"); 2825 2825 } … … 2880 2880 $self->SASLAnswerChallenge($node); 2881 2881 } 2882 2882 2883 2883 if ($tag eq "failure") 2884 2884 { 2885 2885 $self->SASLClientFailure($node); 2886 2886 } 2887 2887 2888 2888 if ($tag eq "success") 2889 2889 { … … 2906 2906 my $challenge64 = &XML::Stream::XPath($node,"text()"); 2907 2907 my $challenge = MIME::Base64::decode_base64($challenge64); 2908 2908 2909 2909 my $response = $self->SASLGetClient()->client_step($challenge); 2910 2910 … … 2929 2929 2930 2930 return unless defined($mechanisms); 2931 2931 2932 2932 my $sasl = new Authen::SASL(mechanism=>join(" ",@{$mechanisms}), 2933 2933 callback=>{ user => $username, … … 2954 2954 { 2955 2955 my $self = shift; 2956 2956 2957 2957 return $self->{SASL}->{authed}; 2958 2958 } … … 2967 2967 { 2968 2968 my $self = shift; 2969 2969 2970 2970 return $self->{SASL}->{done}; 2971 2971 } … … 2980 2980 { 2981 2981 my $self = shift; 2982 2982 2983 2983 return $self->{SASL}->{error}; 2984 2984 } … … 2994 2994 my $self = shift; 2995 2995 my $node = shift; 2996 2996 2997 2997 my $type = &XML::Stream::XPath($node,"*/name()"); 2998 2998 … … 3011 3011 my $self = shift; 3012 3012 my $node = shift; 3013 3013 3014 3014 $self->{SASL}->{authed} = 1; 3015 3015 $self->{SASL}->{done} = 1; … … 3027 3027 { 3028 3028 my $self = shift; 3029 3029 3030 3030 return $self->{SASL}->{client}; 3031 3031 } … … 3068 3068 my $self = shift; 3069 3069 my $type = shift; 3070 3070 3071 3071 $self->Send("<failure xmlns='".&ConstXMLNS('xmpp-sasl')."'><${type}/></failure>"); 3072 3072 } … … 3232 3232 } 3233 3233 3234 3234 3235 3235 ############################################################################## 3236 3236 # … … 3309 3309 { 3310 3310 my $const = shift; 3311 3311 3312 3312 return $XMLNS{$const}; 3313 3313 }
Note: See TracChangeset
for help on using the changeset viewer.