Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Page:  1  2  next
Avatar
deepak #1
Member since Dec 2005 · 26 posts
Group memberships: Members
Show profile · Link to this post
Subject: User Search
How can we add User Search to Miniclient ?
Avatar
Alex #2
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

JEP-0055 should be used for search. You will find it here:
http://www.jabber.org/jeps/jep-0055.html
Some servers still use the old Jabber Search. So it depends on your server. But both is supported by agsXMPP.

Alex
Avatar
deepak #3
Member since Dec 2005 · 26 posts
Group memberships: Members
Show profile · Link to this post
How to use JEPs. I am not talking only about JEP-0055 but any JEP. I always stuck on this.

Thanks for ur reply.
Avatar
Alex #4
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi deepak,

JEPS are extension protocols to the Core XMPP protocol. The most common Jeps are already implemented in agsXMPP. If you need one that we haven't integreated yet, you could do this yourself easily with the base classes in agsXMPP.

Alex
Avatar
Goofster #5
Member since Feb 2006 · 3 posts
Group memberships: Members
Show profile · Link to this post
Hi,

I think deepak and I share the same problem. I looked at the JEP and I understand the xmpp syntax, but I'm stuck trying to create the right searchrequest using agsXMPP. Can you give me a small example how to easilly search for a user?.

Roel
Avatar
Alex #6
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

you need a server with search support. There are different ways to implement a search. First you have to discover the search gateway of your server using disco. Then you send a SearchIq of type=get to this Jid (here users.jabber.org)

  1. SearchIq sIq = new SearchIq();
  2. sIq.To = new Jid('users.jabber.org');
  3. sIq.Type = IqType.get;
  4. xmpp_con.Send(sIq);

  1. <iq id='agsXMPP_1' to='users.jabber.org' type='get'><query xmlns='jabber:iq:search'/></iq>

The server will send you the supported search fields:

  1. <iq xml:lang='en' type='result' to='gnauck@myjabber.net/Exodus' id='agsXMPP_1' from='users.jabber.org'><query xmlns='jabber:iq:search'><instructions>Find a contact by entering the search criteria in the given fields. Note: Each field supports wild card searches (%)</instructions><first/><last/><nick/><email/></query></iq>

Fill the search fields and send the query back to the server (type=set). Here we search users with the nickname Alex.

  1. <iq id='agsXMPP_2' to='users.jabber.org' type='set'><query xmlns='jabber:iq:search'><nick>Alex</nick></query></iq>

Now the server returns the search results:

  1. <iq type='result' to='gnauck@myjabber.net/Exodus' id='jcl_72' from='users.jabber.org'><query xmlns='jabber:iq:search'><item jid='*panther*@jabber.org'><first/><last/><nick/><email/></item><item jid='101497@jabber.org'><first/><last/><nick>Alex</nick><email>chao.alex@iac.com.tw</email></item><item jid='101596@jabber.org'><first/><last/><nick>alex</nick><email>alexlintw@msn.com</email></item><item jid='101835@jabber.org'><first/><last/><nick>ALEX</nick><email>wei1212@ms28.hinet.net</email></item><item jid='~!alex!~@jabber.od.ua'><first/><last/><nick>Alex</nick><email/></item></query></iq>

Display the searchItem in a Listview or another control.

Alex
This post was edited on 2015-07-29, 12:03 by Alex.
Avatar
preky #7
Member since Jan 2006 · 17 posts
Group memberships: Members
Show profile · Link to this post
Subject: In other words..
Can you please specify events to use in that process or this calls aren't async?

After investigation i'm using XmppCon_OnIq event to get first search call result...but recieving error...investigating that error...

  1. SEND: <iq xmlns='jabber:client' id='agsXMPP_6' to='users.osiris' type='get'><query xmlns='jabber:iq:search' /></iq>
  2. RECV: <iq xmlns='jabber:client' from='users.osiris' id='agsXMPP_6' to='preky@osiris/MiniClient' type='error'><query xmlns='jabber:iq:search' /><error code='404' type='cancel'><remote-server-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' /></error></iq>

now the thing that's funny is that users directory in Miranda is also set as 'users.osiris' but in miranda i'm getting results and through MiniClient i'm recv xml above. Any Idea?

Ok, users shouldn't be in the code you have posted, but the name of the server I presume but in that way i'm rcv this:

  1. SEND: <iq xmlns='jabber:client' id='agsXMPP_6' to='osiris' type='get'><query xmlns='jabber:iq:search' /></iq>
  2. RECV: <iq xmlns='jabber:client' from='osiris' id='agsXMPP_6' to='preky@osiris/MiniClient' type='error'><query xmlns='jabber:iq:search' /><error code='501' type='cancel'><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' /></error></iq>

so i presume that server installed deosn't support JEP-0055 am I right?

Hmm, actually I found the right answer. Search shouldn't be send to 'users.server' but to 'search.server'.
After that i geting response from server.

In OnIq event method using this...
  1. if (query.GetType() == typeof(agsXMPP.protocol.iq.search.Search))
  2. {
  3.     agsXMPP.protocol.iq.search.Search search = query as agsXMPP.protocol.iq.search.Search;
  4.     if (iq.Type == IqType.error)
  5.     {
  6.         MessageBox.Show(query.InnerXml);
  7.     }
  8.     else
  9.     {
  10.         //IqType.result
  11.         if (search.Instructions.Length == 0)
  12.         {
  13.             agsXMPP.Xml.Dom.NodeList list = search.GetItems;
  14.             foreach(agsXMPP.Xml.Dom.Node node in list)
  15.             {
  16.                      ....
  17.             }
  18.         }
  19.     }
  20. }
Preky
This post was edited on 2015-07-29, 12:05 by Alex.
Avatar
preky #8
Member since Jan 2006 · 17 posts
Group memberships: Members
Show profile · Link to this post
Subject: SearchItem cast
in documentation i haven't found how to...
cast to SearchItem. In the code below i'm trying to cast but without success.
  1. agsXMPP.protocol.iq.search.Search search = query as agsXMPP.protocol.iq.search.Search;
  2. if (iq.Type == IqType.error)
  3. {
  4.     MessageBox.Show(query.InnerXml);
  5. }
  6. else
  7. {
  8.     //IqType.result
  9.     if (search.Instructions == null || search.Instructions.Length == 0)
  10.     {
  11.         agsXMPP.Xml.Dom.NodeList list = search.GetItems;
  12.         ArrayList list2 = new ArrayList();
  13.         foreach(agsXMPP.Xml.Dom.Node node in list)
  14.         {
  15.             agsXMPP.Xml.Dom.Element element = (agsXMPP.Xml.Dom.Element)node;
  16. (CAST error ->)        agsXMPP.protocol.iq.search.SearchItem item = (agsXMPP.protocol.iq.search.SearchItem)element;
  17.             if (item != null)
  18.                 list2.Add(item);
  19.                
  20.         }
  21.     }
  22. }

getting invalid cast error?

Please, tell me what is wrong.THX!
Preky
This post was edited 2 times, last on 2015-07-29, 12:05 by Alex.
Avatar
Alex #9
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi Preky,

use the IqGrabber when sending your Query. In the IqGrabber you can define a callback for the result. In The MiniClient sample there are lots of samples how to use the IqGrabber class.
Cast the Query result to a search object (Search.cs) and call GetItems to get a list of the items in the result.
You dont have to parse the XML yourself.

Alex
Avatar
Alex #10
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
try this:
  1. agsXMPP.protocol.iq.search.Search search = query as agsXMPP.protocol.iq.search.Search;
  2. if (iq.Type == IqType.error)
  3. {
  4.  MessageBox.Show(query.InnerXml);
  5. }
  6. else
  7. {
  8.  //IqType.result
  9.  if (search.Instructions == null || search.Instructions.Length == 0)
  10.  {
  11.   agsXMPP.Xml.Dom.NodeList list = search.GetItems;
  12.   foreach(SearchItem sItem in list)
  13.   {
  14.    Console.WriteLine(sItem.ToString());
  15.   }
  16. }

Alex
This post was edited on 2015-07-29, 12:05 by Alex.
Avatar
preky #11
Member since Jan 2006 · 17 posts
Group memberships: Members
Show profile · Link to this post
That was the first foreach i have wrote and also was getting Specified cast error. Any idea?

on the other hand I'm running on NET1.1 maybe that's the problem?

that's stream content

  1. RECV: <iq xmlns=&quot;jabber:client&quot; from=&quot;search.osiris&quot; id=&quot;agsXMPP_5&quot; to=&quot;preky@osiris/MiniClient&quot; type=&quot;result&quot;><query xmlns=&quot;jabber:iq:search&quot;><item jid=&quot;preky@osiris&quot;><nick /><email> </email></item><item jid=&quot;preky1@osiris&quot;><nick /><email> </email></item><item jid=&quot;preky2@osiris&quot;><nick /><email> </email></item><item jid=&quot;preky3@osiris&quot;><nick /><email> </email></item></query></iq>

so empty stream is not the problem.
Thx for help and fast reply!
Preky
This post was edited on 2015-07-29, 12:06 by Alex.
Avatar
Alex #12
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
This sample does no cast at all at the position you had a cast error. So there could be no invalid cast exception. If you post us a full working sample we will take a look at the code.

Alex
Avatar
Alex #13
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Are you using the latest code of agsXMPP? Is Seach.cs and SearchItem.cs registered in ElementFactory.cs?

Alex
Avatar
preky #14
Member since Jan 2006 · 17 posts
Group memberships: Members
Show profile · Link to this post
I have just send you email.
Well the version I have is 0.71 and I have downloaded it in Friday.

It's urgent for me to solve the problem in native way, so if you could please assist me to solve this as soon as possible.

Thx!

P.S. GetItems property is returning agsXMPP.Xml.Dom.NodeList with agsXMPP.Xml.Dom.Element items I haven't yet looked into framework but shouldn't elements be of SearchItem type?
Preky
This post was edited on 2006-02-13, 14:20 by Unknown user.
Avatar
Goofster #15
Member since Feb 2006 · 3 posts
Group memberships: Members
Show profile · Link to this post
I had the missing searchItem problem too last week. The searchitem class is only in the svn repository, not in 0.71.

Roel
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:
Page:  1  2  next
Forum: agsXMPP RSS