Not logged in. · Lost password · Register
Forum: XMPP Protocol RSS
Page:  1  2  next
Avatar
Aatif Ali #1
Member since Feb 2007 · 19 posts · Location: Islamabd
Group memberships: Members
Show profile · Link to this post
Subject: Hash for avators
As i am working on avators and i got some helping material via this forum but i can't able to generate the hash code (binary) for image also i don't know which technique of hashing can be interprated by jabber servers. can anybody tell me little bit about hash in avators?? or any idea of how to implement it for jabber servers.
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by from XEP:
The <x/> element in the jabber:x:avatar namespace contains a SHA1 hash (hexadecimal, not base64) of the image data itself (not the base64-encoded version) in a <hash/> element. (Because the odds of creating an identical hash are small, the hash is considered unique to the image and can be used to cache images between client sessions, resulting in fewer requests for the image.) The initial announcement of the availability of an avatar is done by sending a presence packet with the jabber:x:avatar information, as follows:
Avatar
Aatif Ali #3
Member since Feb 2007 · 19 posts · Location: Islamabd
Group memberships: Members
Show profile · Link to this post
Subject: Setting Avator,Vcard
 i hav written a code for Vcard and my Code Foe Setting Vcard photo is...
    VcardIq viq = new VcardIq(IqType.set, new Jid(_connection.Server));
                        viq.Id="vc1";
                        viq.From=_connection.MyJID;
                       
                   
                        viq.Vcard.Photo=new Photo(pictureBox3.Image,ImageFormat.Jpeg);//ImageFormat.Jpeg
           
                    _connection.Send(viq);
and when i send this code i receive this message

send<iq xmlns="jabber:client" type="set" to="jabber.hot-chilli.net" id="vc1" from="atifaligoldmine@jabber.hot-chilli.net/IPPI"><vCard xmlns="vcard-temp"><PHOTO><TYPE>image/jpeg</TYPE><BINVAL>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</BINVAL></PHOTO></vCard></iq>



RECV: <iq xmlns="jabber:client" from="jabber.hot-chilli.net" to="atifaligoldmine@jabber.hot-chilli.net/IPPI" type="error" id="vc1"><vCard xmlns="vcard-temp"><PHOTO><TYPE>image/jpeg</TYPE><BINVAL>AAAAAAAAAAAAAAAAAAA=</BINVAL></PHOTO></vCard><error code="405" type="cancel"><not-allowed xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></iq>

and return this error can u figure me out where i m goin wrong in Code..
Avatar
Alex #4
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hm no, looks OK for me.
The from attribute is not required, it's optional.
Can you try to set some other fields in the vCard like name, email and nickname without a photo?

Alex
Avatar
Aatif Ali #5
Member since Feb 2007 · 19 posts · Location: Islamabd
Group memberships: Members
Show profile · Link to this post
Subject: Avators Update
Thankx For Reply  Now  I have Don with Avators but There is little bit Problem  When I changed my Avator  it is changed on my side But on client side it   doesnt chaged until i dont get Signout  and next time when i login again it Does Change
  Can u once again help me  and the code for changing my Avator is

private void button1_Click(object sender, System.EventArgs e)
        {
            try
            {
                OpenFileDialog of = new OpenFileDialog();

                if(of.ShowDialog() == DialogResult.OK)
                {
                    string     StrPath = of.FileName;
                    this.senderpic.Image=Image.FromFile(of.FileName);
                    Image img = Image.FromFile(of.FileName);
                VcardIq viq = new VcardIq(IqType.set, new Jid(_connection.Server));
                    viq.Id="vc1";
                viq.To=_connection.MyJID;

                viq.Vcard.Photo=new Photo(senderpic.Image,ImageFormat.Jpeg                                        _connection.Send(viq);
                                }
            }
            catch(Exception ee)
            {
                MessageBox.Show (ee.Message );
            }
           
        }
it works at server side but not at clint side on changed event...
Avatar
Alex #6
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Sorry, but i don't understand your questions and the code you posted.
Avatar
Aatif Ali #7
Member since Feb 2007 · 19 posts · Location: Islamabd
Group memberships: Members
Show profile · Link to this post
Subject: Avators Update
Sorry for bad english actually i have successfully implemet the avators but i can' able to update. i.e when i change my avator it donot apears on other side (i am chatting with) but new avator only apears when i signed out and again sign in again. Here i am also placing my avator code please look into it. Is it possible to add an update tag to it which may work for me or any other solution for this problem.

VcardIq viq = new VcardIq(IqType.set, new Jid(_connection.Server));
viq.Id="vc1";
viq.To=_connection.MyJID;
viq.Vcard.Photo=new Photo(senderpic.Image,ImageFormat.Jpeg);//ImageFormat.Jpeg
_connection.Send(viq);
This post was edited 3 times, last on 2007-02-13, 10:21 by Aatif Ali.
Avatar
Alex #8
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

i don't think you have implemented the avatars completely.
Do you send the Hash of the avatar with your presence?
If your avatars is changing then you also have to notify you contacts that you changed it. And this is done with the Hash in the presence.
So if there is a new Hash in your presence then all your contacts which get your presence know that the avatar changed and they can retrieve the new one.

Alex
Avatar
Aatif Ali #9
Member since Feb 2007 · 19 posts · Location: Islamabd
Group memberships: Members
Show profile · Link to this post
viq.Vcard.Photo=new Photo(senderpic.Image,ImageFormat.Jpeg);//ImageFormat.Jpeg

this line of code will send the hash of image so i don't think i have to resend it again. Is there any other hash that i have to send? if there is any can you give us the xml  or function?
Avatar
Alex #10
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
no, this line of code is sending nothing at all. It's just putting a binary photo into your vcard object.
Avatar
Aatif Ali #11
Member since Feb 2007 · 19 posts · Location: Islamabd
Group memberships: Members
Show profile · Link to this post
so can you give me some reference of hash
Avatar
Alex #12
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
it's at the beginning of this thread.
You have to build a SHA1 Hash of the image date and include this is the your presence information.
Please take a look at the XEP again to see how it works.

Alex
Avatar
Aatif Ali #13
Member since Feb 2007 · 19 posts · Location: Islamabd
Group memberships: Members
Show profile · Link to this post
ok thanks, let me look into that than i will come back to you
Avatar
Aatif Ali #14
Member since Feb 2007 · 19 posts · Location: Islamabd
Group memberships: Members
Show profile · Link to this post
Here i am sending this presence with hash but still i am not able to get the updated image at other end. Do i need to to add some other code to update it??
<presence><x xmlns='jabber:x:avatar'><hash> hash code of my selected image></x></presence>

problem is still there i.e when i signout and than sign in than i can see the updated avator.
Avatar
Alex #15
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Of course you have to.

Your contacts have to store the hash value and compare it with each new presence packet they get from you.
When the Hash changed then they know that there must be a new picture have to retrieve it from your vCard again.

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  next