Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Avatar
tjabber #1
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
Subject: Setting default privacy list doesn't contain default element
I'm trying to set the default privacy list. The result looks like:

<iq xmlns="jabber:client" id="agsXMPP_5" type="set"><query xmlns="jabber:iq:privacy" /></iq>

And it should look something like:

<iq from='romeo@example.net/orchard' type='set' id='default1'>
<query xmlns='jabber:iq:privacy'>
  <default name='special'/>
</query>
</iq>

The from attribute and the default element are missing.

The code looks like:

  public void ChangeDefaultList(string name, IqCB cb, object cbArg)
        {
            PrivacyIq pIq = new PrivacyIq();

            pIq.Type = agsXMPP.protocol.client.IqType.set;
            pIq.Query.Default = new Default(name);

            SendStanza(pIq, cb, cbArg);
        }

When I trace through the pIq.Query.Default is being set to null so the AddChild just returns so the serialization to XML doesn't contain the default element. My C# isn't that sharp and embarrassingly, I just can't figure out what's happening in the different properties sets and gets.

Any ideas?
This post was edited 2 times, last on 2008-02-15, 01:12 by tjabber.
Avatar
Alex #2
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
sorry there was a bug/typo in Privacy.cs. I fixed it, new code is in SVN.

I changed the following property
  1. public Default Default
  2. {
  3.     get
  4.     {
  5.         return SelectSingleElement(typeof(Default)) as Default;
  6.     }
  7.     set
  8.     {
  9.         if (HasTag(typeof(Default)))
  10.             RemoveTag(typeof(Default));
  11.  
  12.         this.AddChild(value);
  13.     }
  14. }

You don't need from attributes on the main xmpp stanzas iq, message and presence. Because you are authenticated and the server knows from whom they are coming.

When the server forwards the stanzas it stamps the missing from attribute automatically. If you add a wrong from attribute to spoof packets the server will overwrite it or disconnect you. This is for security reason and SPAM protection.

Alex
Alexander Gnauck
AG-Software
Avatar
Alex #3
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #1
Quote by tjabber:
My C# isn't that sharp and embarrassingly, I just can't figure out what's happening in the different properties sets and gets.
we also speak VB ;-)
Alexander Gnauck
AG-Software
Avatar
tjabber #4
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #2
I should have figured that out. And you are correct about the from attribute. When I was sending the XML directly I thought it was the "from" that was causing the syntax error, but with default present the from doesn't seem to be necessary.

thanx

And Alex, can you please work on all the other software I use :-)
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP SDK Support RSS