Not logged in. · Lost password · Register
Forum: agsXMPP RSS
I am unable to get the photo from an openfire vcard
Page:  1  2  3  next
Avatar
rheuser #1
Member since Aug 2008 · 25 posts · Location: Fremont, Ca, USA
Group memberships: Members
Show profile · Link to this post
Subject: Getting Photo from Vcard
I have written the following code:

  1.     public void GetPhoto(Jid jid, XmppClientConnection xmppCon, string PhotoHash)
  2.     {
  3.       VcardIq viq = new VcardIq(IqType.get, new Jid(jid.Bare));
  4.       packetId = viq.Id;
  5.       xmppCon.IqGrabber.SendIq(viq, new IqCB(VcardResult), null);
  6.     }
  7.  
  8.     private void VcardResult(object sender, IQ iq, object data)
  9.     {
  10.       if (iq.Type == IqType.result)
  11.       {
  12.         Vcard vcard = iq.Vcard;
  13.         if (vcard != null)
  14.         {
  15.           string fullname = vcard.Fullname;
  16.           string nickname = vcard.Nickname;
  17.           string description = vcard.Description;
  18.           Photo photo = vcard.Photo;
  19.           if (photo != null)
  20.           {
  21.             OnPhotoReceived(sender, iq.From, photo);
  22.           }
  23.           else
  24.           {
  25.           }
  26.         }
  27.       }
  28.     }

This code works great with Gtalk.  However, when I use it with Openfire, the photo is null even when the Vcard XML has a photo.  Here is an example.  What am I doing wrong?

photo = null

{<vCard xmlns="vcard-temp"><VERSION>2.0</VERSION><JABBERID>mheuser\40cadorian.com@aim.localhost</JABBERID><NICKNAME>Madolyn Heuser</NICKNAME><PHOTO><TYPE>image/jpeg</TYPE><BINVAL>R0lGODlhMAAwAPcAAPFdOTo6Om4mG/aQdPNxW/m3raowH/NtUfJmQVkyKyUlJfecie9IJPFVPvWH
c+8+I/eehWAzLSkpKfNsSfrEu/mynPWOcf718jg4OPJgRPinjvN1VPSBYvFbP/aSeO9AJM1QPBoa
Gu9DJCwXFPR5WaU2JvNxTv3o5Pipke9CJCIiIvvBrPm5rfJkTJwtHfJqTh0dHfBSLPBVLvehkvvP
yPNyUNY6I/JpSfvItPWKbfmvmPaXffSFa3Q1KxUVFfzUwfmyofBWMDQ0NDIyMhEREfJtW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nNBoIIIOMM1dhftHLhaxBzQIUAnRGEMa
/7BwOhcQIQAYsMIQ0qEKFQjABg/Ig8zGNgk6vKANkBhDK3iABD0wAQrFiMcN0HCDA6jPAUNsXR/+
lKwRHBGJ2fCHFlRRDRhQwgAf0MQd9MDHPt4hBrPIRyPeAQBckPEAcsAECadAhmYlkBw+CAA+4LjE
JsJgHiOghAuM0Y461OEMjWjEIt6wB0Oi4QWIVCQWitAARzbLBeQggg9AgQ9QUHIdEpBGHecxDx+M
QADoUAc13vEGXNwAlXJowQsyQIZKZIlyr3OkC0YghhHMIxX6AAU/8AEMJdIiHKrQJQxCwEsf+EBk
rnRdCvLAgLFBYmwMOI9oYCmGbRggBNrERyq2Cf+MBcLCCOwIpwrqGAJy+uxniHtXy2Iggxjs6zPB
oEQsZRmCavDjohidJAbcN4RxaEECqlDAQKuxjQ49AHGdYIIMzlCFRQDgpYvolS4yQQ5I+iAEMJAG
RneKD41qYw4R2MQ40sEONyjCpFLUg5gAkAhCIIAUfCAFApDhRiLIch4VlYYEdsrVngZgDvbAQzpf
CI8YnAEAniBFFx5VAyn0gKZWNec8YFANBUjACFzN6zYDAIw57MIcePBRFOEhpkQgYAJS4MU+EgDX
uPoAqzBQgSq0wAZu6DWvk+ynFYTgj3RIQAWX9IFVRztac8oVpyqwqxH8IQRtXLarfE0iZ42Qy2qF
kNO0uH1sQemaWgmkgw1CsAIGgPFanvJVG9ngBhs8K1IYjLOg0HUub6WhCt9WNhvDlWRxM6rRzXb0
owqQhgrGS97xSsOuEuiSP7iBXWBod7vG1awQlDtULbBDAviVADvYoQXkjGO9wc0uPuCL2cxudLPc
4MYQCqKhBAshG8LFQADeu9OAAAA7</BINVAL></PHOTO></vCard>}
This post was edited on 2014-02-20, 12:23 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

I looked at the code several times and see no reason why this Xml should not work.

Can you please post or attach the complete stanza from GTalk where it works and Openfire where it doesn't?
Then I can compare the Xml. You can cut the base64 image data because it can be huge, but this should be no problem.
Are you on the .NET compact Framework or the normal Framework?
 If the
Thanks,
Alex
Avatar
rheuser #3
Member since Aug 2008 · 25 posts · Location: Fremont, Ca, USA
Group memberships: Members
Show profile · Link to this post
Subject: requested iq stanzas
Alex,

I am using .Net Compact Framework 2 on the Sony Xperia. Both clients call the same routine to get the photo.

Here is the working one from Gtalk with the binary image removed; with this one vcard.photo contains the photo;

{<iq xmlns="jabber:client" type="result" from="Madolyn.Heuser@gmail.com" to="dick.heuser@gmail.com/GtalkTestW5DA1E668" id="agsXMPP_5"><vCard xmlns="vcard-temp"><FN>Madolyn Heuser</FN><PHOTO><TYPE>image/png</TYPE><BINVAL></BINVAL></PHOTO></vCard></iq>}


Here is the one from the OpenFire server that does not work; with this one, vcard.photo is null;

{<iq xmlns="jabber:client" type="result" from="madolyn.heuser\40gmail.com@gtalk.localhost" to="dickheuser@localhost/OpenFireWindowsMobileClient" id="agsXMPP_16"><vCard xmlns="vcard-temp"><VERSION>2.0</VERSION><JABBERID>madolyn.heuser\40gmail.com@gtalk.localhost</JABBERID><NICKNAME>madolyn.heuser</NICKNAME><PHOTO><TYPE>image/jpeg</TYPE><BINVAL></BINVAL></PHOTO></vCard></iq>}

These are both for the same contact on Gtalk.

By the way, is there a property that gives me the Hashtotal of the photo from the presence or do I have to parse that myself?

Best regards,
Dick Heuser
Avatar
Alex #4
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi Dick,

I tried to cause your problem with this small code snippet, but I can't.

  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3.     string xml = @"<iq xmlns='jabber:client' type='result' from='madolyn.heuser\40gmail.com@gtalk.localhost' to='dickheuser@localhost/OpenFireWindowsMobileClient' id='agsXMPP_16'><vCard xmlns='vcard-temp'><VERSION>2.0</VERSION><JABBERID>madolyn.heuser\40gmail.com@gtalk.localhost</JABBERID><NICKNAME>madolyn.heuser</NICKNAME><PHOTO><TYPE>image/jpeg</TYPE><BINVAL>ABCD</BINVAL></PHOTO></vCard></iq>";
  4.     Document doc = new Document();
  5.     doc.LoadXml(xml);
  6.  
  7.     Console.WriteLine(doc.ToString());
  8. }

See my attached screenshot from the debugger, the photo is there.

Can you please try to debug the code step by step and try to see why photo is null in your case?

Alex
The author has attached one file to this post:
debug.png 90.8 kBytes
You have no permission to open this file.
Avatar
Alex #5
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #3
Quote by rheuser:
By the way, is there a property that gives me the Hashtotal of the photo from the presence or do I have to parse that myself?

no, currently not, but all the Hashing functions come with the .NET Framework and agsXMPP gives you all useful helper functions to them in the Util class. So you can build the Hash yourself with one line of code.

Alex
Avatar
rheuser #6
Member since Aug 2008 · 25 posts · Location: Fremont, Ca, USA
Group memberships: Members
Show profile · Link to this post
Subject: Getting Photo Hashtotal from Presence
Actually, I was interested in the other end.  I want to extract the Hashtotal from the Presence when it is received.  There are properties in the Presence class for Show, Status and Type but not for the Photo Hash.  Or am I missing something?  I wrote the code to parse the XML and find the Hashtotal so that I can compare it to the one stored but since you already parse for almost all the other data in the Presence, I was surprised that there is not a property for the Hashtotal of the Photo.
Avatar
Alex #7
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I think what you are looking for is the presence which includes the hash and looks like this:

  1. <presence from='juliet@capulet.com/balcony'>
  2.  <x xmlns='vcard-temp:x:update'>
  3.     <photo>sha1-hash-of-image</photo>
  4.  </x>
  5. </presence>

There is the VcardUpdate class in the agsXMPP.protocol.x.vcard_update namespace which gives you this object.
You can get this object with teh following code:

  1. VcardUpdate update = pres.SelectSingleElement(typeof(VcardUpdate )) as VcardUpdate;

there is no property for this in presence because current clients add so many different infos to their presence. If we add all this properties the presence class is overloaded with to many infos which is causing lots of confusion to XMPP newbies.

You also should not use this anymore today because constraint clients (eg. mobile phones) are not happy about all this extra stuff in presence packets. Pubsub or PEP is what you should use today.

See also:
XEP-0060: Publish-Subscribe
XEP-0084: User Avatar
XEP-0163: Personal Eventing via Pubsub

Regards,
Alex
Avatar
rheuser #8
Member since Aug 2008 · 25 posts · Location: Fremont, Ca, USA
Group memberships: Members
Show profile · Link to this post
In reply to post #4
Alex,

I am unclear what would help debug this problem and what you mean by step by step.

Here is the iq returned but I cut the binary photo value:
{<iq xmlns="jabber:client" type="result" from="mheuser\40cadorian.com@aim.localhost" to="dickheuser@localhost/OpenFireWindowsMobileClient" id="agsXMPP_16"><vCard xmlns="vcard-temp"><VERSION>2.0</VERSION><JABBERID>mheuser\40cadorian.com@aim.localhost</JABBERID><NICKNAME>Madolyn Heuser</NICKNAME><PHOTO><TYPE>image/jpeg</TYPE><BINVAL></BINVAL></PHOTO></vCard></iq>}

here is the Vcard also with the binary photo cut:
{<vCard xmlns="vcard-temp"><VERSION>2.0</VERSION><JABBERID>mheuser\40cadorian.com@aim.localhost</JABBERID><NICKNAME>Madolyn Heuser</NICKNAME><PHOTO><TYPE>image/jpeg</TYPE><BINVAL></BINVAL></PHOTO></vCard>}

I included a screen shot with the value of local variables at the time of the problem.  I do not know how to get the kind of screen shot that you took that shows the expanded objects and their values.  If you can tell me more of what would be helpful, I will be happy to try to get it.  Would access to our Openfire server help you?

Best regards,
Dick Heuser
The author has attached one file to this post:
Screen Shot for Photo Problem.jpg 339 kBytes
You have no permission to open this file.
Avatar
Alex #9
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by rheuser:
I do not know how to get the kind of screen shot that you took that shows the expanded objects and their values.
this is the tooltip when I hover over the variable in the source code. I think this tooltips care there since VS2005. I was using 2008 when creting this screenshot.

Alex
Avatar
Alex #10
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #8
Quote by rheuser:
I am unclear what would help debug this problem and what you mean by step by step.

I mean debugging your code with agsXMPP in debug mode. If I understood it correctly you have the IQ and Vcard objects. But the photo object is missing and its creating a standard element instead of the photo object. Am I correct? I think when you parse it manual you can find the info.
So something is going wrong when the parser is building the objects using the ElementFactory. You you have to set a breakpoint when the vcard response comes over the socket in ClientSocket OnReceive and see why its not creating the photo object.

Again to clarify.
You are in the same session without disconnect and reconnect when it works for GTalk but not for Openfire?
Because I have seen the Photo stuff failing on my machine soemtimes as well, or raising compiler errors in VS2005 and CF. After clearing the cache and recompiling it worked fine. On my machine it was always related to System.Drawing which is referenced only by the photo class.

Thanks,
Alex
Avatar
rheuser #11
Member since Aug 2008 · 25 posts · Location: Fremont, Ca, USA
Group memberships: Members
Show profile · Link to this post
In reply to post #9
Subject: Tooltip
Alex,

I understand how to get the tooltip box to popup showing the object values, but when I try to take a screen shot by press alt-shift-PrtScn the tooltip disappears and is not in the screen shot.  How do you take the screen shot with the tooltip information showing?
Avatar
rheuser #12
Member since Aug 2008 · 25 posts · Location: Fremont, Ca, USA
Group memberships: Members
Show profile · Link to this post
In reply to post #10
Subject: Same session
Alex,
Yes, it is the same session where the Photo Object was built from the Presence received from Gtalk and the Photo object was not built using the Presence received from Openfire.  It is very consistent and easily repeated.  So, I will try to gather the data that you want from ClientSocket OnReceive.

Regards,
Dick
Avatar
rheuser #13
Member since Aug 2008 · 25 posts · Location: Fremont, Ca, USA
Group memberships: Members
Show profile · Link to this post
In reply to post #10
Subject: Debug
Alex,

OK.  Everything is running in Debug mode.  I have installed the ClientSocket OnReceive Event Handler.  It gets all of the data just fine.  The data seems OK.  But when the Vcard is received in the VcardResultHandler, the Vcard.photo property is null.  I have attached another screen shot.  However, I am sure that this is not what you need.  I am still unsure how to get the data that you need.

Regards,
Dick
The author has attached one file to this post:
ScreenShot for Alex.jpg 307.3 kBytes
You have no permission to open this file.
Avatar
rheuser #14
Member since Aug 2008 · 25 posts · Location: Fremont, Ca, USA
Group memberships: Members
Show profile · Link to this post
In reply to post #10
Subject: OpenFire
Alex,

I would be happy to get you access to our OpenFire server since it is a development machine if that would help you.  Then you could debug it on your own machine.
Avatar
Alex #15
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #12
Quote by rheuser:
Yes, it is the same session where the Photo Object was built from the Presence received from Gtalk and the Photo object was not built using the Presence received from Openfire.  It is very consistent and easily repeated.  So, I will try to gather the data that you want from ClientSocket OnReceive.

so your Openfire server must be on the federated network. Can you create an test account for me and set such a vcard which is causing the problems?

Alex
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  3  next
Forum: agsXMPP RSS