Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
Huntsman #1
Member since Apr 2016 · 42 posts
Group memberships: Members
Show profile · Link to this post
Subject: Problem in IQ grabber
Hello AG,
im facing a problem. i am creating a simple jabber app. i just want to add a blocked contact list grabbing option. but i can't grab the iq. here is my code.

  1.    Private Sub GetBlockList()
  2.         On Error Resume Next
  3.         Dim e As New client.IQ(IqType.get)
  4.         e.Id = "BH_BlockList"
  5.         e.To = New Jid(x.Server)
  6.         Dim el As New Element("blocklist")
  7.         el.SetAttribute("xmlns", "urn:xmpp:blocking")
  8.         e.Query = el
  9.  
  10.         Dim iqs As New IqGrabber(x)
  11.         iqs.SendIq(e, New IqCB(AddressOf OnReadIQ))
  12.     End Sub
  13.  
  14.     Private Sub OnReadIQ(ByVal sender As Object, ByVal iq As client.IQ, ByVal data As Object)
  15.         On Error Resume Next
  16.         If iq.Type = IqType.result Then
  17.             Dim list As ElementList = TryCast(iq, Element).SelectElements("item")
  18.             If list.Count = 0 Then
  19.                 list.Clear()
  20.             End If
  21.             For Each item As Element In list
  22.                 ListBox1.Items.Add(item.GetAttribute("jid"))
  23.             Next
  24.         End If
  25.     End Sub


and here is the return xml

  1. [WRITE]  <iq type="get" id="BH_BlockList" to="nimbuzz.com"><blocklist xmlns="urn:xmpp:blocking" /></iq>
  2.  
  3. [READ]  <iq xmlns="jabber:client" to="user@nimbuzz.com/987812244" id="BH_BlockList" type="result" from="nimbuzz.com"><blocklist xmlns="urn:xmpp:blocking"><item jid="zicko2000@nimbuzz.com" /><item jid="fnpfdfnpfd2fnpfdfnpfd8@nimbuzz.com" /><item jid="whrwnwhrwn5whrwnwhrwn4@nimbuzz.com" /><item jid="nybwrnybwr8nybwrnybwr8@nimbuzz.com" /><item jid="wyrwgwyrwg9wyrwgwyrwg3@nimbuzz.com" /><item jid="rbfpxrbfpx3rbfpxrbfpx9@nimbuzz.com" /><item jid="kcwpwkcwpw5kcwpwkcwpw7@nimbuzz.com" /><item jid="bwgkrbwgkr4bwgkrbwgkr4@nimbuzz.com" /><item jid="kebghkebgh6kebghkebgh4@nimbuzz.com" /><item jid="xermgxermg4xermgxermg4@nimbuzz.com" /><item jid="nxwdnnxwdn0nxwdnnxwdn7@nimbuzz.com" /><item jid="mxrmemxrme3mxrmemxrme3@nimbuzz.com" /><item jid="gwcrkgwcrk6gwcrkgwcrk5@nimbuzz.com" /><item jid="knhbpknhbp6knhbpknhbp5@nimbuzz.com" /><item jid="xppdexppde1xppdexppde7@nimbuzz.com" /><item jid="hdwcchdwcc7hdwcchdwcc7@nimbuzz.com" /><item jid="xgghpxgghp1xgghpxgghp7@nimbuzz.com" /><item jid="nncwhnncwh5nncwhnncwh9@nimbuzz.com" /><item jid="hgfwbhgfwb8hgfwbhgfwb6@nimbuzz.com" /><item jid="gybfggybfg8gybfggybfg4@nimbuzz.com" /><item jid="ywrdfywrdf4ywrdfywrdf1@nimbuzz.com" /><item jid="cpwercpwer0cpwercpwer1@nimbuzz.com" /><item jid="mwcgwmwcgw2mwcgwmwcgw9@nimbuzz.com" /><item jid="gwrkfgwrkf6gwrkfgwrkf4@nimbuzz.com" /><item jid="cnwnbcnwnb8cnwnbcnwnb6@nimbuzz.com" /><item jid="nfpwrnfpwr1nfpwrnfpwr4@nimbuzz.com" /><item jid="ykrpxykrpx9ykrpxykrpx5@nimbuzz.com" /><item jid="pgwxppgwxp2pgwxppgwxp5@nimbuzz.com" /><item jid="rdhbprdhbp8rdhbprdhbp1@nimbuzz.com" /><item jid="yycffyycff0yycffyycff3@nimbuzz.com" /><item jid="xkfexxkfex8xkfexxkfex5@nimbuzz.com" /><item jid="mpekrmpekr9mpekrmpekr10@nimbuzz.com" /><item jid="krgdfkrgdf7krgdfkrgdf10@nimbuzz.com" /><item jid="cfhxfcfhxf8cfhxfcfhxf5@nimbuzz.com" /></blocklist></iq>

but i can't get the blocked ids in ListBox1 :( . please help
This post was edited 2 times, last on 2016-04-14, 11:16 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The Xml tree is the following:

- iq
   - blocklist
      - item
      - item
      - item

you would have to select blocklist from iq first, and then your items from blocklist.

I also would suggest that you study our code and see how we build the protocol class and build the blocking classes the same way.

Alex
Avatar
Huntsman #3
Member since Apr 2016 · 42 posts
Group memberships: Members
Show profile · Link to this post
hello alex,
can you please tell me how to select blocklist from IQ.
Avatar
Alex #4
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you should write a custom Element class for it and register it in the factory. Then you can just select the Element by its Type.

Alex
Avatar
Huntsman #5
Member since Apr 2016 · 42 posts
Group memberships: Members
Show profile · Link to this post
Sir, can you please show me a demo code to how to set and add the custum element beacause iam begginer in agsxmpp library.  :-D   :rolleyes:
Avatar
Huntsman #6
Member since Apr 2016 · 42 posts
Group memberships: Members
Show profile · Link to this post
      public Element BlockContactsQuery
        {
            get
            {
                return this.SelectSingleElement("blocklist");
            }
            set
            {
                if (value != null)
                    ReplaceChild(value);
                else
                    RemoveTag("blocklist");
            }
        }


finally i got it sir. thank you very much for your effort. << Ags Rocks !!. >>
Avatar
Alex #7
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
great to hear that you got it working.
See also the attached document for a small tutorial on custom Elements.

Alex
The author has attached one file to this post:
creating_own_packet_types.pdf 161.2 kBytes
You have no permission to open this file.
Avatar
Huntsman #8
Member since Apr 2016 · 42 posts
Group memberships: Members
Show profile · Link to this post
Thank you very much, sir.
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 RSS