YamingPeng100 / asmack

Automatically exported from code.google.com/p/asmack
Other
0 stars 0 forks source link

Not parsing vCard correctly #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello, it seems that aSmack can't parse vCard package well.

aSmack version: 2010.05.07
Android version: 1.5 (emulator)

XMPP Server: chat.facebook.com

My Java code:
---------------------------------------------
public VCard getVCard(String user) {
  VCard vcard = new VCard();
  try {
    vcard.load(this.connection, user);
  } catch (XMPPException e) {
    Log.e(LOG_TAG, e.getMessage());
  }
  return vcard;
}

...

VCard vcard = getVCard("uXXXX@chat.facebook.com");
Log.d(LOG_TAG, vcard.toXML());

---------------------------------------------

From the attached log you can see that the vCard package is received, also
with encoded avatar, but aSmack can't detect it ("No VCard for
uXXXX@chat.facebook.com").

Original issue reported on code.google.com by brun...@gmail.com on 11 May 2010 at 4:16

Attachments:

GoogleCodeExporter commented 9 years ago
The sysout is caused by
http://github.com/rtreffer/smack/blob/master/source/org/jivesoftware/smackx/pack
et/VCard.java#L540

You ran into a ClassCastException on
result = (VCard) 
collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

This means that the collector received an response but couldn't build a 
package. A
common symptom for a missing PacketExtension. "vCard" in the "vcard-temp" 
namespace
has to be associated with a vCard-parser.

https://svn.igniterealtime.org/svn/repos/smack/trunk/build/resources/META-INF/sm
ack.providers
    <iqProvider>
        <elementName>vCard</elementName>
        <namespace>vcard-temp</namespace>
        <className>org.jivesoftware.smackx.provider.VCardProvider</className> 
    </iqProvider>

In code:
ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new
org.jivesoftware.smackx.provider.VCardProvider());

Have fun!

Original comment by rtreffer@gmail.com on 11 May 2010 at 10:46

GoogleCodeExporter commented 9 years ago
Set do DONE because I think it's that problem. please reopen and provide more
information if I'm wrong.

Original comment by rtreffer@gmail.com on 12 May 2010 at 6:42

GoogleCodeExporter commented 9 years ago
Thank you, that solved the issue :)
I think that this suggestion should be added to the javadoc of the VCard class.
Bye!

Original comment by brun...@gmail.com on 12 May 2010 at 8:47

GoogleCodeExporter commented 9 years ago
Please help me, i have the same issue, but inserting line

ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new  
org.jivesoftware.smackx.provider.VCardProvider());

nothing changes. Where should I put this string,before connection.connnect() or 
just before vCard.load(connection) ???
thanks in advance!

Original comment by irapha...@gmail.com on 19 Sep 2010 at 1:37

GoogleCodeExporter commented 9 years ago
Im unable to get Friends profile picture using this.. can anyone please list 
out the steps what to do ?

I am getting same error as was mentioned above.

Original comment by vdkhakhk...@gmail.com on 27 Dec 2010 at 1:26

GoogleCodeExporter commented 9 years ago
I met the same issue which was resolved by adding the VCardProvider. Thank you 
rtreffer!

Original comment by zfla...@gmail.com on 3 Mar 2011 at 1:41

GoogleCodeExporter commented 9 years ago
When I call vcard.getAvatar, the resulting array is not a picture of the array. 
How to get friends pictures? Please help,Thanks.

Original comment by azhan...@gmail.com on 17 May 2011 at 8:05

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
@rtreffer@gmail.com Thanks a lot.

It works pretty well when I added

ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new
org.jivesoftware.smackx.provider.VCardProvider());

before

vcard.load(this.connection, user);

Original comment by Ali.Nou...@gmail.com on 15 Dec 2011 at 7:57

GoogleCodeExporter commented 9 years ago
I used the code 
ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new
org.jivesoftware.smackx.provider.VCardProvider());

but it still doesn't work, any help?

Original comment by david.to...@gmail.com on 30 May 2013 at 10:47

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Adding the IQProvider DOESN'T work for me too.
ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new
org.jivesoftware.smackx.provider.VCardProvider());

I'm getting this in logcat:
SENT (1102292544): <iq id="2hh9b-8" from="XXXX@XXXX.com/Smack" 
type="get"><vCard xmlns='vcard-temp'/></iq>

RCV  (1102292544): <iq id='2hh9b-8' type='error' 
to='XXXX@XXXX.com/Smack'><error type='cancel'><item-not-found 
xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>

I/System.out(14075): No VCard for XXXX@XXXX.com/Smack

E/AndroidRuntime(14075): java.lang.NullPointerException: expected receiver of 
type org.jivesoftware.smackx.packet.VCard, but got null

Original comment by abey...@gmail.com on 5 Aug 2013 at 12:32

GoogleCodeExporter commented 9 years ago
Hi I am using 'asmack:asmack:8-4.0.2' and while loading the vcard with null 
Avatar it crashes the App with following error 
 java.lang.ClassCastException: org.jivesoftware.smack.util.PacketParserUtils$2 cannot be cast to org.jivesoftware.smackx.vcardtemp.packet.VCard
            at org.jivesoftware.smackx.vcardtemp.packet.VCard.doLoad(VCard.java:560)
            at org.jivesoftware.smackx.vcardtemp.packet.VCard.load(VCard.java:542)

Although the same App with no changes in it works fine when Avatar is set to 
something.
Don't know how to fix above solution doesn't work.
Thanks

Original comment by puspendu...@gmail.com on 9 Oct 2014 at 5:12

GoogleCodeExporter commented 9 years ago
any one with a solution for this : 
 java.lang.ClassCastException: org.jivesoftware.smack.util.PacketParserUtils$2 cannot be cast to org.jivesoftware.smackx.vcardtemp.packet.VCard
            at org.jivesoftware.smackx.vcardtemp.packet.VCard.doLoad(VCard.java:560)
            at org.jivesoftware.smackx.vcardtemp.packet.VCard.load(VCard.java:542)

Original comment by adit....@cognitiveclouds.com on 7 Nov 2014 at 7:23

GoogleCodeExporter commented 9 years ago
I just Got it worked when i changed my code here

ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new 
VCardProvider()); to ProviderManager.getInstance().addIQProvider("vCard", 
"vcard-temp:x:update", new VCardProvider());

Original comment by ndabhish...@gmail.com on 9 Feb 2015 at 6:52