2

I am building a XMPP chat client app with eclipse, java and asmack. Using tutorials and many many google searches I managed to get the buddy list working, actual chatting also works fine. My problem is with searching for more buddies to add to my contacts list. The XML to send is exemplified here : http://xmpp.org/extensions/xep-0055.html My request is :

<iq
id="search123"
from="name3@webserv.xxx.com/name3"
to="search.xxx.zzz.com"
type="set" >
<query xmlns="jabber:iq:search" >
    <nick>
android
    </nick>
</query>
</iq>

the response I thought I was getting was/is this:

<iq
id="search123"
from="search.xxx.zzz.com"
to="name3@webserv.telebroad.com/Smack"
type="result" >
</iq>

But using connConfig.setDebuggerEnabled(true); (and an online Telnet Client) I managed to find out that the server IS actually working correctly and it's sending the requested results, but I'm just getting what you see above. I have been at this for 4 days and my self esteem is quite low :P Here is my code concerning the IQ request and response:

Packet asdf = new Packet() {
                    @Override
                    public String toXML() {
                        return    "<iq type='set'"+
                                " from='name3@webserv.xxx.com/name3'"+
                                " to='search.xxx.zzz.com'"+
                                " id='search2'"+
                                " xml:lang='en'>"+
                              " <query xmlns='jabber:iq:search'>"+
                                " <nick>Android</nick>"+
                              " </query>"+
                            " </iq>";
                    }
                };


ChatList.connection.sendPacket(asdf);
                Log.e("packet", "request = "+ asdf.toXML());
                PacketFilter filter = new IQTypeFilter(IQ.Type.RESULT);
                ChatList.connection.addPacketListener(new PacketListener() {
                    public void processPacket(Packet packet) {
                        IQ iq = (IQ)packet;


                        Log.e("response","incoming packet : "+ packet.toXML());
                        Log.e("response","incoming packet2 : "+ packet.toString());

                    }
                }, filter);  

I've tried lots of TypeFilters to no avail. I'm stumped!!

Bottom line:

1.request is being accepted correctly by server;

2.server response is correct(so says the debugger);

3.any response.toString or toXML prints out the type result XML from above(without the actual items after type='result'>.

4.I am about a week overdue on my final build for this app...help! :)

Sebek
  • 642
  • 8
  • 22

3 Answers3

1

Try adding

ProviderManager pm = ProviderManager.getInstance(); 
pm.addIQProvider( "query","jabber:iq:search",new UserSearch.Provider());
pm.addExtensionProvider("x","jabber:x:data", new DataFormProvider());

before establishing connection.

0

This spec is already implemented via the UserSearchManager. Try using that instead.

As for your own case, I would guess that you haven't registered an appropriate provider for this specific element and namespace (like org.jivesoftware.smackx.search.UserSearch$Provider). In a normal Java environment, this would already be registered, but you will have to code it yourself in Android.

Robin
  • 24,062
  • 5
  • 49
  • 58
  • Thank you Robin. My javadoc isn't working (i'm a noob) so you really pointed me in the right direction. I managed to retrieve the data I wanted. It's in a ReportedData data = usm.getSearchResults ...Now i just need to get it out of the this "data" variable :P. When i'm done i will edit my question to include the full code for the result. Hopefully saving someone the pain I had to go trough :P – Sebek Nov 09 '12 at 12:32
  • I'm still having problems with getting the data from the ReportedData variable. [link](http://stackoverflow.com/q/8213812/1688731) this is the closest thing I could find to an actual solution, but still not enough. Any ideas anyone? – Sebek Nov 16 '12 at 13:00
0

https://stackoverflow.com/a/14214622/1688731 This...just works!!!! I have no idea why. maybe Iterator iterator = row.getValues("jid"); does the trick. But everything else, I've tried a LOT of times!!

Community
  • 1
  • 1
Sebek
  • 642
  • 8
  • 22