Are VCards working on Smack? Any alternatives?

Hi, I have been having trouble getting VCards to work. Saving my own VCard seems to work fine, however when trying to retrieve the VCard for another user, I get this error:

XMPPError: feature-not-implemented - cancel

Are VCards currently operational or is it still unimplemented?

Are there alternatives to VCards? I would like to query the server for information on a particular user when another user wants to look at their profile.

Thank you

Please follow the instructions found at https://github.com/igniterealtime/Smack/wiki/How-to-ask-for-help-or-report-an-is sue when asking for help. Thank you.

Hey Flow, thanks for the reply and the debug information. Here is the information I’ve gathered:

I first save the VCard using this command:

VCard vCard = new VCard();
        VCardManager vCardManager = VCardManager.getInstanceFor(conn1);
        vCard.setFirstName("kir");
        vCard.setLastName("max");
        vCard.setNickName("KIR");
        vCard.setField("TITLE", "Mr");         try {
            vCard.save(conn1);
            Log.e(TAG, "Vcard saved");
        } catch (SmackException.NoResponseException e) {
            e.printStackTrace();
        } catch (XMPPException.XMPPErrorException e) {
            e.printStackTrace();
        } catch (SmackException.NotConnectedException e) {
            e.printStackTrace();
        }

Here is the debug trace:

SENT (0): <iq id='7W4lM-10' type='set'><vCard xmlns='vcard-temp'><N><FAMILY>max</FAMILY><GIVEN>kir</GIVEN></N><FN>kir max</FN><TITLE>Mr</TITLE><NICKNAME>KIR</NICKNAME></vCard></iq>
RECV (0): <iq from='ctest@example.com' to='ctest@example.com/Smack' id='7W4lM-7' type='result'><query xmlns='jabber:iq:roster'/></iq>
RECV (0): <presence from='ctest@example.com/Smack' to='ctest@example.com/Smack' xml:lang='en' id='7W4lM-8'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.igniterealtime.org/projects/smack' ver='NfJ3flI83zSdUDzCEICtbypursw='/></presence><iq from='ctest@example.com' to='ctest@example.com/Smack' id='7W4lM-10' type='result'/>

It seems to work fine.

Retrieving the vcard creates an error. In this case, I’m trying to retrieve my own vcard (I’ve tried with myself and other users):

VCardManager vCardManager = VCardManager.getInstanceFor(conn1);         boolean isSupported = false;
        try {
            vCardManager.isSupported(conn1.getUser());
            isSupported = true;
        } catch (SmackException.NoResponseException e) {
            e.printStackTrace();
        } catch (XMPPException.XMPPErrorException e) {
            e.printStackTrace();
        } catch (SmackException.NotConnectedException e) {
            e.printStackTrace();
        }         if(isSupported) {
            try {
                vCardManager.loadVCard(conn1.getUser());
            } catch (SmackException.NoResponseException e) {
                e.printStackTrace();
            } catch (XMPPException.XMPPErrorException e) {
                e.printStackTrace();
            } catch (SmackException.NotConnectedException e) {
                e.printStackTrace();
            }
        }

Here is the debug trace:

SENT (0): <iq to='ctest@example.com/Smack' id='7W4lM-14' type='get'><vCard xmlns='vcard-temp'/></iq>
RECV (0): <iq from='ctest@example.com/Smack' to='ctest@example.com/Smack' xml:lang='en' id='7W4lM-14' type='get'><vCard xmlns='vcard-temp'/></iq>
SENT (0): <iq to='ctest@example.com/Smack' id='7W4lM-14' type='error'><error type='cancel'><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>
RECV (0): <iq from='ctest@example.com/Smack' to='ctest@example.com/Smack' xml:lang='en' id='7W4lM-14' type='error'><error type='cancel'><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>

I have also included this iqproviderextension:

ProviderManager pm = new ProviderManager();
        pm.addIQProvider("vCard", "vcard-temp", new VCardProvider());

The error that I receive is this:

W/System.err﹕ org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: feature-not-implemented - cancel
W/System.err﹕ at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:232)
W/System.err﹕ at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:213)
W/System.err﹕ at org.jivesoftware.smackx.vcardtemp.VCardManager.loadVCard(VCardManager.java:125)
W/System.err﹕ at app.example.com.connections.LoginFragment.loadvCard(LoginFragment.java:147)
W/System.err﹕ at app.example.com.connections.LoginFragment$3.onClick(LoginFragment.java:81)
W/System.err﹕ at android.view.View.performClick(View.java:4754)
W/System.err﹕ at android.view.View$PerformClick.run(View.java:19605)
W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:733)
W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err﹕ at android.os.Looper.loop(Looper.java:146)
W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5752)
W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)

Thank you for your help!

Just to clarify, I’m able to get my own vCard using the loadVCard() method, but trying to query for another person’s VCard still yields the same result feature not implemented result.

I figured out the error. The JID being reported to me was user@example.com/Smack. I thought that this was the JID to query the server and the isSupported method said that it was supported. According to the Debug, it was sending it back as user@example.com. I wouldn’t have known that if I hadn’t enabled debugging. Thanks Flow, I wouldn’t have figured that out if you hadn’t suggested enabling debug (I didn’t know that existed). Thank you for your help!

You are welcome.