Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Avatar
acdelemos #1
Member since Feb 2006 · 21 posts · Location: Brazil
Group memberships: Members
Show profile · Link to this post
Subject: Avatar
Hi

How to use option Avatar, i like display the photo between clients.
Avatar is equal to vcard.Photo.

Thanxs
Sorry my poor english.
Avatar
Alex #2
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

there are different ways to display an avatar image.


all of them should be supported by agsXMPP. I have no idea which Jep current client implementaions like pandion or exodus are using. And if you want to stay compatible to them.

Alex
Alexander Gnauck
AG-Software
Avatar
acdelemos #3
Member since Feb 2006 · 21 posts · Location: Brazil
Group memberships: Members
Show profile · Link to this post
Hi Alex.   

You it could say which to me of these is most correct to be used (agsXMPP.protocol.iq.avatar.Avatar or agsXMPP.protocol.iq.avatar.AvatarIq), and where I can use them.  I intend to only show the Avatar in form of chat, if you he will have an example I am grateful.   

Thanxs.
Avatar
Alex #4
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by acdelemos:
... (agsXMPP.protocol.iq.avatar.Avatar or agsXMPP.protocol.iq.avatar.AvatarIq) ...
You need both classes because they belong to each other.

here is a example how you receive a avatar image from a contact

juliet send an avatar IQ to romeo
  1. <iq id="jcl_13" to="romeo@jabber.org/Pandion" type="get"><query xmlns="jabber:iq:avatar"/></iq>

romeo answers the Iq and sends the avatar image to juiliet
  1. <iq id="jcl_13" to="juliet@jabber.org/Exodus" type="result" from="romeo@jabber.org/Pandion">
  2.  <query xmlns="jabber:iq:avatar">
  3.     <data>
  4.       here is the base64 encoded image
  5.     </data>
  6.  </query>
  7. </iq>

Normally clients which use avatars distribute a hash code of their avatar with the presence which looks like this:
  1. <presence from="juliet@jabber.org/Exodus" to="romeo@jabber.org">
  2.  <x xmlns="jabber:x:avatar">
  3.     <hash>1838ad4cb1c70ed5bc2966ac2c12c9b0eb86968d</hash>
  4.  </x>
  5.  <priority>8</priority>
  6. </presence>

You should store the hash. If the hash changes then the user has set a new avatar image and you have to request the image again. Normally you cache the avatars to save bandwidth and don't request them on each login.

Alex
Alexander Gnauck
AG-Software
Avatar
penicylline #5
Member since May 2008 · 4 posts
Group memberships: Members
Show profile · Link to this post
is there another way to set avatar except use photo element in Vcard data?
Avatar
Jabberer #6
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
there is:
Software Developer
AG-Software
Avatar
penicylline #7
Member since May 2008 · 4 posts
Group memberships: Members
Show profile · Link to this post
I have a question. The value in tag "hash" is a string with 40 character but when I use hash with "sha-1"  function ( C#), return value is a byte array with 20 bytes. Must I convert 20 bytes to Hex string?
 my code here:
            Vcard vc = new Vcard();
            vc.Photo = new Photo(pictureBox1.Image, System.Drawing.Imaging.ImageFormat.Png);
            /////////////////////////////
            SHA1 sh = SHA1.Create();
            MemoryStream m = new MemoryStream();
            vc.Photo.Image.Save(m,System.Drawing.Imaging.ImageFormat.Png);
            string s = BitConverter.ToString(sh.ComputeHash(m.ToArray()));
            s.Replace("-", "");
            rtb.Text = s;
    // s is hash string in the hash tag.
is this righ?
This post was edited on 2008-05-29, 07:52 by penicylline.
Avatar
Jabberer #8
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
yes, most(all) Hashes in XMPP are handled this way.
A function for this is in the agsXMPP source code. Look for HexToString at:
http://svn.ag-software.de/ags/trunk/agsxmpp/util/Hash.cs
Software Developer
AG-Software
This post was edited on 2008-05-29, 09:45 by Jabberer.
Avatar
penicylline #9
Member since May 2008 · 4 posts
Group memberships: Members
Show profile · Link to this post
My avatar is a picture with lage size, must I resize it to smaller before I use this command:
            vc.Photo = new Photo(pictureBox1.Image, System.Drawing.Imaging.ImageFormat.Png);
additional: the source format of this picture is jpg.
Avatar
Jabberer #10
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
you should resize it. Depending on the server you are using the size is not limited. But you should allow you users only to set images with small filesize. Eg max 10K or something like that.
You can choose the image format between different type. If I remember correctlthe MiniClient detects it automatically in the vcard.
Software Developer
AG-Software
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:
Forum: agsXMPP SDK Support RSS