Hi Bernd,
don't hesitate to commit directly.
anyways, thx for the patch ;)
Gerolf
On Fri, May 2, 2008 at 9:11 PM, Bernd Fondermann <[EMAIL PROTECTED]>
wrote:
> Bernd Fondermann wrote:
>
> > Gerolf Seitz wrote:
> >
> > > heya,
> > >
> > > i just committed my first take on handling subscription
> > > requests/approvals/cancellations
> > > and unsubscriptions.
> > > there are a lot of TODOs in there regarding persistance and
> > > determining the
> > > correct
> > > set of resources a stanza needs to be relayed to.
> > >
> > > until now, i used the RFC3921bis-04 version as a reference, as it's
> > > nicer to
> > > read...
> > >
> > > i plan to revise it to reflect the conformance to the original
> > > RFC3921.
> > >
> > > except of the TODOs, the basic handling described in RFC3921bis-04#3
> > > should be finished.
> > >
> >
> > I cannot await further presence commits! :-)
> >
> > A quick test reveiled that some clients send 'id' attributes on presence
> > stanzas and some do send inner elements (which is allowed as far as I
> > understand it).
> >
>
> Hi Gerolf,
>
> I had to put my hands on this. Now it is working better for the clients I
> use (Smack & Coccinella).
>
> Since you are probably working on this or already fixed it locally, here
> is my patch per email:
>
> Index:
> src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/PresenceHandler.java
> ===================================================================
> ---
> src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/PresenceHandler.java
> (revision 652621)
> +++
> src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/PresenceHandler.java
> Fri May 02 20:56:31 CEST 2008
> @@ -34,6 +34,7 @@
> import org.apache.vysper.xmpp.stanza.Stanza;
> import org.apache.vysper.xmpp.stanza.StanzaBuilder;
> import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
> +import org.apache.vysper.xmpp.stanza.XMPPCoreStanzaVerifier;
> import org.apache.vysper.xmpp.xmlfragment.XMLElementVerifier;
>
> /**
> @@ -55,16 +56,17 @@
> // or in case of multiple resources, use the from attribute
> or return an
> // error if the from attribute is not present.
> Entity initiatingEntity =
> sessionContext.getInitiatingEntity();
> - XMLElementVerifier verifier = stanza.getVerifier();
> + XMPPCoreStanzaVerifier verifier = stanza.getCoreVerifier();
>
> - int nrOfAttributes = stanza.getAttributes().size();
> - if ((nrOfAttributes == 0 ||
> verifier.onlyAttributesPresent("from"))
> - && verifier.subElementsPresentExact(0)) {
> + boolean hasFrom = verifier.attributePresent("from");
> + boolean hasTo = verifier.attributePresent("to");
> + boolean hasType = verifier.attributePresent("type");
> +
> + if (!hasTo && !hasType) {
> // RFC3921bis-04#4.2.2 Initial Presence
> handleOutboundInitialPresence(stanza,
> sessionContext,
> initiatingEntity);
> - } else if (verifier.onlyAttributesPresent("type", "to")
> - && sessionContext.isServerToServer() ==
> false) {
> + } else if (hasType && hasTo && !hasFrom &&
> !sessionContext.isServerToServer()) {
> // this is an outbound subscription
> // request/approval/cancellation/unsubscription
> // stamp it with the bare JID of the user
> @@ -88,10 +90,10 @@
>
> handleOutboundSubscriptionCancellation(stampedStanza,
> sessionContext);
> }
> - } else if (verifier.onlyAttributesPresent("from", "to")) {
> + } else if (hasFrom && hasTo && !hasType) {
> // RFC3921bis-04#4.2.3
> handleInboundInitialPresence(stanza,
> sessionContext);
> - } else if (verifier.onlyAttributesPresent("type", "to",
> "from")) {
> + } else if (hasFrom && hasTo && hasType) {
> String type = stanza.getType();
> if ("subscribe".equals(type)) {
> // RFC3921bis-04#3.1.3
> @@ -109,7 +111,7 @@
>
> }
>
> - } else if (verifier.allAttributesPresent("from", "to")) {
> + } else if (hasFrom && hasTo) {
>
>
> }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>